From 30c98eb53adbb4c33d8cbbc9c69e5404ae80f92a Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Tue, 5 Aug 2008 17:59:39 +0300 Subject: [PATCH] Misc --- libs/libgtkmap/gtkmap.c | 16 ++++++++++------ libs/libgtkmap/path.c | 24 ++++++++++++++++++++++-- libs/libgtkmap/path.h | 3 --- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/libs/libgtkmap/gtkmap.c b/libs/libgtkmap/gtkmap.c index e0190b3..1fa1e7a 100644 --- a/libs/libgtkmap/gtkmap.c +++ b/libs/libgtkmap/gtkmap.c @@ -1108,6 +1108,7 @@ if (path->head==path->tail) map=GTK_MAP(widget); priv=GTK_MAP_GET_PRIVATE(map); + prev=path->head; x1=unit2x(path->head->unitx); y1=unit2y(path->head->unity); @@ -1126,18 +1127,21 @@ switch (path->type) { break; } cairo_set_line_width(priv->ct, priv->draw_width); -#if 0 cairo_rectangle(priv->ct, event->area.x, event->area.y, event->area.width, event->area.height); cairo_clip(priv->ct); -#endif -cairo_move_to(priv->ct, x1, y1); +#if 0 if (priv->rotate_view) { - gtk_map_update_rotation_matrix(priv,unit2x(priv->center.unitx),unit2y(priv->center.unity) ); + gtk_map_update_rotation_matrix(priv, unit2x(priv->center.unitx), unit2y(priv->center.unity)); cairo_set_matrix(priv->ct, &priv->matrix_rotate); } #endif +cairo_move_to(priv->ct, x1, y1); +#endif for (curr=path->head, wcurr=path->whead; curr++!=path->tail;) { + if (!curr->unitx) + continue; + x2=unit2x(curr->unitx); y2=unit2y(curr->unity); @@ -1151,8 +1155,6 @@ for (curr=path->head, wcurr=path->whead; curr++!=path->tail;) { cairo_line_to(priv->ct, x2, y2); #else gdk_draw_line(widget->window, priv->gc_track, x1, y1, x2, y2); - x1=x2; - y1=y2; #endif } } @@ -1169,6 +1171,8 @@ for (curr=path->head, wcurr=path->whead; curr++!=path->tail;) { wcurr++; } prev=curr; + x1=x2; + y1=y2; } #if 0 if (path->type==PATH_TYPE_ROUTE) diff --git a/libs/libgtkmap/path.c b/libs/libgtkmap/path.c index ad96d82..ef89c07 100644 --- a/libs/libgtkmap/path.c +++ b/libs/libgtkmap/path.c @@ -53,6 +53,9 @@ struct sql_select_stmt { }; static struct sql_select_stmt sql; +/* Null point */ +Point point_null; + #define PATH_TABLE_PATHS "create table IF NOT EXISTS paths ( \ nid int primary key, \ name text not null, \ @@ -81,7 +84,7 @@ static struct sql_select_stmt sql; #define MACRO_PATH_INIT(path) { \ (path).head = (path).tail = g_new0(Point, ARRAY_CHUNK_SIZE); \ - *((path).tail) = _point_null; \ + *((path).tail) = point_null; \ (path).cap = (path).head + ARRAY_CHUNK_SIZE; \ (path).whead = g_new0(WayPoint, ARRAY_CHUNK_SIZE); \ (path).wtail = (path).whead; \ @@ -201,6 +204,8 @@ object_class->dispose=path_dispose; object_class->finalize=path_finalize; /* g_type_class_add_private (klass, sizeof(PathPrivate)); */ +memset(&point_null, 0, sizeof(point_null)); + signals[NEW_POINT]=g_signal_new("new-point", G_OBJECT_CLASS_TYPE(object_class), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET(PathClass, new_point), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL); @@ -361,6 +366,18 @@ guint unitx, unity; latlon2unit(lat, lon, &unitx, &unity); +/* Initial point */ +if (path->head==path->tail) { + MACRO_PATH_INCREMENT_TAIL(*path); + path->tail->unitx=unitx; + path->tail->unity=unity; + path->tail->time=ptime; + path->tail->altitude=altitude; + path->speed=speed; + path->points=1; + return TRUE; +} + if (abs((gint)unitx-path->tail->unitx) > path->sensitivity || abs((gint)unity-path->tail->unity) > path->sensitivity) { if (path->tail->unity && path->tail->unitx) { gdouble plat, plon; @@ -403,12 +420,15 @@ path_add_break(Path *path) g_return_val_if_fail(path, FALSE); g_return_val_if_fail(path->tail, FALSE); +if (path->head==path->tail) + return FALSE; + if (path->tail->unity && path->tail->unitx) { /* To mark a "break" in a track, we'll add a (0, 0) point and then another instance of the most recent track point. */ MACRO_PATH_INCREMENT_TAIL(*path); - *path->tail=_point_null; + *path->tail=point_null; MACRO_PATH_INCREMENT_TAIL(*path); *path->tail=path->tail[-2]; diff --git a/libs/libgtkmap/path.h b/libs/libgtkmap/path.h index b37ce24..348b0ed 100644 --- a/libs/libgtkmap/path.h +++ b/libs/libgtkmap/path.h @@ -170,9 +170,6 @@ struct _PathClass { void (*reached_waypoint) (Path *path); }; -/* Null point */ -Point _point_null; - Path *path_new(PathType type, guint id); void path_free(Path *p); void path_clear(Path *p); -- 2.39.5