Mercurial > hg > orthanc-stone
diff Framework/Layers/LineMeasureTracker.cpp @ 367:face7b7008de am-2
line and circle measure tools are now compatible with WebAssembly
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 01 Nov 2018 12:09:11 +0100 |
parents | 50e5ec1bdd46 |
children | b70e9be013e4 |
line wrap: on
line diff
--- a/Framework/Layers/LineMeasureTracker.cpp Thu Nov 01 11:55:45 2018 +0100 +++ b/Framework/Layers/LineMeasureTracker.cpp Thu Nov 01 12:09:11 2018 +0100 @@ -21,8 +21,6 @@ #include "LineMeasureTracker.h" -#include "../Viewport/CairoFont.h" - #include <stdio.h> namespace OrthancStone @@ -34,14 +32,14 @@ uint8_t red, uint8_t green, uint8_t blue, - unsigned int fontSize) : + const Orthanc::Font& font) : statusBar_(statusBar), slice_(slice), x1_(x), y1_(y), x2_(x), y2_(y), - fontSize_(fontSize) + font_(font) { color_[0] = red; color_[1] = green; @@ -60,13 +58,13 @@ cairo_line_to(cr, x2_, y2_); cairo_stroke(cr); - if (fontSize_ != 0) + if (y2_ - y1_ < 0) { - cairo_move_to(cr, x2_, y2_ - static_cast<double>(fontSize_) / zoom); -#if ORTHANC_ENABLE_NATIVE==1 // text rendering currently fails in wasm - CairoFont font("sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); - font.Draw(context, FormatLength(), static_cast<double>(fontSize_) / zoom); -#endif + context.DrawText(font_, FormatLength(), x2_, y2_ - 5, BitmapAnchor_BottomCenter); + } + else + { + context.DrawText(font_, FormatLength(), x2_, y2_ + 5, BitmapAnchor_TopCenter); } }