[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: gaf.git: branch: master updated (1.5.0-20080706-439-gba3af99)



The branch, master has been updated
       via  ba3af993a28bf244f9fae7a216827c94cacf2c3c (commit)
       via  d0df24b4e4346327275c4e17cbeff63afeb0df4f (commit)
      from  d8cc920d932f1557f3d93da6abd1d99e690f39ef (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 gschem/src/o_find.c |  147 ++++++++++++++++++++++++++++-----------------------
 1 files changed, 81 insertions(+), 66 deletions(-)


=================
 Commit Messages
=================

commit ba3af993a28bf244f9fae7a216827c94cacf2c3c
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Sat Dec 20 22:07:44 2008 +0000

    gschem: Refactor duplicated code in o_find_object()
    
    Also add documentation for this and our new helper function.

:100644 100644 475295a... 4ea3c0c... M	gschem/src/o_find.c

commit d0df24b4e4346327275c4e17cbeff63afeb0df4f
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Sat Dec 20 22:07:44 2008 +0000

    gschem: Fix breakage in multiple-object hit select-cycling
    
    This was broken when switching to OBJECT GLists. We need to start
    our first search for objects _after_ the one we selected last time,
    otherwise we just find the same object again and again.

:100644 100644 a886131... 475295a... M	gschem/src/o_find.c

=========
 Changes
=========

commit ba3af993a28bf244f9fae7a216827c94cacf2c3c
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Sat Dec 20 22:07:44 2008 +0000

    gschem: Refactor duplicated code in o_find_object()
    
    Also add documentation for this and our new helper function.

diff --git a/gschem/src/o_find.c b/gschem/src/o_find.c
index 475295a..4ea3c0c 100644
--- a/gschem/src/o_find.c
+++ b/gschem/src/o_find.c
@@ -28,17 +28,72 @@
 #include <dmalloc.h>
 #endif
 
-/*! \todo Finish function documentation!!!
- *  \brief
+
+/*! \brief Tests a if a given OBJECT was hit at a given set of coordinates
+ *
  *  \par Function Description
+ *  Tests a if a given OBJECT was hit at a given set of coordinates. If so,
+ *  processes selection changes as appropriate for the object and passed
+ *  flag. Saves a pointer to the found object so future find operations
+ *  resume after this object.
  *
+ *  \param [in] w_current         The GSCHEM_TOPLEVEL object.
+ *  \param [in] object            The OBJECT being hit-tested.
+ *  \param [in] w_x               The X coordinate to test (in world coords).
+ *  \param [in] w_y               The Y coordinate to test (in world coords).
+ *  \param [in] w_slack           The slack applied to the hit-test.
+ *  \param [in] change_selection  Whether to select the found object or not.
+ *  \returns TRUE if the OBJECT was hit, otherwise FALSE.
  */
-gboolean o_find_object(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y,
-		       gboolean change_selection)
+static gboolean find_single_object (GSCHEM_TOPLEVEL *w_current, OBJECT *object,
+                                    int w_x, int w_y, int w_slack,
+                                    int change_selection)
+{
+  TOPLEVEL *toplevel = w_current->toplevel;
+  if (object->sel_func != NULL &&
+      (object->visibility == VISIBLE || toplevel->show_hidden_text) &&
+      inside_region (object->w_left  - w_slack, object->w_top    - w_slack,
+                     object->w_right + w_slack, object->w_bottom + w_slack,
+                     w_x, w_y) &&
+      o_shortest_distance (object, w_x, w_y) < w_slack) {
+    if (change_selection) {
+      /* FIXME: should this be moved to o_select_object()? (Werner) */
+      if (object->type == OBJ_NET && w_current->net_selection_mode) {
+        o_select_connected_nets (w_current, object);
+      } else {
+        (*object->sel_func) (w_current, object, SINGLE, 0); /* 0 is count */
+      }
+    }
+    toplevel->page_current->object_lastplace = object;
+    i_update_menus (w_current);
+    return TRUE;
+  }
+  return FALSE;
+}
+
+
+/*! \brief Find an OBJECT at a given set of coordinates
+ *
+ *  \par Function Description
+ *  Tests for OBJECTS hit at a given set of coordinates. If
+ *  change_selection is TRUE, it updates the page's selection.
+ *
+ *  Find operations resume searching after the last object which was
+ *  found, so multiple find operations at the same point will cycle
+ *  through any objects on top of each other at this location.
+ *
+ *  \param [in] w_current         The GSCHEM_TOPLEVEL object.
+ *  \param [in] object            The OBJECT being hit-tested.
+ *  \param [in] w_x               The X coordinate to test (in world coords).
+ *  \param [in] w_y               The Y coordinate to test (in world coords).
+ *  \param [in] change_selection  Whether to select the found object or not.
+ *  \returns TRUE if the object was hit at the given coordinates,
+ *           otherwise FALSE.
+ */
+gboolean o_find_object (GSCHEM_TOPLEVEL *w_current, int w_x, int w_y,
+                        gboolean change_selection)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
-  OBJECT *o_current=NULL;
-  gboolean object_found = FALSE;
   int w_slack;
   GList *iter = NULL;
 
@@ -57,62 +112,22 @@ gboolean o_find_object(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y,
 
   /* do first search (if we found any objects after the last found object) */
   while (iter != NULL) {
-    o_current = iter->data;
-    if (inside_region(o_current->w_left - w_slack, o_current->w_top - w_slack,
-                      o_current->w_right + w_slack, o_current->w_bottom + w_slack,
-                      w_x, w_y) &&
-        o_shortest_distance (o_current, w_x, w_y) < w_slack ) {
-      if (o_current->sel_func != NULL &&
-          (o_current->visibility == VISIBLE || toplevel->show_hidden_text)) {
-        if (change_selection) {
-          /* FIXME: should this switch be moved to o_select_object()? (Werner) */
-          if (o_current->type == OBJ_NET && w_current->net_selection_mode) {
-            o_select_connected_nets(w_current, o_current);
-          } else {
-            (*o_current->sel_func)(w_current, o_current,
-                                   SINGLE, 0); /* 0 is count */
-          }
-        }
-        object_found = TRUE;
-        toplevel->page_current->object_lastplace = o_current;
-        i_update_menus(w_current);
-        return object_found;
-      }
+    OBJECT *o_current = iter->data;
+    if (find_single_object (w_current, o_current,
+                            w_x, w_y, w_slack, change_selection)) {
+      return TRUE;
     }
     iter = g_list_next (iter);
-  } 
-
-#if DEBUG
-  printf("SEARCHING AGAIN\n");
-#endif
+  }
 
   /* now search from the beginning up until the object_lastplace */
   for (iter = toplevel->page_current->object_list;
        iter != NULL; iter = g_list_next (iter)) {
-    o_current = iter->data;
-    if (inside_region(o_current->w_left - w_slack, o_current->w_top - w_slack,
-                      o_current->w_right + w_slack, o_current->w_bottom + w_slack,
-                      w_x, w_y) &&
-        o_shortest_distance (o_current, w_x, w_y) < w_slack) {
-
-      if (o_current->sel_func != NULL &&
-          (o_current->visibility == VISIBLE || toplevel->show_hidden_text)) {
-        if (change_selection) {
-          /* FIXME: should this switch be moved to o_select_object()? (Werner) */
-          if (o_current->type == OBJ_NET && w_current->net_selection_mode) {
-            o_select_connected_nets(w_current, o_current);
-          } else {
-            (*o_current->sel_func)(w_current, o_current, SINGLE, 0); /* 0 is count */
-          }
-        }
-        toplevel->page_current->object_lastplace = o_current;
-        object_found = TRUE;
-
-        i_update_menus(w_current);
-        return object_found;
-      }
+    OBJECT *o_current = iter->data;
+    if (find_single_object (w_current, o_current,
+                            w_x, w_y, w_slack, change_selection)) {
+      return TRUE;
     }
-
     /* break once we've inspected up to where we started the first loop */
     if (o_current == toplevel->page_current->object_lastplace)
       break;
@@ -128,8 +143,7 @@ gboolean o_find_object(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y,
   }
 
   i_update_menus(w_current);
-
-  return (object_found);
+  return FALSE;
 }
 
 /*! \todo Finish function documentation!!!

commit d0df24b4e4346327275c4e17cbeff63afeb0df4f
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Sat Dec 20 22:07:44 2008 +0000

    gschem: Fix breakage in multiple-object hit select-cycling
    
    This was broken when switching to OBJECT GLists. We need to start
    our first search for objects _after_ the one we selected last time,
    otherwise we just find the same object again and again.

diff --git a/gschem/src/o_find.c b/gschem/src/o_find.c
index a886131..475295a 100644
--- a/gschem/src/o_find.c
+++ b/gschem/src/o_find.c
@@ -49,13 +49,13 @@ gboolean o_find_object(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y,
      (w_x/w_y) position, this will select the next object below the
      position point. You can change the selected object by clicking
      at the same place multiple times. */
-  if (toplevel->page_current->object_lastplace != NULL)
+  if (toplevel->page_current->object_lastplace != NULL) {
     iter = g_list_find (toplevel->page_current->object_list,
                         toplevel->page_current->object_lastplace);
-  if (iter == NULL)
-    iter = toplevel->page_current->object_list;
+    iter = g_list_next (iter);
+  }
 
-  /* do first search */
+  /* do first search (if we found any objects after the last found object) */
   while (iter != NULL) {
     o_current = iter->data;
     if (inside_region(o_current->w_left - w_slack, o_current->w_top - w_slack,
@@ -86,11 +86,9 @@ gboolean o_find_object(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y,
   printf("SEARCHING AGAIN\n");
 #endif
 
-  /* now search again since we didn't find anything starting at start
-     just in case we started last time at object_lastplace */
-  iter = toplevel->page_current->object_list;
-  while (iter != NULL &&
-         iter->data != toplevel->page_current->object_lastplace) {
+  /* now search from the beginning up until the object_lastplace */
+  for (iter = toplevel->page_current->object_list;
+       iter != NULL; iter = g_list_next (iter)) {
     o_current = iter->data;
     if (inside_region(o_current->w_left - w_slack, o_current->w_top - w_slack,
                       o_current->w_right + w_slack, o_current->w_bottom + w_slack,
@@ -108,13 +106,16 @@ gboolean o_find_object(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y,
           }
         }
         toplevel->page_current->object_lastplace = o_current;
-         object_found = TRUE;
+        object_found = TRUE;
 
         i_update_menus(w_current);
         return object_found;
       }
     }
-    iter = g_list_next (iter);
+
+    /* break once we've inspected up to where we started the first loop */
+    if (o_current == toplevel->page_current->object_lastplace)
+      break;
   }
 
   /* didn't find anything.... reset lastplace */




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs