QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
qgslayoutitemelevationprofile.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutitemelevationprofile.h
3 -------------------------------
4 begin : January 2023
5 copyright : (C) 2023 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#ifndef QGSLAYOUTITEMELEVATIONPROFILE_H
18#define QGSLAYOUTITEMELEVATIONPROFILE_H
19
20#include "qgis_core.h"
21#include "qgslayoutitem.h"
22#include "qgsmaplayerref.h"
23
24class QgsLayoutItemElevationProfilePlot;
25class Qgs2DPlot;
28
35{
36 Q_OBJECT
37
38 public:
39
44
46
52 static QgsLayoutItemElevationProfile *create( QgsLayout *layout ) SIP_FACTORY;
53
54 int type() const override;
55 QIcon icon() const override;
57 QgsLayoutItem::Flags itemFlags() const override;
58
63 Qgs2DPlot *plot();
64
69 const Qgs2DPlot *plot() const SIP_SKIP;
70
76 QList< QgsMapLayer * > layers() const;
77
83 void setLayers( const QList< QgsMapLayer * > &layers );
84
94 void setProfileCurve( QgsCurve *curve SIP_TRANSFER );
95
103 QgsCurve *profileCurve() const;
104
112 void setCrs( const QgsCoordinateReferenceSystem &crs );
113
122
133 void setTolerance( double tolerance );
134
145 double tolerance() const;
146
152 bool atlasDriven() const { return mAtlasDriven; }
153
161 void setAtlasDriven( bool enabled );
162
166 QgsProfileRequest profileRequest() const;
167
168 void paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget ) override;
169
170 public slots:
171
172 void refresh() override;
173 void invalidateCache() override;
174
175 protected:
176 void draw( QgsLayoutItemRenderContext &context ) override;
177 bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
178 bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
179
180 private slots:
181
182 void recreateCachedImageInBackground();
183 void profileGenerationFinished();
184 private:
185
186 std::unique_ptr< QgsLayoutItemElevationProfilePlot > mPlot;
187
188 QList< QgsMapLayerRef > mLayers;
189
191 std::unique_ptr< QgsCurve> mCurve;
192 bool mAtlasDriven = false;
193
194 double mTolerance = 0;
195
196 // render job handling
197
198 // see note in QgsLayoutItemMap about these!
199 std::unique_ptr< QImage > mCacheFinalImage;
200 std::unique_ptr< QImage > mCacheRenderingImage;
201 bool mUpdatesEnabled = true;
202 bool mCacheInvalidated = true;
203 bool mDrawing = false;
204 bool mDrawingPreview = false;
205 QTimer *mBackgroundUpdateTimer = nullptr;
206 double mPreviewScaleFactor = 0;
207 std::unique_ptr< QPainter > mPainter;
208 std::unique_ptr< QgsProfilePlotRenderer > mRenderJob;
209 bool mPainterCancelWait = false;
210
211
212};
213
214#endif //QGSLAYOUTITEMELEVATIONPROFILE_H
Base class for 2-dimensional plot/chart/graphs.
Definition: qgsplot.h:235
This class represents a coordinate reference system (CRS).
Abstract base class for curved geometry type.
Definition: qgscurve.h:36
A layout item subclass for elevation profile plots.
bool atlasDriven() const
Returns whether the profile curve is set to follow the current atlas feature.
Contains settings and helpers relating to a render of a QgsLayoutItem.
Definition: qgslayoutitem.h:44
Base class for graphical items within a QgsLayout.
virtual QIcon icon() const
Returns the item's icon.
void paint(QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget) override
Handles preparing a paint surface for the layout item and painting the item's content.
virtual bool writePropertiesToElement(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Stores item state within an XML DOM element.
int type() const override
Returns a unique graphics item type identifier.
virtual void refreshDataDefinedProperty(QgsLayoutObject::DataDefinedProperty property=QgsLayoutObject::AllProperties)
Refreshes a data defined property for the item by reevaluating the property's value and redrawing the...
virtual void invalidateCache()
Forces a deferred update of any cached image the item uses.
virtual Flags itemFlags() const
Returns the item's flags, which indicate how the item behaves.
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.
DataDefinedProperty
Data defined properties for different item types.
@ AllProperties
All properties for item.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:50
Generates and renders elevation profile plots.
Encapsulates properties and constraints relating to fetching elevation profiles from different source...
The class is used as a container of context for various read/write operations on other objects.
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_FACTORY
Definition: qgis_sip.h:76
const QgsCoordinateReferenceSystem & crs