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() )
// .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
{
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
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;