1
/***************************************************************************
2
* Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de> *
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 <QMessageBox>
28
#include <App/Application.h>
29
#include <App/Document.h>
30
#include <Gui/Application.h>
31
#include <Gui/Document.h>
33
#include "DlgSettings3DViewPartImp.h"
34
#include "ui_DlgSettings3DViewPart.h"
35
#include "ViewProvider.h"
38
using namespace PartGui;
41
* Constructs a DlgSettings3DViewPart which is a child of 'parent', with the
42
* name 'name' and widget flags set to 'f'
44
DlgSettings3DViewPart::DlgSettings3DViewPart(QWidget* parent)
45
: PreferencePage(parent), ui(new Ui_DlgSettings3DViewPart), checkValue(false)
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);
57
* Destroys the object and frees any allocated resources
59
DlgSettings3DViewPart::~DlgSettings3DViewPart() = default;
61
void DlgSettings3DViewPart::onMaxDeviationValueChanged(double v)
63
if (!this->isVisible())
65
if (v < 0.01 && !checkValue) {
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."));
73
void DlgSettings3DViewPart::saveSettings()
75
ui->maxDeviation->onSave();
76
ui->maxAngularDeflection->onSave();
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();
89
void DlgSettings3DViewPart::loadSettings()
91
ui->maxDeviation->onRestore();
92
ui->maxAngularDeflection->onRestore();
96
* Sets the strings of the subwidgets using the current language.
98
void DlgSettings3DViewPart::changeEvent(QEvent *e)
100
if (e->type() == QEvent::LanguageChange) {
101
ui->retranslateUi(this);
104
QWidget::changeEvent(e);
108
#include "moc_DlgSettings3DViewPartImp.cpp"