[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gEDA-dev: PCB-HID patch - subtle behavior changes



On Fri, Jul 07, 2006 at 10:02:07PM -0400, DJ Delorie wrote:
> 
> > + /* Somebody must have had a really long drill list, and hacked this in to
> > +  * keep it from falling off the edge of the paper */
> > +#if 0
> >        if (SL_TYPE (idx) == SL_FAB)
> 
> The problem is that the board might fill the page.  The right solution
> is to re-scale the page, taking into account the drill list.
> Otherwise there's always a risk that the drill list will be printed
> off-page.
> 
> The above code was a hack, but it's been there all along in the ps
> hid, because I didn't have the code to properly scale the fab drawing.

Slightly more ambitious patch dealing with PrintFab position
on a PostScript page.  When the drill list fits "naturally",
no offset is added, which makes me happy.  When the drill list
would otherwise fall off the left edge of the paper, just enough
offset is added to keep that from happening, which should make
DJ a little happier.  This does set up the hooks for rescaling,
if DJ wants to take that on.

diff --exclude=Makefile.in --exclude=CVS --exclude=aclocal.m4 --exclude=configure -ur pcb/src/hid/ps/ps.c /home/ldoolitt/src/pcb-20060707/src/hid/ps/ps.c
--- pcb/src/hid/ps/ps.c	2006-07-07 08:52:26.000000000 -0700
+++ /home/ldoolitt/src/pcb-20060707/src/hid/ps/ps.c	2006-07-09 14:40:15.000000000 -0700
@@ -399,9 +399,17 @@
       fprintf (f, "%d %d translate\n",
 	       -PCB->MaxWidth / 2, -PCB->MaxHeight / 2);
 
-      if (SL_TYPE (idx) == SL_FAB)
-	fprintf (f, "0 %d translate\n",
-		 (int) ((boffset - 0.5) * 100000) - PCB->MaxHeight / 2);
+      /* Keep the drill list from falling off the left edge of the paper,
+       * even if it means some of the board falls off the right edge.
+       * If lusers don't want to make smaller boards, or use fewer drill
+       * sizes, they can always ignore this sheet. */
+      if (SL_TYPE (idx) == SL_FAB) {
+        int natural = (int) ((boffset - 0.5) * 100000) - PCB->MaxHeight / 2;
+	int needed  = PrintFab_overhang();
+        fprintf (f, "%% PrintFab overhang natural %d, needed %d\n", natural, needed);
+	if (needed > natural)
+	  fprintf (f, "0 %d translate\n", needed - natural);
+      }
 
       if (invert)
 	{
@@ -449,10 +457,14 @@
 		 "/dh { gsave %d setlinewidth 0 gray %d 0 360 arc stroke grestore} bind def\n",
 		 MIN_PINORVIAHOLE, MIN_PINORVIAHOLE * 3 / 2);
     }
+  /* Try to outsmart ps2pdf's heuristics for page rotation, by putting
+   * text on all pages -- even if that text is blank */
   if (SL_TYPE (idx) != SL_FAB)
     fprintf (f,
 	     "gsave tx ty translate 1 -1 scale 0 0 moveto (Layer %s) show grestore newpath /ty ty ts sub def\n",
 	     name);
+  else
+    fprintf (f, "gsave tx ty translate 1 -1 scale 0 0 moveto ( ) show grestore newpath /ty ty ts sub def\n");
   return 1;
 }
 
diff --exclude=Makefile.in --exclude=CVS --exclude=aclocal.m4 --exclude=configure -ur pcb/src/print.c /home/ldoolitt/src/pcb-20060707/src/print.c
--- pcb/src/print.c	2006-06-09 20:07:41.000000000 -0700
+++ /home/ldoolitt/src/pcb-20060707/src/print.c	2006-07-09 14:48:29.000000000 -0700
@@ -181,6 +181,31 @@
     }
 }
 
+static int
+count_drill_lines(DrillInfoTypePtr AllDrills)
+{
+  int n, ds = 0;
+  for (n = AllDrills->DrillN - 1; n >= 0; n--)
+    {
+      DrillTypePtr drill = &(AllDrills->Drill[n]);
+      if (drill->PinCount + drill->ViaCount > drill->UnplatedCount)
+	ds++;
+      if (drill->UnplatedCount)
+	ds++;
+    }
+  return ds;
+}
+
+
+int
+PrintFab_overhang(void)
+{
+  DrillInfoTypePtr AllDrills = GetDrillInfo (PCB->Data);
+  int ds = count_drill_lines(AllDrills);
+  if (ds < 4) ds = 4;
+  return (ds+2) * TEXT_LINE;
+}
+
 void
 PrintFab (void)
 {
@@ -193,23 +218,18 @@
   AllDrills = GetDrillInfo (PCB->Data);
   RoundDrillInfo (AllDrills, 100);
   yoff = -TEXT_LINE;
-  for (n = AllDrills->DrillN - 1; n >= 0; n--)
-    {
-      DrillTypePtr drill = &(AllDrills->Drill[n]);
-      if (drill->PinCount + drill->ViaCount > drill->UnplatedCount)
-	ds++;
-      if (drill->UnplatedCount)
-	ds++;
-    }
+
+  /* count how many drill description lines will be needed */
+  ds = count_drill_lines(AllDrills);
 
   /*
    * When we only have a few drill sizes we need to make sure the
    * drill table header doesn't fall on top of the board info
    * section.
    */
-  if (AllDrills->DrillN < 4)
+  if (ds < 4)
     {
-      yoff -= (4 - AllDrills->DrillN) * TEXT_LINE;
+      yoff -= (4 - ds) * TEXT_LINE;
     }
 
   gui->set_line_width (Output.fgGC, FAB_LINE_W);
diff --exclude=Makefile.in --exclude=CVS --exclude=aclocal.m4 --exclude=configure -ur pcb/src/print.h /home/ldoolitt/src/pcb-20060707/src/print.h
--- pcb/src/print.h	2006-03-22 15:17:20.000000000 -0800
+++ /home/ldoolitt/src/pcb-20060707/src/print.h	2006-07-09 14:24:30.000000000 -0700
@@ -35,6 +35,7 @@
 
 #include "global.h"
 
-void PrintFab ();
+int PrintFab_overhang(void);
+void PrintFab (void);
 
 #endif


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