]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.plant3d/src/org/simantics/plant3d/actions/TranslateInlineAction.java
SCL bindings to some G3D and Plant3D Java classes
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / actions / TranslateInlineAction.java
index 23096f7eabfc96e40568bef31e571ffca5405d7f..c8c862240e76659e1ce0c6a92c2b4d1181796efb 100644 (file)
@@ -46,23 +46,29 @@ public class TranslateInlineAction extends TranslateAction{
                                        setEnabled(false);
                                        return;
                                }
-                               if (prev.getControlPoint().isInline() && !prev.getControlPoint().isFixed())
+                               if (prev.getControlPoint().isInline() && !prev.getControlPoint().isFixed() && prev.getPrevious() != null)
                                        prev = prev.getPrevious();
-                               if (next.getControlPoint().isInline() && !next.getControlPoint().isFixed()) {
+                               if (next.getControlPoint().isInline() && !next.getControlPoint().isFixed() && next.getNext() != null) {
                                        next = next.getNext();
                                }
                                Point3d ns = new Point3d();
                                Point3d ne = new Point3d();
                                Point3d ps = new Point3d();
                                Point3d pe = new Point3d();
-                               next.getControlPointEnds(ns, ne);
-                               prev.getControlPointEnds(ps, pe);
+                               next.getEnds(ns, ne);
+                               prev.getEnds(ps, pe);
                                dir = comp.getControlPoint().getPathLegDirection(Direction.NEXT);
                                dir.normalize();
                                // We may have offsets in the path leg, hence we have to project the coordinates.
                                Vector3d wp = node.getWorldPosition();
-                               s = MathTools.closestPointOnStraight(pe, wp, dir);
-                               e = MathTools.closestPointOnStraight(ns, wp, dir);
+                               if (prev.getControlPoint().isVariableLength())
+                                   s = MathTools.closestPointOnStraight(ps, wp, dir);
+                               else
+                                   s = MathTools.closestPointOnStraight(pe, wp, dir);
+                               if (next.getControlPoint().isVariableLength())
+                                   e = MathTools.closestPointOnStraight(ne, wp, dir);
+                               else
+                                   e = MathTools.closestPointOnStraight(ns, wp, dir);
                                // Remove component's own space from end points to get actual movement range
                                double l = comp.getControlPoint().getInlineLength();
                                Vector3d ld = new Vector3d(dir);