QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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"
22 #include "qgstemporalrangeobject.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;
34 class Qgs3DMapSettings;
36 
44 class _3D_EXPORT QgsLayoutItem3DMap : public QgsLayoutItem, public QgsTemporalRangeObject
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  }
62  SIP_END
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
QgsLayoutItem::writePropertiesToElement
virtual bool writePropertiesToElement(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Stores item state within an XML DOM element.
Definition: qgslayoutitem.cpp:1318
QgsReadWriteContext
Definition: qgsreadwritecontext.h:34
qgstemporalrangeobject.h
QgsLayoutItem::icon
virtual QIcon icon() const
Returns the item's icon.
Definition: qgslayoutitem.h:331
QgsLayoutItem::finalizeRestoreFromXml
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
Definition: qgslayoutitem.cpp:825
QgsLayoutItem3DMap::cameraPose
QgsCameraPose cameraPose() const
Returns camera view.
Definition: qgslayoutitem3dmap.h:89
QgsLayoutItemRenderContext
Definition: qgslayoutitem.h:44
QgsLayoutItem3DMap
Definition: qgslayoutitem3dmap.h:44
QgsLayoutItem::readPropertiesFromElement
virtual bool readPropertiesFromElement(const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context)
Sets item state from a DOM element.
Definition: qgslayoutitem.cpp:1323
QgsLayoutItem::draw
virtual void draw(QgsLayoutItemRenderContext &context)=0
Draws the item's contents using the specified item render context.
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsLayoutItem::type
int type() const override
Returns a unique graphics item type identifier.
Definition: qgslayoutitem.cpp:124
SIP_CONVERT_TO_SUBCLASS_CODE
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:172
qgslayoutitem.h
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
Qgs3DMapSettings
Definition: qgs3dmapsettings.h:51
QgsLayoutItem
Base class for graphical items within a QgsLayout.
Definition: qgslayoutitem.h:112
QgsCameraPose
Definition: qgscamerapose.h:44
QgsLayoutItem::refresh
void refresh() override
Refreshes the item, causing a recalculation of any property overrides and recalculation of its positi...
Definition: qgslayoutitem.cpp:1172
Qgs3DMapScene
Definition: qgs3dmapscene.h:60
qgscamerapose.h
QgsLayout
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:49
QgsLayoutItem::displayName
virtual QString displayName() const
Gets item display name.
Definition: qgslayoutitem.cpp:107
SIP_END
#define SIP_END
Definition: qgis_sip.h:189
QgsOffscreen3DEngine
Definition: qgsoffscreen3dengine.h:64
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
QgsTemporalRangeObject
Definition: qgstemporalrangeobject.h:33
qgslayoutitem3dmap.h
QgsLayoutItem3DMap::mapSettings
Qgs3DMapSettings * mapSettings() const
Returns map scene. May be nullptr if not yet configured.
Definition: qgslayoutitem3dmap.h:98