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

#include "widgets.hpp"

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

#include "../platform/video_timer.hpp"

#include "../std/scoped_ptr.hpp"

#include <QtCore/QTimer>

namespace qt
{
  class QScaleSlider;

  class DrawWidget;

  class QtVideoTimer : public ::VideoTimer
  {
  private:

    QTimer * m_timer;
    DrawWidget * m_widget;

  public:

    QtVideoTimer(DrawWidget * w, ::VideoTimer::TFrameFn frameFn);

    void resume();
    void pause();

    void start();
    void stop();
  };

  class DrawWidget : public QGLWidget
  {
    typedef model::FeaturesFetcher model_t;

    bool m_isInitialized;
    bool m_isTimerStarted;

    scoped_ptr<Framework<model_t> > m_framework;

    bool m_isDrag;
    bool m_isRotate;

    QTimer * m_timer;
    QTimer * m_animTimer;
    size_t m_redrawInterval;

    Q_OBJECT

  signals:
    void ViewportChanged();

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

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

    void ShowAll();
    void Repaint();
    void ScaleChanged(int action);
    void ScaleTimerElapsed();
    void AnimTimerElapsed();

  public:
    DrawWidget(QWidget * pParent);

    void SetScaleControl(QScaleSlider * pScale);

    void Search(string const & text, SearchCallbackT callback);
    void ShowFeature(m2::RectD const & rect);

    void SaveState();
    /// @return false if can't load previously saved values
    bool LoadState();

    void UpdateNow();
    void UpdateAfterSettingsChanged();

    void PrepareShutdown();

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

  protected:

    VideoTimer * CreateVideoTimer();

    static const uint32_t ini_file_version = 0;

  protected:

    /// @name Overriden from base_type.
    //@{
    virtual void initializeGL();
    virtual void resizeGL(int w, int h);
    virtual void paintGL();
    //@}

    void DrawFrame();

    /// @name Overriden from QWidget.
    //@{
    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);
    //@}

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

    QScaleSlider * m_pScale;
  };
}