Salome HOME
Methods to work with imagw references:
[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 Images that are depended on "MustBeUpdated" images.
26    * \param theDoc document where this operation is performed
27    */
28   static void                           SetMustBeUpdatedImages( 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    * \return generated name
36    */
37   static QString                        GenerateObjectName( const Handle(HYDROData_Document)& theDoc,
38                                                             const QString&                    thePrefix,
39                                                             const QStringList&                theUsedNames = QStringList() );
40
41   /**
42    * \brief Find the data object with the specified name.
43    * \param theModule module
44    * \param theName name
45    * \param theObjectKind kind of object
46    * \return data object
47    */
48   static Handle(HYDROData_Entity)       FindObjectByName( const Handle(HYDROData_Document)& theDoc,
49                                                           const QString&                    theName,
50                                                           const ObjectKind                  theObjectKind = KIND_UNKNOWN );
51
52   /**
53    * \brief Find the data objects with the specified names.
54    * \param theModule module
55    * \param theNames list of names
56    * \param theObjectKind kind of object
57    * \return list of data objects
58    */
59   static HYDROData_SequenceOfObjects    FindObjectsByNames( const Handle(HYDROData_Document)& theDoc,
60                                                             const QStringList&                theNames,
61                                                             const ObjectKind                  theObjectKind = KIND_UNKNOWN );
62 };
63
64 inline bool ValuesEquals( const double& theFirst, const double& theSecond )
65 {
66   return theFirst > ( theSecond - Precision::Confusion() ) &&
67          theFirst < ( theSecond + Precision::Confusion() );
68 }
69
70 inline bool ValuesMoreEquals( const double& theFirst, const double& theSecond )
71 {
72   return theFirst >= theSecond || ValuesEquals( theFirst, theSecond );
73 }
74
75 inline  bool ValuesLessEquals( const double& theFirst, const double& theSecond )
76 {
77   return theFirst <= theSecond || ValuesEquals( theFirst, theSecond );
78 }
79
80
81
82
83 #endif
84
85