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
|
#ifndef MBGL_MAP_TRANSFORM
#define MBGL_MAP_TRANSFORM
#include <mbgl/map/camera.hpp>
#include <mbgl/map/mode.hpp>
#include <mbgl/map/transform_state.hpp>
#include <mbgl/map/update.hpp>
#include <mbgl/util/chrono.hpp>
#include <mbgl/util/geo.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <cstdint>
#include <cmath>
#include <functional>
namespace mbgl {
class View;
class Transform : private util::noncopyable {
public:
Transform(View&, ConstrainMode);
// Map view
bool resize(std::array<uint16_t, 2> size);
void jumpTo(const CameraOptions&);
void easeTo(const CameraOptions&);
// Position
void moveBy(const PrecisionPoint&, const Duration& = Duration::zero());
void setLatLng(const LatLng&, const Duration& = Duration::zero());
void setLatLng(const LatLng&, const PrecisionPoint&, const Duration& = Duration::zero());
void setLatLngZoom(const LatLng&, double zoom, const Duration& = Duration::zero());
LatLng getLatLng() const { return state.getLatLng(); }
// Zoom
void scaleBy(double ds, const PrecisionPoint& center = { 0, 0 }, const Duration& = Duration::zero());
void setScale(double scale, const PrecisionPoint& center = { 0, 0 }, const Duration& = Duration::zero());
void setZoom(double zoom, const Duration& = Duration::zero());
double getZoom() const;
double getScale() const;
// Angle
void rotateBy(const PrecisionPoint& first, const PrecisionPoint& second, const Duration& = Duration::zero());
void setAngle(double angle, const Duration& = Duration::zero());
void setAngle(double angle, const PrecisionPoint& center);
double getAngle() const;
// Pitch
void setPitch(double pitch, const Duration& = Duration::zero());
double getPitch() const;
// Transitions
bool inTransition() const;
Update updateTransitions(const TimePoint& now);
void cancelTransitions();
// Gesture
void setGestureInProgress(bool);
bool isGestureInProgress() const { return state.isGestureInProgress(); }
// Transform state
TransformState getState() const { return state; }
bool isRotating() const { return state.isRotating(); }
bool isScaling() const { return state.isScaling(); }
bool isPanning() const { return state.isPanning(); }
private:
void _moveBy(const PrecisionPoint&, const Duration& = Duration::zero());
void _setScale(double scale, const PrecisionPoint& center, const Duration& = Duration::zero());
void _setScaleXY(double new_scale, double xn, double yn, const Duration& = Duration::zero());
void _easeTo(const CameraOptions&, double new_scale, double new_angle, double xn, double yn);
void _setAngle(double angle, const Duration& = Duration::zero());
View &view;
TransformState state;
void startTransition(std::function<double(double)> easing,
std::function<Update(double)> frame,
std::function<void()> finish,
const Duration& duration);
TimePoint transitionStart;
Duration transitionDuration;
std::function<Update(const TimePoint)> transitionFrameFn;
std::function<void()> transitionFinishFn;
};
} // namespace mbgl
#endif
|