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

Function main

Examples/Infovis/Cxx/MultiView.cxx:49–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47};
48
49int main(int, char*[])
50{
51 vtkMutableDirectedGraph* graph = vtkMutableDirectedGraph::New();
52 vtkIdType a = graph->AddVertex();
53 vtkIdType b = graph->AddChild(a);
54 vtkIdType c = graph->AddChild(a);
55 vtkIdType d = graph->AddChild(b);
56 vtkIdType e = graph->AddChild(c);
57 vtkIdType f = graph->AddChild(c);
58
59 vtkStringArray* labels = vtkStringArray::New();
60 labels->SetName("Label");
61 labels->InsertValue(a, "a");
62 labels->InsertValue(b, "b");
63 labels->InsertValue(c, "c");
64 labels->InsertValue(d, "d");
65 labels->InsertValue(e, "e");
66 labels->InsertValue(f, "f");
67 graph->GetVertexData()->AddArray(labels);
68
69 vtkTree* tree = vtkTree::New();
70 bool validTree = tree->CheckedShallowCopy(graph);
71 if (!validTree)
72 {
73 std::cout << "ERROR: Invalid tree" << std::endl;
74 graph->Delete();
75 labels->Delete();
76 tree->Delete();
77 return EXIT_FAILURE;
78 }
79 vtkGraphLayoutView* view = vtkGraphLayoutView::New();
80 vtkDataRepresentation* rep = view->SetRepresentationFromInput(tree);
81 vtkViewTheme* theme = vtkViewTheme::CreateMellowTheme();
82 view->ApplyViewTheme(theme);
83 view->SetVertexColorArrayName("VertexDegree");
84 view->SetColorVertices(true);
85 view->SetVertexLabelArrayName("Label");
86 view->SetVertexLabelVisibility(true);
87
88 vtkGraphLayoutView* view2 = vtkGraphLayoutView::New();
89 vtkDataRepresentation* rep2 = view2->SetRepresentationFromInput(tree);
90 view2->SetVertexLabelArrayName("Label");
91 view2->SetVertexLabelVisibility(true);
92
93 vtkAnnotationLink* link = vtkAnnotationLink::New();
94 rep->SetAnnotationLink(link);
95 rep2->SetAnnotationLink(link);
96
97 ViewUpdater* update = ViewUpdater::New();
98 update->AddView(view);
99 update->AddView(view2);
100
101 view->ResetCamera();
102 view2->ResetCamera();
103 view->Render();
104 view2->Render();
105 view->GetInteractor()->Start();
106

Callers

nothing calls this directly

Calls 15

GetVertexDataMethod · 0.80
DeleteMethod · 0.65
RenderMethod · 0.65
NewFunction · 0.50
AddVertexMethod · 0.45
AddChildMethod · 0.45
SetNameMethod · 0.45
InsertValueMethod · 0.45
AddArrayMethod · 0.45
CheckedShallowCopyMethod · 0.45
ApplyViewThemeMethod · 0.45

Tested by

no test coverage detected