[vtkusers] Fwd: QVTKWidget and vtkGraphLayoutView

phantomjinx p.g.richardson at phantomjinx.co.uk
Thu May 7 04:43:58 EDT 2015


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

I sent below a few days ago.

Does anyone have any insight into this since I am unable to proceed any further.

Any help much appreciated.

Thanks

Paul


- -------- Forwarded Message --------
Subject: [vtkusers] QVTKWidget and vtkGraphLayoutView
Date: Sat, 02 May 2015 20:51:53 +0100
From: phantomjinx <p.g.richardson at phantomjinx.co.uk>
To: vtkusers at vtk.org

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
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iEYEARECAAYFAlVLJc4ACgkQcthLMIwdEb1JsACglK1jsDft0ezITlnvXEWojmC8
0TEAn0nuFQ2+VpgNvLGD4HOdAGql3XOr
=zZVY
-----END PGP SIGNATURE-----


More information about the vtkusers mailing list