forked from sam-itt/sofis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap-gauge.h
99 lines (80 loc) · 2.63 KB
/
map-gauge.h
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
/*
* SPDX-FileCopyrightText: 2021 Samuel Cuella <[email protected]>
*
* This file is part of SoFIS - an open source EFIS
*
* SPDX-License-Identifier: GPL-2.0-only
*/
#ifndef MAP_GAUGE_H
#define MAP_GAUGE_H
#include "base-gauge.h"
#include "generic-layer.h"
#include "map-tile-cache.h"
#include "map-provider.h"
#include "route-map-provider.h"
#include "data-source.h"
#include "misc.h"
/* int(32) pixel coordinates go up to
* 2,147,483,647 which is the maximum coordinate
* of level 23
*/
#define MAP_GAUGE_MAX_LEVEL 23
typedef struct{
/*TODO: Array of pointers to layers, as much as providers/overlays*/
GenericLayer *layer;
SDL_Rect src;
SDL_Rect dst;
}MapPatch;
typedef struct{
MapPatch *patches;
size_t apatches;
size_t npatches;
SDL_Rect marker_src;
SDL_Rect marker_dst;
}MapGaugeState;
typedef struct{
GenericLayer layer;
/* Marker position in "world" coordinates
* world coordinates are respective to the
* current level.
*
* Note: this is the point marked, the icon
* itself is centered on these coordinates
*/
int32_t x;
int32_t y;
float heading;
}MapGaugeMarker;
typedef struct{
BaseGauge super;
MapTileCache tile_cache;
/*current zoom level*/
uintf8_t level;
/*Top-left coordinates of the viewport*/
int32_t world_x;
int32_t world_y;
/*The little plane on the map*/
MapGaugeMarker marker;
bool roaming; /*The view is roaming around and not tied to the marker*/
Uint32 last_manipulation;
MapProvider *tile_providers[2]; /*static for now*/
size_t ntile_providers;
MapProvider *overlays[1]; /*static for now*/
size_t noverlays;
RouteMapProvider *route_overlay;
MapGaugeState state;
}MapGauge;
MapGauge *map_gauge_new(int w, int h);
MapGauge *map_gauge_init(MapGauge *self, int w, int h);
bool map_gauge_set_level(MapGauge *self, uintf8_t level);
bool map_gauge_set_marker_position(MapGauge *self, double latitude, double longitude);
bool map_gauge_set_marker_heading(MapGauge *self, float heading);
bool map_gauge_manipulate_viewport(MapGauge *self, int32_t dx, int32_t dy, bool animated);
bool map_gauge_center_on_marker(MapGauge *self, bool animated);
bool map_gauge_follow_marker(MapGauge *self);
bool map_gauge_move_viewport(MapGauge *self, int32_t dx, int32_t dy, bool animated);
bool map_gauge_set_viewport(MapGauge *self, int32_t x, int32_t y, bool animated);
void map_gauge_location_changed(MapGauge *self, LocationData *newv);
void map_gauge_attitude_changed(MapGauge *self, AttitudeData *newv);
void map_gauge_route_changed(MapGauge *self, RouteData *newv);
#endif /* MAP_GAUGE_H */