FreeCAD

Форк
0
/
DlgCustomizeSpNavSettings.cpp 
390 строк · 16.9 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2012 Petar Perisin <petar.perisin@gmail.com>            *
3
 *                                                                         *
4
 *   This file is part of the FreeCAD CAx development system.              *
5
 *                                                                         *
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.      *
10
 *                                                                         *
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.                  *
15
 *                                                                         *
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                                *
20
 *                                                                         *
21
 ***************************************************************************/
22

23
#include "PreCompiled.h"
24

25
#include "DlgCustomizeSpNavSettings.h"
26
#include "ui_DlgCustomizeSpNavSettings.h"
27
#include "Application.h"
28
#include "GuiApplicationNativeEventAware.h"
29

30

31
using namespace Gui::Dialog;
32

33
DlgCustomizeSpNavSettings::DlgCustomizeSpNavSettings(QWidget* parent)
34
    : CustomizeActionPage(parent)
35
    , ui(new Ui_DlgCustomizeSpNavSettings)
36
    , init(false)
37
{
38
    auto app = qobject_cast<GUIApplicationNativeEventAware*>(QApplication::instance());
39

40
    if (!app) {
41
        return;
42
    }
43
    if (!app->isSpaceballPresent()) {
44
        this->setWindowTitle(tr("Spaceball Motion"));
45
        this->setMessage(tr("No Spaceball Present"));
46
        return;
47
    }
48
    this->init = true;
49
    ui->setupUi(this);
50
    setupConnections();
51
    initialize();
52
}
53

54
DlgCustomizeSpNavSettings::~DlgCustomizeSpNavSettings() = default;
55

56
void DlgCustomizeSpNavSettings::setupConnections()
57
{
58
    // clang-format off
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);
109
    // clang-format on
110
}
111

112
void DlgCustomizeSpNavSettings::setMessage(const QString& message)
113
{
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);
122
}
123

124
void DlgCustomizeSpNavSettings::changeEvent(QEvent* e)
125
{
126
    if (e->type() == QEvent::LanguageChange) {
127
        if (this->init) {
128
            ui->retranslateUi(this);
129
        }
130
        else {
131
            this->setWindowTitle(tr("Spaceball Motion"));
132
            QLabel* messageLabel = this->findChild<QLabel*>();
133
            if (messageLabel) {
134
                messageLabel->setText(tr("No Spaceball Present"));
135
            }
136
        }
137
    }
138
    QWidget::changeEvent(e);
139
}
140

141
ParameterGrp::handle DlgCustomizeSpNavSettings::spaceballMotionGroup() const
142
{
143
    static ParameterGrp::handle group = App::GetApplication()
144
                                            .GetUserParameter()
145
                                            .GetGroup("BaseApp")
146
                                            ->GetGroup("Spaceball")
147
                                            ->GetGroup("Motion");
148
    return group;
149
}
150

151
void DlgCustomizeSpNavSettings::on_ButtonCalibrate_clicked()
152
{
153
    spaceballMotionGroup()->SetBool("Calibrate", true);
154
}
155

156
void DlgCustomizeSpNavSettings::initialize()
157
{
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));
163

164
    ui->CBEnablePanLR->setChecked(spaceballMotionGroup()->GetBool("PanLREnable", true));
165
    ui->CBReversePanLR->setChecked(spaceballMotionGroup()->GetBool("PanLRReverse", false));
166
    ui->SliderPanLR->setValue(spaceballMotionGroup()->GetInt("PanLRSensitivity", 0));
167

168
    ui->CBEnablePanUD->setChecked(spaceballMotionGroup()->GetBool("PanUDEnable", true));
169
    ui->CBReversePanUD->setChecked(spaceballMotionGroup()->GetBool("PanUDReverse", false));
170
    ui->SliderPanUD->setValue(spaceballMotionGroup()->GetInt("PanUDSensitivity", 0));
171

172
    ui->CBEnableZoom->setChecked(spaceballMotionGroup()->GetBool("ZoomEnable", true));
173
    ui->CBReverseZoom->setChecked(spaceballMotionGroup()->GetBool("ZoomReverse", false));
174
    ui->SliderZoom->setValue(spaceballMotionGroup()->GetInt("ZoomSensitivity", 0));
175

176
    ui->CBEnableTilt->setChecked(spaceballMotionGroup()->GetBool("TiltEnable", true));
177
    ui->CBReverseTilt->setChecked(spaceballMotionGroup()->GetBool("TiltReverse", false));
178
    ui->SliderTilt->setValue(spaceballMotionGroup()->GetInt("TiltSensitivity", 0));
179

180
    ui->CBEnableRoll->setChecked(spaceballMotionGroup()->GetBool("RollEnable", true));
181
    ui->CBReverseRoll->setChecked(spaceballMotionGroup()->GetBool("RollReverse", false));
182
    ui->SliderRoll->setValue(spaceballMotionGroup()->GetInt("RollSensitivity", 0));
183

184
    ui->CBEnableSpin->setChecked(spaceballMotionGroup()->GetBool("SpinEnable", true));
185
    ui->CBReverseSpin->setChecked(spaceballMotionGroup()->GetBool("SpinReverse", false));
186
    ui->SliderSpin->setValue(spaceballMotionGroup()->GetInt("SpinSensitivity", 0));
187

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());
197

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());
209
}
210

211
void DlgCustomizeSpNavSettings::on_ButtonDefaultSpNavMotions_clicked()
212
{
213
    spaceballMotionGroup()->Clear();
214
    initialize();
215
}
216

217
void DlgCustomizeSpNavSettings::on_CBDominant_clicked()
218
{
219
    spaceballMotionGroup()->SetBool("Dominant", ui->CBDominant->isChecked());
220
}
221

222
void DlgCustomizeSpNavSettings::on_CBFlipYZ_clicked()
223
{
224
    spaceballMotionGroup()->SetBool("FlipYZ", ui->CBFlipYZ->isChecked());
225
}
226

227
void DlgCustomizeSpNavSettings::on_CBRotations_clicked()
228
{
229
    spaceballMotionGroup()->SetBool("Rotations", ui->CBRotations->isChecked());
230

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());
240
}
241

242
void DlgCustomizeSpNavSettings::on_CBTranslations_clicked()
243
{
244
    spaceballMotionGroup()->SetBool("Translations", ui->CBTranslations->isChecked());
245

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());
257
}
258

259
void DlgCustomizeSpNavSettings::on_SliderGlobal_sliderReleased()
260
{
261
    spaceballMotionGroup()->SetInt("GlobalSensitivity", ui->SliderGlobal->value());
262
}
263

264
void DlgCustomizeSpNavSettings::on_CBEnablePanLR_clicked()
265
{
266
    spaceballMotionGroup()->SetBool("PanLREnable", ui->CBEnablePanLR->isChecked());
267

268
    ui->CBReversePanLR->setEnabled(ui->CBEnablePanLR->isChecked());
269
    ui->SliderPanLR->setEnabled(ui->CBEnablePanLR->isChecked());
270
}
271

272
void DlgCustomizeSpNavSettings::on_CBReversePanLR_clicked()
273
{
274
    spaceballMotionGroup()->SetBool("PanLRReverse", ui->CBReversePanLR->isChecked());
275
}
276

277
void DlgCustomizeSpNavSettings::on_SliderPanLR_sliderReleased()
278
{
279
    spaceballMotionGroup()->SetInt("PanLRSensitivity", ui->SliderPanLR->value());
280
}
281

282
void DlgCustomizeSpNavSettings::on_CBEnablePanUD_clicked()
283
{
284
    spaceballMotionGroup()->SetBool("PanUDEnable", ui->CBEnablePanUD->isChecked());
285

286
    ui->CBReversePanUD->setEnabled(ui->CBEnablePanUD->isChecked());
287
    ui->SliderPanUD->setEnabled(ui->CBEnablePanUD->isChecked());
288
}
289

290
void DlgCustomizeSpNavSettings::on_CBReversePanUD_clicked()
291
{
292
    spaceballMotionGroup()->SetBool("PanUDReverse", ui->CBReversePanUD->isChecked());
293
}
294

295
void DlgCustomizeSpNavSettings::on_SliderPanUD_sliderReleased()
296
{
297
    spaceballMotionGroup()->SetInt("PanUDSensitivity", ui->SliderPanUD->value());
298
}
299

300
void DlgCustomizeSpNavSettings::on_CBEnableZoom_clicked()
301
{
302
    spaceballMotionGroup()->SetBool("ZoomEnable", ui->CBEnableZoom->isChecked());
303

304
    ui->CBReverseZoom->setEnabled(ui->CBEnableZoom->isChecked());
305
    ui->SliderZoom->setEnabled(ui->CBEnableZoom->isChecked());
306
}
307

308
void DlgCustomizeSpNavSettings::on_CBReverseZoom_clicked()
309
{
310
    spaceballMotionGroup()->SetBool("ZoomReverse", ui->CBReverseZoom->isChecked());
311
}
312

313
void DlgCustomizeSpNavSettings::on_SliderZoom_sliderReleased()
314
{
315
    spaceballMotionGroup()->SetInt("ZoomSensitivity", ui->SliderZoom->value());
316
}
317

318
void DlgCustomizeSpNavSettings::on_CBEnableTilt_clicked()
319
{
320
    spaceballMotionGroup()->SetBool("TiltEnable", ui->CBEnableTilt->isChecked());
321

322
    ui->CBReverseTilt->setEnabled(ui->CBEnableTilt->isChecked());
323
    ui->SliderTilt->setEnabled(ui->CBEnableTilt->isChecked());
324
}
325

326
void DlgCustomizeSpNavSettings::on_CBReverseTilt_clicked()
327
{
328
    spaceballMotionGroup()->SetBool("TiltReverse", ui->CBReverseTilt->isChecked());
329
}
330

331
void DlgCustomizeSpNavSettings::on_SliderTilt_sliderReleased()
332
{
333
    spaceballMotionGroup()->SetInt("TiltSensitivity", ui->SliderTilt->value());
334
}
335

336
void DlgCustomizeSpNavSettings::on_CBEnableRoll_clicked()
337
{
338
    spaceballMotionGroup()->SetBool("RollEnable", ui->CBEnableRoll->isChecked());
339

340
    ui->CBReverseRoll->setEnabled(ui->CBEnableRoll->isChecked());
341
    ui->SliderRoll->setEnabled(ui->CBEnableRoll->isChecked());
342
}
343

344
void DlgCustomizeSpNavSettings::on_CBReverseRoll_clicked()
345
{
346
    spaceballMotionGroup()->SetBool("RollReverse", ui->CBReverseRoll->isChecked());
347
}
348

349
void DlgCustomizeSpNavSettings::on_SliderRoll_sliderReleased()
350
{
351
    spaceballMotionGroup()->SetInt("RollSensitivity", ui->SliderRoll->value());
352
}
353

354
void DlgCustomizeSpNavSettings::on_CBEnableSpin_clicked()
355
{
356
    spaceballMotionGroup()->SetBool("SpinEnable", ui->CBEnableSpin->isChecked());
357

358
    ui->CBReverseSpin->setEnabled(ui->CBEnableSpin->isChecked());
359
    ui->SliderSpin->setEnabled(ui->CBEnableSpin->isChecked());
360
}
361

362
void DlgCustomizeSpNavSettings::on_CBReverseSpin_clicked()
363
{
364
    spaceballMotionGroup()->SetBool("SpinReverse", ui->CBReverseSpin->isChecked());
365
}
366

367
void DlgCustomizeSpNavSettings::on_SliderSpin_sliderReleased()
368
{
369
    spaceballMotionGroup()->SetInt("SpinSensitivity", ui->SliderSpin->value());
370
}
371

372
void DlgCustomizeSpNavSettings::onAddMacroAction(const QByteArray& macroName)
373
{
374
    // don't need to do anything here.
375
    Q_UNUSED(macroName);
376
}
377

378
void DlgCustomizeSpNavSettings::onRemoveMacroAction(const QByteArray& macroName)
379
{
380
    // don't need to do anything here.
381
    Q_UNUSED(macroName);
382
}
383

384
void DlgCustomizeSpNavSettings::onModifyMacroAction(const QByteArray& macroName)
385
{
386
    // don't need to do anything here.
387
    Q_UNUSED(macroName);
388
}
389

390
#include "moc_DlgCustomizeSpNavSettings.cpp"
391

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.