From b20ed0044cebfdd161511eae3dd31f3d0ccc8810 Mon Sep 17 00:00:00 2001 From: adv Date: Mon, 23 Sep 2013 12:52:29 +0000 Subject: [PATCH] The region object has been added for HYDRO data model. --- src/HYDROData/CMakeLists.txt | 4 + src/HYDROData/HYDROData.vcproj | 16 +++ src/HYDROData/HYDROData_Calculation.cxx | 37 +++---- src/HYDROData/HYDROData_Calculation.h | 35 +++--- src/HYDROData/HYDROData_Domain.cxx | 128 ++++++++++++++++++++++ src/HYDROData/HYDROData_Domain.h | 137 ++++++++++++++++++++++++ src/HYDROData/HYDROData_Iterator.cxx | 4 + src/HYDROData/HYDROData_Object.h | 3 +- src/HYDROData/HYDROData_Region.cxx | 27 +++++ src/HYDROData/HYDROData_Region.h | 55 ++++++++++ src/HYDROData/HYDROData_Zone.cxx | 111 ++----------------- src/HYDROData/HYDROData_Zone.h | 85 ++------------- 12 files changed, 431 insertions(+), 211 deletions(-) create mode 100644 src/HYDROData/HYDROData_Domain.cxx create mode 100644 src/HYDROData/HYDROData_Domain.h create mode 100644 src/HYDROData/HYDROData_Region.cxx create mode 100644 src/HYDROData/HYDROData_Region.h diff --git a/src/HYDROData/CMakeLists.txt b/src/HYDROData/CMakeLists.txt index 8928c59c..fb5bb5eb 100644 --- a/src/HYDROData/CMakeLists.txt +++ b/src/HYDROData/CMakeLists.txt @@ -6,12 +6,14 @@ set(PROJECT_HEADERS HYDROData_Bathymetry.h HYDROData_Calculation.h HYDROData_Document.h + HYDROData_Domain.h HYDROData_Lambert93.h HYDROData_Image.h HYDROData_Iterator.h HYDROData_Object.h HYDROData_Polyline.h HYDROData_VisualState.h + HYDROData_Region.h HYDROData_Tool.h HYDROData_Zone.h HYDROOperations_Factory.h @@ -23,12 +25,14 @@ set(PROJECT_SOURCES HYDROData_Bathymetry.cxx HYDROData_Calculation.cxx HYDROData_Document.cxx + HYDROData_Domain.cxx HYDROData_Image.cxx HYDROData_Iterator.cxx HYDROData_Lambert93.cxx HYDROData_Object.cxx HYDROData_Polyline.cxx HYDROData_VisualState.cxx + HYDROData_Region.cxx HYDROData_Tool.cxx HYDROData_Zone.cxx HYDROOperations_Factory.cxx diff --git a/src/HYDROData/HYDROData.vcproj b/src/HYDROData/HYDROData.vcproj index bacb345f..9c90a8ab 100644 --- a/src/HYDROData/HYDROData.vcproj +++ b/src/HYDROData/HYDROData.vcproj @@ -141,6 +141,10 @@ RelativePath=".\HYDROData_Document.cxx" > + + @@ -157,6 +161,10 @@ RelativePath=".\HYDROData_Polyline.cxx" > + + @@ -222,6 +230,10 @@ RelativePath=".\HYDROData_Document.h" > + + @@ -238,6 +250,10 @@ RelativePath=".\HYDROData_Polyline.h" > + + diff --git a/src/HYDROData/HYDROData_Calculation.cxx b/src/HYDROData/HYDROData_Calculation.cxx index 766077e1..f11513cc 100644 --- a/src/HYDROData/HYDROData_Calculation.cxx +++ b/src/HYDROData/HYDROData_Calculation.cxx @@ -5,6 +5,7 @@ #include "HYDROData_Iterator.h" #include "HYDROData_Polyline.h" #include "HYDROData_Zone.h" +#include "HYDROData_Region.h" #include @@ -55,14 +56,14 @@ QStringList HYDROData_Calculation::DumpToPython( MapOfTreatedObjects& theTreated } aResList << QString( "" ); - aZones = GetSplittedZones(); + aZones = GetRegions(); anIter.Init( aZones ); for ( ; anIter.More(); anIter.Next() ) { Handle(HYDROData_Zone) aSplittedZone = Handle(HYDROData_Zone)::DownCast( anIter.Value() ); if ( !aSplittedZone.IsNull() ) - setPythonReferenceObject( theTreatedObjects, aResList, aSplittedZone, "AddSplittedZone" ); + setPythonReferenceObject( theTreatedObjects, aResList, aSplittedZone, "AddRegion" ); } return aResList; @@ -121,40 +122,40 @@ void HYDROData_Calculation::RemoveZones() ClearReferenceObjects( DataTag_Zone ); } -int HYDROData_Calculation::NbSplittedZones() const +int HYDROData_Calculation::NbRegions() const { - return NbReferenceObjects( DataTag_SplittedZone ); + return NbReferenceObjects( DataTag_Region ); } -void HYDROData_Calculation::AddSplittedZone( const Handle(HYDROData_Zone)& theZone ) +void HYDROData_Calculation::AddRegion( const Handle(HYDROData_Region)& theRegion ) { - AddReferenceObject( theZone, DataTag_SplittedZone ); + AddReferenceObject( theRegion, DataTag_Region ); } -void HYDROData_Calculation::SetSplittedZone( const int theIndex, - const Handle(HYDROData_Zone)& theZone ) +void HYDROData_Calculation::SetRegion( const int theIndex, + const Handle(HYDROData_Region)& theRegion ) { - SetReferenceObject( theZone, DataTag_SplittedZone, theIndex ); + SetReferenceObject( theRegion, DataTag_Region, theIndex ); } -void HYDROData_Calculation::SetSplittedZones( const HYDROData_SequenceOfObjects& theZones ) +void HYDROData_Calculation::SetRegions( const HYDROData_SequenceOfObjects& theRegions ) { - SetReferenceObjects( theZones, DataTag_SplittedZone ); + SetReferenceObjects( theRegions, DataTag_Region ); } -Handle(HYDROData_Zone) HYDROData_Calculation::GetSplittedZone( const int theIndex ) const +Handle(HYDROData_Region) HYDROData_Calculation::GetRegion( const int theIndex ) const { - return Handle(HYDROData_Zone)::DownCast( - GetReferenceObject( DataTag_SplittedZone, theIndex ) ); + return Handle(HYDROData_Region)::DownCast( + GetReferenceObject( DataTag_Region, theIndex ) ); } -HYDROData_SequenceOfObjects HYDROData_Calculation::GetSplittedZones() const +HYDROData_SequenceOfObjects HYDROData_Calculation::GetRegions() const { - return GetReferenceObjects( DataTag_SplittedZone ); + return GetReferenceObjects( DataTag_Region ); } -void HYDROData_Calculation::RemoveSplittedZones() +void HYDROData_Calculation::RemoveRegions() { - ClearReferenceObjects( DataTag_SplittedZone ); + ClearReferenceObjects( DataTag_Region ); } diff --git a/src/HYDROData/HYDROData_Calculation.h b/src/HYDROData/HYDROData_Calculation.h index 64de389e..a5b72c0f 100644 --- a/src/HYDROData/HYDROData_Calculation.h +++ b/src/HYDROData/HYDROData_Calculation.h @@ -11,6 +11,7 @@ class QFile; class Handle(HYDROData_Polyline); class Handle(HYDROData_Zone); +class Handle(HYDROData_Region); DEFINE_STANDARD_HANDLE(HYDROData_Calculation, HYDROData_Object) @@ -33,7 +34,7 @@ protected: DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve DataTag_BoundaryPolyline, ///< reference boundary polyline DataTag_Zone, ///< reference zones - DataTag_SplittedZone ///< reference splitted zones + DataTag_Region ///< reference regions }; public: @@ -84,7 +85,7 @@ public: * Replace the refrence zone for calculation case. */ HYDRODATA_EXPORT virtual void SetZone( const int theIndex, - const Handle(HYDROData_Zone)& theBathymetry ); + const Handle(HYDROData_Zone)& theZone ); /** * Sets the refrence zones for calculation case. @@ -108,40 +109,40 @@ public: /** - * Returns number of splitted zones for calculation case. + * Returns number of regions for calculation case. */ - HYDRODATA_EXPORT virtual int NbSplittedZones() const; + HYDRODATA_EXPORT virtual int NbRegions() const; /** - * Add new one splitted zone for calculation case. + * Add new one region for calculation case. */ - HYDRODATA_EXPORT virtual void AddSplittedZone( const Handle(HYDROData_Zone)& theZone ); + HYDRODATA_EXPORT virtual void AddRegion( const Handle(HYDROData_Region)& theRegion ); /** - * Replace the splitted zone for calculation case. + * Replace the region for calculation case. */ - HYDRODATA_EXPORT virtual void SetSplittedZone( const int theIndex, - const Handle(HYDROData_Zone)& theBathymetry ); + HYDRODATA_EXPORT virtual void SetRegion( const int theIndex, + const Handle(HYDROData_Region)& theRegion ); /** - * Sets the refrence zones for calculation case. + * Sets the refrence region for calculation case. */ - HYDRODATA_EXPORT virtual void SetSplittedZones( const HYDROData_SequenceOfObjects& theZones ); + HYDRODATA_EXPORT virtual void SetRegions( const HYDROData_SequenceOfObjects& theRegions ); /** - * Returns splitted zone of calculation case by index. + * Returns region of calculation case by index. */ - HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) GetSplittedZone( const int theIndex ) const; + HYDRODATA_EXPORT virtual Handle(HYDROData_Region) GetRegion( const int theIndex ) const; /** - * Returns all splitted zone of calculation case. + * Returns all regions of calculation case. */ - HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetSplittedZones() const; + HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetRegions() const; /** - * Removes all splitted refrence zone of calculation case. + * Removes all regions of calculation case. */ - HYDRODATA_EXPORT virtual void RemoveSplittedZones(); + HYDRODATA_EXPORT virtual void RemoveRegions(); protected: diff --git a/src/HYDROData/HYDROData_Domain.cxx b/src/HYDROData/HYDROData_Domain.cxx new file mode 100644 index 00000000..8491c19d --- /dev/null +++ b/src/HYDROData/HYDROData_Domain.cxx @@ -0,0 +1,128 @@ + +#include "HYDROData_Domain.h" + +#include "HYDROData_Bathymetry.h" +#include "HYDROData_Document.h" +#include "HYDROData_Iterator.h" + +#include + +#include +#include + +IMPLEMENT_STANDARD_HANDLE(HYDROData_Domain, HYDROData_Object) +IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Domain, HYDROData_Object) + +HYDROData_Domain::HYDROData_Domain() +{ +} + +HYDROData_Domain::~HYDROData_Domain() +{ +} + +QStringList HYDROData_Domain::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const +{ + QStringList aResList; + + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this ); + if ( aDocument.IsNull() ) + return aResList; + + QString aDocName = aDocument->GetDocPyName(); + QString aZoneName = GetName(); + + aResList << QString( "%1 = %2.CreateObject( %3 );" ) + .arg( aZoneName ).arg( aDocName ).arg( getPythonKindId() ); + aResList << QString( "%1.SetName( \"%2\" );" ) + .arg( aZoneName ).arg( aZoneName ); + aResList << QString( "" ); + + QColor aFillingColor = GetFillingColor(); + aResList << QString( "filling_color = QColor( %1, %2, %3, %4 );" ) + .arg( aFillingColor.red() ).arg( aFillingColor.green() ) + .arg( aFillingColor.blue() ).arg( aFillingColor.alpha() ); + aResList << QString( "%1.SetFillingColor( filling_color );" ).arg( aZoneName ); + aResList << QString( "" ); + + QColor aBorderColor = GetBorderColor(); + aResList << QString( "border_color = QColor( %1, %2, %3, %4 );" ) + .arg( aBorderColor.red() ).arg( aBorderColor.green() ) + .arg( aBorderColor.blue() ).arg( aBorderColor.alpha() ); + aResList << QString( "%1.SetBorderColor( border_color );" ).arg( aZoneName ); + aResList << QString( "" ); + + HYDROData_SequenceOfObjects aZoneBaths = GetBathymetries(); + HYDROData_SequenceOfObjects::Iterator aBathsIter( aZoneBaths ); + for ( ; aBathsIter.More(); aBathsIter.Next() ) + { + Handle(HYDROData_Bathymetry) aRefBath = + Handle(HYDROData_Bathymetry)::DownCast( aBathsIter.Value() ); + if ( !aRefBath.IsNull() ) + setPythonReferenceObject( theTreatedObjects, aResList, aRefBath, "AddBathymetry" ); + } + + return aResList; +} + +QColor HYDROData_Domain::DefaultFillingColor() +{ + return QColor( Qt::green ); +} + +void HYDROData_Domain::SetFillingColor( const QColor& theColor ) +{ + return SetColor( theColor, DataTag_FillingColor ); +} + +QColor HYDROData_Domain::GetFillingColor() const +{ + return GetColor( DefaultFillingColor(), DataTag_FillingColor ); +} + +QColor HYDROData_Domain::DefaultBorderColor() +{ + return QColor( Qt::transparent ); +} + +void HYDROData_Domain::SetBorderColor( const QColor& theColor ) +{ + return SetColor( theColor, DataTag_BorderColor ); +} + +QColor HYDROData_Domain::GetBorderColor() const +{ + return GetColor( DefaultBorderColor(), DataTag_BorderColor ); +} + +int HYDROData_Domain::NbBathymetries() const +{ + return NbReferenceObjects( DataTag_Bathymetry ); +} + +void HYDROData_Domain::AddBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry ) +{ + AddReferenceObject( theBathymetry, DataTag_Bathymetry ); +} + +void HYDROData_Domain::SetBathymetry( const int theIndex, + const Handle(HYDROData_Bathymetry)& theBathymetry ) +{ + SetReferenceObject( theBathymetry, DataTag_Bathymetry, theIndex ); +} + +Handle(HYDROData_Bathymetry) HYDROData_Domain::GetBathymetry( const int theIndex ) const +{ + return Handle(HYDROData_Bathymetry)::DownCast( + GetReferenceObject( DataTag_Bathymetry, theIndex ) ); +} + +HYDROData_SequenceOfObjects HYDROData_Domain::GetBathymetries() const +{ + return GetReferenceObjects( DataTag_Bathymetry ); +} + +void HYDROData_Domain::RemoveBathymetries() +{ + ClearReferenceObjects( DataTag_Bathymetry ); +} diff --git a/src/HYDROData/HYDROData_Domain.h b/src/HYDROData/HYDROData_Domain.h new file mode 100644 index 00000000..00c24906 --- /dev/null +++ b/src/HYDROData/HYDROData_Domain.h @@ -0,0 +1,137 @@ + +#ifndef HYDROData_Domain_HeaderFile +#define HYDROData_Domain_HeaderFile + +#include + +#include +#include + +class Handle(HYDROData_Bathymetry); + +DEFINE_STANDARD_HANDLE(HYDROData_Domain, HYDROData_Object) + + +/**\class HYDROData_Domain + * \brief Class that stores/retreives information about the 2d surface. + */ +class HYDROData_Domain : public HYDROData_Object +{ + +protected: + /** + * Enumeration of tags corresponding to the persistent object parameters. + */ + enum DataTag + { + DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve + DataTag_Bathymetry, ///< reference bathymetries + DataTag_FillingColor, ///< filling color of zone + DataTag_BorderColor, ///< border color of zone + }; + +public: + DEFINE_STANDARD_RTTI(HYDROData_Domain); + + /** + * Returns the kind of this object. Must be redefined in all objects of known type. + */ + HYDRODATA_EXPORT virtual const ObjectKind GetKind() const = 0; + + /** + * Dump object to Python script representation. + */ + HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const; + + + /** + * Returns default filling color for new zone. + */ + HYDRODATA_EXPORT static QColor DefaultFillingColor(); + + /** + * Sets filling color for zone. + */ + HYDRODATA_EXPORT virtual void SetFillingColor( const QColor& theColor ); + + /** + * Returns filling color of zone. + */ + HYDRODATA_EXPORT virtual QColor GetFillingColor() const; + + + /** + * Returns default border color for new zone. + */ + HYDRODATA_EXPORT static QColor DefaultBorderColor(); + + /** + * Sets border color for zone. + */ + HYDRODATA_EXPORT virtual void SetBorderColor( const QColor& theColor ); + + /** + * Returns border color of zone. + */ + HYDRODATA_EXPORT virtual QColor GetBorderColor() const; + + + /** + * Returns number of bathymetry objects for zone. + */ + HYDRODATA_EXPORT virtual int NbBathymetries() const; + + /** + * Add reference bathymetry object for zone. + */ + HYDRODATA_EXPORT virtual void AddBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry ); + + /** + * Change reference bathymetry object with given index for zone. + */ + HYDRODATA_EXPORT virtual void SetBathymetry( const int theIndex, + const Handle(HYDROData_Bathymetry)& theBathymetry ); + + /** + * Returns reference bathymetry object of zone by it index. + */ + HYDRODATA_EXPORT virtual Handle(HYDROData_Bathymetry) GetBathymetry( const int theIndex ) const; + + /** + * Returns list of all reference bathymetry objects of zone. + */ + HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetBathymetries() const; + + /** + * Clear list of bathymetry objects of zone. + */ + HYDRODATA_EXPORT virtual void RemoveBathymetries(); + + /** + * Returns data of object wrapped to QVariant. + * Reimplemented to wrap and return saved 2d polyline. + */ + //HYDRODATA_EXPORT virtual QVariant GetDataVariant(); + +protected: + + friend class HYDROData_Iterator; + + /** + * Creates new object in the internal data structure. Use higher level objects + * to create objects with real content. + */ + HYDROData_Domain(); + + /** + * Destructs properties of the object and object itself, removes it from the document. + */ + ~HYDROData_Domain(); + + /** + * Returns id for creation of object in python scripting. + */ + virtual QString getPythonKindId() const = 0; +}; + +#endif diff --git a/src/HYDROData/HYDROData_Iterator.cxx b/src/HYDROData/HYDROData_Iterator.cxx index 401b54d4..254c530a 100644 --- a/src/HYDROData/HYDROData_Iterator.cxx +++ b/src/HYDROData/HYDROData_Iterator.cxx @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -76,6 +77,9 @@ Handle_HYDROData_Object HYDROData_Iterator::Object( const TDF_Label theLabel ) case KIND_ZONE: aResult = new HYDROData_Zone(); break; + case KIND_REGION: + aResult = new HYDROData_Region(); + break; } if ( !aResult.IsNull() ) diff --git a/src/HYDROData/HYDROData_Object.h b/src/HYDROData/HYDROData_Object.h index 8ddb4948..e8669db7 100644 --- a/src/HYDROData/HYDROData_Object.h +++ b/src/HYDROData/HYDROData_Object.h @@ -27,7 +27,8 @@ const ObjectKind KIND_PROFILE = 6; const ObjectKind KIND_PROFILES_GROUP = 7; const ObjectKind KIND_GUIDE_LINE = 8; const ObjectKind KIND_ZONE = 9; -const ObjectKind KIND_LAST = KIND_ZONE; +const ObjectKind KIND_REGION = 10; +const ObjectKind KIND_LAST = KIND_REGION; DEFINE_STANDARD_HANDLE(HYDROData_Object, MMgt_TShared) diff --git a/src/HYDROData/HYDROData_Region.cxx b/src/HYDROData/HYDROData_Region.cxx new file mode 100644 index 00000000..2550de1f --- /dev/null +++ b/src/HYDROData/HYDROData_Region.cxx @@ -0,0 +1,27 @@ + +#include "HYDROData_Region.h" + +#include + +#define PYTHON_REGION_ID "KIND_REGION" + + +IMPLEMENT_STANDARD_HANDLE(HYDROData_Region, HYDROData_Domain) +IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Region, HYDROData_Domain) + + +HYDROData_Region::HYDROData_Region() +{ +} + +HYDROData_Region::~HYDROData_Region() +{ +} + +QString HYDROData_Region::getPythonKindId() const +{ + return QString( PYTHON_REGION_ID ); +} + + + diff --git a/src/HYDROData/HYDROData_Region.h b/src/HYDROData/HYDROData_Region.h new file mode 100644 index 00000000..2cc3f0e1 --- /dev/null +++ b/src/HYDROData/HYDROData_Region.h @@ -0,0 +1,55 @@ + +#ifndef HYDROData_Region_HeaderFile +#define HYDROData_Region_HeaderFile + +#include + + +DEFINE_STANDARD_HANDLE(HYDROData_Region, HYDROData_Domain) + + +/**\class HYDROData_Domain + * \brief Class that stores/retreives information about the 2d surface. + */ +class HYDROData_Region : public HYDROData_Domain +{ + +protected: + /** + * Enumeration of tags corresponding to the persistent object parameters. + */ + enum DataTag + { + DataTag_First = HYDROData_Domain::DataTag_First + 100, ///< first tag, to reserve + }; + +public: + DEFINE_STANDARD_RTTI(HYDROData_Region); + + /** + * Returns the kind of this object. Must be redefined in all objects of known type. + */ + HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_REGION; } + +protected: + + friend class HYDROData_Iterator; + + /** + * Creates new object in the internal data structure. Use higher level objects + * to create objects with real content. + */ + HYDROData_Region(); + + /** + * Destructs properties of the object and object itself, removes it from the document. + */ + ~HYDROData_Region(); + + /** + * Returns id for creation of object in python scripting. + */ + virtual QString getPythonKindId() const; +}; + +#endif diff --git a/src/HYDROData/HYDROData_Zone.cxx b/src/HYDROData/HYDROData_Zone.cxx index 91765f5f..15246161 100644 --- a/src/HYDROData/HYDROData_Zone.cxx +++ b/src/HYDROData/HYDROData_Zone.cxx @@ -13,8 +13,8 @@ #define PYTHON_ZONE_ID "KIND_ZONE" -IMPLEMENT_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Object) -IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Zone, HYDROData_Object) +IMPLEMENT_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Domain) +IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Zone, HYDROData_Domain) HYDROData_Zone::HYDROData_Zone() { @@ -26,82 +26,18 @@ HYDROData_Zone::~HYDROData_Zone() QStringList HYDROData_Zone::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { - QStringList aResList; - - Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this ); - if ( aDocument.IsNull() ) + QStringList aResList = HYDROData_Domain::DumpToPython( theTreatedObjects ); + if ( aResList.isEmpty() ) return aResList; - QString aDocName = aDocument->GetDocPyName(); - QString aZoneName = GetName(); - - aResList << QString( "%1 = %2.CreateObject( %3 );" ) - .arg( aZoneName ).arg( aDocName ).arg( PYTHON_ZONE_ID ); - aResList << QString( "%1.SetName( \"%2\" );" ) - .arg( aZoneName ).arg( aZoneName ); - aResList << QString( "" ); - - QColor aFillingColor = GetFillingColor(); - aResList << QString( "filling_color = QColor( %1, %2, %3, %4 );" ) - .arg( aFillingColor.red() ).arg( aFillingColor.green() ) - .arg( aFillingColor.blue() ).arg( aFillingColor.alpha() ); - aResList << QString( "%1.SetFillingColor( filling_color );" ).arg( aZoneName ); - aResList << QString( "" ); - - QColor aBorderColor = GetBorderColor(); - aResList << QString( "border_color = QColor( %1, %2, %3, %4 );" ) - .arg( aBorderColor.red() ).arg( aBorderColor.green() ) - .arg( aBorderColor.blue() ).arg( aBorderColor.alpha() ); - aResList << QString( "%1.SetBorderColor( border_color );" ).arg( aZoneName ); aResList << QString( "" ); Handle(HYDROData_Polyline) aRefPolyline = GetPolyline(); setPythonReferenceObject( theTreatedObjects, aResList, aRefPolyline, "SetPolyline" ); - aResList << QString( "" ); - - HYDROData_SequenceOfObjects aZoneBaths = GetBathymetries(); - HYDROData_SequenceOfObjects::Iterator aBathsIter( aZoneBaths ); - for ( ; aBathsIter.More(); aBathsIter.Next() ) - { - Handle(HYDROData_Bathymetry) aRefBath = - Handle(HYDROData_Bathymetry)::DownCast( aBathsIter.Value() ); - if ( !aRefBath.IsNull() ) - setPythonReferenceObject( theTreatedObjects, aResList, aRefBath, "AddBathymetry" ); - } return aResList; } -QColor HYDROData_Zone::DefaultFillingColor() -{ - return QColor( Qt::green ); -} - -void HYDROData_Zone::SetFillingColor( const QColor& theColor ) -{ - return SetColor( theColor, DataTag_FillingColor ); -} - -QColor HYDROData_Zone::GetFillingColor() const -{ - return GetColor( DefaultFillingColor(), DataTag_FillingColor ); -} - -QColor HYDROData_Zone::DefaultBorderColor() -{ - return QColor( Qt::transparent ); -} - -void HYDROData_Zone::SetBorderColor( const QColor& theColor ) -{ - return SetColor( theColor, DataTag_BorderColor ); -} - -QColor HYDROData_Zone::GetBorderColor() const -{ - return GetColor( DefaultBorderColor(), DataTag_BorderColor ); -} - void HYDROData_Zone::SetPolyline( const Handle(HYDROData_Polyline)& thePolyline ) { SetReferenceObject( thePolyline, DataTag_Polyline ); @@ -118,38 +54,6 @@ void HYDROData_Zone::RemovePolyline() ClearReferenceObjects( DataTag_Polyline ); } -int HYDROData_Zone::NbBathymetries() const -{ - return NbReferenceObjects( DataTag_Bathymetry ); -} - -void HYDROData_Zone::AddBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry ) -{ - AddReferenceObject( theBathymetry, DataTag_Bathymetry ); -} - -void HYDROData_Zone::SetBathymetry( const int theIndex, - const Handle(HYDROData_Bathymetry)& theBathymetry ) -{ - SetReferenceObject( theBathymetry, DataTag_Bathymetry, theIndex ); -} - -Handle(HYDROData_Bathymetry) HYDROData_Zone::GetBathymetry( const int theIndex ) const -{ - return Handle(HYDROData_Bathymetry)::DownCast( - GetReferenceObject( DataTag_Bathymetry, theIndex ) ); -} - -HYDROData_SequenceOfObjects HYDROData_Zone::GetBathymetries() const -{ - return GetReferenceObjects( DataTag_Bathymetry ); -} - -void HYDROData_Zone::RemoveBathymetries() -{ - ClearReferenceObjects( DataTag_Bathymetry ); -} - QPainterPath HYDROData_Zone::GetPainterPath() const { QPainterPath aPath; @@ -163,3 +67,10 @@ QPainterPath HYDROData_Zone::GetPainterPath() const return aPath; } +QString HYDROData_Zone::getPythonKindId() const +{ + return QString( PYTHON_ZONE_ID ); +} + + + diff --git a/src/HYDROData/HYDROData_Zone.h b/src/HYDROData/HYDROData_Zone.h index 5b277a13..4bbe43b5 100644 --- a/src/HYDROData/HYDROData_Zone.h +++ b/src/HYDROData/HYDROData_Zone.h @@ -2,22 +2,18 @@ #ifndef HYDROData_Zone_HeaderFile #define HYDROData_Zone_HeaderFile -#include +#include -#include #include -#include - -class Handle(HYDROData_Bathymetry); class Handle(HYDROData_Polyline); -DEFINE_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Object) +DEFINE_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Domain) /**\class HYDROData_Zone * \brief Class that stores/retreives information about the 2d face. */ -class HYDROData_Zone : public HYDROData_Object +class HYDROData_Zone : public HYDROData_Domain { protected: @@ -26,11 +22,8 @@ protected: */ enum DataTag { - DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve - DataTag_Bathymetry, ///< reference bathymetries + DataTag_First = HYDROData_Domain::DataTag_First + 100, ///< first tag, to reserve DataTag_Polyline, ///< reference polyline - DataTag_FillingColor, ///< filling color of zone - DataTag_BorderColor, ///< border color of zone }; public: @@ -39,7 +32,7 @@ public: /** * Returns the kind of this object. Must be redefined in all objects of known type. */ - HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_ZONE;} + HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_ZONE; } /** * Dump object to Python script representation. @@ -47,38 +40,6 @@ public: HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const; - /** - * Returns default filling color for new zone. - */ - HYDRODATA_EXPORT static QColor DefaultFillingColor(); - - /** - * Sets filling color for zone. - */ - HYDRODATA_EXPORT virtual void SetFillingColor( const QColor& theColor ); - - /** - * Returns filling color of zone. - */ - HYDRODATA_EXPORT virtual QColor GetFillingColor() const; - - - /** - * Returns default border color for new zone. - */ - HYDRODATA_EXPORT static QColor DefaultBorderColor(); - - /** - * Sets border color for zone. - */ - HYDRODATA_EXPORT virtual void SetBorderColor( const QColor& theColor ); - - /** - * Returns border color of zone. - */ - HYDRODATA_EXPORT virtual QColor GetBorderColor() const; - - /** * Sets reference polyline object for zone. */ @@ -95,37 +56,6 @@ public: HYDRODATA_EXPORT virtual void RemovePolyline(); - /** - * Returns number of bathymetry objects for zone. - */ - HYDRODATA_EXPORT virtual int NbBathymetries() const; - - /** - * Add reference bathymetry object for zone. - */ - HYDRODATA_EXPORT virtual void AddBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry ); - - /** - * Change reference bathymetry object with given index for zone. - */ - HYDRODATA_EXPORT virtual void SetBathymetry( const int theIndex, - const Handle(HYDROData_Bathymetry)& theBathymetry ); - - /** - * Returns reference bathymetry object of zone by it index. - */ - HYDRODATA_EXPORT virtual Handle(HYDROData_Bathymetry) GetBathymetry( const int theIndex ) const; - - /** - * Returns list of all reference bathymetry objects of zone. - */ - HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetBathymetries() const; - - /** - * Clear list of bathymetry objects of zone. - */ - HYDRODATA_EXPORT virtual void RemoveBathymetries(); - /** * Returns data of object wrapped to QVariant. * Reimplemented to wrap and return saved 2d polyline. @@ -152,6 +82,11 @@ protected: * Destructs properties of the object and object itself, removes it from the document. */ ~HYDROData_Zone(); + + /** + * Returns id for creation of object in python scripting. + */ + virtual QString getPythonKindId() const; }; #endif -- 2.39.2