From f48e79cd0467af4e6d3e9220a164ab5418e794be Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 3 Oct 2023 17:37:31 +0200 Subject: [PATCH] Part: add WorkbenchManipulator to Part module --- src/Mod/Part/Gui/AppPartGui.cpp | 5 ++ src/Mod/Part/Gui/CMakeLists.txt | 2 + src/Mod/Part/Gui/WorkbenchManipulator.cpp | 46 ++++++++++++++++ src/Mod/Part/Gui/WorkbenchManipulator.h | 64 +++++++++++++++++++++++ 4 files changed, 117 insertions(+) create mode 100644 src/Mod/Part/Gui/WorkbenchManipulator.cpp create mode 100644 src/Mod/Part/Gui/WorkbenchManipulator.h diff --git a/src/Mod/Part/Gui/AppPartGui.cpp b/src/Mod/Part/Gui/AppPartGui.cpp index fbaef82d4b..be70015d5c 100644 --- a/src/Mod/Part/Gui/AppPartGui.cpp +++ b/src/Mod/Part/Gui/AppPartGui.cpp @@ -77,6 +77,7 @@ #include "ViewProviderSpline.h" #include "ViewProviderTorusParametric.h" #include "Workbench.h" +#include "WorkbenchManipulator.h" // use a different name to CreateCommand() @@ -149,6 +150,7 @@ PyMOD_INIT_FUNC(PartGui) Py_INCREF(pAttachEngineTextsModule); PyModule_AddObject(partGuiModule, "AttachEngineResources", pAttachEngineTextsModule); + // clang-format off PartGui::PropertyEnumAttacherItem ::init(); PartGui::SoBrepFaceSet ::initClass(); PartGui::SoBrepEdgeSet ::initClass(); @@ -212,6 +214,9 @@ PyMOD_INIT_FUNC(PartGui) PartGui::ArcEngine ::initClass(); PartGui::Workbench ::init(); + auto manip = std::make_shared(); + Gui::WorkbenchManipulator::installManipulator(manip); + // clang-format on // instantiating the commands CreatePartCommands(); diff --git a/src/Mod/Part/Gui/CMakeLists.txt b/src/Mod/Part/Gui/CMakeLists.txt index b7876e68fb..ea1c2eee9e 100644 --- a/src/Mod/Part/Gui/CMakeLists.txt +++ b/src/Mod/Part/Gui/CMakeLists.txt @@ -218,6 +218,8 @@ SET(PartGui_SRCS ViewProviderPrimitive.h Workbench.cpp Workbench.h + WorkbenchManipulator.cpp + WorkbenchManipulator.h ReferenceHighlighter.cpp ReferenceHighlighter.h SectionCutting.cpp diff --git a/src/Mod/Part/Gui/WorkbenchManipulator.cpp b/src/Mod/Part/Gui/WorkbenchManipulator.cpp new file mode 100644 index 0000000000..063cfa70b7 --- /dev/null +++ b/src/Mod/Part/Gui/WorkbenchManipulator.cpp @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later + +/*************************************************************************** + * Copyright (c) 2023 Werner Mayer * + * * + * This file is part of FreeCAD. * + * * + * FreeCAD is free software: you can redistribute it and/or modify it * + * under the terms of the GNU Lesser General Public License as * + * published by the Free Software Foundation, either version 2.1 of the * + * License, or (at your option) any later version. * + * * + * FreeCAD 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 * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with FreeCAD. If not, see * + * . * + * * + **************************************************************************/ + + +#include "PreCompiled.h" +#include "WorkbenchManipulator.h" +#include +#include + +using namespace PartGui; + +void WorkbenchManipulator::modifyMenuBar([[maybe_unused]] Gui::MenuItem* menuBar) +{ +} + +void WorkbenchManipulator::modifyContextMenu(const char* recipient, Gui::MenuItem* menuBar) +{ +} + +void WorkbenchManipulator::modifyToolBars(Gui::ToolBarItem* toolBar) +{ +} + +void WorkbenchManipulator::modifyDockWindows([[maybe_unused]] Gui::DockWindowItems* dockWindow) +{ +} diff --git a/src/Mod/Part/Gui/WorkbenchManipulator.h b/src/Mod/Part/Gui/WorkbenchManipulator.h new file mode 100644 index 0000000000..f4c682a490 --- /dev/null +++ b/src/Mod/Part/Gui/WorkbenchManipulator.h @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later + +/*************************************************************************** + * Copyright (c) 2023 Werner Mayer * + * * + * This file is part of FreeCAD. * + * * + * FreeCAD is free software: you can redistribute it and/or modify it * + * under the terms of the GNU Lesser General Public License as * + * published by the Free Software Foundation, either version 2.1 of the * + * License, or (at your option) any later version. * + * * + * FreeCAD 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 * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with FreeCAD. If not, see * + * . * + * * + **************************************************************************/ + + +#ifndef PARTGUI_WORKBENCHMANIPULATOR_H +#define PARTGUI_WORKBENCHMANIPULATOR_H + +#include + +namespace PartGui { + +class WorkbenchManipulator: public Gui::WorkbenchManipulator +{ +protected: + /*! + * \brief modifyMenuBar + * Method to manipulate the menu structure of a workbench. + * The default implementation doesn't change anything.SectionCut + */ + void modifyMenuBar(Gui::MenuItem* menuBar) override; + /*! + * \brief modifyContextMenu + * Method to manipulate the contextmenu structure of a workbench. + * The default implementation doesn't change anything. + */ + void modifyContextMenu(const char* recipient, Gui::MenuItem* menuBar) override; + /*! + * \brief modifyToolBars + * Method to manipulate the toolbar structure of a workbench + * The default implementation doesn't change anything. + */ + void modifyToolBars([[maybe_unused]] Gui::ToolBarItem* toolBar) override; + /*! + * \brief modifyDockWindows + * Method to manipulate the dock window structure of a workbench + * The default implementation doesn't change anything. + */ + void modifyDockWindows([[maybe_unused]] Gui::DockWindowItems* dockWindow) override; +}; + +} // namespace PartGui + + +#endif // PARTGUI_WORKBENCHMANIPULATOR_H