From bb45c7b97e02e84b8a09e4e83577c17ca3e00ae5 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Sat, 28 Dec 2019 09:14:31 -0500 Subject: [PATCH] [TD]adjust symbol location for font and text --- src/Mod/TechDraw/Gui/QGISectionLine.cpp | 35 +++++++++++-------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/Mod/TechDraw/Gui/QGISectionLine.cpp b/src/Mod/TechDraw/Gui/QGISectionLine.cpp index 77be9177cf..65b8750a67 100644 --- a/src/Mod/TechDraw/Gui/QGISectionLine.cpp +++ b/src/Mod/TechDraw/Gui/QGISectionLine.cpp @@ -40,6 +40,7 @@ #include "QGISectionLine.h" using namespace TechDrawGui; +using namespace TechDraw; QGISectionLine::QGISectionLine() { @@ -198,32 +199,26 @@ void QGISectionLine::makeSymbolsTrad() m_symFont.setPixelSize(QGIView::calculateFontPixelSize(m_symSize)); m_symbol1->setFont(m_symFont); m_symbol1->setPlainText(QString::fromUtf8(m_symbol)); - if (m_arrowDir.y < 0.0) { //pointing down - extLineStart += QPointF (0.0, m_symSize); //move text down a bit - } else if (m_arrowDir.y > 0.0) { //pointing up - extLineStart -= QPointF (0.0, m_symSize); //move text up a bit - } - if (m_arrowDir.x < 0.0) { //pointing left - extLineStart -= QPointF (m_symSize, 0.0); //move text left a bit - } else if (m_arrowDir.x > 0.0) { //pointing rightup - extLineStart += QPointF (m_symSize, 0.0); //move text right a bit + + QRectF symRect = m_symbol1->boundingRect(); + double symWidth = symRect.width(); + double symHeight = symRect.height(); + double symbolFudge = 1.0; + double angle = atan2f(m_arrowDir.y,m_arrowDir.x); + if (angle < 0.0) { + angle = 2 * M_PI + angle; } + Base::Vector3d adjustVector(cos(angle) * symWidth, sin(angle) * symHeight, 0.0); + adjustVector = (DrawUtil::invertY(adjustVector) / 2.0) * symbolFudge; + QPointF qAdjust(adjustVector.x, adjustVector.y); + + extLineStart += qAdjust; m_symbol1->centerAt(extLineStart); m_symbol2->setFont(m_symFont); m_symbol2->setPlainText(QString::fromUtf8(m_symbol)); - if (m_arrowDir.y < 0.0) { //pointing down - extLineEnd += QPointF (0.0, m_symSize); //move text down a bit - } else if (m_arrowDir.y > 0.0) { //pointing up - extLineEnd -= QPointF (0.0, m_symSize); //move text up a bit - } - if (m_arrowDir.x < 0.0) { //pointing left - extLineEnd -= QPointF (m_symSize, 0.0); //move text left a bit - } else if (m_arrowDir.x > 0.0) { //pointing rightup - extLineEnd += QPointF (m_symSize, 0.0); //move text right a bit - } + extLineEnd += qAdjust; m_symbol2->centerAt(extLineEnd); - } void QGISectionLine::makeSymbolsISO()