-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathparkinglotgraph.h
62 lines (56 loc) · 1.56 KB
/
parkinglotgraph.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
#ifndef PARKINGLOTGRAPH_H
#define PARKINGLOTGRAPH_H
#include "Road.h"
#include "ParkingSpaceWidget.h"
#include "path.h"
#include <QVector>
#include <QPoint>
#include <QGraphicsScene>
#include <QMap>
#include <QPixmap>
#include "Road.h"
#include "car.h"
class Car;
class ParkingLotGraph
{
public:
struct Node{
public:
enum Type{entry = 1, stair, exit, queueHead, space, road, act};
Node(const QPoint& p, Type t, uint n, int idd) : number(n), id(idd), type(t), data(p) {}
void addPath(Node* another);
uint number;
int id;
Type type;
QPoint data;
Road::Action action = Road::Action::none;
QVector<Node*> adjacent;
QVector<float> weight;
int getId() const;
Road::Action getAction() const;
void setAction(const Road::Action &value) {
action = value;
}
};
ParkingLotGraph(const ParkingLotWidget*pkl);
Node* addNode(QPoint p, Node::Type t, uint n) {
Node* no = new Node(p, t, n, m_all.size());
m_all.push_back(no);
return no;
}
void paint(QGraphicsScene* scene);
Path* findPath(Node::Type t1, int n1, Node::Type t2, int n2);
Path* findPath(Car* car, int entry);
uint getNodeId(Node::Type t, int n);
~ParkingLotGraph();
QPixmap *getPixmap();
private:
QVector<Node* > m_all;
QVector<Node* > m_spaceList;
QVector<Node* > m_roadNodeList;
QVector<Node* > m_actionList;
QPixmap* m_pixmap = nullptr;
void generatePixmap();
const ParkingLotWidget* pk;
};
#endif // PARKINGLOTGRAPH_H