SWMMVis  6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
OpenSWMMVisMapToolMeasure Class Reference

Interactive tool for measuring geodesic distances or areas on the map. More...

#include <maptoolmeasure.h>

Inheritance diagram for OpenSWMMVisMapToolMeasure:
Collaboration diagram for OpenSWMMVisMapToolMeasure:

Signals

void modeChanged (MeasureMode mode)
 
void distanceUnitChanged (MeasurementUnitManager::DistanceUnit unit)
 
void areaUnitChanged (MeasurementUnitManager::AreaUnit unit)
 
void totalChanged (double total)
 
void measurementCleared ()
 
- Signals inherited from OpenSWMMVisMapTool
void cursorChanged (const QCursor &cursor)
 
void activeChanged (bool active)
 
void repaintRequested ()
 Emitted to instruct the canvas to repaint its overlay.
 

Public Member Functions

 OpenSWMMVisMapToolMeasure (MapCanvas *canvas, QObject *parent=nullptr)
 
 ~OpenSWMMVisMapToolMeasure () override
 
QCursor cursor () const override
 Returns the mouse cursor to display while this tool is active.
 
MeasureMode mode () const
 
void setMode (MeasureMode mode)
 
MeasurementUnitManager::DistanceUnit distanceUnit () const
 
void setDistanceUnit (MeasurementUnitManager::DistanceUnit unit)
 
MeasurementUnitManager::AreaUnit areaUnit () const
 
void setAreaUnit (MeasurementUnitManager::AreaUnit unit)
 
double total () const
 Returns the cumulative measured value in the selected unit.
 
void clearMeasurement ()
 
void activate () override
 Called by the canvas when this tool becomes the active tool.
 
void deactivate () override
 Called by the canvas when another tool replaces this one.
 
void mousePressEvent (QMouseEvent *event) override
 
void mouseMoveEvent (QMouseEvent *event) override
 
void mouseDoubleClickEvent (QMouseEvent *event) override
 
void keyPressEvent (QKeyEvent *event) override
 
void paint (QPainter *painter, const MapExtent &canvasExtent, const SpatialReferenceSystem *canvasSRS) override
 Called by the canvas in drawForeground() so the tool can draw transient overlay graphics (rubber-band, measure segments, etc.).
 
- Public Member Functions inherited from OpenSWMMVisMapTool
 OpenSWMMVisMapTool (const QString &toolName, MapCanvas *canvas, QObject *parent=nullptr)
 
virtual ~OpenSWMMVisMapTool ()=default
 
QString toolName () const
 Returns the human-readable name of this tool.
 
bool isActive () const
 Returns true when this tool is the active tool on its canvas.
 
MapCanvascanvas () const
 Returns the MapCanvas this tool is attached to.
 
virtual void mouseReleaseEvent (QMouseEvent *event)
 
virtual void wheelEvent (QWheelEvent *event)
 
virtual void keyReleaseEvent (QKeyEvent *event)
 
QGraphicsScene * scene () const
 Returns the scene this tool's canvas is using.
 
void toMapCoords (int px, int py, double &mapX, double &mapY) const
 Converts a widget pixel position to map coordinates.
 
void toPixelCoords (double mapX, double mapY, int &px, int &py) const
 Converts map coordinates to widget pixel position.
 

Properties

MeasureMode mode
 
double total
 
- Properties inherited from OpenSWMMVisMapTool
QString toolName
 
QCursor cursor
 
bool active
 

Additional Inherited Members

- Protected Attributes inherited from OpenSWMMVisMapTool
QString m_toolName
 
MapCanvasm_canvas = nullptr
 

Detailed Description

Interactive tool for measuring geodesic distances or areas on the map.

Measurements are CRS-aware:

  • Geographic CRS (lon/lat): coordinates are transformed to WGS-84 then the Haversine formula (R = 6 378 137 m) is applied.
  • Projected CRS: Euclidean distance in CRS linear units × linearUnitsToMetres().
  • Local / undefined CRS: raw Euclidean with no unit label.

Distance mode: shows a cumulative label at every committed vertex. Area mode: shows a semi-transparent polygon fill while drawing. Double-click finalises the measurement; subsequent left-click starts a new one. Escape removes the last vertex while drawing; clears a finalised result.

Constructor & Destructor Documentation

◆ OpenSWMMVisMapToolMeasure()

OpenSWMMVisMapToolMeasure::OpenSWMMVisMapToolMeasure ( MapCanvas canvas,
QObject *  parent = nullptr 
)
explicit
Here is the call graph for this function:

◆ ~OpenSWMMVisMapToolMeasure()

OpenSWMMVisMapToolMeasure::~OpenSWMMVisMapToolMeasure ( )
override

Member Function Documentation

◆ activate()

void OpenSWMMVisMapToolMeasure::activate ( )
overridevirtual

Called by the canvas when this tool becomes the active tool.

Reimplemented from OpenSWMMVisMapTool.

Here is the call graph for this function:

◆ areaUnit()

MeasurementUnitManager::AreaUnit OpenSWMMVisMapToolMeasure::areaUnit ( ) const
Here is the caller graph for this function:

◆ areaUnitChanged

void OpenSWMMVisMapToolMeasure::areaUnitChanged ( MeasurementUnitManager::AreaUnit  unit)
signal
Here is the caller graph for this function:

◆ clearMeasurement()

void OpenSWMMVisMapToolMeasure::clearMeasurement ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cursor()

QCursor OpenSWMMVisMapToolMeasure::cursor ( ) const
overridevirtual

Returns the mouse cursor to display while this tool is active.

Reimplemented from OpenSWMMVisMapTool.

◆ deactivate()

void OpenSWMMVisMapToolMeasure::deactivate ( )
overridevirtual

Called by the canvas when another tool replaces this one.

Reimplemented from OpenSWMMVisMapTool.

Here is the call graph for this function:

◆ distanceUnit()

MeasurementUnitManager::DistanceUnit OpenSWMMVisMapToolMeasure::distanceUnit ( ) const
Here is the caller graph for this function:

◆ distanceUnitChanged

void OpenSWMMVisMapToolMeasure::distanceUnitChanged ( MeasurementUnitManager::DistanceUnit  unit)
signal
Here is the caller graph for this function:

◆ keyPressEvent()

void OpenSWMMVisMapToolMeasure::keyPressEvent ( QKeyEvent *  event)
overridevirtual

Reimplemented from OpenSWMMVisMapTool.

Here is the call graph for this function:

◆ measurementCleared

void OpenSWMMVisMapToolMeasure::measurementCleared ( )
signal
Here is the caller graph for this function:

◆ mode()

MeasureMode OpenSWMMVisMapToolMeasure::mode ( ) const

◆ modeChanged

void OpenSWMMVisMapToolMeasure::modeChanged ( MeasureMode  mode)
signal
Here is the caller graph for this function:

◆ mouseDoubleClickEvent()

void OpenSWMMVisMapToolMeasure::mouseDoubleClickEvent ( QMouseEvent *  event)
overridevirtual

Reimplemented from OpenSWMMVisMapTool.

Here is the call graph for this function:

◆ mouseMoveEvent()

void OpenSWMMVisMapToolMeasure::mouseMoveEvent ( QMouseEvent *  event)
overridevirtual

Reimplemented from OpenSWMMVisMapTool.

Here is the call graph for this function:

◆ mousePressEvent()

void OpenSWMMVisMapToolMeasure::mousePressEvent ( QMouseEvent *  event)
overridevirtual

Reimplemented from OpenSWMMVisMapTool.

Here is the call graph for this function:

◆ paint()

void OpenSWMMVisMapToolMeasure::paint ( QPainter *  painter,
const MapExtent canvasExtent,
const SpatialReferenceSystem canvasSRS 
)
overridevirtual

Called by the canvas in drawForeground() so the tool can draw transient overlay graphics (rubber-band, measure segments, etc.).

Override this to paint tool overlays directly via QPainter in view coordinates.

Reimplemented from OpenSWMMVisMapTool.

Here is the call graph for this function:

◆ setAreaUnit()

void OpenSWMMVisMapToolMeasure::setAreaUnit ( MeasurementUnitManager::AreaUnit  unit)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setDistanceUnit()

void OpenSWMMVisMapToolMeasure::setDistanceUnit ( MeasurementUnitManager::DistanceUnit  unit)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setMode()

void OpenSWMMVisMapToolMeasure::setMode ( MeasureMode  mode)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ total()

double OpenSWMMVisMapToolMeasure::total ( ) const

Returns the cumulative measured value in the selected unit.

◆ totalChanged

void OpenSWMMVisMapToolMeasure::totalChanged ( double  total)
signal
Here is the caller graph for this function:

Property Documentation

◆ mode

MeasureMode OpenSWMMVisMapToolMeasure::mode
readwrite

◆ total

double OpenSWMMVisMapToolMeasure::total
read

The documentation for this class was generated from the following files: