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 void _createCP() throws Exception{
57 if (controlPoint != null)
59 if (getPipeRun() != null) {
60 controlPoint = ControlPointFactory.create(this);
61 // TODO : these should not be needed.
62 controlPoint.setDeletable(false);
63 controlPoint.setFixed(true);
67 @RelatedSetObj(Plant3D.URIs.HasPipeRun)
69 public void setPipeRun(PipeRun pipeRun) {
70 super.setPipeRun(pipeRun);
73 } catch (Exception e) {
74 // TODO Auto-generated catch block
78 firePropertyChanged(Plant3D.URIs.HasPipeRun);
81 @RelatedGetObj(Plant3D.URIs.HasPipeRun)
83 public PipeRun getPipeRun() {
84 return super.getPipeRun();
88 public PipeControlPoint getControlPoint() {
94 public void setPosition(Vector3d position) {
95 super.setPosition(position);
100 public void setOrientation(Quat4d orientation) {
101 super.setOrientation(orientation);
105 private void updateCP() {
106 if (controlPoint == null)
108 if (controlPoint.getPipeRun() == null)
110 controlPoint._setWorldPosition(getWorldPosition());
111 controlPoint._setWorldOrientation(getWorldOrientation());
116 public Map<String, Object> updateParameterMap() {
117 Map<String,Object> map = new HashMap<String, Object>();
119 PipeRun pipeRun = getPipeRun();
120 if (pipeRun != null) {
121 map.put("length", pipeRun.getPipeDiameter() * 2.0);
122 map.put("radius", pipeRun.getPipeDiameter() * 0.5);
128 protected double[] getColor() {
129 return new double[]{0.7,0.7,0.7};
133 protected double[] getSelectedColor() {
134 return new double[]{0.5,0,0.5};
137 public boolean isConnected() {
138 PipeControlPoint pcp = getControlPoint();
139 return (pcp.getNext() != null || pcp.getPrevious() != null);
142 public boolean isNextConnected() {
143 PipeControlPoint pcp = getControlPoint();
144 return (pcp.getNext() != null);
147 public boolean isPrevConnected() {
148 PipeControlPoint pcp = getControlPoint();
149 return (pcp.getNext() != null);