X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.plant3d%2Fsrc%2Forg%2Fsimantics%2Fplant3d%2Factions%2FRoutePipeAction.java;h=9773a9eae8c77a5c3c3a1bf350ffadaee6a0dc39;hb=c44f3e6a480f19b26a586a271ac200f051c60cf2;hp=24b6a14bdfcef66fd5c1df8876fa6c14ac2fe0ff;hpb=53d55c24c779745f188bdb18d32f71d20acb61b2;p=simantics%2F3d.git diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/actions/RoutePipeAction.java b/org.simantics.plant3d/src/org/simantics/plant3d/actions/RoutePipeAction.java index 24b6a14b..9773a9ea 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/actions/RoutePipeAction.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/actions/RoutePipeAction.java @@ -69,7 +69,7 @@ public class RoutePipeAction extends vtkSwtAction { private enum ToolState{NOT_ACTIVE, INITIALIZING, SELECTING_POSITION, SELECTING_SPLIT, ROUTING}; private ToolState state = ToolState.NOT_ACTIVE; - private ConstraintDetector detector = new DummyConstraintDetector(); + private ConstraintDetector detector;// = new DummyConstraintDetector(); private boolean useDefault = false; private Vector3d direction = null; @@ -95,6 +95,7 @@ public class RoutePipeAction extends vtkSwtAction { nodeMap = root.getNodeMap(); splitPointSelectionGizmo = new SplitPointSelectionGizmo(panel); terminalSelectionGizmo = new TerminalSelectionGizmo(panel); + detector = new org.simantics.g3d.vtk.swt.ConstraintDetector(panel); } public void setComponent(PipelineComponent component) { @@ -529,7 +530,7 @@ public class RoutePipeAction extends vtkSwtAction { // selectionLine = null; } } else if (e.getButton() ==MouseEvent.BUTTON2){ - // detector.updateConstraintReference(); + updateConstraints(); } else if (e.getButton() == MouseEvent.BUTTON3){ endPiping(); } @@ -595,6 +596,27 @@ public class RoutePipeAction extends vtkSwtAction { return true; } + private void updateConstraints() { + detector.clearConstraints(); + if (hoverObject == null) { + return; + } + if (hoverObject instanceof Nozzle) { + Nozzle n = (Nozzle)hoverObject; + detector.addContraintPoint(new Point3d(n.getWorldPosition())); + } else if (hoverObject instanceof InlineComponent) { + InlineComponent c = (InlineComponent)hoverObject; + Point3d p1 = new Point3d(); + Point3d p2 = new Point3d(); + c.getEnds(p1, p2); + detector.addContraintPoint(p1); + detector.addContraintPoint(p2); + } else if (hoverObject instanceof TurnComponent) { + TurnComponent n = (TurnComponent)hoverObject; + detector.addContraintPoint(new Point3d(n.getWorldPosition())); + } + } + @Override public boolean mouseMoved(MouseEvent e) { if (useDefault) { @@ -627,7 +649,7 @@ public class RoutePipeAction extends vtkSwtAction { return nodes; } - + INode hoverObject = null; private void updateRouting(double x, double y) { // if(input.keyPressed(KeyEvent.VK_ESCAPE)) { @@ -660,12 +682,14 @@ public class RoutePipeAction extends vtkSwtAction { - INode hoverObject = null; + List hover = isOverNode((int)x,(int)y); if (hover.size() > 0) { hoverObject = hover.get(0); - } + } else { + hoverObject = null; + } // System.out.println(hoverObject + " " + getLast()); if (hoverObject != null) { if (hoverObject.equals(getLast()) ) {