direcs  2012-09-30
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
settingsDialog.cpp
Go to the documentation of this file.
1 /*************************************************************************
2  * Copyright (C) Markus Knapp *
3  * www.direcs.de *
4  * *
5  * This file is part of direcs. *
6  * *
7  * direcs is free software: you can redistribute it and/or modify it *
8  * under the terms of the GNU General Public License as published *
9  * by the Free Software Foundation, version 3 of the License. *
10  * *
11  * direcs is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with direcs. If not, see <http://www.gnu.org/licenses/>. *
18  * *
19  *************************************************************************/
20 
21 #include "settingsDialog.h"
22 
23 SettingsDialog::SettingsDialog(QWidget* parent) : QDialog(parent)
24 {
25  ui.setupUi(this);
26 
27 
28  // change the value of a spinBox when the value of the corresponding slider changes
29  connect(ui.sliderMotor1Speed, SIGNAL(valueChanged(int)), ui.spinBoxMotor1Speed, SLOT(setValue(int)));
30  connect(ui.sliderMotor2Speed, SIGNAL(valueChanged(int)), ui.spinBoxMotor2Speed, SLOT(setValue(int)));
31  connect(ui.sliderMotor3Speed, SIGNAL(valueChanged(int)), ui.spinBoxMotor3Speed, SLOT(setValue(int)));
32  connect(ui.sliderMotor4Speed, SIGNAL(valueChanged(int)), ui.spinBoxMotor4Speed, SLOT(setValue(int)));
33  // and vice versa
34  connect(ui.spinBoxMotor1Speed, SIGNAL(valueChanged(int)), ui.sliderMotor1Speed, SLOT(setValue(int)));
35  connect(ui.spinBoxMotor2Speed, SIGNAL(valueChanged(int)), ui.sliderMotor2Speed, SLOT(setValue(int)));
36  connect(ui.spinBoxMotor3Speed, SIGNAL(valueChanged(int)), ui.sliderMotor3Speed, SLOT(setValue(int)));
37  connect(ui.spinBoxMotor4Speed, SIGNAL(valueChanged(int)), ui.sliderMotor4Speed, SLOT(setValue(int)));
38 
39  // change the value of a spinBox when the value of the corresponding slider changes
40  connect(ui.sliderMaximumSpeed, SIGNAL(valueChanged(int)), ui.spinBoxMaximumSpeed, SLOT(setValue(int)));
41  connect(ui.sliderMinimumSpeed, SIGNAL(valueChanged(int)), ui.spinBoxMinimumSpeed, SLOT(setValue(int)));
42  connect(ui.sliderAllMotorsSpeed, SIGNAL(valueChanged(int)), ui.spinBoxAllMotorsSpeed, SLOT(setValue(int)));
43  // and vice versa
44  connect(ui.spinBoxMaximumSpeed, SIGNAL(valueChanged(int)), ui.sliderMaximumSpeed, SLOT(setValue(int)));
45  connect(ui.spinBoxMinimumSpeed, SIGNAL(valueChanged(int)), ui.sliderMinimumSpeed, SLOT(setValue(int)));
46  connect(ui.spinBoxAllMotorsSpeed, SIGNAL(valueChanged(int)), ui.sliderAllMotorsSpeed, SLOT(setValue(int)));
47 
48  // change the value of a spinBox when the value of the corresponding slider changes
49  connect(ui.sliderPassageWidth, SIGNAL(valueChanged(int)), ui.spinBoxPassageWidth, SLOT(setValue(int)));
50  // and vice versa
51  connect(ui.spinBoxPassageWidth, SIGNAL(valueChanged(int)), ui.sliderPassageWidth, SLOT(setValue(int)));
52 
53  // change the value of a spinBox when the value of the corresponding slider changes
54  connect(ui.sliderStraightForwardDeviation, SIGNAL(valueChanged(int)), ui.spinBoxStraightForwardDeviation, SLOT(setValue(int)));
55  // and vice versa
56  connect(ui.spinBoxStraightForwardDeviation, SIGNAL(valueChanged(int)), ui.sliderStraightForwardDeviation, SLOT(setValue(int)));
57 
58  // change the value of a spinBox when the value of the corresponding slider changes
59  connect(ui.sliderObstacleLaserScanner, SIGNAL(valueChanged(int)), ui.spinBoxObstacleLaserScanner, SLOT(setValue(int)));
60  // and vice versa
61  connect(ui.spinBoxObstacleLaserScanner, SIGNAL(valueChanged(int)), ui.sliderObstacleLaserScanner, SLOT(setValue(int)));
62 
63  // change the value of a spinBox when the value of the corresponding slider changes
64  connect(ui.sliderObstacle, SIGNAL(valueChanged(int)), ui.spinBoxObstacle, SLOT(setValue(int)));
65  // and vice versa
66  connect(ui.spinBoxObstacle, SIGNAL(valueChanged(int)), ui.sliderObstacle, SLOT(setValue(int)));
67 
68  //----------------------------------
69  // and now the important stuff...
70  //----------------------------------
71  // emit the signal from the widget to obstacleCheckThread via Direcs!
72  connect(ui.sliderPassageWidth, SIGNAL(valueChanged(int)), SIGNAL(setPassageWidth(int)));
73 
74  // emit the signal from Gui to obstacleCheckThread via Direcs!
75  connect(ui.sliderStraightForwardDeviation, SIGNAL(valueChanged(int)), SIGNAL(setStraightForwardDeviation(int)));
76 
77  // emit the signal from Gui to obstacleCheckThread via Direcs!
78  connect(ui.sliderObstacleLaserScanner, SIGNAL(valueChanged(int)), SIGNAL(setMinObstacleDistanceLaserFront(int)));
80 
81  // emit the signal from Gui to obstacleCheckThread via Direcs!
82  connect(ui.sliderObstacle, SIGNAL(valueChanged(int)), SIGNAL(setMinObstacleDistance(int)));
83 }
84 
85 
87 {
88  switch (motor)
89  {
90  case 1:
91  return ui.sliderMotor1Speed->value();
92  break;
93  case 2:
94  return ui.sliderMotor2Speed->value();
95  break;
96  }
97 
98 
99  return -1;
100 }
101 
102 
104 {
105  return ui.sliderMinimumSpeed->value();
106 }
107 
108 
110 {
111  return ui.sliderMaximumSpeed->value();
112 }
113 
114 
116 {
117  return ui.sliderObstacle->value();
118 }
119 
120 
122 {
123  return ui.sliderObstacleLaserScanner->value();
124 }
125 
126 
128 {
129  return ui.sliderPassageWidth->value();
130 }
131 
132 
134 {
135  return ui.sliderStraightForwardDeviation->value();
136 }
137 
138 
140 {
141  return ui.checkBoxSaveSettings->checkState();
142 }
143 
144 
145 void SettingsDialog::setSliderMotorSpeed(int motor, int value)
146 {
147  switch (motor)
148  {
149  case 1:
150  ui.sliderMotor1Speed->setValue(value);
151  ui.spinBoxMotor1Speed->setValue(value);
152  break;
153  case 2:
154  ui.sliderMotor2Speed->setValue(value);
155  ui.spinBoxMotor2Speed->setValue(value);
156  break;
157  }
158 }
159 
160 
162 {
163  // no auto connect in constructor, because this slot has no "value" parameter!
164  emit setMotorSpeed(MOTOR1, ui.sliderMotor1Speed->value());
165 
166  //int value = ui.sliderMotor1Speed->value();
167 
168  //laserDistanceLineListFront->at(0)->setStartAngle(ui.sliderMotor1Speed->value() * 16);
169  //laserDistanceLineListFront->at(0)->setPos(value, value);
170  //appendLog(QString("x,y=%1").arg(value));
171 }
172 
173 
175 {
176  // no auto connect in constructor, because this slot has no "value" parameter!
177  emit setMotorSpeed(MOTOR2, ui.sliderMotor2Speed->value());
178 
179  //laserDistanceLineListFront->at(0)->setSpanAngle(ui.sliderMotor2Speed->value() * 16);
180  //appendLog(QString("spanAngle=%1").arg(ui.sliderMotor2Speed->value()));
181 }
182 
183 
185 {
186  // no auto connect in constructor, because this slot has no "value" parameter!
187  emit setMotorSpeed(MOTOR3, ui.sliderMotor3Speed->value());
188 
189  //laserDistanceLineListFront->at(0)->setSpanAngle(ui.sliderMotor3Speed->value() * 16);
190  //appendLog(QString("spanAngle=%1").arg(ui.sliderMotor3Speed->value()));
191 }
192 
193 
195 {
196  // no auto connect in constructor, because this slot has no "value" parameter!
197  emit setMotorSpeed(MOTOR4, ui.sliderMotor4Speed->value());
198 
199  //laserDistanceLineListFront->at(0)->setSpanAngle(ui.sliderMotor4Speed->value() * 16);
200  //appendLog(QString("spanAngle=%1").arg(ui.sliderMotor4Speed->value()));
201 }
202 
203 
205 {
206  /*
207  int speed = ui.sliderAllMotorsSpeed->value();
208 
209 
210  // set same speed to 4 other motor speed sliders
211  ui.sliderMotor1Speed->setValue(speed);
212  ui.sliderMotor2Speed->setValue(speed);
213  ui.sliderMotor3Speed->setValue(speed);
214  ui.sliderMotor4Speed->setValue(speed);
215  */
216 
217  // no auto connect in constructor, because this slot has no "value" parameter!
218  emit setMotorSpeed(ALLMOTORS, ui.sliderAllMotorsSpeed->value());
219 
220  //laserDistanceLineListFront->at(0)->setSpanAngle(ui.sliderMotor4Speed->value() * 16);
221  //appendLog(QString("spanAngle=%1").arg(ui.sliderMotor4Speed->value()));
222 }
223 
224 
226 {
227  // no auto connect in constructor, because this slot has no "value" parameter!
228  emit setMaximumSpeed(ui.sliderMaximumSpeed->value());
229 }
230 
231 
233 {
234  ui.sliderMinimumSpeed->setValue(speed);
235 }
236 
237 
239 {
240  ui.sliderMaximumSpeed->setValue(speed);
241 }
242 
243 
245 {
246  ui.sliderObstacle->setValue(value);
247 }
248 
249 
251 {
252  ui.sliderObstacleLaserScanner->setValue(value);
253 }
254 
255 
257 {
258  ui.sliderPassageWidth->setValue(width);
259 }
260 
261 
263 {
264  ui.sliderStraightForwardDeviation->setValue(angle);
265 }
266 
267 
268 void SettingsDialog::setCheckBoxSaveSettings(Qt::CheckState state)
269 {
270  ui.checkBoxSaveSettings->setCheckState(state);
271 }