FEM: modernize C++: use range-based for loop
This commit is contained in:
@@ -137,28 +137,26 @@ void TaskFemConstraintSpring::addToSelection()
|
||||
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
|
||||
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
|
||||
|
||||
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end();
|
||||
++it) {// for every selected object
|
||||
if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
|
||||
for (auto & it : selection) {// for every selected object
|
||||
if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
const std::vector<std::string>& subNames = it->getSubNames();
|
||||
App::DocumentObject* obj = it->getObject();
|
||||
const std::vector<std::string>& subNames = it.getSubNames();
|
||||
App::DocumentObject* obj = it.getObject();
|
||||
|
||||
for (size_t subIt = 0; subIt < (subNames.size());
|
||||
++subIt) {// for every selected sub element
|
||||
for (const auto & subName : subNames) {// for every selected sub element
|
||||
bool addMe = true;
|
||||
if (subNames[subIt].substr(0, 4) != "Face") {
|
||||
if (subName.substr(0, 4) != "Face") {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Only faces can be picked"));
|
||||
return;
|
||||
}
|
||||
for (std::vector<std::string>::iterator itr =
|
||||
std::find(SubElements.begin(), SubElements.end(), subNames[subIt]);
|
||||
std::find(SubElements.begin(), SubElements.end(), subName);
|
||||
itr != SubElements.end();
|
||||
itr = std::find(++itr,
|
||||
SubElements.end(),
|
||||
subNames[subIt])) {// for every sub element in selection that
|
||||
subName)) {// for every sub element in selection that
|
||||
// matches one in old list
|
||||
if (obj
|
||||
== Objects[std::distance(
|
||||
@@ -171,8 +169,8 @@ void TaskFemConstraintSpring::addToSelection()
|
||||
if (addMe) {
|
||||
QSignalBlocker block(ui->lw_references);
|
||||
Objects.push_back(obj);
|
||||
SubElements.push_back(subNames[subIt]);
|
||||
ui->lw_references->addItem(makeRefText(obj, subNames[subIt]));
|
||||
SubElements.push_back(subName);
|
||||
ui->lw_references->addItem(makeRefText(obj, subName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -194,23 +192,21 @@ void TaskFemConstraintSpring::removeFromSelection()
|
||||
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
|
||||
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
|
||||
std::vector<size_t> itemsToDel;
|
||||
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end();
|
||||
++it) {// for every selected object
|
||||
if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
|
||||
for (const auto & it : selection) {// for every selected object
|
||||
if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
const std::vector<std::string>& subNames = it->getSubNames();
|
||||
App::DocumentObject* obj = it->getObject();
|
||||
const std::vector<std::string>& subNames = it.getSubNames();
|
||||
const App::DocumentObject* obj = it.getObject();
|
||||
|
||||
for (size_t subIt = 0; subIt < (subNames.size());
|
||||
++subIt) {// for every selected sub element
|
||||
for (const auto & subName : subNames) {// for every selected sub element
|
||||
for (std::vector<std::string>::iterator itr =
|
||||
std::find(SubElements.begin(), SubElements.end(), subNames[subIt]);
|
||||
std::find(SubElements.begin(), SubElements.end(), subName);
|
||||
itr != SubElements.end();
|
||||
itr = std::find(++itr,
|
||||
SubElements.end(),
|
||||
subNames[subIt])) {// for every sub element in selection that
|
||||
subName)) {// for every sub element in selection that
|
||||
// matches one in old list
|
||||
if (obj
|
||||
== Objects[std::distance(
|
||||
|
||||
Reference in New Issue
Block a user