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

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

#include "geometry/polyline2d.hpp"
#include "geometry/screenbase.hpp"

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

#include "std/noncopyable.hpp"

#include "base/buffer_vector.hpp"


class Navigator;
namespace graphics
{
  class Screen;
  class DisplayList;
}
namespace location
{
  class RouteMatchingInfo;
}

template <class T> class DoLeftProduct
{
  T const & m_t;
public:
  DoLeftProduct(T const & t) : m_t(t) {}
  template <class X> X operator() (X const & x) const { return x * m_t; }
};

typedef math::Matrix<double, 3, 3> MatrixT;
typedef buffer_vector<m2::PointD, 32> PointContainerT;

class Track : private noncopyable
{
public:
  typedef m2::PolylineD PolylineD;

  Track() {}
  virtual ~Track();

  explicit Track(PolylineD const & polyline)
    : m_polyline(polyline)
  {
    ASSERT_GREATER(polyline.GetSize(), 1, ());

    m_rect = m_polyline.GetLimitRect();
  }

  /// @note Move semantics is used here.
  virtual Track * CreatePersistent();
  float GetMainWidth() const;
  graphics::Color const & GetMainColor() const;

  virtual void Draw(graphics::Screen * pScreen, MatrixT const & matrix) const;
  virtual void CreateDisplayList(graphics::Screen * dlScreen, MatrixT const & matrix, bool isScaleChanged,
                         int, double, location::RouteMatchingInfo const &) const;
  virtual void CleanUp() const;
  virtual bool HasDisplayLists() const;

  /// @name Simple Getters-Setter
  //@{

  struct TrackOutline
  {
    float m_lineWidth;
    graphics::Color m_color;
  };

  void AddOutline(TrackOutline const * outline, size_t arraySize);

  string const & GetName() const { return m_name; }
  void SetName(string const & name) { m_name = name; }

  PolylineD const & GetPolyline() const { return m_polyline; }
  m2::RectD const & GetLimitRect() const { return m_rect; }
  //@}
  double GetLengthMeters() const;

protected:
  graphics::DisplayList * GetDisplayList() const { return m_dList; }
  void SetDisplayList(graphics::DisplayList * dl) const { m_dList = dl; }
  void CreateDisplayListPolyline(graphics::Screen * dlScreen, PointContainerT const & pts2) const;
  void Swap(Track & rhs);
  void DeleteDisplayList() const;

private:
  string m_name;

  vector<TrackOutline> m_outlines;
  PolylineD m_polyline;
  m2::RectD m_rect;

  mutable graphics::DisplayList * m_dList = nullptr;
};

void TransformPolyline(Track::PolylineD const & polyline, MatrixT const & matrix, PointContainerT & pts);
void TransformAndSymplifyPolyline(Track::PolylineD const & polyline, MatrixT const & matrix,
                                  double width, PointContainerT & pts);