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

gEDA-cvs: gaf.git: branch: master updated (1.5.1-20081221-126-g72fd325)



The branch, master has been updated
       via  72fd3257b7f7949714e16b6bb970c6b7bd658305 (commit)
       via  f37c893edfeb016e57aae5e92f48093608e5cdfb (commit)
       via  7d01d4ae87fd329ffa3e93df9e286dd6e56e225c (commit)
       via  998e8546754fe2ab41a57ce112c3966190c501df (commit)
      from  6249029131003dc6191f804ea2866e9bad28ed8c (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/prototype.h  |    3 +
 gschem/src/g_keys.c         |    1 +
 gschem/src/i_callbacks.c    |   18 ++
 gschem/src/o_cue.c          |   69 +++---
 gschem/src/o_pin.c          |   10 +-
 gschem/src/x_dialog.c       |   76 +++++++
 gschem/src/x_menus.c        |    1 +
 libgeda/include/defines.h   |    7 +-
 libgeda/include/prototype.h |    2 +-
 libgeda/src/o_pin_basic.c   |   32 +++-
 libgeda/src/s_conn.c        |  488 +++++++++++--------------------------------
 libgeda/src/s_cue.c         |   42 ++---
 12 files changed, 318 insertions(+), 431 deletions(-)


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

commit f37c893edfeb016e57aae5e92f48093608e5cdfb
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Sat Jan 3 02:38:29 2009 +0000

    gschem: Add interface to toggle a pin between net pin and bus pin types.
    
    This allows schematic diagrams of hierarchical connections to include
    buses. Since gnetlist does not currently support buses, this feature is
    useful only for diagrams, or when used with a custom netlister.
    
    Since we don't want to mislead users into thinking bus pins netlist,
    the option to set pin type is only present on the page's popup menu,
    and is marked "(graphical)".

:100644 100644 fabfa85... 1bb685f... M	gschem/include/prototype.h
:100644 100644 838890d... 0a9d1fe... M	gschem/src/g_keys.c
:100644 100644 64fd915... da043ee... M	gschem/src/i_callbacks.c
:100644 100644 b7b5d8e... f782484... M	gschem/src/x_dialog.c
:100644 100644 e2c38a7... 258ea88... M	gschem/src/x_menus.c
:100644 100644 536d088... 121a004... M	libgeda/include/prototype.h
:100644 100644 dc65a0b... e1573ae... M	libgeda/src/o_pin_basic.c

commit 7d01d4ae87fd329ffa3e93df9e286dd6e56e225c
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Fri Jan 2 23:14:53 2009 +0000

    libgeda: Fix bus/net to bus/net pin connectivity checking rules
    
    Previously, the type of pin was not checked when computing connections,
    and buses were disallowed from connecting to any type of pin.
    
    Refactor s_conn_update_line_object() to concicely check the following:
    
      Allow connections between matching pin types only.
      Allow connections between nets, other nets and net pins.
      Allow connections between nets and the mid-points of a bus.
      Allow connections between buses, other buses and bus pins.

:100644 100644 8e8fe97... d4f5b0a... M	libgeda/src/s_conn.c

commit 998e8546754fe2ab41a57ce112c3966190c501df
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Fri Jan 2 23:14:52 2009 +0000

    gschem: Add support for rendering and adding pins with type PIN_TYPE_BUS
    
    Bus pins are rendered thicker, and with a bigger cue than standard pins
    of PIN_TYPE_NET.
    
    This commit also fixes a bug where the wrong sized cue circle was drawn
    for net-net interconnections.

:100644 100644 c104804... bc74598... M	gschem/src/o_cue.c
:100644 100644 b4e6c45... 9e37997... M	gschem/src/o_pin.c
:100644 100644 ecc4643... 536d82d... M	libgeda/include/defines.h
:100644 100644 2b9ef71... dc65a0b... M	libgeda/src/o_pin_basic.c
:100644 100644 aa8888e... 9d7b681... M	libgeda/src/s_cue.c

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

commit f37c893edfeb016e57aae5e92f48093608e5cdfb
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Sat Jan 3 02:38:29 2009 +0000

    gschem: Add interface to toggle a pin between net pin and bus pin types.
    
    This allows schematic diagrams of hierarchical connections to include
    buses. Since gnetlist does not currently support buses, this feature is
    useful only for diagrams, or when used with a custom netlister.
    
    Since we don't want to mislead users into thinking bus pins netlist,
    the option to set pin type is only present on the page's popup menu,
    and is marked "(graphical)".

diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
index fabfa85..1bb685f 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -77,6 +77,7 @@ SCM g_keys_edit_mirror_hotkey(SCM rest);
 SCM g_keys_edit_slot(SCM rest);
 SCM g_keys_edit_color(SCM rest);
 SCM g_keys_edit_edit(SCM rest);
+SCM g_keys_edit_pin_type(SCM rest);
 SCM g_keys_edit_text(SCM rest);
 SCM g_keys_edit_lock(SCM rest);
 SCM g_keys_edit_unlock(SCM rest);
@@ -326,6 +327,7 @@ void i_callback_edit_move(gpointer data, guint callback_action, GtkWidget *widge
 void i_callback_edit_move_hotkey(gpointer data, guint callback_action, GtkWidget *widget);
 void i_callback_edit_delete(gpointer data, guint callback_action, GtkWidget *widget);
 void i_callback_edit_edit(gpointer data, guint callback_action, GtkWidget *widget);
+void i_callback_edit_pin_type(gpointer data, guint callback_action, GtkWidget *widget);
 void i_callback_edit_text(gpointer data, guint callback_action, GtkWidget *widget);
 void i_callback_edit_slot(gpointer data, guint callback_action, GtkWidget *widget);
 void i_callback_edit_color(gpointer data, guint callback_action, GtkWidget *widget);
@@ -760,6 +762,7 @@ void major_changed_dialog(GSCHEM_TOPLEVEL* w_current);
 void x_dialog_close_changed_page (GSCHEM_TOPLEVEL *w_current, PAGE *page);
 gboolean x_dialog_close_window (GSCHEM_TOPLEVEL *w_current);
 int x_dialog_validate_attribute(GtkWindow* parent, char *attribute);
+void x_dialog_edit_pin_type(GSCHEM_TOPLEVEL *w_current, const GList *obj_list);
 /* x_event.c */
 gint x_event_expose(GtkWidget *widget, GdkEventExpose *event, GSCHEM_TOPLEVEL *w_current);
 gint x_event_button_pressed(GtkWidget *widget, GdkEventButton *event, GSCHEM_TOPLEVEL *w_current);
diff --git a/gschem/src/g_keys.c b/gschem/src/g_keys.c
index 838890d..0a9d1fe 100644
--- a/gschem/src/g_keys.c
+++ b/gschem/src/g_keys.c
@@ -237,6 +237,7 @@ DEFINE_G_KEYS(edit_mirror_hotkey)
 DEFINE_G_KEYS(edit_slot)
 DEFINE_G_KEYS(edit_color)
 DEFINE_G_KEYS(edit_edit)
+DEFINE_G_KEYS(edit_pin_type)
 DEFINE_G_KEYS(edit_text)
 DEFINE_G_KEYS(edit_lock)
 DEFINE_G_KEYS(edit_unlock)
diff --git a/gschem/src/i_callbacks.c b/gschem/src/i_callbacks.c
index 64fd915..da043ee 100644
--- a/gschem/src/i_callbacks.c
+++ b/gschem/src/i_callbacks.c
@@ -697,6 +697,24 @@ DEFINE_I_CALLBACK(edit_edit)
  *  \par Function Description
  *
  */
+DEFINE_I_CALLBACK(edit_pin_type)
+{
+  GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
+
+  exit_if_null(w_current);
+
+  i_update_middle_button (w_current, i_callback_edit_pin_type, _("Edit pin type"));
+
+  x_dialog_edit_pin_type (w_current,
+                          geda_list_get_glist (w_current->toplevel->
+                                                 page_current->selection_list));
+}
+
+/*! \todo Finish function documentation!!!
+ *  \brief
+ *  \par Function Description
+ *
+ */
 DEFINE_I_CALLBACK(edit_text)
 {
   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
diff --git a/gschem/src/x_dialog.c b/gschem/src/x_dialog.c
index b7b5d8e..f782484 100644
--- a/gschem/src/x_dialog.c
+++ b/gschem/src/x_dialog.c
@@ -4113,3 +4113,79 @@ int x_dialog_validate_attribute(GtkWindow* parent, char *attribute)
 }
 /***************** End of misc helper dialog boxes **************/
 
+/*! \brief Edit the type of a pin (bus or net)
+ *  \par Function Description
+ *  This function presents an app modal dialog to edit the type of a pin
+ */
+
+void x_dialog_edit_pin_type (GSCHEM_TOPLEVEL *w_current, const GList *obj_list)
+{
+  GtkWidget *dialog;
+  GtkWidget *vbox;
+  GtkWidget *radio1;
+  GtkWidget *radio2;
+  const GList *iter;
+  int new_type;
+
+  if (obj_list == NULL)
+    return;
+
+  dialog = gschem_dialog_new_with_buttons(_("Pin type"),
+                                          GTK_WINDOW(w_current->main_window),
+                                          GTK_DIALOG_MODAL,
+                                          "pin-type-edit", w_current,
+                                          GTK_STOCK_CANCEL,
+                                          GTK_RESPONSE_CANCEL,
+                                          GTK_STOCK_OK,
+                                          GTK_RESPONSE_OK,
+                                          NULL);
+
+  /* Set the alternative button order (ok, cancel, help) for other systems */
+  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
+                                           GTK_RESPONSE_OK,
+                                           GTK_RESPONSE_CANCEL,
+                                           -1);
+
+  gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
+
+  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
+
+  gtk_container_border_width (GTK_CONTAINER (dialog), DIALOG_BORDER_SPACING);
+  vbox = GTK_DIALOG (dialog)->vbox;
+  gtk_box_set_spacing (GTK_BOX(vbox), DIALOG_V_SPACING);
+
+  radio1 = gtk_radio_button_new_with_label (NULL, _("Net pin"));
+  radio2 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio1),
+                                                        _("Bus pin (graphical)"));
+  /* Pack them into a box, then show all the widgets */
+  gtk_box_pack_start (GTK_BOX (vbox), radio1, TRUE, TRUE, 2);
+  gtk_box_pack_start (GTK_BOX (vbox), radio2, TRUE, TRUE, 2);
+  gtk_widget_show_all (vbox);
+
+  switch (gtk_dialog_run (GTK_DIALOG (dialog))) {
+    case GTK_RESPONSE_OK:
+      new_type = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio1)) ?
+                   PIN_TYPE_NET : PIN_TYPE_BUS;
+      for (iter = obj_list; iter != NULL; iter = g_list_next (iter)) {
+        OBJECT *object = iter->data;
+
+        if (object->type == OBJ_PIN) {
+          o_invalidate (w_current, object);
+          s_conn_remove_object (w_current->toplevel, object);
+          o_pin_set_type (object, new_type);
+          s_conn_update_object (w_current->toplevel, object);
+          o_invalidate (w_current, object);
+        }
+      }
+      break;
+
+    case GTK_RESPONSE_CANCEL:
+    default:
+      /* Do nothing */
+      break;
+  }
+
+  gtk_widget_destroy (dialog);
+}
+
+/***************** End of pin type edit dialog box *********************/
diff --git a/gschem/src/x_menus.c b/gschem/src/x_menus.c
index e2c38a7..258ea88 100644
--- a/gschem/src/x_menus.c
+++ b/gschem/src/x_menus.c
@@ -46,6 +46,7 @@ static GtkItemFactoryEntry popup_items[] = {
   { "/sep1", NULL, NULL, 0, "<Separator>"},
   { N_("/Select"), 	  NULL, i_callback_edit_select,       0, NULL},
   { N_("/Edit..."), 	  NULL, i_callback_edit_edit,         0, NULL},
+  { N_("/Edit pin type..."), 	  NULL, i_callback_edit_pin_type,         0, NULL},
   { N_("/Copy"),          NULL, i_callback_edit_copy,         0, NULL},
   { N_("/Move"),          NULL, i_callback_edit_move,         0, NULL},
   { N_("/Delete"),        NULL, i_callback_edit_delete,       0, NULL},
diff --git a/libgeda/include/prototype.h b/libgeda/include/prototype.h
index 536d088..121a004 100644
--- a/libgeda/include/prototype.h
+++ b/libgeda/include/prototype.h
@@ -279,7 +279,7 @@ void o_pin_rotate_world(TOPLEVEL *toplevel, int world_centerx, int world_centery
 void o_pin_mirror_world(TOPLEVEL *toplevel, int world_centerx, int world_centery, OBJECT *object);
 void o_pin_modify(TOPLEVEL *toplevel, OBJECT *object, int x, int y, int whichone);
 void o_pin_update_whichend(TOPLEVEL *toplevel, GList *object_list, int num_pins);
-
+void o_pin_set_type(OBJECT *o_current, int pin_type);
 /* o_selection.c */
 SELECTION *o_selection_new( void );
 void o_selection_add(SELECTION *selection, OBJECT *o_selected);
diff --git a/libgeda/src/o_pin_basic.c b/libgeda/src/o_pin_basic.c
index dc65a0b..e1573ae 100644
--- a/libgeda/src/o_pin_basic.c
+++ b/libgeda/src/o_pin_basic.c
@@ -101,17 +101,13 @@ OBJECT *o_pin_new(TOPLEVEL *toplevel,
   new_node->line->x[1] = x2;
   new_node->line->y[1] = y2;
 
-  if (pin_type == PIN_TYPE_BUS)
-    new_node->line_width = PIN_WIDTH_BUS;
-  else
-    new_node->line_width = PIN_WIDTH_NET;
+  o_pin_set_type (new_node, pin_type);
 
   o_pin_recalc (toplevel, new_node);
 
   new_node->draw_func = pin_draw_func;  
   new_node->sel_func = select_func;  
 
-  new_node->pin_type = pin_type;
   new_node->whichend = whichend;
   
   if (!toplevel->ADDING_SEL) {
@@ -577,3 +573,29 @@ void o_pin_update_whichend(TOPLEVEL *toplevel,
     iter = g_list_next (iter);
   }
 }
+
+
+/*! \brief Sets the type, and corresponding width of a pin
+ *
+ *  \par Function Description
+ *  Sets the pin's type and width to a particular style.
+ *
+ *  \param [in] o_current  The pin OBJECT being modified
+ *  \param [in] type       The new type of this pin
+ */
+void o_pin_set_type (OBJECT *o_current, int pin_type)
+{
+  switch (pin_type) {
+    default:
+      g_critical ("o_pin_set_type: Got invalid pin type %i\n", pin_type);
+      /* Fall through */
+    case PIN_TYPE_NET:
+      o_current->line_width = PIN_WIDTH_NET;
+      o_current->pin_type = PIN_TYPE_NET;
+      break;
+    case PIN_TYPE_BUS:
+      o_current->line_width = PIN_WIDTH_BUS;
+      o_current->pin_type = PIN_TYPE_BUS;
+      break;
+  }
+}

commit 7d01d4ae87fd329ffa3e93df9e286dd6e56e225c
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Fri Jan 2 23:14:53 2009 +0000

    libgeda: Fix bus/net to bus/net pin connectivity checking rules
    
    Previously, the type of pin was not checked when computing connections,
    and buses were disallowed from connecting to any type of pin.
    
    Refactor s_conn_update_line_object() to concicely check the following:
    
      Allow connections between matching pin types only.
      Allow connections between nets, other nets and net pins.
      Allow connections between nets and the mid-points of a bus.
      Allow connections between buses, other buses and bus pins.

diff --git a/libgeda/src/s_conn.c b/libgeda/src/s_conn.c
index 8e8fe97..d4f5b0a 100644
--- a/libgeda/src/s_conn.c
+++ b/libgeda/src/s_conn.c
@@ -292,6 +292,52 @@ void s_conn_update_glist (TOPLEVEL *toplevel, GList *obj_list)
   }
 }
 
+
+/*! \brief Checks if an object is bus, or a bus pin
+ *
+ *  \par Function Description
+ *  Checks if an object is a bus or a bus pin
+ *
+ *  \param object  The OBJECT to test
+ *  \return TRUE if the objects is a bis, or bus pin
+ */
+static int is_bus_related (OBJECT *object)
+{
+  return (object->type == OBJ_BUS ||
+           (object->type == OBJ_PIN && object->pin_type == PIN_TYPE_BUS));
+}
+
+
+/*! \brief Checks if two objects are of compatible types to be connected
+ *
+ *  \par Function Description
+ *  Checks if two objects are legal to be connected together
+ *
+ *  \param object1  First OBJECT
+ *  \param object2  Second OBJECT
+ *  \return TRUE if the objects are compatible, FALSE if not
+ */
+static int check_direct_compat (OBJECT *object1, OBJECT *object2)
+{
+  return (is_bus_related (object1) == is_bus_related (object2));
+}
+
+
+static void add_connection (OBJECT *object, OBJECT *other_object,
+                            int type, int x, int y,
+                            int whichone, int other_whichone)
+{
+  /* Describe the connection */
+  CONN *new_conn = s_conn_return_new (other_object, type, x, y,
+                                      whichone, other_whichone);
+  /* Do uniqness check */
+  if (s_conn_uniq (object->conn_list, new_conn)) {
+    object->conn_list = g_list_append (object->conn_list, new_conn);
+  } else {
+    g_free (new_conn);
+  }
+}
+
 /*! \brief add a line OBJECT to the connection system
  *  \par Function Description
  *  This function searches for all geometrical conections of the OBJECT
@@ -308,392 +354,112 @@ static void s_conn_update_line_object (TOPLEVEL *toplevel, OBJECT *object)
   GList *object_list;
   OBJECT *other_object;
   OBJECT *found;
-  CONN *new_conn;
-  int k;
-  int add_conn;
+  int j, k;
 
   /* loop over all tiles which object appears in */
   for (tl_current = object->tiles;
        tl_current != NULL;
        tl_current = g_list_next (tl_current)) {
-    t_current = (TILE*)tl_current->data;
-
-    add_conn = FALSE;
-    
-    object_list = t_current->objects;
-    while (object_list != NULL) {
-      other_object = (OBJECT *) object_list->data;
-      
-#if DEBUG
-      printf("Tile has object: %s\n", other_object->name);
-#endif
+    t_current = tl_current->data;
 
-      /* here is where you check the end points */
-      for (k = 0; k < 2; k++) {
-        /* do first end point */
-
-        if (object->line->x[0] == other_object->line->x[k] &&
-            object->line->y[0] == other_object->line->y[k] &&
-            object != other_object) {
-
-          if (object->type == OBJ_PIN) {
-            if (0 == object->whichend) {
-              if (other_object->type == OBJ_PIN && /* new addition */
-                  k != other_object->whichend ) { /* was 0 */
-                add_conn = FALSE; 
-              } else {
-                add_conn = TRUE;
-              }
-            } else {
-              add_conn = FALSE;
-            }
-          } else if (other_object->type == OBJ_PIN) {
-            if (k == other_object->whichend) {
-              if (object->type == OBJ_PIN && /* new addition */
-                  k != object->whichend ) {
-                add_conn = FALSE; 
-              } else {
-                add_conn = TRUE;
-              }
-            } else {
-              add_conn = FALSE;
-            }
-          } else {
-            add_conn = TRUE;
-          }
+    for (object_list = t_current->objects;
+         object_list != NULL;
+         object_list = g_list_next (object_list)) {
+      other_object = object_list->data;
 
-          /* check for pin / bus compatibility */
-          /* you cannot connect pins and buses at all */
-          if (add_conn) {
-            if ((object->type == OBJ_PIN && other_object->type == OBJ_BUS) ||
-                (object->type == OBJ_BUS && other_object->type == OBJ_PIN)) {
-              add_conn = FALSE;
-            } else {
-              add_conn = TRUE;
-            }
-          }
+      if (object == other_object)
+        continue;
 
-          /* check for net / bus compatibility */
-          /* you cannot connect the endpoint of a bus to a net */
-          /* and the reverse is true as well */
-          if (add_conn) {
-            if ((object->type == OBJ_NET && other_object->type == OBJ_BUS) ||
-                (object->type == OBJ_BUS && other_object->type == OBJ_NET)) {
-              add_conn = FALSE;
-            } else {
-              add_conn = TRUE;
-            }
-          }
-          
-#if DEBUG
-          if (add_conn) {
-            printf("0\n");
-            printf("k: %d\n", k);
-            printf("object: %d\n", object->whichend);
-            printf("other: %d\n\n", other_object->whichend);
-          }
-#endif
+      /* Here is where you check the end points */
+      /* Check both end points of the other object */
+      for (k = 0; k < 2; k++) {
 
-          if (add_conn) {
-            new_conn =
-              s_conn_return_new(other_object, CONN_ENDPOINT,
-                                other_object->line->x[k],
-                                other_object->line->y[k], 0, k);
-
-            /* do uniqness check */
-            if (s_conn_uniq(object->conn_list, new_conn)) {
-              object->conn_list =
-                g_list_append(object->conn_list, new_conn);
-            } else {
-              g_free(new_conn);
-            }
+        /* If the other object is a pin, only check the correct end */
+        if (other_object->type == OBJ_PIN && other_object->whichend != k)
+          continue;
 
-            new_conn = s_conn_return_new(object, CONN_ENDPOINT,
-                                         object->line->x[0],
-                                         object->line->y[0], k, 0);
-
-            /* do uniqness check */
-            if (s_conn_uniq(other_object->conn_list, new_conn)) {
-              other_object->conn_list =
-                g_list_append(other_object->conn_list,
-                              new_conn);
-            } else {
-              g_free(new_conn);
-            }
+        /* Check both end points of the object */
+        for (j = 0; j < 2; j++) {
 
-#if DEBUG
-            printf("first end point -> %d\n", k);
-#endif
-          }
-        }
+          /* If the object is a pin, only check the correct end */
+          if (object->type == OBJ_PIN && object->whichend != j)
+            continue;
 
-        /* do second end point */
-        if (object->line->x[1] == other_object->line->x[k] &&
-            object->line->y[1] == other_object->line->y[k] &&
-            object != other_object) {
-          
-          if (object->type == OBJ_PIN) {
-            if (1 == object->whichend) {
-              if (other_object->type == OBJ_PIN && /* new addition */
-                  k != other_object->whichend ) { /* was 1 */
-                add_conn = FALSE; 
-              } else {
-                add_conn = TRUE;
-              }
-            } else {
-              add_conn = FALSE;
-            }
-          } else if (other_object->type == OBJ_PIN) {
-            if (k == other_object->whichend) {
-              if (object->type == OBJ_PIN && /* new addition */
-                  k != object->whichend ) {
-                add_conn = FALSE; 
-              } else {
-                add_conn = TRUE;
-              }       
-            } else {
-              add_conn = FALSE;
-            }
-          } else {
-            add_conn = TRUE;
-          }
+          /* Check for coincidence and compatability between
+             the objects being tested. */
+          if (object->line->x[j] == other_object->line->x[k] &&
+              object->line->y[j] == other_object->line->y[k] &&
+              check_direct_compat (object, other_object)) {
 
-          /* check for pin / bus compatibility */
-          /* you cannot connect pins and buses at all */
-          if (add_conn) {
-            if ((object->type == OBJ_PIN && other_object->type == OBJ_BUS) ||
-                (object->type == OBJ_BUS && other_object->type == OBJ_PIN)) {
-              add_conn = FALSE;
-            } else {
-              add_conn = TRUE;
-            }
-          }
+            add_connection (object, other_object, CONN_ENDPOINT,
+                            other_object->line->x[k],
+                            other_object->line->y[k], j, k);
 
-          /* check for net / bus compatibility */
-          /* you cannot connect the endpoint of a bus to a net */
-          /* and the reverse is true as well */
-          if (add_conn) {
-            if ((object->type == OBJ_NET && other_object->type == OBJ_BUS) ||
-                (object->type == OBJ_BUS && other_object->type == OBJ_NET)) {
-              add_conn = FALSE;
-            } else {
-              add_conn = TRUE;
-            }
-          }
-
-#if DEBUG
-          if (add_conn) {
-            printf("1\n");
-            printf("k: %d\n", k);
-            printf("object: %d\n", object->whichend);
-            printf("other: %d\n\n", other_object->whichend);
-          }
-#endif
-          
-          if (add_conn) {
-            new_conn =
-              s_conn_return_new(other_object, CONN_ENDPOINT,
-                                other_object->line->x[k],
-                                other_object->line->y[k], 1, k);
-
-            /* do uniqness check */
-            if (s_conn_uniq(object->conn_list, new_conn)) {
-              object->conn_list =
-                g_list_append(object->conn_list, new_conn);
-            } else {
-              g_free(new_conn);
-            }
-
-            new_conn = s_conn_return_new(object, CONN_ENDPOINT,
-                                         object->line->x[1],
-                                         object->line->y[1], k, 1);
-
-            /* do uniqness check */
-            if (s_conn_uniq(other_object->conn_list, new_conn)) {
-              other_object->conn_list =
-                g_list_append(other_object->conn_list,
-                              new_conn);
-            } else {
-              g_free(new_conn);
-            }
-
-#if DEBUG
-            printf("second end point -> %d\n", k);
-#endif
+            add_connection (other_object, object, CONN_ENDPOINT,
+                            object->line->x[j],
+                            object->line->y[j], k, j);
           }
         }
-        
-
-        /* check for midpoint of other object, k endpoint of current obj*/
-        found = s_conn_check_midpoint(other_object,
-                                      object->line->x[k],
-                                      object->line->y[k]);
-
-        /* pins are not allowed midpoint connections (on them) */
-        /* pins can cause midpoint connections (via their endpoints) */
-        if (found && other_object->type != OBJ_PIN) { /* found midpoint */
-          /* have to add it to the current object and other object */
-#if DEBUG         
-          printf("%d endpoint to %s midpoint of: %s\n", k, object->name,
-                 found->name);
-#endif          
-
-          if (object->type == OBJ_PIN) {
-            if (k == object->whichend) {
-              add_conn = TRUE;
-            } else {
-              add_conn = FALSE;
-            }
-          } else {
-            add_conn = TRUE;
-          }
+      }
 
-          /* check for pin / bus compatibility */
-          /* you cannot connect pins and buses at all */
-          if (add_conn) {
-            if ((object->type == OBJ_PIN && other_object->type == OBJ_BUS) ||
-                (object->type == OBJ_BUS && other_object->type == OBJ_PIN)) {
-              add_conn = FALSE;
-            } else {
-              add_conn = TRUE;
-            }
-          }
+      /* Check both end points of the object against midpoints of the other */
+      for (k = 0; k < 2; k++) {
 
-          /* check for bus / net compatibility */
-          /* you cannot have the middle of bus connect to nets */
-          if (add_conn) {
-            if (object->type == OBJ_BUS && other_object->type == OBJ_NET) {
-              add_conn = FALSE;
-            } else {
-              add_conn = TRUE;
-            }
-          }
+        /* If the object is a pin, only check the correct end */
+        if (object->type == OBJ_PIN && object->whichend != k)
+          continue;
 
-          if (add_conn) {
-            /* First do the other object and put it in the current */
-            /* object list */
-            new_conn =
-              s_conn_return_new(other_object, CONN_MIDPOINT,
-                                object->line->x[k],
-                                object->line->y[k], k, -1);
-
-            /* do uniqness check */
-            if (s_conn_uniq(object->conn_list, new_conn)) {
-              object->conn_list =
-                g_list_append(object->conn_list, new_conn);
-            } else {
-              g_free(new_conn);
-            }
+        /* check for midpoint of other object, k endpoint of current obj*/
+        found = s_conn_check_midpoint (other_object, object->line->x[k],
+                                                     object->line->y[k]);
+
+        /* Pins are not allowed midpoint connections onto them. */
+        /* Allow nets to connect to the middle of buses. */
+        /* Allow compatible objects to connect. */
+        if (found && other_object->type != OBJ_PIN &&
+            ((object->type == OBJ_NET && other_object->type == OBJ_BUS) ||
+              check_direct_compat (object, other_object))) {
+
+          add_connection (object, other_object, CONN_MIDPOINT,
+                          object->line->x[k],
+                          object->line->y[k], k, -1);
+
+          add_connection (other_object, object, CONN_MIDPOINT,
+                          object->line->x[k],
+                          object->line->y[k], -1, k);
+        }
+      }
 
-            /* Next do the current object and put it into the other */
-            /* object list */
-            new_conn = s_conn_return_new(object, CONN_MIDPOINT,
-                                         object->line->x[k],
-                                         object->line->y[k], -1, k);
-
-            /* do uniqness check */
-            if (s_conn_uniq(other_object->conn_list, new_conn)) {
-              other_object->conn_list =
-                g_list_append(other_object->conn_list,
-                              new_conn);
-            } else {
-              g_free(new_conn);
-            }
+      /* Check both end points of the other object against midpoints of the first */
+      for (k = 0; k < 2; k++) {
 
-          }
-        }
-        
-        /****/
+        /* If the other object is a pin, only check the correct end */
+        if (other_object->type == OBJ_PIN && other_object->whichend != k)
+          continue;
 
         /* do object's endpoints cross the middle of other_object? */
         /* check for midpoint of other object, k endpoint of current obj*/
-        found = s_conn_check_midpoint(object,
-                                      other_object->line->x[k],
-                                      other_object->line->y[k]);
-
-        /* pins are not allowed midpoint connections (on them) */
-        /* pins can cause midpoint connections (via their endpoints) */
-        if (found && object->type != OBJ_PIN) { /* found midpoint */
-          /* have to add it to the current object and other object */
-#if DEBUG          
-          printf("SECOND! %d endpoint to %s midpoint of: %s\n", k,
-                 other_object->name,
-                 found->name);
-#endif          
-
-          if (other_object->type == OBJ_PIN) {
-            if (k == other_object->whichend) {
-              add_conn = TRUE;
-            } else {
-              add_conn = FALSE;
-            }
-          } else {
-            add_conn = TRUE;
-          }
-
-          
-          /* check for pin / bus compatibility */
-          /* you cannot connect pins and buses at all */
-          if (add_conn) {
-            if ((object->type == OBJ_PIN && other_object->type == OBJ_BUS) ||
-                (object->type == OBJ_BUS && other_object->type == OBJ_PIN)) {
-              add_conn = FALSE;
-            } else {
-              add_conn = TRUE;
-            }
-          }
-
-          /* check for bus / net compatibility */
-          /* you cannot have the middle of bus connect to nets */
-          if (add_conn) {
-            if (object->type == OBJ_NET && other_object->type == OBJ_BUS) {
-              add_conn = FALSE;
-            } else {
-              add_conn = TRUE;
-            }
-          }
-
-          
-          if (add_conn) {
-            /* First do the other object and put it in the current */
-            /* object list */
-            new_conn =
-              s_conn_return_new(other_object, CONN_MIDPOINT,
-                                other_object->line->x[k],
-                                other_object->line->y[k], -1, k);
-
-            /* do uniqness check */
-            if (s_conn_uniq(object->conn_list, new_conn)) {
-              object->conn_list =
-                g_list_append(object->conn_list, new_conn);
-            } else {
-              g_free(new_conn);
-            }
-
-            /* Next do the current object and put it into the other */
-            /* object list */
-            new_conn = s_conn_return_new(object, CONN_MIDPOINT,
-                                         other_object->line->x[k],
-                                         other_object->line->y[k], k, -1);
-
-            /* do uniqness check */
-            if (s_conn_uniq(other_object->conn_list, new_conn)) {
-              other_object->conn_list =
-                g_list_append(other_object->conn_list,
-                              new_conn);
-            } else {
-              g_free(new_conn);
-            }
-
-          }
-          /* **** */
-          
-        } /* found midpoint */
-
-      } /* end of for over endpoints */
+        found = s_conn_check_midpoint (object, other_object->line->x[k],
+                                               other_object->line->y[k]);
+
+        /* Pins are not allowed midpoint connections onto them. */
+        /* Allow nets to connect to the middle of buses. */
+        /* Allow compatible objects to connect. */
+        if (found && object->type != OBJ_PIN &&
+             ((object->type == OBJ_BUS && other_object->type == OBJ_NET) ||
+               check_direct_compat (object, other_object))) {
+
+          add_connection (object, other_object, CONN_MIDPOINT,
+                          other_object->line->x[k],
+                          other_object->line->y[k], -1, k);
+
+          add_connection (other_object, object, CONN_MIDPOINT,
+                          other_object->line->x[k],
+                          other_object->line->y[k], k, -1);
+        }
+      }
 
-      object_list = g_list_next(object_list);
-    } 
+    }
   }
 
 #if DEBUG

commit 998e8546754fe2ab41a57ce112c3966190c501df
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Fri Jan 2 23:14:52 2009 +0000

    gschem: Add support for rendering and adding pins with type PIN_TYPE_BUS
    
    Bus pins are rendered thicker, and with a bigger cue than standard pins
    of PIN_TYPE_NET.
    
    This commit also fixes a bug where the wrong sized cue circle was drawn
    for net-net interconnections.

diff --git a/gschem/src/o_cue.c b/gschem/src/o_cue.c
index c104804..bc74598 100644
--- a/gschem/src/o_cue.c
+++ b/gschem/src/o_cue.c
@@ -115,36 +115,33 @@ void o_cue_draw_lowlevel(GSCHEM_TOPLEVEL *w_current, OBJECT *object, int whichon
   y = object->line->y[whichone];
 
   type = CONN_ENDPOINT;
-  
+
+  if (object->type == OBJ_BUS ||
+       (object->type == OBJ_PIN && object->pin_type == PIN_TYPE_BUS))
+    bus_involved = TRUE;
+
   cl_current = object->conn_list;
   while(cl_current != NULL && !done) {
     conn = (CONN *) cl_current->data;
    
     if (conn->x == x && conn->y == y) {
+
+      if (conn->other_object &&
+           (conn->other_object->type == OBJ_BUS ||
+             (conn->other_object->type == OBJ_PIN &&
+              conn->other_object->pin_type == PIN_TYPE_BUS)))
+        bus_involved=TRUE;
+
       switch(conn->type) {
         
         case(CONN_ENDPOINT):
           count++;
-          if (conn->other_object &&
-              ((object->type == OBJ_NET &&
-               conn->other_object->type == OBJ_BUS) ||
-              (object->type == OBJ_BUS &&
-               conn->other_object->type == OBJ_NET))) {
-            bus_involved=TRUE;
-          }
           break;
 
         case(CONN_MIDPOINT):
           type = CONN_MIDPOINT;
           done = TRUE;
           count = 0;
-          if (conn->other_object &&
-              ((object->type == OBJ_NET &&
-                conn->other_object->type == OBJ_BUS) ||
-               (object->type == OBJ_BUS &&
-               conn->other_object->type == OBJ_NET))) {
-            bus_involved=TRUE;
-          }
           break;
       }
     }
@@ -156,9 +153,6 @@ void o_cue_draw_lowlevel(GSCHEM_TOPLEVEL *w_current, OBJECT *object, int whichon
   printf("type: %d count: %d\n", type, count);
 #endif
   
-  size = SCREENabs(toplevel, CUE_BOX_SIZE);
-  x2size = 2 * size;
-
   WORLDtoSCREEN(toplevel, x, y, &screen_x, &screen_y);
   
   switch(type) {
@@ -166,6 +160,8 @@ void o_cue_draw_lowlevel(GSCHEM_TOPLEVEL *w_current, OBJECT *object, int whichon
     case(CONN_ENDPOINT):
       if (object->type == OBJ_NET) { /* only nets have these cues */
         if (count < 1) { /* Didn't find anything connected there */
+          size = SCREENabs(toplevel, CUE_BOX_SIZE);
+          x2size = 2 * size;
           if (toplevel->DONT_REDRAW == 0) {
             o_cue_set_color (w_current, NET_ENDPOINT_COLOR);
             cairo_move_to (w_current->cr, screen_x - size, screen_y - size);
@@ -180,9 +176,9 @@ void o_cue_draw_lowlevel(GSCHEM_TOPLEVEL *w_current, OBJECT *object, int whichon
           /* draw circle */
 
           if (bus_involved) {
-            size = SCREENabs(toplevel, CUE_CIRCLE_SMALL_SIZE) / 2;
-          } else {
             size = SCREENabs(toplevel, CUE_CIRCLE_LARGE_SIZE) / 2;
+          } else {
+            size = SCREENabs(toplevel, CUE_CIRCLE_SMALL_SIZE) / 2;
           }
           x2size = 2 * size;
           if (toplevel->DONT_REDRAW == 0) {
@@ -195,14 +191,18 @@ void o_cue_draw_lowlevel(GSCHEM_TOPLEVEL *w_current, OBJECT *object, int whichon
       } else if (object->type == OBJ_PIN) {
         /* Didn't find anything connected there */
         if (count < 1 && object->whichend == whichone) {
+          if (bus_involved) {
+            size = SCREENabs(toplevel, PIN_CUE_SIZE_BUS);
+          } else {
+            size = SCREENabs(toplevel, PIN_CUE_SIZE_NET);
+          }
+          x2size = size * 2;
 
           otherone = !whichone;
 
-          pinsize = SCREENabs(toplevel, 10);
-          if (toplevel->pin_style == THICK ) {
-            cairo_set_line_width (w_current->cr, pinsize);
-            cairo_set_line_cap (w_current->cr, CAIRO_LINE_CAP_BUTT);
-          }
+          pinsize = 1;
+          if (toplevel->pin_style == THICK )
+            pinsize = SCREENabs(toplevel, object->line_width);
 
           if (toplevel->DONT_REDRAW == 0) {
             o_cue_set_color (w_current, NET_ENDPOINT_COLOR);
@@ -217,7 +217,8 @@ void o_cue_draw_lowlevel(GSCHEM_TOPLEVEL *w_current, OBJECT *object, int whichon
                                    screen_x,         screen_y,
                                    screen_x - size, screen_y);
               }
-              cairo_stroke (w_current->cr);
+              gschem_cairo_stroke (w_current->cr, TYPE_SOLID,
+                                   END_NONE, pinsize, -1, -1);
             } else if (object->line->x[0] == object->line->x[1]) {
               /* vertical line */
               if (object->line->y[whichone] <= object->line->y[otherone]) {
@@ -229,7 +230,8 @@ void o_cue_draw_lowlevel(GSCHEM_TOPLEVEL *w_current, OBJECT *object, int whichon
                                    screen_x, screen_y,
                                    screen_x, screen_y + size);
               }
-              cairo_stroke (w_current->cr);
+              gschem_cairo_stroke (w_current->cr, TYPE_SOLID,
+                                   END_NONE, pinsize, -1, -1);
             } else {
               /* angled line */
               /* not supporting rendering of que for angled pin for now. hack */
@@ -244,9 +246,9 @@ void o_cue_draw_lowlevel(GSCHEM_TOPLEVEL *w_current, OBJECT *object, int whichon
   
       /* draw circle */
       if (bus_involved) {
-        size = SCREENabs(toplevel, CUE_CIRCLE_SMALL_SIZE) / 2;
-      } else {
         size = SCREENabs(toplevel, CUE_CIRCLE_LARGE_SIZE) / 2;
+      } else {
+        size = SCREENabs(toplevel, CUE_CIRCLE_SMALL_SIZE) / 2;
       }
       x2size = size * 2;
 
@@ -297,13 +299,10 @@ void o_cue_draw_lowlevel_midpoints(GSCHEM_TOPLEVEL *w_current, OBJECT *object)
 
         /* draw circle */
         if (conn->other_object &&
-            ( (object->type == OBJ_BUS &&
-               conn->other_object->type == OBJ_NET) ||
-              (object->type == OBJ_NET &&
-               conn->other_object->type == OBJ_BUS))) {
-          size = SCREENabs(toplevel, CUE_CIRCLE_SMALL_SIZE) / 2;
-        } else {
+            (object->type == OBJ_BUS || conn->other_object->type == OBJ_BUS)) {
           size = SCREENabs(toplevel, CUE_CIRCLE_LARGE_SIZE) / 2;
+        } else {
+          size = SCREENabs(toplevel, CUE_CIRCLE_SMALL_SIZE) / 2;
         }
         x2size = size * 2;
 
diff --git a/gschem/src/o_pin.c b/gschem/src/o_pin.c
index b4e6c45..9e37997 100644
--- a/gschem/src/o_pin.c
+++ b/gschem/src/o_pin.c
@@ -63,7 +63,7 @@ void o_pin_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
   if (toplevel->DONT_REDRAW == 0) {
     size = 1;
     if (toplevel->pin_style == THICK) {
-      size = SCREENabs(toplevel, PIN_WIDTH);
+      size = SCREENabs (toplevel, o_current->line_width);
       if (size < 1)
         size=1;
     }
@@ -113,7 +113,7 @@ void o_pin_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_cur
   }
 
   if (toplevel->pin_style == THICK) {
-    size = SCREENabs(toplevel, PIN_WIDTH);
+    size = SCREENabs (toplevel, o_current->line_width);
     if (size < 1) {
       size = 1;
     }
@@ -237,8 +237,9 @@ void o_pin_invalidate_rubber (GSCHEM_TOPLEVEL *w_current)
   WORLDtoSCREEN(toplevel, w_current->first_wx, w_current->first_wy, &x1, &y1);
   WORLDtoSCREEN(toplevel, w_current->second_wx, w_current->second_wy, &x2, &y2);
 
+  /* Pins are always first created as net pins, use net pin width */
   if (toplevel->net_style == THICK ) {
-    bloat = SCREENabs (toplevel, PIN_WIDTH) / 2;
+    bloat = SCREENabs (toplevel, PIN_WIDTH_NET) / 2;
   }
 
   min_x = min (x1, x2) - bloat;
@@ -264,8 +265,9 @@ void o_pin_draw_rubber (GSCHEM_TOPLEVEL *w_current)
   WORLDtoSCREEN(toplevel, w_current->first_wx, w_current->first_wy, &x1, &y1);
   WORLDtoSCREEN(toplevel, w_current->second_wx, w_current->second_wy, &x2, &y2);
 
+  /* Pins are always first created as net pins, use net pin width */
   if (toplevel->net_style == THICK )
-    size = SCREENabs(toplevel, PIN_WIDTH);
+    size = SCREENabs(toplevel, PIN_WIDTH_NET);
 
   if (size < 1)
     size = 1;
diff --git a/libgeda/include/defines.h b/libgeda/include/defines.h
index ecc4643..536d82d 100644
--- a/libgeda/include/defines.h
+++ b/libgeda/include/defines.h
@@ -67,15 +67,18 @@
 #define THICK           1
 
 /* various thicknesses (in mils) */
-#define NET_WIDTH	10
-#define PIN_WIDTH	10
 #define LINE_WIDTH	10
+#define NET_WIDTH	10
+#define PIN_WIDTH_NET	10
 #define BUS_WIDTH	30
+#define PIN_WIDTH_BUS	30
 
 /* various visual cue sizes (in mils) */
 #define CUE_BOX_SIZE 		30
 #define CUE_CIRCLE_SMALL_SIZE	30
 #define CUE_CIRCLE_LARGE_SIZE	60
+#define PIN_CUE_SIZE_NET	30
+#define PIN_CUE_SIZE_BUS	50
 
 /* For text location on component not found graphics */
 #define NOT_FOUND_TEXT_X	100
diff --git a/libgeda/src/o_pin_basic.c b/libgeda/src/o_pin_basic.c
index 2b9ef71..dc65a0b 100644
--- a/libgeda/src/o_pin_basic.c
+++ b/libgeda/src/o_pin_basic.c
@@ -100,7 +100,11 @@ OBJECT *o_pin_new(TOPLEVEL *toplevel,
   new_node->line->y[0] = y1;
   new_node->line->x[1] = x2;
   new_node->line->y[1] = y2;
-  new_node->line_width = PIN_WIDTH;
+
+  if (pin_type == PIN_TYPE_BUS)
+    new_node->line_width = PIN_WIDTH_BUS;
+  else
+    new_node->line_width = PIN_WIDTH_NET;
 
   o_pin_recalc (toplevel, new_node);
 
@@ -324,7 +328,7 @@ void o_pin_print(TOPLEVEL *toplevel, FILE *fp, OBJECT *o_current,
   y2 = o_current->line->y[1] - origin_y;
   pin_width = 2;
   if(toplevel->pin_style == THICK) {
-    pin_width = PIN_WIDTH;
+    pin_width = o_current->line_width;
   }
 
   fprintf(fp, "%d %d %d %d %d line\n",x1,y1,x2,y2,pin_width);
diff --git a/libgeda/src/s_cue.c b/libgeda/src/s_cue.c
index aa8888e..9d7b681 100644
--- a/libgeda/src/s_cue.c
+++ b/libgeda/src/s_cue.c
@@ -130,35 +130,32 @@ void s_cue_output_lowlevel(TOPLEVEL * toplevel, OBJECT * object, int whichone,
 
   type = CONN_ENDPOINT;
 
+  if (object->type == OBJ_BUS ||
+       (object->type == OBJ_PIN && object->pin_type == PIN_TYPE_BUS))
+    bus_involved = TRUE;
+
   cl_current = object->conn_list;
   while (cl_current != NULL && !done) {
     conn = (CONN *) cl_current->data;
 
     if (conn->x == x && conn->y == y) {
+
+      if (conn->other_object &&
+           (conn->other_object->type == OBJ_BUS ||
+             (conn->other_object->type == OBJ_PIN &&
+              conn->other_object->pin_type == PIN_TYPE_BUS)))
+        bus_involved=TRUE;
+
       switch (conn->type) {
 
         case (CONN_ENDPOINT):
           count++;
-          if (conn->other_object &&
-              ((object->type == OBJ_NET &&
-                conn->other_object->type == OBJ_BUS) ||
-               (object->type == OBJ_BUS &&
-                conn->other_object->type == OBJ_NET))) {
-            bus_involved=TRUE;
-          }
           break;
 
         case (CONN_MIDPOINT):
           type = CONN_MIDPOINT;
           done = TRUE;
           count = 0;
-          if (conn->other_object &&
-              ((object->type == OBJ_NET &&
-                conn->other_object->type == OBJ_BUS) ||
-               (object->type == OBJ_BUS &&
-                conn->other_object->type == OBJ_NET))) {
-            bus_involved=TRUE;
-          }
           break;
       }
     }
@@ -215,7 +212,10 @@ void s_cue_output_lowlevel_midpoints(TOPLEVEL * toplevel, OBJECT * object,
   int x, y;
   GList *cl_current;
   CONN *conn;
-  int size_flag;
+  int size_flag = FALSE;
+
+  if (object->type == OBJ_BUS)
+    size_flag = TRUE;
 
   cl_current = object->conn_list;
   while (cl_current != NULL) {
@@ -227,17 +227,9 @@ void s_cue_output_lowlevel_midpoints(TOPLEVEL * toplevel, OBJECT * object,
         x = conn->x;
         y = conn->y;
 
-        if (conn->other_object &&
-          ( (object->type == OBJ_BUS &&
-             conn->other_object->type == OBJ_NET) ||
-            (object->type == OBJ_NET &&
-             conn->other_object->type == OBJ_BUS))) {
-        size_flag = TRUE;
-      } else {
-        size_flag = FALSE;
-      }
+        if (conn->other_object && conn->other_object->type == OBJ_BUS)
+          size_flag = TRUE;
 
-        
         if (output_type == POSTSCRIPT) {
           s_cue_postscript_fillcircle(toplevel, fp, x, y, size_flag);
         }




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