aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/addcylinderdialog.cpp
blob: 043f29907da48a431529553a14dbd689c4219137 (plain) (blame)
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
/*
 * addcylinderdialog.cpp
 *
 * classes for the add cylinder dialog of Subsurface
 *
 */
#include "addcylinderdialog.h"
#include "ui_addcylinderdialog.h"
#include <QComboBox>
#include <QDoubleSpinBox>
#include "../conversions.h"


AddCylinderDialog::AddCylinderDialog(QWidget *parent) : ui(new Ui::AddCylinderDialog())
{
	ui->setupUi(this);
}

void AddCylinderDialog::setCylinder(cylinder_t *cylinder)
{
	double volume, pressure;
	int index;

	currentCylinder = cylinder;
	convert_volume_pressure(cylinder->type.size.mliter, cylinder->type.workingpressure.mbar, &volume, &pressure);

	index = ui->cylinderType->findText(QString(cylinder->type.description));
	ui->cylinderType->setCurrentIndex(index);
	ui->size->setValue(volume);
	ui->pressure->setValue(pressure);

	ui->o2percent->setValue(cylinder->gasmix.o2.permille / 10.0);
	ui->hepercent->setValue(cylinder->gasmix.he.permille / 10.0);

	convert_pressure(cylinder->start.mbar, &pressure);
	ui->start->setValue(pressure);

	convert_pressure(cylinder->end.mbar, &pressure);
	ui->end->setValue(pressure);
}

void AddCylinderDialog::updateCylinder()
{
	QByteArray description = ui->cylinderType->currentText().toLocal8Bit();

	currentCylinder->type.description = description.data();
	currentCylinder->type.size.mliter = ui->size->value();
	currentCylinder->type.workingpressure.mbar = ui->pressure->value();
	currentCylinder->gasmix.o2.permille = ui->o2percent->value();
	currentCylinder->gasmix.he.permille = ui->hepercent->value();
	currentCylinder->start.mbar = ui->start->value();
	currentCylinder->end.mbar = ui->end->value();
}