Reformat files with clang-format

This commit is contained in:
André Althaus
2024-02-17 14:41:12 +01:00
parent fd4bea24b7
commit bb25074076
12 changed files with 819 additions and 521 deletions

View File

@@ -24,8 +24,8 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QMessageBox>
# include <QTimer>
#include <QMessageBox>
#include <QTimer>
#endif
#include <App/Document.h>
@@ -52,26 +52,30 @@ using namespace Gui;
/* TRANSLATOR PartDesignGui::TaskLinearPatternParameters */
TaskLinearPatternParameters::TaskLinearPatternParameters(ViewProviderTransformed *TransformedView,QWidget *parent)
TaskLinearPatternParameters::TaskLinearPatternParameters(ViewProviderTransformed* TransformedView,
QWidget* parent)
: TaskTransformedParameters(TransformedView, parent)
, ui(new Ui_TaskLinearPatternParameters)
{
setupUI();
}
TaskLinearPatternParameters::TaskLinearPatternParameters(TaskMultiTransformParameters *parentTask, QWidget* parameterWidget)
: TaskTransformedParameters(parentTask), ui(new Ui_TaskLinearPatternParameters)
TaskLinearPatternParameters::TaskLinearPatternParameters(TaskMultiTransformParameters* parentTask,
QWidget* parameterWidget)
: TaskTransformedParameters(parentTask)
, ui(new Ui_TaskLinearPatternParameters)
{
setupParameterUI(parameterWidget);
}
void TaskLinearPatternParameters::setupParameterUI(QWidget *widget)
void TaskLinearPatternParameters::setupParameterUI(QWidget* widget)
{
ui->setupUi(widget);
QMetaObject::connectSlotsByName(this);
// Get the feature data
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
PartDesign::LinearPattern* pcLinearPattern =
static_cast<PartDesign::LinearPattern*>(getObject());
ui->spinLength->bind(pcLinearPattern->Length);
ui->spinOffset->bind(pcLinearPattern->Offset);
@@ -101,16 +105,18 @@ void TaskLinearPatternParameters::setupParameterUI(QWidget *widget)
this->fillAxisCombo(dirLinks, nullptr);
}
//show the parts coordinate system axis for selection
PartDesign::Body * body = PartDesign::Body::findBodyOf(getObject());
if(body) {
// show the parts coordinate system axis for selection
PartDesign::Body* body = PartDesign::Body::findBodyOf(getObject());
if (body) {
try {
App::Origin *origin = body->getOrigin();
App::Origin* origin = body->getOrigin();
ViewProviderOrigin* vpOrigin;
vpOrigin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->getViewProvider(origin));
vpOrigin = static_cast<ViewProviderOrigin*>(
Gui::Application::Instance->getViewProvider(origin));
vpOrigin->setTemporaryVisibility(true, false);
} catch (const Base::Exception &ex) {
Base::Console().Error ("%s\n", ex.what () );
}
catch (const Base::Exception& ex) {
Base::Console().Error("%s\n", ex.what());
}
}
@@ -119,21 +125,35 @@ void TaskLinearPatternParameters::setupParameterUI(QWidget *widget)
updateViewTimer = new QTimer(this);
updateViewTimer->setSingleShot(true);
updateViewTimer->setInterval(getUpdateViewTimeout());
connect(updateViewTimer, &QTimer::timeout,
this, &TaskLinearPatternParameters::onUpdateViewTimer);
connect(updateViewTimer,
&QTimer::timeout,
this,
&TaskLinearPatternParameters::onUpdateViewTimer);
connect(ui->comboDirection, qOverload<int>(&QComboBox::activated),
this, &TaskLinearPatternParameters::onDirectionChanged);
connect(ui->checkReverse, &QCheckBox::toggled,
this, &TaskLinearPatternParameters::onCheckReverse);
connect(ui->comboMode, qOverload<int>(&QComboBox::activated),
this, &TaskLinearPatternParameters::onModeChanged);
connect(ui->spinLength, qOverload<double>(&Gui::QuantitySpinBox::valueChanged),
this, &TaskLinearPatternParameters::onLength);
connect(ui->spinOffset, qOverload<double>(&Gui::QuantitySpinBox::valueChanged),
this, &TaskLinearPatternParameters::onOffset);
connect(ui->spinOccurrences, &Gui::UIntSpinBox::unsignedChanged,
this, &TaskLinearPatternParameters::onOccurrences);
connect(ui->comboDirection,
qOverload<int>(&QComboBox::activated),
this,
&TaskLinearPatternParameters::onDirectionChanged);
connect(ui->checkReverse,
&QCheckBox::toggled,
this,
&TaskLinearPatternParameters::onCheckReverse);
connect(ui->comboMode,
qOverload<int>(&QComboBox::activated),
this,
&TaskLinearPatternParameters::onModeChanged);
connect(ui->spinLength,
qOverload<double>(&Gui::QuantitySpinBox::valueChanged),
this,
&TaskLinearPatternParameters::onLength);
connect(ui->spinOffset,
qOverload<double>(&Gui::QuantitySpinBox::valueChanged),
this,
&TaskLinearPatternParameters::onOffset);
connect(ui->spinOccurrences,
&Gui::UIntSpinBox::unsignedChanged,
this,
&TaskLinearPatternParameters::onOccurrences);
}
void TaskLinearPatternParameters::retranslateParameterUI(QWidget* widget)
@@ -143,22 +163,26 @@ void TaskLinearPatternParameters::retranslateParameterUI(QWidget* widget)
void TaskLinearPatternParameters::updateUI()
{
if (blockUpdate)
if (blockUpdate) {
return;
}
blockUpdate = true;
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
PartDesign::LinearPatternMode mode = static_cast<PartDesign::LinearPatternMode>(pcLinearPattern->Mode.getValue());
PartDesign::LinearPattern* pcLinearPattern =
static_cast<PartDesign::LinearPattern*>(getObject());
PartDesign::LinearPatternMode mode =
static_cast<PartDesign::LinearPatternMode>(pcLinearPattern->Mode.getValue());
bool reverse = pcLinearPattern->Reversed.getValue();
double length = pcLinearPattern->Length.getValue();
double offset = pcLinearPattern->Offset.getValue();
unsigned occurrences = pcLinearPattern->Occurrences.getValue();
if (dirLinks.setCurrentLink(pcLinearPattern->Direction) == -1){
//failed to set current, because the link isn't in the list yet
dirLinks.addLink(pcLinearPattern->Direction, getRefStr(pcLinearPattern->Direction.getValue(),
pcLinearPattern->Direction.getSubValues()));
if (dirLinks.setCurrentLink(pcLinearPattern->Direction) == -1) {
// failed to set current, because the link isn't in the list yet
dirLinks.addLink(pcLinearPattern->Direction,
getRefStr(pcLinearPattern->Direction.getValue(),
pcLinearPattern->Direction.getSubValues()));
dirLinks.setCurrentLink(pcLinearPattern->Direction);
}
@@ -206,16 +230,18 @@ void TaskLinearPatternParameters::onSelectionChanged(const Gui::SelectionChanges
exitSelectionMode();
std::vector<std::string> directions;
App::DocumentObject* selObj = nullptr;
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
PartDesign::LinearPattern* pcLinearPattern =
static_cast<PartDesign::LinearPattern*>(getObject());
if (pcLinearPattern) {
getReferencedSelection(pcLinearPattern, msg, selObj, directions);
// Note: ReferenceSelection has already checked the selection for validity
if (selObj && (selectionMode == SelectionMode::Reference ||
selObj->isDerivedFrom(App::Line::getClassTypeId()) ||
selObj->isDerivedFrom(Part::Feature::getClassTypeId()) ||
selObj->isDerivedFrom(PartDesign::Line::getClassTypeId()) ||
selObj->isDerivedFrom(PartDesign::Plane::getClassTypeId()))) {
if (selObj
&& (selectionMode == SelectionMode::Reference
|| selObj->isDerivedFrom(App::Line::getClassTypeId())
|| selObj->isDerivedFrom(Part::Feature::getClassTypeId())
|| selObj->isDerivedFrom(PartDesign::Line::getClassTypeId())
|| selObj->isDerivedFrom(PartDesign::Plane::getClassTypeId()))) {
setupTransaction();
pcLinearPattern->Direction.setValue(selObj, directions);
recomputeFeature();
@@ -226,20 +252,26 @@ void TaskLinearPatternParameters::onSelectionChanged(const Gui::SelectionChanges
}
}
void TaskLinearPatternParameters::onCheckReverse(const bool on) {
if (blockUpdate)
void TaskLinearPatternParameters::onCheckReverse(const bool on)
{
if (blockUpdate) {
return;
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
}
PartDesign::LinearPattern* pcLinearPattern =
static_cast<PartDesign::LinearPattern*>(getObject());
pcLinearPattern->Reversed.setValue(on);
exitSelectionMode();
kickUpdateViewTimer();
}
void TaskLinearPatternParameters::onModeChanged(const int mode) {
if (blockUpdate)
void TaskLinearPatternParameters::onModeChanged(const int mode)
{
if (blockUpdate) {
return;
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
}
PartDesign::LinearPattern* pcLinearPattern =
static_cast<PartDesign::LinearPattern*>(getObject());
pcLinearPattern->Mode.setValue(mode);
adaptVisibilityToMode();
@@ -248,30 +280,39 @@ void TaskLinearPatternParameters::onModeChanged(const int mode) {
kickUpdateViewTimer();
}
void TaskLinearPatternParameters::onLength(const double l) {
if (blockUpdate)
void TaskLinearPatternParameters::onLength(const double l)
{
if (blockUpdate) {
return;
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
}
PartDesign::LinearPattern* pcLinearPattern =
static_cast<PartDesign::LinearPattern*>(getObject());
pcLinearPattern->Length.setValue(l);
exitSelectionMode();
kickUpdateViewTimer();
}
void TaskLinearPatternParameters::onOffset(const double o) {
if (blockUpdate)
void TaskLinearPatternParameters::onOffset(const double o)
{
if (blockUpdate) {
return;
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
}
PartDesign::LinearPattern* pcLinearPattern =
static_cast<PartDesign::LinearPattern*>(getObject());
pcLinearPattern->Offset.setValue(o);
exitSelectionMode();
kickUpdateViewTimer();
}
void TaskLinearPatternParameters::onOccurrences(const uint n) {
if (blockUpdate)
void TaskLinearPatternParameters::onOccurrences(const uint n)
{
if (blockUpdate) {
return;
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
}
PartDesign::LinearPattern* pcLinearPattern =
static_cast<PartDesign::LinearPattern*>(getObject());
pcLinearPattern->Occurrences.setValue(n);
exitSelectionMode();
@@ -280,23 +321,28 @@ void TaskLinearPatternParameters::onOccurrences(const uint n) {
void TaskLinearPatternParameters::onDirectionChanged(int /*num*/)
{
if (blockUpdate)
if (blockUpdate) {
return;
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
try{
}
PartDesign::LinearPattern* pcLinearPattern =
static_cast<PartDesign::LinearPattern*>(getObject());
try {
if (!dirLinks.getCurrentLink().getValue()) {
// enter reference selection mode
hideObject();
showBase();
selectionMode = SelectionMode::Reference;
Gui::Selection().clearSelection();
addReferenceSelectionGate(AllowSelection::EDGE | AllowSelection::FACE | AllowSelection::PLANAR);
} else {
addReferenceSelectionGate(AllowSelection::EDGE | AllowSelection::FACE
| AllowSelection::PLANAR);
}
else {
exitSelectionMode();
pcLinearPattern->Direction.Paste(dirLinks.getCurrentLink());
}
} catch (Base::Exception &e) {
QMessageBox::warning(nullptr,tr("Error"),QApplication::translate("Exception", e.what()));
}
catch (Base::Exception& e) {
QMessageBox::warning(nullptr, tr("Error"), QApplication::translate("Exception", e.what()));
}
kickUpdateViewTimer();
@@ -307,13 +353,14 @@ void TaskLinearPatternParameters::onUpdateView(bool on)
blockUpdate = !on;
if (on) {
// Do the same like in TaskDlgLinearPatternParameters::accept() but without doCommand
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
PartDesign::LinearPattern* pcLinearPattern =
static_cast<PartDesign::LinearPattern*>(getObject());
std::vector<std::string> directions;
App::DocumentObject* obj;
setupTransaction();
getDirection(obj, directions);
pcLinearPattern->Direction.setValue(obj,directions);
pcLinearPattern->Direction.setValue(obj, directions);
pcLinearPattern->Reversed.setValue(getReverse());
pcLinearPattern->Length.setValue(getLength());
pcLinearPattern->Offset.setValue(getOffset());
@@ -323,9 +370,10 @@ void TaskLinearPatternParameters::onUpdateView(bool on)
}
}
void TaskLinearPatternParameters::getDirection(App::DocumentObject*& obj, std::vector<std::string>& sub) const
void TaskLinearPatternParameters::getDirection(App::DocumentObject*& obj,
std::vector<std::string>& sub) const
{
const App::PropertyLinkSub &lnk = dirLinks.getCurrentLink();
const App::PropertyLinkSub& lnk = dirLinks.getCurrentLink();
obj = lnk.getValue();
sub = lnk.getSubValues();
}
@@ -358,17 +406,18 @@ unsigned TaskLinearPatternParameters::getOccurrences() const
TaskLinearPatternParameters::~TaskLinearPatternParameters()
{
try {
//hide the parts coordinate system axis for selection
PartDesign::Body * body = PartDesign::Body::findBodyOf(getObject());
// hide the parts coordinate system axis for selection
PartDesign::Body* body = PartDesign::Body::findBodyOf(getObject());
if (body) {
App::Origin *origin = body->getOrigin();
App::Origin* origin = body->getOrigin();
ViewProviderOrigin* vpOrigin;
vpOrigin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->getViewProvider(origin));
vpOrigin = static_cast<ViewProviderOrigin*>(
Gui::Application::Instance->getViewProvider(origin));
vpOrigin->resetTemporaryVisibility();
}
}
catch (const Base::Exception &ex) {
Base::Console().Error ("%s\n", ex.what () );
catch (const Base::Exception& ex) {
Base::Console().Error("%s\n", ex.what());
}
}
@@ -380,9 +429,9 @@ void TaskLinearPatternParameters::doApply()
std::string direction = buildLinkSingleSubPythonStr(obj, directions);
auto tobj = getObject();
FCMD_OBJ_CMD(tobj,"Direction = " << direction);
FCMD_OBJ_CMD(tobj,"Reversed = " << getReverse());
FCMD_OBJ_CMD(tobj,"Mode = " << getMode());
FCMD_OBJ_CMD(tobj, "Direction = " << direction);
FCMD_OBJ_CMD(tobj, "Reversed = " << getReverse());
FCMD_OBJ_CMD(tobj, "Mode = " << getMode());
ui->spinLength->apply();
ui->spinOffset->apply();
ui->spinOccurrences->apply();
@@ -393,7 +442,8 @@ void TaskLinearPatternParameters::doApply()
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskDlgLinearPatternParameters::TaskDlgLinearPatternParameters(ViewProviderLinearPattern *LinearPatternView)
TaskDlgLinearPatternParameters::TaskDlgLinearPatternParameters(
ViewProviderLinearPattern* LinearPatternView)
: TaskDlgTransformedParameters(LinearPatternView)
{
parameter = new TaskLinearPatternParameters(LinearPatternView);