X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_PolylineXY.cxx;h=1c824402a3276a9d19d48de047d4790d619d2061;hb=18bf2fdae8933e8a31ca58f36b6dceb7a4a8cf42;hp=72423bb3e76612eeadc53a40b338b6c3f8cc6c6a;hpb=95fae05fbf436c6efd6dcebe37dc8315e9f3147b;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_PolylineXY.cxx b/src/HYDROData/HYDROData_PolylineXY.cxx index 72423bb3..1c824402 100755 --- a/src/HYDROData/HYDROData_PolylineXY.cxx +++ b/src/HYDROData/HYDROData_PolylineXY.cxx @@ -1,3 +1,20 @@ +// Copyright (C) 2014-2015 EDF-R&D +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #include "HYDROData_PolylineXY.h" @@ -164,8 +181,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 ); } } } @@ -409,9 +428,10 @@ TopoDS_Wire HYDROData_PolylineXY::BuildWire( const SectionType& if ( thePoints.Size() > 1 ) { - HYDROData_BSplineOperation aBSpline( thePoints, theIsClosed, LOCAL_SELECTION_TOLERANCE ); + Handle(Geom_BSplineCurve) aCurve = + HYDROData_BSplineOperation::ComputeCurve( thePoints, theIsClosed, LOCAL_SELECTION_TOLERANCE ); - TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aBSpline.Curve() ).Edge(); + TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aCurve ).Edge(); aMakeWire.Add( anEdge ); } aMakeWire.Build(); @@ -447,8 +467,9 @@ void HYDROData_PolylineXY::BuildPainterPath( QPainterPath& } else { - HYDROData_BSplineOperation aBSpline( thePoints, theIsClosed, LOCAL_SELECTION_TOLERANCE ); - aBSpline.ComputePath( thePath ); + Handle(Geom_BSplineCurve) aCurve = + HYDROData_BSplineOperation::ComputeCurve( thePoints, theIsClosed, LOCAL_SELECTION_TOLERANCE ); + HYDROData_BSplineOperation::ComputePath( aCurve, thePath ); } } @@ -636,18 +657,19 @@ double HYDROData_PolylineXY::GetDistance( const int theSectionIndex, aPointToTest = aPoint; } - HYDROData_BSplineOperation aBSpline( aPoints, anIsSectionClosed, LOCAL_SELECTION_TOLERANCE ); + Handle(Geom_BSplineCurve) aCurve = + HYDROData_BSplineOperation::ComputeCurve( aPoints, anIsSectionClosed, LOCAL_SELECTION_TOLERANCE ); - Quantity_Parameter aFirstParam = aBSpline.Curve()->FirstParameter(); - Quantity_Parameter aSecondParam = aBSpline.Curve()->LastParameter(); + Quantity_Parameter aFirstParam = aCurve->FirstParameter(); + Quantity_Parameter aSecondParam = aCurve->LastParameter(); if ( thePointIndex != aSectNbPoints - 1 ) { - GeomAPI_ProjectPointOnCurve aProject( aPointToTest, aBSpline.Curve() ); + GeomAPI_ProjectPointOnCurve aProject( aPointToTest, aCurve ); aSecondParam = aProject.LowerDistanceParameter(); } - GeomAdaptor_Curve anAdap( aBSpline.Curve() ); + GeomAdaptor_Curve anAdap( aCurve ); aResDistance = GCPnts_AbscissaPoint::Length( anAdap, aFirstParam, aSecondParam ); } @@ -1123,5 +1145,26 @@ void HYDROData_PolylineXY::UpdateLocalCS( double theDx, double theDy ) SetToUpdate( true ); } +void HYDROData_PolylineXY::Transform( const QTransform& theTrsf ) +{ + NCollection_Sequence aSectNames; + NCollection_Sequence aSectTypes; + NCollection_Sequence aSectClosures; + GetSections( aSectNames, aSectTypes, aSectClosures ); + + 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 ); + + QPointF aTrsfPoint = theTrsf.map( QPointF( aPoint.X(), aPoint.Y() ) ); + aPoint.SetX( aTrsfPoint.x() ); + aPoint.SetY( aTrsfPoint.y() ); + } + SetPoints( i, aPoints ); + } + + Update(); +}