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

gEDA-cvs: branch: master updated (1.4.0-20080127-46-gdeacf7e)



The branch, master has been updated
       via  deacf7e8bc9a67aa4ac446f8627f177e8daa249a (commit)
       via  087374bd49bdc0fcefc535fe901de55439c28a17 (commit)
       via  c377b5f84dd046dd6716d262bc6b5c883bb9f280 (commit)
      from  b4aade65f2488b4a7fd74f34a90225c0da7ec9f3 (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  |    8 ++
 gschem/src/g_rc.c              |   17 ++++
 gschem/src/g_register.c        |    1 +
 gschem/src/gschem_toplevel.c   |    2 +
 gschem/src/i_vars.c            |    2 +
 gschem/src/o_net.c             |  190 ++++++++++++++++++++++++++++++++++++----
 9 files changed, 206 insertions(+), 19 deletions(-)


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

commit deacf7e8bc9a67aa4ac446f8627f177e8daa249a
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Mon Mar 31 14:42:14 2008 +0200

    Add CTRL modifier key to mangetic net mode
    
    If magnetic net mode is active and you don't want to connect to
    the closest possible connetion, you can use the CTRL key now.
    Note: You're losing the ability to draw non-orthogonal nets in
    magnetic net mode.

:100644 100644 bba9af1... 13db241... M	gschem/src/o_net.c

commit 087374bd49bdc0fcefc535fe901de55439c28a17
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Sun Mar 9 10:14:50 2008 +0100

    make the net direction mode configurable (ON/OFF)
    
    Add all variables and callbacks to make the net direction mode
    configurable. The configuration variable is used in o_net.c.

:100644 100644 faed101... eeb2040... M	gschem/include/gschem_struct.h
:100644 100644 35037b2... 6be9935... M	gschem/include/i_vars.h
:100644 100644 68ee8bf... b320e11... M	gschem/include/prototype.h
:100644 100644 28aaf39... d35b605... M	gschem/lib/system-gschemrc.in
:100644 100644 17d52e0... 190d950... M	gschem/src/g_rc.c
:100644 100644 35209af... c836e1c... M	gschem/src/g_register.c
:100644 100644 9b0c766... 78a8070... M	gschem/src/gschem_toplevel.c
:100644 100644 90a3912... afa83c1... M	gschem/src/i_vars.c
:100644 100644 becf0dc... bba9af1... M	gschem/src/o_net.c

commit c377b5f84dd046dd6716d262bc6b5c883bb9f280
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Sun Mar 9 09:40:11 2008 +0100

    guess net direction when adding nets in gschem
    
    When drawing a L-shape net the old behavier was to draw the horizontal
    net first and the vertikal after. This patch guesses the direction
    dependant of the starting point of the net. It tries to continue nets
    and not to overwrite them.  This functionality was originally written
    by "ar" and posted to the geda-dev mailing list.

:100644 100644 f90e7af... faed101... M	gschem/include/gschem_struct.h
:100644 100644 8e55574... 68ee8bf... M	gschem/include/prototype.h
:100644 100644 4825c3b... 9b0c766... M	gschem/src/gschem_toplevel.c
:100644 100644 d28ba02... becf0dc... M	gschem/src/o_net.c

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

commit deacf7e8bc9a67aa4ac446f8627f177e8daa249a
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Mon Mar 31 14:42:14 2008 +0200

    Add CTRL modifier key to mangetic net mode
    
    If magnetic net mode is active and you don't want to connect to
    the closest possible connetion, you can use the CTRL key now.
    Note: You're losing the ability to draw non-orthogonal nets in
    magnetic net mode.

diff --git a/gschem/src/o_net.c b/gschem/src/o_net.c
index bba9af1..13db241 100644
--- a/gschem/src/o_net.c
+++ b/gschem/src/o_net.c
@@ -607,6 +607,7 @@ void o_net_finishmagnetic(GSCHEM_TOPLEVEL *w_current)
  *  \par Function Description
  *  If the mouse is moved, this function is called to update the 
  *  position of the magnetic marker.
+ *  If the controllkey is pressed the magnetic marker follows the mouse.
  */
 void o_net_start_magnetic(GSCHEM_TOPLEVEL *w_current, int x, int y)
 {
@@ -614,7 +615,13 @@ void o_net_start_magnetic(GSCHEM_TOPLEVEL *w_current, int x, int y)
   /* the dc is completely clean now, reset inside_action. */
   w_current->inside_action = 0;
 
-  o_net_find_magnetic(w_current, x, y);
+  if (w_current->CONTROLKEY) {
+    w_current->magnetic_x = x;
+    w_current->magnetic_y = y;
+  }
+  else {
+    o_net_find_magnetic(w_current, x, y);
+  }
 
   o_net_drawrubber(w_current);
 }
@@ -865,13 +872,24 @@ void o_net_rubbernet(GSCHEM_TOPLEVEL *w_current, int x, int y)
 
   g_assert( w_current->inside_action != 0 );
 
-  /* Orthognal mode enabled when Control Key is NOT pressed */
-  ortho = !w_current->CONTROLKEY;
+  /* Orthognal mode enabled when Control Key is NOT pressed or
+     if we are using magnetic mode */
+  ortho = !w_current->CONTROLKEY || w_current->magneticnet_mode;
 
   o_net_eraserubber(w_current);
 
-  if (w_current->magneticnet_mode)
-    o_net_find_magnetic(w_current, x, y);
+  if (w_current->magneticnet_mode) {
+    if (w_current->CONTROLKEY) {
+      /* set the magnetic marker position to current xy if the
+	 controlkey is pressed. Thus the net will not connect to 
+	 the closest net if we finish the net drawing */
+      w_current->magnetic_x = x;
+      w_current->magnetic_y = y;
+    }
+    else {
+      o_net_find_magnetic(w_current, x, y);
+    }
+  }
 
   w_current->last_x = fix_x(toplevel, x);
   w_current->last_y = fix_y(toplevel, y);

commit 087374bd49bdc0fcefc535fe901de55439c28a17
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Sun Mar 9 10:14:50 2008 +0100

    make the net direction mode configurable (ON/OFF)
    
    Add all variables and callbacks to make the net direction mode
    configurable. The configuration variable is used in o_net.c.

diff --git a/gschem/include/gschem_struct.h b/gschem/include/gschem_struct.h
index faed101..eeb2040 100644
--- a/gschem/include/gschem_struct.h
+++ b/gschem/include/gschem_struct.h
@@ -153,6 +153,7 @@ struct st_gschem_toplevel {
   int text_display_zoomfactor;  /* zoom factor at which text is displayed completely */
   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 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 35037b2..6be9935 100644
--- a/gschem/include/i_vars.h
+++ b/gschem/include/i_vars.h
@@ -15,6 +15,7 @@ extern int default_override_bus_color;
 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_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 68ee8bf..b320e11 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -210,6 +210,7 @@ SCM g_rc_stroke_color(SCM index, SCM color, SCM outline_color, SCM ps_color, SCM
 SCM g_rc_freestyle_color(SCM index, SCM color, SCM outline_color, SCM ps_color, SCM ir, SCM ig, SCM ib);
 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_style(SCM mode);
 SCM g_rc_bus_style(SCM mode);
 SCM g_rc_pin_style(SCM mode);
diff --git a/gschem/lib/system-gschemrc.in b/gschem/lib/system-gschemrc.in
index 28aaf39..d35b605 100644
--- a/gschem/lib/system-gschemrc.in
+++ b/gschem/lib/system-gschemrc.in
@@ -113,6 +113,14 @@
 ; Not user changable.
 (net-midpoint-mode "filled")
 
+;  net-direction-mode string
+;
+;  Controlls if the net direction mode is used. This mode tries to guess
+;  the best continuation direction of a L-shape net when adding a net.
+;
+(net-direction-mode "enabled")
+;(net-direction-mode "disabled")
+
 ;  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 17d52e0..190d950 100644
--- a/gschem/src/g_rc.c
+++ b/gschem/src/g_rc.c
@@ -302,6 +302,23 @@ SCM g_rc_net_midpoint_mode(SCM mode)
  *  \par Function Description
  *
  */
+SCM g_rc_net_direction_mode(SCM mode)
+{
+  static const vstbl_entry mode_table[] = {
+    {TRUE , "enabled" },
+    {FALSE, "disabled"}
+  };
+
+  RETURN_G_RC_MODE("net-direction-mode",
+		   default_net_direction_mode,
+		   2);
+}
+
+/*! \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 35209af..c836e1c 100644
--- a/gschem/src/g_register.c
+++ b/gschem/src/g_register.c
@@ -80,6 +80,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-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 9b0c766..78a8070 100644
--- a/gschem/src/gschem_toplevel.c
+++ b/gschem/src/gschem_toplevel.c
@@ -176,6 +176,7 @@ GSCHEM_TOPLEVEL *gschem_toplevel_new ()
   w_current->text_display_zoomfactor = 0;
   w_current->net_endpoint_mode = NONE;
   w_current->net_midpoint_mode = NONE;
+  w_current->net_direction_mode = TRUE;
   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 90a3912..afa83c1 100644
--- a/gschem/src/i_vars.c
+++ b/gschem/src/i_vars.c
@@ -46,6 +46,7 @@ int   default_override_bus_color = -1;
 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_pin_color = PIN_COLOR;
 int   default_pin_style = THICK;
 int   default_net_style = THICK;
@@ -175,6 +176,7 @@ void i_vars_set(GSCHEM_TOPLEVEL *w_current)
   toplevel->net_endpoint_color = default_net_endpoint_color;
   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;
   toplevel->override_net_color = default_override_net_color;
 
   toplevel->junction_color = default_junction_color;
diff --git a/gschem/src/o_net.c b/gschem/src/o_net.c
index becf0dc..bba9af1 100644
--- a/gschem/src/o_net.c
+++ b/gschem/src/o_net.c
@@ -639,7 +639,8 @@ void o_net_start(GSCHEM_TOPLEVEL *w_current, int x, int y)
   w_current->last_y = w_current->start_y = w_current->second_y = 
     fix_y(toplevel, y);
 
-  o_net_guess_direction(w_current, x, y);
+  if (w_current->net_direction_mode)
+    o_net_guess_direction(w_current, x, y);
 }
 
 /*! \brief finish a net drawing action 

commit c377b5f84dd046dd6716d262bc6b5c883bb9f280
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Sun Mar 9 09:40:11 2008 +0100

    guess net direction when adding nets in gschem
    
    When drawing a L-shape net the old behavier was to draw the horizontal
    net first and the vertikal after. This patch guesses the direction
    dependant of the starting point of the net. It tries to continue nets
    and not to overwrite them.  This functionality was originally written
    by "ar" and posted to the geda-dev mailing list.

diff --git a/gschem/include/gschem_struct.h b/gschem/include/gschem_struct.h
index f90e7af..faed101 100644
--- a/gschem/include/gschem_struct.h
+++ b/gschem/include/gschem_struct.h
@@ -102,6 +102,7 @@ struct st_gschem_toplevel {
   int rubbernet_visible;                /* Is the rubbernet currently on
 					   the screen? */
   int magnetic_visible;                 /* Is the magnetic marker visible */
+  int net_direction;                    /* bit field to guess the best net direction */
 
   /* --------------------- */
   /* Gschem internal state */
diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
index 8e55574..68ee8bf 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -642,6 +642,7 @@ void o_net_reset(GSCHEM_TOPLEVEL *w_current);
 void o_net_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current);
 void o_net_draw_xor(GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_current);
 void o_net_draw_xor_single(GSCHEM_TOPLEVEL *w_current, int dx, int dy, int whichone, OBJECT *o_current);
+void o_net_guess_direction(GSCHEM_TOPLEVEL *w_current, int x, int y);
 void o_net_find_magnetic(GSCHEM_TOPLEVEL *w_current, int event_x, int event_y);
 void o_net_finishmagnetic(GSCHEM_TOPLEVEL *w_current);
 void o_net_start_magnetic(GSCHEM_TOPLEVEL *w_current, int x, int y);
diff --git a/gschem/src/gschem_toplevel.c b/gschem/src/gschem_toplevel.c
index 4825c3b..9b0c766 100644
--- a/gschem/src/gschem_toplevel.c
+++ b/gschem/src/gschem_toplevel.c
@@ -126,6 +126,7 @@ GSCHEM_TOPLEVEL *gschem_toplevel_new ()
   w_current->rotated_inside = 0;
   w_current->rubbernet_visible = 0;
   w_current->magnetic_visible = 0;
+  w_current->net_direction = 0;
 
   /* --------------------- */
   /* Gschem internal state */
diff --git a/gschem/src/o_net.c b/gschem/src/o_net.c
index d28ba02..becf0dc 100644
--- a/gschem/src/o_net.c
+++ b/gschem/src/o_net.c
@@ -47,6 +47,11 @@
 #define MAGNETIC_NET_WEIGHT 2.0
 #define MAGNETIC_BUS_WEIGHT 3.0
 
+/* Bit definitions for the four quardrants of the direction guessing */
+#define QUADRANT1  0x01
+#define QUADRANT2  0x02
+#define QUADRANT3  0x04
+#define QUADRANT4  0x08
 
 
 /*! \brief Reset all variables used for net drawing
@@ -276,6 +281,132 @@ void o_net_draw_xor_single(GSCHEM_TOPLEVEL *w_current, int dx, int dy, int which
 
 }
 
+
+/*! \brief guess the best direction for the next net drawing action
+ *  \par Function Description
+ *  This function checks all connectable objects at a starting point.
+ *  It determines the best drawing direction for each quadrant of the
+ *  possible net endpoint.
+ *  
+ *  The directions are stored in the GSCHEM_TOPLEVEL->net_direction variable
+ *  as a bitfield.
+ */
+void o_net_guess_direction(GSCHEM_TOPLEVEL *w_current,
+			   int x, int y)
+{
+  TOPLEVEL *toplevel = w_current->toplevel;
+  int up=0, down=0, left=0, right=0;
+  int x1, y1, x2, y2, wx, wy;
+  int xmin, ymin, xmax, ymax;
+  int orientation;
+  GList *objectlists, *iter1, *iter2;
+  OBJECT *o_current;
+
+  int *current_rules;
+  /* badness values       {OVERWRITE, ORTHO, CONTINUE} */
+  const int pin_rules[] = {100, 50, 0};
+  const int bus_rules[] = {90, 0, 40};
+  const int net_rules[] = {80, 30, 0};
+  
+
+  SCREENtoWORLD(toplevel, x, y, &wx, &wy);
+  wx = snap_grid(toplevel, wx);
+  wy = snap_grid(toplevel, wy);
+  objectlists = s_tile_get_objectlists(toplevel, wx, wy, wx, wy);
+
+  for (iter1 = objectlists; iter1 != NULL; iter1 = g_list_next(iter1)) {
+    for (iter2 = (GList*) iter1->data; iter2 != NULL; iter2 = g_list_next(iter2)) {
+      o_current = (OBJECT*) iter2->data;
+
+      if ((orientation = o_net_orientation(o_current)) == NEITHER)
+	continue;
+
+      switch (o_current->type) {
+      case OBJ_NET:
+	current_rules = (int*) net_rules;
+	break;
+      case OBJ_PIN:
+	current_rules = (int*) pin_rules;
+	break;
+      case OBJ_BUS:
+	current_rules = (int*) bus_rules;
+	break;
+      default:
+	g_assert_not_reached ();
+      }
+      
+      x1 = o_current->line->x[0];
+      x2 = o_current->line->x[1];
+      y1 = o_current->line->y[0];
+      y2 = o_current->line->y[1];
+      
+      xmin = min(x1, x2);
+      ymin = min(y1, y2);
+      xmax = max(x1, x2);
+      ymax = max(y1, y2);
+      
+      if (orientation == HORIZONTAL && wy == y1) {
+	if (wx == xmin) {
+	  up = max(up, current_rules[1]);
+	  down = max(down, current_rules[1]);
+	  right = max(right, current_rules[0]);
+	  left = max(left, current_rules[2]);
+	}
+	else if (wx == xmax) {
+	  up = max(up, current_rules[1]);
+	  down = max(down, current_rules[1]);
+	  right = max(right, current_rules[2]);
+	  left = max(left, current_rules[0]);
+	}
+	else if (xmin < wx && wx < xmax) {
+	  up = max(up, current_rules[1]);
+	  down = max(down, current_rules[1]);
+	  right = max(right, current_rules[0]);
+	  left = max(left, current_rules[0]);
+	}
+	else {
+	  continue;
+	}
+      }
+      if (orientation == VERTICAL && wx == x1) {
+	if (wy == ymin) {
+	  up = max(up, current_rules[0]);
+	  down = max(down, current_rules[2]);
+	  right = max(right, current_rules[1]);
+	  left = max(left, current_rules[1]);
+	}
+	else if (wy == ymax) {
+	  up = max(up, current_rules[2]);
+	  down = max(down, current_rules[0]);
+	  right = max(right, current_rules[1]);
+	  left = max(left, current_rules[1]);
+	}
+	else if (ymin < wy && wy < ymax) {
+	  up = max(up, current_rules[0]);
+	  down = max(down, current_rules[0]);
+	  right = max(right, current_rules[1]);
+	  left = max(left, current_rules[1]);
+	}
+	else {
+	  continue;
+	}
+      }
+    }
+  }
+  
+  w_current->net_direction = 0;
+  w_current->net_direction |= up >= right ? 0 : QUADRANT1;
+  w_current->net_direction |= up >= left ? 0 : QUADRANT2;
+  w_current->net_direction |= down >= left ? 0 : QUADRANT3;
+  w_current->net_direction |= down >= right ? 0 : QUADRANT4;
+
+#if 0
+  printf("o_net_guess_direction: up=%d down=%d left=%d right=%d direction=%d\n",
+	 up, down, left, right, w_current->net_direction);
+#endif
+  g_list_free(objectlists);
+}
+
 /*! \brief find the closest possible location to connect to
  *  \par Function Description
  *  This function calculates the distance to all connectable objects 
@@ -508,6 +639,7 @@ void o_net_start(GSCHEM_TOPLEVEL *w_current, int x, int y)
   w_current->last_y = w_current->start_y = w_current->second_y = 
     fix_y(toplevel, y);
 
+  o_net_guess_direction(w_current, x, y);
 }
 
 /*! \brief finish a net drawing action 
@@ -728,40 +860,41 @@ int o_net_end(GSCHEM_TOPLEVEL *w_current, int x, int y)
 void o_net_rubbernet(GSCHEM_TOPLEVEL *w_current, int x, int y)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
-  int diff_x, diff_y;
-  int ortho;
+  int ortho, horizontal, quadrant;
 
   g_assert( w_current->inside_action != 0 );
 
   /* Orthognal mode enabled when Control Key is NOT pressed */
   ortho = !w_current->CONTROLKEY;
 
-  gdk_gc_set_foreground(w_current->xor_gc,
-			x_get_darkcolor(w_current->select_color));
-  
   o_net_eraserubber(w_current);
 
   if (w_current->magneticnet_mode)
     o_net_find_magnetic(w_current, x, y);
 
+  w_current->last_x = fix_x(toplevel, x);
+  w_current->last_y = fix_y(toplevel, y);
+
   /* In orthogonal mode secondary line is the same as the first */
-  if (!ortho)
-  {
+  if (!ortho) {
       w_current->second_x = w_current->last_x;
       w_current->second_y = w_current->last_y;
   }
+  /* If you press the control key then you can draw non-ortho nets */
+  else {
+    if (w_current->last_y < w_current->start_y) 
+      quadrant = w_current->last_x > w_current->start_x ? QUADRANT1: QUADRANT2;
+    else
+      quadrant = w_current->last_x > w_current->start_x ? QUADRANT4: QUADRANT3;
 
-  w_current->last_x = fix_x(toplevel, x);
-  w_current->last_y = fix_y(toplevel, y);
+    horizontal = w_current->net_direction & quadrant;
 
-  /* If you press the control key then you can draw non-ortho nets */
-  if (ortho) {
-    diff_x = abs(w_current->last_x - w_current->start_x);
-    diff_y = abs(w_current->last_y - w_current->start_y);
+    if (!w_current->SHIFTKEY)
+      horizontal = !horizontal;
 
     /* calculate the co-ordinates necessary to draw the lines*/
     /* Pressing the shift key will cause the vertical and horizontal lines to switch places */
-    if ( !w_current->SHIFTKEY ) {
+    if ( horizontal ) {
       w_current->last_y = w_current->start_y;
       w_current->second_x = w_current->last_x;
       w_current->second_y = fix_y(toplevel,y);




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