-
Notifications
You must be signed in to change notification settings - Fork 1
/
mapview.h
99 lines (70 loc) · 1.99 KB
/
mapview.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef MAPVIEW_H
#define MAPVIEW_H
#include "map.h"
#include <QWidget>
class MapView : public QWidget
{
Q_OBJECT
public:
explicit MapView(QWidget *parent, Map *map);
~MapView();
void setMap(Map* map);
void setMode(int mode);
void setCurrentAnimPath(int animPath);
float getZoom() { return zoom; }
void setZoom(float zoom);
void zoomIn();
void zoomOut();
void zoomMax();
void zoomMin();
void toggleGrid(bool toggle) { showGrid = toggle; repaint(); }
void setNodeWidth(int width);
int getCenterX() { return centerX; }
int getCenterY() { return centerY; }
QPoint getCurrentPos();
signals:
void scrollTo(int x, int y);
void scrollTo(QPoint p);
void scrollTo_(int x, int y);
void changeSelectedNode(Node* node);
void changeDeselectedNode();
void changeSelectedMapObj(MapObject* mapObj);
void changeDeselectedMapObj();
void changeSelectedKeyframe(Keyframe* keyframe);
void changeDeselectedKeyframe();
public slots:
void viewAreaResized(QResizeEvent* evt);
void select(MovableObject* obj);
void deselect();
protected:
void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE;
void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE;
void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE;
private:
Map* map;
int mode;
MovableObject* selectedObj;
bool selected;
int currentAnimPath;
bool drag;
int dragX, dragY;
int lastX, lastY;
int sDragX, sDragY;
float zoom;
bool showGrid;
int gridSize;
int centerX;
int centerY;
int roundDown(int num, int factor);
QPolygon keyframeShape;
QPainterPath keyframeShapeL;
QPainterPath keyframeShapeR;
QPoint tempPos;
QPointF rotateArroundPoint(QPointF point, QPointF center, float angle);
int round(int number, int multiple)
{
return (number + (multiple / 2)) / multiple * multiple;
}
};
#endif // MAPVIEW_H