QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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 
23 #include "qgscamerapose.h"
24 
25 
26 class Qgs3DMapScene;
27 class Qgs3DMapSettings;
29 
37 class _3D_EXPORT QgsLayoutItem3DMap : public QgsLayoutItem
38 {
39  Q_OBJECT
40 
41 #ifdef SIP_RUN
43  // the conversions have to be static, because they're using multiple inheritance
44  // (seen in PyQt4 .sip files for some QGraphicsItem classes)
45  switch ( sipCpp->type() )
46  {
47  // really, these *should* use the constants from QgsLayoutItemRegistry, but sip doesn't like that!
48  case QGraphicsItem::UserType + 115:
49  sipType = sipType_QgsLayoutItem3DMap;
50  *sipCppRet = static_cast<QgsLayoutItem3DMap *>( sipCpp );
51  break;
52  default:
53  sipType = 0;
54  }
55  SIP_END
56 #endif
57 
58  public:
59 
66 
68 
74  static QgsLayoutItem3DMap *create( QgsLayout *layout ) SIP_FACTORY;
75 
76  virtual int type() const override;
77  QIcon icon() const override;
78 
80  void setCameraPose( const QgsCameraPose &pose );
82  QgsCameraPose cameraPose() const { return mCameraPose; }
83 
89  void setMapSettings( Qgs3DMapSettings *settings SIP_TRANSFER );
91  Qgs3DMapSettings *mapSettings() const { return mSettings.get(); }
92 
96  void assignFreeId();
97 
99  QString displayName() const override;
100 
101  void finalizeRestoreFromXml() override;
102 
103  public slots:
104  void refresh() override;
105 
106  protected:
107  void draw( QgsLayoutItemRenderContext &context ) override;
108  bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
109  bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
110 
111  private slots:
112  void onImageCaptured( const QImage &img );
113  void onSceneStateChanged();
114  void onSizePositionChanged();
115 
116  private:
118  void updateToolTip();
119 
120  private:
121  std::unique_ptr<Qgs3DMapSettings> mSettings;
122  std::unique_ptr<QgsOffscreen3DEngine> mEngine;
123  Qgs3DMapScene *mScene = nullptr;
124  QImage mCapturedImage;
125  QgsCameraPose mCameraPose;
126  bool mDrawing = false;
127 
129  int mMapId = 1;
130 };
131 
132 #endif // QGSLAYOUTITEM3DMAP_H
The class is used as a container of context for various read/write operations on other objects...
virtual QIcon icon() const
Returns the item&#39;s icon.
Base class for graphical items within a QgsLayout.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
int type() const override
Returns a unique graphics item type identifier.
3 Definition of the world
3 Class that encapsulates camera pose in a 3D scene.
Definition: qgscamerapose.h:41
virtual bool readPropertiesFromElement(const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context)
Sets item state from a DOM element.
3 Off-screen 3D engine implementation.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_END
Definition: qgis_sip.h:189
#define SIP_FACTORY
Definition: qgis_sip.h:76
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:49
Contains settings and helpers relating to a render of a QgsLayoutItem.
Definition: qgslayoutitem.h:44
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
virtual QString displayName() const
Gets item display name.
3 Entity that encapsulates our 3D scene - contains all other entities (such as terrain) as children...
Definition: qgs3dmapscene.h:54
Qgs3DMapSettings * mapSettings() const
Returns map scene. May be nullptr if not yet configured.
3Implements support of 3D map views in print layouts
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:172
QgsCameraPose cameraPose() const
Returns camera view.
virtual bool writePropertiesToElement(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Stores item state within an XML DOM element.
virtual void draw(QgsLayoutItemRenderContext &context)=0
Draws the item&#39;s contents using the specified item render context.
void refresh() override
Refreshes the item, causing a recalculation of any property overrides and recalculation of its positi...