2 * Copyright (C) 2009-2011 Andy Spencer <andy753421@gmail.com>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * Hack alert: grits-opengl.h needs to be included before grits-viewer
20 * - GritsViewer depends on GritsObject for add/remove functions
21 * - GritsObject depends on GritsOpenGL for load/unload functions
22 * - GritsOpenGL depends on GritsViewer for inheritance
24 * The problem here is that GritsOpenGL needs the GritsViewer definition but
25 * GritsViewer only needs the typedefs (through GritsObject), so GritsViewer
26 * needs to be included after the GritsOpenGL typedefs but before the
27 * GritsOpenGL definition. This is handled internally by grits-opengl.h
29 * This should probably be fixed, but making a GritsGLObject interface seems
30 * like too much work. Merging GritsViewer and GritsOpenGL would also work, but
31 * I like the separate that that's provided by having two.
33 #include "grits-opengl.h"
35 #ifndef __GRITS_VIEWER_H__
36 #define __GRITS_VIEWER_H__
39 #include <glib-object.h>
47 /* Rendering levels */
49 * GRITS_LEVEL_BACKGROUND:
51 * The level used to draw background objects (stars, atmosphere, etc).
53 #define GRITS_LEVEL_BACKGROUND -100
58 * The level used to draw world objects. This is for both surface data as well
59 * as things in the air or underground. Most objects should use
62 #define GRITS_LEVEL_WORLD 0
65 * GRITS_LEVEL_OVERLAY:
67 * The level used to draw screen overlays. These will be drawn in front of most
68 * of ther objects. Text and markers should use %GRITS_LEVEL_OVERLAY.
70 #define GRITS_LEVEL_OVERLAY 100
75 * The level used to draw the Heads Up Display. This is for things that are not
76 * anchored at all the the world. They should be drawn in front of everything
79 #define GRITS_LEVEL_HUD 200
82 #define GRITS_TYPE_VIEWER (grits_viewer_get_type())
83 #define GRITS_VIEWER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GRITS_TYPE_VIEWER, GritsViewer))
84 #define GRITS_IS_VIEWER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GRITS_TYPE_VIEWER))
85 #define GRITS_VIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRITS_TYPE_VIEWER, GritsViewerClass))
86 #define GRITS_IS_VIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRITS_TYPE_VIEWER))
87 #define GRITS_VIEWER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GRITS_TYPE_VIEWER, GritsViewerClass))
89 typedef struct _GritsViewer GritsViewer;
90 typedef struct _GritsViewerClass GritsViewerClass;
94 * @lat: the target latitude
95 * @lon: the target longitude
96 * @user_data: user data passed to the function
98 * Determine the surface elevation (ground level) at a given point.
100 * Returns: the elevation in meters above sea level
102 typedef gdouble (*GritsHeightFunc)(gdouble lat, gdouble lon, gpointer user_data);
104 #include "grits-plugin.h"
105 #include "grits-prefs.h"
106 #include "objects/grits-object.h"
108 struct _GritsViewer {
109 GtkDrawingArea parent_instance;
111 /* instance members */
112 GritsPlugins *plugins;
121 gdouble drag_x, drag_y;
127 struct _GritsViewerClass {
128 GtkDrawingAreaClass parent_class;
131 void (*center_position) (GritsViewer *viewer,
132 gdouble lat, gdouble lon, gdouble elev);
134 void (*project) (GritsViewer *viewer,
135 gdouble lat, gdouble lon, gdouble elev,
136 gdouble *px, gdouble *py, gdouble *pz);
137 void (*unproject) (GritsViewer *viewer,
138 gdouble px, gdouble py,gdouble pz,
139 gdouble *lat, gdouble *lon, gdouble *elev);
141 void (*clear_height_func)(GritsViewer *viewer);
142 void (*set_height_func) (GritsViewer *viewer, GritsBounds *bounds,
143 GritsHeightFunc height_func, gpointer user_data,
146 void (*add) (GritsViewer *viewer, GritsObject *object,
147 gint level, gboolean sort);
148 void (*remove) (GritsViewer *viewer, GritsObject *object);
151 GType grits_viewer_get_type(void);
154 void grits_viewer_setup(GritsViewer *viewer, GritsPlugins *plugins, GritsPrefs *prefs);
156 void grits_viewer_set_time(GritsViewer *viewer, time_t time);
157 time_t grits_viewer_get_time(GritsViewer *viewer);
159 void grits_viewer_set_location(GritsViewer *viewer, gdouble lat, gdouble lon, gdouble elev);
160 void grits_viewer_get_location(GritsViewer *viewer, gdouble *lat, gdouble *lon, gdouble *elev);
161 void grits_viewer_pan(GritsViewer *viewer, gdouble forward, gdouble right, gdouble up);
162 void grits_viewer_zoom(GritsViewer *viewer, gdouble scale);
164 void grits_viewer_set_rotation(GritsViewer *viewer, gdouble x, gdouble y, gdouble z);
165 void grits_viewer_get_rotation(GritsViewer *viewer, gdouble *x, gdouble *y, gdouble *z);
166 void grits_viewer_rotate (GritsViewer *viewer, gdouble x, gdouble y, gdouble z);
168 void grits_viewer_refresh(GritsViewer *viewer);
170 void grits_viewer_set_offline(GritsViewer *viewer, gboolean offline);
171 gboolean grits_viewer_get_offline(GritsViewer *viewer);
173 /* To be implemented by subclasses */
174 void grits_viewer_center_position(GritsViewer *viewer,
175 gdouble lat, gdouble lon, gdouble elev);
177 void grits_viewer_project(GritsViewer *viewer,
178 gdouble lat, gdouble lon, gdouble elev,
179 gdouble *px, gdouble *py, gdouble *pz);
180 void grits_viewer_unproject(GritsViewer *viewer,
181 gdouble px, gdouble py, gdouble pz,
182 gdouble *lat, gdouble *lon, gdouble *elev);
184 void grits_viewer_clear_height_func(GritsViewer *viewer);
185 void grits_viewer_set_height_func(GritsViewer *viewer, GritsBounds *bounds,
186 GritsHeightFunc height_func, gpointer user_data,
189 void grits_viewer_add(GritsViewer *viewer, GritsObject *object,
190 gint level, gboolean sort);
191 void grits_viewer_remove(GritsViewer *viewer, GritsObject *object);
193 void grits_viewer_queue_draw(GritsViewer *viewer);