From 11c76c998e80428c6931c3b678940124a9518dfe Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Thu, 20 Apr 2023 19:40:40 +0200 Subject: [PATCH] Sketcher: Fix double icons not selectable ========================================= The scaling factor used was the one of the ViewProviderSketch, however ZoomTranslation uses its own scaling factor. fixes #6283 --- .../Gui/EditModeConstraintCoinManager.cpp | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Mod/Sketcher/Gui/EditModeConstraintCoinManager.cpp b/src/Mod/Sketcher/Gui/EditModeConstraintCoinManager.cpp index 3f62f61884..4cbce1ef8b 100644 --- a/src/Mod/Sketcher/Gui/EditModeConstraintCoinManager.cpp +++ b/src/Mod/Sketcher/Gui/EditModeConstraintCoinManager.cpp @@ -1743,6 +1743,7 @@ std::set EditModeConstraintCoinManager::detectPreselectionConstr(const SoPi SbVec3f absPos; SbVec3f trans; + float scaleFactor; auto translation = static_cast(static_cast(tailFather)->getChild( static_cast(ConstraintNodePosition::FirstTranslationIndex))); @@ -1750,17 +1751,22 @@ std::set EditModeConstraintCoinManager::detectPreselectionConstr(const SoPi trans = translation->translation.getValue(); + scaleFactor = translation->getScaleFactor(); + if (tail != sep->getChild(static_cast(ConstraintNodePosition::FirstIconIndex))) { + Base::Console().Log("SecondIcon\n"); auto translation2 = static_cast(static_cast(tailFather)->getChild( static_cast(ConstraintNodePosition::SecondTranslationIndex))); absPos += translation2->abPos.getValue(); trans += translation2->translation.getValue(); + + scaleFactor = translation2->getScaleFactor(); } - // TODO: Is this calculation actually sound? Why the absolute position is not scaled and the translation is? Review. - SbVec3f constrPos = absPos + trans*ViewProviderSketchCoinAttorney::getScaleFactor(viewProvider); + // Only the translation is scaled because this is how SoZoomTranslation works + SbVec3f constrPos = absPos + scaleFactor*trans; SbVec2f iconCoords = ViewProviderSketchCoinAttorney::getScreenCoordinates(viewProvider, SbVec2f(constrPos[0],constrPos[1])); @@ -1785,16 +1791,20 @@ std::set EditModeConstraintCoinManager::detectPreselectionConstr(const SoPi if (b->first.contains(iconX, iconY)) { // We've found a bounding box that contains the mouse pointer! - for (std::set::iterator k = b->second.begin(); k != b->second.end(); ++k) + for (std::set::iterator k = b->second.begin(); k != b->second.end(); ++k) { constrIndices.insert(*k); + } } } } else { // It's a constraint icon, not a combined one QStringList constrIdStrings = constrIdsStr.split(QString::fromLatin1(",")); - while (!constrIdStrings.empty()) - constrIndices.insert(constrIdStrings.takeAt(0).toInt()); + while (!constrIdStrings.empty()) { + auto constraintid = constrIdStrings.takeAt(0).toInt(); + constrIndices.insert(constraintid); + + } } } }