Files
create/src/Mod/Part/Gui/DlgSettings3DViewPartImp.cpp
Markus Reitböck 8fa48b25b4 Part: use CMake to generate precompiled headers on all platforms
"Professional CMake" book suggest the following:

"Targets should build successfully with or without compiler support for precompiled headers. It
 should be considered an optimization, not a requirement. In particular, do not explicitly include a
 precompile header (e.g. stdafx.h) in the source code, let CMake force-include an automatically
 generated precompile header on the compiler command line instead. This is more portable across
 the major compilers and is likely to be easier to maintain. It will also avoid warnings being
 generated from certain code checking tools like iwyu (include what you use)."

Therefore, removed the "#include <PreCompiled.h>" from sources, also
there is no need for the "#ifdef _PreComp_" anymore
2025-09-24 20:08:56 +02:00

144 lines
5.5 KiB
C++

/***************************************************************************
* Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
# include <QMessageBox>
#include <App/Application.h>
#include <App/Document.h>
#include <Gui/Application.h>
#include <Gui/Document.h>
#include "DlgSettings3DViewPartImp.h"
#include "ui_DlgSettings3DViewPart.h"
#include "ViewProvider.h"
using namespace PartGui;
/**
* Constructs a DlgSettings3DViewPart which is a child of 'parent', with the
* name 'name' and widget flags set to 'f'
*/
DlgSettings3DViewPart::DlgSettings3DViewPart(QWidget* parent)
: PreferencePage(parent)
, ui(new Ui_DlgSettings3DViewPart)
, checkValue(false)
{
ui->setupUi(this);
connect(ui->maxDeviation,
qOverload<double>(&QDoubleSpinBox::valueChanged),
this,
&DlgSettings3DViewPart::onMaxDeviationValueChanged);
connect(ui->maxAngularDeflection,
qOverload<double>(&QDoubleSpinBox::valueChanged),
this,
&DlgSettings3DViewPart::onMaxAngularDeflectionValueChanged);
ParameterGrp::handle hPart = App::GetApplication().GetParameterGroupByPath(
"User parameter:BaseApp/Preferences/Mod/Part");
const double minDeviationlowerLimit = hPart->GetFloat(
"MinimumDeviation", ui->maxDeviation->minimum());
ui->maxDeviation->setMinimum(minDeviationlowerLimit);
const double minAngleDeflectionlowerLimit = hPart->GetFloat(
"MinimumDeviation", ui->maxAngularDeflection->minimum());
ui->maxAngularDeflection->setMinimum(minAngleDeflectionlowerLimit);
}
/**
* Destroys the object and frees any allocated resources
*/
DlgSettings3DViewPart::~DlgSettings3DViewPart() = default;
void DlgSettings3DViewPart::onMaxDeviationValueChanged(double vMaxDev)
{
if (!this->isVisible()) {
return;
}
const double maxDevMinThreshold = 0.01;
if (vMaxDev < maxDevMinThreshold && !checkValue) {
checkValue = true;
QMessageBox::warning(
this,
tr("Deviation"),
tr("Setting a too small deviation causes the tessellation to take longer"
" and thus freezes or slows down the GUI."));
}
}
void DlgSettings3DViewPart::onMaxAngularDeflectionValueChanged(double vMaxAngle)
{
if (!this->isVisible()) {
return;
}
/**
* The lower threshold of 2.0 was determined by testing
* as laid out in the table as per comment hyperlink:
* https://github.com/FreeCAD/FreeCAD/issues/15951#issuecomment-2304308163
*/
const double vMaxAngleMinThreshold = 2.0;
if (vMaxAngle < vMaxAngleMinThreshold && !checkValue) {
checkValue = true;
QMessageBox::warning(
this,
tr("Angle deflection"),
tr("Setting a too small angle deviation causes the tessellation to take longer"
" and thus freezes or slows down the GUI."));
}
}
void DlgSettings3DViewPart::saveSettings()
{
ui->maxDeviation->onSave();
ui->maxAngularDeflection->onSave();
// search for Part view providers and apply the new settings
std::vector<App::Document*> docs = App::GetApplication().getDocuments();
for (auto it : docs) {
Gui::Document* doc = Gui::Application::Instance->getDocument(it);
std::vector<Gui::ViewProvider*> views =
doc->getViewProvidersOfType(ViewProviderPart::getClassTypeId());
for (auto view : views) {
static_cast<ViewProviderPart*>(view)->reload();
}
}
}
void DlgSettings3DViewPart::loadSettings()
{
ui->maxDeviation->onRestore();
ui->maxAngularDeflection->onRestore();
}
/**
* Sets the strings of the subwidgets using the current language.
*/
void DlgSettings3DViewPart::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange) {
ui->retranslateUi(this);
}
else {
QWidget::changeEvent(e);
}
}
#include "moc_DlgSettings3DViewPartImp.cpp"