Commit 1f4efa82 authored by Jan Möbius's avatar Jan Möbius

Use ranges for Object Iteration to simplify code

parent 37613b3e
......@@ -383,14 +383,13 @@ void MovePlugin::slotMouseWheelEvent(QWheelEvent * _event, const std::string & /
manip_size_modifier_ = 0.0;
// Resize all manipulators based on the modifier on all objects
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it)
for (auto* o_it : PluginFunctions::objects(PluginFunctions::ALL_OBJECTS) )
o_it->manipulatorNode()->set_size(manip_size_ * manip_size_modifier_);
// Redraw scene with updated manipulators
emit updateView();
}
//------------------------------------------------------------------------------
/** \brief MousePress event occured
......@@ -414,8 +413,7 @@ void MovePlugin::slotMouseEvent(QMouseEvent* _event) {
if (placeMode_) {
manMode_ = QtTranslationManipulatorNode::TranslationRotation;
for (PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS); o_it
!= PluginFunctions::objectsEnd(); ++o_it)
for (auto* o_it : PluginFunctions::objects(PluginFunctions::ALL_OBJECTS) )
if (o_it->manipPlaced())
o_it->manipulatorNode()->setMode(manMode_);
......@@ -675,7 +673,7 @@ void MovePlugin::setManipMode (QtTranslationManipulatorNode::ManipulatorMode _mo
manMode_ = _mode;
// Iterate over all objects that have a placed manip and set their mode
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it)
for (auto* o_it : PluginFunctions::objects(PluginFunctions::ALL_OBJECTS) )
if ( o_it->manipPlaced() )
o_it->manipulatorNode()->setMode (_mode);
......@@ -802,8 +800,7 @@ void MovePlugin::manipulatorMoved( QtTranslationManipulatorNode* _node , QMouseE
// move all other targets without manipulator
if(allTargets_) {
for (PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS); o_it
!= PluginFunctions::objectsEnd(); ++o_it) {
for (auto* o_it : PluginFunctions::objects(PluginFunctions::TARGET_OBJECTS) ) {
if ((o_it->id() != objectId) && !o_it->manipulatorNode()->draw_manipulator()) { // If it has its own manipulator active, dont move it
// move the object which corresponds to the manipulator
......@@ -1203,11 +1200,9 @@ void MovePlugin::slotSetDirection() {
// // Apply to All Target Objects
// if ( pW->targetObjects->isChecked() ) {
// for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ;
// o_it PluginFunctions::objectsEnd(); ++o_it){
//
// o_it->manipulatorNode()->set_direction( dirX, dirY );
// }
// for (auto* o_it : PluginFunctions::objects(PluginFunctions::TARGET_OBJECTS) ) {
// o_it->manipulatorNode()->set_direction( dirX, dirY );
// }
// }
......@@ -1287,8 +1282,7 @@ void MovePlugin::slotTranslation() {
// move all other targets without manipulator
if(allTargets_) {
for (PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS); o_it
!= PluginFunctions::objectsEnd(); ++o_it) {
for (auto* o_it : PluginFunctions::objects(PluginFunctions::TARGET_OBJECTS) ) {
if ((o_it->id() != object->id()) && !o_it->manipulatorNode()->draw_manipulator()) { // If it has its own manipulator active, dont move it
if (PluginFunctions::pickMode() == "Move") {
......@@ -1365,7 +1359,7 @@ void MovePlugin::slotMoveManipToCOG() {
// if ( pW->targetObjects->isChecked() ) {
// for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) {
// for (auto* o_it : PluginFunctions::objects(PluginFunctions::TARGET_OBJECTS) ) {
// if ( o_it->manipulatorNode()->hidden() )
// continue;
//
......@@ -1500,7 +1494,7 @@ void MovePlugin::slotRotate() {
// move all other targets without manipulator
if(allTargets_) {
for (PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS); o_it != PluginFunctions::objectsEnd(); ++o_it) {
for (auto* o_it : PluginFunctions::objects(PluginFunctions::TARGET_OBJECTS) ) {
// If it has its own manipulator active, don't move it
if ((o_it->id() != object->id()) && !o_it->manipulatorNode()->draw_manipulator()) {
......@@ -1651,8 +1645,7 @@ void MovePlugin::slotScale() {
// move all other targets without manipulator
if(allTargets_) {
for (PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS); o_it
!= PluginFunctions::objectsEnd(); ++o_it) {
for (auto* o_it : PluginFunctions::objects(PluginFunctions::TARGET_OBJECTS) ) {
if ((o_it->id() != object->id()) && !o_it->manipulatorNode()->draw_manipulator()) { // If it has its own manipulator active, dont move it
if (PluginFunctions::pickMode() == "Move")
......@@ -1744,22 +1737,22 @@ void MovePlugin::slotMoveToOrigin() {
double vertexCount = 0.0;
// Compute cog for all objects
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) {
for (auto* o_it : PluginFunctions::objects(PluginFunctions::TARGET_OBJECTS) ) {
if ( o_it->dataType( DATA_TRIANGLE_MESH )) {
TriMesh* mesh = PluginFunctions::triMesh(*o_it);
TriMesh* mesh = PluginFunctions::triMesh(o_it);
cog += MeshInfo::cog(mesh) * double(mesh->n_vertices());
vertexCount += double(mesh->n_vertices());
}
if ( o_it->dataType( DATA_POLY_MESH )) {
PolyMesh* mesh = PluginFunctions::polyMesh(*o_it);
PolyMesh* mesh = PluginFunctions::polyMesh(o_it);
cog += MeshInfo::cog(mesh) * double(mesh->n_vertices());
vertexCount += double(mesh->n_vertices());
}
#ifdef ENABLE_TSPLINEMESH_SUPPORT
if ( o_it->dataType( DATA_TSPLINE_MESH )) {
TSplineMesh& mesh = *PluginFunctions::tsplineMesh(*o_it);
TSplineMesh& mesh = *PluginFunctions::tsplineMesh(o_it);
cog += MeshInfo::cog(mesh) * double(mesh.n_vertices());
vertexCount += double(mesh.n_vertices());
}
......@@ -1767,7 +1760,7 @@ void MovePlugin::slotMoveToOrigin() {
#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
if ( o_it->dataType( DATA_HEXAHEDRAL_MESH )) {
HexahedralMesh& mesh = *PluginFunctions::hexahedralMesh(*o_it);
HexahedralMesh& mesh = *PluginFunctions::hexahedralMesh(o_it);
cog += cogVolumeMesh(mesh) * double(mesh.n_vertices());
vertexCount += double(mesh.n_vertices());
}
......@@ -1775,7 +1768,7 @@ void MovePlugin::slotMoveToOrigin() {
#ifdef ENABLE_TETRAHEDRALMESH_SUPPORT
if ( o_it->dataType( DATA_TETRAHEDRAL_MESH )) {
TetrahedralMesh& mesh = *PluginFunctions::tetrahedralMesh(*o_it);
TetrahedralMesh& mesh = *PluginFunctions::tetrahedralMesh(o_it);
cog += cogVolumeMesh(mesh) * double(mesh.n_vertices());
vertexCount += double(mesh.n_vertices());
}
......@@ -1783,7 +1776,7 @@ void MovePlugin::slotMoveToOrigin() {
#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
if ( o_it->dataType( DATA_POLYHEDRAL_MESH )) {
PolyhedralMesh& mesh = *PluginFunctions::polyhedralMesh(*o_it);
PolyhedralMesh& mesh = *PluginFunctions::polyhedralMesh(o_it);
cog += cogVolumeMesh(mesh) * double(mesh.n_vertices());
vertexCount += double(mesh.n_vertices());
}
......@@ -1795,9 +1788,9 @@ void MovePlugin::slotMoveToOrigin() {
}
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) {
for (auto* o_it : PluginFunctions::objects(PluginFunctions::TARGET_OBJECTS) ) {
if ( o_it->dataType( DATA_TRIANGLE_MESH )) {
TriMesh* mesh = PluginFunctions::triMesh(*o_it);
TriMesh* mesh = PluginFunctions::triMesh(o_it);
if ( !useCommonCOG )
cog = MeshInfo::cog(mesh);
......@@ -1809,7 +1802,7 @@ void MovePlugin::slotMoveToOrigin() {
}
if ( o_it->dataType( DATA_POLY_MESH )) {
PolyMesh* mesh = PluginFunctions::polyMesh(*o_it);
PolyMesh* mesh = PluginFunctions::polyMesh(o_it);
if ( !useCommonCOG )
cog = MeshInfo::cog(mesh);
......@@ -1823,7 +1816,7 @@ void MovePlugin::slotMoveToOrigin() {
#ifdef ENABLE_TSPLINEMESH_SUPPORT
if ( o_it->dataType( DATA_TSPLINE_MESH )) {
TSplineMesh* mesh = PluginFunctions::tsplineMesh(*o_it);
TSplineMesh* mesh = PluginFunctions::tsplineMesh(o_it);
if ( !useCommonCOG )
cog = MeshInfo::cog(mesh);
......@@ -1838,7 +1831,7 @@ void MovePlugin::slotMoveToOrigin() {
#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
if ( o_it->dataType( DATA_HEXAHEDRAL_MESH )) {
HexahedralMesh& mesh = *PluginFunctions::hexahedralMesh(*o_it);
HexahedralMesh& mesh = *PluginFunctions::hexahedralMesh(o_it);
if ( !useCommonCOG )
cog = cogVolumeMesh(mesh);
......@@ -1853,7 +1846,7 @@ void MovePlugin::slotMoveToOrigin() {
#ifdef ENABLE_TETRAHEDRALMESH_SUPPORT
if ( o_it->dataType( DATA_TETRAHEDRAL_MESH )) {
TetrahedralMesh& mesh = *PluginFunctions::tetrahedralMesh(*o_it);
TetrahedralMesh& mesh = *PluginFunctions::tetrahedralMesh(o_it);
if ( !useCommonCOG )
cog = cogVolumeMesh(mesh);
......@@ -1868,7 +1861,7 @@ void MovePlugin::slotMoveToOrigin() {
#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
if ( o_it->dataType( DATA_POLYHEDRAL_MESH )) {
PolyhedralMesh& mesh = *PluginFunctions::polyhedralMesh(*o_it);
PolyhedralMesh& mesh = *PluginFunctions::polyhedralMesh(o_it);
if ( !useCommonCOG )
cog = cogVolumeMesh(mesh);
......@@ -1932,19 +1925,19 @@ void MovePlugin::unifyBoundingBox(Unificationtype u)
if ( useCommonBB ) {
// Compute cog for all objects
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) {
for (auto* o_it : PluginFunctions::objects(PluginFunctions::TARGET_OBJECTS) ) {
ACG::Vec3d bb_min_tmp(0.0,0.0,0.0);
ACG::Vec3d bb_max_tmp(0.0,0.0,0.0);
if ( o_it->dataType( DATA_TRIANGLE_MESH )) {
TriMesh& mesh = *PluginFunctions::triMesh(*o_it);
TriMesh& mesh = *PluginFunctions::triMesh(o_it);
getBB(mesh,bb_min_tmp,bb_max_tmp);
bb_min.minimize(bb_min_tmp);
bb_max.maximize(bb_max_tmp);
}
if ( o_it->dataType( DATA_POLY_MESH )) {
PolyMesh& mesh = *PluginFunctions::polyMesh(*o_it);
PolyMesh& mesh = *PluginFunctions::polyMesh(o_it);
getBB(mesh,bb_min_tmp,bb_max_tmp);
bb_min.minimize(bb_min_tmp);
bb_max.maximize(bb_max_tmp);
......@@ -1952,7 +1945,7 @@ void MovePlugin::unifyBoundingBox(Unificationtype u)
#ifdef ENABLE_TSPLINEMESH_SUPPORT
if ( o_it->dataType( DATA_TSPLINE_MESH )) {
TSplineMesh& mesh = *PluginFunctions::tsplineMesh(*o_it);
TSplineMesh& mesh = *PluginFunctions::tsplineMesh(o_it);
getBB(mesh,bb_min_tmp,bb_max_tmp);
bb_min.minimize(bb_min_tmp);
bb_max.maximize(bb_max_tmp);
......@@ -1961,7 +1954,7 @@ void MovePlugin::unifyBoundingBox(Unificationtype u)
#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
if ( o_it->dataType( DATA_HEXAHEDRAL_MESH )) {
HexahedralMesh& mesh = *PluginFunctions::hexahedralMesh(*o_it);
HexahedralMesh& mesh = *PluginFunctions::hexahedralMesh(o_it);
getBBVolumeMesh(mesh,bb_min_tmp,bb_max_tmp);
bb_min.minimize(bb_min_tmp);
bb_max.maximize(bb_max_tmp);
......@@ -1970,7 +1963,7 @@ void MovePlugin::unifyBoundingBox(Unificationtype u)
#ifdef ENABLE_TETRAHEDRALMESH_SUPPORT
if ( o_it->dataType( DATA_TETRAHEDRAL_MESH )) {
TetrahedralMesh& mesh = *PluginFunctions::tetrahedralMesh(*o_it);
TetrahedralMesh& mesh = *PluginFunctions::tetrahedralMesh(o_it);
getBBVolumeMesh(mesh,bb_min_tmp,bb_max_tmp);
bb_min.minimize(bb_min_tmp);
bb_max.maximize(bb_max_tmp);
......@@ -1979,7 +1972,7 @@ void MovePlugin::unifyBoundingBox(Unificationtype u)
#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
if ( o_it->dataType( DATA_POLYHEDRAL_MESH )) {
PolyhedralMesh& mesh = *PluginFunctions::polyhedralMesh(*o_it);
PolyhedralMesh& mesh = *PluginFunctions::polyhedralMesh(o_it);
getBBVolumeMesh(mesh,bb_min_tmp,bb_max_tmp);
bb_min.minimize(bb_min_tmp);
bb_max.maximize(bb_max_tmp);
......@@ -1990,48 +1983,48 @@ void MovePlugin::unifyBoundingBox(Unificationtype u)
}
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) {
for (auto* o_it : PluginFunctions::objects(PluginFunctions::TARGET_OBJECTS) ) {
if ( useCommonBB ) {
if ( o_it->dataType( DATA_TRIANGLE_MESH ) )
unifyBB(*PluginFunctions::triMesh(*o_it),bb_min,bb_max, u);
unifyBB(*PluginFunctions::triMesh(o_it),bb_min,bb_max, u);
else if ( o_it->dataType( DATA_POLY_MESH ) )
unifyBB(*PluginFunctions::polyMesh(*o_it),bb_min,bb_max, u);
unifyBB(*PluginFunctions::polyMesh(o_it),bb_min,bb_max, u);
#ifdef ENABLE_TSPLINEMESH_SUPPORT
else if ( o_it->dataType( DATA_TSPLINE_MESH ) )
unifyBB(*PluginFunctions::tsplineMesh(*o_it),bb_min,bb_max, u);
unifyBB(*PluginFunctions::tsplineMesh(o_it),bb_min,bb_max, u);
#endif
#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
else if ( o_it->dataType( DATA_HEXAHEDRAL_MESH ) )
unifyBBVolumeMesh(*PluginFunctions::hexahedralMesh(*o_it),(PluginFunctions::hexahedralMeshObject(*o_it)->normals()),bb_min,bb_max, u);
unifyBBVolumeMesh(*PluginFunctions::hexahedralMesh(o_it),(PluginFunctions::hexahedralMeshObject(o_it)->normals()),bb_min,bb_max, u);
#endif
#ifdef ENABLE_TETRAHEDRALMESH_SUPPORT
else if ( o_it->dataType( DATA_TETRAHEDRAL_MESH ) )
unifyBBVolumeMesh(*PluginFunctions::tetrahedralMesh(*o_it),(PluginFunctions::tetrahedralMeshObject(*o_it)->normals()),bb_min,bb_max, u);
unifyBBVolumeMesh(*PluginFunctions::tetrahedralMesh(o_it),(PluginFunctions::tetrahedralMeshObject(o_it)->normals()),bb_min,bb_max, u);
#endif
#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
else if ( o_it->dataType( DATA_POLYHEDRAL_MESH ) )
unifyBBVolumeMesh(*PluginFunctions::polyhedralMesh(*o_it),(PluginFunctions::polyhedralMeshObject(*o_it)->normals()),bb_min,bb_max, u);
unifyBBVolumeMesh(*PluginFunctions::polyhedralMesh(o_it),(PluginFunctions::polyhedralMeshObject(o_it)->normals()),bb_min,bb_max, u);
#endif
} else {
if ( o_it->dataType( DATA_TRIANGLE_MESH ) )
unifyBB(*PluginFunctions::triMesh(*o_it), u);
unifyBB(*PluginFunctions::triMesh(o_it), u);
else if ( o_it->dataType( DATA_POLY_MESH ) )
unifyBB(*PluginFunctions::polyMesh(*o_it), u);
unifyBB(*PluginFunctions::polyMesh(o_it), u);
#ifdef ENABLE_TSPLINEMESH_SUPPORT
else if ( o_it->dataType( DATA_TSPLINE_MESH ) )
unifyBB(*PluginFunctions::tsplineMesh(*o_it), u);
unifyBB(*PluginFunctions::tsplineMesh(o_it), u);
#endif
#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
else if ( o_it->dataType( DATA_HEXAHEDRAL_MESH ) )
unifyBBVolumeMesh(*PluginFunctions::hexahedralMesh(*o_it),(PluginFunctions::hexahedralMeshObject(*o_it)->normals()), u);
unifyBBVolumeMesh(*PluginFunctions::hexahedralMesh(o_it),(PluginFunctions::hexahedralMeshObject(o_it)->normals()), u);
#endif
#ifdef ENABLE_TETRAHEDRALMESH_SUPPORT
else if ( o_it->dataType( DATA_TETRAHEDRAL_MESH ) )
unifyBBVolumeMesh(*PluginFunctions::tetrahedralMesh(*o_it),(PluginFunctions::tetrahedralMeshObject(*o_it)->normals()), u);
unifyBBVolumeMesh(*PluginFunctions::tetrahedralMesh(o_it),(PluginFunctions::tetrahedralMeshObject(o_it)->normals()), u);
#endif
#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
else if ( o_it->dataType( DATA_POLYHEDRAL_MESH ) )
unifyBBVolumeMesh(*PluginFunctions::polyhedralMesh(*o_it),(PluginFunctions::polyhedralMeshObject(*o_it)->normals()), u);
unifyBBVolumeMesh(*PluginFunctions::polyhedralMesh(o_it),(PluginFunctions::polyhedralMeshObject(o_it)->normals()), u);
#endif
}
......@@ -2162,7 +2155,7 @@ void MovePlugin::slotPickToolbarAction(QAction* _action)
if (_action == biggerManipAction_)
{
manip_size_modifier_ = manip_size_modifier_ + 0.1;
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it)
for (auto* o_it : PluginFunctions::objects(PluginFunctions::ALL_OBJECTS) )
o_it->manipulatorNode()->set_size(manip_size_ * manip_size_modifier_);
emit nodeVisibilityChanged (-1);
}
......@@ -2170,7 +2163,7 @@ void MovePlugin::slotPickToolbarAction(QAction* _action)
if (_action == smallerManipAction_)
{
manip_size_modifier_ = manip_size_modifier_ - 0.1;
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it)
for (auto* o_it : PluginFunctions::objects(PluginFunctions::ALL_OBJECTS) )
o_it->manipulatorNode()->set_size(manip_size_ * manip_size_modifier_);
emit nodeVisibilityChanged (-1);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment