+QStringList HYDROData_PolylineXY::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+{
+ QStringList aResList = dumpObjectCreation( theTreatedObjects );
+ QString aPolylineName = GetObjPyName();
+
+ // Set the wire color
+ QStringList aWireColorDef;
+
+ QColor aWireColor = GetWireColor();
+ setPythonObjectColor( aWireColorDef, aWireColor, DefaultWireColor(), "SetWireColor" );
+
+ if ( !aWireColorDef.isEmpty() )
+ {
+ aResList << aWireColorDef;
+ aResList << QString( "" );
+ }
+
+ bool anIsEditable = IsEditable();
+ if ( !anIsEditable )
+ {
+ // If polyline is not editable we try to import the shape from geom
+ TCollection_AsciiString aGeomObjectEntry = GetGeomObjectEntry();
+ if ( !aGeomObjectEntry.IsEmpty() )
+ {
+ QString aSalomeObjName = HYDROData_Tool::GenerateNameForPython( theTreatedObjects, "polyline_sobj" );
+ aResList << QString( "%1 = salome.myStudy.FindObjectID( \"%2\" );" )
+ .arg( aSalomeObjName ).arg( aGeomObjectEntry.ToCString() );
+
+ aResList << QString( "%1.ImportFromGeomIOR( %2.GetIOR() );" )
+ .arg( aPolylineName ).arg( aSalomeObjName );
+
+ aResList << QString( "%1.SetGeomObjectEntry( \"%2\" );" )
+ .arg( aPolylineName ).arg( aGeomObjectEntry.ToCString() );
+ }
+ }
+ else
+ {
+ // Set polilyne data
+ NCollection_Sequence<TCollection_AsciiString> aSectNames;
+ NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
+ NCollection_Sequence<bool> aSectClosures;
+ GetSections( aSectNames, aSectTypes, aSectClosures );
+
+ for ( int i = 1, n = aSectNames.Size(); i <= n; ++i )
+ {
+ const TCollection_AsciiString& aSectName = aSectNames.Value( i );
+ const SectionType& aSectType = aSectTypes.Value( i );
+ bool aSectClosure = aSectClosures.Value( i );
+
+ aResList << QString( "%1.AddSection( \"%2\", %3, %4 );" ).arg( aPolylineName )
+ .arg( aSectName.ToCString() ).arg( aSectType ).arg( aSectClosure );
+
+ HYDROData_IPolyline::PointsList aSectPointsList = GetPoints( i - 1 );
+ for ( int k = 1, aNbPoints = aSectPointsList.Size(); k <= aNbPoints; ++k )
+ {
+ const Point& aSectPoint = aSectPointsList.Value( k );
+
+ QString anXStr = QString::number( aSectPoint.X(), 'f', 2 );
+ QString anYStr = QString::number( aSectPoint.Y(), 'f', 2 );
+ aResList << QString( "%1.AddPoint( %2, gp_XY( %3, %4 ) );" ).arg( aPolylineName )
+ .arg( i - 1 ).arg( anXStr ).arg( anYStr );
+ }
+ }
+ }
+ aResList << QString( "" );
+ aResList << QString( "%1.Update();" ).arg( aPolylineName );
+ aResList << QString( "" );
+
+ return aResList;
+}
+
+QVariant HYDROData_PolylineXY::GetDataVariant()
+{
+ QPainterPath aPath = GetPainterPath();
+
+ QVariant aVarData;
+ aVarData.setValue<QPainterPath>( aPath );
+
+ return aVarData;
+}
+
+QColor HYDROData_PolylineXY::DefaultWireColor()