]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Unattached size change (reducer) did not recognise being size change 71/3171/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Thu, 29 Aug 2019 15:51:53 +0000 (18:51 +0300)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Thu, 29 Aug 2019 15:51:53 +0000 (18:51 +0300)
gitlab #12

Change-Id: Ife915d2a48050fc65617d905e41a821894a623c3

org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/ControlPointFactory.java
org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java

index 99b1448cb8e498decc9c8eef3f7655bd0fdea324..4dfe29c75069c22d87ac4538d06cde3de7d36e23 100644 (file)
@@ -62,6 +62,8 @@ public class ControlPointFactory {
                                sub.setDeletable(false);
                                if (inst.isOffset)
                                        pcp.setOffset(0.0);
+                               if (inst.isSizeChange)
+                                   pcp.setSizeChange(true);
                        }
                        
                        break;
index 53a612e201179eca765af679c424c04a4c8ef601..51addbb09ee9edf707af756c8d9d035807aa99d2 100644 (file)
@@ -33,11 +33,12 @@ public class PipeControlPoint extends G3DNode implements IP3DNode {
        private PipelineComponent component;
        
        private PointType type;
-       private boolean fixed = true;
-       private boolean rotate = false;
-       private boolean reverse = false;
-       private boolean deletable = true;
-       private boolean sub = false;
+       private boolean isFixed = true;
+       private boolean isRotate = false;
+       private boolean isReverse = false;
+       private boolean isDeletable = true;
+       private boolean isSizeChange = false;
+       private boolean isSub = false;
        
        public PipeControlPoint(PipelineComponent component) {
                this.component = component;
@@ -79,43 +80,43 @@ public class PipeControlPoint extends G3DNode implements IP3DNode {
        
        @GetPropertyValue(name="Fixed",tabId="Debug",value="fixed")
        public boolean isFixed() {
-               return fixed;
+               return isFixed;
        }
        
        
        public void setFixed(boolean fixed) {
-               this.fixed = fixed;
+               this.isFixed = fixed;
        }
        
        @GetPropertyValue(name="Rotate",tabId="Debug",value="rotate")
        public boolean isRotate() {
-               return rotate;
+               return isRotate;
        }
        
        public void setRotate(boolean rotate) {
-               this.rotate = rotate;
+               this.isRotate = rotate;
        }
        
        @GetPropertyValue(name="Reverse",tabId="Debug",value="reverse")
        public boolean isReverse() {
-               return reverse;
+               return isReverse;
        }
        
        public void setReverse(boolean reverse) {
-               this.reverse = reverse;
+               this.isReverse = reverse;
        }
        
        public void setSub(boolean sub) {
-               this.sub = sub;
+               this.isSub = sub;
        }
                
        @GetPropertyValue(name="Deletable",tabId="Debug",value="deletable")
        public boolean isDeletable() {
-               return deletable;
+               return isDeletable;
        }
        
        public void setDeletable(boolean deletable) {
-               this.deletable = deletable;
+               this.isDeletable = deletable;
        }
        
        public boolean isPathLegEnd() {
@@ -135,23 +136,23 @@ public class PipeControlPoint extends G3DNode implements IP3DNode {
        }
        
        public boolean isDirected() {
-               return fixed && isEnd();
+               return isFixed && isEnd();
        }
        
        public boolean isNonDirected() {
-               return !fixed && isEnd();
+               return !isFixed && isEnd();
        }
        
        public boolean isVariableLength() {
-               return !fixed && isInline();
+               return !isFixed && isInline();
        }
        
        public boolean isVariableAngle() {
-               return !fixed && isTurn();
+               return !isFixed && isTurn();
        }
        
        public boolean isBranchEnd() {
-               return deletable && isEnd();
+               return isDeletable && isEnd();
        }
        
        public boolean isOffset() {
@@ -159,7 +160,7 @@ public class PipeControlPoint extends G3DNode implements IP3DNode {
        }
        
        public boolean isDualSub() {
-               return parent != null && sub;
+               return parent != null && isSub;
        }
        
        public boolean isDualInline() {
@@ -167,12 +168,17 @@ public class PipeControlPoint extends G3DNode implements IP3DNode {
        }
        
        public boolean isSizeChange() {
-               if (children.size() == 0)
-                       return false;
-               if (!isDualInline())
-                       return false;
-               return getPipeRun() != children.get(0).getPipeRun();
+           return isSizeChange;
+//             if (children.size() == 0)
+//                     return false;
+//             if (!isDualInline())
+//                     return false;
+//             return getPipeRun() != children.get(0).getPipeRun();
        }
+       
+       public void setSizeChange(boolean isSizeChange) {
+        this.isSizeChange = isSizeChange;
+    }
 
        
        private PipeControlPoint next;
@@ -189,12 +195,14 @@ public class PipeControlPoint extends G3DNode implements IP3DNode {
        public void setNext(PipeControlPoint next) {
                if (isEnd() && previous != null && next != null)
                        throw new RuntimeException("End control points are allowed to have only one connection");
+               if (next == this)
+            throw new RuntimeException("Cannot connect to self");
                if (this.next == next)
                    return;
                if (DEBUG) System.out.println(this + " next " + next);
                this.next = next;
                if (component != null) {
-                       if (parent == null || sub)
+                       if (parent == null || isSub)
                                component.setNext(next != null ? next.component : null);
                        else
                                component.setBranch0(next != null ? next.component : null);
@@ -206,12 +214,14 @@ public class PipeControlPoint extends G3DNode implements IP3DNode {
        public void setPrevious(PipeControlPoint previous) {
                if (isEnd() && next != null && previous != null)
                        throw new RuntimeException("End control points are allowed to have only one connection");
+               if (previous == this)
+                   throw new RuntimeException("Cannot connect to self");
                if (this.previous == previous)
                    return;
                if (DEBUG) System.out.println(this + " previous " + previous);
                this.previous = previous;
                if (component != null) {
-                       if (parent == null || sub)
+                       if (parent == null || isSub)
                                component.setPrevious(previous != null ? previous.component : null);
                        else
                                component.setBranch0(previous != null ? previous.component : null);
@@ -1128,8 +1138,10 @@ public class PipeControlPoint extends G3DNode implements IP3DNode {
                ocp.removeComponent();
                sccp.removeComponent();
                
-               p1.remChild(ocp);
-               p2.remChild(sccp);
+               if (p1 != null)
+                   p1.remChild(ocp);
+               if (p2 != null)
+                   p2.remChild(sccp);
                
                // TODO : now we assume that this is size change, and we do
                if (ocp.next != null)
@@ -1145,8 +1157,10 @@ public class PipeControlPoint extends G3DNode implements IP3DNode {
                sccp.setNext(null);
                sccp.setPrevious(null);
                
-               checkRemove(p1);
-               checkRemove(p2);
+               if (p1 != null)
+                   checkRemove(p1);
+               if (p2 != null)
+                   checkRemove(p2);
        }
        
        private void removeSubPoints() {