FreeCAD

Форк
0
/
DlgSettings3DViewPartImp.cpp 
108 строк · 4.2 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de>              *
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
#endif
27

28
#include <App/Application.h>
29
#include <App/Document.h>
30
#include <Gui/Application.h>
31
#include <Gui/Document.h>
32

33
#include "DlgSettings3DViewPartImp.h"
34
#include "ui_DlgSettings3DViewPart.h"
35
#include "ViewProvider.h"
36

37

38
using namespace PartGui;
39

40
/**
41
 *  Constructs a DlgSettings3DViewPart which is a child of 'parent', with the
42
 *  name 'name' and widget flags set to 'f'
43
 */
44
DlgSettings3DViewPart::DlgSettings3DViewPart(QWidget* parent)
45
  : PreferencePage(parent), ui(new Ui_DlgSettings3DViewPart), checkValue(false)
46
{
47
    ui->setupUi(this);
48
    connect(ui->maxDeviation, qOverload<double>(&QDoubleSpinBox::valueChanged),
49
            this, &DlgSettings3DViewPart::onMaxDeviationValueChanged);
50
    ParameterGrp::handle hPart = App::GetApplication().GetParameterGroupByPath
51
        ("User parameter:BaseApp/Preferences/Mod/Part");
52
    double lowerLimit = hPart->GetFloat("MinimumDeviation", ui->maxDeviation->minimum());
53
    ui->maxDeviation->setMinimum(lowerLimit);
54
}
55

56
/**
57
 *  Destroys the object and frees any allocated resources
58
 */
59
DlgSettings3DViewPart::~DlgSettings3DViewPart() = default;
60

61
void DlgSettings3DViewPart::onMaxDeviationValueChanged(double v)
62
{
63
    if (!this->isVisible())
64
        return;
65
    if (v < 0.01 && !checkValue) {
66
        checkValue = true;
67
        QMessageBox::warning(this, tr("Deviation"),
68
            tr("Setting a too small deviation causes the tessellation to take longer"
69
               "and thus freezes or slows down the GUI."));
70
    }
71
}
72

73
void DlgSettings3DViewPart::saveSettings()
74
{
75
    ui->maxDeviation->onSave();
76
    ui->maxAngularDeflection->onSave();
77

78
    // search for Part view providers and apply the new settings
79
    std::vector<App::Document*> docs = App::GetApplication().getDocuments();
80
    for (auto it : docs) {
81
        Gui::Document* doc = Gui::Application::Instance->getDocument(it);
82
        std::vector<Gui::ViewProvider*> views = doc->getViewProvidersOfType(ViewProviderPart::getClassTypeId());
83
        for (auto view : views) {
84
            static_cast<ViewProviderPart*>(view)->reload();
85
        }
86
    }
87
}
88

89
void DlgSettings3DViewPart::loadSettings()
90
{
91
    ui->maxDeviation->onRestore();
92
    ui->maxAngularDeflection->onRestore();
93
}
94

95
/**
96
 * Sets the strings of the subwidgets using the current language.
97
 */
98
void DlgSettings3DViewPart::changeEvent(QEvent *e)
99
{
100
    if (e->type() == QEvent::LanguageChange) {
101
        ui->retranslateUi(this);
102
    }
103
    else {
104
        QWidget::changeEvent(e);
105
    }
106
}
107

108
#include "moc_DlgSettings3DViewPartImp.cpp"
109

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

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

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

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