-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalibrer.cpp
106 lines (95 loc) · 4.04 KB
/
calibrer.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "calibrer.h"
#include "ui_calibrer.h"
calibrer::calibrer(QWidget *parent, Screen *screen) :
QDialog(parent),
ui(new Ui::calibrer)
{
ui->setupUi(this);
connect(this->ui->hs_height,SIGNAL(valueChanged(int)),this,SLOT(size_change(int)));
connect(this->ui->hs_width,SIGNAL(valueChanged(int)),this,SLOT(size_change(int)));
connect(this->ui->hs_x_offset,SIGNAL(valueChanged(int)),this,SLOT(offset_change(int)));
connect(this->ui->hs_y_offset,SIGNAL(valueChanged(int)),this,SLOT(offset_change(int)));
connect(this->ui->hs_scan_speed,SIGNAL(valueChanged(int)), this, SLOT(other_change(int)));
connect(this->ui->hs_line_res,SIGNAL(valueChanged(int)),this,SLOT(other_change(int)));
connect(this->ui->hs_circle_res,SIGNAL(valueChanged(int)),this,SLOT(other_change(int)));
this->loading = false;
this->screen = screen;
this->size_change(0);
if(! QFile("calibration.ini").exists()){
this->saveSettings();
}else{
this->loadSettings();
}
this->update();
}
calibrer::~calibrer()
{
delete ui;
}
void calibrer::size_change(int val){
this->ui->hs_x_offset->setMaximum(65535 - this->ui->hs_width->value());
this->ui->hs_y_offset->setMaximum(65535 - this->ui->hs_height->value());
this->update();
}
void calibrer::offset_change(int val){
this->ui->hs_height->setMaximum(65535 - this->ui->hs_y_offset->value());
this->ui->hs_width->setMaximum(65535 - this->ui->hs_x_offset->value());
this->update();
}
void calibrer::other_change(int val){
this->update();
}
void calibrer::update(){
ui->lbl_height_value->setText(QString::number(ui->hs_height->value()));
ui->lbl_width_value->setText(QString::number(ui->hs_width->value()));
ui->lbl_X_Offset_Value->setText(QString::number(ui->hs_x_offset->value()));
ui->lbl_Y_Offset_Value->setText(QString::number(ui->hs_y_offset->value()));
ui->lbl_scan_speed_value->setText(QString::number(ui->hs_scan_speed->value()));
ui->lbl_circle_res_value->setText(QString::number(ui->hs_circle_res->value()));
ui->lbl_line_res_value->setText(QString::number(ui->hs_line_res->value()));
Parameters::get()->set(this->ui->hs_width->value(), this->ui->hs_height->value(),this->ui->hs_x_offset->value(),this->ui->hs_y_offset->value(), this->ui->hs_scan_speed->value(),this->ui->hs_line_res->value(),this->ui->hs_circle_res->value());
}
void calibrer::on_pb_close_clicked()
{
this->hide();
}
void calibrer::on_pb_save_clicked()
{
this->saveSettings();
}
void calibrer::loadSettings(){
QSettings settings("calibration.ini",QSettings::IniFormat);
ui->hs_height->setValue(0);
ui->hs_width->setValue(0);
ui->hs_x_offset->setValue(0);
ui->hs_y_offset->setValue(0);
ui->hs_height->setValue(settings.value("Geometry/height", 2000).toInt());
ui->hs_width->setValue(settings.value("Geometry/width", 2000).toInt());
ui->hs_x_offset->setValue(settings.value("Geometry/offset_x", 0).toInt());
ui->hs_y_offset->setValue(settings.value("Geometry/offset_y", 0).toInt());
ui->hs_scan_speed->setValue(settings.value("Laser/scan_speed",1000).toInt());
ui->hs_line_res->setValue(settings.value("Resolutions/line",1000).toInt());
ui->hs_circle_res->setValue(settings.value("Resolution/line",1000).toInt());
this->update();
}
void calibrer::saveSettings(){
QSettings settings("calibration.ini", QSettings::IniFormat);
settings.beginGroup("Geometry");
settings.setValue("height",ui->hs_height->value());
settings.setValue("width",ui->hs_width->value());
settings.setValue("offset_x",ui->hs_x_offset->value());
settings.setValue("offset_y",ui->hs_y_offset->value());
settings.endGroup();
settings.beginGroup("Laser");
settings.setValue("scan_speed",ui->hs_scan_speed->value());
settings.endGroup();
settings.beginGroup("Resolutions");
settings.setValue("line",ui->hs_line_res->value());
settings.setValue("circle",ui->hs_circle_res->value());
settings.endGroup();
settings.sync();
}
void calibrer::on_pb_load_clicked()
{
this->loadSettings();
}