forked from rpelorosso/pcb-tracer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotesTool.h
More file actions
62 lines (52 loc) · 1.5 KB
/
Copy pathNotesTool.h
File metadata and controls
62 lines (52 loc) · 1.5 KB
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
#ifndef NOTESTOOL_H
#define NOTESTOOL_H
#include <QGraphicsRectItem>
#include <QGraphicsTextItem>
#include <QColor>
#include <QUuid>
#include <QPointF>
#include <vector>
#include "IEditorTool.h"
class Editor;
class TextNote : public QGraphicsRectItem {
public:
TextNote(const QRectF& rect, const QColor& color, QGraphicsItem* parent = nullptr);
void setText(const QString& text);
void adjustTextPos();
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr) override;
QVariantMap toDict() const;
static TextNote* fromDict(const QVariantMap& data);
int m_id;
QColor m_color;
QGraphicsTextItem* m_textItem;
QString m_text;
};
class NotesTool : public IEditorTool {
public:
static int note_count;
NotesTool(Editor* editor);
void enterMode();
bool onMousePress(QMouseEvent* event);
bool onMouseMove(QMouseEvent* event);
bool onMouseRelease(QMouseEvent* event);
void startDrawing(QMouseEvent* event);
void updateDrawing(QMouseEvent* event);
void finishDrawing(QMouseEvent* event);
void deleteNote(QMouseEvent* event);
void cancelDrawing();
Editor* m_editor;
bool m_drawing;
TextNote* m_currentNote;
QPointF m_startPos;
std::vector<TextNote*> m_notes;
static int genNoteId() {
return ++note_count;
}
static int getLastNoteId() {
return note_count;
}
static void setNoteCount(int count) {
note_count = count;
}
};
#endif // NOTESTOOL_H