Convert self to real names
authorAndy Spencer <andy753421@gmail.com>
Mon, 8 Feb 2010 10:47:06 +0000 (10:47 +0000)
committerAndy Spencer <andy753421@gmail.com>
Mon, 8 Feb 2010 10:47:06 +0000 (10:47 +0000)
This follows the conventions used by the rest of the G world..

We were also using real names in the headers anyway, this makes them
consistent.

22 files changed:
examples/plugin/teapot.c
src/data/gis-http.c
src/data/gis-wms.c
src/data/gis-wms.h
src/gis-opengl.c
src/gis-plugin.c
src/gis-plugin.h
src/gis-prefs.c
src/gis-viewer.c
src/gis-viewer.h
src/objects/gis-callback.c
src/objects/gis-marker.c
src/objects/gis-object.c
src/objects/gis-object.h
src/objects/gis-tile.c
src/plugins/elev.c
src/plugins/env.c
src/plugins/map.c
src/plugins/sat.c
src/plugins/test.c
src/roam.c
src/roam.h

index 445c157..a506cf1 100644 (file)
 /***********
  * Helpers *
  ***********/
-static gboolean rotate(gpointer _self)
+static gboolean rotate(gpointer _teapot)
 {
-       GisPluginTeapot *self = _self;
-       if (gtk_toggle_button_get_active(self->button)) {
-               self->rotation += 1.0;
-               gtk_widget_queue_draw(GTK_WIDGET(self->viewer));
+       GisPluginTeapot *teapot = _teapot;
+       if (gtk_toggle_button_get_active(teapot->button)) {
+               teapot->rotation += 1.0;
+               gtk_widget_queue_draw(GTK_WIDGET(teapot->viewer));
        }
        return TRUE;
 }
 
-static gpointer expose(GisCallback *callback, gpointer _self)
+static gpointer expose(GisCallback *callback, gpointer _teapot)
 {
-       GisPluginTeapot *self = GIS_PLUGIN_TEAPOT(_self);
+       GisPluginTeapot *teapot = GIS_PLUGIN_TEAPOT(_teapot);
        g_debug("GisPluginTeapot: expose");
 
        glMatrixMode(GL_PROJECTION);
@@ -56,7 +56,7 @@ static gpointer expose(GisCallback *callback, gpointer _self)
        glEnable(GL_COLOR_MATERIAL);
 
        glTranslatef(-0.5, -0.5, -2);
-       glRotatef(self->rotation, 1, 1, 0);
+       glRotatef(teapot->rotation, 1, 1, 0);
        glColor4f(0.9, 0.9, 0.7, 1.0);
        glDisable(GL_CULL_FACE);
        gdk_gl_draw_teapot(TRUE, 0.25);
@@ -71,20 +71,20 @@ static gpointer expose(GisCallback *callback, gpointer _self)
 GisPluginTeapot *gis_plugin_teapot_new(GisViewer *viewer, GisPrefs *prefs)
 {
        g_debug("GisPluginTeapot: new");
-       GisPluginTeapot *self = g_object_new(GIS_TYPE_PLUGIN_TEAPOT, NULL);
-       self->viewer = viewer;
+       GisPluginTeapot *teapot = g_object_new(GIS_TYPE_PLUGIN_TEAPOT, NULL);
+       teapot->viewer = viewer;
 
        /* Add renderers */
-       GisCallback *callback = gis_callback_new(expose, self);
+       GisCallback *callback = gis_callback_new(expose, teapot);
        gis_viewer_add(viewer, GIS_OBJECT(callback), GIS_LEVEL_WORLD, 0);
 
-       return self;
+       return teapot;
 }
 
-static GtkWidget *gis_plugin_teapot_get_config(GisPlugin *_self)
+static GtkWidget *gis_plugin_teapot_get_config(GisPlugin *_teapot)
 {
-       GisPluginTeapot *self = GIS_PLUGIN_TEAPOT(_self);
-       return GTK_WIDGET(self->button);
+       GisPluginTeapot *teapot = GIS_PLUGIN_TEAPOT(_teapot);
+       return GTK_WIDGET(teapot->button);
 }
 
 
@@ -103,19 +103,19 @@ static void gis_plugin_teapot_plugin_init(GisPluginInterface *iface)
        iface->get_config = gis_plugin_teapot_get_config;
 }
 /* Class/Object init */
-static void gis_plugin_teapot_init(GisPluginTeapot *self)
+static void gis_plugin_teapot_init(GisPluginTeapot *teapot)
 {
        g_debug("GisPluginTeapot: init");
        /* Set defaults */
-       self->button    = GTK_TOGGLE_BUTTON(gtk_toggle_button_new_with_label("Rotate"));
-       self->rotate_id = g_timeout_add(1000/60, rotate, self);
-       self->rotation  = 30.0;
+       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)
 {
        g_debug("GisPluginTeapot: dispose");
-       GisPluginTeapot *self = GIS_PLUGIN_TEAPOT(gobject);
-       g_source_remove(self->rotate_id);
+       GisPluginTeapot *teapot = GIS_PLUGIN_TEAPOT(gobject);
+       g_source_remove(teapot->rotate_id);
        /* Drop references */
        G_OBJECT_CLASS(gis_plugin_teapot_parent_class)->dispose(gobject);
 }
index e89d252..1f1c270 100644 (file)
 GisHttp *gis_http_new(const gchar *prefix)
 {
        g_debug("GisHttp: new - %s", prefix);
-       GisHttp *self = g_new0(GisHttp, 1);
-       self->soup = soup_session_sync_new();
-       self->prefix = g_strdup(prefix);
-       g_object_set(self->soup, "user-agent", PACKAGE_STRING, NULL);
-       return self;
+       GisHttp *http = g_new0(GisHttp, 1);
+       http->soup = soup_session_sync_new();
+       http->prefix = g_strdup(prefix);
+       g_object_set(http->soup, "user-agent", PACKAGE_STRING, NULL);
+       return http;
 }
 
-void gis_http_free(GisHttp *self)
+void gis_http_free(GisHttp *http)
 {
-       g_debug("GisHttp: free - %s", self->prefix);
-       soup_session_abort(self->soup);
-       g_object_unref(self->soup);
-       g_free(self->prefix);
-       g_free(self);
+       g_debug("GisHttp: free - %s", http->prefix);
+       soup_session_abort(http->soup);
+       g_object_unref(http->soup);
+       g_free(http->prefix);
+       g_free(http);
 }
 
 /* For passing data to the chunck callback */
@@ -75,14 +75,14 @@ static void _chunk_cb(SoupMessage *message, SoupBuffer *chunk, gpointer _info)
 }
 
 /* TODO: use .part extentions and continue even when using GIS_ONCE */
-gchar *gis_http_fetch(GisHttp *self, const gchar *uri, const char *local,
+gchar *gis_http_fetch(GisHttp *http, const gchar *uri, const char *local,
                GisCacheType mode, GisChunkCallback callback, gpointer user_data)
 {
        g_debug("GisHttp: fetch - %.20s... >> %s/%s  mode=%d",
-                       uri, self->prefix, local, mode);
+                       uri, http->prefix, local, mode);
 
        gchar *path = g_build_filename(g_get_user_cache_dir(), PACKAGE,
-                       self->prefix, local, NULL);
+                       http->prefix, local, NULL);
 
        /* Unlink the file if we're refreshing it */
        if (mode == GIS_REFRESH)
@@ -110,7 +110,7 @@ gchar *gis_http_fetch(GisHttp *self, const gchar *uri, const char *local,
                        g_error("message is null, cannot parse uri");
                g_signal_connect(message, "got-chunk", G_CALLBACK(_chunk_cb), &info);
                soup_message_headers_set_range(message->request_headers, ftell(fp), -1);
-               soup_session_send_message(self->soup, message);
+               soup_session_send_message(http->soup, message);
 
                /* Finished */
                if (message->status_code == 416) {
index 9d38862..0b550a2 100644 (file)
@@ -90,14 +90,14 @@ static gchar *_make_uri(GisWms *wms, GisTile *tile)
                tile->edge.n);
 }
 
-gchar *gis_wms_fetch(GisWms *self, GisTile *tile, GisCacheType mode,
+gchar *gis_wms_fetch(GisWms *wms, GisTile *tile, GisCacheType mode,
                GisChunkCallback callback, gpointer user_data)
 {
-       gchar *uri   = _make_uri(self, tile);
+       gchar *uri   = _make_uri(wms, tile);
        gchar *tilep = gis_tile_get_path(tile);
-       gchar *local = g_strdup_printf("%s%s", tilep, self->extension);
+       gchar *local = g_strdup_printf("%s%s", tilep, wms->extension);
        mode = GIS_ONCE;
-       gchar *path  = gis_http_fetch(self->http, uri, local,
+       gchar *path  = gis_http_fetch(wms->http, uri, local,
                        mode, callback, user_data);
        g_free(uri);
        g_free(tilep);
@@ -111,24 +111,24 @@ GisWms *gis_wms_new(
        const gchar *extension, gint width, gint height)
 {
        g_debug("GisWms: new - %s", uri_prefix);
-       GisWms *self = g_new0(GisWms, 1);
-       self->http         = gis_http_new(prefix);
-       self->uri_prefix   = g_strdup(uri_prefix);
-       self->uri_layer    = g_strdup(uri_layer);
-       self->uri_format   = g_strdup(uri_format);
-       self->extension    = g_strdup(extension);
-       self->width        = width;
-       self->height       = height;
-       return self;
+       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;
+       return wms;
 }
 
-void gis_wms_free(GisWms *self)
+void gis_wms_free(GisWms *wms)
 {
-       g_debug("GisWms: free - %s", self->uri_prefix);
-       gis_http_free(self->http);
-       g_free(self->uri_prefix);
-       g_free(self->uri_layer);
-       g_free(self->uri_format);
-       g_free(self->extension);
-       g_free(self);
+       g_debug("GisWms: free - %s", wms->uri_prefix);
+       gis_http_free(wms->http);
+       g_free(wms->uri_prefix);
+       g_free(wms->uri_layer);
+       g_free(wms->uri_format);
+       g_free(wms->extension);
+       g_free(wms);
 }
index 1057341..90152b8 100644 (file)
@@ -42,6 +42,6 @@ GisWms *gis_wms_new(
 gchar *gis_wms_fetch(GisWms *wms, GisTile *tile, GisCacheType mode,
                GisChunkCallback callback, gpointer user_data);
 
-void gis_wms_free(GisWms *self);
+void gis_wms_free(GisWms *wms);
 
 #endif
index c1d6fd5..08babe5 100644 (file)
 /***********
  * Helpers *
  ***********/
-static void _set_visuals(GisOpenGL *self)
+static void _set_visuals(GisOpenGL *opengl)
 {
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
 
        /* Camera 1 */
        double lat, lon, elev, rx, ry, rz;
-       gis_viewer_get_location(GIS_VIEWER(self), &lat, &lon, &elev);
-       gis_viewer_get_rotation(GIS_VIEWER(self), &rx, &ry, &rz);
+       gis_viewer_get_location(GIS_VIEWER(opengl), &lat, &lon, &elev);
+       gis_viewer_get_rotation(GIS_VIEWER(opengl), &rx, &ry, &rz);
        glRotatef(rx, 1, 0, 0);
        glRotatef(rz, 0, 0, 1);
 
@@ -106,18 +106,18 @@ static void _set_visuals(GisOpenGL *self)
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
        //glShadeModel(GL_FLAT);
 
-       roam_sphere_update_view(self->sphere);
+       roam_sphere_update_view(opengl->sphere);
 }
 
 
 /********************
  * Object handleing *
  ********************/
-static void _draw_tile(GisOpenGL *self, GisTile *tile)
+static void _draw_tile(GisOpenGL *opengl, GisTile *tile)
 {
        if (!tile || !tile->data)
                return;
-       GList *triangles = roam_sphere_get_intersect(self->sphere, FALSE,
+       GList *triangles = roam_sphere_get_intersect(opengl->sphere, FALSE,
                        tile->edge.n, tile->edge.s, tile->edge.e, tile->edge.w);
        if (!triangles)
                g_warning("GisOpenGL: _draw_tiles - No triangles to draw: edges=%f,%f,%f,%f",
@@ -179,7 +179,7 @@ static void _draw_tile(GisOpenGL *self, GisTile *tile)
        g_list_free(triangles);
 }
 
-static void _draw_tiles(GisOpenGL *self, GisTile *tile)
+static void _draw_tiles(GisOpenGL *opengl, GisTile *tile)
 {
        /* Only draw children if possible */
        gboolean has_children = TRUE;
@@ -190,17 +190,17 @@ static void _draw_tiles(GisOpenGL *self, GisTile *tile)
        if (has_children)
                /* Only draw children */
                gis_tile_foreach(tile, child)
-                       _draw_tiles(self, child);
+                       _draw_tiles(opengl, child);
        else
                /* No children, draw this tile */
-               _draw_tile(self, tile);
+               _draw_tile(opengl, tile);
 }
 
-static void _draw_marker(GisOpenGL *self, GisMarker *marker)
+static void _draw_marker(GisOpenGL *opengl, GisMarker *marker)
 {
        GisPoint *point = gis_object_center(GIS_OBJECT(marker));
        gdouble px, py, pz;
-       gis_viewer_project(GIS_VIEWER(self),
+       gis_viewer_project(GIS_VIEWER(opengl),
                        point->lat, point->lon, point->elev,
                        &px, &py, &pz);
        if (pz > 1)
@@ -214,8 +214,8 @@ static void _draw_marker(GisOpenGL *self, GisMarker *marker)
 
        glMatrixMode(GL_PROJECTION); glLoadIdentity();
        glMatrixMode(GL_MODELVIEW);  glLoadIdentity();
-       glOrtho(0, GTK_WIDGET(self)->allocation.width,
-               0, GTK_WIDGET(self)->allocation.height, -1, 1);
+       glOrtho(0, GTK_WIDGET(opengl)->allocation.width,
+               0, GTK_WIDGET(opengl)->allocation.height, -1, 1);
        glTranslated(px - marker->xoff,
                     py - marker->yoff, 0);
 
@@ -232,18 +232,18 @@ static void _draw_marker(GisOpenGL *self, GisMarker *marker)
        glEnd();
 }
 
-static void _draw_callback(GisOpenGL *self, GisCallback *callback)
+static void _draw_callback(GisOpenGL *opengl, GisCallback *callback)
 {
        callback->callback(callback, callback->user_data);
 }
 
-static void _draw_object(GisOpenGL *self, GisObject *object)
+static void _draw_object(GisOpenGL *opengl, GisObject *object)
 {
        //g_debug("GisOpenGL: draw_object");
        /* Skip out of range objects */
        if (object->lod > 0) {
                gdouble eye[3], obj[3];
-               gis_viewer_get_location(GIS_VIEWER(self), &eye[0], &eye[1], &eye[2]);
+               gis_viewer_get_location(GIS_VIEWER(opengl), &eye[0], &eye[1], &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,
                        &obj[0], &obj[1], &obj[2]);
@@ -257,18 +257,18 @@ static void _draw_object(GisOpenGL *self, GisObject *object)
        glMatrixMode(GL_MODELVIEW);  glPushMatrix();
        glPushAttrib(GL_ALL_ATTRIB_BITS);
        if (GIS_IS_MARKER(object)) {
-               _draw_marker(self, GIS_MARKER(object));
+               _draw_marker(opengl, GIS_MARKER(object));
        } else if (GIS_IS_CALLBACK(object)) {
-               _draw_callback(self, GIS_CALLBACK(object));
+               _draw_callback(opengl, GIS_CALLBACK(object));
        } else if (GIS_IS_TILE(object)) {
-               _draw_tiles(self, GIS_TILE(object));
+               _draw_tiles(opengl, GIS_TILE(object));
        }
        glPopAttrib();
        glMatrixMode(GL_PROJECTION); glPopMatrix();
        glMatrixMode(GL_MODELVIEW);  glPopMatrix();
 }
 
-static void _load_object(GisOpenGL *self, GisObject *object)
+static void _load_object(GisOpenGL *opengl, GisObject *object)
 {
        g_debug("GisOpenGL: load_object");
        if (GIS_IS_MARKER(object)) {
@@ -291,7 +291,7 @@ static void _load_object(GisOpenGL *self, GisObject *object)
        }
 }
 
-static void _unload_object(GisOpenGL *self, GisObject *object)
+static void _unload_object(GisOpenGL *opengl, GisObject *object)
 {
        g_debug("GisOpenGL: unload_object");
        if (GIS_IS_MARKER(object)) {
@@ -312,27 +312,27 @@ struct RenderLevel {
        GList sorted;
 };
 
-static void on_realize(GisOpenGL *self, gpointer _)
+static void on_realize(GisOpenGL *opengl, gpointer _)
 {
        g_debug("GisOpenGL: on_realize");
 
-       GdkGLContext   *glcontext  = gtk_widget_get_gl_context(GTK_WIDGET(self));
-       GdkGLDrawable  *gldrawable = gtk_widget_get_gl_drawable(GTK_WIDGET(self));
+       GdkGLContext   *glcontext  = gtk_widget_get_gl_context(GTK_WIDGET(opengl));
+       GdkGLDrawable  *gldrawable = gtk_widget_get_gl_drawable(GTK_WIDGET(opengl));
        if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext))
                g_assert_not_reached();
 
-       _set_visuals(self);
-       g_mutex_lock(self->sphere_lock);
-       roam_sphere_update_errors(self->sphere);
-       g_mutex_unlock(self->sphere_lock);
+       _set_visuals(opengl);
+       g_mutex_lock(opengl->sphere_lock);
+       roam_sphere_update_errors(opengl->sphere);
+       g_mutex_unlock(opengl->sphere_lock);
 }
 
-static gboolean on_configure(GisOpenGL *self, GdkEventConfigure *event, gpointer _)
+static gboolean on_configure(GisOpenGL *opengl, GdkEventConfigure *event, gpointer _)
 {
        g_debug("GisOpenGL: on_configure");
 
-       double width  = GTK_WIDGET(self)->allocation.width;
-       double height = GTK_WIDGET(self)->allocation.height;
+       double width  = GTK_WIDGET(opengl)->allocation.width;
+       double height = GTK_WIDGET(opengl)->allocation.height;
 
        /* Setup OpenGL Window */
        glViewport(0, 0, width, height);
@@ -342,9 +342,9 @@ static gboolean on_configure(GisOpenGL *self, GdkEventConfigure *event, gpointer
        gluPerspective(rad2deg(ang)*2, width/height, 1, 10*EARTH_R);
 
 #ifndef ROAM_DEBUG
-       g_mutex_lock(self->sphere_lock);
-       roam_sphere_update_errors(self->sphere);
-       g_mutex_unlock(self->sphere_lock);
+       g_mutex_lock(opengl->sphere_lock);
+       roam_sphere_update_errors(opengl->sphere);
+       g_mutex_unlock(opengl->sphere_lock);
 #endif
 
        return FALSE;
@@ -353,7 +353,7 @@ static gboolean on_configure(GisOpenGL *self, GdkEventConfigure *event, gpointer
 static gboolean _draw_level(gpointer key, gpointer value, gpointer user_data)
 {
        g_debug("GisOpenGL: _draw_level - level=%-4d", (int)key);
-       GisOpenGL *self = user_data;
+       GisOpenGL *opengl = user_data;
        struct RenderLevel *level = value;
        int nsorted = 0, nunsorted = 0;
        GList *cur = NULL;
@@ -362,14 +362,14 @@ 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++)
-               _draw_object(self, GIS_OBJECT(cur->data));
+               _draw_object(opengl, GIS_OBJECT(cur->data));
 
        /* 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++)
-               _draw_object(self, GIS_OBJECT(cur->data));
+               _draw_object(opengl, GIS_OBJECT(cur->data));
 
        /* TODO: Prune empty levels */
 
@@ -378,36 +378,36 @@ static gboolean _draw_level(gpointer key, gpointer value, gpointer user_data)
        return FALSE;
 }
 
-static gboolean on_expose(GisOpenGL *self, GdkEventExpose *event, gpointer _)
+static gboolean on_expose(GisOpenGL *opengl, GdkEventExpose *event, gpointer _)
 {
        g_debug("GisOpenGL: on_expose - begin");
 
        glClear(GL_COLOR_BUFFER_BIT);
 
-       _set_visuals(self);
+       _set_visuals(opengl);
 #ifdef ROAM_DEBUG
        glColor4f(0.0, 0.0, 9.0, 0.6);
        glDisable(GL_TEXTURE_2D);
        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
-       roam_sphere_draw(self->sphere);
-       //roam_sphere_draw_normals(self->sphere);
+       roam_sphere_draw(opengl->sphere);
+       //roam_sphere_draw_normals(opengl->sphere);
 #else
-       g_tree_foreach(self->objects, _draw_level, self);
-       if (self->wireframe) {
+       g_tree_foreach(opengl->objects, _draw_level, opengl);
+       if (opengl->wireframe) {
                glClear(GL_DEPTH_BUFFER_BIT);
                glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
-               roam_sphere_draw(self->sphere);
+               roam_sphere_draw(opengl->sphere);
        }
 #endif
 
-       GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(GTK_WIDGET(self));
+       GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(GTK_WIDGET(opengl));
        gdk_gl_drawable_swap_buffers(gldrawable);
 
        g_debug("GisOpenGL: on_expose - end\n");
        return FALSE;
 }
 
-static gboolean on_key_press(GisOpenGL *self, GdkEventKey *event, gpointer _)
+static gboolean on_key_press(GisOpenGL *opengl, GdkEventKey *event, gpointer _)
 {
        g_debug("GisOpenGL: on_key_press - key=%x, state=%x, plus=%x",
                        event->keyval, event->state, GDK_plus);
@@ -416,16 +416,16 @@ static gboolean on_key_press(GisOpenGL *self, GdkEventKey *event, gpointer _)
        gdk_threads_leave();
        /* Testing */
        if (kv == GDK_w) {
-               self->wireframe = !self->wireframe;
-               gtk_widget_queue_draw(GTK_WIDGET(self));
+               opengl->wireframe = !opengl->wireframe;
+               gtk_widget_queue_draw(GTK_WIDGET(opengl));
        }
 #ifdef ROAM_DEBUG
-       else if (kv == GDK_n) roam_sphere_split_one(self->sphere);
-       else if (kv == GDK_p) roam_sphere_merge_one(self->sphere);
-       else if (kv == GDK_r) roam_sphere_split_merge(self->sphere);
-       else if (kv == GDK_u) roam_sphere_update_errors(self->sphere);
+       else if (kv == GDK_n) roam_sphere_split_one(opengl->sphere);
+       else if (kv == GDK_p) roam_sphere_merge_one(opengl->sphere);
+       else if (kv == GDK_r) roam_sphere_split_merge(opengl->sphere);
+       else if (kv == GDK_u) roam_sphere_update_errors(opengl->sphere);
        gdk_threads_enter();
-       gtk_widget_queue_draw(GTK_WIDGET(self));
+       gtk_widget_queue_draw(GTK_WIDGET(opengl));
 #else
        gdk_threads_enter();
 #endif
@@ -437,26 +437,26 @@ static gboolean _update_errors_cb(gpointer sphere)
        roam_sphere_update_errors(sphere);
        return FALSE;
 }
-static void on_view_changed(GisOpenGL *self,
+static void on_view_changed(GisOpenGL *opengl,
                gdouble _1, gdouble _2, gdouble _3)
 {
        g_debug("GisOpenGL: on_view_changed");
-       _set_visuals(self);
+       _set_visuals(opengl);
 #ifndef ROAM_DEBUG
-       self->ue_source = g_idle_add_full(G_PRIORITY_HIGH_IDLE+30,
-                       _update_errors_cb, self->sphere, NULL);
-       //roam_sphere_update_errors(self->sphere);
+       opengl->ue_source = g_idle_add_full(G_PRIORITY_HIGH_IDLE+30,
+                       _update_errors_cb, opengl->sphere, NULL);
+       //roam_sphere_update_errors(opengl->sphere);
 #endif
 }
 
-static gboolean on_idle(GisOpenGL *self)
+static gboolean on_idle(GisOpenGL *opengl)
 {
        //g_debug("GisOpenGL: on_idle");
        gdk_threads_enter();
-       g_mutex_lock(self->sphere_lock);
-       if (roam_sphere_split_merge(self->sphere))
-               gtk_widget_queue_draw(GTK_WIDGET(self));
-       g_mutex_unlock(self->sphere_lock);
+       g_mutex_lock(opengl->sphere_lock);
+       if (roam_sphere_split_merge(opengl->sphere))
+               gtk_widget_queue_draw(GTK_WIDGET(opengl));
+       g_mutex_unlock(opengl->sphere_lock);
        gdk_threads_leave();
        return TRUE;
 }
@@ -468,42 +468,42 @@ static gboolean on_idle(GisOpenGL *self)
 GisViewer *gis_opengl_new(GisPlugins *plugins, GisPrefs *prefs)
 {
        g_debug("GisOpenGL: new");
-       GisViewer *self = g_object_new(GIS_TYPE_OPENGL, NULL);
-       gis_viewer_setup(self, plugins, prefs);
-       return self;
+       GisViewer *opengl = g_object_new(GIS_TYPE_OPENGL, NULL);
+       gis_viewer_setup(opengl, plugins, prefs);
+       return opengl;
 }
 
-static void gis_opengl_center_position(GisViewer *_self, gdouble lat, gdouble lon, gdouble elev)
+static void gis_opengl_center_position(GisViewer *_opengl, gdouble lat, gdouble lon, gdouble elev)
 {
-       GisOpenGL *self = GIS_OPENGL(_self);
+       GisOpenGL *opengl = GIS_OPENGL(_opengl);
        glRotatef(lon, 0, 1, 0);
        glRotatef(-lat, 1, 0, 0);
        glTranslatef(0, 0, elev2rad(elev));
 }
 
-static void gis_opengl_project(GisViewer *_self,
+static void gis_opengl_project(GisViewer *_opengl,
                gdouble lat, gdouble lon, gdouble elev,
                gdouble *px, gdouble *py, gdouble *pz)
 {
-       GisOpenGL *self = GIS_OPENGL(_self);
+       GisOpenGL *opengl = GIS_OPENGL(_opengl);
        gdouble x, y, z;
        lle2xyz(lat, lon, elev, &x, &y, &z);
        gluProject(x, y, z,
-               self->sphere->view->model,
-               self->sphere->view->proj,
-               self->sphere->view->view,
+               opengl->sphere->view->model,
+               opengl->sphere->view->proj,
+               opengl->sphere->view->view,
                px, py, pz);
 }
 
-static void gis_opengl_set_height_func(GisViewer *_self, GisTile *tile,
+static void gis_opengl_set_height_func(GisViewer *_opengl, GisTile *tile,
                RoamHeightFunc height_func, gpointer user_data, gboolean update)
 {
-       GisOpenGL *self = GIS_OPENGL(_self);
+       GisOpenGL *opengl = GIS_OPENGL(_opengl);
        if (!tile)
                return;
        /* TODO: get points? */
-       g_mutex_lock(self->sphere_lock);
-       GList *triangles = roam_sphere_get_intersect(self->sphere, TRUE,
+       g_mutex_lock(opengl->sphere_lock);
+       GList *triangles = roam_sphere_get_intersect(opengl->sphere, TRUE,
                        tile->edge.n, tile->edge.s, tile->edge.e, tile->edge.w);
        for (GList *cur = triangles; cur; cur = cur->next) {
                RoamTriangle *tri = cur->data;
@@ -518,7 +518,7 @@ static void gis_opengl_set_height_func(GisViewer *_self, GisTile *tile,
                }
        }
        g_list_free(triangles);
-       g_mutex_unlock(self->sphere_lock);
+       g_mutex_unlock(opengl->sphere_lock);
 }
 
 static void _gis_opengl_clear_height_func_rec(RoamTriangle *root)
@@ -535,23 +535,23 @@ static void _gis_opengl_clear_height_func_rec(RoamTriangle *root)
        _gis_opengl_clear_height_func_rec(root->kids[1]);
 }
 
-static void gis_opengl_clear_height_func(GisViewer *_self)
+static void gis_opengl_clear_height_func(GisViewer *_opengl)
 {
-       GisOpenGL *self = GIS_OPENGL(_self);
-       for (int i = 0; i < G_N_ELEMENTS(self->sphere->roots); i++)
-               _gis_opengl_clear_height_func_rec(self->sphere->roots[i]);
+       GisOpenGL *opengl = GIS_OPENGL(_opengl);
+       for (int i = 0; i < G_N_ELEMENTS(opengl->sphere->roots); i++)
+               _gis_opengl_clear_height_func_rec(opengl->sphere->roots[i]);
 }
 
-static gpointer gis_opengl_add(GisViewer *_self, GisObject *object,
+static gpointer gis_opengl_add(GisViewer *_opengl, GisObject *object,
                gint key, gboolean sort)
 {
-       g_assert(GIS_IS_OPENGL(_self));
-       GisOpenGL *self = GIS_OPENGL(_self);
-       _load_object(self, object);
-       struct RenderLevel *level = g_tree_lookup(self->objects, (gpointer)key);
+       g_assert(GIS_IS_OPENGL(_opengl));
+       GisOpenGL *opengl = GIS_OPENGL(_opengl);
+       _load_object(opengl, object);
+       struct RenderLevel *level = g_tree_lookup(opengl->objects, (gpointer)key);
        if (!level) {
                level = g_new0(struct RenderLevel, 1);
-               g_tree_insert(self->objects, (gpointer)key, level);
+               g_tree_insert(opengl->objects, (gpointer)key, level);
        }
        GList *list = sort ? &level->sorted : &level->unsorted;
        /* Put the link in the list */
@@ -563,13 +563,13 @@ static gpointer gis_opengl_add(GisViewer *_self, GisObject *object,
        return next;
 }
 
-static GisObject *gis_opengl_remove(GisViewer *_self, gpointer _link)
+static GisObject *gis_opengl_remove(GisViewer *_opengl, gpointer _link)
 {
-       g_assert(GIS_IS_OPENGL(_self));
-       GisOpenGL *self = GIS_OPENGL(_self);
+       g_assert(GIS_IS_OPENGL(_opengl));
+       GisOpenGL *opengl = GIS_OPENGL(_opengl);
        GList *link = _link;
        GisObject *object = link->data;
-       _unload_object(self, object);
+       _unload_object(opengl, object);
        /* Just unlink and free it, link->prev is assured */
        link->prev->next = link->next;
        if (link->next)
@@ -599,7 +599,7 @@ static void _objects_free(gpointer value)
 }
 
 G_DEFINE_TYPE(GisOpenGL, gis_opengl, GIS_TYPE_VIEWER);
-static void gis_opengl_init(GisOpenGL *self)
+static void gis_opengl_init(GisOpenGL *opengl)
 {
        g_debug("GisOpenGL: init");
        /* OpenGL setup */
@@ -608,56 +608,56 @@ static void gis_opengl_init(GisOpenGL *self)
                        GDK_GL_MODE_DOUBLE | GDK_GL_MODE_ALPHA);
        if (!glconfig)
                g_error("Failed to create glconfig");
-       if (!gtk_widget_set_gl_capability(GTK_WIDGET(self),
+       if (!gtk_widget_set_gl_capability(GTK_WIDGET(opengl),
                                glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE))
                g_error("GL lacks required capabilities");
        g_object_unref(glconfig);
 
-       self->objects = g_tree_new_full(_objects_cmp, NULL, NULL, _objects_free);
-       self->sphere = roam_sphere_new(self);
-       self->sphere_lock = g_mutex_new();
+       opengl->objects = g_tree_new_full(_objects_cmp, NULL, NULL, _objects_free);
+       opengl->sphere = roam_sphere_new(opengl);
+       opengl->sphere_lock = g_mutex_new();
 
 #ifndef ROAM_DEBUG
-       self->sm_source[0] = g_timeout_add_full(G_PRIORITY_HIGH_IDLE+30, 33,  (GSourceFunc)on_idle, self, NULL);
-       self->sm_source[1] = g_timeout_add_full(G_PRIORITY_HIGH_IDLE+10, 500, (GSourceFunc)on_idle, self, NULL);
+       opengl->sm_source[0] = g_timeout_add_full(G_PRIORITY_HIGH_IDLE+30, 33,  (GSourceFunc)on_idle, opengl, NULL);
+       opengl->sm_source[1] = g_timeout_add_full(G_PRIORITY_HIGH_IDLE+10, 500, (GSourceFunc)on_idle, opengl, NULL);
 #endif
 
-       gtk_widget_add_events(GTK_WIDGET(self), GDK_KEY_PRESS_MASK);
-       g_signal_connect(self, "realize",          G_CALLBACK(on_realize),      NULL);
-       g_signal_connect(self, "configure-event",  G_CALLBACK(on_configure),    NULL);
-       g_signal_connect(self, "expose-event",     G_CALLBACK(on_expose),       NULL);
+       gtk_widget_add_events(GTK_WIDGET(opengl), GDK_KEY_PRESS_MASK);
+       g_signal_connect(opengl, "realize",          G_CALLBACK(on_realize),      NULL);
+       g_signal_connect(opengl, "configure-event",  G_CALLBACK(on_configure),    NULL);
+       g_signal_connect(opengl, "expose-event",     G_CALLBACK(on_expose),       NULL);
 
-       g_signal_connect(self, "key-press-event",  G_CALLBACK(on_key_press),    NULL);
+       g_signal_connect(opengl, "key-press-event",  G_CALLBACK(on_key_press),    NULL);
 
-       g_signal_connect(self, "location-changed", G_CALLBACK(on_view_changed), NULL);
-       g_signal_connect(self, "rotation-changed", G_CALLBACK(on_view_changed), NULL);
+       g_signal_connect(opengl, "location-changed", G_CALLBACK(on_view_changed), NULL);
+       g_signal_connect(opengl, "rotation-changed", G_CALLBACK(on_view_changed), NULL);
 }
-static void gis_opengl_dispose(GObject *_self)
+static void gis_opengl_dispose(GObject *_opengl)
 {
        g_debug("GisOpenGL: dispose");
-       GisOpenGL *self = GIS_OPENGL(_self);
-       if (self->sm_source[0]) {
-               g_source_remove(self->sm_source[0]);
-               self->sm_source[0] = 0;
+       GisOpenGL *opengl = GIS_OPENGL(_opengl);
+       if (opengl->sm_source[0]) {
+               g_source_remove(opengl->sm_source[0]);
+               opengl->sm_source[0] = 0;
        }
-       if (self->sm_source[1]) {
-               g_source_remove(self->sm_source[1]);
-               self->sm_source[1] = 0;
+       if (opengl->sm_source[1]) {
+               g_source_remove(opengl->sm_source[1]);
+               opengl->sm_source[1] = 0;
        }
-       if (self->ue_source) {
-               g_source_remove(self->ue_source);
-               self->ue_source = 0;
+       if (opengl->ue_source) {
+               g_source_remove(opengl->ue_source);
+               opengl->ue_source = 0;
        }
-       G_OBJECT_CLASS(gis_opengl_parent_class)->dispose(_self);
+       G_OBJECT_CLASS(gis_opengl_parent_class)->dispose(_opengl);
 }
-static void gis_opengl_finalize(GObject *_self)
+static void gis_opengl_finalize(GObject *_opengl)
 {
        g_debug("GisOpenGL: finalize");
-       GisOpenGL *self = GIS_OPENGL(_self);
-       roam_sphere_free(self->sphere);
-       g_tree_destroy(self->objects);
-       g_mutex_free(self->sphere_lock);
-       G_OBJECT_CLASS(gis_opengl_parent_class)->finalize(_self);
+       GisOpenGL *opengl = GIS_OPENGL(_opengl);
+       roam_sphere_free(opengl->sphere);
+       g_tree_destroy(opengl->objects);
+       g_mutex_free(opengl->sphere_lock);
+       G_OBJECT_CLASS(gis_opengl_parent_class)->finalize(_opengl);
 }
 static void gis_opengl_class_init(GisOpenGLClass *klass)
 {
index 255c0be..6f0834a 100644 (file)
@@ -47,26 +47,26 @@ GType gis_plugin_get_type()
        return type;
 }
 
-const gchar *gis_plugin_get_name(GisPlugin *self)
+const gchar *gis_plugin_get_name(GisPlugin *plugin)
 {
-       if (!GIS_IS_PLUGIN(self))
+       if (!GIS_IS_PLUGIN(plugin))
                return NULL;
-       return GIS_PLUGIN_GET_INTERFACE(self)->name;
+       return GIS_PLUGIN_GET_INTERFACE(plugin)->name;
 }
 
-const gchar *gis_plugin_get_description(GisPlugin *self)
+const gchar *gis_plugin_get_description(GisPlugin *plugin)
 {
-       if (!GIS_IS_PLUGIN(self))
+       if (!GIS_IS_PLUGIN(plugin))
                return NULL;
-       return GIS_PLUGIN_GET_INTERFACE(self)->description;
+       return GIS_PLUGIN_GET_INTERFACE(plugin)->description;
 }
 
-GtkWidget *gis_plugin_get_config(GisPlugin *self)
+GtkWidget *gis_plugin_get_config(GisPlugin *plugin)
 {
-       if (!GIS_IS_PLUGIN(self))
+       if (!GIS_IS_PLUGIN(plugin))
                return NULL;
-       GisPluginInterface *iface = GIS_PLUGIN_GET_INTERFACE(self);
-       return iface->get_config ? iface->get_config(self) : NULL;
+       GisPluginInterface *iface = GIS_PLUGIN_GET_INTERFACE(plugin);
+       return iface->get_config ? iface->get_config(plugin) : NULL;
 }
 
 
@@ -81,17 +81,17 @@ typedef struct {
 GisPlugins *gis_plugins_new(const gchar *dir, GisPrefs *prefs)
 {
        g_debug("GisPlugins: new - dir=%s", dir);
-       GisPlugins *self = g_new0(GisPlugins, 1);
-       self->prefs = prefs;
+       GisPlugins *plugins = g_new0(GisPlugins, 1);
+       plugins->prefs = prefs;
        if (dir)
-               self->dir = g_strdup(dir);
-       return self;
+               plugins->dir = g_strdup(dir);
+       return plugins;
 }
 
-void gis_plugins_free(GisPlugins *self)
+void gis_plugins_free(GisPlugins *plugins)
 {
        g_debug("GisPlugins: free");
-       for (GList *cur = self->plugins; cur; cur = cur->next) {
+       for (GList *cur = plugins->plugins; cur; cur = cur->next) {
                GisPluginStore *store = cur->data;
                g_debug("GisPlugin: freeing %s refs=%d->%d", store->name,
                        G_OBJECT(store->plugin)->ref_count,
@@ -100,17 +100,17 @@ void gis_plugins_free(GisPlugins *self)
                g_free(store->name);
                g_free(store);
        }
-       g_list_free(self->plugins);
-       if (self->dir)
-               g_free(self->dir);
-       g_free(self);
+       g_list_free(plugins->plugins);
+       if (plugins->dir)
+               g_free(plugins->dir);
+       g_free(plugins);
 }
 
-GList *gis_plugins_available(GisPlugins *self)
+GList *gis_plugins_available(GisPlugins *plugins)
 {
        g_debug("GisPlugins: available");
        GList *list = NULL;
-       gchar *dirs[] = {self->dir, PLUGINSDIR};
+       gchar *dirs[] = {plugins->dir, PLUGINSDIR};
        g_debug("pluginsdir=%s", PLUGINSDIR);
        for (int i = 0; i<2; i++) {
                if (dirs[i] == NULL)
@@ -132,11 +132,11 @@ GList *gis_plugins_available(GisPlugins *self)
        return list;
 }
 
-GisPlugin *gis_plugins_load(GisPlugins *self, const char *name,
+GisPlugin *gis_plugins_load(GisPlugins *plugins, const char *name,
                GisViewer *viewer, GisPrefs *prefs)
 {
        g_debug("GisPlugins: load %s", name);
-       gchar *path = g_strdup_printf("%s/%s.%s", self->dir, name, G_MODULE_SUFFIX);
+       gchar *path = g_strdup_printf("%s/%s.%s", plugins->dir, name, G_MODULE_SUFFIX);
        g_debug("GisPlugins: load - trying %s", path);
        if (!g_file_test(path, G_FILE_TEST_EXISTS)) {
                g_free(path);
@@ -170,62 +170,62 @@ GisPlugin *gis_plugins_load(GisPlugins *self, const char *name,
        GisPluginStore *store = g_new0(GisPluginStore, 1);
        store->name = g_strdup(name);
        store->plugin = constructor(viewer, prefs);
-       self->plugins = g_list_prepend(self->plugins, store);
+       plugins->plugins = g_list_prepend(plugins->plugins, store);
        return store->plugin;
 }
 
-GisPlugin *gis_plugins_enable(GisPlugins *self, const char *name,
+GisPlugin *gis_plugins_enable(GisPlugins *plugins, const char *name,
                GisViewer *viewer, GisPrefs *prefs)
 {
-       GisPlugin *plugin = gis_plugins_load(self, name, viewer, prefs);
-       gis_prefs_set_boolean_v(self->prefs, "plugins", name, TRUE);
+       GisPlugin *plugin = gis_plugins_load(plugins, name, viewer, prefs);
+       gis_prefs_set_boolean_v(plugins->prefs, "plugins", name, TRUE);
        return plugin;
 }
 
-GList *gis_plugins_load_enabled(GisPlugins *self,
+GList *gis_plugins_load_enabled(GisPlugins *plugins,
                GisViewer *viewer, GisPrefs *prefs)
 {
        GList *loaded = NULL;
-       for (GList *cur = gis_plugins_available(self); cur; cur = cur->next) {
+       for (GList *cur = gis_plugins_available(plugins); cur; cur = cur->next) {
                gchar *name = cur->data;
-               if (gis_prefs_get_boolean_v(self->prefs, "plugins", name, NULL)) {
-                       GisPlugin *plugin = gis_plugins_load(self, name, viewer, prefs);
+               if (gis_prefs_get_boolean_v(plugins->prefs, "plugins", name, NULL)) {
+                       GisPlugin *plugin = gis_plugins_load(plugins, name, viewer, prefs);
                        loaded = g_list_prepend(loaded, plugin);
                }
        }
        return loaded;
 }
 
-gboolean gis_plugins_unload(GisPlugins *self, const char *name)
+gboolean gis_plugins_unload(GisPlugins *plugins, const char *name)
 {
        g_debug("GisPlugins: unload %s", name);
-       for (GList *cur = self->plugins; cur; cur = cur->next) {
+       for (GList *cur = plugins->plugins; cur; cur = cur->next) {
                GisPluginStore *store = cur->data;
                if (g_str_equal(store->name, name)) {
                        g_object_unref(store->plugin);
                        g_free(store->name);
                        g_free(store);
-                       self->plugins = g_list_delete_link(self->plugins, cur);
+                       plugins->plugins = g_list_delete_link(plugins->plugins, cur);
                }
        }
        return FALSE;
 }
 
-gboolean gis_plugins_disable(GisPlugins *self, const char *name)
+gboolean gis_plugins_disable(GisPlugins *plugins, const char *name)
 {
-       gis_prefs_set_boolean_v(self->prefs, "plugins", name, FALSE);
-       gis_plugins_unload(self, name);
+       gis_prefs_set_boolean_v(plugins->prefs, "plugins", name, FALSE);
+       gis_plugins_unload(plugins, name);
        return FALSE;
 }
 
-void gis_plugins_foreach(GisPlugins *self, GCallback _callback, gpointer user_data)
+void gis_plugins_foreach(GisPlugins *plugins, GCallback _callback, gpointer user_data)
 {
        g_debug("GisPlugins: foreach");
-       if (self == NULL)
+       if (plugins == NULL)
                return;
        typedef void (*CBFunc)(GisPlugin *, const gchar *, gpointer);
        CBFunc callback = (CBFunc)_callback;
-       for (GList *cur = self->plugins; cur; cur = cur->next) {
+       for (GList *cur = plugins->plugins; cur; cur = cur->next) {
                GisPluginStore *store = cur->data;
                callback(store->plugin, store->name, user_data);
        }
index 26c0519..1bc73dc 100644 (file)
@@ -39,17 +39,17 @@ struct _GisPluginInterface
        const gchar *description;
 
        /* Virtual functions */
-       GtkWidget *(*get_config)(GisPlugin *self);
+       GtkWidget *(*get_config)(GisPlugin *plugin);
 };
 
 GType gis_plugin_get_type();
 
 /* Methods */
-const gchar *gis_plugin_get_name(GisPlugin *self);
+const gchar *gis_plugin_get_name(GisPlugin *plugin);
 
-const gchar *gis_plugin_get_description(GisPlugin *self);
+const gchar *gis_plugin_get_description(GisPlugin *plugin);
 
-GtkWidget *gis_plugin_get_config(GisPlugin *self);
+GtkWidget *gis_plugin_get_config(GisPlugin *plugin);
 
 /* Plugins API */
 #include "gis-viewer.h"
@@ -72,13 +72,13 @@ GList *gis_plugins_available(GisPlugins *plugins);
 GisPlugin *gis_plugins_load(GisPlugins *plugins, const char *name,
                GisViewer *viewer, GisPrefs *prefs);
 
-GisPlugin *gis_plugins_enable(GisPlugins *self, const char *name,
+GisPlugin *gis_plugins_enable(GisPlugins *plugin, const char *name,
                GisViewer *viewer, GisPrefs *prefs);
 
-GList *gis_plugins_load_enabled(GisPlugins *self,
+GList *gis_plugins_load_enabled(GisPlugins *plugin,
                GisViewer *viewer, GisPrefs *prefs);
 
-gboolean gis_plugins_disable(GisPlugins *self, const char *name);
+gboolean gis_plugins_disable(GisPlugins *plugin, const char *name);
 
 gboolean gis_plugins_unload(GisPlugins *plugins, const char *name);
 
index 95f3812..70b5006 100644 (file)
@@ -33,43 +33,43 @@ static guint signals[NUM_SIGNALS];
 GisPrefs *gis_prefs_new(const gchar *config, const gchar *defaults)
 {
        g_debug("GisPrefs: new - %s, %s", config, defaults);
-       GisPrefs *self = g_object_new(GIS_TYPE_PREFS, NULL);
+       GisPrefs *prefs = g_object_new(GIS_TYPE_PREFS, NULL);
        if (config)
-               self->key_path = g_strdup(config);
+               prefs->key_path = g_strdup(config);
        else
-               self->key_path = g_build_filename(g_get_user_config_dir(),
+               prefs->key_path = g_build_filename(g_get_user_config_dir(),
                                PACKAGE, "config.ini", NULL);
        GError *error = NULL;
-       g_key_file_load_from_file(self->key_file, self->key_path,
+       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_clear_error(&error);
-               g_key_file_load_from_file(self->key_file, defaults,
+               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_clear_error(&error);
                gchar *tmp = g_build_filename(PKGDATADIR, "defaults.ini", NULL);
-               g_key_file_load_from_file(self->key_file, tmp,
+               g_key_file_load_from_file(prefs->key_file, tmp,
                                G_KEY_FILE_KEEP_COMMENTS, &error);
                g_free(tmp);
        }
        if (error) {
                g_debug("GisPrefs: new - Unable to load key file `%s': %s",
-                       self->key_path, error->message);
+                       prefs->key_path, error->message);
        }
-       g_debug("GisPrefs: new - using %s", self->key_path);
-       return self;
+       g_debug("GisPrefs: 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 *self,                                      \
+c_type gis_prefs_get_##name##_v(GisPrefs *prefs,                                      \
                const gchar *group, const gchar *key, GError **_error)               \
 {                                                                                    \
        GError *error = NULL;                                                        \
-       c_type value = g_key_file_get_##name(self->key_file, group, key, &error);    \
+       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)                \
                g_warning("GisPrefs: get_value_##name - error getting key %s: %s\n", \
                                key, error->message);                                \
@@ -77,27 +77,27 @@ c_type gis_prefs_get_##name##_v(GisPrefs *self,
                *_error = error;                                                     \
        return value;                                                                \
 }                                                                                    \
-c_type gis_prefs_get_##name(GisPrefs *self, const gchar *key, GError **error)        \
+c_type gis_prefs_get_##name(GisPrefs *prefs, const gchar *key, GError **error)        \
 {                                                                                    \
        gchar **keys  = g_strsplit(key, "/", 2);                                     \
-       c_type value = gis_prefs_get_##name##_v(self, keys[0], keys[1], error);      \
+       c_type value = gis_prefs_get_##name##_v(prefs, keys[0], keys[1], error);      \
        g_strfreev(keys);                                                            \
        return value;                                                                \
 }                                                                                    \
                                                                                      \
-void gis_prefs_set_##name##_v(GisPrefs *self,                                        \
+void gis_prefs_set_##name##_v(GisPrefs *prefs,                                        \
                const gchar *group, const gchar *key, const c_type value)            \
 {                                                                                    \
-       g_key_file_set_##name(self->key_file, group, key, value);                    \
+       g_key_file_set_##name(prefs->key_file, group, key, value);                    \
        gchar *all = g_strconcat(group, "/", key, NULL);                             \
-       g_signal_emit(self, signals[SIG_PREF_CHANGED], 0,                            \
+       g_signal_emit(prefs, signals[SIG_PREF_CHANGED], 0,                            \
                        all, g_type, &value);                                        \
        g_free(all);                                                                 \
 }                                                                                    \
-void gis_prefs_set_##name(GisPrefs *self, const gchar *key, const c_type value)      \
+void gis_prefs_set_##name(GisPrefs *prefs, const gchar *key, const c_type value)      \
 {                                                                                    \
        gchar **keys = g_strsplit(key, "/", 2);                                      \
-       gis_prefs_set_##name##_v(self, keys[0], keys[1], value);                     \
+       gis_prefs_set_##name##_v(prefs, keys[0], keys[1], value);                     \
        g_strfreev(keys);                                                            \
 }                                                                                    \
 
@@ -111,28 +111,28 @@ 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 *self)
+static void gis_prefs_init(GisPrefs *prefs)
 {
        g_debug("GisPrefs: init");
-       self->key_file = g_key_file_new();
+       prefs->key_file = g_key_file_new();
 }
-static void gis_prefs_dispose(GObject *_self)
+static void gis_prefs_dispose(GObject *_prefs)
 {
        g_debug("GisPrefs: dispose");
-       GisPrefs *self = GIS_PREFS(_self);
-       if (self->key_file) {
+       GisPrefs *prefs = GIS_PREFS(_prefs);
+       if (prefs->key_file) {
                gsize length;
-               gchar *dir = g_path_get_dirname(self->key_path);
+               gchar *dir = g_path_get_dirname(prefs->key_path);
                g_mkdir_with_parents(dir, 0755);
-               gchar *data = g_key_file_to_data(self->key_file, &length, NULL);
-               g_file_set_contents(self->key_path, data, length, NULL);
-               g_key_file_free(self->key_file);
-               g_free(self->key_path);
+               gchar *data = g_key_file_to_data(prefs->key_file, &length, NULL);
+               g_file_set_contents(prefs->key_path, data, length, NULL);
+               g_key_file_free(prefs->key_file);
+               g_free(prefs->key_path);
                g_free(dir);
                g_free(data);
-               self->key_file = NULL;
+               prefs->key_file = NULL;
        }
-       G_OBJECT_CLASS(gis_prefs_parent_class)->dispose(_self);
+       G_OBJECT_CLASS(gis_prefs_parent_class)->dispose(_prefs);
 }
 static void gis_prefs_class_init(GisPrefsClass *klass)
 {
index 5b89a71..db244a4 100644 (file)
@@ -42,68 +42,68 @@ static guint signals[NUM_SIGNALS];
  * Helpers *
  ***********/
 /* Misc helpers */
-static void _gis_viewer_fix_location(GisViewer *self)
+static void _gis_viewer_fix_location(GisViewer *viewer)
 {
-       while (self->location[0] <  -90) self->location[0] += 180;
-       while (self->location[0] >   90) self->location[0] -= 180;
-       while (self->location[1] < -180) self->location[1] += 360;
-       while (self->location[1] >  180) self->location[1] -= 360;
-       self->location[2] = ABS(self->location[2]);
+       while (viewer->location[0] <  -90) viewer->location[0] += 180;
+       while (viewer->location[0] >   90) viewer->location[0] -= 180;
+       while (viewer->location[1] < -180) viewer->location[1] += 360;
+       while (viewer->location[1] >  180) viewer->location[1] -= 360;
+       viewer->location[2] = ABS(viewer->location[2]);
 }
 
 /* Signal helpers */
-static void _gis_viewer_emit_location_changed(GisViewer *self)
+static void _gis_viewer_emit_location_changed(GisViewer *viewer)
 {
-       g_signal_emit(self, signals[SIG_LOCATION_CHANGED], 0,
-                       self->location[0],
-                       self->location[1],
-                       self->location[2]);
+       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 *self)
+static void _gis_viewer_emit_rotation_changed(GisViewer *viewer)
 {
-       g_signal_emit(self, signals[SIG_ROTATION_CHANGED], 0,
-                       self->rotation[0],
-                       self->rotation[1],
-                       self->rotation[2]);
+       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 *self)
+static void _gis_viewer_emit_time_changed(GisViewer *viewer)
 {
-       g_signal_emit(self, signals[SIG_TIME_CHANGED], 0,
-                       self->time);
+       g_signal_emit(viewer, signals[SIG_TIME_CHANGED], 0,
+                       viewer->time);
 }
-static void _gis_viewer_emit_refresh(GisViewer *self)
+static void _gis_viewer_emit_refresh(GisViewer *viewer)
 {
-       g_signal_emit(self, signals[SIG_REFRESH], 0);
+       g_signal_emit(viewer, signals[SIG_REFRESH], 0);
 }
-static void _gis_viewer_emit_offline(GisViewer *self)
+static void _gis_viewer_emit_offline(GisViewer *viewer)
 {
-       g_signal_emit(self, signals[SIG_OFFLINE], 0,
-                       self->offline);
+       g_signal_emit(viewer, signals[SIG_OFFLINE], 0,
+                       viewer->offline);
 }
 
 /*************
  * Callbacks *
  *************/
-static gboolean on_key_press(GisViewer *self, GdkEventKey *event, gpointer _)
+static gboolean on_key_press(GisViewer *viewer, GdkEventKey *event, gpointer _)
 {
        g_debug("GisViewer: on_key_press - key=%x, state=%x, plus=%x",
                        event->keyval, event->state, GDK_plus);
 
        double lat, lon, elev, pan;
-       gis_viewer_get_location(self, &lat, &lon, &elev);
+       gis_viewer_get_location(viewer, &lat, &lon, &elev);
        pan = MIN(elev/(EARTH_R/2), 30);
        guint kv = event->keyval;
        gdk_threads_leave();
-       if      (kv == GDK_Left  || kv == GDK_h) gis_viewer_pan(self,  0,  -pan, 0);
-       else if (kv == GDK_Down  || kv == GDK_j) gis_viewer_pan(self, -pan, 0,   0);
-       else if (kv == GDK_Up    || kv == GDK_k) gis_viewer_pan(self,  pan, 0,   0);
-       else if (kv == GDK_Right || kv == GDK_l) gis_viewer_pan(self,  0,   pan, 0);
-       else if (kv == GDK_minus || kv == GDK_o) gis_viewer_zoom(self, 10./9);
-       else if (kv == GDK_plus  || kv == GDK_i) gis_viewer_zoom(self, 9./10);
-       else if (kv == GDK_H) gis_viewer_rotate(self,  0, 0, -2);
-       else if (kv == GDK_J) gis_viewer_rotate(self,  2, 0,  0);
-       else if (kv == GDK_K) gis_viewer_rotate(self, -2, 0,  0);
-       else if (kv == GDK_L) gis_viewer_rotate(self,  0, 0,  2);
+       if      (kv == GDK_Left  || kv == GDK_h) gis_viewer_pan(viewer,  0,  -pan, 0);
+       else if (kv == GDK_Down  || kv == GDK_j) gis_viewer_pan(viewer, -pan, 0,   0);
+       else if (kv == GDK_Up    || kv == GDK_k) gis_viewer_pan(viewer,  pan, 0,   0);
+       else if (kv == GDK_Right || kv == GDK_l) gis_viewer_pan(viewer,  0,   pan, 0);
+       else if (kv == GDK_minus || kv == GDK_o) gis_viewer_zoom(viewer, 10./9);
+       else if (kv == GDK_plus  || kv == GDK_i) gis_viewer_zoom(viewer, 9./10);
+       else if (kv == GDK_H) gis_viewer_rotate(viewer,  0, 0, -2);
+       else if (kv == GDK_J) gis_viewer_rotate(viewer,  2, 0,  0);
+       else if (kv == GDK_K) gis_viewer_rotate(viewer, -2, 0,  0);
+       else if (kv == GDK_L) gis_viewer_rotate(viewer,  0, 0,  2);
        return FALSE;
 }
 
@@ -114,110 +114,110 @@ enum {
        GIS_DRAG_TILT,
 };
 
-static gboolean on_button_press(GisViewer *self, GdkEventButton *event, gpointer _)
+static gboolean on_button_press(GisViewer *viewer, GdkEventButton *event, gpointer _)
 {
        g_debug("GisViewer: on_button_press - %d", event->button);
-       gtk_widget_grab_focus(GTK_WIDGET(self));
+       gtk_widget_grab_focus(GTK_WIDGET(viewer));
        switch (event->button) {
-       case 1:  self->drag_mode = GIS_DRAG_PAN;  break;
-       case 2:  self->drag_mode = GIS_DRAG_ZOOM; break;
-       case 3:  self->drag_mode = GIS_DRAG_TILT; break;
-       defualt: self->drag_mode = GIS_DRAG_NONE; break;
+       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;
+       defualt: viewer->drag_mode = GIS_DRAG_NONE; break;
        }
-       self->drag_x = event->x;
-       self->drag_y = event->y;
+       viewer->drag_x = event->x;
+       viewer->drag_y = event->y;
        return FALSE;
 }
 
-static gboolean on_button_release(GisViewer *self, GdkEventButton *event, gpointer _)
+static gboolean on_button_release(GisViewer *viewer, GdkEventButton *event, gpointer _)
 {
        g_debug("GisViewer: on_button_release");
-       self->drag_mode = GIS_DRAG_NONE;
+       viewer->drag_mode = GIS_DRAG_NONE;
        return FALSE;
 }
 
-static gboolean on_motion_notify(GisViewer *self, GdkEventMotion *event, gpointer _)
+static gboolean on_motion_notify(GisViewer *viewer, GdkEventMotion *event, gpointer _)
 {
-       gdouble x_dist = self->drag_x - event->x;
-       gdouble y_dist = self->drag_y - event->y;
+       gdouble x_dist = viewer->drag_x - event->x;
+       gdouble y_dist = viewer->drag_y - event->y;
        gdouble lat, lon, elev, scale;
-       gis_viewer_get_location(GIS_VIEWER(self), &lat, &lon, &elev);
+       gis_viewer_get_location(GIS_VIEWER(viewer), &lat, &lon, &elev);
        scale = elev/EARTH_R/15;
-       switch (self->drag_mode) {
+       switch (viewer->drag_mode) {
        case GIS_DRAG_PAN:
-               gis_viewer_pan(self, -y_dist*scale, x_dist*scale, 0);
+               gis_viewer_pan(viewer, -y_dist*scale, x_dist*scale, 0);
                break;
        case GIS_DRAG_ZOOM:
-               gis_viewer_zoom(self, pow(2, -y_dist/500));
+               gis_viewer_zoom(viewer, pow(2, -y_dist/500));
                break;
        case GIS_DRAG_TILT:
-               gis_viewer_rotate(self, y_dist/10, 0, x_dist/10);
+               gis_viewer_rotate(viewer, y_dist/10, 0, x_dist/10);
                break;
        }
-       self->drag_x = event->x;
-       self->drag_y = event->y;
+       viewer->drag_x = event->x;
+       viewer->drag_y = event->y;
        return FALSE;
 }
 
-static void on_view_changed(GisViewer *self,
+static void on_view_changed(GisViewer *viewer,
                gdouble _1, gdouble _2, gdouble _3)
 {
-       gtk_widget_queue_draw(GTK_WIDGET(self));
+       gtk_widget_queue_draw(GTK_WIDGET(viewer));
 }
 
 /***********
  * Methods *
  ***********/
-void gis_viewer_setup(GisViewer *self, GisPlugins *plugins, GisPrefs *prefs)
+void gis_viewer_setup(GisViewer *viewer, GisPlugins *plugins, GisPrefs *prefs)
 {
-       self->plugins = plugins;
-       self->prefs   = prefs;
-       self->offline = gis_prefs_get_boolean(prefs, "gis/offline", NULL);
+       viewer->plugins = plugins;
+       viewer->prefs   = prefs;
+       viewer->offline = gis_prefs_get_boolean(prefs, "gis/offline", NULL);
 }
 
-void gis_viewer_set_time(GisViewer *self, const char *time)
+void gis_viewer_set_time(GisViewer *viewer, const char *time)
 {
-       g_assert(GIS_IS_VIEWER(self));
+       g_assert(GIS_IS_VIEWER(viewer));
        g_debug("GisViewer: set_time - time=%s", time);
-       g_free(self->time);
-       self->time = g_strdup(time);
-       _gis_viewer_emit_time_changed(self);
+       g_free(viewer->time);
+       viewer->time = g_strdup(time);
+       _gis_viewer_emit_time_changed(viewer);
 }
 
-gchar *gis_viewer_get_time(GisViewer *self)
+gchar *gis_viewer_get_time(GisViewer *viewer)
 {
-       g_assert(GIS_IS_VIEWER(self));
+       g_assert(GIS_IS_VIEWER(viewer));
        g_debug("GisViewer: get_time");
-       return self->time;
+       return viewer->time;
 }
 
-void gis_viewer_set_location(GisViewer *self, gdouble lat, gdouble lon, gdouble elev)
+void gis_viewer_set_location(GisViewer *viewer, gdouble lat, gdouble lon, gdouble elev)
 {
-       g_assert(GIS_IS_VIEWER(self));
+       g_assert(GIS_IS_VIEWER(viewer));
        g_debug("GisViewer: set_location");
-       self->location[0] = lat;
-       self->location[1] = lon;
-       self->location[2] = elev;
-       _gis_viewer_fix_location(self);
-       _gis_viewer_emit_location_changed(self);
+       viewer->location[0] = lat;
+       viewer->location[1] = lon;
+       viewer->location[2] = elev;
+       _gis_viewer_fix_location(viewer);
+       _gis_viewer_emit_location_changed(viewer);
 }
 
-void gis_viewer_get_location(GisViewer *self, gdouble *lat, gdouble *lon, gdouble *elev)
+void gis_viewer_get_location(GisViewer *viewer, gdouble *lat, gdouble *lon, gdouble *elev)
 {
-       g_assert(GIS_IS_VIEWER(self));
+       g_assert(GIS_IS_VIEWER(viewer));
        //g_debug("GisViewer: get_location");
-       *lat  = self->location[0];
-       *lon  = self->location[1];
-       *elev = self->location[2];
+       *lat  = viewer->location[0];
+       *lon  = viewer->location[1];
+       *elev = viewer->location[2];
 }
 
-void gis_viewer_pan(GisViewer *self, gdouble forward, gdouble sideways, gdouble up)
+void gis_viewer_pan(GisViewer *viewer, gdouble forward, gdouble sideways, gdouble up)
 {
-       g_assert(GIS_IS_VIEWER(self));
+       g_assert(GIS_IS_VIEWER(viewer));
        g_debug("GisViewer: pan - forward=%8.3f, sideways=%8.3f, up=%8.3f",
                        forward, sideways, up);
        gdouble dist   = sqrt(forward*forward + sideways*sideways);
-       gdouble angle1 = deg2rad(self->rotation[2]);
+       gdouble angle1 = deg2rad(viewer->rotation[2]);
        gdouble angle2 = atan2(sideways, forward);
        gdouble angle  = angle1 + angle2;
        g_message("pan: dist=%f, angle=%f+%f=%f move=%f,%f",
@@ -225,164 +225,164 @@ void gis_viewer_pan(GisViewer *self, gdouble forward, gdouble sideways, gdouble
                        dist*cos(angle),
                        dist*sin(angle));
        /* This isn't accurate, but it's usable */
-       self->location[0] += dist*cos(angle);
-       self->location[1] += dist*sin(angle);
-       self->location[2] += up;
-       _gis_viewer_fix_location(self);
-       _gis_viewer_emit_location_changed(self);
+       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);
 }
 
-void gis_viewer_zoom(GisViewer *self, gdouble scale)
+void gis_viewer_zoom(GisViewer *viewer, gdouble scale)
 {
-       g_assert(GIS_IS_VIEWER(self));
+       g_assert(GIS_IS_VIEWER(viewer));
        g_debug("GisViewer: zoom");
-       self->location[2] *= scale;
-       _gis_viewer_emit_location_changed(self);
+       viewer->location[2] *= scale;
+       _gis_viewer_emit_location_changed(viewer);
 }
 
-void gis_viewer_set_rotation(GisViewer *self, gdouble x, gdouble y, gdouble z)
+void gis_viewer_set_rotation(GisViewer *viewer, gdouble x, gdouble y, gdouble z)
 {
-       g_assert(GIS_IS_VIEWER(self));
+       g_assert(GIS_IS_VIEWER(viewer));
        g_debug("GisViewer: set_rotation");
-       self->rotation[0] = x;
-       self->rotation[1] = y;
-       self->rotation[2] = z;
-       _gis_viewer_emit_rotation_changed(self);
+       viewer->rotation[0] = x;
+       viewer->rotation[1] = y;
+       viewer->rotation[2] = z;
+       _gis_viewer_emit_rotation_changed(viewer);
 }
 
-void gis_viewer_get_rotation(GisViewer *self, gdouble *x, gdouble *y, gdouble *z)
+void gis_viewer_get_rotation(GisViewer *viewer, gdouble *x, gdouble *y, gdouble *z)
 {
-       g_assert(GIS_IS_VIEWER(self));
+       g_assert(GIS_IS_VIEWER(viewer));
        g_debug("GisViewer: get_rotation");
-       *x = self->rotation[0];
-       *y = self->rotation[1];
-       *z = self->rotation[2];
+       *x = viewer->rotation[0];
+       *y = viewer->rotation[1];
+       *z = viewer->rotation[2];
 }
 
-void gis_viewer_rotate(GisViewer *self, gdouble x, gdouble y, gdouble z)
+void gis_viewer_rotate(GisViewer *viewer, gdouble x, gdouble y, gdouble z)
 {
-       g_assert(GIS_IS_VIEWER(self));
+       g_assert(GIS_IS_VIEWER(viewer));
        g_debug("GisViewer: rotate - x=%.0f, y=%.0f, z=%.0f", x, y, z);
-       self->rotation[0] += x;
-       self->rotation[1] += y;
-       self->rotation[2] += z;
-       _gis_viewer_emit_rotation_changed(self);
+       viewer->rotation[0] += x;
+       viewer->rotation[1] += y;
+       viewer->rotation[2] += z;
+       _gis_viewer_emit_rotation_changed(viewer);
 }
 
-void gis_viewer_refresh(GisViewer *self)
+void gis_viewer_refresh(GisViewer *viewer)
 {
        g_debug("GisViewer: refresh");
-       _gis_viewer_emit_refresh(self);
+       _gis_viewer_emit_refresh(viewer);
 }
 
-void gis_viewer_set_offline(GisViewer *self, gboolean offline)
+void gis_viewer_set_offline(GisViewer *viewer, gboolean offline)
 {
-       g_assert(GIS_IS_VIEWER(self));
+       g_assert(GIS_IS_VIEWER(viewer));
        g_debug("GisViewer: set_offline - %d", offline);
-       gis_prefs_set_boolean(self->prefs, "gis/offline", offline);
-       self->offline = offline;
-       _gis_viewer_emit_offline(self);
+       gis_prefs_set_boolean(viewer->prefs, "gis/offline", offline);
+       viewer->offline = offline;
+       _gis_viewer_emit_offline(viewer);
 }
 
-gboolean gis_viewer_get_offline(GisViewer *self)
+gboolean gis_viewer_get_offline(GisViewer *viewer)
 {
-       g_assert(GIS_IS_VIEWER(self));
-       g_debug("GisViewer: get_offline - %d", self->offline);
-       return self->offline;
+       g_assert(GIS_IS_VIEWER(viewer));
+       g_debug("GisViewer: get_offline - %d", viewer->offline);
+       return viewer->offline;
 }
 
 /* To be implemented by subclasses */
-void gis_viewer_center_position(GisViewer *self,
+void gis_viewer_center_position(GisViewer *viewer,
                gdouble lat, gdouble lon, gdouble elev)
 {
-       GisViewerClass *klass = GIS_VIEWER_GET_CLASS(self);
+       GisViewerClass *klass = GIS_VIEWER_GET_CLASS(viewer);
        if (!klass->center_position)
                g_warning("GisViewer: center_position - Unimplemented");
-       klass->center_position(self, lat, lon, elev);
+       klass->center_position(viewer, lat, lon, elev);
 }
 
-void gis_viewer_project(GisViewer *self,
+void gis_viewer_project(GisViewer *viewer,
                gdouble lat, gdouble lon, gdouble elev,
                gdouble *px, gdouble *py, gdouble *pz)
 {
-       GisViewerClass *klass = GIS_VIEWER_GET_CLASS(self);
+       GisViewerClass *klass = GIS_VIEWER_GET_CLASS(viewer);
        if (!klass->project)
                g_warning("GisViewer: project - Unimplemented");
-       klass->project(self, lat, lon, elev, px, py, pz);
+       klass->project(viewer, lat, lon, elev, px, py, pz);
 }
 
-void gis_viewer_clear_height_func(GisViewer *self)
+void gis_viewer_clear_height_func(GisViewer *viewer)
 {
-       GisViewerClass *klass = GIS_VIEWER_GET_CLASS(self);
+       GisViewerClass *klass = GIS_VIEWER_GET_CLASS(viewer);
        if (!klass->clear_height_func)
                g_warning("GisViewer: clear_height_func - Unimplemented");
-       klass->clear_height_func(self);
+       klass->clear_height_func(viewer);
 }
 
-void gis_viewer_set_height_func(GisViewer *self, GisTile *tile,
+void gis_viewer_set_height_func(GisViewer *viewer, GisTile *tile,
                GisHeightFunc height_func, gpointer user_data,
                gboolean update)
 {
-       GisViewerClass *klass = GIS_VIEWER_GET_CLASS(self);
+       GisViewerClass *klass = GIS_VIEWER_GET_CLASS(viewer);
        if (!klass->set_height_func)
                g_warning("GisViewer: set_height_func - Unimplemented");
-       klass->set_height_func(self, tile, height_func, user_data, update);
+       klass->set_height_func(viewer, tile, height_func, user_data, update);
 }
 
-gpointer gis_viewer_add(GisViewer *self, GisObject *object,
+gpointer gis_viewer_add(GisViewer *viewer, GisObject *object,
                gint level, gboolean sort)
 {
-       GisViewerClass *klass = GIS_VIEWER_GET_CLASS(self);
+       GisViewerClass *klass = GIS_VIEWER_GET_CLASS(viewer);
        if (!klass->add)
                g_warning("GisViewer: add - Unimplemented");
-       return klass->add(self, object, level, sort);
+       return klass->add(viewer, object, level, sort);
 }
 
-GisObject *gis_viewer_remove(GisViewer *self, gpointer ref)
+GisObject *gis_viewer_remove(GisViewer *viewer, gpointer ref)
 {
-       GisViewerClass *klass = GIS_VIEWER_GET_CLASS(self);
+       GisViewerClass *klass = GIS_VIEWER_GET_CLASS(viewer);
        if (!klass->remove)
                g_warning("GisViewer: remove - Unimplemented");
-       return klass->remove(self, ref);
+       return klass->remove(viewer, ref);
 }
 
 /****************
  * GObject code *
  ****************/
 G_DEFINE_ABSTRACT_TYPE(GisViewer, gis_viewer, GTK_TYPE_DRAWING_AREA);
-static void gis_viewer_init(GisViewer *self)
+static void gis_viewer_init(GisViewer *viewer)
 {
        g_debug("GisViewer: init");
        /* Default values */
-       self->time = g_strdup("");
-       self->location[0] = 40;
-       self->location[1] = -100;
-       self->location[2] = 1.5*EARTH_R;
-       self->rotation[0] = 0;
-       self->rotation[1] = 0;
-       self->rotation[2] = 0;
-
-       g_object_set(self, "can-focus", TRUE, NULL);
-       gtk_widget_add_events(GTK_WIDGET(self),
+       viewer->time = g_strdup("");
+       viewer->location[0] = 40;
+       viewer->location[1] = -100;
+       viewer->location[2] = 1.5*EARTH_R;
+       viewer->rotation[0] = 0;
+       viewer->rotation[1] = 0;
+       viewer->rotation[2] = 0;
+
+       g_object_set(viewer, "can-focus", TRUE, NULL);
+       gtk_widget_add_events(GTK_WIDGET(viewer),
                        GDK_BUTTON_PRESS_MASK |
                        GDK_BUTTON_RELEASE_MASK |
                        GDK_POINTER_MOTION_MASK |
                        GDK_KEY_PRESS_MASK);
 
-       g_signal_connect(self, "key-press-event",      G_CALLBACK(on_key_press),      NULL);
+       g_signal_connect(viewer, "key-press-event",      G_CALLBACK(on_key_press),      NULL);
 
-       g_signal_connect(self, "button-press-event",   G_CALLBACK(on_button_press),   NULL);
-       g_signal_connect(self, "button-release-event", G_CALLBACK(on_button_release), NULL);
-       g_signal_connect(self, "motion-notify-event",  G_CALLBACK(on_motion_notify),  NULL);
+       g_signal_connect(viewer, "button-press-event",   G_CALLBACK(on_button_press),   NULL);
+       g_signal_connect(viewer, "button-release-event", G_CALLBACK(on_button_release), NULL);
+       g_signal_connect(viewer, "motion-notify-event",  G_CALLBACK(on_motion_notify),  NULL);
 
-       g_signal_connect(self, "location-changed",     G_CALLBACK(on_view_changed),   NULL);
-       g_signal_connect(self, "rotation-changed",     G_CALLBACK(on_view_changed),   NULL);
+       g_signal_connect(viewer, "location-changed",     G_CALLBACK(on_view_changed),   NULL);
+       g_signal_connect(viewer, "rotation-changed",     G_CALLBACK(on_view_changed),   NULL);
 }
 static void gis_viewer_finalize(GObject *gobject)
 {
        g_debug("GisViewer: finalize");
-       GisViewer *self = GIS_VIEWER(gobject);
-       g_free(self->time);
+       GisViewer *viewer = GIS_VIEWER(gobject);
+       g_free(viewer->time);
        G_OBJECT_CLASS(gis_viewer_parent_class)->finalize(gobject);
 }
 static void gis_viewer_class_init(GisViewerClass *klass)
index ea07348..fbc9767 100644 (file)
@@ -72,8 +72,8 @@ struct _GisViewerClass {
                                  gdouble lat, gdouble lon, gdouble elev,
                                  gdouble *px, gdouble *py, gdouble *pz);
 
-       void (*clear_height_func)(GisViewer *self);
-       void (*set_height_func)  (GisViewer *self, GisTile *tile,
+       void (*clear_height_func)(GisViewer *viewer);
+       void (*set_height_func)  (GisViewer *viewer, GisTile *tile,
                                  GisHeightFunc height_func, gpointer user_data,
                                  gboolean update);
 
@@ -92,7 +92,7 @@ gchar *gis_viewer_get_time(GisViewer *viewer);
 
 void gis_viewer_set_location(GisViewer *viewer, gdouble  lat, gdouble  lon, gdouble  elev);
 void gis_viewer_get_location(GisViewer *viewer, gdouble *lat, gdouble *lon, gdouble *elev);
-void gis_viewer_pan(GisViewer *self, gdouble forward, gdouble sideways, gdouble up);
+void gis_viewer_pan(GisViewer *viewer, gdouble forward, gdouble sideways, gdouble up);
 void gis_viewer_zoom(GisViewer *viewer, gdouble  scale);
 
 void gis_viewer_set_rotation(GisViewer *viewer, gdouble  x, gdouble  y, gdouble  z);
@@ -112,13 +112,13 @@ void gis_viewer_project(GisViewer *viewer,
                gdouble lat, gdouble lon, gdouble elev,
                gdouble *px, gdouble *py, gdouble *pz);
 
-void gis_viewer_clear_height_func(GisViewer *self);
-void gis_viewer_set_height_func(GisViewer *self, GisTile *tile,
+void gis_viewer_clear_height_func(GisViewer *viewer);
+void gis_viewer_set_height_func(GisViewer *viewer, GisTile *tile,
                GisHeightFunc height_func, gpointer user_data,
                gboolean update);
 
-gpointer gis_viewer_add(GisViewer *self, GisObject *object,
+gpointer gis_viewer_add(GisViewer *viewer, GisObject *object,
                gint level, gboolean sort);
-GisObject *gis_viewer_remove(GisViewer *self, gpointer ref);
+GisObject *gis_viewer_remove(GisViewer *viewer, gpointer ref);
 
 #endif
index b739159..79d8300 100644 (file)
 
 /* GisCallback */
 G_DEFINE_TYPE(GisCallback, gis_callback, GIS_TYPE_OBJECT);
-static void gis_callback_init(GisCallback *self) { }
+static void gis_callback_init(GisCallback *cb) { }
 static void gis_callback_class_init(GisCallbackClass *klass) { }
 
 GisCallback *gis_callback_new(GisCallbackFunc callback, gpointer user_data)
 {
-       GisCallback *self = g_object_new(GIS_TYPE_CALLBACK, NULL);
-       self->callback  = callback;
-       self->user_data = user_data;
-       return self;
+       GisCallback *cb = g_object_new(GIS_TYPE_CALLBACK, NULL);
+       cb->callback  = callback;
+       cb->user_data = user_data;
+       return cb;
 }
index 42639ad..69e8ad5 100644 (file)
@@ -26,32 +26,32 @@ GisMarker *gis_marker_new(const gchar *label)
        static const int WIDTH  = 100;
        static const int HEIGHT =  20;
 
-       GisMarker *self = g_object_new(GIS_TYPE_MARKER, NULL);
-       self->xoff  = RADIUS;
-       self->yoff  = HEIGHT-RADIUS;
-       self->label = g_strdup(label);
-       self->cairo = cairo_create(cairo_image_surface_create(
+       GisMarker *marker = g_object_new(GIS_TYPE_MARKER, NULL);
+       marker->xoff  = RADIUS;
+       marker->yoff  = HEIGHT-RADIUS;
+       marker->label = g_strdup(label);
+       marker->cairo = cairo_create(cairo_image_surface_create(
                                CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT));
-       cairo_set_source_rgba(self->cairo, 1, 1, 1, 1);
-       cairo_arc(self->cairo, self->xoff, self->yoff, RADIUS, 0, 2*G_PI);
-       cairo_fill(self->cairo);
-       cairo_move_to(self->cairo, self->xoff+4, self->yoff-8);
-       cairo_set_font_size(self->cairo, 10);
-       cairo_show_text(self->cairo, self->label);
-       return self;
+       cairo_set_source_rgba(marker->cairo, 1, 1, 1, 1);
+       cairo_arc(marker->cairo, marker->xoff, marker->yoff, RADIUS, 0, 2*G_PI);
+       cairo_fill(marker->cairo);
+       cairo_move_to(marker->cairo, marker->xoff+4, marker->yoff-8);
+       cairo_set_font_size(marker->cairo, 10);
+       cairo_show_text(marker->cairo, marker->label);
+       return marker;
 }
 
 G_DEFINE_TYPE(GisMarker, gis_marker, GIS_TYPE_OBJECT);
-static void gis_marker_init(GisMarker *self) { }
+static void gis_marker_init(GisMarker *marker) { }
 
-static void gis_marker_finalize(GObject *_self)
+static void gis_marker_finalize(GObject *_marker)
 {
-       GisMarker *self = GIS_MARKER(_self);
-       //g_debug("GisMarker: finalize - %s", self->label);
-       cairo_surface_t *surface = cairo_get_target(self->cairo);
+       GisMarker *marker = GIS_MARKER(_marker);
+       //g_debug("GisMarker: finalize - %s", marker->label);
+       cairo_surface_t *surface = cairo_get_target(marker->cairo);
        cairo_surface_destroy(surface);
-       cairo_destroy(self->cairo);
-       g_free(self->label);
+       cairo_destroy(marker->cairo);
+       g_free(marker->label);
 }
 
 static void gis_marker_class_init(GisMarkerClass *klass)
index b869337..e7f4b06 100644 (file)
@@ -24,20 +24,20 @@ GisPoint *gis_point_new()
        return g_new0(GisPoint, 1);
 }
 
-void gis_point_set_lle(GisPoint *self, gdouble lat, gdouble lon, gdouble elev)
+void gis_point_set_lle(GisPoint *point, gdouble lat, gdouble lon, gdouble elev)
 {
-       self->lat  = lat;
-       self->lon  = lon;
-       self->elev = elev;
+       point->lat  = lat;
+       point->lon  = lon;
+       point->elev = elev;
 }
 
-void gis_point_free(GisPoint *self)
+void gis_point_free(GisPoint *point)
 {
-       g_free(self);
+       g_free(point);
 }
 
 
 /* GisObject */
 G_DEFINE_TYPE(GisObject, gis_object, G_TYPE_OBJECT);
-static void gis_object_init(GisObject *self) { }
+static void gis_object_init(GisObject *object) { }
 static void gis_object_class_init(GisObjectClass *klass) { }
index baf21db..4055d87 100644 (file)
@@ -51,7 +51,7 @@ static inline Mam##Bar##Class *MAM##_##BAR##_GET_CLASS(gpointer obj) { \
                Mam, Bar, \
                mam, bar) \
 G_DEFINE_TYPE(Mam##Bar, mam##_##bar, parent_type); \
-static void mam##_##bar##_init(Mam##Bar *self) { \
+static void mam##_##bar##_init(Mam##Bar *mambar) { \
 } \
 static void mam##_##bar##_class_init(Mam##Bar##Class *klass) { \
 } \
index 14430f4..fce15e5 100644 (file)
@@ -27,14 +27,14 @@ gchar *gis_tile_path_table[2][2] = {
 GisTile *gis_tile_new(GisTile *parent,
        gdouble n, gdouble s, gdouble e, gdouble w)
 {
-       GisTile *self = g_object_new(GIS_TYPE_TILE, NULL);
-       self->parent = parent;
-       self->edge.n = n;
-       self->edge.s = s;
-       self->edge.e = e;
-       self->edge.w = w;
-       self->atime  = time(NULL);
-       return self;
+       GisTile *tile = g_object_new(GIS_TYPE_TILE, NULL);
+       tile->parent = parent;
+       tile->edge.n = n;
+       tile->edge.s = s;
+       tile->edge.e = e;
+       tile->edge.w = w;
+       tile->atime  = time(NULL);
+       return tile;
 }
 
 gchar *gis_tile_get_path(GisTile *child)
@@ -53,13 +53,13 @@ gchar *gis_tile_get_path(GisTile *child)
        return g_string_free(path, FALSE);
 }
 
-gdouble _gis_tile_get_min_dist(GisTile *self,
+gdouble _gis_tile_get_min_dist(GisTile *tile,
                gdouble lat, gdouble lon, gdouble elev)
 {
-       gdouble tlat  = lat > self->edge.n ? self->edge.n :
-                        lat < self->edge.s ? self->edge.s : lat;
-       gdouble tlon  = lon > self->edge.e ? self->edge.e :
-                       lon < self->edge.w ? self->edge.w : lon;
+       gdouble tlat  = lat > tile->edge.n ? tile->edge.n :
+                        lat < tile->edge.s ? tile->edge.s : lat;
+       gdouble tlon  = lon > tile->edge.e ? tile->edge.e :
+                       lon < tile->edge.w ? tile->edge.w : lon;
        gdouble telev = 0; // TODO: elevation at rlat,rlon
        //if (lat == tlat && lon == tlon)
        //      return elev; /* Shortcut? */
@@ -69,15 +69,15 @@ gdouble _gis_tile_get_min_dist(GisTile *self,
        return distd(a, b);
 }
 
-gboolean _gis_tile_needs_split(GisTile *self,
+gboolean _gis_tile_needs_split(GisTile *tile,
                gdouble max_res, gint width, gint height,
                gdouble lat, gdouble lon, gdouble elev)
 {
-       gdouble lat_point = self->edge.n < 0 ? self->edge.n :
-                           self->edge.s > 0 ? self->edge.s : 0;
-       gdouble min_dist  = _gis_tile_get_min_dist(self, lat, lon, elev);
+       gdouble lat_point = tile->edge.n < 0 ? tile->edge.n :
+                           tile->edge.s > 0 ? tile->edge.s : 0;
+       gdouble min_dist  = _gis_tile_get_min_dist(tile, lat, lon, elev);
        gdouble view_res  = MPPX(min_dist);
-       gdouble lon_dist  = self->edge.e - self->edge.w;
+       gdouble lon_dist  = tile->edge.e - tile->edge.w;
        gdouble tile_res  = ll2m(lon_dist, lat_point)/width;
 
        /* This isn't really right, but it helps with memory since we don't (yet?) test if the tile
@@ -87,7 +87,7 @@ gboolean _gis_tile_needs_split(GisTile *self,
        //g_message("tile=(%7.2f %7.2f %7.2f %7.2f) "
        //          "eye=(%9.1f %9.1f %9.1f) "
        //          "elev=%9.1f / dist=%9.1f = %f",
-       //              self->edge.n, self->edge.s, self->edge.e, self->edge.w,
+       //              tile->edge.n, tile->edge.s, tile->edge.e, tile->edge.w,
        //              lat, lon, elev,
        //              elev, min_dist, scale);
 
@@ -96,29 +96,29 @@ gboolean _gis_tile_needs_split(GisTile *self,
        return view_res < tile_res;
 }
 
-void gis_tile_update(GisTile *self,
+void gis_tile_update(GisTile *tile,
                gdouble res, gint width, gint height,
                gdouble lat, gdouble lon, gdouble elev,
                GisTileLoadFunc load_func, gpointer user_data)
 {
-       self->atime = time(NULL);
-       //g_debug("GisTile: update - %p->atime = %u", self, (guint)self->atime);
-       gdouble lat_dist = self->edge.n - self->edge.s;
-       gdouble lon_dist = self->edge.e - self->edge.w;
-       if (_gis_tile_needs_split(self, res, width, height, lat, lon, elev)) {
-               gdouble lat_step = lat_dist / G_N_ELEMENTS(self->children);
-               gdouble lon_step = lon_dist / G_N_ELEMENTS(self->children[0]);
+       tile->atime = time(NULL);
+       //g_debug("GisTile: update - %p->atime = %u", tile, (guint)tile->atime);
+       gdouble lat_dist = tile->edge.n - tile->edge.s;
+       gdouble lon_dist = tile->edge.e - tile->edge.w;
+       if (_gis_tile_needs_split(tile, res, width, height, lat, lon, elev)) {
+               gdouble lat_step = lat_dist / G_N_ELEMENTS(tile->children);
+               gdouble lon_step = lon_dist / G_N_ELEMENTS(tile->children[0]);
                int x, y;
-               gis_tile_foreach_index(self, x, y) {
-                       if (!self->children[x][y]) {
-                               self->children[x][y] = gis_tile_new(self,
-                                               self->edge.n-(lat_step*(x+0)),
-                                               self->edge.n-(lat_step*(x+1)),
-                                               self->edge.w+(lon_step*(y+1)),
-                                               self->edge.w+(lon_step*(y+0)));
-                               load_func(self->children[x][y], user_data);
+               gis_tile_foreach_index(tile, x, y) {
+                       if (!tile->children[x][y]) {
+                               tile->children[x][y] = gis_tile_new(tile,
+                                               tile->edge.n-(lat_step*(x+0)),
+                                               tile->edge.n-(lat_step*(x+1)),
+                                               tile->edge.w+(lon_step*(y+1)),
+                                               tile->edge.w+(lon_step*(y+0)));
+                               load_func(tile->children[x][y], user_data);
                        }
-                       gis_tile_update(self->children[x][y],
+                       gis_tile_update(tile->children[x][y],
                                        res, width, height,
                                        lat, lon, elev,
                                        load_func, user_data);
@@ -126,16 +126,16 @@ void gis_tile_update(GisTile *self,
        }
 }
 
-GisTile *gis_tile_find(GisTile *self, gdouble lat, gdouble lon)
+GisTile *gis_tile_find(GisTile *tile, gdouble lat, gdouble lon)
 {
-       gint    rows = G_N_ELEMENTS(self->children);
-       gint    cols = G_N_ELEMENTS(self->children[0]);
+       gint    rows = G_N_ELEMENTS(tile->children);
+       gint    cols = G_N_ELEMENTS(tile->children[0]);
 
-       gdouble lat_step = (self->edge.n - self->edge.s) / rows;
-       gdouble lon_step = (self->edge.e - self->edge.w) / cols;
+       gdouble lat_step = (tile->edge.n - tile->edge.s) / rows;
+       gdouble lon_step = (tile->edge.e - tile->edge.w) / cols;
 
-       gdouble lat_offset = self->edge.n - lat;;
-       gdouble lon_offset = lon - self->edge.w;
+       gdouble lat_offset = tile->edge.n - lat;;
+       gdouble lon_offset = lon - tile->edge.w;
 
        gint    row = lat_offset / lat_step;
        gint    col = lon_offset / lon_step;
@@ -149,50 +149,50 @@ GisTile *gis_tile_find(GisTile *self, gdouble lat, gdouble lon)
 
        if (row < 0 || row >= rows || col < 0 || col >= cols)
                return NULL;
-       else if (self->children[row][col] && self->children[row][col]->data)
-               return gis_tile_find(self->children[row][col], lat, lon);
+       else if (tile->children[row][col] && tile->children[row][col]->data)
+               return gis_tile_find(tile->children[row][col], lat, lon);
        else
-               return self;
+               return tile;
 }
 
-GisTile *gis_tile_gc(GisTile *self, time_t atime,
+GisTile *gis_tile_gc(GisTile *tile, time_t atime,
                GisTileFreeFunc free_func, gpointer user_data)
 {
-       if (!self)
+       if (!tile)
                return NULL;
        gboolean has_children = FALSE;
        int x, y;
-       gis_tile_foreach_index(self, x, y) {
-               self->children[x][y] = gis_tile_gc(
-                               self->children[x][y], atime,
+       gis_tile_foreach_index(tile, x, y) {
+               tile->children[x][y] = gis_tile_gc(
+                               tile->children[x][y], atime,
                                free_func, user_data);
-               if (self->children[x][y])
+               if (tile->children[x][y])
                        has_children = TRUE;
        }
        //g_debug("GisTile: gc - %p->atime=%u < atime=%u",
-       //              self, (guint)self->atime, (guint)atime);
-       if (!has_children && self->atime < atime && self->data) {
-               free_func(self, user_data);
-               g_object_unref(self);
+       //              tile, (guint)tile->atime, (guint)atime);
+       if (!has_children && tile->atime < atime && tile->data) {
+               free_func(tile, user_data);
+               g_object_unref(tile);
                return NULL;
        }
-       return self;
+       return tile;
 }
 
 /* Use GObject for this */
-void gis_tile_free(GisTile *self, GisTileFreeFunc free_func, gpointer user_data)
+void gis_tile_free(GisTile *tile, GisTileFreeFunc free_func, gpointer user_data)
 {
-       if (!self)
+       if (!tile)
                return;
        GisTile *child;
-       gis_tile_foreach(self, child)
+       gis_tile_foreach(tile, child)
                gis_tile_free(child, free_func, user_data);
        if (free_func)
-               free_func(self, user_data);
-       g_object_unref(self);
+               free_func(tile, user_data);
+       g_object_unref(tile);
 }
 
 /* GObject code */
 G_DEFINE_TYPE(GisTile, gis_tile, GIS_TYPE_OBJECT);
-static void gis_tile_init(GisTile *self) { }
+static void gis_tile_init(GisTile *tile) { }
 static void gis_tile_class_init(GisTileClass *klass) { }
index 938d77a..83b2e7b 100644 (file)
@@ -34,12 +34,12 @@ struct _TileData {
        guint16   *bil;
 };
 
-static gdouble _height_func(gdouble lat, gdouble lon, gpointer _self)
+static gdouble _height_func(gdouble lat, gdouble lon, gpointer _elev)
 {
-       GisPluginElev *self = _self;
-       if (!self) return 0;
+       GisPluginElev *elev = _elev;
+       if (!elev) return 0;
 
-       GisTile *tile = gis_tile_find(self->tiles, lat, lon);
+       GisTile *tile = gis_tile_find(elev->tiles, lat, lon);
        if (!tile) return 0;
 
        struct _TileData *data = tile->data;
@@ -79,12 +79,10 @@ static gdouble _height_func(gdouble lat, gdouble lon, gpointer _self)
        gint16 px01 = bil[MIN((y_flr+1),h-1)*w + MIN((x_flr  ),w-1)];
        gint16 px11 = bil[MIN((y_flr+1),h-1)*w + MIN((x_flr+1),w-1)];
 
-       gdouble elev =
-               px00 * (1-x_rem) * (1-y_rem) +
-               px10 * (  x_rem) * (1-y_rem) +
-               px01 * (1-x_rem) * (  y_rem) +
-               px11 * (  x_rem) * (  y_rem);
-       return elev;
+       return px00 * (1-x_rem) * (1-y_rem) +
+              px10 * (  x_rem) * (1-y_rem) +
+              px01 * (1-x_rem) * (  y_rem) +
+              px11 * (  x_rem) * (  y_rem);
 }
 
 /**********************
@@ -93,7 +91,7 @@ static gdouble _height_func(gdouble lat, gdouble lon, gpointer _self)
 #define LOAD_BIL    TRUE
 #define LOAD_OPENGL FALSE
 struct _LoadTileData {
-       GisPluginElev    *self;
+       GisPluginElev    *elev;
        gchar            *path;
        GisTile          *tile;
        GdkPixbuf        *pixbuf;
@@ -165,7 +163,7 @@ static gboolean _load_tile_cb(gpointer _load)
 {
        struct _LoadTileData *load = _load;
        g_debug("GisPluginElev: _load_tile_cb: %s", load->path);
-       GisPluginElev    *self   = load->self;
+       GisPluginElev    *elev   = load->elev;
        GisTile          *tile   = load->tile;
        GdkPixbuf        *pixbuf = load->pixbuf;
        struct _TileData *data   = load->data;
@@ -178,9 +176,9 @@ static gboolean _load_tile_cb(gpointer _load)
        tile->data = data;
 
        /* Do necessasairy processing */
-       /* TODO: Lock this and move to thread, can remove self from _load then */
+       /* TODO: Lock this and move to thread, can remove elev from _load then */
        if (LOAD_BIL)
-               gis_viewer_set_height_func(self->viewer, tile, _height_func, self, TRUE);
+               gis_viewer_set_height_func(elev->viewer, tile, _height_func, elev, TRUE);
 
        /* Cleanup unneeded things */
        if (!LOAD_BIL)
@@ -190,14 +188,14 @@ static gboolean _load_tile_cb(gpointer _load)
 
        return FALSE;
 }
-static void _load_tile(GisTile *tile, gpointer _self)
+static void _load_tile(GisTile *tile, gpointer _elev)
 {
-       GisPluginElev *self = _self;
+       GisPluginElev *elev = _elev;
 
        struct _LoadTileData *load = g_new0(struct _LoadTileData, 1);
-       load->path = gis_wms_fetch(self->wms, tile, GIS_ONCE, NULL, NULL);
+       load->path = gis_wms_fetch(elev->wms, tile, GIS_ONCE, NULL, NULL);
        g_debug("GisPluginElev: _load_tile: %s", load->path);
-       load->self = self;
+       load->elev = elev;
        load->tile = tile;
        load->data = g_new0(struct _TileData, 1);
        if (LOAD_BIL || LOAD_OPENGL) {
@@ -227,27 +225,27 @@ static gboolean _free_tile_cb(gpointer _data)
        g_free(data);
        return FALSE;
 }
-static void _free_tile(GisTile *tile, gpointer _self)
+static void _free_tile(GisTile *tile, gpointer _elev)
 {
-       GisPluginElev *self = _self;
+       GisPluginElev *elev = _elev;
        g_debug("GisPluginElev: _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 _self)
+static gpointer _update_tiles(gpointer _elev)
 {
-       GisPluginElev *self = _self;
-       g_mutex_lock(self->mutex);
-       gdouble lat, lon, elev;
-       gis_viewer_get_location(self->viewer, &lat, &lon, &elev);
-       gis_tile_update(self->tiles,
+       GisPluginElev *elev = _elev;
+       g_mutex_lock(elev->mutex);
+       gdouble lat, lon, elevation;
+       gis_viewer_get_location(elev->viewer, &lat, &lon, &elevation);
+       gis_tile_update(elev->tiles,
                        MAX_RESOLUTION, TILE_WIDTH, TILE_WIDTH,
-                       lat, lon, elev,
-                       _load_tile, self);
-       gis_tile_gc(self->tiles, time(NULL)-10,
-                       _free_tile, self);
-       g_mutex_unlock(self->mutex);
+                       lat, lon, elevation,
+                       _load_tile, elev);
+       gis_tile_gc(elev->tiles, time(NULL)-10,
+                       _free_tile, elev);
+       g_mutex_unlock(elev->mutex);
        return NULL;
 }
 
@@ -255,9 +253,9 @@ static gpointer _update_tiles(gpointer _self)
  * Callbacks *
  *************/
 static void _on_location_changed(GisViewer *viewer,
-               gdouble lat, gdouble lon, gdouble elev, GisPluginElev *self)
+               gdouble lat, gdouble lon, gdouble elevation, GisPluginElev *elev)
 {
-       g_thread_create(_update_tiles, self, FALSE, NULL);
+       g_thread_create(_update_tiles, elev, FALSE, NULL);
 }
 
 /***********
@@ -266,22 +264,22 @@ static void _on_location_changed(GisViewer *viewer,
 GisPluginElev *gis_plugin_elev_new(GisViewer *viewer)
 {
        g_debug("GisPluginElev: new");
-       GisPluginElev *self = g_object_new(GIS_TYPE_PLUGIN_ELEV, NULL);
-       self->viewer = g_object_ref(viewer);
+       GisPluginElev *elev = g_object_new(GIS_TYPE_PLUGIN_ELEV, NULL);
+       elev->viewer = g_object_ref(viewer);
 
        /* Load initial tiles */
-       _load_tile(self->tiles, self);
-       g_thread_create(_update_tiles, self, FALSE, NULL);
+       _load_tile(elev->tiles, elev);
+       g_thread_create(_update_tiles, elev, FALSE, NULL);
 
        /* Connect signals */
-       self->sigid = g_signal_connect(self->viewer, "location-changed",
-                       G_CALLBACK(_on_location_changed), self);
+       elev->sigid = g_signal_connect(elev->viewer, "location-changed",
+                       G_CALLBACK(_on_location_changed), elev);
 
        /* Add renderers */
        if (LOAD_OPENGL)
-               gis_viewer_add(viewer, GIS_OBJECT(self->tiles), GIS_LEVEL_WORLD, 0);
+               gis_viewer_add(viewer, GIS_OBJECT(elev->tiles), GIS_LEVEL_WORLD, 0);
 
-       return self;
+       return elev;
 }
 
 
@@ -299,38 +297,38 @@ static void gis_plugin_elev_plugin_init(GisPluginInterface *iface)
        /* Add methods to the interface */
 }
 /* Class/Object init */
-static void gis_plugin_elev_init(GisPluginElev *self)
+static void gis_plugin_elev_init(GisPluginElev *elev)
 {
        g_debug("GisPluginElev: init");
        /* Set defaults */
-       self->mutex = g_mutex_new();
-       self->tiles = gis_tile_new(NULL, NORTH, SOUTH, EAST, WEST);
-       self->wms   = gis_wms_new(
+       elev->mutex = g_mutex_new();
+       elev->tiles = gis_tile_new(NULL, NORTH, SOUTH, EAST, WEST);
+       elev->wms   = gis_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)
 {
        g_debug("GisPluginElev: dispose");
-       GisPluginElev *self = GIS_PLUGIN_ELEV(gobject);
+       GisPluginElev *elev = GIS_PLUGIN_ELEV(gobject);
        /* Drop references */
        if (LOAD_BIL)
-               gis_viewer_clear_height_func(self->viewer);
-       if (self->viewer) {
-               g_signal_handler_disconnect(self->viewer, self->sigid);
-               g_object_unref(self->viewer);
-               self->viewer = NULL;
+               gis_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);
 }
 static void gis_plugin_elev_finalize(GObject *gobject)
 {
        g_debug("GisPluginElev: finalize");
-       GisPluginElev *self = GIS_PLUGIN_ELEV(gobject);
+       GisPluginElev *elev = GIS_PLUGIN_ELEV(gobject);
        /* Free data */
-       gis_tile_free(self->tiles, _free_tile, self);
-       gis_wms_free(self->wms);
-       g_mutex_free(self->mutex);
+       gis_tile_free(elev->tiles, _free_tile, elev);
+       gis_wms_free(elev->wms);
+       g_mutex_free(elev->mutex);
        G_OBJECT_CLASS(gis_plugin_elev_parent_class)->finalize(gobject);
 
 }
index a15c023..e5787c6 100644 (file)
 /***********
  * Helpers *
  ***********/
-static gpointer expose(GisCallback *callback, gpointer _self)
+static gpointer expose(GisCallback *callback, gpointer _env)
 {
-       GisPluginEnv *self = GIS_PLUGIN_ENV(_self);
+       GisPluginEnv *env = GIS_PLUGIN_ENV(_env);
        g_debug("GisPluginEnv: expose");
 
        gdouble lat, lon, elev;
-       gis_viewer_get_location(self->viewer, &lat, &lon, &elev);
+       gis_viewer_get_location(env->viewer, &lat, &lon, &elev);
 
        /* Misc */
        gdouble rg   = MAX(0, 1-(elev/20000));
@@ -54,7 +54,7 @@ static gpointer expose(GisCallback *callback, gpointer _self)
        for (elev = -EARTH_R; elev < 0; elev += EARTH_R/10) {
                glPushMatrix();
                glColor4f(0.3, 0.3, 1.0, 0.2);
-               gis_viewer_center_position(self->viewer, lat, lon, elev);
+               gis_viewer_center_position(env->viewer, lat, lon, elev);
 
                glBegin(GL_TRIANGLE_FAN);
                glVertex3f(0, 0, 0);
@@ -78,23 +78,23 @@ static gpointer expose(GisCallback *callback, gpointer _self)
 GisPluginEnv *gis_plugin_env_new(GisViewer *viewer, GisPrefs *prefs)
 {
        g_debug("GisPluginEnv: new");
-       GisPluginEnv *self = g_object_new(GIS_TYPE_PLUGIN_ENV, NULL);
-       self->viewer = g_object_ref(viewer);
+       GisPluginEnv *env = g_object_new(GIS_TYPE_PLUGIN_ENV, NULL);
+       env->viewer = g_object_ref(viewer);
 
        /* Create objects */
-       GisCallback *callback   = gis_callback_new(expose, self);
+       GisCallback *callback   = gis_callback_new(expose, env);
        GisTile     *background = gis_tile_new(NULL, NORTH, SOUTH, EAST, WEST);
-       glGenTextures(1, &self->tex);
-       background->data = &self->tex;
+       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);
-       self->refs = g_list_prepend(self->refs, ref1);
-       self->refs = g_list_prepend(self->refs, ref2);
+       env->refs = g_list_prepend(env->refs, ref1);
+       env->refs = g_list_prepend(env->refs, ref2);
 
-       return self;
+       return env;
 }
 
 
@@ -112,7 +112,7 @@ static void gis_plugin_env_plugin_init(GisPluginInterface *iface)
        /* Add methods to the interface */
 }
 /* Class/Object init */
-static void gis_plugin_env_init(GisPluginEnv *self)
+static void gis_plugin_env_init(GisPluginEnv *env)
 {
        g_debug("GisPluginEnv: init");
        /* Set defaults */
@@ -120,15 +120,15 @@ static void gis_plugin_env_init(GisPluginEnv *self)
 static void gis_plugin_env_dispose(GObject *gobject)
 {
        g_debug("GisPluginEnv: dispose");
-       GisPluginEnv *self = GIS_PLUGIN_ENV(gobject);
+       GisPluginEnv *env = GIS_PLUGIN_ENV(gobject);
        /* Drop references */
-       if (self->viewer) {
-               for (GList *cur = self->refs; cur; cur = cur->next)
-                       gis_viewer_remove(self->viewer, cur->data);
-               g_list_free(self->refs);
-               g_object_unref(self->viewer);
-               glDeleteTextures(1, &self->tex);
-               self->viewer = NULL;
+       if (env->viewer) {
+               for (GList *cur = env->refs; cur; cur = cur->next)
+                       gis_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);
 }
index cdc6f24..7edc1ce 100644 (file)
@@ -36,7 +36,7 @@ const guchar colormap[][2][4] = {
 };
 
 struct _LoadTileData {
-       GisPluginMap *self;
+       GisPluginMap *map;
        GisTile      *tile;
        GdkPixbuf    *pixbuf;
 };
@@ -44,7 +44,7 @@ struct _LoadTileData {
 static gboolean _load_tile_cb(gpointer _data)
 {
        struct _LoadTileData *data = _data;
-       GisPluginMap *self   = data->self;
+       GisPluginMap *map    = data->map;
        GisTile      *tile   = data->tile;
        GdkPixbuf    *pixbuf = data->pixbuf;
        g_free(data);
@@ -85,18 +85,18 @@ static gboolean _load_tile_cb(gpointer _data)
        glFlush();
 
        tile->data = tex;
-       gtk_widget_queue_draw(GTK_WIDGET(self->viewer));
+       gtk_widget_queue_draw(GTK_WIDGET(map->viewer));
        g_object_unref(pixbuf);
        return FALSE;
 }
 
-static void _load_tile(GisTile *tile, gpointer _self)
+static void _load_tile(GisTile *tile, gpointer _map)
 {
-       GisPluginMap *self = _self;
+       GisPluginMap *map = _map;
        g_debug("GisPluginMap: _load_tile start %p", g_thread_self());
-       char *path = gis_wms_fetch(self->wms, tile, GIS_ONCE, NULL, NULL);
+       char *path = gis_wms_fetch(map->wms, tile, GIS_ONCE, NULL, NULL);
        struct _LoadTileData *data = g_new0(struct _LoadTileData, 1);
-       data->self   = self;
+       data->map    = map;
        data->tile   = tile;
        data->pixbuf = gdk_pixbuf_new_from_file(path, NULL);
        if (data->pixbuf) {
@@ -115,27 +115,27 @@ static gboolean _free_tile_cb(gpointer data)
        g_free(data);
        return FALSE;
 }
-static void _free_tile(GisTile *tile, gpointer _self)
+static void _free_tile(GisTile *tile, gpointer _map)
 {
-       GisPluginMap *self = _self;
+       GisPluginMap *map = _map;
        g_debug("GisPluginMap: _free_tile: %p", tile->data);
        g_idle_add_full(G_PRIORITY_LOW, _free_tile_cb, tile->data, NULL);
 }
 
-static gpointer _update_tiles(gpointer _self)
+static gpointer _update_tiles(gpointer _map)
 {
        g_debug("GisPluginMap: _update_tiles");
-       GisPluginMap *self = _self;
-       g_mutex_lock(self->mutex);
+       GisPluginMap *map = _map;
+       g_mutex_lock(map->mutex);
        gdouble lat, lon, elev;
-       gis_viewer_get_location(self->viewer, &lat, &lon, &elev);
-       gis_tile_update(self->tiles,
+       gis_viewer_get_location(map->viewer, &lat, &lon, &elev);
+       gis_tile_update(map->tiles,
                        MAX_RESOLUTION, TILE_WIDTH, TILE_WIDTH,
                        lat, lon, elev,
-                       _load_tile, self);
-       gis_tile_gc(self->tiles, time(NULL)-10,
-                       _free_tile, self);
-       g_mutex_unlock(self->mutex);
+                       _load_tile, map);
+       gis_tile_gc(map->tiles, time(NULL)-10,
+                       _free_tile, map);
+       g_mutex_unlock(map->mutex);
        return NULL;
 }
 
@@ -143,9 +143,9 @@ static gpointer _update_tiles(gpointer _self)
  * Callbacks *
  *************/
 static void _on_location_changed(GisViewer *viewer,
-               gdouble lat, gdouble lon, gdouble elev, GisPluginMap *self)
+               gdouble lat, gdouble lon, gdouble elev, GisPluginMap *map)
 {
-       g_thread_create(_update_tiles, self, FALSE, NULL);
+       g_thread_create(_update_tiles, map, FALSE, NULL);
 }
 
 /***********
@@ -154,21 +154,21 @@ static void _on_location_changed(GisViewer *viewer,
 GisPluginMap *gis_plugin_map_new(GisViewer *viewer)
 {
        g_debug("GisPluginMap: new");
-       GisPluginMap *self = g_object_new(GIS_TYPE_PLUGIN_MAP, NULL);
-       self->viewer = g_object_ref(viewer);
+       GisPluginMap *map = g_object_new(GIS_TYPE_PLUGIN_MAP, NULL);
+       map->viewer = g_object_ref(viewer);
 
        /* Load initial tiles */
-       _load_tile(self->tiles, self);
-       g_thread_create(_update_tiles, self, FALSE, NULL);
+       _load_tile(map->tiles, map);
+       g_thread_create(_update_tiles, map, FALSE, NULL);
 
        /* Connect signals */
-       self->sigid = g_signal_connect(self->viewer, "location-changed",
-                       G_CALLBACK(_on_location_changed), self);
+       map->sigid = g_signal_connect(map->viewer, "location-changed",
+                       G_CALLBACK(_on_location_changed), map);
 
        /* Add renderers */
-       gis_viewer_add(viewer, GIS_OBJECT(self->tiles), GIS_LEVEL_OVERLAY, 0);
+       gis_viewer_add(viewer, GIS_OBJECT(map->tiles), GIS_LEVEL_OVERLAY, 0);
 
-       return self;
+       return map;
 }
 
 
@@ -186,36 +186,36 @@ static void gis_plugin_map_plugin_init(GisPluginInterface *iface)
        /* Add methods to the interface */
 }
 /* Class/Object init */
-static void gis_plugin_map_init(GisPluginMap *self)
+static void gis_plugin_map_init(GisPluginMap *map)
 {
        g_debug("GisPluginMap: init");
        /* Set defaults */
-       self->mutex  = g_mutex_new();
-       self->tiles  = gis_tile_new(NULL, NORTH, SOUTH, EAST, WEST);
-       self->wms    = gis_wms_new(
+       map->mutex  = g_mutex_new();
+       map->tiles  = gis_tile_new(NULL, NORTH, SOUTH, EAST, WEST);
+       map->wms    = gis_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)
 {
        g_debug("GisPluginMap: dispose");
-       GisPluginMap *self = GIS_PLUGIN_MAP(gobject);
+       GisPluginMap *map = GIS_PLUGIN_MAP(gobject);
        /* Drop references */
-       if (self->viewer) {
-               g_signal_handler_disconnect(self->viewer, self->sigid);
-               g_object_unref(self->viewer);
-               self->viewer = NULL;
+       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);
 }
 static void gis_plugin_map_finalize(GObject *gobject)
 {
        g_debug("GisPluginMap: finalize");
-       GisPluginMap *self = GIS_PLUGIN_MAP(gobject);
+       GisPluginMap *map = GIS_PLUGIN_MAP(gobject);
        /* Free data */
-       gis_tile_free(self->tiles, _free_tile, self);
-       gis_wms_free(self->wms);
-       g_mutex_free(self->mutex);
+       gis_tile_free(map->tiles, _free_tile, map);
+       gis_wms_free(map->wms);
+       g_mutex_free(map->mutex);
        G_OBJECT_CLASS(gis_plugin_map_parent_class)->finalize(gobject);
 
 }
index 3ddccc8..4856ae6 100644 (file)
 #define TILE_HEIGHT    512
 
 struct _LoadTileData {
-       GisPluginSat *self;
+       GisPluginSat *sat;
        GisTile      *tile;
        GdkPixbuf    *pixbuf;
 };
 static gboolean _load_tile_cb(gpointer _data)
 {
        struct _LoadTileData *data = _data;
-       GisPluginSat *self   = data->self;
+       GisPluginSat *sat    = data->sat;
        GisTile      *tile   = data->tile;
        GdkPixbuf    *pixbuf = data->pixbuf;
        g_free(data);
@@ -62,18 +62,18 @@ static gboolean _load_tile_cb(gpointer _data)
        glFlush();
 
        tile->data = tex;
-       gtk_widget_queue_draw(GTK_WIDGET(self->viewer));
+       gtk_widget_queue_draw(GTK_WIDGET(sat->viewer));
        g_object_unref(pixbuf);
        return FALSE;
 }
 
-static void _load_tile(GisTile *tile, gpointer _self)
+static void _load_tile(GisTile *tile, gpointer _sat)
 {
-       GisPluginSat *self = _self;
+       GisPluginSat *sat = _sat;
        g_debug("GisPluginSat: _load_tile start %p", g_thread_self());
-       char *path = gis_wms_fetch(self->wms, tile, GIS_ONCE, NULL, NULL);
+       char *path = gis_wms_fetch(sat->wms, tile, GIS_ONCE, NULL, NULL);
        struct _LoadTileData *data = g_new0(struct _LoadTileData, 1);
-       data->self   = self;
+       data->sat   = sat;
        data->tile   = tile;
        data->pixbuf = gdk_pixbuf_new_from_file(path, NULL);
        if (data->pixbuf) {
@@ -93,27 +93,27 @@ static gboolean _free_tile_cb(gpointer data)
        g_free(data);
        return FALSE;
 }
-static void _free_tile(GisTile *tile, gpointer _self)
+static void _free_tile(GisTile *tile, gpointer _sat)
 {
-       GisPluginSat *self = _self;
+       GisPluginSat *sat = _sat;
        g_debug("GisPluginSat: _free_tile: %p=%d", tile->data, *(guint*)tile->data);
        g_idle_add_full(G_PRIORITY_LOW, _free_tile_cb, tile->data, NULL);
 }
 
-static gpointer _update_tiles(gpointer _self)
+static gpointer _update_tiles(gpointer _sat)
 {
        g_debug("GisPluginSat: _update_tiles");
-       GisPluginSat *self = _self;
-       g_mutex_lock(self->mutex);
+       GisPluginSat *sat = _sat;
+       g_mutex_lock(sat->mutex);
        gdouble lat, lon, elev;
-       gis_viewer_get_location(self->viewer, &lat, &lon, &elev);
-       gis_tile_update(self->tiles,
+       gis_viewer_get_location(sat->viewer, &lat, &lon, &elev);
+       gis_tile_update(sat->tiles,
                        MAX_RESOLUTION, TILE_WIDTH, TILE_WIDTH,
                        lat, lon, elev,
-                       _load_tile, self);
-       gis_tile_gc(self->tiles, time(NULL)-10,
-                       _free_tile, self);
-       g_mutex_unlock(self->mutex);
+                       _load_tile, sat);
+       gis_tile_gc(sat->tiles, time(NULL)-10,
+                       _free_tile, sat);
+       g_mutex_unlock(sat->mutex);
        return NULL;
 }
 
@@ -121,9 +121,9 @@ static gpointer _update_tiles(gpointer _self)
  * Callbacks *
  *************/
 static void _on_location_changed(GisViewer *viewer,
-               gdouble lat, gdouble lon, gdouble elev, GisPluginSat *self)
+               gdouble lat, gdouble lon, gdouble elev, GisPluginSat *sat)
 {
-       g_thread_create(_update_tiles, self, FALSE, NULL);
+       g_thread_create(_update_tiles, sat, FALSE, NULL);
 }
 
 /***********
@@ -132,21 +132,21 @@ static void _on_location_changed(GisViewer *viewer,
 GisPluginSat *gis_plugin_sat_new(GisViewer *viewer)
 {
        g_debug("GisPluginSat: new");
-       GisPluginSat *self = g_object_new(GIS_TYPE_PLUGIN_SAT, NULL);
-       self->viewer = g_object_ref(viewer);
+       GisPluginSat *sat = g_object_new(GIS_TYPE_PLUGIN_SAT, NULL);
+       sat->viewer = g_object_ref(viewer);
 
        /* Load initial tiles */
-       _load_tile(self->tiles, self);
-       g_thread_create(_update_tiles, self, FALSE, NULL);
+       _load_tile(sat->tiles, sat);
+       g_thread_create(_update_tiles, sat, FALSE, NULL);
 
        /* Connect signals */
-       self->sigid = g_signal_connect(self->viewer, "location-changed",
-                       G_CALLBACK(_on_location_changed), self);
+       sat->sigid = g_signal_connect(sat->viewer, "location-changed",
+                       G_CALLBACK(_on_location_changed), sat);
 
        /* Add renderers */
-       gis_viewer_add(viewer, GIS_OBJECT(self->tiles), GIS_LEVEL_WORLD, 0);
+       gis_viewer_add(viewer, GIS_OBJECT(sat->tiles), GIS_LEVEL_WORLD, 0);
 
-       return self;
+       return sat;
 }
 
 
@@ -164,36 +164,36 @@ static void gis_plugin_sat_plugin_init(GisPluginInterface *iface)
        /* Add methods to the interface */
 }
 /* Class/Object init */
-static void gis_plugin_sat_init(GisPluginSat *self)
+static void gis_plugin_sat_init(GisPluginSat *sat)
 {
        g_debug("GisPluginSat: init");
        /* Set defaults */
-       self->mutex = g_mutex_new();
-       self->tiles = gis_tile_new(NULL, NORTH, SOUTH, EAST, WEST);
-       self->wms   = gis_wms_new(
+       sat->mutex = g_mutex_new();
+       sat->tiles = gis_tile_new(NULL, NORTH, SOUTH, EAST, WEST);
+       sat->wms   = gis_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)
 {
        g_debug("GisPluginSat: dispose");
-       GisPluginSat *self = GIS_PLUGIN_SAT(gobject);
+       GisPluginSat *sat = GIS_PLUGIN_SAT(gobject);
        /* Drop references */
-       if (self->viewer) {
-               g_signal_handler_disconnect(self->viewer, self->sigid);
-               g_object_unref(self->viewer);
-               self->viewer = NULL;
+       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);
 }
 static void gis_plugin_sat_finalize(GObject *gobject)
 {
        g_debug("GisPluginSat: finalize");
-       GisPluginSat *self = GIS_PLUGIN_SAT(gobject);
+       GisPluginSat *sat = GIS_PLUGIN_SAT(gobject);
        /* Free data */
-       gis_tile_free(self->tiles, _free_tile, self);
-       gis_wms_free(self->wms);
-       g_mutex_free(self->mutex);
+       gis_tile_free(sat->tiles, _free_tile, sat);
+       gis_wms_free(sat->wms);
+       g_mutex_free(sat->mutex);
        G_OBJECT_CLASS(gis_plugin_sat_parent_class)->finalize(gobject);
 
 }
index 2cbc140..986a4f0 100644 (file)
 GisPluginTest *gis_plugin_test_new(GisViewer *viewer)
 {
        g_debug("GisPluginTest: new");
-       GisPluginTest *self = g_object_new(GIS_TYPE_PLUGIN_TEST, NULL);
-       self->viewer = g_object_ref(viewer);
+       GisPluginTest *test = g_object_new(GIS_TYPE_PLUGIN_TEST, NULL);
+       test->viewer = g_object_ref(viewer);
 
        GisMarker *marker = gis_marker_new("St. Charles");
        gis_point_set_lle(gis_object_center(GIS_OBJECT(marker)), 38.841847, -90.491982, 0);
        GIS_OBJECT(marker)->lod = EARTH_R/4;
-       self->marker = gis_viewer_add(self->viewer, GIS_OBJECT(marker), GIS_LEVEL_OVERLAY, 0);
+       test->marker = gis_viewer_add(test->viewer, GIS_OBJECT(marker), GIS_LEVEL_OVERLAY, 0);
 
-       return self;
+       return test;
 }
 
 
@@ -55,20 +55,20 @@ static void gis_plugin_test_plugin_init(GisPluginInterface *iface)
        /* Add methods to the interface */
 }
 /* Class/Object init */
-static void gis_plugin_test_init(GisPluginTest *self)
+static void gis_plugin_test_init(GisPluginTest *test)
 {
        g_debug("GisPluginTest: init");
 }
-static void gis_plugin_test_dispose(GObject *_self)
+static void gis_plugin_test_dispose(GObject *_test)
 {
        g_debug("GisPluginTest: dispose");
-       GisPluginTest *self = GIS_PLUGIN_TEST(_self);
-       if (self->viewer) {
-               gis_viewer_remove(self->viewer, self->marker);
-               g_object_unref(self->viewer);
-               self->viewer = NULL;
+       GisPluginTest *test = GIS_PLUGIN_TEST(_test);
+       if (test->viewer) {
+               gis_viewer_remove(test->viewer, test->marker);
+               g_object_unref(test->viewer);
+               test->viewer = NULL;
        }
-       G_OBJECT_CLASS(gis_plugin_test_parent_class)->finalize(_self);
+       G_OBJECT_CLASS(gis_plugin_test_parent_class)->finalize(_test);
 }
 static void gis_plugin_test_class_init(GisPluginTestClass *klass)
 {
index a3bc847..a5fd272 100644 (file)
@@ -52,51 +52,51 @@ static gint dia_cmp(RoamDiamond *a, RoamDiamond *b, gpointer data)
  *************/
 RoamPoint *roam_point_new(gdouble lat, gdouble lon, gdouble elev)
 {
-       RoamPoint *self = g_new0(RoamPoint, 1);
-       self->lat  = lat;
-       self->lon  = lon;
-       self->elev = elev;
+       RoamPoint *point = g_new0(RoamPoint, 1);
+       point->lat  = lat;
+       point->lon  = lon;
+       point->elev = elev;
        /* For get_intersect */
-       lle2xyz(lat, lon, elev, &self->x, &self->y, &self->z);
-       return self;
+       lle2xyz(lat, lon, elev, &point->x, &point->y, &point->z);
+       return point;
 }
-RoamPoint *roam_point_dup(RoamPoint *self)
+RoamPoint *roam_point_dup(RoamPoint *point)
 {
-       RoamPoint *new = g_memdup(self, sizeof(RoamPoint));
+       RoamPoint *new = g_memdup(point, sizeof(RoamPoint));
        new->tris = 0;
        return new;
 }
-void roam_point_add_triangle(RoamPoint *self, RoamTriangle *triangle)
+void roam_point_add_triangle(RoamPoint *point, RoamTriangle *triangle)
 {
        for (int i = 0; i < 3; i++) {
-               self->norm[i] *= self->tris;
-               self->norm[i] += triangle->norm[i];
+               point->norm[i] *= point->tris;
+               point->norm[i] += triangle->norm[i];
        }
-       self->tris++;
+       point->tris++;
        for (int i = 0; i < 3; i++)
-               self->norm[i] /= self->tris;
+               point->norm[i] /= point->tris;
 }
-void roam_point_remove_triangle(RoamPoint *self, RoamTriangle *triangle)
+void roam_point_remove_triangle(RoamPoint *point, RoamTriangle *triangle)
 {
        for (int i = 0; i < 3; i++) {
-               self->norm[i] *= self->tris;
-               self->norm[i] -= triangle->norm[i];
+               point->norm[i] *= point->tris;
+               point->norm[i] -= triangle->norm[i];
        }
-       self->tris--;
-       if (self->tris)
+       point->tris--;
+       if (point->tris)
                for (int i = 0; i < 3; i++)
-                       self->norm[i] /= self->tris;
+                       point->norm[i] /= point->tris;
 }
-void roam_point_update_height(RoamPoint *self)
+void roam_point_update_height(RoamPoint *point)
 {
-       if (self->height_func) {
-               gdouble elev = self->height_func(
-                               self->lat, self->lon, self->height_data);
-               lle2xyz(self->lat, self->lon, elev,
-                               &self->x, &self->y, &self->z);
+       if (point->height_func) {
+               gdouble elev = point->height_func(
+                               point->lat, point->lon, point->height_data);
+               lle2xyz(point->lat, point->lon, elev,
+                               &point->x, &point->y, &point->z);
        }
 }
-void roam_point_update_projection(RoamPoint *self, RoamSphere *sphere)
+void roam_point_update_projection(RoamPoint *point, RoamSphere *sphere)
 {
        static int count   = 0;
        static int version = 0;
@@ -106,12 +106,12 @@ void roam_point_update_projection(RoamPoint *self, RoamSphere *sphere)
                version = sphere->view->version;
        }
 
-       if (self->pversion != sphere->view->version) {
+       if (point->pversion != sphere->view->version) {
                /* Cache projection */
-               gluProject(self->x, self->y, self->z,
+               gluProject(point->x, point->y, point->z,
                        sphere->view->model, sphere->view->proj, sphere->view->view,
-                       &self->px, &self->py, &self->pz);
-               self->pversion = sphere->view->version;
+                       &point->px, &point->py, &point->pz);
+               point->pversion = sphere->view->version;
                count++;
        }
 }
@@ -121,113 +121,113 @@ void roam_point_update_projection(RoamPoint *self, RoamSphere *sphere)
  ****************/
 RoamTriangle *roam_triangle_new(RoamPoint *l, RoamPoint *m, RoamPoint *r)
 {
-       RoamTriangle *self = g_new0(RoamTriangle, 1);
+       RoamTriangle *triangle = g_new0(RoamTriangle, 1);
 
-       self->error = 0;
-       self->p.l = l;
-       self->p.m = m;
-       self->p.r = r;
-       self->split = roam_point_new(
+       triangle->error = 0;
+       triangle->p.l = l;
+       triangle->p.m = m;
+       triangle->p.r = r;
+       triangle->split = roam_point_new(
                (l->lat + r->lat)/2,
                (ABS(l->lat) == 90 ? r->lon :
                 ABS(r->lat) == 90 ? l->lon :
                 lon_avg(l->lon, r->lon)),
                (l->elev + r->elev)/2);
        /* TODO: Move this back to sphere, or actually use the nesting */
-       self->split->height_func = m->height_func;
-       self->split->height_data = m->height_data;
-       roam_point_update_height(self->split);
-       //if ((float)self->split->lat > 44 && (float)self->split->lat < 46)
+       triangle->split->height_func = m->height_func;
+       triangle->split->height_data = m->height_data;
+       roam_point_update_height(triangle->split);
+       //if ((float)triangle->split->lat > 44 && (float)triangle->split->lat < 46)
        //      g_debug("RoamTriangle: new - (l,m,r,split).lats = %7.2f %7.2f %7.2f %7.2f",
-       //                      l->lat, m->lat, r->lat, self->split->lat);
+       //                      l->lat, m->lat, r->lat, triangle->split->lat);
        //if ((float)l->lat == (float)r->lat &&
-       //    (float)self->split->lat != (float)l->lat)
+       //    (float)triangle->split->lat != (float)l->lat)
        //      g_warning("RoamTriangle: new - split.lat=%f != (l=r).lat=%f",
-       //              self->split->lat, l->lat);
+       //              triangle->split->lat, l->lat);
 
        /* Update normal */
        double pa[3];
        double pb[3];
-       pa[0] = self->p.l->x - self->p.m->x;
-       pa[1] = self->p.l->y - self->p.m->y;
-       pa[2] = self->p.l->z - self->p.m->z;
+       pa[0] = triangle->p.l->x - triangle->p.m->x;
+       pa[1] = triangle->p.l->y - triangle->p.m->y;
+       pa[2] = triangle->p.l->z - triangle->p.m->z;
 
-       pb[0] = self->p.r->x - self->p.m->x;
-       pb[1] = self->p.r->y - self->p.m->y;
-       pb[2] = self->p.r->z - self->p.m->z;
+       pb[0] = triangle->p.r->x - triangle->p.m->x;
+       pb[1] = triangle->p.r->y - triangle->p.m->y;
+       pb[2] = triangle->p.r->z - triangle->p.m->z;
 
-       self->norm[0] = pa[1] * pb[2] - pa[2] * pb[1];
-       self->norm[1] = pa[2] * pb[0] - pa[0] * pb[2];
-       self->norm[2] = pa[0] * pb[1] - pa[1] * pb[0];
+       triangle->norm[0] = pa[1] * pb[2] - pa[2] * pb[1];
+       triangle->norm[1] = pa[2] * pb[0] - pa[0] * pb[2];
+       triangle->norm[2] = pa[0] * pb[1] - pa[1] * pb[0];
 
-       double total = sqrt(self->norm[0] * self->norm[0] +
-                           self->norm[1] * self->norm[1] +
-                           self->norm[2] * self->norm[2]);
+       double total = sqrt(triangle->norm[0] * triangle->norm[0] +
+                           triangle->norm[1] * triangle->norm[1] +
+                           triangle->norm[2] * triangle->norm[2]);
 
-       self->norm[0] /= total;
-       self->norm[1] /= total;
-       self->norm[2] /= total;
+       triangle->norm[0] /= total;
+       triangle->norm[1] /= total;
+       triangle->norm[2] /= total;
 
        /* Store bounding box, for get_intersect */
        RoamPoint *p[] = {l,m,r};
-       self->edge.n =  -90; self->edge.s =  90;
-       self->edge.e = -180; self->edge.w = 180;
+       triangle->edge.n =  -90; triangle->edge.s =  90;
+       triangle->edge.e = -180; triangle->edge.w = 180;
        gboolean maxed = FALSE;
        for (int i = 0; i < G_N_ELEMENTS(p); i++) {
-               self->edge.n = MAX(self->edge.n, p[i]->lat);
-               self->edge.s = MIN(self->edge.s, p[i]->lat);
+               triangle->edge.n = MAX(triangle->edge.n, p[i]->lat);
+               triangle->edge.s = MIN(triangle->edge.s, p[i]->lat);
                if (p[i]->lat == 90 || p[i]->lat == -90)
                        continue;
                if (p[i]->lon == 180) {
                        maxed = TRUE;
                        continue;
                }
-               self->edge.e = MAX(self->edge.e, p[i]->lon);
-               self->edge.w = MIN(self->edge.w, p[i]->lon);
+               triangle->edge.e = MAX(triangle->edge.e, p[i]->lon);
+               triangle->edge.w = MIN(triangle->edge.w, p[i]->lon);
        }
        if (maxed) {
-               if (self->edge.e < 0)
-                       self->edge.w = -180;
+               if (triangle->edge.e < 0)
+                       triangle->edge.w = -180;
                else
-                       self->edge.e =  180;
+                       triangle->edge.e =  180;
        }
 
-       //g_message("roam_triangle_new: %p", self);
-       return self;
+       //g_message("roam_triangle_new: %p", triangle);
+       return triangle;
 }
 
-void roam_triangle_free(RoamTriangle *self)
+void roam_triangle_free(RoamTriangle *triangle)
 {
-       g_free(self->split);
-       g_free(self);
+       g_free(triangle->split);
+       g_free(triangle);
 }
 
-void roam_triangle_add(RoamTriangle *self,
+void roam_triangle_add(RoamTriangle *triangle,
                RoamTriangle *left, RoamTriangle *base, RoamTriangle *right,
                RoamSphere *sphere)
 {
-       self->t.l = left;
-       self->t.b = base;
-       self->t.r = right;
+       triangle->t.l = left;
+       triangle->t.b = base;
+       triangle->t.r = right;
 
-       roam_point_add_triangle(self->p.l, self);
-       roam_point_add_triangle(self->p.m, self);
-       roam_point_add_triangle(self->p.r, self);
+       roam_point_add_triangle(triangle->p.l, triangle);
+       roam_point_add_triangle(triangle->p.m, triangle);
+       roam_point_add_triangle(triangle->p.r, triangle);
 
        if (sphere->view)
-               roam_triangle_update_errors(self, sphere);
+               roam_triangle_update_errors(triangle, sphere);
 
-       self->handle = g_pqueue_push(sphere->triangles, self);
+       triangle->handle = g_pqueue_push(sphere->triangles, triangle);
 }
 
-void roam_triangle_remove(RoamTriangle *self, RoamSphere *sphere)
+void roam_triangle_remove(RoamTriangle *triangle, RoamSphere *sphere)
 {
        /* Update vertex normals */
-       roam_point_remove_triangle(self->p.l, self);
-       roam_point_remove_triangle(self->p.m, self);
-       roam_point_remove_triangle(self->p.r, self);
+       roam_point_remove_triangle(triangle->p.l, triangle);
+       roam_point_remove_triangle(triangle->p.m, triangle);
+       roam_point_remove_triangle(triangle->p.r, triangle);
 
-       g_pqueue_remove(sphere->triangles, self->handle);
+       g_pqueue_remove(sphere->triangles, triangle->handle);
 }
 
 void roam_triangle_sync_neighbors(RoamTriangle *new, RoamTriangle *old, RoamTriangle *neigh)
@@ -238,43 +238,43 @@ void roam_triangle_sync_neighbors(RoamTriangle *new, RoamTriangle *old, RoamTria
        else g_assert_not_reached();
 }
 
-gboolean roam_point_visible(RoamPoint *self, RoamSphere *sphere)
+gboolean roam_point_visible(RoamPoint *triangle, RoamSphere *sphere)
 {
        gint *view = sphere->view->view;
-       return self->px > view[0] && self->px < view[2] &&
-              self->py > view[1] && self->py < view[3] &&
-              self->pz > 0       && self->pz < 1;
+       return triangle->px > view[0] && triangle->px < view[2] &&
+              triangle->py > view[1] && triangle->py < view[3] &&
+              triangle->pz > 0       && triangle->pz < 1;
 }
-gboolean roam_triangle_visible(RoamTriangle *self, RoamSphere *sphere)
+gboolean roam_triangle_visible(RoamTriangle *triangle, RoamSphere *sphere)
 {
        /* Do this with a bounding box */
-       return roam_point_visible(self->p.l, sphere) ||
-              roam_point_visible(self->p.m, sphere) ||
-              roam_point_visible(self->p.r, sphere);
+       return roam_point_visible(triangle->p.l, sphere) ||
+              roam_point_visible(triangle->p.m, sphere) ||
+              roam_point_visible(triangle->p.r, sphere);
 }
 
-void roam_triangle_update_errors(RoamTriangle *self, RoamSphere *sphere)
+void roam_triangle_update_errors(RoamTriangle *triangle, RoamSphere *sphere)
 {
        /* Update points */
-       roam_point_update_projection(self->p.l, sphere);
-       roam_point_update_projection(self->p.m, sphere);
-       roam_point_update_projection(self->p.r, sphere);
+       roam_point_update_projection(triangle->p.l, sphere);
+       roam_point_update_projection(triangle->p.m, sphere);
+       roam_point_update_projection(triangle->p.r, sphere);
 
        /* Not exactly correct, could be out on both sides (middle in) */
-       if (!roam_triangle_visible(self, sphere)) {
-               self->error = -1;
+       if (!roam_triangle_visible(triangle, sphere)) {
+               triangle->error = -1;
        } else {
-               roam_point_update_projection(self->split, sphere);
-               RoamPoint *l = self->p.l;
-               RoamPoint *m = self->p.m;
-               RoamPoint *r = self->p.r;
-               RoamPoint *split = self->split;
+               roam_point_update_projection(triangle->split, sphere);
+               RoamPoint *l = triangle->p.l;
+               RoamPoint *m = triangle->p.m;
+               RoamPoint *r = triangle->p.r;
+               RoamPoint *split = triangle->split;
 
                /*               l-r midpoint        projected l-r midpoint */
                gdouble pxdist = (l->px + r->px)/2 - split->px;
                gdouble pydist = (l->py + r->py)/2 - split->py;
 
-               self->error = sqrt(pxdist*pxdist + pydist*pydist);
+               triangle->error = sqrt(pxdist*pxdist + pydist*pydist);
 
                /* Multiply by size of triangle */
                double size = -( l->px * (m->py - r->py) +
@@ -283,75 +283,75 @@ void roam_triangle_update_errors(RoamTriangle *self, RoamSphere *sphere)
 
                /* Size < 0 == backface */
                //if (size < 0)
-               //      self->error *= -1;
-               self->error *= size;
+               //      triangle->error *= -1;
+               triangle->error *= size;
        }
 }
 
-void roam_triangle_split(RoamTriangle *self, RoamSphere *sphere)
+void roam_triangle_split(RoamTriangle *triangle, RoamSphere *sphere)
 {
-       //g_message("roam_triangle_split: %p, e=%f\n", self, self->error);
+       //g_message("roam_triangle_split: %p, e=%f\n", triangle, triangle->error);
 
        sphere->polys += 2;
 
-       if (self != self->t.b->t.b)
-               roam_triangle_split(self->t.b, sphere);
-       if (self != self->t.b->t.b)
+       if (triangle != triangle->t.b->t.b)
+               roam_triangle_split(triangle->t.b, sphere);
+       if (triangle != triangle->t.b->t.b)
                g_assert_not_reached();
 
-       RoamTriangle *base = self->t.b;
+       RoamTriangle *base = triangle->t.b;
 
        /* Add new triangles */
-       RoamPoint *mid = self->split;
-       RoamTriangle *sl = self->kids[0] = roam_triangle_new(self->p.m, mid, self->p.l); // Self Left
-       RoamTriangle *sr = self->kids[1] = roam_triangle_new(self->p.r, mid, self->p.m); // Self Right
+       RoamPoint *mid = triangle->split;
+       RoamTriangle *sl = triangle->kids[0] = roam_triangle_new(triangle->p.m, mid, triangle->p.l); // triangle Left
+       RoamTriangle *sr = triangle->kids[1] = roam_triangle_new(triangle->p.r, mid, triangle->p.m); // triangle Right
        RoamTriangle *bl = base->kids[0] = roam_triangle_new(base->p.m, mid, base->p.l); // Base Left
        RoamTriangle *br = base->kids[1] = roam_triangle_new(base->p.r, mid, base->p.m); // Base Right
 
-       /*                tri,l,  base,      r,  sphere */
-       roam_triangle_add(sl, sr, self->t.l, br, sphere);
-       roam_triangle_add(sr, bl, self->t.r, sl, sphere);
+       /*                triangle,l,  base,      r,  sphere */
+       roam_triangle_add(sl, sr, triangle->t.l, br, sphere);
+       roam_triangle_add(sr, bl, triangle->t.r, sl, sphere);
        roam_triangle_add(bl, br, base->t.l, sr, sphere);
        roam_triangle_add(br, sl, base->t.r, bl, sphere);
 
-       roam_triangle_sync_neighbors(sl, self, self->t.l);
-       roam_triangle_sync_neighbors(sr, self, self->t.r);
+       roam_triangle_sync_neighbors(sl, triangle, triangle->t.l);
+       roam_triangle_sync_neighbors(sr, triangle, triangle->t.r);
        roam_triangle_sync_neighbors(bl, base, base->t.l);
        roam_triangle_sync_neighbors(br, base, base->t.r);
 
        /* Remove old triangles */
-       roam_triangle_remove(self, sphere);
+       roam_triangle_remove(triangle, sphere);
        roam_triangle_remove(base, sphere);
 
        /* Add/Remove diamonds */
-       RoamDiamond *diamond = roam_diamond_new(self, base, sl, sr, bl, br);
+       RoamDiamond *diamond = roam_diamond_new(triangle, base, sl, sr, bl, br);
        roam_diamond_update_errors(diamond, sphere);
        roam_diamond_add(diamond, sphere);
-       roam_diamond_remove(self->parent, sphere);
+       roam_diamond_remove(triangle->parent, sphere);
        roam_diamond_remove(base->parent, sphere);
 }
 
-void roam_triangle_draw(RoamTriangle *self)
+void roam_triangle_draw(RoamTriangle *triangle)
 {
        glBegin(GL_TRIANGLES);
-       glNormal3dv(self->p.r->norm); glVertex3dv((double*)self->p.r);
-       glNormal3dv(self->p.m->norm); glVertex3dv((double*)self->p.m);
-       glNormal3dv(self->p.l->norm); glVertex3dv((double*)self->p.l);
+       glNormal3dv(triangle->p.r->norm); glVertex3dv((double*)triangle->p.r);
+       glNormal3dv(triangle->p.m->norm); glVertex3dv((double*)triangle->p.m);
+       glNormal3dv(triangle->p.l->norm); glVertex3dv((double*)triangle->p.l);
        glEnd();
        return;
 }
 
-void roam_triangle_draw_normal(RoamTriangle *self)
+void roam_triangle_draw_normal(RoamTriangle *triangle)
 {
        double center[] = {
-               (self->p.l->x + self->p.m->x + self->p.r->x)/3.0,
-               (self->p.l->y + self->p.m->y + self->p.r->y)/3.0,
-               (self->p.l->z + self->p.m->z + self->p.r->z)/3.0,
+               (triangle->p.l->x + triangle->p.m->x + triangle->p.r->x)/3.0,
+               (triangle->p.l->y + triangle->p.m->y + triangle->p.r->y)/3.0,
+               (triangle->p.l->z + triangle->p.m->z + triangle->p.r->z)/3.0,
        };
        double end[] = {
-               center[0]+self->norm[0]*2000000,
-               center[1]+self->norm[1]*2000000,
-               center[2]+self->norm[2]*2000000,
+               center[0]+triangle->norm[0]*2000000,
+               center[1]+triangle->norm[1]*2000000,
+               center[2]+triangle->norm[2]*2000000,
        };
        glBegin(GL_LINES);
        glVertex3dv(center);
@@ -367,54 +367,54 @@ RoamDiamond *roam_diamond_new(
                RoamTriangle *kid0, RoamTriangle *kid1,
                RoamTriangle *kid2, RoamTriangle *kid3)
 {
-       RoamDiamond *self = g_new0(RoamDiamond, 1);
+       RoamDiamond *diamond = g_new0(RoamDiamond, 1);
 
-       self->kids[0] = kid0;
-       self->kids[1] = kid1;
-       self->kids[2] = kid2;
-       self->kids[3] = kid3;
+       diamond->kids[0] = kid0;
+       diamond->kids[1] = kid1;
+       diamond->kids[2] = kid2;
+       diamond->kids[3] = kid3;
 
-       kid0->parent = self;
-       kid1->parent = self;
-       kid2->parent = self;
-       kid3->parent = self;
+       kid0->parent = diamond;
+       kid1->parent = diamond;
+       kid2->parent = diamond;
+       kid3->parent = diamond;
 
-       self->parents[0] = parent0;
-       self->parents[1] = parent1;
+       diamond->parents[0] = parent0;
+       diamond->parents[1] = parent1;
 
-       return self;
+       return diamond;
 }
-void roam_diamond_add(RoamDiamond *self, RoamSphere *sphere)
+void roam_diamond_add(RoamDiamond *diamond, RoamSphere *sphere)
 {
-       self->active = TRUE;
-       self->error  = MAX(self->parents[0]->error, self->parents[1]->error);
-       self->handle = g_pqueue_push(sphere->diamonds, self);
+       diamond->active = TRUE;
+       diamond->error  = MAX(diamond->parents[0]->error, diamond->parents[1]->error);
+       diamond->handle = g_pqueue_push(sphere->diamonds, diamond);
 }
-void roam_diamond_remove(RoamDiamond *self, RoamSphere *sphere)
+void roam_diamond_remove(RoamDiamond *diamond, RoamSphere *sphere)
 {
-       if (self && self->active) {
-               self->active = FALSE;
-               g_pqueue_remove(sphere->diamonds, self->handle);
+       if (diamond && diamond->active) {
+               diamond->active = FALSE;
+               g_pqueue_remove(sphere->diamonds, diamond->handle);
        }
 }
-void roam_diamond_merge(RoamDiamond *self, RoamSphere *sphere)
+void roam_diamond_merge(RoamDiamond *diamond, RoamSphere *sphere)
 {
-       //g_message("roam_diamond_merge: %p, e=%f\n", self, self->error);
+       //g_message("roam_diamond_merge: %p, e=%f\n", diamond, diamond->error);
 
        sphere->polys -= 2;
 
        /* TODO: pick the best split */
-       RoamTriangle **kids = self->kids;
+       RoamTriangle **kids = diamond->kids;
 
        /* Create triangles */
-       RoamTriangle *tri  = self->parents[0];
-       RoamTriangle *base = self->parents[1];
+       RoamTriangle *triangle  = diamond->parents[0];
+       RoamTriangle *base = diamond->parents[1];
 
-       roam_triangle_add(tri,  kids[0]->t.b, base, kids[1]->t.b, sphere);
-       roam_triangle_add(base, kids[2]->t.b, tri,  kids[3]->t.b, sphere);
+       roam_triangle_add(triangle,  kids[0]->t.b, base, kids[1]->t.b, sphere);
+       roam_triangle_add(base, kids[2]->t.b, triangle,  kids[3]->t.b, sphere);
 
-       roam_triangle_sync_neighbors(tri,  kids[0], kids[0]->t.b);
-       roam_triangle_sync_neighbors(tri,  kids[1], kids[1]->t.b);
+       roam_triangle_sync_neighbors(triangle,  kids[0], kids[0]->t.b);
+       roam_triangle_sync_neighbors(triangle,  kids[1], kids[1]->t.b);
        roam_triangle_sync_neighbors(base, kids[2], kids[2]->t.b);
        roam_triangle_sync_neighbors(base, kids[3], kids[3]->t.b);
 
@@ -425,14 +425,14 @@ void roam_diamond_merge(RoamDiamond *self, RoamSphere *sphere)
        roam_triangle_remove(kids[3], sphere);
 
        /* Clear kids */
-       tri->kids[0]  = tri->kids[1]  = NULL;
+       triangle->kids[0]  = triangle->kids[1]  = NULL;
        base->kids[0] = base->kids[1] = NULL;
 
        /* Add/Remove triangles */
-       if (tri->t.l->t.l == tri->t.r->t.r &&
-           tri->t.l->t.l != tri && tri->parent) {
-               roam_diamond_update_errors(tri->parent, sphere);
-               roam_diamond_add(tri->parent, sphere);
+       if (triangle->t.l->t.l == triangle->t.r->t.r &&
+           triangle->t.l->t.l != triangle && triangle->parent) {
+               roam_diamond_update_errors(triangle->parent, sphere);
+               roam_diamond_add(triangle->parent, sphere);
        }
 
        if (base->t.l->t.l == base->t.r->t.r &&
@@ -442,22 +442,22 @@ void roam_diamond_merge(RoamDiamond *self, RoamSphere *sphere)
        }
 
        /* Remove and free diamond and child triangles */
-       roam_diamond_remove(self, sphere);
-       g_assert(self->kids[0]->p.m == self->kids[1]->p.m &&
-                self->kids[1]->p.m == self->kids[2]->p.m &&
-                self->kids[2]->p.m == self->kids[3]->p.m);
-       g_assert(self->kids[0]->p.m->tris == 0);
-       roam_triangle_free(self->kids[0]);
-       roam_triangle_free(self->kids[1]);
-       roam_triangle_free(self->kids[2]);
-       roam_triangle_free(self->kids[3]);
-       g_free(self);
+       roam_diamond_remove(diamond, sphere);
+       g_assert(diamond->kids[0]->p.m == diamond->kids[1]->p.m &&
+                diamond->kids[1]->p.m == diamond->kids[2]->p.m &&
+                diamond->kids[2]->p.m == diamond->kids[3]->p.m);
+       g_assert(diamond->kids[0]->p.m->tris == 0);
+       roam_triangle_free(diamond->kids[0]);
+       roam_triangle_free(diamond->kids[1]);
+       roam_triangle_free(diamond->kids[2]);
+       roam_triangle_free(diamond->kids[3]);
+       g_free(diamond);
 }
-void roam_diamond_update_errors(RoamDiamond *self, RoamSphere *sphere)
+void roam_diamond_update_errors(RoamDiamond *diamond, RoamSphere *sphere)
 {
-       roam_triangle_update_errors(self->parents[0], sphere);
-       roam_triangle_update_errors(self->parents[1], sphere);
-       self->error = MAX(self->parents[0]->error, self->parents[1]->error);
+       roam_triangle_update_errors(diamond->parents[0], sphere);
+       roam_triangle_update_errors(diamond->parents[1], sphere);
+       diamond->error = MAX(diamond->parents[0]->error, diamond->parents[1]->error);
 }
 
 /**************
@@ -465,10 +465,10 @@ void roam_diamond_update_errors(RoamDiamond *self, RoamSphere *sphere)
  **************/
 RoamSphere *roam_sphere_new()
 {
-       RoamSphere *self = g_new0(RoamSphere, 1);
-       self->polys       = 8;
-       self->triangles   = g_pqueue_new((GCompareDataFunc)tri_cmp, NULL);
-       self->diamonds    = g_pqueue_new((GCompareDataFunc)dia_cmp, NULL);
+       RoamSphere *sphere = g_new0(RoamSphere, 1);
+       sphere->polys       = 8;
+       sphere->triangles   = g_pqueue_new((GCompareDataFunc)tri_cmp, NULL);
+       sphere->diamonds    = g_pqueue_new((GCompareDataFunc)dia_cmp, NULL);
 
        RoamPoint *vertexes[] = {
                roam_point_new( 90,   0,  0), // 0 (North)
@@ -493,133 +493,133 @@ RoamSphere *roam_sphere_new()
        for (int i = 0; i < 6; i++)
                roam_point_update_height(vertexes[i]);
        for (int i = 0; i < 8; i++)
-               self->roots[i] = roam_triangle_new(
+               sphere->roots[i] = roam_triangle_new(
                        vertexes[_triangles[i][0][0]],
                        vertexes[_triangles[i][0][1]],
                        vertexes[_triangles[i][0][2]]);
        for (int i = 0; i < 8; i++)
-               roam_triangle_add(self->roots[i],
-                       self->roots[_triangles[i][1][0]],
-                       self->roots[_triangles[i][1][1]],
-                       self->roots[_triangles[i][1][2]],
-                       self);
+               roam_triangle_add(sphere->roots[i],
+                       sphere->roots[_triangles[i][1][0]],
+                       sphere->roots[_triangles[i][1][1]],
+                       sphere->roots[_triangles[i][1][2]],
+                       sphere);
        for (int i = 0; i < 8; i++)
-               g_debug("RoamSphere: new - %p edge=%f,%f,%f,%f", self->roots[i],
-                               self->roots[i]->edge.n,
-                               self->roots[i]->edge.s,
-                               self->roots[i]->edge.e,
-                               self->roots[i]->edge.w);
+               g_debug("RoamSphere: new - %p edge=%f,%f,%f,%f", sphere->roots[i],
+                               sphere->roots[i]->edge.n,
+                               sphere->roots[i]->edge.s,
+                               sphere->roots[i]->edge.e,
+                               sphere->roots[i]->edge.w);
 
-       return self;
+       return sphere;
 }
-void roam_sphere_update_view(RoamSphere *self)
+void roam_sphere_update_view(RoamSphere *sphere)
 {
-       if (!self->view)
-               self->view = g_new0(RoamView, 1);
-       glGetDoublev (GL_MODELVIEW_MATRIX,  self->view->model);
-       glGetDoublev (GL_PROJECTION_MATRIX, self->view->proj);
-       glGetIntegerv(GL_VIEWPORT,          self->view->view);
-       self->view->version++;
+       if (!sphere->view)
+               sphere->view = g_new0(RoamView, 1);
+       glGetDoublev (GL_MODELVIEW_MATRIX,  sphere->view->model);
+       glGetDoublev (GL_PROJECTION_MATRIX, sphere->view->proj);
+       glGetIntegerv(GL_VIEWPORT,          sphere->view->view);
+       sphere->view->version++;
 }
-void roam_sphere_update_errors(RoamSphere *self)
+void roam_sphere_update_errors(RoamSphere *sphere)
 {
-       g_debug("RoamSphere: update_errors - polys=%d", self->polys);
-       GPtrArray *tris = g_pqueue_get_array(self->triangles);
-       GPtrArray *dias = g_pqueue_get_array(self->diamonds);
+       g_debug("RoamSphere: update_errors - polys=%d", sphere->polys);
+       GPtrArray *tris = g_pqueue_get_array(sphere->triangles);
+       GPtrArray *dias = g_pqueue_get_array(sphere->diamonds);
 
-       roam_sphere_update_view(self);
+       roam_sphere_update_view(sphere);
 
        for (int i = 0; i < tris->len; i++) {
-               RoamTriangle *tri = tris->pdata[i];
-               roam_triangle_update_errors(tri, self);
-               g_pqueue_priority_changed(self->triangles, tri->handle);
+               RoamTriangle *triangle = tris->pdata[i];
+               roam_triangle_update_errors(triangle, sphere);
+               g_pqueue_priority_changed(sphere->triangles, triangle->handle);
        }
 
        for (int i = 0; i < dias->len; i++) {
-               RoamDiamond *dia = dias->pdata[i];
-               roam_diamond_update_errors(dia, self);
-               g_pqueue_priority_changed(self->diamonds, dia->handle);
+               RoamDiamond *diamond = dias->pdata[i];
+               roam_diamond_update_errors(diamond, sphere);
+               g_pqueue_priority_changed(sphere->diamonds, diamond->handle);
        }
 
        g_ptr_array_free(tris, TRUE);
        g_ptr_array_free(dias, TRUE);
 }
 
-void roam_sphere_split_one(RoamSphere *self)
+void roam_sphere_split_one(RoamSphere *sphere)
 {
-       RoamTriangle *to_split = g_pqueue_peek(self->triangles);
+       RoamTriangle *to_split = g_pqueue_peek(sphere->triangles);
        if (!to_split) return;
-       roam_triangle_split(to_split, self);
+       roam_triangle_split(to_split, sphere);
 }
-void roam_sphere_merge_one(RoamSphere *self)
+void roam_sphere_merge_one(RoamSphere *sphere)
 {
-       RoamDiamond *to_merge = g_pqueue_peek(self->diamonds);
+       RoamDiamond *to_merge = g_pqueue_peek(sphere->diamonds);
        if (!to_merge) return;
-       roam_diamond_merge(to_merge, self);
+       roam_diamond_merge(to_merge, sphere);
 }
-gint roam_sphere_split_merge(RoamSphere *self)
+gint roam_sphere_split_merge(RoamSphere *sphere)
 {
        gint iters = 0, max_iters = 500;
        //gint target = 4000;
        gint target = 2000;
        //gint target = 500;
 
-       if (!self->view)
+       if (!sphere->view)
                return 0;
 
-       if (target - self->polys > 100) {
-               //g_debug("RoamSphere: split_merge - Splitting %d - %d > 100", target, self->polys);
-               while (self->polys < target && iters++ < max_iters)
-                       roam_sphere_split_one(self);
+       if (target - sphere->polys > 100) {
+               //g_debug("RoamSphere: split_merge - Splitting %d - %d > 100", target, sphere->polys);
+               while (sphere->polys < target && iters++ < max_iters)
+                       roam_sphere_split_one(sphere);
        }
 
-       if (self->polys - target > 100) {
-               //g_debug("RoamSphere: split_merge - Merging %d - %d > 100", self->polys, target);
-               while (self->polys > target && iters++ < max_iters)
-                       roam_sphere_merge_one(self);
+       if (sphere->polys - target > 100) {
+               //g_debug("RoamSphere: split_merge - Merging %d - %d > 100", sphere->polys, target);
+               while (sphere->polys > target && iters++ < max_iters)
+                       roam_sphere_merge_one(sphere);
        }
 
-       while (((RoamTriangle*)g_pqueue_peek(self->triangles))->error >
-              ((RoamDiamond *)g_pqueue_peek(self->diamonds ))->error &&
+       while (((RoamTriangle*)g_pqueue_peek(sphere->triangles))->error >
+              ((RoamDiamond *)g_pqueue_peek(sphere->diamonds ))->error &&
               iters++ < max_iters) {
                //g_debug("RoamSphere: split_merge - Fixing 1 %f > %f && %d < %d",
-               //              ((RoamTriangle*)g_pqueue_peek(self->triangles))->error,
-               //              ((RoamDiamond *)g_pqueue_peek(self->diamonds ))->error,
+               //              ((RoamTriangle*)g_pqueue_peek(sphere->triangles))->error,
+               //              ((RoamDiamond *)g_pqueue_peek(sphere->diamonds ))->error,
                //              iters-1, max_iters);
-               roam_sphere_merge_one(self);
-               roam_sphere_split_one(self);
+               roam_sphere_merge_one(sphere);
+               roam_sphere_split_one(sphere);
        }
 
        return iters;
 }
-void roam_sphere_draw(RoamSphere *self)
+void roam_sphere_draw(RoamSphere *sphere)
 {
        g_debug("RoamSphere: draw");
-       g_pqueue_foreach(self->triangles, (GFunc)roam_triangle_draw, NULL);
+       g_pqueue_foreach(sphere->triangles, (GFunc)roam_triangle_draw, NULL);
 }
-void roam_sphere_draw_normals(RoamSphere *self)
+void roam_sphere_draw_normals(RoamSphere *sphere)
 {
        g_debug("RoamSphere: draw_normal");
-       g_pqueue_foreach(self->triangles, (GFunc)roam_triangle_draw_normal, NULL);
+       g_pqueue_foreach(sphere->triangles, (GFunc)roam_triangle_draw_normal, NULL);
 }
-static GList *_roam_sphere_get_leaves(RoamTriangle *tri, GList *list, gboolean all)
+static GList *_roam_sphere_get_leaves(RoamTriangle *triangle, GList *list, gboolean all)
 {
-       if (tri->kids[0] && tri->kids[1]) {
-               if (all) list = g_list_prepend(list, tri);
-               list = _roam_sphere_get_leaves(tri->kids[0], list, all);
-               list = _roam_sphere_get_leaves(tri->kids[1], list, all);
+       if (triangle->kids[0] && triangle->kids[1]) {
+               if (all) list = g_list_prepend(list, triangle);
+               list = _roam_sphere_get_leaves(triangle->kids[0], list, all);
+               list = _roam_sphere_get_leaves(triangle->kids[1], list, all);
                return list;
        } else {
-               return g_list_prepend(list, tri);
+               return g_list_prepend(list, triangle);
        }
 }
-static GList *_roam_sphere_get_intersect_rec(RoamTriangle *tri, GList *list,
+static GList *_roam_sphere_get_intersect_rec(RoamTriangle *triangle, GList *list,
                gboolean all, gdouble n, gdouble s, gdouble e, gdouble w)
 {
-       gdouble tn = tri->edge.n;
-       gdouble ts = tri->edge.s;
-       gdouble te = tri->edge.e;
-       gdouble tw = tri->edge.w;
+       gdouble tn = triangle->edge.n;
+       gdouble ts = triangle->edge.s;
+       gdouble te = triangle->edge.e;
+       gdouble tw = triangle->edge.w;
 
        gboolean debug = FALSE  &&
                n==90 && s==45 && e==-90 && w==-180 &&
@@ -627,7 +627,7 @@ static GList *_roam_sphere_get_intersect_rec(RoamTriangle *tri, GList *list,
 
        if (debug)
                g_message("t=%p: %f < %f || %f > %f || %f < %f || %f > %f",
-                           tri, tn,   s,   ts,   n,   te,   w,   tw,   e);
+                           triangle, tn,   s,   ts,   n,   te,   w,   tw,   e);
        if (tn < s || ts > n || te < w || tw > e) {
                /* No intersect */
                if (debug) g_message("no intersect");
@@ -635,25 +635,25 @@ static GList *_roam_sphere_get_intersect_rec(RoamTriangle *tri, GList *list,
        } else if (tn <= n && ts >= s && te <= e && tw >= w) {
                /* Triangle is completely contained */
                if (debug) g_message("contained");
-               if (all) list = g_list_prepend(list, tri);
-               return _roam_sphere_get_leaves(tri, list, all);
-       } else if (tri->kids[0] && tri->kids[1]) {
+               if (all) list = g_list_prepend(list, triangle);
+               return _roam_sphere_get_leaves(triangle, list, all);
+       } else if (triangle->kids[0] && triangle->kids[1]) {
                /* Paritial intersect with children */
                if (debug) g_message("edge w/ child");
-               if (all) list = g_list_prepend(list, tri);
-               list = _roam_sphere_get_intersect_rec(tri->kids[0], list, all, n, s, e, w);
-               list = _roam_sphere_get_intersect_rec(tri->kids[1], list, all, n, s, e, w);
+               if (all) list = g_list_prepend(list, triangle);
+               list = _roam_sphere_get_intersect_rec(triangle->kids[0], list, all, n, s, e, w);
+               list = _roam_sphere_get_intersect_rec(triangle->kids[1], list, all, n, s, e, w);
                return list;
        } else {
                /* This triangle is an edge case */
                if (debug) g_message("edge");
-               return g_list_prepend(list, tri);
+               return g_list_prepend(list, triangle);
        }
 }
 /* Warning: This grabs pointers to triangles which can be changed by other
  * calls, e.g. split_merge. If you use this, you need to do some locking to
  * prevent the returned list from becomming stale. */
-GList *roam_sphere_get_intersect(RoamSphere *self, gboolean all,
+GList *roam_sphere_get_intersect(RoamSphere *sphere, gboolean all,
                gdouble n, gdouble s, gdouble e, gdouble w)
 {
        /* I think this is correct..
@@ -661,28 +661,28 @@ GList *roam_sphere_get_intersect(RoamSphere *self, gboolean all,
         * time = n_tiles * 2*tris_per_tile * i_cost
         * time = 30      * 2*333           * i_cost = 20000 * i_cost */
        GList *list = NULL;
-       for (int i = 0; i < G_N_ELEMENTS(self->roots); i++)
-               list = _roam_sphere_get_intersect_rec(self->roots[i],
+       for (int i = 0; i < G_N_ELEMENTS(sphere->roots); i++)
+               list = _roam_sphere_get_intersect_rec(sphere->roots[i],
                                list, all, n, s, e, w);
        return list;
 }
-void roam_sphere_free_tri(RoamTriangle *tri)
+void roam_sphere_free_tri(RoamTriangle *triangle)
 {
-       if (--tri->p.l->tris == 0) g_free(tri->p.l);
-       if (--tri->p.m->tris == 0) g_free(tri->p.m);
-       if (--tri->p.r->tris == 0) g_free(tri->p.r);
-       roam_triangle_free(tri);
+       if (--triangle->p.l->tris == 0) g_free(triangle->p.l);
+       if (--triangle->p.m->tris == 0) g_free(triangle->p.m);
+       if (--triangle->p.r->tris == 0) g_free(triangle->p.r);
+       roam_triangle_free(triangle);
 }
-void roam_sphere_free(RoamSphere *self)
+void roam_sphere_free(RoamSphere *sphere)
 {
        g_debug("RoamSphere: free");
        /* Slow method, but it should work */
-       while (self->polys > 8)
-               roam_sphere_merge_one(self);
+       while (sphere->polys > 8)
+               roam_sphere_merge_one(sphere);
        /* TODO: free points */
-       g_pqueue_foreach(self->triangles, (GFunc)roam_sphere_free_tri, NULL);
-       g_pqueue_free(self->triangles);
-       g_pqueue_free(self->diamonds);
-       g_free(self->view);
-       g_free(self);
+       g_pqueue_foreach(sphere->triangles, (GFunc)roam_sphere_free_tri, NULL);
+       g_pqueue_free(sphere->triangles);
+       g_pqueue_free(sphere->diamonds);
+       g_free(sphere->view);
+       g_free(sphere);
 }
index 02d0beb..0e18527 100644 (file)
@@ -102,7 +102,7 @@ RoamDiamond *roam_diamond_new(
 void roam_diamond_add(RoamDiamond *diamond, RoamSphere *sphere);
 void roam_diamond_remove(RoamDiamond *diamond, RoamSphere *sphere);
 void roam_diamond_merge(RoamDiamond *diamond, RoamSphere *sphere);
-void roam_diamond_update_errors(RoamDiamond *self, RoamSphere *sphere);
+void roam_diamond_update_errors(RoamDiamond *diamond, RoamSphere *sphere);
 
 /**************
  * RoamSphere *