Contents of /trunk/src/map.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 246 - (hide annotations)
Mon Jul 27 15:02:00 2009 UTC (14 years, 10 months ago) by harbaum
File MIME type: text/plain
File size: 6455 byte(s)
Detail popup work
1 harbaum 1 /*
2     * Copyright (C) 2008 Till Harbaum <till@harbaum.org>.
3     *
4     * This file is part of OSM2Go.
5     *
6     * OSM2Go is free software: you can redistribute it and/or modify
7     * it under the terms of the GNU General Public License as published by
8     * the Free Software Foundation, either version 3 of the License, or
9     * (at your option) any later version.
10     *
11     * OSM2Go is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with OSM2Go. If not, see <http://www.gnu.org/licenses/>.
18     */
19    
20     #ifndef MAP_H
21     #define MAP_H
22    
23     #include "osm.h"
24    
25     #define MAP_LAYER_ALL (0xffff)
26 harbaum 153 #define MAP_LAYER_OBJECTS_ONLY ((1<<CANVAS_GROUP_POLYGONS) | (1<<CANVAS_GROUP_WAYS_HL) | (1<<CANVAS_GROUP_WAYS_OL) | (1<<CANVAS_GROUP_WAYS) | (1<<CANVAS_GROUP_WAYS_INT) | (1<<CANVAS_GROUP_NODES_HL) | (1<<CANVAS_GROUP_NODES_IHL) | (1<<CANVAS_GROUP_NODES) | (1<<CANVAS_GROUP_WAYS_DIR))
27 harbaum 1
28     /* -------- all sizes are in meters ---------- */
29     #define MAP_COLOR_NONE 0x0
30     #define NO_COLOR CANVAS_COLOR(0x00,0x00,0x00,0x00)
31    
32 harbaum 22 #define RGBA_COMBINE(a,b) (((a)&~0xff) | ((b)&0xff))
33 harbaum 1
34     #define ZOOM_FACTOR_MENU (1.5)
35     #define ZOOM_FACTOR_WHEEL (1.1)
36     #define ZOOM_FACTOR_BUTTON (1.5)
37    
38     /* the "drag limit" is the number of pixels the mouse/pen has to */
39     /* be moved so the action is actually considered dragging. This is */
40     /* to prevent accidential dragging when the user only intended to click */
41     /* something. This is especially useful when using a touchscreen. */
42     #ifndef USE_HILDON
43     #define MAP_DRAG_LIMIT 4
44     #else
45     #define MAP_DRAG_LIMIT 16
46     #endif
47    
48     /* don't reorder these as some things in map.c */
49     /* rely on a certain order */
50     typedef enum {
51     MAP_ACTION_IDLE=0,
52     MAP_ACTION_NODE_ADD,
53     MAP_ACTION_BG_ADJUST,
54     MAP_ACTION_WAY_ADD,
55     MAP_ACTION_WAY_NODE_ADD,
56     MAP_ACTION_WAY_CUT,
57     MAP_ACTION_NUM
58     } map_action_t;
59    
60     typedef struct map_highlight_s {
61     canvas_item_t *item;
62     struct map_highlight_s *next;
63     } map_highlight_t;
64    
65     typedef struct map_item_s {
66 harbaum 154 object_t object;
67 harbaum 1 gboolean highlight;
68     canvas_item_t *item;
69     } map_item_t;
70    
71     /* this is a chain of map_items which is attached to all entries */
72     /* in the osm tree (node_t, way_t, ...) to be able to get a link */
73     /* to the screen representation of a give node/way/etc */
74     typedef struct map_item_chain_s {
75     map_item_t *map_item;
76     struct map_item_chain_s *next;
77     } map_item_chain_t;
78    
79     typedef struct {
80     gint refcount;
81     float zoom; // zoom level (1.0 = 1m/pixel
82 harbaum 162 float detail; // deatil level (1.0 = normal)
83 harbaum 1 struct { gint x,y; } scroll_offset; // initial scroll offset
84     } map_state_t;
85    
86     typedef struct map_s {
87     appdata_t *appdata;
88    
89     canvas_t *canvas;
90    
91     map_state_t *state;
92    
93     map_highlight_t *highlight; // list of elements used for highlighting
94    
95     map_item_t selected; // the currently selected item (node or way)
96    
97     canvas_item_t *cursor; // the cursor visible on the draw layer
98     canvas_item_t *touchnode; // the blue "touch node" on the draw layer
99    
100     tag_t *last_node_tags; // used to "repeat" tagging
101     tag_t *last_way_tags;
102    
103     /* background image related stuff */
104     struct {
105     GdkPixbuf *pix;
106     canvas_item_t *item;
107     struct { float x, y; } offset;
108     struct { float x, y; } scale;
109     } bg;
110    
111     struct {
112     map_action_t type; // current action type in progress
113    
114     struct { // action related variables/states
115     way_t *way;
116     way_t *extending, *ends_on; // ways touched by first and last node
117     };
118     } action;
119    
120     /* variables required for pen/mouse handling */
121     struct {
122     gboolean is;
123     gboolean drag;
124     map_item_t *on_item;
125     struct { gint x,y; } at; // point mouse button was last pressed
126     struct { gint x,y; } so; // initial scroll offset
127     gboolean on_selected_node; // the currently clicked node
128     // (may be part of a selected way)
129     } pen_down;
130    
131     struct style_s *style;
132    
133     } map_t;
134    
135     GtkWidget *map_new(appdata_t *appdata);
136 harbaum 173 map_state_t *map_state_new(void);
137 harbaum 1 void map_state_free(map_state_t *state);
138 harbaum 173 void map_state_reset(map_state_t *state);
139 harbaum 1 void map_init(appdata_t *appdata);
140     gboolean map_key_press_event(appdata_t *appdata, GdkEventKey *event);
141     void map_item_set_flags(map_item_t *map_item, int set, int clr);
142     void map_show_node(map_t *map, node_t *node);
143     void map_cmenu_show(map_t *map);
144     void map_highlight_refresh(appdata_t *appdata);
145    
146     void map_item_redraw(appdata_t *appdata, map_item_t *map_item);
147    
148     void map_clear(appdata_t *appdata, gint layer_mask);
149     void map_paint(appdata_t *appdata);
150    
151     void map_action_set(appdata_t *appdata, map_action_t action);
152     void map_action_cancel(appdata_t *appdata);
153     void map_action_ok(appdata_t *appdata);
154    
155     void map_delete_selected(appdata_t *appdata);
156    
157     /* track stuff */
158     void map_track_draw(map_t *map, struct track_s *track);
159     struct track_seg_s;
160     void map_track_draw_seg(map_t *map, struct track_seg_s *seg);
161     void map_track_update_seg(map_t *map, struct track_seg_s *seg);
162     void map_track_remove(appdata_t *appdata);
163 harbaum 156 void map_track_pos(appdata_t *appdata, pos_t *pos);
164 harbaum 1
165     /* background stuff */
166     void map_set_bg_image(map_t *map, char *filename);
167     void map_remove_bg_image(map_t *map);
168    
169     void map_hide_selected(appdata_t *appdata);
170     void map_show_all(appdata_t *appdata);
171    
172     void map_set_zoom(map_t *map, double zoom, gboolean update_scroll_offsets);
173 harbaum 246 gboolean map_scroll_to_if_offscreen(map_t *map, lpos_t *lpos);
174 harbaum 1
175     /* various functions required by map_edit */
176     gboolean map_item_is_selected_node(map_t *map, map_item_t *map_item);
177     gboolean map_item_is_selected_way(map_t *map, map_item_t *map_item);
178     void map_item_chain_destroy(map_item_chain_t **chainP);
179     map_item_t *map_item_at(map_t *map, gint x, gint y);
180 harbaum 15 map_item_t *map_real_item_at(map_t *map, gint x, gint y);
181 harbaum 1 void map_item_deselect(appdata_t *appdata);
182     void map_way_delete(appdata_t *appdata, way_t *way);
183     void map_way_draw(map_t *map, way_t *way);
184     void map_way_select(appdata_t *appdata, way_t *way);
185     void map_outside_error(appdata_t *appdata);
186     void map_node_draw(map_t *map, node_t *node);
187 harbaum 153 void map_relation_select(appdata_t *appdata, relation_t *relation);
188 harbaum 1
189 harbaum 162 void map_detail_increase(map_t *map);
190     void map_detail_decrease(map_t *map);
191     void map_detail_normal(map_t *map);
192    
193 harbaum 1 #endif // MAP_H