Sketcher: fix false detection of doubleclick

Double-click detector code was comparing double-click threshold (value =
5) with distance between clicked objects in model space (i.e.
double-click distance threshold was equal to 5 mm in model space
regardless of zoom). The fix changes the comparison to pixels on screen
instead.

This fixes the inability to select sketch entities in quick succession,
when the sketch is small (i.e. less than 40 mm or so).
This commit is contained in:
DeepSOIC
2017-11-10 17:31:00 +03:00
parent 210a48cbf3
commit 356e2810a4
2 changed files with 6 additions and 6 deletions

View File

@@ -147,7 +147,7 @@ SbColor ViewProviderSketch::SelectColor (0.11f,0.68f,0.11f); //
SbColor ViewProviderSketch::PreselectSelectedColor (0.36f,0.48f,0.11f); // #5D7B1C -> ( 93,123, 28)
// Variables for holding previous click
SbTime ViewProviderSketch::prvClickTime;
SbVec3f ViewProviderSketch::prvClickPoint;
SbVec2s ViewProviderSketch::prvClickPos;
SbVec2s ViewProviderSketch::prvCursorPos;
SbVec2s ViewProviderSketch::newCursorPos;
@@ -617,19 +617,19 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe
float dci = (float) QApplication::doubleClickInterval()/1000.0f;
if (done &&
(point - prvClickPoint).length() < dblClickRadius &&
SbVec2f(cursorPos - prvClickPos).length() < dblClickRadius &&
(SbTime::getTimeOfDay() - prvClickTime).getValue() < dci) {
// Double Click Event Occurred
editDoubleClicked();
// Reset Double Click Static Variables
prvClickTime = SbTime();
prvClickPoint = SbVec3f(0.0f, 0.0f, 0.0f);
Mode = STATUS_NONE;
prvClickPos = SbVec2s(-16000,-16000); //certainly far away from any clickable place, to avoid re-trigger of double-click if next click happens fast.
Mode = STATUS_NONE;
} else {
prvClickTime = SbTime::getTimeOfDay();
prvClickPoint = point;
prvClickPos = cursorPos;
prvCursorPos = cursorPos;
newCursorPos = cursorPos;
if (!done)

View File

@@ -378,7 +378,7 @@ protected:
static SbColor InformationColor;
static SbTime prvClickTime;
static SbVec3f prvClickPoint;
static SbVec2s prvClickPos; //used by double-click-detector
static SbVec2s prvCursorPos;
static SbVec2s newCursorPos;