PartDesign: apply std::ranges

This commit is contained in:
bofdahof
2025-03-12 20:01:50 +10:00
committed by Chris Hennes
parent beb5dd9629
commit 216a76e971
13 changed files with 60 additions and 71 deletions

View File

@@ -294,13 +294,12 @@ void TaskPipeParameters::onDeleteEdge()
delete item;
// search inside the list of spines
auto pipe = getObject<PartDesign::Pipe>();
const auto pipe = getObject<PartDesign::Pipe>();
std::vector<std::string> refs = pipe->Spine.getSubValues();
std::string obj = data.constData();
std::vector<std::string>::iterator f = std::find(refs.begin(), refs.end(), obj);
const std::string obj = data.constData();
// if something was found, delete it and update the spine list
if (f != refs.end()) {
if (const auto f = std::ranges::find(refs, obj); f != refs.end()) {
refs.erase(f);
pipe->Spine.setValue(pipe->Spine.getValue(), refs);
clearButtons();
@@ -339,7 +338,7 @@ bool TaskPipeParameters::referenceSelected(const SelectionChanges& msg) const
std::vector<App::DocumentObject*> sections = pipe->Sections.getValues();
// cannot use the same object for profile and section
if (std::find(sections.begin(), sections.end(), profile) != sections.end()) {
if (std::ranges::find(sections, profile) != sections.end()) {
success = false;
}
else {
@@ -358,10 +357,10 @@ bool TaskPipeParameters::referenceSelected(const SelectionChanges& msg) const
case StateHandlerTaskPipe::SelectionModes::refSpineEdgeAdd:
case StateHandlerTaskPipe::SelectionModes::refSpineEdgeRemove: {
// change the references
std::string subName(msg.pSubName);
auto pipe = getObject<PartDesign::Pipe>();
const std::string subName(msg.pSubName);
const auto pipe = getObject<PartDesign::Pipe>();
std::vector<std::string> refs = pipe->Spine.getSubValues();
std::vector<std::string>::iterator f = std::find(refs.begin(), refs.end(), subName);
const auto f = std::ranges::find(refs, subName);
if (selectionMode == StateHandlerTaskPipe::SelectionModes::refSpine) {
getViewObject<ViewProviderPipe>()->highlightReferences(ViewProviderPipe::Spine,
@@ -792,11 +791,11 @@ bool TaskPipeOrientation::referenceSelected(const SelectionChanges& msg) const
return false;
}
if (auto pipe = getObject<PartDesign::Pipe>()) {
if (const auto pipe = getObject<PartDesign::Pipe>()) {
// change the references
std::string subName(msg.pSubName);
const std::string subName(msg.pSubName);
std::vector<std::string> refs = pipe->AuxillerySpine.getSubValues();
std::vector<std::string>::iterator f = std::find(refs.begin(), refs.end(), subName);
const auto f = std::ranges::find(refs, subName);
if (selectionMode == StateHandlerTaskPipe::SelectionModes::refAuxSpine) {
refs.clear();
@@ -846,13 +845,12 @@ void TaskPipeOrientation::onDeleteItem()
delete item;
// search inside the list of spines
if (auto pipe = getObject<PartDesign::Pipe>()) {
if (const auto pipe = getObject<PartDesign::Pipe>()) {
std::vector<std::string> refs = pipe->AuxillerySpine.getSubValues();
std::string obj = data.constData();
std::vector<std::string>::iterator f = std::find(refs.begin(), refs.end(), obj);
const std::string obj = data.constData();
// if something was found, delete it and update the spine list
if (f != refs.end()) {
if (const auto f = std::ranges::find(refs, obj); f != refs.end()) {
refs.erase(f);
pipe->AuxillerySpine.setValue(pipe->AuxillerySpine.getValue(), refs);
clearButtons();
@@ -1048,11 +1046,10 @@ bool TaskPipeScaling::referenceSelected(const SelectionChanges& msg) const
}
// change the references
if (auto pipe = getObject<PartDesign::Pipe>()) {
if (const auto pipe = getObject<PartDesign::Pipe>()) {
std::vector<App::DocumentObject*> refs = pipe->Sections.getValues();
App::DocumentObject* obj = pipe->getDocument()->getObject(msg.pObjectName);
std::vector<App::DocumentObject*>::iterator f =
std::find(refs.begin(), refs.end(), obj);
const auto f = std::ranges::find(refs, obj);
if (selectionMode == StateHandlerTaskPipe::SelectionModes::refSectionAdd) {
if (f != refs.end()) {
@@ -1100,13 +1097,11 @@ void TaskPipeScaling::onDeleteSection()
.first->getNameInDocument());
delete item;
if (auto pipe = getObject<PartDesign::Pipe>()) {
if (const auto pipe = getObject<PartDesign::Pipe>()) {
std::vector<App::DocumentObject*> refs = pipe->Sections.getValues();
App::DocumentObject* obj = pipe->getDocument()->getObject(data.constData());
std::vector<App::DocumentObject*>::iterator f =
std::find(refs.begin(), refs.end(), obj);
if (f != refs.end()) {
if (const auto f = std::ranges::find(refs.begin(), refs.end(), obj); f != refs.end()) {
pipe->Sections.removeValue(obj);
clearButtons();
recomputeFeature();