1 package org.simantics.plant3d.scenegraph;
3 import java.util.ArrayList;
4 import java.util.Collection;
5 import java.util.Collections;
6 import java.util.Comparator;
9 import org.simantics.g3d.math.MathTools;
10 import org.simantics.g3d.property.annotations.GetPropertyValue;
11 import org.simantics.g3d.property.annotations.PropertyTabBlacklist;
12 import org.simantics.g3d.property.annotations.SetPropertyValue;
13 import org.simantics.g3d.scenegraph.IG3DNode;
14 import org.simantics.g3d.vtk.common.VtkView;
15 import org.simantics.objmap.graph.annotations.GraphType;
16 import org.simantics.objmap.graph.annotations.RelatedElementsAdd;
17 import org.simantics.objmap.graph.annotations.RelatedElementsGet;
18 import org.simantics.objmap.graph.annotations.RelatedElementsRem;
19 import org.simantics.objmap.graph.annotations.RelatedGetValue;
20 import org.simantics.objmap.graph.annotations.RelatedSetValue;
21 import org.simantics.plant3d.ontology.Plant3D;
22 import org.simantics.plant3d.scenegraph.controlpoint.PipeControlPoint;
25 import vtk.vtkRenderer;
27 @GraphType(Plant3D.URIs.PipeRun)
28 @PropertyTabBlacklist("Transform")
29 public class PipeRun extends P3DParentNode<IP3DNode> {
31 private double pipeDiameter = 0.1;
32 private double[] turnRadius = new double[] {0.2};
35 public void update(vtkRenderer ren) {
40 public void visualize(VtkView panel) {
45 public Collection<vtkProp3D> getActors() {
46 return Collections.EMPTY_LIST;
50 public void stopVisualize() {
54 @RelatedGetValue(Plant3D.URIs.HasTurnRadius)
55 @GetPropertyValue(value=Plant3D.URIs.HasTurnRadius, name = "Elbow radius")
56 public double getTurnRadius() {
60 @RelatedSetValue(Plant3D.URIs.HasTurnRadius)
61 @SetPropertyValue(Plant3D.URIs.HasTurnRadius)
62 public void setTurnRadius(double turnRadius) {
63 this.turnRadius[0] = turnRadius;
64 firePropertyChanged(Plant3D.URIs.HasTurnRadius);
65 firePropertyChanged(Plant3D.URIs.HasTurnRadiusArray);
68 @RelatedGetValue(Plant3D.URIs.HasTurnRadiusArray)
69 @GetPropertyValue(value=Plant3D.URIs.HasTurnRadiusArray, name = "Elbow radius array")
70 public double[] getTurnRadiusArray() {
74 @RelatedSetValue(Plant3D.URIs.HasTurnRadiusArray)
75 @SetPropertyValue(Plant3D.URIs.HasTurnRadiusArray)
76 public void setTurnRadiusArray(double[] turnRadiusArray) {
77 if (turnRadiusArray == null || turnRadiusArray.length == 0)
79 this.turnRadius = turnRadiusArray;
80 firePropertyChanged(Plant3D.URIs.HasTurnRadiusArray);
83 @RelatedGetValue(Plant3D.URIs.HasPipeDiameter)
84 @GetPropertyValue(value=Plant3D.URIs.HasPipeDiameter, name = "Diameter")
85 public double getPipeDiameter() {
89 @RelatedSetValue(Plant3D.URIs.HasPipeDiameter)
90 @SetPropertyValue(Plant3D.URIs.HasPipeDiameter)
91 public void setPipeDiameter(double pipeDiameter) {
92 this.pipeDiameter = pipeDiameter;
93 firePropertyChanged(Plant3D.URIs.HasPipeDiameter);
96 @RelatedElementsAdd(Plant3D.URIs.children)
97 public void addChild(PipelineComponent node) {
98 addNode(Plant3D.URIs.children,node);
101 @RelatedElementsGet(Plant3D.URIs.children)
102 public Collection<PipelineComponent> getChild() {
103 Collection<PipelineComponent> coll = new ArrayList<PipelineComponent>();
104 for (IG3DNode n : getNodes(Plant3D.URIs.children)) {
105 coll.add((PipelineComponent)n);
110 @RelatedElementsRem(Plant3D.URIs.children)
111 public void remChild(PipelineComponent node) {
112 removeNode(Plant3D.URIs.children, node);
116 public List<PipelineComponent> getSortedChild() {
117 List<PipelineComponent> coll = new ArrayList<PipelineComponent>();
118 for (IG3DNode n : getNodes(Plant3D.URIs.children)) {
119 coll.add((PipelineComponent)n);
121 Collections.sort(coll, new ComponentComparator());
124 private static String PIPECP = "pipecp";
126 public void addChild(PipeControlPoint node) {
127 addNode(PIPECP,node);
130 public void remChild(PipeControlPoint node) {
131 removeNode(PIPECP, node);
134 public void deattachChild(PipeControlPoint node) {
135 deattachNode(PIPECP, node);
138 public Collection<PipeControlPoint> getControlPoints() {
139 Collection<PipeControlPoint> coll = new ArrayList<PipeControlPoint>();
140 for (IG3DNode n : getNodes(PIPECP)) {
141 coll.add((PipeControlPoint)n);
147 public boolean equalSpecs(PipeRun other) {
148 if (!MathTools.equals(pipeDiameter,other.pipeDiameter))
150 if (turnRadius.length != other.turnRadius.length)
152 for (int i = 0; i < turnRadius.length; i++) {
153 if (!MathTools.equals(turnRadius[i],other.turnRadius[i]))
159 private class ComponentComparator implements Comparator<PipelineComponent> {
161 public int compare(PipelineComponent o1, PipelineComponent o2) {
165 PipelineComponent c = o1.getPrevious();