[cairo-commit] roadster/src db.c, 1.14, 1.15 gotowindow.c, 1.7,
1.8 importwindow.c, 1.5, 1.6 layers.c, 1.12, 1.13 layers.h,
1.5, 1.6 mainwindow.c, 1.23, 1.24 mainwindow.h, 1.8, 1.9 map.c,
1.25, 1.26 map.h, 1.6, 1.7 map_draw_cairo.c, 1.10,
1.11 map_draw_gdk.c, 1.5, 1.6 searchwindow.c, 1.12,
1.13 util.h, 1.5, 1.6
Ian McIntosh
commit at pdx.freedesktop.org
Sun Mar 13 15:31:23 PST 2005
Committed by: ian
Update of /cvs/cairo/roadster/src
In directory gabe:/tmp/cvs-serv29750/src
Modified Files:
db.c gotowindow.c importwindow.c layers.c layers.h
mainwindow.c mainwindow.h map.c map.h map_draw_cairo.c
map_draw_gdk.c searchwindow.c util.h
Log Message:
* src/db.c: Switch to mysql_use_result(). Add more memory related paramaters to embedded MySQL.
* src/mainwindow.c: Rename a few map related functions. Fix mousewheel zoomin/zoomout. Keep statusbar lat/lon updated when dragging/scrolling. Slow down scrolling slightly.
* src/searchwindow.c:
* src/gotowindow.c: Use new mainwindow function names.
* src/importwindow.c: Move GTK_PROCESS_MAINLOOP macro to src/util.h.
* src/layers.c: Add dash settings using integer in addition to floating point (for GDK).
* src/map_draw_*: Use new dash settings.
Index: db.c
===================================================================
RCS file: /cvs/cairo/roadster/src/db.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- db.c 13 Mar 2005 19:24:27 -0000 1.14
+++ db.c 13 Mar 2005 23:31:21 -0000 1.15
@@ -50,7 +50,7 @@
// better for embedded or local servers
// mysql_store_result - more client memory, gets all results right away and frees up server
// better for remote servers
-#define MYSQL_GET_RESULT(x) mysql_store_result((x))
+#define MYSQL_GET_RESULT(x) mysql_use_result((x))
db_connection_t* g_pDB = NULL;
@@ -67,6 +67,8 @@
#ifdef HAVE_MYSQL_EMBED
gchar* pszDataDir = g_strdup_printf("%s/.roadster/data", g_get_home_dir());
gchar* pszSetDataDirCommand = g_strdup_printf("--datadir=%s", pszDataDir);
+ gchar* pszSetQueryCacheSize = g_strdup_printf("--query-cache-size=%dMB", 40);
+ gchar* pszKeyBufferSize = g_strdup_printf("--key-buffer-size=%dMB", 32);
// Create directory if it doesn't exist
if(GNOME_VFS_OK != gnome_vfs_make_directory(pszDataDir, 0700)) {
@@ -76,12 +78,12 @@
gchar* apszServerOptions[] = {
"", // program name -- unused
"--skip-innodb", // don't bother with table types we don't use
- "--skip-bdb", //
-
- "--query-cache-type=1",
- "--query-cache-size=40MB",
+ "--skip-bdb",
+ "--query-cache-type=1", // enable query cache (for map tiles)
+ pszSetQueryCacheSize, //
-// "--flush", // seems like a good idea since users can quickly kill the app/daemon
+ pszKeyBufferSize,
+ "--ft-min-word-len=2", // 2 chars should count as a word for fulltext indexes
pszSetDataDirCommand
};
@@ -92,6 +94,8 @@
}
g_free(pszDataDir);
g_free(pszSetDataDirCommand);
+ g_free(pszSetQueryCacheSize);
+ g_free(pszKeyBufferSize);
#endif
}
Index: gotowindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/gotowindow.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- gotowindow.c 4 Mar 2005 09:27:26 -0000 1.7
+++ gotowindow.c 13 Mar 2005 23:31:21 -0000 1.8
@@ -83,7 +83,7 @@
if(!util_string_to_double(pszLatitude, &(pt.m_fLatitude))) return FALSE;
if(!util_string_to_double(pszLongitude, &(pt.m_fLongitude))) return FALSE;
- mainwindow_set_centerpoint(&pt);
+ mainwindow_map_center_on_mappoint(&pt);
mainwindow_draw_map(DRAWFLAG_ALL);
mainwindow_statusbar_update_position();
return TRUE;
Index: importwindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/importwindow.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- importwindow.c 4 Mar 2005 09:27:26 -0000 1.5
+++ importwindow.c 13 Mar 2005 23:31:21 -0000 1.6
@@ -27,10 +27,7 @@
#include "import.h"
#include "mainwindow.h"
#include "importwindow.h"
-
-//#define G_PROCESS_MAINLOOP while(g_main_context_iteration(g_main_context_default(), FALSE)) { /* do nothing */ }
-// #define G_PROCESS_MAINLOOP while(g_main_iteration(FALSE)) { /* do nothing */ }
-#define GTK_PROCESS_MAINLOOP while (gtk_events_pending ()) { gtk_main_iteration (); }
+#include "util.h"
struct {
GtkWindow* m_pWindow;
Index: layers.c
===================================================================
RCS file: /cvs/cairo/roadster/src/layers.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- layers.c 13 Mar 2005 19:24:27 -0000 1.12
+++ layers.c 13 Mar 2005 23:31:21 -0000 1.13
@@ -31,12 +31,13 @@
layer_t * g_aLayers[NUM_LAYERS+1];
-gdouble pDash_Solid[] = {10};
-gdouble pDash_1_14[] = {1, 14};
+gdouble pafDash_Solid[] = {10};
+gdouble pafDash_1_14[] = {1, 14};
+gint8 panDash_1_14[] = {1, 14};
dashstyle_t g_aDashStyles[NUM_DASH_STYLES] = {
- {NULL, 0},
- {pDash_1_14, 2},
+ {NULL, NULL, 0},
+ {pafDash_1_14, panDash_1_14, 2},
};
static void layers_load_from_file();
Index: layers.h
===================================================================
RCS file: /cvs/cairo/roadster/src/layers.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- layers.h 3 Mar 2005 07:32:46 -0000 1.5
+++ layers.h 13 Mar 2005 23:31:21 -0000 1.6
@@ -60,8 +60,9 @@
#define NUM_DASH_STYLES (2)
typedef struct dashstyle {
- gdouble* m_pfList;
- gint m_nCount;
+ gdouble* m_pafDashList; // the dashes, as floating point (for Cairo)
+ gint8* m_panDashList; // the dashes, as integers (for GDK)
+ gint m_nDashCount;
} dashstyle_t;
dashstyle_t g_aDashStyles[NUM_DASH_STYLES];
Index: mainwindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/mainwindow.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- mainwindow.c 10 Mar 2005 19:18:09 -0000 1.23
+++ mainwindow.c 13 Mar 2005 23:31:21 -0000 1.24
@@ -58,7 +58,7 @@
#define DRAW_PRETTY_TIMEOUT_MS (180) // how long after stopping various movements should we redraw in high-quality mode
#define SCROLL_TIMEOUT_MS (100) // how often (in MS) to move (SHORTER THAN ABOVE TIME)
-#define SCROLL_DISTANCE_IN_PIXELS (80) // how far to move every (above) MS
+#define SCROLL_DISTANCE_IN_PIXELS (60) // how far to move every (above) MS
#define BORDER_SCROLL_CLICK_TARGET_SIZE (20) // the size of the click target (distance from edge of map view) to begin scrolling
// Layerlist columns
@@ -97,6 +97,9 @@
static gboolean mainwindow_callback_on_gps_redraw_timeout(gpointer pData);
static void mainwindow_setup_selected_tool(void);
+
+void mainwindow_map_center_on_windowpoint(gint nX, gint nY);
+
struct {
gint m_nX;
gint m_nY;
@@ -398,10 +401,7 @@
gint nDeltaX = nPixels * g_aDirectionMultipliers[eScrollDirection].m_nX;
gint nDeltaY = nPixels * g_aDirectionMultipliers[eScrollDirection].m_nY;
- map_center_on_windowpoint(g_MainWindow.m_pMap,
- (nWidth / 2) + nDeltaX,
- (nHeight / 2) + nDeltaY);
-
+ mainwindow_map_center_on_windowpoint((nWidth / 2) + nDeltaX, (nHeight / 2) + nDeltaY);
mainwindow_draw_map(DRAWFLAG_GEOMETRY);
mainwindow_set_draw_pretty_timeout();
}
@@ -471,6 +471,7 @@
snprintf(buf, 199, "1:%d", uZoomLevelScale);
mainwindow_set_statusbar_zoomscale(buf);
+ GTK_PROCESS_MAINLOOP;
}
void mainwindow_statusbar_update_position(void)
@@ -480,6 +481,7 @@
map_get_centerpoint(g_MainWindow.m_pMap, &pt);
g_snprintf(buf, 200, "Lat: %.5f, Lon: %.5f", pt.m_fLatitude, pt.m_fLongitude);
mainwindow_set_statusbar_position(buf);
+ GTK_PROCESS_MAINLOOP;
}
/*
@@ -771,7 +773,7 @@
}
}
else if(event->type == GDK_2BUTTON_PRESS) {
- map_center_on_windowpoint(g_MainWindow.m_pMap, nX, nY);
+ mainwindow_map_center_on_windowpoint(nX, nY);
mainwindow_draw_map(DRAWFLAG_ALL);
}
}
@@ -812,9 +814,7 @@
if(nDeltaX == 0 && nDeltaY == 0) return TRUE;
- map_center_on_windowpoint(g_MainWindow.m_pMap,
- (nWidth / 2) + nDeltaX,
- (nHeight / 2) + nDeltaY);
+ mainwindow_map_center_on_windowpoint((nWidth / 2) + nDeltaX, (nHeight / 2) + nDeltaY);
mainwindow_draw_map(DRAWFLAG_GEOMETRY);
mainwindow_set_draw_pretty_timeout();
@@ -858,9 +858,13 @@
// respond to scroll wheel events by zooming in and out
if(event->direction == GDK_SCROLL_UP) {
zoom_in_one();
+ mainwindow_draw_map(DRAWFLAG_GEOMETRY);
+ mainwindow_set_draw_pretty_timeout();
}
else if(event->direction == GDK_SCROLL_DOWN) {
zoom_out_one();
+ mainwindow_draw_map(DRAWFLAG_GEOMETRY);
+ mainwindow_set_draw_pretty_timeout();
}
}
@@ -925,7 +929,6 @@
// push it to screen
GdkPixmap* pMapPixmap = map_get_pixmap(g_MainWindow.m_pMap);
- // Copy relevant portion of off-screen bitmap to window
gdk_draw_drawable(GTK_WIDGET(g_MainWindow.m_pDrawingArea)->window,
GTK_WIDGET(g_MainWindow.m_pDrawingArea)->style->fg_gc[GTK_WIDGET_STATE(g_MainWindow.m_pDrawingArea)],
pMapPixmap,
@@ -1036,14 +1039,41 @@
return TRUE;
}
-void mainwindow_set_centerpoint(mappoint_t* pPoint)
+void mainwindow_map_center_on_windowpoint(gint nX, gint nY)
+{
+ // Calculate the # of pixels away from the center point the click was
+ gint16 nPixelDeltaX = nX - (GTK_WIDGET(g_MainWindow.m_pDrawingArea)->allocation.width / 2);
+ gint16 nPixelDeltaY = nY - (GTK_WIDGET(g_MainWindow.m_pDrawingArea)->allocation.height / 2);
+
+ // Convert pixels to world coordinates
+ gint nZoomLevel = map_get_zoomlevel(g_MainWindow.m_pMap);
+ double fWorldDeltaX = map_pixels_to_degrees(g_MainWindow.m_pMap, nPixelDeltaX, nZoomLevel);
+ // reverse the X, clicking above
+ double fWorldDeltaY = -map_pixels_to_degrees(g_MainWindow.m_pMap, nPixelDeltaY, nZoomLevel);
+
+ mappoint_t pt;
+ map_get_centerpoint(g_MainWindow.m_pMap, &pt);
+
+ pt.m_fLatitude += fWorldDeltaY;
+ pt.m_fLongitude += fWorldDeltaX;
+ map_set_centerpoint(g_MainWindow.m_pMap, &pt);
+
+ mainwindow_statusbar_update_position();
+}
+
+void mainwindow_map_center_on_mappoint(mappoint_t* pPoint)
{
+ g_assert(pPoint != NULL);
+
map_set_centerpoint(g_MainWindow.m_pMap, pPoint);
+
mainwindow_statusbar_update_position();
}
void mainwindow_get_centerpoint(mappoint_t* pPoint)
{
+ g_assert(pPoint != NULL);
+
map_get_centerpoint(g_MainWindow.m_pMap, pPoint);
}
Index: mainwindow.h
===================================================================
RCS file: /cvs/cairo/roadster/src/mainwindow.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- mainwindow.h 7 Mar 2005 05:30:10 -0000 1.8
+++ mainwindow.h 13 Mar 2005 23:31:21 -0000 1.9
@@ -70,8 +70,8 @@
void mainwindow_statusbar_update_position(void);
// Map
-void mainwindow_set_centerpoint(mappoint_t* pPoint);
-void mainwindow_get_centerpoint(mappoint_t* pPoint);
+void mainwindow_map_set_centerpoint(mappoint_t* pPoint);
+void mainwindow_map_get_centerpoint(mappoint_t* pPoint);
typedef enum {
DIRECTION_NONE, DIRECTION_N, DIRECTION_NE, DIRECTION_E, DIRECTION_SE, DIRECTION_S, DIRECTION_SW, DIRECTION_W, DIRECTION_NW
Index: map.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- map.c 13 Mar 2005 19:32:45 -0000 1.25
+++ map.c 13 Mar 2005 23:31:21 -0000 1.26
@@ -294,7 +294,7 @@
}
// convert pixels to a span of degrees
-static double map_pixels_to_degrees(map_t* pMap, gint16 nPixels, guint16 uZoomLevel)
+double map_pixels_to_degrees(map_t* pMap, gint16 nPixels, guint16 uZoomLevel)
{
double fMonitorPixelsPerInch = 85 + 1/3;
double fPixelsPerMeter = fMonitorPixelsPerInch * INCHES_PER_METER;
Index: map.h
===================================================================
RCS file: /cvs/cairo/roadster/src/map.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- map.h 7 Mar 2005 05:30:10 -0000 1.6
+++ map.h 13 Mar 2005 23:31:21 -0000 1.7
@@ -197,7 +197,7 @@
void map_windowpoint_to_mappoint(map_t* pMap, screenpoint_t* pScreenPoint, mappoint_t* pMapPoint);
gdouble map_distance_in_units_to_degrees(map_t* pMap, gdouble fDistance, gint nDistanceUnit);
double map_get_distance_in_meters(mappoint_t* pA, mappoint_t* pB);
-
+double map_pixels_to_degrees(map_t* pMap, gint16 nPixels, guint16 uZoomLevel);
// remove this!
void map_center_on_windowpoint(map_t* pMap, guint16 uX, guint16 uY);
Index: map_draw_cairo.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map_draw_cairo.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- map_draw_cairo.c 13 Mar 2005 19:24:27 -0000 1.10
+++ map_draw_cairo.c 13 Mar 2005 23:31:21 -0000 1.11
@@ -907,8 +907,8 @@
cairo_set_tolerance(pCairo, fTolerance);
cairo_set_line_join(pCairo, pSubLayerStyle->m_nJoinStyle);
cairo_set_line_cap(pCairo, nCapStyle); /* CAIRO_LINE_CAP_BUTT, CAIRO_LINE_CAP_ROUND, CAIRO_LINE_CAP_CAP */
- if(g_aDashStyles[pSubLayerStyle->m_nDashStyle].m_nCount > 1) {
- cairo_set_dash(pCairo, g_aDashStyles[pSubLayerStyle->m_nDashStyle].m_pfList, g_aDashStyles[pSubLayerStyle->m_nDashStyle].m_nCount, 0.0);
+ if(g_aDashStyles[pSubLayerStyle->m_nDashStyle].m_nDashCount > 1) {
+ cairo_set_dash(pCairo, g_aDashStyles[pSubLayerStyle->m_nDashStyle].m_pafDashList, g_aDashStyles[pSubLayerStyle->m_nDashStyle].m_nDashCount, 0.0);
}
// Set layer attributes
Index: map_draw_gdk.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map_draw_gdk.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- map_draw_gdk.c 7 Mar 2005 05:30:10 -0000 1.5
+++ map_draw_gdk.c 13 Mar 2005 23:31:21 -0000 1.6
@@ -151,10 +151,13 @@
// Use GDK dash style if ANY dash pattern is set
gint nDashStyle = GDK_LINE_SOLID;
- if(pSubLayerStyle->m_nDashStyle != 0) {
+ if(g_aDashStyles[pSubLayerStyle->m_nDashStyle].m_nDashCount > 1) {
nDashStyle = GDK_LINE_ON_OFF_DASH;
- // gdk_gc_set_dashes
+ gdk_gc_set_dashes(pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)],
+ 0, /* offset */
+ g_aDashStyles[pSubLayerStyle->m_nDashStyle].m_panDashList,
+ g_aDashStyles[pSubLayerStyle->m_nDashStyle].m_nDashCount);
}
// XXX: Don't use round at low zoom levels
Index: searchwindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/searchwindow.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- searchwindow.c 7 Mar 2005 23:31:41 -0000 1.12
+++ searchwindow.c 13 Mar 2005 23:31:21 -0000 1.13
@@ -151,10 +151,10 @@
RESULTLIST_ZOOMLEVEL, &nZoomLevel,
-1);
- mainwindow_set_centerpoint(&pt);
+ mainwindow_map_center_on_mappoint(&pt);
+ //mainwindow_statusbar_update_position();
mainwindow_set_zoomlevel(nZoomLevel);
mainwindow_draw_map(DRAWFLAG_ALL);
- mainwindow_statusbar_update_position();
}
}
Index: util.h
===================================================================
RCS file: /cvs/cairo/roadster/src/util.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- util.h 10 Mar 2005 19:18:09 -0000 1.5
+++ util.h 13 Mar 2005 23:31:21 -0000 1.6
@@ -26,6 +26,8 @@
#include <gtk/gtk.h>
+#define GTK_PROCESS_MAINLOOP while (gtk_events_pending ()) { gtk_main_iteration (); }
+
#define NUM_ELEMS(a) (sizeof(a) / sizeof(a[0]))
#define SWAP(x, y) { (x) ^= (y) ^= (x) ^= (y); }
More information about the cairo-commit
mailing list