Skip to content

Commit

Permalink
TechDraw: add separator for Rectangle balloons
Browse files Browse the repository at this point in the history
  • Loading branch information
fjullien authored and WandererFan committed Apr 17, 2019
1 parent c779f34 commit 13c82aa
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
23 changes: 22 additions & 1 deletion src/Mod/TechDraw/Gui/QGIViewBalloon.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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<int>::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) {
Expand Down
5 changes: 4 additions & 1 deletion src/Mod/TechDraw/Gui/QGIViewDimension.h
Expand Up @@ -79,7 +79,10 @@ Q_OBJECT
void setPrettyPre(void);
void setPrettyNormal(void);
void setColor(QColor c);


bool verticalSep;
std::vector<int> seps;

QGCustomText* getDimText(void) { return m_dimText; }
void setDimText(QGCustomText* newText) { m_dimText = newText; }
QGCustomText* getTolText(void) { return m_tolText; }
Expand Down

0 comments on commit 13c82aa

Please sign in to comment.