Skip to content

Commit

Permalink
Sketcher: Ignore small mouse moves after selection.
Browse files Browse the repository at this point in the history
Switch to drag mode only after cursor moved 3 pixels.
  • Loading branch information
itain authored and wwmayer committed Aug 24, 2014
1 parent 3c8a00d commit 6eeaae5
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/Mod/Sketcher/Gui/ViewProviderSketch.cpp
Expand Up @@ -914,9 +914,22 @@ void ViewProviderSketch::editDoubleClicked(void)

bool ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventorViewer *viewer)
{
// maximum radius for mouse moves when selecting a geometry before switching to drag mode
const int dragIgnoredDistance = 3;

if (!edit)
return false;
assert(edit);

// ignore small moves after selection
switch (Mode) {
case STATUS_SELECT_Point:
case STATUS_SELECT_Edge:
case STATUS_SELECT_Constraint:
short dx, dy;
(cursorPos - prvCursorPos).getValue(dx, dy);
if(std::abs(dx) < dragIgnoredDistance && std::abs(dy) < dragIgnoredDistance)
return false;
}

// Calculate 3d point to the mouse position
SbLine line;
Expand All @@ -927,7 +940,10 @@ bool ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventor
snapToGrid(x, y);

bool preselectChanged;
if (Mode != STATUS_SKETCH_DragPoint &&
if (Mode != STATUS_SELECT_Point &&
Mode != STATUS_SELECT_Edge &&
Mode != STATUS_SELECT_Constraint &&
Mode != STATUS_SKETCH_DragPoint &&
Mode != STATUS_SKETCH_DragCurve &&
Mode != STATUS_SKETCH_DragConstraint &&
Mode != STATUS_SKETCH_UseRubberBand) {
Expand Down Expand Up @@ -976,8 +992,14 @@ bool ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventor
const Part::Geometry *geo = getSketchObject()->getGeometry(edit->DragCurve);
if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) {
relative = true;
xInit = x;
yInit = y;
//xInit = x;
//yInit = y;
// Since the cursor moved from where it was clicked, and this is a relative move,
// calculate the click position and use it as initial point.
SbLine line2;
getProjectingLine(prvCursorPos, viewer, line2);
getCoordsOnSketchPlane(xInit,yInit,line2.getPosition(),line2.getDirection());
snapToGrid(xInit, yInit);
} else {
relative = false;
xInit = 0;
Expand Down

0 comments on commit 6eeaae5

Please sign in to comment.