Skip to content

Commit 7cd57a2

Browse files
author
tpat
committed
Added license text, const auto refs, and changed for loops to range based
1 parent 94c600e commit 7cd57a2

File tree

6 files changed

+82
-26
lines changed

6 files changed

+82
-26
lines changed

src/Graphics/Widgets/WidgetFactory.cc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
/*
2+
For more information, please see: http://software.sci.utah.edu
3+
4+
The MIT License
5+
6+
Copyright (c) 2015 Scientific Computing and Imaging Institute,
7+
University of Utah.
8+
9+
10+
Permission is hereby granted, free of charge, to any person obtaining a
11+
copy of this software and associated documentation files (the "Software"),
12+
to deal in the Software without restriction, including without limitation
13+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
14+
and/or sell copies of the Software, and to permit persons to whom the
15+
Software is furnished to do so, subject to the following conditions:
16+
17+
The above copyright notice and this permission notice shall be included
18+
in all copies or substantial portions of the Software.
19+
20+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26+
DEALINGS IN THE SOFTWARE.
27+
*/
28+
129
#include <Graphics/Widgets/WidgetFactory.h>
230

331
using namespace SCIRun;

src/Graphics/Widgets/WidgetFactory.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
/*
2+
For more information, please see: http://software.sci.utah.edu
3+
4+
The MIT License
5+
6+
Copyright (c) 2015 Scientific Computing and Imaging Institute,
7+
University of Utah.
8+
9+
10+
Permission is hereby granted, free of charge, to any person obtaining a
11+
copy of this software and associated documentation files (the "Software"),
12+
to deal in the Software without restriction, including without limitation
13+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
14+
and/or sell copies of the Software, and to permit persons to whom the
15+
Software is furnished to do so, subject to the following conditions:
16+
17+
The above copyright notice and this permission notice shall be included
18+
in all copies or substantial portions of the Software.
19+
20+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26+
DEALINGS IN THE SOFTWARE.
27+
*/
28+
129
#ifndef Graphics_Graphics_Widgets_WidgetFactory_H
230
#define Graphics_Graphics_Widgets_WidgetFactory_H
331

src/Interface/Modules/Render/ES/SRInterface.cc

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,7 @@ namespace SCIRun {
347347
//----------------------------------------------------------------------------------------------
348348

349349
//----------------------------------------------------------------------------------------------
350-
void SRInterface::select(const glm::ivec2& pos,
351-
std::vector<Graphics::Datatypes::WidgetHandle> &objList,
352-
int port)
350+
void SRInterface::select(const glm::ivec2& pos, WidgetList& objList, int port)
353351
{
354352
mSelected = "";
355353
widgetSelected_ = false;
@@ -381,18 +379,18 @@ namespace SCIRun {
381379

382380
int nameIndex = 0;
383381
//modify and add each object to draw
384-
// for (auto& obj : objList)
385-
for (int i = 0; i < objList.size(); i++)
382+
for (auto& obj : objList)
386383
{
387-
std::string objectName = objList[i]->uniqueID();
384+
// auto& obj = objList[i];
385+
std::string objectName = obj->uniqueID();
388386
uint32_t selid = getSelectIDForName(objectName);
389387
selMap.insert(std::make_pair(selid, objectName));
390388
glm::vec4 selCol = getVectorForID(selid);
391389

392390
// Add vertex buffer objects.
393391
std::vector<char*> vbo_buffer;
394392
std::vector<size_t> stride_vbo;
395-
for (auto it = objList[i]->vbos().cbegin(); it != objList[i]->vbos().cend(); ++it, ++nameIndex)
393+
for (auto it = obj->vbos().cbegin(); it != obj->vbos().cend(); ++it, ++nameIndex)
396394
{
397395
const auto& vbo = *it;
398396

@@ -417,7 +415,7 @@ namespace SCIRun {
417415

418416
// Add index buffer objects.
419417
nameIndex = 0;
420-
for (auto it = objList[i]->ibos().cbegin(); it != objList[i]->ibos().cend(); ++it, ++nameIndex)
418+
for (auto it = obj->ibos().cbegin(); it != obj->ibos().cend(); ++it, ++nameIndex)
421419
{
422420
const auto& ibo = *it;
423421
GLenum primType = GL_UNSIGNED_SHORT;
@@ -466,7 +464,7 @@ namespace SCIRun {
466464
if (auto shaderMan = sm.lock())
467465
{
468466
// Add passes
469-
for (auto& pass : objList[i]->passes())
467+
for (auto& pass : obj->passes())
470468
{
471469
uint64_t entityID = getEntityIDForName(pass.passName, port);
472470

@@ -480,7 +478,7 @@ namespace SCIRun {
480478
// We will be constructing a render list from the VBO and IBO.
481479
RenderList list;
482480

483-
for (const auto& vbo : objList[i]->vbos())
481+
for (const auto& vbo : obj->vbos())
484482
{
485483
if (vbo.name == pass.vboName)
486484
{
@@ -584,14 +582,14 @@ namespace SCIRun {
584582
{
585583
mSelected = it->second;
586584

587-
for(int i = 0; i < objList.size(); i++)
585+
for (auto &obj : objList)
588586
{
589-
if(objList[i]->uniqueID() == it->second)
587+
if (obj->uniqueID() == it->second)
590588
{
591-
mOriginWorld = objList[i]->origin_;
592-
mFlipAxisWorld = objList[i]->getFlipVector();
593-
mWidgetMovement = objList[i]->getMovementType();
594-
mConnectedWidgets = objList[i]->connectedIds_;
589+
mOriginWorld = obj->origin_;
590+
mFlipAxisWorld = obj->getFlipVector();
591+
mWidgetMovement = obj->getMovementType();
592+
mConnectedWidgets = obj->connectedIds_;
595593
}
596594
}
597595
}

src/Interface/Modules/Render/ES/SRInterface.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ namespace SCIRun {
150150

151151
//---------------- Widgets -------------------------------------------------------------------
152152
// todo Selecting objects...
153-
void select(const glm::ivec2& pos, std::vector<Graphics::Datatypes::WidgetHandle> &objList, int port);
153+
typedef std::vector<Graphics::Datatypes::WidgetHandle> WidgetList;
154+
void select(const glm::ivec2& pos, WidgetList& objList, int port);
154155
std::string &getSelection() {return mSelected;}
155156
gen::Transform &getWidgetTransform() {return mWidgetTransform;}
156157

src/Interface/Modules/Render/ViewScene.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ void ViewSceneDialog::selectObject(const int x, const int y)
12431243
std::string selName = spire->getSelection();
12441244
if (selName != "")
12451245
{
1246-
for (auto &obj : objList)
1246+
for (const auto &obj : objList)
12471247
{
12481248
if (obj->uniqueID() == selName)
12491249
{

src/Modules/Legacy/Visualization/ShowAndEditDipoles.cc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -292,15 +292,15 @@ void ShowAndEditDipoles::toggleLastVectorShown()
292292
void ShowAndEditDipoles::generateGeomsList()
293293
{
294294
auto state = get_state();
295-
// Recreate geom list
296-
geoms_.resize(0);
297295

298296
// Rewrite all existing geom
299-
for(auto arrow : arrows_)
297+
geoms_.clear();
298+
for(const auto& arrow : arrows_)
300299
{
301-
for(auto widget : arrow->widgets_)
300+
for(const auto& widget : arrow->widgets_)
302301
geoms_.push_back(widget);
303302
}
303+
304304
if(state->getValue(ShowLines).toBool())
305305
geoms_.push_back(addLines());
306306
}
@@ -335,10 +335,11 @@ void ShowAndEditDipoles::processWidgetFeedback(const ModuleFeedback& var)
335335
}
336336

337337
// Remove parantheses
338-
for(size_t i = 0; i < matches.size(); i++)
338+
for(auto& match : matches)
339339
{
340-
matches[i] = matches[i].substr(1, matches[i].length()-2);
340+
match = match.substr(1, match.length()-2);
341341
}
342+
342343
// Cast to size_t
343344
widgetType = boost::lexical_cast<size_t>(matches[0]);
344345
widgetID = boost::lexical_cast<size_t>(matches[1]);
@@ -359,9 +360,9 @@ void ShowAndEditDipoles::processWidgetFeedback(const ModuleFeedback& var)
359360

360361
void ShowAndEditDipoles::moveDipolesTogether(const Transform& transform)
361362
{
362-
for(size_t i = 0; i < pos_.size(); i++)
363+
for(auto& pos : pos_)
363364
{
364-
pos_[i] = transform * pos_[i];
365+
pos = transform * pos;
365366
}
366367
}
367368

0 commit comments

Comments
 (0)