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:
@@ -60,7 +60,7 @@ ViewProvider* ViewProviderBuilder::create(const Base::Type& type)
|
||||
|
||||
Gui::SoFCSelection* ViewProviderBuilder::createSelection()
|
||||
{
|
||||
Gui::SoFCSelection* sel = new Gui::SoFCSelection();
|
||||
auto sel = new Gui::SoFCSelection();
|
||||
|
||||
float transparency;
|
||||
ParameterGrp::handle hGrp = Gui::WindowParameter::getDefaultParameter()->GetGroup("View");
|
||||
@@ -72,7 +72,7 @@ Gui::SoFCSelection* ViewProviderBuilder::createSelection()
|
||||
else {
|
||||
// Search for a user defined value with the current color as default
|
||||
SbColor highlightColor = sel->colorHighlight.getValue();
|
||||
unsigned long highlight = (unsigned long)(highlightColor.getPackedValue());
|
||||
auto highlight = (unsigned long)(highlightColor.getPackedValue());
|
||||
highlight = hGrp->GetUnsigned("HighlightColor", highlight);
|
||||
highlightColor.setPackedValue((uint32_t)highlight, transparency);
|
||||
sel->colorHighlight.setValue(highlightColor);
|
||||
@@ -83,7 +83,7 @@ Gui::SoFCSelection* ViewProviderBuilder::createSelection()
|
||||
else {
|
||||
// Do the same with the selection color
|
||||
SbColor selectionColor = sel->colorSelection.getValue();
|
||||
unsigned long selection = (unsigned long)(selectionColor.getPackedValue());
|
||||
auto selection = (unsigned long)(selectionColor.getPackedValue());
|
||||
selection = hGrp->GetUnsigned("SelectionColor", selection);
|
||||
selectionColor.setPackedValue((uint32_t)selection, transparency);
|
||||
sel->colorSelection.setValue(selectionColor);
|
||||
@@ -104,16 +104,16 @@ ViewProviderColorBuilder::~ViewProviderColorBuilder()
|
||||
|
||||
void ViewProviderColorBuilder::buildNodes(const App::Property* prop, std::vector<SoNode*>& node) const
|
||||
{
|
||||
const App::PropertyColorList* color = static_cast<const App::PropertyColorList*>(prop);
|
||||
const auto color = static_cast<const App::PropertyColorList*>(prop);
|
||||
const std::vector<App::Color>& val = color->getValues();
|
||||
unsigned long i=0;
|
||||
|
||||
SoMaterial* material = new SoMaterial();
|
||||
auto material = new SoMaterial();
|
||||
material->diffuseColor.setNum(val.size());
|
||||
|
||||
SbColor* colors = material->diffuseColor.startEditing();
|
||||
for (std::vector<App::Color>::const_iterator it = val.begin(); it != val.end(); ++it) {
|
||||
colors[i].setValue(it->r, it->g, it->b);
|
||||
for (const auto & it : val) {
|
||||
colors[i].setValue(it.r, it.g, it.b);
|
||||
i++;
|
||||
}
|
||||
material->diffuseColor.finishEditing();
|
||||
|
||||
Reference in New Issue
Block a user