From 5c26b7a3ba7bd14647a7c98228e93b348b96d014 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Sat, 21 Sep 2019 10:38:02 +0800 Subject: [PATCH] Gui: add toolbar button for toggling selection bounding box --- src/Gui/CommandView.cpp | 46 ++++++ src/Gui/Icons/resource.qrc | 2 + src/Gui/Icons/sel-bbox.svg | 283 +++++++++++++++++++++++++++++++++++++ src/Gui/Workbench.cpp | 5 +- 4 files changed, 334 insertions(+), 2 deletions(-) create mode 100644 src/Gui/Icons/sel-bbox.svg diff --git a/src/Gui/CommandView.cpp b/src/Gui/CommandView.cpp index 0c4eed990e..5610b97b0b 100644 --- a/src/Gui/CommandView.cpp +++ b/src/Gui/CommandView.cpp @@ -60,6 +60,7 @@ #include "SoAxisCrossKit.h" #include "View3DInventor.h" #include "View3DInventorViewer.h" +#include "ViewParams.h" #include "WaitCursor.h" #include "ViewProviderMeasureDistance.h" #include "ViewProviderGeometryObject.h" @@ -3445,6 +3446,50 @@ void StdCmdTreeViewActions::activated(int iMsg) } } +//====================================================================== +// Std_SelBoundingBox +//=========================================================================== +DEF_STD_CMD_AC(StdCmdSelBoundingBox); + +StdCmdSelBoundingBox::StdCmdSelBoundingBox() + :Command("Std_SelBoundingBox") +{ + sGroup = QT_TR_NOOP("View"); + sMenuText = QT_TR_NOOP("&Bounding box"); + sToolTipText = QT_TR_NOOP("Show selection bounding box"); + sWhatsThis = "Std_SelBack"; + sStatusTip = QT_TR_NOOP("Show selection bounding box"); + sPixmap = "sel-bbox"; + eType = Alter3DView; +} + +void StdCmdSelBoundingBox::activated(int iMsg) +{ + bool checked = !!iMsg; + if(checked != ViewParams::instance()->getShowSelectionBoundingBox()) { + ViewParams::instance()->setShowSelectionBoundingBox(checked); + if(_pcAction) + _pcAction->setChecked(checked,true); + } +} + +bool StdCmdSelBoundingBox::isActive(void) +{ + if(_pcAction) { + bool checked = _pcAction->isChecked(); + if(checked != ViewParams::instance()->getShowSelectionBoundingBox()) + _pcAction->setChecked(!checked,true); + } + return true; +} + +Action * StdCmdSelBoundingBox::createAction(void) +{ + Action *pcAction = Command::createAction(); + pcAction->setCheckable(true); + return pcAction; +} + //=========================================================================== // Instantiation //=========================================================================== @@ -3518,6 +3563,7 @@ void CreateViewStdCommands(void) rcCmdMgr.addCommand(new StdCmdAxisCross()); rcCmdMgr.addCommand(new CmdViewMeasureClearAll()); rcCmdMgr.addCommand(new CmdViewMeasureToggleAll()); + rcCmdMgr.addCommand(new StdCmdSelBoundingBox()); rcCmdMgr.addCommand(new StdCmdSelBack()); rcCmdMgr.addCommand(new StdCmdSelForward()); rcCmdMgr.addCommand(new StdCmdTreeViewActions()); diff --git a/src/Gui/Icons/resource.qrc b/src/Gui/Icons/resource.qrc index fe4fefdf81..5685b07c36 100644 --- a/src/Gui/Icons/resource.qrc +++ b/src/Gui/Icons/resource.qrc @@ -84,6 +84,7 @@ sel-back.svg sel-forward.svg sel-instance.svg + sel-bbox.svg help-browser.svg preferences-system.svg process-stop.svg @@ -241,6 +242,7 @@ sel-back.svg sel-forward.svg sel-instance.svg + sel-bbox.svg help-browser.svg preferences-system.svg window-new.svg diff --git a/src/Gui/Icons/sel-bbox.svg b/src/Gui/Icons/sel-bbox.svg new file mode 100644 index 0000000000..36859dc20d --- /dev/null +++ b/src/Gui/Icons/sel-bbox.svg @@ -0,0 +1,283 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Gui/Workbench.cpp b/src/Gui/Workbench.cpp index 2f837428c9..0faaddc3cf 100644 --- a/src/Gui/Workbench.cpp +++ b/src/Gui/Workbench.cpp @@ -578,7 +578,8 @@ MenuItem* StdWorkbench::setupMenuBar() const MenuItem* view = new MenuItem( menuBar ); view->setCommand("&View"); *view << "Std_ViewCreate" << "Std_OrthographicCamera" << "Std_PerspectiveCamera" << "Std_MainFullscreen" << "Separator" - << stdviews << "Std_FreezeViews" << "Std_DrawStyle" << "Separator" << view3d << zoom + << stdviews << "Std_FreezeViews" << "Std_DrawStyle" << "Std_SelBoundingBox" + << "Separator" << view3d << zoom << "Std_ViewDockUndockFullscreen" << "Std_AxisCross" << "Std_ToggleClipPlane" << "Std_TextureMapping" #ifdef BUILD_VR @@ -658,7 +659,7 @@ ToolBarItem* StdWorkbench::setupToolBars() const // View ToolBarItem* view = new ToolBarItem( root ); view->setCommand("View"); - *view << "Std_ViewFitAll" << "Std_ViewFitSelection" << "Std_DrawStyle" + *view << "Std_ViewFitAll" << "Std_ViewFitSelection" << "Std_DrawStyle" << "Std_SelBoundingBox" << "Separator" << "Std_TreeViewActions" << "Std_ViewIsometric" << "Separator" << "Std_ViewFront" << "Std_ViewTop" << "Std_ViewRight" << "Separator" << "Std_ViewRear" << "Std_ViewBottom" << "Std_ViewLeft" << "Separator" << "Std_MeasureDistance" ;