Show area of closed contour with SI units.

Similar to the way that Analyze → Measure Area... works.

Fixes #639.
pull/640/head
whitequark 2020-06-23 02:24:12 +00:00
parent 35c6af4929
commit 211ae8c446
2 changed files with 1 additions and 5 deletions

View File

@ -767,11 +767,7 @@ void Group::DrawContourAreaLabels(Canvas *canvas) {
Canvas::Stroke stroke = Style::Stroke(hs); Canvas::Stroke stroke = Style::Stroke(hs);
stroke.layer = Canvas::Layer::FRONT; stroke.layer = Canvas::Layer::FRONT;
double scale = SS.MmPerUnit(); std::string label = SS.MmToStringSI(fabs(sbls.SignedArea()), /*dim=*/2);
std::string label = ssprintf("%.3f %s²",
fabs(sbls.SignedArea() / (scale * scale)),
SS.UnitName());
double fontHeight = Style::TextHeight(hs); double fontHeight = Style::TextHeight(hs);
double textWidth = VectorFont::Builtin()->GetWidth(fontHeight, label), double textWidth = VectorFont::Builtin()->GetWidth(fontHeight, label),
textHeight = VectorFont::Builtin()->GetCapHeight(fontHeight); textHeight = VectorFont::Builtin()->GetCapHeight(fontHeight);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB