A paint device for scalable graphics. More…
#include <QskGraphic.h>
Inherits from QPaintDevice
Name | |
---|---|
enum | RenderHint { RenderPensUnscaled = 0x1} |
enum | CommandType { VectorData = 1 « 0, RasterData = 1 « 1, Transformation = 1 « 2} |
typedef QFlags< RenderHint > | RenderHints |
typedef QFlags< CommandType > | CommandTypes |
Name | ||
---|---|---|
QskGraphic() | ||
QskGraphic(const QskGraphic & other) | ||
QskGraphic(QskGraphic && other) | ||
~QskGraphic() override | ||
QskGraphic & | operator=(const QskGraphic & other) | |
QskGraphic & | operator=(QskGraphic && other) | |
bool | operator==(const QskGraphic & other) const | |
bool | operator!=(const QskGraphic & other) const | |
void | reset() | |
bool | isNull() const | |
bool | isEmpty() const | |
CommandTypes | commandTypes() const | |
void | render(QPainter * painter) const | |
void | render(QPainter * painter, const QskColorFilter & colorFilter, QTransform * initialTransform =nullptr) const | |
void | render(QPainter * painter, const QSizeF & size, Qt::AspectRatioMode aspectRatioMode =Qt::IgnoreAspectRatio) const | |
void | render(QPainter * painter, const QPointF & pos, Qt::Alignment alignment =Qt::AlignTop | Qt::AlignLeft) const |
void | render(QPainter * painter, const QRectF & rect, Qt::AspectRatioMode aspectRatioMode =Qt::IgnoreAspectRatio) const | |
void | render(QPainter * painter, const QRectF & rect, const QskColorFilter & colorFilter, Qt::AspectRatioMode aspectRatioMode =Qt::IgnoreAspectRatio) const | |
QPixmap | toPixmap(qreal devicePixelRatio =0.0) const | |
QPixmap | toPixmap(const QSize & size, Qt::AspectRatioMode aspectRatioMode =Qt::IgnoreAspectRatio, qreal devicePixelRatio =0.0) const | |
QImage | toImage(qreal devicePixelRatio =0.0) const | |
QImage | toImage(const QSize & size, Qt::AspectRatioMode aspectRatioMode =Qt::IgnoreAspectRatio, qreal devicePixelRatio =0.0) const | |
QRectF | scaledBoundingRect(qreal sx, qreal sy) const | |
QRectF | boundingRect() const | |
QRectF | controlPointRect() const | |
const QVector< QskPainterCommand > & | commands() const | |
void | setCommands(const QVector< QskPainterCommand > & commands) | |
void | setDefaultSize(const QSizeF & size) | |
QSizeF | defaultSize() const | |
qreal | heightForWidth(qreal width) const | |
qreal | widthForHeight(qreal height) const | |
void | setRenderHint(RenderHint hint, bool on =true) | |
bool | testRenderHint(RenderHint hint) const | |
RenderHints | renderHints() const | |
QPaintEngine * | paintEngine() const override | |
int | metric(PaintDeviceMetric metric) const override | |
quint64 | modificationId() const | |
uint | hash(uint seed) const | |
QskGraphic | fromImage(const QImage & image) | |
QskGraphic | fromPixmap(const QPixmap & pixmap) | |
QskGraphic | fromPixmapAsImage(const QPixmap & pixmap) |
Name | |
---|---|
virtual QSize | sizeMetrics() const |
virtual void | drawPath(const QPainterPath & path) |
virtual void | drawPixmap(const QRectF & rect, const QPixmap & pixmap, const QRectF & subRect) |
virtual void | drawImage(const QRectF & rect, const QImage & image, const QRectF & subRect, Qt::ImageConversionFlags flags) |
virtual void | updateState(const QPaintEngineState & state) |
Name | |
---|---|
class | QskGraphicPaintEngine |
class QskGraphic;
A paint device for scalable graphics.
QskGraphic 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. It can be stored and loaded from disk using the operators from QskGraphicIO. Together with QSvgRenderer it can be used to implement a simple SVG compiler.
QskGraphic maps all scalable drawing primitives to a QPainterPath and stores them together with the painter state changes ( pen, brush, transformation … ) in a list of QskPainterCommand. 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 QskGraphic 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.
QskGraphic caches 2 different rectangles:
The control point rectangle is the bounding rectangle of all control point rectangles of the painter paths, or the target rectangle of the pixmaps/images.
The bounding rectangle extends the control point rectangle by what is needed for rendering the outline with an unscaled pen. 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.
Enumerator | Value | Description |
---|---|---|
RenderPensUnscaled | 0x1 |
Enumerator | Value | Description |
---|---|---|
VectorData | 1 « 0 | |
RasterData | 1 « 1 | |
Transformation | 1 « 2 |
typedef QFlags< RenderHint > QskGraphic::RenderHints;
typedef QFlags< CommandType > QskGraphic::CommandTypes;
QskGraphic()
QskGraphic(
const QskGraphic & other
)
QskGraphic(
QskGraphic && other
)
~QskGraphic() override
QskGraphic & operator=(
const QskGraphic & other
)
QskGraphic & operator=(
QskGraphic && other
)
bool operator==(
const QskGraphic & other
) const
inline bool operator!=(
const QskGraphic & other
) const
void reset()
bool isNull() const
bool isEmpty() const
CommandTypes commandTypes() const
void render(
QPainter * painter
) const
void render(
QPainter * painter,
const QskColorFilter & colorFilter,
QTransform * initialTransform =nullptr
) const
void render(
QPainter * painter,
const QSizeF & size,
Qt::AspectRatioMode aspectRatioMode =Qt::IgnoreAspectRatio
) const
void render(
QPainter * painter,
const QPointF & pos,
Qt::Alignment alignment =Qt::AlignTop|Qt::AlignLeft
) const
void render(
QPainter * painter,
const QRectF & rect,
Qt::AspectRatioMode aspectRatioMode =Qt::IgnoreAspectRatio
) const
void render(
QPainter * painter,
const QRectF & rect,
const QskColorFilter & colorFilter,
Qt::AspectRatioMode aspectRatioMode =Qt::IgnoreAspectRatio
) const
QPixmap toPixmap(
qreal devicePixelRatio =0.0
) const
QPixmap toPixmap(
const QSize & size,
Qt::AspectRatioMode aspectRatioMode =Qt::IgnoreAspectRatio,
qreal devicePixelRatio =0.0
) const
QImage toImage(
qreal devicePixelRatio =0.0
) const
QImage toImage(
const QSize & size,
Qt::AspectRatioMode aspectRatioMode =Qt::IgnoreAspectRatio,
qreal devicePixelRatio =0.0
) const
QRectF scaledBoundingRect(
qreal sx,
qreal sy
) const
QRectF boundingRect() const
QRectF controlPointRect() const
const QVector< QskPainterCommand > & commands() const
void setCommands(
const QVector< QskPainterCommand > & commands
)
void setDefaultSize(
const QSizeF & size
)
QSizeF defaultSize() const
qreal heightForWidth(
qreal width
) const
qreal widthForHeight(
qreal height
) const
void setRenderHint(
RenderHint hint,
bool on =true
)
bool testRenderHint(
RenderHint hint
) const
RenderHints renderHints() const
QPaintEngine * paintEngine() const override
int metric(
PaintDeviceMetric metric
) const override
quint64 modificationId() const
uint hash(
uint seed
) const
static QskGraphic fromImage(
const QImage & image
)
static QskGraphic fromPixmap(
const QPixmap & pixmap
)
static QskGraphic fromPixmapAsImage(
const QPixmap & pixmap
)
virtual QSize sizeMetrics() const
virtual void drawPath(
const QPainterPath & path
)
virtual void drawPixmap(
const QRectF & rect,
const QPixmap & pixmap,
const QRectF & subRect
)
virtual void drawImage(
const QRectF & rect,
const QImage & image,
const QRectF & subRect,
Qt::ImageConversionFlags flags
)
virtual void updateState(
const QPaintEngineState & state
)
friend class QskGraphicPaintEngine(
QskGraphicPaintEngine
);
Updated on 28 July 2023 at 14:02:29 CEST