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

@@ -64,7 +64,7 @@ ViewProviderGeometryObject::ViewProviderGeometryObject()
float r, g, b;
if (randomColor){
float fMax = (float)RAND_MAX;
auto fMax = (float)RAND_MAX;
r = (float)rand()/fMax;
g = (float)rand()/fMax;
b = (float)rand()/fMax;
@@ -175,7 +175,7 @@ void ViewProviderGeometryObject::updateData(const App::Property* prop)
pcBoundingBox->maxBounds.setValue(box.MaxX, box.MaxY, box.MaxZ);
}
else if (prop->isDerivedFrom(App::PropertyPlacement::getClassTypeId())) {
App::GeoFeature* geometry = dynamic_cast<App::GeoFeature*>(getObject());
auto geometry = dynamic_cast<App::GeoFeature*>(getObject());
if (geometry && prop == &geometry->Placement) {
const App::PropertyComplexGeoData* data = geometry->getPropertyOfGeometry();
if (data) {
@@ -191,7 +191,7 @@ void ViewProviderGeometryObject::updateData(const App::Property* prop)
SoPickedPointList ViewProviderGeometryObject::getPickedPoints(const SbVec2s& pos, const View3DInventorViewer& viewer,bool pickAll) const
{
SoSeparator* root = new SoSeparator;
auto root = new SoSeparator;
root->ref();
root->addChild(viewer.getHeadlight());
root->addChild(viewer.getSoRenderManager()->getCamera());
@@ -210,7 +210,7 @@ SoPickedPointList ViewProviderGeometryObject::getPickedPoints(const SbVec2s& pos
SoPickedPoint* ViewProviderGeometryObject::getPickedPoint(const SbVec2s& pos, const View3DInventorViewer& viewer) const
{
SoSeparator* root = new SoSeparator;
auto root = new SoSeparator;
root->ref();
root->addChild(viewer.getHeadlight());
root->addChild(viewer.getSoRenderManager()->getCamera());
@@ -251,14 +251,14 @@ void ViewProviderGeometryObject::showBoundingBox(bool show)
r = ((bbcol >> 24) & 0xff) / 255.0; g = ((bbcol >> 16) & 0xff) / 255.0; b = ((bbcol >> 8) & 0xff) / 255.0;
pcBoundSwitch = new SoSwitch();
SoSeparator* pBoundingSep = new SoSeparator();
SoDrawStyle* lineStyle = new SoDrawStyle;
auto pBoundingSep = new SoSeparator();
auto lineStyle = new SoDrawStyle;
lineStyle->lineWidth = 2.0f;
pBoundingSep->addChild(lineStyle);
pcBoundColor->rgb.setValue(r, g, b);
pBoundingSep->addChild(pcBoundColor);
SoFont* font = new SoFont();
auto font = new SoFont();
font->size.setValue(getBoundBoxFontSize());
pBoundingSep->addChild(font);
@@ -288,7 +288,7 @@ void ViewProviderGeometryObject::setSelectable(bool selectable)
SoPathList & pathList = sa.getPaths();
for (int i=0;i<pathList.getLength();i++) {
SoFCSelection *selNode = dynamic_cast<SoFCSelection*>(pathList[i]->getTail());
auto selNode = dynamic_cast<SoFCSelection*>(pathList[i]->getTail());
if (selectable) {
if (selNode) {
selNode->selectionMode = SoFCSelection::SEL_ON;