Index: trunk/src/print.c =================================================================== --- trunk/src/print.c (revision 2023) +++ trunk/src/print.c (nonexistent) @@ -1,304 +0,0 @@ -/* $Id$ */ - -/* - * COPYRIGHT - * - * PCB, interactive printed circuit board design - * Copyright (C) 1994,1995,1996, 2003 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@rz.uni-ulm.de - * - */ - -/* Change History: - * 10/11/96 11:37 AJF Added support for a Text() driver function. - * This was done out of a pressing need to force text to be printed on the - * silkscreen layer. Perhaps the design is not the best. - */ - - -/* printing routines - */ -#include "config.h" - -#include -#ifdef HAVE_UNISTD_H -#include -#endif -#include - - -#include "data.h" -#include "draw.h" -#include "drill.h" -#include "misc.h" -#include "print.h" -#include "polygon.h" - - -RCSID("$Id$"); - -/* --------------------------------------------------------------------------- - * prints a FAB drawing. - */ - -#define TEXT_SIZE MIL_TO_COORD(150) -#define TEXT_LINE MIL_TO_COORD(150) -#define DRILL_MARK_SIZE MIL_TO_COORD(16) -#define FAB_LINE_W MIL_TO_COORD(8) - -static void fab_line(hidGC gc, int x1, int y1, int x2, int y2) -{ - gui->draw_line(gc, x1, y1, x2, y2); -} - -static void fab_circle(hidGC gc, int x, int y, int r) -{ - gui->draw_arc(gc, x, y, r, r, 0, 180); - gui->draw_arc(gc, x, y, r, r, 180, 180); -} - -/* align is 0=left, 1=center, 2=right, add 8 for underline */ -static void text_at(hidGC gc, int x, int y, int align, char *fmt, ...) -{ - char tmp[512]; - int w = 0, i; - TextType t; - va_list a; - FontTypePtr font = &PCB->Font; - va_start(a, fmt); - vsprintf(tmp, fmt, a); - va_end(a); - t.Direction = 0; - t.TextString = tmp; - t.Scale = COORD_TO_MIL(TEXT_SIZE); /* pcnt of 100mil base height */ - t.Flags = NoFlags(); - t.X = x; - t.Y = y; - for (i = 0; tmp[i]; i++) - w += (font->Symbol[(int) tmp[i]].Width + font->Symbol[(int) tmp[i]].Delta); - w = SCALE_TEXT(w, t.Scale); - t.X -= w * (align & 3) / 2; - if (t.X < 0) - t.X = 0; - DrawTextLowLevel(&t, 0); - if (align & 8) - fab_line(gc, t.X, - t.Y + SCALE_TEXT(font->MaxHeight, t.Scale) + MIL_TO_COORD(10), - t.X + w, t.Y + SCALE_TEXT(font->MaxHeight, t.Scale) + MIL_TO_COORD(10)); -} - -/* Y, +, X, circle, square */ -static void drill_sym(hidGC gc, int idx, int x, int y) -{ - int type = idx % 5; - int size = idx / 5; - int s2 = (size + 1) * DRILL_MARK_SIZE; - int i; - switch (type) { - case 0: /* Y */ ; - fab_line(gc, x, y, x, y + s2); - fab_line(gc, x, y, x + s2 * 13 / 15, y - s2 / 2); - fab_line(gc, x, y, x - s2 * 13 / 15, y - s2 / 2); - for (i = 1; i <= size; i++) - fab_circle(gc, x, y, i * DRILL_MARK_SIZE); - break; - case 1: /* + */ - ; - fab_line(gc, x, y - s2, x, y + s2); - fab_line(gc, x - s2, y, x + s2, y); - for (i = 1; i <= size; i++) { - fab_line(gc, x - i * DRILL_MARK_SIZE, y - i * DRILL_MARK_SIZE, x + i * DRILL_MARK_SIZE, y - i * DRILL_MARK_SIZE); - fab_line(gc, x - i * DRILL_MARK_SIZE, y - i * DRILL_MARK_SIZE, x - i * DRILL_MARK_SIZE, y + i * DRILL_MARK_SIZE); - fab_line(gc, x - i * DRILL_MARK_SIZE, y + i * DRILL_MARK_SIZE, x + i * DRILL_MARK_SIZE, y + i * DRILL_MARK_SIZE); - fab_line(gc, x + i * DRILL_MARK_SIZE, y - i * DRILL_MARK_SIZE, x + i * DRILL_MARK_SIZE, y + i * DRILL_MARK_SIZE); - } - break; - case 2: /* X */ ; - fab_line(gc, x - s2 * 3 / 4, y - s2 * 3 / 4, x + s2 * 3 / 4, y + s2 * 3 / 4); - fab_line(gc, x - s2 * 3 / 4, y + s2 * 3 / 4, x + s2 * 3 / 4, y - s2 * 3 / 4); - for (i = 1; i <= size; i++) { - fab_line(gc, x - i * DRILL_MARK_SIZE, y - i * DRILL_MARK_SIZE, x + i * DRILL_MARK_SIZE, y - i * DRILL_MARK_SIZE); - fab_line(gc, x - i * DRILL_MARK_SIZE, y - i * DRILL_MARK_SIZE, x - i * DRILL_MARK_SIZE, y + i * DRILL_MARK_SIZE); - fab_line(gc, x - i * DRILL_MARK_SIZE, y + i * DRILL_MARK_SIZE, x + i * DRILL_MARK_SIZE, y + i * DRILL_MARK_SIZE); - fab_line(gc, x + i * DRILL_MARK_SIZE, y - i * DRILL_MARK_SIZE, x + i * DRILL_MARK_SIZE, y + i * DRILL_MARK_SIZE); - } - break; - case 3: /* circle */ ; - for (i = 0; i <= size; i++) - fab_circle(gc, x, y, (i + 1) * DRILL_MARK_SIZE - DRILL_MARK_SIZE / 2); - break; - case 4: /* square */ - for (i = 1; i <= size + 1; i++) { - fab_line(gc, x - i * DRILL_MARK_SIZE, y - i * DRILL_MARK_SIZE, x + i * DRILL_MARK_SIZE, y - i * DRILL_MARK_SIZE); - fab_line(gc, x - i * DRILL_MARK_SIZE, y - i * DRILL_MARK_SIZE, x - i * DRILL_MARK_SIZE, y + i * DRILL_MARK_SIZE); - fab_line(gc, x - i * DRILL_MARK_SIZE, y + i * DRILL_MARK_SIZE, x + i * DRILL_MARK_SIZE, y + i * DRILL_MARK_SIZE); - fab_line(gc, x + i * DRILL_MARK_SIZE, y - i * DRILL_MARK_SIZE, x + i * DRILL_MARK_SIZE, y + i * DRILL_MARK_SIZE); - } - break; - } -} - -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(hidGC gc) -{ - DrillInfoTypePtr AllDrills; - int i, n, yoff, total_drills = 0, ds = 0; - time_t currenttime; - char utcTime[64]; - AllDrills = GetDrillInfo(PCB->Data); - RoundDrillInfo(AllDrills, MIL_TO_COORD(1)); - yoff = -TEXT_LINE; - - /* 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 (ds < 4) { - yoff -= (4 - ds) * TEXT_LINE; - } - - gui->set_line_width(gc, FAB_LINE_W); - - for (n = AllDrills->DrillN - 1; n >= 0; n--) { - int plated_sym = -1, unplated_sym = -1; - DrillTypePtr drill = &(AllDrills->Drill[n]); - if (drill->PinCount + drill->ViaCount > drill->UnplatedCount) - plated_sym = --ds; - if (drill->UnplatedCount) - unplated_sym = --ds; - gui->set_color(gc, PCB->PinColor); - for (i = 0; i < drill->PinN; i++) - drill_sym(gc, TEST_FLAG(HOLEFLAG, drill->Pin[i]) ? unplated_sym : plated_sym, drill->Pin[i]->X, drill->Pin[i]->Y); - if (plated_sym != -1) { - drill_sym(gc, plated_sym, TEXT_SIZE, yoff + TEXT_SIZE / 4); - text_at(gc, MIL_TO_COORD(1350), yoff, MIL_TO_COORD(2), "YES"); - text_at(gc, MIL_TO_COORD(980), yoff, MIL_TO_COORD(2), "%d", drill->PinCount + drill->ViaCount - drill->UnplatedCount); - - if (unplated_sym != -1) - yoff -= TEXT_LINE; - } - if (unplated_sym != -1) { - drill_sym(gc, unplated_sym, TEXT_SIZE, yoff + TEXT_SIZE / 4); - text_at(gc, MIL_TO_COORD(1400), yoff, MIL_TO_COORD(2), "NO"); - text_at(gc, MIL_TO_COORD(980), yoff, MIL_TO_COORD(2), "%d", drill->UnplatedCount); - } - gui->set_color(gc, PCB->ElementColor); - text_at(gc, MIL_TO_COORD(450), yoff, MIL_TO_COORD(2), "%0.3f", COORD_TO_INCH(drill->DrillSize) + 0.0004); - if (plated_sym != -1 && unplated_sym != -1) - text_at(gc, MIL_TO_COORD(450), yoff + TEXT_LINE, MIL_TO_COORD(2), "%0.3f", COORD_TO_INCH(drill->DrillSize) + 0.0004); - yoff -= TEXT_LINE; - total_drills += drill->PinCount; - total_drills += drill->ViaCount; - } - - gui->set_color(gc, PCB->ElementColor); - text_at(gc, 0, yoff, MIL_TO_COORD(9), "Symbol"); - text_at(gc, MIL_TO_COORD(410), yoff, MIL_TO_COORD(9), "Diam. (Inch)"); - text_at(gc, MIL_TO_COORD(950), yoff, MIL_TO_COORD(9), "Count"); - text_at(gc, MIL_TO_COORD(1300), yoff, MIL_TO_COORD(9), "Plated?"); - yoff -= TEXT_LINE; - text_at(gc, 0, yoff, 0, - "There are %d different drill sizes used in this layout, %d holes total", AllDrills->DrillN, total_drills); - /* Create a portable timestamp. */ - currenttime = time(NULL); - { - /* avoid gcc complaints */ - const char *fmt = "%c UTC"; - strftime(utcTime, sizeof utcTime, fmt, gmtime(¤ttime)); - } - yoff = -TEXT_LINE; - for (i = 0; i < max_copper_layer; i++) { - LayerType *l = LAYER_PTR(i); - if (l->Name && (linelist_length(&l->Line) || arclist_length(&l->Arc))) { - if (strcmp("route", l->Name) == 0) - break; - if (strcmp("outline", l->Name) == 0) - break; - } - } - if (i == max_copper_layer) { - gui->set_line_width(gc, MIL_TO_COORD(10)); - gui->draw_line(gc, 0, 0, PCB->MaxWidth, 0); - gui->draw_line(gc, 0, 0, 0, PCB->MaxHeight); - gui->draw_line(gc, PCB->MaxWidth, 0, PCB->MaxWidth, PCB->MaxHeight); - gui->draw_line(gc, 0, PCB->MaxHeight, PCB->MaxWidth, PCB->MaxHeight); - /*FPrintOutline (); */ - gui->set_line_width(gc, FAB_LINE_W); - text_at(gc, MIL_TO_COORD(2000), yoff, 0, - "Maximum Dimensions: %f mils wide, %f mils high", COORD_TO_MIL(PCB->MaxWidth), COORD_TO_MIL(PCB->MaxHeight)); - text_at(gc, PCB->MaxWidth / 2, PCB->MaxHeight + MIL_TO_COORD(20), 1, - "Board outline is the centerline of this %f mil" - " rectangle - 0,0 to %f,%f mils", - COORD_TO_MIL(FAB_LINE_W), COORD_TO_MIL(PCB->MaxWidth), COORD_TO_MIL(PCB->MaxHeight)); - } - else { - LayerTypePtr layer = LAYER_PTR(i); - gui->set_line_width(gc, MIL_TO_COORD(10)); - LINE_LOOP(layer); - { - gui->draw_line(gc, line->Point1.X, line->Point1.Y, line->Point2.X, line->Point2.Y); - } - END_LOOP; - ARC_LOOP(layer); - { - gui->draw_arc(gc, arc->X, arc->Y, arc->Width, arc->Height, arc->StartAngle, arc->Delta); - } - END_LOOP; - TEXT_LOOP(layer); - { - DrawTextLowLevel(text, 0); - } - END_LOOP; - gui->set_line_width(gc, FAB_LINE_W); - text_at(gc, PCB->MaxWidth / 2, PCB->MaxHeight + MIL_TO_COORD(20), 1, "Board outline is the centerline of this path"); - } - yoff -= TEXT_LINE; - text_at(gc, MIL_TO_COORD(2000), yoff, 0, "Date: %s", utcTime); - yoff -= TEXT_LINE; - text_at(gc, MIL_TO_COORD(2000), yoff, 0, "Author: %s", pcb_author()); - yoff -= TEXT_LINE; - text_at(gc, MIL_TO_COORD(2000), yoff, 0, "Title: %s - Fabrication Drawing", UNKNOWN(PCB->Name)); -} Index: trunk/src/print.h =================================================================== --- trunk/src/print.h (revision 2023) +++ trunk/src/print.h (nonexistent) @@ -1,41 +0,0 @@ -/* - * 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@rz.uni-ulm.de - * - * RCS: $Id$ - */ - -/* prototypes for printing routines - */ - -#ifndef PCB_PRINT_H -#define PCB_PRINT_H - -#include - -#include "global.h" - -int PrintFab_overhang(void); -void PrintFab(hidGC gc); - -#endif Index: trunk/src/Makefile.dep =================================================================== --- trunk/src/Makefile.dep (revision 2023) +++ trunk/src/Makefile.dep (revision 2024) @@ -277,7 +277,7 @@ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h data.h global.h misc.h ../src_3rd/genvector/gds_char.h \ mymem.h error.h draw.h pcb-printf.h plugins.h hid_helper.h hid.h \ - hid_nogui.h hid_draw_helpers.h ../src_plugins/export_ps/ps.h print.h \ + hid_nogui.h hid_draw_helpers.h ../src_plugins/export_ps/ps.h draw_fab.h \ hid_init.h hid_attrib.h hid_flags.h hid_actions.h conf_core.h conf.h \ pcb-printf.h ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/dom.h \ ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/parser.h \ @@ -1607,7 +1607,7 @@ ../src_3rd/liblihata/genht/htsp.h ../src_3rd/liblihata/genht/ht.h \ ../src_3rd/liblihata/genht/ht_inlines.h ../src_3rd/genvector/vtp0.h \ list_conf.h data.h draw.h error.h misc.h mymem.h rotate.h rtree.h \ - print.h hid_helper.h + draw_fab.h hid_helper.h drill.o: drill.c ../config.h ../config.manual.h ../config.auto.h mymem.h \ global.h const.h ../globalconst.h ../config.h macro.h global_typedefs.h \ unit.h global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h \ @@ -2172,7 +2172,7 @@ ../src_3rd/liblihata/genht/ht_inlines.h ../src_3rd/genvector/vtp0.h \ list_conf.h data.h action_helper.h undo.h funchash_core.h funchash.h \ funchash_core_list.h polygon.h draw.h search.h misc_util.h crosshair.h -print.o: print.c ../config.h ../config.manual.h ../config.auto.h data.h \ +draw_fab.o: draw_fab.c ../config.h ../config.manual.h ../config.auto.h data.h \ global.h const.h ../globalconst.h ../config.h macro.h global_typedefs.h \ unit.h global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h \ list_common.h list_line.h ../src_3rd/genlist/gentdlist_impl.h \ @@ -2181,7 +2181,7 @@ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h draw.h drill.h misc.h ../src_3rd/genvector/gds_char.h \ - mymem.h print.h polygon.h + mymem.h draw_fab.h polygon.h rats.o: rats.c ../config.h ../config.manual.h ../config.auto.h \ conf_core.h ../globalconst.h ../config.h conf.h global.h const.h macro.h \ global_typedefs.h unit.h global_objs.h ../src_3rd/genlist/gendlist.h \ Index: trunk/src/Makefile.in =================================================================== --- trunk/src/Makefile.in (revision 2023) +++ trunk/src/Makefile.in (revision 2024) @@ -31,6 +31,7 @@ crosshair.o data.o draw.o + draw_fab.o drill.o error.o event.o @@ -83,7 +84,7 @@ polygon.o polygon1.o polygon_act.o - print.o + rats.o rats_act.o rats_patch.o Index: trunk/src/draw.c =================================================================== --- trunk/src/draw.c (revision 2023) +++ trunk/src/draw.c (revision 2024) @@ -39,7 +39,7 @@ #include "misc.h" #include "rotate.h" #include "rtree.h" -#include "print.h" +#include "draw_fab.h" #include "hid_helper.h" #undef NDEBUG @@ -780,7 +780,7 @@ } if (gui->set_layer("fab", SL(FAB, 0), 0)) { - PrintFab(Output.fgGC); + DrawFab(Output.fgGC); gui->end_layer(); } } Index: trunk/src/draw_fab.c =================================================================== --- trunk/src/draw_fab.c (nonexistent) +++ trunk/src/draw_fab.c (revision 2024) @@ -0,0 +1,304 @@ +/* $Id$ */ + +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 1994,1995,1996, 2003 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@rz.uni-ulm.de + * + */ + +/* Change History: + * 10/11/96 11:37 AJF Added support for a Text() driver function. + * This was done out of a pressing need to force text to be printed on the + * silkscreen layer. Perhaps the design is not the best. + */ + + +/* printing routines + */ +#include "config.h" + +#include +#ifdef HAVE_UNISTD_H +#include +#endif +#include + + +#include "data.h" +#include "draw.h" +#include "drill.h" +#include "misc.h" +#include "draw_fab.h" +#include "polygon.h" + + +RCSID("$Id$"); + +/* --------------------------------------------------------------------------- + * prints a FAB drawing. + */ + +#define TEXT_SIZE MIL_TO_COORD(150) +#define TEXT_LINE MIL_TO_COORD(150) +#define DRILL_MARK_SIZE MIL_TO_COORD(16) +#define FAB_LINE_W MIL_TO_COORD(8) + +static void fab_line(hidGC gc, int x1, int y1, int x2, int y2) +{ + gui->draw_line(gc, x1, y1, x2, y2); +} + +static void fab_circle(hidGC gc, int x, int y, int r) +{ + gui->draw_arc(gc, x, y, r, r, 0, 180); + gui->draw_arc(gc, x, y, r, r, 180, 180); +} + +/* align is 0=left, 1=center, 2=right, add 8 for underline */ +static void text_at(hidGC gc, int x, int y, int align, char *fmt, ...) +{ + char tmp[512]; + int w = 0, i; + TextType t; + va_list a; + FontTypePtr font = &PCB->Font; + va_start(a, fmt); + vsprintf(tmp, fmt, a); + va_end(a); + t.Direction = 0; + t.TextString = tmp; + t.Scale = COORD_TO_MIL(TEXT_SIZE); /* pcnt of 100mil base height */ + t.Flags = NoFlags(); + t.X = x; + t.Y = y; + for (i = 0; tmp[i]; i++) + w += (font->Symbol[(int) tmp[i]].Width + font->Symbol[(int) tmp[i]].Delta); + w = SCALE_TEXT(w, t.Scale); + t.X -= w * (align & 3) / 2; + if (t.X < 0) + t.X = 0; + DrawTextLowLevel(&t, 0); + if (align & 8) + fab_line(gc, t.X, + t.Y + SCALE_TEXT(font->MaxHeight, t.Scale) + MIL_TO_COORD(10), + t.X + w, t.Y + SCALE_TEXT(font->MaxHeight, t.Scale) + MIL_TO_COORD(10)); +} + +/* Y, +, X, circle, square */ +static void drill_sym(hidGC gc, int idx, int x, int y) +{ + int type = idx % 5; + int size = idx / 5; + int s2 = (size + 1) * DRILL_MARK_SIZE; + int i; + switch (type) { + case 0: /* Y */ ; + fab_line(gc, x, y, x, y + s2); + fab_line(gc, x, y, x + s2 * 13 / 15, y - s2 / 2); + fab_line(gc, x, y, x - s2 * 13 / 15, y - s2 / 2); + for (i = 1; i <= size; i++) + fab_circle(gc, x, y, i * DRILL_MARK_SIZE); + break; + case 1: /* + */ + ; + fab_line(gc, x, y - s2, x, y + s2); + fab_line(gc, x - s2, y, x + s2, y); + for (i = 1; i <= size; i++) { + fab_line(gc, x - i * DRILL_MARK_SIZE, y - i * DRILL_MARK_SIZE, x + i * DRILL_MARK_SIZE, y - i * DRILL_MARK_SIZE); + fab_line(gc, x - i * DRILL_MARK_SIZE, y - i * DRILL_MARK_SIZE, x - i * DRILL_MARK_SIZE, y + i * DRILL_MARK_SIZE); + fab_line(gc, x - i * DRILL_MARK_SIZE, y + i * DRILL_MARK_SIZE, x + i * DRILL_MARK_SIZE, y + i * DRILL_MARK_SIZE); + fab_line(gc, x + i * DRILL_MARK_SIZE, y - i * DRILL_MARK_SIZE, x + i * DRILL_MARK_SIZE, y + i * DRILL_MARK_SIZE); + } + break; + case 2: /* X */ ; + fab_line(gc, x - s2 * 3 / 4, y - s2 * 3 / 4, x + s2 * 3 / 4, y + s2 * 3 / 4); + fab_line(gc, x - s2 * 3 / 4, y + s2 * 3 / 4, x + s2 * 3 / 4, y - s2 * 3 / 4); + for (i = 1; i <= size; i++) { + fab_line(gc, x - i * DRILL_MARK_SIZE, y - i * DRILL_MARK_SIZE, x + i * DRILL_MARK_SIZE, y - i * DRILL_MARK_SIZE); + fab_line(gc, x - i * DRILL_MARK_SIZE, y - i * DRILL_MARK_SIZE, x - i * DRILL_MARK_SIZE, y + i * DRILL_MARK_SIZE); + fab_line(gc, x - i * DRILL_MARK_SIZE, y + i * DRILL_MARK_SIZE, x + i * DRILL_MARK_SIZE, y + i * DRILL_MARK_SIZE); + fab_line(gc, x + i * DRILL_MARK_SIZE, y - i * DRILL_MARK_SIZE, x + i * DRILL_MARK_SIZE, y + i * DRILL_MARK_SIZE); + } + break; + case 3: /* circle */ ; + for (i = 0; i <= size; i++) + fab_circle(gc, x, y, (i + 1) * DRILL_MARK_SIZE - DRILL_MARK_SIZE / 2); + break; + case 4: /* square */ + for (i = 1; i <= size + 1; i++) { + fab_line(gc, x - i * DRILL_MARK_SIZE, y - i * DRILL_MARK_SIZE, x + i * DRILL_MARK_SIZE, y - i * DRILL_MARK_SIZE); + fab_line(gc, x - i * DRILL_MARK_SIZE, y - i * DRILL_MARK_SIZE, x - i * DRILL_MARK_SIZE, y + i * DRILL_MARK_SIZE); + fab_line(gc, x - i * DRILL_MARK_SIZE, y + i * DRILL_MARK_SIZE, x + i * DRILL_MARK_SIZE, y + i * DRILL_MARK_SIZE); + fab_line(gc, x + i * DRILL_MARK_SIZE, y - i * DRILL_MARK_SIZE, x + i * DRILL_MARK_SIZE, y + i * DRILL_MARK_SIZE); + } + break; + } +} + +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 DrawFab_overhang(void) +{ + DrillInfoTypePtr AllDrills = GetDrillInfo(PCB->Data); + int ds = count_drill_lines(AllDrills); + if (ds < 4) + ds = 4; + return (ds + 2) * TEXT_LINE; +} + +void DrawFab(hidGC gc) +{ + DrillInfoTypePtr AllDrills; + int i, n, yoff, total_drills = 0, ds = 0; + time_t currenttime; + char utcTime[64]; + AllDrills = GetDrillInfo(PCB->Data); + RoundDrillInfo(AllDrills, MIL_TO_COORD(1)); + yoff = -TEXT_LINE; + + /* 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 (ds < 4) { + yoff -= (4 - ds) * TEXT_LINE; + } + + gui->set_line_width(gc, FAB_LINE_W); + + for (n = AllDrills->DrillN - 1; n >= 0; n--) { + int plated_sym = -1, unplated_sym = -1; + DrillTypePtr drill = &(AllDrills->Drill[n]); + if (drill->PinCount + drill->ViaCount > drill->UnplatedCount) + plated_sym = --ds; + if (drill->UnplatedCount) + unplated_sym = --ds; + gui->set_color(gc, PCB->PinColor); + for (i = 0; i < drill->PinN; i++) + drill_sym(gc, TEST_FLAG(HOLEFLAG, drill->Pin[i]) ? unplated_sym : plated_sym, drill->Pin[i]->X, drill->Pin[i]->Y); + if (plated_sym != -1) { + drill_sym(gc, plated_sym, TEXT_SIZE, yoff + TEXT_SIZE / 4); + text_at(gc, MIL_TO_COORD(1350), yoff, MIL_TO_COORD(2), "YES"); + text_at(gc, MIL_TO_COORD(980), yoff, MIL_TO_COORD(2), "%d", drill->PinCount + drill->ViaCount - drill->UnplatedCount); + + if (unplated_sym != -1) + yoff -= TEXT_LINE; + } + if (unplated_sym != -1) { + drill_sym(gc, unplated_sym, TEXT_SIZE, yoff + TEXT_SIZE / 4); + text_at(gc, MIL_TO_COORD(1400), yoff, MIL_TO_COORD(2), "NO"); + text_at(gc, MIL_TO_COORD(980), yoff, MIL_TO_COORD(2), "%d", drill->UnplatedCount); + } + gui->set_color(gc, PCB->ElementColor); + text_at(gc, MIL_TO_COORD(450), yoff, MIL_TO_COORD(2), "%0.3f", COORD_TO_INCH(drill->DrillSize) + 0.0004); + if (plated_sym != -1 && unplated_sym != -1) + text_at(gc, MIL_TO_COORD(450), yoff + TEXT_LINE, MIL_TO_COORD(2), "%0.3f", COORD_TO_INCH(drill->DrillSize) + 0.0004); + yoff -= TEXT_LINE; + total_drills += drill->PinCount; + total_drills += drill->ViaCount; + } + + gui->set_color(gc, PCB->ElementColor); + text_at(gc, 0, yoff, MIL_TO_COORD(9), "Symbol"); + text_at(gc, MIL_TO_COORD(410), yoff, MIL_TO_COORD(9), "Diam. (Inch)"); + text_at(gc, MIL_TO_COORD(950), yoff, MIL_TO_COORD(9), "Count"); + text_at(gc, MIL_TO_COORD(1300), yoff, MIL_TO_COORD(9), "Plated?"); + yoff -= TEXT_LINE; + text_at(gc, 0, yoff, 0, + "There are %d different drill sizes used in this layout, %d holes total", AllDrills->DrillN, total_drills); + /* Create a portable timestamp. */ + currenttime = time(NULL); + { + /* avoid gcc complaints */ + const char *fmt = "%c UTC"; + strftime(utcTime, sizeof utcTime, fmt, gmtime(¤ttime)); + } + yoff = -TEXT_LINE; + for (i = 0; i < max_copper_layer; i++) { + LayerType *l = LAYER_PTR(i); + if (l->Name && (linelist_length(&l->Line) || arclist_length(&l->Arc))) { + if (strcmp("route", l->Name) == 0) + break; + if (strcmp("outline", l->Name) == 0) + break; + } + } + if (i == max_copper_layer) { + gui->set_line_width(gc, MIL_TO_COORD(10)); + gui->draw_line(gc, 0, 0, PCB->MaxWidth, 0); + gui->draw_line(gc, 0, 0, 0, PCB->MaxHeight); + gui->draw_line(gc, PCB->MaxWidth, 0, PCB->MaxWidth, PCB->MaxHeight); + gui->draw_line(gc, 0, PCB->MaxHeight, PCB->MaxWidth, PCB->MaxHeight); + /*FPrintOutline (); */ + gui->set_line_width(gc, FAB_LINE_W); + text_at(gc, MIL_TO_COORD(2000), yoff, 0, + "Maximum Dimensions: %f mils wide, %f mils high", COORD_TO_MIL(PCB->MaxWidth), COORD_TO_MIL(PCB->MaxHeight)); + text_at(gc, PCB->MaxWidth / 2, PCB->MaxHeight + MIL_TO_COORD(20), 1, + "Board outline is the centerline of this %f mil" + " rectangle - 0,0 to %f,%f mils", + COORD_TO_MIL(FAB_LINE_W), COORD_TO_MIL(PCB->MaxWidth), COORD_TO_MIL(PCB->MaxHeight)); + } + else { + LayerTypePtr layer = LAYER_PTR(i); + gui->set_line_width(gc, MIL_TO_COORD(10)); + LINE_LOOP(layer); + { + gui->draw_line(gc, line->Point1.X, line->Point1.Y, line->Point2.X, line->Point2.Y); + } + END_LOOP; + ARC_LOOP(layer); + { + gui->draw_arc(gc, arc->X, arc->Y, arc->Width, arc->Height, arc->StartAngle, arc->Delta); + } + END_LOOP; + TEXT_LOOP(layer); + { + DrawTextLowLevel(text, 0); + } + END_LOOP; + gui->set_line_width(gc, FAB_LINE_W); + text_at(gc, PCB->MaxWidth / 2, PCB->MaxHeight + MIL_TO_COORD(20), 1, "Board outline is the centerline of this path"); + } + yoff -= TEXT_LINE; + text_at(gc, MIL_TO_COORD(2000), yoff, 0, "Date: %s", utcTime); + yoff -= TEXT_LINE; + text_at(gc, MIL_TO_COORD(2000), yoff, 0, "Author: %s", pcb_author()); + yoff -= TEXT_LINE; + text_at(gc, MIL_TO_COORD(2000), yoff, 0, "Title: %s - Fabrication Drawing", UNKNOWN(PCB->Name)); +} Index: trunk/src/draw_fab.h =================================================================== --- trunk/src/draw_fab.h (nonexistent) +++ trunk/src/draw_fab.h (revision 2024) @@ -0,0 +1,41 @@ +/* + * 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@rz.uni-ulm.de + * + * RCS: $Id$ + */ + +/* prototypes for printing routines + */ + +#ifndef PCB_PRINT_H +#define PCB_PRINT_H + +#include + +#include "global.h" + +int DrawFab_overhang(void); +void DrawFab(hidGC gc); + +#endif Index: trunk/src_plugins/export_ps/ps.c =================================================================== --- trunk/src_plugins/export_ps/ps.c (revision 2023) +++ trunk/src_plugins/export_ps/ps.c (revision 2024) @@ -22,7 +22,7 @@ #include "hid_nogui.h" #include "hid_draw_helpers.h" #include "ps.h" -#include "print.h" +#include "draw_fab.h" #include "hid_init.h" #include "hid_attrib.h" #include "hid_helper.h" @@ -900,7 +900,7 @@ * sizes, they can always ignore this sheet. */ if (SL_TYPE(idx) == SL_FAB) { Coord natural = boffset - MIL_TO_COORD(500) - PCB->MaxHeight / 2; - Coord needed = PrintFab_overhang(); + Coord needed = DrawFab_overhang(); pcb_fprintf(global.f, "%% PrintFab overhang natural %mi, needed %mi\n", natural, needed); if (needed > natural) pcb_fprintf(global.f, "0 %mi translate\n", needed - natural);