Mercurial > hg > orthanc-stone
comparison Framework/Layers/CircleMeasureTracker.cpp @ 726:4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 21 May 2019 11:43:25 +0200 |
parents | 3b4df9925db6 |
children |
comparison
equal
deleted
inserted
replaced
714:d2c0e347ddc2 | 726:4f2416d519b4 |
---|---|
22 #include "CircleMeasureTracker.h" | 22 #include "CircleMeasureTracker.h" |
23 | 23 |
24 #include <stdio.h> | 24 #include <stdio.h> |
25 #include <boost/math/constants/constants.hpp> | 25 #include <boost/math/constants/constants.hpp> |
26 | 26 |
27 namespace OrthancStone | 27 namespace Deprecated |
28 { | 28 { |
29 CircleMeasureTracker::CircleMeasureTracker(IStatusBar* statusBar, | 29 CircleMeasureTracker::CircleMeasureTracker(IStatusBar* statusBar, |
30 const CoordinateSystem3D& slice, | 30 const OrthancStone::CoordinateSystem3D& slice, |
31 double x, | 31 double x, |
32 double y, | 32 double y, |
33 uint8_t red, | 33 uint8_t red, |
34 uint8_t green, | 34 uint8_t green, |
35 uint8_t blue, | 35 uint8_t blue, |
46 color_[1] = green; | 46 color_[1] = green; |
47 color_[2] = blue; | 47 color_[2] = blue; |
48 } | 48 } |
49 | 49 |
50 | 50 |
51 void CircleMeasureTracker::Render(CairoContext& context, | 51 void CircleMeasureTracker::Render(OrthancStone::CairoContext& context, |
52 double zoom) | 52 double zoom) |
53 { | 53 { |
54 double x = (x1_ + x2_) / 2.0; | 54 double x = (x1_ + x2_) / 2.0; |
55 double y = (y1_ + y2_) / 2.0; | 55 double y = (y1_ + y2_) / 2.0; |
56 | 56 |
57 Vector tmp; | 57 OrthancStone::Vector tmp; |
58 LinearAlgebra::AssignVector(tmp, x2_ - x1_, y2_ - y1_); | 58 OrthancStone::LinearAlgebra::AssignVector(tmp, x2_ - x1_, y2_ - y1_); |
59 double r = boost::numeric::ublas::norm_2(tmp) / 2.0; | 59 double r = boost::numeric::ublas::norm_2(tmp) / 2.0; |
60 | 60 |
61 context.SetSourceColor(color_[0], color_[1], color_[2]); | 61 context.SetSourceColor(color_[0], color_[1], color_[2]); |
62 | 62 |
63 cairo_t* cr = context.GetObject(); | 63 cairo_t* cr = context.GetObject(); |
67 cairo_arc(cr, 0, 0, r, 0, 2.0 * boost::math::constants::pi<double>()); | 67 cairo_arc(cr, 0, 0, r, 0, 2.0 * boost::math::constants::pi<double>()); |
68 cairo_stroke_preserve(cr); | 68 cairo_stroke_preserve(cr); |
69 cairo_stroke(cr); | 69 cairo_stroke(cr); |
70 cairo_restore(cr); | 70 cairo_restore(cr); |
71 | 71 |
72 context.DrawText(font_, FormatRadius(), x, y, BitmapAnchor_Center); | 72 context.DrawText(font_, FormatRadius(), x, y, OrthancStone::BitmapAnchor_Center); |
73 } | 73 } |
74 | 74 |
75 | 75 |
76 double CircleMeasureTracker::GetRadius() const // In millimeters | 76 double CircleMeasureTracker::GetRadius() const // In millimeters |
77 { | 77 { |
78 Vector a = slice_.MapSliceToWorldCoordinates(x1_, y1_); | 78 OrthancStone::Vector a = slice_.MapSliceToWorldCoordinates(x1_, y1_); |
79 Vector b = slice_.MapSliceToWorldCoordinates(x2_, y2_); | 79 OrthancStone::Vector b = slice_.MapSliceToWorldCoordinates(x2_, y2_); |
80 return boost::numeric::ublas::norm_2(b - a) / 2.0; | 80 return boost::numeric::ublas::norm_2(b - a) / 2.0; |
81 } | 81 } |
82 | 82 |
83 | 83 |
84 std::string CircleMeasureTracker::FormatRadius() const | 84 std::string CircleMeasureTracker::FormatRadius() const |