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