From 13c82aa67d468ad21fcc73fb56521161a2a15f68 Mon Sep 17 00:00:00 2001 From: Franck Jullien Date: Sun, 7 Apr 2019 19:13:26 +0200 Subject: [PATCH] TechDraw: add separator for Rectangle balloons --- src/Mod/TechDraw/Gui/QGIViewBalloon.cpp | 23 ++++++++++++++++++++++- src/Mod/TechDraw/Gui/QGIViewDimension.h | 5 ++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/Mod/TechDraw/Gui/QGIViewBalloon.cpp b/src/Mod/TechDraw/Gui/QGIViewBalloon.cpp index 36d9f449d7..b60221f295 100644 --- a/src/Mod/TechDraw/Gui/QGIViewBalloon.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewBalloon.cpp @@ -275,6 +275,21 @@ void QGIViewBalloon::updateBalloon(bool obtuse) font.setPointSizeF(Rez::guiX(vp->Fontsize.getValue())); font.setFamily(QString::fromUtf8(vp->Font.getValue())); balloonLabel->setFont(font); + + QString labelText = QString::fromUtf8(balloon->Text.getStrValue().data()); + balloonLabel->verticalSep = false; + + if (strcmp(balloon->Symbol.getValueAsString(), "Rectangle") == 0) { + while (labelText.contains(QString::fromUtf8("|"))) { + int pos = labelText.indexOf(QString::fromUtf8("|")); + labelText.replace(pos, 1, QString::fromUtf8(" ")); + QFontMetrics fm(balloonLabel->getFont()); + balloonLabel->seps.push_back(fm.width((labelText.left(pos + 2)))); + balloonLabel->verticalSep = true; + } + } + + balloonLabel->setDimString(labelText, Rez::guiX(balloon->TextWrapLen.getValue())); } void QGIViewBalloon::balloonLabelDragged(bool ctrl) @@ -377,8 +392,14 @@ void QGIViewBalloon::draw_modifier(bool modifier) offset = (textWidth / 2.0) + Rez::guiX(2.0); } else if (strcmp(balloonType, "Rectangle") == 0) { //Add some room - textWidth = (textWidth * scale) + Rez::guiX(2.0); textHeight = (textHeight * scale) + Rez::guiX(1.0); + if (balloonLabel->verticalSep) { + for (std::vector::iterator it = balloonLabel->seps.begin() ; it != balloonLabel->seps.end(); ++it) { + balloonPath.moveTo(lblCenter.x - (textWidth / 2.0) + *it, lblCenter.y - (textHeight / 2.0)); + balloonPath.lineTo(lblCenter.x - (textWidth / 2.0) + *it, lblCenter.y + (textHeight / 2.0)); + } + } + textWidth = (textWidth * scale) + Rez::guiX(2.0); balloonPath.addRect(lblCenter.x -(textWidth / 2.0), lblCenter.y - (textHeight / 2.0), textWidth, textHeight); offset = (textWidth / 2.0); } else if (strcmp(balloonType, "Triangle") == 0) { diff --git a/src/Mod/TechDraw/Gui/QGIViewDimension.h b/src/Mod/TechDraw/Gui/QGIViewDimension.h index 4d3c41dddf..630e70b60d 100644 --- a/src/Mod/TechDraw/Gui/QGIViewDimension.h +++ b/src/Mod/TechDraw/Gui/QGIViewDimension.h @@ -79,7 +79,10 @@ public: void setPrettyPre(void); void setPrettyNormal(void); void setColor(QColor c); - + + bool verticalSep; + std::vector seps; + QGCustomText* getDimText(void) { return m_dimText; } void setDimText(QGCustomText* newText) { m_dimText = newText; } QGCustomText* getTolText(void) { return m_tolText; }