]> Pileus Git - grits/blob - src/gis-viewer.h
Document GisOpenGL
[grits] / src / gis-viewer.h
1 /*
2  * Copyright (C) 2009-2010 Andy Spencer <andy753421@gmail.com>
3  *
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.
8  *
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.
13  *
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/>.
16  */
17
18 #ifndef __GIS_VIEWER_H__
19 #define __GIS_VIEWER_H__
20
21 #include <gtk/gtk.h>
22 #include <glib-object.h>
23
24 /* Rendering levels */
25 /**
26  * GIS_LEVEL_BACKGROUND: 
27  *
28  * The level used to draw background objects (stars, atmosphere, etc).
29  */
30 #define GIS_LEVEL_BACKGROUND -100
31
32 /**
33  * GIS_LEVEL_WORLD: 
34  *
35  * The level used to draw world objects. This is for both surface data as well
36  * as things in the air or underground. Most objects should use
37  * %GIS_LEVEL_WORLD;
38  */
39 #define GIS_LEVEL_WORLD         0
40
41 /**
42  * GIS_LEVEL_OVERLAY: 
43  *
44  * The level used to draw screen overlays. These will be drawn in front of most
45  * of ther objects. Text and markers should use %GIS_LEVEL_OVERLAY.
46  */
47 #define GIS_LEVEL_OVERLAY     100
48
49 /**
50  * GIS_LEVEL_HUD: 
51  *
52  * The level used to draw the Heads Up Display. This is for things that are not
53  * anchored at all the the world. They should be drawn in front of everything
54  * else.
55  */
56 #define GIS_LEVEL_HUD         200
57
58 /* Type macros */
59 #define GIS_TYPE_VIEWER            (gis_viewer_get_type())
60 #define GIS_VIEWER(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj),   GIS_TYPE_VIEWER, GisViewer))
61 #define GIS_IS_VIEWER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj),   GIS_TYPE_VIEWER))
62 #define GIS_VIEWER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST   ((klass), GIS_TYPE_VIEWER, GisViewerClass))
63 #define GIS_IS_VIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE   ((klass), GIS_TYPE_VIEWER))
64 #define GIS_VIEWER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),   GIS_TYPE_VIEWER, GisViewerClass))
65
66 typedef struct _GisViewer      GisViewer;
67 typedef struct _GisViewerClass GisViewerClass;
68
69 /**
70  * GisHeightFunc:
71  * @lat:       the target latitude
72  * @lon:       the target longitude
73  * @user_data: user data passed to the function
74  *
75  * Determine the surface elevation (ground level) at a given point.
76  *
77  * Returns: the elevation in meters above sea level
78  */
79 typedef gdouble (*GisHeightFunc)(gdouble lat, gdouble lon, gpointer user_data);
80
81 #include "gis-plugin.h"
82 #include "gis-prefs.h"
83 #include "objects/gis-object.h"
84 #include "objects/gis-tile.h"
85
86 struct _GisViewer {
87         GtkDrawingArea parent_instance;
88
89         /* instance members */
90         GisPlugins *plugins;
91         GisPrefs   *prefs;
92         gchar      *time;
93         gdouble     location[3];
94         gdouble     rotation[3];
95         gboolean    offline;
96
97         /* For dragging */
98         gint    drag_mode;
99         gdouble drag_x, drag_y;
100 };
101
102 struct _GisViewerClass {
103         GtkDrawingAreaClass parent_class;
104
105         /* class members */
106         void (*center_position)  (GisViewer *viewer,
107                                   gdouble lat, gdouble lon, gdouble elev);
108
109         void (*project)          (GisViewer *viewer,
110                                   gdouble lat, gdouble lon, gdouble elev,
111                                   gdouble *px, gdouble *py, gdouble *pz);
112
113         void (*clear_height_func)(GisViewer *viewer);
114         void (*set_height_func)  (GisViewer *viewer, GisTile *tile,
115                                   GisHeightFunc height_func, gpointer user_data,
116                                   gboolean update);
117
118         gpointer (*add)          (GisViewer *viewer, GisObject *object,
119                                   gint level, gboolean sort);
120         GisObject *(*remove)     (GisViewer *viewer, gpointer ref);
121 };
122
123 GType gis_viewer_get_type(void);
124
125 /* Methods */
126 void gis_viewer_setup(GisViewer *viewer, GisPlugins *plugins, GisPrefs *prefs);
127
128 void gis_viewer_set_time(GisViewer *viewer, const gchar *time);
129 gchar *gis_viewer_get_time(GisViewer *viewer);
130
131 void gis_viewer_set_location(GisViewer *viewer, gdouble  lat, gdouble  lon, gdouble  elev);
132 void gis_viewer_get_location(GisViewer *viewer, gdouble *lat, gdouble *lon, gdouble *elev);
133 void gis_viewer_pan(GisViewer *viewer, gdouble forward, gdouble right, gdouble up);
134 void gis_viewer_zoom(GisViewer *viewer, gdouble  scale);
135
136 void gis_viewer_set_rotation(GisViewer *viewer, gdouble  x, gdouble  y, gdouble  z);
137 void gis_viewer_get_rotation(GisViewer *viewer, gdouble *x, gdouble *y, gdouble *z);
138 void gis_viewer_rotate      (GisViewer *viewer, gdouble  x, gdouble  y, gdouble  z);
139
140 void gis_viewer_refresh(GisViewer *viewer);
141
142 void gis_viewer_set_offline(GisViewer *viewer, gboolean offline);
143 gboolean gis_viewer_get_offline(GisViewer *viewer);
144
145 /* To be implemented by subclasses */
146 void gis_viewer_center_position(GisViewer *viewer,
147                 gdouble lat, gdouble lon, gdouble elev);
148
149 void gis_viewer_project(GisViewer *viewer,
150                 gdouble lat, gdouble lon, gdouble elev,
151                 gdouble *px, gdouble *py, gdouble *pz);
152
153 void gis_viewer_clear_height_func(GisViewer *viewer);
154 void gis_viewer_set_height_func(GisViewer *viewer, GisTile *tile,
155                 GisHeightFunc height_func, gpointer user_data,
156                 gboolean update);
157
158 gpointer gis_viewer_add(GisViewer *viewer, GisObject *object,
159                 gint level, gboolean sort);
160 GisObject *gis_viewer_remove(GisViewer *viewer, gpointer ref);
161
162 #endif