From: rkv Date: Thu, 16 Jan 2014 10:41:44 +0000 (+0000) Subject: The method GetObjPyName is introduced in the Entity. X-Git-Tag: BR_hydro_v_1_0~85 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=63cfcd8fde33b237c06377b628b4e9e8027a425f;p=modules%2Fhydro.git The method GetObjPyName is introduced in the Entity. --- diff --git a/src/HYDROData/HYDROData_AltitudeObject.cxx b/src/HYDROData/HYDROData_AltitudeObject.cxx index 0898db1d..ba0a8701 100644 --- a/src/HYDROData/HYDROData_AltitudeObject.cxx +++ b/src/HYDROData/HYDROData_AltitudeObject.cxx @@ -19,7 +19,7 @@ HYDROData_AltitudeObject::~HYDROData_AltitudeObject() QStringList HYDROData_AltitudeObject::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); - QString aName = GetName(); + QString aName = GetObjPyName(); // TODO diff --git a/src/HYDROData/HYDROData_Bathymetry.cxx b/src/HYDROData/HYDROData_Bathymetry.cxx index d9132207..9bdfd1cf 100644 --- a/src/HYDROData/HYDROData_Bathymetry.cxx +++ b/src/HYDROData/HYDROData_Bathymetry.cxx @@ -41,7 +41,7 @@ HYDROData_Bathymetry::~HYDROData_Bathymetry() QStringList HYDROData_Bathymetry::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); - QString aBathymetryName = GetName(); + QString aBathymetryName = GetObjPyName(); aResList << QString( "%1.SetAltitudesInverted( %2 );" ) .arg( aBathymetryName ).arg( IsAltitudesInverted() ); diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index 6bc7bbfc..7beedc8d 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -107,7 +107,7 @@ void HYDROData_CalculationCase::SetName( const QString& theName ) QStringList HYDROData_CalculationCase::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); - QString aCalculName = GetName(); + QString aCalculName = GetObjPyName(); HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects(); HYDROData_SequenceOfObjects::Iterator anIter( aGeomObjects ); diff --git a/src/HYDROData/HYDROData_Channel.cxx b/src/HYDROData/HYDROData_Channel.cxx index d0d64376..2159ce7f 100644 --- a/src/HYDROData/HYDROData_Channel.cxx +++ b/src/HYDROData/HYDROData_Channel.cxx @@ -46,9 +46,13 @@ HYDROData_Channel::~HYDROData_Channel() QStringList HYDROData_Channel::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); - QString aName = GetName(); + QString aName = GetObjPyName(); - // TODO + Handle(HYDROData_Polyline3D) aRefGideLine = GetGuideLine(); + setPythonReferenceObject( theTreatedObjects, aResList, aRefGideLine, "SetGuideLine" ); + + Handle(HYDROData_Profile) aRefProfile = GetProfile(); + setPythonReferenceObject( theTreatedObjects, aResList, aRefProfile, "SetProfile" ); aResList << QString( "" ); aResList << QString( "%1.Update();" ).arg( aName ); diff --git a/src/HYDROData/HYDROData_Confluence.cxx b/src/HYDROData/HYDROData_Confluence.cxx index 378ccc6d..64883f88 100644 --- a/src/HYDROData/HYDROData_Confluence.cxx +++ b/src/HYDROData/HYDROData_Confluence.cxx @@ -23,7 +23,7 @@ HYDROData_Confluence::~HYDROData_Confluence() QStringList HYDROData_Confluence::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); - QString aName = GetName(); + QString aName = GetObjPyName(); // TODO diff --git a/src/HYDROData/HYDROData_Digue.cxx b/src/HYDROData/HYDROData_Digue.cxx index 1312e1d7..80149acc 100644 --- a/src/HYDROData/HYDROData_Digue.cxx +++ b/src/HYDROData/HYDROData_Digue.cxx @@ -21,20 +21,6 @@ HYDROData_Digue::~HYDROData_Digue() { } -QStringList HYDROData_Digue::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const -{ - QStringList aResList = dumpObjectCreation( theTreatedObjects ); - QString aName = GetName(); - - // TODO - - aResList << QString( "" ); - aResList << QString( "%1.Update();" ).arg( aName ); - aResList << QString( "" ); - - return aResList; -} - QColor HYDROData_Digue::DefaultFillingColor() { return QColor( Qt::red ); diff --git a/src/HYDROData/HYDROData_Digue.h b/src/HYDROData/HYDROData_Digue.h index fcd8fb77..18d114c9 100644 --- a/src/HYDROData/HYDROData_Digue.h +++ b/src/HYDROData/HYDROData_Digue.h @@ -29,11 +29,6 @@ public: */ HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_DIGUE;} - /** - * Dump object to Python script representation. - */ - HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const; - /** * Returns default filling color for new digue. */ diff --git a/src/HYDROData/HYDROData_Entity.cxx b/src/HYDROData/HYDROData_Entity.cxx index 2e194aa9..797973ea 100644 --- a/src/HYDROData/HYDROData_Entity.cxx +++ b/src/HYDROData/HYDROData_Entity.cxx @@ -43,6 +43,11 @@ QString HYDROData_Entity::GetName() const return QString(); } +QString HYDROData_Entity::GetObjPyName() const +{ + return GetName().replace(" ", "_"); +} + void HYDROData_Entity::SetName(const QString& theName) { TDataStd_Name::Set(myLab, TCollection_ExtendedString(theName.toLatin1().constData())); @@ -63,12 +68,12 @@ QStringList HYDROData_Entity::dumpObjectCreation( MapOfTreatedObjects& theTreate return aResList; QString aDocName = aDocument->GetDocPyName(); - QString aName = GetName(); + QString aName = GetObjPyName(); aResList << QString( "%1 = %2.CreateObject( %3 );" ) .arg( aName ).arg( aDocName ).arg( getPyTypeID() ); aResList << QString( "%1.SetName( \"%2\" );" ) - .arg( aName ).arg( aName ); + .arg( aName ).arg( GetName() ); aResList << QString( "" ); return aResList; @@ -497,7 +502,7 @@ void HYDROData_Entity::setPythonReferenceObject( MapOfTreatedObjects& if ( theRefObject.IsNull() ) return; - QString aRefObjName = theRefObject->GetName(); + QString aRefObjName = theRefObject->GetObjPyName(); if ( aRefObjName.isEmpty() ) return; @@ -523,7 +528,7 @@ void HYDROData_Entity::setPythonReferenceObject( MapOfTreatedObjects& if ( anIsToSetObject ) { theScript << QString( "%1.%2( %3 );" ) - .arg( GetName() ).arg( theMethod ).arg( aRefObjName ); + .arg( GetObjPyName() ).arg( theMethod ).arg( aRefObjName ); } } diff --git a/src/HYDROData/HYDROData_Entity.h b/src/HYDROData/HYDROData_Entity.h index a0af6b11..b1b36333 100644 --- a/src/HYDROData/HYDROData_Entity.h +++ b/src/HYDROData/HYDROData_Entity.h @@ -94,6 +94,11 @@ public: */ HYDRODATA_EXPORT virtual void SetName( const QString& theName ); + /** + * Returns the name of this object valid for Python script. + */ + HYDRODATA_EXPORT virtual QString GetObjPyName() const; + /** * Dump object to Python script representation. * Base implementation returns empty list, diff --git a/src/HYDROData/HYDROData_Image.cxx b/src/HYDROData/HYDROData_Image.cxx index da75db76..ef915a00 100644 --- a/src/HYDROData/HYDROData_Image.cxx +++ b/src/HYDROData/HYDROData_Image.cxx @@ -40,7 +40,7 @@ HYDROData_Image::~HYDROData_Image() QStringList HYDROData_Image::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); - QString anImageName = GetName(); + QString anImageName = GetObjPyName(); QString aFilePath = GetFilePath(); if ( !aFilePath.isEmpty() ) diff --git a/src/HYDROData/HYDROData_ImmersibleZone.cxx b/src/HYDROData/HYDROData_ImmersibleZone.cxx index 3cca1c65..3232ae96 100644 --- a/src/HYDROData/HYDROData_ImmersibleZone.cxx +++ b/src/HYDROData/HYDROData_ImmersibleZone.cxx @@ -43,7 +43,7 @@ HYDROData_ImmersibleZone::~HYDROData_ImmersibleZone() QStringList HYDROData_ImmersibleZone::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); - QString aZoneName = GetName(); + QString aZoneName = GetObjPyName(); QColor aFillingColor = GetFillingColor(); aResList << QString( "filling_color = QColor( %1, %2, %3, %4 );" ) diff --git a/src/HYDROData/HYDROData_Obstacle.cxx b/src/HYDROData/HYDROData_Obstacle.cxx index 295ad00c..2b8c7cb6 100644 --- a/src/HYDROData/HYDROData_Obstacle.cxx +++ b/src/HYDROData/HYDROData_Obstacle.cxx @@ -53,7 +53,7 @@ HYDROData_Obstacle::~HYDROData_Obstacle() QStringList HYDROData_Obstacle::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); - QString aName = GetName(); + QString aName = GetObjPyName(); // TODO diff --git a/src/HYDROData/HYDROData_ObstacleAltitude.cxx b/src/HYDROData/HYDROData_ObstacleAltitude.cxx index 3b535e31..d6310ff0 100644 --- a/src/HYDROData/HYDROData_ObstacleAltitude.cxx +++ b/src/HYDROData/HYDROData_ObstacleAltitude.cxx @@ -19,7 +19,7 @@ HYDROData_ObstacleAltitude::~HYDROData_ObstacleAltitude() QStringList HYDROData_ObstacleAltitude::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); - QString aName = GetName(); + QString aName = GetObjPyName(); // TODO diff --git a/src/HYDROData/HYDROData_Polyline3D.cxx b/src/HYDROData/HYDROData_Polyline3D.cxx index 206dc384..6239b431 100644 --- a/src/HYDROData/HYDROData_Polyline3D.cxx +++ b/src/HYDROData/HYDROData_Polyline3D.cxx @@ -34,9 +34,16 @@ HYDROData_Polyline3D::~HYDROData_Polyline3D() QStringList HYDROData_Polyline3D::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); - QString aName = GetName(); + QString aName = GetObjPyName(); - // TODO + Handle(HYDROData_PolylineXY) aRefPolyline = GetPolylineXY(); + setPythonReferenceObject( theTreatedObjects, aResList, aRefPolyline, "SetPolylineXY" ); + + Handle(HYDROData_ProfileUZ) aRefProfile = GetProfileUZ(); + setPythonReferenceObject( theTreatedObjects, aResList, aRefProfile, "SetProfileUZ" ); + + Handle(HYDROData_IAltitudeObject) aRefBathymetry = GetAltitudeObject(); + setPythonReferenceObject( theTreatedObjects, aResList, aRefBathymetry, "SetAltitudeObject" ); aResList << QString( "" ); aResList << QString( "%1.Update();" ).arg( aName ); diff --git a/src/HYDROData/HYDROData_PolylineXY.cxx b/src/HYDROData/HYDROData_PolylineXY.cxx index fd53ca01..d418144a 100755 --- a/src/HYDROData/HYDROData_PolylineXY.cxx +++ b/src/HYDROData/HYDROData_PolylineXY.cxx @@ -107,7 +107,7 @@ HYDROData_PolylineXY::~HYDROData_PolylineXY() QStringList HYDROData_PolylineXY::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); - QString aPolylineName = GetName(); + QString aPolylineName = GetObjPyName(); // Set polilyne data NCollection_Sequence aSectNames; diff --git a/src/HYDROData/HYDROData_Profile.cxx b/src/HYDROData/HYDROData_Profile.cxx index 8efcf23b..6d0d6857 100755 --- a/src/HYDROData/HYDROData_Profile.cxx +++ b/src/HYDROData/HYDROData_Profile.cxx @@ -43,7 +43,7 @@ HYDROData_Profile::~HYDROData_Profile() QStringList HYDROData_Profile::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); - QString aName = GetName(); + QString aName = GetObjPyName(); QColor aFillingColor = GetFillingColor(); aResList << QString( "filling_color = QColor( %1, %2, %3, %4 );" ) diff --git a/src/HYDROData/HYDROData_ProfileUZ.cxx b/src/HYDROData/HYDROData_ProfileUZ.cxx index 49225298..8247cba5 100755 --- a/src/HYDROData/HYDROData_ProfileUZ.cxx +++ b/src/HYDROData/HYDROData_ProfileUZ.cxx @@ -31,7 +31,7 @@ HYDROData_ProfileUZ::~HYDROData_ProfileUZ() QStringList HYDROData_ProfileUZ::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); - QString aName = GetName(); + QString aName = GetObjPyName(); // Set polilyne data const TCollection_AsciiString& aSectName = GetSectionName( 0 ); diff --git a/src/HYDROData/HYDROData_Region.cxx b/src/HYDROData/HYDROData_Region.cxx index 6548310b..03c91d34 100644 --- a/src/HYDROData/HYDROData_Region.cxx +++ b/src/HYDROData/HYDROData_Region.cxx @@ -44,7 +44,7 @@ HYDROData_Region::~HYDROData_Region() QStringList HYDROData_Region::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); - QString aRegionName = GetName(); + QString aRegionName = GetObjPyName(); HYDROData_SequenceOfObjects aZones = GetZones(); HYDROData_SequenceOfObjects::Iterator anIter( aZones ); diff --git a/src/HYDROData/HYDROData_River.cxx b/src/HYDROData/HYDROData_River.cxx index 88d1bbce..bd22befb 100644 --- a/src/HYDROData/HYDROData_River.cxx +++ b/src/HYDROData/HYDROData_River.cxx @@ -23,7 +23,7 @@ HYDROData_River::~HYDROData_River() QStringList HYDROData_River::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); - QString aName = GetName(); + QString aName = GetObjPyName(); // TODO diff --git a/src/HYDROData/HYDROData_Stream.cxx b/src/HYDROData/HYDROData_Stream.cxx index 312657ae..fbe9212b 100644 --- a/src/HYDROData/HYDROData_Stream.cxx +++ b/src/HYDROData/HYDROData_Stream.cxx @@ -86,7 +86,7 @@ HYDROData_Stream::~HYDROData_Stream() QStringList HYDROData_Stream::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); - QString aName = GetName(); + QString aName = GetObjPyName(); // TODO diff --git a/src/HYDROData/HYDROData_StreamAltitude.cxx b/src/HYDROData/HYDROData_StreamAltitude.cxx index ce2d971a..0b70548d 100644 --- a/src/HYDROData/HYDROData_StreamAltitude.cxx +++ b/src/HYDROData/HYDROData_StreamAltitude.cxx @@ -47,7 +47,7 @@ HYDROData_StreamAltitude::~HYDROData_StreamAltitude() QStringList HYDROData_StreamAltitude::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); - QString aName = GetName(); + QString aName = GetObjPyName(); // TODO diff --git a/src/HYDROData/HYDROData_Zone.cxx b/src/HYDROData/HYDROData_Zone.cxx index 4d96a649..d9789f00 100644 --- a/src/HYDROData/HYDROData_Zone.cxx +++ b/src/HYDROData/HYDROData_Zone.cxx @@ -44,7 +44,7 @@ QStringList HYDROData_Zone::DumpToPython( MapOfTreatedObjects& theTreatedObjects // How can we get the shape? Mb Update() method to intersect the shapes of reference objects? // TODO: TopoDS_Shape aRefShape = GetShape(); - QString aName = GetName(); + QString aName = GetObjPyName(); aResList << QString( "" ); aResList << QString( "%1.Update();" ).arg( aName ); aResList << QString( "" );