QGIS API Documentation 3.41.0-Master (cea29feecf2)
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
33 class 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:
72
74
80 static QgsLayoutItem3DMap *create( QgsLayout *layout ) SIP_FACTORY;
81
82 virtual int type() const override;
83 QIcon icon() const override;
84
86 void setCameraPose( const QgsCameraPose &pose );
88 QgsCameraPose cameraPose() const { return mCameraPose; }
89
95 void setMapSettings( Qgs3DMapSettings *settings SIP_TRANSFER );
97 Qgs3DMapSettings *mapSettings() const { return mSettings.get(); }
98
102 void assignFreeId();
103
105 QString displayName() const override;
106
107 void finalizeRestoreFromXml() override;
108
109 public slots:
110 void refresh() override;
111
112 protected:
113 void draw( QgsLayoutItemRenderContext &context ) override;
114 bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
115 bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
116
117 private slots:
118 void onImageCaptured( const QImage &img );
119 void onSceneStateChanged();
120 void onSizePositionChanged();
121
122 private:
124 void updateToolTip();
125
126 private:
127 std::unique_ptr<Qgs3DMapSettings> mSettings;
128 std::unique_ptr<QgsOffscreen3DEngine> mEngine;
129 Qgs3DMapScene *mScene = nullptr;
130 QImage mCapturedImage;
131 QgsCameraPose mCameraPose;
132 bool mDrawing = false;
133
135 int mMapId = 1;
136};
137
138#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