FreeCAD

Форк
0
/
DlgCustomizeSpNavSettings.cpp 
378 строк · 16.6 Кб
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
    if (!app->isSpaceballPresent())
43
    {
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
    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);
108
}
109

110
void DlgCustomizeSpNavSettings::setMessage(const QString& message)
111
{
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);
120
}
121

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

137
ParameterGrp::handle DlgCustomizeSpNavSettings::spaceballMotionGroup() const
138
{
139
    static ParameterGrp::handle group = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Spaceball")->GetGroup("Motion");
140
    return group;
141
}
142

143
void DlgCustomizeSpNavSettings::on_ButtonCalibrate_clicked()
144
{
145
    spaceballMotionGroup()->SetBool("Calibrate", true);
146
}
147

148
void DlgCustomizeSpNavSettings::initialize()
149
{
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));
155

156
    ui->CBEnablePanLR ->setChecked(spaceballMotionGroup()->GetBool("PanLREnable", true));
157
    ui->CBReversePanLR->setChecked(spaceballMotionGroup()->GetBool("PanLRReverse", false));
158
    ui->SliderPanLR   ->setValue(spaceballMotionGroup()->GetInt("PanLRSensitivity", 0));
159

160
    ui->CBEnablePanUD ->setChecked(spaceballMotionGroup()->GetBool("PanUDEnable", true));
161
    ui->CBReversePanUD->setChecked(spaceballMotionGroup()->GetBool("PanUDReverse", false));
162
    ui->SliderPanUD   ->setValue(spaceballMotionGroup()->GetInt("PanUDSensitivity", 0));
163

164
    ui->CBEnableZoom ->setChecked(spaceballMotionGroup()->GetBool("ZoomEnable", true));
165
    ui->CBReverseZoom->setChecked(spaceballMotionGroup()->GetBool("ZoomReverse", false));
166
    ui->SliderZoom   ->setValue(spaceballMotionGroup()->GetInt("ZoomSensitivity", 0));
167

168
    ui->CBEnableTilt ->setChecked(spaceballMotionGroup()->GetBool("TiltEnable", true));
169
    ui->CBReverseTilt->setChecked(spaceballMotionGroup()->GetBool("TiltReverse", false));
170
    ui->SliderTilt   ->setValue(spaceballMotionGroup()->GetInt("TiltSensitivity", 0));
171

172
    ui->CBEnableRoll ->setChecked(spaceballMotionGroup()->GetBool("RollEnable", true));
173
    ui->CBReverseRoll->setChecked(spaceballMotionGroup()->GetBool("RollReverse", false));
174
    ui->SliderRoll   ->setValue(spaceballMotionGroup()->GetInt("RollSensitivity", 0));
175

176
    ui->CBEnableSpin ->setChecked(spaceballMotionGroup()->GetBool("SpinEnable", true));
177
    ui->CBReverseSpin->setChecked(spaceballMotionGroup()->GetBool("SpinReverse", false));
178
    ui->SliderSpin   ->setValue(spaceballMotionGroup()->GetInt("SpinSensitivity", 0));
179

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

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());
199
}
200

201
void DlgCustomizeSpNavSettings::on_ButtonDefaultSpNavMotions_clicked()
202
{
203
    spaceballMotionGroup()->Clear();
204
    initialize();
205
}
206

207
void DlgCustomizeSpNavSettings::on_CBDominant_clicked()
208
{
209
    spaceballMotionGroup()->SetBool("Dominant", ui->CBDominant->isChecked());
210
}
211

212
void DlgCustomizeSpNavSettings::on_CBFlipYZ_clicked()
213
{
214
    spaceballMotionGroup()->SetBool("FlipYZ", ui->CBFlipYZ->isChecked());
215
}
216

217
void DlgCustomizeSpNavSettings::on_CBRotations_clicked()
218
{
219
    spaceballMotionGroup()->SetBool("Rotations", ui->CBRotations->isChecked());
220

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());
230
}
231

232
void DlgCustomizeSpNavSettings::on_CBTranslations_clicked()
233
{
234
    spaceballMotionGroup()->SetBool("Translations", ui->CBTranslations->isChecked());
235

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());
245
}
246

247
void DlgCustomizeSpNavSettings::on_SliderGlobal_sliderReleased()
248
{
249
    spaceballMotionGroup()->SetInt("GlobalSensitivity", ui->SliderGlobal->value());
250
}
251

252
void DlgCustomizeSpNavSettings::on_CBEnablePanLR_clicked()
253
{
254
    spaceballMotionGroup()->SetBool("PanLREnable", ui->CBEnablePanLR->isChecked());
255

256
    ui->CBReversePanLR->setEnabled(ui->CBEnablePanLR->isChecked());
257
    ui->SliderPanLR   ->setEnabled(ui->CBEnablePanLR->isChecked());
258
}
259

260
void DlgCustomizeSpNavSettings::on_CBReversePanLR_clicked()
261
{
262
    spaceballMotionGroup()->SetBool("PanLRReverse", ui->CBReversePanLR->isChecked());
263
}
264

265
void DlgCustomizeSpNavSettings::on_SliderPanLR_sliderReleased()
266
{
267
    spaceballMotionGroup()->SetInt("PanLRSensitivity", ui->SliderPanLR->value());
268
}
269

270
void DlgCustomizeSpNavSettings::on_CBEnablePanUD_clicked()
271
{
272
    spaceballMotionGroup()->SetBool("PanUDEnable", ui->CBEnablePanUD->isChecked());
273

274
    ui->CBReversePanUD->setEnabled(ui->CBEnablePanUD->isChecked());
275
    ui->SliderPanUD   ->setEnabled(ui->CBEnablePanUD->isChecked());
276
}
277

278
void DlgCustomizeSpNavSettings::on_CBReversePanUD_clicked()
279
{
280
    spaceballMotionGroup()->SetBool("PanUDReverse", ui->CBReversePanUD->isChecked());
281
}
282

283
void DlgCustomizeSpNavSettings::on_SliderPanUD_sliderReleased()
284
{
285
    spaceballMotionGroup()->SetInt("PanUDSensitivity", ui->SliderPanUD->value());
286
}
287

288
void DlgCustomizeSpNavSettings::on_CBEnableZoom_clicked()
289
{
290
    spaceballMotionGroup()->SetBool("ZoomEnable", ui->CBEnableZoom->isChecked());
291

292
    ui->CBReverseZoom ->setEnabled(ui->CBEnableZoom->isChecked());
293
    ui->SliderZoom    ->setEnabled(ui->CBEnableZoom->isChecked());
294
}
295

296
void DlgCustomizeSpNavSettings::on_CBReverseZoom_clicked()
297
{
298
    spaceballMotionGroup()->SetBool("ZoomReverse", ui->CBReverseZoom->isChecked());
299
}
300

301
void DlgCustomizeSpNavSettings::on_SliderZoom_sliderReleased()
302
{
303
    spaceballMotionGroup()->SetInt("ZoomSensitivity", ui->SliderZoom->value());
304
}
305

306
void DlgCustomizeSpNavSettings::on_CBEnableTilt_clicked()
307
{
308
    spaceballMotionGroup()->SetBool("TiltEnable", ui->CBEnableTilt->isChecked());
309

310
    ui->CBReverseTilt->setEnabled(ui->CBEnableTilt->isChecked());
311
    ui->SliderTilt   ->setEnabled(ui->CBEnableTilt->isChecked());
312
}
313

314
void DlgCustomizeSpNavSettings::on_CBReverseTilt_clicked()
315
{
316
    spaceballMotionGroup()->SetBool("TiltReverse", ui->CBReverseTilt->isChecked());
317
}
318

319
void DlgCustomizeSpNavSettings::on_SliderTilt_sliderReleased()
320
{
321
    spaceballMotionGroup()->SetInt("TiltSensitivity", ui->SliderTilt->value());
322
}
323

324
void DlgCustomizeSpNavSettings::on_CBEnableRoll_clicked()
325
{
326
    spaceballMotionGroup()->SetBool("RollEnable", ui->CBEnableRoll->isChecked());
327

328
    ui->CBReverseRoll->setEnabled(ui->CBEnableRoll->isChecked());
329
    ui->SliderRoll   ->setEnabled(ui->CBEnableRoll->isChecked());
330
}
331

332
void DlgCustomizeSpNavSettings::on_CBReverseRoll_clicked()
333
{
334
    spaceballMotionGroup()->SetBool("RollReverse", ui->CBReverseRoll->isChecked());
335
}
336

337
void DlgCustomizeSpNavSettings::on_SliderRoll_sliderReleased()
338
{
339
    spaceballMotionGroup()->SetInt("RollSensitivity", ui->SliderRoll->value());
340
}
341

342
void DlgCustomizeSpNavSettings::on_CBEnableSpin_clicked()
343
{
344
    spaceballMotionGroup()->SetBool("SpinEnable", ui->CBEnableSpin->isChecked());
345

346
    ui->CBReverseSpin->setEnabled(ui->CBEnableSpin->isChecked());
347
    ui->SliderSpin   ->setEnabled(ui->CBEnableSpin->isChecked());
348
}
349

350
void DlgCustomizeSpNavSettings::on_CBReverseSpin_clicked()
351
{
352
    spaceballMotionGroup()->SetBool("SpinReverse", ui->CBReverseSpin->isChecked());
353
}
354

355
void DlgCustomizeSpNavSettings::on_SliderSpin_sliderReleased()
356
{
357
    spaceballMotionGroup()->SetInt("SpinSensitivity", ui->SliderSpin->value());
358
}
359

360
void DlgCustomizeSpNavSettings::onAddMacroAction(const QByteArray &macroName)
361
{
362
    //don't need to do anything here.
363
    Q_UNUSED(macroName);
364
}
365

366
void DlgCustomizeSpNavSettings::onRemoveMacroAction(const QByteArray &macroName)
367
{
368
    //don't need to do anything here.
369
    Q_UNUSED(macroName);
370
}
371

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

378
#include "moc_DlgCustomizeSpNavSettings.cpp"
379

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

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

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

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