[vtkusers] connection vtkQtTree - vtkGraphLayoutView
Jeff Baumes
jeff.baumes at kitware.com
Mon Mar 14 13:07:52 EDT 2011
I do not know of a simple way to make this difference in selections go away.
The vtkGraphLayoutView generates vertex + edge selections, and vtkQtTreeView
generates vertex-only selections. I believe the best solution is to have
vtkGraphLayoutView have an option to not select edges, as you suggested. If
you are interested in adding that option, you can patch
vtkGraphLayoutView.cxx to add some checks in ConvertSelection() based on a
new boolean member variable and submit it to us for inclusion in VTK, or you
could subclass vtkGraphLayoutView and reimplement ConvertSelection() if you
want to just get it working for your own application.
Jeff
On Fri, Mar 11, 2011 at 4:41 PM, Nicolas Rannou <
nicolas_rannou at hms.harvard.edu> wrote:
> Hi all,
>
> I'm trying to connect a vtkQtTree and a vtkGraphLayout but the selection
> is not working as expected.
>
> When I select something in the vtkGraphLayout, the selection can contain
> vertices and edges.
> When I select something in the vtkQtTree, the selection only contains
> vertices.
>
> If I select edges + vertices in the vtkGraphLayout, i.e. vertices: 1 and
> 4, edge:3, it highlights *vertices* 1,3,4 in the vtkQtTree...
>
> Then I have 3 questions/issues:
> (see pseudo-code at the end of the email)
>
> #1: should I modify the structure of my vtkTree (Add specific arrays for
> vertices/edges?) so the vtkQtTree handles properly selection of
> edges+vertices?
>
> #2: can I get my vtkQtTree to return the edges? Or should I find the edges
> after it returns the vertices (is there an efficient way to do it?)?
>
> #3: is there a straight forward way to disable edges selection in the
> vtkGraphLayoutView? (Something like: EdgesNotSelectable()?)
>
>
> Thanks,
>
>
> Nicolas
>
>
> // What I do
>
> I first create a graph and add some arrays associated to the *vertices*.
> vtkSmartPointer<vtkMutableDirectedGraph> graph =
> vtkSmartPointer<vtkMutableDirectedGraph>::New();
> vtkIdType a = graph->AddVertex();
> vtkIdType b = graph->AddChild(a);
> vtkIdType c = graph->AddChild(a);
>
> vtkSmartPointer<vtkStringArray> cellType =
> vtkSmartPointer<vtkStringArray>::New();
> cellType->SetName("name");
> cellType->InsertValue(a, "TypeA");
> cellType->InsertValue(b, "TypeB");
> cellType->InsertValue(c, "TypeC");
>
> graph->GetVertexData()->AddArray(cellType);
> ...
>
> I convert the graph to a vtkTree and add this representation to the
> vtkQtTree and to the vtkGraphLayout.
>
> I connect the views through vtkAnnotations and vtkEventQtSlotConnect.
> this->m_annotationLink = vtkSmartPointer<vtkAnnotationLink>::New();
>
> this->m_treeGraphView->GetRepresentation()->SetAnnotationLink(this->m_annotationLink);
>
> this->m_treeTableView->GetRepresentation()->SetAnnotationLink(this->m_annotationLink);
>
> this->m_connect = vtkSmartPointer<vtkEventQtSlotConnect>::New();
> this->m_connect->Connect(this->m_treeTableView->GetRepresentation(),
> vtkCommand::SelectionChangedEvent,
> this, SLOT(selectionChanged(vtkObject*, unsigned long, void*, void*)));
> this->m_connect->Connect(this->m_treeGraphView->GetRepresentation(),
> vtkCommand::SelectionChangedEvent,
> this, SLOT(selectionChanged(vtkObject*, unsigned long, void*, void*)));
>
> selectionChanged() only call update on the 2 views
>
> _______________________________________________
> 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
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
--
Jeff Baumes, Ph.D.
Technical Lead, Kitware Inc.
(518) 881-4932
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110314/2d1bb758/attachment.htm>
More information about the vtkusers
mailing list