From: nds Date: Wed, 25 Dec 2013 15:42:59 +0000 (+0000) Subject: Refs #288 - the profile section selected and addition mode is activated X-Git-Tag: BR_hydro_v_0_7~57 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3cc307dd0c8bbcc054b82ca99d143a44e494ab04;p=modules%2Fhydro.git Refs #288 - the profile section selected and addition mode is activated --- diff --git a/src/HYDROCurveCreator/CurveCreator_Widget.cxx b/src/HYDROCurveCreator/CurveCreator_Widget.cxx index e4df186f..af71520e 100644 --- a/src/HYDROCurveCreator/CurveCreator_Widget.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Widget.cxx @@ -575,50 +575,6 @@ QAction* CurveCreator_Widget::getAction( ActionMode theMode ) 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; - - if ( myActionMap[ADDITION_MODE_ID]->isChecked() ) - aMode = AdditionMode; - else if ( myActionMap[MODIFICATION_MODE_ID]->isChecked() ) - aMode = ModificationMode; - else if ( myActionMap[DETECTION_MODE_ID]->isChecked() ) - aMode = DetectionMode; - - return aMode; -} - void CurveCreator_Widget::onEditSection( int theSection ) { if( !myCurve ) @@ -881,6 +837,13 @@ QList CurveCreator_Widget::getSelectedSections() return mySectionView->getSelectedSections(); } +void CurveCreator_Widget::setSelectedSections( const QList& theSections ) +{ + mySectionView->setSelectedSections( theSections ); + updateActionsStates(); + updateUndoRedo(); +} + /** * According to the widget state, performs the remove action */ @@ -904,6 +867,55 @@ bool CurveCreator_Widget::removeEnabled() return isEnabled; } +void CurveCreator_Widget::setActionMode( const ActionMode& theMode ) +{ + ActionMode aPrevMode = getActionMode(); + QAction* aPrevAction = getAction( aPrevMode ); + QAction* anAction = getAction( theMode ); + switch ( theMode ) { + case NoneMode: + case AdditionMode: { + if ( aPrevAction ) { + if ( aPrevAction->isChecked() ) { + aPrevAction->setChecked( false ); + } + } + if ( aPrevMode == ModificationMode ) + onModificationMode( false ); + if ( aPrevMode == AdditionMode ) + onAdditionMode( false ); + + if ( theMode == AdditionMode ) + { + anAction->setChecked( true ); + onModeChanged( true ); + } + } + break; + break; + case ModificationMode: + { + //TODO + } + break; + case DetectionMode: + break; + } +} + +CurveCreator_Widget::ActionMode CurveCreator_Widget::getActionMode() const +{ + ActionMode aMode = NoneMode; + + if ( myActionMap[ADDITION_MODE_ID]->isChecked() ) + aMode = AdditionMode; + else if ( myActionMap[MODIFICATION_MODE_ID]->isChecked() ) + aMode = ModificationMode; + else if ( myActionMap[DETECTION_MODE_ID]->isChecked() ) + aMode = DetectionMode; + + return aMode; +} //================================================================================= // function : GeometryGUI::addCoordsByClick() diff --git a/src/HYDROCurveCreator/CurveCreator_Widget.h b/src/HYDROCurveCreator/CurveCreator_Widget.h index f3fba8a1..2d4348cc 100644 --- a/src/HYDROCurveCreator/CurveCreator_Widget.h +++ b/src/HYDROCurveCreator/CurveCreator_Widget.h @@ -60,6 +60,13 @@ public: DisableClosedSection = 0x00000004 }; + enum ActionMode { + NoneMode, + AdditionMode, + ModificationMode, + DetectionMode + }; + public: explicit CurveCreator_Widget( QWidget* parent, CurveCreator_ICurve *theCurve, @@ -78,10 +85,14 @@ public: void setCurve( CurveCreator_ICurve* theCurve ); QList getSelectedSections(); + void setSelectedSections( const QList& theSections ); void removeSelected(); bool removeEnabled(); + void setActionMode( const ActionMode& theMode ); + ActionMode getActionMode() const; + signals: void selectionChanged(); void subOperationStarted( QWidget*, bool ); @@ -147,13 +158,6 @@ protected: DETECTION_MODE_ID }; - enum ActionMode { - NoneMode, - AdditionMode, - ModificationMode, - DetectionMode - }; - private: OCCViewer_Viewer* getOCCViewer(); @@ -162,9 +166,6 @@ private: QAction* getAction(ActionId theId); QAction* getAction(ActionMode theMode); - void setActionMode( const ActionMode& theMode ); - ActionMode getActionMode() const; - void updateActionsStates(); void updateUndoRedo(); diff --git a/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx b/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx index e4725a2a..9c10ea4a 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx @@ -126,6 +126,7 @@ HYDROGUI_ProfileDlg::~HYDROGUI_ProfileDlg() void HYDROGUI_ProfileDlg::reset() { myEditorWidget->reset(); + myEditorWidget->setActionMode( CurveCreator_Widget::AdditionMode ); } Handle(AIS_InteractiveContext) HYDROGUI_ProfileDlg::getAISContext() @@ -147,6 +148,11 @@ QString HYDROGUI_ProfileDlg::getProfileName() const void HYDROGUI_ProfileDlg::setProfile( CurveCreator_ICurve* theProfile ) { myEditorWidget->setCurve( theProfile ); + + // select the single section by default + QList aSections; + aSections << 0; + myEditorWidget->setSelectedSections( aSections ); } QList HYDROGUI_ProfileDlg::getSelectedSections()