#include <XGUI_OperationMgr.h>
#include <XGUI_PropertyPanel.h>
#include <XGUI_ModuleConnector.h>
+#include <XGUI_ContextMenuMgr.h>
#include <XGUI_Tools.h>
#include <SketchPlugin_Feature.h>
XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
connect(anOpMgr, SIGNAL(keyEnterReleased()), this, SLOT(onEnterReleased()));
- connect(anOpMgr, SIGNAL(keyDeleteReleased()), this, SLOT(onDeleteObjects()));
connect(anOpMgr, SIGNAL(operationActivatedByPreselection()),
this, SLOT(onOperationActivatedByPreselection()));
hasFeature = true;
}
}
- if (hasFeature)
- theMenu->addAction(action("DELETE_PARTSET_CMD"));
+ if (hasFeature) {
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
+ XGUI_Workshop* aWorkshop = aConnector->workshop();
+ QAction* anAction = aWorkshop->contextMenuMgr()->action("DELETE_CMD");
+ theMenu->addAction(anAction);
+ }
+ }
+ bool isConstruction;
+ if (mySketchMgr->canChangeConstruction(isConstruction)) {
+ QAction* anAction = action("CONSTRUCTION_CMD");
+ theMenu->addAction(anAction);
+ anAction->setChecked(isConstruction);
}
}
myRestartingMode = RM_EmptyFeatureUsed;
}
-void PartSet_Module::onDeleteObjects()
-{
- ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
- if (PartSet_SketcherMgr::isSketchOperation(anOperation) ||
- PartSet_SketcherMgr::isNestedSketchOperation(anOperation))
- deleteObjects();
-}
-
void PartSet_Module::onOperationActivatedByPreselection()
{
ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
void PartSet_Module::createActions()
{
- QAction* aAction = new QAction(QIcon(":pictures/delete.png"), tr("Delete"), this);
- addAction("DELETE_PARTSET_CMD", aAction);
+ QAction* anAction;
+
+ anAction = new QAction(tr("Construction"), this);
+ anAction->setCheckable(true);
+ addAction("CONSTRUCTION_CMD", anAction);
}
QAction* PartSet_Module::action(const QString& theId) const
QAction* aAction = static_cast<QAction*>(sender());
QString anId = aAction->data().toString();
- if (anId == "DELETE_PARTSET_CMD") {
- deleteObjects();
+ if (anId == "CONSTRUCTION_CMD") {
+ mySketchMgr->setConstruction(isChecked);
}
}
-void PartSet_Module::deleteObjects()
+bool PartSet_Module::deleteObjects()
{
ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
- bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(anOperation);
- if (!isSketchOp && !PartSet_SketcherMgr::isNestedSketchOperation(anOperation))
- return;
+ bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(anOperation),
+ isNestedOp = PartSet_SketcherMgr::isNestedSketchOperation(anOperation);
+ if (!isSketchOp && !isNestedOp)
+ return false;
// sketch feature should be skipped, only sub-features can be removed
// when sketch operation is active
// selected objects should be collected before the current operation abort because
// the abort leads to selection lost on constraint objects. It can be corrected after #386 issue
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
+ XGUI_Workshop* aWorkshop = aConnector->workshop();
ModuleBase_ISelection* aSel = aConnector->selection();
QObjectPtrList aSelectedObj = aSel->selectedPresentations();
- XGUI_Workshop* aWorkshop = aConnector->workshop();
- XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
- if (!isSketchOp && anOpMgr->canStopOperation()) {
- ModuleBase_Operation* aCurrentOp = anOpMgr->currentOperation();
- if (aCurrentOp) {
- aCurrentOp->abort();
- }
- }
+ // if there are no selected objects in the viewer, that means that the selection in another
+ // place cased this method. It is necessary to return the false value to understande in above
+ // method that delete is not processed
+ if (aSelectedObj.count() == 0)
+ return false;
+
+ if (isNestedOp)
+ anOperation->abort();
+
+ // the active nested sketch operation should be aborted unconditionally
+ if (PartSet_SketcherMgr::isNestedSketchOperation(anOperation))
+ anOperation->abort();
+
std::set<FeaturePtr> aRefFeatures;
foreach (ObjectPtr aObj, aSelectedObj)
{
}
//}
}
- QString aDescription = tr("Delete");
+
+ QString aDescription = aWorkshop->contextMenuMgr()->action("DELETE_CMD")->text();
/**
// according to #355 feature, it is not necessary to inform about dependencies during
// sketch delete operation
aWorkshop->displayer()->updateViewer();
//myDisplayer->updateViewer();
aMgr->finishOperation();
+
+ return true;
}