From 858e59fabfd3c90754b512387f46aec058dafb13 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 30 Jun 2024 12:38:45 +0200 Subject: [PATCH 01/15] Sketcher: Fix format string in ExternalGeometryFacade::initExtensions() The format string of the warnings were incorrect and caused an fmt::format_error exception --- src/Mod/Sketcher/App/ExternalGeometryFacade.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mod/Sketcher/App/ExternalGeometryFacade.cpp b/src/Mod/Sketcher/App/ExternalGeometryFacade.cpp index 6cc6efaac8..152e10bd2b 100644 --- a/src/Mod/Sketcher/App/ExternalGeometryFacade.cpp +++ b/src/Mod/Sketcher/App/ExternalGeometryFacade.cpp @@ -91,7 +91,7 @@ void ExternalGeometryFacade::initExtensions() getGeo()->setExtension(std::make_unique()); // Create getExtension - Base::Console().Warning("%s\nSketcher External Geometry without Geometry Extension: %s \n", + Base::Console().Warning("Sketcher External Geometry without Geometry Extension: %s \n", boost::uuids::to_string(Geo->getTag()).c_str()); } @@ -101,7 +101,7 @@ void ExternalGeometryFacade::initExtensions() std::make_unique()); // Create getExtension Base::Console().Warning( - "%s\nSketcher External Geometry without ExternalGeometryExtension: %s \n", + "Sketcher External Geometry without ExternalGeometryExtension: %s \n", boost::uuids::to_string(Geo->getTag()).c_str()); } From 0e8752448b2cbdc205f7c36d1f8dec29eff95d7b Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 2 Jul 2024 17:24:23 +0200 Subject: [PATCH 02/15] Start: Make the Start Page a passive view Do not attach the Start Page to an existing document as otherwise weird behaviour can be observed: 1. Start FreeCAD 2. Open a project file or data file 3. Open the Start Page 4. Make a change to the document 5. Close the document. You won't be asked to save your change 6. In the tree view the document is still shown because the Start Page is attached to the document 7. Close the Start Page. Now you will be asked to save your change --- src/Mod/Start/Gui/Manipulator.cpp | 3 +-- src/Mod/Start/Gui/StartView.cpp | 4 ++-- src/Mod/Start/Gui/StartView.h | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Mod/Start/Gui/Manipulator.cpp b/src/Mod/Start/Gui/Manipulator.cpp index 1682bb9cda..03522ada4e 100644 --- a/src/Mod/Start/Gui/Manipulator.cpp +++ b/src/Mod/Start/Gui/Manipulator.cpp @@ -56,10 +56,9 @@ void CmdStart::activated(int iMsg) { Q_UNUSED(iMsg); auto mw = Gui::getMainWindow(); - auto doc = Gui::Application::Instance->activeDocument(); auto existingView = mw->findChild(QLatin1String("StartView")); if (!existingView) { - existingView = gsl::owner(new StartGui::StartView(doc, mw)); + existingView = gsl::owner(new StartGui::StartView(mw)); mw->addWindow(existingView); // Transfers ownership } Gui::getMainWindow()->setActiveWindow(existingView); diff --git a/src/Mod/Start/Gui/StartView.cpp b/src/Mod/Start/Gui/StartView.cpp index 432c469bea..5232c55ad3 100644 --- a/src/Mod/Start/Gui/StartView.cpp +++ b/src/Mod/Start/Gui/StartView.cpp @@ -100,8 +100,8 @@ gsl::owner createNewButton(const NewButton& newButton) } // namespace -StartView::StartView(Gui::Document* pcDocument, QWidget* parent) - : Gui::MDIView(pcDocument, parent) +StartView::StartView(QWidget* parent) + : Gui::MDIView(nullptr, parent) , _contents(new QScrollArea(parent)) , _newFileLabel {nullptr} , _examplesLabel {nullptr} diff --git a/src/Mod/Start/Gui/StartView.h b/src/Mod/Start/Gui/StartView.h index 33beea9980..fe2d33167c 100644 --- a/src/Mod/Start/Gui/StartView.h +++ b/src/Mod/Start/Gui/StartView.h @@ -54,7 +54,7 @@ class StartGuiExport StartView: public Gui::MDIView TYPESYSTEM_HEADER_WITH_OVERRIDE(); // NOLINT public: - StartView(Gui::Document* pcDocument, QWidget* parent); + StartView(QWidget* parent); const char* getName() const override { From 30d8a74ce7421a1ded9d5ce1e7340d596f328c6d Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 2 Jul 2024 11:18:00 +0200 Subject: [PATCH 03/15] Gui: Fix crash when trying to calibrate image after document is closed --- src/Gui/TaskView/TaskImage.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/Gui/TaskView/TaskImage.cpp b/src/Gui/TaskView/TaskImage.cpp index 0480fd8aa1..1e2cbaf509 100644 --- a/src/Gui/TaskView/TaskImage.cpp +++ b/src/Gui/TaskView/TaskImage.cpp @@ -204,16 +204,20 @@ void TaskImage::scaleImage(double factor) void TaskImage::startScale() { - scale->activate(); - ui->pushButtonScale->hide(); - ui->groupBoxCalibration->show(); - ui->pushButtonApply->setEnabled(false); + if (scale) { + scale->activate(); + ui->pushButtonScale->hide(); + ui->groupBoxCalibration->show(); + ui->pushButtonApply->setEnabled(false); + } } void TaskImage::acceptScale() { - scaleImage(scale->getScaleFactor()); - rejectScale(); + if (scale) { + scaleImage(scale->getScaleFactor()); + rejectScale(); + } } void TaskImage::enableApplyBtn() @@ -223,9 +227,11 @@ void TaskImage::enableApplyBtn() void TaskImage::rejectScale() { - scale->deactivate(); - ui->pushButtonScale->show(); - ui->groupBoxCalibration->hide(); + if (scale) { + scale->deactivate(); + ui->pushButtonScale->show(); + ui->groupBoxCalibration->hide(); + } } void TaskImage::onInteractiveScale() From f5a87bc620930937890514c3b3780d4124e80f5b Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 27 Jun 2024 15:59:31 +0200 Subject: [PATCH 04/15] Spreadsheet: Fix SheetPython::getViewProviderName() to return the correct type name For more details see: https://forum.freecad.org/viewtopic.php?t=88642 --- src/Mod/Spreadsheet/App/Sheet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Spreadsheet/App/Sheet.cpp b/src/Mod/Spreadsheet/App/Sheet.cpp index e730ca29f0..241bdf30e9 100644 --- a/src/Mod/Spreadsheet/App/Sheet.cpp +++ b/src/Mod/Spreadsheet/App/Sheet.cpp @@ -1785,7 +1785,7 @@ PROPERTY_SOURCE_TEMPLATE(Spreadsheet::SheetPython, Spreadsheet::Sheet) template<> const char* Spreadsheet::SheetPython::getViewProviderName() const { - return "SpreadsheetGui::ViewProviderSheet"; + return "SpreadsheetGui::ViewProviderSheetPython"; } template<> PyObject* Spreadsheet::SheetPython::getPyObject() From 876e88f405ad858f970f5de87543dbe3386e5f3c Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 27 Jun 2024 18:35:40 +0200 Subject: [PATCH 05/15] Gui: Fix crash in QuarterWidgetP::removeFromCacheContext Fixes #https://github.com/FreeCAD/FreeCAD/issues/14988 --- src/Gui/Quarter/QuarterWidgetP.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Gui/Quarter/QuarterWidgetP.cpp b/src/Gui/Quarter/QuarterWidgetP.cpp index 5f3267e5c8..7771c4b79b 100644 --- a/src/Gui/Quarter/QuarterWidgetP.cpp +++ b/src/Gui/Quarter/QuarterWidgetP.cpp @@ -169,13 +169,22 @@ QuarterWidgetP::removeFromCacheContext(QuarterWidgetP_cachecontext * context, co for (int i = 0; i < cachecontext_list->getLength(); i++) { if ((*cachecontext_list)[i] == context) { - // set the context while calling destructingContext() (might trigger OpenGL calls) - const_cast (widget)->makeCurrent(); - // fetch the cc_glglue context instance as a workaround for a bug fixed in Coin r12818 - (void) cc_glglue_instance(context->id); + QtGLContext* glcontext = widget->context(); + if (glcontext) { + // set the context while calling destructingContext() (might trigger OpenGL calls) + if (glcontext->isValid()) { + const_cast (widget)->makeCurrent(); + } + // fetch the cc_glglue context instance as a workaround for a bug fixed in Coin r12818 + (void) cc_glglue_instance(context->id); + } cachecontext_list->removeFast(i); SoContextHandler::destructingContext(context->id); - const_cast (widget)->doneCurrent(); + if (glcontext) { + if (glcontext->isValid()) { + const_cast (widget)->doneCurrent(); + } + } delete context; return; } From 535faeb297a375e4df436483cbe3ea33e8a4664d Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 28 Jun 2024 15:08:02 +0200 Subject: [PATCH 06/15] Mesh: Use a lower threshold for the MeshPart_SectionByPlane command See forum: https://forum.freecad.org/viewtopic.php?t=88734 --- src/Mod/MeshPart/Gui/Command.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Mod/MeshPart/Gui/Command.cpp b/src/Mod/MeshPart/Gui/Command.cpp index 9e3b6cb0c5..1934ad5b25 100644 --- a/src/Mod/MeshPart/Gui/Command.cpp +++ b/src/Mod/MeshPart/Gui/Command.cpp @@ -230,7 +230,8 @@ void CmdMeshPartSection::activated(int) for (auto it : docObj) { const Mesh::MeshObject* mesh = static_cast(it)->Mesh.getValuePtr(); std::vector polylines; - mesh->crossSections(sections, polylines); + const float minSectionLength = 1e-7F; + mesh->crossSections(sections, polylines, minSectionLength); for (const auto& it2 : polylines) { for (const auto& it3 : it2) { From 3666215f8b13ca7fd32b0d40c12ad91712d77d1d Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 28 Jun 2024 15:09:19 +0200 Subject: [PATCH 07/15] Mesh: Do one import per line for the recorded macro --- src/Mod/Mesh/Gui/Command.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Mod/Mesh/Gui/Command.cpp b/src/Mod/Mesh/Gui/Command.cpp index c086afbf9b..19d9360d72 100644 --- a/src/Mod/Mesh/Gui/Command.cpp +++ b/src/Mod/Mesh/Gui/Command.cpp @@ -904,8 +904,10 @@ CmdMeshTrimByPlane::CmdMeshTrimByPlane() void CmdMeshTrimByPlane::activated(int) { - doCommand(Doc, - "import MeshPartGui, FreeCADGui\nFreeCADGui.runCommand('MeshPart_TrimByPlane')\n"); + const char* cmd = "import MeshPartGui\n" + "import FreeCADGui\n" + "FreeCADGui.runCommand('MeshPart_TrimByPlane')\n"; + runCommand(Doc, cmd); } bool CmdMeshTrimByPlane::isActive() @@ -935,8 +937,10 @@ CmdMeshSectionByPlane::CmdMeshSectionByPlane() void CmdMeshSectionByPlane::activated(int) { - doCommand(Doc, - "import MeshPartGui, FreeCADGui\nFreeCADGui.runCommand('MeshPart_SectionByPlane')\n"); + const char* cmd = "import MeshPartGui\n" + "import FreeCADGui\n" + "FreeCADGui.runCommand('MeshPart_SectionByPlane')\n"; + runCommand(Doc, cmd); } bool CmdMeshSectionByPlane::isActive() @@ -966,8 +970,10 @@ CmdMeshCrossSections::CmdMeshCrossSections() void CmdMeshCrossSections::activated(int) { - doCommand(Doc, - "import MeshPartGui, FreeCADGui\nFreeCADGui.runCommand('MeshPart_CrossSections')\n"); + const char* cmd = "import MeshPartGui\n" + "import FreeCADGui\n" + "FreeCADGui.runCommand('MeshPart_CrossSections')\n"; + runCommand(Doc, cmd); } bool CmdMeshCrossSections::isActive() From aac8bdd7bcc0d58fa2ac9f71e1e67fae48b2b05e Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 29 Jun 2024 12:35:56 +0200 Subject: [PATCH 08/15] Fixes #14772: Random color problem --- src/Gui/CommandFeat.cpp | 17 ++++++++++++----- src/Mod/PartDesign/Gui/ViewProviderBody.cpp | 1 - 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Gui/CommandFeat.cpp b/src/Gui/CommandFeat.cpp index dfee930f48..730b77394e 100644 --- a/src/Gui/CommandFeat.cpp +++ b/src/Gui/CommandFeat.cpp @@ -25,8 +25,9 @@ #ifndef _PreComp_ #endif -#include +#include #include +#include #include "Application.h" #include "CommandT.h" #include "DockWindowManager.h" @@ -116,6 +117,10 @@ void StdCmdRandomColor::activated(int iMsg) } }; + auto allowToChangeColor = [](const App::DocumentObject* obj) { + return (obj->isDerivedFrom() || obj->isDerivedFrom()); + }; + // get the complete selection std::vector sel = Selection().getCompleteSelection(); @@ -125,10 +130,12 @@ void StdCmdRandomColor::activated(int iMsg) setRandomColor(view); if (auto grp = it.pObject->getExtension()) { - std::vector objs = grp->getObjects(); - for (auto obj : objs) { - ViewProvider* view = Application::Instance->getViewProvider(obj); - setRandomColor(view); + if (allowToChangeColor(it.pObject)) { + std::vector objs = grp->getObjects(); + for (auto obj : objs) { + ViewProvider* view = Application::Instance->getViewProvider(obj); + setRandomColor(view); + } } } } diff --git a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp index aa78a19e97..79947520cf 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp @@ -427,7 +427,6 @@ void ViewProviderBody::unifyVisualProperty(const App::Property* prop) { if (prop == &Visibility || prop == &Selectable || prop == &DisplayModeBody || - prop == &ShapeAppearance || prop == &PointColorArray || prop == &LineColorArray) { return; From 0af1ec2cf346244cce35851113c0da6efbedb1a4 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 3 Jul 2024 09:54:11 +0200 Subject: [PATCH 09/15] PD: Do not set hard-coded maximum for thickness parameter Fixes #15140: Thickness value Task panel issue --- src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp index 5edc2a807a..b340c106f1 100644 --- a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp @@ -58,7 +58,6 @@ TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpVie double a = pcThickness->Value.getValue(); ui->Value->setMinimum(0.0); - ui->Value->setMaximum(89.99); ui->Value->setValue(a); ui->Value->selectAll(); QMetaObject::invokeMethod(ui->Value, "setFocus", Qt::QueuedConnection); From 7c0ecac58046d5e97b979107f04138508f654c61 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 3 Jul 2024 10:08:16 +0200 Subject: [PATCH 10/15] PD: Fix linter warnings in TaskThicknessParameters --- .../Gui/TaskThicknessParameters.cpp | 53 +++++++------------ 1 file changed, 19 insertions(+), 34 deletions(-) diff --git a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp index b340c106f1..cb008d5eb5 100644 --- a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp @@ -54,7 +54,7 @@ TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpVie ui->setupUi(proxy); this->groupLayout()->addWidget(proxy); - PartDesign::Thickness* pcThickness = static_cast(DressUpView->getObject()); + auto pcThickness = dynamic_cast(DressUpView->getObject()); double a = pcThickness->Value.getValue(); ui->Value->setMinimum(0.0); @@ -103,23 +103,22 @@ TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpVie connect(ui->listWidgetReferences, &QListWidget::itemDoubleClicked, this, &TaskThicknessParameters::doubleClicked); - int mode = pcThickness->Mode.getValue(); + int mode = static_cast(pcThickness->Mode.getValue()); ui->modeComboBox->setCurrentIndex(mode); - int join = pcThickness->Join.getValue(); + int join = static_cast(pcThickness->Join.getValue()); ui->joinComboBox->setCurrentIndex(join); - if (strings.size() == 0) + if (strings.empty()) { setSelectionMode(refSel); - else + } + else { hideOnError(); + } } void TaskThicknessParameters::onSelectionChanged(const Gui::SelectionChanges& msg) { - // executed when the user selected something in the CAD object - // adds/deletes the selection accordingly - if (msg.Type == Gui::SelectionChanges::AddSelection) { if (selectionMode == refSel) { referenceSelected(msg, ui->listWidgetReferences); @@ -141,7 +140,7 @@ void TaskThicknessParameters::onRefDeleted() void TaskThicknessParameters::onValueChanged(double angle) { setButtons(none); - PartDesign::Thickness* pcThickness = static_cast(DressUpView->getObject()); + auto pcThickness = dynamic_cast(DressUpView->getObject()); setupTransaction(); pcThickness->Value.setValue(angle); pcThickness->getDocument()->recomputeFeature(pcThickness); @@ -152,7 +151,7 @@ void TaskThicknessParameters::onValueChanged(double angle) void TaskThicknessParameters::onJoinTypeChanged(int join) { setButtons(none); - PartDesign::Thickness* pcThickness = static_cast(DressUpView->getObject()); + auto pcThickness = dynamic_cast(DressUpView->getObject()); setupTransaction(); pcThickness->Join.setValue(join); pcThickness->getDocument()->recomputeFeature(pcThickness); @@ -163,7 +162,7 @@ void TaskThicknessParameters::onJoinTypeChanged(int join) { void TaskThicknessParameters::onModeChanged(int mode) { setButtons(none); - PartDesign::Thickness* pcThickness = static_cast(DressUpView->getObject()); + auto pcThickness = dynamic_cast(DressUpView->getObject()); setupTransaction(); pcThickness->Mode.setValue(mode); pcThickness->getDocument()->recomputeFeature(pcThickness); @@ -178,7 +177,7 @@ double TaskThicknessParameters::getValue() const void TaskThicknessParameters::onReversedChanged(const bool on) { setButtons(none); - PartDesign::Thickness* pcThickness = static_cast(DressUpView->getObject()); + auto pcThickness = dynamic_cast(DressUpView->getObject()); setupTransaction(); pcThickness->Reversed.setValue(on); pcThickness->getDocument()->recomputeFeature(pcThickness); @@ -191,9 +190,10 @@ bool TaskThicknessParameters::getReversed() const return ui->checkReverse->isChecked(); } -void TaskThicknessParameters::onIntersectionChanged(const bool on) { +void TaskThicknessParameters::onIntersectionChanged(const bool on) +{ setButtons(none); - PartDesign::Thickness* pcThickness = static_cast(DressUpView->getObject()); + auto pcThickness = dynamic_cast(DressUpView->getObject()); pcThickness->Intersection.setValue(on); pcThickness->getDocument()->recomputeFeature(pcThickness); // hide the thickness if there was a computation error @@ -243,8 +243,9 @@ void TaskThicknessParameters::changeEvent(QEvent *e) void TaskThicknessParameters::apply() { //Alert user if he created an empty feature - if (ui->listWidgetReferences->count() == 0) + if (ui->listWidgetReferences->count() == 0) { Base::Console().Warning(tr("Empty thickness created !\n").toStdString().c_str()); + } } //************************************************************************** @@ -262,32 +263,16 @@ TaskDlgThicknessParameters::TaskDlgThicknessParameters(ViewProviderThickness *Dr TaskDlgThicknessParameters::~TaskDlgThicknessParameters() = default; -//==== calls from the TaskView =============================================================== - - -//void TaskDlgThicknessParameters::open() -//{ -// // a transaction is already open at creation time of the draft -// if (!Gui::Command::hasPendingCommand()) { -// QString msg = QObject::tr("Edit draft"); -// Gui::Command::openCommand((const char*)msg.toUtf8()); -// } -//} -// -//void TaskDlgThicknessParameters::clicked(int) -//{ -// -//} - bool TaskDlgThicknessParameters::accept() { auto obj = vp->getObject(); - if (!obj->isError()) + if (!obj->isError()) { parameter->showObject(); + } parameter->apply(); - TaskThicknessParameters* draftparameter = static_cast(parameter); + auto draftparameter = dynamic_cast(parameter); FCMD_OBJ_CMD(obj,"Value = " << draftparameter->getValue()); FCMD_OBJ_CMD(obj,"Reversed = " << draftparameter->getReversed()); From 610e1d67adc6b5295b5620b9316c8b8bd099317b Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 3 Jul 2024 11:00:33 +0200 Subject: [PATCH 11/15] PD: Refactor TaskThicknessParameters --- .../Gui/TaskThicknessParameters.cpp | 101 ++++++++++-------- .../PartDesign/Gui/TaskThicknessParameters.h | 16 ++- 2 files changed, 69 insertions(+), 48 deletions(-) diff --git a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp index cb008d5eb5..2cc056893f 100644 --- a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp @@ -48,12 +48,21 @@ using namespace Gui; TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpView, QWidget *parent) : TaskDressUpParameters(DressUpView, false, true, parent) , ui(new Ui_TaskThicknessParameters) +{ + addContainerWidget(); + initControls(); +} + +void TaskThicknessParameters::addContainerWidget() { // we need a separate container widget to add all controls to proxy = new QWidget(this); ui->setupUi(proxy); this->groupLayout()->addWidget(proxy); +} +void TaskThicknessParameters::initControls() +{ auto pcThickness = dynamic_cast(DressUpView->getObject()); double a = pcThickness->Value.getValue(); @@ -77,6 +86,24 @@ TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpVie ui->listWidgetReferences->addItem(QString::fromStdString(string)); } + setupConnections(); + + int mode = static_cast(pcThickness->Mode.getValue()); + ui->modeComboBox->setCurrentIndex(mode); + + int join = static_cast(pcThickness->Join.getValue()); + ui->joinComboBox->setCurrentIndex(join); + + if (strings.empty()) { + setSelectionMode(refSel); + } + else { + hideOnError(); + } +} + +void TaskThicknessParameters::setupConnections() +{ QMetaObject::connectSlotsByName(this); connect(ui->Value, qOverload(&Gui::QuantitySpinBox::valueChanged), @@ -102,19 +129,6 @@ TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpVie this, &TaskThicknessParameters::setSelection); connect(ui->listWidgetReferences, &QListWidget::itemDoubleClicked, this, &TaskThicknessParameters::doubleClicked); - - int mode = static_cast(pcThickness->Mode.getValue()); - ui->modeComboBox->setCurrentIndex(mode); - - int join = static_cast(pcThickness->Join.getValue()); - ui->joinComboBox->setCurrentIndex(join); - - if (strings.empty()) { - setSelectionMode(refSel); - } - else { - hideOnError(); - } } void TaskThicknessParameters::onSelectionChanged(const Gui::SelectionChanges& msg) @@ -137,37 +151,39 @@ void TaskThicknessParameters::onRefDeleted() TaskDressUpParameters::deleteRef(ui->listWidgetReferences); } -void TaskThicknessParameters::onValueChanged(double angle) +PartDesign::Thickness* TaskThicknessParameters::onBeforeChange() { setButtons(none); - auto pcThickness = dynamic_cast(DressUpView->getObject()); setupTransaction(); - pcThickness->Value.setValue(angle); - pcThickness->getDocument()->recomputeFeature(pcThickness); + return dynamic_cast(DressUpView->getObject()); +} + +void TaskThicknessParameters::onAfterChange(PartDesign::Thickness* obj) +{ + obj->recomputeFeature(); // hide the thickness if there was a computation error hideOnError(); } +void TaskThicknessParameters::onValueChanged(double angle) +{ + PartDesign::Thickness* thickness = onBeforeChange(); + thickness->Value.setValue(angle); + onAfterChange(thickness); +} + void TaskThicknessParameters::onJoinTypeChanged(int join) { - setButtons(none); - auto pcThickness = dynamic_cast(DressUpView->getObject()); - setupTransaction(); - pcThickness->Join.setValue(join); - pcThickness->getDocument()->recomputeFeature(pcThickness); - // hide the thickness if there was a computation error - hideOnError(); + PartDesign::Thickness* thickness = onBeforeChange(); + thickness->Join.setValue(join); + onAfterChange(thickness); } void TaskThicknessParameters::onModeChanged(int mode) { - setButtons(none); - auto pcThickness = dynamic_cast(DressUpView->getObject()); - setupTransaction(); - pcThickness->Mode.setValue(mode); - pcThickness->getDocument()->recomputeFeature(pcThickness); - // hide the thickness if there was a computation error - hideOnError(); + PartDesign::Thickness* thickness = onBeforeChange(); + thickness->Mode.setValue(mode); + onAfterChange(thickness); } double TaskThicknessParameters::getValue() const @@ -175,14 +191,10 @@ double TaskThicknessParameters::getValue() const return ui->Value->value().getValue(); } -void TaskThicknessParameters::onReversedChanged(const bool on) { - setButtons(none); - auto pcThickness = dynamic_cast(DressUpView->getObject()); - setupTransaction(); - pcThickness->Reversed.setValue(on); - pcThickness->getDocument()->recomputeFeature(pcThickness); - // hide the thickness if there was a computation error - hideOnError(); +void TaskThicknessParameters::onReversedChanged(bool on) { + PartDesign::Thickness* thickness = onBeforeChange(); + thickness->Reversed.setValue(on); + onAfterChange(thickness); } bool TaskThicknessParameters::getReversed() const @@ -190,14 +202,11 @@ bool TaskThicknessParameters::getReversed() const return ui->checkReverse->isChecked(); } -void TaskThicknessParameters::onIntersectionChanged(const bool on) +void TaskThicknessParameters::onIntersectionChanged(bool on) { - setButtons(none); - auto pcThickness = dynamic_cast(DressUpView->getObject()); - pcThickness->Intersection.setValue(on); - pcThickness->getDocument()->recomputeFeature(pcThickness); - // hide the thickness if there was a computation error - hideOnError(); + PartDesign::Thickness* thickness = onBeforeChange(); + thickness->Intersection.setValue(on); + onAfterChange(thickness); } bool TaskThicknessParameters::getIntersection() const diff --git a/src/Mod/PartDesign/Gui/TaskThicknessParameters.h b/src/Mod/PartDesign/Gui/TaskThicknessParameters.h index 7d16706a98..00ac520a7c 100644 --- a/src/Mod/PartDesign/Gui/TaskThicknessParameters.h +++ b/src/Mod/PartDesign/Gui/TaskThicknessParameters.h @@ -29,6 +29,11 @@ class Ui_TaskThicknessParameters; +namespace PartDesign +{ +class Thickness; +} + namespace PartDesignGui { class TaskThicknessParameters : public TaskDressUpParameters @@ -51,8 +56,8 @@ private Q_SLOTS: void onValueChanged(double angle); void onModeChanged(int mode); void onJoinTypeChanged(int join); - void onReversedChanged(bool reversed); - void onIntersectionChanged(bool intersection); + void onReversedChanged(bool on); + void onIntersectionChanged(bool on); void onRefDeleted() override; protected: @@ -61,6 +66,13 @@ protected: void changeEvent(QEvent *e) override; void onSelectionChanged(const Gui::SelectionChanges& msg) override; +private: + void addContainerWidget(); + void initControls(); + void setupConnections(); + PartDesign::Thickness* onBeforeChange(); + void onAfterChange(PartDesign::Thickness* obj); + private: std::unique_ptr ui; }; From 7a9fd501c3ea0e259f843dc21f488ef6af43c201 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 3 Jul 2024 11:03:09 +0200 Subject: [PATCH 12/15] PD: Reformat TaskThicknessParameters --- .../Gui/TaskThicknessParameters.cpp | 68 ++++++++++--------- .../PartDesign/Gui/TaskThicknessParameters.h | 23 ++++--- 2 files changed, 49 insertions(+), 42 deletions(-) diff --git a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp index 2cc056893f..05624eb89e 100644 --- a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp @@ -24,9 +24,9 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include +#include +#include +#include #endif #include @@ -45,7 +45,7 @@ using namespace Gui; /* TRANSLATOR PartDesignGui::TaskThicknessParameters */ -TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpView, QWidget *parent) +TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp* DressUpView, QWidget* parent) : TaskDressUpParameters(DressUpView, false, true, parent) , ui(new Ui_TaskThicknessParameters) { @@ -81,8 +81,7 @@ void TaskThicknessParameters::initControls() ui->checkIntersection->setChecked(i); std::vector strings = pcThickness->Base.getSubValues(); - for (const auto & string : strings) - { + for (const auto& string : strings) { ui->listWidgetReferences->addItem(QString::fromStdString(string)); } @@ -104,31 +103,33 @@ void TaskThicknessParameters::initControls() void TaskThicknessParameters::setupConnections() { + // clang-format off QMetaObject::connectSlotsByName(this); connect(ui->Value, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &TaskThicknessParameters::onValueChanged); + this, &TaskThicknessParameters::onValueChanged); connect(ui->checkReverse, &QCheckBox::toggled, - this, &TaskThicknessParameters::onReversedChanged); + this, &TaskThicknessParameters::onReversedChanged); connect(ui->checkIntersection, &QCheckBox::toggled, - this, &TaskThicknessParameters::onIntersectionChanged); + this, &TaskThicknessParameters::onIntersectionChanged); connect(ui->buttonRefSel, &QToolButton::toggled, - this, &TaskThicknessParameters::onButtonRefSel); + this, &TaskThicknessParameters::onButtonRefSel); connect(ui->modeComboBox, qOverload(&QComboBox::currentIndexChanged), - this, &TaskThicknessParameters::onModeChanged); + this, &TaskThicknessParameters::onModeChanged); connect(ui->joinComboBox, qOverload(&QComboBox::currentIndexChanged), - this, &TaskThicknessParameters::onJoinTypeChanged); + this, &TaskThicknessParameters::onJoinTypeChanged); // Create context menu createDeleteAction(ui->listWidgetReferences); connect(deleteAction, &QAction::triggered, this, &TaskThicknessParameters::onRefDeleted); connect(ui->listWidgetReferences, &QListWidget::currentItemChanged, - this, &TaskThicknessParameters::setSelection); + this, &TaskThicknessParameters::setSelection); connect(ui->listWidgetReferences, &QListWidget::itemClicked, - this, &TaskThicknessParameters::setSelection); + this, &TaskThicknessParameters::setSelection); connect(ui->listWidgetReferences, &QListWidget::itemDoubleClicked, - this, &TaskThicknessParameters::doubleClicked); + this, &TaskThicknessParameters::doubleClicked); + // clang-format on } void TaskThicknessParameters::onSelectionChanged(const Gui::SelectionChanges& msg) @@ -172,14 +173,16 @@ void TaskThicknessParameters::onValueChanged(double angle) onAfterChange(thickness); } -void TaskThicknessParameters::onJoinTypeChanged(int join) { +void TaskThicknessParameters::onJoinTypeChanged(int join) +{ PartDesign::Thickness* thickness = onBeforeChange(); thickness->Join.setValue(join); onAfterChange(thickness); } -void TaskThicknessParameters::onModeChanged(int mode) { +void TaskThicknessParameters::onModeChanged(int mode) +{ PartDesign::Thickness* thickness = onBeforeChange(); thickness->Mode.setValue(mode); @@ -191,7 +194,8 @@ double TaskThicknessParameters::getValue() const return ui->Value->value().getValue(); } -void TaskThicknessParameters::onReversedChanged(bool on) { +void TaskThicknessParameters::onReversedChanged(bool on) +{ PartDesign::Thickness* thickness = onBeforeChange(); thickness->Reversed.setValue(on); onAfterChange(thickness); @@ -214,12 +218,14 @@ bool TaskThicknessParameters::getIntersection() const return ui->checkIntersection->isChecked(); } -int TaskThicknessParameters::getJoinType() const { +int TaskThicknessParameters::getJoinType() const +{ return ui->joinComboBox->currentIndex(); } -int TaskThicknessParameters::getMode() const { +int TaskThicknessParameters::getMode() const +{ return ui->modeComboBox->currentIndex(); } @@ -231,17 +237,17 @@ TaskThicknessParameters::~TaskThicknessParameters() Gui::Selection().rmvSelectionGate(); } catch (const Py::Exception&) { - Base::PyException e; // extract the Python error text + Base::PyException e; // extract the Python error text e.ReportException(); } } -bool TaskThicknessParameters::event(QEvent *e) +bool TaskThicknessParameters::event(QEvent* e) { return TaskDressUpParameters::KeyEvent(e); } -void TaskThicknessParameters::changeEvent(QEvent *e) +void TaskThicknessParameters::changeEvent(QEvent* e) { TaskBox::changeEvent(e); if (e->type() == QEvent::LanguageChange) { @@ -251,7 +257,7 @@ void TaskThicknessParameters::changeEvent(QEvent *e) void TaskThicknessParameters::apply() { - //Alert user if he created an empty feature + // Alert user if he created an empty feature if (ui->listWidgetReferences->count() == 0) { Base::Console().Warning(tr("Empty thickness created !\n").toStdString().c_str()); } @@ -262,10 +268,10 @@ void TaskThicknessParameters::apply() // TaskDialog //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -TaskDlgThicknessParameters::TaskDlgThicknessParameters(ViewProviderThickness *DressUpView) +TaskDlgThicknessParameters::TaskDlgThicknessParameters(ViewProviderThickness* DressUpView) : TaskDlgDressUpParameters(DressUpView) { - parameter = new TaskThicknessParameters(DressUpView); + parameter = new TaskThicknessParameters(DressUpView); Content.push_back(parameter); } @@ -283,11 +289,11 @@ bool TaskDlgThicknessParameters::accept() auto draftparameter = dynamic_cast(parameter); - FCMD_OBJ_CMD(obj,"Value = " << draftparameter->getValue()); - FCMD_OBJ_CMD(obj,"Reversed = " << draftparameter->getReversed()); - FCMD_OBJ_CMD(obj,"Mode = " << draftparameter->getMode()); - FCMD_OBJ_CMD(obj,"Intersection = " << draftparameter->getIntersection()); - FCMD_OBJ_CMD(obj,"Join = " << draftparameter->getJoinType()); + FCMD_OBJ_CMD(obj, "Value = " << draftparameter->getValue()); + FCMD_OBJ_CMD(obj, "Reversed = " << draftparameter->getReversed()); + FCMD_OBJ_CMD(obj, "Mode = " << draftparameter->getMode()); + FCMD_OBJ_CMD(obj, "Intersection = " << draftparameter->getIntersection()); + FCMD_OBJ_CMD(obj, "Join = " << draftparameter->getJoinType()); return TaskDlgDressUpParameters::accept(); } diff --git a/src/Mod/PartDesign/Gui/TaskThicknessParameters.h b/src/Mod/PartDesign/Gui/TaskThicknessParameters.h index 00ac520a7c..35c2194044 100644 --- a/src/Mod/PartDesign/Gui/TaskThicknessParameters.h +++ b/src/Mod/PartDesign/Gui/TaskThicknessParameters.h @@ -34,14 +34,15 @@ namespace PartDesign class Thickness; } -namespace PartDesignGui { +namespace PartDesignGui +{ -class TaskThicknessParameters : public TaskDressUpParameters +class TaskThicknessParameters: public TaskDressUpParameters { Q_OBJECT public: - explicit TaskThicknessParameters(ViewProviderDressUp *DressUpView, QWidget *parent=nullptr); + explicit TaskThicknessParameters(ViewProviderDressUp* DressUpView, QWidget* parent = nullptr); ~TaskThicknessParameters() override; void apply() override; @@ -49,8 +50,8 @@ public: double getValue() const; bool getReversed() const; bool getIntersection() const; - int getMode() const; - int getJoinType() const; + int getMode() const; + int getJoinType() const; private Q_SLOTS: void onValueChanged(double angle); @@ -62,8 +63,8 @@ private Q_SLOTS: protected: void setButtons(const selectionModes mode) override; - bool event(QEvent *e) override; - void changeEvent(QEvent *e) override; + bool event(QEvent* e) override; + void changeEvent(QEvent* e) override; void onSelectionChanged(const Gui::SelectionChanges& msg) override; private: @@ -78,12 +79,12 @@ private: }; /// simulation dialog for the TaskView -class TaskDlgThicknessParameters : public TaskDlgDressUpParameters +class TaskDlgThicknessParameters: public TaskDlgDressUpParameters { Q_OBJECT public: - explicit TaskDlgThicknessParameters(ViewProviderThickness *ThicknessView); + explicit TaskDlgThicknessParameters(ViewProviderThickness* ThicknessView); ~TaskDlgThicknessParameters() override; public: @@ -91,6 +92,6 @@ public: bool accept() override; }; -} //namespace PartDesignGui +} // namespace PartDesignGui -#endif // GUI_TASKVIEW_TASKAPPERANCE_H +#endif // GUI_TASKVIEW_TASKAPPERANCE_H From a77d6b8a385087b085c05841c0f64eb2cf4f29e7 Mon Sep 17 00:00:00 2001 From: FEA-eng <59876896+FEA-eng@users.noreply.github.com> Date: Thu, 4 Jul 2024 20:08:15 +0200 Subject: [PATCH 13/15] PD: Update Workbench.cpp --- src/Mod/PartDesign/Gui/Workbench.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/PartDesign/Gui/Workbench.cpp b/src/Mod/PartDesign/Gui/Workbench.cpp index 651c1fae1e..3cfec4eb6b 100644 --- a/src/Mod/PartDesign/Gui/Workbench.cpp +++ b/src/Mod/PartDesign/Gui/Workbench.cpp @@ -572,7 +572,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const << "Separator" << "Part_CheckGeometry" << "Separator" - << "PartDesign_Migrate" + // << "PartDesign_Migrate" << "PartDesign_Sprocket"; // For 0.13 a couple of python packages like numpy, matplotlib and others From 7ab2b92fc82b1e6cdd7c6ee03dbc59dc85729d50 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 5 Jul 2024 11:38:09 +0200 Subject: [PATCH 14/15] Gui: Don't show Python console by default Fixes #15201 --- src/Gui/Workbench.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Gui/Workbench.cpp b/src/Gui/Workbench.cpp index e4ca175b20..11fbdc2a5a 100644 --- a/src/Gui/Workbench.cpp +++ b/src/Gui/Workbench.cpp @@ -853,15 +853,13 @@ ToolBarItem* StdWorkbench::setupCommandBars() const DockWindowItems* StdWorkbench::setupDockWindows() const { auto root = new DockWindowItems(); - root->addDockWidget("Std_ToolBox", Qt::RightDockWidgetArea, false, false); - //root->addDockWidget("Std_HelpView", Qt::RightDockWidgetArea, true, false); root->addDockWidget("Std_TreeView", Qt::LeftDockWidgetArea, true, false); root->addDockWidget("Std_PropertyView", Qt::LeftDockWidgetArea, true, false); root->addDockWidget("Std_SelectionView", Qt::LeftDockWidgetArea, false, false); root->addDockWidget("Std_ComboView", Qt::LeftDockWidgetArea, true, true); root->addDockWidget("Std_TaskView", Qt::LeftDockWidgetArea, true, true); - root->addDockWidget("Std_ReportView", Qt::BottomDockWidgetArea, true, true); - root->addDockWidget("Std_PythonView", Qt::BottomDockWidgetArea, true, true); + root->addDockWidget("Std_ReportView", Qt::BottomDockWidgetArea, false, true); + root->addDockWidget("Std_PythonView", Qt::BottomDockWidgetArea, false, true); //Dagview through parameter. ParameterGrp::handle group = App::GetApplication().GetUserParameter(). From dd71f4d5db2dff9a4c0428ff0336dc012f84f966 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 5 Jul 2024 13:14:12 +0200 Subject: [PATCH 15/15] PD: Remove dead code from workbench class --- src/Mod/PartDesign/Gui/Workbench.cpp | 132 +-------------------------- src/Mod/PartDesign/Gui/Workbench.h | 29 +----- 2 files changed, 7 insertions(+), 154 deletions(-) diff --git a/src/Mod/PartDesign/Gui/Workbench.cpp b/src/Mod/PartDesign/Gui/Workbench.cpp index 3cfec4eb6b..0c4b196d2e 100644 --- a/src/Mod/PartDesign/Gui/Workbench.cpp +++ b/src/Mod/PartDesign/Gui/Workbench.cpp @@ -68,111 +68,18 @@ namespace sp = std::placeholders; /// @namespace PartDesignGui @class Workbench TYPESYSTEM_SOURCE(PartDesignGui::Workbench, Gui::StdWorkbench) -Workbench::Workbench() { -} +Workbench::Workbench() = default; -Workbench::~Workbench() { +Workbench::~Workbench() +{ WorkflowManager::destruct(); } -void Workbench::_switchToDocument(const App::Document* /*doc*/) -{ -// TODO Commented out for thurther remove or rewrite (2015-09-04, Fat-Zer) -// if (doc == NULL) return; -// -// PartDesign::Body* activeBody = NULL; -// std::vector bodies = doc->getObjectsOfType(PartDesign::Body::getClassTypeId()); -// -// // No tip, so build up structure or migrate -// if (!doc->Tip.getValue()) -// { -// ;/*if (doc->countObjects() == 0){ -// buildDefaultPartAndBody(doc); -// activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); -// assert(activeBody); -// } else { -// // empty document with no tip, so do migration -// _doMigration(doc); -// activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); -// assert(activeBody); -// } -// */ -// } -// else -// { -// App::Part *docPart = dynamic_cast(doc->Tip.getValue()); -// if (docPart) { -// App::Part *viewPart = Gui::Application::Instance->activeView()->getActiveObject("Part"); -// if (viewPart != docPart) -// Gui::Application::Instance->activeView()->setActiveObject(docPart, "Part"); -// //if (docPart->countObjectsOfType(PartDesign::Body::getClassTypeId()) < 1) -// // setUpPart(docPart); -// PartDesign::Body *tempBody = dynamic_cast (docPart->getObjectsOfType(PartDesign::Body::getClassTypeId()).front()); -// if (tempBody) { -// PartDesign::Body *viewBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); -// activeBody = viewBody; -// if (!viewBody) -// activeBody = tempBody; -// else if (!docPart->hasObject(viewBody)) -// activeBody = tempBody; -// -// if (activeBody != viewBody) -// Gui::Application::Instance->activeView()->setActiveObject(activeBody, PDBODYKEY); -// } -// } -// } -// -// /*if (activeBody == NULL) { -// QMessageBox::critical(Gui::getMainWindow(), QObject::tr("Could not create body"), -// QObject::tr("No body was found in this document, and none could be created. Please report this bug." -// "We recommend you do not use this document with the PartDesign workbench until the bug has been fixed." -// )); -// }*/ -} - -void Workbench::slotActiveDocument(const Gui::Document& /*Doc*/) -{ -// _switchToDocument(Doc.getDocument()); -} - -void Workbench::slotNewDocument(const App::Document& /*Doc*/) -{ -// _switchToDocument(&Doc); -} - -void Workbench::slotFinishRestoreDocument(const App::Document& /*Doc*/) -{ -// _switchToDocument(&Doc); -} - -void Workbench::slotDeleteDocument(const App::Document&) -{ - //ActivePartObject = 0; - //ActiveGuiDoc = 0; - //ActiveAppDoc = 0; - //ActiveVp = 0; -} -/* - This does not work for Std_DuplicateSelection: - Tree.cpp gives: "Cannot reparent unknown object", probably because the signalNewObject is emitted - before the duplication of the object has been completely finished - -void Workbench::slotNewObject(const App::DocumentObject& obj) -{ - if ((obj.getDocument() == ActiveAppDoc) && (ActivePartObject != NULL)) { - // Add the new object to the active Body - // Note: Will this break Undo? But how else can we catch Edit->Duplicate selection? - Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)", - ActivePartObject->getNameInDocument(), obj.getNameInDocument()); - } -} -*/ - void Workbench::setupContextMenu(const char* recipient, Gui::MenuItem* item) const { auto selection = Gui::Selection().getSelection(); // Add move Tip Command - if ( !selection.empty() ) { + if (!selection.empty()) { App::DocumentObject *feature = selection.front().pObject; PartDesign::Body *body = nullptr; @@ -434,7 +341,6 @@ void Workbench::activated() "PartDesign_Mirrored", "PartDesign_LinearPattern", "PartDesign_PolarPattern", -// "PartDesign_Scaled", "PartDesign_MultiTransform", nullptr}; Watcher.push_back(new Gui::TaskView::TaskWatcherCommands( @@ -444,37 +350,18 @@ void Workbench::activated() "PartDesign_MultiTransform" )); - // make the previously used active Body active again - //PartDesignGui::ActivePartObject = NULL; - _switchToDocument(App::GetApplication().getActiveDocument()); - addTaskWatcher(Watcher); if(App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/PartDesign")->GetBool("SwitchToTask", true)) Gui::Control().showTaskView(); - - //NOLINTBEGIN - // Let us be notified when a document is activated, so that we can update the ActivePartObject - activeDoc = Gui::Application::Instance->signalActiveDocument.connect(std::bind(&Workbench::slotActiveDocument, this, sp::_1)); - createDoc = App::GetApplication().signalNewDocument.connect(std::bind(&Workbench::slotNewDocument, this, sp::_1)); - finishDoc = App::GetApplication().signalFinishRestoreDocument.connect(std::bind(&Workbench::slotFinishRestoreDocument, this, sp::_1)); - deleteDoc = App::GetApplication().signalDeleteDocument.connect(std::bind(&Workbench::slotDeleteDocument, this, sp::_1)); - //NOLINTEND } void Workbench::deactivated() { - // Let us be notified when a document is activated, so that we can update the ActivePartObject - activeDoc.disconnect(); - createDoc.disconnect(); - finishDoc.disconnect(); - deleteDoc.disconnect(); - removeTaskWatcher(); // reset the active Body Gui::Command::doCommand(Gui::Command::Doc,"import PartDesignGui"); Gui::Workbench::deactivated(); - } Gui::MenuItem* Workbench::setupMenuBar() const @@ -536,7 +423,6 @@ Gui::MenuItem* Workbench::setupMenuBar() const << "PartDesign_LinearPattern" << "PartDesign_PolarPattern" << "PartDesign_MultiTransform"; -// << "PartDesign_Scaled" // dressups Gui::MenuItem* dressups = new Gui::MenuItem; @@ -572,7 +458,6 @@ Gui::MenuItem* Workbench::setupMenuBar() const << "Separator" << "Part_CheckGeometry" << "Separator" - // << "PartDesign_Migrate" << "PartDesign_Sprocket"; // For 0.13 a couple of python packages like numpy, matplotlib and others @@ -650,16 +535,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const *part << "PartDesign_Mirrored" << "PartDesign_LinearPattern" << "PartDesign_PolarPattern" - // << "PartDesign_Scaled" << "PartDesign_MultiTransform"; return root; } - -Gui::ToolBarItem* Workbench::setupCommandBars() const -{ - // Part tools - Gui::ToolBarItem* root = new Gui::ToolBarItem; - return root; -} - diff --git a/src/Mod/PartDesign/Gui/Workbench.h b/src/Mod/PartDesign/Gui/Workbench.h index 5138f78e02..af2bf5137b 100644 --- a/src/Mod/PartDesign/Gui/Workbench.h +++ b/src/Mod/PartDesign/Gui/Workbench.h @@ -30,8 +30,6 @@ namespace Gui { class MenuItem; -class Document; -class ViewProviderDocumentObject; } @@ -48,7 +46,7 @@ public: Workbench(); ~Workbench() override; - /** Run some actions when the workbench gets activated. */ + /** Run some actions when the workbench gets activated. */ void activated() override; /** Run some actions when the workbench gets deactivated. */ void deactivated() override; @@ -57,29 +55,8 @@ public: void setupContextMenu(const char* recipient, Gui::MenuItem*) const override; protected: - Gui::MenuItem* setupMenuBar() const override; - Gui::ToolBarItem* setupToolBars() const override; - Gui::ToolBarItem* setupCommandBars() const override; - -private: - /// Refresh the Body's highlighting when a document becomes active - void slotActiveDocument(const Gui::Document&); - /// Refresh the highlighting. Migrate legacy documents on loading - void slotFinishRestoreDocument(const App::Document&); - /// Ensure that there are base planes and a body in a new document - void slotNewDocument(const App::Document&); - /// Update the ActivePartObject etc. when a document is closed - void slotDeleteDocument(const App::Document&); - // Add new objects to the body, if appropriate - //void slotNewObject(const App::DocumentObject& obj); - - void _switchToDocument(const App::Document* doc); - -private: - boost::signals2::connection activeDoc; - boost::signals2::connection createDoc; - boost::signals2::connection finishDoc; - boost::signals2::connection deleteDoc; + Gui::MenuItem* setupMenuBar() const override; + Gui::ToolBarItem* setupToolBars() const override; }; } // namespace PartDesignGui