Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 4586) +++ trunk/scconfig/Rev.h (revision 4587) @@ -1 +1 @@ -static const int myrev = 4585; +static const int myrev = 4587; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 4586) +++ trunk/scconfig/Rev.tab (revision 4587) @@ -1,3 +1,4 @@ +4587 configure draw_fab moved to a plugin 4585 configure unravel - the big cleanup, moving code and files 4450 configure io_lihata plugin config and 3rd party lib dependency fix 4398 configure io_kicad plugin interdeps and enable io_kicad by default Index: trunk/scconfig/plugins.h =================================================================== --- trunk/scconfig/plugins.h (revision 4586) +++ trunk/scconfig/plugins.h (revision 4587) @@ -10,6 +10,7 @@ plugin_def("boardflip", "flip board objects", sdisable, 0) plugin_def("distalign", "distribute and align objs", sbuildin, 1) plugin_def("distaligntext", "distribute and align text", sbuildin, 1) +plugin_def("draw_fab", "fab layer in some exports", sbuildin, 1) plugin_def("jostle", "push lines out of the way", sbuildin, 1) plugin_def("polycombine", "combine selected polygons", sbuildin, 1) plugin_def("polystitch", "stitch polygon at cursor", sdisable, 0) @@ -77,3 +78,6 @@ /* for the uniq name lib: */ plugin_dep("io_kicad_legacy", "io_kicad") + +/* for drill.[ch] */ +plugin_dep("draw_fab", "report") Index: trunk/src/draw_fab.c =================================================================== --- trunk/src/draw_fab.c (revision 4586) +++ trunk/src/draw_fab.c (nonexistent) @@ -1,287 +0,0 @@ -/* - * 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 - * - */ - -/* printing routines */ -#include "config.h" - -#include - -#include "board.h" -#include "build_run.h" -#include "data.h" -#include "draw.h" -#include "drill.h" -#include "draw_fab.h" -#include "obj_all.h" - -/* --------------------------------------------------------------------------- - * prints a FAB drawing. - */ - -#define TEXT_SIZE PCB_MIL_TO_COORD(150) -#define TEXT_LINE PCB_MIL_TO_COORD(150) -#define DRILL_MARK_SIZE PCB_MIL_TO_COORD(16) -#define FAB_LINE_W PCB_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, const 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 = PCB_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 = PCB_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 + PCB_SCALE_TEXT(font->MaxHeight, t.Scale) + PCB_MIL_TO_COORD(10), - t.X + w, t.Y + PCB_SCALE_TEXT(font->MaxHeight, t.Scale) + PCB_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, PCB_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(PCB_FLAG_HOLE, 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, PCB_MIL_TO_COORD(1350), yoff, PCB_MIL_TO_COORD(2), "YES"); - text_at(gc, PCB_MIL_TO_COORD(980), yoff, PCB_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, PCB_MIL_TO_COORD(1400), yoff, PCB_MIL_TO_COORD(2), "NO"); - text_at(gc, PCB_MIL_TO_COORD(980), yoff, PCB_MIL_TO_COORD(2), "%d", drill->UnplatedCount); - } - gui->set_color(gc, PCB->ElementColor); - text_at(gc, PCB_MIL_TO_COORD(450), yoff, PCB_MIL_TO_COORD(2), "%0.3f", PCB_COORD_TO_INCH(drill->DrillSize) + 0.0004); - if (plated_sym != -1 && unplated_sym != -1) - text_at(gc, PCB_MIL_TO_COORD(450), yoff + TEXT_LINE, PCB_MIL_TO_COORD(2), "%0.3f", PCB_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, PCB_MIL_TO_COORD(9), "Symbol"); - text_at(gc, PCB_MIL_TO_COORD(410), yoff, PCB_MIL_TO_COORD(9), "Diam. (Inch)"); - text_at(gc, PCB_MIL_TO_COORD(950), yoff, PCB_MIL_TO_COORD(9), "Count"); - text_at(gc, PCB_MIL_TO_COORD(1300), yoff, PCB_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, PCB_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, PCB_MIL_TO_COORD(2000), yoff, 0, - "Maximum Dimensions: %f mils wide, %f mils high", PCB_COORD_TO_MIL(PCB->MaxWidth), PCB_COORD_TO_MIL(PCB->MaxHeight)); - text_at(gc, PCB->MaxWidth / 2, PCB->MaxHeight + PCB_MIL_TO_COORD(20), 1, - "Board outline is the centerline of this %f mil" - " rectangle - 0,0 to %f,%f mils", - PCB_COORD_TO_MIL(FAB_LINE_W), PCB_COORD_TO_MIL(PCB->MaxWidth), PCB_COORD_TO_MIL(PCB->MaxHeight)); - } - else { - LayerTypePtr layer = LAYER_PTR(i); - gui->set_line_width(gc, PCB_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 + PCB_MIL_TO_COORD(20), 1, "Board outline is the centerline of this path"); - } - yoff -= TEXT_LINE; - text_at(gc, PCB_MIL_TO_COORD(2000), yoff, 0, "Date: %s", utcTime); - yoff -= TEXT_LINE; - text_at(gc, PCB_MIL_TO_COORD(2000), yoff, 0, "Author: %s", pcb_author()); - yoff -= TEXT_LINE; - text_at(gc, PCB_MIL_TO_COORD(2000), yoff, 0, "Title: %s - Fabrication Drawing", UNKNOWN(PCB->Name)); -} Index: trunk/src/draw_fab.h =================================================================== --- trunk/src/draw_fab.h (revision 4586) +++ trunk/src/draw_fab.h (nonexistent) @@ -1,38 +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 - * - */ - -/* prototypes for printing routines */ - -#ifndef PCB_PRINT_H -#define PCB_PRINT_H - -#include "config.h" -#include "hid.h" - -int DrawFab_overhang(void); -void DrawFab(hidGC gc); - -#endif Index: trunk/src/drill.c =================================================================== --- trunk/src/drill.c (revision 4586) +++ trunk/src/drill.c (nonexistent) @@ -1,303 +0,0 @@ -/* - * COPYRIGHT - * - * PCB, interactive printed circuit board design - * Copyright (C) 1994,1995,1996 Thomas Nau - * - * This module, drill.c, was written and is Copyright (C) 1997 harry eaton - * - * 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 - * - */ -#include "config.h" - -#include "data.h" -#include "mymem.h" -#include "drill.h" -#include "macro.h" -#include "obj_pinvia.h" - -/* - * some local prototypes - */ -static void FillDrill(DrillTypePtr, ElementTypePtr, PinTypePtr); -static void InitializeDrill(DrillTypePtr, PinTypePtr, ElementTypePtr); - - -static void FillDrill(DrillTypePtr Drill, ElementTypePtr Element, PinTypePtr Pin) -{ - pcb_cardinal_t n; - ElementTypeHandle ptr; - PinTypeHandle pin; - - pin = GetDrillPinMemory(Drill); - *pin = Pin; - if (Element) { - Drill->PinCount++; - for (n = Drill->ElementN - 1; n != -1; n--) - if (Drill->Element[n] == Element) - break; - if (n == -1) { - ptr = GetDrillElementMemory(Drill); - *ptr = Element; - } - } - else - Drill->ViaCount++; - if (TEST_FLAG(PCB_FLAG_HOLE, Pin)) - Drill->UnplatedCount++; -} - -static void InitializeDrill(DrillTypePtr drill, PinTypePtr pin, ElementTypePtr element) -{ - void *ptr; - - drill->DrillSize = pin->DrillingHole; - drill->ElementN = 0; - drill->ViaCount = 0; - drill->PinCount = 0; - drill->UnplatedCount = 0; - drill->ElementMax = 0; - drill->Element = NULL; - drill->PinN = 0; - drill->Pin = NULL; - drill->PinMax = 0; - ptr = (void *) GetDrillPinMemory(drill); - *((PinTypeHandle) ptr) = pin; - if (element) { - ptr = (void *) GetDrillElementMemory(drill); - *((ElementTypeHandle) ptr) = element; - drill->PinCount = 1; - } - else - drill->ViaCount = 1; - if (TEST_FLAG(PCB_FLAG_HOLE, pin)) - drill->UnplatedCount = 1; -} - -static int DrillQSort(const void *va, const void *vb) -{ - DrillType *a = (DrillType *) va; - DrillType *b = (DrillType *) vb; - return a->DrillSize - b->DrillSize; -} - -DrillInfoTypePtr GetDrillInfo(DataTypePtr top) -{ - DrillInfoTypePtr AllDrills; - DrillTypePtr Drill = NULL; - DrillType savedrill, swapdrill; - pcb_bool DrillFound = pcb_false; - pcb_bool NewDrill; - - AllDrills = (DrillInfoTypePtr) calloc(1, sizeof(DrillInfoType)); - ALLPIN_LOOP(top); - { - if (!DrillFound) { - DrillFound = pcb_true; - Drill = GetDrillInfoDrillMemory(AllDrills); - InitializeDrill(Drill, pin, element); - } - else { - if (Drill->DrillSize == pin->DrillingHole) - FillDrill(Drill, element, pin); - else { - NewDrill = pcb_false; - DRILL_LOOP(AllDrills); - { - if (drill->DrillSize == pin->DrillingHole) { - Drill = drill; - FillDrill(Drill, element, pin); - break; - } - else if (drill->DrillSize > pin->DrillingHole) { - if (!NewDrill) { - NewDrill = pcb_true; - InitializeDrill(&swapdrill, pin, element); - Drill = GetDrillInfoDrillMemory(AllDrills); - Drill->DrillSize = pin->DrillingHole + 1; - Drill = drill; - } - savedrill = *drill; - *drill = swapdrill; - swapdrill = savedrill; - } - } - END_LOOP; - if (AllDrills->Drill[AllDrills->DrillN - 1].DrillSize < pin->DrillingHole) { - Drill = GetDrillInfoDrillMemory(AllDrills); - InitializeDrill(Drill, pin, element); - } - } - } - } - ENDALL_LOOP; - VIA_LOOP(top); - { - if (!DrillFound) { - DrillFound = pcb_true; - Drill = GetDrillInfoDrillMemory(AllDrills); - Drill->DrillSize = via->DrillingHole; - FillDrill(Drill, NULL, via); - } - else { - if (Drill->DrillSize != via->DrillingHole) { - DRILL_LOOP(AllDrills); - { - if (drill->DrillSize == via->DrillingHole) { - Drill = drill; - FillDrill(Drill, NULL, via); - break; - } - } - END_LOOP; - if (Drill->DrillSize != via->DrillingHole) { - Drill = GetDrillInfoDrillMemory(AllDrills); - Drill->DrillSize = via->DrillingHole; - FillDrill(Drill, NULL, via); - } - } - else - FillDrill(Drill, NULL, via); - } - } - END_LOOP; - qsort(AllDrills->Drill, AllDrills->DrillN, sizeof(DrillType), DrillQSort); - return (AllDrills); -} - -#define ROUND(x,n) ((int)(((x)+(n)/2)/(n))*(n)) - -void RoundDrillInfo(DrillInfoTypePtr d, int roundto) -{ - unsigned int i = 0; - - while ((d->DrillN > 0) && (i < d->DrillN - 1)) { - int diam1 = ROUND(d->Drill[i].DrillSize, roundto); - int diam2 = ROUND(d->Drill[i + 1].DrillSize, roundto); - - if (diam1 == diam2) { - int ei, ej; - - d->Drill[i].ElementMax = d->Drill[i].ElementN + d->Drill[i + 1].ElementN; - if (d->Drill[i].ElementMax) { - d->Drill[i].Element = (ElementTypePtr *) realloc(d->Drill[i].Element, d->Drill[i].ElementMax * sizeof(ElementTypePtr)); - - for (ei = 0; ei < d->Drill[i + 1].ElementN; ei++) { - for (ej = 0; ej < d->Drill[i].ElementN; ej++) - if (d->Drill[i].Element[ej] == d->Drill[i + 1].Element[ei]) - break; - if (ej == d->Drill[i].ElementN) - d->Drill[i].Element[d->Drill[i].ElementN++] - = d->Drill[i + 1].Element[ei]; - } - } - free(d->Drill[i + 1].Element); - d->Drill[i + 1].Element = NULL; - - d->Drill[i].PinMax = d->Drill[i].PinN + d->Drill[i + 1].PinN; - d->Drill[i].Pin = (PinTypePtr *) realloc(d->Drill[i].Pin, d->Drill[i].PinMax * sizeof(PinTypePtr)); - memcpy(d->Drill[i].Pin + d->Drill[i].PinN, d->Drill[i + 1].Pin, d->Drill[i + 1].PinN * sizeof(PinTypePtr)); - d->Drill[i].PinN += d->Drill[i + 1].PinN; - free(d->Drill[i + 1].Pin); - d->Drill[i + 1].Pin = NULL; - - d->Drill[i].PinCount += d->Drill[i + 1].PinCount; - d->Drill[i].ViaCount += d->Drill[i + 1].ViaCount; - d->Drill[i].UnplatedCount += d->Drill[i + 1].UnplatedCount; - - d->Drill[i].DrillSize = diam1; - - memmove(d->Drill + i + 1, d->Drill + i + 2, (d->DrillN - i - 2) * sizeof(DrillType)); - d->DrillN--; - } - else { - d->Drill[i].DrillSize = diam1; - i++; - } - } -} - -void FreeDrillInfo(DrillInfoTypePtr Drills) -{ - DRILL_LOOP(Drills); - { - free(drill->Element); - free(drill->Pin); - } - END_LOOP; - free(Drills->Drill); - free(Drills); -} - -/* --------------------------------------------------------------------------- - * get next slot for a Drill, allocates memory if necessary - */ -DrillTypePtr GetDrillInfoDrillMemory(DrillInfoTypePtr DrillInfo) -{ - DrillTypePtr drill = DrillInfo->Drill; - - /* realloc new memory if necessary and clear it */ - if (DrillInfo->DrillN >= DrillInfo->DrillMax) { - DrillInfo->DrillMax += STEP_DRILL; - drill = (DrillTypePtr) realloc(drill, DrillInfo->DrillMax * sizeof(DrillType)); - DrillInfo->Drill = drill; - memset(drill + DrillInfo->DrillN, 0, STEP_DRILL * sizeof(DrillType)); - } - return (drill + DrillInfo->DrillN++); -} - -/* --------------------------------------------------------------------------- - * get next slot for a DrillPoint, allocates memory if necessary - */ -PinTypeHandle GetDrillPinMemory(DrillTypePtr Drill) -{ - PinTypePtr *pin; - - pin = Drill->Pin; - - /* realloc new memory if necessary and clear it */ - if (Drill->PinN >= Drill->PinMax) { - Drill->PinMax += STEP_POINT; - pin = (PinTypePtr *) realloc(pin, Drill->PinMax * sizeof(PinTypeHandle)); - Drill->Pin = pin; - memset(pin + Drill->PinN, 0, STEP_POINT * sizeof(PinTypeHandle)); - } - return (pin + Drill->PinN++); -} - -/* --------------------------------------------------------------------------- - * get next slot for a DrillElement, allocates memory if necessary - */ -ElementTypeHandle GetDrillElementMemory(DrillTypePtr Drill) -{ - ElementTypePtr *element; - - element = Drill->Element; - - /* realloc new memory if necessary and clear it */ - if (Drill->ElementN >= Drill->ElementMax) { - Drill->ElementMax += STEP_ELEMENT; - element = (ElementTypePtr *) realloc(element, Drill->ElementMax * sizeof(ElementTypeHandle)); - Drill->Element = element; - memset(element + Drill->ElementN, 0, STEP_ELEMENT * sizeof(ElementTypeHandle)); - } - return (element + Drill->ElementN++); -} - Index: trunk/src/drill.h =================================================================== --- trunk/src/drill.h (revision 4586) +++ trunk/src/drill.h (nonexistent) @@ -1,57 +0,0 @@ -/* - * COPYRIGHT - * - * PCB, interactive printed circuit board design - * Copyright (C) 1994,1995,1996 Thomas Nau - * - * This module, drill.h, was written and is Copyright (C) 1997 harry eaton - * - * 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 - * - */ -#ifndef PCB_DRILL_H -#define PCB_DRILL_H - -typedef struct { /* holds drill information */ - Coord DrillSize; /* this drill's diameter */ - pcb_cardinal_t ElementN, /* the number of elements using this drill size */ - ElementMax, /* max number of elements from malloc() */ - PinCount, /* number of pins drilled this size */ - ViaCount, /* number of vias drilled this size */ - UnplatedCount, /* number of these holes that are unplated */ - PinN, /* number of drill coordinates in the list */ - PinMax; /* max number of coordinates from malloc() */ - PinTypePtr *Pin; /* coordinates to drill */ - ElementTypePtr *Element; /* a pointer to an array of element pointers */ -} DrillType, *DrillTypePtr; - -typedef struct { /* holds a range of Drill Infos */ - pcb_cardinal_t DrillN, /* number of drill sizes */ - DrillMax; /* max number from malloc() */ - DrillTypePtr Drill; /* plated holes */ -} DrillInfoType, *DrillInfoTypePtr; - -DrillInfoTypePtr GetDrillInfo(DataTypePtr); -void FreeDrillInfo(DrillInfoTypePtr); -void RoundDrillInfo(DrillInfoTypePtr, int); -DrillTypePtr GetDrillInfoDrillMemory(DrillInfoTypePtr); -PinTypeHandle GetDrillPinMemory(DrillTypePtr); -ElementTypeHandle GetDrillElementMemory(DrillTypePtr); - -#endif Index: trunk/src/Makefile.dep =================================================================== --- trunk/src/Makefile.dep (revision 4586) +++ trunk/src/Makefile.dep (revision 4587) @@ -546,7 +546,7 @@ rubberband.h hid.h error.h drc.h buffer.h misc.h mymem.h layer.h error.h \ draw.h pcb-printf.h ../src_3rd/genvector/gds_char.h plugins.h \ hid_helper.h hid.h hid_nogui.h hid_draw_helpers.h \ - ../src_plugins/export_ps/ps.h draw_fab.h hid_init.h hid_attrib.h \ + ../src_plugins/export_ps/ps.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 \ @@ -2429,7 +2429,7 @@ ../src_3rd/liblihata/genht/hash.h obj_line_list.h obj_pad_list.h \ obj_pad.h obj_pinvia_list.h obj_pinvia.h obj_poly_list.h obj_text_list.h \ obj_text.h obj_rat_list.h obj_rat.h library.h rats_patch.h board.h \ - data.h global_element.h crosshair.h buffer.h drill.h error.h search.h \ + data.h global_element.h crosshair.h buffer.h error.h search.h \ rats.h netlist.h route_style.h misc_util.h misc.h mymem.h mymem.h rats.h \ rtree.h flag_str.h macro.h undo.h find.h draw.h pcb-printf.h plugins.h \ action_helper.h hid_actions.h misc_util.h \ @@ -2969,7 +2969,7 @@ obj_text_list.h obj_text.h obj_rat_list.h obj_rat.h library.h \ rats_patch.h vtonpoint.h data.h global_element.h crosshair.h \ rubberband.h hid.h error.h drc.h buffer.h draw.h misc.h mymem.h rotate.h \ - rtree.h draw_fab.h obj_all.h obj_poly.h + rtree.h obj_all.h obj_poly.h draw_fab.o: draw_fab.c ../config.h board.h const.h macro.h \ global_typedefs.h pcb_bool.h unit.h vtroutestyle.h \ ../src_3rd/genvector/genvector_impl.h \ @@ -2984,7 +2984,7 @@ obj_pad_list.h obj_pad.h obj_pinvia_list.h obj_pinvia.h obj_poly_list.h \ obj_text_list.h obj_text.h obj_rat_list.h obj_rat.h library.h \ rats_patch.h vtonpoint.h build_run.h data.h global_element.h crosshair.h \ - rubberband.h hid.h error.h drc.h buffer.h draw.h drill.h draw_fab.h \ + rubberband.h hid.h error.h drc.h buffer.h draw.h \ obj_all.h obj_poly.h drill.o: drill.c ../config.h data.h globalconst.h global_typedefs.h \ pcb_bool.h unit.h global_objs.h ../src_3rd/genlist/gendlist.h attrib.h \ @@ -2998,7 +2998,7 @@ obj_text_list.h obj_text.h obj_rat_list.h obj_rat.h layer.h crosshair.h \ rubberband.h vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h error.h drc.h buffer.h \ - mymem.h drill.h macro.h + mymem.h macro.h error.o: error.c ../config.h data.h globalconst.h global_typedefs.h \ pcb_bool.h unit.h global_objs.h ../src_3rd/genlist/gendlist.h attrib.h \ flag.h polyarea.h global_element.h obj_all_list.h obj_arc_list.h \ Index: trunk/src/Makefile.in =================================================================== --- trunk/src/Makefile.in (revision 4586) +++ trunk/src/Makefile.in (revision 4587) @@ -41,8 +41,6 @@ crosshair.o data.o draw.o - draw_fab.o - drill.o error.o event.o file_act.o @@ -124,6 +122,7 @@ select.o select_act.o set.o + stub_draw_fab.o stub_mincut.o stub_stroke.o stub_vendor.o Index: trunk/src/draw.c =================================================================== --- trunk/src/draw.c (revision 4586) +++ trunk/src/draw.c (revision 4587) @@ -38,7 +38,7 @@ #include "misc.h" #include "rotate.h" #include "rtree.h" -#include "draw_fab.h" +#include "stub_draw_fab.h" #include "obj_all.h" #undef NDEBUG @@ -789,7 +789,7 @@ } if (gui->set_layer("fab", SL(FAB, 0), 0)) { - DrawFab(Output.fgGC); + stub_DrawFab(Output.fgGC); gui->end_layer(); } } Index: trunk/src/macro.h =================================================================== --- trunk/src/macro.h (revision 4586) +++ trunk/src/macro.h (revision 4587) @@ -76,13 +76,6 @@ */ #define END_LOOP }} while (0) -#define DRILL_LOOP(top) do { \ - pcb_cardinal_t n; \ - DrillTypePtr drill; \ - for (n = 0; (top)->DrillN > 0 && n < (top)->DrillN; n++) \ - { \ - drill = &(top)->Drill[n] - #define ENDALL_LOOP }} while (0); }} while(0) #endif Index: trunk/src/stub_draw_fab.c =================================================================== --- trunk/src/stub_draw_fab.c (nonexistent) +++ trunk/src/stub_draw_fab.c (revision 4587) @@ -0,0 +1,40 @@ +/* + * 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 + * + */ +#include "config.h" +#include "stub_draw_fab.h" + +int dummy_DrawFab_overhang(void) +{ + return 0; +} + +void dummy_DrawFab(hidGC gc) +{ +} + +int (*stub_DrawFab_overhang)(void) = dummy_DrawFab_overhang; +void (*stub_DrawFab)(hidGC gc) = dummy_DrawFab; + Index: trunk/src/stub_draw_fab.h =================================================================== --- trunk/src/stub_draw_fab.h (nonexistent) +++ trunk/src/stub_draw_fab.h (revision 4587) @@ -0,0 +1,37 @@ +/* + * 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 + * + */ + +/* drawing the fab layer is a plugin now */ + +#ifndef PCB_STUB_DRAW_FAB_H +#define PCB_STUB_DRAW_FAB_H + +#include "hid.h" + +extern int (*stub_DrawFab_overhang)(void); +extern void (*stub_DrawFab)(hidGC gc); + +#endif Index: trunk/src_plugins/draw_fab/Makefile =================================================================== --- trunk/src_plugins/draw_fab/Makefile (nonexistent) +++ trunk/src_plugins/draw_fab/Makefile (revision 4587) @@ -0,0 +1,6 @@ +all: + cd ../../src && make mod_draw_fab + +clean: + rm *.o *.so 2>/dev/null ; true + Index: trunk/src_plugins/draw_fab/Plug.tmpasm =================================================================== --- trunk/src_plugins/draw_fab/Plug.tmpasm (nonexistent) +++ trunk/src_plugins/draw_fab/Plug.tmpasm (revision 4587) @@ -0,0 +1,10 @@ +put /local/pcb/mod {draw_fab} +append /local/pcb/mod/OBJS [@ + $(PLUGDIR)/draw_fab/draw_fab.o +@] + +switch /local/pcb/draw_fab/controls + case {buildin} include /local/pcb/tmpasm/buildin; end; + case {plugin} include /local/pcb/tmpasm/plugin; end; + case {disable} include /local/pcb/tmpasm/disable; end; +end Index: trunk/src_plugins/draw_fab/README =================================================================== --- trunk/src_plugins/draw_fab/README (nonexistent) +++ trunk/src_plugins/draw_fab/README (revision 4587) @@ -0,0 +1,5 @@ +Draw the fab layer (for various exporters). + +#state: works +#default: buildin +#implements: (feature) Index: trunk/src_plugins/draw_fab/draw_fab.c =================================================================== --- trunk/src_plugins/draw_fab/draw_fab.c (nonexistent) +++ trunk/src_plugins/draw_fab/draw_fab.c (revision 4587) @@ -0,0 +1,299 @@ +/* + * 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 + * + */ + +/* printing routines */ +#include "config.h" + +#include + +#include "board.h" +#include "build_run.h" +#include "data.h" +#include "draw.h" +#include "../report/drill.h" +#include "obj_all.h" +#include "plugins.h" +#include "stub_draw_fab.h" + +/* --------------------------------------------------------------------------- + * prints a FAB drawing. + */ + +#define TEXT_SIZE PCB_MIL_TO_COORD(150) +#define TEXT_LINE PCB_MIL_TO_COORD(150) +#define DRILL_MARK_SIZE PCB_MIL_TO_COORD(16) +#define FAB_LINE_W PCB_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, const 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 = PCB_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 = PCB_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 + PCB_SCALE_TEXT(font->MaxHeight, t.Scale) + PCB_MIL_TO_COORD(10), + t.X + w, t.Y + PCB_SCALE_TEXT(font->MaxHeight, t.Scale) + PCB_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; +} + + +static 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; +} + +static 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, PCB_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(PCB_FLAG_HOLE, 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, PCB_MIL_TO_COORD(1350), yoff, PCB_MIL_TO_COORD(2), "YES"); + text_at(gc, PCB_MIL_TO_COORD(980), yoff, PCB_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, PCB_MIL_TO_COORD(1400), yoff, PCB_MIL_TO_COORD(2), "NO"); + text_at(gc, PCB_MIL_TO_COORD(980), yoff, PCB_MIL_TO_COORD(2), "%d", drill->UnplatedCount); + } + gui->set_color(gc, PCB->ElementColor); + text_at(gc, PCB_MIL_TO_COORD(450), yoff, PCB_MIL_TO_COORD(2), "%0.3f", PCB_COORD_TO_INCH(drill->DrillSize) + 0.0004); + if (plated_sym != -1 && unplated_sym != -1) + text_at(gc, PCB_MIL_TO_COORD(450), yoff + TEXT_LINE, PCB_MIL_TO_COORD(2), "%0.3f", PCB_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, PCB_MIL_TO_COORD(9), "Symbol"); + text_at(gc, PCB_MIL_TO_COORD(410), yoff, PCB_MIL_TO_COORD(9), "Diam. (Inch)"); + text_at(gc, PCB_MIL_TO_COORD(950), yoff, PCB_MIL_TO_COORD(9), "Count"); + text_at(gc, PCB_MIL_TO_COORD(1300), yoff, PCB_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, PCB_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, PCB_MIL_TO_COORD(2000), yoff, 0, + "Maximum Dimensions: %f mils wide, %f mils high", PCB_COORD_TO_MIL(PCB->MaxWidth), PCB_COORD_TO_MIL(PCB->MaxHeight)); + text_at(gc, PCB->MaxWidth / 2, PCB->MaxHeight + PCB_MIL_TO_COORD(20), 1, + "Board outline is the centerline of this %f mil" + " rectangle - 0,0 to %f,%f mils", + PCB_COORD_TO_MIL(FAB_LINE_W), PCB_COORD_TO_MIL(PCB->MaxWidth), PCB_COORD_TO_MIL(PCB->MaxHeight)); + } + else { + LayerTypePtr layer = LAYER_PTR(i); + gui->set_line_width(gc, PCB_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 + PCB_MIL_TO_COORD(20), 1, "Board outline is the centerline of this path"); + } + yoff -= TEXT_LINE; + text_at(gc, PCB_MIL_TO_COORD(2000), yoff, 0, "Date: %s", utcTime); + yoff -= TEXT_LINE; + text_at(gc, PCB_MIL_TO_COORD(2000), yoff, 0, "Author: %s", pcb_author()); + yoff -= TEXT_LINE; + text_at(gc, PCB_MIL_TO_COORD(2000), yoff, 0, "Title: %s - Fabrication Drawing", UNKNOWN(PCB->Name)); +} + +static void hid_draw_fab_uninit(void) +{ +} + +pcb_uninit_t hid_draw_fab_init(void) +{ + stub_DrawFab = DrawFab; + stub_DrawFab_overhang = DrawFab_overhang; + return hid_draw_fab_uninit; +} Index: trunk/src_plugins/export_ps/ps.c =================================================================== --- trunk/src_plugins/export_ps/ps.c (revision 4586) +++ trunk/src_plugins/export_ps/ps.c (revision 4587) @@ -26,7 +26,6 @@ #include "hid_nogui.h" #include "hid_draw_helpers.h" #include "ps.h" -#include "draw_fab.h" #include "hid_init.h" #include "hid_attrib.h" #include "hid_flags.h" @@ -34,6 +33,7 @@ #include "conf_core.h" #include "compat_misc.h" #include "compat_nls.h" +#include "stub_draw_fab.h" const char *ps_cookie = "ps HID"; @@ -900,7 +900,7 @@ * sizes, they can always ignore this sheet. */ if (SL_TYPE(idx) == SL_FAB) { Coord natural = boffset - PCB_MIL_TO_COORD(500) - PCB->MaxHeight / 2; - Coord needed = DrawFab_overhang(); + Coord needed = stub_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); Index: trunk/src_plugins/plugins_feature.tmpasm =================================================================== --- trunk/src_plugins/plugins_feature.tmpasm (revision 4586) +++ trunk/src_plugins/plugins_feature.tmpasm (revision 4587) @@ -9,6 +9,7 @@ include {../src_plugins/boardflip/Plug.tmpasm} include {../src_plugins/distalign/Plug.tmpasm} include {../src_plugins/distaligntext/Plug.tmpasm} +include {../src_plugins/draw_fab/Plug.tmpasm} include {../src_plugins/jostle/Plug.tmpasm} include {../src_plugins/polycombine/Plug.tmpasm} include {../src_plugins/polystitch/Plug.tmpasm} Index: trunk/src_plugins/report/Plug.tmpasm =================================================================== --- trunk/src_plugins/report/Plug.tmpasm (revision 4586) +++ trunk/src_plugins/report/Plug.tmpasm (revision 4587) @@ -1,5 +1,8 @@ put /local/pcb/mod {report} -put /local/pcb/mod/OBJS [@ $(PLUGDIR)/report/report.o @] +put /local/pcb/mod/OBJS [@ + $(PLUGDIR)/report/report.o + $(PLUGDIR)/report/drill.o +@] put /local/pcb/mod/CONF {$(PLUGDIR)/report/report_conf.h} switch /local/pcb/report/controls Index: trunk/src_plugins/report/drill.c =================================================================== --- trunk/src_plugins/report/drill.c (nonexistent) +++ trunk/src_plugins/report/drill.c (revision 4587) @@ -0,0 +1,303 @@ +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * + * This module, drill.c, was written and is Copyright (C) 1997 harry eaton + * + * 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 + * + */ +#include "config.h" + +#include "data.h" +#include "mymem.h" +#include "drill.h" +#include "macro.h" +#include "obj_pinvia.h" + +/* + * some local prototypes + */ +static void FillDrill(DrillTypePtr, ElementTypePtr, PinTypePtr); +static void InitializeDrill(DrillTypePtr, PinTypePtr, ElementTypePtr); + + +static void FillDrill(DrillTypePtr Drill, ElementTypePtr Element, PinTypePtr Pin) +{ + pcb_cardinal_t n; + ElementTypeHandle ptr; + PinTypeHandle pin; + + pin = GetDrillPinMemory(Drill); + *pin = Pin; + if (Element) { + Drill->PinCount++; + for (n = Drill->ElementN - 1; n != -1; n--) + if (Drill->Element[n] == Element) + break; + if (n == -1) { + ptr = GetDrillElementMemory(Drill); + *ptr = Element; + } + } + else + Drill->ViaCount++; + if (TEST_FLAG(PCB_FLAG_HOLE, Pin)) + Drill->UnplatedCount++; +} + +static void InitializeDrill(DrillTypePtr drill, PinTypePtr pin, ElementTypePtr element) +{ + void *ptr; + + drill->DrillSize = pin->DrillingHole; + drill->ElementN = 0; + drill->ViaCount = 0; + drill->PinCount = 0; + drill->UnplatedCount = 0; + drill->ElementMax = 0; + drill->Element = NULL; + drill->PinN = 0; + drill->Pin = NULL; + drill->PinMax = 0; + ptr = (void *) GetDrillPinMemory(drill); + *((PinTypeHandle) ptr) = pin; + if (element) { + ptr = (void *) GetDrillElementMemory(drill); + *((ElementTypeHandle) ptr) = element; + drill->PinCount = 1; + } + else + drill->ViaCount = 1; + if (TEST_FLAG(PCB_FLAG_HOLE, pin)) + drill->UnplatedCount = 1; +} + +static int DrillQSort(const void *va, const void *vb) +{ + DrillType *a = (DrillType *) va; + DrillType *b = (DrillType *) vb; + return a->DrillSize - b->DrillSize; +} + +DrillInfoTypePtr GetDrillInfo(DataTypePtr top) +{ + DrillInfoTypePtr AllDrills; + DrillTypePtr Drill = NULL; + DrillType savedrill, swapdrill; + pcb_bool DrillFound = pcb_false; + pcb_bool NewDrill; + + AllDrills = (DrillInfoTypePtr) calloc(1, sizeof(DrillInfoType)); + ALLPIN_LOOP(top); + { + if (!DrillFound) { + DrillFound = pcb_true; + Drill = GetDrillInfoDrillMemory(AllDrills); + InitializeDrill(Drill, pin, element); + } + else { + if (Drill->DrillSize == pin->DrillingHole) + FillDrill(Drill, element, pin); + else { + NewDrill = pcb_false; + DRILL_LOOP(AllDrills); + { + if (drill->DrillSize == pin->DrillingHole) { + Drill = drill; + FillDrill(Drill, element, pin); + break; + } + else if (drill->DrillSize > pin->DrillingHole) { + if (!NewDrill) { + NewDrill = pcb_true; + InitializeDrill(&swapdrill, pin, element); + Drill = GetDrillInfoDrillMemory(AllDrills); + Drill->DrillSize = pin->DrillingHole + 1; + Drill = drill; + } + savedrill = *drill; + *drill = swapdrill; + swapdrill = savedrill; + } + } + END_LOOP; + if (AllDrills->Drill[AllDrills->DrillN - 1].DrillSize < pin->DrillingHole) { + Drill = GetDrillInfoDrillMemory(AllDrills); + InitializeDrill(Drill, pin, element); + } + } + } + } + ENDALL_LOOP; + VIA_LOOP(top); + { + if (!DrillFound) { + DrillFound = pcb_true; + Drill = GetDrillInfoDrillMemory(AllDrills); + Drill->DrillSize = via->DrillingHole; + FillDrill(Drill, NULL, via); + } + else { + if (Drill->DrillSize != via->DrillingHole) { + DRILL_LOOP(AllDrills); + { + if (drill->DrillSize == via->DrillingHole) { + Drill = drill; + FillDrill(Drill, NULL, via); + break; + } + } + END_LOOP; + if (Drill->DrillSize != via->DrillingHole) { + Drill = GetDrillInfoDrillMemory(AllDrills); + Drill->DrillSize = via->DrillingHole; + FillDrill(Drill, NULL, via); + } + } + else + FillDrill(Drill, NULL, via); + } + } + END_LOOP; + qsort(AllDrills->Drill, AllDrills->DrillN, sizeof(DrillType), DrillQSort); + return (AllDrills); +} + +#define ROUND(x,n) ((int)(((x)+(n)/2)/(n))*(n)) + +void RoundDrillInfo(DrillInfoTypePtr d, int roundto) +{ + unsigned int i = 0; + + while ((d->DrillN > 0) && (i < d->DrillN - 1)) { + int diam1 = ROUND(d->Drill[i].DrillSize, roundto); + int diam2 = ROUND(d->Drill[i + 1].DrillSize, roundto); + + if (diam1 == diam2) { + int ei, ej; + + d->Drill[i].ElementMax = d->Drill[i].ElementN + d->Drill[i + 1].ElementN; + if (d->Drill[i].ElementMax) { + d->Drill[i].Element = (ElementTypePtr *) realloc(d->Drill[i].Element, d->Drill[i].ElementMax * sizeof(ElementTypePtr)); + + for (ei = 0; ei < d->Drill[i + 1].ElementN; ei++) { + for (ej = 0; ej < d->Drill[i].ElementN; ej++) + if (d->Drill[i].Element[ej] == d->Drill[i + 1].Element[ei]) + break; + if (ej == d->Drill[i].ElementN) + d->Drill[i].Element[d->Drill[i].ElementN++] + = d->Drill[i + 1].Element[ei]; + } + } + free(d->Drill[i + 1].Element); + d->Drill[i + 1].Element = NULL; + + d->Drill[i].PinMax = d->Drill[i].PinN + d->Drill[i + 1].PinN; + d->Drill[i].Pin = (PinTypePtr *) realloc(d->Drill[i].Pin, d->Drill[i].PinMax * sizeof(PinTypePtr)); + memcpy(d->Drill[i].Pin + d->Drill[i].PinN, d->Drill[i + 1].Pin, d->Drill[i + 1].PinN * sizeof(PinTypePtr)); + d->Drill[i].PinN += d->Drill[i + 1].PinN; + free(d->Drill[i + 1].Pin); + d->Drill[i + 1].Pin = NULL; + + d->Drill[i].PinCount += d->Drill[i + 1].PinCount; + d->Drill[i].ViaCount += d->Drill[i + 1].ViaCount; + d->Drill[i].UnplatedCount += d->Drill[i + 1].UnplatedCount; + + d->Drill[i].DrillSize = diam1; + + memmove(d->Drill + i + 1, d->Drill + i + 2, (d->DrillN - i - 2) * sizeof(DrillType)); + d->DrillN--; + } + else { + d->Drill[i].DrillSize = diam1; + i++; + } + } +} + +void FreeDrillInfo(DrillInfoTypePtr Drills) +{ + DRILL_LOOP(Drills); + { + free(drill->Element); + free(drill->Pin); + } + END_LOOP; + free(Drills->Drill); + free(Drills); +} + +/* --------------------------------------------------------------------------- + * get next slot for a Drill, allocates memory if necessary + */ +DrillTypePtr GetDrillInfoDrillMemory(DrillInfoTypePtr DrillInfo) +{ + DrillTypePtr drill = DrillInfo->Drill; + + /* realloc new memory if necessary and clear it */ + if (DrillInfo->DrillN >= DrillInfo->DrillMax) { + DrillInfo->DrillMax += STEP_DRILL; + drill = (DrillTypePtr) realloc(drill, DrillInfo->DrillMax * sizeof(DrillType)); + DrillInfo->Drill = drill; + memset(drill + DrillInfo->DrillN, 0, STEP_DRILL * sizeof(DrillType)); + } + return (drill + DrillInfo->DrillN++); +} + +/* --------------------------------------------------------------------------- + * get next slot for a DrillPoint, allocates memory if necessary + */ +PinTypeHandle GetDrillPinMemory(DrillTypePtr Drill) +{ + PinTypePtr *pin; + + pin = Drill->Pin; + + /* realloc new memory if necessary and clear it */ + if (Drill->PinN >= Drill->PinMax) { + Drill->PinMax += STEP_POINT; + pin = (PinTypePtr *) realloc(pin, Drill->PinMax * sizeof(PinTypeHandle)); + Drill->Pin = pin; + memset(pin + Drill->PinN, 0, STEP_POINT * sizeof(PinTypeHandle)); + } + return (pin + Drill->PinN++); +} + +/* --------------------------------------------------------------------------- + * get next slot for a DrillElement, allocates memory if necessary + */ +ElementTypeHandle GetDrillElementMemory(DrillTypePtr Drill) +{ + ElementTypePtr *element; + + element = Drill->Element; + + /* realloc new memory if necessary and clear it */ + if (Drill->ElementN >= Drill->ElementMax) { + Drill->ElementMax += STEP_ELEMENT; + element = (ElementTypePtr *) realloc(element, Drill->ElementMax * sizeof(ElementTypeHandle)); + Drill->Element = element; + memset(element + Drill->ElementN, 0, STEP_ELEMENT * sizeof(ElementTypeHandle)); + } + return (element + Drill->ElementN++); +} + Index: trunk/src_plugins/report/drill.h =================================================================== --- trunk/src_plugins/report/drill.h (nonexistent) +++ trunk/src_plugins/report/drill.h (revision 4587) @@ -0,0 +1,64 @@ +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * + * This module, drill.h, was written and is Copyright (C) 1997 harry eaton + * + * 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 + * + */ +#ifndef PCB_DRILL_H +#define PCB_DRILL_H + +typedef struct { /* holds drill information */ + Coord DrillSize; /* this drill's diameter */ + pcb_cardinal_t ElementN, /* the number of elements using this drill size */ + ElementMax, /* max number of elements from malloc() */ + PinCount, /* number of pins drilled this size */ + ViaCount, /* number of vias drilled this size */ + UnplatedCount, /* number of these holes that are unplated */ + PinN, /* number of drill coordinates in the list */ + PinMax; /* max number of coordinates from malloc() */ + PinTypePtr *Pin; /* coordinates to drill */ + ElementTypePtr *Element; /* a pointer to an array of element pointers */ +} DrillType, *DrillTypePtr; + +typedef struct { /* holds a range of Drill Infos */ + pcb_cardinal_t DrillN, /* number of drill sizes */ + DrillMax; /* max number from malloc() */ + DrillTypePtr Drill; /* plated holes */ +} DrillInfoType, *DrillInfoTypePtr; + +DrillInfoTypePtr GetDrillInfo(DataTypePtr); +void FreeDrillInfo(DrillInfoTypePtr); +void RoundDrillInfo(DrillInfoTypePtr, int); +DrillTypePtr GetDrillInfoDrillMemory(DrillInfoTypePtr); +PinTypeHandle GetDrillPinMemory(DrillTypePtr); +ElementTypeHandle GetDrillElementMemory(DrillTypePtr); + +#define DRILL_LOOP(top) do { \ + pcb_cardinal_t n; \ + DrillTypePtr drill; \ + for (n = 0; (top)->DrillN > 0 && n < (top)->DrillN; n++) \ + { \ + drill = &(top)->Drill[n] + +#endif