]> Pileus Git - grits/commitdiff
Removing unnecessary things from gis-object
authorAndy Spencer <andy753421@gmail.com>
Mon, 25 Jan 2010 07:45:09 +0000 (07:45 +0000)
committerAndy Spencer <andy753421@gmail.com>
Mon, 25 Jan 2010 09:33:08 +0000 (09:33 +0000)
- GisObject primitives aren't being used anymore (for now)

src/gis-object.c
src/gis-object.h
src/gis-opengl.c
src/plugins/test.c

index cfd1870f137ab62456aa658b9177cf937ab316e5..bd6c5c95800287f906693d7ff744b26a56f3d788 100644 (file)
 #include "gis-object.h"
 #include "gis-util.h"
 
-/* TODO
- *   - Manage normals for GisPoint
- */
-
 /* GisPoint */
 GisPoint *gis_point_new()
 {
@@ -36,113 +32,15 @@ void gis_point_set_lle(GisPoint *self, gdouble lat, gdouble lon, gdouble elev)
        self->lat  = lat;
        self->lon  = lon;
        self->elev = elev;
-       lle2xyz(self->lat, self->lon, self->elev,
-                       &self->x, &self->y, &self->z);
-}
-
-void gis_point_set_xyz(GisPoint *self, gdouble x, gdouble y, gdouble z)
-{
-       self->x = x;
-       self->y = y;
-       self->z = z;
 }
 
-void gis_point_set_coords(GisPoint *self, gdouble x, gdouble y)
+void gis_point_free(GisPoint *self)
 {
-       self->cx = x;
-       self->cy = y;
-}
-
-void gis_point_project(GisPoint *self, GisProjection *proj)
-{
-       gluProject(self->x, self->y, self->z,
-                  proj->model, proj->proj, proj->view,
-                  &self->px, &self->py, &self->pz);
-}
-
-GisPoint *gis_point_ref(GisPoint *self)
-{
-       self->refs++;
-       return self;
-}
-
-void gis_point_unref(GisPoint *self)
-{
-       self->refs--;
-       if (self->refs <= 0)
-               g_free(self);
-}
-
-
-/* GisTriangle */
-GisTriangle *gis_triangle_new(GisPoint *a, GisPoint *b, GisPoint *c, guint tex)
-{
-       GisTriangle *self = g_new0(GisTriangle, 1);
-       GIS_OBJECT(self)->type = GIS_TYPE_TRIANGLE;
-       gis_point_set_xyz(&GIS_OBJECT(self)->center,
-               (a->x + b->x + c->x)/3,
-               (a->y + b->y + c->y)/3,
-               (a->z + b->z + c->z)/3);
-       self->verts[0] = gis_point_ref(a);
-       self->verts[1] = gis_point_ref(b);
-       self->verts[2] = gis_point_ref(c);
-       self->tex      = tex;
-       return self;
-}
-
-void gis_triangle_free(GisTriangle *self)
-{
-       gis_point_unref(self->verts[0]);
-       gis_point_unref(self->verts[1]);
-       gis_point_unref(self->verts[2]);
-       g_free(self);
-}
-
-
-/* GisQuad */
-GisQuad *gis_quad_new(GisPoint *a, GisPoint *b, GisPoint *c, GisPoint *d, guint tex)
-{
-       GisQuad *self = g_new0(GisQuad, 1);
-       GIS_OBJECT(self)->type = GIS_TYPE_QUAD;
-       gis_point_set_xyz(&GIS_OBJECT(self)->center,
-               (a->x + b->x + c->x + d->x)/4,
-               (a->y + b->y + c->y + d->y)/4,
-               (a->z + b->z + c->z + d->z)/4);
-       self->verts[0] = gis_point_ref(a);
-       self->verts[1] = gis_point_ref(b);
-       self->verts[2] = gis_point_ref(c);
-       self->verts[3] = gis_point_ref(d);
-       self->tex      = tex;
-       return self;
-}
-
-void gis_quad_free(GisQuad *self)
-{
-       gis_point_unref(self->verts[0]);
-       gis_point_unref(self->verts[1]);
-       gis_point_unref(self->verts[2]);
-       gis_point_unref(self->verts[3]);
        g_free(self);
 }
 
 
-/* GisCallback */
-GisCallback *gis_callback_new(GisCallbackFunc callback, gpointer user_data)
-{
-       GisCallback *self = g_new0(GisCallback, 1);
-       GIS_OBJECT(self)->type = GIS_TYPE_CALLBACK;
-       self->callback  = callback;
-       self->user_data = user_data;
-       return self;
-}
-
-void gis_callback_free(GisCallback *self)
-{
-       g_free(self);
-}
-
-
-/* GisCallback */
+/* GisMarker */
 GisMarker *gis_marker_new(const gchar *label)
 {
        static const int RADIUS =   4;
@@ -172,3 +70,19 @@ void gis_marker_free(GisMarker *self)
        g_free(self->label);
        g_free(self);
 }
+
+
+/* GisCallback */
+GisCallback *gis_callback_new(GisCallbackFunc callback, gpointer user_data)
+{
+       GisCallback *self = g_new0(GisCallback, 1);
+       GIS_OBJECT(self)->type = GIS_TYPE_CALLBACK;
+       self->callback  = callback;
+       self->user_data = user_data;
+       return self;
+}
+
+void gis_callback_free(GisCallback *self)
+{
+       g_free(self);
+}
index a58b8157b5d7cf604f5022f8a55b3fa98166ef3e..9fc0ba750522fcfb4701b246d6b345b0b2424bc0 100644 (file)
 #include <glib.h>
 #include <cairo.h>
 
-/* Base types */
-typedef struct _GisProjection GisProjection;
+/* GisPoint */
 typedef struct _GisPoint      GisPoint;
 
-struct _GisProjection {
-       gdouble model[16];
-       gdouble proj[16];
-       gint    view[4];
-};
 struct _GisPoint {
-       union {
-               gdouble lle[3];
-               struct { gdouble lat, lon, elev; };
-       };
-       union {
-               gdouble xyz[3];
-               struct { gdouble x, y, z; };
-       };
-       union {
-               gdouble proj[3];
-               struct { gdouble px, py, pz; };
-       };
-       union {
-               gdouble norm[3];
-               struct { gdouble nx, ny, nz; };
-       };
-       union {
-               gdouble coords[2];
-               struct { gdouble cx, cy, xz; };
-       };
-       gint refs;
+       gdouble lat, lon, elev;
 };
 
-/* Objects */
+GisPoint *gis_point_new();
+void gis_point_set_lle(GisPoint *point, gdouble lat, gdouble lon, gdouble elev);
+void gis_point_free(GisPoint *point);
+
+
+/* GisObject */
 #define GIS_OBJECT(object)     ((GisObject  *)object)
-#define GIS_TRIANGLE(triangle) ((GisTriangle*)triangle)
-#define GIS_QUAD(quad)         ((GisQuad    *)quad)
-#define GIS_CALLBACK(callback) ((GisCallback*)callback)
-#define GIS_MARKER(marker)     ((GisMarker  *)marker)
 
 typedef enum {
-       GIS_TYPE_TRIANGLE,
-       GIS_TYPE_QUAD,
        GIS_TYPE_CALLBACK,
        GIS_TYPE_MARKER,
        GIS_NUM_TYPES,
 } GisObjectType;
 
-typedef struct _GisObject   GisObject;
-typedef struct _GisTriangle GisTriangle;
-typedef struct _GisQuad     GisQuad;
-typedef struct _GisCallback GisCallback;
-typedef struct _GisMarker   GisMarker;
-
-typedef gpointer (*GisCallbackFunc)(GisCallback *callback, gpointer user_data);
+typedef struct _GisObject GisObject;
 
 struct _GisObject {
-       GisObjectType  type;
-       GisPoint       center;
-       GisProjection *proj;
-       gdouble        lod;
-};
-struct _GisTriangle {
-       GisObject  parent;
-       GisPoint  *verts[3];
-       guint      tex;
-};
-struct _GisQuad {
-       GisObject  parent;
-       GisPoint  *verts[4];
-       guint     tex;
-};
-struct _GisCallback {
-       GisObject       parent;
-       GisCallbackFunc callback;
-       gpointer        user_data;
+       GisObjectType type;
+       GisPoint      center;
+       gdouble       lod;
 };
+
+static inline GisPoint *gis_object_center(GisObject *object)
+{
+       return &GIS_OBJECT(object)->center;
+}
+
+
+/* GisMarker */
+#define GIS_MARKER(marker) ((GisMarker  *)marker)
+
+typedef struct _GisMarker GisMarker;
+
 struct _GisMarker   {
        GisObject  parent;
        gint       xoff, yoff;
@@ -106,28 +69,24 @@ struct _GisMarker   {
        guint      tex;
 };
 
-/* Support functions */
-#define gis_object_center(object) \
-       (&GIS_OBJECT(object)->center)
+GisMarker *gis_marker_new(const gchar *label);
+void gis_marker_free(GisMarker *marker);
 
-GisPoint *gis_point_new();
-void gis_point_set_lle(GisPoint *point, gdouble lat, gdouble lon, gdouble elev);
-void gis_point_set_xyz(GisPoint *point, gdouble x, gdouble y, gdouble z);
-void gis_point_set_coords(GisPoint *point, gdouble x, gdouble y);
-void gis_point_project(GisPoint *point, GisProjection *proj);
-GisPoint *gis_point_ref(GisPoint *point);
-void gis_point_unref(GisPoint *point);
 
-GisTriangle *gis_triangle_new(GisPoint *a, GisPoint *b, GisPoint *c, guint tex);
-void gis_triangle_free(GisTriangle *tri);
+/* GisCallback */
+#define GIS_CALLBACK(callback) ((GisCallback*)callback)
 
-GisQuad *gis_quad_new(GisPoint *a, GisPoint *b, GisPoint *c, GisPoint *d, guint tex);
-void gis_quad_free(GisQuad *quad);
+typedef struct _GisCallback GisCallback;
+typedef gpointer (*GisCallbackFunc)(GisCallback *callback, gpointer user_data);
+
+struct _GisCallback {
+       GisObject       parent;
+       GisCallbackFunc callback;
+       gpointer        user_data;
+};
 
 GisCallback *gis_callback_new(GisCallbackFunc callback, gpointer user_data);
 void gis_callback_free(GisCallback *cb);
 
-GisMarker *gis_marker_new(const gchar *label);
-void gis_marker_free(GisMarker *marker);
 
 #endif
index 0bcde3d9279a288ce45a36ac4606dfa6a6a43e01..b1886c2b2ce0c36b321f348ba1de50835a0a3013 100644 (file)
@@ -65,9 +65,11 @@ static void _gis_opengl_end(GisOpenGL *self)
  ********************/
 static void _draw_marker(GisOpenGL *self, GisMarker *marker)
 {
-       GisProjection *proj = (GisProjection*)self->sphere->view;
-       GisPoint *point = gis_object_center(marker);
-       gis_point_project(point, proj);
+       GisPoint *point = gis_object_center(GIS_OBJECT(marker));
+       gdouble px, py, pz;
+       gis_viewer_project(GIS_VIEWER(self),
+                       point->lat, point->lon, point->elev,
+                       &px, &py, &pz);
 
        g_debug("GisOpenGL: draw_marker - texture=%d", marker->tex);
 
@@ -79,8 +81,8 @@ static void _draw_marker(GisOpenGL *self, GisMarker *marker)
        glMatrixMode(GL_MODELVIEW);  glLoadIdentity();
        glOrtho(0, GTK_WIDGET(self)->allocation.width,
                0, GTK_WIDGET(self)->allocation.height, -1, 1);
-       glTranslated(gis_object_center(marker)->px - marker->xoff,
-                    gis_object_center(marker)->py - marker->yoff, 0);
+       glTranslated(px - marker->xoff,
+                    py - marker->yoff, 0);
 
        glDisable(GL_LIGHTING);
        glDisable(GL_COLOR_MATERIAL);
index 5be0fd7a0eb9f6feef69dc8d360e42b0e3bc1952..5094758cd804693f399e16c1f5f985403f2baa34 100644 (file)
@@ -33,7 +33,7 @@ GisPluginTest *gis_plugin_test_new(GisViewer *viewer)
        self->viewer = viewer;
 
        GisMarker *marker = gis_marker_new("St. Charles");
-       gis_point_set_lle(gis_object_center(marker), 38.841847, -90.491982, 0);
+       gis_point_set_lle(gis_object_center(GIS_OBJECT(marker)), 38.841847, -90.491982, 0);
        gis_viewer_add(self->viewer, GIS_OBJECT(marker));
 
        return self;