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

path_text_element.cpp « graphics - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a2b20d912c9e13a7a04680997c386bee9904a980 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "../base/SRC_FIRST.hpp"
#include "path_text_element.hpp"
#include "overlay_renderer.hpp"

namespace graphics
{
  PathTextElement::Params::Params()
    : m_pts(0),
      m_ptsCount(0),
      m_fullLength(0),
      m_pathOffset(0),
      m_textOffset(0)
  {}

  PathTextElement::PathTextElement(Params const & p)
    : TextElement(p),
      m_glyphLayout(p.m_glyphCache,
        p.m_fontDesc,
        p.m_pts,
        p.m_ptsCount,
        visText(),
        p.m_fullLength,
        p.m_pathOffset,
        p.m_textOffset)
  {
    setPivot(m_glyphLayout.pivot());
    setIsValid((m_glyphLayout.firstVisible() == 0) && (m_glyphLayout.lastVisible() == visText().size()));
  }

  vector<m2::AnyRectD> const & PathTextElement::boundRects() const
  {
    if (isDirtyRect())
    {
      m_boundRects.clear();
      m_boundRects.reserve(m_glyphLayout.boundRects().size());

      for (unsigned i = 0; i < m_glyphLayout.boundRects().size(); ++i)
        m_boundRects.push_back(m_glyphLayout.boundRects()[i]);

      //for (unsigned i = 0; i < m_boundRects.size(); ++i)
      //  m_boundRects[i] = m2::Inflate(m_boundRects[i], m2::PointD(10, 10));
      //m_boundRects[i].m2::Inflate(m2::PointD(40, 2)); //< to create more sparse street names structure
      setIsDirtyRect(false);
    }

    return m_boundRects;
  }

  void PathTextElement::draw(OverlayRenderer * screen, math::Matrix<double, 3, 3> const & m) const
  {
    int doffs = 0;
    if (screen->isDebugging())
    {
      graphics::Color c(255, 255, 255, 32);

      if (isFrozen())
        c = graphics::Color(0, 0, 255, 64);
      if (isNeedRedraw())
        c = graphics::Color(255, 0, 0, 64);

      screen->drawRectangle(roughBoundRect(), graphics::Color(255, 255, 0, 64), depth() + doffs++);

      for (unsigned i = 0; i < boundRects().size(); ++i)
        screen->drawRectangle(boundRects()[i], c, depth() + doffs++);
    }

    if (!isNeedRedraw() || !isVisible() || !isValid())
      return;

    graphics::FontDesc desc = m_fontDesc;

    if (desc.m_isMasked)
    {
      drawTextImpl(m_glyphLayout, screen, m, false, false, desc, depth() + doffs++);
      desc.m_isMasked = false;
    }

    drawTextImpl(m_glyphLayout, screen, m, false, false, desc, depth() + doffs++);
  }

  void PathTextElement::setPivot(m2::PointD const & pivot)
  {
    TextElement::setPivot(pivot);
    m_glyphLayout.setPivot(pivot);
  }

  void PathTextElement::setTransformation(const math::Matrix<double, 3, 3> & m)
  {
    m_glyphLayout = GlyphLayout(m_glyphLayout, getResetMatrix() * m);
    TextElement::setPivot(m_glyphLayout.pivot());
    setIsValid((m_glyphLayout.firstVisible() == 0) && (m_glyphLayout.lastVisible() == visText().size()));
    TextElement::setTransformation(m);
  }
}