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 super.setPipeRun(pipeRun);
89 } catch (Exception e) {
90 // TODO Auto-generated catch block
94 firePropertyChanged(Plant3D.URIs.HasPipeRun);
97 @RelatedGetObj(Plant3D.URIs.HasPipeRun)
99 public PipeRun getPipeRun() {
100 return super.getPipeRun();
104 public PipeControlPoint getControlPoint() {
110 public void setPosition(Vector3d position) {
111 super.setPosition(position);
116 public void setOrientation(Quat4d orientation) {
117 super.setOrientation(orientation);
121 private void updateCP() {
122 if (controlPoint == null)
124 if (controlPoint.getPipeRun() == null)
126 controlPoint._setWorldPosition(getWorldPosition());
127 controlPoint._setWorldOrientation(getWorldOrientation());
132 public Map<String, Object> updateParameterMap() {
133 Map<String,Object> map = new HashMap<String, Object>();
135 PipeRun pipeRun = getPipeRun();
136 if (pipeRun != null) {
137 //map.put("length", pipeRun.getPipeDiameter() * 2.0);
138 map.put("radius", pipeRun.getPipeDiameter() * 0.5);
144 protected double[] getColor() {
145 return new double[]{0.7,0.7,0.7};
149 protected double[] getSelectedColor() {
150 return new double[]{0.5,0,0.5};
153 public boolean isConnected() {
154 PipeControlPoint pcp = getControlPoint();
155 return (pcp.getNext() != null || pcp.getPrevious() != null);
158 public boolean isNextConnected() {
159 PipeControlPoint pcp = getControlPoint();
160 return (pcp.getNext() != null);
163 public boolean isPrevConnected() {
164 PipeControlPoint pcp = getControlPoint();
165 return (pcp.getNext() != null);