Skip to content

Commit

Permalink
Fix elevation profile item transparency forces rasterisation of
Browse files Browse the repository at this point in the history
whole layout, expand unit test coverage
  • Loading branch information
nyalldawson committed Oct 11, 2023
1 parent 3588d41 commit df1dc0d
Show file tree
Hide file tree
Showing 11 changed files with 360 additions and 15 deletions.
Expand Up @@ -44,6 +44,10 @@ The caller takes responsibility for deleting the returned object.

virtual QgsLayoutItem::Flags itemFlags() const;

virtual bool requiresRasterization() const;

virtual bool containsAdvancedEffects() const;


Qgs2DPlot *plot();
%Docstring
Expand Down Expand Up @@ -177,6 +181,15 @@ Sets the ``unit`` for the distance axis.
virtual void invalidateCache();


signals:

void previewRefreshed();
%Docstring
Emitted whenever the item's preview has been refreshed.

.. versionadded:: 3.34
%End

protected:
virtual void draw( QgsLayoutItemRenderContext &context );

Expand Down
1 change: 1 addition & 0 deletions src/core/layout/qgslayoutitem.h
Expand Up @@ -1367,6 +1367,7 @@ class CORE_EXPORT QgsLayoutItem : public QgsLayoutObject, public QGraphicsRectIt
friend class QgsLayoutItemGroup;
friend class QgsLayoutItemMap;
friend class QgsLayoutItemLegend;
friend class QgsLayoutItemElevationProfile;
friend class QgsCompositionConverter;
};

Expand Down
11 changes: 11 additions & 0 deletions src/core/layout/qgslayoutitemelevationprofile.cpp
Expand Up @@ -449,6 +449,16 @@ QgsLayoutItem::Flags QgsLayoutItemElevationProfile::itemFlags() const
return QgsLayoutItem::FlagOverridesPaint;
}

bool QgsLayoutItemElevationProfile::requiresRasterization() const
{
return blendMode() != QPainter::CompositionMode_SourceOver;
}

bool QgsLayoutItemElevationProfile::containsAdvancedEffects() const
{
return mEvaluatedOpacity < 1.0;
}

Qgs2DPlot *QgsLayoutItemElevationProfile::plot()
{
return mPlot.get();
Expand Down Expand Up @@ -920,6 +930,7 @@ void QgsLayoutItemElevationProfile::profileGenerationFinished()
mCacheFinalImage = std::move( mCacheRenderingImage );
emit backgroundTaskCountChanged( 0 );
update();
emit previewRefreshed();
}

Qgis::DistanceUnit QgsLayoutItemElevationProfile::distanceUnit() const
Expand Down
11 changes: 11 additions & 0 deletions src/core/layout/qgslayoutitemelevationprofile.h
Expand Up @@ -55,6 +55,8 @@ class CORE_EXPORT QgsLayoutItemElevationProfile: public QgsLayoutItem
QIcon icon() const override;
void refreshDataDefinedProperty( QgsLayoutObject::DataDefinedProperty property = QgsLayoutObject::AllProperties ) override;
QgsLayoutItem::Flags itemFlags() const override;
bool requiresRasterization() const override;
bool containsAdvancedEffects() const override;

/**
* Returns a reference to the elevation plot object, which can be used to
Expand Down Expand Up @@ -188,6 +190,15 @@ class CORE_EXPORT QgsLayoutItemElevationProfile: public QgsLayoutItem
void refresh() override;
void invalidateCache() override;

signals:

/**
* Emitted whenever the item's preview has been refreshed.
*
* \since QGIS 3.34
*/
void previewRefreshed();

protected:
void draw( QgsLayoutItemRenderContext &context ) override;
bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
Expand Down

0 comments on commit df1dc0d

Please sign in to comment.