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: 8e09f139685ae35c6e7181ac777cdcebbb1e308c (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
#pragma once

#include "qt/qtoglcontextfactory.hpp"

#include "map/framework.hpp"
#include "map/navigator.hpp"

#include "drape_frontend/drape_engine.hpp"

#include "base/deferred_task.hpp"

#include "std/unique_ptr.hpp"

#include <QtGui/QWindow>


namespace qt
{
  class QScaleSlider;

  class DrawWidget : public QWindow
  {
    typedef QWindow TBase;

    dp::MasterPointer<dp::OGLContextFactory> m_contextFactory;
    unique_ptr<Framework> m_framework;

    bool m_isDrag;
    bool m_isRotate;

    qreal m_ratio;

    inline int L2D(int px) const { return px * m_ratio; }
    inline m2::PointD GetDevicePoint(QMouseEvent * e) const;
    DragEvent GetDragEvent(QMouseEvent * e) const;
    RotateEvent GetRotateEvent(QPoint const & pt) const;

    Q_OBJECT

  public Q_SLOTS:
    void MoveLeft();
    void MoveRight();
    void MoveUp();
    void MoveDown();

    void ScalePlus();
    void ScaleMinus();
    void ScalePlusLight();
    void ScaleMinusLight();

    void ShowAll();
    void ScaleChanged(int action);

  public:
    DrawWidget(QWidget * pParent);
    ~DrawWidget();

    void SetScaleControl(QScaleSlider * pScale);

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

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

    void SaveState();
    void LoadState();

    void UpdateAfterSettingsChanged();

    void PrepareShutdown();

    Framework & GetFramework() { return *m_framework.get(); }

    void SetMapStyle(MapStyle mapStyle);

    void SetRouter(routing::RouterType routerType);

  protected:
    void StartPressTask(m2::PointD const & pt, unsigned ms);
    void KillPressTask();
    void OnPressTaskEvent(m2::PointD const & pt, unsigned ms);
    void OnActivateMark(unique_ptr<UserMarkCopy> pCopy);

    void CreateEngine();

  protected:
    /// @name Overriden from QWidget.
    //@{
    virtual void exposeEvent(QExposeEvent * e);
    virtual void mousePressEvent(QMouseEvent * e);
    virtual void mouseDoubleClickEvent(QMouseEvent * e);
    virtual void mouseMoveEvent(QMouseEvent * e);
    virtual void mouseReleaseEvent(QMouseEvent * e);
    virtual void wheelEvent(QWheelEvent * e);
    virtual void keyReleaseEvent(QKeyEvent * e);
    //@}

    Q_SLOT void sizeChanged(int);

  private:
    void UpdateScaleControl();
    void StopDragging(QMouseEvent * e);
    void StopRotating(QMouseEvent * e);
    void StopRotating(QKeyEvent * e);

    QScaleSlider * m_pScale;

    unique_ptr<DeferredTask> m_deferredTask;
    m2::PointD m_taskPoint;
    bool m_wasLongClick, m_isCleanSingleClick;

    bool m_emulatingLocation;

    PinClickManager & GetBalloonManager() { return m_framework->GetBalloonManager(); }

    void InitRenderPolicy();
  };
}