58 QList<QgsLayoutItem3DMap *> mapsList;
59 mLayout->layoutItems( mapsList );
68 if ( map->mMapId == mMapId )
71 maxId = std::max( maxId, map->mMapId );
76 mLayout->itemsModel()->updateItemDisplayName(
this );
88 return tr(
"3D Map %1" ).arg( mMapId );
91 void QgsLayoutItem3DMap::updateToolTip()
99 QPainter *painter = ctx.
painter();
101 int w =
static_cast<int>( std::ceil( rect().width() * ctx.
scaleFactor() ) );
102 int h =
static_cast<int>( std::ceil( rect().height() * ctx.
scaleFactor() ) );
103 QRect r( 0, 0, w, h );
109 painter->drawText( r, Qt::AlignCenter, tr(
"Scene not set" ) );
117 mCapturedImage = QImage();
120 if ( !mCapturedImage.isNull() )
122 painter->drawImage( r, mCapturedImage );
129 if (
mLayout->renderContext().isPreviewRender() )
131 painter->drawText( r, Qt::AlignCenter, tr(
"Loading" ) );
136 QSize sizePixelsInt = QSize(
static_cast<int>( std::ceil( sizePixels.width() ) ),
137 static_cast<int>( std::ceil( sizePixels.height() ) ) );
147 mEngine->setSize( sizePixelsInt );
151 mEngine->setRootEntity( mScene );
154 if ( mEngine->size() != sizePixelsInt )
155 mEngine->setSize( sizePixelsInt );
159 if (
mLayout->renderContext().isPreviewRender() )
161 onSceneStateChanged();
172 painter->drawImage( r, img );
178 void QgsLayoutItem3DMap::onImageCaptured(
const QImage &img )
180 mCapturedImage = img;
184 void QgsLayoutItem3DMap::onSceneStateChanged()
188 mEngine->requestCaptureImage();
192 void QgsLayoutItem3DMap::onSizePositionChanged()
194 mCapturedImage = QImage();
203 QDomElement elemSettings = mSettings->writeXml( document, context );
204 element.appendChild( elemSettings );
207 QDomElement elemCameraPose = mCameraPose.
writeXml( document );
208 element.appendChild( elemCameraPose );
211 QDomElement elemTemporal = document.createElement( QStringLiteral(
"temporal-settings" ) );
212 elemTemporal.setAttribute( QStringLiteral(
"isTemporal" ),
isTemporal() ? 1 : 0 );
215 elemTemporal.setAttribute( QStringLiteral(
"temporalRangeBegin" ),
temporalRange().begin().toString( Qt::ISODate ) );
216 elemTemporal.setAttribute( QStringLiteral(
"temporalRangeEnd" ),
temporalRange().end().toString( Qt::ISODate ) );
218 element.appendChild( elemTemporal );
226 QDomElement elemSettings = element.firstChildElement( QStringLiteral(
"qgis3d" ) );
227 if ( !elemSettings.isNull() )
230 mSettings->readXml( elemSettings, context );
233 mSettings->resolveReferences( *
mLayout->project() );
235 mSettings->setTransformContext(
mLayout->project()->transformContext() );
236 mSettings->setPathResolver(
mLayout->project()->pathResolver() );
237 mSettings->setMapThemeCollection(
mLayout->project()->mapThemeCollection() );
241 QDomElement elemCameraPose = element.firstChildElement( QStringLiteral(
"camera-pose" ) );
242 if ( !elemCameraPose.isNull() )
243 mCameraPose.
readXml( elemCameraPose );
246 QDomElement elemTemporal = element.firstChildElement( QStringLiteral(
"temporal-settings" ) );
247 setIsTemporal( elemTemporal.attribute( QStringLiteral(
"isTemporal" ) ).toInt() );
250 QDateTime begin = QDateTime::fromString( elemTemporal.attribute( QStringLiteral(
"temporalRangeBegin" ) ), Qt::ISODate );
251 QDateTime end = QDateTime::fromString( elemTemporal.attribute( QStringLiteral(
"temporalRangeBegin" ) ), Qt::ISODate );
265 mSettings.reset( settings );
270 mCapturedImage = QImage();
278 mCapturedImage = QImage();
283 if ( mCameraPose == pose )
287 mCapturedImage = QImage();