arrows to show track direction
EASY FIXES:
+ "Interesting" stuff happens when we swich modes while using the ruler.
"click to go there" elevation map: average out, not nearest trackpoint.
Ruler: calculate degrees by spherical geometry formula ('zoom in too much' bug -- coord_to_screen out of range of double)
for UTM: rotate compass for declination.
iter = iter->next;
}
if (items)
- g_list_free(items);
+ g_slist_free(items);
} else {
gchar *name = vik_treeview_item_get_pointer(vt, src_item_iter);
trw_layer_move_item(vtl_src, vtl_dest, name, type);
}
}
+void a_viewport_clip_line ( gint *x1, gint *y1, gint *x2, gint *y2 )
+{
+ if ( *x1 > 20000 || *x1 < -20000 ) {
+ gdouble shrinkfactor = ABS(20000.0 / *x1);
+ *x1 = *x2 + (shrinkfactor * (*x1-*x2));
+ *y1 = *y2 + (shrinkfactor * (*y1-*y2));
+ } else if ( *y1 > 20000 || *y1 < -20000 ) {
+ gdouble shrinkfactor = ABS(20000.0 / *x1);
+ *x1 = *x2 + (shrinkfactor * (*x1-*x2));
+ *y1 = *y2 + (shrinkfactor * (*y1-*y2));
+ } else if ( *x2 > 20000 || *x2 < -20000 ) {
+ gdouble shrinkfactor = ABS(20000.0 / (gdouble)*x2);
+ *x2 = *x1 + (shrinkfactor * (*x2-*x1));
+ *y2 = *y1 + (shrinkfactor * (*y2-*y1));
+ printf("%f, %d, %d\n", shrinkfactor, *x2, *y2);
+ } else if ( *y2 > 20000 || *y2 < -20000 ) {
+ gdouble shrinkfactor = ABS(20000.0 / (gdouble)*x2);
+ *x2 = *x1 + (shrinkfactor * (*x2-*x1));
+ *y2 = *y1 + (shrinkfactor * (*y2-*y1));
+ }
+}
+
void vik_viewport_draw_line ( VikViewport *vvp, GdkGC *gc, gint x1, gint y1, gint x2, gint y2 )
{
if ( ! ( ( x1 < 0 && x2 < 0 ) || ( y1 < 0 && y2 < 0 ) ||
- ( x1 > vvp->width && x2 > vvp->width ) || ( y1 > vvp->height && y2 > vvp->height ) ) )
- gdk_draw_line ( vvp->scr_buffer, gc, x1, y1, x2, y2);
+ ( x1 > vvp->width && x2 > vvp->width ) || ( y1 > vvp->height && y2 > vvp->height ) ) ) {
+ /*** clipping, yeah! ***/
+ a_viewport_clip_line ( &x1, &y1, &x2, &y2 );
+ gdk_draw_line ( vvp->scr_buffer, gc, x1, y1, x2, y2);
+ }
}
void vik_viewport_draw_rectangle ( VikViewport *vvp, GdkGC *gc, gboolean filled, gint x1, gint y1, gint x2, gint y2 )
GdkGC *vik_viewport_new_gc ( VikViewport *vvp, const gchar *colorname, gint thickness );
+/* run this before drawing a line. vik_viewport_draw_line runs it for you */
+void a_viewport_clip_line ( gint *x1, gint *y1, gint *x2, gint *y2 );
+
void vik_viewport_draw_line ( VikViewport *vvp, GdkGC *gc, gint x1, gint y1, gint x2, gint y2 );
void vik_viewport_draw_rectangle ( VikViewport *vvp, GdkGC *gc, gboolean filled, gint x1, gint y1, gint x2, gint y2 );
void vik_viewport_draw_string ( VikViewport *vvp, GdkFont *font, GdkGC *gc, gint x1, gint y1, const gchar *string );
gint i;
/* draw line with arrow ends */
- gdk_draw_line(d, gc, x1, y1, x2, y2);
+ {
+ gint tmp_x1=x1, tmp_y1=y1, tmp_x2=x2, tmp_y2=y2;
+ a_viewport_clip_line(&tmp_x1, &tmp_y1, &tmp_x2, &tmp_y2);
+ gdk_draw_line(d, gc, tmp_x1, tmp_y1, tmp_x2, tmp_y2);
+ }
+
+ a_viewport_clip_line(&x1, &y1, &x2, &y2);
+ gdk_draw_line(d, gc, x1, y1, x2, y2);
+
gdk_draw_line(d, gc, x1 - dy, y1 + dx, x1 + dy, y1 - dx);
gdk_draw_line(d, gc, x2 - dy, y2 + dx, x2 + dy, y2 - dx);
gdk_draw_line(d, gc, x2, y2, x2 - (dx * c + dy * s), y2 - (dy * c - dx * s));