2 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
4 * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #ifndef _VIKING_VIEWPORT_H
23 #define _VIKING_VIEWPORT_H
26 #include <glib-object.h>
35 #define VIK_VIEWPORT_TYPE (vik_viewport_get_type ())
36 #define VIK_VIEWPORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VIK_VIEWPORT_TYPE, VikViewport))
37 #define VIK_VIEWPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VIK_VIEWPORT_TYPE, VikViewportClass))
38 #define VIK_IS_VIEWPORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIK_VIEWPORT_TYPE))
39 #define VIK_IS_VIEWPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VIK_VIEWPORT_TYPE))
41 #define VIK_VIEWPORT_MAX_ZOOM 32768.0
42 #define VIK_VIEWPORT_MIN_ZOOM (1 / 32.0)
44 /* used for coord to screen etc, screen to coord */
45 #define VIK_VIEWPORT_UTM_WRONG_ZONE -9999999
46 #define VIK_VIEWPORT_OFF_SCREEN_DOUBLE -9999999.9
49 /* Glib type inheritance and initialization */
50 typedef struct _VikViewport VikViewport
;
51 typedef struct _VikViewportClass VikViewportClass
;
53 struct _VikViewportClass
55 GtkDrawingAreaClass drawing_area_class
;
56 void (*updated_center
) (VikViewport
*vw
);
58 GType
vik_viewport_get_type ();
61 /* Viking initialization */
62 VikViewport
*vik_viewport_new ();
63 void vik_viewport_configure_manually ( VikViewport
*vvp
, gint width
, guint height
); /* for off-screen viewports */
64 gboolean
vik_viewport_configure ( VikViewport
*vp
);
67 /* coordinate transformations */
68 void vik_viewport_screen_to_coord ( VikViewport
*vvp
, int x
, int y
, VikCoord
*coord
);
69 void vik_viewport_coord_to_screen ( VikViewport
*vvp
, const VikCoord
*coord
, int *x
, int *y
);
73 void vik_viewport_set_ympp ( VikViewport
*vvp
, gdouble ympp
);
74 void vik_viewport_set_xmpp ( VikViewport
*vvp
, gdouble xmpp
);
75 gdouble
vik_viewport_get_ympp ( VikViewport
*vvp
);
76 gdouble
vik_viewport_get_xmpp ( VikViewport
*vvp
);
77 void vik_viewport_set_zoom ( VikViewport
*vvp
, gdouble mpp
);
78 gdouble
vik_viewport_get_zoom ( VikViewport
*vvp
);
79 void vik_viewport_zoom_in ( VikViewport
*vvp
);
80 void vik_viewport_zoom_out ( VikViewport
*vvp
);
83 /* viewport position */
84 const VikCoord
*vik_viewport_get_center ( VikViewport
*vvp
);
85 void vik_viewport_set_center_coord ( VikViewport
*vvp
, const VikCoord
*coord
, gboolean save_position
);
86 void vik_viewport_set_center_screen ( VikViewport
*vvp
, int x
, int y
);
87 void vik_viewport_center_for_zonen ( VikViewport
*vvp
, struct UTM
*center
, int zone
);
88 gchar
vik_viewport_leftmost_zone ( VikViewport
*vvp
);
89 gchar
vik_viewport_rightmost_zone ( VikViewport
*vvp
);
90 void vik_viewport_set_center_utm ( VikViewport
*vvp
, const struct UTM
*utm
, gboolean save_position
);
91 void vik_viewport_set_center_latlon ( VikViewport
*vvp
, const struct LatLon
*ll
, gboolean save_position
);
92 void vik_viewport_corners_for_zonen ( VikViewport
*vvp
, int zone
, VikCoord
*ul
, VikCoord
*br
);
93 void vik_viewport_get_min_max_lat_lon ( VikViewport
*vp
, gdouble
*min_lat
, gdouble
*max_lat
, gdouble
*min_lon
, gdouble
*max_lon
);
94 LatLonBBox
vik_viewport_get_bbox ( VikViewport
*vp
);
96 gboolean
vik_viewport_go_back ( VikViewport
*vvp
);
97 gboolean
vik_viewport_go_forward ( VikViewport
*vvp
);
98 gboolean
vik_viewport_back_available ( const VikViewport
*vvp
);
99 gboolean
vik_viewport_forward_available ( const VikViewport
*vvp
);
100 void vik_viewport_show_centers ( VikViewport
*vvp
, GtkWindow
*parent
);
102 /* drawmode management */
104 VIK_VIEWPORT_DRAWMODE_UTM
=0,
105 VIK_VIEWPORT_DRAWMODE_EXPEDIA
,
106 VIK_VIEWPORT_DRAWMODE_MERCATOR
,
107 VIK_VIEWPORT_DRAWMODE_LATLON
,
108 VIK_VIEWPORT_NUM_DRAWMODES
/*< skip >*/
109 } VikViewportDrawMode
;
111 VikCoordMode
vik_viewport_get_coord_mode ( const VikViewport
*vvp
);
112 gboolean
vik_viewport_is_one_zone ( VikViewport
*vvp
);
113 const gchar
*vik_viewport_get_drawmode_name(VikViewport
*vv
, VikViewportDrawMode mode
);
114 void vik_viewport_set_drawmode ( VikViewport
*vvp
, VikViewportDrawMode drawmode
);
115 VikViewportDrawMode
vik_viewport_get_drawmode ( VikViewport
*vvp
);
116 /* Do not forget to update vik_viewport_get_drawmode_name() if you modify VikViewportDrawMode */
120 void vik_viewport_set_trigger ( VikViewport
*vp
, gpointer trigger
);
121 gpointer
vik_viewport_get_trigger ( VikViewport
*vp
);
122 void vik_viewport_snapshot_save ( VikViewport
*vp
);
123 void vik_viewport_snapshot_load ( VikViewport
*vp
);
124 void vik_viewport_set_half_drawn(VikViewport
*vp
, gboolean half_drawn
);
125 gboolean
vik_viewport_get_half_drawn( VikViewport
*vp
);
128 /***************************************************************************************************
129 * Drawing-related operations
130 ***************************************************************************************************/
132 /* Viewport buffer management/drawing to screen */
133 GdkPixmap
*vik_viewport_get_pixmap ( VikViewport
*vvp
); /* get pointer to drawing buffer */
134 void vik_viewport_sync ( VikViewport
*vvp
); /* draw buffer to window */
135 void vik_viewport_pan_sync ( VikViewport
*vvp
, gint x_off
, gint y_off
);
136 void vik_viewport_clear ( VikViewport
*vvp
);
137 void vik_viewport_draw_pixbuf ( VikViewport
*vvp
, GdkPixbuf
*pixbuf
, gint src_x
, gint src_y
,
138 gint dest_x
, gint dest_y
, gint w
, gint h
);
139 gint
vik_viewport_get_width ( VikViewport
*vvp
);
140 gint
vik_viewport_get_height ( VikViewport
*vvp
);
142 void vik_viewport_reset_copyrights ( VikViewport
*vp
);
143 void vik_viewport_add_copyright ( VikViewport
*vp
, const gchar
*copyright
);
145 void vik_viewport_reset_logos ( VikViewport
*vp
);
146 void vik_viewport_add_logo ( VikViewport
*vp
, const GdkPixbuf
*logo
);
148 /* Viewport features */
149 void vik_viewport_draw_scale ( VikViewport
*vvp
);
150 void vik_viewport_set_draw_scale ( VikViewport
*vvp
, gboolean draw_scale
);
151 gboolean
vik_viewport_get_draw_scale ( VikViewport
*vvp
);
152 void vik_viewport_draw_copyright ( VikViewport
*vvp
);
153 void vik_viewport_draw_centermark ( VikViewport
*vvp
);
154 void vik_viewport_set_draw_centermark ( VikViewport
*vvp
, gboolean draw_centermark
);
155 gboolean
vik_viewport_get_draw_centermark ( VikViewport
*vvp
);
156 void vik_viewport_draw_logo ( VikViewport
*vvp
);
157 void vik_viewport_set_draw_highlight ( VikViewport
*vvp
, gboolean draw_highlight
);
158 gboolean
vik_viewport_get_draw_highlight ( VikViewport
*vvp
);
160 /* Color/graphics context management */
161 void vik_viewport_set_background_color ( VikViewport
*vvp
, const gchar
*color
);
162 const gchar
*vik_viewport_get_background_color ( VikViewport
*vvp
);
163 GdkColor
*vik_viewport_get_background_gdkcolor ( VikViewport
*vvp
);
164 void vik_viewport_set_background_gdkcolor ( VikViewport
*vvp
, GdkColor
* );
165 void vik_gc_get_fg_color ( GdkGC
*gc
, GdkColor
*dest
); /* warning: could be slow, don't use obsessively */
166 GdkGC
*vik_viewport_new_gc ( VikViewport
*vvp
, const gchar
*colorname
, gint thickness
);
167 GdkGC
*vik_viewport_new_gc_from_color ( VikViewport
*vvp
, GdkColor
*color
, gint thickness
);
169 void vik_viewport_set_highlight_color ( VikViewport
*vvp
, const gchar
*color
);
170 const gchar
*vik_viewport_get_highlight_color ( VikViewport
*vvp
);
171 GdkColor
*vik_viewport_get_highlight_gdkcolor ( VikViewport
*vvp
);
172 void vik_viewport_set_highlight_gdkcolor ( VikViewport
*vvp
, GdkColor
* );
173 GdkGC
* vik_viewport_get_gc_highlight ( VikViewport
*vvp
);
174 void vik_viewport_set_highlight_thickness ( VikViewport
*vvp
, gint thickness
);
176 /* Drawing primitives */
177 void a_viewport_clip_line ( gint
*x1
, gint
*y1
, gint
*x2
, gint
*y2
); /* run this before drawing a line. vik_viewport_draw_line runs it for you */
178 void vik_viewport_draw_line ( VikViewport
*vvp
, GdkGC
*gc
, gint x1
, gint y1
, gint x2
, gint y2
);
179 void vik_viewport_draw_rectangle ( VikViewport
*vvp
, GdkGC
*gc
, gboolean filled
, gint x1
, gint y1
, gint x2
, gint y2
);
180 void vik_viewport_draw_string ( VikViewport
*vvp
, GdkFont
*font
, GdkGC
*gc
, gint x1
, gint y1
, const gchar
*string
);
181 void vik_viewport_draw_arc ( VikViewport
*vvp
, GdkGC
*gc
, gboolean filled
, gint x
, gint y
, gint width
, gint height
, gint angle1
, gint angle2
);
182 void vik_viewport_draw_polygon ( VikViewport
*vvp
, GdkGC
*gc
, gboolean filled
, GdkPoint
*points
, gint npoints
);
183 void vik_viewport_draw_layout ( VikViewport
*vvp
, GdkGC
*gc
, gint x
, gint y
, PangoLayout
*layout
);
186 void vik_viewport_compute_bearing ( VikViewport
*vp
, gint x1
, gint y1
, gint x2
, gint y2
, gdouble
*angle
, gdouble
*baseangle
);