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 abstract class GeometryNode extends P3DNode implements ParameterizedNode, NodeHighlighter {
20 private GeometryComponent component;
22 public GeometryNode() {
23 component = new GeometryComponent() {
25 protected double[] getColor() {
26 return GeometryNode.this.getColor();
30 protected double[] getSelectedColor() {
31 return GeometryNode.this.getSelectedColor();
37 public void visualize(VtkView panel) {
39 component.visualize(panel);
40 update(panel.getRenderer());
43 public void updateParameters() {
44 component.updateParameters();
48 public Map<String, Object> getParameterMap() {
49 return component.getParameterMap();
52 public Map<String, Object> getCalculatedParameters() {
53 return component.getCalculatedParameters();
57 public Map<String, Object> getTotalParameters() {
58 return component.getTotalParameters();
61 public void setParametersUpdated(boolean parametersUpdated) {
62 component.setParametersUpdated(parametersUpdated);
65 public void setParameterMap(Map<String, Object> parameters) {
66 Set<String> ids = component.setParameterMap(parameters);
67 for (String id : ids) {
68 firePropertyChanged(id);
72 @RelatedGetObj(Plant3D.URIs.hasGeometry)
73 public GeometryProvider getGeometry() {
74 return component.getGeometry();
77 @RelatedSetObj(Plant3D.URIs.hasGeometry)
78 public void setGeometry(final GeometryProvider provider) {
79 if (provider != null && provider.equals(component.getGeometry()))
81 component.setGeometry(provider);
82 firePropertyChanged(Plant3D.URIs.hasGeometry);
86 public Collection<vtkProp3D> getActors() {
87 return component.getActors();
91 public void stopVisualize() {
92 component.stopVisualize();
96 public void highlight(HighlightEventType type) {
97 component.highlight(type);
101 protected double[] getSelectedColor() {
102 return new double[]{1,0,0};
105 protected double[] getColor() {
106 return new double[]{1,1,0};
109 public void update(vtkRenderer ren) {
110 vtkUtil.updateTransform(getActors(), getWorldPosition(), getWorldOrientation());