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

Renders raster layers into an off-screen QImage on a worker thread. More...

#include <maprenderjob.h>

Inheritance diagram for MapRenderJob:
Collaboration diagram for MapRenderJob:

Signals

void finished (QImage result)
 Emitted on the GUI thread when rendering is complete (or cancelled).
 

Public Member Functions

 MapRenderJob (const QList< OpenSWMMVisLayer * > &layers, const MapExtent &extent, const QSize &imageSize, qreal devicePixelRatio, SpatialReferenceSystem *srs, const QColor &bgColor, QObject *parent=nullptr)
 Constructs a render job.
 
 ~MapRenderJob () override=default
 Destructor — non-blocking.
 
void start ()
 Queues the render on a QtConcurrent thread.
 
void cancel ()
 Signals the worker to skip remaining layers.
 
bool isCancelled () const
 Returns true after cancel() has been called.
 

Detailed Description

Renders raster layers into an off-screen QImage on a worker thread.

This class implements the QGIS-style "map render job" pattern:

  1. The MapCanvas creates a MapRenderJob with the current extent, viewport size, CRS, and the list of visible raster layers.
  2. start() dispatches the render to a QtConcurrent worker thread.
  3. Each raster layer's render() method is called with a QPainter backed by the target QImage.
  4. When all layers have painted, finished(QImage) is emitted on the GUI thread.

Cancellation: Call cancel() to skip remaining layers; the partially-rendered image is still delivered via finished() so the canvas always has a buffer.

Note
Layer render() implementations must be safe for concurrent read access.

Constructor & Destructor Documentation

◆ MapRenderJob()

MapRenderJob::MapRenderJob ( const QList< OpenSWMMVisLayer * > &  layers,
const MapExtent extent,
const QSize &  imageSize,
qreal  devicePixelRatio,
SpatialReferenceSystem srs,
const QColor &  bgColor,
QObject *  parent = nullptr 
)

Constructs a render job.

Parameters
layersShallow copy of the raster-layer stack (bottom-to-top order).
extentGeographic extent in canvas-CRS coordinates.
imageSizePixel dimensions of the output image.
srsCanvas CRS (not owned; must outlive the job).
bgColorBackground fill colour for the buffer.
parentQt parent.

◆ ~MapRenderJob()

MapRenderJob::~MapRenderJob ( )
overridedefault

Destructor — non-blocking.

Worker thread is independent of the job's lifetime: it owns its own copies of all rendering state (snapshot taken in start()) and a shared cancel flag. The job can be deleted any time without freezing the GUI thread or risking use-after-free in the worker.

Member Function Documentation

◆ cancel()

void MapRenderJob::cancel ( )

Signals the worker to skip remaining layers.

◆ finished

void MapRenderJob::finished ( QImage  result)
signal

Emitted on the GUI thread when rendering is complete (or cancelled).

Parameters
resultThe composited raster image, sized to imageSize.

◆ isCancelled()

bool MapRenderJob::isCancelled ( ) const
inline

Returns true after cancel() has been called.

◆ start()

void MapRenderJob::start ( )

Queues the render on a QtConcurrent thread.

finished() is emitted when done. Calling start() a second time before finished() fires has no effect.


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