QwtGraphic(3) | Qwt User's Guide | QwtGraphic(3) |
QwtGraphic - A paint device for scalable graphics.
#include <qwt_graphic.h>
Inherits QwtNullPaintDevice.
enum RenderHint { RenderPensUnscaled = 0x1 }
typedef QFlags< RenderHint > RenderHints
Render hints.
QwtGraphic ()
Constructor. QwtGraphic (const QwtGraphic &)
Copy constructor. virtual ~QwtGraphic ()
Destructor. QwtGraphic & operator= (const QwtGraphic
&)
Assignment operator. void reset ()
Clear all stored commands. bool isNull () const
bool isEmpty () const
void render (QPainter *) const
Replay all recorded painter commands. void render (QPainter *, const
QSizeF &, Qt::AspectRatioMode=Qt::IgnoreAspectRatio) const
Replay all recorded painter commands. void render (QPainter *, const
QRectF &, Qt::AspectRatioMode=Qt::IgnoreAspectRatio) const
Replay all recorded painter commands. void render (QPainter *, const
QPointF &, Qt::Alignment=Qt::AlignTop|Qt::AlignLeft) const
Replay all recorded painter commands. QPixmap toPixmap () const
Convert the graphic to a QPixmap. QPixmap toPixmap (const QSize &,
Qt::AspectRatioMode=Qt::IgnoreAspectRatio) const
Convert the graphic to a QPixmap. QImage toImage () const
Convert the graphic to a QImage. QImage toImage (const QSize &,
Qt::AspectRatioMode=Qt::IgnoreAspectRatio) const
Convert the graphic to a QImage. QRectF scaledBoundingRect (double sx,
double sy) const
Calculate the target rectangle for scaling the graphic. QRectF
boundingRect () const
QRectF controlPointRect () const
const QVector< QwtPainterCommand > & commands () const
void setCommands (QVector< QwtPainterCommand > &)
Append paint commands. void setDefaultSize (const QSizeF &)
Set a default size. QSizeF defaultSize () const
Default size. void setRenderHint (RenderHint, bool on=true)
bool testRenderHint (RenderHint) const
virtual QSize sizeMetrics () const
virtual void drawPath (const QPainterPath &)
virtual void drawPixmap (const QRectF &, const QPixmap &, const
QRectF &)
Store a pixmap command in the command list. virtual void drawImage
(const QRectF &, const QImage &, const QRectF &,
Qt::ImageConversionFlags)
Store a image command in the command list. virtual void updateState
(const QPaintEngineState &state)
Store a state command in the command list.
A paint device for scalable graphics.
QwtGraphic is the representation of a graphic that is tailored for scalability. Like QPicture it will be initialized by QPainter operations and can be replayed later to any target paint device.
While the usual image representations QImage and QPixmap are not scalable Qt offers two paint devices, that might be candidates for representing a vector graphic:
QwtGraphic maps all scalable drawing primitives to a QPainterPath and stores them together with the painter state changes ( pen, brush, transformation ... ) in a list of QwtPaintCommands. For being a complete QPaintDevice it also stores pixmaps or images, what is somehow against the idea of the class, because these objects can't be scaled without a loss in quality.
The main issue about scaling a QwtGraphic object are the pens used for drawing the outlines of the painter paths. While non cosmetic pens ( QPen::isCosmetic() ) are scaled with the same ratio as the path, cosmetic pens have a fixed width. A graphic might have paths with different pens - cosmetic and non-cosmetic.
QwtGraphic caches 2 different rectangles:
Because the offset for drawing the outline depends on the shape of the painter path ( the peak of a triangle is different than the flat side ) scaling with a fixed aspect ratio always needs to be calculated from the control point rectangle.
See also:
Render hints. The default setting is to disable all hints
Hint how to render a graphic
See also:
Enumerator
When RenderPensUnscaled is set this specific scaling is applied for the control points only, but not for the pens. All other painter transformations ( set up by application code ) are supposed to work like usual.
See also:
Constructor. Initializes a null graphic
See also:
Copy constructor.
Parameters:
See also:
The bounding rectangle is the controlPointRect() extended by the areas needed for rendering the outlines with unscaled pens.
Returns:
See also:
Returns:
See also:
The control point rectangle is the bounding rectangle of all control points of the paths and the target rectangles of the images/pixmaps.
Returns:
See also:
Default size. When a non empty size has been assigned by setDefaultSize() this size will be returned. Otherwise the default size is the size of the bounding rectangle.
The default size is used in all methods rendering the graphic, where no size is explicitly specified.
Returns:
See also:
Store a image command in the command list.
Parameters:
See also:
Reimplemented from QwtNullPaintDevice.
Store a path command in the command list
Parameters:
See also:
Reimplemented from QwtNullPaintDevice.
Store a pixmap command in the command list.
Parameters:
See also:
Reimplemented from QwtNullPaintDevice.
Returns:
See also:
Returns:
See also:
Assignment operator.
Parameters:
Returns:
Replay all recorded painter commands.
Parameters:
Replay all recorded painter commands. The graphic is scaled to fit into the rectangle of the given size starting at ( 0, 0 ).
Parameters:
Replay all recorded painter commands. The graphic is scaled to fit into the given rectangle
Parameters:
Replay all recorded painter commands. The graphic is scaled to the defaultSize() and aligned to a position.
Parameters:
Clear all stored commands.
See also:
Calculate the target rectangle for scaling the graphic.
Parameters:
Note:
Returns:
See also:
Append paint commands.
Parameters:
See also:
Set a default size. The default size is used in all methods rendering the graphic, where no size is explicitly specified. Assigning an empty size means, that the default size will be calculated from the bounding rectangle.
The default setting is an empty size.
Parameters:
See also:
Toggle an render hint
Parameters:
See also:
Returns:
Implements QwtNullPaintDevice.
Test a render hint
Parameters:
Returns:
See also:
Convert the graphic to a QImage. All pixels of the image get initialized by 0 ( transparent ) before the graphic is scaled and rendered on it.
The format of the image is QImage::Format_ARGB32_Premultiplied.
The size of the image is the default size ( ceiled to integers ) of the graphic.
Returns:
See also:
Convert the graphic to a QImage. All pixels of the image get initialized by 0 ( transparent ) before the graphic is scaled and rendered on it.
The format of the image is QImage::Format_ARGB32_Premultiplied.
Parameters:
Returns:
See also:
Convert the graphic to a QPixmap. All pixels of the pixmap get initialized by Qt::transparent before the graphic is scaled and rendered on it.
The size of the pixmap is the default size ( ceiled to integers ) of the graphic.
Returns:
See also:
Convert the graphic to a QPixmap. All pixels of the pixmap get initialized by Qt::transparent before the graphic is scaled and rendered on it.
Parameters:
Returns:
See also:
Store a state command in the command list.
Parameters:
See also:
Reimplemented from QwtNullPaintDevice.
Generated automatically by Doxygen for Qwt User's Guide from the source code.
Wed Jan 2 2019 | Version 6.1.4 |