PD: Make blockUpdate private class member

This commit is contained in:
wmayer
2024-07-17 20:09:53 +02:00
parent f0024a8930
commit cf6d8da448
6 changed files with 31 additions and 33 deletions

View File

@@ -300,16 +300,6 @@ TaskDlgDraftParameters::~TaskDlgDraftParameters() = default;
//==== calls from the TaskView ===============================================================
//void TaskDlgDraftParameters::open()
//{
// // a transaction is already open at creation time of the draft
// if (!Gui::Command::hasPendingCommand()) {
// QString msg = QObject::tr("Edit draft");
// Gui::Command::openCommand((const char*)msg.toUtf8());
// }
//}
bool TaskDlgDraftParameters::accept()
{
auto tobj = vp->getObject();
@@ -328,13 +318,6 @@ bool TaskDlgDraftParameters::accept()
draftparameter->getLine(obj, strings);
std::string pullDirection = buildLinkSingleSubPythonStr(obj, strings);
// Force the user to select a neutral plane
// if (neutralPlane.empty() || neutralPlane == "None") {
// QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Missing neutral plane"),
// QObject::tr("Please select a plane or an edge plus a pull direction"));
// return false;
// }
FCMD_OBJ_CMD(tobj,"Angle = " << draftparameter->getAngle());
FCMD_OBJ_CMD(tobj,"Reversed = " << draftparameter->getReversed());
if(neutralPlane.empty())

View File

@@ -27,6 +27,7 @@
#endif
#include <App/Document.h>
#include <Base/Tools.h>
#include <Base/UnitsApi.h>
#include <Gui/Command.h>
#include <Mod/PartDesign/App/FeatureExtrude.h>
@@ -564,8 +565,7 @@ bool TaskExtrudeParameters::hasProfileFace(PartDesign::ProfileBased* profile) co
void TaskExtrudeParameters::fillDirectionCombo()
{
bool oldVal_blockUpdate = blockUpdate;
blockUpdate = true;
Base::StateLocker lock(getUpdateBlockRef(), true);
if (axesInList.empty()) {
bool hasFace = false;
@@ -628,8 +628,6 @@ void TaskExtrudeParameters::fillDirectionCombo()
ui->directionCB->setCurrentIndex(indexOfCurrent);
if (hasCustom)
ui->directionCB->setCurrentIndex(DirectionModes::Custom);
blockUpdate = oldVal_blockUpdate;
}
void TaskExtrudeParameters::addAxisToCombo(App::DocumentObject* linkObj, std::string linkSubname,

View File

@@ -58,9 +58,28 @@ private:
/** Notifies when the object is about to be removed. */
void slotDeletedObject(const Gui::ViewProviderDocumentObject& Obj) override;
protected:
bool isUpdateBlocked() const
{
return blockUpdate;
}
bool& getUpdateBlockRef()
{
return blockUpdate;
}
void setUpdateBlocked(bool value)
{
blockUpdate = value;
}
protected:
PartDesignGui::ViewProvider *vp;
/// Lock updateUI(), applying changes to the underlying feature and calling recomputeFeature()
private:
bool blockUpdate;
};

View File

@@ -27,6 +27,7 @@
#include <App/DocumentObject.h>
#include <App/Origin.h>
#include <Base/Console.h>
#include <Base/Tools.h>
#include <Gui/Application.h>
#include <Gui/CommandT.h>
#include <Gui/Document.h>
@@ -177,8 +178,7 @@ void TaskHelixParameters::showCoordinateAxes()
void TaskHelixParameters::fillAxisCombo(bool forceRefill)
{
bool oldVal_blockUpdate = blockUpdate;
blockUpdate = true;
Base::StateLocker lock(getUpdateBlockRef(), true);
if (axesInList.empty())
forceRefill = true;//not filled yet, full refill
@@ -201,8 +201,6 @@ void TaskHelixParameters::fillAxisCombo(bool forceRefill)
int indexOfCurrent = addCurrentLink();
if (indexOfCurrent != -1)
ui->axis->setCurrentIndex(indexOfCurrent);
blockUpdate = oldVal_blockUpdate;
}
void TaskHelixParameters::addSketchAxes()

View File

@@ -281,7 +281,7 @@ void TaskHoleParameters::threadedChanged()
// update view not active if modeling threads
// this will also ensure that the feature is recomputed.
ui->UpdateView->setEnabled(ui->Threaded->isChecked() && ui->ModelThread->isChecked());
blockUpdate = ui->Threaded->isChecked() && ui->ModelThread->isChecked() && !(ui->UpdateView->isChecked());
setUpdateBlocked(ui->Threaded->isChecked() && ui->ModelThread->isChecked() && !(ui->UpdateView->isChecked()));
pcHole->Threaded.setValue(ui->Threaded->isChecked());
recomputeFeature();
@@ -296,7 +296,7 @@ void TaskHoleParameters::modelThreadChanged()
// update view not active if modeling threads
// this will also ensure that the feature is recomputed.
ui->UpdateView->setEnabled(ui->Threaded->isChecked() && ui->ModelThread->isChecked());
blockUpdate = ui->Threaded->isChecked() && ui->ModelThread->isChecked() && !(ui->UpdateView->isChecked());
setUpdateBlocked(ui->Threaded->isChecked() && ui->ModelThread->isChecked() && !(ui->UpdateView->isChecked()));
// conditional enabling of thread modeling options
ui->UseCustomThreadClearance->setEnabled(ui->Threaded->isChecked() && ui->ModelThread->isChecked());
@@ -310,7 +310,7 @@ void TaskHoleParameters::modelThreadChanged()
void TaskHoleParameters::updateViewChanged(bool isChecked)
{
blockUpdate = !isChecked;
setUpdateBlocked(!isChecked);
recomputeFeature();
}

View File

@@ -86,7 +86,7 @@ TaskRevolutionParameters::TaskRevolutionParameters(PartDesignGui::ViewProvider*
setupDialog();
blockUpdate = false;
setUpdateBlocked(false);
updateUI(ui->changeMode->currentIndex());
connectSignals();
@@ -185,7 +185,7 @@ void TaskRevolutionParameters::translateModeList(int index)
void TaskRevolutionParameters::fillAxisCombo(bool forceRefill)
{
Base::StateLocker lock(blockUpdate, true);
Base::StateLocker lock(getUpdateBlockRef(), true);
if (axesInList.empty())
forceRefill = true;//not filled yet, full refill
@@ -348,9 +348,9 @@ void TaskRevolutionParameters::connectSignals()
void TaskRevolutionParameters::updateUI(int index)
{
if (blockUpdate)
if (isUpdateBlocked())
return;
Base::StateLocker lock(blockUpdate, true);
Base::StateLocker lock(getUpdateBlockRef(), true);
fillAxisCombo();
setCheckboxes(static_cast<PartDesign::Revolution::RevolMethod>(index));
}
@@ -485,7 +485,7 @@ void TaskRevolutionParameters::onAngle2Changed(double len)
void TaskRevolutionParameters::onAxisChanged(int num)
{
if (blockUpdate)
if (isUpdateBlocked())
return;
PartDesign::ProfileBased* pcRevolution = static_cast<PartDesign::ProfileBased*>(vp->getObject());