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

Left-click on the canvas to place a new SWMM node. More...

#include <maptooladdnode.h>

Inheritance diagram for OpenSWMMVisMapToolAddNode:
Collaboration diagram for OpenSWMMVisMapToolAddNode:

Signals

void nodeAdded (const QString &name, int nodeType, double x, double y)
 
void nodeInsertedOnConduit (const QString &nodeName, const QString &splitLinkName, const QString &newLinkName)
 
void statusMessageChanged (const QString &message)
 
- 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

 OpenSWMMVisMapToolAddNode (MapCanvas *canvas, int nodeType, const QString &elementKind, QObject *parent=nullptr)
 
QCursor cursor () const override
 Returns the mouse cursor to display while this tool is active.
 
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 mouseReleaseEvent (QMouseEvent *event) override
 
void mouseMoveEvent (QMouseEvent *event) override
 
void paint (QPainter *painter, const MapExtent &extent, const SpatialReferenceSystem *srs) override
 Called by the canvas in drawForeground() so the tool can draw transient overlay graphics (rubber-band, measure segments, etc.).
 
void setTerrain (GISRasterLayer *layer, double offset, double factor=1.0)
 Sets the active terrain layer and node offset used to auto-fill InvertElev when a node is placed freely (a node inserted on a conduit takes the engine's interpolated invert instead).
 
bool kindCanSplitConduit () const
 Whether this tool's node kind may be inserted mid-conduit — every kind but OUTFALL.
 
int nodeType () const
 
- 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 mouseDoubleClickEvent (QMouseEvent *event)
 
virtual void wheelEvent (QWheelEvent *event)
 
virtual void keyPressEvent (QKeyEvent *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.
 

Additional Inherited Members

- Protected Attributes inherited from OpenSWMMVisMapTool
QString m_toolName
 
MapCanvasm_canvas = nullptr
 
- Properties inherited from OpenSWMMVisMapTool
QString toolName
 
QCursor cursor
 
bool active
 

Detailed Description

Left-click on the canvas to place a new SWMM node.

The tool is configured with a fixed node type at construction (Junction / Outfall / Storage / Divider). A numeric suffix on a default name prefix is auto-assigned to keep the engine's uniqueness invariant ("J1", "J2", …) unless the project window provides a custom prefix.

Where the click lands decides what happens (ADDNODE_SPLIT_REDESIGN_PLAN_2026-09-10.md):

  • empty canvas (or snapped to an existing node) → the node is placed there (AddNodeCommand, terrain-derived invert).
  • a conduit → the conduit is split at that point and the node inserted there (InsertNodeSplitCommand; storage and dividers are converted from the split junction and get their creation defaults). Outfalls are refused on a conduit — an outfall must be terminal — with a status-bar hint and no edit. Pumps, weirs, orifices and outlets have no length to divide and never count as a conduit hit. The click is armed on press and committed on RELEASE (the convention for canvas tools that may open a dialog — see maptoolpick2dcells.h).

Every placement pushes one command onto the canvas' MapUndoStack. Engine state must be OPENED or BUILDING — the tool logs and ignores clicks otherwise.

Constructor & Destructor Documentation

◆ OpenSWMMVisMapToolAddNode()

OpenSWMMVisMapToolAddNode::OpenSWMMVisMapToolAddNode ( MapCanvas canvas,
int  nodeType,
const QString &  elementKind,
QObject *  parent = nullptr 
)
Parameters
canvasTarget map canvas.
nodeTypeSWMM_NodeType value (0=Junction / 1=Outfall / 2=Storage / 3=Divider).
elementKindNaming-preference key: "junction", "outfall", "storage", or "divider". Used to look up the configurable prefix from PreferencesManager.

Member Function Documentation

◆ activate()

void OpenSWMMVisMapToolAddNode::activate ( )
overridevirtual

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

Reimplemented from OpenSWMMVisMapTool.

Here is the call graph for this function:

◆ cursor()

QCursor OpenSWMMVisMapToolAddNode::cursor ( ) const
overridevirtual

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

Reimplemented from OpenSWMMVisMapTool.

◆ deactivate()

void OpenSWMMVisMapToolAddNode::deactivate ( )
overridevirtual

Called by the canvas when another tool replaces this one.

Reimplemented from OpenSWMMVisMapTool.

Here is the call graph for this function:

◆ kindCanSplitConduit()

bool OpenSWMMVisMapToolAddNode::kindCanSplitConduit ( ) const

Whether this tool's node kind may be inserted mid-conduit — every kind but OUTFALL.

Here is the caller graph for this function:

◆ mouseMoveEvent()

void OpenSWMMVisMapToolAddNode::mouseMoveEvent ( QMouseEvent *  event)
overridevirtual

Reimplemented from OpenSWMMVisMapTool.

Here is the call graph for this function:

◆ mousePressEvent()

void OpenSWMMVisMapToolAddNode::mousePressEvent ( QMouseEvent *  event)
overridevirtual

Reimplemented from OpenSWMMVisMapTool.

◆ mouseReleaseEvent()

void OpenSWMMVisMapToolAddNode::mouseReleaseEvent ( QMouseEvent *  event)
overridevirtual

Reimplemented from OpenSWMMVisMapTool.

Here is the call graph for this function:

◆ nodeAdded

void OpenSWMMVisMapToolAddNode::nodeAdded ( const QString &  name,
int  nodeType,
double  x,
double  y 
)
signal

◆ nodeInsertedOnConduit

void OpenSWMMVisMapToolAddNode::nodeInsertedOnConduit ( const QString &  nodeName,
const QString &  splitLinkName,
const QString &  newLinkName 
)
signal

Emitted when a placement split a conduit (in addition to nodeAdded).

◆ nodeType()

int OpenSWMMVisMapToolAddNode::nodeType ( ) const
inline

◆ paint()

void OpenSWMMVisMapToolAddNode::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:

◆ setTerrain()

void OpenSWMMVisMapToolAddNode::setTerrain ( GISRasterLayer layer,
double  offset,
double  factor = 1.0 
)

Sets the active terrain layer and node offset used to auto-fill InvertElev when a node is placed freely (a node inserted on a conduit takes the engine's interpolated invert instead).

Parameters
layerRaster layer to sample; nullptr disables terrain assistance.
offsetSigned value added to terrain Z (negative = below ground).
factorConversion factor from raster vertical units to model vertical units (e.g., 3.28084 when raster is metres and model is feet). Defaults to 1.0 (no conversion).
Here is the caller graph for this function:

◆ statusMessageChanged

void OpenSWMMVisMapToolAddNode::statusMessageChanged ( const QString &  message)
signal
Here is the caller graph for this function:

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