mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -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:
|
protected:
|
||||||
|
|
||||||
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
|
virtual void draw( QgsLayoutItemRenderContext &context );
|
||||||
|
|
||||||
virtual void drawFrame( QgsRenderContext &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
|
class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem, QgsLayoutUndoObjectInterface
|
||||||
{
|
{
|
||||||
%Docstring
|
%Docstring
|
||||||
Base class for graphical items within a QgsLayout.
|
Base class for graphical items within a :py:class:`QgsLayout`.
|
||||||
|
|
||||||
.. versionadded:: 3.0
|
.. versionadded:: 3.0
|
||||||
%End
|
%End
|
||||||
@ -939,9 +993,10 @@ painter.
|
|||||||
:param painter: destination QPainter
|
:param painter: destination QPainter
|
||||||
%End
|
%End
|
||||||
|
|
||||||
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 ) = 0;
|
virtual void draw( QgsLayoutItemRenderContext &context ) = 0;
|
||||||
%Docstring
|
%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.
|
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.
|
Use the QgsRenderContext methods to convert from millimeters or other units to the painter's units.
|
||||||
%End
|
%End
|
||||||
|
@ -73,7 +73,7 @@ Returns a list of items contained by the group.
|
|||||||
|
|
||||||
|
|
||||||
protected:
|
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;
|
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 QSizeF totalSize() const;
|
||||||
|
|
||||||
virtual void render( QgsRenderContext &context, const QRectF &renderExtent, int frameIndex,
|
virtual void render( QgsLayoutItemRenderContext &context, const QRectF &renderExtent, int frameIndex );
|
||||||
const QStyleOptionGraphicsItem *itemStyle = 0 );
|
|
||||||
|
|
||||||
virtual double findNearbyPageBreak( double yPos );
|
virtual double findNearbyPageBreak( double yPos );
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ Returns the label font color.
|
|||||||
|
|
||||||
|
|
||||||
protected:
|
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;
|
virtual bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const;
|
||||||
|
|
||||||
|
@ -495,7 +495,7 @@ Returns the legend's renderer settings object.
|
|||||||
|
|
||||||
|
|
||||||
protected:
|
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;
|
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:
|
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;
|
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``.
|
Constructor for a QgsLayoutNodesItem with the given ``polygon`` nodes, attached to the specified ``layout``.
|
||||||
%End
|
%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;
|
virtual bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const;
|
||||||
@ -145,7 +145,7 @@ Method called in addNode.
|
|||||||
Method called in removeNode.
|
Method called in removeNode.
|
||||||
%End
|
%End
|
||||||
|
|
||||||
virtual void _draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 ) = 0;
|
virtual void _draw( QgsLayoutItemRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 ) = 0;
|
||||||
%Docstring
|
%Docstring
|
||||||
Method called in paint.
|
Method called in paint.
|
||||||
%End
|
%End
|
||||||
|
@ -105,7 +105,7 @@ page orientation.
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
|
virtual void draw( QgsLayoutItemRenderContext &context );
|
||||||
|
|
||||||
virtual void drawFrame( QgsRenderContext &context );
|
virtual void drawFrame( QgsRenderContext &context );
|
||||||
|
|
||||||
|
@ -299,7 +299,7 @@ Is emitted on picture rotation change
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
|
virtual void draw( QgsLayoutItemRenderContext &context );
|
||||||
|
|
||||||
virtual QSizeF applyItemSizeConstraint( const QSizeF &targetSize );
|
virtual QSizeF applyItemSizeConstraint( const QSizeF &targetSize );
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ Ownership of ``symbol`` is not transferred.
|
|||||||
|
|
||||||
virtual bool _removeNode( const int nodeIndex );
|
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 );
|
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 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 );
|
virtual void _readXmlStyle( const QDomElement &elmt, const QgsReadWriteContext &context );
|
||||||
|
|
||||||
|
@ -491,7 +491,7 @@ Adjusts the scale bar box size and updates the item.
|
|||||||
|
|
||||||
protected:
|
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;
|
virtual bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const;
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ Returns the corner radius for rounded rectangle corners.
|
|||||||
|
|
||||||
protected:
|
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;
|
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`
|
.. seealso:: :py:func:`recalculateFrameRects`
|
||||||
%End
|
%End
|
||||||
|
|
||||||
virtual void render( QgsRenderContext &context, const QRectF &renderExtent, int frameIndex,
|
virtual void render( QgsLayoutItemRenderContext &context, const QRectF &renderExtent, int frameIndex ) = 0;
|
||||||
const QStyleOptionGraphicsItem *itemStyle = 0 ) = 0;
|
|
||||||
%Docstring
|
%Docstring
|
||||||
Renders a portion of the multiframe's content into a render ``context``.
|
Renders a portion of the multiframe's content into a render ``context``.
|
||||||
|
|
||||||
:param context: destination render painter
|
:param context: destination render painter
|
||||||
:param renderExtent: visible extent of content to render into the painter.
|
:param renderExtent: visible extent of content to render into the painter.
|
||||||
:param frameIndex: frame number for content
|
:param frameIndex: frame number for content
|
||||||
:param itemStyle: item style options for graphics item rendering
|
|
||||||
%End
|
%End
|
||||||
|
|
||||||
virtual void addFrame( QgsLayoutFrame *frame /Transfer/, bool recalcFrameSizes = true );
|
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 QSizeF totalSize() const;
|
||||||
|
|
||||||
virtual void render( QgsRenderContext &context, const QRectF &renderExtent, int frameIndex,
|
virtual void render( QgsLayoutItemRenderContext &context, const QRectF &renderExtent, int frameIndex );
|
||||||
const QStyleOptionGraphicsItem *itemStyle = 0 );
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
@ -413,6 +413,10 @@ Constructor for QgsSymbolRenderContext
|
|||||||
|
|
||||||
|
|
||||||
QgsRenderContext &renderContext();
|
QgsRenderContext &renderContext();
|
||||||
|
%Docstring
|
||||||
|
Returns a reference to the context's render context.
|
||||||
|
%End
|
||||||
|
|
||||||
|
|
||||||
void setOriginalValueVariable( const QVariant &value );
|
void setOriginalValueVariable( const QVariant &value );
|
||||||
%Docstring
|
%Docstring
|
||||||
|
@ -157,14 +157,14 @@ void QgsLayoutFrame::cleanup()
|
|||||||
QgsLayoutItem::cleanup();
|
QgsLayoutItem::cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsLayoutFrame::draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle )
|
void QgsLayoutFrame::draw( QgsLayoutItemRenderContext &context )
|
||||||
{
|
{
|
||||||
if ( mMultiFrame )
|
if ( mMultiFrame )
|
||||||
{
|
{
|
||||||
//calculate index of frame
|
//calculate index of frame
|
||||||
int frameIndex = mMultiFrame->frameIndex( this );
|
int frameIndex = mMultiFrame->frameIndex( this );
|
||||||
Q_ASSERT_X( frameIndex >= 0, "QgsLayoutFrame::draw", "Invalid frame index for frame" );
|
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:
|
protected:
|
||||||
|
|
||||||
void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
|
void draw( QgsLayoutItemRenderContext &context ) override;
|
||||||
void drawFrame( QgsRenderContext &context ) override;
|
void drawFrame( QgsRenderContext &context ) override;
|
||||||
void drawBackground( QgsRenderContext &context ) override;
|
void drawBackground( QgsRenderContext &context ) override;
|
||||||
bool writePropertiesToElement( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const override;
|
bool writePropertiesToElement( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const override;
|
||||||
|
@ -33,6 +33,14 @@
|
|||||||
|
|
||||||
#define CACHE_SIZE_LIMIT 5000
|
#define CACHE_SIZE_LIMIT 5000
|
||||||
|
|
||||||
|
QgsLayoutItemRenderContext::QgsLayoutItemRenderContext( QgsRenderContext &context, double viewScaleFactor )
|
||||||
|
: mRenderContext( context )
|
||||||
|
, mViewScaleFactor( viewScaleFactor )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QgsLayoutItem::QgsLayoutItem( QgsLayout *layout, bool manageZValue )
|
QgsLayoutItem::QgsLayoutItem( QgsLayout *layout, bool manageZValue )
|
||||||
: QgsLayoutObject( layout )
|
: QgsLayoutObject( layout )
|
||||||
, QGraphicsRectItem( nullptr )
|
, 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)
|
// 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() );
|
p.translate( -boundingRect().x() * context.scaleFactor(), -boundingRect().y() * context.scaleFactor() );
|
||||||
drawBackground( context );
|
drawBackground( context );
|
||||||
draw( context, itemStyle );
|
double viewScale = QgsLayoutUtils::scaleFactorFromItemStyle( itemStyle );
|
||||||
|
QgsLayoutItemRenderContext itemRenderContext( context, viewScale );
|
||||||
|
draw( itemRenderContext );
|
||||||
drawFrame( context );
|
drawFrame( context );
|
||||||
p.end();
|
p.end();
|
||||||
|
|
||||||
@ -341,7 +351,9 @@ void QgsLayoutItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *it
|
|||||||
|
|
||||||
// scale painter from mm to dots
|
// scale painter from mm to dots
|
||||||
painter->scale( 1.0 / context.scaleFactor(), 1.0 / context.scaleFactor() );
|
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() );
|
painter->scale( context.scaleFactor(), context.scaleFactor() );
|
||||||
drawFrame( context );
|
drawFrame( context );
|
||||||
@ -1427,3 +1439,4 @@ void QgsLayoutItem::refreshBlendMode()
|
|||||||
// Update the item effect to use the new blend mode
|
// Update the item effect to use the new blend mode
|
||||||
mEffect->setCompositionMode( blendMode );
|
mEffect->setCompositionMode( blendMode );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,76 @@ class QPainter;
|
|||||||
class QgsLayoutItemGroup;
|
class QgsLayoutItemGroup;
|
||||||
class QgsLayoutEffect;
|
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
|
* \ingroup core
|
||||||
* \class QgsLayoutItem
|
* \class QgsLayoutItem
|
||||||
@ -845,11 +915,12 @@ class CORE_EXPORT QgsLayoutItem : public QgsLayoutObject, public QGraphicsRectIt
|
|||||||
virtual void drawDebugRect( QPainter *painter );
|
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.
|
* 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.
|
* 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.
|
* 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!
|
// nothing to draw here!
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ class CORE_EXPORT QgsLayoutItemGroup: public QgsLayoutItem
|
|||||||
void finalizeRestoreFromXml() override;
|
void finalizeRestoreFromXml() override;
|
||||||
|
|
||||||
protected:
|
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 writePropertiesToElement( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const override;
|
||||||
bool readPropertiesFromElement( const QDomElement &itemElement, const QDomDocument &document, const QgsReadWriteContext &context ) override;
|
bool readPropertiesFromElement( const QDomElement &itemElement, const QDomDocument &document, const QgsReadWriteContext &context ) override;
|
||||||
|
|
||||||
|
@ -279,16 +279,15 @@ QSizeF QgsLayoutItemHtml::totalSize() const
|
|||||||
return mSize;
|
return mSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsLayoutItemHtml::render( QgsRenderContext &context, const QRectF &renderExtent, const int,
|
void QgsLayoutItemHtml::render( QgsLayoutItemRenderContext &context, const QRectF &renderExtent, const int )
|
||||||
const QStyleOptionGraphicsItem * )
|
|
||||||
{
|
{
|
||||||
if ( !mWebPage )
|
if ( !mWebPage )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QPainter *painter = context.painter();
|
QPainter *painter = context.renderContext().painter();
|
||||||
painter->save();
|
painter->save();
|
||||||
// painter is scaled to dots, so scale back to layout units
|
// 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 );
|
painter->translate( 0.0, -renderExtent.top() * mHtmlUnitsToLayoutUnits );
|
||||||
mWebPage->mainFrame()->render( painter, QRegion( renderExtent.left(), renderExtent.top() * mHtmlUnitsToLayoutUnits, renderExtent.width() * mHtmlUnitsToLayoutUnits, renderExtent.height() * mHtmlUnitsToLayoutUnits ) );
|
mWebPage->mainFrame()->render( painter, QRegion( renderExtent.left(), renderExtent.top() * mHtmlUnitsToLayoutUnits, renderExtent.width() * mHtmlUnitsToLayoutUnits, renderExtent.height() * mHtmlUnitsToLayoutUnits ) );
|
||||||
painter->restore();
|
painter->restore();
|
||||||
|
@ -204,8 +204,7 @@ class CORE_EXPORT QgsLayoutItemHtml: public QgsLayoutMultiFrame
|
|||||||
|
|
||||||
QString displayName() const override;
|
QString displayName() const override;
|
||||||
QSizeF totalSize() const override;
|
QSizeF totalSize() const override;
|
||||||
void render( QgsRenderContext &context, const QRectF &renderExtent, int frameIndex,
|
void render( QgsLayoutItemRenderContext &context, const QRectF &renderExtent, int frameIndex ) override;
|
||||||
const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
|
|
||||||
|
|
||||||
//overridden to break frames without dividing lines of text
|
//overridden to break frames without dividing lines of text
|
||||||
double findNearbyPageBreak( double yPos ) override;
|
double findNearbyPageBreak( double yPos ) override;
|
||||||
|
@ -97,13 +97,13 @@ QIcon QgsLayoutItemLabel::icon() const
|
|||||||
return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItemLabel.svg" ) );
|
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->save();
|
||||||
|
|
||||||
// painter is scaled to dots, so scale back to layout units
|
// 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 penWidth = frameEnabled() ? ( pen().widthF() / 2.0 ) : 0;
|
||||||
double xPenAdjust = mMarginX < 0 ? -penWidth : penWidth;
|
double xPenAdjust = mMarginX < 0 ? -penWidth : penWidth;
|
||||||
|
@ -218,7 +218,7 @@ class CORE_EXPORT QgsLayoutItemLabel: public QgsLayoutItem
|
|||||||
void refresh() override;
|
void refresh() override;
|
||||||
|
|
||||||
protected:
|
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 writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
|
||||||
bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
|
bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
|
||||||
|
|
||||||
|
@ -138,13 +138,13 @@ void QgsLayoutItemLegend::refresh()
|
|||||||
onAtlasFeature();
|
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->save();
|
||||||
|
|
||||||
// painter is scaled to dots, so scale back to layout units
|
// 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 ) ) );
|
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;
|
void refreshDataDefinedProperty( const QgsLayoutObject::DataDefinedProperty property = QgsLayoutObject::AllProperties ) override;
|
||||||
|
|
||||||
protected:
|
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 writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
|
||||||
bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
|
bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
|
||||||
|
|
||||||
|
@ -509,7 +509,7 @@ QgsLayoutItemMapOverview *QgsLayoutItemMap::overview()
|
|||||||
return mOverviewStack->overview( 0 );
|
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:
|
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 writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
|
||||||
bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) 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 );
|
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->setPen( Qt::NoPen );
|
||||||
painter->setBrush( Qt::NoBrush );
|
painter->setBrush( Qt::NoBrush );
|
||||||
|
|
||||||
context.setForceVectorOutput( true );
|
context.renderContext().setForceVectorOutput( true );
|
||||||
rescaleToFitBoundingBox();
|
rescaleToFitBoundingBox();
|
||||||
_draw( context );
|
_draw( context );
|
||||||
|
|
||||||
if ( mDrawNodes && layout()->renderContext().isPreviewRender() )
|
if ( mDrawNodes && layout()->renderContext().isPreviewRender() )
|
||||||
drawNodes( context, style );
|
drawNodes( context );
|
||||||
}
|
}
|
||||||
|
|
||||||
double QgsLayoutNodesItem::computeDistance( QPointF pt1,
|
double QgsLayoutNodesItem::computeDistance( QPointF pt1,
|
||||||
@ -161,11 +161,11 @@ bool QgsLayoutNodesItem::addNode( QPointF pt,
|
|||||||
return rc;
|
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;
|
QgsStringMap properties;
|
||||||
properties.insert( QStringLiteral( "name" ), QStringLiteral( "cross" ) );
|
properties.insert( QStringLiteral( "name" ), QStringLiteral( "cross" ) );
|
||||||
@ -176,18 +176,18 @@ void QgsLayoutNodesItem::drawNodes( QgsRenderContext &context, const QStyleOptio
|
|||||||
symbol->setSize( rectSize );
|
symbol->setSize( rectSize );
|
||||||
symbol->setAngle( 45 );
|
symbol->setAngle( 45 );
|
||||||
|
|
||||||
symbol->startRender( context );
|
symbol->startRender( context.renderContext() );
|
||||||
for ( QPointF pt : mPolygon )
|
for ( QPointF pt : mPolygon )
|
||||||
symbol->renderPoint( pt * QgsLayoutUtils::scaleFactorFromItemStyle( itemStyle ), nullptr, context );
|
symbol->renderPoint( pt * context.viewScaleFactor(), nullptr, context.renderContext() );
|
||||||
symbol->stopRender( context );
|
symbol->stopRender( context.renderContext() );
|
||||||
|
|
||||||
if ( mSelectedNode >= 0 && mSelectedNode < mPolygon.size() )
|
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;
|
QgsStringMap properties;
|
||||||
properties.insert( QStringLiteral( "name" ), QStringLiteral( "square" ) );
|
properties.insert( QStringLiteral( "name" ), QStringLiteral( "square" ) );
|
||||||
@ -199,9 +199,9 @@ void QgsLayoutNodesItem::drawSelectedNode( QgsRenderContext &context, const QSty
|
|||||||
symbol.reset( QgsMarkerSymbol::createSimple( properties ) );
|
symbol.reset( QgsMarkerSymbol::createSimple( properties ) );
|
||||||
symbol->setSize( rectSize );
|
symbol->setSize( rectSize );
|
||||||
|
|
||||||
symbol->startRender( context );
|
symbol->startRender( context.renderContext() );
|
||||||
symbol->renderPoint( mPolygon.at( mSelectedNode ) * QgsLayoutUtils::scaleFactorFromItemStyle( itemStyle ), nullptr, context );
|
symbol->renderPoint( mPolygon.at( mSelectedNode ) * context.viewScaleFactor(), nullptr, context.renderContext() );
|
||||||
symbol->stopRender( context );
|
symbol->stopRender( context.renderContext() );
|
||||||
}
|
}
|
||||||
|
|
||||||
int QgsLayoutNodesItem::nodeAtPosition( QPointF node,
|
int QgsLayoutNodesItem::nodeAtPosition( QPointF node,
|
||||||
|
@ -126,7 +126,7 @@ class CORE_EXPORT QgsLayoutNodesItem: public QgsLayoutItem
|
|||||||
*/
|
*/
|
||||||
QgsLayoutNodesItem( const QPolygonF &polygon, QgsLayout *layout );
|
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 writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
|
||||||
bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) 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;
|
virtual bool _removeNode( const int nodeIndex ) = 0;
|
||||||
|
|
||||||
//! Method called in paint.
|
//! 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.
|
//! Method called in readXml.
|
||||||
virtual void _readXmlStyle( const QDomElement &elmt, const QgsReadWriteContext &context ) = 0;
|
virtual void _readXmlStyle( const QDomElement &elmt, const QgsReadWriteContext &context ) = 0;
|
||||||
@ -188,8 +188,8 @@ class CORE_EXPORT QgsLayoutNodesItem: public QgsLayoutItem
|
|||||||
bool mDrawNodes = false;
|
bool mDrawNodes = false;
|
||||||
|
|
||||||
//! Draw nodes
|
//! Draw nodes
|
||||||
void drawNodes( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) const;
|
void drawNodes( QgsLayoutItemRenderContext &context ) const;
|
||||||
void drawSelectedNode( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) const;
|
void drawSelectedNode( QgsLayoutItemRenderContext &context ) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -181,19 +181,19 @@ void QgsLayoutItemPage::redraw()
|
|||||||
mGrid->update();
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double scale = context.convertToPainterUnits( 1, QgsUnitTypes::RenderMillimeters );
|
double scale = context.renderContext().convertToPainterUnits( 1, QgsUnitTypes::RenderMillimeters );
|
||||||
|
|
||||||
QgsExpressionContext expressionContext = createExpressionContext();
|
QgsExpressionContext expressionContext = createExpressionContext();
|
||||||
context.setExpressionContext( expressionContext );
|
context.renderContext().setExpressionContext( expressionContext );
|
||||||
|
|
||||||
QPainter *painter = context.painter();
|
QPainter *painter = context.renderContext().painter();
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
if ( mLayout->renderContext().isPreviewRender() )
|
if ( mLayout->renderContext().isPreviewRender() )
|
||||||
@ -220,10 +220,10 @@ void QgsLayoutItemPage::draw( QgsRenderContext &context, const QStyleOptionGraph
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr< QgsFillSymbol > symbol( mLayout->pageCollection()->pageStyleSymbol()->clone() );
|
std::unique_ptr< QgsFillSymbol > symbol( mLayout->pageCollection()->pageStyleSymbol()->clone() );
|
||||||
symbol->startRender( context );
|
symbol->startRender( context.renderContext() );
|
||||||
|
|
||||||
//get max bleed from symbol
|
//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
|
//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,
|
//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 ) );
|
std::ceil( rect().width() * scale ) - 2 * maxBleedPixels, std::ceil( rect().height() * scale ) - 2 * maxBleedPixels ) );
|
||||||
QList<QPolygonF> rings; //empty list
|
QList<QPolygonF> rings; //empty list
|
||||||
|
|
||||||
symbol->renderPolygon( pagePolygon, &rings, nullptr, context );
|
symbol->renderPolygon( pagePolygon, &rings, nullptr, context.renderContext() );
|
||||||
symbol->stopRender( context );
|
symbol->stopRender( context.renderContext() );
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ class CORE_EXPORT QgsLayoutItemPage : public QgsLayoutItem
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
|
void draw( QgsLayoutItemRenderContext &context ) override;
|
||||||
void drawFrame( QgsRenderContext &context ) override;
|
void drawFrame( QgsRenderContext &context ) override;
|
||||||
void drawBackground( QgsRenderContext &context ) override;
|
void drawBackground( QgsRenderContext &context ) override;
|
||||||
|
|
||||||
|
@ -80,12 +80,12 @@ QgsLayoutItemPicture *QgsLayoutItemPicture::create( QgsLayout *layout )
|
|||||||
return new QgsLayoutItemPicture( 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->save();
|
||||||
// painter is scaled to dots, so scale back to layout units
|
// 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
|
//picture resizing
|
||||||
if ( mMode != FormatUnknown )
|
if ( mMode != FormatUnknown )
|
||||||
|
@ -268,7 +268,7 @@ class CORE_EXPORT QgsLayoutItemPicture: public QgsLayoutItem
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
|
void draw( QgsLayoutItemRenderContext &context ) override;
|
||||||
QSizeF applyItemSizeConstraint( const QSizeF &targetSize ) override;
|
QSizeF applyItemSizeConstraint( const QSizeF &targetSize ) override;
|
||||||
bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
|
bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
|
||||||
bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
|
bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
|
||||||
|
@ -97,20 +97,20 @@ QString QgsLayoutItemPolygon::displayName() const
|
|||||||
return tr( "<Polygon>" );
|
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
|
//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 );
|
QTransform t = QTransform::fromScale( scale, scale );
|
||||||
|
|
||||||
QList<QPolygonF> rings; //empty
|
QList<QPolygonF> rings; //empty
|
||||||
QPainterPath polygonPath;
|
QPainterPath polygonPath;
|
||||||
polygonPath.addPolygon( mPolygon );
|
polygonPath.addPolygon( mPolygon );
|
||||||
|
|
||||||
mPolygonStyleSymbol->startRender( context );
|
mPolygonStyleSymbol->startRender( context.renderContext() );
|
||||||
mPolygonStyleSymbol->renderPolygon( polygonPath.toFillPolygon( t ), &rings,
|
mPolygonStyleSymbol->renderPolygon( polygonPath.toFillPolygon( t ), &rings,
|
||||||
nullptr, context );
|
nullptr, context.renderContext() );
|
||||||
mPolygonStyleSymbol->stopRender( context );
|
mPolygonStyleSymbol->stopRender( context.renderContext() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsLayoutItemPolygon::_readXmlStyle( const QDomElement &elmt, const QgsReadWriteContext &context )
|
void QgsLayoutItemPolygon::_readXmlStyle( const QDomElement &elmt, const QgsReadWriteContext &context )
|
||||||
|
@ -71,7 +71,7 @@ class CORE_EXPORT QgsLayoutItemPolygon: public QgsLayoutNodesItem
|
|||||||
protected:
|
protected:
|
||||||
bool _addNode( const int indexPoint, QPointF newPoint, const double radius ) override;
|
bool _addNode( const int indexPoint, QPointF newPoint, const double radius ) override;
|
||||||
bool _removeNode( const int nodeIndex ) 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 _readXmlStyle( const QDomElement &elmt, const QgsReadWriteContext &context ) override;
|
||||||
void _writeXmlStyle( QDomDocument &doc, QDomElement &elmt, const QgsReadWriteContext &context ) const override;
|
void _writeXmlStyle( QDomDocument &doc, QDomElement &elmt, const QgsReadWriteContext &context ) const override;
|
||||||
|
|
||||||
|
@ -263,23 +263,23 @@ QString QgsLayoutItemPolyline::displayName() const
|
|||||||
return tr( "<Polyline>" );
|
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
|
//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 );
|
QTransform t = QTransform::fromScale( scale, scale );
|
||||||
|
|
||||||
mPolylineStyleSymbol->startRender( context );
|
mPolylineStyleSymbol->startRender( context.renderContext() );
|
||||||
mPolylineStyleSymbol->renderPolyline( t.map( mPolygon ), nullptr, context );
|
mPolylineStyleSymbol->renderPolyline( t.map( mPolygon ), nullptr, context.renderContext() );
|
||||||
mPolylineStyleSymbol->stopRender( context );
|
mPolylineStyleSymbol->stopRender( context.renderContext() );
|
||||||
|
|
||||||
// painter is scaled to dots, so scale back to layout units
|
// 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() );
|
drawStartMarker( context.renderContext().painter() );
|
||||||
drawEndMarker( context.painter() );
|
drawEndMarker( context.renderContext().painter() );
|
||||||
context.painter()->restore();
|
context.renderContext().painter()->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsLayoutItemPolyline::_readXmlStyle( const QDomElement &elmt, const QgsReadWriteContext &context )
|
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 _addNode( const int indexPoint, QPointF newPoint, const double radius ) override;
|
||||||
bool _removeNode( const int nodeIndex ) 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 _readXmlStyle( const QDomElement &elmt, const QgsReadWriteContext &context ) override;
|
||||||
void _writeXmlStyle( QDomDocument &doc, QDomElement &elmt, const QgsReadWriteContext &context ) const override;
|
void _writeXmlStyle( QDomDocument &doc, QDomElement &elmt, const QgsReadWriteContext &context ) const override;
|
||||||
bool writePropertiesToElement( QDomElement &element, QDomDocument &document, 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 );
|
return QgsLayoutSize( mStyle->calculateBoxSize( mSettings, createScaleContext() ), QgsUnitTypes::LayoutMillimeters );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsLayoutItemScaleBar::draw( QgsRenderContext &context, const QStyleOptionGraphicsItem * )
|
void QgsLayoutItemScaleBar::draw( QgsLayoutItemRenderContext &context )
|
||||||
{
|
{
|
||||||
if ( !mStyle )
|
if ( !mStyle )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mStyle->draw( context, mSettings, createScaleContext() );
|
mStyle->draw( context.renderContext(), mSettings, createScaleContext() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsLayoutItemScaleBar::setNumberOfSegments( int nSegments )
|
void QgsLayoutItemScaleBar::setNumberOfSegments( int nSegments )
|
||||||
|
@ -425,7 +425,7 @@ class CORE_EXPORT QgsLayoutItemScaleBar: public QgsLayoutItem
|
|||||||
void finalizeRestoreFromXml() override;
|
void finalizeRestoreFromXml() override;
|
||||||
protected:
|
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 writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
|
||||||
bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
|
bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
|
||||||
|
|
||||||
|
@ -150,13 +150,13 @@ double QgsLayoutItemShape::estimatedFrameBleed() const
|
|||||||
return mMaxSymbolBleed;
|
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->setPen( Qt::NoPen );
|
||||||
painter->setBrush( Qt::NoBrush );
|
painter->setBrush( Qt::NoBrush );
|
||||||
|
|
||||||
double scale = context.convertToPainterUnits( 1, QgsUnitTypes::RenderMillimeters );
|
double scale = context.renderContext().convertToPainterUnits( 1, QgsUnitTypes::RenderMillimeters );
|
||||||
|
|
||||||
QPolygonF shapePolygon;
|
QPolygonF shapePolygon;
|
||||||
|
|
||||||
@ -206,9 +206,9 @@ void QgsLayoutItemShape::draw( QgsRenderContext &context, const QStyleOptionGrap
|
|||||||
|
|
||||||
QList<QPolygonF> rings; //empty list
|
QList<QPolygonF> rings; //empty list
|
||||||
|
|
||||||
symbol()->startRender( context );
|
symbol()->startRender( context.renderContext() );
|
||||||
symbol()->renderPolygon( shapePolygon, &rings, nullptr, context );
|
symbol()->renderPolygon( shapePolygon, &rings, nullptr, context.renderContext() );
|
||||||
symbol()->stopRender( context );
|
symbol()->stopRender( context.renderContext() );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QgsLayoutItemShape::writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const
|
bool QgsLayoutItemShape::writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const
|
||||||
|
@ -109,7 +109,7 @@ class CORE_EXPORT QgsLayoutItemShape : public QgsLayoutItem
|
|||||||
|
|
||||||
protected:
|
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 writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
|
||||||
bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
|
bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
|
||||||
|
@ -34,6 +34,7 @@ class QRectF;
|
|||||||
class QPainter;
|
class QPainter;
|
||||||
class QStyleOptionGraphicsItem;
|
class QStyleOptionGraphicsItem;
|
||||||
class QgsRenderContext;
|
class QgsRenderContext;
|
||||||
|
class QgsLayoutItemRenderContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \ingroup core
|
* \ingroup core
|
||||||
@ -175,10 +176,8 @@ class CORE_EXPORT QgsLayoutMultiFrame: public QgsLayoutObject, public QgsLayoutU
|
|||||||
* \param context destination render painter
|
* \param context destination render painter
|
||||||
* \param renderExtent visible extent of content to render into the painter.
|
* \param renderExtent visible extent of content to render into the painter.
|
||||||
* \param frameIndex frame number for content
|
* \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,
|
virtual void render( QgsLayoutItemRenderContext &context, const QRectF &renderExtent, int frameIndex ) = 0;
|
||||||
const QStyleOptionGraphicsItem *itemStyle = nullptr ) = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a \a frame to the multiframe.
|
* Adds a \a frame to the multiframe.
|
||||||
|
@ -279,8 +279,7 @@ QPair<int, int> QgsLayoutTable::rowRange( const int frameIndex ) const
|
|||||||
return qMakePair( firstVisible, lastVisible );
|
return qMakePair( firstVisible, lastVisible );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsLayoutTable::render( QgsRenderContext &context, const QRectF &, const int frameIndex,
|
void QgsLayoutTable::render( QgsLayoutItemRenderContext &context, const QRectF &, const int frameIndex )
|
||||||
const QStyleOptionGraphicsItem * )
|
|
||||||
{
|
{
|
||||||
bool emptyTable = mTableContents.length() == 0;
|
bool emptyTable = mTableContents.length() == 0;
|
||||||
if ( emptyTable && mEmptyTableMode == QgsLayoutTable::HideTable )
|
if ( emptyTable && mEmptyTableMode == QgsLayoutTable::HideTable )
|
||||||
@ -327,10 +326,10 @@ void QgsLayoutTable::render( QgsRenderContext &context, const QRectF &, const in
|
|||||||
mergeCells = true;
|
mergeCells = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPainter *p = context.painter();
|
QPainter *p = context.renderContext().painter();
|
||||||
p->save();
|
p->save();
|
||||||
// painter is scaled to dots, so scale back to layout units
|
// 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
|
//draw the text
|
||||||
p->setPen( Qt::SolidLine );
|
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 writePropertiesToElement( QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
|
||||||
bool readPropertiesFromElement( const QDomElement &itemElem, const QDomDocument &doc, const QgsReadWriteContext &context ) override;
|
bool readPropertiesFromElement( const QDomElement &itemElem, const QDomDocument &doc, const QgsReadWriteContext &context ) override;
|
||||||
QSizeF totalSize() const override;
|
QSizeF totalSize() const override;
|
||||||
void render( QgsRenderContext &context, const QRectF &renderExtent, int frameIndex,
|
void render( QgsLayoutItemRenderContext &context, const QRectF &renderExtent, int frameIndex ) override;
|
||||||
const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
@ -447,7 +447,15 @@ class CORE_EXPORT QgsSymbolRenderContext
|
|||||||
//! QgsSymbolRenderContext cannot be copied.
|
//! QgsSymbolRenderContext cannot be copied.
|
||||||
QgsSymbolRenderContext( const QgsSymbolRenderContext &rh ) = delete;
|
QgsSymbolRenderContext( const QgsSymbolRenderContext &rh ) = delete;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a reference to the context's render context.
|
||||||
|
*/
|
||||||
QgsRenderContext &renderContext() { return mRenderContext; }
|
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
|
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; }
|
void setConvertScaleToMapUnits( bool convert ) { mConvertScaleToMapUnits = convert; }
|
||||||
bool convertScaleToMapUnits() const { return mConvertScaleToMapUnits; }
|
bool convertScaleToMapUnits() const { return mConvertScaleToMapUnits; }
|
||||||
|
|
||||||
void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
|
void draw( QgsLayoutItemRenderContext &context ) override;
|
||||||
private:
|
private:
|
||||||
//gcp list
|
//gcp list
|
||||||
QgsGCPList mGCPList;
|
QgsGCPList mGCPList;
|
||||||
|
@ -54,9 +54,9 @@ class TestItem : public QgsLayoutItem
|
|||||||
bool forceResize = false;
|
bool forceResize = false;
|
||||||
|
|
||||||
protected:
|
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->save();
|
||||||
painter->setRenderHint( QPainter::Antialiasing, false );
|
painter->setRenderHint( QPainter::Antialiasing, false );
|
||||||
painter->setPen( Qt::NoPen );
|
painter->setPen( Qt::NoPen );
|
||||||
|
@ -74,8 +74,7 @@ class TestMultiFrame : public QgsLayoutMultiFrame
|
|||||||
return QgsLayoutItemRegistry::PluginItem + 1;
|
return QgsLayoutItemRegistry::PluginItem + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void render( QgsRenderContext &, const QRectF &, int,
|
void render( QgsLayoutItemRenderContext &, const QRectF &, int ) override
|
||||||
const QStyleOptionGraphicsItem * ) override
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ class TestItem : public QgsLayoutItem
|
|||||||
|
|
||||||
//implement pure virtual methods
|
//implement pure virtual methods
|
||||||
int type() const override { return QgsLayoutItemRegistry::LayoutItem + 101; }
|
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