X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.plant3d%2Fsrc%2Forg%2Fsimantics%2Fplant3d%2Feditor%2FPlant3DEditor.java;h=a97be312f5e3605947f3a45a80c2c2a735bce984;hb=e9988b476c8634d67cae75c53a8d084f463d5419;hp=b11cf90e98e2ea1dc35b116c20f1e5b1d8371db9;hpb=ebfe6b0245b5cf9231cecedf0aaacd891eb5d344;p=simantics%2F3d.git diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java b/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java index b11cf90e..a97be312 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java @@ -8,9 +8,12 @@ import java.util.Set; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.layout.GridLayoutFactory; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.swt.SWT; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.layout.FillLayout; @@ -25,6 +28,7 @@ import org.simantics.db.exception.DatabaseException; import org.simantics.g3d.scenegraph.NodeMap; import org.simantics.g3d.scenegraph.RenderListener; import org.simantics.g3d.scenegraph.base.INode; +import org.simantics.g3d.toolbar.ToolComposite; import org.simantics.g3d.vtk.action.RemoveAction; import org.simantics.g3d.vtk.common.HoverHighlighter; import org.simantics.g3d.vtk.common.NodeSelectionProvider2; @@ -46,6 +50,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 +61,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; @@ -87,10 +93,12 @@ import vtk.vtkSimpleMotionBlurPass; public class Plant3DEditor extends ResourceEditorPart { private Composite parent; + protected ToolComposite toolComposite; private Resource input; // private InteractiveVtkPanel panel; // private SWTAWTComponent component; private InteractiveVtkComposite panel; + private P3DRootNode rootNode; private IMapping mapping; @@ -108,13 +116,16 @@ public class Plant3DEditor extends ResourceEditorPart { protected RemoveAndSplitAction removeSplitAction; protected RoutePipeAction routePipeAction; protected AddComponentAction addComponentAction; + protected ReversePipeRunAction reversePipeRunAction; private P3DNodeMap nodeMap; @Override public void createPartControl(Composite parent) { this.parent = parent; - parent.setLayout (new FillLayout ()); + //parent.setLayout (new FillLayout ()); + + // component = new SWTAWTComponent(parent,SWT.NONE) { // // @Override @@ -131,9 +142,17 @@ public class Plant3DEditor extends ResourceEditorPart { IResourceEditorInput rei = (IResourceEditorInput)getEditorInput(); input = rei.getResource(); + toolComposite = new ToolComposite(parent, SWT.BORDER); + toolComposite.setVisible(true); + panel = new InteractiveVtkComposite(parent); + GridLayoutFactory.fillDefaults().margins(0, 0).spacing(0, 0).applyTo(parent); + GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(getPanel().getComponent()); + + GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(toolComposite); + //IActionBars actionBars = getEditorSite().getActionBars(); hookContextMenu(); @@ -160,7 +179,7 @@ public class Plant3DEditor extends ResourceEditorPart { @Override public void run(ReadGraph graph) throws DatabaseException { - System.out.println("START PLANT3D LOAD"); + //System.out.println("START PLANT3D LOAD"); PipingRules.setEnabled(false); IMappingSchema schema = getSchema(graph); mapping = Mappings.createWithListening(schema); @@ -176,7 +195,7 @@ public class Plant3DEditor extends ResourceEditorPart { throw new DatabaseException(e); } - System.out.println("END PLANT3D LOAD"); + //System.out.println("END PLANT3D LOAD"); } }); @@ -243,14 +262,15 @@ public class Plant3DEditor extends ResourceEditorPart { protected void createActions() { focusAction = new FocusAction(panel, cameraAction); - translateAction = new TranslateAction(panel,nodeMap); - translateInlineAction = new TranslateInlineAction(panel, nodeMap); - translateFreeVariableLengthAction = new TranslateFreeVariableLengthAction(panel, getRootNode()); - rotateAction = new RotateAction(panel,nodeMap); + translateAction = new TranslateAction(panel,nodeMap,toolComposite); + translateInlineAction = new TranslateInlineAction(panel, nodeMap,toolComposite); + translateFreeVariableLengthAction = new TranslateFreeVariableLengthAction(panel, getRootNode(), toolComposite); + rotateAction = new RotateAction(panel,nodeMap,toolComposite); removeAction = new RemoveAction(nodeMap); removeSplitAction = new RemoveAndSplitAction(nodeMap); - routePipeAction = new RoutePipeAction(panel,rootNode); + routePipeAction = new RoutePipeAction(panel,rootNode, toolComposite); addComponentAction = new AddComponentAction(panel, rootNode, getLibraryUri()); + reversePipeRunAction = new ReversePipeRunAction(nodeMap); } public void populate() { @@ -273,6 +293,7 @@ public class Plant3DEditor extends ResourceEditorPart { if (nodeMap.isRangeModified()); nodeMap.commit("Load sync"); } catch (Exception e) { + ExceptionUtils.logAndShowError("Failed to load model correctly", e); //throw new DatabaseException(e); } panel.removeListener(this); @@ -398,9 +419,10 @@ public class Plant3DEditor extends ResourceEditorPart { } try { if (selected.size() == 0) { - for (Item eq : P3DUtil.getEquipments(getLibraryUri())) { - m.add(new AddEquipmentAction(rootNode, eq)); - } + m.add(new AddEquipmentAction(rootNode, getLibraryUri())); +// for (Item eq : P3DUtil.getEquipments(getLibraryUri())) { +// m.add(new AddEquipmentAction(rootNode, eq)); +// } } else if (selected.size() == 1) { IP3DNode node = (IP3DNode)selected.get(0); if (node instanceof Equipment) { @@ -454,6 +476,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); }