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());
42
if (!app->isSpaceballPresent())
44
this->setWindowTitle(tr("Spaceball Motion"));
45
this->setMessage(tr("No Spaceball Present"));
54
DlgCustomizeSpNavSettings::~DlgCustomizeSpNavSettings() = default;
56
void DlgCustomizeSpNavSettings::setupConnections()
58
connect(ui->CBDominant, &QCheckBox::clicked,
59
this, &DlgCustomizeSpNavSettings::on_CBDominant_clicked);
60
connect(ui->CBFlipYZ, &QCheckBox::clicked,
61
this, &DlgCustomizeSpNavSettings::on_CBFlipYZ_clicked);
62
connect(ui->CBRotations, &QCheckBox::clicked,
63
this, &DlgCustomizeSpNavSettings::on_CBRotations_clicked);
64
connect(ui->CBTranslations, &QCheckBox::clicked,
65
this, &DlgCustomizeSpNavSettings::on_CBTranslations_clicked);
66
connect(ui->SliderGlobal, &QSlider::sliderReleased,
67
this, &DlgCustomizeSpNavSettings::on_SliderGlobal_sliderReleased);
68
connect(ui->CBEnablePanLR, &QCheckBox::clicked,
69
this, &DlgCustomizeSpNavSettings::on_CBEnablePanLR_clicked);
70
connect(ui->CBReversePanLR, &QCheckBox::clicked,
71
this, &DlgCustomizeSpNavSettings::on_CBReversePanLR_clicked);
72
connect(ui->SliderPanLR, &QSlider::sliderReleased,
73
this, &DlgCustomizeSpNavSettings::on_SliderPanLR_sliderReleased);
74
connect(ui->CBEnablePanUD, &QCheckBox::clicked,
75
this, &DlgCustomizeSpNavSettings::on_CBEnablePanUD_clicked);
76
connect(ui->CBReversePanUD, &QCheckBox::clicked,
77
this, &DlgCustomizeSpNavSettings::on_CBReversePanUD_clicked);
78
connect(ui->SliderPanUD, &QSlider::sliderReleased,
79
this, &DlgCustomizeSpNavSettings::on_SliderPanUD_sliderReleased);
80
connect(ui->CBEnableZoom, &QCheckBox::clicked,
81
this, &DlgCustomizeSpNavSettings::on_CBEnableZoom_clicked);
82
connect(ui->CBReverseZoom, &QCheckBox::clicked,
83
this, &DlgCustomizeSpNavSettings::on_CBReverseZoom_clicked);
84
connect(ui->SliderZoom, &QSlider::sliderReleased,
85
this, &DlgCustomizeSpNavSettings::on_SliderZoom_sliderReleased);
86
connect(ui->CBEnableTilt, &QCheckBox::clicked,
87
this, &DlgCustomizeSpNavSettings::on_CBEnableTilt_clicked);
88
connect(ui->CBReverseTilt, &QCheckBox::clicked,
89
this, &DlgCustomizeSpNavSettings::on_CBReverseTilt_clicked);
90
connect(ui->SliderTilt, &QSlider::sliderReleased,
91
this, &DlgCustomizeSpNavSettings::on_SliderTilt_sliderReleased);
92
connect(ui->CBEnableRoll, &QCheckBox::clicked,
93
this, &DlgCustomizeSpNavSettings::on_CBEnableRoll_clicked);
94
connect(ui->CBReverseRoll, &QCheckBox::clicked,
95
this, &DlgCustomizeSpNavSettings::on_CBReverseRoll_clicked);
96
connect(ui->SliderRoll, &QSlider::sliderReleased,
97
this, &DlgCustomizeSpNavSettings::on_SliderRoll_sliderReleased);
98
connect(ui->CBEnableSpin, &QCheckBox::clicked,
99
this, &DlgCustomizeSpNavSettings::on_CBEnableSpin_clicked);
100
connect(ui->CBReverseSpin, &QCheckBox::clicked,
101
this, &DlgCustomizeSpNavSettings::on_CBReverseSpin_clicked);
102
connect(ui->SliderSpin, &QSlider::sliderReleased,
103
this, &DlgCustomizeSpNavSettings::on_SliderSpin_sliderReleased);
104
connect(ui->ButtonDefaultSpNavMotions, &QPushButton::clicked,
105
this, &DlgCustomizeSpNavSettings::on_ButtonDefaultSpNavMotions_clicked);
106
connect(ui->ButtonCalibrate, &QPushButton::clicked,
107
this, &DlgCustomizeSpNavSettings::on_ButtonCalibrate_clicked);
110
void DlgCustomizeSpNavSettings::setMessage(const QString& message)
112
auto messageLabel = new QLabel(message,this);
113
auto layout = new QVBoxLayout();
114
auto layout2 = new QHBoxLayout();
115
layout2->addStretch();
116
layout2->addWidget(messageLabel);
117
layout2->addStretch();
118
layout->addItem(layout2);
119
this->setLayout(layout);
122
void DlgCustomizeSpNavSettings::changeEvent(QEvent *e)
124
if (e->type() == QEvent::LanguageChange) {
126
ui->retranslateUi(this);
129
this->setWindowTitle(tr("Spaceball Motion"));
130
QLabel *messageLabel = this->findChild<QLabel*>();
131
if (messageLabel) messageLabel->setText(tr("No Spaceball Present"));
134
QWidget::changeEvent(e);
137
ParameterGrp::handle DlgCustomizeSpNavSettings::spaceballMotionGroup() const
139
static ParameterGrp::handle group = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Spaceball")->GetGroup("Motion");
143
void DlgCustomizeSpNavSettings::on_ButtonCalibrate_clicked()
145
spaceballMotionGroup()->SetBool("Calibrate", true);
148
void DlgCustomizeSpNavSettings::initialize()
150
ui->CBDominant->setChecked(spaceballMotionGroup()->GetBool("Dominant", false));
151
ui->CBFlipYZ->setChecked(spaceballMotionGroup()->GetBool("FlipYZ", false));
152
ui->CBRotations->setChecked(spaceballMotionGroup()->GetBool("Rotations", true));
153
ui->CBTranslations->setChecked(spaceballMotionGroup()->GetBool("Translations", true));
154
ui->SliderGlobal->setValue(spaceballMotionGroup()->GetInt("GlobalSensitivity", 0));
156
ui->CBEnablePanLR ->setChecked(spaceballMotionGroup()->GetBool("PanLREnable", true));
157
ui->CBReversePanLR->setChecked(spaceballMotionGroup()->GetBool("PanLRReverse", false));
158
ui->SliderPanLR ->setValue(spaceballMotionGroup()->GetInt("PanLRSensitivity", 0));
160
ui->CBEnablePanUD ->setChecked(spaceballMotionGroup()->GetBool("PanUDEnable", true));
161
ui->CBReversePanUD->setChecked(spaceballMotionGroup()->GetBool("PanUDReverse", false));
162
ui->SliderPanUD ->setValue(spaceballMotionGroup()->GetInt("PanUDSensitivity", 0));
164
ui->CBEnableZoom ->setChecked(spaceballMotionGroup()->GetBool("ZoomEnable", true));
165
ui->CBReverseZoom->setChecked(spaceballMotionGroup()->GetBool("ZoomReverse", false));
166
ui->SliderZoom ->setValue(spaceballMotionGroup()->GetInt("ZoomSensitivity", 0));
168
ui->CBEnableTilt ->setChecked(spaceballMotionGroup()->GetBool("TiltEnable", true));
169
ui->CBReverseTilt->setChecked(spaceballMotionGroup()->GetBool("TiltReverse", false));
170
ui->SliderTilt ->setValue(spaceballMotionGroup()->GetInt("TiltSensitivity", 0));
172
ui->CBEnableRoll ->setChecked(spaceballMotionGroup()->GetBool("RollEnable", true));
173
ui->CBReverseRoll->setChecked(spaceballMotionGroup()->GetBool("RollReverse", false));
174
ui->SliderRoll ->setValue(spaceballMotionGroup()->GetInt("RollSensitivity", 0));
176
ui->CBEnableSpin ->setChecked(spaceballMotionGroup()->GetBool("SpinEnable", true));
177
ui->CBReverseSpin->setChecked(spaceballMotionGroup()->GetBool("SpinReverse", false));
178
ui->SliderSpin ->setValue(spaceballMotionGroup()->GetInt("SpinSensitivity", 0));
180
ui->CBEnableTilt ->setEnabled(ui->CBRotations->isChecked());
181
ui->CBReverseTilt->setEnabled(ui->CBRotations->isChecked() && ui->CBEnableTilt->isChecked());
182
ui->SliderTilt ->setEnabled(ui->CBRotations->isChecked() && ui->CBEnableTilt->isChecked());
183
ui->CBEnableRoll ->setEnabled(ui->CBRotations->isChecked());
184
ui->CBReverseRoll->setEnabled(ui->CBRotations->isChecked() && ui->CBEnableRoll->isChecked());
185
ui->SliderRoll ->setEnabled(ui->CBRotations->isChecked() && ui->CBEnableRoll->isChecked());
186
ui->CBEnableSpin ->setEnabled(ui->CBRotations->isChecked());
187
ui->CBReverseSpin->setEnabled(ui->CBRotations->isChecked() && ui->CBEnableSpin->isChecked());
188
ui->SliderSpin ->setEnabled(ui->CBRotations->isChecked() && ui->CBEnableSpin->isChecked());
190
ui->CBEnablePanLR ->setEnabled(ui->CBTranslations->isChecked());
191
ui->CBReversePanLR->setEnabled(ui->CBTranslations->isChecked() && ui->CBEnablePanLR->isChecked());
192
ui->SliderPanLR ->setEnabled(ui->CBTranslations->isChecked() && ui->CBEnablePanLR->isChecked());
193
ui->CBEnablePanUD ->setEnabled(ui->CBTranslations->isChecked());
194
ui->CBReversePanUD->setEnabled(ui->CBTranslations->isChecked() && ui->CBEnablePanUD->isChecked());
195
ui->SliderPanUD ->setEnabled(ui->CBTranslations->isChecked() && ui->CBEnablePanUD->isChecked());
196
ui->CBEnableZoom ->setEnabled(ui->CBTranslations->isChecked());
197
ui->CBReverseZoom ->setEnabled(ui->CBTranslations->isChecked() && ui->CBEnableZoom->isChecked());
198
ui->SliderZoom ->setEnabled(ui->CBTranslations->isChecked() && ui->CBEnableZoom->isChecked());
201
void DlgCustomizeSpNavSettings::on_ButtonDefaultSpNavMotions_clicked()
203
spaceballMotionGroup()->Clear();
207
void DlgCustomizeSpNavSettings::on_CBDominant_clicked()
209
spaceballMotionGroup()->SetBool("Dominant", ui->CBDominant->isChecked());
212
void DlgCustomizeSpNavSettings::on_CBFlipYZ_clicked()
214
spaceballMotionGroup()->SetBool("FlipYZ", ui->CBFlipYZ->isChecked());
217
void DlgCustomizeSpNavSettings::on_CBRotations_clicked()
219
spaceballMotionGroup()->SetBool("Rotations", ui->CBRotations->isChecked());
221
ui->CBEnableTilt ->setEnabled(ui->CBRotations->isChecked());
222
ui->CBReverseTilt->setEnabled(ui->CBRotations->isChecked() && ui->CBEnableTilt->isChecked());
223
ui->SliderTilt ->setEnabled(ui->CBRotations->isChecked() && ui->CBEnableTilt->isChecked());
224
ui->CBEnableRoll ->setEnabled(ui->CBRotations->isChecked());
225
ui->CBReverseRoll->setEnabled(ui->CBRotations->isChecked() && ui->CBEnableRoll->isChecked());
226
ui->SliderRoll ->setEnabled(ui->CBRotations->isChecked() && ui->CBEnableRoll->isChecked());
227
ui->CBEnableSpin ->setEnabled(ui->CBRotations->isChecked());
228
ui->CBReverseSpin->setEnabled(ui->CBRotations->isChecked() && ui->CBEnableSpin->isChecked());
229
ui->SliderSpin ->setEnabled(ui->CBRotations->isChecked() && ui->CBEnableSpin->isChecked());
232
void DlgCustomizeSpNavSettings::on_CBTranslations_clicked()
234
spaceballMotionGroup()->SetBool("Translations", ui->CBTranslations->isChecked());
236
ui->CBEnablePanLR ->setEnabled(ui->CBTranslations->isChecked());
237
ui->CBReversePanLR->setEnabled(ui->CBTranslations->isChecked() && ui->CBEnablePanLR->isChecked());
238
ui->SliderPanLR ->setEnabled(ui->CBTranslations->isChecked() && ui->CBEnablePanLR->isChecked());
239
ui->CBEnablePanUD ->setEnabled(ui->CBTranslations->isChecked());
240
ui->CBReversePanUD->setEnabled(ui->CBTranslations->isChecked() && ui->CBEnablePanUD->isChecked());
241
ui->SliderPanUD ->setEnabled(ui->CBTranslations->isChecked() && ui->CBEnablePanUD->isChecked());
242
ui->CBEnableZoom ->setEnabled(ui->CBTranslations->isChecked());
243
ui->CBReverseZoom ->setEnabled(ui->CBTranslations->isChecked() && ui->CBEnableZoom->isChecked());
244
ui->SliderZoom ->setEnabled(ui->CBTranslations->isChecked() && ui->CBEnableZoom->isChecked());
247
void DlgCustomizeSpNavSettings::on_SliderGlobal_sliderReleased()
249
spaceballMotionGroup()->SetInt("GlobalSensitivity", ui->SliderGlobal->value());
252
void DlgCustomizeSpNavSettings::on_CBEnablePanLR_clicked()
254
spaceballMotionGroup()->SetBool("PanLREnable", ui->CBEnablePanLR->isChecked());
256
ui->CBReversePanLR->setEnabled(ui->CBEnablePanLR->isChecked());
257
ui->SliderPanLR ->setEnabled(ui->CBEnablePanLR->isChecked());
260
void DlgCustomizeSpNavSettings::on_CBReversePanLR_clicked()
262
spaceballMotionGroup()->SetBool("PanLRReverse", ui->CBReversePanLR->isChecked());
265
void DlgCustomizeSpNavSettings::on_SliderPanLR_sliderReleased()
267
spaceballMotionGroup()->SetInt("PanLRSensitivity", ui->SliderPanLR->value());
270
void DlgCustomizeSpNavSettings::on_CBEnablePanUD_clicked()
272
spaceballMotionGroup()->SetBool("PanUDEnable", ui->CBEnablePanUD->isChecked());
274
ui->CBReversePanUD->setEnabled(ui->CBEnablePanUD->isChecked());
275
ui->SliderPanUD ->setEnabled(ui->CBEnablePanUD->isChecked());
278
void DlgCustomizeSpNavSettings::on_CBReversePanUD_clicked()
280
spaceballMotionGroup()->SetBool("PanUDReverse", ui->CBReversePanUD->isChecked());
283
void DlgCustomizeSpNavSettings::on_SliderPanUD_sliderReleased()
285
spaceballMotionGroup()->SetInt("PanUDSensitivity", ui->SliderPanUD->value());
288
void DlgCustomizeSpNavSettings::on_CBEnableZoom_clicked()
290
spaceballMotionGroup()->SetBool("ZoomEnable", ui->CBEnableZoom->isChecked());
292
ui->CBReverseZoom ->setEnabled(ui->CBEnableZoom->isChecked());
293
ui->SliderZoom ->setEnabled(ui->CBEnableZoom->isChecked());
296
void DlgCustomizeSpNavSettings::on_CBReverseZoom_clicked()
298
spaceballMotionGroup()->SetBool("ZoomReverse", ui->CBReverseZoom->isChecked());
301
void DlgCustomizeSpNavSettings::on_SliderZoom_sliderReleased()
303
spaceballMotionGroup()->SetInt("ZoomSensitivity", ui->SliderZoom->value());
306
void DlgCustomizeSpNavSettings::on_CBEnableTilt_clicked()
308
spaceballMotionGroup()->SetBool("TiltEnable", ui->CBEnableTilt->isChecked());
310
ui->CBReverseTilt->setEnabled(ui->CBEnableTilt->isChecked());
311
ui->SliderTilt ->setEnabled(ui->CBEnableTilt->isChecked());
314
void DlgCustomizeSpNavSettings::on_CBReverseTilt_clicked()
316
spaceballMotionGroup()->SetBool("TiltReverse", ui->CBReverseTilt->isChecked());
319
void DlgCustomizeSpNavSettings::on_SliderTilt_sliderReleased()
321
spaceballMotionGroup()->SetInt("TiltSensitivity", ui->SliderTilt->value());
324
void DlgCustomizeSpNavSettings::on_CBEnableRoll_clicked()
326
spaceballMotionGroup()->SetBool("RollEnable", ui->CBEnableRoll->isChecked());
328
ui->CBReverseRoll->setEnabled(ui->CBEnableRoll->isChecked());
329
ui->SliderRoll ->setEnabled(ui->CBEnableRoll->isChecked());
332
void DlgCustomizeSpNavSettings::on_CBReverseRoll_clicked()
334
spaceballMotionGroup()->SetBool("RollReverse", ui->CBReverseRoll->isChecked());
337
void DlgCustomizeSpNavSettings::on_SliderRoll_sliderReleased()
339
spaceballMotionGroup()->SetInt("RollSensitivity", ui->SliderRoll->value());
342
void DlgCustomizeSpNavSettings::on_CBEnableSpin_clicked()
344
spaceballMotionGroup()->SetBool("SpinEnable", ui->CBEnableSpin->isChecked());
346
ui->CBReverseSpin->setEnabled(ui->CBEnableSpin->isChecked());
347
ui->SliderSpin ->setEnabled(ui->CBEnableSpin->isChecked());
350
void DlgCustomizeSpNavSettings::on_CBReverseSpin_clicked()
352
spaceballMotionGroup()->SetBool("SpinReverse", ui->CBReverseSpin->isChecked());
355
void DlgCustomizeSpNavSettings::on_SliderSpin_sliderReleased()
357
spaceballMotionGroup()->SetInt("SpinSensitivity", ui->SliderSpin->value());
360
void DlgCustomizeSpNavSettings::onAddMacroAction(const QByteArray ¯oName)
362
//don't need to do anything here.
366
void DlgCustomizeSpNavSettings::onRemoveMacroAction(const QByteArray ¯oName)
368
//don't need to do anything here.
372
void DlgCustomizeSpNavSettings::onModifyMacroAction(const QByteArray ¯oName)
374
//don't need to do anything here.
378
#include "moc_DlgCustomizeSpNavSettings.cpp"