Action to be taken upon graph file open
| 120 | |
| 121 | // Action to be taken upon graph file open |
| 122 | void CustomLinkView::slotOpenXMLFile() |
| 123 | { |
| 124 | // Browse for and open the file |
| 125 | QDir dir; |
| 126 | |
| 127 | // Open the text data file |
| 128 | QString fileName = QFileDialog::getOpenFileName( |
| 129 | this, "Select the text data file", QDir::homePath(), "XML Files (*.xml);;All Files (*.*)"); |
| 130 | |
| 131 | if (fileName.isNull()) |
| 132 | { |
| 133 | std::cerr << "Could not open file" << endl; |
| 134 | return; |
| 135 | } |
| 136 | |
| 137 | // Create XML reader |
| 138 | this->XMLReader->SetFileName(fileName.toUtf8().data()); |
| 139 | this->XMLReader->ReadTagNameOff(); |
| 140 | this->XMLReader->Update(); |
| 141 | |
| 142 | // Set up some hard coded parameters for the graph view |
| 143 | this->GraphView->SetVertexLabelArrayName("id"); |
| 144 | this->GraphView->VertexLabelVisibilityOn(); |
| 145 | this->GraphView->SetVertexColorArrayName("VertexDegree"); |
| 146 | this->GraphView->ColorVerticesOn(); |
| 147 | this->GraphView->SetEdgeColorArrayName("edge id"); |
| 148 | this->GraphView->ColorEdgesOn(); |
| 149 | |
| 150 | // Create a tree layout strategy |
| 151 | VTK_CREATE(vtkTreeLayoutStrategy, treeStrat); |
| 152 | treeStrat->RadialOn(); |
| 153 | treeStrat->SetAngle(360); |
| 154 | treeStrat->SetLogSpacingValue(1); |
| 155 | this->GraphView->SetLayoutStrategy(treeStrat); |
| 156 | |
| 157 | // Set the input to the graph view |
| 158 | this->GraphView->SetRepresentationFromInputConnection(this->XMLReader->GetOutputPort()); |
| 159 | |
| 160 | // Okay now do an explicit reset camera so that |
| 161 | // the user doesn't have to move the mouse |
| 162 | // in the window to see the resulting graph |
| 163 | this->GraphView->ResetCamera(); |
| 164 | |
| 165 | // Now hand off tree to the tree view |
| 166 | this->TreeView->SetRepresentationFromInputConnection(this->XMLReader->GetOutputPort()); |
| 167 | this->ColumnView->SetRepresentationFromInputConnection(this->XMLReader->GetOutputPort()); |
| 168 | |
| 169 | // Extract a table and give to table view |
| 170 | VTK_CREATE(vtkAttributeDataToTableFilter, toTable); |
| 171 | toTable->SetInputConnection(this->XMLReader->GetOutputPort()); |
| 172 | toTable->SetFieldAssociation(vtkDataObject::FIELD_ASSOCIATION_VERTICES); |
| 173 | this->TableView->SetRepresentationFromInputConnection(toTable->GetOutputPort()); |
| 174 | |
| 175 | this->SetupCustomLink(); |
| 176 | |
| 177 | // Hide an unwanted column in the tree view. |
| 178 | this->TreeView->HideColumn(2); |
| 179 |
nothing calls this directly
no test coverage detected