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

screen_qt.hpp « qt_tstfrm - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fbf5e11ad040737bed11f4acfb5f895359fe6208 (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
#pragma once

#include "../geometry/screenbase.hpp"
#include "../geometry/rect2d.hpp"
#include "../geometry/point2d.hpp"

#include <QtCore/QPoint>

class QPainter;

namespace qt
{
  class Screen
  {
    QPainter * m_p;
    ScreenBase m_convertor;

    void drawPathImpl(vector<QPoint> const & path);

    template <class T>
    inline QPoint qpoint(std::pair<T, T> const & p) const
    {
      m2::PointD pp = m_convertor.GtoP(m2::PointD(p.first, p.second));
      return QPoint(pp.x, pp.y);
    }
    inline QPoint qpoint(m2::PointD const & p) const
    {
      m2::PointD pp = m_convertor.GtoP(p);
      return QPoint(pp.x, pp.y);
    }

  public:
    void setPainter(QPainter * p) { m_p = p; }
    void onSize(int w, int h) { m_convertor.OnSize(0, 0, w, h); }
    void setFromRect(m2::RectD const & r) { m_convertor.SetFromRect(m2::AnyRectD(r)); }

    template <class TCont> void drawPath(TCont const & c)
    {
      vector<QPoint> qvec;
      qvec.reserve(c.size());
      for (typename TCont::const_iterator i = c.begin(); i != c.end(); ++i)
        qvec.push_back(qpoint(*i));

      drawPathImpl(qvec);
    }

    void drawLine(m2::PointD const & p1, m2::PointD const & p2);

    void drawRect(m2::RectD const & r);
    void hatchRect(m2::RectD const & r);
  };
}