-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathitem.h
41 lines (34 loc) · 1.05 KB
/
item.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef ITEM_H
#define ITEM_H
#include <QGraphicsItem>
#include <QTreeWidgetItem>
class Scene;
class Item : public QGraphicsItem{
public:
enum Type{
LINE,
RECT,
CIRCLE,
ELLIPSE,
INVALID
};
Item(Scene *scene = nullptr, QGraphicsItem *parent = nullptr);
virtual Type getType() const {return INVALID;}
virtual QColor getFillColor() const;
virtual void reDraw();
void setBrush(const QBrush &value);
QColor getColor() const;
protected:
QPoint toScenePos(const QPoint &userPos) const;
QBrush brush = QBrush(Qt::black);
QPainterPath path;
Scene *scene;
QPainterPath shape() const override;
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
void drawPixel(int x, int y);
void drawPixel(const QPoint &p);
void drawPixel(int x, int y, QPainterPath &painterPath);
void drawPixel(const QPoint &p, QPainterPath &painterPath);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
};
#endif // ITEM_H