File indexing completed on 2024-05-19 03:53:36

0001 #ifndef IMAGEPAINTER_H
0002 #define IMAGEPAINTER_H
0003 
0004 #include "ui/container.h"
0005 #include "ui/painter.h"
0006 
0007 #include <QVector>
0008 
0009 class ImagePainter : public Painter
0010 {
0011 public:
0012     /** Shape of the painter. */
0013     enum class Shape {
0014         Polygon,
0015         Rectangle
0016     };
0017 
0018     explicit ImagePainter(Container* parent);
0019     ~ImagePainter();
0020     
0021     void paint(QPoint point, bool isDragging) override;
0022     void paintObject(MarkedObject* object) override;
0023     void repaint() override;
0024     void undo() override;
0025     void deleteCurrentObject() override;
0026     void changeItem(const QString& filepath) override;
0027 
0028     bool importObjects(QVector<MarkedObject*> objects) override;
0029     
0030     void setShape(Shape shape) { m_shape = shape; m_parent->currentObject()->clear(); repaint(); }
0031 
0032     void zoomIn();
0033     void zoomOut();
0034     void scaleImage(double factor);
0035 
0036 private:
0037     QVector<QGraphicsItem*> m_items;
0038     QGraphicsItem* m_currentItem;
0039     qreal m_scaleW;
0040     qreal m_scaleH;
0041 
0042     Shape m_shape;
0043 
0044     QString m_filepath;
0045 };
0046 
0047 #endif // IMAGEPAINTER_H