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