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

overlay_element.hpp « graphics - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e8471a2627f1c59ce83ce037885d9476696e1d88 (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#pragma once

#include "../geometry/point2d.hpp"
#include "../geometry/any_rect2d.hpp"
#include "../base/matrix.hpp"
#include "defines.hpp"
#include "../std/vector.hpp"

namespace graphics
{
  class OverlayRenderer;

  class OverlayElement
  {
  public:

    struct UserInfo
    {
      size_t m_mwmID;
      uint32_t m_offset;

      UserInfo() : m_mwmID(size_t(-1)) {}
      inline bool IsValid() const { return (m_mwmID != size_t(-1)); }
      inline bool operator== (UserInfo const & a) const
      {
        return IsValid() && (a.m_mwmID == m_mwmID) && (a.m_offset == m_offset);
      }
    };

  private:

    m2::PointD m_pivot;
    graphics::EPosition m_position;
    double m_depth;    

    bool m_isNeedRedraw;
    bool m_isFrozen;
    bool m_isVisible;
    bool m_isValid;
    mutable bool m_isDirtyRect;
    mutable bool m_isDirtyLayout;

    mutable bool m_isDirtyRoughRect;
    mutable m2::RectD m_roughBoundRect;

    math::Matrix<double, 3, 3> m_inverseMatrix;

  protected:
    math::Matrix<double, 3, 3> const & getResetMatrix() const;

  public:

    UserInfo m_userInfo;
    static m2::PointD const computeTopLeft(m2::PointD const & sz,
                                           m2::PointD const & pv,
                                           EPosition pos);

    struct Params
    {
      m2::PointD m_pivot;
      graphics::EPosition m_position;
      double m_depth;
      UserInfo m_userInfo;
      Params();
    };

    OverlayElement(Params const & p);
    virtual ~OverlayElement();

    /// PLEASE, REMEMBER THE REFERENCE!!!
    virtual vector<m2::AnyRectD> const & boundRects() const = 0;
    virtual void draw(OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const = 0;
    /// Set new transformation ! RELATIVE TO INIT STATE ! for drawing and safe information for reseting
    /// Need to call base class method
    virtual void setTransformation(math::Matrix<double, 3, 3> const & m) = 0;
    /// This method reset transformation to initial state.
    /// Geometry stored in coordinates relative to the tile.
    /// Need to call base class method
    virtual void resetTransformation();

    virtual double priority() const;

    m2::PointD const & pivot() const;
    virtual void setPivot(m2::PointD const & pv);

    m2::PointD const point(EPosition pos) const;

    void offset(m2::PointD const & offs);

    graphics::EPosition position() const;
    void setPosition(graphics::EPosition pos);

    double depth() const;
    void setDepth(double depth);

    bool isFrozen() const;
    void setIsFrozen(bool flag);

    bool isNeedRedraw() const;
    void setIsNeedRedraw(bool flag);

    bool isDirtyRect() const;
    void setIsDirtyRect(bool flag) const;

    bool isDirtyLayout() const;
    void setIsDirtyLayout(bool flag) const;

    bool isVisible() const;
    void setIsVisible(bool flag);

    bool isValid() const;
    void setIsValid(bool flag);

    m2::PointD getOffset() const;
    void setOffset(m2::PointD offset);

    UserInfo const & userInfo() const;

    virtual bool hitTest(m2::PointD const & pt) const;
    virtual bool roughHitTest(m2::PointD const & pt) const;

    m2::RectD const & roughBoundRect() const;

    virtual bool hasSharpGeometry() const;
  };

}