-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMetroSearch.h
131 lines (118 loc) · 3.36 KB
/
MetroSearch.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//MetroSearch.h
#pragma once
//对中文字符使用utf-8编码
#if defined(_MSC_VER) && (_MSC_VER >= 1600)
#pragma execution_character_set("utf-8")
#endif
#include<QtWidgets/QWidget>
#include<QDockWidget>
#include<QPushButton>
#include<QThread>
#include<QTimer>
#include<QLabel>
#include<QColor>
#include<QSize>
#include<QPainter>
#include<QPaintEvent>
#include<QLineEdit>
#include<QComboBox>
#include<QSlider>
#include<QDebug>
#include<QObject>
#include<QToolTip>
#include<QAbstractItemView>
#include<QAbstractItemModel>
#include<QStandardItem>
#include<QStyledItemDelegate>
#include<QMessageBox>
#include"ui_MetroSearch.h"
#include<iostream>
#include<fstream>
#include<sstream>
#include"Python.h"
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include"Line.h"
#include"Station.h"
#define MAXINT 10000000
const double MAXTRANSFERCOST = 4;
const double MAXSITESCOST = 1;
using namespace std;
enum paintType {
None = 0,
route,
map,
lineMap
};
class MetroSearch : public QWidget {
Q_OBJECT
public:
MetroSearch(QWidget* parent = nullptr);
~MetroSearch();
void initCityBox();
void initHistoryBox();
void buildNetwork();
void dijkstraSearch(int startIndex);
string terminalDirection(int startIndex, int nextIndex);
private:
Ui::MetroSearchClass ui;
QComboBox* chooseCity, * chooseStartLine, * chooseStartStation;
QComboBox* chooseEndLine, * chooseEndStation, * lineBox;
QComboBox* historyBox;
QPushButton* searchButton, * exchangeButton, * switchButton;
QPushButton* lineButton, * updateButton, * historyButton;
QSlider* transferCostSlider, * sitesCostSlider;
QLabel* cityIntro, * startLineIntro, * startStationIntro;
QLabel* endLineIntro, * endStationIntro;
QLabel* leftTransfer, * rightTransfer;
QLabel* leftSites, * rightSites;
QLabel* updateLabel, * historyLabel;
QLabel* metroIconLabel, * metroIconLabel2, * metroIconLabel3, * cityIcon;
QFont ft, exchangeFt, sliderFt;
QTimer timer;
bool isPaintRoute, isPaintMap;
int canvasH, canvasW, historyCapacity;
vector<string> cityListEng, cityList;
vector<Line*> lineList;
vector<Station*> stationList;
vector<QPoint> pointPath;
QRect paintArea;
int action, state;
int stationCount;
int schemeIndex;
double transferCost; //换乘代价
double sitesCost; //途径代价
double redProportion;
double greenProportion;
double blueProportion;
double lightThershold;
double limitedLat;
bool isOut;
//dijstra算法数据成员
stack<int> scheme; //最终方案栈
stack<int> reservedScheme;
int schemeSize;
int* schemePath;
int* updater; //updater用以记录距离缩短者
double* dist, * pi;
double* costDist, * costPi; //两者为综合代价距离,包含换乘与站台停留时间因素
public slots:
void initLineBox(int index);
void initStartStationBox(int index);
void initEndStationBox(int index);
void paintEvent(QPaintEvent* event);
bool event(QEvent* event);
void searchButtonPaint();
void switchButtonPaint();
void lineButtonPaint();
void updateInfo();
void transferCostChange(int value);
void sitesCostChange(int value);
void exchangeStation();
void applyHistory();
};
//定义数组求最小函数(返回最小值的下标)
template<class type>
int arrayMin(type* array, int size);