X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_Zone.cxx;h=36b13d65629b20eb2edd5293622947deb8edf647;hb=0d9decc8762a829f1bdc69048fab08122e441ec0;hp=fa2c0e16171b80e5c43c83c9cd4c0164c5e629ec;hpb=38afdfd781e77ef1d5135bed210c8ebd4b60f34f;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_Zone.cxx b/src/HYDROData/HYDROData_Zone.cxx index fa2c0e16..36b13d65 100644 --- a/src/HYDROData/HYDROData_Zone.cxx +++ b/src/HYDROData/HYDROData_Zone.cxx @@ -1,22 +1,24 @@ #include "HYDROData_Zone.h" -#include "HYDROData_Bathymetry.h" #include "HYDROData_Document.h" -#include "HYDROData_Polyline.h" -#include "HYDROData_Iterator.h" +#include "HYDROData_Object.h" -#include +#include +#include + +#include -#include #include -#define PYTHON_POLYLINE_ID "KIND_ZONE" +#define PYTHON_ZONE_ID "KIND_ZONE" + +IMPLEMENT_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Entity) +IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Zone, HYDROData_Entity) -IMPLEMENT_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Object) -IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Zone, HYDROData_Object) HYDROData_Zone::HYDROData_Zone() +: HYDROData_Entity() { } @@ -32,97 +34,82 @@ QStringList HYDROData_Zone::DumpToPython( MapOfTreatedObjects& theTreatedObjects if ( aDocument.IsNull() ) return aResList; - return aResList; -} - -QColor HYDROData_Zone::DefaultFillingColor() -{ - return QColor( Qt::green ); -} - -void HYDROData_Zone::SetFillingColor( const QColor& theColor ) -{ - return SetColor( theColor, DataTag_FillingColor ); -} + QString aDocName = aDocument->GetDocPyName(); + QString aZoneName = GetName(); -QColor HYDROData_Zone::GetFillingColor() const -{ - return GetColor( DefaultFillingColor(), DataTag_FillingColor ); -} + 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 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() ) + setPythonReferenceObject( theTreatedObjects, aResList, aRefGeomObj, "AddGeometryObject" ); + } -void HYDROData_Zone::SetBorderColor( const QColor& theColor ) -{ - return SetColor( theColor, DataTag_BorderColor ); -} + // How can we get the shape? Mb Update() method to intersect the shapes of reference objects? + // TODO: TopoDS_Shape aRefShape = GetShape(); -QColor HYDROData_Zone::GetBorderColor() const -{ - return GetColor( DefaultBorderColor(), DataTag_BorderColor ); + return aResList; } -void HYDROData_Zone::SetPolyline( const Handle(HYDROData_Polyline)& thePolyline ) +void HYDROData_Zone::SetShape( const TopoDS_Shape& theShape ) { - SetReferenceObject( thePolyline, DataTag_Polyline ); + TNaming_Builder aBuilder( myLab.FindChild( DataTag_Shape ) ); + aBuilder.Generated( theShape ); } -Handle(HYDROData_Polyline) HYDROData_Zone::GetPolyline() const +TopoDS_Shape HYDROData_Zone::GetShape() const { - return Handle(HYDROData_Polyline)::DownCast( - GetReferenceObject( DataTag_Polyline ) ); + Handle(TNaming_NamedShape) aNamedShape; + if( myLab.FindChild( DataTag_Shape ).FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) ) + return aNamedShape->Get(); + return TopoDS_Shape(); } -void HYDROData_Zone::RemovePolyline() +int HYDROData_Zone::NbGeometryObjects() const { - ClearReferenceObjects( DataTag_Polyline ); + return NbReferenceObjects( DataTag_GeometryObject ); } -int HYDROData_Zone::NbBathymetries() const +void HYDROData_Zone::AddGeometryObject( const Handle(HYDROData_Object)& theObject ) { - return NbReferenceObjects( DataTag_Bathymetry ); + AddReferenceObject( theObject, DataTag_GeometryObject ); } -void HYDROData_Zone::AddBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry ) +void HYDROData_Zone::SetGeometryObject( const int theIndex, + const Handle(HYDROData_Object)& theObject ) { - AddReferenceObject( theBathymetry, DataTag_Bathymetry ); + SetReferenceObject( theObject, DataTag_GeometryObject, theIndex ); } -void HYDROData_Zone::SetBathymetry( const int theIndex, - const Handle(HYDROData_Bathymetry)& theBathymetry ) +void HYDROData_Zone::SetGeometryObjects( const HYDROData_SequenceOfObjects& theObjects ) { - SetReferenceObject( theBathymetry, DataTag_Bathymetry, theIndex ); + SetReferenceObjects( theObjects, DataTag_GeometryObject ); } -Handle(HYDROData_Bathymetry) HYDROData_Zone::GetBathymetry( const int theIndex ) const +Handle(HYDROData_Object) HYDROData_Zone::GetGeometryObject( const int theIndex ) const { - return Handle(HYDROData_Bathymetry)::DownCast( - GetReferenceObject( DataTag_Bathymetry, theIndex ) ); + return Handle(HYDROData_Object)::DownCast( + GetReferenceObject( DataTag_GeometryObject, theIndex ) ); } -HYDROData_SequenceOfObjects HYDROData_Zone::GetBathymetries() const +HYDROData_SequenceOfObjects HYDROData_Zone::GetGeometryObjects() const { - return GetReferenceObjects( DataTag_Bathymetry ); + return GetReferenceObjects( DataTag_GeometryObject ); } -void HYDROData_Zone::RemoveBathymetries() +void HYDROData_Zone::RemoveGeometryObjects() { - ClearReferenceObjects( DataTag_Bathymetry ); + ClearReferenceObjects( DataTag_GeometryObject ); } -QPainterPath HYDROData_Zone::GetPainterPath() const -{ - QPainterPath aPath; - Handle(HYDROData_Polyline) aPolyline = GetPolyline(); - if ( !aPolyline.IsNull() ) - { - aPath = aPolyline->painterPath(); - } - return aPath; -}