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

gEDA-cvs: pcb.git: branch: master updated (9e89e388015c2b9b970f3a1473c8688a662a2e58)



The branch, master has been updated
       via  9e89e388015c2b9b970f3a1473c8688a662a2e58 (commit)
      from  c9ec925b0f0c9499930cd7c3a47c3f4161346832 (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
=========

 ChangeLog        |   22 ++++++++++++++++
 configure.ac     |   54 +++++++++++++++++++++++++++++++++------
 src/Makefile.am  |   31 ++++++++++++----------
 src/gts/cdt.c    |   75 ++++++++++++++++++++---------------------------------
 src/toporouter.c |   20 +++++++++++---
 src/toporouter.h |    5 +--
 6 files changed, 131 insertions(+), 76 deletions(-)


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

commit 9e89e388015c2b9b970f3a1473c8688a662a2e58
Author: Ineiev <ineiev@xxxxxxxxx>
Commit: Anthony Blake <tonyb33@xxxxxxxxx>

    Toporouter: portability fixes
    
    1) add #include <assert.h>
    
    2) add configure options for toporouter
    --disable-toporouter switches off toporouter
    --disable-toporouter-output switches off toporouter cairo output
    
    3) make toporouter compatible with glib < 2.10.0
    provide slist_insert_sorted_with_data() for those cases
    
    4) fix VPATH builds
    gts/predicates_init stuff was not quite clean
    
    5) fix find_closest() implementation for glib < 2.4.0
    The earlier version combined with toporouter produced
    segfault on tut1.pcb (on top of glib-2.0.1 and glib-2.6.4);
    furthermore, it accessed to undocumented glib structures.

:100644 100644 4497f72... 2140da7... M	ChangeLog
:100644 100644 aed978b... 2685bd7... M	configure.ac
:100644 100644 3cdb551... ebff648... M	src/Makefile.am
:100644 100644 6c17249... 2038ab5... M	src/gts/cdt.c
:100644 100644 e806344... 8b42315... M	src/toporouter.c
:100644 100644 2b7b254... ebf1ca3... M	src/toporouter.h

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

commit 9e89e388015c2b9b970f3a1473c8688a662a2e58
Author: Ineiev <ineiev@xxxxxxxxx>
Commit: Anthony Blake <tonyb33@xxxxxxxxx>

    Toporouter: portability fixes
    
    1) add #include <assert.h>
    
    2) add configure options for toporouter
    --disable-toporouter switches off toporouter
    --disable-toporouter-output switches off toporouter cairo output
    
    3) make toporouter compatible with glib < 2.10.0
    provide slist_insert_sorted_with_data() for those cases
    
    4) fix VPATH builds
    gts/predicates_init stuff was not quite clean
    
    5) fix find_closest() implementation for glib < 2.4.0
    The earlier version combined with toporouter produced
    segfault on tut1.pcb (on top of glib-2.0.1 and glib-2.6.4);
    furthermore, it accessed to undocumented glib structures.

diff --git a/ChangeLog b/ChangeLog
index 4497f72..2140da7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2009-05-05 17:17  ineiev
+
+	* src/gts/cdt.c: fix find_closest() for glib < 2.4.0.
+
+2008-05-05 17:17  ineiev
+
+	* src/Makefile.am: fix VPATH builds
+
+2008-05-05 17:17  ineiev
+
+	* src/toporouter.c: make the code compatible with glib < 2.10.0
+
+2008-05-05 17:17  ineiev
+
+	* configure.ac, src/Makefile.am, src/toporouter.c,
+	  src/toporouter.h: add toporouter-related configure
+	  options
+
+2008-05-05 17:17  ineiev
+
+	* src/toporouter.h: add #include <assert.h>
+
 2008-11-27 22:35  danmc
 
 	* doc/actions.texi: regen.
diff --git a/configure.ac b/configure.ac
index aed978b..2685bd7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -223,6 +223,42 @@ then
     HIDLIST=
 fi
 
+AC_MSG_CHECKING([whether to enable toporouter])
+AC_ARG_ENABLE([toporouter],
+ [AS_HELP_STRING([--enable-toporouter],
+  [build toporouter [[yes]]])
+ ]
+)
+AS_CASE(["x$enable_toporouter"],[xyes | xno],,
+ [enable_toporouter=yes
+ ]
+)
+AC_MSG_RESULT([$enable_toporouter])
+AM_CONDITIONAL([WITH_TOPOROUTER], test $enable_toporouter != no)
+
+AC_MSG_CHECKING([whether to enable toporouter output])
+AC_ARG_ENABLE([toporouter-output],
+ [AS_HELP_STRING([--enable-toporouter-output],
+  [enable toporouter graphical output [[yes]]])
+ ]
+)
+AS_CASE(["z$enable_toporouter_output"],[zyes | zno],,
+ [enable_toporouter_output=yes]
+)
+AC_MSG_RESULT([$enable_toporouter_output])
+AS_CASE([$enable_toporouter_output],[yes],
+ [
+  topo_output_enabled=1
+ ],
+ [
+  topo_output_enabled=0
+ ]
+)
+AC_DEFINE_UNQUOTED([TOPO_OUTPUT_ENABLED], [$topo_output_enabled],
+ [Define to 1 to enable toporouter graphical output]
+)
+
+
 AC_MSG_CHECKING([for whether to use DBUS])
 AC_ARG_ENABLE([dbus],
 [  --enable-dbus           Enable DBUS IPC],
@@ -446,6 +482,12 @@ AC_CHECK_HEADERS(dlfcn.h)
 if test "x${WIN32}" = "xyes" ; then
 	AC_CHECK_HEADERS(windows.h)
 fi
+# Search for glib
+PKG_CHECK_MODULES(GLIB, glib-2.0, ,
+		[AC_MSG_RESULT([Note: cannot find glib-2.0.
+You may want to review the following errors:
+$GLIB_PKG_ERRORS])]
+)
 
 for e in $HIDLIST; do
     case $e in
@@ -497,12 +539,6 @@ $GTK_PKG_ERRORS])]
 		AC_CHECK_HEADERS([gdk/gdkx.h])
 	fi
 
-	# Search for glib
-	PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.4.0, , 
-		[AC_MSG_ERROR([Cannot find glib >= 2.4.0, install it and rerun ./configure.
-Please review the following errors:
-$GLIB_PKG_ERRORS])]
-	)
 	GLIB_VERSION=`$PKG_CONFIG glib-2.0 --modversion`
 	;;
 
@@ -751,8 +787,8 @@ AM_CONDITIONAL(DEBUG_BUILD, test x$enable_debug = xyes)
 
 # ------------- Complete set of CFLAGS and LIBS -------------------
 
-CFLAGS="$CFLAGS $X_CFLAGS $DBUS_CFLAGS $GTK_CFLAGS"
-LIBS="$LIBS $XM_LIBS $DBUS_LIBS $X_LIBS $GTK_LIBS $DMALLOC_LIBS $GD_LIBS $INTLLIBS"
+CFLAGS="$CFLAGS $X_CFLAGS $DBUS_CFLAGS $GLIB_CFLAGS $GTK_CFLAGS"
+LIBS="$LIBS $XM_LIBS $DBUS_LIBS $X_LIBS $GLIB_LIBS $GTK_LIBS $DMALLOC_LIBS $GD_LIBS $INTLLIBS"
 
 
 # if we have gcc then add -Wall
@@ -902,6 +938,8 @@ AC_MSG_RESULT([
    Printer:                  $with_printer
    Exporters:                $with_exporters
    Build documentation:      $docs_yesno
+   Build toporouter:         $enable_toporouter
+   Enable toporouter output: $enable_toporouter_output
    xdg data directory:       $expandedXDGDATADIR
    KDE data directory:       $expandedKDEDATADIR
    dmalloc debugging:        $with_dmalloc
diff --git a/src/Makefile.am b/src/Makefile.am
index 3cdb551..ebff648 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -132,8 +132,6 @@ PCB_SRCS = \
 	strflags.h \
 	thermal.c \
 	thermal.h \
-	toporouter.c \
-	toporouter.h \
 	undo.c \
 	undo.h \
 	vector.c \
@@ -148,9 +146,8 @@ PCB_SRCS = \
 	hid/common/draw_helpers.c \
 	hid/common/draw_helpers.h \
 	hid/hidint.h 
-pcb_SOURCES = ${PCB_SRCS} core_lists.h
 
-EXTRA_pcb_SOURCES = ${DBUS_SRCS}
+EXTRA_pcb_SOURCES = ${DBUS_SRCS} toporouter.c toporouter.h
 DBUS_SRCS= \
 	dbus-pcbmain.c \
 	dbus-pcbmain.h \
@@ -166,14 +163,24 @@ BUILT_SOURCES = \
 	hid/png/png_lists.h \
 	hid/nelma/nelma_lists.h \
 	hid/ps/ps_lists.h \
-	gts/predicates_init.h \
 	parse_y.h \
 	pcb-menu.h \
 	res_parse.h \
 	hid/common/hidlist.h
 
-pcb_LDADD = @HIDLIBS@ libgts.a
-pcb_DEPENDENCIES = @HIDLIBS@ libgts.a
+pcb_LDADD = @HIDLIBS@
+pcb_DEPENDENCIES = @HIDLIBS@
+
+if WITH_TOPOROUTER
+PCB_SRCS += toporouter.c toporouter.h
+noinst_PROGRAMS = predicates_init
+noinst_LIBRARIES += libgts.a
+pcb_LDADD += libgts.a
+pcb_DEPENDENCIES += libgts.a
+BUILT_SOURCES += gts/predicates_init.h
+endif
+
+pcb_SOURCES = ${PCB_SRCS} core_lists.h
 
 # Action, Attribute, and Flag lists.
 core_lists.h : ${PCB_SRCS} Makefile
@@ -310,15 +317,13 @@ hid/lesstif/lesstif_lists.h : ${LIBLESSTIF_SRCS} Makefile
 	(for f in ${LIBLESSTIF_SRCS} ; do cat $(srcdir)/$$f ; done) | grep "^REGISTER" > $@.tmp
 	mv $@.tmp $@
 
-gts/predicates_init: gts/predicates_init.c gts/rounding.h
-	$(COMPILE) $(srcdir)/gts/predicates_init.c -o $(srcdir)/gts/predicates_init
+predicates_init_SOURCES = gts/predicates_init.c gts/rounding.h
 
-gts/predicates_init.h: gts/predicates_init
-	./gts/predicates_init >  $(srcdir)/gts/predicates_init.h
+gts/predicates_init.h: predicates_init
+	./predicates_init >  gts/predicates_init.h
 
 libgts_a_CPPFLAGS = -I./gts
 LIBGTS_SRCS = \
-	gts/predicates_init.h \
 	gts/object.c \
 	gts/point.c \
 	gts/vertex.c \
@@ -437,8 +442,6 @@ DISTCLEANFILES= pcbtest.sh gpcb-menu.h pcb-menu.h \
 	hid/nelma/nelma_lists.h \
 	hid/ps/ps_lists.h \
 	gts/gts_lists.h \
-	gts/predicates_init.h \
-	gts/predicates_init \
 	core_lists.h \
 	dbus-introspect.h
 
diff --git a/src/gts/cdt.c b/src/gts/cdt.c
index 6c17249..2038ab5 100644
--- a/src/gts/cdt.c
+++ b/src/gts/cdt.c
@@ -79,10 +79,6 @@ static GtsFace * closest_face (GtsSurface * s, GtsPoint * p)
 
 #else /* not USE_SURFACE_BTREE */
 
-#  if GLIB_CHECK_VERSION(2,4,0)
-/* finally, with g_hash_table_find we are able to stop iteration over the hash 
-   table in the middle */
-
 typedef struct _SFindClosest SFindClosest; 
 
 struct _SFindClosest {
@@ -92,6 +88,10 @@ struct _SFindClosest {
   gint stop;
 };
 
+#  if GLIB_CHECK_VERSION(2,4,0)
+/* finally, with g_hash_table_find we are able to stop iteration over the hash
+   table in the middle */
+
 static gboolean find_closest (gpointer key, gpointer value, gpointer user_data)
 {
   SFindClosest * data = (SFindClosest *) user_data;
@@ -126,59 +126,40 @@ static GtsFace * closest_face (GtsSurface * s, GtsPoint * p)
 
 #  else /* VERSION < 2.4.0 */
 
-/* Due to an unkown reason g_hash_table_foreach does not allow to stop 
- * the loop, hence the redefinition. I hope they don't change
- * the GHashTable, GHashNode structures ... */
-typedef struct _GHashNode      GHashNode;
-
-struct _GHashNode
+static void
+find_closest (gpointer key, gpointer value, gpointer user_data)
 {
-  gpointer key;
-  gpointer value;
-  GHashNode *next;
-};
+  SFindClosest * data = (SFindClosest *) user_data;
+  GtsFace * f = GTS_FACE (value);
 
-struct _GHashTable
-{
-  gint size;
-  gint nnodes;
-  guint frozen;
-  GHashNode **nodes;
-  GHashFunc hash_func;
-  GCompareFunc key_compare_func;
-};
+  if (gts_triangle_orientation (GTS_TRIANGLE (f)) > 0.) {
+    GtsPoint * p1 = GTS_POINT (GTS_SEGMENT (GTS_TRIANGLE (f)->e1)->v1);
+    gdouble d = ((data->p->x - p1->x)*(data->p->x - p1->x) +
+		 (data->p->y - p1->y)*(data->p->y - p1->y));
+
+    if (d < data->dmin) {
+      data->dmin = d;
+      data->closest = f;
+    }
+  }
+  data->stop--;
+}
 
 /* select the face closest to @p among n^1/3 randomly picked faces
  * of @surface */
 static GtsFace * closest_face (GtsSurface * s, GtsPoint * p)
 {
-  guint i, n, nt, ns;
-  gdouble dmin = G_MAXDOUBLE;
-  GtsFace * closest = NULL;
-  GHashNode * node;
-  GHashTable * hash_table = s->faces;
+  SFindClosest fc;
 
-  nt = g_hash_table_size (hash_table);
-  if (!nt)
+  if (!g_hash_table_size (s->faces))
     return NULL;
 
-  ns = exp(log((gdouble) nt)/3.);
-  for (i = 0, n = 0; i < hash_table->size && n < ns; i++)
-    for (node = hash_table->nodes[i]; node && n < ns; node = node->next) {
-      GtsFace * f = node->key;
-
-      if (gts_triangle_orientation (GTS_TRIANGLE (f)) > 0.) {
-	GtsPoint * p1 = GTS_POINT (GTS_SEGMENT (GTS_TRIANGLE (f)->e1)->v1);
-	gdouble d = (p->x - p1->x)*(p->x - p1->x) + (p->y - p1->y)*(p->y - p1->y);
-		 
-	if (d < dmin) {
-	  dmin = d;
-	  closest = f;
-	}
-	n++;
-      }
-    }
-  return closest;
+  fc.dmin = G_MAXDOUBLE;
+  fc.closest = NULL;
+  fc.p = p;
+  fc.stop = (gint) exp (log ((gdouble) g_hash_table_size (s->faces))/3.);
+  g_hash_table_foreach (s->faces, find_closest, &fc);
+  return fc.closest;
 }
 #  endif /* VERSION < 2.4.0 */
 #endif /* not USE_SURFACE_BTREE */
diff --git a/src/toporouter.c b/src/toporouter.c
index e806344..8b42315 100644
--- a/src/toporouter.c
+++ b/src/toporouter.c
@@ -207,7 +207,7 @@ toporouter_output_init(int w, int h, char *filename)
     dc->iw = (double)PCB->MaxWidth * dc->s + (2 * MARGIN);
   }
 
-#ifdef CAIRO_H  
+#if TOPO_OUTPUT_ENABLED
   dc->surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, dc->iw, dc->ih);
   dc->cr = cairo_create (dc->surface);
   
@@ -223,7 +223,7 @@ toporouter_output_init(int w, int h, char *filename)
 void
 toporouter_output_close(drawing_context_t *dc) 
 {
-#ifdef CAIRO_H  
+#if TOPO_OUTPUT_ENABLED
   cairo_surface_write_to_png (dc->surface, dc->filename);
   cairo_destroy (dc->cr);
   cairo_surface_destroy (dc->surface);
@@ -257,7 +257,7 @@ lookup_thickness(char *name)
 gint
 toporouter_draw_vertex(gpointer item, gpointer data)
 {
-#ifdef CAIRO_H
+#if TOPO_OUTPUT_ENABLED
   drawing_context_t *dc = (drawing_context_t *) data;
   ToporouterVertex *tv;
   PinType *pin;
@@ -360,7 +360,7 @@ toporouter_draw_vertex(gpointer item, gpointer data)
 gint
 toporouter_draw_edge(gpointer item, gpointer data)
 {
-#ifdef CAIRO_H
+#if TOPO_OUTPUT_ENABLED
   drawing_context_t *dc = (drawing_context_t *) data;
   ToporouterEdge *te;
   ToporouterConstraint *tc;
@@ -428,6 +428,7 @@ toporouter_draw_edge(gpointer item, gpointer data)
 void
 toporouter_draw_surface(GtsSurface *s, char *filename, int w, int h, int mode, void *data) 
 {
+#if TOPO_OUTPUT_ENABLED
   drawing_context_t *dc;
   
   dc = toporouter_output_init(w, h, filename);
@@ -515,6 +516,7 @@ toporouter_draw_surface(GtsSurface *s, char *filename, int w, int h, int mode, v
   }
 
   toporouter_output_close(dc);
+#endif
 }
 
 toporouter_t *toporouter_new() 
@@ -3744,6 +3746,16 @@ attach_cmp(gconstpointer a, gconstpointer b)
   return 0;
 }
 
+#if !GLIB_CHECK_VERSION (2,10,0)
+/* work-around g_slist_insert_sorted_with_data() absence */
+static GSList*
+g_slist_insert_sorted_with_data (GSList *list, gpointer data,
+  GCompareDataFunc func, gpointer user_data)
+{
+  g_slist_append (list, data);
+  return g_slist_sort_with_data (list, func, user_data);
+}
+#endif /* !GLIB_CHECK_VERSION (2,10,0) */
 
 /* 
  * inserts b into a's visibility
diff --git a/src/toporouter.h b/src/toporouter.h
index 2b7b254..ebf1ca3 100644
--- a/src/toporouter.h
+++ b/src/toporouter.h
@@ -27,6 +27,7 @@
 #ifndef __TOPOROUTER_INCLUDED__
 #define __TOPOROUTER_INCLUDED__
 
+#include <assert.h>
 #include "data.h"
 #include "macro.h"
 #include "autoroute.h"
@@ -55,9 +56,7 @@
 #define TOPOROUTER_FLAG_DUMP_CDTS     (1<<1)
 #define TOPOROUTER_FLAG_DEBUG_CDTS    (1<<2)
 
-#define OUTPUT_ENABLED 
-
-#ifdef OUTPUT_ENABLED
+#if TOPO_OUTPUT_ENABLED
   #include <cairo.h>
 #endif
 




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