Skip to content

Commit

Permalink
[TD]adjust symbol location for font and text
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Dec 29, 2019
1 parent 4cca918 commit e33a90d
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions src/Mod/TechDraw/Gui/QGISectionLine.cpp
Expand Up @@ -40,6 +40,7 @@
#include "QGISectionLine.h"

using namespace TechDrawGui;
using namespace TechDraw;

QGISectionLine::QGISectionLine()
{
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit e33a90d

Please sign in to comment.