if( !myCurve )
return;
- stopModificationMode();
+ stopActionMode();
myNewSectionEditor->clear();
myNewSectionEditor->setEditMode(false);
QString aSectName = QString( CurveCreator_UtilsICurve::getUniqSectionName( myCurve ).c_str() );
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;
if( !myCurve )
return;
- stopModificationMode();
+ stopActionMode();
mySection = theSection;
QString aSectName = QString::fromStdString( myCurve->getSectionName(theSection));
bool isClosed = myCurve->isClosed(theSection);
if( aSections.size() == 0 ){
return;
}
- stopModificationMode();
+ stopActionMode();
int aMainSect = aSections[0];
int aMainSectSize = myCurve->getNbPoints(aMainSect);
{
if( !myCurve )
return;
- stopModificationMode();
+ stopActionMode();
myCurve->clear();
mySectionView->reset();
updateActionsStates();
{
if( !myCurve )
return;
- stopModificationMode();
+ stopActionMode();
myCurve->join();
mySectionView->reset();
updateActionsStates();
{
if( !myCurve )
return;
- stopModificationMode();
+ stopActionMode();
QList<int> aSelSections = mySectionView->getSelectedSections();
for( int i = 0 ; i < aSelSections.size() ; i++ ){
myCurve->setSectionType(aSelSections[i], CurveCreator::Spline );
{
if( !myCurve )
return;
- stopModificationMode();
+ stopActionMode();
QList<int> aSelSections = mySectionView->getSelectedSections();
for( int i = 0 ; i < aSelSections.size() ; i++ ){
myCurve->setSectionType( aSelSections[i], CurveCreator::Polyline );
{
if( !myCurve )
return;
- stopModificationMode();
+ stopActionMode();
QList<int> aSelSections = mySectionView->getSelectedSections();
for( int i = 0 ; i < aSelSections.size() ; i++ ){
myCurve->setClosed(aSelSections[i], true);
{
if( !myCurve )
return;
- stopModificationMode();
+ stopActionMode();
QList<int> aSelSections = mySectionView->getSelectedSections();
for( int i = 0 ; i < aSelSections.size() ; i++ ){
myCurve->setClosed(aSelSections[i], false);
*/
void CurveCreator_Widget::removeSection()
{
- stopModificationMode();
+ stopActionMode();
QList< QPair<int,int> > aSelPoints = mySectionView->getSelectedPoints();
int aCurrSect=-1;
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 );
}
/**
void addCoordsByClick( QMouseEvent* );
protected:
- enum ActionId{ UNDO_ID,
+ enum ActionId{ NONE_ID,
+ UNDO_ID,
REDO_ID,
NEW_SECTION_ID,
ADDITION_MODE_ID,
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();
void setSelectedPoints( const CurveCreator_ICurve::SectionToPointList& =
CurveCreator_ICurve::SectionToPointList() );
- void stopModificationMode();
+ void stopActionMode();
void startCurveModification( CurveCreator_ICurve::SectionToPointList& thePoints,
const bool theFillPoints = true );