Salome HOME
[fix] After merge with BR_PY3
[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 class TopoDS_Shape;
25 class HYDROData_IAltitudeObject;
26 class HYDROData_DummyObject3D;
27 class HYDROData_ShapesGroup;
28
29 /**\class HYDROData_Object
30  * \brief The base class for all geometrical objects in the HYDRO module.
31  *
32  */
33 class HYDROData_Object : public HYDROData_Entity
34 {
35 protected:
36   /**
37    * Enumeration of tags corresponding to the persistent object parameters.
38    */
39   enum DataTag
40   {
41     DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
42     DataTag_TopShape,
43     DataTag_Shape3D,
44     DataTag_AltitudeObject,      ///< reference altitude object
45     DataTag_FillingColor,        ///< filling color of geometrical object
46     DataTag_BorderColor,         ///< border color of geometrical object
47     DataTag_Object3D,            ///< child 3D object
48     DataTag_EdgesGroup,          ///< child group objects
49     DataTag_ChildAltitudeObject, ///< child altitude object
50     DataTag_IsSubmersible,       ///< the attribute "is submersible"
51   };
52
53 public:
54   DEFINE_STANDARD_RTTIEXT(HYDROData_Object, HYDROData_Entity);
55
56   /**
57    * Updates the name of this object.
58    * Reimplemented to update the names child groups.
59    */
60   HYDRODATA_EXPORT virtual void SetName( const QString& theName );
61
62   /**
63    * Update the geometry object.
64    * Call this method whenever you made changes for object data.
65    */
66   HYDRODATA_EXPORT virtual void Update();
67
68   /**
69    * Returns the list of all reference objects of this object.
70    */
71   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
72
73   /**
74    * Sets the "MustBeUpdated" flag: if object is depended on updated features.
75    * Reimplemented to update the state of child 3D object.
76    */
77   HYDRODATA_EXPORT virtual void Changed( Geometry );
78
79
80   /**
81    * Sets the top(2d projection) shape of the object.
82    */
83   HYDRODATA_EXPORT virtual void SetTopShape( const TopoDS_Shape& theShape );
84
85   /**
86    * Returns the top shape of the object.
87    */
88   HYDRODATA_EXPORT virtual TopoDS_Shape GetTopShape() const;
89
90   /**
91    * Sets the 3d shape of the object.
92    */
93   HYDRODATA_EXPORT virtual void SetShape3D( const TopoDS_Shape& theShape );
94
95   /**
96    * Returns the 3d shape of the object.
97    */
98   HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
99
100   /**
101    * Returns reference object which represent the 3D shape of object.
102    */
103   HYDRODATA_EXPORT virtual Handle(HYDROData_DummyObject3D) GetObject3D() const;
104
105
106   /**
107    * Returns sequence of object groups.
108    */
109   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGroups() const;
110
111   /**
112    * Returns group data model object by it id.
113    */
114   HYDRODATA_EXPORT virtual Handle(HYDROData_ShapesGroup) GetGroup( const int theGroupId ) const;
115
116   /**
117    * Returns group id by data model object.
118    */
119   HYDRODATA_EXPORT virtual int GetGroupId( const Handle(HYDROData_ShapesGroup)& theGroup ) const;
120
121
122   /**
123    * Set reference altitude object for geometry object.
124    */
125   HYDRODATA_EXPORT virtual bool SetAltitudeObject( const Handle(HYDROData_IAltitudeObject)& theAltitude );
126
127   /**
128    * Returns reference altitude object of geometry object.
129    */
130   HYDRODATA_EXPORT virtual Handle(HYDROData_IAltitudeObject) GetAltitudeObject() const;
131
132   /**
133    * Clear the reference altitude object for geometry object.
134    */
135   HYDRODATA_EXPORT virtual void RemoveAltitudeObject();
136
137
138    /**
139    * Sets filling color for object.
140    */
141   HYDRODATA_EXPORT virtual void SetFillingColor( const QColor& theColor );
142
143   /**
144    * Returns filling color of object.
145    */
146   HYDRODATA_EXPORT virtual QColor GetFillingColor() const;
147
148    /**
149    * Sets border color for object.
150    */
151   HYDRODATA_EXPORT virtual void SetBorderColor( const QColor& theColor );
152
153   /**
154    * Returns border color of object.
155    */
156   HYDRODATA_EXPORT virtual QColor GetBorderColor() const;
157
158   HYDRODATA_EXPORT bool IsSubmersible() const;
159   HYDRODATA_EXPORT void SetIsSubmersible( bool ) const;
160
161   HYDRODATA_EXPORT virtual void GetBoundaries( QList<TopoDS_Shape>& theBoundShapes,
162                                                QStringList& theBoundNames ) const;
163
164 protected:
165
166   /**
167    * Creates new object in the internal data structure. Use higher level objects 
168    * to create objects with real content.
169    */
170   HYDRODATA_EXPORT HYDROData_Object( Geometry );
171
172   /**
173    * Destructs properties of the object and object itself, removes it from the document.
174    */
175   virtual HYDRODATA_EXPORT ~HYDROData_Object();
176
177 protected:
178   HYDRODATA_EXPORT virtual QColor DefaultFillingColor() const;
179   HYDRODATA_EXPORT virtual QColor DefaultBorderColor() const;
180
181   /**
182    * Dump the initial object creation to a Python script.
183    * Reimplemented to dump the object colors.
184    */
185   HYDRODATA_EXPORT virtual QStringList dumpObjectCreation( MapOfTreatedObjects& theTreatedObjects ) const;
186
187
188   /**
189    * Checks and if necessary create child 3D object.
190    * Reimplement this function in your subclass if you 
191    * do not want to create child 3D object.
192    */
193   HYDRODATA_EXPORT virtual void checkAndSetObject3D();
194
195
196   /**
197    * Returns the type of child altitude object.
198    * Base implementation returns KIND_UNKNOWN, it means that child altitude 
199    * object will not be created inside of checkAndSetAltitudeObject() function.
200    * Reimplement this function in your subclass an return correct altitude
201    * object type if you want to create child altitude object.
202    */
203   HYDRODATA_EXPORT virtual ObjectKind getAltitudeObjectType() const;
204
205   /**
206    * Checks and if necessary create child altitude object.
207    */
208   HYDRODATA_EXPORT virtual void checkAndSetAltitudeObject();
209
210   /**
211    * Return the child altitude object.
212    */
213   HYDRODATA_EXPORT virtual Handle(HYDROData_IAltitudeObject) getChildAltitudeObject() const;
214
215
216   /**
217    * Create new one child group object.
218    */
219   HYDRODATA_EXPORT virtual Handle(HYDROData_ShapesGroup) createGroupObject();
220
221   /**
222    * Remove all child group objects.
223    */
224   HYDRODATA_EXPORT virtual void RemoveGroupObjects();
225
226   /**
227    * Removes the top shape from data label of the object.
228    */
229   HYDRODATA_EXPORT void RemoveTopShape();
230
231   /**
232    * Removes the 3d shape from data label of the object.
233    */
234   HYDRODATA_EXPORT void RemoveShape3D();
235 };
236
237 #endif