]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java
Remove listener calls when property values not updated.
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / scenegraph / controlpoint / PipingRules.java
index d00e4018de1407887cb1982e578bb2b3d967a4a5..e8729872d53a0b863cf40e45049b1eefd7fdad96 100644 (file)
@@ -216,6 +216,17 @@ public class PipingRules {
                        System.out.println("PipingRules.updateInlineControlPoint() " + pcp);
                PipeControlPoint start = pcp.findPreviousEnd();
                updatePathLegNext(start, pcp, PathLegUpdateType.NONE);
+               
+               if (pcp.isOffset()) {
+                       // Adjusting the rotation angle of an offset component may change variable angle turns
+                       PipeControlPoint end = pcp.findNextEnd();
+                       if (end.isVariableAngle()) {
+                               updatePathLegNext(end, end, PathLegUpdateType.NONE);
+                       }
+                       if (start.isVariableAngle()) {
+                               updatePathLegPrev(start, start, PathLegUpdateType.NONE);
+                       }
+               }
        }
 
        private static PipeControlPoint insertElbow(PipeControlPoint pcp1, PipeControlPoint pcp2, Vector3d pos) throws Exception{
@@ -748,7 +759,7 @@ public class PipingRules {
                        continue;
                    double curr = gapObj.d;
                    int d = 1;
-                   while (curr < -MIN_INLINE_LENGTH) {
+                   while (d < gaps.size() && curr < -MIN_INLINE_LENGTH) {
                        GapObj next = i+d >= 0 ? gaps.get(i+d) : null;
                     GapObj prev = i-d >= 0 ? gaps.get(i-d) : null;
                        if (next != null && next.gap == Gap.SPACE) {
@@ -767,12 +778,12 @@ public class PipingRules {
                                pcp.first.setWorldPosition(p);
                            }
                        }
-                       if (curr < -MIN_INLINE_LENGTH && prev != null && prev.gap == Gap.SPACE) {
+                       else if (prev != null && prev.gap == Gap.SPACE) {
                            double move = Math.min(-curr, prev.d);
                         curr+= move;
-                        next.d -= move;
-                        if (next.d < MIN_INLINE_LENGTH)
-                            next.gap = Gap.ATTACHED;
+                        prev.d -= move;
+                        if (prev.d < MIN_INLINE_LENGTH)
+                            prev.gap = Gap.ATTACHED;
                         Vector3d mv = new Vector3d(dir);
                         mv.normalize();
                         mv.scale(-move);
@@ -783,6 +794,9 @@ public class PipingRules {
                             pcp.first.setWorldPosition(p);
                         }
                        }
+                       else {
+                           d++;
+                       }
                    }
                }
            } else {
@@ -1356,7 +1370,7 @@ public class PipingRules {
                    while (iter > 0) {
                        Vector3d tp = new Vector3d(dir);
                        tp.scaleAdd(curr, dp);
-                       tcp.setPosition(tp);
+                       tcp._setPosition(tp); // no firing of listeners here
                            if (other == ne) {
                                dir2 = pathLegDirection(tcp);
                            } else {
@@ -1376,7 +1390,7 @@ public class PipingRules {
                    }
            }
            finally {
-               tcp.setPosition(tp0);
+               tcp._setPosition(tp0); // return the original value
            }
            return curr;
        }
@@ -1890,7 +1904,7 @@ public class PipingRules {
                                return Math.PI; // FIXME : argh
                        }
                        
-                       Quat4d q = PipeControlPoint.getControlPointOrientationQuat(dir, tcp.getRotationAngle() != null ? tcp.getRotationAngle() : 0.0);
+                       Quat4d q = tcp.getControlPointOrientationQuat(dir, tcp.getRotationAngle() != null ? tcp.getRotationAngle() : 0.0);
                        Vector3d v = new Vector3d();
                        MathTools.rotate(q, MathTools.Y_AXIS,v);
                        tcp.setTurnAxis(v);