From 590b0469c360b9fd2d8487c4070b126fdcc0af3d Mon Sep 17 00:00:00 2001 From: logari81 Date: Sat, 24 Dec 2011 08:21:18 +0000 Subject: [PATCH] + untabify, remove unused variables + use Constraint::GeoUndef for comparisons where possible + fix two absurdly implemented loops git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5341 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d --- src/Mod/Sketcher/Gui/CommandConstraints.cpp | 22 ++++++--------------- src/Mod/Sketcher/Gui/DrawSketchHandler.h | 4 ++-- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.cpp b/src/Mod/Sketcher/Gui/CommandConstraints.cpp index 7567c0b2a..62105be0a 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.cpp +++ b/src/Mod/Sketcher/Gui/CommandConstraints.cpp @@ -220,7 +220,6 @@ void CmdSketcherConstrainHorizontal::activated(int iMsg) } // undo command open openCommand("add horizontal constraint"); - for (std::vector::iterator it=ids.begin(); it != ids.end(); it++) { // issue the actual commands to create the constraint doCommand(Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Horizontal',%d)) " @@ -277,7 +276,7 @@ void CmdSketcherConstrainVertical::activated(int iMsg) std::vector ids; // go through the selected subelements - for(std::vector::const_iterator it=SubNames.begin();it!=SubNames.end();++it){ + for (std::vector::const_iterator it=SubNames.begin();it!=SubNames.end();++it) { // only handle edges if (it->size() > 4 && it->substr(0,4) == "Edge") { int index=std::atoi(it->substr(4,4000).c_str()); @@ -693,7 +692,7 @@ void CmdSketcherConstrainPointOnObject::activated(int iMsg) VtId2 = std::atoi(SubNames[1].substr(6,4000).c_str()); } - if ((VtId1 >= 0 && GeoId2 >= 0) || (VtId2 >= 0 && GeoId1 >= 0)) { + if ((VtId1 >= 0 && GeoId2 != Constraint::GeoUndef) || (VtId2 >= 0 && GeoId1 != Constraint::GeoUndef)) { if (VtId2 >= 0 && GeoId1 >= 0) { std::swap(VtId1,VtId2); std::swap(GeoId1,GeoId2); @@ -807,7 +806,7 @@ void CmdSketcherConstrainDistanceX::activated(int iMsg) getSelection().clearSelection(); return; } - else if (GeoId1 >= 0 && GeoId2 < 0 && VtId2 < 0) { // horizontal length of a line + else if (GeoId1 >= 0 && GeoId2 == Constraint::GeoUndef && VtId2 < 0) { // horizontal length of a line const Part::Geometry *geom = geo[GeoId1]; if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { const Part::GeomLineSegment *lineSeg; @@ -942,7 +941,7 @@ void CmdSketcherConstrainDistanceY::activated(int iMsg) getSelection().clearSelection(); return; } - else if (GeoId1 >= 0 && GeoId2 < 0 && VtId2 < 0) { // horizontal length of a line + else if (GeoId1 >= 0 && GeoId2 == Constraint::GeoUndef && VtId2 < 0) { // horizontal length of a line const Part::Geometry *geom = geo[GeoId1]; if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { const Part::GeomLineSegment *lineSeg; @@ -1031,7 +1030,6 @@ void CmdSketcherConstrainParallel::activated(int iMsg) // get the needed lists and objects const std::vector &SubNames = selection[0].getSubNames(); Sketcher::SketchObject* Obj = dynamic_cast(selection[0].getObject()); - const std::vector< Sketcher::Constraint * > &vals = Obj->Constraints.getValues(); const std::vector &geomlist = Obj->Geometry.getValues(); @@ -1067,16 +1065,11 @@ void CmdSketcherConstrainParallel::activated(int iMsg) // undo command open openCommand("add parallel constraint"); - int i = 0; - for (std::vector::iterator it = ids.begin(); it!=ids.end();++it, i++) { - if(i == ids.size() - 1) - break; - + for (int i=0; i < int(ids.size()-1); i++) { Gui::Command::doCommand( Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Parallel',%d,%d)) ", selection[0].getFeatName(),ids[i],ids[i+1]); } - // finish the transaction and update commitCommand(); updateActive(); @@ -1587,10 +1580,7 @@ void CmdSketcherConstrainEqual::activated(int iMsg) // undo command open openCommand("add equality constraint"); - int i = 0; - for (std::vector::iterator it = ids.begin(); it!=ids.end();it++, i++) { - if( i == ids.size() - 1) - break; + for (int i=0; i < int(ids.size()-1); i++) { Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Equal',%d,%d)) ", selection[0].getFeatName(),ids[i],ids[i+1]); } diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandler.h b/src/Mod/Sketcher/Gui/DrawSketchHandler.h index db8eede6f..0e85bff15 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandler.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandler.h @@ -94,8 +94,8 @@ protected: // helpers void setCursor( const QPixmap &p,int x,int y ); void unsetCursor(void); - void applyCursor(void); - void applyCursor(QCursor &newCursor); + void applyCursor(void); + void applyCursor(QCursor &newCursor); ViewProviderSketch *sketchgui; QCursor oldCursor;