2 * Copyright (C) 2009-2010 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: gis-opengl.h needs to be included before gis-viewer
20 * - GisViewer depends on GisObject for add/remove functions
21 * - GisObject depends on GisOpenGL for load/unload functions
22 * - GisOpenGL depends on GisViewer for inheritance
24 * The problem here is that GisOpenGL needs the GisViewer definition
25 * but GisViewer only needs the typedefs (through GisObject),
26 * so GisViewer needs to be included after the GisOpenGL typedefs but
27 * before the GisOpenGL definition. This is handled internally by
30 * This should probably be fixed, but making a GisGLObject interface
31 * seems like too much work. Merging GisViewer and GisOpenGL would also work,
32 * but I like the separate that that's provided by having two.
34 #include "gis-opengl.h"
36 #ifndef __GIS_VIEWER_H__
37 #define __GIS_VIEWER_H__
40 #include <glib-object.h>
42 /* Rendering levels */
44 * GIS_LEVEL_BACKGROUND:
46 * The level used to draw background objects (stars, atmosphere, etc).
48 #define GIS_LEVEL_BACKGROUND -100
53 * The level used to draw world objects. This is for both surface data as well
54 * as things in the air or underground. Most objects should use
57 #define GIS_LEVEL_WORLD 0
62 * The level used to draw screen overlays. These will be drawn in front of most
63 * of ther objects. Text and markers should use %GIS_LEVEL_OVERLAY.
65 #define GIS_LEVEL_OVERLAY 100
70 * The level used to draw the Heads Up Display. This is for things that are not
71 * anchored at all the the world. They should be drawn in front of everything
74 #define GIS_LEVEL_HUD 200
77 #define GIS_TYPE_VIEWER (gis_viewer_get_type())
78 #define GIS_VIEWER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GIS_TYPE_VIEWER, GisViewer))
79 #define GIS_IS_VIEWER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GIS_TYPE_VIEWER))
80 #define GIS_VIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIS_TYPE_VIEWER, GisViewerClass))
81 #define GIS_IS_VIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIS_TYPE_VIEWER))
82 #define GIS_VIEWER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIS_TYPE_VIEWER, GisViewerClass))
84 typedef struct _GisViewer GisViewer;
85 typedef struct _GisViewerClass GisViewerClass;
89 * @lat: the target latitude
90 * @lon: the target longitude
91 * @user_data: user data passed to the function
93 * Determine the surface elevation (ground level) at a given point.
95 * Returns: the elevation in meters above sea level
97 typedef gdouble (*GisHeightFunc)(gdouble lat, gdouble lon, gpointer user_data);
99 #include "gis-plugin.h"
100 #include "gis-prefs.h"
101 #include "objects/gis-object.h"
104 GtkDrawingArea parent_instance;
106 /* instance members */
116 gdouble drag_x, drag_y;
119 struct _GisViewerClass {
120 GtkDrawingAreaClass parent_class;
123 void (*center_position) (GisViewer *viewer,
124 gdouble lat, gdouble lon, gdouble elev);
126 void (*project) (GisViewer *viewer,
127 gdouble lat, gdouble lon, gdouble elev,
128 gdouble *px, gdouble *py, gdouble *pz);
130 void (*clear_height_func)(GisViewer *viewer);
131 void (*set_height_func) (GisViewer *viewer, GisBounds *bounds,
132 GisHeightFunc height_func, gpointer user_data,
135 gpointer (*add) (GisViewer *viewer, GisObject *object,
136 gint level, gboolean sort);
137 GisObject *(*remove) (GisViewer *viewer, gpointer ref);
140 GType gis_viewer_get_type(void);
143 void gis_viewer_setup(GisViewer *viewer, GisPlugins *plugins, GisPrefs *prefs);
145 void gis_viewer_set_time(GisViewer *viewer, time_t time);
146 time_t gis_viewer_get_time(GisViewer *viewer);
148 void gis_viewer_set_location(GisViewer *viewer, gdouble lat, gdouble lon, gdouble elev);
149 void gis_viewer_get_location(GisViewer *viewer, gdouble *lat, gdouble *lon, gdouble *elev);
150 void gis_viewer_pan(GisViewer *viewer, gdouble forward, gdouble right, gdouble up);
151 void gis_viewer_zoom(GisViewer *viewer, gdouble scale);
153 void gis_viewer_set_rotation(GisViewer *viewer, gdouble x, gdouble y, gdouble z);
154 void gis_viewer_get_rotation(GisViewer *viewer, gdouble *x, gdouble *y, gdouble *z);
155 void gis_viewer_rotate (GisViewer *viewer, gdouble x, gdouble y, gdouble z);
157 void gis_viewer_refresh(GisViewer *viewer);
159 void gis_viewer_set_offline(GisViewer *viewer, gboolean offline);
160 gboolean gis_viewer_get_offline(GisViewer *viewer);
162 /* To be implemented by subclasses */
163 void gis_viewer_center_position(GisViewer *viewer,
164 gdouble lat, gdouble lon, gdouble elev);
166 void gis_viewer_project(GisViewer *viewer,
167 gdouble lat, gdouble lon, gdouble elev,
168 gdouble *px, gdouble *py, gdouble *pz);
170 void gis_viewer_clear_height_func(GisViewer *viewer);
171 void gis_viewer_set_height_func(GisViewer *viewer, GisBounds *bounds,
172 GisHeightFunc height_func, gpointer user_data,
175 gpointer gis_viewer_add(GisViewer *viewer, GisObject *object,
176 gint level, gboolean sort);
177 GisObject *gis_viewer_remove(GisViewer *viewer, gpointer ref);