Hi,
First of all, sorry for the rant on geda-user. You guys are doing a
hell lot of good work for free and I do appreciate it. Despite of all
the concerns, geda _is_ a useful software, and I found the current
development version noticeably better than the version I tried one
year ago.
I played a bit with gschem today. For a newcomer like me, it has a lot
of rough edges. Fortunately, configuring it (quite) a bit, changing
keyboard mappings etc helped a lot. There are still many annoyances
that cannot be fixed by configuration, though.
I tried to improve the way nets are being routed. See the attached
patch (against v.1.3.0). It only deals with new nets (moving and
copying works as before) and currently does not take into account
device pins.
Cheers,
-r.
diff -ruN geda-gschem-1.3.0/include/gschem_struct.h geda-gschem-1.3.0ar/include/gschem_struct.h
--- geda-gschem-1.3.0/include/gschem_struct.h 2007-12-30 02:50:19.000000000 +0000
+++ geda-gschem-1.3.0ar/include/gschem_struct.h 2008-01-12 00:03:27.000000000 +0000
@@ -98,7 +98,8 @@
int inside_action; /* Are we doing an action? */
int rotated_inside; /* Was the selection rotated
inside an action? */
-
+ int directions;
+
/* --------------------- */
/* Gschem internal state */
/* --------------------- */
diff -ruN geda-gschem-1.3.0/src/o_net.c geda-gschem-1.3.0ar/src/o_net.c
--- geda-gschem-1.3.0/src/o_net.c 2007-12-30 02:50:19.000000000 +0000
+++ geda-gschem-1.3.0ar/src/o_net.c 2008-01-12 02:57:49.000000000 +0000
@@ -32,6 +32,15 @@
#include <dmalloc.h>
#endif
+#define VERT_UP 1
+#define VERT_DOWN 2
+#define VERT 3
+#define HORIZ_LEFT 4
+#define HORIZ_RIGHT 8
+#define HORIZ 12
+
+//#define NET_DEBUG 1
+
/*! \todo Finish function documentation!!!
* \brief
* \par Function Description
@@ -252,7 +261,9 @@
void o_net_start(GSCHEM_TOPLEVEL *w_current, int x, int y)
{
TOPLEVEL *toplevel = w_current->toplevel;
+ OBJECT *o_current;
int size;
+ int x1, y1, d1, d2;
/* initalize all parameters used when drawing the new net */
w_current->last_x = w_current->start_x = w_current->second_x =
@@ -260,6 +271,39 @@
w_current->last_y = w_current->start_y = w_current->second_y =
fix_y(toplevel, y);
+
+ o_current = toplevel->page_current->object_head;
+
+ SCREENtoWORLD(toplevel, w_current->start_x, w_current->start_y, &x1, &y1);
+ x1 = snap_grid(toplevel, x1);
+ y1 = snap_grid(toplevel, y1);
+
+ /* check all nets under cursor and mark invalid start directions */
+
+ w_current->directions = HORIZ | VERT;
+
+ while (o_current != NULL) {
+ if (o_current->type == OBJ_NET) {
+ if (o_net_orientation(o_current) == HORIZONTAL && o_current->line->y[0] == y1) {
+ d1 = min(o_current->line->x[0], o_current->line->x[1]);
+ d2 = max(o_current->line->x[0], o_current->line->x[1]);
+ if (x1 > d1)
+ w_current->directions &= ~HORIZ_LEFT;
+ if (x1 < d2)
+ w_current->directions &= ~HORIZ_RIGHT;
+ }
+ if (o_net_orientation(o_current) == VERTICAL && o_current->line->x[0] == x1) {
+ d1 = min(o_current->line->y[0], o_current->line->y[1]);
+ d2 = max(o_current->line->y[0], o_current->line->y[1]);
+ if (y1 > d1)
+ w_current->directions &= ~VERT_DOWN;
+ if (y1 < d2)
+ w_current->directions &= ~VERT_UP;
+ }
+ }
+ o_current = o_current->next;
+ }
+
if (toplevel->net_style == THICK ) {
size = SCREENabs(toplevel, NET_WIDTH);
gdk_gc_set_line_attributes(w_current->xor_gc, size,
@@ -521,7 +565,8 @@
int diff_x, diff_y;
int size;
int ortho;
-
+ int horiz = 0, vert = 0;
+
g_assert( w_current->inside_action != 0 );
if (toplevel->net_style == THICK) {
@@ -567,9 +612,31 @@
diff_x = abs(w_current->last_x - w_current->start_x);
diff_y = abs(w_current->last_y - w_current->start_y);
+ horiz = ((w_current->last_x > w_current->start_x) && (w_current->directions & HORIZ_RIGHT)) ||
+ ((w_current->last_x < w_current->start_x) && (w_current->directions & HORIZ_LEFT));
+ vert = ((w_current->last_y < w_current->start_y) && (w_current->directions & VERT_UP)) ||
+ ((w_current->last_y > w_current->start_y) && (w_current->directions & VERT_DOWN));
+
+ /*
+ printf ("%d %d, %d %d %d %d, %d %d\n", w_current->last_x - w_current->start_x, -w_current->last_y + w_current->start_y,
+ w_current->directions & HORIZ_LEFT, w_current->directions & HORIZ_RIGHT,
+ w_current->directions & VERT_DOWN, w_current->directions & VERT_UP,
+ horiz, vert);
+ */
+ /* if both directions are valid (or both are invalid) start with longer net */
+ if ((horiz && vert) || (!horiz && !vert))
+ horiz = diff_x > diff_y;
+
+ /* if only one net is to be drawn force the direction even if not valid */
+ if (!diff_x)
+ horiz = 0;
+ if (!diff_y)
+ horiz = 1;
+
+
/* 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 ( horiz == !w_current->SHIFTKEY ) {
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-dev mailing list
[email protected]
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev