1 /*******************************************************************************
\r
2 * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.
\r
3 * All rights reserved. This program and the accompanying materials
\r
4 * are made available under the terms of the Eclipse Public License v1.0
\r
5 * which accompanies this distribution, and is available at
\r
6 * http://www.eclipse.org/legal/epl-v10.html
\r
9 * VTT Technical Research Centre of Finland - initial API and implementation
\r
10 *******************************************************************************/
\r
11 package org.simantics.processeditor.scenegraph;
\r
13 import javax.vecmath.AxisAngle4d;
\r
15 import org.simantics.db.Graph;
\r
16 import org.simantics.db.Resource;
\r
17 import org.simantics.processeditor.ProcessResource;
\r
18 import org.simantics.processeditor.common.ControlPointTools;
\r
19 import org.simantics.processeditor.stubs.PipeControlPoint;
\r
20 import org.simantics.processeditor.stubs.PipelineComponent;
\r
21 import org.simantics.proconf.g3d.base.ThreeDimensionalEditorBase;
\r
22 import org.simantics.proconf.g3d.scenegraph.IGraphicsNode;
\r
23 import org.simantics.proconf.g3d.scenegraph.ParameterizedModelNode;
\r
28 public class PipelineComponentNode extends ParameterizedModelNode {
\r
30 boolean updating = false;
\r
32 public PipelineComponentNode(ThreeDimensionalEditorBase editor, IGraphicsNode parent, Graph graph, Resource resource) {
\r
33 super(editor,parent,graph, resource, ProcessResource.plant3Dresource.HasGraphics);
\r
34 PipelineComponent component = new PipelineComponent(graph, resource);
\r
35 if(!component.isInstanceOf(ProcessResource.plant3Dresource.PipelineComponent))
\r
36 throw new RuntimeException("Resource must be instance of Inline Component " + resource);
\r
37 if (!(parent instanceof PipeRunNode))
\r
38 throw new RuntimeException("Parent must be instance of PipelineNode " + parent.getResource() + " " + resource);
\r
40 //PipeControlPoint pcp = component.getControlPoint();
\r
41 // monitor = new StructuralChangeMonitor(
\r
42 // new StructuralChangeListener[] { this }, pcp.getResource(), GlobalIdMap
\r
43 // .get(Layer0Mapping.HAS_PROPERTY));
\r
44 updateTransform(graph);
\r
47 // public void handleUpdate(StructuralChangeMonitor monitor, GraphChangeEvent event) {
\r
50 // if (event.getParameter() instanceof InlineComponentNode)
\r
52 // if (event.getTransactionId() == null)
\r
54 // if (event.getParameter() instanceof AbstractGraphicsNode)
\r
58 // updateTransform();
\r
59 // updating = false;
\r
62 public void updateTransform(Graph graph) {
\r
63 super.updateTransform(graph);
\r
65 PipelineComponent component = new PipelineComponent(graph,shapeResource);
\r
67 PipeControlPoint pcp = component.getControlPoint();
\r
68 Double angle = component.getAtMostOneRelatedScalarDouble(ProcessResource.plant3Dresource.HasRotationAngle);
\r
69 double componentAngle = 0.0;
\r
71 componentAngle = angle;
\r
73 AxisAngle4d aa = ControlPointTools.getControlPointRotation(pcp, componentAngle);
\r
79 public void dispose() {
\r
80 //monitor.dispose();
\r