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 theDoc document
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 );
77 * \brief Updates the child object name.
78 * \param theOldStr old father object name
79 * \param theNewStr new father object name
80 * \param theObject object to update
82 static void UpdateChildObjectName( const QString& theOldStr,
83 const QString& theNewStr,
84 const Handle(HYDROData_Entity)& theObject );
88 * \brief Generate name for new object in python environment.
89 * \param theTreatedObjects objects which was alredy created by dump operation
90 * \param thePrefix name prefix
91 * \return generated name
93 static QString GenerateNameForPython( const MapOfTreatedObjects& theTreatedObjects,
94 const QString& thePrefix );
97 inline bool ValuesEquals( const double& theFirst, const double& theSecond )
99 return theFirst > ( theSecond - Precision::Confusion() ) &&
100 theFirst < ( theSecond + Precision::Confusion() );
103 inline bool ValuesMoreEquals( const double& theFirst, const double& theSecond )
105 return theFirst >= theSecond || ValuesEquals( theFirst, theSecond );
108 inline bool ValuesLessEquals( const double& theFirst, const double& theSecond )
110 return theFirst <= theSecond || ValuesEquals( theFirst, theSecond );