Salome HOME
cf48d52c107b21de103a075864394d1a68db2021
[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 theModule module
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
78 inline bool ValuesEquals( const double& theFirst, const double& theSecond )
79 {
80   return theFirst > ( theSecond - Precision::Confusion() ) &&
81          theFirst < ( theSecond + Precision::Confusion() );
82 }
83
84 inline bool ValuesMoreEquals( const double& theFirst, const double& theSecond )
85 {
86   return theFirst >= theSecond || ValuesEquals( theFirst, theSecond );
87 }
88
89 inline  bool ValuesLessEquals( const double& theFirst, const double& theSecond )
90 {
91   return theFirst <= theSecond || ValuesEquals( theFirst, theSecond );
92 }
93
94
95
96
97 #endif
98
99