27 QgsTerrainTextureGenerator::QgsTerrainTextureGenerator(
const Qgs3DMapSettings &map )
33 int QgsTerrainTextureGenerator::render(
const QgsRectangle &
extent,
const QString &debugText )
36 mapSettings.setExtent( extent );
43 jobData.jobId = ++mLastJobId;
46 jobData.debugText = debugText;
48 mJobs.insert( job, jobData );
53 void QgsTerrainTextureGenerator::cancelJob(
int jobId )
55 Q_FOREACH (
const JobData &jd, mJobs )
57 if ( jd.jobId == jobId )
60 jd.job->cancelWithoutBlocking();
62 jd.job->deleteLater();
63 mJobs.remove( jd.job );
67 Q_ASSERT(
false &&
"requested job ID does not exist!" );
70 QImage QgsTerrainTextureGenerator::renderSynchronously(
const QgsRectangle &extent,
const QString &debugText )
73 mapSettings.setExtent( extent );
75 QImage img = QImage( mapSettings.outputSize(), mapSettings.outputImageFormat() );
76 img.setDotsPerMeterX( 1000 * mapSettings.outputDpi() / 25.4 );
77 img.setDotsPerMeterY( 1000 * mapSettings.outputDpi() / 25.4 );
78 img.fill( Qt::transparent );
83 job.renderSynchronously();
85 if ( mMap.showTerrainTilesInfo() )
88 p.setPen( Qt::white );
89 p.drawRect( 0, 0, img.width() - 1, img.height() - 1 );
90 p.drawText( img.rect(), debugText, QTextOption( Qt::AlignCenter ) );
99 void QgsTerrainTextureGenerator::onRenderingFinished()
103 Q_ASSERT( mJobs.contains( mapJob ) );
104 JobData jobData = mJobs.value( mapJob );
108 if ( mMap.showTerrainTilesInfo() )
112 p.setPen( Qt::white );
113 p.drawRect( 0, 0, img.width() - 1, img.height() - 1 );
114 p.drawText( img.rect(), jobData.debugText, QTextOption( Qt::AlignCenter ) );
118 mapJob->deleteLater();
119 mJobs.remove( mapJob );
124 emit tileReady( jobData.jobId, img );
131 mapSettings.
setOutputSize( QSize( mMap.mapTileResolution(), mMap.mapTileResolution() ) );
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.
void setTransformContext(const QgsCoordinateTransformContext &context)
Sets the coordinate transform context, which stores various information regarding which datum transfo...
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.
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...
void setLayers(const QList< QgsMapLayer * > &layers)
Set list of layers for map rendering.