From bb9a30ac659ea45f98d55c6b3528be3e715546d5 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Mon, 26 Feb 2024 17:55:36 +0100 Subject: [PATCH] PD: Make datum points highlightable/selectable (#12439) * PD: Make datum points highlightable/selectable Give the user some feedback by changing the color of the datum point marker as the user selects or hovers over it. Closes #9540 --- .../PartDesign/Gui/ViewProviderDatumPoint.cpp | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Mod/PartDesign/Gui/ViewProviderDatumPoint.cpp b/src/Mod/PartDesign/Gui/ViewProviderDatumPoint.cpp index 5aa19bf696..b3140facb9 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderDatumPoint.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderDatumPoint.cpp @@ -25,6 +25,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ +# include # include # include # include @@ -32,6 +33,8 @@ #include #include +#include +#include #include #include "ViewProviderDatumPoint.h" @@ -54,21 +57,20 @@ ViewProviderDatumPoint::~ViewProviderDatumPoint() = default; void ViewProviderDatumPoint::attach ( App::DocumentObject *obj ) { ViewProviderDatum::attach ( obj ); - SoMFVec3f v; - v.setNum(1); - v.set1Value(0, 0,0,0); - - SoVertexProperty* vprop = new SoVertexProperty(); - vprop->vertex = v; - - // Using a marker gives a larger point but it doesn't do highlighting automatically like the SoBrepPointSet - // TODO Fix the highlight (may be via additional pcHighlight node?) (2015-09-09, Fat-Zer) - SoMarkerSet* marker = new SoMarkerSet(); - marker->vertexProperty = vprop; + const int markerSize = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/View")->GetInt("MarkerSize", 9); + // Using a marker gives a larger point. + auto *marker = new SoMarkerSet(); marker->numPoints = 1; - marker->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex("DIAMOND_FILLED", App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")->GetInt("MarkerSize", 9)); + marker->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex("DIAMOND_FILLED", + markerSize); - getShapeRoot ()->addChild(marker); + auto *pcHighlight = Gui::ViewProviderBuilder::createSelection(); + pcHighlight->style = Gui::SoFCSelection::EMISSIVE_DIFFUSE; + pcHighlight->addChild(new SoCoordinate3()); + pcHighlight->addChild(marker); + + getShapeRoot ()->addChild(pcHighlight); } void ViewProviderDatumPoint::onChanged (const App::Property* prop) {