Contents of /trunk/src/map.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 249 - (hide annotations)
Thu Jul 30 07:57:48 2009 UTC (14 years, 10 months ago) by harbaum
File MIME type: text/plain
File size: 6534 byte(s)
Download aread size checks improved
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 harbaum 249 #define MAP_DETAIL_STEP 1.5
39    
40 harbaum 1 /* the "drag limit" is the number of pixels the mouse/pen has to */
41     /* be moved so the action is actually considered dragging. This is */
42     /* to prevent accidential dragging when the user only intended to click */
43     /* something. This is especially useful when using a touchscreen. */
44     #ifndef USE_HILDON
45     #define MAP_DRAG_LIMIT 4
46     #else
47     #define MAP_DRAG_LIMIT 16
48     #endif
49    
50     /* don't reorder these as some things in map.c */
51     /* rely on a certain order */
52     typedef enum {
53     MAP_ACTION_IDLE=0,
54     MAP_ACTION_NODE_ADD,
55     MAP_ACTION_BG_ADJUST,
56     MAP_ACTION_WAY_ADD,
57     MAP_ACTION_WAY_NODE_ADD,
58     MAP_ACTION_WAY_CUT,
59     MAP_ACTION_NUM
60     } map_action_t;
61    
62     typedef struct map_highlight_s {
63     canvas_item_t *item;
64     struct map_highlight_s *next;
65     } map_highlight_t;
66    
67     typedef struct map_item_s {
68 harbaum 154 object_t object;
69 harbaum 1 gboolean highlight;
70     canvas_item_t *item;
71     } map_item_t;
72    
73     /* this is a chain of map_items which is attached to all entries */
74     /* in the osm tree (node_t, way_t, ...) to be able to get a link */
75     /* to the screen representation of a give node/way/etc */
76     typedef struct map_item_chain_s {
77     map_item_t *map_item;
78     struct map_item_chain_s *next;
79     } map_item_chain_t;
80    
81     typedef struct {
82     gint refcount;
83     float zoom; // zoom level (1.0 = 1m/pixel
84 harbaum 162 float detail; // deatil level (1.0 = normal)
85 harbaum 1 struct { gint x,y; } scroll_offset; // initial scroll offset
86     } map_state_t;
87    
88     typedef struct map_s {
89     appdata_t *appdata;
90    
91     canvas_t *canvas;
92    
93     map_state_t *state;
94    
95     map_highlight_t *highlight; // list of elements used for highlighting
96    
97     map_item_t selected; // the currently selected item (node or way)
98    
99     canvas_item_t *cursor; // the cursor visible on the draw layer
100     canvas_item_t *touchnode; // the blue "touch node" on the draw layer
101    
102     tag_t *last_node_tags; // used to "repeat" tagging
103     tag_t *last_way_tags;
104    
105     /* background image related stuff */
106     struct {
107     GdkPixbuf *pix;
108     canvas_item_t *item;
109     struct { float x, y; } offset;
110     struct { float x, y; } scale;
111     } bg;
112    
113     struct {
114     map_action_t type; // current action type in progress
115    
116     struct { // action related variables/states
117     way_t *way;
118     way_t *extending, *ends_on; // ways touched by first and last node
119     };
120     } action;
121    
122     /* variables required for pen/mouse handling */
123     struct {
124     gboolean is;
125     gboolean drag;
126     map_item_t *on_item;
127     struct { gint x,y; } at; // point mouse button was last pressed
128     struct { gint x,y; } so; // initial scroll offset
129     gboolean on_selected_node; // the currently clicked node
130     // (may be part of a selected way)
131     } pen_down;
132    
133     struct style_s *style;
134    
135     } map_t;
136    
137     GtkWidget *map_new(appdata_t *appdata);
138 harbaum 173 map_state_t *map_state_new(void);
139 harbaum 1 void map_state_free(map_state_t *state);
140 harbaum 173 void map_state_reset(map_state_t *state);
141 harbaum 1 void map_init(appdata_t *appdata);
142     gboolean map_key_press_event(appdata_t *appdata, GdkEventKey *event);
143     void map_item_set_flags(map_item_t *map_item, int set, int clr);
144     void map_show_node(map_t *map, node_t *node);
145     void map_cmenu_show(map_t *map);
146     void map_highlight_refresh(appdata_t *appdata);
147    
148     void map_item_redraw(appdata_t *appdata, map_item_t *map_item);
149    
150     void map_clear(appdata_t *appdata, gint layer_mask);
151     void map_paint(appdata_t *appdata);
152    
153     void map_action_set(appdata_t *appdata, map_action_t action);
154     void map_action_cancel(appdata_t *appdata);
155     void map_action_ok(appdata_t *appdata);
156    
157     void map_delete_selected(appdata_t *appdata);
158    
159     /* track stuff */
160     void map_track_draw(map_t *map, struct track_s *track);
161     struct track_seg_s;
162     void map_track_draw_seg(map_t *map, struct track_seg_s *seg);
163     void map_track_update_seg(map_t *map, struct track_seg_s *seg);
164     void map_track_remove(appdata_t *appdata);
165 harbaum 156 void map_track_pos(appdata_t *appdata, pos_t *pos);
166 harbaum 1
167     /* background stuff */
168     void map_set_bg_image(map_t *map, char *filename);
169     void map_remove_bg_image(map_t *map);
170    
171     void map_hide_selected(appdata_t *appdata);
172     void map_show_all(appdata_t *appdata);
173    
174     void map_set_zoom(map_t *map, double zoom, gboolean update_scroll_offsets);
175 harbaum 246 gboolean map_scroll_to_if_offscreen(map_t *map, lpos_t *lpos);
176 harbaum 1
177     /* various functions required by map_edit */
178     gboolean map_item_is_selected_node(map_t *map, map_item_t *map_item);
179     gboolean map_item_is_selected_way(map_t *map, map_item_t *map_item);
180     void map_item_chain_destroy(map_item_chain_t **chainP);
181     map_item_t *map_item_at(map_t *map, gint x, gint y);
182 harbaum 15 map_item_t *map_real_item_at(map_t *map, gint x, gint y);
183 harbaum 1 void map_item_deselect(appdata_t *appdata);
184     void map_way_delete(appdata_t *appdata, way_t *way);
185     void map_way_draw(map_t *map, way_t *way);
186     void map_way_select(appdata_t *appdata, way_t *way);
187     void map_outside_error(appdata_t *appdata);
188     void map_node_draw(map_t *map, node_t *node);
189 harbaum 153 void map_relation_select(appdata_t *appdata, relation_t *relation);
190 harbaum 1
191 harbaum 249 void map_detail_change(map_t *map, float detail);
192 harbaum 162 void map_detail_increase(map_t *map);
193     void map_detail_decrease(map_t *map);
194     void map_detail_normal(map_t *map);
195    
196 harbaum 1 #endif // MAP_H