Action to be taken upon graph file open
| 74 | |
| 75 | // Action to be taken upon graph file open |
| 76 | void StatsView::slotOpenSQLiteDB() |
| 77 | { |
| 78 | // Browse for and open the file |
| 79 | QDir dir; |
| 80 | |
| 81 | // Open the text data file |
| 82 | QString fileName = QFileDialog::getOpenFileName(this, "Select the SQLite database file", |
| 83 | QDir::homePath(), "SQLite Files (*.db);;All Files (*.*)"); |
| 84 | |
| 85 | if (fileName.isNull()) |
| 86 | { |
| 87 | std::cerr << "Could not open file" << endl; |
| 88 | return; |
| 89 | } |
| 90 | |
| 91 | // Create SQLite reader |
| 92 | QString fullName = "sqlite://" + fileName; |
| 93 | vtkSQLiteDatabase* db = |
| 94 | vtkSQLiteDatabase::SafeDownCast(vtkSQLDatabase::CreateFromURL(fullName.toUtf8().data())); |
| 95 | bool status = db->Open(""); |
| 96 | if (!status) |
| 97 | { |
| 98 | std::cerr << "Couldn't open database.\n"; |
| 99 | return; |
| 100 | } |
| 101 | |
| 102 | // Query database |
| 103 | vtkSQLQuery* query = db->GetQueryInstance(); |
| 104 | query->SetQuery("SELECT * from main_tbl"); |
| 105 | this->RowQueryToTable->SetQuery(query); |
| 106 | |
| 107 | // Calculate descriptive statistics |
| 108 | VTK_CREATE(vtkDescriptiveStatistics, descriptive); |
| 109 | descriptive->SetInputConnection(0, this->RowQueryToTable->GetOutputPort()); |
| 110 | descriptive->AddColumn("Temp1"); |
| 111 | descriptive->AddColumn("Temp2"); |
| 112 | descriptive->Update(); |
| 113 | |
| 114 | // Calculate order statistics -- quartiles |
| 115 | VTK_CREATE(vtkOrderStatistics, order1); |
| 116 | order1->SetInputConnection(0, this->RowQueryToTable->GetOutputPort()); |
| 117 | order1->AddColumn("Temp1"); |
| 118 | order1->AddColumn("Temp2"); |
| 119 | order1->SetQuantileDefinition(vtkOrderStatistics::InverseCDFAveragedSteps); |
| 120 | order1->Update(); |
| 121 | |
| 122 | // Calculate order statistics -- deciles |
| 123 | VTK_CREATE(vtkOrderStatistics, order2); |
| 124 | order2->SetInputConnection(0, this->RowQueryToTable->GetOutputPort()); |
| 125 | order2->AddColumn("Temp1"); |
| 126 | order2->AddColumn("Temp2"); |
| 127 | order2->SetNumberOfIntervals(10); |
| 128 | order2->Update(); |
| 129 | |
| 130 | // Calculate correlative statistics |
| 131 | VTK_CREATE(vtkCorrelativeStatistics, correlative); |
| 132 | correlative->SetInputConnection(0, this->RowQueryToTable->GetOutputPort()); |
| 133 | correlative->AddColumnPair("Temp1", "Temp2"); |
nothing calls this directly
no test coverage detected