-
Notifications
You must be signed in to change notification settings - Fork 9
/
mainwindow.cpp
87 lines (81 loc) · 2.57 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
86
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->MeField->setEnabled(false);
ui->HField->setEnabled(false);
ui->PcField->setEnabled(false);
ui->TcField->setEnabled(false);
ui->GamField->setEnabled(false);
ui->GamField2->setEnabled(false);
ui->RField->setEnabled(false);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_allParamsOption_toggled(bool checked)
{
if (checked){
ui->MeField->setEnabled(false);
ui->GamField2->setEnabled(false);
ui->HField->setEnabled(true);
ui->PcField->setEnabled(true);
ui->TcField->setEnabled(true);
ui->GamField->setEnabled(true);
ui->RField->setEnabled(true);
}
else{
ui->MeField->setEnabled(true);
ui->GamField2->setEnabled(true);
}
}
void MainWindow::on_exitMachOption_toggled(bool checked)
{
if (checked){
ui->MeField->setEnabled(true);
ui->GamField2->setEnabled(true);
ui->HField->setEnabled(false);
ui->PcField->setEnabled(false);
ui->TcField->setEnabled(false);
ui->GamField->setEnabled(false);
ui->RField->setEnabled(false);
}
else{
ui->MeField->setEnabled(true);
ui->GamField2->setEnabled(true);
}
}
void MainWindow::on_pushButton_clicked()
{
std::string option;
if (ui->allParamsOption->isChecked()){
Engine.chamber_pressure = ui->PcField->text().toFloat();
Engine.chamber_temperature = ui->TcField->text().toFloat();
Engine.gamma = ui->GamField->text().toFloat();
Engine.R_gas = ui->RField->text().toFloat();
float altitude = ui->HField->text().toFloat();
std::pair<float,float> tP = eq.returnOutsideTemperatureAndPressure(altitude);
Engine.exit_pressure = tP.second;
Engine.exit_Mach = eq.getExitMach(Engine.chamber_temperature, Engine.chamber_pressure, Engine.exit_pressure, Engine.gamma, Engine.R_gas);
option = "one";
}
else if (ui->exitMachOption->isChecked()){
try{
Engine.exit_Mach = ui->MeField->text().toFloat();
Engine.gamma = ui->GamField2->text().toFloat();
}
catch (float defaultMe) {
defaultMe = 2.0;
Engine.exit_Mach = defaultMe;
option = "two";
}
}
this->close();
//for widgets, setting parent argument to 0 opens widget in a new window
mocdesign = new methodofcharacteristics(0, Engine, option);
mocdesign->show();
}