From: rkv Date: Thu, 16 Jan 2014 07:38:16 +0000 (+0000) Subject: Dump of profile is implemented. X-Git-Tag: BR_hydro_v_1_0~91 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ba70cb7d5a35a6d311acc1b061fb450afe04d0f8;p=modules%2Fhydro.git Dump of profile is implemented. --- diff --git a/src/HYDROData/HYDROData_AltitudeObject.cxx b/src/HYDROData/HYDROData_AltitudeObject.cxx index 941582f9..0898db1d 100644 --- a/src/HYDROData/HYDROData_AltitudeObject.cxx +++ b/src/HYDROData/HYDROData_AltitudeObject.cxx @@ -19,10 +19,14 @@ HYDROData_AltitudeObject::~HYDROData_AltitudeObject() QStringList HYDROData_AltitudeObject::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); - QString anAltitudeName = GetName(); + QString aName = GetName(); // TODO + aResList << QString( "" ); + aResList << QString( "%1.Update();" ).arg( aName ); + aResList << QString( "" ); + return aResList; } diff --git a/src/HYDROData/HYDROData_Bathymetry.cxx b/src/HYDROData/HYDROData_Bathymetry.cxx index 7ac8a237..d9132207 100644 --- a/src/HYDROData/HYDROData_Bathymetry.cxx +++ b/src/HYDROData/HYDROData_Bathymetry.cxx @@ -50,6 +50,10 @@ QStringList HYDROData_Bathymetry::DumpToPython( MapOfTreatedObjects& theTreatedO aResList << QString( "%1.ImportFromFile( \"%2\" );" ) .arg( aBathymetryName ).arg( aFilePath.ToCString() ); + aResList << QString( "" ); + aResList << QString( "%1.Update();" ).arg( aBathymetryName ); + aResList << QString( "" ); + return aResList; } diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index 7ee3bd8c..9813ae94 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -137,6 +137,10 @@ QStringList HYDROData_CalculationCase::DumpToPython( MapOfTreatedObjects& theTre // TODO } + aResList << QString( "" ); + aResList << QString( "%1.Update();" ).arg( aCalculName ); + aResList << QString( "" ); + return aResList; } diff --git a/src/HYDROData/HYDROData_Channel.cxx b/src/HYDROData/HYDROData_Channel.cxx index b2e9d1cc..d0d64376 100644 --- a/src/HYDROData/HYDROData_Channel.cxx +++ b/src/HYDROData/HYDROData_Channel.cxx @@ -46,9 +46,14 @@ HYDROData_Channel::~HYDROData_Channel() QStringList HYDROData_Channel::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); + QString aName = GetName(); // TODO + aResList << QString( "" ); + aResList << QString( "%1.Update();" ).arg( aName ); + aResList << QString( "" ); + return aResList; } diff --git a/src/HYDROData/HYDROData_Confluence.cxx b/src/HYDROData/HYDROData_Confluence.cxx index 5d20481c..378ccc6d 100644 --- a/src/HYDROData/HYDROData_Confluence.cxx +++ b/src/HYDROData/HYDROData_Confluence.cxx @@ -23,9 +23,14 @@ HYDROData_Confluence::~HYDROData_Confluence() QStringList HYDROData_Confluence::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); + QString aName = GetName(); // TODO + aResList << QString( "" ); + aResList << QString( "%1.Update();" ).arg( aName ); + aResList << QString( "" ); + return aResList; } diff --git a/src/HYDROData/HYDROData_Digue.cxx b/src/HYDROData/HYDROData_Digue.cxx index 8fb46694..1312e1d7 100644 --- a/src/HYDROData/HYDROData_Digue.cxx +++ b/src/HYDROData/HYDROData_Digue.cxx @@ -24,9 +24,14 @@ 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; } diff --git a/src/HYDROData/HYDROData_Document.cxx b/src/HYDROData/HYDROData_Document.cxx index a96ac998..4c2fb49f 100644 --- a/src/HYDROData/HYDROData_Document.cxx +++ b/src/HYDROData/HYDROData_Document.cxx @@ -232,7 +232,7 @@ QStringList HYDROData_Document::DumpToPython( MapOfTreatedObjects& theTreatedObj QStringList aResScript; - aResScript << QString( "from HYDROpy import *" ); + aResScript << QString( "from HYDROPy import *" ); aResScript << QString( "from PyQt4.QtCore import *" ); aResScript << QString( "from PyQt4.QtGui import *" ); aResScript << QString( "" ); diff --git a/src/HYDROData/HYDROData_Image.cxx b/src/HYDROData/HYDROData_Image.cxx index 108ba642..da75db76 100644 --- a/src/HYDROData/HYDROData_Image.cxx +++ b/src/HYDROData/HYDROData_Image.cxx @@ -136,6 +136,8 @@ QStringList HYDROData_Image::DumpToPython( MapOfTreatedObjects& theTreatedObject aResList << QString( "%1.Update();" ).arg( anImageName ); } + aResList << QString( "" ); + return aResList; } diff --git a/src/HYDROData/HYDROData_ImmersibleZone.cxx b/src/HYDROData/HYDROData_ImmersibleZone.cxx index 69cfebdd..3cca1c65 100644 --- a/src/HYDROData/HYDROData_ImmersibleZone.cxx +++ b/src/HYDROData/HYDROData_ImmersibleZone.cxx @@ -65,6 +65,10 @@ QStringList HYDROData_ImmersibleZone::DumpToPython( MapOfTreatedObjects& theTrea Handle(HYDROData_PolylineXY) aRefPolyline = GetPolyline(); setPythonReferenceObject( theTreatedObjects, aResList, aRefPolyline, "SetPolyline" ); + aResList << QString( "" ); + aResList << QString( "%1.Update();" ).arg( aZoneName ); + aResList << QString( "" ); + return aResList; } diff --git a/src/HYDROData/HYDROData_Obstacle.cxx b/src/HYDROData/HYDROData_Obstacle.cxx index 5572a892..295ad00c 100644 --- a/src/HYDROData/HYDROData_Obstacle.cxx +++ b/src/HYDROData/HYDROData_Obstacle.cxx @@ -53,9 +53,14 @@ HYDROData_Obstacle::~HYDROData_Obstacle() QStringList HYDROData_Obstacle::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); + QString aName = GetName(); // TODO + aResList << QString( "" ); + aResList << QString( "%1.Update();" ).arg( aName ); + aResList << QString( "" ); + return aResList; } diff --git a/src/HYDROData/HYDROData_ObstacleAltitude.cxx b/src/HYDROData/HYDROData_ObstacleAltitude.cxx index 0b62773b..3b535e31 100644 --- a/src/HYDROData/HYDROData_ObstacleAltitude.cxx +++ b/src/HYDROData/HYDROData_ObstacleAltitude.cxx @@ -19,9 +19,14 @@ HYDROData_ObstacleAltitude::~HYDROData_ObstacleAltitude() QStringList HYDROData_ObstacleAltitude::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); + QString aName = GetName(); // TODO + aResList << QString( "" ); + aResList << QString( "%1.Update();" ).arg( aName ); + aResList << QString( "" ); + return aResList; } diff --git a/src/HYDROData/HYDROData_Polyline3D.cxx b/src/HYDROData/HYDROData_Polyline3D.cxx index 3931be8f..206dc384 100644 --- a/src/HYDROData/HYDROData_Polyline3D.cxx +++ b/src/HYDROData/HYDROData_Polyline3D.cxx @@ -34,9 +34,14 @@ HYDROData_Polyline3D::~HYDROData_Polyline3D() QStringList HYDROData_Polyline3D::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); + QString aName = GetName(); // TODO + aResList << QString( "" ); + aResList << QString( "%1.Update();" ).arg( aName ); + aResList << QString( "" ); + return aResList; } diff --git a/src/HYDROData/HYDROData_PolylineXY.cxx b/src/HYDROData/HYDROData_PolylineXY.cxx index f462bff3..f9137e66 100755 --- a/src/HYDROData/HYDROData_PolylineXY.cxx +++ b/src/HYDROData/HYDROData_PolylineXY.cxx @@ -124,7 +124,7 @@ QStringList HYDROData_PolylineXY::DumpToPython( MapOfTreatedObjects& theTreatedO aResList << QString( "%1.AddSection( \"%2\", %3, %4 );" ).arg( aPolylineName ) .arg( aSectName.ToCString() ).arg( aSectType ).arg( aSectClosure ); - HYDROData_PolylineXY::PointsList aSectPointsList = GetPoints( i ); + HYDROData_IPolyline::PointsList aSectPointsList = GetPoints( i - 1 ); for ( int k = 1, aNbPoints = aSectPointsList.Size(); k <= aNbPoints; ++k ) { const Point& aSectPoint = aSectPointsList.Value( k ); @@ -134,6 +134,10 @@ QStringList HYDROData_PolylineXY::DumpToPython( MapOfTreatedObjects& theTreatedO } } + aResList << QString( "" ); + aResList << QString( "%1.Update();" ).arg( aPolylineName ); + aResList << QString( "" ); + return aResList; } diff --git a/src/HYDROData/HYDROData_Profile.cxx b/src/HYDROData/HYDROData_Profile.cxx index 03c6ba85..ec1b9d7f 100755 --- a/src/HYDROData/HYDROData_Profile.cxx +++ b/src/HYDROData/HYDROData_Profile.cxx @@ -43,8 +43,61 @@ HYDROData_Profile::~HYDROData_Profile() QStringList HYDROData_Profile::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); + QString aName = GetName(); + + 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( aName ); + 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( aName ); + aResList << QString( "" ); + + //TCollection_AsciiString aFilePath = GetFilePath(); + //if ( !aFilePath.IsEmpty() ) + //{ + // aResList << QString( "%1.ImportFromFile( \"%2\" );" ) + // .arg( aName ).arg( aFilePath.ToCString() ); + //} + + bool isValid = IsValid(); + QString aGap = QString().fill( ' ', 11 ); + + aResList << QString( "points = [" ); - //TODO + if ( isValid ) + { + HYDROData_Profile::ProfilePoints aPointsList = GetProfilePoints(); + for ( int k = 1, aNbPoints = aPointsList.Size(); k <= aNbPoints; ++k ) + { + const ProfilePoint& aPoint = aPointsList.Value( k ); + aResList << QString( aGap + "gp_XYZ( %1, %2, %3 )%4" ).arg( aPoint.X() ).arg( aPoint.Y() ).arg( aPoint.Z() ) + .arg( ( k < aNbPoints ? "," : "" ) ); + } + aResList << QString( "];" ); + aResList << QString( "%1.SetProfilePoints( points );" ).arg( aName ); + } + else + { + HYDROData_IPolyline::PointsList aPointsList = GetParametricPoints(); + for ( int k = 1, aNbPoints = aPointsList.Size(); k <= aNbPoints; ++k ) + { + const HYDROData_IPolyline::Point& aPoint = aPointsList.Value( k ); + aResList << QString( aGap + "gp_XY( %1, %2 )%3" ).arg( aPoint.X() ).arg( aPoint.Y() ) + .arg( ( k < aNbPoints ? "," : "" ) ); + } + aResList << QString( "];" ); + aResList << QString( "%1.SetParametricPoints( points )" ).arg( aName ); + } + aResList << QString( "" ); + aResList << QString( "%1.Update();" ).arg( aName ); + aResList << QString( "" ); return aResList; } diff --git a/src/HYDROData/HYDROData_ProfileUZ.cxx b/src/HYDROData/HYDROData_ProfileUZ.cxx index 649c8096..09fc5234 100755 --- a/src/HYDROData/HYDROData_ProfileUZ.cxx +++ b/src/HYDROData/HYDROData_ProfileUZ.cxx @@ -28,6 +28,35 @@ HYDROData_ProfileUZ::~HYDROData_ProfileUZ() { } +QStringList HYDROData_ProfileUZ::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const +{ + QStringList aResList = dumpObjectCreation( theTreatedObjects ); + QString aName = GetName(); + + // Set polilyne data + const TCollection_AsciiString& aSectName = GetSectionName( 0 ); + const SectionType& aSectType = GetSectionType( 0 ); + bool aSectClosure = IsClosedSection( 0 ); + + aResList << QString( "%1.AddSection( \"%2\", %3, %4 );" ).arg( aName ) + .arg( aSectName.ToCString() ).arg( aSectType ).arg( aSectClosure ); + + HYDROData_IPolyline::PointsList aSectPointsList = GetPoints( 0 ); + for ( int k = 1, aNbPoints = aSectPointsList.Size(); k <= aNbPoints; ++k ) + { + const Point& aSectPoint = aSectPointsList.Value( k ); + + aResList << QString( "%1.AddPoint( 0, QPointF( %2, %3 ) );" ).arg( aName ) + .arg( aSectPoint.X() ).arg( aSectPoint.Y() ); + } + + aResList << QString( "" ); + aResList << QString( "%1.Update();" ).arg( aName ); + aResList << QString( "" ); + + return aResList; +} + TopoDS_Shape HYDROData_ProfileUZ::GetShape() const { // TODO diff --git a/src/HYDROData/HYDROData_ProfileUZ.h b/src/HYDROData/HYDROData_ProfileUZ.h index 0e1dcd0d..e948b4d3 100644 --- a/src/HYDROData/HYDROData_ProfileUZ.h +++ b/src/HYDROData/HYDROData_ProfileUZ.h @@ -30,6 +30,11 @@ public: */ HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_PROFILEUZ;} + /** + * Dump object to Python script representation. + */ + HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const; + public: /** diff --git a/src/HYDROData/HYDROData_Region.cxx b/src/HYDROData/HYDROData_Region.cxx index b5e05cb7..40699374 100644 --- a/src/HYDROData/HYDROData_Region.cxx +++ b/src/HYDROData/HYDROData_Region.cxx @@ -55,6 +55,9 @@ QStringList HYDROData_Region::DumpToPython( MapOfTreatedObjects& theTreatedObjec if ( !aRefZone.IsNull() ) setPythonReferenceObject( theTreatedObjects, aResList, aRefZone, "AddZone" ); } + + aResList << QString( "" ); + aResList << QString( "%1.Update();" ).arg( aRegionName ); aResList << QString( "" ); return aResList; diff --git a/src/HYDROData/HYDROData_River.cxx b/src/HYDROData/HYDROData_River.cxx index 27be9ea9..88d1bbce 100644 --- a/src/HYDROData/HYDROData_River.cxx +++ b/src/HYDROData/HYDROData_River.cxx @@ -23,9 +23,14 @@ HYDROData_River::~HYDROData_River() QStringList HYDROData_River::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); + QString aName = GetName(); // TODO + aResList << QString( "" ); + aResList << QString( "%1.Update();" ).arg( aName ); + aResList << QString( "" ); + return aResList; } diff --git a/src/HYDROData/HYDROData_Stream.cxx b/src/HYDROData/HYDROData_Stream.cxx index 07bf9971..312657ae 100644 --- a/src/HYDROData/HYDROData_Stream.cxx +++ b/src/HYDROData/HYDROData_Stream.cxx @@ -86,9 +86,14 @@ HYDROData_Stream::~HYDROData_Stream() QStringList HYDROData_Stream::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); + QString aName = GetName(); // TODO + aResList << QString( "" ); + aResList << QString( "%1.Update();" ).arg( aName ); + aResList << QString( "" ); + return aResList; } diff --git a/src/HYDROData/HYDROData_StreamAltitude.cxx b/src/HYDROData/HYDROData_StreamAltitude.cxx index bbcbb566..ce2d971a 100644 --- a/src/HYDROData/HYDROData_StreamAltitude.cxx +++ b/src/HYDROData/HYDROData_StreamAltitude.cxx @@ -47,9 +47,14 @@ HYDROData_StreamAltitude::~HYDROData_StreamAltitude() QStringList HYDROData_StreamAltitude::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); + QString aName = GetName(); // TODO + aResList << QString( "" ); + aResList << QString( "%1.Update();" ).arg( aName ); + aResList << QString( "" ); + return aResList; } diff --git a/src/HYDROData/HYDROData_Zone.cxx b/src/HYDROData/HYDROData_Zone.cxx index f90f0287..4d96a649 100644 --- a/src/HYDROData/HYDROData_Zone.cxx +++ b/src/HYDROData/HYDROData_Zone.cxx @@ -44,6 +44,10 @@ 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(); + aResList << QString( "" ); + aResList << QString( "%1.Update();" ).arg( aName ); + aResList << QString( "" ); return aResList; }