Skip to content

Commit

Permalink
[TD]change Angle Dim tolerance format
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Aug 22, 2020
1 parent bba3d2a commit cc81f79
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/Mod/TechDraw/App/DrawViewDimension.h
Expand Up @@ -158,11 +158,12 @@ class TechDrawExport DrawViewDimension : public TechDraw::DrawView
pointPair getArrowPositions(void);
void saveArrowPositions(const Base::Vector2d positions[]);

bool showUnits() const;
bool useDecimals() const;

protected:
virtual void onChanged(const App::Property* prop) override;
virtual void onDocumentRestored() override;
bool showUnits() const;
bool useDecimals() const;
std::string getPrefix() const;
std::string getDefaultFormatSpec() const;
virtual pointPair getPointsOneEdge();
Expand Down
24 changes: 14 additions & 10 deletions src/Mod/TechDraw/Gui/QGIViewDimension.cpp
Expand Up @@ -234,13 +234,19 @@ void QGIDatumLabel::setPosFromCenter(const double &xCenter, const double &yCente
//set label's Qt position(top,left) given boundingRect center point
setPos(xCenter - m_dimText->boundingRect().width() / 2., yCenter - m_dimText->boundingRect().height() / 2.);

//set tolerance position
QRectF labelBox = m_dimText->boundingRect();
double right = labelBox.right();
double top = labelBox.top();
double bottom = labelBox.bottom();
double middle = (top + bottom) / 2.0;

//set unit position
QRectF unitBox = m_unitText->boundingRect();
double unitWidth = unitBox.width();
double unitRight = right + unitWidth;
m_unitText->setPos(right,top);

//set tolerance position
QRectF overBox = m_tolTextOver->boundingRect();
double overWidth = overBox.width();
QRectF underBox = m_tolTextUnder->boundingRect();
Expand All @@ -249,17 +255,11 @@ void QGIDatumLabel::setPosFromCenter(const double &xCenter, const double &yCente
if (overWidth > underWidth) {
width = overWidth;
}
double tolRight = right + width;
double tolRight = unitRight + width;

m_tolTextOver->justifyRightAt(tolRight, middle, false);
m_tolTextUnder->justifyRightAt(tolRight, middle + underBox.height(), false);

//set unit position
if (dim->hasTolerance()) {
m_unitText->setPos(tolRight,top);
} else {
m_unitText->setPos(right, top);
}
}

void QGIDatumLabel::setLabelCenter()
Expand Down Expand Up @@ -335,6 +335,10 @@ void QGIDatumLabel::setTolString()
qsPrecision +
QString::fromUtf8("g"); //trim trailing zeroes
}
QString tolSuffix;
if ((dim->Type.isValue("Angle")) || (dim->Type.isValue("Angle3Pt"))) {
tolSuffix = QString::fromUtf8(dim->getFormatedValue(2).c_str()); //just the unit
}

QString overFormat;
QString underFormat;
Expand All @@ -347,8 +351,8 @@ void QGIDatumLabel::setTolString()
underFormat = qs2.sprintf(qsFormatUnder.toStdString().c_str(), underTol);
#endif

m_tolTextOver->setPlainText(overFormat);
m_tolTextUnder->setPlainText(underFormat);
m_tolTextOver->setPlainText(overFormat + tolSuffix);
m_tolTextUnder->setPlainText(underFormat + tolSuffix);

return;
}
Expand Down

0 comments on commit cc81f79

Please sign in to comment.