YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
sliderOptions.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 */
6
7#include "sliderOptions.h"
8#include "ui_sliderOptions.h"
9#include <QSettings>
10
12 QDialog(parent),
13 ui(new Ui::sliderOptions)
14{
15 ui->setupUi(this);
16
17 QString title = QString("SliderOptions");
18 setWindowTitle(title);
19
20 QSettings settings("YARP", "yarpmotorgui");
21 val_pos_choice = settings.value("val_pos_choice", 0).toInt();
22 val_trq_choice = settings.value("val_trq_choice", 0).toInt();
23 val_vel_choice = settings.value("val_vel_choice", 0).toInt();
24 val_pos_digits = settings.value("num_of_pos_decimals", 3).toInt();
25 val_pos_custom_step = settings.value("val_pos_custom_step", 1.0).toDouble();
26 val_trq_custom_step = settings.value("val_trq_custom_step", 1.0).toDouble();
27 val_vel_custom_step = settings.value("val_vel_custom_step", 1.0).toDouble();
28 val_vel_limit = settings.value("velocity_slider_limit", 100.0).toDouble();
29
30 pos_digits_validator = new QIntValidator(this);
31 pos_step_validator = new QDoubleValidator(this);
32 vel_step_validator = new QDoubleValidator(this);
33 trq_step_validator = new QDoubleValidator(this);
34 vel_lims_validator = new QDoubleValidator(this);
35 vel_lims_validator->setRange(0 , 100);
36
37 ui->pos_decimal_digits->setValidator(pos_digits_validator);
38 ui->pos_step->setValidator(pos_step_validator);
39 ui->vel_step->setValidator(vel_step_validator);
40 ui->trq_step->setValidator(trq_step_validator);
41 ui->vel_limiter->setValidator(vel_lims_validator);
42
43 ui->pos_decimal_digits->setText(QString("%1").arg(val_pos_digits));
44 ui->pos_step->setText(QString("%1").arg(val_pos_custom_step));
45 ui->trq_step->setText(QString("%1").arg(val_trq_custom_step));
46 ui->vel_step->setText(QString("%1").arg(val_vel_custom_step));
47 ui->vel_limiter->setText(QString("%1").arg(val_vel_limit));
48
49 connect(this, SIGNAL(sig_setPosSliderOptionSO(int, double, int)), parent, SLOT(onSetPosSliderOptionMW(int, double, int)));
50 connect(this, SIGNAL(sig_setVelSliderOptionSO(int, double)), parent, SLOT(onSetVelSliderOptionMW(int, double)));
51 connect(this, SIGNAL(sig_setTrqSliderOptionSO(int, double)), parent, SLOT(onSetTrqSliderOptionMW(int, double)));
52
53 switch (val_pos_choice)
54 {
55 case 0:
56 ui->radio_pos_auto->setChecked(true);
57 break;
58 case 1:
59 ui->radio_pos_user->setChecked(true);
60 break;
61 case 2:
62 ui->radio_pos_one->setChecked(true);
63 break;
64 default:
65 ui->radio_pos_auto->setChecked(true);
66 break;
67 }
68 switch (val_vel_choice)
69 {
70 case 0:
71 ui->radio_vel_auto->setChecked(true);
72 break;
73 case 1:
74 ui->radio_vel_user->setChecked(true);
75 break;
76 case 2:
77 ui->radio_vel_one->setChecked(true);
78 break;
79 default:
80 ui->radio_vel_auto->setChecked(true);
81 break;
82 }
83 switch (val_trq_choice)
84 {
85 case 0:
86 ui->radio_trq_auto->setChecked(true);
87 break;
88 case 1:
89 ui->radio_trq_user->setChecked(true);
90 break;
91 case 2:
92 ui->radio_trq_one->setChecked(true);
93 break;
94 default:
95 ui->radio_trq_auto->setChecked(true);
96 break;
97 }
98}
99
101{
102 if (ui->radio_pos_auto->isChecked()) {
103 val_pos_choice = 0;
104 } else if (ui->radio_pos_user->isChecked()) {
105 val_pos_choice = 1;
106 } else if (ui->radio_pos_one->isChecked()) {
107 val_pos_choice = 2;
108 }
109
110 if (ui->radio_vel_auto->isChecked()) {
111 val_vel_choice = 0;
112 } else if (ui->radio_vel_user->isChecked()) {
113 val_vel_choice = 1;
114 } else if (ui->radio_vel_one->isChecked()) {
115 val_vel_choice = 2;
116 }
117
118 if (ui->radio_trq_auto->isChecked()) {
119 val_trq_choice = 0;
120 } else if (ui->radio_trq_user->isChecked()) {
121 val_trq_choice = 1;
122 } else if (ui->radio_trq_one->isChecked()) {
123 val_trq_choice = 2;
124 }
125
126 val_pos_custom_step = ui->pos_step->text().toDouble();
127 val_vel_custom_step = ui->vel_step->text().toDouble();
128 val_trq_custom_step = ui->trq_step->text().toDouble();
129 val_vel_limit = ui->vel_limiter->text().toDouble();
130 val_pos_digits = ui->pos_decimal_digits->text().toInt();
131
132 QSettings settings("YARP", "yarpmotorgui");
133 settings.setValue("val_pos_choice", val_pos_choice);
134 settings.setValue("val_trq_choice", val_trq_choice);
135 settings.setValue("val_vel_choice", val_vel_choice);
136 settings.setValue("val_pos_custom_step", val_pos_custom_step);
137 settings.setValue("val_trq_custom_step", val_trq_custom_step);
138 settings.setValue("val_vel_custom_step", val_vel_custom_step);
139 settings.setValue("velocity_slider_limit", val_vel_limit);
140 settings.setValue("num_of_pos_decimals", val_pos_digits);
141 emit sig_setPosSliderOptionSO(val_pos_choice, val_pos_custom_step, val_pos_digits);
142 emit sig_setVelSliderOptionSO(val_vel_choice, val_vel_custom_step);
143 emit sig_setTrqSliderOptionSO(val_trq_choice, val_trq_custom_step);
144 disconnect(this, SIGNAL(sig_setPosSliderOptionSO(int, double, int)), nullptr, nullptr);
145 disconnect(this, SIGNAL(sig_setVelSliderOptionSO(int, double)), nullptr, nullptr);
146 disconnect(this, SIGNAL(sig_setTrqSliderOptionSO(int, double)), nullptr, nullptr);
147
148 delete pos_digits_validator;
149 delete pos_step_validator;
150 delete vel_step_validator;
151 delete trq_step_validator;
152 delete vel_lims_validator;
153 delete ui;
154}
int SIGNAL(int pid, int signum)
void sig_setVelSliderOptionSO(int, double)
sliderOptions(QWidget *parent=0)
void sig_setTrqSliderOptionSO(int, double)
void sig_setPosSliderOptionSO(int, double, int)
Definition aboutdlg.h:11