[cairo-commit] roadster/src Makefile.am, 1.12, 1.13 animator.c, NONE, 1.1 animator.h, NONE, 1.1 gpsclient.c, 1.6, 1.7 main.c, 1.14, 1.15 mainwindow.c, 1.25, 1.26 map.c, 1.27, 1.28 map_draw_cairo.c, 1.11, 1.12 map_draw_gdk.c, 1.6, 1.7 welcomewindow.c, 1.4, 1.5

Ian McIntosh commit at pdx.freedesktop.org
Fri Mar 18 00:37:38 PST 2005


Committed by: ian

Update of /cvs/cairo/roadster/src
In directory gabe:/tmp/cvs-serv17508/src

Modified Files:
	Makefile.am gpsclient.c main.c mainwindow.c map.c 
	map_draw_cairo.c map_draw_gdk.c welcomewindow.c 
Added Files:
	animator.c animator.h 
Log Message:
	* src/animator.h:
	* src/animator.c: New files.  Animates from 0.0 to 1.0 in various ways.
	* src/main.c: Add init for animator.c.
	* src/mainwindow.c: Add smoothly animated recentering.  Add different "draw pretty" timeout values for different operations.
	* src/gpsclient.c: Disabled temporarily, since we're not using it.
	* src/map_draw_cairo.c: Set font once per layer.  Do crude bounding box test for all objects (prevents nasty Cairo/X swap-death).
	* src/map_draw_gdk.c: Do crude bounding box test for all objects (faster).
	* src/welcomewindow.c: Point to new 2004 TIGER data.
	* data/layers.xml: Style tweaks.


Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/roadster/src/Makefile.am,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- Makefile.am	8 Mar 2005 18:40:50 -0000	1.12
+++ Makefile.am	18 Mar 2005 08:37:35 -0000	1.13
@@ -47,7 +47,8 @@
 	map_draw_cairo.c\
 	map_draw_gdk.c\
 	road.c\
-	prefs.c
+	prefs.c\
+	animator.c
 
 roadster_LDADD = \
 	$(GNOME_LIBS) \

--- NEW FILE: animator.c ---
/***************************************************************************
 *            animator.c
 *
 *  Copyright  2005  Ian McIntosh
 *  ian_mcintosh at linuxadvocate.org
 ****************************************************************************/

/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <gtk/gtk.h>

#include "animator.h"
#include "util.h"

void animator_init()
{

}

animator_t* animator_new(EAnimationType eAnimationType, gdouble fAnimationTimeInSeconds)
{
        animator_t* pNew = g_new0(animator_t, 1);

        pNew->m_pTimer = g_timer_new();
        pNew->m_eAnimationType = eAnimationType;
        pNew->m_fAnimationTimeInSeconds = fAnimationTimeInSeconds;

        return pNew;
}

void animator_destroy(animator_t* pAnimator)
{
	if(pAnimator == NULL) return;	// allow NULL

	g_timer_destroy(pAnimator->m_pTimer);

	g_free(pAnimator);
}

gboolean animator_is_done(animator_t* pAnimator)
{
        g_assert(pAnimator != NULL);

        gdouble fElapsedSeconds = g_timer_elapsed(pAnimator->m_pTimer, NULL);
        return (fElapsedSeconds >= pAnimator->m_fAnimationTimeInSeconds);
}

gdouble animator_get_time_percent(animator_t* pAnimator)
{
        g_assert(pAnimator != NULL);

        gdouble fElapsedSeconds = g_timer_elapsed(pAnimator->m_pTimer, NULL);

	// Cap at 1.0
	if(fElapsedSeconds >= pAnimator->m_fAnimationTimeInSeconds) {
		return 1.0;
	}
	return (fElapsedSeconds / pAnimator->m_fAnimationTimeInSeconds);
}

// returns a floating point 0.0 to 1.0
gdouble animator_get_progress(animator_t* pAnimator)
{
        g_assert(pAnimator != NULL);

	gdouble fTimePercent = animator_get_time_percent(pAnimator);

	// for now use a constant slide
	gdouble fReturn;
	 
	// constant movement
	//fReturn = fTimePercent;

	// The formula for a parabola is:  y = Ax^2 + Bx + C
	// Here, x is an input percentage (of time) from 0.0 to 1.0
	// ...and y is an output percetange (distance) from 0.0 to 1.0

	if(pAnimator->m_eAnimationType == ANIMATIONTYPE_SLIDE) {
		// Slide - accelerate for the first half (standard upward facing parabola going from x=0 to x=0.5) 
		if(fTimePercent < 0.5) {
			// use parabola function y=2x^2 + 0x + 0
			fReturn = (2*fTimePercent*fTimePercent);
		}
		// Slide - decelerate for the last half (try graphing this with x instead of fTimePercent and y instead of fReturn) 
		else {
			// this meets up with the above equation at (0.5,0.5)
			fReturn = 1.0 - (2.0 * (1.0 - fTimePercent) * (1.0 - fTimePercent));
		}
	}
	else if(pAnimator->m_eAnimationType == ANIMATIONTYPE_FAST_THEN_SLIDE) {
		if(fTimePercent < 0.5) {
			// go 80% of the distance in half the time
			fReturn = (fTimePercent / 0.5) * 0.8;
		}
		else {
			fReturn = 1.0 - (2.0 * (1.0 - fTimePercent) * (1.0 - fTimePercent));

			// compress it into last 10%
			fReturn = (fReturn * 0.2) + 0.8;
		}
	}
	else {
		g_assert_not_reached();
	}

	// Make 100% sure it's capped to 0.0 -> 1.0
	fReturn = min(fReturn, 1.0);
	fReturn = max(fReturn, 0.0);
	return fReturn;
}

/*
UINT CSequencer::SlideTo(UINT iFrame, ENTITY* pEntity, LONG nDestX, LONG nDestY, double fTripTime)
{
        RECT rcEntity;
        
        rcEntity = pEntity->rcDest;
        
        LONG nStartX = rcEntity.left;
        LONG nStartY = rcEntity.top;
        
        // We want trips to take about 'tripTime' seconds.
        //
	gdouble fDeltaX = nDestX - nStartX;
	gdouble fDeltaY = nDestY - nStartY;
	gdouble fDistance = (LONG)sqrt((fDeltaX * fDeltaX) + (fDeltaY * fDeltaY));
	fDistance = max( fDistance, 1.0 );

        LONG cFrames = (LONG)(m_uTargetFPS * fTripTime);

        // (avoid divide-by-zero problems)
        //
        dxy = max( dxy, 1 );
        cFrames = max( cFrames, 1 );
        
        // Graceful movement is solved by the parabola:
        //       y = (2*dxy*x*x)/(f*f) - (2*dxy*x)/(f) + (dxy)/(2)
        // where y = distance from starting point
        //   and x = frame number
        //
        // Find the coefficients (Ax^2 + Bx +C) of that formula.
        //
        double A =    ((double)(2 * dxy) / (cFrames * cFrames));
        double B = 0 -((double)(2 * dxy) / (cFrames));
	double C =    ((double)(    dxy) / (2));

	// Perform the first half of the movement (where we're accelerating)
	//
 
	LONG x, y;


	for (LONG iMove = cFrames/2; iMove < cFrames; iMove++)
    {
		double percentMove = ((A * iMove * iMove) + (B * iMove) + C) / dxy;

		x = nStartX + (LONG)( percentMove * dx );
		y = nStartY + (LONG)( percentMove * dy );

		MoveRectangle(&rcEntity, x,y);
		
		this->AddAction_MoveEntity(iFrame++, pEntity, rcEntity);
	}

    // Perform the second half of the movement (where we're decelerating)
    //
	for (iMove = 0; iMove < cFrames/2; iMove++)
    {
		double percentMove = 1.0 - (A * iMove * iMove + B * iMove + C) / dxy;

		x = nStartX + (LONG)( percentMove * dx );
		y = nStartY + (LONG)( percentMove * dy );

		MoveRectangle(&rcEntity, x,y);

		this->AddAction_MoveEntity(iFrame++, pEntity, rcEntity);
	}

	// Make sure they end up exactly where we told them to go
	if(x != nDestX || y != nDestY) {
		MoveRectangle(&rcEntity, x, y);

		this->AddAction_MoveEntity(iFrame, pEntity, rcEntity);
	}

	return iFrame;
}
*/

--- NEW FILE: animator.h ---
/***************************************************************************
 *            animator.h
 *
 *  Copyright  2005  Ian McIntosh
 *  ian_mcintosh at linuxadvocate.org
 ****************************************************************************/

/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef _ANIMATOR_H
#define _ANIMATOR_H

#include <gtk/gtk.h>

typedef enum { ANIMATIONTYPE_NONE=0, ANIMATIONTYPE_SLIDE=1, ANIMATIONTYPE_FAST_THEN_SLIDE=2 } EAnimationType;

typedef struct animator {
        GTimer* m_pTimer;
        EAnimationType m_eAnimationType;
        gdouble m_fAnimationTimeInSeconds;
} animator_t;

animator_t* animator_new(EAnimationType eAnimationType, gdouble fAnimationTimeInSeconds);
gdouble animator_get_progress(animator_t* pAnimator);
void animator_destroy(animator_t* pAnimator);

#endif

Index: gpsclient.c
===================================================================
RCS file: /cvs/cairo/roadster/src/gpsclient.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- gpsclient.c	4 Mar 2005 04:06:35 -0000	1.6
+++ gpsclient.c	18 Mar 2005 08:37:35 -0000	1.7
@@ -49,6 +49,7 @@
 
 static void gpsclient_connect(void)
 {
+return;
 	// don't do anything if already connected
 	if(g_GPSClient.m_pPublicGPSData->m_eStatus != GPS_STATUS_NO_GPSD) return;	// already connected
 

Index: main.c
===================================================================
RCS file: /cvs/cairo/roadster/src/main.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- main.c	7 Mar 2005 23:31:41 -0000	1.14
+++ main.c	18 Mar 2005 08:37:35 -0000	1.15
@@ -32,6 +32,7 @@
 #include "gpsclient.h"
 #include "scenemanager.h"
 #include "prefs.h"
+#include "animator.h"
 
 static gboolean main_init(void);
 static void main_deinit(void);
@@ -99,6 +100,9 @@
 	g_print("initializing gui\n");
 	gui_init();
 
+	g_print("initializing animator\n");
+	animator_init();
+	
 	g_print("initializing db\n");
 	db_init();
 

Index: mainwindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/mainwindow.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- mainwindow.c	14 Mar 2005 02:04:30 -0000	1.25
+++ mainwindow.c	18 Mar 2005 08:37:35 -0000	1.26
@@ -43,6 +43,7 @@
 #include "databasewindow.h"
 #include "mainwindow.h"
 #include "glyph.h"
+#include "animator.h"
 
 #include <gdk/gdk.h>
 #include <gdk/gdkx.h>
@@ -56,11 +57,19 @@
 #define PROGRAM_COPYRIGHT		"Copyright (c) 2005 Ian McIntosh"
 #define PROGRAM_DESCRIPTION		"Mapping for everyone!"
 
-#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	(60)	// how far to move every (above) MS
+// how long after stopping various movements should we redraw in high-quality mode
+#define DRAW_PRETTY_SCROLL_TIMEOUT_MS	(110)	// NOTE: should be longer than the SCROLL_TIMEOUT_MS below!!
+#define DRAW_PRETTY_ZOOM_TIMEOUT_MS	(180)
+#define DRAW_PRETTY_DRAG_TIMEOUT_MS	(250)
+#define DRAW_PRETTY_RESIZE_TIMEOUT_MS	(180)
+
+#define SCROLL_TIMEOUT_MS		(80)	// how often (in MS) to move
+#define SCROLL_DISTANCE_IN_PIXELS	(80)	// 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
 
+#define SLIDE_TIMEOUT_MS		(90)	// time between frames (in MS) for smooth-sliding (on double click?)
+#define	SLIDE_TIME_IN_SECONDS		(1.2)	// how long the whole slide should take, in seconds
+
 // Layerlist columns
 #define LAYERLIST_COLUMN_ENABLED	(0)
 #define LAYERLIST_COLUMN_NAME		(1)
@@ -95,9 +104,10 @@
 static gboolean mainwindow_on_expose_event(GtkWidget *pDrawingArea, GdkEventExpose *event, gpointer data);
 static gint mainwindow_on_configure_event(GtkWidget *pDrawingArea, GdkEventConfigure *event);
 static gboolean mainwindow_callback_on_gps_redraw_timeout(gpointer pData);
+static gboolean mainwindow_callback_on_slide_timeout(gpointer pData);
 static void mainwindow_setup_selected_tool(void);
 
-
+void mainwindow_map_center_on_mappoint(mappoint_t* pPoint);
 void mainwindow_map_center_on_windowpoint(gint nX, gint nY);
 
 struct {
@@ -155,12 +165,18 @@
 	
 	gboolean m_bMouseDragging;
 	gboolean m_bMouseDragMovement;
-	screenpoint_t m_ptClickLocation;
+	screenpoint_t m_ptClickLocation;	
 
 	gint m_nCurrentGPSPath;
 	gint m_nGPSLocationGlyph;
 	gint m_nDrawPrettyTimeoutID;
 	gint m_nScrollTimeoutID;
+
+	// Sliding
+	gboolean m_bSliding;
+	mappoint_t m_ptSlideStartLocation;
+	mappoint_t m_ptSlideEndLocation;
+	animator_t* m_pAnimator;
 } g_MainWindow = {0};
 
 
@@ -244,7 +260,9 @@
 	g_MainWindow.m_pTooltips			= gtk_tooltips_new();
 	g_MainWindow.m_pSpeedLabel			= GTK_LABEL(glade_xml_get_widget(pGladeXML, "speedlabel"));		g_return_if_fail(g_MainWindow.m_pSpeedLabel != NULL);
 	g_MainWindow.m_pGPSSignalStrengthProgressBar = GTK_PROGRESS_BAR(glade_xml_get_widget(pGladeXML, "gpssignalprogressbar"));		g_return_if_fail(g_MainWindow.m_pGPSSignalStrengthProgressBar != NULL);
-	
+
+	g_signal_connect(G_OBJECT(g_MainWindow.m_pWindow), "delete_event", G_CALLBACK(gtk_main_quit), NULL);
+
 	// create drawing area
 	g_MainWindow.m_pDrawingArea = GTK_DRAWING_AREA(gtk_drawing_area_new());
 	// create map
@@ -263,12 +281,12 @@
 	gtk_box_pack_end(GTK_BOX(g_MainWindow.m_pContentBox), GTK_WIDGET(g_MainWindow.m_pDrawingArea),
 					TRUE, // expand
 					TRUE, // fill
-					0);
+                                        0);
 	gtk_widget_show(GTK_WIDGET(g_MainWindow.m_pDrawingArea));
 
 	cursor_init();
 
-	g_MainWindow.m_nGPSLocationGlyph = glyph_load(PACKAGE_DATA_DIR"/car.svg");
+        g_MainWindow.m_nGPSLocationGlyph = glyph_load(PACKAGE_DATA_DIR"/car.svg");
 
 	/*
 	**
@@ -337,9 +355,12 @@
 //                         -1);
 //         }
 
-	g_timeout_add(TIMER_GPS_REDRAW_INTERVAL_MS,
-			  (GSourceFunc)mainwindow_callback_on_gps_redraw_timeout,
-			  (gpointer)NULL);
+	// GPS check timeout
+	g_timeout_add(TIMER_GPS_REDRAW_INTERVAL_MS, (GSourceFunc)mainwindow_callback_on_gps_redraw_timeout, (gpointer)NULL);
+
+	// Slide timeout
+//	g_MainWindow.m_pAnimator = animator_new(ANIMATIONTYPE_SLIDE, 10.0);
+	g_timeout_add(SLIDE_TIMEOUT_MS, (GSourceFunc)mainwindow_callback_on_slide_timeout, (gpointer)NULL);
 
 	// give it a call to init everything
 	mainwindow_callback_on_gps_redraw_timeout(NULL);
@@ -379,12 +400,12 @@
 	}
 }
 
-void mainwindow_set_draw_pretty_timeout()
+void mainwindow_set_draw_pretty_timeout(gint nTimeoutInMilliseconds)
 {
 	// cancel existing one, if one exists
 	mainwindow_cancel_draw_pretty_timeout();
 
-	g_MainWindow.m_nDrawPrettyTimeoutID = g_timeout_add(DRAW_PRETTY_TIMEOUT_MS, mainwindow_on_draw_pretty_timeout, NULL);
+	g_MainWindow.m_nDrawPrettyTimeoutID = g_timeout_add(nTimeoutInMilliseconds, mainwindow_on_draw_pretty_timeout, NULL);
 	g_assert(g_MainWindow.m_nDrawPrettyTimeoutID != 0);
 }
 
@@ -403,7 +424,7 @@
 
 		mainwindow_map_center_on_windowpoint((nWidth / 2) + nDeltaX, (nHeight / 2) + nDeltaY);
 		mainwindow_draw_map(DRAWFLAG_GEOMETRY);
-		mainwindow_set_draw_pretty_timeout();
+		mainwindow_set_draw_pretty_timeout(DRAW_PRETTY_SCROLL_TIMEOUT_MS);
 	}
 }
 
@@ -471,7 +492,7 @@
 
 	snprintf(buf, 199, "1:%d", uZoomLevelScale);
 	mainwindow_set_statusbar_zoomscale(buf);
-	GTK_PROCESS_MAINLOOP;
+//	GTK_PROCESS_MAINLOOP;
 }
 
 void mainwindow_statusbar_update_position(void)
@@ -481,7 +502,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;
+//	GTK_PROCESS_MAINLOOP;    ugh this makes text flash when stopping scrolling
 }
 
 /*
@@ -545,7 +566,7 @@
 	mainwindow_statusbar_update_zoomscale();
 
 	mainwindow_draw_map(DRAWFLAG_GEOMETRY);
-	mainwindow_set_draw_pretty_timeout();
+	mainwindow_set_draw_pretty_timeout(DRAW_PRETTY_ZOOM_TIMEOUT_MS);
 }
 
 //
@@ -557,6 +578,8 @@
         g_signal_handlers_block_by_func(g_MainWindow.m_pZoomScale, mainwindow_on_zoomscale_value_changed, NULL);
 	gtk_range_set_value(GTK_RANGE(g_MainWindow.m_pZoomScale), nZoomLevel);
 	g_signal_handlers_unblock_by_func(g_MainWindow.m_pZoomScale, mainwindow_on_zoomscale_value_changed, NULL);
+
+	mainwindow_statusbar_update_zoomscale();
 }
 
 static void zoom_in_one(void)
@@ -588,22 +611,22 @@
 
 void mainwindow_on_aboutmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data)
 {
-	const gchar *ppAuthors[] = {
-		"Ian McIntosh <ian_mcintosh at linuxadvocate.org>",
-		"Nathan Fredrickson <nathan at silverorange.com>",
-		NULL
-	};
-
-  	GtkWidget *pAboutWindow = gnome_about_new(
-	  				PROGRAM_NAME,
-	  				VERSION,
-					PROGRAM_COPYRIGHT,
-					PROGRAM_DESCRIPTION,
-	  				(const gchar **) ppAuthors,
-					NULL,
-	 				NULL,
-					NULL);
-	gtk_widget_show(pAboutWindow);
+//         const gchar *ppAuthors[] = {
+//                 "Ian McIntosh <ian_mcintosh at linuxadvocate.org>",
+//                 "Nathan Fredrickson <nathan at silverorange.com>",
+//                 NULL
+//         };
+//
+//         GtkWidget *pAboutWindow = gnome_about_new(
+//                                         PROGRAM_NAME,
+//                                         VERSION,
+//                                         PROGRAM_COPYRIGHT,
+//                                         PROGRAM_DESCRIPTION,
+//                                         (const gchar **) ppAuthors,
+//                                         NULL,
+//                                         NULL,
+//                                         NULL);
+//         gtk_widget_show(pAboutWindow);
 }
 
 // Toggle toolbar visibility
@@ -627,13 +650,15 @@
 void mainwindow_on_zoomin_activate(GtkMenuItem *menuitem, gpointer user_data)
 {
 	zoom_in_one();
-	mainwindow_draw_map(DRAWFLAG_ALL);
+	mainwindow_draw_map(DRAWFLAG_GEOMETRY);
+	mainwindow_set_draw_pretty_timeout(DRAW_PRETTY_ZOOM_TIMEOUT_MS);
 }
 
 void mainwindow_on_zoomout_activate(GtkMenuItem *menuitem, gpointer user_data)
 {
 	zoom_out_one();
-	mainwindow_draw_map(DRAWFLAG_ALL);
+	mainwindow_draw_map(DRAWFLAG_GEOMETRY);
+	mainwindow_set_draw_pretty_timeout(DRAW_PRETTY_ZOOM_TIMEOUT_MS);
 }
 
 void mainwindow_on_fullscreenmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data)
@@ -724,11 +749,11 @@
 				g_MainWindow.m_bScrolling = TRUE;
 				g_MainWindow.m_eScrollDirection = eScrollDirection;
 
-				mainwindow_scroll_direction(g_MainWindow.m_eScrollDirection, SCROLL_DISTANCE_IN_PIXELS);
+				// XXX: s.garrity asked for a single click to scroll once, BUT when we added double-click to slide
+				// it resulted in weird behavior
+		//		mainwindow_scroll_direction(g_MainWindow.m_eScrollDirection, SCROLL_DISTANCE_IN_PIXELS);
+				
 				mainwindow_set_scroll_timeout();
-				//}
-				//gdk_cursor_unref(pCursor);
-
 			}
 			else {
 				// else begin a drag
@@ -773,8 +798,21 @@
 			}
 		}
 		else if(event->type == GDK_2BUTTON_PRESS) {
-			mainwindow_map_center_on_windowpoint(nX, nY);
-			mainwindow_draw_map(DRAWFLAG_ALL);
+			
+			animator_destroy(g_MainWindow.m_pAnimator);
+
+			g_MainWindow.m_bSliding = TRUE;
+			g_MainWindow.m_pAnimator = animator_new(ANIMATIONTYPE_FAST_THEN_SLIDE, SLIDE_TIME_IN_SECONDS);
+
+			// set startpoint
+			map_get_centerpoint(g_MainWindow.m_pMap, &g_MainWindow.m_ptSlideStartLocation);
+
+			// set endpoint
+			screenpoint_t ptScreenPoint = {nX, nY};
+			map_windowpoint_to_mappoint(g_MainWindow.m_pMap, &ptScreenPoint, &(g_MainWindow.m_ptSlideEndLocation));
+
+//			map_center_on_windowpoint(g_MainWindow.m_pMap, nX, nY);
+//			mainwindow_draw_map(DRAWFLAG_ALL);
 		}
 	}
 	// Right-click?
@@ -796,18 +834,17 @@
 static gboolean mainwindow_on_mouse_motion(GtkWidget* w, GdkEventMotion *event)
 {
         gint nX,nY;
-	gint nState;
+
 	if (event->is_hint) {
-		gdk_window_get_pointer(event->window, &nX, &nY, &nState);
+		gdk_window_get_pointer(w->window, &nX, &nY, NULL);
 	}
 	else
 	{
 		nX = event->x;
 		nY = event->y;
-		nState = event->state;
+		//nState = event->state;
 	}
 
-
 	gint nWidth = GTK_WIDGET(g_MainWindow.m_pDrawingArea)->allocation.width;
 	gint nHeight = GTK_WIDGET(g_MainWindow.m_pDrawingArea)->allocation.height;
 
@@ -826,7 +863,7 @@
 
 		mainwindow_map_center_on_windowpoint((nWidth / 2) + nDeltaX, (nHeight / 2) + nDeltaY);
 		mainwindow_draw_map(DRAWFLAG_GEOMETRY);
-		mainwindow_set_draw_pretty_timeout();
+		mainwindow_set_draw_pretty_timeout(DRAW_PRETTY_DRAG_TIMEOUT_MS);
 
 		g_MainWindow.m_ptClickLocation.m_nX = nX;
 		g_MainWindow.m_ptClickLocation.m_nY = nY;
@@ -869,28 +906,31 @@
 	if(event->direction == GDK_SCROLL_UP) {
 		zoom_in_one();
 		mainwindow_draw_map(DRAWFLAG_GEOMETRY);
-		mainwindow_set_draw_pretty_timeout();
+		mainwindow_set_draw_pretty_timeout(DRAW_PRETTY_ZOOM_TIMEOUT_MS);
 	}
 	else if(event->direction == GDK_SCROLL_DOWN) {
 		zoom_out_one();
 		mainwindow_draw_map(DRAWFLAG_GEOMETRY);
-		mainwindow_set_draw_pretty_timeout();
+		mainwindow_set_draw_pretty_timeout(DRAW_PRETTY_ZOOM_TIMEOUT_MS);
 	}
 }
 
 static void mainwindow_begin_import_geography_data(void)
 {
+g_print("starting..\n");
+
 	GtkWidget* pDialog = gtk_file_chooser_dialog_new(
 				"Select Map Data for Import",
-                g_MainWindow.m_pWindow,
-                GTK_FILE_CHOOSER_ACTION_OPEN,
-    			GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                		g_MainWindow.m_pWindow,
+		                GTK_FILE_CHOOSER_ACTION_OPEN,
+    				GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
 				"Import", GTK_RESPONSE_ACCEPT,
 				NULL);
-
+g_print("setting..\n");
 	gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(pDialog), TRUE);
 	gtk_widget_set_sensitive(GTK_WIDGET(g_MainWindow.m_pWindow), FALSE);
-	
+
+g_print("running..\n");
 	gint nResponse = gtk_dialog_run(GTK_DIALOG(pDialog));
 	gtk_widget_hide(pDialog);
 
@@ -957,7 +997,7 @@
 	map_set_dimensions(g_MainWindow.m_pMap, &dim);
 
 	mainwindow_draw_map(DRAWFLAG_GEOMETRY);
-	mainwindow_set_draw_pretty_timeout();
+	mainwindow_set_draw_pretty_timeout(DRAW_PRETTY_RESIZE_TIMEOUT_MS);
 	return TRUE;
 }
 
@@ -1049,6 +1089,46 @@
 	return TRUE;
 }
 
+static gboolean mainwindow_callback_on_slide_timeout(gpointer pData)
+{
+	if(g_MainWindow.m_bSliding) {
+		g_assert(g_MainWindow.m_pAnimator != NULL);
+
+		// Figure out the progress along the path and interpolate 
+		// between startpoint and endpoint
+
+		gdouble fPercent = animator_get_progress(g_MainWindow.m_pAnimator);
+		gboolean bDone = animator_is_done(g_MainWindow.m_pAnimator);
+		if(bDone) {
+			animator_destroy(g_MainWindow.m_pAnimator);
+			g_MainWindow.m_pAnimator = NULL;
+			g_MainWindow.m_bSliding = FALSE;
+
+			fPercent = 1.0;
+
+			// should we delete the timer?
+		}
+
+		gdouble fDeltaLat = g_MainWindow.m_ptSlideEndLocation.m_fLatitude - g_MainWindow.m_ptSlideStartLocation.m_fLatitude;
+		gdouble fDeltaLon = g_MainWindow.m_ptSlideEndLocation.m_fLongitude - g_MainWindow.m_ptSlideStartLocation.m_fLongitude;
+
+		mappoint_t ptNew;
+		ptNew.m_fLatitude = g_MainWindow.m_ptSlideStartLocation.m_fLatitude + (fPercent * fDeltaLat);
+		ptNew.m_fLongitude = g_MainWindow.m_ptSlideStartLocation.m_fLongitude + (fPercent * fDeltaLon);
+
+		mainwindow_map_center_on_mappoint(&ptNew);
+		if(bDone) {
+			// when done, draw a full frame
+			mainwindow_draw_map(DRAWFLAG_GEOMETRY);
+			mainwindow_draw_map(DRAWFLAG_ALL);
+		}
+		else {
+			mainwindow_draw_map(DRAWFLAG_GEOMETRY);
+		}
+	}
+	return TRUE;
+}
+
 void mainwindow_map_center_on_windowpoint(gint nX, gint nY)
 {
 	// Calculate the # of pixels away from the center point the click was

Index: map.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- map.c	14 Mar 2005 02:04:30 -0000	1.27
+++ map.c	18 Mar 2005 08:37:35 -0000	1.28
@@ -84,7 +84,7 @@
 	{   20000, ""}, 	// 7
 	{   10000, ""},		// 8
 	{    4000, ""},		// 9
-	{    1800, ""},		// 10
+	{    1700, ""},		// 10
 };
 
 draworder_t layerdraworder[NUM_SUBLAYER_TO_DRAW] = {
@@ -187,6 +187,8 @@
 	map_get_render_metrics(pMap, &renderMetrics);
 	rendermetrics_t* pRenderMetrics = &renderMetrics;
 
+//g_print("drawing at %f,%f\n", pMap->m_MapCenter.m_fLatitude, pMap->m_MapCenter.m_fLongitude);
+
 	//
 	// Load geometry
 	//
@@ -508,6 +510,7 @@
 	gdouble fLatStart = (gdouble)nLatStart / TILE_SHIFT;
 	gdouble fLonStart = (gdouble)nLonStart / TILE_SHIFT;
 
+//	g_print("%f < %f\n", fLatStart, pRect->m_A.m_fLatitude);
 	g_assert(fLatStart <= pRect->m_A.m_fLatitude);
         g_assert(fLonStart <= pRect->m_A.m_fLongitude);
 

Index: map_draw_cairo.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map_draw_cairo.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- map_draw_cairo.c	13 Mar 2005 23:31:21 -0000	1.11
+++ map_draw_cairo.c	18 Mar 2005 08:37:35 -0000	1.12
@@ -25,7 +25,7 @@
 
 #define RENDERING_THREAD_YIELD	// do nothing
 
-#define	ACCEPTABLE_LINE_LABEL_OVERDRAW_IN_PIXELS_SQUARED (25*25)
+#define	ACCEPTABLE_LINE_LABEL_OVERDRAW_IN_PIXELS_SQUARED (38*38)
 
 #define HACK_AROUND_CAIRO_LINE_CAP_BUG	// enable to ensure roads have rounded caps if the style dictates
 
@@ -49,14 +49,22 @@
 #include "locationset.h"
 #include "scenemanager.h"
[...1512 lines suppressed...]
-	for(i=0 ; i<pPointStringsArray->len ; i++) {
-		RENDERING_THREAD_YIELD;
-		
-		pointstring_t* pPointString = g_ptr_array_index(pPointStringsArray, i);
-		if(pPointString->m_pszName[0] != '\0') {
-			map_draw_cairo_polygon_label(pMap, pCairo, pLabelStyle, pRenderMetrics, pPointString, pPointString->m_pszName);
-		}
-	}
-}
-
 void map_draw_cairo_gps_trail(map_t* pMap, cairo_t* pCairo, pointstring_t* pPointString)
 {
 	rendermetrics_t renderMetrics = {0};
@@ -1018,4 +1326,5 @@
 		cairo_stroke(pCairo);
 	}
 }
-
+*/
+#endif

Index: map_draw_gdk.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map_draw_gdk.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- map_draw_gdk.c	13 Mar 2005 23:31:21 -0000	1.6
+++ map_draw_gdk.c	18 Mar 2005 08:37:35 -0000	1.7
@@ -52,7 +52,7 @@
 	gdk_gc_get_values(pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)], &gcValues);
 
 	// 2. Drawing
-	
+
 	// 2.1. Draw Background
 	if(nDrawFlags & DRAWFLAG_GEOMETRY) {
 		map_draw_gdk_background(pMap, pPixmap);
@@ -64,7 +64,7 @@
 		for(i=0 ; i<NUM_ELEMS(layerdraworder) ; i++) {
 			gint nLayer = layerdraworder[i].nLayer;
 			gint nSubLayer = layerdraworder[i].nSubLayer;
-	
+
 			if(layerdraworder[i].eSubLayerRenderType == SUBLAYER_RENDERTYPE_LINES) {
 				map_draw_gdk_layer_lines(pMap, pPixmap,
 						pRenderMetrics,
@@ -72,7 +72,8 @@
 				/* style */ 	&(g_aLayers[nLayer]->m_Style.m_aSubLayers[nSubLayer]),
 						&(g_aLayers[nLayer]->m_TextLabelStyle));
 			}
-			else if(layerdraworder[i].eSubLayerRenderType == SUBLAYER_RENDERTYPE_POLYGONS) {
+			else 
+                if(layerdraworder[i].eSubLayerRenderType == SUBLAYER_RENDERTYPE_POLYGONS) {
 				map_draw_gdk_layer_polygons(pMap, pPixmap,
 						pRenderMetrics,
 				/* geometry */ 	pMap->m_apLayerData[nLayer]->m_pPointStringsArray,
@@ -104,9 +105,11 @@
 	// Raise the tolerance way up for thin lines
 	gint nCapStyle = pSubLayerStyle->m_nCapStyle;
 
+	gint nLineWidth = (gint)fLineWidth;
+
 	// Set line style
 	gdk_gc_set_line_attributes(pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)],
-			   ((gint)fLineWidth), GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_MITER);
+			   nLineWidth, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_MITER);
 
 	GdkColor clr;
 	clr.red = pSubLayerStyle->m_clrColor.m_fRed * 65535;
@@ -117,6 +120,11 @@
 	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;
+
 		if(pPointString->m_pPointsArray->len >= 2) {
 			GdkPoint aPoints[MAX_GDK_LINE_SEGMENTS];
 
@@ -125,12 +133,25 @@
 				continue;
 			}
 
-			// start at index 1 (0 was used above)
 			for(iPoint=0 ; iPoint<pPointString->m_pPointsArray->len ; iPoint++) {
 				pPoint = g_ptr_array_index(pPointString->m_pPointsArray, iPoint);
-				
-				aPoints[iPoint].x = SCALE_X(pRenderMetrics, pPoint->m_fLongitude);
-				aPoints[iPoint].y = SCALE_Y(pRenderMetrics, pPoint->m_fLatitude);
+
+				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_polygon(pPixmap, pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)],
 				TRUE, aPoints, pPointString->m_pPointsArray->len);
@@ -167,9 +188,11 @@
 		nCapStyle = GDK_CAP_PROJECTING;
 	}
 
+	gint nLineWidth = (gint)fLineWidth;
+
 	// Set line style
 	gdk_gc_set_line_attributes(pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)],
-			   ((gint)fLineWidth), nDashStyle, nCapStyle, GDK_JOIN_MITER);
+			   nLineWidth, nDashStyle, nCapStyle, GDK_JOIN_MITER);
 
 	GdkColor clr;
 	clr.red = pSubLayerStyle->m_clrColor.m_fRed * 65535;
@@ -180,6 +203,11 @@
 	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;
+	
 		if(pPointString->m_pPointsArray->len >= 2) {
 			GdkPoint aPoints[MAX_GDK_LINE_SEGMENTS];
 
@@ -188,15 +216,29 @@
 				continue;
 			}
 
-			// start at index 1 (0 was used above)
 			for(iPoint=0 ; iPoint<pPointString->m_pPointsArray->len ; iPoint++) {
 				pPoint = g_ptr_array_index(pPointString->m_pPointsArray, iPoint);
-				
-				aPoints[iPoint].x = SCALE_X(pRenderMetrics, pPoint->m_fLongitude);
-				aPoints[iPoint].y = SCALE_Y(pRenderMetrics, pPoint->m_fLatitude);
+
+				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;
 			}
-			gdk_draw_lines(pPixmap, pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)],
-				aPoints, pPointString->m_pPointsArray->len);
+
+			// 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);
    		}
 	}
 }

Index: welcomewindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/welcomewindow.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- welcomewindow.c	4 Mar 2005 09:27:26 -0000	1.4
+++ welcomewindow.c	18 Mar 2005 08:37:35 -0000	1.5
@@ -31,7 +31,7 @@
 #include "mainwindow.h"
 #include "welcomewindow.h"
 
-#define URL_CENSUS_GOV_TIGER_DATA_WEBSITE ("http://www.census.gov/geo/www/tiger/tiger2003/tgr2003.html")
+#define URL_CENSUS_GOV_TIGER_DATA_WEBSITE ("http://www.census.gov/geo/www/tiger/tiger2004fe/tgr2004fe.html")
 
 struct {
 	GtkWindow* m_pWindow;




More information about the cairo-commit mailing list