]> err.no Git - mapper/commitdiff
More map widget integration work
authorKaj-Michael Lang <milang@tal.org>
Tue, 20 May 2008 14:00:23 +0000 (17:00 +0300)
committerKaj-Michael Lang <milang@tal.org>
Tue, 20 May 2008 14:00:23 +0000 (17:00 +0300)
src/cb.c
src/mapper.c
src/path.c
src/path.h
src/poi-gui.c
src/search.c
src/ui-common.c
src/ui-common.h

index 5b654f9f720b491b7c9cad58db47b53eda8e6cf3..50dae340954e3360f22f5d1e747ff178257187f9 100644 (file)
--- a/src/cb.c
+++ b/src/cb.c
@@ -45,8 +45,6 @@
 #include "utils.h"
 #include "poi.h"
 #include "path.h"
-#include "route.h"
-#include "track.h"
 #include "settings.h"
 #include "gps.h"
 #include "mapper-types.h"
@@ -320,10 +318,11 @@ gboolean
 menu_cb_goto_destination(GtkAction *action)
 {
 if (gtk_map_goto_position(_dest)==FALSE) {
-       MACRO_BANNER_SHOW_INFO(_window, _("Destination not set."));
+       MACRO_BANNER_SHOW_INFO(_window, _("Destination has not been set."));
 } else {
-       gtk_map_set_zoom(_map, 3);
-       MACRO_BANNER_SHOW_INFO(_window, _("At destination"));
+       if (gtk_map_get_zoom(_map)>3)
+               gtk_map_set_zoom(_map, 3);
+       MACRO_BANNER_SHOW_INFO(_window, _("At destination point"));
 }
 return TRUE;
 }
@@ -331,22 +330,30 @@ return TRUE;
 gboolean 
 menu_cb_goto_gps(GtkAction *action)
 {
-gtk_map_set_center_mode(_map, CENTER_LATLON);
-MACRO_BANNER_SHOW_INFO(_window, _("At GPS coordinates."));
-map_update_location_from_center();
+if (gtk_map_set_center_mode(_map, CENTER_LATLON)) {
+       MACRO_BANNER_SHOW_INFO(_window, _("At GPS track coordinates."));
+       map_update_location_from_center();
+} else {
+       MACRO_BANNER_SHOW_INFO(_window, _("No active GPS track."));
+}
 return TRUE;
 }
 
 gboolean 
 menu_cb_goto_nextway(GtkAction *action)
 {
+GtkMapCenterMode *cm;
+
 g_return_val_if_fail(_route, TRUE);
 
 if (_route->next_way && _route->next_way->point->unity) {
-       if (gtk_map_get_center_mode(_map) > 0)
+       g_object_get(_map, "center-mode", &cm);
+       if (cm>0)
                set_action_activate("autocenter_none", TRUE);
 
-       gtk_map_set_center_unit(_route->next_way->point->unitx, _route->next_way->point->unity);
+       gtk_map_set_center_unit(_map, _route->next_way->point->unitx, _route->next_way->point->unity);
+       if (gtk_map_get_zoom(_map)>3)
+               gtk_map_set_zoom(_map, 3);
 } else {
        MACRO_BANNER_SHOW_INFO(_window, _("There is no next waypoint."));
 }
@@ -357,19 +364,13 @@ return TRUE;
 gboolean 
 menu_cb_goto_nearpoi(GtkAction *action)
 {
+GtkMapCenterMode *cm;
 gdouble lat, lon;
 poi_info *p;
 
-if (gtk_map_get_center_mode(_map)!=CENTER_MANUAL) {
-       /* Auto-Center is enabled - use the GPS position. */
-       lat=_gps->data.lat;
-       lon=_gps->data.lon;
-} else {
-       gtk_map_get_center_latlon(_map, &lat, &lon);
-}
+gtk_map_get_center_latlon(_map, &lat, &lon);
 
 p=poi_find_nearest(lat, lon);
-
 if (p) {
        gchar *banner;
 
@@ -1102,8 +1103,11 @@ gboolean
 cmenu_cb_way_distance_to(GtkAction *action)
 {
 WayPoint *way;
+gdouble lat, lon;
 
-if ((way = route_find_nearest_waypoint(_route, x2unit(_cmenu_position_x), y2unit(_cmenu_position_y))))
+gtk_map_get_menu_latlon(_map, &lat, &lon);
+
+if ((way = route_find_nearest_waypoint(_route, lat, lon)))
        route_show_distance_to(_route, way->point);
 
 return TRUE;
@@ -1113,8 +1117,11 @@ gboolean
 cmenu_cb_way_delete(GtkAction *action)
 {
 WayPoint *way;
+gdouble lat, lon;
+
+gtk_map_get_menu_latlon(_map, &lat, &lon);
 
-if ((way = route_find_nearest_waypoint(_route, x2unit(_cmenu_position_x), y2unit(_cmenu_position_y)))) {
+if ((way = route_find_nearest_waypoint(_route, lat, lon))) {
        gchar buffer[BUFFER_SIZE];
        GtkWidget *confirm;
 
index a38ff4c676e0d4d48a921a76e7359f3cfed8bf2c..c4a613cd0ccc79239569a6dea3b0aaa866e92117 100644 (file)
@@ -441,10 +441,10 @@ switch (mis) {
                w="UI";
        break;
        case MAPPER_INIT_GOTO:
-               if (map_goto_position(&_home)==FALSE)
+               if (gtk_map_goto_position(_map, &_home)==FALSE)
                        g_printerr("Home is not set.\n");
                else
-                       gtk_map_center_latlon(64.25, 22.00); /* XXX */
+                       gtk_map_center_latlon(_map, 60.45, 22.25);
                mis=MAPPER_INIT_DONE;
                p=1.0;
                w="Done";
index 9d0698e8c598c52a52ac93d20c00ee8cec1675ea..eba74ddcd2f8c25521a0961004abd1500330ac8a 100644 (file)
@@ -343,14 +343,14 @@ if (route->next_way) {
        /* First, set near_dist_squared with the new distance from
         * near_point. */
        near = route->near_point;
-       near_dist_squared = DISTANCE_SQUARED(point, *near);
+       near_dist_squared = DISTANCE_SQUARED(*point, *near);
 
        /* Now, search route for a closer point.  If quick is TRUE, then we'll
         * only search forward, only as long as we keep finding closer points.
         */
        for (curr = route->near_point; curr++ != route->tail;) {
                if (curr->unity) {
-                       guint dist_squared = DISTANCE_SQUARED(point, *curr);
+                       guint dist_squared = DISTANCE_SQUARED(*point, *curr);
                        if (dist_squared <= near_dist_squared) {
                                near = curr;
                                near_dist_squared = dist_squared;
@@ -365,8 +365,8 @@ if (route->next_way) {
 
        for (wnext = wcurr = route->next_way; wcurr != route->wtail; wcurr++) {
                if (wcurr->point < near || (wcurr->point == near && quick 
-                               && (route->next_wpt && (DISTANCE_SQUARED(point, *near) > route->next_way_dist_squared
-                               && DISTANCE_SQUARED(point, *route->next_wpt) < route->next_wpt_dist_squared))))
+                               && (route->next_wpt && (DISTANCE_SQUARED(*point, *near) > route->next_way_dist_squared
+                               && DISTANCE_SQUARED(*point, *route->next_wpt) < route->next_wpt_dist_squared))))
                    /* Okay, this else if expression warrants explanation.  If the
                     * nearest track point happens to be a waypoint, then we want to
                     * check if we have "passed" that waypoint.  To check this, we
@@ -381,8 +381,8 @@ if (route->next_way) {
        }
 
        if (wnext == route->wtail && (wnext->point < near || (wnext->point == near && quick
-                                         && (route->next_wpt && (DISTANCE_SQUARED (_gps->data, *near) > route->next_way_dist_squared
-                                              && DISTANCE_SQUARED(point, *route->next_wpt) < route->next_wpt_dist_squared)))))
+                                         && (route->next_wpt && (DISTANCE_SQUARED (*point, *near) > route->next_way_dist_squared
+                                              && DISTANCE_SQUARED(*point, *route->next_wpt) < route->next_wpt_dist_squared)))))
        {
                route->next_way = NULL;
                route->next_wpt = NULL;
@@ -408,9 +408,9 @@ if (route->next_way) {
                        }
                        ret = TRUE;
                }
-               route->next_way_dist_squared = DISTANCE_SQUARED(_gps->data, *wnext->point);
+               route->next_way_dist_squared = DISTANCE_SQUARED(*point, *wnext->point);
                if (route->next_wpt)
-                       route->next_wpt_dist_squared = DISTANCE_SQUARED(_gps->data, *route->next_wpt);
+                       route->next_wpt_dist_squared = DISTANCE_SQUARED(*point, *route->next_wpt);
        }
 }
 return ret;
index b70fc6625243cb375d4e96590f2c00c09dd4e113..213724a9d2bae97cef631cee5c19664139177d15 100644 (file)
@@ -55,6 +55,10 @@ struct _Point {
        gfloat altitude;
 };
 
+#define DISTANCE_SQUARED(a, b) \
+       ((guint64)((((gint64)(b).unitx)-(a).unitx)*(((gint64)(b).unitx)-(a).unitx)) \
+       + (guint64)((((gint64)(b).unity)-(a).unity)*(((gint64)(b).unity)-(a).unity)))
+
 /**
  * A latitude/longitue pair
  */
@@ -151,6 +155,8 @@ gboolean path_wresize(Path *path, guint wsize);
 
 gdouble path_get_distance_to(Path *path, Point *point, gdouble lat, gdouble lon);
 
+gboolean path_update_nears(Path *route, Point *point, gboolean quick);
+
 gboolean path_insert_break(Path *path);
 void path_insert_mark_text(Path *path, gchar *text);
 void path_insert_mark_autonumber(Path *path);
index 70e5baf863602463465be83d710e21c761b54520..bae17fd73b4b753034419ace492a6d75149e0753 100644 (file)
@@ -98,8 +98,7 @@ GtkWidget *dialog;
 guint i;
 gchar *buffer;
 
-buffer = g_strdup_printf("%s\n\t%s\n%s", _("Delete category?"),
-                        dpoi->txt_label, _("WARNING: All POIs in that category will also be deleted!"));
+buffer = g_strdup_printf("%s\n\t%s\n%s", _("Delete category?"), dpoi->txt_label, _("WARNING: All POIs in that category will also be deleted!"));
 dialog = hildon_note_new_confirmation(GTK_WINDOW(_window), buffer);
 g_free(buffer);
 i = gtk_dialog_run(GTK_DIALOG(dialog));
@@ -109,8 +108,7 @@ if (i == GTK_RESPONSE_OK) {
        if (poi_category_delete(dpoi->id)==FALSE)
                popup_error(_window, _("Problem deleting category or POI"));
        gtk_widget_hide_all(dpoi->dialog);
-       map_poi_cache_clear();
-       map_force_redraw();
+       gtk_map_refresh(_map);
 }
 
 return TRUE;
index ae113bd6fdbcfcfa3549ecdd2472b4a508d31b96..7601ffa934079e164a5a945ce3b5091c03ea7fc9 100644 (file)
@@ -226,7 +226,7 @@ if (!model)
 gtk_tree_model_get(model, &iter, ITEM_LAT, &lat, -1);
 gtk_tree_model_get(model, &iter, ITEM_LON, &lon, -1);
 
-map_center_latlon(lat, lon);
+gtk_map_center_latlon(_map, lat, lon);
 g_idle_add_full(G_PRIORITY_HIGH_IDLE,(GSourceFunc)map_update_location_from_center, NULL, NULL);
 #if 0
 gtk_widget_destroy(s->dialog);
index 51d8d6d67b86e33b97b630df98737ed1642ae576..12b87b5d022c6c292d44ee494847a06b4b3b6b0f 100644 (file)
@@ -24,8 +24,6 @@
 #include "utils.h"
 #include "poi.h"
 #include "path.h"
-#include "route.h"
-#include "track.h"
 #include "settings.h"
 #include "gps.h"
 #include "gtkmap.h"
@@ -694,7 +692,7 @@ gtk_box_pack_start(GTK_BOX(mapvbox), hbox, TRUE, TRUE, 0);
 ui_notebook.map=gtk_notebook_append_page(notebook, mapvbox, label);
 
 /* Map widget */
-_map=gtkmap_new();
+_map=gtk_map_new();
 gtk_paned_add2(GTK_PANED(hbox), _map);
 
 #ifndef WITH_DEVICE_770
index 0f50144e29c48d79876d84ac671e6e4998d54390..4a0b55df98dd034a9db0286c2422a2a427387f23 100644 (file)
@@ -20,6 +20,7 @@
 #include "mapper-types.h"
 #include "ui-maemo.h"
 #include "hildon-wrappers.h"
+#include "path.h"
 
 #define SCALE_WIDTH (200)
 
@@ -121,9 +122,10 @@ GtkMenu *_menu_map;
 GtkWidget *route_tree_view;
 GtkWidget *track_tree_view;
 
-/** Context menu click location on map */
-guint _cmenu_position_x;
-guint _cmenu_position_y;
+Path *_route;
+Path *_track;
+
+AutoRouteDownloadData _autoroute_data;
 
 void mapper_ui_init(void);
 gboolean window_present();