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