2 #ifndef HYDROData_Tool_HeaderFile
3 #define HYDROData_Tool_HeaderFile
6 #include "HYDROData_Entity.h"
8 #include <Precision.hxx>
10 #include <TopAbs_ShapeEnum.hxx>
13 #include <QStringList>
17 class TopTools_SequenceOfShape;
18 class Handle(HYDROData_Document);
20 class HYDRODATA_EXPORT HYDROData_Tool {
24 static void WriteStringsToFile( QFile& theFile,
25 const QStringList& theStrings,
26 const QString& theSep = "\n" );
29 * Enables "MustBeUpdated" flag for objects that are depended on "MustBeUpdated" objects.
30 * \param theDoc document where this operation is performed
32 static void SetMustBeUpdatedObjects( const Handle(HYDROData_Document)& theDoc );
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
42 static QString GenerateObjectName( const Handle(HYDROData_Document)& theDoc,
43 const QString& thePrefix,
44 const QStringList& theUsedNames = QStringList(),
45 const bool theIsTryToUsePurePrefix = false );
48 * \brief Find the data object with the specified name.
49 * \param theModule module
51 * \param theObjectKind kind of object
54 static Handle(HYDROData_Entity) FindObjectByName( const Handle(HYDROData_Document)& theDoc,
55 const QString& theName,
56 const ObjectKind theObjectKind = KIND_UNKNOWN );
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
65 static HYDROData_SequenceOfObjects FindObjectsByNames( const Handle(HYDROData_Document)& theDoc,
66 const QStringList& theNames,
67 const ObjectKind theObjectKind = KIND_UNKNOWN );
70 * \brief Checks the type of object.
71 * \param theObject object to check
72 * \return true if object is geometry object
74 static bool IsGeometryObject( const Handle(HYDROData_Entity)& theObject );
78 inline bool ValuesEquals( const double& theFirst, const double& theSecond )
80 return theFirst > ( theSecond - Precision::Confusion() ) &&
81 theFirst < ( theSecond + Precision::Confusion() );
84 inline bool ValuesMoreEquals( const double& theFirst, const double& theSecond )
86 return theFirst >= theSecond || ValuesEquals( theFirst, theSecond );
89 inline bool ValuesLessEquals( const double& theFirst, const double& theSecond )
91 return theFirst <= theSecond || ValuesEquals( theFirst, theSecond );