From 3e644ed2af8357b42d91b634bd92f3cda2ee4bf1 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Tue, 21 Sep 2021 13:45:52 +0200 Subject: [PATCH] Sketcher: Constraint hiding/showing not working properly for combined constraint icons ====================================================================================== Hiden constraint icons should not be grouped into combined icons. This may also improve selection of combined (stacked) icons. fixes #4590 --- src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 55 ++++++++++++--------- src/Mod/Sketcher/Gui/ViewProviderSketch.h | 2 + 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index cfeb1c0e59..3459526a49 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -3455,6 +3455,7 @@ void ViewProviderSketch::drawConstraintIcons() thisIcon.position = absPos; thisIcon.destination = coinIconPtr; thisIcon.infoPtr = infoPtr; + thisIcon.visible = (*it)->isInVirtualSpace == getIsShownVirtualSpace(); if ((*it)->Type==Symmetric) { Base::Vector3d startingpoint = getSketchObject()->getPoint((*it)->First,(*it)->FirstPos); @@ -3539,36 +3540,44 @@ void ViewProviderSketch::combineConstraintIcons(IconQueue iconQueue) iconQueue.pop_back(); // we group only icons not being Symmetry icons, because we want those on the line - if(init.type != QString::fromLatin1("Constraint_Symmetric")){ + // and only icons that are visible + if(init.type != QString::fromLatin1("Constraint_Symmetric") && init.visible){ IconQueue::iterator i = iconQueue.begin(); + + while(i != iconQueue.end()) { - bool addedToGroup = false; + if((*i).visible) { + bool addedToGroup = false; - for(IconQueue::iterator j = thisGroup.begin(); - j != thisGroup.end(); ++j) { - float distSquared = pow(i->position[0]-j->position[0],2) + pow(i->position[1]-j->position[1],2); - if(distSquared <= maxDistSquared && (*i).type != QString::fromLatin1("Constraint_Symmetric")) { - // Found an icon in iconQueue that's close enough to - // a member of thisGroup, so move it into thisGroup - thisGroup.push_back(*i); - i = iconQueue.erase(i); - addedToGroup = true; - break; + for(IconQueue::iterator j = thisGroup.begin(); + j != thisGroup.end(); ++j) { + float distSquared = pow(i->position[0]-j->position[0],2) + pow(i->position[1]-j->position[1],2); + if(distSquared <= maxDistSquared && (*i).type != QString::fromLatin1("Constraint_Symmetric")) { + // Found an icon in iconQueue that's close enough to + // a member of thisGroup, so move it into thisGroup + thisGroup.push_back(*i); + i = iconQueue.erase(i); + addedToGroup = true; + break; + } } - } - if(addedToGroup) { - if(i == iconQueue.end()) - // We just got the last icon out of iconQueue - break; - else - // Start looking through the iconQueue again, in case - // we have an icon that's now close enough to thisGroup - i = iconQueue.begin(); - } else - ++i; + if(addedToGroup) { + if(i == iconQueue.end()) + // We just got the last icon out of iconQueue + break; + else + // Start looking through the iconQueue again, in case + // we have an icon that's now close enough to thisGroup + i = iconQueue.begin(); + } else + ++i; + } + else // if !visible we skip it + i++; } + } if(thisGroup.size() == 1) { diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.h b/src/Mod/Sketcher/Gui/ViewProviderSketch.h index 2486301a62..598ff154c9 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.h +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.h @@ -370,6 +370,8 @@ protected: /// Angle to rotate an icon double iconRotation; + + bool visible; }; /// Internal type used for drawing constraint icons