MCPcopy Create free account
hub / github.com/Kitware/VTK / TestGraphLayoutView

Function TestGraphLayoutView

Views/Infovis/Testing/Cxx/TestGraphLayoutView.cxx:1061–1163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1059 "ExitEvent 276 299 0 0 0 0 0\n";
1060
1061int TestGraphLayoutView(int argc, char* argv[])
1062{
1063 bool record = false;
1064
1065 VTK_CREATE(vtkTesting, testHelper);
1066 testHelper->AddArguments(argc, const_cast<const char**>(argv));
1067 string dataRoot = testHelper->GetDataRoot();
1068 string file = dataRoot + "/Data/treetest.xml";
1069
1070 VTK_CREATE(vtkXMLTreeReader, reader);
1071 reader->SetFileName(file.c_str());
1072 reader->SetMaskArrays(true);
1073 reader->Update();
1074 vtkTree* t = reader->GetOutput();
1075 VTK_CREATE(vtkStringArray, label);
1076 label->SetName("edge label");
1077 VTK_CREATE(vtkIdTypeArray, dist);
1078 dist->SetName("distance");
1079 for (vtkIdType i = 0; i < t->GetNumberOfEdges(); i++)
1080 {
1081 dist->InsertNextValue(i);
1082 switch (i % 3)
1083 {
1084 case 0:
1085 label->InsertNextValue("a");
1086 break;
1087 case 1:
1088 label->InsertNextValue("b");
1089 break;
1090 case 2:
1091 label->InsertNextValue("c");
1092 break;
1093 }
1094 }
1095 t->GetEdgeData()->AddArray(dist);
1096 t->GetEdgeData()->AddArray(label);
1097
1098 VTK_CREATE(vtkStringToNumeric, numeric);
1099 numeric->SetInputData(t);
1100
1101 // Graph layout view
1102 VTK_CREATE(vtkGraphLayoutView, view);
1103 view->DisplayHoverTextOn();
1104 view->SetLayoutStrategyToCircular();
1105 view->SetVertexLabelArrayName("name");
1106 view->VertexLabelVisibilityOn();
1107 view->SetVertexColorArrayName("size");
1108 view->ColorVerticesOn();
1109 view->SetRepresentationFromInputConnection(numeric->GetOutputPort());
1110 view->SetVertexScalarBarVisibility(true);
1111 view->SetEdgeColorArrayName("distance");
1112 view->ColorEdgesOn();
1113 view->SetEdgeLabelArrayName("edge label");
1114 view->EdgeLabelVisibilityOn();
1115 vtkRenderedGraphRepresentation* rep =
1116 vtkRenderedGraphRepresentation::SafeDownCast(view->GetRepresentation());
1117 rep->SetVertexHoverArrayName("name");
1118 rep->SetEdgeHoverArrayName("edge label");

Callers

nothing calls this directly

Calls 15

vtkRegressionTestImageFunction · 0.85
GetEdgeDataMethod · 0.80
ColorVerticesOnMethod · 0.80
ColorEdgesOnMethod · 0.80
GetRepresentationMethod · 0.80
GetScalarBarActorMethod · 0.80
GetVertexScalarBarMethod · 0.80
RenderMethod · 0.65
AddArgumentsMethod · 0.45
GetDataRootMethod · 0.45
SetFileNameMethod · 0.45

Tested by

no test coverage detected