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
@@ -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>
@@ -0,0 +1,163 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="24"
width="24"
version="1.1"
id="svg23"
sodipodi:docname="mActionAdd3DMap.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)">
<metadata
id="metadata29">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs27">
<linearGradient
inkscape:collect="always"
id="linearGradient918">
<stop
style="stop-color:#bfbfbf;stop-opacity:1"
offset="0"
id="stop914" />
<stop
style="stop-color:#e1e1e1;stop-opacity:1"
offset="1"
id="stop916" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient918"
id="linearGradient920"
x1="3.1228814"
y1="12.46981"
x2="8.275053"
y2="14.920922"
gradientUnits="userSpaceOnUse" />
</defs>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1871"
inkscape:window-height="1025"
id="namedview25"
showgrid="false"
inkscape:zoom="2"
inkscape:cx="141.16464"
inkscape:cy="18.121147"
inkscape:window-x="49"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg23" />
<linearGradient
id="a"
gradientUnits="userSpaceOnUse"
x1="3.5"
x2="11.5"
y1="19.5"
y2="19.5"
gradientTransform="translate(41.288136,10.305085)">
<stop
offset="0"
stop-color="#b7b7b7"
id="stop2" />
<stop
offset="1"
stop-color="#e6e6e6"
id="stop4" />
</linearGradient>
<path
style="fill:url(#linearGradient920);fill-opacity:1;stroke:none;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 21.221115,4.8048602 -0.983202,0.43846 -3.16343,-0.4307914 -2.54778,0.1286093 L 9.8801462,4.3893472 6.454113,6.5957888 5.0087476,6.5827232 3.8477042,11.243014 l -2.87303007,4.437033 3.14407087,0.06429 9.540628,2.572195 7.850231,-0.563536 z"
id="path847-3"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccccccccc" />
<g
id="g952"
style="stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke:#aaaaaa;stroke-opacity:1">
<path
sodipodi:nodetypes="ccccc"
inkscape:connector-curvature="0"
id="path849-6"
d="M 13.053454,4.7153071 9.3797338,8.3492956 6.7214087,11.611531 5.7301688,13.429378 4.1818687,15.744345"
style="fill:none;stroke:#aaaaaa;stroke-width:0.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
sodipodi:nodetypes="cccc"
inkscape:connector-curvature="0"
id="path851-7"
d="m 17.256619,5.0413044 -4.393208,5.1728316 -1.864108,2.721474 -0.951918,4.105895"
style="fill:none;stroke:#aaaaaa;stroke-width:0.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
sodipodi:nodetypes="cccccc"
inkscape:connector-curvature="0"
id="path853-5"
d="m 20.237913,5.2433202 -0.481796,3.4228902 -2.192507,3.0912416 -2.155672,1.623494 -0.758428,2.046017 -0.735466,2.889576"
style="fill:none;stroke:#aaaaaa;stroke-width:0.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
sodipodi:nodetypes="ccccc"
inkscape:connector-curvature="0"
id="path855-3"
d="m 4.0595127,11.593921 2.661896,0.01761 4.2778943,1.324079 c 2.194869,-0.350329 4.377703,-0.778818 6.564307,-1.178158 l 3.629577,3.248202"
style="fill:none;stroke:#aaaaaa;stroke-width:0.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
sodipodi:nodetypes="ccccc"
inkscape:connector-curvature="0"
id="path857-5"
d="m 6.2173238,6.8859807 4.0432972,0.6004049 2.682193,2.5228974 6.813303,-1.3430726 1.793563,1.9437616"
style="fill:none;stroke:#aaaaaa;stroke-width:0.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
<path
style="fill:none;fill-opacity:1;stroke:#9a9a9a;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 21.221115,4.8048602 19.806458,5.1354565 17.074483,4.8125289 14.526703,4.9411382 9.8801462,4.3893472 6.454113,6.5957888 5.0087476,6.5827232 3.8477042,11.243014 l -2.87303007,4.437033 3.14407087,0.06429 9.540628,2.572195 7.850231,-0.563536 z"
id="path847-3-9"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccccccccc" />
<g
id="g19"
transform="matrix(0.69230769,0,0,0.69230769,1.8461539,1.8461539)">
<rect
style="fill:#5a8c5a"
id="rect11"
y="19"
x="19"
width="13"
ry="2.6149368"
rx="2.6149371"
height="13" />
<path
inkscape:connector-curvature="0"
id="path13"
style="overflow:visible;fill:#ffffff;fill-rule:evenodd;stroke:#ffffff;stroke-width:2.5999999;stroke-linecap:round;stroke-linejoin:round"
d="m 21.6,25.499999 h 7.8" />
<path
inkscape:connector-curvature="0"
id="path15"
style="overflow:visible;fill:#ffffff;fill-rule:evenodd;stroke:#ffffff;stroke-width:2.5999999;stroke-linecap:round;stroke-linejoin:round"
d="M 25.5,29.399999 V 21.6" />
<path
style="opacity:0.3;fill:#fcffff;fill-rule:evenodd"
inkscape:connector-curvature="0"
id="path17"
d="m 20.3,25.499999 h 10.4 c 0,0 0,0 0,-2.6 C 30.7,20.3 30.05,20.3 25.5,20.3 c -4.55,0 -5.2,0 -5.2,2.599999 0,2.6 0,2.6 0,2.6 z" />
</g>
</svg>
@@ -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.
You can’t perform that action at this time.