Skip to content

Implement clone stamp tool for raster editing - #55

Open
aaronque wants to merge 1 commit into
lutraconsulting:masterfrom
aaronque:master
Open

aaronque wants to merge 1 commit into
lutraconsulting:masterfrom
aaronque:master

Conversation

@aaronque

Copy link
Copy Markdown

Hi Radosław and the Lutra Consulting team! First of all, thank you for this amazing and incredibly useful plugin.

The Problem:
When working with high-resolution DSMs (Digital Surface Models), power lines and narrow obstacles are often captured and act as solid walls, which completely ruins viewshed or line-of-sight analyses. While the current "Apply Low-Pass Filter" is great, using it over a power line and its surrounding terrain creates a flat "terrace" (it averages the heights). We needed a way to remove the obstacle while perfectly preserving the natural slope and texture of the surrounding terrain.

The Solution:
I've implemented a true "Clone Stamp" tool (similar to Photoshop's workflow) built natively on top of your RasterHandler.

Key Features:

  • ServalCloneTool (Custom QgsMapTool): Allows for continuous brush strokes (dragging) rather than just single clicks.
  • Texture Preserving: Right-clicking sets the source origin. Left-clicking and dragging reads the exact pixel grid from the source offset and writes it to the target cell by cell, perfectly preserving terrain slopes and textures.
  • Brush Size Control: Added a new SpinBox to the toolbar to adjust the pixel width of the brush dynamically.
  • Undo/Redo Optimized: Implemented a distance threshold logic inside the canvasMoveEvent. The tool only writes a new block when the mouse moves a certain distance based on the brush size, preventing the QGIS undo stack from flooding during long brush strokes.

All changes are integrated smoothly into the existing UI and respect the current plugin architecture. I hope you find this contribution useful for the community! Let me know if you need any adjustments to the code.

Added a clone stamp tool to the toolbar for raster editing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant