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

Re: gEDA-user: DRC-GUI



On Thu, 2009-04-02 at 17:47 +0100, Peter Clifton wrote:

> It is based on top of my local customisation patches, and the
> "before_pours" PCB+GL branch. The relevant patches could probably just
> be applied on top of the "before_pours" branch. (I've attached them).

I missed one.. this comes first:

From decbc6413e59abbd3be940c76561ae06682e0477 Mon Sep 17 00:00:00 2001
From: Peter Clifton <pcjc2@xxxxxxxxx>
Date: Wed, 1 Apr 2009 13:45:11 +0100
Subject: [PATCH] Allow the DRC to call GUI specific hooks

---
 src/Makefile.am              |    1 +
 src/action.c                 |    2 +
 src/find.c                   |   47 +++++++++++---
 src/gpcb-menu.res            |    1 +
 src/hid.h                    |   10 +++
 src/hid/batch/batch.c        |    3 +-
 src/hid/bom/bom.c            |    1 +
 src/hid/common/hidnogui.c    |    4 +-
 src/hid/gerber/gerber.c      |    4 +-
 src/hid/gtk/gtkhid-main.c    |   23 ++++++-
 src/hid/gtk/gui-config.c     |    2 +
 src/hid/gtk/gui-drc-window.c |  145 ++++++++++++++++++++++++++++++++++++++++++
 src/hid/gtk/gui.h            |    9 +++
 src/hid/lesstif/main.c       |    3 +-
 src/hid/lpr/lpr.c            |    3 +-
 src/hid/nelma/nelma.c        |    3 +-
 src/hid/png/png.c            |    3 +-
 src/hid/ps/eps.c             |    4 +-
 src/hid/ps/ps.c              |    3 +-
 19 files changed, 248 insertions(+), 23 deletions(-)
 create mode 100644 src/hid/gtk/gui-drc-window.c

diff --git a/src/Makefile.am b/src/Makefile.am
index 146fbb9..77e4467 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -241,6 +241,7 @@ LIBGTK_SRCS = \
 	hid/gtk/gui-dialog-print.c \
 	hid/gtk/gui-dialog-size.c \
 	hid/gtk/gui-dialog.c \
+	hid/gtk/gui-drc-window.c \
 	hid/gtk/gui-keyref-window.c \
 	hid/gtk/gui-library-window.c \
 	hid/gtk/gui-library-window.h \
diff --git a/src/action.c b/src/action.c
index 7b78fed..6e7af6f 100644
--- a/src/action.c
+++ b/src/action.c
@@ -1746,6 +1746,8 @@ ActionDRCheck (int argc, char **argv, int x, int y)
 {
   int count;
 
+  /* TODO: Override some of these messages for a GUI driven DRC ? */
+
   Message (_("Rules are minspace %d.%02d, minoverlap %d.%d "
 	     "minwidth %d.%02d, minsilk %d.%02d\n"
 	     "min drill %d.%02d, min annular ring %d.%02d\n"),
diff --git a/src/find.c b/src/find.c
index 94ace4d..748d389 100644
--- a/src/find.c
+++ b/src/find.c
@@ -157,11 +157,18 @@ RCSID ("$Id$");
 #define	IS_PV_ON_PAD(PV,Pad) \
 	( IsPointInPad((PV)->X, (PV)->Y, MAX((PV)->Thickness/2 +Bloat,0), (Pad)))
 
-static char drc_dialog_message[289];
+static char drc_dialog_message[289] = {0,};
 static void
 reset_drc_dialog_message(void)
 {
-   drc_dialog_message[0] = 0;
+  if (gui->drc_gui != NULL)
+    {
+      gui->drc_gui->reset_drc_dialog_message ();
+    }
+  else
+    {
+      drc_dialog_message[0] = 0;
+    }
 }
 #ifdef __GNUC__
 static void append_drc_dialog_message(const char *fmt, ...)
@@ -170,15 +177,26 @@ static void append_drc_dialog_message(const char *fmt, ...)
 static void
 append_drc_dialog_message(const char *fmt, ...)
 {
-  size_t len = strlen (drc_dialog_message), 
-         remained = sizeof (drc_dialog_message) - len - 1;
+  size_t len, remained;
   va_list ap;
+
   va_start (ap, fmt);
+
+  if (gui->drc_gui != NULL)
+    {
+      gui->drc_gui->append_drc_dialog_messagev (fmt, ap);
+    }
+  else
+    {
+      len = strlen (drc_dialog_message);
+      remained = sizeof (drc_dialog_message) - len - 1;
 #ifdef HAVE_VSNPRINTF
-  vsnprintf (drc_dialog_message + len, remained, fmt, ap);
+      vsnprintf (drc_dialog_message + len, remained, fmt, ap);
 #else
-  vsprintf (drc_dialog_message + len, fmt, ap);
+      vsprintf (drc_dialog_message + len, fmt, ap);
 #endif
+    }
+
   va_end (ap);
 }
 
@@ -194,9 +212,18 @@ static int
 throw_drc_dialog(void)
 {
   int r;
-  append_drc_dialog_message (DRC_CONTINUE); 
-  r = gui->confirm_dialog (drc_dialog_message, DRC_CANCEL, DRC_NEXT);
-  reset_drc_dialog_message();
+
+  if (gui->drc_gui != NULL)
+    {
+      r = gui->drc_gui->throw_drc_dialog ();
+      gui->drc_gui->reset_drc_dialog_message ();
+    }
+  else
+    {
+      append_drc_dialog_message (DRC_CONTINUE);
+      r = gui->confirm_dialog (drc_dialog_message, DRC_CANCEL, DRC_NEXT);
+      reset_drc_dialog_message();
+    }
   return r;
 }
 
@@ -3467,7 +3494,7 @@ DumpList (void)
 static Boolean
 DRCFind (int What, void *ptr1, void *ptr2, void *ptr3)
 {
-  reset_drc_dialog_message();
+//  reset_drc_dialog_message();
   if (PCB->Shrink != 0)
     {
       Bloat = -PCB->Shrink;
diff --git a/src/gpcb-menu.res b/src/gpcb-menu.res
index 5e56536..26e15e8 100644
--- a/src/gpcb-menu.res
+++ b/src/gpcb-menu.res
@@ -445,6 +445,7 @@ MainMenu =
   {Window
    {"Library" DoWindows(Library) a={"i" "<Key>i"}}
    {"Message Log" DoWindows(Log)}
+   {"DRC Check" DoWindows(DRC)}
    {"Netlist" DoWindows(Netlist)}
    {"Command Entry" Command() a={":" "<Key>:"}}
    {"Pinout" Display(Pinout) a={"Shift-D" "Shift<Key>d"}}
diff --git a/src/hid.h b/src/hid.h
index 6cceaaf..ee62369 100644
--- a/src/hid.h
+++ b/src/hid.h
@@ -229,6 +229,14 @@ typedef enum
   PCB_WATCH_HANGUP   = 1 << 3  /**< As in POLLHUP */
 } PCBWatchFlags;
 
+/* DRC GUI Hooks */
+  typedef struct
+  {
+    void (*reset_drc_dialog_message) (void);
+    void (*append_drc_dialog_messagev) (const char *fmt, va_list va);
+    int (*throw_drc_dialog) (void);
+  } HID_DRC_GUI;
+
 
 /* This is the main HID structure.  */
   typedef struct
@@ -536,6 +544,8 @@ typedef enum
        Returns nonzero if the user wishes to cancel the operation.  */
     int (*progress) (int so_far_, int total_, const char *message_);
 
+    HID_DRC_GUI *drc_gui;
+
   } HID;
 
 /* Call this as soon as possible from main().  No other HID calls are
diff --git a/src/hid/batch/batch.c b/src/hid/batch/batch.c
index 3e80139..5479b46 100644
--- a/src/hid/batch/batch.c
+++ b/src/hid/batch/batch.c
@@ -507,7 +507,8 @@ HID batch_gui = {
   batch_attribute_dialog,
   batch_show_item,
   batch_beep,
-  batch_progress
+  batch_progress,
+  0 /* batch_drc_gui */
 };
 
 #include "dolists.h"
diff --git a/src/hid/bom/bom.c b/src/hid/bom/bom.c
index 18fca46..9892269 100644
--- a/src/hid/bom/bom.c
+++ b/src/hid/bom/bom.c
@@ -587,6 +587,7 @@ HID bom_hid = {
   0,				/* bom_show_item */
   0,				/* bom_beep */
   0,				/* bom_progress */
+  0,				/* bom_drc_gui */
 };
 
 void
diff --git a/src/hid/common/hidnogui.c b/src/hid/common/hidnogui.c
index 57509dc..5c33332 100644
--- a/src/hid/common/hidnogui.c
+++ b/src/hid/common/hidnogui.c
@@ -394,7 +394,8 @@ HID hid_nogui = {
   nogui_attribute_dialog,
   nogui_show_item,
   nogui_beep,
-  nogui_progress
+  nogui_progress,
+  0 /* nogui_drc_gui */
 };
 
 #define AD(x) if (!d->x) d->x = s->x
@@ -447,4 +448,5 @@ apply_default_hid (HID * d, HID * s)
   AD (show_item);
   AD (beep);
   AD (progress);
+  AD (drc_gui);
 }
diff --git a/src/hid/gerber/gerber.c b/src/hid/gerber/gerber.c
index 0f70e2a..29f69bf 100644
--- a/src/hid/gerber/gerber.c
+++ b/src/hid/gerber/gerber.c
@@ -1129,7 +1129,9 @@ static HID gerber_hid = {
   0 /* gerber_fileselect */ ,
   0 /* gerber_attribute_dialog */ ,
   0 /* gerber_show_item */ ,
-  0				/* gerber_beep */
+  0 /* gerber_beep */ ,
+  0 /* gerber_progress */ ,
+  0 /* gerber_drc_gui */
 };
 
 void
diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index ad11ba8..bb5b3d7 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -1474,6 +1474,11 @@ ghid_progress (int so_far, int total, const char *message)
 }
 
 /* ---------------------------------------------------------------------- */
+HID_DRC_GUI ghid_drc_gui = {
+  ghid_drc_window_reset_message,
+  ghid_drc_window_append_messagev,
+  ghid_drc_window_throw_dialog
+};
 
 HID ghid_hid = {
   sizeof (HID),
@@ -1534,7 +1539,8 @@ HID ghid_hid = {
   ghid_attribute_dialog,
   ghid_show_item,
   ghid_beep,
-  ghid_progress
+  ghid_progress,
+  &ghid_drc_gui
 };
 
 HID ghid_extents = {
@@ -1595,7 +1601,8 @@ HID ghid_extents = {
   0 /* ghid_attribute_dialog */ ,
   0 /* ghid_show_item */ ,
   0 /* ghid_beep */ ,
-  0 /* ghid_progress */
+  0 /* ghid_progress */ ,
+  0 /* ghid_drc_gui */
 };
 
 /* ------------------------------------------------------------ 
@@ -2340,8 +2347,8 @@ CursorAction(int argc, char **argv, int x, int y)
 /* ------------------------------------------------------------ */
 
 static const char dowindows_syntax[] =
-"DoWindows(1|2|3|4)\n"
-"DoWindows(Layout|Library|Log|Netlist|Preferences)";
+"DoWindows(1|2|3|4|5|6)\n"
+"DoWindows(Layout|Library|Log|Netlist|Preferences|DRC)";
 
 static const char dowindows_help[] =
 "Open various GUI windows.";
@@ -2371,6 +2378,10 @@ Open the netlist window.
 @itemx Preferences
 Open the preferences window.
 
+@item 6
+@itemx DRC
+Open the DRC violations window.
+
 @end table
 
 %end-doc */
@@ -2399,6 +2410,10 @@ DoWindows (int argc, char **argv, int x, int y)
     {
       ghid_config_window_show ();
     }
+  else if (strcmp (a, "6") == 0 || strcasecmp (a, "DRC") == 0)
+    {
+      ghid_drc_window_show (TRUE);
+    }
   else
     {
       AFAIL (dowindows);
diff --git a/src/hid/gtk/gui-config.c b/src/hid/gtk/gui-config.c
index 1b50d32..23c3164 100644
--- a/src/hid/gtk/gui-config.c
+++ b/src/hid/gtk/gui-config.c
@@ -130,6 +130,8 @@ static ConfigAttribute config_attributes[] = {
   {"top-window-height", CONFIG_Integer, &_ghidgui.top_window_height},
   {"log-window-width", CONFIG_Integer, &_ghidgui.log_window_width},
   {"log-window-height", CONFIG_Integer, &_ghidgui.log_window_height},
+  {"drc-window-width", CONFIG_Integer, &_ghidgui.drc_window_width},
+  {"drc-window-height", CONFIG_Integer, &_ghidgui.drc_window_height},
   {"library-window-width", CONFIG_Integer, &_ghidgui.library_window_width},
   {"library-window-height", CONFIG_Integer, &_ghidgui.library_window_height},
   {"netlist-window-height", CONFIG_Integer, &_ghidgui.netlist_window_height},
diff --git a/src/hid/gtk/gui-drc-window.c b/src/hid/gtk/gui-drc-window.c
new file mode 100644
index 0000000..9298729
--- /dev/null
+++ b/src/hid/gtk/gui-drc-window.c
@@ -0,0 +1,145 @@
+/* $Id$ */
+
+/*
+ *                            COPYRIGHT
+ *
+ *  PCB, interactive printed circuit board design
+ *  Copyright (C) 1994,1995,1996 Thomas Nau
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *  Contact addresses for paper mail and Email:
+ *  Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
+ *  Thomas.Nau@xxxxxxxxxxxxx
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "gui.h"
+
+#ifdef HAVE_LIBDMALLOC
+#include <dmalloc.h>
+#endif
+
+RCSID ("$Id$");
+
+static GtkWidget *drc_window, *drc_list;
+
+
+/* Remember user window resizes. */
+static gint
+drc_window_configure_event_cb (GtkWidget * widget,
+			       GdkEventConfigure * ev, gpointer data)
+{
+  ghidgui->drc_window_width = widget->allocation.width;
+  ghidgui->drc_window_height = widget->allocation.height;
+  ghidgui->config_modified = TRUE;
+
+  return FALSE;
+}
+
+static void
+drc_close_cb (gpointer data)
+{
+  gtk_widget_destroy (drc_window);
+  drc_window = NULL;
+}
+
+static void
+drc_destroy_cb (GtkWidget * widget, gpointer data)
+{
+  drc_window = NULL;
+}
+
+void
+ghid_drc_window_show (gboolean raise)
+{
+  GtkWidget *vbox, *hbox, *button;
+
+  if (drc_window)
+    {
+      if (raise)
+        gtk_window_present(GTK_WINDOW(drc_window));
+      return;
+    }
+
+  drc_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  g_signal_connect (G_OBJECT (drc_window), "destroy",
+		    G_CALLBACK (drc_destroy_cb), NULL);
+  g_signal_connect (G_OBJECT (drc_window), "configure_event",
+		    G_CALLBACK (drc_window_configure_event_cb), NULL);
+  gtk_window_set_title (GTK_WINDOW (drc_window), _("PCB DRC"));
+  gtk_window_set_wmclass (GTK_WINDOW (drc_window), "PCB_DRC", "PCB");
+  gtk_window_set_default_size (GTK_WINDOW (drc_window),
+			       ghidgui->drc_window_width,
+			       ghidgui->drc_window_height);
+
+  vbox = gtk_vbox_new (FALSE, 0);
+  gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
+  gtk_container_add (GTK_CONTAINER (drc_window), vbox);
+
+  drc_list = ghid_scrolled_text_view (vbox, NULL,
+				      GTK_POLICY_AUTOMATIC,
+				      GTK_POLICY_AUTOMATIC);
+
+  hbox = gtk_hbutton_box_new ();
+  gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_END);
+  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+  button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
+  g_signal_connect (G_OBJECT (button), "clicked",
+		    G_CALLBACK (drc_close_cb), NULL);
+  gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
+
+  gtk_widget_realize (drc_window);
+  if (Settings.AutoPlace)
+    gtk_widget_set_uposition (GTK_WIDGET (drc_window), 10, 10);
+  gtk_widget_show_all (drc_window);
+}
+
+static void
+ghid_drc_append_violation (gchar * s)
+{
+  ghid_drc_window_show (FALSE);
+}
+
+void ghid_drc_window_reset_message (void)
+{
+  printf ("RESET DRC WINDOW\n");
+}
+
+#if 0
+void ghid_drc_window_append_message (const char *fmt, ...)
+{
+  va_list va;
+  va_start (va, fmt);
+  vprintf (fmt, va);
+  va_end (va);
+}
+#endif
+
+void ghid_drc_window_append_messagev (const char *fmt, va_list va)
+{
+  vprintf (fmt, va);
+}
+
+int ghid_drc_window_throw_dialog (void)
+{
+  printf ("THROW DRC WINDOW\n");
+  ghid_drc_window_show (TRUE);
+}
+
diff --git a/src/hid/gtk/gui.h b/src/hid/gtk/gui.h
index 771056b..734d923 100644
--- a/src/hid/gtk/gui.h
+++ b/src/hid/gtk/gui.h
@@ -189,6 +189,8 @@ typedef struct
     top_window_height,
     log_window_width,
     log_window_height,
+    drc_window_width,
+    drc_window_height,
     keyref_window_width,
     keyref_window_height,
     library_window_width,
@@ -402,6 +404,13 @@ void ghid_dialog_print (HID *);
 
 int ghid_attribute_dialog (HID_Attribute *, int, HID_Attr_Val *, const char *, const char *);
 
+/* gui-drc-window.c */
+void ghid_drc_window_show (gboolean raise);
+void ghid_drc_window_reset_message (void);
+//void ghid_drc_window_append_mesage (const char *fmt, ...);
+void ghid_drc_window_append_messagev (const char *fmt, va_list va);
+int ghid_drc_window_throw_dialog (void);
+
 /* gui-route-style function prototypes.
 */
   /* In gui-dialog-size.c */
diff --git a/src/hid/lesstif/main.c b/src/hid/lesstif/main.c
index d2b680b..99f9851 100644
--- a/src/hid/lesstif/main.c
+++ b/src/hid/lesstif/main.c
@@ -3928,7 +3928,8 @@ HID lesstif_gui = {
   lesstif_attribute_dialog,
   lesstif_show_item,
   lesstif_beep,
-  lesstif_progress
+  lesstif_progress,
+  0 /* lesstif_drc_gui */
 };
 
 #include "dolists.h"
diff --git a/src/hid/lpr/lpr.c b/src/hid/lpr/lpr.c
index cbf19c6..31d288e 100644
--- a/src/hid/lpr/lpr.c
+++ b/src/hid/lpr/lpr.c
@@ -163,7 +163,8 @@ HID lpr_hid = {
   0 /* lpr_attribute_dialog */ ,
   0 /* lpr_show_item */ ,
   0 /* lpr_beep */ ,
-  0 /* lpr_progress */
+  0 /* lpr_progress */ ,
+  0 /* lpr_drc_gui */
 };
 
 void
diff --git a/src/hid/nelma/nelma.c b/src/hid/nelma/nelma.c
index e548bc0..2dfe41a 100644
--- a/src/hid/nelma/nelma.c
+++ b/src/hid/nelma/nelma.c
@@ -1102,7 +1102,8 @@ HID             nelma_hid = {
 	0 /* nelma_attribute_dialog */ ,
 	0 /* nelma_show_item */ ,
 	0 /* nelma_beep */ ,
-	0			/* nelma_progress */
+	0 /* nelma_progress */ ,
+	0 /* nelma_drc_gui */
 };
 
 #include "dolists.h"
diff --git a/src/hid/png/png.c b/src/hid/png/png.c
index ae4c95f..aa9dc52 100644
--- a/src/hid/png/png.c
+++ b/src/hid/png/png.c
@@ -1376,7 +1376,8 @@ HID png_hid = {
   0 /* png_attribute_dialog */ ,
   0 /* png_show_item */ ,
   0 /* png_beep */ ,
-  0 /* png_progress */
+  0 /* png_progress */ ,
+  0 /* png_drc_gui */
 };
 
 #include "dolists.h"
diff --git a/src/hid/ps/eps.c b/src/hid/ps/eps.c
index be49202..3dc8510 100644
--- a/src/hid/ps/eps.c
+++ b/src/hid/ps/eps.c
@@ -663,7 +663,9 @@ static HID eps_hid = {
   0 /* eps_prompt_for */ ,
   0 /* eps_attribute_dialog */ ,
   0 /* eps_show_item */ ,
-  0				/* eps_beep */
+  0 /* eps_beep */ ,
+  0 /* eps_progress */ ,
+  0 /* eps_drc_gui */
 };
 
 void
diff --git a/src/hid/ps/ps.c b/src/hid/ps/ps.c
index cb96675..880b2ee 100644
--- a/src/hid/ps/ps.c
+++ b/src/hid/ps/ps.c
@@ -1203,7 +1203,8 @@ HID ps_hid = {
   0 /* ps_attribute_dialog */ ,
   0 /* ps_show_item */ ,
   0 /* ps_beep */ ,
-  0 /* ps_progress */
+  0 /* ps_progress */ ,
+  0 /* ps_drc_gui */
 };
 
 #include "dolists.h"
-- 
1.6.0.4


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