From 441e349df8f090948bdbcc8dc2a492011207ca4b Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 11 Dec 2014 14:57:27 +0300 Subject: [PATCH] Commit of the current operation if the preselection is activated. --- src/ModuleBase/ModuleBase_Operation.cpp | 27 +++++++++---------- src/ModuleBase/ModuleBase_Operation.h | 1 + .../ModuleBase_WidgetShapeSelector.cpp | 7 ++--- src/PartSet/PartSet_Module.cpp | 20 ++++++++++++++ src/PartSet/PartSet_Module.h | 4 +++ src/XGUI/XGUI_OperationMgr.cpp | 2 ++ src/XGUI/XGUI_OperationMgr.h | 4 +++ src/XGUI/XGUI_Workshop.cpp | 3 +-- 8 files changed, 48 insertions(+), 20 deletions(-) diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index 89b1957d3..58d0c2d9c 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -232,13 +232,15 @@ void ModuleBase_Operation::setRunning(bool theState) bool ModuleBase_Operation::activateByPreselection() { - if (!myPropertyPanel) - return false; - if (myPreSelection.empty()) + if (!myPropertyPanel || myPreSelection.empty()) { + myPropertyPanel->activateNextWidget(NULL); return false; + } const QList& aWidgets = myPropertyPanel->modelWidgets(); - if (aWidgets.empty()) + if (aWidgets.empty()) { + myPropertyPanel->activateNextWidget(NULL); return false; + } ModuleBase_ModelWidget* aWgt, *aFilledWgt = 0; QList::const_iterator aWIt; @@ -261,19 +263,14 @@ bool ModuleBase_Operation::activateByPreselection() aFilledWgt = aWgt; } } - if (isSet && canBeCommitted()) { - // if all widgets are filled with selection - commit - // in order to commit the operation outside of starting procedure - use timer event - QTimer::singleShot(50, this, SLOT(commit())); + + if (aFilledWgt) { + myPropertyPanel->activateNextWidget(aFilledWgt); + emit activatedByPreselection(); return true; } - else { - //activate next widget - if (aFilledWgt) { - myPropertyPanel->activateNextWidget(aFilledWgt); - return true; - } - } + else + myPropertyPanel->activateNextWidget(NULL); return false; } diff --git a/src/ModuleBase/ModuleBase_Operation.h b/src/ModuleBase/ModuleBase_Operation.h index acefc9ee8..17233f0f2 100644 --- a/src/ModuleBase/ModuleBase_Operation.h +++ b/src/ModuleBase/ModuleBase_Operation.h @@ -142,6 +142,7 @@ signals: void stopped(); /// the operation is aborted or committed void resumed(); /// the operation is resumed void postponed(); /// the operation is postponed + void activatedByPreselection(); /// the operation is filled with existing preselection public slots: /// Starts operation diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index 886c57658..4ac9d96b7 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -248,8 +248,10 @@ void ModuleBase_WidgetShapeSelector::onSelectionChanged() //QObjectPtrList aObjects = myWorkshop->selection()->selectedPresentations(); QList aSelected = myWorkshop->selection()->getSelected(); - if (aSelected.size() > 0) - setSelection(aSelected.first()); + if (aSelected.size() > 0) { + if (setSelection(aSelected.first())) + emit focusOutWidget(this); + } } //******************************************************************** @@ -306,7 +308,6 @@ bool ModuleBase_WidgetShapeSelector::setSelection(ModuleBase_ViewerPrs theValue) } if (isValid(aObject, aShape)) { setObject(aObject, aShape); - emit focusOutWidget(this); return true; } return false; diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 65cc6e200..b47766109 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -112,6 +112,8 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop) XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr(); connect(anOpMgr, SIGNAL(keyEnterReleased()), this, SLOT(onEnterReleased())); + connect(anOpMgr, SIGNAL(operationActivatedByPreselection()), + this, SLOT(onOperationActivatedByPreselection())); connect(aViewer, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)), this, SLOT(onKeyRelease(ModuleBase_IViewWindow*, QKeyEvent*))); @@ -570,6 +572,24 @@ void PartSet_Module::onEnterReleased() myRestartingMode = RM_EmptyFeatureUsed; } +void PartSet_Module::onOperationActivatedByPreselection() +{ + ModuleBase_Operation* aOperation = myWorkshop->currentOperation(); + if (!aOperation) + return; + + // Set final definitions if they are necessary + //propertyPanelDefined(aOperation); + + /// Commit sketcher operations automatically + FeaturePtr aFeature = aOperation->feature(); + std::shared_ptr aSPFeature = + std::dynamic_pointer_cast(aFeature); + if (aSPFeature) { + aOperation->commit(); + } +} + void PartSet_Module::onNoMoreWidgets() { ModuleBase_Operation* aOperation = myWorkshop->currentOperation(); diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index b2edc3205..129df5353 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -96,6 +96,10 @@ protected slots: /// Set a specific type of restarting the current operation void onEnterReleased(); + /// SLOT, that is called by the current operation filling with the preselection. + /// It commits the operation of it is can be committed + void onOperationActivatedByPreselection(); + /// Launches the operation from current highlighting void launchEditing(); diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 94e5026e2..4a5449caf 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -103,6 +103,8 @@ bool XGUI_OperationMgr::startOperation(ModuleBase_Operation* theOperation) connect(theOperation, SIGNAL(committed()), SLOT(onOperationComitted())); connect(theOperation, SIGNAL(stopped()), SLOT(onOperationStopped())); connect(theOperation, SIGNAL(resumed()), SLOT(onOperationResumed())); + connect(theOperation, SIGNAL(activatedByPreselection()), + SIGNAL(operationActivatedByPreselection())); theOperation->start(); onValidateOperation(); diff --git a/src/XGUI/XGUI_OperationMgr.h b/src/XGUI/XGUI_OperationMgr.h index 29a340b0d..8c8acfb3d 100644 --- a/src/XGUI/XGUI_OperationMgr.h +++ b/src/XGUI/XGUI_OperationMgr.h @@ -108,9 +108,13 @@ signals: /// Signal is emitted after the validate methods calls. void operationValidated(bool); + /// Signal is emitted after the current operation is filled with existing preselection. + void operationActivatedByPreselection(); + /// Signal is emitted after the key released click. void keyEnterReleased(); + protected: /// Commits the current operatin if it is valid diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index b77c27bbd..91041203f 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -593,8 +593,7 @@ void XGUI_Workshop::onOperationStarted() // Do not activate widgets by default if the current operation is editing operation // Because we don't know which widget is going to be edited. if ((!aOperation->isEditOperation())) { - if (!aOperation->activateByPreselection()) - myPropertyPanel->activateNextWidget(NULL); + aOperation->activateByPreselection(); } // Set final definitions if they are necessary myModule->propertyPanelDefined(aOperation); -- 2.39.2