From 211ae8c44649532991c5fbedf40a735fa799ea81 Mon Sep 17 00:00:00 2001 From: whitequark Date: Tue, 23 Jun 2020 02:24:12 +0000 Subject: [PATCH] Show area of closed contour with SI units. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Similar to the way that Analyze → Measure Area... works. Fixes #639. --- src/groupmesh.cpp | 6 +----- test/analysis/contour_area/normal.png | Bin 4872 -> 4787 bytes 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/groupmesh.cpp b/src/groupmesh.cpp index 8117834e..a46bb221 100644 --- a/src/groupmesh.cpp +++ b/src/groupmesh.cpp @@ -767,11 +767,7 @@ void Group::DrawContourAreaLabels(Canvas *canvas) { Canvas::Stroke stroke = Style::Stroke(hs); stroke.layer = Canvas::Layer::FRONT; - double scale = SS.MmPerUnit(); - std::string label = ssprintf("%.3f %s²", - fabs(sbls.SignedArea() / (scale * scale)), - SS.UnitName()); - + std::string label = SS.MmToStringSI(fabs(sbls.SignedArea()), /*dim=*/2); double fontHeight = Style::TextHeight(hs); double textWidth = VectorFont::Builtin()->GetWidth(fontHeight, label), textHeight = VectorFont::Builtin()->GetCapHeight(fontHeight); diff --git a/test/analysis/contour_area/normal.png b/test/analysis/contour_area/normal.png index 9daf8eebb6a11cd10651ddfb29e9bfb8865aa9a3..486fcdc4102cb485be2fb3f83264897aada4eeae 100644 GIT binary patch delta 2645 zcma)8X;hO}8omjTAYn7OAiGkfDhL$`C}L1>sHF-O#DHKzMV5wu6hzh}r~@O_Ab!)J zpac$sR3H$GA;^{h+SHLnp%Nr)DQZv%vL1aG@=(9xLxHH!I9KyCCs=|QH%0Ptj`A_V}DY7G_ZY=j&zn<0|UhFpQ;Ez~;P zvTx#>xM)f~b!FC0$WrHzzUC{%pD#Z2ILuU-KiVH%OLZ3M6?7zi3`iK{cxpq3k((iV z%(`twmPcbZX(v>U)okMzPMsKt>_EFlAUT=a*< zD3zKi_gc1jL>F%7jQpI*&-%&W#ca<2{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