From 80a7b36da31bf1c65ebf22efb0b247f30685f277 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Wed, 13 Feb 2019 14:41:17 -0500 Subject: [PATCH] Fix Dim text position for some DistanceX - Dim text position was affected by point selection order when distance was no horizontal. --- src/Mod/TechDraw/Gui/QGIViewDimension.cpp | 40 ++++++++++------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/Mod/TechDraw/Gui/QGIViewDimension.cpp b/src/Mod/TechDraw/Gui/QGIViewDimension.cpp index d8b71b1c2b..d50bb0f11c 100644 --- a/src/Mod/TechDraw/Gui/QGIViewDimension.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewDimension.cpp @@ -493,16 +493,16 @@ void QGIViewDimension::draw() if (strcmp(dimType, "Distance") == 0 || strcmp(dimType, "DistanceX") == 0 || strcmp(dimType, "DistanceY") == 0) { + Base::Vector3d stdUp(0.0,1.0,0.0); + Base::Vector3d stdLeft(-1.0,0.0,0.0); pointPair pts = dim->getLinearPoints(); Base::Vector3d startDist, endDist, midDist; //start/end/mid points of distance line startDist = Rez::guiX(pts.first); endDist = Rez::guiX(pts.second); - if (strcmp(dimType, "DistanceY") == 0 ) { - if (startDist.y < endDist.y) { //measure bottom to top - Base::Vector3d temp = startDist; - startDist = endDist; - endDist = temp; - } + if (startDist.y < endDist.y) { //measure bottom to top + Base::Vector3d temp = startDist; + startDist = endDist; + endDist = temp; } Base::Vector3d vecDist = (endDist - startDist); @@ -563,10 +563,14 @@ void QGIViewDimension::draw() } Base::Vector3d textNorm = normDim; - if (std::abs(dirDist.x) < FLT_EPSILON) { //this is DistanceY - textNorm = Base::Vector3d(-1.0,0.0,0.0); //text up is left (iso) - } else if (std::abs(dirDist.y) < FLT_EPSILON) { //this is DistanceX - textNorm = Base::Vector3d(0.0,1.0,0.0); //text up is up + if (strcmp(dimType, "DistanceX") == 0 ) { + textNorm = stdUp; //always above + } else if (strcmp(dimType, "DistanceY") == 0 ) { + textNorm = stdLeft; //left of dimLine + } else if (std::abs(dirDist.x) < FLT_EPSILON) { //this is horizontal dim line + textNorm = stdLeft; //left of dimLine + } else if (std::abs(dirDist.y) < FLT_EPSILON) { //this is vertical dim line + textNorm = stdLeft; //left of dimLine } // +/- pos of startDist vs endDist for vert/horiz Dims // distStartDelta sb zero for normal dims @@ -601,7 +605,7 @@ void QGIViewDimension::draw() fauxCenter = lblCenter + textOffset * dirExtActual; double slope; if (DrawUtil::fpCompare(dirDist.x, 0.0)) { - slope = std::numeric_limits::max(); + slope = std::numeric_limits::max(); //vertical line } else { slope = fabs(dirDist.y / dirDist.x); } @@ -616,18 +620,10 @@ void QGIViewDimension::draw() } } else if (strcmp(dimType, "DistanceX") == 0 ) { - if (lblCenter.y > figureCenter.y) { //text always above dimLine - fauxCenter = lblCenter + textOffset * textNorm; - } else { - fauxCenter = lblCenter + textOffset * textNorm; - } - } else if (strcmp(dimType, "DistanceY") == 0 ) { //text always to left of dimLine + fauxCenter = lblCenter + textOffset * textNorm; + } else if (strcmp(dimType, "DistanceY") == 0 ) { angle = - angle; - if (lblCenter.x > figureCenter.x) { - fauxCenter = lblCenter - textOffset * textNorm; - } else { - fauxCenter = lblCenter - textOffset * textNorm; - } + fauxCenter = lblCenter - textOffset * textNorm; } //intersection of extension lines and dimension line