Removed structure TILE_LOC: now objects have a list of references to
TILE structures.
---
 libgeda/include/prototype.h |    1 -
 libgeda/include/struct.h    |    7 +---
 libgeda/src/s_basic.c       |    2 +-
 libgeda/src/s_conn.c        |   21 ++-------
 libgeda/src/s_tile.c        |   92 ++++++++-----------------------------------
 5 files changed, 24 insertions(+), 99 deletions(-)

diff --git a/libgeda/include/prototype.h b/libgeda/include/prototype.h
index a7df60d..93a3d22 100644
--- a/libgeda/include/prototype.h
+++ b/libgeda/include/prototype.h
@@ -477,7 +477,6 @@ void s_stretch_destroy_all(STRETCH *head);
 
 /* s_tile.c */
 void s_tile_init(TOPLEVEL *toplevel, PAGE *p_current);
-TILE_LOC *s_tile_new_loc(int i, int j);
 void s_tile_add_line_object(TOPLEVEL *toplevel, OBJECT *object);
 void s_tile_remove_object(TOPLEVEL *toplevel, PAGE *page, OBJECT *object);
 void s_tile_update_object(TOPLEVEL *toplevel, OBJECT *object);
diff --git a/libgeda/include/struct.h b/libgeda/include/struct.h
index 98cfbc8..8a9ad2f 100644
--- a/libgeda/include/struct.h
+++ b/libgeda/include/struct.h
@@ -42,7 +42,6 @@ typedef struct st_toplevel TOPLEVEL;
 typedef struct st_color COLOR;
 typedef struct st_undo UNDO;
 typedef struct st_tile TILE;
-typedef struct st_tile_loc TILE_LOC;
 
 typedef struct st_conn CONN;
 typedef struct st_bus_ripper BUS_RIPPER;
@@ -205,7 +204,7 @@ struct st_object {
   TEXT *text;
   PICTURE *picture;
 
-  GList *tile_locs;                    /* tile locations */
+  GList *tiles;                        /* tiles */
 
   GList *conn_list;                    /* List of connections */
   /* to and from this object */
@@ -336,10 +335,6 @@ struct st_tile {
   int top, left, right, bottom;
 };
 
-struct st_tile_loc {
-  int i, j;    /* these are the indices into the tile structure */
-};
-
 struct st_page {
 
   int pid;
diff --git a/libgeda/src/s_basic.c b/libgeda/src/s_basic.c
index 8bce75c..c84e439 100644
--- a/libgeda/src/s_basic.c
+++ b/libgeda/src/s_basic.c
@@ -137,7 +137,7 @@ OBJECT *s_basic_init_object( char *name )
   new_node->text = NULL;
   new_node->complex = NULL;
 
-  new_node->tile_locs = NULL;
+  new_node->tiles = NULL;
 
   new_node->conn_list = NULL;
 
diff --git a/libgeda/src/s_conn.c b/libgeda/src/s_conn.c
index da1e10b..085bf1d 100644
--- a/libgeda/src/s_conn.c
+++ b/libgeda/src/s_conn.c
@@ -271,31 +271,22 @@ OBJECT *s_conn_check_midpoint(OBJECT *o_current, int x, 
int y)
 void s_conn_update_object(TOPLEVEL * toplevel, OBJECT * object)
 {
   TILE *t_current;
-  TILE_LOC *tl_current;
-  GList *tloc_list;
+  GList *tl_current;
   GList *object_list;
   OBJECT *other_object;
   OBJECT *found;
   CONN *new_conn;
-  int i, j;
   int k;
   int add_conn;
 
   /* loop over all tiles which object appears in */
-  tloc_list = object->tile_locs;
-  while (tloc_list != NULL) {
-    tl_current = (TILE_LOC *) tloc_list->data;
+  for (tl_current = object->tiles;
+       tl_current != NULL;
+       tl_current = g_list_next (tl_current)) {
+    t_current = (TILE*)tl_current->data;
 
     add_conn = FALSE;
     
-    i = tl_current->i;
-    j = tl_current->j;
-
-#if DEBUG
-    printf("\nInside tile: %d %d\n\n", i, j);
-#endif
-    
-    t_current = &toplevel->page_current->world_tiles[i][j];
     object_list = t_current->objects;
     while (object_list != NULL) {
       other_object = (OBJECT *) object_list->data;
@@ -670,8 +661,6 @@ void s_conn_update_object(TOPLEVEL * toplevel, OBJECT * 
object)
 
       object_list = g_list_next(object_list);
     } 
-
-    tloc_list = g_list_next(tloc_list);
   }
 
 #if DEBUG
diff --git a/libgeda/src/s_tile.c b/libgeda/src/s_tile.c
index 2b7c91c..a1e3de4 100644
--- a/libgeda/src/s_tile.c
+++ b/libgeda/src/s_tile.c
@@ -87,29 +87,11 @@ void s_tile_init(TOPLEVEL * toplevel, PAGE * p_current)
  *  \par Function Description
  *
  */
-TILE_LOC *s_tile_new_loc(int i, int j)
-{
-  TILE_LOC *tile_loc;
-
-  tile_loc = (TILE_LOC *) g_malloc(sizeof(TILE_LOC));
-
-  tile_loc->i = i;
-  tile_loc->j = j;
-
-  return (tile_loc);
-}
-
-/*! \todo Finish function documentation!!!
- *  \brief
- *  \par Function Description
- *
- */
 void s_tile_add_line_object (TOPLEVEL *toplevel, OBJECT *object)
 {
   TILE *t_current;
   PAGE *p_current;
   GList *found;
-  TILE_LOC *tile_loc;
   int i, j;
   int v, w;
   double x1, y1, x2, y2;
@@ -168,10 +150,7 @@ void s_tile_add_line_object (TOPLEVEL *toplevel, OBJECT 
*object)
           /*printf("%d %d\n", v, w);*/
           t_current->objects = g_list_append(t_current->objects,
                                              object);
-
-          tile_loc = s_tile_new_loc(v, w);
-          object->tile_locs = g_list_append(object->tile_locs,
-                                            tile_loc);
+          object->tiles = g_list_append(object->tiles, t_current);
         }
 
         v = (int) x;
@@ -187,9 +166,7 @@ void s_tile_add_line_object (TOPLEVEL *toplevel, OBJECT 
*object)
           /*printf("%d %d\n", v, w);*/
           t_current->objects = g_list_append(t_current->objects,
                                              object);
-          tile_loc = s_tile_new_loc(v, w);
-          object->tile_locs = g_list_append(object->tile_locs,
-                                            tile_loc);
+          object->tiles = g_list_append(object->tiles, t_current);
         }
 
       } else {
@@ -206,9 +183,7 @@ void s_tile_add_line_object (TOPLEVEL *toplevel, OBJECT 
*object)
           /*printf("%d %d\n", v, w);*/
           t_current->objects = g_list_append(t_current->objects,
                                              object);
-          tile_loc = s_tile_new_loc(v, w);
-          object->tile_locs = g_list_append(object->tile_locs,
-                                            tile_loc);
+          object->tiles = g_list_append(object->tiles, t_current);
         }
       }
     }
@@ -234,9 +209,7 @@ void s_tile_add_line_object (TOPLEVEL *toplevel, OBJECT 
*object)
             /*printf("%d %d\n", v, w);*/
             t_current->objects =
               g_list_append(t_current->objects, object);
-            tile_loc = s_tile_new_loc(v, w);
-            object->tile_locs =
-              g_list_append(object->tile_locs, tile_loc);
+            object->tiles = g_list_append(object->tiles, t_current);
           }
 
           w = (int) y;
@@ -253,9 +226,7 @@ void s_tile_add_line_object (TOPLEVEL *toplevel, OBJECT 
*object)
             /*printf("%d %d\n", v, w);*/
             t_current->objects =
               g_list_append(t_current->objects, object);
-            tile_loc = s_tile_new_loc(v, w);
-            object->tile_locs =
-              g_list_append(object->tile_locs, tile_loc);
+            object->tiles = g_list_append(object->tiles, t_current);
           }
 
         } else {
@@ -273,9 +244,7 @@ void s_tile_add_line_object (TOPLEVEL *toplevel, OBJECT 
*object)
             /*printf("%d %d\n", v, w);*/
             t_current->objects =
               g_list_append(t_current->objects, object);
-            tile_loc = s_tile_new_loc(v, w);
-            object->tile_locs =
-              g_list_append(object->tile_locs, tile_loc);
+            object->tiles = g_list_append(object->tiles, t_current);
           }
         }
       }
@@ -301,9 +270,7 @@ void s_tile_add_line_object (TOPLEVEL *toplevel, OBJECT 
*object)
         /*printf("%d %d\n", v, w);*/
         t_current->objects = g_list_append(t_current->objects,
                                            object);
-        tile_loc = s_tile_new_loc(v, w);
-        object->tile_locs = g_list_append(object->tile_locs,
-                                          tile_loc);
+        object->tiles = g_list_append(object->tiles, t_current);
       }
 
     }
@@ -320,37 +287,20 @@ void s_tile_add_line_object (TOPLEVEL *toplevel, OBJECT 
*object)
  */
 void s_tile_remove_object(TOPLEVEL *toplevel, PAGE *page, OBJECT *object)
 {
-  TILE *t_current;
-  TILE_LOC *tl_current;
-  GList *tloc_list;
-  GList *found;
-  int i, j;
-
-  tloc_list = object->tile_locs;
-  while (tloc_list != NULL) {
-
-    tl_current = (TILE_LOC *) tloc_list->data;
-        
-    i = tl_current->i;
-    j = tl_current->j;
-
-    g_free(tl_current);
+  GList *tl_current;
 
-    t_current = &page->world_tiles[i][j];
-    t_current->objects = g_list_remove(t_current->objects, object);
-
-#if 1 
-    found = g_list_find(t_current->objects, object);
-    if (found) {
-      printf("found an object left over %s in %d, %d\nPlease e-mail [EMAIL 
PROTECTED] with this error message and .sch\n", object->name, i, j);
-    }
-#endif
+  for (tl_current = object->tiles;
+       tl_current != NULL;
+       tl_current = g_list_next (tl_current)) {
+    TILE *t_current = (TILE*)tl_current->data;
     
-    tloc_list = g_list_next(tloc_list);
+    /* remove object from the list of objects for this tile */
+    t_current->objects = g_list_remove(t_current->objects, object);
   }
 
-  g_list_free(tloc_list);
-  object->tile_locs = NULL;
+  /* reset the list of tiles for this object appears in */
+  g_list_free(object->tiles);
+  object->tiles = NULL;
 }
 
 /*! \todo Finish function documentation!!!
@@ -426,9 +376,7 @@ void s_tile_print(TOPLEVEL * toplevel)
 {
   TILE *t_current;
   GList *temp;
-  GList *temp2;
   OBJECT *o_current;
-  TILE_LOC *tloc;
   int i, j;
 
   for (j = 0; j < MAX_TILES_Y; j++) {
@@ -442,12 +390,6 @@ void s_tile_print(TOPLEVEL * toplevel)
         o_current = (OBJECT *) temp->data;
 
         printf("%s\n", o_current->name);
-        temp2 = o_current->tile_locs;
-        while (temp2 != NULL) {
-          tloc = (TILE_LOC *) temp2->data;
-          printf("     %d %d\n", tloc->i, tloc->j);
-          temp2 = g_list_next(temp2);
-        }
 
         temp = g_list_next(temp);
       }
-- 
1.5.6




_______________________________________________
geda-dev mailing list
[email protected]
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev

Reply via email to