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 = 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 = turnRadius;
64 firePropertyChanged(Plant3D.URIs.HasTurnRadius);
67 @RelatedGetValue(Plant3D.URIs.HasPipeDiameter)
68 @GetPropertyValue(value=Plant3D.URIs.HasPipeDiameter, name = "Diameter")
69 public double getPipeDiameter() {
73 @RelatedSetValue(Plant3D.URIs.HasPipeDiameter)
74 @SetPropertyValue(Plant3D.URIs.HasPipeDiameter)
75 public void setPipeDiameter(double pipeDiameter) {
76 this.pipeDiameter = pipeDiameter;
77 firePropertyChanged(Plant3D.URIs.HasPipeDiameter);
80 @RelatedElementsAdd(Plant3D.URIs.childen)
81 public void addChild(PipelineComponent node) {
82 addNode(Plant3D.URIs.childen,node);
85 @RelatedElementsGet(Plant3D.URIs.childen)
86 public Collection<PipelineComponent> getChild() {
87 Collection<PipelineComponent> coll = new ArrayList<PipelineComponent>();
88 for (IG3DNode n : getNodes(Plant3D.URIs.childen)) {
89 coll.add((PipelineComponent)n);
94 @RelatedElementsRem(Plant3D.URIs.childen)
95 public void remChild(PipelineComponent node) {
96 removeNode(Plant3D.URIs.childen, node);
100 public List<PipelineComponent> getSortedChild() {
101 List<PipelineComponent> coll = new ArrayList<PipelineComponent>();
102 for (IG3DNode n : getNodes(Plant3D.URIs.childen)) {
103 coll.add((PipelineComponent)n);
105 Collections.sort(coll, new ComponentComparator());
108 public void addChild(PipeControlPoint node) {
109 addNode("pipecp",node);
112 public void remChild(PipeControlPoint node) {
113 removeNode("pipecp", node);
116 public void deattachChild(PipeControlPoint node) {
117 deattachNode("pipecp", node);
120 public Collection<PipeControlPoint> getControlPoints() {
121 Collection<PipeControlPoint> coll = new ArrayList<PipeControlPoint>();
122 for (IG3DNode n : getNodes("pipecp")) {
123 coll.add((PipeControlPoint)n);
128 public boolean equalSpecs(PipeRun other) {
129 if (!MathTools.equals(pipeDiameter,other.pipeDiameter))
131 if (!MathTools.equals(turnRadius,other.turnRadius))
136 private class ComponentComparator implements Comparator<PipelineComponent> {
138 public int compare(PipelineComponent o1, PipelineComponent o2) {
142 PipelineComponent c = o1.getPrevious();