Merge pull request #23274 from kadet1090/enlarge-planes

Gui: Enlarge planes on mouse over and selection
This commit is contained in:
Benjamin Nauck
2025-09-09 06:20:15 +02:00
committed by GitHub
12 changed files with 401 additions and 185 deletions

View File

@@ -51,10 +51,13 @@
#include <Mod/Part/Gui/TaskAttacher.h>
#include "TaskAttacher.h"
#include "ViewProviderDatum.h"
#include "ViewProvider2DObject.h"
#include "ui_TaskAttacher.h"
#include <Gui/ViewParams.h>
using namespace PartGui;
using namespace Gui;
@@ -218,6 +221,21 @@ TaskAttacher::TaskAttacher(Gui::ViewProviderDocumentObject* ViewProvider, QWidge
ui->attachmentOffsetPitch->bind(App::ObjectIdentifier::parse(ViewProvider->getObject(), std::string("AttachmentOffset.Rotation.Pitch")));
ui->attachmentOffsetRoll->bind(App::ObjectIdentifier::parse(ViewProvider->getObject(), std::string("AttachmentOffset.Rotation.Roll")));
auto document = ViewProvider->getObject()->getDocument();
for (auto planeDocumentObject : document->getObjectsOfType(App::Plane::getClassTypeId())) {
auto planeViewProvider = Application::Instance->getViewProvider<Gui::ViewProviderPlane>(planeDocumentObject);
if (!planeViewProvider) {
continue;
}
modifiedPlaneViewProviders.push_back(planeViewProvider);
planeViewProvider->setTemporaryScale(ViewParams::instance()->getDatumTemporaryScaleFactor());
planeViewProvider->setLabelVisibility(true);
};
visibilityAutomation(true);
updateAttachmentOffsetUI();
updateReferencesUI();
@@ -231,9 +249,9 @@ TaskAttacher::TaskAttacher(Gui::ViewProviderDocumentObject* ViewProvider, QWidge
auto bnd1 = std::bind(&TaskAttacher::objectDeleted, this, sp::_1);
auto bnd2 = std::bind(&TaskAttacher::documentDeleted, this, sp::_1);
//NOLINTEND
Gui::Document* document = Gui::Application::Instance->getDocument(ViewProvider->getObject()->getDocument());
connectDelObject = document->signalDeletedObject.connect(bnd1);
connectDelDocument = document->signalDeleteDocument.connect(bnd2);
Gui::Document* guiDocument = Gui::Application::Instance->getDocument(ViewProvider->getObject()->getDocument());
connectDelObject = guiDocument->signalDeletedObject.connect(bnd1);
connectDelDocument = guiDocument->signalDeleteDocument.connect(bnd2);
handleInitialSelection();
}
@@ -248,6 +266,11 @@ TaskAttacher::~TaskAttacher()
connectDelObject.disconnect();
connectDelDocument.disconnect();
for (auto planeViewProvider : modifiedPlaneViewProviders) {
planeViewProvider->resetTemporarySize();
planeViewProvider->setLabelVisibility(false);
}
}
void TaskAttacher::objectDeleted(const Gui::ViewProviderDocumentObject& view)

View File

@@ -42,6 +42,7 @@ class Property;
}
namespace Gui {
class ViewProviderPlane;
class ViewProvider;
}
@@ -158,6 +159,8 @@ private:
Connection connectDelObject;
Connection connectDelDocument;
std::vector<Gui::ViewProviderPlane*> modifiedPlaneViewProviders;
App::PropertyOverrideContext overrides;
};

View File

@@ -55,6 +55,8 @@
#include <Gui/Control.h>
#include <Gui/Document.h>
#include <Gui/MainWindow.h>
#include <Gui/ViewParams.h>
#include <Gui/ViewProviderPlane.h>
#include <Gui/Selection/SelectionFilter.h>
using namespace PartDesignGui;
@@ -502,6 +504,7 @@ public:
SketchRequestSelection(Gui::Document* guidocument, PartDesign::Body* activeBody)
: guidocument(guidocument)
, activeBody(activeBody)
, planeFinder(guidocument->getDocument(), activeBody)
{
}
@@ -567,7 +570,7 @@ private:
Gui::Application::Instance->getViewProvider(origin));
if (vpo) {
vpo->setTemporaryVisibility(Gui::DatumElement::Planes | Gui::DatumElement::Axes);
vpo->setTemporaryScale(3.0); // NOLINT
vpo->setTemporaryScale(Gui::ViewParams::instance()->getDatumTemporaryScaleFactor());
vpo->setPlaneLabelVisibility(true);
}
}
@@ -584,14 +587,14 @@ private:
PartDesign::Body* partDesignBody = activeBody;
auto onAccept = [partDesignBody, sketch]() {
SketchRequestSelection::resetOriginVisibility(partDesignBody);
resetOriginVisibility(partDesignBody);
Gui::Selection().clearSelection();
PartDesignGui::setEdit(sketch, partDesignBody);
};
auto onReject = [partDesignBody]() {
SketchRequestSelection::resetOriginVisibility(partDesignBody);
resetOriginVisibility(partDesignBody);
};
Gui::Selection().clearSelection();
@@ -616,7 +619,7 @@ private:
void findAndSelectPlane()
{
App::Document* appdocument = guidocument->getDocument();
PlaneFinder planeFinder{appdocument, activeBody};
planeFinder.findBasePlanes();
planeFinder.findDatumPlanes();
planeFinder.findShapeBinderPlanes();
@@ -625,14 +628,35 @@ private:
std::vector<PartDesignGui::TaskFeaturePick::featureStatus> status = planeFinder.getStatus();
unsigned validPlaneCount = planeFinder.countValidPlanes();
for (auto& plane : planes) {
auto* planeViewProvider = Gui::Application::Instance->getViewProvider<Gui::ViewProviderPlane>(plane);
// skip updating planes from coordinate systems
if (!planeViewProvider->getRole().empty()) {
continue;
}
planeViewProvider->setLabelVisibility(true);
planeViewProvider->setTemporaryScale(Gui::ViewParams::instance()->getDatumTemporaryScaleFactor());
}
//
// Lambda definitions
//
App::Document* documentOfBody = appdocument;
PartDesign::Body* partDesignBody = activeBody;
auto restorePlaneVisibility = [planes]() {
for (auto& plane : planes) {
auto* planeViewProvider = Gui::Application::Instance->getViewProvider<Gui::ViewProviderPlane>(plane);
planeViewProvider->resetTemporarySize();
planeViewProvider->setLabelVisibility(false);
}
};
// Determines if user made a valid selection in dialog
auto acceptFunction = [](const std::vector<App::DocumentObject*>& features) -> bool {
auto acceptFunction = [restorePlaneVisibility](const std::vector<App::DocumentObject*>& features) -> bool {
restorePlaneVisibility();
return !features.empty();
};
@@ -643,7 +667,8 @@ private:
// Called by dialog for "Cancel", or "OK" if accepter returns false
std::string docname = documentOfBody->getName();
auto rejectFunction = [docname]() {
auto rejectFunction = [docname, restorePlaneVisibility]() {
restorePlaneVisibility();
Gui::Document* document = Gui::Application::Instance->getDocument(docname.c_str());
if (document)
document->abortCommand();
@@ -729,6 +754,8 @@ private:
private:
Gui::Document* guidocument;
PartDesign::Body* activeBody;
PlaneFinder planeFinder;
};
}

View File

@@ -54,6 +54,8 @@
#include "TaskFeaturePick.h"
#include "Utils.h"
#include <Gui/ViewParams.h>
using namespace PartDesignGui;
using namespace Attacher;
@@ -159,7 +161,7 @@ TaskFeaturePick::TaskFeaturePick(std::vector<App::DocumentObject*>& objects,
Gui::Application::Instance->getViewProvider(origin));
if (vpo) {
vpo->setTemporaryVisibility(originVisStatus[origin]);
vpo->setTemporaryScale(4.0); // NOLINT
vpo->setTemporaryScale(Gui::ViewParams::instance()->getDatumTemporaryScaleFactor());
vpo->setPlaneLabelVisibility(true);
origins.push_back(vpo);
}