-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoile.h
81 lines (70 loc) · 1.98 KB
/
toile.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifndef TOILE_H
#define TOILE_H
#include<QWidget>
#include<QPoint>
#include<QBrush>
#include<QGraphicsScene>
#include<QPainterPath>
#include<QMenu>
class Toile : public QWidget
{
Q_OBJECT
public:
explicit Toile(QWidget *parent = nullptr);
enum Etats{
Select = 0,
Line = 1,
PolyLine = 2,
Circle = 3,
Ellipse = 4,
Square = 5,
Rectangle = 6
};
private:
QList<QPainterPath> pathContiner;
QList<QPen> displayList;
QList<QString> pathNameList;
/** Select fonction **/
void createSelectMenu();
QList<QAction> selectedAction;
QMenu selectedMenu;
QActionGroup* selectAG = nullptr;
bool findSelectedObjects(QPoint position);
/** propriety of line*/
Qt::PenStyle penStyle = Qt::SolidLine;
QBrush color = Qt::red;
Qt::PenJoinStyle joinStyle = Qt::RoundJoin;
Qt::PenCapStyle capStyle = Qt::RoundCap;
int lineWidth = 3;
int etat = Line;
/** mouseZone reprensent the area selected by the mouse **/
QRect mouseZone;
/** rayon reprensent the radius of mouse zone **/
const int rayon = 5;
QPoint start_point;
QPoint end_point;
QPen pen;
QPainterPath* currentPath = nullptr;
QPen* currentPen = nullptr;
QPainterPath* polyLinePath = nullptr;
bool findSelectedObject();
void updateMouseZone(QPoint position);
protected:
virtual void paintEvent(QPaintEvent* e);
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseDoubleClickEvent(QMouseEvent *event);
signals:
void objectSelected(QPen* pen);
public slots:
void modifyPathList(QAction* action);
void changeColor(int colorIndex);
void changeTypeOfLine(int typeIndex);
void changeJoinStyle(int typeIndex);
void changeCapStyle(int typeIndex);
void changeEtat(int etat );
void changeLineWidth(int width);
void selectObject(QAction* action);
};
#endif // CANVAS_H