From 5aa347a5113696846e4c7a25884336bc415e75d9 Mon Sep 17 00:00:00 2001 From: adv Date: Fri, 17 Jan 2014 06:57:02 +0000 Subject: [PATCH] Dump to python corrected. --- src/HYDROData/HYDROData_Profile.cxx | 64 +++++++++++++++-------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/src/HYDROData/HYDROData_Profile.cxx b/src/HYDROData/HYDROData_Profile.cxx index 6d0d6857..76dfad84 100755 --- a/src/HYDROData/HYDROData_Profile.cxx +++ b/src/HYDROData/HYDROData_Profile.cxx @@ -43,21 +43,7 @@ HYDROData_Profile::~HYDROData_Profile() QStringList HYDROData_Profile::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); - QString aName = GetObjPyName(); - - 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( "" ); + QString aProfileName = GetObjPyName(); //TCollection_AsciiString aFilePath = GetFilePath(); //if ( !aFilePath.IsEmpty() ) @@ -66,22 +52,22 @@ QStringList HYDROData_Profile::DumpToPython( MapOfTreatedObjects& theTreatedObje // .arg( aName ).arg( aFilePath.ToCString() ); //} - bool isValid = IsValid(); - QString aGap = QString().fill( ' ', 11 ); + bool anIsValidProfile = IsValid(); - aResList << QString( "points = [" ); + QStringList aPntsDefinition; + QString aPntsListName = HYDROData_Tool::GenerateNameForPython( theTreatedObjects, "profile_points" ); - if ( isValid ) + QString aGap = QString().fill( ' ', aPntsListName.length() + 5 ); + if ( anIsValidProfile ) { 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 ? "," : "" ) ); + aPntsDefinition << 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 { @@ -89,11 +75,27 @@ QStringList HYDROData_Profile::DumpToPython( MapOfTreatedObjects& theTreatedObje 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 ? "," : "" ) ); + aPntsDefinition << 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 ); + } + + if ( !aPntsDefinition.isEmpty() ) + { + QString& aFirstStr = aPntsDefinition.first(); + aFirstStr = aFirstStr.trimmed(); + aFirstStr.prepend( QString( "%1 = [ " ).arg( aPntsListName ) ); + + aPntsDefinition.last().append( " ];" ); + + aResList << aPntsDefinition; + + aResList << QString( "%1.%3( %2 );" ) + .arg( aProfileName ).arg( aPntsListName ) + .arg( anIsValidProfile ? "SetProfilePoints" : "SetParametricPoints" ); + + aResList << QString( "" ); } // Set a polyline type if it is not default @@ -103,13 +105,13 @@ QStringList HYDROData_Profile::DumpToPython( MapOfTreatedObjects& theTreatedObje HYDROData_IPolyline::SectionType aSecType = aPrf->GetSectionType( 0 ); if ( aSecType != HYDROData_IPolyline::SECTION_POLYLINE ) { - aResList << QString( "%1.GetProfileUZ().SetSectionType( 0, %2 );" ).arg( aName ) - .arg( "HYDROData_IPolyline.SECTION_SPLINE" ); + aResList << QString( "%1.GetProfileUZ().SetSectionType( 0, %2 );" ) + .arg( aProfileName ).arg( "HYDROData_IPolyline.SECTION_SPLINE" ); + aResList << QString( "" ); } } - aResList << QString( "" ); - aResList << QString( "%1.Update();" ).arg( aName ); + aResList << QString( "%1.Update();" ).arg( aProfileName ); aResList << QString( "" ); return aResList; -- 2.39.2