mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
[layouts] Remove use of QStyleOptionGraphicsItem from QgsLayoutItem API
Turns out the useful methods in QStyleOptionGraphicsItem were deprecated in Qt 5.10. To future protect our API this replaces all public use of QStyleOptionGraphicsItem, so that we're free to revise the internals of how we use QStyleOptionGraphicsItem without breaking the public QGIS API.
This commit is contained in:
parent
9911209257
commit
0e3af9c6a9
@ -118,7 +118,7 @@ Returns whether the frame is empty.
|
||||
|
||||
protected:
|
||||
|
||||
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
|
||||
virtual void draw( QgsLayoutItemRenderContext &context );
|
||||
|
||||
virtual void drawFrame( QgsRenderContext &context );
|
||||
|
||||
|
@ -9,10 +9,64 @@
|
||||
|
||||
|
||||
|
||||
|
||||
class QgsLayoutItemRenderContext
|
||||
{
|
||||
%Docstring
|
||||
Contains settings and helpers relating to a render of a QgsLayoutItem.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgslayoutitem.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsLayoutItemRenderContext( QgsRenderContext &context, double viewScaleFactor = 1.0 );
|
||||
%Docstring
|
||||
Constructor for QgsLayoutItemRenderContext.
|
||||
|
||||
The ``renderContext`` parameter specifies a QgsRenderContext for use within
|
||||
the QgsLayoutItemRenderContext.
|
||||
|
||||
The ``viewScaleFactor`` gives the current view zoom (scale factor). It can be
|
||||
used to scale render graphics so that they always appear a constant size,
|
||||
regardless of the current view zoom.
|
||||
%End
|
||||
|
||||
|
||||
|
||||
QgsRenderContext &renderContext();
|
||||
%Docstring
|
||||
Returns a reference to the context's render context.
|
||||
|
||||
Note that the context's painter has been scaled so that painter units are pixels.
|
||||
Use the QgsRenderContext methods to convert from millimeters or other units to the painter's units.
|
||||
%End
|
||||
|
||||
|
||||
double viewScaleFactor() const;
|
||||
%Docstring
|
||||
Returns the current view zoom (scale factor). It can be
|
||||
used to scale render graphics so that they always appear a constant size,
|
||||
regardless of the current view zoom.
|
||||
|
||||
E.g. a value of 0.5 indicates that the view is zoomed out to 50% size, so rendered
|
||||
items must be scaled by 200% in order to have a constant visible size. A value
|
||||
of 2.0 indicates that the view is zoomed in 200%, so rendered items must be
|
||||
scaled by 50% in order to have a constant visible size.
|
||||
%End
|
||||
|
||||
private:
|
||||
QgsLayoutItemRenderContext( const QgsLayoutItemRenderContext &rh );
|
||||
};
|
||||
|
||||
|
||||
class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem, QgsLayoutUndoObjectInterface
|
||||
{
|
||||
%Docstring
|
||||
Base class for graphical items within a QgsLayout.
|
||||
Base class for graphical items within a :py:class:`QgsLayout`.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
@ -939,9 +993,10 @@ painter.
|
||||
:param painter: destination QPainter
|
||||
%End
|
||||
|
||||
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 ) = 0;
|
||||
virtual void draw( QgsLayoutItemRenderContext &context ) = 0;
|
||||
%Docstring
|
||||
Draws the item's contents using the specified render ``context``.
|
||||
Draws the item's contents using the specified item render ``context``.
|
||||
|
||||
Note that the context's painter has been scaled so that painter units are pixels.
|
||||
Use the QgsRenderContext methods to convert from millimeters or other units to the painter's units.
|
||||
%End
|
||||
|
@ -73,7 +73,7 @@ Returns a list of items contained by the group.
|
||||
|
||||
|
||||
protected:
|
||||
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
|
||||
virtual void draw( QgsLayoutItemRenderContext &context );
|
||||
|
||||
virtual bool writePropertiesToElement( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const;
|
||||
|
||||
|
@ -222,8 +222,8 @@ Returns whether user stylesheets are enabled for the HTML content.
|
||||
|
||||
virtual QSizeF totalSize() const;
|
||||
|
||||
virtual void render( QgsRenderContext &context, const QRectF &renderExtent, int frameIndex,
|
||||
const QStyleOptionGraphicsItem *itemStyle = 0 );
|
||||
virtual void render( QgsLayoutItemRenderContext &context, const QRectF &renderExtent, int frameIndex );
|
||||
|
||||
|
||||
virtual double findNearbyPageBreak( double yPos );
|
||||
|
||||
|
@ -233,7 +233,7 @@ Returns the label font color.
|
||||
|
||||
|
||||
protected:
|
||||
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
|
||||
virtual void draw( QgsLayoutItemRenderContext &context );
|
||||
|
||||
virtual bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const;
|
||||
|
||||
|
@ -495,7 +495,7 @@ Returns the legend's renderer settings object.
|
||||
|
||||
|
||||
protected:
|
||||
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
|
||||
virtual void draw( QgsLayoutItemRenderContext &context );
|
||||
|
||||
virtual bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const;
|
||||
|
||||
|
@ -472,7 +472,7 @@ will be calculated. This can be expensive to calculate, so if they are not requi
|
||||
|
||||
protected:
|
||||
|
||||
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
|
||||
virtual void draw( QgsLayoutItemRenderContext &context );
|
||||
|
||||
virtual bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const;
|
||||
|
||||
|
@ -125,7 +125,7 @@ Constructor for QgsLayoutNodesItem, attached to the specified ``layout``.
|
||||
Constructor for a QgsLayoutNodesItem with the given ``polygon`` nodes, attached to the specified ``layout``.
|
||||
%End
|
||||
|
||||
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
|
||||
virtual void draw( QgsLayoutItemRenderContext &context );
|
||||
|
||||
|
||||
virtual bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const;
|
||||
@ -145,7 +145,7 @@ Method called in addNode.
|
||||
Method called in removeNode.
|
||||
%End
|
||||
|
||||
virtual void _draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 ) = 0;
|
||||
virtual void _draw( QgsLayoutItemRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 ) = 0;
|
||||
%Docstring
|
||||
Method called in paint.
|
||||
%End
|
||||
|
@ -105,7 +105,7 @@ page orientation.
|
||||
|
||||
protected:
|
||||
|
||||
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
|
||||
virtual void draw( QgsLayoutItemRenderContext &context );
|
||||
|
||||
virtual void drawFrame( QgsRenderContext &context );
|
||||
|
||||
|
@ -299,7 +299,7 @@ Is emitted on picture rotation change
|
||||
|
||||
protected:
|
||||
|
||||
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
|
||||
virtual void draw( QgsLayoutItemRenderContext &context );
|
||||
|
||||
virtual QSizeF applyItemSizeConstraint( const QSizeF &targetSize );
|
||||
|
||||
|
@ -68,7 +68,7 @@ Ownership of ``symbol`` is not transferred.
|
||||
|
||||
virtual bool _removeNode( const int nodeIndex );
|
||||
|
||||
virtual void _draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
|
||||
virtual void _draw( QgsLayoutItemRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
|
||||
|
||||
virtual void _readXmlStyle( const QDomElement &elmt, const QgsReadWriteContext &context );
|
||||
|
||||
|
@ -215,7 +215,7 @@ Returns the pen width in millimeters for the stroke of the arrow head.
|
||||
|
||||
virtual bool _removeNode( const int nodeIndex );
|
||||
|
||||
virtual void _draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
|
||||
virtual void _draw( QgsLayoutItemRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
|
||||
|
||||
virtual void _readXmlStyle( const QDomElement &elmt, const QgsReadWriteContext &context );
|
||||
|
||||
|
@ -491,7 +491,7 @@ Adjusts the scale bar box size and updates the item.
|
||||
|
||||
protected:
|
||||
|
||||
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
|
||||
virtual void draw( QgsLayoutItemRenderContext &context );
|
||||
|
||||
virtual bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const;
|
||||
|
||||
|
@ -101,7 +101,7 @@ Returns the corner radius for rounded rectangle corners.
|
||||
|
||||
protected:
|
||||
|
||||
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
|
||||
virtual void draw( QgsLayoutItemRenderContext &context );
|
||||
|
||||
|
||||
virtual bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const;
|
||||
|
@ -144,15 +144,13 @@ the frame size has no minimum in that direction.
|
||||
.. seealso:: :py:func:`recalculateFrameRects`
|
||||
%End
|
||||
|
||||
virtual void render( QgsRenderContext &context, const QRectF &renderExtent, int frameIndex,
|
||||
const QStyleOptionGraphicsItem *itemStyle = 0 ) = 0;
|
||||
virtual void render( QgsLayoutItemRenderContext &context, const QRectF &renderExtent, int frameIndex ) = 0;
|
||||
%Docstring
|
||||
Renders a portion of the multiframe's content into a render ``context``.
|
||||
|
||||
:param context: destination render painter
|
||||
:param renderExtent: visible extent of content to render into the painter.
|
||||
:param frameIndex: frame number for content
|
||||
:param itemStyle: item style options for graphics item rendering
|
||||
%End
|
||||
|
||||
virtual void addFrame( QgsLayoutFrame *frame /Transfer/, bool recalcFrameSizes = true );
|
||||
|
@ -515,8 +515,8 @@ Returns the current contents of the table. Excludes header cells.
|
||||
|
||||
virtual QSizeF totalSize() const;
|
||||
|
||||
virtual void render( QgsRenderContext &context, const QRectF &renderExtent, int frameIndex,
|
||||
const QStyleOptionGraphicsItem *itemStyle = 0 );
|
||||
virtual void render( QgsLayoutItemRenderContext &context, const QRectF &renderExtent, int frameIndex );
|
||||
|
||||
|
||||
public slots:
|
||||
|
||||
|
@ -413,6 +413,10 @@ Constructor for QgsSymbolRenderContext
|
||||
|
||||
|
||||
QgsRenderContext &renderContext();
|
||||
%Docstring
|
||||
Returns a reference to the context's render context.
|
||||
%End
|
||||
|
||||
|
||||
void setOriginalValueVariable( const QVariant &value );
|
||||
%Docstring
|
||||
|
@ -157,14 +157,14 @@ void QgsLayoutFrame::cleanup()
|
||||
QgsLayoutItem::cleanup();
|
||||
}
|
||||
|
||||
void QgsLayoutFrame::draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle )
|
||||
void QgsLayoutFrame::draw( QgsLayoutItemRenderContext &context )
|
||||
{
|
||||
if ( mMultiFrame )
|
||||
{
|
||||
//calculate index of frame
|
||||
int frameIndex = mMultiFrame->frameIndex( this );
|
||||
Q_ASSERT_X( frameIndex >= 0, "QgsLayoutFrame::draw", "Invalid frame index for frame" );
|
||||
mMultiFrame->render( context, mSection, frameIndex, itemStyle );
|
||||
mMultiFrame->render( context, mSection, frameIndex );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ class CORE_EXPORT QgsLayoutFrame: public QgsLayoutItem
|
||||
|
||||
protected:
|
||||
|
||||
void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
|
||||
void draw( QgsLayoutItemRenderContext &context ) override;
|
||||
void drawFrame( QgsRenderContext &context ) override;
|
||||
void drawBackground( QgsRenderContext &context ) override;
|
||||
bool writePropertiesToElement( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const override;
|
||||
|
@ -33,6 +33,14 @@
|
||||
|
||||
#define CACHE_SIZE_LIMIT 5000
|
||||
|
||||
QgsLayoutItemRenderContext::QgsLayoutItemRenderContext( QgsRenderContext &context, double viewScaleFactor )
|
||||
: mRenderContext( context )
|
||||
, mViewScaleFactor( viewScaleFactor )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
QgsLayoutItem::QgsLayoutItem( QgsLayout *layout, bool manageZValue )
|
||||
: QgsLayoutObject( layout )
|
||||
, QGraphicsRectItem( nullptr )
|
||||
@ -312,7 +320,9 @@ void QgsLayoutItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *it
|
||||
// need to translate so that item origin is at 0,0 in painter coordinates (not bounding rect origin)
|
||||
p.translate( -boundingRect().x() * context.scaleFactor(), -boundingRect().y() * context.scaleFactor() );
|
||||
drawBackground( context );
|
||||
draw( context, itemStyle );
|
||||
double viewScale = QgsLayoutUtils::scaleFactorFromItemStyle( itemStyle );
|
||||
QgsLayoutItemRenderContext itemRenderContext( context, viewScale );
|
||||
draw( itemRenderContext );
|
||||
drawFrame( context );
|
||||
p.end();
|
||||
|
||||
@ -341,7 +351,9 @@ void QgsLayoutItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *it
|
||||
|
||||
// scale painter from mm to dots
|
||||
painter->scale( 1.0 / context.scaleFactor(), 1.0 / context.scaleFactor() );
|
||||
draw( context, itemStyle );
|
||||
double viewScale = QgsLayoutUtils::scaleFactorFromItemStyle( itemStyle );
|
||||
QgsLayoutItemRenderContext itemRenderContext( context, viewScale );
|
||||
draw( itemRenderContext );
|
||||
|
||||
painter->scale( context.scaleFactor(), context.scaleFactor() );
|
||||
drawFrame( context );
|
||||
@ -1427,3 +1439,4 @@ void QgsLayoutItem::refreshBlendMode()
|
||||
// Update the item effect to use the new blend mode
|
||||
mEffect->setCompositionMode( blendMode );
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,76 @@ class QPainter;
|
||||
class QgsLayoutItemGroup;
|
||||
class QgsLayoutEffect;
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup core
|
||||
* \class QgsLayoutItemRenderContext
|
||||
* Contains settings and helpers relating to a render of a QgsLayoutItem.
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
class CORE_EXPORT QgsLayoutItemRenderContext
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for QgsLayoutItemRenderContext.
|
||||
*
|
||||
* The \a renderContext parameter specifies a QgsRenderContext for use within
|
||||
* the QgsLayoutItemRenderContext.
|
||||
*
|
||||
* The \a viewScaleFactor gives the current view zoom (scale factor). It can be
|
||||
* used to scale render graphics so that they always appear a constant size,
|
||||
* regardless of the current view zoom.
|
||||
*/
|
||||
QgsLayoutItemRenderContext( QgsRenderContext &context, double viewScaleFactor = 1.0 );
|
||||
|
||||
//! QgsLayoutItemRenderContext cannot be copied.
|
||||
QgsLayoutItemRenderContext( const QgsLayoutItemRenderContext &other ) = delete;
|
||||
|
||||
//! QgsLayoutItemRenderContext cannot be copied.
|
||||
QgsLayoutItemRenderContext &operator=( const QgsLayoutItemRenderContext &other ) = delete;
|
||||
|
||||
/**
|
||||
* Returns a reference to the context's render context.
|
||||
*
|
||||
* Note that the context's painter has been scaled so that painter units are pixels.
|
||||
* Use the QgsRenderContext methods to convert from millimeters or other units to the painter's units.
|
||||
*/
|
||||
QgsRenderContext &renderContext() { return mRenderContext; }
|
||||
|
||||
/**
|
||||
* Returns a reference to the context's render context.
|
||||
*
|
||||
* Note that the context's painter has been scaled so that painter units are pixels.
|
||||
* Use the QgsRenderContext methods to convert from millimeters or other units to the painter's units.
|
||||
*
|
||||
* \note Not available in Python bindings.
|
||||
*/
|
||||
const QgsRenderContext &renderContext() const { return mRenderContext; } SIP_SKIP
|
||||
|
||||
/**
|
||||
* Returns the current view zoom (scale factor). It can be
|
||||
* used to scale render graphics so that they always appear a constant size,
|
||||
* regardless of the current view zoom.
|
||||
*
|
||||
* E.g. a value of 0.5 indicates that the view is zoomed out to 50% size, so rendered
|
||||
* items must be scaled by 200% in order to have a constant visible size. A value
|
||||
* of 2.0 indicates that the view is zoomed in 200%, so rendered items must be
|
||||
* scaled by 50% in order to have a constant visible size.
|
||||
*/
|
||||
double viewScaleFactor() const { return mViewScaleFactor; }
|
||||
|
||||
private:
|
||||
|
||||
#ifdef SIP_RUN
|
||||
QgsLayoutItemRenderContext( const QgsLayoutItemRenderContext &rh ) SIP_FORCE;
|
||||
#endif
|
||||
|
||||
QgsRenderContext &mRenderContext;
|
||||
double mViewScaleFactor = 1.0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup core
|
||||
* \class QgsLayoutItem
|
||||
@ -845,11 +915,12 @@ class CORE_EXPORT QgsLayoutItem : public QgsLayoutObject, public QGraphicsRectIt
|
||||
virtual void drawDebugRect( QPainter *painter );
|
||||
|
||||
/**
|
||||
* Draws the item's contents using the specified render \a context.
|
||||
* Draws the item's contents using the specified item render \a context.
|
||||
*
|
||||
* Note that the context's painter has been scaled so that painter units are pixels.
|
||||
* Use the QgsRenderContext methods to convert from millimeters or other units to the painter's units.
|
||||
*/
|
||||
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) = 0;
|
||||
virtual void draw( QgsLayoutItemRenderContext &context ) = 0;
|
||||
|
||||
/**
|
||||
* Draws the frame around the item.
|
||||
|
@ -276,7 +276,7 @@ void QgsLayoutItemGroup::paint( QPainter *, const QStyleOptionGraphicsItem *, QW
|
||||
{
|
||||
}
|
||||
|
||||
void QgsLayoutItemGroup::draw( QgsRenderContext &, const QStyleOptionGraphicsItem * )
|
||||
void QgsLayoutItemGroup::draw( QgsLayoutItemRenderContext & )
|
||||
{
|
||||
// nothing to draw here!
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ class CORE_EXPORT QgsLayoutItemGroup: public QgsLayoutItem
|
||||
void finalizeRestoreFromXml() override;
|
||||
|
||||
protected:
|
||||
void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
|
||||
void draw( QgsLayoutItemRenderContext &context ) override;
|
||||
bool writePropertiesToElement( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const override;
|
||||
bool readPropertiesFromElement( const QDomElement &itemElement, const QDomDocument &document, const QgsReadWriteContext &context ) override;
|
||||
|
||||
|
@ -279,16 +279,15 @@ QSizeF QgsLayoutItemHtml::totalSize() const
|
||||
return mSize;
|
||||
}
|
||||
|
||||
void QgsLayoutItemHtml::render( QgsRenderContext &context, const QRectF &renderExtent, const int,
|
||||
const QStyleOptionGraphicsItem * )
|
||||
void QgsLayoutItemHtml::render( QgsLayoutItemRenderContext &context, const QRectF &renderExtent, const int )
|
||||
{
|
||||
if ( !mWebPage )
|
||||
return;
|
||||
|
||||
QPainter *painter = context.painter();
|
||||
QPainter *painter = context.renderContext().painter();
|
||||
painter->save();
|
||||
// painter is scaled to dots, so scale back to layout units
|
||||
painter->scale( context.scaleFactor() / mHtmlUnitsToLayoutUnits, context.scaleFactor() / mHtmlUnitsToLayoutUnits );
|
||||
painter->scale( context.renderContext().scaleFactor() / mHtmlUnitsToLayoutUnits, context.renderContext().scaleFactor() / mHtmlUnitsToLayoutUnits );
|
||||
painter->translate( 0.0, -renderExtent.top() * mHtmlUnitsToLayoutUnits );
|
||||
mWebPage->mainFrame()->render( painter, QRegion( renderExtent.left(), renderExtent.top() * mHtmlUnitsToLayoutUnits, renderExtent.width() * mHtmlUnitsToLayoutUnits, renderExtent.height() * mHtmlUnitsToLayoutUnits ) );
|
||||
painter->restore();
|
||||
|
@ -204,8 +204,7 @@ class CORE_EXPORT QgsLayoutItemHtml: public QgsLayoutMultiFrame
|
||||
|
||||
QString displayName() const override;
|
||||
QSizeF totalSize() const override;
|
||||
void render( QgsRenderContext &context, const QRectF &renderExtent, int frameIndex,
|
||||
const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
|
||||
void render( QgsLayoutItemRenderContext &context, const QRectF &renderExtent, int frameIndex ) override;
|
||||
|
||||
//overridden to break frames without dividing lines of text
|
||||
double findNearbyPageBreak( double yPos ) override;
|
||||
|
@ -97,13 +97,13 @@ QIcon QgsLayoutItemLabel::icon() const
|
||||
return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItemLabel.svg" ) );
|
||||
}
|
||||
|
||||
void QgsLayoutItemLabel::draw( QgsRenderContext &context, const QStyleOptionGraphicsItem * )
|
||||
void QgsLayoutItemLabel::draw( QgsLayoutItemRenderContext &context )
|
||||
{
|
||||
QPainter *painter = context.painter();
|
||||
QPainter *painter = context.renderContext().painter();
|
||||
painter->save();
|
||||
|
||||
// painter is scaled to dots, so scale back to layout units
|
||||
painter->scale( context.scaleFactor(), context.scaleFactor() );
|
||||
painter->scale( context.renderContext().scaleFactor(), context.renderContext().scaleFactor() );
|
||||
|
||||
double penWidth = frameEnabled() ? ( pen().widthF() / 2.0 ) : 0;
|
||||
double xPenAdjust = mMarginX < 0 ? -penWidth : penWidth;
|
||||
|
@ -218,7 +218,7 @@ class CORE_EXPORT QgsLayoutItemLabel: public QgsLayoutItem
|
||||
void refresh() override;
|
||||
|
||||
protected:
|
||||
void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
|
||||
void draw( QgsLayoutItemRenderContext &context ) override;
|
||||
bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
|
||||
bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
|
||||
|
||||
|
@ -138,13 +138,13 @@ void QgsLayoutItemLegend::refresh()
|
||||
onAtlasFeature();
|
||||
}
|
||||
|
||||
void QgsLayoutItemLegend::draw( QgsRenderContext &context, const QStyleOptionGraphicsItem * )
|
||||
void QgsLayoutItemLegend::draw( QgsLayoutItemRenderContext &context )
|
||||
{
|
||||
QPainter *painter = context.painter();
|
||||
QPainter *painter = context.renderContext().painter();
|
||||
painter->save();
|
||||
|
||||
// painter is scaled to dots, so scale back to layout units
|
||||
painter->scale( context.scaleFactor(), context.scaleFactor() );
|
||||
painter->scale( context.renderContext().scaleFactor(), context.renderContext().scaleFactor() );
|
||||
|
||||
painter->setPen( QPen( QColor( 0, 0, 0 ) ) );
|
||||
|
||||
|
@ -442,7 +442,7 @@ class CORE_EXPORT QgsLayoutItemLegend : public QgsLayoutItem
|
||||
void refreshDataDefinedProperty( const QgsLayoutObject::DataDefinedProperty property = QgsLayoutObject::AllProperties ) override;
|
||||
|
||||
protected:
|
||||
void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
|
||||
void draw( QgsLayoutItemRenderContext &context ) override;
|
||||
bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
|
||||
bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
|
||||
|
||||
|
@ -509,7 +509,7 @@ QgsLayoutItemMapOverview *QgsLayoutItemMap::overview()
|
||||
return mOverviewStack->overview( 0 );
|
||||
}
|
||||
|
||||
void QgsLayoutItemMap::draw( QgsRenderContext &, const QStyleOptionGraphicsItem * )
|
||||
void QgsLayoutItemMap::draw( QgsLayoutItemRenderContext & )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -419,7 +419,7 @@ class CORE_EXPORT QgsLayoutItemMap : public QgsLayoutItem
|
||||
|
||||
protected:
|
||||
|
||||
void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
|
||||
void draw( QgsLayoutItemRenderContext &context ) override;
|
||||
bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
|
||||
bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
|
||||
|
||||
|
@ -70,18 +70,18 @@ void QgsLayoutNodesItem::init()
|
||||
connect( this, &QgsLayoutNodesItem::sizePositionChanged, this, &QgsLayoutNodesItem::updateBoundingRect );
|
||||
}
|
||||
|
||||
void QgsLayoutNodesItem::draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *style )
|
||||
void QgsLayoutNodesItem::draw( QgsLayoutItemRenderContext &context )
|
||||
{
|
||||
QPainter *painter = context.painter();
|
||||
QPainter *painter = context.renderContext().painter();
|
||||
painter->setPen( Qt::NoPen );
|
||||
painter->setBrush( Qt::NoBrush );
|
||||
|
||||
context.setForceVectorOutput( true );
|
||||
context.renderContext().setForceVectorOutput( true );
|
||||
rescaleToFitBoundingBox();
|
||||
_draw( context );
|
||||
|
||||
if ( mDrawNodes && layout()->renderContext().isPreviewRender() )
|
||||
drawNodes( context, style );
|
||||
drawNodes( context );
|
||||
}
|
||||
|
||||
double QgsLayoutNodesItem::computeDistance( QPointF pt1,
|
||||
@ -161,11 +161,11 @@ bool QgsLayoutNodesItem::addNode( QPointF pt,
|
||||
return rc;
|
||||
}
|
||||
|
||||
void QgsLayoutNodesItem::drawNodes( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle ) const
|
||||
void QgsLayoutNodesItem::drawNodes( QgsLayoutItemRenderContext &context ) const
|
||||
{
|
||||
context.painter()->setRenderHint( QPainter::Antialiasing, false );
|
||||
context.renderContext().painter()->setRenderHint( QPainter::Antialiasing, false );
|
||||
|
||||
double rectSize = 9.0 / QgsLayoutUtils::scaleFactorFromItemStyle( itemStyle );
|
||||
double rectSize = 9.0 / context.viewScaleFactor();
|
||||
|
||||
QgsStringMap properties;
|
||||
properties.insert( QStringLiteral( "name" ), QStringLiteral( "cross" ) );
|
||||
@ -176,18 +176,18 @@ void QgsLayoutNodesItem::drawNodes( QgsRenderContext &context, const QStyleOptio
|
||||
symbol->setSize( rectSize );
|
||||
symbol->setAngle( 45 );
|
||||
|
||||
symbol->startRender( context );
|
||||
symbol->startRender( context.renderContext() );
|
||||
for ( QPointF pt : mPolygon )
|
||||
symbol->renderPoint( pt * QgsLayoutUtils::scaleFactorFromItemStyle( itemStyle ), nullptr, context );
|
||||
symbol->stopRender( context );
|
||||
symbol->renderPoint( pt * context.viewScaleFactor(), nullptr, context.renderContext() );
|
||||
symbol->stopRender( context.renderContext() );
|
||||
|
||||
if ( mSelectedNode >= 0 && mSelectedNode < mPolygon.size() )
|
||||
drawSelectedNode( context, itemStyle );
|
||||
drawSelectedNode( context );
|
||||
}
|
||||
|
||||
void QgsLayoutNodesItem::drawSelectedNode( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle ) const
|
||||
void QgsLayoutNodesItem::drawSelectedNode( QgsLayoutItemRenderContext &context ) const
|
||||
{
|
||||
double rectSize = 9.0 / QgsLayoutUtils::scaleFactorFromItemStyle( itemStyle );
|
||||
double rectSize = 9.0 / context.viewScaleFactor();
|
||||
|
||||
QgsStringMap properties;
|
||||
properties.insert( QStringLiteral( "name" ), QStringLiteral( "square" ) );
|
||||
@ -199,9 +199,9 @@ void QgsLayoutNodesItem::drawSelectedNode( QgsRenderContext &context, const QSty
|
||||
symbol.reset( QgsMarkerSymbol::createSimple( properties ) );
|
||||
symbol->setSize( rectSize );
|
||||
|
||||
symbol->startRender( context );
|
||||
symbol->renderPoint( mPolygon.at( mSelectedNode ) * QgsLayoutUtils::scaleFactorFromItemStyle( itemStyle ), nullptr, context );
|
||||
symbol->stopRender( context );
|
||||
symbol->startRender( context.renderContext() );
|
||||
symbol->renderPoint( mPolygon.at( mSelectedNode ) * context.viewScaleFactor(), nullptr, context.renderContext() );
|
||||
symbol->stopRender( context.renderContext() );
|
||||
}
|
||||
|
||||
int QgsLayoutNodesItem::nodeAtPosition( QPointF node,
|
||||
|
@ -126,7 +126,7 @@ class CORE_EXPORT QgsLayoutNodesItem: public QgsLayoutItem
|
||||
*/
|
||||
QgsLayoutNodesItem( const QPolygonF &polygon, QgsLayout *layout );
|
||||
|
||||
void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
|
||||
void draw( QgsLayoutItemRenderContext &context ) override;
|
||||
|
||||
bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
|
||||
bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
|
||||
@ -144,7 +144,7 @@ class CORE_EXPORT QgsLayoutNodesItem: public QgsLayoutItem
|
||||
virtual bool _removeNode( const int nodeIndex ) = 0;
|
||||
|
||||
//! Method called in paint.
|
||||
virtual void _draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) = 0;
|
||||
virtual void _draw( QgsLayoutItemRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) = 0;
|
||||
|
||||
//! Method called in readXml.
|
||||
virtual void _readXmlStyle( const QDomElement &elmt, const QgsReadWriteContext &context ) = 0;
|
||||
@ -188,8 +188,8 @@ class CORE_EXPORT QgsLayoutNodesItem: public QgsLayoutItem
|
||||
bool mDrawNodes = false;
|
||||
|
||||
//! Draw nodes
|
||||
void drawNodes( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) const;
|
||||
void drawSelectedNode( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) const;
|
||||
void drawNodes( QgsLayoutItemRenderContext &context ) const;
|
||||
void drawSelectedNode( QgsLayoutItemRenderContext &context ) const;
|
||||
|
||||
};
|
||||
|
||||
|
@ -181,19 +181,19 @@ void QgsLayoutItemPage::redraw()
|
||||
mGrid->update();
|
||||
}
|
||||
|
||||
void QgsLayoutItemPage::draw( QgsRenderContext &context, const QStyleOptionGraphicsItem * )
|
||||
void QgsLayoutItemPage::draw( QgsLayoutItemRenderContext &context )
|
||||
{
|
||||
if ( !context.painter() || !mLayout || !mLayout->renderContext().pagesVisible() )
|
||||
if ( !context.renderContext().painter() || !mLayout || !mLayout->renderContext().pagesVisible() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
double scale = context.convertToPainterUnits( 1, QgsUnitTypes::RenderMillimeters );
|
||||
double scale = context.renderContext().convertToPainterUnits( 1, QgsUnitTypes::RenderMillimeters );
|
||||
|
||||
QgsExpressionContext expressionContext = createExpressionContext();
|
||||
context.setExpressionContext( expressionContext );
|
||||
context.renderContext().setExpressionContext( expressionContext );
|
||||
|
||||
QPainter *painter = context.painter();
|
||||
QPainter *painter = context.renderContext().painter();
|
||||
painter->save();
|
||||
|
||||
if ( mLayout->renderContext().isPreviewRender() )
|
||||
@ -220,10 +220,10 @@ void QgsLayoutItemPage::draw( QgsRenderContext &context, const QStyleOptionGraph
|
||||
}
|
||||
|
||||
std::unique_ptr< QgsFillSymbol > symbol( mLayout->pageCollection()->pageStyleSymbol()->clone() );
|
||||
symbol->startRender( context );
|
||||
symbol->startRender( context.renderContext() );
|
||||
|
||||
//get max bleed from symbol
|
||||
double maxBleedPixels = QgsSymbolLayerUtils::estimateMaxSymbolBleed( symbol.get(), context );
|
||||
double maxBleedPixels = QgsSymbolLayerUtils::estimateMaxSymbolBleed( symbol.get(), context.renderContext() );
|
||||
|
||||
//Now subtract 1 pixel to prevent semi-transparent borders at edge of solid page caused by
|
||||
//anti-aliased painting. This may cause a pixel to be cropped from certain edge lines/symbols,
|
||||
@ -238,8 +238,8 @@ void QgsLayoutItemPage::draw( QgsRenderContext &context, const QStyleOptionGraph
|
||||
std::ceil( rect().width() * scale ) - 2 * maxBleedPixels, std::ceil( rect().height() * scale ) - 2 * maxBleedPixels ) );
|
||||
QList<QPolygonF> rings; //empty list
|
||||
|
||||
symbol->renderPolygon( pagePolygon, &rings, nullptr, context );
|
||||
symbol->stopRender( context );
|
||||
symbol->renderPolygon( pagePolygon, &rings, nullptr, context.renderContext() );
|
||||
symbol->stopRender( context.renderContext() );
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ class CORE_EXPORT QgsLayoutItemPage : public QgsLayoutItem
|
||||
|
||||
protected:
|
||||
|
||||
void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
|
||||
void draw( QgsLayoutItemRenderContext &context ) override;
|
||||
void drawFrame( QgsRenderContext &context ) override;
|
||||
void drawBackground( QgsRenderContext &context ) override;
|
||||
|
||||
|
@ -80,12 +80,12 @@ QgsLayoutItemPicture *QgsLayoutItemPicture::create( QgsLayout *layout )
|
||||
return new QgsLayoutItemPicture( layout );
|
||||
}
|
||||
|
||||
void QgsLayoutItemPicture::draw( QgsRenderContext &context, const QStyleOptionGraphicsItem * )
|
||||
void QgsLayoutItemPicture::draw( QgsLayoutItemRenderContext &context )
|
||||
{
|
||||
QPainter *painter = context.painter();
|
||||
QPainter *painter = context.renderContext().painter();
|
||||
painter->save();
|
||||
// painter is scaled to dots, so scale back to layout units
|
||||
painter->scale( context.scaleFactor(), context.scaleFactor() );
|
||||
painter->scale( context.renderContext().scaleFactor(), context.renderContext().scaleFactor() );
|
||||
|
||||
//picture resizing
|
||||
if ( mMode != FormatUnknown )
|
||||
|
@ -268,7 +268,7 @@ class CORE_EXPORT QgsLayoutItemPicture: public QgsLayoutItem
|
||||
|
||||
protected:
|
||||
|
||||
void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
|
||||
void draw( QgsLayoutItemRenderContext &context ) override;
|
||||
QSizeF applyItemSizeConstraint( const QSizeF &targetSize ) override;
|
||||
bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
|
||||
bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
|
||||
|
@ -97,20 +97,20 @@ QString QgsLayoutItemPolygon::displayName() const
|
||||
return tr( "<Polygon>" );
|
||||
}
|
||||
|
||||
void QgsLayoutItemPolygon::_draw( QgsRenderContext &context, const QStyleOptionGraphicsItem * )
|
||||
void QgsLayoutItemPolygon::_draw( QgsLayoutItemRenderContext &context, const QStyleOptionGraphicsItem * )
|
||||
{
|
||||
//setup painter scaling to dots so that raster symbology is drawn to scale
|
||||
double scale = context.convertToPainterUnits( 1, QgsUnitTypes::RenderMillimeters );
|
||||
double scale = context.renderContext().convertToPainterUnits( 1, QgsUnitTypes::RenderMillimeters );
|
||||
QTransform t = QTransform::fromScale( scale, scale );
|
||||
|
||||
QList<QPolygonF> rings; //empty
|
||||
QPainterPath polygonPath;
|
||||
polygonPath.addPolygon( mPolygon );
|
||||
|
||||
mPolygonStyleSymbol->startRender( context );
|
||||
mPolygonStyleSymbol->startRender( context.renderContext() );
|
||||
mPolygonStyleSymbol->renderPolygon( polygonPath.toFillPolygon( t ), &rings,
|
||||
nullptr, context );
|
||||
mPolygonStyleSymbol->stopRender( context );
|
||||
nullptr, context.renderContext() );
|
||||
mPolygonStyleSymbol->stopRender( context.renderContext() );
|
||||
}
|
||||
|
||||
void QgsLayoutItemPolygon::_readXmlStyle( const QDomElement &elmt, const QgsReadWriteContext &context )
|
||||
|
@ -71,7 +71,7 @@ class CORE_EXPORT QgsLayoutItemPolygon: public QgsLayoutNodesItem
|
||||
protected:
|
||||
bool _addNode( const int indexPoint, QPointF newPoint, const double radius ) override;
|
||||
bool _removeNode( const int nodeIndex ) override;
|
||||
void _draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
|
||||
void _draw( QgsLayoutItemRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
|
||||
void _readXmlStyle( const QDomElement &elmt, const QgsReadWriteContext &context ) override;
|
||||
void _writeXmlStyle( QDomDocument &doc, QDomElement &elmt, const QgsReadWriteContext &context ) const override;
|
||||
|
||||
|
@ -263,23 +263,23 @@ QString QgsLayoutItemPolyline::displayName() const
|
||||
return tr( "<Polyline>" );
|
||||
}
|
||||
|
||||
void QgsLayoutItemPolyline::_draw( QgsRenderContext &context, const QStyleOptionGraphicsItem * )
|
||||
void QgsLayoutItemPolyline::_draw( QgsLayoutItemRenderContext &context, const QStyleOptionGraphicsItem * )
|
||||
{
|
||||
context.painter()->save();
|
||||
context.renderContext().painter()->save();
|
||||
//setup painter scaling to dots so that raster symbology is drawn to scale
|
||||
double scale = context.convertToPainterUnits( 1, QgsUnitTypes::RenderMillimeters );
|
||||
double scale = context.renderContext().convertToPainterUnits( 1, QgsUnitTypes::RenderMillimeters );
|
||||
QTransform t = QTransform::fromScale( scale, scale );
|
||||
|
||||
mPolylineStyleSymbol->startRender( context );
|
||||
mPolylineStyleSymbol->renderPolyline( t.map( mPolygon ), nullptr, context );
|
||||
mPolylineStyleSymbol->stopRender( context );
|
||||
mPolylineStyleSymbol->startRender( context.renderContext() );
|
||||
mPolylineStyleSymbol->renderPolyline( t.map( mPolygon ), nullptr, context.renderContext() );
|
||||
mPolylineStyleSymbol->stopRender( context.renderContext() );
|
||||
|
||||
// painter is scaled to dots, so scale back to layout units
|
||||
context.painter()->scale( context.scaleFactor(), context.scaleFactor() );
|
||||
context.renderContext().painter()->scale( context.renderContext().scaleFactor(), context.renderContext().scaleFactor() );
|
||||
|
||||
drawStartMarker( context.painter() );
|
||||
drawEndMarker( context.painter() );
|
||||
context.painter()->restore();
|
||||
drawStartMarker( context.renderContext().painter() );
|
||||
drawEndMarker( context.renderContext().painter() );
|
||||
context.renderContext().painter()->restore();
|
||||
}
|
||||
|
||||
void QgsLayoutItemPolyline::_readXmlStyle( const QDomElement &elmt, const QgsReadWriteContext &context )
|
||||
|
@ -189,7 +189,7 @@ class CORE_EXPORT QgsLayoutItemPolyline: public QgsLayoutNodesItem
|
||||
|
||||
bool _addNode( const int indexPoint, QPointF newPoint, const double radius ) override;
|
||||
bool _removeNode( const int nodeIndex ) override;
|
||||
void _draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
|
||||
void _draw( QgsLayoutItemRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
|
||||
void _readXmlStyle( const QDomElement &elmt, const QgsReadWriteContext &context ) override;
|
||||
void _writeXmlStyle( QDomDocument &doc, QDomElement &elmt, const QgsReadWriteContext &context ) const override;
|
||||
bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
|
||||
|
@ -67,12 +67,12 @@ QgsLayoutSize QgsLayoutItemScaleBar::minimumSize() const
|
||||
return QgsLayoutSize( mStyle->calculateBoxSize( mSettings, createScaleContext() ), QgsUnitTypes::LayoutMillimeters );
|
||||
}
|
||||
|
||||
void QgsLayoutItemScaleBar::draw( QgsRenderContext &context, const QStyleOptionGraphicsItem * )
|
||||
void QgsLayoutItemScaleBar::draw( QgsLayoutItemRenderContext &context )
|
||||
{
|
||||
if ( !mStyle )
|
||||
return;
|
||||
|
||||
mStyle->draw( context, mSettings, createScaleContext() );
|
||||
mStyle->draw( context.renderContext(), mSettings, createScaleContext() );
|
||||
}
|
||||
|
||||
void QgsLayoutItemScaleBar::setNumberOfSegments( int nSegments )
|
||||
|
@ -425,7 +425,7 @@ class CORE_EXPORT QgsLayoutItemScaleBar: public QgsLayoutItem
|
||||
void finalizeRestoreFromXml() override;
|
||||
protected:
|
||||
|
||||
void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
|
||||
void draw( QgsLayoutItemRenderContext &context ) override;
|
||||
bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
|
||||
bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
|
||||
|
||||
|
@ -150,13 +150,13 @@ double QgsLayoutItemShape::estimatedFrameBleed() const
|
||||
return mMaxSymbolBleed;
|
||||
}
|
||||
|
||||
void QgsLayoutItemShape::draw( QgsRenderContext &context, const QStyleOptionGraphicsItem * )
|
||||
void QgsLayoutItemShape::draw( QgsLayoutItemRenderContext &context )
|
||||
{
|
||||
QPainter *painter = context.painter();
|
||||
QPainter *painter = context.renderContext().painter();
|
||||
painter->setPen( Qt::NoPen );
|
||||
painter->setBrush( Qt::NoBrush );
|
||||
|
||||
double scale = context.convertToPainterUnits( 1, QgsUnitTypes::RenderMillimeters );
|
||||
double scale = context.renderContext().convertToPainterUnits( 1, QgsUnitTypes::RenderMillimeters );
|
||||
|
||||
QPolygonF shapePolygon;
|
||||
|
||||
@ -206,9 +206,9 @@ void QgsLayoutItemShape::draw( QgsRenderContext &context, const QStyleOptionGrap
|
||||
|
||||
QList<QPolygonF> rings; //empty list
|
||||
|
||||
symbol()->startRender( context );
|
||||
symbol()->renderPolygon( shapePolygon, &rings, nullptr, context );
|
||||
symbol()->stopRender( context );
|
||||
symbol()->startRender( context.renderContext() );
|
||||
symbol()->renderPolygon( shapePolygon, &rings, nullptr, context.renderContext() );
|
||||
symbol()->stopRender( context.renderContext() );
|
||||
}
|
||||
|
||||
bool QgsLayoutItemShape::writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const
|
||||
|
@ -109,7 +109,7 @@ class CORE_EXPORT QgsLayoutItemShape : public QgsLayoutItem
|
||||
|
||||
protected:
|
||||
|
||||
void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
|
||||
void draw( QgsLayoutItemRenderContext &context ) override;
|
||||
|
||||
bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
|
||||
bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
|
||||
|
@ -34,6 +34,7 @@ class QRectF;
|
||||
class QPainter;
|
||||
class QStyleOptionGraphicsItem;
|
||||
class QgsRenderContext;
|
||||
class QgsLayoutItemRenderContext;
|
||||
|
||||
/**
|
||||
* \ingroup core
|
||||
@ -175,10 +176,8 @@ class CORE_EXPORT QgsLayoutMultiFrame: public QgsLayoutObject, public QgsLayoutU
|
||||
* \param context destination render painter
|
||||
* \param renderExtent visible extent of content to render into the painter.
|
||||
* \param frameIndex frame number for content
|
||||
* \param itemStyle item style options for graphics item rendering
|
||||
*/
|
||||
virtual void render( QgsRenderContext &context, const QRectF &renderExtent, int frameIndex,
|
||||
const QStyleOptionGraphicsItem *itemStyle = nullptr ) = 0;
|
||||
virtual void render( QgsLayoutItemRenderContext &context, const QRectF &renderExtent, int frameIndex ) = 0;
|
||||
|
||||
/**
|
||||
* Adds a \a frame to the multiframe.
|
||||
|
@ -279,8 +279,7 @@ QPair<int, int> QgsLayoutTable::rowRange( const int frameIndex ) const
|
||||
return qMakePair( firstVisible, lastVisible );
|
||||
}
|
||||
|
||||
void QgsLayoutTable::render( QgsRenderContext &context, const QRectF &, const int frameIndex,
|
||||
const QStyleOptionGraphicsItem * )
|
||||
void QgsLayoutTable::render( QgsLayoutItemRenderContext &context, const QRectF &, const int frameIndex )
|
||||
{
|
||||
bool emptyTable = mTableContents.length() == 0;
|
||||
if ( emptyTable && mEmptyTableMode == QgsLayoutTable::HideTable )
|
||||
@ -327,10 +326,10 @@ void QgsLayoutTable::render( QgsRenderContext &context, const QRectF &, const in
|
||||
mergeCells = true;
|
||||
}
|
||||
|
||||
QPainter *p = context.painter();
|
||||
QPainter *p = context.renderContext().painter();
|
||||
p->save();
|
||||
// painter is scaled to dots, so scale back to layout units
|
||||
p->scale( context.scaleFactor(), context.scaleFactor() );
|
||||
p->scale( context.renderContext().scaleFactor(), context.renderContext().scaleFactor() );
|
||||
|
||||
//draw the text
|
||||
p->setPen( Qt::SolidLine );
|
||||
|
@ -477,8 +477,7 @@ class CORE_EXPORT QgsLayoutTable: public QgsLayoutMultiFrame
|
||||
bool writePropertiesToElement( QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
|
||||
bool readPropertiesFromElement( const QDomElement &itemElem, const QDomDocument &doc, const QgsReadWriteContext &context ) override;
|
||||
QSizeF totalSize() const override;
|
||||
void render( QgsRenderContext &context, const QRectF &renderExtent, int frameIndex,
|
||||
const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
|
||||
void render( QgsLayoutItemRenderContext &context, const QRectF &renderExtent, int frameIndex ) override;
|
||||
|
||||
public slots:
|
||||
|
||||
|
@ -447,7 +447,15 @@ class CORE_EXPORT QgsSymbolRenderContext
|
||||
//! QgsSymbolRenderContext cannot be copied.
|
||||
QgsSymbolRenderContext( const QgsSymbolRenderContext &rh ) = delete;
|
||||
|
||||
/**
|
||||
* Returns a reference to the context's render context.
|
||||
*/
|
||||
QgsRenderContext &renderContext() { return mRenderContext; }
|
||||
|
||||
/**
|
||||
* Returns a reference to the context's render context.
|
||||
* \note Not available in Python bindings.
|
||||
*/
|
||||
const QgsRenderContext &renderContext() const { return mRenderContext; } SIP_SKIP
|
||||
|
||||
/**
|
||||
|
@ -150,7 +150,7 @@ void QgsResidualPlotItem::paint( QPainter *painter, const QStyleOptionGraphicsIt
|
||||
}
|
||||
}
|
||||
|
||||
void QgsResidualPlotItem::draw( QgsRenderContext &, const QStyleOptionGraphicsItem * )
|
||||
void QgsResidualPlotItem::draw( QgsLayoutItemRenderContext & )
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class QgsResidualPlotItem: public QgsLayoutItem
|
||||
void setConvertScaleToMapUnits( bool convert ) { mConvertScaleToMapUnits = convert; }
|
||||
bool convertScaleToMapUnits() const { return mConvertScaleToMapUnits; }
|
||||
|
||||
void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
|
||||
void draw( QgsLayoutItemRenderContext &context ) override;
|
||||
private:
|
||||
//gcp list
|
||||
QgsGCPList mGCPList;
|
||||
|
@ -54,9 +54,9 @@ class TestItem : public QgsLayoutItem
|
||||
bool forceResize = false;
|
||||
|
||||
protected:
|
||||
void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem * = nullptr ) override
|
||||
void draw( QgsLayoutItemRenderContext &context ) override
|
||||
{
|
||||
QPainter *painter = context.painter();
|
||||
QPainter *painter = context.renderContext().painter();
|
||||
painter->save();
|
||||
painter->setRenderHint( QPainter::Antialiasing, false );
|
||||
painter->setPen( Qt::NoPen );
|
||||
|
@ -74,8 +74,7 @@ class TestMultiFrame : public QgsLayoutMultiFrame
|
||||
return QgsLayoutItemRegistry::PluginItem + 1;
|
||||
}
|
||||
|
||||
void render( QgsRenderContext &, const QRectF &, int,
|
||||
const QStyleOptionGraphicsItem * ) override
|
||||
void render( QgsLayoutItemRenderContext &, const QRectF &, int ) override
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ class TestItem : public QgsLayoutItem
|
||||
|
||||
//implement pure virtual methods
|
||||
int type() const override { return QgsLayoutItemRegistry::LayoutItem + 101; }
|
||||
void draw( QgsRenderContext &, const QStyleOptionGraphicsItem * = nullptr ) override
|
||||
void draw( QgsLayoutItemRenderContext & ) override
|
||||
{ }
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user