diff --git a/src/Mod/TechDraw/App/DrawUtil.cpp b/src/Mod/TechDraw/App/DrawUtil.cpp index 2669df5e24..3c3c84cec1 100644 --- a/src/Mod/TechDraw/App/DrawUtil.cpp +++ b/src/Mod/TechDraw/App/DrawUtil.cpp @@ -485,7 +485,8 @@ Base::Vector3d DrawUtil::vertex2Vector(const TopoDS_Vertex& v) return Base::Vector3d(gp.X(), gp.Y(), gp.Z()); } -//TODO: make formatVector using toVector3d +// template specialization +//template <> // GCC BUG 85282, wanting this to be outside class body std::string DrawUtil::formatVector(const Base::Vector3d& v) { std::stringstream builder; @@ -493,51 +494,7 @@ std::string DrawUtil::formatVector(const Base::Vector3d& v) builder << " (" << v.x << ", " << v.y << ", " << v.z << ") "; return builder.str(); } - -template <> // GCC BUG 85282, wanting this to be outside class body -Base::Vector3d DrawUtil::toVector3d(const QPointF& v) -{ - return Base::Vector3d(v.x(), v.y(), 0); -} - -std::string DrawUtil::formatVector(const gp_Dir2d& v) -{ - std::stringstream builder; - builder << std::fixed << std::setprecision(Base::UnitsApi::getDecimals()); - builder << " (" << v.X() << ", " << v.Y() << ") "; - return builder.str(); -} -std::string DrawUtil::formatVector(const gp_Vec& v) -{ - std::stringstream builder; - builder << std::fixed << std::setprecision(Base::UnitsApi::getDecimals()); - builder << " (" << v.X() << ", " << v.Y() << ", " << v.Z() << ") "; - return builder.str(); -} - -std::string DrawUtil::formatVector(const gp_Pnt& v) -{ - std::stringstream builder; - builder << std::fixed << std::setprecision(Base::UnitsApi::getDecimals()); - builder << " (" << v.X() << ", " << v.Y() << ", " << v.Z() << ") "; - return builder.str(); -} - -std::string DrawUtil::formatVector(const gp_Pnt2d& v) -{ - std::stringstream builder; - builder << std::fixed << std::setprecision(Base::UnitsApi::getDecimals()); - builder << " (" << v.X() << ", " << v.Y() << ") "; - return builder.str(); -} - -std::string DrawUtil::formatVector(const QPointF& v) -{ - std::stringstream builder; - builder << std::fixed << std::setprecision(Base::UnitsApi::getDecimals()); - builder << " (" << v.x() << ", " << v.y() << ") "; - return builder.str(); -} +//template std::string DrawUtil::formatVector(const Base::Vector3d &v); //! compare 2 vectors for sorting - true if v1 < v2 //! precision::Confusion() is too strict for vertex - vertex comparisons diff --git a/src/Mod/TechDraw/App/DrawUtil.h b/src/Mod/TechDraw/App/DrawUtil.h index d9233ff8e7..1209f0bd3a 100644 --- a/src/Mod/TechDraw/App/DrawUtil.h +++ b/src/Mod/TechDraw/App/DrawUtil.h @@ -116,13 +116,12 @@ public: static Base::Vector3d vertex2Vector(const TopoDS_Vertex& v); + template + static std::string formatVector(const T& v) + { + return formatVector(toVector3d(v)); + } static std::string formatVector(const Base::Vector3d& v); - static std::string formatVector(const gp_Dir& v); - static std::string formatVector(const gp_Dir2d& v); - static std::string formatVector(const gp_Vec& v); - static std::string formatVector(const gp_Pnt& v); - static std::string formatVector(const gp_Pnt2d& v); - static std::string formatVector(const QPointF& v); static bool vectorLess(const Base::Vector3d& v1, const Base::Vector3d& v2); //!std::map require comparator to be a type not a function @@ -176,6 +175,11 @@ public: return Base::Vector3d(v.X(), v.Y(), v.Z()); } + static Base::Vector3d toVector3d(const QPointF& v) + { + return Base::Vector3d(v.x(), v.y(), 0); + } + //! To gp_* // TODO: Would this be relevant to move to Base::Vector3d? Probably template @@ -280,8 +284,12 @@ public: static void dumpEdges(const char* text, const TopoDS_Shape& s); }; -template <> // GCC BUG 85282, wanting this to be outside class body. This is only the declaration, the definition .cpp -Base::Vector3d DrawUtil::toVector3d(const QPointF& v); + +// GCC BUG 85282, wanting this to be outside class body. This is only the declaration, the definition .cpp +//template<> std::string DrawUtil::formatVector(const Base::Vector3d &v); + +// GCC BUG 85282, wanting this to be outside class body. This is only the declaration, the definition .cpp +//template<> Base::Vector3d DrawUtil::toVector3d(const QPointF& v); }//end namespace TechDraw #endif