Salome HOME
"Lat" and "Lang" labels added in import image panel (issue).
[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    * \brief Checks the type of object.
65    * \param theObject object to check
66    * \return true if object is geometry object
67    */
68   static bool                           IsGeometryObject( const Handle(HYDROData_Entity)& theObject );
69
70 };
71
72 inline bool ValuesEquals( const double& theFirst, const double& theSecond )
73 {
74   return theFirst > ( theSecond - Precision::Confusion() ) &&
75          theFirst < ( theSecond + Precision::Confusion() );
76 }
77
78 inline bool ValuesMoreEquals( const double& theFirst, const double& theSecond )
79 {
80   return theFirst >= theSecond || ValuesEquals( theFirst, theSecond );
81 }
82
83 inline  bool ValuesLessEquals( const double& theFirst, const double& theSecond )
84 {
85   return theFirst <= theSecond || ValuesEquals( theFirst, theSecond );
86 }
87
88
89
90
91 #endif
92
93