X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_Zone.cxx;h=fdbf91b082aad2b50bae545cf3cd9c9190f895c8;hb=deed826b2d6c39ba2ed410108cdf54d64cded321;hp=91765f5f79dbe4ad8f98cb05426a17dda04609cc;hpb=3cff85424556651afcab2e7fa5081531d748b7cc;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_Zone.cxx b/src/HYDROData/HYDROData_Zone.cxx index 91765f5f..fdbf91b0 100644 --- a/src/HYDROData/HYDROData_Zone.cxx +++ b/src/HYDROData/HYDROData_Zone.cxx @@ -1,22 +1,28 @@ #include "HYDROData_Zone.h" +#include "HYDROData_ArtificialObject.h" #include "HYDROData_Bathymetry.h" #include "HYDROData_Document.h" -#include "HYDROData_Polyline.h" -#include "HYDROData_Iterator.h" +#include "HYDROData_NaturalObject.h" -#include +#include +#include + +#include -#include #include +#include + #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_Entity) +IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Zone, HYDROData_Entity) + HYDROData_Zone::HYDROData_Zone() +: HYDROData_Entity() { } @@ -28,7 +34,7 @@ QStringList HYDROData_Zone::DumpToPython( MapOfTreatedObjects& theTreatedObjects { QStringList aResList; - Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this ); + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); if ( aDocument.IsNull() ) return aResList; @@ -41,125 +47,131 @@ QStringList HYDROData_Zone::DumpToPython( MapOfTreatedObjects& theTreatedObjects .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() ) + HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects(); + HYDROData_SequenceOfObjects::Iterator aGeomObjsIter( aGeomObjects ); + for ( ; aGeomObjsIter.More(); aGeomObjsIter.Next() ) { - Handle(HYDROData_Bathymetry) aRefBath = - Handle(HYDROData_Bathymetry)::DownCast( aBathsIter.Value() ); - if ( !aRefBath.IsNull() ) - setPythonReferenceObject( theTreatedObjects, aResList, aRefBath, "AddBathymetry" ); + Handle(HYDROData_Object) aRefGeomObj = + Handle(HYDROData_Object)::DownCast( aGeomObjsIter.Value() ); + if ( !aRefGeomObj.IsNull() ) + setPythonReferenceObject( theTreatedObjects, aResList, aRefGeomObj, "AddGeometryObject" ); } + // How can we get the shape? Mb Update() method to intersect the shapes of reference objects? + // TODO: TopoDS_Shape aRefShape = GetShape(); + return aResList; } -QColor HYDROData_Zone::DefaultFillingColor() +void HYDROData_Zone::SetShape( const TopoDS_Shape& theShape ) { - return QColor( Qt::green ); + TNaming_Builder aBuilder( myLab.FindChild( DataTag_Shape ) ); + aBuilder.Generated( theShape ); } -void HYDROData_Zone::SetFillingColor( const QColor& theColor ) +TopoDS_Shape HYDROData_Zone::GetShape() const { - return SetColor( theColor, DataTag_FillingColor ); + Handle(TNaming_NamedShape) aNamedShape; + if( myLab.FindChild( DataTag_Shape ).FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) ) + return aNamedShape->Get(); + return TopoDS_Shape(); } -QColor HYDROData_Zone::GetFillingColor() const +bool HYDROData_Zone::IsMergingNeed() const { - return GetColor( DefaultFillingColor(), DataTag_FillingColor ); -} + Handle(HYDROData_Bathymetry) aRefBathymetry; -QColor HYDROData_Zone::DefaultBorderColor() -{ - return QColor( Qt::transparent ); -} + HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects(); + HYDROData_SequenceOfObjects::Iterator aGeomObjsIter( aGeomObjects ); + for ( ; aGeomObjsIter.More(); aGeomObjsIter.Next() ) + { + Handle(HYDROData_Object) aRefGeomObj = + Handle(HYDROData_Object)::DownCast( aGeomObjsIter.Value() ); + if ( aRefGeomObj.IsNull() ) + continue; + + Handle(HYDROData_Bathymetry) anObjBathymetry = aRefGeomObj->GetBathymetry(); + if ( anObjBathymetry.IsNull() ) + continue; + + if ( aRefBathymetry.IsNull() ) + { + aRefBathymetry = anObjBathymetry; + continue; + } + + if ( !IsEqual( aRefBathymetry, anObjBathymetry ) ) + return true; + } -void HYDROData_Zone::SetBorderColor( const QColor& theColor ) -{ - return SetColor( theColor, DataTag_BorderColor ); + return false; } -QColor HYDROData_Zone::GetBorderColor() const +void HYDROData_Zone::SetMergeType( const MergeBathymetriesType& theType ) { - return GetColor( DefaultBorderColor(), DataTag_BorderColor ); + Handle(TDataStd_Integer) anInt; + if ( myLab.FindChild( DataTag_MergeType ).FindAttribute( TDataStd_Integer::GetID(), anInt ) ) + { + anInt->Set( (int)theType ); + } + else + { + anInt = TDataStd_Integer::Set( myLab.FindChild( DataTag_MergeType ), (int)theType ); + } } -void HYDROData_Zone::SetPolyline( const Handle(HYDROData_Polyline)& thePolyline ) +HYDROData_Zone::MergeBathymetriesType HYDROData_Zone::GetMergeType() const { - SetReferenceObject( thePolyline, DataTag_Polyline ); -} + MergeBathymetriesType aMergeType = Merge_UNKNOWN; + + Handle(TDataStd_Integer) anInt; + if ( myLab.FindChild( DataTag_MergeType ).FindAttribute( TDataStd_Integer::GetID(), anInt ) ) + aMergeType = (MergeBathymetriesType)anInt->Get(); -Handle(HYDROData_Polyline) HYDROData_Zone::GetPolyline() const -{ - return Handle(HYDROData_Polyline)::DownCast( - GetReferenceObject( DataTag_Polyline ) ); + return aMergeType; } -void HYDROData_Zone::RemovePolyline() +void HYDROData_Zone::SetMergeBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry ) { - ClearReferenceObjects( DataTag_Polyline ); + SetReferenceObject( theBathymetry, DataTag_Bathymetry ); } -int HYDROData_Zone::NbBathymetries() const +Handle(HYDROData_Bathymetry) HYDROData_Zone::GetMergeBathymetry() const { - return NbReferenceObjects( DataTag_Bathymetry ); + return Handle(HYDROData_Bathymetry)::DownCast( + GetReferenceObject( DataTag_Bathymetry ) ); } -void HYDROData_Zone::AddBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry ) +void HYDROData_Zone::RemoveMergeBathymetry() { - AddReferenceObject( theBathymetry, DataTag_Bathymetry ); + ClearReferenceObjects( DataTag_Bathymetry ); } -void HYDROData_Zone::SetBathymetry( const int theIndex, - const Handle(HYDROData_Bathymetry)& theBathymetry ) +bool HYDROData_Zone::AddGeometryObject( const Handle(HYDROData_Object)& theObject ) { - SetReferenceObject( theBathymetry, DataTag_Bathymetry, theIndex ); -} + if ( theObject.IsNull() ) + return false; + + if ( !theObject->IsKind( STANDARD_TYPE(HYDROData_ArtificialObject) ) && + !theObject->IsKind( STANDARD_TYPE(HYDROData_NaturalObject) ) ) + return false; // Wrong type of object -Handle(HYDROData_Bathymetry) HYDROData_Zone::GetBathymetry( const int theIndex ) const -{ - return Handle(HYDROData_Bathymetry)::DownCast( - GetReferenceObject( DataTag_Bathymetry, theIndex ) ); -} + if ( HasReference( theObject, DataTag_GeometryObject ) ) + return false; // Object is already in reference list -HYDROData_SequenceOfObjects HYDROData_Zone::GetBathymetries() const -{ - return GetReferenceObjects( DataTag_Bathymetry ); + AddReferenceObject( theObject, DataTag_GeometryObject ); + return true; } -void HYDROData_Zone::RemoveBathymetries() +HYDROData_SequenceOfObjects HYDROData_Zone::GetGeometryObjects() const { - ClearReferenceObjects( DataTag_Bathymetry ); + return GetReferenceObjects( DataTag_GeometryObject ); } -QPainterPath HYDROData_Zone::GetPainterPath() const +void HYDROData_Zone::RemoveGeometryObjects() { - QPainterPath aPath; + ClearReferenceObjects( DataTag_GeometryObject ); +} - Handle(HYDROData_Polyline) aPolyline = GetPolyline(); - if ( !aPolyline.IsNull() ) - { - aPath = aPolyline->painterPath(); - } - return aPath; -}