Skip to content
Permalink
Browse files
[FEATURE] 3D maps in print layouts (part 2) - PR #7705
  • Loading branch information
wonder-sk committed Aug 25, 2018
2 parents 6097b13 + 02a6b83 commit 504cd618adbef707df5f55e6d397b5dc76e6aaee
Show file tree
Hide file tree
Showing 14 changed files with 894 additions and 16 deletions.
@@ -702,6 +702,7 @@
<file>themes/default/mIconGPU.svg</file>
<file>themes/default/mAddToProject.svg</file>
<file>themes/default/mDockify.svg</file>
<file>themes/default/mActionAdd3DMap.svg</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -54,6 +54,7 @@ SET(QGIS_3D_MOC_HDRS
qgs3dmapsettings.h
qgsabstract3dengine.h
qgscameracontroller.h
qgslayoutitem3dmap.h
qgsoffscreen3dengine.h
qgswindow3dengine.h

@@ -63,6 +63,13 @@ void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteConte
elemOrigin.attribute( "y" ).toDouble(),
elemOrigin.attribute( "z" ).toDouble() );

QDomElement elemColor = elem.firstChildElement( "color" );
if ( !elemColor.isNull() )
{
mBackgroundColor = QgsSymbolLayerUtils::decodeColor( elemColor.attribute( "background" ) );
mSelectionColor = QgsSymbolLayerUtils::decodeColor( elemColor.attribute( "selection" ) );
}

QDomElement elemCrs = elem.firstChildElement( "crs" );
mCrs.readXml( elemCrs );

@@ -147,6 +154,11 @@ QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteCon
elemOrigin.setAttribute( "z", QString::number( mOrigin.z() ) );
elem.appendChild( elemOrigin );

QDomElement elemColor = doc.createElement( "color" );
elemColor.setAttribute( "background", QgsSymbolLayerUtils::encodeColor( mBackgroundColor ) );
elemColor.setAttribute( "selection", QgsSymbolLayerUtils::encodeColor( mSelectionColor ) );
elem.appendChild( elemColor );

QDomElement elemCrs = doc.createElement( "crs" );
mCrs.writeXml( elemCrs, doc );
elem.appendChild( elemCrs );
@@ -419,6 +419,9 @@ void QgsCameraController::setLookingAtPoint( const QgsVector3D &point, float dis

void QgsCameraController::setCameraPose( const QgsCameraPose &camPose )
{
if ( camPose == mCameraPose )
return;

mCameraPose = camPose;

if ( mCamera )
@@ -17,6 +17,31 @@

#include <Qt3DRender/QCamera>

#include <QDomDocument>

QDomElement QgsCameraPose::writeXml( QDomDocument &doc ) const
{
QDomElement elemCamera = doc.createElement( "camera-pose" );
elemCamera.setAttribute( QStringLiteral( "x" ), mCenterPoint.x() );
elemCamera.setAttribute( QStringLiteral( "y" ), mCenterPoint.y() );
elemCamera.setAttribute( QStringLiteral( "z" ), mCenterPoint.z() );
elemCamera.setAttribute( QStringLiteral( "dist" ), mDistanceFromCenterPoint );
elemCamera.setAttribute( QStringLiteral( "pitch" ), mPitchAngle );
elemCamera.setAttribute( QStringLiteral( "heading" ), mHeadingAngle );
return elemCamera;
}

void QgsCameraPose::readXml( const QDomElement &elem )
{
double x = elem.attribute( QStringLiteral( "x" ) ).toDouble();
double y = elem.attribute( QStringLiteral( "y" ) ).toDouble();
double z = elem.attribute( QStringLiteral( "z" ) ).toDouble();
mCenterPoint = QgsVector3D( x, y, z );

mDistanceFromCenterPoint = elem.attribute( QStringLiteral( "dist" ) ).toFloat();
mPitchAngle = elem.attribute( QStringLiteral( "pitch" ) ).toFloat();
mHeadingAngle = elem.attribute( QStringLiteral( "heading" ) ).toFloat();
}

void QgsCameraPose::updateCamera( Qt3DRender::QCamera *camera )
{
@@ -25,6 +25,9 @@ namespace Qt3DRender
class QCamera;
}

class QDomDocument;
class QDomElement;

/**
* \ingroup 3d
* Class that encapsulates camera pose in a 3D scene. The pose is defined with the following parameters:
@@ -62,6 +65,11 @@ class _3D_EXPORT QgsCameraPose
//! Update Qt3D camera view matrix based on the pose
void updateCamera( Qt3DRender::QCamera *camera );

//! Writes configuration to a new DOM element and returns it
QDomElement writeXml( QDomDocument &doc ) const;
//! Reads configuration from a DOM element previously written using writeXml()
void readXml( const QDomElement &elem );

bool operator==( const QgsCameraPose &other ) const
{
return mCenterPoint == other.mCenterPoint &&

0 comments on commit 504cd61

Please sign in to comment.