Skip to content

Commit

Permalink
[Part] Preferences max angle deflection alert
Browse files Browse the repository at this point in the history
  • Loading branch information
Syres916 authored Aug 22, 2024
1 parent a750034 commit 4a1a752
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 14 deletions.
60 changes: 46 additions & 14 deletions src/Mod/Part/Gui/DlgSettings3DViewPartImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,63 @@ using namespace PartGui;
* name 'name' and widget flags set to 'f'
*/
DlgSettings3DViewPart::DlgSettings3DViewPart(QWidget* parent)
: PreferencePage(parent), ui(new Ui_DlgSettings3DViewPart), checkValue(false)
: PreferencePage(parent)
, ui(new Ui_DlgSettings3DViewPart)
, checkValue(false)
{

Check warning on line 48 in src/Mod/Part/Gui/DlgSettings3DViewPartImp.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

{ should almost always be at the end of the previous line [whitespace/braces] [4]
ui->setupUi(this);
connect(ui->maxDeviation, qOverload<double>(&QDoubleSpinBox::valueChanged),
this, &DlgSettings3DViewPart::onMaxDeviationValueChanged);
ParameterGrp::handle hPart = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Mod/Part");
double lowerLimit = hPart->GetFloat("MinimumDeviation", ui->maxDeviation->minimum());
ui->maxDeviation->setMinimum(lowerLimit);
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(

Check warning on line 60 in src/Mod/Part/Gui/DlgSettings3DViewPartImp.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

variable 'minDeviationlowerLimit' is not initialized [cppcoreguidelines-init-variables]
"MinimumDeviation", ui->maxDeviation->minimum());
ui->maxDeviation->setMinimum(minDeviationlowerLimit);
const double minAngleDeflectionlowerLimit = hPart->GetFloat(

Check warning on line 63 in src/Mod/Part/Gui/DlgSettings3DViewPartImp.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

variable 'minAngleDeflectionlowerLimit' is not initialized [cppcoreguidelines-init-variables]
"MinimumDeviation", ui->maxAngularDeflection->minimum());
ui->maxAngularDeflection->setMinimum(minAngleDeflectionlowerLimit);
}

/**
* Destroys the object and frees any allocated resources
*/
DlgSettings3DViewPart::~DlgSettings3DViewPart() = default;

void DlgSettings3DViewPart::onMaxDeviationValueChanged(double v)
void DlgSettings3DViewPart::onMaxDeviationValueChanged(double vMaxDev)
{

Check warning on line 74 in src/Mod/Part/Gui/DlgSettings3DViewPartImp.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

{ should almost always be at the end of the previous line [whitespace/braces] [4]
if (!this->isVisible())
if (!this->isVisible()) {
return;
if (v < 0.01 && !checkValue) {
}
const double maxDevMinThreshold = 0.01;
if (vMaxDev < maxDevMinThreshold && !checkValue) {
checkValue = true;
QMessageBox::warning(this, tr("Deviation"),
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."));
" and thus freezes or slows down the GUI."));
}
}

void DlgSettings3DViewPart::onMaxAngularDeflectionValueChanged(double vMaxAngle)
{

Check warning on line 90 in src/Mod/Part/Gui/DlgSettings3DViewPartImp.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

{ should almost always be at the end of the previous line [whitespace/braces] [4]
if (!this->isVisible()) {
return;
}
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."));
}
}

Expand All @@ -79,13 +111,13 @@ void DlgSettings3DViewPart::saveSettings()
std::vector<App::Document*> docs = App::GetApplication().getDocuments();

Check warning on line 111 in src/Mod/Part/Gui/DlgSettings3DViewPartImp.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

variable 'docs' is not initialized [cppcoreguidelines-init-variables]
for (auto it : docs) {
Gui::Document* doc = Gui::Application::Instance->getDocument(it);
std::vector<Gui::ViewProvider*> views = doc->getViewProvidersOfType(ViewProviderPart::getClassTypeId());
std::vector<Gui::ViewProvider*> views =
doc->getViewProvidersOfType(ViewProviderPart::getClassTypeId());
for (auto view : views) {
static_cast<ViewProviderPart*>(view)->reload();
}
}
}

void DlgSettings3DViewPart::loadSettings()
{

Check warning on line 122 in src/Mod/Part/Gui/DlgSettings3DViewPartImp.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

{ should almost always be at the end of the previous line [whitespace/braces] [4]
ui->maxDeviation->onRestore();
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Part/Gui/DlgSettings3DViewPartImp.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class DlgSettings3DViewPart : public Gui::Dialog::PreferencePage

private:
void onMaxDeviationValueChanged(double);
void onMaxAngularDeflectionValueChanged(double);

private:
std::unique_ptr<Ui_DlgSettings3DViewPart> ui;
Expand Down

0 comments on commit 4a1a752

Please sign in to comment.