-
Notifications
You must be signed in to change notification settings - Fork 1
/
interface.cpp
executable file
·85 lines (76 loc) · 2.7 KB
/
interface.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 "interface.h"
//#include "ui_interface.h"
#include <fstream>
#include <iostream>
#include <string>
Interface::Interface(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Interface)
{
ui->setupUi(this);
this->setWindowState(this->windowState() ^ Qt::WindowMaximized);
}
Interface::~Interface()
{
// delete mind;
delete ui;
}
void Interface::on_button_start_clicked()
{
int algo = 0;
algo = ui->box_algorithm->currentIndex();
std::cout << "index:" << algo << std::endl;
switch(algo)
{
case FIRE_STATION:
mind = new minDistance(this,std::stoi(ui->text_pop->text().toStdString()),
std::stoi(ui->text_generation->text().toStdString()),
std::stof(ui->text_mutation->text().toStdString()),
std::stoi(ui->text_elitism->text().toStdString()),
std::stof(ui->text_crossRate->text().toStdString()));
mind->Run();
break;
}
}
void Interface::Plot(std::vector<double> &x, std::vector<double> &y, QColor color, QCPScatterStyle::ScatterShape shape,
QCPGraph::LineStyle line, float xStep, float yStep, QString xLabel, QString ylabel, int xRange1,
int xRange2, int yRange1, int yRange2, int size)
{
QVector<double> lat = QVector<double>::fromStdVector(y);
QVector<double> lon = QVector<double>::fromStdVector(x);
ui->graphInterface->addGraph();
ui->graphInterface->xAxis->setAutoTickStep(false);
ui->graphInterface->yAxis->setAutoTickStep(false);
ui->graphInterface->xAxis->setTickStep(xStep);
ui->graphInterface->yAxis->setTickStep(yStep);
ui->graphInterface->xAxis->setLabel(xLabel);
ui->graphInterface->yAxis->setLabel(ylabel);
ui->graphInterface->xAxis->setRange(xRange1, xRange2);
ui->graphInterface->yAxis->setRange(yRange1, yRange2);
int num_graph = ui->graphInterface->graphCount();
const int graph_pos = num_graph - 1;
ui->graphInterface->graph(graph_pos)->setData(lon, lat);
ui->graphInterface->graph(graph_pos)->setScatterStyle(QCPScatterStyle(shape, color, Qt::white, size));
ui->graphInterface->graph(graph_pos)->setLineStyle(line);
ui->graphInterface->replot();
}
void Interface::on_button_reset_clicked()
{
ui->text_answer->setText("");
ui->text_crossRate->setText("");
ui->text_elitism->setText("");
ui->text_generation->setText("");
ui->text_mutation->setText("");
ui->text_pop->setText("");
ui->graphInterface->clearGraphs();
ui->graphInterface->replot();
}
void Interface::ClearGraph()
{
ui->graphInterface->clearGraphs();
}
void Interface::on_button_stop_clicked()
{
delete mind;
exit(0);
}