Skip to content

Commit d4a3f68

Browse files
committedAug 21, 2018
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!
1 parent eb220ed commit d4a3f68

File tree

10 files changed

+463
-1
lines changed

10 files changed

+463
-1
lines changed
 

‎images/images.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,7 @@
702702
<file>themes/default/mIconGPU.svg</file>
703703
<file>themes/default/mAddToProject.svg</file>
704704
<file>themes/default/mDockify.svg</file>
705+
<file>themes/default/mActionAdd3DMap.svg</file>
705706
</qresource>
706707
<qresource prefix="/images/tips">
707708
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
Lines changed: 163 additions & 0 deletions
Loading

‎src/3d/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ SET(QGIS_3D_MOC_HDRS
5454
qgs3dmapsettings.h
5555
qgsabstract3dengine.h
5656
qgscameracontroller.h
57+
qgslayoutitem3dmap.h
5758
qgsoffscreen3dengine.h
5859
qgswindow3dengine.h
5960

‎src/3d/qgslayoutitem3dmap.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@
2626
QgsLayoutItem3DMap::QgsLayoutItem3DMap( QgsLayout *layout )
2727
: QgsLayoutItem( layout )
2828
{
29-
3029
}
3130

31+
QgsLayoutItem3DMap::~QgsLayoutItem3DMap() = default;
32+
33+
3234
QgsLayoutItem3DMap *QgsLayoutItem3DMap::create( QgsLayout *layout )
3335
{
3436
return new QgsLayoutItem3DMap( layout );
@@ -41,6 +43,9 @@ int QgsLayoutItem3DMap::type() const
4143

4244
void QgsLayoutItem3DMap::draw( QgsLayoutItemRenderContext &context )
4345
{
46+
if ( !mSettings )
47+
return;
48+
4449
QgsOffscreen3DEngine engine;
4550
QSizeF sizePixels = mLayout->renderContext().measurementConverter().convert( sizeWithUnits(), QgsUnitTypes::LayoutPixels ).toQSizeF();
4651
engine.setSize( QSize( static_cast<int>( std::ceil( sizePixels.width() ) ),

‎src/3d/qgslayoutitem3dmap.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class Qgs3DMapSettings;
3434
*/
3535
class _3D_EXPORT QgsLayoutItem3DMap : public QgsLayoutItem
3636
{
37+
Q_OBJECT
3738

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

65+
~QgsLayoutItem3DMap();
66+
6467
/**
6568
* Returns a new 3D map item for the specified \a layout.
6669
*

‎src/app/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ IF (WITH_3D)
446446
3d/qgspolygon3dsymbolwidget.cpp
447447
3d/qgsphongmaterialwidget.cpp
448448
3d/qgsvectorlayer3drendererwidget.cpp
449+
layout/qgslayout3dmapwidget.cpp
449450
)
450451

451452
SET (QGIS_APP_MOC_HDRS
@@ -459,6 +460,7 @@ IF (WITH_3D)
459460
3d/qgspolygon3dsymbolwidget.h
460461
3d/qgsphongmaterialwidget.h
461462
3d/qgsvectorlayer3drendererwidget.h
463+
layout/qgslayout3dmapwidget.h
462464
)
463465
ENDIF (WITH_3D)
464466

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/***************************************************************************
2+
qgslayout3dmapwidget.cpp
3+
--------------------------------------
4+
Date : August 2018
5+
Copyright : (C) 2018 by Martin Dobias
6+
Email : wonder dot sk at gmail dot com
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
15+
16+
#include "qgslayout3dmapwidget.h"
17+
18+
19+
QgsLayout3DMapWidget::QgsLayout3DMapWidget( QgsLayoutItem3DMap *map3D )
20+
: QgsLayoutItemBaseWidget( nullptr, map3D )
21+
, mMap3D( map3D )
22+
{
23+
setupUi( this );
24+
}

‎src/app/layout/qgslayout3dmapwidget.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/***************************************************************************
2+
qgslayout3dmapwidget.h
3+
--------------------------------------
4+
Date : August 2018
5+
Copyright : (C) 2018 by Martin Dobias
6+
Email : wonder dot sk at gmail dot com
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
15+
16+
#ifndef QGSLAYOUT3DMAPWIDGET_H
17+
#define QGSLAYOUT3DMAPWIDGET_H
18+
19+
#include "qgslayoutitemwidget.h"
20+
#include "ui_qgslayout3dmapwidgetbase.h"
21+
#include "qgslayoutitem3dmap.h"
22+
23+
class QgsLayoutItem3DMap;
24+
25+
class QgsLayout3DMapWidget : public QgsLayoutItemBaseWidget, private Ui::QgsLayout3DMapWidgetBase
26+
{
27+
Q_OBJECT
28+
public:
29+
explicit QgsLayout3DMapWidget( QgsLayoutItem3DMap *map3D );
30+
31+
private:
32+
QPointer< QgsLayoutItem3DMap > mMap3D;
33+
};
34+
35+
#endif // QGSLAYOUT3DMAPWIDGET_H

‎src/app/layout/qgslayoutapputils.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
#include "qgisapp.h"
4444
#include "qgsmapcanvas.h"
4545

46+
#ifdef HAVE_3D
47+
#include "qgslayout3dmapwidget.h"
48+
#endif
49+
4650
void QgsLayoutAppUtils::registerGuiForKnownItemTypes()
4751
{
4852
QgsLayoutItemGuiRegistry *registry = QgsGui::layoutItemGuiRegistry();
@@ -341,4 +345,15 @@ void QgsLayoutAppUtils::registerGuiForKnownItemTypes()
341345
return f;
342346
} );
343347
registry->addLayoutItemGuiMetadata( attributeTableItemMetadata .release() );
348+
349+
// 3D map item
350+
#ifdef HAVE_3D
351+
std::unique_ptr< QgsLayoutItemGuiMetadata > map3dMetadata = qgis::make_unique< QgsLayoutItemGuiMetadata>(
352+
QgsLayoutItemRegistry::Layout3DMap, QObject::tr( "3D Map" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAdd3DMap.svg" ) ),
353+
[ = ]( QgsLayoutItem * item )->QgsLayoutItemBaseWidget *
354+
{
355+
return new QgsLayout3DMapWidget( qobject_cast< QgsLayoutItem3DMap * >( item ) );
356+
}, createRubberBand );
357+
registry->addLayoutItemGuiMetadata( map3dMetadata.release() );
358+
#endif
344359
}
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>QgsLayout3DMapWidgetBase</class>
4+
<widget class="QWidget" name="QgsLayout3DMapWidgetBase">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>540</width>
10+
<height>613</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>3D Map</string>
15+
</property>
16+
<layout class="QVBoxLayout" name="verticalLayout_2">
17+
<property name="spacing">
18+
<number>0</number>
19+
</property>
20+
<property name="leftMargin">
21+
<number>0</number>
22+
</property>
23+
<property name="topMargin">
24+
<number>0</number>
25+
</property>
26+
<property name="rightMargin">
27+
<number>0</number>
28+
</property>
29+
<property name="bottomMargin">
30+
<number>0</number>
31+
</property>
32+
<item>
33+
<widget class="QLabel" name="mLabel">
34+
<property name="sizePolicy">
35+
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
36+
<horstretch>0</horstretch>
37+
<verstretch>0</verstretch>
38+
</sizepolicy>
39+
</property>
40+
<property name="styleSheet">
41+
<string notr="true">padding: 2px; font-weight: bold; background-color: rgb(200, 200, 200);</string>
42+
</property>
43+
<property name="text">
44+
<string>3D Map</string>
45+
</property>
46+
</widget>
47+
</item>
48+
<item>
49+
<widget class="QScrollArea" name="scrollArea">
50+
<property name="widgetResizable">
51+
<bool>true</bool>
52+
</property>
53+
<widget class="QWidget" name="scrollAreaWidgetContents_2">
54+
<property name="geometry">
55+
<rect>
56+
<x>0</x>
57+
<y>0</y>
58+
<width>510</width>
59+
<height>635</height>
60+
</rect>
61+
</property>
62+
<layout class="QVBoxLayout" name="verticalLayout_6">
63+
<item>
64+
<widget class="QGroupBox" name="groupBox_3">
65+
<property name="title">
66+
<string>Scene settings</string>
67+
</property>
68+
<layout class="QVBoxLayout" name="verticalLayout_5">
69+
<item>
70+
<widget class="QPushButton" name="mCopySettingsButton">
71+
<property name="text">
72+
<string>Copy settings from a 3D view...</string>
73+
</property>
74+
</widget>
75+
</item>
76+
</layout>
77+
</widget>
78+
</item>
79+
<item>
80+
<widget class="QGroupBox" name="groupBox_4">
81+
<property name="title">
82+
<string>Camera pose</string>
83+
</property>
84+
<layout class="QGridLayout" name="gridLayout_3">
85+
<item row="0" column="0">
86+
<widget class="QLabel" name="label">
87+
<property name="text">
88+
<string>Center X</string>
89+
</property>
90+
</widget>
91+
</item>
92+
<item row="0" column="1">
93+
<widget class="QDoubleSpinBox" name="mCenterXLineEdit">
94+
<property name="decimals">
95+
<number>1</number>
96+
</property>
97+
<property name="minimum">
98+
<double>-999999.000000000000000</double>
99+
</property>
100+
<property name="maximum">
101+
<double>999999.000000000000000</double>
102+
</property>
103+
</widget>
104+
</item>
105+
<item row="1" column="0">
106+
<widget class="QLabel" name="label_3">
107+
<property name="text">
108+
<string>Center Y</string>
109+
</property>
110+
</widget>
111+
</item>
112+
<item row="1" column="1">
113+
<widget class="QDoubleSpinBox" name="mCenterYLineEdit">
114+
<property name="decimals">
115+
<number>1</number>
116+
</property>
117+
<property name="minimum">
118+
<double>-999999.000000000000000</double>
119+
</property>
120+
<property name="maximum">
121+
<double>999999.000000000000000</double>
122+
</property>
123+
</widget>
124+
</item>
125+
<item row="2" column="0">
126+
<widget class="QLabel" name="label_4">
127+
<property name="text">
128+
<string>Center Z</string>
129+
</property>
130+
</widget>
131+
</item>
132+
<item row="2" column="1">
133+
<widget class="QDoubleSpinBox" name="mCenterZLineEdit">
134+
<property name="decimals">
135+
<number>1</number>
136+
</property>
137+
<property name="minimum">
138+
<double>-999999.000000000000000</double>
139+
</property>
140+
<property name="maximum">
141+
<double>999999.000000000000000</double>
142+
</property>
143+
</widget>
144+
</item>
145+
<item row="3" column="0">
146+
<widget class="QLabel" name="label_5">
147+
<property name="text">
148+
<string>Distance</string>
149+
</property>
150+
</widget>
151+
</item>
152+
<item row="3" column="1">
153+
<widget class="QDoubleSpinBox" name="mDistanceToCenterLineEdit">
154+
<property name="decimals">
155+
<number>1</number>
156+
</property>
157+
<property name="maximum">
158+
<double>999999.000000000000000</double>
159+
</property>
160+
</widget>
161+
</item>
162+
<item row="4" column="0">
163+
<widget class="QLabel" name="label_6">
164+
<property name="text">
165+
<string>Pitch</string>
166+
</property>
167+
</widget>
168+
</item>
169+
<item row="4" column="1">
170+
<widget class="QDoubleSpinBox" name="mPitchAngleLineEdit">
171+
<property name="suffix">
172+
<string> °</string>
173+
</property>
174+
<property name="decimals">
175+
<number>1</number>
176+
</property>
177+
<property name="maximum">
178+
<double>360.000000000000000</double>
179+
</property>
180+
</widget>
181+
</item>
182+
<item row="5" column="0">
183+
<widget class="QLabel" name="label_7">
184+
<property name="text">
185+
<string>Heading</string>
186+
</property>
187+
</widget>
188+
</item>
189+
<item row="5" column="1">
190+
<widget class="QDoubleSpinBox" name="mHeadingAngleLineEdit">
191+
<property name="suffix">
192+
<string> °</string>
193+
</property>
194+
<property name="decimals">
195+
<number>1</number>
196+
</property>
197+
<property name="maximum">
198+
<double>360.000000000000000</double>
199+
</property>
200+
</widget>
201+
</item>
202+
</layout>
203+
</widget>
204+
</item>
205+
</layout>
206+
</widget>
207+
</widget>
208+
</item>
209+
</layout>
210+
</widget>
211+
<resources/>
212+
<connections/>
213+
</ui>

0 commit comments

Comments
 (0)
Please sign in to comment.