-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
81 lines (65 loc) · 1.87 KB
/
mainwindow.cpp
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
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QDialog(parent),
ui(new Ui::MainWindow)
{
//主界面启动
ui->setupUi(this);
//系统时间初始化、计时开始
this->initSystemTime();
systemTime=new QTimer(this);
connect(systemTime,SIGNAL(timeout()),this,SLOT(timeUpDate()));
systemTime->start(INTERNAL_TIME);
//点击注册旅客后弹出注册界面
connect(ui->signUp_Button,SIGNAL(clicked()),this,SLOT(create_NewCustomer()));
//添加图片背景
this->map_image=new QImage();
map_image->load("D:\\study\\travel\\travel_plan\\welcome.jpg");
*map_image=map_image->scaled(491,411,Qt::KeepAspectRatio);
QGraphicsScene *map_scene=new QGraphicsScene();
map_scene->addPixmap(QPixmap::fromImage(*map_image));
ui->main_map->setScene(map_scene);
ui->main_map->resize(map_image->width()+2,map_image->height()+2);
ui->main_map->show();
}
MainWindow::~MainWindow()
{
delete ui;
}
//主窗口点击注册新旅客后弹出注册界面
void MainWindow::create_NewCustomer()
{
Traveller newCus;
Strategy generator_stra;
int fee=generator_stra.leastFee__strategy(newCus);
vector<int> temp=newCus.getTravelRoad();
for(auto m:temp)
{
qDebug()<<m;
}
qDebug()<<endl<<"leastfee"<<fee<<endl;
//将点击后新建的旅客添加到主界面类中
this->addCustomer(newCus);
}
//添加新旅客
void MainWindow::addCustomer(Traveller &newCustomer)
{
allCustomers.push_back(newCustomer);
}
void MainWindow::timeUpDate()
{
//更新时间系统时间
timeDH.second=(++timeDH.second)%24;
if(!timeDH.second)
{
++timeDH.second;
}
// qDebug()<<currentDay<<" "<<currentHour;
systemTime->start(INTERNAL_TIME);
//更新旅客状态
}
void MainWindow::initSystemTime()
{
timeDH=make_pair(0,0);
}