Salome HOME
refs #430: incorrect coordinates in dump polyline
[modules/hydro.git] / src / HYDROData / HYDROData_PolylineXY.cxx
index e66438086ea59139e31e280ec67d9806f7331639..9711309a883a4a7c50f99e675f1a9dfab909b87c 100755 (executable)
@@ -164,8 +164,10 @@ QStringList HYDROData_PolylineXY::DumpToPython( MapOfTreatedObjects& theTreatedO
       {
         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( aSectPoint.X() ).arg( aSectPoint.Y() );
+          .arg( i - 1 ).arg( anXStr ).arg( anYStr );
       }
     }
   }
@@ -538,6 +540,11 @@ void HYDROData_PolylineXY::Update()
   setPolylineShape( aResult );
 }
 
+bool HYDROData_PolylineXY::IsHas2dPrs() const
+{
+  return true;
+}
+
 bool HYDROData_PolylineXY::IsEditable() const
 {
   return !myLab.IsAttribute( GUID_IS_UNEDITABLE );
@@ -1097,4 +1104,26 @@ QPainterPath HYDROData_PolylineXY::GetPainterPath() const
   return aPath;
 }
 
+void HYDROData_PolylineXY::UpdateLocalCS( double theDx, double theDy )
+{
+  NCollection_Sequence<TCollection_AsciiString>           aSectNames;
+  NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
+  NCollection_Sequence<bool>                              aSectClosures;
+  GetSections( aSectNames, aSectTypes, aSectClosures );
+
+  gp_XY aDelta( theDx, theDy );
+  for ( int i = 0, aNbSects = aSectNames.Size(); i < aNbSects; i++ )
+  {
+    PointsList aPoints = GetPoints( i );
+    for( int j = 1, n = aPoints.Size(); j <= n; ++j )
+    {
+      Point& aPoint = aPoints.ChangeValue( j );
+      aPoint += aDelta;
+    }
+    SetPoints( i, aPoints );
+  }
+  SetToUpdate( true );
+}
+
+