X-Git-Url: https://git.sven.stormbind.net/?a=blobdiff_plain;f=src%2Fimageobj.h;fp=src%2Fimageobj.h;h=6795a178428c665c3b70aa8bc5ce4a26fc093c6d;hb=d483bd8e6523c23c6f1d8908a2e0611c2bc9ff4f;hp=0000000000000000000000000000000000000000;hpb=7dfa3fe589d1722d49681f42cdb0bf1e6efb5223;p=sven%2Fvym.git diff --git a/src/imageobj.h b/src/imageobj.h new file mode 100644 index 0000000..6795a17 --- /dev/null +++ b/src/imageobj.h @@ -0,0 +1,52 @@ +#ifndef IMAGEOBJ_H +#define IMAGEOBJ_H + +#include +#include +#include + +/*! \brief Base class for images, which can be pixmaps or svg + * + * ImageObj is used both by items part of the map "tree" in + * ImageItem and as flag in FlagObj + * + * Both of these types are actually drawn onto the map + */ + +class ImageObj : public QGraphicsItem { + public: + enum ImageType { Undefined, Pixmap, SVG, ClonedSVG }; + + ImageObj(); + ImageObj(QGraphicsItem *); + ~ImageObj(); + void init(); + void copy(ImageObj *); + void setPos(const QPointF &pos); + void setPos(const qreal &x, const qreal &y); + void setZValue(qreal z); + void setVisibility(bool); + void setWidth(qreal w); + void setScaleFactor(qreal f); + qreal getScaleFactor(); + virtual QRectF boundingRect() const; + virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); + bool load(const QString &, bool createClone = false); + bool save(const QString &); + QString getExtension(); + ImageType getType(); + QIcon getIcon(); + + protected: + ImageObj::ImageType imageType; + + QGraphicsSvgItem *svgItem; + QString svgCachePath; + + QGraphicsPixmapItem *pixmapItem; + + qreal scaleFactor; + + ulong imageID; +}; +#endif