Skip to content

Commit

Permalink
Sketcher: [skip ci] explicit command to stop current operation
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Feb 6, 2020
1 parent 78039eb commit e0f1079
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/Mod/Sketcher/Gui/Command.cpp
Expand Up @@ -328,6 +328,45 @@ bool CmdSketcherLeaveSketch::isActive(void)
return false;
}

DEF_STD_CMD_A(CmdSketcherStopOperation)

CmdSketcherStopOperation::CmdSketcherStopOperation()
: Command("Sketcher_StopOperation")
{
sAppModule = "Sketcher";
sGroup = QT_TR_NOOP("Sketcher");
sMenuText = QT_TR_NOOP("Stop operation");
sToolTipText = QT_TR_NOOP("Stop current operation");
sWhatsThis = "Sketcher_StopOperation";
sStatusTip = sToolTipText;
sPixmap = "process-stop";
eType = 0;
}

void CmdSketcherStopOperation::activated(int iMsg)
{
Q_UNUSED(iMsg);
Gui::Document *doc = getActiveGuiDocument();

if (doc) {
SketcherGui::ViewProviderSketch* vp = dynamic_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
if (vp) {
vp->purgeHandler();
}
}
}

bool CmdSketcherStopOperation::isActive(void)
{
Gui::Document *doc = getActiveGuiDocument();
if (doc) {
SketcherGui::ViewProviderSketch* vp = dynamic_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
if (vp)
return true;
}
return false;
}

DEF_STD_CMD_A(CmdSketcherReorientSketch)

CmdSketcherReorientSketch::CmdSketcherReorientSketch()
Expand Down Expand Up @@ -872,6 +911,7 @@ void CreateSketcherCommands(void)
rcCmdMgr.addCommand(new CmdSketcherNewSketch());
rcCmdMgr.addCommand(new CmdSketcherEditSketch());
rcCmdMgr.addCommand(new CmdSketcherLeaveSketch());
rcCmdMgr.addCommand(new CmdSketcherStopOperation());
rcCmdMgr.addCommand(new CmdSketcherReorientSketch());
rcCmdMgr.addCommand(new CmdSketcherMapSketch());
rcCmdMgr.addCommand(new CmdSketcherViewSketch());
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Sketcher/Gui/ViewProviderSketch.cpp
Expand Up @@ -401,6 +401,7 @@ void ViewProviderSketch::deactivateHandler()
std::vector<Base::Vector2d> editCurve;
editCurve.clear();
drawEdit(editCurve); // erase any line
resetPositionText();
edit->sketchHandler->deactivated(this);
edit->sketchHandler->unsetCursor();
delete(edit->sketchHandler);
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Sketcher/Gui/Workbench.cpp
Expand Up @@ -90,6 +90,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
addSketcherWorkbenchVirtualSpace(*virtualspace);

addSketcherWorkbenchSketchActions( *sketch );
*sketch << "Sketcher_StopOperation";
*sketch << geom
<< cons
<< consaccel
Expand Down

0 comments on commit e0f1079

Please sign in to comment.