QGIS API Documentation 3.43.0-Master (c67cf405802)
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;
28class QgsLineSymbol;
29
36{
37 Q_OBJECT
38
39 public:
40
45
47
53 static QgsLayoutItemElevationProfile *create( QgsLayout *layout ) SIP_FACTORY;
54
55 int type() const override;
56 QIcon icon() const override;
58 QgsLayoutItem::Flags itemFlags() const override;
59 bool requiresRasterization() const override;
60 bool containsAdvancedEffects() const override;
61
66 Qgs2DPlot *plot();
67
72 const Qgs2DPlot *plot() const SIP_SKIP;
73
79 QList< QgsMapLayer * > layers() const;
80
86 void setLayers( const QList< QgsMapLayer * > &layers );
87
97 void setProfileCurve( QgsCurve *curve SIP_TRANSFER );
98
106 QgsCurve *profileCurve() const;
107
115 void setCrs( const QgsCoordinateReferenceSystem &crs );
116
125
136 void setTolerance( double tolerance );
137
148 double tolerance() const;
149
155 bool atlasDriven() const { return mAtlasDriven; }
156
164 void setAtlasDriven( bool enabled );
165
169 QgsProfileRequest profileRequest() const;
170
171 void paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget ) override;
172
179 Qgis::DistanceUnit distanceUnit() const;
180
187 void setDistanceUnit( Qgis::DistanceUnit unit );
188
196 {
197 return mSubsectionsSymbol.get();
198 }
199
207 void setSubsectionsSymbol( QgsLineSymbol *symbol SIP_TRANSFER );
208
209 public slots:
210
211 void refresh() override;
212 void invalidateCache() override;
213
214 signals:
215
222
223 protected:
224 void draw( QgsLayoutItemRenderContext &context ) override;
225 bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
226 bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
227
228 private slots:
229
230 void recreateCachedImageInBackground();
231 void profileGenerationFinished();
232 private:
233
234 std::unique_ptr< QgsLayoutItemElevationProfilePlot > mPlot;
235
236 QList< QgsMapLayerRef > mLayers;
237
240 std::unique_ptr< QgsCurve> mCurve;
241 bool mAtlasDriven = false;
242
243 double mTolerance = 0;
244
245 std::unique_ptr<QgsLineSymbol> mSubsectionsSymbol;
246
247 // render job handling
248
249 // see note in QgsLayoutItemMap about these!
250 std::unique_ptr< QImage > mCacheFinalImage;
251 std::unique_ptr< QImage > mCacheRenderingImage;
252 bool mUpdatesEnabled = true;
253 bool mCacheInvalidated = true;
254 bool mDrawing = false;
255 bool mDrawingPreview = false;
256 QTimer *mBackgroundUpdateTimer = nullptr;
257 double mPreviewScaleFactor = 0;
258 std::unique_ptr< QPainter > mPainter;
259 std::unique_ptr< QgsProfilePlotRenderer > mRenderJob;
260
261
262};
263
264#endif //QGSLAYOUTITEMELEVATIONPROFILE_H
DistanceUnit
Units of distance.
Definition qgis.h:4843
@ Unknown
Unknown distance unit.
Base class for 2-dimensional plot/chart/graphs.
Definition qgsplot.h:273
Represents a coordinate reference system (CRS).
Abstract base class for curved geometry type.
Definition qgscurve.h:35
A layout item subclass for elevation profile plots.
QgsLineSymbol * subsectionsSymbol()
Returns the symbol used to draw the subsections.
bool atlasDriven() const
Returns whether the profile curve is set to follow the current atlas feature.
void previewRefreshed()
Emitted whenever the item's preview has been refreshed.
Contains settings and helpers relating to a render of a QgsLayoutItem.
Base class for graphical items within a QgsLayout.
virtual void refreshDataDefinedProperty(QgsLayoutObject::DataDefinedProperty property=QgsLayoutObject::DataDefinedProperty::AllProperties)
Refreshes a data defined property for the item by reevaluating the property's value and redrawing the...
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 bool requiresRasterization() const
Returns true if the item is drawn in such a way that forces the whole layout to be rasterized when ex...
virtual bool containsAdvancedEffects() const
Returns true if the item contains contents with blend modes or transparency effects which can only be...
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.
QFlags< Flag > Flags
void refresh() override
Refreshes the item, causing a recalculation of any property overrides and recalculation of its positi...
friend class QgsLayoutItemElevationProfile
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:49
A line symbol type, for rendering LineString and MultiLineString geometries.
Generates and renders elevation profile plots.
Encapsulates properties and constraints relating to fetching elevation profiles from different source...
A container for the context for various read/write operations on 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