#include <ModuleBase_ISelection.h>
#include <ModuleBase_Operation.h>
+#include <ModuleBase_OperationAction.h>
+#include <ModuleBase_OperationFeature.h>
#include <XGUI_ModuleConnector.h>
#include <XGUI_Workshop.h>
#include <XGUI_Displayer.h>
#include <XGUI_DataModel.h>
#include <XGUI_ObjectsBrowser.h>
+#include <XGUI_OperationMgr.h>
#include <Events_Loop.h>
#include <ModelAPI_Events.h>
connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onActivatePart(bool)));
myActions["ACTIVATE_PART_CMD"] = aAction;
- aAction = new QAction(QIcon(":icons/deactivate.png"), tr("Deactivate"), this);
- connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onActivatePartSet(bool)));
- myActions["DEACTIVATE_PART_CMD"] = aAction;
-
// Activate PartSet
aAction = new QAction(QIcon(":icons/activate.png"), tr("Activate"), this);
connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onActivatePartSet(bool)));
} else {
aPnt = PartSet_Tools::getPoint(aConstrFeature,
SketchPlugin_ConstraintCoincidence::ENTITY_B());
+ if (aPnt.get() == NULL)
+ return;
aP = aPnt->impl<gp_Pnt>();
if (aOrig->isEqual(aPnt)) {
aToDelFeatures.append(aConstrFeature);
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
XGUI_Workshop* aWorkshop = aConnector->workshop();
ModuleBase_Operation* anOperation = myModule->workshop()->currentOperation();
- if (PartSet_SketcherMgr::isNestedSketchOperation(anOperation))
- anOperation->abort();
- SessionPtr aMgr = ModelAPI_Session::get();
-
- QString aName = tr("Detach %1").arg(aLine->data()->name().c_str());
- aMgr->startOperation(aName.toStdString());
+ ModuleBase_OperationAction* anOpAction = new ModuleBase_OperationAction(
+ tr("Detach %1").arg(aLine->data()->name().c_str()), myModule);
+ bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(anOperation);
+ XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
+ // the active nested sketch operation should be aborted unconditionally
+ // the Delete action should be additionally granted for the Sketch operation
+ // in order to do not abort/commit it
+ if (!anOpMgr->canStartOperation(anOpAction->id(), isSketchOp/*granted*/))
+ return; // the objects are processed but can not be deleted
+
+ anOpMgr->startOperation(anOpAction);
aWorkshop->deleteFeatures(aToDelFeatures);
- aMgr->finishOperation();
+
+ anOpMgr->commitOperation();
}
myCoinsideLines.clear();
}
bool isUseTransaction = false;
// 1. change auxiliary type of a created feature
if (PartSet_SketcherMgr::isNestedCreateOperation(anOperation) &&
- PartSet_SketcherMgr::isEntity(anOperation->id().toStdString()) ) {
- anObjects.append(anOperation->feature());
+ PartSet_SketcherMgr::isEntity(anOperation->id().toStdString()) ) {
+ ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+ (anOperation);
+ if (aFOperation)
+ anObjects.append(aFOperation->feature());
}
else {
isUseTransaction = true;
}
QAction* anAction = action("AUXILIARY_CMD");
- SessionPtr aMgr = ModelAPI_Session::get();
+ //SessionPtr aMgr = ModelAPI_Session::get();
+ ModuleBase_OperationAction* anOpAction = 0;
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
+ XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
if (isUseTransaction) {
- if (PartSet_SketcherMgr::isNestedSketchOperation(anOperation))
- anOperation->abort();
- aMgr->startOperation(anAction->text().toStdString());
+ anOpAction = new ModuleBase_OperationAction(anAction->text(), myModule);
+ bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(anOperation);
+
+ if (!anOpMgr->canStartOperation(anOpAction->id(), isSketchOp/*granted*/))
+ return; // the objects are processed but can not be deleted
+
+ anOpMgr->startOperation(anOpAction);
}
myModule->sketchMgr()->storeSelection();
}
}
}
- if (isUseTransaction) {
- aMgr->finishOperation();
- XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
- XGUI_Workshop* aWorkshop = aConnector->workshop();
- aWorkshop->updateCommandStatus();
- }
+ if (isUseTransaction)
+ anOpMgr->commitOperation();
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
myModule->sketchMgr()->restoreSelection();
// 1. change auxiliary type of a created feature
if (PartSet_SketcherMgr::isNestedCreateOperation(anOperation) &&
PartSet_SketcherMgr::isEntity(anOperation->id().toStdString()) ) {
- anObjects.append(anOperation->feature());
+ ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(anOperation);
+ if (aFOperation)
+ anObjects.append(aFOperation->feature());
}
else {
/// The operation should not be aborted here, because the method does not changed