-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphics_view.h
69 lines (52 loc) · 1.36 KB
/
graphics_view.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
#ifndef GRAPHICS_VIEW_H
#define GRAPHICS_VIEW_H
#include <QGraphicsView>
#include <QFont>
#include <set>
#include <memory>
#include <vector>
#include "types.h"
#include <optional>
struct Node {
Node(size_t index, QGraphicsItem* item, std::shared_ptr<Event> event):
event_index(index),
view(item),
event(event)
{
}
size_t event_index;
QGraphicsItem* view;
std::shared_ptr<Event> event;
std::vector<std::weak_ptr<Node>> children;
std::weak_ptr<Node> parent;
QColor colour;
};
class graphics_view: public QGraphicsView
{
Q_OBJECT
public:
graphics_view(QWidget *parent=0);
void apply_zoom(qreal amount);
void pan(qreal dx, qreal dy);
void create_scene(const std::vector<std::shared_ptr<Event>>& events);
void layout_scene();
public slots:
void reset();
void move_left();
void move_pid_left();
void move_right();
void move_pid_right();
void deselect();
void next_failure();
protected:
void highlight_selected();
void mousePressEvent(QMouseEvent *event) override;
std::optional<size_t> selected_node;
size_t pid_count = 0;
std::vector<std::shared_ptr<Node>> nodes;
std::set<size_t> markers;
std::map<QGraphicsItem*, size_t> event_indexes;
QFont render_font;
std::vector<std::weak_ptr<Node>> bad_nodes;
};
#endif // GRAPHICS_VIEW_H