Skip to content
Permalink
Browse files

Initial support for 3D map item in print layouts GUI

The GUI logic is not working yet, just getting the new files ready.

Many thanks to @nirvn for the icon!
  • Loading branch information
wonder-sk committed Aug 21, 2018
1 parent eb220ed commit d4a3f68eb1c5d3936d9accadc60a96d2c6c6b4a2
@@ -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

@@ -26,9 +26,11 @@
QgsLayoutItem3DMap::QgsLayoutItem3DMap( QgsLayout *layout )
: QgsLayoutItem( layout )
{

}

QgsLayoutItem3DMap::~QgsLayoutItem3DMap() = default;


QgsLayoutItem3DMap *QgsLayoutItem3DMap::create( QgsLayout *layout )
{
return new QgsLayoutItem3DMap( layout );
@@ -41,6 +43,9 @@ int QgsLayoutItem3DMap::type() const

void QgsLayoutItem3DMap::draw( QgsLayoutItemRenderContext &context )
{
if ( !mSettings )
return;

QgsOffscreen3DEngine engine;
QSizeF sizePixels = mLayout->renderContext().measurementConverter().convert( sizeWithUnits(), QgsUnitTypes::LayoutPixels ).toQSizeF();
engine.setSize( QSize( static_cast<int>( std::ceil( sizePixels.width() ) ),
@@ -34,6 +34,7 @@ class Qgs3DMapSettings;
*/
class _3D_EXPORT QgsLayoutItem3DMap : public QgsLayoutItem
{
Q_OBJECT

#ifdef SIP_RUN
SIP_CONVERT_TO_SUBCLASS_CODE
@@ -61,6 +62,8 @@ class _3D_EXPORT QgsLayoutItem3DMap : public QgsLayoutItem
*/
QgsLayoutItem3DMap( QgsLayout *layout SIP_TRANSFERTHIS );

~QgsLayoutItem3DMap();

/**
* Returns a new 3D map item for the specified \a layout.
*
@@ -446,6 +446,7 @@ IF (WITH_3D)
3d/qgspolygon3dsymbolwidget.cpp
3d/qgsphongmaterialwidget.cpp
3d/qgsvectorlayer3drendererwidget.cpp
layout/qgslayout3dmapwidget.cpp
)

SET (QGIS_APP_MOC_HDRS
@@ -459,6 +460,7 @@ IF (WITH_3D)
3d/qgspolygon3dsymbolwidget.h
3d/qgsphongmaterialwidget.h
3d/qgsvectorlayer3drendererwidget.h
layout/qgslayout3dmapwidget.h
)
ENDIF (WITH_3D)

@@ -0,0 +1,24 @@
/***************************************************************************
qgslayout3dmapwidget.cpp
--------------------------------------
Date : August 2018
Copyright : (C) 2018 by Martin Dobias
Email : wonder dot sk at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgslayout3dmapwidget.h"


QgsLayout3DMapWidget::QgsLayout3DMapWidget( QgsLayoutItem3DMap *map3D )
: QgsLayoutItemBaseWidget( nullptr, map3D )
, mMap3D( map3D )
{
setupUi( this );
}
@@ -0,0 +1,35 @@
/***************************************************************************
qgslayout3dmapwidget.h
--------------------------------------
Date : August 2018
Copyright : (C) 2018 by Martin Dobias
Email : wonder dot sk at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSLAYOUT3DMAPWIDGET_H
#define QGSLAYOUT3DMAPWIDGET_H

#include "qgslayoutitemwidget.h"
#include "ui_qgslayout3dmapwidgetbase.h"
#include "qgslayoutitem3dmap.h"

class QgsLayoutItem3DMap;

class QgsLayout3DMapWidget : public QgsLayoutItemBaseWidget, private Ui::QgsLayout3DMapWidgetBase
{
Q_OBJECT
public:
explicit QgsLayout3DMapWidget( QgsLayoutItem3DMap *map3D );

private:
QPointer< QgsLayoutItem3DMap > mMap3D;
};

#endif // QGSLAYOUT3DMAPWIDGET_H
@@ -43,6 +43,10 @@
#include "qgisapp.h"
#include "qgsmapcanvas.h"

#ifdef HAVE_3D
#include "qgslayout3dmapwidget.h"
#endif

void QgsLayoutAppUtils::registerGuiForKnownItemTypes()
{
QgsLayoutItemGuiRegistry *registry = QgsGui::layoutItemGuiRegistry();
@@ -341,4 +345,15 @@ void QgsLayoutAppUtils::registerGuiForKnownItemTypes()
return f;
} );
registry->addLayoutItemGuiMetadata( attributeTableItemMetadata .release() );

// 3D map item
#ifdef HAVE_3D
std::unique_ptr< QgsLayoutItemGuiMetadata > map3dMetadata = qgis::make_unique< QgsLayoutItemGuiMetadata>(
QgsLayoutItemRegistry::Layout3DMap, QObject::tr( "3D Map" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAdd3DMap.svg" ) ),
[ = ]( QgsLayoutItem * item )->QgsLayoutItemBaseWidget *
{
return new QgsLayout3DMapWidget( qobject_cast< QgsLayoutItem3DMap * >( item ) );
}, createRubberBand );
registry->addLayoutItemGuiMetadata( map3dMetadata.release() );
#endif
}

0 comments on commit d4a3f68

Please sign in to comment.
You can’t perform that action at this time.