From: adv Date: Mon, 9 Dec 2013 08:03:14 +0000 (+0000) Subject: The type of section for profile added (Bug #172). X-Git-Tag: BR_hydro_v_0_5~35 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5f5584107a486013bff5df971695bc8197716252;p=modules%2Fhydro.git The type of section for profile added (Bug #172). --- diff --git a/src/HYDROCurveCreator/CurveCreator_Profile.cxx b/src/HYDROCurveCreator/CurveCreator_Profile.cxx index 4164ca68..c857fd20 100644 --- a/src/HYDROCurveCreator/CurveCreator_Profile.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Profile.cxx @@ -133,18 +133,6 @@ bool CurveCreator_Profile::setClosed( const int theISection, return false; } -bool CurveCreator_Profile::setSectionTypeInternal( const int theISection, - const CurveCreator::SectionType theType ) -{ - return CurveCreator_Curve::setSectionTypeInternal( theISection, theType ); -} - -bool CurveCreator_Profile::setSectionType( const int theISection, - const CurveCreator::SectionType theType ) -{ - return CurveCreator_Curve::setSectionType( theISection, theType ); -} - bool CurveCreator_Profile::addPointsInternal( const CurveCreator::SectionsMap &theSectionsMap ) { bool res = false; diff --git a/src/HYDROCurveCreator/CurveCreator_Profile.hxx b/src/HYDROCurveCreator/CurveCreator_Profile.hxx index 3d080011..d544c87c 100644 --- a/src/HYDROCurveCreator/CurveCreator_Profile.hxx +++ b/src/HYDROCurveCreator/CurveCreator_Profile.hxx @@ -97,18 +97,6 @@ public: virtual bool setClosed( const int theISection, const bool theIsClosed ); - - //! For internal use only! Undo/Redo are not used here. - virtual bool setSectionTypeInternal( const int theISection, - const CurveCreator::SectionType theType ); - /** - * Set type of the specified section (or all sections - * if \a theISection is -1). - */ - virtual bool setSectionType( const int theISection, - const CurveCreator::SectionType theType ); - - /***********************************************/ /*** Point methods ***/ /***********************************************/ diff --git a/src/HYDROData/HYDROData_ProfileUZ.cxx b/src/HYDROData/HYDROData_ProfileUZ.cxx index 80fe9987..dc82a136 100755 --- a/src/HYDROData/HYDROData_ProfileUZ.cxx +++ b/src/HYDROData/HYDROData_ProfileUZ.cxx @@ -8,6 +8,9 @@ #include +#include +#include +#include #include #include @@ -90,12 +93,29 @@ void HYDROData_ProfileUZ::SetSectionName( const int /*theSe HYDROData_ProfileUZ::SectionType HYDROData_ProfileUZ::GetSectionType( const int /*theSectionIndex*/ ) const { - return SECTION_POLYLINE; + Handle(TDataStd_ExtStringList) aNamesList; + Handle(TDataStd_IntegerList) aTypesList; + Handle(TDataStd_BooleanList) aClosuresList; + getSectionsLists( aNamesList, aTypesList, aClosuresList, false ); + if ( aTypesList.IsNull() || aTypesList->IsEmpty() ) + return SECTION_POLYLINE; + + return (SectionType)aTypesList->First(); } void HYDROData_ProfileUZ::SetSectionType( const int /*theSectionIndex*/, - const SectionType /*theSectionType*/ ) + const SectionType theSectionType ) { + Handle(TDataStd_ExtStringList) aNamesList; + Handle(TDataStd_IntegerList) aTypesList; + Handle(TDataStd_BooleanList) aClosuresList; + getSectionsLists( aNamesList, aTypesList, aClosuresList ); + if ( aTypesList.IsNull() ) + return; + + // Refill the existing list + aTypesList->Clear(); + aTypesList->Append( theSectionType ); } bool HYDROData_ProfileUZ::IsClosedSection( const int /*theSectionIndex*/ ) const diff --git a/src/HYDROGUI/HYDROGUI_ProfileOp.cxx b/src/HYDROGUI/HYDROGUI_ProfileOp.cxx index a9a9cf2c..90f382c7 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileOp.cxx @@ -91,23 +91,36 @@ void HYDROGUI_ProfileOp::startOperation() QString aProfileName; if( !myEditedObject.IsNull() ) { - CurveCreator::Coordinates aCurveCoords; - CurveCreator::SectionsMap aSectionsMap; - - HYDROData_ProfileUZ::PointsList aSectPointsList = myEditedObject->GetParametricPoints(); - CurveCreator::PosPointsList aPoints; - for ( int k = 1, aNbPoints = aSectPointsList.Size(); k <= aNbPoints; ++k ) + Handle(HYDROData_ProfileUZ) aProfileUZ = myEditedObject->GetProfileUZ( false ); + if ( !aProfileUZ.IsNull() ) { - const HYDROData_ProfileUZ::Point& aSectPoint = aSectPointsList.Value( k ); - aCurveCoords.clear(); - aCurveCoords.push_back( aSectPoint.X() ); - aCurveCoords.push_back( aSectPoint.Y() ); + CurveCreator::Coordinates aCurveCoords; + CurveCreator::SectionsMap aSectionsMap; + + HYDROData_ProfileUZ::PointsList aSectPointsList = aProfileUZ->GetPoints(); + CurveCreator::PosPointsList aPoints; + for ( int k = 1, aNbPoints = aSectPointsList.Size(); k <= aNbPoints; ++k ) + { + const HYDROData_ProfileUZ::Point& aSectPoint = aSectPointsList.Value( k ); + aCurveCoords.clear(); + aCurveCoords.push_back( aSectPoint.X() ); + aCurveCoords.push_back( aSectPoint.Y() ); + + CurveCreator_PosPoint* aPosPoint = new CurveCreator_PosPoint( k, aCurveCoords ); + aPoints.push_back( aPosPoint ); + } + + aSectionsMap[0] = aPoints; + myProfile->addPointsInternal( aSectionsMap ); + + HYDROData_ProfileUZ::SectionType aSectType = aProfileUZ->GetSectionType( 0 ); - CurveCreator_PosPoint* aPosPoint = new CurveCreator_PosPoint( k, aCurveCoords ); - aPoints.push_back( aPosPoint ); + CurveCreator::SectionType aCurveType = CurveCreator::Polyline; + if( aSectType == HYDROData_ProfileUZ::SECTION_SPLINE ) + aCurveType = CurveCreator::Spline; + + myProfile->setSectionType( 0, aCurveType ); } - aSectionsMap[0] = aPoints; - myProfile->addPointsInternal( aSectionsMap ); aProfileName = myEditedObject->GetName(); } @@ -177,6 +190,10 @@ bool HYDROGUI_ProfileOp::processApply( int& theUpdateFlags, if( aProfileObj.IsNull() ) return false; + Handle(HYDROData_ProfileUZ) aProfileUZ = aProfileObj->GetProfileUZ(); + if ( aProfileUZ.IsNull() ) + return false; + aProfileObj->SetName(aProfileName); HYDROData_ProfileUZ::PointsList aProfileParamPoints; @@ -200,6 +217,12 @@ bool HYDROGUI_ProfileOp::processApply( int& theUpdateFlags, } aProfileObj->SetParametricPoints( aProfileParamPoints ); + HYDROData_ProfileUZ::SectionType aSectType = HYDROData_ProfileUZ::SECTION_POLYLINE; + if ( myProfile->getSectionType( 0 ) == CurveCreator::Spline ) + aSectType = HYDROData_ProfileUZ::SECTION_SPLINE; + + aProfileUZ->SetSectionType( 0, aSectType ); + aProfileObj->Update(); theUpdateFlags = UF_Model;