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

gEDA-cvs: gaf.git: branch: master updated (1.5.0-20080706-209-gf58328e)



The branch, master has been updated
       via  f58328ec7a4d445b98b67a63b23647f25ae7bb4c (commit)
       via  d0c0a23543aaa266a63799d4decff58768cf961b (commit)
      from  2a9f5584219a894557aa7fd97f94a9a941c5bc1b (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/include/gschem_struct.h |    2 +
 gschem/include/i_vars.h        |    1 +
 gschem/include/prototype.h     |    2 +
 gschem/lib/system-gschemrc.in  |   11 ++++
 gschem/src/g_rc.c              |   18 ++++++
 gschem/src/g_register.c        |    1 +
 gschem/src/gschem_toplevel.c   |    2 +
 gschem/src/i_vars.c            |    3 +
 gschem/src/o_find.c            |   25 ++++++--
 gschem/src/o_select.c          |   94 ++++++++++++++++++++++++++++
 gschem/tests/net_selection.sch |  131 ++++++++++++++++++++++++++++++++++++++++
 11 files changed, 285 insertions(+), 5 deletions(-)
 create mode 100644 gschem/tests/net_selection.sch


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

commit f58328ec7a4d445b98b67a63b23647f25ae7bb4c
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Sun Oct 5 10:01:03 2008 +0200

    gschem: code and test file for the net selection patch
    
    This commit adds the main functionality to gschem. The new function
    o_select_connected_nets() will select nets depending on the configured
    net_selection_mode and the current net_selection_state.
    
    The implementation uses two stacks for traversing the connections. The
    netnames stack contains all connected netnames and the net stack
    contains a collection of all currently collected nets.
    
    Note: The search for the netnames is very expensive, because of the
    required search of all netnames in all objects.
    The default net_selection_mode in system-gschemrc is set to "enable-net",
    only the directly connected nets are selected.
    
    The functionality can be testet with the test schematic
    tests/net_selection.sch.
    
    This patches are based on the work of Franz Mottas [1895538].

:100644 100644 0087240... 4ad41a1... M	gschem/src/o_find.c
:100644 100644 ca152ab... 69c20b9... M	gschem/src/o_select.c
:000000 100644 0000000... aac8118... A	gschem/tests/net_selection.sch

commit d0c0a23543aaa266a63799d4decff58768cf961b
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Sun Oct 5 09:58:29 2008 +0200

    variables and configuration for net selection patch
    
    The net selection lets you select all connected segments of a single
    net segment. The behaviour can be configured with the net-selection-mode
    variable in system-gschemrc.
    
    This patch is based on the work of Franz Mottas [1895538].

:100644 100644 b16b4ea... ec42020... M	gschem/include/gschem_struct.h
:100644 100644 661103e... b9087a9... M	gschem/include/i_vars.h
:100644 100644 96b6ed6... fe4667d... M	gschem/include/prototype.h
:100644 100644 afc5941... 5cacce1... M	gschem/lib/system-gschemrc.in
:100644 100644 1389d23... c355fda... M	gschem/src/g_rc.c
:100644 100644 acba0ed... 8b5765b... M	gschem/src/g_register.c
:100644 100644 8c67769... 13c7c08... M	gschem/src/gschem_toplevel.c
:100644 100644 fc043a3... a6b7084... M	gschem/src/i_vars.c

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

commit f58328ec7a4d445b98b67a63b23647f25ae7bb4c
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Sun Oct 5 10:01:03 2008 +0200

    gschem: code and test file for the net selection patch
    
    This commit adds the main functionality to gschem. The new function
    o_select_connected_nets() will select nets depending on the configured
    net_selection_mode and the current net_selection_state.
    
    The implementation uses two stacks for traversing the connections. The
    netnames stack contains all connected netnames and the net stack
    contains a collection of all currently collected nets.
    
    Note: The search for the netnames is very expensive, because of the
    required search of all netnames in all objects.
    The default net_selection_mode in system-gschemrc is set to "enable-net",
    only the directly connected nets are selected.
    
    The functionality can be testet with the test schematic
    tests/net_selection.sch.
    
    This patches are based on the work of Franz Mottas [1895538].

diff --git a/gschem/src/o_find.c b/gschem/src/o_find.c
index 0087240..4ad41a1 100644
--- a/gschem/src/o_find.c
+++ b/gschem/src/o_find.c
@@ -43,6 +43,11 @@ gboolean o_find_object(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y,
 
   w_slack = WORLDabs( toplevel, w_current->select_slack_pixels );
 
+  /* Decide whether to iterate over all object or start at the last
+     found object. If there is more than one object below the
+     (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) {
     o_current = toplevel->page_current->object_head;
   } else {
@@ -61,9 +66,14 @@ gboolean o_find_object(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y,
 	   (o_current->visibility == INVISIBLE &&
 	    toplevel->show_hidden_text))) {
 	if (change_selection) {
-	  (*o_current->sel_func)(
-				 w_current, o_current, 
-				 SINGLE, 0); /* 0 is count */
+	  /* 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 =
@@ -95,8 +105,13 @@ gboolean o_find_object(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y,
            (o_current->visibility == INVISIBLE &&
             toplevel->show_hidden_text))) {
 	if (change_selection) {
-	  /* 0 is count */
-	  (*o_current->sel_func)(w_current, o_current, SINGLE, 0);
+	  /* 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;
diff --git a/gschem/src/o_select.c b/gschem/src/o_select.c
index ca152ab..69c20b9 100644
--- a/gschem/src/o_select.c
+++ b/gschem/src/o_select.c
@@ -32,6 +32,9 @@
 
 #include <math.h>
 #include <stdio.h>
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
 
 #include "gschem.h"
 
@@ -363,6 +366,97 @@ void o_select_box_search(GSCHEM_TOPLEVEL *w_current)
   i_update_menus(w_current);
 }
 
+/*! \brief Select all nets connected to the current net
+ *  \par Depending on the state of the w_current->net_selection_mode variable
+ *   and the net_selection_state of the current net this function will either
+ *   select the single net, all directly connected nets or all nets connected
+ *   with netname labels.
+ *  \param [in] w_current  GSCHEM_TOPLEVEL struct.
+ *  \param [in] o_net      Pointer to a single net object
+ */
+void o_select_connected_nets(GSCHEM_TOPLEVEL *w_current, OBJECT* o_net)
+{
+  TOPLEVEL *toplevel = w_current->toplevel;
+  GList *iter1;
+  OBJECT *o_current;
+  int count=0;
+  gchar* netname;
+
+  GList *netstack = NULL;
+  GList *netnamestack = NULL;
+  GList *netnameiter;
+
+  g_assert(o_net->type == OBJ_NET);
+
+  if (!o_net->selected) {
+    w_current->net_selection_state = 1;
+  }
+
+  /* the current net is the startpoint for the stack */
+  netstack = g_list_prepend(netstack, o_net);
+
+  count = 0; 
+  while (1) {
+    netnameiter = g_list_last(netnamestack);
+    for (iter1 = g_list_last(netstack);
+	 iter1 != NULL; 
+	 iter1 = g_list_previous(iter1), count++) {
+      o_current = iter1->data;
+      if (o_current->type == OBJ_NET && 
+	  (!o_current->selected || count == 0)) {
+	(*o_current->sel_func)(w_current, o_current, SINGLE, count);
+	if (w_current->net_selection_state > 1) {
+	  /* collect nets */
+	  netstack = g_list_concat(s_conn_return_others(NULL, o_current), netstack);
+	}
+	if (w_current->net_selection_state > 2) {
+	  /* collect netnames */
+	  netname = o_attrib_search_attrib_name(o_current->attribs, "netname", 0);
+	  if (netname != NULL) {
+	    if (g_list_find_custom(netnamestack, netname, (GCompareFunc) strcmp) == NULL) {
+	      netnamestack = g_list_append(netnamestack, netname);
+	    }
+	    else {
+	      g_free(netname);
+	    }
+	  }
+	}
+      }
+    }
+    g_list_free(netstack);
+    netstack = NULL;
+
+    if (netnameiter == g_list_last(netnamestack))
+      break; /* no new netnames in the stack --> finished */
+
+    /* get all the nets of the stacked netnames */
+    for (o_current =  toplevel->page_current->object_head->next;
+	 o_current != NULL;
+	 o_current = o_current->next) {
+      if (o_current->type == OBJ_TEXT
+	  && o_current->attached_to != NULL) {
+	if (o_current->attached_to->type == OBJ_NET) {
+	  netname = o_attrib_search_attrib_name(o_current->attached_to->attribs, "netname", 0);
+	  if (netname != NULL) {
+	    if (g_list_find_custom(netnamestack, netname, (GCompareFunc) strcmp) != NULL) {
+	      netstack = g_list_prepend(netstack, o_current->attached_to);
+	    }
+	    g_free(netname);
+	  }
+	}
+      }
+    }
+  }
+
+  w_current->net_selection_state += 1;
+  if (w_current->net_selection_state > w_current->net_selection_mode)
+    w_current->net_selection_state = 1;
+
+  for (iter1 = netnamestack; iter1 != NULL; iter1 = g_list_next(iter1))
+    g_free(iter1->data);
+  g_list_free(netnamestack);
+}
+
 /* This is a wrapper for o_selection_return_first_object */
 /* This function always looks at the current page selection list */ 
 OBJECT *o_select_return_first_object(GSCHEM_TOPLEVEL *w_current)
diff --git a/gschem/tests/net_selection.sch b/gschem/tests/net_selection.sch
new file mode 100644
index 0000000..aac8118
--- /dev/null
+++ b/gschem/tests/net_selection.sch
@@ -0,0 +1,131 @@
+v 20080127 1
+N 33300 53100 33300 52800 4
+N 33300 52800 35600 52800 4
+N 36000 52800 38300 52800 4
+N 38300 52800 38300 53100 4
+C 34300 52800 1 0 0 vcc-1.sym
+C 36400 52800 1 0 0 vcc-1.sym
+T 32800 58300 9 10 1 0 0 0 1
+Test0: connected net segments
+N 32800 58100 36200 58100 4
+N 36200 58100 36200 57800 4
+N 36200 57800 38900 57800 4
+N 38900 58100 38900 57600 4
+T 32800 56300 9 10 1 0 0 0 1
+Test2: connected net segment with netnames
+N 32800 56000 34400 56000 4
+N 34400 56000 34400 55800 4
+N 34400 55800 35600 55800 4
+{
+T 35300 55900 5 10 1 1 0 0 1
+netname=aaa
+}
+N 36400 55800 37300 55800 4
+{
+T 36400 55900 5 10 1 1 0 0 1
+netname=aaa
+}
+N 37300 55800 37300 56000 4
+N 37300 56000 38900 56000 4
+N 38900 56200 38900 55800 4
+T 32800 55200 9 10 1 0 0 0 1
+Test3: connected net segment with multiple netnames
+N 32800 55000 33600 55000 4
+N 33600 55000 33600 54800 4
+N 33600 54800 34600 54800 4
+{
+T 34100 54900 5 10 1 1 0 0 1
+netname=bb1
+}
+N 35000 54800 35800 54800 4
+{
+T 35200 54900 5 10 1 1 0 0 1
+netname=bb1
+}
+N 35800 54800 35800 55000 4
+N 35800 55000 36300 55000 4
+N 36300 55000 36300 54800 4
+N 36300 54800 36800 54800 4
+{
+T 36500 54900 5 10 1 1 0 0 1
+netname=bb2
+}
+N 37200 54800 38000 54800 4
+{
+T 37400 54900 5 10 1 1 0 0 1
+netname=bb2
+}
+N 38000 54800 38000 55000 4
+N 38000 55000 38900 55000 4
+N 38900 55100 38900 54800 4
+N 32800 54100 33600 54100 4
+{
+T 33000 53900 5 10 1 1 0 0 1
+netname=cc0
+}
+N 33600 54100 33600 53900 4
+N 33600 53900 34600 53900 4
+{
+T 34100 54000 5 10 1 1 0 0 1
+netname=cc1
+}
+N 35000 53900 35800 53900 4
+{
+T 35200 54000 5 10 1 1 0 0 1
+netname=cc1
+}
+N 35800 53900 35800 54100 4
+N 35800 54100 36300 54100 4
+N 36300 54100 36300 53900 4
+N 36300 53900 36800 53900 4
+{
+T 36500 54000 5 10 1 1 0 0 1
+netname=cc2
+}
+N 37200 53900 38000 53900 4
+{
+T 37400 54000 5 10 1 1 0 0 1
+netname=cc2
+}
+N 38000 53900 38000 54100 4
+N 38000 54100 38900 54100 4
+N 38900 54200 38900 53900 4
+{
+T 39000 54000 5 10 1 1 0 0 1
+netname=cc0
+}
+T 32800 54300 9 10 1 0 0 0 1
+Test4: connected netssegment with multiple netnames and netname loop
+N 36200 56900 38900 56900 4
+N 38900 57200 38900 56700 4
+T 32800 57400 9 10 1 0 0 0 1
+Test1: connected net segments with loops
+N 33400 57200 33400 56800 4
+N 33800 56800 33800 57200 4
+N 34300 56800 34300 57200 4
+N 33800 57000 34300 57000 4
+N 34100 57000 34100 56800 4
+N 33400 56800 35100 56800 4
+N 35100 56800 35100 57200 4
+N 35100 57000 36200 57000 4
+N 35200 56800 35700 56800 4
+N 35700 56800 35700 57000 4
+N 36200 56800 36200 57200 4
+N 36200 56800 37000 56800 4
+N 37000 56800 37000 56900 4
+N 36500 56800 36500 57200 4
+N 32800 57200 36500 57200 4
+N 36300 56800 36300 57100 4
+N 36300 57100 35100 57100 4
+T 32800 53400 9 10 1 0 0 0 1
+Test5: Nets connected with labels
+N 33300 53100 32800 53100 4
+N 38300 53100 38900 53100 4
+N 38900 53300 38900 52800 4
+T 32800 59500 9 10 1 0 0 0 3
+This is a collection of possible connections that can
+appear in a schematic. 
+The net selection code should work with all tests.
+N 32800 58800 35400 58800 4
+T 32800 58900 9 10 1 0 0 0 1
+single net, of course

commit d0c0a23543aaa266a63799d4decff58768cf961b
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Sun Oct 5 09:58:29 2008 +0200

    variables and configuration for net selection patch
    
    The net selection lets you select all connected segments of a single
    net segment. The behaviour can be configured with the net-selection-mode
    variable in system-gschemrc.
    
    This patch is based on the work of Franz Mottas [1895538].

diff --git a/gschem/include/gschem_struct.h b/gschem/include/gschem_struct.h
index b16b4ea..ec42020 100644
--- a/gschem/include/gschem_struct.h
+++ b/gschem/include/gschem_struct.h
@@ -154,6 +154,8 @@ struct st_gschem_toplevel {
   int net_endpoint_mode;  /* can be either NONE, FILLEDBOX, EMPTYBOX, X */
   int net_midpoint_mode;  /* can be either NONE or FILLED or EMPTY */
   int net_direction_mode; /* controls if the net direction mode is used */
+  int net_selection_mode;  /* controls the behaviour when selecting a net */
+  int net_selection_state;  /* current status of the net selecting mode */
   int embed_complex;      /* controls if complex objects are embedded */
   int include_complex;    /* controls if complex objects are included */
   int scrollbars_flag;    /* controls if scrollbars are displayed */
diff --git a/gschem/include/i_vars.h b/gschem/include/i_vars.h
index 661103e..b9087a9 100644
--- a/gschem/include/i_vars.h
+++ b/gschem/include/i_vars.h
@@ -17,6 +17,7 @@ extern int default_override_pin_color;
 extern int default_net_endpoint_mode;
 extern int default_net_midpoint_mode;
 extern int default_net_direction_mode;
+extern int default_net_selection_mode;
 extern int default_junction_color;
 extern int default_pin_color;
 extern int default_line_style;
diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
index 96b6ed6..fe4667d 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -214,6 +214,7 @@ SCM g_rc_freestyle_color(SCM index, SCM color, SCM outline_color, SCM ps_color,
 SCM g_rc_net_endpoint_mode(SCM mode);
 SCM g_rc_net_midpoint_mode(SCM mode);
 SCM g_rc_net_direction_mode(SCM mode);
+SCM g_rc_net_selection_mode(SCM mode);
 SCM g_rc_net_style(SCM mode);
 SCM g_rc_bus_style(SCM mode);
 SCM g_rc_pin_style(SCM mode);
@@ -716,6 +717,7 @@ void o_select_box_end(GSCHEM_TOPLEVEL *w_current, int x, int y);
 void o_select_box_rubberband(GSCHEM_TOPLEVEL *w_current, int x, int y);
 void o_select_box_rubberband_xor(GSCHEM_TOPLEVEL *w_current);
 void o_select_box_search(GSCHEM_TOPLEVEL *w_current);
+void o_select_connected_nets(GSCHEM_TOPLEVEL *w_current, OBJECT* o_current);
 OBJECT *o_select_return_first_object(GSCHEM_TOPLEVEL *w_current);
 int o_select_selected(GSCHEM_TOPLEVEL *w_current);
 void o_select_unselect_list(GSCHEM_TOPLEVEL *w_current, SELECTION *selection);
diff --git a/gschem/lib/system-gschemrc.in b/gschem/lib/system-gschemrc.in
index afc5941..5cacce1 100644
--- a/gschem/lib/system-gschemrc.in
+++ b/gschem/lib/system-gschemrc.in
@@ -121,6 +121,17 @@
 (net-direction-mode "enabled")
 ;(net-direction-mode "disabled")
 
+;  net-selection-mode string
+;
+; Controls how many net segments are selected when you click at a net
+; If one of the enabled items is used, the selection state will toggle 
+; through all selection states. The mode defines the maximum search depth
+; for the net selection mode
+;
+;(net-selection-mode "disabled")
+(net-selection-mode "enabled_net")
+;(net-selection-mode "enabled_all")
+
 ;  net-consolidate string
 ;
 ;  Controls if the net consolidation code is used when schematics are read
diff --git a/gschem/src/g_rc.c b/gschem/src/g_rc.c
index 1389d23..c355fda 100644
--- a/gschem/src/g_rc.c
+++ b/gschem/src/g_rc.c
@@ -308,6 +308,24 @@ SCM g_rc_net_direction_mode(SCM mode)
  *  \par Function Description
  *
  */
+SCM g_rc_net_selection_mode(SCM mode)
+{
+  static const vstbl_entry mode_table[] = {
+    {0, "disabled"},
+    {2, "enabled_net"},
+    {3, "enabled_all"}
+  };
+
+  RETURN_G_RC_MODE("net-selection-mode",
+		   default_net_selection_mode,
+		   3);
+}
+
+/*! \todo Finish function documentation!!!
+ *  \brief
+ *  \par Function Description
+ *
+ */
 SCM g_rc_net_style(SCM mode)
 {
   static const vstbl_entry mode_table[] = {
diff --git a/gschem/src/g_register.c b/gschem/src/g_register.c
index acba0ed..8b5765b 100644
--- a/gschem/src/g_register.c
+++ b/gschem/src/g_register.c
@@ -77,6 +77,7 @@ static struct gsubr_t gschem_funcs[] = {
   { "net-endpoint-mode",         1, 0, 0, g_rc_net_endpoint_mode },
   { "net-midpoint-mode",         1, 0, 0, g_rc_net_midpoint_mode },
   { "net-direction-mode",        1, 0, 0, g_rc_net_direction_mode },
+  { "net-selection-mode",        1, 0, 0, g_rc_net_selection_mode },
   { "net-style",                 1, 0, 0, g_rc_net_style },
   { "bus-style",                 1, 0, 0, g_rc_bus_style },
   { "pin-style",                 1, 0, 0, g_rc_pin_style },
diff --git a/gschem/src/gschem_toplevel.c b/gschem/src/gschem_toplevel.c
index 8c67769..13c7c08 100644
--- a/gschem/src/gschem_toplevel.c
+++ b/gschem/src/gschem_toplevel.c
@@ -170,6 +170,8 @@ GSCHEM_TOPLEVEL *gschem_toplevel_new ()
   w_current->net_endpoint_mode = NONE;
   w_current->net_midpoint_mode = NONE;
   w_current->net_direction_mode = TRUE;
+  w_current->net_selection_mode = 0;
+  w_current->net_selection_state = 0;
   w_current->embed_complex = 0;
   w_current->include_complex = 0;
   w_current->scrollbars_flag = 0;
diff --git a/gschem/src/i_vars.c b/gschem/src/i_vars.c
index fc043a3..a6b7084 100644
--- a/gschem/src/i_vars.c
+++ b/gschem/src/i_vars.c
@@ -53,6 +53,7 @@ int   default_override_pin_color = -1;
 int   default_net_endpoint_mode = FILLEDBOX;
 int   default_net_midpoint_mode = FILLED;
 int   default_net_direction_mode = TRUE;
+int   default_net_selection_mode = 0;
 int   default_pin_color = PIN_COLOR;
 int   default_pin_style = THICK;
 int   default_net_style = THICK;
@@ -186,6 +187,8 @@ void i_vars_set(GSCHEM_TOPLEVEL *w_current)
   w_current->net_endpoint_mode  = default_net_endpoint_mode;
   w_current->net_midpoint_mode  = default_net_midpoint_mode;
   w_current->net_direction_mode = default_net_direction_mode;
+  w_current->net_selection_mode = default_net_selection_mode;
+
   toplevel->override_net_color = default_override_net_color;
 
   toplevel->junction_color = default_junction_color;




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