QSkinny 0.8.0
C++/Qt UI toolkit
|
A paint device for scalable graphics. More...
#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 : quint8 { RenderPensUnscaled = 1 << 0 } |
enum | CommandType : quint8 { VectorData = 1 << 0 , RasterData = 1 << 1 , Transformation = 1 << 2 } |
typedef QFlags< RenderHint > | RenderHints |
typedef QFlags< CommandType > | CommandTypes |
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 &) |
virtual void | addCommand (const QskPainterCommand &) |
Properties | |
qreal | aspectRatio |
QRectF | viewBox |
QRectF | boundingRect |
QRectF | controlPointRect |
QSizeF | defaultSize |
quint64 | modificationId |
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 : quint8 |
Definition at line 48 of file QskGraphic.h.
enum QskGraphic::RenderHint : quint8 |
Definition at line 41 of file QskGraphic.h.
QskGraphic::QskGraphic | ( | ) |
Definition at line 393 of file QskGraphic.cpp.
QskGraphic::QskGraphic | ( | const QskGraphic & | other | ) |
Definition at line 399 of file QskGraphic.cpp.
QskGraphic::QskGraphic | ( | QskGraphic && | other | ) |
Definition at line 406 of file QskGraphic.cpp.
|
override |
Definition at line 412 of file QskGraphic.cpp.
|
protectedvirtual |
Definition at line 984 of file QskGraphic.cpp.
qreal QskGraphic::aspectRatio | ( | ) | const |
Definition at line 634 of file QskGraphic.cpp.
QRectF QskGraphic::boundingRect | ( | ) | const |
Definition at line 558 of file QskGraphic.cpp.
const QVector< QskPainterCommand > & QskGraphic::commands | ( | ) | const |
Definition at line 1018 of file QskGraphic.cpp.
QskGraphic::CommandTypes QskGraphic::commandTypes | ( | ) | const |
Definition at line 535 of file QskGraphic.cpp.
QRectF QskGraphic::controlPointRect | ( | ) | const |
Definition at line 566 of file QskGraphic.cpp.
QSizeF QskGraphic::defaultSize | ( | ) | const |
Definition at line 608 of file QskGraphic.cpp.
|
protectedvirtual |
Definition at line 949 of file QskGraphic.cpp.
|
protectedvirtual |
Definition at line 904 of file QskGraphic.cpp.
|
protectedvirtual |
Definition at line 934 of file QskGraphic.cpp.
|
static |
Definition at line 1108 of file QskGraphic.cpp.
|
static |
Definition at line 1063 of file QskGraphic.cpp.
|
static |
Definition at line 1077 of file QskGraphic.cpp.
|
static |
Definition at line 1091 of file QskGraphic.cpp.
QskHashValue QskGraphic::hash | ( | QskHashValue | seed | ) | const |
Definition at line 1055 of file QskGraphic.cpp.
qreal QskGraphic::heightForWidth | ( | qreal | width | ) | const |
Definition at line 616 of file QskGraphic.cpp.
bool QskGraphic::isEmpty | ( | ) | const |
Definition at line 530 of file QskGraphic.cpp.
bool QskGraphic::isNull | ( | ) | const |
Definition at line 525 of file QskGraphic.cpp.
|
override |
Definition at line 446 of file QskGraphic.cpp.
quint64 QskGraphic::modificationId | ( | ) | const |
Definition at line 1050 of file QskGraphic.cpp.
|
inline |
Definition at line 164 of file QskGraphic.h.
QskGraphic & QskGraphic::operator= | ( | const QskGraphic & | other | ) |
Definition at line 417 of file QskGraphic.cpp.
QskGraphic & QskGraphic::operator= | ( | QskGraphic && | other | ) |
Definition at line 426 of file QskGraphic.cpp.
bool QskGraphic::operator== | ( | const QskGraphic & | other | ) | const |
Definition at line 433 of file QskGraphic.cpp.
|
override |
Definition at line 438 of file QskGraphic.cpp.
void QskGraphic::render | ( | QPainter * | painter | ) | const |
Definition at line 643 of file QskGraphic.cpp.
void QskGraphic::render | ( | QPainter * | painter, |
const QPointF & | pos, | ||
Qt::Alignment | alignment = Qt::AlignTop | Qt::AlignLeft |
||
) | const |
Definition at line 774 of file QskGraphic.cpp.
void QskGraphic::render | ( | QPainter * | painter, |
const QRectF & | rect, | ||
const QskColorFilter & | colorFilter, | ||
Qt::AspectRatioMode | aspectRatioMode = Qt::IgnoreAspectRatio |
||
) | const |
Definition at line 684 of file QskGraphic.cpp.
void QskGraphic::render | ( | QPainter * | painter, |
const QRectF & | rect, | ||
Qt::AspectRatioMode | aspectRatioMode = Qt::IgnoreAspectRatio |
||
) | const |
Definition at line 678 of file QskGraphic.cpp.
void QskGraphic::render | ( | QPainter * | painter, |
const QSizeF & | size, | ||
Qt::AspectRatioMode | aspectRatioMode = Qt::IgnoreAspectRatio |
||
) | const |
Definition at line 671 of file QskGraphic.cpp.
void QskGraphic::render | ( | QPainter * | painter, |
const QskColorFilter & | colorFilter, | ||
QTransform * | initialTransform = nullptr |
||
) | const |
Definition at line 648 of file QskGraphic.cpp.
QskGraphic::RenderHints QskGraphic::renderHints | ( | ) | const |
Definition at line 553 of file QskGraphic.cpp.
void QskGraphic::reset | ( | ) |
Definition at line 515 of file QskGraphic.cpp.
QRectF QskGraphic::scaledBoundingRect | ( | qreal | sx, |
qreal | sy | ||
) | const |
Definition at line 574 of file QskGraphic.cpp.
void QskGraphic::setCommands | ( | const QVector< QskPainterCommand > & | commands | ) |
Definition at line 1023 of file QskGraphic.cpp.
void QskGraphic::setRenderHint | ( | RenderHint | hint, |
bool | on = true |
||
) |
Definition at line 540 of file QskGraphic.cpp.
void QskGraphic::setViewBox | ( | const QRectF & | rect | ) |
Definition at line 598 of file QskGraphic.cpp.
|
protectedvirtual |
Definition at line 592 of file QskGraphic.cpp.
bool QskGraphic::testRenderHint | ( | RenderHint | hint | ) | const |
Definition at line 548 of file QskGraphic.cpp.
QImage QskGraphic::toImage | ( | const QSize & | size, |
Qt::AspectRatioMode | aspectRatioMode = Qt::IgnoreAspectRatio , |
||
qreal | devicePixelRatio = 0.0 |
||
) | const |
Definition at line 856 of file QskGraphic.cpp.
QImage QskGraphic::toImage | ( | qreal | devicePixelRatio = 0.0 | ) | const |
Definition at line 878 of file QskGraphic.cpp.
QPixmap QskGraphic::toPixmap | ( | const QSize & | size, |
Qt::AspectRatioMode | aspectRatioMode = Qt::IgnoreAspectRatio , |
||
qreal | devicePixelRatio = 0.0 |
||
) | const |
Definition at line 834 of file QskGraphic.cpp.
QPixmap QskGraphic::toPixmap | ( | qreal | devicePixelRatio = 0.0 | ) | const |
Definition at line 808 of file QskGraphic.cpp.
|
protectedvirtual |
Definition at line 965 of file QskGraphic.cpp.
QRectF QskGraphic::viewBox | ( | ) | const |
Definition at line 603 of file QskGraphic.cpp.
qreal QskGraphic::widthForHeight | ( | qreal | height | ) | const |
Definition at line 625 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.