From f383c18c9f85a1b439c6bfb2a27d652278ed019a Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Sat, 20 Nov 2010 07:45:58 +0000 Subject: [PATCH] libgis -> grits: Update functions/types/etc --- TODO | 12 +- docs/api/Makefile.am | 2 +- docs/api/grits-demo.xml | 12 +- docs/api/grits-docs.sgml | 26 +-- examples/plugin/teapot.c | 54 +++---- examples/plugin/teapot.h | 26 +-- src/.vimrc | 2 +- src/data/grits-data.c | 2 +- src/data/grits-data.h | 28 ++-- src/data/grits-http.c | 74 ++++----- src/data/grits-http.h | 20 +-- src/data/grits-wms.c | 58 +++---- src/data/grits-wms.h | 18 +-- src/grits-demo.c | 32 ++-- src/grits-opengl.c | 152 +++++++++--------- src/grits-opengl.h | 32 ++-- src/grits-plugin.c | 172 ++++++++++---------- src/grits-plugin.h | 68 ++++---- src/grits-prefs.c | 60 +++---- src/grits-prefs.h | 60 +++---- src/grits-test.c | 30 ++-- src/grits-util.c | 18 +-- src/grits-util.h | 22 +-- src/grits-viewer.c | 298 +++++++++++++++++------------------ src/grits-viewer.h | 131 ++++++++------- src/grits.h | 4 +- src/objects/grits-callback.c | 30 ++-- src/objects/grits-callback.h | 42 ++--- src/objects/grits-marker.c | 50 +++--- src/objects/grits-marker.h | 34 ++-- src/objects/grits-object.c | 25 ++- src/objects/grits-object.h | 50 +++--- src/objects/grits-tile.c | 128 +++++++-------- src/objects/grits-tile.h | 82 +++++----- src/plugins/elev.c | 121 +++++++------- src/plugins/elev.h | 34 ++-- src/plugins/env.c | 66 ++++---- src/plugins/env.h | 32 ++-- src/plugins/map.c | 114 +++++++------- src/plugins/map.h | 34 ++-- src/plugins/sat.c | 112 ++++++------- src/plugins/sat.h | 34 ++-- src/plugins/test.c | 56 +++---- src/plugins/test.h | 28 ++-- src/roam.c | 4 +- src/roam.h | 2 +- src/tile-test.c | 24 +-- 47 files changed, 1256 insertions(+), 1259 deletions(-) diff --git a/TODO b/TODO index 8bc73a1..a634b2f 100644 --- a/TODO +++ b/TODO @@ -5,19 +5,19 @@ Miscellaneous - Organize examples and demo programs - Add real examples do dist -GisObject: - - Improve GisMarker +GritsObject: + - Improve GritsMarker - Add min/max LOD mabye: ? - - Add linked list node to GisObject for add/remove - - Move rendering code to objects intead of GisOpenGL + - Add linked list node to GritsObject for add/remove + - Move rendering code to objects intead of GritsOpenGL - How to work with non-opengl renders, do we care? -GisTile: +GritsTile: - Prioritize tile updates - Only updates visible tiles - Render correct tile resolution when zooming out - - Integrate with GisTile? + - Integrate with GritsTile? how: - Update tiles after each render - Use backfaces to only fetch rendered triangles for each tile diff --git a/docs/api/Makefile.am b/docs/api/Makefile.am index 79cf675..b19ba0b 100644 --- a/docs/api/Makefile.am +++ b/docs/api/Makefile.am @@ -2,7 +2,7 @@ AM_CPPFLAGS = $(SOUP_CFLAGS) $(GLIB_CFLAGS) $(GTK_CFLAGS) # Gtk docs GTKDOC_LIBS = $(SOUP_LIBS) $(GLIB_LIBS) $(GTK_LIBS) \ - $(top_srcdir)/src/grits.la \ + $(top_srcdir)/src/libgrits.la \ $(top_srcdir)/src/plugins/*.la DOC_MODULE = grits DOC_SOURCE_DIR = $(top_srcdir)/src/ diff --git a/docs/api/grits-demo.xml b/docs/api/grits-demo.xml index 1f6cdce..9cc9a1e 100644 --- a/docs/api/grits-demo.xml +++ b/docs/api/grits-demo.xml @@ -1,22 +1,22 @@ - + - gis-demo + grits-demo 1 - gis-demo + grits-demo Grits demonstration program - gis-demo [GTK_OPTIONS] + grits-demo [GTK_OPTIONS] Description - gis-demo TODO (short description) + grits-demo TODO (short description) TODO (long description) @@ -25,7 +25,7 @@ Environment - GIS_PLUGIN_PATH + GRITS_PLUGIN_PATH Secondary path to use when searching for plugins. diff --git a/docs/api/grits-docs.sgml b/docs/api/grits-docs.sgml index 4afe49f..805a787 100644 --- a/docs/api/grits-docs.sgml +++ b/docs/api/grits-docs.sgml @@ -8,30 +8,30 @@ Core API - - - - + + + + Data Access - - - + + + Drawing Objects - - - - + + + + Plugins - + @@ -47,7 +47,7 @@ Miscellaneous - + diff --git a/examples/plugin/teapot.c b/examples/plugin/teapot.c index d2a51fe..60c52f4 100644 --- a/examples/plugin/teapot.c +++ b/examples/plugin/teapot.c @@ -27,7 +27,7 @@ ***********/ static gboolean rotate(gpointer _teapot) { - GisPluginTeapot *teapot = _teapot; + GritsPluginTeapot *teapot = _teapot; if (gtk_toggle_button_get_active(teapot->button)) { teapot->rotation += 1.0; gtk_widget_queue_draw(GTK_WIDGET(teapot->viewer)); @@ -35,10 +35,10 @@ static gboolean rotate(gpointer _teapot) return TRUE; } -static void expose(GisCallback *callback, GisOpenGL *opengl, gpointer _teapot) +static void expose(GritsCallback *callback, GritsOpenGL *opengl, gpointer _teapot) { - GisPluginTeapot *teapot = GIS_PLUGIN_TEAPOT(_teapot); - g_debug("GisPluginTeapot: expose"); + GritsPluginTeapot *teapot = GRITS_PLUGIN_TEAPOT(_teapot); + g_debug("GritsPluginTeapot: expose"); glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -66,22 +66,22 @@ static void expose(GisCallback *callback, GisOpenGL *opengl, gpointer _teapot) /*********** * Methods * ***********/ -GisPluginTeapot *gis_plugin_teapot_new(GisViewer *viewer, GisPrefs *prefs) +GritsPluginTeapot *grits_plugin_teapot_new(GritsViewer *viewer, GritsPrefs *prefs) { - g_debug("GisPluginTeapot: new"); - GisPluginTeapot *teapot = g_object_new(GIS_TYPE_PLUGIN_TEAPOT, NULL); + g_debug("GritsPluginTeapot: new"); + GritsPluginTeapot *teapot = g_object_new(GRITS_TYPE_PLUGIN_TEAPOT, NULL); teapot->viewer = viewer; /* Add renderers */ - GisCallback *callback = gis_callback_new(expose, teapot); - gis_viewer_add(viewer, GIS_OBJECT(callback), GIS_LEVEL_OVERLAY+1, 0); + GritsCallback *callback = grits_callback_new(expose, teapot); + grits_viewer_add(viewer, GRITS_OBJECT(callback), GRITS_LEVEL_OVERLAY+1, 0); return teapot; } -static GtkWidget *gis_plugin_teapot_get_config(GisPlugin *_teapot) +static GtkWidget *grits_plugin_teapot_get_config(GritsPlugin *_teapot) { - GisPluginTeapot *teapot = GIS_PLUGIN_TEAPOT(_teapot); + GritsPluginTeapot *teapot = GRITS_PLUGIN_TEAPOT(_teapot); return GTK_WIDGET(teapot->button); } @@ -90,36 +90,36 @@ static GtkWidget *gis_plugin_teapot_get_config(GisPlugin *_teapot) * GObject code * ****************/ /* Plugin init */ -static void gis_plugin_teapot_plugin_init(GisPluginInterface *iface); -G_DEFINE_TYPE_WITH_CODE(GisPluginTeapot, gis_plugin_teapot, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE(GIS_TYPE_PLUGIN, - gis_plugin_teapot_plugin_init)); -static void gis_plugin_teapot_plugin_init(GisPluginInterface *iface) +static void grits_plugin_teapot_plugin_init(GritsPluginInterface *iface); +G_DEFINE_TYPE_WITH_CODE(GritsPluginTeapot, grits_plugin_teapot, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE(GRITS_TYPE_PLUGIN, + grits_plugin_teapot_plugin_init)); +static void grits_plugin_teapot_plugin_init(GritsPluginInterface *iface) { - g_debug("GisPluginTeapot: plugin_init"); + g_debug("GritsPluginTeapot: plugin_init"); /* Add methods to the interface */ - iface->get_config = gis_plugin_teapot_get_config; + iface->get_config = grits_plugin_teapot_get_config; } /* Class/Object init */ -static void gis_plugin_teapot_init(GisPluginTeapot *teapot) +static void grits_plugin_teapot_init(GritsPluginTeapot *teapot) { - g_debug("GisPluginTeapot: init"); + g_debug("GritsPluginTeapot: init"); /* Set defaults */ teapot->button = GTK_TOGGLE_BUTTON(gtk_toggle_button_new_with_label("Rotate")); teapot->rotate_id = g_timeout_add(1000/60, rotate, teapot); teapot->rotation = 30.0; } -static void gis_plugin_teapot_dispose(GObject *gobject) +static void grits_plugin_teapot_dispose(GObject *gobject) { - g_debug("GisPluginTeapot: dispose"); - GisPluginTeapot *teapot = GIS_PLUGIN_TEAPOT(gobject); + g_debug("GritsPluginTeapot: dispose"); + GritsPluginTeapot *teapot = GRITS_PLUGIN_TEAPOT(gobject); g_source_remove(teapot->rotate_id); /* Drop references */ - G_OBJECT_CLASS(gis_plugin_teapot_parent_class)->dispose(gobject); + G_OBJECT_CLASS(grits_plugin_teapot_parent_class)->dispose(gobject); } -static void gis_plugin_teapot_class_init(GisPluginTeapotClass *klass) +static void grits_plugin_teapot_class_init(GritsPluginTeapotClass *klass) { - g_debug("GisPluginTeapot: class_init"); + g_debug("GritsPluginTeapot: class_init"); GObjectClass *gobject_class = (GObjectClass*)klass; - gobject_class->dispose = gis_plugin_teapot_dispose; + gobject_class->dispose = grits_plugin_teapot_dispose; } diff --git a/examples/plugin/teapot.h b/examples/plugin/teapot.h index a849ef3..c042ae9 100644 --- a/examples/plugin/teapot.h +++ b/examples/plugin/teapot.h @@ -20,33 +20,33 @@ #include -#define GIS_TYPE_PLUGIN_TEAPOT (gis_plugin_teapot_get_type ()) -#define GIS_PLUGIN_TEAPOT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GIS_TYPE_PLUGIN_TEAPOT, GisPluginTeapot)) -#define GIS_IS_PLUGIN_TEAPOT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GIS_TYPE_PLUGIN_TEAPOT)) -#define GIS_PLUGIN_TEAPOT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIS_TYPE_PLUGIN_TEAPOT, GisPluginTeapotClass)) -#define GIS_IS_PLUGIN_TEAPOT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIS_TYPE_PLUGIN_TEAPOT)) -#define GIS_PLUGIN_TEAPOT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIS_TYPE_PLUGIN_TEAPOT, GisPluginTeapotClass)) +#define GRITS_TYPE_PLUGIN_TEAPOT (grits_plugin_teapot_get_type ()) +#define GRITS_PLUGIN_TEAPOT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GRITS_TYPE_PLUGIN_TEAPOT, GritsPluginTeapot)) +#define GRITS_IS_PLUGIN_TEAPOT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GRITS_TYPE_PLUGIN_TEAPOT)) +#define GRITS_PLUGIN_TEAPOT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRITS_TYPE_PLUGIN_TEAPOT, GritsPluginTeapotClass)) +#define GRITS_IS_PLUGIN_TEAPOT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRITS_TYPE_PLUGIN_TEAPOT)) +#define GRITS_PLUGIN_TEAPOT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GRITS_TYPE_PLUGIN_TEAPOT, GritsPluginTeapotClass)) -typedef struct _GisPluginTeapot GisPluginTeapot; -typedef struct _GisPluginTeapotClass GisPluginTeapotClass; +typedef struct _GritsPluginTeapot GritsPluginTeapot; +typedef struct _GritsPluginTeapotClass GritsPluginTeapotClass; -struct _GisPluginTeapot { +struct _GritsPluginTeapot { GObject parent_instance; /* instance members */ - GisViewer *viewer; + GritsViewer *viewer; GtkToggleButton *button; guint rotate_id; float rotation; }; -struct _GisPluginTeapotClass { +struct _GritsPluginTeapotClass { GObjectClass parent_class; }; -GType gis_plugin_teapot_get_type(); +GType grits_plugin_teapot_get_type(); /* Methods */ -GisPluginTeapot *gis_plugin_teapot_new(GisViewer *viewer, GisPrefs *prefs); +GritsPluginTeapot *grits_plugin_teapot_new(GritsViewer *viewer, GritsPrefs *prefs); #endif diff --git a/src/.vimrc b/src/.vimrc index 2de4374..2dd1127 100644 --- a/src/.vimrc +++ b/src/.vimrc @@ -1,5 +1,5 @@ set makeprg=make\ test -set tw=100 +"set tw=100 au FileType valgrind syn match gritsFile "\v<(grits-\w+|roam|elev|env|map|sat|test|radar)\.c>" containedin=valgrindSrc au FileType valgrind hi link gritsFile Error diff --git a/src/data/grits-data.c b/src/data/grits-data.c index a41e9b0..5145b77 100644 --- a/src/data/grits-data.c +++ b/src/data/grits-data.c @@ -16,7 +16,7 @@ */ /** - * SECTION:gis-data + * SECTION:grits-data * @short_description: Miscellaneous utilities for data access * @include: glib/gstdio.h * diff --git a/src/data/grits-data.h b/src/data/grits-data.h index 671280d..65d6430 100644 --- a/src/data/grits-data.h +++ b/src/data/grits-data.h @@ -15,29 +15,29 @@ * along with this program. If not, see . */ -#ifndef __GIS_DATA_H__ -#define __GIS_DATA_H__ +#ifndef __GRITS_DATA_H__ +#define __GRITS_DATA_H__ #include /** - * GisCacheType: - * @GIS_LOCAL: Only return local files (for offline mode) - * @GIS_ONCE: Download the file only if it does not exist - * @GIS_UPDATE: Update the file to be like the server - * @GIS_REFRESH: Delete the existing file and fetch a new copy + * GritsCacheType: + * @GRITS_LOCAL: Only return local files (for offline mode) + * @GRITS_ONCE: Download the file only if it does not exist + * @GRITS_UPDATE: Update the file to be like the server + * @GRITS_REFRESH: Delete the existing file and fetch a new copy * * Various methods for caching data */ typedef enum { - GIS_LOCAL, - GIS_ONCE, - GIS_UPDATE, - GIS_REFRESH, -} GisCacheType; + GRITS_LOCAL, + GRITS_ONCE, + GRITS_UPDATE, + GRITS_REFRESH, +} GritsCacheType; /** - * GisChunkCallback: + * GritsChunkCallback: * @file: path to the file which is being fetched * @cur: current offset in the file * @total: total size of the file @@ -46,7 +46,7 @@ typedef enum { * Function called when part of a file is fetched * Used for updating progress bars, etc */ -typedef void (*GisChunkCallback)(gchar *file, goffset cur, +typedef void (*GritsChunkCallback)(gchar *file, goffset cur, goffset total, gpointer user_data); FILE *fopen_p(const gchar *path, const gchar *mode); diff --git a/src/data/grits-http.c b/src/data/grits-http.c index c0f098f..c4b4484 100644 --- a/src/data/grits-http.c +++ b/src/data/grits-http.c @@ -16,13 +16,13 @@ */ /** - * SECTION:gis-http + * SECTION:grits-http * @short_description: Hyper Text Transfer Protocol * - * #GisHttp is a small wrapper around libsoup to provide data access using the - * Hyper Text Transfer Protocol. Each #GisHttp should be associated with a - * particular server or dataset, all the files downloaded for this dataset will - * be cached together in $HOME/.cache/grits/ + * #GritsHttp is a small wrapper around libsoup to provide data access using + * the Hyper Text Transfer Protocol. Each #GritsHttp should be associated with + * a particular server or dataset, all the files downloaded for this dataset + * will be cached together in $HOME/.cache/grits/ */ #include @@ -32,25 +32,25 @@ #include "grits-http.h" -gchar *_get_cache_path(GisHttp *http, const gchar *local) +gchar *_get_cache_path(GritsHttp *http, const gchar *local) { return g_build_filename(g_get_user_cache_dir(), PACKAGE, http->prefix, local, NULL); } /** - * gis_http_new: + * grits_http_new: * @prefix: The prefix in the cache to store the downloaded files. * For example: * "/nexrad/level2/". * - * Create a new #GisHttp for the given prefix + * Create a new #GritsHttp for the given prefix * - * Returns: the new #GisHttp + * Returns: the new #GritsHttp */ -GisHttp *gis_http_new(const gchar *prefix) +GritsHttp *grits_http_new(const gchar *prefix) { - g_debug("GisHttp: new - %s", prefix); - GisHttp *http = g_new0(GisHttp, 1); + g_debug("GritsHttp: new - %s", prefix); + GritsHttp *http = g_new0(GritsHttp, 1); http->soup = soup_session_sync_new(); http->prefix = g_strdup(prefix); g_object_set(http->soup, "user-agent", PACKAGE_STRING, NULL); @@ -58,14 +58,14 @@ GisHttp *gis_http_new(const gchar *prefix) } /** - * gis_http_free: - * @http: the #GisHttp to free + * grits_http_free: + * @http: the #GritsHttp to free * * Frees resources used by @http and cancels any pending requests. */ -void gis_http_free(GisHttp *http) +void grits_http_free(GritsHttp *http) { - g_debug("GisHttp: free - %s", http->prefix); + g_debug("GritsHttp: free - %s", http->prefix); soup_session_abort(http->soup); g_object_unref(http->soup); g_free(http->prefix); @@ -76,12 +76,12 @@ void gis_http_free(GisHttp *http) struct _CacheInfo { FILE *fp; gchar *path; - GisChunkCallback callback; + GritsChunkCallback callback; gpointer user_data; }; struct _CacheInfoMain { gchar *path; - GisChunkCallback callback; + GritsChunkCallback callback; gpointer user_data; goffset cur, total; }; @@ -106,13 +106,13 @@ static void _chunk_cb(SoupMessage *message, SoupBuffer *chunk, gpointer _info) struct _CacheInfo *info = _info; if (!SOUP_STATUS_IS_SUCCESSFUL(message->status_code)) { - g_warning("GisHttp: _chunk_cb - soup failed with %d", + g_warning("GritsHttp: _chunk_cb - soup failed with %d", message->status_code); return; } if (!fwrite(chunk->data, chunk->length, 1, info->fp)) - g_error("GisHttp: _chunk_cb - Unable to write data"); + g_error("GritsHttp: _chunk_cb - Unable to write data"); if (info->callback) { struct _CacheInfoMain *infomain = g_new0(struct _CacheInfoMain, 1); @@ -129,8 +129,8 @@ static void _chunk_cb(SoupMessage *message, SoupBuffer *chunk, gpointer _info) } /** - * gis_http_fetch: - * @http: the #GisHttp connection to use + * grits_http_fetch: + * @http: the #GritsHttp connection to use * @uri: the URI to fetch * @local: the local name to give to the file * @mode: the update type to use when fetching data @@ -142,21 +142,21 @@ static void _chunk_cb(SoupMessage *message, SoupBuffer *chunk, gpointer _info) * * Returns: The local path to the complete file */ -/* TODO: use .part extentions and continue even when using GIS_ONCE */ -gchar *gis_http_fetch(GisHttp *http, const gchar *uri, const char *local, - GisCacheType mode, GisChunkCallback callback, gpointer user_data) +/* TODO: use .part extentions and continue even when using GRITS_ONCE */ +gchar *grits_http_fetch(GritsHttp *http, const gchar *uri, const char *local, + GritsCacheType mode, GritsChunkCallback callback, gpointer user_data) { - g_debug("GisHttp: fetch - %s mode=%d", local, mode); + g_debug("GritsHttp: fetch - %s mode=%d", local, mode); gchar *path = _get_cache_path(http, local); /* Unlink the file if we're refreshing it */ - if (mode == GIS_REFRESH) + if (mode == GRITS_REFRESH) g_remove(path); /* Do the cache if necessasairy */ - if (!(mode == GIS_ONCE && g_file_test(path, G_FILE_TEST_EXISTS)) && - mode != GIS_LOCAL) { - g_debug("GisHttp: fetch - Caching file %s", local); + if (!(mode == GRITS_ONCE && g_file_test(path, G_FILE_TEST_EXISTS)) && + mode != GRITS_LOCAL) { + g_debug("GritsHttp: fetch - Caching file %s", local); /* Open the file for writting */ gchar *part = path; @@ -192,7 +192,7 @@ gchar *gis_http_fetch(GisHttp *http, const gchar *uri, const char *local, if (message->status_code == 416) { /* Range unsatisfiable, file already complete */ } else if (!SOUP_STATUS_IS_SUCCESSFUL(message->status_code)) { - g_warning("GisHttp: done_cb - error copying file, status=%d\n" + g_warning("GritsHttp: done_cb - error copying file, status=%d\n" "\tsrc=%s\n" "\tdst=%s", message->status_code, uri, path); @@ -206,8 +206,8 @@ gchar *gis_http_fetch(GisHttp *http, const gchar *uri, const char *local, } /** - * gis_http_available: - * @http: the #GisHttp connection to use + * grits_http_available: + * @http: the #GritsHttp connection to use * @filter: filter used to extract files from the index, or NULL * For example: "href=\"([^"]*)\"" * @cache: path to the local cache, or NULL to not search the cache @@ -222,11 +222,11 @@ gchar *gis_http_fetch(GisHttp *http, const gchar *uri, const char *local, * * Returns the list of matching filenames */ -GList *gis_http_available(GisHttp *http, +GList *grits_http_available(GritsHttp *http, gchar *filter, gchar *cache, gchar *extract, gchar *index) { - g_debug("GisHttp: available - %s~=%s %s~=%s", + g_debug("GritsHttp: available - %s~=%s %s~=%s", filter, cache, extract, index); GRegex *filter_re = g_regex_new(filter, 0, 0, NULL); GList *files = NULL; @@ -247,8 +247,8 @@ GList *gis_http_available(GisHttp *http, if (index) { gchar tmp[32]; g_snprintf(tmp, sizeof(tmp), ".index.%x", g_random_int()); - gchar *path = gis_http_fetch(http, index, tmp, - GIS_REFRESH, NULL, NULL); + gchar *path = grits_http_fetch(http, index, tmp, + GRITS_REFRESH, NULL, NULL); if (!path) return files; gchar *html; diff --git a/src/data/grits-http.h b/src/data/grits-http.h index 713c2c8..04f9a63 100644 --- a/src/data/grits-http.h +++ b/src/data/grits-http.h @@ -15,29 +15,29 @@ * along with this program. If not, see . */ -#ifndef __GIS_HTTP_H__ -#define __GIS_HTTP_H__ +#ifndef __GRITS_HTTP_H__ +#define __GRITS_HTTP_H__ #include #include #include "grits-data.h" -typedef struct _GisHttp { +typedef struct _GritsHttp { SoupSession *soup; gchar *prefix; -} GisHttp; +} GritsHttp; -GisHttp *gis_http_new(const gchar *prefix); +GritsHttp *grits_http_new(const gchar *prefix); -void gis_http_free(GisHttp *http); +void grits_http_free(GritsHttp *http); -gchar *gis_http_fetch(GisHttp *http, const gchar *uri, const gchar *local, - GisCacheType mode, - GisChunkCallback callback, +gchar *grits_http_fetch(GritsHttp *http, const gchar *uri, const gchar *local, + GritsCacheType mode, + GritsChunkCallback callback, gpointer user_data); -GList *gis_http_available(GisHttp *http, +GList *grits_http_available(GritsHttp *http, gchar *filter, gchar *cache, gchar *extract, gchar *index); diff --git a/src/data/grits-wms.c b/src/data/grits-wms.c index 300528c..32c0c0c 100644 --- a/src/data/grits-wms.c +++ b/src/data/grits-wms.c @@ -16,11 +16,11 @@ */ /** - * SECTION:gis-wms + * SECTION:grits-wms * @short_description: Web Map Service * * Provides an API for accessing image tiles form a Web Map Service (WMS) - * server. #GisWms integrates closely with #GisTile. The remote server must + * server. #GritsWms integrates closely with #GritsTile. The remote server must * support the EPSG:4326 cartographic projection. */ @@ -76,7 +76,7 @@ #include "grits-wms.h" #include "grits-http.h" -static gchar *_make_uri(GisWms *wms, GisTile *tile) +static gchar *_make_uri(GritsWms *wms, GritsTile *tile) { return g_strdup_printf( "%s?" @@ -102,24 +102,24 @@ static gchar *_make_uri(GisWms *wms, GisTile *tile) } /** - * gis_wms_fetch: - * @wms: the #GisWms to fetch the data from - * @tile: a #GisTile representing the area to be fetched + * grits_wms_fetch: + * @wms: the #GritsWms to fetch the data from + * @tile: a #GritsTile representing the area to be fetched * @mode: the update type to use when fetching data * @callback: callback to call when a chunk of data is received * @user_data: user data to pass to the callback * - * Fetch a image coresponding to a #GisTile from a WMS server. + * Fetch a image coresponding to a #GritsTile from a WMS server. * * Returns: the path to the local file. */ -gchar *gis_wms_fetch(GisWms *wms, GisTile *tile, GisCacheType mode, - GisChunkCallback callback, gpointer user_data) +gchar *grits_wms_fetch(GritsWms *wms, GritsTile *tile, GritsCacheType mode, + GritsChunkCallback callback, gpointer user_data) { gchar *uri = _make_uri(wms, tile); - gchar *tilep = gis_tile_get_path(tile); + gchar *tilep = grits_tile_get_path(tile); gchar *local = g_strdup_printf("%s%s", tilep, wms->extension); - gchar *path = gis_http_fetch(wms->http, uri, local, + gchar *path = grits_http_fetch(wms->http, uri, local, mode, callback, user_data); g_free(uri); g_free(tilep); @@ -128,7 +128,7 @@ gchar *gis_wms_fetch(GisWms *wms, GisTile *tile, GisCacheType mode, } /** - * gis_wms_new: + * grits_wms_new: * @uri_prefix: the base URL for the WMS server * @uri_layer: the layer the images should be fetched from (wms LAYERS) * @uri_format: the format the images should be fetch in (wms FORMAT) @@ -137,39 +137,39 @@ gchar *gis_wms_fetch(GisWms *wms, GisTile *tile, GisCacheType mode, * @width: width in pixels for downloaded images (wms WIDTH) * @height: height in pixels for downloaded images (wms HEIGHT) * - * Creates a #GisWms for some layer on a WMS server. The returned #GisWms + * Creates a #GritsWms for some layer on a WMS server. The returned #GritsWms * stores information about the images so it does not need to be entered each * time a images is fetched. * - * Returns: the new #GisWms + * Returns: the new #GritsWms */ -GisWms *gis_wms_new( +GritsWms *grits_wms_new( const gchar *uri_prefix, const gchar *uri_layer, const gchar *uri_format, const gchar *prefix, const gchar *extension, gint width, gint height) { - g_debug("GisWms: new - %s", uri_prefix); - GisWms *wms = g_new0(GisWms, 1); - wms->http = gis_http_new(prefix); - wms->uri_prefix = g_strdup(uri_prefix); - wms->uri_layer = g_strdup(uri_layer); - wms->uri_format = g_strdup(uri_format); - wms->extension = g_strdup(extension); - wms->width = width; - wms->height = height; + g_debug("GritsWms: new - %s", uri_prefix); + GritsWms *wms = g_new0(GritsWms, 1); + wms->http = grits_http_new(prefix); + wms->uri_prefix = g_strdup(uri_prefix); + wms->uri_layer = g_strdup(uri_layer); + wms->uri_format = g_strdup(uri_format); + wms->extension = g_strdup(extension); + wms->width = width; + wms->height = height; return wms; } /** - * gis_wms_free: - * @wms: the #GisWms to free + * grits_wms_free: + * @wms: the #GritsWms to free * * Free resources used by @wms and cancel any pending requests. */ -void gis_wms_free(GisWms *wms) +void grits_wms_free(GritsWms *wms) { - g_debug("GisWms: free - %s", wms->uri_prefix); - gis_http_free(wms->http); + g_debug("GritsWms: free - %s", wms->uri_prefix); + grits_http_free(wms->http); g_free(wms->uri_prefix); g_free(wms->uri_layer); g_free(wms->uri_format); diff --git a/src/data/grits-wms.h b/src/data/grits-wms.h index 236a405..494bd20 100644 --- a/src/data/grits-wms.h +++ b/src/data/grits-wms.h @@ -15,32 +15,32 @@ * along with this program. If not, see . */ -#ifndef __GIS_WMS_H__ -#define __GIS_WMS_H__ +#ifndef __GRITS_WMS_H__ +#define __GRITS_WMS_H__ #include #include "data/grits-http.h" #include "objects/grits-tile.h" -typedef struct _GisWms { - GisHttp *http; +typedef struct _GritsWms { + GritsHttp *http; gchar *uri_prefix; gchar *uri_layer; gchar *uri_format; gchar *extension; gint width; gint height; -} GisWms; +} GritsWms; -GisWms *gis_wms_new( +GritsWms *grits_wms_new( const gchar *uri_prefix, const gchar *uri_layer, const gchar *uri_format, const gchar *prefix, const gchar *extension, gint width, gint height); -gchar *gis_wms_fetch(GisWms *wms, GisTile *tile, GisCacheType mode, - GisChunkCallback callback, gpointer user_data); +gchar *grits_wms_fetch(GritsWms *wms, GritsTile *tile, GritsCacheType mode, + GritsChunkCallback callback, gpointer user_data); -void gis_wms_free(GisWms *wms); +void grits_wms_free(GritsWms *wms); #endif diff --git a/src/grits-demo.c b/src/grits-demo.c index c439e6f..d9532f4 100644 --- a/src/grits-demo.c +++ b/src/grits-demo.c @@ -22,9 +22,9 @@ #include "grits.h" -static GisPrefs *prefs; -static GisPlugins *plugins; -static GisViewer *viewer; +static GritsPrefs *prefs; +static GritsPlugins *plugins; +static GritsViewer *viewer; /************* @@ -39,7 +39,7 @@ static gboolean on_delete(GtkWidget *widget, GdkEvent *event, gpointer data) static void on_offline(GtkToggleAction *action, gpointer _) { gboolean active = gtk_toggle_action_get_active(action); - gis_viewer_set_offline(viewer, active); + grits_viewer_set_offline(viewer, active); } static void on_plugin(GtkToggleAction *action, GtkWidget *notebook) @@ -47,16 +47,16 @@ static void on_plugin(GtkToggleAction *action, GtkWidget *notebook) const gchar *name = gtk_action_get_name(GTK_ACTION(action)); gboolean active = gtk_toggle_action_get_active(action); if (active) { - GisPlugin *plugin = gis_plugins_enable(plugins, name, - GIS_VIEWER(viewer), prefs); - GtkWidget *config = gis_plugin_get_config(plugin); + GritsPlugin *plugin = grits_plugins_enable(plugins, name, + GRITS_VIEWER(viewer), prefs); + GtkWidget *config = grits_plugin_get_config(plugin); if (config) { gtk_notebook_append_page(GTK_NOTEBOOK(notebook), config, gtk_label_new(name)); gtk_widget_show_all(config); } } else { - gis_plugins_disable(plugins, name); + grits_plugins_disable(plugins, name); guint n_pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); for (int i = 0; i < n_pages; i++) { GtkWidget *body = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i); @@ -145,14 +145,14 @@ static void setup_plugins(GtkUIManager *manager, GtkNotebook *notebook) GtkActionGroup *actions = gtk_action_group_new("Plugins"); gtk_ui_manager_insert_action_group(manager, actions, 1); guint merge_id = gtk_ui_manager_new_merge_id(manager); - for (GList *cur = gis_plugins_available(plugins); cur; cur = cur->next) { + for (GList *cur = grits_plugins_available(plugins); cur; cur = cur->next) { gchar *name = cur->data; GtkToggleAction *action = gtk_toggle_action_new(name, name, NULL, NULL); g_signal_connect(action, "toggled", G_CALLBACK(on_plugin), notebook); gtk_action_group_add_action(actions, GTK_ACTION(action)); gtk_ui_manager_add_ui(manager, merge_id, "/Menu/Plugins", name, name, GTK_UI_MANAGER_AUTO, TRUE); - if (gis_prefs_get_boolean_v(prefs, "plugins", name, NULL)) + if (grits_prefs_get_boolean_v(prefs, "plugins", name, NULL)) gtk_toggle_action_set_active(action, TRUE); } } @@ -161,7 +161,7 @@ static void restore_states(GtkUIManager *manager) { GtkAction *action = gtk_ui_manager_get_action(manager, "/Menu/File/Offline"); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), - gis_viewer_get_offline(viewer)); + grits_viewer_get_offline(viewer)); } int main(int argc, char **argv) @@ -170,9 +170,9 @@ int main(int argc, char **argv) gdk_threads_init(); gtk_init(&argc, &argv); - prefs = gis_prefs_new(NULL, NULL); - plugins = gis_plugins_new(g_getenv("GIS_PLUGIN_PATH"), prefs); - viewer = gis_opengl_new(plugins, prefs); + prefs = grits_prefs_new(NULL, NULL); + plugins = grits_plugins_new(g_getenv("GRITS_PLUGIN_PATH"), prefs); + viewer = grits_opengl_new(plugins, prefs); gdk_threads_enter(); @@ -186,12 +186,12 @@ int main(int argc, char **argv) gtk_main(); - gis_plugins_free(plugins); + grits_plugins_free(plugins); g_object_unref(prefs); gdk_threads_leave(); - g_debug("GisDemo: main - refs=%d,%d", + g_debug("GritsDemo: main - refs=%d,%d", G_OBJECT(manager)->ref_count, G_OBJECT(window)->ref_count); g_object_unref(manager); diff --git a/src/grits-opengl.c b/src/grits-opengl.c index 7993741..93a1165 100644 --- a/src/grits-opengl.c +++ b/src/grits-opengl.c @@ -16,15 +16,15 @@ */ /** - * SECTION:gis-opengl + * SECTION:grits-opengl * @short_description: OpenGL based virtual globe * - * #GisOpenGL is the core rendering engine used by grits. Theoretically other - * renderers could be writte, but they have not been. GisOpenGL uses the ROAM - * algorithm for updating surface mesh the planet. The only thing GisOpenGL can - * actually render on it's own is a wireframe of a sphere. + * #GritsOpenGL is the core rendering engine used by grits. Theoretically other + * renderers could be writte, but they have not been. GritsOpenGL uses the ROAM + * algorithm for updating surface mesh the planet. The only thing GritsOpenGL + * can actually render on it's own is a wireframe of a sphere. * - * GisOpenGL relies on #GtkGlExt and requires (at least) OpenGL 2.0. + * GritsOpenGL relies on #GtkGlExt and requires (at least) OpenGL 2.0. */ #include @@ -49,15 +49,15 @@ /*********** * Helpers * ***********/ -static void _set_visuals(GisOpenGL *opengl) +static void _set_visuals(GritsOpenGL *opengl) { glMatrixMode(GL_MODELVIEW); glLoadIdentity(); /* Camera 1 */ double lat, lon, elev, rx, ry, rz; - gis_viewer_get_location(GIS_VIEWER(opengl), &lat, &lon, &elev); - gis_viewer_get_rotation(GIS_VIEWER(opengl), &rx, &ry, &rz); + grits_viewer_get_location(GRITS_VIEWER(opengl), &lat, &lon, &elev); + grits_viewer_get_rotation(GRITS_VIEWER(opengl), &rx, &ry, &rz); glRotatef(rx, 1, 0, 0); glRotatef(rz, 0, 0, 1); @@ -128,9 +128,9 @@ struct RenderLevel { GList sorted; }; -static gboolean on_configure(GisOpenGL *opengl, GdkEventConfigure *event, gpointer _) +static gboolean on_configure(GritsOpenGL *opengl, GdkEventConfigure *event, gpointer _) { - g_debug("GisOpenGL: on_configure"); + g_debug("GritsOpenGL: on_configure"); double width = GTK_WIDGET(opengl)->allocation.width; double height = GTK_WIDGET(opengl)->allocation.height; @@ -153,8 +153,8 @@ static gboolean on_configure(GisOpenGL *opengl, GdkEventConfigure *event, gpoint static gboolean _draw_level(gpointer key, gpointer value, gpointer user_data) { - g_debug("GisOpenGL: _draw_level - level=%-4d", (int)key); - GisOpenGL *opengl = user_data; + g_debug("GritsOpenGL: _draw_level - level=%-4d", (int)key); + GritsOpenGL *opengl = user_data; struct RenderLevel *level = value; int nsorted = 0, nunsorted = 0; GList *cur = NULL; @@ -163,25 +163,25 @@ static gboolean _draw_level(gpointer key, gpointer value, gpointer user_data) glDepthMask(TRUE); glClear(GL_DEPTH_BUFFER_BIT); for (cur = level->unsorted.next; cur; cur = cur->next, nunsorted++) - gis_object_draw( GIS_OBJECT(cur->data), opengl); + grits_object_draw(GRITS_OBJECT(cur->data), opengl); /* Freeze depth buffer and draw transparent objects sorted */ /* TODO: sorting */ //glDepthMask(FALSE); glAlphaFunc(GL_GREATER, 0.1); for (cur = level->sorted.next; cur; cur = cur->next, nsorted++) - gis_object_draw(GIS_OBJECT(cur->data), opengl); + grits_object_draw(GRITS_OBJECT(cur->data), opengl); /* TODO: Prune empty levels */ - g_debug("GisOpenGL: _draw_level - drew %d,%d objects", + g_debug("GritsOpenGL: _draw_level - drew %d,%d objects", nunsorted, nsorted); return FALSE; } -static gboolean on_expose(GisOpenGL *opengl, GdkEventExpose *event, gpointer _) +static gboolean on_expose(GritsOpenGL *opengl, GdkEventExpose *event, gpointer _) { - g_debug("GisOpenGL: on_expose - begin"); + g_debug("GritsOpenGL: on_expose - begin"); glClear(GL_COLOR_BUFFER_BIT); @@ -208,13 +208,13 @@ static gboolean on_expose(GisOpenGL *opengl, GdkEventExpose *event, gpointer _) GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(GTK_WIDGET(opengl)); gdk_gl_drawable_swap_buffers(gldrawable); - g_debug("GisOpenGL: on_expose - end\n"); + g_debug("GritsOpenGL: on_expose - end\n"); return FALSE; } -static gboolean on_key_press(GisOpenGL *opengl, GdkEventKey *event, gpointer _) +static gboolean on_key_press(GritsOpenGL *opengl, GdkEventKey *event, gpointer _) { - g_debug("GisOpenGL: on_key_press - key=%x, state=%x, plus=%x", + g_debug("GritsOpenGL: on_key_press - key=%x, state=%x, plus=%x", event->keyval, event->state, GDK_plus); guint kv = event->keyval; @@ -235,17 +235,17 @@ static gboolean on_key_press(GisOpenGL *opengl, GdkEventKey *event, gpointer _) static gboolean _update_errors_cb(gpointer _opengl) { - GisOpenGL *opengl = _opengl; + GritsOpenGL *opengl = _opengl; g_mutex_lock(opengl->sphere_lock); roam_sphere_update_errors(opengl->sphere); g_mutex_unlock(opengl->sphere_lock); opengl->ue_source = 0; return FALSE; } -static void on_view_changed(GisOpenGL *opengl, +static void on_view_changed(GritsOpenGL *opengl, gdouble _1, gdouble _2, gdouble _3) { - g_debug("GisOpenGL: on_view_changed"); + g_debug("GritsOpenGL: on_view_changed"); _set_visuals(opengl); #ifndef ROAM_DEBUG if (!opengl->ue_source) @@ -257,9 +257,9 @@ static void on_view_changed(GisOpenGL *opengl, #endif } -static gboolean on_idle(GisOpenGL *opengl) +static gboolean on_idle(GritsOpenGL *opengl) { - //g_debug("GisOpenGL: on_idle"); + //g_debug("GritsOpenGL: on_idle"); g_mutex_lock(opengl->sphere_lock); if (roam_sphere_split_merge(opengl->sphere)) gtk_widget_queue_draw(GTK_WIDGET(opengl)); @@ -267,9 +267,9 @@ static gboolean on_idle(GisOpenGL *opengl) return TRUE; } -static void on_realize(GisOpenGL *opengl, gpointer _) +static void on_realize(GritsOpenGL *opengl, gpointer _) { - g_debug("GisOpenGL: on_realize"); + g_debug("GritsOpenGL: on_realize"); /* Start OpenGL */ GdkGLContext *glcontext = gtk_widget_get_gl_context(GTK_WIDGET(opengl)); @@ -300,37 +300,37 @@ static void on_realize(GisOpenGL *opengl, gpointer _) } /********************* - * GisViewer methods * + * GritsViewer methods * *********************/ /** - * gis_opengl_new: + * grits_opengl_new: * @plugins: the plugins store to use * @prefs: the preferences object to use * * Create a new OpenGL renderer. * - * Returns: the new #GisOpenGL + * Returns: the new #GritsOpenGL */ -GisViewer *gis_opengl_new(GisPlugins *plugins, GisPrefs *prefs) +GritsViewer *grits_opengl_new(GritsPlugins *plugins, GritsPrefs *prefs) { - g_debug("GisOpenGL: new"); - GisViewer *opengl = g_object_new(GIS_TYPE_OPENGL, NULL); - gis_viewer_setup(opengl, plugins, prefs); + g_debug("GritsOpenGL: new"); + GritsViewer *opengl = g_object_new(GRITS_TYPE_OPENGL, NULL); + grits_viewer_setup(opengl, plugins, prefs); return opengl; } -static void gis_opengl_center_position(GisViewer *_opengl, gdouble lat, gdouble lon, gdouble elev) +static void grits_opengl_center_position(GritsViewer *_opengl, gdouble lat, gdouble lon, gdouble elev) { glRotatef(lon, 0, 1, 0); glRotatef(-lat, 1, 0, 0); glTranslatef(0, 0, elev2rad(elev)); } -static void gis_opengl_project(GisViewer *_opengl, +static void grits_opengl_project(GritsViewer *_opengl, gdouble lat, gdouble lon, gdouble elev, gdouble *px, gdouble *py, gdouble *pz) { - GisOpenGL *opengl = GIS_OPENGL(_opengl); + GritsOpenGL *opengl = GRITS_OPENGL(_opengl); gdouble x, y, z; lle2xyz(lat, lon, elev, &x, &y, &z); gluProject(x, y, z, @@ -340,10 +340,10 @@ static void gis_opengl_project(GisViewer *_opengl, px, py, pz); } -static void gis_opengl_set_height_func(GisViewer *_opengl, GisBounds *bounds, +static void grits_opengl_set_height_func(GritsViewer *_opengl, GritsBounds *bounds, RoamHeightFunc height_func, gpointer user_data, gboolean update) { - GisOpenGL *opengl = GIS_OPENGL(_opengl); + GritsOpenGL *opengl = GRITS_OPENGL(_opengl); /* TODO: get points? */ g_mutex_lock(opengl->sphere_lock); GList *triangles = roam_sphere_get_intersect(opengl->sphere, TRUE, @@ -364,7 +364,7 @@ static void gis_opengl_set_height_func(GisViewer *_opengl, GisBounds *bounds, g_mutex_unlock(opengl->sphere_lock); } -static void _gis_opengl_clear_height_func_rec(RoamTriangle *root) +static void _grits_opengl_clear_height_func_rec(RoamTriangle *root) { if (!root) return; @@ -374,22 +374,22 @@ static void _gis_opengl_clear_height_func_rec(RoamTriangle *root) points[i]->height_data = NULL; roam_point_update_height(points[i]); } - _gis_opengl_clear_height_func_rec(root->kids[0]); - _gis_opengl_clear_height_func_rec(root->kids[1]); + _grits_opengl_clear_height_func_rec(root->kids[0]); + _grits_opengl_clear_height_func_rec(root->kids[1]); } -static void gis_opengl_clear_height_func(GisViewer *_opengl) +static void grits_opengl_clear_height_func(GritsViewer *_opengl) { - GisOpenGL *opengl = GIS_OPENGL(_opengl); + GritsOpenGL *opengl = GRITS_OPENGL(_opengl); for (int i = 0; i < G_N_ELEMENTS(opengl->sphere->roots); i++) - _gis_opengl_clear_height_func_rec(opengl->sphere->roots[i]); + _grits_opengl_clear_height_func_rec(opengl->sphere->roots[i]); } -static gpointer gis_opengl_add(GisViewer *_opengl, GisObject *object, +static gpointer grits_opengl_add(GritsViewer *_opengl, GritsObject *object, gint key, gboolean sort) { - g_assert(GIS_IS_OPENGL(_opengl)); - GisOpenGL *opengl = GIS_OPENGL(_opengl); + g_assert(GRITS_IS_OPENGL(_opengl)); + GritsOpenGL *opengl = GRITS_OPENGL(_opengl); g_mutex_lock(opengl->objects_lock); struct RenderLevel *level = g_tree_lookup(opengl->objects, (gpointer)key); if (!level) { @@ -409,13 +409,13 @@ static gpointer gis_opengl_add(GisViewer *_opengl, GisObject *object, return link; } -static GisObject *gis_opengl_remove(GisViewer *_opengl, gpointer _link) +static GritsObject *grits_opengl_remove(GritsViewer *_opengl, gpointer _link) { - g_assert(GIS_IS_OPENGL(_opengl)); - GisOpenGL *opengl = GIS_OPENGL(_opengl); + g_assert(GRITS_IS_OPENGL(_opengl)); + GritsOpenGL *opengl = GRITS_OPENGL(_opengl); g_mutex_lock(opengl->objects_lock); GList *link = _link; - GisObject *object = link->data; + GritsObject *object = link->data; /* Just unlink and free it, link->prev is assured */ link->prev->next = link->next; if (link->next) @@ -445,10 +445,10 @@ static void _objects_free(gpointer value) g_free(level); } -G_DEFINE_TYPE(GisOpenGL, gis_opengl, GIS_TYPE_VIEWER); -static void gis_opengl_init(GisOpenGL *opengl) +G_DEFINE_TYPE(GritsOpenGL, grits_opengl, GRITS_TYPE_VIEWER); +static void grits_opengl_init(GritsOpenGL *opengl) { - g_debug("GisOpenGL: init"); + g_debug("GritsOpenGL: init"); opengl->objects = g_tree_new_full(_objects_cmp, NULL, NULL, _objects_free); opengl->objects_lock = g_mutex_new(); opengl->sphere = roam_sphere_new(opengl); @@ -468,10 +468,10 @@ static void gis_opengl_init(GisOpenGL *opengl) /* Finish OpenGL init after it's realized */ g_signal_connect(opengl, "realize", G_CALLBACK(on_realize), NULL); } -static void gis_opengl_dispose(GObject *_opengl) +static void grits_opengl_dispose(GObject *_opengl) { - g_debug("GisOpenGL: dispose"); - GisOpenGL *opengl = GIS_OPENGL(_opengl); + g_debug("GritsOpenGL: dispose"); + GritsOpenGL *opengl = GRITS_OPENGL(_opengl); if (opengl->sm_source[0]) { g_source_remove(opengl->sm_source[0]); opengl->sm_source[0] = 0; @@ -484,30 +484,30 @@ static void gis_opengl_dispose(GObject *_opengl) g_source_remove(opengl->ue_source); opengl->ue_source = 0; } - G_OBJECT_CLASS(gis_opengl_parent_class)->dispose(_opengl); + G_OBJECT_CLASS(grits_opengl_parent_class)->dispose(_opengl); } -static void gis_opengl_finalize(GObject *_opengl) +static void grits_opengl_finalize(GObject *_opengl) { - g_debug("GisOpenGL: finalize"); - GisOpenGL *opengl = GIS_OPENGL(_opengl); + g_debug("GritsOpenGL: finalize"); + GritsOpenGL *opengl = GRITS_OPENGL(_opengl); roam_sphere_free(opengl->sphere); g_tree_destroy(opengl->objects); g_mutex_free(opengl->objects_lock); g_mutex_free(opengl->sphere_lock); - G_OBJECT_CLASS(gis_opengl_parent_class)->finalize(_opengl); + G_OBJECT_CLASS(grits_opengl_parent_class)->finalize(_opengl); } -static void gis_opengl_class_init(GisOpenGLClass *klass) +static void grits_opengl_class_init(GritsOpenGLClass *klass) { - g_debug("GisOpenGL: class_init"); + g_debug("GritsOpenGL: class_init"); GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - gobject_class->finalize = gis_opengl_finalize; - gobject_class->dispose = gis_opengl_dispose; - - GisViewerClass *viewer_class = GIS_VIEWER_CLASS(klass); - viewer_class->center_position = gis_opengl_center_position; - viewer_class->project = gis_opengl_project; - viewer_class->clear_height_func = gis_opengl_clear_height_func; - viewer_class->set_height_func = gis_opengl_set_height_func; - viewer_class->add = gis_opengl_add; - viewer_class->remove = gis_opengl_remove; + gobject_class->finalize = grits_opengl_finalize; + gobject_class->dispose = grits_opengl_dispose; + + GritsViewerClass *viewer_class = GRITS_VIEWER_CLASS(klass); + viewer_class->center_position = grits_opengl_center_position; + viewer_class->project = grits_opengl_project; + viewer_class->clear_height_func = grits_opengl_clear_height_func; + viewer_class->set_height_func = grits_opengl_set_height_func; + viewer_class->add = grits_opengl_add; + viewer_class->remove = grits_opengl_remove; } diff --git a/src/grits-opengl.h b/src/grits-opengl.h index 0b5a9b6..0379509 100644 --- a/src/grits-opengl.h +++ b/src/grits-opengl.h @@ -15,27 +15,27 @@ * along with this program. If not, see . */ -#ifndef __GIS_OPENGL_H__ -#define __GIS_OPENGL_H__ +#ifndef __GRITS_OPENGL_H__ +#define __GRITS_OPENGL_H__ #include /* Type macros */ -#define GIS_TYPE_OPENGL (gis_opengl_get_type()) -#define GIS_OPENGL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GIS_TYPE_OPENGL, GisOpenGL)) -#define GIS_IS_OPENGL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GIS_TYPE_OPENGL)) -#define GIS_OPENGL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIS_TYPE_OPENGL, GisOpenGLClass)) -#define GIS_IS_OPENGL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIS_TYPE_OPENGL)) -#define GIS_OPENGL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIS_TYPE_OPENGL, GisOpenGLClass)) +#define GRITS_TYPE_OPENGL (grits_opengl_get_type()) +#define GRITS_OPENGL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GRITS_TYPE_OPENGL, GritsOpenGL)) +#define GRITS_IS_OPENGL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GRITS_TYPE_OPENGL)) +#define GRITS_OPENGL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRITS_TYPE_OPENGL, GritsOpenGLClass)) +#define GRITS_IS_OPENGL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRITS_TYPE_OPENGL)) +#define GRITS_OPENGL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GRITS_TYPE_OPENGL, GritsOpenGLClass)) -typedef struct _GisOpenGL GisOpenGL; -typedef struct _GisOpenGLClass GisOpenGLClass; +typedef struct _GritsOpenGL GritsOpenGL; +typedef struct _GritsOpenGLClass GritsOpenGLClass; #include "grits-viewer.h" #include "roam.h" -struct _GisOpenGL { - GisViewer parent_instance; +struct _GritsOpenGL { + GritsViewer parent_instance; /* instance members */ GTree *objects; @@ -49,15 +49,15 @@ struct _GisOpenGL { gboolean wireframe; }; -struct _GisOpenGLClass { - GisViewerClass parent_class; +struct _GritsOpenGLClass { + GritsViewerClass parent_class; /* class members */ }; -GType gis_opengl_get_type(void); +GType grits_opengl_get_type(void); /* Methods */ -GisViewer *gis_opengl_new(GisPlugins *plugins, GisPrefs *prefs); +GritsViewer *grits_opengl_new(GritsPlugins *plugins, GritsPrefs *prefs); #endif diff --git a/src/grits-plugin.c b/src/grits-plugin.c index 6ceea39..144c713 100644 --- a/src/grits-plugin.c +++ b/src/grits-plugin.c @@ -16,22 +16,22 @@ */ /** - * SECTION:gis-plugin + * SECTION:grits-plugin * @short_description: Plugin support * - * A plugin in grits is a GObject which implements the GisPlugin interface. + * A plugin in grits is a GObject which implements the GritsPlugin interface. * Additionally, each plugin is compiled to a separate shared object and loaded * conditionally at runtime when the plugin is enabled. Each such shared object - * should define a GisPluginConstructor() function named gis_plugin_NAME_new - * which will be called when loading the plugin. + * should define a GritsPluginConstructor() function named + * grits_plugin_NAME_new which will be called when loading the plugin. * * Almost all grits functionality is provided by a set of plugins. Each plugin * can how however much it likes. The interface between plugins and the rest of * grits is intentionally very thin. Since grits is the library, plugins must * manually do everything. For instance, to draw something in the world, the - * plugin must add an object to the viewer. Likewise, plugins need to register - * callbacks on the viewer in order to receive updates, very little happens - * automagically. + * plugin must add an object to the viewer. Likewise, plugins need to + * register callbacks on the viewer in order to receive updates, very little + * happens automagically. * * That being said, one thing that plugins do do automagically, is provide a * configuration area. Since the plugin doesn't know what application is is @@ -49,7 +49,7 @@ /******************** * Plugin interface * ********************/ -static void gis_plugin_base_init(gpointer g_class) +static void grits_plugin_base_init(gpointer g_class) { static gboolean is_initialized = FALSE; if (!is_initialized) { @@ -58,23 +58,23 @@ static void gis_plugin_base_init(gpointer g_class) } } -GType gis_plugin_get_type() +GType grits_plugin_get_type() { static GType type = 0; if (type == 0) { static const GTypeInfo info = { - sizeof(GisPluginInterface), - gis_plugin_base_init, + sizeof(GritsPluginInterface), + grits_plugin_base_init, NULL, }; type = g_type_register_static(G_TYPE_INTERFACE, - "GisPlugin", &info, 0); + "GritsPlugin", &info, 0); } return type; } /** - * gis_plugin_get_name: + * grits_plugin_get_name: * @plugin: the plugin * * Get a short human readable name for a plugin, this is not necessarily the @@ -82,30 +82,30 @@ GType gis_plugin_get_type() * * Returns: a short name for the plugin */ -const gchar *gis_plugin_get_name(GisPlugin *plugin) +const gchar *grits_plugin_get_name(GritsPlugin *plugin) { - if (!GIS_IS_PLUGIN(plugin)) + if (!GRITS_IS_PLUGIN(plugin)) return NULL; - return GIS_PLUGIN_GET_INTERFACE(plugin)->name; + return GRITS_PLUGIN_GET_INTERFACE(plugin)->name; } /** - * gis_plugin_get_description: + * grits_plugin_get_description: * @plugin: the plugin * * Get a description of a plugin * * Returns: a description of the plugin */ -const gchar *gis_plugin_get_description(GisPlugin *plugin) +const gchar *grits_plugin_get_description(GritsPlugin *plugin) { - if (!GIS_IS_PLUGIN(plugin)) + if (!GRITS_IS_PLUGIN(plugin)) return NULL; - return GIS_PLUGIN_GET_INTERFACE(plugin)->description; + return GRITS_PLUGIN_GET_INTERFACE(plugin)->description; } /** - * gis_plugin_get_config: + * grits_plugin_get_config: * @plugin: the plugin * * Each plugin can provide a configuration area. Applications using grits @@ -114,11 +114,11 @@ const gchar *gis_plugin_get_description(GisPlugin *plugin) * * Returns: a configuration widget for the plugin */ -GtkWidget *gis_plugin_get_config(GisPlugin *plugin) +GtkWidget *grits_plugin_get_config(GritsPlugin *plugin) { - if (!GIS_IS_PLUGIN(plugin)) + if (!GRITS_IS_PLUGIN(plugin)) return NULL; - GisPluginInterface *iface = GIS_PLUGIN_GET_INTERFACE(plugin); + GritsPluginInterface *iface = GRITS_PLUGIN_GET_INTERFACE(plugin); return iface->get_config ? iface->get_config(plugin) : NULL; } @@ -128,23 +128,23 @@ GtkWidget *gis_plugin_get_config(GisPlugin *plugin) ***************/ typedef struct { gchar *name; - GisPlugin *plugin; -} GisPluginStore; + GritsPlugin *plugin; +} GritsPluginStore; /** - * gis_plugins_new: + * grits_plugins_new: * @dir: the directory to search for plugins in - * @prefs: a #GisPrefs to save the state of plugins, or NULL + * @prefs: a #GritsPrefs to save the state of plugins, or NULL * * Create a new plugin source. If @prefs is not %NULL, the state of the plugins * will be saved when they are either enabled or disabled. * * Returns: the new plugin source */ -GisPlugins *gis_plugins_new(const gchar *dir, GisPrefs *prefs) +GritsPlugins *grits_plugins_new(const gchar *dir, GritsPrefs *prefs) { - g_debug("GisPlugins: new - dir=%s", dir); - GisPlugins *plugins = g_new0(GisPlugins, 1); + g_debug("GritsPlugins: new - dir=%s", dir); + GritsPlugins *plugins = g_new0(GritsPlugins, 1); plugins->prefs = prefs; if (dir) plugins->dir = g_strdup(dir); @@ -152,17 +152,17 @@ GisPlugins *gis_plugins_new(const gchar *dir, GisPrefs *prefs) } /** - * gis_plugins_free: - * @plugins: the #GisPlugins to free + * grits_plugins_free: + * @plugins: the #GritsPlugins to free * * Free data used by a plugin source */ -void gis_plugins_free(GisPlugins *plugins) +void grits_plugins_free(GritsPlugins *plugins) { - g_debug("GisPlugins: free"); + g_debug("GritsPlugins: free"); for (GList *cur = plugins->plugins; cur; cur = cur->next) { - GisPluginStore *store = cur->data; - g_debug("GisPlugin: freeing %s refs=%d->%d", store->name, + GritsPluginStore *store = cur->data; + g_debug("GritsPlugin: freeing %s refs=%d->%d", store->name, G_OBJECT(store->plugin)->ref_count, G_OBJECT(store->plugin)->ref_count-1); g_object_unref(store->plugin); @@ -176,7 +176,7 @@ void gis_plugins_free(GisPlugins *plugins) } /** - * gis_plugins_available: + * grits_plugins_available: * @plugins: the plugin source * * Search the plugin directory for shared objects which can be loaded as @@ -184,9 +184,9 @@ void gis_plugins_free(GisPlugins *plugins) * * Returns: the list of available plugins */ -GList *gis_plugins_available(GisPlugins *plugins) +GList *grits_plugins_available(GritsPlugins *plugins) { - g_debug("GisPlugins: available"); + g_debug("GritsPlugins: available"); GList *list = NULL; gchar *dirs[] = {plugins->dir, PLUGINSDIR}; g_debug("pluginsdir=%s", PLUGINSDIR); @@ -218,31 +218,31 @@ GList *gis_plugins_available(GisPlugins *plugins) } /** - * gis_plugins_load: + * grits_plugins_load: * @plugins: the plugins source * @name: the name of the plugin to load - * @viewer: a #GisViewer to pass to the plugins constructor - * @prefs: a #GisPrefs to pass to the plugins constructor + * @viewer: a #GritsViewer to pass to the plugins constructor + * @prefs: a #GritsPrefs to pass to the plugins constructor * * @name should be the name of the shared object without the file extension. - * This is the same as what is returned by gis_plugins_available(). + * This is the same as what is returned by grits_plugins_available(). * - * When loading plugins, the @prefs argument is used, not the #GisPrefs stored + * When loading plugins, the @prefs argument is used, not the #GritsPrefs stored * in @plugins. * * Returns: the new plugin */ -GisPlugin *gis_plugins_load(GisPlugins *plugins, const char *name, - GisViewer *viewer, GisPrefs *prefs) +GritsPlugin *grits_plugins_load(GritsPlugins *plugins, const char *name, + GritsViewer *viewer, GritsPrefs *prefs) { - g_debug("GisPlugins: load %s", name); + g_debug("GritsPlugins: load %s", name); gchar *path = g_strdup_printf("%s/%s.%s", plugins->dir, name, G_MODULE_SUFFIX); - g_debug("GisPlugins: load - trying %s", path); + g_debug("GritsPlugins: load - trying %s", path); if (!g_file_test(path, G_FILE_TEST_EXISTS)) { g_free(path); path = g_strdup_printf("%s/%s.%s", PLUGINSDIR, name, G_MODULE_SUFFIX); } - g_debug("GisPlugins: load - trying %s", path); + g_debug("GritsPlugins: load - trying %s", path); if (!g_file_test(path, G_FILE_TEST_EXISTS)) { g_warning("Module %s not found", name); g_free(path); @@ -256,7 +256,7 @@ GisPlugin *gis_plugins_load(GisPlugins *plugins, const char *name, } gpointer constructor_ptr; // GCC 4.1 fix? - gchar *constructor_str = g_strconcat("gis_plugin_", name, "_new", NULL); + gchar *constructor_str = g_strconcat("grits_plugin_", name, "_new", NULL); if (!g_module_symbol(module, constructor_str, &constructor_ptr)) { g_warning("Unable to load symbol %s from %s: %s", constructor_str, name, g_module_error()); @@ -265,9 +265,9 @@ GisPlugin *gis_plugins_load(GisPlugins *plugins, const char *name, return NULL; } g_free(constructor_str); - GisPluginConstructor constructor = constructor_ptr; + GritsPluginConstructor constructor = constructor_ptr; - GisPluginStore *store = g_new0(GisPluginStore, 1); + GritsPluginStore *store = g_new0(GritsPluginStore, 1); store->name = g_strdup(name); store->plugin = constructor(viewer, prefs); plugins->plugins = g_list_prepend(plugins->plugins, store); @@ -275,47 +275,47 @@ GisPlugin *gis_plugins_load(GisPlugins *plugins, const char *name, } /** - * gis_plugins_enable: + * grits_plugins_enable: * @plugins: the plugins source * @name: the name of the plugin to load - * @viewer: a #GisViewer to pass to the plugins constructor - * @prefs: a #GisPrefs to pass to the plugins constructor + * @viewer: a #GritsViewer to pass to the plugins constructor + * @prefs: a #GritsPrefs to pass to the plugins constructor * - * Load a plugin and save it's loaded/unloaded state in the #GisPrefs stored in + * Load a plugin and save it's loaded/unloaded state in the #GritsPrefs stored in * #plugins. * - * See also: gis_plugins_load() + * See also: grits_plugins_load() * * Returns: the new plugin */ -GisPlugin *gis_plugins_enable(GisPlugins *plugins, const char *name, - GisViewer *viewer, GisPrefs *prefs) +GritsPlugin *grits_plugins_enable(GritsPlugins *plugins, const char *name, + GritsViewer *viewer, GritsPrefs *prefs) { - GisPlugin *plugin = gis_plugins_load(plugins, name, viewer, prefs); - gis_prefs_set_boolean_v(plugins->prefs, "plugins", name, TRUE); + GritsPlugin *plugin = grits_plugins_load(plugins, name, viewer, prefs); + grits_prefs_set_boolean_v(plugins->prefs, "plugins", name, TRUE); return plugin; } /** - * gis_plugins_load_enabled: + * grits_plugins_load_enabled: * @plugins: the plugins source - * @viewer: a #GisViewer to pass to the plugins constructor - * @prefs: a #GisPrefs to pass to the plugins constructor + * @viewer: a #GritsViewer to pass to the plugins constructor + * @prefs: a #GritsPrefs to pass to the plugins constructor * * Load all enabled which have previously been enabled. * - * See also: gis_plugins_load() + * See also: grits_plugins_load() * * Returns: a list of all loaded plugins */ -GList *gis_plugins_load_enabled(GisPlugins *plugins, - GisViewer *viewer, GisPrefs *prefs) +GList *grits_plugins_load_enabled(GritsPlugins *plugins, + GritsViewer *viewer, GritsPrefs *prefs) { GList *loaded = NULL; - for (GList *cur = gis_plugins_available(plugins); cur; cur = cur->next) { + for (GList *cur = grits_plugins_available(plugins); cur; cur = cur->next) { gchar *name = cur->data; - if (gis_prefs_get_boolean_v(plugins->prefs, "plugins", name, NULL)) { - GisPlugin *plugin = gis_plugins_load(plugins, name, viewer, prefs); + if (grits_prefs_get_boolean_v(plugins->prefs, "plugins", name, NULL)) { + GritsPlugin *plugin = grits_plugins_load(plugins, name, viewer, prefs); loaded = g_list_prepend(loaded, plugin); } } @@ -323,7 +323,7 @@ GList *gis_plugins_load_enabled(GisPlugins *plugins, } /** - * gis_plugins_unload: + * grits_plugins_unload: * @plugins: the plugins source * @name: the name of the plugin to unload * @@ -331,11 +331,11 @@ GList *gis_plugins_load_enabled(GisPlugins *plugins, * * Returns: %FALSE */ -gboolean gis_plugins_unload(GisPlugins *plugins, const char *name) +gboolean grits_plugins_unload(GritsPlugins *plugins, const char *name) { - g_debug("GisPlugins: unload %s", name); + g_debug("GritsPlugins: unload %s", name); for (GList *cur = plugins->plugins; cur; cur = cur->next) { - GisPluginStore *store = cur->data; + GritsPluginStore *store = cur->data; if (g_str_equal(store->name, name)) { g_object_unref(store->plugin); g_free(store->name); @@ -347,41 +347,41 @@ gboolean gis_plugins_unload(GisPlugins *plugins, const char *name) } /** - * gis_plugins_disable: + * grits_plugins_disable: * @plugins: the plugins source * @name: the name of the plugin to unload * - * Unload a plugin and save it's loaded/unloaded state in the #GisPrefs stored + * Unload a plugin and save it's loaded/unloaded state in the #GritsPrefs stored * in #plugins. * - * See also: gis_plugins_unload() + * See also: grits_plugins_unload() * * Returns: %FALSE */ -gboolean gis_plugins_disable(GisPlugins *plugins, const char *name) +gboolean grits_plugins_disable(GritsPlugins *plugins, const char *name) { - gis_prefs_set_boolean_v(plugins->prefs, "plugins", name, FALSE); - gis_plugins_unload(plugins, name); + grits_prefs_set_boolean_v(plugins->prefs, "plugins", name, FALSE); + grits_plugins_unload(plugins, name); return FALSE; } /** - * gis_plugins_foreach: + * grits_plugins_foreach: * @plugins: the plugins source * @callback: a function to call on each plugin * @user_data: user data to pass to the function * * Iterate over all plugins loaded by the plugins source */ -void gis_plugins_foreach(GisPlugins *plugins, GCallback _callback, gpointer user_data) +void grits_plugins_foreach(GritsPlugins *plugins, GCallback _callback, gpointer user_data) { - g_debug("GisPlugins: foreach"); + g_debug("GritsPlugins: foreach"); if (plugins == NULL) return; - typedef void (*CBFunc)(GisPlugin *, const gchar *, gpointer); + typedef void (*CBFunc)(GritsPlugin *, const gchar *, gpointer); CBFunc callback = (CBFunc)_callback; for (GList *cur = plugins->plugins; cur; cur = cur->next) { - GisPluginStore *store = cur->data; + GritsPluginStore *store = cur->data; callback(store->plugin, store->name, user_data); } } diff --git a/src/grits-plugin.h b/src/grits-plugin.h index 41c6b97..780a16a 100644 --- a/src/grits-plugin.h +++ b/src/grits-plugin.h @@ -15,8 +15,8 @@ * along with this program. If not, see . */ -#ifndef __GIS_PLUGIN_H__ -#define __GIS_PLUGIN_H__ +#ifndef __GRITS_PLUGIN_H__ +#define __GRITS_PLUGIN_H__ #include #include @@ -24,15 +24,15 @@ /******************** * Plugin interface * ********************/ -#define GIS_TYPE_PLUGIN (gis_plugin_get_type()) -#define GIS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIS_TYPE_PLUGIN, GisPlugin)) -#define GIS_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIS_TYPE_PLUGIN)) -#define GIS_PLUGIN_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), GIS_TYPE_PLUGIN, GisPluginInterface)) +#define GRITS_TYPE_PLUGIN (grits_plugin_get_type()) +#define GRITS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GRITS_TYPE_PLUGIN, GritsPlugin)) +#define GRITS_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GRITS_TYPE_PLUGIN)) +#define GRITS_PLUGIN_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), GRITS_TYPE_PLUGIN, GritsPluginInterface)) -typedef struct _GisPlugin GisPlugin; -typedef struct _GisPluginInterface GisPluginInterface; +typedef struct _GritsPlugin GritsPlugin; +typedef struct _GritsPluginInterface GritsPluginInterface; -struct _GisPluginInterface +struct _GritsPluginInterface { GTypeInterface parent_iface; @@ -41,63 +41,63 @@ struct _GisPluginInterface const gchar *description; /* Virtual functions */ - GtkWidget *(*get_config)(GisPlugin *plugin); + GtkWidget *(*get_config)(GritsPlugin *plugin); }; -GType gis_plugin_get_type(); +GType grits_plugin_get_type(); /* Methods */ -const gchar *gis_plugin_get_name(GisPlugin *plugin); +const gchar *grits_plugin_get_name(GritsPlugin *plugin); -const gchar *gis_plugin_get_description(GisPlugin *plugin); +const gchar *grits_plugin_get_description(GritsPlugin *plugin); -GtkWidget *gis_plugin_get_config(GisPlugin *plugin); +GtkWidget *grits_plugin_get_config(GritsPlugin *plugin); /*************** * Plugins API * ***************/ -typedef struct _GisPlugins GisPlugins; +typedef struct _GritsPlugins GritsPlugins; #include "grits-viewer.h" #include "grits-prefs.h" /** - * GisPluginConstructor: + * GritsPluginConstructor: * @viewer: the viewer the plugin is associated with * @prefs: preferences the plugin can use for storing informtion * * Create a new instance of a plugin. Each plugin should supply a constructor named - * gis_plugin_NAME_new in it's shared object. + * grits_plugin_NAME_new in it's shared object. * * Returns: the new plugin */ -typedef GisPlugin *(*GisPluginConstructor)(GisViewer *viewer, GisPrefs *prefs); +typedef GritsPlugin *(*GritsPluginConstructor)(GritsViewer *viewer, GritsPrefs *prefs); -struct _GisPlugins { - gchar *dir; - GList *plugins; - GisPrefs *prefs; +struct _GritsPlugins { + gchar *dir; + GList *plugins; + GritsPrefs *prefs; }; -GisPlugins *gis_plugins_new(const gchar *dir, GisPrefs *prefs); +GritsPlugins *grits_plugins_new(const gchar *dir, GritsPrefs *prefs); -void gis_plugins_free(); +void grits_plugins_free(); -GList *gis_plugins_available(GisPlugins *plugins); +GList *grits_plugins_available(GritsPlugins *plugins); -GisPlugin *gis_plugins_load(GisPlugins *plugins, const char *name, - GisViewer *viewer, GisPrefs *prefs); +GritsPlugin *grits_plugins_load(GritsPlugins *plugins, const char *name, + GritsViewer *viewer, GritsPrefs *prefs); -GisPlugin *gis_plugins_enable(GisPlugins *plugins, const char *name, - GisViewer *viewer, GisPrefs *prefs); +GritsPlugin *grits_plugins_enable(GritsPlugins *plugins, const char *name, + GritsViewer *viewer, GritsPrefs *prefs); -GList *gis_plugins_load_enabled(GisPlugins *plugins, - GisViewer *viewer, GisPrefs *prefs); +GList *grits_plugins_load_enabled(GritsPlugins *plugins, + GritsViewer *viewer, GritsPrefs *prefs); -gboolean gis_plugins_disable(GisPlugins *plugins, const char *name); +gboolean grits_plugins_disable(GritsPlugins *plugins, const char *name); -gboolean gis_plugins_unload(GisPlugins *plugins, const char *name); +gboolean grits_plugins_unload(GritsPlugins *plugins, const char *name); -void gis_plugins_foreach(GisPlugins *plugins, GCallback callback, gpointer user_data); +void grits_plugins_foreach(GritsPlugins *plugins, GCallback callback, gpointer user_data); #endif diff --git a/src/grits-prefs.c b/src/grits-prefs.c index 4e1b064..80a1d49 100644 --- a/src/grits-prefs.c +++ b/src/grits-prefs.c @@ -16,13 +16,13 @@ */ /** - * SECTION:gis-prefs + * SECTION:grits-prefs * @short_description: Persistent preference handing * - * #GisPrefs is used to store and access preferences in grits. It is mostly a + * #GritsPrefs is used to store and access preferences in grits. It is mostly a * wrapper around a #GKeyFile. Preferences can be stored for the application * using grits, but may also be stored by grits itself. An example of this are - * whether grits is in online or offline mode. Many #GisPlugins also + * whether grits is in online or offline mode. Many #GritsPlugins also * store preferences. * * There are two variants of preference functions. The normal variant takes @@ -46,19 +46,19 @@ static guint signals[NUM_SIGNALS]; * Methods * ***********/ /** - * gis_prefs_new: + * grits_prefs_new: * @config: the path to the config file * @defaults: the path to the default config file * * Create a new preference object for the given @config. If the config does not * exist the @defaults file is loaded. * - * Returns: the new #GisPrefs + * Returns: the new #GritsPrefs */ -GisPrefs *gis_prefs_new(const gchar *config, const gchar *defaults) +GritsPrefs *grits_prefs_new(const gchar *config, const gchar *defaults) { - g_debug("GisPrefs: new - %s, %s", config, defaults); - GisPrefs *prefs = g_object_new(GIS_TYPE_PREFS, NULL); + g_debug("GritsPrefs: new - %s, %s", config, defaults); + GritsPrefs *prefs = g_object_new(GRITS_TYPE_PREFS, NULL); if (config) prefs->key_path = g_strdup(config); else @@ -68,13 +68,13 @@ GisPrefs *gis_prefs_new(const gchar *config, const gchar *defaults) g_key_file_load_from_file(prefs->key_file, prefs->key_path, G_KEY_FILE_KEEP_COMMENTS, &error); if (error && defaults) { - g_debug("GisPrefs: new - Trying defaults"); + g_debug("GritsPrefs: new - Trying defaults"); g_clear_error(&error); g_key_file_load_from_file(prefs->key_file, defaults, G_KEY_FILE_KEEP_COMMENTS, &error); } if (error) { - g_debug("GisPrefs: new - Trying GIS defaults"); + g_debug("GritsPrefs: new - Trying GRITS defaults"); g_clear_error(&error); gchar *tmp = g_build_filename(PKGDATADIR, "defaults.ini", NULL); g_key_file_load_from_file(prefs->key_file, tmp, @@ -82,36 +82,36 @@ GisPrefs *gis_prefs_new(const gchar *config, const gchar *defaults) g_free(tmp); } if (error) { - g_debug("GisPrefs: new - Unable to load key file `%s': %s", + g_debug("GritsPrefs: new - Unable to load key file `%s': %s", prefs->key_path, error->message); } - g_debug("GisPrefs: new - using %s", prefs->key_path); + g_debug("GritsPrefs: new - using %s", prefs->key_path); return prefs; } #define make_pref_type(name, c_type, g_type) \ -c_type gis_prefs_get_##name##_v(GisPrefs *prefs, \ +c_type grits_prefs_get_##name##_v(GritsPrefs *prefs, \ const gchar *group, const gchar *key, GError **_error) \ { \ GError *error = NULL; \ c_type value = g_key_file_get_##name(prefs->key_file, group, key, &error); \ if (error && error->code != G_KEY_FILE_ERROR_GROUP_NOT_FOUND && \ error->code != G_KEY_FILE_ERROR_KEY_NOT_FOUND) \ - g_warning("GisPrefs: get_"#name" - error getting key %s: %s\n", \ + g_warning("GritsPrefs: get_"#name" - error getting key %s: %s\n", \ key, error->message); \ if (error && _error) \ *_error = error; \ return value; \ } \ -c_type gis_prefs_get_##name(GisPrefs *prefs, const gchar *key, GError **error) \ +c_type grits_prefs_get_##name(GritsPrefs *prefs, const gchar *key, GError **error) \ { \ gchar **keys = g_strsplit(key, "/", 2); \ - c_type value = gis_prefs_get_##name##_v(prefs, keys[0], keys[1], error); \ + c_type value = grits_prefs_get_##name##_v(prefs, keys[0], keys[1], error); \ g_strfreev(keys); \ return value; \ } \ \ -void gis_prefs_set_##name##_v(GisPrefs *prefs, \ +void grits_prefs_set_##name##_v(GritsPrefs *prefs, \ const gchar *group, const gchar *key, const c_type value) \ { \ g_key_file_set_##name(prefs->key_file, group, key, value); \ @@ -120,10 +120,10 @@ void gis_prefs_set_##name##_v(GisPrefs *prefs, all, g_type, &value); \ g_free(all); \ } \ -void gis_prefs_set_##name(GisPrefs *prefs, const gchar *key, const c_type value) \ +void grits_prefs_set_##name(GritsPrefs *prefs, const gchar *key, const c_type value) \ { \ gchar **keys = g_strsplit(key, "/", 2); \ - gis_prefs_set_##name##_v(prefs, keys[0], keys[1], value); \ + grits_prefs_set_##name##_v(prefs, keys[0], keys[1], value); \ g_strfreev(keys); \ } \ @@ -136,16 +136,16 @@ make_pref_type(double, gdouble, G_TYPE_DOUBLE) /**************** * GObject code * ****************/ -G_DEFINE_TYPE(GisPrefs, gis_prefs, G_TYPE_OBJECT); -static void gis_prefs_init(GisPrefs *prefs) +G_DEFINE_TYPE(GritsPrefs, grits_prefs, G_TYPE_OBJECT); +static void grits_prefs_init(GritsPrefs *prefs) { - g_debug("GisPrefs: init"); + g_debug("GritsPrefs: init"); prefs->key_file = g_key_file_new(); } -static void gis_prefs_dispose(GObject *_prefs) +static void grits_prefs_dispose(GObject *_prefs) { - g_debug("GisPrefs: dispose"); - GisPrefs *prefs = GIS_PREFS(_prefs); + g_debug("GritsPrefs: dispose"); + GritsPrefs *prefs = GRITS_PREFS(_prefs); if (prefs->key_file) { gsize length; gchar *dir = g_path_get_dirname(prefs->key_path); @@ -158,16 +158,16 @@ static void gis_prefs_dispose(GObject *_prefs) g_free(data); prefs->key_file = NULL; } - G_OBJECT_CLASS(gis_prefs_parent_class)->dispose(_prefs); + G_OBJECT_CLASS(grits_prefs_parent_class)->dispose(_prefs); } -static void gis_prefs_class_init(GisPrefsClass *klass) +static void grits_prefs_class_init(GritsPrefsClass *klass) { - g_debug("GisPrefs: class_init"); + g_debug("GritsPrefs: class_init"); GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - gobject_class->dispose = gis_prefs_dispose; + gobject_class->dispose = grits_prefs_dispose; /** - * GisPrefs::pref-changed: + * GritsPrefs::pref-changed: * @prefs: the preference store. * @key: the key to the preference. * @type: the type of the preference that changed. diff --git a/src/grits-prefs.h b/src/grits-prefs.h index 9949568..b49c209 100644 --- a/src/grits-prefs.h +++ b/src/grits-prefs.h @@ -15,23 +15,23 @@ * along with this program. If not, see . */ -#ifndef __GIS_PREFS_H__ -#define __GIS_PREFS_H__ +#ifndef __GRITS_PREFS_H__ +#define __GRITS_PREFS_H__ #include /* Type macros */ -#define GIS_TYPE_PREFS (gis_prefs_get_type()) -#define GIS_PREFS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GIS_TYPE_PREFS, GisPrefs)) -#define GIS_IS_PREFS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GIS_TYPE_PREFS)) -#define GIS_PREFS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIS_TYPE_PREFS, GisPrefsClass)) -#define GIS_IS_PREFS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIS_TYPE_PREFS)) -#define GIS_PREFS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIS_TYPE_PREFS, GisPrefsClass)) +#define GRITS_TYPE_PREFS (grits_prefs_get_type()) +#define GRITS_PREFS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GRITS_TYPE_PREFS, GritsPrefs)) +#define GRITS_IS_PREFS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GRITS_TYPE_PREFS)) +#define GRITS_PREFS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRITS_TYPE_PREFS, GritsPrefsClass)) +#define GRITS_IS_PREFS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRITS_TYPE_PREFS)) +#define GRITS_PREFS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GRITS_TYPE_PREFS, GritsPrefsClass)) -typedef struct _GisPrefs GisPrefs; -typedef struct _GisPrefsClass GisPrefsClass; +typedef struct _GritsPrefs GritsPrefs; +typedef struct _GritsPrefsClass GritsPrefsClass; -struct _GisPrefs { +struct _GritsPrefs { GObject parent_instance; /* instance members */ @@ -39,34 +39,34 @@ struct _GisPrefs { GKeyFile *key_file; }; -struct _GisPrefsClass { +struct _GritsPrefsClass { GObjectClass parent_class; /* class members */ }; -GType gis_prefs_get_type(void); +GType grits_prefs_get_type(void); /* Methods */ -GisPrefs *gis_prefs_new(const gchar *config, const gchar *defaults); +GritsPrefs *grits_prefs_new(const gchar *config, const gchar *defaults); -gchar *gis_prefs_get_string (GisPrefs *prefs, const gchar *key, GError **error); -gboolean gis_prefs_get_boolean (GisPrefs *prefs, const gchar *key, GError **error); -gint gis_prefs_get_integer (GisPrefs *prefs, const gchar *key, GError **error); -gdouble gis_prefs_get_double (GisPrefs *prefs, const gchar *key, GError **error); +gchar *grits_prefs_get_string (GritsPrefs *prefs, const gchar *key, GError **error); +gboolean grits_prefs_get_boolean (GritsPrefs *prefs, const gchar *key, GError **error); +gint grits_prefs_get_integer (GritsPrefs *prefs, const gchar *key, GError **error); +gdouble grits_prefs_get_double (GritsPrefs *prefs, const gchar *key, GError **error); -gchar *gis_prefs_get_string_v (GisPrefs *prefs, const gchar *group, const gchar *key, GError **error); -gboolean gis_prefs_get_boolean_v(GisPrefs *prefs, const gchar *group, const gchar *key, GError **error); -gint gis_prefs_get_integer_v(GisPrefs *prefs, const gchar *group, const gchar *key, GError **error); -gdouble gis_prefs_get_double_v (GisPrefs *prefs, const gchar *group, const gchar *key, GError **error); +gchar *grits_prefs_get_string_v (GritsPrefs *prefs, const gchar *group, const gchar *key, GError **error); +gboolean grits_prefs_get_boolean_v(GritsPrefs *prefs, const gchar *group, const gchar *key, GError **error); +gint grits_prefs_get_integer_v(GritsPrefs *prefs, const gchar *group, const gchar *key, GError **error); +gdouble grits_prefs_get_double_v (GritsPrefs *prefs, const gchar *group, const gchar *key, GError **error); -void gis_prefs_set_string (GisPrefs *prefs, const gchar *key, const gchar *string); -void gis_prefs_set_boolean (GisPrefs *prefs, const gchar *key, gboolean value); -void gis_prefs_set_integer (GisPrefs *prefs, const gchar *key, gint value); -void gis_prefs_set_double (GisPrefs *prefs, const gchar *key, gdouble value); +void grits_prefs_set_string (GritsPrefs *prefs, const gchar *key, const gchar *string); +void grits_prefs_set_boolean (GritsPrefs *prefs, const gchar *key, gboolean value); +void grits_prefs_set_integer (GritsPrefs *prefs, const gchar *key, gint value); +void grits_prefs_set_double (GritsPrefs *prefs, const gchar *key, gdouble value); -void gis_prefs_set_string_v (GisPrefs *prefs, const gchar *group, const gchar *key, const gchar *string); -void gis_prefs_set_boolean_v(GisPrefs *prefs, const gchar *group, const gchar *key, gboolean value); -void gis_prefs_set_integer_v(GisPrefs *prefs, const gchar *group, const gchar *key, gint value); -void gis_prefs_set_double_v (GisPrefs *prefs, const gchar *group, const gchar *key, gdouble value); +void grits_prefs_set_string_v (GritsPrefs *prefs, const gchar *group, const gchar *key, const gchar *string); +void grits_prefs_set_boolean_v(GritsPrefs *prefs, const gchar *group, const gchar *key, gboolean value); +void grits_prefs_set_integer_v(GritsPrefs *prefs, const gchar *group, const gchar *key, gint value); +void grits_prefs_set_double_v (GritsPrefs *prefs, const gchar *group, const gchar *key, gdouble value); #endif diff --git a/src/grits-test.c b/src/grits-test.c index 43d014b..1890f81 100644 --- a/src/grits-test.c +++ b/src/grits-test.c @@ -22,16 +22,16 @@ #include "grits.h" -GisPrefs *prefs = NULL; -GisPlugins *plugins = NULL; -GisViewer *viewer = NULL; +GritsPrefs *prefs = NULL; +GritsPlugins *plugins = NULL; +GritsViewer *viewer = NULL; /************* * Callbacks * *************/ -static gboolean gis_shutdown(GtkWidget *window) +static gboolean grits_shutdown(GtkWidget *window) { - gis_plugins_free(plugins); + grits_plugins_free(plugins); g_object_unref(prefs); gtk_widget_destroy(window); @@ -43,20 +43,20 @@ static gboolean gis_shutdown(GtkWidget *window) } static gboolean on_delete(GtkWidget *widget, GdkEvent *event, gpointer data) { - return gis_shutdown(widget); + return grits_shutdown(widget); } static gboolean on_key_press(GtkWidget *widget, GdkEventKey *event, gpointer window) { if (event->keyval == GDK_q) - return gis_shutdown(widget); + return grits_shutdown(widget); return FALSE; } -static void load_plugin(GisPlugins *plugins, gchar *name, - GisViewer *viewer, GisPrefs *prefs, GtkNotebook *notebook) +static void load_plugin(GritsPlugins *plugins, gchar *name, + GritsViewer *viewer, GritsPrefs *prefs, GtkNotebook *notebook) { - GisPlugin *plugin = gis_plugins_load(plugins, name, viewer, prefs); - GtkWidget *config = gis_plugin_get_config(plugin); + GritsPlugin *plugin = grits_plugins_load(plugins, name, viewer, prefs); + GtkWidget *config = grits_plugin_get_config(plugin); gtk_notebook_append_page(notebook, config, gtk_label_new(name)); } @@ -70,9 +70,9 @@ int main(int argc, char **argv) gtk_init(&argc, &argv); gtk_gl_init(&argc, &argv); - prefs = gis_prefs_new(NULL, NULL); - plugins = gis_plugins_new(g_getenv("GIS_PLUGIN_PATH"), prefs); - viewer = gis_opengl_new(plugins, prefs); + prefs = grits_prefs_new(NULL, NULL); + plugins = grits_plugins_new(g_getenv("GRITS_PLUGIN_PATH"), prefs); + viewer = grits_opengl_new(plugins, prefs); gdk_threads_enter(); GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); @@ -87,7 +87,7 @@ int main(int argc, char **argv) gtk_widget_show_all(window); /* Configurable stuff */ - gis_viewer_set_offline(viewer, TRUE); + grits_viewer_set_offline(viewer, TRUE); load_plugin(plugins, "elev", viewer, prefs, GTK_NOTEBOOK(config)); load_plugin(plugins, "env", viewer, prefs, GTK_NOTEBOOK(config)); //load_plugin(plugins, "map", viewer, prefs, GTK_NOTEBOOK(config)); diff --git a/src/grits-util.c b/src/grits-util.c index 634f132..a792014 100644 --- a/src/grits-util.c +++ b/src/grits-util.c @@ -16,7 +16,7 @@ */ /** - * SECTION:gis-util + * SECTION:grits-util * @short_description: Geographic utilities * * Miscellaneous utility functions, these deal mostly with coordinate @@ -74,10 +74,10 @@ #include "grits-util.h" /************ - * GisPoint * + * GritsPoint * ************/ /** - * gis_point_set_lle: + * grits_point_set_lle: * @point: the point to modify * @lat: the new latitude * @lon: the new longitude @@ -85,7 +85,7 @@ * * Set the latitude, longitude, and elevation for a point. */ -void gis_point_set_lle(GisPoint *point, gdouble lat, gdouble lon, gdouble elev) +void grits_point_set_lle(GritsPoint *point, gdouble lat, gdouble lon, gdouble elev) { point->lat = lat; point->lon = lon; @@ -93,11 +93,11 @@ void gis_point_set_lle(GisPoint *point, gdouble lat, gdouble lon, gdouble elev) } -/************* - * GisBounds * - *************/ +/*************** + * GritsBounds * + ***************/ /** - * gis_bounds_set_bounds: + * grits_bounds_set_bounds: * @n: the north edge * @s: the south edge * @e: the east edge @@ -105,7 +105,7 @@ void gis_point_set_lle(GisPoint *point, gdouble lat, gdouble lon, gdouble elev) * * Set the north, south, east, and west edges of the bounding box */ -void gis_bounds_set_bounds(GisBounds *bounds, +void grits_bounds_set_bounds(GritsBounds *bounds, gdouble n, gdouble s, gdouble e, gdouble w) { bounds->n = n; diff --git a/src/grits-util.h b/src/grits-util.h index ccc7558..0771541 100644 --- a/src/grits-util.h +++ b/src/grits-util.h @@ -15,8 +15,8 @@ * along with this program. If not, see . */ -#ifndef __GIS_UTIL_H__ -#define __GIS_UTIL_H__ +#ifndef __GRITS_UTIL_H__ +#define __GRITS_UTIL_H__ #include @@ -150,22 +150,22 @@ * Datatypes * *************/ -/* GisPoint */ -typedef struct _GisPoint GisPoint; -struct _GisPoint { +/* GritsPoint */ +typedef struct _GritsPoint GritsPoint; +struct _GritsPoint { gdouble lat, lon, elev; }; -void gis_point_set_lle(GisPoint *point, +void grits_point_set_lle(GritsPoint *point, gdouble lat, gdouble lon, gdouble elev); -/* GisBounds */ -typedef struct _GisBounds GisBounds; -struct _GisBounds { +/* GritsBounds */ +typedef struct _GritsBounds GritsBounds; +struct _GritsBounds { gdouble n, s, e, w; }; -void gis_bounds_set_bounds(GisBounds *bounds, +void grits_bounds_set_bounds(GritsBounds *bounds, gdouble n, gdouble s, gdouble e, gdouble w); @@ -175,7 +175,7 @@ void gis_bounds_set_bounds(GisBounds *bounds, /** * FOV_DIST: * - * Used by GisOpenGL to set up the drawing window + * Used by GritsOpenGL to set up the drawing window */ #define FOV_DIST 2000.0 diff --git a/src/grits-viewer.c b/src/grits-viewer.c index 767b919..3a7827e 100644 --- a/src/grits-viewer.c +++ b/src/grits-viewer.c @@ -16,10 +16,10 @@ */ /** - * SECTION:gis-viewer + * SECTION:grits-viewer * @short_description: Virtual globe base class * - * #GisViewer is the base class for the virtual globe widget. It handles + * #GritsViewer is the base class for the virtual globe widget. It handles * everything not directly related to drawing the globe. Plugins and * applications using the viewer should normally talk to the viewer and not care * how it is implemented. @@ -52,7 +52,7 @@ static guint signals[NUM_SIGNALS]; * Helpers * ***********/ /* Misc helpers */ -static void _gis_viewer_fix_location(GisViewer *viewer) +static void _grits_viewer_fix_location(GritsViewer *viewer) { while (viewer->location[0] < -90) viewer->location[0] += 180; while (viewer->location[0] > 90) viewer->location[0] -= 180; @@ -62,30 +62,30 @@ static void _gis_viewer_fix_location(GisViewer *viewer) } /* Signal helpers */ -static void _gis_viewer_emit_location_changed(GisViewer *viewer) +static void _grits_viewer_emit_location_changed(GritsViewer *viewer) { g_signal_emit(viewer, signals[SIG_LOCATION_CHANGED], 0, viewer->location[0], viewer->location[1], viewer->location[2]); } -static void _gis_viewer_emit_rotation_changed(GisViewer *viewer) +static void _grits_viewer_emit_rotation_changed(GritsViewer *viewer) { g_signal_emit(viewer, signals[SIG_ROTATION_CHANGED], 0, viewer->rotation[0], viewer->rotation[1], viewer->rotation[2]); } -static void _gis_viewer_emit_time_changed(GisViewer *viewer) +static void _grits_viewer_emit_time_changed(GritsViewer *viewer) { g_signal_emit(viewer, signals[SIG_TIME_CHANGED], 0, viewer->time); } -static void _gis_viewer_emit_refresh(GisViewer *viewer) +static void _grits_viewer_emit_refresh(GritsViewer *viewer) { g_signal_emit(viewer, signals[SIG_REFRESH], 0); } -static void _gis_viewer_emit_offline(GisViewer *viewer) +static void _grits_viewer_emit_offline(GritsViewer *viewer) { g_signal_emit(viewer, signals[SIG_OFFLINE], 0, viewer->offline); @@ -94,92 +94,92 @@ static void _gis_viewer_emit_offline(GisViewer *viewer) /************* * Callbacks * *************/ -static gboolean on_key_press(GisViewer *viewer, GdkEventKey *event, gpointer _) +static gboolean on_key_press(GritsViewer *viewer, GdkEventKey *event, gpointer _) { - g_debug("GisViewer: on_key_press - key=%x, state=%x, plus=%x", + g_debug("GritsViewer: on_key_press - key=%x, state=%x, plus=%x", event->keyval, event->state, GDK_plus); double lat, lon, elev, pan; - gis_viewer_get_location(viewer, &lat, &lon, &elev); + grits_viewer_get_location(viewer, &lat, &lon, &elev); pan = MIN(elev/(EARTH_R/2), 30); switch (event->keyval) { - case GDK_Left: case GDK_h: gis_viewer_pan(viewer, 0, -pan, 0); break; - case GDK_Down: case GDK_j: gis_viewer_pan(viewer, -pan, 0, 0); break; - case GDK_Up: case GDK_k: gis_viewer_pan(viewer, pan, 0, 0); break; - case GDK_Right: case GDK_l: gis_viewer_pan(viewer, 0, pan, 0); break; - case GDK_minus: case GDK_o: gis_viewer_zoom(viewer, 10./9); break; - case GDK_plus: case GDK_i: gis_viewer_zoom(viewer, 9./10); break; - case GDK_H: gis_viewer_rotate(viewer, 0, 0, -2); break; - case GDK_J: gis_viewer_rotate(viewer, 2, 0, 0); break; - case GDK_K: gis_viewer_rotate(viewer, -2, 0, 0); break; - case GDK_L: gis_viewer_rotate(viewer, 0, 0, 2); break; + case GDK_Left: case GDK_h: grits_viewer_pan(viewer, 0, -pan, 0); break; + case GDK_Down: case GDK_j: grits_viewer_pan(viewer, -pan, 0, 0); break; + case GDK_Up: case GDK_k: grits_viewer_pan(viewer, pan, 0, 0); break; + case GDK_Right: case GDK_l: grits_viewer_pan(viewer, 0, pan, 0); break; + case GDK_minus: case GDK_o: grits_viewer_zoom(viewer, 10./9); break; + case GDK_plus: case GDK_i: grits_viewer_zoom(viewer, 9./10); break; + case GDK_H: grits_viewer_rotate(viewer, 0, 0, -2); break; + case GDK_J: grits_viewer_rotate(viewer, 2, 0, 0); break; + case GDK_K: grits_viewer_rotate(viewer, -2, 0, 0); break; + case GDK_L: grits_viewer_rotate(viewer, 0, 0, 2); break; } return FALSE; } -static gboolean on_scroll(GisViewer *viewer, GdkEventScroll *event, gpointer _) +static gboolean on_scroll(GritsViewer *viewer, GdkEventScroll *event, gpointer _) { switch (event->direction) { - case GDK_SCROLL_DOWN: gis_viewer_zoom(viewer, 10./9); break; - case GDK_SCROLL_UP: gis_viewer_zoom(viewer, 9./10); break; + case GDK_SCROLL_DOWN: grits_viewer_zoom(viewer, 10./9); break; + case GDK_SCROLL_UP: grits_viewer_zoom(viewer, 9./10); break; default: break; } return FALSE; } enum { - GIS_DRAG_NONE, - GIS_DRAG_PAN, - GIS_DRAG_ZOOM, - GIS_DRAG_TILT, + GRITS_DRAG_NONE, + GRITS_DRAG_PAN, + GRITS_DRAG_ZOOM, + GRITS_DRAG_TILT, }; -static gboolean on_button_press(GisViewer *viewer, GdkEventButton *event, gpointer _) +static gboolean on_button_press(GritsViewer *viewer, GdkEventButton *event, gpointer _) { - g_debug("GisViewer: on_button_press - %d", event->button); + g_debug("GritsViewer: on_button_press - %d", event->button); gtk_widget_grab_focus(GTK_WIDGET(viewer)); switch (event->button) { - case 1: viewer->drag_mode = GIS_DRAG_PAN; break; - case 2: viewer->drag_mode = GIS_DRAG_ZOOM; break; - case 3: viewer->drag_mode = GIS_DRAG_TILT; break; - default: viewer->drag_mode = GIS_DRAG_NONE; break; + case 1: viewer->drag_mode = GRITS_DRAG_PAN; break; + case 2: viewer->drag_mode = GRITS_DRAG_ZOOM; break; + case 3: viewer->drag_mode = GRITS_DRAG_TILT; break; + default: viewer->drag_mode = GRITS_DRAG_NONE; break; } viewer->drag_x = event->x; viewer->drag_y = event->y; return FALSE; } -static gboolean on_button_release(GisViewer *viewer, GdkEventButton *event, gpointer _) +static gboolean on_button_release(GritsViewer *viewer, GdkEventButton *event, gpointer _) { - g_debug("GisViewer: on_button_release"); - viewer->drag_mode = GIS_DRAG_NONE; + g_debug("GritsViewer: on_button_release"); + viewer->drag_mode = GRITS_DRAG_NONE; return FALSE; } -static gboolean on_motion_notify(GisViewer *viewer, GdkEventMotion *event, gpointer _) +static gboolean on_motion_notify(GritsViewer *viewer, GdkEventMotion *event, gpointer _) { gdouble x = viewer->drag_x - event->x; gdouble y = viewer->drag_y - event->y; gdouble lat, lon, elev, scale; - gis_viewer_get_location(GIS_VIEWER(viewer), &lat, &lon, &elev); + grits_viewer_get_location(GRITS_VIEWER(viewer), &lat, &lon, &elev); scale = elev/EARTH_R/15; switch (viewer->drag_mode) { - case GIS_DRAG_PAN: gis_viewer_pan(viewer, -y*scale, x*scale, 0); break; - case GIS_DRAG_ZOOM: gis_viewer_zoom(viewer, pow(2, -y/500)); break; - case GIS_DRAG_TILT: gis_viewer_rotate(viewer, y/10, 0, x/10); break; + case GRITS_DRAG_PAN: grits_viewer_pan(viewer, -y*scale, x*scale, 0); break; + case GRITS_DRAG_ZOOM: grits_viewer_zoom(viewer, pow(2, -y/500)); break; + case GRITS_DRAG_TILT: grits_viewer_rotate(viewer, y/10, 0, x/10); break; } viewer->drag_x = event->x; viewer->drag_y = event->y; return FALSE; } -static void on_view_changed(GisViewer *viewer, +static void on_view_changed(GritsViewer *viewer, gdouble _1, gdouble _2, gdouble _3) { gtk_widget_queue_draw(GTK_WIDGET(viewer)); } -static void on_realize(GisViewer *viewer) +static void on_realize(GritsViewer *viewer) { GdkCursor *cursor = gdk_cursor_new(GDK_FLEUR); GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(viewer)); @@ -190,53 +190,53 @@ static void on_realize(GisViewer *viewer) * Methods * ***********/ /** - * gis_viewer_setup: + * grits_viewer_setup: * @viewer: the viewer * @plugins: a plugins store * @prefs: a prefs store * - * This should be called by objects which implement GisViewer somewhere in their + * This should be called by objects which implement GritsViewer somewhere in their * constructor. */ -void gis_viewer_setup(GisViewer *viewer, GisPlugins *plugins, GisPrefs *prefs) +void grits_viewer_setup(GritsViewer *viewer, GritsPlugins *plugins, GritsPrefs *prefs) { viewer->plugins = plugins; viewer->prefs = prefs; - viewer->offline = gis_prefs_get_boolean(prefs, "gis/offline", NULL); + viewer->offline = grits_prefs_get_boolean(prefs, "grits/offline", NULL); } /** - * gis_viewer_set_time: + * grits_viewer_set_time: * @viewer: the viewer * @time: the time to set the view to * * Set the current time for the view */ -void gis_viewer_set_time(GisViewer *viewer, time_t time) +void grits_viewer_set_time(GritsViewer *viewer, time_t time) { - g_assert(GIS_IS_VIEWER(viewer)); - g_debug("GisViewer: set_time - time=%ld", time); + g_assert(GRITS_IS_VIEWER(viewer)); + g_debug("GritsViewer: set_time - time=%ld", time); viewer->time = time; - _gis_viewer_emit_time_changed(viewer); + _grits_viewer_emit_time_changed(viewer); } /** - * gis_viewer_get_time: + * grits_viewer_get_time: * @viewer: the viewer * * Get the time that is being viewed * * Returns: the current time */ -time_t gis_viewer_get_time(GisViewer *viewer) +time_t grits_viewer_get_time(GritsViewer *viewer) { - g_assert(GIS_IS_VIEWER(viewer)); - g_debug("GisViewer: get_time"); + g_assert(GRITS_IS_VIEWER(viewer)); + g_debug("GritsViewer: get_time"); return viewer->time; } /** - * gis_viewer_set_location: + * grits_viewer_set_location: * @viewer: the viewer * @lat: the new latitude * @lon: the new longitude @@ -244,19 +244,19 @@ time_t gis_viewer_get_time(GisViewer *viewer) * * Set the location for the camera */ -void gis_viewer_set_location(GisViewer *viewer, gdouble lat, gdouble lon, gdouble elev) +void grits_viewer_set_location(GritsViewer *viewer, gdouble lat, gdouble lon, gdouble elev) { - g_assert(GIS_IS_VIEWER(viewer)); - g_debug("GisViewer: set_location"); + g_assert(GRITS_IS_VIEWER(viewer)); + g_debug("GritsViewer: set_location"); viewer->location[0] = lat; viewer->location[1] = lon; viewer->location[2] = elev; - _gis_viewer_fix_location(viewer); - _gis_viewer_emit_location_changed(viewer); + _grits_viewer_fix_location(viewer); + _grits_viewer_emit_location_changed(viewer); } /** - * gis_viewer_get_location: + * grits_viewer_get_location: * @viewer: the viewer * @lat: the location to store the latitude * @lon: the location to store the longitude @@ -264,17 +264,17 @@ void gis_viewer_set_location(GisViewer *viewer, gdouble lat, gdouble lon, gdoubl * * Get the location of the camera */ -void gis_viewer_get_location(GisViewer *viewer, gdouble *lat, gdouble *lon, gdouble *elev) +void grits_viewer_get_location(GritsViewer *viewer, gdouble *lat, gdouble *lon, gdouble *elev) { - g_assert(GIS_IS_VIEWER(viewer)); - //g_debug("GisViewer: get_location"); + g_assert(GRITS_IS_VIEWER(viewer)); + //g_debug("GritsViewer: get_location"); *lat = viewer->location[0]; *lon = viewer->location[1]; *elev = viewer->location[2]; } /** - * gis_viewer_pan: + * grits_viewer_pan: * @viewer: the viewer * @forward: distance to move forward in meters * @right: distance to move right in meters @@ -285,10 +285,10 @@ void gis_viewer_get_location(GisViewer *viewer, gdouble *lat, gdouble *lon, gdou * Bugs: the distances are not in meters * Bugs: panning does not move in strait lines */ -void gis_viewer_pan(GisViewer *viewer, gdouble forward, gdouble sideways, gdouble up) +void grits_viewer_pan(GritsViewer *viewer, gdouble forward, gdouble sideways, gdouble up) { - g_assert(GIS_IS_VIEWER(viewer)); - g_debug("GisViewer: pan - forward=%8.3f, sideways=%8.3f, up=%8.3f", + g_assert(GRITS_IS_VIEWER(viewer)); + g_debug("GritsViewer: pan - forward=%8.3f, sideways=%8.3f, up=%8.3f", forward, sideways, up); gdouble dist = sqrt(forward*forward + sideways*sideways); gdouble angle1 = deg2rad(viewer->rotation[2]); @@ -298,27 +298,27 @@ void gis_viewer_pan(GisViewer *viewer, gdouble forward, gdouble sideways, gdoubl viewer->location[0] += dist*cos(angle); viewer->location[1] += dist*sin(angle); viewer->location[2] += up; - _gis_viewer_fix_location(viewer); - _gis_viewer_emit_location_changed(viewer); + _grits_viewer_fix_location(viewer); + _grits_viewer_emit_location_changed(viewer); } /** - * gis_viewer_zoom: + * grits_viewer_zoom: * @viewer: the viewer * @scale: the scale to multiple the elevation by * * Multiple the elevation by a scale. */ -void gis_viewer_zoom(GisViewer *viewer, gdouble scale) +void grits_viewer_zoom(GritsViewer *viewer, gdouble scale) { - g_assert(GIS_IS_VIEWER(viewer)); - g_debug("GisViewer: zoom"); + g_assert(GRITS_IS_VIEWER(viewer)); + g_debug("GritsViewer: zoom"); viewer->location[2] *= scale; - _gis_viewer_emit_location_changed(viewer); + _grits_viewer_emit_location_changed(viewer); } /** - * gis_viewer_set_rotation: + * grits_viewer_set_rotation: * @viewer: the viewer * @x: rotation new around the x axes * @y: rotation new around the y axes @@ -326,18 +326,18 @@ void gis_viewer_zoom(GisViewer *viewer, gdouble scale) * * Set the rotations in degrees around the x, y, and z axes. */ -void gis_viewer_set_rotation(GisViewer *viewer, gdouble x, gdouble y, gdouble z) +void grits_viewer_set_rotation(GritsViewer *viewer, gdouble x, gdouble y, gdouble z) { - g_assert(GIS_IS_VIEWER(viewer)); - g_debug("GisViewer: set_rotation"); + g_assert(GRITS_IS_VIEWER(viewer)); + g_debug("GritsViewer: set_rotation"); viewer->rotation[0] = x; viewer->rotation[1] = y; viewer->rotation[2] = z; - _gis_viewer_emit_rotation_changed(viewer); + _grits_viewer_emit_rotation_changed(viewer); } /** - * gis_viewer_get_rotation: + * grits_viewer_get_rotation: * @viewer: the viewer * @x: rotation around the x axes * @y: rotation around the y axes @@ -345,17 +345,17 @@ void gis_viewer_set_rotation(GisViewer *viewer, gdouble x, gdouble y, gdouble z) * * Get the rotations in degrees around the x, y, and z axes. */ -void gis_viewer_get_rotation(GisViewer *viewer, gdouble *x, gdouble *y, gdouble *z) +void grits_viewer_get_rotation(GritsViewer *viewer, gdouble *x, gdouble *y, gdouble *z) { - g_assert(GIS_IS_VIEWER(viewer)); - g_debug("GisViewer: get_rotation"); + g_assert(GRITS_IS_VIEWER(viewer)); + g_debug("GritsViewer: get_rotation"); *x = viewer->rotation[0]; *y = viewer->rotation[1]; *z = viewer->rotation[2]; } /** - * gis_viewer_rotate: + * grits_viewer_rotate: * @viewer: the viewer * @x: rotation around the x axes * @y: rotation around the y axes @@ -363,58 +363,58 @@ void gis_viewer_get_rotation(GisViewer *viewer, gdouble *x, gdouble *y, gdouble * * Add to the rotation around the x, y, and z axes. */ -void gis_viewer_rotate(GisViewer *viewer, gdouble x, gdouble y, gdouble z) +void grits_viewer_rotate(GritsViewer *viewer, gdouble x, gdouble y, gdouble z) { - g_assert(GIS_IS_VIEWER(viewer)); - g_debug("GisViewer: rotate - x=%.0f, y=%.0f, z=%.0f", x, y, z); + g_assert(GRITS_IS_VIEWER(viewer)); + g_debug("GritsViewer: rotate - x=%.0f, y=%.0f, z=%.0f", x, y, z); viewer->rotation[0] += x; viewer->rotation[1] += y; viewer->rotation[2] += z; - _gis_viewer_emit_rotation_changed(viewer); + _grits_viewer_emit_rotation_changed(viewer); } /** - * gis_viewer_refresh: + * grits_viewer_refresh: * @viewer: the viewer * * Trigger the refresh signal. This will cause any remote data to be checked for * updates. */ -void gis_viewer_refresh(GisViewer *viewer) +void grits_viewer_refresh(GritsViewer *viewer) { - g_debug("GisViewer: refresh"); - _gis_viewer_emit_refresh(viewer); + g_debug("GritsViewer: refresh"); + _grits_viewer_emit_refresh(viewer); } /** - * gis_viewer_set_offline: + * grits_viewer_set_offline: * @viewer: the viewer * @offline: %TRUE to enter offline mode * * Set the offline mode. If @offline is %TRUE, only locally cached data will be * used. */ -void gis_viewer_set_offline(GisViewer *viewer, gboolean offline) +void grits_viewer_set_offline(GritsViewer *viewer, gboolean offline) { - g_assert(GIS_IS_VIEWER(viewer)); - g_debug("GisViewer: set_offline - %d", offline); - gis_prefs_set_boolean(viewer->prefs, "gis/offline", offline); + g_assert(GRITS_IS_VIEWER(viewer)); + g_debug("GritsViewer: set_offline - %d", offline); + grits_prefs_set_boolean(viewer->prefs, "grits/offline", offline); viewer->offline = offline; - _gis_viewer_emit_offline(viewer); + _grits_viewer_emit_offline(viewer); } /** - * gis_viewer_get_offline: + * grits_viewer_get_offline: * @viewer: the viewer * * Check if the viewer is in offline mode. * * Returns: %TRUE if the viewer is in offline mode. */ -gboolean gis_viewer_get_offline(GisViewer *viewer) +gboolean grits_viewer_get_offline(GritsViewer *viewer) { - g_assert(GIS_IS_VIEWER(viewer)); - g_debug("GisViewer: get_offline - %d", viewer->offline); + g_assert(GRITS_IS_VIEWER(viewer)); + g_debug("GritsViewer: get_offline - %d", viewer->offline); return viewer->offline; } @@ -422,7 +422,7 @@ gboolean gis_viewer_get_offline(GisViewer *viewer) * To be implemented by subclasses * ***********************************/ /** - * gis_viewer_center_position: + * grits_viewer_center_position: * @viewer: the viewer * @lat: the latitude * @lon: the longitude @@ -431,17 +431,17 @@ gboolean gis_viewer_get_offline(GisViewer *viewer) * Center the viewer on a point. This can be used before drawing operations to * center the items a particular location. */ -void gis_viewer_center_position(GisViewer *viewer, +void grits_viewer_center_position(GritsViewer *viewer, gdouble lat, gdouble lon, gdouble elev) { - GisViewerClass *klass = GIS_VIEWER_GET_CLASS(viewer); + GritsViewerClass *klass = GRITS_VIEWER_GET_CLASS(viewer); if (!klass->center_position) - g_warning("GisViewer: center_position - Unimplemented"); + g_warning("GritsViewer: center_position - Unimplemented"); klass->center_position(viewer, lat, lon, elev); } /** - * gis_viewer_project: + * grits_viewer_project: * @viewer: the viewer * @lat: the latitude * @lon: the latitude @@ -452,35 +452,35 @@ void gis_viewer_center_position(GisViewer *viewer, * * Project a latitude, longitude, elevation point to to x, y, and z coordinates * in screen space. Useful for drawing orthographic data over a particular point - * in space. E.g. #GisMarker. + * in space. E.g. #GritsMarker. */ -void gis_viewer_project(GisViewer *viewer, +void grits_viewer_project(GritsViewer *viewer, gdouble lat, gdouble lon, gdouble elev, gdouble *px, gdouble *py, gdouble *pz) { - GisViewerClass *klass = GIS_VIEWER_GET_CLASS(viewer); + GritsViewerClass *klass = GRITS_VIEWER_GET_CLASS(viewer); if (!klass->project) - g_warning("GisViewer: project - Unimplemented"); + g_warning("GritsViewer: project - Unimplemented"); klass->project(viewer, lat, lon, elev, px, py, pz); } /** - * gis_viewer_clear_height_func: + * grits_viewer_clear_height_func: * @viewer: the viewer * * Clears the height function for the entire viewer. Useful when an elevation * plugin is unloaded. */ -void gis_viewer_clear_height_func(GisViewer *viewer) +void grits_viewer_clear_height_func(GritsViewer *viewer) { - GisViewerClass *klass = GIS_VIEWER_GET_CLASS(viewer); + GritsViewerClass *klass = GRITS_VIEWER_GET_CLASS(viewer); if (!klass->clear_height_func) - g_warning("GisViewer: clear_height_func - Unimplemented"); + g_warning("GritsViewer: clear_height_func - Unimplemented"); klass->clear_height_func(viewer); } /** - * gis_viewer_set_height_func: + * grits_viewer_set_height_func: * @viewer: the viewer * @bounds: the area to set the height function for * @height_func: the height function @@ -489,18 +489,18 @@ void gis_viewer_clear_height_func(GisViewer *viewer) * * Set the height function to be used for a given part of the surface.. */ -void gis_viewer_set_height_func(GisViewer *viewer, GisBounds *bounds, - GisHeightFunc height_func, gpointer user_data, +void grits_viewer_set_height_func(GritsViewer *viewer, GritsBounds *bounds, + GritsHeightFunc height_func, gpointer user_data, gboolean update) { - GisViewerClass *klass = GIS_VIEWER_GET_CLASS(viewer); + GritsViewerClass *klass = GRITS_VIEWER_GET_CLASS(viewer); if (!klass->set_height_func) - g_warning("GisViewer: set_height_func - Unimplemented"); + g_warning("GritsViewer: set_height_func - Unimplemented"); klass->set_height_func(viewer, bounds, height_func, user_data, update); } /** - * gis_viewer_add: + * grits_viewer_add: * @viewer: the viewer * @object: the object to add * @level: the level to add the object to @@ -518,42 +518,42 @@ void gis_viewer_set_height_func(GisViewer *viewer, GisBounds *bounds, * The viewer steals the objects reference. Call g_object_ref if you plan on * holding a reference as well. * - * Returns: a handle to be pass to gis_viewer_remove() + * Returns: a handle to be pass to grits_viewer_remove() */ -gpointer gis_viewer_add(GisViewer *viewer, GisObject *object, +gpointer grits_viewer_add(GritsViewer *viewer, GritsObject *object, gint level, gboolean sort) { - GisViewerClass *klass = GIS_VIEWER_GET_CLASS(viewer); + GritsViewerClass *klass = GRITS_VIEWER_GET_CLASS(viewer); if (!klass->add) - g_warning("GisViewer: add - Unimplemented"); + g_warning("GritsViewer: add - Unimplemented"); return klass->add(viewer, object, level, sort); } /** - * gis_viewer_remove: + * grits_viewer_remove: * @viewer: the viewer - * @ref: the handle obtained from gis_viewer_add() + * @ref: the handle obtained from grits_viewer_add() * * Remove an object from the viewer. The objects reference count is decremented * prior to being removed. * - * Returns: the #GisObject referenced by the handle + * Returns: the #GritsObject referenced by the handle */ -GisObject *gis_viewer_remove(GisViewer *viewer, gpointer ref) +GritsObject *grits_viewer_remove(GritsViewer *viewer, gpointer ref) { - GisViewerClass *klass = GIS_VIEWER_GET_CLASS(viewer); + GritsViewerClass *klass = GRITS_VIEWER_GET_CLASS(viewer); if (!klass->remove) - g_warning("GisViewer: remove - Unimplemented"); + g_warning("GritsViewer: remove - Unimplemented"); return klass->remove(viewer, ref); } /**************** * GObject code * ****************/ -G_DEFINE_ABSTRACT_TYPE(GisViewer, gis_viewer, GTK_TYPE_DRAWING_AREA); -static void gis_viewer_init(GisViewer *viewer) +G_DEFINE_ABSTRACT_TYPE(GritsViewer, grits_viewer, GTK_TYPE_DRAWING_AREA); +static void grits_viewer_init(GritsViewer *viewer) { - g_debug("GisViewer: init"); + g_debug("GritsViewer: init"); /* Default values */ viewer->time = time(NULL); viewer->location[0] = 40; @@ -582,19 +582,19 @@ static void gis_viewer_init(GisViewer *viewer) g_signal_connect(viewer, "realize", G_CALLBACK(on_realize), NULL); } -static void gis_viewer_finalize(GObject *gobject) +static void grits_viewer_finalize(GObject *gobject) { - g_debug("GisViewer: finalize"); - G_OBJECT_CLASS(gis_viewer_parent_class)->finalize(gobject); + g_debug("GritsViewer: finalize"); + G_OBJECT_CLASS(grits_viewer_parent_class)->finalize(gobject); } -static void gis_viewer_class_init(GisViewerClass *klass) +static void grits_viewer_class_init(GritsViewerClass *klass) { - g_debug("GisViewer: class_init"); + g_debug("GritsViewer: class_init"); GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - gobject_class->finalize = gis_viewer_finalize; + gobject_class->finalize = grits_viewer_finalize; /** - * GisViewer::time-changed: + * GritsViewer::time-changed: * @viewer: the viewer. * @time: the new time. * @@ -614,7 +614,7 @@ static void gis_viewer_class_init(GisViewerClass *klass) G_TYPE_LONG); /** - * GisViewer::location-changed: + * GritsViewer::location-changed: * @viewer: the viewer. * @lat: the new latitude. * @lon: the new longitude. @@ -638,7 +638,7 @@ static void gis_viewer_class_init(GisViewerClass *klass) G_TYPE_DOUBLE); /** - * GisViewer::rotation-changed: + * GritsViewer::rotation-changed: * @viewer: the viewer. * @x: rotation new around the x axes. * @y: rotation new around the y axes. @@ -662,7 +662,7 @@ static void gis_viewer_class_init(GisViewerClass *klass) G_TYPE_DOUBLE); /** - * GisViewer::refresh: + * GritsViewer::refresh: * @viewer: the viewer. * * The ::refresh signal is emitted when a refresh is needed. If you are @@ -681,7 +681,7 @@ static void gis_viewer_class_init(GisViewerClass *klass) 0); /** - * GisViewer::offline: + * GritsViewer::offline: * @viewer: the viewer. * @offline: %TRUE if the viewer going offline. * diff --git a/src/grits-viewer.h b/src/grits-viewer.h index 8e50b81..aff426b 100644 --- a/src/grits-viewer.h +++ b/src/grits-viewer.h @@ -16,76 +16,75 @@ */ /** - * Hack alert: gis-opengl.h needs to be included before gis-viewer - * - GisViewer depends on GisObject for add/remove functions - * - GisObject depends on GisOpenGL for load/unload functions - * - GisOpenGL depends on GisViewer for inheritance + * Hack alert: grits-opengl.h needs to be included before grits-viewer + * - GritsViewer depends on GritsObject for add/remove functions + * - GritsObject depends on GritsOpenGL for load/unload functions + * - GritsOpenGL depends on GritsViewer for inheritance * - * The problem here is that GisOpenGL needs the GisViewer definition - * but GisViewer only needs the typedefs (through GisObject), - * so GisViewer needs to be included after the GisOpenGL typedefs but - * before the GisOpenGL definition. This is handled internally by - * gis-opengl.h + * The problem here is that GritsOpenGL needs the GritsViewer definition but + * GritsViewer only needs the typedefs (through GritsObject), so GritsViewer + * needs to be included after the GritsOpenGL typedefs but before the + * GritsOpenGL definition. This is handled internally by grits-opengl.h * - * This should probably be fixed, but making a GisGLObject interface - * seems like too much work. Merging GisViewer and GisOpenGL would also work, - * but I like the separate that that's provided by having two. + * This should probably be fixed, but making a GritsGLObject interface seems + * like too much work. Merging GritsViewer and GritsOpenGL would also work, but + * I like the separate that that's provided by having two. */ #include "grits-opengl.h" -#ifndef __GIS_VIEWER_H__ -#define __GIS_VIEWER_H__ +#ifndef __GRITS_VIEWER_H__ +#define __GRITS_VIEWER_H__ #include #include /* Rendering levels */ /** - * GIS_LEVEL_BACKGROUND: + * GRITS_LEVEL_BACKGROUND: * * The level used to draw background objects (stars, atmosphere, etc). */ -#define GIS_LEVEL_BACKGROUND -100 +#define GRITS_LEVEL_BACKGROUND -100 /** - * GIS_LEVEL_WORLD: + * GRITS_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; + * %GRITS_LEVEL_WORLD; */ -#define GIS_LEVEL_WORLD 0 +#define GRITS_LEVEL_WORLD 0 /** - * GIS_LEVEL_OVERLAY: + * GRITS_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. + * of ther objects. Text and markers should use %GRITS_LEVEL_OVERLAY. */ -#define GIS_LEVEL_OVERLAY 100 +#define GRITS_LEVEL_OVERLAY 100 /** - * GIS_LEVEL_HUD: + * GRITS_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 +#define GRITS_LEVEL_HUD 200 /* Type macros */ -#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)) +#define GRITS_TYPE_VIEWER (grits_viewer_get_type()) +#define GRITS_VIEWER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GRITS_TYPE_VIEWER, GritsViewer)) +#define GRITS_IS_VIEWER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GRITS_TYPE_VIEWER)) +#define GRITS_VIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRITS_TYPE_VIEWER, GritsViewerClass)) +#define GRITS_IS_VIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRITS_TYPE_VIEWER)) +#define GRITS_VIEWER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GRITS_TYPE_VIEWER, GritsViewerClass)) -typedef struct _GisViewer GisViewer; -typedef struct _GisViewerClass GisViewerClass; +typedef struct _GritsViewer GritsViewer; +typedef struct _GritsViewerClass GritsViewerClass; /** - * GisHeightFunc: + * GritsHeightFunc: * @lat: the target latitude * @lon: the target longitude * @user_data: user data passed to the function @@ -94,18 +93,18 @@ typedef struct _GisViewerClass GisViewerClass; * * Returns: the elevation in meters above sea level */ -typedef gdouble (*GisHeightFunc)(gdouble lat, gdouble lon, gpointer user_data); +typedef gdouble (*GritsHeightFunc)(gdouble lat, gdouble lon, gpointer user_data); #include "grits-plugin.h" #include "grits-prefs.h" #include "objects/grits-object.h" -struct _GisViewer { +struct _GritsViewer { GtkDrawingArea parent_instance; /* instance members */ - GisPlugins *plugins; - GisPrefs *prefs; + GritsPlugins *plugins; + GritsPrefs *prefs; time_t time; gdouble location[3]; gdouble rotation[3]; @@ -116,64 +115,64 @@ struct _GisViewer { gdouble drag_x, drag_y; }; -struct _GisViewerClass { +struct _GritsViewerClass { GtkDrawingAreaClass parent_class; /* class members */ - void (*center_position) (GisViewer *viewer, + void (*center_position) (GritsViewer *viewer, gdouble lat, gdouble lon, gdouble elev); - void (*project) (GisViewer *viewer, + void (*project) (GritsViewer *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, GisBounds *bounds, - GisHeightFunc height_func, gpointer user_data, + void (*clear_height_func)(GritsViewer *viewer); + void (*set_height_func) (GritsViewer *viewer, GritsBounds *bounds, + GritsHeightFunc height_func, gpointer user_data, gboolean update); - gpointer (*add) (GisViewer *viewer, GisObject *object, + gpointer (*add) (GritsViewer *viewer, GritsObject *object, gint level, gboolean sort); - GisObject *(*remove) (GisViewer *viewer, gpointer ref); + GritsObject *(*remove) (GritsViewer *viewer, gpointer ref); }; -GType gis_viewer_get_type(void); +GType grits_viewer_get_type(void); /* Methods */ -void gis_viewer_setup(GisViewer *viewer, GisPlugins *plugins, GisPrefs *prefs); +void grits_viewer_setup(GritsViewer *viewer, GritsPlugins *plugins, GritsPrefs *prefs); -void gis_viewer_set_time(GisViewer *viewer, time_t time); -time_t gis_viewer_get_time(GisViewer *viewer); +void grits_viewer_set_time(GritsViewer *viewer, time_t time); +time_t grits_viewer_get_time(GritsViewer *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 grits_viewer_set_location(GritsViewer *viewer, gdouble lat, gdouble lon, gdouble elev); +void grits_viewer_get_location(GritsViewer *viewer, gdouble *lat, gdouble *lon, gdouble *elev); +void grits_viewer_pan(GritsViewer *viewer, gdouble forward, gdouble right, gdouble up); +void grits_viewer_zoom(GritsViewer *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 grits_viewer_set_rotation(GritsViewer *viewer, gdouble x, gdouble y, gdouble z); +void grits_viewer_get_rotation(GritsViewer *viewer, gdouble *x, gdouble *y, gdouble *z); +void grits_viewer_rotate (GritsViewer *viewer, gdouble x, gdouble y, gdouble z); -void gis_viewer_refresh(GisViewer *viewer); +void grits_viewer_refresh(GritsViewer *viewer); -void gis_viewer_set_offline(GisViewer *viewer, gboolean offline); -gboolean gis_viewer_get_offline(GisViewer *viewer); +void grits_viewer_set_offline(GritsViewer *viewer, gboolean offline); +gboolean grits_viewer_get_offline(GritsViewer *viewer); /* To be implemented by subclasses */ -void gis_viewer_center_position(GisViewer *viewer, +void grits_viewer_center_position(GritsViewer *viewer, gdouble lat, gdouble lon, gdouble elev); -void gis_viewer_project(GisViewer *viewer, +void grits_viewer_project(GritsViewer *viewer, gdouble lat, gdouble lon, gdouble elev, gdouble *px, gdouble *py, gdouble *pz); -void gis_viewer_clear_height_func(GisViewer *viewer); -void gis_viewer_set_height_func(GisViewer *viewer, GisBounds *bounds, - GisHeightFunc height_func, gpointer user_data, +void grits_viewer_clear_height_func(GritsViewer *viewer); +void grits_viewer_set_height_func(GritsViewer *viewer, GritsBounds *bounds, + GritsHeightFunc height_func, gpointer user_data, gboolean update); -gpointer gis_viewer_add(GisViewer *viewer, GisObject *object, +gpointer grits_viewer_add(GritsViewer *viewer, GritsObject *object, gint level, gboolean sort); -GisObject *gis_viewer_remove(GisViewer *viewer, gpointer ref); +GritsObject *grits_viewer_remove(GritsViewer *viewer, gpointer ref); #endif diff --git a/src/grits.h b/src/grits.h index 024ab0c..94cc1ab 100644 --- a/src/grits.h +++ b/src/grits.h @@ -15,8 +15,8 @@ * along with this program. If not, see . */ -#ifndef __GIS_H__ -#define __GIS_H__ +#ifndef __GRITS_H__ +#define __GRITS_H__ /* Grits Core */ #include diff --git a/src/objects/grits-callback.c b/src/objects/grits-callback.c index 512c3d3..8bc97c4 100644 --- a/src/objects/grits-callback.c +++ b/src/objects/grits-callback.c @@ -16,14 +16,14 @@ */ /** - * SECTION:gis-callback + * SECTION:grits-callback * @short_description: Custom callback objects * - * #GisCallback objects are used for custom drawing functions. A common example + * #GritsCallback objects are used for custom drawing functions. A common example * of this would be to render something which does not easily fit into a normal * object. For instance, a Heads-Up-Display overlay. * - * Callbacks are an alternate to extending GisObject with a new class and + * Callbacks are an alternate to extending GritsObject with a new class and * should be used when only once instance of the object will be needed. */ @@ -31,38 +31,38 @@ #include "grits-callback.h" /** - * gis_callback_new: + * grits_callback_new: * @callback: the function to call to draw the object * @user_data: user data to pass to the drawing function * - * Create a #GisCallback object with an associated function and user data. + * Create a #GritsCallback object with an associated function and user data. * - * Returns: the new #GisCallback + * Returns: the new #GritsCallback */ -GisCallback *gis_callback_new(GisCallbackFunc draw_cb, gpointer user_data) +GritsCallback *grits_callback_new(GritsCallbackFunc draw_cb, gpointer user_data) { - GisCallback *cb = g_object_new(GIS_TYPE_CALLBACK, NULL); + GritsCallback *cb = g_object_new(GRITS_TYPE_CALLBACK, NULL); cb->draw = draw_cb; cb->user_data = user_data; return cb; } /* Proxy class methods to per-object methods */ -static void proxy_draw(GisObject *_cb, GisOpenGL *opengl) +static void proxy_draw(GritsObject *_cb, GritsOpenGL *opengl) { - GisCallback *cb = GIS_CALLBACK(_cb); + GritsCallback *cb = GRITS_CALLBACK(_cb); if (cb->draw) cb->draw(cb, opengl, cb->user_data); } -/* GisCallback */ -G_DEFINE_TYPE(GisCallback, gis_callback, GIS_TYPE_OBJECT); -static void gis_callback_init(GisCallback *cb) +/* GritsCallback */ +G_DEFINE_TYPE(GritsCallback, grits_callback, GRITS_TYPE_OBJECT); +static void grits_callback_init(GritsCallback *cb) { } -static void gis_callback_class_init(GisCallbackClass *klass) +static void grits_callback_class_init(GritsCallbackClass *klass) { - GisObjectClass *object_class = GIS_OBJECT_CLASS(klass); + GritsObjectClass *object_class = GRITS_OBJECT_CLASS(klass); object_class->draw = proxy_draw; } diff --git a/src/objects/grits-callback.h b/src/objects/grits-callback.h index b4a3619..5bee549 100644 --- a/src/objects/grits-callback.h +++ b/src/objects/grits-callback.h @@ -15,45 +15,45 @@ * along with this program. If not, see . */ -#ifndef __GIS_CALLBACK_H__ -#define __GIS_CALLBACK_H__ +#ifndef __GRITS_CALLBACK_H__ +#define __GRITS_CALLBACK_H__ #include #include #include "grits-object.h" -/* GisCallback */ -#define GIS_TYPE_CALLBACK (gis_callback_get_type()) -#define GIS_CALLBACK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GIS_TYPE_CALLBACK, GisCallback)) -#define GIS_IS_CALLBACK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GIS_TYPE_CALLBACK)) -#define GIS_CALLBACK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIS_TYPE_CALLBACK, GisCallbackClass)) -#define GIS_IS_CALLBACK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIS_TYPE_CALLBACK)) -#define GIS_CALLBACK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIS_TYPE_CALLBACK, GisCallbackClass)) +/* GritsCallback */ +#define GRITS_TYPE_CALLBACK (grits_callback_get_type()) +#define GRITS_CALLBACK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GRITS_TYPE_CALLBACK, GritsCallback)) +#define GRITS_IS_CALLBACK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GRITS_TYPE_CALLBACK)) +#define GRITS_CALLBACK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRITS_TYPE_CALLBACK, GritsCallbackClass)) +#define GRITS_IS_CALLBACK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRITS_TYPE_CALLBACK)) +#define GRITS_CALLBACK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GRITS_TYPE_CALLBACK, GritsCallbackClass)) -typedef struct _GisCallback GisCallback; -typedef struct _GisCallbackClass GisCallbackClass; +typedef struct _GritsCallback GritsCallback; +typedef struct _GritsCallbackClass GritsCallbackClass; /** - * GisCallbackFunc: + * GritsCallbackFunc: * @callback: the callback object to be drawn * @user_data: the user data associated with the callback * * A function to be called when the callback object is being rendered */ -typedef void (*GisCallbackFunc)(GisCallback *callback, GisOpenGL *opengl, gpointer user_data); +typedef void (*GritsCallbackFunc)(GritsCallback *callback, GritsOpenGL *opengl, gpointer user_data); -struct _GisCallback { - GisObject parent; - GisCallbackFunc draw; - gpointer user_data; +struct _GritsCallback { + GritsObject parent; + GritsCallbackFunc draw; + gpointer user_data; }; -struct _GisCallbackClass { - GisObjectClass parent_class; +struct _GritsCallbackClass { + GritsObjectClass parent_class; }; -GType gis_callback_get_type(void); +GType grits_callback_get_type(void); -GisCallback *gis_callback_new(GisCallbackFunc draw_cb, gpointer user_data); +GritsCallback *grits_callback_new(GritsCallbackFunc draw_cb, gpointer user_data); #endif diff --git a/src/objects/grits-marker.c b/src/objects/grits-marker.c index ff6ccb2..497c77c 100644 --- a/src/objects/grits-marker.c +++ b/src/objects/grits-marker.c @@ -16,17 +16,17 @@ */ /** - * SECTION:gis-marker + * SECTION:grits-marker * @short_description: Single point markers * - * Each #GisMarker represents some point on the earth with some form of + * Each #GritsMarker represents some point on the earth with some form of * content. Commonly this is used to mark geographic features such as cities or * states. * * While markers represent a place in three dimensions somewhere on, below, or * above the surface of the earth, they are drawn in 2 dimensions so that they - * look normal and readable by the user. Due to this, GisObjects should almost - * always be added to the GIS_LEVEL_OVERLAY level so they are drawn "above" the + * look normal and readable by the user. Due to this, GritsObjects should almost + * always be added to the GRITS_LEVEL_OVERLAY level so they are drawn "above" the * actual earth. */ @@ -35,22 +35,22 @@ #include "grits-marker.h" /** - * gis_marker_new: + * grits_marker_new: * @label: a short description of the marker * - * Create a new GisMarker which shows the given label when drawn. + * Create a new GritsMarker which shows the given label when drawn. * - * Returns: the new #GisMarker. + * Returns: the new #GritsMarker. */ -GisMarker *gis_marker_new(const gchar *label) +GritsMarker *grits_marker_new(const gchar *label) { - //g_debug("GisMarker: new - %s", label); + //g_debug("GritsMarker: new - %s", label); static const gdouble OUTLINE = 2; static const gdouble RADIUS = 3; static const gdouble WIDTH = 128; static const gdouble HEIGHT = 32; - GisMarker *marker = g_object_new(GIS_TYPE_MARKER, NULL); + GritsMarker *marker = g_object_new(GRITS_TYPE_MARKER, NULL); marker->xoff = RADIUS+OUTLINE; marker->yoff = HEIGHT-(RADIUS+OUTLINE); marker->label = g_strdup(label); @@ -96,12 +96,12 @@ GisMarker *gis_marker_new(const gchar *label) } /* Drawing */ -static void gis_marker_draw(GisObject *_marker, GisOpenGL *opengl) +static void grits_marker_draw(GritsObject *_marker, GritsOpenGL *opengl) { - GisMarker *marker = GIS_MARKER(_marker); - GisPoint *point = gis_object_center(marker); + GritsMarker *marker = GRITS_MARKER(_marker); + GritsPoint *point = grits_object_center(marker); gdouble px, py, pz; - gis_viewer_project(GIS_VIEWER(opengl), + grits_viewer_project(GRITS_VIEWER(opengl), point->lat, point->lon, point->elev, &px, &py, &pz); @@ -111,7 +111,7 @@ static void gis_marker_draw(GisObject *_marker, GisOpenGL *opengl) if (pz > 1) return; - //g_debug("GisOpenGL: draw_marker - %s pz=%f ", marker->label, pz); + //g_debug("GritsOpenGL: draw_marker - %s pz=%f ", marker->label, pz); cairo_surface_t *surface = cairo_get_target(marker->cairo); gdouble width = cairo_image_surface_get_width(surface); @@ -138,15 +138,15 @@ static void gis_marker_draw(GisObject *_marker, GisOpenGL *opengl) } /* GObject code */ -G_DEFINE_TYPE(GisMarker, gis_marker, GIS_TYPE_OBJECT); -static void gis_marker_init(GisMarker *marker) +G_DEFINE_TYPE(GritsMarker, grits_marker, GRITS_TYPE_OBJECT); +static void grits_marker_init(GritsMarker *marker) { } -static void gis_marker_finalize(GObject *_marker) +static void grits_marker_finalize(GObject *_marker) { - //g_debug("GisMarker: finalize - %s", marker->label); - GisMarker *marker = GIS_MARKER(_marker); + //g_debug("GritsMarker: finalize - %s", marker->label); + GritsMarker *marker = GRITS_MARKER(_marker); glDeleteTextures(1, &marker->tex); cairo_surface_t *surface = cairo_get_target(marker->cairo); cairo_surface_destroy(surface); @@ -154,12 +154,12 @@ static void gis_marker_finalize(GObject *_marker) g_free(marker->label); } -static void gis_marker_class_init(GisMarkerClass *klass) +static void grits_marker_class_init(GritsMarkerClass *klass) { - g_debug("GisMarker: class_init"); + g_debug("GritsMarker: class_init"); GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - gobject_class->finalize = gis_marker_finalize; + gobject_class->finalize = grits_marker_finalize; - GisObjectClass *object_class = GIS_OBJECT_CLASS(klass); - object_class->draw = gis_marker_draw; + GritsObjectClass *object_class = GRITS_OBJECT_CLASS(klass); + object_class->draw = grits_marker_draw; } diff --git a/src/objects/grits-marker.h b/src/objects/grits-marker.h index 50dca05..5fdedc7 100644 --- a/src/objects/grits-marker.h +++ b/src/objects/grits-marker.h @@ -15,39 +15,39 @@ * along with this program. If not, see . */ -#ifndef __GIS_MARKER_H__ -#define __GIS_MARKER_H__ +#ifndef __GRITS_MARKER_H__ +#define __GRITS_MARKER_H__ #include #include #include #include "grits-object.h" -/* GisMarker */ -#define GIS_TYPE_MARKER (gis_marker_get_type()) -#define GIS_MARKER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GIS_TYPE_MARKER, GisMarker)) -#define GIS_IS_MARKER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GIS_TYPE_MARKER)) -#define GIS_MARKER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIS_TYPE_MARKER, GisMarkerClass)) -#define GIS_IS_MARKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIS_TYPE_MARKER)) -#define GIS_MARKER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIS_TYPE_MARKER, GisMarkerClass)) +/* GritsMarker */ +#define GRITS_TYPE_MARKER (grits_marker_get_type()) +#define GRITS_MARKER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GRITS_TYPE_MARKER, GritsMarker)) +#define GRITS_IS_MARKER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GRITS_TYPE_MARKER)) +#define GRITS_MARKER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRITS_TYPE_MARKER, GritsMarkerClass)) +#define GRITS_IS_MARKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRITS_TYPE_MARKER)) +#define GRITS_MARKER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GRITS_TYPE_MARKER, GritsMarkerClass)) -typedef struct _GisMarker GisMarker; -typedef struct _GisMarkerClass GisMarkerClass; +typedef struct _GritsMarker GritsMarker; +typedef struct _GritsMarkerClass GritsMarkerClass; -struct _GisMarker { - GisObject parent_instance; +struct _GritsMarker { + GritsObject parent_instance; gint xoff, yoff; gchar *label; cairo_t *cairo; guint tex; }; -struct _GisMarkerClass { - GisObjectClass parent_class; +struct _GritsMarkerClass { + GritsObjectClass parent_class; }; -GType gis_marker_get_type(void); +GType grits_marker_get_type(void); -GisMarker *gis_marker_new(const gchar *label); +GritsMarker *grits_marker_new(const gchar *label); #endif diff --git a/src/objects/grits-object.c b/src/objects/grits-object.c index f625e7a..455723d 100644 --- a/src/objects/grits-object.c +++ b/src/objects/grits-object.c @@ -16,7 +16,7 @@ */ /** - * SECTION:gis-object + * SECTION:grits-object * @short_description: Base class for drawing operations * * Objects in grits are things which can be added to the viewer and will be @@ -24,8 +24,8 @@ * level of detail which are used by the viewer to determine which objects * should be drawn. * - * Each #GisObject is also a #GObject, but not every GObject in grits is a - * GisObject. The "Object" part of the name is just coincidence. + * Each #GritsObject is also a #GObject, but not every GObject in grits is a + * GritsObject. The "Object" part of the name is just coincidence. */ #include @@ -35,11 +35,8 @@ #include "grits-object.h" -/************* - * GisObject * - *************/ /** - * gis_object_draw: + * grits_object_draw: * @object: the object * @opengl: the viewer the object is being displayed in * @@ -48,11 +45,11 @@ * The GL_PROJECTION and GL_MODELVIEW matricies and GL_ALL_ATTRIB_BITS will be * restored to the default state after the call to draw. */ -void gis_object_draw(GisObject *object, GisOpenGL *opengl) +void grits_object_draw(GritsObject *object, GritsOpenGL *opengl) { - GisObjectClass *klass = GIS_OBJECT_GET_CLASS(object); + GritsObjectClass *klass = GRITS_OBJECT_GET_CLASS(object); if (!klass->draw) { - g_warning("GisObject: draw - Unimplemented"); + g_warning("GritsObject: draw - Unimplemented"); return; } @@ -64,7 +61,7 @@ void gis_object_draw(GisObject *object, GisOpenGL *opengl) if (object->lod > 0) { /* LOD test */ gdouble eye[3], obj[3]; - gis_viewer_get_location(GIS_VIEWER(opengl), &eye[0], &eye[1], &eye[2]); + grits_viewer_get_location(GRITS_VIEWER(opengl), &eye[0], &eye[1], &eye[2]); gdouble elev = eye[2]; lle2xyz(eye[0], eye[1], eye[2], &eye[0], &eye[1], &eye[2]); lle2xyz(object->center.lat, object->center.lon, object->center.elev, @@ -96,11 +93,11 @@ void gis_object_draw(GisObject *object, GisOpenGL *opengl) } /* GObject stuff */ -G_DEFINE_ABSTRACT_TYPE(GisObject, gis_object, G_TYPE_OBJECT); -static void gis_object_init(GisObject *object) +G_DEFINE_ABSTRACT_TYPE(GritsObject, grits_object, G_TYPE_OBJECT); +static void grits_object_init(GritsObject *object) { } -static void gis_object_class_init(GisObjectClass *klass) +static void grits_object_class_init(GritsObjectClass *klass) { } diff --git a/src/objects/grits-object.h b/src/objects/grits-object.h index 298580b..b8a91a6 100644 --- a/src/objects/grits-object.h +++ b/src/objects/grits-object.h @@ -15,53 +15,53 @@ * along with this program. If not, see . */ -#ifndef __GIS_OBJECT_H__ -#define __GIS_OBJECT_H__ +#ifndef __GRITS_OBJECT_H__ +#define __GRITS_OBJECT_H__ #include #include #include "grits-util.h" -/* GisObject */ -#define GIS_TYPE_OBJECT (gis_object_get_type()) -#define GIS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GIS_TYPE_OBJECT, GisObject)) -#define GIS_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GIS_TYPE_OBJECT)) -#define GIS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIS_TYPE_OBJECT, GisObjectClass)) -#define GIS_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIS_TYPE_OBJECT)) -#define GIS_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIS_TYPE_OBJECT, GisObjectClass)) +/* GritsObject */ +#define GRITS_TYPE_OBJECT (grits_object_get_type()) +#define GRITS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GRITS_TYPE_OBJECT, GritsObject)) +#define GRITS_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GRITS_TYPE_OBJECT)) +#define GRITS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRITS_TYPE_OBJECT, GritsObjectClass)) +#define GRITS_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRITS_TYPE_OBJECT)) +#define GRITS_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GRITS_TYPE_OBJECT, GritsObjectClass)) -typedef struct _GisObject GisObject; -typedef struct _GisObjectClass GisObjectClass; +typedef struct _GritsObject GritsObject; +typedef struct _GritsObjectClass GritsObjectClass; -struct _GisObject { - GObject parent_instance; - GisPoint center; - gboolean hidden; - gdouble lod; +struct _GritsObject { + GObject parent_instance; + GritsPoint center; + gboolean hidden; + gdouble lod; }; #include "grits-opengl.h" -struct _GisObjectClass { +struct _GritsObjectClass { GObjectClass parent_class; /* Move some of these to GObject? */ - void (*draw) (GisObject *object, GisOpenGL *opengl); + void (*draw) (GritsObject *object, GritsOpenGL *opengl); }; -GType gis_object_get_type(void); +GType grits_object_get_type(void); /* Implemented by sub-classes */ -void gis_object_draw(GisObject *object, GisOpenGL *opengl); +void grits_object_draw(GritsObject *object, GritsOpenGL *opengl); /** - * gis_object_center: - * @object: The #GisObject to get the center of + * grits_object_center: + * @object: The #GritsObject to get the center of * - * Get the #GisPoint representing the center of an object + * Get the #GritsPoint representing the center of an object * * Returns: the center point */ -#define gis_object_center(object) \ - (&GIS_OBJECT(object)->center) +#define grits_object_center(object) \ + (&GRITS_OBJECT(object)->center) #endif diff --git a/src/objects/grits-tile.c b/src/objects/grits-tile.c index c71be50..ed3feec 100644 --- a/src/objects/grits-tile.c +++ b/src/objects/grits-tile.c @@ -16,19 +16,19 @@ */ /** - * SECTION:gis-tile + * SECTION:grits-tile * @short_description: Latitude/longitude overlays * - * Each #GisTile corresponds to a latitude/longitude box on the surface of the - * earth. When drawn, the #GisTile renders an images associated with it to the - * surface of the earth. This is primarily used to draw ground overlays. + * Each #GritsTile corresponds to a latitude/longitude box on the surface of + * the earth. When drawn, the #GritsTile renders an images associated with it + * to the surface of the earth. This is primarily used to draw ground overlays. * - * Each GisTile can be split into subtiles in order to draw higher resolution + * Each GritsTile can be split into subtiles in order to draw higher resolution * overlays. Pointers to subtitles are stored in the parent tile and a parent * pointer is stored in each child. * - * Each #GisTile has a data filed which must be set by the user in order for - * the tile to be drawn. When used with GisOpenGL the data must be an integer + * Each #GritsTile has a data filed which must be set by the user in order for + * the tile to be drawn. When used with GritsOpenGL the data must be an integer * representing the OpenGL texture to use when drawing the tile. */ @@ -36,13 +36,13 @@ #include #include "grits-tile.h" -gchar *gis_tile_path_table[2][2] = { +gchar *grits_tile_path_table[2][2] = { {"00.", "01."}, {"10.", "11."}, }; /** - * gis_tile_new: + * grits_tile_new: * @parent: the parent for the tile, or NULL * @n: the northern border of the tile * @s: the southern border of the tile @@ -51,21 +51,21 @@ gchar *gis_tile_path_table[2][2] = { * * Create a tile associated with a particular latitude/longitude box. * - * Returns: the new #GisTile + * Returns: the new #GritsTile */ -GisTile *gis_tile_new(GisTile *parent, +GritsTile *grits_tile_new(GritsTile *parent, gdouble n, gdouble s, gdouble e, gdouble w) { - GisTile *tile = g_object_new(GIS_TYPE_TILE, NULL); + GritsTile *tile = g_object_new(GRITS_TYPE_TILE, NULL); tile->parent = parent; tile->atime = time(NULL); - gis_bounds_set_bounds(&tile->coords, 0, 1, 1, 0); - gis_bounds_set_bounds(&tile->edge, n, s, e, w); + grits_bounds_set_bounds(&tile->coords, 0, 1, 1, 0); + grits_bounds_set_bounds(&tile->edge, n, s, e, w); return tile; } /** - * gis_tile_get_path: + * grits_tile_get_path: * @child: the tile to generate a path for * * Generate a string representation of a tiles location in a group of nested @@ -75,15 +75,15 @@ GisTile *gis_tile_new(GisTile *parent, * * Returns: the path representing the tiles's location */ -gchar *gis_tile_get_path(GisTile *child) +gchar *grits_tile_get_path(GritsTile *child) { /* This could be easily cached if necessary */ int x, y; GList *parts = NULL; - for (GisTile *parent = child->parent; parent; child = parent, parent = child->parent) - gis_tile_foreach_index(child, x, y) + for (GritsTile *parent = child->parent; parent; child = parent, parent = child->parent) + grits_tile_foreach_index(child, x, y) if (parent->children[x][y] == child) - parts = g_list_prepend(parts, gis_tile_path_table[x][y]); + parts = g_list_prepend(parts, grits_tile_path_table[x][y]); GString *path = g_string_new(""); for (GList *cur = parts; cur; cur = cur->next) g_string_append(path, cur->data); @@ -91,9 +91,9 @@ gchar *gis_tile_get_path(GisTile *child) return g_string_free(path, FALSE); } -static gdouble _gis_tile_get_min_dist(GisPoint *eye, GisBounds *bounds) +static gdouble _grits_tile_get_min_dist(GritsPoint *eye, GritsBounds *bounds) { - GisPoint pos = {}; + GritsPoint pos = {}; pos.lat = eye->lat > bounds->n ? bounds->n : eye->lat < bounds->s ? bounds->s : eye->lat; pos.lon = eye->lon > bounds->e ? bounds->e : @@ -106,10 +106,10 @@ static gdouble _gis_tile_get_min_dist(GisPoint *eye, GisBounds *bounds) return distd(a, b); } -static gboolean _gis_tile_precise(GisPoint *eye, GisBounds *bounds, +static gboolean _grits_tile_precise(GritsPoint *eye, GritsBounds *bounds, gdouble max_res, gint width, gint height) { - gdouble min_dist = _gis_tile_get_min_dist(eye, bounds); + gdouble min_dist = _grits_tile_get_min_dist(eye, bounds); gdouble view_res = MPPX(min_dist); gdouble lat_point = bounds->n < 0 ? bounds->n : @@ -134,7 +134,7 @@ static gboolean _gis_tile_precise(GisPoint *eye, GisBounds *bounds, } /** - * gis_tile_update: + * grits_tile_update: * @root: the root tile to split * @eye: the point the tile is viewed from, for calculating distances * @res: a maximum resolution in meters per pixel to split tiles to @@ -149,12 +149,12 @@ static gboolean _gis_tile_precise(GisPoint *eye, GisBounds *bounds, * the tile is recursively subdivided until a sufficient resolution is * achieved. */ -void gis_tile_update(GisTile *root, GisPoint *eye, +void grits_tile_update(GritsTile *root, GritsPoint *eye, gdouble res, gint width, gint height, - GisTileLoadFunc load_func, gpointer user_data) + GritsTileLoadFunc load_func, gpointer user_data) { root->atime = time(NULL); - //g_debug("GisTile: update - %p->atime = %u", + //g_debug("GritsTile: update - %p->atime = %u", // root, (guint)root->atime); const gdouble rows = G_N_ELEMENTS(root->children); const gdouble cols = G_N_ELEMENTS(root->children[0]); @@ -163,21 +163,21 @@ void gis_tile_update(GisTile *root, GisPoint *eye, const gdouble lat_step = lat_dist / rows; const gdouble lon_step = lon_dist / cols; int row, col; - gis_tile_foreach_index(root, row, col) { - GisTile **child = &root->children[row][col]; - GisBounds edge; + grits_tile_foreach_index(root, row, col) { + GritsTile **child = &root->children[row][col]; + GritsBounds edge; edge.n = root->edge.n-(lat_step*(row+0)); edge.s = root->edge.n-(lat_step*(row+1)); edge.e = root->edge.w+(lon_step*(col+1)); edge.w = root->edge.w+(lon_step*(col+0)); - if (!_gis_tile_precise(eye, &edge, res, + if (!_grits_tile_precise(eye, &edge, res, width/cols, height/rows)) { if (!*child) { - *child = gis_tile_new(root, edge.n, edge.s, + *child = grits_tile_new(root, edge.n, edge.s, edge.e, edge.w); load_func(*child, user_data); } - gis_tile_update(*child, eye, + grits_tile_update(*child, eye, res, width, height, load_func, user_data); } @@ -185,7 +185,7 @@ void gis_tile_update(GisTile *root, GisPoint *eye, } /** - * gis_tile_find: + * grits_tile_find: * @root: the root tile to search from * @lat: target latitude * @lon: target longitude @@ -195,7 +195,7 @@ void gis_tile_update(GisTile *root, GisPoint *eye, * * Returns: the child tile */ -GisTile *gis_tile_find(GisTile *root, gdouble lat, gdouble lon) +GritsTile *grits_tile_find(GritsTile *root, gdouble lat, gdouble lon) { gint rows = G_N_ELEMENTS(root->children); gint cols = G_N_ELEMENTS(root->children[0]); @@ -219,13 +219,13 @@ GisTile *gis_tile_find(GisTile *root, gdouble lat, gdouble lon) if (row < 0 || row >= rows || col < 0 || col >= cols) return NULL; else if (root->children[row][col] && root->children[row][col]->data) - return gis_tile_find(root->children[row][col], lat, lon); + return grits_tile_find(root->children[row][col], lat, lon); else return root; } /** - * gis_tile_gc: + * grits_tile_gc: * @root: the root tile to start garbage collection at * @atime: most recent time at which tiles will be kept * @free_func: function used to free the image when a new tile is collected @@ -236,21 +236,21 @@ GisTile *gis_tile_find(GisTile *root, gdouble lat, gdouble lon) * * Returns: a pointer to the original tile, or NULL if it was garbage collected */ -GisTile *gis_tile_gc(GisTile *root, time_t atime, - GisTileFreeFunc free_func, gpointer user_data) +GritsTile *grits_tile_gc(GritsTile *root, time_t atime, + GritsTileFreeFunc free_func, gpointer user_data) { if (!root) return NULL; gboolean has_children = FALSE; int x, y; - gis_tile_foreach_index(root, x, y) { - root->children[x][y] = gis_tile_gc( + grits_tile_foreach_index(root, x, y) { + root->children[x][y] = grits_tile_gc( root->children[x][y], atime, free_func, user_data); if (root->children[x][y]) has_children = TRUE; } - //g_debug("GisTile: gc - %p->atime=%u < atime=%u", + //g_debug("GritsTile: gc - %p->atime=%u < atime=%u", // root, (guint)root->atime, (guint)atime); if (!has_children && root->atime < atime && root->data) { free_func(root, user_data); @@ -262,32 +262,32 @@ GisTile *gis_tile_gc(GisTile *root, time_t atime, /* Use GObject for this */ /** - * gis_tile_free: + * grits_tile_free: * @root: the root tile to free * @free_func: function used to free the image when a new tile is collected * @user_data: user data to past to the free function * * Recursively free a tile and all it's children. */ -void gis_tile_free(GisTile *root, GisTileFreeFunc free_func, gpointer user_data) +void grits_tile_free(GritsTile *root, GritsTileFreeFunc free_func, gpointer user_data) { if (!root) return; - GisTile *child; - gis_tile_foreach(root, child) - gis_tile_free(child, free_func, user_data); + GritsTile *child; + grits_tile_foreach(root, child) + grits_tile_free(child, free_func, user_data); if (free_func) free_func(root, user_data); g_object_unref(root); } /* Draw a single tile */ -static void gis_tile_draw_one(GisTile *tile, GisOpenGL *opengl, GList *triangles) +static void grits_tile_draw_one(GritsTile *tile, GritsOpenGL *opengl, GList *triangles) { if (!tile || !tile->data) return; if (!triangles) - g_warning("GisOpenGL: _draw_tiles - No triangles to draw: edges=%f,%f,%f,%f", + g_warning("GritsOpenGL: _draw_tiles - No triangles to draw: edges=%f,%f,%f,%f", tile->edge.n, tile->edge.s, tile->edge.e, tile->edge.w); //g_message("drawing %4d triangles for tile edges=%7.2f,%7.2f,%7.2f,%7.2f", // g_list_length(triangles), tile->edge.n, tile->edge.s, tile->edge.e, tile->edge.w); @@ -357,12 +357,12 @@ static void gis_tile_draw_one(GisTile *tile, GisOpenGL *opengl, GList *triangles } /* Draw the tile */ -static void gis_tile_draw_rec(GisTile *tile, GisOpenGL *opengl) +static void grits_tile_draw_rec(GritsTile *tile, GritsOpenGL *opengl) { /* Only draw children if possible */ gboolean has_children = FALSE; - GisTile *child; - gis_tile_foreach(tile, child) + GritsTile *child; + grits_tile_foreach(tile, child) if (child && child->data) has_children = TRUE; @@ -376,10 +376,10 @@ static void gis_tile_draw_rec(GisTile *tile, GisOpenGL *opengl) const gdouble lat_step = lat_dist / rows; const gdouble lon_step = lon_dist / cols; int row, col; - gis_tile_foreach_index(tile, row, col) { - GisTile *child = tile->children[row][col]; + grits_tile_foreach_index(tile, row, col) { + GritsTile *child = tile->children[row][col]; if (child && child->data) { - gis_tile_draw_rec(child, opengl); + grits_tile_draw_rec(child, opengl); } else { const gdouble n = tile->edge.n-(lat_step*(row+0)); const gdouble s = tile->edge.n-(lat_step*(row+1)); @@ -395,27 +395,27 @@ static void gis_tile_draw_rec(GisTile *tile, GisOpenGL *opengl) tile->edge.n, tile->edge.s, tile->edge.e, tile->edge.w); } if (triangles) - gis_tile_draw_one(tile, opengl, triangles); + grits_tile_draw_one(tile, opengl, triangles); g_list_free(triangles); } -static void gis_tile_draw(GisObject *tile, GisOpenGL *opengl) +static void grits_tile_draw(GritsObject *tile, GritsOpenGL *opengl) { glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); - gis_tile_draw_rec(GIS_TILE(tile), opengl); + grits_tile_draw_rec(GRITS_TILE(tile), opengl); } /* GObject code */ -G_DEFINE_TYPE(GisTile, gis_tile, GIS_TYPE_OBJECT); -static void gis_tile_init(GisTile *tile) +G_DEFINE_TYPE(GritsTile, grits_tile, GRITS_TYPE_OBJECT); +static void grits_tile_init(GritsTile *tile) { } -static void gis_tile_class_init(GisTileClass *klass) +static void grits_tile_class_init(GritsTileClass *klass) { - g_debug("GisTile: class_init"); - GisObjectClass *object_class = GIS_OBJECT_CLASS(klass); - object_class->draw = gis_tile_draw; + g_debug("GritsTile: class_init"); + GritsObjectClass *object_class = GRITS_OBJECT_CLASS(klass); + object_class->draw = grits_tile_draw; } diff --git a/src/objects/grits-tile.h b/src/objects/grits-tile.h index 91f5ac6..309f4bc 100644 --- a/src/objects/grits-tile.h +++ b/src/objects/grits-tile.h @@ -15,25 +15,25 @@ * along with this program. If not, see . */ -#ifndef __GIS_TILE_H__ -#define __GIS_TILE_H__ +#ifndef __GRITS_TILE_H__ +#define __GRITS_TILE_H__ #include #include #include "grits-object.h" -#define GIS_TYPE_TILE (gis_tile_get_type()) -#define GIS_TILE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GIS_TYPE_TILE, GisTile)) -#define GIS_IS_TILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GIS_TYPE_TILE)) -#define GIS_TILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIS_TYPE_TILE, GisTileClass)) -#define GIS_IS_TILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIS_TYPE_TILE)) -#define GIS_TILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIS_TYPE_TILE, GisTileClass)) +#define GRITS_TYPE_TILE (grits_tile_get_type()) +#define GRITS_TILE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GRITS_TYPE_TILE, GritsTile)) +#define GRITS_IS_TILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GRITS_TYPE_TILE)) +#define GRITS_TILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRITS_TYPE_TILE, GritsTileClass)) +#define GRITS_IS_TILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRITS_TYPE_TILE)) +#define GRITS_TILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GRITS_TYPE_TILE, GritsTileClass)) -typedef struct _GisTile GisTile; -typedef struct _GisTileClass GisTileClass; +typedef struct _GritsTile GritsTile; +typedef struct _GritsTileClass GritsTileClass; -struct _GisTile { - GisObject parent_instance; +struct _GritsTile { + GritsObject parent_instance; /* Pointer to the tile data */ gpointer data; @@ -42,94 +42,94 @@ struct _GisTile { gint zindex; /* North,South,East,West limits */ - GisBounds edge; + GritsBounds edge; /* Texture mapping coordinates */ - GisBounds coords; + GritsBounds coords; /* Pointers to parent/child nodes */ - GisTile *parent; - GisTile *children[2][2]; + GritsTile *parent; + GritsTile *children[2][2]; /* Last access time (for garbage collection) */ time_t atime; }; -struct _GisTileClass { - GisObjectClass parent_class; +struct _GritsTileClass { + GritsObjectClass parent_class; }; /** - * GisTileLoadFunc: + * GritsTileLoadFunc: * @tile: the tile to load * @user_data: data paseed to the function * - * Used to load the image data associated with a tile. For GisOpenGL, this + * Used to load the image data associated with a tile. For GritsOpenGL, this * function should store the OpenGL texture number in the tiles data field. */ -typedef void (*GisTileLoadFunc)(GisTile *tile, gpointer user_data); +typedef void (*GritsTileLoadFunc)(GritsTile *tile, gpointer user_data); /** - * GisTileFreeFunc: + * GritsTileFreeFunc: * @tile: the tile to free * @user_data: data paseed to the function * * Used to free the image data associated with a tile */ -typedef void (*GisTileFreeFunc)(GisTile *tile, gpointer user_data); +typedef void (*GritsTileFreeFunc)(GritsTile *tile, gpointer user_data); /* Forech functions */ /** - * gis_tile_foreach: - * @parent: the #GisTile to iterate over - * @child: a pointer to a #GisTile to store the current subtile + * grits_tile_foreach: + * @parent: the #GritsTile to iterate over + * @child: a pointer to a #GritsTile to store the current subtile * * Iterate over each imediate subtile of @parent. */ -#define gis_tile_foreach(parent, child) \ +#define grits_tile_foreach(parent, child) \ for (int _x = 0; _x < G_N_ELEMENTS(parent->children); _x++) \ for (int _y = 0; child = parent->children[_x][_y], \ _y < G_N_ELEMENTS(parent->children[_x]); _y++) /** - * gis_tile_foreach_index: - * @parent: the #GisTile to iterate over + * grits_tile_foreach_index: + * @parent: the #GritsTile to iterate over * @x: integer to store the x index of the current subtile * @y: integer to store the y index of the current subtile * * Iterate over each imediate subtile of @parent. */ -#define gis_tile_foreach_index(parent, x, y) \ +#define grits_tile_foreach_index(parent, x, y) \ for (x = 0; x < G_N_ELEMENTS(parent->children); x++) \ for (y = 0; y < G_N_ELEMENTS(parent->children[x]); y++) /* Path to string table, keep in sync with tile->children */ -extern gchar *gis_tile_path_table[2][2]; +extern gchar *grits_tile_path_table[2][2]; -GType gis_tile_get_type(void); +GType grits_tile_get_type(void); /* Allocate a new Tile */ -GisTile *gis_tile_new(GisTile *parent, +GritsTile *grits_tile_new(GritsTile *parent, gdouble n, gdouble s, gdouble e, gdouble w); /* Return a string representation of the tile's path */ -gchar *gis_tile_get_path(GisTile *child); +gchar *grits_tile_get_path(GritsTile *child); /* Update a root tile */ /* Based on eye distance */ -void gis_tile_update(GisTile *root, GisPoint *eye, +void grits_tile_update(GritsTile *root, GritsPoint *eye, gdouble res, gint width, gint height, - GisTileLoadFunc load_func, gpointer user_data); + GritsTileLoadFunc load_func, gpointer user_data); /* Find the leaf tile containing lat-lon */ -GisTile *gis_tile_find(GisTile *root, gdouble lat, gdouble lon); +GritsTile *grits_tile_find(GritsTile *root, gdouble lat, gdouble lon); /* Delete nodes that haven't been accessed since atime */ -GisTile *gis_tile_gc(GisTile *root, time_t atime, - GisTileFreeFunc free_func, gpointer user_data); +GritsTile *grits_tile_gc(GritsTile *root, time_t atime, + GritsTileFreeFunc free_func, gpointer user_data); /* Free a tile and all it's children */ -void gis_tile_free(GisTile *root, - GisTileFreeFunc free_func, gpointer user_data); +void grits_tile_free(GritsTile *root, + GritsTileFreeFunc free_func, gpointer user_data); #endif diff --git a/src/plugins/elev.c b/src/plugins/elev.c index f59238d..251ec74 100644 --- a/src/plugins/elev.c +++ b/src/plugins/elev.c @@ -19,7 +19,7 @@ * SECTION:elev * @short_description: Elevation plugin * - * #GisPluginElev provides access to ground elevation. It does this in two ways: + * #GritsPluginElev provides access to ground elevation. It does this in two ways: * First, it provides a height function used by the viewer when drawing the * world. Second, it can load the elevation data into an image and draw a * greyscale elevation overlay on the planets surface. @@ -39,17 +39,17 @@ #define TILE_SIZE (TILE_WIDTH*TILE_HEIGHT*sizeof(guint16)) struct _TileData { - /* OpenGL has to be first to make gis_opengl_render_tiles happy */ + /* OpenGL has to be first to make grits_opengl_render_tiles happy */ guint opengl; guint16 *bil; }; static gdouble _height_func(gdouble lat, gdouble lon, gpointer _elev) { - GisPluginElev *elev = _elev; + GritsPluginElev *elev = _elev; if (!elev) return 0; - GisTile *tile = gis_tile_find(elev->tiles, lat, lon); + GritsTile *tile = grits_tile_find(elev->tiles, lat, lon); if (!tile) return 0; struct _TileData *data = tile->data; @@ -101,9 +101,9 @@ static gdouble _height_func(gdouble lat, gdouble lon, gpointer _elev) #define LOAD_BIL TRUE #define LOAD_OPENGL FALSE struct _LoadTileData { - GisPluginElev *elev; + GritsPluginElev *elev; gchar *path; - GisTile *tile; + GritsTile *tile; GdkPixbuf *pixbuf; struct _TileData *data; }; @@ -112,9 +112,9 @@ static guint16 *_load_bil(gchar *path) gsize len; gchar *data = NULL; g_file_get_contents(path, &data, &len, NULL); - g_debug("GisPluginElev: load_bil %p", data); + g_debug("GritsPluginElev: load_bil %p", data); if (len != TILE_SIZE) { - g_warning("GisPluginElev: _load_bil - unexpected tile size %d, != %d", + g_warning("GritsPluginElev: _load_bil - unexpected tile size %d, != %d", len, TILE_SIZE); g_free(data); return NULL; @@ -140,7 +140,7 @@ static GdkPixbuf *_load_pixbuf(guint16 *bil) pixels[r*stride + c*nchan + 3] = 128; } } - g_debug("GisPluginElev: load_pixbuf %p", pixbuf); + g_debug("GritsPluginElev: load_pixbuf %p", pixbuf); return pixbuf; } static guint _load_opengl(GdkPixbuf *pixbuf) @@ -166,15 +166,15 @@ static guint _load_opengl(GdkPixbuf *pixbuf) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); - g_debug("GisPluginElev: load_opengl %d", opengl); + g_debug("GritsPluginElev: load_opengl %d", opengl); return opengl; } static gboolean _load_tile_cb(gpointer _load) { struct _LoadTileData *load = _load; - g_debug("GisPluginElev: _load_tile_cb: %s", load->path); - GisPluginElev *elev = load->elev; - GisTile *tile = load->tile; + g_debug("GritsPluginElev: _load_tile_cb: %s", load->path); + GritsPluginElev *elev = load->elev; + GritsTile *tile = load->tile; GdkPixbuf *pixbuf = load->pixbuf; struct _TileData *data = load->data; g_free(load->path); @@ -188,7 +188,8 @@ static gboolean _load_tile_cb(gpointer _load) /* Do necessasairy processing */ /* TODO: Lock this and move to thread, can remove elev from _load then */ if (LOAD_BIL) - gis_viewer_set_height_func(elev->viewer, &tile->edge, _height_func, elev, TRUE); + grits_viewer_set_height_func(elev->viewer, &tile->edge, + _height_func, elev, TRUE); /* Cleanup unneeded things */ if (!LOAD_BIL) @@ -198,13 +199,13 @@ static gboolean _load_tile_cb(gpointer _load) return FALSE; } -static void _load_tile(GisTile *tile, gpointer _elev) +static void _load_tile(GritsTile *tile, gpointer _elev) { - GisPluginElev *elev = _elev; + GritsPluginElev *elev = _elev; struct _LoadTileData *load = g_new0(struct _LoadTileData, 1); - load->path = gis_wms_fetch(elev->wms, tile, GIS_ONCE, NULL, NULL); - g_debug("GisPluginElev: _load_tile: %s", load->path); + load->path = grits_wms_fetch(elev->wms, tile, GRITS_ONCE, NULL, NULL); + g_debug("GritsPluginElev: _load_tile: %s", load->path); load->elev = elev; load->tile = tile; load->data = g_new0(struct _TileData, 1); @@ -235,24 +236,24 @@ static gboolean _free_tile_cb(gpointer _data) g_free(data); return FALSE; } -static void _free_tile(GisTile *tile, gpointer _elev) +static void _free_tile(GritsTile *tile, gpointer _elev) { - g_debug("GisPluginElev: _free_tile: %p", tile->data); + g_debug("GritsPluginElev: _free_tile: %p", tile->data); if (tile->data) g_idle_add_full(G_PRIORITY_LOW, _free_tile_cb, tile->data, NULL); } static gpointer _update_tiles(gpointer _elev) { - GisPluginElev *elev = _elev; + GritsPluginElev *elev = _elev; if (!g_mutex_trylock(elev->mutex)) return NULL; - GisPoint eye; - gis_viewer_get_location(elev->viewer, &eye.lat, &eye.lon, &eye.elev); - gis_tile_update(elev->tiles, &eye, + GritsPoint eye; + grits_viewer_get_location(elev->viewer, &eye.lat, &eye.lon, &eye.elev); + grits_tile_update(elev->tiles, &eye, MAX_RESOLUTION, TILE_WIDTH, TILE_WIDTH, _load_tile, elev); - gis_tile_gc(elev->tiles, time(NULL)-10, + grits_tile_gc(elev->tiles, time(NULL)-10, _free_tile, elev); g_mutex_unlock(elev->mutex); return NULL; @@ -261,13 +262,13 @@ static gpointer _update_tiles(gpointer _elev) /************* * Callbacks * *************/ -static void _on_location_changed(GisViewer *viewer, - gdouble lat, gdouble lon, gdouble elevation, GisPluginElev *elev) +static void _on_location_changed(GritsViewer *viewer, + gdouble lat, gdouble lon, gdouble elevation, GritsPluginElev *elev) { g_thread_create(_update_tiles, elev, FALSE, NULL); } -static gpointer _threaded_init(GisPluginElev *elev) +static gpointer _threaded_init(GritsPluginElev *elev) { _load_tile(elev->tiles, elev); _update_tiles(elev); @@ -278,17 +279,17 @@ static gpointer _threaded_init(GisPluginElev *elev) * Methods * ***********/ /** - * gis_plugin_elev_new: - * @viewer: the #GisViewer to use for drawing + * grits_plugin_elev_new: + * @viewer: the #GritsViewer to use for drawing * * Create a new instance of the elevation plugin. * - * Returns: the new #GisPluginElev + * Returns: the new #GritsPluginElev */ -GisPluginElev *gis_plugin_elev_new(GisViewer *viewer) +GritsPluginElev *grits_plugin_elev_new(GritsViewer *viewer) { - g_debug("GisPluginElev: new"); - GisPluginElev *elev = g_object_new(GIS_TYPE_PLUGIN_ELEV, NULL); + g_debug("GritsPluginElev: new"); + GritsPluginElev *elev = g_object_new(GRITS_TYPE_PLUGIN_ELEV, NULL); elev->viewer = g_object_ref(viewer); /* Load initial tiles */ @@ -300,7 +301,7 @@ GisPluginElev *gis_plugin_elev_new(GisViewer *viewer) /* Add renderers */ if (LOAD_OPENGL) - gis_viewer_add(viewer, GIS_OBJECT(elev->tiles), GIS_LEVEL_WORLD, 0); + grits_viewer_add(viewer, GRITS_OBJECT(elev->tiles), GRITS_LEVEL_WORLD, 0); return elev; } @@ -310,55 +311,55 @@ GisPluginElev *gis_plugin_elev_new(GisViewer *viewer) * GObject code * ****************/ /* Plugin init */ -static void gis_plugin_elev_plugin_init(GisPluginInterface *iface); -G_DEFINE_TYPE_WITH_CODE(GisPluginElev, gis_plugin_elev, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE(GIS_TYPE_PLUGIN, - gis_plugin_elev_plugin_init)); -static void gis_plugin_elev_plugin_init(GisPluginInterface *iface) +static void grits_plugin_elev_plugin_init(GritsPluginInterface *iface); +G_DEFINE_TYPE_WITH_CODE(GritsPluginElev, grits_plugin_elev, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE(GRITS_TYPE_PLUGIN, + grits_plugin_elev_plugin_init)); +static void grits_plugin_elev_plugin_init(GritsPluginInterface *iface) { - g_debug("GisPluginElev: plugin_init"); + g_debug("GritsPluginElev: plugin_init"); /* Add methods to the interface */ } /* Class/Object init */ -static void gis_plugin_elev_init(GisPluginElev *elev) +static void grits_plugin_elev_init(GritsPluginElev *elev) { - g_debug("GisPluginElev: init"); + g_debug("GritsPluginElev: init"); /* Set defaults */ elev->mutex = g_mutex_new(); - elev->tiles = gis_tile_new(NULL, NORTH, SOUTH, EAST, WEST); - elev->wms = gis_wms_new( + elev->tiles = grits_tile_new(NULL, NORTH, SOUTH, EAST, WEST); + elev->wms = grits_wms_new( "http://www.nasa.network.com/elev", "srtm30", "application/bil", "srtm/", "bil", TILE_WIDTH, TILE_HEIGHT); } -static void gis_plugin_elev_dispose(GObject *gobject) +static void grits_plugin_elev_dispose(GObject *gobject) { - g_debug("GisPluginElev: dispose"); - GisPluginElev *elev = GIS_PLUGIN_ELEV(gobject); + g_debug("GritsPluginElev: dispose"); + GritsPluginElev *elev = GRITS_PLUGIN_ELEV(gobject); /* Drop references */ if (LOAD_BIL) - gis_viewer_clear_height_func(elev->viewer); + grits_viewer_clear_height_func(elev->viewer); if (elev->viewer) { g_signal_handler_disconnect(elev->viewer, elev->sigid); g_object_unref(elev->viewer); elev->viewer = NULL; } - G_OBJECT_CLASS(gis_plugin_elev_parent_class)->dispose(gobject); + G_OBJECT_CLASS(grits_plugin_elev_parent_class)->dispose(gobject); } -static void gis_plugin_elev_finalize(GObject *gobject) +static void grits_plugin_elev_finalize(GObject *gobject) { - g_debug("GisPluginElev: finalize"); - GisPluginElev *elev = GIS_PLUGIN_ELEV(gobject); + g_debug("GritsPluginElev: finalize"); + GritsPluginElev *elev = GRITS_PLUGIN_ELEV(gobject); /* Free data */ - gis_tile_free(elev->tiles, _free_tile, elev); - gis_wms_free(elev->wms); + grits_tile_free(elev->tiles, _free_tile, elev); + grits_wms_free(elev->wms); g_mutex_free(elev->mutex); - G_OBJECT_CLASS(gis_plugin_elev_parent_class)->finalize(gobject); + G_OBJECT_CLASS(grits_plugin_elev_parent_class)->finalize(gobject); } -static void gis_plugin_elev_class_init(GisPluginElevClass *klass) +static void grits_plugin_elev_class_init(GritsPluginElevClass *klass) { - g_debug("GisPluginElev: class_init"); + g_debug("GritsPluginElev: class_init"); GObjectClass *gobject_class = (GObjectClass*)klass; - gobject_class->dispose = gis_plugin_elev_dispose; - gobject_class->finalize = gis_plugin_elev_finalize; + gobject_class->dispose = grits_plugin_elev_dispose; + gobject_class->finalize = grits_plugin_elev_finalize; } diff --git a/src/plugins/elev.h b/src/plugins/elev.h index d32352b..9f09c3e 100644 --- a/src/plugins/elev.h +++ b/src/plugins/elev.h @@ -20,34 +20,34 @@ #include -#define GIS_TYPE_PLUGIN_ELEV (gis_plugin_elev_get_type ()) -#define GIS_PLUGIN_ELEV(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GIS_TYPE_PLUGIN_ELEV, GisPluginElev)) -#define GIS_IS_PLUGIN_ELEV(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GIS_TYPE_PLUGIN_ELEV)) -#define GIS_PLUGIN_ELEV_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIS_TYPE_PLUGIN_ELEV, GisPluginElevClass)) -#define GIS_IS_PLUGIN_ELEV_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIS_TYPE_PLUGIN_ELEV)) -#define GIS_PLUGIN_ELEV_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIS_TYPE_PLUGIN_ELEV, GisPluginElevClass)) +#define GRITS_TYPE_PLUGIN_ELEV (grits_plugin_elev_get_type ()) +#define GRITS_PLUGIN_ELEV(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GRITS_TYPE_PLUGIN_ELEV, GritsPluginElev)) +#define GRITS_IS_PLUGIN_ELEV(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GRITS_TYPE_PLUGIN_ELEV)) +#define GRITS_PLUGIN_ELEV_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRITS_TYPE_PLUGIN_ELEV, GritsPluginElevClass)) +#define GRITS_IS_PLUGIN_ELEV_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRITS_TYPE_PLUGIN_ELEV)) +#define GRITS_PLUGIN_ELEV_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GRITS_TYPE_PLUGIN_ELEV, GritsPluginElevClass)) -typedef struct _GisPluginElev GisPluginElev; -typedef struct _GisPluginElevClass GisPluginElevClass; +typedef struct _GritsPluginElev GritsPluginElev; +typedef struct _GritsPluginElevClass GritsPluginElevClass; -struct _GisPluginElev { +struct _GritsPluginElev { GObject parent_instance; /* instance members */ - GisViewer *viewer; - GisTile *tiles; - GisWms *wms; - GMutex *mutex; - gulong sigid; + GritsViewer *viewer; + GritsTile *tiles; + GritsWms *wms; + GMutex *mutex; + gulong sigid; }; -struct _GisPluginElevClass { +struct _GritsPluginElevClass { GObjectClass parent_class; }; -GType gis_plugin_elev_get_type(); +GType grits_plugin_elev_get_type(); /* Methods */ -GisPluginElev *gis_plugin_elev_new(GisViewer *viewer); +GritsPluginElev *grits_plugin_elev_new(GritsViewer *viewer); #endif diff --git a/src/plugins/env.c b/src/plugins/env.c index 129e759..3a1f324 100644 --- a/src/plugins/env.c +++ b/src/plugins/env.c @@ -19,7 +19,7 @@ * SECTION:env * @short_description: Environment plugin * - * #GisPluginEnv provides environmental information such as sky images. It can + * #GritsPluginEnv provides environmental information such as sky images. It can * also paint a blank overlay on the surface so that other plugins can draw * transparent overlays nicely. */ @@ -35,13 +35,13 @@ /*********** * Helpers * ***********/ -static void expose(GisCallback *callback, GisOpenGL *opengl, gpointer _env) +static void expose(GritsCallback *callback, GritsOpenGL *opengl, gpointer _env) { - GisPluginEnv *env = GIS_PLUGIN_ENV(_env); - g_debug("GisPluginEnv: expose"); + GritsPluginEnv *env = GRITS_PLUGIN_ENV(_env); + g_debug("GritsPluginEnv: expose"); gdouble lat, lon, elev; - gis_viewer_get_location(env->viewer, &lat, &lon, &elev); + grits_viewer_get_location(env->viewer, &lat, &lon, &elev); /* Misc */ gdouble rg = MAX(0, 1-(elev/40000)); @@ -55,7 +55,7 @@ static void expose(GisCallback *callback, GisOpenGL *opengl, gpointer _env) glDisable(GL_LIGHTING); glMatrixMode(GL_MODELVIEW); glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA); - gis_viewer_center_position(env->viewer, lat, lon, -EARTH_R); + grits_viewer_center_position(env->viewer, lat, lon, -EARTH_R); gdouble ds = EARTH_R+elev; // distance to self gdouble da = EARTH_R+300000; // distance to top of atmosphere @@ -82,30 +82,30 @@ static void expose(GisCallback *callback, GisOpenGL *opengl, gpointer _env) * Methods * ***********/ /** - * gis_plugin_env_new: - * @viewer: the #GisViewer to use for drawing - * @prefs: the #GisPrefs for storing configurations + * grits_plugin_env_new: + * @viewer: the #GritsViewer to use for drawing + * @prefs: the #GritsPrefs for storing configurations * * Create a new instance of the environment plugin. * - * Returns: the new #GisPluginEnv + * Returns: the new #GritsPluginEnv */ -GisPluginEnv *gis_plugin_env_new(GisViewer *viewer, GisPrefs *prefs) +GritsPluginEnv *grits_plugin_env_new(GritsViewer *viewer, GritsPrefs *prefs) { - g_debug("GisPluginEnv: new"); - GisPluginEnv *env = g_object_new(GIS_TYPE_PLUGIN_ENV, NULL); + g_debug("GritsPluginEnv: new"); + GritsPluginEnv *env = g_object_new(GRITS_TYPE_PLUGIN_ENV, NULL); env->viewer = g_object_ref(viewer); /* Create objects */ - GisCallback *callback = gis_callback_new(expose, env); - GisTile *background = gis_tile_new(NULL, NORTH, SOUTH, EAST, WEST); + GritsCallback *callback = grits_callback_new(expose, env); + GritsTile *background = grits_tile_new(NULL, NORTH, SOUTH, EAST, WEST); glGenTextures(1, &env->tex); background->data = &env->tex; /* Add renderers */ gpointer ref1, ref2; - ref1 = gis_viewer_add(viewer, GIS_OBJECT(callback), GIS_LEVEL_BACKGROUND, FALSE); - ref2 = gis_viewer_add(viewer, GIS_OBJECT(background), GIS_LEVEL_BACKGROUND, FALSE); + ref1 = grits_viewer_add(viewer, GRITS_OBJECT(callback), GRITS_LEVEL_BACKGROUND, FALSE); + ref2 = grits_viewer_add(viewer, GRITS_OBJECT(background), GRITS_LEVEL_BACKGROUND, FALSE); env->refs = g_list_prepend(env->refs, ref1); env->refs = g_list_prepend(env->refs, ref2); @@ -117,39 +117,39 @@ GisPluginEnv *gis_plugin_env_new(GisViewer *viewer, GisPrefs *prefs) * GObject code * ****************/ /* Plugin init */ -static void gis_plugin_env_plugin_init(GisPluginInterface *iface); -G_DEFINE_TYPE_WITH_CODE(GisPluginEnv, gis_plugin_env, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE(GIS_TYPE_PLUGIN, - gis_plugin_env_plugin_init)); -static void gis_plugin_env_plugin_init(GisPluginInterface *iface) +static void grits_plugin_env_plugin_init(GritsPluginInterface *iface); +G_DEFINE_TYPE_WITH_CODE(GritsPluginEnv, grits_plugin_env, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE(GRITS_TYPE_PLUGIN, + grits_plugin_env_plugin_init)); +static void grits_plugin_env_plugin_init(GritsPluginInterface *iface) { - g_debug("GisPluginEnv: plugin_init"); + g_debug("GritsPluginEnv: plugin_init"); /* Add methods to the interface */ } /* Class/Object init */ -static void gis_plugin_env_init(GisPluginEnv *env) +static void grits_plugin_env_init(GritsPluginEnv *env) { - g_debug("GisPluginEnv: init"); + g_debug("GritsPluginEnv: init"); /* Set defaults */ } -static void gis_plugin_env_dispose(GObject *gobject) +static void grits_plugin_env_dispose(GObject *gobject) { - g_debug("GisPluginEnv: dispose"); - GisPluginEnv *env = GIS_PLUGIN_ENV(gobject); + g_debug("GritsPluginEnv: dispose"); + GritsPluginEnv *env = GRITS_PLUGIN_ENV(gobject); /* Drop references */ if (env->viewer) { for (GList *cur = env->refs; cur; cur = cur->next) - gis_viewer_remove(env->viewer, cur->data); + grits_viewer_remove(env->viewer, cur->data); g_list_free(env->refs); g_object_unref(env->viewer); glDeleteTextures(1, &env->tex); env->viewer = NULL; } - G_OBJECT_CLASS(gis_plugin_env_parent_class)->dispose(gobject); + G_OBJECT_CLASS(grits_plugin_env_parent_class)->dispose(gobject); } -static void gis_plugin_env_class_init(GisPluginEnvClass *klass) +static void grits_plugin_env_class_init(GritsPluginEnvClass *klass) { - g_debug("GisPluginEnv: class_init"); + g_debug("GritsPluginEnv: class_init"); GObjectClass *gobject_class = (GObjectClass*)klass; - gobject_class->dispose = gis_plugin_env_dispose; + gobject_class->dispose = grits_plugin_env_dispose; } diff --git a/src/plugins/env.h b/src/plugins/env.h index 7b73a2e..0f5b7f7 100644 --- a/src/plugins/env.h +++ b/src/plugins/env.h @@ -20,33 +20,33 @@ #include -#define GIS_TYPE_PLUGIN_ENV (gis_plugin_env_get_type ()) -#define GIS_PLUGIN_ENV(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GIS_TYPE_PLUGIN_ENV, GisPluginEnv)) -#define GIS_IS_PLUGIN_ENV(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GIS_TYPE_PLUGIN_ENV)) -#define GIS_PLUGIN_ENV_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIS_TYPE_PLUGIN_ENV, GisPluginEnvClass)) -#define GIS_IS_PLUGIN_ENV_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIS_TYPE_PLUGIN_ENV)) -#define GIS_PLUGIN_ENV_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIS_TYPE_PLUGIN_ENV, GisPluginEnvClass)) +#define GRITS_TYPE_PLUGIN_ENV (grits_plugin_env_get_type ()) +#define GRITS_PLUGIN_ENV(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GRITS_TYPE_PLUGIN_ENV, GritsPluginEnv)) +#define GRITS_IS_PLUGIN_ENV(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GRITS_TYPE_PLUGIN_ENV)) +#define GRITS_PLUGIN_ENV_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRITS_TYPE_PLUGIN_ENV, GritsPluginEnvClass)) +#define GRITS_IS_PLUGIN_ENV_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRITS_TYPE_PLUGIN_ENV)) +#define GRITS_PLUGIN_ENV_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GRITS_TYPE_PLUGIN_ENV, GritsPluginEnvClass)) -typedef struct _GisPluginEnv GisPluginEnv; -typedef struct _GisPluginEnvClass GisPluginEnvClass; +typedef struct _GritsPluginEnv GritsPluginEnv; +typedef struct _GritsPluginEnvClass GritsPluginEnvClass; -struct _GisPluginEnv { +struct _GritsPluginEnv { GObject parent_instance; /* instance members */ - GisViewer *viewer; - guint tex; - GisTile *background; - GList *refs; + GritsViewer *viewer; + guint tex; + GritsTile *background; + GList *refs; }; -struct _GisPluginEnvClass { +struct _GritsPluginEnvClass { GObjectClass parent_class; }; -GType gis_plugin_env_get_type(); +GType grits_plugin_env_get_type(); /* Methods */ -GisPluginEnv *gis_plugin_env_new(GisViewer *viewer, GisPrefs *prefs); +GritsPluginEnv *grits_plugin_env_new(GritsViewer *viewer, GritsPrefs *prefs); #endif diff --git a/src/plugins/map.c b/src/plugins/map.c index 13e9185..6c73796 100644 --- a/src/plugins/map.c +++ b/src/plugins/map.c @@ -19,7 +19,7 @@ * SECTION:map * @short_description: Map plugin * - * #GisPluginMap provides map overlays. Much of this data is obtained from the + * #GritsPluginMap provides map overlays. Much of this data is obtained from the * OpenStreetMap project. */ @@ -45,23 +45,23 @@ static const guchar colormap[][2][4] = { }; struct _LoadTileData { - GisPluginMap *map; - GisTile *tile; - gchar *path; + GritsPluginMap *map; + GritsTile *tile; + gchar *path; }; static gboolean _load_tile_cb(gpointer _data) { struct _LoadTileData *data = _data; - GisPluginMap *map = data->map; - GisTile *tile = data->tile; - gchar *path = data->path; + GritsPluginMap *map = data->map; + GritsTile *tile = data->tile; + gchar *path = data->path; g_free(data); /* Load pixbuf */ - g_debug("GisPluginMap: _load_tile_cb start"); + g_debug("GritsPluginMap: _load_tile_cb start"); GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(path, NULL); if (!pixbuf) { - g_warning("GisPluginMap: _load_tile - Error loading pixbuf %s", path); + g_warning("GritsPluginMap: _load_tile - Error loading pixbuf %s", path); g_remove(path); g_free(path); return FALSE; @@ -108,16 +108,16 @@ static gboolean _load_tile_cb(gpointer _data) return FALSE; } -static void _load_tile(GisTile *tile, gpointer _map) +static void _load_tile(GritsTile *tile, gpointer _map) { - GisPluginMap *map = _map; - g_debug("GisPluginMap: _load_tile start %p", g_thread_self()); + GritsPluginMap *map = _map; + g_debug("GritsPluginMap: _load_tile start %p", g_thread_self()); struct _LoadTileData *data = g_new0(struct _LoadTileData, 1); data->map = map; data->tile = tile; - data->path = gis_wms_fetch(map->wms, tile, GIS_ONCE, NULL, NULL); + data->path = grits_wms_fetch(map->wms, tile, GRITS_ONCE, NULL, NULL); g_idle_add_full(G_PRIORITY_LOW, _load_tile_cb, data, NULL); - g_debug("GisPluginMap: _load_tile end %p", g_thread_self()); + g_debug("GritsPluginMap: _load_tile end %p", g_thread_self()); } static gboolean _free_tile_cb(gpointer data) @@ -126,25 +126,25 @@ static gboolean _free_tile_cb(gpointer data) g_free(data); return FALSE; } -static void _free_tile(GisTile *tile, gpointer _map) +static void _free_tile(GritsTile *tile, gpointer _map) { - g_debug("GisPluginMap: _free_tile: %p", tile->data); + g_debug("GritsPluginMap: _free_tile: %p", tile->data); if (tile->data) g_idle_add_full(G_PRIORITY_LOW, _free_tile_cb, tile->data, NULL); } static gpointer _update_tiles(gpointer _map) { - g_debug("GisPluginMap: _update_tiles"); - GisPluginMap *map = _map; + g_debug("GritsPluginMap: _update_tiles"); + GritsPluginMap *map = _map; if (!g_mutex_trylock(map->mutex)) return NULL; - GisPoint eye; - gis_viewer_get_location(map->viewer, &eye.lat, &eye.lon, &eye.elev); - gis_tile_update(map->tiles, &eye, + GritsPoint eye; + grits_viewer_get_location(map->viewer, &eye.lat, &eye.lon, &eye.elev); + grits_tile_update(map->tiles, &eye, MAX_RESOLUTION, TILE_WIDTH, TILE_WIDTH, _load_tile, map); - gis_tile_gc(map->tiles, time(NULL)-10, + grits_tile_gc(map->tiles, time(NULL)-10, _free_tile, map); g_mutex_unlock(map->mutex); return NULL; @@ -153,13 +153,13 @@ static gpointer _update_tiles(gpointer _map) /************* * Callbacks * *************/ -static void _on_location_changed(GisViewer *viewer, - gdouble lat, gdouble lon, gdouble elev, GisPluginMap *map) +static void _on_location_changed(GritsViewer *viewer, + gdouble lat, gdouble lon, gdouble elev, GritsPluginMap *map) { g_thread_create(_update_tiles, map, FALSE, NULL); } -static gpointer _threaded_init(GisPluginMap *map) +static gpointer _threaded_init(GritsPluginMap *map) { _load_tile(map->tiles, map); _update_tiles(map); @@ -170,17 +170,17 @@ static gpointer _threaded_init(GisPluginMap *map) * Methods * ***********/ /** - * gis_plugin_map_new: - * @viewer: the #GisViewer to use for drawing + * grits_plugin_map_new: + * @viewer: the #GritsViewer to use for drawing * * Create a new instance of the map plugin. * - * Returns: the new #GisPluginMap + * Returns: the new #GritsPluginMap */ -GisPluginMap *gis_plugin_map_new(GisViewer *viewer) +GritsPluginMap *grits_plugin_map_new(GritsViewer *viewer) { - g_debug("GisPluginMap: new"); - GisPluginMap *map = g_object_new(GIS_TYPE_PLUGIN_MAP, NULL); + g_debug("GritsPluginMap: new"); + GritsPluginMap *map = g_object_new(GRITS_TYPE_PLUGIN_MAP, NULL); map->viewer = g_object_ref(viewer); /* Load initial tiles */ @@ -191,7 +191,7 @@ GisPluginMap *gis_plugin_map_new(GisViewer *viewer) G_CALLBACK(_on_location_changed), map); /* Add renderers */ - gis_viewer_add(viewer, GIS_OBJECT(map->tiles), GIS_LEVEL_OVERLAY-1, 0); + grits_viewer_add(viewer, GRITS_OBJECT(map->tiles), GRITS_LEVEL_OVERLAY-1, 0); return map; } @@ -201,53 +201,53 @@ GisPluginMap *gis_plugin_map_new(GisViewer *viewer) * GObject code * ****************/ /* Plugin init */ -static void gis_plugin_map_plugin_init(GisPluginInterface *iface); -G_DEFINE_TYPE_WITH_CODE(GisPluginMap, gis_plugin_map, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE(GIS_TYPE_PLUGIN, - gis_plugin_map_plugin_init)); -static void gis_plugin_map_plugin_init(GisPluginInterface *iface) +static void grits_plugin_map_plugin_init(GritsPluginInterface *iface); +G_DEFINE_TYPE_WITH_CODE(GritsPluginMap, grits_plugin_map, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE(GRITS_TYPE_PLUGIN, + grits_plugin_map_plugin_init)); +static void grits_plugin_map_plugin_init(GritsPluginInterface *iface) { - g_debug("GisPluginMap: plugin_init"); + g_debug("GritsPluginMap: plugin_init"); /* Add methods to the interface */ } /* Class/Object init */ -static void gis_plugin_map_init(GisPluginMap *map) +static void grits_plugin_map_init(GritsPluginMap *map) { - g_debug("GisPluginMap: init"); + g_debug("GritsPluginMap: init"); /* Set defaults */ - map->mutex = g_mutex_new(); - map->tiles = gis_tile_new(NULL, NORTH, SOUTH, EAST, WEST); - map->wms = gis_wms_new( + map->mutex = g_mutex_new(); + map->tiles = grits_tile_new(NULL, NORTH, SOUTH, EAST, WEST); + map->wms = grits_wms_new( "http://labs.metacarta.com/wms/vmap0", "basic", "image/png", "osm/", "png", TILE_WIDTH, TILE_HEIGHT); } -static void gis_plugin_map_dispose(GObject *gobject) +static void grits_plugin_map_dispose(GObject *gobject) { - g_debug("GisPluginMap: dispose"); - GisPluginMap *map = GIS_PLUGIN_MAP(gobject); + g_debug("GritsPluginMap: dispose"); + GritsPluginMap *map = GRITS_PLUGIN_MAP(gobject); /* Drop references */ if (map->viewer) { g_signal_handler_disconnect(map->viewer, map->sigid); g_object_unref(map->viewer); map->viewer = NULL; } - G_OBJECT_CLASS(gis_plugin_map_parent_class)->dispose(gobject); + G_OBJECT_CLASS(grits_plugin_map_parent_class)->dispose(gobject); } -static void gis_plugin_map_finalize(GObject *gobject) +static void grits_plugin_map_finalize(GObject *gobject) { - g_debug("GisPluginMap: finalize"); - GisPluginMap *map = GIS_PLUGIN_MAP(gobject); + g_debug("GritsPluginMap: finalize"); + GritsPluginMap *map = GRITS_PLUGIN_MAP(gobject); /* Free data */ - gis_tile_free(map->tiles, _free_tile, map); - gis_wms_free(map->wms); + grits_tile_free(map->tiles, _free_tile, map); + grits_wms_free(map->wms); g_mutex_free(map->mutex); - G_OBJECT_CLASS(gis_plugin_map_parent_class)->finalize(gobject); + G_OBJECT_CLASS(grits_plugin_map_parent_class)->finalize(gobject); } -static void gis_plugin_map_class_init(GisPluginMapClass *klass) +static void grits_plugin_map_class_init(GritsPluginMapClass *klass) { - g_debug("GisPluginMap: class_init"); + g_debug("GritsPluginMap: class_init"); GObjectClass *gobject_class = (GObjectClass*)klass; - gobject_class->dispose = gis_plugin_map_dispose; - gobject_class->finalize = gis_plugin_map_finalize; + gobject_class->dispose = grits_plugin_map_dispose; + gobject_class->finalize = grits_plugin_map_finalize; } diff --git a/src/plugins/map.h b/src/plugins/map.h index 406fff9..91741e2 100644 --- a/src/plugins/map.h +++ b/src/plugins/map.h @@ -20,34 +20,34 @@ #include -#define GIS_TYPE_PLUGIN_MAP (gis_plugin_map_get_type ()) -#define GIS_PLUGIN_MAP(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GIS_TYPE_PLUGIN_MAP, GisPluginMap)) -#define GIS_IS_PLUGIN_MAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GIS_TYPE_PLUGIN_MAP)) -#define GIS_PLUGIN_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIS_TYPE_PLUGIN_MAP, GisPluginMapClass)) -#define GIS_IS_PLUGIN_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIS_TYPE_PLUGIN_MAP)) -#define GIS_PLUGIN_MAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIS_TYPE_PLUGIN_MAP, GisPluginMapClass)) +#define GRITS_TYPE_PLUGIN_MAP (grits_plugin_map_get_type ()) +#define GRITS_PLUGIN_MAP(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GRITS_TYPE_PLUGIN_MAP, GritsPluginMap)) +#define GRITS_IS_PLUGIN_MAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GRITS_TYPE_PLUGIN_MAP)) +#define GRITS_PLUGIN_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRITS_TYPE_PLUGIN_MAP, GritsPluginMapClass)) +#define GRITS_IS_PLUGIN_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRITS_TYPE_PLUGIN_MAP)) +#define GRITS_PLUGIN_MAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GRITS_TYPE_PLUGIN_MAP, GritsPluginMapClass)) -typedef struct _GisPluginMap GisPluginMap; -typedef struct _GisPluginMapClass GisPluginMapClass; +typedef struct _GritsPluginMap GritsPluginMap; +typedef struct _GritsPluginMapClass GritsPluginMapClass; -struct _GisPluginMap { +struct _GritsPluginMap { GObject parent_instance; /* instance members */ - GisViewer *viewer; - GisTile *tiles; - GisWms *wms; - GMutex *mutex; - gulong sigid; + GritsViewer *viewer; + GritsTile *tiles; + GritsWms *wms; + GMutex *mutex; + gulong sigid; }; -struct _GisPluginMapClass { +struct _GritsPluginMapClass { GObjectClass parent_class; }; -GType gis_plugin_map_get_type(); +GType grits_plugin_map_get_type(); /* Methods */ -GisPluginMap *gis_plugin_map_new(GisViewer *viewer); +GritsPluginMap *grits_plugin_map_new(GritsViewer *viewer); #endif diff --git a/src/plugins/sat.c b/src/plugins/sat.c index 3ae85b9..29a7d26 100644 --- a/src/plugins/sat.c +++ b/src/plugins/sat.c @@ -19,7 +19,7 @@ * SECTION:sat * @short_description: Satellite plugin * - * #GisPluginSat provides overlays using satellite imagery. This is mostly + * #GritsPluginSat provides overlays using satellite imagery. This is mostly * provided by NASA's Blue Marble Next Generation. */ @@ -37,23 +37,23 @@ #define TILE_HEIGHT 512 struct _LoadTileData { - GisPluginSat *sat; - GisTile *tile; - gchar *path; + GritsPluginSat *sat; + GritsTile *tile; + gchar *path; }; static gboolean _load_tile_cb(gpointer _data) { struct _LoadTileData *data = _data; - GisPluginSat *sat = data->sat; - GisTile *tile = data->tile; - gchar *path = data->path; + GritsPluginSat *sat = data->sat; + GritsTile *tile = data->tile; + gchar *path = data->path; g_free(data); /* Load pixbuf */ - g_debug("GisPluginSat: _load_tile_cb start"); + g_debug("GritsPluginSat: _load_tile_cb start"); GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(path, NULL); if (!pixbuf) { - g_warning("GisPluginSat: _load_tile - Error loading pixbuf %s", path); + g_warning("GritsPluginSat: _load_tile - Error loading pixbuf %s", path); g_remove(path); g_free(path); return FALSE; @@ -98,16 +98,16 @@ static gboolean _load_tile_cb(gpointer _data) return FALSE; } -static void _load_tile(GisTile *tile, gpointer _sat) +static void _load_tile(GritsTile *tile, gpointer _sat) { - GisPluginSat *sat = _sat; - g_debug("GisPluginSat: _load_tile start %p", g_thread_self()); + GritsPluginSat *sat = _sat; + g_debug("GritsPluginSat: _load_tile start %p", g_thread_self()); struct _LoadTileData *data = g_new0(struct _LoadTileData, 1); data->sat = sat; data->tile = tile; - data->path = gis_wms_fetch(sat->wms, tile, GIS_ONCE, NULL, NULL); + data->path = grits_wms_fetch(sat->wms, tile, GRITS_ONCE, NULL, NULL); g_idle_add_full(G_PRIORITY_LOW, _load_tile_cb, data, NULL); - g_debug("GisPluginSat: _load_tile end %p", g_thread_self()); + g_debug("GritsPluginSat: _load_tile end %p", g_thread_self()); } static gboolean _free_tile_cb(gpointer data) @@ -116,25 +116,25 @@ static gboolean _free_tile_cb(gpointer data) g_free(data); return FALSE; } -static void _free_tile(GisTile *tile, gpointer _sat) +static void _free_tile(GritsTile *tile, gpointer _sat) { - g_debug("GisPluginSat: _free_tile: %p", tile->data); + g_debug("GritsPluginSat: _free_tile: %p", tile->data); if (tile->data) g_idle_add_full(G_PRIORITY_LOW, _free_tile_cb, tile->data, NULL); } static gpointer _update_tiles(gpointer _sat) { - g_debug("GisPluginSat: _update_tiles"); - GisPluginSat *sat = _sat; + g_debug("GritsPluginSat: _update_tiles"); + GritsPluginSat *sat = _sat; if (!g_mutex_trylock(sat->mutex)) return NULL; - GisPoint eye; - gis_viewer_get_location(sat->viewer, &eye.lat, &eye.lon, &eye.elev); - gis_tile_update(sat->tiles, &eye, + GritsPoint eye; + grits_viewer_get_location(sat->viewer, &eye.lat, &eye.lon, &eye.elev); + grits_tile_update(sat->tiles, &eye, MAX_RESOLUTION, TILE_WIDTH, TILE_WIDTH, _load_tile, sat); - gis_tile_gc(sat->tiles, time(NULL)-10, + grits_tile_gc(sat->tiles, time(NULL)-10, _free_tile, sat); g_mutex_unlock(sat->mutex); return NULL; @@ -143,13 +143,13 @@ static gpointer _update_tiles(gpointer _sat) /************* * Callbacks * *************/ -static void _on_location_changed(GisViewer *viewer, - gdouble lat, gdouble lon, gdouble elev, GisPluginSat *sat) +static void _on_location_changed(GritsViewer *viewer, + gdouble lat, gdouble lon, gdouble elev, GritsPluginSat *sat) { g_thread_create(_update_tiles, sat, FALSE, NULL); } -static gpointer _threaded_init(GisPluginSat *sat) +static gpointer _threaded_init(GritsPluginSat *sat) { _load_tile(sat->tiles, sat); _update_tiles(sat); @@ -160,17 +160,17 @@ static gpointer _threaded_init(GisPluginSat *sat) * Methods * ***********/ /** - * gis_plugin_sat_new: - * @viewer: the #GisViewer to use for drawing + * grits_plugin_sat_new: + * @viewer: the #GritsViewer to use for drawing * * Create a new instance of the satellite plugin. * - * Returns: the new #GisPluginSat + * Returns: the new #GritsPluginSat */ -GisPluginSat *gis_plugin_sat_new(GisViewer *viewer) +GritsPluginSat *grits_plugin_sat_new(GritsViewer *viewer) { - g_debug("GisPluginSat: new"); - GisPluginSat *sat = g_object_new(GIS_TYPE_PLUGIN_SAT, NULL); + g_debug("GritsPluginSat: new"); + GritsPluginSat *sat = g_object_new(GRITS_TYPE_PLUGIN_SAT, NULL); sat->viewer = g_object_ref(viewer); /* Load initial tiles */ @@ -181,7 +181,7 @@ GisPluginSat *gis_plugin_sat_new(GisViewer *viewer) G_CALLBACK(_on_location_changed), sat); /* Add renderers */ - gis_viewer_add(viewer, GIS_OBJECT(sat->tiles), GIS_LEVEL_WORLD, FALSE); + grits_viewer_add(viewer, GRITS_OBJECT(sat->tiles), GRITS_LEVEL_WORLD, FALSE); return sat; } @@ -191,53 +191,53 @@ GisPluginSat *gis_plugin_sat_new(GisViewer *viewer) * GObject code * ****************/ /* Plugin init */ -static void gis_plugin_sat_plugin_init(GisPluginInterface *iface); -G_DEFINE_TYPE_WITH_CODE(GisPluginSat, gis_plugin_sat, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE(GIS_TYPE_PLUGIN, - gis_plugin_sat_plugin_init)); -static void gis_plugin_sat_plugin_init(GisPluginInterface *iface) +static void grits_plugin_sat_plugin_init(GritsPluginInterface *iface); +G_DEFINE_TYPE_WITH_CODE(GritsPluginSat, grits_plugin_sat, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE(GRITS_TYPE_PLUGIN, + grits_plugin_sat_plugin_init)); +static void grits_plugin_sat_plugin_init(GritsPluginInterface *iface) { - g_debug("GisPluginSat: plugin_init"); + g_debug("GritsPluginSat: plugin_init"); /* Add methods to the interface */ } /* Class/Object init */ -static void gis_plugin_sat_init(GisPluginSat *sat) +static void grits_plugin_sat_init(GritsPluginSat *sat) { - g_debug("GisPluginSat: init"); + g_debug("GritsPluginSat: init"); /* Set defaults */ sat->mutex = g_mutex_new(); - sat->tiles = gis_tile_new(NULL, NORTH, SOUTH, EAST, WEST); - sat->wms = gis_wms_new( + sat->tiles = grits_tile_new(NULL, NORTH, SOUTH, EAST, WEST); + sat->wms = grits_wms_new( "http://www.nasa.network.com/wms", "bmng200406", "image/jpeg", "bmng/", "jpg", TILE_WIDTH, TILE_HEIGHT); } -static void gis_plugin_sat_dispose(GObject *gobject) +static void grits_plugin_sat_dispose(GObject *gobject) { - g_debug("GisPluginSat: dispose"); - GisPluginSat *sat = GIS_PLUGIN_SAT(gobject); + g_debug("GritsPluginSat: dispose"); + GritsPluginSat *sat = GRITS_PLUGIN_SAT(gobject); /* Drop references */ if (sat->viewer) { g_signal_handler_disconnect(sat->viewer, sat->sigid); g_object_unref(sat->viewer); sat->viewer = NULL; } - G_OBJECT_CLASS(gis_plugin_sat_parent_class)->dispose(gobject); + G_OBJECT_CLASS(grits_plugin_sat_parent_class)->dispose(gobject); } -static void gis_plugin_sat_finalize(GObject *gobject) +static void grits_plugin_sat_finalize(GObject *gobject) { - g_debug("GisPluginSat: finalize"); - GisPluginSat *sat = GIS_PLUGIN_SAT(gobject); + g_debug("GritsPluginSat: finalize"); + GritsPluginSat *sat = GRITS_PLUGIN_SAT(gobject); /* Free data */ - gis_tile_free(sat->tiles, _free_tile, sat); - gis_wms_free(sat->wms); + grits_tile_free(sat->tiles, _free_tile, sat); + grits_wms_free(sat->wms); g_mutex_free(sat->mutex); - G_OBJECT_CLASS(gis_plugin_sat_parent_class)->finalize(gobject); + G_OBJECT_CLASS(grits_plugin_sat_parent_class)->finalize(gobject); } -static void gis_plugin_sat_class_init(GisPluginSatClass *klass) +static void grits_plugin_sat_class_init(GritsPluginSatClass *klass) { - g_debug("GisPluginSat: class_init"); + g_debug("GritsPluginSat: class_init"); GObjectClass *gobject_class = (GObjectClass*)klass; - gobject_class->dispose = gis_plugin_sat_dispose; - gobject_class->finalize = gis_plugin_sat_finalize; + gobject_class->dispose = grits_plugin_sat_dispose; + gobject_class->finalize = grits_plugin_sat_finalize; } diff --git a/src/plugins/sat.h b/src/plugins/sat.h index 9669fe0..b871741 100644 --- a/src/plugins/sat.h +++ b/src/plugins/sat.h @@ -20,34 +20,34 @@ #include -#define GIS_TYPE_PLUGIN_SAT (gis_plugin_sat_get_type ()) -#define GIS_PLUGIN_SAT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GIS_TYPE_PLUGIN_SAT, GisPluginSat)) -#define GIS_IS_PLUGIN_SAT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GIS_TYPE_PLUGIN_SAT)) -#define GIS_PLUGIN_SAT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIS_TYPE_PLUGIN_SAT, GisPluginSatClass)) -#define GIS_IS_PLUGIN_SAT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIS_TYPE_PLUGIN_SAT)) -#define GIS_PLUGIN_SAT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIS_TYPE_PLUGIN_SAT, GisPluginSatClass)) +#define GRITS_TYPE_PLUGIN_SAT (grits_plugin_sat_get_type ()) +#define GRITS_PLUGIN_SAT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GRITS_TYPE_PLUGIN_SAT, GritsPluginSat)) +#define GRITS_IS_PLUGIN_SAT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GRITS_TYPE_PLUGIN_SAT)) +#define GRITS_PLUGIN_SAT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRITS_TYPE_PLUGIN_SAT, GritsPluginSatClass)) +#define GRITS_IS_PLUGIN_SAT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRITS_TYPE_PLUGIN_SAT)) +#define GRITS_PLUGIN_SAT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GRITS_TYPE_PLUGIN_SAT, GritsPluginSatClass)) -typedef struct _GisPluginSat GisPluginSat; -typedef struct _GisPluginSatClass GisPluginSatClass; +typedef struct _GritsPluginSat GritsPluginSat; +typedef struct _GritsPluginSatClass GritsPluginSatClass; -struct _GisPluginSat { +struct _GritsPluginSat { GObject parent_instance; /* instance members */ - GisViewer *viewer; - GisTile *tiles; - GisWms *wms; - GMutex *mutex; - gulong sigid; + GritsViewer *viewer; + GritsTile *tiles; + GritsWms *wms; + GMutex *mutex; + gulong sigid; }; -struct _GisPluginSatClass { +struct _GritsPluginSatClass { GObjectClass parent_class; }; -GType gis_plugin_sat_get_type(); +GType grits_plugin_sat_get_type(); /* Methods */ -GisPluginSat *gis_plugin_sat_new(GisViewer *viewer); +GritsPluginSat *grits_plugin_sat_new(GritsViewer *viewer); #endif diff --git a/src/plugins/test.c b/src/plugins/test.c index f42f02c..609297c 100644 --- a/src/plugins/test.c +++ b/src/plugins/test.c @@ -19,7 +19,7 @@ * SECTION:test * @short_description: Testing plugin * - * #GisPluginTest is a testing plugin used during development and as an example + * #GritsPluginTest is a testing plugin used during development and as an example * for how to create a plugin. */ @@ -36,25 +36,25 @@ ***********/ gboolean _load_marker(gpointer _test) { - GisPluginTest *test = _test; - GisMarker *marker = gis_marker_new("St. Charles"); - gis_point_set_lle(gis_object_center(marker), 38.841847, -90.491982, 0); - GIS_OBJECT(marker)->lod = EARTH_R; - test->marker = gis_viewer_add(test->viewer, GIS_OBJECT(marker), GIS_LEVEL_OVERLAY, 0); + GritsPluginTest *test = _test; + GritsMarker *marker = grits_marker_new("St. Charles"); + grits_point_set_lle(grits_object_center(marker), 38.841847, -90.491982, 0); + GRITS_OBJECT(marker)->lod = EARTH_R; + test->marker = grits_viewer_add(test->viewer, GRITS_OBJECT(marker), GRITS_LEVEL_OVERLAY, 0); return FALSE; } /** - * gis_plugin_test_new: - * @viewer: the #GisViewer to use for drawing + * grits_plugin_test_new: + * @viewer: the #GritsViewer to use for drawing * * Create a new instance of the testing plugin. * - * Returns: the new #GisPluginTest + * Returns: the new #GritsPluginTest */ -GisPluginTest *gis_plugin_test_new(GisViewer *viewer) +GritsPluginTest *grits_plugin_test_new(GritsViewer *viewer) { - g_debug("GisPluginTest: new"); - GisPluginTest *test = g_object_new(GIS_TYPE_PLUGIN_TEST, NULL); + g_debug("GritsPluginTest: new"); + GritsPluginTest *test = g_object_new(GRITS_TYPE_PLUGIN_TEST, NULL); test->viewer = g_object_ref(viewer); g_idle_add(_load_marker, test); return test; @@ -65,34 +65,34 @@ GisPluginTest *gis_plugin_test_new(GisViewer *viewer) * GObject code * ****************/ /* Plugin init */ -static void gis_plugin_test_plugin_init(GisPluginInterface *iface); -G_DEFINE_TYPE_WITH_CODE(GisPluginTest, gis_plugin_test, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE(GIS_TYPE_PLUGIN, - gis_plugin_test_plugin_init)); -static void gis_plugin_test_plugin_init(GisPluginInterface *iface) +static void grits_plugin_test_plugin_init(GritsPluginInterface *iface); +G_DEFINE_TYPE_WITH_CODE(GritsPluginTest, grits_plugin_test, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE(GRITS_TYPE_PLUGIN, + grits_plugin_test_plugin_init)); +static void grits_plugin_test_plugin_init(GritsPluginInterface *iface) { - g_debug("GisPluginTest: plugin_init"); + g_debug("GritsPluginTest: plugin_init"); /* Add methods to the interface */ } /* Class/Object init */ -static void gis_plugin_test_init(GisPluginTest *test) +static void grits_plugin_test_init(GritsPluginTest *test) { - g_debug("GisPluginTest: init"); + g_debug("GritsPluginTest: init"); } -static void gis_plugin_test_dispose(GObject *_test) +static void grits_plugin_test_dispose(GObject *_test) { - g_debug("GisPluginTest: dispose"); - GisPluginTest *test = GIS_PLUGIN_TEST(_test); + g_debug("GritsPluginTest: dispose"); + GritsPluginTest *test = GRITS_PLUGIN_TEST(_test); if (test->viewer) { - gis_viewer_remove(test->viewer, test->marker); + grits_viewer_remove(test->viewer, test->marker); g_object_unref(test->viewer); test->viewer = NULL; } - G_OBJECT_CLASS(gis_plugin_test_parent_class)->finalize(_test); + G_OBJECT_CLASS(grits_plugin_test_parent_class)->finalize(_test); } -static void gis_plugin_test_class_init(GisPluginTestClass *klass) +static void grits_plugin_test_class_init(GritsPluginTestClass *klass) { - g_debug("GisPluginTest: class_init"); + g_debug("GritsPluginTest: class_init"); GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - gobject_class->dispose = gis_plugin_test_dispose; + gobject_class->dispose = grits_plugin_test_dispose; } diff --git a/src/plugins/test.h b/src/plugins/test.h index 623454a..f1b7924 100644 --- a/src/plugins/test.h +++ b/src/plugins/test.h @@ -20,31 +20,31 @@ #include -#define GIS_TYPE_PLUGIN_TEST (gis_plugin_test_get_type ()) -#define GIS_PLUGIN_TEST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GIS_TYPE_PLUGIN_TEST, GisPluginTest)) -#define GIS_IS_PLUGIN_TEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GIS_TYPE_PLUGIN_TEST)) -#define GIS_PLUGIN_TEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIS_TYPE_PLUGIN_TEST, GisPluginTestClass)) -#define GIS_IS_PLUGIN_TEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIS_TYPE_PLUGIN_TEST)) -#define GIS_PLUGIN_TEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIS_TYPE_PLUGIN_TEST, GisPluginTestClass)) +#define GRITS_TYPE_PLUGIN_TEST (grits_plugin_test_get_type ()) +#define GRITS_PLUGIN_TEST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GRITS_TYPE_PLUGIN_TEST, GritsPluginTest)) +#define GRITS_IS_PLUGIN_TEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GRITS_TYPE_PLUGIN_TEST)) +#define GRITS_PLUGIN_TEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRITS_TYPE_PLUGIN_TEST, GritsPluginTestClass)) +#define GRITS_IS_PLUGIN_TEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRITS_TYPE_PLUGIN_TEST)) +#define GRITS_PLUGIN_TEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GRITS_TYPE_PLUGIN_TEST, GritsPluginTestClass)) -typedef struct _GisPluginTest GisPluginTest; -typedef struct _GisPluginTestClass GisPluginTestClass; +typedef struct _GritsPluginTest GritsPluginTest; +typedef struct _GritsPluginTestClass GritsPluginTestClass; -struct _GisPluginTest { +struct _GritsPluginTest { GObject parent_instance; /* instance members */ - GisViewer *viewer; - gpointer marker; + GritsViewer *viewer; + gpointer marker; }; -struct _GisPluginTestClass { +struct _GritsPluginTestClass { GObjectClass parent_class; }; -GType gis_plugin_test_get_type(); +GType grits_plugin_test_get_type(); /* Methods */ -GisPluginTest *gis_plugin_test_new(GisViewer *viewer); +GritsPluginTest *grits_plugin_test_new(GritsViewer *viewer); #endif diff --git a/src/roam.c b/src/roam.c index aca55a3..768ca35 100644 --- a/src/roam.c +++ b/src/roam.c @@ -21,8 +21,8 @@ * * A spherical version of the Realtime Optimally-Adapting Meshes (ROAM) * algorithm is use for drawing the surface of the planet. ROAM provide a - * continuous level-of-detail mesh of the planet which is used by #GisOpenGL - * when drawing surface textures for GisTiles. + * continuous level-of-detail mesh of the planet which is used by #GritsOpenGL + * when drawing surface textures for GritsTiles. * * This implementation of the ROAM algorithm is based on an octahedron as the * base model. diff --git a/src/roam.h b/src/roam.h index aec4b21..7b9636d 100644 --- a/src/roam.h +++ b/src/roam.h @@ -32,7 +32,7 @@ typedef struct _RoamSphere RoamSphere; * @lon: the longitude * @user_data: user data passed to the function * - * See #GisHeightFunc + * See #GritsHeightFunc * * Returns: the elevation */ diff --git a/src/tile-test.c b/src/tile-test.c index edaabe6..a800b9c 100644 --- a/src/tile-test.c +++ b/src/tile-test.c @@ -50,15 +50,15 @@ gpointer do_bmng_cache(gpointer _image) { GtkImage *image = _image; g_message("Creating bmng tile"); - GisTile *tile = gis_tile_new(NULL, NORTH, SOUTH, EAST, WEST); - tile->children[0][1] = gis_tile_new(tile, NORTH, 0, 0, WEST); + GritsTile *tile = grits_tile_new(NULL, NORTH, SOUTH, EAST, WEST); + tile->children[0][1] = grits_tile_new(tile, NORTH, 0, 0, WEST); tile = tile->children[0][1]; g_message("Fetching bmng image"); - GisWms *bmng_wms = gis_wms_new( + GritsWms *bmng_wms = grits_wms_new( "http://www.nasa.network.com/wms", "bmng200406", "image/jpeg", "bmng_test/", "jpg", 512, 256); - const char *path = gis_wms_fetch(bmng_wms, tile, GIS_ONCE, NULL, NULL); + const char *path = grits_wms_fetch(bmng_wms, tile, GRITS_ONCE, NULL, NULL); g_message("Loading bmng image: [%s]", path); GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(path, NULL); @@ -67,8 +67,8 @@ gpointer do_bmng_cache(gpointer _image) gdk_threads_leave(); g_message("Cleaning bmng up"); - gis_wms_free(bmng_wms); - gis_tile_free(tile, NULL, NULL); + grits_wms_free(bmng_wms); + grits_tile_free(tile, NULL, NULL); return NULL; } @@ -76,15 +76,15 @@ gpointer do_osm_cache(gpointer _image) { GtkImage *image = _image; g_message("Creating osm tile"); - GisTile *tile = gis_tile_new(NULL, NORTH, SOUTH, EAST, WEST); - tile->children[0][1] = gis_tile_new(tile, NORTH, 0, 0, WEST); + GritsTile *tile = grits_tile_new(NULL, NORTH, SOUTH, EAST, WEST); + tile->children[0][1] = grits_tile_new(tile, NORTH, 0, 0, WEST); tile = tile->children[0][1]; g_message("Fetching osm image"); - GisWms *osm_wms = gis_wms_new( + GritsWms *osm_wms = grits_wms_new( "http://labs.metacarta.com/wms/vmap0", "basic", "image/png", "osm_test/", "png", 512, 256); - const char *path = gis_wms_fetch(osm_wms, tile, GIS_ONCE, NULL, NULL); + const char *path = grits_wms_fetch(osm_wms, tile, GRITS_ONCE, NULL, NULL); g_message("Loading osm image: [%s]", path); GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(path, NULL); @@ -93,8 +93,8 @@ gpointer do_osm_cache(gpointer _image) gdk_threads_leave(); g_message("Cleaning osm up"); - gis_wms_free(osm_wms); - gis_tile_free(tile, NULL, NULL); + grits_wms_free(osm_wms); + grits_tile_free(tile, NULL, NULL); return NULL; } -- 2.43.2