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

draw_widget.hpp « qt - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: dbc5bee990983d3e959e7f4a712bcaf62d7813c0 (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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#pragma once

#include "qt/qt_common/map_widget.hpp"

#include "map/everywhere_search_params.hpp"
#include "map/place_page_info.hpp"
#include "map/routing_manager.hpp"

#include "search/result.hpp"

#include "routing/router.hpp"

#include "drape_frontend/gui/skin.hpp"

#include "drape_frontend/drape_engine.hpp"

#include <condition_variable>
#include <memory>
#include <mutex>

#include "boost/optional.hpp"

#include <QtWidgets/QRubberBand>

class Framework;
class QQuickWindow;

namespace qt
{
namespace common
{
class ScaleSlider;
}

class Screenshoter;
struct ScreenshotParams;

class DrawWidget : public qt::common::MapWidget
{
  using TBase = MapWidget;

  Q_OBJECT

public Q_SLOTS:
  void ShowAll();

  void ChoosePositionModeEnable();
  void ChoosePositionModeDisable();
  void OnUpdateCountryStatusByTimer();

public:
  DrawWidget(Framework & framework, bool apiOpenGLES3, std::unique_ptr<ScreenshotParams> && screenshotParams,
             QWidget * parent);
  ~DrawWidget() override;

  bool Search(search::EverywhereSearchParams const & params);
  string GetDistance(search::Result const & res) const;
  void ShowSearchResult(search::Result const & res);

  void CreateFeature();

  void OnLocationUpdate(location::GpsInfo const & info);

  void UpdateAfterSettingsChanged();

  void PrepareShutdown();

  Framework & GetFramework() { return m_framework; }

  void SetMapStyle(MapStyle mapStyle);

  void SetRouter(routing::RouterType routerType);

  using TCurrentCountryChanged = function<void(storage::CountryId const &, string const &,
                                               storage::Status, uint64_t, uint8_t)>;
  void SetCurrentCountryChangedListener(TCurrentCountryChanged const & listener);

  void DownloadCountry(storage::CountryId const & countryId);
  void RetryToDownloadCountry(storage::CountryId const & countryId);

  RouteMarkType GetRoutePointAddMode() const { return m_routePointAddMode; }
  void SetRoutePointAddMode(RouteMarkType mode) { m_routePointAddMode = mode; }
  void FollowRoute();
  void ClearRoute();
  void OnRouteRecommendation(RoutingManager::Recommendation recommendation);

  void RefreshDrawingRules();

  static void SetDefaultSurfaceFormat(bool apiOpenGLES3);

protected:
  /// @name Overriden from MapWidget.
  //@{
  void initializeGL() override;

  void mousePressEvent(QMouseEvent * e) override;
  void mouseMoveEvent(QMouseEvent * e) override;
  void mouseReleaseEvent(QMouseEvent * e) override;
  void keyPressEvent(QKeyEvent * e) override;
  void keyReleaseEvent(QKeyEvent * e) override;

  void OnViewportChanged(ScreenBase const & screen) override;
  //@}
private:
  void SubmitFakeLocationPoint(m2::PointD const & pt);
  void SubmitRoutingPoint(m2::PointD const & pt);
  void SubmitBookmark(m2::PointD const & pt);
  void ShowPlacePage(place_page::Info const & info);

  void UpdateCountryStatus(storage::CountryId const & countryId);

  void VisualizeMwmsBordersInRect(m2::RectD const & rect, bool withPoints, bool fromPackedPolygon);

  m2::PointD GetCoordsFromSettingsIfExists(bool start, m2::PointD const & pt);

  QRubberBand * m_rubberBand;
  QPoint m_rubberBandOrigin;

  bool m_emulatingLocation;

  TCurrentCountryChanged m_currentCountryChanged;
  storage::CountryId m_countryId;

public:
  enum class SelectionMode
  {
    Features,
    CityBoundaries,
    CityRoads,
    MwmsBordersByPolyFiles,
    MwmsBordersWithPointsByPolyFiles,
    MwmsBordersByPackedPolygon,
    MwmsBordersWithPointsByPackedPolygon
  };

  void SetSelectionMode(SelectionMode mode) { m_currentSelectionMode = {mode}; }
  void DropSelectionMode() { m_currentSelectionMode = {}; }
  bool SelectionModeIsSet() { return static_cast<bool>(m_currentSelectionMode); }
  SelectionMode GetSelectionMode() const { return *m_currentSelectionMode; }

private:
  boost::optional<SelectionMode> m_currentSelectionMode;
  RouteMarkType m_routePointAddMode = RouteMarkType::Finish;

  std::unique_ptr<Screenshoter> m_screenshoter;
};
}  // namespace qt