From: sbh Date: Fri, 19 Sep 2014 11:38:17 +0000 (+0400) Subject: Issue #145 behavior on edit constraint corrected X-Git-Tag: V_0.4.4~45 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7d7c82a40c584a3004bdbf41df431ba7c0b7eb4c;p=modules%2Fshaper.git Issue #145 behavior on edit constraint corrected --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 211bc89cc..082c8cfa7 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -127,11 +127,6 @@ void PartSet_Module::featureCreated(QAction* theFeature) connect(theFeature, SIGNAL(triggered(bool)), this, SLOT(onFeatureTriggered())); } -QStringList PartSet_Module::nestedFeatures(QString) -{ - return QStringList(); -} - std::string PartSet_Module::featureFile(const std::string& theFeatureId) { return myFeaturesInFiles[theFeatureId]; diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 39ee6a763..803015f38 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -41,8 +41,6 @@ Q_OBJECT /// Called on creation of menu item in desktop virtual void featureCreated(QAction* theFeature); - /// Returnc list of nested commands for the given feature - virtual QStringList nestedFeatures(QString theFeature); std::string featureFile(const std::string&); /// Creates an operation and send it to loop diff --git a/src/XGUI/XGUI_ActionsMgr.cpp b/src/XGUI/XGUI_ActionsMgr.cpp index 294faab4b..165d0457e 100644 --- a/src/XGUI/XGUI_ActionsMgr.cpp +++ b/src/XGUI/XGUI_ActionsMgr.cpp @@ -61,7 +61,8 @@ void XGUI_ActionsMgr::update() if (myOperationMgr->hasOperation()) { setAllEnabled(false); ModuleBase_Operation* anOperation = myOperationMgr->currentOperation(); - QString anOperationId = anOperation->id(); + FeaturePtr aFeature = anOperation->feature(); + QString anOperationId = QString::fromStdString(aFeature->getKind()); //anOperation->id(); setActionEnabled(anOperationId, true); bool isNestedEnabled = anOperation->isNestedOperationsEnabled(); setNestedCommandsEnabled(isNestedEnabled, anOperationId); @@ -85,15 +86,13 @@ void XGUI_ActionsMgr::setNestedCommandsEnabled(bool theEnabled, const QString& t { QStringList ltNestedActions; if (theParent.isEmpty()) { //Disable ALL nested - foreach(QString eachParent, myNestedActions.keys()) - { + foreach(QString eachParent, myNestedActions.keys()) { ltNestedActions << myNestedActions[eachParent]; } } else { ltNestedActions << myNestedActions[theParent]; } - foreach(QString eachNested, ltNestedActions) - { + foreach(QString eachNested, ltNestedActions) { setActionEnabled(eachNested, theEnabled); } } @@ -117,13 +116,11 @@ void XGUI_ActionsMgr::setActionEnabled(const QString& theId, const bool theEnabl void XGUI_ActionsMgr::updateCheckState() { QString eachCommand = QString(); - foreach(eachCommand, myActions.keys()) - { + foreach(eachCommand, myActions.keys()) { setActionChecked(eachCommand, false); } QStringList ltActiveCommands = myOperationMgr->operationList(); - foreach(eachCommand, ltActiveCommands) - { + foreach(eachCommand, ltActiveCommands) { setActionChecked(eachCommand, true); } } diff --git a/src/XGUI/XGUI_Command.cpp b/src/XGUI/XGUI_Command.cpp index 59df312b1..07d0d310f 100644 --- a/src/XGUI/XGUI_Command.cpp +++ b/src/XGUI/XGUI_Command.cpp @@ -1,6 +1,8 @@ #include "XGUI_Command.h" #include #include +#include +#include XGUI_Command::XGUI_Command(const QString& theId, QObject * parent, bool isCheckable) : QWidgetAction(parent), @@ -65,4 +67,4 @@ const QStringList& XGUI_Command::nestedCommands() const void XGUI_Command::setNestedCommands(const QStringList& myUnblockableCommands) { this->myNestedCommands = myUnblockableCommands; -} +} \ No newline at end of file diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index b8e43d7ea..edb72cdb7 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -41,9 +41,11 @@ int XGUI_OperationMgr::operationsCount() const QStringList XGUI_OperationMgr::operationList() { QStringList result; - foreach(ModuleBase_Operation* eachOperation, myOperations) - { - result << eachOperation->id(); + foreach(ModuleBase_Operation* eachOperation, myOperations) { + FeaturePtr aFeature = eachOperation->feature(); + if(aFeature) { + result << QString::fromStdString(aFeature->getKind()); + } } return result; } @@ -80,7 +82,9 @@ bool XGUI_OperationMgr::startOperation(ModuleBase_Operation* theOperation) bool XGUI_OperationMgr::abortAllOperations() { - if (operationsCount() == 1) { + if(!hasOperation()) { + return true; + } else if (operationsCount() == 1) { onAbortOperation(); return true; } @@ -215,9 +219,6 @@ void XGUI_OperationMgr::onKeyReleased(QKeyEvent* theEvent) { // Let the manager decide what to do with the given key combination. ModuleBase_Operation* anOperation = currentOperation(); - if(anOperation) { - anOperation->activateNextToCurrentWidget(); - } bool isRestart = false; switch (theEvent->key()) { case Qt::Key_Escape: { @@ -226,6 +227,9 @@ void XGUI_OperationMgr::onKeyReleased(QKeyEvent* theEvent) break; case Qt::Key_Return: case Qt::Key_Enter: { + if(anOperation) { + anOperation->activateNextToCurrentWidget(); + } commitOperation(); } break; diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index 69408d05c..dd3cc642d 100644 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -110,7 +110,6 @@ void XGUI_PropertyPanel::setModelWidgets(const QList& t setTabOrder(anOkBtn, aCancelBtn); } } - onActivateNextWidget(NULL); } const QList& XGUI_PropertyPanel::modelWidgets() const diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index f3c19f8b3..4046ede8f 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -475,6 +475,7 @@ void XGUI_Workshop::onOperationStarted() } myPropertyPanel->setModelWidgets(aWidgets); + myPropertyPanel->onActivateNextWidget(NULL); myPropertyPanel->setWindowTitle(aOperation->getDescription()->description()); } updateCommandStatus(); @@ -574,11 +575,14 @@ void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation) aCommand = salomeConnector()->command(theOperation->getDescription()->operationId()); } else { XGUI_MainMenu* aMenu = myMainWindow->menuObject(); - aCommand = aMenu->feature(theOperation->getDescription()->operationId()); + FeaturePtr aFeature = theOperation->feature(); + if(aFeature) + aCommand = aMenu->feature(QString::fromStdString(aFeature->getKind())); } //Abort operation on uncheck the command - if (aCommand) + if (aCommand) { connect(aCommand, SIGNAL(triggered(bool)), theOperation, SLOT(setRunning(bool))); + } } /* @@ -858,8 +862,7 @@ void XGUI_Workshop::updateCommandStatus() if (aMgr->hasModuleDocument()) { QAction* aUndoCmd; QAction* aRedoCmd; - foreach(QAction* aCmd, aCommands) - { + foreach(QAction* aCmd, aCommands) { QString aId = aCmd->data().toString(); if (aId == "UNDO_CMD") aUndoCmd = aCmd; @@ -872,8 +875,7 @@ void XGUI_Workshop::updateCommandStatus() aUndoCmd->setEnabled(aMgr->canUndo()); aRedoCmd->setEnabled(aMgr->canRedo()); } else { - foreach(QAction* aCmd, aCommands) - { + foreach(QAction* aCmd, aCommands) { QString aId = aCmd->data().toString(); if (aId == "NEW_CMD") aCmd->setEnabled(true); @@ -1147,16 +1149,27 @@ void XGUI_Workshop::showOnlyObjects(const QList& theList) //************************************************************** void XGUI_Workshop::updateCommandsOnViewSelection() { - SessionPtr aMgr = ModelAPI_Session::get(); - ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); XGUI_Selection* aSelection = mySelector->selection(); if (aSelection->getSelected().size() == 0) return; + // Restrict validators to manage only nested (child) features + // of the current feature i.e. if current feature is Sketch - + // Sketch Features & Constraints can be validated. + QStringList aNestedIds; + if(myOperationMgr->hasOperation()) { + FeaturePtr aFeature = myOperationMgr->currentOperation()->feature(); + if(aFeature) { + aNestedIds << myActionsMgr->nestedCommands(QString::fromStdString(aFeature->getKind())); + } + } + SessionPtr aMgr = ModelAPI_Session::get(); + ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); QList aActions = getModuleCommands(); - foreach(QAction* aAction, aActions) - { + foreach(QAction* aAction, aActions) { QString aId = aAction->data().toString(); + if(!aNestedIds.contains(aId)) + continue; std::list aValidators; std::list > anArguments; aFactory->validators(aId.toStdString(), aValidators, anArguments);