/*
- * Copyright (C) 2009 Andy Spencer <spenceal@rose-hulman.edu>
+ * Copyright (C) 2009-2010 Andy Spencer <andy753421@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef __GIS_VIEW_H__
-#define __GIS_VIEW_H__
+#ifndef __GIS_VIEWER_H__
+#define __GIS_VIEWER_H__
+#include <gtk/gtk.h>
#include <glib-object.h>
+/* Rendering levels */
+/**
+ * GIS_LEVEL_BACKGROUND:
+ *
+ * The level used to draw background objects (stars, atmosphere, etc).
+ */
+#define GIS_LEVEL_BACKGROUND -100
+
+/**
+ * GIS_LEVEL_WORLD:
+ *
+ * The level used to draw world objects. This is for both surface data as well
+ * as things in the air or underground. Most objects should use
+ * %GIS_LEVEL_WORLD;
+ */
+#define GIS_LEVEL_WORLD 0
+
+/**
+ * GIS_LEVEL_OVERLAY:
+ *
+ * The level used to draw screen overlays. These will be drawn in front of most
+ * of ther objects. Text and markers should use %GIS_LEVEL_OVERLAY.
+ */
+#define GIS_LEVEL_OVERLAY 100
+
+/**
+ * GIS_LEVEL_HUD:
+ *
+ * The level used to draw the Heads Up Display. This is for things that are not
+ * anchored at all the the world. They should be drawn in front of everything
+ * else.
+ */
+#define GIS_LEVEL_HUD 200
+
/* Type macros */
-#define GIS_TYPE_VIEW (gis_view_get_type())
-#define GIS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GIS_TYPE_VIEW, GisView))
-#define GIS_IS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GIS_TYPE_VIEW))
-#define GIS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIS_TYPE_VIEW, GisViewClass))
-#define GIS_IS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIS_TYPE_VIEW))
-#define GIS_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIS_TYPE_VIEW, GisViewClass))
+#define GIS_TYPE_VIEWER (gis_viewer_get_type())
+#define GIS_VIEWER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GIS_TYPE_VIEWER, GisViewer))
+#define GIS_IS_VIEWER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GIS_TYPE_VIEWER))
+#define GIS_VIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIS_TYPE_VIEWER, GisViewerClass))
+#define GIS_IS_VIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIS_TYPE_VIEWER))
+#define GIS_VIEWER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIS_TYPE_VIEWER, GisViewerClass))
+
+typedef struct _GisViewer GisViewer;
+typedef struct _GisViewerClass GisViewerClass;
+
+/**
+ * GisHeightFunc:
+ * @lat: the target latitude
+ * @lon: the target longitude
+ * @user_data: user data passed to the function
+ *
+ * Determine the surface elevation (ground level) at a given point.
+ *
+ * Returns: the elevation in meters above sea level
+ */
+typedef gdouble (*GisHeightFunc)(gdouble lat, gdouble lon, gpointer user_data);
-typedef struct _GisView GisView;
-typedef struct _GisViewClass GisViewClass;
+#include "gis-plugin.h"
+#include "gis-prefs.h"
+#include "objects/gis-object.h"
+#include "objects/gis-tile.h"
-struct _GisView {
- GObject parent_instance;
+struct _GisViewer {
+ GtkDrawingArea parent_instance;
/* instance members */
- gchar *time;
- gchar *site;
- gdouble location[3];
- gdouble rotation[3];
- gboolean offline;
+ GisPlugins *plugins;
+ GisPrefs *prefs;
+ gchar *time;
+ gdouble location[3];
+ gdouble rotation[3];
+ gboolean offline;
+
+ /* For dragging */
+ gint drag_mode;
+ gdouble drag_x, drag_y;
};
-struct _GisViewClass {
- GObjectClass parent_class;
+struct _GisViewerClass {
+ GtkDrawingAreaClass parent_class;
/* class members */
+ void (*center_position) (GisViewer *viewer,
+ gdouble lat, gdouble lon, gdouble elev);
+
+ void (*project) (GisViewer *viewer,
+ gdouble lat, gdouble lon, gdouble elev,
+ gdouble *px, gdouble *py, gdouble *pz);
+
+ void (*clear_height_func)(GisViewer *viewer);
+ void (*set_height_func) (GisViewer *viewer, GisTile *tile,
+ GisHeightFunc height_func, gpointer user_data,
+ gboolean update);
+
+ gpointer (*add) (GisViewer *viewer, GisObject *object,
+ gint level, gboolean sort);
+ GisObject *(*remove) (GisViewer *viewer, gpointer ref);
};
-GType gis_view_get_type(void);
+GType gis_viewer_get_type(void);
/* Methods */
-GisView *gis_view_new();
+void gis_viewer_setup(GisViewer *viewer, GisPlugins *plugins, GisPrefs *prefs);
+
+void gis_viewer_set_time(GisViewer *viewer, const gchar *time);
+gchar *gis_viewer_get_time(GisViewer *viewer);
+
+void gis_viewer_set_location(GisViewer *viewer, gdouble lat, gdouble lon, gdouble elev);
+void gis_viewer_get_location(GisViewer *viewer, gdouble *lat, gdouble *lon, gdouble *elev);
+void gis_viewer_pan(GisViewer *viewer, gdouble forward, gdouble right, gdouble up);
+void gis_viewer_zoom(GisViewer *viewer, gdouble scale);
+
+void gis_viewer_set_rotation(GisViewer *viewer, gdouble x, gdouble y, gdouble z);
+void gis_viewer_get_rotation(GisViewer *viewer, gdouble *x, gdouble *y, gdouble *z);
+void gis_viewer_rotate (GisViewer *viewer, gdouble x, gdouble y, gdouble z);
-void gis_view_set_time(GisView *view, const gchar *time);
-gchar *gis_view_get_time(GisView *view);
+void gis_viewer_refresh(GisViewer *viewer);
-void gis_view_set_location(GisView *view, gdouble lat, gdouble lon, gdouble elev);
-void gis_view_get_location(GisView *view, gdouble *lat, gdouble *lon, gdouble *elev);
-void gis_view_pan (GisView *view, gdouble lat, gdouble lon, gdouble elev);
-void gis_view_zoom (GisView *view, gdouble scale);
+void gis_viewer_set_offline(GisViewer *viewer, gboolean offline);
+gboolean gis_viewer_get_offline(GisViewer *viewer);
-void gis_view_set_rotation(GisView *view, gdouble x, gdouble y, gdouble z);
-void gis_view_get_rotation(GisView *view, gdouble *x, gdouble *y, gdouble *z);
-void gis_view_rotate (GisView *view, gdouble x, gdouble y, gdouble z);
+/* To be implemented by subclasses */
+void gis_viewer_center_position(GisViewer *viewer,
+ gdouble lat, gdouble lon, gdouble elev);
-/* To be deprecated, use {get,set}_location */
-void gis_view_set_site(GisView *view, const gchar *site);
-gchar *gis_view_get_site(GisView *view);
+void gis_viewer_project(GisViewer *viewer,
+ gdouble lat, gdouble lon, gdouble elev,
+ gdouble *px, gdouble *py, gdouble *pz);
-void gis_world_refresh(GisWorld *world);
+void gis_viewer_clear_height_func(GisViewer *viewer);
+void gis_viewer_set_height_func(GisViewer *viewer, GisTile *tile,
+ GisHeightFunc height_func, gpointer user_data,
+ gboolean update);
-void gis_world_set_offline(GisWorld *world, gboolean offline);
-gboolean gis_world_get_offline(GisWorld *world);
+gpointer gis_viewer_add(GisViewer *viewer, GisObject *object,
+ gint level, gboolean sort);
+GisObject *gis_viewer_remove(GisViewer *viewer, gpointer ref);
#endif