-
Notifications
You must be signed in to change notification settings - Fork 1
/
canvas.h
42 lines (35 loc) · 938 Bytes
/
canvas.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
#ifndef CANVAS_H
#define CANVAS_H
#include <QWidget>
#include <vector>
#include <map>
#include "drawdatatype.h"
#include "Single-Lane-Bridge/singlelanebridge.h"
class Canvas : public QWidget
{
Q_OBJECT
public:
explicit Canvas(QWidget *parent = nullptr);
void drawSingleLaneBridge();
signals:
void carWidthChange(int);
public slots:
void updateCanvas();
void setObjects(int id, int pos);
void deleteObject(int id);
private:
int width; // Canvas's width
int height; // Canvas's height
int carWidth;
int carHeight;
int upLanePos, downLanePos, midLanePos;
const int laneWidth = 60; // Bridge's lane width
const int lanePadding = 5;
std::vector<Line> _solidLines;
std::vector<Line> _dottedLines;
std::map<int, Object> objects;
void resizeEvent(QResizeEvent *event);
QWidget *createCanvasWidget();
void paintEvent(QPaintEvent *event);
};
#endif // CANVAS_H