Skip to content

Commit

Permalink
[PD] only recompute once per deletion action
Browse files Browse the repository at this point in the history
  • Loading branch information
donovaly authored and wwmayer committed Feb 23, 2020
1 parent c6bb533 commit da6352c
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 25 deletions.
20 changes: 13 additions & 7 deletions src/Mod/PartDesign/Gui/TaskChamferParameters.cpp
Expand Up @@ -164,23 +164,29 @@ void TaskChamferParameters::onRefDeleted(void)
return;
}

// get the chamfer object
PartDesign::Chamfer* pcChamfer = static_cast<PartDesign::Chamfer*>(DressUpView->getObject());
App::DocumentObject* base = pcChamfer->Base.getValue();
// get all chamfer references
std::vector<std::string> refs = pcChamfer->Base.getSubValues();

// delete the selection backwards to assure the list index keeps valid for the deletion
for (int i = selectedList.count() - 1; i > -1; i--) {
// get the fillet object
PartDesign::Chamfer* pcChamfer = static_cast<PartDesign::Chamfer*>(DressUpView->getObject());
App::DocumentObject* base = pcChamfer->Base.getValue();
// get all fillet references
std::vector<std::string> refs = pcChamfer->Base.getSubValues();
// the ref index is the same as the listWidgetReferences index
// so we can erase using the row number of the element to be deleted
int rowNumber = ui->listWidgetReferences->row(selectedList.at(i));
// erase the reference
refs.erase(refs.begin() + rowNumber);
setupTransaction();
// update the object
pcChamfer->Base.setValue(base, refs);
ui->listWidgetReferences->model()->removeRow(rowNumber);
pcChamfer->getDocument()->recomputeFeature(pcChamfer);
// remove from the list
ui->listWidgetReferences->model()->removeRow(rowNumber);
}

// recompute the feature
pcChamfer->getDocument()->recomputeFeature(pcChamfer);

// if there is only one item left, it cannot be deleted
if (ui->listWidgetReferences->count() == 1) {
deleteAction->setEnabled(false);
Expand Down
18 changes: 12 additions & 6 deletions src/Mod/PartDesign/Gui/TaskDraftParameters.cpp
Expand Up @@ -238,23 +238,29 @@ void TaskDraftParameters::onRefDeleted(void)
return;
}

// get the draft object
PartDesign::Draft* pcDraft = static_cast<PartDesign::Draft*>(DressUpView->getObject());
App::DocumentObject* base = pcDraft->Base.getValue();
// get all draft references
std::vector<std::string> refs = pcDraft->Base.getSubValues();

// delete the selection backwards to assure the list index keeps valid for the deletion
for (int i = selectedList.count() - 1; i > -1; i--) {
// get the fillet object
PartDesign::Draft* pcDraft = static_cast<PartDesign::Draft*>(DressUpView->getObject());
App::DocumentObject* base = pcDraft->Base.getValue();
// get all fillet references
std::vector<std::string> refs = pcDraft->Base.getSubValues();
// the ref index is the same as the listWidgetReferences index
// so we can erase using the row number of the element to be deleted
int rowNumber = ui->listWidgetReferences->row(selectedList.at(i));
// erase the reference
refs.erase(refs.begin() + rowNumber);
setupTransaction();
// update the object
pcDraft->Base.setValue(base, refs);
// remove from the list
ui->listWidgetReferences->model()->removeRow(rowNumber);
pcDraft->getDocument()->recomputeFeature(pcDraft);
}

// recompute the feature
pcDraft->getDocument()->recomputeFeature(pcDraft);

// if there is only one item left, it cannot be deleted
if (ui->listWidgetReferences->count() == 1) {
deleteAction->setEnabled(false);
Expand Down
18 changes: 12 additions & 6 deletions src/Mod/PartDesign/Gui/TaskFilletParameters.cpp
Expand Up @@ -164,23 +164,29 @@ void TaskFilletParameters::onRefDeleted(void)
return;
}

// get the fillet object
PartDesign::Fillet* pcFillet = static_cast<PartDesign::Fillet*>(DressUpView->getObject());
App::DocumentObject* base = pcFillet->Base.getValue();
// get all fillet references
std::vector<std::string> refs = pcFillet->Base.getSubValues();

// delete the selection backwards to assure the list index keeps valid for the deletion
for (int i = selectedList.count()-1; i > -1; i--) {
// get the fillet object
PartDesign::Fillet* pcFillet = static_cast<PartDesign::Fillet*>(DressUpView->getObject());
App::DocumentObject* base = pcFillet->Base.getValue();
// get all fillet references
std::vector<std::string> refs = pcFillet->Base.getSubValues();
// the ref index is the same as the listWidgetReferences index
// so we can erase using the row number of the element to be deleted
int rowNumber = ui->listWidgetReferences->row(selectedList.at(i));
// erase the reference
refs.erase(refs.begin() + rowNumber);
setupTransaction();
// update the object
pcFillet->Base.setValue(base, refs);
// remove from the list
ui->listWidgetReferences->model()->removeRow(rowNumber);
pcFillet->getDocument()->recomputeFeature(pcFillet);
}

// recompute the feature
pcFillet->getDocument()->recomputeFeature(pcFillet);

// if there is only one item left, it cannot be deleted
if (ui->listWidgetReferences->count() == 1) {
deleteAction->setEnabled(false);
Expand Down
18 changes: 12 additions & 6 deletions src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp
Expand Up @@ -186,23 +186,29 @@ void TaskThicknessParameters::onRefDeleted(void)
return;
}

// get the thickness object
PartDesign::Thickness* pcThickness = static_cast<PartDesign::Thickness*>(DressUpView->getObject());
App::DocumentObject* base = pcThickness->Base.getValue();
// get all thickness references
std::vector<std::string> refs = pcThickness->Base.getSubValues();

// delete the selection backwards to assure the list index keeps valid for the deletion
for (int i = selectedList.count() - 1; i > -1; i--) {
// get the fillet object
PartDesign::Thickness* pcThickness = static_cast<PartDesign::Thickness*>(DressUpView->getObject());
App::DocumentObject* base = pcThickness->Base.getValue();
// get all fillet references
std::vector<std::string> refs = pcThickness->Base.getSubValues();
// the ref index is the same as the listWidgetReferences index
// so we can erase using the row number of the element to be deleted
int rowNumber = ui->listWidgetReferences->row(selectedList.at(i));
// erase the reference
refs.erase(refs.begin() + rowNumber);
setupTransaction();
// update the object
pcThickness->Base.setValue(base, refs);
// remove from the list
ui->listWidgetReferences->model()->removeRow(rowNumber);
pcThickness->getDocument()->recomputeFeature(pcThickness);
}

// recompute the feature
pcThickness->getDocument()->recomputeFeature(pcThickness);

// if there is only one item left, it cannot be deleted
if (ui->listWidgetReferences->count() == 1) {
deleteAction->setEnabled(false);
Expand Down

0 comments on commit da6352c

Please sign in to comment.