PD: modernize C++: use range-based for loop
This commit is contained in:
@@ -541,8 +541,8 @@ void Body::onDocumentRestored()
|
||||
bool Body::isSolid()
|
||||
{
|
||||
std::vector<App::DocumentObject *> features = getFullModel();
|
||||
for (auto it = features.begin(); it!=features.end(); ++it){
|
||||
if (isSolidFeature((*it)))
|
||||
for (auto feature : features){
|
||||
if (isSolidFeature(feature))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -265,8 +265,8 @@ void FeatureExtrude::generateTaperedPrism(TopoDS_Shape& prism,
|
||||
TopoDS_Compound comp;
|
||||
BRep_Builder builder;
|
||||
builder.MakeCompound(comp);
|
||||
for (std::list<TopoDS_Shape>::iterator it = drafts.begin(); it != drafts.end(); ++it)
|
||||
builder.Add(comp, *it);
|
||||
for (const auto & draft : drafts)
|
||||
builder.Add(comp, draft);
|
||||
prism = comp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,8 +106,8 @@ App::DocumentObjectExecReturn *Fillet::execute()
|
||||
try {
|
||||
BRepFilletAPI_MakeFillet mkFillet(baseShape.getShape());
|
||||
|
||||
for (std::vector<std::string>::const_iterator it=SubNames.begin(); it != SubNames.end(); ++it) {
|
||||
TopoDS_Edge edge = TopoDS::Edge(baseShape.getSubShape(it->c_str()));
|
||||
for (const auto & it : SubNames) {
|
||||
TopoDS_Edge edge = TopoDS::Edge(baseShape.getSubShape(it.c_str()));
|
||||
mkFillet.Add(radius, edge);
|
||||
}
|
||||
|
||||
|
||||
@@ -954,10 +954,10 @@ double Hole::getThreadClassClearance() const
|
||||
|
||||
// Calculate how much clearance to add based on Thread tolerance class and pitch
|
||||
if (ThreadClass.getValueAsString()[1] == 'G') {
|
||||
for (unsigned int i = 0; i < ThreadClass_ISOmetric_data_size; i++) {
|
||||
double p = ThreadClass_ISOmetric_data[i][0];
|
||||
for (auto it : ThreadClass_ISOmetric_data) {
|
||||
double p = it[0];
|
||||
if (pitch <= p) {
|
||||
return ThreadClass_ISOmetric_data[i][1];
|
||||
return it[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -988,10 +988,10 @@ double Hole::getThreadRunout(int mode) const
|
||||
default:
|
||||
throw Base::ValueError("Unsupported argument");
|
||||
}
|
||||
for (unsigned int i = 0; i < ThreadRunout_size; i++) {
|
||||
double p = ThreadRunout[i][0];
|
||||
for (auto it : ThreadRunout) {
|
||||
double p = it[0];
|
||||
if (pitch <= p) {
|
||||
return sf * ThreadRunout[i][1];
|
||||
return sf * it[1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,11 +50,10 @@ void MultiTransform::positionBySupport()
|
||||
{
|
||||
PartDesign::Transformed::positionBySupport();
|
||||
std::vector<App::DocumentObject*> transFeatures = Transformations.getValues();
|
||||
for (std::vector<App::DocumentObject*>::const_iterator f = transFeatures.begin();
|
||||
f != transFeatures.end(); ++f) {
|
||||
if (!((*f)->getTypeId().isDerivedFrom(PartDesign::Transformed::getClassTypeId())))
|
||||
for (auto f : transFeatures) {
|
||||
if (!(f->getTypeId().isDerivedFrom(PartDesign::Transformed::getClassTypeId())))
|
||||
throw Base::TypeError("Transformation features must be subclasses of Transformed");
|
||||
PartDesign::Transformed* transFeature = static_cast<PartDesign::Transformed*>(*f);
|
||||
PartDesign::Transformed* transFeature = static_cast<PartDesign::Transformed*>(f);
|
||||
transFeature->Placement.setValue(this->Placement.getValue());
|
||||
|
||||
// To avoid that a linked transform feature stays touched after a recompute
|
||||
|
||||
@@ -536,10 +536,8 @@ void Pipe::buildPipePath(const Part::TopoShape& shape, const std::vector<std::st
|
||||
//getContinuousEdges(shape, subedge);
|
||||
|
||||
BRepBuilderAPI_MakeWire mkWire;
|
||||
for (std::vector<std::string>::const_iterator it = subedge.begin();
|
||||
it != subedge.end();
|
||||
++it) {
|
||||
TopoDS_Shape subshape = shape.getSubShape(it->c_str());
|
||||
for (const auto & it : subedge) {
|
||||
TopoDS_Shape subshape = shape.getSubShape(it.c_str());
|
||||
mkWire.Add(TopoDS::Edge(subshape));
|
||||
}
|
||||
path = mkWire.Wire();
|
||||
|
||||
@@ -749,49 +749,49 @@ void ProfileBased::remapSupportShape(const TopoDS_Shape & newShape)
|
||||
shape.setShape(sh);
|
||||
|
||||
std::vector<App::DocumentObject*> refs = this->getInList();
|
||||
for (std::vector<App::DocumentObject*>::iterator it = refs.begin(); it != refs.end(); ++it) {
|
||||
for (auto ref : refs) {
|
||||
std::vector<App::Property*> props;
|
||||
(*it)->getPropertyList(props);
|
||||
for (std::vector<App::Property*>::iterator jt = props.begin(); jt != props.end(); ++jt) {
|
||||
if (!(*jt)->isDerivedFrom(App::PropertyLinkSub::getClassTypeId()))
|
||||
ref->getPropertyList(props);
|
||||
for (auto prop : props) {
|
||||
if (!prop->isDerivedFrom(App::PropertyLinkSub::getClassTypeId()))
|
||||
continue;
|
||||
App::PropertyLinkSub* link = static_cast<App::PropertyLinkSub*>(*jt);
|
||||
App::PropertyLinkSub* link = static_cast<App::PropertyLinkSub*>(prop);
|
||||
if (link->getValue() != this)
|
||||
continue;
|
||||
std::vector<std::string> subValues = link->getSubValues();
|
||||
std::vector<std::string> newSubValues;
|
||||
|
||||
for (std::vector<std::string>::iterator it = subValues.begin(); it != subValues.end(); ++it) {
|
||||
for (auto & subValue : subValues) {
|
||||
std::string shapetype;
|
||||
if (it->compare(0, 4, "Face") == 0) {
|
||||
if (subValue.compare(0, 4, "Face") == 0) {
|
||||
shapetype = "Face";
|
||||
}
|
||||
else if (it->compare(0, 4, "Edge") == 0) {
|
||||
else if (subValue.compare(0, 4, "Edge") == 0) {
|
||||
shapetype = "Edge";
|
||||
}
|
||||
else if (it->compare(0, 6, "Vertex") == 0) {
|
||||
else if (subValue.compare(0, 6, "Vertex") == 0) {
|
||||
shapetype = "Vertex";
|
||||
}
|
||||
else {
|
||||
newSubValues.push_back(*it);
|
||||
newSubValues.push_back(subValue);
|
||||
continue;
|
||||
}
|
||||
|
||||
bool success = false;
|
||||
TopoDS_Shape element;
|
||||
try {
|
||||
element = shape.getSubShape(it->c_str());
|
||||
element = shape.getSubShape(subValue.c_str());
|
||||
}
|
||||
catch (Standard_Failure&) {
|
||||
// This shape doesn't even exist, so no chance to do some tests
|
||||
newSubValues.push_back(*it);
|
||||
newSubValues.push_back(subValue);
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
// as very first test check if old face and new face are parallel planes
|
||||
TopoDS_Shape newElement = Part::TopoShape(newShape).getSubShape(it->c_str());
|
||||
TopoDS_Shape newElement = Part::TopoShape(newShape).getSubShape(subValue.c_str());
|
||||
if (isParallelPlane(element, newElement)) {
|
||||
newSubValues.push_back(*it);
|
||||
newSubValues.push_back(subValue);
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
@@ -824,7 +824,7 @@ void ProfileBased::remapSupportShape(const TopoDS_Shape & newShape)
|
||||
|
||||
// the new shape couldn't be found so keep the old sub-name
|
||||
if (!success)
|
||||
newSubValues.push_back(*it);
|
||||
newSubValues.push_back(subValue);
|
||||
}
|
||||
|
||||
link->setValue(this, newSubValues);
|
||||
|
||||
@@ -88,8 +88,8 @@ App::DocumentObjectExecReturn *Thickness::execute()
|
||||
|
||||
TopTools_ListOfShape closingFaces;
|
||||
|
||||
for (std::vector<std::string>::const_iterator it = subStrings.begin(); it != subStrings.end(); ++it) {
|
||||
TopoDS_Face face = TopoDS::Face(TopShape.getSubShape(it->c_str()));
|
||||
for (const auto & it : subStrings) {
|
||||
TopoDS_Face face = TopoDS::Face(TopShape.getSubShape(it.c_str()));
|
||||
closingFaces.Append(face);
|
||||
}
|
||||
|
||||
|
||||
@@ -248,14 +248,14 @@ App::DocumentObjectExecReturn *Transformed::execute()
|
||||
// Original separately. This way it is easier to discover what feature causes a fuse/cut
|
||||
// to fail. The downside is that performance suffers when there are many originals. But it seems
|
||||
// safe to assume that in most cases there are few originals and many transformations
|
||||
for (std::vector<App::DocumentObject*>::const_iterator o = originals.begin(); o != originals.end(); ++o)
|
||||
for (auto original : originals)
|
||||
{
|
||||
// Extract the original shape and determine whether to cut or to fuse
|
||||
Part::TopoShape fuseShape;
|
||||
Part::TopoShape cutShape;
|
||||
|
||||
if ((*o)->getTypeId().isDerivedFrom(PartDesign::FeatureAddSub::getClassTypeId())) {
|
||||
PartDesign::FeatureAddSub* feature = static_cast<PartDesign::FeatureAddSub*>(*o);
|
||||
if (original->getTypeId().isDerivedFrom(PartDesign::FeatureAddSub::getClassTypeId())) {
|
||||
PartDesign::FeatureAddSub* feature = static_cast<PartDesign::FeatureAddSub*>(original);
|
||||
feature->getAddSubShape(fuseShape, cutShape);
|
||||
if (fuseShape.isNull() && cutShape.isNull())
|
||||
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Shape of additive/subtractive feature is empty"));
|
||||
|
||||
@@ -802,8 +802,8 @@ void prepareProfileBased(PartDesign::Body *pcActiveBody, Gui::Command* cmd, cons
|
||||
std::vector<Gui::SelectionObject> selection = cmd->getSelection().getSelectionEx();
|
||||
if (!selection.empty()) {
|
||||
bool onlyAllowed = true;
|
||||
for (auto it = selection.begin(); it!=selection.end(); ++it){
|
||||
if (PartDesign::Body::findBodyOf((*it).getObject()) != pcActiveBody) { // the selected objects must belong to the body
|
||||
for (const auto & it : selection) {
|
||||
if (PartDesign::Body::findBodyOf(it.getObject()) != pcActiveBody) { // the selected objects must belong to the body
|
||||
onlyAllowed = false;
|
||||
break;
|
||||
}
|
||||
@@ -1633,8 +1633,8 @@ void finishDressupFeature(const Gui::Command* cmd, const std::string& which,
|
||||
{
|
||||
std::ostringstream str;
|
||||
str << '(' << Gui::Command::getObjectCmd(base) << ",[";
|
||||
for (std::vector<std::string>::const_iterator it = SubNames.begin();it!=SubNames.end();++it){
|
||||
str << "'" << *it << "',";
|
||||
for (const auto & SubName : SubNames){
|
||||
str << "'" << SubName << "',";
|
||||
}
|
||||
str << "])";
|
||||
|
||||
@@ -1887,8 +1887,8 @@ void prepareTransformed(PartDesign::Body *pcActiveBody, Gui::Command* cmd, const
|
||||
auto worker = [=](std::vector<App::DocumentObject*> features) {
|
||||
std::stringstream str;
|
||||
str << cmd->getObjectCmd(FeatName.c_str(), pcActiveBody->getDocument()) << ".Originals = [";
|
||||
for (std::vector<App::DocumentObject*>::iterator it = features.begin(); it != features.end(); ++it) {
|
||||
str << cmd->getObjectCmd(*it) << ",";
|
||||
for (auto feature : features) {
|
||||
str << cmd->getObjectCmd(feature) << ",";
|
||||
}
|
||||
str << "]";
|
||||
|
||||
@@ -1952,8 +1952,8 @@ void prepareTransformed(PartDesign::Body *pcActiveBody, Gui::Command* cmd, const
|
||||
}
|
||||
|
||||
PartDesign::Body* activeBody = PartDesignGui::getBody(true);
|
||||
for (std::size_t i = 0; i < features.size(); i++) {
|
||||
if (activeBody != PartDesignGui::getBodyFor(features[i], false)) {
|
||||
for (auto feature : features) {
|
||||
if (activeBody != PartDesignGui::getBodyFor(feature, false)) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection is not in Active Body"),
|
||||
QObject::tr("Please select only one feature in an active body."));
|
||||
return;
|
||||
@@ -2368,11 +2368,10 @@ void CmdPartDesignBoolean::activated(int iMsg)
|
||||
bool updateDocument = false;
|
||||
if (BodyFilter.match() && !BodyFilter.Result.empty()) {
|
||||
std::vector<App::DocumentObject*> bodies;
|
||||
std::vector<std::vector<Gui::SelectionObject> >::iterator i = BodyFilter.Result.begin();
|
||||
for (; i != BodyFilter.Result.end(); i++) {
|
||||
for (std::vector<Gui::SelectionObject>::iterator j = i->begin(); j != i->end(); j++) {
|
||||
if (j->getObject() != pcActiveBody)
|
||||
bodies.push_back(j->getObject());
|
||||
for (auto& results : BodyFilter.Result) {
|
||||
for (auto & result : results) {
|
||||
if (result.getObject() != pcActiveBody)
|
||||
bodies.push_back(result.getObject());
|
||||
}
|
||||
}
|
||||
if (!bodies.empty()) {
|
||||
|
||||
@@ -386,8 +386,8 @@ std::string buildLinkListPythonStr(const std::vector<App::DocumentObject*> & obj
|
||||
|
||||
std::string result("[");
|
||||
|
||||
for (std::vector<App::DocumentObject*>::const_iterator o = objs.begin(); o != objs.end(); o++)
|
||||
result += Gui::Command::getObjectCmd(*o,nullptr,",");
|
||||
for (auto obj : objs)
|
||||
result += Gui::Command::getObjectCmd(obj,nullptr,",");
|
||||
result += "]";
|
||||
|
||||
return result;
|
||||
|
||||
@@ -71,10 +71,10 @@ TaskBooleanParameters::TaskBooleanParameters(ViewProviderBoolean *BooleanView,QW
|
||||
|
||||
PartDesign::Boolean* pcBoolean = static_cast<PartDesign::Boolean*>(BooleanView->getObject());
|
||||
std::vector<App::DocumentObject*> bodies = pcBoolean->Group.getValues();
|
||||
for (std::vector<App::DocumentObject*>::const_iterator it = bodies.begin(); it != bodies.end(); ++it) {
|
||||
for (auto body : bodies) {
|
||||
QListWidgetItem* item = new QListWidgetItem(ui->listWidgetBodies);
|
||||
item->setText(QString::fromUtf8((*it)->Label.getValue()));
|
||||
item->setData(Qt::UserRole, QString::fromLatin1((*it)->getNameInDocument()));
|
||||
item->setText(QString::fromUtf8(body->Label.getValue()));
|
||||
item->setData(Qt::UserRole, QString::fromLatin1(body->getNameInDocument()));
|
||||
}
|
||||
|
||||
// Create context menu
|
||||
@@ -355,8 +355,9 @@ bool TaskDlgBooleanParameters::accept()
|
||||
}
|
||||
std::stringstream str;
|
||||
str << Gui::Command::getObjectCmd(obj) << ".setObjects( [";
|
||||
for (std::vector<std::string>::const_iterator it = bodies.begin(); it != bodies.end(); ++it)
|
||||
str << "App.getDocument('" << obj->getDocument()->getName() << "').getObject('" << *it << "'),";
|
||||
for (const auto & body : bodies) {
|
||||
str << "App.getDocument('" << obj->getDocument()->getName() << "').getObject('" << body << "'),";
|
||||
}
|
||||
str << "])";
|
||||
Gui::Command::runCommand(Gui::Command::Doc,str.str().c_str());
|
||||
}
|
||||
@@ -382,8 +383,9 @@ bool TaskDlgBooleanParameters::reject()
|
||||
if (obj->BaseFeature.getValue()) {
|
||||
doc->setShow(obj->BaseFeature.getValue()->getNameInDocument());
|
||||
std::vector<App::DocumentObject*> bodies = obj->Group.getValues();
|
||||
for (std::vector<App::DocumentObject*>::const_iterator b = bodies.begin(); b != bodies.end(); b++)
|
||||
doc->setShow((*b)->getNameInDocument());
|
||||
for (auto body : bodies) {
|
||||
doc->setShow(body->getNameInDocument());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,9 +67,8 @@ TaskChamferParameters::TaskChamferParameters(ViewProviderDressUp *DressUpView, Q
|
||||
QMetaObject::invokeMethod(ui->chamferSize, "setFocus", Qt::QueuedConnection);
|
||||
|
||||
std::vector<std::string> strings = pcChamfer->Base.getSubValues();
|
||||
for (std::vector<std::string>::const_iterator i = strings.begin(); i != strings.end(); i++)
|
||||
{
|
||||
ui->listWidgetReferences->addItem(QString::fromStdString(*i));
|
||||
for (const auto & string : strings) {
|
||||
ui->listWidgetReferences->addItem(QString::fromStdString(string));
|
||||
}
|
||||
|
||||
QMetaObject::connectSlotsByName(this);
|
||||
|
||||
@@ -74,9 +74,8 @@ TaskDraftParameters::TaskDraftParameters(ViewProviderDressUp *DressUpView, QWidg
|
||||
ui->checkReverse->setChecked(r);
|
||||
|
||||
std::vector<std::string> strings = pcDraft->Base.getSubValues();
|
||||
for (std::vector<std::string>::const_iterator i = strings.begin(); i != strings.end(); ++i)
|
||||
{
|
||||
ui->listWidgetReferences->addItem(QString::fromStdString(*i));
|
||||
for (const auto & string : strings) {
|
||||
ui->listWidgetReferences->addItem(QString::fromStdString(string));
|
||||
}
|
||||
|
||||
QMetaObject::connectSlotsByName(this);
|
||||
|
||||
@@ -155,8 +155,8 @@ void TaskDressUpParameters::addAllEdges(QListWidget* widget)
|
||||
QSignalBlocker block(widget);
|
||||
widget->clear();
|
||||
|
||||
for (std::vector<std::string>::const_iterator it = edgeNames.begin(); it != edgeNames.end(); ++it){
|
||||
widget->addItem(QLatin1String(it->c_str()));
|
||||
for (const auto & it : edgeNames){
|
||||
widget->addItem(QLatin1String(it.c_str()));
|
||||
}
|
||||
|
||||
updateFeature(pcDressUp, edgeNames);
|
||||
@@ -328,8 +328,8 @@ void TaskDressUpParameters::removeItemFromListWidget(QListWidget* widget, const
|
||||
{
|
||||
QList<QListWidgetItem*> items = widget->findItems(QString::fromLatin1(itemstr), Qt::MatchExactly);
|
||||
if (!items.empty()) {
|
||||
for (QList<QListWidgetItem*>::const_iterator i = items.cbegin(); i != items.cend(); i++) {
|
||||
QListWidgetItem* it = widget->takeItem(widget->row(*i));
|
||||
for (auto item : items) {
|
||||
QListWidgetItem* it = widget->takeItem(widget->row(item));
|
||||
delete it;
|
||||
}
|
||||
}
|
||||
@@ -425,8 +425,8 @@ bool TaskDlgDressUpParameters::accept()
|
||||
std::stringstream str;
|
||||
str << Gui::Command::getObjectCmd(vp->getObject()) << ".Base = ("
|
||||
<< Gui::Command::getObjectCmd(parameter->getBase()) << ",[";
|
||||
for (std::vector<std::string>::const_iterator it = refs.begin(); it != refs.end(); ++it)
|
||||
str << "\"" << *it << "\",";
|
||||
for (const auto & ref : refs)
|
||||
str << "\"" << ref << "\",";
|
||||
str << "])";
|
||||
Gui::Command::runCommand(Gui::Command::Doc,str.str().c_str());
|
||||
return TaskDlgFeatureParameters::accept();
|
||||
|
||||
@@ -170,10 +170,10 @@ void TaskFeaturePick::updateList()
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
for (std::vector<featureStatus>::const_iterator st = statuses.begin(); st != statuses.end(); st++) {
|
||||
for (auto status : statuses) {
|
||||
QListWidgetItem* item = ui->listWidget->item(index);
|
||||
|
||||
switch (*st) {
|
||||
switch (status) {
|
||||
case validFeature: item->setHidden(false); break;
|
||||
case invalidShape: item->setHidden(true); break;
|
||||
case isUsed: item->setHidden(!ui->checkUsed->isChecked()); break;
|
||||
@@ -218,8 +218,11 @@ std::vector<App::DocumentObject*> TaskFeaturePick::getFeatures()
|
||||
|
||||
std::vector<App::DocumentObject*> result;
|
||||
|
||||
for (std::vector<QString>::const_iterator s = features.begin(); s != features.end(); ++s)
|
||||
result.push_back(App::GetApplication().getDocument(documentName.c_str())->getObject(s->toLatin1().data()));
|
||||
for (const auto& feature : features) {
|
||||
result.push_back(App::GetApplication()
|
||||
.getDocument(documentName.c_str())
|
||||
->getObject(feature.toLatin1().data()));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -235,7 +238,7 @@ std::vector<App::DocumentObject*> TaskFeaturePick::buildFeatures()
|
||||
|
||||
auto activePart = PartDesignGui::getPartFor(activeBody, false);
|
||||
|
||||
for (std::vector<featureStatus>::const_iterator st = statuses.begin(); st != statuses.end(); st++) {
|
||||
for (auto status : statuses) {
|
||||
QListWidgetItem* item = ui->listWidget->item(index);
|
||||
|
||||
if (item->isSelected() && !item->isHidden()) {
|
||||
@@ -243,21 +246,21 @@ std::vector<App::DocumentObject*> TaskFeaturePick::buildFeatures()
|
||||
auto obj = App::GetApplication().getDocument(documentName.c_str())->getObject(t.toLatin1().data());
|
||||
|
||||
//build the dependent copy or reference if wanted by the user
|
||||
if (*st == otherBody || *st == otherPart || *st == notInBody) {
|
||||
if (status == otherBody || status == otherPart || status == notInBody) {
|
||||
if (!ui->radioXRef->isChecked()) {
|
||||
auto copy = makeCopy(obj, "", ui->radioIndependent->isChecked());
|
||||
|
||||
if (*st == otherBody) {
|
||||
if (status == otherBody) {
|
||||
activeBody->addObject(copy);
|
||||
}
|
||||
else if (*st == otherPart) {
|
||||
else if (status == otherPart) {
|
||||
auto oBody = PartDesignGui::getBodyFor(obj, false);
|
||||
if (!oBody)
|
||||
activePart->addObject(copy);
|
||||
else
|
||||
activeBody->addObject(copy);
|
||||
}
|
||||
else if (*st == notInBody) {
|
||||
else if (status == notInBody) {
|
||||
activeBody->addObject(copy);
|
||||
// doesn't supposed to get here anything but sketch but to be on the safe side better to check
|
||||
if (copy->getTypeId().isDerivedFrom(Sketcher::SketchObject::getClassTypeId())) {
|
||||
|
||||
@@ -68,9 +68,8 @@ TaskFilletParameters::TaskFilletParameters(ViewProviderDressUp *DressUpView, QWi
|
||||
ui->filletRadius->bind(pcFillet->Radius);
|
||||
QMetaObject::invokeMethod(ui->filletRadius, "setFocus", Qt::QueuedConnection);
|
||||
std::vector<std::string> strings = pcFillet->Base.getSubValues();
|
||||
for (std::vector<std::string>::const_iterator i = strings.begin(); i != strings.end(); i++)
|
||||
{
|
||||
ui->listWidgetReferences->addItem(QString::fromStdString(*i));
|
||||
for (const auto & string : strings) {
|
||||
ui->listWidgetReferences->addItem(QString::fromStdString(string));
|
||||
}
|
||||
|
||||
QMetaObject::connectSlotsByName(this);
|
||||
|
||||
@@ -142,8 +142,7 @@ void TaskLinearPatternParameters::setupUI()
|
||||
std::vector<App::DocumentObject*> originals = pcLinearPattern->Originals.getValues();
|
||||
|
||||
// Fill data into dialog elements
|
||||
for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); ++i) {
|
||||
const App::DocumentObject* obj = *i;
|
||||
for (auto obj : originals) {
|
||||
if (obj) {
|
||||
QListWidgetItem* item = new QListWidgetItem();
|
||||
item->setText(QString::fromUtf8(obj->Label.getValue()));
|
||||
|
||||
@@ -226,8 +226,8 @@ void TaskLoftParameters::removeFromListWidget(QListWidget* widget, QString name)
|
||||
|
||||
QList<QListWidgetItem*> items = widget->findItems(name, Qt::MatchExactly);
|
||||
if (!items.empty()) {
|
||||
for (QList<QListWidgetItem*>::const_iterator it = items.cbegin(); it != items.cend(); ++it) {
|
||||
QListWidgetItem* item = widget->takeItem(widget->row(*it));
|
||||
for (auto it : items) {
|
||||
QListWidgetItem* item = widget->takeItem(widget->row(it));
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,8 +120,7 @@ void TaskMirroredParameters::setupUI()
|
||||
std::vector<App::DocumentObject*> originals = pcMirrored->Originals.getValues();
|
||||
|
||||
// Fill data into dialog elements
|
||||
for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); ++i) {
|
||||
const App::DocumentObject* obj = *i;
|
||||
for (auto obj : originals) {
|
||||
if (obj) {
|
||||
QListWidgetItem* item = new QListWidgetItem();
|
||||
item->setText(QString::fromUtf8(obj->Label.getValue()));
|
||||
|
||||
@@ -132,10 +132,10 @@ TaskMultiTransformParameters::TaskMultiTransformParameters(ViewProviderTransform
|
||||
// Fill data into dialog elements
|
||||
ui->listTransformFeatures->setEnabled(true);
|
||||
ui->listTransformFeatures->clear();
|
||||
for (std::vector<App::DocumentObject*>::const_iterator i = transformFeatures.begin(); i != transformFeatures.end(); i++)
|
||||
{
|
||||
if (*i)
|
||||
ui->listTransformFeatures->addItem(QString::fromUtf8((*i)->Label.getValue()));
|
||||
for (auto it : transformFeatures) {
|
||||
if (it) {
|
||||
ui->listTransformFeatures->addItem(QString::fromUtf8(it->Label.getValue()));
|
||||
}
|
||||
}
|
||||
if (!transformFeatures.empty()) {
|
||||
ui->listTransformFeatures->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
|
||||
@@ -149,8 +149,7 @@ TaskMultiTransformParameters::TaskMultiTransformParameters(ViewProviderTransform
|
||||
std::vector<App::DocumentObject*> originals = pcMultiTransform->Originals.getValues();
|
||||
|
||||
// Fill data into dialog elements
|
||||
for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); i++) {
|
||||
const App::DocumentObject* obj = *i;
|
||||
for (auto obj : originals) {
|
||||
if (obj) {
|
||||
QListWidgetItem* item = new QListWidgetItem();
|
||||
item->setText(QString::fromUtf8(obj->Label.getValue()));
|
||||
@@ -561,10 +560,10 @@ bool TaskDlgMultiTransformParameters::accept()
|
||||
std::vector<App::DocumentObject*> transformFeatures = mtParameter->getTransformFeatures();
|
||||
std::stringstream str;
|
||||
str << Gui::Command::getObjectCmd(vp->getObject()) << ".Transformations = [";
|
||||
for (std::vector<App::DocumentObject*>::const_iterator it = transformFeatures.begin(); it != transformFeatures.end(); it++)
|
||||
{
|
||||
if (*it)
|
||||
str << Gui::Command::getObjectCmd(*it) << ",";
|
||||
for (auto it : transformFeatures) {
|
||||
if (it) {
|
||||
str << Gui::Command::getObjectCmd(it) << ",";
|
||||
}
|
||||
}
|
||||
str << "]";
|
||||
Gui::Command::runCommand(Gui::Command::Doc,str.str().c_str());
|
||||
|
||||
@@ -121,8 +121,8 @@ TaskPipeParameters::TaskPipeParameters(ViewProviderPipe *PipeView, bool /*newObj
|
||||
}
|
||||
// the spine edges
|
||||
std::vector<std::string> strings = pipe->Spine.getSubValues();
|
||||
for (std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); ++it) {
|
||||
QString label = QString::fromStdString(*it);
|
||||
for (const auto & string : strings) {
|
||||
QString label = QString::fromStdString(string);
|
||||
QListWidgetItem* item = new QListWidgetItem();
|
||||
item->setText(label);
|
||||
item->setData(Qt::UserRole, QByteArray(label.toUtf8()));
|
||||
@@ -255,8 +255,8 @@ void TaskPipeParameters::removeFromListWidget(QListWidget* widget, QString items
|
||||
{
|
||||
QList<QListWidgetItem*> items = widget->findItems(itemstr, Qt::MatchExactly);
|
||||
if (!items.empty()) {
|
||||
for (QList<QListWidgetItem*>::const_iterator i = items.cbegin(); i != items.cend(); i++) {
|
||||
QListWidgetItem* it = widget->takeItem(widget->row(*i));
|
||||
for (auto item : items) {
|
||||
QListWidgetItem* it = widget->takeItem(widget->row(item));
|
||||
delete it;
|
||||
}
|
||||
}
|
||||
@@ -577,8 +577,8 @@ TaskPipeOrientation::TaskPipeOrientation(ViewProviderPipe* PipeView, bool /*newO
|
||||
ui->profileBaseEdit->setText(QString::fromUtf8(pipe->AuxillerySpine.getValue()->Label.getValue()));
|
||||
|
||||
std::vector<std::string> strings = pipe->AuxillerySpine.getSubValues();
|
||||
for (std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); ++it) {
|
||||
QString label = QString::fromStdString(*it);
|
||||
for (const auto & string : strings) {
|
||||
QString label = QString::fromStdString(string);
|
||||
QListWidgetItem* item = new QListWidgetItem();
|
||||
item->setText(label);
|
||||
item->setData(Qt::UserRole, QByteArray(label.toUtf8()));
|
||||
@@ -751,8 +751,8 @@ void TaskPipeOrientation::removeFromListWidget(QListWidget* widget, QString name
|
||||
{
|
||||
QList<QListWidgetItem*> items = widget->findItems(name, Qt::MatchExactly);
|
||||
if (!items.empty()) {
|
||||
for (QList<QListWidgetItem*>::const_iterator i = items.cbegin(); i != items.cend(); i++) {
|
||||
QListWidgetItem* it = widget->takeItem(widget->row(*i));
|
||||
for (auto item : items) {
|
||||
QListWidgetItem* it = widget->takeItem(widget->row(item));
|
||||
delete it;
|
||||
}
|
||||
}
|
||||
@@ -980,8 +980,8 @@ void TaskPipeScaling::removeFromListWidget(QListWidget* widget, QString name)
|
||||
{
|
||||
QList<QListWidgetItem*> items = widget->findItems(name, Qt::MatchExactly);
|
||||
if (!items.empty()) {
|
||||
for (QList<QListWidgetItem*>::const_iterator i = items.cbegin(); i != items.cend(); i++) {
|
||||
QListWidgetItem* it = widget->takeItem(widget->row(*i));
|
||||
for (auto item : items) {
|
||||
QListWidgetItem* it = widget->takeItem(widget->row(item));
|
||||
delete it;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,8 +148,7 @@ void TaskPolarPatternParameters::setupUI()
|
||||
std::vector<App::DocumentObject*> originals = pcPolarPattern->Originals.getValues();
|
||||
|
||||
// Fill data into dialog elements
|
||||
for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); ++i) {
|
||||
const App::DocumentObject* obj = *i;
|
||||
for (auto obj : originals) {
|
||||
if (obj) {
|
||||
QListWidgetItem* item = new QListWidgetItem();
|
||||
item->setText(QString::fromUtf8(obj->Label.getValue()));
|
||||
|
||||
@@ -111,8 +111,7 @@ void TaskScaledParameters::setupUI()
|
||||
std::vector<App::DocumentObject*> originals = pcScaled->Originals.getValues();
|
||||
|
||||
// Fill data into dialog elements
|
||||
for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); ++i) {
|
||||
const App::DocumentObject* obj = *i;
|
||||
for (auto obj : originals) {
|
||||
if (obj) {
|
||||
QListWidgetItem* item = new QListWidgetItem();
|
||||
item->setText(QString::fromUtf8(obj->Label.getValue()));
|
||||
|
||||
@@ -222,8 +222,8 @@ void TaskShapeBinder::removeFromListWidget(QListWidget* widget, QString itemstr)
|
||||
{
|
||||
QList<QListWidgetItem*> items = widget->findItems(itemstr, Qt::MatchExactly);
|
||||
if (!items.empty()) {
|
||||
for (QList<QListWidgetItem*>::const_iterator i = items.cbegin(); i != items.cend(); i++) {
|
||||
QListWidgetItem* it = widget->takeItem(widget->row(*i));
|
||||
for (auto item : items) {
|
||||
QListWidgetItem* it = widget->takeItem(widget->row(item));
|
||||
delete it;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,9 +194,9 @@ QVariant TaskSketchBasedParameters::objectNameByLabel(const QString& label,
|
||||
// go through all objects and check the labels
|
||||
std::string name = label.toUtf8().data();
|
||||
std::vector<App::DocumentObject*> objs = doc->getObjects();
|
||||
for (std::vector<App::DocumentObject*>::iterator it = objs.begin(); it != objs.end(); ++it) {
|
||||
if (name == (*it)->Label.getValue()) {
|
||||
return QVariant(QByteArray((*it)->getNameInDocument()));
|
||||
for (auto obj : objs) {
|
||||
if (name == obj->Label.getValue()) {
|
||||
return QVariant(QByteArray(obj->getNameInDocument()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,9 +73,9 @@ TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpVie
|
||||
ui->checkIntersection->setChecked(i);
|
||||
|
||||
std::vector<std::string> strings = pcThickness->Base.getSubValues();
|
||||
for (std::vector<std::string>::const_iterator i = strings.begin(); i != strings.end(); i++)
|
||||
for (const auto & string : strings)
|
||||
{
|
||||
ui->listWidgetReferences->addItem(QString::fromStdString(*i));
|
||||
ui->listWidgetReferences->addItem(QString::fromStdString(string));
|
||||
}
|
||||
|
||||
QMetaObject::connectSlotsByName(this);
|
||||
|
||||
@@ -233,8 +233,8 @@ void TaskTransformedParameters::removeItemFromListWidget(QListWidget* widget, co
|
||||
{
|
||||
QList<QListWidgetItem*> items = widget->findItems(itemstr, Qt::MatchExactly);
|
||||
if (!items.empty()) {
|
||||
for (QList<QListWidgetItem*>::const_iterator i = items.cbegin(); i != items.cend(); i++) {
|
||||
QListWidgetItem* it = widget->takeItem(widget->row(*i));
|
||||
for (auto item : items) {
|
||||
QListWidgetItem* it = widget->takeItem(widget->row(item));
|
||||
delete it;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,9 +113,10 @@ bool ViewProviderBoolean::onDelete(const std::vector<std::string> &s)
|
||||
|
||||
// if abort command deleted the object the bodies are visible again
|
||||
std::vector<App::DocumentObject*> bodies = pcBoolean->Group.getValues();
|
||||
for (std::vector<App::DocumentObject*>::const_iterator b = bodies.begin(); b != bodies.end(); b++) {
|
||||
if (*b && Gui::Application::Instance->getViewProvider(*b))
|
||||
Gui::Application::Instance->getViewProvider(*b)->show();
|
||||
for (auto body : bodies) {
|
||||
if (auto vp = Gui::Application::Instance->getViewProvider(body)) {
|
||||
vp->show();
|
||||
}
|
||||
}
|
||||
|
||||
return ViewProvider::onDelete(s);
|
||||
|
||||
@@ -65,12 +65,12 @@ bool ViewProviderMultiTransform::onDelete(const std::vector<std::string> &svec)
|
||||
std::vector<App::DocumentObject*> transformFeatures = pcMultiTransform->Transformations.getValues();
|
||||
|
||||
// if the multitransform object was deleted the transformed features must be deleted, too
|
||||
for (std::vector<App::DocumentObject*>::const_iterator it = transformFeatures.begin(); it != transformFeatures.end(); ++it)
|
||||
{
|
||||
if (*it)
|
||||
for (auto it : transformFeatures) {
|
||||
if (it) {
|
||||
Gui::Command::doCommand(
|
||||
Gui::Command::Doc,"App.getDocument('%s').removeObject(\"%s\")", \
|
||||
(*it)->getDocument()->getName(), (*it)->getNameInDocument());
|
||||
it->getDocument()->getName(), it->getNameInDocument());
|
||||
}
|
||||
}
|
||||
|
||||
// Handle Originals
|
||||
|
||||
Reference in New Issue
Block a user