This repository has been archived by the owner on Aug 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mainwindow.cpp
85 lines (68 loc) · 2.28 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
82
83
84
85
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(RobotMap *map, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
rmap(map)
{
ui->setupUi(this);
setCentralWidget(ui->graphicsView);
fieldItem = new FieldItem();
graphItem = new GraphItem(map);
scene = new QGraphicsScene(this);
ui->graphicsView->setScene(scene);
scene->addItem(fieldItem);
scene->addItem(graphItem);
auto background_color = QColor(Qt::darkGreen);
// background_color.setBlue(200);
scene->setBackgroundBrush(background_color);
timer = new QTimer(this);
// connect(timer,SIGNAL(timeout()),this->ui->graphicsView,SLOT(update()));
connect(timer,SIGNAL(timeout()),this->scene,SLOT(update()));
connect(ui->hw_spinbox,SIGNAL(valueChanged(double)),this,SLOT(setHWeight()));
connect(ui->checkBox,SIGNAL(toggled(bool)),this,SLOT(setDelay()));
connect(ui->spinBox,SIGNAL(valueChanged(int)),this,SLOT(setDelay()));
connect(ui->pushButton,SIGNAL(clicked(bool)),this,SLOT(updateMap()));
connect(ui->spinBox_2,SIGNAL(valueChanged(int)),this,SLOT(setMapRate(int)));
connect(ui->spinBox_3,SIGNAL(valueChanged(int)),this,SLOT(setGuiRate(int)));
timer->setSingleShot(false);
timer->start(33);
ui->graphicsView->setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing);
ui->spinBox_2->setValue(round(1000.0/30.0));
ui->spinBox_3->setValue(round(1000.0/33.0));
setWindowTitle("Fukuro Path Planning");
}
void MainWindow::setHWeight()
{
std::string s = rmap->graphSearch()->string(0,2);
if(s == std::string("a-star")) {
AStarSearch* astar = dynamic_cast<AStarSearch*>(rmap->graphSearch());
astar->setHeuristicWeight(ui->hw_spinbox->value());
}
else if(s == std::string("theta-star")) {
ThetaStarSearch* thetastar = dynamic_cast<ThetaStarSearch*>(rmap->graphSearch());
thetastar->setHeuristicWeight(ui->hw_spinbox->value());
}
}
void MainWindow::setDelay()
{
}
void MainWindow::setGuiRate(int rate)
{
timer->setInterval(round(1000.0/rate));
}
void MainWindow::setMapRate(int rate)
{
rmap->setLoopRate(round(1000.0/rate));
}
void MainWindow::updateMap()
{
rmap->update();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::u()
{
}