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
SnapEngine Class Reference

Stateless helper that finds the nearest snap point for a given cursor position, respecting the application's snapping preferences. More...

#include <snapengine.h>

Collaboration diagram for SnapEngine:

Classes

struct  Result
 

Public Types

enum class  Kind {
  None ,
  Node ,
  Gage ,
  LinkVertex ,
  SubcatchVertex
}
 

Static Public Member Functions

static Result snap (const OpenSWMMVisMapTool *tool, SWMMModelLayer *layer, double mapX, double mapY)
 Find the nearest snap point within the configured tolerance.
 
static void paintSnapRing (QPainter *painter, const OpenSWMMVisMapTool *tool, const Result &result, const QColor &color=QColor(255, 165, 0))
 Paint a snap indicator ring on the overlay channel.
 

Detailed Description

Stateless helper that finds the nearest snap point for a given cursor position, respecting the application's snapping preferences.

Call snap() on every mouseMoveEvent and store the result. Use the stored result in mousePressEvent to commit the snapped coordinate, and in paint() to draw the orange snap indicator ring.

Snap candidates (in priority order):

  1. Node positions — fastest (KD-tree via identifyAt).
  2. Rain-gage positions.
  3. Link polyline vertices (interior + endpoints) — enabled by snapToVertices().
  4. Subcatchment polygon vertices — enabled by snapToVertices().

Member Enumeration Documentation

◆ Kind

enum class SnapEngine::Kind
strong
Enumerator
None 
Node 
Gage 
LinkVertex 
SubcatchVertex 

Member Function Documentation

◆ paintSnapRing()

void SnapEngine::paintSnapRing ( QPainter *  painter,
const OpenSWMMVisMapTool tool,
const Result result,
const QColor &  color = QColor(255, 165, 0) 
)
static

Paint a snap indicator ring on the overlay channel.

Does nothing when result.snapped is false.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ snap()

SnapEngine::Result SnapEngine::snap ( const OpenSWMMVisMapTool tool,
SWMMModelLayer layer,
double  mapX,
double  mapY 
)
static

Find the nearest snap point within the configured tolerance.

Parameters
toolThe calling tool — used only for pixel→map conversion.
layerThe active SWMM model layer to query.
mapXCursor X in map (layer-CRS) coordinates.
mapYCursor Y in map (layer-CRS) coordinates.
Returns
A populated Result if a candidate is found within tolerance, or Result{false, mapX, mapY} otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

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