QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
qgslayoutitem3dmap.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutitem3dmap.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 QGSLAYOUTITEM3DMAP_H
17#define QGSLAYOUTITEM3DMAP_H
18
19#include "qgis_3d.h"
20
21#include "qgslayoutitem.h"
23#include "qgscamerapose.h"
24
25#ifdef SIP_RUN
26// this is needed for the "convert to subclass" code below to compile
27% ModuleHeaderCode
28#include "qgslayoutitem3dmap.h"
29% End
30#endif
31
32
33class Qgs3DMapScene;
36
45{
46 Q_OBJECT
47
48#ifdef SIP_RUN
50 // the conversions have to be static, because they're using multiple inheritance
51 // (seen in PyQt4 .sip files for some QGraphicsItem classes)
52 switch ( sipCpp->type() )
53 {
54 // really, these *should* use the constants from QgsLayoutItemRegistry, but sip doesn't like that!
55 case QGraphicsItem::UserType + 115:
56 sipType = sipType_QgsLayoutItem3DMap;
57 *sipCppRet = static_cast<QgsLayoutItem3DMap *>( sipCpp );
58 break;
59 default:
60 sipType = 0;
61 }
63#endif
64
65 public:
66
73
75
81 static QgsLayoutItem3DMap *create( QgsLayout *layout ) SIP_FACTORY;
82
83 virtual int type() const override;
84 QIcon icon() const override;
85
87 void setCameraPose( const QgsCameraPose &pose );
89 QgsCameraPose cameraPose() const { return mCameraPose; }
90
96 void setMapSettings( Qgs3DMapSettings *settings SIP_TRANSFER );
98 Qgs3DMapSettings *mapSettings() const { return mSettings.get(); }
99
103 void assignFreeId();
104
106 QString displayName() const override;
107
108 void finalizeRestoreFromXml() override;
109
110 public slots:
111 void refresh() override;
112
113 protected:
114 void draw( QgsLayoutItemRenderContext &context ) override;
115 bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
116 bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
117
118 private slots:
119 void onImageCaptured( const QImage &img );
120 void onSceneStateChanged();
121 void onSizePositionChanged();
122
123 private:
125 void updateToolTip();
126
127 private:
128 std::unique_ptr<Qgs3DMapSettings> mSettings;
129 std::unique_ptr<QgsOffscreen3DEngine> mEngine;
130 Qgs3DMapScene *mScene = nullptr;
131 QImage mCapturedImage;
132 QgsCameraPose mCameraPose;
133 bool mDrawing = false;
134
136 int mMapId = 1;
137};
138
139#endif // QGSLAYOUTITEM3DMAP_H
Qgs3DMapSettings * mapSettings() const
Returns map scene. May be nullptr if not yet configured.
QgsCameraPose cameraPose() const
Returns camera view.
Contains settings and helpers relating to a render of a QgsLayoutItem.
Base class for graphical items within a QgsLayout.
virtual QIcon icon() const
Returns the item's icon.
virtual bool writePropertiesToElement(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Stores item state within an XML DOM element.
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
int type() const override
Returns a unique graphics item type identifier.
virtual QString displayName() const
Gets item display name.
virtual bool readPropertiesFromElement(const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context)
Sets item state from a DOM element.
void refresh() override
Refreshes the item, causing a recalculation of any property overrides and recalculation of its positi...
virtual void draw(QgsLayoutItemRenderContext &context)=0
Draws the item's contents using the specified item render context.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition qgslayout.h:49
The class is used as a container of context for various read/write operations on other objects.
Base class for objects with an associated (optional) temporal range.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:191
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:76
#define SIP_END
Definition qgis_sip.h:208