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