All: Reformat according to new standard

This commit is contained in:
pre-commit-ci[bot]
2025-11-11 13:49:01 +01:00
committed by Kacper Donat
parent eafd18dac0
commit 25c3ba7338
2390 changed files with 154630 additions and 115818 deletions

View File

@@ -54,16 +54,18 @@ using namespace SketcherGui;
/* TRANSLATOR SketcherGui::EditDatumDialog */
bool SketcherGui::checkConstraintName(const Sketcher::SketchObject* sketch,
std::string constraintName)
bool SketcherGui::checkConstraintName(const Sketcher::SketchObject* sketch, std::string constraintName)
{
if (constraintName != Base::Tools::getIdentifier(constraintName)) {
Gui::NotifyUserError(
sketch,
QT_TRANSLATE_NOOP("Notifications", "Value Error"),
QT_TRANSLATE_NOOP("Notifications",
"Invalid constraint name (must only contain alphanumericals and "
"underscores, and must not start with digit)"));
QT_TRANSLATE_NOOP(
"Notifications",
"Invalid constraint name (must only contain alphanumericals and "
"underscores, and must not start with digit)"
)
);
return false;
}
@@ -97,10 +99,14 @@ int EditDatumDialog::exec(bool atCursor)
if (Constr->isDimensional()) {
if (sketch->hasConflicts()) {
Gui::TranslatedUserWarning(sketch,
QObject::tr("Dimensional constraint"),
QObject::tr("Not allowed to edit the datum because the "
"sketch contains conflicting constraints"));
Gui::TranslatedUserWarning(
sketch,
QObject::tr("Dimensional constraint"),
QObject::tr(
"Not allowed to edit the datum because the "
"sketch contains conflicting constraints"
)
);
return QDialog::Rejected;
}
@@ -120,33 +126,38 @@ int EditDatumDialog::exec(bool atCursor)
init_val.setUnit(Base::Unit::Angle);
ui_ins_datum->label->setText(tr("Angle:"));
ui_ins_datum->labelEdit->setParamGrpPath(
QByteArray("User parameter:BaseApp/History/SketcherAngle"));
QByteArray("User parameter:BaseApp/History/SketcherAngle")
);
}
else if (Constr->Type == Sketcher::Radius) {
dlg.setWindowTitle(tr("Insert Radius"));
init_val.setUnit(Base::Unit::Length);
ui_ins_datum->label->setText(tr("Radius:"));
ui_ins_datum->labelEdit->setParamGrpPath(
QByteArray("User parameter:BaseApp/History/SketcherLength"));
QByteArray("User parameter:BaseApp/History/SketcherLength")
);
}
else if (Constr->Type == Sketcher::Diameter) {
dlg.setWindowTitle(tr("Insert Diameter"));
init_val.setUnit(Base::Unit::Length);
ui_ins_datum->label->setText(tr("Diameter:"));
ui_ins_datum->labelEdit->setParamGrpPath(
QByteArray("User parameter:BaseApp/History/SketcherLength"));
QByteArray("User parameter:BaseApp/History/SketcherLength")
);
}
else if (Constr->Type == Sketcher::Weight) {
dlg.setWindowTitle(tr("Insert Weight"));
ui_ins_datum->label->setText(tr("Weight:"));
ui_ins_datum->labelEdit->setParamGrpPath(
QByteArray("User parameter:BaseApp/History/SketcherWeight"));
QByteArray("User parameter:BaseApp/History/SketcherWeight")
);
}
else if (Constr->Type == Sketcher::SnellsLaw) {
dlg.setWindowTitle(tr("Refractive Index Ratio", "Constraint_SnellsLaw"));
ui_ins_datum->label->setText(tr("Ratio n2/n1:", "Constraint_SnellsLaw"));
ui_ins_datum->labelEdit->setParamGrpPath(
QByteArray("User parameter:BaseApp/History/SketcherRefrIndexRatio"));
QByteArray("User parameter:BaseApp/History/SketcherRefrIndexRatio")
);
ui_ins_datum->labelEdit->setSingleStep(0.05);
}
else {
@@ -154,7 +165,8 @@ int EditDatumDialog::exec(bool atCursor)
init_val.setUnit(Base::Unit::Length);
ui_ins_datum->label->setText(tr("Length:"));
ui_ins_datum->labelEdit->setParamGrpPath(
QByteArray("User parameter:BaseApp/History/SketcherLength"));
QByteArray("User parameter:BaseApp/History/SketcherLength")
);
}
init_val.setValue(datum);
@@ -167,18 +179,19 @@ int EditDatumDialog::exec(bool atCursor)
ui_ins_datum->cbDriving->setChecked(!Constr->isDriving);
connect(ui_ins_datum->cbDriving,
&QCheckBox::toggled,
this,
&EditDatumDialog::drivingToggled);
connect(ui_ins_datum->labelEdit,
qOverload<const Base::Quantity&>(&Gui::QuantitySpinBox::valueChanged),
this,
&EditDatumDialog::datumChanged);
connect(ui_ins_datum->labelEdit,
&Gui::QuantitySpinBox::showFormulaDialog,
this,
&EditDatumDialog::formEditorOpened);
connect(ui_ins_datum->cbDriving, &QCheckBox::toggled, this, &EditDatumDialog::drivingToggled);
connect(
ui_ins_datum->labelEdit,
qOverload<const Base::Quantity&>(&Gui::QuantitySpinBox::valueChanged),
this,
&EditDatumDialog::datumChanged
);
connect(
ui_ins_datum->labelEdit,
&Gui::QuantitySpinBox::showFormulaDialog,
this,
&EditDatumDialog::formEditorOpened
);
connect(&dlg, &QDialog::accepted, this, &EditDatumDialog::accepted);
connect(&dlg, &QDialog::rejected, this, &EditDatumDialog::rejected);
@@ -229,11 +242,13 @@ void EditDatumDialog::accepted()
performAutoScale(newDatum);
Gui::cmdAppObjectArgs(sketch,
"setDatum(%i,App.Units.Quantity('%f %s'))",
ConstrNbr,
newDatum,
unitString);
Gui::cmdAppObjectArgs(
sketch,
"setDatum(%i,App.Units.Quantity('%f %s'))",
ConstrNbr,
newDatum,
unitString
);
}
}
@@ -245,10 +260,12 @@ void EditDatumDialog::accepted()
constraintName = currConstraintName;
}
Gui::cmdAppObjectArgs(sketch,
"renameConstraint(%d, u'%s')",
ConstrNbr,
constraintName.c_str());
Gui::cmdAppObjectArgs(
sketch,
"renameConstraint(%d, u'%s')",
ConstrNbr,
constraintName.c_str()
);
}
Gui::Command::commitCommand();
@@ -274,9 +291,7 @@ void EditDatumDialog::accepted()
success = true;
}
catch (const Base::Exception& e) {
Gui::NotifyUserError(sketch,
QT_TRANSLATE_NOOP("Notifications", "Value Error"),
e.what());
Gui::NotifyUserError(sketch, QT_TRANSLATE_NOOP("Notifications", "Value Error"), e.what());
Gui::Command::abortCommand();
@@ -312,8 +327,7 @@ void EditDatumDialog::drivingToggled(bool state)
void EditDatumDialog::datumChanged()
{
if (ui_ins_datum->labelEdit->text()
!= std::as_const(ui_ins_datum->labelEdit)->getHistory()[0]) {
if (ui_ins_datum->labelEdit->text() != std::as_const(ui_ins_datum->labelEdit)->getHistory()[0]) {
ui_ins_datum->cbDriving->setChecked(false);
}
}
@@ -394,9 +408,10 @@ bool hasVisualFeature(App::DocumentObject* obj, App::DocumentObject* rootObj, Gu
void EditDatumDialog::performAutoScale(double newDatum)
{
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
"User parameter:BaseApp/Preferences/Mod/Sketcher/dimensioning");
long autoScaleMode =
hGrp->GetInt("AutoScaleMode", static_cast<int>(SketcherGui::AutoScaleMode::Always));
"User parameter:BaseApp/Preferences/Mod/Sketcher/dimensioning"
);
long autoScaleMode
= hGrp->GetInt("AutoScaleMode", static_cast<int>(SketcherGui::AutoScaleMode::Always));
// There is a single constraint in the sketch so it can
// be used as a reference to scale the geometries around the origin
@@ -404,8 +419,7 @@ void EditDatumDialog::performAutoScale(double newDatum)
// was drawn with these geometries as scale references (use <= 2 because
// the sketch axis are considered as external geometries)
if ((autoScaleMode == static_cast<int>(SketcherGui::AutoScaleMode::Always)
|| (autoScaleMode
== static_cast<int>(SketcherGui::AutoScaleMode::WhenNoScaleFeatureIsVisible)
|| (autoScaleMode == static_cast<int>(SketcherGui::AutoScaleMode::WhenNoScaleFeatureIsVisible)
&& !hasVisualFeature(sketch, nullptr, Gui::Application::Instance->activeDocument())))
&& sketch->getExternalGeometryCount() <= 2) {
try {