]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROData/HYDROData_Tool.h
Salome HOME
Update mechanism is corrected (Bug #182).
[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 <QString>
11 #include <QStringList>
12
13 class QFile;
14 class Handle(HYDROData_Document);
15
16 class HYDRODATA_EXPORT HYDROData_Tool {
17
18 public:
19
20   static void                           WriteStringsToFile( QFile&             theFile,
21                                                             const QStringList& theStrings,
22                                                             const QString&     theSep = "\n" );
23
24   /**
25    * Enables "MustBeUpdated" flag for objects that are depended on "MustBeUpdated" objects.
26    * \param theDoc document where this operation is performed
27    */
28   static void                           SetMustBeUpdatedObjects( const Handle(HYDROData_Document)& theDoc );
29
30   /**
31    * \brief Generate name for new object.
32    * \param theModule module
33    * \param thePrefix name prefix
34    * \param theUsedNames list of already used names
35    * \param theIsTryToUsePurePrefix if true - the prefix will be returned if the name equal to the prefix is not busy
36    * \return generated name
37    */
38   static QString                        GenerateObjectName( const Handle(HYDROData_Document)& theDoc,
39                                                             const QString&                    thePrefix,
40                                                             const QStringList&                theUsedNames = QStringList(),
41                                                             const bool                        theIsTryToUsePurePrefix = false );
42
43   /**
44    * \brief Find the data object with the specified name.
45    * \param theModule module
46    * \param theName name
47    * \param theObjectKind kind of object
48    * \return data object
49    */
50   static Handle(HYDROData_Entity)       FindObjectByName( const Handle(HYDROData_Document)& theDoc,
51                                                           const QString&                    theName,
52                                                           const ObjectKind                  theObjectKind = KIND_UNKNOWN );
53
54   /**
55    * \brief Find the data objects with the specified names.
56    * \param theModule module
57    * \param theNames list of names
58    * \param theObjectKind kind of object
59    * \return list of data objects
60    */
61   static HYDROData_SequenceOfObjects    FindObjectsByNames( const Handle(HYDROData_Document)& theDoc,
62                                                             const QStringList&                theNames,
63                                                             const ObjectKind                  theObjectKind = KIND_UNKNOWN );
64
65   /**
66    * \brief Checks the type of object.
67    * \param theObject object to check
68    * \return true if object is geometry object
69    */
70   static bool                           IsGeometryObject( const Handle(HYDROData_Entity)& theObject );
71
72 };
73
74 inline bool ValuesEquals( const double& theFirst, const double& theSecond )
75 {
76   return theFirst > ( theSecond - Precision::Confusion() ) &&
77          theFirst < ( theSecond + Precision::Confusion() );
78 }
79
80 inline bool ValuesMoreEquals( const double& theFirst, const double& theSecond )
81 {
82   return theFirst >= theSecond || ValuesEquals( theFirst, theSecond );
83 }
84
85 inline  bool ValuesLessEquals( const double& theFirst, const double& theSecond )
86 {
87   return theFirst <= theSecond || ValuesEquals( theFirst, theSecond );
88 }
89
90
91
92
93 #endif
94
95