[PD] TaskDlgRevolutionParameters: fix some CI warnings
- reported here: https://github.com/FreeCAD/FreeCAD/pull/7667/commits/f0a0e563 - and here: https://github.com/FreeCAD/FreeCAD/pull/7719/commits/8f3f17f8
This commit is contained in:
@@ -47,33 +47,32 @@ using namespace Gui;
|
|||||||
/* TRANSLATOR PartDesignGui::TaskRevolutionParameters */
|
/* TRANSLATOR PartDesignGui::TaskRevolutionParameters */
|
||||||
|
|
||||||
TaskRevolutionParameters::TaskRevolutionParameters(PartDesignGui::ViewProvider* RevolutionView, QWidget *parent)
|
TaskRevolutionParameters::TaskRevolutionParameters(PartDesignGui::ViewProvider* RevolutionView, QWidget *parent)
|
||||||
: TaskSketchBasedParameters(RevolutionView, parent, "PartDesign_Revolution", tr("Revolution parameters"))
|
: TaskSketchBasedParameters(RevolutionView, parent, "PartDesign_Revolution", tr("Revolution parameters")),
|
||||||
, ui(new Ui_TaskRevolutionParameters)
|
ui(new Ui_TaskRevolutionParameters), proxy(new QWidget(this))
|
||||||
{
|
{
|
||||||
// we need a separate container widget to add all controls to
|
// we need a separate container widget to add all controls to
|
||||||
proxy = new QWidget(this);
|
|
||||||
ui->setupUi(proxy);
|
ui->setupUi(proxy);
|
||||||
QMetaObject::connectSlotsByName(this);
|
QMetaObject::connectSlotsByName(this);
|
||||||
this->groupLayout()->addWidget(proxy);
|
this->groupLayout()->addWidget(proxy);
|
||||||
|
|
||||||
//bind property mirrors
|
// bind property mirrors
|
||||||
PartDesign::ProfileBased* pcFeat = static_cast<PartDesign::ProfileBased*>(vp->getObject());
|
if (auto *rev = dynamic_cast<PartDesign::Revolution *>(vp->getObject())) {
|
||||||
if (pcFeat->isDerivedFrom(PartDesign::Revolution::getClassTypeId())) {
|
|
||||||
PartDesign::Revolution* rev = static_cast<PartDesign::Revolution*>(vp->getObject());
|
|
||||||
this->propAngle = &(rev->Angle);
|
this->propAngle = &(rev->Angle);
|
||||||
this->propMidPlane = &(rev->Midplane);
|
this->propMidPlane = &(rev->Midplane);
|
||||||
this->propReferenceAxis = &(rev->ReferenceAxis);
|
this->propReferenceAxis = &(rev->ReferenceAxis);
|
||||||
this->propReversed = &(rev->Reversed);
|
this->propReversed = &(rev->Reversed);
|
||||||
ui->revolveAngle->bind(rev->Angle);
|
ui->revolveAngle->bind(rev->Angle);
|
||||||
} else {
|
}
|
||||||
assert(pcFeat->isDerivedFrom(PartDesign::Groove::getClassTypeId()));
|
else if (auto *rev = dynamic_cast<PartDesign::Groove *>(vp->getObject())) {
|
||||||
PartDesign::Groove* rev = static_cast<PartDesign::Groove*>(vp->getObject());
|
|
||||||
this->propAngle = &(rev->Angle);
|
this->propAngle = &(rev->Angle);
|
||||||
this->propMidPlane = &(rev->Midplane);
|
this->propMidPlane = &(rev->Midplane);
|
||||||
this->propReferenceAxis = &(rev->ReferenceAxis);
|
this->propReferenceAxis = &(rev->ReferenceAxis);
|
||||||
this->propReversed = &(rev->Reversed);
|
this->propReversed = &(rev->Reversed);
|
||||||
ui->revolveAngle->bind(rev->Angle);
|
ui->revolveAngle->bind(rev->Angle);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
throw Base::TypeError("The ViewProvider is not a Groove or a Revolution.");
|
||||||
|
}
|
||||||
|
|
||||||
ui->checkBoxMidplane->setChecked(propMidPlane->getValue());
|
ui->checkBoxMidplane->setChecked(propMidPlane->getValue());
|
||||||
ui->checkBoxReversed->setChecked(propReversed->getValue());
|
ui->checkBoxReversed->setChecked(propReversed->getValue());
|
||||||
@@ -88,15 +87,16 @@ TaskRevolutionParameters::TaskRevolutionParameters(PartDesignGui::ViewProvider*
|
|||||||
|
|
||||||
setFocus ();
|
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 () );
|
PartDesign::Body * body = PartDesign::Body::findBodyOf ( vp->getObject () );
|
||||||
if(body) {
|
if (body) {
|
||||||
try {
|
try {
|
||||||
App::Origin *origin = body->getOrigin();
|
App::Origin *origin = body->getOrigin();
|
||||||
ViewProviderOrigin* vpOrigin;
|
auto *vpOrigin = static_cast<ViewProviderOrigin*>(
|
||||||
vpOrigin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->getViewProvider(origin));
|
Gui::Application::Instance->getViewProvider(origin));
|
||||||
vpOrigin->setTemporaryVisibility(true, false);
|
vpOrigin->setTemporaryVisibility(true, false);
|
||||||
} catch (const Base::Exception &ex) {
|
}
|
||||||
|
catch (const Base::Exception &ex) {
|
||||||
ex.ReportException();
|
ex.ReportException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -109,17 +109,15 @@ void TaskRevolutionParameters::fillAxisCombo(bool forceRefill)
|
|||||||
if (axesInList.empty())
|
if (axesInList.empty())
|
||||||
forceRefill = true;//not filled yet, full refill
|
forceRefill = true;//not filled yet, full refill
|
||||||
|
|
||||||
if (forceRefill){
|
if (forceRefill) {
|
||||||
ui->axis->clear();
|
ui->axis->clear();
|
||||||
|
axesInList.clear();
|
||||||
for(size_t i = 0; i < axesInList.size(); i++){
|
|
||||||
delete axesInList[i];
|
|
||||||
}
|
|
||||||
this->axesInList.clear();
|
|
||||||
|
|
||||||
//add sketch axes
|
//add sketch axes
|
||||||
PartDesign::ProfileBased* pcFeat = static_cast<PartDesign::ProfileBased*>(vp->getObject());
|
auto *pcFeat = dynamic_cast<PartDesign::ProfileBased*>(vp->getObject());
|
||||||
Part::Part2DObject* pcSketch = dynamic_cast<Part::Part2DObject*>(pcFeat->Profile.getValue());
|
if (!pcFeat)
|
||||||
|
throw Base::TypeError("The ViewProvider is not ProfileBased.");
|
||||||
|
auto *pcSketch = static_cast<Part::Part2DObject*>(pcFeat->Profile.getValue());
|
||||||
if (pcSketch){
|
if (pcSketch){
|
||||||
addAxisToCombo(pcSketch,"V_Axis",QObject::tr("Vertical sketch axis"));
|
addAxisToCombo(pcSketch,"V_Axis",QObject::tr("Vertical sketch axis"));
|
||||||
addAxisToCombo(pcSketch,"H_Axis",QObject::tr("Horizontal sketch axis"));
|
addAxisToCombo(pcSketch,"H_Axis",QObject::tr("Horizontal sketch axis"));
|
||||||
@@ -176,23 +174,23 @@ void TaskRevolutionParameters::addAxisToCombo(App::DocumentObject* linkObj,
|
|||||||
QString itemText)
|
QString itemText)
|
||||||
{
|
{
|
||||||
this->ui->axis->addItem(itemText);
|
this->ui->axis->addItem(itemText);
|
||||||
this->axesInList.push_back(new App::PropertyLinkSub());
|
this->axesInList.emplace_back();
|
||||||
App::PropertyLinkSub &lnk = *(axesInList[axesInList.size()-1]);
|
App::PropertyLinkSub &lnk = *(axesInList[axesInList.size()-1]);
|
||||||
lnk.setValue(linkObj,std::vector<std::string>(1,linkSubname));
|
lnk.setValue(linkObj,std::vector<std::string>(1,linkSubname));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskRevolutionParameters::connectSignals()
|
void TaskRevolutionParameters::connectSignals()
|
||||||
{
|
{
|
||||||
connect(ui->revolveAngle, SIGNAL(valueChanged(double)),
|
connect(ui->revolveAngle, qOverload<double>(&QuantitySpinBox::valueChanged), this,
|
||||||
this, SLOT(onAngleChanged(double)));
|
&TaskRevolutionParameters::onAngleChanged);
|
||||||
connect(ui->axis, SIGNAL(activated(int)),
|
connect(ui->axis, qOverload<int>(&QComboBox::activated), this,
|
||||||
this, SLOT(onAxisChanged(int)));
|
&TaskRevolutionParameters::onAxisChanged);
|
||||||
connect(ui->checkBoxMidplane, SIGNAL(toggled(bool)),
|
connect(ui->checkBoxMidplane, &QCheckBox::toggled, this,
|
||||||
this, SLOT(onMidplane(bool)));
|
&TaskRevolutionParameters::onMidplane);
|
||||||
connect(ui->checkBoxReversed, SIGNAL(toggled(bool)),
|
connect(ui->checkBoxReversed, &QCheckBox::toggled, this,
|
||||||
this, SLOT(onReversed(bool)));
|
&TaskRevolutionParameters::onReversed);
|
||||||
connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
|
connect(ui->checkBoxUpdateView, &QCheckBox::toggled, this,
|
||||||
this, SLOT(onUpdateView(bool)));
|
&TaskRevolutionParameters::onUpdateView);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskRevolutionParameters::updateUI()
|
void TaskRevolutionParameters::updateUI()
|
||||||
@@ -353,9 +351,7 @@ TaskRevolutionParameters::~TaskRevolutionParameters()
|
|||||||
ex.ReportException();
|
ex.ReportException();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < axesInList.size(); i++) {
|
axesInList.clear();
|
||||||
delete axesInList[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskRevolutionParameters::changeEvent(QEvent *e)
|
void TaskRevolutionParameters::changeEvent(QEvent *e)
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ private Q_SLOTS:
|
|||||||
protected:
|
protected:
|
||||||
void onSelectionChanged(const Gui::SelectionChanges& msg) override;
|
void onSelectionChanged(const Gui::SelectionChanges& msg) override;
|
||||||
void changeEvent(QEvent *e) override;
|
void changeEvent(QEvent *e) override;
|
||||||
bool updateView() const;
|
|
||||||
void getReferenceAxis(App::DocumentObject *&obj, std::vector<std::string> &sub) const;
|
void getReferenceAxis(App::DocumentObject *&obj, std::vector<std::string> &sub) const;
|
||||||
double getAngle() const;
|
double getAngle() const;
|
||||||
bool getMidplane() const;
|
bool getMidplane() const;
|
||||||
@@ -88,8 +87,8 @@ private:
|
|||||||
void updateUI();
|
void updateUI();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget* proxy;
|
|
||||||
std::unique_ptr<Ui_TaskRevolutionParameters> ui;
|
std::unique_ptr<Ui_TaskRevolutionParameters> ui;
|
||||||
|
QWidget *proxy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief axesInList is the list of links corresponding to axis combo; must
|
* @brief axesInList is the list of links corresponding to axis combo; must
|
||||||
@@ -99,7 +98,7 @@ private:
|
|||||||
* It is a list of pointers, because properties prohibit assignment. Use new
|
* It is a list of pointers, because properties prohibit assignment. Use new
|
||||||
* when adding stuff, and delete when removing stuff.
|
* 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
|
/// simulation dialog for the TaskView
|
||||||
|
|||||||
Reference in New Issue
Block a user