60 QList<QgsLayoutItem3DMap *> mapsList;
61 mLayout->layoutItems( mapsList );
70 if ( map->mMapId == mMapId )
73 maxId = std::max( maxId, map->mMapId );
78 mLayout->itemsModel()->updateItemDisplayName(
this );
90 return tr(
"3D Map %1" ).arg( mMapId );
93 void QgsLayoutItem3DMap::updateToolTip()
101 QPainter *painter = ctx.
painter();
103 int w =
static_cast<int>( std::ceil( rect().width() * ctx.
scaleFactor() ) );
104 int h =
static_cast<int>( std::ceil( rect().height() * ctx.
scaleFactor() ) );
105 QRect r( 0, 0, w, h );
111 painter->drawText( r, Qt::AlignCenter, tr(
"Scene not set" ) );
119 mCapturedImage = QImage();
122 if ( !mCapturedImage.isNull() )
124 painter->drawImage( r, mCapturedImage );
131 if (
mLayout->renderContext().isPreviewRender() )
133 painter->drawText( r, Qt::AlignCenter, tr(
"Loading" ) );
151 QSize sizePixelsInt = QSize(
static_cast<int>( std::ceil( sizePixels.width() ) ),
152 static_cast<int>( std::ceil( sizePixels.height() ) ) );
162 mEngine->setSize( sizePixelsInt );
166 mEngine->setRootEntity( mScene );
170 if ( mEngine->size() != sizePixelsInt )
171 mEngine->setSize( sizePixelsInt );
175 if (
mLayout->renderContext().isPreviewRender() )
177 onSceneStateChanged();
191 painter->drawImage( r, img );
200 void QgsLayoutItem3DMap::onImageCaptured(
const QImage &img )
202 mCapturedImage = img;
206 void QgsLayoutItem3DMap::onSceneStateChanged()
210 mEngine->requestCaptureImage();
214 void QgsLayoutItem3DMap::onSizePositionChanged()
216 mCapturedImage = QImage();
225 QDomElement elemSettings = mSettings->writeXml( document, context );
226 element.appendChild( elemSettings );
229 QDomElement elemCameraPose = mCameraPose.
writeXml( document );
230 element.appendChild( elemCameraPose );
233 QDomElement elemTemporal = document.createElement( QStringLiteral(
"temporal-settings" ) );
234 elemTemporal.setAttribute( QStringLiteral(
"isTemporal" ),
isTemporal() ? 1 : 0 );
237 elemTemporal.setAttribute( QStringLiteral(
"temporalRangeBegin" ),
temporalRange().begin().toString( Qt::ISODate ) );
238 elemTemporal.setAttribute( QStringLiteral(
"temporalRangeEnd" ),
temporalRange().end().toString( Qt::ISODate ) );
240 element.appendChild( elemTemporal );
248 QDomElement elemSettings = element.firstChildElement( QStringLiteral(
"qgis3d" ) );
249 if ( !elemSettings.isNull() )
252 mSettings->readXml( elemSettings, context );
255 mSettings->resolveReferences( *
mLayout->project() );
257 mSettings->setTransformContext(
mLayout->project()->transformContext() );
258 mSettings->setPathResolver(
mLayout->project()->pathResolver() );
259 mSettings->setMapThemeCollection(
mLayout->project()->mapThemeCollection() );
263 QDomElement elemCameraPose = element.firstChildElement( QStringLiteral(
"camera-pose" ) );
264 if ( !elemCameraPose.isNull() )
265 mCameraPose.
readXml( elemCameraPose );
268 QDomElement elemTemporal = element.firstChildElement( QStringLiteral(
"temporal-settings" ) );
269 setIsTemporal( elemTemporal.attribute( QStringLiteral(
"isTemporal" ) ).toInt() );
272 QDateTime begin = QDateTime::fromString( elemTemporal.attribute( QStringLiteral(
"temporalRangeBegin" ) ), Qt::ISODate );
273 QDateTime end = QDateTime::fromString( elemTemporal.attribute( QStringLiteral(
"temporalRangeBegin" ) ), Qt::ISODate );
287 mSettings.reset( settings );
292 mCapturedImage = QImage();
300 mCapturedImage = QImage();
305 if ( mCameraPose == pose )
309 mCapturedImage = QImage();