QCPAbstractPaintBuffer

Search for usage in LXR

Inheritance diagram for QCPAbstractPaintBuffer:

Public Member Functions

 QCPAbstractPaintBuffer (const QSize &size, double devicePixelRatio)
 
virtual void clear (const QColor &color)=0
 
double devicePixelRatio () const
 
virtual void donePainting ()
 
virtual void draw (QCPPainter *painter) const =0
 
bool invalidated () const
 
void setDevicePixelRatio (double ratio)
 
void setInvalidated (bool invalidated=true)
 
void setSize (const QSize &size)
 
QSize size () const
 
virtual QCPPainterstartPainting ()=0
 

Protected Member Functions

virtual void reallocateBuffer ()=0
 

Protected Attributes

double mDevicePixelRatio
 
bool mInvalidated
 
QSize mSize
 

Detailed Description

The abstract base class for paint buffers, which define the rendering backend.

This abstract base class defines the basic interface that a paint buffer needs to provide in order to be usable by QCustomPlot.

A paint buffer manages both a surface to draw onto, and the matching paint device. The size of the surface can be changed via setSize. External classes (QCustomPlot and QCPLayer) request a painter via startPainting and then perform the draw calls. Once the painting is complete, donePainting is called, so the paint buffer implementation can do clean up if necessary. Before rendering a frame, each paint buffer is usually filled with a color using clear (usually the color is Qt::transparent), to remove the contents of the previous frame.

The simplest paint buffer implementation is QCPPaintBufferPixmap which allows regular software rendering via the raster engine. Hardware accelerated rendering via pixel buffers and frame buffer objects is provided by QCPPaintBufferGlPbuffer and QCPPaintBufferGlFbo. They are used automatically if QCustomPlot::setOpenGl is enabled.

Definition at line 574 of file qcustomplot.h.

Constructor & Destructor Documentation

◆ QCPAbstractPaintBuffer()

QCPAbstractPaintBuffer::QCPAbstractPaintBuffer ( const QSize & size,
double devicePixelRatio )
explicit

Creates a paint buffer and initializes it with the provided size and devicePixelRatio.

Subclasses must call their reallocateBuffer implementation in their respective constructors.

Definition at line 581 of file qcustomplot.cpp.

◆ ~QCPAbstractPaintBuffer()

QCPAbstractPaintBuffer::~QCPAbstractPaintBuffer ( )
virtual

Definition at line 588 of file qcustomplot.cpp.

Member Function Documentation

◆ clear()

virtual void QCPAbstractPaintBuffer::clear ( const QColor & color)
pure virtual

Fills the entire buffer with the provided color. To have an empty transparent buffer, use the named color Qt::transparent.

This method must not be called if there is currently a painter (acquired with startPainting) active.

Implemented in QCPPaintBufferPixmap.

◆ devicePixelRatio()

double QCPAbstractPaintBuffer::devicePixelRatio ( ) const
inline

Definition at line 583 of file qcustomplot.h.

◆ donePainting()

virtual void QCPAbstractPaintBuffer::donePainting ( )
inlinevirtual

If you have acquired a QCPPainter to paint onto this paint buffer via startPainting, call this method as soon as you are done with the painting operations and have deleted the painter.

paint buffer subclasses may use this method to perform any type of cleanup that is necessary. The default implementation does nothing.

Definition at line 592 of file qcustomplot.h.

◆ draw()

virtual void QCPAbstractPaintBuffer::draw ( QCPPainter * painter) const
pure virtual

Draws the contents of this buffer with the provided painter. This is the method that is used to finally join all paint buffers and draw them onto the screen.

Implemented in QCPPaintBufferPixmap.

◆ invalidated()

bool QCPAbstractPaintBuffer::invalidated ( ) const
inline

Definition at line 582 of file qcustomplot.h.

◆ reallocateBuffer()

virtual void QCPAbstractPaintBuffer::reallocateBuffer ( )
protectedpure virtual

Reallocates the internal buffer with the currently configured size (setSize) and device pixel ratio, if applicable (setDevicePixelRatio). It is called as soon as any of those properties are changed on this paint buffer.

Note
Subclasses of QCPAbstractPaintBuffer must call their reimplementation of this method in their constructor, to perform the first allocation (this can not be done by the base class because calling pure virtual methods in base class constructors is not possible).

Implemented in QCPPaintBufferPixmap.

◆ setDevicePixelRatio()

void QCPAbstractPaintBuffer::setDevicePixelRatio ( double ratio)

Sets the device pixel ratio to ratio. This is useful to render on high-DPI output devices. The ratio is automatically set to the device pixel ratio used by the parent QCustomPlot instance.

The buffer is reallocated (by calling reallocateBuffer), so any painters that were obtained by startPainting are invalidated and must not be used after calling this method.

Note
This method is only available for Qt versions 5.4 and higher.

Definition at line 638 of file qcustomplot.cpp.

◆ setInvalidated()

void QCPAbstractPaintBuffer::setInvalidated ( bool invalidated = true)

Sets the invalidated flag to invalidated.

This mechanism is used internally in conjunction with isolated replotting of QCPLayer instances (in QCPLayer::lmBuffered mode). If QCPLayer::replot is called on a buffered layer, i.e. an isolated repaint of only that layer (and its dedicated paint buffer) is requested, QCustomPlot will decide depending on the invalidated flags of other paint buffers whether it also replots them, instead of only the layer on which the replot was called.

The invalidated flag is set to true when QCPLayer association has changed, i.e. if layers were added or removed from this buffer, or if they were reordered. It is set to false as soon as all associated QCPLayer instances are drawn onto the buffer.

Under normal circumstances, it is not necessary to manually call this method.

Definition at line 624 of file qcustomplot.cpp.

◆ setSize()

void QCPAbstractPaintBuffer::setSize ( const QSize & size)

Sets the paint buffer size.

The buffer is reallocated (by calling reallocateBuffer), so any painters that were obtained by startPainting are invalidated and must not be used after calling this method.

If size is already the current buffer size, this method does nothing.

Definition at line 600 of file qcustomplot.cpp.

◆ size()

QSize QCPAbstractPaintBuffer::size ( ) const
inline

Definition at line 581 of file qcustomplot.h.

◆ startPainting()

virtual QCPPainter * QCPAbstractPaintBuffer::startPainting ( )
pure virtual

Returns a QCPPainter which is ready to draw to this buffer. The ownership and thus the responsibility to delete the painter after the painting operations are complete is given to the caller of this method.

Once you are done using the painter, delete the painter and call donePainting.

While a painter generated with this method is active, you must not call setSize, setDevicePixelRatio or clear.

This method may return 0, if a painter couldn't be activated on the buffer. This usually indicates a problem with the respective painting backend.

Implemented in QCPPaintBufferPixmap.

Member Data Documentation

◆ mDevicePixelRatio

double QCPAbstractPaintBuffer::mDevicePixelRatio
protected

Definition at line 599 of file qcustomplot.h.

◆ mInvalidated

bool QCPAbstractPaintBuffer::mInvalidated
protected

Definition at line 602 of file qcustomplot.h.

◆ mSize

QSize QCPAbstractPaintBuffer::mSize
protected

Definition at line 598 of file qcustomplot.h.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.