]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/ConeNode.java
Remove listener calls when property values not updated.
[simantics/3d.git] / org.simantics.g3d.csg / src / org / simantics / g3d / csg / scenegraph2 / ConeNode.java
1 /*******************************************************************************\r
2  * Copyright (c) 2012, 2013 Association for Decentralized Information Management in\r
3  * Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.g3d.csg.scenegraph2;\r
13 \r
14 import org.jcae.opencascade.jni.TopoDS_Shape;\r
15 import org.simantics.g3d.csg.ontology.CSG;\r
16 import org.simantics.g3d.property.annotations.GetPropertyValue;\r
17 import org.simantics.g3d.property.annotations.SetPropertyValue;\r
18 import org.simantics.objmap.graph.annotations.GraphType;\r
19 import org.simantics.objmap.graph.annotations.RelatedGetValue;\r
20 import org.simantics.objmap.graph.annotations.RelatedSetValue;\r
21 import org.simantics.opencascade.OccTriangulator;\r
22 \r
23 @GraphType(CSG.URIs.Cone)\r
24 public class ConeNode extends CSGnode {\r
25 \r
26         private double r1 = 1.0;\r
27         private double r2 = 0.5;\r
28         private double h = 1.0;\r
29         \r
30         \r
31         @RelatedSetValue(CSG.URIs.HasBottomRadius)\r
32         @SetPropertyValue(CSG.URIs.HasBottomRadius)\r
33         public void setR1(double r1) {\r
34                 if (this.r1 == r1)\r
35                         return;\r
36                 this.r1 = r1;\r
37                 firePropertyChanged(CSG.URIs.HasBottomRadius);\r
38         }\r
39         \r
40         @RelatedSetValue(CSG.URIs.HasTopRadius)\r
41         @SetPropertyValue(CSG.URIs.HasTopRadius)\r
42         public void setR2(double r2) {\r
43                 if (this.r2 == r2)\r
44                         return;\r
45                 this.r2 = r2;\r
46                 firePropertyChanged(CSG.URIs.HasTopRadius);\r
47         }\r
48         \r
49         @RelatedSetValue(CSG.URIs.HasHeight)\r
50         @SetPropertyValue(CSG.URIs.HasHeight)\r
51         public void setH(double h) {\r
52                 this.h = h;\r
53                 firePropertyChanged(CSG.URIs.HasHeight);\r
54         }\r
55         \r
56         @RelatedGetValue(CSG.URIs.HasHeight)\r
57         @GetPropertyValue(value=CSG.URIs.HasHeight, name = "Height")\r
58         public double getH() {\r
59                 return h;\r
60         }\r
61         \r
62         @RelatedGetValue(CSG.URIs.HasBottomRadius)\r
63         @GetPropertyValue(value=CSG.URIs.HasBottomRadius, name = "Bottom Radius")\r
64         public double getR1() {\r
65                 return r1;\r
66         }\r
67         \r
68         @RelatedGetValue(CSG.URIs.HasTopRadius)\r
69         @GetPropertyValue(value=CSG.URIs.HasTopRadius, name = "Top Radius")\r
70         public double getR2() {\r
71                 return r2;\r
72         }\r
73         \r
74         @Override\r
75         public TopoDS_Shape getBaseGeometry() {\r
76                 if (Math.abs(r1-r2) > MIN_VALUE) {\r
77 //                      if (r1 < MIN_VALUE)\r
78 //                              return null;\r
79                         return OccTriangulator.makeCone(new double[] { 0.0, -h * 0.5, 0.0 }, new double[] { 0.0, 1.0, 0.0 }, r1,r2, h);\r
80                 } else\r
81                         return OccTriangulator.makeCylinder(new double[] { 0.0, -h * 0.5, 0.0 }, new double[] { 0.0, 1.0, 0.0 }, r1, h);\r
82         }\r
83 \r
84 \r
85 }\r