QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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#include "qgscamerapose.h"
21#include "qgslayoutitem.h"
23
24#ifdef SIP_RUN
25// this is needed for the "convert to subclass" code below to compile
26% ModuleHeaderCode
27#include "qgslayoutitem3dmap.h"
28 % End
29#endif
30
31
32 class Qgs3DMapScene;
35
44{
45 Q_OBJECT
46
47#ifdef SIP_RUN
49 // the conversions have to be static, because they're using multiple inheritance
50 // (seen in PyQt4 .sip files for some QGraphicsItem classes)
51 switch ( sipCpp->type() )
52 {
53 // really, these *should* use the constants from QgsLayoutItemRegistry, but sip doesn't like that!
54 case QGraphicsItem::UserType + 115:
55 sipType = sipType_QgsLayoutItem3DMap;
56 *sipCppRet = static_cast<QgsLayoutItem3DMap *>( sipCpp );
57 break;
58 default:
59 sipType = 0;
60 }
62#endif
63
64 public:
71
73
80
81 int type() const override;
82 QIcon icon() const override;
83
85 void setCameraPose( const QgsCameraPose &pose );
87 QgsCameraPose cameraPose() const { return mCameraPose; }
88
94 void setMapSettings( Qgs3DMapSettings *settings SIP_TRANSFER );
96 Qgs3DMapSettings *mapSettings() const { return mSettings.get(); }
97
101 void assignFreeId();
102
104 QString displayName() const override;
105
106 void finalizeRestoreFromXml() override;
107
108 public slots:
109 void refresh() override;
110
111 protected:
112 void draw( QgsLayoutItemRenderContext &context ) override;
113 bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
114 bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
115
116 private slots:
117 void onImageCaptured( const QImage &img );
118 void onSceneStateChanged();
119 void onSizePositionChanged();
120
121 private:
123 void updateToolTip();
124
125 private:
126 std::unique_ptr<Qgs3DMapSettings> mSettings;
127 std::unique_ptr<QgsOffscreen3DEngine> mEngine;
128 Qgs3DMapScene *mScene = nullptr;
129 QImage mCapturedImage;
130 QgsCameraPose mCameraPose;
131 bool mDrawing = false;
132
134 int mMapId = 1;
135};
136
137#endif // QGSLAYOUTITEM3DMAP_H
Entity that encapsulates our 3D scene - contains all other entities (such as terrain) as children.
Definition of the world.
Encapsulates camera pose in a 3D scene.
void setCameraPose(const QgsCameraPose &pose)
Configures camera view.
~QgsLayoutItem3DMap() override
Qgs3DMapSettings * mapSettings() const
Returns map scene. May be nullptr if not yet configured.
QgsLayoutItem3DMap(QgsLayout *layout)
Constructor for QgsLayoutItem3DMap, with the specified parent layout.
static QgsLayoutItem3DMap * create(QgsLayout *layout)
Returns a new 3D map item for the specified layout.
QgsCameraPose cameraPose() const
Returns camera view.
Contains settings and helpers relating to a render of a QgsLayoutItem.
friend class QgsLayout
QgsLayoutItem(QgsLayout *layout, bool manageZValue=true)
Constructor for QgsLayoutItem, with the specified parent layout.
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.
const QgsLayout * layout() const
Returns the layout the object is attached to.
Off-screen 3D engine implementation.
A container for the context for various read/write operations on objects.
QgsTemporalRangeObject(bool enabled=false)
Constructor QgsTemporalRangeObject.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:199
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:84
#define SIP_END
Definition qgis_sip.h:216