From: adv Date: Wed, 4 Dec 2013 07:43:32 +0000 (+0000) Subject: Protection from creation ampty profiles and polylines (Bug #143). X-Git-Tag: BR_hydro_v_0_4~63 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=512ec397c07a7f6f569c058451daf788154deb3a;p=modules%2Fhydro.git Protection from creation ampty profiles and polylines (Bug #143). --- diff --git a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx index 1a954304..7ad2b2f6 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx +++ b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx @@ -194,6 +194,12 @@ bool HYDROGUI_PolylineOp::processApply( int& theUpdateFlags, } } + if ( myCurve->getNbSections() <= 0 ) + { + theErrorMsg = tr( "EMPTY_POLYLINE_DATA" ); + return false; + } + Handle(HYDROData_PolylineXY) aPolylineObj; if( myIsEdit ) { @@ -208,7 +214,7 @@ bool HYDROGUI_PolylineOp::processApply( int& theUpdateFlags, if( aPolylineObj.IsNull() ) return false; - aPolylineObj->SetName(aPolylineName); + aPolylineObj->SetName( aPolylineName ); for ( int i = 0 ; i < myCurve->getNbSections() ; i++ ) { @@ -225,6 +231,13 @@ bool HYDROGUI_PolylineOp::processApply( int& theUpdateFlags, // Add the points fro section CurveCreator::Coordinates aCurveCoords = myCurve->getPoints( i ); + + if ( aCurveCoords.size() <= 2 ) + { + theErrorMsg = tr( "NUMBER_OF_SECTION_POINTS_INCORRECT" ); + return false; + } + for ( int k = 0 ; k + 1 < aCurveCoords.size() ; k++ ) { HYDROData_PolylineXY::Point aSectPoint; diff --git a/src/HYDROGUI/HYDROGUI_ProfileOp.cxx b/src/HYDROGUI/HYDROGUI_ProfileOp.cxx index efe8572c..de662852 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileOp.cxx @@ -182,6 +182,12 @@ bool HYDROGUI_ProfileOp::processApply( int& theUpdateFlags, HYDROData_ProfileUZ::PointsList aProfileParamPoints; CurveCreator::Coordinates aCurveCoords = myProfile->getPoints( 0 ); + if ( aCurveCoords.size() <= 2 ) + { + theErrorMsg = tr( "NUMBER_OF_PROFILE_POINTS_INCORRECT" ); + return false; + } + for ( int k = 0 ; k + 1 < aCurveCoords.size() ; k++ ) { HYDROData_ProfileUZ::Point aProfileParamPoint; diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 0f4dd7e0..5999f7ef 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -1092,6 +1092,14 @@ file cannot be correctly imported for a Bathymetry definition. EDIT_POLYLINE Edit polyline + + EMPTY_POLYLINE_DATA + No one section is created for polyline, should be at least one. + + + NUMBER_OF_SECTION_POINTS_INCORRECT + Number of points in each polyline section should not be less than 2. + @@ -1116,6 +1124,10 @@ file cannot be correctly imported for a Bathymetry definition. EDIT_PROFILE Edit profile + + NUMBER_OF_PROFILE_POINTS_INCORRECT + Number of profile points should not be less than 2. +