]> Pileus Git - grits/blob - src/gis-viewer.h
Add mouse support
[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 #define GIS_LEVEL_BACKGROUND -100
26 #define GIS_LEVEL_WORLD         0
27 #define GIS_LEVEL_OVERLAY     100
28 #define GIS_LEVEL_HUD         200
29
30 /* Type macros */
31 #define GIS_TYPE_VIEWER            (gis_viewer_get_type())
32 #define GIS_VIEWER(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj),   GIS_TYPE_VIEWER, GisViewer))
33 #define GIS_IS_VIEWER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj),   GIS_TYPE_VIEWER))
34 #define GIS_VIEWER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST   ((klass), GIS_TYPE_VIEWER, GisViewerClass))
35 #define GIS_IS_VIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE   ((klass), GIS_TYPE_VIEWER))
36 #define GIS_VIEWER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),   GIS_TYPE_VIEWER, GisViewerClass))
37
38 typedef struct _GisViewer      GisViewer;
39 typedef struct _GisViewerClass GisViewerClass;
40
41 typedef gdouble (*GisHeightFunc)(gdouble lat, gdouble lon, gpointer user_data);
42
43 #include "gis-plugin.h"
44 #include "gis-prefs.h"
45 #include "objects/gis-object.h"
46 #include "objects/gis-tile.h"
47
48 struct _GisViewer {
49         GtkDrawingArea parent_instance;
50
51         /* instance members */
52         GisPlugins *plugins;
53         GisPrefs   *prefs;
54         gchar      *time;
55         gdouble     location[3];
56         gdouble     rotation[3];
57         gboolean    offline;
58
59         /* For dragging */
60         gint    drag_mode;
61         gdouble drag_x, drag_y;
62 };
63
64 struct _GisViewerClass {
65         GtkDrawingAreaClass parent_class;
66
67         /* class members */
68         void (*center_position)  (GisViewer *viewer,
69                                   gdouble lat, gdouble lon, gdouble elev);
70
71         void (*project)          (GisViewer *viewer,
72                                   gdouble lat, gdouble lon, gdouble elev,
73                                   gdouble *px, gdouble *py, gdouble *pz);
74
75         void (*clear_height_func)(GisViewer *self);
76         void (*set_height_func)  (GisViewer *self, GisTile *tile,
77                                   GisHeightFunc height_func, gpointer user_data,
78                                   gboolean update);
79
80         gpointer (*add)          (GisViewer *viewer, GisObject *object,
81                                   gint level, gboolean sort);
82         GisObject *(*remove)     (GisViewer *viewer, gpointer ref);
83 };
84
85 GType gis_viewer_get_type(void);
86
87 /* Methods */
88 void gis_viewer_setup(GisViewer *viewer, GisPlugins *plugins, GisPrefs *prefs);
89
90 void gis_viewer_set_time(GisViewer *viewer, const gchar *time);
91 gchar *gis_viewer_get_time(GisViewer *viewer);
92
93 void gis_viewer_set_location(GisViewer *viewer, gdouble  lat, gdouble  lon, gdouble  elev);
94 void gis_viewer_get_location(GisViewer *viewer, gdouble *lat, gdouble *lon, gdouble *elev);
95 void gis_viewer_pan         (GisViewer *viewer, gdouble  lat, gdouble  lon, gdouble  elev);
96 void gis_viewer_zoom        (GisViewer *viewer, gdouble  scale);
97
98 void gis_viewer_set_rotation(GisViewer *viewer, gdouble  x, gdouble  y, gdouble  z);
99 void gis_viewer_get_rotation(GisViewer *viewer, gdouble *x, gdouble *y, gdouble *z);
100 void gis_viewer_rotate      (GisViewer *viewer, gdouble  x, gdouble  y, gdouble  z);
101
102 void gis_viewer_refresh(GisViewer *viewer);
103
104 void gis_viewer_set_offline(GisViewer *viewer, gboolean offline);
105 gboolean gis_viewer_get_offline(GisViewer *viewer);
106
107 /* To be implemented by subclasses */
108 void gis_viewer_center_position(GisViewer *viewer,
109                 gdouble lat, gdouble lon, gdouble elev);
110
111 void gis_viewer_project(GisViewer *viewer,
112                 gdouble lat, gdouble lon, gdouble elev,
113                 gdouble *px, gdouble *py, gdouble *pz);
114
115 void gis_viewer_clear_height_func(GisViewer *self);
116 void gis_viewer_set_height_func(GisViewer *self, GisTile *tile,
117                 GisHeightFunc height_func, gpointer user_data,
118                 gboolean update);
119
120 gpointer gis_viewer_add(GisViewer *self, GisObject *object,
121                 gint level, gboolean sort);
122 GisObject *gis_viewer_remove(GisViewer *self, gpointer ref);
123
124 #endif