Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ruler.hpp « map - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c04da25ced491ba21a7637bd3173cafbbc3f20e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#pragma once

#include "../geometry/screenbase.hpp"
#include "../geometry/point2d.hpp"
#include "../geometry/any_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;

  mutable vector<m2::AnyRectD> m_boundRects;

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);

  vector<m2::AnyRectD> const & boundRects() const;

  void draw(yg::gl::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const;

  void map(yg::StylesCache * stylesCache) const;
  bool find(yg::StylesCache * stylesCache) const;
  void fillUnpacked(yg::StylesCache * stylesCache, vector<m2::PointU> & v) const;

  int visualRank() const;
  yg::OverlayElement * clone(math::Matrix<double, 3, 3> const & m) const;
};