]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Allow pipe routing to bypass locked variable angle routing direction 48/3448/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 4 Nov 2019 17:31:38 +0000 (19:31 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 4 Nov 2019 17:31:38 +0000 (19:31 +0200)
gitlab #46

Change-Id: Id51a13a6011427c2e05e34ec23ae237bb356708b

org.simantics.plant3d/src/org/simantics/plant3d/actions/RoutePipeAction.java

index dac9d2c11b004c428a5103116db1fd8c88eed920..7cc13cd46db010e080a097e5b487c55c56eda6d5 100644 (file)
@@ -51,6 +51,7 @@ public class RoutePipeAction extends vtkSwtAction {
        };
 
        LockType lock = LockType.NONE;
+       boolean lockForced;
        private double BRANCH_SNAP_DISTANCE = 0.05;
        private double NOZZLE_SNAP_DISTANCE = 0.05;
 
@@ -176,7 +177,7 @@ public class RoutePipeAction extends vtkSwtAction {
        public boolean keyPressed(KeyEvent e) {
                if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
                        panel.useDefaultAction();
-               if (lock != LockType.CUSTOM) {
+               if (lock != LockType.CUSTOM || !lockForced) {
                        if ((e.getModifiersEx() & KeyEvent.SHIFT_DOWN_MASK) > 0) {
                                if (e.getKeyCode() == KeyEvent.VK_X) {
                                        if (lock != LockType.XY && lock != LockType.XZ) {
@@ -224,10 +225,18 @@ public class RoutePipeAction extends vtkSwtAction {
                                        else
                                                setLockType(LockType.NONE, false);
                                }
+                               if (e.getKeyCode() == KeyEvent.VK_L && direction != null) {
+                                   if (lock != LockType.CUSTOM)
+                        setLockType(LockType.CUSTOM, false);
+                    else
+                        setLockType(LockType.NONE, false);
+                               }
                        }
                }
                if (e.getKeyCode() == KeyEvent.VK_C) {
                        useDefault = !useDefault;
+                       if (useDefault)
+                           setInfoText("Rotating camera");
                        System.out.println("UseDefault " + useDefault);
                }
                
@@ -310,14 +319,17 @@ public class RoutePipeAction extends vtkSwtAction {
                if (startComponent instanceof Nozzle) {
                        direction = startComponent.getControlPoint().getDirectedControlPointDirection();
                        lock = LockType.CUSTOM;
+                       lockForced = true;
                } else if (startComponent instanceof PipelineComponent){
                        if (startComponent instanceof InlineComponent) {
                                direction = startComponent.getControlPoint().getPathLegDirection(reversed ? Direction.PREVIOUS : Direction.NEXT);
                                lock = LockType.CUSTOM;
+                               lockForced = true;
                                if (((InlineComponent) startComponent).isVariableLength()) {
                                        startWithTurn = true;
                                        direction = null;
                                        lock = LockType.NONE;
+                                       lockForced = false;
                                } 
                                Vector3d v = new Vector3d();
                                if (!reversed) {
@@ -329,9 +341,11 @@ public class RoutePipeAction extends vtkSwtAction {
                                if (start.asFixedAngle()) {
                                        direction = startComponent.getControlPoint().getPathLegDirection(reversed ? Direction.PREVIOUS : Direction.NEXT);
                                        lock = LockType.CUSTOM;
+                                       lockForced = start.isFixedAngle();
                                } else {
                                        direction = null;
                                        lock = LockType.NONE;
+                                       lockForced = false;
                                }
                        } else if (startComponent instanceof EndComponent) {
                                throw new Exception("Not supported");
@@ -466,7 +480,7 @@ public class RoutePipeAction extends vtkSwtAction {
        }
        
        private void setLockType(LockType type, boolean force) {
-               if (force || lock != LockType.CUSTOM) {
+               if (force || (lock != LockType.CUSTOM || !lockForced) ) {
                        lock = type;
                        
                        switch (lock) {