]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
PipeRun reverse action 97/3497/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 11 Nov 2019 17:19:05 +0000 (19:19 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 11 Nov 2019 17:19:05 +0000 (19:19 +0200)
gitlab #51

Change-Id: Ifcfbfec7f5ca964c50e23a303dc55c767b7ce877

org.simantics.plant3d/src/org/simantics/plant3d/actions/ReversePipeRunAction.java [new file with mode: 0644]
org.simantics.plant3d/src/org/simantics/plant3d/editor/P3DContentOutlinePage.java
org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java

diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/actions/ReversePipeRunAction.java b/org.simantics.plant3d/src/org/simantics/plant3d/actions/ReversePipeRunAction.java
new file mode 100644 (file)
index 0000000..f1c08d6
--- /dev/null
@@ -0,0 +1,37 @@
+package org.simantics.plant3d.actions;
+
+import org.eclipse.jface.action.Action;
+import org.simantics.g3d.scenegraph.base.INode;
+import org.simantics.g3d.vtk.common.VTKNodeMap;
+import org.simantics.plant3d.Activator;
+import org.simantics.plant3d.scenegraph.PipeRun;
+import org.simantics.plant3d.scenegraph.controlpoint.PipingRules;
+
+public class ReversePipeRunAction extends Action{
+    
+    private VTKNodeMap<?, ? extends INode> nodeMap;
+    PipeRun run;
+    
+    public ReversePipeRunAction(VTKNodeMap<?, ? extends INode> nodeMap) {
+        setText("Reverse");
+        setImageDescriptor(Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/arrow_refresh.png"));
+        this.nodeMap = nodeMap;
+    }
+    
+    public void setNode(INode node) {
+        if (node instanceof PipeRun) {
+            run = (PipeRun)node;
+            setEnabled(true);
+        } else {
+            setEnabled(false);
+        }
+           
+    }
+    
+    @Override
+    public void run() {
+        PipingRules.reverse(run);
+        nodeMap.commit("Reverse run " + run.getName());
+    }
+
+}
index a4e8bafd14b3d777ebaaa0e69b790d1408c85d0f..f853a02f06c56e04416201fb43d9b72f1bcfe838 100644 (file)
@@ -19,6 +19,7 @@ import org.simantics.g3d.scenegraph.base.ParentNode;
 import org.simantics.g3d.vtk.common.NodeSelectionProvider2;
 import org.simantics.g3d.vtk.common.VTKContentOutlinePage;
 import org.simantics.plant3d.Activator;
+import org.simantics.plant3d.ontology.Plant3D;
 import org.simantics.plant3d.scenegraph.EndComponent;
 import org.simantics.plant3d.scenegraph.Equipment;
 import org.simantics.plant3d.scenegraph.Nozzle;
@@ -117,6 +118,18 @@ public class P3DContentOutlinePage extends VTKContentOutlinePage<Resource, INode
                
        }
        
+       @Override
+       public void propertyChanged(INode node, String id) {
+           // TODO Auto-generated method stub
+           if (node instanceof PipelineComponent) {
+               if (Plant3D.URIs.HasNext.equals(id) || Plant3D.URIs.HasPrevious.equals(id)) {
+                   refershViewer(node.getParent());
+                   return;
+               }
+           }
+           super.propertyChanged(node, id);
+       }
+       
        @Override
        public void dispose() {
                manager.dispose();
index b11cf90e98e2ea1dc35b116c20f1e5b1d8371db9..5d755d06f7e3d6b74f704365d1c8dc06c452551b 100644 (file)
@@ -46,6 +46,7 @@ import org.simantics.plant3d.actions.AddComponentAction;
 import org.simantics.plant3d.actions.AddEquipmentAction;
 import org.simantics.plant3d.actions.AddNozzleAction;
 import org.simantics.plant3d.actions.RemoveAndSplitAction;
+import org.simantics.plant3d.actions.ReversePipeRunAction;
 import org.simantics.plant3d.actions.RoutePipeAction;
 import org.simantics.plant3d.actions.TranslateFreeVariableLengthAction;
 import org.simantics.plant3d.actions.TranslateInlineAction;
@@ -56,6 +57,7 @@ import org.simantics.plant3d.scenegraph.IP3DNode;
 import org.simantics.plant3d.scenegraph.InlineComponent;
 import org.simantics.plant3d.scenegraph.Nozzle;
 import org.simantics.plant3d.scenegraph.P3DRootNode;
+import org.simantics.plant3d.scenegraph.PipeRun;
 import org.simantics.plant3d.scenegraph.PipelineComponent;
 import org.simantics.plant3d.scenegraph.SchemaBuilder;
 import org.simantics.plant3d.scenegraph.TurnComponent;
@@ -108,6 +110,7 @@ public class Plant3DEditor extends ResourceEditorPart {
        protected RemoveAndSplitAction removeSplitAction;
        protected RoutePipeAction routePipeAction;
        protected AddComponentAction addComponentAction;
+       protected ReversePipeRunAction reversePipeRunAction;
        
        private P3DNodeMap nodeMap;
        
@@ -251,6 +254,7 @@ public class Plant3DEditor extends ResourceEditorPart {
                removeSplitAction = new RemoveAndSplitAction(nodeMap);
                routePipeAction = new RoutePipeAction(panel,rootNode);
                addComponentAction = new AddComponentAction(panel, rootNode, getLibraryUri());
+               reversePipeRunAction = new ReversePipeRunAction(nodeMap);
        }
        
        public void populate() {
@@ -454,6 +458,10 @@ public class Plant3DEditor extends ResourceEditorPart {
                                        m.add(removeAction);
                                        m.add(removeSplitAction);
                                        removeSplitAction.setNode(node);
+                               } else if (node instanceof PipeRun) {
+                                   m.add(reversePipeRunAction);
+                                   m.add(removeAction);
+                                   reversePipeRunAction.setNode(node);
                                } else {
                                    m.add(removeAction);
                                }