From 93e685bd7af2cb51eb9dd2ddbc601e8ac6e0fc85 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Sat, 31 Aug 2024 19:37:13 -0400 Subject: [PATCH] [TD]fix dim text wrong side of dim line (fix #16172) --- src/Mod/TechDraw/App/DrawViewDimension.cpp | 19 +++++++++++++++++++ src/Mod/TechDraw/App/DrawViewDimension.h | 6 ++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawViewDimension.cpp b/src/Mod/TechDraw/App/DrawViewDimension.cpp index acfa72b610..3ee1a217c0 100644 --- a/src/Mod/TechDraw/App/DrawViewDimension.cpp +++ b/src/Mod/TechDraw/App/DrawViewDimension.cpp @@ -768,6 +768,25 @@ double DrawViewDimension::getProjectedDimValue() const } +pointPair DrawViewDimension::getLinearPoints() const +{ + Base::Vector3d stdY{0, 1, 0}; + if (Type.isValue("Distance")) { + // if the dimVec points the wrong way on generally vertical dims, the dim text will be + // placed on the wrong side of the dim line. + auto dimVec = m_linearPoints.second() - m_linearPoints.first(); + dimVec.Normalize(); + auto dotY = stdY.Dot(dimVec); + if (dotY > 0) { + // dimVec points up (ish) so the dim text will be to right of dim line and readable from + // left side of the page. Dimensions should always be readable from the bottom-right, so + // we flip the points. + return {m_linearPoints.second(), m_linearPoints.first()}; + } + } + return m_linearPoints; +} + pointPair DrawViewDimension::getPointsOneEdge(ReferenceVector references) { // Base::Console().Message("DVD::getPointsOneEdge()\n"); diff --git a/src/Mod/TechDraw/App/DrawViewDimension.h b/src/Mod/TechDraw/App/DrawViewDimension.h index 56836c7ae9..a3dda62008 100644 --- a/src/Mod/TechDraw/App/DrawViewDimension.h +++ b/src/Mod/TechDraw/App/DrawViewDimension.h @@ -158,10 +158,8 @@ public: bool hasBroken3dReferences() const; - virtual pointPair getLinearPoints() const - { - return m_linearPoints; - } + virtual pointPair getLinearPoints() const; + virtual void setLinearPoints(Base::Vector3d point0, Base::Vector3d point1) { m_linearPoints.first(point0);