MapLibre Native Core
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
camera.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <mbgl/util/chrono.hpp>
4 #include <mbgl/util/geo.hpp>
6 #include <mbgl/util/vectors.hpp>
7 
8 #include <optional>
9 
10 #include <functional>
11 
12 namespace mbgl {
13 
19 struct CameraOptions {
20  CameraOptions& withCenter(const std::optional<LatLng>& o) { center = o; return *this; }
21  CameraOptions& withPadding(const std::optional<EdgeInsets>& p) { padding = p; return *this; }
22  CameraOptions& withAnchor(const std::optional<ScreenCoordinate>& o) { anchor = o; return *this; }
23  CameraOptions& withZoom(const std::optional<double>& o) { zoom = o; return *this; }
24  CameraOptions& withBearing(const std::optional<double>& o) { bearing = o; return *this; }
25  CameraOptions& withPitch(const std::optional<double>& o) { pitch = o; return *this; }
26 
28  std::optional<LatLng> center;
29 
32  std::optional<EdgeInsets> padding;
33 
36  std::optional<ScreenCoordinate> anchor;
37 
40  std::optional<double> zoom;
41 
43  std::optional<double> bearing;
44 
47  std::optional<double> pitch;
48 };
49 
50 constexpr bool operator==(const CameraOptions& a, const CameraOptions& b) {
51  return a.center == b.center
52  && a.padding == b.padding
53  && a.anchor == b.anchor
54  && a.zoom == b.zoom
55  && a.bearing == b.bearing
56  && a.pitch == b.pitch;
57 }
58 
59 constexpr bool operator!=(const CameraOptions& a, const CameraOptions& b) {
60  return !(a == b);
61 }
62 
68  std::optional<Duration> duration;
69 
75  std::optional<double> velocity;
76 
79  std::optional<double> minZoom;
80 
82  std::optional<mbgl::util::UnitBezier> easing;
83 
87  std::function<void(double)> transitionFrameFn;
88 
91  std::function<void()> transitionFinishFn;
92 
94  AnimationOptions() = default;
95 
98  : duration(d) {}
99 };
100 
111  std::optional<vec3> position = std::nullopt;
112 
123  std::optional<vec4> orientation = std::nullopt;
124 
126  void setLocation(const LatLngAltitude& location);
127 
130  std::optional<LatLngAltitude> getLocation() const;
131 
135  void lookAtPoint(const LatLng& location, const std::optional<vec3>& upVector = std::nullopt);
136 
139  void setPitchBearing(double pitch, double bearing);
140 };
141 
142 } // namespace mbgl
Definition: actor.hpp:15
constexpr bool operator==(const CameraOptions &a, const CameraOptions &b)
Definition: camera.hpp:50
constexpr bool operator!=(const CameraOptions &a, const CameraOptions &b)
Definition: camera.hpp:59
Clock::duration Duration
Definition: chrono.hpp:18
std::optional< double > velocity
Definition: camera.hpp:75
AnimationOptions(Duration d)
Definition: camera.hpp:97
std::optional< double > minZoom
Definition: camera.hpp:79
std::optional< Duration > duration
Definition: camera.hpp:68
std::optional< mbgl::util::UnitBezier > easing
Definition: camera.hpp:82
std::function< void(double)> transitionFrameFn
Definition: camera.hpp:87
std::function< void()> transitionFinishFn
Definition: camera.hpp:91
std::optional< EdgeInsets > padding
Definition: camera.hpp:32
std::optional< ScreenCoordinate > anchor
Definition: camera.hpp:36
std::optional< double > bearing
Definition: camera.hpp:43
CameraOptions & withPadding(const std::optional< EdgeInsets > &p)
Definition: camera.hpp:21
CameraOptions & withAnchor(const std::optional< ScreenCoordinate > &o)
Definition: camera.hpp:22
std::optional< double > pitch
Definition: camera.hpp:47
std::optional< double > zoom
Definition: camera.hpp:40
std::optional< LatLng > center
Definition: camera.hpp:28
CameraOptions & withZoom(const std::optional< double > &o)
Definition: camera.hpp:23
CameraOptions & withCenter(const std::optional< LatLng > &o)
Definition: camera.hpp:20
CameraOptions & withPitch(const std::optional< double > &o)
Definition: camera.hpp:25
CameraOptions & withBearing(const std::optional< double > &o)
Definition: camera.hpp:24
std::optional< LatLngAltitude > getLocation() const
std::optional< vec3 > position
Definition: camera.hpp:111
void lookAtPoint(const LatLng &location, const std::optional< vec3 > &upVector=std::nullopt)
void setPitchBearing(double pitch, double bearing)
std::optional< vec4 > orientation
Definition: camera.hpp:123
void setLocation(const LatLngAltitude &location)