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

@@ -49,10 +49,12 @@ using namespace Gui;
/* TRANSLATOR PartDesignGui::TaskRevolutionParameters */
TaskRevolutionParameters::TaskRevolutionParameters(PartDesignGui::ViewProvider* RevolutionView,
const char* pixname,
const QString& title,
QWidget *parent)
TaskRevolutionParameters::TaskRevolutionParameters(
PartDesignGui::ViewProvider* RevolutionView,
const char* pixname,
const QString& title,
QWidget* parent
)
: TaskSketchBasedParameters(RevolutionView, parent, pixname, title)
, ui(new Ui_TaskRevolutionParameters)
, proxy(new QWidget(this))
@@ -104,7 +106,7 @@ TaskRevolutionParameters::TaskRevolutionParameters(PartDesignGui::ViewProvider*
vpOrigin->setTemporaryVisibility(Gui::DatumElement::Axes);
}
}
catch (const Base::Exception &ex) {
catch (const Base::Exception& ex) {
ex.reportException();
}
@@ -114,12 +116,13 @@ TaskRevolutionParameters::TaskRevolutionParameters(PartDesignGui::ViewProvider*
Gui::ViewProviderCoordinateSystem* TaskRevolutionParameters::getOriginView() const
{
// show the parts coordinate system axis for selection
PartDesign::Body * body = PartDesign::Body::findBodyOf(getObject());
PartDesign::Body* body = PartDesign::Body::findBodyOf(getObject());
if (body) {
App::Origin *origin = body->getOrigin();
App::Origin* origin = body->getOrigin();
return freecad_cast<ViewProviderCoordinateSystem*>(
Gui::Application::Instance->getViewProvider(origin));
}
Gui::Application::Instance->getViewProvider(origin)
);
}
return nullptr;
}
@@ -150,10 +153,11 @@ void TaskRevolutionParameters::setupDialog()
ui->lineFaceName->setProperty("FeatureName", QByteArray(obj->getNameInDocument()));
}
else if (obj && faceId >= 0) {
ui->lineFaceName->setText(QStringLiteral("%1:%2%3")
.arg(QString::fromUtf8(obj->Label.getValue()),
tr("Face"),
QString::number(faceId)));
ui->lineFaceName->setText(QStringLiteral("%1:%2%3").arg(
QString::fromUtf8(obj->Label.getValue()),
tr("Face"),
QString::number(faceId)
));
ui->lineFaceName->setProperty("FeatureName", QByteArray(obj->getNameInDocument()));
}
else {
@@ -214,50 +218,51 @@ void TaskRevolutionParameters::fillAxisCombo(bool forceRefill)
ui->axis->clear();
axesInList.clear();
auto *pcFeat = getObject<PartDesign::ProfileBased>();
auto* pcFeat = getObject<PartDesign::ProfileBased>();
if (!pcFeat) {
throw Base::TypeError("The object is not profile-based.");
}
//add sketch axes
if (auto *pcSketch = dynamic_cast<Part::Part2DObject*>(pcFeat->Profile.getValue())) {
// add sketch axes
if (auto* pcSketch = dynamic_cast<Part::Part2DObject*>(pcFeat->Profile.getValue())) {
addAxisToCombo(pcSketch, "V_Axis", QObject::tr("Vertical sketch axis"));
addAxisToCombo(pcSketch, "H_Axis", QObject::tr("Horizontal sketch axis"));
for (int i=0; i < pcSketch->getAxisCount(); i++) {
QString itemText = QObject::tr("Construction line %1").arg(i+1);
for (int i = 0; i < pcSketch->getAxisCount(); i++) {
QString itemText = QObject::tr("Construction line %1").arg(i + 1);
std::stringstream sub;
sub << "Axis" << i;
addAxisToCombo(pcSketch,sub.str(),itemText);
addAxisToCombo(pcSketch, sub.str(), itemText);
}
}
//add origin axes
if (PartDesign::Body * body = PartDesign::Body::findBodyOf(pcFeat)) {
// add origin axes
if (PartDesign::Body* body = PartDesign::Body::findBodyOf(pcFeat)) {
try {
App::Origin* orig = body->getOrigin();
addAxisToCombo(orig->getX(), std::string(), tr("Base X-axis"));
addAxisToCombo(orig->getY(), std::string(), tr("Base Y-axis"));
addAxisToCombo(orig->getZ(), std::string(), tr("Base Z-axis"));
} catch (const Base::Exception &ex) {
}
catch (const Base::Exception& ex) {
ex.reportException();
}
}
//add "Select reference"
// add "Select reference"
addAxisToCombo(nullptr, std::string(), tr("Select reference…"));
}//endif forceRefill
} // endif forceRefill
//add current link, if not in list
//first, figure out the item number for current axis
// add current link, if not in list
// first, figure out the item number for current axis
int indexOfCurrent = -1;
App::DocumentObject* ax = propReferenceAxis->getValue();
const std::vector<std::string> &subList = propReferenceAxis->getSubValues();
const std::vector<std::string>& subList = propReferenceAxis->getSubValues();
for (size_t i = 0; i < axesInList.size(); i++) {
if (ax == axesInList[i]->getValue() && subList == axesInList[i]->getSubValues()) {
indexOfCurrent = int(i);
}
}
if (indexOfCurrent == -1 && ax) {
if (indexOfCurrent == -1 && ax) {
assert(subList.size() <= 1);
std::string sub;
if (!subList.empty()) {
@@ -267,19 +272,21 @@ void TaskRevolutionParameters::fillAxisCombo(bool forceRefill)
indexOfCurrent = int(axesInList.size()) - 1;
}
//highlight current.
// highlight current.
if (indexOfCurrent != -1) {
ui->axis->setCurrentIndex(indexOfCurrent);
}
}
void TaskRevolutionParameters::addAxisToCombo(App::DocumentObject* linkObj,
const std::string& linkSubname,
const QString& itemText)
void TaskRevolutionParameters::addAxisToCombo(
App::DocumentObject* linkObj,
const std::string& linkSubname,
const QString& itemText
)
{
this->ui->axis->addItem(itemText);
this->axesInList.emplace_back(new App::PropertyLinkSub());
App::PropertyLinkSub &lnk = *(axesInList[axesInList.size()-1]);
App::PropertyLinkSub& lnk = *(axesInList[axesInList.size() - 1]);
lnk.setValue(linkObj, std::vector<std::string>(1, linkSubname));
}
@@ -465,13 +472,11 @@ void TaskRevolutionParameters::translateFaceName()
int faceId = -1;
bool ok = false;
if (upToFace.indexOf("Face") == 0) {
faceId = upToFace.remove(0,4).toInt(&ok);
faceId = upToFace.remove(0, 4).toInt(&ok);
}
if (ok) {
ui->lineFaceName->setText(QStringLiteral("%1:%2%3")
.arg(parts[0], tr("Face"))
.arg(faceId));
ui->lineFaceName->setText(QStringLiteral("%1:%2%3").arg(parts[0], tr("Face")).arg(faceId));
}
else {
ui->lineFaceName->setText(parts[0]);
@@ -529,24 +534,25 @@ void TaskRevolutionParameters::onAxisChanged(int num)
return;
}
App::DocumentObject *oldRefAxis = propReferenceAxis->getValue();
App::DocumentObject* oldRefAxis = propReferenceAxis->getValue();
std::vector<std::string> oldSubRefAxis = propReferenceAxis->getSubValues();
std::string oldRefName;
if (!oldSubRefAxis.empty()) {
oldRefName = oldSubRefAxis.front();
}
App::PropertyLinkSub &lnk = *(axesInList[num]);
App::PropertyLinkSub& lnk = *(axesInList[num]);
if (!lnk.getValue()) {
// enter reference selection mode
if (auto sketch = dynamic_cast<Part::Part2DObject*>(pcRevolution->Profile.getValue())) {
Gui::cmdAppObjectShow(sketch);
}
TaskSketchBasedParameters::onSelectReference(AllowSelection::EDGE |
AllowSelection::PLANAR |
AllowSelection::CIRCLE);
} else {
if (!pcRevolution->getDocument()->isIn(lnk.getValue())){
TaskSketchBasedParameters::onSelectReference(
AllowSelection::EDGE | AllowSelection::PLANAR | AllowSelection::CIRCLE
);
}
else {
if (!pcRevolution->getDocument()->isIn(lnk.getValue())) {
Base::Console().error("Object was deleted\n");
return;
}
@@ -555,16 +561,15 @@ void TaskRevolutionParameters::onAxisChanged(int num)
}
try {
App::DocumentObject *newRefAxis = propReferenceAxis->getValue();
const std::vector<std::string> &newSubRefAxis = propReferenceAxis->getSubValues();
App::DocumentObject* newRefAxis = propReferenceAxis->getValue();
const std::vector<std::string>& newSubRefAxis = propReferenceAxis->getSubValues();
std::string newRefName;
if (!newSubRefAxis.empty()) {
newRefName = newSubRefAxis.front();
}
if (oldRefAxis != newRefAxis ||
oldSubRefAxis.size() != newSubRefAxis.size() ||
oldRefName != newRefName) {
if (oldRefAxis != newRefAxis || oldSubRefAxis.size() != newSubRefAxis.size()
|| oldRefName != newRefName) {
bool reversed = propReversed->getValue();
if (pcRevolution->isDerivedFrom<PartDesign::Revolution>()) {
reversed = static_cast<PartDesign::Revolution*>(pcRevolution)->suggestReversed();
@@ -599,9 +604,7 @@ void TaskRevolutionParameters::onMidplane(bool on)
recomputeFeature();
if (gizmoContainer) {
rotationGizmo->setMultFactor(
rotationGizmo->getMultFactor() * (on? 0.5: 2)
);
rotationGizmo->setMultFactor(rotationGizmo->getMultFactor() * (on ? 0.5 : 2));
}
}
}
@@ -624,21 +627,21 @@ void TaskRevolutionParameters::onModeChanged(int index)
: &(getObject<PartDesign::Revolution>()->Type);
switch (static_cast<PartDesign::Revolution::RevolMethod>(index)) {
case PartDesign::Revolution::RevolMethod::Angle:
propEnum->setValue("Angle");
break;
case PartDesign::Revolution::RevolMethod::ToLast:
propEnum->setValue(isGroove ? "ThroughAll" : "UpToLast");
break;
case PartDesign::Revolution::RevolMethod::ToFirst:
propEnum->setValue("UpToFirst");
break;
case PartDesign::Revolution::RevolMethod::ToFace:
propEnum->setValue("UpToFace");
break;
case PartDesign::Revolution::RevolMethod::TwoAngles:
propEnum->setValue("TwoAngles");
break;
case PartDesign::Revolution::RevolMethod::Angle:
propEnum->setValue("Angle");
break;
case PartDesign::Revolution::RevolMethod::ToLast:
propEnum->setValue(isGroove ? "ThroughAll" : "UpToLast");
break;
case PartDesign::Revolution::RevolMethod::ToFirst:
propEnum->setValue("UpToFirst");
break;
case PartDesign::Revolution::RevolMethod::ToFace:
propEnum->setValue("UpToFace");
break;
case PartDesign::Revolution::RevolMethod::TwoAngles:
propEnum->setValue("TwoAngles");
break;
}
updateUI(index);
@@ -649,20 +652,23 @@ void TaskRevolutionParameters::onModeChanged(int index)
}
}
void TaskRevolutionParameters::getReferenceAxis(App::DocumentObject*& obj, std::vector<std::string>& sub) const
void TaskRevolutionParameters::getReferenceAxis(
App::DocumentObject*& obj,
std::vector<std::string>& sub
) const
{
if (axesInList.empty()) {
throw Base::RuntimeError("Not initialized!");
}
int num = ui->axis->currentIndex();
const App::PropertyLinkSub &lnk = *(axesInList[num]);
const App::PropertyLinkSub& lnk = *(axesInList[num]);
if (!lnk.getValue()) {
throw Base::RuntimeError("Still in reference selection mode; reference wasn't selected yet");
}
auto revolution = getObject<PartDesign::ProfileBased>();
if (!revolution->getDocument()->isIn(lnk.getValue())){
if (!revolution->getDocument()->isIn(lnk.getValue())) {
throw Base::RuntimeError("Object was deleted");
}
@@ -682,20 +688,20 @@ bool TaskRevolutionParameters::getReversed() const
TaskRevolutionParameters::~TaskRevolutionParameters()
{
//hide the parts coordinate system axis for selection
// hide the parts coordinate system axis for selection
try {
if (auto vpOrigin = getOriginView()) {
vpOrigin->resetTemporaryVisibility();
}
}
catch (const Base::Exception &ex) {
catch (const Base::Exception& ex) {
ex.reportException();
}
axesInList.clear();
}
void TaskRevolutionParameters::changeEvent(QEvent *event)
void TaskRevolutionParameters::changeEvent(QEvent* event)
{
TaskBox::changeEvent(event);
if (event->type() == QEvent::LanguageChange) {
@@ -708,7 +714,7 @@ void TaskRevolutionParameters::changeEvent(QEvent *event)
void TaskRevolutionParameters::apply()
{
//Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Revolution changed"));
// Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Revolution changed"));
ui->revolveAngle->apply();
ui->revolveAngle2->apply();
std::vector<std::string> sub;
@@ -722,7 +728,8 @@ void TaskRevolutionParameters::apply()
int mode = ui->changeMode->currentIndex();
FCMD_OBJ_CMD(tobj, "Type = " << mode);
QString facename = QStringLiteral("None");
if (static_cast<PartDesign::Revolution::RevolMethod>(mode) == PartDesign::Revolution::RevolMethod::ToFace) {
if (static_cast<PartDesign::Revolution::RevolMethod>(mode)
== PartDesign::Revolution::RevolMethod::ToFace) {
facename = getFaceName();
}
FCMD_OBJ_CMD(tobj, "UpToFace = " << facename.toLatin1().data());
@@ -769,7 +776,8 @@ void TaskRevolutionParameters::setGizmoPositions()
profile.getCenterOfGravity(profileCog);
basePos = groove->Base.getValue();
axisDir = groove->Axis.getValue();
} else {
}
else {
auto revolution = getObject<PartDesign::Revolution>();
if (!revolution || revolution->isError()) {
gizmoContainer->visible = false;
@@ -828,19 +836,23 @@ void TaskRevolutionParameters::setGizmoVisibility()
//**************************************************************************
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskDlgRevolutionParameters::TaskDlgRevolutionParameters(ViewProviderRevolution *RevolutionView)
TaskDlgRevolutionParameters::TaskDlgRevolutionParameters(ViewProviderRevolution* RevolutionView)
: TaskDlgSketchBasedParameters(RevolutionView)
{
assert(RevolutionView);
Content.push_back(new TaskRevolutionParameters(RevolutionView, "PartDesign_Revolution", tr("Revolution Parameters")));
Content.push_back(
new TaskRevolutionParameters(RevolutionView, "PartDesign_Revolution", tr("Revolution Parameters"))
);
Content.push_back(preview);
}
TaskDlgGrooveParameters::TaskDlgGrooveParameters(ViewProviderGroove *GrooveView)
TaskDlgGrooveParameters::TaskDlgGrooveParameters(ViewProviderGroove* GrooveView)
: TaskDlgSketchBasedParameters(GrooveView)
{
assert(GrooveView);
Content.push_back(new TaskRevolutionParameters(GrooveView, "PartDesign_Groove", tr("Groove Parameters")));
Content.push_back(
new TaskRevolutionParameters(GrooveView, "PartDesign_Groove", tr("Groove Parameters"))
);
Content.push_back(preview);
}