]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/BoxNode.java
Remove listener calls when property values not updated.
[simantics/3d.git] / org.simantics.g3d.csg / src / org / simantics / g3d / csg / scenegraph2 / BoxNode.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.Box)\r
24 public class BoxNode extends CSGnode {\r
25 \r
26         private double sx = 1.0;\r
27         private double sy = 1.0;\r
28         private double sz = 1.0;\r
29         \r
30         public BoxNode() {\r
31                 System.out.println();\r
32         }\r
33         \r
34         @RelatedSetValue(CSG.URIs.HasXAxisSize)\r
35         @SetPropertyValue(CSG.URIs.HasXAxisSize)\r
36         public void setSX(double d) {\r
37                 if (this.sx == d)\r
38                         return;\r
39                 this.sx = d;\r
40                 firePropertyChanged(CSG.URIs.HasXAxisSize);\r
41         }\r
42         \r
43         @RelatedSetValue(CSG.URIs.HasYAxisSize)\r
44         @SetPropertyValue(CSG.URIs.HasYAxisSize)\r
45         public void setSY(double d) {\r
46                 if (this.sy == d)\r
47                         return;\r
48                 this.sy = d;\r
49                 firePropertyChanged(CSG.URIs.HasYAxisSize);\r
50         }\r
51         \r
52         @RelatedSetValue(CSG.URIs.HasZAxisSize)\r
53         @SetPropertyValue(CSG.URIs.HasZAxisSize)\r
54         public void setSZ(double d) {\r
55                 if (this.sz == d)\r
56                         return;\r
57                 this.sz = d;\r
58                 firePropertyChanged(CSG.URIs.HasZAxisSize);\r
59         }\r
60         \r
61         @RelatedGetValue(CSG.URIs.HasXAxisSize)\r
62         @GetPropertyValue(value=CSG.URIs.HasXAxisSize, name = "X Size")\r
63         public double getSx() {\r
64                 return sx;\r
65         }\r
66         \r
67         @RelatedGetValue(CSG.URIs.HasYAxisSize)\r
68         @GetPropertyValue(value=CSG.URIs.HasYAxisSize, name = "Y Size")\r
69         public double getSy() {\r
70                 return sy;\r
71         }\r
72         \r
73         @RelatedGetValue(CSG.URIs.HasZAxisSize)\r
74         @GetPropertyValue(value=CSG.URIs.HasZAxisSize, name = "Z Size")\r
75         public double getSz() {\r
76                 return sz;\r
77         }\r
78         \r
79         \r
80         @Override\r
81         public TopoDS_Shape getBaseGeometry() {\r
82                 return OccTriangulator.makeBox(-sx * 0.5, -sy * 0.5, -sz * 0.5, sx * 0.5, sy * 0.5, sz * 0.5);\r
83         }\r
84 \r
85 \r
86 }\r