sec_interp.gui.tools.measure_tool module

Measurement tool for Profile View.

This module provides the ProfileMeasureTool for measuring distances, elevation differences, and slopes in the profile preview window. It separates UI event handling from spatial snapping logic.

class sec_interp.gui.tools.measure_tool.ProfileMeasureTool(*args: Any, **kwargs: Any)

Bases: QgsMapToolEmitPoint

Map tool for measuring distances in profile view.

Supports multi-point polyline measurements: - Click to add points along the trace - Click “Finalizar” button in UI to complete measurement - Right-click or Escape to cancel and reset

__init__(canvas: qgis.gui.QgsMapCanvas) None

Initialize the profile measurement tool.

Parameters:

canvas – The map canvas where measurement is performed.

activate() None

Activate the measurement tool.

canvasMoveEvent(event: Any) None

Handle mouse move for rubber band update.

Parameters:

event – Map tool event from QGIS

canvasReleaseEvent(event: Any) None

Handle mouse click release.

  • Left click: Add point to measurement

  • Right click: Cancel and reset

  • Press Enter to finalize (see keyPressEvent)

Parameters:

event – Map tool event from QGIS

deactivate() None

Deactivate the measurement tool.

Note: We no longer call reset() here to allow measurements to persist visually until a new one is started or explicitly cleared.

finalize_measurement() None

Finalize the measurement and emit final metrics.

This is a public method that can be called from UI buttons. After finalizing, the tool is deactivated but results remain visible.

keyPressEvent(event: Any) None

Handle keyboard events.

  • Enter/Return: Finalize measurement

  • Escape: Cancel measurement

Parameters:

event – Key event from QGIS

measurementChanged

alias of dict

reset() None

Reset the tool state.

If measurement is finalized, only clears the points data but keeps the visual elements (rubber band and markers) visible.

class sec_interp.gui.tools.measure_tool.ProfileSnapper(canvas: qgis.gui.QgsMapCanvas)

Bases: object

Helper class to handle point snapping functionality.

__init__(canvas: qgis.gui.QgsMapCanvas) None

Initialize the profile snapper.

Parameters:

canvas – The map canvas to snap on.

snap(mouse_pos: qgis.PyQt.QtCore.QPoint) qgis.core.QgsPointXY

Find the nearest vertex or edge to the mouse position.