From a28b2f9db8b078ac1610cc4b626d057b0f0849a4 Mon Sep 17 00:00:00 2001 From: asl Date: Wed, 14 Oct 2015 11:27:56 +0300 Subject: [PATCH] operators are moved to the tool class --- src/HYDROData/HYDROData_Entity.cxx | 16 ++++++ src/HYDROData/HYDROData_Entity.h | 12 +++- src/HYDROData/HYDROData_Tool.cxx | 56 +++++++++++++------ src/HYDROData/HYDROData_Tool.h | 44 ++++++++------- src/HYDRO_tests/test_HYDROData_Main.cxx | 14 +---- .../test_HYDROData_StricklerTable.cxx | 2 +- 6 files changed, 91 insertions(+), 53 deletions(-) diff --git a/src/HYDROData/HYDROData_Entity.cxx b/src/HYDROData/HYDROData_Entity.cxx index eb977ea8..2086ccf1 100644 --- a/src/HYDROData/HYDROData_Entity.cxx +++ b/src/HYDROData/HYDROData_Entity.cxx @@ -38,6 +38,22 @@ #include #include +HYDROData_SequenceOfObjects::HYDROData_SequenceOfObjects() + : NCollection_Sequence() +{ +} + +HYDROData_SequenceOfObjects::HYDROData_SequenceOfObjects( const HYDROData_SequenceOfObjects& theSequence ) + : NCollection_Sequence( theSequence ) +{ +} + +HYDROData_SequenceOfObjects::HYDROData_SequenceOfObjects( const NCollection_Sequence& theSequence ) + : NCollection_Sequence( theSequence ) +{ +} + + static const Standard_GUID GUID_MUST_BE_UPDATED("80f2bb81-3873-4631-8ddd-940d2119f000"); IMPLEMENT_STANDARD_HANDLE(HYDROData_Entity,MMgt_TShared) diff --git a/src/HYDROData/HYDROData_Entity.h b/src/HYDROData/HYDROData_Entity.h index 9b715c18..243a41a2 100644 --- a/src/HYDROData/HYDROData_Entity.h +++ b/src/HYDROData/HYDROData_Entity.h @@ -70,9 +70,17 @@ const ObjectKind KIND_LAST = KIND_LAND_COVER; DEFINE_STANDARD_HANDLE(HYDROData_Entity, MMgt_TShared) -typedef QMap MapOfTreatedObjects; +class MapOfTreatedObjects : public QMap +{ +}; -typedef NCollection_Sequence HYDROData_SequenceOfObjects; +class HYDRODATA_EXPORT HYDROData_SequenceOfObjects : public NCollection_Sequence +{ +public: + HYDROData_SequenceOfObjects(); + HYDROData_SequenceOfObjects( const HYDROData_SequenceOfObjects& ); + HYDROData_SequenceOfObjects( const NCollection_Sequence& ); +}; ///! Is Equal for HYDROData_Entity mapping HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Entity& theObj1, const Handle_HYDROData_Entity& theObj2); diff --git a/src/HYDROData/HYDROData_Tool.cxx b/src/HYDROData/HYDROData_Tool.cxx index 48b9340f..404e19aa 100644 --- a/src/HYDROData/HYDROData_Tool.cxx +++ b/src/HYDROData/HYDROData_Tool.cxx @@ -16,30 +16,28 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include "HYDROData_Tool.h" - -#include "HYDROData_ArtificialObject.h" -#include "HYDROData_Image.h" -#include "HYDROData_Iterator.h" -#include "HYDROData_NaturalObject.h" -#include "HYDROData_ShapesGroup.h" - +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include - -#include -#include -#include -#include -#include +#include #include #include -#include +#include #include +#include +#include #include +#include +#include #include -#include static int aMaxNameId = std::numeric_limits::max(); @@ -304,3 +302,29 @@ QString HYDROData_Tool::toQString( const TCollection_ExtendedString& theStr ) { return QString( (QChar*)theStr.ToExtString(), theStr.Length() ); } + +std::ostream& operator<<( std::ostream& theStream, const QString& theText ) +{ + theStream << theText.toStdString(); + return theStream; +} + +std::ostream& operator<<( std::ostream& theStream, const QColor& theColor ) +{ + theStream << "[" << theColor.red() << ", " << theColor.green() << ", " << theColor.blue() << "]"; + return theStream; +} + +std::ostream& operator<<( std::ostream& theStream, const TopoDS_Shape& theShape ) +{ + theStream << "[" << theShape.TShape().operator->() << "]"; + return theStream; +} + +std::ostream& operator<<( std::ostream& theStream, const TopoDS_Face& theFace ) +{ + theStream << "[" << theFace.TShape().operator->() << "]"; + return theStream; +} + + diff --git a/src/HYDROData/HYDROData_Tool.h b/src/HYDROData/HYDROData_Tool.h index 93de80d5..761f9ec8 100644 --- a/src/HYDROData/HYDROData_Tool.h +++ b/src/HYDROData/HYDROData_Tool.h @@ -20,23 +20,23 @@ #define HYDROData_Tool_HeaderFile #include "HYDROData.h" -#include "HYDROData_Entity.h" - -#include - -#include - -#include #include -#include -#include +#include +class Handle_HYDROData_Document; +class Handle_HYDROData_Entity; +class HYDROData_SequenceOfObjects; +class MapOfTreatedObjects; +class gp_XY; +class QColor; class QFile; -class TopoDS_Shape; -class TopTools_SequenceOfShape; -class Handle(HYDROData_Document); +class TCollection_ExtendedString; +enum TopAbs_State; class TopoDS_Edge; +class TopoDS_Face; +class TopoDS_Shape; class TopoDS_Wire; +class TopTools_SequenceOfShape; class HYDRODATA_EXPORT HYDROData_Tool { @@ -50,7 +50,7 @@ public: * Enables "MustBeUpdated" flag for objects that are depended on "MustBeUpdated" objects. * \param theDoc document where this operation is performed */ - static void SetMustBeUpdatedObjects( const Handle(HYDROData_Document)& theDoc ); + static void SetMustBeUpdatedObjects( const Handle_HYDROData_Document& theDoc ); /** * \brief Generate name for new object. @@ -60,17 +60,17 @@ public: * \param theIsTryToUsePurePrefix if true - the prefix will be returned if the name equal to the prefix is not busy * \return generated name */ - static QString GenerateObjectName( const Handle(HYDROData_Document)& theDoc, - const QString& thePrefix, - const QStringList& theUsedNames = QStringList(), - const bool theIsTryToUsePurePrefix = false ); + static QString GenerateObjectName( const Handle_HYDROData_Document& theDoc, + const QString& thePrefix, + const QStringList& theUsedNames = QStringList(), + const bool theIsTryToUsePurePrefix = false ); /** * \brief Checks the type of object. * \param theObject object to check * \return true if object is geometry object */ - static bool IsGeometryObject( const Handle(HYDROData_Entity)& theObject ); + static bool IsGeometryObject( const Handle_HYDROData_Entity& theObject ); /** * \brief Updates the child object name. @@ -80,7 +80,7 @@ public: */ static void UpdateChildObjectName( const QString& theOldStr, const QString& theNewStr, - const Handle(HYDROData_Entity)& theObject ); + const Handle_HYDROData_Entity& theObject ); /** @@ -137,8 +137,10 @@ inline bool ValuesLessEquals( const double& theFirst, const double& theSecond ) return theFirst <= theSecond || ValuesEquals( theFirst, theSecond ); } - - +HYDRODATA_EXPORT std::ostream& operator<<( std::ostream& theStream, const QString& theText ); +HYDRODATA_EXPORT std::ostream& operator<<( std::ostream& theStream, const QColor& theText ); +HYDRODATA_EXPORT std::ostream& operator<<( std::ostream& theStream, const TopoDS_Shape& theShape ); +HYDRODATA_EXPORT std::ostream& operator<<( std::ostream& theStream, const TopoDS_Face& theFace ); #endif diff --git a/src/HYDRO_tests/test_HYDROData_Main.cxx b/src/HYDRO_tests/test_HYDROData_Main.cxx index 66fcdafc..157fee69 100644 --- a/src/HYDRO_tests/test_HYDROData_Main.cxx +++ b/src/HYDRO_tests/test_HYDROData_Main.cxx @@ -28,18 +28,6 @@ #include #include #include - -std::ostream& operator<<( std::ostream& theStream, const QString& theText ) -{ - theStream << theText.toStdString(); - return theStream; -} - -std::ostream& operator<<( std::ostream& theStream, const QColor& theColor ) -{ - theStream << "[" << theColor.red() << ", " << theColor.green() << ", " << theColor.blue() << "]"; - return theStream; -} #include int main( int argc, char* argv[] ) @@ -90,6 +78,6 @@ int main( int argc, char* argv[] ) return 0; } - //anApp.exec(); + anApp.exec(); return result.wasSuccessful() ? 0 : 1; } diff --git a/src/HYDRO_tests/test_HYDROData_StricklerTable.cxx b/src/HYDRO_tests/test_HYDROData_StricklerTable.cxx index 4c0b5f80..f59a1912 100644 --- a/src/HYDRO_tests/test_HYDROData_StricklerTable.cxx +++ b/src/HYDRO_tests/test_HYDROData_StricklerTable.cxx @@ -19,10 +19,10 @@ #include #include #include +#include #include #include #include -#include const QString DEF_STR_PATH = qgetenv( "HYDRO_ROOT_DIR" ) + "/share/salome/resources/hydro/def_strickler_table.txt"; -- 2.39.2