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" ) );
138 QSize sizePixelsInt = QSize(
static_cast<int>( std::ceil( sizePixels.width() ) ),
139 static_cast<int>( std::ceil( sizePixels.height() ) ) );
149 mEngine->setSize( sizePixelsInt );
153 mEngine->setRootEntity( mScene );
157 if ( mEngine->size() != sizePixelsInt )
158 mEngine->setSize( sizePixelsInt );
162 if (
mLayout->renderContext().isPreviewRender() )
164 onSceneStateChanged();
175 painter->drawImage( r, img );
181 void QgsLayoutItem3DMap::onImageCaptured(
const QImage &img )
183 mCapturedImage = img;
187 void QgsLayoutItem3DMap::onSceneStateChanged()
191 mEngine->requestCaptureImage();
195 void QgsLayoutItem3DMap::onSizePositionChanged()
197 mCapturedImage = QImage();
206 QDomElement elemSettings = mSettings->writeXml( document, context );
207 element.appendChild( elemSettings );
210 QDomElement elemCameraPose = mCameraPose.
writeXml( document );
211 element.appendChild( elemCameraPose );
214 QDomElement elemTemporal = document.createElement( QStringLiteral(
"temporal-settings" ) );
215 elemTemporal.setAttribute( QStringLiteral(
"isTemporal" ),
isTemporal() ? 1 : 0 );
218 elemTemporal.setAttribute( QStringLiteral(
"temporalRangeBegin" ),
temporalRange().begin().toString( Qt::ISODate ) );
219 elemTemporal.setAttribute( QStringLiteral(
"temporalRangeEnd" ),
temporalRange().end().toString( Qt::ISODate ) );
221 element.appendChild( elemTemporal );
229 QDomElement elemSettings = element.firstChildElement( QStringLiteral(
"qgis3d" ) );
230 if ( !elemSettings.isNull() )
233 mSettings->readXml( elemSettings, context );
236 mSettings->resolveReferences( *
mLayout->project() );
238 mSettings->setTransformContext(
mLayout->project()->transformContext() );
239 mSettings->setPathResolver(
mLayout->project()->pathResolver() );
240 mSettings->setMapThemeCollection(
mLayout->project()->mapThemeCollection() );
244 QDomElement elemCameraPose = element.firstChildElement( QStringLiteral(
"camera-pose" ) );
245 if ( !elemCameraPose.isNull() )
246 mCameraPose.
readXml( elemCameraPose );
249 QDomElement elemTemporal = element.firstChildElement( QStringLiteral(
"temporal-settings" ) );
250 setIsTemporal( elemTemporal.attribute( QStringLiteral(
"isTemporal" ) ).toInt() );
253 QDateTime begin = QDateTime::fromString( elemTemporal.attribute( QStringLiteral(
"temporalRangeBegin" ) ), Qt::ISODate );
254 QDateTime end = QDateTime::fromString( elemTemporal.attribute( QStringLiteral(
"temporalRangeBegin" ) ), Qt::ISODate );
268 mSettings.reset( settings );
273 mCapturedImage = QImage();
281 mCapturedImage = QImage();
286 if ( mCameraPose == pose )
290 mCapturedImage = QImage();