FreeCAD

Форк
0
/
SketcherSettings.cpp 
668 строк · 22.7 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2014 Werner Mayer <wmayer[at]users.sourceforge.net>     *
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
#ifndef _PreComp_
25
#include <QMessageBox>
26
#include <QPainter>
27
#include <QPixmap>
28
#endif
29

30
#include <App/Application.h>
31
#include <Base/Console.h>
32
#include <Base/Interpreter.h>
33
#include <Gui/Command.h>
34

35
#include "SketcherSettings.h"
36
#include "ui_SketcherSettings.h"
37
#include "ui_SketcherSettingsAppearance.h"
38
#include "ui_SketcherSettingsDisplay.h"
39
#include "ui_SketcherSettingsGrid.h"
40

41

42
using namespace SketcherGui;
43

44
/* TRANSLATOR SketcherGui::SketcherSettings */
45

46
QList<int> getPenStyles()
47
{
48
    QList<int> styles;
49
    styles << 0b1111111111111111   // solid
50
           << 0b1110111011101110   // dashed 3:1
51
           << 0b1111110011111100   // dashed 6:2
52
           << 0b0000111100001111   // dashed 4:4
53
           << 0b1010101010101010   // point 1:1
54
           << 0b1110010011100100   // dash point
55
           << 0b1111111100111100;  // dash long-dash
56
    return styles;
57
}
58

59
const QVector<qreal> binaryPatternToDashPattern(int binaryPattern)
60
{
61
    QVector<qreal> dashPattern;
62
    int count = 0;
63
    bool isDash = (binaryPattern & 0x8000) != 0;  // Check the highest bit
64

65
    for (int i = 0; i < 16; ++i) {
66
        bool currentBit = (binaryPattern & (0x8000 >> i)) != 0;
67
        if (currentBit == isDash) {
68
            ++count;  // Counting dashes or spaces
69
        }
70
        else {
71
            // Adjust count to be odd for dashes and even for spaces (see qt doc)
72
            count = (count % 2 == (isDash ? 0 : 1)) ? count + 1 : count;
73
            dashPattern << count;
74
            count = 1;  // Reset count for next dash/space
75
            isDash = !isDash;
76
        }
77
    }
78
    count = (count % 2 == (isDash ? 0 : 1)) ? count + 1 : count;
79
    dashPattern << count;  // Add the last count
80

81
    if ((dashPattern.size() % 2) == 1) {
82
        // prevent this error : qWarning("QPen::setDashPattern: Pattern not of even length");
83
        dashPattern << 1;
84
    }
85

86
    return dashPattern;
87
}
88

89
SketcherSettings::SketcherSettings(QWidget* parent)
90
    : PreferencePage(parent)
91
    , ui(new Ui_SketcherSettings)
92
{
93
    ui->setupUi(this);
94
}
95

96
/**
97
 *  Destroys the object and frees any allocated resources
98
 */
99
SketcherSettings::~SketcherSettings()
100
{
101
    // no need to delete child widgets, Qt does it all for us
102
}
103

104
void SketcherSettings::saveSettings()
105
{
106
    // Sketch editing
107
    ui->checkBoxAdvancedSolverTaskBox->onSave();
108
    ui->checkBoxRecalculateInitialSolutionWhileDragging->onSave();
109
    ui->checkBoxEnableEscape->onSave();
110
    ui->checkBoxDisableShading->onSave();
111
    ui->checkBoxNotifyConstraintSubstitutions->onSave();
112
    ui->checkBoxAutoRemoveRedundants->onSave();
113
    ui->checkBoxUnifiedCoincident->onSave();
114
    ui->checkBoxHorVerAuto->onSave();
115

116
    enum
117
    {
118
        DimensionSingleTool,
119
        DimensionSeparateTools,
120
        DimensionBoth
121
    };
122

123
    // Dimensioning constraints mode
124
    ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
125
        "User parameter:BaseApp/Preferences/Mod/Sketcher/dimensioning");
126
    bool singleTool = true;
127
    bool SeparatedTools = false;
128
    int index = ui->dimensioningMode->currentIndex();
129
    switch (index) {
130
        case DimensionSeparateTools:
131
            singleTool = false;
132
            SeparatedTools = true;
133
            break;
134
        case DimensionBoth:
135
            singleTool = true;
136
            SeparatedTools = true;
137
            break;
138
    }
139
    hGrp->SetBool("SingleDimensioningTool", singleTool);
140
    hGrp->SetBool("SeparatedDimensioningTools", SeparatedTools);
141

142
    ui->radiusDiameterMode->setEnabled(index != 1);
143

144
    enum
145
    {
146
        DimensionAutoRadiusDiam,
147
        DimensionDiameter,
148
        DimensionRadius
149
    };
150

151
    bool Diameter = true;
152
    bool Radius = true;
153
    index = ui->radiusDiameterMode->currentIndex();
154
    switch (index) {
155
        case DimensionDiameter:
156
            Diameter = true;
157
            Radius = false;
158
            break;
159
        case DimensionRadius:
160
            Diameter = false;
161
            Radius = true;
162
            break;
163
    }
164
    hGrp->SetBool("DimensioningDiameter", Diameter);
165
    hGrp->SetBool("DimensioningRadius", Radius);
166

167
    hGrp = App::GetApplication().GetParameterGroupByPath(
168
        "User parameter:BaseApp/Preferences/Mod/Sketcher/Tools");
169

170
    index = ui->ovpVisibility->currentIndex();
171
    hGrp->SetInt("OnViewParameterVisibility", index);
172

173
    checkForRestart();
174
}
175

176
void SketcherSettings::loadSettings()
177
{
178
    // Sketch editing
179
    ui->checkBoxAdvancedSolverTaskBox->onRestore();
180
    ui->checkBoxRecalculateInitialSolutionWhileDragging->onRestore();
181
    ui->checkBoxEnableEscape->onRestore();
182
    ui->checkBoxDisableShading->onRestore();
183
    ui->checkBoxNotifyConstraintSubstitutions->onRestore();
184
    ui->checkBoxAutoRemoveRedundants->onRestore();
185
    ui->checkBoxUnifiedCoincident->onRestore();
186
    setProperty("checkBoxUnifiedCoincident", ui->checkBoxUnifiedCoincident->isChecked());
187
    ui->checkBoxHorVerAuto->onRestore();
188
    setProperty("checkBoxHorVerAuto", ui->checkBoxHorVerAuto->isChecked());
189

190
    // Dimensioning constraints mode
191
    ui->dimensioningMode->clear();
192
    ui->dimensioningMode->addItem(tr("Single tool"));
193
    ui->dimensioningMode->addItem(tr("Separated tools"));
194
    ui->dimensioningMode->addItem(tr("Both"));
195

196
    ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
197
        "User parameter:BaseApp/Preferences/Mod/Sketcher/dimensioning");
198
    bool singleTool = hGrp->GetBool("SingleDimensioningTool", true);
199
    bool SeparatedTools = hGrp->GetBool("SeparatedDimensioningTools", false);
200
    int index = SeparatedTools ? (singleTool ? 2 : 1) : 0;
201
    ui->dimensioningMode->setCurrentIndex(index);
202
    setProperty("dimensioningMode", index);
203
    connect(ui->dimensioningMode,
204
            QOverload<int>::of(&QComboBox::currentIndexChanged),
205
            this,
206
            &SketcherSettings::dimensioningModeChanged);
207

208
    ui->radiusDiameterMode->setEnabled(index != 1);
209

210
    // Dimensioning constraints mode
211
    ui->radiusDiameterMode->clear();
212
    ui->radiusDiameterMode->addItem(tr("Auto"));
213
    ui->radiusDiameterMode->addItem(tr("Diameter"));
214
    ui->radiusDiameterMode->addItem(tr("Radius"));
215

216
    bool Diameter = hGrp->GetBool("DimensioningDiameter", true);
217
    bool Radius = hGrp->GetBool("DimensioningRadius", true);
218
    index = Diameter ? (Radius ? 0 : 1) : 2;
219
    ui->radiusDiameterMode->setCurrentIndex(index);
220

221
    hGrp = App::GetApplication().GetParameterGroupByPath(
222
        "User parameter:BaseApp/Preferences/Mod/Sketcher/Tools");
223
    ui->ovpVisibility->clear();
224
    ui->ovpVisibility->addItem(tr("None"));
225
    ui->ovpVisibility->addItem(tr("Dimensions only"));
226
    ui->ovpVisibility->addItem(tr("Position and dimensions"));
227

228
    index = hGrp->GetInt("OnViewParameterVisibility", 1);
229
    ui->ovpVisibility->setCurrentIndex(index);
230
}
231

232
void SketcherSettings::dimensioningModeChanged(int index)
233
{
234
    ui->radiusDiameterMode->setEnabled(index != 1);
235
}
236

237
void SketcherSettings::checkForRestart()
238
{
239
    if (property("dimensioningMode").toInt() != ui->dimensioningMode->currentIndex()) {
240
        SketcherSettings::requireRestart();
241
    }
242
    if (property("checkBoxUnifiedCoincident").toBool()
243
        != ui->checkBoxUnifiedCoincident->isChecked()) {
244
        SketcherSettings::requireRestart();
245
    }
246
    if (property("checkBoxHorVerAuto").toBool() != ui->checkBoxHorVerAuto->isChecked()) {
247
        SketcherSettings::requireRestart();
248
    }
249
}
250

251
/**
252
 * Sets the strings of the subwidgets using the current language.
253
 */
254
void SketcherSettings::changeEvent(QEvent* e)
255
{
256
    if (e->type() == QEvent::LanguageChange) {
257
        ui->retranslateUi(this);
258
    }
259
    else {
260
        QWidget::changeEvent(e);
261
    }
262
}
263

264
void SketcherSettings::resetSettingsToDefaults()
265
{
266
    ParameterGrp::handle hGrp;
267

268
    hGrp = App::GetApplication().GetParameterGroupByPath(
269
        "User parameter:BaseApp/Preferences/Mod/Sketcher/dimensioning");
270
    // reset "Dimension tools" parameters
271
    hGrp->RemoveBool("SingleDimensioningTool");
272
    hGrp->RemoveBool("SeparatedDimensioningTools");
273

274
    // reset "radius/diameter mode for dimensioning" parameter
275
    hGrp->RemoveBool("DimensioningDiameter");
276
    hGrp->RemoveBool("DimensioningRadius");
277

278
    hGrp = App::GetApplication().GetParameterGroupByPath(
279
        "User parameter:BaseApp/Preferences/Mod/Sketcher/Tools");
280
    // reset "OVP visibility" parameter
281
    hGrp->RemoveInt("OnViewParameterVisibility");
282

283
    // finally reset all the parameters associated to Gui::Pref* widgets
284
    PreferencePage::resetSettingsToDefaults();
285
}
286

287
/* TRANSLATOR SketcherGui::SketcherSettingsGrid */
288

289
SketcherSettingsGrid::SketcherSettingsGrid(QWidget* parent)
290
    : PreferencePage(parent)
291
    , ui(new Ui_SketcherSettingsGrid)
292
{
293
    ui->setupUi(this);
294

295
    QList<int> styles = getPenStyles();
296

297
    ui->gridLinePattern->setIconSize(QSize(80, 12));
298
    ui->gridDivLinePattern->setIconSize(QSize(80, 12));
299
    for (auto& style : styles) {
300
        QPixmap px(ui->gridLinePattern->iconSize());
301
        px.fill(Qt::transparent);
302
        QBrush brush(Qt::black);
303

304
        QPen pen;
305
        pen.setDashPattern(binaryPatternToDashPattern(style));
306
        pen.setBrush(brush);
307
        pen.setWidth(2);
308

309
        QPainter painter(&px);
310
        painter.setPen(pen);
311
        double mid = ui->gridLinePattern->iconSize().height() / 2.0;
312
        painter.drawLine(0, mid, ui->gridLinePattern->iconSize().width(), mid);
313
        painter.end();
314

315
        ui->gridLinePattern->addItem(QIcon(px), QString(), QVariant(style));
316
        ui->gridDivLinePattern->addItem(QIcon(px), QString(), QVariant(style));
317
    }
318
}
319

320
SketcherSettingsGrid::~SketcherSettingsGrid()
321
{
322
    // no need to delete child widgets, Qt does it all for us
323
}
324

325
void SketcherSettingsGrid::saveSettings()
326
{
327
    ui->checkBoxShowGrid->onSave();
328
    ui->gridSize->onSave();
329
    ui->checkBoxGridAuto->onSave();
330
    ui->gridSizePixelThreshold->onSave();
331
    ui->gridLineColor->onSave();
332
    ui->gridDivLineColor->onSave();
333
    ui->gridLineWidth->onSave();
334
    ui->gridDivLineWidth->onSave();
335
    ui->gridNumberSubdivision->onSave();
336

337
    ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
338
        "User parameter:BaseApp/Preferences/Mod/Sketcher/General");
339
    QVariant data = ui->gridLinePattern->itemData(ui->gridLinePattern->currentIndex());
340
    int pattern = data.toInt();
341
    hGrp->SetInt("GridLinePattern", pattern);
342

343
    data = ui->gridDivLinePattern->itemData(ui->gridDivLinePattern->currentIndex());
344
    pattern = data.toInt();
345
    hGrp->SetInt("GridDivLinePattern", pattern);
346
}
347

348
void SketcherSettingsGrid::loadSettings()
349
{
350
    ui->checkBoxShowGrid->onRestore();
351
    ui->gridSize->onRestore();
352
    ui->checkBoxGridAuto->onRestore();
353
    ui->gridSizePixelThreshold->onRestore();
354
    ui->gridLineColor->onRestore();
355
    ui->gridDivLineColor->onRestore();
356
    ui->gridLineWidth->onRestore();
357
    ui->gridDivLineWidth->onRestore();
358
    ui->gridNumberSubdivision->onRestore();
359

360
    ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
361
        "User parameter:BaseApp/Preferences/Mod/Sketcher/General");
362
    int pattern = hGrp->GetInt("GridLinePattern", 0b0000111100001111);
363
    int index = ui->gridLinePattern->findData(QVariant(pattern));
364
    if (index < 0) {
365
        index = 1;
366
    }
367
    ui->gridLinePattern->setCurrentIndex(index);
368
    pattern = hGrp->GetInt("GridDivLinePattern", 0b1111111111111111);
369
    index = ui->gridDivLinePattern->findData(QVariant(pattern));
370
    if (index < 0) {
371
        index = 0;
372
    }
373
    ui->gridDivLinePattern->setCurrentIndex(index);
374
}
375

376
/**
377
 * Sets the strings of the subwidgets using the current language.
378
 */
379
void SketcherSettingsGrid::changeEvent(QEvent* e)
380
{
381
    if (e->type() == QEvent::LanguageChange) {
382
        ui->retranslateUi(this);
383
    }
384
    else {
385
        QWidget::changeEvent(e);
386
    }
387
}
388

389
/* TRANSLATOR SketcherGui::SketcherSettingsDisplay */
390

391
SketcherSettingsDisplay::SketcherSettingsDisplay(QWidget* parent)
392
    : PreferencePage(parent)
393
    , ui(new Ui_SketcherSettingsDisplay)
394
{
395
    ui->setupUi(this);
396

397
    connect(ui->btnTVApply,
398
            &QPushButton::clicked,
399
            this,
400
            &SketcherSettingsDisplay::onBtnTVApplyClicked);
401
}
402

403
/**
404
 *  Destroys the object and frees any allocated resources
405
 */
406
SketcherSettingsDisplay::~SketcherSettingsDisplay()
407
{
408
    // no need to delete child widgets, Qt does it all for us
409
}
410

411
void SketcherSettingsDisplay::saveSettings()
412
{
413
    ui->EditSketcherFontSize->onSave();
414
    ui->viewScalingFactor->onSave();
415
    ui->SegmentsPerGeometry->onSave();
416
    ui->dialogOnDistanceConstraint->onSave();
417
    ui->continueMode->onSave();
418
    ui->constraintMode->onSave();
419
    ui->checkBoxHideUnits->onSave();
420
    ui->checkBoxShowCursorCoords->onSave();
421
    ui->checkBoxUseSystemDecimals->onSave();
422
    ui->checkBoxShowDimensionalName->onSave();
423
    ui->prefDimensionalStringFormat->onSave();
424
    ui->checkBoxTVHideDependent->onSave();
425
    ui->checkBoxTVShowLinks->onSave();
426
    ui->checkBoxTVShowSupport->onSave();
427
    ui->checkBoxTVRestoreCamera->onSave();
428
    ui->checkBoxTVForceOrtho->onSave();
429
    ui->checkBoxTVSectionView->onSave();
430
}
431

432
void SketcherSettingsDisplay::loadSettings()
433
{
434
    ui->EditSketcherFontSize->onRestore();
435
    ui->viewScalingFactor->onRestore();
436
    ui->SegmentsPerGeometry->onRestore();
437
    ui->dialogOnDistanceConstraint->onRestore();
438
    ui->continueMode->onRestore();
439
    ui->constraintMode->onRestore();
440
    ui->checkBoxHideUnits->onRestore();
441
    ui->checkBoxShowCursorCoords->onRestore();
442
    ui->checkBoxUseSystemDecimals->onRestore();
443
    ui->checkBoxShowDimensionalName->onRestore();
444
    ui->prefDimensionalStringFormat->onRestore();
445
    ui->checkBoxTVHideDependent->onRestore();
446
    ui->checkBoxTVShowLinks->onRestore();
447
    ui->checkBoxTVShowSupport->onRestore();
448
    ui->checkBoxTVRestoreCamera->onRestore();
449
    ui->checkBoxTVForceOrtho->onRestore();
450
    this->ui->checkBoxTVForceOrtho->setEnabled(this->ui->checkBoxTVRestoreCamera->isChecked());
451
    ui->checkBoxTVSectionView->onRestore();
452
}
453

454
/**
455
 * Sets the strings of the subwidgets using the current language.
456
 */
457
void SketcherSettingsDisplay::changeEvent(QEvent* e)
458
{
459
    if (e->type() == QEvent::LanguageChange) {
460
        ui->retranslateUi(this);
461
    }
462
    else {
463
        QWidget::changeEvent(e);
464
    }
465
}
466

467
void SketcherSettingsDisplay::onBtnTVApplyClicked(bool)
468
{
469
    QString errMsg;
470
    try {
471
        Gui::Command::doCommand(Gui::Command::Gui,
472
                                "for name,doc in App.listDocuments().items():\n"
473
                                "    for sketch in doc.findObjects('Sketcher::SketchObject'):\n"
474
                                "        sketch.ViewObject.HideDependent = %s\n"
475
                                "        sketch.ViewObject.ShowLinks = %s\n"
476
                                "        sketch.ViewObject.ShowSupport = %s\n"
477
                                "        sketch.ViewObject.RestoreCamera = %s\n"
478
                                "        sketch.ViewObject.ForceOrtho = %s\n"
479
                                "        sketch.ViewObject.SectionView = %s\n",
480
                                this->ui->checkBoxTVHideDependent->isChecked() ? "True" : "False",
481
                                this->ui->checkBoxTVShowLinks->isChecked() ? "True" : "False",
482
                                this->ui->checkBoxTVShowSupport->isChecked() ? "True" : "False",
483
                                this->ui->checkBoxTVRestoreCamera->isChecked() ? "True" : "False",
484
                                this->ui->checkBoxTVForceOrtho->isChecked() ? "True" : "False",
485
                                this->ui->checkBoxTVSectionView->isChecked() ? "True" : "False");
486
    }
487
    catch (Base::PyException& e) {
488
        Base::Console().DeveloperError("SketcherSettings", "error in onBtnTVApplyClicked:\n");
489
        e.ReportException();
490
        errMsg = QString::fromLatin1(e.what());
491
    }
492
    catch (...) {
493
        errMsg = tr("Unexpected C++ exception");
494
    }
495
    if (errMsg.length() > 0) {
496
        QMessageBox::warning(this, tr("Sketcher"), errMsg);
497
    }
498
}
499

500

501
/* TRANSLATOR SketcherGui::SketcherSettingsAppearance */
502

503
SketcherSettingsAppearance::SketcherSettingsAppearance(QWidget* parent)
504
    : PreferencePage(parent)
505
    , ui(new Ui_SketcherSettingsAppearance)
506
{
507
    ui->setupUi(this);
508

509
    QList<int> styles = getPenStyles();
510

511
    ui->EdgePattern->setIconSize(QSize(70, 12));
512
    ui->ConstructionPattern->setIconSize(QSize(70, 12));
513
    ui->InternalPattern->setIconSize(QSize(70, 12));
514
    ui->ExternalPattern->setIconSize(QSize(70, 12));
515
    for (auto& style : styles) {
516
        QPixmap px(ui->EdgePattern->iconSize());
517
        px.fill(Qt::transparent);
518
        QBrush brush(Qt::black);
519
        QPen pen;
520
        pen.setDashPattern(binaryPatternToDashPattern(style));
521
        pen.setBrush(brush);
522
        pen.setWidth(2);
523

524
        QPainter painter(&px);
525
        painter.setPen(pen);
526
        double mid = ui->EdgePattern->iconSize().height() / 2.0;
527
        painter.drawLine(0, mid, ui->EdgePattern->iconSize().width(), mid);
528
        painter.end();
529

530
        ui->EdgePattern->addItem(QIcon(px), QString(), QVariant(style));
531
        ui->ConstructionPattern->addItem(QIcon(px), QString(), QVariant(style));
532
        ui->InternalPattern->addItem(QIcon(px), QString(), QVariant(style));
533
        ui->ExternalPattern->addItem(QIcon(px), QString(), QVariant(style));
534
    }
535
}
536

537
/**
538
 *  Destroys the object and frees any allocated resources
539
 */
540
SketcherSettingsAppearance::~SketcherSettingsAppearance()
541
{
542
    // no need to delete child widgets, Qt does it all for us
543
}
544

545
void SketcherSettingsAppearance::saveSettings()
546
{
547
    // Sketcher
548
    ui->SketchEdgeColor->onSave();
549
    ui->SketchVertexColor->onSave();
550
    ui->EditedEdgeColor->onSave();
551
    ui->ConstructionColor->onSave();
552
    ui->ExternalColor->onSave();
553
    ui->InvalidSketchColor->onSave();
554
    ui->FullyConstrainedColor->onSave();
555
    ui->InternalAlignedGeoColor->onSave();
556
    ui->FullyConstraintElementColor->onSave();
557
    ui->FullyConstraintConstructionElementColor->onSave();
558
    ui->FullyConstraintInternalAlignmentColor->onSave();
559

560
    ui->ConstrainedColor->onSave();
561
    ui->NonDrivingConstraintColor->onSave();
562
    ui->DatumColor->onSave();
563
    ui->ExprBasedConstrDimColor->onSave();
564
    ui->DeactivatedConstrDimColor->onSave();
565

566
    ui->CursorTextColor->onSave();
567
    ui->CursorCrosshairColor->onSave();
568
    ui->CreateLineColor->onSave();
569

570
    ui->EdgeWidth->onSave();
571
    ui->ConstructionWidth->onSave();
572
    ui->InternalWidth->onSave();
573
    ui->ExternalWidth->onSave();
574

575
    ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
576
        "User parameter:BaseApp/Preferences/Mod/Sketcher/View");
577
    QVariant data = ui->EdgePattern->itemData(ui->EdgePattern->currentIndex());
578
    int pattern = data.toInt();
579
    hGrp->SetInt("EdgePattern", pattern);
580

581
    data = ui->ConstructionPattern->itemData(ui->ConstructionPattern->currentIndex());
582
    pattern = data.toInt();
583
    hGrp->SetInt("ConstructionPattern", pattern);
584

585
    data = ui->InternalPattern->itemData(ui->InternalPattern->currentIndex());
586
    pattern = data.toInt();
587
    hGrp->SetInt("InternalPattern", pattern);
588

589
    data = ui->ExternalPattern->itemData(ui->ExternalPattern->currentIndex());
590
    pattern = data.toInt();
591
    hGrp->SetInt("ExternalPattern", pattern);
592
}
593

594
void SketcherSettingsAppearance::loadSettings()
595
{
596
    // Sketcher
597
    ui->SketchEdgeColor->onRestore();
598
    ui->SketchVertexColor->onRestore();
599
    ui->EditedEdgeColor->onRestore();
600
    ui->ConstructionColor->onRestore();
601
    ui->ExternalColor->onRestore();
602
    ui->InvalidSketchColor->onRestore();
603
    ui->FullyConstrainedColor->onRestore();
604
    ui->InternalAlignedGeoColor->onRestore();
605
    ui->FullyConstraintElementColor->onRestore();
606
    ui->FullyConstraintConstructionElementColor->onRestore();
607
    ui->FullyConstraintInternalAlignmentColor->onRestore();
608

609
    ui->ConstrainedColor->onRestore();
610
    ui->NonDrivingConstraintColor->onRestore();
611
    ui->DatumColor->onRestore();
612
    ui->ExprBasedConstrDimColor->onRestore();
613
    ui->DeactivatedConstrDimColor->onRestore();
614

615
    ui->CursorTextColor->onRestore();
616
    ui->CursorCrosshairColor->onRestore();
617
    ui->CreateLineColor->onRestore();
618

619
    ui->EdgeWidth->onRestore();
620
    ui->ConstructionWidth->onRestore();
621
    ui->InternalWidth->onRestore();
622
    ui->ExternalWidth->onRestore();
623

624
    ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
625
        "User parameter:BaseApp/Preferences/Mod/Sketcher/View");
626
    int pattern = hGrp->GetInt("EdgePattern", 0b1111111111111111);
627
    int index = ui->EdgePattern->findData(QVariant(pattern));
628
    if (index < 0) {
629
        index = 0;
630
    }
631
    ui->EdgePattern->setCurrentIndex(index);
632

633
    pattern = hGrp->GetInt("ConstructionPattern", 0b1111110011111100);
634
    index = ui->ConstructionPattern->findData(QVariant(pattern));
635
    if (index < 0) {
636
        index = 0;
637
    }
638
    ui->ConstructionPattern->setCurrentIndex(index);
639

640
    pattern = hGrp->GetInt("InternalPattern", 0b1111110011111100);
641
    index = ui->InternalPattern->findData(QVariant(pattern));
642
    if (index < 0) {
643
        index = 0;
644
    }
645
    ui->InternalPattern->setCurrentIndex(index);
646

647
    pattern = hGrp->GetInt("ExternalPattern", 0b1110010011100100);
648
    index = ui->ExternalPattern->findData(QVariant(pattern));
649
    if (index < 0) {
650
        index = 0;
651
    }
652
    ui->ExternalPattern->setCurrentIndex(index);
653
}
654

655
/**
656
 * Sets the strings of the subwidgets using the current language.
657
 */
658
void SketcherSettingsAppearance::changeEvent(QEvent* e)
659
{
660
    if (e->type() == QEvent::LanguageChange) {
661
        ui->retranslateUi(this);
662
    }
663
    else {
664
        QWidget::changeEvent(e);
665
    }
666
}
667

668
#include "moc_SketcherSettings.cpp"
669

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

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

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

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