From: Marko Luukkainen Date: Tue, 29 Oct 2019 12:04:06 +0000 (+0200) Subject: Allow setSelection from other components X-Git-Tag: v1.43.0~162^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=6dd5b348d85e1b5d9dffa9422a01388701b061eb;p=simantics%2F3d.git Allow setSelection from other components Additionally, allow other components to utilize node highlight method gitlab #29 Change-Id: Ifcee2c1691456f389c8460b50cf1235c3750ac42 --- diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/NodeSelectionProvider2.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/NodeSelectionProvider2.java index 5de69f35..d5b8d709 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/NodeSelectionProvider2.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/NodeSelectionProvider2.java @@ -29,6 +29,7 @@ import org.simantics.g3d.scenegraph.base.INode; import org.simantics.g3d.tools.AdaptationUtils; import org.simantics.objmap.graph.IMapping; import org.simantics.objmap.structural.StructuralResource; +import org.simantics.utils.ui.AdaptionUtils; import vtk.vtkProp; @@ -69,6 +70,22 @@ public class NodeSelectionProvider2 implements ISelectionPr @Override public void setSelection(ISelection selection) { + Collection nodes = AdaptionUtils.adaptToCollection(selection, IG3DNode.class); + Collection resources= AdaptionUtils.adaptToCollection(selection, Resource.class); + if (nodes.size() > 0) { + processSelection(selection); + fireSelectionChanged(this); + } else if (resources.size() > 0) { + nodes = new ArrayList(); + for (Resource r : resources) { + JavaObject n = mapping.get((DBObject)r); + if (n instanceof IG3DNode) { + nodes.add((IG3DNode)n); + } + } + processSelection(new StructuredSelection(nodes.toArray())); + fireSelectionChanged(this); + } } diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/SelectionHighlighter.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/SelectionHighlighter.java index 789cfb18..9998f5bf 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/SelectionHighlighter.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/SelectionHighlighter.java @@ -171,7 +171,7 @@ public class SelectionHighlighter implements ISelectionChangedL } - protected void setColor(E node, boolean edge, double color[]) { + public void setColor(E node, boolean edge, double color[]) { for (vtkProp prop : nodeMap.getRenderObjects(node)) { if (prop instanceof vtkActor) { vtkActor act = (vtkActor)prop;