1 package org.simantics.plant3d.scenegraph;
3 import java.util.Collection;
7 import org.simantics.g3d.scenegraph.GeometryProvider;
8 import org.simantics.g3d.scenegraph.NodeHighlighter;
9 import org.simantics.g3d.vtk.common.VtkView;
10 import org.simantics.g3d.vtk.utils.vtkUtil;
11 import org.simantics.objmap.graph.annotations.RelatedGetObj;
12 import org.simantics.objmap.graph.annotations.RelatedSetObj;
13 import org.simantics.plant3d.ontology.Plant3D;
16 import vtk.vtkRenderer;
18 public class P3DParentGeometryNode<T extends IP3DNode> extends P3DParentNode<T> implements ParameterizedNode, NodeHighlighter{
20 private GeometryComponent component;
23 public P3DParentGeometryNode() {
24 component = new GeometryComponent() {
26 protected double[] getColor() {
27 return P3DParentGeometryNode.this.getColor();
31 protected double[] getSelectedColor() {
32 return P3DParentGeometryNode.this.getSelectedColor();
38 public void visualize(VtkView ren) {
40 component.visualize(ren);
41 update(ren.getRenderer());
44 public void updateParameters() {
45 component.updateParameters();
48 public Map<String, Object> getParameterMap() {
49 return component.getParameterMap();
52 public Map<String, Object> getCalculatedParameters() {
53 return component.getCalculatedParameters();
56 public void setParameterMap(Map<String, Object> parameters) {
57 Set<String> ids = component.setParameterMap(parameters);
58 for (String id : ids) {
59 firePropertyChanged(id);
64 @RelatedGetObj(Plant3D.URIs.hasGeometry)
65 public GeometryProvider getGeometry() {
66 //return geometryProvider;
67 return component.getGeometry();
70 @RelatedSetObj(Plant3D.URIs.hasGeometry)
71 public void setGeometry(final GeometryProvider provider) {
72 if (provider != null && provider.equals(component.getGeometry()))
74 component.setGeometry(provider);
75 firePropertyChanged(Plant3D.URIs.hasGeometry);
80 public Collection<vtkProp3D> getActors() {
81 return component.getActors();
85 public void stopVisualize() {
86 component.stopVisualize();
90 public void highlight(HighlightEventType type) {
91 component.highlight(type);
94 protected double[] getSelectedColor() {
95 return new double[]{1,0,0};
98 protected double[] getColor() {
99 return new double[]{1,1,0};
104 public void update(vtkRenderer ren) {
105 vtkUtil.updateTransform(getActors(), getWorldPosition(), getWorldOrientation());