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