Gui: Use auto and range-based for (#7481)

* On lines where the variable type is obvious from inspection, avoid repeating the type using auto. 
* When possible use a ranged for loop instead of begin() and end() iterators
This commit is contained in:
berniev
2022-09-15 04:25:13 +10:00
committed by GitHub
parent d7792826b4
commit 75acacd1b7
175 changed files with 2051 additions and 2057 deletions

View File

@@ -175,7 +175,7 @@ void
SoAxisCrossKit::createAxes()
{
// Create the heads.
SoCone *head = new SoCone;
auto head = new SoCone;
head->bottomRadius.setValue(5);
head->height.setValue(10);
setPart("xHead.shape", head);
@@ -183,14 +183,14 @@ SoAxisCrossKit::createAxes()
setPart("zHead.shape", head);
// Create the axes.
SoCoordinate3* coords = new SoCoordinate3;
auto coords = new SoCoordinate3;
coords->point.set1Value(0, SbVec3f(0,0,0));
coords->point.set1Value(1, SbVec3f(90,0,0));
setPart("xAxis.coordinate3", coords);
setPart("yAxis.coordinate3", coords);
setPart("zAxis.coordinate3", coords);
SoLineSet *shape = new SoLineSet;
auto shape = new SoLineSet;
setPart("xAxis.shape", shape);
setPart("yAxis.shape", shape);
setPart("zAxis.shape", shape);
@@ -260,18 +260,18 @@ SoRegPoint::SoRegPoint()
root->ref();
// translation
SoTranslation* move = new SoTranslation();
auto move = new SoTranslation();
move->translation.setValue(base.getValue() + normal.getValue() * length.getValue());
root->addChild(move);
// sub-group
SoBaseColor* col = new SoBaseColor();
auto col = new SoBaseColor();
col->rgb.setValue(this->color.getValue());
SoFontStyle* font = new SoFontStyle;
auto font = new SoFontStyle;
font->size = 14;
SoSeparator* sub = new SoSeparator();
auto sub = new SoSeparator();
sub->addChild(col);
sub->addChild(font);
sub->addChild(new SoText2());
@@ -346,17 +346,17 @@ void SoRegPoint::notify(SoNotList * node)
{
SoField * f = node->getLastField();
if (f == &this->base || f == &this->normal || f == &this->length) {
SoTranslation* move = static_cast<SoTranslation*>(root->getChild(0));
auto move = static_cast<SoTranslation*>(root->getChild(0));
move->translation.setValue(base.getValue() + normal.getValue() * length.getValue());
}
else if (f == &this->color) {
SoSeparator* sub = static_cast<SoSeparator*>(root->getChild(1));
SoBaseColor* col = static_cast<SoBaseColor*>(sub->getChild(0));
auto sub = static_cast<SoSeparator*>(root->getChild(1));
auto col = static_cast<SoBaseColor*>(sub->getChild(0));
col->rgb = this->color.getValue();
}
else if (f == &this->text) {
SoSeparator* sub = static_cast<SoSeparator*>(root->getChild(1));
SoText2* label = static_cast<SoText2*>(sub->getChild(2));
auto sub = static_cast<SoSeparator*>(root->getChild(1));
auto label = static_cast<SoText2*>(sub->getChild(2));
label->string = this->text.getValue();
}