17#ifndef QGSLAYOUTITEMELEVATIONPROFILE_H
18#define QGSLAYOUTITEMELEVATIONPROFILE_H
26using namespace Qt::StringLiterals;
28class QgsLayoutItemElevationProfilePlot;
58 int type()
const override;
59 QIcon
icon()
const override;
82 QList< QgsMapLayer * >
layers()
const;
98 QList<QgsAbstractProfileSource *>
sources()
const;
106 void setSources(
const QList< std::variant< QgsMapLayer *, QgsAbstractProfileSource * > > &
sources );
117 if ( PyList_Check( a0 ) && PyList_GET_SIZE( a0 ) )
120 QList< std::variant< QgsMapLayer *, QgsAbstractProfileSource * > > sourcesList;
121 for ( SIP_SSIZE_T i = 0; i < PyList_GET_SIZE( a0 ); ++i )
123 PyObject *p0 = PyList_GetItem( a0, i );
126 const sipTypeDef *source_type = sipFindType(
"QgsAbstractProfileSource" );
128 if ( sipCanConvertToType( p0, sipType_QgsMapLayer, SIP_NOT_NONE ) )
130 QgsMapLayer *layerSource =
reinterpret_cast<QgsMapLayer *
>( sipConvertToType( p0, sipType_QgsMapLayer, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
135 sourcesList << layerSource;
140 PyErr_SetString( PyExc_ValueError, u
"The input list contains a map layer that does not provide a valid profile source!"_s.toUtf8().constData() );
144 sipReleaseType( layerSource, sipType_QgsMapLayer, state );
146 else if ( sipCanConvertToType( p0, source_type, SIP_NOT_NONE ) )
151 sourcesList << profileSource;
154 sipReleaseType( profileSource, source_type, state );
159 PyErr_SetString( PyExc_TypeError, u
"The input list contains an element with unexpected type!"_s.toUtf8().constData() );
164 sipCpp->setSources( sourcesList );
170 PyErr_SetString( PyExc_TypeError, u
"First argument is not a list or is empty."_s.toUtf8().constData() );
252 void setAtlasDriven(
bool enabled );
259 void paint( QPainter *painter,
const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
override;
322 double elevationScale()
const;
336 void setElevationScale(
double scale );
350 double distanceScale()
const;
364 void setDistanceScale(
double scale );
387 void recreateCachedImageInBackground();
388 void profileGenerationFinished();
389 void setSourcesPrivate();
394 std::unique_ptr< QgsLayoutItemElevationProfilePlot > mPlot;
396 QList< QgsMapLayerRef > mLayers;
397 QList< std::variant< QgsMapLayerRef, QgsAbstractProfileSource * > > mSources;
400 double mElevationScale = 10;
401 double mDistanceScale = 1000;
405 std::unique_ptr< QgsCurve> mCurve;
406 bool mAtlasDriven =
false;
408 double mTolerance = 0;
410 std::unique_ptr<QgsLineSymbol> mSubsectionsSymbol;
415 std::unique_ptr< QImage > mCacheFinalImage;
416 std::unique_ptr< QImage > mCacheRenderingImage;
417 bool mUpdatesEnabled =
true;
418 bool mCacheInvalidated =
true;
419 bool mDrawing =
false;
420 bool mDrawingPreview =
false;
421 QTimer *mBackgroundUpdateTimer =
nullptr;
422 double mPreviewScaleFactor = 0;
423 std::unique_ptr< QPainter > mPainter;
424 std::unique_ptr< QgsProfilePlotRenderer > mRenderJob;
DistanceUnit
Units of distance.
@ Unknown
Unknown distance unit.
ElevationProfileRangeMethod
Elevation profile range calculation methods.
@ ManualRange
Distance/elevation ranges are manually set.
Base class for 2-dimensional plot/chart/graphs with an X and Y axes.
Interface for classes which can generate elevation profiles.
Represents a coordinate reference system (CRS).
Abstract base class for curved geometry type.
static QgsLayoutItemElevationProfile * create(QgsLayout *layout)
Returns a new elevation profile item for the specified layout.
Qgs2DXyPlot * plot()
Returns a reference to the elevation plot object, which can be used to set plot appearance and proper...
QgsLayoutItemElevationProfile(QgsLayout *layout)
Constructor for QgsLayoutItemElevationProfile, with the specified parent layout.
QgsCurve * profileCurve() const
Returns the cross section profile curve, which represents the line along which the profile should be ...
void setLayers(const QList< QgsMapLayer * > &layers)
Sets the list of map layers participating in the elevation profile.
QList< QgsMapLayer * > layers() const
Returns the list of map layers participating in the elevation profile.
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets the desired Coordinate Reference System (crs) for the profile.
void setSources(const QList< std::variant< QgsMapLayer *, QgsAbstractProfileSource * > > &sources)
Sets the list of sources participating in the elevation profile.
QList< QgsAbstractProfileSource * > sources() const
Returns the list of sources participating in the elevation profile.
void setTolerance(double tolerance)
Sets the tolerance of the request (in crs() units).
QgsCoordinateReferenceSystem crs() const
Returns the desired Coordinate Reference System for the profile.
double tolerance() const
Returns the tolerance of the request (in crs() units).
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.
void setProfileCurve(QgsCurve *curve)
Sets the cross section profile curve, which represents the line along which the profile should be gen...
Contains settings and helpers relating to a render of a QgsLayoutItem.
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...
QgsLayoutItem(QgsLayout *layout, bool manageZValue=true)
Constructor for QgsLayoutItem, with the specified parent layout.
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.
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.
const QgsLayout * layout() const
Returns the layout the object is attached to.
DataDefinedProperty
Data defined properties for different item types.
@ AllProperties
All properties for item.
A line symbol type, for rendering LineString and MultiLineString geometries.
Base class for all map layer types.
virtual QgsAbstractProfileSource * profileSource()
Returns the layer's profile source if it has profile capabilities.
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.
Contains information about the context of a rendering operation.
#define SIP_TYPEHINT(type)