diff --git a/src/Mod/Part/Gui/DlgSettingsGeneral.cpp b/src/Mod/Part/Gui/DlgSettingsGeneral.cpp
index 04ffe7b683..93998159c7 100644
--- a/src/Mod/Part/Gui/DlgSettingsGeneral.cpp
+++ b/src/Mod/Part/Gui/DlgSettingsGeneral.cpp
@@ -67,6 +67,7 @@ void DlgSettingsGeneral::saveSettings()
ui->comboDefaultProfileTypeForHole->onSave();
ui->checkShowFinalPreview->onSave();
ui->checkShowTransparentPreview->onSave();
+ ui->checkShowProfilePreview->onSave();
ui->checkSwitchToTask->onSave();
}
@@ -82,6 +83,7 @@ void DlgSettingsGeneral::loadSettings()
ui->comboDefaultProfileTypeForHole->onRestore();
ui->checkShowFinalPreview->onRestore();
ui->checkShowTransparentPreview->onRestore();
+ ui->checkShowProfilePreview->onRestore();
ui->checkSwitchToTask->onRestore();
}
diff --git a/src/Mod/Part/Gui/DlgSettingsGeneral.ui b/src/Mod/Part/Gui/DlgSettingsGeneral.ui
index d51a00e338..90d019a585 100644
--- a/src/Mod/Part/Gui/DlgSettingsGeneral.ui
+++ b/src/Mod/Part/Gui/DlgSettingsGeneral.ui
@@ -7,7 +7,7 @@
0
0
550
- 513
+ 552
@@ -203,7 +203,7 @@
-
- Show final result by default when editing feature
+ Show final result by default when editing features
ShowFinal
@@ -216,7 +216,7 @@
-
- Show transparent preview overlay by default when editing feature
+ Show transparent preview overlay by default when editing features
true
@@ -229,6 +229,22 @@
+ -
+
+
+ Highlight the profile used to create features
+
+
+ true
+
+
+ ShowProfilePreview
+
+
+ Mod/PartDesign/Preview
+
+
+
diff --git a/src/Mod/PartDesign/Gui/StyleParameters.h b/src/Mod/PartDesign/Gui/StyleParameters.h
index 38dbededff..34661146d1 100644
--- a/src/Mod/PartDesign/Gui/StyleParameters.h
+++ b/src/Mod/PartDesign/Gui/StyleParameters.h
@@ -32,6 +32,9 @@ namespace PartDesignGui::StyleParameters {
DEFINE_STYLE_PARAMETER(PreviewCommonColor, Base::Color(1.0F, 1.0F, 0.0F));
DEFINE_STYLE_PARAMETER(PreviewDressUpColor, Base::Color(1.0F, 0.0F, 1.0F));
+ DEFINE_STYLE_PARAMETER(PreviewProfileLineWidth, Gui::StyleParameters::Numeric(4));
+ DEFINE_STYLE_PARAMETER(PreviewProfileOpacity, Gui::StyleParameters::Numeric(0.0));
+
DEFINE_STYLE_PARAMETER(PreviewErrorColor, Base::Color(1.0F, 0.0F, 0.0F));
DEFINE_STYLE_PARAMETER(PreviewErrorOpacity, Gui::StyleParameters::Numeric(0.05));
diff --git a/src/Mod/PartDesign/Gui/ViewProviderSketchBased.cpp b/src/Mod/PartDesign/Gui/ViewProviderSketchBased.cpp
index 44587b242d..a8fc196426 100644
--- a/src/Mod/PartDesign/Gui/ViewProviderSketchBased.cpp
+++ b/src/Mod/PartDesign/Gui/ViewProviderSketchBased.cpp
@@ -23,11 +23,21 @@
#include "PreCompiled.h"
+#ifndef _PreComp_
+# include
+#endif
+
+#include
+#include
#include
+#include
#include
#include
#include "ViewProviderSketchBased.h"
+#include "StyleParameters.h"
+
+#include
using namespace PartDesignGui;
@@ -35,7 +45,32 @@ using namespace PartDesignGui;
PROPERTY_SOURCE(PartDesignGui::ViewProviderSketchBased, PartDesignGui::ViewProvider)
-ViewProviderSketchBased::ViewProviderSketchBased() = default;
+ViewProviderSketchBased::ViewProviderSketchBased() :
+ pcProfileToggle(new SoToggleSwitch),
+ pcProfileShape(new PartGui::SoPreviewShape)
+{
+ auto annotation = new Gui::So3DAnnotation;
+ annotation->addChild(pcProfileShape);
+
+ pcProfileToggle->addChild(annotation);
+
+ const auto updateProfileVisibility = [this]() {
+ pcProfileToggle->on = hGrp->GetBool("ShowProfilePreview", true);
+ };
+
+ handlers.addHandler(hGrp, "ShowProfilePreview", [updateProfileVisibility](const Gui::ParamKey*) {
+ updateProfileVisibility();
+ });
+
+ updateProfileVisibility();
+
+ auto* styleParametersManager = Base::provideService();
+ pcProfileShape->transparency = 1.0F - static_cast(
+ styleParametersManager->resolve(StyleParameters::PreviewProfileOpacity).value);
+ pcProfileShape->lineWidth = static_cast(
+ styleParametersManager->resolve(StyleParameters::PreviewProfileLineWidth).value);
+}
+
ViewProviderSketchBased::~ViewProviderSketchBased() = default;
@@ -47,3 +82,45 @@ std::vector ViewProviderSketchBased::claimChildren() const
return temp;
}
+
+void ViewProviderSketchBased::attach(App::DocumentObject* pcObject)
+{
+ ViewProvider::attach(pcObject);
+
+ pcPreviewRoot->addChild(pcProfileToggle);
+
+ // we want the profile to be the same color as the preview
+ pcProfileShape->color.connectFrom(&pcPreviewShape->color);
+}
+
+void ViewProviderSketchBased::updateProfileShape()
+{
+ auto document = pcObject->getDocument();
+ if (document->testStatus(App::Document::Restoring)) {
+ return;
+ }
+
+ auto profileBased = getObject();
+ updatePreviewShape(profileBased->getTopoShapeVerifiedFace(true), pcProfileShape);
+}
+
+void ViewProviderSketchBased::updateData(const App::Property* prop)
+{
+ ViewProvider::updateData(prop);
+
+ auto profileBased = getObject();
+ if (!profileBased) {
+ return;
+ }
+
+ if (prop == &profileBased->Profile) {
+ updateProfileShape();
+ }
+
+}
+void ViewProviderSketchBased::updatePreview()
+{
+ ViewProvider::updatePreview();
+
+ updateProfileShape();
+}
diff --git a/src/Mod/PartDesign/Gui/ViewProviderSketchBased.h b/src/Mod/PartDesign/Gui/ViewProviderSketchBased.h
index 46dc93f736..0294730692 100644
--- a/src/Mod/PartDesign/Gui/ViewProviderSketchBased.h
+++ b/src/Mod/PartDesign/Gui/ViewProviderSketchBased.h
@@ -25,6 +25,9 @@
#include "ViewProvider.h"
+#include
+#include
+
namespace PartDesignGui {
/**
@@ -43,6 +46,21 @@ public:
/// grouping handling
std::vector claimChildren() const override;
+ void attach(App::DocumentObject* pcObject) override;
+
+protected:
+ void updateData(const App::Property* prop) override;
+ void updatePreview() override;
+
+private:
+ void updateProfileShape();
+
+ Gui::CoinPtr pcProfileToggle;
+ Gui::CoinPtr pcProfileShape;
+
+ ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
+ "User parameter:BaseApp/Preferences/Mod/PartDesign/Preview");
+ Gui::ParamHandlers handlers;
};
} /* PartDesignGui */