From 580f1752efd9d3e8c2890c4016b04dafd639bab7 Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 26 Oct 2015 14:39:14 +0300 Subject: [PATCH] Increase sensitivity for vertexes selection --- src/XGUI/XGUI_Displayer.cpp | 17 +++++++++++------ src/XGUI/XGUI_Displayer.h | 4 ++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index b68df4408..a3a39a870 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -220,8 +220,10 @@ bool XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS, // the fix from VPA for more suitable selection of sketcher lines if(anAISIO->Width() > 1) { for(int aModeIdx = 0; aModeIdx < myActiveSelectionModes.length(); ++aModeIdx) { - aContext->SetSelectionSensitivity(anAISIO, - myActiveSelectionModes.value(aModeIdx), anAISIO->Width() + 2); + int aMode = myActiveSelectionModes.value(aModeIdx); + double aPrecision = (aMode == getSelectionMode(TopAbs_VERTEX))? 15 : + (anAISIO->Width() + 2); + aContext->SetSelectionSensitivity(anAISIO, aMode, aPrecision); } } } @@ -390,16 +392,19 @@ void XGUI_Displayer::getModesOfActivation(ObjectPtr theObject, QIntList& theMode } } +int XGUI_Displayer::getSelectionMode(int theShapeType) +{ + return (theShapeType >= TopAbs_SHAPE)? theShapeType : + AIS_Shape::SelectionMode((TopAbs_ShapeEnum)theShapeType); +} + void XGUI_Displayer::activateObjects(const QIntList& theModes, const QObjectPtrList& theObjList, const bool theUpdateViewer) { // Convert shape types to selection types QIntList aModes; foreach(int aType, theModes) { - if (aType >= TopAbs_SHAPE) - aModes.append(aType); - else - aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)aType)); + aModes.append(getSelectionMode(aType)); } #ifdef DEBUG_ACTIVATE_OBJECTS diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index 3cd6f9c73..91129ece6 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -226,6 +226,10 @@ class XGUI_EXPORT XGUI_Displayer: public QObject /// \param theUpdateViewer update viewer flag /// \return previously defined color on the object QColor setObjectColor(ObjectPtr theObject, const QColor& theColor, bool theUpdateViewer = true); + + /// Converts shape type (TopAbs_ShapeEnum) to selection mode + /// \param theShapeType a shape type from TopAbs_ShapeEnum + static int getSelectionMode(int theShapeType); signals: /// Signal on object display -- 2.39.2