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: 4c6c0441f1278d774aad0adf3f5be9dd0f702254 (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
128
129
#pragma once

#include "graphics/defines.hpp"
#include "graphics/color.hpp"

#include "indexer/feature_decl.hpp"

#include "geometry/point2d.hpp"
#include "geometry/any_rect2d.hpp"

#include "base/matrix.hpp"
#include "base/buffer_vector.hpp"

#include "std/bitset.hpp"


namespace graphics
{
  class OverlayRenderer;

  class OverlayElement
  {
  public:
    struct UserInfo
    {
      FeatureID m_featureID;

      inline bool IsValid() const { return m_featureID.IsValid(); }
      inline bool operator== (UserInfo const & r) const
      {
        return (IsValid() && m_featureID == r.m_featureID);
      }
    };

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

    enum { NEED_REDRAW,
           FROZEN,
           VISIBLE,
           VALID,
           DIRTY_LAYOUT,
           FLAGS_COUNT };

    mutable bitset<FLAGS_COUNT> m_flags;

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

    /// @name Getting element boundaries.
    //@{
    virtual m2::RectD GetBoundRect() const;
    typedef buffer_vector<m2::AnyRectD, 4> RectsT;
    virtual void GetMiniBoundRects(RectsT & rects) const;
    //@}

    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, bool dirtyFlag = true);

    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 isDirtyLayout() const;
    virtual void setIsDirtyLayout(bool flag) const;

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

    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 hasSharpGeometry() const;

    void DrawRectsDebug(graphics::OverlayRenderer * r, Color color, double depth) const;
  };
}