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.h
Go to the documentation of this file.
1
8#ifndef MAPRENDERJOB_H
9#define MAPRENDERJOB_H
10
11#include "map/mapextent.h"
12
13#include <QImage>
14#include <QList>
15#include <QObject>
16#include <QSize>
17
18#include <atomic>
19#include <memory>
20
23
42class MapRenderJob : public QObject
43{
44 Q_OBJECT
45
46public:
47
57 MapRenderJob(const QList<OpenSWMMVisLayer *> &layers,
58 const MapExtent &extent,
59 const QSize &imageSize,
60 qreal devicePixelRatio,
62 const QColor &bgColor,
63 QObject *parent = nullptr);
64
72 ~MapRenderJob() override = default;
73
79 void start();
80
84 void cancel();
85
89 [[nodiscard]] bool isCancelled() const { return m_cancelled->load(); }
90
91signals:
92
97 void finished(QImage result);
98
99private:
100 void run();
101
102 QList<OpenSWMMVisLayer *> m_layers;
103 MapExtent m_extent;
104 QSize m_imageSize;
105 qreal m_dpr { 1.0 };
107 QColor m_bgColor;
108 bool m_started { false };
109 // Shared with the worker lambda. Survives the job's destruction so the
110 // worker can keep checking it after `delete m_renderJob` from the GUI.
111 std::shared_ptr<std::atomic<bool>> m_cancelled
112 { std::make_shared<std::atomic<bool>>(false) };
113};
114
115#endif // MAPRENDERJOB_H
An axis-aligned bounding box in the coordinate space of a given CRS.
Definition mapextent.h:26
Renders raster layers into an off-screen QImage on a worker thread.
Definition maprenderjob.h:43
void start()
Queues the render on a QtConcurrent thread.
Definition maprenderjob.cpp:43
void cancel()
Signals the worker to skip remaining layers.
Definition maprenderjob.cpp:142
~MapRenderJob() override=default
Destructor — non-blocking.
bool isCancelled() const
Returns true after cancel() has been called.
Definition maprenderjob.h:89
void finished(QImage result)
Emitted on the GUI thread when rendering is complete (or cancelled).
Abstract base class for all layers displayed in the MapCanvas.
Definition openswmmvislayer.h:116
Represents a coordinate reference system backed by a GDAL OGRSpatialReference.
Definition spatialreferencesystem.h:28
Axis-aligned bounding box in a map coordinate system, used by MapCanvas and all layer types to define...
QVector< int > parent
union-find
Definition pslgminsize.cpp:176