28 QgsTerrainTextureGenerator::QgsTerrainTextureGenerator(
const Qgs3DMapSettings &map )
34 int QgsTerrainTextureGenerator::render(
const QgsRectangle &
extent,
const QString &debugText )
37 mapSettings.setExtent( extent );
44 jobData.jobId = ++mLastJobId;
47 jobData.debugText = debugText;
49 mJobs.insert( job, jobData );
54 void QgsTerrainTextureGenerator::cancelJob(
int jobId )
56 Q_FOREACH (
const JobData &jd, mJobs )
58 if ( jd.jobId == jobId )
61 jd.job->cancelWithoutBlocking();
63 jd.job->deleteLater();
64 mJobs.remove( jd.job );
68 Q_ASSERT(
false &&
"requested job ID does not exist!" );
71 QImage QgsTerrainTextureGenerator::renderSynchronously(
const QgsRectangle &extent,
const QString &debugText )
74 mapSettings.setExtent( extent );
76 QImage img = QImage( mapSettings.outputSize(), mapSettings.outputImageFormat() );
77 img.setDotsPerMeterX( 1000 * mapSettings.outputDpi() / 25.4 );
78 img.setDotsPerMeterY( 1000 * mapSettings.outputDpi() / 25.4 );
79 img.fill( Qt::transparent );
84 job.renderSynchronously();
86 if ( mMap.showTerrainTilesInfo() )
89 p.setPen( Qt::white );
90 p.drawRect( 0, 0, img.width() - 1, img.height() - 1 );
91 p.drawText( img.rect(), debugText, QTextOption( Qt::AlignCenter ) );
100 void QgsTerrainTextureGenerator::onRenderingFinished()
104 Q_ASSERT( mJobs.contains( mapJob ) );
105 JobData jobData = mJobs.value( mapJob );
109 if ( mMap.showTerrainTilesInfo() )
113 p.setPen( Qt::white );
114 p.drawRect( 0, 0, img.width() - 1, img.height() - 1 );
115 p.drawText( img.rect(), jobData.debugText, QTextOption( Qt::AlignCenter ) );
119 mapJob->deleteLater();
120 mJobs.remove( mapJob );
125 emit tileReady( jobData.jobId, img );
132 mapSettings.
setOutputSize( QSize( mMap.mapTileResolution(), mMap.mapTileResolution() ) );
140 QString mapThemeName = mMap.terrainMapTheme();
141 if ( mapThemeName.isEmpty() || !mapThemes || !mapThemes->
hasMapTheme( mapThemeName ) )
void finished()
emitted when asynchronous rendering is finished (or canceled).
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
sets destination coordinate reference system
A rectangle specified with double values.
Job implementation that renders everything sequentially using a custom painter.
void start() override
Start the rendering job and immediately return.
bool hasMapTheme(const QString &name) const
Returns whether a map theme with a matching name exists.
void setTransformContext(const QgsCoordinateTransformContext &context)
Sets the coordinate transform context, which stores various information regarding which datum transfo...
QList< QgsMapLayer * > mapThemeVisibleLayers(const QString &name) const
Returns the list of layers that are visible for the specified map theme.
QMap< QString, QString > mapThemeStyleOverrides(const QString &name)
Gets layer style overrides (for QgsMapSettings) of the visible layers for given map theme...
void setLayerStyleOverrides(const QMap< QString, QString > &overrides)
Set map of map layer style overrides (key: layer ID, value: style name) where a different style shoul...
3 Definition of the world
Enable drawing of labels on top of the map.
void setFlag(Flag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
The QgsMapSettings class contains configuration for rendering of the map.
void setOutputSize(QSize size)
Sets the size of the resulting map image.
Job implementation that renders everything sequentially in one thread.
void setBackgroundColor(const QColor &color)
Sets the background color of the map.
QImage renderedImage() override
Gets a preview/resulting image.
void setLayers(const QList< QgsMapLayer *> &layers)
Set list of layers for map rendering.
virtual QgsRectangle extent() const =0
extent of the terrain in terrain's CRS
void setPathResolver(const QgsPathResolver &resolver)
Sets the path resolver for conversion between relative and absolute paths during rendering operations...
Container class that allows storage of map themes consisting of visible map layers and layer styles...