Salome HOME
middle z for 3D guideline
[modules/hydro.git] / src / HYDROData / HYDROData_Object.h
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #ifndef HYDROData_Object_HeaderFile
20 #define HYDROData_Object_HeaderFile
21
22 #include <HYDROData_Entity.h>
23
24 DEFINE_STANDARD_HANDLE(HYDROData_Object, HYDROData_Entity)
25
26 class TopoDS_Shape;
27 class Handle(HYDROData_IAltitudeObject);
28 class Handle(HYDROData_DummyObject3D);
29 class Handle(HYDROData_ShapesGroup);
30
31 /**\class HYDROData_Object
32  * \brief The base class for all geometrical objects in the HYDRO module.
33  *
34  */
35 class HYDROData_Object : public HYDROData_Entity
36 {
37 protected:
38   /**
39    * Enumeration of tags corresponding to the persistent object parameters.
40    */
41   enum DataTag
42   {
43     DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
44     DataTag_TopShape,
45     DataTag_Shape3D,
46     DataTag_AltitudeObject,      ///< reference altitude object
47     DataTag_FillingColor,        ///< filling color of geometrical object
48     DataTag_BorderColor,         ///< border color of geometrical object
49     DataTag_Object3D,            ///< child 3D object
50     DataTag_EdgesGroup,          ///< child group objects
51     DataTag_ChildAltitudeObject, ///< child altitude object
52     DataTag_IsSubmersible,       ///< the attribute "is submersible"
53     DataTag_MiddleZ,             ///< middle Z value of Shape3D
54   };
55
56 public:
57   DEFINE_STANDARD_RTTI(HYDROData_Object);
58
59   /**
60    * Updates the name of this object.
61    * Reimplemented to update the names child groups.
62    */
63   HYDRODATA_EXPORT virtual void SetName( const QString& theName );
64
65   /**
66    * Update the geometry object.
67    * Call this method whenever you made changes for object data.
68    */
69   HYDRODATA_EXPORT virtual void Update();
70
71   /**
72    * Returns the list of all reference objects of this object.
73    */
74   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
75
76   /**
77    * Sets the "MustBeUpdated" flag: if object is depended on updated features.
78    * Reimplemented to update the state of child 3D object.
79    */
80   HYDRODATA_EXPORT virtual void SetToUpdate( bool theFlag );
81
82
83   /**
84    * Sets the top(2d projection) shape of the object.
85    */
86   HYDRODATA_EXPORT virtual void SetTopShape( const TopoDS_Shape& theShape );
87
88   /**
89    * Returns the top shape of the object.
90    */
91   HYDRODATA_EXPORT virtual TopoDS_Shape GetTopShape() const = 0;
92
93   /**
94    * Sets the 3d shape of the object.
95    */
96   HYDRODATA_EXPORT virtual void SetShape3D( const TopoDS_Shape& theShape );
97
98   /**
99    * Returns the 3d shape of the object.
100    */
101   HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const = 0;
102
103   /**
104    * Returns the middle z value of 3D object representation or -9999 if no value.
105    */
106   HYDRODATA_EXPORT virtual Standard_Boolean GetMiddleZ( Standard_Real& theMiddleZ ) const;
107
108   /**
109    * Set the middle z value of 3D object representation.
110    */
111   HYDRODATA_EXPORT virtual void SetMiddleZ( const Standard_Real& theMiddleZ );
112
113   /**
114    * Returns reference object which represent the 3D shape of object.
115    */
116   HYDRODATA_EXPORT virtual Handle(HYDROData_DummyObject3D) GetObject3D() const;
117
118
119   /**
120    * Returns sequence of object groups.
121    */
122   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGroups() const;
123
124   /**
125    * Returns group data model object by it id.
126    */
127   HYDRODATA_EXPORT virtual Handle(HYDROData_ShapesGroup) GetGroup( const int theGroupId ) const;
128
129   /**
130    * Returns group id by data model object.
131    */
132   HYDRODATA_EXPORT virtual int GetGroupId( const Handle(HYDROData_ShapesGroup)& theGroup ) const;
133
134
135   /**
136    * Set reference altitude object for geometry object.
137    */
138   HYDRODATA_EXPORT virtual bool SetAltitudeObject( const Handle(HYDROData_IAltitudeObject)& theAltitude );
139
140   /**
141    * Returns reference altitude object of geometry object.
142    */
143   HYDRODATA_EXPORT virtual Handle(HYDROData_IAltitudeObject) GetAltitudeObject() const;
144
145   /**
146    * Clear the reference altitude object for geometry object.
147    */
148   HYDRODATA_EXPORT virtual void RemoveAltitudeObject();
149
150
151    /**
152    * Sets filling color for object.
153    */
154   HYDRODATA_EXPORT virtual void SetFillingColor( const QColor& theColor );
155
156   /**
157    * Returns filling color of object.
158    */
159   HYDRODATA_EXPORT virtual QColor GetFillingColor() const;
160
161    /**
162    * Sets border color for object.
163    */
164   HYDRODATA_EXPORT virtual void SetBorderColor( const QColor& theColor );
165
166   /**
167    * Returns border color of object.
168    */
169   HYDRODATA_EXPORT virtual QColor GetBorderColor() const;
170
171   HYDRODATA_EXPORT bool IsSubmersible() const;
172   HYDRODATA_EXPORT void SetIsSubmersible( bool ) const;
173
174 protected:
175
176   /**
177    * Returns default filling color for new object.
178    */
179   HYDRODATA_EXPORT virtual QColor getDefaultFillingColor() const;
180
181   /**
182    * Returns default border color for new object.
183    */
184   HYDRODATA_EXPORT virtual QColor getDefaultBorderColor() const;
185
186 protected:
187
188   /**
189    * Creates new object in the internal data structure. Use higher level objects 
190    * to create objects with real content.
191    */
192   HYDRODATA_EXPORT HYDROData_Object();
193
194   /**
195    * Destructs properties of the object and object itself, removes it from the document.
196    */
197   virtual HYDRODATA_EXPORT ~HYDROData_Object();
198
199 protected:
200
201   /**
202    * Dump the initial object creation to a Python script.
203    * Reimplemented to dump the object colors.
204    */
205   HYDRODATA_EXPORT virtual QStringList dumpObjectCreation( MapOfTreatedObjects& theTreatedObjects ) const;
206
207
208   /**
209    * Checks and if necessary create child 3D object.
210    * Reimplement this function in your subclass if you 
211    * do not want to create child 3D object.
212    */
213   HYDRODATA_EXPORT virtual void checkAndSetObject3D();
214
215
216   /**
217    * Returns the type of child altitude object.
218    * Base implementation returns KIND_UNKNOWN, it means that child altitude 
219    * object will not be created inside of checkAndSetAltitudeObject() function.
220    * Reimplement this function in your subclass an return correct altitude
221    * object type if you want to create child altitude object.
222    */
223   HYDRODATA_EXPORT virtual ObjectKind getAltitudeObjectType() const;
224
225   /**
226    * Checks and if necessary create child altitude object.
227    */
228   HYDRODATA_EXPORT virtual void checkAndSetAltitudeObject();
229
230   /**
231    * Return the child altitude object.
232    */
233   HYDRODATA_EXPORT virtual Handle(HYDROData_IAltitudeObject) getChildAltitudeObject() const;
234
235
236   /**
237    * Create new one child group object.
238    */
239   HYDRODATA_EXPORT virtual Handle(HYDROData_ShapesGroup) createGroupObject();
240
241   /**
242    * Remove all child group objects.
243    */
244   HYDRODATA_EXPORT virtual void removeGroupObjects();
245
246
247   /**
248    * Retrieve the top shape of the object from data label.
249    */
250   HYDRODATA_EXPORT TopoDS_Shape getTopShape() const;
251
252   /**
253    * Removes the top shape from data label of the object.
254    */
255   HYDRODATA_EXPORT void removeTopShape();
256
257
258   /**
259    * Retrieve the 3d shape of the object from data label.
260    */
261   HYDRODATA_EXPORT TopoDS_Shape getShape3D() const;
262
263   /**
264    * Removes the 3d shape from data label of the object.
265    */
266   HYDRODATA_EXPORT void removeShape3D();
267 };
268
269 #endif