Salome HOME
copyrights are updated
[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( MapOfTreatedObjects& theTreatedObjects ) const;
56
57   /**
58    * Update the immersible zone object.
59    * Call this method whenever you made changes for object data.
60    */
61   HYDRODATA_EXPORT virtual void Update();
62
63   HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy );
64
65   /**
66    * Checks that object has 2D presentation. Reimlemented to retun true.
67    */
68   HYDRODATA_EXPORT virtual bool IsHas2dPrs() const;
69
70   /**
71    * Returns default filling color for new obstacle.
72    */
73   HYDRODATA_EXPORT virtual QColor DefaultFillingColor() const;
74
75   /**
76    * Returns default border color for new obstacle.
77    */
78   HYDRODATA_EXPORT virtual QColor DefaultBorderColor() const;
79
80
81   /**
82    * Sets the 3d shape of the object.
83    */
84   HYDRODATA_EXPORT virtual void SetShape3D( const TopoDS_Shape& theShape );
85
86 public:
87
88   /**
89    * Imports shape from file containing geometrical object and sets this
90    * shape as the obstacle shape.
91    * The supported file types:
92    *  - BREP
93    *  - IGES
94    *  - STEP
95    *  - ACIS
96    * \param theFilePath the path to file
97    * \return \c true if file has been successfully read
98    */
99   HYDRODATA_EXPORT virtual bool ImportFromFile( const QString& theFilePath );
100
101   /**
102    * Stores the file path of the imported file.
103    * \param theFilePath file path
104    */
105   HYDRODATA_EXPORT void SetFilePath(const QString& theFilePath);
106
107   /**
108    * Returns the imported file path.
109    */
110   HYDRODATA_EXPORT QString GetFilePath() const;
111
112   
113   /**
114    * Imports shape from IOR.
115    * \param theIOR the IOR of Geom object
116    * \return \c true if shape has been successfully imported
117    */
118   HYDRODATA_EXPORT virtual bool ImportFromGeomIOR( const TCollection_AsciiString& theIOR );
119
120   /**
121    * Stores the study entry of the imported GEOM object.
122    * \param theEntry GEOM object entry
123    */
124   HYDRODATA_EXPORT void SetGeomObjectEntry( const TCollection_AsciiString& theEntry );
125
126   /**
127    * Returns the imported GEOM object entry.
128    */
129   HYDRODATA_EXPORT TCollection_AsciiString GetGeomObjectEntry() const;
130
131   /**
132    * Returns the imported GEOM object name.
133    */
134   HYDRODATA_EXPORT TCollection_AsciiString GetGeomObjectName() const;
135
136   /**
137    * Translate the obstacle to the given distance.
138    */
139   HYDRODATA_EXPORT void Translate( const double theDx,
140                                    const double theDy,
141                                    const double theDz );
142
143 protected:
144   /**
145    * Returns the type of child altitude object.
146    * Reimplemented to create obstacle altitude object.
147    */
148   HYDRODATA_EXPORT virtual ObjectKind getAltitudeObjectType() const;
149
150 private:
151
152   /**
153    * Imports shape from the BREP file.
154    * \param theFilePath the path to file
155    * \return shape as TopoDS_Shape (null shape if import was failed)
156    */
157   TopoDS_Shape ImportBREP( const QString& theFilePath ) const;
158
159   /**
160    * Imports shape from the IGES file.
161    * \param theFilePath the path to file
162    * \return shape as TopoDS_Shape (null shape if import was failed)
163    */
164   TopoDS_Shape ImportIGES( const QString& theFilePath ) const;
165
166   /**
167    * Imports shape from the STEP file.
168    * \param theFilePath the path to file
169    * \return shape as TopoDS_Shape (null shape if import was failed)
170    */
171   TopoDS_Shape ImportSTEP( const QString& theFilePath ) const;
172
173   /**
174    * Create all necessary child group objects.
175    */
176   void createGroupObjects();
177
178   /**
179    * Sets the translation coefficients.
180    */
181   void setTranslation( const double theDx, const double theDy, const double theDz );
182
183   /**
184    * Returns the translation coefficients.
185    */
186   bool getTranslation( double& theDx, double& theDy, double& theDz ) const;
187
188 protected:
189
190   friend class HYDROData_Iterator;
191
192   /**
193    * Creates new object in the internal data structure. Use higher level objects 
194    * to create objects with real content.
195    */
196   HYDRODATA_EXPORT HYDROData_Obstacle();
197
198   /**
199    * Destructs properties of the object and object itself, removes it from the document.
200    */
201   virtual HYDRODATA_EXPORT ~HYDROData_Obstacle();
202
203 };
204
205 #endif