]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROData/HYDROData_Tool.h
Salome HOME
One useful method added.
[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
15 class QFile;
16 class TopoDS_Shape;
17 class TopTools_SequenceOfShape;
18 class Handle(HYDROData_Document);
19
20 class HYDRODATA_EXPORT HYDROData_Tool {
21
22 public:
23
24   static void                           WriteStringsToFile( QFile&             theFile,
25                                                             const QStringList& theStrings,
26                                                             const QString&     theSep = "\n" );
27
28   /**
29    * Enables "MustBeUpdated" flag for objects that are depended on "MustBeUpdated" objects.
30    * \param theDoc document where this operation is performed
31    */
32   static void                           SetMustBeUpdatedObjects( const Handle(HYDROData_Document)& theDoc );
33
34   /**
35    * \brief Generate name for new object.
36    * \param theDoc document
37    * \param thePrefix name prefix
38    * \param theUsedNames list of already used names
39    * \param theIsTryToUsePurePrefix if true - the prefix will be returned if the name equal to the prefix is not busy
40    * \return generated name
41    */
42   static QString                        GenerateObjectName( const Handle(HYDROData_Document)& theDoc,
43                                                             const QString&                    thePrefix,
44                                                             const QStringList&                theUsedNames = QStringList(),
45                                                             const bool                        theIsTryToUsePurePrefix = false );
46
47   /**
48    * \brief Find the data object with the specified name.
49    * \param theModule module
50    * \param theName name
51    * \param theObjectKind kind of object
52    * \return data object
53    */
54   static Handle(HYDROData_Entity)       FindObjectByName( const Handle(HYDROData_Document)& theDoc,
55                                                           const QString&                    theName,
56                                                           const ObjectKind                  theObjectKind = KIND_UNKNOWN );
57
58   /**
59    * \brief Find the data objects with the specified names.
60    * \param theModule module
61    * \param theNames list of names
62    * \param theObjectKind kind of object
63    * \return list of data objects
64    */
65   static HYDROData_SequenceOfObjects    FindObjectsByNames( const Handle(HYDROData_Document)& theDoc,
66                                                             const QStringList&                theNames,
67                                                             const ObjectKind                  theObjectKind = KIND_UNKNOWN );
68
69   /**
70    * \brief Checks the type of object.
71    * \param theObject object to check
72    * \return true if object is geometry object
73    */
74   static bool                           IsGeometryObject( const Handle(HYDROData_Entity)& theObject );
75
76   /**
77    * \brief Updates the child object name.
78    * \param theOldStr old father object name
79    * \param theNewStr new father object name
80    * \param theObject object to update
81    */
82   static void                           UpdateChildObjectName( const QString&                  theOldStr,
83                                                                const QString&                  theNewStr,
84                                                                const Handle(HYDROData_Entity)& theObject );
85
86
87   /**
88    * \brief Generate name for new object in python environment.
89    * \param theTreatedObjects objects which was alredy created by dump operation
90    * \param thePrefix name prefix
91    * \return generated name
92    */
93   static QString                        GenerateNameForPython( const MapOfTreatedObjects& theTreatedObjects,
94                                                                const QString&             thePrefix );
95 };
96
97 inline bool ValuesEquals( const double& theFirst, const double& theSecond )
98 {
99   return theFirst > ( theSecond - Precision::Confusion() ) &&
100          theFirst < ( theSecond + Precision::Confusion() );
101 }
102
103 inline bool ValuesMoreEquals( const double& theFirst, const double& theSecond )
104 {
105   return theFirst >= theSecond || ValuesEquals( theFirst, theSecond );
106 }
107
108 inline  bool ValuesLessEquals( const double& theFirst, const double& theSecond )
109 {
110   return theFirst <= theSecond || ValuesEquals( theFirst, theSecond );
111 }
112
113
114
115
116 #endif
117
118