From 159f82af459834d7a6226afed56265c9fa758589 Mon Sep 17 00:00:00 2001 From: Florian Foinant-Willig Date: Wed, 31 May 2023 22:34:03 +0200 Subject: [PATCH 1/4] Sketcher: Add command to switch arc helper --- src/Mod/Sketcher/Gui/AppSketcherGui.cpp | 2 + src/Mod/Sketcher/Gui/CMakeLists.txt | 1 + .../Sketcher/Gui/CommandSketcherBSpline.cpp | 321 --------------- .../Sketcher/Gui/CommandSketcherOverlay.cpp | 389 ++++++++++++++++++ src/Mod/Sketcher/Gui/Utils.cpp | 20 + src/Mod/Sketcher/Gui/Utils.h | 3 + src/Mod/Sketcher/Gui/Workbench.cpp | 11 +- 7 files changed, 422 insertions(+), 325 deletions(-) create mode 100644 src/Mod/Sketcher/Gui/CommandSketcherOverlay.cpp diff --git a/src/Mod/Sketcher/Gui/AppSketcherGui.cpp b/src/Mod/Sketcher/Gui/AppSketcherGui.cpp index eb389779bd..b53b551e91 100644 --- a/src/Mod/Sketcher/Gui/AppSketcherGui.cpp +++ b/src/Mod/Sketcher/Gui/AppSketcherGui.cpp @@ -47,6 +47,7 @@ void CreateSketcherCommandsConstraints(); void CreateSketcherCommandsConstraintAccel(); void CreateSketcherCommandsAlterGeo(); void CreateSketcherCommandsBSpline(); +void CreateSketcherCommandsOverlay(); void CreateSketcherCommandsVirtualSpace(); void loadSketcherResource() @@ -116,6 +117,7 @@ PyMOD_INIT_FUNC(SketcherGui) CreateSketcherCommandsAlterGeo(); CreateSketcherCommandsConstraintAccel(); CreateSketcherCommandsBSpline(); + CreateSketcherCommandsOverlay(); CreateSketcherCommandsVirtualSpace(); SketcherGui::Workbench::init(); diff --git a/src/Mod/Sketcher/Gui/CMakeLists.txt b/src/Mod/Sketcher/Gui/CMakeLists.txt index d669e70f06..08772bda5a 100644 --- a/src/Mod/Sketcher/Gui/CMakeLists.txt +++ b/src/Mod/Sketcher/Gui/CMakeLists.txt @@ -84,6 +84,7 @@ SET(SketcherGui_SRCS CommandConstraints.cpp CommandSketcherTools.cpp CommandSketcherBSpline.cpp + CommandSketcherOverlay.cpp CommandSketcherVirtualSpace.cpp CommandAlterGeometry.cpp Resources/Sketcher.qrc diff --git a/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp b/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp index 57a3a61caf..50fd6eb2a4 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp @@ -49,26 +49,6 @@ using namespace std; using namespace SketcherGui; using namespace Sketcher; -bool isSketcherBSplineActive(Gui::Document* doc, bool actsOnSelection) -{ - if (doc) { - // checks if a Sketch Viewprovider is in Edit and is in no special mode - if (doc->getInEdit() - && doc->getInEdit()->isDerivedFrom(SketcherGui::ViewProviderSketch::getClassTypeId())) { - if (static_cast(doc->getInEdit())->getSketchMode() - == ViewProviderSketch::STATUS_NONE) { - if (!actsOnSelection) - return true; - else if (Gui::Selection().countObjectsOfType( - Sketcher::SketchObject::getClassTypeId()) - > 0) - return true; - } - } - } - return false; -} - void ActivateBSplineHandler(Gui::Document* doc, DrawSketchHandler* handler) { std::unique_ptr ptr(handler); @@ -83,14 +63,6 @@ void ActivateBSplineHandler(Gui::Document* doc, DrawSketchHandler* handler) } } -void ShowRestoreInformationLayer(const char* visibleelementname) -{ - ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath( - "User parameter:BaseApp/Preferences/Mod/Sketcher/General"); - bool status = hGrp->GetBool(visibleelementname, true); - hGrp->SetBool(visibleelementname, !status); -} - /// For a knot given by (GeoId, PosId) finds the B-Spline and the knot's /// index within it (by OCC numbering). /// Returns true if the entities are found, false otherwise. @@ -129,293 +101,6 @@ bool findBSplineAndKnotIndex(Sketcher::SketchObject* Obj, int knotGeoId, return false; } -// Show/Hide B-spline degree -DEF_STD_CMD_A(CmdSketcherBSplineDegree) - -CmdSketcherBSplineDegree::CmdSketcherBSplineDegree() - : Command("Sketcher_BSplineDegree") -{ - sAppModule = "Sketcher"; - sGroup = "Sketcher"; - sMenuText = QT_TR_NOOP("Show/hide B-spline degree"); - sToolTipText = QT_TR_NOOP("Switches between showing and hiding the degree for all B-splines"); - sWhatsThis = "Sketcher_BSplineDegree"; - sStatusTip = sToolTipText; - sPixmap = "Sketcher_BSplineDegree"; - sAccel = ""; - eType = ForEdit; -} - -void CmdSketcherBSplineDegree::activated(int iMsg) -{ - Q_UNUSED(iMsg); - - ShowRestoreInformationLayer("BSplineDegreeVisible"); -} - -bool CmdSketcherBSplineDegree::isActive() -{ - return isSketcherBSplineActive(getActiveGuiDocument(), false); -} - -// Show/Hide B-spline polygon -DEF_STD_CMD_A(CmdSketcherBSplinePolygon) - -CmdSketcherBSplinePolygon::CmdSketcherBSplinePolygon() - : Command("Sketcher_BSplinePolygon") -{ - sAppModule = "Sketcher"; - sGroup = "Sketcher"; - sMenuText = QT_TR_NOOP("Show/hide B-spline control polygon"); - sToolTipText = - QT_TR_NOOP("Switches between showing and hiding the control polygons for all B-splines"); - sWhatsThis = "Sketcher_BSplinePolygon"; - sStatusTip = sToolTipText; - sPixmap = "Sketcher_BSplinePolygon"; - sAccel = ""; - eType = ForEdit; -} - -void CmdSketcherBSplinePolygon::activated(int iMsg) -{ - Q_UNUSED(iMsg); - - ShowRestoreInformationLayer("BSplineControlPolygonVisible"); -} - -bool CmdSketcherBSplinePolygon::isActive() -{ - return isSketcherBSplineActive(getActiveGuiDocument(), false); -} - -// Show/Hide B-spline comb -DEF_STD_CMD_A(CmdSketcherBSplineComb) - -CmdSketcherBSplineComb::CmdSketcherBSplineComb() - : Command("Sketcher_BSplineComb") -{ - sAppModule = "Sketcher"; - sGroup = "Sketcher"; - sMenuText = QT_TR_NOOP("Show/hide B-spline curvature comb"); - sToolTipText = - QT_TR_NOOP("Switches between showing and hiding the curvature comb for all B-splines"); - sWhatsThis = "Sketcher_BSplineComb"; - sStatusTip = sToolTipText; - sPixmap = "Sketcher_BSplineComb"; - sAccel = ""; - eType = ForEdit; -} - -void CmdSketcherBSplineComb::activated(int iMsg) -{ - Q_UNUSED(iMsg); - - ShowRestoreInformationLayer("BSplineCombVisible"); -} - -bool CmdSketcherBSplineComb::isActive() -{ - return isSketcherBSplineActive(getActiveGuiDocument(), false); -} - -// -DEF_STD_CMD_A(CmdSketcherBSplineKnotMultiplicity) - -CmdSketcherBSplineKnotMultiplicity::CmdSketcherBSplineKnotMultiplicity() - : Command("Sketcher_BSplineKnotMultiplicity") -{ - sAppModule = "Sketcher"; - sGroup = "Sketcher"; - sMenuText = QT_TR_NOOP("Show/hide B-spline knot multiplicity"); - sToolTipText = - QT_TR_NOOP("Switches between showing and hiding the knot multiplicity for all B-splines"); - sWhatsThis = "Sketcher_BSplineKnotMultiplicity"; - sStatusTip = sToolTipText; - sPixmap = "Sketcher_BSplineKnotMultiplicity"; - sAccel = ""; - eType = ForEdit; -} - -void CmdSketcherBSplineKnotMultiplicity::activated(int iMsg) -{ - Q_UNUSED(iMsg); - - ShowRestoreInformationLayer("BSplineKnotMultiplicityVisible"); -} - -bool CmdSketcherBSplineKnotMultiplicity::isActive() -{ - return isSketcherBSplineActive(getActiveGuiDocument(), false); -} - -// -DEF_STD_CMD_A(CmdSketcherBSplinePoleWeight) - -CmdSketcherBSplinePoleWeight::CmdSketcherBSplinePoleWeight() - : Command("Sketcher_BSplinePoleWeight") -{ - sAppModule = "Sketcher"; - sGroup = "Sketcher"; - sMenuText = QT_TR_NOOP("Show/hide B-spline control point weight"); - sToolTipText = QT_TR_NOOP( - "Switches between showing and hiding the control point weight for all B-splines"); - sWhatsThis = "Sketcher_BSplinePoleWeight"; - sStatusTip = sToolTipText; - sPixmap = "Sketcher_BSplinePoleWeight"; - sAccel = ""; - eType = ForEdit; -} - -void CmdSketcherBSplinePoleWeight::activated(int iMsg) -{ - Q_UNUSED(iMsg); - - ShowRestoreInformationLayer("BSplinePoleWeightVisible"); -} - -bool CmdSketcherBSplinePoleWeight::isActive() -{ - return isSketcherBSplineActive(getActiveGuiDocument(), false); -} - -// Composite drop down menu for show/hide geometry information layer -DEF_STD_CMD_ACLU(CmdSketcherCompBSplineShowHideGeometryInformation) - -CmdSketcherCompBSplineShowHideGeometryInformation:: - CmdSketcherCompBSplineShowHideGeometryInformation() - : Command("Sketcher_CompBSplineShowHideGeometryInformation") -{ - sAppModule = "Sketcher"; - sGroup = "Sketcher"; - sMenuText = QT_TR_NOOP("Show/hide B-spline information layer"); - sToolTipText = sMenuText; - sWhatsThis = "Sketcher_CompBSplineShowHideGeometryInformation"; - sStatusTip = sToolTipText; - eType = ForEdit; -} - -void CmdSketcherCompBSplineShowHideGeometryInformation::activated(int iMsg) -{ - Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager(); - Gui::Command* cmd; - - if (iMsg == 0) - cmd = rcCmdMgr.getCommandByName("Sketcher_BSplineDegree"); - else if (iMsg == 1) - cmd = rcCmdMgr.getCommandByName("Sketcher_BSplinePolygon"); - else if (iMsg == 2) - cmd = rcCmdMgr.getCommandByName("Sketcher_BSplineComb"); - else if (iMsg == 3) - cmd = rcCmdMgr.getCommandByName("Sketcher_BSplineKnotMultiplicity"); - else if (iMsg == 4) - cmd = rcCmdMgr.getCommandByName("Sketcher_BSplinePoleWeight"); - else - return; - - cmd->invoke(0); - - // Since the default icon is reset when enabling/disabling the command we have - // to explicitly set the icon of the used command. - Gui::ActionGroup* pcAction = qobject_cast(_pcAction); - QList a = pcAction->actions(); - - assert(iMsg < a.size()); - pcAction->setIcon(a[iMsg]->icon()); - // we must also set the tooltip of the used command - pcAction->setToolTip(a[iMsg]->toolTip()); -} - -Gui::Action* CmdSketcherCompBSplineShowHideGeometryInformation::createAction() -{ - Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); - pcAction->setDropDownMenu(true); - applyCommandData(this->className(), pcAction); - - QAction* c1 = pcAction->addAction(QString()); - c1->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_BSplineDegree")); - QAction* c2 = pcAction->addAction(QString()); - c2->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_BSplinePolygon")); - QAction* c3 = pcAction->addAction(QString()); - c3->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_BSplineComb")); - QAction* c4 = pcAction->addAction(QString()); - c4->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_BSplineKnotMultiplicity")); - QAction* c5 = pcAction->addAction(QString()); - c5->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_BSplinePoleWeight")); - - _pcAction = pcAction; - languageChange(); - - pcAction->setIcon(c2->icon()); - int defaultId = 1; - pcAction->setProperty("defaultAction", QVariant(defaultId)); - - return pcAction; -} - -void CmdSketcherCompBSplineShowHideGeometryInformation::languageChange() -{ - Command::languageChange(); - - if (!_pcAction) - return; - Gui::ActionGroup* pcAction = qobject_cast(_pcAction); - QList a = pcAction->actions(); - - QAction* c1 = a[0]; - c1->setText(QApplication::translate("CmdSketcherCompBSplineShowHideGeometryInformation", - "Show/hide B-spline degree")); - c1->setToolTip(QApplication::translate( - "Sketcher_BSplineDegree", - "Switches between showing and hiding the degree for all B-splines")); - c1->setStatusTip(QApplication::translate( - "Sketcher_BSplineDegree", - "Switches between showing and hiding the degree for all B-splines")); - QAction* c2 = a[1]; - c2->setText(QApplication::translate("CmdSketcherCompBSplineShowHideGeometryInformation", - "Show/hide B-spline control polygon")); - c2->setToolTip(QApplication::translate( - "Sketcher_BSplinePolygon", - "Switches between showing and hiding the control polygons for all B-splines")); - c2->setStatusTip(QApplication::translate( - "Sketcher_BSplinePolygon", - "Switches between showing and hiding the control polygons for all B-splines")); - QAction* c3 = a[2]; - c3->setText(QApplication::translate("CmdSketcherCompBSplineShowHideGeometryInformation", - "Show/hide B-spline curvature comb")); - c3->setToolTip(QApplication::translate( - "Sketcher_BSplineComb", - "Switches between showing and hiding the curvature comb for all B-splines")); - c3->setStatusTip(QApplication::translate( - "Sketcher_BSplineComb", - "Switches between showing and hiding the curvature comb for all B-splines")); - QAction* c4 = a[3]; - c4->setText(QApplication::translate("CmdSketcherCompBSplineShowHideGeometryInformation", - "Show/hide B-spline knot multiplicity")); - c4->setToolTip(QApplication::translate( - "Sketcher_BSplineKnotMultiplicity", - "Switches between showing and hiding the knot multiplicity for all B-splines")); - c4->setStatusTip(QApplication::translate( - "Sketcher_BSplineKnotMultiplicity", - "Switches between showing and hiding the knot multiplicity for all B-splines")); - - QAction* c5 = a[4]; - c5->setText(QApplication::translate("CmdSketcherCompBSplineShowHideGeometryInformation", - "Show/hide B-spline control point weight")); - c5->setToolTip(QApplication::translate( - "Sketcher_BSplinePoleWeight", - "Switches between showing and hiding the control point weight for all B-splines")); - c5->setStatusTip(QApplication::translate( - "Sketcher_BSplinePoleWeight", - "Switches between showing and hiding the control point weight for all B-splines")); -} - -void CmdSketcherCompBSplineShowHideGeometryInformation::updateAction(int /*mode*/) -{} - -bool CmdSketcherCompBSplineShowHideGeometryInformation::isActive() -{ - return isSketcherBSplineActive(getActiveGuiDocument(), false); -} // Convert to NURBS DEF_STD_CMD_A(CmdSketcherConvertToNURBS) @@ -1385,12 +1070,6 @@ void CreateSketcherCommandsBSpline() { Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager(); - rcCmdMgr.addCommand(new CmdSketcherBSplineDegree()); - rcCmdMgr.addCommand(new CmdSketcherBSplinePolygon()); - rcCmdMgr.addCommand(new CmdSketcherBSplineComb()); - rcCmdMgr.addCommand(new CmdSketcherBSplineKnotMultiplicity()); - rcCmdMgr.addCommand(new CmdSketcherBSplinePoleWeight()); - rcCmdMgr.addCommand(new CmdSketcherCompBSplineShowHideGeometryInformation()); rcCmdMgr.addCommand(new CmdSketcherConvertToNURBS()); rcCmdMgr.addCommand(new CmdSketcherIncreaseDegree()); rcCmdMgr.addCommand(new CmdSketcherDecreaseDegree()); diff --git a/src/Mod/Sketcher/Gui/CommandSketcherOverlay.cpp b/src/Mod/Sketcher/Gui/CommandSketcherOverlay.cpp new file mode 100644 index 0000000000..5f2f90f6c6 --- /dev/null +++ b/src/Mod/Sketcher/Gui/CommandSketcherOverlay.cpp @@ -0,0 +1,389 @@ +/*************************************************************************** + * Copyright (c) 2023 Florian Foinant-Willig * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + +#include "PreCompiled.h" +#ifndef _PreComp_ +#include +#include +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "DrawSketchHandler.h" +#include "Utils.h" +#include "ViewProviderSketch.h" + +using namespace std; +using namespace SketcherGui; +using namespace Sketcher; + + +void ShowRestoreInformationLayer(const char* visibleelementname) +{ + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/Mod/Sketcher/General"); + bool status = hGrp->GetBool(visibleelementname, true); + hGrp->SetBool(visibleelementname, !status); +} + +// Show/Hide B-spline degree +DEF_STD_CMD_A(CmdSketcherBSplineDegree) + +CmdSketcherBSplineDegree::CmdSketcherBSplineDegree() + : Command("Sketcher_BSplineDegree") +{ + sAppModule = "Sketcher"; + sGroup = "Sketcher"; + sMenuText = QT_TR_NOOP("Show/hide B-spline degree"); + sToolTipText = QT_TR_NOOP("Switches between showing and hiding the degree for all B-splines"); + sWhatsThis = "Sketcher_BSplineDegree"; + sStatusTip = sToolTipText; + sPixmap = "Sketcher_BSplineDegree"; + sAccel = ""; + eType = ForEdit; +} + +void CmdSketcherBSplineDegree::activated(int iMsg) +{ + Q_UNUSED(iMsg); + + ShowRestoreInformationLayer("BSplineDegreeVisible"); +} + +bool CmdSketcherBSplineDegree::isActive() +{ + return isSketcherBSplineActive(getActiveGuiDocument(), false); +} + +// Show/Hide B-spline polygon +DEF_STD_CMD_A(CmdSketcherBSplinePolygon) + +CmdSketcherBSplinePolygon::CmdSketcherBSplinePolygon() + : Command("Sketcher_BSplinePolygon") +{ + sAppModule = "Sketcher"; + sGroup = "Sketcher"; + sMenuText = QT_TR_NOOP("Show/hide B-spline control polygon"); + sToolTipText = + QT_TR_NOOP("Switches between showing and hiding the control polygons for all B-splines"); + sWhatsThis = "Sketcher_BSplinePolygon"; + sStatusTip = sToolTipText; + sPixmap = "Sketcher_BSplinePolygon"; + sAccel = ""; + eType = ForEdit; +} + +void CmdSketcherBSplinePolygon::activated(int iMsg) +{ + Q_UNUSED(iMsg); + + ShowRestoreInformationLayer("BSplineControlPolygonVisible"); +} + +bool CmdSketcherBSplinePolygon::isActive() +{ + return isSketcherBSplineActive(getActiveGuiDocument(), false); +} + +// Show/Hide B-spline comb +DEF_STD_CMD_A(CmdSketcherBSplineComb) + +CmdSketcherBSplineComb::CmdSketcherBSplineComb() + : Command("Sketcher_BSplineComb") +{ + sAppModule = "Sketcher"; + sGroup = "Sketcher"; + sMenuText = QT_TR_NOOP("Show/hide B-spline curvature comb"); + sToolTipText = + QT_TR_NOOP("Switches between showing and hiding the curvature comb for all B-splines"); + sWhatsThis = "Sketcher_BSplineComb"; + sStatusTip = sToolTipText; + sPixmap = "Sketcher_BSplineComb"; + sAccel = ""; + eType = ForEdit; +} + +void CmdSketcherBSplineComb::activated(int iMsg) +{ + Q_UNUSED(iMsg); + + ShowRestoreInformationLayer("BSplineCombVisible"); +} + +bool CmdSketcherBSplineComb::isActive() +{ + return isSketcherBSplineActive(getActiveGuiDocument(), false); +} + +// +DEF_STD_CMD_A(CmdSketcherBSplineKnotMultiplicity) + +CmdSketcherBSplineKnotMultiplicity::CmdSketcherBSplineKnotMultiplicity() + : Command("Sketcher_BSplineKnotMultiplicity") +{ + sAppModule = "Sketcher"; + sGroup = "Sketcher"; + sMenuText = QT_TR_NOOP("Show/hide B-spline knot multiplicity"); + sToolTipText = + QT_TR_NOOP("Switches between showing and hiding the knot multiplicity for all B-splines"); + sWhatsThis = "Sketcher_BSplineKnotMultiplicity"; + sStatusTip = sToolTipText; + sPixmap = "Sketcher_BSplineKnotMultiplicity"; + sAccel = ""; + eType = ForEdit; +} + +void CmdSketcherBSplineKnotMultiplicity::activated(int iMsg) +{ + Q_UNUSED(iMsg); + + ShowRestoreInformationLayer("BSplineKnotMultiplicityVisible"); +} + +bool CmdSketcherBSplineKnotMultiplicity::isActive() +{ + return isSketcherBSplineActive(getActiveGuiDocument(), false); +} + +// +DEF_STD_CMD_A(CmdSketcherBSplinePoleWeight) + +CmdSketcherBSplinePoleWeight::CmdSketcherBSplinePoleWeight() + : Command("Sketcher_BSplinePoleWeight") +{ + sAppModule = "Sketcher"; + sGroup = "Sketcher"; + sMenuText = QT_TR_NOOP("Show/hide B-spline control point weight"); + sToolTipText = QT_TR_NOOP( + "Switches between showing and hiding the control point weight for all B-splines"); + sWhatsThis = "Sketcher_BSplinePoleWeight"; + sStatusTip = sToolTipText; + sPixmap = "Sketcher_BSplinePoleWeight"; + sAccel = ""; + eType = ForEdit; +} + +void CmdSketcherBSplinePoleWeight::activated(int iMsg) +{ + Q_UNUSED(iMsg); + + ShowRestoreInformationLayer("BSplinePoleWeightVisible"); +} + +bool CmdSketcherBSplinePoleWeight::isActive() +{ + return isSketcherBSplineActive(getActiveGuiDocument(), false); +} + +// Composite drop down menu for show/hide BSpline information layer +DEF_STD_CMD_ACLU(CmdSketcherCompBSplineShowHideGeometryInformation) + +CmdSketcherCompBSplineShowHideGeometryInformation:: + CmdSketcherCompBSplineShowHideGeometryInformation() + : Command("Sketcher_CompBSplineShowHideGeometryInformation") +{ + sAppModule = "Sketcher"; + sGroup = "Sketcher"; + sMenuText = QT_TR_NOOP("Show/hide B-spline information layer"); + sToolTipText = sMenuText; + sWhatsThis = "Sketcher_CompBSplineShowHideGeometryInformation"; + sStatusTip = sToolTipText; + eType = ForEdit; +} + +void CmdSketcherCompBSplineShowHideGeometryInformation::activated(int iMsg) +{ + Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager(); + Gui::Command* cmd; + + if (iMsg == 0) + cmd = rcCmdMgr.getCommandByName("Sketcher_BSplineDegree"); + else if (iMsg == 1) + cmd = rcCmdMgr.getCommandByName("Sketcher_BSplinePolygon"); + else if (iMsg == 2) + cmd = rcCmdMgr.getCommandByName("Sketcher_BSplineComb"); + else if (iMsg == 3) + cmd = rcCmdMgr.getCommandByName("Sketcher_BSplineKnotMultiplicity"); + else if (iMsg == 4) + cmd = rcCmdMgr.getCommandByName("Sketcher_BSplinePoleWeight"); + else + return; + + cmd->invoke(0); + + // Since the default icon is reset when enabling/disabling the command we have + // to explicitly set the icon of the used command. + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + QList a = pcAction->actions(); + + assert(iMsg < a.size()); + pcAction->setIcon(a[iMsg]->icon()); + // we must also set the tooltip of the used command + pcAction->setToolTip(a[iMsg]->toolTip()); +} + +Gui::Action* CmdSketcherCompBSplineShowHideGeometryInformation::createAction() +{ + Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); + pcAction->setDropDownMenu(true); + applyCommandData(this->className(), pcAction); + + QAction* c1 = pcAction->addAction(QString()); + c1->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_BSplineDegree")); + QAction* c2 = pcAction->addAction(QString()); + c2->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_BSplinePolygon")); + QAction* c3 = pcAction->addAction(QString()); + c3->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_BSplineComb")); + QAction* c4 = pcAction->addAction(QString()); + c4->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_BSplineKnotMultiplicity")); + QAction* c5 = pcAction->addAction(QString()); + c5->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_BSplinePoleWeight")); + + _pcAction = pcAction; + languageChange(); + + pcAction->setIcon(c2->icon()); + int defaultId = 1; + pcAction->setProperty("defaultAction", QVariant(defaultId)); + + return pcAction; +} + +void CmdSketcherCompBSplineShowHideGeometryInformation::languageChange() +{ + Command::languageChange(); + + if (!_pcAction) + return; + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + QList a = pcAction->actions(); + + QAction* c1 = a[0]; + c1->setText(QApplication::translate("CmdSketcherCompBSplineShowHideGeometryInformation", + "Show/hide B-spline degree")); + c1->setToolTip(QApplication::translate( + "Sketcher_BSplineDegree", + "Switches between showing and hiding the degree for all B-splines")); + c1->setStatusTip(QApplication::translate( + "Sketcher_BSplineDegree", + "Switches between showing and hiding the degree for all B-splines")); + QAction* c2 = a[1]; + c2->setText(QApplication::translate("CmdSketcherCompBSplineShowHideGeometryInformation", + "Show/hide B-spline control polygon")); + c2->setToolTip(QApplication::translate( + "Sketcher_BSplinePolygon", + "Switches between showing and hiding the control polygons for all B-splines")); + c2->setStatusTip(QApplication::translate( + "Sketcher_BSplinePolygon", + "Switches between showing and hiding the control polygons for all B-splines")); + QAction* c3 = a[2]; + c3->setText(QApplication::translate("CmdSketcherCompBSplineShowHideGeometryInformation", + "Show/hide B-spline curvature comb")); + c3->setToolTip(QApplication::translate( + "Sketcher_BSplineComb", + "Switches between showing and hiding the curvature comb for all B-splines")); + c3->setStatusTip(QApplication::translate( + "Sketcher_BSplineComb", + "Switches between showing and hiding the curvature comb for all B-splines")); + QAction* c4 = a[3]; + c4->setText(QApplication::translate("CmdSketcherCompBSplineShowHideGeometryInformation", + "Show/hide B-spline knot multiplicity")); + c4->setToolTip(QApplication::translate( + "Sketcher_BSplineKnotMultiplicity", + "Switches between showing and hiding the knot multiplicity for all B-splines")); + c4->setStatusTip(QApplication::translate( + "Sketcher_BSplineKnotMultiplicity", + "Switches between showing and hiding the knot multiplicity for all B-splines")); + + QAction* c5 = a[4]; + c5->setText(QApplication::translate("CmdSketcherCompBSplineShowHideGeometryInformation", + "Show/hide B-spline control point weight")); + c5->setToolTip(QApplication::translate( + "Sketcher_BSplinePoleWeight", + "Switches between showing and hiding the control point weight for all B-splines")); + c5->setStatusTip(QApplication::translate( + "Sketcher_BSplinePoleWeight", + "Switches between showing and hiding the control point weight for all B-splines")); +} + +void CmdSketcherCompBSplineShowHideGeometryInformation::updateAction(int /*mode*/) +{} + +bool CmdSketcherCompBSplineShowHideGeometryInformation::isActive() +{ + return isSketcherBSplineActive(getActiveGuiDocument(), false); +} + +// +DEF_STD_CMD_A(CmdSketcherArcOverlay) + +CmdSketcherArcOverlay::CmdSketcherArcOverlay() + : Command("Sketcher_ArcOverlay") +{ + sAppModule = "Sketcher"; + sGroup = "Sketcher"; + sMenuText = QT_TR_NOOP("Show/hide circular helper for arcs"); + sToolTipText = + QT_TR_NOOP("Switches between showing and hiding the circular helper for all arcs"); + sWhatsThis = "Sketcher_ArcOverlay"; + sStatusTip = sToolTipText; + sPixmap = "Sketcher_ArcOverlay"; + sAccel = ""; + eType = ForEdit; +} + +void CmdSketcherArcOverlay::activated(int iMsg) +{ + Q_UNUSED(iMsg); + + ShowRestoreInformationLayer("ArcCircleHelperVisible"); +} + +bool CmdSketcherArcOverlay::isActive() +{ + return isSketchInEdit(getActiveGuiDocument()); +} + +void CreateSketcherCommandsOverlay() +{ + Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager(); + + rcCmdMgr.addCommand(new CmdSketcherBSplineDegree()); + rcCmdMgr.addCommand(new CmdSketcherBSplinePolygon()); + rcCmdMgr.addCommand(new CmdSketcherBSplineComb()); + rcCmdMgr.addCommand(new CmdSketcherBSplineKnotMultiplicity()); + rcCmdMgr.addCommand(new CmdSketcherBSplinePoleWeight()); + rcCmdMgr.addCommand(new CmdSketcherCompBSplineShowHideGeometryInformation()); + rcCmdMgr.addCommand(new CmdSketcherArcOverlay()); +} diff --git a/src/Mod/Sketcher/Gui/Utils.cpp b/src/Mod/Sketcher/Gui/Utils.cpp index 17b48b0281..ebab5ccd39 100644 --- a/src/Mod/Sketcher/Gui/Utils.cpp +++ b/src/Mod/Sketcher/Gui/Utils.cpp @@ -414,6 +414,26 @@ bool SketcherGui::isCommandActive(Gui::Document* doc, bool actsOnSelection) return false; } +bool SketcherGui::isSketcherBSplineActive(Gui::Document* doc, bool actsOnSelection) +{ + if (doc) { + // checks if a Sketch Viewprovider is in Edit and is in no special mode + if (doc->getInEdit() + && doc->getInEdit()->isDerivedFrom(SketcherGui::ViewProviderSketch::getClassTypeId())) { + if (static_cast(doc->getInEdit())->getSketchMode() + == ViewProviderSketch::STATUS_NONE) { + if (!actsOnSelection) + return true; + else if (Gui::Selection().countObjectsOfType( + Sketcher::SketchObject::getClassTypeId()) + > 0) + return true; + } + } + } + return false; +} + SketcherGui::ViewProviderSketch* SketcherGui::getInactiveHandlerEditModeSketchViewProvider(Gui::Document* doc) { diff --git a/src/Mod/Sketcher/Gui/Utils.h b/src/Mod/Sketcher/Gui/Utils.h index fecf4e1c3e..1ce611e270 100644 --- a/src/Mod/Sketcher/Gui/Utils.h +++ b/src/Mod/Sketcher/Gui/Utils.h @@ -145,6 +145,8 @@ bool isSketchInEdit(Gui::Document* doc); /// sketcher is no special state or a sketchHandler is active. bool isCommandActive(Gui::Document* doc, bool actsOnSelection = false); +bool isSketcherBSplineActive(Gui::Document* doc, bool actsOnSelection); + SketcherGui::ViewProviderSketch* getInactiveHandlerEditModeSketchViewProvider(Gui::Document* doc); SketcherGui::ViewProviderSketch* getInactiveHandlerEditModeSketchViewProvider(); @@ -162,6 +164,7 @@ bool showCursorCoords(); bool useSystemDecimals(); std::string lengthToDisplayFormat(double value, int digits); std::string angleToDisplayFormat(double value, int digits); + }// namespace SketcherGui /// converts a 2D vector into a 3D vector in the XY plane diff --git a/src/Mod/Sketcher/Gui/Workbench.cpp b/src/Mod/Sketcher/Gui/Workbench.cpp index 2751b3410a..09dbdddf9f 100644 --- a/src/Mod/Sketcher/Gui/Workbench.cpp +++ b/src/Mod/Sketcher/Gui/Workbench.cpp @@ -517,8 +517,7 @@ inline void SketcherAddWorkbenchBSplines(Gui::MenuItem& bspline) template<> inline void SketcherAddWorkbenchBSplines(Gui::ToolBarItem& bspline) { - bspline << "Sketcher_CompBSplineShowHideGeometryInformation" - << "Sketcher_BSplineConvertToNURBS" + bspline << "Sketcher_BSplineConvertToNURBS" << "Sketcher_BSplineIncreaseDegree" << "Sketcher_BSplineDecreaseDegree" << "Sketcher_CompModifyKnotMultiplicity" @@ -532,13 +531,17 @@ inline void SketcherAddWorkbenchVirtualSpace(T& virtualspace); template<> inline void SketcherAddWorkbenchVirtualSpace(Gui::MenuItem& virtualspace) { - virtualspace << "Sketcher_SwitchVirtualSpace"; + virtualspace << "Sketcher_SwitchVirtualSpace" + << "Sketcher_CompBSplineShowHideGeometryInformation" + << "Sketcher_ArcOverlay"; } template<> inline void SketcherAddWorkbenchVirtualSpace(Gui::ToolBarItem& virtualspace) { - virtualspace << "Sketcher_SwitchVirtualSpace"; + virtualspace << "Sketcher_SwitchVirtualSpace" + << "Sketcher_CompBSplineShowHideGeometryInformation" + << "Sketcher_ArcOverlay"; } template From 4a5da1940c5b4af8207a0f5593fe460005f3fbb4 Mon Sep 17 00:00:00 2001 From: Florian Foinant-Willig Date: Fri, 2 Jun 2023 22:02:30 +0200 Subject: [PATCH 2/4] Create overlay icon folder and ArcOverlay icon And move BSpline overlay related icons to the new folder --- src/Mod/Sketcher/Gui/AppSketcherGui.cpp | 1 + src/Mod/Sketcher/Gui/Resources/Sketcher.qrc | 72 ++- .../icons/overlay/Sketcher_ArcOverlay.svg | 435 ++++++++++++++++++ .../Sketcher_BSplineComb.svg | 0 .../Sketcher_BSplineDegree.svg | 0 .../Sketcher_BSplineKnotMultiplicity.svg | 0 .../Sketcher_BSplinePoleWeight.svg | 0 .../Sketcher_BSplinePolygon.svg | 0 8 files changed, 463 insertions(+), 45 deletions(-) create mode 100644 src/Mod/Sketcher/Gui/Resources/icons/overlay/Sketcher_ArcOverlay.svg rename src/Mod/Sketcher/Gui/Resources/icons/{splines => overlay}/Sketcher_BSplineComb.svg (100%) rename src/Mod/Sketcher/Gui/Resources/icons/{splines => overlay}/Sketcher_BSplineDegree.svg (100%) rename src/Mod/Sketcher/Gui/Resources/icons/{splines => overlay}/Sketcher_BSplineKnotMultiplicity.svg (100%) rename src/Mod/Sketcher/Gui/Resources/icons/{splines => overlay}/Sketcher_BSplinePoleWeight.svg (100%) rename src/Mod/Sketcher/Gui/Resources/icons/{splines => overlay}/Sketcher_BSplinePolygon.svg (100%) diff --git a/src/Mod/Sketcher/Gui/AppSketcherGui.cpp b/src/Mod/Sketcher/Gui/AppSketcherGui.cpp index b53b551e91..f1f35539d8 100644 --- a/src/Mod/Sketcher/Gui/AppSketcherGui.cpp +++ b/src/Mod/Sketcher/Gui/AppSketcherGui.cpp @@ -109,6 +109,7 @@ PyMOD_INIT_FUNC(SketcherGui) Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/pointers")); Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/splines")); Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/tools")); + Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/overlay")); // instantiating the commands CreateSketcherCommands(); diff --git a/src/Mod/Sketcher/Gui/Resources/Sketcher.qrc b/src/Mod/Sketcher/Gui/Resources/Sketcher.qrc index 617c3fb158..ae46a831bc 100644 --- a/src/Mod/Sketcher/Gui/Resources/Sketcher.qrc +++ b/src/Mod/Sketcher/Gui/Resources/Sketcher.qrc @@ -1,10 +1,7 @@ - icons/Sketcher_Sketch.svg icons/SketcherWorkbench.svg - icons/SketcherWorkbench.svg - - + icons/Sketcher_Sketch.svg icons/constraints/Constraint_Block.svg icons/constraints/Constraint_Concentric.svg icons/constraints/Constraint_Diameter.svg @@ -37,10 +34,10 @@ icons/constraints/Constraint_PointOnPoint.svg icons/constraints/Constraint_PointOnStart.svg icons/constraints/Constraint_PointToObject.svg - icons/constraints/Constraint_Radius.svg - icons/constraints/Constraint_Radius_Driven.svg icons/constraints/Constraint_Radiam.svg icons/constraints/Constraint_Radiam_Driven.svg + icons/constraints/Constraint_Radius.svg + icons/constraints/Constraint_Radius_Driven.svg icons/constraints/Constraint_SnellsLaw.svg icons/constraints/Constraint_SnellsLaw_Driven.svg icons/constraints/Constraint_Symmetric.svg @@ -55,8 +52,7 @@ icons/constraints/Sketcher_ToggleConstraint.svg icons/constraints/Sketcher_Toggle_Constraint_Driven.svg icons/constraints/Sketcher_Toggle_Constraint_Driving.svg - - + icons/dialogs/Sketcher_Settings.svg icons/elements/Sketcher_Element_Arc_Edge.svg icons/elements/Sketcher_Element_Arc_EndPoint.svg icons/elements/Sketcher_Element_Arc_MidPoint.svg @@ -91,28 +87,24 @@ icons/elements/Sketcher_Element_Parabolic_Arc_Start_Point.svg icons/elements/Sketcher_Element_Point_StartingPoint.svg icons/elements/Sketcher_Element_SelectionTypeInvalid.svg - - icons/general/Sketcher_EditSketch.svg + icons/general/Sketcher_GridToggle.svg + icons/general/Sketcher_GridToggle_Deactivated.svg icons/general/Sketcher_LeaveSketch.svg icons/general/Sketcher_MapSketch.svg icons/general/Sketcher_MergeSketch.svg icons/general/Sketcher_MirrorSketch.svg icons/general/Sketcher_NewSketch.svg + icons/general/Sketcher_RenderingOrder_Construction.svg + icons/general/Sketcher_RenderingOrder_External.svg + icons/general/Sketcher_RenderingOrder_Normal.svg icons/general/Sketcher_ReorientSketch.svg + icons/general/Sketcher_Snap.svg + icons/general/Sketcher_Snap_Deactivated.svg icons/general/Sketcher_SwitchVirtualSpace.svg icons/general/Sketcher_ValidateSketch.svg icons/general/Sketcher_ViewSection.svg icons/general/Sketcher_ViewSketch.svg - icons/general/Sketcher_GridToggle.svg - icons/general/Sketcher_GridToggle_Deactivated.svg - icons/general/Sketcher_RenderingOrder_Construction.svg - icons/general/Sketcher_RenderingOrder_External.svg - icons/general/Sketcher_RenderingOrder_Normal.svg - icons/general/Sketcher_Snap.svg - icons/general/Sketcher_Snap_Deactivated.svg - - icons/geometry/Sketcher_AlterFillet.svg icons/geometry/Sketcher_CarbonCopy.svg icons/geometry/Sketcher_CarbonCopy_Constr.svg @@ -127,21 +119,18 @@ icons/geometry/Sketcher_CreateArc.svg icons/geometry/Sketcher_CreateArc_Constr.svg icons/geometry/Sketcher_CreateBSpline.svg - icons/geometry/Sketcher_CreateBSpline_Constr.svg icons/geometry/Sketcher_CreateBSplineByInterpolation.svg icons/geometry/Sketcher_CreateBSplineByInterpolation_Constr.svg - icons/geometry/Sketcher_Create_Periodic_BSplineByInterpolation.svg - icons/geometry/Sketcher_Create_Periodic_BSplineByInterpolation_Constr.svg + icons/geometry/Sketcher_CreateBSpline_Constr.svg icons/geometry/Sketcher_CreateCircle.svg icons/geometry/Sketcher_CreateCircle_Constr.svg - icons/geometry/Sketcher_CreateEllipse_3points.svg - icons/geometry/Sketcher_CreateEllipse_3points_Constr.svg icons/geometry/Sketcher_CreateEllipseByCenter.svg icons/geometry/Sketcher_CreateEllipseByCenter_Constr.svg + icons/geometry/Sketcher_CreateEllipse_3points.svg + icons/geometry/Sketcher_CreateEllipse_3points_Constr.svg icons/geometry/Sketcher_CreateElliptical_Arc.svg icons/geometry/Sketcher_CreateElliptical_Arc_Constr.svg icons/geometry/Sketcher_CreateFillet.svg - icons/geometry/Sketcher_CreatePointFillet.svg icons/geometry/Sketcher_CreateHeptagon.svg icons/geometry/Sketcher_CreateHeptagon_Constr.svg icons/geometry/Sketcher_CreateHexagon.svg @@ -158,15 +147,14 @@ icons/geometry/Sketcher_CreateParabolic_Arc_Constr.svg icons/geometry/Sketcher_CreatePentagon.svg icons/geometry/Sketcher_CreatePentagon_Constr.svg - icons/geometry/Sketcher_Create_Periodic_BSpline.svg - icons/geometry/Sketcher_Create_Periodic_BSpline_Constr.svg icons/geometry/Sketcher_CreatePoint.svg + icons/geometry/Sketcher_CreatePointFillet.svg icons/geometry/Sketcher_CreatePolyline.svg icons/geometry/Sketcher_CreatePolyline_Constr.svg icons/geometry/Sketcher_CreateRectangle.svg - icons/geometry/Sketcher_CreateRectangle_Constr.svg icons/geometry/Sketcher_CreateRectangle_Center.svg icons/geometry/Sketcher_CreateRectangle_Center_Constr.svg + icons/geometry/Sketcher_CreateRectangle_Constr.svg icons/geometry/Sketcher_CreateRegularPolygon.svg icons/geometry/Sketcher_CreateRegularPolygon_Constr.svg icons/geometry/Sketcher_CreateSlot.svg @@ -176,13 +164,15 @@ icons/geometry/Sketcher_CreateText.svg icons/geometry/Sketcher_CreateTriangle.svg icons/geometry/Sketcher_CreateTriangle_Constr.svg + icons/geometry/Sketcher_Create_Periodic_BSpline.svg + icons/geometry/Sketcher_Create_Periodic_BSplineByInterpolation.svg + icons/geometry/Sketcher_Create_Periodic_BSplineByInterpolation_Constr.svg + icons/geometry/Sketcher_Create_Periodic_BSpline_Constr.svg icons/geometry/Sketcher_Extend.svg icons/geometry/Sketcher_External.svg icons/geometry/Sketcher_Split.svg icons/geometry/Sketcher_ToggleConstruction.svg icons/geometry/Sketcher_Trimming.svg - - icons/obsolete/Sketcher_ConstrainCoincident_old.svg icons/obsolete/Sketcher_ConstrainDistance_old.svg icons/obsolete/Sketcher_ConstrainHorizontal_old.svg @@ -192,8 +182,12 @@ icons/obsolete/Sketcher_ProfilesHexagon1.svg icons/obsolete/Sketcher_ToggleConstruction_old.svg icons/obsolete/Sketcher_ToggleNormal.svg - - + icons/overlay/Sketcher_ArcOverlay.svg + icons/overlay/Sketcher_BSplineComb.svg + icons/overlay/Sketcher_BSplineDegree.svg + icons/overlay/Sketcher_BSplineKnotMultiplicity.svg + icons/overlay/Sketcher_BSplinePoleWeight.svg + icons/overlay/Sketcher_BSplinePolygon.svg icons/pointers/Sketcher_Pointer_CarbonCopy.svg icons/pointers/Sketcher_Pointer_Create_3PointArc.svg icons/pointers/Sketcher_Pointer_Create_3PointCircle.svg @@ -201,8 +195,8 @@ icons/pointers/Sketcher_Pointer_Create_ArcOfEllipse.svg icons/pointers/Sketcher_Pointer_Create_ArcOfHyperbola.svg icons/pointers/Sketcher_Pointer_Create_ArcOfParabola.svg - icons/pointers/Sketcher_Pointer_Create_Box.svg icons/pointers/Sketcher_Pointer_Create_BSpline.svg + icons/pointers/Sketcher_Pointer_Create_Box.svg icons/pointers/Sketcher_Pointer_Create_Circle.svg icons/pointers/Sketcher_Pointer_Create_Ellipse.svg icons/pointers/Sketcher_Pointer_Create_Fillet.svg @@ -217,22 +211,13 @@ icons/pointers/Sketcher_Pointer_Slot.svg icons/pointers/Sketcher_Pointer_Splitting.svg icons/pointers/Sketcher_Pointer_Trimming.svg - - icons/splines/Sketcher_BSplineApproximate.svg - icons/splines/Sketcher_BSplineComb.svg icons/splines/Sketcher_BSplineDecreaseDegree.svg icons/splines/Sketcher_BSplineDecreaseKnotMultiplicity.svg - icons/splines/Sketcher_BSplineDegree.svg icons/splines/Sketcher_BSplineIncreaseDegree.svg icons/splines/Sketcher_BSplineIncreaseKnotMultiplicity.svg icons/splines/Sketcher_BSplineInsertKnot.svg icons/splines/Sketcher_JoinCurves.svg - icons/splines/Sketcher_BSplineKnotMultiplicity.svg - icons/splines/Sketcher_BSplinePoleWeight.svg - icons/splines/Sketcher_BSplinePolygon.svg - - icons/tools/Sketcher_Clone.svg icons/tools/Sketcher_Copy.svg icons/tools/Sketcher_DeleteConstraints.svg @@ -250,7 +235,4 @@ icons/tools/Sketcher_SelectVerticalAxis.svg icons/tools/Sketcher_Symmetry.svg - - icons/dialogs/Sketcher_Settings.svg - diff --git a/src/Mod/Sketcher/Gui/Resources/icons/overlay/Sketcher_ArcOverlay.svg b/src/Mod/Sketcher/Gui/Resources/icons/overlay/Sketcher_ArcOverlay.svg new file mode 100644 index 0000000000..64053c3a9a --- /dev/null +++ b/src/Mod/Sketcher/Gui/Resources/icons/overlay/Sketcher_ArcOverlay.svg @@ -0,0 +1,435 @@ + + + +image/svg+xml[wmayer]Sketcher_Create3PointCircle2014-03-29http://www.freecadweb.org/wiki/index.php?title=ArtworkFreeCADFreeCAD/src/Mod/Sketcher/Gui/Resources/icons/Sketcher_Create3PointCircle.svgFreeCAD LGPL2+https://www.gnu.org/copyleft/lesser.html[agryson] Alexander Gryson diff --git a/src/Mod/Sketcher/Gui/Resources/icons/splines/Sketcher_BSplineComb.svg b/src/Mod/Sketcher/Gui/Resources/icons/overlay/Sketcher_BSplineComb.svg similarity index 100% rename from src/Mod/Sketcher/Gui/Resources/icons/splines/Sketcher_BSplineComb.svg rename to src/Mod/Sketcher/Gui/Resources/icons/overlay/Sketcher_BSplineComb.svg diff --git a/src/Mod/Sketcher/Gui/Resources/icons/splines/Sketcher_BSplineDegree.svg b/src/Mod/Sketcher/Gui/Resources/icons/overlay/Sketcher_BSplineDegree.svg similarity index 100% rename from src/Mod/Sketcher/Gui/Resources/icons/splines/Sketcher_BSplineDegree.svg rename to src/Mod/Sketcher/Gui/Resources/icons/overlay/Sketcher_BSplineDegree.svg diff --git a/src/Mod/Sketcher/Gui/Resources/icons/splines/Sketcher_BSplineKnotMultiplicity.svg b/src/Mod/Sketcher/Gui/Resources/icons/overlay/Sketcher_BSplineKnotMultiplicity.svg similarity index 100% rename from src/Mod/Sketcher/Gui/Resources/icons/splines/Sketcher_BSplineKnotMultiplicity.svg rename to src/Mod/Sketcher/Gui/Resources/icons/overlay/Sketcher_BSplineKnotMultiplicity.svg diff --git a/src/Mod/Sketcher/Gui/Resources/icons/splines/Sketcher_BSplinePoleWeight.svg b/src/Mod/Sketcher/Gui/Resources/icons/overlay/Sketcher_BSplinePoleWeight.svg similarity index 100% rename from src/Mod/Sketcher/Gui/Resources/icons/splines/Sketcher_BSplinePoleWeight.svg rename to src/Mod/Sketcher/Gui/Resources/icons/overlay/Sketcher_BSplinePoleWeight.svg diff --git a/src/Mod/Sketcher/Gui/Resources/icons/splines/Sketcher_BSplinePolygon.svg b/src/Mod/Sketcher/Gui/Resources/icons/overlay/Sketcher_BSplinePolygon.svg similarity index 100% rename from src/Mod/Sketcher/Gui/Resources/icons/splines/Sketcher_BSplinePolygon.svg rename to src/Mod/Sketcher/Gui/Resources/icons/overlay/Sketcher_BSplinePolygon.svg From f120c7a31721b4f643847e0f0d344eeaf9095bfc Mon Sep 17 00:00:00 2001 From: Florian Foinant-Willig Date: Mon, 14 Aug 2023 22:12:18 +0200 Subject: [PATCH 3/4] Fix menu and ressource file --- src/Mod/Sketcher/Gui/Resources/Sketcher.qrc | 75 +++++++++++++-------- src/Mod/Sketcher/Gui/Workbench.cpp | 35 +++++----- 2 files changed, 63 insertions(+), 47 deletions(-) diff --git a/src/Mod/Sketcher/Gui/Resources/Sketcher.qrc b/src/Mod/Sketcher/Gui/Resources/Sketcher.qrc index ae46a831bc..52f4638e45 100644 --- a/src/Mod/Sketcher/Gui/Resources/Sketcher.qrc +++ b/src/Mod/Sketcher/Gui/Resources/Sketcher.qrc @@ -1,7 +1,10 @@ - icons/SketcherWorkbench.svg icons/Sketcher_Sketch.svg + icons/SketcherWorkbench.svg + icons/SketcherWorkbench.svg + + icons/constraints/Constraint_Block.svg icons/constraints/Constraint_Concentric.svg icons/constraints/Constraint_Diameter.svg @@ -34,10 +37,10 @@ icons/constraints/Constraint_PointOnPoint.svg icons/constraints/Constraint_PointOnStart.svg icons/constraints/Constraint_PointToObject.svg - icons/constraints/Constraint_Radiam.svg - icons/constraints/Constraint_Radiam_Driven.svg icons/constraints/Constraint_Radius.svg icons/constraints/Constraint_Radius_Driven.svg + icons/constraints/Constraint_Radiam.svg + icons/constraints/Constraint_Radiam_Driven.svg icons/constraints/Constraint_SnellsLaw.svg icons/constraints/Constraint_SnellsLaw_Driven.svg icons/constraints/Constraint_Symmetric.svg @@ -52,7 +55,8 @@ icons/constraints/Sketcher_ToggleConstraint.svg icons/constraints/Sketcher_Toggle_Constraint_Driven.svg icons/constraints/Sketcher_Toggle_Constraint_Driving.svg - icons/dialogs/Sketcher_Settings.svg + + icons/elements/Sketcher_Element_Arc_Edge.svg icons/elements/Sketcher_Element_Arc_EndPoint.svg icons/elements/Sketcher_Element_Arc_MidPoint.svg @@ -87,24 +91,28 @@ icons/elements/Sketcher_Element_Parabolic_Arc_Start_Point.svg icons/elements/Sketcher_Element_Point_StartingPoint.svg icons/elements/Sketcher_Element_SelectionTypeInvalid.svg + + icons/general/Sketcher_EditSketch.svg - icons/general/Sketcher_GridToggle.svg - icons/general/Sketcher_GridToggle_Deactivated.svg icons/general/Sketcher_LeaveSketch.svg icons/general/Sketcher_MapSketch.svg icons/general/Sketcher_MergeSketch.svg icons/general/Sketcher_MirrorSketch.svg icons/general/Sketcher_NewSketch.svg - icons/general/Sketcher_RenderingOrder_Construction.svg - icons/general/Sketcher_RenderingOrder_External.svg - icons/general/Sketcher_RenderingOrder_Normal.svg icons/general/Sketcher_ReorientSketch.svg - icons/general/Sketcher_Snap.svg - icons/general/Sketcher_Snap_Deactivated.svg icons/general/Sketcher_SwitchVirtualSpace.svg icons/general/Sketcher_ValidateSketch.svg icons/general/Sketcher_ViewSection.svg icons/general/Sketcher_ViewSketch.svg + icons/general/Sketcher_GridToggle.svg + icons/general/Sketcher_GridToggle_Deactivated.svg + icons/general/Sketcher_RenderingOrder_Construction.svg + icons/general/Sketcher_RenderingOrder_External.svg + icons/general/Sketcher_RenderingOrder_Normal.svg + icons/general/Sketcher_Snap.svg + icons/general/Sketcher_Snap_Deactivated.svg + + icons/geometry/Sketcher_AlterFillet.svg icons/geometry/Sketcher_CarbonCopy.svg icons/geometry/Sketcher_CarbonCopy_Constr.svg @@ -119,18 +127,21 @@ icons/geometry/Sketcher_CreateArc.svg icons/geometry/Sketcher_CreateArc_Constr.svg icons/geometry/Sketcher_CreateBSpline.svg + icons/geometry/Sketcher_CreateBSpline_Constr.svg icons/geometry/Sketcher_CreateBSplineByInterpolation.svg icons/geometry/Sketcher_CreateBSplineByInterpolation_Constr.svg - icons/geometry/Sketcher_CreateBSpline_Constr.svg + icons/geometry/Sketcher_Create_Periodic_BSplineByInterpolation.svg + icons/geometry/Sketcher_Create_Periodic_BSplineByInterpolation_Constr.svg icons/geometry/Sketcher_CreateCircle.svg icons/geometry/Sketcher_CreateCircle_Constr.svg - icons/geometry/Sketcher_CreateEllipseByCenter.svg - icons/geometry/Sketcher_CreateEllipseByCenter_Constr.svg icons/geometry/Sketcher_CreateEllipse_3points.svg icons/geometry/Sketcher_CreateEllipse_3points_Constr.svg + icons/geometry/Sketcher_CreateEllipseByCenter.svg + icons/geometry/Sketcher_CreateEllipseByCenter_Constr.svg icons/geometry/Sketcher_CreateElliptical_Arc.svg icons/geometry/Sketcher_CreateElliptical_Arc_Constr.svg icons/geometry/Sketcher_CreateFillet.svg + icons/geometry/Sketcher_CreatePointFillet.svg icons/geometry/Sketcher_CreateHeptagon.svg icons/geometry/Sketcher_CreateHeptagon_Constr.svg icons/geometry/Sketcher_CreateHexagon.svg @@ -147,14 +158,15 @@ icons/geometry/Sketcher_CreateParabolic_Arc_Constr.svg icons/geometry/Sketcher_CreatePentagon.svg icons/geometry/Sketcher_CreatePentagon_Constr.svg + icons/geometry/Sketcher_Create_Periodic_BSpline.svg + icons/geometry/Sketcher_Create_Periodic_BSpline_Constr.svg icons/geometry/Sketcher_CreatePoint.svg - icons/geometry/Sketcher_CreatePointFillet.svg icons/geometry/Sketcher_CreatePolyline.svg icons/geometry/Sketcher_CreatePolyline_Constr.svg icons/geometry/Sketcher_CreateRectangle.svg + icons/geometry/Sketcher_CreateRectangle_Constr.svg icons/geometry/Sketcher_CreateRectangle_Center.svg icons/geometry/Sketcher_CreateRectangle_Center_Constr.svg - icons/geometry/Sketcher_CreateRectangle_Constr.svg icons/geometry/Sketcher_CreateRegularPolygon.svg icons/geometry/Sketcher_CreateRegularPolygon_Constr.svg icons/geometry/Sketcher_CreateSlot.svg @@ -164,15 +176,13 @@ icons/geometry/Sketcher_CreateText.svg icons/geometry/Sketcher_CreateTriangle.svg icons/geometry/Sketcher_CreateTriangle_Constr.svg - icons/geometry/Sketcher_Create_Periodic_BSpline.svg - icons/geometry/Sketcher_Create_Periodic_BSplineByInterpolation.svg - icons/geometry/Sketcher_Create_Periodic_BSplineByInterpolation_Constr.svg - icons/geometry/Sketcher_Create_Periodic_BSpline_Constr.svg icons/geometry/Sketcher_Extend.svg icons/geometry/Sketcher_External.svg icons/geometry/Sketcher_Split.svg icons/geometry/Sketcher_ToggleConstruction.svg icons/geometry/Sketcher_Trimming.svg + + icons/obsolete/Sketcher_ConstrainCoincident_old.svg icons/obsolete/Sketcher_ConstrainDistance_old.svg icons/obsolete/Sketcher_ConstrainHorizontal_old.svg @@ -182,12 +192,8 @@ icons/obsolete/Sketcher_ProfilesHexagon1.svg icons/obsolete/Sketcher_ToggleConstruction_old.svg icons/obsolete/Sketcher_ToggleNormal.svg - icons/overlay/Sketcher_ArcOverlay.svg - icons/overlay/Sketcher_BSplineComb.svg - icons/overlay/Sketcher_BSplineDegree.svg - icons/overlay/Sketcher_BSplineKnotMultiplicity.svg - icons/overlay/Sketcher_BSplinePoleWeight.svg - icons/overlay/Sketcher_BSplinePolygon.svg + + icons/pointers/Sketcher_Pointer_CarbonCopy.svg icons/pointers/Sketcher_Pointer_Create_3PointArc.svg icons/pointers/Sketcher_Pointer_Create_3PointCircle.svg @@ -195,8 +201,8 @@ icons/pointers/Sketcher_Pointer_Create_ArcOfEllipse.svg icons/pointers/Sketcher_Pointer_Create_ArcOfHyperbola.svg icons/pointers/Sketcher_Pointer_Create_ArcOfParabola.svg - icons/pointers/Sketcher_Pointer_Create_BSpline.svg icons/pointers/Sketcher_Pointer_Create_Box.svg + icons/pointers/Sketcher_Pointer_Create_BSpline.svg icons/pointers/Sketcher_Pointer_Create_Circle.svg icons/pointers/Sketcher_Pointer_Create_Ellipse.svg icons/pointers/Sketcher_Pointer_Create_Fillet.svg @@ -211,6 +217,8 @@ icons/pointers/Sketcher_Pointer_Slot.svg icons/pointers/Sketcher_Pointer_Splitting.svg icons/pointers/Sketcher_Pointer_Trimming.svg + + icons/splines/Sketcher_BSplineApproximate.svg icons/splines/Sketcher_BSplineDecreaseDegree.svg icons/splines/Sketcher_BSplineDecreaseKnotMultiplicity.svg @@ -218,6 +226,16 @@ icons/splines/Sketcher_BSplineIncreaseKnotMultiplicity.svg icons/splines/Sketcher_BSplineInsertKnot.svg icons/splines/Sketcher_JoinCurves.svg + + + icons/overlay/Sketcher_BSplineComb.svg + icons/overlay/Sketcher_BSplineDegree.svg + icons/overlay/Sketcher_BSplineKnotMultiplicity.svg + icons/overlay/Sketcher_BSplinePoleWeight.svg + icons/overlay/Sketcher_BSplinePolygon.svg + icons/overlay/Sketcher_ArcOverlay.svg + + icons/tools/Sketcher_Clone.svg icons/tools/Sketcher_Copy.svg icons/tools/Sketcher_DeleteConstraints.svg @@ -235,4 +253,7 @@ icons/tools/Sketcher_SelectVerticalAxis.svg icons/tools/Sketcher_Symmetry.svg + + icons/dialogs/Sketcher_Settings.svg + diff --git a/src/Mod/Sketcher/Gui/Workbench.cpp b/src/Mod/Sketcher/Gui/Workbench.cpp index 09dbdddf9f..7f8456ec46 100644 --- a/src/Mod/Sketcher/Gui/Workbench.cpp +++ b/src/Mod/Sketcher/Gui/Workbench.cpp @@ -134,10 +134,10 @@ Gui::ToolBarItem* Workbench::setupToolBars() const bspline->setCommand("Sketcher B-spline tools"); addSketcherWorkbenchBSplines(*bspline); - Gui::ToolBarItem* virtualspace = + Gui::ToolBarItem* visual = new Gui::ToolBarItem(root, Gui::ToolBarItem::DefaultVisibility::Unavailable); - virtualspace->setCommand("Sketcher virtual space"); - addSketcherWorkbenchVirtualSpace(*virtualspace); + visual->setCommand("Sketcher visual"); + addSketcherWorkbenchVisual(*visual); Gui::ToolBarItem* edittools = new Gui::ToolBarItem(root, Gui::ToolBarItem::DefaultVisibility::Unavailable); @@ -500,12 +500,7 @@ inline void SketcherAddWorkbenchBSplines(T& bspline); template<> inline void SketcherAddWorkbenchBSplines(Gui::MenuItem& bspline) { - bspline << "Sketcher_BSplineDegree" - << "Sketcher_BSplinePolygon" - << "Sketcher_BSplineComb" - << "Sketcher_BSplineKnotMultiplicity" - << "Sketcher_BSplinePoleWeight" - << "Sketcher_BSplineConvertToNURBS" + bspline << "Sketcher_BSplineConvertToNURBS" << "Sketcher_BSplineIncreaseDegree" << "Sketcher_BSplineDecreaseDegree" << "Sketcher_BSplineIncreaseKnotMultiplicity" @@ -526,22 +521,22 @@ inline void SketcherAddWorkbenchBSplines(Gui::ToolBarItem& bsp } template -inline void SketcherAddWorkbenchVirtualSpace(T& virtualspace); +inline void SketcherAddWorkbenchVisual(T& visual); template<> -inline void SketcherAddWorkbenchVirtualSpace(Gui::MenuItem& virtualspace) +inline void SketcherAddWorkbenchVisual(Gui::MenuItem& visual) { - virtualspace << "Sketcher_SwitchVirtualSpace" - << "Sketcher_CompBSplineShowHideGeometryInformation" - << "Sketcher_ArcOverlay"; + visual << "Sketcher_SwitchVirtualSpace" + << "Sketcher_CompBSplineShowHideGeometryInformation" + << "Sketcher_ArcOverlay"; } template<> -inline void SketcherAddWorkbenchVirtualSpace(Gui::ToolBarItem& virtualspace) +inline void SketcherAddWorkbenchVisual(Gui::ToolBarItem& visual) { - virtualspace << "Sketcher_SwitchVirtualSpace" - << "Sketcher_CompBSplineShowHideGeometryInformation" - << "Sketcher_ArcOverlay"; + visual << "Sketcher_SwitchVirtualSpace" + << "Sketcher_CompBSplineShowHideGeometryInformation" + << "Sketcher_ArcOverlay"; } template @@ -585,9 +580,9 @@ void addSketcherWorkbenchBSplines(Gui::MenuItem& bspline) SketcherAddWorkbenchBSplines(bspline); } -void addSketcherWorkbenchVirtualSpace(Gui::MenuItem& virtualspace) +void addSketcherWorkbenchVisual(Gui::MenuItem& visual) { - SketcherAddWorkbenchVirtualSpace(virtualspace); + SketcherAddWorkbenchVisual(visual); } void addSketcherWorkbenchSketchActions(Gui::ToolBarItem& sketch) From 06cd311acde7d8a0e93f421dcf497b57c3b14389 Mon Sep 17 00:00:00 2001 From: Florian Foinant-Willig Date: Mon, 14 Aug 2023 22:31:36 +0200 Subject: [PATCH 4/4] Fix the fix o:-) --- src/Mod/Sketcher/Gui/Workbench.cpp | 12 ++++++------ src/Mod/Sketcher/Gui/Workbench.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Mod/Sketcher/Gui/Workbench.cpp b/src/Mod/Sketcher/Gui/Workbench.cpp index 7f8456ec46..3055e7236e 100644 --- a/src/Mod/Sketcher/Gui/Workbench.cpp +++ b/src/Mod/Sketcher/Gui/Workbench.cpp @@ -87,16 +87,16 @@ Gui::MenuItem* Workbench::setupMenuBar() const bsplines->setCommand("Sketcher B-spline tools"); addSketcherWorkbenchBSplines(*bsplines); - Gui::MenuItem* virtualspace = new Gui::MenuItem(); - virtualspace->setCommand("Sketcher virtual space"); - addSketcherWorkbenchVirtualSpace(*virtualspace); + Gui::MenuItem* visual = new Gui::MenuItem(); + visual->setCommand("Sketcher visual"); + addSketcherWorkbenchVisual(*visual); Gui::MenuItem* sketch = new Gui::MenuItem; root->insertItem(item, sketch); sketch->setCommand("S&ketch"); addSketcherWorkbenchSketchActions(*sketch); addSketcherWorkbenchSketchEditModeActions(*sketch); - *sketch << geom << cons << consaccel << bsplines << virtualspace; + *sketch << geom << cons << consaccel << bsplines << visual; return root; } @@ -615,9 +615,9 @@ void addSketcherWorkbenchBSplines(Gui::ToolBarItem& bspline) SketcherAddWorkbenchBSplines(bspline); } -void addSketcherWorkbenchVirtualSpace(Gui::ToolBarItem& virtualspace) +void addSketcherWorkbenchVisual(Gui::ToolBarItem& visual) { - SketcherAddWorkbenchVirtualSpace(virtualspace); + SketcherAddWorkbenchVisual(visual); } void addSketcherWorkbenchEditTools(Gui::ToolBarItem& edittools) diff --git a/src/Mod/Sketcher/Gui/Workbench.h b/src/Mod/Sketcher/Gui/Workbench.h index 4345806bb8..ca78a23640 100644 --- a/src/Mod/Sketcher/Gui/Workbench.h +++ b/src/Mod/Sketcher/Gui/Workbench.h @@ -60,7 +60,7 @@ SketcherGuiExport void addSketcherWorkbenchGeometries(Gui::MenuItem& geom); SketcherGuiExport void addSketcherWorkbenchConstraints(Gui::MenuItem& cons); SketcherGuiExport void addSketcherWorkbenchTools(Gui::MenuItem& consaccel); SketcherGuiExport void addSketcherWorkbenchBSplines(Gui::MenuItem& bspline); -SketcherGuiExport void addSketcherWorkbenchVirtualSpace(Gui::MenuItem& virtualspace); +SketcherGuiExport void addSketcherWorkbenchVisual(Gui::MenuItem& visual); SketcherGuiExport void addSketcherWorkbenchSketchActions(Gui::ToolBarItem& sketch); SketcherGuiExport void addSketcherWorkbenchSketchEditModeActions(Gui::ToolBarItem& sketch); @@ -68,7 +68,7 @@ SketcherGuiExport void addSketcherWorkbenchGeometries(Gui::ToolBarItem& geom); SketcherGuiExport void addSketcherWorkbenchConstraints(Gui::ToolBarItem& cons); SketcherGuiExport void addSketcherWorkbenchTools(Gui::ToolBarItem& consaccel); SketcherGuiExport void addSketcherWorkbenchBSplines(Gui::ToolBarItem& bspline); -SketcherGuiExport void addSketcherWorkbenchVirtualSpace(Gui::ToolBarItem& virtualspace); +SketcherGuiExport void addSketcherWorkbenchVisual(Gui::ToolBarItem& visual); SketcherGuiExport void addSketcherWorkbenchEditTools(Gui::ToolBarItem& edittools); }// namespace SketcherGui