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