Skip to content

Commit

Permalink
[PD] TaskDlgRevolutionParameters: fix some CI warnings
Browse files Browse the repository at this point in the history
- reported here: f0a0e563
- and here: 8f3f17f8
  • Loading branch information
donovaly authored and wwmayer committed Nov 9, 2022
1 parent eb407fe commit 2aa232b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 40 deletions.
70 changes: 33 additions & 37 deletions src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp
Expand Up @@ -47,33 +47,32 @@ using namespace Gui;
/* TRANSLATOR PartDesignGui::TaskRevolutionParameters */

TaskRevolutionParameters::TaskRevolutionParameters(PartDesignGui::ViewProvider* RevolutionView, QWidget *parent)
: TaskSketchBasedParameters(RevolutionView, parent, "PartDesign_Revolution", tr("Revolution parameters"))
, ui(new Ui_TaskRevolutionParameters)
: TaskSketchBasedParameters(RevolutionView, parent, "PartDesign_Revolution", tr("Revolution parameters")),
ui(new Ui_TaskRevolutionParameters), proxy(new QWidget(this))
{
// we need a separate container widget to add all controls to
proxy = new QWidget(this);
ui->setupUi(proxy);
QMetaObject::connectSlotsByName(this);
this->groupLayout()->addWidget(proxy);

//bind property mirrors
PartDesign::ProfileBased* pcFeat = static_cast<PartDesign::ProfileBased*>(vp->getObject());
if (pcFeat->isDerivedFrom(PartDesign::Revolution::getClassTypeId())) {
PartDesign::Revolution* rev = static_cast<PartDesign::Revolution*>(vp->getObject());
// bind property mirrors
if (auto *rev = dynamic_cast<PartDesign::Revolution *>(vp->getObject())) {
this->propAngle = &(rev->Angle);
this->propMidPlane = &(rev->Midplane);
this->propReferenceAxis = &(rev->ReferenceAxis);
this->propReversed = &(rev->Reversed);
ui->revolveAngle->bind(rev->Angle);
} else {
assert(pcFeat->isDerivedFrom(PartDesign::Groove::getClassTypeId()));
PartDesign::Groove* rev = static_cast<PartDesign::Groove*>(vp->getObject());
}
else if (auto *rev = dynamic_cast<PartDesign::Groove *>(vp->getObject())) {
this->propAngle = &(rev->Angle);
this->propMidPlane = &(rev->Midplane);
this->propReferenceAxis = &(rev->ReferenceAxis);
this->propReversed = &(rev->Reversed);
ui->revolveAngle->bind(rev->Angle);
}
else {
throw Base::TypeError("The ViewProvider is not a Groove or a Revolution.");
}

ui->checkBoxMidplane->setChecked(propMidPlane->getValue());
ui->checkBoxReversed->setChecked(propReversed->getValue());
Expand All @@ -88,15 +87,16 @@ TaskRevolutionParameters::TaskRevolutionParameters(PartDesignGui::ViewProvider*

setFocus ();

//show the parts coordinate system axis for selection
// show the parts coordinate system axis for selection
PartDesign::Body * body = PartDesign::Body::findBodyOf ( vp->getObject () );
if(body) {
if (body) {
try {
App::Origin *origin = body->getOrigin();
ViewProviderOrigin* vpOrigin;
vpOrigin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->getViewProvider(origin));
auto *vpOrigin = static_cast<ViewProviderOrigin*>(
Gui::Application::Instance->getViewProvider(origin));
vpOrigin->setTemporaryVisibility(true, false);
} catch (const Base::Exception &ex) {
}
catch (const Base::Exception &ex) {
ex.ReportException();
}
}
Expand All @@ -109,17 +109,15 @@ void TaskRevolutionParameters::fillAxisCombo(bool forceRefill)
if (axesInList.empty())
forceRefill = true;//not filled yet, full refill

if (forceRefill){
if (forceRefill) {
ui->axis->clear();

for(size_t i = 0; i < axesInList.size(); i++){
delete axesInList[i];
}
this->axesInList.clear();
axesInList.clear();

//add sketch axes
PartDesign::ProfileBased* pcFeat = static_cast<PartDesign::ProfileBased*>(vp->getObject());
Part::Part2DObject* pcSketch = dynamic_cast<Part::Part2DObject*>(pcFeat->Profile.getValue());
auto *pcFeat = dynamic_cast<PartDesign::ProfileBased*>(vp->getObject());
if (!pcFeat)
throw Base::TypeError("The ViewProvider is not ProfileBased.");
auto *pcSketch = static_cast<Part::Part2DObject*>(pcFeat->Profile.getValue());
if (pcSketch){
addAxisToCombo(pcSketch,"V_Axis",QObject::tr("Vertical sketch axis"));
addAxisToCombo(pcSketch,"H_Axis",QObject::tr("Horizontal sketch axis"));
Expand Down Expand Up @@ -176,23 +174,23 @@ void TaskRevolutionParameters::addAxisToCombo(App::DocumentObject* linkObj,
QString itemText)
{
this->ui->axis->addItem(itemText);
this->axesInList.push_back(new App::PropertyLinkSub());
this->axesInList.emplace_back();
App::PropertyLinkSub &lnk = *(axesInList[axesInList.size()-1]);
lnk.setValue(linkObj,std::vector<std::string>(1,linkSubname));
}

void TaskRevolutionParameters::connectSignals()
{
connect(ui->revolveAngle, SIGNAL(valueChanged(double)),
this, SLOT(onAngleChanged(double)));
connect(ui->axis, SIGNAL(activated(int)),
this, SLOT(onAxisChanged(int)));
connect(ui->checkBoxMidplane, SIGNAL(toggled(bool)),
this, SLOT(onMidplane(bool)));
connect(ui->checkBoxReversed, SIGNAL(toggled(bool)),
this, SLOT(onReversed(bool)));
connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
this, SLOT(onUpdateView(bool)));
connect(ui->revolveAngle, qOverload<double>(&QuantitySpinBox::valueChanged), this,
&TaskRevolutionParameters::onAngleChanged);
connect(ui->axis, qOverload<int>(&QComboBox::activated), this,
&TaskRevolutionParameters::onAxisChanged);
connect(ui->checkBoxMidplane, &QCheckBox::toggled, this,
&TaskRevolutionParameters::onMidplane);
connect(ui->checkBoxReversed, &QCheckBox::toggled, this,
&TaskRevolutionParameters::onReversed);
connect(ui->checkBoxUpdateView, &QCheckBox::toggled, this,
&TaskRevolutionParameters::onUpdateView);
}

void TaskRevolutionParameters::updateUI()
Expand Down Expand Up @@ -353,9 +351,7 @@ TaskRevolutionParameters::~TaskRevolutionParameters()
ex.ReportException();
}

for (size_t i = 0; i < axesInList.size(); i++) {
delete axesInList[i];
}
axesInList.clear();
}

void TaskRevolutionParameters::changeEvent(QEvent *e)
Expand Down
5 changes: 2 additions & 3 deletions src/Mod/PartDesign/Gui/TaskRevolutionParameters.h
Expand Up @@ -70,7 +70,6 @@ private Q_SLOTS:
protected:
void onSelectionChanged(const Gui::SelectionChanges& msg) override;
void changeEvent(QEvent *e) override;
bool updateView() const;
void getReferenceAxis(App::DocumentObject *&obj, std::vector<std::string> &sub) const;
double getAngle() const;
bool getMidplane() const;
Expand All @@ -88,8 +87,8 @@ private Q_SLOTS:
void updateUI();

private:
QWidget* proxy;
std::unique_ptr<Ui_TaskRevolutionParameters> ui;
QWidget *proxy;

/**
* @brief axesInList is the list of links corresponding to axis combo; must
Expand All @@ -99,7 +98,7 @@ private Q_SLOTS:
* It is a list of pointers, because properties prohibit assignment. Use new
* when adding stuff, and delete when removing stuff.
*/
std::vector<App::PropertyLinkSub*> axesInList;
std::vector<std::unique_ptr<App::PropertyLinkSub>> axesInList;
};

/// simulation dialog for the TaskView
Expand Down

0 comments on commit 2aa232b

Please sign in to comment.