[TechDraw] Use templates instead of duplicate code: toGp

This commit is contained in:
Benjamin Bræstrup Sayoc
2024-10-08 00:35:25 +02:00
parent 20ac96f4c8
commit 1d7e7c86a0
13 changed files with 63 additions and 76 deletions

View File

@@ -494,12 +494,10 @@ std::string DrawUtil::formatVector(const Base::Vector3d& v)
return builder.str();
}
std::string DrawUtil::formatVector(const gp_Dir& v)
template <> // GCC BUG 85282, wanting this to be outside class body
Base::Vector3d DrawUtil::toVector3d<QPointF>(const QPointF& v)
{
std::stringstream builder;
builder << std::fixed << std::setprecision(Base::UnitsApi::getDecimals());
builder << " (" << v.X() << ", " << v.Y() << ", " << v.Z() << ") ";
return builder.str();
return Base::Vector3d(v.x(), v.y(), 0);
}
std::string DrawUtil::formatVector(const gp_Dir2d& v)
@@ -669,7 +667,7 @@ Base::Vector3d DrawUtil::vecRotate(Base::Vector3d vec, double angle, Base::Vecto
gp_Vec DrawUtil::closestBasis(gp_Vec inVec)
{
return gp_Vec(togp_Dir(closestBasis(toVector3d(inVec))));
return gp_Vec(to<gp_Dir>(closestBasis(toVector3d(inVec))));
}
//! returns stdX, stdY or stdZ.
@@ -909,7 +907,7 @@ gp_Vec DrawUtil::maskDirection(gp_Vec inVec, gp_Dir directionToMask)
Base::Vector3d DrawUtil::maskDirection(Base::Vector3d inVec, Base::Vector3d directionToMask)
{
return toVector3d(maskDirection(togp_Vec(inVec), togp_Vec(directionToMask)));
return toVector3d(maskDirection(to<gp_Vec>(inVec), to<gp_Vec>(directionToMask)));
}
//! get the coordinate of inPoint for the cardinal unit direction.