[vtkusers] QVTKWidget and vtkGraphLayoutView

phantomjinx p.g.richardson at phantomjinx.co.uk
Sat May 2 15:51:53 EDT 2015


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Am slowly learning VTK so forgive the crudeness of code but I am trying to integrate a mutable
graph into my QT application.

Following tutorials etc..., I have setup a QVTKWidget and am now inserting into it a
vtkGraphLayoutView, except I just cannot
get it to work. The following causes the application to display rubbish (window displays code from
IDE underneath see [4]) where the QVTKWidget is supposed to be:

   VTK_CREATE(vtkMutableUndirectedGraph, graph);

   // Create 3 vertices
   vtkIdType v1 = graph->AddVertex();
   vtkIdType v2 = graph->AddVertex();
   vtkIdType v3 = graph->AddVertex();

   // Create a fully connected graph
   graph->AddEdge(v1, v2);
   graph->AddEdge(v2, v3);
   graph->AddEdge(v1, v3);

   VTK_CREATE(vtkGraphLayoutView, graphLayoutView);
   graphLayoutView->SetInteractor(parent->GetInteractor());	// [1]
   parent->SetRenderWindow(graphLayoutView->GetRenderWindow()); // [2]
   graphLayoutView->AddRepresentationFromInput(graph);

   VTK_CREATE(vtkCircularLayoutStrategy, circularLayoutStrategy);
   graphLayoutView->SetLayoutStrategy(circularLayoutStrategy);
   graphLayoutView->SetVertexLabelVisibility(true);
   graphLayoutView->SetEdgeLabelVisibility(true);
   graphLayoutView->GetRenderer()->SetBackground(1.0, 0.0, 1.0);

//   [3]
//   VTK_CREATE(vtkCallbackCommand, selectionCallback);
//   selectionCallback->SetCallback(SelectionCallbackFunction);
//
graphLayoutView->GetRepresentation()->GetAnnotationLink()->AddObserver("AnnotationChangedEvent",
selectionCallback);

   graphLayoutView->ResetCamera();
   graphLayoutView->Render();

   graphLayoutView->GetInteractor()->Initialize();
   graphLayoutView->GetInteractor()->Start();

I originally did succeeed in displaying the drawn triangle by replacing lines [1] and [2] with:

    parent->GetRenderWindow()->AddRenderer(graphLayoutView->GetRenderer());

However, no mouse clicks work since the QVTKWidget parent has a different interactor to the
graphLayoutView.

Can someone with far my knowledge than I give me a bump in the right direction.

OS - Fedora 20
VTK - 6.1
QT - 5.4.1

Many thanks.

PGR

[4] http://phantomjinx.co.uk/stuff/qtapp.png
- -- 
Paul Richardson

  * p.g.richardson at phantomjinx.co.uk
  * p.g.richardson at redhat.com
  * pgrichardson at linux.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iEYEARECAAYFAlVFKtkACgkQcthLMIwdEb3eWwCfRue1kKC+FRY5OfR6+WRX+NfC
LqgAn2HCwEXi8RINg0uGRiSAAxQkYdMI
=jyYe
-----END PGP SIGNATURE-----


More information about the vtkusers mailing list