void DrawPathTool::updateDirtyRect() { QRectF rect; if (dragging) { rectIncludeSafe(rect, click_pos_map); rectInclude(rect, cur_pos_map); } if (editingInProgress() && previous_point_is_curve_point) { rectIncludeSafe(rect, previous_pos_map); rectInclude(rect, previous_drag_map); } if ((editingInProgress() && !dragging) || (!editingInProgress() && !shift_pressed && ctrl_pressed) || (!editingInProgress() && (picking_angle || picked_angle))) { angle_helper->includeDirtyRect(rect); } if (shift_pressed || (!editingInProgress() && ctrl_pressed)) snap_helper->includeDirtyRect(rect); includePreviewRects(rect); if (is_helper_tool) emit(dirtyRectChanged(rect)); else { if (rect.isValid()) map()->setDrawingBoundingBox(rect, qMax(qMax(dragging ? 1 : 0, angle_helper->getDisplayRadius()), snap_helper->getDisplayRadius()), true); else map()->clearDrawingBoundingBox(); } }
void DrawRectangleTool::updateDirtyRect() { QRectF rect; includePreviewRects(rect); if (shift_pressed) snap_helper->includeDirtyRect(rect); if (is_helper_tool) emit(dirtyRectChanged(rect)); else { if (angle_helper->isActive()) angle_helper->includeDirtyRect(rect); if (rect.isValid()) { float helper_cross_radius = Settings::getInstance().getRectangleToolHelperCrossRadiusPx(); int pixel_border = 0; if (editingInProgress()) pixel_border = helper_cross_radius; // helper_cross_radius as border is less than ideal but the only way to always ensure visibility of the helper cross at the moment if (angle_helper->isActive()) pixel_border = qMax(pixel_border, angle_helper->getDisplayRadius()); map()->setDrawingBoundingBox(rect, pixel_border, true); } else map()->clearDrawingBoundingBox(); } }
bool CutHoleTool::mousePressEvent(QMouseEvent* event, MapCoordF map_coord, MapWidget* widget) { if (path_tool) return path_tool->mousePressEvent(event, map_coord, widget); if (!(event->buttons() & Qt::LeftButton)) return false; // Start a new hole edit_widget = widget; switch (hole_type) { case CutHoleTool::Path: path_tool = new DrawPathTool(editor, NULL, true, true); break; case CutHoleTool::Circle: path_tool = new DrawCircleTool(editor, NULL, true); break; case CutHoleTool::Rect: path_tool = new DrawRectangleTool(editor, NULL, true); break; /* no default; watch compiler warnings for unhandled cases! */ } connect(path_tool, SIGNAL(dirtyRectChanged(QRectF)), this, SLOT(pathDirtyRectChanged(QRectF))); connect(path_tool, SIGNAL(pathAborted()), this, SLOT(pathAborted())); connect(path_tool, SIGNAL(pathFinished(PathObject*)), this, SLOT(pathFinished(PathObject*))); path_tool->init(); path_tool->mousePressEvent(event, map_coord, widget); return true; }
void DrawCircleTool::setDirtyRect() { QRectF rect; includePreviewRects(rect); if (is_helper_tool) emit(dirtyRectChanged(rect)); else { if (rect.isValid()) map()->setDrawingBoundingBox(rect, 0, true); else map()->clearDrawingBoundingBox(); } }
void CutTool::startCuttingArea(const PathCoord& coord, MapWidget* widget) { drag_part_index = edit_object->findPartIndexForIndex(coord.index); if (drag_part_index > 0) { QMessageBox::warning(window(), tr("Error"), tr("Splitting holes of area objects is not supported yet!")); return; } cutting_area = true; drag_start_len = coord.clen; edit_widget = widget; path_tool = new DrawPathTool(editor, nullptr, true, false); connect(path_tool, SIGNAL(dirtyRectChanged(QRectF)), this, SLOT(pathDirtyRectChanged(QRectF))); connect(path_tool, SIGNAL(pathAborted()), this, SLOT(pathAborted())); connect(path_tool, SIGNAL(pathFinished(PathObject*)), this, SLOT(pathFinished(PathObject*))); }