diff options
author | rachytski <siarhei.rachytski@gmail.com> | 2011-09-14 19:57:03 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:23:48 +0300 |
commit | 97a982f9843009f20b3ed7432707f65403b0dd09 (patch) | |
tree | b08893ad4740ee0cd144b0adefd19f79525a1baa /map/ruler.hpp | |
parent | ba950b9fb63abf54a321d532b8c8a1d4a37de9d8 (diff) |
added separate Ruler class.
Diffstat (limited to 'map/ruler.hpp')
-rw-r--r-- | map/ruler.hpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/map/ruler.hpp b/map/ruler.hpp new file mode 100644 index 0000000000..ee57ac38c8 --- /dev/null +++ b/map/ruler.hpp @@ -0,0 +1,67 @@ +#pragma once + +#include "../geometry/screenbase.hpp" +#include "../geometry/point2d.hpp" +#include "../geometry/aa_rect2d.hpp" +#include "../yg/overlay_element.hpp" +#include "../yg/font_desc.hpp" + +namespace yg +{ + class StylesCache; + + namespace gl + { + class Screen; + class OverlayRenderer; + } +} + +class Ruler : public yg::OverlayElement +{ +private: + + unsigned m_minPxWidth; + unsigned m_maxPxWidth; + + double m_minUnitsWidth; + double m_maxUnitsWidth; + double m_visualScale; + + yg::FontDesc m_fontDesc; + ScreenBase m_screen; + + float m_unitsDiff; //< current diff in units between two endpoints of the ruler. + string m_scalerText; + vector<m2::PointD> m_path; + + m2::RectD m_boundRect; + + unsigned ceil(double unitsDiff); + + typedef OverlayElement base_t; + +public: + + void update(); //< update internal params after some other params changed. + + struct Params : public base_t::Params + { + }; + + Ruler(Params const & p); + + void setScreen(ScreenBase const & screen); + ScreenBase const & screen() const; + + void setMinPxWidth(unsigned minPxWidth); + void setMinUnitsWidth(double minUnitsWidth); + void setMaxUnitsWidth(double maxUnitsWidth); + void setVisualScale(double visualScale); + void setFontDesc(yg::FontDesc const & fontDesc); + + m2::AARectD const boundRect() const; + void draw(yg::gl::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const; + + void cache(yg::StylesCache * stylesCache); +}; |