QSkinny 0.8.0
C++/Qt UI toolkit
|
#include <QskGraphic.h>
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:
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.
Definition at line 27 of file QskGraphic.h.
Public Types | |
enum | RenderHint { RenderPensUnscaled = 0x1 } |
enum | CommandType { VectorData = 1 << 0 , RasterData = 1 << 1 , Transformation = 1 << 2 } |
typedef QFlags< RenderHint > | RenderHints |
typedef QFlags< CommandType > | CommandTypes |
Properties | |
qreal | aspectRatio |
QRectF | viewBox |
QRectF | boundingRect |
QRectF | controlPointRect |
QSizeF | defaultSize |
quint64 | modificationId |
Public Member Functions | |
QskGraphic (const QskGraphic &) | |
QskGraphic (QskGraphic &&) | |
QskGraphic & | operator= (const QskGraphic &) |
QskGraphic & | operator= (QskGraphic &&) |
bool | operator== (const QskGraphic &) const |
bool | operator!= (const QskGraphic &) const |
void | reset () |
bool | isNull () const |
bool | isEmpty () const |
CommandTypes | commandTypes () const |
void | render (QPainter *) const |
void | render (QPainter *, const QskColorFilter &, QTransform *initialTransform=nullptr) const |
void | render (QPainter *, const QSizeF &, Qt::AspectRatioMode=Qt::IgnoreAspectRatio) const |
void | render (QPainter *, const QPointF &, Qt::Alignment=Qt::AlignTop|Qt::AlignLeft) const |
void | render (QPainter *, const QRectF &, Qt::AspectRatioMode=Qt::IgnoreAspectRatio) const |
void | render (QPainter *, const QRectF &, const QskColorFilter &, Qt::AspectRatioMode=Qt::IgnoreAspectRatio) const |
QPixmap | toPixmap (qreal devicePixelRatio=0.0) const |
QPixmap | toPixmap (const QSize &, Qt::AspectRatioMode=Qt::IgnoreAspectRatio, qreal devicePixelRatio=0.0) const |
QImage | toImage (qreal devicePixelRatio=0.0) const |
QImage | toImage (const QSize &, Qt::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 > &) |
QSizeF | defaultSize () const |
void | setViewBox (const QRectF &) |
QRectF | viewBox () const |
qreal | aspectRatio () const |
qreal | heightForWidth (qreal width) const |
qreal | widthForHeight (qreal height) const |
void | setRenderHint (RenderHint, bool on=true) |
bool | testRenderHint (RenderHint) const |
RenderHints | renderHints () const |
QPaintEngine * | paintEngine () const override |
int | metric (PaintDeviceMetric metric) const override |
quint64 | modificationId () const |
QskHashValue | hash (QskHashValue seed) const |
Static Public Member Functions | |
static QskGraphic | fromImage (const QImage &) |
static QskGraphic | fromPixmap (const QPixmap &) |
static QskGraphic | fromPixmapAsImage (const QPixmap &) |
static QskGraphic | fromGraphic (const QskGraphic &, const QskColorFilter &) |
Protected Member Functions | |
virtual QSize | sizeMetrics () const |
virtual void | drawPath (const QPainterPath &) |
virtual void | drawPixmap (const QRectF &, const QPixmap &, const QRectF &) |
virtual void | drawImage (const QRectF &, const QImage &, const QRectF &, Qt::ImageConversionFlags) |
virtual void | updateState (const QPaintEngineState &state) |
typedef QFlags< CommandType > QskGraphic::CommandTypes |
Definition at line 55 of file QskGraphic.h.
typedef QFlags< RenderHint > QskGraphic::RenderHints |
Definition at line 46 of file QskGraphic.h.
enum QskGraphic::CommandType |
Definition at line 48 of file QskGraphic.h.
enum QskGraphic::RenderHint |
Definition at line 41 of file QskGraphic.h.
QskGraphic::QskGraphic | ( | ) |
Definition at line 392 of file QskGraphic.cpp.
QskGraphic::QskGraphic | ( | const QskGraphic & | other | ) |
Definition at line 398 of file QskGraphic.cpp.
QskGraphic::QskGraphic | ( | QskGraphic && | other | ) |
Definition at line 405 of file QskGraphic.cpp.
|
override |
Definition at line 411 of file QskGraphic.cpp.
qreal QskGraphic::aspectRatio | ( | ) | const |
Definition at line 633 of file QskGraphic.cpp.
QRectF QskGraphic::boundingRect | ( | ) | const |
Definition at line 557 of file QskGraphic.cpp.
const QVector< QskPainterCommand > & QskGraphic::commands | ( | ) | const |
Definition at line 1012 of file QskGraphic.cpp.
QskGraphic::CommandTypes QskGraphic::commandTypes | ( | ) | const |
Definition at line 534 of file QskGraphic.cpp.
QRectF QskGraphic::controlPointRect | ( | ) | const |
Definition at line 565 of file QskGraphic.cpp.
QSizeF QskGraphic::defaultSize | ( | ) | const |
Definition at line 607 of file QskGraphic.cpp.
|
protectedvirtual |
Definition at line 948 of file QskGraphic.cpp.
|
protectedvirtual |
Definition at line 903 of file QskGraphic.cpp.
|
protectedvirtual |
Definition at line 933 of file QskGraphic.cpp.
|
static |
Definition at line 1102 of file QskGraphic.cpp.
|
static |
Definition at line 1057 of file QskGraphic.cpp.
|
static |
Definition at line 1071 of file QskGraphic.cpp.
|
static |
Definition at line 1085 of file QskGraphic.cpp.
QskHashValue QskGraphic::hash | ( | QskHashValue | seed | ) | const |
Definition at line 1049 of file QskGraphic.cpp.
qreal QskGraphic::heightForWidth | ( | qreal | width | ) | const |
Definition at line 615 of file QskGraphic.cpp.
bool QskGraphic::isEmpty | ( | ) | const |
Definition at line 529 of file QskGraphic.cpp.
bool QskGraphic::isNull | ( | ) | const |
Definition at line 524 of file QskGraphic.cpp.
|
override |
Definition at line 445 of file QskGraphic.cpp.
quint64 QskGraphic::modificationId | ( | ) | const |
Definition at line 1044 of file QskGraphic.cpp.
|
inline |
Definition at line 162 of file QskGraphic.h.
QskGraphic & QskGraphic::operator= | ( | const QskGraphic & | other | ) |
Definition at line 416 of file QskGraphic.cpp.
QskGraphic & QskGraphic::operator= | ( | QskGraphic && | other | ) |
Definition at line 425 of file QskGraphic.cpp.
bool QskGraphic::operator== | ( | const QskGraphic & | other | ) | const |
Definition at line 432 of file QskGraphic.cpp.
|
override |
Definition at line 437 of file QskGraphic.cpp.
void QskGraphic::render | ( | QPainter * | painter | ) | const |
Definition at line 642 of file QskGraphic.cpp.
void QskGraphic::render | ( | QPainter * | painter, |
const QPointF & | pos, | ||
Qt::Alignment | alignment = Qt::AlignTop | Qt::AlignLeft |
||
) | const |
Definition at line 773 of file QskGraphic.cpp.
void QskGraphic::render | ( | QPainter * | painter, |
const QRectF & | rect, | ||
const QskColorFilter & | colorFilter, | ||
Qt::AspectRatioMode | aspectRatioMode = Qt::IgnoreAspectRatio |
||
) | const |
Definition at line 683 of file QskGraphic.cpp.
void QskGraphic::render | ( | QPainter * | painter, |
const QRectF & | rect, | ||
Qt::AspectRatioMode | aspectRatioMode = Qt::IgnoreAspectRatio |
||
) | const |
Definition at line 677 of file QskGraphic.cpp.
void QskGraphic::render | ( | QPainter * | painter, |
const QSizeF & | size, | ||
Qt::AspectRatioMode | aspectRatioMode = Qt::IgnoreAspectRatio |
||
) | const |
Definition at line 670 of file QskGraphic.cpp.
void QskGraphic::render | ( | QPainter * | painter, |
const QskColorFilter & | colorFilter, | ||
QTransform * | initialTransform = nullptr |
||
) | const |
Definition at line 647 of file QskGraphic.cpp.
QskGraphic::RenderHints QskGraphic::renderHints | ( | ) | const |
Definition at line 552 of file QskGraphic.cpp.
void QskGraphic::reset | ( | ) |
Definition at line 514 of file QskGraphic.cpp.
QRectF QskGraphic::scaledBoundingRect | ( | qreal | sx, |
qreal | sy | ||
) | const |
Definition at line 573 of file QskGraphic.cpp.
void QskGraphic::setCommands | ( | const QVector< QskPainterCommand > & | commands | ) |
Definition at line 1017 of file QskGraphic.cpp.
void QskGraphic::setRenderHint | ( | RenderHint | hint, |
bool | on = true |
||
) |
Definition at line 539 of file QskGraphic.cpp.
void QskGraphic::setViewBox | ( | const QRectF & | rect | ) |
Definition at line 597 of file QskGraphic.cpp.
|
protectedvirtual |
Definition at line 591 of file QskGraphic.cpp.
bool QskGraphic::testRenderHint | ( | RenderHint | hint | ) | const |
Definition at line 547 of file QskGraphic.cpp.
QImage QskGraphic::toImage | ( | const QSize & | size, |
Qt::AspectRatioMode | aspectRatioMode = Qt::IgnoreAspectRatio , |
||
qreal | devicePixelRatio = 0.0 |
||
) | const |
Definition at line 855 of file QskGraphic.cpp.
QImage QskGraphic::toImage | ( | qreal | devicePixelRatio = 0.0 | ) | const |
Definition at line 877 of file QskGraphic.cpp.
QPixmap QskGraphic::toPixmap | ( | const QSize & | size, |
Qt::AspectRatioMode | aspectRatioMode = Qt::IgnoreAspectRatio , |
||
qreal | devicePixelRatio = 0.0 |
||
) | const |
Definition at line 833 of file QskGraphic.cpp.
QPixmap QskGraphic::toPixmap | ( | qreal | devicePixelRatio = 0.0 | ) | const |
Definition at line 807 of file QskGraphic.cpp.
|
protectedvirtual |
Definition at line 964 of file QskGraphic.cpp.
QRectF QskGraphic::viewBox | ( | ) | const |
Definition at line 602 of file QskGraphic.cpp.
qreal QskGraphic::widthForHeight | ( | qreal | height | ) | const |
Definition at line 624 of file QskGraphic.cpp.
|
read |
Definition at line 31 of file QskGraphic.h.
|
read |
Definition at line 33 of file QskGraphic.h.
|
read |
Definition at line 34 of file QskGraphic.h.
|
read |
Definition at line 35 of file QskGraphic.h.
|
read |
Definition at line 36 of file QskGraphic.h.
|
readwrite |
Definition at line 32 of file QskGraphic.h.