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;
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;
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;
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;
import vtk.vtkSSAAPass;
import vtk.vtkSequencePass;
import vtk.vtkSimpleMotionBlurPass;
-import vtk.vtkSobelGradientMagnitudePass;
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<Resource,INode> mapping;
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
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();
return new NodeSelectionProvider2<Resource,INode>(this,mapping,nodeMap);
}
- protected HoverHighlighter createHoverHighlhighter() {
- return new HoverHighlighter(panel,nodeMap);
+ protected HoverHighlighter<Resource> createHoverHighlhighter() {
+ return new HoverHighlighter<>(panel,nodeMap);
}
- protected SelectionHighlighter<Resource,INode> createSelectionHighlighter() {
- return new SelectionHighlighter<Resource,INode>(panel,nodeMap);
+ protected SelectionHighlighter<Resource> createSelectionHighlighter() {
+ return new SelectionHighlighter<Resource>(panel,nodeMap);
}
protected String getLibraryUri() {
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() {
}
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) {
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);
}
return outlinePage;
}
- @SuppressWarnings("rawtypes")
@Override
- public Object getAdapter(Class adapter) {
- if (IPropertyPage.class.equals(adapter))
- return new StandardPropertyPage(getSite(),getPropertyContexts());
- if (IContentOutlinePage.class.equals(adapter)) {
- return createOutline();
+ public <T> T getAdapter(Class<T> adapter) {
+ if (adapter.isAssignableFrom(IPropertyPage.class))
+ return adapter.cast(new StandardPropertyPage(getSite(),getPropertyContexts()));
+ if (adapter.isAssignableFrom(ISelectionProvider.class))
+ return adapter.cast(selectionProvider);
+ if (adapter.isAssignableFrom(IContentOutlinePage.class)) {
+ return adapter.cast(createOutline());
}
- if (NodeMap.class.equals(adapter)) {
- return nodeMap;
+ if (adapter.isAssignableFrom(NodeMap.class)) {
+ return adapter.cast(nodeMap);
}
- if (INode.class.equals(adapter)) {
- return rootNode;
+ if (adapter.isAssignableFrom(INode.class)) {
+ return adapter.cast(rootNode);
}
- if (IMapping.class.equals(adapter)) {
- return mapping;
+ if (adapter.isAssignableFrom(IMapping.class)) {
+ return adapter.cast(mapping);
}
-// if (InteractiveVtkPanel.class.equals(adapter)) {
-// return panel;
+// if (adapter.isAssignableFrom(InteractiveVtkPanel.class)) {
+// return adapter.cast(panel);
// }
- if (VtkView.class.equals(adapter))
- return panel;
- if (ISelectionProvider.class.equals(adapter))
- return selectionProvider;
+ if (adapter.isAssignableFrom(VtkView.class))
+ return adapter.cast(panel);
return super.getAdapter(adapter);
}