[cairo-commit] roadster/src mainwindow.c, 1.30, 1.31 map.c, 1.32,
1.33 map.h, 1.11, 1.12 map_draw_cairo.c, 1.13,
1.14 map_draw_gdk.c, 1.9, 1.10
Ian McIntosh
commit at pdx.freedesktop.org
Fri Mar 25 14:02:13 PST 2005
Committed by: ian
Update of /cvs/cairo/roadster/src
In directory gabe:/tmp/cvs-serv16624/src
Modified Files:
mainwindow.c map.c map.h map_draw_cairo.c map_draw_gdk.c
Log Message:
* src/mainwindow.c: Tweak when mouse cursor changes during drags, etc.
* src/map_draw_gdk.c:
* src/map_draw_cairo.c: Use lat,lon in bounding box tests instead of screen X,Y to help avoid integer overflow issues when zoomed in.
Index: mainwindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/mainwindow.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- mainwindow.c 23 Mar 2005 21:15:46 -0000 1.30
+++ mainwindow.c 25 Mar 2005 22:02:11 -0000 1.31
@@ -90,7 +90,7 @@
#define TOOLTIP_OFFSET_X (20)
#define TOOLTIP_OFFSET_Y (0)
-#define MAX_DISTANCE_FOR_AUTO_SLIDE_IN_PIXELS (3500.0)
+#define MAX_DISTANCE_FOR_AUTO_SLIDE_IN_PIXELS (3500.0) // when selecting search results, we slide to them instead of jumping if they are within this distance
// Types
typedef struct {
@@ -844,16 +844,13 @@
}
// Left mouse button up?
else if(event->type == GDK_BUTTON_RELEASE) {
- //tooltip_set_upper_left_corner(g_MainWindow.m_pTooltip, (gint)(event->x_root) + TOOLTIP_OFFSET_X, (gint)(event->y_root) + TOOLTIP_OFFSET_Y);
- //tooltip_show(g_MainWindow.m_pTooltip);
-
- // restore cursor
- GdkCursor* pCursor = gdk_cursor_new(GDK_LEFT_PTR);
- gdk_window_set_cursor(GTK_WIDGET(g_MainWindow.m_pDrawingArea)->window, pCursor);
- gdk_cursor_unref(pCursor);
-
// end mouse dragging, if active
if(g_MainWindow.m_bMouseDragging == TRUE) {
+ // restore cursor
+ GdkCursor* pCursor = gdk_cursor_new(GDK_LEFT_PTR);
+ gdk_window_set_cursor(GTK_WIDGET(g_MainWindow.m_pDrawingArea)->window, pCursor);
+ gdk_cursor_unref(pCursor);
+
g_MainWindow.m_bMouseDragging = FALSE;
if(g_MainWindow.m_bMouseDragMovement) {
mainwindow_cancel_draw_pretty_timeout();
@@ -865,6 +862,8 @@
// end scrolling, if active
if(g_MainWindow.m_bScrolling == TRUE) {
+ // NOTE: don't restore cursor (mouse could *still* be over screen edge)
+
g_MainWindow.m_bScrolling = FALSE;
mainwindow_cancel_draw_pretty_timeout();
Index: map.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- map.c 23 Mar 2005 22:43:05 -0000 1.32
+++ map.c 25 Mar 2005 22:02:11 -0000 1.33
@@ -516,8 +516,6 @@
if(pResultSet) {
TIMER_SHOW(mytimer, "after clear layers");
while((aRow = db_fetch_row(pResultSet))) {
- RENDERING_THREAD_YIELD;
-
uRowCount++;
// aRow[0] is ID
@@ -558,7 +556,7 @@
g_ptr_array_add(
pMap->m_apLayerData[nTypeID]->m_pPointStringsArray, pNewPointString);
} // end while loop on rows
- //g_print("[%d rows]\n", uRowCount);
+ g_print("[%d rows]\n", uRowCount);
TIMER_SHOW(mytimer, "after rows retrieved");
db_free_result(pResultSet);
@@ -581,8 +579,6 @@
// Free each pointstring
for(j = (pLayerData->m_pPointStringsArray->len - 1) ; j>=0 ; j--) {
- RENDERING_THREAD_YIELD;
-
pointstring_t* pPointString = g_ptr_array_remove_index_fast(pLayerData->m_pPointStringsArray, j);
pointstring_free(pPointString);
}
Index: map.h
===================================================================
RCS file: /cvs/cairo/roadster/src/map.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- map.h 23 Mar 2005 21:15:46 -0000 1.11
+++ map.h 25 Mar 2005 22:02:11 -0000 1.12
@@ -24,6 +24,11 @@
#ifndef _MAP_H_
#define _MAP_H_
+#define MIN_LATITUDE (-90.0)
+#define MAX_LATITUDE (90.0)
+#define MIN_LONGITUDE (-180.0)
+#define MAX_LONGITUDE (180.0)
+
typedef enum {
kSublayerBottom,
kSublayerTop,
Index: map_draw_cairo.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map_draw_cairo.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- map_draw_cairo.c 20 Mar 2005 03:37:09 -0000 1.13
+++ map_draw_cairo.c 25 Mar 2005 22:02:11 -0000 1.14
@@ -366,7 +366,7 @@
void map_draw_cairo_layer_points(map_t* pMap, cairo_t* pCairo, rendermetrics_t* pRenderMetrics, GPtrArray* pLocationsArray)
{
- gdouble fRadius = map_degrees_to_pixels(pMap, 0.0007, map_get_zoomlevel(pMap));
+/* gdouble fRadius = map_degrees_to_pixels(pMap, 0.0007, map_get_zoomlevel(pMap));
gboolean bAddition = FALSE;
cairo_save(pCairo);
@@ -375,8 +375,6 @@
gint iLocation;
for(iLocation=0 ; iLocation<pLocationsArray->len ; iLocation++) {
- RENDERING_THREAD_YIELD;
-
location_t* pLocation = g_ptr_array_index(pLocationsArray, iLocation);
cairo_move_to(pCairo, SCALE_X(pRenderMetrics, pLocation->m_Coordinates.m_fLongitude), SCALE_Y(pRenderMetrics, pLocation->m_Coordinates.m_fLatitude));
@@ -395,8 +393,6 @@
cairo_set_alpha(pCairo, 1.0);
fRadius = 2;
for(iLocation=0 ; iLocation<pLocationsArray->len ; iLocation++) {
- RENDERING_THREAD_YIELD;
-
location_t* pLocation = g_ptr_array_index(pLocationsArray, iLocation);
cairo_move_to(pCairo, SCALE_X(pRenderMetrics, pLocation->m_Coordinates.m_fLongitude), SCALE_Y(pRenderMetrics, pLocation->m_Coordinates.m_fLatitude));
@@ -408,10 +404,12 @@
// cairo_fill(pCairo);
cairo_restore(pCairo);
+*/
}
void map_draw_cairo_locations(map_t* pMap, cairo_t* pCairo, rendermetrics_t* pRenderMetrics)
{
+/*
location_t loc;
location_t* pLoc = &loc;
@@ -441,6 +439,7 @@
cairo_rectangle(pCairo, fX - BAP, fY - BAP, BAP*2, BAP*2);
cairo_fill(pCairo);
cairo_restore(pCairo);
+*/
}
@@ -466,39 +465,43 @@
if(FALSE == scenemanager_can_draw_label_at(pMap->m_pSceneManager, pszLabel, NULL)) {
return;
}
-
+
mappoint_t* pMapPoint1 = g_ptr_array_index(pPointString->m_pPointsArray, 0);
mappoint_t* pMapPoint2 = g_ptr_array_index(pPointString->m_pPointsArray, 1);
-
+
// swap first and second points such that the line goes left-to-right
if(pMapPoint2->m_fLongitude < pMapPoint1->m_fLongitude) {
mappoint_t* pTmp = pMapPoint1; pMapPoint1 = pMapPoint2; pMapPoint2 = pTmp;
}
-
+
+ // find extents
+ gdouble fMaxLat = max(pMapPoint1->m_fLatitude, pMapPoint2->m_fLatitude);
+ gdouble fMinLat = min(pMapPoint1->m_fLatitude, pMapPoint2->m_fLatitude);
+ gdouble fMaxLon = max(pMapPoint1->m_fLongitude, pMapPoint2->m_fLongitude);
+ gdouble fMinLon = min(pMapPoint1->m_fLongitude, pMapPoint2->m_fLongitude);
+
gdouble fX1 = SCALE_X(pRenderMetrics, pMapPoint1->m_fLongitude);
gdouble fY1 = SCALE_Y(pRenderMetrics, pMapPoint1->m_fLatitude);
gdouble fX2 = SCALE_X(pRenderMetrics, pMapPoint2->m_fLongitude);
gdouble fY2 = SCALE_Y(pRenderMetrics, pMapPoint2->m_fLatitude);
-
- // Find minimum bounding rectangle
- gdouble fMaxX = max(fX1, fX2);
- gdouble fMaxY = max(fY1, fY2);
- gdouble fMinX = min(fX1, fX2);
- gdouble fMinY = min(fY1, fY2);
-
- // Overlap test
- if(fMaxX < 0.0 || fMaxY < 0 || fMinX > (gdouble)(pRenderMetrics->m_nWindowWidth) || fMinY > (gdouble)(pRenderMetrics->m_nWindowHeight)) {
+
+ // rectangle overlap test
+ if(fMaxLat < pRenderMetrics->m_rWorldBoundingBox.m_A.m_fLatitude
+ || fMaxLon < pRenderMetrics->m_rWorldBoundingBox.m_A.m_fLongitude
+ || fMinLat > pRenderMetrics->m_rWorldBoundingBox.m_B.m_fLatitude
+ || fMinLon > pRenderMetrics->m_rWorldBoundingBox.m_B.m_fLongitude)
+ {
return;
}
-
+
gdouble fRise = fY2 - fY1;
gdouble fRun = fX2 - fX1;
gdouble fLineLengthSquared = (fRun*fRun) + (fRise*fRise);
-
+
gchar* pszFontFamily = ROAD_FONT;
-
+
cairo_save(pCairo);
-
+
// get total width of string
cairo_text_extents_t extents;
cairo_text_extents(pCairo, pszLabel, &extents);
@@ -1128,10 +1131,10 @@
gdouble fTotalX = 0.0;
gdouble fTotalY = 0.0;
- gdouble fMaxX = -G_MAXDOUBLE; // init to the worst possible value so first point will override
- gdouble fMaxY = -G_MAXDOUBLE;
- gdouble fMinX = G_MAXDOUBLE;
- gdouble fMinY = G_MAXDOUBLE;
+ gdouble fMaxLat = MIN_LATITUDE; // init to the worst possible value so first point will override
+ gdouble fMinLat = MAX_LATITUDE;
+ gdouble fMaxLon = MIN_LONGITUDE;
+ gdouble fMinLon = MAX_LONGITUDE;
mappoint_t* pMapPoint;
gdouble fX;
@@ -1140,32 +1143,31 @@
for(i=0 ; i<pPointString->m_pPointsArray->len ; i++) {
pMapPoint = g_ptr_array_index(pPointString->m_pPointsArray, i);
+ // find extents
+ fMaxLat = max(pMapPoint->m_fLatitude,fMaxLat);
+ fMinLat = min(pMapPoint->m_fLatitude,fMinLat);
+ fMaxLon = max(pMapPoint->m_fLongitude,fMaxLon);
+ fMinLon = min(pMapPoint->m_fLongitude,fMinLon);
+
fX = SCALE_X(pRenderMetrics, pMapPoint->m_fLongitude);
fY = SCALE_Y(pRenderMetrics, pMapPoint->m_fLatitude);
- // find extents
- fMaxX = max(fX,fMaxX);
- fMinX = min(fX,fMinX);
- fMaxY = max(fY,fMaxY);
- fMinY = min(fY,fMinY);
-
// sum up Xs and Ys (we'll take an average later)
fTotalX += fX;
fTotalY += fY;
}
- RENDERING_THREAD_YIELD;
// rectangle overlap test
- if(fMaxX < 0.0 || fMaxY < 0 || fMinX > (gdouble)(pRenderMetrics->m_nWindowWidth) || fMinY > (gdouble)(pRenderMetrics->m_nWindowHeight)) {
+ if(fMaxLat < pRenderMetrics->m_rWorldBoundingBox.m_A.m_fLatitude
+ || fMaxLon < pRenderMetrics->m_rWorldBoundingBox.m_A.m_fLongitude
+ || fMinLat > pRenderMetrics->m_rWorldBoundingBox.m_B.m_fLatitude
+ || fMinLon > pRenderMetrics->m_rWorldBoundingBox.m_B.m_fLongitude)
+ {
return; // not visible
}
- //
- gdouble fPolygonHeight = fMaxY - fMinY;
- gdouble fPolygonWidth = fMaxX - fMinX;
-
- gdouble fDrawX = fMinX + fPolygonWidth/2; //fTotalX / pPointString->m_pPointsArray->len;
- gdouble fDrawY = fMinY + fPolygonHeight/2; //fTotalY / pPointString->m_pPointsArray->len;
+ gdouble fDrawX = SCALE_X(pRenderMetrics, (fMinLon + fMaxLon) / 2); //fMinX + fPolygonWidth/2; //fTotalX / pPointString->m_pPointsArray->len;
+ gdouble fDrawY = SCALE_Y(pRenderMetrics, (fMinLat + fMaxLat) / 2); //fMinY + fPolygonHeight/2; //fTotalY / pPointString->m_pPointsArray->len;
cairo_save(pCairo);
Index: map_draw_gdk.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map_draw_gdk.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- map_draw_gdk.c 23 Mar 2005 21:15:46 -0000 1.9
+++ map_draw_gdk.c 25 Mar 2005 22:02:11 -0000 1.10
@@ -93,59 +93,16 @@
TIMER_END(maptimer, "END RENDER MAP (gdk)");
}
-static void map_draw_gdk_tracks(map_t* pMap, GdkPixmap* pPixmap, rendermetrics_t* pRenderMetrics)
+static void map_draw_gdk_background(map_t* pMap, GdkPixmap* pPixmap)
{
- gint i;
- for(i=0 ; i<pMap->m_pTracksArray->len ; i++) {
- gint hTrack = g_array_index(pMap->m_pTracksArray, gint, i);
-
- GdkColor clr;
- clr.red = (gint)(0.5 * 65535.0);
- clr.green = (gint)(0.5 * 65535.0);
- clr.blue = (gint)(1.0 * 65535.0);
- gdk_gc_set_rgb_fg_color(pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)], &clr);
-
- pointstring_t* pPointString = track_get_pointstring(hTrack);
- if(pPointString == NULL) continue;
-
- if(pPointString->m_pPointsArray->len >= 2) {
- GdkPoint aPoints[MAX_GDK_LINE_SEGMENTS];
- gint nMaxX=G_MININT;
- gint nMaxY=G_MININT;
- gint nMinX=G_MAXINT;
- gint nMinY=G_MAXINT;
-
- if(pPointString->m_pPointsArray->len > MAX_GDK_LINE_SEGMENTS) {
- g_warning("not drawing track with > %d segments\n", MAX_GDK_LINE_SEGMENTS);
- continue;
- }
-
- gint iPoint;
- for(iPoint=0 ; iPoint<pPointString->m_pPointsArray->len ; iPoint++) {
- mappoint_t* pPoint = g_ptr_array_index(pPointString->m_pPointsArray, iPoint);
-
- gint nX,nY;
- nX = (gint)SCALE_X(pRenderMetrics, pPoint->m_fLongitude);
- nY = (gint)SCALE_Y(pRenderMetrics, pPoint->m_fLatitude);
-
- // find extents
- nMaxX = max(nX,nMaxX);
- nMinX = min(nX,nMinX);
- nMaxY = max(nY,nMaxY);
- nMinY = min(nY,nMinY);
-
- aPoints[iPoint].x = nX;
- aPoints[iPoint].y = nY;
- }
-
- // overlap test
- if(nMaxX < 0 || nMaxY < 0 || nMinX > pRenderMetrics->m_nWindowWidth || nMinY > pRenderMetrics->m_nWindowHeight) {
- continue;
- }
-
- gdk_draw_lines(pPixmap, pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)], aPoints, pPointString->m_pPointsArray->len);
- }
- }
+ GdkColor clr;
+ clr.red = 240/255.0 * 65535;
+ clr.green = 235/255.0 * 65535;
+ clr.blue = 230/255.0 * 65535;
+ gdk_gc_set_rgb_fg_color(pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)], &clr);
+
+ gdk_draw_rectangle(pPixmap, pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)],
+ TRUE, 0,0, pMap->m_MapDimensions.m_uWidth, pMap->m_MapDimensions.m_uHeight);
}
static void map_draw_gdk_layer_polygons(map_t* pMap, GdkPixmap* pPixmap, rendermetrics_t* pRenderMetrics, GPtrArray* pPointStringsArray, sublayerstyle_t* pSubLayerStyle, textlabelstyle_t* pLabelStyle)
@@ -177,10 +134,10 @@
for(iString=0 ; iString<pPointStringsArray->len ; iString++) {
pPointString = g_ptr_array_index(pPointStringsArray, iString);
- gint nMaxX=G_MININT;
- gint nMaxY=G_MININT;
- gint nMinX=G_MAXINT;
- gint nMinY=G_MAXINT;
+ gdouble fMaxLat = MIN_LATITUDE; // init to the worst possible value so first point will override
+ gdouble fMinLat = MAX_LATITUDE;
+ gdouble fMaxLon = MIN_LONGITUDE;
+ gdouble fMinLon = MAX_LONGITUDE;
if(pPointString->m_pPointsArray->len >= 2) {
GdkPoint aPoints[MAX_GDK_LINE_SEGMENTS];
@@ -193,22 +150,23 @@
for(iPoint=0 ; iPoint<pPointString->m_pPointsArray->len ; iPoint++) {
pPoint = g_ptr_array_index(pPointString->m_pPointsArray, iPoint);
- gint nX,nY;
- nX = (gint)SCALE_X(pRenderMetrics, pPoint->m_fLongitude);
- nY = (gint)SCALE_Y(pRenderMetrics, pPoint->m_fLatitude);
-
// find extents
- nMaxX = max(nX,nMaxX);
- nMinX = min(nX,nMinX);
- nMaxY = max(nY,nMaxY);
- nMinY = min(nY,nMinY);
+ fMaxLat = max(pPoint->m_fLatitude,fMaxLat);
+ fMinLat = min(pPoint->m_fLatitude,fMinLat);
+ fMaxLon = max(pPoint->m_fLongitude,fMaxLon);
+ fMinLon = min(pPoint->m_fLongitude,fMinLon);
- aPoints[iPoint].x = nX;
- aPoints[iPoint].y = nY;
+ aPoints[iPoint].x = (gint)SCALE_X(pRenderMetrics, pPoint->m_fLongitude);
+ aPoints[iPoint].y = (gint)SCALE_Y(pRenderMetrics, pPoint->m_fLatitude);
}
- // overlap test
- if(nMaxX < 0 || nMaxY < 0 || nMinX > pRenderMetrics->m_nWindowWidth || nMinY > pRenderMetrics->m_nWindowHeight) {
- continue;
+
+ // rectangle overlap test
+ if(fMaxLat < pRenderMetrics->m_rWorldBoundingBox.m_A.m_fLatitude
+ || fMaxLon < pRenderMetrics->m_rWorldBoundingBox.m_A.m_fLongitude
+ || fMinLat > pRenderMetrics->m_rWorldBoundingBox.m_B.m_fLatitude
+ || fMinLon > pRenderMetrics->m_rWorldBoundingBox.m_B.m_fLongitude)
+ {
+ continue; // not visible
}
gdk_draw_polygon(pPixmap, pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)],
TRUE, aPoints, pPointString->m_pPointsArray->len);
@@ -246,7 +204,7 @@
}
gint nLineWidth = (gint)fLineWidth;
-
+
// Set line style
gdk_gc_set_line_attributes(pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)],
nLineWidth, nDashStyle, nCapStyle, GDK_JOIN_MITER);
@@ -260,10 +218,10 @@
for(iString=0 ; iString<pPointStringsArray->len ; iString++) {
pPointString = g_ptr_array_index(pPointStringsArray, iString);
- gint nMaxX=G_MININT;
- gint nMaxY=G_MININT;
- gint nMinX=G_MAXINT;
- gint nMinY=G_MAXINT;
+ gdouble fMaxLat = MIN_LATITUDE; // init to the worst possible value so first point will override
+ gdouble fMinLat = MAX_LATITUDE;
+ gdouble fMaxLon = MIN_LONGITUDE;
+ gdouble fMinLon = MAX_LONGITUDE;
if(pPointString->m_pPointsArray->len >= 2) {
GdkPoint aPoints[MAX_GDK_LINE_SEGMENTS];
@@ -276,23 +234,23 @@
for(iPoint=0 ; iPoint<pPointString->m_pPointsArray->len ; iPoint++) {
pPoint = g_ptr_array_index(pPointString->m_pPointsArray, iPoint);
- gint nX,nY;
- nX = (gint)SCALE_X(pRenderMetrics, pPoint->m_fLongitude);
- nY = (gint)SCALE_Y(pRenderMetrics, pPoint->m_fLatitude);
-
// find extents
- nMaxX = max(nX,nMaxX);
- nMinX = min(nX,nMinX);
- nMaxY = max(nY,nMaxY);
- nMinY = min(nY,nMinY);
+ fMaxLat = max(pPoint->m_fLatitude,fMaxLat);
+ fMinLat = min(pPoint->m_fLatitude,fMinLat);
+ fMaxLon = max(pPoint->m_fLongitude,fMaxLon);
+ fMinLon = min(pPoint->m_fLongitude,fMinLon);
- aPoints[iPoint].x = nX;
- aPoints[iPoint].y = nY;
+ aPoints[iPoint].x = (gint)SCALE_X(pRenderMetrics, pPoint->m_fLongitude);
+ aPoints[iPoint].y = (gint)SCALE_Y(pRenderMetrics, pPoint->m_fLatitude);
}
- // overlap test
- if(nMaxX < 0 || nMaxY < 0 || nMinX > pRenderMetrics->m_nWindowWidth || nMinY > pRenderMetrics->m_nWindowHeight) {
- continue;
+ // rectangle overlap test
+ if(fMaxLat < pRenderMetrics->m_rWorldBoundingBox.m_A.m_fLatitude
+ || fMaxLon < pRenderMetrics->m_rWorldBoundingBox.m_A.m_fLongitude
+ || fMinLat > pRenderMetrics->m_rWorldBoundingBox.m_B.m_fLatitude
+ || fMinLon > pRenderMetrics->m_rWorldBoundingBox.m_B.m_fLongitude)
+ {
+ continue; // not visible
}
gdk_draw_lines(pPixmap, pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)], aPoints, pPointString->m_pPointsArray->len);
@@ -300,14 +258,59 @@
}
}
-static void map_draw_gdk_background(map_t* pMap, GdkPixmap* pPixmap)
+static void map_draw_gdk_tracks(map_t* pMap, GdkPixmap* pPixmap, rendermetrics_t* pRenderMetrics)
{
- GdkColor clr;
- clr.red = 240/255.0 * 65535;
- clr.green = 235/255.0 * 65535;
- clr.blue = 230/255.0 * 65535;
- gdk_gc_set_rgb_fg_color(pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)], &clr);
-
- gdk_draw_rectangle(pPixmap, pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)],
- TRUE, 0,0, pMap->m_MapDimensions.m_uWidth, pMap->m_MapDimensions.m_uHeight);
+ gint i;
+ for(i=0 ; i<pMap->m_pTracksArray->len ; i++) {
+ gint hTrack = g_array_index(pMap->m_pTracksArray, gint, i);
+
+ GdkColor clr;
+ clr.red = (gint)(0.5 * 65535.0);
+ clr.green = (gint)(0.5 * 65535.0);
+ clr.blue = (gint)(1.0 * 65535.0);
+ gdk_gc_set_rgb_fg_color(pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)], &clr);
+
+ pointstring_t* pPointString = track_get_pointstring(hTrack);
+ if(pPointString == NULL) continue;
+
+ if(pPointString->m_pPointsArray->len >= 2) {
+
+ if(pPointString->m_pPointsArray->len > MAX_GDK_LINE_SEGMENTS) {
+ g_warning("not drawing track with > %d segments\n", MAX_GDK_LINE_SEGMENTS);
+ continue;
+ }
+
+ GdkPoint aPoints[MAX_GDK_LINE_SEGMENTS];
+
+ gdouble fMaxLat = MIN_LATITUDE; // init to the worst possible value so first point will override
+ gdouble fMinLat = MAX_LATITUDE;
+ gdouble fMaxLon = MIN_LONGITUDE;
+ gdouble fMinLon = MAX_LONGITUDE;
+
+ gint iPoint;
+ for(iPoint=0 ; iPoint<pPointString->m_pPointsArray->len ; iPoint++) {
+ mappoint_t* pPoint = g_ptr_array_index(pPointString->m_pPointsArray, iPoint);
+
+ // find extents
+ fMaxLat = max(pPoint->m_fLatitude,fMaxLat);
+ fMinLat = min(pPoint->m_fLatitude,fMinLat);
+ fMaxLon = max(pPoint->m_fLongitude,fMaxLon);
+ fMinLon = min(pPoint->m_fLongitude,fMinLon);
+
+ aPoints[iPoint].x = (gint)SCALE_X(pRenderMetrics, pPoint->m_fLongitude);
+ aPoints[iPoint].y = (gint)SCALE_Y(pRenderMetrics, pPoint->m_fLatitude);
+ }
+
+ // rectangle overlap test
+ if(fMaxLat < pRenderMetrics->m_rWorldBoundingBox.m_A.m_fLatitude
+ || fMaxLon < pRenderMetrics->m_rWorldBoundingBox.m_A.m_fLongitude
+ || fMinLat > pRenderMetrics->m_rWorldBoundingBox.m_B.m_fLatitude
+ || fMinLon > pRenderMetrics->m_rWorldBoundingBox.m_B.m_fLongitude)
+ {
+ continue; // not visible
+ }
+
+ gdk_draw_lines(pPixmap, pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)], aPoints, pPointString->m_pPointsArray->len);
+ }
+ }
}
More information about the cairo-commit
mailing list