diff --git a/src/Mod/PartDesign/App/Body.cpp b/src/Mod/PartDesign/App/Body.cpp index 1d9dba2a8f..6f3ec09edd 100644 --- a/src/Mod/PartDesign/App/Body.cpp +++ b/src/Mod/PartDesign/App/Body.cpp @@ -353,7 +353,7 @@ std::vector Body::removeObject(App::DocumentObject* featur } std::vector model = Group.getValues(); - std::vector::iterator it = std::find(model.begin(), model.end(), feature); + const auto it = std::ranges::find(model, feature); // Adjust Tip feature if it is pointing to the deleted object if (Tip.getValue()== feature) { diff --git a/src/Mod/PartDesign/App/FeatureDressUp.cpp b/src/Mod/PartDesign/App/FeatureDressUp.cpp index ed7d00e37e..d98a3ab7ad 100644 --- a/src/Mod/PartDesign/App/FeatureDressUp.cpp +++ b/src/Mod/PartDesign/App/FeatureDressUp.cpp @@ -158,7 +158,7 @@ void DressUp::getContinuousEdges(Part::TopoShape TopShape, std::vector< std::str buf << "Edge"; buf << id; - if(std::find(SubNames.begin(),SubNames.end(),buf.str()) == SubNames.end()) + if (std::ranges::find(SubNames, buf.str()) == SubNames.end()) { SubNames.push_back(buf.str()); } diff --git a/src/Mod/PartDesign/App/FeatureLoft.cpp b/src/Mod/PartDesign/App/FeatureLoft.cpp index 05cb21c004..440e8c2ff3 100644 --- a/src/Mod/PartDesign/App/FeatureLoft.cpp +++ b/src/Mod/PartDesign/App/FeatureLoft.cpp @@ -72,11 +72,11 @@ Loft::getSectionShape(const char *name, size_t expected_size) { std::vector shapes; - // Be smart. If part of a sketch is selected, use the entire sketch unless it is a single vertex - + // Be smart. If part of a sketch is selected, use the entire sketch unless it is a single vertex - // backward compatibility (#16630) auto subName = subs.empty() ? "" : subs.front(); auto useEntireSketch = obj->isDerivedFrom() && subName.find("Vertex") != 0; - if (subs.empty() || std::find(subs.begin(), subs.end(), std::string()) != subs.end() || useEntireSketch ) { + if (subs.empty() || std::ranges::find(subs, std::string()) != subs.end() || useEntireSketch ) { shapes.push_back(Part::Feature::getTopoShape(obj)); if (shapes.back().isNull()) FC_THROWM(Part::NullShapeException, "Failed to get shape of " diff --git a/src/Mod/PartDesign/App/ShapeBinder.cpp b/src/Mod/PartDesign/App/ShapeBinder.cpp index 53625c6468..2f84429815 100644 --- a/src/Mod/PartDesign/App/ShapeBinder.cpp +++ b/src/Mod/PartDesign/App/ShapeBinder.cpp @@ -317,8 +317,7 @@ void ShapeBinder::slotChangedObject(const App::DocumentObject& Obj, const App::P list = obj->getInListRecursive(); chain.insert(chain.end(), list.begin(), list.end()); - auto it = std::find(chain.begin(), chain.end(), &Obj); - if (it != chain.end()) { + if (const auto it = std::ranges::find(chain, &Obj); it != chain.end()) { if (hasPlacementChanged()) { enforceRecompute(); } diff --git a/src/Mod/PartDesign/Gui/CommandBody.cpp b/src/Mod/PartDesign/Gui/CommandBody.cpp index 8ac6b343d1..0f2f85e804 100644 --- a/src/Mod/PartDesign/Gui/CommandBody.cpp +++ b/src/Mod/PartDesign/Gui/CommandBody.cpp @@ -379,16 +379,16 @@ void CmdPartDesignMigrate::activated(int iMsg) featIt = baseFeatSetIt; continue; } else { - // The base feature seems already assigned to some chain - // Find which + // The base feature seems already assigned to some chain. Find which std::list::iterator baseFeatIt; - auto chainIt = std::find_if( featureChains.begin(), featureChains.end(), - [baseFeat, &baseFeatIt] ( std::list&chain ) mutable -> bool { - baseFeatIt = std::find( chain.begin(), chain.end(), baseFeat ); - return baseFeatIt != chain.end(); - } ); + auto isChain = [baseFeat, &baseFeatIt]( + std::list& fchain) mutable -> bool { + baseFeatIt = std::ranges::find(fchain, baseFeat); + return baseFeatIt != fchain.end(); + }; - if ( chainIt != featureChains.end() ) { + if (auto chainIt = std::ranges::find_if(featureChains, isChain); + chainIt != featureChains.end() ) { assert (baseFeatIt != chainIt->end()); if ( std::next ( baseFeatIt ) == chainIt->end() ) { // just append our chain to already found diff --git a/src/Mod/PartDesign/Gui/TaskBooleanParameters.cpp b/src/Mod/PartDesign/Gui/TaskBooleanParameters.cpp index 6fe2e5764a..e1ec6d3ffd 100644 --- a/src/Mod/PartDesign/Gui/TaskBooleanParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskBooleanParameters.cpp @@ -136,7 +136,7 @@ void TaskBooleanParameters::onSelectionChanged(const Gui::SelectionChanges& msg) std::vector bodies = pcBoolean->Group.getValues(); if (selectionMode == bodyAdd) { - if (std::find(bodies.begin(), bodies.end(), pcBody) == bodies.end()) { + if (std::ranges::find(bodies, pcBody) == bodies.end()) { bodies.push_back(pcBody); pcBoolean->Group.setValues(std::vector()); pcBoolean->addObjects(bodies); @@ -178,13 +178,11 @@ void TaskBooleanParameters::onSelectionChanged(const Gui::SelectionChanges& msg) } } else if (selectionMode == bodyRemove) { - std::vector::iterator b = - std::find(bodies.begin(), bodies.end(), pcBody); - if (b != bodies.end()) { + if (const auto b = std::ranges::find(bodies, pcBody); b != bodies.end()) { bodies.erase(b); pcBoolean->setObjects(bodies); - QString internalName = QString::fromStdString(body); + const QString internalName = QString::fromStdString(body); for (int row = 0; row < ui->listWidgetBodies->count(); row++) { QListWidgetItem* item = ui->listWidgetBodies->item(row); QString name = item->data(Qt::UserRole).toString(); diff --git a/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp b/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp index 8467f87ed7..9f32c90f23 100644 --- a/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp @@ -119,19 +119,19 @@ void TaskDressUpParameters::referenceSelected(const Gui::SelectionChanges& msg, // TODO: Must we make a copy here instead of assigning to const char* ? const char* fname = base->getNameInDocument(); - if (strcmp(msg.pObjectName, fname) != 0) + if (strcmp(msg.pObjectName, fname) != 0) { return; + } - std::string subName(msg.pSubName); + const std::string subName(msg.pSubName); std::vector refs = pcDressUp->Base.getSubValues(); - std::vector::iterator f = std::find(refs.begin(), refs.end(), subName); - if (f != refs.end()) { //If it's found then it's in the list so we remove it. - refs.erase(f); + if (const auto f = std::ranges::find(refs, subName); f != refs.end()) { + refs.erase(f); // it's in the list. Remove it removeItemFromListWidget(widget, msg.pSubName); } - else { //if it's not found then it's not yet in the list so we add it. - refs.push_back(subName); + else { + refs.push_back(subName); // not yet in the list so we add it widget->addItem(QString::fromStdString(msg.pSubName)); } diff --git a/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp b/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp index f22d89afb1..18a47f41c1 100644 --- a/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp @@ -404,19 +404,18 @@ void TaskExtrudeParameters::selectedShapeFace(const Gui::SelectionChanges& msg) } std::vector faces = getShapeFaces(); - std::string subName(msg.pSubName); + const std::string subName(msg.pSubName); if (subName.empty()) { return; } - auto positionInList = std::find(faces.begin(), faces.end(), subName); - - if (positionInList != faces.end()) { // If it's found then it's in the list so we remove it. - faces.erase(positionInList); + if (const auto positionInList = std::ranges::find(faces, subName); + positionInList != faces.end()) { // it's in the list + faces.erase(positionInList); // remove it. } - else { // if it's not found then it's not yet in the list so we add it. - faces.push_back(subName); + else { + faces.push_back(subName); // not yet in the list so add it. } extrude->UpToShape.setValue(base, faces); diff --git a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp index 81747c6418..023c8017e6 100644 --- a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp +++ b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp @@ -29,6 +29,8 @@ #include #endif +#include + #include #include @@ -555,9 +557,7 @@ void TaskFeaturePick::onDoubleClick(QListWidgetItem* item) void TaskFeaturePick::slotDeletedObject(const Gui::ViewProviderDocumentObject& Obj) { - std::vector::iterator it; - it = std::find(origins.begin(), origins.end(), &Obj); - if (it != origins.end()) { + if (const auto it = std::ranges::find(origins, &Obj); it != origins.end()) { origins.erase(it); } } diff --git a/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp b/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp index 8529a322ea..36341c991f 100644 --- a/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp @@ -214,11 +214,11 @@ bool TaskLoftParameters::referenceSelected(const Gui::SelectionChanges& msg) con loft->Profile.setValue(obj, {msg.pSubName}); return true; } - else if (selectionMode == refAdd || selectionMode == refRemove) { + + if (selectionMode == refAdd || selectionMode == refRemove) { // now check the sections std::vector refs = loft->Sections.getValues(); - std::vector::iterator f = - std::find(refs.begin(), refs.end(), obj); + const auto f = std::ranges::find(refs, obj); if (selectionMode == refAdd) { if (f != refs.end()) { @@ -266,12 +266,10 @@ void TaskLoftParameters::onDeleteSection() delete item; // search inside the list of sections - if (auto loft = getObject()) { + if (const auto loft = getObject()) { std::vector refs = loft->Sections.getValues(); App::DocumentObject* obj = loft->getDocument()->getObject(data.constData()); - std::vector::iterator f = - std::find(refs.begin(), refs.end(), obj); - if (f != refs.end()) { + if (const auto f = std::ranges::find(refs, obj); f != refs.end()) { loft->Sections.removeValue(obj); recomputeFeature(); diff --git a/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp index 0c65626b2e..235379ee76 100644 --- a/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp @@ -294,13 +294,12 @@ void TaskPipeParameters::onDeleteEdge() delete item; // search inside the list of spines - auto pipe = getObject(); + const auto pipe = getObject(); std::vector refs = pipe->Spine.getSubValues(); - std::string obj = data.constData(); - std::vector::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 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(); + const std::string subName(msg.pSubName); + const auto pipe = getObject(); std::vector refs = pipe->Spine.getSubValues(); - std::vector::iterator f = std::find(refs.begin(), refs.end(), subName); + const auto f = std::ranges::find(refs, subName); if (selectionMode == StateHandlerTaskPipe::SelectionModes::refSpine) { getViewObject()->highlightReferences(ViewProviderPipe::Spine, @@ -792,11 +791,11 @@ bool TaskPipeOrientation::referenceSelected(const SelectionChanges& msg) const return false; } - if (auto pipe = getObject()) { + if (const auto pipe = getObject()) { // change the references - std::string subName(msg.pSubName); + const std::string subName(msg.pSubName); std::vector refs = pipe->AuxillerySpine.getSubValues(); - std::vector::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()) { + if (const auto pipe = getObject()) { std::vector refs = pipe->AuxillerySpine.getSubValues(); - std::string obj = data.constData(); - std::vector::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()) { + if (const auto pipe = getObject()) { std::vector refs = pipe->Sections.getValues(); App::DocumentObject* obj = pipe->getDocument()->getObject(msg.pObjectName); - std::vector::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()) { + if (const auto pipe = getObject()) { std::vector refs = pipe->Sections.getValues(); App::DocumentObject* obj = pipe->getDocument()->getObject(data.constData()); - std::vector::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(); diff --git a/src/Mod/PartDesign/Gui/TaskShapeBinder.cpp b/src/Mod/PartDesign/Gui/TaskShapeBinder.cpp index c9a285c169..1c3b570cf0 100644 --- a/src/Mod/PartDesign/Gui/TaskShapeBinder.cpp +++ b/src/Mod/PartDesign/Gui/TaskShapeBinder.cpp @@ -204,11 +204,10 @@ void TaskShapeBinder::deleteItem() PartDesign::ShapeBinder* binder = vp->getObject(); PartDesign::ShapeBinder::getFilteredReferences(&binder->Support, obj, subs); - std::string subname = data.constData(); - std::vector::iterator it = std::find(subs.begin(), subs.end(), subname); + const std::string subname = data.constData(); // if something was found, delete it and update the support - if (it != subs.end()) { + if (const auto it = std::ranges::find(subs, subname); it != subs.end()) { subs.erase(it); binder->Support.setValue(obj, subs); @@ -317,10 +316,11 @@ bool TaskShapeBinder::referenceSelected(const SelectionChanges& msg) const if (selectionMode != refObjAdd) { // ensure the new selected subref belongs to the same object - if (strcmp(msg.pObjectName, obj->getNameInDocument()) != 0) + if (strcmp(msg.pObjectName, obj->getNameInDocument()) != 0) { return false; + } - std::vector::iterator f = std::find(refs.begin(), refs.end(), subName); + const auto f = std::ranges::find(refs, subName); if (selectionMode == refAdd) { if (f == refs.end()) diff --git a/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp b/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp index 83f4e4fc25..02ec184bfe 100644 --- a/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp @@ -238,7 +238,7 @@ bool TaskTransformedParameters::originalSelected(const Gui::SelectionChanges& ms // Do the same like in TaskDlgTransformedParameters::accept() but without doCommand std::vector originals = pcTransformed->Originals.getValues(); - auto or_iter = std::find(originals.begin(), originals.end(), selectedObject); + const auto or_iter = std::ranges::find(originals, selectedObject); if (selectionMode == SelectionMode::AddFeature) { if (or_iter == originals.end()) { originals.push_back(selectedObject);