package org.simantics.plant3d.scenegraph.controlpoint;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.List;
private Type type;
private boolean fixed = true;
+ private boolean rotate = false;
private boolean deletable = true;
private boolean sub = false;
this.fixed = fixed;
}
+ @GetPropertyValue(name="Rotate",tabId="Debug",value="rotate")
+ public boolean isRotate() {
+ return rotate;
+ }
+
+
+ public void setRotate(boolean rotate) {
+ this.rotate = rotate;
+ }
+
public void setSub(boolean sub) {
this.sub = sub;
}
component.setNext(next != null ? next.component : null);
else
component.setBranch0(next != null ? next.component : null);
+ updateSubPoint();
}
+
}
public void setPrevious(PipeControlPoint previous) {
// if (previous != null && getPipeRun() == null)
// throw new RuntimeException("Cannot connect control point befor piperun has been set");
this.previous = previous;
- if (component != null)
+ if (component != null) {
if (parent == null || sub)
component.setPrevious(previous != null ? previous.component : null);
else
component.setBranch0(previous != null ? previous.component : null);
+ updateSubPoint();
+ }
+
}
public PipeControlPoint parent;
}
public Vector3d getSizeChangeOffsetVector(Vector3d dir) {
+ Quat4d q;
if (rotationAngle == null)
- rotationAngle = 0.0;
- Quat4d q = getControlPointOrientationQuat(dir, rotationAngle);
- Vector3d v = new Vector3d(0.0,0.0,offset);
+ q = getControlPointOrientationQuat(dir, 0.0);
+ else
+ q = getControlPointOrientationQuat(dir, rotationAngle);
+ Vector3d v = new Vector3d(0.0,offset,0.0);
+ Vector3d offset = new Vector3d();
+ MathTools.rotate(q, v, offset);
+ return offset;
+ }
+
+ public Vector3d getSizeChangeOffsetVector() {
+ Quat4d q;
+ if (rotationAngle == null)
+ q = getControlPointOrientationQuat(0.0);
+ else
+ q = getControlPointOrientationQuat(rotationAngle);
+ Vector3d v = new Vector3d(0.0,offset,0.0);
Vector3d offset = new Vector3d();
MathTools.rotate(q, v, offset);
return offset;
return previous.toString();
}
+ @GetPropertyValue(name="Sub",tabId="Debug",value="sub")
+ private String getSubString() {
+ if (children.size() == 0)
+ return "";
+ return Arrays.toString(children.toArray());
+ }
+
+ @GetPropertyValue(name="Type",tabId="Debug",value="type")
+ public String getTypeString() {
+ return type.name();
+ }
+
public Quat4d getControlPointOrientationQuat(double angle) {
if (turnAxis == null) {
} else {
if (isInline()) {
+ PipeControlPoint pcp = this;
+ if (pcp.isDualSub()) {
+ pcp = pcp.getParentPoint();
+ }
Vector3d v = new Vector3d();
- v.sub(getWorldPosition(),previous.getWorldPosition());
+ v.sub(pcp.getWorldPosition(),previous.getWorldPosition());
return v;
} else if (isDirected()) {
return getDirectedControlPointDirection();
return v;
} else {
if (isInline()) {
+ PipeControlPoint pcp = this;
+ if (pcp.isDualInline()) {
+ pcp = pcp.getSubPoint().get(0);
+ }
Vector3d v = new Vector3d();
- v.sub(getWorldPosition(),next.getWorldPosition());
+ v.sub(pcp.getWorldPosition(),next.getWorldPosition());
return v;
} else if (isDirected()) {
Vector3d v = getDirectedControlPointDirection();
p1.remChild(ocp);
p2.remChild(sccp);
+ // TODO : now we assume that this is size change, and we do
+ if (ocp.next != null)
+ ocp.next.setPrevious(null);
+ if (ocp.previous != null)
+ ocp.previous.setNext(null);
+ if (sccp.next != null)
+ sccp.next.setPrevious(null);
+ if (sccp.previous != null)
+ sccp.previous.setNext(null);
ocp.setNext(null);
ocp.setPrevious(null);
sccp.setNext(null);
}
PipelineComponent comp = component;
component = null;
+
comp.remove();
}
super.setOrientation(orientation);
if (getParentPoint() == null && component != null)
component._setWorldOrientation(getWorldOrientation());
- for (PipeControlPoint sub : getSubPoint()) {
- sub.setWorldPosition(getWorldPosition());
- sub.setWorldOrientation(getWorldOrientation());
- }
+ updateSubPoint();
}
@Override
public void setPosition(Vector3d position) {
if (MathTools.equals(position, getPosition()))
return;
+ if (Double.isNaN(position.x) || Double.isNaN(position.y) || Double.isNaN(position.z))
+ throw new IllegalArgumentException("NaN is not supported");
super.setPosition(position);
if (getParentPoint() == null && component != null)
component._setWorldPosition(getWorldPosition());
- for (PipeControlPoint sub : getSubPoint()) {
- sub.setWorldPosition(getWorldPosition());
- sub.setWorldOrientation(getWorldOrientation());
+ updateSubPoint();
+ }
+
+ private void updateSubPoint() {
+ if (isOffset()) {
+ if (next == null && previous == null) {
+ for (PipeControlPoint sub : getSubPoint()) {
+ sub.setWorldPosition(getWorldPosition());
+ sub.setWorldOrientation(getWorldOrientation());
+ }
+ return;
+ }
+ for (PipeControlPoint sub : getSubPoint()) {
+ Vector3d wp = getWorldPosition();
+ wp.add(getSizeChangeOffsetVector());
+ sub.setWorldPosition(wp);
+ sub.setWorldOrientation(getWorldOrientation());
+ }
+ } else {
+ for (PipeControlPoint sub : getSubPoint()) {
+ sub.setWorldPosition(getWorldPosition());
+ sub.setWorldOrientation(getWorldOrientation());
+ }
}
}
public void _setWorldPosition(Vector3d position) {
Vector3d localPos = getLocalPosition(position);
super.setPosition(localPos);
- for (PipeControlPoint sub : getSubPoint()) {
- sub.setWorldPosition(getWorldPosition());
- sub.setWorldOrientation(getWorldOrientation());
- }
+ updateSubPoint();
}
public void _setWorldOrientation(Quat4d orientation) {
Quat4d localOr = getLocalOrientation(orientation);
super.setOrientation(localOr);
- for (PipeControlPoint sub : getSubPoint()) {
- sub.setWorldPosition(getWorldPosition());
- sub.setWorldOrientation(getWorldOrientation());
- }
+ updateSubPoint();
}
@Override