2 #ifndef HYDROData_Tool_HeaderFile
3 #define HYDROData_Tool_HeaderFile
6 #include "HYDROData_Entity.h"
8 #include <Precision.hxx>
11 #include <QStringList>
14 class Handle(HYDROData_Document);
16 class HYDRODATA_EXPORT HYDROData_Tool {
20 static void WriteStringsToFile( QFile& theFile,
21 const QStringList& theStrings,
22 const QString& theSep = "\n" );
25 * Enables "MustBeUpdated" flag for objects that are depended on "MustBeUpdated" objects.
26 * \param theDoc document where this operation is performed
28 static void SetMustBeUpdatedObjects( const Handle(HYDROData_Document)& theDoc );
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
38 static QString GenerateObjectName( const Handle(HYDROData_Document)& theDoc,
39 const QString& thePrefix,
40 const QStringList& theUsedNames = QStringList(),
41 const bool theIsTryToUsePurePrefix = false );
44 * \brief Find the data object with the specified name.
45 * \param theModule module
47 * \param theObjectKind kind of object
50 static Handle(HYDROData_Entity) FindObjectByName( const Handle(HYDROData_Document)& theDoc,
51 const QString& theName,
52 const ObjectKind theObjectKind = KIND_UNKNOWN );
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
61 static HYDROData_SequenceOfObjects FindObjectsByNames( const Handle(HYDROData_Document)& theDoc,
62 const QStringList& theNames,
63 const ObjectKind theObjectKind = KIND_UNKNOWN );
66 * \brief Checks the type of object.
67 * \param theObject object to check
68 * \return true if object is geometry object
70 static bool IsGeometryObject( const Handle(HYDROData_Entity)& theObject );
74 inline bool ValuesEquals( const double& theFirst, const double& theSecond )
76 return theFirst > ( theSecond - Precision::Confusion() ) &&
77 theFirst < ( theSecond + Precision::Confusion() );
80 inline bool ValuesMoreEquals( const double& theFirst, const double& theSecond )
82 return theFirst >= theSecond || ValuesEquals( theFirst, theSecond );
85 inline bool ValuesLessEquals( const double& theFirst, const double& theSecond )
87 return theFirst <= theSecond || ValuesEquals( theFirst, theSecond );