Salome HOME
Bug #487: dump/load script - problem with obstacle.
[modules/hydro.git] / src / HYDROData / HYDROData_Obstacle.h
1
2 #ifndef HYDROData_Obstacle_HeaderFile
3 #define HYDROData_Obstacle_HeaderFile
4
5 #include "HYDROData_ArtificialObject.h"
6
7 DEFINE_STANDARD_HANDLE(HYDROData_Obstacle, HYDROData_ArtificialObject)
8
9 /**\class HYDROData_Obstacle
10  * \brief 
11  *
12  */
13 class HYDROData_Obstacle : public HYDROData_ArtificialObject
14 {
15 protected:
16   /**
17    * Enumeration of tags corresponding to the persistent object parameters.
18    */
19   enum DataTag
20   {
21     DataTag_First = HYDROData_ArtificialObject::DataTag_First + 100, ///< first tag, to reserve
22     DataTag_GeomObjectEntry, ///< study entry of the imported GEOM object
23     DataTag_FilePath,        ///< imported file path
24     DataTag_Translation,     ///< translation coefficients
25   };
26
27 public:
28   DEFINE_STANDARD_RTTI(HYDROData_Obstacle);
29
30   /**
31    * Returns the kind of this object. Must be redefined in all objects of known type.
32    */
33   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_OBSTACLE;}
34
35   /**
36    * Dump object to Python script representation.
37    */
38   HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
39
40   /**
41    * Update the immersible zone object.
42    * Call this method whenever you made changes for object data.
43    */
44   HYDRODATA_EXPORT virtual void Update();
45
46   HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy );
47
48   /**
49    * Checks that object has 2D presentation. Reimlemented to retun true.
50    */
51   HYDRODATA_EXPORT virtual bool IsHas2dPrs() const;
52
53   /**
54    * Returns the top shape of the object.
55    */
56   HYDRODATA_EXPORT virtual TopoDS_Shape GetTopShape() const;
57
58   /**
59    * Returns the 3d shape of the object.
60    */
61   HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
62
63   /**
64    * Returns default filling color for new obstacle.
65    */
66   HYDRODATA_EXPORT static QColor DefaultFillingColor();
67
68   /**
69    * Returns default border color for new obstacle.
70    */
71   HYDRODATA_EXPORT static QColor DefaultBorderColor();
72
73
74   /**
75    * Sets the 3d shape of the object.
76    */
77   HYDRODATA_EXPORT virtual void SetShape3D( const TopoDS_Shape& theShape );
78
79 public:
80
81   /**
82    * Imports shape from file containing geometrical object and sets this
83    * shape as the obstacle shape.
84    * The supported file types:
85    *  - BREP
86    *  - IGES
87    *  - STEP
88    *  - ACIS
89    * \param theFilePath the path to file
90    * \return \c true if file has been successfully read
91    */
92   HYDRODATA_EXPORT virtual bool ImportFromFile( const QString& theFilePath );
93
94   /**
95    * Stores the file path of the imported file.
96    * \param theFilePath file path
97    */
98   HYDRODATA_EXPORT void SetFilePath(const QString& theFilePath);
99
100   /**
101    * Returns the imported file path.
102    */
103   HYDRODATA_EXPORT QString GetFilePath() const;
104
105   
106   /**
107    * Imports shape from IOR.
108    * \param theIOR the IOR of Geom object
109    * \return \c true if shape has been successfully imported
110    */
111   HYDRODATA_EXPORT virtual bool ImportFromGeomIOR( const TCollection_AsciiString& theIOR );
112
113   /**
114    * Stores the study entry of the imported GEOM object.
115    * \param theEntry GEOM object entry
116    */
117   HYDRODATA_EXPORT void SetGeomObjectEntry( const TCollection_AsciiString& theEntry );
118
119   /**
120    * Returns the imported GEOM object entry.
121    */
122   HYDRODATA_EXPORT TCollection_AsciiString GetGeomObjectEntry() const;
123
124   /**
125    * Returns the imported GEOM object name.
126    */
127   HYDRODATA_EXPORT TCollection_AsciiString GetGeomObjectName() const;
128
129   /**
130    * Translate the obstacle to the given distance.
131    */
132   HYDRODATA_EXPORT void Translate( const double theDx,
133                                    const double theDy,
134                                    const double theDz );
135
136 protected:
137
138   /**
139    * Returns default filling color for new object.
140    */
141   HYDRODATA_EXPORT virtual QColor getDefaultFillingColor() const;
142
143   /**
144    * Returns default border color for new object.
145    */
146   HYDRODATA_EXPORT virtual QColor getDefaultBorderColor() const;
147
148   /**
149    * Returns the type of child altitude object.
150    * Reimplemented to create obstacle altitude object.
151    */
152   HYDRODATA_EXPORT virtual ObjectKind getAltitudeObjectType() const;
153
154 private:
155
156   /**
157    * Imports shape from the BREP file.
158    * \param theFilePath the path to file
159    * \return shape as TopoDS_Shape (null shape if import was failed)
160    */
161   TopoDS_Shape ImportBREP( const QString& theFilePath ) const;
162
163   /**
164    * Imports shape from the IGES file.
165    * \param theFilePath the path to file
166    * \return shape as TopoDS_Shape (null shape if import was failed)
167    */
168   TopoDS_Shape ImportIGES( const QString& theFilePath ) const;
169
170   /**
171    * Imports shape from the STEP file.
172    * \param theFilePath the path to file
173    * \return shape as TopoDS_Shape (null shape if import was failed)
174    */
175   TopoDS_Shape ImportSTEP( const QString& theFilePath ) const;
176
177   /**
178    * Create all necessary child group objects.
179    */
180   void createGroupObjects();
181
182   /**
183    * Sets the translation coefficients.
184    */
185   void setTranslation( const double theDx, const double theDy, const double theDz );
186
187   /**
188    * Returns the translation coefficients.
189    */
190   bool getTranslation( double& theDx, double& theDy, double& theDz ) const;
191
192 protected:
193
194   friend class HYDROData_Iterator;
195
196   /**
197    * Creates new object in the internal data structure. Use higher level objects 
198    * to create objects with real content.
199    */
200   HYDRODATA_EXPORT HYDROData_Obstacle();
201
202   /**
203    * Destructs properties of the object and object itself, removes it from the document.
204    */
205   virtual HYDRODATA_EXPORT ~HYDROData_Obstacle();
206
207 };
208
209 #endif