]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROData/HYDROData_Tool.h
Salome HOME
Find object by name were moved to the methods of document.
[modules/hydro.git] / src / HYDROData / HYDROData_Tool.h
1
2 #ifndef HYDROData_Tool_HeaderFile
3 #define HYDROData_Tool_HeaderFile
4
5 #include "HYDROData.h"
6 #include "HYDROData_Entity.h"
7
8 #include <Precision.hxx>
9
10 #include <TopAbs_ShapeEnum.hxx>
11
12 #include <QString>
13 #include <QStringList>
14 #include <gp_XY.hxx>
15 #include <TopoDS_Face.hxx>
16
17 class QFile;
18 class TopoDS_Shape;
19 class TopTools_SequenceOfShape;
20 class Handle(HYDROData_Document);
21
22 class HYDRODATA_EXPORT HYDROData_Tool {
23
24 public:
25
26   static void                           WriteStringsToFile( QFile&             theFile,
27                                                             const QStringList& theStrings,
28                                                             const QString&     theSep = "\n" );
29
30   /**
31    * Enables "MustBeUpdated" flag for objects that are depended on "MustBeUpdated" objects.
32    * \param theDoc document where this operation is performed
33    */
34   static void                           SetMustBeUpdatedObjects( const Handle(HYDROData_Document)& theDoc );
35
36   /**
37    * \brief Generate name for new object.
38    * \param theDoc document
39    * \param thePrefix name prefix
40    * \param theUsedNames list of already used names
41    * \param theIsTryToUsePurePrefix if true - the prefix will be returned if the name equal to the prefix is not busy
42    * \return generated name
43    */
44   static QString                        GenerateObjectName( const Handle(HYDROData_Document)& theDoc,
45                                                             const QString&                    thePrefix,
46                                                             const QStringList&                theUsedNames = QStringList(),
47                                                             const bool                        theIsTryToUsePurePrefix = false );
48
49   /**
50    * \brief Checks the type of object.
51    * \param theObject object to check
52    * \return true if object is geometry object
53    */
54   static bool                           IsGeometryObject( const Handle(HYDROData_Entity)& theObject );
55
56   /**
57    * \brief Updates the child object name.
58    * \param theOldStr old father object name
59    * \param theNewStr new father object name
60    * \param theObject object to update
61    */
62   static void                           UpdateChildObjectName( const QString&                  theOldStr,
63                                                                const QString&                  theNewStr,
64                                                                const Handle(HYDROData_Entity)& theObject );
65
66
67   /**
68    * \brief Generate name for new object in python environment.
69    * \param theTreatedObjects objects which was alredy created by dump operation
70    * \param thePrefix name prefix
71    * \return generated name
72    */
73   static QString                        GenerateNameForPython( const MapOfTreatedObjects& theTreatedObjects,
74                                                                const QString&             thePrefix );
75  /**
76   * Computes Point State from TopAbs (simplified & limited method).
77   */
78
79  static TopAbs_State                    ComputePointState( const gp_XY& thePnt2d, 
80                                                                const TopoDS_Face& theFace );
81 };
82
83 inline bool ValuesEquals( const double& theFirst, const double& theSecond )
84 {
85   return theFirst > ( theSecond - Precision::Confusion() ) &&
86          theFirst < ( theSecond + Precision::Confusion() );
87 }
88
89 inline bool ValuesMoreEquals( const double& theFirst, const double& theSecond )
90 {
91   return theFirst >= theSecond || ValuesEquals( theFirst, theSecond );
92 }
93
94 inline  bool ValuesLessEquals( const double& theFirst, const double& theSecond )
95 {
96   return theFirst <= theSecond || ValuesEquals( theFirst, theSecond );
97 }
98
99
100
101
102 #endif
103
104