Nakuja Flight Computer Testing and Simulation Engine (NaFCTSE) 1.0
A testing and verification tool for the Nakuja Rocket Project flight computers
|
The abstract base class for paint buffers, which define the rendering backend. More...
Public Member Functions | |
QCPAbstractPaintBuffer (const QSize &size, double devicePixelRatio) | |
QSize | size () const |
bool | invalidated () const |
double | devicePixelRatio () const |
void | setSize (const QSize &size) |
void | setInvalidated (bool invalidated=true) |
void | setDevicePixelRatio (double ratio) |
virtual QCPPainter * | startPainting ()=0 |
virtual void | donePainting () |
virtual void | draw (QCPPainter *painter) const =0 |
virtual void | clear (const QColor &color)=0 |
Protected Member Functions | |
virtual void | reallocateBuffer ()=0 |
Protected Attributes | |
QSize | mSize |
double | mDevicePixelRatio |
bool | mInvalidated |
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.
|
explicit |
Creates a paint buffer and initializes it with the provided size and devicePixelRatio.
Subclasses must call their reallocateBuffer implementation in their respective constructors.
|
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.
|
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.
|
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.
|
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.
Implemented in QCPPaintBufferPixmap.
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.
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.
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.
|
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.