import javax.vecmath.Vector3d;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
import org.simantics.g3d.math.EulerTools;
import org.simantics.g3d.math.EulerTools.Order;
import org.simantics.g3d.math.MathTools;
import org.simantics.g3d.scenegraph.IG3DNode;
import org.simantics.g3d.scenegraph.base.INode;
import org.simantics.g3d.scenegraph.structural.IStructuralNode;
+import org.simantics.g3d.toolbar.ToolComposite;
import org.simantics.g3d.vtk.Activator;
import org.simantics.g3d.vtk.common.VTKNodeMap;
import org.simantics.g3d.vtk.gizmo.RotateAxisGizmo;
//AxisAngle4d rotation = new AxisAngle4d();
Quat4d worldOrientation = new Quat4d();
+ protected ToolComposite toolComposite;
+ protected Combo axisCombo;
+
public void setNode(IG3DNode node) {
this.node = node;
if ((node instanceof IStructuralNode) && ((IStructuralNode)node).isPartOfInstantiatedModel() && !((IStructuralNode)node).isInstantiatedModelRoot()) {
return node;
}
- public RotateAction(InteractiveVtkComposite panel, VTKNodeMap<?, ? extends INode> nodeMap) {
+ public RotateAction(InteractiveVtkComposite panel, VTKNodeMap<?, ? extends INode> nodeMap, ToolComposite toolComposite) {
super(panel);
setImageDescriptor(Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/arrow_rotate_clockwise.png"));
setText("Rotate");
this.nodeMap = nodeMap;
-
+ this.toolComposite = toolComposite;
steps = 36;
angles = new double[steps+1];
dragCursor = Display.getCurrent().getSystemCursor(SWT.CURSOR_CROSS);
}
+ protected void createTools(ToolComposite toolComposite) {
+ Label label = new Label(toolComposite, SWT.READ_ONLY);
+ label.setText("Rotate axis:");
+ axisCombo = new Combo(toolComposite, SWT.READ_ONLY);
+ axisCombo.add("X");
+ axisCombo.add("Y");
+ axisCombo.add("Z");
+ axisCombo.add("Camera");
+ axisCombo.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ Combo c = (Combo)e.getSource();
+ index = c.getSelectionIndex();
+ updateLock();
+ panel.getComponent().setFocus();
+ }
+ });
+ axisCombo.select(index);
+
+ Button close = new Button(toolComposite, SWT.PUSH);
+ close.setText("Close");
+ close.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ panel.useDefaultAction();
+ };
+ });
+ toolComposite.relayout();
+ }
+
public void attach() {
if (node == null)
return;
-
+ if (toolComposite != null) {
+ createTools(toolComposite);
+ }
super.attach();
ThreadUtils.asyncExec(panel.getThreadQueue(), new Runnable() {
public void run() {
}
public void deattach() {
-
+ if (toolComposite != null) {
+ toolComposite.clear();
+ axisCombo = null;
+ }
node = null;
nodeMap.commit("Rotate");
deattachUI();
if (e.getKeyCode() == KeyEvent.VK_G) {
worldCoord = !worldCoord;
}
- gizmo.setType(index);
- panel.refresh();
+
+ updateLock();
+
return true;
}
+ private void updateLock() {
+ gizmo.setType(index);
+ if (axisCombo != null)
+ axisCombo.select(index);
+ panel.refresh();
+ }
+
@Override
public boolean keyReleased(KeyEvent e) {
return false;
private void update() {
Vector3d nodePos = node.getWorldPosition();
- System.out.println(nodePos);
+// System.out.println(nodePos);
gizmo.setPosition(nodePos);
if (worldCoord) {
gizmo.setRotation(new AxisAngle4d());
// intersection point
j.set(i2);
i.cross(j, axis);
- System.out.println("I,J " + i + " " + j);
+// System.out.println("I,J " + i + " " + j);
double angleI = i2.angle(i);
double angleJ = i2.angle(j);
prevAngle = Math.atan2(Math.cos(angleJ), Math.cos(angleI));
taxis = new Vector3d(axis);
MathTools.rotate(parentWorldOrientation, axis, axis);
}
- System.out.println(inputType);
+// System.out.println(inputType);
if (inputType == InputType.INTERSECT) {
double s[] = new double[2];
double angleI = i2.angle(i);
double angleJ = i2.angle(j);
double angle = Math.atan2(Math.cos(angleJ), Math.cos(angleI));
- System.out.println("Angle " + angle + " i " + angleI + " j " + angleJ + " prev " + prevAngle);
+// System.out.println("Angle " + angle + " i " + angleI + " j " + angleJ + " prev " + prevAngle);
if(!worldCoord)
axis = taxis;
if (useStep) {
//Quat4d q = MathTools.getQuat(euler);
Quat4d q = EulerTools.getQuatFromEuler(order, euler);
setOrientation(q);
- System.out.println(" (" + MathTools.radToDeg(euler.x) + " " + MathTools.radToDeg(euler.y) + " " + MathTools.radToDeg(euler.z) + ") " + qrot + " "+ q);
+// System.out.println(" (" + MathTools.radToDeg(euler.x) + " " + MathTools.radToDeg(euler.y) + " " + MathTools.radToDeg(euler.z) + ") " + qrot + " "+ q);
} else {
setOrientation(qrot);
}
//Quat4d q = MathTools.getQuat(euler);
Quat4d q = EulerTools.getQuatFromEuler(order, euler);
setOrientation(q);
- System.out.println(" (" + MathTools.radToDeg(euler.x) + " " + MathTools.radToDeg(euler.y) + " " + MathTools.radToDeg(euler.z) + ") " + qrot + " "+ q);
+// System.out.println(" (" + MathTools.radToDeg(euler.x) + " " + MathTools.radToDeg(euler.y) + " " + MathTools.radToDeg(euler.z) + ") " + qrot + " "+ q);
} else {
setOrientation(qrot);
}
case Z:
return new Vector3d(0.0, 0.0, 1.0);
case P:
- Vector3d axis = new Vector3d(panel.getRenderer().GetActiveCamera()
- .GetDirectionOfProjection());
+ Vector3d axis = new Vector3d(panel.getRenderer().GetActiveCamera().GetDirectionOfProjection());
axis.normalize();
return axis;
default:
import javax.vecmath.Vector3d;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
import org.simantics.g3d.math.MathTools;
import org.simantics.g3d.math.Ray;
import org.simantics.g3d.scenegraph.IG3DNode;
import org.simantics.g3d.scenegraph.base.INode;
import org.simantics.g3d.scenegraph.structural.IStructuralNode;
+import org.simantics.g3d.toolbar.ToolComposite;
import org.simantics.g3d.vtk.Activator;
import org.simantics.g3d.vtk.common.VTKNodeMap;
import org.simantics.g3d.vtk.gizmo.TranslateAxisGizmo;
private Cursor activeCursor;// = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
private Cursor dragCursor;// = Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR);
+ protected ToolComposite toolComposite;
+ protected Combo axisCombo;
+
public void setNode(IG3DNode node) {
this.node = node;
if ((node instanceof IStructuralNode) && ((IStructuralNode)node).isPartOfInstantiatedModel() && !((IStructuralNode)node).isInstantiatedModelRoot()) {
return node;
}
- public TranslateAction(InteractiveVtkComposite panel, VTKNodeMap<?, ? extends INode> nodeMap) {
+ public TranslateAction(InteractiveVtkComposite panel, VTKNodeMap<?, ? extends INode> nodeMap, ToolComposite toolComposite) {
super(panel);
setImageDescriptor(Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/arrow_out.png"));
setText("Translate");
activeCursor = Display.getCurrent().getSystemCursor(SWT.CURSOR_HAND);
dragCursor = Display.getCurrent().getSystemCursor(SWT.CURSOR_SIZEALL);
+ this.toolComposite = toolComposite;
+ }
+
+ protected void createTools(ToolComposite toolComposite) {
+ Label label = new Label(toolComposite, SWT.READ_ONLY);
+ label.setText("Translate direction:");
+ axisCombo = new Combo(toolComposite, SWT.READ_ONLY);
+ axisCombo.add("X");
+ axisCombo.add("Y");
+ axisCombo.add("Z");
+ axisCombo.add("XY");
+ axisCombo.add("XZ");
+ axisCombo.add("YZ");
+ axisCombo.add("Camera");
+ axisCombo.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ Combo c = (Combo)e.getSource();
+ index = c.getSelectionIndex();
+ updateLock();
+ panel.getComponent().setFocus();
+ }
+ });
+ axisCombo.select(index);
+ Button close = new Button(toolComposite, SWT.PUSH);
+ close.setText("Close");
+ close.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ panel.useDefaultAction();
+ };
+ });
+ toolComposite.relayout();
}
public void attach() {
if (node == null)
return;
+ if (toolComposite != null) {
+ createTools(toolComposite);
+ }
super.attach();
ThreadUtils.asyncExec(panel.getThreadQueue(), new Runnable() {
update();
}
});
-
-
-
}
public void deattach() {
+ if (toolComposite != null) {
+ toolComposite.clear();
+ axisCombo = null;
+ }
node = null;
nodeMap.commit("Translate");
if (e.getKeyCode() == KeyEvent.VK_G) {
worldCoord = !worldCoord;
}
- gizmo.setType(index);
+ updateLock();
update();
//panel.repaint();
return true;
}
+ private void updateLock() {
+ gizmo.setType(index);
+ if (axisCombo != null)
+ axisCombo.select(index);
+ panel.refresh();
+ }
@Override
translate.x = s[0];
break;
- case Y :
- dir = new Vector3d(0.0,1.0,0.0);
- if(!worldCoord)
- MathTools.rotate(q, dir, dir);
- i1 = new Vector3d();
- i2 = new Vector3d();
- s = new double[2];
- MathTools.intersectStraightStraight( p, dir,ray.pos, ray.dir, i2, i1,s);
- translate.y = s[0];
- break;
- case Z :
- dir = new Vector3d(0.0,0.0,1.0);
- if(!worldCoord)
- MathTools.rotate(q, dir, dir);
- i1 = new Vector3d();
- i2 = new Vector3d();
- s = new double[2];
- MathTools.intersectStraightStraight( p, dir,ray.pos, ray.dir, i2, i1,s);
- translate.z = s[0];
- break;
- case XY :
- normal = new Vector3d(0.0,0.0,1.0);
- if(!worldCoord)
- MathTools.rotate(q, normal, normal);
- r = new Vector3d();
- if (MathTools.intersectStraightPlane(ray.pos, ray.dir, p, normal, r)) {
- r.sub(p);
- translate.x = r.x;
- translate.y = r.y;
- }
- break;
- case XZ :
- normal = new Vector3d(0.0,1.0,0.0);
- if(!worldCoord)
- MathTools.rotate(q, normal, normal);
- r = new Vector3d();
- if (MathTools.intersectStraightPlane(ray.pos, ray.dir, p, normal, r)) {
- r.sub(p);
- translate.x = r.x;
- translate.z = r.z;
- }
- break;
- case YZ :
- normal = new Vector3d(1.0,0.0,0.0);
- if(!worldCoord)
- MathTools.rotate(q, normal, normal);
- r = new Vector3d();
- if (MathTools.intersectStraightPlane(ray.pos, ray.dir, p, normal, r)) {
- r.sub(p);
- translate.y = r.y;
- translate.z = r.z;
- }
- break;
- default :
-
- return null;
+ case Y :
+ dir = new Vector3d(0.0,1.0,0.0);
+ if(!worldCoord)
+ MathTools.rotate(q, dir, dir);
+ i1 = new Vector3d();
+ i2 = new Vector3d();
+ s = new double[2];
+ MathTools.intersectStraightStraight( p, dir,ray.pos, ray.dir, i2, i1,s);
+ translate.y = s[0];
+ break;
+ case Z :
+ dir = new Vector3d(0.0,0.0,1.0);
+ if(!worldCoord)
+ MathTools.rotate(q, dir, dir);
+ i1 = new Vector3d();
+ i2 = new Vector3d();
+ s = new double[2];
+ MathTools.intersectStraightStraight( p, dir,ray.pos, ray.dir, i2, i1,s);
+ translate.z = s[0];
+ break;
+ case XY :
+ normal = new Vector3d(0.0,0.0,1.0);
+ if(!worldCoord)
+ MathTools.rotate(q, normal, normal);
+ r = new Vector3d();
+ if (MathTools.intersectStraightPlane(ray.pos, ray.dir, p, normal, r)) {
+ r.sub(p);
+ translate.x = r.x;
+ translate.y = r.y;
+ }
+ break;
+ case XZ :
+ normal = new Vector3d(0.0,1.0,0.0);
+ if(!worldCoord)
+ MathTools.rotate(q, normal, normal);
+ r = new Vector3d();
+ if (MathTools.intersectStraightPlane(ray.pos, ray.dir, p, normal, r)) {
+ r.sub(p);
+ translate.x = r.x;
+ translate.z = r.z;
+ }
+ break;
+ case YZ :
+ normal = new Vector3d(1.0,0.0,0.0);
+ if(!worldCoord)
+ MathTools.rotate(q, normal, normal);
+ r = new Vector3d();
+ if (MathTools.intersectStraightPlane(ray.pos, ray.dir, p, normal, r)) {
+ r.sub(p);
+ translate.y = r.y;
+ translate.z = r.z;
}
- translate.sub(offset);
- return translate;
+ break;
+ default :
+
+ return null;
+ }
+ translate.sub(offset);
+ return translate;
}
}
org.simantics.g3d.scenegraph.structural,
org.simantics.g3d.scl,
org.simantics.g3d.shape,
+ org.simantics.g3d.toolbar,
org.simantics.g3d.tools,
org.simantics.g3d.ui,
org.simantics.g3d.wizard
--- /dev/null
+package org.simantics.g3d.toolbar;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+public class ToolComposite extends Composite{
+
+ public ToolComposite(Composite parent, int style) {
+ super(parent, style|SWT.BORDER);
+ RowLayout layout = new RowLayout();
+ layout.center = true;
+ layout.marginBottom = 1;
+ layout.marginTop = 1;
+ setLayout(layout);
+ }
+
+ public void clear() {
+ Control children[] = getChildren();
+ for (Control c : children)
+ c.dispose();
+ relayout();
+ }
+
+ public void relayout() {
+ getParent().layout(true);
+ layout(true);
+ }
+
+}
import javax.vecmath.Tuple3d;
import javax.vecmath.Vector3d;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Label;
import org.simantics.db.Resource;
import org.simantics.g3d.math.MathTools;
import org.simantics.g3d.math.Ray;
import org.simantics.g3d.scenegraph.NodeMap;
import org.simantics.g3d.scenegraph.base.INode;
+import org.simantics.g3d.toolbar.ToolComposite;
import org.simantics.g3d.tools.ConstraintDetector;
import org.simantics.g3d.vtk.gizmo.TranslateAxisGizmo;
import org.simantics.g3d.vtk.swt.InteractiveVtkComposite;
public class RoutePipeAction extends vtkSwtAction {
enum LockType {
- X, Y, Z, XY, YZ, XZ, NONE, CUSTOM
+ X, Y, Z, XY, XZ, YZ, NONE, CUSTOM
};
LockType lock = LockType.NONE;
private Set<PositionType> allowed = new HashSet<PositionType>();
- public RoutePipeAction(InteractiveVtkComposite panel, P3DRootNode root) {
- this(panel,root, true);
+ protected ToolComposite toolComposite;
+ protected Combo axisCombo;
+ protected Button cameraButton;
+
+ public RoutePipeAction(InteractiveVtkComposite panel, P3DRootNode root, ToolComposite toolComposite) {
+ this(panel,root, toolComposite, true);
}
- public RoutePipeAction(InteractiveVtkComposite panel, P3DRootNode root, boolean allowBranches) {
+ public RoutePipeAction(InteractiveVtkComposite panel, P3DRootNode root, ToolComposite toolComposite, boolean allowBranches) {
super(panel);
this.root = root;
this.allowBranches = allowBranches;
terminalSelectionGizmo = new TerminalSelectionGizmo(panel);
constraintPointGizmo = new ConstraintPointGizmo(panel);
detector = new org.simantics.g3d.vtk.swt.ConstraintDetector(panel);
+ this.toolComposite = toolComposite;
}
public void setComponent(PipelineComponent component) {
setEnabled(allowed.size() > 0);
}
- public void deattach() {
- deactivate();
- startComponent = null;
-
- deattachUI();
- super.deattach();
- panel.refresh();
- }
+ protected void createTools(ToolComposite toolComposite) {
+ Label label = new Label(toolComposite, SWT.READ_ONLY);
+ label.setText("Route direction:");
+ axisCombo = new Combo(toolComposite, SWT.READ_ONLY);
+ axisCombo.add("X");
+ axisCombo.add("Y");
+ axisCombo.add("Z");
+ axisCombo.add("XY");
+ axisCombo.add("XZ");
+ axisCombo.add("YZ");
+ axisCombo.add("None");
+ axisCombo.add("Custom");
+ axisCombo.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ Combo c = (Combo)e.getSource();
+ setLockType(LockType.values()[c.getSelectionIndex()],false);
+ panel.getComponent().setFocus();
+
+ }
+ });
+ axisCombo.select(lock.ordinal());
+ cameraButton = new Button(toolComposite, SWT.TOGGLE);
+ cameraButton.setText("Camera");
+ cameraButton.setSelection(useDefault);
+ cameraButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setUseDefault(((Button)e.getSource()).getSelection());
+ panel.getComponent().setFocus();
+ }
+ });
+ Button close = new Button(toolComposite, SWT.PUSH);
+ close.setText("Close");
+ close.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ panel.useDefaultAction();
+ };
+ });
+ toolComposite.relayout();
+ }
+
+ public void deattach() {
+ deactivate();
+ if (toolComposite != null) {
+ toolComposite.clear();
+ axisCombo = null;
+ cameraButton = null;
+ }
+
+ startComponent = null;
+
+ deattachUI();
+ super.deattach();
+ panel.refresh();
+ }
public void attach() {
if (startComponent == null)
return;
-
+ if (toolComposite != null) {
+ createTools(toolComposite);
+ }
super.attach();
ThreadUtils.asyncExec(panel.getThreadQueue(), new Runnable() {
public void run() {
}
}
if (e.getKeyCode() == KeyEvent.VK_C) {
- useDefault = !useDefault;
- if (useDefault)
- setInfoText("Rotating camera");
- System.out.println("UseDefault " + useDefault);
+ setUseDefault(!useDefault);
}
-
-
-
update();
return true;
}
+ private void setUseDefault(boolean b) {
+ useDefault = b;
+ if (useDefault)
+ setInfoText("Rotating camera");
+ if (cameraButton != null)
+ cameraButton.setSelection(useDefault);
+ }
+
private void update() {
panel.refresh();
translateAxisGizmo.attach(panel);
setPreviousPosition(previousPosition);
updateCurrentPoint();
+ updateWidget();
}
protected void setPreviousPosition(Vector3d v) {
translateAxisGizmo.attach(panel);
setPreviousPosition(previousPosition);
updateCurrentPoint();
+ updateWidget();
}
private void activateSplit(PipeControlPoint start) throws Exception{
}
private void setLockType(LockType type, boolean force) {
- if (force || (lock != LockType.CUSTOM || !lockForced) ) {
+ if (type == LockType.CUSTOM && (direction == null || added.size() > 0)) {
+ // nothing to do..
+ } else if (force || (lock != LockType.CUSTOM || !lockForced || added.size() > 0) ) {
+
lock = type;
switch (lock) {
break;
}
+
}
+ updateWidget();
+ }
+
+ private void updateWidget() {
+ if (axisCombo != null) {
+ axisCombo.select(lock.ordinal());
+ axisCombo.setEnabled(!lockForced || lock != LockType.CUSTOM);
+ }
}
@Override
addPoint();
}
} else {
- throw new RuntimeException("RoutePipeAction initlialization has been failed, no added components found");
+ throw new RuntimeException("RoutePipeAction initialization has failed, no added components found");
// // user was selecting position of branch
// lastPoint.set(startPoint);
// controlPoints.add(new Point3d(startPoint));
import org.simantics.g3d.math.Ray;
import org.simantics.g3d.scenegraph.IG3DNode;
+import org.simantics.g3d.toolbar.ToolComposite;
import org.simantics.g3d.vtk.swt.InteractiveVtkComposite;
import org.simantics.g3d.vtk.utils.vtkUtil;
import org.simantics.plant3d.Activator;
private InlineComponent component;
- public TranslateFreeVariableLengthAction(InteractiveVtkComposite panel, P3DRootNode root) {
- super(panel, root, false);
+ public TranslateFreeVariableLengthAction(InteractiveVtkComposite panel, P3DRootNode root, ToolComposite toolComposite) {
+ super(panel, root, toolComposite, false);
setText("Translate");
setImageDescriptor(Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/arrow_refresh.png"));
}
import org.simantics.g3d.math.Ray;
import org.simantics.g3d.scenegraph.IG3DNode;
import org.simantics.g3d.scenegraph.base.INode;
+import org.simantics.g3d.toolbar.ToolComposite;
import org.simantics.g3d.vtk.common.VTKNodeMap;
import org.simantics.g3d.vtk.swt.InteractiveVtkComposite;
import org.simantics.g3d.vtk.swt.TranslateAction;
private Vector3d e;
private Vector3d dir;
- public TranslateInlineAction(InteractiveVtkComposite panel, VTKNodeMap<?, ? extends INode> nodeMap) {
- super(panel, nodeMap);
+ public TranslateInlineAction(InteractiveVtkComposite panel, VTKNodeMap<?, ? extends INode> nodeMap, ToolComposite toolComposite) {
+ super(panel, nodeMap, toolComposite);
setImageDescriptor(Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/arrow_refresh.png"));
}
}
}
+ @Override
+ protected void createTools(ToolComposite toolComposite) {
+
+ }
+
@Override
public boolean keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
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;
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;
@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();
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);
}