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.emptyList();
50 public void stopVisualize() {
54 @SuppressWarnings("deprecation")
55 @RelatedGetValue(Plant3D.URIs.HasTurnRadius)
56 @GetPropertyValue(value=Plant3D.URIs.HasTurnRadius, name = "Elbow radius")
57 public double getTurnRadius() {
61 @SuppressWarnings("deprecation")
62 @RelatedSetValue(Plant3D.URIs.HasTurnRadius)
63 @SetPropertyValue(Plant3D.URIs.HasTurnRadius)
64 public void setTurnRadius(double turnRadius) {
65 this.turnRadius[0] = turnRadius;
66 firePropertyChanged(Plant3D.URIs.HasTurnRadius);
67 firePropertyChanged(Plant3D.URIs.HasTurnRadiusArray);
70 @RelatedGetValue(Plant3D.URIs.HasTurnRadiusArray)
71 @GetPropertyValue(value=Plant3D.URIs.HasTurnRadiusArray, name = "Elbow radius array")
72 public double[] getTurnRadiusArray() {
76 @RelatedSetValue(Plant3D.URIs.HasTurnRadiusArray)
77 @SetPropertyValue(Plant3D.URIs.HasTurnRadiusArray)
78 public void setTurnRadiusArray(double[] turnRadiusArray) {
79 if (turnRadiusArray == null || turnRadiusArray.length == 0)
81 this.turnRadius = turnRadiusArray;
82 firePropertyChanged(Plant3D.URIs.HasTurnRadiusArray);
85 @RelatedGetValue(Plant3D.URIs.HasPipeDiameter)
86 @GetPropertyValue(value=Plant3D.URIs.HasPipeDiameter, name = "Diameter")
87 public double getPipeDiameter() {
91 @RelatedSetValue(Plant3D.URIs.HasPipeDiameter)
92 @SetPropertyValue(Plant3D.URIs.HasPipeDiameter)
93 public void setPipeDiameter(double pipeDiameter) {
94 this.pipeDiameter = pipeDiameter;
95 firePropertyChanged(Plant3D.URIs.HasPipeDiameter);
98 @RelatedElementsAdd(Plant3D.URIs.children)
99 public void addChild(PipelineComponent node) {
100 addNode(Plant3D.URIs.children,node);
103 @RelatedElementsGet(Plant3D.URIs.children)
104 public Collection<PipelineComponent> getChild() {
105 Collection<PipelineComponent> coll = new ArrayList<PipelineComponent>();
106 for (IG3DNode n : getNodes(Plant3D.URIs.children)) {
107 coll.add((PipelineComponent)n);
112 @RelatedElementsRem(Plant3D.URIs.children)
113 public void remChild(PipelineComponent node) {
114 removeNode(Plant3D.URIs.children, node);
118 public List<PipelineComponent> getSortedChild() {
119 List<PipelineComponent> coll = new ArrayList<PipelineComponent>();
120 for (IG3DNode n : getNodes(Plant3D.URIs.children)) {
121 coll.add((PipelineComponent)n);
123 Collections.sort(coll, new ComponentComparator());
126 private static String PIPECP = "pipecp";
128 public void addChild(PipeControlPoint node) {
129 addNode(PIPECP,node);
132 public void remChild(PipeControlPoint node) {
133 removeNode(PIPECP, node);
136 public void deattachChild(PipeControlPoint node) {
137 deattachNode(PIPECP, node);
140 public Collection<PipeControlPoint> getControlPoints() {
141 Collection<PipeControlPoint> coll = new ArrayList<PipeControlPoint>();
142 for (IG3DNode n : getNodes(PIPECP)) {
143 coll.add((PipeControlPoint)n);
149 public boolean equalSpecs(PipeRun other) {
150 if (!MathTools.equals(pipeDiameter,other.pipeDiameter))
152 if (turnRadius.length != other.turnRadius.length)
154 for (int i = 0; i < turnRadius.length; i++) {
155 if (!MathTools.equals(turnRadius[i],other.turnRadius[i]))
161 private class ComponentComparator implements Comparator<PipelineComponent> {
163 public int compare(PipelineComponent o1, PipelineComponent o2) {
167 PipelineComponent c = o1.getPrevious();