From: nds Date: Fri, 6 Dec 2013 07:03:11 +0000 (+0000) Subject: Bug #196 - Regression: modification mode is canceled after call ny context menu command X-Git-Tag: BR_hydro_v_0_4~13 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=95ccf034dee367cc12d9e5f55fa87da33e5847e1;p=modules%2Fhydro.git Bug #196 - Regression: modification mode is canceled after call ny context menu command --- diff --git a/src/HYDROCurveCreator/CurveCreator_Widget.cxx b/src/HYDROCurveCreator/CurveCreator_Widget.cxx index b44a2734..581ce149 100644 --- a/src/HYDROCurveCreator/CurveCreator_Widget.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Widget.cxx @@ -507,7 +507,7 @@ void CurveCreator_Widget::onNewSection() if( !myCurve ) return; - stopModificationMode(); + stopActionMode(); myNewSectionEditor->clear(); myNewSectionEditor->setEditMode(false); QString aSectName = QString( CurveCreator_UtilsICurve::getUniqSectionName( myCurve ).c_str() ); @@ -548,13 +548,65 @@ QAction* CurveCreator_Widget::createAction( ActionId theId, const QString& theNa return anAct; } -QAction* CurveCreator_Widget::getAction(ActionId theId) +QAction* CurveCreator_Widget::getAction( ActionId theId ) { if( myActionMap.contains(theId) ) return myActionMap[theId]; return NULL; } +QAction* CurveCreator_Widget::getAction( ActionMode theMode ) +{ + ActionId anActionId = NONE_ID; + switch ( theMode ) { + case AdditionMode: + anActionId = ADDITION_MODE_ID; + break; + case ModificationMode: + anActionId = MODIFICATION_MODE_ID; + break; + case DetectionMode: + anActionId = DETECTION_MODE_ID; + break; + default: + break; + } + QAction* anAction = 0; + if ( anActionId != NONE_ID && myActionMap.contains( anActionId ) ) + anAction = myActionMap[anActionId]; + return anAction; +} + +void CurveCreator_Widget::setActionMode( const ActionMode& theMode ) +{ + ActionMode aPrevMode = getActionMode(); + QAction* aPrevAction = getAction( aPrevMode ); + switch ( theMode ) { + case NoneMode: { + if ( aPrevAction ) { + if ( aPrevAction->isChecked() ) + aPrevAction->setChecked( false ); + } + if ( aPrevMode == ModificationMode ) + onModificationMode( false ); + if ( aPrevMode == AdditionMode ) + onAdditionMode( false ); + } + break; + case AdditionMode: { + // TODO + } + break; + case ModificationMode: + { + //TODO + } + break; + case DetectionMode: + break; + } +} + CurveCreator_Widget::ActionMode CurveCreator_Widget::getActionMode() const { ActionMode aMode = NoneMode; @@ -574,7 +626,7 @@ void CurveCreator_Widget::onEditSection( int theSection ) if( !myCurve ) return; - stopModificationMode(); + stopActionMode(); mySection = theSection; QString aSectName = QString::fromStdString( myCurve->getSectionName(theSection)); bool isClosed = myCurve->isClosed(theSection); @@ -613,7 +665,7 @@ void CurveCreator_Widget::onJoin() if( aSections.size() == 0 ){ return; } - stopModificationMode(); + stopActionMode(); int aMainSect = aSections[0]; int aMainSectSize = myCurve->getNbPoints(aMainSect); @@ -649,7 +701,7 @@ void CurveCreator_Widget::onClearAll() { if( !myCurve ) return; - stopModificationMode(); + stopActionMode(); myCurve->clear(); mySectionView->reset(); updateActionsStates(); @@ -660,7 +712,7 @@ void CurveCreator_Widget::onJoinAll() { if( !myCurve ) return; - stopModificationMode(); + stopActionMode(); myCurve->join(); mySectionView->reset(); updateActionsStates(); @@ -676,7 +728,7 @@ void CurveCreator_Widget::onSetSpline() { if( !myCurve ) return; - stopModificationMode(); + stopActionMode(); QList aSelSections = mySectionView->getSelectedSections(); for( int i = 0 ; i < aSelSections.size() ; i++ ){ myCurve->setSectionType(aSelSections[i], CurveCreator::Spline ); @@ -689,7 +741,7 @@ void CurveCreator_Widget::onSetPolyline() { if( !myCurve ) return; - stopModificationMode(); + stopActionMode(); QList aSelSections = mySectionView->getSelectedSections(); for( int i = 0 ; i < aSelSections.size() ; i++ ){ myCurve->setSectionType( aSelSections[i], CurveCreator::Polyline ); @@ -702,7 +754,7 @@ void CurveCreator_Widget::onCloseSections() { if( !myCurve ) return; - stopModificationMode(); + stopActionMode(); QList aSelSections = mySectionView->getSelectedSections(); for( int i = 0 ; i < aSelSections.size() ; i++ ){ myCurve->setClosed(aSelSections[i], true); @@ -715,7 +767,7 @@ void CurveCreator_Widget::onUncloseSections() { if( !myCurve ) return; - stopModificationMode(); + stopActionMode(); QList aSelSections = mySectionView->getSelectedSections(); for( int i = 0 ; i < aSelSections.size() ; i++ ){ myCurve->setClosed(aSelSections[i], false); @@ -1010,7 +1062,7 @@ void CurveCreator_Widget::onCellChanged( int theRow, int theColumn ) */ void CurveCreator_Widget::removeSection() { - stopModificationMode(); + stopActionMode(); QList< QPair > aSelPoints = mySectionView->getSelectedPoints(); int aCurrSect=-1; @@ -1252,14 +1304,9 @@ void CurveCreator_Widget::setSelectedPoints( const CurveCreator_ICurve::SectionT updateLocalPointView(); } -void CurveCreator_Widget::stopModificationMode() +void CurveCreator_Widget::stopActionMode() { - QAction* anAction = myActionMap[MODIFICATION_MODE_ID]; - if ( anAction ) { - if ( anAction->isChecked() ) - anAction->setChecked( false ); - } - onModificationMode( false ); + setActionMode( NoneMode ); } /** diff --git a/src/HYDROCurveCreator/CurveCreator_Widget.h b/src/HYDROCurveCreator/CurveCreator_Widget.h index 7da055ae..9243452d 100644 --- a/src/HYDROCurveCreator/CurveCreator_Widget.h +++ b/src/HYDROCurveCreator/CurveCreator_Widget.h @@ -128,7 +128,8 @@ protected: void addCoordsByClick( QMouseEvent* ); protected: - enum ActionId{ UNDO_ID, + enum ActionId{ NONE_ID, + UNDO_ID, REDO_ID, NEW_SECTION_ID, ADDITION_MODE_ID, @@ -159,6 +160,9 @@ private: QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage, const QString& theToolTip, const QKeySequence& theShortcut ); QAction* getAction(ActionId theId); + QAction* getAction(ActionMode theMode); + + void setActionMode( const ActionMode& theMode ); ActionMode getActionMode() const; void updateActionsStates(); @@ -179,7 +183,7 @@ private: void setSelectedPoints( const CurveCreator_ICurve::SectionToPointList& = CurveCreator_ICurve::SectionToPointList() ); - void stopModificationMode(); + void stopActionMode(); void startCurveModification( CurveCreator_ICurve::SectionToPointList& thePoints, const bool theFillPoints = true );