From 763fc0159b1774f52fd11f5e7f51bf679d6297a1 Mon Sep 17 00:00:00 2001 From: tritao Date: Mon, 13 Jan 2025 23:07:15 +0000 Subject: [PATCH 01/10] Gui: Rename `SoFCUnifiedSelection::selectionRole` for clarity. --- src/Gui/Selection/SoFCUnifiedSelection.cpp | 14 +++++++------- src/Gui/Selection/SoFCUnifiedSelection.h | 2 +- src/Gui/View3DInventorViewer.cpp | 6 ++---- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Gui/Selection/SoFCUnifiedSelection.cpp b/src/Gui/Selection/SoFCUnifiedSelection.cpp index 719e384139..0fd85e0ef1 100644 --- a/src/Gui/Selection/SoFCUnifiedSelection.cpp +++ b/src/Gui/Selection/SoFCUnifiedSelection.cpp @@ -113,12 +113,12 @@ SoFCUnifiedSelection::SoFCUnifiedSelection() { SO_NODE_CONSTRUCTOR(SoFCUnifiedSelection); - SO_NODE_ADD_FIELD(colorHighlight, (SbColor(1.0f, 0.6f, 0.0f))); - SO_NODE_ADD_FIELD(colorSelection, (SbColor(0.1f, 0.8f, 0.1f))); - SO_NODE_ADD_FIELD(highlightMode, (AUTO)); - SO_NODE_ADD_FIELD(selectionMode, (ON)); - SO_NODE_ADD_FIELD(selectionRole, (true)); - SO_NODE_ADD_FIELD(useNewSelection, (true)); + SO_NODE_ADD_FIELD(colorHighlight, (SbColor(1.0f, 0.6f, 0.0f))); + SO_NODE_ADD_FIELD(colorSelection, (SbColor(0.1f, 0.8f, 0.1f))); + SO_NODE_ADD_FIELD(highlightMode, (AUTO)); + SO_NODE_ADD_FIELD(selectionMode, (ON)); + SO_NODE_ADD_FIELD(selectionEnabled, (true)); + SO_NODE_ADD_FIELD(useNewSelection, (true)); SO_NODE_DEFINE_ENUM_VALUE(HighlightModes, AUTO); SO_NODE_DEFINE_ENUM_VALUE(HighlightModes, ON); @@ -729,7 +729,7 @@ void SoFCUnifiedSelection::handleEvent(SoHandleEventAction * action) { // If off then don't handle this event - if (!selectionRole.getValue()) { + if (!selectionEnabled.getValue()) { inherited::handleEvent(action); return; } diff --git a/src/Gui/Selection/SoFCUnifiedSelection.h b/src/Gui/Selection/SoFCUnifiedSelection.h index ad22f37411..b400d9a9ce 100644 --- a/src/Gui/Selection/SoFCUnifiedSelection.h +++ b/src/Gui/Selection/SoFCUnifiedSelection.h @@ -76,7 +76,7 @@ public: SoSFColor colorSelection; SoSFEnum highlightMode; SoSFEnum selectionMode; - SoSFBool selectionRole; + SoSFBool selectionEnabled; SoSFBool useNewSelection; void doAction(SoAction *action) override; diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index 7f0d238e5d..9f677de628 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -1798,14 +1798,12 @@ const std::vector& View3DInventorViewer::getPolygon(SelectionRole* role void View3DInventorViewer::setSelectionEnabled(bool enable) { - SoNode* root = getSceneGraph(); - static_cast(root)->selectionRole.setValue(enable); // NOLINT + this->selectionRoot->selectionEnabled.setValue(enable); // NOLINT } bool View3DInventorViewer::isSelectionEnabled() const { - SoNode* root = getSceneGraph(); - return static_cast(root)->selectionRole.getValue(); // NOLINT + return this->selectionRoot->selectionEnabled.getValue(); // NOLINT } SbVec2f View3DInventorViewer::screenCoordsOfPath(SoPath* path) const From 20276324c05b036014c2a0e288bb2e5011143376 Mon Sep 17 00:00:00 2001 From: tritao Date: Mon, 13 Jan 2025 23:13:31 +0000 Subject: [PATCH 02/10] Gui: Cleanup `SoFCUnifiedSelection::handleEvent`. --- src/Gui/Selection/SoFCUnifiedSelection.cpp | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/Gui/Selection/SoFCUnifiedSelection.cpp b/src/Gui/Selection/SoFCUnifiedSelection.cpp index 0fd85e0ef1..d406ef93b1 100644 --- a/src/Gui/Selection/SoFCUnifiedSelection.cpp +++ b/src/Gui/Selection/SoFCUnifiedSelection.cpp @@ -734,27 +734,18 @@ SoFCUnifiedSelection::handleEvent(SoHandleEventAction * action) return; } - auto mymode = static_cast(this->highlightMode.getValue()); + auto highlightMode = static_cast(this->highlightMode.getValue()); const SoEvent * event = action->getEvent(); - // If we don't need to pick for locate highlighting, - // then just behave as separator and return. - // NOTE: we still have to pick for ON even though we don't have - // to re-render, because the app needs to be notified as the mouse - // goes over locate highlight nodes. - //if (highlightMode.getValue() == OFF) { - // inherited::handleEvent( action ); - // return; - //} - // // If this is a mouseMotion event, then check for locate highlighting // - if (event->isOfType(SoLocation2Event::getClassTypeId())) { + bool isMouseMotionEvent = event->isOfType(SoLocation2Event::getClassTypeId()); + if (isMouseMotionEvent) { // NOTE: If preselection is off then we do not check for a picked point because otherwise this search may slow // down extremely the system on really big data sets. In this case we just check for a picked point if the data // set has been selected. - if (mymode == AUTO || mymode == ON) { + if (highlightMode == AUTO || highlightMode == ON) { // check to see if the mouse is over our geometry... auto infos = this->getPickedList(action,true); if(!infos.empty()) From ae56e62049ae3fade806059fb6ef848c5a7acf29 Mon Sep 17 00:00:00 2001 From: tritao Date: Wed, 5 Feb 2025 13:11:05 +0000 Subject: [PATCH 03/10] Gui: Cleanup mystery comments around `ResolveMode`. --- src/Mod/TechDraw/Gui/Command.cpp | 12 ++++++------ src/Mod/TechDraw/Gui/CommandHelpers.cpp | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Mod/TechDraw/Gui/Command.cpp b/src/Mod/TechDraw/Gui/Command.cpp index 0478f97aaa..5f540a18ae 100644 --- a/src/Mod/TechDraw/Gui/Command.cpp +++ b/src/Mod/TechDraw/Gui/Command.cpp @@ -913,8 +913,8 @@ void execComplexSection(Gui::Command* cmd) std::vector xShapes; App::DocumentObject* profileObject(nullptr); std::vector profileSubs; - Gui::ResolveMode resolve = Gui::ResolveMode::OldStyleElement;//mystery - bool single = false; //mystery + Gui::ResolveMode resolve = Gui::ResolveMode::OldStyleElement; + bool single = false; auto selection = cmd->getSelection().getSelectionEx( nullptr, App::DocumentObject::getClassTypeId(), resolve, single); for (auto& sel : selection) { @@ -1069,8 +1069,8 @@ void CmdTechDrawProjectionGroup::activated(int iMsg) std::vector xShapes; App::DocumentObject* partObj = nullptr; std::string faceName; - Gui::ResolveMode resolve = Gui::ResolveMode::OldStyleElement;//mystery - bool single = false; //mystery + Gui::ResolveMode resolve = Gui::ResolveMode::OldStyleElement; + bool single = false; auto selection = getSelection().getSelectionEx(nullptr, App::DocumentObject::getClassTypeId(), resolve, single); for (auto& sel : selection) { @@ -1970,8 +1970,8 @@ void getSelectedShapes(Gui::Command* cmd, App::DocumentObject* faceObj, std::string& faceName) { - Gui::ResolveMode resolve = Gui::ResolveMode::OldStyleElement;//mystery - bool single = false; //mystery + Gui::ResolveMode resolve = Gui::ResolveMode::OldStyleElement; + bool single = false; auto selection = cmd->getSelection().getSelectionEx(nullptr, App::DocumentObject::getClassTypeId(), resolve, single); for (auto& sel : selection) { diff --git a/src/Mod/TechDraw/Gui/CommandHelpers.cpp b/src/Mod/TechDraw/Gui/CommandHelpers.cpp index b996b9bb20..e1e2b059f6 100644 --- a/src/Mod/TechDraw/Gui/CommandHelpers.cpp +++ b/src/Mod/TechDraw/Gui/CommandHelpers.cpp @@ -137,8 +137,8 @@ void CommandHelpers::getSelectedShapes(Gui::Command* cmd, App::DocumentObject* faceObj, std::string& faceName) { - Gui::ResolveMode resolve = Gui::ResolveMode::OldStyleElement;//mystery - bool single = false; //mystery + auto resolve = Gui::ResolveMode::OldStyleElement; + bool single = false; auto selection = cmd->getSelection().getSelectionEx(nullptr, App::DocumentObject::getClassTypeId(), resolve, single); for (auto& sel : selection) { From ee078645d7761ae899989861462cf06b51087f24 Mon Sep 17 00:00:00 2001 From: tritao Date: Wed, 5 Feb 2025 13:13:58 +0000 Subject: [PATCH 04/10] Gui: Document `ResolveMode` directly. --- src/Gui/Selection/Selection.h | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/Gui/Selection/Selection.h b/src/Gui/Selection/Selection.h index f5e0154204..9cd6b4a197 100644 --- a/src/Gui/Selection/Selection.h +++ b/src/Gui/Selection/Selection.h @@ -49,9 +49,13 @@ namespace Gui { enum class ResolveMode { + /// No resolve NoResolve, + /// Sub-object with old style element name OldStyleElement, + /// Sub-object with new style element name NewStyleElement, + /// Resolve sub-object and follow link FollowLink }; @@ -227,9 +231,6 @@ public: * * @param attach: whether to attach this observer on construction * @param resolve: sub-object resolving mode. - * 0 no resolve, - * 1 resolve sub-object with old style element name - * 2 resolve sub-object with new style element name */ explicit SelectionObserver(bool attach = true, ResolveMode resolve = ResolveMode::OldStyleElement); /** Constructor @@ -237,9 +238,6 @@ public: * @param vp: filtering view object. * @param attach: whether to attach this observer on construction * @param resolve: sub-object resolving mode. - * 0 no resolve, - * 1 resolve sub-object with old style element name - * 2 resolve sub-object with new style element name * * Constructs an selection observer that receives only selection event of * objects within the same document as the input view object. @@ -452,9 +450,6 @@ public: * empty vector is returned. If document name is "*", then all document is * considered. * @param resolve: sub-object resolving mode - * 0 no resolve, - * 1 resolve sub-object with old style element name - * 2 resolve sub-object with new style element name * @param single: if set to true, then it will return an empty vector if * there is more than one selections. * @@ -469,9 +464,6 @@ public: * considered. * @param typeId: specify the type of object to be returned. * @param resolve: sub-object resolving mode. - * 0 no resolve, - * 1 resolve sub-object with old style element name - * 2 resolve sub-object with new style element name * @param single: if set to true, then it will return an empty vector if * there is more than one selections. * @@ -549,9 +541,6 @@ public: * @param pDocName: optional filtering document, NULL for current active * document * @param resolve: sub-object resolving mode. - * 0 no resolve, - * 1 resolve sub-object with old style element name - * 2 resolve sub-object with new style element name * @param index: optional position in the stack */ std::vector selStackGet(const char* pDocName=nullptr, ResolveMode resolve = ResolveMode::OldStyleElement, int index=0) const; From b4e5614bff9fc93ad94500c1c5f5b8378eb1eb52 Mon Sep 17 00:00:00 2001 From: tritao Date: Wed, 15 Jan 2025 12:05:03 +0000 Subject: [PATCH 05/10] Gui: Change `SoFCUnifiedSelection` from highlight to preselection terminology. --- src/Gui/Selection/SoFCUnifiedSelection.cpp | 43 +++++++++++----------- src/Gui/Selection/SoFCUnifiedSelection.h | 10 ++--- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/Gui/Selection/SoFCUnifiedSelection.cpp b/src/Gui/Selection/SoFCUnifiedSelection.cpp index d406ef93b1..ee3f66a2b0 100644 --- a/src/Gui/Selection/SoFCUnifiedSelection.cpp +++ b/src/Gui/Selection/SoFCUnifiedSelection.cpp @@ -115,15 +115,15 @@ SoFCUnifiedSelection::SoFCUnifiedSelection() SO_NODE_ADD_FIELD(colorHighlight, (SbColor(1.0f, 0.6f, 0.0f))); SO_NODE_ADD_FIELD(colorSelection, (SbColor(0.1f, 0.8f, 0.1f))); - SO_NODE_ADD_FIELD(highlightMode, (AUTO)); + SO_NODE_ADD_FIELD(preselectionMode, (AUTO)); SO_NODE_ADD_FIELD(selectionMode, (ON)); SO_NODE_ADD_FIELD(selectionEnabled, (true)); SO_NODE_ADD_FIELD(useNewSelection, (true)); - SO_NODE_DEFINE_ENUM_VALUE(HighlightModes, AUTO); - SO_NODE_DEFINE_ENUM_VALUE(HighlightModes, ON); - SO_NODE_DEFINE_ENUM_VALUE(HighlightModes, OFF); - SO_NODE_SET_SF_ENUM_TYPE (highlightMode, HighlightModes); + SO_NODE_DEFINE_ENUM_VALUE(PreselectionModes, AUTO); + SO_NODE_DEFINE_ENUM_VALUE(PreselectionModes, ON); + SO_NODE_DEFINE_ENUM_VALUE(PreselectionModes, OFF); + SO_NODE_SET_SF_ENUM_TYPE (preselectionMode, PreselectionModes); // Documentation of SoFullPath: // Since the SoFullPath is derived from SoPath and contains no private data, you can cast SoPath instances to the SoFullPath type. @@ -177,7 +177,7 @@ void SoFCUnifiedSelection::applySettings() bool enablePre = hGrp->GetBool("EnablePreselection", true); bool enableSel = hGrp->GetBool("EnableSelection", true); if (!enablePre) { - this->highlightMode = SoFCUnifiedSelection::OFF; + this->preselectionMode = SoFCUnifiedSelection::OFF; } else { // Search for a user defined value with the current color as default @@ -315,10 +315,10 @@ void SoFCUnifiedSelection::doAction(SoAction *action) if (action->getTypeId() == SoFCEnableHighlightAction::getClassTypeId()) { auto preaction = static_cast(action); if (preaction->highlight) { - this->highlightMode = SoFCUnifiedSelection::AUTO; + this->preselectionMode = SoFCUnifiedSelection::AUTO; } else { - this->highlightMode = SoFCUnifiedSelection::OFF; + this->preselectionMode = SoFCUnifiedSelection::OFF; } } @@ -353,7 +353,7 @@ void SoFCUnifiedSelection::doAction(SoAction *action) currenthighlight = nullptr; } } - else if (highlightMode.getValue() != OFF + else if (preselectionMode.getValue() != OFF && hilaction->SelChange.Type == SelectionChanges::SetPreselect) { if (currenthighlight) { SoHighlightElementAction hlAction; @@ -487,15 +487,16 @@ void SoFCUnifiedSelection::doAction(SoAction *action) inherited::doAction( action ); } -bool SoFCUnifiedSelection::setHighlight(const PickedInfo &info) { +bool SoFCUnifiedSelection::setPreselect(const PickedInfo &info) { if(!info.pp) - return setHighlight(nullptr,nullptr,nullptr,nullptr,0.0,0.0,0.0); + return setPreselect(nullptr,nullptr,nullptr,nullptr,0.0,0.0,0.0); + const auto &pt = info.pp->getPoint(); - return setHighlight(static_cast(info.pp->getPath()), + return setPreselect(static_cast(info.pp->getPath()), info.pp->getDetail(), info.vpd, info.element.c_str(), pt[0],pt[1],pt[2]); } -bool SoFCUnifiedSelection::setHighlight(SoFullPath *path, const SoDetail *det, +bool SoFCUnifiedSelection::setPreselect(SoFullPath *path, const SoDetail *det, ViewProviderDocumentObject *vpd, const char *element, float x, float y, float z) { Base::FlagToggler flag(setPreSelection); @@ -597,7 +598,7 @@ bool SoFCUnifiedSelection::setSelection(const std::vector &infos, bo auto pPath = static_cast(pp->getPath()); const auto &pt = pp->getPoint(); SoSelectionElementAction::Type type = SoSelectionElementAction::None; - auto mymode = static_cast(this->highlightMode.getValue()); + auto preselectionMode = static_cast(this->preselectionMode.getValue()); static char buf[513]; auto subName = info.element; std::string objectName = objname; @@ -618,7 +619,7 @@ bool SoFCUnifiedSelection::setSelection(const std::vector &infos, bo return false; } - if (ok && mymode == OFF) { + if (ok && preselectionMode == OFF) { snprintf(buf, 512, "Selected: %s.%s.%s (%g, %g, %g)", docname, objname, info.element.c_str(), fabs(pt[0]) > 1e-7 ? pt[0] : 0.0, fabs(pt[1]) > 1e-7 ? pt[1] : 0.0, fabs(pt[2]) > 1e-7 ? pt[2] : 0.0); @@ -701,7 +702,7 @@ bool SoFCUnifiedSelection::setSelection(const std::vector &infos, bo if (ok) type = hasNext ? SoSelectionElementAction::All : SoSelectionElementAction::Append; - if (mymode == OFF) { + if (preselectionMode == OFF) { snprintf(buf, 512, "Selected: %s.%s.%s (%g, %g, %g)", docname, objectName.c_str(), subName.c_str(), fabs(pt[0]) > 1e-7 ? pt[0] : 0.0, fabs(pt[1]) > 1e-7 ? pt[1] : 0.0, fabs(pt[2]) > 1e-7 ? pt[2] : 0.0); @@ -734,24 +735,24 @@ SoFCUnifiedSelection::handleEvent(SoHandleEventAction * action) return; } - auto highlightMode = static_cast(this->highlightMode.getValue()); + auto preselectionMode = static_cast(this->preselectionMode.getValue()); const SoEvent * event = action->getEvent(); // - // If this is a mouseMotion event, then check for locate highlighting + // If this is a mouseMotion event, then check for preselected entities. // bool isMouseMotionEvent = event->isOfType(SoLocation2Event::getClassTypeId()); if (isMouseMotionEvent) { // NOTE: If preselection is off then we do not check for a picked point because otherwise this search may slow // down extremely the system on really big data sets. In this case we just check for a picked point if the data // set has been selected. - if (highlightMode == AUTO || highlightMode == ON) { + if (preselectionMode == AUTO || preselectionMode == ON) { // check to see if the mouse is over our geometry... auto infos = this->getPickedList(action,true); if(!infos.empty()) - setHighlight(infos[0]); + setPreselect(infos[0]); else { - setHighlight(PickedInfo()); + setPreselect(PickedInfo()); if (this->preSelection > 0) { this->preSelection = 0; // touch() makes sure to call GLRenderBelowPath so that the cursor can be updated diff --git a/src/Gui/Selection/SoFCUnifiedSelection.h b/src/Gui/Selection/SoFCUnifiedSelection.h index b400d9a9ce..92b538f24c 100644 --- a/src/Gui/Selection/SoFCUnifiedSelection.h +++ b/src/Gui/Selection/SoFCUnifiedSelection.h @@ -50,7 +50,7 @@ class ViewProviderDocumentObject; /** Unified Selection node * This is the new selection node for the 3D Viewer which will * gradually remove all the low level selection nodes in the view - * provider. The handling of the highlighting and the selection will + * provider. The handling of the preselection and the selection will * be unified here. * \author Jürgen Riegel */ @@ -65,7 +65,7 @@ public: SoFCUnifiedSelection(); void applySettings(); - enum HighlightModes { + enum SelectionModes { AUTO, ON, OFF }; @@ -74,7 +74,7 @@ public: SoSFColor colorHighlight; SoSFColor colorSelection; - SoSFEnum highlightMode; + SoSFEnum preselectionMode; SoSFEnum selectionMode; SoSFBool selectionEnabled; SoSFBool useNewSelection; @@ -109,8 +109,8 @@ private: std::string element; }; - bool setHighlight(const PickedInfo &); - bool setHighlight(SoFullPath *path, const SoDetail *det, + bool setPreselect(const PickedInfo &); + bool setPreselect(SoFullPath *path, const SoDetail *det, ViewProviderDocumentObject *vpd, const char *element, float x, float y, float z); bool setSelection(const std::vector &, bool ctrlDown=false); From 4ace865b9108c78e288b4cfb9826fc5d7f9652a2 Mon Sep 17 00:00:00 2001 From: tritao Date: Wed, 15 Jan 2025 13:39:18 +0000 Subject: [PATCH 06/10] Gui: Some `SoFCUnifiedSelection` code readability improvements. --- src/Gui/Selection/SoFCUnifiedSelection.cpp | 148 ++++++++++----------- src/Gui/Selection/SoFCUnifiedSelection.h | 11 +- 2 files changed, 75 insertions(+), 84 deletions(-) diff --git a/src/Gui/Selection/SoFCUnifiedSelection.cpp b/src/Gui/Selection/SoFCUnifiedSelection.cpp index ee3f66a2b0..0c6ae57006 100644 --- a/src/Gui/Selection/SoFCUnifiedSelection.cpp +++ b/src/Gui/Selection/SoFCUnifiedSelection.cpp @@ -100,7 +100,7 @@ void printPreselectionInfo(const char* documentName, double precision); } -SoFullPath * Gui::SoFCUnifiedSelection::currenthighlight = nullptr; +SoFullPath * Gui::SoFCUnifiedSelection::currentHighlightPath = nullptr; // ************************************************************************* @@ -144,9 +144,9 @@ SoFCUnifiedSelection::~SoFCUnifiedSelection() { // If we're being deleted and we're the current highlight, // NULL out that variable - if (currenthighlight) { - currenthighlight->unref(); - currenthighlight = nullptr; + if (currentHighlightPath) { + currentHighlightPath->unref(); + currentHighlightPath = nullptr; } if (detailPath) { detailPath->unref(); @@ -167,16 +167,15 @@ void SoFCUnifiedSelection::finish() } bool SoFCUnifiedSelection::hasHighlight() { - return currenthighlight != nullptr; + return currentHighlightPath != nullptr; } void SoFCUnifiedSelection::applySettings() { float transparency; ParameterGrp::handle hGrp = Gui::WindowParameter::getDefaultParameter()->GetGroup("View"); - bool enablePre = hGrp->GetBool("EnablePreselection", true); - bool enableSel = hGrp->GetBool("EnableSelection", true); - if (!enablePre) { + bool enablePreselection = hGrp->GetBool("EnablePreselection", true); + if (!enablePreselection) { this->preselectionMode = SoFCUnifiedSelection::OFF; } else { @@ -188,7 +187,8 @@ void SoFCUnifiedSelection::applySettings() this->colorHighlight.setValue(highlightColor); } - if (!enableSel) { + bool enableSelection = hGrp->GetBool("EnableSelection", true); + if (!enableSelection) { this->selectionMode = SoFCUnifiedSelection::OFF; } else { @@ -313,8 +313,8 @@ SoFCUnifiedSelection::getPickedList(SoHandleEventAction* action, bool singlePick void SoFCUnifiedSelection::doAction(SoAction *action) { if (action->getTypeId() == SoFCEnableHighlightAction::getClassTypeId()) { - auto preaction = static_cast(action); - if (preaction->highlight) { + auto enableHighlightAction = static_cast(action); + if (enableHighlightAction->highlight) { this->preselectionMode = SoFCUnifiedSelection::AUTO; } else { @@ -323,8 +323,8 @@ void SoFCUnifiedSelection::doAction(SoAction *action) } if (action->getTypeId() == SoFCEnableSelectionAction::getClassTypeId()) { - auto selaction = static_cast(action); - if (selaction->selection) { + auto enableSelectionAction = static_cast(action); + if (enableSelectionAction->selection) { this->selectionMode = SoFCUnifiedSelection::ON; } else { @@ -333,52 +333,52 @@ void SoFCUnifiedSelection::doAction(SoAction *action) } if (action->getTypeId() == SoFCSelectionColorAction::getClassTypeId()) { - auto colaction = static_cast(action); - this->colorSelection = colaction->selectionColor; + auto selectionColorAction = static_cast(action); + this->colorSelection = selectionColorAction->selectionColor; } if (action->getTypeId() == SoFCHighlightColorAction::getClassTypeId()) { - auto colaction = static_cast(action); - this->colorHighlight = colaction->highlightColor; + auto highlightColorAction = static_cast(action); + this->colorHighlight = highlightColorAction->highlightColor; } if (action->getTypeId() == SoFCHighlightAction::getClassTypeId()) { - auto hilaction = static_cast(action); + auto highlightAction = static_cast(action); // Do not clear currently highlighted object when setting new pre-selection - if (!setPreSelection && hilaction->SelChange.Type == SelectionChanges::RmvPreselect) { - if (currenthighlight) { - SoHighlightElementAction hlAction; - hlAction.apply(currenthighlight); - currenthighlight->unref(); - currenthighlight = nullptr; + if (!setPreSelection && highlightAction->SelChange.Type == SelectionChanges::RmvPreselect) { + if (currentHighlightPath) { + SoHighlightElementAction highlightAction; + highlightAction.apply(currentHighlightPath); + currentHighlightPath->unref(); + currentHighlightPath = nullptr; } } else if (preselectionMode.getValue() != OFF - && hilaction->SelChange.Type == SelectionChanges::SetPreselect) { - if (currenthighlight) { - SoHighlightElementAction hlAction; - hlAction.apply(currenthighlight); - currenthighlight->unref(); - currenthighlight = nullptr; + && highlightAction->SelChange.Type == SelectionChanges::SetPreselect) { + if (currentHighlightPath) { + SoHighlightElementAction highlightAction; + highlightAction.apply(currentHighlightPath); + currentHighlightPath->unref(); + currentHighlightPath = nullptr; } - App::Document* doc = App::GetApplication().getDocument(hilaction->SelChange.pDocName); - App::DocumentObject* obj = doc->getObject(hilaction->SelChange.pObjectName); + App::Document* doc = App::GetApplication().getDocument(highlightAction->SelChange.pDocName); + App::DocumentObject* obj = doc->getObject(highlightAction->SelChange.pObjectName); ViewProvider*vp = Application::Instance->getViewProvider(obj); - SoDetail* detail = vp->getDetail(hilaction->SelChange.pSubName); + SoDetail* detail = vp->getDetail(highlightAction->SelChange.pSubName); - SoHighlightElementAction hlAction; - hlAction.setHighlighted(true); - hlAction.setColor(this->colorHighlight.getValue()); - hlAction.setElement(detail); - hlAction.apply(vp->getRoot()); + SoHighlightElementAction highlightAction; + highlightAction.setHighlighted(true); + highlightAction.setColor(this->colorHighlight.getValue()); + highlightAction.setElement(detail); + highlightAction.apply(vp->getRoot()); delete detail; SoSearchAction sa; sa.setNode(vp->getRoot()); sa.apply(vp->getRoot()); - currenthighlight = static_cast(sa.getPath()->copy()); - currenthighlight->ref(); + currentHighlightPath = static_cast(sa.getPath()->copy()); + currentHighlightPath->ref(); } if (useNewSelection.getValue()) @@ -386,30 +386,30 @@ void SoFCUnifiedSelection::doAction(SoAction *action) } if (action->getTypeId() == SoFCSelectionAction::getClassTypeId()) { - auto selaction = static_cast(action); + auto selectionAction = static_cast(action); if(selectionMode.getValue() == ON - && (selaction->SelChange.Type == SelectionChanges::AddSelection - || selaction->SelChange.Type == SelectionChanges::RmvSelection)) + && (selectionAction->SelChange.Type == SelectionChanges::AddSelection + || selectionAction->SelChange.Type == SelectionChanges::RmvSelection)) { // selection changes inside the 3d view are handled in handleEvent() - App::Document* doc = App::GetApplication().getDocument(selaction->SelChange.pDocName); - App::DocumentObject* obj = doc->getObject(selaction->SelChange.pObjectName); + App::Document* doc = App::GetApplication().getDocument(selectionAction->SelChange.pDocName); + App::DocumentObject* obj = doc->getObject(selectionAction->SelChange.pObjectName); ViewProvider*vp = Application::Instance->getViewProvider(obj); if (vp && (useNewSelection.getValue()||vp->useNewSelectionModel()) && vp->isSelectable()) { SoDetail *detail = nullptr; detailPath->truncate(0); - auto subName = selaction->SelChange.pSubName; + auto subName = selectionAction->SelChange.pSubName; App::ElementNamePair elementName;; App::GeoFeature::resolveElement(obj, subName, elementName); if (Data::isMappedElement(subName) && !elementName.oldName.empty()) { // If we have a shortened element name subName = elementName.oldName.c_str(); // use it. } - if(!selaction->SelChange.pSubName || !selaction->SelChange.pSubName[0] || + if(!selectionAction->SelChange.pSubName || !selectionAction->SelChange.pSubName[0] || vp->getDetailPath(subName,detailPath,true,detail)) { SoSelectionElementAction::Type type = SoSelectionElementAction::None; - if (selaction->SelChange.Type == SelectionChanges::AddSelection) { + if (selectionAction->SelChange.Type == SelectionChanges::AddSelection) { if (detail) type = SoSelectionElementAction::Append; else @@ -434,13 +434,13 @@ void SoFCUnifiedSelection::doAction(SoAction *action) delete detail; } } - else if (selaction->SelChange.Type == SelectionChanges::ClrSelection) { + else if (selectionAction->SelChange.Type == SelectionChanges::ClrSelection) { SoSelectionElementAction selectionAction(SoSelectionElementAction::None); for(int i=0;igetNumChildren();++i) selectionAction.apply(this->getChild(i)); } else if(selectionMode.getValue() == ON - && selaction->SelChange.Type == SelectionChanges::SetSelection) { + && selectionAction->SelChange.Type == SelectionChanges::SetSelection) { std::vector vps; if (this->pcDocument) vps = this->pcDocument->getViewProvidersOfType(ViewProviderDocumentObject::getClassTypeId()); @@ -459,22 +459,22 @@ void SoFCUnifiedSelection::doAction(SoAction *action) } } } - else if (selaction->SelChange.Type == SelectionChanges::SetPreselectSignal) { + else if (selectionAction->SelChange.Type == SelectionChanges::SetPreselectSignal) { // selection changes inside the 3d view are handled in handleEvent() - App::Document* doc = App::GetApplication().getDocument(selaction->SelChange.pDocName); - App::DocumentObject* obj = doc->getObject(selaction->SelChange.pObjectName); + App::Document* doc = App::GetApplication().getDocument(selectionAction->SelChange.pDocName); + App::DocumentObject* obj = doc->getObject(selectionAction->SelChange.pObjectName); ViewProvider*vp = Application::Instance->getViewProvider(obj); if (vp && vp->isDerivedFrom(ViewProviderDocumentObject::getClassTypeId()) && (useNewSelection.getValue()||vp->useNewSelectionModel()) && vp->isSelectable()) { detailPath->truncate(0); SoDetail *det = nullptr; - if(vp->getDetailPath(selaction->SelChange.pSubName,detailPath,true,det)) { - setHighlight(detailPath,det,static_cast(vp), - selaction->SelChange.pSubName, - selaction->SelChange.x, - selaction->SelChange.y, - selaction->SelChange.z); + if(vp->getDetailPath(selectionAction->SelChange.pSubName,detailPath,true,det)) { + setPreselect(detailPath,det,static_cast(vp), + selectionAction->SelChange.pSubName, + selectionAction->SelChange.x, + selectionAction->SelChange.y, + selectionAction->SelChange.z); } delete det; } @@ -514,32 +514,32 @@ bool SoFCUnifiedSelection::setPreselect(SoFullPath *path, const SoDetail *det, int ret = Gui::Selection().setPreselect(docname,objname,element,x,y,z); - if(ret<0 && currenthighlight) + if(ret<0 && currentHighlightPath) return true; if(ret) { - if (currenthighlight) { + if (currentHighlightPath) { SoHighlightElementAction action; action.setHighlighted(false); - action.apply(currenthighlight); - currenthighlight->unref(); - currenthighlight = nullptr; + action.apply(currentHighlightPath); + currentHighlightPath->unref(); + currentHighlightPath = nullptr; } - currenthighlight = static_cast(path->copy()); - currenthighlight->ref(); + currentHighlightPath = static_cast(path->copy()); + currentHighlightPath->ref(); highlighted = true; } } - if(currenthighlight) { + if(currentHighlightPath) { SoHighlightElementAction action; action.setHighlighted(highlighted); action.setColor(this->colorHighlight.getValue()); action.setElement(det); - action.apply(currenthighlight); + action.apply(currentHighlightPath); if(!highlighted) { - currenthighlight->unref(); - currenthighlight = nullptr; + currentHighlightPath->unref(); + currentHighlightPath = nullptr; Selection().rmvPreselect(); } this->touch(); @@ -1644,9 +1644,9 @@ bool SoFCSelectionRoot::doActionPrivate(Stack &stack, SoAction *action) { } if(action->isOfType(SoHighlightElementAction::getClassTypeId())) { - auto hlAction = static_cast(action); - if(hlAction->isHighlighted()) { - if(hlAction->getElement()) { + auto highlightAction = static_cast(action); + if(highlightAction->isHighlighted()) { + if(highlightAction->getElement()) { auto ctx = getActionContext(action,this,SelContextPtr(),false); if(ctx && ctx->hlAll) { ctx->hlAll = false; @@ -1656,7 +1656,7 @@ bool SoFCSelectionRoot::doActionPrivate(Stack &stack, SoAction *action) { auto ctx = getActionContext(action,this,SelContextPtr()); assert(ctx); ctx->hlAll = true; - ctx->hlColor = hlAction->getColor(); + ctx->hlColor = highlightAction->getColor(); touch(); return false; } diff --git a/src/Gui/Selection/SoFCUnifiedSelection.h b/src/Gui/Selection/SoFCUnifiedSelection.h index 92b538f24c..ec5c8c55c8 100644 --- a/src/Gui/Selection/SoFCUnifiedSelection.h +++ b/src/Gui/Selection/SoFCUnifiedSelection.h @@ -80,12 +80,9 @@ public: SoSFBool useNewSelection; void doAction(SoAction *action) override; - //virtual void GLRender(SoGLRenderAction * action); void handleEvent(SoHandleEventAction * action) override; void GLRenderBelowPath(SoGLRenderAction * action) override; - //virtual void GLRenderInPath(SoGLRenderAction * action); - //static void turnOffCurrentHighlight(SoGLRenderAction * action); static bool hasHighlight(); @@ -93,14 +90,8 @@ public: protected: ~SoFCUnifiedSelection() override; - //virtual void redrawHighlighted(SoAction * act, SbBool flag); - //virtual SbBool readInstance(SoInput * in, unsigned short flags); private: - //static void turnoffcurrent(SoAction * action); - //void setOverride(SoGLRenderAction * action); - //SbBool isHighlighted(SoAction *action); - //SbBool preRender(SoGLRenderAction *act, GLint &oldDepthFunc); static int getPriority(const SoPickedPoint* p); struct PickedInfo { @@ -118,7 +109,7 @@ private: Gui::Document *pcDocument{nullptr}; - static SoFullPath * currenthighlight; + static SoFullPath * currentHighlightPath; SoFullPath * detailPath; SbBool setPreSelection; From 18299a6d83463f6406c9255402a1ba43a412edbc Mon Sep 17 00:00:00 2001 From: tritao Date: Wed, 15 Jan 2025 12:20:22 +0000 Subject: [PATCH 07/10] Gui: Change `SoFCSelection` from highlight to preselection terminology. --- src/Gui/Selection/SoFCSelection.cpp | 24 +++++++++---------- src/Gui/Selection/SoFCSelection.h | 4 ++-- src/Gui/ViewProviderBuilder.cpp | 2 +- src/Gui/ViewProviderGeometryObject.cpp | 4 ++-- src/Gui/ViewProviderVRMLObject.cpp | 2 +- src/Mod/Robot/Gui/ViewProviderRobotObject.cpp | 4 ++-- src/Mod/Robot/Gui/ViewProviderTrajectory.cpp | 2 +- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Gui/Selection/SoFCSelection.cpp b/src/Gui/Selection/SoFCSelection.cpp index 5317a4b50f..0d11ebd692 100644 --- a/src/Gui/Selection/SoFCSelection.cpp +++ b/src/Gui/Selection/SoFCSelection.cpp @@ -79,7 +79,7 @@ SoFCSelection::SoFCSelection() SO_NODE_ADD_FIELD(colorHighlight, (SbColor(0.8f, 0.1f, 0.1f))); SO_NODE_ADD_FIELD(colorSelection, (SbColor(0.1f, 0.8f, 0.1f))); SO_NODE_ADD_FIELD(style, (EMISSIVE)); - SO_NODE_ADD_FIELD(highlightMode, (AUTO)); + SO_NODE_ADD_FIELD(preselectionMode, (AUTO)); SO_NODE_ADD_FIELD(selectionMode, (SEL_ON)); SO_NODE_ADD_FIELD(selected, (NOTSELECTED)); SO_NODE_ADD_FIELD(documentName, ("")); @@ -92,10 +92,10 @@ SoFCSelection::SoFCSelection() SO_NODE_DEFINE_ENUM_VALUE(Styles, BOX); SO_NODE_SET_SF_ENUM_TYPE(style, Styles); - SO_NODE_DEFINE_ENUM_VALUE(HighlightModes, AUTO); - SO_NODE_DEFINE_ENUM_VALUE(HighlightModes, ON); - SO_NODE_DEFINE_ENUM_VALUE(HighlightModes, OFF); - SO_NODE_SET_SF_ENUM_TYPE (highlightMode, HighlightModes); + SO_NODE_DEFINE_ENUM_VALUE(PreselectionModes, AUTO); + SO_NODE_DEFINE_ENUM_VALUE(PreselectionModes, ON); + SO_NODE_DEFINE_ENUM_VALUE(PreselectionModes, OFF); + SO_NODE_SET_SF_ENUM_TYPE (preselectionMode, PreselectionModes); SO_NODE_DEFINE_ENUM_VALUE(SelectionModes, SEL_ON); SO_NODE_DEFINE_ENUM_VALUE(SelectionModes, SEL_OFF); @@ -219,10 +219,10 @@ void SoFCSelection::doAction(SoAction *action) if (action->getTypeId() == SoFCEnableHighlightAction::getClassTypeId()) { auto preaction = static_cast(action); if (preaction->highlight) { - this->highlightMode = SoFCSelection::AUTO; + this->preselectionMode = SoFCSelection::AUTO; } else { - this->highlightMode = SoFCSelection::OFF; + this->preselectionMode = SoFCSelection::OFF; } } @@ -359,7 +359,7 @@ SoFCSelection::handleEvent(SoHandleEventAction * action) } static char buf[513]; - auto mymode = static_cast(this->highlightMode.getValue()); + auto mymode = static_cast(this->preselectionMode.getValue()); const SoEvent * event = action->getEvent(); #ifdef NO_FRONTBUFFER // mouse move events for preselection @@ -777,7 +777,7 @@ SoFCSelection::preRender(SoGLRenderAction *action, GLint &oldDepthFunc) //////////////////////////////////////////////////////////////////////// { // If not performing locate highlighting, just return. - if (highlightMode.getValue() == OFF) + if (preselectionMode.getValue() == OFF) return false; SoState *state = action->getState(); @@ -787,7 +787,7 @@ SoFCSelection::preRender(SoGLRenderAction *action, GLint &oldDepthFunc) // ??? never be called. We are not caching this node correctly yet.... //SoCacheElement::invalidate(state); - SbBool drawHighlighted = (highlightMode.getValue() == ON || isHighlighted(action) || selected.getValue() == SELECTED); + SbBool drawHighlighted = (preselectionMode.getValue() == ON || isHighlighted(action) || selected.getValue() == SELECTED); if (drawHighlighted) { // prevent diffuse & emissive color from leaking out... @@ -930,7 +930,7 @@ SoFCSelection::readInstance ( SoInput * in, unsigned short flags ) bool SoFCSelection::setOverride(SoGLRenderAction * action, SelContextPtr ctx) { - auto mymode = static_cast(this->highlightMode.getValue()); + auto mymode = static_cast(this->preselectionMode.getValue()); bool preselected = ctx && ctx->isHighlighted() && (useNewSelection.getValue()||mymode == AUTO); if (!preselected && mymode!=ON && (!ctx || !ctx->isSelected())) return false; @@ -1040,7 +1040,7 @@ void SoFCSelection::applySettings () bool enablePre = hGrp->GetBool("EnablePreselection", true); bool enableSel = hGrp->GetBool("EnableSelection", true); if (!enablePre) { - this->highlightMode = Gui::SoFCSelection::OFF; + this->preselectionMode = Gui::SoFCSelection::OFF; } else { // Search for a user defined value with the current color as default diff --git a/src/Gui/Selection/SoFCSelection.h b/src/Gui/Selection/SoFCSelection.h index 2b4b0deb3c..9327aafa49 100644 --- a/src/Gui/Selection/SoFCSelection.h +++ b/src/Gui/Selection/SoFCSelection.h @@ -69,7 +69,7 @@ public: /// Load highlight settings from the configuration void applySettings (); - enum HighlightModes { + enum PreselectionModes { AUTO, ON, OFF }; @@ -91,7 +91,7 @@ public: SoSFColor colorSelection; SoSFEnum style; SoSFEnum selected; - SoSFEnum highlightMode; + SoSFEnum preselectionMode; SoSFEnum selectionMode; SoSFString documentName; diff --git a/src/Gui/ViewProviderBuilder.cpp b/src/Gui/ViewProviderBuilder.cpp index 478dace621..c6bb1097e3 100644 --- a/src/Gui/ViewProviderBuilder.cpp +++ b/src/Gui/ViewProviderBuilder.cpp @@ -63,7 +63,7 @@ Gui::SoFCSelection* ViewProviderBuilder::createSelection() bool enablePre = hGrp->GetBool("EnablePreselection", true); bool enableSel = hGrp->GetBool("EnableSelection", true); if (!enablePre) { - sel->highlightMode = Gui::SoFCSelection::OFF; + sel->preselectionMode = Gui::SoFCSelection::OFF; } else { // Search for a user defined value with the current color as default diff --git a/src/Gui/ViewProviderGeometryObject.cpp b/src/Gui/ViewProviderGeometryObject.cpp index ad25dbface..e585a4ed60 100644 --- a/src/Gui/ViewProviderGeometryObject.cpp +++ b/src/Gui/ViewProviderGeometryObject.cpp @@ -347,13 +347,13 @@ void ViewProviderGeometryObject::setSelectable(bool selectable) if (selectable) { if (selNode) { selNode->selectionMode = SoFCSelection::SEL_ON; - selNode->highlightMode = SoFCSelection::AUTO; + selNode->preselectionMode = SoFCSelection::AUTO; } } else { if (selNode) { selNode->selectionMode = SoFCSelection::SEL_OFF; - selNode->highlightMode = SoFCSelection::OFF; + selNode->preselectionMode = SoFCSelection::OFF; selNode->selected = SoFCSelection::NOTSELECTED; } } diff --git a/src/Gui/ViewProviderVRMLObject.cpp b/src/Gui/ViewProviderVRMLObject.cpp index 044eeb021f..0f106c69f1 100644 --- a/src/Gui/ViewProviderVRMLObject.cpp +++ b/src/Gui/ViewProviderVRMLObject.cpp @@ -59,7 +59,7 @@ PROPERTY_SOURCE(Gui::ViewProviderVRMLObject, Gui::ViewProviderDocumentObject) ViewProviderVRMLObject::ViewProviderVRMLObject() { pcVRML = new SoFCSelection(); - pcVRML->highlightMode = Gui::SoFCSelection::OFF; + pcVRML->preselectionMode = Gui::SoFCSelection::OFF; pcVRML->selectionMode = Gui::SoFCSelection::SEL_OFF; //pcVRML->style = Gui::SoFCSelection::BOX; pcVRML->ref(); diff --git a/src/Mod/Robot/Gui/ViewProviderRobotObject.cpp b/src/Mod/Robot/Gui/ViewProviderRobotObject.cpp index 83e914a503..ec3ecd8feb 100644 --- a/src/Mod/Robot/Gui/ViewProviderRobotObject.cpp +++ b/src/Mod/Robot/Gui/ViewProviderRobotObject.cpp @@ -53,13 +53,13 @@ ViewProviderRobotObject::ViewProviderRobotObject() ADD_PROPERTY(Manipulator, (0)); pcRobotRoot = new Gui::SoFCSelection(); - pcRobotRoot->highlightMode = Gui::SoFCSelection::OFF; + pcRobotRoot->preselectionMode = Gui::SoFCSelection::OFF; // pcRobotRoot->selectionMode = Gui::SoFCSelection::SEL_OFF; // pcRobotRoot->style = Gui::SoFCSelection::BOX; pcRobotRoot->ref(); pcSimpleRoot = new Gui::SoFCSelection(); - pcSimpleRoot->highlightMode = Gui::SoFCSelection::OFF; + pcSimpleRoot->preselectionMode = Gui::SoFCSelection::OFF; // pcSimpleRoot->selectionMode = Gui::SoFCSelection::SEL_OFF; pcSimpleRoot->ref(); diff --git a/src/Mod/Robot/Gui/ViewProviderTrajectory.cpp b/src/Mod/Robot/Gui/ViewProviderTrajectory.cpp index e50b604906..4a10b13dfe 100644 --- a/src/Mod/Robot/Gui/ViewProviderTrajectory.cpp +++ b/src/Mod/Robot/Gui/ViewProviderTrajectory.cpp @@ -52,7 +52,7 @@ ViewProviderTrajectory::ViewProviderTrajectory() { pcTrajectoryRoot = new Gui::SoFCSelection(); - pcTrajectoryRoot->highlightMode = Gui::SoFCSelection::OFF; + pcTrajectoryRoot->preselectionMode = Gui::SoFCSelection::OFF; pcTrajectoryRoot->selectionMode = Gui::SoFCSelection::SEL_OFF; // pcRobotRoot->style = Gui::SoFCSelection::BOX; pcTrajectoryRoot->ref(); From 0f675bb63530c31e5e9698fb2f8280fe6791af2f Mon Sep 17 00:00:00 2001 From: tritao Date: Wed, 15 Jan 2025 13:39:32 +0000 Subject: [PATCH 08/10] Gui: Rename `SoFCEnableHighlightAction` to preselection terminology. --- src/Gui/Selection/SoFCSelection.cpp | 8 ++-- src/Gui/Selection/SoFCSelectionAction.cpp | 52 +++++++++++----------- src/Gui/Selection/SoFCSelectionAction.h | 16 +++---- src/Gui/Selection/SoFCUnifiedSelection.cpp | 8 ++-- src/Gui/View3DSettings.cpp | 2 +- 5 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/Gui/Selection/SoFCSelection.cpp b/src/Gui/Selection/SoFCSelection.cpp index 0d11ebd692..b5dc26de5e 100644 --- a/src/Gui/Selection/SoFCSelection.cpp +++ b/src/Gui/Selection/SoFCSelection.cpp @@ -216,9 +216,9 @@ void SoFCSelection::doAction(SoAction *action) if(!useNewSelection.getValue()) { - if (action->getTypeId() == SoFCEnableHighlightAction::getClassTypeId()) { - auto preaction = static_cast(action); - if (preaction->highlight) { + if (action->getTypeId() == SoFCEnablePreselectionAction::getClassTypeId()) { + auto preaction = static_cast(action); + if (preaction->enabled) { this->preselectionMode = SoFCSelection::AUTO; } else { @@ -228,7 +228,7 @@ void SoFCSelection::doAction(SoAction *action) if (action->getTypeId() == SoFCEnableSelectionAction::getClassTypeId()) { auto selaction = static_cast(action); - if (selaction->selection) { + if (selaction->enabled) { this->selectionMode = SoFCSelection::SEL_ON; } else { diff --git a/src/Gui/Selection/SoFCSelectionAction.cpp b/src/Gui/Selection/SoFCSelectionAction.cpp index 14777bd78b..55f4f06067 100644 --- a/src/Gui/Selection/SoFCSelectionAction.cpp +++ b/src/Gui/Selection/SoFCSelectionAction.cpp @@ -296,7 +296,7 @@ void SoFCEnableSelectionAction::finish() SoFCEnableSelectionAction::SoFCEnableSelectionAction (const SbBool& sel) - : selection(sel) + : enabled(sel) { SO_ACTION_CONSTRUCTOR(SoFCEnableSelectionAction); } @@ -317,7 +317,7 @@ void SoFCEnableSelectionAction::callDoAction(SoAction *action,SoNode *node) // --------------------------------------------------------------- -SO_ACTION_SOURCE(SoFCEnableHighlightAction) +SO_ACTION_SOURCE(SoFCEnablePreselectionAction) /** * The order of the defined SO_ACTION_ADD_METHOD statements is very important. First the base @@ -327,28 +327,28 @@ SO_ACTION_SOURCE(SoFCEnableHighlightAction) * This means that \c SoSwitch must be listed after \c SoGroup and \c SoFCSelection after * \c SoSeparator because both classes inherits the others. */ -void SoFCEnableHighlightAction::initClass() +void SoFCEnablePreselectionAction::initClass() { - SO_ACTION_INIT_CLASS(SoFCEnableHighlightAction,SoAction); + SO_ACTION_INIT_CLASS(SoFCEnablePreselectionAction,SoAction); - SO_ENABLE(SoFCEnableHighlightAction, SoSwitchElement); + SO_ENABLE(SoFCEnablePreselectionAction, SoSwitchElement); SO_ACTION_ADD_METHOD(SoNode,nullAction); - SO_ENABLE(SoFCEnableHighlightAction, SoModelMatrixElement); - SO_ENABLE(SoFCEnableHighlightAction, SoShapeStyleElement); - SO_ENABLE(SoFCEnableHighlightAction, SoComplexityElement); - SO_ENABLE(SoFCEnableHighlightAction, SoComplexityTypeElement); - SO_ENABLE(SoFCEnableHighlightAction, SoCoordinateElement); - SO_ENABLE(SoFCEnableHighlightAction, SoFontNameElement); - SO_ENABLE(SoFCEnableHighlightAction, SoFontSizeElement); - SO_ENABLE(SoFCEnableHighlightAction, SoProfileCoordinateElement); - SO_ENABLE(SoFCEnableHighlightAction, SoProfileElement); - SO_ENABLE(SoFCEnableHighlightAction, SoSwitchElement); - SO_ENABLE(SoFCEnableHighlightAction, SoUnitsElement); - SO_ENABLE(SoFCEnableHighlightAction, SoViewVolumeElement); - SO_ENABLE(SoFCEnableHighlightAction, SoViewingMatrixElement); - SO_ENABLE(SoFCEnableHighlightAction, SoViewportRegionElement); + SO_ENABLE(SoFCEnablePreselectionAction, SoModelMatrixElement); + SO_ENABLE(SoFCEnablePreselectionAction, SoShapeStyleElement); + SO_ENABLE(SoFCEnablePreselectionAction, SoComplexityElement); + SO_ENABLE(SoFCEnablePreselectionAction, SoComplexityTypeElement); + SO_ENABLE(SoFCEnablePreselectionAction, SoCoordinateElement); + SO_ENABLE(SoFCEnablePreselectionAction, SoFontNameElement); + SO_ENABLE(SoFCEnablePreselectionAction, SoFontSizeElement); + SO_ENABLE(SoFCEnablePreselectionAction, SoProfileCoordinateElement); + SO_ENABLE(SoFCEnablePreselectionAction, SoProfileElement); + SO_ENABLE(SoFCEnablePreselectionAction, SoSwitchElement); + SO_ENABLE(SoFCEnablePreselectionAction, SoUnitsElement); + SO_ENABLE(SoFCEnablePreselectionAction, SoViewVolumeElement); + SO_ENABLE(SoFCEnablePreselectionAction, SoViewingMatrixElement); + SO_ENABLE(SoFCEnablePreselectionAction, SoViewportRegionElement); @@ -369,28 +369,28 @@ void SoFCEnableHighlightAction::initClass() SO_ACTION_ADD_METHOD(SoFCSelection,callDoAction); } -void SoFCEnableHighlightAction::finish() +void SoFCEnablePreselectionAction::finish() { atexit_cleanup(); } -SoFCEnableHighlightAction::SoFCEnableHighlightAction (const SbBool& sel) - : highlight(sel) +SoFCEnablePreselectionAction::SoFCEnablePreselectionAction (const SbBool& sel) + : enabled(sel) { - SO_ACTION_CONSTRUCTOR(SoFCEnableHighlightAction); + SO_ACTION_CONSTRUCTOR(SoFCEnablePreselectionAction); } -SoFCEnableHighlightAction::~SoFCEnableHighlightAction() = default; +SoFCEnablePreselectionAction::~SoFCEnablePreselectionAction() = default; -void SoFCEnableHighlightAction::beginTraversal(SoNode *node) +void SoFCEnablePreselectionAction::beginTraversal(SoNode *node) { traverse(node); } -void SoFCEnableHighlightAction::callDoAction(SoAction *action,SoNode *node) +void SoFCEnablePreselectionAction::callDoAction(SoAction *action,SoNode *node) { node->doAction(action); } diff --git a/src/Gui/Selection/SoFCSelectionAction.h b/src/Gui/Selection/SoFCSelectionAction.h index 7576ca911a..c3e36e0c06 100644 --- a/src/Gui/Selection/SoFCSelectionAction.h +++ b/src/Gui/Selection/SoFCSelectionAction.h @@ -100,7 +100,7 @@ public: SoFCEnableSelectionAction (const SbBool& sel); ~SoFCEnableSelectionAction() override; - SbBool selection; + SbBool enabled; static void initClass(); static void finish(); @@ -113,19 +113,19 @@ private: }; /** - * The SoFCEnableHighlightAction class is used to inform an SoFCSelection node + * The SoFCEnablePreselectionAction class is used to inform an SoFCSelection node * whether preselection is enabled or disabled. * @author Werner Mayer */ -class GuiExport SoFCEnableHighlightAction : public SoAction +class GuiExport SoFCEnablePreselectionAction : public SoAction { - SO_ACTION_HEADER(SoFCEnableHighlightAction); + SO_ACTION_HEADER(SoFCEnablePreselectionAction); public: - SoFCEnableHighlightAction (const SbBool& sel); - ~SoFCEnableHighlightAction() override; + SoFCEnablePreselectionAction (const SbBool& sel); + ~SoFCEnablePreselectionAction() override; - SbBool highlight; + SbBool enabled; static void initClass(); static void finish(); @@ -164,7 +164,7 @@ private: /** * The SoFCHighlightColorAction class is used to inform an SoFCSelection node - * which preselection color is used. + * which highlight color is used. * @author Werner Mayer */ class GuiExport SoFCHighlightColorAction : public SoAction diff --git a/src/Gui/Selection/SoFCUnifiedSelection.cpp b/src/Gui/Selection/SoFCUnifiedSelection.cpp index 0c6ae57006..2be6b29bd4 100644 --- a/src/Gui/Selection/SoFCUnifiedSelection.cpp +++ b/src/Gui/Selection/SoFCUnifiedSelection.cpp @@ -312,9 +312,9 @@ SoFCUnifiedSelection::getPickedList(SoHandleEventAction* action, bool singlePick void SoFCUnifiedSelection::doAction(SoAction *action) { - if (action->getTypeId() == SoFCEnableHighlightAction::getClassTypeId()) { - auto enableHighlightAction = static_cast(action); - if (enableHighlightAction->highlight) { + if (action->getTypeId() == SoFCEnablePreselectionAction::getClassTypeId()) { + auto enablePreselectionAction = static_cast(action); + if (enablePreselectionAction->enabled) { this->preselectionMode = SoFCUnifiedSelection::AUTO; } else { @@ -324,7 +324,7 @@ void SoFCUnifiedSelection::doAction(SoAction *action) if (action->getTypeId() == SoFCEnableSelectionAction::getClassTypeId()) { auto enableSelectionAction = static_cast(action); - if (enableSelectionAction->selection) { + if (enableSelectionAction->enabled) { this->selectionMode = SoFCUnifiedSelection::ON; } else { diff --git a/src/Gui/View3DSettings.cpp b/src/Gui/View3DSettings.cpp index a91c21709c..c1a2f7e3d9 100644 --- a/src/Gui/View3DSettings.cpp +++ b/src/Gui/View3DSettings.cpp @@ -185,7 +185,7 @@ void View3DSettings::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M } else if (strcmp(Reason,"EnablePreselection") == 0) { const ParameterGrp& rclGrp = ((ParameterGrp&)rCaller); - SoFCEnableHighlightAction cAct(rclGrp.GetBool("EnablePreselection", true)); + SoFCEnablePreselectionAction cAct(rclGrp.GetBool("EnablePreselection", true)); for (auto _viewer : _viewers) { cAct.apply(_viewer->getSceneGraph()); } From 8d6775e83781057b0f4bc10e4a6392375a0cb004 Mon Sep 17 00:00:00 2001 From: tritao Date: Wed, 15 Jan 2025 13:39:43 +0000 Subject: [PATCH 09/10] Gui: Rename `SoFCHighlightAction` to preselect terminology. --- src/Gui/Selection/SoFCSelectionAction.cpp | 48 +++++++++++----------- src/Gui/Selection/SoFCSelectionAction.h | 12 +++--- src/Gui/Selection/SoFCUnifiedSelection.cpp | 16 ++++---- src/Gui/SoFCDB.cpp | 8 ++-- src/Gui/View3DInventorViewer.cpp | 8 ++-- 5 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/Gui/Selection/SoFCSelectionAction.cpp b/src/Gui/Selection/SoFCSelectionAction.cpp index 55f4f06067..6d66687b5e 100644 --- a/src/Gui/Selection/SoFCSelectionAction.cpp +++ b/src/Gui/Selection/SoFCSelectionAction.cpp @@ -69,7 +69,7 @@ using namespace Gui; -SO_ACTION_SOURCE(SoFCHighlightAction) +SO_ACTION_SOURCE(SoFCPreselectionAction) /** * The order of the defined SO_ACTION_ADD_METHOD statements is very important. First the base @@ -79,28 +79,28 @@ SO_ACTION_SOURCE(SoFCHighlightAction) * This means that \c SoSwitch must be listed after \c SoGroup and \c SoFCSelection after * \c SoSeparator because both classes inherits the others. */ -void SoFCHighlightAction::initClass() +void SoFCPreselectionAction::initClass() { - SO_ACTION_INIT_CLASS(SoFCHighlightAction,SoAction); + SO_ACTION_INIT_CLASS(SoFCPreselectionAction,SoAction); - SO_ENABLE(SoFCHighlightAction, SoSwitchElement); + SO_ENABLE(SoFCPreselectionAction, SoSwitchElement); SO_ACTION_ADD_METHOD(SoNode,nullAction); - SO_ENABLE(SoFCHighlightAction, SoModelMatrixElement); - SO_ENABLE(SoFCHighlightAction, SoShapeStyleElement); - SO_ENABLE(SoFCHighlightAction, SoComplexityElement); - SO_ENABLE(SoFCHighlightAction, SoComplexityTypeElement); - SO_ENABLE(SoFCHighlightAction, SoCoordinateElement); - SO_ENABLE(SoFCHighlightAction, SoFontNameElement); - SO_ENABLE(SoFCHighlightAction, SoFontSizeElement); - SO_ENABLE(SoFCHighlightAction, SoProfileCoordinateElement); - SO_ENABLE(SoFCHighlightAction, SoProfileElement); - SO_ENABLE(SoFCHighlightAction, SoSwitchElement); - SO_ENABLE(SoFCHighlightAction, SoUnitsElement); - SO_ENABLE(SoFCHighlightAction, SoViewVolumeElement); - SO_ENABLE(SoFCHighlightAction, SoViewingMatrixElement); - SO_ENABLE(SoFCHighlightAction, SoViewportRegionElement); + SO_ENABLE(SoFCPreselectionAction, SoModelMatrixElement); + SO_ENABLE(SoFCPreselectionAction, SoShapeStyleElement); + SO_ENABLE(SoFCPreselectionAction, SoComplexityElement); + SO_ENABLE(SoFCPreselectionAction, SoComplexityTypeElement); + SO_ENABLE(SoFCPreselectionAction, SoCoordinateElement); + SO_ENABLE(SoFCPreselectionAction, SoFontNameElement); + SO_ENABLE(SoFCPreselectionAction, SoFontSizeElement); + SO_ENABLE(SoFCPreselectionAction, SoProfileCoordinateElement); + SO_ENABLE(SoFCPreselectionAction, SoProfileElement); + SO_ENABLE(SoFCPreselectionAction, SoSwitchElement); + SO_ENABLE(SoFCPreselectionAction, SoUnitsElement); + SO_ENABLE(SoFCPreselectionAction, SoViewVolumeElement); + SO_ENABLE(SoFCPreselectionAction, SoViewingMatrixElement); + SO_ENABLE(SoFCPreselectionAction, SoViewportRegionElement); @@ -125,28 +125,28 @@ void SoFCHighlightAction::initClass() SO_ACTION_ADD_METHOD(SoPointSet,callDoAction); } -void SoFCHighlightAction::finish() +void SoFCPreselectionAction::finish() { atexit_cleanup(); } -SoFCHighlightAction::SoFCHighlightAction (const SelectionChanges &SelCh) +SoFCPreselectionAction::SoFCPreselectionAction (const SelectionChanges &SelCh) :SelChange(SelCh) { - SO_ACTION_CONSTRUCTOR(SoFCHighlightAction); + SO_ACTION_CONSTRUCTOR(SoFCPreselectionAction); } -SoFCHighlightAction::~SoFCHighlightAction() = default; +SoFCPreselectionAction::~SoFCPreselectionAction() = default; -void SoFCHighlightAction::beginTraversal(SoNode *node) +void SoFCPreselectionAction::beginTraversal(SoNode *node) { traverse(node); } -void SoFCHighlightAction::callDoAction(SoAction *action,SoNode *node) +void SoFCPreselectionAction::callDoAction(SoAction *action,SoNode *node) { node->doAction(action); } diff --git a/src/Gui/Selection/SoFCSelectionAction.h b/src/Gui/Selection/SoFCSelectionAction.h index c3e36e0c06..f1c3191056 100644 --- a/src/Gui/Selection/SoFCSelectionAction.h +++ b/src/Gui/Selection/SoFCSelectionAction.h @@ -38,17 +38,17 @@ namespace Gui { class SelectionChanges; /** - * The SoFCHighlightAction class is used to inform an SoFCSelection node - * whether an object gets highlighted. + * The SoFCPreselectionAction class is used to inform an SoFCSelection node + * whether an object gets preselected. * @author Jürgen Riegel */ -class GuiExport SoFCHighlightAction : public SoAction +class GuiExport SoFCPreselectionAction : public SoAction { - SO_ACTION_HEADER(SoFCHighlightAction); + SO_ACTION_HEADER(SoFCPreselectionAction); public: - SoFCHighlightAction (const SelectionChanges &SelCh); - ~SoFCHighlightAction() override; + SoFCPreselectionAction (const SelectionChanges &SelCh); + ~SoFCPreselectionAction() override; static void initClass(); static void finish(); diff --git a/src/Gui/Selection/SoFCUnifiedSelection.cpp b/src/Gui/Selection/SoFCUnifiedSelection.cpp index 2be6b29bd4..79460ba148 100644 --- a/src/Gui/Selection/SoFCUnifiedSelection.cpp +++ b/src/Gui/Selection/SoFCUnifiedSelection.cpp @@ -342,10 +342,10 @@ void SoFCUnifiedSelection::doAction(SoAction *action) this->colorHighlight = highlightColorAction->highlightColor; } - if (action->getTypeId() == SoFCHighlightAction::getClassTypeId()) { - auto highlightAction = static_cast(action); - // Do not clear currently highlighted object when setting new pre-selection - if (!setPreSelection && highlightAction->SelChange.Type == SelectionChanges::RmvPreselect) { + if (action->getTypeId() == SoFCPreselectionAction::getClassTypeId()) { + auto preselectAction = static_cast(action); + // Do not clear currently preselected object when setting new pre-selection + if (!setPreSelection && preselectAction->SelChange.Type == SelectionChanges::RmvPreselect) { if (currentHighlightPath) { SoHighlightElementAction highlightAction; highlightAction.apply(currentHighlightPath); @@ -354,7 +354,7 @@ void SoFCUnifiedSelection::doAction(SoAction *action) } } else if (preselectionMode.getValue() != OFF - && highlightAction->SelChange.Type == SelectionChanges::SetPreselect) { + && preselectAction->SelChange.Type == SelectionChanges::SetPreselect) { if (currentHighlightPath) { SoHighlightElementAction highlightAction; highlightAction.apply(currentHighlightPath); @@ -362,10 +362,10 @@ void SoFCUnifiedSelection::doAction(SoAction *action) currentHighlightPath = nullptr; } - App::Document* doc = App::GetApplication().getDocument(highlightAction->SelChange.pDocName); - App::DocumentObject* obj = doc->getObject(highlightAction->SelChange.pObjectName); + App::Document* doc = App::GetApplication().getDocument(preselectAction->SelChange.pDocName); + App::DocumentObject* obj = doc->getObject(preselectAction->SelChange.pObjectName); ViewProvider*vp = Application::Instance->getViewProvider(obj); - SoDetail* detail = vp->getDetail(highlightAction->SelChange.pSubName); + SoDetail* detail = vp->getDetail(preselectAction->SelChange.pSubName); SoHighlightElementAction highlightAction; highlightAction.setHighlighted(true); diff --git a/src/Gui/SoFCDB.cpp b/src/Gui/SoFCDB.cpp index d762615c11..43b18b56b1 100644 --- a/src/Gui/SoFCDB.cpp +++ b/src/Gui/SoFCDB.cpp @@ -107,13 +107,13 @@ void Gui::SoFCDB::init() SoFCBoundingBox ::initClass(); SoFCSelection ::initClass(); SoFCUnifiedSelection ::initClass(); - SoFCHighlightAction ::initClass(); + SoFCPreselectionAction ::initClass(); SoFCSelectionAction ::initClass(); SoFCDocumentAction ::initClass(); SoGLWidgetNode ::initClass(); SoGLVBOActivatedElement ::initClass(); SoFCEnableSelectionAction ::initClass(); - SoFCEnableHighlightAction ::initClass(); + SoFCEnablePreselectionAction ::initClass(); SoFCSelectionColorAction ::initClass(); SoFCHighlightColorAction ::initClass(); SoFCDocumentObjectAction ::initClass(); @@ -226,12 +226,12 @@ void Gui::SoFCDB::finish() SoFCBackgroundGradient ::finish(); SoFCBoundingBox ::finish(); SoFCSelection ::finish(); - SoFCHighlightAction ::finish(); + SoFCPreselectionAction ::finish(); SoFCSelectionAction ::finish(); SoFCDocumentAction ::finish(); SoFCDocumentObjectAction ::finish(); SoFCEnableSelectionAction ::finish(); - SoFCEnableHighlightAction ::finish(); + SoFCEnablePreselectionAction ::finish(); SoFCSelectionColorAction ::finish(); SoUpdateVBOAction ::finish(); SoFCHighlightColorAction ::finish(); diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index 9f677de628..13ec6525af 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -794,11 +794,11 @@ void View3DInventorViewer::onSelectionChanged(const SelectionChanges & reason) { //Hint: do not create a tmp. instance of SelectionChanges SelectionChanges selChanges(SelectionChanges::RmvPreselect); - SoFCHighlightAction cAct(selChanges); - cAct.apply(pcViewProviderRoot); + SoFCPreselectionAction preselectionAction(selChanges); + preselectionAction.apply(pcViewProviderRoot); } else { - SoFCSelectionAction cAct(Reason); - cAct.apply(pcViewProviderRoot); + SoFCSelectionAction selectionAction(Reason); + selectionAction.apply(pcViewProviderRoot); } } /// @endcond From 9e1fa947e54ffe4706f8f200c0fed29cbccbbe0b Mon Sep 17 00:00:00 2001 From: tritao Date: Wed, 15 Jan 2025 17:47:49 +0000 Subject: [PATCH 10/10] Gui: Fix single usage of `SelectionSingleton::instance()`. --- src/Gui/3Dconnexion/navlib/NavlibPivot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Gui/3Dconnexion/navlib/NavlibPivot.cpp b/src/Gui/3Dconnexion/navlib/NavlibPivot.cpp index 09ccde1878..86237942bb 100644 --- a/src/Gui/3Dconnexion/navlib/NavlibPivot.cpp +++ b/src/Gui/3Dconnexion/navlib/NavlibPivot.cpp @@ -57,7 +57,7 @@ long NavlibInterface::GetSelectionTransform(navlib::matrix_t&) const long NavlibInterface::GetIsSelectionEmpty(navlib::bool_t& empty) const { - empty = !Gui::SelectionSingleton::instance().hasSelection(); + empty = !Gui::Selection().hasSelection(); return 0; }