connect(theOperation, SIGNAL(committed()), SLOT(onOperationCommitted()));
connect(theOperation, SIGNAL(stopped()), SLOT(onOperationStopped()));
connect(theOperation, SIGNAL(resumed()), SLOT(onOperationResumed()));
+ connect(theOperation, SIGNAL(triggered(bool)), SLOT(onOperationTriggered(bool)));
connect(theOperation, SIGNAL(activatedByPreselection()),
SIGNAL(operationActivatedByPreselection()));
return result;
}
+bool XGUI_OperationMgr::commitAllOperations()
+{
+ while (hasOperation()) {
+ if (isApplyEnabled()) {
+ onCommitOperation();
+ } else {
+ currentOperation()->abort();
+ }
+ }
+ return true;
+}
+
void XGUI_OperationMgr::onValidateOperation()
{
if (!hasOperation())
void XGUI_OperationMgr::setApplyEnabled(const bool theEnabled)
{
myIsApplyEnabled = theEnabled;
- emit applyEnableChanged(theEnabled);
+ emit validationStateChanged(theEnabled);
}
bool XGUI_OperationMgr::isApplyEnabled() const
void XGUI_OperationMgr::onOperationStarted()
{
ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
+
+ bool isNestedOk = (myOperations.count() >= 1) &&
+ myOperations.at(0)->isValid();
+ emit nestedStateChanged(isNestedOk);
emit operationStarted(aSenderOperation);
}
void XGUI_OperationMgr::onOperationCommitted()
{
ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
+ emit nestedStateChanged(myOperations.count() >= 1);
emit operationCommitted(aSenderOperation);
}
}
}
+void XGUI_OperationMgr::onOperationTriggered(bool theState)
+{
+ ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
+ if (aSenderOperation && !theState) {
+ ModuleBase_Operation* aCurrentOperation = currentOperation();
+ if (aSenderOperation == aCurrentOperation)
+ aCurrentOperation->abort();
+ else {
+ // it is possible to trigger upper operation(e.g. sketch, current is sketch line)
+ // all operation from the current to triggered should also be aborted
+ while(hasOperation()) {
+ ModuleBase_Operation* aCurrentOperation = currentOperation();
+ aCurrentOperation->abort();
+ if(aSenderOperation == aCurrentOperation)
+ break;
+ }
+ }
+ }
+}
+
bool XGUI_OperationMgr::onKeyReleased(QKeyEvent* theEvent)
{
// Let the manager decide what to do with the given key combination.
emit keyEnterReleased();
commitOperation();
}
- break;
+ break;
default:
isAccepted = false;
break;