1
/***************************************************************************
2
* Copyright (c) 2012 Petar Perisin <petar.perisin@gmail.com> *
4
* This file is part of the FreeCAD CAx development system. *
6
* This library is free software; you can redistribute it and/or *
7
* modify it under the terms of the GNU Library General Public *
8
* License as published by the Free Software Foundation; either *
9
* version 2 of the License, or (at your option) any later version. *
11
* This library 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 Library General Public License for more details. *
16
* You should have received a copy of the GNU Library General Public *
17
* License along with this library; see the file COPYING.LIB. If not, *
18
* write to the Free Software Foundation, Inc., 59 Temple Place, *
19
* Suite 330, Boston, MA 02111-1307, USA *
21
***************************************************************************/
23
#include "PreCompiled.h"
25
#include "DlgCustomizeSpNavSettings.h"
26
#include "ui_DlgCustomizeSpNavSettings.h"
27
#include "Application.h"
28
#include "GuiApplicationNativeEventAware.h"
31
using namespace Gui::Dialog;
33
DlgCustomizeSpNavSettings::DlgCustomizeSpNavSettings(QWidget* parent)
34
: CustomizeActionPage(parent)
35
, ui(new Ui_DlgCustomizeSpNavSettings)
38
auto app = qobject_cast<GUIApplicationNativeEventAware*>(QApplication::instance());
43
if (!app->isSpaceballPresent()) {
44
this->setWindowTitle(tr("Spaceball Motion"));
45
this->setMessage(tr("No Spaceball Present"));
54
DlgCustomizeSpNavSettings::~DlgCustomizeSpNavSettings() = default;
56
void DlgCustomizeSpNavSettings::setupConnections()
59
connect(ui->CBDominant, &QCheckBox::clicked,
60
this, &DlgCustomizeSpNavSettings::on_CBDominant_clicked);
61
connect(ui->CBFlipYZ, &QCheckBox::clicked,
62
this, &DlgCustomizeSpNavSettings::on_CBFlipYZ_clicked);
63
connect(ui->CBRotations, &QCheckBox::clicked,
64
this, &DlgCustomizeSpNavSettings::on_CBRotations_clicked);
65
connect(ui->CBTranslations, &QCheckBox::clicked,
66
this, &DlgCustomizeSpNavSettings::on_CBTranslations_clicked);
67
connect(ui->SliderGlobal, &QSlider::sliderReleased,
68
this, &DlgCustomizeSpNavSettings::on_SliderGlobal_sliderReleased);
69
connect(ui->CBEnablePanLR, &QCheckBox::clicked,
70
this, &DlgCustomizeSpNavSettings::on_CBEnablePanLR_clicked);
71
connect(ui->CBReversePanLR, &QCheckBox::clicked,
72
this, &DlgCustomizeSpNavSettings::on_CBReversePanLR_clicked);
73
connect(ui->SliderPanLR, &QSlider::sliderReleased,
74
this, &DlgCustomizeSpNavSettings::on_SliderPanLR_sliderReleased);
75
connect(ui->CBEnablePanUD, &QCheckBox::clicked,
76
this, &DlgCustomizeSpNavSettings::on_CBEnablePanUD_clicked);
77
connect(ui->CBReversePanUD, &QCheckBox::clicked,
78
this, &DlgCustomizeSpNavSettings::on_CBReversePanUD_clicked);
79
connect(ui->SliderPanUD, &QSlider::sliderReleased,
80
this, &DlgCustomizeSpNavSettings::on_SliderPanUD_sliderReleased);
81
connect(ui->CBEnableZoom, &QCheckBox::clicked,
82
this, &DlgCustomizeSpNavSettings::on_CBEnableZoom_clicked);
83
connect(ui->CBReverseZoom, &QCheckBox::clicked,
84
this, &DlgCustomizeSpNavSettings::on_CBReverseZoom_clicked);
85
connect(ui->SliderZoom, &QSlider::sliderReleased,
86
this, &DlgCustomizeSpNavSettings::on_SliderZoom_sliderReleased);
87
connect(ui->CBEnableTilt, &QCheckBox::clicked,
88
this, &DlgCustomizeSpNavSettings::on_CBEnableTilt_clicked);
89
connect(ui->CBReverseTilt, &QCheckBox::clicked,
90
this, &DlgCustomizeSpNavSettings::on_CBReverseTilt_clicked);
91
connect(ui->SliderTilt, &QSlider::sliderReleased,
92
this, &DlgCustomizeSpNavSettings::on_SliderTilt_sliderReleased);
93
connect(ui->CBEnableRoll, &QCheckBox::clicked,
94
this, &DlgCustomizeSpNavSettings::on_CBEnableRoll_clicked);
95
connect(ui->CBReverseRoll, &QCheckBox::clicked,
96
this, &DlgCustomizeSpNavSettings::on_CBReverseRoll_clicked);
97
connect(ui->SliderRoll, &QSlider::sliderReleased,
98
this, &DlgCustomizeSpNavSettings::on_SliderRoll_sliderReleased);
99
connect(ui->CBEnableSpin, &QCheckBox::clicked,
100
this, &DlgCustomizeSpNavSettings::on_CBEnableSpin_clicked);
101
connect(ui->CBReverseSpin, &QCheckBox::clicked,
102
this, &DlgCustomizeSpNavSettings::on_CBReverseSpin_clicked);
103
connect(ui->SliderSpin, &QSlider::sliderReleased,
104
this, &DlgCustomizeSpNavSettings::on_SliderSpin_sliderReleased);
105
connect(ui->ButtonDefaultSpNavMotions, &QPushButton::clicked,
106
this, &DlgCustomizeSpNavSettings::on_ButtonDefaultSpNavMotions_clicked);
107
connect(ui->ButtonCalibrate, &QPushButton::clicked,
108
this, &DlgCustomizeSpNavSettings::on_ButtonCalibrate_clicked);
112
void DlgCustomizeSpNavSettings::setMessage(const QString& message)
114
auto messageLabel = new QLabel(message, this);
115
auto layout = new QVBoxLayout();
116
auto layout2 = new QHBoxLayout();
117
layout2->addStretch();
118
layout2->addWidget(messageLabel);
119
layout2->addStretch();
120
layout->addItem(layout2);
121
this->setLayout(layout);
124
void DlgCustomizeSpNavSettings::changeEvent(QEvent* e)
126
if (e->type() == QEvent::LanguageChange) {
128
ui->retranslateUi(this);
131
this->setWindowTitle(tr("Spaceball Motion"));
132
QLabel* messageLabel = this->findChild<QLabel*>();
134
messageLabel->setText(tr("No Spaceball Present"));
138
QWidget::changeEvent(e);
141
ParameterGrp::handle DlgCustomizeSpNavSettings::spaceballMotionGroup() const
143
static ParameterGrp::handle group = App::GetApplication()
146
->GetGroup("Spaceball")
147
->GetGroup("Motion");
151
void DlgCustomizeSpNavSettings::on_ButtonCalibrate_clicked()
153
spaceballMotionGroup()->SetBool("Calibrate", true);
156
void DlgCustomizeSpNavSettings::initialize()
158
ui->CBDominant->setChecked(spaceballMotionGroup()->GetBool("Dominant", false));
159
ui->CBFlipYZ->setChecked(spaceballMotionGroup()->GetBool("FlipYZ", false));
160
ui->CBRotations->setChecked(spaceballMotionGroup()->GetBool("Rotations", true));
161
ui->CBTranslations->setChecked(spaceballMotionGroup()->GetBool("Translations", true));
162
ui->SliderGlobal->setValue(spaceballMotionGroup()->GetInt("GlobalSensitivity", 0));
164
ui->CBEnablePanLR->setChecked(spaceballMotionGroup()->GetBool("PanLREnable", true));
165
ui->CBReversePanLR->setChecked(spaceballMotionGroup()->GetBool("PanLRReverse", false));
166
ui->SliderPanLR->setValue(spaceballMotionGroup()->GetInt("PanLRSensitivity", 0));
168
ui->CBEnablePanUD->setChecked(spaceballMotionGroup()->GetBool("PanUDEnable", true));
169
ui->CBReversePanUD->setChecked(spaceballMotionGroup()->GetBool("PanUDReverse", false));
170
ui->SliderPanUD->setValue(spaceballMotionGroup()->GetInt("PanUDSensitivity", 0));
172
ui->CBEnableZoom->setChecked(spaceballMotionGroup()->GetBool("ZoomEnable", true));
173
ui->CBReverseZoom->setChecked(spaceballMotionGroup()->GetBool("ZoomReverse", false));
174
ui->SliderZoom->setValue(spaceballMotionGroup()->GetInt("ZoomSensitivity", 0));
176
ui->CBEnableTilt->setChecked(spaceballMotionGroup()->GetBool("TiltEnable", true));
177
ui->CBReverseTilt->setChecked(spaceballMotionGroup()->GetBool("TiltReverse", false));
178
ui->SliderTilt->setValue(spaceballMotionGroup()->GetInt("TiltSensitivity", 0));
180
ui->CBEnableRoll->setChecked(spaceballMotionGroup()->GetBool("RollEnable", true));
181
ui->CBReverseRoll->setChecked(spaceballMotionGroup()->GetBool("RollReverse", false));
182
ui->SliderRoll->setValue(spaceballMotionGroup()->GetInt("RollSensitivity", 0));
184
ui->CBEnableSpin->setChecked(spaceballMotionGroup()->GetBool("SpinEnable", true));
185
ui->CBReverseSpin->setChecked(spaceballMotionGroup()->GetBool("SpinReverse", false));
186
ui->SliderSpin->setValue(spaceballMotionGroup()->GetInt("SpinSensitivity", 0));
188
ui->CBEnableTilt->setEnabled(ui->CBRotations->isChecked());
189
ui->CBReverseTilt->setEnabled(ui->CBRotations->isChecked() && ui->CBEnableTilt->isChecked());
190
ui->SliderTilt->setEnabled(ui->CBRotations->isChecked() && ui->CBEnableTilt->isChecked());
191
ui->CBEnableRoll->setEnabled(ui->CBRotations->isChecked());
192
ui->CBReverseRoll->setEnabled(ui->CBRotations->isChecked() && ui->CBEnableRoll->isChecked());
193
ui->SliderRoll->setEnabled(ui->CBRotations->isChecked() && ui->CBEnableRoll->isChecked());
194
ui->CBEnableSpin->setEnabled(ui->CBRotations->isChecked());
195
ui->CBReverseSpin->setEnabled(ui->CBRotations->isChecked() && ui->CBEnableSpin->isChecked());
196
ui->SliderSpin->setEnabled(ui->CBRotations->isChecked() && ui->CBEnableSpin->isChecked());
198
ui->CBEnablePanLR->setEnabled(ui->CBTranslations->isChecked());
199
ui->CBReversePanLR->setEnabled(ui->CBTranslations->isChecked()
200
&& ui->CBEnablePanLR->isChecked());
201
ui->SliderPanLR->setEnabled(ui->CBTranslations->isChecked() && ui->CBEnablePanLR->isChecked());
202
ui->CBEnablePanUD->setEnabled(ui->CBTranslations->isChecked());
203
ui->CBReversePanUD->setEnabled(ui->CBTranslations->isChecked()
204
&& ui->CBEnablePanUD->isChecked());
205
ui->SliderPanUD->setEnabled(ui->CBTranslations->isChecked() && ui->CBEnablePanUD->isChecked());
206
ui->CBEnableZoom->setEnabled(ui->CBTranslations->isChecked());
207
ui->CBReverseZoom->setEnabled(ui->CBTranslations->isChecked() && ui->CBEnableZoom->isChecked());
208
ui->SliderZoom->setEnabled(ui->CBTranslations->isChecked() && ui->CBEnableZoom->isChecked());
211
void DlgCustomizeSpNavSettings::on_ButtonDefaultSpNavMotions_clicked()
213
spaceballMotionGroup()->Clear();
217
void DlgCustomizeSpNavSettings::on_CBDominant_clicked()
219
spaceballMotionGroup()->SetBool("Dominant", ui->CBDominant->isChecked());
222
void DlgCustomizeSpNavSettings::on_CBFlipYZ_clicked()
224
spaceballMotionGroup()->SetBool("FlipYZ", ui->CBFlipYZ->isChecked());
227
void DlgCustomizeSpNavSettings::on_CBRotations_clicked()
229
spaceballMotionGroup()->SetBool("Rotations", ui->CBRotations->isChecked());
231
ui->CBEnableTilt->setEnabled(ui->CBRotations->isChecked());
232
ui->CBReverseTilt->setEnabled(ui->CBRotations->isChecked() && ui->CBEnableTilt->isChecked());
233
ui->SliderTilt->setEnabled(ui->CBRotations->isChecked() && ui->CBEnableTilt->isChecked());
234
ui->CBEnableRoll->setEnabled(ui->CBRotations->isChecked());
235
ui->CBReverseRoll->setEnabled(ui->CBRotations->isChecked() && ui->CBEnableRoll->isChecked());
236
ui->SliderRoll->setEnabled(ui->CBRotations->isChecked() && ui->CBEnableRoll->isChecked());
237
ui->CBEnableSpin->setEnabled(ui->CBRotations->isChecked());
238
ui->CBReverseSpin->setEnabled(ui->CBRotations->isChecked() && ui->CBEnableSpin->isChecked());
239
ui->SliderSpin->setEnabled(ui->CBRotations->isChecked() && ui->CBEnableSpin->isChecked());
242
void DlgCustomizeSpNavSettings::on_CBTranslations_clicked()
244
spaceballMotionGroup()->SetBool("Translations", ui->CBTranslations->isChecked());
246
ui->CBEnablePanLR->setEnabled(ui->CBTranslations->isChecked());
247
ui->CBReversePanLR->setEnabled(ui->CBTranslations->isChecked()
248
&& ui->CBEnablePanLR->isChecked());
249
ui->SliderPanLR->setEnabled(ui->CBTranslations->isChecked() && ui->CBEnablePanLR->isChecked());
250
ui->CBEnablePanUD->setEnabled(ui->CBTranslations->isChecked());
251
ui->CBReversePanUD->setEnabled(ui->CBTranslations->isChecked()
252
&& ui->CBEnablePanUD->isChecked());
253
ui->SliderPanUD->setEnabled(ui->CBTranslations->isChecked() && ui->CBEnablePanUD->isChecked());
254
ui->CBEnableZoom->setEnabled(ui->CBTranslations->isChecked());
255
ui->CBReverseZoom->setEnabled(ui->CBTranslations->isChecked() && ui->CBEnableZoom->isChecked());
256
ui->SliderZoom->setEnabled(ui->CBTranslations->isChecked() && ui->CBEnableZoom->isChecked());
259
void DlgCustomizeSpNavSettings::on_SliderGlobal_sliderReleased()
261
spaceballMotionGroup()->SetInt("GlobalSensitivity", ui->SliderGlobal->value());
264
void DlgCustomizeSpNavSettings::on_CBEnablePanLR_clicked()
266
spaceballMotionGroup()->SetBool("PanLREnable", ui->CBEnablePanLR->isChecked());
268
ui->CBReversePanLR->setEnabled(ui->CBEnablePanLR->isChecked());
269
ui->SliderPanLR->setEnabled(ui->CBEnablePanLR->isChecked());
272
void DlgCustomizeSpNavSettings::on_CBReversePanLR_clicked()
274
spaceballMotionGroup()->SetBool("PanLRReverse", ui->CBReversePanLR->isChecked());
277
void DlgCustomizeSpNavSettings::on_SliderPanLR_sliderReleased()
279
spaceballMotionGroup()->SetInt("PanLRSensitivity", ui->SliderPanLR->value());
282
void DlgCustomizeSpNavSettings::on_CBEnablePanUD_clicked()
284
spaceballMotionGroup()->SetBool("PanUDEnable", ui->CBEnablePanUD->isChecked());
286
ui->CBReversePanUD->setEnabled(ui->CBEnablePanUD->isChecked());
287
ui->SliderPanUD->setEnabled(ui->CBEnablePanUD->isChecked());
290
void DlgCustomizeSpNavSettings::on_CBReversePanUD_clicked()
292
spaceballMotionGroup()->SetBool("PanUDReverse", ui->CBReversePanUD->isChecked());
295
void DlgCustomizeSpNavSettings::on_SliderPanUD_sliderReleased()
297
spaceballMotionGroup()->SetInt("PanUDSensitivity", ui->SliderPanUD->value());
300
void DlgCustomizeSpNavSettings::on_CBEnableZoom_clicked()
302
spaceballMotionGroup()->SetBool("ZoomEnable", ui->CBEnableZoom->isChecked());
304
ui->CBReverseZoom->setEnabled(ui->CBEnableZoom->isChecked());
305
ui->SliderZoom->setEnabled(ui->CBEnableZoom->isChecked());
308
void DlgCustomizeSpNavSettings::on_CBReverseZoom_clicked()
310
spaceballMotionGroup()->SetBool("ZoomReverse", ui->CBReverseZoom->isChecked());
313
void DlgCustomizeSpNavSettings::on_SliderZoom_sliderReleased()
315
spaceballMotionGroup()->SetInt("ZoomSensitivity", ui->SliderZoom->value());
318
void DlgCustomizeSpNavSettings::on_CBEnableTilt_clicked()
320
spaceballMotionGroup()->SetBool("TiltEnable", ui->CBEnableTilt->isChecked());
322
ui->CBReverseTilt->setEnabled(ui->CBEnableTilt->isChecked());
323
ui->SliderTilt->setEnabled(ui->CBEnableTilt->isChecked());
326
void DlgCustomizeSpNavSettings::on_CBReverseTilt_clicked()
328
spaceballMotionGroup()->SetBool("TiltReverse", ui->CBReverseTilt->isChecked());
331
void DlgCustomizeSpNavSettings::on_SliderTilt_sliderReleased()
333
spaceballMotionGroup()->SetInt("TiltSensitivity", ui->SliderTilt->value());
336
void DlgCustomizeSpNavSettings::on_CBEnableRoll_clicked()
338
spaceballMotionGroup()->SetBool("RollEnable", ui->CBEnableRoll->isChecked());
340
ui->CBReverseRoll->setEnabled(ui->CBEnableRoll->isChecked());
341
ui->SliderRoll->setEnabled(ui->CBEnableRoll->isChecked());
344
void DlgCustomizeSpNavSettings::on_CBReverseRoll_clicked()
346
spaceballMotionGroup()->SetBool("RollReverse", ui->CBReverseRoll->isChecked());
349
void DlgCustomizeSpNavSettings::on_SliderRoll_sliderReleased()
351
spaceballMotionGroup()->SetInt("RollSensitivity", ui->SliderRoll->value());
354
void DlgCustomizeSpNavSettings::on_CBEnableSpin_clicked()
356
spaceballMotionGroup()->SetBool("SpinEnable", ui->CBEnableSpin->isChecked());
358
ui->CBReverseSpin->setEnabled(ui->CBEnableSpin->isChecked());
359
ui->SliderSpin->setEnabled(ui->CBEnableSpin->isChecked());
362
void DlgCustomizeSpNavSettings::on_CBReverseSpin_clicked()
364
spaceballMotionGroup()->SetBool("SpinReverse", ui->CBReverseSpin->isChecked());
367
void DlgCustomizeSpNavSettings::on_SliderSpin_sliderReleased()
369
spaceballMotionGroup()->SetInt("SpinSensitivity", ui->SliderSpin->value());
372
void DlgCustomizeSpNavSettings::onAddMacroAction(const QByteArray& macroName)
374
// don't need to do anything here.
378
void DlgCustomizeSpNavSettings::onRemoveMacroAction(const QByteArray& macroName)
380
// don't need to do anything here.
384
void DlgCustomizeSpNavSettings::onModifyMacroAction(const QByteArray& macroName)
386
// don't need to do anything here.
390
#include "moc_DlgCustomizeSpNavSettings.cpp"