|
From: Paul F. <pg...@us...> - 2008-11-04 14:56:41
|
Update of /cvsroot/roadmap/roadmap/src In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv8277 Modified Files: roadmap_canvas.h roadmap_math.c roadmap_math.h roadmap_screen.c Log Message: support for chorded (multitouch) rotation and drag, on the iphone. also support for bezier lines in iphone drawing routines. (all from morten bek.) Index: roadmap_canvas.h =================================================================== RCS file: /cvsroot/roadmap/roadmap/src/roadmap_canvas.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** roadmap_canvas.h 7 Oct 2008 00:42:20 -0000 1.12 --- roadmap_canvas.h 4 Nov 2008 14:56:23 -0000 1.13 *************** *** 33,36 **** --- 33,38 ---- #include "roadmap_gui.h" + #define MAX_CHORDING_POINTS 5 + enum { IMAGE_NORMAL, IMAGE_SELECTED *************** *** 204,207 **** --- 206,217 ---- int size, const char *text); + #ifdef IPHONE + void roadmap_canvas_get_chording_pt (RoadMapGuiPoint points[MAX_CHORDING_POINTS]); + int roadmap_canvas_is_chording(); + #else + void roadmap_canvas_get_chording_pt (RoadMapGuiPoint points[MAX_CHORDING_POINTS]); + #define roadmap_canvas_is_chording() 0 + #endif + #endif // INCLUDE__ROADMAP_CANVAS__H Index: roadmap_math.c =================================================================== RCS file: /cvsroot/roadmap/roadmap/src/roadmap_math.c,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** roadmap_math.c 4 Nov 2008 14:32:02 -0000 1.55 --- roadmap_math.c 4 Nov 2008 14:56:23 -0000 1.56 *************** *** 1226,1230 **** } - #ifdef IPHONE float roadmap_math_get_angle (RoadMapGuiPoint *point0, RoadMapGuiPoint *point1) { --- 1226,1229 ---- *************** *** 1234,1240 **** } - #endif - - void roadmap_math_to_position (const RoadMapGuiPoint *point, RoadMapPosition *position, --- 1233,1236 ---- Index: roadmap_screen.c =================================================================== RCS file: /cvsroot/roadmap/roadmap/src/roadmap_screen.c,v retrieving revision 1.133 retrieving revision 1.134 diff -C2 -d -r1.133 -r1.134 *** roadmap_screen.c 7 Oct 2008 19:45:59 -0000 1.133 --- roadmap_screen.c 4 Nov 2008 14:56:23 -0000 1.134 *************** *** 152,155 **** --- 152,161 ---- + // This is only supported for the iphone right now + static int RoadMapScreenChordingEvent = 0; + static RoadMapGuiPoint RoadMapScreenChordingAnchors[MAX_CHORDING_POINTS]; + static float RoadMapScreenChordingAngle; + static int RoadMapScreenChordingIsRotating = 0; + /* Define the buffers used to group all actual drawings. */ *************** *** 1688,1693 **** RoadMapScreenDragging = 1; ! RoadMapScreenPointerLocation = *point; roadmap_screen_freeze (); /* We don't want to move with the GPS position. */ return 1; --- 1694,1732 ---- RoadMapScreenDragging = 1; ! ! if (roadmap_canvas_is_chording() && !RoadMapScreenChordingEvent) { ! RoadMapScreenChordingEvent = 1; ! roadmap_canvas_get_chording_pt (RoadMapScreenChordingAnchors); ! RoadMapGuiPoint *anchors = RoadMapScreenChordingAnchors; ! ! if (anchors[2].x == 1) { //Rotate mode ! //save angle ! RoadMapScreenChordingIsRotating = 1; ! RoadMapScreenChordingAngle = ! roadmap_math_get_angle (&anchors[0], &anchors[1]); ! } else { //Drag / zoom mode ! point->x = abs(anchors[1].x - anchors[0].x) /2; ! if (anchors[0].x > anchors[1].x) { ! point->x += anchors[1].x; ! } else { ! point->x += anchors[0].x; ! } ! ! point->y = abs(anchors[1].y - anchors[0].y) /2; ! if (anchors[0].y > anchors[1].y) { ! point->y += anchors[1].y; ! } else { ! point->y += anchors[0].y; ! } ! RoadMapScreenPointerLocation = *point; ! } ! ! } else { ! ! RoadMapScreenPointerLocation = *point; ! } ! roadmap_screen_freeze (); /* We don't want to move with the GPS position. */ + roadmap_screen_refresh (); return 1; *************** *** 1695,1705 **** static int roadmap_screen_drag_end (RoadMapGuiPoint *point) { ! roadmap_screen_record_move ! (RoadMapScreenPointerLocation.x - point->x, ! RoadMapScreenPointerLocation.y - point->y); RoadMapScreenDragging = 0; - RoadMapScreenPointerLocation = *point; roadmap_screen_unfreeze (); roadmap_screen_refresh (); --- 1734,1751 ---- static int roadmap_screen_drag_end (RoadMapGuiPoint *point) { + if (RoadMapScreenChordingEvent) { ! RoadMapScreenChordingEvent = 0; ! RoadMapScreenChordingIsRotating = 0; ! ! } else { ! ! roadmap_screen_record_move ! (RoadMapScreenPointerLocation.x - point->x, ! RoadMapScreenPointerLocation.y - point->y); + RoadMapScreenPointerLocation = *point; + } RoadMapScreenDragging = 0; roadmap_screen_unfreeze (); roadmap_screen_refresh (); *************** *** 1710,1728 **** static int roadmap_screen_drag_motion (RoadMapGuiPoint *point) { ! if (RoadMapScreenViewMode == VIEW_MODE_3D) { ! RoadMapGuiPoint p = *point; ! RoadMapGuiPoint p2 = RoadMapScreenPointerLocation; ! roadmap_math_unproject (&p); ! roadmap_math_unproject (&p2); ! roadmap_screen_record_move (p2.x - p.x, p2.y - p.y); ! ! } else { ! roadmap_screen_record_move ! (RoadMapScreenPointerLocation.x - point->x, ! RoadMapScreenPointerLocation.y - point->y); } --- 1756,1833 ---- static int roadmap_screen_drag_motion (RoadMapGuiPoint *point) { ! if (roadmap_canvas_is_chording() && RoadMapScreenChordingEvent) { ! RoadMapGuiPoint ChordingPt[MAX_CHORDING_POINTS]; ! roadmap_canvas_get_chording_pt (ChordingPt); ! ! if (!RoadMapScreenChordingIsRotating) { ! // Calculate zoom change ! long diag_new = roadmap_math_screen_distance ! (&ChordingPt[0], &ChordingPt[1], MATH_DIST_ACTUAL); ! long diag_anch = roadmap_math_screen_distance ! (&RoadMapScreenChordingAnchors[0], &RoadMapScreenChordingAnchors[1], MATH_DIST_ACTUAL); ! float scale = (float)diag_anch / (float)diag_new; ! ! roadmap_math_zoom_set (ceil(roadmap_math_get_zoom() * scale)); ! roadmap_layer_adjust (); ! ! // Calculate point position ! point->x = abs(ChordingPt[1].x - ChordingPt[0].x) /2; ! if (ChordingPt[0].x > ChordingPt[1].x) { ! point->x += ChordingPt[1].x; ! } else { ! point->x += ChordingPt[0].x; ! } ! ! point->y = abs(ChordingPt[1].y - ChordingPt[0].y) /2; ! if (ChordingPt[0].y > ChordingPt[1].y) { ! point->y += ChordingPt[1].y; ! } else { ! point->y += ChordingPt[0].y; ! } ! ! roadmap_screen_record_move ! (RoadMapScreenPointerLocation.x - point->x, ! RoadMapScreenPointerLocation.y - point->y); ! ! RoadMapScreenPointerLocation = *point; ! } else { ! float angle_new = roadmap_math_get_angle (&ChordingPt[0], &ChordingPt[1]); ! ! int angle_delta = ceil (angle_new - RoadMapScreenChordingAngle); ! if (angle_delta > 15) { ! roadmap_screen_rotate (15); ! RoadMapScreenChordingAngle += 15; ! } else if (angle_delta < -15) { ! roadmap_screen_rotate (-15); ! RoadMapScreenChordingAngle -= 15; ! } else { ! roadmap_screen_rotate (angle_delta); ! RoadMapScreenChordingAngle += angle_delta; ! } ! } ! ! RoadMapScreenChordingAnchors[0].x = ChordingPt[0].x; ! RoadMapScreenChordingAnchors[0].y = ChordingPt[0].y; ! RoadMapScreenChordingAnchors[1].x = ChordingPt[1].x; ! RoadMapScreenChordingAnchors[1].y = ChordingPt[1].y; ! } else { ! if (RoadMapScreenViewMode == VIEW_MODE_3D) { ! RoadMapGuiPoint p = *point; ! RoadMapGuiPoint p2 = RoadMapScreenPointerLocation; ! roadmap_math_unproject (&p); ! roadmap_math_unproject (&p2); ! ! roadmap_screen_record_move (p2.x - p.x, p2.y - p.y); ! ! } else { ! ! roadmap_screen_record_move ! (RoadMapScreenPointerLocation.x - point->x, ! RoadMapScreenPointerLocation.y - point->y); ! } } Index: roadmap_math.h =================================================================== RCS file: /cvsroot/roadmap/roadmap/src/roadmap_math.h,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** roadmap_math.h 4 Nov 2008 14:32:02 -0000 1.41 --- roadmap_math.h 4 Nov 2008 14:56:23 -0000 1.42 *************** *** 176,182 **** #define MILLIONTHS 6 - #ifdef IPHONE float roadmap_math_get_angle (RoadMapGuiPoint *point0, RoadMapGuiPoint *point1); ! #endif #endif // INCLUDED__ROADMAP_MATH__H --- 176,181 ---- #define MILLIONTHS 6 float roadmap_math_get_angle (RoadMapGuiPoint *point0, RoadMapGuiPoint *point1); ! #endif // INCLUDED__ROADMAP_MATH__H |