From 418cefd7ee4d02d584c5a871f07104683606787b Mon Sep 17 00:00:00 2001 From: Ian Rees Date: Thu, 4 Jun 2015 18:12:39 +0200 Subject: [PATCH] Cleaning up compile warnings, mainly in Sketcher fabs() instead of std::abs(), add cmath include --- src/Mod/Part/App/Part2DObject.cpp | 2 +- src/Mod/Sketcher/App/SketchObject.cpp | 12 ++++++++---- src/Mod/Sketcher/App/SketchObject.h | 6 ++++++ src/Mod/Sketcher/Gui/DrawSketchHandler.cpp | 9 +++++---- src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp | 6 +++--- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/Mod/Part/App/Part2DObject.cpp b/src/Mod/Part/App/Part2DObject.cpp index 9d34a71d6..7a8d34b7e 100644 --- a/src/Mod/Part/App/Part2DObject.cpp +++ b/src/Mod/Part/App/Part2DObject.cpp @@ -288,7 +288,7 @@ bool Part2DObject::seekTrimPoints(const std::vector &geomlist, if (periodic) { // in case both points coincide, cancel the selection of one of both - if (abs(param2-param1-period) < 1e-10) { + if (fabs(param2-param1-period) < 1e-10) { if (param2 - pickedParam >= pickedParam - param1) GeoId2 = -1; else diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 45c126ab0..7548d950f 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -42,7 +42,9 @@ # include # include # include -#endif +# include +# include +#endif // #ifndef _PreComp_ #include #include @@ -51,8 +53,6 @@ #include -#include - #include "SketchObject.h" #include "SketchObjectPy.h" #include "Sketch.h" @@ -1527,6 +1527,8 @@ int SketchObject::ExposeInternalGeometry(int GeoId) focus2=true; focus2elementindex=(*it)->First; break; + default: + return -1; } } } @@ -1690,6 +1692,8 @@ int SketchObject::DeleteUnusedInternalGeometry(int GeoId) focus2=true; focus2elementindex=(*it)->First; break; + default: + return -1; } } } @@ -2765,7 +2769,7 @@ bool SketchObject::AutoLockTangencyAndPerpty(Constraint *cstr, bool bForce, bool if (angleErr < -M_PI) angleErr += M_PI*2; //the autodetector - if(abs(angleErr) > M_PI/2 ) + if(fabs(angleErr) > M_PI/2 ) angleDesire += M_PI; cstr->Value = angleDesire + angleOffset; //external tangency. The angle stored is offset by Pi/2 so that a value of 0.0 is invalid and threated as "undecided". diff --git a/src/Mod/Sketcher/App/SketchObject.h b/src/Mod/Sketcher/App/SketchObject.h index 5473392fb..89ba9bd63 100644 --- a/src/Mod/Sketcher/App/SketchObject.h +++ b/src/Mod/Sketcher/App/SketchObject.h @@ -134,8 +134,14 @@ public: /// trim a curve int trim(int geoId, const Base::Vector3d& point); /// Exposes all internal geometry of an object supporting internal geometry + /*! + * \return -1 on error + */ int ExposeInternalGeometry(int GeoId); /// Deletes all unused (not further constrained) internal geometry + /*! + * \return -1 on error + */ int DeleteUnusedInternalGeometry(int GeoId); /// retrieves for a Vertex number the corresponding GeoId and PosId diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp index 8507dee72..12019ffb5 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp +++ b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp @@ -29,7 +29,8 @@ # include # include # include -#endif +# include +#endif // #ifndef _PreComp_ /// Here the FreeCAD includes sorted by Base,App,Gui...... #include @@ -195,7 +196,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector &suggested // the angle between the line and the hitting direction are over around 6 degrees (it is substantially parallel) // or if it is an sketch axis (that can not move to accomodate to the shape), then only if it is around 6 degrees with the normal (around 84 degrees) - if(abs(cosangle) < 0.995f || ((GeoId==-1 || GeoId==-2) && abs(cosangle) < 0.1)) + if (fabs(cosangle) < 0.995f || ((GeoId==-1 || GeoId==-2) && fabs(cosangle) < 0.1)) suggestedConstraints.push_back(constr); @@ -292,7 +293,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector &suggested Base::Vector3d focus1PMirrored = focus1P + 2*distancetoline*norm; // mirror of focus1 with respect to the line - double error = abs((focus1PMirrored-focus2P).Length() - 2*a); + double error = fabs((focus1PMirrored-focus2P).Length() - 2*a); if ( error< tangDeviation) { tangId = i; @@ -347,7 +348,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector &suggested Base::Vector3d focus1PMirrored = focus1P + 2*distancetoline*norm; // mirror of focus1 with respect to the line - double error = abs((focus1PMirrored-focus2P).Length() - 2*a); + double error = fabs((focus1PMirrored-focus2P).Length() - 2*a); if ( error< tangDeviation ) { tangId = i; diff --git a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp index 6e369bbe1..35a8a9059 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2009 Jürgen Riegel * + * Copyright (c) 2009 Juergen Riegel * * * * This file is part of the FreeCAD CAx development system. * * * @@ -382,7 +382,7 @@ void TaskSketcherConstrains::on_listWidgetConstraints_itemChanged(QListWidgetIte { double n1 = 1.0; double n2 = 1.0; - if(abs(v->Value)>=1) { + if (fabs(v->Value) >= 1) { n2 = v->Value; } else { n1 = 1/v->Value; @@ -545,7 +545,7 @@ void TaskSketcherConstrains::slotConstraintsChanged(void) double v = (*it)->Value; double n1 = 1.0; double n2 = 1.0; - if(abs(v)>=1) { + if (fabs(v) >= 1) { n2 = v; } else { n1 = 1/v;