bool DrawFreehandTool::mouseMoveEvent(QMouseEvent* event, MapCoordF map_coord, MapWidget* widget) { Q_UNUSED(widget); bool mouse_down = containsDrawingButtons(event->buttons()); if (!mouse_down) { if (!editingInProgress()) { setPreviewPointsPosition(map_coord); setDirtyRect(); } } else { if (!editingInProgress()) return false; dragging = true; cur_pos = event->pos(); cur_pos_map = map_coord; updatePath(); } return true; }
bool DrawRectangleTool::mouseMoveEvent(QMouseEvent* event, MapCoordF map_coord, MapWidget* widget) { Q_UNUSED(widget); cur_pos = event->pos(); cur_pos_map = map_coord; constrained_pos_map = cur_pos_map; updateHover(containsDrawingButtons(event->buttons())); return true; }
bool DrawCircleTool::mouseMoveEvent(QMouseEvent* event, MapCoordF map_coord, MapWidget* widget) { Q_UNUSED(widget); bool mouse_down = containsDrawingButtons(event->buttons()); if (!mouse_down) { if (!editingInProgress()) { setPreviewPointsPosition(map_coord); setDirtyRect(); } else { cur_pos = event->pos(); cur_pos_map = map_coord; if (!second_point_set) opposite_pos_map = map_coord; updateCircle(); } } else { if (!editingInProgress()) return false; if ((event->pos() - click_pos).manhattanLength() >= Settings::getInstance().getStartDragDistancePx()) { if (!dragging) { dragging = true; updateStatusText(); } } if (dragging) { cur_pos = event->pos(); cur_pos_map = map_coord; if (!second_point_set) opposite_pos_map = cur_pos_map; updateCircle(); } } return true; }
bool DrawPathTool::mouseMoveEvent(QMouseEvent* event, MapCoordF map_coord, MapWidget* widget) { cur_pos = event->pos(); cur_pos_map = map_coord; if (!containsDrawingButtons(event->buttons())) { updateHover(); } else if (!editingInProgress()) { left_mouse_down = true; if (picking_angle) pickAngle(map_coord, widget); else return false; } else if (following) { updateFollowing(); } else { bool drag_distance_reached = (event->pos() - click_pos).manhattanLength() >= Settings::getInstance().getStartDragDistancePx(); if (dragging && !drag_distance_reached) { if (create_spline_corner) { create_spline_corner = false; } else if (path_has_preview_point) { undoLastPoint(); } } else if (drag_distance_reached) { // Giving a direction by dragging dragging = true; create_spline_corner = false; create_segment = true; if (previous_point_is_curve_point) angle_helper->setCenter(click_pos_map); QPointF constrained_pos; angle_helper->getConstrainedCursorPositions(map_coord, constrained_pos_map, constrained_pos, widget); if (previous_point_is_curve_point) { hidePreviewPoints(); float drag_direction = calculateRotation(constrained_pos.toPoint(), constrained_pos_map); // Add a new node or convert the last node into a corner? if ((widget->mapToViewport(previous_pos_map) - click_pos).manhattanLength() >= Settings::getInstance().getStartDragDistancePx()) createPreviewCurve(MapCoord(click_pos_map), drag_direction); else { create_spline_corner = true; // This hides the old direction indicator previous_drag_map = previous_pos_map; } } updateDirtyRect(); } } return true; }