-
Notifications
You must be signed in to change notification settings - Fork 1
/
addlidardialog.cpp
90 lines (68 loc) · 2.91 KB
/
addlidardialog.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
#include "addlidardialog.h"
#include <string.h>
#include <iostream>
#include <QFileDialog>
#include "ui_addlidardialog.h"
AddLidarDialog::AddLidarDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::AddLidarDialog) {
ui->setupUi(this);
modelGroup = new QButtonGroup();
returnTypeGroup = new QButtonGroup();
vlp16RadioBtn = findChild<QRadioButton*>("vlp16RadioButton");
pandar40RadioBtn = findChild<QRadioButton*>("pandar40RadioButton");
singleRadioBtn = findChild<QRadioButton*>("singleRadioButton");
dualRadioBtn = findChild<QRadioButton*>("dualRadioButton");
nameInput = findChild<QLineEdit*>("nameInput");
ipInput = findChild<QLineEdit*>("ipInput");
portInput = findChild<QLineEdit*>("portInput");
correctionFileInput = findChild<QLabel*>("correctionFileInput");
selectFileButton = findChild<QPushButton*>("selectFileButton");
modelGroup->addButton(vlp16RadioBtn, 1);
modelGroup->addButton(pandar40RadioBtn, 2);
vlp16RadioBtn->setChecked(true);
returnTypeGroup->addButton(singleRadioBtn, 1);
returnTypeGroup->addButton(dualRadioBtn, 2);
singleRadioBtn->setChecked(true);
portInput->setValidator(new QIntValidator(portInput));
ipInput->setInputMask("000.000.000.000");
lidarConfig.model = "VLP16";
lidarConfig.port = 2368;
lidarConfig.returnType = 0;
lidarConfig.correctionFilePath = " ";
initConnection();
}
AddLidarDialog::~AddLidarDialog() {
}
void AddLidarDialog::initConnection() {
connect (nameInput, SIGNAL (textChanged(const QString &)), this, SLOT (nameUpdate(const QString &)));
connect (ipInput, SIGNAL (textChanged(const QString &)), this, SLOT (ipUpdate(const QString &)));
connect (portInput, SIGNAL (textChanged(const QString &)), this, SLOT (portUpdate(const QString &)));
connect(modelGroup, SIGNAL(buttonClicked(int)), this, SLOT(modelGroupButtonsClicked(int)));
connect(returnTypeGroup, SIGNAL(buttonClicked(int)), this, SLOT(returnTypeGroupButtonsClicked(int)));
connect (selectFileButton, SIGNAL (clicked ()), this, SLOT (selectFileButtonPressed ()));
}
void AddLidarDialog::nameUpdate(const QString &input) {
lidarConfig.name = input.toStdString();
}
void AddLidarDialog::ipUpdate(const QString &input) {
lidarConfig.ip = input.toStdString();
}
void AddLidarDialog::portUpdate(const QString &input) {
lidarConfig.port = input.toInt();
}
CLidarConfig AddLidarDialog::getLidarConfig() {
return lidarConfig;
}
void AddLidarDialog::modelGroupButtonsClicked(int id) {
lidarConfig.model = modelGroup->button(id)->text().toStdString();
}
void AddLidarDialog::returnTypeGroupButtonsClicked(int id) {
lidarConfig.returnType = id - 1;
}
void AddLidarDialog::selectFileButtonPressed() {
QString fileName = QFileDialog::getOpenFileName(this,
tr("Select"), "/", tr("Files (*.csv)"));
correctionFileInput->setText(fileName);
lidarConfig.correctionFilePath = fileName.toStdString();
}