-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplay.h
72 lines (60 loc) · 2.03 KB
/
display.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
#ifndef DISPLAY_H
#define DISPLAY_H
#include <QGraphicsScene>
#include <vector>
#include <map>
#include <QGraphicsView>
#include <QGraphicsPixmapItem>
#include <QGraphicsSceneMouseEvent>
#define WINDOWW 400
#define WINDOWH 300
struct Point{
int x;
int y;
};
class Interface;
class Display : public QGraphicsScene
{
public:
Display(QObject *parent);
void init(QGraphicsView* view, std::vector<int> state, Interface *interface);
void leftClick(int x, int y);
void rightClick(int x, int y);
void move(int x, int y);
void leftRelease(int x, int y);
void rightRelease();
void update(std::vector<int> state);
bool isMouseHoverRobot(int x, int y);
int isMouseHoverObject(int x, int y);
void exchangeImage(int id);
void highlightImage(QGraphicsPixmapItem* image, bool highlight);
void rotateHead(float angle);
void enableGUI(bool enable);
void cleanGUI();
private:
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
Interface* _interface;
std::vector<QGraphicsPixmapItem*> _images;
std::vector<QGraphicsPixmapItem*> _activeObjects;
std::vector<std::string> _imagesNames; //{"background","robot","flour","eggs","spoon","bowl","bowlFlour","bowlEggs","bowlBoth","bowlMixed","tray","trayBatter"}
std::map<std::string, int> _imagesInv;
std::vector<std::vector<Point>> _locationsObjects; //
std::vector<Point> _locationsRobot;
std::vector<Point> _offsetHead;
std::vector<std::vector<int>> _sizes;
std::vector<int> _rotationRobot;
std::vector<int> _lastState; //{Lr, Lf, Le, Ls, Lb, Lt, Sb, St}
QGraphicsRectItem* _cadre;
QGraphicsRectItem* _filing;
QGraphicsRectItem* _rectangle;
Point _rotationCentre;
int _cadreX;
int _cadreY;
int _currentHover;
bool _leftPressed;
bool _rightPressed;
bool _disabled;
};
#endif // DISPLAY_H