1 package org.simantics.plant3d.scenegraph;
3 import java.util.HashMap;
6 import javax.vecmath.Quat4d;
7 import javax.vecmath.Vector3d;
9 import org.simantics.g3d.property.annotations.GetPropertyValue;
10 import org.simantics.objmap.graph.annotations.DynamicGraphType;
11 import org.simantics.objmap.graph.annotations.GetType;
12 import org.simantics.objmap.graph.annotations.RelatedGetObj;
13 import org.simantics.objmap.graph.annotations.RelatedGetValue;
14 import org.simantics.objmap.graph.annotations.RelatedSetObj;
15 import org.simantics.objmap.graph.annotations.RelatedSetValue;
16 import org.simantics.objmap.graph.annotations.SetType;
17 import org.simantics.plant3d.ontology.Plant3D;
18 import org.simantics.plant3d.scenegraph.controlpoint.ControlPointFactory;
19 import org.simantics.plant3d.scenegraph.controlpoint.PipeControlPoint;
22 @DynamicGraphType(Plant3D.URIs.Nozzle)
23 public class Nozzle extends PipelineComponent {
26 private PipeControlPoint controlPoint;
28 @GetType(Plant3D.URIs.Nozzle)
29 public String getType() {
33 @SetType(Plant3D.URIs.Nozzle)
34 public void setType(String type) throws Exception{
42 @RelatedGetValue(Plant3D.URIs.HasNozzleId)
43 @GetPropertyValue(name="Nozzle ID", value=Plant3D.URIs.HasNozzleId, tabId="Default")
44 public int getNozzleId() {
48 @RelatedSetValue(Plant3D.URIs.HasNozzleId)
49 public void setNozzleId(int id) {
53 firePropertyChanged(Plant3D.URIs.HasNozzleId);
56 private boolean fixed = false;
58 @RelatedGetValue(Plant3D.URIs.IsFixedNozzle)
59 @GetPropertyValue(name="Fixed", value=Plant3D.URIs.IsFixedNozzle, tabId="Default")
60 public boolean isFixed() {
64 @RelatedSetValue(Plant3D.URIs.IsFixedNozzle)
65 public void setFixed(boolean fixed) {
66 if (fixed == this.fixed)
69 firePropertyChanged(Plant3D.URIs.IsFixedNozzle);
72 private void _createCP() throws Exception{
73 if (controlPoint != null)
75 controlPoint = ControlPointFactory.create(this);
76 // TODO : these should not be needed.
77 controlPoint.setDeletable(false);
78 controlPoint.setFixed(true);
83 @RelatedSetObj(Plant3D.URIs.HasPipeRun)
85 public void setPipeRun(PipeRun pipeRun) {
86 if (this.getPipeRun() == pipeRun)
89 super.setPipeRun(pipeRun);
92 } catch (Exception e) {
93 // TODO Auto-generated catch block
97 firePropertyChanged(Plant3D.URIs.HasPipeRun);
100 @RelatedGetObj(Plant3D.URIs.HasPipeRun)
102 public PipeRun getPipeRun() {
103 return super.getPipeRun();
107 public PipeControlPoint getControlPoint() {
113 public void setPosition(Vector3d position) {
114 super.setPosition(position);
119 public void setOrientation(Quat4d orientation) {
120 super.setOrientation(orientation);
124 private void updateCP() {
125 if (controlPoint == null)
127 if (controlPoint.getPipeRun() == null)
129 controlPoint._setWorldPosition(getWorldPosition());
130 controlPoint._setWorldOrientation(getWorldOrientation());
135 public Map<String, Object> updateParameterMap() {
136 Map<String,Object> map = new HashMap<String, Object>();
138 PipeRun pipeRun = getPipeRun();
139 if (pipeRun != null) {
140 //map.put("length", pipeRun.getPipeDiameter() * 2.0);
141 map.put("radius", pipeRun.getPipeDiameter() * 0.5);
147 protected double[] getColor() {
148 return new double[]{0.7,0.7,0.7};
152 protected double[] getSelectedColor() {
153 return new double[]{0.5,0,0.5};
156 public boolean isConnected() {
157 PipeControlPoint pcp = getControlPoint();
158 return (pcp.getNext() != null || pcp.getPrevious() != null);
161 public boolean isNextConnected() {
162 PipeControlPoint pcp = getControlPoint();
163 return (pcp.getNext() != null);
166 public boolean isPrevConnected() {
167 PipeControlPoint pcp = getControlPoint();
168 return (pcp.getNext() != null);