Index: trunk/src/action.c =================================================================== --- trunk/src/action.c (revision 1021) +++ trunk/src/action.c (revision 1022) @@ -74,7 +74,7 @@ #include "rats_patch.h" #include -#include /* rand() */ +#include /* rand() */ #ifdef HAVE_LIBDMALLOC #include @@ -92,136 +92,132 @@ /* --------------------------------------------------------------------------- * some local types */ -typedef enum -{ - F_AddSelected, - F_All, - F_AllConnections, - F_AllRats, - F_AllUnusedPins, - F_Arc, - F_Arrow, - F_Block, - F_Description, - F_Cancel, - F_Center, - F_Clear, - F_ClearAndRedraw, - F_ClearList, - F_Close, - F_Connection, - F_Convert, - F_Copy, - F_CycleClip, - F_CycleCrosshair, - F_DeleteRats, - F_Drag, - F_DrillReport, - F_Element, - F_ElementByName, - F_ElementConnections, - F_ElementToBuffer, - F_Escape, - F_Find, - F_FlipElement, - F_FoundPins, - F_Grid, - F_InsertPoint, - F_Layer, - F_Layout, - F_LayoutAs, - F_LayoutToBuffer, - F_Line, - F_LineSize, - F_Lock, - F_Mirror, - F_Move, - F_NameOnPCB, - F_Netlist, - F_NetByName, - F_None, - F_Notify, - F_Object, - F_ObjectByName, - F_PasteBuffer, - F_PadByName, - F_PinByName, - F_PinOrPadName, - F_Pinout, - F_Polygon, - F_PolygonHole, - F_PreviousPoint, - F_RatsNest, - F_Rectangle, - F_Redraw, - F_Release, - F_Revert, - F_Remove, - F_RemoveSelected, - F_Report, - F_Reset, - F_ResetLinesAndPolygons, - F_ResetPinsViasAndPads, - F_Restore, - F_Rotate, - F_Save, - F_Selected, - F_SelectedArcs, - F_SelectedElements, - F_SelectedLines, - F_SelectedNames, - F_SelectedObjects, - F_SelectedPads, - F_SelectedPins, - F_SelectedTexts, - F_SelectedVias, - F_SelectedRats, - F_Stroke, - F_Text, - F_TextByName, - F_TextScale, - F_Thermal, - F_ToLayout, - F_ToggleAllDirections, - F_ToggleAutoDRC, - F_ToggleClearLine, - F_ToggleFullPoly, - F_ToggleGrid, - F_ToggleHideNames, - F_ToggleMinCut, - F_ToggleMask, - F_ToggleName, - F_ToggleObject, - F_ToggleShowDRC, - F_ToggleLiveRoute, - F_ToggleRubberBandMode, - F_ToggleStartDirection, - F_ToggleSnapPin, - F_ToggleSnapOffGridLine, - F_ToggleHighlightOnPoint, - F_ToggleThindraw, - F_ToggleLockNames, - F_ToggleOnlyNames, - F_ToggleThindrawPoly, - F_ToggleOrthoMove, - F_ToggleLocalRef, - F_ToggleCheckPlanes, - F_ToggleUniqueNames, - F_Via, - F_ViaByName, - F_Value, - F_ViaDrillingHole, - F_ViaSize, - F_Zoom -} -FunctionID; +typedef enum { + F_AddSelected, + F_All, + F_AllConnections, + F_AllRats, + F_AllUnusedPins, + F_Arc, + F_Arrow, + F_Block, + F_Description, + F_Cancel, + F_Center, + F_Clear, + F_ClearAndRedraw, + F_ClearList, + F_Close, + F_Connection, + F_Convert, + F_Copy, + F_CycleClip, + F_CycleCrosshair, + F_DeleteRats, + F_Drag, + F_DrillReport, + F_Element, + F_ElementByName, + F_ElementConnections, + F_ElementToBuffer, + F_Escape, + F_Find, + F_FlipElement, + F_FoundPins, + F_Grid, + F_InsertPoint, + F_Layer, + F_Layout, + F_LayoutAs, + F_LayoutToBuffer, + F_Line, + F_LineSize, + F_Lock, + F_Mirror, + F_Move, + F_NameOnPCB, + F_Netlist, + F_NetByName, + F_None, + F_Notify, + F_Object, + F_ObjectByName, + F_PasteBuffer, + F_PadByName, + F_PinByName, + F_PinOrPadName, + F_Pinout, + F_Polygon, + F_PolygonHole, + F_PreviousPoint, + F_RatsNest, + F_Rectangle, + F_Redraw, + F_Release, + F_Revert, + F_Remove, + F_RemoveSelected, + F_Report, + F_Reset, + F_ResetLinesAndPolygons, + F_ResetPinsViasAndPads, + F_Restore, + F_Rotate, + F_Save, + F_Selected, + F_SelectedArcs, + F_SelectedElements, + F_SelectedLines, + F_SelectedNames, + F_SelectedObjects, + F_SelectedPads, + F_SelectedPins, + F_SelectedTexts, + F_SelectedVias, + F_SelectedRats, + F_Stroke, + F_Text, + F_TextByName, + F_TextScale, + F_Thermal, + F_ToLayout, + F_ToggleAllDirections, + F_ToggleAutoDRC, + F_ToggleClearLine, + F_ToggleFullPoly, + F_ToggleGrid, + F_ToggleHideNames, + F_ToggleMinCut, + F_ToggleMask, + F_ToggleName, + F_ToggleObject, + F_ToggleShowDRC, + F_ToggleLiveRoute, + F_ToggleRubberBandMode, + F_ToggleStartDirection, + F_ToggleSnapPin, + F_ToggleSnapOffGridLine, + F_ToggleHighlightOnPoint, + F_ToggleThindraw, + F_ToggleLockNames, + F_ToggleOnlyNames, + F_ToggleThindrawPoly, + F_ToggleOrthoMove, + F_ToggleLocalRef, + F_ToggleCheckPlanes, + F_ToggleUniqueNames, + F_Via, + F_ViaByName, + F_Value, + F_ViaDrillingHole, + F_ViaSize, + F_Zoom +} FunctionID; -typedef struct /* used to identify subfunctions */ -{ - char *Identifier; - FunctionID ID; -} -FunctionType, *FunctionTypePtr; +typedef struct { /* used to identify subfunctions */ + char *Identifier; + FunctionID ID; +} FunctionType, *FunctionTypePtr; /* --------------------------------------------------------------------------- */ @@ -301,25 +297,21 @@ */ static PointType InsertedPoint; static LayerTypePtr lastLayer; -static struct -{ - PolygonTypePtr poly; - LineType line; -} -fake; +static struct { + PolygonTypePtr poly; + LineType line; +} fake; -static struct -{ - Coord X, Y; - Cardinal Buffer; - bool Click; - bool Moving; /* selected type clicked on */ - int Hit; /* move type clicked on */ - void *ptr1; - void *ptr2; - void *ptr3; -} -Note; +static struct { + Coord X, Y; + Cardinal Buffer; + bool Click; + bool Moving; /* selected type clicked on */ + int Hit; /* move type clicked on */ + void *ptr1; + void *ptr2; + void *ptr3; +} Note; static int defer_updates = 0; static int defer_needs_update = 0; @@ -331,143 +323,143 @@ static BoxType StrokeBox; #endif static FunctionType Functions[] = { - {"AddSelected", F_AddSelected}, - {"All", F_All}, - {"AllConnections", F_AllConnections}, - {"AllRats", F_AllRats}, - {"AllUnusedPins", F_AllUnusedPins}, - {"Arc", F_Arc}, - {"Arrow", F_Arrow}, - {"Block", F_Block}, - {"Description", F_Description}, - {"Cancel", F_Cancel}, - {"Center", F_Center}, - {"Clear", F_Clear}, - {"ClearAndRedraw", F_ClearAndRedraw}, - {"ClearList", F_ClearList}, - {"Close", F_Close}, - {"Connection", F_Connection}, - {"Convert", F_Convert}, - {"Copy", F_Copy}, - {"CycleClip", F_CycleClip}, - {"CycleCrosshair", F_CycleCrosshair}, - {"DeleteRats", F_DeleteRats}, - {"Drag", F_Drag}, - {"DrillReport", F_DrillReport}, - {"Element", F_Element}, - {"ElementByName", F_ElementByName}, - {"ElementConnections", F_ElementConnections}, - {"ElementToBuffer", F_ElementToBuffer}, - {"Escape", F_Escape}, - {"Find", F_Find}, - {"FlipElement", F_FlipElement}, - {"FoundPins", F_FoundPins}, - {"Grid", F_Grid}, - {"InsertPoint", F_InsertPoint}, - {"Layer", F_Layer}, - {"Layout", F_Layout}, - {"LayoutAs", F_LayoutAs}, - {"LayoutToBuffer", F_LayoutToBuffer}, - {"Line", F_Line}, - {"LineSize", F_LineSize}, - {"Lock", F_Lock}, - {"Mirror", F_Mirror}, - {"Move", F_Move}, - {"NameOnPCB", F_NameOnPCB}, - {"Netlist", F_Netlist}, - {"NetByName", F_NetByName}, - {"None", F_None}, - {"Notify", F_Notify}, - {"Object", F_Object}, - {"ObjectByName", F_ObjectByName}, - {"PasteBuffer", F_PasteBuffer}, - {"PadByName", F_PadByName}, - {"PinByName", F_PinByName}, - {"PinOrPadName", F_PinOrPadName}, - {"Pinout", F_Pinout}, - {"Polygon", F_Polygon}, - {"PolygonHole", F_PolygonHole}, - {"PreviousPoint", F_PreviousPoint}, - {"RatsNest", F_RatsNest}, - {"Rectangle", F_Rectangle}, - {"Redraw", F_Redraw}, - {"Release", F_Release}, - {"Remove", F_Remove}, - {"RemoveSelected", F_RemoveSelected}, - {"Report", F_Report}, - {"Reset", F_Reset}, - {"ResetLinesAndPolygons", F_ResetLinesAndPolygons}, - {"ResetPinsViasAndPads", F_ResetPinsViasAndPads}, - {"Restore", F_Restore}, - {"Revert", F_Revert}, - {"Rotate", F_Rotate}, - {"Save", F_Save}, - {"Selected", F_Selected}, - {"SelectedArcs", F_SelectedArcs}, - {"SelectedElements", F_SelectedElements}, - {"SelectedLines", F_SelectedLines}, - {"SelectedNames", F_SelectedNames}, - {"SelectedObjects", F_SelectedObjects}, - {"SelectedPins", F_SelectedPins}, - {"SelectedPads", F_SelectedPads}, - {"SelectedRats", F_SelectedRats}, - {"SelectedTexts", F_SelectedTexts}, - {"SelectedVias", F_SelectedVias}, - {"Stroke", F_Stroke}, - {"Text", F_Text}, - {"TextByName", F_TextByName}, - {"TextScale", F_TextScale}, - {"Thermal", F_Thermal}, - {"ToLayout", F_ToLayout}, - {"Toggle45Degree", F_ToggleAllDirections}, - {"ToggleClearLine", F_ToggleClearLine}, - {"ToggleFullPoly", F_ToggleFullPoly}, - {"ToggleGrid", F_ToggleGrid}, - {"ToggleMask", F_ToggleMask}, - {"ToggleName", F_ToggleName}, - {"ToggleObject", F_ToggleObject}, - {"ToggleRubberBandMode", F_ToggleRubberBandMode}, - {"ToggleStartDirection", F_ToggleStartDirection}, - {"ToggleSnapPin", F_ToggleSnapPin}, - {"ToggleSnapOffGridLine", F_ToggleSnapOffGridLine}, - {"ToggleHighlightOnPoint", F_ToggleHighlightOnPoint}, - {"ToggleThindraw", F_ToggleThindraw}, - {"ToggleThindrawPoly", F_ToggleThindrawPoly}, - {"ToggleLockNames", F_ToggleLockNames}, - {"ToggleOnlyNames", F_ToggleOnlyNames}, - {"ToggleHideNames", F_ToggleHideNames}, - {"ToggleMinCut", F_ToggleMinCut}, - {"ToggleCheckPlanes", F_ToggleCheckPlanes}, - {"ToggleLocalRef", F_ToggleLocalRef}, - {"ToggleOrthoMove", F_ToggleOrthoMove}, - {"ToggleShowDRC", F_ToggleShowDRC}, - {"ToggleLiveRoute", F_ToggleLiveRoute}, - {"ToggleAutoDRC", F_ToggleAutoDRC}, - {"ToggleUniqueNames", F_ToggleUniqueNames}, - {"Value", F_Value}, - {"Via", F_Via}, - {"ViaByName", F_ViaByName}, - {"ViaSize", F_ViaSize}, - {"ViaDrillingHole", F_ViaDrillingHole}, - {"Zoom", F_Zoom} + {"AddSelected", F_AddSelected}, + {"All", F_All}, + {"AllConnections", F_AllConnections}, + {"AllRats", F_AllRats}, + {"AllUnusedPins", F_AllUnusedPins}, + {"Arc", F_Arc}, + {"Arrow", F_Arrow}, + {"Block", F_Block}, + {"Description", F_Description}, + {"Cancel", F_Cancel}, + {"Center", F_Center}, + {"Clear", F_Clear}, + {"ClearAndRedraw", F_ClearAndRedraw}, + {"ClearList", F_ClearList}, + {"Close", F_Close}, + {"Connection", F_Connection}, + {"Convert", F_Convert}, + {"Copy", F_Copy}, + {"CycleClip", F_CycleClip}, + {"CycleCrosshair", F_CycleCrosshair}, + {"DeleteRats", F_DeleteRats}, + {"Drag", F_Drag}, + {"DrillReport", F_DrillReport}, + {"Element", F_Element}, + {"ElementByName", F_ElementByName}, + {"ElementConnections", F_ElementConnections}, + {"ElementToBuffer", F_ElementToBuffer}, + {"Escape", F_Escape}, + {"Find", F_Find}, + {"FlipElement", F_FlipElement}, + {"FoundPins", F_FoundPins}, + {"Grid", F_Grid}, + {"InsertPoint", F_InsertPoint}, + {"Layer", F_Layer}, + {"Layout", F_Layout}, + {"LayoutAs", F_LayoutAs}, + {"LayoutToBuffer", F_LayoutToBuffer}, + {"Line", F_Line}, + {"LineSize", F_LineSize}, + {"Lock", F_Lock}, + {"Mirror", F_Mirror}, + {"Move", F_Move}, + {"NameOnPCB", F_NameOnPCB}, + {"Netlist", F_Netlist}, + {"NetByName", F_NetByName}, + {"None", F_None}, + {"Notify", F_Notify}, + {"Object", F_Object}, + {"ObjectByName", F_ObjectByName}, + {"PasteBuffer", F_PasteBuffer}, + {"PadByName", F_PadByName}, + {"PinByName", F_PinByName}, + {"PinOrPadName", F_PinOrPadName}, + {"Pinout", F_Pinout}, + {"Polygon", F_Polygon}, + {"PolygonHole", F_PolygonHole}, + {"PreviousPoint", F_PreviousPoint}, + {"RatsNest", F_RatsNest}, + {"Rectangle", F_Rectangle}, + {"Redraw", F_Redraw}, + {"Release", F_Release}, + {"Remove", F_Remove}, + {"RemoveSelected", F_RemoveSelected}, + {"Report", F_Report}, + {"Reset", F_Reset}, + {"ResetLinesAndPolygons", F_ResetLinesAndPolygons}, + {"ResetPinsViasAndPads", F_ResetPinsViasAndPads}, + {"Restore", F_Restore}, + {"Revert", F_Revert}, + {"Rotate", F_Rotate}, + {"Save", F_Save}, + {"Selected", F_Selected}, + {"SelectedArcs", F_SelectedArcs}, + {"SelectedElements", F_SelectedElements}, + {"SelectedLines", F_SelectedLines}, + {"SelectedNames", F_SelectedNames}, + {"SelectedObjects", F_SelectedObjects}, + {"SelectedPins", F_SelectedPins}, + {"SelectedPads", F_SelectedPads}, + {"SelectedRats", F_SelectedRats}, + {"SelectedTexts", F_SelectedTexts}, + {"SelectedVias", F_SelectedVias}, + {"Stroke", F_Stroke}, + {"Text", F_Text}, + {"TextByName", F_TextByName}, + {"TextScale", F_TextScale}, + {"Thermal", F_Thermal}, + {"ToLayout", F_ToLayout}, + {"Toggle45Degree", F_ToggleAllDirections}, + {"ToggleClearLine", F_ToggleClearLine}, + {"ToggleFullPoly", F_ToggleFullPoly}, + {"ToggleGrid", F_ToggleGrid}, + {"ToggleMask", F_ToggleMask}, + {"ToggleName", F_ToggleName}, + {"ToggleObject", F_ToggleObject}, + {"ToggleRubberBandMode", F_ToggleRubberBandMode}, + {"ToggleStartDirection", F_ToggleStartDirection}, + {"ToggleSnapPin", F_ToggleSnapPin}, + {"ToggleSnapOffGridLine", F_ToggleSnapOffGridLine}, + {"ToggleHighlightOnPoint", F_ToggleHighlightOnPoint}, + {"ToggleThindraw", F_ToggleThindraw}, + {"ToggleThindrawPoly", F_ToggleThindrawPoly}, + {"ToggleLockNames", F_ToggleLockNames}, + {"ToggleOnlyNames", F_ToggleOnlyNames}, + {"ToggleHideNames", F_ToggleHideNames}, + {"ToggleMinCut", F_ToggleMinCut}, + {"ToggleCheckPlanes", F_ToggleCheckPlanes}, + {"ToggleLocalRef", F_ToggleLocalRef}, + {"ToggleOrthoMove", F_ToggleOrthoMove}, + {"ToggleShowDRC", F_ToggleShowDRC}, + {"ToggleLiveRoute", F_ToggleLiveRoute}, + {"ToggleAutoDRC", F_ToggleAutoDRC}, + {"ToggleUniqueNames", F_ToggleUniqueNames}, + {"Value", F_Value}, + {"Via", F_Via}, + {"ViaByName", F_ViaByName}, + {"ViaSize", F_ViaSize}, + {"ViaDrillingHole", F_ViaDrillingHole}, + {"Zoom", F_Zoom} }; /* --------------------------------------------------------------------------- * some local routines */ -static int GetFunctionID (String); -static void AdjustAttachedBox (void); -static void NotifyLine (void); -static void NotifyBlock (void); -static void NotifyMode (void); -static void ClearWarnings (void); +static int GetFunctionID(String); +static void AdjustAttachedBox(void); +static void NotifyLine(void); +static void NotifyBlock(void); +static void NotifyMode(void); +static void ClearWarnings(void); #ifdef HAVE_LIBSTROKE -static void FinishStroke (void); -extern void stroke_init (void); -extern void stroke_record (int x, int y); -extern int stroke_trans (char *s); +static void FinishStroke(void); +extern void stroke_init(void); +extern void stroke_record(int x, int y); +extern int stroke_trans(char *s); #endif -static void ChangeFlag (char *, char *, int, char *); +static void ChangeFlag(char *, char *, int, char *); #define ARG(n) (argc > (n) ? argv[n] : NULL) @@ -476,123 +468,113 @@ /* --------------------------------------------------------------------------- * FinishStroke - try to recognize the stroke sent */ -void -FinishStroke (void) +void FinishStroke(void) { - char msg[255]; - int type; - unsigned long num; - void *ptr1, *ptr2, *ptr3; + char msg[255]; + int type; + unsigned long num; + void *ptr1, *ptr2, *ptr3; - mid_stroke = false; - if (stroke_trans (msg)) - { - num = atoi (msg); - switch (num) - { - case 456: - if (Settings.Mode == LINE_MODE) - { - SetMode (LINE_MODE); - } - break; - case 9874123: - case 74123: - case 987412: - case 8741236: - case 874123: - RotateScreenObject (StrokeBox.X1, StrokeBox.Y1, SWAP_IDENT ? 1 : 3); - break; - case 7896321: - case 786321: - case 789632: - case 896321: - RotateScreenObject (StrokeBox.X1, StrokeBox.Y1, SWAP_IDENT ? 3 : 1); - break; - case 258: - SetMode (LINE_MODE); - break; - case 852: - SetMode (ARROW_MODE); - break; - case 1478963: - ActionUndo (""); - break; - case 147423: - case 147523: - case 1474123: - Redo (true); - break; - case 148963: - case 147863: - case 147853: - case 145863: - SetMode (VIA_MODE); - break; - case 951: - case 9651: - case 9521: - case 9621: - case 9851: - case 9541: - case 96521: - case 96541: - case 98541: - SetZoom (1000); /* special zoom extents */ - break; - case 159: - case 1269: - case 1259: - case 1459: - case 1569: - case 1589: - case 12569: - case 12589: - case 14589: - { - Coord x = (StrokeBox.X1 + StrokeBox.X2) / 2; - Coord y = (StrokeBox.Y1 + StrokeBox.Y2) / 2; - double z; - /* XXX: PCB->MaxWidth and PCB->MaxHeight may be the wrong - * divisors below. The old code WAS broken, but this - * replacement has not been tested for correctness. - */ - z = - 1 + - log (fabs (StrokeBox.X2 - StrokeBox.X1) / PCB->MaxWidth) / - log (2.0); - z = - MAX (z, - 1 + - log (fabs (StrokeBox.Y2 - StrokeBox.Y1) / PCB->MaxHeight) / - log (2.0)); - SetZoom (z); + mid_stroke = false; + if (stroke_trans(msg)) { + num = atoi(msg); + switch (num) { + case 456: + if (Settings.Mode == LINE_MODE) { + SetMode(LINE_MODE); + } + break; + case 9874123: + case 74123: + case 987412: + case 8741236: + case 874123: + RotateScreenObject(StrokeBox.X1, StrokeBox.Y1, SWAP_IDENT ? 1 : 3); + break; + case 7896321: + case 786321: + case 789632: + case 896321: + RotateScreenObject(StrokeBox.X1, StrokeBox.Y1, SWAP_IDENT ? 3 : 1); + break; + case 258: + SetMode(LINE_MODE); + break; + case 852: + SetMode(ARROW_MODE); + break; + case 1478963: + ActionUndo(""); + break; + case 147423: + case 147523: + case 1474123: + Redo(true); + break; + case 148963: + case 147863: + case 147853: + case 145863: + SetMode(VIA_MODE); + break; + case 951: + case 9651: + case 9521: + case 9621: + case 9851: + case 9541: + case 96521: + case 96541: + case 98541: + SetZoom(1000); /* special zoom extents */ + break; + case 159: + case 1269: + case 1259: + case 1459: + case 1569: + case 1589: + case 12569: + case 12589: + case 14589: + { + Coord x = (StrokeBox.X1 + StrokeBox.X2) / 2; + Coord y = (StrokeBox.Y1 + StrokeBox.Y2) / 2; + double z; + /* XXX: PCB->MaxWidth and PCB->MaxHeight may be the wrong + * divisors below. The old code WAS broken, but this + * replacement has not been tested for correctness. + */ + z = 1 + log(fabs(StrokeBox.X2 - StrokeBox.X1) / PCB->MaxWidth) / log(2.0); + z = MAX(z, 1 + log(fabs(StrokeBox.Y2 - StrokeBox.Y1) / PCB->MaxHeight) / log(2.0)); + SetZoom(z); - CenterDisplay (x, y); - break; - } + CenterDisplay(x, y); + break; + } - default: - Message (_("Unknown stroke %s\n"), msg); - break; + default: + Message(_("Unknown stroke %s\n"), msg); + break; + } } - } - else - gui->beep (); + else + gui->beep(); } #endif /* --------------------------------------------------------------------------- */ /* Ask the suer for a search pattern */ -static char *gui_get_pat(search_method_t *method) +static char *gui_get_pat(search_method_t * method) { const char *methods[] = { "regexp", "list of names", NULL }; HID_Attribute attrs[] = { - { .name = "Pattern", .help_text="Name/refdes pattern", .type=HID_String}, - { .name = "Method", .help_text="method of search: either regular expression or a list of full names separated by |", .type=HID_Enum, .enumerations=methods} + {.name = "Pattern",.help_text = "Name/refdes pattern",.type = HID_String}, + {.name = "Method",.help_text = "method of search: either regular expression or a list of full names separated by |",.type = + HID_Enum,.enumerations = methods} }; #define nattr sizeof(attrs)/sizeof(attrs[0]) - static HID_Attr_Val results[nattr] = {0}; + static HID_Attr_Val results[nattr] = { 0 }; attrs[0].default_val.str_value = results[0].str_value; attrs[1].default_val.int_value = results[1].int_value; @@ -607,200 +589,181 @@ /* --------------------------------------------------------------------------- * Clear warning color from pins/pads */ -static void -ClearWarnings () +static void ClearWarnings() { - Settings.RatWarn = false; - ALLPIN_LOOP (PCB->Data); - { - if (TEST_FLAG (WARNFLAG, pin)) - { - CLEAR_FLAG (WARNFLAG, pin); - DrawPin (pin); - } - } - ENDALL_LOOP; - VIA_LOOP (PCB->Data); - { - if (TEST_FLAG (WARNFLAG, via)) - { - CLEAR_FLAG (WARNFLAG, via); - DrawVia (via); - } - } - END_LOOP; - ALLPAD_LOOP (PCB->Data); - { - if (TEST_FLAG (WARNFLAG, pad)) - { - CLEAR_FLAG (WARNFLAG, pad); - DrawPad (pad); - } - } - ENDALL_LOOP; - ALLLINE_LOOP (PCB->Data); - { - if (TEST_FLAG (WARNFLAG, line)) - { - CLEAR_FLAG (WARNFLAG, line); - DrawLine (layer, line); - } - } - ENDALL_LOOP; - ALLARC_LOOP (PCB->Data); - { - if (TEST_FLAG (WARNFLAG, arc)) - { - CLEAR_FLAG (WARNFLAG, arc); - DrawArc (layer, arc); - } - } - ENDALL_LOOP; - ALLPOLYGON_LOOP (PCB->Data); - { - if (TEST_FLAG (WARNFLAG, polygon)) - { - CLEAR_FLAG (WARNFLAG, polygon); - DrawPolygon (layer, polygon); - } - } - ENDALL_LOOP; + Settings.RatWarn = false; + ALLPIN_LOOP(PCB->Data); + { + if (TEST_FLAG(WARNFLAG, pin)) { + CLEAR_FLAG(WARNFLAG, pin); + DrawPin(pin); + } + } + ENDALL_LOOP; + VIA_LOOP(PCB->Data); + { + if (TEST_FLAG(WARNFLAG, via)) { + CLEAR_FLAG(WARNFLAG, via); + DrawVia(via); + } + } + END_LOOP; + ALLPAD_LOOP(PCB->Data); + { + if (TEST_FLAG(WARNFLAG, pad)) { + CLEAR_FLAG(WARNFLAG, pad); + DrawPad(pad); + } + } + ENDALL_LOOP; + ALLLINE_LOOP(PCB->Data); + { + if (TEST_FLAG(WARNFLAG, line)) { + CLEAR_FLAG(WARNFLAG, line); + DrawLine(layer, line); + } + } + ENDALL_LOOP; + ALLARC_LOOP(PCB->Data); + { + if (TEST_FLAG(WARNFLAG, arc)) { + CLEAR_FLAG(WARNFLAG, arc); + DrawArc(layer, arc); + } + } + ENDALL_LOOP; + ALLPOLYGON_LOOP(PCB->Data); + { + if (TEST_FLAG(WARNFLAG, polygon)) { + CLEAR_FLAG(WARNFLAG, polygon); + DrawPolygon(layer, polygon); + } + } + ENDALL_LOOP; - Draw (); + Draw(); } -static void -click_cb (hidval hv) +static void click_cb(hidval hv) { - if (Note.Click) - { - notify_crosshair_change (false); - Note.Click = false; - if (Note.Moving && !gui->shift_is_pressed ()) - { - Note.Buffer = Settings.BufferNumber; - SetBufferNumber (MAX_BUFFER - 1); - ClearBuffer (PASTEBUFFER); - AddSelectedToBuffer (PASTEBUFFER, Note.X, Note.Y, true); - SaveUndoSerialNumber (); - RemoveSelected (); - SaveMode (); - saved_mode = true; - SetMode (PASTEBUFFER_MODE); - } - else if (Note.Hit && !gui->shift_is_pressed ()) - { - BoxType box; + if (Note.Click) { + notify_crosshair_change(false); + Note.Click = false; + if (Note.Moving && !gui->shift_is_pressed()) { + Note.Buffer = Settings.BufferNumber; + SetBufferNumber(MAX_BUFFER - 1); + ClearBuffer(PASTEBUFFER); + AddSelectedToBuffer(PASTEBUFFER, Note.X, Note.Y, true); + SaveUndoSerialNumber(); + RemoveSelected(); + SaveMode(); + saved_mode = true; + SetMode(PASTEBUFFER_MODE); + } + else if (Note.Hit && !gui->shift_is_pressed()) { + BoxType box; - SaveMode (); - saved_mode = true; - SetMode (gui->control_is_pressed ()? COPY_MODE : MOVE_MODE); - Crosshair.AttachedObject.Ptr1 = Note.ptr1; - Crosshair.AttachedObject.Ptr2 = Note.ptr2; - Crosshair.AttachedObject.Ptr3 = Note.ptr3; - Crosshair.AttachedObject.Type = Note.Hit; + SaveMode(); + saved_mode = true; + SetMode(gui->control_is_pressed()? COPY_MODE : MOVE_MODE); + Crosshair.AttachedObject.Ptr1 = Note.ptr1; + Crosshair.AttachedObject.Ptr2 = Note.ptr2; + Crosshair.AttachedObject.Ptr3 = Note.ptr3; + Crosshair.AttachedObject.Type = Note.Hit; - if (Crosshair.drags != NULL) { - free(Crosshair.drags); - Crosshair.drags = NULL; - } - Crosshair.dragx = Note.X; - Crosshair.dragy = Note.Y; - box.X1 = Note.X + SLOP * pixel_slop; - box.X2 = Note.X - SLOP * pixel_slop; - box.Y1 = Note.Y + SLOP * pixel_slop; - box.Y2 = Note.Y - SLOP * pixel_slop; - Crosshair.drags = ListBlock (&box, &Crosshair.drags_len); - Crosshair.drags_current = 0; - AttachForCopy (Note.X, Note.Y); - } - else - { - BoxType box; + if (Crosshair.drags != NULL) { + free(Crosshair.drags); + Crosshair.drags = NULL; + } + Crosshair.dragx = Note.X; + Crosshair.dragy = Note.Y; + box.X1 = Note.X + SLOP * pixel_slop; + box.X2 = Note.X - SLOP * pixel_slop; + box.Y1 = Note.Y + SLOP * pixel_slop; + box.Y2 = Note.Y - SLOP * pixel_slop; + Crosshair.drags = ListBlock(&box, &Crosshair.drags_len); + Crosshair.drags_current = 0; + AttachForCopy(Note.X, Note.Y); + } + else { + BoxType box; - Note.Hit = 0; - Note.Moving = false; - SaveUndoSerialNumber (); - box.X1 = -MAX_COORD; - box.Y1 = -MAX_COORD; - box.X2 = MAX_COORD; - box.Y2 = MAX_COORD; - /* unselect first if shift key not down */ - if (!gui->shift_is_pressed () && SelectBlock (&box, false)) - SetChangedFlag (true); - NotifyBlock (); - Crosshair.AttachedBox.Point1.X = Note.X; - Crosshair.AttachedBox.Point1.Y = Note.Y; + Note.Hit = 0; + Note.Moving = false; + SaveUndoSerialNumber(); + box.X1 = -MAX_COORD; + box.Y1 = -MAX_COORD; + box.X2 = MAX_COORD; + box.Y2 = MAX_COORD; + /* unselect first if shift key not down */ + if (!gui->shift_is_pressed() && SelectBlock(&box, false)) + SetChangedFlag(true); + NotifyBlock(); + Crosshair.AttachedBox.Point1.X = Note.X; + Crosshair.AttachedBox.Point1.Y = Note.Y; + } + notify_crosshair_change(true); } - notify_crosshair_change (true); - } } -static void -ReleaseMode (void) +static void ReleaseMode(void) { - BoxType box; + BoxType box; - if (Note.Click) - { - BoxType box; + if (Note.Click) { + BoxType box; - box.X1 = -MAX_COORD; - box.Y1 = -MAX_COORD; - box.X2 = MAX_COORD; - box.Y2 = MAX_COORD; + box.X1 = -MAX_COORD; + box.Y1 = -MAX_COORD; + box.X2 = MAX_COORD; + box.Y2 = MAX_COORD; - Note.Click = false; /* inhibit timer action */ - SaveUndoSerialNumber (); - /* unselect first if shift key not down */ - if (!gui->shift_is_pressed ()) - { - if (SelectBlock (&box, false)) - SetChangedFlag (true); - if (Note.Moving) - { - Note.Moving = 0; - Note.Hit = 0; - return; - } + Note.Click = false; /* inhibit timer action */ + SaveUndoSerialNumber(); + /* unselect first if shift key not down */ + if (!gui->shift_is_pressed()) { + if (SelectBlock(&box, false)) + SetChangedFlag(true); + if (Note.Moving) { + Note.Moving = 0; + Note.Hit = 0; + return; + } + } + RestoreUndoSerialNumber(); + if (SelectObject()) + SetChangedFlag(true); + Note.Hit = 0; + Note.Moving = 0; } - RestoreUndoSerialNumber (); - if (SelectObject ()) - SetChangedFlag (true); - Note.Hit = 0; - Note.Moving = 0; - } - else if (Note.Moving) - { - RestoreUndoSerialNumber (); - NotifyMode (); - ClearBuffer (PASTEBUFFER); - SetBufferNumber (Note.Buffer); - Note.Moving = false; - Note.Hit = 0; - } - else if (Note.Hit) - { - NotifyMode (); - Note.Hit = 0; - } - else if (Settings.Mode == ARROW_MODE) - { - box.X1 = Crosshair.AttachedBox.Point1.X; - box.Y1 = Crosshair.AttachedBox.Point1.Y; - box.X2 = Crosshair.AttachedBox.Point2.X; - box.Y2 = Crosshair.AttachedBox.Point2.Y; + else if (Note.Moving) { + RestoreUndoSerialNumber(); + NotifyMode(); + ClearBuffer(PASTEBUFFER); + SetBufferNumber(Note.Buffer); + Note.Moving = false; + Note.Hit = 0; + } + else if (Note.Hit) { + NotifyMode(); + Note.Hit = 0; + } + else if (Settings.Mode == ARROW_MODE) { + box.X1 = Crosshair.AttachedBox.Point1.X; + box.Y1 = Crosshair.AttachedBox.Point1.Y; + box.X2 = Crosshair.AttachedBox.Point2.X; + box.Y2 = Crosshair.AttachedBox.Point2.Y; - RestoreUndoSerialNumber (); - if (SelectBlock (&box, true)) - SetChangedFlag (true); - else if (Bumped) - IncrementUndoSerialNumber (); - Crosshair.AttachedBox.State = STATE_FIRST; - } - if (saved_mode) - RestoreMode (); - saved_mode = false; + RestoreUndoSerialNumber(); + if (SelectBlock(&box, true)) + SetChangedFlag(true); + else if (Bumped) + IncrementUndoSerialNumber(); + Crosshair.AttachedBox.State = STATE_FIRST; + } + if (saved_mode) + RestoreMode(); + saved_mode = false; } /* --------------------------------------------------------------------------- @@ -810,66 +773,58 @@ static char function_hash[HSIZE]; static int hash_initted = 0; -static int -hashfunc(String s) +static int hashfunc(String s) { - int i = 0; - while (*s) - { - i ^= i >> 16; - i = (i * 13) ^ (unsigned char)tolower((int) *s); - s ++; - } - i = (unsigned int)i % HSIZE; - return i; + int i = 0; + while (*s) { + i ^= i >> 16; + i = (i * 13) ^ (unsigned char) tolower((int) *s); + s++; + } + i = (unsigned int) i % HSIZE; + return i; } -static int -GetFunctionID (String Ident) +static int GetFunctionID(String Ident) { - int i, h; + int i, h; - if (Ident == 0) - return -1; + if (Ident == 0) + return -1; - if (!hash_initted) - { - hash_initted = 1; - if (HSIZE < ENTRIES (Functions) * 2) - { - fprintf(stderr, _("Error: function hash size too small (%d vs %lu at %s:%d)\n"), - HSIZE, (unsigned long) ENTRIES (Functions)*2, __FILE__, __LINE__); - exit(1); + if (!hash_initted) { + hash_initted = 1; + if (HSIZE < ENTRIES(Functions) * 2) { + fprintf(stderr, _("Error: function hash size too small (%d vs %lu at %s:%d)\n"), + HSIZE, (unsigned long) ENTRIES(Functions) * 2, __FILE__, __LINE__); + exit(1); + } + if (ENTRIES(Functions) > 254) { + /* Change 'char' to 'int' and remove this when we get to 256 + strings to hash. */ + fprintf(stderr, _("Error: function hash type too small (%d vs %lu at %s:%d)\n"), + 256, (unsigned long) ENTRIES(Functions), __FILE__, __LINE__); + exit(1); + + } + for (i = ENTRIES(Functions) - 1; i >= 0; i--) { + h = hashfunc(Functions[i].Identifier); + while (function_hash[h]) + h = (h + 1) % HSIZE; + function_hash[h] = i + 1; + } } - if (ENTRIES (Functions) > 254) - { - /* Change 'char' to 'int' and remove this when we get to 256 - strings to hash. */ - fprintf(stderr, _("Error: function hash type too small (%d vs %lu at %s:%d)\n"), - 256, (unsigned long) ENTRIES (Functions), __FILE__, __LINE__); - exit(1); - + + i = hashfunc(Ident); + while (1) { + /* We enforce the "hash table bigger than function table" rule, + so we know there will be at least one zero entry to find. */ + if (!function_hash[i]) + return (-1); + if (!strcasecmp(Ident, Functions[function_hash[i] - 1].Identifier)) + return ((int) Functions[function_hash[i] - 1].ID); + i = (i + 1) % HSIZE; } - for (i=ENTRIES (Functions)-1; i>=0; i--) - { - h = hashfunc (Functions[i].Identifier); - while (function_hash[h]) - h = (h + 1) % HSIZE; - function_hash[h] = i + 1; - } - } - - i = hashfunc (Ident); - while (1) - { - /* We enforce the "hash table bigger than function table" rule, - so we know there will be at least one zero entry to find. */ - if (!function_hash[i]) - return (-1); - if (!strcasecmp (Ident, Functions[function_hash[i]-1].Identifier)) - return ((int) Functions[function_hash[i]-1].ID); - i = (i + 1) % HSIZE; - } } /* --------------------------------------------------------------------------- @@ -876,167 +831,137 @@ * set new coordinates if in 'RECTANGLE' mode * the cursor shape is also adjusted */ -static void -AdjustAttachedBox (void) +static void AdjustAttachedBox(void) { - if (Settings.Mode == ARC_MODE) - { - Crosshair.AttachedBox.otherway = gui->shift_is_pressed (); - return; - } - switch (Crosshair.AttachedBox.State) - { - case STATE_SECOND: /* one corner is selected */ - { - /* update coordinates */ - Crosshair.AttachedBox.Point2.X = Crosshair.X; - Crosshair.AttachedBox.Point2.Y = Crosshair.Y; - break; - } - } + if (Settings.Mode == ARC_MODE) { + Crosshair.AttachedBox.otherway = gui->shift_is_pressed(); + return; + } + switch (Crosshair.AttachedBox.State) { + case STATE_SECOND: /* one corner is selected */ + { + /* update coordinates */ + Crosshair.AttachedBox.Point2.X = Crosshair.X; + Crosshair.AttachedBox.Point2.Y = Crosshair.Y; + break; + } + } } /* --------------------------------------------------------------------------- * adjusts the objects which are to be created like attached lines... */ -void -AdjustAttachedObjects (void) +void AdjustAttachedObjects(void) { - PointTypePtr pnt; - switch (Settings.Mode) - { - /* update at least an attached block (selection) */ - case NO_MODE: - case ARROW_MODE: - if (Crosshair.AttachedBox.State) - { - Crosshair.AttachedBox.Point2.X = Crosshair.X; - Crosshair.AttachedBox.Point2.Y = Crosshair.Y; - } - break; + PointTypePtr pnt; + switch (Settings.Mode) { + /* update at least an attached block (selection) */ + case NO_MODE: + case ARROW_MODE: + if (Crosshair.AttachedBox.State) { + Crosshair.AttachedBox.Point2.X = Crosshair.X; + Crosshair.AttachedBox.Point2.Y = Crosshair.Y; + } + break; - /* rectangle creation mode */ - case RECTANGLE_MODE: - case ARC_MODE: - AdjustAttachedBox (); - break; + /* rectangle creation mode */ + case RECTANGLE_MODE: + case ARC_MODE: + AdjustAttachedBox(); + break; - /* polygon creation mode */ - case POLYGON_MODE: - case POLYGONHOLE_MODE: - AdjustAttachedLine (); - break; - /* line creation mode */ - case LINE_MODE: - if (PCB->RatDraw || PCB->Clipping == 0) - AdjustAttachedLine (); - else - AdjustTwoLine (PCB->Clipping - 1); - break; - /* point insertion mode */ - case INSERTPOINT_MODE: - pnt = AdjustInsertPoint (); - if (pnt) - InsertedPoint = *pnt; - break; - case ROTATE_MODE: - break; - } + /* polygon creation mode */ + case POLYGON_MODE: + case POLYGONHOLE_MODE: + AdjustAttachedLine(); + break; + /* line creation mode */ + case LINE_MODE: + if (PCB->RatDraw || PCB->Clipping == 0) + AdjustAttachedLine(); + else + AdjustTwoLine(PCB->Clipping - 1); + break; + /* point insertion mode */ + case INSERTPOINT_MODE: + pnt = AdjustInsertPoint(); + if (pnt) + InsertedPoint = *pnt; + break; + case ROTATE_MODE: + break; + } } /* --------------------------------------------------------------------------- * creates points of a line */ -static void -NotifyLine (void) +static void NotifyLine(void) { - int type = NO_TYPE; - void *ptr1, *ptr2, *ptr3; + int type = NO_TYPE; + void *ptr1, *ptr2, *ptr3; - if (!Marked.status || TEST_FLAG (LOCALREFFLAG, PCB)) - SetLocalRef (Crosshair.X, Crosshair.Y, true); - switch (Crosshair.AttachedLine.State) - { - case STATE_FIRST: /* first point */ - if (PCB->RatDraw && SearchScreen (Crosshair.X, Crosshair.Y, - PAD_TYPE | PIN_TYPE, &ptr1, &ptr1, - &ptr1) == NO_TYPE) - { - gui->beep (); - break; + if (!Marked.status || TEST_FLAG(LOCALREFFLAG, PCB)) + SetLocalRef(Crosshair.X, Crosshair.Y, true); + switch (Crosshair.AttachedLine.State) { + case STATE_FIRST: /* first point */ + if (PCB->RatDraw && SearchScreen(Crosshair.X, Crosshair.Y, PAD_TYPE | PIN_TYPE, &ptr1, &ptr1, &ptr1) == NO_TYPE) { + gui->beep(); + break; + } + if (TEST_FLAG(AUTODRCFLAG, PCB) && Settings.Mode == LINE_MODE) { + type = SearchScreen(Crosshair.X, Crosshair.Y, PIN_TYPE | PAD_TYPE | VIA_TYPE, &ptr1, &ptr2, &ptr3); + LookupConnection(Crosshair.X, Crosshair.Y, true, 1, FOUNDFLAG); + } + if (type == PIN_TYPE || type == VIA_TYPE) { + Crosshair.AttachedLine.Point1.X = Crosshair.AttachedLine.Point2.X = ((PinTypePtr) ptr2)->X; + Crosshair.AttachedLine.Point1.Y = Crosshair.AttachedLine.Point2.Y = ((PinTypePtr) ptr2)->Y; + } + else if (type == PAD_TYPE) { + PadTypePtr pad = (PadTypePtr) ptr2; + double d1 = Distance(Crosshair.X, Crosshair.Y, pad->Point1.X, pad->Point1.Y); + double d2 = Distance(Crosshair.X, Crosshair.Y, pad->Point2.X, pad->Point2.Y); + if (d2 < d1) { + Crosshair.AttachedLine.Point1 = Crosshair.AttachedLine.Point2 = pad->Point2; + } + else { + Crosshair.AttachedLine.Point1 = Crosshair.AttachedLine.Point2 = pad->Point1; + } + } + else { + Crosshair.AttachedLine.Point1.X = Crosshair.AttachedLine.Point2.X = Crosshair.X; + Crosshair.AttachedLine.Point1.Y = Crosshair.AttachedLine.Point2.Y = Crosshair.Y; + } + Crosshair.AttachedLine.State = STATE_SECOND; + break; + + case STATE_SECOND: + /* fall through to third state too */ + lastLayer = CURRENT; + default: /* all following points */ + Crosshair.AttachedLine.State = STATE_THIRD; + break; } - if (TEST_FLAG (AUTODRCFLAG, PCB) && Settings.Mode == LINE_MODE) - { - type = SearchScreen (Crosshair.X, Crosshair.Y, - PIN_TYPE | PAD_TYPE | VIA_TYPE, &ptr1, &ptr2, - &ptr3); - LookupConnection (Crosshair.X, Crosshair.Y, true, 1, - FOUNDFLAG); - } - if (type == PIN_TYPE || type == VIA_TYPE) - { - Crosshair.AttachedLine.Point1.X = - Crosshair.AttachedLine.Point2.X = ((PinTypePtr) ptr2)->X; - Crosshair.AttachedLine.Point1.Y = - Crosshair.AttachedLine.Point2.Y = ((PinTypePtr) ptr2)->Y; - } - else if (type == PAD_TYPE) - { - PadTypePtr pad = (PadTypePtr) ptr2; - double d1 = Distance (Crosshair.X, Crosshair.Y, pad->Point1.X, pad->Point1.Y); - double d2 = Distance (Crosshair.X, Crosshair.Y, pad->Point2.X, pad->Point2.Y); - if (d2 < d1) - { - Crosshair.AttachedLine.Point1 = - Crosshair.AttachedLine.Point2 = pad->Point2; - } - else - { - Crosshair.AttachedLine.Point1 = - Crosshair.AttachedLine.Point2 = pad->Point1; - } - } - else - { - Crosshair.AttachedLine.Point1.X = - Crosshair.AttachedLine.Point2.X = Crosshair.X; - Crosshair.AttachedLine.Point1.Y = - Crosshair.AttachedLine.Point2.Y = Crosshair.Y; - } - Crosshair.AttachedLine.State = STATE_SECOND; - break; - - case STATE_SECOND: - /* fall through to third state too */ - lastLayer = CURRENT; - default: /* all following points */ - Crosshair.AttachedLine.State = STATE_THIRD; - break; - } } /* --------------------------------------------------------------------------- * create first or second corner of a marked block */ -static void -NotifyBlock (void) +static void NotifyBlock(void) { - notify_crosshair_change (false); - switch (Crosshair.AttachedBox.State) - { - case STATE_FIRST: /* setup first point */ - Crosshair.AttachedBox.Point1.X = - Crosshair.AttachedBox.Point2.X = Crosshair.X; - Crosshair.AttachedBox.Point1.Y = - Crosshair.AttachedBox.Point2.Y = Crosshair.Y; - Crosshair.AttachedBox.State = STATE_SECOND; - break; + notify_crosshair_change(false); + switch (Crosshair.AttachedBox.State) { + case STATE_FIRST: /* setup first point */ + Crosshair.AttachedBox.Point1.X = Crosshair.AttachedBox.Point2.X = Crosshair.X; + Crosshair.AttachedBox.Point1.Y = Crosshair.AttachedBox.Point2.Y = Crosshair.Y; + Crosshair.AttachedBox.State = STATE_SECOND; + break; - case STATE_SECOND: /* setup second point */ - Crosshair.AttachedBox.State = STATE_THIRD; - break; - } - notify_crosshair_change (true); + case STATE_SECOND: /* setup second point */ + Crosshair.AttachedBox.State = STATE_THIRD; + break; + } + notify_crosshair_change(true); } @@ -1047,809 +972,659 @@ * * new created objects are added to the create undo list of course */ -static void -NotifyMode (void) +static void NotifyMode(void) { - void *ptr1, *ptr2, *ptr3; - int type; + void *ptr1, *ptr2, *ptr3; + int type; - if (Settings.RatWarn) - ClearWarnings (); - switch (Settings.Mode) - { - case ARROW_MODE: - { - int test; - hidval hv; + if (Settings.RatWarn) + ClearWarnings(); + switch (Settings.Mode) { + case ARROW_MODE: + { + int test; + hidval hv; - Note.Click = true; - /* do something after click time */ - gui->add_timer (click_cb, CLICK_TIME, hv); + Note.Click = true; + /* do something after click time */ + gui->add_timer(click_cb, CLICK_TIME, hv); - /* see if we clicked on something already selected - * (Note.Moving) or clicked on a MOVE_TYPE - * (Note.Hit) - */ - for (test = (SELECT_TYPES | MOVE_TYPES) & ~RATLINE_TYPE; - test; test &= ~type) - { - type = SearchScreen (Note.X, Note.Y, test, &ptr1, &ptr2, &ptr3); - if (!Note.Hit && (type & MOVE_TYPES) && - !TEST_FLAG (LOCKFLAG, (PinTypePtr) ptr2)) - { - Note.Hit = type; - Note.ptr1 = ptr1; - Note.ptr2 = ptr2; - Note.ptr3 = ptr3; - } - if (!Note.Moving && (type & SELECT_TYPES) && - TEST_FLAG (SELECTEDFLAG, (PinTypePtr) ptr2)) - Note.Moving = true; - if ((Note.Hit && Note.Moving) || type == NO_TYPE) - break; - } - break; - } + /* see if we clicked on something already selected + * (Note.Moving) or clicked on a MOVE_TYPE + * (Note.Hit) + */ + for (test = (SELECT_TYPES | MOVE_TYPES) & ~RATLINE_TYPE; test; test &= ~type) { + type = SearchScreen(Note.X, Note.Y, test, &ptr1, &ptr2, &ptr3); + if (!Note.Hit && (type & MOVE_TYPES) && !TEST_FLAG(LOCKFLAG, (PinTypePtr) ptr2)) { + Note.Hit = type; + Note.ptr1 = ptr1; + Note.ptr2 = ptr2; + Note.ptr3 = ptr3; + } + if (!Note.Moving && (type & SELECT_TYPES) && TEST_FLAG(SELECTEDFLAG, (PinTypePtr) ptr2)) + Note.Moving = true; + if ((Note.Hit && Note.Moving) || type == NO_TYPE) + break; + } + break; + } - case VIA_MODE: - { - PinTypePtr via; + case VIA_MODE: + { + PinTypePtr via; - if (!PCB->ViaOn) - { - Message (_("You must turn via visibility on before\n" - "you can place vias\n")); - break; - } - if ((via = CreateNewVia (PCB->Data, Note.X, Note.Y, - Settings.ViaThickness, 2 * Settings.Keepaway, - 0, Settings.ViaDrillingHole, NULL, - NoFlags ())) != NULL) - { - AddObjectToCreateUndoList (VIA_TYPE, via, via, via); - if (gui->shift_is_pressed ()) - ChangeObjectThermal (VIA_TYPE, via, via, via, PCB->ThermStyle); - IncrementUndoSerialNumber (); - DrawVia (via); - Draw (); - } - break; - } + if (!PCB->ViaOn) { + Message(_("You must turn via visibility on before\n" "you can place vias\n")); + break; + } + if ((via = CreateNewVia(PCB->Data, Note.X, Note.Y, + Settings.ViaThickness, 2 * Settings.Keepaway, + 0, Settings.ViaDrillingHole, NULL, NoFlags())) != NULL) { + AddObjectToCreateUndoList(VIA_TYPE, via, via, via); + if (gui->shift_is_pressed()) + ChangeObjectThermal(VIA_TYPE, via, via, via, PCB->ThermStyle); + IncrementUndoSerialNumber(); + DrawVia(via); + Draw(); + } + break; + } - case ARC_MODE: - { - switch (Crosshair.AttachedBox.State) - { - case STATE_FIRST: - Crosshair.AttachedBox.Point1.X = - Crosshair.AttachedBox.Point2.X = Note.X; - Crosshair.AttachedBox.Point1.Y = - Crosshair.AttachedBox.Point2.Y = Note.Y; - Crosshair.AttachedBox.State = STATE_SECOND; - break; + case ARC_MODE: + { + switch (Crosshair.AttachedBox.State) { + case STATE_FIRST: + Crosshair.AttachedBox.Point1.X = Crosshair.AttachedBox.Point2.X = Note.X; + Crosshair.AttachedBox.Point1.Y = Crosshair.AttachedBox.Point2.Y = Note.Y; + Crosshair.AttachedBox.State = STATE_SECOND; + break; - case STATE_SECOND: - case STATE_THIRD: - { - ArcTypePtr arc; - Coord wx, wy; - Angle sa, dir; + case STATE_SECOND: + case STATE_THIRD: + { + ArcTypePtr arc; + Coord wx, wy; + Angle sa, dir; - wx = Note.X - Crosshair.AttachedBox.Point1.X; - wy = Note.Y - Crosshair.AttachedBox.Point1.Y; - if (XOR (Crosshair.AttachedBox.otherway, abs (wy) > abs (wx))) - { - Crosshair.AttachedBox.Point2.X = - Crosshair.AttachedBox.Point1.X + abs (wy) * SGNZ (wx); - sa = (wx >= 0) ? 0 : 180; + wx = Note.X - Crosshair.AttachedBox.Point1.X; + wy = Note.Y - Crosshair.AttachedBox.Point1.Y; + if (XOR(Crosshair.AttachedBox.otherway, abs(wy) > abs(wx))) { + Crosshair.AttachedBox.Point2.X = Crosshair.AttachedBox.Point1.X + abs(wy) * SGNZ(wx); + sa = (wx >= 0) ? 0 : 180; #ifdef ARC45 - if (abs (wy) / 2 >= abs (wx)) - dir = (SGNZ (wx) == SGNZ (wy)) ? 45 : -45; - else + if (abs(wy) / 2 >= abs(wx)) + dir = (SGNZ(wx) == SGNZ(wy)) ? 45 : -45; + else #endif - dir = (SGNZ (wx) == SGNZ (wy)) ? 90 : -90; - } - else - { - Crosshair.AttachedBox.Point2.Y = - Crosshair.AttachedBox.Point1.Y + abs (wx) * SGNZ (wy); - sa = (wy >= 0) ? -90 : 90; + dir = (SGNZ(wx) == SGNZ(wy)) ? 90 : -90; + } + else { + Crosshair.AttachedBox.Point2.Y = Crosshair.AttachedBox.Point1.Y + abs(wx) * SGNZ(wy); + sa = (wy >= 0) ? -90 : 90; #ifdef ARC45 - if (abs (wx) / 2 >= abs (wy)) - dir = (SGNZ (wx) == SGNZ (wy)) ? -45 : 45; - else + if (abs(wx) / 2 >= abs(wy)) + dir = (SGNZ(wx) == SGNZ(wy)) ? -45 : 45; + else #endif - dir = (SGNZ (wx) == SGNZ (wy)) ? -90 : 90; - wy = wx; + dir = (SGNZ(wx) == SGNZ(wy)) ? -90 : 90; + wy = wx; + } + if (abs(wy) > 0 && (arc = CreateNewArcOnLayer(CURRENT, + Crosshair.AttachedBox.Point2.X, + Crosshair.AttachedBox.Point2.Y, + abs(wy), + abs(wy), + sa, + dir, + Settings.LineThickness, + 2 * Settings.Keepaway, + MakeFlags(TEST_FLAG(CLEARNEWFLAG, PCB) ? CLEARLINEFLAG : 0)))) { + BoxTypePtr bx; + + bx = GetArcEnds(arc); + Crosshair.AttachedBox.Point1.X = Crosshair.AttachedBox.Point2.X = bx->X2; + Crosshair.AttachedBox.Point1.Y = Crosshair.AttachedBox.Point2.Y = bx->Y2; + AddObjectToCreateUndoList(ARC_TYPE, CURRENT, arc, arc); + IncrementUndoSerialNumber(); + addedLines++; + DrawArc(CURRENT, arc); + Draw(); + Crosshair.AttachedBox.State = STATE_THIRD; + } + break; + } + } + break; } - if (abs (wy) > 0 && (arc = CreateNewArcOnLayer (CURRENT, - Crosshair. - AttachedBox. - Point2.X, - Crosshair. - AttachedBox. - Point2.Y, - abs (wy), - abs (wy), - sa, - dir, - Settings. - LineThickness, - 2 * Settings. - Keepaway, - MakeFlags - (TEST_FLAG - (CLEARNEWFLAG, - PCB) ? - CLEARLINEFLAG : - 0)))) + case LOCK_MODE: { - BoxTypePtr bx; + type = SearchScreen(Note.X, Note.Y, LOCK_TYPES, &ptr1, &ptr2, &ptr3); + if (type == ELEMENT_TYPE) { + ElementTypePtr element = (ElementTypePtr) ptr2; - bx = GetArcEnds (arc); - Crosshair.AttachedBox.Point1.X = - Crosshair.AttachedBox.Point2.X = bx->X2; - Crosshair.AttachedBox.Point1.Y = - Crosshair.AttachedBox.Point2.Y = bx->Y2; - AddObjectToCreateUndoList (ARC_TYPE, CURRENT, arc, arc); - IncrementUndoSerialNumber (); - addedLines++; - DrawArc (CURRENT, arc); - Draw (); - Crosshair.AttachedBox.State = STATE_THIRD; + TOGGLE_FLAG(LOCKFLAG, element); + PIN_LOOP(element); + { + TOGGLE_FLAG(LOCKFLAG, pin); + CLEAR_FLAG(SELECTEDFLAG, pin); + } + END_LOOP; + PAD_LOOP(element); + { + TOGGLE_FLAG(LOCKFLAG, pad); + CLEAR_FLAG(SELECTEDFLAG, pad); + } + END_LOOP; + CLEAR_FLAG(SELECTEDFLAG, element); + /* always re-draw it since I'm too lazy + * to tell if a selected flag changed + */ + DrawElement(element); + Draw(); + hid_actionl("Report", "Object", NULL); + } + else if (type != NO_TYPE) { + TextTypePtr thing = (TextTypePtr) ptr3; + TOGGLE_FLAG(LOCKFLAG, thing); + if (TEST_FLAG(LOCKFLAG, thing) + && TEST_FLAG(SELECTEDFLAG, thing)) { + /* this is not un-doable since LOCK isn't */ + CLEAR_FLAG(SELECTEDFLAG, thing); + DrawObject(type, ptr1, ptr2); + Draw(); + } + hid_actionl("Report", "Object", NULL); + } + break; } - break; - } - } - break; - } - case LOCK_MODE: - { - type = SearchScreen (Note.X, Note.Y, LOCK_TYPES, &ptr1, &ptr2, &ptr3); - if (type == ELEMENT_TYPE) - { - ElementTypePtr element = (ElementTypePtr) ptr2; + case THERMAL_MODE: + { + if (((type = SearchScreen(Note.X, Note.Y, PIN_TYPES, &ptr1, &ptr2, &ptr3)) != NO_TYPE) + && !TEST_FLAG(HOLEFLAG, (PinTypePtr) ptr3)) { + if (gui->shift_is_pressed()) { + int tstyle = GET_THERM(INDEXOFCURRENT, (PinTypePtr) ptr3); + tstyle++; + if (tstyle > 5) + tstyle = 1; + ChangeObjectThermal(type, ptr1, ptr2, ptr3, tstyle); + } + else if (GET_THERM(INDEXOFCURRENT, (PinTypePtr) ptr3)) + ChangeObjectThermal(type, ptr1, ptr2, ptr3, 0); + else + ChangeObjectThermal(type, ptr1, ptr2, ptr3, PCB->ThermStyle); + } + break; + } - TOGGLE_FLAG (LOCKFLAG, element); - PIN_LOOP (element); - { - TOGGLE_FLAG (LOCKFLAG, pin); - CLEAR_FLAG (SELECTEDFLAG, pin); - } - END_LOOP; - PAD_LOOP (element); - { - TOGGLE_FLAG (LOCKFLAG, pad); - CLEAR_FLAG (SELECTEDFLAG, pad); - } - END_LOOP; - CLEAR_FLAG (SELECTEDFLAG, element); - /* always re-draw it since I'm too lazy - * to tell if a selected flag changed - */ - DrawElement (element); - Draw (); - hid_actionl ("Report", "Object", NULL); - } - else if (type != NO_TYPE) - { - TextTypePtr thing = (TextTypePtr) ptr3; - TOGGLE_FLAG (LOCKFLAG, thing); - if (TEST_FLAG (LOCKFLAG, thing) - && TEST_FLAG (SELECTEDFLAG, thing)) - { - /* this is not un-doable since LOCK isn't */ - CLEAR_FLAG (SELECTEDFLAG, thing); - DrawObject (type, ptr1, ptr2); - Draw (); - } - hid_actionl ("Report", "Object", NULL); - } - break; - } - case THERMAL_MODE: - { - if (((type - = - SearchScreen (Note.X, Note.Y, PIN_TYPES, &ptr1, &ptr2, - &ptr3)) != NO_TYPE) - && !TEST_FLAG (HOLEFLAG, (PinTypePtr) ptr3)) - { - if (gui->shift_is_pressed ()) - { - int tstyle = GET_THERM (INDEXOFCURRENT, (PinTypePtr) ptr3); - tstyle++; - if (tstyle > 5) - tstyle = 1; - ChangeObjectThermal (type, ptr1, ptr2, ptr3, tstyle); - } - else if (GET_THERM (INDEXOFCURRENT, (PinTypePtr) ptr3)) - ChangeObjectThermal (type, ptr1, ptr2, ptr3, 0); - else - ChangeObjectThermal (type, ptr1, ptr2, ptr3, PCB->ThermStyle); - } - break; - } + case LINE_MODE: + /* do update of position */ + NotifyLine(); + if (Crosshair.AttachedLine.State != STATE_THIRD) + break; - case LINE_MODE: - /* do update of position */ - NotifyLine (); - if (Crosshair.AttachedLine.State != STATE_THIRD) - break; + /* Remove anchor if clicking on start point; + * this means we can't paint 0 length lines + * which could be used for square SMD pads. + * Instead use a very small delta, or change + * the file after saving. + */ + if (Crosshair.X == Crosshair.AttachedLine.Point1.X && Crosshair.Y == Crosshair.AttachedLine.Point1.Y) { + SetMode(LINE_MODE); + break; + } - /* Remove anchor if clicking on start point; - * this means we can't paint 0 length lines - * which could be used for square SMD pads. - * Instead use a very small delta, or change - * the file after saving. - */ - if (Crosshair.X == Crosshair.AttachedLine.Point1.X - && Crosshair.Y == Crosshair.AttachedLine.Point1.Y) - { - SetMode (LINE_MODE); - break; - } + if (PCB->RatDraw) { + RatTypePtr line; + if ((line = AddNet())) { + addedLines++; + AddObjectToCreateUndoList(RATLINE_TYPE, line, line, line); + IncrementUndoSerialNumber(); + DrawRat(line); + Crosshair.AttachedLine.Point1.X = Crosshair.AttachedLine.Point2.X; + Crosshair.AttachedLine.Point1.Y = Crosshair.AttachedLine.Point2.Y; + Draw(); + } + break; + } + else + /* create line if both ends are determined && length != 0 */ + { + LineTypePtr line; + int maybe_found_flag; - if (PCB->RatDraw) - { - RatTypePtr line; - if ((line = AddNet ())) - { - addedLines++; - AddObjectToCreateUndoList (RATLINE_TYPE, line, line, line); - IncrementUndoSerialNumber (); - DrawRat (line); - Crosshair.AttachedLine.Point1.X = - Crosshair.AttachedLine.Point2.X; - Crosshair.AttachedLine.Point1.Y = - Crosshair.AttachedLine.Point2.Y; - Draw (); - } - break; - } - else - /* create line if both ends are determined && length != 0 */ - { - LineTypePtr line; - int maybe_found_flag; + if (PCB->Clipping + && Crosshair.AttachedLine.Point1.X == + Crosshair.AttachedLine.Point2.X + && Crosshair.AttachedLine.Point1.Y == + Crosshair.AttachedLine.Point2.Y + && (Crosshair.AttachedLine.Point2.X != Note.X || Crosshair.AttachedLine.Point2.Y != Note.Y)) { + /* We will only need to paint the second line segment. + Since we only check for vias on the first segment, + swap them so the non-empty segment is the first segment. */ + Crosshair.AttachedLine.Point2.X = Note.X; + Crosshair.AttachedLine.Point2.Y = Note.Y; + } - if (PCB->Clipping - && Crosshair.AttachedLine.Point1.X == - Crosshair.AttachedLine.Point2.X - && Crosshair.AttachedLine.Point1.Y == - Crosshair.AttachedLine.Point2.Y - && (Crosshair.AttachedLine.Point2.X != Note.X - || Crosshair.AttachedLine.Point2.Y != Note.Y)) - { - /* We will only need to paint the second line segment. - Since we only check for vias on the first segment, - swap them so the non-empty segment is the first segment. */ - Crosshair.AttachedLine.Point2.X = Note.X; - Crosshair.AttachedLine.Point2.Y = Note.Y; - } + if (TEST_FLAG(AUTODRCFLAG, PCB) + && !TEST_SILK_LAYER(CURRENT)) + maybe_found_flag = FOUNDFLAG; + else + maybe_found_flag = 0; - if (TEST_FLAG (AUTODRCFLAG, PCB) - && ! TEST_SILK_LAYER (CURRENT)) - maybe_found_flag = FOUNDFLAG; - else - maybe_found_flag = 0; + if ((Crosshair.AttachedLine.Point1.X != + Crosshair.AttachedLine.Point2.X || Crosshair.AttachedLine.Point1.Y != Crosshair.AttachedLine.Point2.Y) + && (line = + CreateDrawnLineOnLayer(CURRENT, + Crosshair.AttachedLine.Point1.X, + Crosshair.AttachedLine.Point1.Y, + Crosshair.AttachedLine.Point2.X, + Crosshair.AttachedLine.Point2.Y, + Settings.LineThickness, + 2 * Settings.Keepaway, + MakeFlags(maybe_found_flag | + (TEST_FLAG(CLEARNEWFLAG, PCB) ? CLEARLINEFLAG : 0)))) != NULL) { + PinTypePtr via; - if ((Crosshair.AttachedLine.Point1.X != - Crosshair.AttachedLine.Point2.X - || Crosshair.AttachedLine.Point1.Y != - Crosshair.AttachedLine.Point2.Y) - && (line = - CreateDrawnLineOnLayer (CURRENT, - Crosshair.AttachedLine.Point1.X, - Crosshair.AttachedLine.Point1.Y, - Crosshair.AttachedLine.Point2.X, - Crosshair.AttachedLine.Point2.Y, - Settings.LineThickness, - 2 * Settings.Keepaway, - MakeFlags (maybe_found_flag | - (TEST_FLAG - (CLEARNEWFLAG, - PCB) ? CLEARLINEFLAG : - 0)))) != NULL) - { - PinTypePtr via; - - addedLines++; - AddObjectToCreateUndoList (LINE_TYPE, CURRENT, line, line); - DrawLine (CURRENT, line); - /* place a via if vias are visible, the layer is - in a new group since the last line and there - isn't a pin already here */ - if (PCB->ViaOn && GetLayerGroupNumberByPointer (CURRENT) != - GetLayerGroupNumberByPointer (lastLayer) && - SearchObjectByLocation (PIN_TYPES, &ptr1, &ptr2, &ptr3, - Crosshair.AttachedLine.Point1.X, - Crosshair.AttachedLine.Point1.Y, - Settings.ViaThickness / 2) == - NO_TYPE - && (via = - CreateNewVia (PCB->Data, - Crosshair.AttachedLine.Point1.X, - Crosshair.AttachedLine.Point1.Y, - Settings.ViaThickness, - 2 * Settings.Keepaway, 0, - Settings.ViaDrillingHole, NULL, - NoFlags ())) != NULL) - { - AddObjectToCreateUndoList (VIA_TYPE, via, via, via); - DrawVia (via); + addedLines++; + AddObjectToCreateUndoList(LINE_TYPE, CURRENT, line, line); + DrawLine(CURRENT, line); + /* place a via if vias are visible, the layer is + in a new group since the last line and there + isn't a pin already here */ + if (PCB->ViaOn && GetLayerGroupNumberByPointer(CURRENT) != + GetLayerGroupNumberByPointer(lastLayer) && + SearchObjectByLocation(PIN_TYPES, &ptr1, &ptr2, &ptr3, + Crosshair.AttachedLine.Point1.X, + Crosshair.AttachedLine.Point1.Y, + Settings.ViaThickness / 2) == + NO_TYPE + && (via = + CreateNewVia(PCB->Data, + Crosshair.AttachedLine.Point1.X, + Crosshair.AttachedLine.Point1.Y, + Settings.ViaThickness, + 2 * Settings.Keepaway, 0, Settings.ViaDrillingHole, NULL, NoFlags())) != NULL) { + AddObjectToCreateUndoList(VIA_TYPE, via, via, via); + DrawVia(via); + } + /* copy the coordinates */ + Crosshair.AttachedLine.Point1.X = Crosshair.AttachedLine.Point2.X; + Crosshair.AttachedLine.Point1.Y = Crosshair.AttachedLine.Point2.Y; + IncrementUndoSerialNumber(); + lastLayer = CURRENT; + } + if (PCB->Clipping && (Note.X != Crosshair.AttachedLine.Point2.X || Note.Y != Crosshair.AttachedLine.Point2.Y) + && (line = + CreateDrawnLineOnLayer(CURRENT, + Crosshair.AttachedLine.Point2.X, + Crosshair.AttachedLine.Point2.Y, + Note.X, Note.Y, + Settings.LineThickness, + 2 * Settings.Keepaway, + MakeFlags((TEST_FLAG + (AUTODRCFLAG, + PCB) ? FOUNDFLAG : 0) | + (TEST_FLAG(CLEARNEWFLAG, PCB) ? CLEARLINEFLAG : 0)))) != NULL) { + addedLines++; + AddObjectToCreateUndoList(LINE_TYPE, CURRENT, line, line); + IncrementUndoSerialNumber(); + DrawLine(CURRENT, line); + /* move to new start point */ + Crosshair.AttachedLine.Point1.X = Note.X; + Crosshair.AttachedLine.Point1.Y = Note.Y; + Crosshair.AttachedLine.Point2.X = Note.X; + Crosshair.AttachedLine.Point2.Y = Note.Y; + if (TEST_FLAG(SWAPSTARTDIRFLAG, PCB)) { + PCB->Clipping ^= 3; + } + } + Draw(); } - /* copy the coordinates */ - Crosshair.AttachedLine.Point1.X = - Crosshair.AttachedLine.Point2.X; - Crosshair.AttachedLine.Point1.Y = - Crosshair.AttachedLine.Point2.Y; - IncrementUndoSerialNumber (); - lastLayer = CURRENT; - } - if (PCB->Clipping && (Note.X != Crosshair.AttachedLine.Point2.X - || Note.Y != - Crosshair.AttachedLine.Point2.Y) - && (line = - CreateDrawnLineOnLayer (CURRENT, - Crosshair.AttachedLine.Point2.X, - Crosshair.AttachedLine.Point2.Y, - Note.X, Note.Y, - Settings.LineThickness, - 2 * Settings.Keepaway, - MakeFlags ((TEST_FLAG - (AUTODRCFLAG, - PCB) ? FOUNDFLAG : 0) | - (TEST_FLAG - (CLEARNEWFLAG, - PCB) ? CLEARLINEFLAG : - 0)))) != NULL) - { - addedLines++; - AddObjectToCreateUndoList (LINE_TYPE, CURRENT, line, line); - IncrementUndoSerialNumber (); - DrawLine (CURRENT, line); - /* move to new start point */ - Crosshair.AttachedLine.Point1.X = Note.X; - Crosshair.AttachedLine.Point1.Y = Note.Y; - Crosshair.AttachedLine.Point2.X = Note.X; - Crosshair.AttachedLine.Point2.Y = Note.Y; - if (TEST_FLAG (SWAPSTARTDIRFLAG, PCB)) - { - PCB->Clipping ^= 3; - } - } - Draw (); - } - break; + break; - case RECTANGLE_MODE: - /* do update of position */ - NotifyBlock (); + case RECTANGLE_MODE: + /* do update of position */ + NotifyBlock(); - /* create rectangle if both corners are determined - * and width, height are != 0 - */ - if (Crosshair.AttachedBox.State == STATE_THIRD && - Crosshair.AttachedBox.Point1.X != Crosshair.AttachedBox.Point2.X && - Crosshair.AttachedBox.Point1.Y != Crosshair.AttachedBox.Point2.Y) - { - PolygonTypePtr polygon; + /* create rectangle if both corners are determined + * and width, height are != 0 + */ + if (Crosshair.AttachedBox.State == STATE_THIRD && + Crosshair.AttachedBox.Point1.X != Crosshair.AttachedBox.Point2.X && + Crosshair.AttachedBox.Point1.Y != Crosshair.AttachedBox.Point2.Y) { + PolygonTypePtr polygon; - int flags = CLEARPOLYFLAG; - if (TEST_FLAG (NEWFULLPOLYFLAG, PCB)) - flags |= FULLPOLYFLAG; - if ((polygon = CreateNewPolygonFromRectangle (CURRENT, - Crosshair. - AttachedBox.Point1.X, - Crosshair. - AttachedBox.Point1.Y, - Crosshair. - AttachedBox.Point2.X, - Crosshair. - AttachedBox.Point2.Y, - MakeFlags - (flags))) != - NULL) - { - AddObjectToCreateUndoList (POLYGON_TYPE, CURRENT, - polygon, polygon); - IncrementUndoSerialNumber (); - DrawPolygon (CURRENT, polygon); - Draw (); - } + int flags = CLEARPOLYFLAG; + if (TEST_FLAG(NEWFULLPOLYFLAG, PCB)) + flags |= FULLPOLYFLAG; + if ((polygon = CreateNewPolygonFromRectangle(CURRENT, + Crosshair.AttachedBox.Point1.X, + Crosshair.AttachedBox.Point1.Y, + Crosshair.AttachedBox.Point2.X, + Crosshair.AttachedBox.Point2.Y, MakeFlags(flags))) != NULL) { + AddObjectToCreateUndoList(POLYGON_TYPE, CURRENT, polygon, polygon); + IncrementUndoSerialNumber(); + DrawPolygon(CURRENT, polygon); + Draw(); + } - /* reset state to 'first corner' */ - Crosshair.AttachedBox.State = STATE_FIRST; - } - break; + /* reset state to 'first corner' */ + Crosshair.AttachedBox.State = STATE_FIRST; + } + break; - case TEXT_MODE: - { - char *string; + case TEXT_MODE: + { + char *string; - if ((string = gui->prompt_for (_("Enter text:"), "")) != NULL) - { - if (strlen(string) > 0) - { - TextTypePtr text; - int flag = CLEARLINEFLAG; + if ((string = gui->prompt_for(_("Enter text:"), "")) != NULL) { + if (strlen(string) > 0) { + TextTypePtr text; + int flag = CLEARLINEFLAG; - if (GetLayerGroupNumberByNumber (INDEXOFCURRENT) == - GetLayerGroupNumberByNumber (solder_silk_layer)) - flag |= ONSOLDERFLAG; - if ((text = CreateNewText (CURRENT, &PCB->Font, Note.X, - Note.Y, 0, Settings.TextScale, - string, MakeFlags (flag))) != NULL) - { - AddObjectToCreateUndoList (TEXT_TYPE, CURRENT, text, text); - IncrementUndoSerialNumber (); - DrawText (CURRENT, text); - Draw (); - } + if (GetLayerGroupNumberByNumber(INDEXOFCURRENT) == GetLayerGroupNumberByNumber(solder_silk_layer)) + flag |= ONSOLDERFLAG; + if ((text = CreateNewText(CURRENT, &PCB->Font, Note.X, + Note.Y, 0, Settings.TextScale, string, MakeFlags(flag))) != NULL) { + AddObjectToCreateUndoList(TEXT_TYPE, CURRENT, text, text); + IncrementUndoSerialNumber(); + DrawText(CURRENT, text); + Draw(); + } + } + free(string); + } + break; } - free (string); - } - break; - } - case POLYGON_MODE: - { - PointTypePtr points = Crosshair.AttachedPolygon.Points; - Cardinal n = Crosshair.AttachedPolygon.PointN; + case POLYGON_MODE: + { + PointTypePtr points = Crosshair.AttachedPolygon.Points; + Cardinal n = Crosshair.AttachedPolygon.PointN; - /* do update of position; use the 'LINE_MODE' mechanism */ - NotifyLine (); + /* do update of position; use the 'LINE_MODE' mechanism */ + NotifyLine(); - /* check if this is the last point of a polygon */ - if (n >= 3 && - points->X == Crosshair.AttachedLine.Point2.X && - points->Y == Crosshair.AttachedLine.Point2.Y) - { - CopyAttachedPolygonToLayer (); - Draw (); - break; - } + /* check if this is the last point of a polygon */ + if (n >= 3 && points->X == Crosshair.AttachedLine.Point2.X && points->Y == Crosshair.AttachedLine.Point2.Y) { + CopyAttachedPolygonToLayer(); + Draw(); + break; + } - /* create new point if it's the first one or if it's - * different to the last one - */ - if (!n || - points[n - 1].X != Crosshair.AttachedLine.Point2.X || - points[n - 1].Y != Crosshair.AttachedLine.Point2.Y) - { - CreateNewPointInPolygon (&Crosshair.AttachedPolygon, - Crosshair.AttachedLine.Point2.X, - Crosshair.AttachedLine.Point2.Y); + /* create new point if it's the first one or if it's + * different to the last one + */ + if (!n || points[n - 1].X != Crosshair.AttachedLine.Point2.X || points[n - 1].Y != Crosshair.AttachedLine.Point2.Y) { + CreateNewPointInPolygon(&Crosshair.AttachedPolygon, Crosshair.AttachedLine.Point2.X, Crosshair.AttachedLine.Point2.Y); - /* copy the coordinates */ - Crosshair.AttachedLine.Point1.X = Crosshair.AttachedLine.Point2.X; - Crosshair.AttachedLine.Point1.Y = Crosshair.AttachedLine.Point2.Y; - } - break; - } + /* copy the coordinates */ + Crosshair.AttachedLine.Point1.X = Crosshair.AttachedLine.Point2.X; + Crosshair.AttachedLine.Point1.Y = Crosshair.AttachedLine.Point2.Y; + } + break; + } - case POLYGONHOLE_MODE: - { - switch (Crosshair.AttachedObject.State) - { - /* first notify, lookup object */ - case STATE_FIRST: - Crosshair.AttachedObject.Type = - SearchScreen (Note.X, Note.Y, POLYGON_TYPE, - &Crosshair.AttachedObject.Ptr1, - &Crosshair.AttachedObject.Ptr2, - &Crosshair.AttachedObject.Ptr3); + case POLYGONHOLE_MODE: + { + switch (Crosshair.AttachedObject.State) { + /* first notify, lookup object */ + case STATE_FIRST: + Crosshair.AttachedObject.Type = + SearchScreen(Note.X, Note.Y, POLYGON_TYPE, + &Crosshair.AttachedObject.Ptr1, &Crosshair.AttachedObject.Ptr2, &Crosshair.AttachedObject.Ptr3); - if (Crosshair.AttachedObject.Type != NO_TYPE) - { - if (TEST_FLAG (LOCKFLAG, (PolygonTypePtr) - Crosshair.AttachedObject.Ptr2)) - { - Message (_("Sorry, the object is locked\n")); - Crosshair.AttachedObject.Type = NO_TYPE; - break; - } - else - Crosshair.AttachedObject.State = STATE_SECOND; - } - break; + if (Crosshair.AttachedObject.Type != NO_TYPE) { + if (TEST_FLAG(LOCKFLAG, (PolygonTypePtr) + Crosshair.AttachedObject.Ptr2)) { + Message(_("Sorry, the object is locked\n")); + Crosshair.AttachedObject.Type = NO_TYPE; + break; + } + else + Crosshair.AttachedObject.State = STATE_SECOND; + } + break; - /* second notify, insert new point into object */ - case STATE_SECOND: - { - PointTypePtr points = Crosshair.AttachedPolygon.Points; - Cardinal n = Crosshair.AttachedPolygon.PointN; - POLYAREA *original, *new_hole, *result; - FlagType Flags; + /* second notify, insert new point into object */ + case STATE_SECOND: + { + PointTypePtr points = Crosshair.AttachedPolygon.Points; + Cardinal n = Crosshair.AttachedPolygon.PointN; + POLYAREA *original, *new_hole, *result; + FlagType Flags; - /* do update of position; use the 'LINE_MODE' mechanism */ - NotifyLine (); + /* do update of position; use the 'LINE_MODE' mechanism */ + NotifyLine(); - /* check if this is the last point of a polygon */ - if (n >= 3 && - points->X == Crosshair.AttachedLine.Point2.X && - points->Y == Crosshair.AttachedLine.Point2.Y) - { - /* Create POLYAREAs from the original polygon - * and the new hole polygon */ - original = PolygonToPoly ((PolygonType *)Crosshair.AttachedObject.Ptr2); - new_hole = PolygonToPoly (&Crosshair.AttachedPolygon); + /* check if this is the last point of a polygon */ + if (n >= 3 && points->X == Crosshair.AttachedLine.Point2.X && points->Y == Crosshair.AttachedLine.Point2.Y) { + /* Create POLYAREAs from the original polygon + * and the new hole polygon */ + original = PolygonToPoly((PolygonType *) Crosshair.AttachedObject.Ptr2); + new_hole = PolygonToPoly(&Crosshair.AttachedPolygon); - /* Subtract the hole from the original polygon shape */ - poly_Boolean_free (original, new_hole, &result, PBO_SUB); + /* Subtract the hole from the original polygon shape */ + poly_Boolean_free(original, new_hole, &result, PBO_SUB); - /* Convert the resulting polygon(s) into a new set of nodes - * and place them on the page. Delete the original polygon. - */ - SaveUndoSerialNumber (); - Flags = ((PolygonType *)Crosshair.AttachedObject.Ptr2)->Flags; - PolyToPolygonsOnLayer (PCB->Data, (LayerType *)Crosshair.AttachedObject.Ptr1, - result, Flags); - RemoveObject (POLYGON_TYPE, - Crosshair.AttachedObject.Ptr1, - Crosshair.AttachedObject.Ptr2, - Crosshair.AttachedObject.Ptr3); - RestoreUndoSerialNumber (); - IncrementUndoSerialNumber (); - Draw (); + /* Convert the resulting polygon(s) into a new set of nodes + * and place them on the page. Delete the original polygon. + */ + SaveUndoSerialNumber(); + Flags = ((PolygonType *) Crosshair.AttachedObject.Ptr2)->Flags; + PolyToPolygonsOnLayer(PCB->Data, (LayerType *) Crosshair.AttachedObject.Ptr1, result, Flags); + RemoveObject(POLYGON_TYPE, + Crosshair.AttachedObject.Ptr1, Crosshair.AttachedObject.Ptr2, Crosshair.AttachedObject.Ptr3); + RestoreUndoSerialNumber(); + IncrementUndoSerialNumber(); + Draw(); - /* reset state of attached line */ - memset (&Crosshair.AttachedPolygon, 0, sizeof (PolygonType)); - Crosshair.AttachedLine.State = STATE_FIRST; - addedLines = 0; + /* reset state of attached line */ + memset(&Crosshair.AttachedPolygon, 0, sizeof(PolygonType)); + Crosshair.AttachedLine.State = STATE_FIRST; + addedLines = 0; - break; - } + break; + } - /* create new point if it's the first one or if it's - * different to the last one - */ - if (!n || - points[n - 1].X != Crosshair.AttachedLine.Point2.X || - points[n - 1].Y != Crosshair.AttachedLine.Point2.Y) - { - CreateNewPointInPolygon (&Crosshair.AttachedPolygon, - Crosshair.AttachedLine.Point2.X, - Crosshair.AttachedLine.Point2.Y); + /* create new point if it's the first one or if it's + * different to the last one + */ + if (!n || points[n - 1].X != Crosshair.AttachedLine.Point2.X || points[n - 1].Y != Crosshair.AttachedLine.Point2.Y) { + CreateNewPointInPolygon(&Crosshair.AttachedPolygon, + Crosshair.AttachedLine.Point2.X, Crosshair.AttachedLine.Point2.Y); - /* copy the coordinates */ - Crosshair.AttachedLine.Point1.X = Crosshair.AttachedLine.Point2.X; - Crosshair.AttachedLine.Point1.Y = Crosshair.AttachedLine.Point2.Y; + /* copy the coordinates */ + Crosshair.AttachedLine.Point1.X = Crosshair.AttachedLine.Point2.X; + Crosshair.AttachedLine.Point1.Y = Crosshair.AttachedLine.Point2.Y; + } + break; + } + } + + break; } - break; - } - } - break; - } + case PASTEBUFFER_MODE: + { + TextType estr[MAX_ELEMENTNAMES]; + ElementTypePtr e = 0; - case PASTEBUFFER_MODE: - { - TextType estr[MAX_ELEMENTNAMES]; - ElementTypePtr e = 0; + if (gui->shift_is_pressed()) { + int type = SearchScreen(Note.X, Note.Y, ELEMENT_TYPE, &ptr1, &ptr2, + &ptr3); + if (type == ELEMENT_TYPE) { + e = (ElementTypePtr) ptr1; + if (e) { + int i; - if (gui->shift_is_pressed ()) - { - int type = - SearchScreen (Note.X, Note.Y, ELEMENT_TYPE, &ptr1, &ptr2, - &ptr3); - if (type == ELEMENT_TYPE) - { - e = (ElementTypePtr) ptr1; - if (e) - { - int i; + memcpy(estr, e->Name, MAX_ELEMENTNAMES * sizeof(TextType)); + for (i = 0; i < MAX_ELEMENTNAMES; ++i) + estr[i].TextString = estr[i].TextString ? strdup(estr[i].TextString) : NULL; + RemoveElement(e); + } + } + } + if (CopyPastebufferToLayout(Note.X, Note.Y)) + SetChangedFlag(true); + if (e) { + int type = SearchScreen(Note.X, Note.Y, ELEMENT_TYPE, &ptr1, &ptr2, + &ptr3); + if (type == ELEMENT_TYPE && ptr1) { + int i, save_n; + e = (ElementTypePtr) ptr1; - memcpy (estr, e->Name, - MAX_ELEMENTNAMES * sizeof (TextType)); - for (i = 0; i < MAX_ELEMENTNAMES; ++i) - estr[i].TextString = estr[i].TextString ? strdup(estr[i].TextString) : NULL; - RemoveElement (e); - } - } - } - if (CopyPastebufferToLayout (Note.X, Note.Y)) - SetChangedFlag (true); - if (e) - { - int type = - SearchScreen (Note.X, Note.Y, ELEMENT_TYPE, &ptr1, &ptr2, - &ptr3); - if (type == ELEMENT_TYPE && ptr1) - { - int i, save_n; - e = (ElementTypePtr) ptr1; + save_n = NAME_INDEX(PCB); - save_n = NAME_INDEX (PCB); + for (i = 0; i < MAX_ELEMENTNAMES; i++) { + if (i == save_n) + EraseElementName(e); + r_delete_entry(PCB->Data->name_tree[i], (BoxType *) & (e->Name[i])); + memcpy(&(e->Name[i]), &(estr[i]), sizeof(TextType)); + e->Name[i].Element = e; + SetTextBoundingBox(&PCB->Font, &(e->Name[i])); + r_insert_entry(PCB->Data->name_tree[i], (BoxType *) & (e->Name[i]), 0); + if (i == save_n) + DrawElementName(e); + } + } + } + break; + } - for (i = 0; i < MAX_ELEMENTNAMES; i++) - { - if (i == save_n) - EraseElementName (e); - r_delete_entry (PCB->Data->name_tree[i], - (BoxType *) & (e->Name[i])); - memcpy (&(e->Name[i]), &(estr[i]), sizeof (TextType)); - e->Name[i].Element = e; - SetTextBoundingBox (&PCB->Font, &(e->Name[i])); - r_insert_entry (PCB->Data->name_tree[i], - (BoxType *) & (e->Name[i]), 0); - if (i == save_n) - DrawElementName (e); - } - } - } - break; - } + case REMOVE_MODE: + if ((type = SearchScreen(Note.X, Note.Y, REMOVE_TYPES, &ptr1, &ptr2, &ptr3)) != NO_TYPE) { + if (TEST_FLAG(LOCKFLAG, (LineTypePtr) ptr2)) { + Message(_("Sorry, the object is locked\n")); + break; + } + if (type == ELEMENT_TYPE) { + RubberbandTypePtr ptr; + int i; - case REMOVE_MODE: - if ((type = - SearchScreen (Note.X, Note.Y, REMOVE_TYPES, &ptr1, &ptr2, - &ptr3)) != NO_TYPE) - { - if (TEST_FLAG (LOCKFLAG, (LineTypePtr) ptr2)) - { - Message (_("Sorry, the object is locked\n")); - break; - } - if (type == ELEMENT_TYPE) - { - RubberbandTypePtr ptr; - int i; - - Crosshair.AttachedObject.RubberbandN = 0; - LookupRatLines (type, ptr1, ptr2, ptr3); - ptr = Crosshair.AttachedObject.Rubberband; - for (i = 0; i < Crosshair.AttachedObject.RubberbandN; i++) - { - if (PCB->RatOn) - EraseRat ((RatTypePtr) ptr->Line); - if (TEST_FLAG (RUBBERENDFLAG, ptr->Line)) - MoveObjectToRemoveUndoList (RATLINE_TYPE, - ptr->Line, ptr->Line, - ptr->Line); - else - TOGGLE_FLAG (RUBBERENDFLAG, ptr->Line); /* only remove line once */ - ptr++; + Crosshair.AttachedObject.RubberbandN = 0; + LookupRatLines(type, ptr1, ptr2, ptr3); + ptr = Crosshair.AttachedObject.Rubberband; + for (i = 0; i < Crosshair.AttachedObject.RubberbandN; i++) { + if (PCB->RatOn) + EraseRat((RatTypePtr) ptr->Line); + if (TEST_FLAG(RUBBERENDFLAG, ptr->Line)) + MoveObjectToRemoveUndoList(RATLINE_TYPE, ptr->Line, ptr->Line, ptr->Line); + else + TOGGLE_FLAG(RUBBERENDFLAG, ptr->Line); /* only remove line once */ + ptr++; + } + } + RemoveObject(type, ptr1, ptr2, ptr3); + IncrementUndoSerialNumber(); + SetChangedFlag(true); } - } - RemoveObject (type, ptr1, ptr2, ptr3); - IncrementUndoSerialNumber (); - SetChangedFlag (true); - } - break; + break; - case ROTATE_MODE: - RotateScreenObject (Note.X, Note.Y, - gui->shift_is_pressed ()? (SWAP_IDENT ? - 1 : 3) - : (SWAP_IDENT ? 3 : 1)); - break; + case ROTATE_MODE: + RotateScreenObject(Note.X, Note.Y, gui->shift_is_pressed()? (SWAP_IDENT ? 1 : 3) + : (SWAP_IDENT ? 3 : 1)); + break; - /* both are almost the same */ - case COPY_MODE: - case MOVE_MODE: - switch (Crosshair.AttachedObject.State) - { - /* first notify, lookup object */ - case STATE_FIRST: - { - int types = (Settings.Mode == COPY_MODE) ? - COPY_TYPES : MOVE_TYPES; + /* both are almost the same */ + case COPY_MODE: + case MOVE_MODE: + switch (Crosshair.AttachedObject.State) { + /* first notify, lookup object */ + case STATE_FIRST: + { + int types = (Settings.Mode == COPY_MODE) ? COPY_TYPES : MOVE_TYPES; - Crosshair.AttachedObject.Type = - SearchScreen (Note.X, Note.Y, types, - &Crosshair.AttachedObject.Ptr1, - &Crosshair.AttachedObject.Ptr2, - &Crosshair.AttachedObject.Ptr3); - if (Crosshair.AttachedObject.Type != NO_TYPE) - { - if (Settings.Mode == MOVE_MODE && - TEST_FLAG (LOCKFLAG, (PinTypePtr) - Crosshair.AttachedObject.Ptr2)) - { - Message (_("Sorry, the object is locked\n")); - Crosshair.AttachedObject.Type = NO_TYPE; - } - else - AttachForCopy (Note.X, Note.Y); - } - break; - } + Crosshair.AttachedObject.Type = + SearchScreen(Note.X, Note.Y, types, + &Crosshair.AttachedObject.Ptr1, &Crosshair.AttachedObject.Ptr2, &Crosshair.AttachedObject.Ptr3); + if (Crosshair.AttachedObject.Type != NO_TYPE) { + if (Settings.Mode == MOVE_MODE && TEST_FLAG(LOCKFLAG, (PinTypePtr) + Crosshair.AttachedObject.Ptr2)) { + Message(_("Sorry, the object is locked\n")); + Crosshair.AttachedObject.Type = NO_TYPE; + } + else + AttachForCopy(Note.X, Note.Y); + } + break; + } - /* second notify, move or copy object */ - case STATE_SECOND: - if (Settings.Mode == COPY_MODE) - CopyObject (Crosshair.AttachedObject.Type, - Crosshair.AttachedObject.Ptr1, - Crosshair.AttachedObject.Ptr2, - Crosshair.AttachedObject.Ptr3, - Note.X - Crosshair.AttachedObject.X, - Note.Y - Crosshair.AttachedObject.Y); - else - { - MoveObjectAndRubberband (Crosshair.AttachedObject.Type, - Crosshair.AttachedObject.Ptr1, - Crosshair.AttachedObject.Ptr2, - Crosshair.AttachedObject.Ptr3, - Note.X - Crosshair.AttachedObject.X, - Note.Y - Crosshair.AttachedObject.Y); - SetLocalRef (0, 0, false); - } - SetChangedFlag (true); + /* second notify, move or copy object */ + case STATE_SECOND: + if (Settings.Mode == COPY_MODE) + CopyObject(Crosshair.AttachedObject.Type, + Crosshair.AttachedObject.Ptr1, + Crosshair.AttachedObject.Ptr2, + Crosshair.AttachedObject.Ptr3, Note.X - Crosshair.AttachedObject.X, Note.Y - Crosshair.AttachedObject.Y); + else { + MoveObjectAndRubberband(Crosshair.AttachedObject.Type, + Crosshair.AttachedObject.Ptr1, + Crosshair.AttachedObject.Ptr2, + Crosshair.AttachedObject.Ptr3, + Note.X - Crosshair.AttachedObject.X, Note.Y - Crosshair.AttachedObject.Y); + SetLocalRef(0, 0, false); + } + SetChangedFlag(true); - /* reset identifiers */ - Crosshair.AttachedObject.Type = NO_TYPE; - Crosshair.AttachedObject.State = STATE_FIRST; - break; - } - break; + /* reset identifiers */ + Crosshair.AttachedObject.Type = NO_TYPE; + Crosshair.AttachedObject.State = STATE_FIRST; + break; + } + break; - /* insert a point into a polygon/line/... */ - case INSERTPOINT_MODE: - switch (Crosshair.AttachedObject.State) - { - /* first notify, lookup object */ - case STATE_FIRST: - Crosshair.AttachedObject.Type = - SearchScreen (Note.X, Note.Y, INSERT_TYPES, - &Crosshair.AttachedObject.Ptr1, - &Crosshair.AttachedObject.Ptr2, - &Crosshair.AttachedObject.Ptr3); + /* insert a point into a polygon/line/... */ + case INSERTPOINT_MODE: + switch (Crosshair.AttachedObject.State) { + /* first notify, lookup object */ + case STATE_FIRST: + Crosshair.AttachedObject.Type = + SearchScreen(Note.X, Note.Y, INSERT_TYPES, + &Crosshair.AttachedObject.Ptr1, &Crosshair.AttachedObject.Ptr2, &Crosshair.AttachedObject.Ptr3); - if (Crosshair.AttachedObject.Type != NO_TYPE) - { - if (TEST_FLAG (LOCKFLAG, (PolygonTypePtr) - Crosshair.AttachedObject.Ptr2)) - { - Message (_("Sorry, the object is locked\n")); - Crosshair.AttachedObject.Type = NO_TYPE; - break; - } - else - { - /* get starting point of nearest segment */ - if (Crosshair.AttachedObject.Type == POLYGON_TYPE) - { - fake.poly = - (PolygonTypePtr) Crosshair.AttachedObject.Ptr2; - polyIndex = - GetLowestDistancePolygonPoint (fake.poly, Note.X, - Note.Y); - fake.line.Point1 = fake.poly->Points[polyIndex]; - fake.line.Point2 = fake.poly->Points[ - prev_contour_point (fake.poly, polyIndex)]; - Crosshair.AttachedObject.Ptr2 = &fake.line; + if (Crosshair.AttachedObject.Type != NO_TYPE) { + if (TEST_FLAG(LOCKFLAG, (PolygonTypePtr) + Crosshair.AttachedObject.Ptr2)) { + Message(_("Sorry, the object is locked\n")); + Crosshair.AttachedObject.Type = NO_TYPE; + break; + } + else { + /* get starting point of nearest segment */ + if (Crosshair.AttachedObject.Type == POLYGON_TYPE) { + fake.poly = (PolygonTypePtr) Crosshair.AttachedObject.Ptr2; + polyIndex = GetLowestDistancePolygonPoint(fake.poly, Note.X, Note.Y); + fake.line.Point1 = fake.poly->Points[polyIndex]; + fake.line.Point2 = fake.poly->Points[prev_contour_point(fake.poly, polyIndex)]; + Crosshair.AttachedObject.Ptr2 = &fake.line; - } - Crosshair.AttachedObject.State = STATE_SECOND; - InsertedPoint = *AdjustInsertPoint (); - } - } - break; + } + Crosshair.AttachedObject.State = STATE_SECOND; + InsertedPoint = *AdjustInsertPoint(); + } + } + break; - /* second notify, insert new point into object */ - case STATE_SECOND: - if (Crosshair.AttachedObject.Type == POLYGON_TYPE) - InsertPointIntoObject (POLYGON_TYPE, - Crosshair.AttachedObject.Ptr1, fake.poly, - &polyIndex, - InsertedPoint.X, InsertedPoint.Y, false, false); - else - InsertPointIntoObject (Crosshair.AttachedObject.Type, - Crosshair.AttachedObject.Ptr1, - Crosshair.AttachedObject.Ptr2, - &polyIndex, - InsertedPoint.X, InsertedPoint.Y, false, false); - SetChangedFlag (true); + /* second notify, insert new point into object */ + case STATE_SECOND: + if (Crosshair.AttachedObject.Type == POLYGON_TYPE) + InsertPointIntoObject(POLYGON_TYPE, + Crosshair.AttachedObject.Ptr1, fake.poly, + &polyIndex, InsertedPoint.X, InsertedPoint.Y, false, false); + else + InsertPointIntoObject(Crosshair.AttachedObject.Type, + Crosshair.AttachedObject.Ptr1, + Crosshair.AttachedObject.Ptr2, &polyIndex, InsertedPoint.X, InsertedPoint.Y, false, false); + SetChangedFlag(true); - /* reset identifiers */ - Crosshair.AttachedObject.Type = NO_TYPE; - Crosshair.AttachedObject.State = STATE_FIRST; - break; + /* reset identifiers */ + Crosshair.AttachedObject.Type = NO_TYPE; + Crosshair.AttachedObject.State = STATE_FIRST; + break; + } + break; } - break; - } } @@ -1891,31 +1666,29 @@ %end-doc */ -static int -ActionAtomic (int argc, char **argv, Coord x, Coord y) +static int ActionAtomic(int argc, char **argv, Coord x, Coord y) { - if (argc != 1) - AFAIL (atomic); + if (argc != 1) + AFAIL(atomic); - switch (GetFunctionID (argv[0])) - { - case F_Save: - SaveUndoSerialNumber (); - break; - case F_Restore: - RestoreUndoSerialNumber (); - break; - case F_Close: - RestoreUndoSerialNumber (); - IncrementUndoSerialNumber (); - break; - case F_Block: - RestoreUndoSerialNumber (); - if (Bumped) - IncrementUndoSerialNumber (); - break; - } - return 0; + switch (GetFunctionID(argv[0])) { + case F_Save: + SaveUndoSerialNumber(); + break; + case F_Restore: + RestoreUndoSerialNumber(); + break; + case F_Close: + RestoreUndoSerialNumber(); + IncrementUndoSerialNumber(); + break; + case F_Block: + RestoreUndoSerialNumber(); + if (Bumped) + IncrementUndoSerialNumber(); + break; + } + return 0; } /* -------------------------------------------------------------------------- */ @@ -1931,43 +1704,35 @@ %end-doc */ -static int -ActionDRCheck (int argc, char **argv, Coord x, Coord y) +static int ActionDRCheck(int argc, char **argv, Coord x, Coord y) { - int count; + int count; - if (gui->drc_gui == NULL || gui->drc_gui->log_drc_overview) - { - Message (_("%m+Rules are minspace %$mS, minoverlap %$mS " - "minwidth %$mS, minsilk %$mS\n" - "min drill %$mS, min annular ring %$mS\n"), - Settings.grid_unit->allow, - PCB->Bloat, PCB->Shrink, - PCB->minWid, PCB->minSlk, - PCB->minDrill, PCB->minRing); - } - count = DRCAll (); - if (gui->drc_gui == NULL || gui->drc_gui->log_drc_overview) - { - if (count == 0) - Message (_("No DRC problems found.\n")); - else if (count > 0) - Message (_("Found %d design rule errors.\n"), count); - else - Message (_("Aborted DRC after %d design rule errors.\n"), -count); - } - return 0; + if (gui->drc_gui == NULL || gui->drc_gui->log_drc_overview) { + Message(_("%m+Rules are minspace %$mS, minoverlap %$mS " + "minwidth %$mS, minsilk %$mS\n" + "min drill %$mS, min annular ring %$mS\n"), + Settings.grid_unit->allow, PCB->Bloat, PCB->Shrink, PCB->minWid, PCB->minSlk, PCB->minDrill, PCB->minRing); + } + count = DRCAll(); + if (gui->drc_gui == NULL || gui->drc_gui->log_drc_overview) { + if (count == 0) + Message(_("No DRC problems found.\n")); + else if (count > 0) + Message(_("Found %d design rule errors.\n"), count); + else + Message(_("Aborted DRC after %d design rule errors.\n"), -count); + } + return 0; } /* ---------------------------------------------------------------- */ -static const char cycledrag_syntax[] = - "CycleDrag()\n"; +static const char cycledrag_syntax[] = "CycleDrag()\n"; static const char cycledrag_help[] = "Cycle through which object is being dragged"; #define close_enough(a, b) ((((a)-(b)) > 0) ? ((a)-(b) < (SLOP * pixel_slop)) : ((a)-(b) > -(SLOP * pixel_slop))) -static int -CycleDrag (int argc, char **argv, Coord x, Coord y) +static int CycleDrag(int argc, char **argv, Coord x, Coord y) { void *ptr1, *ptr2, *ptr3; int over = 0; @@ -1974,7 +1739,7 @@ if (Crosshair.drags == NULL) return NULL; - + do { Crosshair.drags_current++; if (Crosshair.drags_current >= Crosshair.drags_len) { @@ -1982,51 +1747,52 @@ over++; } - if (SearchObjectByID (PCB->Data, &ptr1, &ptr2, &ptr3, Crosshair.drags[Crosshair.drags_current], LINE_TYPE) != NO_TYPE) { + if (SearchObjectByID(PCB->Data, &ptr1, &ptr2, &ptr3, Crosshair.drags[Crosshair.drags_current], LINE_TYPE) != NO_TYPE) { /* line has two endpoints, check which one is close to the original x;y */ LineType *l = ptr2; long int d1, d2; if (close_enough(Note.X, l->Point1.X) && close_enough(Note.Y, l->Point1.Y)) { - Crosshair.AttachedObject.Type = LINEPOINT_TYPE; - Crosshair.AttachedObject.Ptr1 = ptr1; - Crosshair.AttachedObject.Ptr2 = ptr2; - Crosshair.AttachedObject.Ptr3 = &l->Point1; + Crosshair.AttachedObject.Type = LINEPOINT_TYPE; + Crosshair.AttachedObject.Ptr1 = ptr1; + Crosshair.AttachedObject.Ptr2 = ptr2; + Crosshair.AttachedObject.Ptr3 = &l->Point1; return 0; } if (close_enough(Note.X, l->Point2.X) && close_enough(Note.Y, l->Point2.Y)) { - Crosshair.AttachedObject.Type = LINEPOINT_TYPE; - Crosshair.AttachedObject.Ptr1 = ptr1; - Crosshair.AttachedObject.Ptr2 = ptr2; - Crosshair.AttachedObject.Ptr3 = &l->Point2; + Crosshair.AttachedObject.Type = LINEPOINT_TYPE; + Crosshair.AttachedObject.Ptr1 = ptr1; + Crosshair.AttachedObject.Ptr2 = ptr2; + Crosshair.AttachedObject.Ptr3 = &l->Point2; return 0; } } - else if (SearchObjectByID (PCB->Data, &ptr1, &ptr2, &ptr3, Crosshair.drags[Crosshair.drags_current], VIA_TYPE) != NO_TYPE) { - Crosshair.AttachedObject.Type = VIA_TYPE; - Crosshair.AttachedObject.Ptr1 = ptr1; - Crosshair.AttachedObject.Ptr2 = ptr2; - Crosshair.AttachedObject.Ptr3 = ptr3; + else if (SearchObjectByID(PCB->Data, &ptr1, &ptr2, &ptr3, Crosshair.drags[Crosshair.drags_current], VIA_TYPE) != NO_TYPE) { + Crosshair.AttachedObject.Type = VIA_TYPE; + Crosshair.AttachedObject.Ptr1 = ptr1; + Crosshair.AttachedObject.Ptr2 = ptr2; + Crosshair.AttachedObject.Ptr3 = ptr3; return 0; } - else if (SearchObjectByID (PCB->Data, &ptr1, &ptr2, &ptr3, Crosshair.drags[Crosshair.drags_current], PAD_TYPE) != NO_TYPE) { - Crosshair.AttachedObject.Type = ELEMENT_TYPE; - Crosshair.AttachedObject.Ptr1 = ptr1; - Crosshair.AttachedObject.Ptr2 = ptr1; - Crosshair.AttachedObject.Ptr3 = ptr1; + else if (SearchObjectByID(PCB->Data, &ptr1, &ptr2, &ptr3, Crosshair.drags[Crosshair.drags_current], PAD_TYPE) != NO_TYPE) { + Crosshair.AttachedObject.Type = ELEMENT_TYPE; + Crosshair.AttachedObject.Ptr1 = ptr1; + Crosshair.AttachedObject.Ptr2 = ptr1; + Crosshair.AttachedObject.Ptr3 = ptr1; return 0; } - else if (SearchObjectByID (PCB->Data, &ptr1, &ptr2, &ptr3, Crosshair.drags[Crosshair.drags_current], ARC_TYPE) != NO_TYPE) { - Crosshair.AttachedObject.Type = ARC_TYPE; - Crosshair.AttachedObject.Ptr1 = ptr1; - Crosshair.AttachedObject.Ptr2 = ptr2; - Crosshair.AttachedObject.Ptr3 = ptr3; + else if (SearchObjectByID(PCB->Data, &ptr1, &ptr2, &ptr3, Crosshair.drags[Crosshair.drags_current], ARC_TYPE) != NO_TYPE) { + Crosshair.AttachedObject.Type = ARC_TYPE; + Crosshair.AttachedObject.Ptr1 = ptr1; + Crosshair.AttachedObject.Ptr2 = ptr2; + Crosshair.AttachedObject.Ptr3 = ptr3; return 0; } - } while(over <= 1); + } while (over <= 1); return -1; } + #undef close_enough /* -------------------------------------------------------------------------- */ @@ -2033,8 +1799,7 @@ static const char dumplibrary_syntax[] = "DumpLibrary()"; -static const char dumplibrary_help[] = - "Display the entire contents of the libraries."; +static const char dumplibrary_help[] = "Display the entire contents of the libraries."; /* %start-doc actions DumpLibrary @@ -2041,34 +1806,29 @@ %end-doc */ -static int -ActionDumpLibrary (int argc, char **argv, Coord x, Coord y) +static int ActionDumpLibrary(int argc, char **argv, Coord x, Coord y) { - int i, j; + int i, j; - printf ("**** Do not count on this format. It will change ****\n\n"); - printf ("MenuN = %d\n", Library.MenuN); - printf ("MenuMax = %d\n", Library.MenuMax); - for (i = 0; i < Library.MenuN; i++) - { - printf ("Library #%d:\n", i); - printf (" EntryN = %d\n", Library.Menu[i].EntryN); - printf (" EntryMax = %d\n", Library.Menu[i].EntryMax); - printf (" Name = \"%s\"\n", UNKNOWN (Library.Menu[i].Name)); - printf (" directory = \"%s\"\n", - UNKNOWN (Library.Menu[i].directory)); - printf (" Style = \"%s\"\n", UNKNOWN (Library.Menu[i].Style)); - printf (" flag = %d\n", Library.Menu[i].flag); + printf("**** Do not count on this format. It will change ****\n\n"); + printf("MenuN = %d\n", Library.MenuN); + printf("MenuMax = %d\n", Library.MenuMax); + for (i = 0; i < Library.MenuN; i++) { + printf("Library #%d:\n", i); + printf(" EntryN = %d\n", Library.Menu[i].EntryN); + printf(" EntryMax = %d\n", Library.Menu[i].EntryMax); + printf(" Name = \"%s\"\n", UNKNOWN(Library.Menu[i].Name)); + printf(" directory = \"%s\"\n", UNKNOWN(Library.Menu[i].directory)); + printf(" Style = \"%s\"\n", UNKNOWN(Library.Menu[i].Style)); + printf(" flag = %d\n", Library.Menu[i].flag); - for (j = 0; j < Library.Menu[i].EntryN; j++) - { - printf (" #%4d: ", j); - printf ("newlib: \"%s\"\n", - UNKNOWN (Library.Menu[i].Entry[j].ListEntry)); + for (j = 0; j < Library.Menu[i].EntryN; j++) { + printf(" #%4d: ", j); + printf("newlib: \"%s\"\n", UNKNOWN(Library.Menu[i].Entry[j].ListEntry)); + } } - } - return 0; + return 0; } /* -------------------------------------------------------------------------- */ @@ -2075,8 +1835,7 @@ static const char flip_syntax[] = "Flip(Object|Selected|SelectedElements)"; -static const char flip_help[] = - "Flip an element to the opposite side of the board."; +static const char flip_help[] = "Flip an element to the opposite side of the board."; /* %start-doc actions Flip @@ -2088,41 +1847,36 @@ %end-doc */ -static int -ActionFlip (int argc, char **argv, Coord x, Coord y) +static int ActionFlip(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - ElementTypePtr element; - void *ptrtmp; - int err = 0; + char *function = ARG(0); + ElementTypePtr element; + void *ptrtmp; + int err = 0; - if (function) - { - switch (GetFunctionID (function)) - { - case F_Object: - if ((SearchScreen (x, y, ELEMENT_TYPE, - &ptrtmp, &ptrtmp, &ptrtmp)) != NO_TYPE) - { - element = (ElementTypePtr) ptrtmp; - ChangeElementSide (element, 2 * Crosshair.Y - PCB->MaxHeight); - IncrementUndoSerialNumber (); - Draw (); - } - break; - case F_Selected: - case F_SelectedElements: - ChangeSelectedElementSide (); - break; - default: - err = 1; - break; + if (function) { + switch (GetFunctionID(function)) { + case F_Object: + if ((SearchScreen(x, y, ELEMENT_TYPE, &ptrtmp, &ptrtmp, &ptrtmp)) != NO_TYPE) { + element = (ElementTypePtr) ptrtmp; + ChangeElementSide(element, 2 * Crosshair.Y - PCB->MaxHeight); + IncrementUndoSerialNumber(); + Draw(); + } + break; + case F_Selected: + case F_SelectedElements: + ChangeSelectedElementSide(); + break; + default: + err = 1; + break; + } + if (!err) + return 0; } - if (!err) - return 0; - } - AFAIL (flip); + AFAIL(flip); } /* -------------------------------------------------------------------------- */ @@ -2140,37 +1894,33 @@ %end-doc */ -static int -ActionMessage (int argc, char **argv, Coord x, Coord y) +static int ActionMessage(int argc, char **argv, Coord x, Coord y) { - int i; + int i; - if (argc < 1) - AFAIL (message); + if (argc < 1) + AFAIL(message); - for (i = 0; i < argc; i++) - { - Message (argv[i]); - Message ("\n"); - } + for (i = 0; i < argc; i++) { + Message(argv[i]); + Message("\n"); + } - return 0; + return 0; } /* -------------------------------------------------------------------------- */ -static const char setthermal_syntax[] = - "SetThermal(Object|SelectedPins|SelectedVias|Selected, Style)"; +static const char setthermal_syntax[] = "SetThermal(Object|SelectedPins|SelectedVias|Selected, Style)"; static const char setthermal_help[] = - "Set the thermal (on the current layer) of pins or vias to the given style.\n" - "Style = 0 means no thermal.\n" - "Style = 1 has diagonal fingers with sharp edges.\n" - "Style = 2 has horizontal and vertical fingers with sharp edges.\n" - "Style = 3 is a solid connection to the plane." - "Style = 4 has diagonal fingers with rounded edges.\n" - "Style = 5 has horizontal and vertical fingers with rounded edges.\n"; + "Set the thermal (on the current layer) of pins or vias to the given style.\n" + "Style = 0 means no thermal.\n" + "Style = 1 has diagonal fingers with sharp edges.\n" + "Style = 2 has horizontal and vertical fingers with sharp edges.\n" + "Style = 3 is a solid connection to the plane." + "Style = 4 has diagonal fingers with rounded edges.\n" "Style = 5 has horizontal and vertical fingers with rounded edges.\n"; /* %start-doc actions SetThermal @@ -2190,54 +1940,48 @@ to connect with. However, they will have no effect without the polygon. %end-doc */ -static int -ActionSetThermal (int argc, char **argv, Coord x, Coord y) +static int ActionSetThermal(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - char *style = ARG (1); - void *ptr1, *ptr2, *ptr3; - int type, kind; - int err = 0; + char *function = ARG(0); + char *style = ARG(1); + void *ptr1, *ptr2, *ptr3; + int type, kind; + int err = 0; - if (function && *function && style && *style) - { - bool absolute; + if (function && *function && style && *style) { + bool absolute; - kind = GetValue (style, NULL, &absolute); - if (absolute) - switch (GetFunctionID (function)) - { - case F_Object: - if ((type = - SearchScreen (Crosshair.X, Crosshair.Y, CHANGETHERMAL_TYPES, - &ptr1, &ptr2, &ptr3)) != NO_TYPE) - { - ChangeObjectThermal (type, ptr1, ptr2, ptr3, kind); - IncrementUndoSerialNumber (); - Draw (); - } - break; - case F_SelectedPins: - ChangeSelectedThermals (PIN_TYPE, kind); - break; - case F_SelectedVias: - ChangeSelectedThermals (VIA_TYPE, kind); - break; - case F_Selected: - case F_SelectedElements: - ChangeSelectedThermals (CHANGETHERMAL_TYPES, kind); - break; - default: - err = 1; - break; - } - else - err = 1; - if (!err) - return 0; - } + kind = GetValue(style, NULL, &absolute); + if (absolute) + switch (GetFunctionID(function)) { + case F_Object: + if ((type = SearchScreen(Crosshair.X, Crosshair.Y, CHANGETHERMAL_TYPES, &ptr1, &ptr2, &ptr3)) != NO_TYPE) { + ChangeObjectThermal(type, ptr1, ptr2, ptr3, kind); + IncrementUndoSerialNumber(); + Draw(); + } + break; + case F_SelectedPins: + ChangeSelectedThermals(PIN_TYPE, kind); + break; + case F_SelectedVias: + ChangeSelectedThermals(VIA_TYPE, kind); + break; + case F_Selected: + case F_SelectedElements: + ChangeSelectedThermals(CHANGETHERMAL_TYPES, kind); + break; + default: + err = 1; + break; + } + else + err = 1; + if (!err) + return 0; + } - AFAIL (setthermal); + AFAIL(setthermal); } /* --------------------------------------------------------------------------- @@ -2246,33 +1990,28 @@ * event handler to set the cursor according to the X pointer position * called from inside main.c */ -void -EventMoveCrosshair (int ev_x, int ev_y) +void EventMoveCrosshair(int ev_x, int ev_y) { #ifdef HAVE_LIBSTROKE - if (mid_stroke) - { - StrokeBox.X2 = ev_x; - StrokeBox.Y2 = ev_y; - stroke_record (ev_x, ev_y); - return; - } + if (mid_stroke) { + StrokeBox.X2 = ev_x; + StrokeBox.Y2 = ev_y; + stroke_record(ev_x, ev_y); + return; + } #endif /* HAVE_LIBSTROKE */ - if (MoveCrosshairAbsolute (ev_x, ev_y)) - { - /* update object position and cursor location */ - AdjustAttachedObjects (); - notify_crosshair_change (true); - } + if (MoveCrosshairAbsolute(ev_x, ev_y)) { + /* update object position and cursor location */ + AdjustAttachedObjects(); + notify_crosshair_change(true); + } } /* --------------------------------------------------------------------------- */ -static const char setvalue_syntax[] = - "SetValue(Grid|Line|LineSize|Text|TextScale|ViaDrillingHole|Via|ViaSize, delta)"; +static const char setvalue_syntax[] = "SetValue(Grid|Line|LineSize|Text|TextScale|ViaDrillingHole|Via|ViaSize, delta)"; -static const char setvalue_help[] = - "Change various board-wide values and sizes."; +static const char setvalue_help[] = "Change various board-wide values and sizes."; /* %start-doc actions SetValue @@ -2300,70 +2039,64 @@ %end-doc */ -static int -ActionSetValue (int argc, char **argv, Coord x, Coord y) +static int ActionSetValue(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - char *val = ARG (1); - char *units = ARG (2); - bool absolute; /* flag for 'absolute' value */ - double value; - int err = 0; + char *function = ARG(0); + char *val = ARG(1); + char *units = ARG(2); + bool absolute; /* flag for 'absolute' value */ + double value; + int err = 0; - if (function && val) - { - value = GetValue (val, units, &absolute); - switch (GetFunctionID (function)) - { - case F_ViaDrillingHole: - SetViaDrillingHole (absolute ? value : - value + Settings.ViaDrillingHole, - false); - hid_action ("RouteStylesChanged"); - break; + if (function && val) { + value = GetValue(val, units, &absolute); + switch (GetFunctionID(function)) { + case F_ViaDrillingHole: + SetViaDrillingHole(absolute ? value : value + Settings.ViaDrillingHole, false); + hid_action("RouteStylesChanged"); + break; - case F_Grid: - if (absolute) - SetGrid (value, false); - else - { - /* On the way down, short against the minimum - * PCB drawing unit */ - if ((value + PCB->Grid) < 1) - SetGrid (1, false); - else if (PCB->Grid == 1) - SetGrid (value, false); - else - SetGrid (value + PCB->Grid, false); - } - break; + case F_Grid: + if (absolute) + SetGrid(value, false); + else { + /* On the way down, short against the minimum + * PCB drawing unit */ + if ((value + PCB->Grid) < 1) + SetGrid(1, false); + else if (PCB->Grid == 1) + SetGrid(value, false); + else + SetGrid(value + PCB->Grid, false); + } + break; - case F_LineSize: - case F_Line: - SetLineSize (absolute ? value : value + Settings.LineThickness); - hid_action ("RouteStylesChanged"); - break; + case F_LineSize: + case F_Line: + SetLineSize(absolute ? value : value + Settings.LineThickness); + hid_action("RouteStylesChanged"); + break; - case F_Via: - case F_ViaSize: - SetViaSize (absolute ? value : value + Settings.ViaThickness, false); - hid_action ("RouteStylesChanged"); - break; + case F_Via: + case F_ViaSize: + SetViaSize(absolute ? value : value + Settings.ViaThickness, false); + hid_action("RouteStylesChanged"); + break; - case F_Text: - case F_TextScale: - value /= 45; - SetTextScale (absolute ? value : value + Settings.TextScale); - break; - default: - err = 1; - break; + case F_Text: + case F_TextScale: + value /= 45; + SetTextScale(absolute ? value : value + Settings.TextScale); + break; + default: + err = 1; + break; + } + if (!err) + return 0; } - if (!err) - return 0; - } - AFAIL (setvalue); + AFAIL(setvalue); } @@ -2380,27 +2113,23 @@ %end-doc */ -static int -ActionQuit (int argc, char **argv, Coord x, Coord y) +static int ActionQuit(int argc, char **argv, Coord x, Coord y) { - char *force = ARG (0); - if (force && strcasecmp (force, "force") == 0) - { - PCB->Changed = 0; - exit (0); - } - if (!PCB->Changed || gui->close_confirm_dialog () == HID_CLOSE_CONFIRM_OK) - QuitApplication (); - return 1; + char *force = ARG(0); + if (force && strcasecmp(force, "force") == 0) { + PCB->Changed = 0; + exit(0); + } + if (!PCB->Changed || gui->close_confirm_dialog() == HID_CLOSE_CONFIRM_OK) + QuitApplication(); + return 1; } /* --------------------------------------------------------------------------- */ -static const char connection_syntax[] = - "Connection(Find|ResetLinesAndPolygons|ResetPinsAndVias|Reset)"; +static const char connection_syntax[] = "Connection(Find|ResetLinesAndPolygons|ResetPinsAndVias|Reset)"; -static const char connection_help[] = - "Searches connections of the object at the cursor position."; +static const char connection_help[] = "Searches connections of the object at the cursor position."; /* %start-doc actions Connection @@ -2425,55 +2154,48 @@ %end-doc */ -static int -ActionConnection (int argc, char **argv, Coord x, Coord y) +static int ActionConnection(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - if (function) - { - switch (GetFunctionID (function)) - { - case F_Find: - { - gui->get_coords (_("Click on a connection"), &x, &y); - LookupConnection (x, y, true, 1, FOUNDFLAG); - break; - } + char *function = ARG(0); + if (function) { + switch (GetFunctionID(function)) { + case F_Find: + { + gui->get_coords(_("Click on a connection"), &x, &y); + LookupConnection(x, y, true, 1, FOUNDFLAG); + break; + } - case F_ResetLinesAndPolygons: - if (ResetFoundLinesAndPolygons (true)) - { - IncrementUndoSerialNumber (); - Draw (); - } - break; + case F_ResetLinesAndPolygons: + if (ResetFoundLinesAndPolygons(true)) { + IncrementUndoSerialNumber(); + Draw(); + } + break; - case F_ResetPinsViasAndPads: - if (ResetFoundPinsViasAndPads (true)) - { - IncrementUndoSerialNumber (); - Draw (); - } - break; + case F_ResetPinsViasAndPads: + if (ResetFoundPinsViasAndPads(true)) { + IncrementUndoSerialNumber(); + Draw(); + } + break; - case F_Reset: - if (ResetConnections (true)) - { - IncrementUndoSerialNumber (); - Draw (); - } - break; + case F_Reset: + if (ResetConnections(true)) { + IncrementUndoSerialNumber(); + Draw(); + } + break; + } + return 0; } - return 0; - } - AFAIL (connection); + AFAIL(connection); } /* --------------------------------------------------------------------------- */ -static const char disperseelements_syntax[] = - "DisperseElements(All|Selected)"; +static const char disperseelements_syntax[] = "DisperseElements(All|Selected)"; static const char disperseelements_help[] = "Disperses elements."; @@ -2489,108 +2211,97 @@ #define GAP MIL_TO_COORD(100) -static int -ActionDisperseElements (int argc, char **argv, Coord x, Coord y) +static int ActionDisperseElements(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - Coord minx = GAP, - miny = GAP, - maxy = GAP, - dx, dy; - int all = 0, bad = 0; + char *function = ARG(0); + Coord minx = GAP, miny = GAP, maxy = GAP, dx, dy; + int all = 0, bad = 0; - if (!function || !*function) - { - bad = 1; - } - else - { - switch (GetFunctionID (function)) - { - case F_All: - all = 1; - break; + if (!function || !*function) { + bad = 1; + } + else { + switch (GetFunctionID(function)) { + case F_All: + all = 1; + break; - case F_Selected: - all = 0; - break; + case F_Selected: + all = 0; + break; - default: - bad = 1; + default: + bad = 1; + } } - } - if (bad) - { - AFAIL (disperseelements); - } + if (bad) { + AFAIL(disperseelements); + } - ELEMENT_LOOP (PCB->Data); - { - /* - * If we want to disperse selected elements, maybe we need smarter - * code here to avoid putting components on top of others which - * are not selected. For now, I'm assuming that this is typically - * going to be used either with a brand new design or a scratch - * design holding some new components - */ - if (!TEST_FLAG (LOCKFLAG, element) && (all || TEST_FLAG (SELECTEDFLAG, element))) - { + ELEMENT_LOOP(PCB->Data); + { + /* + * If we want to disperse selected elements, maybe we need smarter + * code here to avoid putting components on top of others which + * are not selected. For now, I'm assuming that this is typically + * going to be used either with a brand new design or a scratch + * design holding some new components + */ + if (!TEST_FLAG(LOCKFLAG, element) && (all || TEST_FLAG(SELECTEDFLAG, element))) { - /* figure out how much to move the element */ - dx = minx - element->BoundingBox.X1; + /* figure out how much to move the element */ + dx = minx - element->BoundingBox.X1; - /* snap to the grid */ - dx -= (element->MarkX + dx) % PCB->Grid; + /* snap to the grid */ + dx -= (element->MarkX + dx) % PCB->Grid; - /* - * and add one grid size so we make sure we always space by GAP or - * more - */ - dx += PCB->Grid; + /* + * and add one grid size so we make sure we always space by GAP or + * more + */ + dx += PCB->Grid; - /* Figure out if this row has room. If not, start a new row */ - if (GAP + element->BoundingBox.X2 + dx > PCB->MaxWidth) - { - miny = maxy + GAP; - minx = GAP; - } + /* Figure out if this row has room. If not, start a new row */ + if (GAP + element->BoundingBox.X2 + dx > PCB->MaxWidth) { + miny = maxy + GAP; + minx = GAP; + } - /* figure out how much to move the element */ - dx = minx - element->BoundingBox.X1; - dy = miny - element->BoundingBox.Y1; + /* figure out how much to move the element */ + dx = minx - element->BoundingBox.X1; + dy = miny - element->BoundingBox.Y1; - /* snap to the grid */ - dx -= (element->MarkX + dx) % PCB->Grid; - dx += PCB->Grid; - dy -= (element->MarkY + dy) % PCB->Grid; - dy += PCB->Grid; + /* snap to the grid */ + dx -= (element->MarkX + dx) % PCB->Grid; + dx += PCB->Grid; + dy -= (element->MarkY + dy) % PCB->Grid; + dy += PCB->Grid; - /* move the element */ - MoveElementLowLevel (PCB->Data, element, dx, dy); + /* move the element */ + MoveElementLowLevel(PCB->Data, element, dx, dy); - /* and add to the undo list so we can undo this operation */ - AddObjectToMoveUndoList (ELEMENT_TYPE, NULL, NULL, element, dx, dy); + /* and add to the undo list so we can undo this operation */ + AddObjectToMoveUndoList(ELEMENT_TYPE, NULL, NULL, element, dx, dy); - /* keep track of how tall this row is */ - minx += element->BoundingBox.X2 - element->BoundingBox.X1 + GAP; - if (maxy < element->BoundingBox.Y2) - { - maxy = element->BoundingBox.Y2; - } - } + /* keep track of how tall this row is */ + minx += element->BoundingBox.X2 - element->BoundingBox.X1 + GAP; + if (maxy < element->BoundingBox.Y2) { + maxy = element->BoundingBox.Y2; + } + } - } - END_LOOP; + } + END_LOOP; - /* done with our action so increment the undo # */ - IncrementUndoSerialNumber (); + /* done with our action so increment the undo # */ + IncrementUndoSerialNumber(); - Redraw (); - SetChangedFlag (true); + Redraw(); + SetChangedFlag(true); - return 0; + return 0; } #undef GAP @@ -2598,16 +2309,15 @@ /* --------------------------------------------------------------------------- */ static const char display_syntax[] = - "Display(NameOnPCB|Description|Value)\n" - "Display(Grid|Redraw)\n" - "Display(CycleClip|CycleCrosshair|Toggle45Degree|ToggleStartDirection)\n" - "Display(ToggleGrid|ToggleRubberBandMode|ToggleUniqueNames)\n" - "Display(ToggleMask|ToggleName|ToggleClearLine|ToggleFullPoly)\n" - "Display(ToggleSnapPin|ToggleSnapOffGridLine|ToggleHighlightOnPoint)\n" - "Display(ToggleThindraw|ToggleThindrawPoly|ToggleOrthoMove|ToggleLocalRef)\n" - "Display(ToggleCheckPlanes|ToggleShowDRC|ToggleAutoDRC)\n" - "Display(ToggleLiveRoute|LockNames|OnlyNames)\n" - "Display(Pinout|PinOrPadName)"; + "Display(NameOnPCB|Description|Value)\n" + "Display(Grid|Redraw)\n" + "Display(CycleClip|CycleCrosshair|Toggle45Degree|ToggleStartDirection)\n" + "Display(ToggleGrid|ToggleRubberBandMode|ToggleUniqueNames)\n" + "Display(ToggleMask|ToggleName|ToggleClearLine|ToggleFullPoly)\n" + "Display(ToggleSnapPin|ToggleSnapOffGridLine|ToggleHighlightOnPoint)\n" + "Display(ToggleThindraw|ToggleThindrawPoly|ToggleOrthoMove|ToggleLocalRef)\n" + "Display(ToggleCheckPlanes|ToggleShowDRC|ToggleAutoDRC)\n" + "Display(ToggleLiveRoute|LockNames|OnlyNames)\n" "Display(Pinout|PinOrPadName)"; static const char display_help[] = "Several display-related actions."; @@ -2740,371 +2450,350 @@ %end-doc */ -static enum crosshair_shape -CrosshairShapeIncrement (enum crosshair_shape shape) +static enum crosshair_shape CrosshairShapeIncrement(enum crosshair_shape shape) { - switch(shape) - { - case Basic_Crosshair_Shape: - shape = Union_Jack_Crosshair_Shape; - break; - case Union_Jack_Crosshair_Shape: - shape = Dozen_Crosshair_Shape; - break; - case Dozen_Crosshair_Shape: - shape = Crosshair_Shapes_Number; - break; - case Crosshair_Shapes_Number: - shape = Basic_Crosshair_Shape; - break; - } - return shape; + switch (shape) { + case Basic_Crosshair_Shape: + shape = Union_Jack_Crosshair_Shape; + break; + case Union_Jack_Crosshair_Shape: + shape = Dozen_Crosshair_Shape; + break; + case Dozen_Crosshair_Shape: + shape = Crosshair_Shapes_Number; + break; + case Crosshair_Shapes_Number: + shape = Basic_Crosshair_Shape; + break; + } + return shape; } -static int -ActionDisplay (int argc, char **argv, Coord childX, Coord childY) +static int ActionDisplay(int argc, char **argv, Coord childX, Coord childY) { - char *function, *str_dir; - int id; - int err = 0; + char *function, *str_dir; + int id; + int err = 0; - function = ARG (0); - str_dir = ARG (1); + function = ARG(0); + str_dir = ARG(1); - if (function && (!str_dir || !*str_dir)) - { - switch (id = GetFunctionID (function)) - { + if (function && (!str_dir || !*str_dir)) { + switch (id = GetFunctionID(function)) { - /* redraw layout */ - case F_ClearAndRedraw: - case F_Redraw: - Redraw (); - break; + /* redraw layout */ + case F_ClearAndRedraw: + case F_Redraw: + Redraw(); + break; - /* change the displayed name of elements */ - case F_Value: - case F_NameOnPCB: - case F_Description: - ELEMENT_LOOP (PCB->Data); - { - EraseElementName (element); - } - END_LOOP; - CLEAR_FLAG (DESCRIPTIONFLAG | NAMEONPCBFLAG, PCB); - switch (id) - { - case F_Value: - break; - case F_NameOnPCB: - SET_FLAG (NAMEONPCBFLAG, PCB); - break; - case F_Description: - SET_FLAG (DESCRIPTIONFLAG, PCB); - break; - } - ELEMENT_LOOP (PCB->Data); - { - DrawElementName (element); - } - END_LOOP; - Draw (); - break; + /* change the displayed name of elements */ + case F_Value: + case F_NameOnPCB: + case F_Description: + ELEMENT_LOOP(PCB->Data); + { + EraseElementName(element); + } + END_LOOP; + CLEAR_FLAG(DESCRIPTIONFLAG | NAMEONPCBFLAG, PCB); + switch (id) { + case F_Value: + break; + case F_NameOnPCB: + SET_FLAG(NAMEONPCBFLAG, PCB); + break; + case F_Description: + SET_FLAG(DESCRIPTIONFLAG, PCB); + break; + } + ELEMENT_LOOP(PCB->Data); + { + DrawElementName(element); + } + END_LOOP; + Draw(); + break; - /* toggle line-adjust flag */ - case F_ToggleAllDirections: - TOGGLE_FLAG (ALLDIRECTIONFLAG, PCB); - AdjustAttachedObjects (); - break; + /* toggle line-adjust flag */ + case F_ToggleAllDirections: + TOGGLE_FLAG(ALLDIRECTIONFLAG, PCB); + AdjustAttachedObjects(); + break; - case F_CycleClip: - notify_crosshair_change (false); - if TEST_FLAG - (ALLDIRECTIONFLAG, PCB) - { - TOGGLE_FLAG (ALLDIRECTIONFLAG, PCB); - PCB->Clipping = 0; - } - else - PCB->Clipping = (PCB->Clipping + 1) % 3; - AdjustAttachedObjects (); - notify_crosshair_change (true); - break; + case F_CycleClip: + notify_crosshair_change(false); + if TEST_FLAG + (ALLDIRECTIONFLAG, PCB) { + TOGGLE_FLAG(ALLDIRECTIONFLAG, PCB); + PCB->Clipping = 0; + } + else + PCB->Clipping = (PCB->Clipping + 1) % 3; + AdjustAttachedObjects(); + notify_crosshair_change(true); + break; - case F_CycleCrosshair: - notify_crosshair_change (false); - Crosshair.shape = CrosshairShapeIncrement(Crosshair.shape); - if (Crosshair_Shapes_Number == Crosshair.shape) - Crosshair.shape = Basic_Crosshair_Shape; - notify_crosshair_change (true); - break; + case F_CycleCrosshair: + notify_crosshair_change(false); + Crosshair.shape = CrosshairShapeIncrement(Crosshair.shape); + if (Crosshair_Shapes_Number == Crosshair.shape) + Crosshair.shape = Basic_Crosshair_Shape; + notify_crosshair_change(true); + break; - case F_ToggleRubberBandMode: - notify_crosshair_change (false); - TOGGLE_FLAG (RUBBERBANDFLAG, PCB); - notify_crosshair_change (true); - break; + case F_ToggleRubberBandMode: + notify_crosshair_change(false); + TOGGLE_FLAG(RUBBERBANDFLAG, PCB); + notify_crosshair_change(true); + break; - case F_ToggleStartDirection: - notify_crosshair_change (false); - TOGGLE_FLAG (SWAPSTARTDIRFLAG, PCB); - notify_crosshair_change (true); - break; + case F_ToggleStartDirection: + notify_crosshair_change(false); + TOGGLE_FLAG(SWAPSTARTDIRFLAG, PCB); + notify_crosshair_change(true); + break; - case F_ToggleUniqueNames: - TOGGLE_FLAG (UNIQUENAMEFLAG, PCB); - break; + case F_ToggleUniqueNames: + TOGGLE_FLAG(UNIQUENAMEFLAG, PCB); + break; - case F_ToggleSnapPin: - notify_crosshair_change (false); - TOGGLE_FLAG (SNAPPINFLAG, PCB); - notify_crosshair_change (true); - break; + case F_ToggleSnapPin: + notify_crosshair_change(false); + TOGGLE_FLAG(SNAPPINFLAG, PCB); + notify_crosshair_change(true); + break; - case F_ToggleSnapOffGridLine: - notify_crosshair_change (false); - TOGGLE_FLAG (SNAPOFFGRIDLINEFLAG, PCB); - notify_crosshair_change (true); - break; + case F_ToggleSnapOffGridLine: + notify_crosshair_change(false); + TOGGLE_FLAG(SNAPOFFGRIDLINEFLAG, PCB); + notify_crosshair_change(true); + break; - case F_ToggleHighlightOnPoint: - notify_crosshair_change (false); - TOGGLE_FLAG (HIGHLIGHTONPOINTFLAG, PCB); - notify_crosshair_change (true); - break; + case F_ToggleHighlightOnPoint: + notify_crosshair_change(false); + TOGGLE_FLAG(HIGHLIGHTONPOINTFLAG, PCB); + notify_crosshair_change(true); + break; - case F_ToggleLocalRef: - TOGGLE_FLAG (LOCALREFFLAG, PCB); - break; + case F_ToggleLocalRef: + TOGGLE_FLAG(LOCALREFFLAG, PCB); + break; - case F_ToggleThindraw: - TOGGLE_FLAG (THINDRAWFLAG, PCB); - Redraw (); - break; + case F_ToggleThindraw: + TOGGLE_FLAG(THINDRAWFLAG, PCB); + Redraw(); + break; - case F_ToggleThindrawPoly: - TOGGLE_FLAG (THINDRAWPOLYFLAG, PCB); - Redraw (); - break; + case F_ToggleThindrawPoly: + TOGGLE_FLAG(THINDRAWPOLYFLAG, PCB); + Redraw(); + break; - case F_ToggleLockNames: - TOGGLE_FLAG (LOCKNAMESFLAG, PCB); - CLEAR_FLAG (ONLYNAMESFLAG, PCB); - break; + case F_ToggleLockNames: + TOGGLE_FLAG(LOCKNAMESFLAG, PCB); + CLEAR_FLAG(ONLYNAMESFLAG, PCB); + break; - case F_ToggleOnlyNames: - TOGGLE_FLAG (ONLYNAMESFLAG, PCB); - CLEAR_FLAG (LOCKNAMESFLAG, PCB); - break; + case F_ToggleOnlyNames: + TOGGLE_FLAG(ONLYNAMESFLAG, PCB); + CLEAR_FLAG(LOCKNAMESFLAG, PCB); + break; - case F_ToggleHideNames: - TOGGLE_FLAG (HIDENAMESFLAG, PCB); - Redraw (); - break; + case F_ToggleHideNames: + TOGGLE_FLAG(HIDENAMESFLAG, PCB); + Redraw(); + break; - case F_ToggleMinCut: - TOGGLE_FLAG (ENABLEMINCUTFLAG, PCB); - break; + case F_ToggleMinCut: + TOGGLE_FLAG(ENABLEMINCUTFLAG, PCB); + break; - case F_ToggleShowDRC: - TOGGLE_FLAG (SHOWDRCFLAG, PCB); - break; + case F_ToggleShowDRC: + TOGGLE_FLAG(SHOWDRCFLAG, PCB); + break; - case F_ToggleLiveRoute: - TOGGLE_FLAG (LIVEROUTEFLAG, PCB); - break; + case F_ToggleLiveRoute: + TOGGLE_FLAG(LIVEROUTEFLAG, PCB); + break; - case F_ToggleAutoDRC: - notify_crosshair_change (false); - TOGGLE_FLAG (AUTODRCFLAG, PCB); - if (TEST_FLAG (AUTODRCFLAG, PCB) && Settings.Mode == LINE_MODE) - { - if (ResetConnections (true)) - { - IncrementUndoSerialNumber (); - Draw (); - } - if (Crosshair.AttachedLine.State != STATE_FIRST) - LookupConnection (Crosshair.AttachedLine.Point1.X, - Crosshair.AttachedLine.Point1.Y, true, 1, - FOUNDFLAG); - } - notify_crosshair_change (true); - break; + case F_ToggleAutoDRC: + notify_crosshair_change(false); + TOGGLE_FLAG(AUTODRCFLAG, PCB); + if (TEST_FLAG(AUTODRCFLAG, PCB) && Settings.Mode == LINE_MODE) { + if (ResetConnections(true)) { + IncrementUndoSerialNumber(); + Draw(); + } + if (Crosshair.AttachedLine.State != STATE_FIRST) + LookupConnection(Crosshair.AttachedLine.Point1.X, Crosshair.AttachedLine.Point1.Y, true, 1, FOUNDFLAG); + } + notify_crosshair_change(true); + break; - case F_ToggleCheckPlanes: - TOGGLE_FLAG (CHECKPLANESFLAG, PCB); - Redraw (); - break; + case F_ToggleCheckPlanes: + TOGGLE_FLAG(CHECKPLANESFLAG, PCB); + Redraw(); + break; - case F_ToggleOrthoMove: - TOGGLE_FLAG (ORTHOMOVEFLAG, PCB); - break; + case F_ToggleOrthoMove: + TOGGLE_FLAG(ORTHOMOVEFLAG, PCB); + break; - case F_ToggleName: - TOGGLE_FLAG (SHOWNUMBERFLAG, PCB); - Redraw (); - break; + case F_ToggleName: + TOGGLE_FLAG(SHOWNUMBERFLAG, PCB); + Redraw(); + break; - case F_ToggleMask: - TOGGLE_FLAG (SHOWMASKFLAG, PCB); - Redraw (); - break; + case F_ToggleMask: + TOGGLE_FLAG(SHOWMASKFLAG, PCB); + Redraw(); + break; - case F_ToggleClearLine: - TOGGLE_FLAG (CLEARNEWFLAG, PCB); - break; + case F_ToggleClearLine: + TOGGLE_FLAG(CLEARNEWFLAG, PCB); + break; - case F_ToggleFullPoly: - TOGGLE_FLAG (NEWFULLPOLYFLAG, PCB); - break; + case F_ToggleFullPoly: + TOGGLE_FLAG(NEWFULLPOLYFLAG, PCB); + break; - /* shift grid alignment */ - case F_ToggleGrid: - { - Coord oldGrid = PCB->Grid; + /* shift grid alignment */ + case F_ToggleGrid: + { + Coord oldGrid = PCB->Grid; - PCB->Grid = 1; - if (MoveCrosshairAbsolute (Crosshair.X, Crosshair.Y)) - notify_crosshair_change (true); /* first notify was in MoveCrosshairAbs */ - SetGrid (oldGrid, true); - } - break; + PCB->Grid = 1; + if (MoveCrosshairAbsolute(Crosshair.X, Crosshair.Y)) + notify_crosshair_change(true); /* first notify was in MoveCrosshairAbs */ + SetGrid(oldGrid, true); + } + break; - /* toggle displaying of the grid */ - case F_Grid: - Settings.DrawGrid = !Settings.DrawGrid; - Redraw (); - break; + /* toggle displaying of the grid */ + case F_Grid: + Settings.DrawGrid = !Settings.DrawGrid; + Redraw(); + break; - /* display the pinout of an element */ - case F_Pinout: - { - ElementTypePtr element; - void *ptrtmp; - Coord x, y; + /* display the pinout of an element */ + case F_Pinout: + { + ElementTypePtr element; + void *ptrtmp; + Coord x, y; - gui->get_coords (_("Click on an element"), &x, &y); - if ((SearchScreen - (x, y, ELEMENT_TYPE, &ptrtmp, - &ptrtmp, &ptrtmp)) != NO_TYPE) - { - element = (ElementTypePtr) ptrtmp; - gui->show_item (element); - } - break; - } + gui->get_coords(_("Click on an element"), &x, &y); + if ((SearchScreen(x, y, ELEMENT_TYPE, &ptrtmp, &ptrtmp, &ptrtmp)) != NO_TYPE) { + element = (ElementTypePtr) ptrtmp; + gui->show_item(element); + } + break; + } - /* toggle displaying of pin/pad/via names */ - case F_PinOrPadName: - { - void *ptr1, *ptr2, *ptr3; + /* toggle displaying of pin/pad/via names */ + case F_PinOrPadName: + { + void *ptr1, *ptr2, *ptr3; - switch (SearchScreen (Crosshair.X, Crosshair.Y, - ELEMENT_TYPE | PIN_TYPE | PAD_TYPE | - VIA_TYPE, (void **) &ptr1, (void **) &ptr2, - (void **) &ptr3)) - { - case ELEMENT_TYPE: - PIN_LOOP ((ElementTypePtr) ptr1); - { - if (TEST_FLAG (DISPLAYNAMEFLAG, pin)) - ErasePinName (pin); - else - DrawPinName (pin); - AddObjectToFlagUndoList (PIN_TYPE, ptr1, pin, pin); - TOGGLE_FLAG (DISPLAYNAMEFLAG, pin); - } - END_LOOP; - PAD_LOOP ((ElementTypePtr) ptr1); - { - if (TEST_FLAG (DISPLAYNAMEFLAG, pad)) - ErasePadName (pad); - else - DrawPadName (pad); - AddObjectToFlagUndoList (PAD_TYPE, ptr1, pad, pad); - TOGGLE_FLAG (DISPLAYNAMEFLAG, pad); - } - END_LOOP; - SetChangedFlag (true); - IncrementUndoSerialNumber (); - Draw (); - break; + switch (SearchScreen(Crosshair.X, Crosshair.Y, + ELEMENT_TYPE | PIN_TYPE | PAD_TYPE | + VIA_TYPE, (void **) &ptr1, (void **) &ptr2, (void **) &ptr3)) { + case ELEMENT_TYPE: + PIN_LOOP((ElementTypePtr) ptr1); + { + if (TEST_FLAG(DISPLAYNAMEFLAG, pin)) + ErasePinName(pin); + else + DrawPinName(pin); + AddObjectToFlagUndoList(PIN_TYPE, ptr1, pin, pin); + TOGGLE_FLAG(DISPLAYNAMEFLAG, pin); + } + END_LOOP; + PAD_LOOP((ElementTypePtr) ptr1); + { + if (TEST_FLAG(DISPLAYNAMEFLAG, pad)) + ErasePadName(pad); + else + DrawPadName(pad); + AddObjectToFlagUndoList(PAD_TYPE, ptr1, pad, pad); + TOGGLE_FLAG(DISPLAYNAMEFLAG, pad); + } + END_LOOP; + SetChangedFlag(true); + IncrementUndoSerialNumber(); + Draw(); + break; - case PIN_TYPE: - if (TEST_FLAG (DISPLAYNAMEFLAG, (PinTypePtr) ptr2)) - ErasePinName ((PinTypePtr) ptr2); - else - DrawPinName ((PinTypePtr) ptr2); - AddObjectToFlagUndoList (PIN_TYPE, ptr1, ptr2, ptr3); - TOGGLE_FLAG (DISPLAYNAMEFLAG, (PinTypePtr) ptr2); - SetChangedFlag (true); - IncrementUndoSerialNumber (); - Draw (); - break; + case PIN_TYPE: + if (TEST_FLAG(DISPLAYNAMEFLAG, (PinTypePtr) ptr2)) + ErasePinName((PinTypePtr) ptr2); + else + DrawPinName((PinTypePtr) ptr2); + AddObjectToFlagUndoList(PIN_TYPE, ptr1, ptr2, ptr3); + TOGGLE_FLAG(DISPLAYNAMEFLAG, (PinTypePtr) ptr2); + SetChangedFlag(true); + IncrementUndoSerialNumber(); + Draw(); + break; - case PAD_TYPE: - if (TEST_FLAG (DISPLAYNAMEFLAG, (PadTypePtr) ptr2)) - ErasePadName ((PadTypePtr) ptr2); - else - DrawPadName ((PadTypePtr) ptr2); - AddObjectToFlagUndoList (PAD_TYPE, ptr1, ptr2, ptr3); - TOGGLE_FLAG (DISPLAYNAMEFLAG, (PadTypePtr) ptr2); - SetChangedFlag (true); - IncrementUndoSerialNumber (); - Draw (); - break; - case VIA_TYPE: - if (TEST_FLAG (DISPLAYNAMEFLAG, (PinTypePtr) ptr2)) - EraseViaName ((PinTypePtr) ptr2); - else - DrawViaName ((PinTypePtr) ptr2); - AddObjectToFlagUndoList (VIA_TYPE, ptr1, ptr2, ptr3); - TOGGLE_FLAG (DISPLAYNAMEFLAG, (PinTypePtr) ptr2); - SetChangedFlag (true); - IncrementUndoSerialNumber (); - Draw (); - break; - } - break; - } - default: - err = 1; + case PAD_TYPE: + if (TEST_FLAG(DISPLAYNAMEFLAG, (PadTypePtr) ptr2)) + ErasePadName((PadTypePtr) ptr2); + else + DrawPadName((PadTypePtr) ptr2); + AddObjectToFlagUndoList(PAD_TYPE, ptr1, ptr2, ptr3); + TOGGLE_FLAG(DISPLAYNAMEFLAG, (PadTypePtr) ptr2); + SetChangedFlag(true); + IncrementUndoSerialNumber(); + Draw(); + break; + case VIA_TYPE: + if (TEST_FLAG(DISPLAYNAMEFLAG, (PinTypePtr) ptr2)) + EraseViaName((PinTypePtr) ptr2); + else + DrawViaName((PinTypePtr) ptr2); + AddObjectToFlagUndoList(VIA_TYPE, ptr1, ptr2, ptr3); + TOGGLE_FLAG(DISPLAYNAMEFLAG, (PinTypePtr) ptr2); + SetChangedFlag(true); + IncrementUndoSerialNumber(); + Draw(); + break; + } + break; + } + default: + err = 1; + } } - } - else if (function && str_dir) - { - switch (GetFunctionID (function)) - { - case F_ToggleGrid: - if (argc > 2) - { - PCB->GridOffsetX = GetValue (argv[1], NULL, NULL); - PCB->GridOffsetY = GetValue (argv[2], NULL, NULL); - if (Settings.DrawGrid) - Redraw (); - } - break; + else if (function && str_dir) { + switch (GetFunctionID(function)) { + case F_ToggleGrid: + if (argc > 2) { + PCB->GridOffsetX = GetValue(argv[1], NULL, NULL); + PCB->GridOffsetY = GetValue(argv[2], NULL, NULL); + if (Settings.DrawGrid) + Redraw(); + } + break; - default: - err = 1; - break; + default: + err = 1; + break; + } } - } - if (!err) - return 0; + if (!err) + return 0; - AFAIL (display); + AFAIL(display); } /* --------------------------------------------------------------------------- */ static const char mode_syntax[] = - "Mode(Arc|Arrow|Copy|InsertPoint|Line|Lock|Move|None|PasteBuffer)\n" - "Mode(Polygon|Rectangle|Remove|Rotate|Text|Thermal|Via)\n" - "Mode(Notify|Release|Cancel|Stroke)\n" - "Mode(Save|Restore)"; + "Mode(Arc|Arrow|Copy|InsertPoint|Line|Lock|Move|None|PasteBuffer)\n" + "Mode(Polygon|Rectangle|Remove|Rotate|Text|Thermal|Via)\n" "Mode(Notify|Release|Cancel|Stroke)\n" "Mode(Save|Restore)"; static const char mode_help[] = "Change or use the tool mode."; @@ -3160,216 +2849,201 @@ %end-doc */ -static int -ActionMode (int argc, char **argv, Coord x, Coord y) +static int ActionMode(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); + char *function = ARG(0); - if (function) - { - Note.X = Crosshair.X; - Note.Y = Crosshair.Y; - notify_crosshair_change (false); - switch (GetFunctionID (function)) - { - case F_Arc: - SetMode (ARC_MODE); - break; - case F_Arrow: - SetMode (ARROW_MODE); - break; - case F_Copy: - SetMode (COPY_MODE); - break; - case F_InsertPoint: - SetMode (INSERTPOINT_MODE); - break; - case F_Line: - SetMode (LINE_MODE); - break; - case F_Lock: - SetMode (LOCK_MODE); - break; - case F_Move: - SetMode (MOVE_MODE); - break; - case F_None: - SetMode (NO_MODE); - break; - case F_Cancel: - { - int saved_mode = Settings.Mode; - SetMode (NO_MODE); - SetMode (saved_mode); - } - break; - case F_Escape: - { - switch (Settings.Mode) - { - case VIA_MODE: - case PASTEBUFFER_MODE: - case TEXT_MODE: - case ROTATE_MODE: - case REMOVE_MODE: - case MOVE_MODE: - case COPY_MODE: - case INSERTPOINT_MODE: - case RUBBERBANDMOVE_MODE: - case THERMAL_MODE: - case LOCK_MODE: - SetMode (NO_MODE); - SetMode (ARROW_MODE); - break; + if (function) { + Note.X = Crosshair.X; + Note.Y = Crosshair.Y; + notify_crosshair_change(false); + switch (GetFunctionID(function)) { + case F_Arc: + SetMode(ARC_MODE); + break; + case F_Arrow: + SetMode(ARROW_MODE); + break; + case F_Copy: + SetMode(COPY_MODE); + break; + case F_InsertPoint: + SetMode(INSERTPOINT_MODE); + break; + case F_Line: + SetMode(LINE_MODE); + break; + case F_Lock: + SetMode(LOCK_MODE); + break; + case F_Move: + SetMode(MOVE_MODE); + break; + case F_None: + SetMode(NO_MODE); + break; + case F_Cancel: + { + int saved_mode = Settings.Mode; + SetMode(NO_MODE); + SetMode(saved_mode); + } + break; + case F_Escape: + { + switch (Settings.Mode) { + case VIA_MODE: + case PASTEBUFFER_MODE: + case TEXT_MODE: + case ROTATE_MODE: + case REMOVE_MODE: + case MOVE_MODE: + case COPY_MODE: + case INSERTPOINT_MODE: + case RUBBERBANDMOVE_MODE: + case THERMAL_MODE: + case LOCK_MODE: + SetMode(NO_MODE); + SetMode(ARROW_MODE); + break; - case LINE_MODE: - if (Crosshair.AttachedLine.State == STATE_FIRST) - SetMode (ARROW_MODE); - else - { - SetMode (NO_MODE); - SetMode (LINE_MODE); - } - break; + case LINE_MODE: + if (Crosshair.AttachedLine.State == STATE_FIRST) + SetMode(ARROW_MODE); + else { + SetMode(NO_MODE); + SetMode(LINE_MODE); + } + break; - case RECTANGLE_MODE: - if (Crosshair.AttachedBox.State == STATE_FIRST) - SetMode (ARROW_MODE); - else - { - SetMode (NO_MODE); - SetMode (RECTANGLE_MODE); - } - break; - - case POLYGON_MODE: - if (Crosshair.AttachedLine.State == STATE_FIRST) - SetMode (ARROW_MODE); - else - { - SetMode (NO_MODE); - SetMode (POLYGON_MODE); - } - break; + case RECTANGLE_MODE: + if (Crosshair.AttachedBox.State == STATE_FIRST) + SetMode(ARROW_MODE); + else { + SetMode(NO_MODE); + SetMode(RECTANGLE_MODE); + } + break; - case POLYGONHOLE_MODE: - if (Crosshair.AttachedLine.State == STATE_FIRST) - SetMode (ARROW_MODE); - else - { - SetMode (NO_MODE); - SetMode (POLYGONHOLE_MODE); - } - break; + case POLYGON_MODE: + if (Crosshair.AttachedLine.State == STATE_FIRST) + SetMode(ARROW_MODE); + else { + SetMode(NO_MODE); + SetMode(POLYGON_MODE); + } + break; - case ARC_MODE: - if (Crosshair.AttachedBox.State == STATE_FIRST) - SetMode (ARROW_MODE); - else - { - SetMode (NO_MODE); - SetMode (ARC_MODE); - } - break; - - case ARROW_MODE: - break; - - default: - break; - } - } - break; - - case F_Notify: - NotifyMode (); - break; - case F_PasteBuffer: - SetMode (PASTEBUFFER_MODE); - break; - case F_Polygon: - SetMode (POLYGON_MODE); - break; - case F_PolygonHole: - SetMode (POLYGONHOLE_MODE); - break; + case POLYGONHOLE_MODE: + if (Crosshair.AttachedLine.State == STATE_FIRST) + SetMode(ARROW_MODE); + else { + SetMode(NO_MODE); + SetMode(POLYGONHOLE_MODE); + } + break; + + case ARC_MODE: + if (Crosshair.AttachedBox.State == STATE_FIRST) + SetMode(ARROW_MODE); + else { + SetMode(NO_MODE); + SetMode(ARC_MODE); + } + break; + + case ARROW_MODE: + break; + + default: + break; + } + } + break; + + case F_Notify: + NotifyMode(); + break; + case F_PasteBuffer: + SetMode(PASTEBUFFER_MODE); + break; + case F_Polygon: + SetMode(POLYGON_MODE); + break; + case F_PolygonHole: + SetMode(POLYGONHOLE_MODE); + break; #ifndef HAVE_LIBSTROKE - case F_Release: - ReleaseMode (); - break; + case F_Release: + ReleaseMode(); + break; #else - case F_Release: - if (mid_stroke) - FinishStroke (); - else - ReleaseMode (); - break; + case F_Release: + if (mid_stroke) + FinishStroke(); + else + ReleaseMode(); + break; #endif - case F_Remove: - SetMode (REMOVE_MODE); - break; - case F_Rectangle: - SetMode (RECTANGLE_MODE); - break; - case F_Rotate: - SetMode (ROTATE_MODE); - break; - case F_Stroke: + case F_Remove: + SetMode(REMOVE_MODE); + break; + case F_Rectangle: + SetMode(RECTANGLE_MODE); + break; + case F_Rotate: + SetMode(ROTATE_MODE); + break; + case F_Stroke: #ifdef HAVE_LIBSTROKE - mid_stroke = true; - StrokeBox.X1 = Crosshair.X; - StrokeBox.Y1 = Crosshair.Y; - break; + mid_stroke = true; + StrokeBox.X1 = Crosshair.X; + StrokeBox.Y1 = Crosshair.Y; + break; #else - /* Handle middle mouse button restarts of drawing mode. If not in - | a drawing mode, middle mouse button will select objects. - */ - if (Settings.Mode == LINE_MODE - && Crosshair.AttachedLine.State != STATE_FIRST) - { - SetMode (LINE_MODE); - } - else if (Settings.Mode == ARC_MODE - && Crosshair.AttachedBox.State != STATE_FIRST) - SetMode (ARC_MODE); - else if (Settings.Mode == RECTANGLE_MODE - && Crosshair.AttachedBox.State != STATE_FIRST) - SetMode (RECTANGLE_MODE); - else if (Settings.Mode == POLYGON_MODE - && Crosshair.AttachedLine.State != STATE_FIRST) - SetMode (POLYGON_MODE); - else - { - SaveMode (); - saved_mode = true; - SetMode (ARROW_MODE); - NotifyMode (); - } - break; + /* Handle middle mouse button restarts of drawing mode. If not in + | a drawing mode, middle mouse button will select objects. + */ + if (Settings.Mode == LINE_MODE && Crosshair.AttachedLine.State != STATE_FIRST) { + SetMode(LINE_MODE); + } + else if (Settings.Mode == ARC_MODE && Crosshair.AttachedBox.State != STATE_FIRST) + SetMode(ARC_MODE); + else if (Settings.Mode == RECTANGLE_MODE && Crosshair.AttachedBox.State != STATE_FIRST) + SetMode(RECTANGLE_MODE); + else if (Settings.Mode == POLYGON_MODE && Crosshair.AttachedLine.State != STATE_FIRST) + SetMode(POLYGON_MODE); + else { + SaveMode(); + saved_mode = true; + SetMode(ARROW_MODE); + NotifyMode(); + } + break; #endif - case F_Text: - SetMode (TEXT_MODE); - break; - case F_Thermal: - SetMode (THERMAL_MODE); - break; - case F_Via: - SetMode (VIA_MODE); - break; + case F_Text: + SetMode(TEXT_MODE); + break; + case F_Thermal: + SetMode(THERMAL_MODE); + break; + case F_Via: + SetMode(VIA_MODE); + break; - case F_Restore: /* restore the last saved mode */ - RestoreMode (); - break; + case F_Restore: /* restore the last saved mode */ + RestoreMode(); + break; - case F_Save: /* save currently selected mode */ - SaveMode (); - break; + case F_Save: /* save currently selected mode */ + SaveMode(); + break; + } + notify_crosshair_change(true); + return 0; } - notify_crosshair_change (true); - return 0; - } - AFAIL (mode); + AFAIL(mode); } /* --------------------------------------------------------------------------- */ @@ -3382,368 +3056,320 @@ %end-doc */ -static int -ActionRemoveSelected (int argc, char **argv, Coord x, Coord y) +static int ActionRemoveSelected(int argc, char **argv, Coord x, Coord y) { - if (RemoveSelected ()) - SetChangedFlag (true); - return 0; + if (RemoveSelected()) + SetChangedFlag(true); + return 0; } #ifdef BA_TODO /* --------------------------------------------------------------------------- */ -static const char renumber_syntax[] = "Renumber()\n" - "Renumber(filename)"; +static const char renumber_syntax[] = "Renumber()\n" "Renumber(filename)"; static const char renumber_help[] = - "Renumber all elements. The changes will be recorded to filename\n" - "for use in backannotating these changes to the schematic."; + "Renumber all elements. The changes will be recorded to filename\n" + "for use in backannotating these changes to the schematic."; /* %start-doc actions Renumber %end-doc */ -static int -ActionRenumber (int argc, char **argv, Coord x, Coord y) +static int ActionRenumber(int argc, char **argv, Coord x, Coord y) { - bool changed = false; - ElementTypePtr *element_list; - ElementTypePtr *locked_element_list; - unsigned int i, j, k, cnt, lock_cnt; - unsigned int tmpi; - size_t sz; - char *tmps; - char *name; - FILE *out; - static char * default_file = NULL; - size_t cnt_list_sz = 100; - struct _cnt_list - { - char *name; - unsigned int cnt; - } *cnt_list; - char **was, **is, *pin; - unsigned int c_cnt = 0; - int unique, ok; - int free_name = 0; + bool changed = false; + ElementTypePtr *element_list; + ElementTypePtr *locked_element_list; + unsigned int i, j, k, cnt, lock_cnt; + unsigned int tmpi; + size_t sz; + char *tmps; + char *name; + FILE *out; + static char *default_file = NULL; + size_t cnt_list_sz = 100; + struct _cnt_list { + char *name; + unsigned int cnt; + } *cnt_list; + char **was, **is, *pin; + unsigned int c_cnt = 0; + int unique, ok; + int free_name = 0; - if (argc < 1) - { - /* - * We deal with the case where name already exists in this - * function so the GUI doesn't need to deal with it - */ - name = gui->fileselect (_("Save Renumber Annotation File As ..."), - _("Choose a file to record the renumbering to.\n" - "This file may be used to back annotate the\n" - "change to the schematics.\n"), - default_file, ".eco", "eco", - 0); + if (argc < 1) { + /* + * We deal with the case where name already exists in this + * function so the GUI doesn't need to deal with it + */ + name = gui->fileselect(_("Save Renumber Annotation File As ..."), + _("Choose a file to record the renumbering to.\n" + "This file may be used to back annotate the\n" + "change to the schematics.\n"), default_file, ".eco", "eco", 0); - free_name = 1; - } - else - name = argv[0]; + free_name = 1; + } + else + name = argv[0]; - if (default_file) - { - free (default_file); - default_file = NULL; - } + if (default_file) { + free(default_file); + default_file = NULL; + } - if (name && *name) - { - default_file = strdup (name); - } + if (name && *name) { + default_file = strdup(name); + } - if ((out = fopen (name, "r"))) - { - fclose (out); - if (!gui->confirm_dialog (_("File exists! Ok to overwrite?"), 0)) - { - if (free_name && name) - free (name); - return 0; + if ((out = fopen(name, "r"))) { + fclose(out); + if (!gui->confirm_dialog(_("File exists! Ok to overwrite?"), 0)) { + if (free_name && name) + free(name); + return 0; + } } - } - if ((out = fopen (name, "w")) == NULL) - { - Message (_("Could not open %s\n"), name); - if (free_name && name) - free (name); - return 1; - } - - if (free_name && name) - free (name); + if ((out = fopen(name, "w")) == NULL) { + Message(_("Could not open %s\n"), name); + if (free_name && name) + free(name); + return 1; + } - fprintf (out, "*COMMENT* PCB Annotation File\n"); - fprintf (out, "*FILEVERSION* 20061031\n"); + if (free_name && name) + free(name); - /* - * Make a first pass through all of the elements and sort them out - * by location on the board. While here we also collect a list of - * locked elements. - * - * We'll actually renumber things in the 2nd pass. - */ - element_list = (ElementType **)calloc (PCB->Data->ElementN, sizeof (ElementTypePtr)); - locked_element_list = (ElementType **)calloc (PCB->Data->ElementN, sizeof (ElementTypePtr)); - was = (char **)calloc (PCB->Data->ElementN, sizeof (char *)); - is = (char **)calloc (PCB->Data->ElementN, sizeof (char *)); - if (element_list == NULL || locked_element_list == NULL || was == NULL - || is == NULL) - { - fprintf (stderr, "calloc() failed in %s\n", __FUNCTION__); - exit (1); - } + fprintf(out, "*COMMENT* PCB Annotation File\n"); + fprintf(out, "*FILEVERSION* 20061031\n"); - - cnt = 0; - lock_cnt = 0; - ELEMENT_LOOP (PCB->Data); - { - if (TEST_FLAG (LOCKFLAG, element->Name) || TEST_FLAG (LOCKFLAG, element)) - { - /* - * add to the list of locked elements which we won't try to - * renumber and whose reference designators are now reserved. + /* + * Make a first pass through all of the elements and sort them out + * by location on the board. While here we also collect a list of + * locked elements. + * + * We'll actually renumber things in the 2nd pass. */ - pcb_fprintf (out, - "*WARN* Element \"%s\" at %$md is locked and will not be renumbered.\n", - UNKNOWN (NAMEONPCB_NAME (element)), element->MarkX, element->MarkY); - locked_element_list[lock_cnt] = element; - lock_cnt++; - } + element_list = (ElementType **) calloc(PCB->Data->ElementN, sizeof(ElementTypePtr)); + locked_element_list = (ElementType **) calloc(PCB->Data->ElementN, sizeof(ElementTypePtr)); + was = (char **) calloc(PCB->Data->ElementN, sizeof(char *)); + is = (char **) calloc(PCB->Data->ElementN, sizeof(char *)); + if (element_list == NULL || locked_element_list == NULL || was == NULL || is == NULL) { + fprintf(stderr, "calloc() failed in %s\n", __FUNCTION__); + exit(1); + } - else - { - /* count of devices which will be renumbered */ - cnt++; - /* search for correct position in the list */ - i = 0; - while (element_list[i] && element->MarkY > element_list[i]->MarkY) - i++; + cnt = 0; + lock_cnt = 0; + ELEMENT_LOOP(PCB->Data); + { + if (TEST_FLAG(LOCKFLAG, element->Name) || TEST_FLAG(LOCKFLAG, element)) { + /* + * add to the list of locked elements which we won't try to + * renumber and whose reference designators are now reserved. + */ + pcb_fprintf(out, + "*WARN* Element \"%s\" at %$md is locked and will not be renumbered.\n", + UNKNOWN(NAMEONPCB_NAME(element)), element->MarkX, element->MarkY); + locked_element_list[lock_cnt] = element; + lock_cnt++; + } + else { + /* count of devices which will be renumbered */ + cnt++; + + /* search for correct position in the list */ + i = 0; + while (element_list[i] && element->MarkY > element_list[i]->MarkY) + i++; + + /* + * We have found the position where we have the first element that + * has the same Y value or a lower Y value. Now move forward if + * needed through the X values + */ + while (element_list[i] + && element->MarkY == element_list[i]->MarkY && element->MarkX > element_list[i]->MarkX) + i++; + + for (j = cnt - 1; j > i; j--) { + element_list[j] = element_list[j - 1]; + } + element_list[i] = element; + } + } + END_LOOP; + + /* - * We have found the position where we have the first element that - * has the same Y value or a lower Y value. Now move forward if - * needed through the X values + * Now that the elements are sorted by board position, we go through + * and renumber them. */ - while (element_list[i] - && element->MarkY == element_list[i]->MarkY - && element->MarkX > element_list[i]->MarkX) - i++; - for (j = cnt - 1; j > i; j--) - { - element_list[j] = element_list[j - 1]; - } - element_list[i] = element; - } - } - END_LOOP; + /* + * turn off the flag which requires unique names so it doesn't get + * in our way. When we're done with the renumber we will have unique + * names. + */ + unique = TEST_FLAG(UNIQUENAMEFLAG, PCB); + CLEAR_FLAG(UNIQUENAMEFLAG, PCB); + cnt_list = (struct _cnt_list *) calloc(cnt_list_sz, sizeof(struct _cnt_list)); + for (i = 0; i < cnt; i++) { + /* If there is no refdes, maybe just spit out a warning */ + if (NAMEONPCB_NAME(element_list[i])) { + /* figure out the prefix */ + tmps = strdup(NAMEONPCB_NAME(element_list[i])); + j = 0; + while (tmps[j] && (tmps[j] < '0' || tmps[j] > '9') + && tmps[j] != '?') + j++; + tmps[j] = '\0'; - /* - * Now that the elements are sorted by board position, we go through - * and renumber them. - */ + /* check the counter for this prefix */ + for (j = 0; cnt_list[j].name && (strcmp(cnt_list[j].name, tmps) != 0) + && j < cnt_list_sz; j++); - /* - * turn off the flag which requires unique names so it doesn't get - * in our way. When we're done with the renumber we will have unique - * names. - */ - unique = TEST_FLAG (UNIQUENAMEFLAG, PCB); - CLEAR_FLAG (UNIQUENAMEFLAG, PCB); + /* grow the list if needed */ + if (j == cnt_list_sz) { + cnt_list_sz += 100; + cnt_list = (struct _cnt_list *) realloc(cnt_list, cnt_list_sz); + if (cnt_list == NULL) { + fprintf(stderr, "realloc failed() in %s\n", __FUNCTION__); + exit(1); + } + /* zero out the memory that we added */ + for (tmpi = j; tmpi < cnt_list_sz; tmpi++) { + cnt_list[tmpi].name = NULL; + cnt_list[tmpi].cnt = 0; + } + } - cnt_list = (struct _cnt_list *)calloc (cnt_list_sz, sizeof (struct _cnt_list)); - for (i = 0; i < cnt; i++) - { - /* If there is no refdes, maybe just spit out a warning */ - if (NAMEONPCB_NAME (element_list[i])) - { - /* figure out the prefix */ - tmps = strdup (NAMEONPCB_NAME (element_list[i])); - j = 0; - while (tmps[j] && (tmps[j] < '0' || tmps[j] > '9') - && tmps[j] != '?') - j++; - tmps[j] = '\0'; + /* + * start a new counter if we don't have a counter for this + * prefix + */ + if (!cnt_list[j].name) { + cnt_list[j].name = strdup(tmps); + cnt_list[j].cnt = 0; + } - /* check the counter for this prefix */ - for (j = 0; - cnt_list[j].name && (strcmp (cnt_list[j].name, tmps) != 0) - && j < cnt_list_sz; j++); + /* + * check to see if the new refdes is already used by a + * locked element + */ + do { + ok = 1; + cnt_list[j].cnt++; + free(tmps); - /* grow the list if needed */ - if (j == cnt_list_sz) - { - cnt_list_sz += 100; - cnt_list = (struct _cnt_list *)realloc (cnt_list, cnt_list_sz); - if (cnt_list == NULL) - { - fprintf (stderr, "realloc failed() in %s\n", __FUNCTION__); - exit (1); - } - /* zero out the memory that we added */ - for (tmpi = j; tmpi < cnt_list_sz; tmpi++) - { - cnt_list[tmpi].name = NULL; - cnt_list[tmpi].cnt = 0; - } - } + /* space for the prefix plus 1 digit plus the '\0' */ + sz = strlen(cnt_list[j].name) + 2; - /* - * start a new counter if we don't have a counter for this - * prefix - */ - if (!cnt_list[j].name) - { - cnt_list[j].name = strdup (tmps); - cnt_list[j].cnt = 0; - } + /* and 1 more per extra digit needed to hold the number */ + tmpi = cnt_list[j].cnt; + while (tmpi > 10) { + sz++; + tmpi = tmpi / 10; + } + tmps = (char *) malloc(sz * sizeof(char)); + sprintf(tmps, "%s%d", cnt_list[j].name, cnt_list[j].cnt); - /* - * check to see if the new refdes is already used by a - * locked element - */ - do - { - ok = 1; - cnt_list[j].cnt++; - free (tmps); + /* + * now compare to the list of reserved (by locked + * elements) names + */ + for (k = 0; k < lock_cnt; k++) { + if (strcmp(UNKNOWN(NAMEONPCB_NAME(locked_element_list[k])), tmps) == 0) { + ok = 0; + break; + } + } - /* space for the prefix plus 1 digit plus the '\0' */ - sz = strlen (cnt_list[j].name) + 2; + } + while (!ok); - /* and 1 more per extra digit needed to hold the number */ - tmpi = cnt_list[j].cnt; - while (tmpi > 10) - { - sz++; - tmpi = tmpi / 10; - } - tmps = (char *)malloc (sz * sizeof (char)); - sprintf (tmps, "%s%d", cnt_list[j].name, cnt_list[j].cnt); + if (strcmp(tmps, NAMEONPCB_NAME(element_list[i])) != 0) { + fprintf(out, "*RENAME* \"%s\" \"%s\"\n", NAMEONPCB_NAME(element_list[i]), tmps); - /* - * now compare to the list of reserved (by locked - * elements) names - */ - for (k = 0; k < lock_cnt; k++) - { - if (strcmp - (UNKNOWN (NAMEONPCB_NAME (locked_element_list[k])), - tmps) == 0) - { - ok = 0; - break; - } - } + /* add this rename to our table of renames so we can update the netlist */ + was[c_cnt] = strdup(NAMEONPCB_NAME(element_list[i])); + is[c_cnt] = strdup(tmps); + c_cnt++; - } - while (!ok); + AddObjectToChangeNameUndoList(ELEMENT_TYPE, NULL, NULL, element_list[i], NAMEONPCB_NAME(element_list[i])); - if (strcmp (tmps, NAMEONPCB_NAME (element_list[i])) != 0) - { - fprintf (out, "*RENAME* \"%s\" \"%s\"\n", - NAMEONPCB_NAME (element_list[i]), tmps); + ChangeObjectName(ELEMENT_TYPE, element_list[i], NULL, NULL, tmps); + changed = true; - /* add this rename to our table of renames so we can update the netlist */ - was[c_cnt] = strdup (NAMEONPCB_NAME (element_list[i])); - is[c_cnt] = strdup (tmps); - c_cnt++; + /* we don't free tmps in this case because it is used */ + } + else + free(tmps); + } + else { + pcb_fprintf(out, "*WARN* Element at %$md has no name.\n", element_list[i]->MarkX, element_list[i]->MarkY); + } - AddObjectToChangeNameUndoList (ELEMENT_TYPE, NULL, NULL, - element_list[i], - NAMEONPCB_NAME (element_list - [i])); - - ChangeObjectName (ELEMENT_TYPE, element_list[i], NULL, NULL, - tmps); - changed = true; - - /* we don't free tmps in this case because it is used */ - } - else - free (tmps); } - else - { - pcb_fprintf (out, "*WARN* Element at %$md has no name.\n", - element_list[i]->MarkX, element_list[i]->MarkY); - } - } + fclose(out); - fclose (out); + /* restore the unique flag setting */ + if (unique) + SET_FLAG(UNIQUENAMEFLAG, PCB); - /* restore the unique flag setting */ - if (unique) - SET_FLAG (UNIQUENAMEFLAG, PCB); + if (changed) { - if (changed) - { + /* update the netlist */ + AddNetlistLibToUndoList(&(PCB->NetlistLib)); - /* update the netlist */ - AddNetlistLibToUndoList (&(PCB->NetlistLib)); + /* iterate over each net */ + for (i = 0; i < PCB->NetlistLib.MenuN; i++) { - /* iterate over each net */ - for (i = 0; i < PCB->NetlistLib.MenuN; i++) - { + /* iterate over each pin on the net */ + for (j = 0; j < PCB->NetlistLib.Menu[i].EntryN; j++) { - /* iterate over each pin on the net */ - for (j = 0; j < PCB->NetlistLib.Menu[i].EntryN; j++) - { + /* figure out the pin number part from strings like U3-21 */ + tmps = strdup(PCB->NetlistLib.Menu[i].Entry[j].ListEntry); + for (k = 0; tmps[k] && tmps[k] != '-'; k++); + tmps[k] = '\0'; + pin = tmps + k + 1; - /* figure out the pin number part from strings like U3-21 */ - tmps = strdup (PCB->NetlistLib.Menu[i].Entry[j].ListEntry); - for (k = 0; tmps[k] && tmps[k] != '-'; k++); - tmps[k] = '\0'; - pin = tmps + k + 1; + /* iterate over the list of changed reference designators */ + for (k = 0; k < c_cnt; k++) { + /* + * if the pin needs to change, change it and quit + * searching in the list. + */ + if (strcmp(tmps, was[k]) == 0) { + free(PCB->NetlistLib.Menu[i].Entry[j].ListEntry); + PCB->NetlistLib.Menu[i].Entry[j].ListEntry = (char *) malloc((strlen(is[k]) + strlen(pin) + 2) * sizeof(char)); + sprintf(PCB->NetlistLib.Menu[i].Entry[j].ListEntry, "%s-%s", is[k], pin); + k = c_cnt; + } - /* iterate over the list of changed reference designators */ - for (k = 0; k < c_cnt; k++) - { - /* - * if the pin needs to change, change it and quit - * searching in the list. - */ - if (strcmp (tmps, was[k]) == 0) - { - free (PCB->NetlistLib.Menu[i].Entry[j].ListEntry); - PCB->NetlistLib.Menu[i].Entry[j].ListEntry = - (char *)malloc ((strlen (is[k]) + strlen (pin) + - 2) * sizeof (char)); - sprintf (PCB->NetlistLib.Menu[i].Entry[j].ListEntry, - "%s-%s", is[k], pin); - k = c_cnt; - } + } + free(tmps); + } + } + for (k = 0; k < c_cnt; k++) { + free(was[k]); + free(is[k]); + } - } - free (tmps); - } + NetlistChanged(0); + IncrementUndoSerialNumber(); + SetChangedFlag(true); } - for (k = 0; k < c_cnt; k++) - { - free (was[k]); - free (is[k]); - } - NetlistChanged (0); - IncrementUndoSerialNumber (); - SetChangedFlag (true); - } - - free (locked_element_list); - free (element_list); - free (cnt_list); - return 0; + free(locked_element_list); + free(element_list); + free(cnt_list); + return 0; } #endif @@ -3751,8 +3377,7 @@ static const char ripup_syntax[] = "RipUp(All|Selected|Element)"; -static const char ripup_help[] = - "Ripup auto-routed tracks, or convert an element to parts."; +static const char ripup_help[] = "Ripup auto-routed tracks, or convert an element to parts."; /* %start-doc actions RipUp @@ -3773,107 +3398,94 @@ %end-doc */ -static int -ActionRipUp (int argc, char **argv, Coord x, Coord y) +static int ActionRipUp(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - bool changed = false; + char *function = ARG(0); + bool changed = false; - if (function) - { - switch (GetFunctionID (function)) - { - case F_All: - ALLLINE_LOOP (PCB->Data); - { - if (TEST_FLAG (AUTOFLAG, line) && !TEST_FLAG (LOCKFLAG, line)) - { - RemoveObject (LINE_TYPE, layer, line, line); - changed = true; - } - } - ENDALL_LOOP; - ALLARC_LOOP (PCB->Data); - { - if (TEST_FLAG (AUTOFLAG, arc) && !TEST_FLAG (LOCKFLAG, arc)) - { - RemoveObject (ARC_TYPE, layer, arc, arc); - changed = true; - } - } - ENDALL_LOOP; - VIA_LOOP (PCB->Data); - { - if (TEST_FLAG (AUTOFLAG, via) && !TEST_FLAG (LOCKFLAG, via)) - { - RemoveObject (VIA_TYPE, via, via, via); - changed = true; - } - } - END_LOOP; + if (function) { + switch (GetFunctionID(function)) { + case F_All: + ALLLINE_LOOP(PCB->Data); + { + if (TEST_FLAG(AUTOFLAG, line) && !TEST_FLAG(LOCKFLAG, line)) { + RemoveObject(LINE_TYPE, layer, line, line); + changed = true; + } + } + ENDALL_LOOP; + ALLARC_LOOP(PCB->Data); + { + if (TEST_FLAG(AUTOFLAG, arc) && !TEST_FLAG(LOCKFLAG, arc)) { + RemoveObject(ARC_TYPE, layer, arc, arc); + changed = true; + } + } + ENDALL_LOOP; + VIA_LOOP(PCB->Data); + { + if (TEST_FLAG(AUTOFLAG, via) && !TEST_FLAG(LOCKFLAG, via)) { + RemoveObject(VIA_TYPE, via, via, via); + changed = true; + } + } + END_LOOP; - if (changed) - { - IncrementUndoSerialNumber (); - SetChangedFlag (true); - } - break; - case F_Selected: - VISIBLELINE_LOOP (PCB->Data); - { - if (TEST_FLAGS (AUTOFLAG | SELECTEDFLAG, line) - && !TEST_FLAG (LOCKFLAG, line)) - { - RemoveObject (LINE_TYPE, layer, line, line); - changed = true; - } - } - ENDALL_LOOP; - if (PCB->ViaOn) - VIA_LOOP (PCB->Data); - { - if (TEST_FLAGS (AUTOFLAG | SELECTEDFLAG, via) - && !TEST_FLAG (LOCKFLAG, via)) - { - RemoveObject (VIA_TYPE, via, via, via); - changed = true; - } - } - END_LOOP; - if (changed) - { - IncrementUndoSerialNumber (); - SetChangedFlag (true); - } - break; - case F_Element: - { - void *ptr1, *ptr2, *ptr3; + if (changed) { + IncrementUndoSerialNumber(); + SetChangedFlag(true); + } + break; + case F_Selected: + VISIBLELINE_LOOP(PCB->Data); + { + if (TEST_FLAGS(AUTOFLAG | SELECTEDFLAG, line) + && !TEST_FLAG(LOCKFLAG, line)) { + RemoveObject(LINE_TYPE, layer, line, line); + changed = true; + } + } + ENDALL_LOOP; + if (PCB->ViaOn) + VIA_LOOP(PCB->Data); + { + if (TEST_FLAGS(AUTOFLAG | SELECTEDFLAG, via) + && !TEST_FLAG(LOCKFLAG, via)) { + RemoveObject(VIA_TYPE, via, via, via); + changed = true; + } + } + END_LOOP; + if (changed) { + IncrementUndoSerialNumber(); + SetChangedFlag(true); + } + break; + case F_Element: + { + void *ptr1, *ptr2, *ptr3; - if (SearchScreen (Crosshair.X, Crosshair.Y, ELEMENT_TYPE, - &ptr1, &ptr2, &ptr3) != NO_TYPE) - { - Note.Buffer = Settings.BufferNumber; - SetBufferNumber (MAX_BUFFER - 1); - ClearBuffer (PASTEBUFFER); - CopyObjectToBuffer (PASTEBUFFER->Data, PCB->Data, - ELEMENT_TYPE, ptr1, ptr2, ptr3); - SmashBufferElement (PASTEBUFFER); - PASTEBUFFER->X = 0; - PASTEBUFFER->Y = 0; - SaveUndoSerialNumber (); - EraseObject (ELEMENT_TYPE, ptr1, ptr1); - MoveObjectToRemoveUndoList (ELEMENT_TYPE, ptr1, ptr2, ptr3); - RestoreUndoSerialNumber (); - CopyPastebufferToLayout (0, 0); - SetBufferNumber (Note.Buffer); - SetChangedFlag (true); - } - } - break; + if (SearchScreen(Crosshair.X, Crosshair.Y, ELEMENT_TYPE, &ptr1, &ptr2, &ptr3) != NO_TYPE) { + Note.Buffer = Settings.BufferNumber; + SetBufferNumber(MAX_BUFFER - 1); + ClearBuffer(PASTEBUFFER); + CopyObjectToBuffer(PASTEBUFFER->Data, PCB->Data, ELEMENT_TYPE, ptr1, ptr2, ptr3); + SmashBufferElement(PASTEBUFFER); + PASTEBUFFER->X = 0; + PASTEBUFFER->Y = 0; + SaveUndoSerialNumber(); + EraseObject(ELEMENT_TYPE, ptr1, ptr1); + MoveObjectToRemoveUndoList(ELEMENT_TYPE, ptr1, ptr2, ptr3); + RestoreUndoSerialNumber(); + CopyPastebufferToLayout(0, 0); + SetBufferNumber(Note.Buffer); + SetChangedFlag(true); + } + } + break; + } } - } - return 0; + return 0; } /* --------------------------------------------------------------------------- */ @@ -3901,64 +3513,55 @@ %end-doc */ -static int -ActionAddRats (int argc, char **argv, Coord x, Coord y) +static int ActionAddRats(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - RatTypePtr shorty; - float len, small; + char *function = ARG(0); + RatTypePtr shorty; + float len, small; - if (function) - { - if (Settings.RatWarn) - ClearWarnings (); - switch (GetFunctionID (function)) - { - case F_AllRats: - if (AddAllRats (false, NULL)) - SetChangedFlag (true); - break; - case F_SelectedRats: - case F_Selected: - if (AddAllRats (true, NULL)) - SetChangedFlag (true); - break; - case F_Close: - small = SQUARE (MAX_COORD); - shorty = NULL; - RAT_LOOP (PCB->Data); - { - if (TEST_FLAG (SELECTEDFLAG, line)) - continue; - len = SQUARE (line->Point1.X - line->Point2.X) + - SQUARE (line->Point1.Y - line->Point2.Y); - if (len < small) - { - small = len; - shorty = line; - } - } - END_LOOP; - if (shorty) - { - AddObjectToFlagUndoList (RATLINE_TYPE, shorty, shorty, shorty); - SET_FLAG (SELECTEDFLAG, shorty); - DrawRat (shorty); - Draw (); - CenterDisplay ((shorty->Point2.X + shorty->Point1.X) / 2, - (shorty->Point2.Y + shorty->Point1.Y) / 2); - } - break; + if (function) { + if (Settings.RatWarn) + ClearWarnings(); + switch (GetFunctionID(function)) { + case F_AllRats: + if (AddAllRats(false, NULL)) + SetChangedFlag(true); + break; + case F_SelectedRats: + case F_Selected: + if (AddAllRats(true, NULL)) + SetChangedFlag(true); + break; + case F_Close: + small = SQUARE(MAX_COORD); + shorty = NULL; + RAT_LOOP(PCB->Data); + { + if (TEST_FLAG(SELECTEDFLAG, line)) + continue; + len = SQUARE(line->Point1.X - line->Point2.X) + SQUARE(line->Point1.Y - line->Point2.Y); + if (len < small) { + small = len; + shorty = line; + } + } + END_LOOP; + if (shorty) { + AddObjectToFlagUndoList(RATLINE_TYPE, shorty, shorty, shorty); + SET_FLAG(SELECTEDFLAG, shorty); + DrawRat(shorty); + Draw(); + CenterDisplay((shorty->Point2.X + shorty->Point1.X) / 2, (shorty->Point2.Y + shorty->Point1.Y) / 2); + } + break; + } } - } - return 0; + return 0; } /* --------------------------------------------------------------------------- */ -static const char delete_syntax[] = - "Delete(Object|Selected)\n" - "Delete(AllRats|SelectedRats)"; +static const char delete_syntax[] = "Delete(Object|Selected)\n" "Delete(AllRats|SelectedRats)"; static const char delete_help[] = "Delete stuff."; @@ -3966,49 +3569,45 @@ %end-doc */ -static int -ActionDelete (int argc, char **argv, Coord x, Coord y) +static int ActionDelete(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - int id = GetFunctionID (function); + char *function = ARG(0); + int id = GetFunctionID(function); - Note.X = Crosshair.X; - Note.Y = Crosshair.Y; + Note.X = Crosshair.X; + Note.Y = Crosshair.Y; - if (id == -1) /* no arg */ - { - if (RemoveSelected() == false) - id = F_Object; - } + if (id == -1) { /* no arg */ + if (RemoveSelected() == false) + id = F_Object; + } - switch (id) - { - case F_Object: - SaveMode(); - SetMode(REMOVE_MODE); - NotifyMode(); - RestoreMode(); - break; - case F_Selected: - RemoveSelected(); - break; - case F_AllRats: - if (DeleteRats (false)) - SetChangedFlag (true); - break; - case F_SelectedRats: - if (DeleteRats (true)) - SetChangedFlag (true); - break; - } + switch (id) { + case F_Object: + SaveMode(); + SetMode(REMOVE_MODE); + NotifyMode(); + RestoreMode(); + break; + case F_Selected: + RemoveSelected(); + break; + case F_AllRats: + if (DeleteRats(false)) + SetChangedFlag(true); + break; + case F_SelectedRats: + if (DeleteRats(true)) + SetChangedFlag(true); + break; + } - return 0; + return 0; } /* --------------------------------------------------------------------------- */ -static const char deleterats_syntax[] = - "DeleteRats(AllRats|Selected|SelectedRats)"; +static const char deleterats_syntax[] = "DeleteRats(AllRats|Selected|SelectedRats)"; static const char deleterats_help[] = "Delete rat lines."; @@ -4016,28 +3615,25 @@ %end-doc */ -static int -ActionDeleteRats (int argc, char **argv, Coord x, Coord y) +static int ActionDeleteRats(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - if (function) - { - if (Settings.RatWarn) - ClearWarnings (); - switch (GetFunctionID (function)) - { - case F_AllRats: - if (DeleteRats (false)) - SetChangedFlag (true); - break; - case F_SelectedRats: - case F_Selected: - if (DeleteRats (true)) - SetChangedFlag (true); - break; + char *function = ARG(0); + if (function) { + if (Settings.RatWarn) + ClearWarnings(); + switch (GetFunctionID(function)) { + case F_AllRats: + if (DeleteRats(false)) + SetChangedFlag(true); + break; + case F_SelectedRats: + case F_Selected: + if (DeleteRats(true)) + SetChangedFlag(true); + break; + } } - } - return 0; + return 0; } /* --------------------------------------------------------------------------- */ @@ -4053,17 +3649,14 @@ %end-doc */ -static int -ActionAutoPlaceSelected (int argc, char **argv, Coord x, Coord y) +static int ActionAutoPlaceSelected(int argc, char **argv, Coord x, Coord y) { - hid_action("Busy"); - if (gui->confirm_dialog (_("Auto-placement can NOT be undone.\n" - "Do you want to continue anyway?\n"), 0)) - { - if (AutoPlaceSelected ()) - SetChangedFlag (true); - } - return 0; + hid_action("Busy"); + if (gui->confirm_dialog(_("Auto-placement can NOT be undone.\n" "Do you want to continue anyway?\n"), 0)) { + if (AutoPlaceSelected()) + SetChangedFlag(true); + } + return 0; } /* --------------------------------------------------------------------------- */ @@ -4095,34 +3688,29 @@ %end-doc */ -static int -ActionAutoRoute (int argc, char **argv, Coord x, Coord y) +static int ActionAutoRoute(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - hid_action("Busy"); - if (function) /* one parameter */ - { - switch (GetFunctionID (function)) - { - case F_AllRats: - if (AutoRoute (false)) - SetChangedFlag (true); - break; - case F_SelectedRats: - case F_Selected: - if (AutoRoute (true)) - SetChangedFlag (true); - break; + char *function = ARG(0); + hid_action("Busy"); + if (function) { /* one parameter */ + switch (GetFunctionID(function)) { + case F_AllRats: + if (AutoRoute(false)) + SetChangedFlag(true); + break; + case F_SelectedRats: + case F_Selected: + if (AutoRoute(true)) + SetChangedFlag(true); + break; + } } - } - return 0; + return 0; } /* --------------------------------------------------------------------------- */ -static const char markcrosshair_syntax[] = - "MarkCrosshair()\n" - "MarkCrosshair(Center)"; +static const char markcrosshair_syntax[] = "MarkCrosshair()\n" "MarkCrosshair(Center)"; static const char markcrosshair_help[] = "Set/Reset the Crosshair mark."; @@ -4140,82 +3728,81 @@ %end-doc */ -static int -ActionMarkCrosshair (int argc, char **argv, Coord x, Coord y) +static int ActionMarkCrosshair(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - if (!function || !*function) - { - if (Marked.status) - { - notify_mark_change (false); - Marked.status = false; - notify_mark_change (true); + char *function = ARG(0); + if (!function || !*function) { + if (Marked.status) { + notify_mark_change(false); + Marked.status = false; + notify_mark_change(true); + } + else { + notify_mark_change(false); + Marked.status = false; + Marked.status = true; + Marked.X = Crosshair.X; + Marked.Y = Crosshair.Y; + notify_mark_change(true); + } } - else - { - notify_mark_change (false); - Marked.status = false; - Marked.status = true; - Marked.X = Crosshair.X; - Marked.Y = Crosshair.Y; - notify_mark_change (true); + else if (GetFunctionID(function) == F_Center) { + notify_mark_change(false); + Marked.status = true; + Marked.X = Crosshair.X; + Marked.Y = Crosshair.Y; + notify_mark_change(true); } - } - else if (GetFunctionID (function) == F_Center) - { - notify_mark_change (false); - Marked.status = true; - Marked.X = Crosshair.X; - Marked.Y = Crosshair.Y; - notify_mark_change (true); - } - return 0; + return 0; } /* --------------------------------------------------------------------------- */ /* helper: get route style size for a function and selected object type. size_id: 0=main size; 1=2nd size (drill); 2=clearance */ -static int get_style_size(int funcid, Coord *out, int type, int size_id) +static int get_style_size(int funcid, Coord * out, int type, int size_id) { switch (funcid) { - case F_Object: - switch(type) { - case ELEMENT_TYPE: /* we'd set pin/pad properties, so fall thru */ - case VIA_TYPE: - case PIN_TYPE: return get_style_size(F_SelectedVias, out, 0, size_id); - case PAD_TYPE: return get_style_size(F_SelectedPads, out, 0, size_id); - case LINE_TYPE: return get_style_size(F_SelectedLines, out, 0, size_id); - case ARC_TYPE: return get_style_size(F_SelectedArcs, out, 0, size_id); - } - Message (_("Sorry, can't fetch the style of that object tpye (%x)\n"), type); + case F_Object: + switch (type) { + case ELEMENT_TYPE: /* we'd set pin/pad properties, so fall thru */ + case VIA_TYPE: + case PIN_TYPE: + return get_style_size(F_SelectedVias, out, 0, size_id); + case PAD_TYPE: + return get_style_size(F_SelectedPads, out, 0, size_id); + case LINE_TYPE: + return get_style_size(F_SelectedLines, out, 0, size_id); + case ARC_TYPE: + return get_style_size(F_SelectedArcs, out, 0, size_id); + } + Message(_("Sorry, can't fetch the style of that object tpye (%x)\n"), type); + return -1; + case F_SelectedPads: + if (size_id != 2) /* don't mess with pad size */ return -1; - case F_SelectedPads: - if (size_id != 2) /* don't mess with pad size */ - return -1; - case F_SelectedVias: - case F_SelectedPins: - case F_SelectedObjects: - case F_Selected: - case F_SelectedElements: - if (size_id == 0) - *out = Settings.ViaThickness; - else if (size_id == 1) - *out = Settings.ViaDrillingHole; - else - *out = Settings.Keepaway; - break; - case F_SelectedArcs: - case F_SelectedLines: - if (size_id == 2) - *out = Settings.Keepaway; - else - *out = Settings.LineThickness; - return 0; - case F_SelectedTexts: - case F_SelectedNames: - Message (_("Sorry, can't change style of every selected object\n")); - return -1; + case F_SelectedVias: + case F_SelectedPins: + case F_SelectedObjects: + case F_Selected: + case F_SelectedElements: + if (size_id == 0) + *out = Settings.ViaThickness; + else if (size_id == 1) + *out = Settings.ViaDrillingHole; + else + *out = Settings.Keepaway; + break; + case F_SelectedArcs: + case F_SelectedLines: + if (size_id == 2) + *out = Settings.Keepaway; + else + *out = Settings.LineThickness; + return 0; + case F_SelectedTexts: + case F_SelectedNames: + Message(_("Sorry, can't change style of every selected object\n")); + return -1; } return 0; } @@ -4224,11 +3811,10 @@ /* --------------------------------------------------------------------------- */ static const char changesize_syntax[] = - "ChangeSize(Object, delta|style)\n" - "ChangeSize(SelectedObjects|Selected, delta|style)\n" - "ChangeSize(SelectedLines|SelectedPins|SelectedVias, delta|style)\n" - "ChangeSize(SelectedPads|SelectedTexts|SelectedNames, delta|style)\n" - "ChangeSize(SelectedElements, delta|style)"; + "ChangeSize(Object, delta|style)\n" + "ChangeSize(SelectedObjects|Selected, delta|style)\n" + "ChangeSize(SelectedLines|SelectedPins|SelectedVias, delta|style)\n" + "ChangeSize(SelectedPads|SelectedTexts|SelectedNames, delta|style)\n" "ChangeSize(SelectedElements, delta|style)"; static const char changesize_help[] = "Changes the size of objects."; @@ -4242,183 +3828,172 @@ %end-doc */ -static int -ActionChangeSize (int argc, char **argv, Coord x, Coord y) +static int ActionChangeSize(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - char *delta = ARG (1); - char *units = ARG (2); - bool absolute; /* indicates if absolute size is given */ - Coord value; - int type, tostyle = 0; - void *ptr1, *ptr2, *ptr3; + char *function = ARG(0); + char *delta = ARG(1); + char *units = ARG(2); + bool absolute; /* indicates if absolute size is given */ + Coord value; + int type, tostyle = 0; + void *ptr1, *ptr2, *ptr3; - if (function && delta) - { - int funcid = GetFunctionID (function); + if (function && delta) { + int funcid = GetFunctionID(function); - if (funcid == F_Object) - type = SearchScreen (Crosshair.X, Crosshair.Y, CHANGESIZE_TYPES, &ptr1, &ptr2, &ptr3); + if (funcid == F_Object) + type = SearchScreen(Crosshair.X, Crosshair.Y, CHANGESIZE_TYPES, &ptr1, &ptr2, &ptr3); - if (strcmp(argv[1], "style") == 0) { - if (get_style_size(funcid, &value, type, 0) != 0) - return 1; - absolute = 1; - tostyle = 1; - } - else - value = GetValue (delta, units, &absolute); - switch (funcid) - { - case F_Object: - { - if (type != NO_TYPE) - if (TEST_FLAG (LOCKFLAG, (PinTypePtr) ptr2)) - Message (_("Sorry, the object is locked\n")); - if (tostyle) { - if (ChangeObject1stSize (type, ptr1, ptr2, ptr3, value, absolute)) - SetChangedFlag (true); + if (strcmp(argv[1], "style") == 0) { + if (get_style_size(funcid, &value, type, 0) != 0) + return 1; + absolute = 1; + tostyle = 1; + } + else + value = GetValue(delta, units, &absolute); + switch (funcid) { + case F_Object: + { + if (type != NO_TYPE) + if (TEST_FLAG(LOCKFLAG, (PinTypePtr) ptr2)) + Message(_("Sorry, the object is locked\n")); + if (tostyle) { + if (ChangeObject1stSize(type, ptr1, ptr2, ptr3, value, absolute)) + SetChangedFlag(true); + } + else { + if (ChangeObjectSize(type, ptr1, ptr2, ptr3, value, absolute)) + SetChangedFlag(true); + } + break; } - else { - if (ChangeObjectSize (type, ptr1, ptr2, ptr3, value, absolute)) - SetChangedFlag (true); - } - break; - } - case F_SelectedVias: - if (ChangeSelectedSize (VIA_TYPE, value, absolute)) - SetChangedFlag (true); - break; + case F_SelectedVias: + if (ChangeSelectedSize(VIA_TYPE, value, absolute)) + SetChangedFlag(true); + break; - case F_SelectedPins: - if (ChangeSelectedSize (PIN_TYPE, value, absolute)) - SetChangedFlag (true); - break; + case F_SelectedPins: + if (ChangeSelectedSize(PIN_TYPE, value, absolute)) + SetChangedFlag(true); + break; - case F_SelectedPads: - if (ChangeSelectedSize (PAD_TYPE, value, absolute)) - SetChangedFlag (true); - break; + case F_SelectedPads: + if (ChangeSelectedSize(PAD_TYPE, value, absolute)) + SetChangedFlag(true); + break; - case F_SelectedArcs: - if (ChangeSelectedSize (ARC_TYPE, value, absolute)) - SetChangedFlag (true); - break; + case F_SelectedArcs: + if (ChangeSelectedSize(ARC_TYPE, value, absolute)) + SetChangedFlag(true); + break; - case F_SelectedLines: - if (ChangeSelectedSize (LINE_TYPE, value, absolute)) - SetChangedFlag (true); - break; + case F_SelectedLines: + if (ChangeSelectedSize(LINE_TYPE, value, absolute)) + SetChangedFlag(true); + break; - case F_SelectedTexts: - if (ChangeSelectedSize (TEXT_TYPE, value, absolute)) - SetChangedFlag (true); - break; + case F_SelectedTexts: + if (ChangeSelectedSize(TEXT_TYPE, value, absolute)) + SetChangedFlag(true); + break; - case F_SelectedNames: - if (ChangeSelectedSize (ELEMENTNAME_TYPE, value, absolute)) - SetChangedFlag (true); - break; + case F_SelectedNames: + if (ChangeSelectedSize(ELEMENTNAME_TYPE, value, absolute)) + SetChangedFlag(true); + break; - case F_SelectedElements: - if (ChangeSelectedSize (ELEMENT_TYPE, value, absolute)) - SetChangedFlag (true); - break; + case F_SelectedElements: + if (ChangeSelectedSize(ELEMENT_TYPE, value, absolute)) + SetChangedFlag(true); + break; - case F_Selected: - case F_SelectedObjects: - if (ChangeSelectedSize (CHANGESIZE_TYPES, value, absolute)) - SetChangedFlag (true); - break; + case F_Selected: + case F_SelectedObjects: + if (ChangeSelectedSize(CHANGESIZE_TYPES, value, absolute)) + SetChangedFlag(true); + break; + } } - } - return 0; + return 0; } /* --------------------------------------------------------------------------- */ static const char changedrillsize_syntax[] = - "ChangeDrillSize(Object, delta|style)\n" - "ChangeDrillSize(SelectedPins|SelectedVias|Selected|SelectedObjects, delta|style)"; + "ChangeDrillSize(Object, delta|style)\n" "ChangeDrillSize(SelectedPins|SelectedVias|Selected|SelectedObjects, delta|style)"; -static const char changedrillsize_help[] = - "Changes the drilling hole size of objects."; +static const char changedrillsize_help[] = "Changes the drilling hole size of objects."; /* %start-doc actions ChangeDrillSize %end-doc */ -static int -ActionChange2ndSize (int argc, char **argv, Coord x, Coord y) +static int ActionChange2ndSize(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - char *delta = ARG (1); - char *units = ARG (2); - int type; - void *ptr1, *ptr2, *ptr3; + char *function = ARG(0); + char *delta = ARG(1); + char *units = ARG(2); + int type; + void *ptr1, *ptr2, *ptr3; - bool absolute; - Coord value; + bool absolute; + Coord value; - if (function && delta) - { - int funcid = GetFunctionID (function); + if (function && delta) { + int funcid = GetFunctionID(function); - if (funcid == F_Object) { - gui->get_coords (_("Select an Object"), &x, &y); - type = SearchScreen (x, y, CHANGE2NDSIZE_TYPES, &ptr1, &ptr2, &ptr3); - } + if (funcid == F_Object) { + gui->get_coords(_("Select an Object"), &x, &y); + type = SearchScreen(x, y, CHANGE2NDSIZE_TYPES, &ptr1, &ptr2, &ptr3); + } - if (strcmp(argv[1], "style") == 0) { - if (get_style_size(funcid, &value, type, 1) != 0) - return 1; - absolute = 1; - } - else - value = GetValue (delta, units, &absolute); + if (strcmp(argv[1], "style") == 0) { + if (get_style_size(funcid, &value, type, 1) != 0) + return 1; + absolute = 1; + } + else + value = GetValue(delta, units, &absolute); - switch (GetFunctionID (function)) - { - case F_Object: - { + switch (GetFunctionID(function)) { + case F_Object: + { - if (type != NO_TYPE) - if (ChangeObject2ndSize - (type, ptr1, ptr2, ptr3, value, absolute, true)) - SetChangedFlag (true); - break; - } + if (type != NO_TYPE) + if (ChangeObject2ndSize(type, ptr1, ptr2, ptr3, value, absolute, true)) + SetChangedFlag(true); + break; + } - case F_SelectedVias: - if (ChangeSelected2ndSize (VIA_TYPE, value, absolute)) - SetChangedFlag (true); - break; + case F_SelectedVias: + if (ChangeSelected2ndSize(VIA_TYPE, value, absolute)) + SetChangedFlag(true); + break; - case F_SelectedPins: - if (ChangeSelected2ndSize (PIN_TYPE, value, absolute)) - SetChangedFlag (true); - break; - case F_Selected: - case F_SelectedObjects: - if (ChangeSelected2ndSize (PIN_TYPES, value, absolute)) - SetChangedFlag (true); - break; + case F_SelectedPins: + if (ChangeSelected2ndSize(PIN_TYPE, value, absolute)) + SetChangedFlag(true); + break; + case F_Selected: + case F_SelectedObjects: + if (ChangeSelected2ndSize(PIN_TYPES, value, absolute)) + SetChangedFlag(true); + break; + } } - } - return 0; + return 0; } /* --------------------------------------------------------------------------- */ static const char changeclearsize_syntax[] = - "ChangeClearSize(Object, delta|style)\n" - "ChangeClearSize(SelectedPins|SelectedPads|SelectedVias, delta|style)\n" - "ChangeClearSize(SelectedLines|SelectedArcs, delta|style)\n" - "ChangeClearSize(Selected|SelectedObjects, delta|style)"; + "ChangeClearSize(Object, delta|style)\n" + "ChangeClearSize(SelectedPins|SelectedPads|SelectedVias, delta|style)\n" + "ChangeClearSize(SelectedLines|SelectedArcs, delta|style)\n" "ChangeClearSize(Selected|SelectedObjects, delta|style)"; -static const char changeclearsize_help[] = - "Changes the clearance size of objects."; +static const char changeclearsize_help[] = "Changes the clearance size of objects."; /* %start-doc actions ChangeClearSize @@ -4428,83 +4003,79 @@ %end-doc */ -static int -ActionChangeClearSize (int argc, char **argv, Coord x, Coord y) +static int ActionChangeClearSize(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - char *delta = ARG (1); - char *units = ARG (2); - bool absolute; - Coord value; - int type; - void *ptr1, *ptr2, *ptr3; + char *function = ARG(0); + char *delta = ARG(1); + char *units = ARG(2); + bool absolute; + Coord value; + int type; + void *ptr1, *ptr2, *ptr3; - if (function && delta) - { - int funcid = GetFunctionID (function); + if (function && delta) { + int funcid = GetFunctionID(function); - if (funcid == F_Object) { - gui->get_coords (_("Select an Object"), &x, &y); - type = SearchScreen (x, y, CHANGECLEARSIZE_TYPES, &ptr1, &ptr2, &ptr3); - } + if (funcid == F_Object) { + gui->get_coords(_("Select an Object"), &x, &y); + type = SearchScreen(x, y, CHANGECLEARSIZE_TYPES, &ptr1, &ptr2, &ptr3); + } - if (strcmp(argv[1], "style") == 0) { - if ((type == NO_TYPE) || (type == POLYGON_TYPE)) /* workaround: SearchScreen(CHANGECLEARSIZE_TYPES) wouldn't return elements */ - type = SearchScreen (x, y, CHANGE2NDSIZE_TYPES, &ptr1, &ptr2, &ptr3); - if (get_style_size(funcid, &value, type, 2) != 0) - return 1; - absolute = 1; - value *= 2; - } - else - value = 2 * GetValue (delta, units, &absolute); - switch (GetFunctionID (function)) - { - case F_Object: - { - if (type != NO_TYPE) - if (ChangeObjectClearSize (type, ptr1, ptr2, ptr3, value, absolute)) - SetChangedFlag (true); - break; - } - case F_SelectedVias: - if (ChangeSelectedClearSize (VIA_TYPE, value, absolute)) - SetChangedFlag (true); - break; - case F_SelectedPads: - if (ChangeSelectedClearSize (PAD_TYPE, value, absolute)) - SetChangedFlag (true); - break; - case F_SelectedPins: - if (ChangeSelectedClearSize (PIN_TYPE, value, absolute)) - SetChangedFlag (true); - break; - case F_SelectedLines: - if (ChangeSelectedClearSize (LINE_TYPE, value, absolute)) - SetChangedFlag (true); - break; - case F_SelectedArcs: - if (ChangeSelectedClearSize (ARC_TYPE, value, absolute)) - SetChangedFlag (true); - break; - case F_Selected: - case F_SelectedObjects: - if (ChangeSelectedClearSize (CHANGECLEARSIZE_TYPES, value, absolute)) - SetChangedFlag (true); - break; + if (strcmp(argv[1], "style") == 0) { + if ((type == NO_TYPE) || (type == POLYGON_TYPE)) /* workaround: SearchScreen(CHANGECLEARSIZE_TYPES) wouldn't return elements */ + type = SearchScreen(x, y, CHANGE2NDSIZE_TYPES, &ptr1, &ptr2, &ptr3); + if (get_style_size(funcid, &value, type, 2) != 0) + return 1; + absolute = 1; + value *= 2; + } + else + value = 2 * GetValue(delta, units, &absolute); + switch (GetFunctionID(function)) { + case F_Object: + { + if (type != NO_TYPE) + if (ChangeObjectClearSize(type, ptr1, ptr2, ptr3, value, absolute)) + SetChangedFlag(true); + break; + } + case F_SelectedVias: + if (ChangeSelectedClearSize(VIA_TYPE, value, absolute)) + SetChangedFlag(true); + break; + case F_SelectedPads: + if (ChangeSelectedClearSize(PAD_TYPE, value, absolute)) + SetChangedFlag(true); + break; + case F_SelectedPins: + if (ChangeSelectedClearSize(PIN_TYPE, value, absolute)) + SetChangedFlag(true); + break; + case F_SelectedLines: + if (ChangeSelectedClearSize(LINE_TYPE, value, absolute)) + SetChangedFlag(true); + break; + case F_SelectedArcs: + if (ChangeSelectedClearSize(ARC_TYPE, value, absolute)) + SetChangedFlag(true); + break; + case F_Selected: + case F_SelectedObjects: + if (ChangeSelectedClearSize(CHANGECLEARSIZE_TYPES, value, absolute)) + SetChangedFlag(true); + break; + } } - } - return 0; + return 0; } /* --------------------------------------------------------------------------- */ static const char changesizes_syntax[] = - "ChangeSizes(Object, delta|style)\n" - "ChangeSizes(SelectedObjects|Selected, delta|style)\n" - "ChangeSizes(SelectedLines|SelectedPins|SelectedVias, delta|style)\n" - "ChangeSizes(SelectedPads|SelectedTexts|SelectedNames, delta|style)\n" - "ChangeSizes(SelectedElements, delta|style)"; + "ChangeSizes(Object, delta|style)\n" + "ChangeSizes(SelectedObjects|Selected, delta|style)\n" + "ChangeSizes(SelectedLines|SelectedPins|SelectedVias, delta|style)\n" + "ChangeSizes(SelectedPads|SelectedTexts|SelectedNames, delta|style)\n" "ChangeSizes(SelectedElements, delta|style)"; static const char changesizes_help[] = "Changes all sizes of objects."; @@ -4514,8 +4085,7 @@ with the same arguments. If any of them did not fail, return success. %end-doc */ -static int -ActionChangeSizes (int argc, char **argv, Coord x, Coord y) +static int ActionChangeSizes(int argc, char **argv, Coord x, Coord y) { int a, b, c; SaveUndoSerialNumber(); @@ -4531,12 +4101,9 @@ /* --------------------------------------------------------------------------- */ -static const char minmaskgap_syntax[] = - "MinMaskGap(delta)\n" - "MinMaskGap(Selected, delta)"; +static const char minmaskgap_syntax[] = "MinMaskGap(delta)\n" "MinMaskGap(Selected, delta)"; -static const char minmaskgap_help[] = - "Ensures the mask is a minimum distance from pins and pads."; +static const char minmaskgap_help[] = "Ensures the mask is a minimum distance from pins and pads."; /* %start-doc actions MinMaskGap @@ -4546,81 +4113,71 @@ %end-doc */ -static int -ActionMinMaskGap (int argc, char **argv, Coord x, Coord y) +static int ActionMinMaskGap(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - char *delta = ARG (1); - char *units = ARG (2); - bool absolute; - Coord value; - int flags; + char *function = ARG(0); + char *delta = ARG(1); + char *units = ARG(2); + bool absolute; + Coord value; + int flags; - if (!function) - return 1; - if (strcasecmp (function, "Selected") == 0) - flags = SELECTEDFLAG; - else - { - units = delta; - delta = function; - flags = 0; - } - value = 2 * GetValue (delta, units, &absolute); + if (!function) + return 1; + if (strcasecmp(function, "Selected") == 0) + flags = SELECTEDFLAG; + else { + units = delta; + delta = function; + flags = 0; + } + value = 2 * GetValue(delta, units, &absolute); - SaveUndoSerialNumber (); - ELEMENT_LOOP (PCB->Data); - { - PIN_LOOP (element); - { - if (!TEST_FLAGS (flags, pin)) - continue; - if (pin->Mask < pin->Thickness + value) + SaveUndoSerialNumber(); + ELEMENT_LOOP(PCB->Data); { - ChangeObjectMaskSize (PIN_TYPE, element, pin, 0, - pin->Thickness + value, 1); - RestoreUndoSerialNumber (); + PIN_LOOP(element); + { + if (!TEST_FLAGS(flags, pin)) + continue; + if (pin->Mask < pin->Thickness + value) { + ChangeObjectMaskSize(PIN_TYPE, element, pin, 0, pin->Thickness + value, 1); + RestoreUndoSerialNumber(); + } + } + END_LOOP; + PAD_LOOP(element); + { + if (!TEST_FLAGS(flags, pad)) + continue; + if (pad->Mask < pad->Thickness + value) { + ChangeObjectMaskSize(PAD_TYPE, element, pad, 0, pad->Thickness + value, 1); + RestoreUndoSerialNumber(); + } + } + END_LOOP; } - } - END_LOOP; - PAD_LOOP (element); - { - if (!TEST_FLAGS (flags, pad)) - continue; - if (pad->Mask < pad->Thickness + value) + END_LOOP; + VIA_LOOP(PCB->Data); { - ChangeObjectMaskSize (PAD_TYPE, element, pad, 0, - pad->Thickness + value, 1); - RestoreUndoSerialNumber (); + if (!TEST_FLAGS(flags, via)) + continue; + if (via->Mask && via->Mask < via->Thickness + value) { + ChangeObjectMaskSize(VIA_TYPE, via, 0, 0, via->Thickness + value, 1); + RestoreUndoSerialNumber(); + } } - } - END_LOOP; - } - END_LOOP; - VIA_LOOP (PCB->Data); - { - if (!TEST_FLAGS (flags, via)) - continue; - if (via->Mask && via->Mask < via->Thickness + value) - { - ChangeObjectMaskSize (VIA_TYPE, via, 0, 0, via->Thickness + value, 1); - RestoreUndoSerialNumber (); - } - } - END_LOOP; - RestoreUndoSerialNumber (); - IncrementUndoSerialNumber (); - return 0; + END_LOOP; + RestoreUndoSerialNumber(); + IncrementUndoSerialNumber(); + return 0; } /* --------------------------------------------------------------------------- */ -static const char mincleargap_syntax[] = - "MinClearGap(delta)\n" - "MinClearGap(Selected, delta)"; +static const char mincleargap_syntax[] = "MinClearGap(delta)\n" "MinClearGap(Selected, delta)"; -static const char mincleargap_help[] = - "Ensures that polygons are a minimum distance from objects."; +static const char mincleargap_help[] = "Ensures that polygons are a minimum distance from objects."; /* %start-doc actions MinClearGap @@ -4630,102 +4187,91 @@ %end-doc */ -static int -ActionMinClearGap (int argc, char **argv, Coord x, Coord y) +static int ActionMinClearGap(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - char *delta = ARG (1); - char *units = ARG (2); - bool absolute; - Coord value; - int flags; + char *function = ARG(0); + char *delta = ARG(1); + char *units = ARG(2); + bool absolute; + Coord value; + int flags; - if (!function) - return 1; - if (strcasecmp (function, "Selected") == 0) - flags = SELECTEDFLAG; - else - { - units = delta; - delta = function; - flags = 0; - } - value = 2 * GetValue (delta, units, &absolute); + if (!function) + return 1; + if (strcasecmp(function, "Selected") == 0) + flags = SELECTEDFLAG; + else { + units = delta; + delta = function; + flags = 0; + } + value = 2 * GetValue(delta, units, &absolute); - SaveUndoSerialNumber (); - ELEMENT_LOOP (PCB->Data); - { - PIN_LOOP (element); - { - if (!TEST_FLAGS (flags, pin)) - continue; - if (pin->Clearance < value) + SaveUndoSerialNumber(); + ELEMENT_LOOP(PCB->Data); { - ChangeObjectClearSize (PIN_TYPE, element, pin, 0, - value, 1); - RestoreUndoSerialNumber (); + PIN_LOOP(element); + { + if (!TEST_FLAGS(flags, pin)) + continue; + if (pin->Clearance < value) { + ChangeObjectClearSize(PIN_TYPE, element, pin, 0, value, 1); + RestoreUndoSerialNumber(); + } + } + END_LOOP; + PAD_LOOP(element); + { + if (!TEST_FLAGS(flags, pad)) + continue; + if (pad->Clearance < value) { + ChangeObjectClearSize(PAD_TYPE, element, pad, 0, value, 1); + RestoreUndoSerialNumber(); + } + } + END_LOOP; } - } - END_LOOP; - PAD_LOOP (element); - { - if (!TEST_FLAGS (flags, pad)) - continue; - if (pad->Clearance < value) + END_LOOP; + VIA_LOOP(PCB->Data); { - ChangeObjectClearSize (PAD_TYPE, element, pad, 0, - value, 1); - RestoreUndoSerialNumber (); + if (!TEST_FLAGS(flags, via)) + continue; + if (via->Clearance < value) { + ChangeObjectClearSize(VIA_TYPE, via, 0, 0, value, 1); + RestoreUndoSerialNumber(); + } } - } - END_LOOP; - } - END_LOOP; - VIA_LOOP (PCB->Data); - { - if (!TEST_FLAGS (flags, via)) - continue; - if (via->Clearance < value) - { - ChangeObjectClearSize (VIA_TYPE, via, 0, 0, value, 1); - RestoreUndoSerialNumber (); - } - } - END_LOOP; - ALLLINE_LOOP (PCB->Data); - { - if (!TEST_FLAGS (flags, line)) - continue; - if (line->Clearance < value) - { - ChangeObjectClearSize (LINE_TYPE, layer, line, 0, value, 1); - RestoreUndoSerialNumber (); - } - } - ENDALL_LOOP; - ALLARC_LOOP (PCB->Data); - { - if (!TEST_FLAGS (flags, arc)) - continue; - if (arc->Clearance < value) - { - ChangeObjectClearSize (ARC_TYPE, layer, arc, 0, value, 1); - RestoreUndoSerialNumber (); - } - } - ENDALL_LOOP; - RestoreUndoSerialNumber (); - IncrementUndoSerialNumber (); - return 0; + END_LOOP; + ALLLINE_LOOP(PCB->Data); + { + if (!TEST_FLAGS(flags, line)) + continue; + if (line->Clearance < value) { + ChangeObjectClearSize(LINE_TYPE, layer, line, 0, value, 1); + RestoreUndoSerialNumber(); + } + } + ENDALL_LOOP; + ALLARC_LOOP(PCB->Data); + { + if (!TEST_FLAGS(flags, arc)) + continue; + if (arc->Clearance < value) { + ChangeObjectClearSize(ARC_TYPE, layer, arc, 0, value, 1); + RestoreUndoSerialNumber(); + } + } + ENDALL_LOOP; + RestoreUndoSerialNumber(); + IncrementUndoSerialNumber(); + return 0; } /* --------------------------------------------------------------------------- */ -static const char changepinname_syntax[] = - "ChangePinName(ElementName,PinNumber,PinName)"; +static const char changepinname_syntax[] = "ChangePinName(ElementName,PinNumber,PinName)"; -static const char changepinname_help[] = - "Sets the name of a specific pin on a specific element."; +static const char changepinname_help[] = "Sets the name of a specific pin on a specific element."; /* %start-doc actions ChangePinName @@ -4739,85 +4285,73 @@ %end-doc */ -static int -ActionChangePinName (int argc, char **argv, Coord x, Coord y) +static int ActionChangePinName(int argc, char **argv, Coord x, Coord y) { - int changed = 0; - char *refdes, *pinnum, *pinname; + int changed = 0; + char *refdes, *pinnum, *pinname; - if (argc != 3) - { - AFAIL (changepinname); - } + if (argc != 3) { + AFAIL(changepinname); + } - refdes = argv[0]; - pinnum = argv[1]; - pinname = argv[2]; + refdes = argv[0]; + pinnum = argv[1]; + pinname = argv[2]; - ELEMENT_LOOP (PCB->Data); - { - if (NSTRCMP (refdes, NAMEONPCB_NAME (element)) == 0) - { - PIN_LOOP (element); + ELEMENT_LOOP(PCB->Data); { - if (NSTRCMP (pinnum, pin->Number) == 0) - { - AddObjectToChangeNameUndoList (PIN_TYPE, NULL, NULL, - pin, pin->Name); - /* - * Note: we can't free() pin->Name first because - * it is used in the undo list - */ - pin->Name = strdup (pinname); - SetChangedFlag (true); - changed = 1; - } - } - END_LOOP; + if (NSTRCMP(refdes, NAMEONPCB_NAME(element)) == 0) { + PIN_LOOP(element); + { + if (NSTRCMP(pinnum, pin->Number) == 0) { + AddObjectToChangeNameUndoList(PIN_TYPE, NULL, NULL, pin, pin->Name); + /* + * Note: we can't free() pin->Name first because + * it is used in the undo list + */ + pin->Name = strdup(pinname); + SetChangedFlag(true); + changed = 1; + } + } + END_LOOP; - PAD_LOOP (element); - { - if (NSTRCMP (pinnum, pad->Number) == 0) - { - AddObjectToChangeNameUndoList (PAD_TYPE, NULL, NULL, - pad, pad->Name); - /* - * Note: we can't free() pad->Name first because - * it is used in the undo list - */ - pad->Name = strdup (pinname); - SetChangedFlag (true); - changed = 1; - } + PAD_LOOP(element); + { + if (NSTRCMP(pinnum, pad->Number) == 0) { + AddObjectToChangeNameUndoList(PAD_TYPE, NULL, NULL, pad, pad->Name); + /* + * Note: we can't free() pad->Name first because + * it is used in the undo list + */ + pad->Name = strdup(pinname); + SetChangedFlag(true); + changed = 1; + } + } + END_LOOP; + } } END_LOOP; - } - } - END_LOOP; - /* - * done with our action so increment the undo # if we actually - * changed anything - */ - if (changed) - { - if (defer_updates) - defer_needs_update = 1; - else - { - IncrementUndoSerialNumber (); - gui->invalidate_all (); + /* + * done with our action so increment the undo # if we actually + * changed anything + */ + if (changed) { + if (defer_updates) + defer_needs_update = 1; + else { + IncrementUndoSerialNumber(); + gui->invalidate_all(); + } } - } - return 0; + return 0; } /* --------------------------------------------------------------------------- */ -static const char changename_syntax[] = - "ChangeName(Object)\n" - "ChangeName(Object|\"Number\")\n" - "ChangeName(Layout|Layer)"; +static const char changename_syntax[] = "ChangeName(Object)\n" "ChangeName(Object|\"Number\")\n" "ChangeName(Layout|Layer)"; static const char changename_help[] = "Sets the name (or pin number) of objects."; @@ -4838,83 +4372,69 @@ %end-doc */ -int -ActionChangeName (int argc, char **argv, Coord x, Coord y) +int ActionChangeName(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - char *pinnums = ARG (1); - char *name; - int pinnum; + char *function = ARG(0); + char *pinnums = ARG(1); + char *name; + int pinnum; - if (function) - { - switch (GetFunctionID (function)) - { - /* change the name of an object */ - case F_Object: - { - int type; - void *ptr1, *ptr2, *ptr3; + if (function) { + switch (GetFunctionID(function)) { + /* change the name of an object */ + case F_Object: + { + int type; + void *ptr1, *ptr2, *ptr3; - gui->get_coords (_("Select an Object"), &x, &y); - if ((type = - SearchScreen (x, y, CHANGENAME_TYPES, - &ptr1, &ptr2, &ptr3)) != NO_TYPE) - { - SaveUndoSerialNumber (); - if ((pinnums != NULL) && (strcasecmp(pinnums, "Number") == 0)) - pinnum = 1; - else - pinnum = 0; - if (QueryInputAndChangeObjectName (type, ptr1, ptr2, ptr3, pinnum)) - { - SetChangedFlag (true); - if (type == ELEMENT_TYPE) - { - RubberbandTypePtr ptr; - int i; + gui->get_coords(_("Select an Object"), &x, &y); + if ((type = SearchScreen(x, y, CHANGENAME_TYPES, &ptr1, &ptr2, &ptr3)) != NO_TYPE) { + SaveUndoSerialNumber(); + if ((pinnums != NULL) && (strcasecmp(pinnums, "Number") == 0)) + pinnum = 1; + else + pinnum = 0; + if (QueryInputAndChangeObjectName(type, ptr1, ptr2, ptr3, pinnum)) { + SetChangedFlag(true); + if (type == ELEMENT_TYPE) { + RubberbandTypePtr ptr; + int i; - RestoreUndoSerialNumber (); - Crosshair.AttachedObject.RubberbandN = 0; - LookupRatLines (type, ptr1, ptr2, ptr3); - ptr = Crosshair.AttachedObject.Rubberband; - for (i = 0; i < Crosshair.AttachedObject.RubberbandN; - i++, ptr++) - { - if (PCB->RatOn) - EraseRat ((RatTypePtr) ptr->Line); - MoveObjectToRemoveUndoList (RATLINE_TYPE, - ptr->Line, ptr->Line, - ptr->Line); - } - IncrementUndoSerialNumber (); - Draw (); - } - } - } - break; - } + RestoreUndoSerialNumber(); + Crosshair.AttachedObject.RubberbandN = 0; + LookupRatLines(type, ptr1, ptr2, ptr3); + ptr = Crosshair.AttachedObject.Rubberband; + for (i = 0; i < Crosshair.AttachedObject.RubberbandN; i++, ptr++) { + if (PCB->RatOn) + EraseRat((RatTypePtr) ptr->Line); + MoveObjectToRemoveUndoList(RATLINE_TYPE, ptr->Line, ptr->Line, ptr->Line); + } + IncrementUndoSerialNumber(); + Draw(); + } + } + } + break; + } - /* change the layout's name */ - case F_Layout: - name = - gui->prompt_for (_("Enter the layout name:"), EMPTY (PCB->Name)); - /* NB: ChangeLayoutName takes ownership of the passed memory */ - if (name && ChangeLayoutName (name)) - SetChangedFlag (true); - break; + /* change the layout's name */ + case F_Layout: + name = gui->prompt_for(_("Enter the layout name:"), EMPTY(PCB->Name)); + /* NB: ChangeLayoutName takes ownership of the passed memory */ + if (name && ChangeLayoutName(name)) + SetChangedFlag(true); + break; - /* change the name of the active layer */ - case F_Layer: - name = gui->prompt_for (_("Enter the layer name:"), - EMPTY (CURRENT->Name)); - /* NB: ChangeLayerName takes ownership of the passed memory */ - if (name && ChangeLayerName (CURRENT, name)) - SetChangedFlag (true); - break; + /* change the name of the active layer */ + case F_Layer: + name = gui->prompt_for(_("Enter the layer name:"), EMPTY(CURRENT->Name)); + /* NB: ChangeLayerName takes ownership of the passed memory */ + if (name && ChangeLayerName(CURRENT, name)) + SetChangedFlag(true); + break; + } } - } - return 0; + return 0; } @@ -4922,8 +4442,7 @@ static const char morphpolygon_syntax[] = "MorphPolygon(Object|Selected)"; -static const char morphpolygon_help[] = - "Converts dead polygon islands into separate polygons."; +static const char morphpolygon_help[] = "Converts dead polygon islands into separate polygons."; /* %start-doc actions MorphPolygon @@ -4935,52 +4454,45 @@ %end-doc */ -static int -ActionMorphPolygon (int argc, char **argv, Coord x, Coord y) +static int ActionMorphPolygon(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - if (function) - { - switch (GetFunctionID (function)) - { - case F_Object: - { - int type; - void *ptr1, *ptr2, *ptr3; + char *function = ARG(0); + if (function) { + switch (GetFunctionID(function)) { + case F_Object: + { + int type; + void *ptr1, *ptr2, *ptr3; - gui->get_coords (_("Select an Object"), &x, &y); - if ((type = SearchScreen (x, y, POLYGON_TYPE, - &ptr1, &ptr2, &ptr3)) != NO_TYPE) - { - MorphPolygon ((LayerType *) ptr1, (PolygonType *) ptr3); - Draw (); - IncrementUndoSerialNumber (); - } - break; - } - case F_Selected: - case F_SelectedObjects: - ALLPOLYGON_LOOP (PCB->Data); - { - if (TEST_FLAG (SELECTEDFLAG, polygon)) - MorphPolygon (layer, polygon); - } - ENDALL_LOOP; - Draw (); - IncrementUndoSerialNumber (); - break; + gui->get_coords(_("Select an Object"), &x, &y); + if ((type = SearchScreen(x, y, POLYGON_TYPE, &ptr1, &ptr2, &ptr3)) != NO_TYPE) { + MorphPolygon((LayerType *) ptr1, (PolygonType *) ptr3); + Draw(); + IncrementUndoSerialNumber(); + } + break; + } + case F_Selected: + case F_SelectedObjects: + ALLPOLYGON_LOOP(PCB->Data); + { + if (TEST_FLAG(SELECTEDFLAG, polygon)) + MorphPolygon(layer, polygon); + } + ENDALL_LOOP; + Draw(); + IncrementUndoSerialNumber(); + break; + } } - } - return 0; + return 0; } /* --------------------------------------------------------------------------- */ -static const char togglehidename_syntax[] = - "ToggleHideName(Object|SelectedElements)"; +static const char togglehidename_syntax[] = "ToggleHideName(Object|SelectedElements)"; -static const char togglehidename_help[] = - "Toggles the visibility of element names."; +static const char togglehidename_help[] = "Toggles the visibility of element names."; /* %start-doc actions ToggleHideName @@ -4989,70 +4501,58 @@ %end-doc */ -static int -ActionToggleHideName (int argc, char **argv, Coord x, Coord y) +static int ActionToggleHideName(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - if (function && PCB->ElementOn) - { - switch (GetFunctionID (function)) - { - case F_Object: - { - int type; - void *ptr1, *ptr2, *ptr3; + char *function = ARG(0); + if (function && PCB->ElementOn) { + switch (GetFunctionID(function)) { + case F_Object: + { + int type; + void *ptr1, *ptr2, *ptr3; - gui->get_coords (_("Select an Object"), &x, &y); - if ((type = SearchScreen (x, y, ELEMENT_TYPE, - &ptr1, &ptr2, &ptr3)) != NO_TYPE) - { - AddObjectToFlagUndoList (type, ptr1, ptr2, ptr3); - EraseElementName ((ElementTypePtr) ptr2); - TOGGLE_FLAG (HIDENAMEFLAG, (ElementTypePtr) ptr2); - DrawElementName ((ElementTypePtr) ptr2); - Draw (); - IncrementUndoSerialNumber (); - } - break; - } - case F_SelectedElements: - case F_Selected: - { - bool changed = false; - ELEMENT_LOOP (PCB->Data); - { - if ((TEST_FLAG (SELECTEDFLAG, element) || - TEST_FLAG (SELECTEDFLAG, - &NAMEONPCB_TEXT (element))) - && (FRONT (element) || PCB->InvisibleObjectsOn)) - { - AddObjectToFlagUndoList (ELEMENT_TYPE, element, - element, element); - EraseElementName (element); - TOGGLE_FLAG (HIDENAMEFLAG, element); - DrawElementName (element); - changed = true; + gui->get_coords(_("Select an Object"), &x, &y); + if ((type = SearchScreen(x, y, ELEMENT_TYPE, &ptr1, &ptr2, &ptr3)) != NO_TYPE) { + AddObjectToFlagUndoList(type, ptr1, ptr2, ptr3); + EraseElementName((ElementTypePtr) ptr2); + TOGGLE_FLAG(HIDENAMEFLAG, (ElementTypePtr) ptr2); + DrawElementName((ElementTypePtr) ptr2); + Draw(); + IncrementUndoSerialNumber(); + } + break; + } + case F_SelectedElements: + case F_Selected: + { + bool changed = false; + ELEMENT_LOOP(PCB->Data); + { + if ((TEST_FLAG(SELECTEDFLAG, element) || TEST_FLAG(SELECTEDFLAG, &NAMEONPCB_TEXT(element))) + && (FRONT(element) || PCB->InvisibleObjectsOn)) { + AddObjectToFlagUndoList(ELEMENT_TYPE, element, element, element); + EraseElementName(element); + TOGGLE_FLAG(HIDENAMEFLAG, element); + DrawElementName(element); + changed = true; + } + } + END_LOOP; + if (changed) { + Draw(); + IncrementUndoSerialNumber(); + } + } } - } - END_LOOP; - if (changed) - { - Draw (); - IncrementUndoSerialNumber (); - } - } } - } - return 0; + return 0; } /* --------------------------------------------------------------------------- */ -static const char changejoin_syntax[] = - "ChangeJoin(ToggleObject|SelectedLines|SelectedArcs|Selected)"; +static const char changejoin_syntax[] = "ChangeJoin(ToggleObject|SelectedLines|SelectedArcs|Selected)"; -static const char changejoin_help[] = - "Changes the join (clearance through polygons) of objects."; +static const char changejoin_help[] = "Changes the join (clearance through polygons) of objects."; /* %start-doc actions ChangeJoin @@ -5064,58 +4564,50 @@ %end-doc */ -static int -ActionChangeJoin (int argc, char **argv, Coord x, Coord y) +static int ActionChangeJoin(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - if (function) - { - switch (GetFunctionID (function)) - { - case F_ToggleObject: - case F_Object: - { - int type; - void *ptr1, *ptr2, *ptr3; + char *function = ARG(0); + if (function) { + switch (GetFunctionID(function)) { + case F_ToggleObject: + case F_Object: + { + int type; + void *ptr1, *ptr2, *ptr3; - gui->get_coords (_("Select an Object"), &x, &y); - if ((type = - SearchScreen (x, y, CHANGEJOIN_TYPES, - &ptr1, &ptr2, &ptr3)) != NO_TYPE) - if (ChangeObjectJoin (type, ptr1, ptr2, ptr3)) - SetChangedFlag (true); - break; - } + gui->get_coords(_("Select an Object"), &x, &y); + if ((type = SearchScreen(x, y, CHANGEJOIN_TYPES, &ptr1, &ptr2, &ptr3)) != NO_TYPE) + if (ChangeObjectJoin(type, ptr1, ptr2, ptr3)) + SetChangedFlag(true); + break; + } - case F_SelectedLines: - if (ChangeSelectedJoin (LINE_TYPE)) - SetChangedFlag (true); - break; + case F_SelectedLines: + if (ChangeSelectedJoin(LINE_TYPE)) + SetChangedFlag(true); + break; - case F_SelectedArcs: - if (ChangeSelectedJoin (ARC_TYPE)) - SetChangedFlag (true); - break; + case F_SelectedArcs: + if (ChangeSelectedJoin(ARC_TYPE)) + SetChangedFlag(true); + break; - case F_Selected: - case F_SelectedObjects: - if (ChangeSelectedJoin (CHANGEJOIN_TYPES)) - SetChangedFlag (true); - break; + case F_Selected: + case F_SelectedObjects: + if (ChangeSelectedJoin(CHANGEJOIN_TYPES)) + SetChangedFlag(true); + break; + } } - } - return 0; + return 0; } /* --------------------------------------------------------------------------- */ static const char changenonetlist_syntax[] = - "ChangeNonetlist(ToggleObject)\n" - "ChangeNonetlist(SelectedElements)\n" - "ChangeNonetlist(Selected|SelectedObjects)"; + "ChangeNonetlist(ToggleObject)\n" "ChangeNonetlist(SelectedElements)\n" "ChangeNonetlist(Selected|SelectedObjects)"; -static const char changenonetlist_help[] = - "Changes the nonetlist flag of elements."; +static const char changenonetlist_help[] = "Changes the nonetlist flag of elements."; /* %start-doc actions ChangeNonetlist @@ -5125,38 +4617,34 @@ %end-doc */ -static int -ActionChangeNonetlist (int argc, char **argv, Coord x, Coord y) +static int ActionChangeNonetlist(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - if (function) - { - switch (GetFunctionID (function)) - { - case F_ToggleObject: - case F_Object: - case F_Element: - { - int type; - void *ptr1, *ptr2, *ptr3; - gui->get_coords (_("Select an Element"), &x, &y); + char *function = ARG(0); + if (function) { + switch (GetFunctionID(function)) { + case F_ToggleObject: + case F_Object: + case F_Element: + { + int type; + void *ptr1, *ptr2, *ptr3; + gui->get_coords(_("Select an Element"), &x, &y); - ptr3 = NULL; - type = SearchScreen (x, y, CHANGENONETLIST_TYPES, - &ptr1, &ptr2, &ptr3); - if (ChangeObjectNonetlist (type, ptr1, ptr2, ptr3)) - SetChangedFlag (true); + ptr3 = NULL; + type = SearchScreen(x, y, CHANGENONETLIST_TYPES, &ptr1, &ptr2, &ptr3); + if (ChangeObjectNonetlist(type, ptr1, ptr2, ptr3)) + SetChangedFlag(true); + break; + } + case F_SelectedElements: + case F_Selected: + case F_SelectedObjects: + if (ChangeSelectedNonetlist(ELEMENT_TYPE)) + SetChangedFlag(true); break; } - case F_SelectedElements: - case F_Selected: - case F_SelectedObjects: - if (ChangeSelectedNonetlist (ELEMENT_TYPE)) - SetChangedFlag (true); - break; } - } - return 0; + return 0; } @@ -5163,12 +4651,9 @@ /* --------------------------------------------------------------------------- */ static const char changesquare_syntax[] = - "ChangeSquare(ToggleObject)\n" - "ChangeSquare(SelectedElements|SelectedPins)\n" - "ChangeSquare(Selected|SelectedObjects)"; + "ChangeSquare(ToggleObject)\n" "ChangeSquare(SelectedElements|SelectedPins)\n" "ChangeSquare(Selected|SelectedObjects)"; -static const char changesquare_help[] = - "Changes the square flag of pins and pads."; +static const char changesquare_help[] = "Changes the square flag of pins and pads."; /* %start-doc actions ChangeSquare @@ -5178,62 +4663,57 @@ %end-doc */ -static int -ActionChangeSquare (int argc, char **argv, Coord x, Coord y) +static int ActionChangeSquare(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - if (function) - { - switch (GetFunctionID (function)) - { - case F_ToggleObject: - case F_Object: - { - int type; - void *ptr1, *ptr2, *ptr3; + char *function = ARG(0); + if (function) { + switch (GetFunctionID(function)) { + case F_ToggleObject: + case F_Object: + { + int type; + void *ptr1, *ptr2, *ptr3; - gui->get_coords (_("Select an Object"), &x, &y); + gui->get_coords(_("Select an Object"), &x, &y); - ptr3 = NULL; - type = SearchScreen (x, y, CHANGESQUARE_TYPES, - &ptr1, &ptr2, &ptr3); + ptr3 = NULL; + type = SearchScreen(x, y, CHANGESQUARE_TYPES, &ptr1, &ptr2, &ptr3); - if (ptr3 != NULL) { - int qstyle = GET_SQUARE ((PinTypePtr) ptr3); - qstyle++; - if (qstyle > 17) - qstyle = 0; - if (type != NO_TYPE) - if (ChangeObjectSquare (type, ptr1, ptr2, ptr3, qstyle)) - SetChangedFlag (true); - } - break; - } + if (ptr3 != NULL) { + int qstyle = GET_SQUARE((PinTypePtr) ptr3); + qstyle++; + if (qstyle > 17) + qstyle = 0; + if (type != NO_TYPE) + if (ChangeObjectSquare(type, ptr1, ptr2, ptr3, qstyle)) + SetChangedFlag(true); + } + break; + } - case F_SelectedElements: - if (ChangeSelectedSquare (ELEMENT_TYPE)) - SetChangedFlag (true); - break; + case F_SelectedElements: + if (ChangeSelectedSquare(ELEMENT_TYPE)) + SetChangedFlag(true); + break; - case F_SelectedPins: - if (ChangeSelectedSquare (PIN_TYPE | PAD_TYPE)) - SetChangedFlag (true); - break; + case F_SelectedPins: + if (ChangeSelectedSquare(PIN_TYPE | PAD_TYPE)) + SetChangedFlag(true); + break; - case F_Selected: - case F_SelectedObjects: - if (ChangeSelectedSquare (PIN_TYPE | PAD_TYPE)) - SetChangedFlag (true); - break; + case F_Selected: + case F_SelectedObjects: + if (ChangeSelectedSquare(PIN_TYPE | PAD_TYPE)) + SetChangedFlag(true); + break; + } } - } - return 0; + return 0; } /* --------------------------------------------------------------------------- */ -static const char setsquare_syntax[] = - "SetSquare(ToggleObject|SelectedElements|SelectedPins)"; +static const char setsquare_syntax[] = "SetSquare(ToggleObject|SelectedElements|SelectedPins)"; static const char setsquare_help[] = "sets the square-flag of objects."; @@ -5245,56 +4725,49 @@ %end-doc */ -static int -ActionSetSquare (int argc, char **argv, Coord x, Coord y) +static int ActionSetSquare(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - if (function && *function) - { - switch (GetFunctionID (function)) - { - case F_ToggleObject: - case F_Object: - { - int type; - void *ptr1, *ptr2, *ptr3; + char *function = ARG(0); + if (function && *function) { + switch (GetFunctionID(function)) { + case F_ToggleObject: + case F_Object: + { + int type; + void *ptr1, *ptr2, *ptr3; - gui->get_coords (_("Select an Object"), &x, &y); - if ((type = - SearchScreen (x, y, CHANGESQUARE_TYPES, - &ptr1, &ptr2, &ptr3)) != NO_TYPE) - if (SetObjectSquare (type, ptr1, ptr2, ptr3)) - SetChangedFlag (true); - break; - } + gui->get_coords(_("Select an Object"), &x, &y); + if ((type = SearchScreen(x, y, CHANGESQUARE_TYPES, &ptr1, &ptr2, &ptr3)) != NO_TYPE) + if (SetObjectSquare(type, ptr1, ptr2, ptr3)) + SetChangedFlag(true); + break; + } - case F_SelectedElements: - if (SetSelectedSquare (ELEMENT_TYPE)) - SetChangedFlag (true); - break; + case F_SelectedElements: + if (SetSelectedSquare(ELEMENT_TYPE)) + SetChangedFlag(true); + break; - case F_SelectedPins: - if (SetSelectedSquare (PIN_TYPE | PAD_TYPE)) - SetChangedFlag (true); - break; + case F_SelectedPins: + if (SetSelectedSquare(PIN_TYPE | PAD_TYPE)) + SetChangedFlag(true); + break; - case F_Selected: - case F_SelectedObjects: - if (SetSelectedSquare (PIN_TYPE | PAD_TYPE)) - SetChangedFlag (true); - break; + case F_Selected: + case F_SelectedObjects: + if (SetSelectedSquare(PIN_TYPE | PAD_TYPE)) + SetChangedFlag(true); + break; + } } - } - return 0; + return 0; } /* --------------------------------------------------------------------------- */ -static const char clearsquare_syntax[] = - "ClearSquare(ToggleObject|SelectedElements|SelectedPins)"; +static const char clearsquare_syntax[] = "ClearSquare(ToggleObject|SelectedElements|SelectedPins)"; -static const char clearsquare_help[] = - "Clears the square-flag of pins and pads."; +static const char clearsquare_help[] = "Clears the square-flag of pins and pads."; /* %start-doc actions ClearSquare @@ -5304,57 +4777,50 @@ %end-doc */ -static int -ActionClearSquare (int argc, char **argv, Coord x, Coord y) +static int ActionClearSquare(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - if (function && *function) - { - switch (GetFunctionID (function)) - { - case F_ToggleObject: - case F_Object: - { - int type; - void *ptr1, *ptr2, *ptr3; + char *function = ARG(0); + if (function && *function) { + switch (GetFunctionID(function)) { + case F_ToggleObject: + case F_Object: + { + int type; + void *ptr1, *ptr2, *ptr3; - gui->get_coords (_("Select an Object"), &x, &y); - if ((type = - SearchScreen (x, y, CHANGESQUARE_TYPES, - &ptr1, &ptr2, &ptr3)) != NO_TYPE) - if (ClrObjectSquare (type, ptr1, ptr2, ptr3)) - SetChangedFlag (true); - break; - } + gui->get_coords(_("Select an Object"), &x, &y); + if ((type = SearchScreen(x, y, CHANGESQUARE_TYPES, &ptr1, &ptr2, &ptr3)) != NO_TYPE) + if (ClrObjectSquare(type, ptr1, ptr2, ptr3)) + SetChangedFlag(true); + break; + } - case F_SelectedElements: - if (ClrSelectedSquare (ELEMENT_TYPE)) - SetChangedFlag (true); - break; + case F_SelectedElements: + if (ClrSelectedSquare(ELEMENT_TYPE)) + SetChangedFlag(true); + break; - case F_SelectedPins: - if (ClrSelectedSquare (PIN_TYPE | PAD_TYPE)) - SetChangedFlag (true); - break; + case F_SelectedPins: + if (ClrSelectedSquare(PIN_TYPE | PAD_TYPE)) + SetChangedFlag(true); + break; - case F_Selected: - case F_SelectedObjects: - if (ClrSelectedSquare (PIN_TYPE | PAD_TYPE)) - SetChangedFlag (true); - break; + case F_Selected: + case F_SelectedObjects: + if (ClrSelectedSquare(PIN_TYPE | PAD_TYPE)) + SetChangedFlag(true); + break; + } } - } - return 0; + return 0; } /* --------------------------------------------------------------------------- */ static const char changeoctagon_syntax[] = - "ChangeOctagon(Object|ToggleObject|SelectedObjects|Selected)\n" - "ChangeOctagon(SelectedElements|SelectedPins|SelectedVias)"; + "ChangeOctagon(Object|ToggleObject|SelectedObjects|Selected)\n" "ChangeOctagon(SelectedElements|SelectedPins|SelectedVias)"; -static const char changeoctagon_help[] = - "Changes the octagon-flag of pins and vias."; +static const char changeoctagon_help[] = "Changes the octagon-flag of pins and vias."; /* %start-doc actions ChangeOctagon @@ -5362,58 +4828,52 @@ %end-doc */ -static int -ActionChangeOctagon (int argc, char **argv, Coord x, Coord y) +static int ActionChangeOctagon(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - if (function) - { - switch (GetFunctionID (function)) - { - case F_ToggleObject: - case F_Object: - { - int type; - void *ptr1, *ptr2, *ptr3; + char *function = ARG(0); + if (function) { + switch (GetFunctionID(function)) { + case F_ToggleObject: + case F_Object: + { + int type; + void *ptr1, *ptr2, *ptr3; - gui->get_coords (_("Select an Object"), &x, &y); - if ((type = - SearchScreen (x, y, CHANGEOCTAGON_TYPES, - &ptr1, &ptr2, &ptr3)) != NO_TYPE) - if (ChangeObjectOctagon (type, ptr1, ptr2, ptr3)) - SetChangedFlag (true); - break; - } + gui->get_coords(_("Select an Object"), &x, &y); + if ((type = SearchScreen(x, y, CHANGEOCTAGON_TYPES, &ptr1, &ptr2, &ptr3)) != NO_TYPE) + if (ChangeObjectOctagon(type, ptr1, ptr2, ptr3)) + SetChangedFlag(true); + break; + } - case F_SelectedElements: - if (ChangeSelectedOctagon (ELEMENT_TYPE)) - SetChangedFlag (true); - break; + case F_SelectedElements: + if (ChangeSelectedOctagon(ELEMENT_TYPE)) + SetChangedFlag(true); + break; - case F_SelectedPins: - if (ChangeSelectedOctagon (PIN_TYPE)) - SetChangedFlag (true); - break; + case F_SelectedPins: + if (ChangeSelectedOctagon(PIN_TYPE)) + SetChangedFlag(true); + break; - case F_SelectedVias: - if (ChangeSelectedOctagon (VIA_TYPE)) - SetChangedFlag (true); - break; + case F_SelectedVias: + if (ChangeSelectedOctagon(VIA_TYPE)) + SetChangedFlag(true); + break; - case F_Selected: - case F_SelectedObjects: - if (ChangeSelectedOctagon (PIN_TYPES)) - SetChangedFlag (true); - break; + case F_Selected: + case F_SelectedObjects: + if (ChangeSelectedOctagon(PIN_TYPES)) + SetChangedFlag(true); + break; + } } - } - return 0; + return 0; } /* --------------------------------------------------------------------------- */ -static const char setoctagon_syntax[] = - "SetOctagon(Object|ToggleObject|SelectedElements|Selected)"; +static const char setoctagon_syntax[] = "SetOctagon(Object|ToggleObject|SelectedElements|Selected)"; static const char setoctagon_help[] = "Sets the octagon-flag of objects."; @@ -5423,62 +4883,55 @@ %end-doc */ -static int -ActionSetOctagon (int argc, char **argv, Coord x, Coord y) +static int ActionSetOctagon(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - if (function) - { - switch (GetFunctionID (function)) - { - case F_ToggleObject: - case F_Object: - { - int type; - void *ptr1, *ptr2, *ptr3; + char *function = ARG(0); + if (function) { + switch (GetFunctionID(function)) { + case F_ToggleObject: + case F_Object: + { + int type; + void *ptr1, *ptr2, *ptr3; - gui->get_coords (_("Select an Object"), &x, &y); - if ((type = - SearchScreen (x, y, CHANGEOCTAGON_TYPES, - &ptr1, &ptr2, &ptr3)) != NO_TYPE) - if (SetObjectOctagon (type, ptr1, ptr2, ptr3)) - SetChangedFlag (true); - break; - } + gui->get_coords(_("Select an Object"), &x, &y); + if ((type = SearchScreen(x, y, CHANGEOCTAGON_TYPES, &ptr1, &ptr2, &ptr3)) != NO_TYPE) + if (SetObjectOctagon(type, ptr1, ptr2, ptr3)) + SetChangedFlag(true); + break; + } - case F_SelectedElements: - if (SetSelectedOctagon (ELEMENT_TYPE)) - SetChangedFlag (true); - break; + case F_SelectedElements: + if (SetSelectedOctagon(ELEMENT_TYPE)) + SetChangedFlag(true); + break; - case F_SelectedPins: - if (SetSelectedOctagon (PIN_TYPE)) - SetChangedFlag (true); - break; + case F_SelectedPins: + if (SetSelectedOctagon(PIN_TYPE)) + SetChangedFlag(true); + break; - case F_SelectedVias: - if (SetSelectedOctagon (VIA_TYPE)) - SetChangedFlag (true); - break; + case F_SelectedVias: + if (SetSelectedOctagon(VIA_TYPE)) + SetChangedFlag(true); + break; - case F_Selected: - case F_SelectedObjects: - if (SetSelectedOctagon (PIN_TYPES)) - SetChangedFlag (true); - break; + case F_Selected: + case F_SelectedObjects: + if (SetSelectedOctagon(PIN_TYPES)) + SetChangedFlag(true); + break; + } } - } - return 0; + return 0; } /* --------------------------------------------------------------------------- */ static const char clearoctagon_syntax[] = - "ClearOctagon(ToggleObject|Object|SelectedObjects|Selected)\n" - "ClearOctagon(SelectedElements|SelectedPins|SelectedVias)"; + "ClearOctagon(ToggleObject|Object|SelectedObjects|Selected)\n" "ClearOctagon(SelectedElements|SelectedPins|SelectedVias)"; -static const char clearoctagon_help[] = - "Clears the octagon-flag of pins and vias."; +static const char clearoctagon_help[] = "Clears the octagon-flag of pins and vias."; /* %start-doc actions ClearOctagon @@ -5486,58 +4939,52 @@ %end-doc */ -static int -ActionClearOctagon (int argc, char **argv, Coord x, Coord y) +static int ActionClearOctagon(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - if (function) - { - switch (GetFunctionID (function)) - { - case F_ToggleObject: - case F_Object: - { - int type; - void *ptr1, *ptr2, *ptr3; + char *function = ARG(0); + if (function) { + switch (GetFunctionID(function)) { + case F_ToggleObject: + case F_Object: + { + int type; + void *ptr1, *ptr2, *ptr3; - gui->get_coords (_("Select an Object"), &x, &y); - if ((type = - SearchScreen (Crosshair.X, Crosshair.Y, CHANGEOCTAGON_TYPES, - &ptr1, &ptr2, &ptr3)) != NO_TYPE) - if (ClrObjectOctagon (type, ptr1, ptr2, ptr3)) - SetChangedFlag (true); - break; - } + gui->get_coords(_("Select an Object"), &x, &y); + if ((type = SearchScreen(Crosshair.X, Crosshair.Y, CHANGEOCTAGON_TYPES, &ptr1, &ptr2, &ptr3)) != NO_TYPE) + if (ClrObjectOctagon(type, ptr1, ptr2, ptr3)) + SetChangedFlag(true); + break; + } - case F_SelectedElements: - if (ClrSelectedOctagon (ELEMENT_TYPE)) - SetChangedFlag (true); - break; + case F_SelectedElements: + if (ClrSelectedOctagon(ELEMENT_TYPE)) + SetChangedFlag(true); + break; - case F_SelectedPins: - if (ClrSelectedOctagon (PIN_TYPE)) - SetChangedFlag (true); - break; + case F_SelectedPins: + if (ClrSelectedOctagon(PIN_TYPE)) + SetChangedFlag(true); + break; - case F_SelectedVias: - if (ClrSelectedOctagon (VIA_TYPE)) - SetChangedFlag (true); - break; + case F_SelectedVias: + if (ClrSelectedOctagon(VIA_TYPE)) + SetChangedFlag(true); + break; - case F_Selected: - case F_SelectedObjects: - if (ClrSelectedOctagon (PIN_TYPES)) - SetChangedFlag (true); - break; + case F_Selected: + case F_SelectedObjects: + if (ClrSelectedOctagon(PIN_TYPES)) + SetChangedFlag(true); + break; + } } - } - return 0; + return 0; } /* --------------------------------------------------------------------------- */ -static const char changehold_syntax[] = - "ChangeHole(ToggleObject|Object|SelectedVias|Selected)"; +static const char changehold_syntax[] = "ChangeHole(ToggleObject|Object|SelectedVias|Selected)"; static const char changehold_help[] = "Changes the hole flag of objects."; @@ -5548,42 +4995,36 @@ %end-doc */ -static int -ActionChangeHole (int argc, char **argv, Coord x, Coord y) +static int ActionChangeHole(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - if (function) - { - switch (GetFunctionID (function)) - { - case F_ToggleObject: - case F_Object: - { - int type; - void *ptr1, *ptr2, *ptr3; + char *function = ARG(0); + if (function) { + switch (GetFunctionID(function)) { + case F_ToggleObject: + case F_Object: + { + int type; + void *ptr1, *ptr2, *ptr3; - gui->get_coords (_("Select an Object"), &x, &y); - if ((type = SearchScreen (x, y, VIA_TYPE, - &ptr1, &ptr2, &ptr3)) != NO_TYPE - && ChangeHole ((PinTypePtr) ptr3)) - IncrementUndoSerialNumber (); - break; - } + gui->get_coords(_("Select an Object"), &x, &y); + if ((type = SearchScreen(x, y, VIA_TYPE, &ptr1, &ptr2, &ptr3)) != NO_TYPE && ChangeHole((PinTypePtr) ptr3)) + IncrementUndoSerialNumber(); + break; + } - case F_SelectedVias: - case F_Selected: - if (ChangeSelectedHole ()) - SetChangedFlag (true); - break; + case F_SelectedVias: + case F_Selected: + if (ChangeSelectedHole()) + SetChangedFlag(true); + break; + } } - } - return 0; + return 0; } /* --------------------------------------------------------------------------- */ -static const char changepaste_syntax[] = - "ChangePaste(ToggleObject|Object|SelectedPads|Selected)"; +static const char changepaste_syntax[] = "ChangePaste(ToggleObject|Object|SelectedPads|Selected)"; static const char changepaste_help[] = "Changes the no paste flag of objects."; @@ -5596,48 +5037,41 @@ %end-doc */ -static int -ActionChangePaste (int argc, char **argv, Coord x, Coord y) +static int ActionChangePaste(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - if (function) - { - switch (GetFunctionID (function)) - { - case F_ToggleObject: - case F_Object: - { - int type; - void *ptr1, *ptr2, *ptr3; + char *function = ARG(0); + if (function) { + switch (GetFunctionID(function)) { + case F_ToggleObject: + case F_Object: + { + int type; + void *ptr1, *ptr2, *ptr3; - gui->get_coords (_("Select an Object"), &x, &y); - if ((type = SearchScreen (x, y, PAD_TYPE, - &ptr1, &ptr2, &ptr3)) != NO_TYPE - && ChangePaste ((PadTypePtr) ptr3)) - IncrementUndoSerialNumber (); - break; - } + gui->get_coords(_("Select an Object"), &x, &y); + if ((type = SearchScreen(x, y, PAD_TYPE, &ptr1, &ptr2, &ptr3)) != NO_TYPE && ChangePaste((PadTypePtr) ptr3)) + IncrementUndoSerialNumber(); + break; + } - case F_SelectedPads: - case F_Selected: - if (ChangeSelectedPaste ()) - SetChangedFlag (true); - break; + case F_SelectedPads: + case F_Selected: + if (ChangeSelectedPaste()) + SetChangedFlag(true); + break; + } } - } - return 0; + return 0; } /* --------------------------------------------------------------------------- */ static const char select_syntax[] = - "Select(Object|ToggleObject)\n" - "Select(All|Block|Connection)\n" - "Select(ElementByName|ObjectByName|PadByName|PinByName)\n" - "Select(ElementByName|ObjectByName|PadByName|PinByName, Name)\n" - "Select(TextByName|ViaByName|NetByName)\n" - "Select(TextByName|ViaByName|NetByName, Name)\n" - "Select(Convert)"; + "Select(Object|ToggleObject)\n" + "Select(All|Block|Connection)\n" + "Select(ElementByName|ObjectByName|PadByName|PinByName)\n" + "Select(ElementByName|ObjectByName|PadByName|PinByName, Name)\n" + "Select(TextByName|ViaByName|NetByName)\n" "Select(TextByName|ViaByName|NetByName, Name)\n" "Select(Convert)"; static const char select_help[] = "Toggles or sets the selection."; @@ -5679,147 +5113,134 @@ %end-doc */ -static int -ActionSelect (int argc, char **argv, Coord x, Coord y) +static int ActionSelect(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - if (function) - { - switch (GetFunctionID (function)) - { + char *function = ARG(0); + if (function) { + switch (GetFunctionID(function)) { #if defined(HAVE_REGCOMP) || defined(HAVE_RE_COMP) - int type; - /* select objects by their names */ - case F_ElementByName: - type = ELEMENT_TYPE; - goto commonByName; - case F_ObjectByName: - type = ALL_TYPES; - goto commonByName; - case F_PadByName: - type = PAD_TYPE; - goto commonByName; - case F_PinByName: - type = PIN_TYPE; - goto commonByName; - case F_TextByName: - type = TEXT_TYPE; - goto commonByName; - case F_ViaByName: - type = VIA_TYPE; - goto commonByName; - case F_NetByName: - type = NET_TYPE; - goto commonByName; + int type; + /* select objects by their names */ + case F_ElementByName: + type = ELEMENT_TYPE; + goto commonByName; + case F_ObjectByName: + type = ALL_TYPES; + goto commonByName; + case F_PadByName: + type = PAD_TYPE; + goto commonByName; + case F_PinByName: + type = PIN_TYPE; + goto commonByName; + case F_TextByName: + type = TEXT_TYPE; + goto commonByName; + case F_ViaByName: + type = VIA_TYPE; + goto commonByName; + case F_NetByName: + type = NET_TYPE; + goto commonByName; - commonByName: - { - char *pattern = ARG (1); - search_method_t method; + commonByName: + { + char *pattern = ARG(1); + search_method_t method; - if (pattern - || (pattern = gui_get_pat(&method)) != NULL) - { - if (SelectObjectByName (type, pattern, true, method)) - SetChangedFlag (true); - if (ARG (1) == NULL) - free (pattern); - } - break; - } + if (pattern || (pattern = gui_get_pat(&method)) != NULL) { + if (SelectObjectByName(type, pattern, true, method)) + SetChangedFlag(true); + if (ARG(1) == NULL) + free(pattern); + } + break; + } #endif /* defined(HAVE_REGCOMP) || defined(HAVE_RE_COMP) */ - /* select a single object */ - case F_ToggleObject: - case F_Object: - if (SelectObject ()) - SetChangedFlag (true); - break; + /* select a single object */ + case F_ToggleObject: + case F_Object: + if (SelectObject()) + SetChangedFlag(true); + break; - /* all objects in block */ - case F_Block: - { - BoxType box; + /* all objects in block */ + case F_Block: + { + BoxType box; - box.X1 = MIN (Crosshair.AttachedBox.Point1.X, - Crosshair.AttachedBox.Point2.X); - box.Y1 = MIN (Crosshair.AttachedBox.Point1.Y, - Crosshair.AttachedBox.Point2.Y); - box.X2 = MAX (Crosshair.AttachedBox.Point1.X, - Crosshair.AttachedBox.Point2.X); - box.Y2 = MAX (Crosshair.AttachedBox.Point1.Y, - Crosshair.AttachedBox.Point2.Y); - notify_crosshair_change (false); - NotifyBlock (); - if (Crosshair.AttachedBox.State == STATE_THIRD && - SelectBlock (&box, true)) - { - SetChangedFlag (true); - Crosshair.AttachedBox.State = STATE_FIRST; - } - notify_crosshair_change (true); - break; - } + box.X1 = MIN(Crosshair.AttachedBox.Point1.X, Crosshair.AttachedBox.Point2.X); + box.Y1 = MIN(Crosshair.AttachedBox.Point1.Y, Crosshair.AttachedBox.Point2.Y); + box.X2 = MAX(Crosshair.AttachedBox.Point1.X, Crosshair.AttachedBox.Point2.X); + box.Y2 = MAX(Crosshair.AttachedBox.Point1.Y, Crosshair.AttachedBox.Point2.Y); + notify_crosshair_change(false); + NotifyBlock(); + if (Crosshair.AttachedBox.State == STATE_THIRD && SelectBlock(&box, true)) { + SetChangedFlag(true); + Crosshair.AttachedBox.State = STATE_FIRST; + } + notify_crosshair_change(true); + break; + } - /* select all visible objects */ - case F_All: - { - BoxType box; + /* select all visible objects */ + case F_All: + { + BoxType box; - box.X1 = -MAX_COORD; - box.Y1 = -MAX_COORD; - box.X2 = MAX_COORD; - box.Y2 = MAX_COORD; - if (SelectBlock (&box, true)) - SetChangedFlag (true); - break; - } + box.X1 = -MAX_COORD; + box.Y1 = -MAX_COORD; + box.X2 = MAX_COORD; + box.Y2 = MAX_COORD; + if (SelectBlock(&box, true)) + SetChangedFlag(true); + break; + } - /* all found connections */ - case F_Connection: - if (SelectConnection (true)) - { - Draw (); - IncrementUndoSerialNumber (); - SetChangedFlag (true); - } - break; + /* all found connections */ + case F_Connection: + if (SelectConnection(true)) { + Draw(); + IncrementUndoSerialNumber(); + SetChangedFlag(true); + } + break; - case F_Convert: - { - Coord x, y; - Note.Buffer = Settings.BufferNumber; - SetBufferNumber (MAX_BUFFER - 1); - ClearBuffer (PASTEBUFFER); - gui->get_coords (_("Select the Element's Mark Location"), &x, &y); - x = GridFit (x, PCB->Grid, PCB->GridOffsetX); - y = GridFit (y, PCB->Grid, PCB->GridOffsetY); - AddSelectedToBuffer (PASTEBUFFER, x, y, true); - SaveUndoSerialNumber (); - RemoveSelected (); - ConvertBufferToElement (PASTEBUFFER); - RestoreUndoSerialNumber (); - CopyPastebufferToLayout (x, y); - SetBufferNumber (Note.Buffer); - } - break; + case F_Convert: + { + Coord x, y; + Note.Buffer = Settings.BufferNumber; + SetBufferNumber(MAX_BUFFER - 1); + ClearBuffer(PASTEBUFFER); + gui->get_coords(_("Select the Element's Mark Location"), &x, &y); + x = GridFit(x, PCB->Grid, PCB->GridOffsetX); + y = GridFit(y, PCB->Grid, PCB->GridOffsetY); + AddSelectedToBuffer(PASTEBUFFER, x, y, true); + SaveUndoSerialNumber(); + RemoveSelected(); + ConvertBufferToElement(PASTEBUFFER); + RestoreUndoSerialNumber(); + CopyPastebufferToLayout(x, y); + SetBufferNumber(Note.Buffer); + } + break; - default: - AFAIL (select); - break; + default: + AFAIL(select); + break; + } } - } - return 0; + return 0; } /* FLAG(have_regex,FlagHaveRegex,0) */ -int -FlagHaveRegex (int parm) +int FlagHaveRegex(int parm) { #if defined(HAVE_REGCOMP) || defined(HAVE_RE_COMP) - return 1; + return 1; #else - return 0; + return 0; #endif } @@ -5826,14 +5247,12 @@ /* --------------------------------------------------------------------------- */ static const char unselect_syntax[] = - "Unselect(All|Block|Connection)\n" - "Unselect(ElementByName|ObjectByName|PadByName|PinByName)\n" - "Unselect(ElementByName|ObjectByName|PadByName|PinByName, Name)\n" - "Unselect(TextByName|ViaByName)\n" - "Unselect(TextByName|ViaByName, Name)\n"; + "Unselect(All|Block|Connection)\n" + "Unselect(ElementByName|ObjectByName|PadByName|PinByName)\n" + "Unselect(ElementByName|ObjectByName|PadByName|PinByName, Name)\n" + "Unselect(TextByName|ViaByName)\n" "Unselect(TextByName|ViaByName, Name)\n"; -static const char unselect_help[] = - "Unselects the object at the pointer location or the specified objects."; +static const char unselect_help[] = "Unselects the object at the pointer location or the specified objects."; /* %start-doc actions Unselect @@ -5865,120 +5284,107 @@ %end-doc */ -static int -ActionUnselect (int argc, char **argv, Coord x, Coord y) +static int ActionUnselect(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - if (function) - { - switch (GetFunctionID (function)) - { + char *function = ARG(0); + if (function) { + switch (GetFunctionID(function)) { #if defined(HAVE_REGCOMP) || defined(HAVE_RE_COMP) - int type; - /* select objects by their names */ - case F_ElementByName: - type = ELEMENT_TYPE; - goto commonByName; - case F_ObjectByName: - type = ALL_TYPES; - goto commonByName; - case F_PadByName: - type = PAD_TYPE; - goto commonByName; - case F_PinByName: - type = PIN_TYPE; - goto commonByName; - case F_TextByName: - type = TEXT_TYPE; - goto commonByName; - case F_ViaByName: - type = VIA_TYPE; - goto commonByName; - case F_NetByName: - type = NET_TYPE; - goto commonByName; + int type; + /* select objects by their names */ + case F_ElementByName: + type = ELEMENT_TYPE; + goto commonByName; + case F_ObjectByName: + type = ALL_TYPES; + goto commonByName; + case F_PadByName: + type = PAD_TYPE; + goto commonByName; + case F_PinByName: + type = PIN_TYPE; + goto commonByName; + case F_TextByName: + type = TEXT_TYPE; + goto commonByName; + case F_ViaByName: + type = VIA_TYPE; + goto commonByName; + case F_NetByName: + type = NET_TYPE; + goto commonByName; - commonByName: - { - char *pattern = ARG (1); - search_method_t method; + commonByName: + { + char *pattern = ARG(1); + search_method_t method; - if (pattern - || (pattern = gui_get_pat(&method)) != NULL) - { - if (SelectObjectByName (type, pattern, false, method)) - SetChangedFlag (true); - if (ARG (1) == NULL) - free (pattern); - } - break; - } + if (pattern || (pattern = gui_get_pat(&method)) != NULL) { + if (SelectObjectByName(type, pattern, false, method)) + SetChangedFlag(true); + if (ARG(1) == NULL) + free(pattern); + } + break; + } #endif /* defined(HAVE_REGCOMP) || defined(HAVE_RE_COMP) */ - /* all objects in block */ - case F_Block: - { - BoxType box; + /* all objects in block */ + case F_Block: + { + BoxType box; - box.X1 = MIN (Crosshair.AttachedBox.Point1.X, - Crosshair.AttachedBox.Point2.X); - box.Y1 = MIN (Crosshair.AttachedBox.Point1.Y, - Crosshair.AttachedBox.Point2.Y); - box.X2 = MAX (Crosshair.AttachedBox.Point1.X, - Crosshair.AttachedBox.Point2.X); - box.Y2 = MAX (Crosshair.AttachedBox.Point1.Y, - Crosshair.AttachedBox.Point2.Y); - notify_crosshair_change (false); - NotifyBlock (); - if (Crosshair.AttachedBox.State == STATE_THIRD && - SelectBlock (&box, false)) - { - SetChangedFlag (true); - Crosshair.AttachedBox.State = STATE_FIRST; - } - notify_crosshair_change (true); - break; - } + box.X1 = MIN(Crosshair.AttachedBox.Point1.X, Crosshair.AttachedBox.Point2.X); + box.Y1 = MIN(Crosshair.AttachedBox.Point1.Y, Crosshair.AttachedBox.Point2.Y); + box.X2 = MAX(Crosshair.AttachedBox.Point1.X, Crosshair.AttachedBox.Point2.X); + box.Y2 = MAX(Crosshair.AttachedBox.Point1.Y, Crosshair.AttachedBox.Point2.Y); + notify_crosshair_change(false); + NotifyBlock(); + if (Crosshair.AttachedBox.State == STATE_THIRD && SelectBlock(&box, false)) { + SetChangedFlag(true); + Crosshair.AttachedBox.State = STATE_FIRST; + } + notify_crosshair_change(true); + break; + } - /* unselect all visible objects */ - case F_All: - { - BoxType box; + /* unselect all visible objects */ + case F_All: + { + BoxType box; - box.X1 = -MAX_COORD; - box.Y1 = -MAX_COORD; - box.X2 = MAX_COORD; - box.Y2 = MAX_COORD; - if (SelectBlock (&box, false)) - SetChangedFlag (true); - break; - } + box.X1 = -MAX_COORD; + box.Y1 = -MAX_COORD; + box.X2 = MAX_COORD; + box.Y2 = MAX_COORD; + if (SelectBlock(&box, false)) + SetChangedFlag(true); + break; + } - /* all found connections */ - case F_Connection: - if (SelectConnection (false)) - { - Draw (); - IncrementUndoSerialNumber (); - SetChangedFlag (true); - } - break; + /* all found connections */ + case F_Connection: + if (SelectConnection(false)) { + Draw(); + IncrementUndoSerialNumber(); + SetChangedFlag(true); + } + break; - default: - AFAIL (unselect); - break; + default: + AFAIL(unselect); + break; + } } - } - return 0; + return 0; } /* --------------------------------------------------------------------------- */ static const char saveto_syntax[] = - "SaveTo(Layout|LayoutAs,filename)\n" - "SaveTo(AllConnections|AllUnusedPins|ElementConnections,filename)\n" - "SaveTo(PasteBuffer,filename)"; + "SaveTo(Layout|LayoutAs,filename)\n" + "SaveTo(AllConnections|AllUnusedPins|ElementConnections,filename)\n" "SaveTo(PasteBuffer,filename)"; static const char saveto_help[] = "Saves data to a file."; @@ -6008,99 +5414,83 @@ %end-doc */ -static int -ActionSaveTo (int argc, char **argv, Coord x, Coord y) +static int ActionSaveTo(int argc, char **argv, Coord x, Coord y) { - char *function; - char *name; + char *function; + char *name; - function = argv[0]; - name = argv[1]; + function = argv[0]; + name = argv[1]; - if (strcasecmp (function, "Layout") == 0) - { - if (SavePCB (PCB->Filename) == 0) - SetChangedFlag (false); - return 0; - } + if (strcasecmp(function, "Layout") == 0) { + if (SavePCB(PCB->Filename) == 0) + SetChangedFlag(false); + return 0; + } - if (argc != 2) - AFAIL (saveto); + if (argc != 2) + AFAIL(saveto); - if (strcasecmp (function, "LayoutAs") == 0) - { - if (SavePCB (name) == 0) - { - SetChangedFlag (false); - free (PCB->Filename); - PCB->Filename = strdup (name); - if (gui->notify_filename_changed != NULL) - gui->notify_filename_changed (); - } - return 0; - } + if (strcasecmp(function, "LayoutAs") == 0) { + if (SavePCB(name) == 0) { + SetChangedFlag(false); + free(PCB->Filename); + PCB->Filename = strdup(name); + if (gui->notify_filename_changed != NULL) + gui->notify_filename_changed(); + } + return 0; + } - if (strcasecmp (function, "AllConnections") == 0) - { - FILE *fp; - bool result; - if ((fp = CheckAndOpenFile (name, true, false, &result, NULL)) != NULL) - { - LookupConnectionsToAllElements (fp); - fclose (fp); - SetChangedFlag (true); + if (strcasecmp(function, "AllConnections") == 0) { + FILE *fp; + bool result; + if ((fp = CheckAndOpenFile(name, true, false, &result, NULL)) != NULL) { + LookupConnectionsToAllElements(fp); + fclose(fp); + SetChangedFlag(true); + } + return 0; } - return 0; - } - if (strcasecmp (function, "AllUnusedPins") == 0) - { - FILE *fp; - bool result; - if ((fp = CheckAndOpenFile (name, true, false, &result, NULL)) != NULL) - { - LookupUnusedPins (fp); - fclose (fp); - SetChangedFlag (true); + if (strcasecmp(function, "AllUnusedPins") == 0) { + FILE *fp; + bool result; + if ((fp = CheckAndOpenFile(name, true, false, &result, NULL)) != NULL) { + LookupUnusedPins(fp); + fclose(fp); + SetChangedFlag(true); + } + return 0; } - return 0; - } - if (strcasecmp (function, "ElementConnections") == 0) - { - ElementTypePtr element; - void *ptrtmp; - FILE *fp; - bool result; + if (strcasecmp(function, "ElementConnections") == 0) { + ElementTypePtr element; + void *ptrtmp; + FILE *fp; + bool result; - if ((SearchScreen (Crosshair.X, Crosshair.Y, ELEMENT_TYPE, - &ptrtmp, &ptrtmp, &ptrtmp)) != NO_TYPE) - { - element = (ElementTypePtr) ptrtmp; - if ((fp = - CheckAndOpenFile (name, true, false, &result, NULL)) != NULL) - { - LookupElementConnections (element, fp); - fclose (fp); - SetChangedFlag (true); - } + if ((SearchScreen(Crosshair.X, Crosshair.Y, ELEMENT_TYPE, &ptrtmp, &ptrtmp, &ptrtmp)) != NO_TYPE) { + element = (ElementTypePtr) ptrtmp; + if ((fp = CheckAndOpenFile(name, true, false, &result, NULL)) != NULL) { + LookupElementConnections(element, fp); + fclose(fp); + SetChangedFlag(true); + } + } + return 0; } - return 0; - } - if (strcasecmp (function, "PasteBuffer") == 0) - { - return SaveBufferElements (name); - } + if (strcasecmp(function, "PasteBuffer") == 0) { + return SaveBufferElements(name); + } - AFAIL (saveto); + AFAIL(saveto); } /* --------------------------------------------------------------------------- */ -static const char savesettings_syntax[] = - "SaveSettings()\n" - "SaveSettings(local)"; +static const char savesettings_syntax[] = "SaveSettings()\n" "SaveSettings(local)"; static const char savesettings_help[] = "Saves settings."; @@ -6112,18 +5502,16 @@ %end-doc */ -static int -ActionSaveSettings (int argc, char **argv, Coord x, Coord y) +static int ActionSaveSettings(int argc, char **argv, Coord x, Coord y) { - int locally = argc > 0 ? (strncasecmp (argv[0], "local", 5) == 0) : 0; - hid_save_settings (locally); - return 0; + int locally = argc > 0 ? (strncasecmp(argv[0], "local", 5) == 0) : 0; + hid_save_settings(locally); + return 0; } /* --------------------------------------------------------------------------- */ -static const char loadfrom_syntax[] = - "LoadFrom(Layout|LayoutToBuffer|ElementToBuffer|Netlist|Revert,filename)"; +static const char loadfrom_syntax[] = "LoadFrom(Layout|LayoutToBuffer|ElementToBuffer|Netlist|Revert,filename)"; static const char loadfrom_help[] = "Load layout data from a file."; @@ -6158,62 +5546,54 @@ %end-doc */ -static int -ActionLoadFrom (int argc, char **argv, Coord x, Coord y) +static int ActionLoadFrom(int argc, char **argv, Coord x, Coord y) { - char *function; - char *name; + char *function; + char *name; - if (argc < 2) - AFAIL (loadfrom); + if (argc < 2) + AFAIL(loadfrom); - function = argv[0]; - name = argv[1]; + function = argv[0]; + name = argv[1]; - if (strcasecmp (function, "ElementToBuffer") == 0) - { - notify_crosshair_change (false); - if (LoadElementToBuffer (PASTEBUFFER, name)) - SetMode (PASTEBUFFER_MODE); - notify_crosshair_change (true); - } + if (strcasecmp(function, "ElementToBuffer") == 0) { + notify_crosshair_change(false); + if (LoadElementToBuffer(PASTEBUFFER, name)) + SetMode(PASTEBUFFER_MODE); + notify_crosshair_change(true); + } - else if (strcasecmp (function, "LayoutToBuffer") == 0) - { - notify_crosshair_change (false); - if (LoadLayoutToBuffer (PASTEBUFFER, name)) - SetMode (PASTEBUFFER_MODE); - notify_crosshair_change (true); - } + else if (strcasecmp(function, "LayoutToBuffer") == 0) { + notify_crosshair_change(false); + if (LoadLayoutToBuffer(PASTEBUFFER, name)) + SetMode(PASTEBUFFER_MODE); + notify_crosshair_change(true); + } - else if (strcasecmp (function, "Layout") == 0) - { - if (!PCB->Changed || - gui->confirm_dialog (_("OK to override layout data?"), 0)) - LoadPCB (name, true); - } + else if (strcasecmp(function, "Layout") == 0) { + if (!PCB->Changed || gui->confirm_dialog(_("OK to override layout data?"), 0)) + LoadPCB(name, true); + } - else if (strcasecmp (function, "Netlist") == 0) - { - if (PCB->Netlistname) - free (PCB->Netlistname); - PCB->Netlistname = StripWhiteSpaceAndDup (name); - { - int i; - for(i = 0; i < NUM_NETLISTS; i++) - FreeLibraryMemory (&(PCB->NetlistLib[i])); - } - if (!ImportNetlist (PCB->Netlistname)) - NetlistChanged (1); - } - else if (strcasecmp (function, "Revert") == 0 && PCB->Filename - && (!PCB->Changed - || gui->confirm_dialog (_("OK to override changes?"), 0))) - { - RevertPCB (); - } + else if (strcasecmp(function, "Netlist") == 0) { + if (PCB->Netlistname) + free(PCB->Netlistname); + PCB->Netlistname = StripWhiteSpaceAndDup(name); + { + int i; + for (i = 0; i < NUM_NETLISTS; i++) + FreeLibraryMemory(&(PCB->NetlistLib[i])); + } + if (!ImportNetlist(PCB->Netlistname)) + NetlistChanged(1); + } + else if (strcasecmp(function, "Revert") == 0 && PCB->Filename + && (!PCB->Changed || gui->confirm_dialog(_("OK to override changes?"), 0))) { + RevertPCB(); + } - return 0; + return 0; } /* --------------------------------------------------------------------------- */ @@ -6228,46 +5608,44 @@ %end-doc */ -static int -ActionNew (int argc, char **argv, Coord x, Coord y) +static int ActionNew(int argc, char **argv, Coord x, Coord y) { - char *name = ARG (0); + char *name = ARG(0); - if (!PCB->Changed || gui->confirm_dialog (_("OK to clear layout data?"), 0)) - { - if (name) - name = strdup (name); - else - name = gui->prompt_for (_("Enter the layout name:"), ""); + if (!PCB->Changed || gui->confirm_dialog(_("OK to clear layout data?"), 0)) { + if (name) + name = strdup(name); + else + name = gui->prompt_for(_("Enter the layout name:"), ""); - if (!name) - return 1; + if (!name) + return 1; - notify_crosshair_change (false); - /* do emergency saving - * clear the old struct and allocate memory for the new one - */ - if (PCB->Changed && Settings.SaveInTMP) - SaveInTMP (); - RemovePCB (PCB); - PCB = CreateNewPCB (); - PCB->Data->LayerN = DEF_LAYER; - CreateNewPCBPost (PCB, 1); + notify_crosshair_change(false); + /* do emergency saving + * clear the old struct and allocate memory for the new one + */ + if (PCB->Changed && Settings.SaveInTMP) + SaveInTMP(); + RemovePCB(PCB); + PCB = CreateNewPCB(); + PCB->Data->LayerN = DEF_LAYER; + CreateNewPCBPost(PCB, 1); - /* setup the new name and reset some values to default */ - free (PCB->Name); - PCB->Name = name; + /* setup the new name and reset some values to default */ + free(PCB->Name); + PCB->Name = name; - ResetStackAndVisibility (); - SetCrosshairRange (0, 0, PCB->MaxWidth, PCB->MaxHeight); - CenterDisplay (PCB->MaxWidth / 2, PCB->MaxHeight / 2); - Redraw (); + ResetStackAndVisibility(); + SetCrosshairRange(0, 0, PCB->MaxWidth, PCB->MaxHeight); + CenterDisplay(PCB->MaxWidth / 2, PCB->MaxHeight / 2); + Redraw(); - hid_action ("PCBChanged"); - notify_crosshair_change (true); - return 0; - } - return 1; + hid_action("PCBChanged"); + notify_crosshair_change(true); + return 0; + } + return 1; } /* --------------------------------------------------------------------------- @@ -6274,22 +5652,18 @@ * no operation, just for testing purposes * syntax: Bell(volume) */ -void -ActionBell (char *volume) +void ActionBell(char *volume) { - gui->beep (); + gui->beep(); } /* --------------------------------------------------------------------------- */ static const char pastebuffer_syntax[] = - "PasteBuffer(AddSelected|Clear|1..MAX_BUFFER)\n" - "PasteBuffer(Rotate, 1..3)\n" - "PasteBuffer(Convert|Save|Restore|Mirror)\n" - "PasteBuffer(ToLayout, X, Y, units)"; + "PasteBuffer(AddSelected|Clear|1..MAX_BUFFER)\n" + "PasteBuffer(Rotate, 1..3)\n" "PasteBuffer(Convert|Save|Restore|Mirror)\n" "PasteBuffer(ToLayout, X, Y, units)"; -static const char pastebuffer_help[] = - "Various operations on the paste buffer."; +static const char pastebuffer_help[] = "Various operations on the paste buffer."; /* %start-doc actions PasteBuffer @@ -6342,153 +5716,137 @@ %end-doc */ -static int -ActionPasteBuffer (int argc, char **argv, Coord x, Coord y) +static int ActionPasteBuffer(int argc, char **argv, Coord x, Coord y) { - char *function = argc ? argv[0] : (char *)""; - char *sbufnum = argc > 1 ? argv[1] : (char *)""; - char *name; - static char *default_file = NULL; - int free_name = 0; + char *function = argc ? argv[0] : (char *) ""; + char *sbufnum = argc > 1 ? argv[1] : (char *) ""; + char *name; + static char *default_file = NULL; + int free_name = 0; - notify_crosshair_change (false); - if (function) - { - switch (GetFunctionID (function)) - { - /* clear contents of paste buffer */ - case F_Clear: - ClearBuffer (PASTEBUFFER); - break; + notify_crosshair_change(false); + if (function) { + switch (GetFunctionID(function)) { + /* clear contents of paste buffer */ + case F_Clear: + ClearBuffer(PASTEBUFFER); + break; - /* copies objects to paste buffer */ - case F_AddSelected: - AddSelectedToBuffer (PASTEBUFFER, 0, 0, false); - break; + /* copies objects to paste buffer */ + case F_AddSelected: + AddSelectedToBuffer(PASTEBUFFER, 0, 0, false); + break; - /* converts buffer contents into an element */ - case F_Convert: - ConvertBufferToElement (PASTEBUFFER); - break; + /* converts buffer contents into an element */ + case F_Convert: + ConvertBufferToElement(PASTEBUFFER); + break; - /* break up element for editing */ - case F_Restore: - SmashBufferElement (PASTEBUFFER); - break; + /* break up element for editing */ + case F_Restore: + SmashBufferElement(PASTEBUFFER); + break; - /* Mirror buffer */ - case F_Mirror: - MirrorBuffer (PASTEBUFFER); - break; + /* Mirror buffer */ + case F_Mirror: + MirrorBuffer(PASTEBUFFER); + break; - case F_Rotate: - if (sbufnum) - { - RotateBuffer (PASTEBUFFER, (BYTE) atoi (sbufnum)); - SetCrosshairRangeToBuffer (); - } - break; + case F_Rotate: + if (sbufnum) { + RotateBuffer(PASTEBUFFER, (BYTE) atoi(sbufnum)); + SetCrosshairRangeToBuffer(); + } + break; - case F_Save: - if (PASTEBUFFER->Data->ElementN == 0) - { - Message (_("Buffer has no elements!\n")); - break; - } - free_name = 0; - if (argc <= 1) - { - name = gui->fileselect (_("Save Paste Buffer As ..."), - _("Choose a file to save the contents of the\n" - "paste buffer to.\n"), - default_file, ".fp", "footprint", - 0); + case F_Save: + if (PASTEBUFFER->Data->ElementN == 0) { + Message(_("Buffer has no elements!\n")); + break; + } + free_name = 0; + if (argc <= 1) { + name = gui->fileselect(_("Save Paste Buffer As ..."), + _("Choose a file to save the contents of the\n" + "paste buffer to.\n"), default_file, ".fp", "footprint", 0); - if (default_file) - { - free (default_file); - default_file = NULL; - } - if ( name && *name) - { - default_file = strdup (name); - } - free_name = 1; - } - - else - name = argv[1]; + if (default_file) { + free(default_file); + default_file = NULL; + } + if (name && *name) { + default_file = strdup(name); + } + free_name = 1; + } - { - FILE *exist; + else + name = argv[1]; - if ((exist = fopen (name, "r"))) - { - fclose (exist); - if (gui-> - confirm_dialog (_("File exists! Ok to overwrite?"), 0)) - SaveBufferElements (name); - } - else - SaveBufferElements (name); + { + FILE *exist; - if (free_name && name) - free (name); - } - break; + if ((exist = fopen(name, "r"))) { + fclose(exist); + if (gui->confirm_dialog(_("File exists! Ok to overwrite?"), 0)) + SaveBufferElements(name); + } + else + SaveBufferElements(name); - case F_ToLayout: - { - static Coord oldx = 0, oldy = 0; - Coord x, y; - bool absolute; + if (free_name && name) + free(name); + } + break; - if (argc == 1) - { - x = y = 0; - } - else if (argc == 3 || argc == 4) - { - x = GetValue (ARG (1), ARG (3), &absolute); - if (!absolute) - x += oldx; - y = GetValue (ARG (2), ARG (3), &absolute); - if (!absolute) - y += oldy; - } - else - { - notify_crosshair_change (true); - AFAIL (pastebuffer); - } + case F_ToLayout: + { + static Coord oldx = 0, oldy = 0; + Coord x, y; + bool absolute; - oldx = x; - oldy = y; - if (CopyPastebufferToLayout (x, y)) - SetChangedFlag (true); - } - break; + if (argc == 1) { + x = y = 0; + } + else if (argc == 3 || argc == 4) { + x = GetValue(ARG(1), ARG(3), &absolute); + if (!absolute) + x += oldx; + y = GetValue(ARG(2), ARG(3), &absolute); + if (!absolute) + y += oldy; + } + else { + notify_crosshair_change(true); + AFAIL(pastebuffer); + } - /* set number */ - default: - { - int number = atoi (function); + oldx = x; + oldy = y; + if (CopyPastebufferToLayout(x, y)) + SetChangedFlag(true); + } + break; - /* correct number */ - if (number) - SetBufferNumber (number - 1); - } + /* set number */ + default: + { + int number = atoi(function); + + /* correct number */ + if (number) + SetBufferNumber(number - 1); + } + } } - } - notify_crosshair_change (true); - return 0; + notify_crosshair_change(true); + return 0; } /* --------------------------------------------------------------------------- */ -static const char undo_syntax[] = "Undo()\n" - "Undo(ClearList)"; +static const char undo_syntax[] = "Undo()\n" "Undo(ClearList)"; static const char undo_help[] = "Undo recent changes."; @@ -6507,160 +5865,123 @@ %end-doc */ -static int -ActionUndo (int argc, char **argv, Coord x, Coord y) +static int ActionUndo(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - if (!function || !*function) - { - /* don't allow undo in the middle of an operation */ - if (Settings.Mode != POLYGONHOLE_MODE && - Crosshair.AttachedObject.State != STATE_FIRST) - return 1; - if (Crosshair.AttachedBox.State != STATE_FIRST - && Settings.Mode != ARC_MODE) - return 1; - /* undo the last operation */ + char *function = ARG(0); + if (!function || !*function) { + /* don't allow undo in the middle of an operation */ + if (Settings.Mode != POLYGONHOLE_MODE && Crosshair.AttachedObject.State != STATE_FIRST) + return 1; + if (Crosshair.AttachedBox.State != STATE_FIRST && Settings.Mode != ARC_MODE) + return 1; + /* undo the last operation */ - notify_crosshair_change (false); - if ((Settings.Mode == POLYGON_MODE || - Settings.Mode == POLYGONHOLE_MODE) && - Crosshair.AttachedPolygon.PointN) - { - GoToPreviousPoint (); - notify_crosshair_change (true); - return 0; - } - /* move anchor point if undoing during line creation */ - if (Settings.Mode == LINE_MODE) - { - if (Crosshair.AttachedLine.State == STATE_SECOND) - { - if (TEST_FLAG (AUTODRCFLAG, PCB)) - Undo (true); /* undo the connection find */ - Crosshair.AttachedLine.State = STATE_FIRST; - SetLocalRef (0, 0, false); - notify_crosshair_change (true); - return 0; - } - if (Crosshair.AttachedLine.State == STATE_THIRD) - { - int type; - void *ptr1, *ptr3, *ptrtmp; - LineTypePtr ptr2; - /* this search is guaranteed to succeed */ - SearchObjectByLocation (LINE_TYPE | RATLINE_TYPE, &ptr1, - &ptrtmp, &ptr3, - Crosshair.AttachedLine.Point1.X, - Crosshair.AttachedLine.Point1.Y, 0); - ptr2 = (LineTypePtr) ptrtmp; + notify_crosshair_change(false); + if ((Settings.Mode == POLYGON_MODE || Settings.Mode == POLYGONHOLE_MODE) && Crosshair.AttachedPolygon.PointN) { + GoToPreviousPoint(); + notify_crosshair_change(true); + return 0; + } + /* move anchor point if undoing during line creation */ + if (Settings.Mode == LINE_MODE) { + if (Crosshair.AttachedLine.State == STATE_SECOND) { + if (TEST_FLAG(AUTODRCFLAG, PCB)) + Undo(true); /* undo the connection find */ + Crosshair.AttachedLine.State = STATE_FIRST; + SetLocalRef(0, 0, false); + notify_crosshair_change(true); + return 0; + } + if (Crosshair.AttachedLine.State == STATE_THIRD) { + int type; + void *ptr1, *ptr3, *ptrtmp; + LineTypePtr ptr2; + /* this search is guaranteed to succeed */ + SearchObjectByLocation(LINE_TYPE | RATLINE_TYPE, &ptr1, + &ptrtmp, &ptr3, Crosshair.AttachedLine.Point1.X, Crosshair.AttachedLine.Point1.Y, 0); + ptr2 = (LineTypePtr) ptrtmp; - /* save both ends of line */ - Crosshair.AttachedLine.Point2.X = ptr2->Point1.X; - Crosshair.AttachedLine.Point2.Y = ptr2->Point1.Y; - if ((type = Undo (true))) - SetChangedFlag (true); - /* check that the undo was of the right type */ - if ((type & UNDO_CREATE) == 0) - { - /* wrong undo type, restore anchor points */ - Crosshair.AttachedLine.Point2.X = - Crosshair.AttachedLine.Point1.X; - Crosshair.AttachedLine.Point2.Y = - Crosshair.AttachedLine.Point1.Y; - notify_crosshair_change (true); - return 0; + /* save both ends of line */ + Crosshair.AttachedLine.Point2.X = ptr2->Point1.X; + Crosshair.AttachedLine.Point2.Y = ptr2->Point1.Y; + if ((type = Undo(true))) + SetChangedFlag(true); + /* check that the undo was of the right type */ + if ((type & UNDO_CREATE) == 0) { + /* wrong undo type, restore anchor points */ + Crosshair.AttachedLine.Point2.X = Crosshair.AttachedLine.Point1.X; + Crosshair.AttachedLine.Point2.Y = Crosshair.AttachedLine.Point1.Y; + notify_crosshair_change(true); + return 0; + } + /* move to new anchor */ + Crosshair.AttachedLine.Point1.X = Crosshair.AttachedLine.Point2.X; + Crosshair.AttachedLine.Point1.Y = Crosshair.AttachedLine.Point2.Y; + /* check if an intermediate point was removed */ + if (type & UNDO_REMOVE) { + /* this search should find the restored line */ + SearchObjectByLocation(LINE_TYPE | RATLINE_TYPE, &ptr1, + &ptrtmp, &ptr3, Crosshair.AttachedLine.Point2.X, Crosshair.AttachedLine.Point2.Y, 0); + ptr2 = (LineTypePtr) ptrtmp; + if (TEST_FLAG(AUTODRCFLAG, PCB)) { + /* undo loses FOUNDFLAG */ + SET_FLAG(FOUNDFLAG, ptr2); + DrawLine(CURRENT, ptr2); + } + Crosshair.AttachedLine.Point1.X = Crosshair.AttachedLine.Point2.X = ptr2->Point2.X; + Crosshair.AttachedLine.Point1.Y = Crosshair.AttachedLine.Point2.Y = ptr2->Point2.Y; + } + FitCrosshairIntoGrid(Crosshair.X, Crosshair.Y); + AdjustAttachedObjects(); + if (--addedLines == 0) { + Crosshair.AttachedLine.State = STATE_SECOND; + lastLayer = CURRENT; + } + else { + /* this search is guaranteed to succeed too */ + SearchObjectByLocation(LINE_TYPE | RATLINE_TYPE, &ptr1, + &ptrtmp, &ptr3, Crosshair.AttachedLine.Point1.X, Crosshair.AttachedLine.Point1.Y, 0); + ptr2 = (LineTypePtr) ptrtmp; + lastLayer = (LayerTypePtr) ptr1; + } + notify_crosshair_change(true); + return 0; + } } - /* move to new anchor */ - Crosshair.AttachedLine.Point1.X = - Crosshair.AttachedLine.Point2.X; - Crosshair.AttachedLine.Point1.Y = - Crosshair.AttachedLine.Point2.Y; - /* check if an intermediate point was removed */ - if (type & UNDO_REMOVE) - { - /* this search should find the restored line */ - SearchObjectByLocation (LINE_TYPE | RATLINE_TYPE, &ptr1, - &ptrtmp, - &ptr3, - Crosshair.AttachedLine.Point2.X, - Crosshair.AttachedLine.Point2.Y, 0); - ptr2 = (LineTypePtr) ptrtmp; - if (TEST_FLAG (AUTODRCFLAG, PCB)) - { - /* undo loses FOUNDFLAG */ - SET_FLAG(FOUNDFLAG, ptr2); - DrawLine (CURRENT, ptr2); - } - Crosshair.AttachedLine.Point1.X = - Crosshair.AttachedLine.Point2.X = ptr2->Point2.X; - Crosshair.AttachedLine.Point1.Y = - Crosshair.AttachedLine.Point2.Y = ptr2->Point2.Y; + if (Settings.Mode == ARC_MODE) { + if (Crosshair.AttachedBox.State == STATE_SECOND) { + Crosshair.AttachedBox.State = STATE_FIRST; + notify_crosshair_change(true); + return 0; + } + if (Crosshair.AttachedBox.State == STATE_THIRD) { + void *ptr1, *ptr2, *ptr3; + BoxTypePtr bx; + /* guaranteed to succeed */ + SearchObjectByLocation(ARC_TYPE, &ptr1, &ptr2, &ptr3, + Crosshair.AttachedBox.Point1.X, Crosshair.AttachedBox.Point1.Y, 0); + bx = GetArcEnds((ArcTypePtr) ptr2); + Crosshair.AttachedBox.Point1.X = Crosshair.AttachedBox.Point2.X = bx->X1; + Crosshair.AttachedBox.Point1.Y = Crosshair.AttachedBox.Point2.Y = bx->Y1; + AdjustAttachedObjects(); + if (--addedLines == 0) + Crosshair.AttachedBox.State = STATE_SECOND; + } } - FitCrosshairIntoGrid (Crosshair.X, Crosshair.Y); - AdjustAttachedObjects (); - if (--addedLines == 0) - { - Crosshair.AttachedLine.State = STATE_SECOND; - lastLayer = CURRENT; + /* undo the last destructive operation */ + if (Undo(true)) + SetChangedFlag(true); + } + else if (function) { + switch (GetFunctionID(function)) { + /* clear 'undo objects' list */ + case F_ClearList: + ClearUndoList(false); + break; } - else - { - /* this search is guaranteed to succeed too */ - SearchObjectByLocation (LINE_TYPE | RATLINE_TYPE, &ptr1, - &ptrtmp, - &ptr3, - Crosshair.AttachedLine.Point1.X, - Crosshair.AttachedLine.Point1.Y, 0); - ptr2 = (LineTypePtr) ptrtmp; - lastLayer = (LayerTypePtr) ptr1; - } - notify_crosshair_change (true); - return 0; - } } - if (Settings.Mode == ARC_MODE) - { - if (Crosshair.AttachedBox.State == STATE_SECOND) - { - Crosshair.AttachedBox.State = STATE_FIRST; - notify_crosshair_change (true); - return 0; - } - if (Crosshair.AttachedBox.State == STATE_THIRD) - { - void *ptr1, *ptr2, *ptr3; - BoxTypePtr bx; - /* guaranteed to succeed */ - SearchObjectByLocation (ARC_TYPE, &ptr1, &ptr2, &ptr3, - Crosshair.AttachedBox.Point1.X, - Crosshair.AttachedBox.Point1.Y, 0); - bx = GetArcEnds ((ArcTypePtr) ptr2); - Crosshair.AttachedBox.Point1.X = - Crosshair.AttachedBox.Point2.X = bx->X1; - Crosshair.AttachedBox.Point1.Y = - Crosshair.AttachedBox.Point2.Y = bx->Y1; - AdjustAttachedObjects (); - if (--addedLines == 0) - Crosshair.AttachedBox.State = STATE_SECOND; - } - } - /* undo the last destructive operation */ - if (Undo (true)) - SetChangedFlag (true); - } - else if (function) - { - switch (GetFunctionID (function)) - { - /* clear 'undo objects' list */ - case F_ClearList: - ClearUndoList (false); - break; - } - } - notify_crosshair_change (true); - return 0; + notify_crosshair_change(true); + return 0; } /* --------------------------------------------------------------------------- */ @@ -6684,31 +6005,23 @@ %end-doc */ -static int -ActionRedo (int argc, char **argv, Coord x, Coord y) +static int ActionRedo(int argc, char **argv, Coord x, Coord y) { - if (((Settings.Mode == POLYGON_MODE || - Settings.Mode == POLYGONHOLE_MODE) && - Crosshair.AttachedPolygon.PointN) || - Crosshair.AttachedLine.State == STATE_SECOND) - return 1; - notify_crosshair_change (false); - if (Redo (true)) - { - SetChangedFlag (true); - if (Settings.Mode == LINE_MODE && - Crosshair.AttachedLine.State != STATE_FIRST) - { - LineType *line = g_list_last (CURRENT->Line)->data; - Crosshair.AttachedLine.Point1.X = - Crosshair.AttachedLine.Point2.X = line->Point2.X; - Crosshair.AttachedLine.Point1.Y = - Crosshair.AttachedLine.Point2.Y = line->Point2.Y; - addedLines++; + if (((Settings.Mode == POLYGON_MODE || + Settings.Mode == POLYGONHOLE_MODE) && Crosshair.AttachedPolygon.PointN) || Crosshair.AttachedLine.State == STATE_SECOND) + return 1; + notify_crosshair_change(false); + if (Redo(true)) { + SetChangedFlag(true); + if (Settings.Mode == LINE_MODE && Crosshair.AttachedLine.State != STATE_FIRST) { + LineType *line = g_list_last(CURRENT->Line)->data; + Crosshair.AttachedLine.Point1.X = Crosshair.AttachedLine.Point2.X = line->Point2.X; + Crosshair.AttachedLine.Point1.Y = Crosshair.AttachedLine.Point2.Y = line->Point2.Y; + addedLines++; + } } - } - notify_crosshair_change (true); - return 0; + notify_crosshair_change(true); + return 0; } /* --------------------------------------------------------------------------- */ @@ -6735,28 +6048,25 @@ %end-doc */ -static int -ActionPolygon (int argc, char **argv, Coord x, Coord y) +static int ActionPolygon(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - if (function && Settings.Mode == POLYGON_MODE) - { - notify_crosshair_change (false); - switch (GetFunctionID (function)) - { - /* close open polygon if possible */ - case F_Close: - ClosePolygon (); - break; + char *function = ARG(0); + if (function && Settings.Mode == POLYGON_MODE) { + notify_crosshair_change(false); + switch (GetFunctionID(function)) { + /* close open polygon if possible */ + case F_Close: + ClosePolygon(); + break; - /* go back to the previous point */ - case F_PreviousPoint: - GoToPreviousPoint (); - break; + /* go back to the previous point */ + case F_PreviousPoint: + GoToPreviousPoint(); + break; + } + notify_crosshair_change(true); } - notify_crosshair_change (true); - } - return 0; + return 0; } /* --------------------------------------------------------------------------- */ @@ -6763,34 +6073,30 @@ static const char routestyle_syntax[] = "RouteStyle(1|2|3|4)"; -static const char routestyle_help[] = - "Copies the indicated routing style into the current sizes."; +static const char routestyle_help[] = "Copies the indicated routing style into the current sizes."; /* %start-doc actions RouteStyle %end-doc */ -static int -ActionRouteStyle (int argc, char **argv, Coord x, Coord y) +static int ActionRouteStyle(int argc, char **argv, Coord x, Coord y) { - char *str = ARG (0); - RouteStyleType *rts; - int number; + char *str = ARG(0); + RouteStyleType *rts; + int number; - if (str) - { - number = atoi (str); - if (number > 0 && number <= NUM_STYLES) - { - rts = &PCB->RouteStyle[number - 1]; - SetLineSize (rts->Thick); - SetViaSize (rts->Diameter, true); - SetViaDrillingHole (rts->Hole, true); - SetKeepawayWidth (rts->Keepaway); - hid_action("RouteStylesChanged"); + if (str) { + number = atoi(str); + if (number > 0 && number <= NUM_STYLES) { + rts = &PCB->RouteStyle[number - 1]; + SetLineSize(rts->Thick); + SetViaSize(rts->Diameter, true); + SetViaDrillingHole(rts->Hole, true); + SetKeepawayWidth(rts->Keepaway); + hid_action("RouteStylesChanged"); + } } - } - return 0; + return 0; } @@ -6810,47 +6116,43 @@ %end-doc */ -static int -ActionMoveObject (int argc, char **argv, Coord x, Coord y) +static int ActionMoveObject(int argc, char **argv, Coord x, Coord y) { - char *x_str = ARG (0); - char *y_str = ARG (1); - char *units = ARG (2); - Coord nx, ny; - bool absolute1, absolute2; - void *ptr1, *ptr2, *ptr3; - int type; + char *x_str = ARG(0); + char *y_str = ARG(1); + char *units = ARG(2); + Coord nx, ny; + bool absolute1, absolute2; + void *ptr1, *ptr2, *ptr3; + int type; - ny = GetValue (y_str, units, &absolute1); - nx = GetValue (x_str, units, &absolute2); + ny = GetValue(y_str, units, &absolute1); + nx = GetValue(x_str, units, &absolute2); - type = SearchScreen (x, y, MOVE_TYPES, &ptr1, &ptr2, &ptr3); - if (type == NO_TYPE) - { - Message (_("Nothing found under crosshair\n")); - return 1; - } - if (absolute1) - nx -= x; - if (absolute2) - ny -= y; - Crosshair.AttachedObject.RubberbandN = 0; - if (TEST_FLAG (RUBBERBANDFLAG, PCB)) - LookupRubberbandLines (type, ptr1, ptr2, ptr3); - if (type == ELEMENT_TYPE) - LookupRatLines (type, ptr1, ptr2, ptr3); - MoveObjectAndRubberband (type, ptr1, ptr2, ptr3, nx, ny); - SetChangedFlag (true); - return 0; + type = SearchScreen(x, y, MOVE_TYPES, &ptr1, &ptr2, &ptr3); + if (type == NO_TYPE) { + Message(_("Nothing found under crosshair\n")); + return 1; + } + if (absolute1) + nx -= x; + if (absolute2) + ny -= y; + Crosshair.AttachedObject.RubberbandN = 0; + if (TEST_FLAG(RUBBERBANDFLAG, PCB)) + LookupRubberbandLines(type, ptr1, ptr2, ptr3); + if (type == ELEMENT_TYPE) + LookupRatLines(type, ptr1, ptr2, ptr3); + MoveObjectAndRubberband(type, ptr1, ptr2, ptr3, nx, ny); + SetChangedFlag(true); + return 0; } /* --------------------------------------------------------------------------- */ -static const char movetocurrentlayer_syntax[] = - "MoveToCurrentLayer(Object|SelectedObjects)"; +static const char movetocurrentlayer_syntax[] = "MoveToCurrentLayer(Object|SelectedObjects)"; -static const char movetocurrentlayer_help[] = - "Moves objects to the current layer."; +static const char movetocurrentlayer_help[] = "Moves objects to the current layer."; /* %start-doc actions MoveToCurrentLayer @@ -6860,43 +6162,37 @@ %end-doc */ -static int -ActionMoveToCurrentLayer (int argc, char **argv, Coord x, Coord y) +static int ActionMoveToCurrentLayer(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - if (function) - { - switch (GetFunctionID (function)) - { - case F_Object: - { - int type; - void *ptr1, *ptr2, *ptr3; + char *function = ARG(0); + if (function) { + switch (GetFunctionID(function)) { + case F_Object: + { + int type; + void *ptr1, *ptr2, *ptr3; - gui->get_coords (_("Select an Object"), &x, &y); - if ((type = - SearchScreen (x, y, MOVETOLAYER_TYPES, - &ptr1, &ptr2, &ptr3)) != NO_TYPE) - if (MoveObjectToLayer (type, ptr1, ptr2, ptr3, CURRENT, false)) - SetChangedFlag (true); - break; - } + gui->get_coords(_("Select an Object"), &x, &y); + if ((type = SearchScreen(x, y, MOVETOLAYER_TYPES, &ptr1, &ptr2, &ptr3)) != NO_TYPE) + if (MoveObjectToLayer(type, ptr1, ptr2, ptr3, CURRENT, false)) + SetChangedFlag(true); + break; + } - case F_SelectedObjects: - case F_Selected: - if (MoveSelectedObjectsToLayer (CURRENT)) - SetChangedFlag (true); - break; + case F_SelectedObjects: + case F_Selected: + if (MoveSelectedObjectsToLayer(CURRENT)) + SetChangedFlag(true); + break; + } } - } - return 0; + return 0; } static const char setsame_syntax[] = "SetSame()"; -static const char setsame_help[] = - "Sets current layer and sizes to match indicated item."; +static const char setsame_help[] = "Sets current layer and sizes to match indicated item."; /* %start-doc actions SetSame @@ -6906,63 +6202,60 @@ %end-doc */ -static int -ActionSetSame (int argc, char **argv, Coord x, Coord y) +static int ActionSetSame(int argc, char **argv, Coord x, Coord y) { - void *ptr1, *ptr2, *ptr3; - int type; - LayerTypePtr layer = CURRENT; + void *ptr1, *ptr2, *ptr3; + int type; + LayerTypePtr layer = CURRENT; - type = SearchScreen (x, y, CLONE_TYPES, &ptr1, &ptr2, &ptr3); + type = SearchScreen(x, y, CLONE_TYPES, &ptr1, &ptr2, &ptr3); /* set layer current and size from line or arc */ - switch (type) - { - case LINE_TYPE: - notify_crosshair_change (false); - Settings.LineThickness = ((LineTypePtr) ptr2)->Thickness; - Settings.Keepaway = ((LineTypePtr) ptr2)->Clearance / 2; - layer = (LayerTypePtr) ptr1; - if (Settings.Mode != LINE_MODE) - SetMode (LINE_MODE); - notify_crosshair_change (true); - hid_action ("RouteStylesChanged"); - break; + switch (type) { + case LINE_TYPE: + notify_crosshair_change(false); + Settings.LineThickness = ((LineTypePtr) ptr2)->Thickness; + Settings.Keepaway = ((LineTypePtr) ptr2)->Clearance / 2; + layer = (LayerTypePtr) ptr1; + if (Settings.Mode != LINE_MODE) + SetMode(LINE_MODE); + notify_crosshair_change(true); + hid_action("RouteStylesChanged"); + break; - case ARC_TYPE: - notify_crosshair_change (false); - Settings.LineThickness = ((ArcTypePtr) ptr2)->Thickness; - Settings.Keepaway = ((ArcTypePtr) ptr2)->Clearance / 2; - layer = (LayerTypePtr) ptr1; - if (Settings.Mode != ARC_MODE) - SetMode (ARC_MODE); - notify_crosshair_change (true); - hid_action ("RouteStylesChanged"); - break; + case ARC_TYPE: + notify_crosshair_change(false); + Settings.LineThickness = ((ArcTypePtr) ptr2)->Thickness; + Settings.Keepaway = ((ArcTypePtr) ptr2)->Clearance / 2; + layer = (LayerTypePtr) ptr1; + if (Settings.Mode != ARC_MODE) + SetMode(ARC_MODE); + notify_crosshair_change(true); + hid_action("RouteStylesChanged"); + break; - case POLYGON_TYPE: - layer = (LayerTypePtr) ptr1; - break; + case POLYGON_TYPE: + layer = (LayerTypePtr) ptr1; + break; - case VIA_TYPE: - notify_crosshair_change (false); - Settings.ViaThickness = ((PinTypePtr) ptr2)->Thickness; - Settings.ViaDrillingHole = ((PinTypePtr) ptr2)->DrillingHole; - Settings.Keepaway = ((PinTypePtr) ptr2)->Clearance / 2; - if (Settings.Mode != VIA_MODE) - SetMode (VIA_MODE); - notify_crosshair_change (true); - hid_action ("RouteStylesChanged"); - break; + case VIA_TYPE: + notify_crosshair_change(false); + Settings.ViaThickness = ((PinTypePtr) ptr2)->Thickness; + Settings.ViaDrillingHole = ((PinTypePtr) ptr2)->DrillingHole; + Settings.Keepaway = ((PinTypePtr) ptr2)->Clearance / 2; + if (Settings.Mode != VIA_MODE) + SetMode(VIA_MODE); + notify_crosshair_change(true); + hid_action("RouteStylesChanged"); + break; - default: - return 1; - } - if (layer != CURRENT) - { - ChangeGroupVisibility (GetLayerNumber (PCB->Data, layer), true, true); - Redraw (); - } - return 0; + default: + return 1; + } + if (layer != CURRENT) { + ChangeGroupVisibility(GetLayerNumber(PCB->Data, layer), true, true); + Redraw(); + } + return 0; } @@ -6969,11 +6262,10 @@ /* --------------------------------------------------------------------------- */ static const char setflag_syntax[] = - "SetFlag(Object|Selected|SelectedObjects, flag)\n" - "SetFlag(SelectedLines|SelectedPins|SelectedVias, flag)\n" - "SetFlag(SelectedPads|SelectedTexts|SelectedNames, flag)\n" - "SetFlag(SelectedElements, flag)\n" - "flag = square | octagon | thermal | join"; + "SetFlag(Object|Selected|SelectedObjects, flag)\n" + "SetFlag(SelectedLines|SelectedPins|SelectedVias, flag)\n" + "SetFlag(SelectedPads|SelectedTexts|SelectedNames, flag)\n" + "SetFlag(SelectedElements, flag)\n" "flag = square | octagon | thermal | join"; static const char setflag_help[] = "Sets flags on objects."; @@ -6988,23 +6280,21 @@ %end-doc */ -static int -ActionSetFlag (int argc, char **argv, Coord x, Coord y) +static int ActionSetFlag(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - char *flag = ARG (1); - ChangeFlag (function, flag, 1, "SetFlag"); - return 0; + char *function = ARG(0); + char *flag = ARG(1); + ChangeFlag(function, flag, 1, "SetFlag"); + return 0; } /* --------------------------------------------------------------------------- */ static const char clrflag_syntax[] = - "ClrFlag(Object|Selected|SelectedObjects, flag)\n" - "ClrFlag(SelectedLines|SelectedPins|SelectedVias, flag)\n" - "ClrFlag(SelectedPads|SelectedTexts|SelectedNames, flag)\n" - "ClrFlag(SelectedElements, flag)\n" - "flag = square | octagon | thermal | join"; + "ClrFlag(Object|Selected|SelectedObjects, flag)\n" + "ClrFlag(SelectedLines|SelectedPins|SelectedVias, flag)\n" + "ClrFlag(SelectedPads|SelectedTexts|SelectedNames, flag)\n" + "ClrFlag(SelectedElements, flag)\n" "flag = square | octagon | thermal | join"; static const char clrflag_help[] = "Clears flags on objects."; @@ -7019,24 +6309,21 @@ %end-doc */ -static int -ActionClrFlag (int argc, char **argv, Coord x, Coord y) +static int ActionClrFlag(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - char *flag = ARG (1); - ChangeFlag (function, flag, 0, "ClrFlag"); - return 0; + char *function = ARG(0); + char *flag = ARG(1); + ChangeFlag(function, flag, 0, "ClrFlag"); + return 0; } /* --------------------------------------------------------------------------- */ static const char changeflag_syntax[] = - "ChangeFlag(Object|Selected|SelectedObjects, flag, value)\n" - "ChangeFlag(SelectedLines|SelectedPins|SelectedVias, flag, value)\n" - "ChangeFlag(SelectedPads|SelectedTexts|SelectedNames, flag, value)\n" - "ChangeFlag(SelectedElements, flag, value)\n" - "flag = square | octagon | thermal | join\n" - "value = 0 | 1"; + "ChangeFlag(Object|Selected|SelectedObjects, flag, value)\n" + "ChangeFlag(SelectedLines|SelectedPins|SelectedVias, flag, value)\n" + "ChangeFlag(SelectedPads|SelectedTexts|SelectedNames, flag, value)\n" + "ChangeFlag(SelectedElements, flag, value)\n" "flag = square | octagon | thermal | join\n" "value = 0 | 1"; static const char changeflag_help[] = "Sets or clears flags on objects."; @@ -7049,107 +6336,98 @@ %end-doc */ -static int -ActionChangeFlag (int argc, char **argv, Coord x, Coord y) +static int ActionChangeFlag(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - char *flag = ARG (1); - int value = argc > 2 ? atoi (argv[2]) : -1; - if (value != 0 && value != 1) - AFAIL (changeflag); + char *function = ARG(0); + char *flag = ARG(1); + int value = argc > 2 ? atoi(argv[2]) : -1; + if (value != 0 && value != 1) + AFAIL(changeflag); - ChangeFlag (function, flag, value, "ChangeFlag"); - return 0; + ChangeFlag(function, flag, value, "ChangeFlag"); + return 0; } -static void -ChangeFlag (char *what, char *flag_name, int value, char *cmd_name) +static void ChangeFlag(char *what, char *flag_name, int value, char *cmd_name) { - bool (*set_object) (int, void *, void *, void *); - bool (*set_selected) (int); + bool(*set_object) (int, void *, void *, void *); + bool(*set_selected) (int); - if (NSTRCMP (flag_name, "square") == 0) - { - set_object = value ? SetObjectSquare : ClrObjectSquare; - set_selected = value ? SetSelectedSquare : ClrSelectedSquare; - } - else if (NSTRCMP (flag_name, "octagon") == 0) - { - set_object = value ? SetObjectOctagon : ClrObjectOctagon; - set_selected = value ? SetSelectedOctagon : ClrSelectedOctagon; - } - else if (NSTRCMP (flag_name, "join") == 0) - { - /* Note: these are backwards, because the flag is "clear" but - the command is "join". */ - set_object = value ? ClrObjectJoin : SetObjectJoin; - set_selected = value ? ClrSelectedJoin : SetSelectedJoin; - } - else - { - Message (_("%s(): Flag \"%s\" is not valid\n"), cmd_name, flag_name); - return; - } + if (NSTRCMP(flag_name, "square") == 0) { + set_object = value ? SetObjectSquare : ClrObjectSquare; + set_selected = value ? SetSelectedSquare : ClrSelectedSquare; + } + else if (NSTRCMP(flag_name, "octagon") == 0) { + set_object = value ? SetObjectOctagon : ClrObjectOctagon; + set_selected = value ? SetSelectedOctagon : ClrSelectedOctagon; + } + else if (NSTRCMP(flag_name, "join") == 0) { + /* Note: these are backwards, because the flag is "clear" but + the command is "join". */ + set_object = value ? ClrObjectJoin : SetObjectJoin; + set_selected = value ? ClrSelectedJoin : SetSelectedJoin; + } + else { + Message(_("%s(): Flag \"%s\" is not valid\n"), cmd_name, flag_name); + return; + } - switch (GetFunctionID (what)) - { - case F_Object: - { - int type; - void *ptr1, *ptr2, *ptr3; + switch (GetFunctionID(what)) { + case F_Object: + { + int type; + void *ptr1, *ptr2, *ptr3; - if ((type = - SearchScreen (Crosshair.X, Crosshair.Y, CHANGESIZE_TYPES, - &ptr1, &ptr2, &ptr3)) != NO_TYPE) - if (TEST_FLAG (LOCKFLAG, (PinTypePtr) ptr2)) - Message (_("Sorry, the object is locked\n")); - if (set_object (type, ptr1, ptr2, ptr3)) - SetChangedFlag (true); - break; - } + if ((type = SearchScreen(Crosshair.X, Crosshair.Y, CHANGESIZE_TYPES, &ptr1, &ptr2, &ptr3)) != NO_TYPE) + if (TEST_FLAG(LOCKFLAG, (PinTypePtr) ptr2)) + Message(_("Sorry, the object is locked\n")); + if (set_object(type, ptr1, ptr2, ptr3)) + SetChangedFlag(true); + break; + } - case F_SelectedVias: - if (set_selected (VIA_TYPE)) - SetChangedFlag (true); - break; + case F_SelectedVias: + if (set_selected(VIA_TYPE)) + SetChangedFlag(true); + break; - case F_SelectedPins: - if (set_selected (PIN_TYPE)) - SetChangedFlag (true); - break; + case F_SelectedPins: + if (set_selected(PIN_TYPE)) + SetChangedFlag(true); + break; - case F_SelectedPads: - if (set_selected (PAD_TYPE)) - SetChangedFlag (true); - break; + case F_SelectedPads: + if (set_selected(PAD_TYPE)) + SetChangedFlag(true); + break; - case F_SelectedLines: - if (set_selected (LINE_TYPE)) - SetChangedFlag (true); - break; + case F_SelectedLines: + if (set_selected(LINE_TYPE)) + SetChangedFlag(true); + break; - case F_SelectedTexts: - if (set_selected (TEXT_TYPE)) - SetChangedFlag (true); - break; + case F_SelectedTexts: + if (set_selected(TEXT_TYPE)) + SetChangedFlag(true); + break; - case F_SelectedNames: - if (set_selected (ELEMENTNAME_TYPE)) - SetChangedFlag (true); - break; + case F_SelectedNames: + if (set_selected(ELEMENTNAME_TYPE)) + SetChangedFlag(true); + break; - case F_SelectedElements: - if (set_selected (ELEMENT_TYPE)) - SetChangedFlag (true); - break; + case F_SelectedElements: + if (set_selected(ELEMENT_TYPE)) + SetChangedFlag(true); + break; - case F_Selected: - case F_SelectedObjects: - if (set_selected (CHANGESIZE_TYPES)) - SetChangedFlag (true); - break; - } + case F_Selected: + case F_SelectedObjects: + if (set_selected(CHANGESIZE_TYPES)) + SetChangedFlag(true); + break; + } } /* --------------------------------------------------------------------------- */ @@ -7164,73 +6442,67 @@ %end-doc */ -static int -ActionExecuteFile (int argc, char **argv, Coord x, Coord y) +static int ActionExecuteFile(int argc, char **argv, Coord x, Coord y) { - FILE *fp; - char *fname; - char line[256]; - int n = 0; - char *sp; + FILE *fp; + char *fname; + char line[256]; + int n = 0; + char *sp; - if (argc != 1) - AFAIL (executefile); + if (argc != 1) + AFAIL(executefile); - fname = argv[0]; + fname = argv[0]; - if ((fp = fopen (fname, "r")) == NULL) - { - fprintf (stderr, _("Could not open actions file \"%s\".\n"), fname); - return 1; - } + if ((fp = fopen(fname, "r")) == NULL) { + fprintf(stderr, _("Could not open actions file \"%s\".\n"), fname); + return 1; + } - defer_updates = 1; - defer_needs_update = 0; - while (fgets (line, sizeof (line), fp) != NULL) - { - n++; - sp = line; + defer_updates = 1; + defer_needs_update = 0; + while (fgets(line, sizeof(line), fp) != NULL) { + n++; + sp = line; - /* eat the trailing newline */ - while (*sp && *sp != '\r' && *sp != '\n') - sp++; - *sp = '\0'; + /* eat the trailing newline */ + while (*sp && *sp != '\r' && *sp != '\n') + sp++; + *sp = '\0'; - /* eat leading spaces and tabs */ - sp = line; - while (*sp && (*sp == ' ' || *sp == '\t')) - sp++; + /* eat leading spaces and tabs */ + sp = line; + while (*sp && (*sp == ' ' || *sp == '\t')) + sp++; - /* - * if we have anything left and its not a comment line - * then execute it - */ + /* + * if we have anything left and its not a comment line + * then execute it + */ - if (*sp && *sp != '#') - { - /*Message ("%s : line %-3d : \"%s\"\n", fname, n, sp);*/ - hid_parse_actions (sp); + if (*sp && *sp != '#') { + /*Message ("%s : line %-3d : \"%s\"\n", fname, n, sp); */ + hid_parse_actions(sp); + } } - } - defer_updates = 0; - if (defer_needs_update) - { - IncrementUndoSerialNumber (); - gui->invalidate_all (); - } - fclose (fp); - return 0; + defer_updates = 0; + if (defer_needs_update) { + IncrementUndoSerialNumber(); + gui->invalidate_all(); + } + fclose(fp); + return 0; } /* --------------------------------------------------------------------------- */ -static int -ActionPSCalib (int argc, char **argv, Coord x, Coord y) +static int ActionPSCalib(int argc, char **argv, Coord x, Coord y) { - HID *ps = hid_find_exporter ("ps"); - ps->calibrate (0.0,0.0); - return 0; + HID *ps = hid_find_exporter("ps"); + ps->calibrate(0.0, 0.0); + return 0; } /* --------------------------------------------------------------------------- */ @@ -7237,46 +6509,41 @@ static ElementType *element_cache = NULL; -static ElementType * -find_element_by_refdes (char *refdes) +static ElementType *find_element_by_refdes(char *refdes) { - if (element_cache - && NAMEONPCB_NAME(element_cache) - && strcmp (NAMEONPCB_NAME(element_cache), refdes) == 0) - return element_cache; + if (element_cache && NAMEONPCB_NAME(element_cache) + && strcmp(NAMEONPCB_NAME(element_cache), refdes) == 0) + return element_cache; - ELEMENT_LOOP (PCB->Data); - { - if (NAMEONPCB_NAME(element) - && strcmp (NAMEONPCB_NAME(element), refdes) == 0) - { - element_cache = element; - return element_cache; - } - } - END_LOOP; - return NULL; + ELEMENT_LOOP(PCB->Data); + { + if (NAMEONPCB_NAME(element) + && strcmp(NAMEONPCB_NAME(element), refdes) == 0) { + element_cache = element; + return element_cache; + } + } + END_LOOP; + return NULL; } -static AttributeType * -lookup_attr (AttributeListTypePtr list, const char *name) +static AttributeType *lookup_attr(AttributeListTypePtr list, const char *name) { - int i; - for (i=0; iNumber; i++) - if (strcmp (list->List[i].name, name) == 0) - return & list->List[i]; - return NULL; + int i; + for (i = 0; i < list->Number; i++) + if (strcmp(list->List[i].name, name) == 0) + return &list->List[i]; + return NULL; } -static void -delete_attr (AttributeListTypePtr list, AttributeType *attr) +static void delete_attr(AttributeListTypePtr list, AttributeType * attr) { - int idx = attr - list->List; - if (idx < 0 || idx >= list->Number) - return; - if (list->Number - idx > 1) - memmove (attr, attr+1, (list->Number - idx - 1) * sizeof(AttributeType)); - list->Number --; + int idx = attr - list->List; + if (idx < 0 || idx >= list->Number) + return; + if (list->Number - idx > 1) + memmove(attr, attr + 1, (list->Number - idx - 1) * sizeof(AttributeType)); + list->Number--; } /* ---------------------------------------------------------------- */ @@ -7311,188 +6578,174 @@ static int number_of_footprints_not_found; -static int -parse_layout_attribute_units (char *name, int def) +static int parse_layout_attribute_units(char *name, int def) { - const char *as = AttributeGet (PCB, name); - if (!as) - return def; - return GetValue (as, NULL, NULL); + const char *as = AttributeGet(PCB, name); + if (!as) + return def; + return GetValue(as, NULL, NULL); } -static int -ActionElementList (int argc, char **argv, Coord x, Coord y) +static int ActionElementList(int argc, char **argv, Coord x, Coord y) { - ElementType *e = NULL; - char *refdes, *value, *footprint, *old; - char *args[3]; - char *function = argv[0]; + ElementType *e = NULL; + char *refdes, *value, *footprint, *old; + char *args[3]; + char *function = argv[0]; #ifdef DEBUG - printf("Entered ActionElementList, executing function %s\n", function); + printf("Entered ActionElementList, executing function %s\n", function); #endif - if (strcasecmp (function, "start") == 0) - { - ELEMENT_LOOP (PCB->Data); - { - CLEAR_FLAG (FOUNDFLAG, element); - } - END_LOOP; - element_cache = NULL; - number_of_footprints_not_found = 0; - return 0; - } + if (strcasecmp(function, "start") == 0) { + ELEMENT_LOOP(PCB->Data); + { + CLEAR_FLAG(FOUNDFLAG, element); + } + END_LOOP; + element_cache = NULL; + number_of_footprints_not_found = 0; + return 0; + } - if (strcasecmp (function, "done") == 0) - { - ELEMENT_LOOP (PCB->Data); - { - if (TEST_FLAG (FOUNDFLAG, element)) - { - CLEAR_FLAG (FOUNDFLAG, element); - } - else if (! EMPTY_STRING_P (NAMEONPCB_NAME (element))) - { - /* Unnamed elements should remain untouched */ - SET_FLAG (SELECTEDFLAG, element); - } - } - END_LOOP; - if (number_of_footprints_not_found > 0) - gui->confirm_dialog ("Not all requested footprints were found.\n" - "See the message log for details", - "Ok", NULL); - return 0; - } + if (strcasecmp(function, "done") == 0) { + ELEMENT_LOOP(PCB->Data); + { + if (TEST_FLAG(FOUNDFLAG, element)) { + CLEAR_FLAG(FOUNDFLAG, element); + } + else if (!EMPTY_STRING_P(NAMEONPCB_NAME(element))) { + /* Unnamed elements should remain untouched */ + SET_FLAG(SELECTEDFLAG, element); + } + } + END_LOOP; + if (number_of_footprints_not_found > 0) + gui->confirm_dialog("Not all requested footprints were found.\n" "See the message log for details", "Ok", NULL); + return 0; + } - if (strcasecmp (function, "need") != 0) - AFAIL (elementlist); + if (strcasecmp(function, "need") != 0) + AFAIL(elementlist); - if (argc != 4) - AFAIL (elementlist); + if (argc != 4) + AFAIL(elementlist); - argc --; - argv ++; + argc--; + argv++; - refdes = ARG(0); - footprint = ARG(1); - value = ARG(2); + refdes = ARG(0); + footprint = ARG(1); + value = ARG(2); - args[0] = footprint; - args[1] = refdes; - args[2] = value; + args[0] = footprint; + args[1] = refdes; + args[2] = value; #ifdef DEBUG - printf(" ... footprint = %s\n", footprint); - printf(" ... refdes = %s\n", refdes); - printf(" ... value = %s\n", value); + printf(" ... footprint = %s\n", footprint); + printf(" ... refdes = %s\n", refdes); + printf(" ... value = %s\n", value); #endif - e = find_element_by_refdes (refdes); + e = find_element_by_refdes(refdes); - if (!e) - { - Coord nx, ny, d; + if (!e) { + Coord nx, ny, d; #ifdef DEBUG - printf(" ... Footprint not on board, need to add it.\n"); + printf(" ... Footprint not on board, need to add it.\n"); #endif - /* Not on board, need to add it. */ - if (LoadFootprint(argc, args, x, y)) - { - number_of_footprints_not_found ++; - return 1; - } + /* Not on board, need to add it. */ + if (LoadFootprint(argc, args, x, y)) { + number_of_footprints_not_found++; + return 1; + } - nx = PCB->MaxWidth / 2; - ny = PCB->MaxHeight / 2; - d = MIN (PCB->MaxWidth, PCB->MaxHeight) / 10; + nx = PCB->MaxWidth / 2; + ny = PCB->MaxHeight / 2; + d = MIN(PCB->MaxWidth, PCB->MaxHeight) / 10; - nx = parse_layout_attribute_units ("import::newX", nx); - ny = parse_layout_attribute_units ("import::newY", ny); - d = parse_layout_attribute_units ("import::disperse", d); + nx = parse_layout_attribute_units("import::newX", nx); + ny = parse_layout_attribute_units("import::newY", ny); + d = parse_layout_attribute_units("import::disperse", d); - if (d > 0) - { - nx += rand () % (d*2) - d; - ny += rand () % (d*2) - d; - } + if (d > 0) { + nx += rand() % (d * 2) - d; + ny += rand() % (d * 2) - d; + } - if (nx < 0) - nx = 0; - if (nx >= PCB->MaxWidth) - nx = PCB->MaxWidth - 1; - if (ny < 0) - ny = 0; - if (ny >= PCB->MaxHeight) - ny = PCB->MaxHeight - 1; + if (nx < 0) + nx = 0; + if (nx >= PCB->MaxWidth) + nx = PCB->MaxWidth - 1; + if (ny < 0) + ny = 0; + if (ny >= PCB->MaxHeight) + ny = PCB->MaxHeight - 1; - /* Place components onto center of board. */ - if (CopyPastebufferToLayout (nx, ny)) - SetChangedFlag (true); - } + /* Place components onto center of board. */ + if (CopyPastebufferToLayout(nx, ny)) + SetChangedFlag(true); + } - else if (e && strcmp (DESCRIPTION_NAME(e), footprint) != 0) - { + else if (e && strcmp(DESCRIPTION_NAME(e), footprint) != 0) { #ifdef DEBUG - printf(" ... Footprint on board, but different from footprint loaded.\n"); + printf(" ... Footprint on board, but different from footprint loaded.\n"); #endif - int er, pr, i; - Coord mx, my; - ElementType *pe; + int er, pr, i; + Coord mx, my; + ElementType *pe; - /* Different footprint, we need to swap them out. */ - if (LoadFootprint(argc, args, x, y)) - { - number_of_footprints_not_found ++; - return 1; - } + /* Different footprint, we need to swap them out. */ + if (LoadFootprint(argc, args, x, y)) { + number_of_footprints_not_found++; + return 1; + } - er = ElementOrientation (e); - pe = PASTEBUFFER->Data->Element->data; - if (!FRONT (e)) - MirrorElementCoordinates (PASTEBUFFER->Data, pe, pe->MarkY*2 - PCB->MaxHeight); - pr = ElementOrientation (pe); + er = ElementOrientation(e); + pe = PASTEBUFFER->Data->Element->data; + if (!FRONT(e)) + MirrorElementCoordinates(PASTEBUFFER->Data, pe, pe->MarkY * 2 - PCB->MaxHeight); + pr = ElementOrientation(pe); - mx = e->MarkX; - my = e->MarkY; + mx = e->MarkX; + my = e->MarkY; - if (er != pr) - RotateElementLowLevel (PASTEBUFFER->Data, pe, pe->MarkX, pe->MarkY, (er-pr+4)%4); + if (er != pr) + RotateElementLowLevel(PASTEBUFFER->Data, pe, pe->MarkX, pe->MarkY, (er - pr + 4) % 4); - for (i=0; iName[i].X = e->Name[i].X - mx + pe->MarkX ; - pe->Name[i].Y = e->Name[i].Y - my + pe->MarkY ; - pe->Name[i].Direction = e->Name[i].Direction; - pe->Name[i].Scale = e->Name[i].Scale; - } + for (i = 0; i < MAX_ELEMENTNAMES; i++) { + pe->Name[i].X = e->Name[i].X - mx + pe->MarkX; + pe->Name[i].Y = e->Name[i].Y - my + pe->MarkY; + pe->Name[i].Direction = e->Name[i].Direction; + pe->Name[i].Scale = e->Name[i].Scale; + } - RemoveElement (e); + RemoveElement(e); - if (CopyPastebufferToLayout (mx, my)) - SetChangedFlag (true); - } + if (CopyPastebufferToLayout(mx, my)) + SetChangedFlag(true); + } - /* Now reload footprint */ - element_cache = NULL; - e = find_element_by_refdes (refdes); + /* Now reload footprint */ + element_cache = NULL; + e = find_element_by_refdes(refdes); - old = ChangeElementText (PCB, PCB->Data, e, NAMEONPCB_INDEX, strdup (refdes)); - if (old) - free(old); - old = ChangeElementText (PCB, PCB->Data, e, VALUE_INDEX, strdup (value)); - if (old) - free(old); + old = ChangeElementText(PCB, PCB->Data, e, NAMEONPCB_INDEX, strdup(refdes)); + if (old) + free(old); + old = ChangeElementText(PCB, PCB->Data, e, VALUE_INDEX, strdup(value)); + if (old) + free(old); - SET_FLAG (FOUNDFLAG, e); + SET_FLAG(FOUNDFLAG, e); #ifdef DEBUG - printf(" ... Leaving ActionElementList.\n"); + printf(" ... Leaving ActionElementList.\n"); #endif - return 0; + return 0; } /* ---------------------------------------------------------------- */ @@ -7508,55 +6761,48 @@ %end-doc */ -static int -ActionElementSetAttr (int argc, char **argv, Coord x, Coord y) +static int ActionElementSetAttr(int argc, char **argv, Coord x, Coord y) { - ElementType *e = NULL; - char *refdes, *name, *value; - AttributeType *attr; + ElementType *e = NULL; + char *refdes, *name, *value; + AttributeType *attr; - if (argc < 2) - { - AFAIL (changepinname); - } + if (argc < 2) { + AFAIL(changepinname); + } - refdes = argv[0]; - name = argv[1]; - value = ARG(2); + refdes = argv[0]; + name = argv[1]; + value = ARG(2); - ELEMENT_LOOP (PCB->Data); - { - if (NSTRCMP (refdes, NAMEONPCB_NAME (element)) == 0) - { - e = element; - break; - } - } - END_LOOP; + ELEMENT_LOOP(PCB->Data); + { + if (NSTRCMP(refdes, NAMEONPCB_NAME(element)) == 0) { + e = element; + break; + } + } + END_LOOP; - if (!e) - { - Message(_("Cannot change attribute of %s - element not found\n"), refdes); - return 1; - } + if (!e) { + Message(_("Cannot change attribute of %s - element not found\n"), refdes); + return 1; + } - attr = lookup_attr (&e->Attributes, name); + attr = lookup_attr(&e->Attributes, name); - if (attr && value) - { - free (attr->value); - attr->value = strdup (value); - } - if (attr && ! value) - { - delete_attr (& e->Attributes, attr); - } - if (!attr && value) - { - CreateNewAttribute (& e->Attributes, name, value); - } + if (attr && value) { + free(attr->value); + attr->value = strdup(value); + } + if (attr && !value) { + delete_attr(&e->Attributes, attr); + } + if (!attr && value) { + CreateNewAttribute(&e->Attributes, name, value); + } - return 0; + return 0; } /* ---------------------------------------------------------------- */ @@ -7570,56 +6816,50 @@ %end-doc */ -static int -ActionExecCommand (int argc, char **argv, Coord x, Coord y) +static int ActionExecCommand(int argc, char **argv, Coord x, Coord y) { - char *command; + char *command; - if (argc < 1) - { - AFAIL (execcommand); - } + if (argc < 1) { + AFAIL(execcommand); + } - command = ARG(0); + command = ARG(0); - if (system (command)) - return 1; - return 0; + if (system(command)) + return 1; + return 0; } /* ---------------------------------------------------------------- */ -static int -pcb_spawnvp (char **argv) +static int pcb_spawnvp(char **argv) { #ifdef HAVE__SPAWNVP - int result = _spawnvp (_P_WAIT, argv[0], (const char * const *) argv); - if (result == -1) - return 1; - else - return 0; + int result = _spawnvp(_P_WAIT, argv[0], (const char *const *) argv); + if (result == -1) + return 1; + else + return 0; #else - int pid; - pid = fork (); - if (pid < 0) - { - /* error */ - Message(_("Cannot fork!")); - return 1; - } - else if (pid == 0) - { - /* Child */ - execvp (argv[0], argv); - exit(1); - } - else - { - int rv; - /* Parent */ - wait (&rv); - } - return 0; + int pid; + pid = fork(); + if (pid < 0) { + /* error */ + Message(_("Cannot fork!")); + return 1; + } + else if (pid == 0) { + /* Child */ + execvp(argv[0], argv); + exit(1); + } + else { + int rv; + /* Parent */ + wait(&rv); + } + return 0; #endif } @@ -7641,82 +6881,77 @@ * with tempfile_unlink to make sure the temporary directory is also * removed when mkdtemp() is used. */ -static char * -tempfile_name_new (char * name) +static char *tempfile_name_new(char *name) { - char *tmpfile = NULL; + char *tmpfile = NULL; #ifdef HAVE_MKDTEMP - char *tmpdir, *mytmpdir; - size_t len; + char *tmpdir, *mytmpdir; + size_t len; #endif - assert ( name != NULL ); + assert(name != NULL); #ifdef HAVE_MKDTEMP #define TEMPLATE "pcb.XXXXXXXX" - - - tmpdir = getenv ("TMPDIR"); - /* FIXME -- what about win32? */ - if (tmpdir == NULL) { - tmpdir = "/tmp"; - } - - mytmpdir = (char *) malloc (sizeof(char) * - (strlen (tmpdir) + - 1 + - strlen (TEMPLATE) + - 1)); - if (mytmpdir == NULL) { - fprintf (stderr, "%s(): malloc failed()\n", __FUNCTION__); - exit (1); - } - - *mytmpdir = '\0'; - (void)strcat (mytmpdir, tmpdir); - (void)strcat (mytmpdir, PCB_DIR_SEPARATOR_S); - (void)strcat (mytmpdir, TEMPLATE); - if (mkdtemp (mytmpdir) == NULL) { - fprintf (stderr, "%s(): mkdtemp (\"%s\") failed\n", __FUNCTION__, mytmpdir); - free (mytmpdir); - return NULL; - } + tmpdir = getenv("TMPDIR"); - len = strlen (mytmpdir) + /* the temp directory name */ - 1 + /* the directory sep. */ - strlen (name) + /* the file name */ - 1 /* the \0 termination */ - ; + /* FIXME -- what about win32? */ + if (tmpdir == NULL) { + tmpdir = "/tmp"; + } - tmpfile = (char *) malloc (sizeof (char) * len); + mytmpdir = (char *) malloc(sizeof(char) * (strlen(tmpdir) + 1 + strlen(TEMPLATE) + 1)); + if (mytmpdir == NULL) { + fprintf(stderr, "%s(): malloc failed()\n", __FUNCTION__); + exit(1); + } - *tmpfile = '\0'; - (void)strcat (tmpfile, mytmpdir); - (void)strcat (tmpfile, PCB_DIR_SEPARATOR_S); - (void)strcat (tmpfile, name); - - free (mytmpdir); + *mytmpdir = '\0'; + (void) strcat(mytmpdir, tmpdir); + (void) strcat(mytmpdir, PCB_DIR_SEPARATOR_S); + (void) strcat(mytmpdir, TEMPLATE); + if (mkdtemp(mytmpdir) == NULL) { + fprintf(stderr, "%s(): mkdtemp (\"%s\") failed\n", __FUNCTION__, mytmpdir); + free(mytmpdir); + return NULL; + } + + + len = strlen(mytmpdir) + /* the temp directory name */ + 1 + /* the directory sep. */ + strlen(name) + /* the file name */ + 1 /* the \0 termination */ + ; + + tmpfile = (char *) malloc(sizeof(char) * len); + + *tmpfile = '\0'; + (void) strcat(tmpfile, mytmpdir); + (void) strcat(tmpfile, PCB_DIR_SEPARATOR_S); + (void) strcat(tmpfile, name); + + free(mytmpdir); #undef TEMPLATE #else - /* - * tmpnam() uses a static buffer so strdup() the result right away - * in case someone decides to create multiple temp names. - */ - tmpfile = strdup (tmpnam (NULL)); + /* + * tmpnam() uses a static buffer so strdup() the result right away + * in case someone decides to create multiple temp names. + */ + tmpfile = strdup(tmpnam(NULL)); #ifdef __WIN32__ - { - /* Guile doesn't like \ separators */ - char *c; - for (c = tmpfile; *c; c++) - if (*c == '\\') - *c = '/'; - } + { + /* Guile doesn't like \ separators */ + char *c; + for (c = tmpfile; *c; c++) + if (*c == '\\') + *c = '/'; + } #endif #endif - return tmpfile; + return tmpfile; } /* ---------------------------------------------------------------- */ @@ -7725,80 +6960,78 @@ * lives in a temporary directory and we need to remove that directory * too. */ -static int -tempfile_unlink (char * name) +static int tempfile_unlink(char *name) { #ifdef DEBUG - /* SDB says: Want to keep old temp files for examiniation when debugging */ - return 0; + /* SDB says: Want to keep old temp files for examiniation when debugging */ + return 0; #endif #ifdef HAVE_MKDTEMP - int e, rc2 = 0; - char *dname; + int e, rc2 = 0; + char *dname; - unlink (name); - /* it is possible that the file was never created so it is OK if the - unlink fails */ + unlink(name); + /* it is possible that the file was never created so it is OK if the + unlink fails */ - /* now figure out the directory name to remove */ - e = strlen (name) - 1; - while (e > 0 && name[e] != PCB_DIR_SEPARATOR_C) {e--;} - - dname = strdup (name); - dname[e] = '\0'; + /* now figure out the directory name to remove */ + e = strlen(name) - 1; + while (e > 0 && name[e] != PCB_DIR_SEPARATOR_C) { + e--; + } - /* - * at this point, e *should* point to the end of the directory part - * but lets make sure. - */ - if (e > 0) { - rc2 = rmdir (dname); - if (rc2 != 0) { - perror (dname); - } + dname = strdup(name); + dname[e] = '\0'; - } else { - fprintf (stderr, _("%s(): Unable to determine temp directory name from the temp file\n"), - __FUNCTION__); - fprintf (stderr, "%s(): \"%s\"\n", - __FUNCTION__, name); - rc2 = -1; - } + /* + * at this point, e *should* point to the end of the directory part + * but lets make sure. + */ + if (e > 0) { + rc2 = rmdir(dname); + if (rc2 != 0) { + perror(dname); + } - /* name was allocated with malloc */ - free (dname); - free (name); + } + else { + fprintf(stderr, _("%s(): Unable to determine temp directory name from the temp file\n"), __FUNCTION__); + fprintf(stderr, "%s(): \"%s\"\n", __FUNCTION__, name); + rc2 = -1; + } - /* - * FIXME - should also return -1 if the temp file exists and was not - * removed. - */ - if (rc2 != 0) { - return -1; - } + /* name was allocated with malloc */ + free(dname); + free(name); + /* + * FIXME - should also return -1 if the temp file exists and was not + * removed. + */ + if (rc2 != 0) { + return -1; + } + #else - int rc = unlink (name); + int rc = unlink(name); - if (rc != 0) { - fprintf (stderr, _("Failed to unlink \"%s\"\n"), name); - free (name); - return rc; - } - free (name); + if (rc != 0) { + fprintf(stderr, _("Failed to unlink \"%s\"\n"), name); + free(name); + return rc; + } + free(name); #endif - return 0; + return 0; } /* ---------------------------------------------------------------- */ static const char import_syntax[] = - "Import()\n" - "Import([gnetlist|make[,source,source,...]])\n" - "Import(setnewpoint[,(mark|center|X,Y)])\n" - "Import(setdisperse,D,units)\n"; + "Import()\n" + "Import([gnetlist|make[,source,source,...]])\n" "Import(setnewpoint[,(mark|center|X,Y)])\n" "Import(setdisperse,D,units)\n"; static const char import_help[] = "Import schematics."; @@ -7911,304 +7144,277 @@ %end-doc */ -static int -ActionImport (int argc, char **argv, Coord x, Coord y) +static int ActionImport(int argc, char **argv, Coord x, Coord y) { - char *mode; - char **sources = NULL; - int nsources = 0; + char *mode; + char **sources = NULL; + int nsources = 0; #ifdef DEBUG - printf("ActionImport: =========== Entering ActionImport ============\n"); + printf("ActionImport: =========== Entering ActionImport ============\n"); #endif - mode = ARG (0); + mode = ARG(0); - if (mode && strcasecmp (mode, "setdisperse") == 0) - { - char *ds, *units; - char buf[50]; + if (mode && strcasecmp(mode, "setdisperse") == 0) { + char *ds, *units; + char buf[50]; - ds = ARG (1); - units = ARG (2); - if (!ds) - { - const char *as = AttributeGet (PCB, "import::disperse"); - ds = gui->prompt_for(_("Enter dispersion:"), as ? as : "0"); + ds = ARG(1); + units = ARG(2); + if (!ds) { + const char *as = AttributeGet(PCB, "import::disperse"); + ds = gui->prompt_for(_("Enter dispersion:"), as ? as : "0"); + } + if (units) { + sprintf(buf, "%s%s", ds, units); + AttributePut(PCB, "import::disperse", buf); + } + else + AttributePut(PCB, "import::disperse", ds); + if (ARG(1) == NULL) + free(ds); + return 0; } - if (units) - { - sprintf(buf, "%s%s", ds, units); - AttributePut (PCB, "import::disperse", buf); - } - else - AttributePut (PCB, "import::disperse", ds); - if (ARG (1) == NULL) - free (ds); - return 0; - } - if (mode && strcasecmp (mode, "setnewpoint") == 0) - { - const char *xs, *ys, *units; - Coord x, y; - char buf[50]; + if (mode && strcasecmp(mode, "setnewpoint") == 0) { + const char *xs, *ys, *units; + Coord x, y; + char buf[50]; - xs = ARG (1); - ys = ARG (2); - units = ARG (3); + xs = ARG(1); + ys = ARG(2); + units = ARG(3); - if (!xs) - { - gui->get_coords (_("Click on a location"), &x, &y); + if (!xs) { + gui->get_coords(_("Click on a location"), &x, &y); + } + else if (strcasecmp(xs, "center") == 0) { + AttributeRemove(PCB, "import::newX"); + AttributeRemove(PCB, "import::newY"); + return 0; + } + else if (strcasecmp(xs, "mark") == 0) { + if (Marked.status) { + x = Marked.X; + y = Marked.Y; + } + } + else if (ys) { + x = GetValue(xs, units, NULL); + y = GetValue(ys, units, NULL); + } + else { + Message(_("Bad syntax for Import(setnewpoint)")); + return 1; + } + + pcb_sprintf(buf, "%$ms", x); + AttributePut(PCB, "import::newX", buf); + pcb_sprintf(buf, "%$ms", y); + AttributePut(PCB, "import::newY", buf); + return 0; } - else if (strcasecmp (xs, "center") == 0) - { - AttributeRemove (PCB, "import::newX"); - AttributeRemove (PCB, "import::newY"); - return 0; - } - else if (strcasecmp (xs, "mark") == 0) - { - if (Marked.status) - { - x = Marked.X; - y = Marked.Y; - } - } - else if (ys) - { - x = GetValue (xs, units, NULL); - y = GetValue (ys, units, NULL); - } - else - { - Message (_("Bad syntax for Import(setnewpoint)")); - return 1; - } - pcb_sprintf (buf, "%$ms", x); - AttributePut (PCB, "import::newX", buf); - pcb_sprintf (buf, "%$ms", y); - AttributePut (PCB, "import::newY", buf); - return 0; - } + if (!mode) + mode = AttributeGet(PCB, "import::mode"); + if (!mode) + mode = "gnetlist"; - if (! mode) - mode = AttributeGet (PCB, "import::mode"); - if (! mode) - mode = "gnetlist"; + if (argc > 1) { + sources = argv + 1; + nsources = argc - 1; + } - if (argc > 1) - { - sources = argv + 1; - nsources = argc - 1; - } + if (!sources) { + char sname[40]; + char *src; - if (! sources) - { - char sname[40]; - char *src; + nsources = -1; + do { + nsources++; + sprintf(sname, "import::src%d", nsources); + src = AttributeGet(PCB, sname); + } while (src); - nsources = -1; - do { - nsources ++; - sprintf(sname, "import::src%d", nsources); - src = AttributeGet (PCB, sname); - } while (src); - - if (nsources > 0) - { - sources = (char **) malloc ((nsources + 1) * sizeof (char *)); - nsources = -1; - do { - nsources ++; - sprintf(sname, "import::src%d", nsources); - src = AttributeGet (PCB, sname); - sources[nsources] = src; - } while (src); + if (nsources > 0) { + sources = (char **) malloc((nsources + 1) * sizeof(char *)); + nsources = -1; + do { + nsources++; + sprintf(sname, "import::src%d", nsources); + src = AttributeGet(PCB, sname); + sources[nsources] = src; + } while (src); + } } - } - if (! sources) - { - /* Replace .pcb with .sch and hope for the best. */ - char *pcbname = PCB->Filename; - char *schname; - char *dot, *slash, *bslash; + if (!sources) { + /* Replace .pcb with .sch and hope for the best. */ + char *pcbname = PCB->Filename; + char *schname; + char *dot, *slash, *bslash; - if (!pcbname) - return hid_action("ImportGUI"); + if (!pcbname) + return hid_action("ImportGUI"); - schname = (char *) malloc (strlen(pcbname) + 5); - strcpy (schname, pcbname); - dot = strchr (schname, '.'); - slash = strchr (schname, '/'); - bslash = strchr (schname, '\\'); - if (dot && slash && dot < slash) - dot = NULL; - if (dot && bslash && dot < bslash) - dot = NULL; - if (dot) - *dot = 0; - strcat (schname, ".sch"); + schname = (char *) malloc(strlen(pcbname) + 5); + strcpy(schname, pcbname); + dot = strchr(schname, '.'); + slash = strchr(schname, '/'); + bslash = strchr(schname, '\\'); + if (dot && slash && dot < slash) + dot = NULL; + if (dot && bslash && dot < bslash) + dot = NULL; + if (dot) + *dot = 0; + strcat(schname, ".sch"); - if (access (schname, F_OK)) - return hid_action("ImportGUI"); + if (access(schname, F_OK)) + return hid_action("ImportGUI"); - sources = (char **) malloc (2 * sizeof (char *)); - sources[0] = schname; - sources[1] = NULL; - nsources = 1; - } + sources = (char **) malloc(2 * sizeof(char *)); + sources[0] = schname; + sources[1] = NULL; + nsources = 1; + } - if (strcasecmp (mode, "gnetlist") == 0) - { - char *tmpfile = tempfile_name_new ("gnetlist_output"); - char **cmd; - int i; + if (strcasecmp(mode, "gnetlist") == 0) { + char *tmpfile = tempfile_name_new("gnetlist_output"); + char **cmd; + int i; - if (tmpfile == NULL) { - Message (_("Could not create temp file")); - return 1; - } + if (tmpfile == NULL) { + Message(_("Could not create temp file")); + return 1; + } - cmd = (char **) malloc ((7 + nsources) * sizeof (char *)); - cmd[0] = Settings.GnetlistProgram; - cmd[1] = "-g"; - cmd[2] = "pcbfwd"; - cmd[3] = "-o"; - cmd[4] = tmpfile; - cmd[5] = "--"; - for (i=0; iFilename, NULL); + cmd[3] = srclist; + cmd[4] = Concat("OUT=", tmpfile, NULL); + i = 5; + if (user_makefile) { + cmd[i++] = "-f"; + cmd[i++] = user_makefile; + } + cmd[i++] = user_target ? user_target : (char *) "pcb_import"; + cmd[i++] = NULL; - cmd[0] = tmpfile; - cmd[1] = NULL; - ActionExecuteFile (1, cmd, 0, 0); + if (pcb_spawnvp(cmd)) { + if (must_free_tmpfile) + unlink(tmpfile); + free(cmd[2]); + free(cmd[3]); + free(cmd[4]); + return 1; + } - free (cmd[2]); - free (cmd[3]); - free (cmd[4]); - if (must_free_tmpfile) - tempfile_unlink (tmpfile); - } - else - { - Message (_("Unknown import mode: %s\n"), mode); - return 1; - } + cmd[0] = tmpfile; + cmd[1] = NULL; + ActionExecuteFile(1, cmd, 0, 0); - DeleteRats (false); - AddAllRats (false, NULL); + free(cmd[2]); + free(cmd[3]); + free(cmd[4]); + if (must_free_tmpfile) + tempfile_unlink(tmpfile); + } + else { + Message(_("Unknown import mode: %s\n"), mode); + return 1; + } + DeleteRats(false); + AddAllRats(false, NULL); + #ifdef DEBUG - printf("ActionImport: =========== Leaving ActionImport ============\n"); + printf("ActionImport: =========== Leaving ActionImport ============\n"); #endif - return 0; + return 0; } /* ------------------------------------------------------------ */ -static const char attributes_syntax[] = -"Attributes(Layout|Layer|Element)\n" -"Attributes(Layer,layername)"; +static const char attributes_syntax[] = "Attributes(Layout|Layer|Element)\n" "Attributes(Layer,layername)"; static const char attributes_help[] = -"Let the user edit the attributes of the layout, current or given\n" -"layer, or selected element."; + "Let the user edit the attributes of the layout, current or given\n" "layer, or selected element."; /* %start-doc actions Attributes @@ -8218,118 +7424,102 @@ %end-doc */ -static int -ActionAttributes (int argc, char **argv, Coord x, Coord y) +static int ActionAttributes(int argc, char **argv, Coord x, Coord y) { - char *function = ARG (0); - char *layername = ARG (1); - char *buf; + char *function = ARG(0); + char *layername = ARG(1); + char *buf; - if (!function) - AFAIL (attributes); + if (!function) + AFAIL(attributes); - if (!gui->edit_attributes) - { - Message (_("This GUI doesn't support Attribute Editing\n")); - return 1; - } + if (!gui->edit_attributes) { + Message(_("This GUI doesn't support Attribute Editing\n")); + return 1; + } - switch (GetFunctionID (function)) - { - case F_Layout: - { - gui->edit_attributes("Layout Attributes", &(PCB->Attributes)); - return 0; - } + switch (GetFunctionID(function)) { + case F_Layout: + { + gui->edit_attributes("Layout Attributes", &(PCB->Attributes)); + return 0; + } - case F_Layer: - { - LayerType *layer = CURRENT; - if (layername) - { - int i; - layer = NULL; - for (i=0; iData->Layer[i].Name, layername) == 0) + case F_Layer: { - layer = & (PCB->Data->Layer[i]); - break; + LayerType *layer = CURRENT; + if (layername) { + int i; + layer = NULL; + for (i = 0; i < max_copper_layer; i++) + if (strcmp(PCB->Data->Layer[i].Name, layername) == 0) { + layer = &(PCB->Data->Layer[i]); + break; + } + if (layer == NULL) { + Message(_("No layer named %s\n"), layername); + return 1; + } + } + buf = (char *) malloc(strlen(layer->Name) + strlen("Layer X Attributes")); + sprintf(buf, "Layer %s Attributes", layer->Name); + gui->edit_attributes(buf, &(layer->Attributes)); + free(buf); + return 0; } - if (layer == NULL) - { - Message (_("No layer named %s\n"), layername); - return 1; - } - } - buf = (char *) malloc (strlen (layer->Name) + strlen ("Layer X Attributes")); - sprintf (buf, "Layer %s Attributes", layer->Name); - gui->edit_attributes(buf, &(layer->Attributes)); - free (buf); - return 0; - } - case F_Element: - { - int n_found = 0; - ElementType *e = NULL; - ELEMENT_LOOP (PCB->Data); - { - if (TEST_FLAG (SELECTEDFLAG, element)) - { - e = element; - n_found ++; - } - } - END_LOOP; - if (n_found > 1) - { - Message (_("Too many elements selected\n")); - return 1; - } - if (n_found == 0) - { - void *ptrtmp; - gui->get_coords (_("Click on an element"), &x, &y); - if ((SearchScreen - (x, y, ELEMENT_TYPE, &ptrtmp, - &ptrtmp, &ptrtmp)) != NO_TYPE) - e = (ElementTypePtr) ptrtmp; - else - { - Message (_("No element found there\n")); - return 1; - } - } + case F_Element: + { + int n_found = 0; + ElementType *e = NULL; + ELEMENT_LOOP(PCB->Data); + { + if (TEST_FLAG(SELECTEDFLAG, element)) { + e = element; + n_found++; + } + } + END_LOOP; + if (n_found > 1) { + Message(_("Too many elements selected\n")); + return 1; + } + if (n_found == 0) { + void *ptrtmp; + gui->get_coords(_("Click on an element"), &x, &y); + if ((SearchScreen(x, y, ELEMENT_TYPE, &ptrtmp, &ptrtmp, &ptrtmp)) != NO_TYPE) + e = (ElementTypePtr) ptrtmp; + else { + Message(_("No element found there\n")); + return 1; + } + } - if (NAMEONPCB_NAME(e)) - { - buf = (char *) malloc (strlen (NAMEONPCB_NAME(e)) + strlen ("Element X Attributes")); - sprintf(buf, "Element %s Attributes", NAMEONPCB_NAME(e)); - } - else - { - buf = strdup ("Unnamed Element Attributes"); - } - gui->edit_attributes(buf, &(e->Attributes)); - free (buf); - break; - } + if (NAMEONPCB_NAME(e)) { + buf = (char *) malloc(strlen(NAMEONPCB_NAME(e)) + strlen("Element X Attributes")); + sprintf(buf, "Element %s Attributes", NAMEONPCB_NAME(e)); + } + else { + buf = strdup("Unnamed Element Attributes"); + } + gui->edit_attributes(buf, &(e->Attributes)); + free(buf); + break; + } - default: - AFAIL (attributes); - } + default: + AFAIL(attributes); + } - return 0; + return 0; } /* ---------------------------------------------------------------- */ -static const char manageplugins_syntax[] = - "ManagePlugins()\n"; +static const char manageplugins_syntax[] = "ManagePlugins()\n"; static const char manageplugins_help[] = "Manage plugins dialog."; -static int -ManagePlugins (int argc, char **argv, Coord x, Coord y) +static int ManagePlugins(int argc, char **argv, Coord x, Coord y) { plugin_info_t *i; int nump = 0, numb = 0; @@ -8337,7 +7527,7 @@ memset(&str, 0, sizeof(str)); - for(i = plugins; i != NULL; i = i->next) + for (i = plugins; i != NULL; i = i->next) if (i->dynamic) nump++; else @@ -8345,7 +7535,7 @@ DSAddString(&str, "Plugins loaded:\n"); if (nump > 0) { - for(i = plugins; i != NULL; i = i->next) { + for (i = plugins; i != NULL; i = i->next) { if (i->dynamic) { DSAddCharacter(&str, ' '); DSAddString(&str, i->name); @@ -8356,11 +7546,11 @@ } } else - DSAddString (&str, " (none)\n"); + DSAddString(&str, " (none)\n"); - DSAddString (&str, "\n\nBuildins:\n"); + DSAddString(&str, "\n\nBuildins:\n"); if (numb > 0) { - for(i = plugins; i != NULL; i = i->next) { + for (i = plugins; i != NULL; i = i->next) { if (!i->dynamic) { DSAddCharacter(&str, ' '); DSAddString(&str, i->name); @@ -8369,9 +7559,9 @@ } } else - DSAddString (&str, " (none)\n"); + DSAddString(&str, " (none)\n"); - DSAddString (&str, "\n\nNOTE: this is the alpha version, can only list plugins/buildins\n"); + DSAddString(&str, "\n\nNOTE: this is the alpha version, can only list plugins/buildins\n"); gui->report_dialog("Manage plugins", str.Data); free(str.Data); return 0; @@ -8378,13 +7568,11 @@ } /* ---------------------------------------------------------------- */ -static const char replacefootprint_syntax[] = - "ReplaceFootprint()\n"; +static const char replacefootprint_syntax[] = "ReplaceFootprint()\n"; static const char replacefootprint_help[] = "Replace the footprint of the selected components with the footprint specified."; -static int -ReplaceFootprint (int argc, char **argv, Coord x, Coord y) +static int ReplaceFootprint(int argc, char **argv, Coord x, Coord y) { char *a[4]; char *fpname; @@ -8391,10 +7579,10 @@ int found = 0; /* check if we have elements selected and quit if not */ - ELEMENT_LOOP (PCB->Data); + ELEMENT_LOOP(PCB->Data); { - if (TEST_FLAG (SELECTEDFLAG, element)) { - found =1; + if (TEST_FLAG(SELECTEDFLAG, element)) { + found = 1; break; } } @@ -8407,7 +7595,7 @@ /* fetch the name of the new footprint */ if (argc == 0) { - fpname = gui->prompt_for ("Footprint name", ""); + fpname = gui->prompt_for("Footprint name", ""); if (fpname == NULL) { Message("No footprint name supplied\n"); return 1; @@ -8426,9 +7614,9 @@ /* action: replace selected elements */ - ELEMENT_LOOP (PCB->Data); + ELEMENT_LOOP(PCB->Data); { - if (TEST_FLAG (SELECTEDFLAG, element)) { + if (TEST_FLAG(SELECTEDFLAG, element)) { a[0] = fpname; a[1] = element->Name[1].TextString; a[2] = element->Name[2].TextString; @@ -8448,212 +7636,211 @@ /* --------------------------------------------------------------------------- */ HID_Action action_action_list[] = { - {"AddRats", 0, ActionAddRats, - addrats_help, addrats_syntax} - , - {"Attributes", 0, ActionAttributes, - attributes_help, attributes_syntax} - , - {"Atomic", 0, ActionAtomic, - atomic_help, atomic_syntax} - , - {"AutoPlaceSelected", 0, ActionAutoPlaceSelected, - autoplace_help, autoplace_syntax} - , - {"AutoRoute", 0, ActionAutoRoute, - autoroute_help, autoroute_syntax} - , - {"ChangeClearSize", 0, ActionChangeClearSize, - changeclearsize_help, changeclearsize_syntax} - , - {"ChangeDrillSize", 0, ActionChange2ndSize, - changedrillsize_help, changedrillsize_syntax} - , - {"ChangeHole", 0, ActionChangeHole, - changehold_help, changehold_syntax} - , - {"ChangeJoin", 0, ActionChangeJoin, - changejoin_help, changejoin_syntax} - , - {"ChangeName", 0, ActionChangeName, - changename_help, changename_syntax} - , - {"ChangePaste", 0, ActionChangePaste, - changepaste_help, changepaste_syntax} - , - {"ChangePinName", 0, ActionChangePinName, - changepinname_help, changepinname_syntax} - , - {"ChangeSize", 0, ActionChangeSize, - changesize_help, changesize_syntax} - , - {"ChangeSizes", 0, ActionChangeSizes, - changesizes_help, changesizes_syntax} - , - {"ChangeNonetlist", 0, ActionChangeNonetlist, - changenonetlist_help, changenonetlist_syntax} - , - {"ChangeSquare", 0, ActionChangeSquare, - changesquare_help, changesquare_syntax} - , - {"ChangeOctagon", 0, ActionChangeOctagon, - changeoctagon_help, changeoctagon_syntax} - , - {"ClearSquare", 0, ActionClearSquare, - clearsquare_help, clearsquare_syntax} - , - {"ClearOctagon", 0, ActionClearOctagon, - clearoctagon_help, clearoctagon_syntax} - , - {"Connection", 0, ActionConnection, - connection_help, connection_syntax} - , - {"Delete", 0, ActionDelete, - delete_help, delete_syntax} - , - {"DeleteRats", 0, ActionDeleteRats, - deleterats_help, deleterats_syntax} - , - {"DisperseElements", 0, ActionDisperseElements, - disperseelements_help, disperseelements_syntax} - , - {"Display", 0, ActionDisplay, - display_help, display_syntax} - , - {"DRC", 0, ActionDRCheck, - drc_help, drc_syntax} - , - {"CycleDrag", 0, CycleDrag, - cycledrag_help, cycledrag_syntax} - , - {"DumpLibrary", 0, ActionDumpLibrary, - dumplibrary_help, dumplibrary_syntax} - , - {"ExecuteFile", 0, ActionExecuteFile, - executefile_help, executefile_syntax} - , - {"Flip", N_("Click on Object or Flip Point"), ActionFlip, - flip_help, flip_syntax} - , - {"LoadFrom", 0, ActionLoadFrom, - loadfrom_help, loadfrom_syntax} - , - {"MarkCrosshair", 0, ActionMarkCrosshair, - markcrosshair_help, markcrosshair_syntax} - , - {"Message", 0, ActionMessage, - message_help, message_syntax} - , - {"MinMaskGap", 0, ActionMinMaskGap, - minmaskgap_help, minmaskgap_syntax} - , - {"MinClearGap", 0, ActionMinClearGap, - mincleargap_help, mincleargap_syntax} - , - {"Mode", 0, ActionMode, - mode_help, mode_syntax} - , - {"MorphPolygon", 0, ActionMorphPolygon, - morphpolygon_help, morphpolygon_syntax} - , - {"PasteBuffer", 0, ActionPasteBuffer, - pastebuffer_help, pastebuffer_syntax} - , - {"Quit", 0, ActionQuit, - quit_help, quit_syntax} - , - {"RemoveSelected", 0, ActionRemoveSelected, - removeselected_help, removeselected_syntax} - , + {"AddRats", 0, ActionAddRats, + addrats_help, addrats_syntax} + , + {"Attributes", 0, ActionAttributes, + attributes_help, attributes_syntax} + , + {"Atomic", 0, ActionAtomic, + atomic_help, atomic_syntax} + , + {"AutoPlaceSelected", 0, ActionAutoPlaceSelected, + autoplace_help, autoplace_syntax} + , + {"AutoRoute", 0, ActionAutoRoute, + autoroute_help, autoroute_syntax} + , + {"ChangeClearSize", 0, ActionChangeClearSize, + changeclearsize_help, changeclearsize_syntax} + , + {"ChangeDrillSize", 0, ActionChange2ndSize, + changedrillsize_help, changedrillsize_syntax} + , + {"ChangeHole", 0, ActionChangeHole, + changehold_help, changehold_syntax} + , + {"ChangeJoin", 0, ActionChangeJoin, + changejoin_help, changejoin_syntax} + , + {"ChangeName", 0, ActionChangeName, + changename_help, changename_syntax} + , + {"ChangePaste", 0, ActionChangePaste, + changepaste_help, changepaste_syntax} + , + {"ChangePinName", 0, ActionChangePinName, + changepinname_help, changepinname_syntax} + , + {"ChangeSize", 0, ActionChangeSize, + changesize_help, changesize_syntax} + , + {"ChangeSizes", 0, ActionChangeSizes, + changesizes_help, changesizes_syntax} + , + {"ChangeNonetlist", 0, ActionChangeNonetlist, + changenonetlist_help, changenonetlist_syntax} + , + {"ChangeSquare", 0, ActionChangeSquare, + changesquare_help, changesquare_syntax} + , + {"ChangeOctagon", 0, ActionChangeOctagon, + changeoctagon_help, changeoctagon_syntax} + , + {"ClearSquare", 0, ActionClearSquare, + clearsquare_help, clearsquare_syntax} + , + {"ClearOctagon", 0, ActionClearOctagon, + clearoctagon_help, clearoctagon_syntax} + , + {"Connection", 0, ActionConnection, + connection_help, connection_syntax} + , + {"Delete", 0, ActionDelete, + delete_help, delete_syntax} + , + {"DeleteRats", 0, ActionDeleteRats, + deleterats_help, deleterats_syntax} + , + {"DisperseElements", 0, ActionDisperseElements, + disperseelements_help, disperseelements_syntax} + , + {"Display", 0, ActionDisplay, + display_help, display_syntax} + , + {"DRC", 0, ActionDRCheck, + drc_help, drc_syntax} + , + {"CycleDrag", 0, CycleDrag, + cycledrag_help, cycledrag_syntax} + , + {"DumpLibrary", 0, ActionDumpLibrary, + dumplibrary_help, dumplibrary_syntax} + , + {"ExecuteFile", 0, ActionExecuteFile, + executefile_help, executefile_syntax} + , + {"Flip", N_("Click on Object or Flip Point"), ActionFlip, + flip_help, flip_syntax} + , + {"LoadFrom", 0, ActionLoadFrom, + loadfrom_help, loadfrom_syntax} + , + {"MarkCrosshair", 0, ActionMarkCrosshair, + markcrosshair_help, markcrosshair_syntax} + , + {"Message", 0, ActionMessage, + message_help, message_syntax} + , + {"MinMaskGap", 0, ActionMinMaskGap, + minmaskgap_help, minmaskgap_syntax} + , + {"MinClearGap", 0, ActionMinClearGap, + mincleargap_help, mincleargap_syntax} + , + {"Mode", 0, ActionMode, + mode_help, mode_syntax} + , + {"MorphPolygon", 0, ActionMorphPolygon, + morphpolygon_help, morphpolygon_syntax} + , + {"PasteBuffer", 0, ActionPasteBuffer, + pastebuffer_help, pastebuffer_syntax} + , + {"Quit", 0, ActionQuit, + quit_help, quit_syntax} + , + {"RemoveSelected", 0, ActionRemoveSelected, + removeselected_help, removeselected_syntax} + , #ifdef BA_TODO - {"Renumber", 0, ActionRenumber, - renumber_help, renumber_syntax} - , + {"Renumber", 0, ActionRenumber, + renumber_help, renumber_syntax} + , #endif - {"RipUp", 0, ActionRipUp, - ripup_help, ripup_syntax} - , - {"Select", 0, ActionSelect, - select_help, select_syntax} - , - {"Unselect", 0, ActionUnselect, - unselect_help, unselect_syntax} - , - {"SaveSettings", 0, ActionSaveSettings, - savesettings_help, savesettings_syntax} - , - {"SaveTo", 0, ActionSaveTo, - saveto_help, saveto_syntax} - , - {"SetSquare", 0, ActionSetSquare, - setsquare_help, setsquare_syntax} - , - {"SetOctagon", 0, ActionSetOctagon, - setoctagon_help, setoctagon_syntax} - , - {"SetThermal", 0, ActionSetThermal, - setthermal_help, setthermal_syntax} - , - {"SetValue", 0, ActionSetValue, - setvalue_help, setvalue_syntax} - , - {"ToggleHideName", 0, ActionToggleHideName, - togglehidename_help, togglehidename_syntax} - , - {"Undo", 0, ActionUndo, - undo_help, undo_syntax} - , - {"Redo", 0, ActionRedo, - redo_help, redo_syntax} - , - {"SetSame", N_("Select item to use attributes from"), ActionSetSame, - setsame_help, setsame_syntax} - , - {"SetFlag", 0, ActionSetFlag, - setflag_help, setflag_syntax} - , - {"ClrFlag", 0, ActionClrFlag, - clrflag_help, clrflag_syntax} - , - {"ChangeFlag", 0, ActionChangeFlag, - changeflag_help, changeflag_syntax} - , - {"Polygon", 0, ActionPolygon, - polygon_help, polygon_syntax} - , - {"RouteStyle", 0, ActionRouteStyle, - routestyle_help, routestyle_syntax} - , - {"MoveObject", N_("Select an Object"), ActionMoveObject, - moveobject_help, moveobject_syntax} - , - {"MoveToCurrentLayer", 0, ActionMoveToCurrentLayer, - movetocurrentlayer_help, movetocurrentlayer_syntax} - , - {"New", 0, ActionNew, - new_help, new_syntax} - , - {"pscalib", 0, ActionPSCalib} - , - {"ElementList", 0, ActionElementList, - elementlist_help, elementlist_syntax} - , - {"ElementSetAttr", 0, ActionElementSetAttr, - elementsetattr_help, elementsetattr_syntax} - , - {"ExecCommand", 0, ActionExecCommand, - execcommand_help, execcommand_syntax} - , - {"Import", 0, ActionImport, - import_help, import_syntax} - , - {"ManagePlugins", 0, ManagePlugins, - manageplugins_help, manageplugins_syntax} - , - {"ReplaceFootprint", 0, ReplaceFootprint, - replacefootprint_help, replacefootprint_syntax} - , + {"RipUp", 0, ActionRipUp, + ripup_help, ripup_syntax} + , + {"Select", 0, ActionSelect, + select_help, select_syntax} + , + {"Unselect", 0, ActionUnselect, + unselect_help, unselect_syntax} + , + {"SaveSettings", 0, ActionSaveSettings, + savesettings_help, savesettings_syntax} + , + {"SaveTo", 0, ActionSaveTo, + saveto_help, saveto_syntax} + , + {"SetSquare", 0, ActionSetSquare, + setsquare_help, setsquare_syntax} + , + {"SetOctagon", 0, ActionSetOctagon, + setoctagon_help, setoctagon_syntax} + , + {"SetThermal", 0, ActionSetThermal, + setthermal_help, setthermal_syntax} + , + {"SetValue", 0, ActionSetValue, + setvalue_help, setvalue_syntax} + , + {"ToggleHideName", 0, ActionToggleHideName, + togglehidename_help, togglehidename_syntax} + , + {"Undo", 0, ActionUndo, + undo_help, undo_syntax} + , + {"Redo", 0, ActionRedo, + redo_help, redo_syntax} + , + {"SetSame", N_("Select item to use attributes from"), ActionSetSame, + setsame_help, setsame_syntax} + , + {"SetFlag", 0, ActionSetFlag, + setflag_help, setflag_syntax} + , + {"ClrFlag", 0, ActionClrFlag, + clrflag_help, clrflag_syntax} + , + {"ChangeFlag", 0, ActionChangeFlag, + changeflag_help, changeflag_syntax} + , + {"Polygon", 0, ActionPolygon, + polygon_help, polygon_syntax} + , + {"RouteStyle", 0, ActionRouteStyle, + routestyle_help, routestyle_syntax} + , + {"MoveObject", N_("Select an Object"), ActionMoveObject, + moveobject_help, moveobject_syntax} + , + {"MoveToCurrentLayer", 0, ActionMoveToCurrentLayer, + movetocurrentlayer_help, movetocurrentlayer_syntax} + , + {"New", 0, ActionNew, + new_help, new_syntax} + , + {"pscalib", 0, ActionPSCalib} + , + {"ElementList", 0, ActionElementList, + elementlist_help, elementlist_syntax} + , + {"ElementSetAttr", 0, ActionElementSetAttr, + elementsetattr_help, elementsetattr_syntax} + , + {"ExecCommand", 0, ActionExecCommand, + execcommand_help, execcommand_syntax} + , + {"Import", 0, ActionImport, + import_help, import_syntax} + , + {"ManagePlugins", 0, ManagePlugins, + manageplugins_help, manageplugins_syntax} + , + {"ReplaceFootprint", 0, ReplaceFootprint, + replacefootprint_help, replacefootprint_syntax} + , }; -REGISTER_ACTIONS (action_action_list) - +REGISTER_ACTIONS(action_action_list) Index: trunk/src/action.h =================================================================== --- trunk/src/action.h (revision 1021) +++ trunk/src/action.h (revision 1022) @@ -35,15 +35,15 @@ #define CLONE_TYPES LINE_TYPE | ARC_TYPE | VIA_TYPE | POLYGON_TYPE -void ActionAdjustStyle (char *); -void EventMoveCrosshair (int, int); +void ActionAdjustStyle(char *); +void EventMoveCrosshair(int, int); -void AdjustAttachedObjects (void); +void AdjustAttachedObjects(void); -void warpNoWhere (void); +void warpNoWhere(void); /* In gui-misc.c */ -bool ActionGetLocation (char *); -void ActionGetXY (char *); +bool ActionGetLocation(char *); +void ActionGetXY(char *); #endif Index: trunk/src/autoplace.c =================================================================== --- trunk/src/autoplace.c (revision 1021) +++ trunk/src/autoplace.c (revision 1022) @@ -65,7 +65,7 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); #define EXPANDRECTXY(r1, x1, y1, x2, y2) { \ r1->X1=MIN(r1->X1, x1); r1->Y1=MIN(r1->Y1, y1); \ @@ -76,72 +76,65 @@ /* --------------------------------------------------------------------------- * some local prototypes */ -static double ComputeCost (NetListTypePtr Nets, double T0, double T); +static double ComputeCost(NetListTypePtr Nets, double T0, double T); /* --------------------------------------------------------------------------- * some local types */ -const struct -{ - double via_cost; - double congestion_penalty; /* penalty length / unit area */ - double overlap_penalty_min; /* penalty length / unit area at start */ - double overlap_penalty_max; /* penalty length / unit area at end */ - double out_of_bounds_penalty; /* assessed for each component oob */ - double overall_area_penalty; /* penalty length / unit area */ - double matching_neighbor_bonus; /* length bonus per same-type neigh. */ - double aligned_neighbor_bonus; /* length bonus per aligned neigh. */ - double oriented_neighbor_bonus; /* length bonus per same-rot neigh. */ +const struct { + double via_cost; + double congestion_penalty; /* penalty length / unit area */ + double overlap_penalty_min; /* penalty length / unit area at start */ + double overlap_penalty_max; /* penalty length / unit area at end */ + double out_of_bounds_penalty; /* assessed for each component oob */ + double overall_area_penalty; /* penalty length / unit area */ + double matching_neighbor_bonus; /* length bonus per same-type neigh. */ + double aligned_neighbor_bonus; /* length bonus per aligned neigh. */ + double oriented_neighbor_bonus; /* length bonus per same-rot neigh. */ #if 0 - double pin_alignment_bonus; /* length bonus per exact alignment */ - double bound_alignment_bonus; /* length bonus per exact alignment */ + double pin_alignment_bonus; /* length bonus per exact alignment */ + double bound_alignment_bonus; /* length bonus per exact alignment */ #endif - double m; /* annealing stage cutoff constant */ - double gamma; /* annealing schedule constant */ - int good_ratio; /* ratio of moves to good moves for halting */ - bool fast; /* ignore SMD/pin conflicts */ - Coord large_grid_size; /* snap perturbations to this grid when T is high */ - Coord small_grid_size; /* snap to this grid when T is small. */ + double m; /* annealing stage cutoff constant */ + double gamma; /* annealing schedule constant */ + int good_ratio; /* ratio of moves to good moves for halting */ + bool fast; /* ignore SMD/pin conflicts */ + Coord large_grid_size; /* snap perturbations to this grid when T is high */ + Coord small_grid_size; /* snap to this grid when T is small. */ } -/* wire cost is manhattan distance (in mils), thus 1 inch = 1000 */ -CostParameter = +/* wire cost is manhattan distance (in mils), thus 1 inch = 1000 */ CostParameter = { - 3e3, /* via cost */ - 2e-2, /* congestion penalty */ - 1e-2, /* initial overlap penalty */ - 1e2, /* final overlap penalty */ - 1e3, /* out of bounds penalty */ - 1e0, /* penalty for total area used */ - 1e0, /* subtract 1000 from cost for every same-type neighbor */ - 1e0, /* subtract 1000 from cost for every aligned neighbor */ - 1e0, /* subtract 1000 from cost for every same-rotation neighbor */ - 20, /* move on when each module has been profitably moved 20 times */ - 0.75, /* annealing schedule constant: 0.85 */ - 40, /* halt when there are 60 times as many moves as good moves */ - false, /* don't ignore SMD/pin conflicts */ - MIL_TO_COORD (100), /* coarse grid is 100 mils */ - MIL_TO_COORD (10), /* fine grid is 10 mils */ + 3e3, /* via cost */ + 2e-2, /* congestion penalty */ + 1e-2, /* initial overlap penalty */ + 1e2, /* final overlap penalty */ + 1e3, /* out of bounds penalty */ + 1e0, /* penalty for total area used */ + 1e0, /* subtract 1000 from cost for every same-type neighbor */ + 1e0, /* subtract 1000 from cost for every aligned neighbor */ + 1e0, /* subtract 1000 from cost for every same-rotation neighbor */ + 20, /* move on when each module has been profitably moved 20 times */ + 0.75, /* annealing schedule constant: 0.85 */ + 40, /* halt when there are 60 times as many moves as good moves */ + false, /* don't ignore SMD/pin conflicts */ + MIL_TO_COORD(100), /* coarse grid is 100 mils */ + MIL_TO_COORD(10), /* fine grid is 10 mils */ }; -typedef struct -{ - ElementTypePtr *element; - Cardinal elementN; -} -ElementPtrListType; +typedef struct { + ElementTypePtr *element; + Cardinal elementN; +} ElementPtrListType; -enum ewhich - { SHIFT, ROTATE, EXCHANGE }; +enum ewhich { SHIFT, ROTATE, EXCHANGE }; -typedef struct -{ - ElementTypePtr element; - enum ewhich which; - Coord DX, DY; /* for shift */ - unsigned rotate; /* for rotate/flip */ - ElementTypePtr other; /* for exchange */ -} -PerturbationType; +typedef struct { + ElementTypePtr element; + enum ewhich which; + Coord DX, DY; /* for shift */ + unsigned rotate; /* for rotate/flip */ + ElementTypePtr other; /* for exchange */ +} PerturbationType; /* --------------------------------------------------------------------------- * some local identifiers @@ -151,80 +144,67 @@ * Update the X, Y and group position information stored in the NetList after * elements have possibly been moved, rotated, flipped, etc. */ -static void -UpdateXY (NetListTypePtr Nets) +static void UpdateXY(NetListTypePtr Nets) { - Cardinal SLayer, CLayer; - Cardinal i, j; - /* find layer groups of the component side and solder side */ - SLayer = GetLayerGroupNumberByNumber (solder_silk_layer); - CLayer = GetLayerGroupNumberByNumber (component_silk_layer); - /* update all nets */ - for (i = 0; i < Nets->NetN; i++) - { - for (j = 0; j < Nets->Net[i].ConnectionN; j++) - { - ConnectionTypePtr c = &(Nets->Net[i].Connection[j]); - switch (c->type) - { - case PAD_TYPE: - c->group = TEST_FLAG (ONSOLDERFLAG, - (ElementTypePtr) c->ptr1) - ? SLayer : CLayer; - c->X = ((PadTypePtr) c->ptr2)->Point1.X; - c->Y = ((PadTypePtr) c->ptr2)->Point1.Y; - break; - case PIN_TYPE: - c->group = SLayer; /* any layer will do */ - c->X = ((PinTypePtr) c->ptr2)->X; - c->Y = ((PinTypePtr) c->ptr2)->Y; - break; - default: - Message ("Odd connection type encountered in " "UpdateXY"); - break; - } + Cardinal SLayer, CLayer; + Cardinal i, j; + /* find layer groups of the component side and solder side */ + SLayer = GetLayerGroupNumberByNumber(solder_silk_layer); + CLayer = GetLayerGroupNumberByNumber(component_silk_layer); + /* update all nets */ + for (i = 0; i < Nets->NetN; i++) { + for (j = 0; j < Nets->Net[i].ConnectionN; j++) { + ConnectionTypePtr c = &(Nets->Net[i].Connection[j]); + switch (c->type) { + case PAD_TYPE: + c->group = TEST_FLAG(ONSOLDERFLAG, (ElementTypePtr) c->ptr1) + ? SLayer : CLayer; + c->X = ((PadTypePtr) c->ptr2)->Point1.X; + c->Y = ((PadTypePtr) c->ptr2)->Point1.Y; + break; + case PIN_TYPE: + c->group = SLayer; /* any layer will do */ + c->X = ((PinTypePtr) c->ptr2)->X; + c->Y = ((PinTypePtr) c->ptr2)->Y; + break; + default: + Message("Odd connection type encountered in " "UpdateXY"); + break; + } + } } - } } /* --------------------------------------------------------------------------- * Create a list of selected elements. */ -static PointerListType -collectSelectedElements () +static PointerListType collectSelectedElements() { - PointerListType list = { 0, 0, NULL }; - ELEMENT_LOOP (PCB->Data); - { - if (TEST_FLAG (SELECTEDFLAG, element)) - { - ElementTypePtr *epp = (ElementTypePtr *) GetPointerMemory (&list); - *epp = element; - } - } - END_LOOP; - return list; + PointerListType list = { 0, 0, NULL }; + ELEMENT_LOOP(PCB->Data); + { + if (TEST_FLAG(SELECTEDFLAG, element)) { + ElementTypePtr *epp = (ElementTypePtr *) GetPointerMemory(&list); + *epp = element; + } + } + END_LOOP; + return list; } -#if 0 /* only for debugging box lists */ +#if 0 /* only for debugging box lists */ #include "create.h" /* makes a line on the solder layer surrounding all boxes in blist */ -static void -showboxes (BoxListTypePtr blist) +static void showboxes(BoxListTypePtr blist) { - Cardinal i; - LayerTypePtr SLayer = &(PCB->Data->Layer[solder_silk_layer]); - for (i = 0; i < blist->BoxN; i++) - { - CreateNewLineOnLayer (SLayer, blist->Box[i].X1, blist->Box[i].Y1, - blist->Box[i].X2, blist->Box[i].Y1, 1, 1, 0); - CreateNewLineOnLayer (SLayer, blist->Box[i].X1, blist->Box[i].Y2, - blist->Box[i].X2, blist->Box[i].Y2, 1, 1, 0); - CreateNewLineOnLayer (SLayer, blist->Box[i].X1, blist->Box[i].Y1, - blist->Box[i].X1, blist->Box[i].Y2, 1, 1, 0); - CreateNewLineOnLayer (SLayer, blist->Box[i].X2, blist->Box[i].Y1, - blist->Box[i].X2, blist->Box[i].Y2, 1, 1, 0); - } + Cardinal i; + LayerTypePtr SLayer = &(PCB->Data->Layer[solder_silk_layer]); + for (i = 0; i < blist->BoxN; i++) { + CreateNewLineOnLayer(SLayer, blist->Box[i].X1, blist->Box[i].Y1, blist->Box[i].X2, blist->Box[i].Y1, 1, 1, 0); + CreateNewLineOnLayer(SLayer, blist->Box[i].X1, blist->Box[i].Y2, blist->Box[i].X2, blist->Box[i].Y2, 1, 1, 0); + CreateNewLineOnLayer(SLayer, blist->Box[i].X1, blist->Box[i].Y1, blist->Box[i].X1, blist->Box[i].Y2, 1, 1, 0); + CreateNewLineOnLayer(SLayer, blist->Box[i].X2, blist->Box[i].Y1, blist->Box[i].X2, blist->Box[i].Y2, 1, 1, 0); + } } #endif @@ -234,11 +214,10 @@ * emanating from that side. */ /*------ r_find_neighbor ------*/ -struct r_neighbor_info -{ - const BoxType *neighbor; - BoxType trap; - direction_t search_dir; +struct r_neighbor_info { + const BoxType *neighbor; + BoxType trap; + direction_t search_dir; }; #define ROTATEBOX(box) { Coord t;\ t = (box).X1; (box).X1 = - (box).Y1; (box).Y1 = t;\ @@ -246,73 +225,66 @@ t = (box).X1; (box).X1 = (box).X2; (box).X2 = t;\ } /* helper methods for __r_find_neighbor */ -static int -__r_find_neighbor_reg_in_sea (const BoxType * region, void *cl) +static int __r_find_neighbor_reg_in_sea(const BoxType * region, void *cl) { - struct r_neighbor_info *ni = (struct r_neighbor_info *) cl; - BoxType query = *region; - ROTATEBOX_TO_NORTH (query, ni->search_dir); - /* ______________ __ trap.y1 __ - * \ / |__| query rect. - * \__________/ __ trap.y2 - * | | - * trap.x1 trap.x2 sides at 45-degree angle - */ - return (query.Y2 > ni->trap.Y1) && (query.Y1 < ni->trap.Y2) && - (query.X2 + ni->trap.Y2 > ni->trap.X1 + query.Y1) && - (query.X1 + query.Y1 < ni->trap.X2 + ni->trap.Y2); + struct r_neighbor_info *ni = (struct r_neighbor_info *) cl; + BoxType query = *region; + ROTATEBOX_TO_NORTH(query, ni->search_dir); + /* ______________ __ trap.y1 __ + * \ / |__| query rect. + * \__________/ __ trap.y2 + * | | + * trap.x1 trap.x2 sides at 45-degree angle + */ + return (query.Y2 > ni->trap.Y1) && (query.Y1 < ni->trap.Y2) && + (query.X2 + ni->trap.Y2 > ni->trap.X1 + query.Y1) && (query.X1 + query.Y1 < ni->trap.X2 + ni->trap.Y2); } -static int -__r_find_neighbor_rect_in_reg (const BoxType * box, void *cl) + +static int __r_find_neighbor_rect_in_reg(const BoxType * box, void *cl) { - struct r_neighbor_info *ni = (struct r_neighbor_info *) cl; - BoxType query = *box; - int r; - ROTATEBOX_TO_NORTH (query, ni->search_dir); - /* ______________ __ trap.y1 __ - * \ / |__| query rect. - * \__________/ __ trap.y2 - * | | - * trap.x1 trap.x2 sides at 45-degree angle - */ - r = (query.Y2 > ni->trap.Y1) && (query.Y1 < ni->trap.Y2) && - (query.X2 + ni->trap.Y2 > ni->trap.X1 + query.Y1) && - (query.X1 + query.Y1 < ni->trap.X2 + ni->trap.Y2); - r = r && (query.Y2 <= ni->trap.Y2); - if (r) - { - ni->trap.Y1 = query.Y2; - ni->neighbor = box; - } - return r; + struct r_neighbor_info *ni = (struct r_neighbor_info *) cl; + BoxType query = *box; + int r; + ROTATEBOX_TO_NORTH(query, ni->search_dir); + /* ______________ __ trap.y1 __ + * \ / |__| query rect. + * \__________/ __ trap.y2 + * | | + * trap.x1 trap.x2 sides at 45-degree angle + */ + r = (query.Y2 > ni->trap.Y1) && (query.Y1 < ni->trap.Y2) && + (query.X2 + ni->trap.Y2 > ni->trap.X1 + query.Y1) && (query.X1 + query.Y1 < ni->trap.X2 + ni->trap.Y2); + r = r && (query.Y2 <= ni->trap.Y2); + if (r) { + ni->trap.Y1 = query.Y2; + ni->neighbor = box; + } + return r; } /* main r_find_neighbor routine. Returns NULL if no neighbor in the * requested direction. */ -static const BoxType * -r_find_neighbor (rtree_t * rtree, const BoxType * box, - direction_t search_direction) +static const BoxType *r_find_neighbor(rtree_t * rtree, const BoxType * box, direction_t search_direction) { - struct r_neighbor_info ni; - BoxType bbox; + struct r_neighbor_info ni; + BoxType bbox; - ni.neighbor = NULL; - ni.trap = *box; - ni.search_dir = search_direction; + ni.neighbor = NULL; + ni.trap = *box; + ni.search_dir = search_direction; - bbox.X1 = bbox.Y1 = 0; - bbox.X2 = PCB->MaxWidth; - bbox.Y2 = PCB->MaxHeight; - /* rotate so that we can use the 'north' case for everything */ - ROTATEBOX_TO_NORTH (bbox, search_direction); - ROTATEBOX_TO_NORTH (ni.trap, search_direction); - /* shift Y's such that trap contains full bounds of trapezoid */ - ni.trap.Y2 = ni.trap.Y1; - ni.trap.Y1 = bbox.Y1; - /* do the search! */ - r_search (rtree, NULL, - __r_find_neighbor_reg_in_sea, __r_find_neighbor_rect_in_reg, &ni); - return ni.neighbor; + bbox.X1 = bbox.Y1 = 0; + bbox.X2 = PCB->MaxWidth; + bbox.Y2 = PCB->MaxHeight; + /* rotate so that we can use the 'north' case for everything */ + ROTATEBOX_TO_NORTH(bbox, search_direction); + ROTATEBOX_TO_NORTH(ni.trap, search_direction); + /* shift Y's such that trap contains full bounds of trapezoid */ + ni.trap.Y2 = ni.trap.Y1; + ni.trap.Y1 = bbox.Y1; + /* do the search! */ + r_search(rtree, NULL, __r_find_neighbor_reg_in_sea, __r_find_neighbor_rect_in_reg, &ni); + return ni.neighbor; } /* --------------------------------------------------------------------------- @@ -324,286 +296,252 @@ * "Placement and Routing of Electronic Modules" edited by Michael Pecht * Marcel Dekker, Inc. 1993. ISBN: 0-8247-8916-4 TK7868.P7.P57 1993 */ -static double -ComputeCost (NetListTypePtr Nets, double T0, double T) +static double ComputeCost(NetListTypePtr Nets, double T0, double T) { - double W = 0; /* wire cost */ - double delta1 = 0; /* wire congestion penalty function */ - double delta2 = 0; /* module overlap penalty function */ - double delta3 = 0; /* out of bounds penalty */ - double delta4 = 0; /* alignment bonus */ - double delta5 = 0; /* total area penalty */ - Cardinal i, j; - Coord minx, maxx, miny, maxy; - bool allpads, allsameside; - Cardinal thegroup; - BoxListType bounds = { 0, 0, NULL }; /* save bounding rectangles here */ - BoxListType solderside = { 0, 0, NULL }; /* solder side component bounds */ - BoxListType componentside = { 0, 0, NULL }; /* component side bounds */ - /* make sure the NetList have the proper updated X and Y coords */ - UpdateXY (Nets); - /* wire length term. approximated by half-perimeter of minimum - * rectangle enclosing the net. Note that we penalize vias in - * all-SMD nets by making the rectangle a cube and weighting - * the "layer height" of the net. */ - for (i = 0; i < Nets->NetN; i++) - { - NetTypePtr n = &Nets->Net[i]; - if (n->ConnectionN < 2) - continue; /* no cost to go nowhere */ - minx = maxx = n->Connection[0].X; - miny = maxy = n->Connection[0].Y; - thegroup = n->Connection[0].group; - allpads = (n->Connection[0].type == PAD_TYPE); - allsameside = true; - for (j = 1; j < n->ConnectionN; j++) - { - ConnectionTypePtr c = &(n->Connection[j]); - MAKEMIN (minx, c->X); - MAKEMAX (maxx, c->X); - MAKEMIN (miny, c->Y); - MAKEMAX (maxy, c->Y); - if (c->type != PAD_TYPE) - allpads = false; - if (c->group != thegroup) - allsameside = false; + double W = 0; /* wire cost */ + double delta1 = 0; /* wire congestion penalty function */ + double delta2 = 0; /* module overlap penalty function */ + double delta3 = 0; /* out of bounds penalty */ + double delta4 = 0; /* alignment bonus */ + double delta5 = 0; /* total area penalty */ + Cardinal i, j; + Coord minx, maxx, miny, maxy; + bool allpads, allsameside; + Cardinal thegroup; + BoxListType bounds = { 0, 0, NULL }; /* save bounding rectangles here */ + BoxListType solderside = { 0, 0, NULL }; /* solder side component bounds */ + BoxListType componentside = { 0, 0, NULL }; /* component side bounds */ + /* make sure the NetList have the proper updated X and Y coords */ + UpdateXY(Nets); + /* wire length term. approximated by half-perimeter of minimum + * rectangle enclosing the net. Note that we penalize vias in + * all-SMD nets by making the rectangle a cube and weighting + * the "layer height" of the net. */ + for (i = 0; i < Nets->NetN; i++) { + NetTypePtr n = &Nets->Net[i]; + if (n->ConnectionN < 2) + continue; /* no cost to go nowhere */ + minx = maxx = n->Connection[0].X; + miny = maxy = n->Connection[0].Y; + thegroup = n->Connection[0].group; + allpads = (n->Connection[0].type == PAD_TYPE); + allsameside = true; + for (j = 1; j < n->ConnectionN; j++) { + ConnectionTypePtr c = &(n->Connection[j]); + MAKEMIN(minx, c->X); + MAKEMAX(maxx, c->X); + MAKEMIN(miny, c->Y); + MAKEMAX(maxy, c->Y); + if (c->type != PAD_TYPE) + allpads = false; + if (c->group != thegroup) + allsameside = false; + } + /* save bounding rectangle */ + { + BoxTypePtr box = GetBoxMemory(&bounds); + box->X1 = minx; + box->Y1 = miny; + box->X2 = maxx; + box->Y2 = maxy; + } + /* okay, add half-perimeter to cost! */ + W += COORD_TO_MIL(maxx - minx) + COORD_TO_MIL(maxy - miny) + ((allpads && !allsameside) ? CostParameter.via_cost : 0); } - /* save bounding rectangle */ - { - BoxTypePtr box = GetBoxMemory (&bounds); - box->X1 = minx; - box->Y1 = miny; - box->X2 = maxx; - box->Y2 = maxy; - } - /* okay, add half-perimeter to cost! */ - W += COORD_TO_MIL(maxx - minx) + COORD_TO_MIL(maxy - miny) + - ((allpads && !allsameside) ? CostParameter.via_cost : 0); - } - /* now compute penalty function Wc which is proportional to - * amount of overlap and congestion. */ - /* delta1 is congestion penalty function */ - delta1 = CostParameter.congestion_penalty * - sqrt (fabs (ComputeIntersectionArea (&bounds))); + /* now compute penalty function Wc which is proportional to + * amount of overlap and congestion. */ + /* delta1 is congestion penalty function */ + delta1 = CostParameter.congestion_penalty * sqrt(fabs(ComputeIntersectionArea(&bounds))); #if 0 - printf ("Wire Congestion Area: %f\n", ComputeIntersectionArea (&bounds)); + printf("Wire Congestion Area: %f\n", ComputeIntersectionArea(&bounds)); #endif - /* free bounding rectangles */ - FreeBoxListMemory (&bounds); - /* now collect module areas (bounding rect of pins/pads) */ - /* two lists for solder side / component side. */ + /* free bounding rectangles */ + FreeBoxListMemory(&bounds); + /* now collect module areas (bounding rect of pins/pads) */ + /* two lists for solder side / component side. */ - ELEMENT_LOOP (PCB->Data); - { - BoxListTypePtr thisside; - BoxListTypePtr otherside; - BoxTypePtr box; - BoxTypePtr lastbox = NULL; - Coord thickness; - Coord clearance; - if (TEST_FLAG (ONSOLDERFLAG, element)) - { - thisside = &solderside; - otherside = &componentside; - } - else - { - thisside = &componentside; - otherside = &solderside; - } - box = GetBoxMemory (thisside); - /* protect against elements with no pins/pads */ - if (element->PinN == 0 && element->PadN == 0) - continue; - /* initialize box so that it will take the dimensions of - * the first pin/pad */ - box->X1 = MAX_COORD; - box->Y1 = MAX_COORD; - box->X2 = -MAX_COORD; - box->Y2 = -MAX_COORD; - PIN_LOOP (element); - { - thickness = pin->Thickness / 2; - clearance = pin->Clearance * 2; - EXPANDRECTXY (box, - pin->X - (thickness + clearance), - pin->Y - (thickness + clearance), - pin->X + (thickness + clearance), - pin->Y + (thickness + clearance))} - END_LOOP; - PAD_LOOP (element); - { - thickness = pad->Thickness / 2; - clearance = pad->Clearance * 2; - EXPANDRECTXY (box, - MIN (pad->Point1.X, - pad->Point2.X) - (thickness + - clearance), - MIN (pad->Point1.Y, - pad->Point2.Y) - (thickness + - clearance), - MAX (pad->Point1.X, - pad->Point2.X) + (thickness + - clearance), - MAX (pad->Point1.Y, - pad->Point2.Y) + (thickness + clearance))} - END_LOOP; - /* add a box for each pin to the "opposite side": - * surface mount components can't sit on top of pins */ - if (!CostParameter.fast) - PIN_LOOP (element); - { - box = GetBoxMemory (otherside); - thickness = pin->Thickness / 2; - clearance = pin->Clearance * 2; - /* we ignore clearance here */ - /* (otherwise pins don't fit next to each other) */ - box->X1 = pin->X - thickness; - box->Y1 = pin->Y - thickness; - box->X2 = pin->X + thickness; - box->Y2 = pin->Y + thickness; - /* speed hack! coalesce with last box if we can */ - if (lastbox != NULL && - ((lastbox->X1 == box->X1 && - lastbox->X2 == box->X2 && - MIN (abs (lastbox->Y1 - box->Y2), - abs (box->Y1 - lastbox->Y2)) < - clearance) || (lastbox->Y1 == box->Y1 - && lastbox->Y2 == box->Y2 - && - MIN (abs - (lastbox->X1 - - box->X2), - abs (box->X1 - lastbox->X2)) < clearance))) + ELEMENT_LOOP(PCB->Data); { - EXPANDRECT (lastbox, box); - otherside->BoxN--; + BoxListTypePtr thisside; + BoxListTypePtr otherside; + BoxTypePtr box; + BoxTypePtr lastbox = NULL; + Coord thickness; + Coord clearance; + if (TEST_FLAG(ONSOLDERFLAG, element)) { + thisside = &solderside; + otherside = &componentside; + } + else { + thisside = &componentside; + otherside = &solderside; + } + box = GetBoxMemory(thisside); + /* protect against elements with no pins/pads */ + if (element->PinN == 0 && element->PadN == 0) + continue; + /* initialize box so that it will take the dimensions of + * the first pin/pad */ + box->X1 = MAX_COORD; + box->Y1 = MAX_COORD; + box->X2 = -MAX_COORD; + box->Y2 = -MAX_COORD; + PIN_LOOP(element); + { + thickness = pin->Thickness / 2; + clearance = pin->Clearance * 2; + EXPANDRECTXY(box, + pin->X - (thickness + clearance), + pin->Y - (thickness + clearance), pin->X + (thickness + clearance), pin->Y + (thickness + clearance))} + END_LOOP; + PAD_LOOP(element); + { + thickness = pad->Thickness / 2; + clearance = pad->Clearance * 2; + EXPANDRECTXY(box, + MIN(pad->Point1.X, + pad->Point2.X) - (thickness + + clearance), + MIN(pad->Point1.Y, + pad->Point2.Y) - (thickness + + clearance), + MAX(pad->Point1.X, + pad->Point2.X) + (thickness + clearance), MAX(pad->Point1.Y, pad->Point2.Y) + (thickness + clearance))} + END_LOOP; + /* add a box for each pin to the "opposite side": + * surface mount components can't sit on top of pins */ + if (!CostParameter.fast) + PIN_LOOP(element); + { + box = GetBoxMemory(otherside); + thickness = pin->Thickness / 2; + clearance = pin->Clearance * 2; + /* we ignore clearance here */ + /* (otherwise pins don't fit next to each other) */ + box->X1 = pin->X - thickness; + box->Y1 = pin->Y - thickness; + box->X2 = pin->X + thickness; + box->Y2 = pin->Y + thickness; + /* speed hack! coalesce with last box if we can */ + if (lastbox != NULL && + ((lastbox->X1 == box->X1 && + lastbox->X2 == box->X2 && + MIN(abs(lastbox->Y1 - box->Y2), + abs(box->Y1 - lastbox->Y2)) < + clearance) || (lastbox->Y1 == box->Y1 + && lastbox->Y2 == box->Y2 + && MIN(abs(lastbox->X1 - box->X2), abs(box->X1 - lastbox->X2)) < clearance))) { + EXPANDRECT(lastbox, box); + otherside->BoxN--; + } + else + lastbox = box; + } + END_LOOP; + /* assess out of bounds penalty */ + if (element->VBox.X1 < 0 || element->VBox.Y1 < 0 || element->VBox.X2 > PCB->MaxWidth || element->VBox.Y2 > PCB->MaxHeight) + delta3 += CostParameter.out_of_bounds_penalty; } - else - lastbox = box; - } - END_LOOP; - /* assess out of bounds penalty */ - if (element->VBox.X1 < 0 || - element->VBox.Y1 < 0 || - element->VBox.X2 > PCB->MaxWidth || element->VBox.Y2 > PCB->MaxHeight) - delta3 += CostParameter.out_of_bounds_penalty; - } - END_LOOP; - /* compute intersection area of module areas box list */ - delta2 = sqrt (fabs (ComputeIntersectionArea (&solderside) + - ComputeIntersectionArea (&componentside))) * - (CostParameter.overlap_penalty_min + - (1 - (T / T0)) * CostParameter.overlap_penalty_max); + END_LOOP; + /* compute intersection area of module areas box list */ + delta2 = sqrt(fabs(ComputeIntersectionArea(&solderside) + + ComputeIntersectionArea(&componentside))) * + (CostParameter.overlap_penalty_min + (1 - (T / T0)) * CostParameter.overlap_penalty_max); #if 0 - printf ("Module Overlap Area (solder): %f\n", - ComputeIntersectionArea (&solderside)); - printf ("Module Overlap Area (component): %f\n", - ComputeIntersectionArea (&componentside)); + printf("Module Overlap Area (solder): %f\n", ComputeIntersectionArea(&solderside)); + printf("Module Overlap Area (component): %f\n", ComputeIntersectionArea(&componentside)); #endif - FreeBoxListMemory (&solderside); - FreeBoxListMemory (&componentside); - /* reward pin/pad x/y alignment */ - /* score higher if pins/pads belong to same *type* of component */ - /* XXX: subkey should be *distance* from thing aligned with, so that - * aligning to something far away isn't profitable */ - { - /* create r tree */ - PointerListType seboxes = { 0, 0, NULL } - , ceboxes = - { - 0, 0, NULL}; - struct ebox - { - BoxType box; - ElementTypePtr element; - }; - direction_t dir[4] = { NORTH, EAST, SOUTH, WEST }; - struct ebox **boxpp, *boxp; - rtree_t *rt_s, *rt_c; - int factor; - ELEMENT_LOOP (PCB->Data); - { - boxpp = (struct ebox **) - GetPointerMemory (TEST_FLAG (ONSOLDERFLAG, element) ? - &seboxes : &ceboxes); - *boxpp = (struct ebox *)malloc (sizeof (**boxpp)); - if (*boxpp == NULL ) + FreeBoxListMemory(&solderside); + FreeBoxListMemory(&componentside); + /* reward pin/pad x/y alignment */ + /* score higher if pins/pads belong to same *type* of component */ + /* XXX: subkey should be *distance* from thing aligned with, so that + * aligning to something far away isn't profitable */ { - fprintf (stderr, "malloc() failed in %s\n", __FUNCTION__); - exit (1); + /* create r tree */ + PointerListType seboxes = { 0, 0, NULL } + , ceboxes = { + 0, 0, NULL}; + struct ebox { + BoxType box; + ElementTypePtr element; + }; + direction_t dir[4] = { NORTH, EAST, SOUTH, WEST }; + struct ebox **boxpp, *boxp; + rtree_t *rt_s, *rt_c; + int factor; + ELEMENT_LOOP(PCB->Data); + { + boxpp = (struct ebox **) + GetPointerMemory(TEST_FLAG(ONSOLDERFLAG, element) ? &seboxes : &ceboxes); + *boxpp = (struct ebox *) malloc(sizeof(**boxpp)); + if (*boxpp == NULL) { + fprintf(stderr, "malloc() failed in %s\n", __FUNCTION__); + exit(1); + } + + (*boxpp)->box = element->VBox; + (*boxpp)->element = element; + } + END_LOOP; + rt_s = r_create_tree((const BoxType **) seboxes.Ptr, seboxes.PtrN, 1); + rt_c = r_create_tree((const BoxType **) ceboxes.Ptr, ceboxes.PtrN, 1); + FreePointerListMemory(&seboxes); + FreePointerListMemory(&ceboxes); + /* now, for each element, find its neighbor on all four sides */ + delta4 = 0; + for (i = 0; i < 4; i++) + ELEMENT_LOOP(PCB->Data); + { + boxp = (struct ebox *) + r_find_neighbor(TEST_FLAG(ONSOLDERFLAG, element) ? rt_s : rt_c, &element->VBox, dir[i]); + /* score bounding box alignments */ + if (!boxp) + continue; + factor = 1; + if (element->Name[0].TextString && + boxp->element->Name[0].TextString && 0 == NSTRCMP(element->Name[0].TextString, boxp->element->Name[0].TextString)) { + delta4 += CostParameter.matching_neighbor_bonus; + factor++; + } + if (element->Name[0].Direction == boxp->element->Name[0].Direction) + delta4 += factor * CostParameter.oriented_neighbor_bonus; + if (element->VBox.X1 == boxp->element->VBox.X1 || + element->VBox.X1 == boxp->element->VBox.X2 || + element->VBox.X2 == boxp->element->VBox.X1 || + element->VBox.X2 == boxp->element->VBox.X2 || + element->VBox.Y1 == boxp->element->VBox.Y1 || + element->VBox.Y1 == boxp->element->VBox.Y2 || + element->VBox.Y2 == boxp->element->VBox.Y1 || element->VBox.Y2 == boxp->element->VBox.Y2) + delta4 += factor * CostParameter.aligned_neighbor_bonus; + } + END_LOOP; + /* free k-d tree memory */ + r_destroy_tree(&rt_s); + r_destroy_tree(&rt_c); } - - (*boxpp)->box = element->VBox; - (*boxpp)->element = element; - } - END_LOOP; - rt_s = r_create_tree ((const BoxType **) seboxes.Ptr, seboxes.PtrN, 1); - rt_c = r_create_tree ((const BoxType **) ceboxes.Ptr, ceboxes.PtrN, 1); - FreePointerListMemory (&seboxes); - FreePointerListMemory (&ceboxes); - /* now, for each element, find its neighbor on all four sides */ - delta4 = 0; - for (i = 0; i < 4; i++) - ELEMENT_LOOP (PCB->Data); - { - boxp = (struct ebox *) - r_find_neighbor (TEST_FLAG (ONSOLDERFLAG, element) ? - rt_s : rt_c, &element->VBox, dir[i]); - /* score bounding box alignments */ - if (!boxp) - continue; - factor = 1; - if (element->Name[0].TextString && - boxp->element->Name[0].TextString && - 0 == NSTRCMP (element->Name[0].TextString, - boxp->element->Name[0].TextString)) + /* penalize total area used by this layout */ { - delta4 += CostParameter.matching_neighbor_bonus; - factor++; + Coord minX = MAX_COORD, minY = MAX_COORD; + Coord maxX = -MAX_COORD, maxY = -MAX_COORD; + ELEMENT_LOOP(PCB->Data); + { + MAKEMIN(minX, element->VBox.X1); + MAKEMIN(minY, element->VBox.Y1); + MAKEMAX(maxX, element->VBox.X2); + MAKEMAX(maxY, element->VBox.Y2); + } + END_LOOP; + if (minX < maxX && minY < maxY) + delta5 = CostParameter.overall_area_penalty * sqrt(COORD_TO_MIL(maxX - minX) * COORD_TO_MIL(maxY - minY)); } - if (element->Name[0].Direction == boxp->element->Name[0].Direction) - delta4 += factor * CostParameter.oriented_neighbor_bonus; - if (element->VBox.X1 == boxp->element->VBox.X1 || - element->VBox.X1 == boxp->element->VBox.X2 || - element->VBox.X2 == boxp->element->VBox.X1 || - element->VBox.X2 == boxp->element->VBox.X2 || - element->VBox.Y1 == boxp->element->VBox.Y1 || - element->VBox.Y1 == boxp->element->VBox.Y2 || - element->VBox.Y2 == boxp->element->VBox.Y1 || - element->VBox.Y2 == boxp->element->VBox.Y2) - delta4 += factor * CostParameter.aligned_neighbor_bonus; - } - END_LOOP; - /* free k-d tree memory */ - r_destroy_tree (&rt_s); - r_destroy_tree (&rt_c); - } - /* penalize total area used by this layout */ - { - Coord minX = MAX_COORD, minY = MAX_COORD; - Coord maxX = -MAX_COORD, maxY = -MAX_COORD; - ELEMENT_LOOP (PCB->Data); - { - MAKEMIN (minX, element->VBox.X1); - MAKEMIN (minY, element->VBox.Y1); - MAKEMAX (maxX, element->VBox.X2); - MAKEMAX (maxY, element->VBox.Y2); - } - END_LOOP; - if (minX < maxX && minY < maxY) - delta5 = CostParameter.overall_area_penalty * - sqrt (COORD_TO_MIL (maxX - minX) * COORD_TO_MIL (maxY - minY)); - } - if (T == 5) - { - T = W + delta1 + delta2 + delta3 - delta4 + delta5; - printf ("cost components are %.3f %.3f %.3f %.3f %.3f %.3f\n", - W / T, delta1 / T, delta2 / T, delta3 / T, -delta4 / T, - delta5 / T); - } - /* done! */ - return W + (delta1 + delta2 + delta3 - delta4 + delta5); + if (T == 5) { + T = W + delta1 + delta2 + delta3 - delta4 + delta5; + printf("cost components are %.3f %.3f %.3f %.3f %.3f %.3f\n", + W / T, delta1 / T, delta2 / T, delta3 / T, -delta4 / T, delta5 / T); + } + /* done! */ + return W + (delta1 + delta2 + delta3 - delta4 + delta5); } /* --------------------------------------------------------------------------- @@ -614,241 +552,218 @@ * (magnitude of shift decreases over time) * -- Only perturb selected elements (need count/list of selected?) -- */ -PerturbationType -createPerturbation (PointerListTypePtr selected, double T) +PerturbationType createPerturbation(PointerListTypePtr selected, double T) { - PerturbationType pt = { 0 }; - /* pick element to perturb */ - pt.element = (ElementTypePtr) selected->Ptr[random () % selected->PtrN]; - /* exchange, flip/rotate or shift? */ - switch (random () % ((selected->PtrN > 1) ? 3 : 2)) - { - case 0: - { /* shift! */ - Coord grid; - double scaleX = CLAMP (sqrt (T), MIL_TO_COORD (2.5), PCB->MaxWidth / 3); - double scaleY = CLAMP (sqrt (T), MIL_TO_COORD (2.5), PCB->MaxHeight / 3); - pt.which = SHIFT; - pt.DX = scaleX * 2 * ((((double) random ()) / RAND_MAX) - 0.5); - pt.DY = scaleY * 2 * ((((double) random ()) / RAND_MAX) - 0.5); - /* snap to grid. different grids for "high" and "low" T */ - grid = (T > MIL_TO_COORD (10)) ? CostParameter.large_grid_size : - CostParameter.small_grid_size; - /* (round away from zero) */ - pt.DX = ((pt.DX / grid) + SGN (pt.DX)) * grid; - pt.DY = ((pt.DY / grid) + SGN (pt.DY)) * grid; - /* limit DX/DY so we don't fall off board */ - pt.DX = MAX (pt.DX, -pt.element->VBox.X1); - pt.DX = MIN (pt.DX, PCB->MaxWidth - pt.element->VBox.X2); - pt.DY = MAX (pt.DY, -pt.element->VBox.Y1); - pt.DY = MIN (pt.DY, PCB->MaxHeight - pt.element->VBox.Y2); - /* all done but the movin' */ - break; - } - case 1: - { /* flip/rotate! */ - /* only flip if it's an SMD component */ - bool isSMD = pt.element->PadN != 0; - pt.which = ROTATE; - pt.rotate = isSMD ? (random () & 3) : (1 + (random () % 3)); - /* 0 - flip; 1-3, rotate. */ - break; - } - case 2: - { /* exchange! */ - pt.which = EXCHANGE; - pt.other = (ElementTypePtr) - selected->Ptr[random () % (selected->PtrN - 1)]; - if (pt.other == pt.element) - pt.other = (ElementTypePtr) selected->Ptr[selected->PtrN - 1]; - /* don't allow exchanging a solderside-side SMD component - * with a non-SMD component. */ - if ((pt.element->PinN != 0 /* non-SMD */ && - TEST_FLAG (ONSOLDERFLAG, pt.other)) || - (pt.other->PinN != 0 /* non-SMD */ && - TEST_FLAG (ONSOLDERFLAG, pt.element))) - return createPerturbation (selected, T); - break; - } - default: - assert (0); - } - return pt; + PerturbationType pt = { 0 }; + /* pick element to perturb */ + pt.element = (ElementTypePtr) selected->Ptr[random() % selected->PtrN]; + /* exchange, flip/rotate or shift? */ + switch (random() % ((selected->PtrN > 1) ? 3 : 2)) { + case 0: + { /* shift! */ + Coord grid; + double scaleX = CLAMP(sqrt(T), MIL_TO_COORD(2.5), PCB->MaxWidth / 3); + double scaleY = CLAMP(sqrt(T), MIL_TO_COORD(2.5), PCB->MaxHeight / 3); + pt.which = SHIFT; + pt.DX = scaleX * 2 * ((((double) random()) / RAND_MAX) - 0.5); + pt.DY = scaleY * 2 * ((((double) random()) / RAND_MAX) - 0.5); + /* snap to grid. different grids for "high" and "low" T */ + grid = (T > MIL_TO_COORD(10)) ? CostParameter.large_grid_size : CostParameter.small_grid_size; + /* (round away from zero) */ + pt.DX = ((pt.DX / grid) + SGN(pt.DX)) * grid; + pt.DY = ((pt.DY / grid) + SGN(pt.DY)) * grid; + /* limit DX/DY so we don't fall off board */ + pt.DX = MAX(pt.DX, -pt.element->VBox.X1); + pt.DX = MIN(pt.DX, PCB->MaxWidth - pt.element->VBox.X2); + pt.DY = MAX(pt.DY, -pt.element->VBox.Y1); + pt.DY = MIN(pt.DY, PCB->MaxHeight - pt.element->VBox.Y2); + /* all done but the movin' */ + break; + } + case 1: + { /* flip/rotate! */ + /* only flip if it's an SMD component */ + bool isSMD = pt.element->PadN != 0; + pt.which = ROTATE; + pt.rotate = isSMD ? (random() & 3) : (1 + (random() % 3)); + /* 0 - flip; 1-3, rotate. */ + break; + } + case 2: + { /* exchange! */ + pt.which = EXCHANGE; + pt.other = (ElementTypePtr) + selected->Ptr[random() % (selected->PtrN - 1)]; + if (pt.other == pt.element) + pt.other = (ElementTypePtr) selected->Ptr[selected->PtrN - 1]; + /* don't allow exchanging a solderside-side SMD component + * with a non-SMD component. */ + if ((pt.element->PinN != 0 /* non-SMD */ && + TEST_FLAG(ONSOLDERFLAG, pt.other)) || (pt.other->PinN != 0 /* non-SMD */ && + TEST_FLAG(ONSOLDERFLAG, pt.element))) + return createPerturbation(selected, T); + break; + } + default: + assert(0); + } + return pt; } -void -doPerturb (PerturbationType * pt, bool undo) +void doPerturb(PerturbationType * pt, bool undo) { - Coord bbcx, bbcy; - /* compute center of element bounding box */ - bbcx = (pt->element->VBox.X1 + pt->element->VBox.X2) / 2; - bbcy = (pt->element->VBox.Y1 + pt->element->VBox.Y2) / 2; - /* do exchange, shift or flip/rotate */ - switch (pt->which) - { - case SHIFT: - { - Coord DX = pt->DX, DY = pt->DY; - if (undo) - { - DX = -DX; - DY = -DY; - } - MoveElementLowLevel (PCB->Data, pt->element, DX, DY); - return; - } - case ROTATE: - { - unsigned b = pt->rotate; - if (undo) - b = (4 - b) & 3; - /* 0 - flip; 1-3, rotate. */ - if (b) - RotateElementLowLevel (PCB->Data, pt->element, bbcx, bbcy, b); - else - { - Coord y = pt->element->VBox.Y1; - MirrorElementCoordinates (PCB->Data, pt->element, 0); - /* mirroring moves the element. move it back. */ - MoveElementLowLevel (PCB->Data, pt->element, 0, - y - pt->element->VBox.Y1); - } - return; - } - case EXCHANGE: - { - /* first exchange positions */ - Coord x1 = pt->element->VBox.X1; - Coord y1 = pt->element->VBox.Y1; - Coord x2 = pt->other->BoundingBox.X1; - Coord y2 = pt->other->BoundingBox.Y1; - MoveElementLowLevel (PCB->Data, pt->element, x2 - x1, y2 - y1); - MoveElementLowLevel (PCB->Data, pt->other, x1 - x2, y1 - y2); - /* then flip both elements if they are on opposite sides */ - if (TEST_FLAG (ONSOLDERFLAG, pt->element) != - TEST_FLAG (ONSOLDERFLAG, pt->other)) - { - PerturbationType mypt; - mypt.element = pt->element; - mypt.which = ROTATE; - mypt.rotate = 0; /* flip */ - doPerturb (&mypt, undo); - mypt.element = pt->other; - doPerturb (&mypt, undo); - } - /* done */ - return; - } - default: - assert (0); - } + Coord bbcx, bbcy; + /* compute center of element bounding box */ + bbcx = (pt->element->VBox.X1 + pt->element->VBox.X2) / 2; + bbcy = (pt->element->VBox.Y1 + pt->element->VBox.Y2) / 2; + /* do exchange, shift or flip/rotate */ + switch (pt->which) { + case SHIFT: + { + Coord DX = pt->DX, DY = pt->DY; + if (undo) { + DX = -DX; + DY = -DY; + } + MoveElementLowLevel(PCB->Data, pt->element, DX, DY); + return; + } + case ROTATE: + { + unsigned b = pt->rotate; + if (undo) + b = (4 - b) & 3; + /* 0 - flip; 1-3, rotate. */ + if (b) + RotateElementLowLevel(PCB->Data, pt->element, bbcx, bbcy, b); + else { + Coord y = pt->element->VBox.Y1; + MirrorElementCoordinates(PCB->Data, pt->element, 0); + /* mirroring moves the element. move it back. */ + MoveElementLowLevel(PCB->Data, pt->element, 0, y - pt->element->VBox.Y1); + } + return; + } + case EXCHANGE: + { + /* first exchange positions */ + Coord x1 = pt->element->VBox.X1; + Coord y1 = pt->element->VBox.Y1; + Coord x2 = pt->other->BoundingBox.X1; + Coord y2 = pt->other->BoundingBox.Y1; + MoveElementLowLevel(PCB->Data, pt->element, x2 - x1, y2 - y1); + MoveElementLowLevel(PCB->Data, pt->other, x1 - x2, y1 - y2); + /* then flip both elements if they are on opposite sides */ + if (TEST_FLAG(ONSOLDERFLAG, pt->element) != TEST_FLAG(ONSOLDERFLAG, pt->other)) { + PerturbationType mypt; + mypt.element = pt->element; + mypt.which = ROTATE; + mypt.rotate = 0; /* flip */ + doPerturb(&mypt, undo); + mypt.element = pt->other; + doPerturb(&mypt, undo); + } + /* done */ + return; + } + default: + assert(0); + } } /* --------------------------------------------------------------------------- * Auto-place selected components. */ -bool -AutoPlaceSelected (void) +bool AutoPlaceSelected(void) { - NetListTypePtr Nets; - PointerListType Selected = { 0, 0, NULL }; - PerturbationType pt; - double C0, T0; - bool changed = false; + NetListTypePtr Nets; + PointerListType Selected = { 0, 0, NULL }; + PerturbationType pt; + double C0, T0; + bool changed = false; - /* (initial netlist processing copied from AddAllRats) */ - /* the netlist library has the text form - * ProcNetlist fills in the Netlist - * structure the way the final routing - * is supposed to look - */ - Nets = ProcNetlist (&(PCB->NetlistLib[NETLIST_EDITED])); - if (!Nets) - { - Message (_("Can't add rat lines because no netlist is loaded.\n")); - goto done; - } + /* (initial netlist processing copied from AddAllRats) */ + /* the netlist library has the text form + * ProcNetlist fills in the Netlist + * structure the way the final routing + * is supposed to look + */ + Nets = ProcNetlist(&(PCB->NetlistLib[NETLIST_EDITED])); + if (!Nets) { + Message(_("Can't add rat lines because no netlist is loaded.\n")); + goto done; + } - Selected = collectSelectedElements (); - if (Selected.PtrN == 0) - { - Message (_("No elements selected to autoplace.\n")); - goto done; - } + Selected = collectSelectedElements(); + if (Selected.PtrN == 0) { + Message(_("No elements selected to autoplace.\n")); + goto done; + } - /* simulated annealing */ - { /* compute T0 by doing a random series of moves. */ - const int TRIALS = 10; - const double Tx = MIL_TO_COORD (300), P = 0.95; - double Cs = 0.0; - int i; - C0 = ComputeCost (Nets, Tx, Tx); - for (i = 0; i < TRIALS; i++) - { - pt = createPerturbation (&Selected, INCH_TO_COORD (1)); - doPerturb (&pt, false); - Cs += fabs (ComputeCost (Nets, Tx, Tx) - C0); - doPerturb (&pt, true); - } - T0 = -(Cs / TRIALS) / log (P); - printf ("Initial T: %f\n", T0); - } - /* now anneal in earnest */ - { - double T = T0; - long steps = 0; - int good_moves = 0, moves = 0; - const int good_move_cutoff = CostParameter.m * Selected.PtrN; - const int move_cutoff = 2 * good_move_cutoff; - printf ("Starting cost is %.0f\n", ComputeCost (Nets, T0, 5)); - C0 = ComputeCost (Nets, T0, T); - while (1) - { - double Cprime; - pt = createPerturbation (&Selected, T); - doPerturb (&pt, false); - Cprime = ComputeCost (Nets, T0, T); - if (Cprime < C0) - { /* good move! */ - C0 = Cprime; - good_moves++; - steps++; - } - else if ((random () / (double) RAND_MAX) < - exp (MIN (MAX (-20, (C0 - Cprime) / T), 20))) - { - /* not good but keep it anyway */ - C0 = Cprime; - steps++; - } - else - doPerturb (&pt, true); /* undo last change */ - moves++; - /* are we at the end of a stage? */ - if (good_moves >= good_move_cutoff || moves >= move_cutoff) - { - printf ("END OF STAGE: COST %.0f\t" - "GOOD_MOVES %d\tMOVES %d\t" - "T: %.1f\n", C0, good_moves, moves, T); - /* is this the end? */ - if (T < 5 || good_moves < moves / CostParameter.good_ratio) - break; - /* nope, adjust T and continue */ - moves = good_moves = 0; - T *= CostParameter.gamma; - /* cost is T dependent, so recompute */ - C0 = ComputeCost (Nets, T0, T); - } - } - changed = (steps > 0); - } + /* simulated annealing */ + { /* compute T0 by doing a random series of moves. */ + const int TRIALS = 10; + const double Tx = MIL_TO_COORD(300), P = 0.95; + double Cs = 0.0; + int i; + C0 = ComputeCost(Nets, Tx, Tx); + for (i = 0; i < TRIALS; i++) { + pt = createPerturbation(&Selected, INCH_TO_COORD(1)); + doPerturb(&pt, false); + Cs += fabs(ComputeCost(Nets, Tx, Tx) - C0); + doPerturb(&pt, true); + } + T0 = -(Cs / TRIALS) / log(P); + printf("Initial T: %f\n", T0); + } + /* now anneal in earnest */ + { + double T = T0; + long steps = 0; + int good_moves = 0, moves = 0; + const int good_move_cutoff = CostParameter.m * Selected.PtrN; + const int move_cutoff = 2 * good_move_cutoff; + printf("Starting cost is %.0f\n", ComputeCost(Nets, T0, 5)); + C0 = ComputeCost(Nets, T0, T); + while (1) { + double Cprime; + pt = createPerturbation(&Selected, T); + doPerturb(&pt, false); + Cprime = ComputeCost(Nets, T0, T); + if (Cprime < C0) { /* good move! */ + C0 = Cprime; + good_moves++; + steps++; + } + else if ((random() / (double) RAND_MAX) < exp(MIN(MAX(-20, (C0 - Cprime) / T), 20))) { + /* not good but keep it anyway */ + C0 = Cprime; + steps++; + } + else + doPerturb(&pt, true); /* undo last change */ + moves++; + /* are we at the end of a stage? */ + if (good_moves >= good_move_cutoff || moves >= move_cutoff) { + printf("END OF STAGE: COST %.0f\t" "GOOD_MOVES %d\tMOVES %d\t" "T: %.1f\n", C0, good_moves, moves, T); + /* is this the end? */ + if (T < 5 || good_moves < moves / CostParameter.good_ratio) + break; + /* nope, adjust T and continue */ + moves = good_moves = 0; + T *= CostParameter.gamma; + /* cost is T dependent, so recompute */ + C0 = ComputeCost(Nets, T0, T); + } + } + changed = (steps > 0); + } done: - if (changed) - { - DeleteRats (false); - AddAllRats (false, NULL); - Redraw (); - } - FreePointerListMemory (&Selected); - return (changed); + if (changed) { + DeleteRats(false); + AddAllRats(false, NULL); + Redraw(); + } + FreePointerListMemory(&Selected); + return (changed); } Index: trunk/src/autoplace.h =================================================================== --- trunk/src/autoplace.h (revision 1021) +++ trunk/src/autoplace.h (revision 1022) @@ -40,6 +40,6 @@ #include "global.h" -bool AutoPlaceSelected (void); +bool AutoPlaceSelected(void); #endif Index: trunk/src/autoroute.c =================================================================== --- trunk/src/autoroute.c (revision 1021) +++ trunk/src/autoroute.c (revision 1022) @@ -84,7 +84,7 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); /* #defines to enable some debugging output */ /* @@ -102,40 +102,38 @@ //#define DEBUG_SHOW_ZIGZAG */ -static direction_t -directionIncrement(direction_t dir) +static direction_t directionIncrement(direction_t dir) { - switch(dir) - { - case NORTH: - dir = EAST; - break; - case EAST: - dir = SOUTH; - break; - case SOUTH: - dir = WEST; - break; - case WEST: - dir = NE; - break; - case NE: - dir = SE; - break; - case SE: - dir = SW; - break; - case SW: - dir = NW; - break; - case NW: - dir = ALL; - break; - case ALL: - dir = NORTH; - break; - } -return dir; + switch (dir) { + case NORTH: + dir = EAST; + break; + case EAST: + dir = SOUTH; + break; + case SOUTH: + dir = WEST; + break; + case WEST: + dir = NE; + break; + case NE: + dir = SE; + break; + case SE: + dir = SW; + break; + case SW: + dir = NW; + break; + case NW: + dir = ALL; + break; + case ALL: + dir = NORTH; + break; + } + return dir; } #ifdef ROUTE_DEBUG @@ -215,186 +213,166 @@ */ /* enumerated type for conflict levels */ -typedef enum -{ NO_CONFLICT = 0, LO_CONFLICT = 1, HI_CONFLICT = 2 } -conflict_t; +typedef enum { NO_CONFLICT = 0, LO_CONFLICT = 1, HI_CONFLICT = 2 } conflict_t; -typedef struct routebox_list -{ - struct routebox *next, *prev; -}routebox_list; +typedef struct routebox_list { + struct routebox *next, *prev; +} routebox_list; -typedef enum etype - { PAD, PIN, VIA, VIA_SHADOW, LINE, OTHER, EXPANSION_AREA, PLANE, THERMAL } - etype; +typedef enum etype { PAD, PIN, VIA, VIA_SHADOW, LINE, OTHER, EXPANSION_AREA, PLANE, THERMAL } etype; -typedef struct routebox -{ - BoxType box, sbox; - union - { - PadTypePtr pad; - PinTypePtr pin; - PinTypePtr via; - struct routebox *via_shadow; /* points to the via in r-tree which - * points to the PinType in the PCB. */ - LineTypePtr line; - void *generic; /* 'other' is polygon, arc, text */ - struct routebox *expansion_area; /* previous expansion area in search */ - } - parent; - unsigned short group; - unsigned short layer; - etype type; - struct - { - unsigned nonstraight:1; - unsigned fixed:1; - /* for searches */ - unsigned source:1; - unsigned target:1; - /* rects on same net as source and target don't need clearance areas */ - unsigned nobloat:1; - /* mark circular pins, so that we be sure to connect them up properly */ - unsigned circular:1; - /* we sometimes create routeboxen that don't actually belong to a - * r-tree yet -- make sure refcount of homelesss is set properly */ - unsigned homeless:1; - /* was this nonfixed obstacle generated on an odd or even pass? */ - unsigned is_odd:1; - /* fixed route boxes that have already been "routed through" in this - * search have their "touched" flag set. */ - unsigned touched:1; - /* this is a status bit for iterating through *different* subnets */ - unsigned subnet_processed:1; - /* some expansion_areas represent via candidates */ - unsigned is_via:1; - /* mark non-straight lines which go from bottom-left to upper-right, - * instead of from upper-left to bottom-right. */ - unsigned bl_to_ur:1; - /* mark polygons which are "transparent" for via-placement; that is, - * vias through the polygon will automatically be given a keepaway - * and will not electrically connect to the polygon. */ - unsigned clear_poly:1; - /* this marks "conflicting" routes that must be torn up to obtain - * a correct routing. This flag allows us to return a correct routing - * even if the user cancels auto-route after a non-final pass. */ - unsigned is_bad:1; - /* for assertion that 'box' is never changed after creation */ - unsigned inited:1; - /* indicate this expansion ares is a thermal between the pin and plane */ - unsigned is_thermal; - } - flags; - /* indicate the direction an expansion box came from */ - cost_t cost; - CheapPointType cost_point; - /* reference count for homeless routeboxes; free when refcount==0 */ - int refcount; - /* when routing with conflicts, we keep a record of what we're - * conflicting with. - */ - vector_t *conflicts_with; - /* route style of the net associated with this routebox */ - RouteStyleType *style; - /* congestion values for the edges of an expansion box */ - unsigned char n, e, s, w; - /* what pass this this track was laid down on */ - unsigned char pass; - /* the direction this came from, if any */ - direction_t came_from; - /* circular lists with connectivity information. */ - routebox_list same_net, same_subnet, original_subnet, different_net; - union { - PinType *via; - LineType *line; - } livedraw_obj; -} -routebox_t; +typedef struct routebox { + BoxType box, sbox; + union { + PadTypePtr pad; + PinTypePtr pin; + PinTypePtr via; + struct routebox *via_shadow; /* points to the via in r-tree which + * points to the PinType in the PCB. */ + LineTypePtr line; + void *generic; /* 'other' is polygon, arc, text */ + struct routebox *expansion_area; /* previous expansion area in search */ + } parent; + unsigned short group; + unsigned short layer; + etype type; + struct { + unsigned nonstraight:1; + unsigned fixed:1; + /* for searches */ + unsigned source:1; + unsigned target:1; + /* rects on same net as source and target don't need clearance areas */ + unsigned nobloat:1; + /* mark circular pins, so that we be sure to connect them up properly */ + unsigned circular:1; + /* we sometimes create routeboxen that don't actually belong to a + * r-tree yet -- make sure refcount of homelesss is set properly */ + unsigned homeless:1; + /* was this nonfixed obstacle generated on an odd or even pass? */ + unsigned is_odd:1; + /* fixed route boxes that have already been "routed through" in this + * search have their "touched" flag set. */ + unsigned touched:1; + /* this is a status bit for iterating through *different* subnets */ + unsigned subnet_processed:1; + /* some expansion_areas represent via candidates */ + unsigned is_via:1; + /* mark non-straight lines which go from bottom-left to upper-right, + * instead of from upper-left to bottom-right. */ + unsigned bl_to_ur:1; + /* mark polygons which are "transparent" for via-placement; that is, + * vias through the polygon will automatically be given a keepaway + * and will not electrically connect to the polygon. */ + unsigned clear_poly:1; + /* this marks "conflicting" routes that must be torn up to obtain + * a correct routing. This flag allows us to return a correct routing + * even if the user cancels auto-route after a non-final pass. */ + unsigned is_bad:1; + /* for assertion that 'box' is never changed after creation */ + unsigned inited:1; + /* indicate this expansion ares is a thermal between the pin and plane */ + unsigned is_thermal; + } flags; + /* indicate the direction an expansion box came from */ + cost_t cost; + CheapPointType cost_point; + /* reference count for homeless routeboxes; free when refcount==0 */ + int refcount; + /* when routing with conflicts, we keep a record of what we're + * conflicting with. + */ + vector_t *conflicts_with; + /* route style of the net associated with this routebox */ + RouteStyleType *style; + /* congestion values for the edges of an expansion box */ + unsigned char n, e, s, w; + /* what pass this this track was laid down on */ + unsigned char pass; + /* the direction this came from, if any */ + direction_t came_from; + /* circular lists with connectivity information. */ + routebox_list same_net, same_subnet, original_subnet, different_net; + union { + PinType *via; + LineType *line; + } livedraw_obj; +} routebox_t; -typedef struct routedata -{ - /* one rtree per layer *group */ - rtree_t *layergrouptree[MAX_LAYER]; /* no silkscreen layers here =) */ - /* root pointer into connectivity information */ - routebox_t *first_net; - /* default routing style */ - RouteStyleType defaultstyle; - /* style structures */ - RouteStyleType *styles[NUM_STYLES + 1]; - /* what is the maximum bloat (keepaway+line half-width or - * keepaway+via_radius) for any style we've seen? */ - Coord max_bloat; - Coord max_keep; - mtspace_t *mtspace; -} -routedata_t; +typedef struct routedata { + /* one rtree per layer *group */ + rtree_t *layergrouptree[MAX_LAYER]; /* no silkscreen layers here =) */ + /* root pointer into connectivity information */ + routebox_t *first_net; + /* default routing style */ + RouteStyleType defaultstyle; + /* style structures */ + RouteStyleType *styles[NUM_STYLES + 1]; + /* what is the maximum bloat (keepaway+line half-width or + * keepaway+via_radius) for any style we've seen? */ + Coord max_bloat; + Coord max_keep; + mtspace_t *mtspace; +} routedata_t; -typedef struct edge_struct -{ - routebox_t *rb; /* path expansion edges are real routeboxen. */ - CheapPointType cost_point; - cost_t cost_to_point; /* from source */ - cost_t cost; /* cached edge cost */ - routebox_t *mincost_target; /* minimum cost from cost_point to any target */ - vetting_t *work; /* for via search edges */ - direction_t expand_dir; - struct - { - /* this indicates that this 'edge' is a via candidate. */ - unsigned is_via:1; - /* record "conflict level" of via candidates, in case we need to split - * them later. */ - conflict_t via_conflict_level:2; - /* when "routing with conflicts", sometimes edge is interior. */ - unsigned is_interior:1; - /* this is a fake edge used to defer searching for via spaces */ - unsigned via_search:1; - /* this is a via edge in a plane where the cost point moves for free */ - unsigned in_plane:1; - } - flags; -} -edge_t; +typedef struct edge_struct { + routebox_t *rb; /* path expansion edges are real routeboxen. */ + CheapPointType cost_point; + cost_t cost_to_point; /* from source */ + cost_t cost; /* cached edge cost */ + routebox_t *mincost_target; /* minimum cost from cost_point to any target */ + vetting_t *work; /* for via search edges */ + direction_t expand_dir; + struct { + /* this indicates that this 'edge' is a via candidate. */ + unsigned is_via:1; + /* record "conflict level" of via candidates, in case we need to split + * them later. */ + conflict_t via_conflict_level:2; + /* when "routing with conflicts", sometimes edge is interior. */ + unsigned is_interior:1; + /* this is a fake edge used to defer searching for via spaces */ + unsigned via_search:1; + /* this is a via edge in a plane where the cost point moves for free */ + unsigned in_plane:1; + } flags; +} edge_t; -static struct -{ - /* net style parameters */ - RouteStyleType *style; - /* the present bloat */ - Coord bloat; - /* cost parameters */ - cost_t ViaCost, /* additional "length" cost for using a via */ - LastConflictPenalty, /* length mult. for routing over last pass' trace */ - ConflictPenalty, /* length multiplier for routing over another trace */ - JogPenalty, /* additional "length" cost for changing direction */ - CongestionPenalty, /* (rational) length multiplier for routing in */ - NewLayerPenalty, /* penalty for routing on a previously unused layer */ - MinPenalty; /* smallest Direction Penalty */ - /* maximum conflict incidence before calling it "no path found" */ - int hi_conflict; - /* are vias allowed? */ - bool use_vias; - /* is this an odd or even pass? */ - bool is_odd; - /* permit conflicts? */ - bool with_conflicts; - /* is this a final "smoothing" pass? */ - bool is_smoothing; - /* rip up nets regardless of conflicts? */ - bool rip_always; - bool last_smooth; - unsigned char pass; -} -AutoRouteParameters; +static struct { + /* net style parameters */ + RouteStyleType *style; + /* the present bloat */ + Coord bloat; + /* cost parameters */ + cost_t ViaCost, /* additional "length" cost for using a via */ + LastConflictPenalty, /* length mult. for routing over last pass' trace */ + ConflictPenalty, /* length multiplier for routing over another trace */ + JogPenalty, /* additional "length" cost for changing direction */ + CongestionPenalty, /* (rational) length multiplier for routing in */ + NewLayerPenalty, /* penalty for routing on a previously unused layer */ + MinPenalty; /* smallest Direction Penalty */ + /* maximum conflict incidence before calling it "no path found" */ + int hi_conflict; + /* are vias allowed? */ + bool use_vias; + /* is this an odd or even pass? */ + bool is_odd; + /* permit conflicts? */ + bool with_conflicts; + /* is this a final "smoothing" pass? */ + bool is_smoothing; + /* rip up nets regardless of conflicts? */ + bool rip_always; + bool last_smooth; + unsigned char pass; +} AutoRouteParameters; -struct routeone_state -{ - /* heap of all candidate expansion edges */ - heap_t *workheap; - /* information about the best path found so far. */ - routebox_t *best_path, *best_target; - cost_t best_cost; +struct routeone_state { + /* heap of all candidate expansion edges */ + heap_t *workheap; + /* information about the best path found so far. */ + routebox_t *best_path, *best_target; + cost_t best_cost; }; @@ -401,28 +379,23 @@ /* --------------------------------------------------------------------------- * some local prototypes */ -static routebox_t *CreateExpansionArea (const BoxType * area, Cardinal group, - routebox_t * parent, - bool relax_edge_requirements, - edge_t * edge); +static routebox_t *CreateExpansionArea(const BoxType * area, Cardinal group, + routebox_t * parent, bool relax_edge_requirements, edge_t * edge); -static cost_t edge_cost (const edge_t * e, const cost_t too_big); -static void best_path_candidate (struct routeone_state *s, - edge_t * e, routebox_t * best_target); +static cost_t edge_cost(const edge_t * e, const cost_t too_big); +static void best_path_candidate(struct routeone_state *s, edge_t * e, routebox_t * best_target); -static BoxType edge_to_box (const routebox_t * rb, direction_t expand_dir); +static BoxType edge_to_box(const routebox_t * rb, direction_t expand_dir); -static void add_or_destroy_edge (struct routeone_state *s, edge_t * e); +static void add_or_destroy_edge(struct routeone_state *s, edge_t * e); static void -RD_DrawThermal (routedata_t * rd, Coord X, Coord Y, - Cardinal group, Cardinal layer, routebox_t * subnet, - bool is_bad); -static void ResetSubnet (routebox_t * net); +RD_DrawThermal(routedata_t * rd, Coord X, Coord Y, Cardinal group, Cardinal layer, routebox_t * subnet, bool is_bad); +static void ResetSubnet(routebox_t * net); #ifdef ROUTE_DEBUG static int showboxen = -2; static int aabort = 0; -static void showroutebox (routebox_t * rb); +static void showroutebox(routebox_t * rb); #endif /* --------------------------------------------------------------------------- @@ -442,68 +415,54 @@ /* assertion helper for routeboxen */ #ifndef NDEBUG -static int -__routebox_is_good (routebox_t * rb) +static int __routebox_is_good(routebox_t * rb) { - assert (rb && (rb->group < max_group) && - (rb->box.X1 <= rb->box.X2) && (rb->box.Y1 <= rb->box.Y2) && - (rb->flags.homeless ? - (rb->box.X1 != rb->box.X2) || (rb->box.Y1 != rb->box.Y2) : - (rb->box.X1 != rb->box.X2) && (rb->box.Y1 != rb->box.Y2))); - assert ((rb->flags.source ? rb->flags.nobloat : 1) && - (rb->flags.target ? rb->flags.nobloat : 1) && - (rb->flags.homeless ? !rb->flags.touched : rb->refcount == 0) && - (rb->flags.touched ? rb->type != EXPANSION_AREA : 1)); - assert ((rb->flags.is_odd ? (!rb->flags.fixed) && - (rb->type == VIA || rb->type == VIA_SHADOW || rb->type == LINE - || rb->type == PLANE) : 1)); - assert (rb->flags.clear_poly ? - ((rb->type == OTHER || rb->type == PLANE) && rb->flags.fixed - && !rb->flags.homeless) : 1); - assert (rb->flags.inited); + assert(rb && (rb->group < max_group) && + (rb->box.X1 <= rb->box.X2) && (rb->box.Y1 <= rb->box.Y2) && + (rb->flags.homeless ? + (rb->box.X1 != rb->box.X2) || (rb->box.Y1 != rb->box.Y2) : (rb->box.X1 != rb->box.X2) && (rb->box.Y1 != rb->box.Y2))); + assert((rb->flags.source ? rb->flags.nobloat : 1) && + (rb->flags.target ? rb->flags.nobloat : 1) && + (rb->flags.homeless ? !rb->flags.touched : rb->refcount == 0) && (rb->flags.touched ? rb->type != EXPANSION_AREA : 1)); + assert((rb->flags.is_odd ? (!rb->flags.fixed) && + (rb->type == VIA || rb->type == VIA_SHADOW || rb->type == LINE || rb->type == PLANE) : 1)); + assert(rb->flags.clear_poly ? ((rb->type == OTHER || rb->type == PLANE) && rb->flags.fixed && !rb->flags.homeless) : 1); + assert(rb->flags.inited); /* run through conflict list showing none are homeless, targets or sources */ - if (rb->conflicts_with) - { - int i; - for (i = 0; i < vector_size (rb->conflicts_with); i++) - { - routebox_t *c = vector_element (rb->conflicts_with, i); - assert (!c->flags.homeless && !c->flags.source && !c->flags.target - && !c->flags.fixed); + if (rb->conflicts_with) { + int i; + for (i = 0; i < vector_size(rb->conflicts_with); i++) { + routebox_t *c = vector_element(rb->conflicts_with, i); + assert(!c->flags.homeless && !c->flags.source && !c->flags.target && !c->flags.fixed); + } } - } - assert (rb->style != NULL && rb->style != NULL); - assert (rb->type == EXPANSION_AREA - || (rb->same_net.next && rb->same_net.prev && rb->same_subnet.next - && rb->same_subnet.prev && rb->original_subnet.next - && rb->original_subnet.prev && rb->different_net.next - && rb->different_net.prev)); - return 1; + assert(rb->style != NULL && rb->style != NULL); + assert(rb->type == EXPANSION_AREA + || (rb->same_net.next && rb->same_net.prev && rb->same_subnet.next + && rb->same_subnet.prev && rb->original_subnet.next + && rb->original_subnet.prev && rb->different_net.next && rb->different_net.prev)); + return 1; } -static int -__edge_is_good (edge_t * e) + +static int __edge_is_good(edge_t * e) { - assert (e && e->rb && __routebox_is_good (e->rb)); - assert ((e->rb->flags.homeless ? e->rb->refcount > 0 : 1)); - assert ((0 <= e->expand_dir) && (e->expand_dir < 9) - && (e->flags. - is_interior ? (e->expand_dir == ALL - && e->rb->conflicts_with) : 1)); - assert ((e->flags.is_via ? e->rb->flags.is_via : 1) - && (e->flags.via_conflict_level >= 0 - && e->flags.via_conflict_level <= 2) - && (e->flags.via_conflict_level != 0 ? e->flags.is_via : 1)); - assert ((e->cost_to_point >= 0) && e->cost >= 0); - return 1; + assert(e && e->rb && __routebox_is_good(e->rb)); + assert((e->rb->flags.homeless ? e->rb->refcount > 0 : 1)); + assert((0 <= e->expand_dir) && (e->expand_dir < 9) + && (e->flags.is_interior ? (e->expand_dir == ALL && e->rb->conflicts_with) : 1)); + assert((e->flags.is_via ? e->rb->flags.is_via : 1) + && (e->flags.via_conflict_level >= 0 && e->flags.via_conflict_level <= 2) + && (e->flags.via_conflict_level != 0 ? e->flags.is_via : 1)); + assert((e->cost_to_point >= 0) && e->cost >= 0); + return 1; } -int -no_planes (const BoxType * b, void *cl) +int no_planes(const BoxType * b, void *cl) { - routebox_t *rb = (routebox_t *) b; - if (rb->type == PLANE) - return 0; - return 1; + routebox_t *rb = (routebox_t *) b; + if (rb->type == PLANE) + return 0; + return 1; } #endif /* !NDEBUG */ @@ -511,129 +470,115 @@ * route utility functions. */ -enum boxlist -{ NET, SUBNET, ORIGINAL, DIFFERENT_NET }; -static struct routebox_list * -__select_list (routebox_t * r, enum boxlist which) +enum boxlist { NET, SUBNET, ORIGINAL, DIFFERENT_NET }; +static struct routebox_list *__select_list(routebox_t * r, enum boxlist which) { - assert (r); - switch (which) - { - default: - assert (0); - case NET: - return &(r->same_net); - case SUBNET: - return &(r->same_subnet); - case ORIGINAL: - return &(r->original_subnet); - case DIFFERENT_NET: - return &(r->different_net); - } + assert(r); + switch (which) { + default: + assert(0); + case NET: + return &(r->same_net); + case SUBNET: + return &(r->same_subnet); + case ORIGINAL: + return &(r->original_subnet); + case DIFFERENT_NET: + return &(r->different_net); + } } -static void -InitLists (routebox_t * r) + +static void InitLists(routebox_t * r) { - static enum boxlist all[] = - { NET, SUBNET, ORIGINAL, DIFFERENT_NET } - , *p; - for (p = all; p < all + (sizeof (all) / sizeof (*p)); p++) - { - struct routebox_list *rl = __select_list (r, *p); - rl->prev = rl->next = r; - } + static enum boxlist all[] = { NET, SUBNET, ORIGINAL, DIFFERENT_NET } + , *p; + for (p = all; p < all + (sizeof(all) / sizeof(*p)); p++) { + struct routebox_list *rl = __select_list(r, *p); + rl->prev = rl->next = r; + } } -static void -MergeNets (routebox_t * a, routebox_t * b, enum boxlist which) +static void MergeNets(routebox_t * a, routebox_t * b, enum boxlist which) { - struct routebox_list *al, *bl, *anl, *bnl; - routebox_t *an, *bn; - assert (a && b); - assert (a != b); - assert (a->type != EXPANSION_AREA); - assert (b->type != EXPANSION_AREA); - al = __select_list (a, which); - bl = __select_list (b, which); - assert (al && bl); - an = al->next; - bn = bl->next; - assert (an && bn); - anl = __select_list (an, which); - bnl = __select_list (bn, which); - assert (anl && bnl); - bl->next = an; - anl->prev = b; - al->next = bn; - bnl->prev = a; + struct routebox_list *al, *bl, *anl, *bnl; + routebox_t *an, *bn; + assert(a && b); + assert(a != b); + assert(a->type != EXPANSION_AREA); + assert(b->type != EXPANSION_AREA); + al = __select_list(a, which); + bl = __select_list(b, which); + assert(al && bl); + an = al->next; + bn = bl->next; + assert(an && bn); + anl = __select_list(an, which); + bnl = __select_list(bn, which); + assert(anl && bnl); + bl->next = an; + anl->prev = b; + al->next = bn; + bnl->prev = a; } -static void -RemoveFromNet (routebox_t * a, enum boxlist which) +static void RemoveFromNet(routebox_t * a, enum boxlist which) { - struct routebox_list *al, *anl, *apl; - routebox_t *an, *ap; - assert (a); - al = __select_list (a, which); - assert (al); - an = al->next; - ap = al->prev; - if (an == a || ap == a) - return; /* not on any list */ - assert (an && ap); - anl = __select_list (an, which); - apl = __select_list (ap, which); - assert (anl && apl); - anl->prev = ap; - apl->next = an; - al->next = al->prev = a; - return; + struct routebox_list *al, *anl, *apl; + routebox_t *an, *ap; + assert(a); + al = __select_list(a, which); + assert(al); + an = al->next; + ap = al->prev; + if (an == a || ap == a) + return; /* not on any list */ + assert(an && ap); + anl = __select_list(an, which); + apl = __select_list(ap, which); + assert(anl && apl); + anl->prev = ap; + apl->next = an; + al->next = al->prev = a; + return; } -static void -init_const_box (routebox_t * rb, - Coord X1, Coord Y1, Coord X2, - Coord Y2, Coord keepaway) +static void init_const_box(routebox_t * rb, Coord X1, Coord Y1, Coord X2, Coord Y2, Coord keepaway) { - BoxType *bp = (BoxType *) & rb->box; /* note discarding const! */ - assert (!rb->flags.inited); - assert (X1 <= X2 && Y1 <= Y2); - bp->X1 = X1 - keepaway; - bp->Y1 = Y1 - keepaway; - bp->X2 = X2 + keepaway; - bp->Y2 = Y2 + keepaway; - bp = (BoxType *) & rb->sbox; - bp->X1 = X1; - bp->Y1 = Y1; - bp->X2 = X2; - bp->Y2 = Y2; - rb->flags.inited = 1; + BoxType *bp = (BoxType *) & rb->box; /* note discarding const! */ + assert(!rb->flags.inited); + assert(X1 <= X2 && Y1 <= Y2); + bp->X1 = X1 - keepaway; + bp->Y1 = Y1 - keepaway; + bp->X2 = X2 + keepaway; + bp->Y2 = Y2 + keepaway; + bp = (BoxType *) & rb->sbox; + bp->X1 = X1; + bp->Y1 = Y1; + bp->X2 = X2; + bp->Y2 = Y2; + rb->flags.inited = 1; } -static inline BoxType -shrink_routebox (const routebox_t * rb) +static inline BoxType shrink_routebox(const routebox_t * rb) { - return rb->sbox; + return rb->sbox; } -static inline cost_t -box_area (const BoxType b) +static inline cost_t box_area(const BoxType b) { - cost_t ans = b.X2 - b.X1; - return ans * (b.Y2 - b.Y1); + cost_t ans = b.X2 - b.X1; + return ans * (b.Y2 - b.Y1); } -static inline CheapPointType -closest_point_in_routebox (const CheapPointType * from, const routebox_t * rb) +static inline CheapPointType closest_point_in_routebox(const CheapPointType * from, const routebox_t * rb) { - return closest_point_in_box (from, &rb->sbox); + return closest_point_in_box(from, &rb->sbox); } -static inline bool -point_in_shrunk_box (const routebox_t * box, Coord X, Coord Y) +static inline bool point_in_shrunk_box(const routebox_t * box, Coord X, Coord Y) { - BoxType b = shrink_routebox (box); - return point_in_box (&b, X, Y); + BoxType b = shrink_routebox(box); + return point_in_box(&b, X, Y); } /*--------------------------------------------------------------------- @@ -640,654 +585,579 @@ * routedata initialization functions. */ -static routebox_t * -AddPin (PointerListType layergroupboxes[], PinTypePtr pin, bool is_via, - RouteStyleType * style) +static routebox_t *AddPin(PointerListType layergroupboxes[], PinTypePtr pin, bool is_via, RouteStyleType * style) { - routebox_t **rbpp, *lastrb = NULL; - int i, ht; - /* a pin cuts through every layer group */ - for (i = 0; i < max_group; i++) - { - rbpp = (routebox_t **) GetPointerMemory (&layergroupboxes[i]); - *rbpp = (routebox_t *)malloc (sizeof (**rbpp)); - memset ((void *) *rbpp, 0, sizeof (**rbpp)); - (*rbpp)->group = i; - ht = HALF_THICK (MAX (pin->Thickness, pin->DrillingHole)); - init_const_box (*rbpp, - /*X1 */ pin->X - ht, - /*Y1 */ pin->Y - ht, - /*X2 */ pin->X + ht, - /*Y2 */ pin->Y + ht, style->Keepaway); - /* set aux. properties */ - if (is_via) - { - (*rbpp)->type = VIA; - (*rbpp)->parent.via = pin; + routebox_t **rbpp, *lastrb = NULL; + int i, ht; + /* a pin cuts through every layer group */ + for (i = 0; i < max_group; i++) { + rbpp = (routebox_t **) GetPointerMemory(&layergroupboxes[i]); + *rbpp = (routebox_t *) malloc(sizeof(**rbpp)); + memset((void *) *rbpp, 0, sizeof(**rbpp)); + (*rbpp)->group = i; + ht = HALF_THICK(MAX(pin->Thickness, pin->DrillingHole)); + init_const_box(*rbpp, + /*X1 */ pin->X - ht, + /*Y1 */ pin->Y - ht, + /*X2 */ pin->X + ht, + /*Y2 */ pin->Y + ht, style->Keepaway); + /* set aux. properties */ + if (is_via) { + (*rbpp)->type = VIA; + (*rbpp)->parent.via = pin; + } + else { + (*rbpp)->type = PIN; + (*rbpp)->parent.pin = pin; + } + (*rbpp)->flags.fixed = 1; + (*rbpp)->came_from = ALL; + (*rbpp)->style = style; + (*rbpp)->flags.circular = !TEST_FLAG(SQUAREFLAG, pin); + /* circular lists */ + InitLists(*rbpp); + /* link together */ + if (lastrb) { + MergeNets(*rbpp, lastrb, NET); + MergeNets(*rbpp, lastrb, SUBNET); + MergeNets(*rbpp, lastrb, ORIGINAL); + } + lastrb = *rbpp; } - else - { - (*rbpp)->type = PIN; - (*rbpp)->parent.pin = pin; - } - (*rbpp)->flags.fixed = 1; - (*rbpp)->came_from = ALL; - (*rbpp)->style = style; - (*rbpp)->flags.circular = !TEST_FLAG (SQUAREFLAG, pin); - /* circular lists */ - InitLists (*rbpp); - /* link together */ - if (lastrb) - { - MergeNets (*rbpp, lastrb, NET); - MergeNets (*rbpp, lastrb, SUBNET); - MergeNets (*rbpp, lastrb, ORIGINAL); - } - lastrb = *rbpp; - } - return lastrb; + return lastrb; } -static routebox_t * -AddPad (PointerListType layergroupboxes[], - ElementTypePtr element, PadTypePtr pad, RouteStyleType * style) + +static routebox_t *AddPad(PointerListType layergroupboxes[], ElementTypePtr element, PadTypePtr pad, RouteStyleType * style) { - Coord halfthick; - routebox_t **rbpp; - int layergroup = (TEST_FLAG (ONSOLDERFLAG, pad) ? back : front); - assert (0 <= layergroup && layergroup < max_group); - assert (PCB->LayerGroups.Number[layergroup] > 0); - rbpp = (routebox_t **) GetPointerMemory (&layergroupboxes[layergroup]); - assert (rbpp); - *rbpp = (routebox_t *)malloc (sizeof (**rbpp)); - assert (*rbpp); - memset (*rbpp, 0, sizeof (**rbpp)); - (*rbpp)->group = layergroup; - halfthick = HALF_THICK (pad->Thickness); - init_const_box (*rbpp, - /*X1 */ MIN (pad->Point1.X, pad->Point2.X) - halfthick, - /*Y1 */ MIN (pad->Point1.Y, pad->Point2.Y) - halfthick, - /*X2 */ MAX (pad->Point1.X, pad->Point2.X) + halfthick, - /*Y2 */ MAX (pad->Point1.Y, pad->Point2.Y) + halfthick, - style->Keepaway); - /* kludge for non-manhattan pads (which are not allowed at present) */ - if (pad->Point1.X != pad->Point2.X && pad->Point1.Y != pad->Point2.Y) - (*rbpp)->flags.nonstraight = 1; - /* set aux. properties */ - (*rbpp)->type = PAD; - (*rbpp)->parent.pad = pad; - (*rbpp)->flags.fixed = 1; - (*rbpp)->came_from = ALL; - (*rbpp)->style = style; - /* circular lists */ - InitLists (*rbpp); - return *rbpp; + Coord halfthick; + routebox_t **rbpp; + int layergroup = (TEST_FLAG(ONSOLDERFLAG, pad) ? back : front); + assert(0 <= layergroup && layergroup < max_group); + assert(PCB->LayerGroups.Number[layergroup] > 0); + rbpp = (routebox_t **) GetPointerMemory(&layergroupboxes[layergroup]); + assert(rbpp); + *rbpp = (routebox_t *) malloc(sizeof(**rbpp)); + assert(*rbpp); + memset(*rbpp, 0, sizeof(**rbpp)); + (*rbpp)->group = layergroup; + halfthick = HALF_THICK(pad->Thickness); + init_const_box(*rbpp, + /*X1 */ MIN(pad->Point1.X, pad->Point2.X) - halfthick, + /*Y1 */ MIN(pad->Point1.Y, pad->Point2.Y) - halfthick, + /*X2 */ MAX(pad->Point1.X, pad->Point2.X) + halfthick, + /*Y2 */ MAX(pad->Point1.Y, pad->Point2.Y) + halfthick, + style->Keepaway); + /* kludge for non-manhattan pads (which are not allowed at present) */ + if (pad->Point1.X != pad->Point2.X && pad->Point1.Y != pad->Point2.Y) + (*rbpp)->flags.nonstraight = 1; + /* set aux. properties */ + (*rbpp)->type = PAD; + (*rbpp)->parent.pad = pad; + (*rbpp)->flags.fixed = 1; + (*rbpp)->came_from = ALL; + (*rbpp)->style = style; + /* circular lists */ + InitLists(*rbpp); + return *rbpp; } -static routebox_t * -AddLine (PointerListType layergroupboxes[], int layergroup, LineTypePtr line, - LineTypePtr ptr, RouteStyleType * style) + +static routebox_t *AddLine(PointerListType layergroupboxes[], int layergroup, LineTypePtr line, + LineTypePtr ptr, RouteStyleType * style) { - routebox_t **rbpp; - assert (layergroupboxes && line); - assert (0 <= layergroup && layergroup < max_group); - assert (PCB->LayerGroups.Number[layergroup] > 0); + routebox_t **rbpp; + assert(layergroupboxes && line); + assert(0 <= layergroup && layergroup < max_group); + assert(PCB->LayerGroups.Number[layergroup] > 0); - rbpp = (routebox_t **) GetPointerMemory (&layergroupboxes[layergroup]); - *rbpp = (routebox_t *)malloc (sizeof (**rbpp)); - memset (*rbpp, 0, sizeof (**rbpp)); - (*rbpp)->group = layergroup; - init_const_box (*rbpp, - /*X1 */ MIN (line->Point1.X, - line->Point2.X) - HALF_THICK (line->Thickness), - /*Y1 */ MIN (line->Point1.Y, - line->Point2.Y) - HALF_THICK (line->Thickness), - /*X2 */ MAX (line->Point1.X, - line->Point2.X) + HALF_THICK (line->Thickness), - /*Y2 */ MAX (line->Point1.Y, - line->Point2.Y) + - HALF_THICK (line->Thickness), style->Keepaway); - /* kludge for non-manhattan lines */ - if (line->Point1.X != line->Point2.X && line->Point1.Y != line->Point2.Y) - { - (*rbpp)->flags.nonstraight = 1; - (*rbpp)->flags.bl_to_ur = - (MIN (line->Point1.X, line->Point2.X) == line->Point1.X) != - (MIN (line->Point1.Y, line->Point2.Y) == line->Point1.Y); + rbpp = (routebox_t **) GetPointerMemory(&layergroupboxes[layergroup]); + *rbpp = (routebox_t *) malloc(sizeof(**rbpp)); + memset(*rbpp, 0, sizeof(**rbpp)); + (*rbpp)->group = layergroup; + init_const_box(*rbpp, + /*X1 */ MIN(line->Point1.X, + line->Point2.X) - HALF_THICK(line->Thickness), + /*Y1 */ MIN(line->Point1.Y, + line->Point2.Y) - HALF_THICK(line->Thickness), + /*X2 */ MAX(line->Point1.X, + line->Point2.X) + HALF_THICK(line->Thickness), + /*Y2 */ MAX(line->Point1.Y, + line->Point2.Y) + HALF_THICK(line->Thickness), style->Keepaway); + /* kludge for non-manhattan lines */ + if (line->Point1.X != line->Point2.X && line->Point1.Y != line->Point2.Y) { + (*rbpp)->flags.nonstraight = 1; + (*rbpp)->flags.bl_to_ur = + (MIN(line->Point1.X, line->Point2.X) == line->Point1.X) != (MIN(line->Point1.Y, line->Point2.Y) == line->Point1.Y); #if defined(ROUTE_DEBUG) && defined(DEBUG_SHOW_ZIGZAG) - showroutebox (*rbpp); + showroutebox(*rbpp); #endif - } - /* set aux. properties */ - (*rbpp)->type = LINE; - (*rbpp)->parent.line = ptr; - (*rbpp)->flags.fixed = 1; - (*rbpp)->came_from = ALL; - (*rbpp)->style = style; - /* circular lists */ - InitLists (*rbpp); - return *rbpp; + } + /* set aux. properties */ + (*rbpp)->type = LINE; + (*rbpp)->parent.line = ptr; + (*rbpp)->flags.fixed = 1; + (*rbpp)->came_from = ALL; + (*rbpp)->style = style; + /* circular lists */ + InitLists(*rbpp); + return *rbpp; } -static routebox_t * -AddIrregularObstacle (PointerListType layergroupboxes[], - Coord X1, Coord Y1, - Coord X2, Coord Y2, Cardinal layergroup, - void *parent, RouteStyleType * style) + +static routebox_t *AddIrregularObstacle(PointerListType layergroupboxes[], + Coord X1, Coord Y1, + Coord X2, Coord Y2, Cardinal layergroup, void *parent, RouteStyleType * style) { - routebox_t **rbpp; - Coord keep = style->Keepaway; - assert (layergroupboxes && parent); - assert (X1 <= X2 && Y1 <= Y2); - assert (0 <= layergroup && layergroup < max_group); - assert (PCB->LayerGroups.Number[layergroup] > 0); + routebox_t **rbpp; + Coord keep = style->Keepaway; + assert(layergroupboxes && parent); + assert(X1 <= X2 && Y1 <= Y2); + assert(0 <= layergroup && layergroup < max_group); + assert(PCB->LayerGroups.Number[layergroup] > 0); - rbpp = (routebox_t **) GetPointerMemory (&layergroupboxes[layergroup]); - *rbpp = (routebox_t *)malloc (sizeof (**rbpp)); - memset (*rbpp, 0, sizeof (**rbpp)); - (*rbpp)->group = layergroup; - init_const_box (*rbpp, X1, Y1, X2, Y2, keep); - (*rbpp)->flags.nonstraight = 1; - (*rbpp)->type = OTHER; - (*rbpp)->parent.generic = parent; - (*rbpp)->flags.fixed = 1; - (*rbpp)->style = style; - /* circular lists */ - InitLists (*rbpp); - return *rbpp; + rbpp = (routebox_t **) GetPointerMemory(&layergroupboxes[layergroup]); + *rbpp = (routebox_t *) malloc(sizeof(**rbpp)); + memset(*rbpp, 0, sizeof(**rbpp)); + (*rbpp)->group = layergroup; + init_const_box(*rbpp, X1, Y1, X2, Y2, keep); + (*rbpp)->flags.nonstraight = 1; + (*rbpp)->type = OTHER; + (*rbpp)->parent.generic = parent; + (*rbpp)->flags.fixed = 1; + (*rbpp)->style = style; + /* circular lists */ + InitLists(*rbpp); + return *rbpp; } -static routebox_t * -AddPolygon (PointerListType layergroupboxes[], Cardinal layer, - PolygonTypePtr polygon, RouteStyleType * style) +static routebox_t *AddPolygon(PointerListType layergroupboxes[], Cardinal layer, PolygonTypePtr polygon, RouteStyleType * style) { - int is_not_rectangle = 1; - int layergroup = GetLayerGroupNumberByNumber (layer); - routebox_t *rb; - assert (0 <= layergroup && layergroup < max_group); - rb = AddIrregularObstacle (layergroupboxes, - polygon->BoundingBox.X1, - polygon->BoundingBox.Y1, - polygon->BoundingBox.X2, - polygon->BoundingBox.Y2, - layergroup, polygon, style); - if (polygon->PointN == 4 && - polygon->HoleIndexN == 0 && - (polygon->Points[0].X == polygon->Points[1].X || - polygon->Points[0].Y == polygon->Points[1].Y) && - (polygon->Points[1].X == polygon->Points[2].X || - polygon->Points[1].Y == polygon->Points[2].Y) && - (polygon->Points[2].X == polygon->Points[3].X || - polygon->Points[2].Y == polygon->Points[3].Y) && - (polygon->Points[3].X == polygon->Points[0].X || - polygon->Points[3].Y == polygon->Points[0].Y)) - is_not_rectangle = 0; - rb->flags.nonstraight = is_not_rectangle; - rb->layer = layer; - rb->came_from = ALL; - if (TEST_FLAG (CLEARPOLYFLAG, polygon)) - { - rb->flags.clear_poly = 1; - if (!is_not_rectangle) - rb->type = PLANE; - } - return rb; + int is_not_rectangle = 1; + int layergroup = GetLayerGroupNumberByNumber(layer); + routebox_t *rb; + assert(0 <= layergroup && layergroup < max_group); + rb = AddIrregularObstacle(layergroupboxes, + polygon->BoundingBox.X1, + polygon->BoundingBox.Y1, + polygon->BoundingBox.X2, polygon->BoundingBox.Y2, layergroup, polygon, style); + if (polygon->PointN == 4 && + polygon->HoleIndexN == 0 && + (polygon->Points[0].X == polygon->Points[1].X || + polygon->Points[0].Y == polygon->Points[1].Y) && + (polygon->Points[1].X == polygon->Points[2].X || + polygon->Points[1].Y == polygon->Points[2].Y) && + (polygon->Points[2].X == polygon->Points[3].X || + polygon->Points[2].Y == polygon->Points[3].Y) && + (polygon->Points[3].X == polygon->Points[0].X || polygon->Points[3].Y == polygon->Points[0].Y)) + is_not_rectangle = 0; + rb->flags.nonstraight = is_not_rectangle; + rb->layer = layer; + rb->came_from = ALL; + if (TEST_FLAG(CLEARPOLYFLAG, polygon)) { + rb->flags.clear_poly = 1; + if (!is_not_rectangle) + rb->type = PLANE; + } + return rb; } -static void -AddText (PointerListType layergroupboxes[], Cardinal layergroup, - TextTypePtr text, RouteStyleType * style) + +static void AddText(PointerListType layergroupboxes[], Cardinal layergroup, TextTypePtr text, RouteStyleType * style) { - AddIrregularObstacle (layergroupboxes, - text->BoundingBox.X1, text->BoundingBox.Y1, - text->BoundingBox.X2, text->BoundingBox.Y2, - layergroup, text, style); + AddIrregularObstacle(layergroupboxes, + text->BoundingBox.X1, text->BoundingBox.Y1, + text->BoundingBox.X2, text->BoundingBox.Y2, layergroup, text, style); } -static routebox_t * -AddArc (PointerListType layergroupboxes[], Cardinal layergroup, - ArcTypePtr arc, RouteStyleType * style) + +static routebox_t *AddArc(PointerListType layergroupboxes[], Cardinal layergroup, ArcTypePtr arc, RouteStyleType * style) { - return AddIrregularObstacle (layergroupboxes, - arc->BoundingBox.X1, arc->BoundingBox.Y1, - arc->BoundingBox.X2, arc->BoundingBox.Y2, - layergroup, arc, style); + return AddIrregularObstacle(layergroupboxes, + arc->BoundingBox.X1, arc->BoundingBox.Y1, + arc->BoundingBox.X2, arc->BoundingBox.Y2, layergroup, arc, style); } -struct rb_info -{ - BoxType query; - routebox_t *winner; - jmp_buf env; +struct rb_info { + BoxType query; + routebox_t *winner; + jmp_buf env; }; -static int -__found_one_on_lg (const BoxType * box, void *cl) +static int __found_one_on_lg(const BoxType * box, void *cl) { - struct rb_info *inf = (struct rb_info *) cl; - routebox_t *rb = (routebox_t *) box; - BoxType sb; + struct rb_info *inf = (struct rb_info *) cl; + routebox_t *rb = (routebox_t *) box; + BoxType sb; - if (rb->flags.nonstraight) - return 0; - sb = shrink_box (&rb->box, rb->style->Keepaway); - if (inf->query.X1 >= sb.X2 || inf->query.X2 <= sb.X1 || - inf->query.Y1 >= sb.Y2 || inf->query.Y2 <= sb.Y1) - return 0; - inf->winner = rb; - if (rb->type == PLANE) - return 1; /* keep looking for something smaller if a plane was found */ - longjmp (inf->env, 1); - return 0; + if (rb->flags.nonstraight) + return 0; + sb = shrink_box(&rb->box, rb->style->Keepaway); + if (inf->query.X1 >= sb.X2 || inf->query.X2 <= sb.X1 || inf->query.Y1 >= sb.Y2 || inf->query.Y2 <= sb.Y1) + return 0; + inf->winner = rb; + if (rb->type == PLANE) + return 1; /* keep looking for something smaller if a plane was found */ + longjmp(inf->env, 1); + return 0; } -static routebox_t * -FindRouteBoxOnLayerGroup (routedata_t * rd, - Coord X, Coord Y, Cardinal layergroup) + +static routebox_t *FindRouteBoxOnLayerGroup(routedata_t * rd, Coord X, Coord Y, Cardinal layergroup) { - struct rb_info info; - info.winner = NULL; - info.query = point_box (X, Y); - if (setjmp (info.env) == 0) - r_search (rd->layergrouptree[layergroup], &info.query, NULL, - __found_one_on_lg, &info); - return info.winner; + struct rb_info info; + info.winner = NULL; + info.query = point_box(X, Y); + if (setjmp(info.env) == 0) + r_search(rd->layergrouptree[layergroup], &info.query, NULL, __found_one_on_lg, &info); + return info.winner; } #ifdef ROUTE_DEBUG_VERBOSE -static void -DumpRouteBox (routebox_t * rb) +static void DumpRouteBox(routebox_t * rb) { - pcb_printf ("RB: %#mD-%#mD l%d; ", - rb->box.X1, rb->box.Y1, rb->box.X2, rb->box.Y2, (int) rb->group); - switch (rb->type) - { - case PAD: - printf ("PAD[%s %s] ", rb->parent.pad->Name, rb->parent.pad->Number); - break; - case PIN: - printf ("PIN[%s %s] ", rb->parent.pin->Name, rb->parent.pin->Number); - break; - case VIA: - if (!rb->parent.via) - break; - printf ("VIA[%s %s] ", rb->parent.via->Name, rb->parent.via->Number); - break; - case LINE: - printf ("LINE "); - break; - case OTHER: - printf ("OTHER "); - break; - case EXPANSION_AREA: - printf ("EXPAREA "); - break; - default: - printf ("UNKNOWN "); - break; - } - if (rb->flags.nonstraight) - printf ("(nonstraight) "); - if (rb->flags.fixed) - printf ("(fixed) "); - if (rb->flags.source) - printf ("(source) "); - if (rb->flags.target) - printf ("(target) "); - if (rb->flags.homeless) - printf ("(homeless) "); - printf ("\n"); + pcb_printf("RB: %#mD-%#mD l%d; ", rb->box.X1, rb->box.Y1, rb->box.X2, rb->box.Y2, (int) rb->group); + switch (rb->type) { + case PAD: + printf("PAD[%s %s] ", rb->parent.pad->Name, rb->parent.pad->Number); + break; + case PIN: + printf("PIN[%s %s] ", rb->parent.pin->Name, rb->parent.pin->Number); + break; + case VIA: + if (!rb->parent.via) + break; + printf("VIA[%s %s] ", rb->parent.via->Name, rb->parent.via->Number); + break; + case LINE: + printf("LINE "); + break; + case OTHER: + printf("OTHER "); + break; + case EXPANSION_AREA: + printf("EXPAREA "); + break; + default: + printf("UNKNOWN "); + break; + } + if (rb->flags.nonstraight) + printf("(nonstraight) "); + if (rb->flags.fixed) + printf("(fixed) "); + if (rb->flags.source) + printf("(source) "); + if (rb->flags.target) + printf("(target) "); + if (rb->flags.homeless) + printf("(homeless) "); + printf("\n"); } #endif -static routedata_t * -CreateRouteData () +static routedata_t *CreateRouteData() { - NetListListType Nets; - PointerListType layergroupboxes[MAX_LAYER]; - BoxType bbox; - routedata_t *rd; - int group, i; + NetListListType Nets; + PointerListType layergroupboxes[MAX_LAYER]; + BoxType bbox; + routedata_t *rd; + int group, i; - /* check which layers are active first */ - routing_layers = 0; - for (group = 0; group < max_group; group++) - { - for (i = 0; i < PCB->LayerGroups.Number[group]; i++) - /* layer must be 1) not silk (ie, < max_copper_layer) and 2) on */ - if ((PCB->LayerGroups.Entries[group][i] < max_copper_layer) && - PCB->Data->Layer[PCB->LayerGroups.Entries[group][i]].On) - { - routing_layers++; - is_layer_group_active[group] = true; - break; - } - else - is_layer_group_active[group] = false; - } - /* if via visibility is turned off, don't use them */ - AutoRouteParameters.use_vias = routing_layers > 1 && PCB->ViaOn; - front = GetLayerGroupNumberByNumber (component_silk_layer); - back = GetLayerGroupNumberByNumber (solder_silk_layer); - /* determine preferred routing direction on each group */ - for (i = 0; i < max_group; i++) - { - if (i != back && i != front) - { - x_cost[i] = (i & 1) ? 2 : 1; - y_cost[i] = (i & 1) ? 1 : 2; + /* check which layers are active first */ + routing_layers = 0; + for (group = 0; group < max_group; group++) { + for (i = 0; i < PCB->LayerGroups.Number[group]; i++) + /* layer must be 1) not silk (ie, < max_copper_layer) and 2) on */ + if ((PCB->LayerGroups.Entries[group][i] < max_copper_layer) && PCB->Data->Layer[PCB->LayerGroups.Entries[group][i]].On) { + routing_layers++; + is_layer_group_active[group] = true; + break; + } + else + is_layer_group_active[group] = false; } - else if (i == back) + /* if via visibility is turned off, don't use them */ + AutoRouteParameters.use_vias = routing_layers > 1 && PCB->ViaOn; + front = GetLayerGroupNumberByNumber(component_silk_layer); + back = GetLayerGroupNumberByNumber(solder_silk_layer); + /* determine preferred routing direction on each group */ + for (i = 0; i < max_group; i++) { + if (i != back && i != front) { + x_cost[i] = (i & 1) ? 2 : 1; + y_cost[i] = (i & 1) ? 1 : 2; + } + else if (i == back) { + x_cost[i] = 4; + y_cost[i] = 2; + } + else { + x_cost[i] = 2; + y_cost[i] = 2; + } + } + /* create routedata */ + rd = (routedata_t *) malloc(sizeof(*rd)); + memset((void *) rd, 0, sizeof(*rd)); + /* create default style */ + rd->defaultstyle.Thick = Settings.LineThickness; + rd->defaultstyle.Diameter = Settings.ViaThickness; + rd->defaultstyle.Hole = Settings.ViaDrillingHole; + rd->defaultstyle.Keepaway = Settings.Keepaway; + rd->max_bloat = BLOAT(&rd->defaultstyle); + rd->max_keep = Settings.Keepaway; + /* create styles structures */ + bbox.X1 = bbox.Y1 = 0; + bbox.X2 = PCB->MaxWidth; + bbox.Y2 = PCB->MaxHeight; + for (i = 0; i < NUM_STYLES + 1; i++) { + RouteStyleType *style = (i < NUM_STYLES) ? &PCB->RouteStyle[i] : &rd->defaultstyle; + rd->styles[i] = style; + } + + /* initialize pointerlisttype */ + for (i = 0; i < max_group; i++) { + layergroupboxes[i].Ptr = NULL; + layergroupboxes[i].PtrN = 0; + layergroupboxes[i].PtrMax = 0; + GROUP_LOOP(PCB->Data, i); + { + if (layer->LineN || layer->ArcN) + usedGroup[i] = true; + else + usedGroup[i] = false; + } + END_LOOP; + } + usedGroup[front] = true; + usedGroup[back] = true; + /* add the objects in the netlist first. + * then go and add all other objects that weren't already added + * + * this saves on searching the trees to find the nets + */ + /* use the DRCFLAG to mark objects as they are entered */ + ResetConnections(false); + Nets = CollectSubnets(false); { - x_cost[i] = 4; - y_cost[i] = 2; + routebox_t *last_net = NULL; + NETLIST_LOOP(&Nets); + { + routebox_t *last_in_net = NULL; + NET_LOOP(netlist); + { + routebox_t *last_in_subnet = NULL; + int j; + + for (j = 0; j < NUM_STYLES; j++) + if (net->Style == rd->styles[j]) + break; + CONNECTION_LOOP(net); + { + routebox_t *rb = NULL; + SET_FLAG(DRCFLAG, (PinTypePtr) connection->ptr2); + if (connection->type == LINE_TYPE) { + LineType *line = (LineType *) connection->ptr2; + + /* lines are listed at each end, so skip one */ + /* this should probably by a macro named "BUMP_LOOP" */ + n--; + + /* dice up non-straight lines into many tiny obstacles */ + if (line->Point1.X != line->Point2.X && line->Point1.Y != line->Point2.Y) { + LineType fake_line = *line; + Coord dx = (line->Point2.X - line->Point1.X); + Coord dy = (line->Point2.Y - line->Point1.Y); + int segs = MAX(ABS(dx), + ABS(dy)) / (4 * BLOAT(rd->styles[j]) + 1); + int qq; + segs = CLAMP(segs, 1, 32); /* don't go too crazy */ + dx /= segs; + dy /= segs; + for (qq = 0; qq < segs - 1; qq++) { + fake_line.Point2.X = fake_line.Point1.X + dx; + fake_line.Point2.Y = fake_line.Point1.Y + dy; + if (fake_line.Point2.X == line->Point2.X && fake_line.Point2.Y == line->Point2.Y) + break; + rb = AddLine(layergroupboxes, connection->group, &fake_line, line, rd->styles[j]); + if (last_in_subnet && rb != last_in_subnet) + MergeNets(last_in_subnet, rb, ORIGINAL); + if (last_in_net && rb != last_in_net) + MergeNets(last_in_net, rb, NET); + last_in_subnet = last_in_net = rb; + fake_line.Point1 = fake_line.Point2; + } + fake_line.Point2 = line->Point2; + rb = AddLine(layergroupboxes, connection->group, &fake_line, line, rd->styles[j]); + } + else { + rb = AddLine(layergroupboxes, connection->group, line, line, rd->styles[j]); + } + } + else + switch (connection->type) { + case PAD_TYPE: + rb = AddPad(layergroupboxes, (ElementType *) connection->ptr1, (PadType *) connection->ptr2, rd->styles[j]); + break; + case PIN_TYPE: + rb = AddPin(layergroupboxes, (PinType *) connection->ptr2, false, rd->styles[j]); + break; + case VIA_TYPE: + rb = AddPin(layergroupboxes, (PinType *) connection->ptr2, true, rd->styles[j]); + break; + case POLYGON_TYPE: + rb = + AddPolygon(layergroupboxes, + GetLayerNumber(PCB->Data, (LayerType *) connection->ptr1), + (struct polygon_st *) connection->ptr2, rd->styles[j]); + break; + } + assert(rb); + /* update circular connectivity lists */ + if (last_in_subnet && rb != last_in_subnet) + MergeNets(last_in_subnet, rb, ORIGINAL); + if (last_in_net && rb != last_in_net) + MergeNets(last_in_net, rb, NET); + last_in_subnet = last_in_net = rb; + rd->max_bloat = MAX(rd->max_bloat, BLOAT(rb->style)); + rd->max_keep = MAX(rd->max_keep, rb->style->Keepaway); + } + END_LOOP; + } + END_LOOP; + if (last_net && last_in_net) + MergeNets(last_net, last_in_net, DIFFERENT_NET); + last_net = last_in_net; + } + END_LOOP; + rd->first_net = last_net; } - else + FreeNetListListMemory(&Nets); + + /* reset all nets to "original" connectivity (which we just set) */ { - x_cost[i] = 2; - y_cost[i] = 2; + routebox_t *net; + LIST_LOOP(rd->first_net, different_net, net); + ResetSubnet(net); + END_LOOP; } - } - /* create routedata */ - rd = (routedata_t *)malloc (sizeof (*rd)); - memset ((void *) rd, 0, sizeof (*rd)); - /* create default style */ - rd->defaultstyle.Thick = Settings.LineThickness; - rd->defaultstyle.Diameter = Settings.ViaThickness; - rd->defaultstyle.Hole = Settings.ViaDrillingHole; - rd->defaultstyle.Keepaway = Settings.Keepaway; - rd->max_bloat = BLOAT (&rd->defaultstyle); - rd->max_keep = Settings.Keepaway; - /* create styles structures */ - bbox.X1 = bbox.Y1 = 0; - bbox.X2 = PCB->MaxWidth; - bbox.Y2 = PCB->MaxHeight; - for (i = 0; i < NUM_STYLES + 1; i++) - { - RouteStyleType *style = - (i < NUM_STYLES) ? &PCB->RouteStyle[i] : &rd->defaultstyle; - rd->styles[i] = style; - } - /* initialize pointerlisttype */ - for (i = 0; i < max_group; i++) - { - layergroupboxes[i].Ptr = NULL; - layergroupboxes[i].PtrN = 0; - layergroupboxes[i].PtrMax = 0; - GROUP_LOOP (PCB->Data, i); - { - if (layer->LineN || layer->ArcN) - usedGroup[i] = true; - else - usedGroup[i] = false; - } - END_LOOP; - } - usedGroup[front] = true; - usedGroup[back] = true; - /* add the objects in the netlist first. - * then go and add all other objects that weren't already added - * - * this saves on searching the trees to find the nets - */ - /* use the DRCFLAG to mark objects as they are entered */ - ResetConnections (false); - Nets = CollectSubnets (false); - { - routebox_t *last_net = NULL; - NETLIST_LOOP (&Nets); - { - routebox_t *last_in_net = NULL; - NET_LOOP (netlist); - { - routebox_t *last_in_subnet = NULL; - int j; - - for (j = 0; j < NUM_STYLES; j++) - if (net->Style == rd->styles[j]) - break; - CONNECTION_LOOP (net); + /* add pins and pads of elements */ + ALLPIN_LOOP(PCB->Data); { - routebox_t *rb = NULL; - SET_FLAG (DRCFLAG, (PinTypePtr) connection->ptr2); - if (connection->type == LINE_TYPE) - { - LineType *line = (LineType *) connection->ptr2; + if (TEST_FLAG(DRCFLAG, pin)) + CLEAR_FLAG(DRCFLAG, pin); + else + AddPin(layergroupboxes, pin, false, rd->styles[NUM_STYLES]); + } + ENDALL_LOOP; + ALLPAD_LOOP(PCB->Data); + { + if (TEST_FLAG(DRCFLAG, pad)) + CLEAR_FLAG(DRCFLAG, pad); + else + AddPad(layergroupboxes, element, pad, rd->styles[NUM_STYLES]); + } + ENDALL_LOOP; + /* add all vias */ + VIA_LOOP(PCB->Data); + { + if (TEST_FLAG(DRCFLAG, via)) + CLEAR_FLAG(DRCFLAG, via); + else + AddPin(layergroupboxes, via, true, rd->styles[NUM_STYLES]); + } + END_LOOP; - /* lines are listed at each end, so skip one */ - /* this should probably by a macro named "BUMP_LOOP" */ - n--; - - /* dice up non-straight lines into many tiny obstacles */ - if (line->Point1.X != line->Point2.X - && line->Point1.Y != line->Point2.Y) + for (i = 0; i < max_copper_layer; i++) { + int layergroup = GetLayerGroupNumberByNumber(i); + /* add all (non-rat) lines */ + LINE_LOOP(LAYER_PTR(i)); { - LineType fake_line = *line; - Coord dx = (line->Point2.X - line->Point1.X); - Coord dy = (line->Point2.Y - line->Point1.Y); - int segs = MAX (ABS (dx), - ABS (dy)) / (4 * BLOAT (rd->styles[j]) + 1); - int qq; - segs = CLAMP (segs, 1, 32); /* don't go too crazy */ - dx /= segs; - dy /= segs; - for (qq = 0; qq < segs - 1; qq++) - { - fake_line.Point2.X = fake_line.Point1.X + dx; - fake_line.Point2.Y = fake_line.Point1.Y + dy; - if (fake_line.Point2.X == line->Point2.X - && fake_line.Point2.Y == line->Point2.Y) - break; - rb = - AddLine (layergroupboxes, connection->group, - &fake_line, line, rd->styles[j]); - if (last_in_subnet && rb != last_in_subnet) - MergeNets (last_in_subnet, rb, ORIGINAL); - if (last_in_net && rb != last_in_net) - MergeNets (last_in_net, rb, NET); - last_in_subnet = last_in_net = rb; - fake_line.Point1 = fake_line.Point2; - } - fake_line.Point2 = line->Point2; - rb = - AddLine (layergroupboxes, connection->group, &fake_line, - line, rd->styles[j]); + if (TEST_FLAG(DRCFLAG, line)) { + CLEAR_FLAG(DRCFLAG, line); + continue; + } + /* dice up non-straight lines into many tiny obstacles */ + if (line->Point1.X != line->Point2.X && line->Point1.Y != line->Point2.Y) { + LineType fake_line = *line; + Coord dx = (line->Point2.X - line->Point1.X); + Coord dy = (line->Point2.Y - line->Point1.Y); + int segs = MAX(ABS(dx), ABS(dy)) / (4 * rd->max_bloat + 1); + int qq; + segs = CLAMP(segs, 1, 32); /* don't go too crazy */ + dx /= segs; + dy /= segs; + for (qq = 0; qq < segs - 1; qq++) { + fake_line.Point2.X = fake_line.Point1.X + dx; + fake_line.Point2.Y = fake_line.Point1.Y + dy; + if (fake_line.Point2.X == line->Point2.X && fake_line.Point2.Y == line->Point2.Y) + break; + AddLine(layergroupboxes, layergroup, &fake_line, line, rd->styles[NUM_STYLES]); + fake_line.Point1 = fake_line.Point2; + } + fake_line.Point2 = line->Point2; + AddLine(layergroupboxes, layergroup, &fake_line, line, rd->styles[NUM_STYLES]); + } + else { + AddLine(layergroupboxes, layergroup, line, line, rd->styles[NUM_STYLES]); + } } - else + END_LOOP; + /* add all polygons */ + POLYGON_LOOP(LAYER_PTR(i)); { - rb = - AddLine (layergroupboxes, connection->group, line, line, - rd->styles[j]); + if (TEST_FLAG(DRCFLAG, polygon)) + CLEAR_FLAG(DRCFLAG, polygon); + else + AddPolygon(layergroupboxes, i, polygon, rd->styles[NUM_STYLES]); } - } - else - switch (connection->type) - { - case PAD_TYPE: - rb = - AddPad (layergroupboxes, (ElementType *)connection->ptr1, - (PadType *)connection->ptr2, rd->styles[j]); - break; - case PIN_TYPE: - rb = - AddPin (layergroupboxes, (PinType *)connection->ptr2, false, - rd->styles[j]); - break; - case VIA_TYPE: - rb = - AddPin (layergroupboxes, (PinType *)connection->ptr2, true, - rd->styles[j]); - break; - case POLYGON_TYPE: - rb = - AddPolygon (layergroupboxes, - GetLayerNumber (PCB->Data, (LayerType *)connection->ptr1), - (struct polygon_st *)connection->ptr2, rd->styles[j]); - break; - } - assert (rb); - /* update circular connectivity lists */ - if (last_in_subnet && rb != last_in_subnet) - MergeNets (last_in_subnet, rb, ORIGINAL); - if (last_in_net && rb != last_in_net) - MergeNets (last_in_net, rb, NET); - last_in_subnet = last_in_net = rb; - rd->max_bloat = MAX (rd->max_bloat, BLOAT (rb->style)); - rd->max_keep = MAX (rd->max_keep, rb->style->Keepaway); + END_LOOP; + /* add all copper text */ + TEXT_LOOP(LAYER_PTR(i)); + { + AddText(layergroupboxes, layergroup, text, rd->styles[NUM_STYLES]); + } + END_LOOP; + /* add all arcs */ + ARC_LOOP(LAYER_PTR(i)); + { + AddArc(layergroupboxes, layergroup, arc, rd->styles[NUM_STYLES]); + } + END_LOOP; } - END_LOOP; - } - END_LOOP; - if (last_net && last_in_net) - MergeNets (last_net, last_in_net, DIFFERENT_NET); - last_net = last_in_net; - } - END_LOOP; - rd->first_net = last_net; - } - FreeNetListListMemory (&Nets); - /* reset all nets to "original" connectivity (which we just set) */ - { - routebox_t *net; - LIST_LOOP (rd->first_net, different_net, net); - ResetSubnet (net); - END_LOOP; - } + /* create r-trees from pointer lists */ + for (i = 0; i < max_group; i++) { + /* create the r-tree */ + rd->layergrouptree[i] = r_create_tree((const BoxType **) layergroupboxes[i].Ptr, layergroupboxes[i].PtrN, 1); + } - /* add pins and pads of elements */ - ALLPIN_LOOP (PCB->Data); - { - if (TEST_FLAG (DRCFLAG, pin)) - CLEAR_FLAG (DRCFLAG, pin); - else - AddPin (layergroupboxes, pin, false, rd->styles[NUM_STYLES]); - } - ENDALL_LOOP; - ALLPAD_LOOP (PCB->Data); - { - if (TEST_FLAG (DRCFLAG, pad)) - CLEAR_FLAG (DRCFLAG, pad); - else - AddPad (layergroupboxes, element, pad, rd->styles[NUM_STYLES]); - } - ENDALL_LOOP; - /* add all vias */ - VIA_LOOP (PCB->Data); - { - if (TEST_FLAG (DRCFLAG, via)) - CLEAR_FLAG (DRCFLAG, via); - else - AddPin (layergroupboxes, via, true, rd->styles[NUM_STYLES]); - } - END_LOOP; + if (AutoRouteParameters.use_vias) { + rd->mtspace = mtspace_create(); - for (i = 0; i < max_copper_layer; i++) - { - int layergroup = GetLayerGroupNumberByNumber (i); - /* add all (non-rat) lines */ - LINE_LOOP (LAYER_PTR (i)); - { - if (TEST_FLAG (DRCFLAG, line)) - { - CLEAR_FLAG (DRCFLAG, line); - continue; - } - /* dice up non-straight lines into many tiny obstacles */ - if (line->Point1.X != line->Point2.X - && line->Point1.Y != line->Point2.Y) - { - LineType fake_line = *line; - Coord dx = (line->Point2.X - line->Point1.X); - Coord dy = (line->Point2.Y - line->Point1.Y); - int segs = MAX (ABS (dx), ABS (dy)) / (4 * rd->max_bloat + 1); - int qq; - segs = CLAMP (segs, 1, 32); /* don't go too crazy */ - dx /= segs; - dy /= segs; - for (qq = 0; qq < segs - 1; qq++) - { - fake_line.Point2.X = fake_line.Point1.X + dx; - fake_line.Point2.Y = fake_line.Point1.Y + dy; - if (fake_line.Point2.X == line->Point2.X - && fake_line.Point2.Y == line->Point2.Y) - break; - AddLine (layergroupboxes, layergroup, &fake_line, line, - rd->styles[NUM_STYLES]); - fake_line.Point1 = fake_line.Point2; - } - fake_line.Point2 = line->Point2; - AddLine (layergroupboxes, layergroup, &fake_line, line, - rd->styles[NUM_STYLES]); - } - else - { - AddLine (layergroupboxes, layergroup, line, line, - rd->styles[NUM_STYLES]); - } - } - END_LOOP; - /* add all polygons */ - POLYGON_LOOP (LAYER_PTR (i)); - { - if (TEST_FLAG (DRCFLAG, polygon)) - CLEAR_FLAG (DRCFLAG, polygon); - else - AddPolygon (layergroupboxes, i, polygon, rd->styles[NUM_STYLES]); - } - END_LOOP; - /* add all copper text */ - TEXT_LOOP (LAYER_PTR (i)); - { - AddText (layergroupboxes, layergroup, text, rd->styles[NUM_STYLES]); - } - END_LOOP; - /* add all arcs */ - ARC_LOOP (LAYER_PTR (i)); - { - AddArc (layergroupboxes, layergroup, arc, rd->styles[NUM_STYLES]); - } - END_LOOP; - } - - /* create r-trees from pointer lists */ - for (i = 0; i < max_group; i++) - { - /* create the r-tree */ - rd->layergrouptree[i] = - r_create_tree ((const BoxType **) layergroupboxes[i].Ptr, - layergroupboxes[i].PtrN, 1); - } - - if (AutoRouteParameters.use_vias) - { - rd->mtspace = mtspace_create (); - - /* create "empty-space" structures for via placement (now that we know - * appropriate keepaways for all the fixed elements) */ - for (i = 0; i < max_group; i++) - { - POINTER_LOOP (&layergroupboxes[i]); - { - routebox_t *rb = (routebox_t *) * ptr; - if (!rb->flags.clear_poly) - mtspace_add (rd->mtspace, &rb->box, FIXED, rb->style->Keepaway); - } - END_LOOP; + /* create "empty-space" structures for via placement (now that we know + * appropriate keepaways for all the fixed elements) */ + for (i = 0; i < max_group; i++) { + POINTER_LOOP(&layergroupboxes[i]); + { + routebox_t *rb = (routebox_t *) * ptr; + if (!rb->flags.clear_poly) + mtspace_add(rd->mtspace, &rb->box, FIXED, rb->style->Keepaway); + } + END_LOOP; + } } - } - /* free pointer lists */ - for (i = 0; i < max_group; i++) - FreePointerListMemory (&layergroupboxes[i]); - /* done! */ - return rd; + /* free pointer lists */ + for (i = 0; i < max_group; i++) + FreePointerListMemory(&layergroupboxes[i]); + /* done! */ + return rd; } -void -DestroyRouteData (routedata_t ** rd) +void DestroyRouteData(routedata_t ** rd) { - int i; - for (i = 0; i < max_group; i++) - r_destroy_tree (&(*rd)->layergrouptree[i]); - if (AutoRouteParameters.use_vias) - mtspace_destroy (&(*rd)->mtspace); - free (*rd); - *rd = NULL; + int i; + for (i = 0; i < max_group; i++) + r_destroy_tree(&(*rd)->layergrouptree[i]); + if (AutoRouteParameters.use_vias) + mtspace_destroy(&(*rd)->mtspace); + free(*rd); + *rd = NULL; } /*----------------------------------------------------------------- @@ -1295,27 +1165,24 @@ */ /* increment the reference count on a routebox. */ -static void -RB_up_count (routebox_t * rb) +static void RB_up_count(routebox_t * rb) { - assert (rb->flags.homeless); - rb->refcount++; + assert(rb->flags.homeless); + rb->refcount++; } /* decrement the reference count on a routebox, freeing if this box becomes * unused. */ -static void -RB_down_count (routebox_t * rb) +static void RB_down_count(routebox_t * rb) { - assert (rb->type == EXPANSION_AREA); - assert (rb->flags.homeless); - assert (rb->refcount > 0); - if (--rb->refcount == 0) - { - if (rb->parent.expansion_area->flags.homeless) - RB_down_count (rb->parent.expansion_area); - free (rb); - } + assert(rb->type == EXPANSION_AREA); + assert(rb->flags.homeless); + assert(rb->refcount > 0); + if (--rb->refcount == 0) { + if (rb->parent.expansion_area->flags.homeless) + RB_down_count(rb->parent.expansion_area); + free(rb); + } } /*----------------------------------------------------------------- @@ -1322,92 +1189,79 @@ * Rectangle-expansion routing code. */ -static void -ResetSubnet (routebox_t * net) +static void ResetSubnet(routebox_t * net) { - routebox_t *rb; - /* reset connectivity of everything on this net */ - LIST_LOOP (net, same_net, rb); - rb->same_subnet = rb->original_subnet; - END_LOOP; + routebox_t *rb; + /* reset connectivity of everything on this net */ + LIST_LOOP(net, same_net, rb); + rb->same_subnet = rb->original_subnet; + END_LOOP; } -static inline cost_t -cost_to_point_on_layer (const CheapPointType * p1, - const CheapPointType * p2, Cardinal point_layer) +static inline cost_t cost_to_point_on_layer(const CheapPointType * p1, const CheapPointType * p2, Cardinal point_layer) { - cost_t x_dist = p1->X - p2->X, y_dist = p1->Y - p2->Y, r; - x_dist *= x_cost[point_layer]; - y_dist *= y_cost[point_layer]; - /* cost is proportional to orthogonal distance. */ - r = ABS (x_dist) + ABS (y_dist); - if (p1->X != p2->X && p1->Y != p2->Y) - r += AutoRouteParameters.JogPenalty; - return r; + cost_t x_dist = p1->X - p2->X, y_dist = p1->Y - p2->Y, r; + x_dist *= x_cost[point_layer]; + y_dist *= y_cost[point_layer]; + /* cost is proportional to orthogonal distance. */ + r = ABS(x_dist) + ABS(y_dist); + if (p1->X != p2->X && p1->Y != p2->Y) + r += AutoRouteParameters.JogPenalty; + return r; } -static cost_t -cost_to_point (const CheapPointType * p1, Cardinal point_layer1, - const CheapPointType * p2, Cardinal point_layer2) +static cost_t cost_to_point(const CheapPointType * p1, Cardinal point_layer1, const CheapPointType * p2, Cardinal point_layer2) { - cost_t r = cost_to_point_on_layer (p1, p2, point_layer1); - /* apply via cost penalty if layers differ */ - if (point_layer1 != point_layer2) - r += AutoRouteParameters.ViaCost; - return r; + cost_t r = cost_to_point_on_layer(p1, p2, point_layer1); + /* apply via cost penalty if layers differ */ + if (point_layer1 != point_layer2) + r += AutoRouteParameters.ViaCost; + return r; } /* return the minimum *cost* from a point to a box on any layer. * It's safe to return a smaller than minimum cost */ -static cost_t -cost_to_layerless_box (const CheapPointType * p, Cardinal point_layer, - const BoxType * b) +static cost_t cost_to_layerless_box(const CheapPointType * p, Cardinal point_layer, const BoxType * b) { - CheapPointType p2 = closest_point_in_box (p, b); - register cost_t c1, c2; + CheapPointType p2 = closest_point_in_box(p, b); + register cost_t c1, c2; - c1 = p2.X - p->X; - c2 = p2.Y - p->Y; + c1 = p2.X - p->X; + c2 = p2.Y - p->Y; - c1 = ABS (c1); - c2 = ABS (c2); - if (c1 < c2) - return c1 * AutoRouteParameters.MinPenalty + c2; - else - return c2 * AutoRouteParameters.MinPenalty + c1; + c1 = ABS(c1); + c2 = ABS(c2); + if (c1 < c2) + return c1 * AutoRouteParameters.MinPenalty + c2; + else + return c2 * AutoRouteParameters.MinPenalty + c1; } /* get to actual pins/pad target coordinates */ -bool -TargetPoint (CheapPointType * nextpoint, const routebox_t * target) +bool TargetPoint(CheapPointType * nextpoint, const routebox_t * target) { - if (target->type == PIN) - { - nextpoint->X = target->parent.pin->X; - nextpoint->Y = target->parent.pin->Y; - return true; - } - else if (target->type == PAD) - { - if (abs (target->parent.pad->Point1.X - nextpoint->X) < - abs (target->parent.pad->Point2.X - nextpoint->X)) - nextpoint->X = target->parent.pad->Point1.X; - else - nextpoint->X = target->parent.pad->Point2.X; - if (abs (target->parent.pad->Point1.Y - nextpoint->Y) < - abs (target->parent.pad->Point2.Y - nextpoint->Y)) - nextpoint->Y = target->parent.pad->Point1.Y; - else - nextpoint->Y = target->parent.pad->Point2.Y; - return true; - } - else - { - nextpoint->X = CENTER_X (target->sbox); - nextpoint->Y = CENTER_Y (target->sbox); - } - return false; + if (target->type == PIN) { + nextpoint->X = target->parent.pin->X; + nextpoint->Y = target->parent.pin->Y; + return true; + } + else if (target->type == PAD) { + if (abs(target->parent.pad->Point1.X - nextpoint->X) < abs(target->parent.pad->Point2.X - nextpoint->X)) + nextpoint->X = target->parent.pad->Point1.X; + else + nextpoint->X = target->parent.pad->Point2.X; + if (abs(target->parent.pad->Point1.Y - nextpoint->Y) < abs(target->parent.pad->Point2.Y - nextpoint->Y)) + nextpoint->Y = target->parent.pad->Point1.Y; + else + nextpoint->Y = target->parent.pad->Point2.Y; + return true; + } + else { + nextpoint->X = CENTER_X(target->sbox); + nextpoint->Y = CENTER_Y(target->sbox); + } + return false; } /* return the *minimum cost* from a point to a route box, including possible @@ -1414,174 +1268,143 @@ * via costs if the route box is on a different layer. * assume routbox is bloated unless it is an expansion area */ -static cost_t -cost_to_routebox (const CheapPointType * p, Cardinal point_layer, - const routebox_t * rb) +static cost_t cost_to_routebox(const CheapPointType * p, Cardinal point_layer, const routebox_t * rb) { - register cost_t trial = 0; - CheapPointType p2 = closest_point_in_routebox (p, rb); - if (!usedGroup[point_layer] || !usedGroup[rb->group]) - trial = AutoRouteParameters.NewLayerPenalty; - if ((p2.X - p->X) * (p2.Y - p->Y) != 0) - trial += AutoRouteParameters.JogPenalty; - /* special case for defered via searching */ - if (point_layer > max_group || point_layer == rb->group) - return trial + ABS (p2.X - p->X) + ABS (p2.Y - p->Y); - /* if this target is only a via away, then the via is cheaper than the congestion */ - if (p->X == p2.X && p->Y == p2.Y) - return trial + 1; - trial += AutoRouteParameters.ViaCost; - trial += ABS (p2.X - p->X) + ABS (p2.Y - p->Y); - return trial; + register cost_t trial = 0; + CheapPointType p2 = closest_point_in_routebox(p, rb); + if (!usedGroup[point_layer] || !usedGroup[rb->group]) + trial = AutoRouteParameters.NewLayerPenalty; + if ((p2.X - p->X) * (p2.Y - p->Y) != 0) + trial += AutoRouteParameters.JogPenalty; + /* special case for defered via searching */ + if (point_layer > max_group || point_layer == rb->group) + return trial + ABS(p2.X - p->X) + ABS(p2.Y - p->Y); + /* if this target is only a via away, then the via is cheaper than the congestion */ + if (p->X == p2.X && p->Y == p2.Y) + return trial + 1; + trial += AutoRouteParameters.ViaCost; + trial += ABS(p2.X - p->X) + ABS(p2.Y - p->Y); + return trial; } -static BoxType -bloat_routebox (routebox_t * rb) +static BoxType bloat_routebox(routebox_t * rb) { - BoxType r; - Coord keepaway; - assert (__routebox_is_good (rb)); + BoxType r; + Coord keepaway; + assert(__routebox_is_good(rb)); - if (rb->flags.nobloat) - return rb->sbox; + if (rb->flags.nobloat) + return rb->sbox; - /* Obstacle exclusion zones get bloated by the larger of - * the two required clearances plus half the track width. - */ - keepaway = MAX (AutoRouteParameters.style->Keepaway, rb->style->Keepaway); - r = bloat_box (&rb->sbox, keepaway + - HALF_THICK (AutoRouteParameters.style->Thick)); - return r; + /* Obstacle exclusion zones get bloated by the larger of + * the two required clearances plus half the track width. + */ + keepaway = MAX(AutoRouteParameters.style->Keepaway, rb->style->Keepaway); + r = bloat_box(&rb->sbox, keepaway + HALF_THICK(AutoRouteParameters.style->Thick)); + return r; } -#ifdef ROUTE_DEBUG /* only for debugging expansion areas */ +#ifdef ROUTE_DEBUG /* only for debugging expansion areas */ /* makes a line on the solder layer silk surrounding the box */ -void -showbox (BoxType b, Dimension thickness, int group) +void showbox(BoxType b, Dimension thickness, int group) { - LineTypePtr line; - LayerTypePtr SLayer = LAYER_PTR (group); - if (showboxen < -1) - return; - if (showboxen != -1 && showboxen != group) - return; + LineTypePtr line; + LayerTypePtr SLayer = LAYER_PTR(group); + if (showboxen < -1) + return; + if (showboxen != -1 && showboxen != group) + return; - if (ddraw != NULL) - { - ddraw->set_line_width (ar_gc, thickness); - ddraw->set_line_cap (ar_gc, Trace_Cap); - ddraw->set_color (ar_gc, SLayer->Color); + if (ddraw != NULL) { + ddraw->set_line_width(ar_gc, thickness); + ddraw->set_line_cap(ar_gc, Trace_Cap); + ddraw->set_color(ar_gc, SLayer->Color); - ddraw->draw_line (ar_gc, b.X1, b.Y1, b.X2, b.Y1); - ddraw->draw_line (ar_gc, b.X1, b.Y2, b.X2, b.Y2); - ddraw->draw_line (ar_gc, b.X1, b.Y1, b.X1, b.Y2); - ddraw->draw_line (ar_gc, b.X2, b.Y1, b.X2, b.Y2); - } + ddraw->draw_line(ar_gc, b.X1, b.Y1, b.X2, b.Y1); + ddraw->draw_line(ar_gc, b.X1, b.Y2, b.X2, b.Y2); + ddraw->draw_line(ar_gc, b.X1, b.Y1, b.X1, b.Y2); + ddraw->draw_line(ar_gc, b.X2, b.Y1, b.X2, b.Y2); + } #if 1 - if (b.Y1 == b.Y2 || b.X1 == b.X2) - thickness = 5; - line = CreateNewLineOnLayer (LAYER_PTR (component_silk_layer), - b.X1, b.Y1, b.X2, b.Y1, thickness, 0, - MakeFlags (0)); - AddObjectToCreateUndoList (LINE_TYPE, - LAYER_PTR (component_silk_layer), line, - line); - if (b.Y1 != b.Y2) - { - line = CreateNewLineOnLayer (LAYER_PTR (component_silk_layer), - b.X1, b.Y2, b.X2, b.Y2, thickness, 0, - MakeFlags (0)); - AddObjectToCreateUndoList (LINE_TYPE, - LAYER_PTR (component_silk_layer), - line, line); - } - line = CreateNewLineOnLayer (LAYER_PTR (component_silk_layer), - b.X1, b.Y1, b.X1, b.Y2, thickness, 0, - MakeFlags (0)); - AddObjectToCreateUndoList (LINE_TYPE, - LAYER_PTR (component_silk_layer), line, - line); - if (b.X1 != b.X2) - { - line = CreateNewLineOnLayer (LAYER_PTR (component_silk_layer), - b.X2, b.Y1, b.X2, b.Y2, thickness, 0, - MakeFlags (0)); - AddObjectToCreateUndoList (LINE_TYPE, - LAYER_PTR (component_silk_layer), - line, line); - } + if (b.Y1 == b.Y2 || b.X1 == b.X2) + thickness = 5; + line = CreateNewLineOnLayer(LAYER_PTR(component_silk_layer), b.X1, b.Y1, b.X2, b.Y1, thickness, 0, MakeFlags(0)); + AddObjectToCreateUndoList(LINE_TYPE, LAYER_PTR(component_silk_layer), line, line); + if (b.Y1 != b.Y2) { + line = CreateNewLineOnLayer(LAYER_PTR(component_silk_layer), b.X1, b.Y2, b.X2, b.Y2, thickness, 0, MakeFlags(0)); + AddObjectToCreateUndoList(LINE_TYPE, LAYER_PTR(component_silk_layer), line, line); + } + line = CreateNewLineOnLayer(LAYER_PTR(component_silk_layer), b.X1, b.Y1, b.X1, b.Y2, thickness, 0, MakeFlags(0)); + AddObjectToCreateUndoList(LINE_TYPE, LAYER_PTR(component_silk_layer), line, line); + if (b.X1 != b.X2) { + line = CreateNewLineOnLayer(LAYER_PTR(component_silk_layer), b.X2, b.Y1, b.X2, b.Y2, thickness, 0, MakeFlags(0)); + AddObjectToCreateUndoList(LINE_TYPE, LAYER_PTR(component_silk_layer), line, line); + } #endif } #endif #if defined(ROUTE_DEBUG) -static void -showedge (edge_t * e) +static void showedge(edge_t * e) { - BoxType *b = (BoxType *) e->rb; + BoxType *b = (BoxType *) e->rb; - if (ddraw == NULL) - return; + if (ddraw == NULL) + return; - ddraw->set_line_cap (ar_gc, Trace_Cap); - ddraw->set_line_width (ar_gc, 1); - ddraw->set_color (ar_gc, Settings.MaskColor); + ddraw->set_line_cap(ar_gc, Trace_Cap); + ddraw->set_line_width(ar_gc, 1); + ddraw->set_color(ar_gc, Settings.MaskColor); - switch (e->expand_dir) - { - case NORTH: - ddraw->draw_line (ar_gc, b->X1, b->Y1, b->X2, b->Y1); - break; - case SOUTH: - ddraw->draw_line (ar_gc, b->X1, b->Y2, b->X2, b->Y2); - break; - case WEST: - ddraw->draw_line (ar_gc, b->X1, b->Y1, b->X1, b->Y2); - break; - case EAST: - ddraw->draw_line (ar_gc, b->X2, b->Y1, b->X2, b->Y2); - break; - default: - break; - } + switch (e->expand_dir) { + case NORTH: + ddraw->draw_line(ar_gc, b->X1, b->Y1, b->X2, b->Y1); + break; + case SOUTH: + ddraw->draw_line(ar_gc, b->X1, b->Y2, b->X2, b->Y2); + break; + case WEST: + ddraw->draw_line(ar_gc, b->X1, b->Y1, b->X1, b->Y2); + break; + case EAST: + ddraw->draw_line(ar_gc, b->X2, b->Y1, b->X2, b->Y2); + break; + default: + break; + } } #endif #if defined(ROUTE_DEBUG) -static void -showroutebox (routebox_t * rb) +static void showroutebox(routebox_t * rb) { - showbox (rb->sbox, rb->flags.source ? 20 : (rb->flags.target ? 10 : 1), - rb->flags.is_via ? component_silk_layer : rb->group); + showbox(rb->sbox, rb->flags.source ? 20 : (rb->flags.target ? 10 : 1), rb->flags.is_via ? component_silk_layer : rb->group); } #endif /* return a "parent" of this edge which immediately precedes it in the route.*/ -static routebox_t * -route_parent (routebox_t * rb) +static routebox_t *route_parent(routebox_t * rb) { - while (rb->flags.homeless && !rb->flags.is_via && !rb->flags.is_thermal) - { - assert (rb->type == EXPANSION_AREA); - rb = rb->parent.expansion_area; - assert (rb); - } - return rb; + while (rb->flags.homeless && !rb->flags.is_via && !rb->flags.is_thermal) { + assert(rb->type == EXPANSION_AREA); + rb = rb->parent.expansion_area; + assert(rb); + } + return rb; } -static vector_t * -path_conflicts (routebox_t * rb, routebox_t * conflictor, bool branch) +static vector_t *path_conflicts(routebox_t * rb, routebox_t * conflictor, bool branch) { - if (branch) - rb->conflicts_with = vector_duplicate (rb->conflicts_with); - else if (!rb->conflicts_with) - rb->conflicts_with = vector_create (); - vector_append (rb->conflicts_with, conflictor); - return rb->conflicts_with; + if (branch) + rb->conflicts_with = vector_duplicate(rb->conflicts_with); + else if (!rb->conflicts_with) + rb->conflicts_with = vector_create(); + vector_append(rb->conflicts_with, conflictor); + return rb->conflicts_with; } /* Touch everything (except fixed) on each net found @@ -1596,270 +1419,228 @@ * than once */ -static void -touch_conflicts (vector_t * conflicts, int touch) +static void touch_conflicts(vector_t * conflicts, int touch) { - static vector_t *last = NULL; - static int last_size = 0; - int i, n; - i = 0; - if (touch) - { - if (last && conflicts != last) - touch_conflicts (last, 0); - if (!conflicts) - return; - last = conflicts; - i = last_size; - } - n = vector_size (conflicts); - for (; i < n; i++) - { - routebox_t *rb = (routebox_t *) vector_element (conflicts, i); - routebox_t *p; - LIST_LOOP (rb, same_net, p); - if (!p->flags.fixed) - p->flags.touched = touch; - END_LOOP; - } - if (!touch) - { - last = NULL; - last_size = 0; - } - else - last_size = n; + static vector_t *last = NULL; + static int last_size = 0; + int i, n; + i = 0; + if (touch) { + if (last && conflicts != last) + touch_conflicts(last, 0); + if (!conflicts) + return; + last = conflicts; + i = last_size; + } + n = vector_size(conflicts); + for (; i < n; i++) { + routebox_t *rb = (routebox_t *) vector_element(conflicts, i); + routebox_t *p; + LIST_LOOP(rb, same_net, p); + if (!p->flags.fixed) + p->flags.touched = touch; + END_LOOP; + } + if (!touch) { + last = NULL; + last_size = 0; + } + else + last_size = n; } /* return a "parent" of this edge which resides in a r-tree somewhere */ /* -- actually, this "parent" *may* be a via box, which doesn't live in * a r-tree. -- */ -static routebox_t * -nonhomeless_parent (routebox_t * rb) +static routebox_t *nonhomeless_parent(routebox_t * rb) { - return route_parent (rb); + return route_parent(rb); } /* some routines to find the minimum *cost* from a cost point to * a target (any target) */ -struct mincost_target_closure -{ - const CheapPointType *CostPoint; - Cardinal CostPointLayer; - routebox_t *nearest; - cost_t nearest_cost; +struct mincost_target_closure { + const CheapPointType *CostPoint; + Cardinal CostPointLayer; + routebox_t *nearest; + cost_t nearest_cost; }; -static int -__region_within_guess (const BoxType * region, void *cl) +static int __region_within_guess(const BoxType * region, void *cl) { - struct mincost_target_closure *mtc = (struct mincost_target_closure *) cl; - cost_t cost_to_region; - if (mtc->nearest == NULL) - return 1; - cost_to_region = - cost_to_layerless_box (mtc->CostPoint, mtc->CostPointLayer, region); - assert (cost_to_region >= 0); - /* if no guess yet, all regions are "close enough" */ - /* note that cost is *strictly more* than minimum distance, so we'll - * always search a region large enough. */ - return (cost_to_region < mtc->nearest_cost); + struct mincost_target_closure *mtc = (struct mincost_target_closure *) cl; + cost_t cost_to_region; + if (mtc->nearest == NULL) + return 1; + cost_to_region = cost_to_layerless_box(mtc->CostPoint, mtc->CostPointLayer, region); + assert(cost_to_region >= 0); + /* if no guess yet, all regions are "close enough" */ + /* note that cost is *strictly more* than minimum distance, so we'll + * always search a region large enough. */ + return (cost_to_region < mtc->nearest_cost); } -static int -__found_new_guess (const BoxType * box, void *cl) + +static int __found_new_guess(const BoxType * box, void *cl) { - struct mincost_target_closure *mtc = (struct mincost_target_closure *) cl; - routebox_t *guess = (routebox_t *) box; - cost_t cost_to_guess = - cost_to_routebox (mtc->CostPoint, mtc->CostPointLayer, guess); - assert (cost_to_guess >= 0); - /* if this is cheaper than previous guess... */ - if (cost_to_guess < mtc->nearest_cost) - { - mtc->nearest = guess; - mtc->nearest_cost = cost_to_guess; /* this is our new guess! */ - return 1; - } - else - return 0; /* not less expensive than our last guess */ + struct mincost_target_closure *mtc = (struct mincost_target_closure *) cl; + routebox_t *guess = (routebox_t *) box; + cost_t cost_to_guess = cost_to_routebox(mtc->CostPoint, mtc->CostPointLayer, guess); + assert(cost_to_guess >= 0); + /* if this is cheaper than previous guess... */ + if (cost_to_guess < mtc->nearest_cost) { + mtc->nearest = guess; + mtc->nearest_cost = cost_to_guess; /* this is our new guess! */ + return 1; + } + else + return 0; /* not less expensive than our last guess */ } /* target_guess is our guess at what the nearest target is, or NULL if we * just plum don't have a clue. */ -static routebox_t * -mincost_target_to_point (const CheapPointType * CostPoint, - Cardinal CostPointLayer, - rtree_t * targets, routebox_t * target_guess) +static routebox_t *mincost_target_to_point(const CheapPointType * CostPoint, + Cardinal CostPointLayer, rtree_t * targets, routebox_t * target_guess) { - struct mincost_target_closure mtc; - assert (target_guess == NULL || target_guess->flags.target); /* this is a target, right? */ - mtc.CostPoint = CostPoint; - mtc.CostPointLayer = CostPointLayer; - mtc.nearest = target_guess; - if (mtc.nearest) - mtc.nearest_cost = - cost_to_routebox (mtc.CostPoint, mtc.CostPointLayer, mtc.nearest); - else - mtc.nearest_cost = EXPENSIVE; - r_search (targets, NULL, __region_within_guess, __found_new_guess, &mtc); - assert (mtc.nearest != NULL && mtc.nearest_cost >= 0); - assert (mtc.nearest->flags.target); /* this is a target, right? */ - return mtc.nearest; + struct mincost_target_closure mtc; + assert(target_guess == NULL || target_guess->flags.target); /* this is a target, right? */ + mtc.CostPoint = CostPoint; + mtc.CostPointLayer = CostPointLayer; + mtc.nearest = target_guess; + if (mtc.nearest) + mtc.nearest_cost = cost_to_routebox(mtc.CostPoint, mtc.CostPointLayer, mtc.nearest); + else + mtc.nearest_cost = EXPENSIVE; + r_search(targets, NULL, __region_within_guess, __found_new_guess, &mtc); + assert(mtc.nearest != NULL && mtc.nearest_cost >= 0); + assert(mtc.nearest->flags.target); /* this is a target, right? */ + return mtc.nearest; } /* create edge from field values */ /* mincost_target_guess can be NULL */ -static edge_t * -CreateEdge (routebox_t * rb, - Coord CostPointX, Coord CostPointY, - cost_t cost_to_point, - routebox_t * mincost_target_guess, - direction_t expand_dir, rtree_t * targets) +static edge_t *CreateEdge(routebox_t * rb, + Coord CostPointX, Coord CostPointY, + cost_t cost_to_point, routebox_t * mincost_target_guess, direction_t expand_dir, rtree_t * targets) { - edge_t *e; - assert (__routebox_is_good (rb)); - e = (edge_t *)malloc (sizeof (*e)); - memset ((void *) e, 0, sizeof (*e)); - assert (e); - e->rb = rb; - if (rb->flags.homeless) - RB_up_count (rb); - e->cost_point.X = CostPointX; - e->cost_point.Y = CostPointY; - e->cost_to_point = cost_to_point; - e->flags.via_search = 0; - /* if this edge is created in response to a target, use it */ - if (targets) - e->mincost_target = - mincost_target_to_point (&e->cost_point, rb->group, - targets, mincost_target_guess); - else - e->mincost_target = mincost_target_guess; - e->expand_dir = expand_dir; - assert (e->rb && e->mincost_target); /* valid edge? */ - assert (!e->flags.is_via || e->expand_dir == ALL); - /* cost point should be on edge (unless this is a plane/via/conflict edge) */ + edge_t *e; + assert(__routebox_is_good(rb)); + e = (edge_t *) malloc(sizeof(*e)); + memset((void *) e, 0, sizeof(*e)); + assert(e); + e->rb = rb; + if (rb->flags.homeless) + RB_up_count(rb); + e->cost_point.X = CostPointX; + e->cost_point.Y = CostPointY; + e->cost_to_point = cost_to_point; + e->flags.via_search = 0; + /* if this edge is created in response to a target, use it */ + if (targets) + e->mincost_target = mincost_target_to_point(&e->cost_point, rb->group, targets, mincost_target_guess); + else + e->mincost_target = mincost_target_guess; + e->expand_dir = expand_dir; + assert(e->rb && e->mincost_target); /* valid edge? */ + assert(!e->flags.is_via || e->expand_dir == ALL); + /* cost point should be on edge (unless this is a plane/via/conflict edge) */ #if 0 - assert (rb->type == PLANE || rb->conflicts_with != NULL || rb->flags.is_via - || rb->flags.is_thermal - || ((expand_dir == NORTH || expand_dir == SOUTH) ? rb->sbox.X1 <= - CostPointX && CostPointX < rb->sbox.X2 - && CostPointY == (expand_dir == - NORTH ? rb->sbox.Y1 : rb->sbox.Y2 - 1) : - /* expand_dir==EAST || expand_dir==WEST */ - rb->sbox.Y1 <= CostPointY && CostPointY < rb->sbox.Y2 && - CostPointX == (expand_dir == - EAST ? rb->sbox.X2 - 1 : rb->sbox.X1))); + assert(rb->type == PLANE || rb->conflicts_with != NULL || rb->flags.is_via + || rb->flags.is_thermal + || ((expand_dir == NORTH || expand_dir == SOUTH) ? rb->sbox.X1 <= + CostPointX && CostPointX < rb->sbox.X2 && CostPointY == (expand_dir == NORTH ? rb->sbox.Y1 : rb->sbox.Y2 - 1) : + /* expand_dir==EAST || expand_dir==WEST */ + rb->sbox.Y1 <= CostPointY && CostPointY < rb->sbox.Y2 && + CostPointX == (expand_dir == EAST ? rb->sbox.X2 - 1 : rb->sbox.X1))); #endif - assert (__edge_is_good (e)); - /* done */ - return e; + assert(__edge_is_good(e)); + /* done */ + return e; } /* create edge, using previous edge to fill in defaults. */ /* most of the work here is in determining a new cost point */ -static edge_t * -CreateEdge2 (routebox_t * rb, direction_t expand_dir, - edge_t * previous_edge, rtree_t * targets, routebox_t * guess) +static edge_t *CreateEdge2(routebox_t * rb, direction_t expand_dir, + edge_t * previous_edge, rtree_t * targets, routebox_t * guess) { - BoxType thisbox; - CheapPointType thiscost, prevcost; - cost_t d; + BoxType thisbox; + CheapPointType thiscost, prevcost; + cost_t d; - assert (rb && previous_edge); - /* okay, find cheapest costpoint to costpoint of previous edge */ - thisbox = edge_to_box (rb, expand_dir); - prevcost = previous_edge->cost_point; - /* find point closest to target */ - thiscost = closest_point_in_box (&prevcost, &thisbox); - /* compute cost-to-point */ - d = cost_to_point_on_layer (&prevcost, &thiscost, rb->group); - /* add in jog penalty */ - if (previous_edge->expand_dir != expand_dir) - d += AutoRouteParameters.JogPenalty; - /* okay, new edge! */ - return CreateEdge (rb, thiscost.X, thiscost.Y, - previous_edge->cost_to_point + d, - guess ? guess : previous_edge->mincost_target, - expand_dir, targets); + assert(rb && previous_edge); + /* okay, find cheapest costpoint to costpoint of previous edge */ + thisbox = edge_to_box(rb, expand_dir); + prevcost = previous_edge->cost_point; + /* find point closest to target */ + thiscost = closest_point_in_box(&prevcost, &thisbox); + /* compute cost-to-point */ + d = cost_to_point_on_layer(&prevcost, &thiscost, rb->group); + /* add in jog penalty */ + if (previous_edge->expand_dir != expand_dir) + d += AutoRouteParameters.JogPenalty; + /* okay, new edge! */ + return CreateEdge(rb, thiscost.X, thiscost.Y, + previous_edge->cost_to_point + d, guess ? guess : previous_edge->mincost_target, expand_dir, targets); } /* create via edge, using previous edge to fill in defaults. */ -static edge_t * -CreateViaEdge (const BoxType * area, Cardinal group, - routebox_t * parent, edge_t * previous_edge, - conflict_t to_site_conflict, - conflict_t through_site_conflict, rtree_t * targets) +static edge_t *CreateViaEdge(const BoxType * area, Cardinal group, + routebox_t * parent, edge_t * previous_edge, + conflict_t to_site_conflict, conflict_t through_site_conflict, rtree_t * targets) { - routebox_t *rb; - CheapPointType costpoint; - cost_t d; - edge_t *ne; - cost_t scale[3]; + routebox_t *rb; + CheapPointType costpoint; + cost_t d; + edge_t *ne; + cost_t scale[3]; - scale[0] = 1; - scale[1] = AutoRouteParameters.LastConflictPenalty; - scale[2] = AutoRouteParameters.ConflictPenalty; + scale[0] = 1; + scale[1] = AutoRouteParameters.LastConflictPenalty; + scale[2] = AutoRouteParameters.ConflictPenalty; - assert (box_is_good (area)); - assert (AutoRouteParameters.with_conflicts || - (to_site_conflict == NO_CONFLICT && - through_site_conflict == NO_CONFLICT)); - rb = CreateExpansionArea (area, group, parent, true, previous_edge); - rb->flags.is_via = 1; - rb->came_from = ALL; + assert(box_is_good(area)); + assert(AutoRouteParameters.with_conflicts || (to_site_conflict == NO_CONFLICT && through_site_conflict == NO_CONFLICT)); + rb = CreateExpansionArea(area, group, parent, true, previous_edge); + rb->flags.is_via = 1; + rb->came_from = ALL; #if defined(ROUTE_DEBUG) && defined(DEBUG_SHOW_VIA_BOXES) - showroutebox (rb); + showroutebox(rb); #endif /* ROUTE_DEBUG && DEBUG_SHOW_VIA_BOXES */ - /* for planes, choose a point near the target */ - if (previous_edge->flags.in_plane) - { - routebox_t *target; - CheapPointType pnt; - /* find a target near this via box */ - pnt.X = CENTER_X (*area); - pnt.Y = CENTER_Y (*area); - target = mincost_target_to_point (&pnt, rb->group, - targets, - previous_edge->mincost_target); - /* now find point near the target */ - pnt.X = CENTER_X (target->box); - pnt.Y = CENTER_Y (target->box); - costpoint = closest_point_in_routebox (&pnt, rb); - /* we moved from the previous cost point through the plane which is free travel */ - d = - (scale[through_site_conflict] * - cost_to_point (&costpoint, group, &costpoint, - previous_edge->rb->group)); - ne = - CreateEdge (rb, costpoint.X, costpoint.Y, - previous_edge->cost_to_point + d, target, ALL, NULL); - ne->mincost_target = target; - } - else - { - routebox_t *target; - target = previous_edge->mincost_target; - costpoint = closest_point_in_routebox (&previous_edge->cost_point, rb); - d = - (scale[to_site_conflict] * - cost_to_point_on_layer (&costpoint, &previous_edge->cost_point, - previous_edge->rb->group)) + - (scale[through_site_conflict] * - cost_to_point (&costpoint, group, &costpoint, - previous_edge->rb->group)); - /* if the target is just this via away, then this via is cheaper */ - if (target->group == group && - point_in_shrunk_box (target, costpoint.X, costpoint.Y)) - d -= AutoRouteParameters.ViaCost / 2; - ne = - CreateEdge (rb, costpoint.X, costpoint.Y, - previous_edge->cost_to_point + d, - previous_edge->mincost_target, ALL, targets); - } - ne->flags.is_via = 1; - ne->flags.via_conflict_level = to_site_conflict; - assert (__edge_is_good (ne)); - return ne; + /* for planes, choose a point near the target */ + if (previous_edge->flags.in_plane) { + routebox_t *target; + CheapPointType pnt; + /* find a target near this via box */ + pnt.X = CENTER_X(*area); + pnt.Y = CENTER_Y(*area); + target = mincost_target_to_point(&pnt, rb->group, targets, previous_edge->mincost_target); + /* now find point near the target */ + pnt.X = CENTER_X(target->box); + pnt.Y = CENTER_Y(target->box); + costpoint = closest_point_in_routebox(&pnt, rb); + /* we moved from the previous cost point through the plane which is free travel */ + d = (scale[through_site_conflict] * cost_to_point(&costpoint, group, &costpoint, previous_edge->rb->group)); + ne = CreateEdge(rb, costpoint.X, costpoint.Y, previous_edge->cost_to_point + d, target, ALL, NULL); + ne->mincost_target = target; + } + else { + routebox_t *target; + target = previous_edge->mincost_target; + costpoint = closest_point_in_routebox(&previous_edge->cost_point, rb); + d = + (scale[to_site_conflict] * + cost_to_point_on_layer(&costpoint, &previous_edge->cost_point, + previous_edge->rb->group)) + + (scale[through_site_conflict] * cost_to_point(&costpoint, group, &costpoint, previous_edge->rb->group)); + /* if the target is just this via away, then this via is cheaper */ + if (target->group == group && point_in_shrunk_box(target, costpoint.X, costpoint.Y)) + d -= AutoRouteParameters.ViaCost / 2; + ne = + CreateEdge(rb, costpoint.X, costpoint.Y, previous_edge->cost_to_point + d, previous_edge->mincost_target, ALL, targets); + } + ne->flags.is_via = 1; + ne->flags.via_conflict_level = to_site_conflict; + assert(__edge_is_good(ne)); + return ne; } /* create "interior" edge for routing with conflicts */ @@ -1868,162 +1649,143 @@ * it will become available if the conflict is elliminated. * That is why we ignore the interior_edge argument. */ -static edge_t * -CreateEdgeWithConflicts (const BoxType * interior_edge, - routebox_t * container, edge_t * previous_edge, - cost_t cost_penalty_to_box, rtree_t * targets) +static edge_t *CreateEdgeWithConflicts(const BoxType * interior_edge, + routebox_t * container, edge_t * previous_edge, + cost_t cost_penalty_to_box, rtree_t * targets) { - routebox_t *rb; - CheapPointType costpoint; - cost_t d; - edge_t *ne; - assert (interior_edge && container && previous_edge && targets); - assert (!container->flags.homeless); - assert (AutoRouteParameters.with_conflicts); - assert (container->flags.touched == 0); - assert (previous_edge->rb->group == container->group); - /* use the caller's idea of what this box should be */ - rb = - CreateExpansionArea (interior_edge, previous_edge->rb->group, - previous_edge->rb, true, previous_edge); - path_conflicts (rb, container, true); /* crucial! */ - costpoint = - closest_point_in_box (&previous_edge->cost_point, interior_edge); - d = - cost_to_point_on_layer (&costpoint, &previous_edge->cost_point, - previous_edge->rb->group); - d *= cost_penalty_to_box; - d += previous_edge->cost_to_point; - ne = CreateEdge (rb, costpoint.X, costpoint.Y, d, NULL, ALL, targets); - ne->flags.is_interior = 1; - assert (__edge_is_good (ne)); - return ne; + routebox_t *rb; + CheapPointType costpoint; + cost_t d; + edge_t *ne; + assert(interior_edge && container && previous_edge && targets); + assert(!container->flags.homeless); + assert(AutoRouteParameters.with_conflicts); + assert(container->flags.touched == 0); + assert(previous_edge->rb->group == container->group); + /* use the caller's idea of what this box should be */ + rb = CreateExpansionArea(interior_edge, previous_edge->rb->group, previous_edge->rb, true, previous_edge); + path_conflicts(rb, container, true); /* crucial! */ + costpoint = closest_point_in_box(&previous_edge->cost_point, interior_edge); + d = cost_to_point_on_layer(&costpoint, &previous_edge->cost_point, previous_edge->rb->group); + d *= cost_penalty_to_box; + d += previous_edge->cost_to_point; + ne = CreateEdge(rb, costpoint.X, costpoint.Y, d, NULL, ALL, targets); + ne->flags.is_interior = 1; + assert(__edge_is_good(ne)); + return ne; } -static void -KillEdge (void *edge) +static void KillEdge(void *edge) { - edge_t *e = (edge_t *) edge; - assert (e); - if (e->rb->flags.homeless) - RB_down_count (e->rb); - if (e->flags.via_search) - mtsFreeWork (&e->work); - free (e); + edge_t *e = (edge_t *) edge; + assert(e); + if (e->rb->flags.homeless) + RB_down_count(e->rb); + if (e->flags.via_search) + mtsFreeWork(&e->work); + free(e); } -static void -DestroyEdge (edge_t ** e) +static void DestroyEdge(edge_t ** e) { - assert (e && *e); - KillEdge (*e); - *e = NULL; + assert(e && *e); + KillEdge(*e); + *e = NULL; } /* cost function for an edge. */ -static cost_t -edge_cost (const edge_t * e, const cost_t too_big) +static cost_t edge_cost(const edge_t * e, const cost_t too_big) { - cost_t penalty = e->cost_to_point; - if (e->rb->flags.is_thermal || e->rb->type == PLANE) - return penalty; /* thermals are cheap */ - if (penalty > too_big) - return penalty; + cost_t penalty = e->cost_to_point; + if (e->rb->flags.is_thermal || e->rb->type == PLANE) + return penalty; /* thermals are cheap */ + if (penalty > too_big) + return penalty; - /* cost_to_routebox adds in our via correction, too. */ - return penalty + - cost_to_routebox (&e->cost_point, e->rb->group, e->mincost_target); + /* cost_to_routebox adds in our via correction, too. */ + return penalty + cost_to_routebox(&e->cost_point, e->rb->group, e->mincost_target); } /* given an edge of a box, return a box containing exactly the points on that * edge. Note that the return box is treated as closed; that is, the bottom and * right "edges" consist of points (just barely) not in the (half-open) box. */ -static BoxType -edge_to_box (const routebox_t * rb, direction_t expand_dir) +static BoxType edge_to_box(const routebox_t * rb, direction_t expand_dir) { - BoxType b = shrink_routebox (rb); - /* narrow box down to just the appropriate edge */ - switch (expand_dir) - { - case NORTH: - b.Y2 = b.Y1 + 1; - break; - case EAST: - b.X1 = b.X2 - 1; - break; - case SOUTH: - b.Y1 = b.Y2 - 1; - break; - case WEST: - b.X2 = b.X1 + 1; - break; - default: - assert (0); - } - /* done! */ - return b; + BoxType b = shrink_routebox(rb); + /* narrow box down to just the appropriate edge */ + switch (expand_dir) { + case NORTH: + b.Y2 = b.Y1 + 1; + break; + case EAST: + b.X1 = b.X2 - 1; + break; + case SOUTH: + b.Y1 = b.Y2 - 1; + break; + case WEST: + b.X2 = b.X1 + 1; + break; + default: + assert(0); + } + /* done! */ + return b; } -struct broken_boxes -{ - BoxType left, center, right; - bool is_valid_left, is_valid_center, is_valid_right; +struct broken_boxes { + BoxType left, center, right; + bool is_valid_left, is_valid_center, is_valid_right; }; -static struct broken_boxes -break_box_edge (const BoxType * original, direction_t which_edge, - routebox_t * breaker) +static struct broken_boxes break_box_edge(const BoxType * original, direction_t which_edge, routebox_t * breaker) { - BoxType origbox, breakbox; - struct broken_boxes result; + BoxType origbox, breakbox; + struct broken_boxes result; - assert (original && breaker); + assert(original && breaker); - origbox = *original; - breakbox = bloat_routebox (breaker); - ROTATEBOX_TO_NORTH (origbox, which_edge); - ROTATEBOX_TO_NORTH (breakbox, which_edge); - result.right.Y1 = result.center.Y1 = result.left.Y1 = origbox.Y1; - result.right.Y2 = result.center.Y2 = result.left.Y2 = origbox.Y1 + 1; - /* validity of breaker is not important because the boxes are marked invalid */ - /*assert (breakbox.X1 <= origbox.X2 && breakbox.X2 >= origbox.X1);*/ - /* left edge piece */ - result.left.X1 = origbox.X1; - result.left.X2 = breakbox.X1; - /* center (ie blocked) edge piece */ - result.center.X1 = MAX (breakbox.X1, origbox.X1); - result.center.X2 = MIN (breakbox.X2, origbox.X2); - /* right edge piece */ - result.right.X1 = breakbox.X2; - result.right.X2 = origbox.X2; - /* validity: */ - result.is_valid_left = (result.left.X1 < result.left.X2); - result.is_valid_center = (result.center.X1 < result.center.X2); - result.is_valid_right = (result.right.X1 < result.right.X2); - /* rotate back */ - ROTATEBOX_FROM_NORTH (result.left, which_edge); - ROTATEBOX_FROM_NORTH (result.center, which_edge); - ROTATEBOX_FROM_NORTH (result.right, which_edge); - /* done */ - return result; + origbox = *original; + breakbox = bloat_routebox(breaker); + ROTATEBOX_TO_NORTH(origbox, which_edge); + ROTATEBOX_TO_NORTH(breakbox, which_edge); + result.right.Y1 = result.center.Y1 = result.left.Y1 = origbox.Y1; + result.right.Y2 = result.center.Y2 = result.left.Y2 = origbox.Y1 + 1; + /* validity of breaker is not important because the boxes are marked invalid */ + /*assert (breakbox.X1 <= origbox.X2 && breakbox.X2 >= origbox.X1); */ + /* left edge piece */ + result.left.X1 = origbox.X1; + result.left.X2 = breakbox.X1; + /* center (ie blocked) edge piece */ + result.center.X1 = MAX(breakbox.X1, origbox.X1); + result.center.X2 = MIN(breakbox.X2, origbox.X2); + /* right edge piece */ + result.right.X1 = breakbox.X2; + result.right.X2 = origbox.X2; + /* validity: */ + result.is_valid_left = (result.left.X1 < result.left.X2); + result.is_valid_center = (result.center.X1 < result.center.X2); + result.is_valid_right = (result.right.X1 < result.right.X2); + /* rotate back */ + ROTATEBOX_FROM_NORTH(result.left, which_edge); + ROTATEBOX_FROM_NORTH(result.center, which_edge); + ROTATEBOX_FROM_NORTH(result.right, which_edge); + /* done */ + return result; } #ifndef NDEBUG -static int -share_edge (const BoxType * child, const BoxType * parent) +static int share_edge(const BoxType * child, const BoxType * parent) { - return - (child->X1 == parent->X2 || child->X2 == parent->X1 || - child->Y1 == parent->Y2 || child->Y2 == parent->Y1) && - ((parent->X1 <= child->X1 && child->X2 <= parent->X2) || - (parent->Y1 <= child->Y1 && child->Y2 <= parent->Y2)); + return + (child->X1 == parent->X2 || child->X2 == parent->X1 || + child->Y1 == parent->Y2 || child->Y2 == parent->Y1) && + ((parent->X1 <= child->X1 && child->X2 <= parent->X2) || (parent->Y1 <= child->Y1 && child->Y2 <= parent->Y2)); } -static int -edge_intersect (const BoxType * child, const BoxType * parent) + +static int edge_intersect(const BoxType * child, const BoxType * parent) { - return - (child->X1 <= parent->X2) && (child->X2 >= parent->X1) && - (child->Y1 <= parent->Y2) && (child->Y2 >= parent->Y1); + return (child->X1 <= parent->X2) && (child->X2 >= parent->X1) && (child->Y1 <= parent->Y2) && (child->Y2 >= parent->Y1); } #endif @@ -2031,53 +1793,48 @@ * immediately preceding expansion area, for backtracing. 'lastarea' is * the last expansion area created, we string these together in a loop * so we can remove them all easily at the end. */ -static routebox_t * -CreateExpansionArea (const BoxType * area, Cardinal group, - routebox_t * parent, - bool relax_edge_requirements, edge_t * src_edge) +static routebox_t *CreateExpansionArea(const BoxType * area, Cardinal group, + routebox_t * parent, bool relax_edge_requirements, edge_t * src_edge) { - routebox_t *rb = (routebox_t *) malloc (sizeof (*rb)); - memset ((void *) rb, 0, sizeof (*rb)); - assert (area && parent); - init_const_box (rb, area->X1, area->Y1, area->X2, area->Y2, 0); - rb->group = group; - rb->type = EXPANSION_AREA; - /* should always share edge or overlap with parent */ - assert (relax_edge_requirements ? box_intersect (&rb->sbox, &parent->sbox) - : share_edge (&rb->sbox, &parent->sbox)); - rb->parent.expansion_area = route_parent (parent); - rb->cost_point = - closest_point_in_box (&rb->parent.expansion_area->cost_point, area); - rb->cost = - rb->parent.expansion_area->cost + - cost_to_point_on_layer (&rb->parent.expansion_area->cost_point, - &rb->cost_point, rb->group); - assert (relax_edge_requirements ? edge_intersect (&rb->sbox, &parent->sbox) - : share_edge (&rb->sbox, &parent->sbox)); - if (rb->parent.expansion_area->flags.homeless) - RB_up_count (rb->parent.expansion_area); - rb->flags.homeless = 1; - rb->flags.nobloat = 1; - rb->style = AutoRouteParameters.style; - rb->conflicts_with = parent->conflicts_with; + routebox_t *rb = (routebox_t *) malloc(sizeof(*rb)); + memset((void *) rb, 0, sizeof(*rb)); + assert(area && parent); + init_const_box(rb, area->X1, area->Y1, area->X2, area->Y2, 0); + rb->group = group; + rb->type = EXPANSION_AREA; + /* should always share edge or overlap with parent */ + assert(relax_edge_requirements ? box_intersect(&rb->sbox, &parent->sbox) + : share_edge(&rb->sbox, &parent->sbox)); + rb->parent.expansion_area = route_parent(parent); + rb->cost_point = closest_point_in_box(&rb->parent.expansion_area->cost_point, area); + rb->cost = + rb->parent.expansion_area->cost + + cost_to_point_on_layer(&rb->parent.expansion_area->cost_point, &rb->cost_point, rb->group); + assert(relax_edge_requirements ? edge_intersect(&rb->sbox, &parent->sbox) + : share_edge(&rb->sbox, &parent->sbox)); + if (rb->parent.expansion_area->flags.homeless) + RB_up_count(rb->parent.expansion_area); + rb->flags.homeless = 1; + rb->flags.nobloat = 1; + rb->style = AutoRouteParameters.style; + rb->conflicts_with = parent->conflicts_with; /* we will never link an EXPANSION_AREA into the nets because they * are *ONLY* used for path searching. No need to call InitLists () */ - rb->came_from = src_edge->expand_dir; + rb->came_from = src_edge->expand_dir; #if defined(ROUTE_DEBUG) && defined(DEBUG_SHOW_EXPANSION_BOXES) - showroutebox (rb); + showroutebox(rb); #endif /* ROUTE_DEBUG && DEBUG_SHOW_EXPANSION_BOXES */ - return rb; + return rb; } /*------ Expand ------*/ -struct E_result -{ - routebox_t *parent; - routebox_t *n, *e, *s, *w; - Coord keep, bloat; - BoxType inflated, orig; - int done; +struct E_result { + routebox_t *parent; + routebox_t *n, *e, *s, *w; + Coord keep, bloat; + BoxType inflated, orig; + int done; }; /* test method for Expand() @@ -2086,152 +1843,130 @@ * like it wouldn't be seen. We do this while keep the inflated * box as large as possible. */ -static int -__Expand_this_rect (const BoxType * box, void *cl) +static int __Expand_this_rect(const BoxType * box, void *cl) { - struct E_result *res = (struct E_result *) cl; - routebox_t *rb = (routebox_t *) box; - BoxType rbox; - Coord dn, de, ds, dw, bloat; + struct E_result *res = (struct E_result *) cl; + routebox_t *rb = (routebox_t *) box; + BoxType rbox; + Coord dn, de, ds, dw, bloat; - /* we don't see conflicts already encountered */ - if (rb->flags.touched) - return 0; + /* we don't see conflicts already encountered */ + if (rb->flags.touched) + return 0; - /* The inflated box outer edges include its own - * track width plus its own keepaway. - * - * To check for intersection, we need to expand - * anything with greater keepaway by its excess - * keepaway. - * - * If something has nobloat then we need to shrink - * the inflated box back and see if it still touches. - */ + /* The inflated box outer edges include its own + * track width plus its own keepaway. + * + * To check for intersection, we need to expand + * anything with greater keepaway by its excess + * keepaway. + * + * If something has nobloat then we need to shrink + * the inflated box back and see if it still touches. + */ - if (rb->flags.nobloat) - { - rbox = rb->sbox; - bloat = res->bloat; - if (rbox.X2 <= res->inflated.X1 + bloat || - rbox.X1 >= res->inflated.X2 - bloat || - rbox.Y1 >= res->inflated.Y2 - bloat || - rbox.Y2 <= res->inflated.Y1 + bloat) - return 0; /* doesn't touch */ - } - else - { - if (rb->style->Keepaway > res->keep) - rbox = bloat_box (&rb->sbox, rb->style->Keepaway - res->keep); - else - rbox = rb->sbox; + if (rb->flags.nobloat) { + rbox = rb->sbox; + bloat = res->bloat; + if (rbox.X2 <= res->inflated.X1 + bloat || + rbox.X1 >= res->inflated.X2 - bloat || rbox.Y1 >= res->inflated.Y2 - bloat || rbox.Y2 <= res->inflated.Y1 + bloat) + return 0; /* doesn't touch */ + } + else { + if (rb->style->Keepaway > res->keep) + rbox = bloat_box(&rb->sbox, rb->style->Keepaway - res->keep); + else + rbox = rb->sbox; - if (rbox.X2 <= res->inflated.X1 || rbox.X1 >= res->inflated.X2 - || rbox.Y1 >= res->inflated.Y2 || rbox.Y2 <= res->inflated.Y1) - return 0; /* doesn't touch */ - bloat = 0; - } + if (rbox.X2 <= res->inflated.X1 || rbox.X1 >= res->inflated.X2 + || rbox.Y1 >= res->inflated.Y2 || rbox.Y2 <= res->inflated.Y1) + return 0; /* doesn't touch */ + bloat = 0; + } - /* this is an intersecting box; it has to jump through a few more hoops */ - if (rb == res->parent || rb->parent.expansion_area == res->parent) - return 0; /* don't see what we came from */ + /* this is an intersecting box; it has to jump through a few more hoops */ + if (rb == res->parent || rb->parent.expansion_area == res->parent) + return 0; /* don't see what we came from */ - /* if we are expanding a source edge, don't let other sources - * or their expansions stop us. - */ + /* if we are expanding a source edge, don't let other sources + * or their expansions stop us. + */ #if 1 - if (res->parent->flags.source) - if (rb->flags.source - || (rb->type == EXPANSION_AREA - && rb->parent.expansion_area->flags.source)) - return 0; + if (res->parent->flags.source) + if (rb->flags.source || (rb->type == EXPANSION_AREA && rb->parent.expansion_area->flags.source)) + return 0; #endif - /* we ignore via expansion boxes because maybe its - * cheaper to get there without the via through - * the path we're exploring now. - */ - if (rb->flags.is_via && rb->type == EXPANSION_AREA) - return 0; + /* we ignore via expansion boxes because maybe its + * cheaper to get there without the via through + * the path we're exploring now. + */ + if (rb->flags.is_via && rb->type == EXPANSION_AREA) + return 0; - if (rb->type == PLANE) /* expanding inside a plane is not good */ - { - if (rbox.X1 < res->orig.X1 && rbox.X2 > res->orig.X2 && - rbox.Y1 < res->orig.Y1 && rbox.Y2 > res->orig.Y2) - { - res->inflated = bloat_box (&res->orig, res->bloat); - return 1; + if (rb->type == PLANE) { /* expanding inside a plane is not good */ + if (rbox.X1 < res->orig.X1 && rbox.X2 > res->orig.X2 && rbox.Y1 < res->orig.Y1 && rbox.Y2 > res->orig.Y2) { + res->inflated = bloat_box(&res->orig, res->bloat); + return 1; + } } - } - /* calculate the distances from original box to this blocker */ - dn = de = ds = dw = 0; - if (!(res->done & _NORTH) && rbox.Y1 <= res->orig.Y1 - && rbox.Y2 > res->inflated.Y1) - dn = res->orig.Y1 - rbox.Y2; - if (!(res->done & _EAST) && rbox.X2 >= res->orig.X2 - && rbox.X1 < res->inflated.X2) - de = rbox.X1 - res->orig.X2; - if (!(res->done & _SOUTH) && rbox.Y2 >= res->orig.Y2 - && rbox.Y1 < res->inflated.Y2) - ds = rbox.Y1 - res->orig.Y2; - if (!(res->done & _WEST) && rbox.X1 <= res->orig.X1 - && rbox.X2 > res->inflated.X1) - dw = res->orig.X1 - rbox.X2; - if (dn <= 0 && de <= 0 && ds <= 0 && dw <= 0) - return 1; - /* now shrink the inflated box to the largest blocking direction */ - if (dn >= de && dn >= ds && dn >= dw) - { - res->inflated.Y1 = rbox.Y2 - bloat; - res->n = rb; - } - else if (de >= ds && de >= dw) - { - res->inflated.X2 = rbox.X1 + bloat; - res->e = rb; - } - else if (ds >= dw) - { - res->inflated.Y2 = rbox.Y1 + bloat; - res->s = rb; - } - else - { - res->inflated.X1 = rbox.X2 - bloat; - res->w = rb; - } - return 1; + /* calculate the distances from original box to this blocker */ + dn = de = ds = dw = 0; + if (!(res->done & _NORTH) && rbox.Y1 <= res->orig.Y1 && rbox.Y2 > res->inflated.Y1) + dn = res->orig.Y1 - rbox.Y2; + if (!(res->done & _EAST) && rbox.X2 >= res->orig.X2 && rbox.X1 < res->inflated.X2) + de = rbox.X1 - res->orig.X2; + if (!(res->done & _SOUTH) && rbox.Y2 >= res->orig.Y2 && rbox.Y1 < res->inflated.Y2) + ds = rbox.Y1 - res->orig.Y2; + if (!(res->done & _WEST) && rbox.X1 <= res->orig.X1 && rbox.X2 > res->inflated.X1) + dw = res->orig.X1 - rbox.X2; + if (dn <= 0 && de <= 0 && ds <= 0 && dw <= 0) + return 1; + /* now shrink the inflated box to the largest blocking direction */ + if (dn >= de && dn >= ds && dn >= dw) { + res->inflated.Y1 = rbox.Y2 - bloat; + res->n = rb; + } + else if (de >= ds && de >= dw) { + res->inflated.X2 = rbox.X1 + bloat; + res->e = rb; + } + else if (ds >= dw) { + res->inflated.Y2 = rbox.Y1 + bloat; + res->s = rb; + } + else { + res->inflated.X1 = rbox.X2 - bloat; + res->w = rb; + } + return 1; } -static bool -boink_box (routebox_t * rb, struct E_result *res, direction_t dir) +static bool boink_box(routebox_t * rb, struct E_result *res, direction_t dir) { - Coord bloat; - if (rb->style->Keepaway > res->keep) - bloat = res->keep - rb->style->Keepaway; - else - bloat = 0; - if (rb->flags.nobloat) - bloat = res->bloat; - switch (dir) - { - case NORTH: - case SOUTH: - if (rb->sbox.X2 <= res->inflated.X1 + bloat - || rb->sbox.X1 >= res->inflated.X2 - bloat) + Coord bloat; + if (rb->style->Keepaway > res->keep) + bloat = res->keep - rb->style->Keepaway; + else + bloat = 0; + if (rb->flags.nobloat) + bloat = res->bloat; + switch (dir) { + case NORTH: + case SOUTH: + if (rb->sbox.X2 <= res->inflated.X1 + bloat || rb->sbox.X1 >= res->inflated.X2 - bloat) + return false; + return true; + case EAST: + case WEST: + if (rb->sbox.Y1 >= res->inflated.Y2 - bloat || rb->sbox.Y2 <= res->inflated.Y1 + bloat) + return false; + return true; + break; + default: + assert(0); + } return false; - return true; - case EAST: - case WEST: - if (rb->sbox.Y1 >= res->inflated.Y2 - bloat - || rb->sbox.Y2 <= res->inflated.Y1 + bloat) - return false; - return true; - break; - default: - assert (0); - } - return false; } /* main Expand routine. @@ -2248,145 +1983,140 @@ * looks past the keepaway to see these targets even though they * weren't actually touched in the expansion. */ -struct E_result * -Expand (rtree_t * rtree, edge_t * e, const BoxType * box) +struct E_result *Expand(rtree_t * rtree, edge_t * e, const BoxType * box) { - static struct E_result ans; - int noshrink; /* bit field of which edges to not shrink */ + static struct E_result ans; + int noshrink; /* bit field of which edges to not shrink */ - ans.bloat = AutoRouteParameters.bloat; - ans.orig = *box; - ans.n = ans.e = ans.s = ans.w = NULL; + ans.bloat = AutoRouteParameters.bloat; + ans.orig = *box; + ans.n = ans.e = ans.s = ans.w = NULL; - /* the inflated box must be bloated in all directions that it might - * hit something in order to guarantee that we see object in the - * tree it might hit. The tree holds objects bloated by their own - * keepaway so we are guaranteed to honor that. - */ - switch (e->expand_dir) - { - case ALL: - ans.inflated.X1 = (e->rb->came_from == EAST ? ans.orig.X1 : 0); - ans.inflated.Y1 = (e->rb->came_from == SOUTH ? ans.orig.Y1 : 0); - ans.inflated.X2 = - (e->rb->came_from == WEST ? ans.orig.X2 : PCB->MaxWidth); - ans.inflated.Y2 = - (e->rb->came_from == NORTH ? ans.orig.Y2 : PCB->MaxHeight); - if (e->rb->came_from == NORTH) - ans.done = noshrink = _SOUTH; - else if (e->rb->came_from == EAST) - ans.done = noshrink = _WEST; - else if (e->rb->came_from == SOUTH) - ans.done = noshrink = _NORTH; - else if (e->rb->came_from == WEST) - ans.done = noshrink = _EAST; - else - ans.done = noshrink = 0; - break; - case NORTH: - ans.done = _SOUTH + _EAST + _WEST; - noshrink = _SOUTH; - ans.inflated.X1 = box->X1 - ans.bloat; - ans.inflated.X2 = box->X2 + ans.bloat; - ans.inflated.Y2 = box->Y2; - ans.inflated.Y1 = 0; /* far north */ - break; - case NE: - ans.done = _SOUTH + _WEST; - noshrink = 0; - ans.inflated.X1 = box->X1 - ans.bloat; - ans.inflated.X2 = PCB->MaxWidth; - ans.inflated.Y2 = box->Y2 + ans.bloat; - ans.inflated.Y1 = 0; - break; - case EAST: - ans.done = _NORTH + _SOUTH + _WEST; - noshrink = _WEST; - ans.inflated.Y1 = box->Y1 - ans.bloat; - ans.inflated.Y2 = box->Y2 + ans.bloat; - ans.inflated.X1 = box->X1; - ans.inflated.X2 = PCB->MaxWidth; - break; - case SE: - ans.done = _NORTH + _WEST; - noshrink = 0; - ans.inflated.X1 = box->X1 - ans.bloat; - ans.inflated.X2 = PCB->MaxWidth; - ans.inflated.Y2 = PCB->MaxHeight; - ans.inflated.Y1 = box->Y1 - ans.bloat; - break; - case SOUTH: - ans.done = _NORTH + _EAST + _WEST; - noshrink = _NORTH; - ans.inflated.X1 = box->X1 - ans.bloat; - ans.inflated.X2 = box->X2 + ans.bloat; - ans.inflated.Y1 = box->Y1; - ans.inflated.Y2 = PCB->MaxHeight; - break; - case SW: - ans.done = _NORTH + _EAST; - noshrink = 0; - ans.inflated.X1 = 0; - ans.inflated.X2 = box->X2 + ans.bloat; - ans.inflated.Y2 = PCB->MaxHeight; - ans.inflated.Y1 = box->Y1 - ans.bloat; - break; - case WEST: - ans.done = _NORTH + _SOUTH + _EAST; - noshrink = _EAST; - ans.inflated.Y1 = box->Y1 - ans.bloat; - ans.inflated.Y2 = box->Y2 + ans.bloat; - ans.inflated.X1 = 0; - ans.inflated.X2 = box->X2; - break; - case NW: - ans.done = _SOUTH + _EAST; - noshrink = 0; - ans.inflated.X1 = 0; - ans.inflated.X2 = box->X2 + ans.bloat; - ans.inflated.Y2 = box->Y2 + ans.bloat; - ans.inflated.Y1 = 0; - break; - default: - noshrink = ans.done = 0; - assert (0); - } - ans.keep = e->rb->style->Keepaway; - ans.parent = nonhomeless_parent (e->rb); - r_search (rtree, &ans.inflated, NULL, __Expand_this_rect, &ans); + /* the inflated box must be bloated in all directions that it might + * hit something in order to guarantee that we see object in the + * tree it might hit. The tree holds objects bloated by their own + * keepaway so we are guaranteed to honor that. + */ + switch (e->expand_dir) { + case ALL: + ans.inflated.X1 = (e->rb->came_from == EAST ? ans.orig.X1 : 0); + ans.inflated.Y1 = (e->rb->came_from == SOUTH ? ans.orig.Y1 : 0); + ans.inflated.X2 = (e->rb->came_from == WEST ? ans.orig.X2 : PCB->MaxWidth); + ans.inflated.Y2 = (e->rb->came_from == NORTH ? ans.orig.Y2 : PCB->MaxHeight); + if (e->rb->came_from == NORTH) + ans.done = noshrink = _SOUTH; + else if (e->rb->came_from == EAST) + ans.done = noshrink = _WEST; + else if (e->rb->came_from == SOUTH) + ans.done = noshrink = _NORTH; + else if (e->rb->came_from == WEST) + ans.done = noshrink = _EAST; + else + ans.done = noshrink = 0; + break; + case NORTH: + ans.done = _SOUTH + _EAST + _WEST; + noshrink = _SOUTH; + ans.inflated.X1 = box->X1 - ans.bloat; + ans.inflated.X2 = box->X2 + ans.bloat; + ans.inflated.Y2 = box->Y2; + ans.inflated.Y1 = 0; /* far north */ + break; + case NE: + ans.done = _SOUTH + _WEST; + noshrink = 0; + ans.inflated.X1 = box->X1 - ans.bloat; + ans.inflated.X2 = PCB->MaxWidth; + ans.inflated.Y2 = box->Y2 + ans.bloat; + ans.inflated.Y1 = 0; + break; + case EAST: + ans.done = _NORTH + _SOUTH + _WEST; + noshrink = _WEST; + ans.inflated.Y1 = box->Y1 - ans.bloat; + ans.inflated.Y2 = box->Y2 + ans.bloat; + ans.inflated.X1 = box->X1; + ans.inflated.X2 = PCB->MaxWidth; + break; + case SE: + ans.done = _NORTH + _WEST; + noshrink = 0; + ans.inflated.X1 = box->X1 - ans.bloat; + ans.inflated.X2 = PCB->MaxWidth; + ans.inflated.Y2 = PCB->MaxHeight; + ans.inflated.Y1 = box->Y1 - ans.bloat; + break; + case SOUTH: + ans.done = _NORTH + _EAST + _WEST; + noshrink = _NORTH; + ans.inflated.X1 = box->X1 - ans.bloat; + ans.inflated.X2 = box->X2 + ans.bloat; + ans.inflated.Y1 = box->Y1; + ans.inflated.Y2 = PCB->MaxHeight; + break; + case SW: + ans.done = _NORTH + _EAST; + noshrink = 0; + ans.inflated.X1 = 0; + ans.inflated.X2 = box->X2 + ans.bloat; + ans.inflated.Y2 = PCB->MaxHeight; + ans.inflated.Y1 = box->Y1 - ans.bloat; + break; + case WEST: + ans.done = _NORTH + _SOUTH + _EAST; + noshrink = _EAST; + ans.inflated.Y1 = box->Y1 - ans.bloat; + ans.inflated.Y2 = box->Y2 + ans.bloat; + ans.inflated.X1 = 0; + ans.inflated.X2 = box->X2; + break; + case NW: + ans.done = _SOUTH + _EAST; + noshrink = 0; + ans.inflated.X1 = 0; + ans.inflated.X2 = box->X2 + ans.bloat; + ans.inflated.Y2 = box->Y2 + ans.bloat; + ans.inflated.Y1 = 0; + break; + default: + noshrink = ans.done = 0; + assert(0); + } + ans.keep = e->rb->style->Keepaway; + ans.parent = nonhomeless_parent(e->rb); + r_search(rtree, &ans.inflated, NULL, __Expand_this_rect, &ans); /* because the overlaping boxes are found in random order, some blockers * may have limited edges prematurely, so we check if the blockers realy * are blocking, and make another try if not */ - if (ans.n && !boink_box (ans.n, &ans, NORTH)) - ans.inflated.Y1 = 0; - else - ans.done |= _NORTH; - if (ans.e && !boink_box (ans.e, &ans, EAST)) - ans.inflated.X2 = PCB->MaxWidth; - else - ans.done |= _EAST; - if (ans.s && !boink_box (ans.s, &ans, SOUTH)) - ans.inflated.Y2 = PCB->MaxHeight; - else - ans.done |= _SOUTH; - if (ans.w && !boink_box (ans.w, &ans, WEST)) - ans.inflated.X1 = 0; - else - ans.done |= _WEST; - if (ans.done != _NORTH + _EAST + _SOUTH + _WEST) - { - r_search (rtree, &ans.inflated, NULL, __Expand_this_rect, &ans); - } - if ((noshrink & _NORTH) == 0) - ans.inflated.Y1 += ans.bloat; - if ((noshrink & _EAST) == 0) - ans.inflated.X2 -= ans.bloat; - if ((noshrink & _SOUTH) == 0) - ans.inflated.Y2 -= ans.bloat; - if ((noshrink & _WEST) == 0) - ans.inflated.X1 += ans.bloat; - return &ans; + if (ans.n && !boink_box(ans.n, &ans, NORTH)) + ans.inflated.Y1 = 0; + else + ans.done |= _NORTH; + if (ans.e && !boink_box(ans.e, &ans, EAST)) + ans.inflated.X2 = PCB->MaxWidth; + else + ans.done |= _EAST; + if (ans.s && !boink_box(ans.s, &ans, SOUTH)) + ans.inflated.Y2 = PCB->MaxHeight; + else + ans.done |= _SOUTH; + if (ans.w && !boink_box(ans.w, &ans, WEST)) + ans.inflated.X1 = 0; + else + ans.done |= _WEST; + if (ans.done != _NORTH + _EAST + _SOUTH + _WEST) { + r_search(rtree, &ans.inflated, NULL, __Expand_this_rect, &ans); + } + if ((noshrink & _NORTH) == 0) + ans.inflated.Y1 += ans.bloat; + if ((noshrink & _EAST) == 0) + ans.inflated.X2 -= ans.bloat; + if ((noshrink & _SOUTH) == 0) + ans.inflated.Y2 -= ans.bloat; + if ((noshrink & _WEST) == 0) + ans.inflated.X1 += ans.bloat; + return &ans; } /* blocker_to_heap puts the blockers into a heap so they @@ -2395,42 +2125,37 @@ * It returns 1 for any fixed blocker that is not part * of this net and zero otherwise. */ -static int -blocker_to_heap (heap_t * heap, routebox_t * rb, - BoxType * box, direction_t dir) +static int blocker_to_heap(heap_t * heap, routebox_t * rb, BoxType * box, direction_t dir) { - BoxType b = rb->sbox; - if (rb->style->Keepaway > AutoRouteParameters.style->Keepaway) - b = - bloat_box (&b, - rb->style->Keepaway - AutoRouteParameters.style->Keepaway); - b = clip_box (&b, box); - assert (box_is_good (&b)); - /* we want to look at the blockers clockwise around the box */ - switch (dir) - { - /* we need to use the other coordinate fraction to resolve - * ties since we want the shorter of the furthest - * first. - */ - case NORTH: - heap_insert (heap, b.X1 - b.X1 / (b.X2 + 1.0), rb); - break; - case EAST: - heap_insert (heap, b.Y1 - b.Y1 / (b.Y2 + 1.0), rb); - break; - case SOUTH: - heap_insert (heap, -(b.X2 + b.X1 / (b.X2 + 1.0)), rb); - break; - case WEST: - heap_insert (heap, -(b.Y2 + b.Y1 / (b.Y2 + 1.0)), rb); - break; - default: - assert (0); - } - if (rb->flags.fixed && !rb->flags.target && !rb->flags.source) - return 1; - return 0; + BoxType b = rb->sbox; + if (rb->style->Keepaway > AutoRouteParameters.style->Keepaway) + b = bloat_box(&b, rb->style->Keepaway - AutoRouteParameters.style->Keepaway); + b = clip_box(&b, box); + assert(box_is_good(&b)); + /* we want to look at the blockers clockwise around the box */ + switch (dir) { + /* we need to use the other coordinate fraction to resolve + * ties since we want the shorter of the furthest + * first. + */ + case NORTH: + heap_insert(heap, b.X1 - b.X1 / (b.X2 + 1.0), rb); + break; + case EAST: + heap_insert(heap, b.Y1 - b.Y1 / (b.Y2 + 1.0), rb); + break; + case SOUTH: + heap_insert(heap, -(b.X2 + b.X1 / (b.X2 + 1.0)), rb); + break; + case WEST: + heap_insert(heap, -(b.Y2 + b.Y1 / (b.Y2 + 1.0)), rb); + break; + default: + assert(0); + } + if (rb->flags.fixed && !rb->flags.target && !rb->flags.source) + return 1; + return 0; } /* this creates an EXPANSION_AREA to bridge small gaps or, @@ -2437,31 +2162,28 @@ * (more commonly) create a supper-thin box to provide a * home for an expansion edge. */ -static routebox_t * -CreateBridge (const BoxType * area, routebox_t * parent, direction_t dir) +static routebox_t *CreateBridge(const BoxType * area, routebox_t * parent, direction_t dir) { - routebox_t *rb = (routebox_t *) malloc (sizeof (*rb)); - memset ((void *) rb, 0, sizeof (*rb)); - assert (area && parent); - init_const_box (rb, area->X1, area->Y1, area->X2, area->Y2, 0); - rb->group = parent->group; - rb->type = EXPANSION_AREA; - rb->came_from = dir; - rb->cost_point = closest_point_in_box (&parent->cost_point, area); - rb->cost = parent->cost + cost_to_point_on_layer (&parent->cost_point, - &rb->cost_point, - rb->group); - rb->parent.expansion_area = route_parent (parent); - if (rb->parent.expansion_area->flags.homeless) - RB_up_count (rb->parent.expansion_area); - rb->flags.homeless = 1; - rb->flags.nobloat = 1; - rb->style = parent->style; - rb->conflicts_with = parent->conflicts_with; + routebox_t *rb = (routebox_t *) malloc(sizeof(*rb)); + memset((void *) rb, 0, sizeof(*rb)); + assert(area && parent); + init_const_box(rb, area->X1, area->Y1, area->X2, area->Y2, 0); + rb->group = parent->group; + rb->type = EXPANSION_AREA; + rb->came_from = dir; + rb->cost_point = closest_point_in_box(&parent->cost_point, area); + rb->cost = parent->cost + cost_to_point_on_layer(&parent->cost_point, &rb->cost_point, rb->group); + rb->parent.expansion_area = route_parent(parent); + if (rb->parent.expansion_area->flags.homeless) + RB_up_count(rb->parent.expansion_area); + rb->flags.homeless = 1; + rb->flags.nobloat = 1; + rb->style = parent->style; + rb->conflicts_with = parent->conflicts_with; #if defined(ROUTE_DEBUG) && defined(DEBUG_SHOW_EDGES) - showroutebox (rb); + showroutebox(rb); #endif - return rb; + return rb; } /* moveable_edge prepares the new search edges based on the @@ -2468,239 +2190,210 @@ * starting box, direction and blocker if any. */ void -moveable_edge (vector_t * result, const BoxType * box, direction_t dir, - routebox_t * rb, - routebox_t * blocker, edge_t * e, rtree_t * targets, - struct routeone_state *s, rtree_t * tree, vector_t * area_vec) +moveable_edge(vector_t * result, const BoxType * box, direction_t dir, + routebox_t * rb, + routebox_t * blocker, edge_t * e, rtree_t * targets, + struct routeone_state *s, rtree_t * tree, vector_t * area_vec) { - BoxType b; - assert (box_is_good (box)); - b = *box; - /* for the cardinal directions, move the box to overlap the - * the parent by 1 unit. Corner expansions overlap more - * and their starting boxes are pre-prepared. - * Check if anything is headed off the board edges - */ - switch (dir) - { - default: - break; - case NORTH: - b.Y2 = b.Y1; - b.Y1--; - if (b.Y1 <= AutoRouteParameters.bloat) - return; /* off board edge */ - break; - case EAST: - b.X1 = b.X2; - b.X2++; - if (b.X2 >= PCB->MaxWidth - AutoRouteParameters.bloat) - return; /* off board edge */ - break; - case SOUTH: - b.Y1 = b.Y2; - b.Y2++; - if (b.Y2 >= PCB->MaxHeight - AutoRouteParameters.bloat) - return; /* off board edge */ - break; - case WEST: - b.X2 = b.X1; - b.X1--; - if (b.X1 <= AutoRouteParameters.bloat) - return; /* off board edge */ - break; - case NE: - if (b.Y1 <= AutoRouteParameters.bloat + 1 - && b.X2 >= PCB->MaxWidth - AutoRouteParameters.bloat - 1) - return; /* off board edge */ - if (b.Y1 <= AutoRouteParameters.bloat + 1) - dir = EAST; /* north off board edge */ - if (b.X2 >= PCB->MaxWidth - AutoRouteParameters.bloat - 1) - dir = NORTH; /* east off board edge */ - break; - case SE: - if (b.Y2 >= PCB->MaxHeight - AutoRouteParameters.bloat - 1 - && b.X2 >= PCB->MaxWidth - AutoRouteParameters.bloat - 1) - return; /* off board edge */ - if (b.Y2 >= PCB->MaxHeight - AutoRouteParameters.bloat - 1) - dir = EAST; /* south off board edge */ - if (b.X2 >= PCB->MaxWidth - AutoRouteParameters.bloat - 1) - dir = SOUTH; /* east off board edge */ - break; - case SW: - if (b.Y2 >= PCB->MaxHeight - AutoRouteParameters.bloat - 1 - && b.X1 <= AutoRouteParameters.bloat + 1) - return; /* off board edge */ - if (b.Y2 >= PCB->MaxHeight - AutoRouteParameters.bloat - 1) - dir = WEST; /* south off board edge */ - if (b.X1 <= AutoRouteParameters.bloat + 1) - dir = SOUTH; /* west off board edge */ - break; - case NW: - if (b.Y1 <= AutoRouteParameters.bloat + 1 - && b.X1 <= AutoRouteParameters.bloat + 1) - return; /* off board edge */ - if (b.Y1 <= AutoRouteParameters.bloat + 1) - dir = WEST; /* north off board edge */ - if (b.X1 <= AutoRouteParameters.bloat + 1) - dir = NORTH; /* west off board edge */ - break; - } - - if (!blocker) - { - edge_t *ne; - routebox_t *nrb = CreateBridge (&b, rb, dir); - /* move the cost point in corner expansions - * these boxes are bigger, so move close to the target - */ - if (dir == NE || dir == SE || dir == SW || dir == NW) - { - CheapPointType p; - p = - closest_point_in_box (&nrb->cost_point, &e->mincost_target->sbox); - p = closest_point_in_box (&p, &b); - nrb->cost += cost_to_point_on_layer (&p, &nrb->cost_point, - nrb->group); - nrb->cost_point = p; - } - ne = CreateEdge (nrb, nrb->cost_point.X, nrb->cost_point.Y, - nrb->cost, NULL, dir, targets); - vector_append (result, ne); - } - else if (AutoRouteParameters.with_conflicts && !blocker->flags.target - && !blocker->flags.fixed && !blocker->flags.touched && - !blocker->flags.source && blocker->type != EXPANSION_AREA) - { - edge_t *ne; - routebox_t *nrb; - /* make a bridge to the edge of the blocker - * in all directions from there - */ - switch (dir) - { + BoxType b; + assert(box_is_good(box)); + b = *box; + /* for the cardinal directions, move the box to overlap the + * the parent by 1 unit. Corner expansions overlap more + * and their starting boxes are pre-prepared. + * Check if anything is headed off the board edges + */ + switch (dir) { + default: + break; case NORTH: - b.Y1 = blocker->sbox.Y2 - 1; - break; + b.Y2 = b.Y1; + b.Y1--; + if (b.Y1 <= AutoRouteParameters.bloat) + return; /* off board edge */ + break; case EAST: - b.X2 = blocker->sbox.X1 + 1; - break; + b.X1 = b.X2; + b.X2++; + if (b.X2 >= PCB->MaxWidth - AutoRouteParameters.bloat) + return; /* off board edge */ + break; case SOUTH: - b.Y2 = blocker->sbox.Y1 + 1; - break; + b.Y1 = b.Y2; + b.Y2++; + if (b.Y2 >= PCB->MaxHeight - AutoRouteParameters.bloat) + return; /* off board edge */ + break; case WEST: - b.X1 = blocker->sbox.X2 - 1; - break; - default: - assert (0); + b.X2 = b.X1; + b.X1--; + if (b.X1 <= AutoRouteParameters.bloat) + return; /* off board edge */ + break; + case NE: + if (b.Y1 <= AutoRouteParameters.bloat + 1 && b.X2 >= PCB->MaxWidth - AutoRouteParameters.bloat - 1) + return; /* off board edge */ + if (b.Y1 <= AutoRouteParameters.bloat + 1) + dir = EAST; /* north off board edge */ + if (b.X2 >= PCB->MaxWidth - AutoRouteParameters.bloat - 1) + dir = NORTH; /* east off board edge */ + break; + case SE: + if (b.Y2 >= PCB->MaxHeight - AutoRouteParameters.bloat - 1 && b.X2 >= PCB->MaxWidth - AutoRouteParameters.bloat - 1) + return; /* off board edge */ + if (b.Y2 >= PCB->MaxHeight - AutoRouteParameters.bloat - 1) + dir = EAST; /* south off board edge */ + if (b.X2 >= PCB->MaxWidth - AutoRouteParameters.bloat - 1) + dir = SOUTH; /* east off board edge */ + break; + case SW: + if (b.Y2 >= PCB->MaxHeight - AutoRouteParameters.bloat - 1 && b.X1 <= AutoRouteParameters.bloat + 1) + return; /* off board edge */ + if (b.Y2 >= PCB->MaxHeight - AutoRouteParameters.bloat - 1) + dir = WEST; /* south off board edge */ + if (b.X1 <= AutoRouteParameters.bloat + 1) + dir = SOUTH; /* west off board edge */ + break; + case NW: + if (b.Y1 <= AutoRouteParameters.bloat + 1 && b.X1 <= AutoRouteParameters.bloat + 1) + return; /* off board edge */ + if (b.Y1 <= AutoRouteParameters.bloat + 1) + dir = WEST; /* north off board edge */ + if (b.X1 <= AutoRouteParameters.bloat + 1) + dir = NORTH; /* west off board edge */ + break; } - if (!box_is_good (&b)) - return; /* how did this happen ? */ - nrb = CreateBridge (&b, rb, dir); - r_insert_entry (tree, &nrb->box, 1); - vector_append (area_vec, nrb); - nrb->flags.homeless = 0; /* not homeless any more */ - /* mark this one as conflicted */ - path_conflicts (nrb, blocker, true); - /* and make an expansion edge */ - nrb->cost_point = - closest_point_in_box (&nrb->cost_point, &blocker->sbox); - nrb->cost += - cost_to_point_on_layer (&nrb->parent.expansion_area->cost_point, - &nrb->cost_point, - nrb->group) * CONFLICT_PENALTY (blocker); - ne = CreateEdge (nrb, nrb->cost_point.X, nrb->cost_point.Y, nrb->cost, - NULL, ALL, targets); - ne->flags.is_interior = 1; - vector_append (result, ne); - } + if (!blocker) { + edge_t *ne; + routebox_t *nrb = CreateBridge(&b, rb, dir); + /* move the cost point in corner expansions + * these boxes are bigger, so move close to the target + */ + if (dir == NE || dir == SE || dir == SW || dir == NW) { + CheapPointType p; + p = closest_point_in_box(&nrb->cost_point, &e->mincost_target->sbox); + p = closest_point_in_box(&p, &b); + nrb->cost += cost_to_point_on_layer(&p, &nrb->cost_point, nrb->group); + nrb->cost_point = p; + } + ne = CreateEdge(nrb, nrb->cost_point.X, nrb->cost_point.Y, nrb->cost, NULL, dir, targets); + vector_append(result, ne); + } + else if (AutoRouteParameters.with_conflicts && !blocker->flags.target + && !blocker->flags.fixed && !blocker->flags.touched && !blocker->flags.source && blocker->type != EXPANSION_AREA) { + edge_t *ne; + routebox_t *nrb; + /* make a bridge to the edge of the blocker + * in all directions from there + */ + switch (dir) { + case NORTH: + b.Y1 = blocker->sbox.Y2 - 1; + break; + case EAST: + b.X2 = blocker->sbox.X1 + 1; + break; + case SOUTH: + b.Y2 = blocker->sbox.Y1 + 1; + break; + case WEST: + b.X1 = blocker->sbox.X2 - 1; + break; + default: + assert(0); + } + if (!box_is_good(&b)) + return; /* how did this happen ? */ + nrb = CreateBridge(&b, rb, dir); + r_insert_entry(tree, &nrb->box, 1); + vector_append(area_vec, nrb); + nrb->flags.homeless = 0; /* not homeless any more */ + /* mark this one as conflicted */ + path_conflicts(nrb, blocker, true); + /* and make an expansion edge */ + nrb->cost_point = closest_point_in_box(&nrb->cost_point, &blocker->sbox); + nrb->cost += + cost_to_point_on_layer(&nrb->parent.expansion_area->cost_point, &nrb->cost_point, nrb->group) * CONFLICT_PENALTY(blocker); + + ne = CreateEdge(nrb, nrb->cost_point.X, nrb->cost_point.Y, nrb->cost, NULL, ALL, targets); + ne->flags.is_interior = 1; + vector_append(result, ne); + } #if 1 - else if (blocker->type == EXPANSION_AREA) - { - if (blocker->cost < rb->cost || blocker->cost <= rb->cost + - cost_to_point_on_layer (&blocker->cost_point, &rb->cost_point, - rb->group)) - return; - if (blocker->conflicts_with || rb->conflicts_with) - return; - /* does the blocker overlap this routebox ?? */ - /* does this re-parenting operation leave a memory leak? */ - if (blocker->parent.expansion_area->flags.homeless) - RB_down_count (blocker->parent.expansion_area); - blocker->parent.expansion_area = rb; - return; - } + else if (blocker->type == EXPANSION_AREA) { + if (blocker->cost < rb->cost || blocker->cost <= rb->cost + + cost_to_point_on_layer(&blocker->cost_point, &rb->cost_point, rb->group)) + return; + if (blocker->conflicts_with || rb->conflicts_with) + return; + /* does the blocker overlap this routebox ?? */ + /* does this re-parenting operation leave a memory leak? */ + if (blocker->parent.expansion_area->flags.homeless) + RB_down_count(blocker->parent.expansion_area); + blocker->parent.expansion_area = rb; + return; + } #endif - else if (blocker->flags.target) - { - routebox_t *nrb; - edge_t *ne; - b = bloat_box (&b, 1); - if (!box_intersect (&b, &blocker->sbox)) - { - /* if the expansion edge stopped before touching, expand the bridge */ - switch (dir) - { - case NORTH: - b.Y1 -= AutoRouteParameters.bloat + 1; - break; - case EAST: - b.X2 += AutoRouteParameters.bloat + 1; - break; - case SOUTH: - b.Y2 += AutoRouteParameters.bloat + 1; - break; - case WEST: - b.X1 -= AutoRouteParameters.bloat + 1; - break; - default: - assert (0); - } + else if (blocker->flags.target) { + routebox_t *nrb; + edge_t *ne; + b = bloat_box(&b, 1); + if (!box_intersect(&b, &blocker->sbox)) { + /* if the expansion edge stopped before touching, expand the bridge */ + switch (dir) { + case NORTH: + b.Y1 -= AutoRouteParameters.bloat + 1; + break; + case EAST: + b.X2 += AutoRouteParameters.bloat + 1; + break; + case SOUTH: + b.Y2 += AutoRouteParameters.bloat + 1; + break; + case WEST: + b.X1 -= AutoRouteParameters.bloat + 1; + break; + default: + assert(0); + } + } + assert(box_intersect(&b, &blocker->sbox)); + b = shrink_box(&b, 1); + nrb = CreateBridge(&b, rb, dir); + r_insert_entry(tree, &nrb->box, 1); + vector_append(area_vec, nrb); + nrb->flags.homeless = 0; /* not homeless any more */ + ne = CreateEdge(nrb, nrb->cost_point.X, nrb->cost_point.Y, nrb->cost, blocker, dir, NULL); + best_path_candidate(s, ne, blocker); + DestroyEdge(&ne); } - assert (box_intersect (&b, &blocker->sbox)); - b = shrink_box (&b, 1); - nrb = CreateBridge (&b, rb, dir); - r_insert_entry (tree, &nrb->box, 1); - vector_append (area_vec, nrb); - nrb->flags.homeless = 0; /* not homeless any more */ - ne = CreateEdge (nrb, nrb->cost_point.X, nrb->cost_point.Y, - nrb->cost, blocker, dir, NULL); - best_path_candidate (s, ne, blocker); - DestroyEdge (&ne); - } } -struct break_info -{ - heap_t *heap; - routebox_t *parent; - BoxType box; - direction_t dir; - bool ignore_source; +struct break_info { + heap_t *heap; + routebox_t *parent; + BoxType box; + direction_t dir; + bool ignore_source; }; -static int -__GatherBlockers (const BoxType * box, void *cl) +static int __GatherBlockers(const BoxType * box, void *cl) { - routebox_t *rb = (routebox_t *) box; - struct break_info *bi = (struct break_info *) cl; - BoxType b; + routebox_t *rb = (routebox_t *) box; + struct break_info *bi = (struct break_info *) cl; + BoxType b; - if (bi->parent == rb || rb->flags.touched || - bi->parent->parent.expansion_area == rb) - return 0; - if (rb->flags.source && bi->ignore_source) - return 0; - b = rb->sbox; - if (rb->style->Keepaway > AutoRouteParameters.style->Keepaway) - b = - bloat_box (&b, - rb->style->Keepaway - AutoRouteParameters.style->Keepaway); - if (b.X2 <= bi->box.X1 || b.X1 >= bi->box.X2 - || b.Y1 >= bi->box.Y2 || b.Y2 <= bi->box.Y1) - return 0; - return blocker_to_heap (bi->heap, rb, &bi->box, bi->dir); + if (bi->parent == rb || rb->flags.touched || bi->parent->parent.expansion_area == rb) + return 0; + if (rb->flags.source && bi->ignore_source) + return 0; + b = rb->sbox; + if (rb->style->Keepaway > AutoRouteParameters.style->Keepaway) + b = bloat_box(&b, rb->style->Keepaway - AutoRouteParameters.style->Keepaway); + if (b.X2 <= bi->box.X1 || b.X1 >= bi->box.X2 || b.Y1 >= bi->box.Y2 || b.Y2 <= bi->box.Y1) + return 0; + return blocker_to_heap(bi->heap, rb, &bi->box, bi->dir); } /* shrink the box to the last limit for the previous direction, @@ -2707,26 +2400,24 @@ * i.e. if dir is SOUTH, then this means fixing up an EAST leftover * edge, which would be the southern most edge for that example. */ -static inline BoxType -previous_edge (Coord last, direction_t i, const BoxType * b) +static inline BoxType previous_edge(Coord last, direction_t i, const BoxType * b) { - BoxType db = *b; - switch (i) - { - case EAST: - db.X1 = last; - break; - case SOUTH: - db.Y1 = last; - break; - case WEST: - db.X2 = last; - break; - default: - Message ("previous edge bogus direction!"); - assert (0); - } - return db; + BoxType db = *b; + switch (i) { + case EAST: + db.X1 = last; + break; + case SOUTH: + db.Y1 = last; + break; + case WEST: + db.X2 = last; + break; + default: + Message("previous edge bogus direction!"); + assert(0); + } + return db; } /* Break all the edges of the box that need breaking, handling @@ -2733,131 +2424,122 @@ * targets as they are found, and putting any moveable edges * in the return vector. */ -vector_t * -BreakManyEdges (struct routeone_state * s, rtree_t * targets, rtree_t * tree, - vector_t * area_vec, struct E_result * ans, routebox_t * rb, - edge_t * e) +vector_t *BreakManyEdges(struct routeone_state * s, rtree_t * targets, rtree_t * tree, + vector_t * area_vec, struct E_result * ans, routebox_t * rb, edge_t * e) { - struct break_info bi; - vector_t *edges; - heap_t *heap[4]; - Coord first, last; - Coord bloat; - direction_t dir; - routebox_t fake; + struct break_info bi; + vector_t *edges; + heap_t *heap[4]; + Coord first, last; + Coord bloat; + direction_t dir; + routebox_t fake; - edges = vector_create (); - bi.ignore_source = rb->parent.expansion_area->flags.source; - bi.parent = rb; - /* we add 2 to the bloat. - * 1 will get us to the actual blocker that Expand() hit - * but 1 more is needed because the new expansion edges - * move out by 1 so they don't overlap their parents - * this extra expansion could "trap" the edge if - * there is a blocker 2 units from the original rb, - * it is 1 unit from the new expansion edge which - * would prevent expansion. So we want to break the - * edge on it now to avoid the trap. - */ + edges = vector_create(); + bi.ignore_source = rb->parent.expansion_area->flags.source; + bi.parent = rb; + /* we add 2 to the bloat. + * 1 will get us to the actual blocker that Expand() hit + * but 1 more is needed because the new expansion edges + * move out by 1 so they don't overlap their parents + * this extra expansion could "trap" the edge if + * there is a blocker 2 units from the original rb, + * it is 1 unit from the new expansion edge which + * would prevent expansion. So we want to break the + * edge on it now to avoid the trap. + */ - bloat = AutoRouteParameters.bloat + 2; - /* for corner expansion, we need to have a fake blocker - * to prevent expansion back where we came from since - * we still need to break portions of all 4 edges - */ - if (e->expand_dir == NE || e->expand_dir == SE || - e->expand_dir == SW || e->expand_dir == NW) - { - BoxType *fb = (BoxType *) &fake.sbox; - memset (&fake, 0, sizeof (fake)); - *fb = e->rb->sbox; - fake.flags.fixed = 1; /* this stops expansion there */ - fake.type = LINE; - fake.style = AutoRouteParameters.style; + bloat = AutoRouteParameters.bloat + 2; + /* for corner expansion, we need to have a fake blocker + * to prevent expansion back where we came from since + * we still need to break portions of all 4 edges + */ + if (e->expand_dir == NE || e->expand_dir == SE || e->expand_dir == SW || e->expand_dir == NW) { + BoxType *fb = (BoxType *) & fake.sbox; + memset(&fake, 0, sizeof(fake)); + *fb = e->rb->sbox; + fake.flags.fixed = 1; /* this stops expansion there */ + fake.type = LINE; + fake.style = AutoRouteParameters.style; #ifndef NDEBUG - /* the routbox_is_good checker wants a lot more! */ - fake.flags.inited = 1; - fb = (BoxType *) &fake.box; - *fb = e->rb->sbox; - fake.same_net.next = fake.same_net.prev = &fake; - fake.same_subnet.next = fake.same_subnet.prev = &fake; - fake.original_subnet.next = fake.original_subnet.prev = &fake; - fake.different_net.next = fake.different_net.prev = &fake; + /* the routbox_is_good checker wants a lot more! */ + fake.flags.inited = 1; + fb = (BoxType *) & fake.box; + *fb = e->rb->sbox; + fake.same_net.next = fake.same_net.prev = &fake; + fake.same_subnet.next = fake.same_subnet.prev = &fake; + fake.original_subnet.next = fake.original_subnet.prev = &fake; + fake.different_net.next = fake.different_net.prev = &fake; #endif - } - /* gather all of the blockers in heaps so they can be accessed - * in clockwise order, which allows finding corners that can - * be expanded. - */ - for (dir = NORTH; dir <= WEST; dir = directionIncrement(dir)) - { - /* don't break the edge we came from */ - if (e->expand_dir != ((dir + 2) % 4)) - { - heap[dir] = heap_create (); - bi.box = bloat_box (&rb->sbox, bloat); - bi.heap = heap[dir]; - bi.dir = dir; - /* convert to edge */ - switch (dir) - { - case NORTH: - bi.box.Y2 = bi.box.Y1 + bloat + 1; - /* for corner expansion, block the start edges and - * limit the blocker search to only the new edge segment - */ - if (e->expand_dir == SE || e->expand_dir == SW) - blocker_to_heap (heap[dir], &fake, &bi.box, dir); - if (e->expand_dir == SE) - bi.box.X1 = e->rb->sbox.X2; - if (e->expand_dir == SW) - bi.box.X2 = e->rb->sbox.X1; - rb->n = r_search (tree, &bi.box, NULL, __GatherBlockers, &bi); - break; - case EAST: - bi.box.X1 = bi.box.X2 - bloat - 1; - /* corner, same as above */ - if (e->expand_dir == SW || e->expand_dir == NW) - blocker_to_heap (heap[dir], &fake, &bi.box, dir); - if (e->expand_dir == SW) - bi.box.Y1 = e->rb->sbox.Y2; - if (e->expand_dir == NW) - bi.box.Y2 = e->rb->sbox.Y1; - rb->e = r_search (tree, &bi.box, NULL, __GatherBlockers, &bi); - break; - case SOUTH: - bi.box.Y1 = bi.box.Y2 - bloat - 1; - /* corner, same as above */ - if (e->expand_dir == NE || e->expand_dir == NW) - blocker_to_heap (heap[dir], &fake, &bi.box, dir); - if (e->expand_dir == NE) - bi.box.X1 = e->rb->sbox.X2; - if (e->expand_dir == NW) - bi.box.X2 = e->rb->sbox.X1; - rb->s = r_search (tree, &bi.box, NULL, __GatherBlockers, &bi); - break; - case WEST: - bi.box.X2 = bi.box.X1 + bloat + 1; - /* corner, same as above */ - if (e->expand_dir == NE || e->expand_dir == SE) - blocker_to_heap (heap[dir], &fake, &bi.box, dir); - if (e->expand_dir == SE) - bi.box.Y1 = e->rb->sbox.Y2; - if (e->expand_dir == NE) - bi.box.Y2 = e->rb->sbox.Y1; - rb->w = r_search (tree, &bi.box, NULL, __GatherBlockers, &bi); - break; - default: - assert (0); - } } - else - heap[dir] = NULL; - } + /* gather all of the blockers in heaps so they can be accessed + * in clockwise order, which allows finding corners that can + * be expanded. + */ + for (dir = NORTH; dir <= WEST; dir = directionIncrement(dir)) { + /* don't break the edge we came from */ + if (e->expand_dir != ((dir + 2) % 4)) { + heap[dir] = heap_create(); + bi.box = bloat_box(&rb->sbox, bloat); + bi.heap = heap[dir]; + bi.dir = dir; + /* convert to edge */ + switch (dir) { + case NORTH: + bi.box.Y2 = bi.box.Y1 + bloat + 1; + /* for corner expansion, block the start edges and + * limit the blocker search to only the new edge segment + */ + if (e->expand_dir == SE || e->expand_dir == SW) + blocker_to_heap(heap[dir], &fake, &bi.box, dir); + if (e->expand_dir == SE) + bi.box.X1 = e->rb->sbox.X2; + if (e->expand_dir == SW) + bi.box.X2 = e->rb->sbox.X1; + rb->n = r_search(tree, &bi.box, NULL, __GatherBlockers, &bi); + break; + case EAST: + bi.box.X1 = bi.box.X2 - bloat - 1; + /* corner, same as above */ + if (e->expand_dir == SW || e->expand_dir == NW) + blocker_to_heap(heap[dir], &fake, &bi.box, dir); + if (e->expand_dir == SW) + bi.box.Y1 = e->rb->sbox.Y2; + if (e->expand_dir == NW) + bi.box.Y2 = e->rb->sbox.Y1; + rb->e = r_search(tree, &bi.box, NULL, __GatherBlockers, &bi); + break; + case SOUTH: + bi.box.Y1 = bi.box.Y2 - bloat - 1; + /* corner, same as above */ + if (e->expand_dir == NE || e->expand_dir == NW) + blocker_to_heap(heap[dir], &fake, &bi.box, dir); + if (e->expand_dir == NE) + bi.box.X1 = e->rb->sbox.X2; + if (e->expand_dir == NW) + bi.box.X2 = e->rb->sbox.X1; + rb->s = r_search(tree, &bi.box, NULL, __GatherBlockers, &bi); + break; + case WEST: + bi.box.X2 = bi.box.X1 + bloat + 1; + /* corner, same as above */ + if (e->expand_dir == NE || e->expand_dir == SE) + blocker_to_heap(heap[dir], &fake, &bi.box, dir); + if (e->expand_dir == SE) + bi.box.Y1 = e->rb->sbox.Y2; + if (e->expand_dir == NE) + bi.box.Y2 = e->rb->sbox.Y1; + rb->w = r_search(tree, &bi.box, NULL, __GatherBlockers, &bi); + break; + default: + assert(0); + } + } + else + heap[dir] = NULL; + } #if 1 - rb->cost += - (rb->n + rb->e + rb->s + - rb->w) * AutoRouteParameters.CongestionPenalty / box_area (rb->sbox); + rb->cost += (rb->n + rb->e + rb->s + rb->w) * AutoRouteParameters.CongestionPenalty / box_area(rb->sbox); #endif /* now handle the blockers: * Go around the expansion area clockwise (North->East->South->West) @@ -2865,306 +2547,267 @@ * order). Break the edges on the blocker and make the segments and corners * moveable as possible. */ - first = last = -1; - for (dir = NORTH; dir <= WEST; dir = directionIncrement(dir)) - { - if (heap[dir] && !heap_is_empty (heap[dir])) - { - /* pull the very first one out of the heap outside of the - * heap loop because it is special; it can be part of a corner - */ - routebox_t *blk = (routebox_t *) heap_remove_smallest (heap[dir]); - BoxType b = rb->sbox; - struct broken_boxes broke = break_box_edge (&b, dir, blk); - if (broke.is_valid_left) - { - /* if last > 0, then the previous edge had a segment - * joining this one, so it forms a valid corner expansion - */ - if (last > 0) - { - /* make a corner expansion */ - BoxType db = b; - switch (dir) - { - case EAST: - /* possible NE expansion */ - db.X1 = last; - db.Y2 = MIN (db.Y2, broke.left.Y2); - break; - case SOUTH: - /* possible SE expansion */ - db.Y1 = last; - db.X1 = MAX (db.X1, broke.left.X1); - break; - case WEST: - /* possible SW expansion */ - db.X2 = last; - db.Y1 = MAX (db.Y1, broke.left.Y1); - break; - default: - assert (0); - break; - } - moveable_edge (edges, &db, (direction_t)(dir + 3), rb, NULL, e, targets, - s, NULL, NULL); + first = last = -1; + for (dir = NORTH; dir <= WEST; dir = directionIncrement(dir)) { + if (heap[dir] && !heap_is_empty(heap[dir])) { + /* pull the very first one out of the heap outside of the + * heap loop because it is special; it can be part of a corner + */ + routebox_t *blk = (routebox_t *) heap_remove_smallest(heap[dir]); + BoxType b = rb->sbox; + struct broken_boxes broke = break_box_edge(&b, dir, blk); + if (broke.is_valid_left) { + /* if last > 0, then the previous edge had a segment + * joining this one, so it forms a valid corner expansion + */ + if (last > 0) { + /* make a corner expansion */ + BoxType db = b; + switch (dir) { + case EAST: + /* possible NE expansion */ + db.X1 = last; + db.Y2 = MIN(db.Y2, broke.left.Y2); + break; + case SOUTH: + /* possible SE expansion */ + db.Y1 = last; + db.X1 = MAX(db.X1, broke.left.X1); + break; + case WEST: + /* possible SW expansion */ + db.X2 = last; + db.Y1 = MAX(db.Y1, broke.left.Y1); + break; + default: + assert(0); + break; + } + moveable_edge(edges, &db, (direction_t) (dir + 3), rb, NULL, e, targets, s, NULL, NULL); + } + else if (dir == NORTH) { /* north is start, so nothing "before" it */ + /* save for a possible corner once we've + * finished circling the box + */ + first = MAX(b.X1, broke.left.X2); + } + else { + /* this is just a boring straight expansion + * since the orthogonal segment was blocked + */ + moveable_edge(edges, &broke.left, dir, rb, NULL, e, targets, s, NULL, NULL); + } + } /* broke.is_valid_left */ + else if (last > 0) { + /* if the last one didn't become a corner, + * we still want to expand it straight out + * in the direction of the previous edge, + * which it belongs to. + */ + BoxType db = previous_edge(last, dir, &rb->sbox); + moveable_edge(edges, &db, (direction_t) (dir - 1), rb, NULL, e, targets, s, NULL, NULL); + } + if (broke.is_valid_center && !blk->flags.source) + moveable_edge(edges, &broke.center, dir, rb, blk, e, targets, s, tree, area_vec); + /* this is the heap extraction loop. We break out + * if there's nothing left in the heap, but if we * are blocked all the way to the far edge, we can + * just leave stuff in the heap when it is destroyed + */ + while (broke.is_valid_right) { + /* move the box edge to the next potential free point */ + switch (dir) { + case NORTH: + last = b.X1 = MAX(broke.right.X1, b.X1); + break; + case EAST: + last = b.Y1 = MAX(broke.right.Y1, b.Y1); + break; + case SOUTH: + last = b.X2 = MIN(broke.right.X2, b.X2); + break; + case WEST: + last = b.Y2 = MIN(broke.right.Y2, b.Y2); + break; + default: + assert(0); + } + if (heap_is_empty(heap[dir])) + break; + blk = (routebox_t *) heap_remove_smallest(heap[dir]); + broke = break_box_edge(&b, dir, blk); + if (broke.is_valid_left) + moveable_edge(edges, &broke.left, dir, rb, NULL, e, targets, s, NULL, NULL); + if (broke.is_valid_center && !blk->flags.source) + moveable_edge(edges, &broke.center, dir, rb, blk, e, targets, s, tree, area_vec); + } + if (!broke.is_valid_right) + last = -1; } - else if (dir == NORTH) /* north is start, so nothing "before" it */ - { - /* save for a possible corner once we've - * finished circling the box - */ - first = MAX (b.X1, broke.left.X2); + else { /* if (heap[dir]) */ + + /* nothing touched this edge! Expand the whole edge unless + * (1) it hit the board edge or (2) was the source of our expansion + * + * for this case (of hitting nothing) we give up trying for corner + * expansions because it is likely that they're not possible anyway + */ + if ((e->expand_dir == ALL ? e->rb->came_from : e->expand_dir) != ((dir + 2) % 4)) { + /* ok, we are not going back on ourselves, and the whole edge seems free */ + moveable_edge(edges, &rb->sbox, dir, rb, NULL, e, targets, s, NULL, NULL); + } + + if (last > 0) { + /* expand the leftover from the prior direction */ + BoxType db = previous_edge(last, dir, &rb->sbox); + moveable_edge(edges, &db, (direction_t) (dir - 1), rb, NULL, e, targets, s, NULL, NULL); + } + last = -1; } - else - { - /* this is just a boring straight expansion - * since the orthogonal segment was blocked - */ - moveable_edge (edges, &broke.left, dir, rb, NULL, e, - targets, s, NULL, NULL); + } /* for loop */ + /* finally, check for the NW corner now that we've come full circle */ + if (first > 0 && last > 0) { + BoxType db = rb->sbox; + db.X2 = first; + db.Y2 = last; + moveable_edge(edges, &db, NW, rb, NULL, e, targets, s, NULL, NULL); + } + else { + if (first > 0) { + BoxType db = rb->sbox; + db.X2 = first; + moveable_edge(edges, &db, NORTH, rb, NULL, e, targets, s, NULL, NULL); } - } /* broke.is_valid_left */ - else if (last > 0) - { - /* if the last one didn't become a corner, - * we still want to expand it straight out - * in the direction of the previous edge, - * which it belongs to. - */ - BoxType db = previous_edge (last, dir, &rb->sbox); - moveable_edge (edges, &db, (direction_t)(dir - 1), rb, NULL, e, targets, s, - NULL, NULL); - } - if (broke.is_valid_center && !blk->flags.source) - moveable_edge (edges, &broke.center, dir, rb, blk, e, targets, s, - tree, area_vec); - /* this is the heap extraction loop. We break out - * if there's nothing left in the heap, but if we * are blocked all the way to the far edge, we can - * just leave stuff in the heap when it is destroyed - */ - while (broke.is_valid_right) - { - /* move the box edge to the next potential free point */ - switch (dir) - { - case NORTH: - last = b.X1 = MAX (broke.right.X1, b.X1); - break; - case EAST: - last = b.Y1 = MAX (broke.right.Y1, b.Y1); - break; - case SOUTH: - last = b.X2 = MIN (broke.right.X2, b.X2); - break; - case WEST: - last = b.Y2 = MIN (broke.right.Y2, b.Y2); - break; - default: - assert (0); + else if (last > 0) { + BoxType db = rb->sbox; + db.Y2 = last; + moveable_edge(edges, &db, WEST, rb, NULL, e, targets, s, NULL, NULL); } - if (heap_is_empty (heap[dir])) - break; - blk = (routebox_t *)heap_remove_smallest (heap[dir]); - broke = break_box_edge (&b, dir, blk); - if (broke.is_valid_left) - moveable_edge (edges, &broke.left, dir, rb, NULL, e, targets, - s, NULL, NULL); - if (broke.is_valid_center && !blk->flags.source) - moveable_edge (edges, &broke.center, dir, rb, blk, e, targets, - s, tree, area_vec); - } - if (!broke.is_valid_right) - last = -1; } - else /* if (heap[dir]) */ - { - /* nothing touched this edge! Expand the whole edge unless - * (1) it hit the board edge or (2) was the source of our expansion - * - * for this case (of hitting nothing) we give up trying for corner - * expansions because it is likely that they're not possible anyway - */ - if ((e->expand_dir == ALL ? e->rb->came_from : e->expand_dir) != - ((dir + 2) % 4)) - { - /* ok, we are not going back on ourselves, and the whole edge seems free */ - moveable_edge (edges, &rb->sbox, dir, rb, NULL, e, targets, s, - NULL, NULL); - } - - if (last > 0) - { - /* expand the leftover from the prior direction */ - BoxType db = previous_edge (last, dir, &rb->sbox); - moveable_edge (edges, &db, (direction_t)(dir - 1), rb, NULL, e, targets, s, - NULL, NULL); - } - last = -1; + /* done with all expansion edges of this box */ + for (dir = NORTH; dir <= WEST; dir = directionIncrement(dir)) { + if (heap[dir]) + heap_destroy(&heap[dir]); } - } /* for loop */ - /* finally, check for the NW corner now that we've come full circle */ - if (first > 0 && last > 0) - { - BoxType db = rb->sbox; - db.X2 = first; - db.Y2 = last; - moveable_edge (edges, &db, NW, rb, NULL, e, targets, s, NULL, NULL); - } - else - { - if (first > 0) - { - BoxType db = rb->sbox; - db.X2 = first; - moveable_edge (edges, &db, NORTH, rb, NULL, e, targets, s, NULL, - NULL); - } - else if (last > 0) - { - BoxType db = rb->sbox; - db.Y2 = last; - moveable_edge (edges, &db, WEST, rb, NULL, e, targets, s, NULL, - NULL); - } - } - /* done with all expansion edges of this box */ - for (dir = NORTH; dir <= WEST; dir = directionIncrement(dir)) - { - if (heap[dir]) - heap_destroy (&heap[dir]); - } - return edges; + return edges; } -static routebox_t * -rb_source (routebox_t * rb) +static routebox_t *rb_source(routebox_t * rb) { - while (rb && !rb->flags.source) - { - assert (rb->type == EXPANSION_AREA); - rb = rb->parent.expansion_area; - } - assert (rb); - return rb; + while (rb && !rb->flags.source) { + assert(rb->type == EXPANSION_AREA); + rb = rb->parent.expansion_area; + } + assert(rb); + return rb; } /* ------------ */ -struct foib_info -{ - const BoxType *box; - routebox_t *intersect; - jmp_buf env; +struct foib_info { + const BoxType *box; + routebox_t *intersect; + jmp_buf env; }; -static int -foib_rect_in_reg (const BoxType * box, void *cl) +static int foib_rect_in_reg(const BoxType * box, void *cl) { - struct foib_info *foib = (struct foib_info *) cl; - BoxType rbox; - routebox_t *rb = (routebox_t *) box; - if (rb->flags.touched) - return 0; + struct foib_info *foib = (struct foib_info *) cl; + BoxType rbox; + routebox_t *rb = (routebox_t *) box; + if (rb->flags.touched) + return 0; /* if (rb->type == EXPANSION_AREA && !rb->flags.is_via)*/ - /* return 0; */ - rbox = bloat_routebox (rb); - if (!box_intersect (&rbox, foib->box)) - return 0; - /* this is an intersector! */ - foib->intersect = (routebox_t *) box; - longjmp (foib->env, 1); /* skip to the end! */ - return 1; + /* return 0; */ + rbox = bloat_routebox(rb); + if (!box_intersect(&rbox, foib->box)) + return 0; + /* this is an intersector! */ + foib->intersect = (routebox_t *) box; + longjmp(foib->env, 1); /* skip to the end! */ + return 1; } -static routebox_t * -FindOneInBox (rtree_t * rtree, routebox_t * rb) + +static routebox_t *FindOneInBox(rtree_t * rtree, routebox_t * rb) { - struct foib_info foib; - BoxType r; + struct foib_info foib; + BoxType r; - r = rb->sbox; - foib.box = &r; - foib.intersect = NULL; + r = rb->sbox; + foib.box = &r; + foib.intersect = NULL; - if (setjmp (foib.env) == 0) - r_search (rtree, &r, NULL, foib_rect_in_reg, &foib); - return foib.intersect; + if (setjmp(foib.env) == 0) + r_search(rtree, &r, NULL, foib_rect_in_reg, &foib); + return foib.intersect; } -struct therm_info -{ - routebox_t *plane; - BoxType query; - jmp_buf env; +struct therm_info { + routebox_t *plane; + BoxType query; + jmp_buf env; }; -static int -ftherm_rect_in_reg (const BoxType * box, void *cl) +static int ftherm_rect_in_reg(const BoxType * box, void *cl) { - routebox_t *rbox = (routebox_t *) box; - struct therm_info *ti = (struct therm_info *) cl; - BoxType sq, sb; + routebox_t *rbox = (routebox_t *) box; + struct therm_info *ti = (struct therm_info *) cl; + BoxType sq, sb; - if (rbox->type != PIN && rbox->type != VIA && rbox->type != VIA_SHADOW) - return 0; - if (rbox->group != ti->plane->group) - return 0; + if (rbox->type != PIN && rbox->type != VIA && rbox->type != VIA_SHADOW) + return 0; + if (rbox->group != ti->plane->group) + return 0; - sb = shrink_routebox (rbox); - switch (rbox->type) - { - case PIN: - sq = shrink_box (&ti->query, rbox->parent.pin->Thickness); - if (!box_intersect (&sb, &sq)) - return 0; - sb.X1 = rbox->parent.pin->X; - sb.Y1 = rbox->parent.pin->Y; - break; - case VIA: - if (rbox->flags.fixed) - { - sq = shrink_box (&ti->query, rbox->parent.via->Thickness); - sb.X1 = rbox->parent.pin->X; - sb.Y1 = rbox->parent.pin->Y; + sb = shrink_routebox(rbox); + switch (rbox->type) { + case PIN: + sq = shrink_box(&ti->query, rbox->parent.pin->Thickness); + if (!box_intersect(&sb, &sq)) + return 0; + sb.X1 = rbox->parent.pin->X; + sb.Y1 = rbox->parent.pin->Y; + break; + case VIA: + if (rbox->flags.fixed) { + sq = shrink_box(&ti->query, rbox->parent.via->Thickness); + sb.X1 = rbox->parent.pin->X; + sb.Y1 = rbox->parent.pin->Y; + } + else { + sq = shrink_box(&ti->query, rbox->style->Diameter); + sb.X1 = CENTER_X(sb); + sb.Y1 = CENTER_Y(sb); + } + if (!box_intersect(&sb, &sq)) + return 0; + break; + case VIA_SHADOW: + sq = shrink_box(&ti->query, rbox->style->Diameter); + if (!box_intersect(&sb, &sq)) + return 0; + sb.X1 = CENTER_X(sb); + sb.Y1 = CENTER_Y(sb); + break; + default: + assert(0); } - else - { - sq = shrink_box (&ti->query, rbox->style->Diameter); - sb.X1 = CENTER_X (sb); - sb.Y1 = CENTER_Y (sb); - } - if (!box_intersect (&sb, &sq)) - return 0; - break; - case VIA_SHADOW: - sq = shrink_box (&ti->query, rbox->style->Diameter); - if (!box_intersect (&sb, &sq)) - return 0; - sb.X1 = CENTER_X (sb); - sb.Y1 = CENTER_Y (sb); - break; - default: - assert (0); - } - ti->plane = rbox; - longjmp (ti->env, 1); - return 1; + ti->plane = rbox; + longjmp(ti->env, 1); + return 1; } /* check for a pin or via target that a polygon can just use a thermal to connect to */ -routebox_t * -FindThermable (rtree_t * rtree, routebox_t * rb) +routebox_t *FindThermable(rtree_t * rtree, routebox_t * rb) { - struct therm_info info; + struct therm_info info; - info.plane = rb; - info.query = shrink_routebox (rb); + info.plane = rb; + info.query = shrink_routebox(rb); - if (setjmp (info.env) == 0) - { - r_search (rtree, &info.query, NULL, ftherm_rect_in_reg, &info); - return NULL; - } - return info.plane; + if (setjmp(info.env) == 0) { + r_search(rtree, &info.query, NULL, ftherm_rect_in_reg, &info); + return NULL; + } + return info.plane; } /*-------------------------------------------------------------------- @@ -3171,316 +2814,272 @@ * Route-tracing code: once we've got a path of expansion boxes, trace * a line through them to actually create the connection. */ -static void -RD_DrawThermal (routedata_t * rd, Coord X, Coord Y, - Cardinal group, Cardinal layer, routebox_t * subnet, - bool is_bad) +static void RD_DrawThermal(routedata_t * rd, Coord X, Coord Y, Cardinal group, Cardinal layer, routebox_t * subnet, bool is_bad) { - routebox_t *rb; - rb = (routebox_t *) malloc (sizeof (*rb)); - memset ((void *) rb, 0, sizeof (*rb)); - init_const_box (rb, X, Y, X + 1, Y + 1, 0); - rb->group = group; - rb->layer = layer; - rb->flags.fixed = 0; - rb->flags.is_bad = is_bad; - rb->flags.is_odd = AutoRouteParameters.is_odd; - rb->flags.circular = 0; - rb->style = AutoRouteParameters.style; - rb->type = THERMAL; - InitLists (rb); - MergeNets (rb, subnet, NET); - MergeNets (rb, subnet, SUBNET); - /* add it to the r-tree, this may be the whole route! */ - r_insert_entry (rd->layergrouptree[rb->group], &rb->box, 1); - rb->flags.homeless = 0; + routebox_t *rb; + rb = (routebox_t *) malloc(sizeof(*rb)); + memset((void *) rb, 0, sizeof(*rb)); + init_const_box(rb, X, Y, X + 1, Y + 1, 0); + rb->group = group; + rb->layer = layer; + rb->flags.fixed = 0; + rb->flags.is_bad = is_bad; + rb->flags.is_odd = AutoRouteParameters.is_odd; + rb->flags.circular = 0; + rb->style = AutoRouteParameters.style; + rb->type = THERMAL; + InitLists(rb); + MergeNets(rb, subnet, NET); + MergeNets(rb, subnet, SUBNET); + /* add it to the r-tree, this may be the whole route! */ + r_insert_entry(rd->layergrouptree[rb->group], &rb->box, 1); + rb->flags.homeless = 0; } -static void -RD_DrawVia (routedata_t * rd, Coord X, Coord Y, - Coord radius, routebox_t * subnet, bool is_bad) +static void RD_DrawVia(routedata_t * rd, Coord X, Coord Y, Coord radius, routebox_t * subnet, bool is_bad) { - routebox_t *rb, *first_via = NULL; - int i; - int ka = AutoRouteParameters.style->Keepaway; - PinType *live_via = NULL; + routebox_t *rb, *first_via = NULL; + int i; + int ka = AutoRouteParameters.style->Keepaway; + PinType *live_via = NULL; - if (TEST_FLAG (LIVEROUTEFLAG, PCB)) - { - live_via = CreateNewVia (PCB->Data, X, Y, radius * 2, - 2 * AutoRouteParameters.style->Keepaway, 0, - AutoRouteParameters.style->Hole, NULL, - MakeFlags (0)); - if (live_via != NULL) - DrawVia (live_via); - } + if (TEST_FLAG(LIVEROUTEFLAG, PCB)) { + live_via = CreateNewVia(PCB->Data, X, Y, radius * 2, + 2 * AutoRouteParameters.style->Keepaway, 0, AutoRouteParameters.style->Hole, NULL, MakeFlags(0)); + if (live_via != NULL) + DrawVia(live_via); + } - /* a via cuts through every layer group */ - for (i = 0; i < max_group; i++) - { - if (!is_layer_group_active[i]) - continue; - rb = (routebox_t *) malloc (sizeof (*rb)); - memset ((void *) rb, 0, sizeof (*rb)); - init_const_box (rb, - /*X1 */ X - radius, /*Y1 */ Y - radius, - /*X2 */ X + radius + 1, /*Y2 */ Y + radius + 1, ka); - rb->group = i; - rb->flags.fixed = 0; /* indicates that not on PCB yet */ - rb->flags.is_odd = AutoRouteParameters.is_odd; - rb->flags.is_bad = is_bad; - rb->came_from = ALL; - rb->flags.circular = true; - rb->style = AutoRouteParameters.style; - rb->pass = AutoRouteParameters.pass; - if (first_via == NULL) - { - rb->type = VIA; - rb->parent.via = NULL; /* indicates that not on PCB yet */ - first_via = rb; - /* only add the first via to mtspace, not the shadows too */ - mtspace_add (rd->mtspace, &rb->box, rb->flags.is_odd ? ODD : EVEN, - rb->style->Keepaway); + /* a via cuts through every layer group */ + for (i = 0; i < max_group; i++) { + if (!is_layer_group_active[i]) + continue; + rb = (routebox_t *) malloc(sizeof(*rb)); + memset((void *) rb, 0, sizeof(*rb)); + init_const_box(rb, + /*X1 */ X - radius, /*Y1 */ Y - radius, + /*X2 */ X + radius + 1, /*Y2 */ Y + radius + 1, ka); + rb->group = i; + rb->flags.fixed = 0; /* indicates that not on PCB yet */ + rb->flags.is_odd = AutoRouteParameters.is_odd; + rb->flags.is_bad = is_bad; + rb->came_from = ALL; + rb->flags.circular = true; + rb->style = AutoRouteParameters.style; + rb->pass = AutoRouteParameters.pass; + if (first_via == NULL) { + rb->type = VIA; + rb->parent.via = NULL; /* indicates that not on PCB yet */ + first_via = rb; + /* only add the first via to mtspace, not the shadows too */ + mtspace_add(rd->mtspace, &rb->box, rb->flags.is_odd ? ODD : EVEN, rb->style->Keepaway); + } + else { + rb->type = VIA_SHADOW; + rb->parent.via_shadow = first_via; + } + InitLists(rb); + /* add these to proper subnet. */ + MergeNets(rb, subnet, NET); + MergeNets(rb, subnet, SUBNET); + assert(__routebox_is_good(rb)); + /* and add it to the r-tree! */ + r_insert_entry(rd->layergrouptree[rb->group], &rb->box, 1); + rb->flags.homeless = 0; /* not homeless anymore */ + rb->livedraw_obj.via = live_via; } - else - { - rb->type = VIA_SHADOW; - rb->parent.via_shadow = first_via; - } - InitLists (rb); - /* add these to proper subnet. */ - MergeNets (rb, subnet, NET); - MergeNets (rb, subnet, SUBNET); - assert (__routebox_is_good (rb)); - /* and add it to the r-tree! */ - r_insert_entry (rd->layergrouptree[rb->group], &rb->box, 1); - rb->flags.homeless = 0; /* not homeless anymore */ - rb->livedraw_obj.via = live_via; - } } + static void -RD_DrawLine (routedata_t * rd, - Coord X1, Coord Y1, Coord X2, - Coord Y2, Coord halfthick, Cardinal group, - routebox_t * subnet, bool is_bad, bool is_45) +RD_DrawLine(routedata_t * rd, + Coord X1, Coord Y1, Coord X2, + Coord Y2, Coord halfthick, Cardinal group, routebox_t * subnet, bool is_bad, bool is_45) { - /* we hold the line in a queue to concatenate segments that - * ajoin one another. That reduces the number of things in - * the trees and allows conflict boxes to be larger, both of - * which are really useful. - */ - static Coord qX1 = -1, qY1, qX2, qY2; - static Coord qhthick; - static Cardinal qgroup; - static bool qis_45, qis_bad; - static routebox_t *qsn; + /* we hold the line in a queue to concatenate segments that + * ajoin one another. That reduces the number of things in + * the trees and allows conflict boxes to be larger, both of + * which are really useful. + */ + static Coord qX1 = -1, qY1, qX2, qY2; + static Coord qhthick; + static Cardinal qgroup; + static bool qis_45, qis_bad; + static routebox_t *qsn; - routebox_t *rb; - Coord ka = AutoRouteParameters.style->Keepaway; + routebox_t *rb; + Coord ka = AutoRouteParameters.style->Keepaway; - /* don't draw zero-length segments. */ - if (X1 == X2 && Y1 == Y2) - return; - if (qX1 == -1) /* first ever */ - { - qX1 = X1; - qY1 = Y1; - qX2 = X2; - qY2 = Y2; - qhthick = halfthick; - qgroup = group; - qis_45 = is_45; - qis_bad = is_bad; - qsn = subnet; - return; - } - /* Check if the lines concatenat. We only check the - * normal expected nextpoint=lastpoint condition - */ - if (X1 == qX2 && Y1 == qY2 && qhthick == halfthick && qgroup == group) - { - if (qX1 == qX2 && X1 == X2) /* everybody on the same X here */ - { - qY2 = Y2; - return; + /* don't draw zero-length segments. */ + if (X1 == X2 && Y1 == Y2) + return; + if (qX1 == -1) { /* first ever */ + qX1 = X1; + qY1 = Y1; + qX2 = X2; + qY2 = Y2; + qhthick = halfthick; + qgroup = group; + qis_45 = is_45; + qis_bad = is_bad; + qsn = subnet; + return; } - if (qY1 == qY2 && Y1 == Y2) /* same Y all around */ - { - qX2 = X2; - return; + /* Check if the lines concatenat. We only check the + * normal expected nextpoint=lastpoint condition + */ + if (X1 == qX2 && Y1 == qY2 && qhthick == halfthick && qgroup == group) { + if (qX1 == qX2 && X1 == X2) { /* everybody on the same X here */ + qY2 = Y2; + return; + } + if (qY1 == qY2 && Y1 == Y2) { /* same Y all around */ + qX2 = X2; + return; + } } - } - /* dump the queue, no match here */ - if (qX1 == -1) - return; /* but not this! */ - rb = (routebox_t *) malloc (sizeof (*rb)); - memset ((void *) rb, 0, sizeof (*rb)); - assert (is_45 ? (ABS (qX2 - qX1) == ABS (qY2 - qY1)) /* line must be 45-degrees */ - : (qX1 == qX2 || qY1 == qY2) /* line must be ortho */ ); - init_const_box (rb, - /*X1 */ MIN (qX1, qX2) - qhthick, - /*Y1 */ MIN (qY1, qY2) - qhthick, - /*X2 */ MAX (qX1, qX2) + qhthick + 1, - /*Y2 */ MAX (qY1, qY2) + qhthick + 1, ka); - rb->group = qgroup; - rb->type = LINE; - rb->parent.line = NULL; /* indicates that not on PCB yet */ - rb->flags.fixed = 0; /* indicates that not on PCB yet */ - rb->flags.is_odd = AutoRouteParameters.is_odd; - rb->flags.is_bad = qis_bad; - rb->came_from = ALL; - rb->flags.homeless = 0; /* we're putting this in the tree */ - rb->flags.nonstraight = qis_45; - rb->flags.bl_to_ur = ((qX2 >= qX1 && qY2 <= qY1) - || (qX2 <= qX1 && qY2 >= qY1)); - rb->style = AutoRouteParameters.style; - rb->pass = AutoRouteParameters.pass; - InitLists (rb); - /* add these to proper subnet. */ - MergeNets (rb, qsn, NET); - MergeNets (rb, qsn, SUBNET); - assert (__routebox_is_good (rb)); - /* and add it to the r-tree! */ - r_insert_entry (rd->layergrouptree[rb->group], &rb->box, 1); + /* dump the queue, no match here */ + if (qX1 == -1) + return; /* but not this! */ + rb = (routebox_t *) malloc(sizeof(*rb)); + memset((void *) rb, 0, sizeof(*rb)); + assert(is_45 ? (ABS(qX2 - qX1) == ABS(qY2 - qY1)) /* line must be 45-degrees */ + : (qX1 == qX2 || qY1 == qY2) /* line must be ortho */ ); + init_const_box(rb, + /*X1 */ MIN(qX1, qX2) - qhthick, + /*Y1 */ MIN(qY1, qY2) - qhthick, + /*X2 */ MAX(qX1, qX2) + qhthick + 1, + /*Y2 */ MAX(qY1, qY2) + qhthick + 1, ka); + rb->group = qgroup; + rb->type = LINE; + rb->parent.line = NULL; /* indicates that not on PCB yet */ + rb->flags.fixed = 0; /* indicates that not on PCB yet */ + rb->flags.is_odd = AutoRouteParameters.is_odd; + rb->flags.is_bad = qis_bad; + rb->came_from = ALL; + rb->flags.homeless = 0; /* we're putting this in the tree */ + rb->flags.nonstraight = qis_45; + rb->flags.bl_to_ur = ((qX2 >= qX1 && qY2 <= qY1) + || (qX2 <= qX1 && qY2 >= qY1)); + rb->style = AutoRouteParameters.style; + rb->pass = AutoRouteParameters.pass; + InitLists(rb); + /* add these to proper subnet. */ + MergeNets(rb, qsn, NET); + MergeNets(rb, qsn, SUBNET); + assert(__routebox_is_good(rb)); + /* and add it to the r-tree! */ + r_insert_entry(rd->layergrouptree[rb->group], &rb->box, 1); - if (TEST_FLAG (LIVEROUTEFLAG, PCB)) - { - LayerType *layer = LAYER_PTR (PCB->LayerGroups.Entries[rb->group][0]); - LineType *line = CreateNewLineOnLayer (layer, qX1, qY1, qX2, qY2, - 2 * qhthick, 0, MakeFlags (0)); - rb->livedraw_obj.line = line; - if (line != NULL) - DrawLine (layer, line); - } + if (TEST_FLAG(LIVEROUTEFLAG, PCB)) { + LayerType *layer = LAYER_PTR(PCB->LayerGroups.Entries[rb->group][0]); + LineType *line = CreateNewLineOnLayer(layer, qX1, qY1, qX2, qY2, + 2 * qhthick, 0, MakeFlags(0)); + rb->livedraw_obj.line = line; + if (line != NULL) + DrawLine(layer, line); + } - /* and to the via space structures */ - if (AutoRouteParameters.use_vias) - mtspace_add (rd->mtspace, &rb->box, rb->flags.is_odd ? ODD : EVEN, - rb->style->Keepaway); - usedGroup[rb->group] = true; - /* and queue this one */ - qX1 = X1; - qY1 = Y1; - qX2 = X2; - qY2 = Y2; - qhthick = halfthick; - qgroup = group; - qis_45 = is_45; - qis_bad = is_bad; - qsn = subnet; + /* and to the via space structures */ + if (AutoRouteParameters.use_vias) + mtspace_add(rd->mtspace, &rb->box, rb->flags.is_odd ? ODD : EVEN, rb->style->Keepaway); + usedGroup[rb->group] = true; + /* and queue this one */ + qX1 = X1; + qY1 = Y1; + qX2 = X2; + qY2 = Y2; + qhthick = halfthick; + qgroup = group; + qis_45 = is_45; + qis_bad = is_bad; + qsn = subnet; } static bool -RD_DrawManhattanLine (routedata_t * rd, - const BoxType * box1, const BoxType * box2, - CheapPointType start, CheapPointType end, - Coord halfthick, Cardinal group, - routebox_t * subnet, bool is_bad, bool last_was_x) +RD_DrawManhattanLine(routedata_t * rd, + const BoxType * box1, const BoxType * box2, + CheapPointType start, CheapPointType end, + Coord halfthick, Cardinal group, routebox_t * subnet, bool is_bad, bool last_was_x) { - CheapPointType knee = start; - if (end.X == start.X) - { - RD_DrawLine (rd, start.X, start.Y, end.X, end.Y, halfthick, group, - subnet, is_bad, false); - return false; - } - else if (end.Y == start.Y) - { - RD_DrawLine (rd, start.X, start.Y, end.X, end.Y, halfthick, group, - subnet, is_bad, false); - return true; - } - /* find where knee belongs */ - if (point_in_box (box1, end.X, start.Y) - || point_in_box (box2, end.X, start.Y)) - { - knee.X = end.X; - knee.Y = start.Y; - } - else - { - knee.X = start.X; - knee.Y = end.Y; - } - if ((knee.X == end.X && !last_was_x) && - (point_in_box (box1, start.X, end.Y) - || point_in_box (box2, start.X, end.Y))) - { - knee.X = start.X; - knee.Y = end.Y; - } - assert (AutoRouteParameters.is_smoothing - || point_in_closed_box (box1, knee.X, knee.Y) - || point_in_closed_box (box2, knee.X, knee.Y)); + CheapPointType knee = start; + if (end.X == start.X) { + RD_DrawLine(rd, start.X, start.Y, end.X, end.Y, halfthick, group, subnet, is_bad, false); + return false; + } + else if (end.Y == start.Y) { + RD_DrawLine(rd, start.X, start.Y, end.X, end.Y, halfthick, group, subnet, is_bad, false); + return true; + } + /* find where knee belongs */ + if (point_in_box(box1, end.X, start.Y) + || point_in_box(box2, end.X, start.Y)) { + knee.X = end.X; + knee.Y = start.Y; + } + else { + knee.X = start.X; + knee.Y = end.Y; + } + if ((knee.X == end.X && !last_was_x) && (point_in_box(box1, start.X, end.Y) + || point_in_box(box2, start.X, end.Y))) { + knee.X = start.X; + knee.Y = end.Y; + } + assert(AutoRouteParameters.is_smoothing || point_in_closed_box(box1, knee.X, knee.Y) + || point_in_closed_box(box2, knee.X, knee.Y)); - if (1 || !AutoRouteParameters.is_smoothing) - { - /* draw standard manhattan paths */ - RD_DrawLine (rd, start.X, start.Y, knee.X, knee.Y, halfthick, group, - subnet, is_bad, false); - RD_DrawLine (rd, knee.X, knee.Y, end.X, end.Y, halfthick, group, - subnet, is_bad, false); - } - else - { - /* draw 45-degree path across knee */ - Coord len45 = MIN (ABS (start.X - end.X), ABS (start.Y - end.Y)); - CheapPointType kneestart = knee, kneeend = knee; - if (kneestart.X == start.X) - kneestart.Y += (kneestart.Y > start.Y) ? -len45 : len45; - else - kneestart.X += (kneestart.X > start.X) ? -len45 : len45; - if (kneeend.X == end.X) - kneeend.Y += (kneeend.Y > end.Y) ? -len45 : len45; - else - kneeend.X += (kneeend.X > end.X) ? -len45 : len45; - RD_DrawLine (rd, start.X, start.Y, kneestart.X, kneestart.Y, halfthick, - group, subnet, is_bad, false); - RD_DrawLine (rd, kneestart.X, kneestart.Y, kneeend.X, kneeend.Y, - halfthick, group, subnet, is_bad, true); - RD_DrawLine (rd, kneeend.X, kneeend.Y, end.X, end.Y, halfthick, group, - subnet, is_bad, false); - } - return (knee.X != end.X); + if (1 || !AutoRouteParameters.is_smoothing) { + /* draw standard manhattan paths */ + RD_DrawLine(rd, start.X, start.Y, knee.X, knee.Y, halfthick, group, subnet, is_bad, false); + RD_DrawLine(rd, knee.X, knee.Y, end.X, end.Y, halfthick, group, subnet, is_bad, false); + } + else { + /* draw 45-degree path across knee */ + Coord len45 = MIN(ABS(start.X - end.X), ABS(start.Y - end.Y)); + CheapPointType kneestart = knee, kneeend = knee; + if (kneestart.X == start.X) + kneestart.Y += (kneestart.Y > start.Y) ? -len45 : len45; + else + kneestart.X += (kneestart.X > start.X) ? -len45 : len45; + if (kneeend.X == end.X) + kneeend.Y += (kneeend.Y > end.Y) ? -len45 : len45; + else + kneeend.X += (kneeend.X > end.X) ? -len45 : len45; + RD_DrawLine(rd, start.X, start.Y, kneestart.X, kneestart.Y, halfthick, group, subnet, is_bad, false); + RD_DrawLine(rd, kneestart.X, kneestart.Y, kneeend.X, kneeend.Y, halfthick, group, subnet, is_bad, true); + RD_DrawLine(rd, kneeend.X, kneeend.Y, end.X, end.Y, halfthick, group, subnet, is_bad, false); + } + return (knee.X != end.X); } /* for smoothing, don't pack traces to min clearance gratuitously */ #if 0 -static void -add_clearance (CheapPointType * nextpoint, const BoxType * b) +static void add_clearance(CheapPointType * nextpoint, const BoxType * b) { - if (nextpoint->X == b->X1) - { - if (nextpoint->X + - AutoRouteParameters.style->Keepaway < (b->X1 + b->X2) / 2) - nextpoint->X += AutoRouteParameters.style->Keepaway; - else - nextpoint->X = (b->X1 + b->X2) / 2; - } - else if (nextpoint->X == b->X2) - { - if (nextpoint->X - - AutoRouteParameters.style->Keepaway > (b->X1 + b->X2) / 2) - nextpoint->X -= AutoRouteParameters.style->Keepaway; - else - nextpoint->X = (b->X1 + b->X2) / 2; - } - else if (nextpoint->Y == b->Y1) - { - if (nextpoint->Y + - AutoRouteParameters.style->Keepaway < (b->Y1 + b->Y2) / 2) - nextpoint->Y += AutoRouteParameters.style->Keepaway; - else - nextpoint->Y = (b->Y1 + b->Y2) / 2; - } - else if (nextpoint->Y == b->Y2) - { - if (nextpoint->Y - - AutoRouteParameters.style->Keepaway > (b->Y1 + b->Y2) / 2) - nextpoint->Y -= AutoRouteParameters.style->Keepaway; - else - nextpoint->Y = (b->Y1 + b->Y2) / 2; - } + if (nextpoint->X == b->X1) { + if (nextpoint->X + AutoRouteParameters.style->Keepaway < (b->X1 + b->X2) / 2) + nextpoint->X += AutoRouteParameters.style->Keepaway; + else + nextpoint->X = (b->X1 + b->X2) / 2; + } + else if (nextpoint->X == b->X2) { + if (nextpoint->X - AutoRouteParameters.style->Keepaway > (b->X1 + b->X2) / 2) + nextpoint->X -= AutoRouteParameters.style->Keepaway; + else + nextpoint->X = (b->X1 + b->X2) / 2; + } + else if (nextpoint->Y == b->Y1) { + if (nextpoint->Y + AutoRouteParameters.style->Keepaway < (b->Y1 + b->Y2) / 2) + nextpoint->Y += AutoRouteParameters.style->Keepaway; + else + nextpoint->Y = (b->Y1 + b->Y2) / 2; + } + else if (nextpoint->Y == b->Y2) { + if (nextpoint->Y - AutoRouteParameters.style->Keepaway > (b->Y1 + b->Y2) / 2) + nextpoint->Y -= AutoRouteParameters.style->Keepaway; + else + nextpoint->Y = (b->Y1 + b->Y2) / 2; + } } #endif @@ -3496,375 +3095,323 @@ * as they don't poke more than half thick outside the path box. */ -static void -TracePath (routedata_t * rd, routebox_t * path, const routebox_t * target, - routebox_t * subnet, bool is_bad) +static void TracePath(routedata_t * rd, routebox_t * path, const routebox_t * target, routebox_t * subnet, bool is_bad) { - bool last_x = false; - Coord halfwidth = HALF_THICK (AutoRouteParameters.style->Thick); - Coord radius = HALF_THICK (AutoRouteParameters.style->Diameter); - CheapPointType lastpoint, nextpoint; - routebox_t *lastpath; - BoxType b; + bool last_x = false; + Coord halfwidth = HALF_THICK(AutoRouteParameters.style->Thick); + Coord radius = HALF_THICK(AutoRouteParameters.style->Diameter); + CheapPointType lastpoint, nextpoint; + routebox_t *lastpath; + BoxType b; - assert (subnet->style == AutoRouteParameters.style); - /*XXX: because we round up odd thicknesses, there's the possibility that - * a connecting line end-point might be 0.005 mil off the "real" edge. - * don't worry about this because line *thicknesses* are always >= 0.01 mil. */ + assert(subnet->style == AutoRouteParameters.style); + /*XXX: because we round up odd thicknesses, there's the possibility that + * a connecting line end-point might be 0.005 mil off the "real" edge. + * don't worry about this because line *thicknesses* are always >= 0.01 mil. */ - /* if we start with a thermal the target was a plane - * or the target was a pin and the source a plane - * in which case this thermal is the whole path - */ - if (path->flags.is_thermal) - { - /* the target was a plane, so we need to find a good spot for the via - * now. It's logical to place it close to the source box which - * is where we're utlimately headed on this path. However, it - * must reside in the plane as well as the via area too. - */ - nextpoint.X = CENTER_X (path->sbox); - nextpoint.Y = CENTER_Y (path->sbox); - if (path->parent.expansion_area->flags.is_via) - { - TargetPoint (&nextpoint, rb_source (path)); - /* nextpoint is the middle of the source terminal now */ - b = clip_box (&path->sbox, &path->parent.expansion_area->sbox); - nextpoint = closest_point_in_box (&nextpoint, &b); - /* now it's in the via and plane near the source */ + /* if we start with a thermal the target was a plane + * or the target was a pin and the source a plane + * in which case this thermal is the whole path + */ + if (path->flags.is_thermal) { + /* the target was a plane, so we need to find a good spot for the via + * now. It's logical to place it close to the source box which + * is where we're utlimately headed on this path. However, it + * must reside in the plane as well as the via area too. + */ + nextpoint.X = CENTER_X(path->sbox); + nextpoint.Y = CENTER_Y(path->sbox); + if (path->parent.expansion_area->flags.is_via) { + TargetPoint(&nextpoint, rb_source(path)); + /* nextpoint is the middle of the source terminal now */ + b = clip_box(&path->sbox, &path->parent.expansion_area->sbox); + nextpoint = closest_point_in_box(&nextpoint, &b); + /* now it's in the via and plane near the source */ + } + else { /* no via coming, target must have been a pin */ + + assert(target->type == PIN); + TargetPoint(&nextpoint, target); + } + assert(point_in_box(&path->sbox, nextpoint.X, nextpoint.Y)); + RD_DrawThermal(rd, nextpoint.X, nextpoint.Y, path->group, path->layer, subnet, is_bad); } - else /* no via coming, target must have been a pin */ - { - assert (target->type == PIN); - TargetPoint (&nextpoint, target); + else { + /* start from best place of target box */ + lastpoint.X = CENTER_X(target->sbox); + lastpoint.Y = CENTER_Y(target->sbox); + TargetPoint(&lastpoint, target); + if (AutoRouteParameters.last_smooth && box_in_box(&path->sbox, &target->sbox)) + path = path->parent.expansion_area; + b = path->sbox; + if (path->flags.circular) + b = shrink_box(&b, MIN(b.X2 - b.X1, b.Y2 - b.Y1) / 5); + nextpoint = closest_point_in_box(&lastpoint, &b); + if (AutoRouteParameters.last_smooth) + RD_DrawLine(rd, lastpoint.X, lastpoint.Y, nextpoint.X, nextpoint.Y, halfwidth, path->group, subnet, is_bad, TRUE); + else + last_x = RD_DrawManhattanLine(rd, &target->sbox, &path->sbox, + lastpoint, nextpoint, halfwidth, path->group, subnet, is_bad, last_x); } - assert (point_in_box (&path->sbox, nextpoint.X, nextpoint.Y)); - RD_DrawThermal (rd, nextpoint.X, nextpoint.Y, path->group, - path->layer, subnet, is_bad); - } - else - { - /* start from best place of target box */ - lastpoint.X = CENTER_X (target->sbox); - lastpoint.Y = CENTER_Y (target->sbox); - TargetPoint (&lastpoint, target); - if (AutoRouteParameters.last_smooth - && box_in_box (&path->sbox, &target->sbox)) - path = path->parent.expansion_area; - b = path->sbox; - if (path->flags.circular) - b = shrink_box (&b, MIN (b.X2 - b.X1, b.Y2 - b.Y1) / 5); - nextpoint = closest_point_in_box (&lastpoint, &b); - if (AutoRouteParameters.last_smooth) - RD_DrawLine (rd, lastpoint.X, lastpoint.Y, nextpoint.X, nextpoint.Y, - halfwidth, path->group, subnet, is_bad, TRUE); - else - last_x = RD_DrawManhattanLine (rd, &target->sbox, &path->sbox, - lastpoint, nextpoint, halfwidth, - path->group, subnet, is_bad, last_x); - } #if defined(ROUTE_DEBUG) && defined(DEBUG_SHOW_ROUTE_BOXES) - showroutebox (path); + showroutebox(path); #if defined(ROUTE_VERBOSE) - pcb_printf ("TRACEPOINT start %#mD\n", nextpoint.X, nextpoint.Y); + pcb_printf("TRACEPOINT start %#mD\n", nextpoint.X, nextpoint.Y); #endif #endif - do - { - lastpoint = nextpoint; - lastpath = path; - assert (path->type == EXPANSION_AREA); - path = path->parent.expansion_area; - b = path->sbox; - if (path->flags.circular) - b = shrink_box (&b, MIN (b.X2 - b.X1, b.Y2 - b.Y1) / 5); - assert (b.X1 != b.X2 && b.Y1 != b.Y2); /* need someplace to put line! */ - /* find point on path perimeter closest to last point */ - /* if source terminal, try to hit a good place */ - nextpoint = closest_point_in_box (&lastpoint, &b); + do { + lastpoint = nextpoint; + lastpath = path; + assert(path->type == EXPANSION_AREA); + path = path->parent.expansion_area; + b = path->sbox; + if (path->flags.circular) + b = shrink_box(&b, MIN(b.X2 - b.X1, b.Y2 - b.Y1) / 5); + assert(b.X1 != b.X2 && b.Y1 != b.Y2); /* need someplace to put line! */ + /* find point on path perimeter closest to last point */ + /* if source terminal, try to hit a good place */ + nextpoint = closest_point_in_box(&lastpoint, &b); #if 0 - /* leave more clearance if this is a smoothing pass */ - if (AutoRouteParameters.is_smoothing && - (nextpoint.X != lastpoint.X || nextpoint.Y != lastpoint.Y)) - add_clearance (&nextpoint, &b); + /* leave more clearance if this is a smoothing pass */ + if (AutoRouteParameters.is_smoothing && (nextpoint.X != lastpoint.X || nextpoint.Y != lastpoint.Y)) + add_clearance(&nextpoint, &b); #endif - if (path->flags.source && path->type != PLANE) - TargetPoint (&nextpoint, path); - assert (point_in_box (&lastpath->box, lastpoint.X, lastpoint.Y)); - assert (point_in_box (&path->box, nextpoint.X, nextpoint.Y)); + if (path->flags.source && path->type != PLANE) + TargetPoint(&nextpoint, path); + assert(point_in_box(&lastpath->box, lastpoint.X, lastpoint.Y)); + assert(point_in_box(&path->box, nextpoint.X, nextpoint.Y)); #if defined(ROUTE_DEBUG_VERBOSE) - printf ("TRACEPATH: "); - DumpRouteBox (path); - pcb_printf ("TRACEPATH: point %#mD to point %#mD layer %d\n", - lastpoint.X, lastpoint.Y, nextpoint.X, nextpoint.Y, - path->group); + printf("TRACEPATH: "); + DumpRouteBox(path); + pcb_printf("TRACEPATH: point %#mD to point %#mD layer %d\n", + lastpoint.X, lastpoint.Y, nextpoint.X, nextpoint.Y, path->group); #endif - /* draw orthogonal lines from lastpoint to nextpoint */ - /* knee is placed in lastpath box */ - /* should never cause line to leave union of lastpath/path boxes */ - if (AutoRouteParameters.last_smooth) - RD_DrawLine (rd, lastpoint.X, lastpoint.Y, nextpoint.X, nextpoint.Y, - halfwidth, path->group, subnet, is_bad, TRUE); - else - last_x = RD_DrawManhattanLine (rd, &lastpath->sbox, &path->sbox, - lastpoint, nextpoint, halfwidth, - path->group, subnet, is_bad, last_x); - if (path->flags.is_via) - { /* if via, then add via */ + /* draw orthogonal lines from lastpoint to nextpoint */ + /* knee is placed in lastpath box */ + /* should never cause line to leave union of lastpath/path boxes */ + if (AutoRouteParameters.last_smooth) + RD_DrawLine(rd, lastpoint.X, lastpoint.Y, nextpoint.X, nextpoint.Y, halfwidth, path->group, subnet, is_bad, TRUE); + else + last_x = RD_DrawManhattanLine(rd, &lastpath->sbox, &path->sbox, + lastpoint, nextpoint, halfwidth, path->group, subnet, is_bad, last_x); + if (path->flags.is_via) { /* if via, then add via */ #ifdef ROUTE_VERBOSE - printf (" (vias)"); + printf(" (vias)"); #endif - assert (point_in_box (&path->box, nextpoint.X, nextpoint.Y)); - RD_DrawVia (rd, nextpoint.X, nextpoint.Y, radius, subnet, is_bad); - } + assert(point_in_box(&path->box, nextpoint.X, nextpoint.Y)); + RD_DrawVia(rd, nextpoint.X, nextpoint.Y, radius, subnet, is_bad); + } - assert (lastpath->flags.is_via || path->group == lastpath->group); + assert(lastpath->flags.is_via || path->group == lastpath->group); #if defined(ROUTE_DEBUG) && defined(DEBUG_SHOW_ROUTE_BOXES) - showroutebox (path); + showroutebox(path); #endif /* ROUTE_DEBUG && DEBUG_SHOW_ROUTE_BOXES */ - /* if this is connected to a plane, draw the thermal */ - if (path->flags.is_thermal || path->type == PLANE) - RD_DrawThermal (rd, lastpoint.X, lastpoint.Y, path->group, - path->layer, subnet, is_bad); - /* when one hop from the source, make an extra path in *this* box */ - if (path->type == EXPANSION_AREA - && path->parent.expansion_area->flags.source - && path->parent.expansion_area->type != PLANE) - { - /* find special point on source (if it exists) */ - if (TargetPoint (&lastpoint, path->parent.expansion_area)) - { - lastpoint = closest_point_in_routebox (&lastpoint, path); - b = shrink_routebox (path); + /* if this is connected to a plane, draw the thermal */ + if (path->flags.is_thermal || path->type == PLANE) + RD_DrawThermal(rd, lastpoint.X, lastpoint.Y, path->group, path->layer, subnet, is_bad); + /* when one hop from the source, make an extra path in *this* box */ + if (path->type == EXPANSION_AREA && path->parent.expansion_area->flags.source && path->parent.expansion_area->type != PLANE) { + /* find special point on source (if it exists) */ + if (TargetPoint(&lastpoint, path->parent.expansion_area)) { + lastpoint = closest_point_in_routebox(&lastpoint, path); + b = shrink_routebox(path); #if 0 - if (AutoRouteParameters.is_smoothing) - add_clearance (&lastpoint, &b); + if (AutoRouteParameters.is_smoothing) + add_clearance(&lastpoint, &b); #else - if (AutoRouteParameters.last_smooth) - RD_DrawLine (rd, lastpoint.X, lastpoint.Y, nextpoint.X, - nextpoint.Y, halfwidth, path->group, subnet, - is_bad, TRUE); - else + if (AutoRouteParameters.last_smooth) + RD_DrawLine(rd, lastpoint.X, lastpoint.Y, nextpoint.X, nextpoint.Y, halfwidth, path->group, subnet, is_bad, TRUE); + else #endif - last_x = RD_DrawManhattanLine (rd, &b, &b, - nextpoint, lastpoint, - halfwidth, path->group, subnet, - is_bad, last_x); + last_x = RD_DrawManhattanLine(rd, &b, &b, nextpoint, lastpoint, halfwidth, path->group, subnet, is_bad, last_x); #if defined(ROUTE_DEBUG_VERBOSE) - printf ("TRACEPATH: "); - DumpRouteBox (path); - pcb_printf - ("TRACEPATH: (to source) point %#mD to point %#mD layer %d\n", - nextpoint.X, nextpoint.Y, lastpoint.X, lastpoint.Y, - path->group); + printf("TRACEPATH: "); + DumpRouteBox(path); + pcb_printf + ("TRACEPATH: (to source) point %#mD to point %#mD layer %d\n", + nextpoint.X, nextpoint.Y, lastpoint.X, lastpoint.Y, path->group); #endif - nextpoint = lastpoint; - } + nextpoint = lastpoint; + } + } } - } - while (!path->flags.source); - /* flush the line queue */ - RD_DrawLine (rd, -1, 0, 0, 0, 0, 0, NULL, false, false); + while (!path->flags.source); + /* flush the line queue */ + RD_DrawLine(rd, -1, 0, 0, 0, 0, 0, NULL, false, false); - if (TEST_FLAG (LIVEROUTEFLAG, PCB)) - Draw (); + if (TEST_FLAG(LIVEROUTEFLAG, PCB)) + Draw(); #ifdef ROUTE_DEBUG - if (ddraw != NULL) - ddraw->flush_debug_draw (); + if (ddraw != NULL) + ddraw->flush_debug_draw(); #endif } /* create a fake "edge" used to defer via site searching. */ static void -CreateSearchEdge (struct routeone_state *s, vetting_t * work, edge_t * parent, - routebox_t * rb, conflict_t conflict, rtree_t * targets, - bool in_plane) +CreateSearchEdge(struct routeone_state *s, vetting_t * work, edge_t * parent, + routebox_t * rb, conflict_t conflict, rtree_t * targets, bool in_plane) { - routebox_t *target; - BoxType b; - cost_t cost; - assert (__routebox_is_good (rb)); - /* find the cheapest target */ + routebox_t *target; + BoxType b; + cost_t cost; + assert(__routebox_is_good(rb)); + /* find the cheapest target */ #if 0 - target = - mincost_target_to_point (&parent->cost_point, max_group + 1, targets, - parent->mincost_target); + target = mincost_target_to_point(&parent->cost_point, max_group + 1, targets, parent->mincost_target); #else - target = parent->mincost_target; + target = parent->mincost_target; #endif - b = shrink_routebox (target); - cost = - parent->cost_to_point + AutoRouteParameters.ViaCost + - cost_to_layerless_box (&rb->cost_point, 0, &b); - if (cost < s->best_cost) - { - edge_t *ne; - ne = (edge_t *)malloc (sizeof (*ne)); - memset ((void *) ne, 0, sizeof (*ne)); - assert (ne); - ne->flags.via_search = 1; - ne->flags.in_plane = in_plane; - ne->rb = rb; - if (rb->flags.homeless) - RB_up_count (rb); - ne->work = work; - ne->mincost_target = target; - ne->flags.via_conflict_level = conflict; - ne->cost_to_point = parent->cost_to_point; - ne->cost_point = parent->cost_point; - ne->cost = cost; - heap_insert (s->workheap, ne->cost, ne); - } - else - { - mtsFreeWork (&work); - } + b = shrink_routebox(target); + cost = parent->cost_to_point + AutoRouteParameters.ViaCost + cost_to_layerless_box(&rb->cost_point, 0, &b); + if (cost < s->best_cost) { + edge_t *ne; + ne = (edge_t *) malloc(sizeof(*ne)); + memset((void *) ne, 0, sizeof(*ne)); + assert(ne); + ne->flags.via_search = 1; + ne->flags.in_plane = in_plane; + ne->rb = rb; + if (rb->flags.homeless) + RB_up_count(rb); + ne->work = work; + ne->mincost_target = target; + ne->flags.via_conflict_level = conflict; + ne->cost_to_point = parent->cost_to_point; + ne->cost_point = parent->cost_point; + ne->cost = cost; + heap_insert(s->workheap, ne->cost, ne); + } + else { + mtsFreeWork(&work); + } } -static void -add_or_destroy_edge (struct routeone_state *s, edge_t * e) +static void add_or_destroy_edge(struct routeone_state *s, edge_t * e) { - e->cost = edge_cost (e, s->best_cost); - assert (__edge_is_good (e)); - assert (is_layer_group_active[e->rb->group]); - if (e->cost < s->best_cost) - heap_insert (s->workheap, e->cost, e); - else - DestroyEdge (&e); + e->cost = edge_cost(e, s->best_cost); + assert(__edge_is_good(e)); + assert(is_layer_group_active[e->rb->group]); + if (e->cost < s->best_cost) + heap_insert(s->workheap, e->cost, e); + else + DestroyEdge(&e); } -static void -best_path_candidate (struct routeone_state *s, - edge_t * e, routebox_t * best_target) +static void best_path_candidate(struct routeone_state *s, edge_t * e, routebox_t * best_target) { - e->cost = edge_cost (e, EXPENSIVE); - if (s->best_path == NULL || e->cost < s->best_cost) - { + e->cost = edge_cost(e, EXPENSIVE); + if (s->best_path == NULL || e->cost < s->best_cost) { #if defined(ROUTE_DEBUG) && defined (ROUTE_VERBOSE) - printf ("New best path seen! cost = %f\n", e->cost); + printf("New best path seen! cost = %f\n", e->cost); #endif - /* new best path! */ - if (s->best_path && s->best_path->flags.homeless) - RB_down_count (s->best_path); - s->best_path = e->rb; - s->best_target = best_target; - s->best_cost = e->cost; - assert (s->best_cost >= 0); - /* don't free this when we destroy edge! */ - if (s->best_path->flags.homeless) - RB_up_count (s->best_path); - } + /* new best path! */ + if (s->best_path && s->best_path->flags.homeless) + RB_down_count(s->best_path); + s->best_path = e->rb; + s->best_target = best_target; + s->best_cost = e->cost; + assert(s->best_cost >= 0); + /* don't free this when we destroy edge! */ + if (s->best_path->flags.homeless) + RB_up_count(s->best_path); + } } /* vectors for via site candidates (see mtspace.h) */ -struct routeone_via_site_state -{ - vector_t *free_space_vec; - vector_t *lo_conflict_space_vec; - vector_t *hi_conflict_space_vec; +struct routeone_via_site_state { + vector_t *free_space_vec; + vector_t *lo_conflict_space_vec; + vector_t *hi_conflict_space_vec; }; void -add_via_sites (struct routeone_state *s, - struct routeone_via_site_state *vss, - mtspace_t * mtspace, routebox_t * within, - conflict_t within_conflict_level, edge_t * parent_edge, - rtree_t * targets, Coord shrink, bool in_plane) +add_via_sites(struct routeone_state *s, + struct routeone_via_site_state *vss, + mtspace_t * mtspace, routebox_t * within, + conflict_t within_conflict_level, edge_t * parent_edge, rtree_t * targets, Coord shrink, bool in_plane) { - Coord radius, keepaway; - vetting_t *work; - BoxType region = shrink_routebox (within); - shrink_box (®ion, shrink); + Coord radius, keepaway; + vetting_t *work; + BoxType region = shrink_routebox(within); + shrink_box(®ion, shrink); - radius = HALF_THICK (AutoRouteParameters.style->Diameter); - keepaway = AutoRouteParameters.style->Keepaway; - assert (AutoRouteParameters.use_vias); - /* XXX: need to clip 'within' to shrunk_pcb_bounds, because when - XXX: routing with conflicts may poke over edge. */ + radius = HALF_THICK(AutoRouteParameters.style->Diameter); + keepaway = AutoRouteParameters.style->Keepaway; + assert(AutoRouteParameters.use_vias); + /* XXX: need to clip 'within' to shrunk_pcb_bounds, because when + XXX: routing with conflicts may poke over edge. */ - /* ask for a via box near our cost_point first */ - work = mtspace_query_rect (mtspace, ®ion, radius, keepaway, - NULL, vss->free_space_vec, - vss->lo_conflict_space_vec, - vss->hi_conflict_space_vec, - AutoRouteParameters.is_odd, - AutoRouteParameters.with_conflicts, - &parent_edge->cost_point); - if (!work) - return; - CreateSearchEdge (s, work, parent_edge, within, within_conflict_level, - targets, in_plane); + /* ask for a via box near our cost_point first */ + work = mtspace_query_rect(mtspace, ®ion, radius, keepaway, + NULL, vss->free_space_vec, + vss->lo_conflict_space_vec, + vss->hi_conflict_space_vec, + AutoRouteParameters.is_odd, AutoRouteParameters.with_conflicts, &parent_edge->cost_point); + if (!work) + return; + CreateSearchEdge(s, work, parent_edge, within, within_conflict_level, targets, in_plane); } void -do_via_search (edge_t * search, struct routeone_state *s, - struct routeone_via_site_state *vss, mtspace_t * mtspace, - rtree_t * targets) +do_via_search(edge_t * search, struct routeone_state *s, + struct routeone_via_site_state *vss, mtspace_t * mtspace, rtree_t * targets) { - int i, j, count = 0; - Coord radius, keepaway; - vetting_t *work; - routebox_t *within; - conflict_t within_conflict_level; + int i, j, count = 0; + Coord radius, keepaway; + vetting_t *work; + routebox_t *within; + conflict_t within_conflict_level; - radius = HALF_THICK (AutoRouteParameters.style->Diameter); - keepaway = AutoRouteParameters.style->Keepaway; - work = mtspace_query_rect (mtspace, NULL, 0, 0, - search->work, vss->free_space_vec, - vss->lo_conflict_space_vec, - vss->hi_conflict_space_vec, - AutoRouteParameters.is_odd, - AutoRouteParameters.with_conflicts, NULL); - within = search->rb; - within_conflict_level = search->flags.via_conflict_level; - for (i = 0; i < 3; i++) - { - vector_t *v = - (i == NO_CONFLICT ? vss->free_space_vec : - i == LO_CONFLICT ? vss->lo_conflict_space_vec : - i == HI_CONFLICT ? vss->hi_conflict_space_vec : NULL); - assert (v); - while (!vector_is_empty (v)) - { - BoxType cliparea; - BoxType *area = (BoxType *)vector_remove_last (v); - if (!(i == NO_CONFLICT || AutoRouteParameters.with_conflicts)) - { - free (area); - continue; - } - /* answers are bloated by radius + keepaway */ - cliparea = shrink_box (area, radius + keepaway); - close_box (&cliparea); - free (area); - assert (box_is_good (&cliparea)); - count++; - for (j = 0; j < max_group; j++) - { - edge_t *ne; - if (j == within->group || !is_layer_group_active[j]) - continue; - ne = CreateViaEdge (&cliparea, j, within, search, - within_conflict_level, (conflict_t)i, targets); - add_or_destroy_edge (s, ne); - } + radius = HALF_THICK(AutoRouteParameters.style->Diameter); + keepaway = AutoRouteParameters.style->Keepaway; + work = mtspace_query_rect(mtspace, NULL, 0, 0, + search->work, vss->free_space_vec, + vss->lo_conflict_space_vec, + vss->hi_conflict_space_vec, AutoRouteParameters.is_odd, AutoRouteParameters.with_conflicts, NULL); + within = search->rb; + within_conflict_level = search->flags.via_conflict_level; + for (i = 0; i < 3; i++) { + vector_t *v = + (i == NO_CONFLICT ? vss->free_space_vec : + i == LO_CONFLICT ? vss->lo_conflict_space_vec : i == HI_CONFLICT ? vss->hi_conflict_space_vec : NULL); + assert(v); + while (!vector_is_empty(v)) { + BoxType cliparea; + BoxType *area = (BoxType *) vector_remove_last(v); + if (!(i == NO_CONFLICT || AutoRouteParameters.with_conflicts)) { + free(area); + continue; + } + /* answers are bloated by radius + keepaway */ + cliparea = shrink_box(area, radius + keepaway); + close_box(&cliparea); + free(area); + assert(box_is_good(&cliparea)); + count++; + for (j = 0; j < max_group; j++) { + edge_t *ne; + if (j == within->group || !is_layer_group_active[j]) + continue; + ne = CreateViaEdge(&cliparea, j, within, search, within_conflict_level, (conflict_t) i, targets); + add_or_destroy_edge(s, ne); + } + } } - } - /* prevent freeing of work when this edge is destroyed */ - search->flags.via_search = 0; - if (!work) - return; - CreateSearchEdge (s, work, search, within, within_conflict_level, targets, - search->flags.in_plane); - assert (vector_is_empty (vss->free_space_vec)); - assert (vector_is_empty (vss->lo_conflict_space_vec)); - assert (vector_is_empty (vss->hi_conflict_space_vec)); + /* prevent freeing of work when this edge is destroyed */ + search->flags.via_search = 0; + if (!work) + return; + CreateSearchEdge(s, work, search, within, within_conflict_level, targets, search->flags.in_plane); + assert(vector_is_empty(vss->free_space_vec)); + assert(vector_is_empty(vss->lo_conflict_space_vec)); + assert(vector_is_empty(vss->hi_conflict_space_vec)); } /* vector of expansion areas to be eventually removed from r-tree @@ -3874,1354 +3421,1161 @@ /* some routines for use in gdb while debugging */ #if defined(ROUTE_DEBUG) -static void -list_conflicts (routebox_t * rb) +static void list_conflicts(routebox_t * rb) { - int i, n; - if (!rb->conflicts_with) - return; - n = vector_size (rb->conflicts_with); - for (i = 0; i < n; i++) - printf ("%p, ", vector_element (rb->conflicts_with, i)); + int i, n; + if (!rb->conflicts_with) + return; + n = vector_size(rb->conflicts_with); + for (i = 0; i < n; i++) + printf("%p, ", vector_element(rb->conflicts_with, i)); } -static void -show_area_vec (int lay) +static void show_area_vec(int lay) { - int n, save; + int n, save; - if (!area_vec) - return; - save = showboxen; - showboxen = lay; - for (n = 0; n < vector_size (area_vec); n++) - { - routebox_t *rb = (routebox_t *) vector_element (area_vec, n); - showroutebox (rb); - } - showboxen = save; + if (!area_vec) + return; + save = showboxen; + showboxen = lay; + for (n = 0; n < vector_size(area_vec); n++) { + routebox_t *rb = (routebox_t *) vector_element(area_vec, n); + showroutebox(rb); + } + showboxen = save; } -static bool -net_id (routebox_t * rb, long int id) +static bool net_id(routebox_t * rb, long int id) { - routebox_t *p; - LIST_LOOP (rb, same_net, p); - if (p->flags.source && p->parent.pad->ID == id) - return true; - END_LOOP; - return false; + routebox_t *p; + LIST_LOOP(rb, same_net, p); + if (p->flags.source && p->parent.pad->ID == id) + return true; + END_LOOP; + return false; } -static void -trace_parents (routebox_t * rb) +static void trace_parents(routebox_t * rb) { - while (rb && rb->type == EXPANSION_AREA) - { - printf (" %p ->", rb); - rb = rb->parent.expansion_area; - } - if (rb) - printf (" %p is source\n", rb); - else - printf ("NULL!\n"); + while (rb && rb->type == EXPANSION_AREA) { + printf(" %p ->", rb); + rb = rb->parent.expansion_area; + } + if (rb) + printf(" %p is source\n", rb); + else + printf("NULL!\n"); } -static void -show_one (routebox_t * rb) +static void show_one(routebox_t * rb) { - int save = showboxen; - showboxen = -1; - showroutebox (rb); - showboxen = save; + int save = showboxen; + showboxen = -1; + showroutebox(rb); + showboxen = save; } -static void -show_path (routebox_t * rb) +static void show_path(routebox_t * rb) { - while (rb && rb->type == EXPANSION_AREA) - { - show_one (rb); - rb = rb->parent.expansion_area; - } - show_one (rb); + while (rb && rb->type == EXPANSION_AREA) { + show_one(rb); + rb = rb->parent.expansion_area; + } + show_one(rb); } -static void -show_sources (routebox_t * rb) +static void show_sources(routebox_t * rb) { - routebox_t *p; - if (!rb->flags.source && !rb->flags.target) - { - printf ("start with a source or target please\n"); - return; - } - LIST_LOOP (rb, same_net, p); - if (p->flags.source) - show_one (p); - END_LOOP; + routebox_t *p; + if (!rb->flags.source && !rb->flags.target) { + printf("start with a source or target please\n"); + return; + } + LIST_LOOP(rb, same_net, p); + if (p->flags.source) + show_one(p); + END_LOOP; } #endif -static int -__conflict_source (const BoxType * box, void *cl) +static int __conflict_source(const BoxType * box, void *cl) { - routebox_t *rb = (routebox_t *) box; - if (rb->flags.touched || rb->flags.fixed) - return 0; - else - { - routebox_t *dis = (routebox_t *) cl; - path_conflicts (dis, rb, false); - touch_conflicts (dis->conflicts_with, 1); - } - return 1; + routebox_t *rb = (routebox_t *) box; + if (rb->flags.touched || rb->flags.fixed) + return 0; + else { + routebox_t *dis = (routebox_t *) cl; + path_conflicts(dis, rb, false); + touch_conflicts(dis->conflicts_with, 1); + } + return 1; } -static void -source_conflicts (rtree_t * tree, routebox_t * rb) +static void source_conflicts(rtree_t * tree, routebox_t * rb) { - if (!AutoRouteParameters.with_conflicts) - return; - r_search (tree, &rb->sbox, NULL, __conflict_source, rb); - touch_conflicts (NULL, 1); + if (!AutoRouteParameters.with_conflicts) + return; + r_search(tree, &rb->sbox, NULL, __conflict_source, rb); + touch_conflicts(NULL, 1); } -struct routeone_status -{ - bool found_route; - int route_had_conflicts; - cost_t best_route_cost; - bool net_completely_routed; +struct routeone_status { + bool found_route; + int route_had_conflicts; + cost_t best_route_cost; + bool net_completely_routed; }; -static struct routeone_status -RouteOne (routedata_t * rd, routebox_t * from, routebox_t * to, int max_edges) +static struct routeone_status RouteOne(routedata_t * rd, routebox_t * from, routebox_t * to, int max_edges) { - struct routeone_status result; - routebox_t *p; - int seen, i; - const BoxType **target_list; - int num_targets; - rtree_t *targets; - /* vector of source edges for filtering */ - vector_t *source_vec; - /* working vector */ - vector_t *edge_vec; + struct routeone_status result; + routebox_t *p; + int seen, i; + const BoxType **target_list; + int num_targets; + rtree_t *targets; + /* vector of source edges for filtering */ + vector_t *source_vec; + /* working vector */ + vector_t *edge_vec; - struct routeone_state s; - struct routeone_via_site_state vss; + struct routeone_state s; + struct routeone_via_site_state vss; - assert (rd && from); - result.route_had_conflicts = 0; - /* no targets on to/from net need keepaway areas */ - LIST_LOOP (from, same_net, p); - p->flags.nobloat = 1; - END_LOOP; - /* set 'source' flags */ - LIST_LOOP (from, same_subnet, p); - if (!p->flags.nonstraight) - p->flags.source = 1; - END_LOOP; + assert(rd && from); + result.route_had_conflicts = 0; + /* no targets on to/from net need keepaway areas */ + LIST_LOOP(from, same_net, p); + p->flags.nobloat = 1; + END_LOOP; + /* set 'source' flags */ + LIST_LOOP(from, same_subnet, p); + if (!p->flags.nonstraight) + p->flags.source = 1; + END_LOOP; - /* count up the targets */ - num_targets = 0; - seen = 0; - /* remove source/target flags from non-straight obstacles, because they - * don't fill their bounding boxes and so connecting to them - * after we've routed is problematic. Better solution? */ - if (to) - { /* if we're routing to a specific target */ - if (!to->flags.source) - { /* not already connected */ - /* check that 'to' and 'from' are on the same net */ - seen = 0; + /* count up the targets */ + num_targets = 0; + seen = 0; + /* remove source/target flags from non-straight obstacles, because they + * don't fill their bounding boxes and so connecting to them + * after we've routed is problematic. Better solution? */ + if (to) { /* if we're routing to a specific target */ + if (!to->flags.source) { /* not already connected */ + /* check that 'to' and 'from' are on the same net */ + seen = 0; #ifndef NDEBUG - LIST_LOOP (from, same_net, p); - if (p == to) - seen = 1; - END_LOOP; + LIST_LOOP(from, same_net, p); + if (p == to) + seen = 1; + END_LOOP; #endif - assert (seen); /* otherwise from and to are on different nets! */ - /* set target flags only on 'to's subnet */ - LIST_LOOP (to, same_subnet, p); - if (!p->flags.nonstraight && is_layer_group_active[p->group]) - { - p->flags.target = 1; - num_targets++; - } - END_LOOP; + assert(seen); /* otherwise from and to are on different nets! */ + /* set target flags only on 'to's subnet */ + LIST_LOOP(to, same_subnet, p); + if (!p->flags.nonstraight && is_layer_group_active[p->group]) { + p->flags.target = 1; + num_targets++; + } + END_LOOP; + } } - } - else - { - /* all nodes on the net but not connected to from are targets */ - LIST_LOOP (from, same_net, p); - if (!p->flags.source && is_layer_group_active[p->group] - && !p->flags.nonstraight) - { - p->flags.target = 1; - num_targets++; + else { + /* all nodes on the net but not connected to from are targets */ + LIST_LOOP(from, same_net, p); + if (!p->flags.source && is_layer_group_active[p->group] + && !p->flags.nonstraight) { + p->flags.target = 1; + num_targets++; + } + END_LOOP; } - END_LOOP; - } - /* if no targets, then net is done! reset flags and return. */ - if (num_targets == 0) - { - LIST_LOOP (from, same_net, p); - p->flags.source = p->flags.target = p->flags.nobloat = 0; - END_LOOP; - result.found_route = false; - result.net_completely_routed = true; - result.best_route_cost = 0; - result.route_had_conflicts = 0; + /* if no targets, then net is done! reset flags and return. */ + if (num_targets == 0) { + LIST_LOOP(from, same_net, p); + p->flags.source = p->flags.target = p->flags.nobloat = 0; + END_LOOP; + result.found_route = false; + result.net_completely_routed = true; + result.best_route_cost = 0; + result.route_had_conflicts = 0; - return result; - } - result.net_completely_routed = false; + return result; + } + result.net_completely_routed = false; - /* okay, there's stuff to route */ - assert (!from->flags.target); - assert (num_targets > 0); - /* create list of target pointers and from that a r-tree of targets */ - target_list = (const BoxType **)malloc (num_targets * sizeof (*target_list)); - i = 0; - LIST_LOOP (from, same_net, p); - if (p->flags.target) - { - target_list[i++] = &p->box; + /* okay, there's stuff to route */ + assert(!from->flags.target); + assert(num_targets > 0); + /* create list of target pointers and from that a r-tree of targets */ + target_list = (const BoxType **) malloc(num_targets * sizeof(*target_list)); + i = 0; + LIST_LOOP(from, same_net, p); + if (p->flags.target) { + target_list[i++] = &p->box; #if defined(ROUTE_DEBUG) && defined(DEBUG_SHOW_TARGETS) - showroutebox (p); + showroutebox(p); #endif - } - END_LOOP; - targets = r_create_tree ((const BoxType **)target_list, i, 0); - assert (i <= num_targets); - free (target_list); + } + END_LOOP; + targets = r_create_tree((const BoxType **) target_list, i, 0); + assert(i <= num_targets); + free(target_list); - source_vec = vector_create (); - /* touch the source subnet to prepare check for conflictors */ - LIST_LOOP (from, same_subnet, p); - p->flags.touched = 1; - END_LOOP; - LIST_LOOP (from, same_subnet, p); - { - /* we need the test for 'source' because this box may be nonstraight */ - if (p->flags.source && is_layer_group_active[p->group]) - { - CheapPointType cp; - edge_t *e; - BoxType b = shrink_routebox (p); + source_vec = vector_create(); + /* touch the source subnet to prepare check for conflictors */ + LIST_LOOP(from, same_subnet, p); + p->flags.touched = 1; + END_LOOP; + LIST_LOOP(from, same_subnet, p); + { + /* we need the test for 'source' because this box may be nonstraight */ + if (p->flags.source && is_layer_group_active[p->group]) { + CheapPointType cp; + edge_t *e; + BoxType b = shrink_routebox(p); #if defined(ROUTE_DEBUG) && defined(DEBUG_SHOW_SOURCES) - showroutebox (p); + showroutebox(p); #endif - /* may expand in all directions from source; center edge cost point. */ - /* note that planes shouldn't really expand, but we need an edge */ + /* may expand in all directions from source; center edge cost point. */ + /* note that planes shouldn't really expand, but we need an edge */ - cp.X = CENTER_X (b); - cp.Y = CENTER_Y (b); - e = CreateEdge (p, cp.X, cp.Y, 0, NULL, ALL, targets); - cp = closest_point_in_box (&cp, &e->mincost_target->sbox); - cp = closest_point_in_box (&cp, &b); - e->cost_point = cp; - p->cost_point = cp; - source_conflicts (rd->layergrouptree[p->group], p); - vector_append (source_vec, e); - } - } - END_LOOP; - LIST_LOOP (from, same_subnet, p); - p->flags.touched = 0; - END_LOOP; - /* break source edges; some edges may be too near obstacles to be able - * to exit from. */ + cp.X = CENTER_X(b); + cp.Y = CENTER_Y(b); + e = CreateEdge(p, cp.X, cp.Y, 0, NULL, ALL, targets); + cp = closest_point_in_box(&cp, &e->mincost_target->sbox); + cp = closest_point_in_box(&cp, &b); + e->cost_point = cp; + p->cost_point = cp; + source_conflicts(rd->layergrouptree[p->group], p); + vector_append(source_vec, e); + } + } + END_LOOP; + LIST_LOOP(from, same_subnet, p); + p->flags.touched = 0; + END_LOOP; + /* break source edges; some edges may be too near obstacles to be able + * to exit from. */ - /* okay, main expansion-search routing loop. */ - /* set up the initial activity heap */ - s.workheap = heap_create (); - assert (s.workheap); - while (!vector_is_empty (source_vec)) - { - edge_t *e = (edge_t *)vector_remove_last (source_vec); - assert (is_layer_group_active[e->rb->group]); - e->cost = edge_cost (e, EXPENSIVE); - heap_insert (s.workheap, e->cost, e); - } - vector_destroy (&source_vec); - /* okay, process items from heap until it is empty! */ - s.best_path = NULL; - s.best_cost = EXPENSIVE; - area_vec = vector_create (); - edge_vec = vector_create (); - vss.free_space_vec = vector_create (); - vss.lo_conflict_space_vec = vector_create (); - vss.hi_conflict_space_vec = vector_create (); - while (!heap_is_empty (s.workheap)) - { - edge_t *e = (edge_t *)heap_remove_smallest (s.workheap); + /* okay, main expansion-search routing loop. */ + /* set up the initial activity heap */ + s.workheap = heap_create(); + assert(s.workheap); + while (!vector_is_empty(source_vec)) { + edge_t *e = (edge_t *) vector_remove_last(source_vec); + assert(is_layer_group_active[e->rb->group]); + e->cost = edge_cost(e, EXPENSIVE); + heap_insert(s.workheap, e->cost, e); + } + vector_destroy(&source_vec); + /* okay, process items from heap until it is empty! */ + s.best_path = NULL; + s.best_cost = EXPENSIVE; + area_vec = vector_create(); + edge_vec = vector_create(); + vss.free_space_vec = vector_create(); + vss.lo_conflict_space_vec = vector_create(); + vss.hi_conflict_space_vec = vector_create(); + while (!heap_is_empty(s.workheap)) { + edge_t *e = (edge_t *) heap_remove_smallest(s.workheap); #ifdef ROUTE_DEBUG - if (aabort) - goto dontexpand; + if (aabort) + goto dontexpand; #endif - /* don't bother expanding this edge if the minimum possible edge cost - * is already larger than the best edge cost we've found. */ - if (s.best_path && e->cost >= s.best_cost) - { - heap_free (s.workheap, KillEdge); - goto dontexpand; /* skip this edge */ - } - /* surprisingly it helps to give up and not try too hard to find - * a route! This is not only faster, but results in better routing. - * who would have guessed? - */ - if (seen++ > max_edges) - goto dontexpand; - assert (__edge_is_good (e)); - /* mark or unmark conflictors as needed */ - touch_conflicts (e->rb->conflicts_with, 1); - if (e->flags.via_search) - { - do_via_search (e, &s, &vss, rd->mtspace, targets); - goto dontexpand; - } - /* we should never add edges on inactive layer groups to the heap. */ - assert (is_layer_group_active[e->rb->group]); + /* don't bother expanding this edge if the minimum possible edge cost + * is already larger than the best edge cost we've found. */ + if (s.best_path && e->cost >= s.best_cost) { + heap_free(s.workheap, KillEdge); + goto dontexpand; /* skip this edge */ + } + /* surprisingly it helps to give up and not try too hard to find + * a route! This is not only faster, but results in better routing. + * who would have guessed? + */ + if (seen++ > max_edges) + goto dontexpand; + assert(__edge_is_good(e)); + /* mark or unmark conflictors as needed */ + touch_conflicts(e->rb->conflicts_with, 1); + if (e->flags.via_search) { + do_via_search(e, &s, &vss, rd->mtspace, targets); + goto dontexpand; + } + /* we should never add edges on inactive layer groups to the heap. */ + assert(is_layer_group_active[e->rb->group]); #if defined(ROUTE_DEBUG) && defined(DEBUG_SHOW_EXPANSION_BOXES) - /*showedge (e);*/ + /*showedge (e); */ #endif - if (e->rb->flags.is_thermal) - { - best_path_candidate (&s, e, e->mincost_target); - goto dontexpand; - } - /* for a plane, look for quick connections with thermals or vias */ - if (e->rb->type == PLANE) - { - routebox_t *pin = FindThermable (targets, e->rb); - if (pin) - { - BoxType b = shrink_routebox (pin); - edge_t *ne; - routebox_t *nrb; - assert (pin->flags.target); - nrb = CreateExpansionArea (&b, e->rb->group, e->rb, true, e); - nrb->flags.is_thermal = 1; - /* moving through the plane is free */ - e->cost_point.X = b.X1; - e->cost_point.Y = b.Y1; - ne = CreateEdge2 (nrb, e->expand_dir, e, NULL, pin); - best_path_candidate (&s, ne, pin); - DestroyEdge (&ne); - } - else - { - /* add in possible via sites in plane */ - if (AutoRouteParameters.use_vias && - e->cost + AutoRouteParameters.ViaCost < s.best_cost) - { - /* we need a giant thermal */ - routebox_t *nrb = - CreateExpansionArea (&e->rb->sbox, e->rb->group, e->rb, - true, e); - edge_t *ne = CreateEdge2 (nrb, e->expand_dir, e, NULL, - e->mincost_target); - nrb->flags.is_thermal = 1; - add_via_sites (&s, &vss, rd->mtspace, nrb, NO_CONFLICT, ne, - targets, e->rb->style->Diameter, true); + if (e->rb->flags.is_thermal) { + best_path_candidate(&s, e, e->mincost_target); + goto dontexpand; } - } - goto dontexpand; /* planes only connect via thermals */ - } - if (e->flags.is_via) - { /* special case via */ - routebox_t *intersecting; - assert (AutoRouteParameters.use_vias); - assert (e->expand_dir == ALL); - assert (vector_is_empty (edge_vec)); - /* if there is already something here on this layer (like an - * EXPANSION_AREA), then we don't want to expand from here - * at least not inside the expansion area. A PLANE on the - * other hand may be a target, or not. - */ - intersecting = - FindOneInBox (rd->layergrouptree[e->rb->group], e->rb); + /* for a plane, look for quick connections with thermals or vias */ + if (e->rb->type == PLANE) { + routebox_t *pin = FindThermable(targets, e->rb); + if (pin) { + BoxType b = shrink_routebox(pin); + edge_t *ne; + routebox_t *nrb; + assert(pin->flags.target); + nrb = CreateExpansionArea(&b, e->rb->group, e->rb, true, e); + nrb->flags.is_thermal = 1; + /* moving through the plane is free */ + e->cost_point.X = b.X1; + e->cost_point.Y = b.Y1; + ne = CreateEdge2(nrb, e->expand_dir, e, NULL, pin); + best_path_candidate(&s, ne, pin); + DestroyEdge(&ne); + } + else { + /* add in possible via sites in plane */ + if (AutoRouteParameters.use_vias && e->cost + AutoRouteParameters.ViaCost < s.best_cost) { + /* we need a giant thermal */ + routebox_t *nrb = CreateExpansionArea(&e->rb->sbox, e->rb->group, e->rb, + true, e); + edge_t *ne = CreateEdge2(nrb, e->expand_dir, e, NULL, + e->mincost_target); + nrb->flags.is_thermal = 1; + add_via_sites(&s, &vss, rd->mtspace, nrb, NO_CONFLICT, ne, targets, e->rb->style->Diameter, true); + } + } + goto dontexpand; /* planes only connect via thermals */ + } + if (e->flags.is_via) { /* special case via */ + routebox_t *intersecting; + assert(AutoRouteParameters.use_vias); + assert(e->expand_dir == ALL); + assert(vector_is_empty(edge_vec)); + /* if there is already something here on this layer (like an + * EXPANSION_AREA), then we don't want to expand from here + * at least not inside the expansion area. A PLANE on the + * other hand may be a target, or not. + */ + intersecting = FindOneInBox(rd->layergrouptree[e->rb->group], e->rb); - if (intersecting && intersecting->flags.target - && intersecting->type == PLANE) - { - /* we have hit a plane */ - edge_t *ne; - routebox_t *nrb; - BoxType b = shrink_routebox (e->rb); - /* limit via region to that inside the plane */ - clip_box (&b, &intersecting->sbox); - nrb = CreateExpansionArea (&b, e->rb->group, e->rb, true, e); - nrb->flags.is_thermal = 1; - ne = CreateEdge2 (nrb, e->expand_dir, e, NULL, intersecting); - best_path_candidate (&s, ne, intersecting); - DestroyEdge (&ne); - goto dontexpand; - } - else if (intersecting == NULL) - { - /* this via candidate is in an open area; add it to r-tree as - * an expansion area */ - assert (e->rb->type == EXPANSION_AREA && e->rb->flags.is_via); - /*assert (!r_search (rd->layergrouptree[e->rb->group], - &e->rb->box, NULL, no_planes,0)); - */ - r_insert_entry (rd->layergrouptree[e->rb->group], &e->rb->box, - 1); - e->rb->flags.homeless = 0; /* not homeless any more */ - /* add to vector of all expansion areas in r-tree */ - vector_append (area_vec, e->rb); - /* mark reset refcount to 0, since this is not homeless any more. */ - e->rb->refcount = 0; - /* go ahead and expand this edge! */ - } - else if (1) - goto dontexpand; - else if (0) - { /* XXX: disabling this causes no via - collisions. */ - BoxType a = bloat_routebox (intersecting), b; - edge_t *ne; - int i, j; - /* something intersects this via candidate. split via candidate - * into pieces and add these pieces to the workheap. */ - for (i = 0; i < 3; i++) - { - for (j = 0; j < 3; j++) - { - b = shrink_routebox (e->rb); - switch (i) - { - case 0: - b.X2 = MIN (b.X2, a.X1); - break; /* left */ - case 1: - b.X1 = MAX (b.X1, a.X1); - b.X2 = MIN (b.X2, a.X2); - break; /*c */ - case 2: - b.X1 = MAX (b.X1, a.X2); - break; /* right */ - default: - assert (0); + if (intersecting && intersecting->flags.target && intersecting->type == PLANE) { + /* we have hit a plane */ + edge_t *ne; + routebox_t *nrb; + BoxType b = shrink_routebox(e->rb); + /* limit via region to that inside the plane */ + clip_box(&b, &intersecting->sbox); + nrb = CreateExpansionArea(&b, e->rb->group, e->rb, true, e); + nrb->flags.is_thermal = 1; + ne = CreateEdge2(nrb, e->expand_dir, e, NULL, intersecting); + best_path_candidate(&s, ne, intersecting); + DestroyEdge(&ne); + goto dontexpand; } - switch (j) - { - case 0: - b.Y2 = MIN (b.Y2, a.Y1); - break; /* top */ - case 1: - b.Y1 = MAX (b.Y1, a.Y1); - b.Y2 = MIN (b.Y2, a.Y2); - break; /*c */ - case 2: - b.Y1 = MAX (b.Y1, a.Y2); - break; /* bottom */ - default: - assert (0); + else if (intersecting == NULL) { + /* this via candidate is in an open area; add it to r-tree as + * an expansion area */ + assert(e->rb->type == EXPANSION_AREA && e->rb->flags.is_via); + /*assert (!r_search (rd->layergrouptree[e->rb->group], + &e->rb->box, NULL, no_planes,0)); + */ + r_insert_entry(rd->layergrouptree[e->rb->group], &e->rb->box, 1); + e->rb->flags.homeless = 0; /* not homeless any more */ + /* add to vector of all expansion areas in r-tree */ + vector_append(area_vec, e->rb); + /* mark reset refcount to 0, since this is not homeless any more. */ + e->rb->refcount = 0; + /* go ahead and expand this edge! */ } - /* skip if this box is not valid */ - if (!(b.X1 < b.X2 && b.Y1 < b.Y2)) - continue; - if (i == 1 && j == 1) - { - /* this bit of the via space is obstructed. */ - if (intersecting->type == EXPANSION_AREA - || intersecting->flags.fixed) - continue; /* skip this bit, it's already been done. */ - /* create an edge with conflicts, if enabled */ - if (!AutoRouteParameters.with_conflicts) - continue; - ne = CreateEdgeWithConflicts (&b, intersecting, e, 1 - /*cost penalty to box */ - , targets); - add_or_destroy_edge (&s, ne); + else if (1) + goto dontexpand; + else if (0) { /* XXX: disabling this causes no via + collisions. */ + BoxType a = bloat_routebox(intersecting), b; + edge_t *ne; + int i, j; + /* something intersects this via candidate. split via candidate + * into pieces and add these pieces to the workheap. */ + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + b = shrink_routebox(e->rb); + switch (i) { + case 0: + b.X2 = MIN(b.X2, a.X1); + break; /* left */ + case 1: + b.X1 = MAX(b.X1, a.X1); + b.X2 = MIN(b.X2, a.X2); + break; /*c */ + case 2: + b.X1 = MAX(b.X1, a.X2); + break; /* right */ + default: + assert(0); + } + switch (j) { + case 0: + b.Y2 = MIN(b.Y2, a.Y1); + break; /* top */ + case 1: + b.Y1 = MAX(b.Y1, a.Y1); + b.Y2 = MIN(b.Y2, a.Y2); + break; /*c */ + case 2: + b.Y1 = MAX(b.Y1, a.Y2); + break; /* bottom */ + default: + assert(0); + } + /* skip if this box is not valid */ + if (!(b.X1 < b.X2 && b.Y1 < b.Y2)) + continue; + if (i == 1 && j == 1) { + /* this bit of the via space is obstructed. */ + if (intersecting->type == EXPANSION_AREA || intersecting->flags.fixed) + continue; /* skip this bit, it's already been done. */ + /* create an edge with conflicts, if enabled */ + if (!AutoRouteParameters.with_conflicts) + continue; + ne = CreateEdgeWithConflicts(&b, intersecting, e, 1 + /*cost penalty to box */ + , targets); + add_or_destroy_edge(&s, ne); + } + else { + /* if this is not the intersecting piece, create a new + * (hopefully unobstructed) via edge and add it back to the + * workheap. */ + ne = CreateViaEdge(&b, e->rb->group, e->rb->parent.expansion_area, e, e->flags.via_conflict_level, NO_CONFLICT + /* value here doesn't matter */ + , targets); + add_or_destroy_edge(&s, ne); + } + } + } + goto dontexpand; } - else - { - /* if this is not the intersecting piece, create a new - * (hopefully unobstructed) via edge and add it back to the - * workheap. */ - ne = - CreateViaEdge (&b, e->rb->group, - e->rb->parent.expansion_area, e, - e->flags.via_conflict_level, - NO_CONFLICT - /* value here doesn't matter */ - , targets); - add_or_destroy_edge (&s, ne); + /* between the time these edges are inserted and the + * time they are processed, new expansion boxes (which + * conflict with these edges) may be added to the graph! + * w.o vias this isn't a problem because the broken box + * is not homeless. */ + } + if (1) { + routebox_t *nrb; + struct E_result *ans; + BoxType b; + vector_t *broken; + if (e->flags.is_interior) { + assert(AutoRouteParameters.with_conflicts); /* no interior edges unless + routing with conflicts! */ + assert(e->rb->conflicts_with); + b = e->rb->sbox; + switch (e->rb->came_from) { + case NORTH: + b.Y2 = b.Y1 + 1; + b.X1 = CENTER_X(b); + b.X2 = b.X1 + 1; + break; + case EAST: + b.X1 = b.X2 - 1; + b.Y1 = CENTER_Y(b); + b.Y2 = b.Y1 + 1; + break; + case SOUTH: + b.Y1 = b.Y2 - 1; + b.X1 = CENTER_X(b); + b.X2 = b.X1 + 1; + break; + case WEST: + b.X2 = b.X1 + 1; + b.Y1 = CENTER_Y(b); + b.Y2 = b.Y1 + 1; + break; + default: + assert(0); + } } - } - } - goto dontexpand; - } - /* between the time these edges are inserted and the - * time they are processed, new expansion boxes (which - * conflict with these edges) may be added to the graph! - * w.o vias this isn't a problem because the broken box - * is not homeless. */ - } - if (1) - { - routebox_t *nrb; - struct E_result *ans; - BoxType b; - vector_t *broken; - if (e->flags.is_interior) - { - assert (AutoRouteParameters.with_conflicts); /* no interior edges unless - routing with conflicts! */ - assert (e->rb->conflicts_with); - b = e->rb->sbox; - switch (e->rb->came_from) - { - case NORTH: - b.Y2 = b.Y1 + 1; - b.X1 = CENTER_X (b); - b.X2 = b.X1 + 1; - break; - case EAST: - b.X1 = b.X2 - 1; - b.Y1 = CENTER_Y (b); - b.Y2 = b.Y1 + 1; - break; - case SOUTH: - b.Y1 = b.Y2 - 1; - b.X1 = CENTER_X (b); - b.X2 = b.X1 + 1; - break; - case WEST: - b.X2 = b.X1 + 1; - b.Y1 = CENTER_Y (b); - b.Y2 = b.Y1 + 1; - break; - default: - assert (0); - } - } - /* sources may not expand to their own edges because of - * adjacent blockers. - */ - else if (e->rb->flags.source) - b = box_center (&e->rb->sbox); - else - b = e->rb->sbox; - ans = Expand (rd->layergrouptree[e->rb->group], e, &b); - if (!box_intersect (&ans->inflated, &ans->orig)) - goto dontexpand; + /* sources may not expand to their own edges because of + * adjacent blockers. + */ + else if (e->rb->flags.source) + b = box_center(&e->rb->sbox); + else + b = e->rb->sbox; + ans = Expand(rd->layergrouptree[e->rb->group], e, &b); + if (!box_intersect(&ans->inflated, &ans->orig)) + goto dontexpand; #if 0 - /* skip if it didn't actually expand */ - if (ans->inflated.X1 >= e->rb->sbox.X1 && - ans->inflated.X2 <= e->rb->sbox.X2 && - ans->inflated.Y1 >= e->rb->sbox.Y1 && - ans->inflated.Y2 <= e->rb->sbox.Y2) - goto dontexpand; + /* skip if it didn't actually expand */ + if (ans->inflated.X1 >= e->rb->sbox.X1 && + ans->inflated.X2 <= e->rb->sbox.X2 && ans->inflated.Y1 >= e->rb->sbox.Y1 && ans->inflated.Y2 <= e->rb->sbox.Y2) + goto dontexpand; #endif - if (!box_is_good (&ans->inflated)) - goto dontexpand; - nrb = CreateExpansionArea (&ans->inflated, e->rb->group, e->rb, - true, e); - r_insert_entry (rd->layergrouptree[nrb->group], &nrb->box, 1); - vector_append (area_vec, nrb); - nrb->flags.homeless = 0; /* not homeless any more */ - broken = - BreakManyEdges (&s, targets, rd->layergrouptree[nrb->group], - area_vec, ans, nrb, e); - while (!vector_is_empty (broken)) - { - edge_t *ne = (edge_t *)vector_remove_last (broken); - add_or_destroy_edge (&s, ne); - } - vector_destroy (&broken); + if (!box_is_good(&ans->inflated)) + goto dontexpand; + nrb = CreateExpansionArea(&ans->inflated, e->rb->group, e->rb, true, e); + r_insert_entry(rd->layergrouptree[nrb->group], &nrb->box, 1); + vector_append(area_vec, nrb); + nrb->flags.homeless = 0; /* not homeless any more */ + broken = BreakManyEdges(&s, targets, rd->layergrouptree[nrb->group], area_vec, ans, nrb, e); + while (!vector_is_empty(broken)) { + edge_t *ne = (edge_t *) vector_remove_last(broken); + add_or_destroy_edge(&s, ne); + } + vector_destroy(&broken); - /* add in possible via sites in nrb */ - if (AutoRouteParameters.use_vias && !e->rb->flags.is_via && - e->cost + AutoRouteParameters.ViaCost < s.best_cost) - add_via_sites (&s, &vss, - rd->mtspace, nrb, NO_CONFLICT, e, targets, 0, - false); - goto dontexpand; + /* add in possible via sites in nrb */ + if (AutoRouteParameters.use_vias && !e->rb->flags.is_via && e->cost + AutoRouteParameters.ViaCost < s.best_cost) + add_via_sites(&s, &vss, rd->mtspace, nrb, NO_CONFLICT, e, targets, 0, false); + goto dontexpand; + } + dontexpand: + DestroyEdge(&e); } - dontexpand: - DestroyEdge (&e); - } - touch_conflicts (NULL, 1); - heap_destroy (&s.workheap); - r_destroy_tree (&targets); - assert (vector_is_empty (edge_vec)); - vector_destroy (&edge_vec); + touch_conflicts(NULL, 1); + heap_destroy(&s.workheap); + r_destroy_tree(&targets); + assert(vector_is_empty(edge_vec)); + vector_destroy(&edge_vec); - /* we should have a path in best_path now */ - if (s.best_path) - { - routebox_t *rb; + /* we should have a path in best_path now */ + if (s.best_path) { + routebox_t *rb; #ifdef ROUTE_VERBOSE - printf ("%d:%d RC %.0f", ro++, seen, s.best_cost); + printf("%d:%d RC %.0f", ro++, seen, s.best_cost); #endif - result.found_route = true; - result.best_route_cost = s.best_cost; - /* determine if the best path had conflicts */ - result.route_had_conflicts = 0; - if (AutoRouteParameters.with_conflicts && s.best_path->conflicts_with) - { - while (!vector_is_empty (s.best_path->conflicts_with)) - { - rb = (routebox_t *)vector_remove_last (s.best_path->conflicts_with); - rb->flags.is_bad = 1; - result.route_had_conflicts++; - } - } + result.found_route = true; + result.best_route_cost = s.best_cost; + /* determine if the best path had conflicts */ + result.route_had_conflicts = 0; + if (AutoRouteParameters.with_conflicts && s.best_path->conflicts_with) { + while (!vector_is_empty(s.best_path->conflicts_with)) { + rb = (routebox_t *) vector_remove_last(s.best_path->conflicts_with); + rb->flags.is_bad = 1; + result.route_had_conflicts++; + } + } #ifdef ROUTE_VERBOSE - if (result.route_had_conflicts) - printf (" (%d conflicts)", result.route_had_conflicts); + if (result.route_had_conflicts) + printf(" (%d conflicts)", result.route_had_conflicts); #endif - if (result.route_had_conflicts < AutoRouteParameters.hi_conflict) - { - /* back-trace the path and add lines/vias to r-tree */ - TracePath (rd, s.best_path, s.best_target, from, - result.route_had_conflicts); - MergeNets (from, s.best_target, SUBNET); - } - else - { + if (result.route_had_conflicts < AutoRouteParameters.hi_conflict) { + /* back-trace the path and add lines/vias to r-tree */ + TracePath(rd, s.best_path, s.best_target, from, result.route_had_conflicts); + MergeNets(from, s.best_target, SUBNET); + } + else { #ifdef ROUTE_VERBOSE - printf (" (too many in fact)"); + printf(" (too many in fact)"); #endif - result.found_route = false; - } + result.found_route = false; + } #ifdef ROUTE_VERBOSE - printf ("\n"); + printf("\n"); #endif - } - else - { + } + else { #ifdef ROUTE_VERBOSE - printf ("%d:%d NO PATH FOUND.\n", ro++, seen); + printf("%d:%d NO PATH FOUND.\n", ro++, seen); #endif - result.best_route_cost = s.best_cost; - result.found_route = false; - } - /* now remove all expansion areas from the r-tree. */ - while (!vector_is_empty (area_vec)) - { - routebox_t *rb = (routebox_t *)vector_remove_last (area_vec); - assert (!rb->flags.homeless); - if (rb->conflicts_with - && rb->parent.expansion_area->conflicts_with != rb->conflicts_with) - vector_destroy (&rb->conflicts_with); - r_delete_entry (rd->layergrouptree[rb->group], &rb->box); - } - vector_destroy (&area_vec); - /* clean up; remove all 'source', 'target', and 'nobloat' flags */ - LIST_LOOP (from, same_net, p); - if (p->flags.source && p->conflicts_with) - vector_destroy (&p->conflicts_with); - p->flags.touched = p->flags.source = p->flags.target = p->flags.nobloat = 0; - END_LOOP; + result.best_route_cost = s.best_cost; + result.found_route = false; + } + /* now remove all expansion areas from the r-tree. */ + while (!vector_is_empty(area_vec)) { + routebox_t *rb = (routebox_t *) vector_remove_last(area_vec); + assert(!rb->flags.homeless); + if (rb->conflicts_with && rb->parent.expansion_area->conflicts_with != rb->conflicts_with) + vector_destroy(&rb->conflicts_with); + r_delete_entry(rd->layergrouptree[rb->group], &rb->box); + } + vector_destroy(&area_vec); + /* clean up; remove all 'source', 'target', and 'nobloat' flags */ + LIST_LOOP(from, same_net, p); + if (p->flags.source && p->conflicts_with) + vector_destroy(&p->conflicts_with); + p->flags.touched = p->flags.source = p->flags.target = p->flags.nobloat = 0; + END_LOOP; - vector_destroy (&vss.free_space_vec); - vector_destroy (&vss.lo_conflict_space_vec); - vector_destroy (&vss.hi_conflict_space_vec); + vector_destroy(&vss.free_space_vec); + vector_destroy(&vss.lo_conflict_space_vec); + vector_destroy(&vss.hi_conflict_space_vec); - return result; + return result; } -static void -InitAutoRouteParameters (int pass, - RouteStyleType * style, - bool with_conflicts, bool is_smoothing, - bool lastpass) +static void InitAutoRouteParameters(int pass, RouteStyleType * style, bool with_conflicts, bool is_smoothing, bool lastpass) { - int i; - /* routing style */ - AutoRouteParameters.style = style; - AutoRouteParameters.bloat = style->Keepaway + HALF_THICK (style->Thick); - /* costs */ - AutoRouteParameters.ViaCost = - INCH_TO_COORD (3.5) + style->Diameter * (is_smoothing ? 80 : 30); - AutoRouteParameters.LastConflictPenalty = - (400 * pass / passes + 2) / (pass + 1); - AutoRouteParameters.ConflictPenalty = - 4 * AutoRouteParameters.LastConflictPenalty; - AutoRouteParameters.JogPenalty = 1000 * (is_smoothing ? 20 : 4); - AutoRouteParameters.CongestionPenalty = 1e6; - AutoRouteParameters.MinPenalty = EXPENSIVE; - for (i = 0; i < max_group; i++) - { - if (is_layer_group_active[i]) - { - AutoRouteParameters.MinPenalty = MIN (x_cost[i], - AutoRouteParameters. - MinPenalty); - AutoRouteParameters.MinPenalty = - MIN (y_cost[i], AutoRouteParameters.MinPenalty); + int i; + /* routing style */ + AutoRouteParameters.style = style; + AutoRouteParameters.bloat = style->Keepaway + HALF_THICK(style->Thick); + /* costs */ + AutoRouteParameters.ViaCost = INCH_TO_COORD(3.5) + style->Diameter * (is_smoothing ? 80 : 30); + AutoRouteParameters.LastConflictPenalty = (400 * pass / passes + 2) / (pass + 1); + AutoRouteParameters.ConflictPenalty = 4 * AutoRouteParameters.LastConflictPenalty; + AutoRouteParameters.JogPenalty = 1000 * (is_smoothing ? 20 : 4); + AutoRouteParameters.CongestionPenalty = 1e6; + AutoRouteParameters.MinPenalty = EXPENSIVE; + for (i = 0; i < max_group; i++) { + if (is_layer_group_active[i]) { + AutoRouteParameters.MinPenalty = MIN(x_cost[i], AutoRouteParameters.MinPenalty); + AutoRouteParameters.MinPenalty = MIN(y_cost[i], AutoRouteParameters.MinPenalty); + } } - } - AutoRouteParameters.NewLayerPenalty = is_smoothing ? - 0.5 * EXPENSIVE : 10 * AutoRouteParameters.ViaCost; - /* other */ - AutoRouteParameters.hi_conflict = MAX (8 * (passes - pass + 1), 6); - AutoRouteParameters.is_odd = (pass & 1); - AutoRouteParameters.with_conflicts = with_conflicts; - AutoRouteParameters.is_smoothing = is_smoothing; - AutoRouteParameters.rip_always = is_smoothing; - AutoRouteParameters.last_smooth = 0; /*lastpass;*/ - AutoRouteParameters.pass = pass + 1; + AutoRouteParameters.NewLayerPenalty = is_smoothing ? 0.5 * EXPENSIVE : 10 * AutoRouteParameters.ViaCost; + /* other */ + AutoRouteParameters.hi_conflict = MAX(8 * (passes - pass + 1), 6); + AutoRouteParameters.is_odd = (pass & 1); + AutoRouteParameters.with_conflicts = with_conflicts; + AutoRouteParameters.is_smoothing = is_smoothing; + AutoRouteParameters.rip_always = is_smoothing; + AutoRouteParameters.last_smooth = 0; /*lastpass; */ + AutoRouteParameters.pass = pass + 1; } #ifndef NDEBUG -int -bad_boy (const BoxType * b, void *cl) +int bad_boy(const BoxType * b, void *cl) { - routebox_t *box = (routebox_t *) b; - if (box->type == EXPANSION_AREA) - return 1; - return 0; + routebox_t *box = (routebox_t *) b; + if (box->type == EXPANSION_AREA) + return 1; + return 0; } -bool -no_expansion_boxes (routedata_t * rd) +bool no_expansion_boxes(routedata_t * rd) { - int i; - BoxType big; - big.X1 = 0; - big.X2 = MAX_COORD; - big.Y1 = 0; - big.Y2 = MAX_COORD; - for (i = 0; i < max_group; i++) - { - if (r_search (rd->layergrouptree[i], &big, NULL, bad_boy, NULL)) - return false; - } - return true; + int i; + BoxType big; + big.X1 = 0; + big.X2 = MAX_COORD; + big.Y1 = 0; + big.Y2 = MAX_COORD; + for (i = 0; i < max_group; i++) { + if (r_search(rd->layergrouptree[i], &big, NULL, bad_boy, NULL)) + return false; + } + return true; } #endif -static void -ripout_livedraw_obj (routebox_t *rb) +static void ripout_livedraw_obj(routebox_t * rb) { - if (rb->type == LINE && rb->livedraw_obj.line) - { - LayerType *layer = LAYER_PTR (PCB->LayerGroups.Entries[rb->group][0]); - EraseLine (rb->livedraw_obj.line); - DestroyObject (PCB->Data, LINE_TYPE, layer, rb->livedraw_obj.line, NULL); - rb->livedraw_obj.line = NULL; - } - if (rb->type == VIA && rb->livedraw_obj.via) - { - EraseVia (rb->livedraw_obj.via); - DestroyObject (PCB->Data, VIA_TYPE, rb->livedraw_obj.via, NULL, NULL); - rb->livedraw_obj.via = NULL; - } + if (rb->type == LINE && rb->livedraw_obj.line) { + LayerType *layer = LAYER_PTR(PCB->LayerGroups.Entries[rb->group][0]); + EraseLine(rb->livedraw_obj.line); + DestroyObject(PCB->Data, LINE_TYPE, layer, rb->livedraw_obj.line, NULL); + rb->livedraw_obj.line = NULL; + } + if (rb->type == VIA && rb->livedraw_obj.via) { + EraseVia(rb->livedraw_obj.via); + DestroyObject(PCB->Data, VIA_TYPE, rb->livedraw_obj.via, NULL, NULL); + rb->livedraw_obj.via = NULL; + } } -static int -ripout_livedraw_obj_cb (const BoxType * b, void *cl) +static int ripout_livedraw_obj_cb(const BoxType * b, void *cl) { - routebox_t *box = (routebox_t *) b; - ripout_livedraw_obj (box); - return 0; + routebox_t *box = (routebox_t *) b; + ripout_livedraw_obj(box); + return 0; } -struct routeall_status -{ - /* --- for completion rate statistics ---- */ - int total_subnets; - /* total subnets routed without conflicts */ - int routed_subnets; - /* total subnets routed with conflicts */ - int conflict_subnets; - /* net failted entirely */ - int failed; - /* net was ripped */ - int ripped; - int total_nets_routed; +struct routeall_status { + /* --- for completion rate statistics ---- */ + int total_subnets; + /* total subnets routed without conflicts */ + int routed_subnets; + /* total subnets routed with conflicts */ + int conflict_subnets; + /* net failted entirely */ + int failed; + /* net was ripped */ + int ripped; + int total_nets_routed; }; -static double -calculate_progress (double this_heap_item, double this_heap_size, - struct routeall_status *ras) +static double calculate_progress(double this_heap_item, double this_heap_size, struct routeall_status *ras) { - double total_passes = passes + smoothes + 1; /* + 1 is the refinement pass */ - double this_pass = AutoRouteParameters.pass - 1; /* Number passes from zero */ - double heap_fraction = (double)(ras->routed_subnets + ras->conflict_subnets + ras->failed) / - (double)ras->total_subnets; - double pass_fraction = (this_heap_item + heap_fraction ) / this_heap_size; - double process_fraction = (this_pass + pass_fraction) / total_passes; + double total_passes = passes + smoothes + 1; /* + 1 is the refinement pass */ + double this_pass = AutoRouteParameters.pass - 1; /* Number passes from zero */ + double heap_fraction = (double) (ras->routed_subnets + ras->conflict_subnets + ras->failed) / (double) ras->total_subnets; + double pass_fraction = (this_heap_item + heap_fraction) / this_heap_size; + double process_fraction = (this_pass + pass_fraction) / total_passes; - return process_fraction; + return process_fraction; } -struct routeall_status -RouteAll (routedata_t * rd) +struct routeall_status RouteAll(routedata_t * rd) { - struct routeall_status ras; - struct routeone_status ros; - bool rip; - int request_cancel; + struct routeall_status ras; + struct routeone_status ros; + bool rip; + int request_cancel; #ifdef NET_HEAP - heap_t *net_heap; + heap_t *net_heap; #endif - heap_t *this_pass, *next_pass, *tmp; - routebox_t *net, *p, *pp; - cost_t total_net_cost, last_cost = 0, this_cost = 0; - int i; - int this_heap_size; - int this_heap_item; + heap_t *this_pass, *next_pass, *tmp; + routebox_t *net, *p, *pp; + cost_t total_net_cost, last_cost = 0, this_cost = 0; + int i; + int this_heap_size; + int this_heap_item; - /* initialize heap for first pass; - * do smallest area first; that makes - * the subsequent costs more representative */ - this_pass = heap_create (); - next_pass = heap_create (); + /* initialize heap for first pass; + * do smallest area first; that makes + * the subsequent costs more representative */ + this_pass = heap_create(); + next_pass = heap_create(); #ifdef NET_HEAP - net_heap = heap_create (); + net_heap = heap_create(); #endif - LIST_LOOP (rd->first_net, different_net, net); - { - double area; - BoxType bb = shrink_routebox (net); - LIST_LOOP (net, same_net, p); - { - MAKEMIN (bb.X1, p->sbox.X1); - MAKEMIN (bb.Y1, p->sbox.Y1); - MAKEMAX (bb.X2, p->sbox.X2); - MAKEMAX (bb.Y2, p->sbox.Y2); - } - END_LOOP; - area = (double) (bb.X2 - bb.X1) * (bb.Y2 - bb.Y1); - heap_insert (this_pass, area, net); - } - END_LOOP; + LIST_LOOP(rd->first_net, different_net, net); + { + double area; + BoxType bb = shrink_routebox(net); + LIST_LOOP(net, same_net, p); + { + MAKEMIN(bb.X1, p->sbox.X1); + MAKEMIN(bb.Y1, p->sbox.Y1); + MAKEMAX(bb.X2, p->sbox.X2); + MAKEMAX(bb.Y2, p->sbox.Y2); + } + END_LOOP; + area = (double) (bb.X2 - bb.X1) * (bb.Y2 - bb.Y1); + heap_insert(this_pass, area, net); + } + END_LOOP; - ras.total_nets_routed = 0; - /* refinement/finishing passes */ - for (i = 0; i <= passes + smoothes; i++) - { + ras.total_nets_routed = 0; + /* refinement/finishing passes */ + for (i = 0; i <= passes + smoothes; i++) { #ifdef ROUTE_VERBOSE - if (i > 0 && i <= passes) - printf ("--------- STARTING REFINEMENT PASS %d ------------\n", i); - else if (i > passes) - printf ("--------- STARTING SMOOTHING PASS %d -------------\n", - i - passes); + if (i > 0 && i <= passes) + printf("--------- STARTING REFINEMENT PASS %d ------------\n", i); + else if (i > passes) + printf("--------- STARTING SMOOTHING PASS %d -------------\n", i - passes); #endif - ras.total_subnets = ras.routed_subnets = ras.conflict_subnets = - ras.failed = ras.ripped = 0; - assert (heap_is_empty (next_pass)); + ras.total_subnets = ras.routed_subnets = ras.conflict_subnets = ras.failed = ras.ripped = 0; + assert(heap_is_empty(next_pass)); - this_heap_size = heap_size (this_pass); - for (this_heap_item = 0; !heap_is_empty (this_pass); this_heap_item++) - { + this_heap_size = heap_size(this_pass); + for (this_heap_item = 0; !heap_is_empty(this_pass); this_heap_item++) { #ifdef ROUTE_DEBUG - if (aabort) - break; + if (aabort) + break; #endif - net = (routebox_t *) heap_remove_smallest (this_pass); - InitAutoRouteParameters (i, net->style, i < passes, i > passes, - i == passes + smoothes); - if (i > 0) - { - /* rip up all unfixed traces in this net ? */ - if (AutoRouteParameters.rip_always) - rip = true; - else - { - rip = false; - LIST_LOOP (net, same_net, p); - if (p->flags.is_bad) - { - rip = true; - break; - } - END_LOOP; - } + net = (routebox_t *) heap_remove_smallest(this_pass); + InitAutoRouteParameters(i, net->style, i < passes, i > passes, i == passes + smoothes); + if (i > 0) { + /* rip up all unfixed traces in this net ? */ + if (AutoRouteParameters.rip_always) + rip = true; + else { + rip = false; + LIST_LOOP(net, same_net, p); + if (p->flags.is_bad) { + rip = true; + break; + } + END_LOOP; + } - LIST_LOOP (net, same_net, p); - p->flags.is_bad = 0; - if (!p->flags.fixed) - { + LIST_LOOP(net, same_net, p); + p->flags.is_bad = 0; + if (!p->flags.fixed) { #ifndef NDEBUG - bool del; + bool del; #endif - assert (!p->flags.homeless); - if (rip) - { - RemoveFromNet (p, NET); - RemoveFromNet (p, SUBNET); - } - if (AutoRouteParameters.use_vias && p->type != VIA_SHADOW - && p->type != PLANE) - { - mtspace_remove (rd->mtspace, &p->box, - p->flags.is_odd ? ODD : EVEN, - p->style->Keepaway); - if (!rip) - mtspace_add (rd->mtspace, &p->box, - p->flags.is_odd ? EVEN : ODD, - p->style->Keepaway); - } - if (rip) - { - if (TEST_FLAG (LIVEROUTEFLAG, PCB)) - ripout_livedraw_obj (p); + assert(!p->flags.homeless); + if (rip) { + RemoveFromNet(p, NET); + RemoveFromNet(p, SUBNET); + } + if (AutoRouteParameters.use_vias && p->type != VIA_SHADOW && p->type != PLANE) { + mtspace_remove(rd->mtspace, &p->box, p->flags.is_odd ? ODD : EVEN, p->style->Keepaway); + if (!rip) + mtspace_add(rd->mtspace, &p->box, p->flags.is_odd ? EVEN : ODD, p->style->Keepaway); + } + if (rip) { + if (TEST_FLAG(LIVEROUTEFLAG, PCB)) + ripout_livedraw_obj(p); #ifndef NDEBUG - del = + del = #endif - r_delete_entry (rd->layergrouptree[p->group], - &p->box); + r_delete_entry(rd->layergrouptree[p->group], &p->box); #ifndef NDEBUG - assert (del); + assert(del); #endif - } - else - { - p->flags.is_odd = AutoRouteParameters.is_odd; - } - } - END_LOOP; - if (TEST_FLAG (LIVEROUTEFLAG, PCB)) - Draw (); - /* reset to original connectivity */ - if (rip) - { - ras.ripped++; - ResetSubnet (net); - } - else - { - heap_insert (next_pass, 0, net); - continue; - } - } - /* count number of subnets */ - FOREACH_SUBNET (net, p); - ras.total_subnets++; - END_FOREACH (net, p); - /* the first subnet doesn't require routing. */ - ras.total_subnets--; - /* and re-route! */ - total_net_cost = 0; - /* only route that which isn't fully routed */ + } + else { + p->flags.is_odd = AutoRouteParameters.is_odd; + } + } + END_LOOP; + if (TEST_FLAG(LIVEROUTEFLAG, PCB)) + Draw(); + /* reset to original connectivity */ + if (rip) { + ras.ripped++; + ResetSubnet(net); + } + else { + heap_insert(next_pass, 0, net); + continue; + } + } + /* count number of subnets */ + FOREACH_SUBNET(net, p); + ras.total_subnets++; + END_FOREACH(net, p); + /* the first subnet doesn't require routing. */ + ras.total_subnets--; + /* and re-route! */ + total_net_cost = 0; + /* only route that which isn't fully routed */ #ifdef ROUTE_DEBUG - if (ras.total_subnets == 0 || aabort) + if (ras.total_subnets == 0 || aabort) #else - if (ras.total_subnets == 0) + if (ras.total_subnets == 0) #endif - { - heap_insert (next_pass, 0, net); - continue; - } + { + heap_insert(next_pass, 0, net); + continue; + } - /* the loop here ensures that we get to all subnets even if - * some of them are unreachable from the first subnet. */ - LIST_LOOP (net, same_net, p); - { + /* the loop here ensures that we get to all subnets even if + * some of them are unreachable from the first subnet. */ + LIST_LOOP(net, same_net, p); + { #ifdef NET_HEAP - BoxType b = shrink_routebox (p); - /* using a heap allows us to start from smaller objects and - * end at bigger ones. also prefer to start at planes, then pads */ - heap_insert (net_heap, (float) (b.X2 - b.X1) * + BoxType b = shrink_routebox(p); + /* using a heap allows us to start from smaller objects and + * end at bigger ones. also prefer to start at planes, then pads */ + heap_insert(net_heap, (float) (b.X2 - b.X1) * #if defined(ROUTE_RANDOMIZED) - (0.3 + rand () / (RAND_MAX + 1.0)) * + (0.3 + rand() / (RAND_MAX + 1.0)) * #endif - (b.Y2 - b.Y1) * (p->type == PLANE ? - -1 : (p->type == - PAD ? 1 : 10)), p); - } - END_LOOP; - ros.net_completely_routed = 0; - while (!heap_is_empty (net_heap)) - { - p = (routebox_t *) heap_remove_smallest (net_heap); + (b.Y2 - b.Y1) * (p->type == PLANE ? -1 : (p->type == PAD ? 1 : 10)), p); + } + END_LOOP; + ros.net_completely_routed = 0; + while (!heap_is_empty(net_heap)) { + p = (routebox_t *) heap_remove_smallest(net_heap); #endif - if (!p->flags.fixed || p->flags.subnet_processed || - p->type == OTHER) - continue; + if (!p->flags.fixed || p->flags.subnet_processed || p->type == OTHER) + continue; - while (!ros.net_completely_routed) - { - double percent; + while (!ros.net_completely_routed) { + double percent; - assert (no_expansion_boxes (rd)); - /* FIX ME: the number of edges to examine should be in autoroute parameters - * i.e. the 2000 and 800 hard-coded below should be controllable by the user - */ - ros = - RouteOne (rd, p, NULL, - ((AutoRouteParameters. - is_smoothing ? 2000 : 800) * (i + - 1)) * - routing_layers); - total_net_cost += ros.best_route_cost; - if (ros.found_route) - { - if (ros.route_had_conflicts) - ras.conflict_subnets++; - else - { - ras.routed_subnets++; - ras.total_nets_routed++; + assert(no_expansion_boxes(rd)); + /* FIX ME: the number of edges to examine should be in autoroute parameters + * i.e. the 2000 and 800 hard-coded below should be controllable by the user + */ + ros = RouteOne(rd, p, NULL, ((AutoRouteParameters.is_smoothing ? 2000 : 800) * (i + 1)) * routing_layers); + total_net_cost += ros.best_route_cost; + if (ros.found_route) { + if (ros.route_had_conflicts) + ras.conflict_subnets++; + else { + ras.routed_subnets++; + ras.total_nets_routed++; + } + } + else { + if (!ros.net_completely_routed) + ras.failed++; + /* don't bother trying any other source in this subnet */ + LIST_LOOP(p, same_subnet, pp); + pp->flags.subnet_processed = 1; + END_LOOP; + break; + } + /* note that we can infer nothing about ras.total_subnets based + * on the number of calls to RouteOne, because we may be unable + * to route a net from a particular starting point, but perfectly + * able to route it from some other. */ + percent = calculate_progress(this_heap_item, this_heap_size, &ras); + request_cancel = gui->progress(percent * 100., 100, _("Autorouting tracks")); + if (request_cancel) { + ras.total_nets_routed = 0; + ras.conflict_subnets = 0; + Message("Autorouting cancelled\n"); + goto out; + } + } } - } - else - { - if (!ros.net_completely_routed) - ras.failed++; - /* don't bother trying any other source in this subnet */ - LIST_LOOP (p, same_subnet, pp); - pp->flags.subnet_processed = 1; - END_LOOP; - break; - } - /* note that we can infer nothing about ras.total_subnets based - * on the number of calls to RouteOne, because we may be unable - * to route a net from a particular starting point, but perfectly - * able to route it from some other. */ - percent = calculate_progress (this_heap_item, this_heap_size, &ras); - request_cancel = gui->progress (percent * 100., 100, - _("Autorouting tracks")); - if (request_cancel) - { - ras.total_nets_routed = 0; - ras.conflict_subnets = 0; - Message ("Autorouting cancelled\n"); - goto out; - } - } - } #ifndef NET_HEAP - END_LOOP; + END_LOOP; #endif - if (!ros.net_completely_routed) - net->flags.is_bad = 1; /* don't skip this the next round */ + if (!ros.net_completely_routed) + net->flags.is_bad = 1; /* don't skip this the next round */ - /* Route easiest nets from this pass first on next pass. - * This works best because it's likely that the hardest - * is the last one routed (since it has the most obstacles) - * but it will do no good to rip it up and try it again - * without first changing any of the other routes - */ - heap_insert (next_pass, total_net_cost, net); - if (total_net_cost < EXPENSIVE) - this_cost += total_net_cost; - /* reset subnet_processed flags */ - LIST_LOOP (net, same_net, p); - { - p->flags.subnet_processed = 0; - } - END_LOOP; - } - /* swap this_pass and next_pass and do it all over again! */ - ro = 0; - assert (heap_is_empty (this_pass)); - tmp = this_pass; - this_pass = next_pass; - next_pass = tmp; + /* Route easiest nets from this pass first on next pass. + * This works best because it's likely that the hardest + * is the last one routed (since it has the most obstacles) + * but it will do no good to rip it up and try it again + * without first changing any of the other routes + */ + heap_insert(next_pass, total_net_cost, net); + if (total_net_cost < EXPENSIVE) + this_cost += total_net_cost; + /* reset subnet_processed flags */ + LIST_LOOP(net, same_net, p); + { + p->flags.subnet_processed = 0; + } + END_LOOP; + } + /* swap this_pass and next_pass and do it all over again! */ + ro = 0; + assert(heap_is_empty(this_pass)); + tmp = this_pass; + this_pass = next_pass; + next_pass = tmp; #if defined(ROUTE_DEBUG) || defined (ROUTE_VERBOSE) - printf - ("END OF PASS %d: %d/%d subnets routed without conflicts at cost %.0f, %d conflicts, %d failed %d ripped\n", - i, ras.routed_subnets, ras.total_subnets, this_cost, - ras.conflict_subnets, ras.failed, ras.ripped); + printf + ("END OF PASS %d: %d/%d subnets routed without conflicts at cost %.0f, %d conflicts, %d failed %d ripped\n", + i, ras.routed_subnets, ras.total_subnets, this_cost, ras.conflict_subnets, ras.failed, ras.ripped); #endif #ifdef ROUTE_DEBUG - if (aabort) - break; + if (aabort) + break; #endif - /* if no conflicts found, skip directly to smoothing pass! */ - if (ras.conflict_subnets == 0 && ras.routed_subnets == ras.total_subnets - && i <= passes) - i = passes - (smoothes ? 0 : 1); - /* if no changes in a smoothing round, then we're done */ - if (this_cost == last_cost && i > passes && i < passes + smoothes) - i = passes + smoothes - 1; - last_cost = this_cost; - this_cost = 0; - } + /* if no conflicts found, skip directly to smoothing pass! */ + if (ras.conflict_subnets == 0 && ras.routed_subnets == ras.total_subnets && i <= passes) + i = passes - (smoothes ? 0 : 1); + /* if no changes in a smoothing round, then we're done */ + if (this_cost == last_cost && i > passes && i < passes + smoothes) + i = passes + smoothes - 1; + last_cost = this_cost; + this_cost = 0; + } - Message ("%d of %d nets successfully routed.\n", - ras.routed_subnets, ras.total_subnets); + Message("%d of %d nets successfully routed.\n", ras.routed_subnets, ras.total_subnets); out: - heap_destroy (&this_pass); - heap_destroy (&next_pass); + heap_destroy(&this_pass); + heap_destroy(&next_pass); #ifdef NET_HEAP - heap_destroy (&net_heap); + heap_destroy(&net_heap); #endif - /* no conflicts should be left at the end of the process. */ - assert (ras.conflict_subnets == 0); + /* no conflicts should be left at the end of the process. */ + assert(ras.conflict_subnets == 0); - return ras; + return ras; } -struct fpin_info -{ - PinTypePtr pin; - Coord X, Y; - jmp_buf env; +struct fpin_info { + PinTypePtr pin; + Coord X, Y; + jmp_buf env; }; -static int -fpin_rect (const BoxType * b, void *cl) +static int fpin_rect(const BoxType * b, void *cl) { - PinTypePtr pin = (PinTypePtr) b; - struct fpin_info *info = (struct fpin_info *) cl; - if (pin->X == info->X && pin->Y == info->Y) - { - info->pin = (PinTypePtr) b; - longjmp (info->env, 1); - } - return 0; + PinTypePtr pin = (PinTypePtr) b; + struct fpin_info *info = (struct fpin_info *) cl; + if (pin->X == info->X && pin->Y == info->Y) { + info->pin = (PinTypePtr) b; + longjmp(info->env, 1); + } + return 0; } -static int -FindPin (const BoxType * box, PinTypePtr * pin) +static int FindPin(const BoxType * box, PinTypePtr * pin) { - struct fpin_info info; + struct fpin_info info; - info.pin = NULL; - info.X = box->X1; - info.Y = box->Y1; - if (setjmp (info.env) == 0) - r_search (PCB->Data->pin_tree, box, NULL, fpin_rect, &info); - else - { - *pin = info.pin; - return PIN_TYPE; - } - if (setjmp (info.env) == 0) - r_search (PCB->Data->via_tree, box, NULL, fpin_rect, &info); - else - { - *pin = info.pin; - return VIA_TYPE; - } - *pin = NULL; - return NO_TYPE; + info.pin = NULL; + info.X = box->X1; + info.Y = box->Y1; + if (setjmp(info.env) == 0) + r_search(PCB->Data->pin_tree, box, NULL, fpin_rect, &info); + else { + *pin = info.pin; + return PIN_TYPE; + } + if (setjmp(info.env) == 0) + r_search(PCB->Data->via_tree, box, NULL, fpin_rect, &info); + else { + *pin = info.pin; + return VIA_TYPE; + } + *pin = NULL; + return NO_TYPE; } /* paths go on first 'on' layer in group */ /* returns 'true' if any paths were added. */ -bool -IronDownAllUnfixedPaths (routedata_t * rd) +bool IronDownAllUnfixedPaths(routedata_t * rd) { - bool changed = false; - LayerTypePtr layer; - routebox_t *net, *p; - int i; - LIST_LOOP (rd->first_net, different_net, net); - { - LIST_LOOP (net, same_net, p); - { - if (!p->flags.fixed) + bool changed = false; + LayerTypePtr layer; + routebox_t *net, *p; + int i; + LIST_LOOP(rd->first_net, different_net, net); { - /* find first on layer in this group */ - assert (PCB->LayerGroups.Number[p->group] > 0); - assert (is_layer_group_active[p->group]); - for (i = 0, layer = NULL; i < PCB->LayerGroups.Number[p->group]; - i++) - { - layer = LAYER_PTR (PCB->LayerGroups.Entries[p->group][i]); - if (layer->On) - break; - } - assert (layer && layer->On); /*at least one layer must be on in this group! */ - assert (p->type != EXPANSION_AREA); - if (p->type == LINE) - { - Coord halfwidth = HALF_THICK (p->style->Thick); - double th = halfwidth * 2 + 1; - BoxType b; - assert (p->parent.line == NULL); - /* orthogonal; thickness is 2*halfwidth */ - /* flip coordinates, if bl_to_ur */ - b = p->sbox; - total_wire_length += - sqrt ((b.X2 - b.X1 - th) * (b.X2 - b.X1 - th) + - (b.Y2 - b.Y1 - th) * (b.Y2 - b.Y1 - th)); - b = shrink_box (&b, halfwidth); - if (b.X2 == b.X1 + 1) - b.X2 = b.X1; - if (b.Y2 == b.Y1 + 1) - b.Y2 = b.Y1; - if (p->flags.bl_to_ur) + LIST_LOOP(net, same_net, p); { - Coord t; - t = b.X1; - b.X1 = b.X2; - b.X2 = t; - } - /* using CreateDrawn instead of CreateNew concatenates sequential lines */ - p->parent.line = CreateDrawnLineOnLayer - (layer, b.X1, b.Y1, b.X2, b.Y2, - p->style->Thick, - p->style->Keepaway * 2, - MakeFlags (AUTOFLAG | - (TEST_FLAG (CLEARNEWFLAG, PCB) ? CLEARLINEFLAG : - 0))); + if (!p->flags.fixed) { + /* find first on layer in this group */ + assert(PCB->LayerGroups.Number[p->group] > 0); + assert(is_layer_group_active[p->group]); + for (i = 0, layer = NULL; i < PCB->LayerGroups.Number[p->group]; i++) { + layer = LAYER_PTR(PCB->LayerGroups.Entries[p->group][i]); + if (layer->On) + break; + } + assert(layer && layer->On); /*at least one layer must be on in this group! */ + assert(p->type != EXPANSION_AREA); + if (p->type == LINE) { + Coord halfwidth = HALF_THICK(p->style->Thick); + double th = halfwidth * 2 + 1; + BoxType b; + assert(p->parent.line == NULL); + /* orthogonal; thickness is 2*halfwidth */ + /* flip coordinates, if bl_to_ur */ + b = p->sbox; + total_wire_length += sqrt((b.X2 - b.X1 - th) * (b.X2 - b.X1 - th) + (b.Y2 - b.Y1 - th) * (b.Y2 - b.Y1 - th)); + b = shrink_box(&b, halfwidth); + if (b.X2 == b.X1 + 1) + b.X2 = b.X1; + if (b.Y2 == b.Y1 + 1) + b.Y2 = b.Y1; + if (p->flags.bl_to_ur) { + Coord t; + t = b.X1; + b.X1 = b.X2; + b.X2 = t; + } + /* using CreateDrawn instead of CreateNew concatenates sequential lines */ + p->parent.line = CreateDrawnLineOnLayer + (layer, b.X1, b.Y1, b.X2, b.Y2, + p->style->Thick, p->style->Keepaway * 2, MakeFlags(AUTOFLAG | (TEST_FLAG(CLEARNEWFLAG, PCB) ? CLEARLINEFLAG : 0))); - if (p->parent.line) - { - AddObjectToCreateUndoList (LINE_TYPE, layer, - p->parent.line, p->parent.line); - changed = true; + if (p->parent.line) { + AddObjectToCreateUndoList(LINE_TYPE, layer, p->parent.line, p->parent.line); + changed = true; + } + } + else if (p->type == VIA || p->type == VIA_SHADOW) { + routebox_t *pp = (p->type == VIA_SHADOW) ? p->parent.via_shadow : p; + Coord radius = HALF_THICK(pp->style->Diameter); + BoxType b = shrink_routebox(p); + total_via_count++; + assert(pp->type == VIA); + if (pp->parent.via == NULL) { + assert(b.X1 + radius == b.X2 - radius); + assert(b.Y1 + radius == b.Y2 - radius); + pp->parent.via = + CreateNewVia(PCB->Data, b.X1 + radius, + b.Y1 + radius, + pp->style->Diameter, 2 * pp->style->Keepaway, 0, pp->style->Hole, NULL, MakeFlags(AUTOFLAG)); + assert(pp->parent.via); + if (pp->parent.via) { + AddObjectToCreateUndoList(VIA_TYPE, pp->parent.via, pp->parent.via, pp->parent.via); + changed = true; + } + } + assert(pp->parent.via); + if (p->type == VIA_SHADOW) { + p->type = VIA; + p->parent.via = pp->parent.via; + } + } + else if (p->type == THERMAL) + /* nothing to do because, the via might not be there yet */ ; + else + assert(0); + } } - } - else if (p->type == VIA || p->type == VIA_SHADOW) - { - routebox_t *pp = - (p->type == VIA_SHADOW) ? p->parent.via_shadow : p; - Coord radius = HALF_THICK (pp->style->Diameter); - BoxType b = shrink_routebox (p); - total_via_count++; - assert (pp->type == VIA); - if (pp->parent.via == NULL) + END_LOOP; + /* loop again to place all the thermals now that the vias are down */ + LIST_LOOP(net, same_net, p); { - assert (b.X1 + radius == b.X2 - radius); - assert (b.Y1 + radius == b.Y2 - radius); - pp->parent.via = - CreateNewVia (PCB->Data, b.X1 + radius, - b.Y1 + radius, - pp->style->Diameter, - 2 * pp->style->Keepaway, - 0, pp->style->Hole, NULL, - MakeFlags (AUTOFLAG)); - assert (pp->parent.via); - if (pp->parent.via) - { - AddObjectToCreateUndoList (VIA_TYPE, - pp->parent.via, - pp->parent.via, - pp->parent.via); - changed = true; - } + if (p->type == THERMAL) { + PinTypePtr pin = NULL; + /* thermals are alread a single point search, no need to shrink */ + int type = FindPin(&p->box, &pin); + if (pin) { + AddObjectToClearPolyUndoList(type, pin->Element ? pin->Element : pin, pin, pin, false); + RestoreToPolygon(PCB->Data, VIA_TYPE, LAYER_PTR(p->layer), pin); + AddObjectToFlagUndoList(type, pin->Element ? pin->Element : pin, pin, pin); + ASSIGN_THERM(p->layer, PCB->ThermStyle, pin); + AddObjectToClearPolyUndoList(type, pin->Element ? pin->Element : pin, pin, pin, true); + ClearFromPolygon(PCB->Data, VIA_TYPE, LAYER_PTR(p->layer), pin); + changed = true; + } + } } - assert (pp->parent.via); - if (p->type == VIA_SHADOW) - { - p->type = VIA; - p->parent.via = pp->parent.via; - } - } - else if (p->type == THERMAL) - /* nothing to do because, the via might not be there yet */ ; - else - assert (0); + END_LOOP; } - } - END_LOOP; - /* loop again to place all the thermals now that the vias are down */ - LIST_LOOP (net, same_net, p); - { - if (p->type == THERMAL) - { - PinTypePtr pin = NULL; - /* thermals are alread a single point search, no need to shrink */ - int type = FindPin (&p->box, &pin); - if (pin) - { - AddObjectToClearPolyUndoList (type, - pin->Element ? pin->Element : pin, - pin, pin, false); - RestoreToPolygon (PCB->Data, VIA_TYPE, LAYER_PTR (p->layer), - pin); - AddObjectToFlagUndoList (type, - pin->Element ? pin->Element : pin, pin, - pin); - ASSIGN_THERM (p->layer, PCB->ThermStyle, pin); - AddObjectToClearPolyUndoList (type, - pin->Element ? pin->Element : pin, - pin, pin, true); - ClearFromPolygon (PCB->Data, VIA_TYPE, LAYER_PTR (p->layer), - pin); - changed = true; - } - } - } - END_LOOP; - } - END_LOOP; - return changed; + END_LOOP; + return changed; } -bool -AutoRoute (bool selected) +bool AutoRoute(bool selected) { - bool changed = false; - routedata_t *rd; - int i; + bool changed = false; + routedata_t *rd; + int i; - total_wire_length = 0; - total_via_count = 0; + total_wire_length = 0; + total_via_count = 0; #ifdef ROUTE_DEBUG - ddraw = gui->request_debug_draw (); - if (ddraw != NULL) - { - ar_gc = ddraw->make_gc (); - ddraw->set_line_cap (ar_gc, Round_Cap); - } + ddraw = gui->request_debug_draw(); + if (ddraw != NULL) { + ar_gc = ddraw->make_gc(); + ddraw->set_line_cap(ar_gc, Round_Cap); + } #endif - for (i = 0; i < NUM_STYLES; i++) - { - if (PCB->RouteStyle[i].Thick == 0 || - PCB->RouteStyle[1].Diameter == 0 || - PCB->RouteStyle[1].Hole == 0 || PCB->RouteStyle[i].Keepaway == 0) - { - Message ("You must define proper routing styles\n" - "before auto-routing.\n"); - return (false); + for (i = 0; i < NUM_STYLES; i++) { + if (PCB->RouteStyle[i].Thick == 0 || + PCB->RouteStyle[1].Diameter == 0 || PCB->RouteStyle[1].Hole == 0 || PCB->RouteStyle[i].Keepaway == 0) { + Message("You must define proper routing styles\n" "before auto-routing.\n"); + return (false); + } } - } - if (PCB->Data->RatN == 0) - return (false); - SaveFindFlag (DRCFLAG); - rd = CreateRouteData (); + if (PCB->Data->RatN == 0) + return (false); + SaveFindFlag(DRCFLAG); + rd = CreateRouteData(); - if (1) - { - routebox_t *net, *rb, *last; - int i = 0; - /* count number of rats selected */ - RAT_LOOP (PCB->Data); - { - if (!selected || TEST_FLAG (SELECTEDFLAG, line)) - i++; - } - END_LOOP; + if (1) { + routebox_t *net, *rb, *last; + int i = 0; + /* count number of rats selected */ + RAT_LOOP(PCB->Data); + { + if (!selected || TEST_FLAG(SELECTEDFLAG, line)) + i++; + } + END_LOOP; #ifdef ROUTE_VERBOSE - printf ("%d nets!\n", i); + printf("%d nets!\n", i); #endif - if (i == 0) - goto donerouting; /* nothing to do here */ - /* if only one rat selected, do things the quick way. =) */ - if (i == 1) - { - RAT_LOOP (PCB->Data); - if (!selected || TEST_FLAG (SELECTEDFLAG, line)) - { - /* look up the end points of this rat line */ - routebox_t *a; - routebox_t *b; - a = - FindRouteBoxOnLayerGroup (rd, line->Point1.X, - line->Point1.Y, line->group1); - b = - FindRouteBoxOnLayerGroup (rd, line->Point2.X, - line->Point2.Y, line->group2); - assert (a != NULL && b != NULL); - assert (a->style == b->style); + if (i == 0) + goto donerouting; /* nothing to do here */ + /* if only one rat selected, do things the quick way. =) */ + if (i == 1) { + RAT_LOOP(PCB->Data); + if (!selected || TEST_FLAG(SELECTEDFLAG, line)) { + /* look up the end points of this rat line */ + routebox_t *a; + routebox_t *b; + a = FindRouteBoxOnLayerGroup(rd, line->Point1.X, line->Point1.Y, line->group1); + b = FindRouteBoxOnLayerGroup(rd, line->Point2.X, line->Point2.Y, line->group2); + assert(a != NULL && b != NULL); + assert(a->style == b->style); /* if (a->type != PAD && b->type == PAD) { @@ -5230,139 +4584,126 @@ b = t; } */ - /* route exactly one net, without allowing conflicts */ - InitAutoRouteParameters (0, a->style, false, true, true); - /* hace planes work better as sources than targets */ - changed = RouteOne (rd, a, b, 150000).found_route || changed; - goto donerouting; - } - END_LOOP; - } - /* otherwise, munge the netlists so that only the selected rats - * get connected. */ - /* first, separate all sub nets into separate nets */ - /* note that this code works because LIST_LOOP is clever enough not to - * be fooled when the list is changing out from under it. */ - last = NULL; - LIST_LOOP (rd->first_net, different_net, net); - { - FOREACH_SUBNET (net, rb); - { - if (last) - { - last->different_net.next = rb; - rb->different_net.prev = last; - } - last = rb; - } - END_FOREACH (net, rb); - LIST_LOOP (net, same_net, rb); - { - rb->same_net = rb->same_subnet; - } - END_LOOP; - /* at this point all nets are equal to their subnets */ - } - END_LOOP; - if (last) - { - last->different_net.next = rd->first_net; - rd->first_net->different_net.prev = last; - } + /* route exactly one net, without allowing conflicts */ + InitAutoRouteParameters(0, a->style, false, true, true); + /* hace planes work better as sources than targets */ + changed = RouteOne(rd, a, b, 150000).found_route || changed; + goto donerouting; + } + END_LOOP; + } + /* otherwise, munge the netlists so that only the selected rats + * get connected. */ + /* first, separate all sub nets into separate nets */ + /* note that this code works because LIST_LOOP is clever enough not to + * be fooled when the list is changing out from under it. */ + last = NULL; + LIST_LOOP(rd->first_net, different_net, net); + { + FOREACH_SUBNET(net, rb); + { + if (last) { + last->different_net.next = rb; + rb->different_net.prev = last; + } + last = rb; + } + END_FOREACH(net, rb); + LIST_LOOP(net, same_net, rb); + { + rb->same_net = rb->same_subnet; + } + END_LOOP; + /* at this point all nets are equal to their subnets */ + } + END_LOOP; + if (last) { + last->different_net.next = rd->first_net; + rd->first_net->different_net.prev = last; + } - /* now merge only those subnets connected by a rat line */ - RAT_LOOP (PCB->Data); - if (!selected || TEST_FLAG (SELECTEDFLAG, line)) - { - /* look up the end points of this rat line */ - routebox_t *a; - routebox_t *b; - a = - FindRouteBoxOnLayerGroup (rd, line->Point1.X, - line->Point1.Y, line->group1); - b = - FindRouteBoxOnLayerGroup (rd, line->Point2.X, - line->Point2.Y, line->group2); - if (!a || !b) - { + /* now merge only those subnets connected by a rat line */ + RAT_LOOP(PCB->Data); + if (!selected || TEST_FLAG(SELECTEDFLAG, line)) { + /* look up the end points of this rat line */ + routebox_t *a; + routebox_t *b; + a = FindRouteBoxOnLayerGroup(rd, line->Point1.X, line->Point1.Y, line->group1); + b = FindRouteBoxOnLayerGroup(rd, line->Point2.X, line->Point2.Y, line->group2); + if (!a || !b) { #ifdef DEBUG_STALE_RATS - AddObjectToFlagUndoList (RATLINE_TYPE, line, line, line); - ASSIGN_FLAG (SELECTEDFLAG, true, line); - DrawRat (line, 0); + AddObjectToFlagUndoList(RATLINE_TYPE, line, line, line); + ASSIGN_FLAG(SELECTEDFLAG, true, line); + DrawRat(line, 0); #endif /* DEBUG_STALE_RATS */ - Message ("The rats nest is stale! Aborting autoroute...\n"); - goto donerouting; - } - /* merge subnets into a net! */ - MergeNets (a, b, NET); + Message("The rats nest is stale! Aborting autoroute...\n"); + goto donerouting; + } + /* merge subnets into a net! */ + MergeNets(a, b, NET); + } + END_LOOP; + /* now 'different_net' may point to too many different nets. Reset. */ + LIST_LOOP(rd->first_net, different_net, net); + { + if (!net->flags.touched) { + LIST_LOOP(net, same_net, rb); + rb->flags.touched = 1; + END_LOOP; + } + else /* this is not a "different net"! */ + RemoveFromNet(net, DIFFERENT_NET); + } + END_LOOP; + /* reset "touched" flag */ + LIST_LOOP(rd->first_net, different_net, net); + { + LIST_LOOP(net, same_net, rb); + { + assert(rb->flags.touched); + rb->flags.touched = 0; + } + END_LOOP; + } + END_LOOP; } - END_LOOP; - /* now 'different_net' may point to too many different nets. Reset. */ - LIST_LOOP (rd->first_net, different_net, net); - { - if (!net->flags.touched) - { - LIST_LOOP (net, same_net, rb); - rb->flags.touched = 1; - END_LOOP; - } - else /* this is not a "different net"! */ - RemoveFromNet (net, DIFFERENT_NET); - } - END_LOOP; - /* reset "touched" flag */ - LIST_LOOP (rd->first_net, different_net, net); - { - LIST_LOOP (net, same_net, rb); - { - assert (rb->flags.touched); - rb->flags.touched = 0; - } - END_LOOP; - } - END_LOOP; - } - /* okay, rd's idea of netlist now corresponds to what we want routed */ - /* auto-route all nets */ - changed = (RouteAll (rd).total_nets_routed > 0) || changed; + /* okay, rd's idea of netlist now corresponds to what we want routed */ + /* auto-route all nets */ + changed = (RouteAll(rd).total_nets_routed > 0) || changed; donerouting: - gui->progress (0, 0, NULL); - if (TEST_FLAG (LIVEROUTEFLAG, PCB)) - { - int i; - BoxType big = {0, 0, MAX_COORD, MAX_COORD}; - for (i = 0; i < max_group; i++) - { - r_search (rd->layergrouptree[i], &big, NULL, ripout_livedraw_obj_cb, NULL); + gui->progress(0, 0, NULL); + if (TEST_FLAG(LIVEROUTEFLAG, PCB)) { + int i; + BoxType big = { 0, 0, MAX_COORD, MAX_COORD }; + for (i = 0; i < max_group; i++) { + r_search(rd->layergrouptree[i], &big, NULL, ripout_livedraw_obj_cb, NULL); + } } - } #ifdef ROUTE_DEBUG - if (ddraw != NULL) - ddraw->finish_debug_draw (); + if (ddraw != NULL) + ddraw->finish_debug_draw(); #endif - if (changed) - changed = IronDownAllUnfixedPaths (rd); - Message ("Total added wire length = %$mS, %d vias added\n", - (Coord) total_wire_length, total_via_count); - DestroyRouteData (&rd); - if (changed) - { - SaveUndoSerialNumber (); + if (changed) + changed = IronDownAllUnfixedPaths(rd); + Message("Total added wire length = %$mS, %d vias added\n", (Coord) total_wire_length, total_via_count); + DestroyRouteData(&rd); + if (changed) { + SaveUndoSerialNumber(); - /* optimize rats, we've changed connectivity a lot. */ - DeleteRats (false /*all rats */ ); - RestoreUndoSerialNumber (); - AddAllRats (false /*all rats */ , NULL); - RestoreUndoSerialNumber (); + /* optimize rats, we've changed connectivity a lot. */ + DeleteRats(false /*all rats */ ); + RestoreUndoSerialNumber(); + AddAllRats(false /*all rats */ , NULL); + RestoreUndoSerialNumber(); - IncrementUndoSerialNumber (); + IncrementUndoSerialNumber(); - Redraw (); - } - RestoreFindFlag (); + Redraw(); + } + RestoreFindFlag(); #if defined (ROUTE_DEBUG) - aabort = 0; + aabort = 0; #endif - return (changed); + return (changed); } Index: trunk/src/autoroute.h =================================================================== --- trunk/src/autoroute.h (revision 1021) +++ trunk/src/autoroute.h (revision 1022) @@ -39,6 +39,6 @@ #include "global.h" -bool AutoRoute (bool); +bool AutoRoute(bool); #endif Index: trunk/src/box.h =================================================================== --- trunk/src/box.h (revision 1021) +++ trunk/src/box.h (revision 1022) @@ -42,9 +42,8 @@ #include "misc.h" -typedef enum -{ NORTH = 0, EAST = 1, SOUTH = 2, WEST = 3, NE = 4, SE = 5, SW = 6, NW = - 7, ALL = 8 } direction_t; +typedef enum { NORTH = 0, EAST = 1, SOUTH = 2, WEST = 3, NE = 4, SE = 5, SW = 6, NW = 7, ALL = 8 +} direction_t; /* rotates box 90-degrees cw */ /* that's a strange rotation! */ @@ -88,9 +87,8 @@ #define CENTER_Y(b) ((b).Y1 + ((b).Y2 - (b).Y1)/2) /* some useful box utilities. */ -typedef struct cheap_point -{ - Coord X, Y; +typedef struct cheap_point { + Coord X, Y; } CheapPointType; @@ -97,136 +95,115 @@ /* note that boxes are closed on top and left and open on bottom and right. */ /* this means that top-left corner is in box, *but bottom-right corner is * not*. */ -static inline bool -point_in_box (const BoxType * box, Coord X, Coord Y) +static inline bool point_in_box(const BoxType * box, Coord X, Coord Y) { - return (X >= box->X1) && (Y >= box->Y1) && (X < box->X2) && (Y < box->Y2); + return (X >= box->X1) && (Y >= box->Y1) && (X < box->X2) && (Y < box->Y2); } -static inline bool -point_in_closed_box (const BoxType * box, Coord X, Coord Y) +static inline bool point_in_closed_box(const BoxType * box, Coord X, Coord Y) { - return (X >= box->X1) && (Y >= box->Y1) && (X <= box->X2) && (Y <= box->Y2); + return (X >= box->X1) && (Y >= box->Y1) && (X <= box->X2) && (Y <= box->Y2); } -static inline bool -box_is_good (const BoxType * b) +static inline bool box_is_good(const BoxType * b) { - return (b->X1 < b->X2) && (b->Y1 < b->Y2); + return (b->X1 < b->X2) && (b->Y1 < b->Y2); } -static inline bool -box_intersect (const BoxType * a, const BoxType * b) +static inline bool box_intersect(const BoxType * a, const BoxType * b) { - return - (a->X1 < b->X2) && (b->X1 < a->X2) && (a->Y1 < b->Y2) && (b->Y1 < a->Y2); + return (a->X1 < b->X2) && (b->X1 < a->X2) && (a->Y1 < b->Y2) && (b->Y1 < a->Y2); } -static inline CheapPointType -closest_point_in_box (const CheapPointType * from, const BoxType * box) +static inline CheapPointType closest_point_in_box(const CheapPointType * from, const BoxType * box) { - CheapPointType r; - assert (box->X1 < box->X2 && box->Y1 < box->Y2); - r.X = - (from->X < box->X1) ? box->X1 : (from->X > - box->X2 - 1) ? box->X2 - 1 : from->X; - r.Y = - (from->Y < box->Y1) ? box->Y1 : (from->Y > - box->Y2 - 1) ? box->Y2 - 1 : from->Y; - assert (point_in_box (box, r.X, r.Y)); - return r; + CheapPointType r; + assert(box->X1 < box->X2 && box->Y1 < box->Y2); + r.X = (from->X < box->X1) ? box->X1 : (from->X > box->X2 - 1) ? box->X2 - 1 : from->X; + r.Y = (from->Y < box->Y1) ? box->Y1 : (from->Y > box->Y2 - 1) ? box->Y2 - 1 : from->Y; + assert(point_in_box(box, r.X, r.Y)); + return r; } -static inline bool -box_in_box (const BoxType * outer, const BoxType * inner) +static inline bool box_in_box(const BoxType * outer, const BoxType * inner) { - return - (outer->X1 <= inner->X1) && (inner->X2 <= outer->X2) && - (outer->Y1 <= inner->Y1) && (inner->Y2 <= outer->Y2); + return (outer->X1 <= inner->X1) && (inner->X2 <= outer->X2) && (outer->Y1 <= inner->Y1) && (inner->Y2 <= outer->Y2); } -static inline BoxType -clip_box (const BoxType * box, const BoxType * clipbox) +static inline BoxType clip_box(const BoxType * box, const BoxType * clipbox) { - BoxType r; - assert (box_intersect (box, clipbox)); - r.X1 = MAX (box->X1, clipbox->X1); - r.X2 = MIN (box->X2, clipbox->X2); - r.Y1 = MAX (box->Y1, clipbox->Y1); - r.Y2 = MIN (box->Y2, clipbox->Y2); - assert (box_in_box (clipbox, &r)); - return r; + BoxType r; + assert(box_intersect(box, clipbox)); + r.X1 = MAX(box->X1, clipbox->X1); + r.X2 = MIN(box->X2, clipbox->X2); + r.Y1 = MAX(box->Y1, clipbox->Y1); + r.Y2 = MIN(box->Y2, clipbox->Y2); + assert(box_in_box(clipbox, &r)); + return r; } -static inline BoxType -shrink_box (const BoxType * box, Coord amount) +static inline BoxType shrink_box(const BoxType * box, Coord amount) { - BoxType r = *box; - r.X1 += amount; - r.Y1 += amount; - r.X2 -= amount; - r.Y2 -= amount; - return r; + BoxType r = *box; + r.X1 += amount; + r.Y1 += amount; + r.X2 -= amount; + r.Y2 -= amount; + return r; } -static inline BoxType -bloat_box (const BoxType * box, Coord amount) +static inline BoxType bloat_box(const BoxType * box, Coord amount) { - return shrink_box (box, -amount); + return shrink_box(box, -amount); } /* construct a minimum box that touches the input box at the center */ -static inline BoxType -box_center (const BoxType * box) +static inline BoxType box_center(const BoxType * box) { - BoxType r; - r.X1 = box->X1 + (box->X2 - box->X1)/2; - r.X2 = r.X1 + 1; - r.Y1 = box->Y1 + (box->Y2 - box->Y1)/2; - r.Y2 = r.Y1 + 1; - return r; + BoxType r; + r.X1 = box->X1 + (box->X2 - box->X1) / 2; + r.X2 = r.X1 + 1; + r.Y1 = box->Y1 + (box->Y2 - box->Y1) / 2; + r.Y2 = r.Y1 + 1; + return r; } /* construct a minimum box that touches the input box at the corner */ -static inline BoxType -box_corner (const BoxType * box) +static inline BoxType box_corner(const BoxType * box) { - BoxType r; - r.X1 = box->X1; - r.X2 = r.X1 + 1; - r.Y1 = box->Y1; - r.Y2 = r.Y1 + 1; - return r; + BoxType r; + r.X1 = box->X1; + r.X2 = r.X1 + 1; + r.Y1 = box->Y1; + r.Y2 = r.Y1 + 1; + return r; } /* construct a box that holds a single point */ -static inline BoxType -point_box (Coord X, Coord Y) +static inline BoxType point_box(Coord X, Coord Y) { - BoxType r; - r.X1 = X; - r.X2 = X + 1; - r.Y1 = Y; - r.Y2 = Y + 1; - return r; + BoxType r; + r.X1 = X; + r.X2 = X + 1; + r.Y1 = Y; + r.Y2 = Y + 1; + return r; } /* close a bounding box by pushing its upper right corner */ -static inline void -close_box (BoxType * r) +static inline void close_box(BoxType * r) { - r->X2++; - r->Y2++; + r->X2++; + r->Y2++; } /* return the square of the minimum distance from a point to some point * inside a box. The box is half-closed! That is, the top-left corner * is considered in the box, but the bottom-right corner is not. */ -static inline double -dist2_to_box (const CheapPointType * p, const BoxType * b) +static inline double dist2_to_box(const CheapPointType * p, const BoxType * b) { - CheapPointType r = closest_point_in_box (p, b); - return Distance (r.X, r.Y, p->X, p->Y); + CheapPointType r = closest_point_in_box(p, b); + return Distance(r.X, r.Y, p->X, p->Y); } #endif /* __BOX_H_INCLUDED__ */ Index: trunk/src/buffer.c =================================================================== --- trunk/src/buffer.c (revision 1021) +++ trunk/src/buffer.c (revision 1022) @@ -60,26 +60,26 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); /* --------------------------------------------------------------------------- * some local prototypes */ -static void *AddViaToBuffer (PinTypePtr); -static void *AddLineToBuffer (LayerTypePtr, LineTypePtr); -static void *AddArcToBuffer (LayerTypePtr, ArcTypePtr); -static void *AddRatToBuffer (RatTypePtr); -static void *AddTextToBuffer (LayerTypePtr, TextTypePtr); -static void *AddPolygonToBuffer (LayerTypePtr, PolygonTypePtr); -static void *AddElementToBuffer (ElementTypePtr); -static void *MoveViaToBuffer (PinTypePtr); -static void *MoveLineToBuffer (LayerTypePtr, LineTypePtr); -static void *MoveArcToBuffer (LayerTypePtr, ArcTypePtr); -static void *MoveRatToBuffer (RatTypePtr); -static void *MoveTextToBuffer (LayerTypePtr, TextTypePtr); -static void *MovePolygonToBuffer (LayerTypePtr, PolygonTypePtr); -static void *MoveElementToBuffer (ElementTypePtr); -static void SwapBuffer (BufferTypePtr); +static void *AddViaToBuffer(PinTypePtr); +static void *AddLineToBuffer(LayerTypePtr, LineTypePtr); +static void *AddArcToBuffer(LayerTypePtr, ArcTypePtr); +static void *AddRatToBuffer(RatTypePtr); +static void *AddTextToBuffer(LayerTypePtr, TextTypePtr); +static void *AddPolygonToBuffer(LayerTypePtr, PolygonTypePtr); +static void *AddElementToBuffer(ElementTypePtr); +static void *MoveViaToBuffer(PinTypePtr); +static void *MoveLineToBuffer(LayerTypePtr, LineTypePtr); +static void *MoveArcToBuffer(LayerTypePtr, ArcTypePtr); +static void *MoveRatToBuffer(RatTypePtr); +static void *MoveTextToBuffer(LayerTypePtr, TextTypePtr); +static void *MovePolygonToBuffer(LayerTypePtr, PolygonTypePtr); +static void *MoveElementToBuffer(ElementTypePtr); +static void SwapBuffer(BufferTypePtr); #define ARG(n) (argc > (n) ? argv[n] : 0) @@ -89,27 +89,22 @@ static DataTypePtr Dest, Source; static ObjectFunctionType AddBufferFunctions = { - AddLineToBuffer, - AddTextToBuffer, - AddPolygonToBuffer, - AddViaToBuffer, - AddElementToBuffer, - NULL, - NULL, - NULL, - NULL, - NULL, - AddArcToBuffer, - AddRatToBuffer -}, MoveBufferFunctions = - -{ + AddLineToBuffer, + AddTextToBuffer, + AddPolygonToBuffer, + AddViaToBuffer, + AddElementToBuffer, + NULL, + NULL, + NULL, + NULL, + NULL, + AddArcToBuffer, + AddRatToBuffer +}, MoveBufferFunctions = { MoveLineToBuffer, - MoveTextToBuffer, - MovePolygonToBuffer, - MoveViaToBuffer, - MoveElementToBuffer, - NULL, NULL, NULL, NULL, NULL, MoveArcToBuffer, MoveRatToBuffer}; + MoveTextToBuffer, + MovePolygonToBuffer, MoveViaToBuffer, MoveElementToBuffer, NULL, NULL, NULL, NULL, NULL, MoveArcToBuffer, MoveRatToBuffer}; static int ExtraFlag = 0; @@ -116,339 +111,314 @@ /* --------------------------------------------------------------------------- * copies a via to paste buffer */ -static void * -AddViaToBuffer (PinTypePtr Via) +static void *AddViaToBuffer(PinTypePtr Via) { - return (CreateNewVia (Dest, Via->X, Via->Y, Via->Thickness, Via->Clearance, - Via->Mask, Via->DrillingHole, Via->Name, - MaskFlags (Via->Flags, FOUNDFLAG | ExtraFlag))); + return (CreateNewVia(Dest, Via->X, Via->Y, Via->Thickness, Via->Clearance, + Via->Mask, Via->DrillingHole, Via->Name, MaskFlags(Via->Flags, FOUNDFLAG | ExtraFlag))); } /* --------------------------------------------------------------------------- * copies a rat-line to paste buffer */ -static void * -AddRatToBuffer (RatTypePtr Rat) +static void *AddRatToBuffer(RatTypePtr Rat) { - return (CreateNewRat (Dest, Rat->Point1.X, Rat->Point1.Y, - Rat->Point2.X, Rat->Point2.Y, Rat->group1, - Rat->group2, Rat->Thickness, - MaskFlags (Rat->Flags, FOUNDFLAG | ExtraFlag))); + return (CreateNewRat(Dest, Rat->Point1.X, Rat->Point1.Y, + Rat->Point2.X, Rat->Point2.Y, Rat->group1, + Rat->group2, Rat->Thickness, MaskFlags(Rat->Flags, FOUNDFLAG | ExtraFlag))); } /* --------------------------------------------------------------------------- * copies a line to buffer */ -static void * -AddLineToBuffer (LayerTypePtr Layer, LineTypePtr Line) +static void *AddLineToBuffer(LayerTypePtr Layer, LineTypePtr Line) { - LineTypePtr line; - LayerTypePtr layer = &Dest->Layer[GetLayerNumber (Source, Layer)]; + LineTypePtr line; + LayerTypePtr layer = &Dest->Layer[GetLayerNumber(Source, Layer)]; - line = CreateNewLineOnLayer (layer, Line->Point1.X, Line->Point1.Y, - Line->Point2.X, Line->Point2.Y, - Line->Thickness, Line->Clearance, - MaskFlags (Line->Flags, - FOUNDFLAG | ExtraFlag)); - if (line && Line->Number) - line->Number = strdup (Line->Number); - return (line); + line = CreateNewLineOnLayer(layer, Line->Point1.X, Line->Point1.Y, + Line->Point2.X, Line->Point2.Y, + Line->Thickness, Line->Clearance, MaskFlags(Line->Flags, FOUNDFLAG | ExtraFlag)); + if (line && Line->Number) + line->Number = strdup(Line->Number); + return (line); } /* --------------------------------------------------------------------------- * copies an arc to buffer */ -static void * -AddArcToBuffer (LayerTypePtr Layer, ArcTypePtr Arc) +static void *AddArcToBuffer(LayerTypePtr Layer, ArcTypePtr Arc) { - LayerTypePtr layer = &Dest->Layer[GetLayerNumber (Source, Layer)]; + LayerTypePtr layer = &Dest->Layer[GetLayerNumber(Source, Layer)]; - return (CreateNewArcOnLayer (layer, Arc->X, Arc->Y, - Arc->Width, Arc->Height, Arc->StartAngle, Arc->Delta, - Arc->Thickness, Arc->Clearance, - MaskFlags (Arc->Flags, - FOUNDFLAG | ExtraFlag))); + return (CreateNewArcOnLayer(layer, Arc->X, Arc->Y, + Arc->Width, Arc->Height, Arc->StartAngle, Arc->Delta, + Arc->Thickness, Arc->Clearance, MaskFlags(Arc->Flags, FOUNDFLAG | ExtraFlag))); } /* --------------------------------------------------------------------------- * copies a text to buffer */ -static void * -AddTextToBuffer (LayerTypePtr Layer, TextTypePtr Text) +static void *AddTextToBuffer(LayerTypePtr Layer, TextTypePtr Text) { - LayerTypePtr layer = &Dest->Layer[GetLayerNumber (Source, Layer)]; + LayerTypePtr layer = &Dest->Layer[GetLayerNumber(Source, Layer)]; - return (CreateNewText (layer, &PCB->Font, Text->X, Text->Y, - Text->Direction, Text->Scale, Text->TextString, - MaskFlags (Text->Flags, ExtraFlag))); + return (CreateNewText(layer, &PCB->Font, Text->X, Text->Y, + Text->Direction, Text->Scale, Text->TextString, MaskFlags(Text->Flags, ExtraFlag))); } /* --------------------------------------------------------------------------- * copies a polygon to buffer */ -static void * -AddPolygonToBuffer (LayerTypePtr Layer, PolygonTypePtr Polygon) +static void *AddPolygonToBuffer(LayerTypePtr Layer, PolygonTypePtr Polygon) { - LayerTypePtr layer = &Dest->Layer[GetLayerNumber (Source, Layer)]; - PolygonTypePtr polygon; + LayerTypePtr layer = &Dest->Layer[GetLayerNumber(Source, Layer)]; + PolygonTypePtr polygon; - polygon = CreateNewPolygon (layer, Polygon->Flags); - CopyPolygonLowLevel (polygon, Polygon); + polygon = CreateNewPolygon(layer, Polygon->Flags); + CopyPolygonLowLevel(polygon, Polygon); - /* Update the polygon r-tree. Unlike similarly named functions for - * other objects, CreateNewPolygon does not do this as it creates a - * skeleton polygon object, which won't have correct bounds. - */ - if (!layer->polygon_tree) - layer->polygon_tree = r_create_tree (NULL, 0, 0); - r_insert_entry (layer->polygon_tree, (BoxType *)polygon, 0); + /* Update the polygon r-tree. Unlike similarly named functions for + * other objects, CreateNewPolygon does not do this as it creates a + * skeleton polygon object, which won't have correct bounds. + */ + if (!layer->polygon_tree) + layer->polygon_tree = r_create_tree(NULL, 0, 0); + r_insert_entry(layer->polygon_tree, (BoxType *) polygon, 0); - CLEAR_FLAG (FOUNDFLAG | ExtraFlag, polygon); - return (polygon); + CLEAR_FLAG(FOUNDFLAG | ExtraFlag, polygon); + return (polygon); } /* --------------------------------------------------------------------------- * copies a element to buffer */ -static void * -AddElementToBuffer (ElementTypePtr Element) +static void *AddElementToBuffer(ElementTypePtr Element) { - ElementTypePtr element; + ElementTypePtr element; - element = GetElementMemory (Dest); - CopyElementLowLevel (Dest, element, Element, false, 0, 0); - CLEAR_FLAG (ExtraFlag, element); - if (ExtraFlag) - { - ELEMENTTEXT_LOOP (element); - { - CLEAR_FLAG (ExtraFlag, text); - } - END_LOOP; - PIN_LOOP (element); - { - CLEAR_FLAG (FOUNDFLAG | ExtraFlag, pin); - } - END_LOOP; - PAD_LOOP (element); - { - CLEAR_FLAG (FOUNDFLAG | ExtraFlag, pad); - } - END_LOOP; - } - return (element); + element = GetElementMemory(Dest); + CopyElementLowLevel(Dest, element, Element, false, 0, 0); + CLEAR_FLAG(ExtraFlag, element); + if (ExtraFlag) { + ELEMENTTEXT_LOOP(element); + { + CLEAR_FLAG(ExtraFlag, text); + } + END_LOOP; + PIN_LOOP(element); + { + CLEAR_FLAG(FOUNDFLAG | ExtraFlag, pin); + } + END_LOOP; + PAD_LOOP(element); + { + CLEAR_FLAG(FOUNDFLAG | ExtraFlag, pad); + } + END_LOOP; + } + return (element); } /* --------------------------------------------------------------------------- * moves a via to paste buffer without allocating memory for the name */ -static void * -MoveViaToBuffer (PinType *via) +static void *MoveViaToBuffer(PinType * via) { - RestoreToPolygon (Source, VIA_TYPE, via, via); + RestoreToPolygon(Source, VIA_TYPE, via, via); - r_delete_entry (Source->via_tree, (BoxType *) via); - Source->Via = g_list_remove (Source->Via, via); - Source->ViaN --; - Dest->Via = g_list_append (Dest->Via, via); - Dest->ViaN ++; + r_delete_entry(Source->via_tree, (BoxType *) via); + Source->Via = g_list_remove(Source->Via, via); + Source->ViaN--; + Dest->Via = g_list_append(Dest->Via, via); + Dest->ViaN++; - CLEAR_FLAG (WARNFLAG | FOUNDFLAG, via); + CLEAR_FLAG(WARNFLAG | FOUNDFLAG, via); - if (!Dest->via_tree) - Dest->via_tree = r_create_tree (NULL, 0, 0); - r_insert_entry (Dest->via_tree, (BoxType *)via, 0); - ClearFromPolygon (Dest, VIA_TYPE, via, via); - return via; + if (!Dest->via_tree) + Dest->via_tree = r_create_tree(NULL, 0, 0); + r_insert_entry(Dest->via_tree, (BoxType *) via, 0); + ClearFromPolygon(Dest, VIA_TYPE, via, via); + return via; } /* --------------------------------------------------------------------------- * moves a rat-line to paste buffer */ -static void * -MoveRatToBuffer (RatType *rat) +static void *MoveRatToBuffer(RatType * rat) { - r_delete_entry (Source->rat_tree, (BoxType *)rat); + r_delete_entry(Source->rat_tree, (BoxType *) rat); - Source->Rat = g_list_remove (Source->Rat, rat); - Source->RatN --; - Dest->Rat = g_list_append (Dest->Rat, rat); - Dest->RatN ++; + Source->Rat = g_list_remove(Source->Rat, rat); + Source->RatN--; + Dest->Rat = g_list_append(Dest->Rat, rat); + Dest->RatN++; - CLEAR_FLAG (FOUNDFLAG, rat); + CLEAR_FLAG(FOUNDFLAG, rat); - if (!Dest->rat_tree) - Dest->rat_tree = r_create_tree (NULL, 0, 0); - r_insert_entry (Dest->rat_tree, (BoxType *)rat, 0); - return rat; + if (!Dest->rat_tree) + Dest->rat_tree = r_create_tree(NULL, 0, 0); + r_insert_entry(Dest->rat_tree, (BoxType *) rat, 0); + return rat; } /* --------------------------------------------------------------------------- * moves a line to buffer */ -static void * -MoveLineToBuffer (LayerType *layer, LineType *line) +static void *MoveLineToBuffer(LayerType * layer, LineType * line) { - LayerTypePtr lay = &Dest->Layer[GetLayerNumber (Source, layer)]; + LayerTypePtr lay = &Dest->Layer[GetLayerNumber(Source, layer)]; - RestoreToPolygon (Source, LINE_TYPE, layer, line); - r_delete_entry (layer->line_tree, (BoxType *)line); + RestoreToPolygon(Source, LINE_TYPE, layer, line); + r_delete_entry(layer->line_tree, (BoxType *) line); - layer->Line = g_list_remove (layer->Line, line); - layer->LineN --; - lay->Line = g_list_append (lay->Line, line); - lay->LineN ++; + layer->Line = g_list_remove(layer->Line, line); + layer->LineN--; + lay->Line = g_list_append(lay->Line, line); + lay->LineN++; - CLEAR_FLAG (FOUNDFLAG, line); + CLEAR_FLAG(FOUNDFLAG, line); - if (!lay->line_tree) - lay->line_tree = r_create_tree (NULL, 0, 0); - r_insert_entry (lay->line_tree, (BoxType *)line, 0); - ClearFromPolygon (Dest, LINE_TYPE, lay, line); - return (line); + if (!lay->line_tree) + lay->line_tree = r_create_tree(NULL, 0, 0); + r_insert_entry(lay->line_tree, (BoxType *) line, 0); + ClearFromPolygon(Dest, LINE_TYPE, lay, line); + return (line); } /* --------------------------------------------------------------------------- * moves an arc to buffer */ -static void * -MoveArcToBuffer (LayerType *layer, ArcType *arc) +static void *MoveArcToBuffer(LayerType * layer, ArcType * arc) { - LayerType *lay = &Dest->Layer[GetLayerNumber (Source, layer)]; + LayerType *lay = &Dest->Layer[GetLayerNumber(Source, layer)]; - RestoreToPolygon (Source, ARC_TYPE, layer, arc); - r_delete_entry (layer->arc_tree, (BoxType *)arc); + RestoreToPolygon(Source, ARC_TYPE, layer, arc); + r_delete_entry(layer->arc_tree, (BoxType *) arc); - layer->Arc = g_list_remove (layer->Arc, arc); - layer->ArcN --; - lay->Arc = g_list_append (lay->Arc, arc); - lay->ArcN ++; + layer->Arc = g_list_remove(layer->Arc, arc); + layer->ArcN--; + lay->Arc = g_list_append(lay->Arc, arc); + lay->ArcN++; - CLEAR_FLAG (FOUNDFLAG, arc); + CLEAR_FLAG(FOUNDFLAG, arc); - if (!lay->arc_tree) - lay->arc_tree = r_create_tree (NULL, 0, 0); - r_insert_entry (lay->arc_tree, (BoxType *)arc, 0); - ClearFromPolygon (Dest, ARC_TYPE, lay, arc); - return (arc); + if (!lay->arc_tree) + lay->arc_tree = r_create_tree(NULL, 0, 0); + r_insert_entry(lay->arc_tree, (BoxType *) arc, 0); + ClearFromPolygon(Dest, ARC_TYPE, lay, arc); + return (arc); } /* --------------------------------------------------------------------------- * moves a text to buffer without allocating memory for the name */ -static void * -MoveTextToBuffer (LayerType *layer, TextType *text) +static void *MoveTextToBuffer(LayerType * layer, TextType * text) { - LayerType *lay = &Dest->Layer[GetLayerNumber (Source, layer)]; + LayerType *lay = &Dest->Layer[GetLayerNumber(Source, layer)]; - r_delete_entry (layer->text_tree, (BoxType *)text); - RestoreToPolygon (Source, TEXT_TYPE, layer, text); + r_delete_entry(layer->text_tree, (BoxType *) text); + RestoreToPolygon(Source, TEXT_TYPE, layer, text); - layer->Text = g_list_remove (layer->Text, text); - layer->TextN --; - lay->Text = g_list_append (lay->Text, text); - lay->TextN ++; + layer->Text = g_list_remove(layer->Text, text); + layer->TextN--; + lay->Text = g_list_append(lay->Text, text); + lay->TextN++; - if (!lay->text_tree) - lay->text_tree = r_create_tree (NULL, 0, 0); - r_insert_entry (lay->text_tree, (BoxType *)text, 0); - ClearFromPolygon (Dest, TEXT_TYPE, lay, text); - return (text); + if (!lay->text_tree) + lay->text_tree = r_create_tree(NULL, 0, 0); + r_insert_entry(lay->text_tree, (BoxType *) text, 0); + ClearFromPolygon(Dest, TEXT_TYPE, lay, text); + return (text); } /* --------------------------------------------------------------------------- * moves a polygon to buffer. Doesn't allocate memory for the points */ -static void * -MovePolygonToBuffer (LayerType *layer, PolygonType *polygon) +static void *MovePolygonToBuffer(LayerType * layer, PolygonType * polygon) { - LayerType *lay = &Dest->Layer[GetLayerNumber (Source, layer)]; + LayerType *lay = &Dest->Layer[GetLayerNumber(Source, layer)]; - r_delete_entry (layer->polygon_tree, (BoxType *)polygon); + r_delete_entry(layer->polygon_tree, (BoxType *) polygon); - layer->Polygon = g_list_remove (layer->Polygon, polygon); - layer->PolygonN --; - lay->Polygon = g_list_append (lay->Polygon, polygon); - lay->PolygonN ++; + layer->Polygon = g_list_remove(layer->Polygon, polygon); + layer->PolygonN--; + lay->Polygon = g_list_append(lay->Polygon, polygon); + lay->PolygonN++; - CLEAR_FLAG (FOUNDFLAG, polygon); + CLEAR_FLAG(FOUNDFLAG, polygon); - if (!lay->polygon_tree) - lay->polygon_tree = r_create_tree (NULL, 0, 0); - r_insert_entry (lay->polygon_tree, (BoxType *)polygon, 0); - return (polygon); + if (!lay->polygon_tree) + lay->polygon_tree = r_create_tree(NULL, 0, 0); + r_insert_entry(lay->polygon_tree, (BoxType *) polygon, 0); + return (polygon); } /* --------------------------------------------------------------------------- * moves a element to buffer without allocating memory for pins/names */ -static void * -MoveElementToBuffer (ElementType *element) +static void *MoveElementToBuffer(ElementType * element) { - /* - * Delete the element from the source (remove it from trees, - * restore to polygons) - */ - r_delete_element (Source, element); + /* + * Delete the element from the source (remove it from trees, + * restore to polygons) + */ + r_delete_element(Source, element); - Source->Element = g_list_remove (Source->Element, element); - Source->ElementN --; - Dest->Element = g_list_append (Dest->Element, element); - Dest->ElementN ++; + Source->Element = g_list_remove(Source->Element, element); + Source->ElementN--; + Dest->Element = g_list_append(Dest->Element, element); + Dest->ElementN++; - PIN_LOOP (element); - { - RestoreToPolygon(Source, PIN_TYPE, element, pin); - CLEAR_FLAG (WARNFLAG | FOUNDFLAG, pin); - } - END_LOOP; - PAD_LOOP (element); - { - RestoreToPolygon(Source, PAD_TYPE, element, pad); - CLEAR_FLAG (WARNFLAG | FOUNDFLAG, pad); - } - END_LOOP; - SetElementBoundingBox (Dest, element, &PCB->Font); - /* - * Now clear the from the polygons in the destination - */ - PIN_LOOP (element); - { - ClearFromPolygon (Dest, PIN_TYPE, element, pin); - } - END_LOOP; - PAD_LOOP (element); - { - ClearFromPolygon (Dest, PAD_TYPE, element, pad); - } - END_LOOP; + PIN_LOOP(element); + { + RestoreToPolygon(Source, PIN_TYPE, element, pin); + CLEAR_FLAG(WARNFLAG | FOUNDFLAG, pin); + } + END_LOOP; + PAD_LOOP(element); + { + RestoreToPolygon(Source, PAD_TYPE, element, pad); + CLEAR_FLAG(WARNFLAG | FOUNDFLAG, pad); + } + END_LOOP; + SetElementBoundingBox(Dest, element, &PCB->Font); + /* + * Now clear the from the polygons in the destination + */ + PIN_LOOP(element); + { + ClearFromPolygon(Dest, PIN_TYPE, element, pin); + } + END_LOOP; + PAD_LOOP(element); + { + ClearFromPolygon(Dest, PAD_TYPE, element, pad); + } + END_LOOP; - return element; + return element; } /* --------------------------------------------------------------------------- * calculates the bounding box of the buffer */ -void -SetBufferBoundingBox (BufferTypePtr Buffer) +void SetBufferBoundingBox(BufferTypePtr Buffer) { - BoxTypePtr box = GetDataBoundingBox (Buffer->Data); + BoxTypePtr box = GetDataBoundingBox(Buffer->Data); - if (box) - Buffer->BoundingBox = *box; + if (box) + Buffer->BoundingBox = *box; } /* --------------------------------------------------------------------------- * clears the contents of the paste buffer */ -void -ClearBuffer (BufferTypePtr Buffer) +void ClearBuffer(BufferTypePtr Buffer) { - if (Buffer && Buffer->Data) - { - FreeDataMemory (Buffer->Data); - Buffer->Data->pcb = PCB; - } + if (Buffer && Buffer->Data) { + FreeDataMemory(Buffer->Data); + Buffer->Data->pcb = PCB; + } } /* ---------------------------------------------------------------------- @@ -455,32 +425,29 @@ * copies all selected and visible objects to the paste buffer * returns true if any objects have been removed */ -void -AddSelectedToBuffer (BufferTypePtr Buffer, Coord X, Coord Y, bool LeaveSelected) +void AddSelectedToBuffer(BufferTypePtr Buffer, Coord X, Coord Y, bool LeaveSelected) { - /* switch crosshair off because adding objects to the pastebuffer - * may change the 'valid' area for the cursor - */ - if (!LeaveSelected) - ExtraFlag = SELECTEDFLAG; - notify_crosshair_change (false); - Source = PCB->Data; - Dest = Buffer->Data; - SelectedOperation (&AddBufferFunctions, false, ALL_TYPES); + /* switch crosshair off because adding objects to the pastebuffer + * may change the 'valid' area for the cursor + */ + if (!LeaveSelected) + ExtraFlag = SELECTEDFLAG; + notify_crosshair_change(false); + Source = PCB->Data; + Dest = Buffer->Data; + SelectedOperation(&AddBufferFunctions, false, ALL_TYPES); - /* set origin to passed or current position */ - if (X || Y) - { - Buffer->X = X; - Buffer->Y = Y; - } - else - { - Buffer->X = Crosshair.X; - Buffer->Y = Crosshair.Y; - } - notify_crosshair_change (true); - ExtraFlag = 0; + /* set origin to passed or current position */ + if (X || Y) { + Buffer->X = X; + Buffer->Y = Y; + } + else { + Buffer->X = Crosshair.X; + Buffer->Y = Crosshair.Y; + } + notify_crosshair_change(true); + ExtraFlag = 0; } /* --------------------------------------------------------------------------- @@ -489,34 +456,30 @@ * returns false on error * if successful, update some other stuff and reposition the pastebuffer */ -bool -LoadElementToBuffer (BufferTypePtr Buffer, const char *Name) +bool LoadElementToBuffer(BufferTypePtr Buffer, const char *Name) { - ElementTypePtr element; + ElementTypePtr element; - ClearBuffer (Buffer); - if (!ParseElement (Buffer->Data, Name)) - { - if (Settings.ShowSolderSide) - SwapBuffer (Buffer); - SetBufferBoundingBox (Buffer); - if (Buffer->Data->ElementN) - { - element = Buffer->Data->Element->data; - Buffer->X = element->MarkX; - Buffer->Y = element->MarkY; - } - else - { - Buffer->X = 0; - Buffer->Y = 0; - } - return (true); + ClearBuffer(Buffer); + if (!ParseElement(Buffer->Data, Name)) { + if (Settings.ShowSolderSide) + SwapBuffer(Buffer); + SetBufferBoundingBox(Buffer); + if (Buffer->Data->ElementN) { + element = Buffer->Data->Element->data; + Buffer->X = element->MarkX; + Buffer->Y = element->MarkY; + } + else { + Buffer->X = 0; + Buffer->Y = 0; + } + return (true); } - /* release memory which might have been acquired */ - ClearBuffer (Buffer); - return (false); + /* release memory which might have been acquired */ + ClearBuffer(Buffer); + return (false); } @@ -526,10 +489,9 @@ */ /* Returns zero on success, non-zero on error. */ -int -LoadFootprintByName (BufferTypePtr Buffer, char *Footprint) +int LoadFootprintByName(BufferTypePtr Buffer, char *Footprint) { - return !LoadElementToBuffer (Buffer, Footprint); + return !LoadElementToBuffer(Buffer, Footprint); } @@ -545,46 +507,43 @@ %end-doc */ -int -LoadFootprint (int argc, char **argv, Coord x, Coord y) +int LoadFootprint(int argc, char **argv, Coord x, Coord y) { - char *name = ARG(0); - char *refdes = ARG(1); - char *value = ARG(2); - ElementTypePtr e; + char *name = ARG(0); + char *refdes = ARG(1); + char *value = ARG(2); + ElementTypePtr e; - if (!name) - AFAIL (loadfootprint); + if (!name) + AFAIL(loadfootprint); - if (LoadFootprintByName (PASTEBUFFER, name)) - return 1; + if (LoadFootprintByName(PASTEBUFFER, name)) + return 1; - if (PASTEBUFFER->Data->ElementN == 0) - { - Message("Footprint %s contains no elements", name); - return 1; - } - if (PASTEBUFFER->Data->ElementN > 1) - { - Message("Footprint %s contains multiple elements", name); - return 1; - } + if (PASTEBUFFER->Data->ElementN == 0) { + Message("Footprint %s contains no elements", name); + return 1; + } + if (PASTEBUFFER->Data->ElementN > 1) { + Message("Footprint %s contains multiple elements", name); + return 1; + } - e = PASTEBUFFER->Data->Element->data; + e = PASTEBUFFER->Data->Element->data; - if (e->Name[0].TextString) - free (e->Name[0].TextString); - e->Name[0].TextString = strdup (name); + if (e->Name[0].TextString) + free(e->Name[0].TextString); + e->Name[0].TextString = strdup(name); - if (e->Name[1].TextString) - free (e->Name[1].TextString); - e->Name[1].TextString = refdes ? strdup (refdes) : 0; + if (e->Name[1].TextString) + free(e->Name[1].TextString); + e->Name[1].TextString = refdes ? strdup(refdes) : 0; - if (e->Name[2].TextString) - free (e->Name[2].TextString); - e->Name[2].TextString = value ? strdup (value) : 0; + if (e->Name[2].TextString) + free(e->Name[2].TextString); + e->Name[2].TextString = value ? strdup(value) : 0; - return 0; + return 0; } /*--------------------------------------------------------------------------- @@ -591,82 +550,70 @@ * * break buffer element into pieces */ -bool -SmashBufferElement (BufferTypePtr Buffer) +bool SmashBufferElement(BufferTypePtr Buffer) { - ElementTypePtr element; - Cardinal group; - LayerTypePtr clayer, slayer; + ElementTypePtr element; + Cardinal group; + LayerTypePtr clayer, slayer; - if (Buffer->Data->ElementN != 1) - { - Message (_("Error! Buffer doesn't contain a single element\n")); - return (false); - } - /* - * At this point the buffer should contain just a single element. - * Now we detach the single element from the buffer and then clear the - * buffer, ready to receive the smashed elements. As a result of detaching - * it the single element is orphaned from the buffer and thus will not be - * free()'d by FreeDataMemory (called via ClearBuffer). This leaves it - * around for us to smash bits off it. It then becomes our responsibility, - * however, to free the single element when we're finished with it. - */ - element = Buffer->Data->Element->data; - Buffer->Data->Element = NULL; - Buffer->Data->ElementN = 0; - ClearBuffer (Buffer); - ELEMENTLINE_LOOP (element); - { - CreateNewLineOnLayer (&Buffer->Data->SILKLAYER, - line->Point1.X, line->Point1.Y, - line->Point2.X, line->Point2.Y, - line->Thickness, 0, NoFlags ()); - if (line) - line->Number = STRDUP (NAMEONPCB_NAME (element)); - } - END_LOOP; - ARC_LOOP (element); - { - CreateNewArcOnLayer (&Buffer->Data->SILKLAYER, - arc->X, arc->Y, arc->Width, arc->Height, arc->StartAngle, - arc->Delta, arc->Thickness, 0, NoFlags ()); - } - END_LOOP; - PIN_LOOP (element); - { - FlagType f = NoFlags (); - AddFlags (f, VIAFLAG); - if (TEST_FLAG (HOLEFLAG, pin)) - AddFlags (f, HOLEFLAG); + if (Buffer->Data->ElementN != 1) { + Message(_("Error! Buffer doesn't contain a single element\n")); + return (false); + } + /* + * At this point the buffer should contain just a single element. + * Now we detach the single element from the buffer and then clear the + * buffer, ready to receive the smashed elements. As a result of detaching + * it the single element is orphaned from the buffer and thus will not be + * free()'d by FreeDataMemory (called via ClearBuffer). This leaves it + * around for us to smash bits off it. It then becomes our responsibility, + * however, to free the single element when we're finished with it. + */ + element = Buffer->Data->Element->data; + Buffer->Data->Element = NULL; + Buffer->Data->ElementN = 0; + ClearBuffer(Buffer); + ELEMENTLINE_LOOP(element); + { + CreateNewLineOnLayer(&Buffer->Data->SILKLAYER, + line->Point1.X, line->Point1.Y, line->Point2.X, line->Point2.Y, line->Thickness, 0, NoFlags()); + if (line) + line->Number = STRDUP(NAMEONPCB_NAME(element)); + } + END_LOOP; + ARC_LOOP(element); + { + CreateNewArcOnLayer(&Buffer->Data->SILKLAYER, + arc->X, arc->Y, arc->Width, arc->Height, arc->StartAngle, arc->Delta, arc->Thickness, 0, NoFlags()); + } + END_LOOP; + PIN_LOOP(element); + { + FlagType f = NoFlags(); + AddFlags(f, VIAFLAG); + if (TEST_FLAG(HOLEFLAG, pin)) + AddFlags(f, HOLEFLAG); - CreateNewVia (Buffer->Data, pin->X, pin->Y, - pin->Thickness, pin->Clearance, pin->Mask, - pin->DrillingHole, pin->Number, f); - } - END_LOOP; - group = - GetLayerGroupNumberByNumber (SWAP_IDENT ? solder_silk_layer : - component_silk_layer); - clayer = &Buffer->Data->Layer[PCB->LayerGroups.Entries[group][0]]; - group = - GetLayerGroupNumberByNumber (SWAP_IDENT ? component_silk_layer : - solder_silk_layer); - slayer = &Buffer->Data->Layer[PCB->LayerGroups.Entries[group][0]]; - PAD_LOOP (element); - { - LineTypePtr line; - line = CreateNewLineOnLayer (TEST_FLAG (ONSOLDERFLAG, pad) ? slayer : clayer, - pad->Point1.X, pad->Point1.Y, - pad->Point2.X, pad->Point2.Y, - pad->Thickness, pad->Clearance, NoFlags ()); - if (line) - line->Number = STRDUP (pad->Number); - } - END_LOOP; - FreeElementMemory (element); - g_slice_free (ElementType, element); - return (true); + CreateNewVia(Buffer->Data, pin->X, pin->Y, pin->Thickness, pin->Clearance, pin->Mask, pin->DrillingHole, pin->Number, f); + } + END_LOOP; + group = GetLayerGroupNumberByNumber(SWAP_IDENT ? solder_silk_layer : component_silk_layer); + clayer = &Buffer->Data->Layer[PCB->LayerGroups.Entries[group][0]]; + group = GetLayerGroupNumberByNumber(SWAP_IDENT ? component_silk_layer : solder_silk_layer); + slayer = &Buffer->Data->Layer[PCB->LayerGroups.Entries[group][0]]; + PAD_LOOP(element); + { + LineTypePtr line; + line = CreateNewLineOnLayer(TEST_FLAG(ONSOLDERFLAG, pad) ? slayer : clayer, + pad->Point1.X, pad->Point1.Y, + pad->Point2.X, pad->Point2.Y, pad->Thickness, pad->Clearance, NoFlags()); + if (line) + line->Number = STRDUP(pad->Number); + } + END_LOOP; + FreeElementMemory(element); + g_slice_free(ElementType, element); + return (true); } /*--------------------------------------------------------------------------- @@ -674,36 +621,32 @@ * see if a polygon is a rectangle. If so, canonicalize it. */ -static int -polygon_is_rectangle (PolygonTypePtr poly) +static int polygon_is_rectangle(PolygonTypePtr poly) { - int i, best; - PointType temp[4]; - if (poly->PointN != 4 || poly->HoleIndexN != 0) - return 0; - best = 0; - for (i=1; i<4; i++) - if (poly->Points[i].X < poly->Points[best].X - || poly->Points[i].Y < poly->Points[best].Y) - best = i; - for (i=0; i<4; i++) - temp[i] = poly->Points[(i+best)%4]; - if (temp[0].X == temp[1].X) - memcpy (poly->Points, temp, sizeof(temp)); - else - { - /* reverse them */ - poly->Points[0] = temp[0]; - poly->Points[1] = temp[3]; - poly->Points[2] = temp[2]; - poly->Points[3] = temp[1]; - } - if (poly->Points[0].X == poly->Points[1].X - && poly->Points[1].Y == poly->Points[2].Y - && poly->Points[2].X == poly->Points[3].X - && poly->Points[3].Y == poly->Points[0].Y) - return 1; - return 0; + int i, best; + PointType temp[4]; + if (poly->PointN != 4 || poly->HoleIndexN != 0) + return 0; + best = 0; + for (i = 1; i < 4; i++) + if (poly->Points[i].X < poly->Points[best].X || poly->Points[i].Y < poly->Points[best].Y) + best = i; + for (i = 0; i < 4; i++) + temp[i] = poly->Points[(i + best) % 4]; + if (temp[0].X == temp[1].X) + memcpy(poly->Points, temp, sizeof(temp)); + else { + /* reverse them */ + poly->Points[0] = temp[0]; + poly->Points[1] = temp[3]; + poly->Points[2] = temp[2]; + poly->Points[3] = temp[1]; + } + if (poly->Points[0].X == poly->Points[1].X + && poly->Points[1].Y == poly->Points[2].Y + && poly->Points[2].X == poly->Points[3].X && poly->Points[3].Y == poly->Points[0].Y) + return 1; + return 0; } /*--------------------------------------------------------------------------- @@ -710,66 +653,55 @@ * * convert buffer contents into an element */ -bool -ConvertBufferToElement (BufferTypePtr Buffer) +bool ConvertBufferToElement(BufferTypePtr Buffer) { - ElementTypePtr Element; - Cardinal group; - Cardinal pin_n = 1; - bool hasParts = false, crooked = false; - int onsolder; - bool warned = false; + ElementTypePtr Element; + Cardinal group; + Cardinal pin_n = 1; + bool hasParts = false, crooked = false; + int onsolder; + bool warned = false; - if (Buffer->Data->pcb == 0) - Buffer->Data->pcb = PCB; + if (Buffer->Data->pcb == 0) + Buffer->Data->pcb = PCB; - Element = CreateNewElement (PCB->Data, NULL, &PCB->Font, NoFlags (), - NULL, NULL, NULL, PASTEBUFFER->X, - PASTEBUFFER->Y, 0, 100, - MakeFlags (SWAP_IDENT ? ONSOLDERFLAG : NOFLAG), - false); - if (!Element) - return (false); - VIA_LOOP (Buffer->Data); - { - char num[8]; - if (via->Mask < via->Thickness) - via->Mask = via->Thickness + 2 * MASKFRAME; - if (via->Name) - CreateNewPin (Element, via->X, via->Y, via->Thickness, - via->Clearance, via->Mask, via->DrillingHole, - NULL, via->Name, MaskFlags (via->Flags, - VIAFLAG | FOUNDFLAG | - SELECTEDFLAG | WARNFLAG)); - else - { - sprintf (num, "%d", pin_n++); - CreateNewPin (Element, via->X, via->Y, via->Thickness, - via->Clearance, via->Mask, via->DrillingHole, - NULL, num, MaskFlags (via->Flags, - VIAFLAG | FOUNDFLAG | SELECTEDFLAG - | WARNFLAG)); - } - hasParts = true; - } - END_LOOP; - - for (onsolder = 0; onsolder < 2; onsolder ++) - { - int silk_layer; - int onsolderflag; - - if ((!onsolder) == (!SWAP_IDENT)) + Element = CreateNewElement(PCB->Data, NULL, &PCB->Font, NoFlags(), + NULL, NULL, NULL, PASTEBUFFER->X, + PASTEBUFFER->Y, 0, 100, MakeFlags(SWAP_IDENT ? ONSOLDERFLAG : NOFLAG), false); + if (!Element) + return (false); + VIA_LOOP(Buffer->Data); { - silk_layer = component_silk_layer; - onsolderflag = NOFLAG; + char num[8]; + if (via->Mask < via->Thickness) + via->Mask = via->Thickness + 2 * MASKFRAME; + if (via->Name) + CreateNewPin(Element, via->X, via->Y, via->Thickness, + via->Clearance, via->Mask, via->DrillingHole, + NULL, via->Name, MaskFlags(via->Flags, VIAFLAG | FOUNDFLAG | SELECTEDFLAG | WARNFLAG)); + else { + sprintf(num, "%d", pin_n++); + CreateNewPin(Element, via->X, via->Y, via->Thickness, + via->Clearance, via->Mask, via->DrillingHole, + NULL, num, MaskFlags(via->Flags, VIAFLAG | FOUNDFLAG | SELECTEDFLAG | WARNFLAG)); + } + hasParts = true; } - else - { - silk_layer = solder_silk_layer; - onsolderflag = ONSOLDERFLAG; - } + END_LOOP; + for (onsolder = 0; onsolder < 2; onsolder++) { + int silk_layer; + int onsolderflag; + + if ((!onsolder) == (!SWAP_IDENT)) { + silk_layer = component_silk_layer; + onsolderflag = NOFLAG; + } + else { + silk_layer = solder_silk_layer; + onsolderflag = ONSOLDERFLAG; + } + #define MAYBE_WARN() \ if (onsolder && !hasParts && !warned) \ { \ @@ -780,97 +712,83 @@ "you wanted\n")); \ } \ - /* get the component-side SM pads */ - group = GetLayerGroupNumberByNumber (silk_layer); - GROUP_LOOP (Buffer->Data, group); - { - char num[8]; - LINE_LOOP (layer); + /* get the component-side SM pads */ + group = GetLayerGroupNumberByNumber(silk_layer); + GROUP_LOOP(Buffer->Data, group); + { + char num[8]; + LINE_LOOP(layer); + { + sprintf(num, "%d", pin_n++); + CreateNewPad(Element, line->Point1.X, + line->Point1.Y, line->Point2.X, + line->Point2.Y, line->Thickness, + line->Clearance, + line->Thickness + line->Clearance, NULL, line->Number ? line->Number : num, MakeFlags(onsolderflag)); + MAYBE_WARN(); + hasParts = true; + } + END_LOOP; + POLYGON_LOOP(layer); + { + Coord x1, y1, x2, y2, w, h, t; + + if (!polygon_is_rectangle(polygon)) { + crooked = true; + continue; + } + + w = polygon->Points[2].X - polygon->Points[0].X; + h = polygon->Points[1].Y - polygon->Points[0].Y; + t = (w < h) ? w : h; + x1 = polygon->Points[0].X + t / 2; + y1 = polygon->Points[0].Y + t / 2; + x2 = x1 + (w - t); + y2 = y1 + (h - t); + + sprintf(num, "%d", pin_n++); + CreateNewPad(Element, + x1, y1, x2, y2, t, + 2 * Settings.Keepaway, t + Settings.Keepaway, NULL, num, MakeFlags(SQUAREFLAG | onsolderflag)); + MAYBE_WARN(); + hasParts = true; + } + END_LOOP; + } + END_LOOP; + } + + /* now add the silkscreen. NOTE: elements must have pads or pins too */ + LINE_LOOP(&Buffer->Data->SILKLAYER); { - sprintf (num, "%d", pin_n++); - CreateNewPad (Element, line->Point1.X, - line->Point1.Y, line->Point2.X, - line->Point2.Y, line->Thickness, - line->Clearance, - line->Thickness + line->Clearance, NULL, - line->Number ? line->Number : num, - MakeFlags (onsolderflag)); - MAYBE_WARN(); - hasParts = true; + if (line->Number && !NAMEONPCB_NAME(Element)) + NAMEONPCB_NAME(Element) = strdup(line->Number); + CreateNewLineInElement(Element, line->Point1.X, line->Point1.Y, line->Point2.X, line->Point2.Y, line->Thickness); + hasParts = true; } END_LOOP; - POLYGON_LOOP (layer); + ARC_LOOP(&Buffer->Data->SILKLAYER); { - Coord x1, y1, x2, y2, w, h, t; - - if (! polygon_is_rectangle (polygon)) - { - crooked = true; - continue; - } - - w = polygon->Points[2].X - polygon->Points[0].X; - h = polygon->Points[1].Y - polygon->Points[0].Y; - t = (w < h) ? w : h; - x1 = polygon->Points[0].X + t/2; - y1 = polygon->Points[0].Y + t/2; - x2 = x1 + (w-t); - y2 = y1 + (h-t); - - sprintf (num, "%d", pin_n++); - CreateNewPad (Element, - x1, y1, x2, y2, t, - 2 * Settings.Keepaway, - t + Settings.Keepaway, - NULL, num, - MakeFlags (SQUAREFLAG | onsolderflag)); - MAYBE_WARN(); - hasParts = true; + CreateNewArcInElement(Element, arc->X, arc->Y, arc->Width, arc->Height, arc->StartAngle, arc->Delta, arc->Thickness); + hasParts = true; } END_LOOP; - } - END_LOOP; - } - - /* now add the silkscreen. NOTE: elements must have pads or pins too */ - LINE_LOOP (&Buffer->Data->SILKLAYER); - { - if (line->Number && !NAMEONPCB_NAME (Element)) - NAMEONPCB_NAME (Element) = strdup (line->Number); - CreateNewLineInElement (Element, line->Point1.X, - line->Point1.Y, line->Point2.X, - line->Point2.Y, line->Thickness); - hasParts = true; - } - END_LOOP; - ARC_LOOP (&Buffer->Data->SILKLAYER); - { - CreateNewArcInElement (Element, arc->X, arc->Y, arc->Width, - arc->Height, arc->StartAngle, arc->Delta, - arc->Thickness); - hasParts = true; - } - END_LOOP; - if (!hasParts) - { - DestroyObject (PCB->Data, ELEMENT_TYPE, Element, Element, Element); - Message (_("There was nothing to convert!\n" - "Elements must have some silk, pads or pins.\n")); - return (false); - } - if (crooked) - Message (_("There were polygons that can't be made into pins!\n" - "So they were not included in the element\n")); - Element->MarkX = Buffer->X; - Element->MarkY = Buffer->Y; - if (SWAP_IDENT) - SET_FLAG (ONSOLDERFLAG, Element); - SetElementBoundingBox (PCB->Data, Element, &PCB->Font); - ClearBuffer (Buffer); - MoveObjectToBuffer (Buffer->Data, PCB->Data, ELEMENT_TYPE, Element, Element, - Element); - SetBufferBoundingBox (Buffer); - return (true); + if (!hasParts) { + DestroyObject(PCB->Data, ELEMENT_TYPE, Element, Element, Element); + Message(_("There was nothing to convert!\n" "Elements must have some silk, pads or pins.\n")); + return (false); + } + if (crooked) + Message(_("There were polygons that can't be made into pins!\n" "So they were not included in the element\n")); + Element->MarkX = Buffer->X; + Element->MarkY = Buffer->Y; + if (SWAP_IDENT) + SET_FLAG(ONSOLDERFLAG, Element); + SetElementBoundingBox(PCB->Data, Element, &PCB->Font); + ClearBuffer(Buffer); + MoveObjectToBuffer(Buffer->Data, PCB->Data, ELEMENT_TYPE, Element, Element, Element); + SetBufferBoundingBox(Buffer); + return (true); } /* --------------------------------------------------------------------------- @@ -878,235 +796,224 @@ * parse the file with enabled 'PCB mode' (see parser) * if successful, update some other stuff */ -bool -LoadLayoutToBuffer (BufferTypePtr Buffer, char *Filename) +bool LoadLayoutToBuffer(BufferTypePtr Buffer, char *Filename) { - PCBTypePtr newPCB = CreateNewPCB (); + PCBTypePtr newPCB = CreateNewPCB(); - /* new data isn't added to the undo list */ - if (!ParsePCB (newPCB, Filename)) - { - /* clear data area and replace pointer */ - ClearBuffer (Buffer); - free (Buffer->Data); - Buffer->Data = newPCB->Data; - newPCB->Data = NULL; - Buffer->X = newPCB->CursorX; - Buffer->Y = newPCB->CursorY; - RemovePCB (newPCB); - Buffer->Data->pcb = PCB; - return (true); - } + /* new data isn't added to the undo list */ + if (!ParsePCB(newPCB, Filename)) { + /* clear data area and replace pointer */ + ClearBuffer(Buffer); + free(Buffer->Data); + Buffer->Data = newPCB->Data; + newPCB->Data = NULL; + Buffer->X = newPCB->CursorX; + Buffer->Y = newPCB->CursorY; + RemovePCB(newPCB); + Buffer->Data->pcb = PCB; + return (true); + } - /* release unused memory */ - RemovePCB (newPCB); - Buffer->Data->pcb = PCB; - return (false); + /* release unused memory */ + RemovePCB(newPCB); + Buffer->Data->pcb = PCB; + return (false); } /* --------------------------------------------------------------------------- * rotates the contents of the pastebuffer */ -void -RotateBuffer (BufferTypePtr Buffer, BYTE Number) +void RotateBuffer(BufferTypePtr Buffer, BYTE Number) { - /* rotate vias */ - VIA_LOOP (Buffer->Data); - { - r_delete_entry (Buffer->Data->via_tree, (BoxType *)via); - ROTATE_VIA_LOWLEVEL (via, Buffer->X, Buffer->Y, Number); - SetPinBoundingBox (via); - r_insert_entry (Buffer->Data->via_tree, (BoxType *)via, 0); - } - END_LOOP; + /* rotate vias */ + VIA_LOOP(Buffer->Data); + { + r_delete_entry(Buffer->Data->via_tree, (BoxType *) via); + ROTATE_VIA_LOWLEVEL(via, Buffer->X, Buffer->Y, Number); + SetPinBoundingBox(via); + r_insert_entry(Buffer->Data->via_tree, (BoxType *) via, 0); + } + END_LOOP; - /* elements */ - ELEMENT_LOOP (Buffer->Data); - { - RotateElementLowLevel (Buffer->Data, element, Buffer->X, Buffer->Y, - Number); - } - END_LOOP; + /* elements */ + ELEMENT_LOOP(Buffer->Data); + { + RotateElementLowLevel(Buffer->Data, element, Buffer->X, Buffer->Y, Number); + } + END_LOOP; - /* all layer related objects */ - ALLLINE_LOOP (Buffer->Data); - { - r_delete_entry (layer->line_tree, (BoxType *)line); - RotateLineLowLevel (line, Buffer->X, Buffer->Y, Number); - r_insert_entry (layer->line_tree, (BoxType *)line, 0); - } - ENDALL_LOOP; - ALLARC_LOOP (Buffer->Data); - { - r_delete_entry (layer->arc_tree, (BoxType *)arc); - RotateArcLowLevel (arc, Buffer->X, Buffer->Y, Number); - r_insert_entry (layer->arc_tree, (BoxType *)arc, 0); - } - ENDALL_LOOP; - ALLTEXT_LOOP (Buffer->Data); - { - r_delete_entry (layer->text_tree, (BoxType *)text); - RotateTextLowLevel (text, Buffer->X, Buffer->Y, Number); - r_insert_entry (layer->text_tree, (BoxType *)text, 0); - } - ENDALL_LOOP; - ALLPOLYGON_LOOP (Buffer->Data); - { - r_delete_entry (layer->polygon_tree, (BoxType *)polygon); - RotatePolygonLowLevel (polygon, Buffer->X, Buffer->Y, Number); - r_insert_entry (layer->polygon_tree, (BoxType *)polygon, 0); - } - ENDALL_LOOP; + /* all layer related objects */ + ALLLINE_LOOP(Buffer->Data); + { + r_delete_entry(layer->line_tree, (BoxType *) line); + RotateLineLowLevel(line, Buffer->X, Buffer->Y, Number); + r_insert_entry(layer->line_tree, (BoxType *) line, 0); + } + ENDALL_LOOP; + ALLARC_LOOP(Buffer->Data); + { + r_delete_entry(layer->arc_tree, (BoxType *) arc); + RotateArcLowLevel(arc, Buffer->X, Buffer->Y, Number); + r_insert_entry(layer->arc_tree, (BoxType *) arc, 0); + } + ENDALL_LOOP; + ALLTEXT_LOOP(Buffer->Data); + { + r_delete_entry(layer->text_tree, (BoxType *) text); + RotateTextLowLevel(text, Buffer->X, Buffer->Y, Number); + r_insert_entry(layer->text_tree, (BoxType *) text, 0); + } + ENDALL_LOOP; + ALLPOLYGON_LOOP(Buffer->Data); + { + r_delete_entry(layer->polygon_tree, (BoxType *) polygon); + RotatePolygonLowLevel(polygon, Buffer->X, Buffer->Y, Number); + r_insert_entry(layer->polygon_tree, (BoxType *) polygon, 0); + } + ENDALL_LOOP; - /* finally the origin and the bounding box */ - ROTATE (Buffer->X, Buffer->Y, Buffer->X, Buffer->Y, Number); - RotateBoxLowLevel (&Buffer->BoundingBox, Buffer->X, Buffer->Y, Number); + /* finally the origin and the bounding box */ + ROTATE(Buffer->X, Buffer->Y, Buffer->X, Buffer->Y, Number); + RotateBoxLowLevel(&Buffer->BoundingBox, Buffer->X, Buffer->Y, Number); } -static void -free_rotate (Coord *x, Coord *y, Coord cx, Coord cy, double cosa, double sina) +static void free_rotate(Coord * x, Coord * y, Coord cx, Coord cy, double cosa, double sina) { - double nx, ny; - Coord px = *x - cx; - Coord py = *y - cy; + double nx, ny; + Coord px = *x - cx; + Coord py = *y - cy; - nx = px * cosa + py * sina; - ny = py * cosa - px * sina; + nx = px * cosa + py * sina; + ny = py * cosa - px * sina; - *x = nx + cx; - *y = ny + cy; + *x = nx + cx; + *y = ny + cy; } void -FreeRotateElementLowLevel (DataTypePtr Data, ElementTypePtr Element, - Coord X, Coord Y, - double cosa, double sina, Angle angle) +FreeRotateElementLowLevel(DataTypePtr Data, ElementTypePtr Element, Coord X, Coord Y, double cosa, double sina, Angle angle) { - /* solder side objects need a different orientation */ + /* solder side objects need a different orientation */ - /* the text subroutine decides by itself if the direction - * is to be corrected - */ + /* the text subroutine decides by itself if the direction + * is to be corrected + */ #if 0 - ELEMENTTEXT_LOOP (Element); - { - if (Data && Data->name_tree[n]) - r_delete_entry (Data->name_tree[n], (BoxType *)text); - RotateTextLowLevel (text, X, Y, Number); - } - END_LOOP; + ELEMENTTEXT_LOOP(Element); + { + if (Data && Data->name_tree[n]) + r_delete_entry(Data->name_tree[n], (BoxType *) text); + RotateTextLowLevel(text, X, Y, Number); + } + END_LOOP; #endif - ELEMENTLINE_LOOP (Element); - { - free_rotate (&line->Point1.X, &line->Point1.Y, X, Y, cosa, sina); - free_rotate (&line->Point2.X, &line->Point2.Y, X, Y, cosa, sina); - SetLineBoundingBox (line); - } - END_LOOP; - PIN_LOOP (Element); - { - /* pre-delete the pins from the pin-tree before their coordinates change */ - if (Data) - r_delete_entry (Data->pin_tree, (BoxType *)pin); - RestoreToPolygon (Data, PIN_TYPE, Element, pin); - free_rotate (&pin->X, &pin->Y, X, Y, cosa, sina); - SetPinBoundingBox (pin); - } - END_LOOP; - PAD_LOOP (Element); - { - /* pre-delete the pads before their coordinates change */ - if (Data) - r_delete_entry (Data->pad_tree, (BoxType *)pad); - RestoreToPolygon (Data, PAD_TYPE, Element, pad); - free_rotate (&pad->Point1.X, &pad->Point1.Y, X, Y, cosa, sina); - free_rotate (&pad->Point2.X, &pad->Point2.Y, X, Y, cosa, sina); - SetLineBoundingBox ((LineType *) pad); - } - END_LOOP; - ARC_LOOP (Element); - { - free_rotate (&arc->X, &arc->Y, X, Y, cosa, sina); - arc->StartAngle = NormalizeAngle (arc->StartAngle + angle); - } - END_LOOP; + ELEMENTLINE_LOOP(Element); + { + free_rotate(&line->Point1.X, &line->Point1.Y, X, Y, cosa, sina); + free_rotate(&line->Point2.X, &line->Point2.Y, X, Y, cosa, sina); + SetLineBoundingBox(line); + } + END_LOOP; + PIN_LOOP(Element); + { + /* pre-delete the pins from the pin-tree before their coordinates change */ + if (Data) + r_delete_entry(Data->pin_tree, (BoxType *) pin); + RestoreToPolygon(Data, PIN_TYPE, Element, pin); + free_rotate(&pin->X, &pin->Y, X, Y, cosa, sina); + SetPinBoundingBox(pin); + } + END_LOOP; + PAD_LOOP(Element); + { + /* pre-delete the pads before their coordinates change */ + if (Data) + r_delete_entry(Data->pad_tree, (BoxType *) pad); + RestoreToPolygon(Data, PAD_TYPE, Element, pad); + free_rotate(&pad->Point1.X, &pad->Point1.Y, X, Y, cosa, sina); + free_rotate(&pad->Point2.X, &pad->Point2.Y, X, Y, cosa, sina); + SetLineBoundingBox((LineType *) pad); + } + END_LOOP; + ARC_LOOP(Element); + { + free_rotate(&arc->X, &arc->Y, X, Y, cosa, sina); + arc->StartAngle = NormalizeAngle(arc->StartAngle + angle); + } + END_LOOP; - free_rotate (&Element->MarkX, &Element->MarkY, X, Y, cosa, sina); - SetElementBoundingBox (Data, Element, &PCB->Font); - ClearFromPolygon (Data, ELEMENT_TYPE, Element, Element); + free_rotate(&Element->MarkX, &Element->MarkY, X, Y, cosa, sina); + SetElementBoundingBox(Data, Element, &PCB->Font); + ClearFromPolygon(Data, ELEMENT_TYPE, Element, Element); } -void -FreeRotateBuffer (BufferTypePtr Buffer, Angle angle) +void FreeRotateBuffer(BufferTypePtr Buffer, Angle angle) { - double cosa, sina; + double cosa, sina; - cosa = cos(angle * M_PI/180.0); - sina = sin(angle * M_PI/180.0); + cosa = cos(angle * M_PI / 180.0); + sina = sin(angle * M_PI / 180.0); - /* rotate vias */ - VIA_LOOP (Buffer->Data); - { - r_delete_entry (Buffer->Data->via_tree, (BoxType *)via); - free_rotate (&via->X, &via->Y, Buffer->X, Buffer->Y, cosa, sina); - SetPinBoundingBox (via); - r_insert_entry (Buffer->Data->via_tree, (BoxType *)via, 0); - } - END_LOOP; + /* rotate vias */ + VIA_LOOP(Buffer->Data); + { + r_delete_entry(Buffer->Data->via_tree, (BoxType *) via); + free_rotate(&via->X, &via->Y, Buffer->X, Buffer->Y, cosa, sina); + SetPinBoundingBox(via); + r_insert_entry(Buffer->Data->via_tree, (BoxType *) via, 0); + } + END_LOOP; - /* elements */ - ELEMENT_LOOP (Buffer->Data); - { - FreeRotateElementLowLevel (Buffer->Data, element, Buffer->X, Buffer->Y, - cosa, sina, angle); - } - END_LOOP; + /* elements */ + ELEMENT_LOOP(Buffer->Data); + { + FreeRotateElementLowLevel(Buffer->Data, element, Buffer->X, Buffer->Y, cosa, sina, angle); + } + END_LOOP; - /* all layer related objects */ - ALLLINE_LOOP (Buffer->Data); - { - r_delete_entry (layer->line_tree, (BoxType *)line); - free_rotate (&line->Point1.X, &line->Point1.Y, Buffer->X, Buffer->Y, cosa, sina); - free_rotate (&line->Point2.X, &line->Point2.Y, Buffer->X, Buffer->Y, cosa, sina); - SetLineBoundingBox (line); - r_insert_entry (layer->line_tree, (BoxType *)line, 0); - } - ENDALL_LOOP; - ALLARC_LOOP (Buffer->Data); - { - r_delete_entry (layer->arc_tree, (BoxType *)arc); - free_rotate (&arc->X, &arc->Y, Buffer->X, Buffer->Y, cosa, sina); - arc->StartAngle = NormalizeAngle (arc->StartAngle + angle); - r_insert_entry (layer->arc_tree, (BoxType *)arc, 0); - } - ENDALL_LOOP; - /* FIXME: rotate text */ - ALLPOLYGON_LOOP (Buffer->Data); - { - r_delete_entry (layer->polygon_tree, (BoxType *)polygon); - POLYGONPOINT_LOOP (polygon); - { - free_rotate (&point->X, &point->Y, Buffer->X, Buffer->Y, cosa, sina); - } - END_LOOP; - SetPolygonBoundingBox (polygon); - r_insert_entry (layer->polygon_tree, (BoxType *)polygon, 0); - } - ENDALL_LOOP; + /* all layer related objects */ + ALLLINE_LOOP(Buffer->Data); + { + r_delete_entry(layer->line_tree, (BoxType *) line); + free_rotate(&line->Point1.X, &line->Point1.Y, Buffer->X, Buffer->Y, cosa, sina); + free_rotate(&line->Point2.X, &line->Point2.Y, Buffer->X, Buffer->Y, cosa, sina); + SetLineBoundingBox(line); + r_insert_entry(layer->line_tree, (BoxType *) line, 0); + } + ENDALL_LOOP; + ALLARC_LOOP(Buffer->Data); + { + r_delete_entry(layer->arc_tree, (BoxType *) arc); + free_rotate(&arc->X, &arc->Y, Buffer->X, Buffer->Y, cosa, sina); + arc->StartAngle = NormalizeAngle(arc->StartAngle + angle); + r_insert_entry(layer->arc_tree, (BoxType *) arc, 0); + } + ENDALL_LOOP; + /* FIXME: rotate text */ + ALLPOLYGON_LOOP(Buffer->Data); + { + r_delete_entry(layer->polygon_tree, (BoxType *) polygon); + POLYGONPOINT_LOOP(polygon); + { + free_rotate(&point->X, &point->Y, Buffer->X, Buffer->Y, cosa, sina); + } + END_LOOP; + SetPolygonBoundingBox(polygon); + r_insert_entry(layer->polygon_tree, (BoxType *) polygon, 0); + } + ENDALL_LOOP; - SetBufferBoundingBox (Buffer); + SetBufferBoundingBox(Buffer); } /* -------------------------------------------------------------------------- */ -static const char freerotatebuffer_syntax[] = - "FreeRotateBuffer([Angle])"; +static const char freerotatebuffer_syntax[] = "FreeRotateBuffer([Angle])"; static const char freerotatebuffer_help[] = - "Rotates the current paste buffer contents by the specified angle. The\n" - "angle is given in degrees. If no angle is given, the user is prompted\n" - "for one.\n"; + "Rotates the current paste buffer contents by the specified angle. The\n" + "angle is given in degrees. If no angle is given, the user is prompted\n" "for one.\n"; /* %start-doc actions FreeRotateBuffer @@ -1115,101 +1022,94 @@ %end-doc */ -int -ActionFreeRotateBuffer(int argc, char **argv, Coord x, Coord y) +int ActionFreeRotateBuffer(int argc, char **argv, Coord x, Coord y) { - char *angle_s; + char *angle_s; - if (argc < 1) - angle_s = gui->prompt_for ("Enter Rotation (degrees, CCW):", "0"); - else - angle_s = argv[0]; + if (argc < 1) + angle_s = gui->prompt_for("Enter Rotation (degrees, CCW):", "0"); + else + angle_s = argv[0]; - notify_crosshair_change (false); - FreeRotateBuffer(PASTEBUFFER, strtod(angle_s, 0)); - notify_crosshair_change (true); - return 0; + notify_crosshair_change(false); + FreeRotateBuffer(PASTEBUFFER, strtod(angle_s, 0)); + notify_crosshair_change(true); + return 0; } /* --------------------------------------------------------------------------- * initializes the buffers by allocating memory */ -void -InitBuffers (void) +void InitBuffers(void) { - int i; + int i; - for (i = 0; i < MAX_BUFFER; i++) - Buffers[i].Data = CreateNewBuffer (); + for (i = 0; i < MAX_BUFFER; i++) + Buffers[i].Data = CreateNewBuffer(); } -void -SwapBuffers (void) +void SwapBuffers(void) { - int i; + int i; - for (i = 0; i < MAX_BUFFER; i++) - SwapBuffer (&Buffers[i]); - SetCrosshairRangeToBuffer (); + for (i = 0; i < MAX_BUFFER; i++) + SwapBuffer(&Buffers[i]); + SetCrosshairRangeToBuffer(); } -void -MirrorBuffer (BufferTypePtr Buffer) +void MirrorBuffer(BufferTypePtr Buffer) { - int i; + int i; - if (Buffer->Data->ElementN) - { - Message (_("You can't mirror a buffer that has elements!\n")); - return; - } - for (i = 0; i < max_copper_layer + 2; i++) - { - LayerTypePtr layer = Buffer->Data->Layer + i; - if (layer->TextN) + if (Buffer->Data->ElementN) { + Message(_("You can't mirror a buffer that has elements!\n")); + return; + } + for (i = 0; i < max_copper_layer + 2; i++) { + LayerTypePtr layer = Buffer->Data->Layer + i; + if (layer->TextN) { + Message(_("You can't mirror a buffer that has text!\n")); + return; + } + } + /* set buffer offset to 'mark' position */ + Buffer->X = SWAP_X(Buffer->X); + Buffer->Y = SWAP_Y(Buffer->Y); + VIA_LOOP(Buffer->Data); { - Message (_("You can't mirror a buffer that has text!\n")); - return; + via->X = SWAP_X(via->X); + via->Y = SWAP_Y(via->Y); } - } - /* set buffer offset to 'mark' position */ - Buffer->X = SWAP_X (Buffer->X); - Buffer->Y = SWAP_Y (Buffer->Y); - VIA_LOOP (Buffer->Data); - { - via->X = SWAP_X (via->X); - via->Y = SWAP_Y (via->Y); - } - END_LOOP; - ALLLINE_LOOP (Buffer->Data); - { - line->Point1.X = SWAP_X (line->Point1.X); - line->Point1.Y = SWAP_Y (line->Point1.Y); - line->Point2.X = SWAP_X (line->Point2.X); - line->Point2.Y = SWAP_Y (line->Point2.Y); - } - ENDALL_LOOP; - ALLARC_LOOP (Buffer->Data); - { - arc->X = SWAP_X (arc->X); - arc->Y = SWAP_Y (arc->Y); - arc->StartAngle = SWAP_ANGLE (arc->StartAngle); - arc->Delta = SWAP_DELTA (arc->Delta); - SetArcBoundingBox (arc); - } - ENDALL_LOOP; - ALLPOLYGON_LOOP (Buffer->Data); - { - POLYGONPOINT_LOOP (polygon); - { - point->X = SWAP_X (point->X); - point->Y = SWAP_Y (point->Y); - } - END_LOOP; - SetPolygonBoundingBox (polygon); - } - ENDALL_LOOP; - SetBufferBoundingBox (Buffer); + END_LOOP; + ALLLINE_LOOP(Buffer->Data); + { + line->Point1.X = SWAP_X(line->Point1.X); + line->Point1.Y = SWAP_Y(line->Point1.Y); + line->Point2.X = SWAP_X(line->Point2.X); + line->Point2.Y = SWAP_Y(line->Point2.Y); + } + ENDALL_LOOP; + ALLARC_LOOP(Buffer->Data); + { + arc->X = SWAP_X(arc->X); + arc->Y = SWAP_Y(arc->Y); + arc->StartAngle = SWAP_ANGLE(arc->StartAngle); + arc->Delta = SWAP_DELTA(arc->Delta); + SetArcBoundingBox(arc); + } + ENDALL_LOOP; + ALLPOLYGON_LOOP(Buffer->Data); + { + POLYGONPOINT_LOOP(polygon); + { + point->X = SWAP_X(point->X); + point->Y = SWAP_Y(point->Y); + } + END_LOOP; + SetPolygonBoundingBox(polygon); + } + ENDALL_LOOP; + SetBufferBoundingBox(Buffer); } @@ -1216,126 +1116,121 @@ /* --------------------------------------------------------------------------- * flip components/tracks from one side to the other */ -static void -SwapBuffer (BufferTypePtr Buffer) +static void SwapBuffer(BufferTypePtr Buffer) { - int j, k; - Cardinal sgroup, cgroup; - LayerType swap; + int j, k; + Cardinal sgroup, cgroup; + LayerType swap; - ELEMENT_LOOP (Buffer->Data); - { - r_delete_element (Buffer->Data, element); - MirrorElementCoordinates (Buffer->Data, element, 0); - } - END_LOOP; - /* set buffer offset to 'mark' position */ - Buffer->X = SWAP_X (Buffer->X); - Buffer->Y = SWAP_Y (Buffer->Y); - VIA_LOOP (Buffer->Data); - { - r_delete_entry (Buffer->Data->via_tree, (BoxType *)via); - via->X = SWAP_X (via->X); - via->Y = SWAP_Y (via->Y); - SetPinBoundingBox (via); - r_insert_entry (Buffer->Data->via_tree, (BoxType *)via, 0); - } - END_LOOP; - ALLLINE_LOOP (Buffer->Data); - { - r_delete_entry (layer->line_tree, (BoxType *)line); - line->Point1.X = SWAP_X (line->Point1.X); - line->Point1.Y = SWAP_Y (line->Point1.Y); - line->Point2.X = SWAP_X (line->Point2.X); - line->Point2.Y = SWAP_Y (line->Point2.Y); - SetLineBoundingBox (line); - r_insert_entry (layer->line_tree, (BoxType *)line, 0); - } - ENDALL_LOOP; - ALLARC_LOOP (Buffer->Data); - { - r_delete_entry (layer->arc_tree, (BoxType *)arc); - arc->X = SWAP_X (arc->X); - arc->Y = SWAP_Y (arc->Y); - arc->StartAngle = SWAP_ANGLE (arc->StartAngle); - arc->Delta = SWAP_DELTA (arc->Delta); - SetArcBoundingBox (arc); - r_insert_entry (layer->arc_tree, (BoxType *)arc, 0); - } - ENDALL_LOOP; - ALLPOLYGON_LOOP (Buffer->Data); - { - r_delete_entry (layer->polygon_tree, (BoxType *)polygon); - POLYGONPOINT_LOOP (polygon); - { - point->X = SWAP_X (point->X); - point->Y = SWAP_Y (point->Y); - } - END_LOOP; - SetPolygonBoundingBox (polygon); - r_insert_entry (layer->polygon_tree, (BoxType *)polygon, 0); - /* hmmm, how to handle clip */ - } - ENDALL_LOOP; - ALLTEXT_LOOP (Buffer->Data); - { - r_delete_entry (layer->text_tree, (BoxType *)text); - text->X = SWAP_X (text->X); - text->Y = SWAP_Y (text->Y); - TOGGLE_FLAG (ONSOLDERFLAG, text); - SetTextBoundingBox (&PCB->Font, text); - r_insert_entry (layer->text_tree, (BoxType *)text, 0); - } - ENDALL_LOOP; - /* swap silkscreen layers */ - swap = Buffer->Data->Layer[solder_silk_layer]; - Buffer->Data->Layer[solder_silk_layer] = - Buffer->Data->Layer[component_silk_layer]; - Buffer->Data->Layer[component_silk_layer] = swap; - - /* swap layer groups when balanced */ - sgroup = GetLayerGroupNumberByNumber (solder_silk_layer); - cgroup = GetLayerGroupNumberByNumber (component_silk_layer); - if (PCB->LayerGroups.Number[cgroup] == PCB->LayerGroups.Number[sgroup]) - { - for (j = k = 0; j < PCB->LayerGroups.Number[sgroup]; j++) + ELEMENT_LOOP(Buffer->Data); { - int t1, t2; - Cardinal cnumber = PCB->LayerGroups.Entries[cgroup][k]; - Cardinal snumber = PCB->LayerGroups.Entries[sgroup][j]; + r_delete_element(Buffer->Data, element); + MirrorElementCoordinates(Buffer->Data, element, 0); + } + END_LOOP; + /* set buffer offset to 'mark' position */ + Buffer->X = SWAP_X(Buffer->X); + Buffer->Y = SWAP_Y(Buffer->Y); + VIA_LOOP(Buffer->Data); + { + r_delete_entry(Buffer->Data->via_tree, (BoxType *) via); + via->X = SWAP_X(via->X); + via->Y = SWAP_Y(via->Y); + SetPinBoundingBox(via); + r_insert_entry(Buffer->Data->via_tree, (BoxType *) via, 0); + } + END_LOOP; + ALLLINE_LOOP(Buffer->Data); + { + r_delete_entry(layer->line_tree, (BoxType *) line); + line->Point1.X = SWAP_X(line->Point1.X); + line->Point1.Y = SWAP_Y(line->Point1.Y); + line->Point2.X = SWAP_X(line->Point2.X); + line->Point2.Y = SWAP_Y(line->Point2.Y); + SetLineBoundingBox(line); + r_insert_entry(layer->line_tree, (BoxType *) line, 0); + } + ENDALL_LOOP; + ALLARC_LOOP(Buffer->Data); + { + r_delete_entry(layer->arc_tree, (BoxType *) arc); + arc->X = SWAP_X(arc->X); + arc->Y = SWAP_Y(arc->Y); + arc->StartAngle = SWAP_ANGLE(arc->StartAngle); + arc->Delta = SWAP_DELTA(arc->Delta); + SetArcBoundingBox(arc); + r_insert_entry(layer->arc_tree, (BoxType *) arc, 0); + } + ENDALL_LOOP; + ALLPOLYGON_LOOP(Buffer->Data); + { + r_delete_entry(layer->polygon_tree, (BoxType *) polygon); + POLYGONPOINT_LOOP(polygon); + { + point->X = SWAP_X(point->X); + point->Y = SWAP_Y(point->Y); + } + END_LOOP; + SetPolygonBoundingBox(polygon); + r_insert_entry(layer->polygon_tree, (BoxType *) polygon, 0); + /* hmmm, how to handle clip */ + } + ENDALL_LOOP; + ALLTEXT_LOOP(Buffer->Data); + { + r_delete_entry(layer->text_tree, (BoxType *) text); + text->X = SWAP_X(text->X); + text->Y = SWAP_Y(text->Y); + TOGGLE_FLAG(ONSOLDERFLAG, text); + SetTextBoundingBox(&PCB->Font, text); + r_insert_entry(layer->text_tree, (BoxType *) text, 0); + } + ENDALL_LOOP; + /* swap silkscreen layers */ + swap = Buffer->Data->Layer[solder_silk_layer]; + Buffer->Data->Layer[solder_silk_layer] = Buffer->Data->Layer[component_silk_layer]; + Buffer->Data->Layer[component_silk_layer] = swap; - if (snumber >= max_copper_layer) - continue; - swap = Buffer->Data->Layer[snumber]; + /* swap layer groups when balanced */ + sgroup = GetLayerGroupNumberByNumber(solder_silk_layer); + cgroup = GetLayerGroupNumberByNumber(component_silk_layer); + if (PCB->LayerGroups.Number[cgroup] == PCB->LayerGroups.Number[sgroup]) { + for (j = k = 0; j < PCB->LayerGroups.Number[sgroup]; j++) { + int t1, t2; + Cardinal cnumber = PCB->LayerGroups.Entries[cgroup][k]; + Cardinal snumber = PCB->LayerGroups.Entries[sgroup][j]; - while (cnumber >= max_copper_layer) - { - k++; - cnumber = PCB->LayerGroups.Entries[cgroup][k]; - } - Buffer->Data->Layer[snumber] = Buffer->Data->Layer[cnumber]; - Buffer->Data->Layer[cnumber] = swap; - k++; - /* move the thermal flags with the layers */ - ALLPIN_LOOP (Buffer->Data); - { - t1 = TEST_THERM (snumber, pin); - t2 = TEST_THERM (cnumber, pin); - ASSIGN_THERM (snumber, t2, pin); - ASSIGN_THERM (cnumber, t1, pin); - } - ENDALL_LOOP; - VIA_LOOP (Buffer->Data); - { - t1 = TEST_THERM (snumber, via); - t2 = TEST_THERM (cnumber, via); - ASSIGN_THERM (snumber, t2, via); - ASSIGN_THERM (cnumber, t1, via); - } - END_LOOP; + if (snumber >= max_copper_layer) + continue; + swap = Buffer->Data->Layer[snumber]; + + while (cnumber >= max_copper_layer) { + k++; + cnumber = PCB->LayerGroups.Entries[cgroup][k]; + } + Buffer->Data->Layer[snumber] = Buffer->Data->Layer[cnumber]; + Buffer->Data->Layer[cnumber] = swap; + k++; + /* move the thermal flags with the layers */ + ALLPIN_LOOP(Buffer->Data); + { + t1 = TEST_THERM(snumber, pin); + t2 = TEST_THERM(cnumber, pin); + ASSIGN_THERM(snumber, t2, pin); + ASSIGN_THERM(cnumber, t1, pin); + } + ENDALL_LOOP; + VIA_LOOP(Buffer->Data); + { + t1 = TEST_THERM(snumber, via); + t2 = TEST_THERM(cnumber, via); + ASSIGN_THERM(snumber, t2, via); + ASSIGN_THERM(cnumber, t1, via); + } + END_LOOP; + } } - } - SetBufferBoundingBox (Buffer); + SetBufferBoundingBox(Buffer); } /* ---------------------------------------------------------------------- @@ -1342,36 +1237,33 @@ * moves the passed object to the passed buffer and removes it * from its original place */ -void * -MoveObjectToBuffer (DataTypePtr Destination, DataTypePtr Src, - int Type, void *Ptr1, void *Ptr2, void *Ptr3) +void *MoveObjectToBuffer(DataTypePtr Destination, DataTypePtr Src, int Type, void *Ptr1, void *Ptr2, void *Ptr3) { - /* setup local identifiers used by move operations */ - Dest = Destination; - Source = Src; - return (ObjectOperation (&MoveBufferFunctions, Type, Ptr1, Ptr2, Ptr3)); + /* setup local identifiers used by move operations */ + Dest = Destination; + Source = Src; + return (ObjectOperation(&MoveBufferFunctions, Type, Ptr1, Ptr2, Ptr3)); } /* ---------------------------------------------------------------------- * Adds the passed object to the passed buffer */ -void * -CopyObjectToBuffer (DataTypePtr Destination, DataTypePtr Src, - int Type, void *Ptr1, void *Ptr2, void *Ptr3) +void *CopyObjectToBuffer(DataTypePtr Destination, DataTypePtr Src, int Type, void *Ptr1, void *Ptr2, void *Ptr3) { - /* setup local identifiers used by Add operations */ - Dest = Destination; - Source = Src; - return (ObjectOperation (&AddBufferFunctions, Type, Ptr1, Ptr2, Ptr3)); + /* setup local identifiers used by Add operations */ + Dest = Destination; + Source = Src; + return (ObjectOperation(&AddBufferFunctions, Type, Ptr1, Ptr2, Ptr3)); } /* ---------------------------------------------------------------------- */ HID_Action rotate_action_list[] = { - {"FreeRotateBuffer", 0, ActionFreeRotateBuffer, - freerotatebuffer_syntax, freerotatebuffer_help}, - {"LoadFootprint", 0, LoadFootprint, - 0,0} + {"FreeRotateBuffer", 0, ActionFreeRotateBuffer, + freerotatebuffer_syntax, freerotatebuffer_help} + , + {"LoadFootprint", 0, LoadFootprint, + 0, 0} }; -REGISTER_ACTIONS (rotate_action_list) +REGISTER_ACTIONS(rotate_action_list) Index: trunk/src/buffer.h =================================================================== --- trunk/src/buffer.h (revision 1021) +++ trunk/src/buffer.h (revision 1022) @@ -36,23 +36,22 @@ /* --------------------------------------------------------------------------- * prototypes */ -void SetBufferBoundingBox (BufferTypePtr); -void ClearBuffer (BufferTypePtr); -void AddSelectedToBuffer (BufferTypePtr, Coord, Coord, bool); -bool LoadElementToBuffer (BufferTypePtr, const char *); -bool ConvertBufferToElement (BufferTypePtr); -bool SmashBufferElement (BufferTypePtr); -bool LoadLayoutToBuffer (BufferTypePtr, char *); -void RotateBuffer (BufferTypePtr, BYTE); -void SelectPasteBuffer (int); -void SwapBuffers (void); -void MirrorBuffer (BufferTypePtr); -void InitBuffers (void); -void *MoveObjectToBuffer (DataTypePtr, DataTypePtr, int, void *, void *, void *); -void *CopyObjectToBuffer (DataTypePtr, DataTypePtr, int, - void *, void *, void *); +void SetBufferBoundingBox(BufferTypePtr); +void ClearBuffer(BufferTypePtr); +void AddSelectedToBuffer(BufferTypePtr, Coord, Coord, bool); +bool LoadElementToBuffer(BufferTypePtr, const char *); +bool ConvertBufferToElement(BufferTypePtr); +bool SmashBufferElement(BufferTypePtr); +bool LoadLayoutToBuffer(BufferTypePtr, char *); +void RotateBuffer(BufferTypePtr, BYTE); +void SelectPasteBuffer(int); +void SwapBuffers(void); +void MirrorBuffer(BufferTypePtr); +void InitBuffers(void); +void *MoveObjectToBuffer(DataTypePtr, DataTypePtr, int, void *, void *, void *); +void *CopyObjectToBuffer(DataTypePtr, DataTypePtr, int, void *, void *, void *); /* This action is called from ActionElementAddIf() */ -int LoadFootprint (int argc, char **argv, Coord x, Coord y); +int LoadFootprint(int argc, char **argv, Coord x, Coord y); #endif Index: trunk/src/buildin.h =================================================================== --- trunk/src/buildin.h (revision 1021) +++ trunk/src/buildin.h (revision 1022) @@ -1,3 +1,2 @@ /* Run the init code of all buildins. */ void buildin_init(void); - Index: trunk/src/change.c =================================================================== --- trunk/src/change.c (revision 1021) +++ trunk/src/change.c (revision 1022) @@ -61,335 +61,352 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); /* --------------------------------------------------------------------------- * some local prototypes */ -static void *ChangePinSize (ElementTypePtr, PinTypePtr); -static void *ChangePinClearSize (ElementTypePtr, PinTypePtr); -static void *ChangePinMaskSize (ElementTypePtr, PinTypePtr); -static void *ChangePadSize (ElementTypePtr, PadTypePtr); -static void *ChangePadClearSize (ElementTypePtr, PadTypePtr); -static void *ChangePadMaskSize (ElementTypePtr, PadTypePtr); -static void *ChangePin2ndSize (ElementTypePtr, PinTypePtr); -static void *ChangeElement1stSize (ElementTypePtr); -static void *ChangeElement2ndSize (ElementTypePtr); -static void *ChangeViaSize (PinTypePtr); -static void *ChangeVia2ndSize (PinTypePtr); -static void *ChangeViaClearSize (PinTypePtr); -static void *ChangeViaMaskSize (PinTypePtr); -static void *ChangeLineSize (LayerTypePtr, LineTypePtr); -static void *ChangeLineClearSize (LayerTypePtr, LineTypePtr); -static void *ChangePolygonClearSize (LayerTypePtr, PolygonTypePtr); -static void *ChangeArcSize (LayerTypePtr, ArcTypePtr); -static void *ChangeArcClearSize (LayerTypePtr, ArcTypePtr); -static void *ChangeTextSize (LayerTypePtr, TextTypePtr); -static void *ChangeElementSize (ElementTypePtr); -static void *ChangeElementNameSize (ElementTypePtr); -static void *ChangeElementClearSize (ElementTypePtr); -static void *ChangePinName (ElementTypePtr, PinTypePtr); -static void *ChangePadName (ElementTypePtr, PadTypePtr); -static void *ChangePinNum (ElementTypePtr, PinTypePtr); -static void *ChangePadNum (ElementTypePtr, PadTypePtr); -static void *ChangeViaName (PinTypePtr); -static void *ChangeLineName (LayerTypePtr, LineTypePtr); -static void *ChangeElementName (ElementTypePtr); -static void *ChangeElementNonetlist (ElementTypePtr); -static void *ChangeTextName (LayerTypePtr, TextTypePtr); -static void *ChangeElementSquare (ElementTypePtr); -static void *SetElementSquare (ElementTypePtr); -static void *ClrElementSquare (ElementTypePtr); -static void *ChangeElementOctagon (ElementTypePtr); -static void *SetElementOctagon (ElementTypePtr); -static void *ClrElementOctagon (ElementTypePtr); -static void *ChangeViaSquare (PinTypePtr); -static void *ChangePinSquare (ElementTypePtr, PinTypePtr); -static void *SetPinSquare (ElementTypePtr, PinTypePtr); -static void *ClrPinSquare (ElementTypePtr, PinTypePtr); -static void *ChangePinOctagon (ElementTypePtr, PinTypePtr); -static void *SetPinOctagon (ElementTypePtr, PinTypePtr); -static void *ClrPinOctagon (ElementTypePtr, PinTypePtr); -static void *ChangeViaOctagon (PinTypePtr); -static void *SetViaOctagon (PinTypePtr); -static void *ClrViaOctagon (PinTypePtr); -static void *ChangePadSquare (ElementTypePtr, PadTypePtr); -static void *SetPadSquare (ElementTypePtr, PadTypePtr); -static void *ClrPadSquare (ElementTypePtr, PadTypePtr); -static void *ChangeViaThermal (PinTypePtr); -static void *ChangePinThermal (ElementTypePtr, PinTypePtr); -static void *ChangeLineJoin (LayerTypePtr, LineTypePtr); -static void *SetLineJoin (LayerTypePtr, LineTypePtr); -static void *ClrLineJoin (LayerTypePtr, LineTypePtr); -static void *ChangeArcJoin (LayerTypePtr, ArcTypePtr); -static void *SetArcJoin (LayerTypePtr, ArcTypePtr); -static void *ClrArcJoin (LayerTypePtr, ArcTypePtr); -static void *ChangeTextJoin (LayerTypePtr, TextTypePtr); -static void *SetTextJoin (LayerTypePtr, TextTypePtr); -static void *ClrTextJoin (LayerTypePtr, TextTypePtr); -static void *ChangePolyClear (LayerTypePtr, PolygonTypePtr); +static void *ChangePinSize(ElementTypePtr, PinTypePtr); +static void *ChangePinClearSize(ElementTypePtr, PinTypePtr); +static void *ChangePinMaskSize(ElementTypePtr, PinTypePtr); +static void *ChangePadSize(ElementTypePtr, PadTypePtr); +static void *ChangePadClearSize(ElementTypePtr, PadTypePtr); +static void *ChangePadMaskSize(ElementTypePtr, PadTypePtr); +static void *ChangePin2ndSize(ElementTypePtr, PinTypePtr); +static void *ChangeElement1stSize(ElementTypePtr); +static void *ChangeElement2ndSize(ElementTypePtr); +static void *ChangeViaSize(PinTypePtr); +static void *ChangeVia2ndSize(PinTypePtr); +static void *ChangeViaClearSize(PinTypePtr); +static void *ChangeViaMaskSize(PinTypePtr); +static void *ChangeLineSize(LayerTypePtr, LineTypePtr); +static void *ChangeLineClearSize(LayerTypePtr, LineTypePtr); +static void *ChangePolygonClearSize(LayerTypePtr, PolygonTypePtr); +static void *ChangeArcSize(LayerTypePtr, ArcTypePtr); +static void *ChangeArcClearSize(LayerTypePtr, ArcTypePtr); +static void *ChangeTextSize(LayerTypePtr, TextTypePtr); +static void *ChangeElementSize(ElementTypePtr); +static void *ChangeElementNameSize(ElementTypePtr); +static void *ChangeElementClearSize(ElementTypePtr); +static void *ChangePinName(ElementTypePtr, PinTypePtr); +static void *ChangePadName(ElementTypePtr, PadTypePtr); +static void *ChangePinNum(ElementTypePtr, PinTypePtr); +static void *ChangePadNum(ElementTypePtr, PadTypePtr); +static void *ChangeViaName(PinTypePtr); +static void *ChangeLineName(LayerTypePtr, LineTypePtr); +static void *ChangeElementName(ElementTypePtr); +static void *ChangeElementNonetlist(ElementTypePtr); +static void *ChangeTextName(LayerTypePtr, TextTypePtr); +static void *ChangeElementSquare(ElementTypePtr); +static void *SetElementSquare(ElementTypePtr); +static void *ClrElementSquare(ElementTypePtr); +static void *ChangeElementOctagon(ElementTypePtr); +static void *SetElementOctagon(ElementTypePtr); +static void *ClrElementOctagon(ElementTypePtr); +static void *ChangeViaSquare(PinTypePtr); +static void *ChangePinSquare(ElementTypePtr, PinTypePtr); +static void *SetPinSquare(ElementTypePtr, PinTypePtr); +static void *ClrPinSquare(ElementTypePtr, PinTypePtr); +static void *ChangePinOctagon(ElementTypePtr, PinTypePtr); +static void *SetPinOctagon(ElementTypePtr, PinTypePtr); +static void *ClrPinOctagon(ElementTypePtr, PinTypePtr); +static void *ChangeViaOctagon(PinTypePtr); +static void *SetViaOctagon(PinTypePtr); +static void *ClrViaOctagon(PinTypePtr); +static void *ChangePadSquare(ElementTypePtr, PadTypePtr); +static void *SetPadSquare(ElementTypePtr, PadTypePtr); +static void *ClrPadSquare(ElementTypePtr, PadTypePtr); +static void *ChangeViaThermal(PinTypePtr); +static void *ChangePinThermal(ElementTypePtr, PinTypePtr); +static void *ChangeLineJoin(LayerTypePtr, LineTypePtr); +static void *SetLineJoin(LayerTypePtr, LineTypePtr); +static void *ClrLineJoin(LayerTypePtr, LineTypePtr); +static void *ChangeArcJoin(LayerTypePtr, ArcTypePtr); +static void *SetArcJoin(LayerTypePtr, ArcTypePtr); +static void *ClrArcJoin(LayerTypePtr, ArcTypePtr); +static void *ChangeTextJoin(LayerTypePtr, TextTypePtr); +static void *SetTextJoin(LayerTypePtr, TextTypePtr); +static void *ClrTextJoin(LayerTypePtr, TextTypePtr); +static void *ChangePolyClear(LayerTypePtr, PolygonTypePtr); /* --------------------------------------------------------------------------- * some local identifiers */ -static Coord Delta; /* change of size */ -static Coord Absolute; /* Absolute size */ -static char *NewName; /* new name */ +static Coord Delta; /* change of size */ +static Coord Absolute; /* Absolute size */ +static char *NewName; /* new name */ static ObjectFunctionType ChangeSizeFunctions = { - ChangeLineSize, - ChangeTextSize, - ChangePolyClear, - ChangeViaSize, - ChangeElementSize, /* changes silk screen line width */ - ChangeElementNameSize, - ChangePinSize, - ChangePadSize, - NULL, - NULL, - ChangeArcSize, - NULL + ChangeLineSize, + ChangeTextSize, + ChangePolyClear, + ChangeViaSize, + ChangeElementSize, /* changes silk screen line width */ + ChangeElementNameSize, + ChangePinSize, + ChangePadSize, + NULL, + NULL, + ChangeArcSize, + NULL }; + static ObjectFunctionType Change1stSizeFunctions = { - ChangeLineSize, - ChangeTextSize, - ChangePolyClear, - ChangeViaSize, - ChangeElement1stSize, - ChangeElementNameSize, - ChangePinSize, - ChangePadSize, - NULL, - NULL, - ChangeArcSize, - NULL + ChangeLineSize, + ChangeTextSize, + ChangePolyClear, + ChangeViaSize, + ChangeElement1stSize, + ChangeElementNameSize, + ChangePinSize, + ChangePadSize, + NULL, + NULL, + ChangeArcSize, + NULL }; + static ObjectFunctionType Change2ndSizeFunctions = { - NULL, - NULL, - NULL, - ChangeVia2ndSize, - ChangeElement2ndSize, - NULL, - ChangePin2ndSize, - NULL, - NULL, - NULL, - NULL, - NULL + NULL, + NULL, + NULL, + ChangeVia2ndSize, + ChangeElement2ndSize, + NULL, + ChangePin2ndSize, + NULL, + NULL, + NULL, + NULL, + NULL }; + static ObjectFunctionType ChangeThermalFunctions = { - NULL, - NULL, - NULL, - ChangeViaThermal, - NULL, - NULL, - ChangePinThermal, - NULL, - NULL, - NULL, - NULL, - NULL + NULL, + NULL, + NULL, + ChangeViaThermal, + NULL, + NULL, + ChangePinThermal, + NULL, + NULL, + NULL, + NULL, + NULL }; + static ObjectFunctionType ChangeClearSizeFunctions = { - ChangeLineClearSize, - NULL, - ChangePolygonClearSize, /* just to tell the user not to :-) */ - ChangeViaClearSize, - ChangeElementClearSize, - NULL, - ChangePinClearSize, - ChangePadClearSize, - NULL, - NULL, - ChangeArcClearSize, - NULL + ChangeLineClearSize, + NULL, + ChangePolygonClearSize, /* just to tell the user not to :-) */ + ChangeViaClearSize, + ChangeElementClearSize, + NULL, + ChangePinClearSize, + ChangePadClearSize, + NULL, + NULL, + ChangeArcClearSize, + NULL }; + static ObjectFunctionType ChangeNameFunctions = { - ChangeLineName, - ChangeTextName, - NULL, - ChangeViaName, - ChangeElementName, - NULL, - ChangePinName, - ChangePadName, - NULL, - NULL, - NULL, - NULL + ChangeLineName, + ChangeTextName, + NULL, + ChangeViaName, + ChangeElementName, + NULL, + ChangePinName, + ChangePadName, + NULL, + NULL, + NULL, + NULL }; + static ObjectFunctionType ChangePinnumFunctions = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - ChangePinNum, - ChangePadNum, - NULL, - NULL, - NULL, - NULL + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + ChangePinNum, + ChangePadNum, + NULL, + NULL, + NULL, + NULL }; + static ObjectFunctionType ChangeSquareFunctions = { - NULL, - NULL, - NULL, - ChangeViaSquare, - ChangeElementSquare, - NULL, - ChangePinSquare, - ChangePadSquare, - NULL, - NULL, - NULL, - NULL + NULL, + NULL, + NULL, + ChangeViaSquare, + ChangeElementSquare, + NULL, + ChangePinSquare, + ChangePadSquare, + NULL, + NULL, + NULL, + NULL }; + static ObjectFunctionType ChangeNonetlistFunctions = { - NULL, - NULL, - NULL, - NULL, - ChangeElementNonetlist, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL + NULL, + NULL, + NULL, + NULL, + ChangeElementNonetlist, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL }; + static ObjectFunctionType ChangeJoinFunctions = { - ChangeLineJoin, - ChangeTextJoin, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - ChangeArcJoin, - NULL + ChangeLineJoin, + ChangeTextJoin, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + ChangeArcJoin, + NULL }; + static ObjectFunctionType ChangeOctagonFunctions = { - NULL, - NULL, - NULL, - ChangeViaOctagon, - ChangeElementOctagon, - NULL, - ChangePinOctagon, - NULL, - NULL, - NULL, - NULL, - NULL + NULL, + NULL, + NULL, + ChangeViaOctagon, + ChangeElementOctagon, + NULL, + ChangePinOctagon, + NULL, + NULL, + NULL, + NULL, + NULL }; + static ObjectFunctionType ChangeMaskSizeFunctions = { - NULL, - NULL, - NULL, - ChangeViaMaskSize, + NULL, + NULL, + NULL, + ChangeViaMaskSize, #if 0 - ChangeElementMaskSize, + ChangeElementMaskSize, #else - NULL, + NULL, #endif - NULL, - ChangePinMaskSize, - ChangePadMaskSize, - NULL, - NULL, - NULL, - NULL + NULL, + ChangePinMaskSize, + ChangePadMaskSize, + NULL, + NULL, + NULL, + NULL }; + static ObjectFunctionType SetSquareFunctions = { - NULL, - NULL, - NULL, - NULL, - SetElementSquare, - NULL, - SetPinSquare, - SetPadSquare, - NULL, - NULL, - NULL, - NULL + NULL, + NULL, + NULL, + NULL, + SetElementSquare, + NULL, + SetPinSquare, + SetPadSquare, + NULL, + NULL, + NULL, + NULL }; + static ObjectFunctionType SetJoinFunctions = { - SetLineJoin, - SetTextJoin, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - SetArcJoin, - NULL + SetLineJoin, + SetTextJoin, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + SetArcJoin, + NULL }; + static ObjectFunctionType SetOctagonFunctions = { - NULL, - NULL, - NULL, - SetViaOctagon, - SetElementOctagon, - NULL, - SetPinOctagon, - NULL, - NULL, - NULL, - NULL, - NULL + NULL, + NULL, + NULL, + SetViaOctagon, + SetElementOctagon, + NULL, + SetPinOctagon, + NULL, + NULL, + NULL, + NULL, + NULL }; + static ObjectFunctionType ClrSquareFunctions = { - NULL, - NULL, - NULL, - NULL, - ClrElementSquare, - NULL, - ClrPinSquare, - ClrPadSquare, - NULL, - NULL, - NULL, - NULL + NULL, + NULL, + NULL, + NULL, + ClrElementSquare, + NULL, + ClrPinSquare, + ClrPadSquare, + NULL, + NULL, + NULL, + NULL }; + static ObjectFunctionType ClrJoinFunctions = { - ClrLineJoin, - ClrTextJoin, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - ClrArcJoin, - NULL + ClrLineJoin, + ClrTextJoin, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + ClrArcJoin, + NULL }; + static ObjectFunctionType ClrOctagonFunctions = { - NULL, - NULL, - NULL, - ClrViaOctagon, - ClrElementOctagon, - NULL, - ClrPinOctagon, - NULL, - NULL, - NULL, - NULL, - NULL + NULL, + NULL, + NULL, + ClrViaOctagon, + ClrElementOctagon, + NULL, + ClrPinOctagon, + NULL, + NULL, + NULL, + NULL, + NULL }; /* --------------------------------------------------------------------------- @@ -396,20 +413,19 @@ * changes the thermal on a via * returns TRUE if changed */ -static void * -ChangeViaThermal (PinTypePtr Via) +static void *ChangeViaThermal(PinTypePtr Via) { - AddObjectToClearPolyUndoList (VIA_TYPE, Via, Via, Via, false); - RestoreToPolygon (PCB->Data, VIA_TYPE, CURRENT, Via); - AddObjectToFlagUndoList (VIA_TYPE, Via, Via, Via); - if (!Delta) /* remove the thermals */ - CLEAR_THERM (INDEXOFCURRENT, Via); - else - ASSIGN_THERM (INDEXOFCURRENT, Delta, Via); - AddObjectToClearPolyUndoList (VIA_TYPE, Via, Via, Via, true); - ClearFromPolygon (PCB->Data, VIA_TYPE, CURRENT, Via); - DrawVia (Via); - return Via; + AddObjectToClearPolyUndoList(VIA_TYPE, Via, Via, Via, false); + RestoreToPolygon(PCB->Data, VIA_TYPE, CURRENT, Via); + AddObjectToFlagUndoList(VIA_TYPE, Via, Via, Via); + if (!Delta) /* remove the thermals */ + CLEAR_THERM(INDEXOFCURRENT, Via); + else + ASSIGN_THERM(INDEXOFCURRENT, Delta, Via); + AddObjectToClearPolyUndoList(VIA_TYPE, Via, Via, Via, true); + ClearFromPolygon(PCB->Data, VIA_TYPE, CURRENT, Via); + DrawVia(Via); + return Via; } /* --------------------------------------------------------------------------- @@ -416,20 +432,19 @@ * changes the thermal on a pin * returns TRUE if changed */ -static void * -ChangePinThermal (ElementTypePtr element, PinTypePtr Pin) +static void *ChangePinThermal(ElementTypePtr element, PinTypePtr Pin) { - AddObjectToClearPolyUndoList (PIN_TYPE, element, Pin, Pin, false); - RestoreToPolygon (PCB->Data, VIA_TYPE, CURRENT, Pin); - AddObjectToFlagUndoList (PIN_TYPE, element, Pin, Pin); - if (!Delta) /* remove the thermals */ - CLEAR_THERM (INDEXOFCURRENT, Pin); - else - ASSIGN_THERM (INDEXOFCURRENT, Delta, Pin); - AddObjectToClearPolyUndoList (PIN_TYPE, element, Pin, Pin, true); - ClearFromPolygon (PCB->Data, VIA_TYPE, CURRENT, Pin); - DrawPin (Pin); - return Pin; + AddObjectToClearPolyUndoList(PIN_TYPE, element, Pin, Pin, false); + RestoreToPolygon(PCB->Data, VIA_TYPE, CURRENT, Pin); + AddObjectToFlagUndoList(PIN_TYPE, element, Pin, Pin); + if (!Delta) /* remove the thermals */ + CLEAR_THERM(INDEXOFCURRENT, Pin); + else + ASSIGN_THERM(INDEXOFCURRENT, Delta, Pin); + AddObjectToClearPolyUndoList(PIN_TYPE, element, Pin, Pin, true); + ClearFromPolygon(PCB->Data, VIA_TYPE, CURRENT, Pin); + DrawPin(Pin); + return Pin; } /* --------------------------------------------------------------------------- @@ -436,35 +451,30 @@ * changes the size of a via * returns TRUE if changed */ -static void * -ChangeViaSize (PinTypePtr Via) +static void *ChangeViaSize(PinTypePtr Via) { - Coord value = Absolute ? Absolute : Via->Thickness + Delta; + Coord value = Absolute ? Absolute : Via->Thickness + Delta; - if (TEST_FLAG (LOCKFLAG, Via)) - return (NULL); - if (!TEST_FLAG (HOLEFLAG, Via) && value <= MAX_PINORVIASIZE && - value >= MIN_PINORVIASIZE && - value >= Via->DrillingHole + MIN_PINORVIACOPPER && - value != Via->Thickness) - { - AddObjectToSizeUndoList (VIA_TYPE, Via, Via, Via); - EraseVia (Via); - r_delete_entry (PCB->Data->via_tree, (BoxType *) Via); - RestoreToPolygon (PCB->Data, PIN_TYPE, Via, Via); - if (Via->Mask) - { - AddObjectToMaskSizeUndoList (VIA_TYPE, Via, Via, Via); - Via->Mask += value - Via->Thickness; + if (TEST_FLAG(LOCKFLAG, Via)) + return (NULL); + if (!TEST_FLAG(HOLEFLAG, Via) && value <= MAX_PINORVIASIZE && + value >= MIN_PINORVIASIZE && value >= Via->DrillingHole + MIN_PINORVIACOPPER && value != Via->Thickness) { + AddObjectToSizeUndoList(VIA_TYPE, Via, Via, Via); + EraseVia(Via); + r_delete_entry(PCB->Data->via_tree, (BoxType *) Via); + RestoreToPolygon(PCB->Data, PIN_TYPE, Via, Via); + if (Via->Mask) { + AddObjectToMaskSizeUndoList(VIA_TYPE, Via, Via, Via); + Via->Mask += value - Via->Thickness; + } + Via->Thickness = value; + SetPinBoundingBox(Via); + r_insert_entry(PCB->Data->via_tree, (BoxType *) Via, 0); + ClearFromPolygon(PCB->Data, VIA_TYPE, Via, Via); + DrawVia(Via); + return (Via); } - Via->Thickness = value; - SetPinBoundingBox (Via); - r_insert_entry (PCB->Data->via_tree, (BoxType *) Via, 0); - ClearFromPolygon (PCB->Data, VIA_TYPE, Via, Via); - DrawVia (Via); - return (Via); - } - return (NULL); + return (NULL); } /* --------------------------------------------------------------------------- @@ -471,33 +481,28 @@ * changes the drilling hole of a via * returns TRUE if changed */ -static void * -ChangeVia2ndSize (PinTypePtr Via) +static void *ChangeVia2ndSize(PinTypePtr Via) { - Coord value = (Absolute) ? Absolute : Via->DrillingHole + Delta; + Coord value = (Absolute) ? Absolute : Via->DrillingHole + Delta; - if (TEST_FLAG (LOCKFLAG, Via)) - return (NULL); - if (value <= MAX_PINORVIASIZE && - value >= MIN_PINORVIAHOLE && (TEST_FLAG (HOLEFLAG, Via) || - value <= - Via->Thickness - MIN_PINORVIACOPPER) - && value != Via->DrillingHole) - { - AddObjectTo2ndSizeUndoList (VIA_TYPE, Via, Via, Via); - EraseVia (Via); - RestoreToPolygon (PCB->Data, VIA_TYPE, Via, Via); - Via->DrillingHole = value; - if (TEST_FLAG (HOLEFLAG, Via)) - { - AddObjectToSizeUndoList (VIA_TYPE, Via, Via, Via); - Via->Thickness = value; + if (TEST_FLAG(LOCKFLAG, Via)) + return (NULL); + if (value <= MAX_PINORVIASIZE && + value >= MIN_PINORVIAHOLE && (TEST_FLAG(HOLEFLAG, Via) || value <= Via->Thickness - MIN_PINORVIACOPPER) + && value != Via->DrillingHole) { + AddObjectTo2ndSizeUndoList(VIA_TYPE, Via, Via, Via); + EraseVia(Via); + RestoreToPolygon(PCB->Data, VIA_TYPE, Via, Via); + Via->DrillingHole = value; + if (TEST_FLAG(HOLEFLAG, Via)) { + AddObjectToSizeUndoList(VIA_TYPE, Via, Via, Via); + Via->Thickness = value; + } + ClearFromPolygon(PCB->Data, VIA_TYPE, Via, Via); + DrawVia(Via); + return (Via); } - ClearFromPolygon (PCB->Data, VIA_TYPE, Via, Via); - DrawVia (Via); - return (Via); - } - return (NULL); + return (NULL); } /* --------------------------------------------------------------------------- @@ -504,33 +509,32 @@ * changes the clearance size of a via * returns TRUE if changed */ -static void * -ChangeViaClearSize (PinTypePtr Via) +static void *ChangeViaClearSize(PinTypePtr Via) { - Coord value = (Absolute) ? Absolute : Via->Clearance + Delta; + Coord value = (Absolute) ? Absolute : Via->Clearance + Delta; - if (TEST_FLAG (LOCKFLAG, Via)) - return (NULL); - value = MIN (MAX_LINESIZE, value); - if (value < 0) - value = 0; - if (Delta < 0 && value < PCB->Bloat * 2) - value = 0; - if ((Delta > 0 || Absolute) && value < PCB->Bloat * 2) - value = PCB->Bloat * 2 + 2; - if (Via->Clearance == value) - return NULL; - RestoreToPolygon (PCB->Data, VIA_TYPE, Via, Via); - AddObjectToClearSizeUndoList (VIA_TYPE, Via, Via, Via); - EraseVia (Via); - r_delete_entry (PCB->Data->via_tree, (BoxType *) Via); - Via->Clearance = value; - SetPinBoundingBox (Via); - r_insert_entry (PCB->Data->via_tree, (BoxType *) Via, 0); - ClearFromPolygon (PCB->Data, VIA_TYPE, Via, Via); - DrawVia (Via); - Via->Element = NULL; - return (Via); + if (TEST_FLAG(LOCKFLAG, Via)) + return (NULL); + value = MIN(MAX_LINESIZE, value); + if (value < 0) + value = 0; + if (Delta < 0 && value < PCB->Bloat * 2) + value = 0; + if ((Delta > 0 || Absolute) && value < PCB->Bloat * 2) + value = PCB->Bloat * 2 + 2; + if (Via->Clearance == value) + return NULL; + RestoreToPolygon(PCB->Data, VIA_TYPE, Via, Via); + AddObjectToClearSizeUndoList(VIA_TYPE, Via, Via, Via); + EraseVia(Via); + r_delete_entry(PCB->Data->via_tree, (BoxType *) Via); + Via->Clearance = value; + SetPinBoundingBox(Via); + r_insert_entry(PCB->Data->via_tree, (BoxType *) Via, 0); + ClearFromPolygon(PCB->Data, VIA_TYPE, Via, Via); + DrawVia(Via); + Via->Element = NULL; + return (Via); } @@ -538,32 +542,28 @@ * changes the size of a pin * returns TRUE if changed */ -static void * -ChangePinSize (ElementTypePtr Element, PinTypePtr Pin) +static void *ChangePinSize(ElementTypePtr Element, PinTypePtr Pin) { - Coord value = (Absolute) ? Absolute : Pin->Thickness + Delta; + Coord value = (Absolute) ? Absolute : Pin->Thickness + Delta; - if (TEST_FLAG (LOCKFLAG, Pin)) - return (NULL); - if (!TEST_FLAG (HOLEFLAG, Pin) && value <= MAX_PINORVIASIZE && - value >= MIN_PINORVIASIZE && - value >= Pin->DrillingHole + MIN_PINORVIACOPPER && - value != Pin->Thickness) - { - AddObjectToSizeUndoList (PIN_TYPE, Element, Pin, Pin); - AddObjectToMaskSizeUndoList (PIN_TYPE, Element, Pin, Pin); - ErasePin (Pin); - r_delete_entry (PCB->Data->pin_tree, &Pin->BoundingBox); - RestoreToPolygon (PCB->Data, PIN_TYPE, Element, Pin); - Pin->Mask += value - Pin->Thickness; - Pin->Thickness = value; - /* SetElementBB updates all associated rtrees */ - SetElementBoundingBox (PCB->Data, Element, &PCB->Font); - ClearFromPolygon (PCB->Data, PIN_TYPE, Element, Pin); - DrawPin (Pin); - return (Pin); - } - return (NULL); + if (TEST_FLAG(LOCKFLAG, Pin)) + return (NULL); + if (!TEST_FLAG(HOLEFLAG, Pin) && value <= MAX_PINORVIASIZE && + value >= MIN_PINORVIASIZE && value >= Pin->DrillingHole + MIN_PINORVIACOPPER && value != Pin->Thickness) { + AddObjectToSizeUndoList(PIN_TYPE, Element, Pin, Pin); + AddObjectToMaskSizeUndoList(PIN_TYPE, Element, Pin, Pin); + ErasePin(Pin); + r_delete_entry(PCB->Data->pin_tree, &Pin->BoundingBox); + RestoreToPolygon(PCB->Data, PIN_TYPE, Element, Pin); + Pin->Mask += value - Pin->Thickness; + Pin->Thickness = value; + /* SetElementBB updates all associated rtrees */ + SetElementBoundingBox(PCB->Data, Element, &PCB->Font); + ClearFromPolygon(PCB->Data, PIN_TYPE, Element, Pin); + DrawPin(Pin); + return (Pin); + } + return (NULL); } /* --------------------------------------------------------------------------- @@ -570,32 +570,31 @@ * changes the clearance size of a pin * returns TRUE if changed */ -static void * -ChangePinClearSize (ElementTypePtr Element, PinTypePtr Pin) +static void *ChangePinClearSize(ElementTypePtr Element, PinTypePtr Pin) { - Coord value = (Absolute) ? Absolute : Pin->Clearance + Delta; + Coord value = (Absolute) ? Absolute : Pin->Clearance + Delta; - if (TEST_FLAG (LOCKFLAG, Pin)) - return (NULL); - value = MIN (MAX_LINESIZE, value); - if (value < 0) - value = 0; - if (Delta < 0 && value < PCB->Bloat * 2) - value = 0; - if ((Delta > 0 || Absolute) && value < PCB->Bloat * 2) - value = PCB->Bloat * 2 + 2; - if (Pin->Clearance == value) - return NULL; - RestoreToPolygon (PCB->Data, PIN_TYPE, Element, Pin); - AddObjectToClearSizeUndoList (PIN_TYPE, Element, Pin, Pin); - ErasePin (Pin); - r_delete_entry (PCB->Data->pin_tree, &Pin->BoundingBox); - Pin->Clearance = value; - /* SetElementBB updates all associated rtrees */ - SetElementBoundingBox (PCB->Data, Element, &PCB->Font); - ClearFromPolygon (PCB->Data, PIN_TYPE, Element, Pin); - DrawPin (Pin); - return (Pin); + if (TEST_FLAG(LOCKFLAG, Pin)) + return (NULL); + value = MIN(MAX_LINESIZE, value); + if (value < 0) + value = 0; + if (Delta < 0 && value < PCB->Bloat * 2) + value = 0; + if ((Delta > 0 || Absolute) && value < PCB->Bloat * 2) + value = PCB->Bloat * 2 + 2; + if (Pin->Clearance == value) + return NULL; + RestoreToPolygon(PCB->Data, PIN_TYPE, Element, Pin); + AddObjectToClearSizeUndoList(PIN_TYPE, Element, Pin, Pin); + ErasePin(Pin); + r_delete_entry(PCB->Data->pin_tree, &Pin->BoundingBox); + Pin->Clearance = value; + /* SetElementBB updates all associated rtrees */ + SetElementBoundingBox(PCB->Data, Element, &PCB->Font); + ClearFromPolygon(PCB->Data, PIN_TYPE, Element, Pin); + DrawPin(Pin); + return (Pin); } /* --------------------------------------------------------------------------- @@ -602,29 +601,27 @@ * changes the size of a pad * returns TRUE if changed */ -static void * -ChangePadSize (ElementTypePtr Element, PadTypePtr Pad) +static void *ChangePadSize(ElementTypePtr Element, PadTypePtr Pad) { - Coord value = (Absolute) ? Absolute : Pad->Thickness + Delta; + Coord value = (Absolute) ? Absolute : Pad->Thickness + Delta; - if (TEST_FLAG (LOCKFLAG, Pad)) - return (NULL); - if (value <= MAX_PADSIZE && value >= MIN_PADSIZE && value != Pad->Thickness) - { - AddObjectToSizeUndoList (PAD_TYPE, Element, Pad, Pad); - AddObjectToMaskSizeUndoList (PAD_TYPE, Element, Pad, Pad); - RestoreToPolygon (PCB->Data, PAD_TYPE, Element, Pad); - ErasePad (Pad); - r_delete_entry (PCB->Data->pad_tree, &Pad->BoundingBox); - Pad->Mask += value - Pad->Thickness; - Pad->Thickness = value; - /* SetElementBB updates all associated rtrees */ - SetElementBoundingBox (PCB->Data, Element, &PCB->Font); - ClearFromPolygon (PCB->Data, PAD_TYPE, Element, Pad); - DrawPad (Pad); - return (Pad); - } - return (NULL); + if (TEST_FLAG(LOCKFLAG, Pad)) + return (NULL); + if (value <= MAX_PADSIZE && value >= MIN_PADSIZE && value != Pad->Thickness) { + AddObjectToSizeUndoList(PAD_TYPE, Element, Pad, Pad); + AddObjectToMaskSizeUndoList(PAD_TYPE, Element, Pad, Pad); + RestoreToPolygon(PCB->Data, PAD_TYPE, Element, Pad); + ErasePad(Pad); + r_delete_entry(PCB->Data->pad_tree, &Pad->BoundingBox); + Pad->Mask += value - Pad->Thickness; + Pad->Thickness = value; + /* SetElementBB updates all associated rtrees */ + SetElementBoundingBox(PCB->Data, Element, &PCB->Font); + ClearFromPolygon(PCB->Data, PAD_TYPE, Element, Pad); + DrawPad(Pad); + return (Pad); + } + return (NULL); } /* --------------------------------------------------------------------------- @@ -631,32 +628,31 @@ * changes the clearance size of a pad * returns TRUE if changed */ -static void * -ChangePadClearSize (ElementTypePtr Element, PadTypePtr Pad) +static void *ChangePadClearSize(ElementTypePtr Element, PadTypePtr Pad) { - Coord value = (Absolute) ? Absolute : Pad->Clearance + Delta; + Coord value = (Absolute) ? Absolute : Pad->Clearance + Delta; - if (TEST_FLAG (LOCKFLAG, Pad)) - return (NULL); - value = MIN (MAX_LINESIZE, value); - if (value < 0) - value = 0; - if (Delta < 0 && value < PCB->Bloat * 2) - value = 0; - if ((Delta > 0 || Absolute) && value < PCB->Bloat * 2) - value = PCB->Bloat * 2 + 2; - if (value == Pad->Clearance) - return NULL; - AddObjectToClearSizeUndoList (PAD_TYPE, Element, Pad, Pad); - RestoreToPolygon (PCB->Data, PAD_TYPE, Element, Pad); - ErasePad (Pad); - r_delete_entry (PCB->Data->pad_tree, &Pad->BoundingBox); - Pad->Clearance = value; - /* SetElementBB updates all associated rtrees */ - SetElementBoundingBox (PCB->Data, Element, &PCB->Font); - ClearFromPolygon (PCB->Data, PAD_TYPE, Element, Pad); - DrawPad (Pad); - return Pad; + if (TEST_FLAG(LOCKFLAG, Pad)) + return (NULL); + value = MIN(MAX_LINESIZE, value); + if (value < 0) + value = 0; + if (Delta < 0 && value < PCB->Bloat * 2) + value = 0; + if ((Delta > 0 || Absolute) && value < PCB->Bloat * 2) + value = PCB->Bloat * 2 + 2; + if (value == Pad->Clearance) + return NULL; + AddObjectToClearSizeUndoList(PAD_TYPE, Element, Pad, Pad); + RestoreToPolygon(PCB->Data, PAD_TYPE, Element, Pad); + ErasePad(Pad); + r_delete_entry(PCB->Data->pad_tree, &Pad->BoundingBox); + Pad->Clearance = value; + /* SetElementBB updates all associated rtrees */ + SetElementBoundingBox(PCB->Data, Element, &PCB->Font); + ClearFromPolygon(PCB->Data, PAD_TYPE, Element, Pad); + DrawPad(Pad); + return Pad; } /* --------------------------------------------------------------------------- @@ -663,43 +659,37 @@ * changes the drilling hole of all pins of an element * returns TRUE if changed */ -static void * -ChangeElement2ndSize (ElementTypePtr Element) +static void *ChangeElement2ndSize(ElementTypePtr Element) { - bool changed = false; - Coord value; + bool changed = false; + Coord value; - if (TEST_FLAG (LOCKFLAG, Element)) - return (NULL); - PIN_LOOP (Element); - { - value = (Absolute) ? Absolute : pin->DrillingHole + Delta; - if (value <= MAX_PINORVIASIZE && - value >= MIN_PINORVIAHOLE && (TEST_FLAG (HOLEFLAG, pin) || - value <= - pin->Thickness - - MIN_PINORVIACOPPER) - && value != pin->DrillingHole) - { - changed = true; - AddObjectTo2ndSizeUndoList (PIN_TYPE, Element, pin, pin); - ErasePin (pin); - RestoreToPolygon (PCB->Data, PIN_TYPE, Element, pin); - pin->DrillingHole = value; - if (TEST_FLAG (HOLEFLAG, pin)) - { - AddObjectToSizeUndoList (PIN_TYPE, Element, pin, pin); - pin->Thickness = value; - } - ClearFromPolygon (PCB->Data, PIN_TYPE, Element, pin); - DrawPin (pin); - } - } - END_LOOP; - if (changed) - return (Element); - else - return (NULL); + if (TEST_FLAG(LOCKFLAG, Element)) + return (NULL); + PIN_LOOP(Element); + { + value = (Absolute) ? Absolute : pin->DrillingHole + Delta; + if (value <= MAX_PINORVIASIZE && + value >= MIN_PINORVIAHOLE && (TEST_FLAG(HOLEFLAG, pin) || value <= pin->Thickness - MIN_PINORVIACOPPER) + && value != pin->DrillingHole) { + changed = true; + AddObjectTo2ndSizeUndoList(PIN_TYPE, Element, pin, pin); + ErasePin(pin); + RestoreToPolygon(PCB->Data, PIN_TYPE, Element, pin); + pin->DrillingHole = value; + if (TEST_FLAG(HOLEFLAG, pin)) { + AddObjectToSizeUndoList(PIN_TYPE, Element, pin, pin); + pin->Thickness = value; + } + ClearFromPolygon(PCB->Data, PIN_TYPE, Element, pin); + DrawPin(pin); + } + } + END_LOOP; + if (changed) + return (Element); + else + return (NULL); } /* --------------------------------------------------------------------------- @@ -706,40 +696,35 @@ * changes ring dia of all pins of an element * returns TRUE if changed */ -static void * -ChangeElement1stSize (ElementTypePtr Element) +static void *ChangeElement1stSize(ElementTypePtr Element) { - bool changed = false; - Coord value; + bool changed = false; + Coord value; - if (TEST_FLAG (LOCKFLAG, Element)) - return (NULL); - PIN_LOOP (Element); - { - value = (Absolute) ? Absolute : pin->DrillingHole + Delta; - if (value <= MAX_PINORVIASIZE && - value >= pin->DrillingHole + MIN_PINORVIACOPPER - && value != pin->Thickness) - { - changed = true; - AddObjectToSizeUndoList (PIN_TYPE, Element, pin, pin); - ErasePin (pin); - RestoreToPolygon (PCB->Data, PIN_TYPE, Element, pin); - pin->Thickness = value; - if (TEST_FLAG (HOLEFLAG, pin)) - { - AddObjectToSizeUndoList (PIN_TYPE, Element, pin, pin); - pin->Thickness = value; - } - ClearFromPolygon (PCB->Data, PIN_TYPE, Element, pin); - DrawPin (pin); - } - } - END_LOOP; - if (changed) - return (Element); - else - return (NULL); + if (TEST_FLAG(LOCKFLAG, Element)) + return (NULL); + PIN_LOOP(Element); + { + value = (Absolute) ? Absolute : pin->DrillingHole + Delta; + if (value <= MAX_PINORVIASIZE && value >= pin->DrillingHole + MIN_PINORVIACOPPER && value != pin->Thickness) { + changed = true; + AddObjectToSizeUndoList(PIN_TYPE, Element, pin, pin); + ErasePin(pin); + RestoreToPolygon(PCB->Data, PIN_TYPE, Element, pin); + pin->Thickness = value; + if (TEST_FLAG(HOLEFLAG, pin)) { + AddObjectToSizeUndoList(PIN_TYPE, Element, pin, pin); + pin->Thickness = value; + } + ClearFromPolygon(PCB->Data, PIN_TYPE, Element, pin); + DrawPin(pin); + } + } + END_LOOP; + if (changed) + return (Element); + else + return (NULL); } /* --------------------------------------------------------------------------- @@ -746,71 +731,61 @@ * changes the clearance of all pins of an element * returns TRUE if changed */ -static void * -ChangeElementClearSize (ElementTypePtr Element) +static void *ChangeElementClearSize(ElementTypePtr Element) { - bool changed = false; - Coord value; + bool changed = false; + Coord value; - if (TEST_FLAG (LOCKFLAG, Element)) - return (NULL); - PIN_LOOP (Element); - { - value = (Absolute) ? Absolute : pin->Clearance + Delta; - if (value <= MAX_PINORVIASIZE && - value >= MIN_PINORVIAHOLE && (TEST_FLAG (HOLEFLAG, pin) || - value <= - pin->Thickness - - MIN_PINORVIACOPPER) - && value != pin->Clearance) - { - changed = true; - AddObjectToClearSizeUndoList (PIN_TYPE, Element, pin, pin); - ErasePin (pin); - RestoreToPolygon (PCB->Data, PIN_TYPE, Element, pin); - pin->Clearance = value; - if (TEST_FLAG (HOLEFLAG, pin)) - { - AddObjectToSizeUndoList (PIN_TYPE, Element, pin, pin); - pin->Thickness = value; - } - ClearFromPolygon (PCB->Data, PIN_TYPE, Element, pin); - DrawPin (pin); - } - } - END_LOOP; + if (TEST_FLAG(LOCKFLAG, Element)) + return (NULL); + PIN_LOOP(Element); + { + value = (Absolute) ? Absolute : pin->Clearance + Delta; + if (value <= MAX_PINORVIASIZE && + value >= MIN_PINORVIAHOLE && (TEST_FLAG(HOLEFLAG, pin) || value <= pin->Thickness - MIN_PINORVIACOPPER) + && value != pin->Clearance) { + changed = true; + AddObjectToClearSizeUndoList(PIN_TYPE, Element, pin, pin); + ErasePin(pin); + RestoreToPolygon(PCB->Data, PIN_TYPE, Element, pin); + pin->Clearance = value; + if (TEST_FLAG(HOLEFLAG, pin)) { + AddObjectToSizeUndoList(PIN_TYPE, Element, pin, pin); + pin->Thickness = value; + } + ClearFromPolygon(PCB->Data, PIN_TYPE, Element, pin); + DrawPin(pin); + } + } + END_LOOP; - PAD_LOOP (Element); - { - value = (Absolute) ? Absolute : pad->Clearance + Delta; - if (value <= MAX_PINORVIASIZE && - value >= MIN_PINORVIAHOLE - && value != pad->Clearance) - { - changed = true; - AddObjectToClearSizeUndoList (PAD_TYPE, Element, pad, pad); - ErasePad (pad); - RestoreToPolygon (PCB->Data, PAD_TYPE, Element, pad); - r_delete_entry (PCB->Data->pad_tree, &pad->BoundingBox); - pad->Clearance = value; - if (TEST_FLAG (HOLEFLAG, pad)) - { - AddObjectToSizeUndoList (PAD_TYPE, Element, pad, pad); - pad->Thickness = value; - } - /* SetElementBB updates all associated rtrees */ - SetElementBoundingBox (PCB->Data, Element, &PCB->Font); + PAD_LOOP(Element); + { + value = (Absolute) ? Absolute : pad->Clearance + Delta; + if (value <= MAX_PINORVIASIZE && value >= MIN_PINORVIAHOLE && value != pad->Clearance) { + changed = true; + AddObjectToClearSizeUndoList(PAD_TYPE, Element, pad, pad); + ErasePad(pad); + RestoreToPolygon(PCB->Data, PAD_TYPE, Element, pad); + r_delete_entry(PCB->Data->pad_tree, &pad->BoundingBox); + pad->Clearance = value; + if (TEST_FLAG(HOLEFLAG, pad)) { + AddObjectToSizeUndoList(PAD_TYPE, Element, pad, pad); + pad->Thickness = value; + } + /* SetElementBB updates all associated rtrees */ + SetElementBoundingBox(PCB->Data, Element, &PCB->Font); - ClearFromPolygon (PCB->Data, PAD_TYPE, Element, pad); - DrawPad (pad); - } - } - END_LOOP; + ClearFromPolygon(PCB->Data, PAD_TYPE, Element, pad); + DrawPad(pad); + } + } + END_LOOP; - if (changed) - return (Element); - else - return (NULL); + if (changed) + return (Element); + else + return (NULL); } /* --------------------------------------------------------------------------- @@ -817,33 +792,28 @@ * changes the drilling hole of a pin * returns TRUE if changed */ -static void * -ChangePin2ndSize (ElementTypePtr Element, PinTypePtr Pin) +static void *ChangePin2ndSize(ElementTypePtr Element, PinTypePtr Pin) { - Coord value = (Absolute) ? Absolute : Pin->DrillingHole + Delta; + Coord value = (Absolute) ? Absolute : Pin->DrillingHole + Delta; - if (TEST_FLAG (LOCKFLAG, Pin)) - return (NULL); - if (value <= MAX_PINORVIASIZE && - value >= MIN_PINORVIAHOLE && (TEST_FLAG (HOLEFLAG, Pin) || - value <= - Pin->Thickness - MIN_PINORVIACOPPER) - && value != Pin->DrillingHole) - { - AddObjectTo2ndSizeUndoList (PIN_TYPE, Element, Pin, Pin); - ErasePin (Pin); - RestoreToPolygon (PCB->Data, PIN_TYPE, Element, Pin); - Pin->DrillingHole = value; - if (TEST_FLAG (HOLEFLAG, Pin)) - { - AddObjectToSizeUndoList (PIN_TYPE, Element, Pin, Pin); - Pin->Thickness = value; + if (TEST_FLAG(LOCKFLAG, Pin)) + return (NULL); + if (value <= MAX_PINORVIASIZE && + value >= MIN_PINORVIAHOLE && (TEST_FLAG(HOLEFLAG, Pin) || value <= Pin->Thickness - MIN_PINORVIACOPPER) + && value != Pin->DrillingHole) { + AddObjectTo2ndSizeUndoList(PIN_TYPE, Element, Pin, Pin); + ErasePin(Pin); + RestoreToPolygon(PCB->Data, PIN_TYPE, Element, Pin); + Pin->DrillingHole = value; + if (TEST_FLAG(HOLEFLAG, Pin)) { + AddObjectToSizeUndoList(PIN_TYPE, Element, Pin, Pin); + Pin->Thickness = value; + } + ClearFromPolygon(PCB->Data, PIN_TYPE, Element, Pin); + DrawPin(Pin); + return (Pin); } - ClearFromPolygon (PCB->Data, PIN_TYPE, Element, Pin); - DrawPin (Pin); - return (Pin); - } - return (NULL); + return (NULL); } /* --------------------------------------------------------------------------- @@ -850,28 +820,25 @@ * changes the size of a line * returns TRUE if changed */ -static void * -ChangeLineSize (LayerTypePtr Layer, LineTypePtr Line) +static void *ChangeLineSize(LayerTypePtr Layer, LineTypePtr Line) { - Coord value = (Absolute) ? Absolute : Line->Thickness + Delta; + Coord value = (Absolute) ? Absolute : Line->Thickness + Delta; - if (TEST_FLAG (LOCKFLAG, Line)) - return (NULL); - if (value <= MAX_LINESIZE && value >= MIN_LINESIZE && - value != Line->Thickness) - { - AddObjectToSizeUndoList (LINE_TYPE, Layer, Line, Line); - EraseLine (Line); - r_delete_entry (Layer->line_tree, (BoxTypePtr) Line); - RestoreToPolygon (PCB->Data, LINE_TYPE, Layer, Line); - Line->Thickness = value; - SetLineBoundingBox (Line); - r_insert_entry (Layer->line_tree, (BoxTypePtr) Line, 0); - ClearFromPolygon (PCB->Data, LINE_TYPE, Layer, Line); - DrawLine (Layer, Line); - return (Line); - } - return (NULL); + if (TEST_FLAG(LOCKFLAG, Line)) + return (NULL); + if (value <= MAX_LINESIZE && value >= MIN_LINESIZE && value != Line->Thickness) { + AddObjectToSizeUndoList(LINE_TYPE, Layer, Line, Line); + EraseLine(Line); + r_delete_entry(Layer->line_tree, (BoxTypePtr) Line); + RestoreToPolygon(PCB->Data, LINE_TYPE, Layer, Line); + Line->Thickness = value; + SetLineBoundingBox(Line); + r_insert_entry(Layer->line_tree, (BoxTypePtr) Line, 0); + ClearFromPolygon(PCB->Data, LINE_TYPE, Layer, Line); + DrawLine(Layer, Line); + return (Line); + } + return (NULL); } /* --------------------------------------------------------------------------- @@ -878,53 +845,47 @@ * changes the clearance size of a line * returns TRUE if changed */ -static void * -ChangeLineClearSize (LayerTypePtr Layer, LineTypePtr Line) +static void *ChangeLineClearSize(LayerTypePtr Layer, LineTypePtr Line) { - Coord value = (Absolute) ? Absolute : Line->Clearance + Delta; + Coord value = (Absolute) ? Absolute : Line->Clearance + Delta; - if (TEST_FLAG (LOCKFLAG, Line) || !TEST_FLAG (CLEARLINEFLAG, Line)) - return (NULL); - value = MIN (MAX_LINESIZE, MAX (value, PCB->Bloat * 2 + 2)); - if (value != Line->Clearance) - { - AddObjectToClearSizeUndoList (LINE_TYPE, Layer, Line, Line); - RestoreToPolygon (PCB->Data, LINE_TYPE, Layer, Line); - EraseLine (Line); - r_delete_entry (Layer->line_tree, (BoxTypePtr) Line); - Line->Clearance = value; - if (Line->Clearance == 0) - { - CLEAR_FLAG (CLEARLINEFLAG, Line); - Line->Clearance = MIL_TO_COORD(10); + if (TEST_FLAG(LOCKFLAG, Line) || !TEST_FLAG(CLEARLINEFLAG, Line)) + return (NULL); + value = MIN(MAX_LINESIZE, MAX(value, PCB->Bloat * 2 + 2)); + if (value != Line->Clearance) { + AddObjectToClearSizeUndoList(LINE_TYPE, Layer, Line, Line); + RestoreToPolygon(PCB->Data, LINE_TYPE, Layer, Line); + EraseLine(Line); + r_delete_entry(Layer->line_tree, (BoxTypePtr) Line); + Line->Clearance = value; + if (Line->Clearance == 0) { + CLEAR_FLAG(CLEARLINEFLAG, Line); + Line->Clearance = MIL_TO_COORD(10); + } + SetLineBoundingBox(Line); + r_insert_entry(Layer->line_tree, (BoxTypePtr) Line, 0); + ClearFromPolygon(PCB->Data, LINE_TYPE, Layer, Line); + DrawLine(Layer, Line); + return (Line); } - SetLineBoundingBox (Line); - r_insert_entry (Layer->line_tree, (BoxTypePtr) Line, 0); - ClearFromPolygon (PCB->Data, LINE_TYPE, Layer, Line); - DrawLine (Layer, Line); - return (Line); - } - return (NULL); + return (NULL); } /* --------------------------------------------------------------------------- * Handle attepts to change the clearance of a polygon. */ -static void * -ChangePolygonClearSize (LayerTypePtr Layer, PolygonTypePtr poly) +static void *ChangePolygonClearSize(LayerTypePtr Layer, PolygonTypePtr poly) { - static int shown_this_message = 0; - if (!shown_this_message) - { - gui->confirm_dialog (_("To change the clearance of objects in a polygon, " - "change the objects, not the polygon.\n" - "Hint: To set a minimum clearance for a group of objects, " - "select them all then :MinClearGap(Selected,=10,mil)"), - "Ok", NULL); - shown_this_message = 1; - } + static int shown_this_message = 0; + if (!shown_this_message) { + gui->confirm_dialog(_("To change the clearance of objects in a polygon, " + "change the objects, not the polygon.\n" + "Hint: To set a minimum clearance for a group of objects, " + "select them all then :MinClearGap(Selected,=10,mil)"), "Ok", NULL); + shown_this_message = 1; + } - return (NULL); + return (NULL); } /* --------------------------------------------------------------------------- @@ -931,28 +892,25 @@ * changes the size of an arc * returns TRUE if changed */ -static void * -ChangeArcSize (LayerTypePtr Layer, ArcTypePtr Arc) +static void *ChangeArcSize(LayerTypePtr Layer, ArcTypePtr Arc) { - Coord value = (Absolute) ? Absolute : Arc->Thickness + Delta; + Coord value = (Absolute) ? Absolute : Arc->Thickness + Delta; - if (TEST_FLAG (LOCKFLAG, Arc)) - return (NULL); - if (value <= MAX_LINESIZE && value >= MIN_LINESIZE && - value != Arc->Thickness) - { - AddObjectToSizeUndoList (ARC_TYPE, Layer, Arc, Arc); - EraseArc (Arc); - r_delete_entry (Layer->arc_tree, (BoxTypePtr) Arc); - RestoreToPolygon (PCB->Data, ARC_TYPE, Layer, Arc); - Arc->Thickness = value; - SetArcBoundingBox (Arc); - r_insert_entry (Layer->arc_tree, (BoxTypePtr) Arc, 0); - ClearFromPolygon (PCB->Data, ARC_TYPE, Layer, Arc); - DrawArc (Layer, Arc); - return (Arc); - } - return (NULL); + if (TEST_FLAG(LOCKFLAG, Arc)) + return (NULL); + if (value <= MAX_LINESIZE && value >= MIN_LINESIZE && value != Arc->Thickness) { + AddObjectToSizeUndoList(ARC_TYPE, Layer, Arc, Arc); + EraseArc(Arc); + r_delete_entry(Layer->arc_tree, (BoxTypePtr) Arc); + RestoreToPolygon(PCB->Data, ARC_TYPE, Layer, Arc); + Arc->Thickness = value; + SetArcBoundingBox(Arc); + r_insert_entry(Layer->arc_tree, (BoxTypePtr) Arc, 0); + ClearFromPolygon(PCB->Data, ARC_TYPE, Layer, Arc); + DrawArc(Layer, Arc); + return (Arc); + } + return (NULL); } /* --------------------------------------------------------------------------- @@ -959,33 +917,30 @@ * changes the clearance size of an arc * returns TRUE if changed */ -static void * -ChangeArcClearSize (LayerTypePtr Layer, ArcTypePtr Arc) +static void *ChangeArcClearSize(LayerTypePtr Layer, ArcTypePtr Arc) { - Coord value = (Absolute) ? Absolute : Arc->Clearance + Delta; + Coord value = (Absolute) ? Absolute : Arc->Clearance + Delta; - if (TEST_FLAG (LOCKFLAG, Arc) || !TEST_FLAG (CLEARLINEFLAG, Arc)) - return (NULL); - value = MIN (MAX_LINESIZE, MAX (value, PCB->Bloat * 2 + 2)); - if (value != Arc->Clearance) - { - AddObjectToClearSizeUndoList (ARC_TYPE, Layer, Arc, Arc); - EraseArc (Arc); - r_delete_entry (Layer->arc_tree, (BoxTypePtr) Arc); - RestoreToPolygon (PCB->Data, ARC_TYPE, Layer, Arc); - Arc->Clearance = value; - if (Arc->Clearance == 0) - { - CLEAR_FLAG (CLEARLINEFLAG, Arc); - Arc->Clearance = MIL_TO_COORD(10); + if (TEST_FLAG(LOCKFLAG, Arc) || !TEST_FLAG(CLEARLINEFLAG, Arc)) + return (NULL); + value = MIN(MAX_LINESIZE, MAX(value, PCB->Bloat * 2 + 2)); + if (value != Arc->Clearance) { + AddObjectToClearSizeUndoList(ARC_TYPE, Layer, Arc, Arc); + EraseArc(Arc); + r_delete_entry(Layer->arc_tree, (BoxTypePtr) Arc); + RestoreToPolygon(PCB->Data, ARC_TYPE, Layer, Arc); + Arc->Clearance = value; + if (Arc->Clearance == 0) { + CLEAR_FLAG(CLEARLINEFLAG, Arc); + Arc->Clearance = MIL_TO_COORD(10); + } + SetArcBoundingBox(Arc); + r_insert_entry(Layer->arc_tree, (BoxTypePtr) Arc, 0); + ClearFromPolygon(PCB->Data, ARC_TYPE, Layer, Arc); + DrawArc(Layer, Arc); + return (Arc); } - SetArcBoundingBox (Arc); - r_insert_entry (Layer->arc_tree, (BoxTypePtr) Arc, 0); - ClearFromPolygon (PCB->Data, ARC_TYPE, Layer, Arc); - DrawArc (Layer, Arc); - return (Arc); - } - return (NULL); + return (NULL); } /* --------------------------------------------------------------------------- @@ -992,29 +947,26 @@ * changes the scaling factor of a text object * returns TRUE if changed */ -static void * -ChangeTextSize (LayerTypePtr Layer, TextTypePtr Text) +static void *ChangeTextSize(LayerTypePtr Layer, TextTypePtr Text) { - int value = Absolute ? COORD_TO_MIL (Absolute) - : Text->Scale + COORD_TO_MIL (Delta); + int value = Absolute ? COORD_TO_MIL(Absolute) + : Text->Scale + COORD_TO_MIL(Delta); - if (TEST_FLAG (LOCKFLAG, Text)) - return (NULL); - if (value <= MAX_TEXTSCALE && value >= MIN_TEXTSCALE && - value != Text->Scale) - { - AddObjectToSizeUndoList (TEXT_TYPE, Layer, Text, Text); - EraseText (Layer, Text); - r_delete_entry (Layer->text_tree, (BoxTypePtr) Text); - RestoreToPolygon (PCB->Data, TEXT_TYPE, Layer, Text); - Text->Scale = value; - SetTextBoundingBox (&PCB->Font, Text); - r_insert_entry (Layer->text_tree, (BoxTypePtr) Text, 0); - ClearFromPolygon (PCB->Data, TEXT_TYPE, Layer, Text); - DrawText (Layer, Text); - return (Text); - } - return (NULL); + if (TEST_FLAG(LOCKFLAG, Text)) + return (NULL); + if (value <= MAX_TEXTSCALE && value >= MIN_TEXTSCALE && value != Text->Scale) { + AddObjectToSizeUndoList(TEXT_TYPE, Layer, Text, Text); + EraseText(Layer, Text); + r_delete_entry(Layer->text_tree, (BoxTypePtr) Text); + RestoreToPolygon(PCB->Data, TEXT_TYPE, Layer, Text); + Text->Scale = value; + SetTextBoundingBox(&PCB->Font, Text); + r_insert_entry(Layer->text_tree, (BoxTypePtr) Text, 0); + ClearFromPolygon(PCB->Data, TEXT_TYPE, Layer, Text); + DrawText(Layer, Text); + return (Text); + } + return (NULL); } /* --------------------------------------------------------------------------- @@ -1021,47 +973,41 @@ * changes the scaling factor of an element's outline * returns TRUE if changed */ -static void * -ChangeElementSize (ElementTypePtr Element) +static void *ChangeElementSize(ElementTypePtr Element) { - Coord value; - bool changed = false; + Coord value; + bool changed = false; - if (TEST_FLAG (LOCKFLAG, Element)) - return (NULL); - if (PCB->ElementOn) - EraseElement (Element); - ELEMENTLINE_LOOP (Element); - { - value = (Absolute) ? Absolute : line->Thickness + Delta; - if (value <= MAX_LINESIZE && value >= MIN_LINESIZE && - value != line->Thickness) - { - AddObjectToSizeUndoList (ELEMENTLINE_TYPE, Element, line, line); - line->Thickness = value; - changed = true; - } - } - END_LOOP; - ARC_LOOP (Element); - { - value = (Absolute) ? Absolute : arc->Thickness + Delta; - if (value <= MAX_LINESIZE && value >= MIN_LINESIZE && - value != arc->Thickness) - { - AddObjectToSizeUndoList (ELEMENTARC_TYPE, Element, arc, arc); - arc->Thickness = value; - changed = true; - } - } - END_LOOP; - if (PCB->ElementOn) - { - DrawElement (Element); - } - if (changed) - return (Element); - return (NULL); + if (TEST_FLAG(LOCKFLAG, Element)) + return (NULL); + if (PCB->ElementOn) + EraseElement(Element); + ELEMENTLINE_LOOP(Element); + { + value = (Absolute) ? Absolute : line->Thickness + Delta; + if (value <= MAX_LINESIZE && value >= MIN_LINESIZE && value != line->Thickness) { + AddObjectToSizeUndoList(ELEMENTLINE_TYPE, Element, line, line); + line->Thickness = value; + changed = true; + } + } + END_LOOP; + ARC_LOOP(Element); + { + value = (Absolute) ? Absolute : arc->Thickness + Delta; + if (value <= MAX_LINESIZE && value >= MIN_LINESIZE && value != arc->Thickness) { + AddObjectToSizeUndoList(ELEMENTARC_TYPE, Element, arc, arc); + arc->Thickness = value; + changed = true; + } + } + END_LOOP; + if (PCB->ElementOn) { + DrawElement(Element); + } + if (changed) + return (Element); + return (NULL); } /* --------------------------------------------------------------------------- @@ -1068,142 +1014,129 @@ * changes the scaling factor of a elementname object * returns TRUE if changed */ -static void * -ChangeElementNameSize (ElementTypePtr Element) +static void *ChangeElementNameSize(ElementTypePtr Element) { - int value = Absolute ? COORD_TO_MIL (Absolute) - : DESCRIPTION_TEXT (Element).Scale + COORD_TO_MIL (Delta); + int value = Absolute ? COORD_TO_MIL(Absolute) + : DESCRIPTION_TEXT(Element).Scale + COORD_TO_MIL(Delta); - if (TEST_FLAG (LOCKFLAG, &Element->Name[0])) - return (NULL); - if (value <= MAX_TEXTSCALE && value >= MIN_TEXTSCALE) - { - EraseElementName (Element); - ELEMENTTEXT_LOOP (Element); - { - AddObjectToSizeUndoList (ELEMENTNAME_TYPE, Element, text, text); - r_delete_entry (PCB->Data->name_tree[n], (BoxType *) text); - text->Scale = value; - SetTextBoundingBox (&PCB->Font, text); - r_insert_entry (PCB->Data->name_tree[n], (BoxType *) text, 0); - } - END_LOOP; - DrawElementName (Element); - return (Element); - } - return (NULL); + if (TEST_FLAG(LOCKFLAG, &Element->Name[0])) + return (NULL); + if (value <= MAX_TEXTSCALE && value >= MIN_TEXTSCALE) { + EraseElementName(Element); + ELEMENTTEXT_LOOP(Element); + { + AddObjectToSizeUndoList(ELEMENTNAME_TYPE, Element, text, text); + r_delete_entry(PCB->Data->name_tree[n], (BoxType *) text); + text->Scale = value; + SetTextBoundingBox(&PCB->Font, text); + r_insert_entry(PCB->Data->name_tree[n], (BoxType *) text, 0); + } + END_LOOP; + DrawElementName(Element); + return (Element); + } + return (NULL); } /* --------------------------------------------------------------------------- * changes the name of a via */ -static void * -ChangeViaName (PinTypePtr Via) +static void *ChangeViaName(PinTypePtr Via) { - char *old = Via->Name; + char *old = Via->Name; - if (TEST_FLAG (DISPLAYNAMEFLAG, Via)) - { - ErasePinName (Via); - Via->Name = NewName; - DrawPinName (Via); - } - else - Via->Name = NewName; - return (old); + if (TEST_FLAG(DISPLAYNAMEFLAG, Via)) { + ErasePinName(Via); + Via->Name = NewName; + DrawPinName(Via); + } + else + Via->Name = NewName; + return (old); } /* --------------------------------------------------------------------------- * changes the name of a pin */ -static void * -ChangePinName (ElementTypePtr Element, PinTypePtr Pin) +static void *ChangePinName(ElementTypePtr Element, PinTypePtr Pin) { - char *old = Pin->Name; + char *old = Pin->Name; - Element = Element; /* get rid of 'unused...' warnings */ - if (TEST_FLAG (DISPLAYNAMEFLAG, Pin)) - { - ErasePinName (Pin); - Pin->Name = NewName; - DrawPinName (Pin); - } - else - Pin->Name = NewName; - return (old); + Element = Element; /* get rid of 'unused...' warnings */ + if (TEST_FLAG(DISPLAYNAMEFLAG, Pin)) { + ErasePinName(Pin); + Pin->Name = NewName; + DrawPinName(Pin); + } + else + Pin->Name = NewName; + return (old); } /* --------------------------------------------------------------------------- * changes the name of a pad */ -static void * -ChangePadName (ElementTypePtr Element, PadTypePtr Pad) +static void *ChangePadName(ElementTypePtr Element, PadTypePtr Pad) { - char *old = Pad->Name; + char *old = Pad->Name; - Element = Element; /* get rid of 'unused...' warnings */ - if (TEST_FLAG (DISPLAYNAMEFLAG, Pad)) - { - ErasePadName (Pad); - Pad->Name = NewName; - DrawPadName (Pad); - } - else - Pad->Name = NewName; - return (old); + Element = Element; /* get rid of 'unused...' warnings */ + if (TEST_FLAG(DISPLAYNAMEFLAG, Pad)) { + ErasePadName(Pad); + Pad->Name = NewName; + DrawPadName(Pad); + } + else + Pad->Name = NewName; + return (old); } /* --------------------------------------------------------------------------- * changes the number of a pin */ -static void * -ChangePinNum (ElementTypePtr Element, PinTypePtr Pin) +static void *ChangePinNum(ElementTypePtr Element, PinTypePtr Pin) { - char *old = Pin->Number; + char *old = Pin->Number; - Element = Element; /* get rid of 'unused...' warnings */ - if (TEST_FLAG (DISPLAYNAMEFLAG, Pin)) - { - ErasePinName (Pin); - Pin->Number = NewName; - DrawPinName (Pin); - } - else - Pin->Number = NewName; - return (old); + Element = Element; /* get rid of 'unused...' warnings */ + if (TEST_FLAG(DISPLAYNAMEFLAG, Pin)) { + ErasePinName(Pin); + Pin->Number = NewName; + DrawPinName(Pin); + } + else + Pin->Number = NewName; + return (old); } /* --------------------------------------------------------------------------- * changes the number of a pad */ -static void * -ChangePadNum (ElementTypePtr Element, PadTypePtr Pad) +static void *ChangePadNum(ElementTypePtr Element, PadTypePtr Pad) { - char *old = Pad->Number; + char *old = Pad->Number; - Element = Element; /* get rid of 'unused...' warnings */ - if (TEST_FLAG (DISPLAYNAMEFLAG, Pad)) - { - ErasePadName (Pad); - Pad->Number = NewName; - DrawPadName (Pad); - } - else - Pad->Number = NewName; - return (old); + Element = Element; /* get rid of 'unused...' warnings */ + if (TEST_FLAG(DISPLAYNAMEFLAG, Pad)) { + ErasePadName(Pad); + Pad->Number = NewName; + DrawPadName(Pad); + } + else + Pad->Number = NewName; + return (old); } /* --------------------------------------------------------------------------- * changes the name of a line */ -static void * -ChangeLineName (LayerTypePtr Layer, LineTypePtr Line) +static void *ChangeLineName(LayerTypePtr Layer, LineTypePtr Line) { - char *old = Line->Number; + char *old = Line->Number; - Layer = Layer; - Line->Number = NewName; - return (old); + Layer = Layer; + Line->Number = NewName; + return (old); } /* --------------------------------------------------------------------------- @@ -1210,55 +1143,47 @@ * changes the layout-name of an element */ -char * -ChangeElementText (PCBType *pcb, DataType *data, ElementTypePtr Element, int which, char *new_name) +char *ChangeElementText(PCBType * pcb, DataType * data, ElementTypePtr Element, int which, char *new_name) { - char *old = Element->Name[which].TextString; + char *old = Element->Name[which].TextString; #ifdef DEBUG - printf("In ChangeElementText, updating old TextString %s to %s\n", old, new_name); + printf("In ChangeElementText, updating old TextString %s to %s\n", old, new_name); #endif - if (pcb && which == NAME_INDEX (pcb)) - EraseElementName (Element); + if (pcb && which == NAME_INDEX(pcb)) + EraseElementName(Element); - r_delete_entry (data->name_tree[which], - & Element->Name[which].BoundingBox); + r_delete_entry(data->name_tree[which], &Element->Name[which].BoundingBox); - Element->Name[which].TextString = new_name; - SetTextBoundingBox (&PCB->Font, &Element->Name[which]); + Element->Name[which].TextString = new_name; + SetTextBoundingBox(&PCB->Font, &Element->Name[which]); - r_insert_entry (data->name_tree[which], - & Element->Name[which].BoundingBox, 0); + r_insert_entry(data->name_tree[which], &Element->Name[which].BoundingBox, 0); - if (pcb && which == NAME_INDEX (pcb)) - DrawElementName (Element); + if (pcb && which == NAME_INDEX(pcb)) + DrawElementName(Element); - return old; + return old; } -static void * -ChangeElementName (ElementTypePtr Element) +static void *ChangeElementName(ElementTypePtr Element) { - if (TEST_FLAG (LOCKFLAG, &Element->Name[0])) - return (NULL); - if (NAME_INDEX (PCB) == NAMEONPCB_INDEX) - { - if (TEST_FLAG (UNIQUENAMEFLAG, PCB) && - UniqueElementName (PCB->Data, NewName) != NewName) - { - Message (_("Error: The name \"%s\" is not unique!\n"), NewName); - return ((char *) -1); + if (TEST_FLAG(LOCKFLAG, &Element->Name[0])) + return (NULL); + if (NAME_INDEX(PCB) == NAMEONPCB_INDEX) { + if (TEST_FLAG(UNIQUENAMEFLAG, PCB) && UniqueElementName(PCB->Data, NewName) != NewName) { + Message(_("Error: The name \"%s\" is not unique!\n"), NewName); + return ((char *) -1); + } } - } - return ChangeElementText (PCB, PCB->Data, Element, NAME_INDEX (PCB), NewName); + return ChangeElementText(PCB, PCB->Data, Element, NAME_INDEX(PCB), NewName); } -static void * -ChangeElementNonetlist (ElementTypePtr Element) +static void *ChangeElementNonetlist(ElementTypePtr Element) { - if (TEST_FLAG (LOCKFLAG, Element)) + if (TEST_FLAG(LOCKFLAG, Element)) return (NULL); TOGGLE_FLAG(NONETLISTFLAG, Element); return Element; @@ -1270,34 +1195,32 @@ * the one for the new string is allocated * returns true if the string has been changed */ -static void * -ChangeTextName (LayerTypePtr Layer, TextTypePtr Text) +static void *ChangeTextName(LayerTypePtr Layer, TextTypePtr Text) { - char *old = Text->TextString; + char *old = Text->TextString; - if (TEST_FLAG (LOCKFLAG, Text)) - return (NULL); - EraseText (Layer, Text); - RestoreToPolygon (PCB->Data, TEXT_TYPE, Layer, Text); - Text->TextString = NewName; + if (TEST_FLAG(LOCKFLAG, Text)) + return (NULL); + EraseText(Layer, Text); + RestoreToPolygon(PCB->Data, TEXT_TYPE, Layer, Text); + Text->TextString = NewName; - /* calculate size of the bounding box */ - SetTextBoundingBox (&PCB->Font, Text); - ClearFromPolygon (PCB->Data, TEXT_TYPE, Layer, Text); - DrawText (Layer, Text); - return (old); + /* calculate size of the bounding box */ + SetTextBoundingBox(&PCB->Font, Text); + ClearFromPolygon(PCB->Data, TEXT_TYPE, Layer, Text); + DrawText(Layer, Text); + return (old); } /* --------------------------------------------------------------------------- * changes the name of a layout; memory has to be already allocated */ -bool -ChangeLayoutName (char *Name) +bool ChangeLayoutName(char *Name) { - free (PCB->Name); - PCB->Name = Name; - hid_action ("PCBChanged"); - return (true); + free(PCB->Name); + PCB->Name = Name; + hid_action("PCBChanged"); + return (true); } /* --------------------------------------------------------------------------- @@ -1304,327 +1227,302 @@ * changes the side of the board an element is on * returns TRUE if done */ -bool -ChangeElementSide (ElementTypePtr Element, Coord yoff) +bool ChangeElementSide(ElementTypePtr Element, Coord yoff) { - if (TEST_FLAG (LOCKFLAG, Element)) - return (false); - EraseElement (Element); - AddObjectToMirrorUndoList (ELEMENT_TYPE, Element, Element, Element, yoff); - MirrorElementCoordinates (PCB->Data, Element, yoff); - DrawElement (Element); - return (true); + if (TEST_FLAG(LOCKFLAG, Element)) + return (false); + EraseElement(Element); + AddObjectToMirrorUndoList(ELEMENT_TYPE, Element, Element, Element, yoff); + MirrorElementCoordinates(PCB->Data, Element, yoff); + DrawElement(Element); + return (true); } /* --------------------------------------------------------------------------- * changes the name of a layer; memory has to be already allocated */ -bool -ChangeLayerName (LayerTypePtr Layer, char *Name) +bool ChangeLayerName(LayerTypePtr Layer, char *Name) { - free (CURRENT->Name); - CURRENT->Name = Name; - hid_action ("LayersChanged"); - return (true); + free(CURRENT->Name); + CURRENT->Name = Name; + hid_action("LayersChanged"); + return (true); } /* --------------------------------------------------------------------------- * changes the clearance flag of a line */ -static void * -ChangeLineJoin (LayerTypePtr Layer, LineTypePtr Line) +static void *ChangeLineJoin(LayerTypePtr Layer, LineTypePtr Line) { - if (TEST_FLAG (LOCKFLAG, Line)) - return (NULL); - EraseLine (Line); - if (TEST_FLAG(CLEARLINEFLAG, Line)) - { - AddObjectToClearPolyUndoList (LINE_TYPE, Layer, Line, Line, false); - RestoreToPolygon (PCB->Data, LINE_TYPE, Layer, Line); - } - AddObjectToFlagUndoList (LINE_TYPE, Layer, Line, Line); - TOGGLE_FLAG (CLEARLINEFLAG, Line); - if (TEST_FLAG(CLEARLINEFLAG, Line)) - { - AddObjectToClearPolyUndoList (LINE_TYPE, Layer, Line, Line, true); - ClearFromPolygon (PCB->Data, LINE_TYPE, Layer, Line); - } - DrawLine (Layer, Line); - return (Line); + if (TEST_FLAG(LOCKFLAG, Line)) + return (NULL); + EraseLine(Line); + if (TEST_FLAG(CLEARLINEFLAG, Line)) { + AddObjectToClearPolyUndoList(LINE_TYPE, Layer, Line, Line, false); + RestoreToPolygon(PCB->Data, LINE_TYPE, Layer, Line); + } + AddObjectToFlagUndoList(LINE_TYPE, Layer, Line, Line); + TOGGLE_FLAG(CLEARLINEFLAG, Line); + if (TEST_FLAG(CLEARLINEFLAG, Line)) { + AddObjectToClearPolyUndoList(LINE_TYPE, Layer, Line, Line, true); + ClearFromPolygon(PCB->Data, LINE_TYPE, Layer, Line); + } + DrawLine(Layer, Line); + return (Line); } /* --------------------------------------------------------------------------- * sets the clearance flag of a line */ -static void * -SetLineJoin (LayerTypePtr Layer, LineTypePtr Line) +static void *SetLineJoin(LayerTypePtr Layer, LineTypePtr Line) { - if (TEST_FLAG (LOCKFLAG, Line) || TEST_FLAG (CLEARLINEFLAG, Line)) - return (NULL); - return ChangeLineJoin (Layer, Line); + if (TEST_FLAG(LOCKFLAG, Line) || TEST_FLAG(CLEARLINEFLAG, Line)) + return (NULL); + return ChangeLineJoin(Layer, Line); } /* --------------------------------------------------------------------------- * clears the clearance flag of a line */ -static void * -ClrLineJoin (LayerTypePtr Layer, LineTypePtr Line) +static void *ClrLineJoin(LayerTypePtr Layer, LineTypePtr Line) { - if (TEST_FLAG (LOCKFLAG, Line) || !TEST_FLAG (CLEARLINEFLAG, Line)) - return (NULL); - return ChangeLineJoin (Layer, Line); + if (TEST_FLAG(LOCKFLAG, Line) || !TEST_FLAG(CLEARLINEFLAG, Line)) + return (NULL); + return ChangeLineJoin(Layer, Line); } /* --------------------------------------------------------------------------- * changes the clearance flag of an arc */ -static void * -ChangeArcJoin (LayerTypePtr Layer, ArcTypePtr Arc) +static void *ChangeArcJoin(LayerTypePtr Layer, ArcTypePtr Arc) { - if (TEST_FLAG (LOCKFLAG, Arc)) - return (NULL); - EraseArc (Arc); - if (TEST_FLAG (CLEARLINEFLAG, Arc)) - { - RestoreToPolygon (PCB->Data, ARC_TYPE, Layer, Arc); - AddObjectToClearPolyUndoList (ARC_TYPE, Layer, Arc, Arc, false); - } - AddObjectToFlagUndoList (ARC_TYPE, Layer, Arc, Arc); - TOGGLE_FLAG (CLEARLINEFLAG, Arc); - if (TEST_FLAG (CLEARLINEFLAG, Arc)) - { - ClearFromPolygon (PCB->Data, ARC_TYPE, Layer, Arc); - AddObjectToClearPolyUndoList (ARC_TYPE, Layer, Arc, Arc, true); - } - DrawArc (Layer, Arc); - return (Arc); + if (TEST_FLAG(LOCKFLAG, Arc)) + return (NULL); + EraseArc(Arc); + if (TEST_FLAG(CLEARLINEFLAG, Arc)) { + RestoreToPolygon(PCB->Data, ARC_TYPE, Layer, Arc); + AddObjectToClearPolyUndoList(ARC_TYPE, Layer, Arc, Arc, false); + } + AddObjectToFlagUndoList(ARC_TYPE, Layer, Arc, Arc); + TOGGLE_FLAG(CLEARLINEFLAG, Arc); + if (TEST_FLAG(CLEARLINEFLAG, Arc)) { + ClearFromPolygon(PCB->Data, ARC_TYPE, Layer, Arc); + AddObjectToClearPolyUndoList(ARC_TYPE, Layer, Arc, Arc, true); + } + DrawArc(Layer, Arc); + return (Arc); } /* --------------------------------------------------------------------------- * sets the clearance flag of an arc */ -static void * -SetArcJoin (LayerTypePtr Layer, ArcTypePtr Arc) +static void *SetArcJoin(LayerTypePtr Layer, ArcTypePtr Arc) { - if (TEST_FLAG (LOCKFLAG, Arc) || TEST_FLAG (CLEARLINEFLAG, Arc)) - return (NULL); - return ChangeArcJoin (Layer, Arc); + if (TEST_FLAG(LOCKFLAG, Arc) || TEST_FLAG(CLEARLINEFLAG, Arc)) + return (NULL); + return ChangeArcJoin(Layer, Arc); } /* --------------------------------------------------------------------------- * clears the clearance flag of an arc */ -static void * -ClrArcJoin (LayerTypePtr Layer, ArcTypePtr Arc) +static void *ClrArcJoin(LayerTypePtr Layer, ArcTypePtr Arc) { - if (TEST_FLAG (LOCKFLAG, Arc) || !TEST_FLAG (CLEARLINEFLAG, Arc)) - return (NULL); - return ChangeArcJoin (Layer, Arc); + if (TEST_FLAG(LOCKFLAG, Arc) || !TEST_FLAG(CLEARLINEFLAG, Arc)) + return (NULL); + return ChangeArcJoin(Layer, Arc); } /* --------------------------------------------------------------------------- * changes the clearance flag of a text */ -static void * -ChangeTextJoin (LayerTypePtr Layer, TextTypePtr Text) +static void *ChangeTextJoin(LayerTypePtr Layer, TextTypePtr Text) { - if (TEST_FLAG (LOCKFLAG, Text)) - return (NULL); - EraseText (Layer, Text); - if (TEST_FLAG(CLEARLINEFLAG, Text)) - { - AddObjectToClearPolyUndoList (TEXT_TYPE, Layer, Text, Text, false); - RestoreToPolygon (PCB->Data, TEXT_TYPE, Layer, Text); - } - AddObjectToFlagUndoList (LINE_TYPE, Layer, Text, Text); - TOGGLE_FLAG (CLEARLINEFLAG, Text); - if (TEST_FLAG(CLEARLINEFLAG, Text)) - { - AddObjectToClearPolyUndoList (TEXT_TYPE, Layer, Text, Text, true); - ClearFromPolygon (PCB->Data, TEXT_TYPE, Layer, Text); - } - DrawText (Layer, Text); - return (Text); + if (TEST_FLAG(LOCKFLAG, Text)) + return (NULL); + EraseText(Layer, Text); + if (TEST_FLAG(CLEARLINEFLAG, Text)) { + AddObjectToClearPolyUndoList(TEXT_TYPE, Layer, Text, Text, false); + RestoreToPolygon(PCB->Data, TEXT_TYPE, Layer, Text); + } + AddObjectToFlagUndoList(LINE_TYPE, Layer, Text, Text); + TOGGLE_FLAG(CLEARLINEFLAG, Text); + if (TEST_FLAG(CLEARLINEFLAG, Text)) { + AddObjectToClearPolyUndoList(TEXT_TYPE, Layer, Text, Text, true); + ClearFromPolygon(PCB->Data, TEXT_TYPE, Layer, Text); + } + DrawText(Layer, Text); + return (Text); } /* --------------------------------------------------------------------------- * sets the clearance flag of a text */ -static void * -SetTextJoin (LayerTypePtr Layer, TextTypePtr Text) +static void *SetTextJoin(LayerTypePtr Layer, TextTypePtr Text) { - if (TEST_FLAG (LOCKFLAG, Text) || TEST_FLAG (CLEARLINEFLAG, Text)) - return (NULL); - return ChangeTextJoin (Layer, Text); + if (TEST_FLAG(LOCKFLAG, Text) || TEST_FLAG(CLEARLINEFLAG, Text)) + return (NULL); + return ChangeTextJoin(Layer, Text); } /* --------------------------------------------------------------------------- * clears the clearance flag of a text */ -static void * -ClrTextJoin (LayerTypePtr Layer, TextTypePtr Text) +static void *ClrTextJoin(LayerTypePtr Layer, TextTypePtr Text) { - if (TEST_FLAG (LOCKFLAG, Text) || !TEST_FLAG (CLEARLINEFLAG, Text)) - return (NULL); - return ChangeTextJoin (Layer, Text); + if (TEST_FLAG(LOCKFLAG, Text) || !TEST_FLAG(CLEARLINEFLAG, Text)) + return (NULL); + return ChangeTextJoin(Layer, Text); } /* --------------------------------------------------------------------------- * changes the square flag of all pins on an element */ -static void * -ChangeElementSquare (ElementTypePtr Element) +static void *ChangeElementSquare(ElementTypePtr Element) { - void *ans = NULL; + void *ans = NULL; - if (TEST_FLAG (LOCKFLAG, Element)) - return (NULL); - PIN_LOOP (Element); - { - ans = ChangePinSquare (Element, pin); - } - END_LOOP; - PAD_LOOP (Element); - { - ans = ChangePadSquare (Element, pad); - } - END_LOOP; - return (ans); + if (TEST_FLAG(LOCKFLAG, Element)) + return (NULL); + PIN_LOOP(Element); + { + ans = ChangePinSquare(Element, pin); + } + END_LOOP; + PAD_LOOP(Element); + { + ans = ChangePadSquare(Element, pad); + } + END_LOOP; + return (ans); } /* --------------------------------------------------------------------------- * sets the square flag of all pins on an element */ -static void * -SetElementSquare (ElementTypePtr Element) +static void *SetElementSquare(ElementTypePtr Element) { - void *ans = NULL; + void *ans = NULL; - if (TEST_FLAG (LOCKFLAG, Element)) - return (NULL); - PIN_LOOP (Element); - { - ans = SetPinSquare (Element, pin); - } - END_LOOP; - PAD_LOOP (Element); - { - ans = SetPadSquare (Element, pad); - } - END_LOOP; - return (ans); + if (TEST_FLAG(LOCKFLAG, Element)) + return (NULL); + PIN_LOOP(Element); + { + ans = SetPinSquare(Element, pin); + } + END_LOOP; + PAD_LOOP(Element); + { + ans = SetPadSquare(Element, pad); + } + END_LOOP; + return (ans); } /* --------------------------------------------------------------------------- * clears the square flag of all pins on an element */ -static void * -ClrElementSquare (ElementTypePtr Element) +static void *ClrElementSquare(ElementTypePtr Element) { - void *ans = NULL; + void *ans = NULL; - if (TEST_FLAG (LOCKFLAG, Element)) - return (NULL); - PIN_LOOP (Element); - { - ans = ClrPinSquare (Element, pin); - } - END_LOOP; - PAD_LOOP (Element); - { - ans = ClrPadSquare (Element, pad); - } - END_LOOP; - return (ans); + if (TEST_FLAG(LOCKFLAG, Element)) + return (NULL); + PIN_LOOP(Element); + { + ans = ClrPinSquare(Element, pin); + } + END_LOOP; + PAD_LOOP(Element); + { + ans = ClrPadSquare(Element, pad); + } + END_LOOP; + return (ans); } /* --------------------------------------------------------------------------- * changes the octagon flags of all pins of an element */ -static void * -ChangeElementOctagon (ElementTypePtr Element) +static void *ChangeElementOctagon(ElementTypePtr Element) { - void *result = NULL; + void *result = NULL; - if (TEST_FLAG (LOCKFLAG, Element)) - return (NULL); - PIN_LOOP (Element); - { - ChangePinOctagon (Element, pin); - result = Element; - } - END_LOOP; - return (result); + if (TEST_FLAG(LOCKFLAG, Element)) + return (NULL); + PIN_LOOP(Element); + { + ChangePinOctagon(Element, pin); + result = Element; + } + END_LOOP; + return (result); } /* --------------------------------------------------------------------------- * sets the octagon flags of all pins of an element */ -static void * -SetElementOctagon (ElementTypePtr Element) +static void *SetElementOctagon(ElementTypePtr Element) { - void *result = NULL; + void *result = NULL; - if (TEST_FLAG (LOCKFLAG, Element)) - return (NULL); - PIN_LOOP (Element); - { - SetPinOctagon (Element, pin); - result = Element; - } - END_LOOP; - return (result); + if (TEST_FLAG(LOCKFLAG, Element)) + return (NULL); + PIN_LOOP(Element); + { + SetPinOctagon(Element, pin); + result = Element; + } + END_LOOP; + return (result); } /* --------------------------------------------------------------------------- * clears the octagon flags of all pins of an element */ -static void * -ClrElementOctagon (ElementTypePtr Element) +static void *ClrElementOctagon(ElementTypePtr Element) { - void *result = NULL; + void *result = NULL; - if (TEST_FLAG (LOCKFLAG, Element)) - return (NULL); - PIN_LOOP (Element); - { - ClrPinOctagon (Element, pin); - result = Element; - } - END_LOOP; - return (result); + if (TEST_FLAG(LOCKFLAG, Element)) + return (NULL); + PIN_LOOP(Element); + { + ClrPinOctagon(Element, pin); + result = Element; + } + END_LOOP; + return (result); } /* --------------------------------------------------------------------------- * changes the square flag of a pad */ -static void * -ChangePadSquare (ElementTypePtr Element, PadTypePtr Pad) +static void *ChangePadSquare(ElementTypePtr Element, PadTypePtr Pad) { - if (TEST_FLAG (LOCKFLAG, Pad)) - return (NULL); - ErasePad (Pad); - AddObjectToClearPolyUndoList (PAD_TYPE, Element, Pad, Pad, false); - RestoreToPolygon (PCB->Data, PAD_TYPE, Element, Pad); - AddObjectToFlagUndoList (PAD_TYPE, Element, Pad, Pad); - TOGGLE_FLAG (SQUAREFLAG, Pad); - AddObjectToClearPolyUndoList (PAD_TYPE, Element, Pad, Pad, true); - ClearFromPolygon (PCB->Data, PAD_TYPE, Element, Pad); - DrawPad (Pad); - return (Pad); + if (TEST_FLAG(LOCKFLAG, Pad)) + return (NULL); + ErasePad(Pad); + AddObjectToClearPolyUndoList(PAD_TYPE, Element, Pad, Pad, false); + RestoreToPolygon(PCB->Data, PAD_TYPE, Element, Pad); + AddObjectToFlagUndoList(PAD_TYPE, Element, Pad, Pad); + TOGGLE_FLAG(SQUAREFLAG, Pad); + AddObjectToClearPolyUndoList(PAD_TYPE, Element, Pad, Pad, true); + ClearFromPolygon(PCB->Data, PAD_TYPE, Element, Pad); + DrawPad(Pad); + return (Pad); } /* --------------------------------------------------------------------------- * sets the square flag of a pad */ -static void * -SetPadSquare (ElementTypePtr Element, PadTypePtr Pad) +static void *SetPadSquare(ElementTypePtr Element, PadTypePtr Pad) { - if (TEST_FLAG (LOCKFLAG, Pad) || TEST_FLAG (SQUAREFLAG, Pad)) - return (NULL); + if (TEST_FLAG(LOCKFLAG, Pad) || TEST_FLAG(SQUAREFLAG, Pad)) + return (NULL); - return (ChangePadSquare (Element, Pad)); + return (ChangePadSquare(Element, Pad)); } @@ -1631,14 +1529,13 @@ /* --------------------------------------------------------------------------- * clears the square flag of a pad */ -static void * -ClrPadSquare (ElementTypePtr Element, PadTypePtr Pad) +static void *ClrPadSquare(ElementTypePtr Element, PadTypePtr Pad) { - if (TEST_FLAG (LOCKFLAG, Pad) || !TEST_FLAG (SQUAREFLAG, Pad)) - return (NULL); + if (TEST_FLAG(LOCKFLAG, Pad) || !TEST_FLAG(SQUAREFLAG, Pad)) + return (NULL); - return (ChangePadSquare (Element, Pad)); + return (ChangePadSquare(Element, Pad)); } @@ -1645,233 +1542,215 @@ /* --------------------------------------------------------------------------- * changes the square flag of a via */ -static void * -ChangeViaSquare (PinTypePtr Via) +static void *ChangeViaSquare(PinTypePtr Via) { - if (TEST_FLAG (LOCKFLAG, Via)) - return (NULL); - EraseVia (Via); - AddObjectToClearPolyUndoList (VIA_TYPE, NULL, Via, Via, false); - RestoreToPolygon (PCB->Data, VIA_TYPE, NULL, Via); - AddObjectToFlagUndoList (VIA_TYPE, NULL, Via, Via); + if (TEST_FLAG(LOCKFLAG, Via)) + return (NULL); + EraseVia(Via); + AddObjectToClearPolyUndoList(VIA_TYPE, NULL, Via, Via, false); + RestoreToPolygon(PCB->Data, VIA_TYPE, NULL, Via); + AddObjectToFlagUndoList(VIA_TYPE, NULL, Via, Via); ASSIGN_SQUARE(Absolute, Via); if (Absolute == 0) - CLEAR_FLAG (SQUAREFLAG, Via); + CLEAR_FLAG(SQUAREFLAG, Via); else - SET_FLAG (SQUAREFLAG, Via); - SetPinBoundingBox (Via); - AddObjectToClearPolyUndoList (VIA_TYPE, NULL, Via, Via, true); - ClearFromPolygon (PCB->Data, VIA_TYPE, NULL, Via); - DrawVia (Via); - return (Via); + SET_FLAG(SQUAREFLAG, Via); + SetPinBoundingBox(Via); + AddObjectToClearPolyUndoList(VIA_TYPE, NULL, Via, Via, true); + ClearFromPolygon(PCB->Data, VIA_TYPE, NULL, Via); + DrawVia(Via); + return (Via); } + /* --------------------------------------------------------------------------- * changes the square flag of a pin */ -static void * -ChangePinSquare (ElementTypePtr Element, PinTypePtr Pin) +static void *ChangePinSquare(ElementTypePtr Element, PinTypePtr Pin) { - if (TEST_FLAG (LOCKFLAG, Pin)) - return (NULL); - ErasePin (Pin); - AddObjectToClearPolyUndoList (PIN_TYPE, Element, Pin, Pin, false); - RestoreToPolygon (PCB->Data, PIN_TYPE, Element, Pin); - AddObjectToFlagUndoList (PIN_TYPE, Element, Pin, Pin); + if (TEST_FLAG(LOCKFLAG, Pin)) + return (NULL); + ErasePin(Pin); + AddObjectToClearPolyUndoList(PIN_TYPE, Element, Pin, Pin, false); + RestoreToPolygon(PCB->Data, PIN_TYPE, Element, Pin); + AddObjectToFlagUndoList(PIN_TYPE, Element, Pin, Pin); ASSIGN_SQUARE(Absolute, Pin); if (Absolute == 0) - CLEAR_FLAG (SQUAREFLAG, Pin); + CLEAR_FLAG(SQUAREFLAG, Pin); else - SET_FLAG (SQUAREFLAG, Pin); - SetPinBoundingBox (Pin); - AddObjectToClearPolyUndoList (PIN_TYPE, Element, Pin, Pin, true); - ClearFromPolygon (PCB->Data, PIN_TYPE, Element, Pin); - DrawPin (Pin); - return (Pin); + SET_FLAG(SQUAREFLAG, Pin); + SetPinBoundingBox(Pin); + AddObjectToClearPolyUndoList(PIN_TYPE, Element, Pin, Pin, true); + ClearFromPolygon(PCB->Data, PIN_TYPE, Element, Pin); + DrawPin(Pin); + return (Pin); } /* --------------------------------------------------------------------------- * sets the square flag of a pin */ -static void * -SetPinSquare (ElementTypePtr Element, PinTypePtr Pin) +static void *SetPinSquare(ElementTypePtr Element, PinTypePtr Pin) { - if (TEST_FLAG (LOCKFLAG, Pin) || TEST_FLAG (SQUAREFLAG, Pin)) - return (NULL); + if (TEST_FLAG(LOCKFLAG, Pin) || TEST_FLAG(SQUAREFLAG, Pin)) + return (NULL); - return (ChangePinSquare (Element, Pin)); + return (ChangePinSquare(Element, Pin)); } /* --------------------------------------------------------------------------- * clears the square flag of a pin */ -static void * -ClrPinSquare (ElementTypePtr Element, PinTypePtr Pin) +static void *ClrPinSquare(ElementTypePtr Element, PinTypePtr Pin) { - if (TEST_FLAG (LOCKFLAG, Pin) || !TEST_FLAG (SQUAREFLAG, Pin)) - return (NULL); + if (TEST_FLAG(LOCKFLAG, Pin) || !TEST_FLAG(SQUAREFLAG, Pin)) + return (NULL); - return (ChangePinSquare (Element, Pin)); + return (ChangePinSquare(Element, Pin)); } /* --------------------------------------------------------------------------- * changes the octagon flag of a via */ -static void * -ChangeViaOctagon (PinTypePtr Via) +static void *ChangeViaOctagon(PinTypePtr Via) { - if (TEST_FLAG (LOCKFLAG, Via)) - return (NULL); - EraseVia (Via); - AddObjectToClearPolyUndoList (VIA_TYPE, Via, Via, Via, false); - RestoreToPolygon (PCB->Data, VIA_TYPE, Via, Via); - AddObjectToFlagUndoList (VIA_TYPE, Via, Via, Via); - TOGGLE_FLAG (OCTAGONFLAG, Via); - AddObjectToClearPolyUndoList (VIA_TYPE, Via, Via, Via, true); - ClearFromPolygon (PCB->Data, VIA_TYPE, Via, Via); - DrawVia (Via); - return (Via); + if (TEST_FLAG(LOCKFLAG, Via)) + return (NULL); + EraseVia(Via); + AddObjectToClearPolyUndoList(VIA_TYPE, Via, Via, Via, false); + RestoreToPolygon(PCB->Data, VIA_TYPE, Via, Via); + AddObjectToFlagUndoList(VIA_TYPE, Via, Via, Via); + TOGGLE_FLAG(OCTAGONFLAG, Via); + AddObjectToClearPolyUndoList(VIA_TYPE, Via, Via, Via, true); + ClearFromPolygon(PCB->Data, VIA_TYPE, Via, Via); + DrawVia(Via); + return (Via); } /* --------------------------------------------------------------------------- * sets the octagon flag of a via */ -static void * -SetViaOctagon (PinTypePtr Via) +static void *SetViaOctagon(PinTypePtr Via) { - if (TEST_FLAG (LOCKFLAG, Via) || TEST_FLAG (OCTAGONFLAG, Via)) - return (NULL); + if (TEST_FLAG(LOCKFLAG, Via) || TEST_FLAG(OCTAGONFLAG, Via)) + return (NULL); - return (ChangeViaOctagon (Via)); + return (ChangeViaOctagon(Via)); } /* --------------------------------------------------------------------------- * clears the octagon flag of a via */ -static void * -ClrViaOctagon (PinTypePtr Via) +static void *ClrViaOctagon(PinTypePtr Via) { - if (TEST_FLAG (LOCKFLAG, Via) || !TEST_FLAG (OCTAGONFLAG, Via)) - return (NULL); + if (TEST_FLAG(LOCKFLAG, Via) || !TEST_FLAG(OCTAGONFLAG, Via)) + return (NULL); - return (ChangeViaOctagon (Via)); + return (ChangeViaOctagon(Via)); } /* --------------------------------------------------------------------------- * changes the octagon flag of a pin */ -static void * -ChangePinOctagon (ElementTypePtr Element, PinTypePtr Pin) +static void *ChangePinOctagon(ElementTypePtr Element, PinTypePtr Pin) { - if (TEST_FLAG (LOCKFLAG, Pin)) - return (NULL); - ErasePin (Pin); - AddObjectToClearPolyUndoList (PIN_TYPE, Element, Pin, Pin, false); - RestoreToPolygon (PCB->Data, PIN_TYPE, Element, Pin); - AddObjectToFlagUndoList (PIN_TYPE, Element, Pin, Pin); - TOGGLE_FLAG (OCTAGONFLAG, Pin); - AddObjectToClearPolyUndoList (PIN_TYPE, Element, Pin, Pin, true); - ClearFromPolygon (PCB->Data, PIN_TYPE, Element, Pin); - DrawPin (Pin); - return (Pin); + if (TEST_FLAG(LOCKFLAG, Pin)) + return (NULL); + ErasePin(Pin); + AddObjectToClearPolyUndoList(PIN_TYPE, Element, Pin, Pin, false); + RestoreToPolygon(PCB->Data, PIN_TYPE, Element, Pin); + AddObjectToFlagUndoList(PIN_TYPE, Element, Pin, Pin); + TOGGLE_FLAG(OCTAGONFLAG, Pin); + AddObjectToClearPolyUndoList(PIN_TYPE, Element, Pin, Pin, true); + ClearFromPolygon(PCB->Data, PIN_TYPE, Element, Pin); + DrawPin(Pin); + return (Pin); } /* --------------------------------------------------------------------------- * sets the octagon flag of a pin */ -static void * -SetPinOctagon (ElementTypePtr Element, PinTypePtr Pin) +static void *SetPinOctagon(ElementTypePtr Element, PinTypePtr Pin) { - if (TEST_FLAG (LOCKFLAG, Pin) || TEST_FLAG (OCTAGONFLAG, Pin)) - return (NULL); + if (TEST_FLAG(LOCKFLAG, Pin) || TEST_FLAG(OCTAGONFLAG, Pin)) + return (NULL); - return (ChangePinOctagon (Element, Pin)); + return (ChangePinOctagon(Element, Pin)); } /* --------------------------------------------------------------------------- * clears the octagon flag of a pin */ -static void * -ClrPinOctagon (ElementTypePtr Element, PinTypePtr Pin) +static void *ClrPinOctagon(ElementTypePtr Element, PinTypePtr Pin) { - if (TEST_FLAG (LOCKFLAG, Pin) || !TEST_FLAG (OCTAGONFLAG, Pin)) - return (NULL); + if (TEST_FLAG(LOCKFLAG, Pin) || !TEST_FLAG(OCTAGONFLAG, Pin)) + return (NULL); - return (ChangePinOctagon (Element, Pin)); + return (ChangePinOctagon(Element, Pin)); } /* --------------------------------------------------------------------------- * changes the hole flag of a via */ -bool -ChangeHole (PinTypePtr Via) +bool ChangeHole(PinTypePtr Via) { - if (TEST_FLAG (LOCKFLAG, Via)) - return (false); - EraseVia (Via); - AddObjectToFlagUndoList (VIA_TYPE, Via, Via, Via); - AddObjectToMaskSizeUndoList (VIA_TYPE, Via, Via, Via); - r_delete_entry (PCB->Data->via_tree, (BoxType *) Via); - RestoreToPolygon (PCB->Data, VIA_TYPE, Via, Via); - TOGGLE_FLAG (HOLEFLAG, Via); + if (TEST_FLAG(LOCKFLAG, Via)) + return (false); + EraseVia(Via); + AddObjectToFlagUndoList(VIA_TYPE, Via, Via, Via); + AddObjectToMaskSizeUndoList(VIA_TYPE, Via, Via, Via); + r_delete_entry(PCB->Data->via_tree, (BoxType *) Via); + RestoreToPolygon(PCB->Data, VIA_TYPE, Via, Via); + TOGGLE_FLAG(HOLEFLAG, Via); - if (TEST_FLAG (HOLEFLAG, Via)) - { - /* A tented via becomes an minimally untented hole. An untented - via retains its mask clearance. */ - if (Via->Mask > Via->Thickness) - { - Via->Mask = (Via->DrillingHole - + (Via->Mask - Via->Thickness)); + if (TEST_FLAG(HOLEFLAG, Via)) { + /* A tented via becomes an minimally untented hole. An untented + via retains its mask clearance. */ + if (Via->Mask > Via->Thickness) { + Via->Mask = (Via->DrillingHole + (Via->Mask - Via->Thickness)); + } + else if (Via->Mask < Via->DrillingHole) { + Via->Mask = Via->DrillingHole + 2 * MASKFRAME; + } } - else if (Via->Mask < Via->DrillingHole) - { - Via->Mask = Via->DrillingHole + 2 * MASKFRAME; + else { + Via->Mask = (Via->Thickness + (Via->Mask - Via->DrillingHole)); } - } - else - { - Via->Mask = (Via->Thickness - + (Via->Mask - Via->DrillingHole)); - } - SetPinBoundingBox (Via); - r_insert_entry (PCB->Data->via_tree, (BoxType *) Via, 0); - ClearFromPolygon (PCB->Data, VIA_TYPE, Via, Via); - DrawVia (Via); - Draw (); - return (true); + SetPinBoundingBox(Via); + r_insert_entry(PCB->Data->via_tree, (BoxType *) Via, 0); + ClearFromPolygon(PCB->Data, VIA_TYPE, Via, Via); + DrawVia(Via); + Draw(); + return (true); } /* --------------------------------------------------------------------------- * changes the nopaste flag of a pad */ -bool -ChangePaste (PadTypePtr Pad) +bool ChangePaste(PadTypePtr Pad) { - if (TEST_FLAG (LOCKFLAG, Pad)) - return (false); - ErasePad (Pad); - AddObjectToFlagUndoList (PAD_TYPE, Pad, Pad, Pad); - TOGGLE_FLAG (NOPASTEFLAG, Pad); - DrawPad (Pad); - Draw (); - return (true); + if (TEST_FLAG(LOCKFLAG, Pad)) + return (false); + ErasePad(Pad); + AddObjectToFlagUndoList(PAD_TYPE, Pad, Pad, Pad); + TOGGLE_FLAG(NOPASTEFLAG, Pad); + DrawPad(Pad); + Draw(); + return (true); } /* --------------------------------------------------------------------------- * changes the CLEARPOLY flag of a polygon */ -static void * -ChangePolyClear (LayerTypePtr Layer, PolygonTypePtr Polygon) +static void *ChangePolyClear(LayerTypePtr Layer, PolygonTypePtr Polygon) { - if (TEST_FLAG (LOCKFLAG, Polygon)) - return (NULL); - AddObjectToClearPolyUndoList (POLYGON_TYPE, Layer, Polygon, Polygon, true); - AddObjectToFlagUndoList (POLYGON_TYPE, Layer, Polygon, Polygon); - TOGGLE_FLAG (CLEARPOLYFLAG, Polygon); - InitClip (PCB->Data, Layer, Polygon); - DrawPolygon (Layer, Polygon); - return (Polygon); + if (TEST_FLAG(LOCKFLAG, Polygon)) + return (NULL); + AddObjectToClearPolyUndoList(POLYGON_TYPE, Layer, Polygon, Polygon, true); + AddObjectToFlagUndoList(POLYGON_TYPE, Layer, Polygon, Polygon); + TOGGLE_FLAG(CLEARPOLYFLAG, Polygon); + InitClip(PCB->Data, Layer, Polygon); + DrawPolygon(Layer, Polygon); + return (Polygon); } /* ---------------------------------------------------------------------- @@ -1878,27 +1757,24 @@ * changes the side of all selected and visible elements * returns true if anything has changed */ -bool -ChangeSelectedElementSide (void) +bool ChangeSelectedElementSide(void) { - bool change = false; + bool change = false; - /* setup identifiers */ - if (PCB->PinOn && PCB->ElementOn) - ELEMENT_LOOP (PCB->Data); - { - if (TEST_FLAG (SELECTEDFLAG, element)) - { - change |= ChangeElementSide (element, 0); - } - } - END_LOOP; - if (change) - { - Draw (); - IncrementUndoSerialNumber (); - } - return (change); + /* setup identifiers */ + if (PCB->PinOn && PCB->ElementOn) + ELEMENT_LOOP(PCB->Data); + { + if (TEST_FLAG(SELECTEDFLAG, element)) { + change |= ChangeElementSide(element, 0); + } + } + END_LOOP; + if (change) { + Draw(); + IncrementUndoSerialNumber(); + } + return (change); } /* ---------------------------------------------------------------------- @@ -1905,19 +1781,17 @@ * changes the thermals on all selected and visible pins * and/or vias. Returns true if anything has changed */ -bool -ChangeSelectedThermals (int types, int therm_style) +bool ChangeSelectedThermals(int types, int therm_style) { - bool change = false; + bool change = false; - Delta = therm_style; - change = SelectedOperation (&ChangeThermalFunctions, false, types); - if (change) - { - Draw (); - IncrementUndoSerialNumber (); - } - return (change); + Delta = therm_style; + change = SelectedOperation(&ChangeThermalFunctions, false, types); + if (change) { + Draw(); + IncrementUndoSerialNumber(); + } + return (change); } /* ---------------------------------------------------------------------- @@ -1924,22 +1798,20 @@ * changes the size of all selected and visible object types * returns true if anything has changed */ -bool -ChangeSelectedSize (int types, Coord Difference, bool fixIt) +bool ChangeSelectedSize(int types, Coord Difference, bool fixIt) { - bool change = false; + bool change = false; - /* setup identifiers */ - Absolute = (fixIt) ? Difference : 0; - Delta = Difference; + /* setup identifiers */ + Absolute = (fixIt) ? Difference : 0; + Delta = Difference; - change = SelectedOperation (&ChangeSizeFunctions, false, types); - if (change) - { - Draw (); - IncrementUndoSerialNumber (); - } - return (change); + change = SelectedOperation(&ChangeSizeFunctions, false, types); + if (change) { + Draw(); + IncrementUndoSerialNumber(); + } + return (change); } /* ---------------------------------------------------------------------- @@ -1946,24 +1818,22 @@ * changes the clearance size of all selected and visible objects * returns true if anything has changed */ -bool -ChangeSelectedClearSize (int types, Coord Difference, bool fixIt) +bool ChangeSelectedClearSize(int types, Coord Difference, bool fixIt) { - bool change = false; + bool change = false; - /* setup identifiers */ - Absolute = (fixIt) ? Difference : 0; - Delta = Difference; - if (TEST_FLAG (SHOWMASKFLAG, PCB)) - change = SelectedOperation (&ChangeMaskSizeFunctions, false, types); - else - change = SelectedOperation (&ChangeClearSizeFunctions, false, types); - if (change) - { - Draw (); - IncrementUndoSerialNumber (); - } - return (change); + /* setup identifiers */ + Absolute = (fixIt) ? Difference : 0; + Delta = Difference; + if (TEST_FLAG(SHOWMASKFLAG, PCB)) + change = SelectedOperation(&ChangeMaskSizeFunctions, false, types); + else + change = SelectedOperation(&ChangeClearSizeFunctions, false, types); + if (change) { + Draw(); + IncrementUndoSerialNumber(); + } + return (change); } /* -------------------------------------------------------------------------- @@ -1970,21 +1840,19 @@ * changes the 2nd size (drilling hole) of all selected and visible objects * returns true if anything has changed */ -bool -ChangeSelected2ndSize (int types, Coord Difference, bool fixIt) +bool ChangeSelected2ndSize(int types, Coord Difference, bool fixIt) { - bool change = false; + bool change = false; - /* setup identifiers */ - Absolute = (fixIt) ? Difference : 0; - Delta = Difference; - change = SelectedOperation (&Change2ndSizeFunctions, false, types); - if (change) - { - Draw (); - IncrementUndoSerialNumber (); - } - return (change); + /* setup identifiers */ + Absolute = (fixIt) ? Difference : 0; + Delta = Difference; + change = SelectedOperation(&Change2ndSizeFunctions, false, types); + if (change) { + Draw(); + IncrementUndoSerialNumber(); + } + return (change); } /* ---------------------------------------------------------------------- @@ -1991,18 +1859,16 @@ * changes the clearance flag (join) of all selected and visible lines * and/or arcs. Returns true if anything has changed */ -bool -ChangeSelectedJoin (int types) +bool ChangeSelectedJoin(int types) { - bool change = false; + bool change = false; - change = SelectedOperation (&ChangeJoinFunctions, false, types); - if (change) - { - Draw (); - IncrementUndoSerialNumber (); - } - return (change); + change = SelectedOperation(&ChangeJoinFunctions, false, types); + if (change) { + Draw(); + IncrementUndoSerialNumber(); + } + return (change); } /* ---------------------------------------------------------------------- @@ -2009,18 +1875,16 @@ * changes the clearance flag (join) of all selected and visible lines * and/or arcs. Returns true if anything has changed */ -bool -SetSelectedJoin (int types) +bool SetSelectedJoin(int types) { - bool change = false; + bool change = false; - change = SelectedOperation (&SetJoinFunctions, false, types); - if (change) - { - Draw (); - IncrementUndoSerialNumber (); - } - return (change); + change = SelectedOperation(&SetJoinFunctions, false, types); + if (change) { + Draw(); + IncrementUndoSerialNumber(); + } + return (change); } /* ---------------------------------------------------------------------- @@ -2027,18 +1891,16 @@ * changes the clearance flag (join) of all selected and visible lines * and/or arcs. Returns true if anything has changed */ -bool -ClrSelectedJoin (int types) +bool ClrSelectedJoin(int types) { - bool change = false; + bool change = false; - change = SelectedOperation (&ClrJoinFunctions, false, types); - if (change) - { - Draw (); - IncrementUndoSerialNumber (); - } - return (change); + change = SelectedOperation(&ClrJoinFunctions, false, types); + if (change) { + Draw(); + IncrementUndoSerialNumber(); + } + return (change); } /* ---------------------------------------------------------------------- @@ -2045,18 +1907,16 @@ * changes the nonetlist-flag of all selected and visible elements * returns true if anything has changed */ -bool -ChangeSelectedNonetlist (int types) +bool ChangeSelectedNonetlist(int types) { - bool change = false; + bool change = false; - change = SelectedOperation (&ChangeNonetlistFunctions, false, types); - if (change) - { - Draw (); - IncrementUndoSerialNumber (); - } - return (change); + change = SelectedOperation(&ChangeNonetlistFunctions, false, types); + if (change) { + Draw(); + IncrementUndoSerialNumber(); + } + return (change); } #if 0 @@ -2064,18 +1924,16 @@ * sets the square-flag of all selected and visible pins or pads * returns true if anything has changed */ -bool -SetSelectedNonetlist (int types) +bool SetSelectedNonetlist(int types) { - bool change = false; + bool change = false; - change = SelectedOperation (&SetNonetlistFunctions, false, types); - if (change) - { - Draw (); - IncrementUndoSerialNumber (); - } - return (change); + change = SelectedOperation(&SetNonetlistFunctions, false, types); + if (change) { + Draw(); + IncrementUndoSerialNumber(); + } + return (change); } /* ---------------------------------------------------------------------- @@ -2082,18 +1940,16 @@ * clears the square-flag of all selected and visible pins or pads * returns true if anything has changed */ -bool -ClrSelectedNonetlist (int types) +bool ClrSelectedNonetlist(int types) { - bool change = false; + bool change = false; - change = SelectedOperation (&ClrNonetlistFunctions, false, types); - if (change) - { - Draw (); - IncrementUndoSerialNumber (); - } - return (change); + change = SelectedOperation(&ClrNonetlistFunctions, false, types); + if (change) { + Draw(); + IncrementUndoSerialNumber(); + } + return (change); } #endif @@ -2101,18 +1957,16 @@ * changes the square-flag of all selected and visible pins or pads * returns true if anything has changed */ -bool -ChangeSelectedSquare (int types) +bool ChangeSelectedSquare(int types) { - bool change = false; + bool change = false; - change = SelectedOperation (&ChangeSquareFunctions, false, types); - if (change) - { - Draw (); - IncrementUndoSerialNumber (); - } - return (change); + change = SelectedOperation(&ChangeSquareFunctions, false, types); + if (change) { + Draw(); + IncrementUndoSerialNumber(); + } + return (change); } /* ---------------------------------------------------------------------- @@ -2119,18 +1973,16 @@ * sets the square-flag of all selected and visible pins or pads * returns true if anything has changed */ -bool -SetSelectedSquare (int types) +bool SetSelectedSquare(int types) { - bool change = false; + bool change = false; - change = SelectedOperation (&SetSquareFunctions, false, types); - if (change) - { - Draw (); - IncrementUndoSerialNumber (); - } - return (change); + change = SelectedOperation(&SetSquareFunctions, false, types); + if (change) { + Draw(); + IncrementUndoSerialNumber(); + } + return (change); } /* ---------------------------------------------------------------------- @@ -2137,18 +1989,16 @@ * clears the square-flag of all selected and visible pins or pads * returns true if anything has changed */ -bool -ClrSelectedSquare (int types) +bool ClrSelectedSquare(int types) { - bool change = false; + bool change = false; - change = SelectedOperation (&ClrSquareFunctions, false, types); - if (change) - { - Draw (); - IncrementUndoSerialNumber (); - } - return (change); + change = SelectedOperation(&ClrSquareFunctions, false, types); + if (change) { + Draw(); + IncrementUndoSerialNumber(); + } + return (change); } /* ---------------------------------------------------------------------- @@ -2155,18 +2005,16 @@ * changes the octagon-flag of all selected and visible pins and vias * returns true if anything has changed */ -bool -ChangeSelectedOctagon (int types) +bool ChangeSelectedOctagon(int types) { - bool change = false; + bool change = false; - change = SelectedOperation (&ChangeOctagonFunctions, false, types); - if (change) - { - Draw (); - IncrementUndoSerialNumber (); - } - return (change); + change = SelectedOperation(&ChangeOctagonFunctions, false, types); + if (change) { + Draw(); + IncrementUndoSerialNumber(); + } + return (change); } /* ---------------------------------------------------------------------- @@ -2173,18 +2021,16 @@ * sets the octagon-flag of all selected and visible pins and vias * returns true if anything has changed */ -bool -SetSelectedOctagon (int types) +bool SetSelectedOctagon(int types) { - bool change = false; + bool change = false; - change = SelectedOperation (&SetOctagonFunctions, false, types); - if (change) - { - Draw (); - IncrementUndoSerialNumber (); - } - return (change); + change = SelectedOperation(&SetOctagonFunctions, false, types); + if (change) { + Draw(); + IncrementUndoSerialNumber(); + } + return (change); } /* ---------------------------------------------------------------------- @@ -2191,18 +2037,16 @@ * clears the octagon-flag of all selected and visible pins and vias * returns true if anything has changed */ -bool -ClrSelectedOctagon (int types) +bool ClrSelectedOctagon(int types) { - bool change = false; + bool change = false; - change = SelectedOperation (&ClrOctagonFunctions, false, types); - if (change) - { - Draw (); - IncrementUndoSerialNumber (); - } - return (change); + change = SelectedOperation(&ClrOctagonFunctions, false, types); + if (change) { + Draw(); + IncrementUndoSerialNumber(); + } + return (change); } /* ---------------------------------------------------------------------- @@ -2209,24 +2053,22 @@ * changes the hole-flag of all selected and visible vias * returns true if anything has changed */ -bool -ChangeSelectedHole (void) +bool ChangeSelectedHole(void) { - bool change = false; + bool change = false; - if (PCB->ViaOn) - VIA_LOOP (PCB->Data); - { - if (TEST_FLAG (SELECTEDFLAG, via)) - change |= ChangeHole (via); - } - END_LOOP; - if (change) - { - Draw (); - IncrementUndoSerialNumber (); - } - return (change); + if (PCB->ViaOn) + VIA_LOOP(PCB->Data); + { + if (TEST_FLAG(SELECTEDFLAG, via)) + change |= ChangeHole(via); + } + END_LOOP; + if (change) { + Draw(); + IncrementUndoSerialNumber(); + } + return (change); } /* ---------------------------------------------------------------------- @@ -2233,23 +2075,21 @@ * changes the no paste-flag of all selected and visible pads * returns true if anything has changed */ -bool -ChangeSelectedPaste (void) +bool ChangeSelectedPaste(void) { - bool change = false; + bool change = false; - ALLPAD_LOOP (PCB->Data); - { - if (TEST_FLAG (SELECTEDFLAG, pad)) - change |= ChangePaste (pad); - } - ENDALL_LOOP; - if (change) - { - Draw (); - IncrementUndoSerialNumber (); - } - return (change); + ALLPAD_LOOP(PCB->Data); + { + if (TEST_FLAG(SELECTEDFLAG, pad)) + change |= ChangePaste(pad); + } + ENDALL_LOOP; + if (change) { + Draw(); + IncrementUndoSerialNumber(); + } + return (change); } @@ -2257,23 +2097,19 @@ * changes the size of the passed object; element size is silk size * Returns true if anything is changed */ -bool -ChangeObjectSize (int Type, void *Ptr1, void *Ptr2, void *Ptr3, - Coord Difference, bool fixIt) +bool ChangeObjectSize(int Type, void *Ptr1, void *Ptr2, void *Ptr3, Coord Difference, bool fixIt) { - bool change; + bool change; - /* setup identifier */ - Absolute = (fixIt) ? Difference : 0; - Delta = Difference; - change = - (ObjectOperation (&ChangeSizeFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL); - if (change) - { - Draw (); - IncrementUndoSerialNumber (); - } - return (change); + /* setup identifier */ + Absolute = (fixIt) ? Difference : 0; + Delta = Difference; + change = (ObjectOperation(&ChangeSizeFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL); + if (change) { + Draw(); + IncrementUndoSerialNumber(); + } + return (change); } /* --------------------------------------------------------------------------- @@ -2280,23 +2116,19 @@ * changes the size of the passed object; element size is pin ring sizes * Returns true if anything is changed */ -bool -ChangeObject1stSize (int Type, void *Ptr1, void *Ptr2, void *Ptr3, - Coord Difference, bool fixIt) +bool ChangeObject1stSize(int Type, void *Ptr1, void *Ptr2, void *Ptr3, Coord Difference, bool fixIt) { - bool change; + bool change; - /* setup identifier */ - Absolute = (fixIt) ? Difference : 0; - Delta = Difference; - change = - (ObjectOperation (&Change1stSizeFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL); - if (change) - { - Draw (); - IncrementUndoSerialNumber (); - } - return (change); + /* setup identifier */ + Absolute = (fixIt) ? Difference : 0; + Delta = Difference; + change = (ObjectOperation(&Change1stSizeFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL); + if (change) { + Draw(); + IncrementUndoSerialNumber(); + } + return (change); } /* --------------------------------------------------------------------------- @@ -2303,29 +2135,22 @@ * changes the clearance size of the passed object * Returns true if anything is changed */ -bool -ChangeObjectClearSize (int Type, void *Ptr1, void *Ptr2, void *Ptr3, - Coord Difference, bool fixIt) +bool ChangeObjectClearSize(int Type, void *Ptr1, void *Ptr2, void *Ptr3, Coord Difference, bool fixIt) { - bool change; + bool change; - /* setup identifier */ - Absolute = (fixIt) ? Difference : 0; - Delta = Difference; - if (TEST_FLAG (SHOWMASKFLAG, PCB)) - change = - (ObjectOperation (&ChangeMaskSizeFunctions, Type, Ptr1, Ptr2, Ptr3) != - NULL); - else - change = - (ObjectOperation (&ChangeClearSizeFunctions, Type, Ptr1, Ptr2, Ptr3) != - NULL); - if (change) - { - Draw (); - IncrementUndoSerialNumber (); - } - return (change); + /* setup identifier */ + Absolute = (fixIt) ? Difference : 0; + Delta = Difference; + if (TEST_FLAG(SHOWMASKFLAG, PCB)) + change = (ObjectOperation(&ChangeMaskSizeFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL); + else + change = (ObjectOperation(&ChangeClearSizeFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL); + if (change) { + Draw(); + IncrementUndoSerialNumber(); + } + return (change); } /* --------------------------------------------------------------------------- @@ -2333,22 +2158,17 @@ * Returns true if anything is changed * */ -bool -ChangeObjectThermal (int Type, void *Ptr1, void *Ptr2, void *Ptr3, - int therm_type) +bool ChangeObjectThermal(int Type, void *Ptr1, void *Ptr2, void *Ptr3, int therm_type) { - bool change; + bool change; - Delta = Absolute = therm_type; - change = - (ObjectOperation (&ChangeThermalFunctions, Type, Ptr1, Ptr2, Ptr3) != - NULL); - if (change) - { - Draw (); - IncrementUndoSerialNumber (); - } - return (change); + Delta = Absolute = therm_type; + change = (ObjectOperation(&ChangeThermalFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL); + if (change) { + Draw(); + IncrementUndoSerialNumber(); + } + return (change); } /* --------------------------------------------------------------------------- @@ -2355,25 +2175,20 @@ * changes the 2nd size of the passed object * Returns true if anything is changed */ -bool -ChangeObject2ndSize (int Type, void *Ptr1, void *Ptr2, void *Ptr3, - Coord Difference, bool fixIt, bool incundo) +bool ChangeObject2ndSize(int Type, void *Ptr1, void *Ptr2, void *Ptr3, Coord Difference, bool fixIt, bool incundo) { - bool change; + bool change; - /* setup identifier */ - Absolute = (fixIt) ? Difference : 0; - Delta = Difference; - change = - (ObjectOperation (&Change2ndSizeFunctions, Type, Ptr1, Ptr2, Ptr3) != - NULL); - if (change) - { - Draw (); - if (incundo) - IncrementUndoSerialNumber (); - } - return (change); + /* setup identifier */ + Absolute = (fixIt) ? Difference : 0; + Delta = Difference; + change = (ObjectOperation(&Change2ndSizeFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL); + if (change) { + Draw(); + if (incundo) + IncrementUndoSerialNumber(); + } + return (change); } /* --------------------------------------------------------------------------- @@ -2380,24 +2195,19 @@ * changes the mask size of the passed object * Returns true if anything is changed */ -bool -ChangeObjectMaskSize (int Type, void *Ptr1, void *Ptr2, void *Ptr3, - Coord Difference, bool fixIt) +bool ChangeObjectMaskSize(int Type, void *Ptr1, void *Ptr2, void *Ptr3, Coord Difference, bool fixIt) { - bool change; + bool change; - /* setup identifier */ - Absolute = (fixIt) ? Difference : 0; - Delta = Difference; - change = - (ObjectOperation (&ChangeMaskSizeFunctions, Type, Ptr1, Ptr2, Ptr3) != - NULL); - if (change) - { - Draw (); - IncrementUndoSerialNumber (); - } - return (change); + /* setup identifier */ + Absolute = (fixIt) ? Difference : 0; + Delta = Difference; + change = (ObjectOperation(&ChangeMaskSizeFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL); + if (change) { + Draw(); + IncrementUndoSerialNumber(); + } + return (change); } /* --------------------------------------------------------------------------- @@ -2407,16 +2217,14 @@ * The allocated memory isn't freed because the old string is used * by the undo module. */ -void * -ChangeObjectName (int Type, void *Ptr1, void *Ptr2, void *Ptr3, char *Name) +void *ChangeObjectName(int Type, void *Ptr1, void *Ptr2, void *Ptr3, char *Name) { - void *result; - /* setup identifier */ - NewName = Name; - if ((result = - ObjectOperation (&ChangeNameFunctions, Type, Ptr1, Ptr2, Ptr3))); - Draw (); - return (result); + void *result; + /* setup identifier */ + NewName = Name; + if ((result = ObjectOperation(&ChangeNameFunctions, Type, Ptr1, Ptr2, Ptr3))); + Draw(); + return (result); } /* --------------------------------------------------------------------------- @@ -2426,16 +2234,14 @@ * The allocated memory isn't freed because the old string is used * by the undo module. */ -void * -ChangeObjectPinnum (int Type, void *Ptr1, void *Ptr2, void *Ptr3, char *Name) +void *ChangeObjectPinnum(int Type, void *Ptr1, void *Ptr2, void *Ptr3, char *Name) { - void *result; - /* setup identifier */ - NewName = Name; - if ((result = - ObjectOperation (&ChangePinnumFunctions, Type, Ptr1, Ptr2, Ptr3))); - Draw (); - return (result); + void *result; + /* setup identifier */ + NewName = Name; + if ((result = ObjectOperation(&ChangePinnumFunctions, Type, Ptr1, Ptr2, Ptr3))); + Draw(); + return (result); } /* --------------------------------------------------------------------------- @@ -2442,16 +2248,14 @@ * changes the clearance-flag of the passed object * Returns true if anything is changed */ -bool -ChangeObjectJoin (int Type, void *Ptr1, void *Ptr2, void *Ptr3) +bool ChangeObjectJoin(int Type, void *Ptr1, void *Ptr2, void *Ptr3) { - if (ObjectOperation (&ChangeJoinFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL) - { - Draw (); - IncrementUndoSerialNumber (); - return (true); - } - return (false); + if (ObjectOperation(&ChangeJoinFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL) { + Draw(); + IncrementUndoSerialNumber(); + return (true); + } + return (false); } /* --------------------------------------------------------------------------- @@ -2458,16 +2262,14 @@ * sets the clearance-flag of the passed object * Returns true if anything is changed */ -bool -SetObjectJoin (int Type, void *Ptr1, void *Ptr2, void *Ptr3) +bool SetObjectJoin(int Type, void *Ptr1, void *Ptr2, void *Ptr3) { - if (ObjectOperation (&SetJoinFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL) - { - Draw (); - IncrementUndoSerialNumber (); - return (true); - } - return (false); + if (ObjectOperation(&SetJoinFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL) { + Draw(); + IncrementUndoSerialNumber(); + return (true); + } + return (false); } /* --------------------------------------------------------------------------- @@ -2474,16 +2276,14 @@ * clears the clearance-flag of the passed object * Returns true if anything is changed */ -bool -ClrObjectJoin (int Type, void *Ptr1, void *Ptr2, void *Ptr3) +bool ClrObjectJoin(int Type, void *Ptr1, void *Ptr2, void *Ptr3) { - if (ObjectOperation (&ClrJoinFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL) - { - Draw (); - IncrementUndoSerialNumber (); - return (true); - } - return (false); + if (ObjectOperation(&ClrJoinFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL) { + Draw(); + IncrementUndoSerialNumber(); + return (true); + } + return (false); } /* --------------------------------------------------------------------------- @@ -2490,17 +2290,14 @@ * changes the square-flag of the passed object * Returns true if anything is changed */ -bool -ChangeObjectNonetlist (int Type, void *Ptr1, void *Ptr2, void *Ptr3) +bool ChangeObjectNonetlist(int Type, void *Ptr1, void *Ptr2, void *Ptr3) { - if (ObjectOperation (&ChangeNonetlistFunctions, Type, Ptr1, Ptr2, Ptr3) != - NULL) - { - Draw (); - IncrementUndoSerialNumber (); - return (true); - } - return (false); + if (ObjectOperation(&ChangeNonetlistFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL) { + Draw(); + IncrementUndoSerialNumber(); + return (true); + } + return (false); } /* --------------------------------------------------------------------------- @@ -2507,18 +2304,15 @@ * changes the square-flag of the passed object * Returns true if anything is changed */ -bool -ChangeObjectSquare (int Type, void *Ptr1, void *Ptr2, void *Ptr3, int style) +bool ChangeObjectSquare(int Type, void *Ptr1, void *Ptr2, void *Ptr3, int style) { - Absolute = style; - if (ObjectOperation (&ChangeSquareFunctions, Type, Ptr1, Ptr2, Ptr3) != - NULL) - { - Draw (); - IncrementUndoSerialNumber (); - return (true); - } - return (false); + Absolute = style; + if (ObjectOperation(&ChangeSquareFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL) { + Draw(); + IncrementUndoSerialNumber(); + return (true); + } + return (false); } /* --------------------------------------------------------------------------- @@ -2525,16 +2319,14 @@ * sets the square-flag of the passed object * Returns true if anything is changed */ -bool -SetObjectSquare (int Type, void *Ptr1, void *Ptr2, void *Ptr3) +bool SetObjectSquare(int Type, void *Ptr1, void *Ptr2, void *Ptr3) { - if (ObjectOperation (&SetSquareFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL) - { - Draw (); - IncrementUndoSerialNumber (); - return (true); - } - return (false); + if (ObjectOperation(&SetSquareFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL) { + Draw(); + IncrementUndoSerialNumber(); + return (true); + } + return (false); } /* --------------------------------------------------------------------------- @@ -2541,16 +2333,14 @@ * clears the square-flag of the passed object * Returns true if anything is changed */ -bool -ClrObjectSquare (int Type, void *Ptr1, void *Ptr2, void *Ptr3) +bool ClrObjectSquare(int Type, void *Ptr1, void *Ptr2, void *Ptr3) { - if (ObjectOperation (&ClrSquareFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL) - { - Draw (); - IncrementUndoSerialNumber (); - return (true); - } - return (false); + if (ObjectOperation(&ClrSquareFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL) { + Draw(); + IncrementUndoSerialNumber(); + return (true); + } + return (false); } /* --------------------------------------------------------------------------- @@ -2557,17 +2347,14 @@ * changes the octagon-flag of the passed object * Returns true if anything is changed */ -bool -ChangeObjectOctagon (int Type, void *Ptr1, void *Ptr2, void *Ptr3) +bool ChangeObjectOctagon(int Type, void *Ptr1, void *Ptr2, void *Ptr3) { - if (ObjectOperation (&ChangeOctagonFunctions, Type, Ptr1, Ptr2, Ptr3) != - NULL) - { - Draw (); - IncrementUndoSerialNumber (); - return (true); - } - return (false); + if (ObjectOperation(&ChangeOctagonFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL) { + Draw(); + IncrementUndoSerialNumber(); + return (true); + } + return (false); } /* --------------------------------------------------------------------------- @@ -2574,16 +2361,14 @@ * sets the octagon-flag of the passed object * Returns true if anything is changed */ -bool -SetObjectOctagon (int Type, void *Ptr1, void *Ptr2, void *Ptr3) +bool SetObjectOctagon(int Type, void *Ptr1, void *Ptr2, void *Ptr3) { - if (ObjectOperation (&SetOctagonFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL) - { - Draw (); - IncrementUndoSerialNumber (); - return (true); - } - return (false); + if (ObjectOperation(&SetOctagonFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL) { + Draw(); + IncrementUndoSerialNumber(); + return (true); + } + return (false); } /* --------------------------------------------------------------------------- @@ -2590,16 +2375,14 @@ * clears the octagon-flag of the passed object * Returns true if anything is changed */ -bool -ClrObjectOctagon (int Type, void *Ptr1, void *Ptr2, void *Ptr3) +bool ClrObjectOctagon(int Type, void *Ptr1, void *Ptr2, void *Ptr3) { - if (ObjectOperation (&ClrOctagonFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL) - { - Draw (); - IncrementUndoSerialNumber (); - return (true); - } - return (false); + if (ObjectOperation(&ClrOctagonFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL) { + Draw(); + IncrementUndoSerialNumber(); + return (true); + } + return (false); } /* --------------------------------------------------------------------------- @@ -2608,79 +2391,69 @@ * The allocated memory isn't freed because the old string is used * by the undo module. */ -void * -QueryInputAndChangeObjectName (int Type, void *Ptr1, void *Ptr2, void *Ptr3, int pinnum) +void *QueryInputAndChangeObjectName(int Type, void *Ptr1, void *Ptr2, void *Ptr3, int pinnum) { - char *name = NULL; - char msg[513]; + char *name = NULL; + char msg[513]; - /* if passed an element name, make it an element reference instead */ - if (Type == ELEMENTNAME_TYPE) - { - Type = ELEMENT_TYPE; - Ptr2 = Ptr1; - Ptr3 = Ptr1; - } - switch (Type) - { - case LINE_TYPE: - name = gui->prompt_for (_("Linename:"), - EMPTY (((LineTypePtr) Ptr2)->Number)); - break; + /* if passed an element name, make it an element reference instead */ + if (Type == ELEMENTNAME_TYPE) { + Type = ELEMENT_TYPE; + Ptr2 = Ptr1; + Ptr3 = Ptr1; + } + switch (Type) { + case LINE_TYPE: + name = gui->prompt_for(_("Linename:"), EMPTY(((LineTypePtr) Ptr2)->Number)); + break; - case VIA_TYPE: - name = gui->prompt_for (_("Vianame:"), - EMPTY (((PinTypePtr) Ptr2)->Name)); - break; + case VIA_TYPE: + name = gui->prompt_for(_("Vianame:"), EMPTY(((PinTypePtr) Ptr2)->Name)); + break; - case PIN_TYPE: - if (pinnum) - sprintf (msg, _("%s Pin Number:"), EMPTY (((PinTypePtr) Ptr2)->Number)); - else - sprintf (msg, _("%s Pin Name:"), EMPTY (((PinTypePtr) Ptr2)->Number)); - name = gui->prompt_for (msg, EMPTY (((PinTypePtr) Ptr2)->Name)); - break; + case PIN_TYPE: + if (pinnum) + sprintf(msg, _("%s Pin Number:"), EMPTY(((PinTypePtr) Ptr2)->Number)); + else + sprintf(msg, _("%s Pin Name:"), EMPTY(((PinTypePtr) Ptr2)->Number)); + name = gui->prompt_for(msg, EMPTY(((PinTypePtr) Ptr2)->Name)); + break; - case PAD_TYPE: - if (pinnum) - sprintf (msg, _("%s Pad Number:"), EMPTY (((PadTypePtr) Ptr2)->Number)); - else - sprintf (msg, _("%s Pad Name:"), EMPTY (((PadTypePtr) Ptr2)->Number)); - name = gui->prompt_for (msg, EMPTY (((PadTypePtr) Ptr2)->Name)); - break; + case PAD_TYPE: + if (pinnum) + sprintf(msg, _("%s Pad Number:"), EMPTY(((PadTypePtr) Ptr2)->Number)); + else + sprintf(msg, _("%s Pad Name:"), EMPTY(((PadTypePtr) Ptr2)->Number)); + name = gui->prompt_for(msg, EMPTY(((PadTypePtr) Ptr2)->Name)); + break; - case TEXT_TYPE: - name = gui->prompt_for (_("Enter text:"), - EMPTY (((TextTypePtr) Ptr2)->TextString)); - break; + case TEXT_TYPE: + name = gui->prompt_for(_("Enter text:"), EMPTY(((TextTypePtr) Ptr2)->TextString)); + break; - case ELEMENT_TYPE: - name = gui->prompt_for (_("Elementname:"), - EMPTY (ELEMENT_NAME - (PCB, (ElementTypePtr) Ptr2))); - break; - } - if (name) - { - /* NB: ChangeObjectName takes ownership of the passed memory */ - char *old; - if (pinnum) - old = (char *)ChangeObjectPinnum (Type, Ptr1, Ptr2, Ptr3, name); - else - old = (char *)ChangeObjectName (Type, Ptr1, Ptr2, Ptr3, name); + case ELEMENT_TYPE: + name = gui->prompt_for(_("Elementname:"), EMPTY(ELEMENT_NAME(PCB, (ElementTypePtr) Ptr2))); + break; + } + if (name) { + /* NB: ChangeObjectName takes ownership of the passed memory */ + char *old; + if (pinnum) + old = (char *) ChangeObjectPinnum(Type, Ptr1, Ptr2, Ptr3, name); + else + old = (char *) ChangeObjectName(Type, Ptr1, Ptr2, Ptr3, name); - if (old != (char *) -1) - { - if (pinnum) - AddObjectToChangePinnumUndoList (Type, Ptr1, Ptr2, Ptr3, old); - else - AddObjectToChangeNameUndoList (Type, Ptr1, Ptr2, Ptr3, old); - IncrementUndoSerialNumber (); + if (old != (char *) -1) { + if (pinnum) + AddObjectToChangePinnumUndoList(Type, Ptr1, Ptr2, Ptr3, old); + else + AddObjectToChangeNameUndoList(Type, Ptr1, Ptr2, Ptr3, old); + IncrementUndoSerialNumber(); + } + Draw(); + return (Ptr3); } - Draw (); - return (Ptr3); - } - return (NULL); + return (NULL); } /* --------------------------------------------------------------------------- @@ -2689,29 +2462,23 @@ * releases the saved pixmap if necessary * and adjusts the cursor confinement box */ -void -ChangePCBSize (Coord Width, Coord Height) +void ChangePCBSize(Coord Width, Coord Height) { - PCB->MaxWidth = Width; - PCB->MaxHeight = Height; + PCB->MaxWidth = Width; + PCB->MaxHeight = Height; - /* crosshair range is different if pastebuffer-mode - * is enabled - */ - if (Settings.Mode == PASTEBUFFER_MODE) - SetCrosshairRange (PASTEBUFFER->X - PASTEBUFFER->BoundingBox.X1, - PASTEBUFFER->Y - PASTEBUFFER->BoundingBox.Y1, - MAX (0, - Width - (PASTEBUFFER->BoundingBox.X2 - - PASTEBUFFER->X)), MAX (0, - Height - - (PASTEBUFFER-> - BoundingBox.Y2 - - PASTEBUFFER-> - Y))); - else - SetCrosshairRange (0, 0, Width, Height); - hid_action ("PCBChanged"); + /* crosshair range is different if pastebuffer-mode + * is enabled + */ + if (Settings.Mode == PASTEBUFFER_MODE) + SetCrosshairRange(PASTEBUFFER->X - PASTEBUFFER->BoundingBox.X1, + PASTEBUFFER->Y - PASTEBUFFER->BoundingBox.Y1, + MAX(0, + Width - (PASTEBUFFER->BoundingBox.X2 - + PASTEBUFFER->X)), MAX(0, Height - (PASTEBUFFER->BoundingBox.Y2 - PASTEBUFFER->Y))); + else + SetCrosshairRange(0, 0, Width, Height); + hid_action("PCBChanged"); } /* --------------------------------------------------------------------------- @@ -2718,25 +2485,23 @@ * changes the mask size of a pad * returns TRUE if changed */ -static void * -ChangePadMaskSize (ElementTypePtr Element, PadTypePtr Pad) +static void *ChangePadMaskSize(ElementTypePtr Element, PadTypePtr Pad) { - Coord value = (Absolute) ? Absolute : Pad->Mask + Delta; + Coord value = (Absolute) ? Absolute : Pad->Mask + Delta; - value = MAX (value, 0); - if (value == Pad->Mask && Absolute == 0) - value = Pad->Thickness; - if (value != Pad->Mask) - { - AddObjectToMaskSizeUndoList (PAD_TYPE, Element, Pad, Pad); - ErasePad (Pad); - r_delete_entry (PCB->Data->pad_tree, &Pad->BoundingBox); - Pad->Mask = value; - SetElementBoundingBox (PCB->Data, Element, &PCB->Font); - DrawPad (Pad); - return (Pad); - } - return (NULL); + value = MAX(value, 0); + if (value == Pad->Mask && Absolute == 0) + value = Pad->Thickness; + if (value != Pad->Mask) { + AddObjectToMaskSizeUndoList(PAD_TYPE, Element, Pad, Pad); + ErasePad(Pad); + r_delete_entry(PCB->Data->pad_tree, &Pad->BoundingBox); + Pad->Mask = value; + SetElementBoundingBox(PCB->Data, Element, &PCB->Font); + DrawPad(Pad); + return (Pad); + } + return (NULL); } /* --------------------------------------------------------------------------- @@ -2743,25 +2508,23 @@ * changes the mask size of a pin * returns TRUE if changed */ -static void * -ChangePinMaskSize (ElementTypePtr Element, PinTypePtr Pin) +static void *ChangePinMaskSize(ElementTypePtr Element, PinTypePtr Pin) { - Coord value = (Absolute) ? Absolute : Pin->Mask + Delta; + Coord value = (Absolute) ? Absolute : Pin->Mask + Delta; - value = MAX (value, 0); - if (value == Pin->Mask && Absolute == 0) - value = Pin->Thickness; - if (value != Pin->Mask) - { - AddObjectToMaskSizeUndoList (PIN_TYPE, Element, Pin, Pin); - ErasePin (Pin); - r_delete_entry (PCB->Data->pin_tree, &Pin->BoundingBox); - Pin->Mask = value; - SetElementBoundingBox (PCB->Data, Element, &PCB->Font); - DrawPin (Pin); - return (Pin); - } - return (NULL); + value = MAX(value, 0); + if (value == Pin->Mask && Absolute == 0) + value = Pin->Thickness; + if (value != Pin->Mask) { + AddObjectToMaskSizeUndoList(PIN_TYPE, Element, Pin, Pin); + ErasePin(Pin); + r_delete_entry(PCB->Data->pin_tree, &Pin->BoundingBox); + Pin->Mask = value; + SetElementBoundingBox(PCB->Data, Element, &PCB->Font); + DrawPin(Pin); + return (Pin); + } + return (NULL); } /* --------------------------------------------------------------------------- @@ -2768,23 +2531,21 @@ * changes the mask size of a via * returns TRUE if changed */ -static void * -ChangeViaMaskSize (PinTypePtr Via) +static void *ChangeViaMaskSize(PinTypePtr Via) { - Coord value; + Coord value; - value = (Absolute) ? Absolute : Via->Mask + Delta; - value = MAX (value, 0); - if (value != Via->Mask) - { - AddObjectToMaskSizeUndoList (VIA_TYPE, Via, Via, Via); - EraseVia (Via); - r_delete_entry (PCB->Data->via_tree, &Via->BoundingBox); - Via->Mask = value; - SetPinBoundingBox (Via); - r_insert_entry (PCB->Data->via_tree, &Via->BoundingBox, 0); - DrawVia (Via); - return (Via); - } - return (NULL); + value = (Absolute) ? Absolute : Via->Mask + Delta; + value = MAX(value, 0); + if (value != Via->Mask) { + AddObjectToMaskSizeUndoList(VIA_TYPE, Via, Via, Via); + EraseVia(Via); + r_delete_entry(PCB->Data->via_tree, &Via->BoundingBox); + Via->Mask = value; + SetPinBoundingBox(Via); + r_insert_entry(PCB->Data->via_tree, &Via->BoundingBox, 0); + DrawVia(Via); + return (Via); + } + return (NULL); } Index: trunk/src/change.h =================================================================== --- trunk/src/change.h (revision 1021) +++ trunk/src/change.h (revision 1022) @@ -68,57 +68,53 @@ #define CHANGEMASKSIZE_TYPES \ (PIN_TYPE | VIA_TYPE | PAD_TYPE) -bool ChangeLayoutName (char *); -bool ChangeLayerName (LayerTypePtr, char *); -bool ChangeSelectedSize (int, Coord, bool); -bool ChangeSelectedClearSize (int, Coord, bool); -bool ChangeSelected2ndSize (int, Coord, bool); -bool ChangeSelectedMaskSize (int, Coord, bool); -bool ChangeSelectedJoin (int); -bool SetSelectedJoin (int); -bool ClrSelectedJoin (int); -bool ChangeSelectedNonetlist (int); -bool ChangeSelectedSquare (int); -bool SetSelectedSquare (int); -bool ClrSelectedSquare (int); -bool ChangeSelectedThermals (int, int); -bool ChangeSelectedHole (void); -bool ChangeSelectedPaste (void); -bool ChangeSelectedOctagon (int); -bool SetSelectedOctagon (int); -bool ClrSelectedOctagon (int); -bool ChangeSelectedElementSide (void); -bool ChangeElementSide (ElementTypePtr, Coord); -bool ChangeHole (PinTypePtr); -bool ChangePaste (PadTypePtr); -bool ChangeObjectSize (int, void *, void *, void *, Coord, bool); -bool ChangeObject1stSize (int, void *, void *, void *, Coord, bool); -bool ChangeObjectThermal (int, void *, void *, void *, int); -bool ChangeObjectClearSize (int, void *, void *, void *, Coord, - bool); -bool ChangeObject2ndSize (int, void *, void *, void *, Coord, - bool, bool); -bool ChangeObjectMaskSize (int, void *, void *, void *, Coord, - bool); -bool ChangeObjectJoin (int, void *, void *, void *); -bool SetObjectJoin (int, void *, void *, void *); -bool ClrObjectJoin (int, void *, void *, void *); -bool ChangeObjectNonetlist (int Type, void *Ptr1, void *Ptr2, void *Ptr3); -bool ChangeObjectSquare (int, void *, void *, void *, int); -bool SetObjectSquare (int, void *, void *, void *); -bool ClrObjectSquare (int, void *, void *, void *); -bool ChangeObjectOctagon (int, void *, void *, void *); -bool SetObjectOctagon (int, void *, void *, void *); -bool ClrObjectOctagon (int, void *, void *, void *); -void *ChangeObjectName (int, void *, void *, void *, char *); -void *QueryInputAndChangeObjectName (int, void *, void *, void *, int); -void ChangePCBSize (Coord, Coord); -void *ChangeObjectPinnum (int Type, void *Ptr1, void *Ptr2, void *Ptr3, char *Name); +bool ChangeLayoutName(char *); +bool ChangeLayerName(LayerTypePtr, char *); +bool ChangeSelectedSize(int, Coord, bool); +bool ChangeSelectedClearSize(int, Coord, bool); +bool ChangeSelected2ndSize(int, Coord, bool); +bool ChangeSelectedMaskSize(int, Coord, bool); +bool ChangeSelectedJoin(int); +bool SetSelectedJoin(int); +bool ClrSelectedJoin(int); +bool ChangeSelectedNonetlist(int); +bool ChangeSelectedSquare(int); +bool SetSelectedSquare(int); +bool ClrSelectedSquare(int); +bool ChangeSelectedThermals(int, int); +bool ChangeSelectedHole(void); +bool ChangeSelectedPaste(void); +bool ChangeSelectedOctagon(int); +bool SetSelectedOctagon(int); +bool ClrSelectedOctagon(int); +bool ChangeSelectedElementSide(void); +bool ChangeElementSide(ElementTypePtr, Coord); +bool ChangeHole(PinTypePtr); +bool ChangePaste(PadTypePtr); +bool ChangeObjectSize(int, void *, void *, void *, Coord, bool); +bool ChangeObject1stSize(int, void *, void *, void *, Coord, bool); +bool ChangeObjectThermal(int, void *, void *, void *, int); +bool ChangeObjectClearSize(int, void *, void *, void *, Coord, bool); +bool ChangeObject2ndSize(int, void *, void *, void *, Coord, bool, bool); +bool ChangeObjectMaskSize(int, void *, void *, void *, Coord, bool); +bool ChangeObjectJoin(int, void *, void *, void *); +bool SetObjectJoin(int, void *, void *, void *); +bool ClrObjectJoin(int, void *, void *, void *); +bool ChangeObjectNonetlist(int Type, void *Ptr1, void *Ptr2, void *Ptr3); +bool ChangeObjectSquare(int, void *, void *, void *, int); +bool SetObjectSquare(int, void *, void *, void *); +bool ClrObjectSquare(int, void *, void *, void *); +bool ChangeObjectOctagon(int, void *, void *, void *); +bool SetObjectOctagon(int, void *, void *, void *); +bool ClrObjectOctagon(int, void *, void *, void *); +void *ChangeObjectName(int, void *, void *, void *, char *); +void *QueryInputAndChangeObjectName(int, void *, void *, void *, int); +void ChangePCBSize(Coord, Coord); +void *ChangeObjectPinnum(int Type, void *Ptr1, void *Ptr2, void *Ptr3, char *Name); /* Change the specified text on an element, either on the board (give PCB, PCB->Data) or in a buffer (give NULL, Buffer->Data). The old string is returned, and must be properly freed by the caller. */ -char *ChangeElementText (PCBType *pcb, DataType *data, ElementTypePtr Element, - int which, char *new_name); +char *ChangeElementText(PCBType * pcb, DataType * data, ElementTypePtr Element, int which, char *new_name); #endif Index: trunk/src/clip.c =================================================================== --- trunk/src/clip.c (revision 1021) +++ trunk/src/clip.c (revision 1022) @@ -43,97 +43,85 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); /* Clip the line to the clipBox * return true if something to be drawn * false if the whole thing is clipped */ -bool -ClipLine (double minx, double miny, double maxx, double maxy, - double *x1, double *y1, - double *x2, double *y2, - double margin) +bool ClipLine(double minx, double miny, double maxx, double maxy, double *x1, double *y1, double *x2, double *y2, double margin) { - double d, r; + double d, r; - minx -= margin; - miny -= margin; - maxx += margin; - maxy += margin; + minx -= margin; + miny -= margin; + maxx += margin; + maxy += margin; - /* clip first point on left side */ - if (*x1 < minx) - { - if (*x2 < minx) - return false; - d = *x2 - *x1; - r = (minx - *x1) / d; - *x1 = minx; - *y1 += r * (*y2 - *y1); - } - /* clip second point on left side */ - if (*x2 < minx) - { - d = *x1 - *x2; - r = (minx - *x2) / d; - *x2 = minx; - *y2 += r * (*y1 - *y2); - } - /* clip first point on right side */ - if (*x1 > maxx) - { - if (*x2 > maxx) - return false; - d = *x2 - *x1; - r = (maxx - *x1) / d; - *x1 = maxx; - *y1 += r * (*y2 - *y1); - } - /* clip second point on right side */ - if (*x2 > maxx) - { - d = *x1 - *x2; - r = (maxx - *x2) / d; - *x2 = maxx; - *y2 += r * (*y1 - *y2); - } + /* clip first point on left side */ + if (*x1 < minx) { + if (*x2 < minx) + return false; + d = *x2 - *x1; + r = (minx - *x1) / d; + *x1 = minx; + *y1 += r * (*y2 - *y1); + } + /* clip second point on left side */ + if (*x2 < minx) { + d = *x1 - *x2; + r = (minx - *x2) / d; + *x2 = minx; + *y2 += r * (*y1 - *y2); + } + /* clip first point on right side */ + if (*x1 > maxx) { + if (*x2 > maxx) + return false; + d = *x2 - *x1; + r = (maxx - *x1) / d; + *x1 = maxx; + *y1 += r * (*y2 - *y1); + } + /* clip second point on right side */ + if (*x2 > maxx) { + d = *x1 - *x2; + r = (maxx - *x2) / d; + *x2 = maxx; + *y2 += r * (*y1 - *y2); + } - /* clip first point on top */ - if (*y1 < miny) - { - if (*y2 < miny) - return false; - d = *y2 - *y1; - r = (miny - *y1) / d; - *y1 = miny; - *x1 += r * (*x2 - *x1); - } - /* clip second point on top */ - if (*y2 < miny) - { - d = *y1 - *y2; - r = (miny - *y2) / d; - *y2 = miny; - *x2 += r * (*x1 - *x2); - } - /* clip first point on bottom */ - if (*y1 > maxy) - { - if (*y2 > maxy) - return false; - d = *y2 - *y1; - r = (maxy - *y1) / d; - *y1 = maxy; - *x1 += r * (*x2 - *x1); - } - /* clip second point on top */ - if (*y2 > maxy) - { - d = *y1 - *y2; - r = (maxy - *y2) / d; - *y2 = maxy; - *x2 += r * (*x1 - *x2); - } - return true; + /* clip first point on top */ + if (*y1 < miny) { + if (*y2 < miny) + return false; + d = *y2 - *y1; + r = (miny - *y1) / d; + *y1 = miny; + *x1 += r * (*x2 - *x1); + } + /* clip second point on top */ + if (*y2 < miny) { + d = *y1 - *y2; + r = (miny - *y2) / d; + *y2 = miny; + *x2 += r * (*x1 - *x2); + } + /* clip first point on bottom */ + if (*y1 > maxy) { + if (*y2 > maxy) + return false; + d = *y2 - *y1; + r = (maxy - *y1) / d; + *y1 = maxy; + *x1 += r * (*x2 - *x1); + } + /* clip second point on top */ + if (*y2 > maxy) { + d = *y1 - *y2; + r = (maxy - *y2) / d; + *y2 = maxy; + *x2 += r * (*x1 - *x2); + } + return true; } Index: trunk/src/clip.h =================================================================== --- trunk/src/clip.h (revision 1021) +++ trunk/src/clip.h (revision 1022) @@ -40,9 +40,7 @@ /* Clip X,Y to the given bounding box, plus a margin. Returns TRUE if there is something left to be drawn. */ -bool ClipLine (double minx, double miny, double maxx, double maxy, - double *x1, double *y1, - double *x2, double *y2, - double margin); +bool ClipLine(double minx, double miny, double maxx, double maxy, + double *x1, double *y1, double *x2, double *y2, double margin); #endif Index: trunk/src/command.c =================================================================== --- trunk/src/command.c (revision 1021) +++ trunk/src/command.c (revision 1022) @@ -55,7 +55,7 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); /* ---------------------------------------------------------------------- */ @@ -84,23 +84,20 @@ %end-doc */ -static int -CommandHelp (int argc, char **argv, Coord x, Coord y) +static int CommandHelp(int argc, char **argv, Coord x, Coord y) { - Message ("following commands are supported:\n" - " Command() execute an action command (too numerous to list)\n" - " see the manual for the list of action commands\n" - " h display this help message\n" - " l [file] load layout\n" - " le [file] load element to buffer\n" - " m [file] load layout to buffer (merge)\n" - " q quits the application\n" - " q! quits without save warning\n" - " rn [file] read in a net-list file\n" - " s [file] save layout\n" - " w [file] save layout\n" - " wq [file] save layout and quit\n"); - return (0); + Message("following commands are supported:\n" + " Command() execute an action command (too numerous to list)\n" + " see the manual for the list of action commands\n" + " h display this help message\n" + " l [file] load layout\n" + " le [file] load element to buffer\n" + " m [file] load layout to buffer (merge)\n" + " q quits the application\n" + " q! quits without save warning\n" + " rn [file] read in a net-list file\n" + " s [file] save layout\n" " w [file] save layout\n" " wq [file] save layout and quit\n"); + return (0); } /* ---------------------------------------------------------------------- */ @@ -121,26 +118,24 @@ %end-doc */ -static int -CommandLoadLayout (int argc, char **argv, Coord x, Coord y) +static int CommandLoadLayout(int argc, char **argv, Coord x, Coord y) { - char *filename, *name = NULL; + char *filename, *name = NULL; - switch (argc) - { - case 1: /* filename is passed in commandline */ - filename = argv[0]; - break; + switch (argc) { + case 1: /* filename is passed in commandline */ + filename = argv[0]; + break; - default: /* usage */ - Message ("Usage: l [name]\n loads layout data\n"); - return (1); - } + default: /* usage */ + Message("Usage: l [name]\n loads layout data\n"); + return (1); + } - if (!PCB->Changed || gui->confirm_dialog ("OK to override layout data?", 0)) - LoadPCB (filename, true); - free (name); - return (0); + if (!PCB->Changed || gui->confirm_dialog("OK to override layout data?", 0)) + LoadPCB(filename, true); + free(name); + return (0); } /* --------------------------------------------------------------------------- */ @@ -158,24 +153,22 @@ %end-doc */ -static int -CommandLoadElementToBuffer (int argc, char **argv, Coord x, Coord y) +static int CommandLoadElementToBuffer(int argc, char **argv, Coord x, Coord y) { - char *filename; + char *filename; - switch (argc) - { - case 1: /* filename is passed in commandline */ - filename = argv[0]; - if (filename && LoadElementToBuffer (PASTEBUFFER, filename)) - SetMode (PASTEBUFFER_MODE); - break; + switch (argc) { + case 1: /* filename is passed in commandline */ + filename = argv[0]; + if (filename && LoadElementToBuffer(PASTEBUFFER, filename)) + SetMode(PASTEBUFFER_MODE); + break; - default: /* usage */ - Message (false, "Usage: le [name]\n loads element data to buffer\n"); - return (1); - } - return (0); + default: /* usage */ + Message(false, "Usage: le [name]\n loads element data to buffer\n"); + return (1); + } + return (0); } /* --------------------------------------------------------------------------- */ @@ -194,24 +187,22 @@ %end-doc */ -static int -CommandLoadLayoutToBuffer (int argc, char **argv, Coord x, Coord y) +static int CommandLoadLayoutToBuffer(int argc, char **argv, Coord x, Coord y) { - char *filename; + char *filename; - switch (argc) - { - case 1: /* filename is passed in commandline */ - filename = argv[0]; - if (filename && LoadLayoutToBuffer (PASTEBUFFER, filename)) - SetMode (PASTEBUFFER_MODE); - break; + switch (argc) { + case 1: /* filename is passed in commandline */ + filename = argv[0]; + if (filename && LoadLayoutToBuffer(PASTEBUFFER, filename)) + SetMode(PASTEBUFFER_MODE); + break; - default: /* usage */ - Message ("Usage: m [name]\n loads layout data to buffer\n"); - return (1); - } - return (0); + default: /* usage */ + Message("Usage: m [name]\n loads layout data to buffer\n"); + return (1); + } + return (0); } /* --------------------------------------------------------------------------- */ @@ -229,18 +220,16 @@ %end-doc */ -static int -CommandQuit (int argc, char **argv, Coord x, Coord y) +static int CommandQuit(int argc, char **argv, Coord x, Coord y) { - if (!PCB->Changed || gui->close_confirm_dialog () == HID_CLOSE_CONFIRM_OK) - QuitApplication (); - return 0; + if (!PCB->Changed || gui->close_confirm_dialog() == HID_CLOSE_CONFIRM_OK) + QuitApplication(); + return 0; } static const char qreally_syntax[] = "q!"; -static const char qreally_help[] = - "Quits the application without confirming."; +static const char qreally_help[] = "Quits the application without confirming."; /* %start-doc actions q! @@ -251,11 +240,10 @@ %end-doc */ -static int -CommandReallyQuit (int argc, char **argv, Coord x, Coord y) +static int CommandReallyQuit(int argc, char **argv, Coord x, Coord y) { - QuitApplication (); - return 0; + QuitApplication(); + return 0; } /* ---------------------------------------------------------------------- */ @@ -278,26 +266,24 @@ %end-doc */ -static int -CommandLoadNetlist (int argc, char **argv, Coord x, Coord y) +static int CommandLoadNetlist(int argc, char **argv, Coord x, Coord y) { - char *filename, *name = NULL; + char *filename, *name = NULL; - switch (argc) - { - case 1: /* filename is passed in commandline */ - filename = argv[0]; - break; + switch (argc) { + case 1: /* filename is passed in commandline */ + filename = argv[0]; + break; - default: /* usage */ - Message ("Usage: rn [name]\n reads in a netlist file\n"); - return (1); - } - if (PCB->Netlistname) - free (PCB->Netlistname); - PCB->Netlistname = StripWhiteSpaceAndDup (filename); - free (name); - return (0); + default: /* usage */ + Message("Usage: rn [name]\n reads in a netlist file\n"); + return (1); + } + if (PCB->Netlistname) + free(PCB->Netlistname); + PCB->Netlistname = StripWhiteSpaceAndDup(filename); + free(name); + return (0); } /* ---------------------------------------------------------------------- */ @@ -330,37 +316,33 @@ %end-doc */ -static int -CommandSaveLayout (int argc, char **argv, Coord x, Coord y) +static int CommandSaveLayout(int argc, char **argv, Coord x, Coord y) { - switch (argc) - { - case 0: - if (PCB->Filename) - { - if (SavePCB (PCB->Filename) == 0) - SetChangedFlag (false); - } - else - Message ("No filename to save to yet\n"); - break; + switch (argc) { + case 0: + if (PCB->Filename) { + if (SavePCB(PCB->Filename) == 0) + SetChangedFlag(false); + } + else + Message("No filename to save to yet\n"); + break; - case 1: - if (SavePCB (argv[0]) == 0) - { - SetChangedFlag (false); - free (PCB->Filename); - PCB->Filename = strdup (argv[0]); - if (gui->notify_filename_changed != NULL) - gui->notify_filename_changed (); - } - break; + case 1: + if (SavePCB(argv[0]) == 0) { + SetChangedFlag(false); + free(PCB->Filename); + PCB->Filename = strdup(argv[0]); + if (gui->notify_filename_changed != NULL) + gui->notify_filename_changed(); + } + break; - default: - Message ("Usage: s [name] | w [name]\n saves layout data\n"); - return (1); - } - return (0); + default: + Message("Usage: s [name] | w [name]\n saves layout data\n"); + return (1); + } + return (0); } /* --------------------------------------------------------------------------- */ @@ -378,47 +360,46 @@ %end-doc */ -static int -CommandSaveLayoutAndQuit (int argc, char **argv, Coord x, Coord y) +static int CommandSaveLayoutAndQuit(int argc, char **argv, Coord x, Coord y) { - if (!CommandSaveLayout (argc, argv, x, y)) - return CommandQuit (0, 0, 0, 0); - return (1); + if (!CommandSaveLayout(argc, argv, x, y)) + return CommandQuit(0, 0, 0, 0); + return (1); } /* --------------------------------------------------------------------------- */ HID_Action command_action_list[] = { - {"h", 0, CommandHelp, - h_help, h_syntax} - , - {"l", 0, CommandLoadLayout, - l_help, l_syntax} - , - {"le", 0, CommandLoadElementToBuffer, - le_help, le_syntax} - , - {"m", 0, CommandLoadLayoutToBuffer, - m_help, m_syntax} - , - {"q", 0, CommandQuit, - q_help, q_syntax} - , - {"q!", 0, CommandReallyQuit, - qreally_help, qreally_syntax} - , - {"rn", 0, CommandLoadNetlist, - rn_help, rn_syntax} - , - {"s", 0, CommandSaveLayout, - s_help, s_syntax} - , - {"w", 0, CommandSaveLayout, - w_help, w_syntax} - , - {"wq", 0, CommandSaveLayoutAndQuit, - wq_help, wq_syntax} - , + {"h", 0, CommandHelp, + h_help, h_syntax} + , + {"l", 0, CommandLoadLayout, + l_help, l_syntax} + , + {"le", 0, CommandLoadElementToBuffer, + le_help, le_syntax} + , + {"m", 0, CommandLoadLayoutToBuffer, + m_help, m_syntax} + , + {"q", 0, CommandQuit, + q_help, q_syntax} + , + {"q!", 0, CommandReallyQuit, + qreally_help, qreally_syntax} + , + {"rn", 0, CommandLoadNetlist, + rn_help, rn_syntax} + , + {"s", 0, CommandSaveLayout, + s_help, s_syntax} + , + {"w", 0, CommandSaveLayout, + w_help, w_syntax} + , + {"wq", 0, CommandSaveLayoutAndQuit, + wq_help, wq_syntax} + , }; -REGISTER_ACTIONS (command_action_list) +REGISTER_ACTIONS(command_action_list) Index: trunk/src/command.h =================================================================== --- trunk/src/command.h (revision 1021) +++ trunk/src/command.h (revision 1022) @@ -33,7 +33,7 @@ #include "global.h" -void ExecuteUserCommand (char *); -void CallActionProc (char *action, char **arg, int argc); +void ExecuteUserCommand(char *); +void CallActionProc(char *action, char **arg, int argc); #endif Index: trunk/src/compat.c =================================================================== --- trunk/src/compat.c (revision 1021) +++ trunk/src/compat.c (revision 1022) @@ -32,29 +32,26 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); #ifndef HAVE_EXPF -float -expf (float x) +float expf(float x) { - return (float) exp ((double) x); + return (float) exp((double) x); } #endif #ifndef HAVE_LOGF -float -logf (float x) +float logf(float x) { - return (float) log ((double) x); + return (float) log((double) x); } #endif #ifndef HAVE_RANDOM -long -random (void) +long random(void) { - return (long) rand (); + return (long) rand(); } #endif @@ -61,52 +58,41 @@ #if !defined(HAVE_DLFCN_H) && defined(WIN32) #include -void * -dlopen (const char * f, int ATTRIBUTE_UNUSED flag) +void *dlopen(const char *f, int ATTRIBUTE_UNUSED flag) { - return LoadLibrary (f); + return LoadLibrary(f); } -void -dlclose (void * h) +void dlclose(void *h) { - FreeLibrary ((HINSTANCE) h); + FreeLibrary((HINSTANCE) h); } -char * -dlerror () +char *dlerror() { - static LPVOID lpMsgBuf = NULL; - DWORD dw; + static LPVOID lpMsgBuf = NULL; + DWORD dw; - /* free the error message buffer */ - if (lpMsgBuf) - LocalFree (lpMsgBuf); + /* free the error message buffer */ + if (lpMsgBuf) + LocalFree(lpMsgBuf); - /* get the error code */ - dw = GetLastError(); + /* get the error code */ + dw = GetLastError(); - /* get the corresponding error message */ - FormatMessage ( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - dw, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR) &lpMsgBuf, - 0, NULL); + /* get the corresponding error message */ + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) & lpMsgBuf, 0, NULL); - return (char *) lpMsgBuf; + return (char *) lpMsgBuf; } -void * -dlsym (void *handle, const char *symbol) +void *dlsym(void *handle, const char *symbol) { - return (void *) GetProcAddress((HMODULE) handle, symbol); + return (void *) GetProcAddress((HMODULE) handle, symbol); } #endif - - Index: trunk/src/compat.h =================================================================== --- trunk/src/compat.h (revision 1021) +++ trunk/src/compat.h (revision 1022) @@ -30,23 +30,23 @@ #include #ifndef HAVE_EXPF -float expf (float); +float expf(float); #endif #ifndef HAVE_LOGF -float logf (float); +float logf(float); #endif #ifndef HAVE_RANDOM -long random (void); +long random(void); #endif #if !defined(HAVE_DLFCN_H) && defined(WIN32) -void * dlopen (const char *, int); -void dlclose (void *); -char * dlerror (void); +void *dlopen(const char *, int); +void dlclose(void *); +char *dlerror(void); -void * dlsym(void *, const char *); +void *dlsym(void *, const char *); #define RTLD_NOW 2 #define RTLD_LOCAL 0 @@ -56,4 +56,3 @@ #endif /* PCB_COMPAT_H */ - Index: trunk/src/const.h =================================================================== --- trunk/src/const.h (revision 1021) +++ trunk/src/const.h (revision 1022) @@ -83,25 +83,25 @@ /* --------------------------------------------------------------------------- * modes */ -#define NO_MODE 0 /* no mode selected */ -#define VIA_MODE 1 /* draw vias */ -#define LINE_MODE 2 /* draw lines */ -#define RECTANGLE_MODE 3 /* create rectangles */ -#define POLYGON_MODE 4 /* draw filled polygons */ -#define PASTEBUFFER_MODE 5 /* paste objects from buffer */ -#define TEXT_MODE 6 /* create text objects */ -#define ROTATE_MODE 102 /* rotate objects */ -#define REMOVE_MODE 103 /* remove objects */ -#define MOVE_MODE 104 /* move objects */ -#define COPY_MODE 105 /* copy objects */ -#define INSERTPOINT_MODE 106 /* insert point into line/polygon */ +#define NO_MODE 0 /* no mode selected */ +#define VIA_MODE 1 /* draw vias */ +#define LINE_MODE 2 /* draw lines */ +#define RECTANGLE_MODE 3 /* create rectangles */ +#define POLYGON_MODE 4 /* draw filled polygons */ +#define PASTEBUFFER_MODE 5 /* paste objects from buffer */ +#define TEXT_MODE 6 /* create text objects */ +#define ROTATE_MODE 102 /* rotate objects */ +#define REMOVE_MODE 103 /* remove objects */ +#define MOVE_MODE 104 /* move objects */ +#define COPY_MODE 105 /* copy objects */ +#define INSERTPOINT_MODE 106 /* insert point into line/polygon */ #define RUBBERBANDMOVE_MODE 107 /* move objects and attached lines */ #define THERMAL_MODE 108 /* toggle thermal layer flag */ #define ARC_MODE 109 /* draw arcs */ -#define ARROW_MODE 110 /* selection with arrow mode */ +#define ARROW_MODE 110 /* selection with arrow mode */ #define PAN_MODE 0 /* same as no mode */ #define LOCK_MODE 111 /* lock/unlock objects */ -#define POLYGONHOLE_MODE 112 /* cut holes in filled polygons */ +#define POLYGONHOLE_MODE 112 /* cut holes in filled polygons */ /* --------------------------------------------------------------------------- * object flags @@ -183,13 +183,13 @@ %end-doc */ #define NOFLAG 0x0000 -#define PINFLAG 0x0001 /* is a pin */ -#define VIAFLAG 0x0002 /* is a via */ -#define FOUNDFLAG 0x0004 /* used by 'FindConnection()' */ -#define HOLEFLAG 0x0008 /* pin or via is only a hole */ -#define NOPASTEFLAG 0x0008 /* pad should not receive - solderpaste. This is to - support fiducials */ +#define PINFLAG 0x0001 /* is a pin */ +#define VIAFLAG 0x0002 /* is a via */ +#define FOUNDFLAG 0x0004 /* used by 'FindConnection()' */ +#define HOLEFLAG 0x0008 /* pin or via is only a hole */ +#define NOPASTEFLAG 0x0008 /* pad should not receive + solderpaste. This is to + support fiducials */ #define RATFLAG 0x0010 /* indicates line is a rat line */ #define PININPOLYFLAG 0x0010 /* pin found inside poly - same as */ /* rat line since not used on lines */ @@ -201,23 +201,23 @@ #define FULLPOLYFLAG 0x0020 /* full polygon is drawn (i.e. all parts instead of only the biggest one) */ #define SELECTEDFLAG 0x0040 /* object has been selected */ #define ONSOLDERFLAG 0x0080 /* element is on bottom side */ -#define AUTOFLAG 0x0080 /* line/via created by auto-router */ -#define SQUAREFLAG 0x0100 /* pin is square, not round */ +#define AUTOFLAG 0x0080 /* line/via created by auto-router */ +#define SQUAREFLAG 0x0100 /* pin is square, not round */ #define RUBBERENDFLAG 0x0200 /* indicates one end already rubber */ /* banding same as warn flag */ /* since pins/pads won't use it */ -#define WARNFLAG 0x0200 /* Warning for pin/via/pad */ +#define WARNFLAG 0x0200 /* Warning for pin/via/pad */ #define USETHERMALFLAG 0x0400 /* draw pin, via with thermal fingers */ #define ONSILKFLAG 0x0400 /* old files use this to indicate silk */ -#define OCTAGONFLAG 0x0800 /* draw pin/via as octagon instead of round */ -#define DRCFLAG 0x1000 /* flag like FOUND flag for DRC checking */ +#define OCTAGONFLAG 0x0800 /* draw pin/via as octagon instead of round */ +#define DRCFLAG 0x1000 /* flag like FOUND flag for DRC checking */ #define LOCKFLAG 0x2000 /* object locked in place */ #define EDGE2FLAG 0x4000 /* Padr.Point2 is closer to outside edge */ /* also pinout text for pins is vertical */ -#define VISITFLAG 0x8000 /* marker to avoid re-visiting an object */ +#define VISITFLAG 0x8000 /* marker to avoid re-visiting an object */ #define NONETLISTFLAG 0x10000 /* element is not on the netlist and should not interfere with the netlist */ -#define MINCUTFLAG 0x20000 /* used by the mincut short find code */ -#define ONPOINTFLAG 0x40000 /*!< crosshair is on line point or arc point */ +#define MINCUTFLAG 0x20000 /* used by the mincut short find code */ +#define ONPOINTFLAG 0x40000 /*!< crosshair is on line point or arc point */ #define NOCOPY_FLAGS (FOUNDFLAG | CONNECTEDFLAG | ONPOINTFLAG) @@ -283,7 +283,7 @@ @end table %end-doc */ -#define PCB_FLAGS 0x01ffffff /* all used flags */ +#define PCB_FLAGS 0x01ffffff /* all used flags */ #define SHOWNUMBERFLAG 0x00000001 #define LOCALREFFLAG 0x00000002 @@ -314,7 +314,7 @@ /* --------------------------------------------------------------------------- * object types */ -#define NO_TYPE 0x00000 /* no object */ +#define NO_TYPE 0x00000 /* no object */ #define VIA_TYPE 0x00001 #define ELEMENT_TYPE 0x00002 #define LINE_TYPE 0x00004 @@ -322,8 +322,8 @@ #define TEXT_TYPE 0x00010 #define RATLINE_TYPE 0x00020 -#define PIN_TYPE 0x00100 /* objects that are part */ -#define PAD_TYPE 0x00200 /* 'pin' of SMD element */ +#define PIN_TYPE 0x00100 /* objects that are part */ +#define PAD_TYPE 0x00200 /* 'pin' of SMD element */ #define ELEMENTNAME_TYPE 0x00400 /* of others */ #define POLYGONPOINT_TYPE 0x00800 #define LINEPOINT_TYPE 0x01000 @@ -332,12 +332,12 @@ #define ELEMENTARC_TYPE 0x08000 #define LOCKED_TYPE 0x10000 /* used to tell search to include locked items. */ -#define NET_TYPE 0x20000 /* used to select whole net. */ +#define NET_TYPE 0x20000 /* used to select whole net. */ #define PIN_TYPES (VIA_TYPE | PIN_TYPE) #define LOCK_TYPES (VIA_TYPE | LINE_TYPE | ARC_TYPE | POLYGON_TYPE | ELEMENT_TYPE \ | TEXT_TYPE | ELEMENTNAME_TYPE | LOCKED_TYPE) -#define ALL_TYPES (~0) /* all bits set */ +#define ALL_TYPES (~0) /* all bits set */ #endif Index: trunk/src/copy.c =================================================================== --- trunk/src/copy.c (revision 1021) +++ trunk/src/copy.c (revision 1022) @@ -55,35 +55,35 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); /* --------------------------------------------------------------------------- * some local prototypes */ -static void *CopyVia (PinTypePtr); -static void *CopyLine (LayerTypePtr, LineTypePtr); -static void *CopyArc (LayerTypePtr, ArcTypePtr); -static void *CopyText (LayerTypePtr, TextTypePtr); -static void *CopyPolygon (LayerTypePtr, PolygonTypePtr); -static void *CopyElement (ElementTypePtr); +static void *CopyVia(PinTypePtr); +static void *CopyLine(LayerTypePtr, LineTypePtr); +static void *CopyArc(LayerTypePtr, ArcTypePtr); +static void *CopyText(LayerTypePtr, TextTypePtr); +static void *CopyPolygon(LayerTypePtr, PolygonTypePtr); +static void *CopyElement(ElementTypePtr); /* --------------------------------------------------------------------------- * some local identifiers */ -static Coord DeltaX, DeltaY; /* movement vector */ +static Coord DeltaX, DeltaY; /* movement vector */ static ObjectFunctionType CopyFunctions = { - CopyLine, - CopyText, - CopyPolygon, - CopyVia, - CopyElement, - NULL, - NULL, - NULL, - NULL, - NULL, - CopyArc, - NULL + CopyLine, + CopyText, + CopyPolygon, + CopyVia, + CopyElement, + NULL, + NULL, + NULL, + NULL, + NULL, + CopyArc, + NULL }; /* --------------------------------------------------------------------------- @@ -90,25 +90,22 @@ * copies data from one polygon to another * 'Dest' has to exist */ -PolygonTypePtr -CopyPolygonLowLevel (PolygonTypePtr Dest, PolygonTypePtr Src) +PolygonTypePtr CopyPolygonLowLevel(PolygonTypePtr Dest, PolygonTypePtr Src) { - Cardinal hole = 0; - Cardinal n; + Cardinal hole = 0; + Cardinal n; - for (n = 0; n < Src->PointN; n++) - { - if (hole < Src->HoleIndexN && n == Src->HoleIndex[hole]) - { - CreateNewHoleInPolygon (Dest); - hole++; - } - CreateNewPointInPolygon (Dest, Src->Points[n].X, Src->Points[n].Y); - } - SetPolygonBoundingBox (Dest); - Dest->Flags = Src->Flags; - CLEAR_FLAG (FOUNDFLAG, Dest); - return (Dest); + for (n = 0; n < Src->PointN; n++) { + if (hole < Src->HoleIndexN && n == Src->HoleIndex[hole]) { + CreateNewHoleInPolygon(Dest); + hole++; + } + CreateNewPointInPolygon(Dest, Src->Points[n].X, Src->Points[n].Y); + } + SetPolygonBoundingBox(Dest); + Dest->Flags = Src->Flags; + CLEAR_FLAG(FOUNDFLAG, Dest); + return (Dest); } /* --------------------------------------------------------------------------- @@ -116,203 +113,176 @@ * if necessary */ ElementTypePtr -CopyElementLowLevel (DataTypePtr Data, ElementTypePtr Dest, - ElementTypePtr Src, bool uniqueName, Coord dx, - Coord dy) +CopyElementLowLevel(DataTypePtr Data, ElementTypePtr Dest, ElementTypePtr Src, bool uniqueName, Coord dx, Coord dy) { - int i; - /* release old memory if necessary */ - if (Dest) - FreeElementMemory (Dest); + int i; + /* release old memory if necessary */ + if (Dest) + FreeElementMemory(Dest); - /* both coordinates and flags are the same */ - Dest = CreateNewElement (Data, Dest, &PCB->Font, - MaskFlags (Src->Flags, FOUNDFLAG), - DESCRIPTION_NAME (Src), NAMEONPCB_NAME (Src), - VALUE_NAME (Src), DESCRIPTION_TEXT (Src).X + dx, - DESCRIPTION_TEXT (Src).Y + dy, - DESCRIPTION_TEXT (Src).Direction, - DESCRIPTION_TEXT (Src).Scale, - MaskFlags (DESCRIPTION_TEXT (Src).Flags, - FOUNDFLAG), uniqueName); + /* both coordinates and flags are the same */ + Dest = CreateNewElement(Data, Dest, &PCB->Font, + MaskFlags(Src->Flags, FOUNDFLAG), + DESCRIPTION_NAME(Src), NAMEONPCB_NAME(Src), + VALUE_NAME(Src), DESCRIPTION_TEXT(Src).X + dx, + DESCRIPTION_TEXT(Src).Y + dy, + DESCRIPTION_TEXT(Src).Direction, + DESCRIPTION_TEXT(Src).Scale, MaskFlags(DESCRIPTION_TEXT(Src).Flags, FOUNDFLAG), uniqueName); - /* abort on error */ - if (!Dest) - return (Dest); + /* abort on error */ + if (!Dest) + return (Dest); - ELEMENTLINE_LOOP (Src); - { - CreateNewLineInElement (Dest, line->Point1.X + dx, - line->Point1.Y + dy, line->Point2.X + dx, - line->Point2.Y + dy, line->Thickness); - } - END_LOOP; - PIN_LOOP (Src); - { - CreateNewPin (Dest, pin->X + dx, pin->Y + dy, pin->Thickness, - pin->Clearance, pin->Mask, pin->DrillingHole, - pin->Name, pin->Number, MaskFlags (pin->Flags, FOUNDFLAG)); - } - END_LOOP; - PAD_LOOP (Src); - { - CreateNewPad (Dest, pad->Point1.X + dx, pad->Point1.Y + dy, - pad->Point2.X + dx, pad->Point2.Y + dy, pad->Thickness, - pad->Clearance, pad->Mask, pad->Name, pad->Number, - MaskFlags (pad->Flags, FOUNDFLAG)); - } - END_LOOP; - ARC_LOOP (Src); - { - CreateNewArcInElement (Dest, arc->X + dx, arc->Y + dy, arc->Width, - arc->Height, arc->StartAngle, arc->Delta, - arc->Thickness); - } - END_LOOP; + ELEMENTLINE_LOOP(Src); + { + CreateNewLineInElement(Dest, line->Point1.X + dx, + line->Point1.Y + dy, line->Point2.X + dx, line->Point2.Y + dy, line->Thickness); + } + END_LOOP; + PIN_LOOP(Src); + { + CreateNewPin(Dest, pin->X + dx, pin->Y + dy, pin->Thickness, + pin->Clearance, pin->Mask, pin->DrillingHole, pin->Name, pin->Number, MaskFlags(pin->Flags, FOUNDFLAG)); + } + END_LOOP; + PAD_LOOP(Src); + { + CreateNewPad(Dest, pad->Point1.X + dx, pad->Point1.Y + dy, + pad->Point2.X + dx, pad->Point2.Y + dy, pad->Thickness, + pad->Clearance, pad->Mask, pad->Name, pad->Number, MaskFlags(pad->Flags, FOUNDFLAG)); + } + END_LOOP; + ARC_LOOP(Src); + { + CreateNewArcInElement(Dest, arc->X + dx, arc->Y + dy, arc->Width, arc->Height, arc->StartAngle, arc->Delta, arc->Thickness); + } + END_LOOP; - for (i=0; iAttributes.Number; i++) - CreateNewAttribute (& Dest->Attributes, - Src->Attributes.List[i].name, - Src->Attributes.List[i].value); + for (i = 0; i < Src->Attributes.Number; i++) + CreateNewAttribute(&Dest->Attributes, Src->Attributes.List[i].name, Src->Attributes.List[i].value); - Dest->MarkX = Src->MarkX + dx; - Dest->MarkY = Src->MarkY + dy; + Dest->MarkX = Src->MarkX + dx; + Dest->MarkY = Src->MarkY + dy; - SetElementBoundingBox (Data, Dest, &PCB->Font); - return (Dest); + SetElementBoundingBox(Data, Dest, &PCB->Font); + return (Dest); } /* --------------------------------------------------------------------------- * copies a via */ -static void * -CopyVia (PinTypePtr Via) +static void *CopyVia(PinTypePtr Via) { - PinTypePtr via; + PinTypePtr via; - via = CreateNewVia (PCB->Data, Via->X + DeltaX, Via->Y + DeltaY, - Via->Thickness, Via->Clearance, Via->Mask, - Via->DrillingHole, Via->Name, - MaskFlags (Via->Flags, FOUNDFLAG)); - if (!via) - return (via); - DrawVia (via); - AddObjectToCreateUndoList (VIA_TYPE, via, via, via); - return (via); + via = CreateNewVia(PCB->Data, Via->X + DeltaX, Via->Y + DeltaY, + Via->Thickness, Via->Clearance, Via->Mask, Via->DrillingHole, Via->Name, MaskFlags(Via->Flags, FOUNDFLAG)); + if (!via) + return (via); + DrawVia(via); + AddObjectToCreateUndoList(VIA_TYPE, via, via, via); + return (via); } /* --------------------------------------------------------------------------- * copies a line */ -static void * -CopyLine (LayerTypePtr Layer, LineTypePtr Line) +static void *CopyLine(LayerTypePtr Layer, LineTypePtr Line) { - LineTypePtr line; + LineTypePtr line; - line = CreateDrawnLineOnLayer (Layer, Line->Point1.X + DeltaX, - Line->Point1.Y + DeltaY, - Line->Point2.X + DeltaX, - Line->Point2.Y + DeltaY, Line->Thickness, - Line->Clearance, - MaskFlags (Line->Flags, FOUNDFLAG)); - if (!line) - return (line); - if (Line->Number) - line->Number = strdup (Line->Number); - DrawLine (Layer, line); - AddObjectToCreateUndoList (LINE_TYPE, Layer, line, line); - return (line); + line = CreateDrawnLineOnLayer(Layer, Line->Point1.X + DeltaX, + Line->Point1.Y + DeltaY, + Line->Point2.X + DeltaX, + Line->Point2.Y + DeltaY, Line->Thickness, Line->Clearance, MaskFlags(Line->Flags, FOUNDFLAG)); + if (!line) + return (line); + if (Line->Number) + line->Number = strdup(Line->Number); + DrawLine(Layer, line); + AddObjectToCreateUndoList(LINE_TYPE, Layer, line, line); + return (line); } /* --------------------------------------------------------------------------- * copies an arc */ -static void * -CopyArc (LayerTypePtr Layer, ArcTypePtr Arc) +static void *CopyArc(LayerTypePtr Layer, ArcTypePtr Arc) { - ArcTypePtr arc; + ArcTypePtr arc; - arc = CreateNewArcOnLayer (Layer, Arc->X + DeltaX, - Arc->Y + DeltaY, Arc->Width, Arc->Height, Arc->StartAngle, - Arc->Delta, Arc->Thickness, Arc->Clearance, - MaskFlags (Arc->Flags, FOUNDFLAG)); - if (!arc) - return (arc); - DrawArc (Layer, arc); - AddObjectToCreateUndoList (ARC_TYPE, Layer, arc, arc); - return (arc); + arc = CreateNewArcOnLayer(Layer, Arc->X + DeltaX, + Arc->Y + DeltaY, Arc->Width, Arc->Height, Arc->StartAngle, + Arc->Delta, Arc->Thickness, Arc->Clearance, MaskFlags(Arc->Flags, FOUNDFLAG)); + if (!arc) + return (arc); + DrawArc(Layer, arc); + AddObjectToCreateUndoList(ARC_TYPE, Layer, arc, arc); + return (arc); } /* --------------------------------------------------------------------------- * copies a text */ -static void * -CopyText (LayerTypePtr Layer, TextTypePtr Text) +static void *CopyText(LayerTypePtr Layer, TextTypePtr Text) { - TextTypePtr text; + TextTypePtr text; - text = CreateNewText (Layer, &PCB->Font, Text->X + DeltaX, - Text->Y + DeltaY, Text->Direction, - Text->Scale, Text->TextString, - MaskFlags (Text->Flags, FOUNDFLAG)); - DrawText (Layer, text); - AddObjectToCreateUndoList (TEXT_TYPE, Layer, text, text); - return (text); + text = CreateNewText(Layer, &PCB->Font, Text->X + DeltaX, + Text->Y + DeltaY, Text->Direction, Text->Scale, Text->TextString, MaskFlags(Text->Flags, FOUNDFLAG)); + DrawText(Layer, text); + AddObjectToCreateUndoList(TEXT_TYPE, Layer, text, text); + return (text); } /* --------------------------------------------------------------------------- * copies a polygon */ -static void * -CopyPolygon (LayerTypePtr Layer, PolygonTypePtr Polygon) +static void *CopyPolygon(LayerTypePtr Layer, PolygonTypePtr Polygon) { - PolygonTypePtr polygon; + PolygonTypePtr polygon; - polygon = CreateNewPolygon (Layer, NoFlags ()); - CopyPolygonLowLevel (polygon, Polygon); - MovePolygonLowLevel (polygon, DeltaX, DeltaY); - if (!Layer->polygon_tree) - Layer->polygon_tree = r_create_tree (NULL, 0, 0); - r_insert_entry (Layer->polygon_tree, (BoxTypePtr) polygon, 0); - InitClip (PCB->Data, Layer, polygon); - DrawPolygon (Layer, polygon); - AddObjectToCreateUndoList (POLYGON_TYPE, Layer, polygon, polygon); - return (polygon); + polygon = CreateNewPolygon(Layer, NoFlags()); + CopyPolygonLowLevel(polygon, Polygon); + MovePolygonLowLevel(polygon, DeltaX, DeltaY); + if (!Layer->polygon_tree) + Layer->polygon_tree = r_create_tree(NULL, 0, 0); + r_insert_entry(Layer->polygon_tree, (BoxTypePtr) polygon, 0); + InitClip(PCB->Data, Layer, polygon); + DrawPolygon(Layer, polygon); + AddObjectToCreateUndoList(POLYGON_TYPE, Layer, polygon, polygon); + return (polygon); } /* --------------------------------------------------------------------------- * copies an element onto the PCB. Then does a draw. */ -static void * -CopyElement (ElementTypePtr Element) +static void *CopyElement(ElementTypePtr Element) { #ifdef DEBUG - printf("Entered CopyElement, trying to copy element %s\n", - Element->Name[1].TextString); + printf("Entered CopyElement, trying to copy element %s\n", Element->Name[1].TextString); #endif - ElementTypePtr element = CopyElementLowLevel (PCB->Data, - NULL, Element, - TEST_FLAG (UNIQUENAMEFLAG, - PCB), DeltaX, - DeltaY); + ElementTypePtr element = CopyElementLowLevel(PCB->Data, + NULL, Element, + TEST_FLAG(UNIQUENAMEFLAG, + PCB), DeltaX, + DeltaY); - /* this call clears the polygons */ - AddObjectToCreateUndoList (ELEMENT_TYPE, element, element, element); - if (PCB->ElementOn && (FRONT (element) || PCB->InvisibleObjectsOn)) - { - DrawElementName (element); - DrawElementPackage (element); - } - if (PCB->PinOn) - { - DrawElementPinsAndPads (element); - } + /* this call clears the polygons */ + AddObjectToCreateUndoList(ELEMENT_TYPE, element, element, element); + if (PCB->ElementOn && (FRONT(element) || PCB->InvisibleObjectsOn)) { + DrawElementName(element); + DrawElementPackage(element); + } + if (PCB->PinOn) { + DrawElementPinsAndPads(element); + } #ifdef DEBUG - printf(" ... Leaving CopyElement.\n"); + printf(" ... Leaving CopyElement.\n"); #endif - return (element); + return (element); } /* --------------------------------------------------------------------------- @@ -319,94 +289,83 @@ * pastes the contents of the buffer to the layout. Only visible objects * are handled by the routine. */ -bool -CopyPastebufferToLayout (Coord X, Coord Y) +bool CopyPastebufferToLayout(Coord X, Coord Y) { - Cardinal i; - bool changed = false; + Cardinal i; + bool changed = false; #ifdef DEBUG - printf("Entering CopyPastebufferToLayout.....\n"); + printf("Entering CopyPastebufferToLayout.....\n"); #endif - /* set movement vector */ - DeltaX = X - PASTEBUFFER->X, DeltaY = Y - PASTEBUFFER->Y; + /* set movement vector */ + DeltaX = X - PASTEBUFFER->X, DeltaY = Y - PASTEBUFFER->Y; - /* paste all layers */ - for (i = 0; i < max_copper_layer + 2; i++) - { - LayerTypePtr sourcelayer = &PASTEBUFFER->Data->Layer[i], - destlayer = LAYER_PTR (i); + /* paste all layers */ + for (i = 0; i < max_copper_layer + 2; i++) { + LayerTypePtr sourcelayer = &PASTEBUFFER->Data->Layer[i], destlayer = LAYER_PTR(i); - if (destlayer->On) - { - changed = changed || - (sourcelayer->LineN != 0) || - (sourcelayer->ArcN != 0) || - (sourcelayer->PolygonN != 0) || (sourcelayer->TextN != 0); - LINE_LOOP (sourcelayer); - { - CopyLine (destlayer, line); - } - END_LOOP; - ARC_LOOP (sourcelayer); - { - CopyArc (destlayer, arc); - } - END_LOOP; - TEXT_LOOP (sourcelayer); - { - CopyText (destlayer, text); - } - END_LOOP; - POLYGON_LOOP (sourcelayer); - { - CopyPolygon (destlayer, polygon); - } - END_LOOP; + if (destlayer->On) { + changed = changed || + (sourcelayer->LineN != 0) || (sourcelayer->ArcN != 0) || (sourcelayer->PolygonN != 0) || (sourcelayer->TextN != 0); + LINE_LOOP(sourcelayer); + { + CopyLine(destlayer, line); + } + END_LOOP; + ARC_LOOP(sourcelayer); + { + CopyArc(destlayer, arc); + } + END_LOOP; + TEXT_LOOP(sourcelayer); + { + CopyText(destlayer, text); + } + END_LOOP; + POLYGON_LOOP(sourcelayer); + { + CopyPolygon(destlayer, polygon); + } + END_LOOP; + } } - } - /* paste elements */ - if (PCB->PinOn && PCB->ElementOn) - { - ELEMENT_LOOP (PASTEBUFFER->Data); - { + /* paste elements */ + if (PCB->PinOn && PCB->ElementOn) { + ELEMENT_LOOP(PASTEBUFFER->Data); + { #ifdef DEBUG - printf("In CopyPastebufferToLayout, pasting element %s\n", - element->Name[1].TextString); + printf("In CopyPastebufferToLayout, pasting element %s\n", element->Name[1].TextString); #endif - if (FRONT (element) || PCB->InvisibleObjectsOn) - { - CopyElement (element); - changed = true; - } - } - END_LOOP; - } + if (FRONT(element) || PCB->InvisibleObjectsOn) { + CopyElement(element); + changed = true; + } + } + END_LOOP; + } - /* finally the vias */ - if (PCB->ViaOn) - { - changed |= (PASTEBUFFER->Data->ViaN != 0); - VIA_LOOP (PASTEBUFFER->Data); - { - CopyVia (via); - } - END_LOOP; - } + /* finally the vias */ + if (PCB->ViaOn) { + changed |= (PASTEBUFFER->Data->ViaN != 0); + VIA_LOOP(PASTEBUFFER->Data); + { + CopyVia(via); + } + END_LOOP; + } - if (changed) - { - Draw (); - IncrementUndoSerialNumber (); - } + if (changed) { + Draw(); + IncrementUndoSerialNumber(); + } #ifdef DEBUG - printf(" .... Leaving CopyPastebufferToLayout.\n"); + printf(" .... Leaving CopyPastebufferToLayout.\n"); #endif - return (changed); + return (changed); } /* --------------------------------------------------------------------------- @@ -414,18 +373,16 @@ * the new objects is moved by DX,DY * I assume that the appropriate layer ... is switched on */ -void * -CopyObject (int Type, void *Ptr1, void *Ptr2, void *Ptr3, - Coord DX, Coord DY) +void *CopyObject(int Type, void *Ptr1, void *Ptr2, void *Ptr3, Coord DX, Coord DY) { - void *ptr; + void *ptr; - /* setup movement vector */ - DeltaX = DX; - DeltaY = DY; + /* setup movement vector */ + DeltaX = DX; + DeltaY = DY; - /* the subroutines add the objects to the undo-list */ - ptr = ObjectOperation (&CopyFunctions, Type, Ptr1, Ptr2, Ptr3); - IncrementUndoSerialNumber (); - return (ptr); + /* the subroutines add the objects to the undo-list */ + ptr = ObjectOperation(&CopyFunctions, Type, Ptr1, Ptr2, Ptr3); + IncrementUndoSerialNumber(); + return (ptr); } Index: trunk/src/copy.h =================================================================== --- trunk/src/copy.h (revision 1021) +++ trunk/src/copy.h (revision 1022) @@ -41,10 +41,9 @@ ELEMENT_TYPE | ELEMENTNAME_TYPE | POLYGON_TYPE | ARC_TYPE) -PolygonTypePtr CopyPolygonLowLevel (PolygonTypePtr, PolygonTypePtr); -ElementTypePtr CopyElementLowLevel (DataTypePtr, ElementTypePtr, - ElementTypePtr, bool, Coord, Coord); -bool CopyPastebufferToLayout (Coord, Coord); -void *CopyObject (int, void *, void *, void *, Coord, Coord); +PolygonTypePtr CopyPolygonLowLevel(PolygonTypePtr, PolygonTypePtr); +ElementTypePtr CopyElementLowLevel(DataTypePtr, ElementTypePtr, ElementTypePtr, bool, Coord, Coord); +bool CopyPastebufferToLayout(Coord, Coord); +void *CopyObject(int, void *, void *, void *, Coord, Coord); #endif Index: trunk/src/core_lists.h =================================================================== --- trunk/src/core_lists.h (revision 1021) +++ trunk/src/core_lists.h (revision 1022) @@ -1,16 +1,16 @@ -REGISTER_ACTIONS (action_action_list) -REGISTER_ACTIONS (rotate_action_list) -REGISTER_ACTIONS (command_action_list) -REGISTER_FLAGS (djopt_flag_list) -REGISTER_ACTIONS (djopt_action_list) -REGISTER_FLAGS (flags_flag_list) -REGISTER_ACTIONS (fontmode_action_list) -REGISTER_ATTRIBUTES (main_attribute_list) -REGISTER_ACTIONS (misc_action_list) -REGISTER_ACTIONS (move_action_list) -REGISTER_ACTIONS (netlist_action_list) -REGISTER_ACTIONS (puller_action_list) -REGISTER_ACTIONS (report_action_list) -REGISTER_ACTIONS (vendor_action_list) -REGISTER_FLAGS (vendor_flag_list) -REGISTER_ACTIONS (toporouter_action_list) +REGISTER_ACTIONS(action_action_list) + REGISTER_ACTIONS(rotate_action_list) + REGISTER_ACTIONS(command_action_list) + REGISTER_FLAGS(djopt_flag_list) + REGISTER_ACTIONS(djopt_action_list) + REGISTER_FLAGS(flags_flag_list) + REGISTER_ACTIONS(fontmode_action_list) + REGISTER_ATTRIBUTES(main_attribute_list) + REGISTER_ACTIONS(misc_action_list) + REGISTER_ACTIONS(move_action_list) + REGISTER_ACTIONS(netlist_action_list) + REGISTER_ACTIONS(puller_action_list) + REGISTER_ACTIONS(report_action_list) + REGISTER_ACTIONS(vendor_action_list) + REGISTER_FLAGS(vendor_flag_list) + REGISTER_ACTIONS(toporouter_action_list) Index: trunk/src/create.c =================================================================== --- trunk/src/create.c (revision 1021) +++ trunk/src/create.c (revision 1022) @@ -58,12 +58,12 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); /* --------------------------------------------------------------------------- * some local identifiers */ -static int ID = 1; /* current object ID; incremented after */ +static int ID = 1; /* current object ID; incremented after */ /* each creation of an object */ static bool be_lenient = false; @@ -71,30 +71,26 @@ /* ---------------------------------------------------------------------- * some local prototypes */ -static void AddTextToElement (TextTypePtr, FontTypePtr, - Coord, Coord, unsigned, char *, int, - FlagType); +static void AddTextToElement(TextTypePtr, FontTypePtr, Coord, Coord, unsigned, char *, int, FlagType); /* --------------------------------------------------------------------------- * Set the lenience mode. */ -void -CreateBeLenient (bool v) +void CreateBeLenient(bool v) { - be_lenient = v; + be_lenient = v; } /* --------------------------------------------------------------------------- * creates a new paste buffer */ -DataTypePtr -CreateNewBuffer (void) +DataTypePtr CreateNewBuffer(void) { - DataTypePtr data; - data = (DataTypePtr) calloc (1, sizeof (DataType)); - data->pcb = (PCBTypePtr) PCB; - return data; + DataTypePtr data; + data = (DataTypePtr) calloc(1, sizeof(DataType)); + data->pcb = (PCBTypePtr) PCB; + return data; } /* --------------------------------------------------------------------------- @@ -101,124 +97,115 @@ * Perhaps PCB should internally just use the Settings colors? For now, * use this to set PCB colors so the config can reassign PCB colors. */ -void -pcb_colors_from_settings (PCBTypePtr ptr) +void pcb_colors_from_settings(PCBTypePtr ptr) { - int i; + int i; - /* copy default settings */ - ptr->ConnectedColor = Settings.ConnectedColor; - ptr->ElementColor = Settings.ElementColor; - ptr->ElementColor_nonetlist = Settings.ElementColor_nonetlist; - ptr->RatColor = Settings.RatColor; - ptr->InvisibleObjectsColor = Settings.InvisibleObjectsColor; - ptr->InvisibleMarkColor = Settings.InvisibleMarkColor; - ptr->ElementSelectedColor = Settings.ElementSelectedColor; - ptr->RatSelectedColor = Settings.RatSelectedColor; - ptr->PinColor = Settings.PinColor; - ptr->PinSelectedColor = Settings.PinSelectedColor; - ptr->PinNameColor = Settings.PinNameColor; - ptr->ViaColor = Settings.ViaColor; - ptr->ViaSelectedColor = Settings.ViaSelectedColor; - ptr->WarnColor = Settings.WarnColor; - ptr->MaskColor = Settings.MaskColor; - for (i = 0; i < MAX_LAYER; i++) - { - ptr->Data->Layer[i].Color = Settings.LayerColor[i]; - ptr->Data->Layer[i].SelectedColor = Settings.LayerSelectedColor[i]; - } - ptr->Data->Layer[component_silk_layer].Color = - Settings.ShowSolderSide ? - Settings.InvisibleObjectsColor : Settings.ElementColor; - ptr->Data->Layer[component_silk_layer].SelectedColor = - Settings.ElementSelectedColor; - ptr->Data->Layer[solder_silk_layer].Color = - Settings.ShowSolderSide ? - Settings.ElementColor : Settings.InvisibleObjectsColor; - ptr->Data->Layer[solder_silk_layer].SelectedColor = - Settings.ElementSelectedColor; + /* copy default settings */ + ptr->ConnectedColor = Settings.ConnectedColor; + ptr->ElementColor = Settings.ElementColor; + ptr->ElementColor_nonetlist = Settings.ElementColor_nonetlist; + ptr->RatColor = Settings.RatColor; + ptr->InvisibleObjectsColor = Settings.InvisibleObjectsColor; + ptr->InvisibleMarkColor = Settings.InvisibleMarkColor; + ptr->ElementSelectedColor = Settings.ElementSelectedColor; + ptr->RatSelectedColor = Settings.RatSelectedColor; + ptr->PinColor = Settings.PinColor; + ptr->PinSelectedColor = Settings.PinSelectedColor; + ptr->PinNameColor = Settings.PinNameColor; + ptr->ViaColor = Settings.ViaColor; + ptr->ViaSelectedColor = Settings.ViaSelectedColor; + ptr->WarnColor = Settings.WarnColor; + ptr->MaskColor = Settings.MaskColor; + for (i = 0; i < MAX_LAYER; i++) { + ptr->Data->Layer[i].Color = Settings.LayerColor[i]; + ptr->Data->Layer[i].SelectedColor = Settings.LayerSelectedColor[i]; + } + ptr->Data->Layer[component_silk_layer].Color = + Settings.ShowSolderSide ? Settings.InvisibleObjectsColor : Settings.ElementColor; + ptr->Data->Layer[component_silk_layer].SelectedColor = Settings.ElementSelectedColor; + ptr->Data->Layer[solder_silk_layer].Color = Settings.ShowSolderSide ? Settings.ElementColor : Settings.InvisibleObjectsColor; + ptr->Data->Layer[solder_silk_layer].SelectedColor = Settings.ElementSelectedColor; } /* --------------------------------------------------------------------------- * creates a new PCB */ -PCBTypePtr -CreateNewPCB_ (bool SetDefaultNames) +PCBTypePtr CreateNewPCB_(bool SetDefaultNames) { - PCBTypePtr ptr; - int i; + PCBTypePtr ptr; + int i; - /* allocate memory, switch all layers on and copy resources */ - ptr = (PCBTypePtr)calloc (1, sizeof (PCBType)); - ptr->Data = CreateNewBuffer (); - ptr->Data->pcb = (PCBTypePtr) ptr; + /* allocate memory, switch all layers on and copy resources */ + ptr = (PCBTypePtr) calloc(1, sizeof(PCBType)); + ptr->Data = CreateNewBuffer(); + ptr->Data->pcb = (PCBTypePtr) ptr; - ptr->ThermStyle = 4; - ptr->IsleArea = 2.e8; - ptr->SilkActive = false; - ptr->RatDraw = false; - SET_FLAG (NAMEONPCBFLAG, ptr); - if (Settings.ShowNumber) - SET_FLAG (SHOWNUMBERFLAG, ptr); - if (Settings.AllDirectionLines) - SET_FLAG (ALLDIRECTIONFLAG, ptr); - ptr->Clipping = 1; /* this is the most useful starting point for now */ - if (Settings.RubberBandMode) - SET_FLAG (RUBBERBANDFLAG, ptr); - if (Settings.SwapStartDirection) - SET_FLAG (SWAPSTARTDIRFLAG, ptr); - if (Settings.UniqueNames) - SET_FLAG (UNIQUENAMEFLAG, ptr); - if (Settings.SnapPin) - SET_FLAG (SNAPPINFLAG, ptr); - if (Settings.SnapOffGridLine) - SET_FLAG (SNAPOFFGRIDLINEFLAG, ptr); - if (Settings.HighlightOnPoint) - SET_FLAG (HIGHLIGHTONPOINTFLAG, ptr); - if (Settings.ClearLine) - SET_FLAG (CLEARNEWFLAG, ptr); - if (Settings.FullPoly) - SET_FLAG (NEWFULLPOLYFLAG, ptr); - if (Settings.OrthogonalMoves) - SET_FLAG (ORTHOMOVEFLAG, ptr); - if (Settings.liveRouting) - SET_FLAG (LIVEROUTEFLAG, ptr); - if (Settings.ShowDRC) - SET_FLAG (SHOWDRCFLAG, ptr); - if (Settings.AutoDRC) - SET_FLAG (AUTODRCFLAG, ptr); - ptr->Grid = Settings.Grid; - ptr->LayerGroups = Settings.LayerGroups; - STYLE_LOOP (ptr); - { - *style = Settings.RouteStyle[n]; - style->index = n; - } - END_LOOP; - hid_action ("RouteStylesChanged"); - ptr->Zoom = Settings.Zoom; - ptr->MaxWidth = Settings.MaxWidth; - ptr->MaxHeight = Settings.MaxHeight; - ptr->ID = ID++; - ptr->ThermScale = 0.5; + ptr->ThermStyle = 4; + ptr->IsleArea = 2.e8; + ptr->SilkActive = false; + ptr->RatDraw = false; + SET_FLAG(NAMEONPCBFLAG, ptr); + if (Settings.ShowNumber) + SET_FLAG(SHOWNUMBERFLAG, ptr); + if (Settings.AllDirectionLines) + SET_FLAG(ALLDIRECTIONFLAG, ptr); + ptr->Clipping = 1; /* this is the most useful starting point for now */ + if (Settings.RubberBandMode) + SET_FLAG(RUBBERBANDFLAG, ptr); + if (Settings.SwapStartDirection) + SET_FLAG(SWAPSTARTDIRFLAG, ptr); + if (Settings.UniqueNames) + SET_FLAG(UNIQUENAMEFLAG, ptr); + if (Settings.SnapPin) + SET_FLAG(SNAPPINFLAG, ptr); + if (Settings.SnapOffGridLine) + SET_FLAG(SNAPOFFGRIDLINEFLAG, ptr); + if (Settings.HighlightOnPoint) + SET_FLAG(HIGHLIGHTONPOINTFLAG, ptr); + if (Settings.ClearLine) + SET_FLAG(CLEARNEWFLAG, ptr); + if (Settings.FullPoly) + SET_FLAG(NEWFULLPOLYFLAG, ptr); + if (Settings.OrthogonalMoves) + SET_FLAG(ORTHOMOVEFLAG, ptr); + if (Settings.liveRouting) + SET_FLAG(LIVEROUTEFLAG, ptr); + if (Settings.ShowDRC) + SET_FLAG(SHOWDRCFLAG, ptr); + if (Settings.AutoDRC) + SET_FLAG(AUTODRCFLAG, ptr); + ptr->Grid = Settings.Grid; + ptr->LayerGroups = Settings.LayerGroups; + STYLE_LOOP(ptr); + { + *style = Settings.RouteStyle[n]; + style->index = n; + } + END_LOOP; + hid_action("RouteStylesChanged"); + ptr->Zoom = Settings.Zoom; + ptr->MaxWidth = Settings.MaxWidth; + ptr->MaxHeight = Settings.MaxHeight; + ptr->ID = ID++; + ptr->ThermScale = 0.5; - ptr->Bloat = Settings.Bloat; - ptr->Shrink = Settings.Shrink; - ptr->minWid = Settings.minWid; - ptr->minSlk = Settings.minSlk; - ptr->minDrill = Settings.minDrill; - ptr->minRing = Settings.minRing; + ptr->Bloat = Settings.Bloat; + ptr->Shrink = Settings.Shrink; + ptr->minWid = Settings.minWid; + ptr->minSlk = Settings.minSlk; + ptr->minDrill = Settings.minDrill; + ptr->minRing = Settings.minRing; - for (i = 0; i < MAX_LAYER; i++) - ptr->Data->Layer[i].Name = strdup (Settings.DefaultLayerName[i]); + for (i = 0; i < MAX_LAYER; i++) + ptr->Data->Layer[i].Name = strdup(Settings.DefaultLayerName[i]); - CreateDefaultFont (ptr); + CreateDefaultFont(ptr); - return (ptr); + return (ptr); } -PCBTypePtr -CreateNewPCB () +PCBTypePtr CreateNewPCB() { PCBTypePtr old, nw; @@ -235,7 +222,7 @@ } else nw = NULL; - + PCB = old; return nw; } @@ -244,13 +231,12 @@ /* This post-processing step adds the top and bottom silk layers to a * pre-existing PCB. */ -int -CreateNewPCBPost (PCBTypePtr pcb, int use_defaults) +int CreateNewPCBPost(PCBTypePtr pcb, int use_defaults) { - /* copy default settings */ - pcb_colors_from_settings (pcb); + /* copy default settings */ + pcb_colors_from_settings(pcb); - return 0; + return 0; } /* --------------------------------------------------------------------------- @@ -257,163 +243,135 @@ * creates a new via */ PinTypePtr -CreateNewVia (DataTypePtr Data, - Coord X, Coord Y, - Coord Thickness, Coord Clearance, Coord Mask, - Coord DrillingHole, const char *Name, FlagType Flags) +CreateNewVia(DataTypePtr Data, + Coord X, Coord Y, + Coord Thickness, Coord Clearance, Coord Mask, Coord DrillingHole, const char *Name, FlagType Flags) { - PinTypePtr Via; + PinTypePtr Via; - if (!be_lenient) - { - VIA_LOOP (Data); - { - if (Distance (X, Y, via->X, via->Y) <= - via->DrillingHole / 2 + DrillingHole / 2) - { - Message (_("%m+Dropping via at %$mD because it's hole would overlap with the via " - "at %$mD\n"), Settings.grid_unit->allow, X, Y, via->X, via->Y); - return (NULL); /* don't allow via stacking */ - } - } - END_LOOP; - } + if (!be_lenient) { + VIA_LOOP(Data); + { + if (Distance(X, Y, via->X, via->Y) <= via->DrillingHole / 2 + DrillingHole / 2) { + Message(_("%m+Dropping via at %$mD because it's hole would overlap with the via " + "at %$mD\n"), Settings.grid_unit->allow, X, Y, via->X, via->Y); + return (NULL); /* don't allow via stacking */ + } + } + END_LOOP; + } - Via = GetViaMemory (Data); + Via = GetViaMemory(Data); - if (!Via) - return (Via); - /* copy values */ - Via->X = X; - Via->Y = Y; - Via->Thickness = Thickness; - Via->Clearance = Clearance; - Via->Mask = Mask; - Via->DrillingHole = vendorDrillMap (DrillingHole); - if (Via->DrillingHole != DrillingHole) - { - Message (_("%m+Mapped via drill hole to %$mS from %$mS per vendor table\n"), - Settings.grid_unit->allow, Via->DrillingHole, DrillingHole); - } + if (!Via) + return (Via); + /* copy values */ + Via->X = X; + Via->Y = Y; + Via->Thickness = Thickness; + Via->Clearance = Clearance; + Via->Mask = Mask; + Via->DrillingHole = vendorDrillMap(DrillingHole); + if (Via->DrillingHole != DrillingHole) { + Message(_("%m+Mapped via drill hole to %$mS from %$mS per vendor table\n"), + Settings.grid_unit->allow, Via->DrillingHole, DrillingHole); + } - Via->Name = STRDUP (Name); - Via->Flags = Flags; - CLEAR_FLAG (WARNFLAG, Via); - SET_FLAG (VIAFLAG, Via); - Via->ID = ID++; + Via->Name = STRDUP(Name); + Via->Flags = Flags; + CLEAR_FLAG(WARNFLAG, Via); + SET_FLAG(VIAFLAG, Via); + Via->ID = ID++; - /* - * don't complain about MIN_PINORVIACOPPER on a mounting hole (pure - * hole) - */ - if (!TEST_FLAG (HOLEFLAG, Via) && - (Via->Thickness < Via->DrillingHole + MIN_PINORVIACOPPER)) - { - Via->Thickness = Via->DrillingHole + MIN_PINORVIACOPPER; - Message (_("%m+Increased via thickness to %$mS to allow enough copper" - " at %$mD.\n"), - Settings.grid_unit->allow, Via->Thickness, Via->X, Via->Y); - } + /* + * don't complain about MIN_PINORVIACOPPER on a mounting hole (pure + * hole) + */ + if (!TEST_FLAG(HOLEFLAG, Via) && (Via->Thickness < Via->DrillingHole + MIN_PINORVIACOPPER)) { + Via->Thickness = Via->DrillingHole + MIN_PINORVIACOPPER; + Message(_("%m+Increased via thickness to %$mS to allow enough copper" + " at %$mD.\n"), Settings.grid_unit->allow, Via->Thickness, Via->X, Via->Y); + } - SetPinBoundingBox (Via); - if (!Data->via_tree) - Data->via_tree = r_create_tree (NULL, 0, 0); - r_insert_entry (Data->via_tree, (BoxTypePtr) Via, 0); - return (Via); + SetPinBoundingBox(Via); + if (!Data->via_tree) + Data->via_tree = r_create_tree(NULL, 0, 0); + r_insert_entry(Data->via_tree, (BoxTypePtr) Via, 0); + return (Via); } -struct line_info -{ - Coord X1, X2, Y1, Y2; - Coord Thickness; - FlagType Flags; - LineType test, *ans; - jmp_buf env; +struct line_info { + Coord X1, X2, Y1, Y2; + Coord Thickness; + FlagType Flags; + LineType test, *ans; + jmp_buf env; }; -static int -line_callback (const BoxType * b, void *cl) +static int line_callback(const BoxType * b, void *cl) { - LineTypePtr line = (LineTypePtr) b; - struct line_info *i = (struct line_info *) cl; + LineTypePtr line = (LineTypePtr) b; + struct line_info *i = (struct line_info *) cl; - if (line->Point1.X == i->X1 && - line->Point2.X == i->X2 && - line->Point1.Y == i->Y1 && line->Point2.Y == i->Y2) - { - i->ans = (LineTypePtr) (-1); - longjmp (i->env, 1); - } - /* check the other point order */ - if (line->Point1.X == i->X1 && - line->Point2.X == i->X2 && - line->Point1.Y == i->Y1 && line->Point2.Y == i->Y2) - { - i->ans = (LineTypePtr) (-1); - longjmp (i->env, 1); - } - if (line->Point2.X == i->X1 && - line->Point1.X == i->X2 && - line->Point2.Y == i->Y1 && line->Point1.Y == i->Y2) - { - i->ans = (LineTypePtr) - 1; - longjmp (i->env, 1); - } - /* remove unnecessary line points */ - if (line->Thickness == i->Thickness - /* don't merge lines if the clear flags differ */ - && TEST_FLAG (CLEARLINEFLAG, line) == TEST_FLAG (CLEARLINEFLAG, i)) - { - if (line->Point1.X == i->X1 && line->Point1.Y == i->Y1) - { - i->test.Point1.X = line->Point2.X; - i->test.Point1.Y = line->Point2.Y; - i->test.Point2.X = i->X2; - i->test.Point2.Y = i->Y2; - if (IsPointOnLine (i->X1, i->Y1, 0.0, &i->test)) - { - i->ans = line; - longjmp (i->env, 1); - } + if (line->Point1.X == i->X1 && line->Point2.X == i->X2 && line->Point1.Y == i->Y1 && line->Point2.Y == i->Y2) { + i->ans = (LineTypePtr) (-1); + longjmp(i->env, 1); } - else if (line->Point2.X == i->X1 && line->Point2.Y == i->Y1) - { - i->test.Point1.X = line->Point1.X; - i->test.Point1.Y = line->Point1.Y; - i->test.Point2.X = i->X2; - i->test.Point2.Y = i->Y2; - if (IsPointOnLine (i->X1, i->Y1, 0.0, &i->test)) - { - i->ans = line; - longjmp (i->env, 1); - } + /* check the other point order */ + if (line->Point1.X == i->X1 && line->Point2.X == i->X2 && line->Point1.Y == i->Y1 && line->Point2.Y == i->Y2) { + i->ans = (LineTypePtr) (-1); + longjmp(i->env, 1); } - else if (line->Point1.X == i->X2 && line->Point1.Y == i->Y2) - { - i->test.Point1.X = line->Point2.X; - i->test.Point1.Y = line->Point2.Y; - i->test.Point2.X = i->X1; - i->test.Point2.Y = i->Y1; - if (IsPointOnLine (i->X2, i->Y2, 0.0, &i->test)) - { - i->ans = line; - longjmp (i->env, 1); - } + if (line->Point2.X == i->X1 && line->Point1.X == i->X2 && line->Point2.Y == i->Y1 && line->Point1.Y == i->Y2) { + i->ans = (LineTypePtr) - 1; + longjmp(i->env, 1); } - else if (line->Point2.X == i->X2 && line->Point2.Y == i->Y2) - { - i->test.Point1.X = line->Point1.X; - i->test.Point1.Y = line->Point1.Y; - i->test.Point2.X = i->X1; - i->test.Point2.Y = i->Y1; - if (IsPointOnLine (i->X2, i->Y2, 0.0, &i->test)) - { - i->ans = line; - longjmp (i->env, 1); - } + /* remove unnecessary line points */ + if (line->Thickness == i->Thickness + /* don't merge lines if the clear flags differ */ + && TEST_FLAG(CLEARLINEFLAG, line) == TEST_FLAG(CLEARLINEFLAG, i)) { + if (line->Point1.X == i->X1 && line->Point1.Y == i->Y1) { + i->test.Point1.X = line->Point2.X; + i->test.Point1.Y = line->Point2.Y; + i->test.Point2.X = i->X2; + i->test.Point2.Y = i->Y2; + if (IsPointOnLine(i->X1, i->Y1, 0.0, &i->test)) { + i->ans = line; + longjmp(i->env, 1); + } + } + else if (line->Point2.X == i->X1 && line->Point2.Y == i->Y1) { + i->test.Point1.X = line->Point1.X; + i->test.Point1.Y = line->Point1.Y; + i->test.Point2.X = i->X2; + i->test.Point2.Y = i->Y2; + if (IsPointOnLine(i->X1, i->Y1, 0.0, &i->test)) { + i->ans = line; + longjmp(i->env, 1); + } + } + else if (line->Point1.X == i->X2 && line->Point1.Y == i->Y2) { + i->test.Point1.X = line->Point2.X; + i->test.Point1.Y = line->Point2.Y; + i->test.Point2.X = i->X1; + i->test.Point2.Y = i->Y1; + if (IsPointOnLine(i->X2, i->Y2, 0.0, &i->test)) { + i->ans = line; + longjmp(i->env, 1); + } + } + else if (line->Point2.X == i->X2 && line->Point2.Y == i->Y2) { + i->test.Point1.X = line->Point1.X; + i->test.Point1.Y = line->Point1.Y; + i->test.Point2.X = i->X1; + i->test.Point2.Y = i->Y1; + if (IsPointOnLine(i->X2, i->Y2, 0.0, &i->test)) { + i->ans = line; + longjmp(i->env, 1); + } + } } - } - return 0; + return 0; } @@ -421,87 +379,77 @@ * creates a new line on a layer and checks for overlap and extension */ LineTypePtr -CreateDrawnLineOnLayer (LayerTypePtr Layer, - Coord X1, Coord Y1, - Coord X2, Coord Y2, - Coord Thickness, Coord Clearance, - FlagType Flags) +CreateDrawnLineOnLayer(LayerTypePtr Layer, + Coord X1, Coord Y1, Coord X2, Coord Y2, Coord Thickness, Coord Clearance, FlagType Flags) { - struct line_info info; - BoxType search; + struct line_info info; + BoxType search; - search.X1 = MIN (X1, X2); - search.X2 = MAX (X1, X2); - search.Y1 = MIN (Y1, Y2); - search.Y2 = MAX (Y1, Y2); - if (search.Y2 == search.Y1) - search.Y2++; - if (search.X2 == search.X1) - search.X2++; - info.X1 = X1; - info.X2 = X2; - info.Y1 = Y1; - info.Y2 = Y2; - info.Thickness = Thickness; - info.Flags = Flags; - info.test.Thickness = 0; - info.test.Flags = NoFlags (); - info.ans = NULL; - /* prevent stacking of duplicate lines - * and remove needless intermediate points - * verify that the layer is on the board first! - */ - if (setjmp (info.env) == 0) - { - r_search (Layer->line_tree, &search, NULL, line_callback, &info); - return CreateNewLineOnLayer (Layer, X1, Y1, X2, Y2, - Thickness, Clearance, Flags); - } + search.X1 = MIN(X1, X2); + search.X2 = MAX(X1, X2); + search.Y1 = MIN(Y1, Y2); + search.Y2 = MAX(Y1, Y2); + if (search.Y2 == search.Y1) + search.Y2++; + if (search.X2 == search.X1) + search.X2++; + info.X1 = X1; + info.X2 = X2; + info.Y1 = Y1; + info.Y2 = Y2; + info.Thickness = Thickness; + info.Flags = Flags; + info.test.Thickness = 0; + info.test.Flags = NoFlags(); + info.ans = NULL; + /* prevent stacking of duplicate lines + * and remove needless intermediate points + * verify that the layer is on the board first! + */ + if (setjmp(info.env) == 0) { + r_search(Layer->line_tree, &search, NULL, line_callback, &info); + return CreateNewLineOnLayer(Layer, X1, Y1, X2, Y2, Thickness, Clearance, Flags); + } - if ((void *) info.ans == (void *) (-1)) - return NULL; /* stacked line */ - /* remove unnecessary points */ - if (info.ans) - { - /* must do this BEFORE getting new line memory */ - MoveObjectToRemoveUndoList (LINE_TYPE, Layer, info.ans, info.ans); - X1 = info.test.Point1.X; - X2 = info.test.Point2.X; - Y1 = info.test.Point1.Y; - Y2 = info.test.Point2.Y; - } - return CreateNewLineOnLayer (Layer, X1, Y1, X2, Y2, - Thickness, Clearance, Flags); + if ((void *) info.ans == (void *) (-1)) + return NULL; /* stacked line */ + /* remove unnecessary points */ + if (info.ans) { + /* must do this BEFORE getting new line memory */ + MoveObjectToRemoveUndoList(LINE_TYPE, Layer, info.ans, info.ans); + X1 = info.test.Point1.X; + X2 = info.test.Point2.X; + Y1 = info.test.Point1.Y; + Y2 = info.test.Point2.Y; + } + return CreateNewLineOnLayer(Layer, X1, Y1, X2, Y2, Thickness, Clearance, Flags); } LineTypePtr -CreateNewLineOnLayer (LayerTypePtr Layer, - Coord X1, Coord Y1, - Coord X2, Coord Y2, - Coord Thickness, Coord Clearance, - FlagType Flags) +CreateNewLineOnLayer(LayerTypePtr Layer, + Coord X1, Coord Y1, Coord X2, Coord Y2, Coord Thickness, Coord Clearance, FlagType Flags) { - LineTypePtr Line; + LineTypePtr Line; - Line = GetLineMemory (Layer); - if (!Line) - return (Line); - Line->ID = ID++; - Line->Flags = Flags; - CLEAR_FLAG (RATFLAG, Line); - Line->Thickness = Thickness; - Line->Clearance = Clearance; - Line->Point1.X = X1; - Line->Point1.Y = Y1; - Line->Point1.ID = ID++; - Line->Point2.X = X2; - Line->Point2.Y = Y2; - Line->Point2.ID = ID++; - SetLineBoundingBox (Line); - if (!Layer->line_tree) - Layer->line_tree = r_create_tree (NULL, 0, 0); - r_insert_entry (Layer->line_tree, (BoxTypePtr) Line, 0); - return (Line); + Line = GetLineMemory(Layer); + if (!Line) + return (Line); + Line->ID = ID++; + Line->Flags = Flags; + CLEAR_FLAG(RATFLAG, Line); + Line->Thickness = Thickness; + Line->Clearance = Clearance; + Line->Point1.X = X1; + Line->Point1.Y = Y1; + Line->Point1.ID = ID++; + Line->Point2.X = X2; + Line->Point2.Y = Y2; + Line->Point2.ID = ID++; + SetLineBoundingBox(Line); + if (!Layer->line_tree) + Layer->line_tree = r_create_tree(NULL, 0, 0); + r_insert_entry(Layer->line_tree, (BoxTypePtr) Line, 0); + return (Line); } /* --------------------------------------------------------------------------- @@ -508,32 +456,31 @@ * creates a new rat-line */ RatTypePtr -CreateNewRat (DataTypePtr Data, Coord X1, Coord Y1, - Coord X2, Coord Y2, Cardinal group1, - Cardinal group2, Coord Thickness, FlagType Flags) +CreateNewRat(DataTypePtr Data, Coord X1, Coord Y1, + Coord X2, Coord Y2, Cardinal group1, Cardinal group2, Coord Thickness, FlagType Flags) { - RatTypePtr Line = GetRatMemory (Data); + RatTypePtr Line = GetRatMemory(Data); - if (!Line) - return (Line); + if (!Line) + return (Line); - Line->ID = ID++; - Line->Flags = Flags; - SET_FLAG (RATFLAG, Line); - Line->Thickness = Thickness; - Line->Point1.X = X1; - Line->Point1.Y = Y1; - Line->Point1.ID = ID++; - Line->Point2.X = X2; - Line->Point2.Y = Y2; - Line->Point2.ID = ID++; - Line->group1 = group1; - Line->group2 = group2; - SetLineBoundingBox ((LineTypePtr) Line); - if (!Data->rat_tree) - Data->rat_tree = r_create_tree (NULL, 0, 0); - r_insert_entry (Data->rat_tree, &Line->BoundingBox, 0); - return (Line); + Line->ID = ID++; + Line->Flags = Flags; + SET_FLAG(RATFLAG, Line); + Line->Thickness = Thickness; + Line->Point1.X = X1; + Line->Point1.Y = Y1; + Line->Point1.ID = ID++; + Line->Point2.X = X2; + Line->Point2.Y = Y2; + Line->Point2.ID = ID++; + Line->group1 = group1; + Line->group2 = group2; + SetLineBoundingBox((LineTypePtr) Line); + if (!Data->rat_tree) + Data->rat_tree = r_create_tree(NULL, 0, 0); + r_insert_entry(Data->rat_tree, &Line->BoundingBox, 0); + return (Line); } /* --------------------------------------------------------------------------- @@ -540,43 +487,38 @@ * creates a new arc on a layer */ ArcTypePtr -CreateNewArcOnLayer (LayerTypePtr Layer, - Coord X1, Coord Y1, - Coord width, - Coord height, - Angle sa, - Angle dir, Coord Thickness, - Coord Clearance, FlagType Flags) +CreateNewArcOnLayer(LayerTypePtr Layer, + Coord X1, Coord Y1, + Coord width, Coord height, Angle sa, Angle dir, Coord Thickness, Coord Clearance, FlagType Flags) { - ArcTypePtr Arc; + ArcTypePtr Arc; - ARC_LOOP (Layer); - { - if (arc->X == X1 && arc->Y == Y1 && arc->Width == width && - NormalizeAngle (arc->StartAngle) == NormalizeAngle (sa) && - arc->Delta == dir) - return (NULL); /* prevent stacked arcs */ - } - END_LOOP; - Arc = GetArcMemory (Layer); - if (!Arc) - return (Arc); + ARC_LOOP(Layer); + { + if (arc->X == X1 && arc->Y == Y1 && arc->Width == width && + NormalizeAngle(arc->StartAngle) == NormalizeAngle(sa) && arc->Delta == dir) + return (NULL); /* prevent stacked arcs */ + } + END_LOOP; + Arc = GetArcMemory(Layer); + if (!Arc) + return (Arc); - Arc->ID = ID++; - Arc->Flags = Flags; - Arc->Thickness = Thickness; - Arc->Clearance = Clearance; - Arc->X = X1; - Arc->Y = Y1; - Arc->Width = width; - Arc->Height = height; - Arc->StartAngle = sa; - Arc->Delta = dir; - SetArcBoundingBox (Arc); - if (!Layer->arc_tree) - Layer->arc_tree = r_create_tree (NULL, 0, 0); - r_insert_entry (Layer->arc_tree, (BoxTypePtr) Arc, 0); - return (Arc); + Arc->ID = ID++; + Arc->Flags = Flags; + Arc->Thickness = Thickness; + Arc->Clearance = Clearance; + Arc->X = X1; + Arc->Y = Y1; + Arc->Width = width; + Arc->Height = height; + Arc->StartAngle = sa; + Arc->Delta = dir; + SetArcBoundingBox(Arc); + if (!Layer->arc_tree) + Layer->arc_tree = r_create_tree(NULL, 0, 0); + r_insert_entry(Layer->arc_tree, (BoxTypePtr) Arc, 0); + return (Arc); } @@ -583,25 +525,21 @@ /* --------------------------------------------------------------------------- * creates a new polygon from the old formats rectangle data */ -PolygonTypePtr -CreateNewPolygonFromRectangle (LayerTypePtr Layer, - Coord X1, Coord Y1, - Coord X2, Coord Y2, - FlagType Flags) +PolygonTypePtr CreateNewPolygonFromRectangle(LayerTypePtr Layer, Coord X1, Coord Y1, Coord X2, Coord Y2, FlagType Flags) { - PolygonTypePtr polygon = CreateNewPolygon (Layer, Flags); - if (!polygon) - return (polygon); + PolygonTypePtr polygon = CreateNewPolygon(Layer, Flags); + if (!polygon) + return (polygon); - CreateNewPointInPolygon (polygon, X1, Y1); - CreateNewPointInPolygon (polygon, X2, Y1); - CreateNewPointInPolygon (polygon, X2, Y2); - CreateNewPointInPolygon (polygon, X1, Y2); - SetPolygonBoundingBox (polygon); - if (!Layer->polygon_tree) - Layer->polygon_tree = r_create_tree (NULL, 0, 0); - r_insert_entry (Layer->polygon_tree, (BoxTypePtr) polygon, 0); - return (polygon); + CreateNewPointInPolygon(polygon, X1, Y1); + CreateNewPointInPolygon(polygon, X2, Y1); + CreateNewPointInPolygon(polygon, X2, Y2); + CreateNewPointInPolygon(polygon, X1, Y2); + SetPolygonBoundingBox(polygon); + if (!Layer->polygon_tree) + Layer->polygon_tree = r_create_tree(NULL, 0, 0); + r_insert_entry(Layer->polygon_tree, (BoxTypePtr) polygon, 0); + return (polygon); } /* --------------------------------------------------------------------------- @@ -608,79 +546,75 @@ * creates a new text on a layer */ TextTypePtr -CreateNewText (LayerTypePtr Layer, FontTypePtr PCBFont, - Coord X, Coord Y, - unsigned Direction, int Scale, char *TextString, FlagType Flags) +CreateNewText(LayerTypePtr Layer, FontTypePtr PCBFont, + Coord X, Coord Y, unsigned Direction, int Scale, char *TextString, FlagType Flags) { - TextType *text; + TextType *text; - if (TextString == NULL) - return NULL; + if (TextString == NULL) + return NULL; - text = GetTextMemory (Layer); - if (text == NULL) - return NULL; + text = GetTextMemory(Layer); + if (text == NULL) + return NULL; - /* copy values, width and height are set by drawing routine - * because at this point we don't know which symbols are available - */ - text->X = X; - text->Y = Y; - text->Direction = Direction; - text->Flags = Flags; - text->Scale = Scale; - text->TextString = strdup (TextString); + /* copy values, width and height are set by drawing routine + * because at this point we don't know which symbols are available + */ + text->X = X; + text->Y = Y; + text->Direction = Direction; + text->Flags = Flags; + text->Scale = Scale; + text->TextString = strdup(TextString); - /* calculate size of the bounding box */ - SetTextBoundingBox (PCBFont, text); - text->ID = ID++; - if (!Layer->text_tree) - Layer->text_tree = r_create_tree (NULL, 0, 0); - r_insert_entry (Layer->text_tree, (BoxTypePtr) text, 0); - return (text); + /* calculate size of the bounding box */ + SetTextBoundingBox(PCBFont, text); + text->ID = ID++; + if (!Layer->text_tree) + Layer->text_tree = r_create_tree(NULL, 0, 0); + r_insert_entry(Layer->text_tree, (BoxTypePtr) text, 0); + return (text); } /* --------------------------------------------------------------------------- * creates a new polygon on a layer */ -PolygonTypePtr -CreateNewPolygon (LayerTypePtr Layer, FlagType Flags) +PolygonTypePtr CreateNewPolygon(LayerTypePtr Layer, FlagType Flags) { - PolygonTypePtr polygon = GetPolygonMemory (Layer); + PolygonTypePtr polygon = GetPolygonMemory(Layer); - /* copy values */ - polygon->Flags = Flags; - polygon->ID = ID++; - polygon->Clipped = NULL; - polygon->NoHoles = NULL; - polygon->NoHolesValid = 0; - return (polygon); + /* copy values */ + polygon->Flags = Flags; + polygon->ID = ID++; + polygon->Clipped = NULL; + polygon->NoHoles = NULL; + polygon->NoHolesValid = 0; + return (polygon); } /* --------------------------------------------------------------------------- * creates a new point in a polygon */ -PointTypePtr -CreateNewPointInPolygon (PolygonTypePtr Polygon, Coord X, Coord Y) +PointTypePtr CreateNewPointInPolygon(PolygonTypePtr Polygon, Coord X, Coord Y) { - PointTypePtr point = GetPointMemoryInPolygon (Polygon); + PointTypePtr point = GetPointMemoryInPolygon(Polygon); - /* copy values */ - point->X = X; - point->Y = Y; - point->ID = ID++; - return (point); + /* copy values */ + point->X = X; + point->Y = Y; + point->ID = ID++; + return (point); } /* --------------------------------------------------------------------------- * creates a new hole in a polygon */ -PolygonType * -CreateNewHoleInPolygon (PolygonType *Polygon) +PolygonType *CreateNewHoleInPolygon(PolygonType * Polygon) { - Cardinal *holeindex = GetHoleIndexMemoryInPolygon (Polygon); - *holeindex = Polygon->PointN; - return Polygon; + Cardinal *holeindex = GetHoleIndexMemoryInPolygon(Polygon); + *holeindex = Polygon->PointN; + return Polygon; } /* --------------------------------------------------------------------------- @@ -688,41 +622,37 @@ * memory is allocated if needed */ ElementTypePtr -CreateNewElement (DataTypePtr Data, ElementTypePtr Element, - FontTypePtr PCBFont, - FlagType Flags, - char *Description, char *NameOnPCB, char *Value, - Coord TextX, Coord TextY, BYTE Direction, - int TextScale, FlagType TextFlags, bool uniqueName) +CreateNewElement(DataTypePtr Data, ElementTypePtr Element, + FontTypePtr PCBFont, + FlagType Flags, + char *Description, char *NameOnPCB, char *Value, + Coord TextX, Coord TextY, BYTE Direction, int TextScale, FlagType TextFlags, bool uniqueName) { #ifdef DEBUG - printf("Entered CreateNewElement.....\n"); + printf("Entered CreateNewElement.....\n"); #endif - if (!Element) - Element = GetElementMemory (Data); + if (!Element) + Element = GetElementMemory(Data); - /* copy values and set additional information */ - TextScale = MAX (MIN_TEXTSCALE, TextScale); - AddTextToElement (&DESCRIPTION_TEXT (Element), PCBFont, TextX, TextY, - Direction, Description, TextScale, TextFlags); - if (uniqueName) - NameOnPCB = UniqueElementName (Data, NameOnPCB); - AddTextToElement (&NAMEONPCB_TEXT (Element), PCBFont, TextX, TextY, - Direction, NameOnPCB, TextScale, TextFlags); - AddTextToElement (&VALUE_TEXT (Element), PCBFont, TextX, TextY, - Direction, Value, TextScale, TextFlags); - DESCRIPTION_TEXT (Element).Element = Element; - NAMEONPCB_TEXT (Element).Element = Element; - VALUE_TEXT (Element).Element = Element; - Element->Flags = Flags; - Element->ID = ID++; + /* copy values and set additional information */ + TextScale = MAX(MIN_TEXTSCALE, TextScale); + AddTextToElement(&DESCRIPTION_TEXT(Element), PCBFont, TextX, TextY, Direction, Description, TextScale, TextFlags); + if (uniqueName) + NameOnPCB = UniqueElementName(Data, NameOnPCB); + AddTextToElement(&NAMEONPCB_TEXT(Element), PCBFont, TextX, TextY, Direction, NameOnPCB, TextScale, TextFlags); + AddTextToElement(&VALUE_TEXT(Element), PCBFont, TextX, TextY, Direction, Value, TextScale, TextFlags); + DESCRIPTION_TEXT(Element).Element = Element; + NAMEONPCB_TEXT(Element).Element = Element; + VALUE_TEXT(Element).Element = Element; + Element->Flags = Flags; + Element->ID = ID++; #ifdef DEBUG - printf(" .... Leaving CreateNewElement.\n"); + printf(" .... Leaving CreateNewElement.\n"); #endif - return (Element); + return (Element); } /* --------------------------------------------------------------------------- @@ -729,67 +659,60 @@ * creates a new arc in an element */ ArcTypePtr -CreateNewArcInElement (ElementTypePtr Element, - Coord X, Coord Y, - Coord Width, Coord Height, - Angle angle, Angle delta, Coord Thickness) +CreateNewArcInElement(ElementTypePtr Element, + Coord X, Coord Y, Coord Width, Coord Height, Angle angle, Angle delta, Coord Thickness) { - ArcType *arc; + ArcType *arc; - arc = g_slice_new0 (ArcType); - Element->Arc = g_list_append (Element->Arc, arc); - Element->ArcN ++; + arc = g_slice_new0(ArcType); + Element->Arc = g_list_append(Element->Arc, arc); + Element->ArcN++; - /* set Delta (0,360], StartAngle in [0,360) */ - if (delta < 0) - { - delta = -delta; - angle -= delta; - } - angle = NormalizeAngle (angle); - delta = NormalizeAngle (delta); - if (delta == 0) - delta = 360; + /* set Delta (0,360], StartAngle in [0,360) */ + if (delta < 0) { + delta = -delta; + angle -= delta; + } + angle = NormalizeAngle(angle); + delta = NormalizeAngle(delta); + if (delta == 0) + delta = 360; - /* copy values */ - arc->X = X; - arc->Y = Y; - arc->Width = Width; - arc->Height = Height; - arc->StartAngle = angle; - arc->Delta = delta; - arc->Thickness = Thickness; - arc->ID = ID++; - return arc; + /* copy values */ + arc->X = X; + arc->Y = Y; + arc->Width = Width; + arc->Height = Height; + arc->StartAngle = angle; + arc->Delta = delta; + arc->Thickness = Thickness; + arc->ID = ID++; + return arc; } /* --------------------------------------------------------------------------- * creates a new line for an element */ -LineTypePtr -CreateNewLineInElement (ElementTypePtr Element, - Coord X1, Coord Y1, - Coord X2, Coord Y2, - Coord Thickness) +LineTypePtr CreateNewLineInElement(ElementTypePtr Element, Coord X1, Coord Y1, Coord X2, Coord Y2, Coord Thickness) { - LineType *line; + LineType *line; - if (Thickness == 0) - return NULL; + if (Thickness == 0) + return NULL; - line = g_slice_new0 (LineType); - Element->Line = g_list_append (Element->Line, line); - Element->LineN ++; + line = g_slice_new0(LineType); + Element->Line = g_list_append(Element->Line, line); + Element->LineN++; - /* copy values */ - line->Point1.X = X1; - line->Point1.Y = Y1; - line->Point2.X = X2; - line->Point2.Y = Y2; - line->Thickness = Thickness; - line->Flags = NoFlags (); - line->ID = ID++; - return line; + /* copy values */ + line->Point1.X = X1; + line->Point1.Y = Y1; + line->Point2.X = X2; + line->Point2.Y = Y2; + line->Thickness = Thickness; + line->Flags = NoFlags(); + line->ID = ID++; + return line; } /* --------------------------------------------------------------------------- @@ -796,69 +719,61 @@ * creates a new pin in an element */ PinTypePtr -CreateNewPin (ElementTypePtr Element, - Coord X, Coord Y, - Coord Thickness, Coord Clearance, Coord Mask, - Coord DrillingHole, char *Name, char *Number, - FlagType Flags) +CreateNewPin(ElementTypePtr Element, + Coord X, Coord Y, + Coord Thickness, Coord Clearance, Coord Mask, Coord DrillingHole, char *Name, char *Number, FlagType Flags) { - PinTypePtr pin = GetPinMemory (Element); + PinTypePtr pin = GetPinMemory(Element); - /* copy values */ - pin->X = X; - pin->Y = Y; - pin->Thickness = Thickness; - pin->Clearance = Clearance; - pin->Mask = Mask; - pin->Name = STRDUP (Name); - pin->Number = STRDUP (Number); - pin->Flags = Flags; - CLEAR_FLAG (WARNFLAG, pin); - SET_FLAG (PINFLAG, pin); - pin->ID = ID++; - pin->Element = Element; + /* copy values */ + pin->X = X; + pin->Y = Y; + pin->Thickness = Thickness; + pin->Clearance = Clearance; + pin->Mask = Mask; + pin->Name = STRDUP(Name); + pin->Number = STRDUP(Number); + pin->Flags = Flags; + CLEAR_FLAG(WARNFLAG, pin); + SET_FLAG(PINFLAG, pin); + pin->ID = ID++; + pin->Element = Element; - /* - * If there is no vendor drill map installed, this will simply - * return DrillingHole. - */ - pin->DrillingHole = vendorDrillMap (DrillingHole); + /* + * If there is no vendor drill map installed, this will simply + * return DrillingHole. + */ + pin->DrillingHole = vendorDrillMap(DrillingHole); - /* Unless we should not map drills on this element, map them! */ - if (vendorIsElementMappable (Element)) - { - if (pin->DrillingHole < MIN_PINORVIASIZE) - { - Message (_("%m+Did not map pin #%s (%s) drill hole because %$mS is below the minimum allowed size\n"), - Settings.grid_unit->allow, UNKNOWN (Number), UNKNOWN (Name), pin->DrillingHole); - pin->DrillingHole = DrillingHole; + /* Unless we should not map drills on this element, map them! */ + if (vendorIsElementMappable(Element)) { + if (pin->DrillingHole < MIN_PINORVIASIZE) { + Message(_("%m+Did not map pin #%s (%s) drill hole because %$mS is below the minimum allowed size\n"), + Settings.grid_unit->allow, UNKNOWN(Number), UNKNOWN(Name), pin->DrillingHole); + pin->DrillingHole = DrillingHole; + } + else if (pin->DrillingHole > MAX_PINORVIASIZE) { + Message(_("%m+Did not map pin #%s (%s) drill hole because %$mS is above the maximum allowed size\n"), + Settings.grid_unit->allow, UNKNOWN(Number), UNKNOWN(Name), pin->DrillingHole); + pin->DrillingHole = DrillingHole; + } + else if (!TEST_FLAG(HOLEFLAG, pin) + && (pin->DrillingHole > pin->Thickness - MIN_PINORVIACOPPER)) { + Message(_("%m+Did not map pin #%s (%s) drill hole because %$mS does not leave enough copper\n"), + Settings.grid_unit->allow, UNKNOWN(Number), UNKNOWN(Name), pin->DrillingHole); + pin->DrillingHole = DrillingHole; + } } - else if (pin->DrillingHole > MAX_PINORVIASIZE) - { - Message (_("%m+Did not map pin #%s (%s) drill hole because %$mS is above the maximum allowed size\n"), - Settings.grid_unit->allow, UNKNOWN (Number), UNKNOWN (Name), pin->DrillingHole); - pin->DrillingHole = DrillingHole; + else { + pin->DrillingHole = DrillingHole; } - else if (!TEST_FLAG (HOLEFLAG, pin) - && (pin->DrillingHole > pin->Thickness - MIN_PINORVIACOPPER)) - { - Message (_("%m+Did not map pin #%s (%s) drill hole because %$mS does not leave enough copper\n"), - Settings.grid_unit->allow, UNKNOWN (Number), UNKNOWN (Name), pin->DrillingHole); - pin->DrillingHole = DrillingHole; + + if (pin->DrillingHole != DrillingHole) { + Message(_("%m+Mapped pin drill hole to %$mS from %$mS per vendor table\n"), + Settings.grid_unit->allow, pin->DrillingHole, DrillingHole); } - } - else - { - pin->DrillingHole = DrillingHole; - } - if (pin->DrillingHole != DrillingHole) - { - Message (_("%m+Mapped pin drill hole to %$mS from %$mS per vendor table\n"), - Settings.grid_unit->allow, pin->DrillingHole, DrillingHole); - } - - return (pin); + return (pin); } /* --------------------------------------------------------------------------- @@ -865,38 +780,35 @@ * creates a new pad in an element */ PadTypePtr -CreateNewPad (ElementTypePtr Element, - Coord X1, Coord Y1, Coord X2, - Coord Y2, Coord Thickness, Coord Clearance, - Coord Mask, char *Name, char *Number, FlagType Flags) +CreateNewPad(ElementTypePtr Element, + Coord X1, Coord Y1, Coord X2, + Coord Y2, Coord Thickness, Coord Clearance, Coord Mask, char *Name, char *Number, FlagType Flags) { - PadTypePtr pad = GetPadMemory (Element); + PadTypePtr pad = GetPadMemory(Element); - /* copy values */ - if (X1 > X2 || (X1 == X2 && Y1 > Y2)) - { - pad->Point1.X = X2; - pad->Point1.Y = Y2; - pad->Point2.X = X1; - pad->Point2.Y = Y1; - } - else - { - pad->Point1.X = X1; - pad->Point1.Y = Y1; - pad->Point2.X = X2; - pad->Point2.Y = Y2; - } - pad->Thickness = Thickness; - pad->Clearance = Clearance; - pad->Mask = Mask; - pad->Name = STRDUP (Name); - pad->Number = STRDUP (Number); - pad->Flags = Flags; - CLEAR_FLAG (WARNFLAG, pad); - pad->ID = ID++; - pad->Element = Element; - return (pad); + /* copy values */ + if (X1 > X2 || (X1 == X2 && Y1 > Y2)) { + pad->Point1.X = X2; + pad->Point1.Y = Y2; + pad->Point2.X = X1; + pad->Point2.Y = Y1; + } + else { + pad->Point1.X = X1; + pad->Point1.Y = Y1; + pad->Point2.X = X2; + pad->Point2.Y = Y2; + } + pad->Thickness = Thickness; + pad->Clearance = Clearance; + pad->Mask = Mask; + pad->Name = STRDUP(Name); + pad->Number = STRDUP(Number); + pad->Flags = Flags; + CLEAR_FLAG(WARNFLAG, pad); + pad->ID = ID++; + pad->Element = Element; + return (pad); } /* --------------------------------------------------------------------------- @@ -904,50 +816,45 @@ * copies the values to the appropriate text object */ static void -AddTextToElement (TextTypePtr Text, FontTypePtr PCBFont, - Coord X, Coord Y, - unsigned Direction, char *TextString, int Scale, FlagType Flags) +AddTextToElement(TextTypePtr Text, FontTypePtr PCBFont, + Coord X, Coord Y, unsigned Direction, char *TextString, int Scale, FlagType Flags) { - free (Text->TextString); - Text->TextString = (TextString && *TextString) ? strdup (TextString) : NULL; - Text->X = X; - Text->Y = Y; - Text->Direction = Direction; - Text->Flags = Flags; - Text->Scale = Scale; + free(Text->TextString); + Text->TextString = (TextString && *TextString) ? strdup(TextString) : NULL; + Text->X = X; + Text->Y = Y; + Text->Direction = Direction; + Text->Flags = Flags; + Text->Scale = Scale; - /* calculate size of the bounding box */ - SetTextBoundingBox (PCBFont, Text); - Text->ID = ID++; + /* calculate size of the bounding box */ + SetTextBoundingBox(PCBFont, Text); + Text->ID = ID++; } /* --------------------------------------------------------------------------- * creates a new line in a symbol */ -LineTypePtr -CreateNewLineInSymbol (SymbolTypePtr Symbol, - Coord X1, Coord Y1, - Coord X2, Coord Y2, Coord Thickness) +LineTypePtr CreateNewLineInSymbol(SymbolTypePtr Symbol, Coord X1, Coord Y1, Coord X2, Coord Y2, Coord Thickness) { - LineTypePtr line = Symbol->Line; + LineTypePtr line = Symbol->Line; - /* realloc new memory if necessary and clear it */ - if (Symbol->LineN >= Symbol->LineMax) - { - Symbol->LineMax += STEP_SYMBOLLINE; - line = (LineTypePtr)realloc (line, Symbol->LineMax * sizeof (LineType)); - Symbol->Line = line; - memset (line + Symbol->LineN, 0, STEP_SYMBOLLINE * sizeof (LineType)); - } + /* realloc new memory if necessary and clear it */ + if (Symbol->LineN >= Symbol->LineMax) { + Symbol->LineMax += STEP_SYMBOLLINE; + line = (LineTypePtr) realloc(line, Symbol->LineMax * sizeof(LineType)); + Symbol->Line = line; + memset(line + Symbol->LineN, 0, STEP_SYMBOLLINE * sizeof(LineType)); + } - /* copy values */ - line = line + Symbol->LineN++; - line->Point1.X = X1; - line->Point1.Y = Y1; - line->Point2.X = X2; - line->Point2.Y = Y2; - line->Thickness = Thickness; - return (line); + /* copy values */ + line = line + Symbol->LineN++; + line->Point1.X = X1; + line->Point1.Y = Y1; + line->Point2.X = X2; + line->Point2.Y = Y2; + line->Thickness = Thickness; + return (line); } /* --------------------------------------------------------------------------- @@ -955,11 +862,10 @@ * checks directories given as colon separated list by resource fontPath * if the fonts filename doesn't contain a directory component */ -void -CreateDefaultFont (PCBTypePtr pcb) +void CreateDefaultFont(PCBTypePtr pcb) { - if (ParseFont (&pcb->Font, Settings.FontFile)) - Message (_("Can't find font-symbol-file '%s'\n"), Settings.FontFile); + if (ParseFont(&pcb->Font, Settings.FontFile)) + Message(_("Can't find font-symbol-file '%s'\n"), Settings.FontFile); } /* --------------------------------------------------------------------------- @@ -966,66 +872,60 @@ * adds a new line to the rubberband list of 'Crosshair.AttachedObject' * if Layer == 0 it is a rat line */ -RubberbandTypePtr -CreateNewRubberbandEntry (LayerTypePtr Layer, - LineTypePtr Line, PointTypePtr MovedPoint) +RubberbandTypePtr CreateNewRubberbandEntry(LayerTypePtr Layer, LineTypePtr Line, PointTypePtr MovedPoint) { - RubberbandTypePtr ptr = GetRubberbandMemory (); + RubberbandTypePtr ptr = GetRubberbandMemory(); - /* we toggle the RUBBERENDFLAG of the line to determine if */ - /* both points are being moved. */ - TOGGLE_FLAG (RUBBERENDFLAG, Line); - ptr->Layer = Layer; - ptr->Line = Line; - ptr->MovedPoint = MovedPoint; - return (ptr); + /* we toggle the RUBBERENDFLAG of the line to determine if */ + /* both points are being moved. */ + TOGGLE_FLAG(RUBBERENDFLAG, Line); + ptr->Layer = Layer; + ptr->Line = Line; + ptr->MovedPoint = MovedPoint; + return (ptr); } /* --------------------------------------------------------------------------- * Add a new net to the netlist menu */ -LibraryMenuTypePtr -CreateNewNet (LibraryTypePtr lib, char *name, char *style) +LibraryMenuTypePtr CreateNewNet(LibraryTypePtr lib, char *name, char *style) { - LibraryMenuTypePtr menu; - char temp[64]; + LibraryMenuTypePtr menu; + char temp[64]; - sprintf (temp, " %s", name); - menu = GetLibraryMenuMemory (lib, NULL); - menu->Name = strdup (temp); - menu->flag = 1; /* net is enabled by default */ - if (style == NULL || NSTRCMP ("(unknown)", style) == 0) - menu->Style = NULL; - else - menu->Style = strdup (style); - return (menu); + sprintf(temp, " %s", name); + menu = GetLibraryMenuMemory(lib, NULL); + menu->Name = strdup(temp); + menu->flag = 1; /* net is enabled by default */ + if (style == NULL || NSTRCMP("(unknown)", style) == 0) + menu->Style = NULL; + else + menu->Style = strdup(style); + return (menu); } /* --------------------------------------------------------------------------- * Add a connection to the net */ -LibraryEntryTypePtr -CreateNewConnection (LibraryMenuTypePtr net, char *conn) +LibraryEntryTypePtr CreateNewConnection(LibraryMenuTypePtr net, char *conn) { - LibraryEntryTypePtr entry = GetLibraryEntryMemory (net); + LibraryEntryTypePtr entry = GetLibraryEntryMemory(net); - entry->ListEntry = STRDUP (conn); - return (entry); + entry->ListEntry = STRDUP(conn); + return (entry); } /* --------------------------------------------------------------------------- * Add an attribute to a list. */ -AttributeTypePtr -CreateNewAttribute (AttributeListTypePtr list, char *name, char *value) +AttributeTypePtr CreateNewAttribute(AttributeListTypePtr list, char *name, char *value) { - if (list->Number >= list->Max) - { - list->Max += 10; - list->List = (AttributeType *)realloc (list->List, list->Max * sizeof (AttributeType)); - } - list->List[list->Number].name = STRDUP (name); - list->List[list->Number].value = STRDUP (value); - list->Number++; - return &list->List[list->Number - 1]; + if (list->Number >= list->Max) { + list->Max += 10; + list->List = (AttributeType *) realloc(list->List, list->Max * sizeof(AttributeType)); + } + list->List[list->Number].name = STRDUP(name); + list->List[list->Number].value = STRDUP(value); + list->Number++; + return &list->List[list->Number - 1]; } Index: trunk/src/create.h =================================================================== --- trunk/src/create.h (revision 1021) +++ trunk/src/create.h (revision 1022) @@ -36,56 +36,37 @@ /* TRUE during file loads, for example to allow overlapping vias. FALSE otherwise, to stop the user from doing normally dangerous things. */ -void CreateBeLenient (bool); +void CreateBeLenient(bool); -DataTypePtr CreateNewBuffer (void); -void pcb_colors_from_settings (PCBTypePtr); -PCBTypePtr CreateNewPCB_ (bool); -PCBTypePtr CreateNewPCB (); +DataTypePtr CreateNewBuffer(void); +void pcb_colors_from_settings(PCBTypePtr); +PCBTypePtr CreateNewPCB_(bool); +PCBTypePtr CreateNewPCB(); /* Called after PCB->Data->LayerN is set. Returns zero if no errors, else nonzero. */ -int CreateNewPCBPost (PCBTypePtr, int /* set defaults */); -PinTypePtr CreateNewVia (DataTypePtr, Coord, Coord, Coord, Coord, - Coord, Coord, const char *, FlagType); -LineTypePtr CreateDrawnLineOnLayer (LayerTypePtr, Coord, Coord, Coord, - Coord, Coord, Coord, FlagType); -LineTypePtr CreateNewLineOnLayer (LayerTypePtr, Coord, Coord, Coord, - Coord, Coord, Coord, FlagType); -RatTypePtr CreateNewRat (DataTypePtr, Coord, Coord, Coord, - Coord, Cardinal, Cardinal, Coord, FlagType); -ArcTypePtr CreateNewArcOnLayer (LayerTypePtr, Coord, Coord, Coord, Coord, - Angle, Angle, Coord, Coord, FlagType); -PolygonTypePtr CreateNewPolygonFromRectangle (LayerTypePtr, Coord, - Coord, Coord, - Coord, FlagType); -TextTypePtr CreateNewText (LayerTypePtr, FontTypePtr, Coord, - Coord, unsigned, int, char *, FlagType); -PolygonTypePtr CreateNewPolygon (LayerTypePtr, FlagType); -PointTypePtr CreateNewPointInPolygon (PolygonTypePtr, - Coord, Coord); -PolygonType *CreateNewHoleInPolygon (PolygonType *polygon); -ElementTypePtr CreateNewElement (DataTypePtr, ElementTypePtr, - FontTypePtr, FlagType, char *, char *, - char *, Coord, Coord, BYTE, - int, FlagType, bool); -LineTypePtr CreateNewLineInElement (ElementTypePtr, Coord, Coord, - Coord, Coord, Coord); -ArcTypePtr CreateNewArcInElement (ElementTypePtr, Coord, Coord, - Coord, Coord, Angle, Angle, Coord); -PinTypePtr CreateNewPin (ElementTypePtr, Coord, Coord, - Coord, Coord, Coord, Coord, - char *, char *, FlagType); -PadTypePtr CreateNewPad (ElementTypePtr, Coord, Coord, - Coord, Coord, Coord, Coord, - Coord, char *, char *, FlagType); -LineTypePtr CreateNewLineInSymbol (SymbolTypePtr, Coord, Coord, - Coord, Coord, Coord); -void CreateDefaultFont (PCBTypePtr); -RubberbandTypePtr CreateNewRubberbandEntry (LayerTypePtr, - LineTypePtr, PointTypePtr); -LibraryMenuTypePtr CreateNewNet (LibraryTypePtr, char *, char *); -LibraryEntryTypePtr CreateNewConnection (LibraryMenuTypePtr, char *); +int CreateNewPCBPost(PCBTypePtr, int /* set defaults */ ); +PinTypePtr CreateNewVia(DataTypePtr, Coord, Coord, Coord, Coord, Coord, Coord, const char *, FlagType); +LineTypePtr CreateDrawnLineOnLayer(LayerTypePtr, Coord, Coord, Coord, Coord, Coord, Coord, FlagType); +LineTypePtr CreateNewLineOnLayer(LayerTypePtr, Coord, Coord, Coord, Coord, Coord, Coord, FlagType); +RatTypePtr CreateNewRat(DataTypePtr, Coord, Coord, Coord, Coord, Cardinal, Cardinal, Coord, FlagType); +ArcTypePtr CreateNewArcOnLayer(LayerTypePtr, Coord, Coord, Coord, Coord, Angle, Angle, Coord, Coord, FlagType); +PolygonTypePtr CreateNewPolygonFromRectangle(LayerTypePtr, Coord, Coord, Coord, Coord, FlagType); +TextTypePtr CreateNewText(LayerTypePtr, FontTypePtr, Coord, Coord, unsigned, int, char *, FlagType); +PolygonTypePtr CreateNewPolygon(LayerTypePtr, FlagType); +PointTypePtr CreateNewPointInPolygon(PolygonTypePtr, Coord, Coord); +PolygonType *CreateNewHoleInPolygon(PolygonType * polygon); +ElementTypePtr CreateNewElement(DataTypePtr, ElementTypePtr, + FontTypePtr, FlagType, char *, char *, char *, Coord, Coord, BYTE, int, FlagType, bool); +LineTypePtr CreateNewLineInElement(ElementTypePtr, Coord, Coord, Coord, Coord, Coord); +ArcTypePtr CreateNewArcInElement(ElementTypePtr, Coord, Coord, Coord, Coord, Angle, Angle, Coord); +PinTypePtr CreateNewPin(ElementTypePtr, Coord, Coord, Coord, Coord, Coord, Coord, char *, char *, FlagType); +PadTypePtr CreateNewPad(ElementTypePtr, Coord, Coord, Coord, Coord, Coord, Coord, Coord, char *, char *, FlagType); +LineTypePtr CreateNewLineInSymbol(SymbolTypePtr, Coord, Coord, Coord, Coord, Coord); +void CreateDefaultFont(PCBTypePtr); +RubberbandTypePtr CreateNewRubberbandEntry(LayerTypePtr, LineTypePtr, PointTypePtr); +LibraryMenuTypePtr CreateNewNet(LibraryTypePtr, char *, char *); +LibraryEntryTypePtr CreateNewConnection(LibraryMenuTypePtr, char *); -AttributeTypePtr CreateNewAttribute (AttributeListTypePtr list, char *name, char *value); +AttributeTypePtr CreateNewAttribute(AttributeListTypePtr list, char *name, char *value); #endif Index: trunk/src/crosshair.c =================================================================== --- trunk/src/crosshair.c (revision 1021) +++ trunk/src/crosshair.c (revision 1022) @@ -55,615 +55,511 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); -typedef struct -{ - int x, y; +typedef struct { + int x, y; } point; /* --------------------------------------------------------------------------- * some local prototypes */ -static void XORPolygon (PolygonTypePtr, Coord, Coord); -static void XORDrawElement (ElementTypePtr, Coord, Coord); -static void XORDrawBuffer (BufferTypePtr); -static void XORDrawInsertPointObject (void); -static void XORDrawMoveOrCopyObject (void); -static void XORDrawAttachedLine (Coord, Coord, Coord, Coord, Coord); -static void XORDrawAttachedArc (Coord); +static void XORPolygon(PolygonTypePtr, Coord, Coord); +static void XORDrawElement(ElementTypePtr, Coord, Coord); +static void XORDrawBuffer(BufferTypePtr); +static void XORDrawInsertPointObject(void); +static void XORDrawMoveOrCopyObject(void); +static void XORDrawAttachedLine(Coord, Coord, Coord, Coord, Coord); +static void XORDrawAttachedArc(Coord); -static void -thindraw_moved_pv (PinType *pv, Coord x, Coord y) +static void thindraw_moved_pv(PinType * pv, Coord x, Coord y) { - /* Make a copy of the pin structure, moved to the correct position */ - PinType moved_pv = *pv; - moved_pv.X += x; - moved_pv.Y += y; + /* Make a copy of the pin structure, moved to the correct position */ + PinType moved_pv = *pv; + moved_pv.X += x; + moved_pv.Y += y; - gui->thindraw_pcb_pv (Crosshair.GC, Crosshair.GC, &moved_pv, true, false); + gui->thindraw_pcb_pv(Crosshair.GC, Crosshair.GC, &moved_pv, true, false); } /* --------------------------------------------------------------------------- * creates a tmp polygon with coordinates converted to screen system */ -static void -XORPolygon (PolygonTypePtr polygon, Coord dx, Coord dy) +static void XORPolygon(PolygonTypePtr polygon, Coord dx, Coord dy) { - Cardinal i; - for (i = 0; i < polygon->PointN; i++) - { - Cardinal next = next_contour_point (polygon, i); - gui->draw_line (Crosshair.GC, - polygon->Points[i].X + dx, - polygon->Points[i].Y + dy, - polygon->Points[next].X + dx, - polygon->Points[next].Y + dy); - } + Cardinal i; + for (i = 0; i < polygon->PointN; i++) { + Cardinal next = next_contour_point(polygon, i); + gui->draw_line(Crosshair.GC, + polygon->Points[i].X + dx, + polygon->Points[i].Y + dy, polygon->Points[next].X + dx, polygon->Points[next].Y + dy); + } } /*----------------------------------------------------------- * Draws the outline of an arc */ -static void -XORDrawAttachedArc (Coord thick) +static void XORDrawAttachedArc(Coord thick) { - ArcType arc; - BoxTypePtr bx; - Coord wx, wy; - Angle sa, dir; - Coord wid = thick / 2; + ArcType arc; + BoxTypePtr bx; + Coord wx, wy; + Angle sa, dir; + Coord wid = thick / 2; - wx = Crosshair.X - Crosshair.AttachedBox.Point1.X; - wy = Crosshair.Y - Crosshair.AttachedBox.Point1.Y; - if (wx == 0 && wy == 0) - return; - arc.X = Crosshair.AttachedBox.Point1.X; - arc.Y = Crosshair.AttachedBox.Point1.Y; - if (XOR (Crosshair.AttachedBox.otherway, abs (wy) > abs (wx))) - { - arc.X = Crosshair.AttachedBox.Point1.X + abs (wy) * SGNZ (wx); - sa = (wx >= 0) ? 0 : 180; + wx = Crosshair.X - Crosshair.AttachedBox.Point1.X; + wy = Crosshair.Y - Crosshair.AttachedBox.Point1.Y; + if (wx == 0 && wy == 0) + return; + arc.X = Crosshair.AttachedBox.Point1.X; + arc.Y = Crosshair.AttachedBox.Point1.Y; + if (XOR(Crosshair.AttachedBox.otherway, abs(wy) > abs(wx))) { + arc.X = Crosshair.AttachedBox.Point1.X + abs(wy) * SGNZ(wx); + sa = (wx >= 0) ? 0 : 180; #ifdef ARC45 - if (abs (wy) >= 2 * abs (wx)) - dir = (SGNZ (wx) == SGNZ (wy)) ? 45 : -45; - else + if (abs(wy) >= 2 * abs(wx)) + dir = (SGNZ(wx) == SGNZ(wy)) ? 45 : -45; + else #endif - dir = (SGNZ (wx) == SGNZ (wy)) ? 90 : -90; - } - else - { - arc.Y = Crosshair.AttachedBox.Point1.Y + abs (wx) * SGNZ (wy); - sa = (wy >= 0) ? -90 : 90; + dir = (SGNZ(wx) == SGNZ(wy)) ? 90 : -90; + } + else { + arc.Y = Crosshair.AttachedBox.Point1.Y + abs(wx) * SGNZ(wy); + sa = (wy >= 0) ? -90 : 90; #ifdef ARC45 - if (abs (wx) >= 2 * abs (wy)) - dir = (SGNZ (wx) == SGNZ (wy)) ? -45 : 45; - else + if (abs(wx) >= 2 * abs(wy)) + dir = (SGNZ(wx) == SGNZ(wy)) ? -45 : 45; + else #endif - dir = (SGNZ (wx) == SGNZ (wy)) ? -90 : 90; - wy = wx; - } - wy = abs (wy); - arc.StartAngle = sa; - arc.Delta = dir; - arc.Width = arc.Height = wy; - bx = GetArcEnds (&arc); - /* sa = sa - 180; */ - gui->draw_arc (Crosshair.GC, arc.X, arc.Y, wy + wid, wy + wid, sa, dir); - if (wid > pixel_slop) - { - gui->draw_arc (Crosshair.GC, arc.X, arc.Y, wy - wid, wy - wid, sa, dir); - gui->draw_arc (Crosshair.GC, bx->X1, bx->Y1, - wid, wid, sa, -180 * SGN (dir)); - gui->draw_arc (Crosshair.GC, bx->X2, bx->Y2, - wid, wid, sa + dir, 180 * SGN (dir)); - } + dir = (SGNZ(wx) == SGNZ(wy)) ? -90 : 90; + wy = wx; + } + wy = abs(wy); + arc.StartAngle = sa; + arc.Delta = dir; + arc.Width = arc.Height = wy; + bx = GetArcEnds(&arc); + /* sa = sa - 180; */ + gui->draw_arc(Crosshair.GC, arc.X, arc.Y, wy + wid, wy + wid, sa, dir); + if (wid > pixel_slop) { + gui->draw_arc(Crosshair.GC, arc.X, arc.Y, wy - wid, wy - wid, sa, dir); + gui->draw_arc(Crosshair.GC, bx->X1, bx->Y1, wid, wid, sa, -180 * SGN(dir)); + gui->draw_arc(Crosshair.GC, bx->X2, bx->Y2, wid, wid, sa + dir, 180 * SGN(dir)); + } } /*----------------------------------------------------------- * Draws the outline of a line */ -static void -XORDrawAttachedLine (Coord x1, Coord y1, Coord x2, Coord y2, Coord thick) +static void XORDrawAttachedLine(Coord x1, Coord y1, Coord x2, Coord y2, Coord thick) { - Coord dx, dy, ox, oy; - double h; + Coord dx, dy, ox, oy; + double h; - dx = x2 - x1; - dy = y2 - y1; - if (dx != 0 || dy != 0) - h = 0.5 * thick / sqrt (SQUARE (dx) + SQUARE (dy)); - else - h = 0.0; - ox = dy * h + 0.5 * SGN (dy); - oy = -(dx * h + 0.5 * SGN (dx)); - gui->draw_line (Crosshair.GC, x1 + ox, y1 + oy, x2 + ox, y2 + oy); - if (abs (ox) >= pixel_slop || abs (oy) >= pixel_slop) - { - Angle angle = atan2 (dx, dy) * 57.295779; - gui->draw_line (Crosshair.GC, x1 - ox, y1 - oy, x2 - ox, y2 - oy); - gui->draw_arc (Crosshair.GC, - x1, y1, thick / 2, thick / 2, angle - 180, 180); - gui->draw_arc (Crosshair.GC, x2, y2, thick / 2, thick / 2, angle, 180); - } + dx = x2 - x1; + dy = y2 - y1; + if (dx != 0 || dy != 0) + h = 0.5 * thick / sqrt(SQUARE(dx) + SQUARE(dy)); + else + h = 0.0; + ox = dy * h + 0.5 * SGN(dy); + oy = -(dx * h + 0.5 * SGN(dx)); + gui->draw_line(Crosshair.GC, x1 + ox, y1 + oy, x2 + ox, y2 + oy); + if (abs(ox) >= pixel_slop || abs(oy) >= pixel_slop) { + Angle angle = atan2(dx, dy) * 57.295779; + gui->draw_line(Crosshair.GC, x1 - ox, y1 - oy, x2 - ox, y2 - oy); + gui->draw_arc(Crosshair.GC, x1, y1, thick / 2, thick / 2, angle - 180, 180); + gui->draw_arc(Crosshair.GC, x2, y2, thick / 2, thick / 2, angle, 180); + } } /* --------------------------------------------------------------------------- * draws the elements of a loaded circuit which is to be merged in */ -static void -XORDrawElement (ElementTypePtr Element, Coord DX, Coord DY) +static void XORDrawElement(ElementTypePtr Element, Coord DX, Coord DY) { - /* if no silkscreen, draw the bounding box */ - if (Element->ArcN == 0 && Element->LineN == 0) - { - gui->draw_line (Crosshair.GC, - DX + Element->BoundingBox.X1, - DY + Element->BoundingBox.Y1, - DX + Element->BoundingBox.X1, - DY + Element->BoundingBox.Y2); - gui->draw_line (Crosshair.GC, - DX + Element->BoundingBox.X1, - DY + Element->BoundingBox.Y2, - DX + Element->BoundingBox.X2, - DY + Element->BoundingBox.Y2); - gui->draw_line (Crosshair.GC, - DX + Element->BoundingBox.X2, - DY + Element->BoundingBox.Y2, - DX + Element->BoundingBox.X2, - DY + Element->BoundingBox.Y1); - gui->draw_line (Crosshair.GC, - DX + Element->BoundingBox.X2, - DY + Element->BoundingBox.Y1, - DX + Element->BoundingBox.X1, - DY + Element->BoundingBox.Y1); - } - else - { - ELEMENTLINE_LOOP (Element); - { - gui->draw_line (Crosshair.GC, - DX + line->Point1.X, - DY + line->Point1.Y, - DX + line->Point2.X, DY + line->Point2.Y); - } - END_LOOP; + /* if no silkscreen, draw the bounding box */ + if (Element->ArcN == 0 && Element->LineN == 0) { + gui->draw_line(Crosshair.GC, + DX + Element->BoundingBox.X1, + DY + Element->BoundingBox.Y1, DX + Element->BoundingBox.X1, DY + Element->BoundingBox.Y2); + gui->draw_line(Crosshair.GC, + DX + Element->BoundingBox.X1, + DY + Element->BoundingBox.Y2, DX + Element->BoundingBox.X2, DY + Element->BoundingBox.Y2); + gui->draw_line(Crosshair.GC, + DX + Element->BoundingBox.X2, + DY + Element->BoundingBox.Y2, DX + Element->BoundingBox.X2, DY + Element->BoundingBox.Y1); + gui->draw_line(Crosshair.GC, + DX + Element->BoundingBox.X2, + DY + Element->BoundingBox.Y1, DX + Element->BoundingBox.X1, DY + Element->BoundingBox.Y1); + } + else { + ELEMENTLINE_LOOP(Element); + { + gui->draw_line(Crosshair.GC, DX + line->Point1.X, DY + line->Point1.Y, DX + line->Point2.X, DY + line->Point2.Y); + } + END_LOOP; - /* arc coordinates and angles have to be converted to X11 notation */ - ARC_LOOP (Element); - { - gui->draw_arc (Crosshair.GC, - DX + arc->X, - DY + arc->Y, - arc->Width, arc->Height, arc->StartAngle, arc->Delta); - } - END_LOOP; - } - /* pin coordinates and angles have to be converted to X11 notation */ - PIN_LOOP (Element); - { - thindraw_moved_pv (pin, DX, DY); - } - END_LOOP; + /* arc coordinates and angles have to be converted to X11 notation */ + ARC_LOOP(Element); + { + gui->draw_arc(Crosshair.GC, DX + arc->X, DY + arc->Y, arc->Width, arc->Height, arc->StartAngle, arc->Delta); + } + END_LOOP; + } + /* pin coordinates and angles have to be converted to X11 notation */ + PIN_LOOP(Element); + { + thindraw_moved_pv(pin, DX, DY); + } + END_LOOP; - /* pads */ - PAD_LOOP (Element); - { - if (PCB->InvisibleObjectsOn || - (TEST_FLAG (ONSOLDERFLAG, pad) != 0) == Settings.ShowSolderSide) - { - /* Make a copy of the pad structure, moved to the correct position */ - PadType moved_pad = *pad; - moved_pad.Point1.X += DX; moved_pad.Point1.Y += DY; - moved_pad.Point2.X += DX; moved_pad.Point2.Y += DY; + /* pads */ + PAD_LOOP(Element); + { + if (PCB->InvisibleObjectsOn || (TEST_FLAG(ONSOLDERFLAG, pad) != 0) == Settings.ShowSolderSide) { + /* Make a copy of the pad structure, moved to the correct position */ + PadType moved_pad = *pad; + moved_pad.Point1.X += DX; + moved_pad.Point1.Y += DY; + moved_pad.Point2.X += DX; + moved_pad.Point2.Y += DY; - gui->thindraw_pcb_pad (Crosshair.GC, &moved_pad, false, false); - } - } - END_LOOP; - /* mark */ - gui->draw_line (Crosshair.GC, - Element->MarkX + DX - EMARK_SIZE, - Element->MarkY + DY, - Element->MarkX + DX, Element->MarkY + DY - EMARK_SIZE); - gui->draw_line (Crosshair.GC, - Element->MarkX + DX + EMARK_SIZE, - Element->MarkY + DY, - Element->MarkX + DX, Element->MarkY + DY - EMARK_SIZE); - gui->draw_line (Crosshair.GC, - Element->MarkX + DX - EMARK_SIZE, - Element->MarkY + DY, - Element->MarkX + DX, Element->MarkY + DY + EMARK_SIZE); - gui->draw_line (Crosshair.GC, - Element->MarkX + DX + EMARK_SIZE, - Element->MarkY + DY, - Element->MarkX + DX, Element->MarkY + DY + EMARK_SIZE); + gui->thindraw_pcb_pad(Crosshair.GC, &moved_pad, false, false); + } + } + END_LOOP; + /* mark */ + gui->draw_line(Crosshair.GC, + Element->MarkX + DX - EMARK_SIZE, Element->MarkY + DY, Element->MarkX + DX, Element->MarkY + DY - EMARK_SIZE); + gui->draw_line(Crosshair.GC, + Element->MarkX + DX + EMARK_SIZE, Element->MarkY + DY, Element->MarkX + DX, Element->MarkY + DY - EMARK_SIZE); + gui->draw_line(Crosshair.GC, + Element->MarkX + DX - EMARK_SIZE, Element->MarkY + DY, Element->MarkX + DX, Element->MarkY + DY + EMARK_SIZE); + gui->draw_line(Crosshair.GC, + Element->MarkX + DX + EMARK_SIZE, Element->MarkY + DY, Element->MarkX + DX, Element->MarkY + DY + EMARK_SIZE); } /* --------------------------------------------------------------------------- * draws all visible and attached objects of the pastebuffer */ -static void -XORDrawBuffer (BufferTypePtr Buffer) +static void XORDrawBuffer(BufferTypePtr Buffer) { - Cardinal i; - Coord x, y; + Cardinal i; + Coord x, y; - /* set offset */ - x = Crosshair.X - Buffer->X; - y = Crosshair.Y - Buffer->Y; + /* set offset */ + x = Crosshair.X - Buffer->X; + y = Crosshair.Y - Buffer->Y; - /* draw all visible layers */ - for (i = 0; i < max_copper_layer + 2; i++) - if (PCB->Data->Layer[i].On) - { - LayerTypePtr layer = &Buffer->Data->Layer[i]; + /* draw all visible layers */ + for (i = 0; i < max_copper_layer + 2; i++) + if (PCB->Data->Layer[i].On) { + LayerTypePtr layer = &Buffer->Data->Layer[i]; - LINE_LOOP (layer); - { + LINE_LOOP(layer); + { /* XORDrawAttachedLine(x +line->Point1.X, y +line->Point1.Y, x +line->Point2.X, y +line->Point2.Y, line->Thickness); */ - gui->draw_line (Crosshair.GC, - x + line->Point1.X, y + line->Point1.Y, - x + line->Point2.X, y + line->Point2.Y); - } - END_LOOP; - ARC_LOOP (layer); + gui->draw_line(Crosshair.GC, x + line->Point1.X, y + line->Point1.Y, x + line->Point2.X, y + line->Point2.Y); + } + END_LOOP; + ARC_LOOP(layer); + { + gui->draw_arc(Crosshair.GC, x + arc->X, y + arc->Y, arc->Width, arc->Height, arc->StartAngle, arc->Delta); + } + END_LOOP; + TEXT_LOOP(layer); + { + BoxTypePtr box = &text->BoundingBox; + gui->draw_rect(Crosshair.GC, x + box->X1, y + box->Y1, x + box->X2, y + box->Y2); + } + END_LOOP; + /* the tmp polygon has n+1 points because the first + * and the last one are set to the same coordinates + */ + POLYGON_LOOP(layer); + { + XORPolygon(polygon, x, y); + } + END_LOOP; + } + + /* draw elements if visible */ + if (PCB->PinOn && PCB->ElementOn) + ELEMENT_LOOP(Buffer->Data); { - gui->draw_arc (Crosshair.GC, - x + arc->X, - y + arc->Y, - arc->Width, - arc->Height, arc->StartAngle, arc->Delta); + if (FRONT(element) || PCB->InvisibleObjectsOn) + XORDrawElement(element, x, y); } END_LOOP; - TEXT_LOOP (layer); + + /* and the vias */ + if (PCB->ViaOn) + VIA_LOOP(Buffer->Data); { - BoxTypePtr box = &text->BoundingBox; - gui->draw_rect (Crosshair.GC, - x + box->X1, y + box->Y1, x + box->X2, y + box->Y2); + thindraw_moved_pv(via, x, y); } END_LOOP; - /* the tmp polygon has n+1 points because the first - * and the last one are set to the same coordinates - */ - POLYGON_LOOP (layer); - { - XORPolygon (polygon, x, y); - } - END_LOOP; - } - - /* draw elements if visible */ - if (PCB->PinOn && PCB->ElementOn) - ELEMENT_LOOP (Buffer->Data); - { - if (FRONT (element) || PCB->InvisibleObjectsOn) - XORDrawElement (element, x, y); - } - END_LOOP; - - /* and the vias */ - if (PCB->ViaOn) - VIA_LOOP (Buffer->Data); - { - thindraw_moved_pv (via, x, y); - } - END_LOOP; } /* --------------------------------------------------------------------------- * draws the rubberband to insert points into polygons/lines/... */ -static void -XORDrawInsertPointObject (void) +static void XORDrawInsertPointObject(void) { - LineTypePtr line = (LineTypePtr) Crosshair.AttachedObject.Ptr2; - PointTypePtr point = (PointTypePtr) Crosshair.AttachedObject.Ptr3; + LineTypePtr line = (LineTypePtr) Crosshair.AttachedObject.Ptr2; + PointTypePtr point = (PointTypePtr) Crosshair.AttachedObject.Ptr3; - if (Crosshair.AttachedObject.Type != NO_TYPE) - { - gui->draw_line (Crosshair.GC, - point->X, point->Y, line->Point1.X, line->Point1.Y); - gui->draw_line (Crosshair.GC, - point->X, point->Y, line->Point2.X, line->Point2.Y); - } + if (Crosshair.AttachedObject.Type != NO_TYPE) { + gui->draw_line(Crosshair.GC, point->X, point->Y, line->Point1.X, line->Point1.Y); + gui->draw_line(Crosshair.GC, point->X, point->Y, line->Point2.X, line->Point2.Y); + } } /* --------------------------------------------------------------------------- * draws the attached object while in MOVE_MODE or COPY_MODE */ -static void -XORDrawMoveOrCopyObject (void) +static void XORDrawMoveOrCopyObject(void) { - RubberbandTypePtr ptr; - Cardinal i; - Coord dx = Crosshair.X - Crosshair.AttachedObject.X, - dy = Crosshair.Y - Crosshair.AttachedObject.Y; + RubberbandTypePtr ptr; + Cardinal i; + Coord dx = Crosshair.X - Crosshair.AttachedObject.X, dy = Crosshair.Y - Crosshair.AttachedObject.Y; - switch (Crosshair.AttachedObject.Type) - { - case VIA_TYPE: - { - PinTypePtr via = (PinTypePtr) Crosshair.AttachedObject.Ptr1; - thindraw_moved_pv (via, dx, dy); - break; - } + switch (Crosshair.AttachedObject.Type) { + case VIA_TYPE: + { + PinTypePtr via = (PinTypePtr) Crosshair.AttachedObject.Ptr1; + thindraw_moved_pv(via, dx, dy); + break; + } - case LINE_TYPE: - { - LineTypePtr line = (LineTypePtr) Crosshair.AttachedObject.Ptr2; + case LINE_TYPE: + { + LineTypePtr line = (LineTypePtr) Crosshair.AttachedObject.Ptr2; - XORDrawAttachedLine (line->Point1.X + dx, line->Point1.Y + dy, - line->Point2.X + dx, line->Point2.Y + dy, - line->Thickness); - break; - } + XORDrawAttachedLine(line->Point1.X + dx, line->Point1.Y + dy, line->Point2.X + dx, line->Point2.Y + dy, line->Thickness); + break; + } - case ARC_TYPE: - { - ArcTypePtr Arc = (ArcTypePtr) Crosshair.AttachedObject.Ptr2; + case ARC_TYPE: + { + ArcTypePtr Arc = (ArcTypePtr) Crosshair.AttachedObject.Ptr2; - gui->draw_arc (Crosshair.GC, - Arc->X + dx, - Arc->Y + dy, - Arc->Width, Arc->Height, Arc->StartAngle, Arc->Delta); - break; - } + gui->draw_arc(Crosshair.GC, Arc->X + dx, Arc->Y + dy, Arc->Width, Arc->Height, Arc->StartAngle, Arc->Delta); + break; + } - case POLYGON_TYPE: - { - PolygonTypePtr polygon = - (PolygonTypePtr) Crosshair.AttachedObject.Ptr2; + case POLYGON_TYPE: + { + PolygonTypePtr polygon = (PolygonTypePtr) Crosshair.AttachedObject.Ptr2; - /* the tmp polygon has n+1 points because the first - * and the last one are set to the same coordinates - */ - XORPolygon (polygon, dx, dy); - break; - } + /* the tmp polygon has n+1 points because the first + * and the last one are set to the same coordinates + */ + XORPolygon(polygon, dx, dy); + break; + } - case LINEPOINT_TYPE: - { - LineTypePtr line; - PointTypePtr point; + case LINEPOINT_TYPE: + { + LineTypePtr line; + PointTypePtr point; - line = (LineTypePtr) Crosshair.AttachedObject.Ptr2; - point = (PointTypePtr) Crosshair.AttachedObject.Ptr3; - if (point == &line->Point1) - XORDrawAttachedLine (point->X + dx, - point->Y + dy, line->Point2.X, - line->Point2.Y, line->Thickness); - else - XORDrawAttachedLine (point->X + dx, - point->Y + dy, line->Point1.X, - line->Point1.Y, line->Thickness); - break; - } + line = (LineTypePtr) Crosshair.AttachedObject.Ptr2; + point = (PointTypePtr) Crosshair.AttachedObject.Ptr3; + if (point == &line->Point1) + XORDrawAttachedLine(point->X + dx, point->Y + dy, line->Point2.X, line->Point2.Y, line->Thickness); + else + XORDrawAttachedLine(point->X + dx, point->Y + dy, line->Point1.X, line->Point1.Y, line->Thickness); + break; + } - case POLYGONPOINT_TYPE: - { - PolygonTypePtr polygon; - PointTypePtr point; - Cardinal point_idx, prev, next; + case POLYGONPOINT_TYPE: + { + PolygonTypePtr polygon; + PointTypePtr point; + Cardinal point_idx, prev, next; - polygon = (PolygonTypePtr) Crosshair.AttachedObject.Ptr2; - point = (PointTypePtr) Crosshair.AttachedObject.Ptr3; - point_idx = polygon_point_idx (polygon, point); + polygon = (PolygonTypePtr) Crosshair.AttachedObject.Ptr2; + point = (PointTypePtr) Crosshair.AttachedObject.Ptr3; + point_idx = polygon_point_idx(polygon, point); - /* get previous and following point */ - prev = prev_contour_point (polygon, point_idx); - next = next_contour_point (polygon, point_idx); + /* get previous and following point */ + prev = prev_contour_point(polygon, point_idx); + next = next_contour_point(polygon, point_idx); - /* draw the two segments */ - gui->draw_line (Crosshair.GC, - polygon->Points[prev].X, polygon->Points[prev].Y, - point->X + dx, point->Y + dy); - gui->draw_line (Crosshair.GC, - point->X + dx, point->Y + dy, - polygon->Points[next].X, polygon->Points[next].Y); - break; - } + /* draw the two segments */ + gui->draw_line(Crosshair.GC, polygon->Points[prev].X, polygon->Points[prev].Y, point->X + dx, point->Y + dy); + gui->draw_line(Crosshair.GC, point->X + dx, point->Y + dy, polygon->Points[next].X, polygon->Points[next].Y); + break; + } - case ELEMENTNAME_TYPE: - { - /* locate the element "mark" and draw an association line from crosshair to it */ - ElementTypePtr element = - (ElementTypePtr) Crosshair.AttachedObject.Ptr1; + case ELEMENTNAME_TYPE: + { + /* locate the element "mark" and draw an association line from crosshair to it */ + ElementTypePtr element = (ElementTypePtr) Crosshair.AttachedObject.Ptr1; - gui->draw_line (Crosshair.GC, - element->MarkX, - element->MarkY, Crosshair.X, Crosshair.Y); - /* fall through to move the text as a box outline */ - } - case TEXT_TYPE: - { - TextTypePtr text = (TextTypePtr) Crosshair.AttachedObject.Ptr2; - BoxTypePtr box = &text->BoundingBox; - gui->draw_rect (Crosshair.GC, - box->X1 + dx, - box->Y1 + dy, box->X2 + dx, box->Y2 + dy); - break; - } + gui->draw_line(Crosshair.GC, element->MarkX, element->MarkY, Crosshair.X, Crosshair.Y); + /* fall through to move the text as a box outline */ + } + case TEXT_TYPE: + { + TextTypePtr text = (TextTypePtr) Crosshair.AttachedObject.Ptr2; + BoxTypePtr box = &text->BoundingBox; + gui->draw_rect(Crosshair.GC, box->X1 + dx, box->Y1 + dy, box->X2 + dx, box->Y2 + dy); + break; + } - /* pin/pad movements result in moving an element */ - case PAD_TYPE: - case PIN_TYPE: - case ELEMENT_TYPE: - XORDrawElement ((ElementTypePtr) Crosshair.AttachedObject.Ptr2, dx, dy); - break; - } + /* pin/pad movements result in moving an element */ + case PAD_TYPE: + case PIN_TYPE: + case ELEMENT_TYPE: + XORDrawElement((ElementTypePtr) Crosshair.AttachedObject.Ptr2, dx, dy); + break; + } - /* draw the attached rubberband lines too */ - i = Crosshair.AttachedObject.RubberbandN; - ptr = Crosshair.AttachedObject.Rubberband; - while (i) - { - PointTypePtr point1, point2; + /* draw the attached rubberband lines too */ + i = Crosshair.AttachedObject.RubberbandN; + ptr = Crosshair.AttachedObject.Rubberband; + while (i) { + PointTypePtr point1, point2; - if (TEST_FLAG (VIAFLAG, ptr->Line)) - { - /* this is a rat going to a polygon. do not draw for rubberband */; + if (TEST_FLAG(VIAFLAG, ptr->Line)) { + /* this is a rat going to a polygon. do not draw for rubberband */ ; + } + else if (TEST_FLAG(RUBBERENDFLAG, ptr->Line)) { + /* 'point1' is always the fix-point */ + if (ptr->MovedPoint == &ptr->Line->Point1) { + point1 = &ptr->Line->Point2; + point2 = &ptr->Line->Point1; + } + else { + point1 = &ptr->Line->Point1; + point2 = &ptr->Line->Point2; + } + XORDrawAttachedLine(point1->X, point1->Y, point2->X + dx, point2->Y + dy, ptr->Line->Thickness); + } + else if (ptr->MovedPoint == &ptr->Line->Point1) + XORDrawAttachedLine(ptr->Line->Point1.X + dx, + ptr->Line->Point1.Y + dy, ptr->Line->Point2.X + dx, ptr->Line->Point2.Y + dy, ptr->Line->Thickness); + + ptr++; + i--; } - else if (TEST_FLAG (RUBBERENDFLAG, ptr->Line)) - { - /* 'point1' is always the fix-point */ - if (ptr->MovedPoint == &ptr->Line->Point1) - { - point1 = &ptr->Line->Point2; - point2 = &ptr->Line->Point1; - } - else - { - point1 = &ptr->Line->Point1; - point2 = &ptr->Line->Point2; - } - XORDrawAttachedLine (point1->X, - point1->Y, point2->X + dx, - point2->Y + dy, ptr->Line->Thickness); - } - else if (ptr->MovedPoint == &ptr->Line->Point1) - XORDrawAttachedLine (ptr->Line->Point1.X + dx, - ptr->Line->Point1.Y + dy, - ptr->Line->Point2.X + dx, - ptr->Line->Point2.Y + dy, ptr->Line->Thickness); - - ptr++; - i--; - } } /* --------------------------------------------------------------------------- * draws additional stuff that follows the crosshair */ -void -DrawAttached (void) +void DrawAttached(void) { - switch (Settings.Mode) - { - case VIA_MODE: - { - /* Make a dummy via structure to draw from */ - PinType via; - via.X = Crosshair.X; - via.Y = Crosshair.Y; - via.Thickness = Settings.ViaThickness; - via.Clearance = 2 * Settings.Keepaway; - via.DrillingHole = Settings.ViaDrillingHole; - via.Mask = 0; - via.Flags = NoFlags (); + switch (Settings.Mode) { + case VIA_MODE: + { + /* Make a dummy via structure to draw from */ + PinType via; + via.X = Crosshair.X; + via.Y = Crosshair.Y; + via.Thickness = Settings.ViaThickness; + via.Clearance = 2 * Settings.Keepaway; + via.DrillingHole = Settings.ViaDrillingHole; + via.Mask = 0; + via.Flags = NoFlags(); - gui->thindraw_pcb_pv (Crosshair.GC, Crosshair.GC, &via, true, false); + gui->thindraw_pcb_pv(Crosshair.GC, Crosshair.GC, &via, true, false); - if (TEST_FLAG (SHOWDRCFLAG, PCB)) - { - /* XXX: Naughty cheat - use the mask to draw DRC clearance! */ - via.Mask = Settings.ViaThickness + PCB->Bloat * 2; - gui->set_color (Crosshair.GC, Settings.CrossColor); - gui->thindraw_pcb_pv (Crosshair.GC, Crosshair.GC, &via, false, true); - gui->set_color (Crosshair.GC, Settings.CrosshairColor); - } - break; - } + if (TEST_FLAG(SHOWDRCFLAG, PCB)) { + /* XXX: Naughty cheat - use the mask to draw DRC clearance! */ + via.Mask = Settings.ViaThickness + PCB->Bloat * 2; + gui->set_color(Crosshair.GC, Settings.CrossColor); + gui->thindraw_pcb_pv(Crosshair.GC, Crosshair.GC, &via, false, true); + gui->set_color(Crosshair.GC, Settings.CrosshairColor); + } + break; + } - /* the attached line is used by both LINEMODE, POLYGON_MODE and POLYGONHOLE_MODE*/ - case POLYGON_MODE: - case POLYGONHOLE_MODE: - /* draw only if starting point is set */ - if (Crosshair.AttachedLine.State != STATE_FIRST) - gui->draw_line (Crosshair.GC, - Crosshair.AttachedLine.Point1.X, - Crosshair.AttachedLine.Point1.Y, - Crosshair.AttachedLine.Point2.X, - Crosshair.AttachedLine.Point2.Y); + /* the attached line is used by both LINEMODE, POLYGON_MODE and POLYGONHOLE_MODE */ + case POLYGON_MODE: + case POLYGONHOLE_MODE: + /* draw only if starting point is set */ + if (Crosshair.AttachedLine.State != STATE_FIRST) + gui->draw_line(Crosshair.GC, + Crosshair.AttachedLine.Point1.X, + Crosshair.AttachedLine.Point1.Y, Crosshair.AttachedLine.Point2.X, Crosshair.AttachedLine.Point2.Y); - /* draw attached polygon only if in POLYGON_MODE or POLYGONHOLE_MODE */ - if (Crosshair.AttachedPolygon.PointN > 1) - { - XORPolygon (&Crosshair.AttachedPolygon, 0, 0); - } - break; + /* draw attached polygon only if in POLYGON_MODE or POLYGONHOLE_MODE */ + if (Crosshair.AttachedPolygon.PointN > 1) { + XORPolygon(&Crosshair.AttachedPolygon, 0, 0); + } + break; - case ARC_MODE: - if (Crosshair.AttachedBox.State != STATE_FIRST) - { - XORDrawAttachedArc (Settings.LineThickness); - if (TEST_FLAG (SHOWDRCFLAG, PCB)) - { - gui->set_color (Crosshair.GC, Settings.CrossColor); - XORDrawAttachedArc (Settings.LineThickness + - 2 * (PCB->Bloat + 1)); - gui->set_color (Crosshair.GC, Settings.CrosshairColor); - } + case ARC_MODE: + if (Crosshair.AttachedBox.State != STATE_FIRST) { + XORDrawAttachedArc(Settings.LineThickness); + if (TEST_FLAG(SHOWDRCFLAG, PCB)) { + gui->set_color(Crosshair.GC, Settings.CrossColor); + XORDrawAttachedArc(Settings.LineThickness + 2 * (PCB->Bloat + 1)); + gui->set_color(Crosshair.GC, Settings.CrosshairColor); + } - } - break; + } + break; - case LINE_MODE: - /* draw only if starting point exists and the line has length */ - if (Crosshair.AttachedLine.State != STATE_FIRST && - Crosshair.AttachedLine.draw) - { - XORDrawAttachedLine (Crosshair.AttachedLine.Point1.X, - Crosshair.AttachedLine.Point1.Y, - Crosshair.AttachedLine.Point2.X, - Crosshair.AttachedLine.Point2.Y, - PCB->RatDraw ? 10 : Settings.LineThickness); - /* draw two lines ? */ - if (PCB->Clipping) - XORDrawAttachedLine (Crosshair.AttachedLine.Point2.X, - Crosshair.AttachedLine.Point2.Y, - Crosshair.X, Crosshair.Y, - PCB->RatDraw ? 10 : Settings.LineThickness); - if (TEST_FLAG (SHOWDRCFLAG, PCB)) - { - gui->set_color (Crosshair.GC, Settings.CrossColor); - XORDrawAttachedLine (Crosshair.AttachedLine.Point1.X, - Crosshair.AttachedLine.Point1.Y, - Crosshair.AttachedLine.Point2.X, - Crosshair.AttachedLine.Point2.Y, - PCB->RatDraw ? 10 : Settings.LineThickness - + 2 * (PCB->Bloat + 1)); - if (PCB->Clipping) - XORDrawAttachedLine (Crosshair.AttachedLine.Point2.X, - Crosshair.AttachedLine.Point2.Y, - Crosshair.X, Crosshair.Y, - PCB->RatDraw ? 10 : Settings. - LineThickness + 2 * (PCB->Bloat + 1)); - gui->set_color (Crosshair.GC, Settings.CrosshairColor); - } - } - break; + case LINE_MODE: + /* draw only if starting point exists and the line has length */ + if (Crosshair.AttachedLine.State != STATE_FIRST && Crosshair.AttachedLine.draw) { + XORDrawAttachedLine(Crosshair.AttachedLine.Point1.X, + Crosshair.AttachedLine.Point1.Y, + Crosshair.AttachedLine.Point2.X, + Crosshair.AttachedLine.Point2.Y, PCB->RatDraw ? 10 : Settings.LineThickness); + /* draw two lines ? */ + if (PCB->Clipping) + XORDrawAttachedLine(Crosshair.AttachedLine.Point2.X, + Crosshair.AttachedLine.Point2.Y, + Crosshair.X, Crosshair.Y, PCB->RatDraw ? 10 : Settings.LineThickness); + if (TEST_FLAG(SHOWDRCFLAG, PCB)) { + gui->set_color(Crosshair.GC, Settings.CrossColor); + XORDrawAttachedLine(Crosshair.AttachedLine.Point1.X, + Crosshair.AttachedLine.Point1.Y, + Crosshair.AttachedLine.Point2.X, + Crosshair.AttachedLine.Point2.Y, PCB->RatDraw ? 10 : Settings.LineThickness + 2 * (PCB->Bloat + 1)); + if (PCB->Clipping) + XORDrawAttachedLine(Crosshair.AttachedLine.Point2.X, + Crosshair.AttachedLine.Point2.Y, + Crosshair.X, Crosshair.Y, PCB->RatDraw ? 10 : Settings.LineThickness + 2 * (PCB->Bloat + 1)); + gui->set_color(Crosshair.GC, Settings.CrosshairColor); + } + } + break; - case PASTEBUFFER_MODE: - XORDrawBuffer (PASTEBUFFER); - break; + case PASTEBUFFER_MODE: + XORDrawBuffer(PASTEBUFFER); + break; - case COPY_MODE: - case MOVE_MODE: - XORDrawMoveOrCopyObject (); - break; + case COPY_MODE: + case MOVE_MODE: + XORDrawMoveOrCopyObject(); + break; - case INSERTPOINT_MODE: - XORDrawInsertPointObject (); - break; - } + case INSERTPOINT_MODE: + XORDrawInsertPointObject(); + break; + } - /* an attached box does not depend on a special mode */ - if (Crosshair.AttachedBox.State == STATE_SECOND || - Crosshair.AttachedBox.State == STATE_THIRD) - { - Coord x1, y1, x2, y2; + /* an attached box does not depend on a special mode */ + if (Crosshair.AttachedBox.State == STATE_SECOND || Crosshair.AttachedBox.State == STATE_THIRD) { + Coord x1, y1, x2, y2; - x1 = Crosshair.AttachedBox.Point1.X; - y1 = Crosshair.AttachedBox.Point1.Y; - x2 = Crosshair.AttachedBox.Point2.X; - y2 = Crosshair.AttachedBox.Point2.Y; - gui->draw_rect (Crosshair.GC, x1, y1, x2, y2); - } + x1 = Crosshair.AttachedBox.Point1.X; + y1 = Crosshair.AttachedBox.Point1.Y; + x2 = Crosshair.AttachedBox.Point2.X; + y2 = Crosshair.AttachedBox.Point2.Y; + gui->draw_rect(Crosshair.GC, x1, y1, x2, y2); + } } @@ -670,33 +566,25 @@ /* -------------------------------------------------------------------------- * draw the marker position */ -void -DrawMark (void) +void DrawMark(void) { - /* Mark is not drawn when it is not set */ - if (!Marked.status) - return; + /* Mark is not drawn when it is not set */ + if (!Marked.status) + return; - gui->draw_line (Crosshair.GC, - Marked.X - MARK_SIZE, - Marked.Y - MARK_SIZE, - Marked.X + MARK_SIZE, Marked.Y + MARK_SIZE); - gui->draw_line (Crosshair.GC, - Marked.X + MARK_SIZE, - Marked.Y - MARK_SIZE, - Marked.X - MARK_SIZE, Marked.Y + MARK_SIZE); + gui->draw_line(Crosshair.GC, Marked.X - MARK_SIZE, Marked.Y - MARK_SIZE, Marked.X + MARK_SIZE, Marked.Y + MARK_SIZE); + gui->draw_line(Crosshair.GC, Marked.X + MARK_SIZE, Marked.Y - MARK_SIZE, Marked.X - MARK_SIZE, Marked.Y + MARK_SIZE); } /* --------------------------------------------------------------------------- * Returns the nearest grid-point to the given Coord */ -Coord -GridFit (Coord x, Coord grid_spacing, Coord grid_offset) +Coord GridFit(Coord x, Coord grid_spacing, Coord grid_offset) { - x -= grid_offset; - x = grid_spacing * round ((double) x / grid_spacing); - x += grid_offset; - return x; + x -= grid_offset; + x = grid_spacing * round((double) x / grid_spacing); + x += grid_offset; + return x; } @@ -715,11 +603,10 @@ * (if necessary) mean repainting the whole screen if the GUI hasn't tracked the * location of existing attached drawing. */ -void -notify_crosshair_change (bool changes_complete) +void notify_crosshair_change(bool changes_complete) { - if (gui->notify_crosshair_change) - gui->notify_crosshair_change (changes_complete); + if (gui->notify_crosshair_change) + gui->notify_crosshair_change(changes_complete); } @@ -737,11 +624,10 @@ * They should initiate a redraw of the mark - which may (if necessary) mean * repainting the whole screen if the GUI hasn't tracked the mark's location. */ -void -notify_mark_change (bool changes_complete) +void notify_mark_change(bool changes_complete) { - if (gui->notify_mark_change) - gui->notify_mark_change (changes_complete); + if (gui->notify_mark_change) + gui->notify_mark_change(changes_complete); } @@ -755,34 +641,30 @@ * warning at the time of their first use. * */ -void -HideCrosshair (void) +void HideCrosshair(void) { - static bool warned_old_api = false; - if (!warned_old_api) - { - Message (_("WARNING: A plugin is using the deprecated API HideCrosshair().\n" - " This API may be removed in a future release of PCB.\n")); - warned_old_api = true; - } + static bool warned_old_api = false; + if (!warned_old_api) { + Message(_("WARNING: A plugin is using the deprecated API HideCrosshair().\n" + " This API may be removed in a future release of PCB.\n")); + warned_old_api = true; + } - notify_crosshair_change (false); - notify_mark_change (false); + notify_crosshair_change(false); + notify_mark_change(false); } -void -RestoreCrosshair (void) +void RestoreCrosshair(void) { - static bool warned_old_api = false; - if (!warned_old_api) - { - Message (_("WARNING: A plugin is using the deprecated API RestoreCrosshair().\n" - " This API may be removed in a future release of PCB.\n")); - warned_old_api = true; - } + static bool warned_old_api = false; + if (!warned_old_api) { + Message(_("WARNING: A plugin is using the deprecated API RestoreCrosshair().\n" + " This API may be removed in a future release of PCB.\n")); + warned_old_api = true; + } - notify_crosshair_change (true); - notify_mark_change (true); + notify_crosshair_change(true); + notify_mark_change(true); } /* @@ -791,96 +673,79 @@ * endpoints. */ struct onpoint_search_info { - CrosshairType *crosshair; - Coord X; - Coord Y; + CrosshairType *crosshair; + Coord X; + Coord Y; }; -static int -onpoint_line_callback(const BoxType *box, void *cl) +static int onpoint_line_callback(const BoxType * box, void *cl) { - struct onpoint_search_info *info = (struct onpoint_search_info *)cl; - CrosshairType *crosshair = info->crosshair; - LineType *line = (LineType *)box; + struct onpoint_search_info *info = (struct onpoint_search_info *) cl; + CrosshairType *crosshair = info->crosshair; + LineType *line = (LineType *) box; #ifdef DEBUG_ONPOINT - printf("X=%ld Y=%ld X1=%ld Y1=%ld X2=%ld Y2=%ld\n", info->X, info->Y, - line->Point1.X, - line->Point1.Y, - line->Point2.X, - line->Point2.Y); + printf("X=%ld Y=%ld X1=%ld Y1=%ld X2=%ld Y2=%ld\n", info->X, info->Y, + line->Point1.X, line->Point1.Y, line->Point2.X, line->Point2.Y); #endif - if ((line->Point1.X == info->X && line->Point1.Y == info->Y) || - (line->Point2.X == info->X && line->Point2.Y == info->Y)) - { - crosshair->onpoint_objs = - g_list_prepend(crosshair->onpoint_objs, line); - crosshair->onpoint_objs_types = - g_list_prepend(crosshair->onpoint_objs_types, - GINT_TO_POINTER(LINE_TYPE)); - SET_FLAG(ONPOINTFLAG, (AnyObjectType *)line); - DrawLine(NULL, line); - return 1; - } - else - { - return 0; - } + if ((line->Point1.X == info->X && line->Point1.Y == info->Y) || (line->Point2.X == info->X && line->Point2.Y == info->Y)) { + crosshair->onpoint_objs = g_list_prepend(crosshair->onpoint_objs, line); + crosshair->onpoint_objs_types = g_list_prepend(crosshair->onpoint_objs_types, GINT_TO_POINTER(LINE_TYPE)); + SET_FLAG(ONPOINTFLAG, (AnyObjectType *) line); + DrawLine(NULL, line); + return 1; + } + else { + return 0; + } } #define close_enough(v1, v2) (fabs((v1)-(v2)) < 10) -static int -onpoint_arc_callback(const BoxType *box, void *cl) +static int onpoint_arc_callback(const BoxType * box, void *cl) { - struct onpoint_search_info *info = (struct onpoint_search_info *)cl; - CrosshairType *crosshair = info->crosshair; - ArcType *arc = (ArcType *)box; + struct onpoint_search_info *info = (struct onpoint_search_info *) cl; + CrosshairType *crosshair = info->crosshair; + ArcType *arc = (ArcType *) box; Coord p1x, p1y, p2x, p2y; - p1x = arc->X - arc->Width * cos (TO_RADIANS (arc->StartAngle)); - p1y = arc->Y + arc->Height * sin (TO_RADIANS (arc->StartAngle)); - p2x = arc->X - arc->Width * cos (TO_RADIANS (arc->StartAngle + arc->Delta)); - p2y = arc->Y + arc->Height * sin (TO_RADIANS (arc->StartAngle + arc->Delta)); + p1x = arc->X - arc->Width * cos(TO_RADIANS(arc->StartAngle)); + p1y = arc->Y + arc->Height * sin(TO_RADIANS(arc->StartAngle)); + p2x = arc->X - arc->Width * cos(TO_RADIANS(arc->StartAngle + arc->Delta)); + p2y = arc->Y + arc->Height * sin(TO_RADIANS(arc->StartAngle + arc->Delta)); /* printf("p1=%ld;%ld p2=%ld;%ld info=%ld;%ld\n", p1x, p1y, p2x, p2y, info->X, info->Y); */ - if ((close_enough(p1x, info->X) && close_enough(p1y, info->Y)) || - (close_enough(p2x, info->X) && close_enough(p2y, info->Y))) - { - crosshair->onpoint_objs = - g_list_prepend(crosshair->onpoint_objs, arc); - crosshair->onpoint_objs_types = - g_list_prepend(crosshair->onpoint_objs_types, GINT_TO_POINTER(ARC_TYPE)); - SET_FLAG(ONPOINTFLAG, (AnyObjectType *)arc); - DrawArc(NULL, arc); - return 1; - } - else - { - return 0; - } + if ((close_enough(p1x, info->X) && close_enough(p1y, info->Y)) || (close_enough(p2x, info->X) && close_enough(p2y, info->Y))) { + crosshair->onpoint_objs = g_list_prepend(crosshair->onpoint_objs, arc); + crosshair->onpoint_objs_types = g_list_prepend(crosshair->onpoint_objs_types, GINT_TO_POINTER(ARC_TYPE)); + SET_FLAG(ONPOINTFLAG, (AnyObjectType *) arc); + DrawArc(NULL, arc); + return 1; + } + else { + return 0; + } } void DrawLineOrArc(int type, void *obj) { - switch (type) - { - case LINEPOINT_TYPE: - /* Attention: We can use a NULL pointer here for the layer, - * because it is not used in the DrawLine() function anyways. - * ATM DrawLine() only alls AddPart() internally, which invalidates - * the area specified by the line's bounding box. - */ - DrawLine(NULL, (LineType *)obj); - break; + switch (type) { + case LINEPOINT_TYPE: + /* Attention: We can use a NULL pointer here for the layer, + * because it is not used in the DrawLine() function anyways. + * ATM DrawLine() only alls AddPart() internally, which invalidates + * the area specified by the line's bounding box. + */ + DrawLine(NULL, (LineType *) obj); + break; #if 0 - case ARCPOINT_TYPE: - /* See comment above */ - DrawArc(NULL, (ArcType *)obj); - break; + case ARCPOINT_TYPE: + /* See comment above */ + DrawArc(NULL, (ArcType *) obj); + break; #endif - } + } } /* @@ -888,91 +753,79 @@ * at the given coordinates and adds them to the crosshair's * object list along with their respective type. */ -static void onpoint_work(CrosshairType *crosshair, Coord X, Coord Y) +static void onpoint_work(CrosshairType * crosshair, Coord X, Coord Y) { - BoxType SearchBox = point_box(X, Y); - struct onpoint_search_info info; - int i; - GList *lobjs, *ltypes; - GList *old_onpoint_objs = crosshair->onpoint_objs; - GList *old_onpoint_objs_types = crosshair->onpoint_objs_types; - bool redraw = false; + BoxType SearchBox = point_box(X, Y); + struct onpoint_search_info info; + int i; + GList *lobjs, *ltypes; + GList *old_onpoint_objs = crosshair->onpoint_objs; + GList *old_onpoint_objs_types = crosshair->onpoint_objs_types; + bool redraw = false; - crosshair->onpoint_objs = NULL; - crosshair->onpoint_objs_types = NULL; + crosshair->onpoint_objs = NULL; + crosshair->onpoint_objs_types = NULL; - info.crosshair = crosshair; - info.X = X; - info.Y = Y; + info.crosshair = crosshair; + info.X = X; + info.Y = Y; - for (i = 0; i < max_copper_layer; i++) - { - LayerType *layer = &PCB->Data->Layer[i]; - /* Only find points of arcs and lines on currently visible layers. */ - if (!layer->On) - continue; - r_search(layer->line_tree, &SearchBox, NULL, - onpoint_line_callback, &info); - r_search(layer->arc_tree, &SearchBox, NULL, - onpoint_arc_callback, &info); - } + for (i = 0; i < max_copper_layer; i++) { + LayerType *layer = &PCB->Data->Layer[i]; + /* Only find points of arcs and lines on currently visible layers. */ + if (!layer->On) + continue; + r_search(layer->line_tree, &SearchBox, NULL, onpoint_line_callback, &info); + r_search(layer->arc_tree, &SearchBox, NULL, onpoint_arc_callback, &info); + } - /* Undraw the old objects */ - for (lobjs = old_onpoint_objs, ltypes = old_onpoint_objs_types; - lobjs != NULL; - lobjs = lobjs->next, ltypes = ltypes->next) - { - /* only remove and redraw those which aren't in the new list */ - if (g_list_find(crosshair->onpoint_objs, lobjs->data) != NULL) - continue; + /* Undraw the old objects */ + for (lobjs = old_onpoint_objs, ltypes = old_onpoint_objs_types; lobjs != NULL; lobjs = lobjs->next, ltypes = ltypes->next) { + /* only remove and redraw those which aren't in the new list */ + if (g_list_find(crosshair->onpoint_objs, lobjs->data) != NULL) + continue; - CLEAR_FLAG(ONPOINTFLAG, (AnyObjectType *)lobjs->data); - DrawLineOrArc(GPOINTER_TO_INT(ltypes->data), lobjs->data); - redraw = true; - } + CLEAR_FLAG(ONPOINTFLAG, (AnyObjectType *) lobjs->data); + DrawLineOrArc(GPOINTER_TO_INT(ltypes->data), lobjs->data); + redraw = true; + } - /* draw the new objects */ - for (lobjs = crosshair->onpoint_objs, - ltypes = crosshair->onpoint_objs_types; - lobjs != NULL; - lobjs = lobjs->next, ltypes = ltypes->next) - { - /* only draw those which aren't in the old list */ - if (g_list_find(old_onpoint_objs, lobjs->data) != NULL) - continue; - DrawLineOrArc(GPOINTER_TO_INT(ltypes->data), lobjs->data); - redraw = true; - } + /* draw the new objects */ + for (lobjs = crosshair->onpoint_objs, + ltypes = crosshair->onpoint_objs_types; lobjs != NULL; lobjs = lobjs->next, ltypes = ltypes->next) { + /* only draw those which aren't in the old list */ + if (g_list_find(old_onpoint_objs, lobjs->data) != NULL) + continue; + DrawLineOrArc(GPOINTER_TO_INT(ltypes->data), lobjs->data); + redraw = true; + } - g_list_free(old_onpoint_objs); - g_list_free(old_onpoint_objs_types); + g_list_free(old_onpoint_objs); + g_list_free(old_onpoint_objs_types); - if (redraw) - { - Redraw(); - } + if (redraw) { + Redraw(); + } } /* --------------------------------------------------------------------------- * Returns the square of the given number */ -static double -square (double x) +static double square(double x) { - return x * x; + return x * x; } -static double -crosshair_sq_dist (CrosshairType *crosshair, Coord x, Coord y) +static double crosshair_sq_dist(CrosshairType * crosshair, Coord x, Coord y) { - return square (x - crosshair->X) + square (y - crosshair->Y); + return square(x - crosshair->X) + square(y - crosshair->Y); } struct snap_data { - CrosshairType *crosshair; - double nearest_sq_dist; - bool nearest_is_grid; - Coord x, y; + CrosshairType *crosshair; + double nearest_sq_dist; + bool nearest_is_grid; + Coord x, y; }; /* Snap to a given location if it is the closest thing we found so far. @@ -981,322 +834,270 @@ * pressing the SHIFT key. If the SHIFT key is pressed, the closest object * (including grid points), is always preferred. */ -static void -check_snap_object (struct snap_data *snap_data, Coord x, Coord y, - bool prefer_to_grid) +static void check_snap_object(struct snap_data *snap_data, Coord x, Coord y, bool prefer_to_grid) { - double sq_dist; + double sq_dist; - sq_dist = crosshair_sq_dist (snap_data->crosshair, x, y); - if (sq_dist < snap_data->nearest_sq_dist || - (prefer_to_grid && snap_data->nearest_is_grid && !gui->shift_is_pressed())) - { - snap_data->x = x; - snap_data->y = y; - snap_data->nearest_sq_dist = sq_dist; - snap_data->nearest_is_grid = false; - } + sq_dist = crosshair_sq_dist(snap_data->crosshair, x, y); + if (sq_dist < snap_data->nearest_sq_dist || (prefer_to_grid && snap_data->nearest_is_grid && !gui->shift_is_pressed())) { + snap_data->x = x; + snap_data->y = y; + snap_data->nearest_sq_dist = sq_dist; + snap_data->nearest_is_grid = false; + } } -static void -check_snap_offgrid_line (struct snap_data *snap_data, - Coord nearest_grid_x, - Coord nearest_grid_y) +static void check_snap_offgrid_line(struct snap_data *snap_data, Coord nearest_grid_x, Coord nearest_grid_y) { - void *ptr1, *ptr2, *ptr3; - int ans; - LineType *line; - Coord try_x, try_y; - double dx, dy; - double dist; + void *ptr1, *ptr2, *ptr3; + int ans; + LineType *line; + Coord try_x, try_y; + double dx, dy; + double dist; - if (!TEST_FLAG (SNAPPINFLAG, PCB)) - return; + if (!TEST_FLAG(SNAPPINFLAG, PCB)) + return; - /* Code to snap at some sensible point along a line */ - /* Pick the nearest grid-point in the x or y direction - * to align with, then adjust until we hit the line - */ - ans = SearchScreenGridSlop (Crosshair.X, Crosshair.Y, - LINE_TYPE, &ptr1, &ptr2, &ptr3); + /* Code to snap at some sensible point along a line */ + /* Pick the nearest grid-point in the x or y direction + * to align with, then adjust until we hit the line + */ + ans = SearchScreenGridSlop(Crosshair.X, Crosshair.Y, LINE_TYPE, &ptr1, &ptr2, &ptr3); - if (ans == NO_TYPE) - return; + if (ans == NO_TYPE) + return; - line = (LineType *)ptr2; + line = (LineType *) ptr2; - /* Allow snapping to off-grid lines when drawing new lines (on - * the same layer), and when moving a line end-point - * (but don't snap to the same line) - */ - if ((Settings.Mode != LINE_MODE || CURRENT != ptr1) && - (Settings.Mode != MOVE_MODE || - Crosshair.AttachedObject.Ptr1 != ptr1 || - Crosshair.AttachedObject.Type != LINEPOINT_TYPE || - Crosshair.AttachedObject.Ptr2 == line)) - return; + /* Allow snapping to off-grid lines when drawing new lines (on + * the same layer), and when moving a line end-point + * (but don't snap to the same line) + */ + if ((Settings.Mode != LINE_MODE || CURRENT != ptr1) && + (Settings.Mode != MOVE_MODE || + Crosshair.AttachedObject.Ptr1 != ptr1 || + Crosshair.AttachedObject.Type != LINEPOINT_TYPE || Crosshair.AttachedObject.Ptr2 == line)) + return; - dx = line->Point2.X - line->Point1.X; - dy = line->Point2.Y - line->Point1.Y; + dx = line->Point2.X - line->Point1.X; + dy = line->Point2.Y - line->Point1.Y; - /* Try snapping along the X axis */ - if (dy != 0.) - { - /* Move in the X direction until we hit the line */ - try_x = (nearest_grid_y - line->Point1.Y) / dy * dx + line->Point1.X; - try_y = nearest_grid_y; - check_snap_object (snap_data, try_x, try_y, true); - } + /* Try snapping along the X axis */ + if (dy != 0.) { + /* Move in the X direction until we hit the line */ + try_x = (nearest_grid_y - line->Point1.Y) / dy * dx + line->Point1.X; + try_y = nearest_grid_y; + check_snap_object(snap_data, try_x, try_y, true); + } - /* Try snapping along the Y axis */ - if (dx != 0.) - { - try_x = nearest_grid_x; - try_y = (nearest_grid_x - line->Point1.X) / dx * dy + line->Point1.Y; - check_snap_object (snap_data, try_x, try_y, true); - } + /* Try snapping along the Y axis */ + if (dx != 0.) { + try_x = nearest_grid_x; + try_y = (nearest_grid_x - line->Point1.X) / dx * dy + line->Point1.Y; + check_snap_object(snap_data, try_x, try_y, true); + } - if (dx != dy) /* If line not parallel with dX = dY direction.. */ - { - /* Try snapping diagonally towards the line in the dX = dY direction */ + if (dx != dy) { /* If line not parallel with dX = dY direction.. */ + /* Try snapping diagonally towards the line in the dX = dY direction */ - if (dy == 0) - dist = line->Point1.Y - nearest_grid_y; - else - dist = ((line->Point1.X - nearest_grid_x) - - (line->Point1.Y - nearest_grid_y) * dx / dy) / (1 - dx / dy); + if (dy == 0) + dist = line->Point1.Y - nearest_grid_y; + else + dist = ((line->Point1.X - nearest_grid_x) - (line->Point1.Y - nearest_grid_y) * dx / dy) / (1 - dx / dy); - try_x = nearest_grid_x + dist; - try_y = nearest_grid_y + dist; + try_x = nearest_grid_x + dist; + try_y = nearest_grid_y + dist; - check_snap_object (snap_data, try_x, try_y, true); - } + check_snap_object(snap_data, try_x, try_y, true); + } - if (dx != -dy) /* If line not parallel with dX = -dY direction.. */ - { - /* Try snapping diagonally towards the line in the dX = -dY direction */ + if (dx != -dy) { /* If line not parallel with dX = -dY direction.. */ + /* Try snapping diagonally towards the line in the dX = -dY direction */ - if (dy == 0) - dist = nearest_grid_y - line->Point1.Y; - else - dist = ((line->Point1.X - nearest_grid_x) - - (line->Point1.Y - nearest_grid_y) * dx / dy) / (1 + dx / dy); + if (dy == 0) + dist = nearest_grid_y - line->Point1.Y; + else + dist = ((line->Point1.X - nearest_grid_x) - (line->Point1.Y - nearest_grid_y) * dx / dy) / (1 + dx / dy); - try_x = nearest_grid_x + dist; - try_y = nearest_grid_y - dist; + try_x = nearest_grid_x + dist; + try_y = nearest_grid_y - dist; - check_snap_object (snap_data, try_x, try_y, true); - } + check_snap_object(snap_data, try_x, try_y, true); + } } /* --------------------------------------------------------------------------- * recalculates the passed coordinates to fit the current grid setting */ -void -FitCrosshairIntoGrid (Coord X, Coord Y) +void FitCrosshairIntoGrid(Coord X, Coord Y) { - Coord nearest_grid_x, nearest_grid_y; - void *ptr1, *ptr2, *ptr3; - struct snap_data snap_data; - int ans; + Coord nearest_grid_x, nearest_grid_y; + void *ptr1, *ptr2, *ptr3; + struct snap_data snap_data; + int ans; - Crosshair.X = CLAMP (X, Crosshair.MinX, Crosshair.MaxX); - Crosshair.Y = CLAMP (Y, Crosshair.MinY, Crosshair.MaxY); + Crosshair.X = CLAMP(X, Crosshair.MinX, Crosshair.MaxX); + Crosshair.Y = CLAMP(Y, Crosshair.MinY, Crosshair.MaxY); - if (PCB->RatDraw) - { - nearest_grid_x = -MIL_TO_COORD (6); - nearest_grid_y = -MIL_TO_COORD (6); - } - else - { - nearest_grid_x = GridFit (Crosshair.X, PCB->Grid, PCB->GridOffsetX); - nearest_grid_y = GridFit (Crosshair.Y, PCB->Grid, PCB->GridOffsetY); + if (PCB->RatDraw) { + nearest_grid_x = -MIL_TO_COORD(6); + nearest_grid_y = -MIL_TO_COORD(6); + } + else { + nearest_grid_x = GridFit(Crosshair.X, PCB->Grid, PCB->GridOffsetX); + nearest_grid_y = GridFit(Crosshair.Y, PCB->Grid, PCB->GridOffsetY); - if (Marked.status && TEST_FLAG (ORTHOMOVEFLAG, PCB)) - { - Coord dx = Crosshair.X - Marked.X; - Coord dy = Crosshair.Y - Marked.Y; - if (ABS (dx) > ABS (dy)) - nearest_grid_y = Marked.Y; - else - nearest_grid_x = Marked.X; + if (Marked.status && TEST_FLAG(ORTHOMOVEFLAG, PCB)) { + Coord dx = Crosshair.X - Marked.X; + Coord dy = Crosshair.Y - Marked.Y; + if (ABS(dx) > ABS(dy)) + nearest_grid_y = Marked.Y; + else + nearest_grid_x = Marked.X; + } + } - } + snap_data.crosshair = &Crosshair; + snap_data.nearest_sq_dist = crosshair_sq_dist(&Crosshair, nearest_grid_x, nearest_grid_y); + snap_data.nearest_is_grid = true; + snap_data.x = nearest_grid_x; + snap_data.y = nearest_grid_y; - snap_data.crosshair = &Crosshair; - snap_data.nearest_sq_dist = - crosshair_sq_dist (&Crosshair, nearest_grid_x, nearest_grid_y); - snap_data.nearest_is_grid = true; - snap_data.x = nearest_grid_x; - snap_data.y = nearest_grid_y; + ans = NO_TYPE; + if (!PCB->RatDraw) + ans = SearchScreenGridSlop(Crosshair.X, Crosshair.Y, ELEMENT_TYPE, &ptr1, &ptr2, &ptr3); - ans = NO_TYPE; - if (!PCB->RatDraw) - ans = SearchScreenGridSlop (Crosshair.X, Crosshair.Y, - ELEMENT_TYPE, &ptr1, &ptr2, &ptr3); + if (ans & ELEMENT_TYPE) { + ElementType *el = (ElementType *) ptr1; + check_snap_object(&snap_data, el->MarkX, el->MarkY, false); + } - if (ans & ELEMENT_TYPE) - { - ElementType *el = (ElementType *) ptr1; - check_snap_object (&snap_data, el->MarkX, el->MarkY, false); - } + ans = NO_TYPE; + if (PCB->RatDraw || TEST_FLAG(SNAPPINFLAG, PCB)) + ans = SearchScreenGridSlop(Crosshair.X, Crosshair.Y, PAD_TYPE, &ptr1, &ptr2, &ptr3); - ans = NO_TYPE; - if (PCB->RatDraw || TEST_FLAG (SNAPPINFLAG, PCB)) - ans = SearchScreenGridSlop (Crosshair.X, Crosshair.Y, - PAD_TYPE, &ptr1, &ptr2, &ptr3); + /* Avoid self-snapping when moving */ + if (ans != NO_TYPE && + Settings.Mode == MOVE_MODE && Crosshair.AttachedObject.Type == ELEMENT_TYPE && ptr1 == Crosshair.AttachedObject.Ptr1) + ans = NO_TYPE; - /* Avoid self-snapping when moving */ - if (ans != NO_TYPE && - Settings.Mode == MOVE_MODE && - Crosshair.AttachedObject.Type == ELEMENT_TYPE && - ptr1 == Crosshair.AttachedObject.Ptr1) - ans = NO_TYPE; + if (ans != NO_TYPE && + (Settings.Mode == LINE_MODE || (Settings.Mode == MOVE_MODE && Crosshair.AttachedObject.Type == LINEPOINT_TYPE))) { + PadTypePtr pad = (PadTypePtr) ptr2; + LayerType *desired_layer; + Cardinal desired_group; + Cardinal SLayer, CLayer; + int found_our_layer = false; - if (ans != NO_TYPE && - ( Settings.Mode == LINE_MODE || - (Settings.Mode == MOVE_MODE && - Crosshair.AttachedObject.Type == LINEPOINT_TYPE))) - { - PadTypePtr pad = (PadTypePtr) ptr2; - LayerType *desired_layer; - Cardinal desired_group; - Cardinal SLayer, CLayer; - int found_our_layer = false; + desired_layer = CURRENT; + if (Settings.Mode == MOVE_MODE && Crosshair.AttachedObject.Type == LINEPOINT_TYPE) { + desired_layer = (LayerType *) Crosshair.AttachedObject.Ptr1; + } - desired_layer = CURRENT; - if (Settings.Mode == MOVE_MODE && - Crosshair.AttachedObject.Type == LINEPOINT_TYPE) - { - desired_layer = (LayerType *)Crosshair.AttachedObject.Ptr1; - } + /* find layer groups of the component side and solder side */ + SLayer = GetLayerGroupNumberByNumber(solder_silk_layer); + CLayer = GetLayerGroupNumberByNumber(component_silk_layer); + desired_group = TEST_FLAG(ONSOLDERFLAG, pad) ? SLayer : CLayer; - /* find layer groups of the component side and solder side */ - SLayer = GetLayerGroupNumberByNumber (solder_silk_layer); - CLayer = GetLayerGroupNumberByNumber (component_silk_layer); - desired_group = TEST_FLAG (ONSOLDERFLAG, pad) ? SLayer : CLayer; + GROUP_LOOP(PCB->Data, desired_group); + { + if (layer == desired_layer) { + found_our_layer = true; + break; + } + } + END_LOOP; - GROUP_LOOP (PCB->Data, desired_group); - { - if (layer == desired_layer) - { - found_our_layer = true; - break; - } - } - END_LOOP; + if (found_our_layer == false) + ans = NO_TYPE; + } - if (found_our_layer == false) - ans = NO_TYPE; - } + if (ans != NO_TYPE) { + PadType *pad = (PadType *) ptr2; + check_snap_object(&snap_data, (pad->Point1.X + pad->Point2.X) / 2, (pad->Point1.Y + pad->Point2.Y) / 2, true); + } - if (ans != NO_TYPE) - { - PadType *pad = (PadType *)ptr2; - check_snap_object (&snap_data, (pad->Point1.X + pad->Point2.X) / 2, - (pad->Point1.Y + pad->Point2.Y) / 2, - true); - } + ans = NO_TYPE; + if (PCB->RatDraw || TEST_FLAG(SNAPPINFLAG, PCB)) + ans = SearchScreenGridSlop(Crosshair.X, Crosshair.Y, PIN_TYPE, &ptr1, &ptr2, &ptr3); - ans = NO_TYPE; - if (PCB->RatDraw || TEST_FLAG (SNAPPINFLAG, PCB)) - ans = SearchScreenGridSlop (Crosshair.X, Crosshair.Y, - PIN_TYPE, &ptr1, &ptr2, &ptr3); + /* Avoid self-snapping when moving */ + if (ans != NO_TYPE && + Settings.Mode == MOVE_MODE && Crosshair.AttachedObject.Type == ELEMENT_TYPE && ptr1 == Crosshair.AttachedObject.Ptr1) + ans = NO_TYPE; - /* Avoid self-snapping when moving */ - if (ans != NO_TYPE && - Settings.Mode == MOVE_MODE && - Crosshair.AttachedObject.Type == ELEMENT_TYPE && - ptr1 == Crosshair.AttachedObject.Ptr1) - ans = NO_TYPE; + if (ans != NO_TYPE) { + PinType *pin = (PinType *) ptr2; + check_snap_object(&snap_data, pin->X, pin->Y, true); + } - if (ans != NO_TYPE) - { - PinType *pin = (PinType *)ptr2; - check_snap_object (&snap_data, pin->X, pin->Y, true); - } + ans = NO_TYPE; + if (TEST_FLAG(SNAPPINFLAG, PCB)) + ans = SearchScreenGridSlop(Crosshair.X, Crosshair.Y, VIA_TYPE, &ptr1, &ptr2, &ptr3); - ans = NO_TYPE; - if (TEST_FLAG (SNAPPINFLAG, PCB)) - ans = SearchScreenGridSlop (Crosshair.X, Crosshair.Y, - VIA_TYPE, &ptr1, &ptr2, &ptr3); + /* Avoid snapping vias to any other vias */ + if (Settings.Mode == MOVE_MODE && Crosshair.AttachedObject.Type == VIA_TYPE && (ans & PIN_TYPES)) + ans = NO_TYPE; - /* Avoid snapping vias to any other vias */ - if (Settings.Mode == MOVE_MODE && - Crosshair.AttachedObject.Type == VIA_TYPE && - (ans & PIN_TYPES)) - ans = NO_TYPE; + if (ans != NO_TYPE) { + PinType *pin = (PinType *) ptr2; + check_snap_object(&snap_data, pin->X, pin->Y, true); + } - if (ans != NO_TYPE) - { - PinType *pin = (PinType *)ptr2; - check_snap_object (&snap_data, pin->X, pin->Y, true); - } + ans = NO_TYPE; + if (TEST_FLAG(SNAPPINFLAG, PCB)) + ans = SearchScreenGridSlop(Crosshair.X, Crosshair.Y, LINEPOINT_TYPE, &ptr1, &ptr2, &ptr3); - ans = NO_TYPE; - if (TEST_FLAG (SNAPPINFLAG, PCB)) - ans = SearchScreenGridSlop (Crosshair.X, Crosshair.Y, - LINEPOINT_TYPE, &ptr1, &ptr2, &ptr3); + if (ans != NO_TYPE) { + PointType *pnt = (PointType *) ptr3; + check_snap_object(&snap_data, pnt->X, pnt->Y, true); + } - if (ans != NO_TYPE) - { - PointType *pnt = (PointType *)ptr3; - check_snap_object (&snap_data, pnt->X, pnt->Y, true); - } + /* + * Snap to offgrid points on lines. + */ + if (TEST_FLAG(SNAPOFFGRIDLINEFLAG, PCB)) + check_snap_offgrid_line(&snap_data, nearest_grid_x, nearest_grid_y); - /* - * Snap to offgrid points on lines. - */ - if (TEST_FLAG (SNAPOFFGRIDLINEFLAG, PCB)) - check_snap_offgrid_line (&snap_data, nearest_grid_x, nearest_grid_y); + ans = NO_TYPE; + if (TEST_FLAG(SNAPPINFLAG, PCB)) + ans = SearchScreenGridSlop(Crosshair.X, Crosshair.Y, POLYGONPOINT_TYPE, &ptr1, &ptr2, &ptr3); - ans = NO_TYPE; - if (TEST_FLAG (SNAPPINFLAG, PCB)) - ans = SearchScreenGridSlop (Crosshair.X, Crosshair.Y, - POLYGONPOINT_TYPE, &ptr1, &ptr2, &ptr3); + if (ans != NO_TYPE) { + PointType *pnt = (PointType *) ptr3; + check_snap_object(&snap_data, pnt->X, pnt->Y, true); + } - if (ans != NO_TYPE) - { - PointType *pnt = (PointType *)ptr3; - check_snap_object (&snap_data, pnt->X, pnt->Y, true); - } + if (snap_data.x >= 0 && snap_data.y >= 0) { + Crosshair.X = snap_data.x; + Crosshair.Y = snap_data.y; + } - if (snap_data.x >= 0 && snap_data.y >= 0) - { - Crosshair.X = snap_data.x; - Crosshair.Y = snap_data.y; - } + if (TEST_FLAG(HIGHLIGHTONPOINTFLAG, PCB)) + onpoint_work(&Crosshair, Crosshair.X, Crosshair.Y); - if (TEST_FLAG (HIGHLIGHTONPOINTFLAG, PCB)) - onpoint_work(&Crosshair, Crosshair.X, Crosshair.Y); + if (Settings.Mode == ARROW_MODE) { + ans = SearchScreenGridSlop(Crosshair.X, Crosshair.Y, LINEPOINT_TYPE, &ptr1, &ptr2, &ptr3); + if (ans == NO_TYPE) + hid_action("PointCursor"); + else if (!TEST_FLAG(SELECTEDFLAG, (LineType *) ptr2)) + hid_actionl("PointCursor", "True", NULL); + } - if (Settings.Mode == ARROW_MODE) - { - ans = SearchScreenGridSlop (Crosshair.X, Crosshair.Y, - LINEPOINT_TYPE, &ptr1, &ptr2, &ptr3); - if (ans == NO_TYPE) - hid_action("PointCursor"); - else if (!TEST_FLAG(SELECTEDFLAG, (LineType *)ptr2)) - hid_actionl("PointCursor","True", NULL); - } + if (Settings.Mode == LINE_MODE && Crosshair.AttachedLine.State != STATE_FIRST && TEST_FLAG(AUTODRCFLAG, PCB)) + EnforceLineDRC(); - if (Settings.Mode == LINE_MODE - && Crosshair.AttachedLine.State != STATE_FIRST - && TEST_FLAG (AUTODRCFLAG, PCB)) - EnforceLineDRC (); - - gui->set_crosshair (Crosshair.X, Crosshair.Y, HID_SC_DO_NOTHING); + gui->set_crosshair(Crosshair.X, Crosshair.Y, HID_SC_DO_NOTHING); } /* --------------------------------------------------------------------------- * move crosshair relative (has to be switched off) */ -void -MoveCrosshairRelative (Coord DeltaX, Coord DeltaY) +void MoveCrosshairRelative(Coord DeltaX, Coord DeltaY) { - FitCrosshairIntoGrid (Crosshair.X + DeltaX, Crosshair.Y + DeltaY); + FitCrosshairIntoGrid(Crosshair.X + DeltaX, Crosshair.Y + DeltaY); } /* --------------------------------------------------------------------------- @@ -1303,44 +1104,41 @@ * move crosshair absolute * return true if the crosshair was moved from its existing position */ -bool -MoveCrosshairAbsolute (Coord X, Coord Y) +bool MoveCrosshairAbsolute(Coord X, Coord Y) { - Coord x, y, z; - x = Crosshair.X; - y = Crosshair.Y; - FitCrosshairIntoGrid (X, Y); - if (Crosshair.X != x || Crosshair.Y != y) - { - /* back up to old position to notify the GUI - * (which might want to erase the old crosshair) */ - z = Crosshair.X; - Crosshair.X = x; - x = z; - z = Crosshair.Y; - Crosshair.Y = y; - notify_crosshair_change (false); /* Our caller notifies when it has done */ - /* now move forward again */ - Crosshair.X = x; - Crosshair.Y = z; - return (true); - } - return (false); + Coord x, y, z; + x = Crosshair.X; + y = Crosshair.Y; + FitCrosshairIntoGrid(X, Y); + if (Crosshair.X != x || Crosshair.Y != y) { + /* back up to old position to notify the GUI + * (which might want to erase the old crosshair) */ + z = Crosshair.X; + Crosshair.X = x; + x = z; + z = Crosshair.Y; + Crosshair.Y = y; + notify_crosshair_change(false); /* Our caller notifies when it has done */ + /* now move forward again */ + Crosshair.X = x; + Crosshair.Y = z; + return (true); + } + return (false); } /* --------------------------------------------------------------------------- * sets the valid range for the crosshair cursor */ -void -SetCrosshairRange (Coord MinX, Coord MinY, Coord MaxX, Coord MaxY) +void SetCrosshairRange(Coord MinX, Coord MinY, Coord MaxX, Coord MaxY) { - Crosshair.MinX = MAX (0, MinX); - Crosshair.MinY = MAX (0, MinY); - Crosshair.MaxX = MIN (PCB->MaxWidth, MaxX); - Crosshair.MaxY = MIN (PCB->MaxHeight, MaxY); + Crosshair.MinX = MAX(0, MinX); + Crosshair.MinY = MAX(0, MinY); + Crosshair.MaxX = MIN(PCB->MaxWidth, MaxX); + Crosshair.MaxY = MIN(PCB->MaxHeight, MaxY); - /* force update of position */ - MoveCrosshairRelative (0, 0); + /* force update of position */ + MoveCrosshairRelative(0, 0); } /* --------------------------------------------------------------------------- @@ -1347,38 +1145,36 @@ * initializes crosshair stuff * clears the struct, allocates to graphical contexts */ -void -InitCrosshair (void) +void InitCrosshair(void) { - Crosshair.GC = gui->make_gc (); + Crosshair.GC = gui->make_gc(); - gui->set_color (Crosshair.GC, Settings.CrosshairColor); - gui->set_draw_xor (Crosshair.GC, 1); - gui->set_line_cap (Crosshair.GC, Trace_Cap); - gui->set_line_width (Crosshair.GC, 1); + gui->set_color(Crosshair.GC, Settings.CrosshairColor); + gui->set_draw_xor(Crosshair.GC, 1); + gui->set_line_cap(Crosshair.GC, Trace_Cap); + gui->set_line_width(Crosshair.GC, 1); - /* set initial shape */ - Crosshair.shape = Basic_Crosshair_Shape; + /* set initial shape */ + Crosshair.shape = Basic_Crosshair_Shape; - /* set default limits */ - Crosshair.MinX = Crosshair.MinY = 0; - Crosshair.MaxX = PCB->MaxWidth; - Crosshair.MaxY = PCB->MaxHeight; + /* set default limits */ + Crosshair.MinX = Crosshair.MinY = 0; + Crosshair.MaxX = PCB->MaxWidth; + Crosshair.MaxY = PCB->MaxHeight; - /* Initialize the onpoint data. */ - Crosshair.onpoint_objs = NULL; - Crosshair.onpoint_objs_types = NULL; + /* Initialize the onpoint data. */ + Crosshair.onpoint_objs = NULL; + Crosshair.onpoint_objs_types = NULL; - /* clear the mark */ - Marked.status = false; + /* clear the mark */ + Marked.status = false; } /* --------------------------------------------------------------------------- * exits crosshair routines, release GCs */ -void -DestroyCrosshair (void) +void DestroyCrosshair(void) { - FreePolygonMemory (&Crosshair.AttachedPolygon); - gui->destroy_gc (Crosshair.GC); + FreePolygonMemory(&Crosshair.AttachedPolygon); + gui->destroy_gc(Crosshair.GC); } Index: trunk/src/crosshair.h =================================================================== --- trunk/src/crosshair.h (revision 1021) +++ trunk/src/crosshair.h (revision 1022) @@ -36,22 +36,22 @@ /* --------------------------------------------------------------------------- * all possible states of an attached object */ -#define STATE_FIRST 0 /* initial state */ +#define STATE_FIRST 0 /* initial state */ #define STATE_SECOND 1 #define STATE_THIRD 2 -Coord GridFit (Coord x, Coord grid_spacing, Coord grid_offset); -void notify_crosshair_change (bool changes_complete); -void notify_mark_change (bool changes_complete); -void HideCrosshair (void); -void RestoreCrosshair (void); -void DrawAttached (void); -void DrawMark (void); -void MoveCrosshairRelative (Coord, Coord); -bool MoveCrosshairAbsolute (Coord, Coord); -void SetCrosshairRange (Coord, Coord, Coord, Coord); -void InitCrosshair (void); -void DestroyCrosshair (void); -void FitCrosshairIntoGrid (Coord, Coord); +Coord GridFit(Coord x, Coord grid_spacing, Coord grid_offset); +void notify_crosshair_change(bool changes_complete); +void notify_mark_change(bool changes_complete); +void HideCrosshair(void); +void RestoreCrosshair(void); +void DrawAttached(void); +void DrawMark(void); +void MoveCrosshairRelative(Coord, Coord); +bool MoveCrosshairAbsolute(Coord, Coord); +void SetCrosshairRange(Coord, Coord, Coord, Coord); +void InitCrosshair(void); +void DestroyCrosshair(void); +void FitCrosshairIntoGrid(Coord, Coord); #endif Index: trunk/src/data.c =================================================================== --- trunk/src/data.c (revision 1021) +++ trunk/src/data.c (revision 1022) @@ -36,23 +36,23 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); /* --------------------------------------------------------------------------- * some shared identifiers */ -CrosshairType Crosshair; /* information about cursor settings */ -MarkType Marked; /* a cross-hair mark */ -OutputType Output; /* some widgets ... used for drawing */ -PCBTypePtr PCB; /* pointer to layout struct */ +CrosshairType Crosshair; /* information about cursor settings */ +MarkType Marked; /* a cross-hair mark */ +OutputType Output; /* some widgets ... used for drawing */ +PCBTypePtr PCB; /* pointer to layout struct */ char *Progname; SettingType Settings; -int LayerStack[MAX_LAYER]; /* determines the layer draw order */ +int LayerStack[MAX_LAYER]; /* determines the layer draw order */ BufferType Buffers[MAX_BUFFER]; /* my buffers */ -LibraryType Library; /* the library */ -bool Bumped; /* if the undo serial number has changed */ +LibraryType Library; /* the library */ +bool Bumped; /* if the undo serial number has changed */ int addedLines; Index: trunk/src/dbus-pcbmain.c =================================================================== --- trunk/src/dbus-pcbmain.c (revision 1021) +++ trunk/src/dbus-pcbmain.c (revision 1022) @@ -36,219 +36,199 @@ typedef struct _IOWatchHandler IOWatchHandler; typedef struct _TimeoutHandler TimeoutHandler; -struct _IOWatchHandler -{ - DBusWatch *dbus_watch; - hidval pcb_watch; +struct _IOWatchHandler { + DBusWatch *dbus_watch; + hidval pcb_watch; }; -struct _TimeoutHandler -{ - DBusTimeout *dbus_timeout; - hidval pcb_timer; - int interval; +struct _TimeoutHandler { + DBusTimeout *dbus_timeout; + hidval pcb_timer; + int interval; }; -static void -block_hook_cb (hidval data) +static void block_hook_cb(hidval data) { - DBusConnection *connection = (DBusConnection *) data.ptr; - if (dbus_connection_get_dispatch_status (connection) != - DBUS_DISPATCH_DATA_REMAINS) - return; + DBusConnection *connection = (DBusConnection *) data.ptr; + if (dbus_connection_get_dispatch_status(connection) != DBUS_DISPATCH_DATA_REMAINS) + return; - /* TODO: IS THIS NEEDED? */ - /* dbus_connection_ref (connection); */ + /* TODO: IS THIS NEEDED? */ + /* dbus_connection_ref (connection); */ - /* Only dispatch once - we don't want to starve other mainloop users */ - dbus_connection_dispatch (connection); + /* Only dispatch once - we don't want to starve other mainloop users */ + dbus_connection_dispatch(connection); - /* dbus_connection_unref (connection); */ - return; + /* dbus_connection_unref (connection); */ + return; } -static void -io_watch_handler_dbus_freed (void *data) +static void io_watch_handler_dbus_freed(void *data) { - IOWatchHandler *handler; - handler = (IOWatchHandler *)data; + IOWatchHandler *handler; + handler = (IOWatchHandler *) data; - /* Remove the watch registered with the HID */ - gui->unwatch_file (handler->pcb_watch); - free (handler); + /* Remove the watch registered with the HID */ + gui->unwatch_file(handler->pcb_watch); + free(handler); } -void -io_watch_handler_cb (hidval pcb_watch, - int fd, unsigned int condition, hidval data) +void io_watch_handler_cb(hidval pcb_watch, int fd, unsigned int condition, hidval data) { - IOWatchHandler *handler; - unsigned int dbus_condition = 0; + IOWatchHandler *handler; + unsigned int dbus_condition = 0; - handler = (IOWatchHandler *) data.ptr; + handler = (IOWatchHandler *) data.ptr; - /* TODO: IS THIS NEEDED? */ - /* if (connection) - dbus_connection_ref (connection); */ + /* TODO: IS THIS NEEDED? */ + /* if (connection) + dbus_connection_ref (connection); */ - if (condition & PCB_WATCH_READABLE) - dbus_condition |= DBUS_WATCH_READABLE; - if (condition & PCB_WATCH_WRITABLE) - dbus_condition |= DBUS_WATCH_WRITABLE; - if (condition & PCB_WATCH_ERROR) - dbus_condition |= DBUS_WATCH_ERROR; - if (condition & PCB_WATCH_HANGUP) - dbus_condition |= DBUS_WATCH_HANGUP; + if (condition & PCB_WATCH_READABLE) + dbus_condition |= DBUS_WATCH_READABLE; + if (condition & PCB_WATCH_WRITABLE) + dbus_condition |= DBUS_WATCH_WRITABLE; + if (condition & PCB_WATCH_ERROR) + dbus_condition |= DBUS_WATCH_ERROR; + if (condition & PCB_WATCH_HANGUP) + dbus_condition |= DBUS_WATCH_HANGUP; - /* We don't touch the handler after this, because DBus - * may have disabled the watch and thus killed the handler - */ - dbus_watch_handle (handler->dbus_watch, dbus_condition); - handler = NULL; + /* We don't touch the handler after this, because DBus + * may have disabled the watch and thus killed the handler + */ + dbus_watch_handle(handler->dbus_watch, dbus_condition); + handler = NULL; - /*if (connection) - dbus_connection_unref (connection);*/ + /*if (connection) + dbus_connection_unref (connection); */ - return; + return; } -static void -timeout_handler_dbus_freed (void *data) +static void timeout_handler_dbus_freed(void *data) { - TimeoutHandler *handler; - handler = (TimeoutHandler *)data; + TimeoutHandler *handler; + handler = (TimeoutHandler *) data; - /* Remove the timeout registered with the HID */ - gui->stop_timer (handler->pcb_timer); - free (handler); + /* Remove the timeout registered with the HID */ + gui->stop_timer(handler->pcb_timer); + free(handler); } -void -timeout_handler_cb (hidval data) +void timeout_handler_cb(hidval data) { - TimeoutHandler *handler; - handler = (TimeoutHandler *)data.ptr; + TimeoutHandler *handler; + handler = (TimeoutHandler *) data.ptr; - /* Re-add the timeout, as PCB will remove the current one - Do this before calling to dbus, incase DBus removes the timeout. - We can't touch handler after libdbus has been run for this reason. */ - handler->pcb_timer = - gui->add_timer (timeout_handler_cb, handler->interval, data); + /* Re-add the timeout, as PCB will remove the current one + Do this before calling to dbus, incase DBus removes the timeout. + We can't touch handler after libdbus has been run for this reason. */ + handler->pcb_timer = gui->add_timer(timeout_handler_cb, handler->interval, data); - dbus_timeout_handle (handler->dbus_timeout); + dbus_timeout_handle(handler->dbus_timeout); } -static dbus_bool_t -watch_add (DBusWatch * dbus_watch, void *data) +static dbus_bool_t watch_add(DBusWatch * dbus_watch, void *data) { - IOWatchHandler *handler; - int fd; - unsigned int pcb_condition; - unsigned int dbus_flags; - hidval temp; + IOWatchHandler *handler; + int fd; + unsigned int pcb_condition; + unsigned int dbus_flags; + hidval temp; - /* We won't create a watch until it becomes enabled. */ - if (!dbus_watch_get_enabled (dbus_watch)) - return TRUE; + /* We won't create a watch until it becomes enabled. */ + if (!dbus_watch_get_enabled(dbus_watch)) + return TRUE; - dbus_flags = dbus_watch_get_flags (dbus_watch); + dbus_flags = dbus_watch_get_flags(dbus_watch); - pcb_condition = PCB_WATCH_ERROR | PCB_WATCH_HANGUP; - if (dbus_flags & DBUS_WATCH_READABLE) - pcb_condition |= PCB_WATCH_READABLE; - if (dbus_flags & DBUS_WATCH_WRITABLE) - pcb_condition |= PCB_WATCH_READABLE; + pcb_condition = PCB_WATCH_ERROR | PCB_WATCH_HANGUP; + if (dbus_flags & DBUS_WATCH_READABLE) + pcb_condition |= PCB_WATCH_READABLE; + if (dbus_flags & DBUS_WATCH_WRITABLE) + pcb_condition |= PCB_WATCH_READABLE; #if HAVE_DBUS_WATCH_GET_UNIX_FD - fd = dbus_watch_get_unix_fd (dbus_watch); + fd = dbus_watch_get_unix_fd(dbus_watch); #else - fd = dbus_watch_get_fd (dbus_watch); + fd = dbus_watch_get_fd(dbus_watch); #endif - handler = (IOWatchHandler *)malloc (sizeof (IOWatchHandler)); - temp.ptr = (void *)handler; - handler->dbus_watch = dbus_watch; - handler->pcb_watch = - gui->watch_file (fd, pcb_condition, io_watch_handler_cb, temp); + handler = (IOWatchHandler *) malloc(sizeof(IOWatchHandler)); + temp.ptr = (void *) handler; + handler->dbus_watch = dbus_watch; + handler->pcb_watch = gui->watch_file(fd, pcb_condition, io_watch_handler_cb, temp); - dbus_watch_set_data (dbus_watch, handler, io_watch_handler_dbus_freed); - return TRUE; + dbus_watch_set_data(dbus_watch, handler, io_watch_handler_dbus_freed); + return TRUE; } -static void -watch_remove (DBusWatch * dbus_watch, void *data) +static void watch_remove(DBusWatch * dbus_watch, void *data) { - /* Free the associated data. Its destroy callback removes the watch */ - dbus_watch_set_data (dbus_watch, NULL, NULL); + /* Free the associated data. Its destroy callback removes the watch */ + dbus_watch_set_data(dbus_watch, NULL, NULL); } -static void -watch_toggled (DBusWatch * dbus_watch, void *data) +static void watch_toggled(DBusWatch * dbus_watch, void *data) { - /* Simply add/remove the watch completely */ - if (dbus_watch_get_enabled (dbus_watch)) - watch_add (dbus_watch, data); - else - watch_remove (dbus_watch, data); + /* Simply add/remove the watch completely */ + if (dbus_watch_get_enabled(dbus_watch)) + watch_add(dbus_watch, data); + else + watch_remove(dbus_watch, data); } -static dbus_bool_t -timeout_add (DBusTimeout * timeout, void *data) +static dbus_bool_t timeout_add(DBusTimeout * timeout, void *data) { - TimeoutHandler *handler; - hidval temp; + TimeoutHandler *handler; + hidval temp; - /* We won't create a timeout until it becomes enabled. */ - if (!dbus_timeout_get_enabled (timeout)) - return TRUE; + /* We won't create a timeout until it becomes enabled. */ + if (!dbus_timeout_get_enabled(timeout)) + return TRUE; - /*FIXME: Need to store the interval, as PCB requires us - to manually re-add the timer each time it expires. - This is non-ideal, and hopefully can be changed? */ + /*FIXME: Need to store the interval, as PCB requires us + to manually re-add the timer each time it expires. + This is non-ideal, and hopefully can be changed? */ - handler = (TimeoutHandler *)malloc (sizeof (TimeoutHandler)); - temp.ptr = (void *)handler; - handler->dbus_timeout = timeout; - handler->interval = dbus_timeout_get_interval (timeout); - handler->pcb_timer = - gui->add_timer (timeout_handler_cb, handler->interval, temp); + handler = (TimeoutHandler *) malloc(sizeof(TimeoutHandler)); + temp.ptr = (void *) handler; + handler->dbus_timeout = timeout; + handler->interval = dbus_timeout_get_interval(timeout); + handler->pcb_timer = gui->add_timer(timeout_handler_cb, handler->interval, temp); - dbus_timeout_set_data (timeout, handler, timeout_handler_dbus_freed); - return TRUE; + dbus_timeout_set_data(timeout, handler, timeout_handler_dbus_freed); + return TRUE; } -static void -timeout_remove (DBusTimeout * timeout, void *data) +static void timeout_remove(DBusTimeout * timeout, void *data) { - /* Free the associated data. Its destroy callback removes the timer */ - dbus_timeout_set_data (timeout, NULL, NULL); + /* Free the associated data. Its destroy callback removes the timer */ + dbus_timeout_set_data(timeout, NULL, NULL); } -static void -timeout_toggled (DBusTimeout * timeout, void *data) +static void timeout_toggled(DBusTimeout * timeout, void *data) { - /* Simply add/remove the timeout completely */ - if (dbus_timeout_get_enabled (timeout)) - timeout_add (timeout, data); - else - timeout_remove (timeout, data); + /* Simply add/remove the timeout completely */ + if (dbus_timeout_get_enabled(timeout)) + timeout_add(timeout, data); + else + timeout_remove(timeout, data); } -void -dispatch_status_changed (DBusConnection * conn, DBusDispatchStatus new_status, - void *data) +void dispatch_status_changed(DBusConnection * conn, DBusDispatchStatus new_status, void *data) { - /* TODO: Can use this eventually to add one-shot idle work-functions to dispatch - remaining IO. It could possibly replace the block_hook polling mechanism. - (We could use a one-shot block_book to dispatch the work though.) + /* TODO: Can use this eventually to add one-shot idle work-functions to dispatch + remaining IO. It could possibly replace the block_hook polling mechanism. + (We could use a one-shot block_book to dispatch the work though.) - *** NO DISPATCHING TO BE DONE INSIDE THIS FUNCTION *** */ + *** NO DISPATCHING TO BE DONE INSIDE THIS FUNCTION *** */ } // END INTERNALS @@ -260,81 +240,66 @@ * * @param connection the connection */ -void -pcb_dbus_connection_setup_with_mainloop (DBusConnection * connection) +void pcb_dbus_connection_setup_with_mainloop(DBusConnection * connection) { - /* ConnectionSetup *cs; */ - hidval temp; + /* ConnectionSetup *cs; */ + hidval temp; - /* FIXME we never free the slot, so its refcount just keeps growing, - * which is kind of broken. - */ - /* dbus_connection_allocate_data_slot (&connection_slot); - if (connection_slot < 0) - goto nomem; */ + /* FIXME we never free the slot, so its refcount just keeps growing, + * which is kind of broken. + */ + /* dbus_connection_allocate_data_slot (&connection_slot); + if (connection_slot < 0) + goto nomem; */ #if 0 - cs = connection_setup_new (connection); + cs = connection_setup_new(connection); - if (!dbus_connection_set_data (connection, connection_slot, cs, - (DBusFreeFunction) connection_setup_free)) - goto nomem; + if (!dbus_connection_set_data(connection, connection_slot, cs, (DBusFreeFunction) connection_setup_free)) + goto nomem; #endif - if (!dbus_connection_set_watch_functions (connection, - watch_add, - watch_remove, - watch_toggled, NULL, NULL)) + if (!dbus_connection_set_watch_functions(connection, watch_add, watch_remove, watch_toggled, NULL, NULL)) /* cs, NULL))*/ - goto nomem; + goto nomem; - if (!dbus_connection_set_timeout_functions (connection, - timeout_add, - timeout_remove, - timeout_toggled, NULL, NULL)) + if (!dbus_connection_set_timeout_functions(connection, timeout_add, timeout_remove, timeout_toggled, NULL, NULL)) /* cs, NULL))*/ - goto nomem; + goto nomem; - dbus_connection_set_dispatch_status_function (connection, - dispatch_status_changed, - NULL, NULL); + dbus_connection_set_dispatch_status_function(connection, dispatch_status_changed, NULL, NULL); /* cs, NULL);*/ - /* Register a new mainloop hook to mop up any unfinished IO. */ - temp.ptr = (void *)connection; - gui->add_block_hook (block_hook_cb, temp); + /* Register a new mainloop hook to mop up any unfinished IO. */ + temp.ptr = (void *) connection; + gui->add_block_hook(block_hook_cb, temp); - return; + return; nomem: - fprintf (stderr, - "Not enough memory to set up DBusConnection for use with PCB\n"); + fprintf(stderr, "Not enough memory to set up DBusConnection for use with PCB\n"); } -void -pcb_dbus_connection_finish_with_mainloop (DBusConnection * connection) +void pcb_dbus_connection_finish_with_mainloop(DBusConnection * connection) { - /*ConnectionSetup *cs; + /*ConnectionSetup *cs; - cs = dbus_connection_get_data (connection, connection_slot ); + cs = dbus_connection_get_data (connection, connection_slot ); - Replace the stored data with NULL, thus freeing the old data - DBus will call the function connection_setup_free() which we registered earlier - dbus_connection_set_data (connection, connection_slot, NULL, NULL ); + Replace the stored data with NULL, thus freeing the old data + DBus will call the function connection_setup_free() which we registered earlier + dbus_connection_set_data (connection, connection_slot, NULL, NULL ); - dbus_connection_free_data_slot( &connection_slot );*/ + dbus_connection_free_data_slot( &connection_slot ); */ - if (!dbus_connection_set_watch_functions (connection, - NULL, NULL, NULL, NULL, NULL)) - goto nomem; + if (!dbus_connection_set_watch_functions(connection, NULL, NULL, NULL, NULL, NULL)) + goto nomem; - if (!dbus_connection_set_timeout_functions (connection, - NULL, NULL, NULL, NULL, NULL)) - goto nomem; + if (!dbus_connection_set_timeout_functions(connection, NULL, NULL, NULL, NULL, NULL)) + goto nomem; - dbus_connection_set_dispatch_status_function (connection, NULL, NULL, NULL); - return; + dbus_connection_set_dispatch_status_function(connection, NULL, NULL, NULL); + return; nomem: - fprintf (stderr, - "Not enough memory when cleaning up DBusConnection mainloop integration\n"); + fprintf(stderr, "Not enough memory when cleaning up DBusConnection mainloop integration\n"); } Index: trunk/src/dbus-pcbmain.h =================================================================== --- trunk/src/dbus-pcbmain.h (revision 1021) +++ trunk/src/dbus-pcbmain.h (revision 1022) @@ -23,7 +23,7 @@ #define DBUS_API_SUBJECT_TO_CHANGE #include -void pcb_dbus_connection_setup_with_mainloop (DBusConnection * connection); -void pcb_dbus_connection_finish_with_mainloop (DBusConnection * connection); +void pcb_dbus_connection_setup_with_mainloop(DBusConnection * connection); +void pcb_dbus_connection_finish_with_mainloop(DBusConnection * connection); #endif /* !PCB_DBUS_PCBMAIN_H */ Index: trunk/src/dbus.c =================================================================== --- trunk/src/dbus.c (revision 1021) +++ trunk/src/dbus.c (revision 1022) @@ -44,363 +44,309 @@ static DBusConnection *pcb_dbus_conn; -static DBusHandlerResult -handle_get_filename (DBusConnection * connection, DBusMessage * message, - void *data) +static DBusHandlerResult handle_get_filename(DBusConnection * connection, DBusMessage * message, void *data) { - DBusMessage *reply; - DBusMessageIter iter; - DBusHandlerResult result; - char *filename; + DBusMessage *reply; + DBusMessageIter iter; + DBusHandlerResult result; + char *filename; - result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - /* TODO: Should check the message signature matches what we expect? */ + /* TODO: Should check the message signature matches what we expect? */ - reply = dbus_message_new_method_return (message); - if (reply == NULL) - { - fprintf (stderr, "pcb_dbus: Couldn't create reply message\n"); - return result; - } - dbus_message_iter_init_append (reply, &iter); + reply = dbus_message_new_method_return(message); + if (reply == NULL) { + fprintf(stderr, "pcb_dbus: Couldn't create reply message\n"); + return result; + } + dbus_message_iter_init_append(reply, &iter); - if (PCB->Filename) - filename = lrealpath (PCB->Filename); - else - filename = NULL; + if (PCB->Filename) + filename = lrealpath(PCB->Filename); + else + filename = NULL; - if (filename == NULL) - { + if (filename == NULL) { #ifdef DEBUG - fprintf (stderr, - "pcb_dbus: DEBUG: Couldn't get working filename, assuming none\n"); + fprintf(stderr, "pcb_dbus: DEBUG: Couldn't get working filename, assuming none\n"); #endif - filename = strdup (""); - if (filename == NULL) - { - fprintf (stderr, - "pcb_dbus: Couldn't strdup( \"\" ) for the filename\n"); - goto out; + filename = strdup(""); + if (filename == NULL) { + fprintf(stderr, "pcb_dbus: Couldn't strdup( \"\" ) for the filename\n"); + goto out; + } } - } - if (!dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &filename)) - { - fprintf (stderr, - "pcb_dbus: Couldn't append return filename string to message reply, Out Of Memory!\n"); - free (filename); - goto out; - } - free (filename); - if (!dbus_connection_send (connection, reply, NULL)) - { - fprintf (stderr, "pcb_dbus: Couldn't send message, Out Of Memory!\n"); - goto out; - } - result = DBUS_HANDLER_RESULT_HANDLED; + if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &filename)) { + fprintf(stderr, "pcb_dbus: Couldn't append return filename string to message reply, Out Of Memory!\n"); + free(filename); + goto out; + } + free(filename); + if (!dbus_connection_send(connection, reply, NULL)) { + fprintf(stderr, "pcb_dbus: Couldn't send message, Out Of Memory!\n"); + goto out; + } + result = DBUS_HANDLER_RESULT_HANDLED; out: - dbus_message_unref (reply); - return result; + dbus_message_unref(reply); + return result; } -static DBusHandlerResult -handle_exec_action (DBusConnection * connection, DBusMessage * message, - void *data) +static DBusHandlerResult handle_exec_action(DBusConnection * connection, DBusMessage * message, void *data) { - DBusMessage *reply; - DBusMessageIter iter; - DBusHandlerResult result; - DBusError err; - dbus_uint32_t retval; - char *action_name; - char **argv; - int argc; + DBusMessage *reply; + DBusMessageIter iter; + DBusHandlerResult result; + DBusError err; + dbus_uint32_t retval; + char *action_name; + char **argv; + int argc; #ifdef DEBUG - int i; + int i; #endif - result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - /* TODO: Should check the message signature matches what we expect? */ + /* TODO: Should check the message signature matches what we expect? */ - /* initialise the error struct */ - dbus_error_init (&err); + /* initialise the error struct */ + dbus_error_init(&err); - /* DON'T FREE action_name, as it belongs to DBUS, - * DO FREE argv, using dbus_free_string_array() - */ - argv = NULL; - if (!dbus_message_get_args (message, - &err, - DBUS_TYPE_STRING, &action_name, - DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &argv, &argc, - DBUS_TYPE_INVALID)) - { - fprintf (stderr, "Failed to read method arguments\n"); - if (argv) - dbus_free_string_array (argv); - return result; - } + /* DON'T FREE action_name, as it belongs to DBUS, + * DO FREE argv, using dbus_free_string_array() + */ + argv = NULL; + if (!dbus_message_get_args(message, + &err, + DBUS_TYPE_STRING, &action_name, + DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &argv, &argc, DBUS_TYPE_INVALID)) { + fprintf(stderr, "Failed to read method arguments\n"); + if (argv) + dbus_free_string_array(argv); + return result; + } #ifdef DEBUG - fprintf (stderr, "pcb_dbus: DEBUG: Executing action: %s(", action_name); - if (argc > 0) - fprintf (stderr, " \"%s\"", argv[0]); - for (i = 1; i < argc; i++) - fprintf (stderr, ", \"%s\"", argv[i]); - fprintf (stderr, " )\n"); + fprintf(stderr, "pcb_dbus: DEBUG: Executing action: %s(", action_name); + if (argc > 0) + fprintf(stderr, " \"%s\"", argv[0]); + for (i = 1; i < argc; i++) + fprintf(stderr, ", \"%s\"", argv[i]); + fprintf(stderr, " )\n"); #endif - /* TODO: Proper return value from actions */ - hid_actionv (action_name, argc, argv); - retval = 0; + /* TODO: Proper return value from actions */ + hid_actionv(action_name, argc, argv); + retval = 0; - dbus_free_string_array (argv); + dbus_free_string_array(argv); - reply = dbus_message_new_method_return (message); - if (reply == NULL) - { - fprintf (stderr, "pcb_dbus: Couldn't create reply message\n"); - return result; - } - dbus_message_iter_init_append (reply, &iter); - if (!dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &retval)) - { - fprintf (stderr, "pcb_dbus: Couldn't sent message, Out Of Memory!\n"); - goto out; - } + reply = dbus_message_new_method_return(message); + if (reply == NULL) { + fprintf(stderr, "pcb_dbus: Couldn't create reply message\n"); + return result; + } + dbus_message_iter_init_append(reply, &iter); + if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &retval)) { + fprintf(stderr, "pcb_dbus: Couldn't sent message, Out Of Memory!\n"); + goto out; + } - if (!dbus_connection_send (connection, reply, NULL)) - { - fprintf (stderr, "pcb_dbus: Couldn't send message, Out Of Memory!\n"); - goto out; - } + if (!dbus_connection_send(connection, reply, NULL)) { + fprintf(stderr, "pcb_dbus: Couldn't send message, Out Of Memory!\n"); + goto out; + } - result = DBUS_HANDLER_RESULT_HANDLED; + result = DBUS_HANDLER_RESULT_HANDLED; out: - dbus_message_unref (reply); - return result; + dbus_message_unref(reply); + return result; } -static DBusHandlerResult -handle_introspect (DBusConnection * connection, DBusMessage * message, - void *data) +static DBusHandlerResult handle_introspect(DBusConnection * connection, DBusMessage * message, void *data) { - DBusMessage *reply; - DBusMessageIter iter; - DBusHandlerResult result; + DBusMessage *reply; + DBusMessageIter iter; + DBusHandlerResult result; - result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - reply = dbus_message_new_method_return (message); - if (reply == NULL) - { - fprintf (stderr, "pcb_dbus: Couldn't create reply message\n"); - return result; - } - dbus_message_iter_init_append (reply, &iter); - if (!dbus_message_iter_append_basic - (&iter, DBUS_TYPE_STRING, &pcb_dbus_introspect_xml)) - { - fprintf (stderr, - "pcb_dbus: Couldn't add introspect XML to message return\n"); - goto out; - } - if (!dbus_connection_send (pcb_dbus_conn, reply, NULL)) - { - fprintf (stderr, - "pcb_dbus: Couldn't queue reply message for sending\n"); - goto out; - } - result = DBUS_HANDLER_RESULT_HANDLED; + result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + reply = dbus_message_new_method_return(message); + if (reply == NULL) { + fprintf(stderr, "pcb_dbus: Couldn't create reply message\n"); + return result; + } + dbus_message_iter_init_append(reply, &iter); + if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &pcb_dbus_introspect_xml)) { + fprintf(stderr, "pcb_dbus: Couldn't add introspect XML to message return\n"); + goto out; + } + if (!dbus_connection_send(pcb_dbus_conn, reply, NULL)) { + fprintf(stderr, "pcb_dbus: Couldn't queue reply message for sending\n"); + goto out; + } + result = DBUS_HANDLER_RESULT_HANDLED; out: - dbus_message_unref (reply); - return result; + dbus_message_unref(reply); + return result; } -static void -unregister_dbus_handler (DBusConnection * connection, void *data) +static void unregister_dbus_handler(DBusConnection * connection, void *data) { } -static DBusHandlerResult -handle_dbus_message (DBusConnection * connection, DBusMessage * message, - void *data) +static DBusHandlerResult handle_dbus_message(DBusConnection * connection, DBusMessage * message, void *data) { - int msg_type; - msg_type = dbus_message_get_type (message); + int msg_type; + msg_type = dbus_message_get_type(message); - switch (msg_type) - { - case DBUS_MESSAGE_TYPE_METHOD_CALL: - { - const char *method_name; - const char *interface_name; + switch (msg_type) { + case DBUS_MESSAGE_TYPE_METHOD_CALL: + { + const char *method_name; + const char *interface_name; - method_name = dbus_message_get_member (message); - if (method_name == NULL) - { - fprintf (stderr, "pcb_dbus: Method had no name specified\n"); - break; - } + method_name = dbus_message_get_member(message); + if (method_name == NULL) { + fprintf(stderr, "pcb_dbus: Method had no name specified\n"); + break; + } - interface_name = dbus_message_get_interface (message); - if (interface_name == NULL) - { - fprintf (stderr, "pcb_dbus: Method had no interface specified\n"); - break; - } + interface_name = dbus_message_get_interface(message); + if (interface_name == NULL) { + fprintf(stderr, "pcb_dbus: Method had no interface specified\n"); + break; + } - if (strcmp (interface_name, PCB_DBUS_INTERFACE) == 0) - { - if (strcmp (method_name, "GetFilename") == 0) - { - return handle_get_filename (connection, message, data); - } - fprintf (stderr, "pcb_dbus: Interface '%s' has no method '%s'\n", - interface_name, method_name); - break; - } - else if (strcmp (interface_name, PCB_DBUS_ACTIONS_INTERFACE) == 0) - { - if (strcmp (method_name, "ExecAction") == 0) - { - return handle_exec_action (connection, message, data); - } - fprintf (stderr, "pcb_dbus: Interface '%s' has no method '%s'\n", - interface_name, method_name); - break; - } - else if (strcmp (interface_name, DBUS_INTERFACE_INTROSPECTABLE) == 0) - { - if (strcmp (method_name, "Introspect") == 0) - { - return handle_introspect (connection, message, data); - } - fprintf (stderr, "pcb_dbus: Interface '%s' has no method '%s'\n", - interface_name, method_name); - break; - } - else - { - fprintf (stderr, "pcb_dbus: Interface '%s' was not recognised\n", - interface_name); - break; - } - } - break; + if (strcmp(interface_name, PCB_DBUS_INTERFACE) == 0) { + if (strcmp(method_name, "GetFilename") == 0) { + return handle_get_filename(connection, message, data); + } + fprintf(stderr, "pcb_dbus: Interface '%s' has no method '%s'\n", interface_name, method_name); + break; + } + else if (strcmp(interface_name, PCB_DBUS_ACTIONS_INTERFACE) == 0) { + if (strcmp(method_name, "ExecAction") == 0) { + return handle_exec_action(connection, message, data); + } + fprintf(stderr, "pcb_dbus: Interface '%s' has no method '%s'\n", interface_name, method_name); + break; + } + else if (strcmp(interface_name, DBUS_INTERFACE_INTROSPECTABLE) == 0) { + if (strcmp(method_name, "Introspect") == 0) { + return handle_introspect(connection, message, data); + } + fprintf(stderr, "pcb_dbus: Interface '%s' has no method '%s'\n", interface_name, method_name); + break; + } + else { + fprintf(stderr, "pcb_dbus: Interface '%s' was not recognised\n", interface_name); + break; + } + } + break; - case DBUS_MESSAGE_TYPE_METHOD_RETURN: - fprintf (stderr, "pcb_dbus: DBUG: Method return message\n"); - /* WON'T ACTUALLY BE ANY UNLESS WE MAKE AN ASYNCRONOUS CALL? */ - break; + case DBUS_MESSAGE_TYPE_METHOD_RETURN: + fprintf(stderr, "pcb_dbus: DBUG: Method return message\n"); + /* WON'T ACTUALLY BE ANY UNLESS WE MAKE AN ASYNCRONOUS CALL? */ + break; - case DBUS_MESSAGE_TYPE_ERROR: - fprintf (stderr, "pcb_dbus: DEBUG: Error message\n"); - /* HOPE NOT! */ - break; + case DBUS_MESSAGE_TYPE_ERROR: + fprintf(stderr, "pcb_dbus: DEBUG: Error message\n"); + /* HOPE NOT! */ + break; - case DBUS_MESSAGE_TYPE_SIGNAL: - fprintf (stderr, "pcb_dbus: DEBUG: Signal message\n"); - /* NONE AT PRESENT */ - break; + case DBUS_MESSAGE_TYPE_SIGNAL: + fprintf(stderr, "pcb_dbus: DEBUG: Signal message\n"); + /* NONE AT PRESENT */ + break; - default: - fprintf (stderr, - "pcb_dbus: DEBUG: Message type wasn't one we know about!\n"); - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - } + default: + fprintf(stderr, "pcb_dbus: DEBUG: Message type wasn't one we know about!\n"); + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } -void -pcb_dbus_setup (void) +void pcb_dbus_setup(void) { - DBusError err; - int ret; - const DBusObjectPathVTable object_vtable = { - unregister_dbus_handler, - handle_dbus_message, - NULL, NULL, NULL, NULL - }; + DBusError err; + int ret; + const DBusObjectPathVTable object_vtable = { + unregister_dbus_handler, + handle_dbus_message, + NULL, NULL, NULL, NULL + }; - /* Initialise the error variable */ - dbus_error_init (&err); + /* Initialise the error variable */ + dbus_error_init(&err); - /* Connect to the bus */ - pcb_dbus_conn = dbus_bus_get_private (DBUS_BUS_SESSION, &err); - if (dbus_error_is_set (&err)) - { - fprintf (stderr, "pcb_dbus: DBus connection Error (%s)\n", err.message); - dbus_error_free (&err); - } - if (pcb_dbus_conn == NULL) - return; + /* Connect to the bus */ + pcb_dbus_conn = dbus_bus_get_private(DBUS_BUS_SESSION, &err); + if (dbus_error_is_set(&err)) { + fprintf(stderr, "pcb_dbus: DBus connection Error (%s)\n", err.message); + dbus_error_free(&err); + } + if (pcb_dbus_conn == NULL) + return; - /* Request the canonical name for PCB on the bus */ - ret = dbus_bus_request_name (pcb_dbus_conn, PCB_DBUS_CANONICAL_NAME, - DBUS_NAME_FLAG_REPLACE_EXISTING, &err); - if (dbus_error_is_set (&err)) - { - fprintf (stderr, "pcb_dbus: DBus name error (%s)\n", err.message); - dbus_error_free (&err); - } - if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER - && ret != DBUS_REQUEST_NAME_REPLY_IN_QUEUE) - { - fprintf (stderr, - "pcb_dbus: Couldn't gain ownership or queued ownership of the canonical DBus name\n"); - return; - } + /* Request the canonical name for PCB on the bus */ + ret = dbus_bus_request_name(pcb_dbus_conn, PCB_DBUS_CANONICAL_NAME, DBUS_NAME_FLAG_REPLACE_EXISTING, &err); + if (dbus_error_is_set(&err)) { + fprintf(stderr, "pcb_dbus: DBus name error (%s)\n", err.message); + dbus_error_free(&err); + } + if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER && ret != DBUS_REQUEST_NAME_REPLY_IN_QUEUE) { + fprintf(stderr, "pcb_dbus: Couldn't gain ownership or queued ownership of the canonical DBus name\n"); + return; + } - if (!dbus_connection_register_object_path (pcb_dbus_conn, PCB_DBUS_OBJECT_PATH, &object_vtable, NULL /* void * user_data */ - )) - { - fprintf (stderr, "pcb_dbus: Couldn't register DBUS handler for %s\n", - PCB_DBUS_OBJECT_PATH); - return; - } + if (!dbus_connection_register_object_path(pcb_dbus_conn, PCB_DBUS_OBJECT_PATH, &object_vtable, NULL /* void * user_data */ + )) { + fprintf(stderr, "pcb_dbus: Couldn't register DBUS handler for %s\n", PCB_DBUS_OBJECT_PATH); + return; + } - /* Setup intergration with the pcb mainloop */ - pcb_dbus_connection_setup_with_mainloop (pcb_dbus_conn); + /* Setup intergration with the pcb mainloop */ + pcb_dbus_connection_setup_with_mainloop(pcb_dbus_conn); /* dbus_error_free(&err); */ - return; + return; } -void -pcb_dbus_finish (void) +void pcb_dbus_finish(void) { - DBusError err; + DBusError err; - /* Initialise the error variable */ - dbus_error_init (&err); + /* Initialise the error variable */ + dbus_error_init(&err); - /* TODO: Could emit a "goodbye" signal here? */ + /* TODO: Could emit a "goodbye" signal here? */ - dbus_connection_flush (pcb_dbus_conn); + dbus_connection_flush(pcb_dbus_conn); - dbus_connection_unregister_object_path (pcb_dbus_conn, - PCB_DBUS_OBJECT_PATH); + dbus_connection_unregister_object_path(pcb_dbus_conn, PCB_DBUS_OBJECT_PATH); - dbus_bus_release_name (pcb_dbus_conn, PCB_DBUS_CANONICAL_NAME, &err); + dbus_bus_release_name(pcb_dbus_conn, PCB_DBUS_CANONICAL_NAME, &err); - dbus_error_free (&err); + dbus_error_free(&err); - pcb_dbus_connection_finish_with_mainloop (pcb_dbus_conn); + pcb_dbus_connection_finish_with_mainloop(pcb_dbus_conn); - dbus_connection_close (pcb_dbus_conn); - dbus_connection_unref (pcb_dbus_conn); + dbus_connection_close(pcb_dbus_conn); + dbus_connection_unref(pcb_dbus_conn); - /* Call DBus shutdown. This doesn't work with shared connections, - only private ones (like we took out earlier). - If any future module / plugin to PCB wants to use DBus too, - we must remove this call. DBus will get shut-down when the app exits. */ - dbus_shutdown (); + /* Call DBus shutdown. This doesn't work with shared connections, + only private ones (like we took out earlier). + If any future module / plugin to PCB wants to use DBus too, + we must remove this call. DBus will get shut-down when the app exits. */ + dbus_shutdown(); } Index: trunk/src/dbus.h =================================================================== --- trunk/src/dbus.h (revision 1021) +++ trunk/src/dbus.h (revision 1022) @@ -21,10 +21,10 @@ #define PCB_DBUS_H /* Carry out all actions to setup the D-Bus and register appropriate callbacks */ -void pcb_dbus_setup (); +void pcb_dbus_setup(); /* Carry out all actions to finalise the D-Bus connection */ -void pcb_dbus_finish (); +void pcb_dbus_finish(); #endif /* !PCB_DBUS_H */ Index: trunk/src/djopt.c =================================================================== --- trunk/src/djopt.c (revision 1021) +++ trunk/src/djopt.c (revision 1022) @@ -48,7 +48,7 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); #ifndef HAVE_RINT #define rint(x) (ceil((x) - 0.5)) @@ -79,32 +79,29 @@ struct line_s; -typedef struct corner_s -{ - int layer; - struct corner_s *next; - int x, y; - int net; - PinType *via; - PadType *pad; - PinType *pin; - int miter; - int n_lines; - struct line_s **lines; +typedef struct corner_s { + int layer; + struct corner_s *next; + int x, y; + int net; + PinType *via; + PadType *pad; + PinType *pin; + int miter; + int n_lines; + struct line_s **lines; } corner_s; -typedef struct line_s -{ - int layer; - struct line_s *next; - corner_s *s, *e; - LineType *line; - char is_pad; +typedef struct line_s { + int layer; + struct line_s *next; + corner_s *s, *e; + LineType *line; + char is_pad; } line_s; -typedef struct rect_s -{ - int x1, y1, x2, y2; +typedef struct rect_s { + int x1, y1, x2, y2; } rect_s; #define DELETE(q) (q)->layer = 0xdeadbeef @@ -122,8 +119,7 @@ static const char djopt_sao_syntax[] = "OptAutoOnly()"; -static const char djopt_sao_help[] = - "Toggles the optimize-only-autorouted flag."; +static const char djopt_sao_help[] = "Toggles the optimize-only-autorouted flag."; /* %start-doc actions OptAutoOnly @@ -137,93 +133,84 @@ %end-doc */ -int -djopt_set_auto_only (int argc, char **argv, Coord x, Coord y) +int djopt_set_auto_only(int argc, char **argv, Coord x, Coord y) { - autorouted_only = autorouted_only ? 0 : 1; - return 0; + autorouted_only = autorouted_only ? 0 : 1; + return 0; } -static int -djopt_get_auto_only (int dummy) +static int djopt_get_auto_only(int dummy) { - return autorouted_only; + return autorouted_only; } HID_Flag djopt_flag_list[] = { - {"optautoonly", djopt_get_auto_only, 0} + {"optautoonly", djopt_get_auto_only, 0} }; -REGISTER_FLAGS (djopt_flag_list) +REGISTER_FLAGS(djopt_flag_list) -static char * -element_name_for (corner_s * c) + static char *element_name_for(corner_s * c) { - ELEMENT_LOOP (PCB->Data); - { - PIN_LOOP (element); - { - if (pin == c->pin) - return element->Name[1].TextString; - } - END_LOOP; - PAD_LOOP (element); - { - if (pad == c->pad) - return element->Name[1].TextString; - } - END_LOOP; - } - END_LOOP; - return "unknown"; + ELEMENT_LOOP(PCB->Data); + { + PIN_LOOP(element); + { + if (pin == c->pin) + return element->Name[1].TextString; + } + END_LOOP; + PAD_LOOP(element); + { + if (pad == c->pad) + return element->Name[1].TextString; + } + END_LOOP; + } + END_LOOP; + return "unknown"; } -static char * -corner_name (corner_s * c) +static char *corner_name(corner_s * c) { - static char buf[4][100]; - static int bn = 0; - char *bp; - bn = (bn + 1) % 4; + static char buf[4][100]; + static int bn = 0; + char *bp; + bn = (bn + 1) % 4; - if (c->net == 0xf1eef1ee) - { - sprintf (buf[bn], "\033[31m[%p freed corner]\033[0m", (void *) c); - return buf[bn]; - } + if (c->net == 0xf1eef1ee) { + sprintf(buf[bn], "\033[31m[%p freed corner]\033[0m", (void *) c); + return buf[bn]; + } - sprintf (buf[bn], "\033[%dm[%p ", - (c->pin || c->pad || c->via) ? 33 : 34, (void *) c); - bp = buf[bn] + strlen (buf[bn]); + sprintf(buf[bn], "\033[%dm[%p ", (c->pin || c->pad || c->via) ? 33 : 34, (void *) c); + bp = buf[bn] + strlen(buf[bn]); - if (c->pin) - pcb_sprintf (bp, "pin %s:%s at %#mD", element_name_for (c), c->pin->Number, c->x, c->y); - else if (c->via) - pcb_sprintf (bp, "via at %#mD", c->x, c->y); - else if (c->pad) - { - pcb_sprintf (bp, "pad %s:%s at %#mD %#mD-%#mD", - element_name_for (c), c->pad->Number, c->x, c->y, - c->pad->Point1.X, c->pad->Point1.Y, - c->pad->Point2.X, c->pad->Point2.Y); - } - else - pcb_sprintf (bp, "at %#mD", c->x, c->y); - sprintf (bp + strlen (bp), " n%d l%d]\033[0m", c->n_lines, c->layer); - return buf[bn]; + if (c->pin) + pcb_sprintf(bp, "pin %s:%s at %#mD", element_name_for(c), c->pin->Number, c->x, c->y); + else if (c->via) + pcb_sprintf(bp, "via at %#mD", c->x, c->y); + else if (c->pad) { + pcb_sprintf(bp, "pad %s:%s at %#mD %#mD-%#mD", + element_name_for(c), c->pad->Number, c->x, c->y, + c->pad->Point1.X, c->pad->Point1.Y, c->pad->Point2.X, c->pad->Point2.Y); + } + else + pcb_sprintf(bp, "at %#mD", c->x, c->y); + sprintf(bp + strlen(bp), " n%d l%d]\033[0m", c->n_lines, c->layer); + return buf[bn]; } static int solder_layer, component_layer; -static void -dj_abort (char *msg, ...) +static void dj_abort(char *msg, ...) { - va_list a; - va_start (a, msg); - vprintf (msg, a); - va_end (a); - fflush (stdout); - abort (); + va_list a; + va_start(a, msg); + vprintf(msg, a); + va_end(a); + fflush(stdout); + abort(); } #if 1 @@ -230,62 +217,54 @@ #define check(c,l) #else #define check(c,l) check2(__LINE__,c,l) -static void -check2 (int srcline, corner_s * c, line_s * l) +static void check2(int srcline, corner_s * c, line_s * l) { - int saw_c = 0, saw_l = 0; - corner_s *cc; - line_s *ll; - int i; + int saw_c = 0, saw_l = 0; + corner_s *cc; + line_s *ll; + int i; - for (cc = corners; cc; cc = cc->next) - { - if (DELETED (cc)) - continue; - if (cc == c) - saw_c = 1; - for (i = 0; i < cc->n_lines; i++) - if (cc->lines[i]->s != cc && cc->lines[i]->e != cc) - dj_abort ("check:%d: cc has line without backref\n", srcline); - if (cc->via && (cc->x != cc->via->X || cc->y != cc->via->Y)) - dj_abort ("check:%d: via not at corner\n", srcline); - if (cc->pin && (cc->x != cc->pin->X || cc->y != cc->pin->Y)) - dj_abort ("check:%d: pin not at corner\n", srcline); - } - if (c && !saw_c) - dj_abort ("check:%d: corner not in corners list\n", srcline); - for (ll = lines; ll; ll = ll->next) - { - if (DELETED (ll)) - continue; - if (ll == l) - saw_l = 1; - for (i = 0; i < ll->s->n_lines; i++) - if (ll->s->lines[i] == ll) - break; - if (i == ll->s->n_lines) - dj_abort ("check:%d: ll->s has no backref\n", srcline); - for (i = 0; i < ll->e->n_lines; i++) - if (ll->e->lines[i] == ll) - break; - if (i == ll->e->n_lines) - dj_abort ("check:%d: ll->e has no backref\n", srcline); - if (!ll->is_pad - && (ll->s->x != ll->line->Point1.X - || ll->s->y != ll->line->Point1.Y - || ll->e->x != ll->line->Point2.X - || ll->e->y != ll->line->Point2.Y)) - { - pcb_printf ("line: %#mD to %#mD pcbline: %#mD to %#mD\n", - ll->s->x, ll->s->y, - ll->e->x, ll->e->y, - ll->line->Point1.X, - ll->line->Point1.Y, ll->line->Point2.X, ll->line->Point2.Y); - dj_abort ("check:%d: line doesn't match pcbline\n", srcline); + for (cc = corners; cc; cc = cc->next) { + if (DELETED(cc)) + continue; + if (cc == c) + saw_c = 1; + for (i = 0; i < cc->n_lines; i++) + if (cc->lines[i]->s != cc && cc->lines[i]->e != cc) + dj_abort("check:%d: cc has line without backref\n", srcline); + if (cc->via && (cc->x != cc->via->X || cc->y != cc->via->Y)) + dj_abort("check:%d: via not at corner\n", srcline); + if (cc->pin && (cc->x != cc->pin->X || cc->y != cc->pin->Y)) + dj_abort("check:%d: pin not at corner\n", srcline); } - } - if (l && !saw_l) - dj_abort ("check:%d: line not in lines list\n", srcline); + if (c && !saw_c) + dj_abort("check:%d: corner not in corners list\n", srcline); + for (ll = lines; ll; ll = ll->next) { + if (DELETED(ll)) + continue; + if (ll == l) + saw_l = 1; + for (i = 0; i < ll->s->n_lines; i++) + if (ll->s->lines[i] == ll) + break; + if (i == ll->s->n_lines) + dj_abort("check:%d: ll->s has no backref\n", srcline); + for (i = 0; i < ll->e->n_lines; i++) + if (ll->e->lines[i] == ll) + break; + if (i == ll->e->n_lines) + dj_abort("check:%d: ll->e has no backref\n", srcline); + if (!ll->is_pad + && (ll->s->x != ll->line->Point1.X + || ll->s->y != ll->line->Point1.Y || ll->e->x != ll->line->Point2.X || ll->e->y != ll->line->Point2.Y)) { + pcb_printf("line: %#mD to %#mD pcbline: %#mD to %#mD\n", + ll->s->x, ll->s->y, + ll->e->x, ll->e->y, ll->line->Point1.X, ll->line->Point1.Y, ll->line->Point2.X, ll->line->Point2.Y); + dj_abort("check:%d: line doesn't match pcbline\n", srcline); + } + } + if (l && !saw_l) + dj_abort("check:%d: line not in lines list\n", srcline); } #endif @@ -292,32 +271,28 @@ #define SWAP(a,b) { a^=b; b^=a; a^=b; } -static int -gridsnap (Coord n) +static int gridsnap(Coord n) { - if (n <= 0) - return 0; - return n - n % (Settings.Grid); + if (n <= 0) + return 0; + return n - n % (Settings.Grid); } /* Avoid commonly used names. */ -static int -djabs (int x) +static int djabs(int x) { - return x > 0 ? x : -x; + return x > 0 ? x : -x; } -static int -djmax (int x, int y) +static int djmax(int x, int y) { - return x > y ? x : y; + return x > y ? x : y; } -static int -djmin (int x, int y) +static int djmin(int x, int y) { - return x < y ? x : y; + return x < y ? x : y; } /* @@ -325,1087 +300,953 @@ * because we can fairly easily overflow a 32 bit integer here. In * fact it only takes 0.46" to do so. */ -static int -dist (int x1, int y1, int x2, int y2) +static int dist(int x1, int y1, int x2, int y2) { - double dx1, dy1, dx2, dy2, d; + double dx1, dy1, dx2, dy2, d; - dx1 = (double) x1; - dy1 = (double) y1; - dx2 = (double) x2; - dy2 = (double) y2; + dx1 = (double) x1; + dy1 = (double) y1; + dx2 = (double) x2; + dy2 = (double) y2; - d = sqrt ((dx1 - dx2) * (dx1 - dx2) + (dy1 - dy2) * (dy1 - dy2)); - d = rint (d); + d = sqrt((dx1 - dx2) * (dx1 - dx2) + (dy1 - dy2) * (dy1 - dy2)); + d = rint(d); - return (int) d; + return (int) d; } -static int -line_length (line_s * l) +static int line_length(line_s * l) { - if (l->s->x == l->e->x) - return djabs (l->s->y - l->e->y); - if (l->s->y == l->e->y) - return djabs (l->s->x - l->e->x); - return dist (l->s->x, l->s->y, l->e->x, l->e->y); + if (l->s->x == l->e->x) + return djabs(l->s->y - l->e->y); + if (l->s->y == l->e->y) + return djabs(l->s->x - l->e->x); + return dist(l->s->x, l->s->y, l->e->x, l->e->y); } -static int -dist_ltp2 (int dx, int y, int y1, int y2) +static int dist_ltp2(int dx, int y, int y1, int y2) { - if (y1 > y2) - SWAP (y1, y2); - if (y < y1) - return dist (dx, y, 0, y1); - if (y > y2) - return dist (dx, y, 0, y2); - return djabs (dx); + if (y1 > y2) + SWAP(y1, y2); + if (y < y1) + return dist(dx, y, 0, y1); + if (y > y2) + return dist(dx, y, 0, y2); + return djabs(dx); } -int -sqr (int a) +int sqr(int a) { - return a * a; + return a * a; } -static int -intersecting_layers (int l1, int l2) +static int intersecting_layers(int l1, int l2) { - if (l1 == -1 || l2 == -1) - return 1; - if (l1 == l2) - return 1; - if (layer_groupings[l1] == layer_groupings[l2]) - return 1; - return 0; + if (l1 == -1 || l2 == -1) + return 1; + if (l1 == l2) + return 1; + if (layer_groupings[l1] == layer_groupings[l2]) + return 1; + return 0; } -static int -dist_line_to_point (line_s * l, corner_s * c) +static int dist_line_to_point(line_s * l, corner_s * c) { - double len, r, d; - /* We can do this quickly if l is vertical or horizontal. */ - if (l->s->x == l->e->x) - return dist_ltp2 (l->s->x - c->x, c->y, l->s->y, l->e->y); - if (l->s->y == l->e->y) - return dist_ltp2 (l->s->y - c->y, c->x, l->s->x, l->e->x); + double len, r, d; + /* We can do this quickly if l is vertical or horizontal. */ + if (l->s->x == l->e->x) + return dist_ltp2(l->s->x - c->x, c->y, l->s->y, l->e->y); + if (l->s->y == l->e->y) + return dist_ltp2(l->s->y - c->y, c->x, l->s->x, l->e->x); - /* Do it the hard way. See comments for IsPointOnLine() in search.c */ - len = sqrt (sqr (l->s->x - l->e->x) + sqr (l->s->y - l->e->y)); - if (len == 0) - return dist (l->s->x, l->s->y, c->x, c->y); - r = - (l->s->y - c->y) * (l->s->y - l->e->y) + (l->s->x - c->x) * (l->s->x - - l->e->x); - r /= len * len; - if (r < 0) - return dist (l->s->x, l->s->y, c->x, c->y); - if (r > 1) - return dist (l->e->x, l->e->y, c->x, c->y); - d = - (l->e->y - l->s->y) * (c->x * l->s->x) + (l->e->x - l->s->x) * (c->y - - l->s->y); - return (int) (d / len); + /* Do it the hard way. See comments for IsPointOnLine() in search.c */ + len = sqrt(sqr(l->s->x - l->e->x) + sqr(l->s->y - l->e->y)); + if (len == 0) + return dist(l->s->x, l->s->y, c->x, c->y); + r = (l->s->y - c->y) * (l->s->y - l->e->y) + (l->s->x - c->x) * (l->s->x - l->e->x); + r /= len * len; + if (r < 0) + return dist(l->s->x, l->s->y, c->x, c->y); + if (r > 1) + return dist(l->e->x, l->e->y, c->x, c->y); + d = (l->e->y - l->s->y) * (c->x * l->s->x) + (l->e->x - l->s->x) * (c->y - l->s->y); + return (int) (d / len); } -static int -line_orient (line_s * l, corner_s * c) +static int line_orient(line_s * l, corner_s * c) { - int x1, y1, x2, y2; - if (c == l->s) - { - x1 = l->s->x; - y1 = l->s->y; - x2 = l->e->x; - y2 = l->e->y; - } - else - { - x1 = l->e->x; - y1 = l->e->y; - x2 = l->s->x; - y2 = l->s->y; - } - if (x1 == x2) - { - if (y1 < y2) - return DOWN; - return UP; - } - else if (y1 == y2) - { - if (x1 < x2) - return RIGHT; - return LEFT; - } - return DIAGONAL; + int x1, y1, x2, y2; + if (c == l->s) { + x1 = l->s->x; + y1 = l->s->y; + x2 = l->e->x; + y2 = l->e->y; + } + else { + x1 = l->e->x; + y1 = l->e->y; + x2 = l->s->x; + y2 = l->s->y; + } + if (x1 == x2) { + if (y1 < y2) + return DOWN; + return UP; + } + else if (y1 == y2) { + if (x1 < x2) + return RIGHT; + return LEFT; + } + return DIAGONAL; } #if 0 /* Not used */ -static corner_s * -common_corner (line_s * l1, line_s * l2) +static corner_s *common_corner(line_s * l1, line_s * l2) { - if (l1->s == l2->s || l1->s == l2->e) - return l1->s; - if (l1->e == l2->s || l1->e == l2->e) - return l1->e; - dj_abort ("common_corner: no common corner found\n"); - return NULL; + if (l1->s == l2->s || l1->s == l2->e) + return l1->s; + if (l1->e == l2->s || l1->e == l2->e) + return l1->e; + dj_abort("common_corner: no common corner found\n"); + return NULL; } #endif -static corner_s * -other_corner (line_s * l, corner_s * c) +static corner_s *other_corner(line_s * l, corner_s * c) { - if (l->s == c) - return l->e; - if (l->e == c) - return l->s; - dj_abort ("other_corner: neither corner passed\n"); - return NULL; + if (l->s == c) + return l->e; + if (l->e == c) + return l->s; + dj_abort("other_corner: neither corner passed\n"); + return NULL; } -static corner_s * -find_corner_if (int x, int y, int l) +static corner_s *find_corner_if(int x, int y, int l) { - corner_s *c; - for (c = corners; c; c = c->next) - { - if (DELETED (c)) - continue; - if (c->x != x || c->y != y) - continue; - if (!(c->layer == -1 || intersecting_layers (c->layer, l))) - continue; - return c; - } - return 0; + corner_s *c; + for (c = corners; c; c = c->next) { + if (DELETED(c)) + continue; + if (c->x != x || c->y != y) + continue; + if (!(c->layer == -1 || intersecting_layers(c->layer, l))) + continue; + return c; + } + return 0; } -static corner_s * -find_corner (int x, int y, int l) +static corner_s *find_corner(int x, int y, int l) { - corner_s *c; - for (c = corners; c; c = c->next) - { - if (DELETED (c)) - continue; - if (c->x != x || c->y != y) - continue; - if (!(c->layer == -1 || intersecting_layers (c->layer, l))) - continue; - return c; - } - c = (corner_s *) malloc (sizeof (corner_s)); - c->next = corners; - corners = c; - c->x = x; - c->y = y; - c->net = 0; - c->via = 0; - c->pad = 0; - c->pin = 0; - c->layer = l; - c->n_lines = 0; - c->lines = (line_s **) malloc (INC * sizeof (line_s *)); - return c; + corner_s *c; + for (c = corners; c; c = c->next) { + if (DELETED(c)) + continue; + if (c->x != x || c->y != y) + continue; + if (!(c->layer == -1 || intersecting_layers(c->layer, l))) + continue; + return c; + } + c = (corner_s *) malloc(sizeof(corner_s)); + c->next = corners; + corners = c; + c->x = x; + c->y = y; + c->net = 0; + c->via = 0; + c->pad = 0; + c->pin = 0; + c->layer = l; + c->n_lines = 0; + c->lines = (line_s **) malloc(INC * sizeof(line_s *)); + return c; } -static void -add_line_to_corner (line_s * l, corner_s * c) +static void add_line_to_corner(line_s * l, corner_s * c) { - int n; - n = (c->n_lines + 1 + INC) & ~INC; - c->lines = (line_s **) realloc (c->lines, n * sizeof (line_s *)); - c->lines[c->n_lines] = l; - c->n_lines++; - dprintf ("add_line_to_corner %#mD\n", c->x, c->y); + int n; + n = (c->n_lines + 1 + INC) & ~INC; + c->lines = (line_s **) realloc(c->lines, n * sizeof(line_s *)); + c->lines[c->n_lines] = l; + c->n_lines++; + dprintf("add_line_to_corner %#mD\n", c->x, c->y); } -static LineType * -create_pcb_line (int layer, int x1, int y1, int x2, int y2, - int thick, int clear, FlagType flags) +static LineType *create_pcb_line(int layer, int x1, int y1, int x2, int y2, int thick, int clear, FlagType flags) { - char *from, *to; - LineType *nl; - LayerType *lyr = LAYER_PTR (layer); + char *from, *to; + LineType *nl; + LayerType *lyr = LAYER_PTR(layer); - from = (char *) lyr->Line; - nl = CreateNewLineOnLayer (PCB->Data->Layer + layer, - x1, y1, x2, y2, thick, clear, flags); - AddObjectToCreateUndoList (LINE_TYPE, lyr, nl, nl); + from = (char *) lyr->Line; + nl = CreateNewLineOnLayer(PCB->Data->Layer + layer, x1, y1, x2, y2, thick, clear, flags); + AddObjectToCreateUndoList(LINE_TYPE, lyr, nl, nl); - to = (char *) lyr->Line; - if (from != to) - { - line_s *lp; - for (lp = lines; lp; lp = lp->next) - { - if (DELETED (lp)) - continue; - if ((char *) (lp->line) >= from - && (char *) (lp->line) <= from + lyr->LineN * sizeof (LineType)) - lp->line = (LineType *) ((char *) (lp->line) + (to - from)); + to = (char *) lyr->Line; + if (from != to) { + line_s *lp; + for (lp = lines; lp; lp = lp->next) { + if (DELETED(lp)) + continue; + if ((char *) (lp->line) >= from && (char *) (lp->line) <= from + lyr->LineN * sizeof(LineType)) + lp->line = (LineType *) ((char *) (lp->line) + (to - from)); + } } - } - return nl; + return nl; } -static void -new_line (corner_s * s, corner_s * e, int layer, LineType * example) +static void new_line(corner_s * s, corner_s * e, int layer, LineType * example) { - line_s *ls; + line_s *ls; - if (layer >= max_copper_layer) - dj_abort ("layer %d\n", layer); + if (layer >= max_copper_layer) + dj_abort("layer %d\n", layer); - if (example == NULL) - dj_abort ("NULL example passed to new_line()\n", layer); + if (example == NULL) + dj_abort("NULL example passed to new_line()\n", layer); - if (s->x == e->x && s->y == e->y) - return; + if (s->x == e->x && s->y == e->y) + return; - ls = (line_s *) malloc (sizeof (line_s)); - ls->next = lines; - lines = ls; - ls->is_pad = 0; - ls->s = s; - ls->e = e; - ls->layer = layer; + ls = (line_s *) malloc(sizeof(line_s)); + ls->next = lines; + lines = ls; + ls->is_pad = 0; + ls->s = s; + ls->e = e; + ls->layer = layer; #if 0 - if ((example->Point1.X == s->x && example->Point1.Y == s->y - && example->Point2.X == e->x && example->Point2.Y == e->y) - || (example->Point2.X == s->x && example->Point2.Y == s->y - && example->Point1.X == e->x && example->Point1.Y == e->y)) - { - ls->line = example; - } - else + if ((example->Point1.X == s->x && example->Point1.Y == s->y && example->Point2.X == e->x && example->Point2.Y == e->y) + || (example->Point2.X == s->x && example->Point2.Y == s->y && example->Point1.X == e->x && example->Point1.Y == e->y)) { + ls->line = example; + } + else #endif - { - LineType *nl; - dprintf - ("New line \033[35m%#mD to %#mD from l%d t%#mS c%#mS f%s\033[0m\n", - s->x, s->y, e->x, e->y, layer, example->Thickness, - example->Clearance, flags_to_string (example->Flags, LINE_TYPE)); - nl = - create_pcb_line (layer, s->x, s->y, e->x, e->y, example->Thickness, - example->Clearance, example->Flags); + { + LineType *nl; + dprintf + ("New line \033[35m%#mD to %#mD from l%d t%#mS c%#mS f%s\033[0m\n", + s->x, s->y, e->x, e->y, layer, example->Thickness, example->Clearance, flags_to_string(example->Flags, LINE_TYPE)); + nl = create_pcb_line(layer, s->x, s->y, e->x, e->y, example->Thickness, example->Clearance, example->Flags); - if (!nl) - dj_abort ("can't create new line!"); - ls->line = nl; - } - add_line_to_corner (ls, s); - add_line_to_corner (ls, e); - check (s, ls); - check (e, ls); + if (!nl) + dj_abort("can't create new line!"); + ls->line = nl; + } + add_line_to_corner(ls, s); + add_line_to_corner(ls, e); + check(s, ls); + check(e, ls); } #if 0 /* Not used */ -static int -c_orth_to (corner_s * c, line_s * l, int o) +static int c_orth_to(corner_s * c, line_s * l, int o) { - int i, o2; - int rv = 0; - for (i = 0; i < c->n_lines; i++) - { - if (c->lines[i] == l) - continue; - o2 = line_orient (c->lines[i], c); - if (ORIENT (o) == ORIENT (o2) || o2 == DIAGONAL) - return 0; - rv++; - } - return rv; + int i, o2; + int rv = 0; + for (i = 0; i < c->n_lines; i++) { + if (c->lines[i] == l) + continue; + o2 = line_orient(c->lines[i], c); + if (ORIENT(o) == ORIENT(o2) || o2 == DIAGONAL) + return 0; + rv++; + } + return rv; } #endif -static line_s * -other_line (corner_s * c, line_s * l) +static line_s *other_line(corner_s * c, line_s * l) { - int i; - line_s *rv = 0; - if (c->pin || c->pad || c->via) - return 0; - for (i = 0; i < c->n_lines; i++) - { - if (c->lines[i] == l) - continue; - if (rv) - return 0; - rv = c->lines[i]; - } - return rv; + int i; + line_s *rv = 0; + if (c->pin || c->pad || c->via) + return 0; + for (i = 0; i < c->n_lines; i++) { + if (c->lines[i] == l) + continue; + if (rv) + return 0; + rv = c->lines[i]; + } + return rv; } -static void -empty_rect (rect_s * rect) +static void empty_rect(rect_s * rect) { - rect->x1 = rect->y1 = INT_MAX; - rect->x2 = rect->y2 = INT_MIN; + rect->x1 = rect->y1 = INT_MAX; + rect->x2 = rect->y2 = INT_MIN; } -static void -add_point_to_rect (rect_s * rect, int x, int y, int w) +static void add_point_to_rect(rect_s * rect, int x, int y, int w) { - if (rect->x1 > x - w) - rect->x1 = x - w; - if (rect->x2 < x + w) - rect->x2 = x + w; - if (rect->y1 > y - w) - rect->y1 = y - w; - if (rect->y2 < y + w) - rect->y2 = y + w; + if (rect->x1 > x - w) + rect->x1 = x - w; + if (rect->x2 < x + w) + rect->x2 = x + w; + if (rect->y1 > y - w) + rect->y1 = y - w; + if (rect->y2 < y + w) + rect->y2 = y + w; } -static void -add_line_to_rect (rect_s * rect, line_s * l) +static void add_line_to_rect(rect_s * rect, line_s * l) { - add_point_to_rect (rect, l->s->x, l->s->y, 0); - add_point_to_rect (rect, l->e->x, l->e->y, 0); + add_point_to_rect(rect, l->s->x, l->s->y, 0); + add_point_to_rect(rect, l->e->x, l->e->y, 0); } -static int -pin_in_rect (rect_s * r, int x, int y, int w) +static int pin_in_rect(rect_s * r, int x, int y, int w) { - if (x < r->x1 && x + w < r->x1) - return 0; - if (x > r->x2 && x - w > r->x2) - return 0; - if (y < r->y1 && y + w < r->y1) - return 0; - if (y > r->y2 && y - w > r->y2) - return 0; - return 1; + if (x < r->x1 && x + w < r->x1) + return 0; + if (x > r->x2 && x - w > r->x2) + return 0; + if (y < r->y1 && y + w < r->y1) + return 0; + if (y > r->y2 && y - w > r->y2) + return 0; + return 1; } -static int -line_in_rect (rect_s * r, line_s * l) +static int line_in_rect(rect_s * r, line_s * l) { - rect_s lr; - empty_rect (&lr); - add_point_to_rect (&lr, l->s->x, l->s->y, l->line->Thickness / 2); - add_point_to_rect (&lr, l->e->x, l->e->y, l->line->Thickness / 2); - dprintf ("line_in_rect %#mD-%#mD vs %#mD-%#mD\n", - r->x1, r->y1, r->x2, r->y2, lr.x1, lr.y1, lr.x2, lr.y2); - /* simple intersection of rectangles */ - if (lr.x1 < r->x1) - lr.x1 = r->x1; - if (lr.x2 > r->x2) - lr.x2 = r->x2; - if (lr.y1 < r->y1) - lr.y1 = r->y1; - if (lr.y2 > r->y2) - lr.y2 = r->y2; - if (lr.x1 < lr.x2 && lr.y1 < lr.y2) - return 1; - return 0; + rect_s lr; + empty_rect(&lr); + add_point_to_rect(&lr, l->s->x, l->s->y, l->line->Thickness / 2); + add_point_to_rect(&lr, l->e->x, l->e->y, l->line->Thickness / 2); + dprintf("line_in_rect %#mD-%#mD vs %#mD-%#mD\n", r->x1, r->y1, r->x2, r->y2, lr.x1, lr.y1, lr.x2, lr.y2); + /* simple intersection of rectangles */ + if (lr.x1 < r->x1) + lr.x1 = r->x1; + if (lr.x2 > r->x2) + lr.x2 = r->x2; + if (lr.y1 < r->y1) + lr.y1 = r->y1; + if (lr.y2 > r->y2) + lr.y2 = r->y2; + if (lr.x1 < lr.x2 && lr.y1 < lr.y2) + return 1; + return 0; } -static int -corner_radius (corner_s * c) +static int corner_radius(corner_s * c) { - int diam = 0; - int i; - if (c->pin) - diam = djmax (c->pin->Thickness, diam); - if (c->via) - diam = djmax (c->via->Thickness, diam); - for (i = 0; i < c->n_lines; i++) - if (c->lines[i]->line) - diam = djmax (c->lines[i]->line->Thickness, diam); - diam = (diam + 1) / 2; - return diam; + int diam = 0; + int i; + if (c->pin) + diam = djmax(c->pin->Thickness, diam); + if (c->via) + diam = djmax(c->via->Thickness, diam); + for (i = 0; i < c->n_lines; i++) + if (c->lines[i]->line) + diam = djmax(c->lines[i]->line->Thickness, diam); + diam = (diam + 1) / 2; + return diam; } #if 0 /* Not used */ -static int -corner_layer (corner_s * c) +static int corner_layer(corner_s * c) { - if (c->pin || c->via) - return -1; - if (c->n_lines < 1) - return -1; - return c->lines[0]->layer; + if (c->pin || c->via) + return -1; + if (c->n_lines < 1) + return -1; + return c->lines[0]->layer; } #endif -static void -add_corner_to_rect_if (rect_s * rect, corner_s * c, rect_s * e) +static void add_corner_to_rect_if(rect_s * rect, corner_s * c, rect_s * e) { - int diam = corner_radius (c); - if (!pin_in_rect (e, c->x, c->y, diam)) - return; - if (c->x < e->x1 && c->y < e->y1 && dist (c->x, c->y, e->x1, e->y1) > diam) - return; - if (c->x > e->x2 && c->y < e->y1 && dist (c->x, c->y, e->x2, e->y1) > diam) - return; - if (c->x < e->x1 && c->y > e->y2 && dist (c->x, c->y, e->x1, e->y2) > diam) - return; - if (c->x > e->x2 && c->y > e->y2 && dist (c->x, c->y, e->x2, e->y2) > diam) - return; + int diam = corner_radius(c); + if (!pin_in_rect(e, c->x, c->y, diam)) + return; + if (c->x < e->x1 && c->y < e->y1 && dist(c->x, c->y, e->x1, e->y1) > diam) + return; + if (c->x > e->x2 && c->y < e->y1 && dist(c->x, c->y, e->x2, e->y1) > diam) + return; + if (c->x < e->x1 && c->y > e->y2 && dist(c->x, c->y, e->x1, e->y2) > diam) + return; + if (c->x > e->x2 && c->y > e->y2 && dist(c->x, c->y, e->x2, e->y2) > diam) + return; - /*pcb_printf("add point %#mD diam %#mS\n", c->x, c->y, diam); */ - add_point_to_rect (rect, c->x, c->y, diam); + /*pcb_printf("add point %#mD diam %#mS\n", c->x, c->y, diam); */ + add_point_to_rect(rect, c->x, c->y, diam); } -static void -remove_line (line_s * l) +static void remove_line(line_s * l) { - int i, j; - LayerType *layer = &(PCB->Data->Layer[l->layer]); + int i, j; + LayerType *layer = &(PCB->Data->Layer[l->layer]); - check (0, 0); + check(0, 0); - if (l->line) - RemoveLine (layer, l->line); + if (l->line) + RemoveLine(layer, l->line); - DELETE (l); + DELETE(l); - for (i = 0, j = 0; i < l->s->n_lines; i++) - if (l->s->lines[i] != l) - l->s->lines[j++] = l->s->lines[i]; - l->s->n_lines = j; + for (i = 0, j = 0; i < l->s->n_lines; i++) + if (l->s->lines[i] != l) + l->s->lines[j++] = l->s->lines[i]; + l->s->n_lines = j; - for (i = 0, j = 0; i < l->e->n_lines; i++) - if (l->e->lines[i] != l) - l->e->lines[j++] = l->e->lines[i]; - l->e->n_lines = j; - check (0, 0); + for (i = 0, j = 0; i < l->e->n_lines; i++) + if (l->e->lines[i] != l) + l->e->lines[j++] = l->e->lines[i]; + l->e->n_lines = j; + check(0, 0); } -static void -move_line_to_layer (line_s * l, int layer) +static void move_line_to_layer(line_s * l, int layer) { - LayerType *ls, *ld; + LayerType *ls, *ld; - ls = LAYER_PTR (l->layer); - ld = LAYER_PTR (layer); + ls = LAYER_PTR(l->layer); + ld = LAYER_PTR(layer); - MoveObjectToLayer (LINE_TYPE, ls, l->line, 0, ld, 0); - l->layer = layer; + MoveObjectToLayer(LINE_TYPE, ls, l->line, 0, ld, 0); + l->layer = layer; } -static void -remove_via_at (corner_s * c) +static void remove_via_at(corner_s * c) { - RemoveObject (VIA_TYPE, c->via, 0, 0); - c->via = 0; + RemoveObject(VIA_TYPE, c->via, 0, 0); + c->via = 0; } -static void -remove_corner (corner_s * c2) +static void remove_corner(corner_s * c2) { - corner_s *c; - dprintf ("remove corner %s\n", corner_name (c2)); - if (corners == c2) - corners = c2->next; - for (c = corners; c; c = c->next) - { - if (DELETED (c)) - continue; - if (c->next == c2) - c->next = c2->next; - } - if (next_corner == c2) - next_corner = c2->next; - free (c2->lines); - c2->lines = 0; - DELETE (c2); + corner_s *c; + dprintf("remove corner %s\n", corner_name(c2)); + if (corners == c2) + corners = c2->next; + for (c = corners; c; c = c->next) { + if (DELETED(c)) + continue; + if (c->next == c2) + c->next = c2->next; + } + if (next_corner == c2) + next_corner = c2->next; + free(c2->lines); + c2->lines = 0; + DELETE(c2); } -static void -merge_corners (corner_s * c1, corner_s * c2) +static void merge_corners(corner_s * c1, corner_s * c2) { - int i; - if (c1 == c2) - abort (); - dprintf ("merge corners %s %s\n", corner_name (c1), corner_name (c2)); - for (i = 0; i < c2->n_lines; i++) - { - add_line_to_corner (c2->lines[i], c1); - if (c2->lines[i]->s == c2) - c2->lines[i]->s = c1; - if (c2->lines[i]->e == c2) - c2->lines[i]->e = c1; - } - if (c1->via && c2->via) - remove_via_at (c2); - else if (c2->via) - c1->via = c2->via; - if (c2->pad) - c1->pad = c2->pad; - if (c2->pin) - c1->pin = c2->pin; - if (c2->layer != c1->layer) - c1->layer = -1; + int i; + if (c1 == c2) + abort(); + dprintf("merge corners %s %s\n", corner_name(c1), corner_name(c2)); + for (i = 0; i < c2->n_lines; i++) { + add_line_to_corner(c2->lines[i], c1); + if (c2->lines[i]->s == c2) + c2->lines[i]->s = c1; + if (c2->lines[i]->e == c2) + c2->lines[i]->e = c1; + } + if (c1->via && c2->via) + remove_via_at(c2); + else if (c2->via) + c1->via = c2->via; + if (c2->pad) + c1->pad = c2->pad; + if (c2->pin) + c1->pin = c2->pin; + if (c2->layer != c1->layer) + c1->layer = -1; - remove_corner (c2); + remove_corner(c2); } -static void -move_corner (corner_s * c, int x, int y) +static void move_corner(corner_s * c, int x, int y) { - PinType *via; - int i; - corner_s *pad; + PinType *via; + int i; + corner_s *pad; - check (c, 0); - if (c->pad || c->pin) - dj_abort ("move_corner: has pin or pad\n"); - dprintf ("move_corner %p from %#mD to %#mD\n", (void *) c, c->x, c->y, x, y); - pad = find_corner_if (x, y, c->layer); - c->x = x; - c->y = y; - via = c->via; - if (via) - { - MoveObject (VIA_TYPE, via, via, via, x - via->X, y - via->Y); - dprintf ("via move %#mD to %#mD\n", via->X, via->Y, x, y); - } - for (i = 0; i < c->n_lines; i++) - { - LineTypePtr tl = c->lines[i]->line; - if (tl) - { - if (c->lines[i]->s == c) - { - MoveObject (LINEPOINT_TYPE, LAYER_PTR (c->lines[i]->layer), tl, - &tl->Point1, x - (tl->Point1.X), - y - (tl->Point1.Y)); - } - else - { - MoveObject (LINEPOINT_TYPE, LAYER_PTR (c->lines[i]->layer), tl, - &tl->Point2, x - (tl->Point2.X), - y - (tl->Point2.Y)); - } - dprintf ("Line %p moved to %#mD %#mD\n", (void *) tl, - tl->Point1.X, tl->Point1.Y, tl->Point2.X, tl->Point2.Y); + check(c, 0); + if (c->pad || c->pin) + dj_abort("move_corner: has pin or pad\n"); + dprintf("move_corner %p from %#mD to %#mD\n", (void *) c, c->x, c->y, x, y); + pad = find_corner_if(x, y, c->layer); + c->x = x; + c->y = y; + via = c->via; + if (via) { + MoveObject(VIA_TYPE, via, via, via, x - via->X, y - via->Y); + dprintf("via move %#mD to %#mD\n", via->X, via->Y, x, y); } - } - if (pad && pad != c) - merge_corners (c, pad); - else - for (i = 0; i < c->n_lines; i++) - { - if (c->lines[i]->s->x == c->lines[i]->e->x - && c->lines[i]->s->y == c->lines[i]->e->y) - { - corner_s *c2 = other_corner (c->lines[i], c); - dprintf ("move_corner: removing line %#mD %#mD %p %p\n", - c->x, c->y, c2->x, c2->y, (void *) c, (void *) c2); + for (i = 0; i < c->n_lines; i++) { + LineTypePtr tl = c->lines[i]->line; + if (tl) { + if (c->lines[i]->s == c) { + MoveObject(LINEPOINT_TYPE, LAYER_PTR(c->lines[i]->layer), tl, &tl->Point1, x - (tl->Point1.X), y - (tl->Point1.Y)); + } + else { + MoveObject(LINEPOINT_TYPE, LAYER_PTR(c->lines[i]->layer), tl, &tl->Point2, x - (tl->Point2.X), y - (tl->Point2.Y)); + } + dprintf("Line %p moved to %#mD %#mD\n", (void *) tl, tl->Point1.X, tl->Point1.Y, tl->Point2.X, tl->Point2.Y); + } + } + if (pad && pad != c) + merge_corners(c, pad); + else + for (i = 0; i < c->n_lines; i++) { + if (c->lines[i]->s->x == c->lines[i]->e->x && c->lines[i]->s->y == c->lines[i]->e->y) { + corner_s *c2 = other_corner(c->lines[i], c); + dprintf("move_corner: removing line %#mD %#mD %p %p\n", c->x, c->y, c2->x, c2->y, (void *) c, (void *) c2); - remove_line (c->lines[i]); - if (c != c2) - merge_corners (c, c2); - check (c, 0); - i--; - break; - } - } - gui->progress (0, 0, 0); - check (c, 0); + remove_line(c->lines[i]); + if (c != c2) + merge_corners(c, c2); + check(c, 0); + i--; + break; + } + } + gui->progress(0, 0, 0); + check(c, 0); } -static int -any_line_selected () +static int any_line_selected() { - line_s *l; - for (l = lines; l; l = l->next) - { - if (DELETED (l)) - continue; - if (l->line && selected (l->line)) - return 1; - } - return 0; + line_s *l; + for (l = lines; l; l = l->next) { + if (DELETED(l)) + continue; + if (l->line && selected(l->line)) + return 1; + } + return 0; } -static int -trim_step (int s, int l1, int l2) +static int trim_step(int s, int l1, int l2) { - dprintf ("trim %d %d %d\n", s, l1, l2); - if (s > l1) - s = l1; - if (s > l2) - s = l2; - if (s != l1 && s != l2) - s = gridsnap (s); - return s; + dprintf("trim %d %d %d\n", s, l1, l2); + if (s > l1) + s = l1; + if (s > l2) + s = l2; + if (s != l1 && s != l2) + s = gridsnap(s); + return s; } -static int canonicalize_line (line_s * l); +static int canonicalize_line(line_s * l); -static int -split_line (line_s * l, corner_s * c) +static int split_line(line_s * l, corner_s * c) { - int i; - LineType *pcbline; - line_s *ls; + int i; + LineType *pcbline; + line_s *ls; - if (!intersecting_layers (l->layer, c->layer)) - return 0; - if (l->is_pad) - return 0; - if (c->pad) - { - dprintf ("split on pad!\n"); - if (l->s->pad == c->pad || l->e->pad == c->pad) - return 0; - dprintf ("splitting...\n"); - } + if (!intersecting_layers(l->layer, c->layer)) + return 0; + if (l->is_pad) + return 0; + if (c->pad) { + dprintf("split on pad!\n"); + if (l->s->pad == c->pad || l->e->pad == c->pad) + return 0; + dprintf("splitting...\n"); + } - check (c, l); - pcbline = create_pcb_line (l->layer, - c->x, c->y, l->e->x, l->e->y, - l->line->Thickness, l->line->Clearance, - l->line->Flags); - if (pcbline == 0) - return 0; /* already a line there */ + check(c, l); + pcbline = create_pcb_line(l->layer, c->x, c->y, l->e->x, l->e->y, l->line->Thickness, l->line->Clearance, l->line->Flags); + if (pcbline == 0) + return 0; /* already a line there */ - check (c, l); + check(c, l); - dprintf ("split line from %#mD to %#mD at %#mD\n", - l->s->x, l->s->y, l->e->x, l->e->y, c->x, c->y); - ls = (line_s *) malloc (sizeof (line_s)); + dprintf("split line from %#mD to %#mD at %#mD\n", l->s->x, l->s->y, l->e->x, l->e->y, c->x, c->y); + ls = (line_s *) malloc(sizeof(line_s)); - ls->next = lines; - lines = ls; - ls->is_pad = 0; - ls->s = c; - ls->e = l->e; - ls->line = pcbline; - ls->layer = l->layer; - for (i = 0; i < l->e->n_lines; i++) - if (l->e->lines[i] == l) - l->e->lines[i] = ls; - l->e = c; - add_line_to_corner (l, c); - add_line_to_corner (ls, c); + ls->next = lines; + lines = ls; + ls->is_pad = 0; + ls->s = c; + ls->e = l->e; + ls->line = pcbline; + ls->layer = l->layer; + for (i = 0; i < l->e->n_lines; i++) + if (l->e->lines[i] == l) + l->e->lines[i] = ls; + l->e = c; + add_line_to_corner(l, c); + add_line_to_corner(ls, c); - MoveObject (LINEPOINT_TYPE, LAYER_PTR (l->layer), l->line, &l->line->Point2, - c->x - (l->line->Point2.X), c->y - (l->line->Point2.Y)); + MoveObject(LINEPOINT_TYPE, LAYER_PTR(l->layer), l->line, &l->line->Point2, + c->x - (l->line->Point2.X), c->y - (l->line->Point2.Y)); - return 1; + return 1; } -static int -canonicalize_line (line_s * l) +static int canonicalize_line(line_s * l) { - /* This could be faster */ - corner_s *c; - if (l->s->x == l->e->x) - { - int y1 = l->s->y; - int y2 = l->e->y; - int x1 = l->s->x - l->line->Thickness / 2; - int x2 = l->s->x + l->line->Thickness / 2; - if (y1 > y2) - { - int t = y1; - y1 = y2; - y2 = t; - } - for (c = corners; c; c = c->next) - { - if (DELETED (c)) - continue; - if ((y1 < c->y && c->y < y2) - && intersecting_layers (l->layer, c->layer)) - { - if (c->x != l->s->x - && c->x < x2 && c->x > x1 && !(c->pad || c->pin)) - { - move_corner (c, l->s->x, c->y); + /* This could be faster */ + corner_s *c; + if (l->s->x == l->e->x) { + int y1 = l->s->y; + int y2 = l->e->y; + int x1 = l->s->x - l->line->Thickness / 2; + int x2 = l->s->x + l->line->Thickness / 2; + if (y1 > y2) { + int t = y1; + y1 = y2; + y2 = t; } - if (c->x == l->s->x) - { - /* FIXME: if the line is split, we have to re-canonicalize - both segments. */ - return split_line (l, c); + for (c = corners; c; c = c->next) { + if (DELETED(c)) + continue; + if ((y1 < c->y && c->y < y2) + && intersecting_layers(l->layer, c->layer)) { + if (c->x != l->s->x && c->x < x2 && c->x > x1 && !(c->pad || c->pin)) { + move_corner(c, l->s->x, c->y); + } + if (c->x == l->s->x) { + /* FIXME: if the line is split, we have to re-canonicalize + both segments. */ + return split_line(l, c); + } + } } - } } - } - else if (l->s->y == l->e->y) - { - int x1 = l->s->x; - int x2 = l->e->x; - int y1 = l->s->y - l->line->Thickness / 2; - int y2 = l->s->y + l->line->Thickness / 2; - if (x1 > x2) - { - int t = x1; - x1 = x2; - x2 = t; - } - for (c = corners; c; c = c->next) - { - if (DELETED (c)) - continue; - if ((x1 < c->x && c->x < x2) - && intersecting_layers (l->layer, c->layer)) - { - if (c->y != l->s->y - && c->y < y2 && c->y > y1 && !(c->pad || c->pin)) - { - move_corner (c, c->x, l->s->y); + else if (l->s->y == l->e->y) { + int x1 = l->s->x; + int x2 = l->e->x; + int y1 = l->s->y - l->line->Thickness / 2; + int y2 = l->s->y + l->line->Thickness / 2; + if (x1 > x2) { + int t = x1; + x1 = x2; + x2 = t; } - if (c->y == l->s->y) - { - /* FIXME: Likewise. */ - return split_line (l, c); + for (c = corners; c; c = c->next) { + if (DELETED(c)) + continue; + if ((x1 < c->x && c->x < x2) + && intersecting_layers(l->layer, c->layer)) { + if (c->y != l->s->y && c->y < y2 && c->y > y1 && !(c->pad || c->pin)) { + move_corner(c, c->x, l->s->y); + } + if (c->y == l->s->y) { + /* FIXME: Likewise. */ + return split_line(l, c); + } + } } - } } - } - else - { - /* diagonal lines. Let's try to split them at pins/vias - anyway. */ - int x1 = l->s->x; - int x2 = l->e->x; - int y1 = l->s->y; - int y2 = l->e->y; - if (x1 > x2) - { - int t = x1; - x1 = x2; - x2 = t; - } - if (y1 > y2) - { - int t = y1; - y1 = y2; - y2 = t; - } - for (c = corners; c; c = c->next) - { - if (DELETED (c)) - continue; - if (!c->via && !c->pin) - continue; - if ((x1 < c->x && c->x < x2) - && (y1 < c->y && c->y < y2) - && intersecting_layers (l->layer, c->layer)) - { - int th = c->pin ? c->pin->Thickness : c->via->Thickness; - th /= 2; - if (dist (l->s->x, l->s->y, c->x, c->y) > th - && dist (l->e->x, l->e->y, c->x, c->y) > th - && PinLineIntersect (c->pin ? c->pin : c->via, l->line)) - { - return split_line (l, c); + else { + /* diagonal lines. Let's try to split them at pins/vias + anyway. */ + int x1 = l->s->x; + int x2 = l->e->x; + int y1 = l->s->y; + int y2 = l->e->y; + if (x1 > x2) { + int t = x1; + x1 = x2; + x2 = t; } - } + if (y1 > y2) { + int t = y1; + y1 = y2; + y2 = t; + } + for (c = corners; c; c = c->next) { + if (DELETED(c)) + continue; + if (!c->via && !c->pin) + continue; + if ((x1 < c->x && c->x < x2) + && (y1 < c->y && c->y < y2) + && intersecting_layers(l->layer, c->layer)) { + int th = c->pin ? c->pin->Thickness : c->via->Thickness; + th /= 2; + if (dist(l->s->x, l->s->y, c->x, c->y) > th + && dist(l->e->x, l->e->y, c->x, c->y) > th && PinLineIntersect(c->pin ? c->pin : c->via, l->line)) { + return split_line(l, c); + } + } + } } - } - return 0; + return 0; } /* Make sure all vias are at line end points */ -static int -canonicalize_lines () +static int canonicalize_lines() { - int changes = 0; - int count; - line_s *l; - while (1) - { - count = 0; - for (l = lines; l; l = l->next) - { - if (DELETED (l)) - continue; - count += canonicalize_line (l); + int changes = 0; + int count; + line_s *l; + while (1) { + count = 0; + for (l = lines; l; l = l->next) { + if (DELETED(l)) + continue; + count += canonicalize_line(l); + } + changes += count; + if (count == 0) + break; } - changes += count; - if (count == 0) - break; - } - return changes; + return changes; } -static int -simple_optimize_corner (corner_s * c) +static int simple_optimize_corner(corner_s * c) { - int i; - int rv = 0; + int i; + int rv = 0; - check (c, 0); - if (c->via) - { - /* see if no via is needed */ - if (selected (c->via)) - dprintf ("via check: line[0] layer %d at %#mD nl %d\n", - c->lines[0]->layer, c->x, c->y, c->n_lines); - /* We can't delete vias that connect to power planes, or vias - that aren't tented (assume they're test points). */ - if (!TEST_ANY_THERMS (c->via) - && c->via->Mask == 0) - { - for (i = 1; i < c->n_lines; i++) - { - if (selected (c->via)) - dprintf (" line[%d] layer %d %#mD to %#mD\n", - i, c->lines[i]->layer, - c->lines[i]->s->x, c->lines[i]->s->y, - c->lines[i]->e->x, c->lines[i]->e->y); - if (c->lines[i]->layer != c->lines[0]->layer) - break; - } - if (i == c->n_lines) - { - if (selected (c->via)) - dprintf (" remove it\n"); - remove_via_at (c); - rv++; - } + check(c, 0); + if (c->via) { + /* see if no via is needed */ + if (selected(c->via)) + dprintf("via check: line[0] layer %d at %#mD nl %d\n", c->lines[0]->layer, c->x, c->y, c->n_lines); + /* We can't delete vias that connect to power planes, or vias + that aren't tented (assume they're test points). */ + if (!TEST_ANY_THERMS(c->via) + && c->via->Mask == 0) { + for (i = 1; i < c->n_lines; i++) { + if (selected(c->via)) + dprintf(" line[%d] layer %d %#mD to %#mD\n", + i, c->lines[i]->layer, c->lines[i]->s->x, c->lines[i]->s->y, c->lines[i]->e->x, c->lines[i]->e->y); + if (c->lines[i]->layer != c->lines[0]->layer) + break; + } + if (i == c->n_lines) { + if (selected(c->via)) + dprintf(" remove it\n"); + remove_via_at(c); + rv++; + } + } } - } - check (c, 0); - if (c->n_lines == 2 && !c->via) - { - /* see if it is an unneeded corner */ - int o = line_orient (c->lines[0], c); - corner_s *c2 = other_corner (c->lines[1], c); - corner_s *c0 = other_corner (c->lines[0], c); - if (o == line_orient (c->lines[1], c2) && o != DIAGONAL) - { - dprintf ("straight %#mD to %#mD to %#mD\n", - c0->x, c0->y, c->x, c->y, c2->x, c2->y); - if (selected (c->lines[0]->line)) - SET_FLAG (SELECTEDFLAG, c->lines[1]->line); - if (selected (c->lines[1]->line)) - SET_FLAG (SELECTEDFLAG, c->lines[0]->line); - move_corner (c, c2->x, c2->y); + check(c, 0); + if (c->n_lines == 2 && !c->via) { + /* see if it is an unneeded corner */ + int o = line_orient(c->lines[0], c); + corner_s *c2 = other_corner(c->lines[1], c); + corner_s *c0 = other_corner(c->lines[0], c); + if (o == line_orient(c->lines[1], c2) && o != DIAGONAL) { + dprintf("straight %#mD to %#mD to %#mD\n", c0->x, c0->y, c->x, c->y, c2->x, c2->y); + if (selected(c->lines[0]->line)) + SET_FLAG(SELECTEDFLAG, c->lines[1]->line); + if (selected(c->lines[1]->line)) + SET_FLAG(SELECTEDFLAG, c->lines[0]->line); + move_corner(c, c2->x, c2->y); + } } - } - check (c, 0); - if (c->n_lines == 1 && !c->via) - { - corner_s *c0 = other_corner (c->lines[0], c); - if (abs(c->x - c0->x) + abs(c->y - c0->y) <= LONGEST_FRECKLE) - { - /* - * Remove this line, as it is a "freckle". A freckle is an extremely - * short line (around 0.01 thou) that is unconnected at one end. - * Freckles are almost insignificantly small, but are annoying as - * they prevent the mitering optimiser from working. - * Freckles sometimes arise because of a bug in the autorouter that - * causes it to create small overshoots (typically 0.01 thou) at the - * intersections of vertical and horizontal lines. These overshoots - * are converted to freckles as a side effect of canonicalize_line(). - * Note that canonicalize_line() is not at fault, the bug is in the - * autorouter creating overshoots. - * The autorouter bug arose some time between the 20080202 and 20091103 - * releases. - * This code is probably worth keeping even when the autorouter bug is - * fixed, as "freckles" could conceivably arise in other ways. - */ - dprintf ("freckle %#mD to %#mD\n", c->x, c->y, c0->x, c0->y); - move_corner (c, c0->x, c0->y); + check(c, 0); + if (c->n_lines == 1 && !c->via) { + corner_s *c0 = other_corner(c->lines[0], c); + if (abs(c->x - c0->x) + abs(c->y - c0->y) <= LONGEST_FRECKLE) { + /* + * Remove this line, as it is a "freckle". A freckle is an extremely + * short line (around 0.01 thou) that is unconnected at one end. + * Freckles are almost insignificantly small, but are annoying as + * they prevent the mitering optimiser from working. + * Freckles sometimes arise because of a bug in the autorouter that + * causes it to create small overshoots (typically 0.01 thou) at the + * intersections of vertical and horizontal lines. These overshoots + * are converted to freckles as a side effect of canonicalize_line(). + * Note that canonicalize_line() is not at fault, the bug is in the + * autorouter creating overshoots. + * The autorouter bug arose some time between the 20080202 and 20091103 + * releases. + * This code is probably worth keeping even when the autorouter bug is + * fixed, as "freckles" could conceivably arise in other ways. + */ + dprintf("freckle %#mD to %#mD\n", c->x, c->y, c0->x, c0->y); + move_corner(c, c0->x, c0->y); + } } - } - check (c, 0); - return rv; + check(c, 0); + return rv; } /* We always run these */ -static int -simple_optimizations () +static int simple_optimizations() { - corner_s *c; - int rv = 0; + corner_s *c; + int rv = 0; - /* Look for corners that aren't */ - for (c = corners; c; c = c->next) - { - if (DELETED (c)) - continue; - if (c->pad || c->pin) - continue; - rv += simple_optimize_corner (c); - } - return rv; + /* Look for corners that aren't */ + for (c = corners; c; c = c->next) { + if (DELETED(c)) + continue; + if (c->pad || c->pin) + continue; + rv += simple_optimize_corner(c); + } + return rv; } -static int -is_hole (corner_s * c) +static int is_hole(corner_s * c) { - return c->pin || c->pad || c->via; + return c->pin || c->pad || c->via; } -static int -orthopull_1 (corner_s * c, int fdir, int rdir, int any_sel) +static int orthopull_1(corner_s * c, int fdir, int rdir, int any_sel) { - static corner_s **cs = 0; - static int cm = 0; - static line_s **ls = 0; - static int lm = 0; - int i, li, ln, cn, snap; - line_s *l = 0; - corner_s *c2, *cb; - int adir = 0, sdir = 0, pull; - int saw_sel = 0, saw_auto = 0; - int max, len = 0, r1 = 0, r2; - rect_s rr; - int edir = 0, done; + static corner_s **cs = 0; + static int cm = 0; + static line_s **ls = 0; + static int lm = 0; + int i, li, ln, cn, snap; + line_s *l = 0; + corner_s *c2, *cb; + int adir = 0, sdir = 0, pull; + int saw_sel = 0, saw_auto = 0; + int max, len = 0, r1 = 0, r2; + rect_s rr; + int edir = 0, done; - if (cs == 0) - { - cs = (corner_s **) malloc (10 * sizeof (corner_s)); - cm = 10; - ls = (line_s **) malloc (10 * sizeof (line_s)); - lm = 10; - } + if (cs == 0) { + cs = (corner_s **) malloc(10 * sizeof(corner_s)); + cm = 10; + ls = (line_s **) malloc(10 * sizeof(line_s)); + lm = 10; + } - for (i = 0; i < c->n_lines; i++) - { - int o = line_orient (c->lines[i], c); - if (o == rdir) - return 0; - } + for (i = 0; i < c->n_lines; i++) { + int o = line_orient(c->lines[i], c); + if (o == rdir) + return 0; + } - switch (fdir) - { - case RIGHT: - adir = DOWN; - sdir = UP; - break; - case DOWN: - adir = RIGHT; - sdir = LEFT; - break; - default: - dj_abort ("fdir not right or down\n"); - } + switch (fdir) { + case RIGHT: + adir = DOWN; + sdir = UP; + break; + case DOWN: + adir = RIGHT; + sdir = LEFT; + break; + default: + dj_abort("fdir not right or down\n"); + } - c2 = c; - cn = 0; - ln = 0; - pull = 0; - while (c2) - { - if (c2->pad || c2->pin || c2->n_lines < 2) - return 0; - if (cn >= cm) - { - cm = cn + 10; - cs = (corner_s **) realloc (cs, cm * sizeof (corner_s)); + c2 = c; + cn = 0; + ln = 0; + pull = 0; + while (c2) { + if (c2->pad || c2->pin || c2->n_lines < 2) + return 0; + if (cn >= cm) { + cm = cn + 10; + cs = (corner_s **) realloc(cs, cm * sizeof(corner_s)); + } + cs[cn++] = c2; + r2 = corner_radius(c2); + if (r1 < r2) + r1 = r2; + l = 0; + for (i = 0; i < c2->n_lines; i++) { + int o = line_orient(c2->lines[i], c2); + if (o == DIAGONAL) + return 0; + if (o == fdir) { + if (l) + return 0; /* we don't support overlapping lines yet */ + l = c2->lines[i]; + } + if (o == rdir && c2->lines[i] != ls[ln - 1]) + return 0; /* likewise */ + if (o == adir) + pull++; + if (o == sdir) + pull--; + } + if (!l) + break; + if (selected(l->line)) + saw_sel = 1; + if (autorouted(l->line)) + saw_auto = 1; + if (ln >= lm) { + lm = ln + 10; + ls = (line_s **) realloc(ls, lm * sizeof(line_s)); + } + ls[ln++] = l; + c2 = other_corner(l, c2); } - cs[cn++] = c2; - r2 = corner_radius (c2); - if (r1 < r2) - r1 = r2; - l = 0; - for (i = 0; i < c2->n_lines; i++) - { - int o = line_orient (c2->lines[i], c2); - if (o == DIAGONAL) - return 0; - if (o == fdir) - { - if (l) - return 0; /* we don't support overlapping lines yet */ - l = c2->lines[i]; - } - if (o == rdir && c2->lines[i] != ls[ln - 1]) - return 0; /* likewise */ - if (o == adir) - pull++; - if (o == sdir) - pull--; - } - if (!l) - break; - if (selected (l->line)) - saw_sel = 1; - if (autorouted (l->line)) - saw_auto = 1; - if (ln >= lm) - { - lm = ln + 10; - ls = (line_s **) realloc (ls, lm * sizeof (line_s)); - } - ls[ln++] = l; - c2 = other_corner (l, c2); - } - if (cn < 2 || pull == 0) - return 0; - if (any_sel && !saw_sel) - return 0; - if (!any_sel && autorouted_only && !saw_auto) - return 0; + if (cn < 2 || pull == 0) + return 0; + if (any_sel && !saw_sel) + return 0; + if (!any_sel && autorouted_only && !saw_auto) + return 0; - /* Ok, now look for other blockages. */ + /* Ok, now look for other blockages. */ - empty_rect (&rr); - add_point_to_rect (&rr, c->x, c->y, corner_radius (c)); - add_point_to_rect (&rr, c2->x, c2->y, corner_radius (c2)); + empty_rect(&rr); + add_point_to_rect(&rr, c->x, c->y, corner_radius(c)); + add_point_to_rect(&rr, c2->x, c2->y, corner_radius(c2)); - if (fdir == RIGHT && pull < 0) - edir = UP; - else if (fdir == RIGHT && pull > 0) - edir = DOWN; - else if (fdir == DOWN && pull < 0) - edir = LEFT; - else if (fdir == DOWN && pull > 0) - edir = RIGHT; + if (fdir == RIGHT && pull < 0) + edir = UP; + else if (fdir == RIGHT && pull > 0) + edir = DOWN; + else if (fdir == DOWN && pull < 0) + edir = LEFT; + else if (fdir == DOWN && pull > 0) + edir = RIGHT; - max = -1; - for (i = 0; i < cn; i++) - for (li = 0; li < cs[i]->n_lines; li++) - { - if (line_orient (cs[i]->lines[li], cs[i]) != edir) - continue; - len = line_length (cs[i]->lines[li]); - if (max > len || max == -1) - max = len; - } - dprintf ("c %s %4#mD cn %d pull %3d max %4#mS\n", - fdir == RIGHT ? "right" : "down ", c->x, c->y, cn, pull, max); + max = -1; + for (i = 0; i < cn; i++) + for (li = 0; li < cs[i]->n_lines; li++) { + if (line_orient(cs[i]->lines[li], cs[i]) != edir) + continue; + len = line_length(cs[i]->lines[li]); + if (max > len || max == -1) + max = len; + } + dprintf("c %s %4#mD cn %d pull %3d max %4#mS\n", fdir == RIGHT ? "right" : "down ", c->x, c->y, cn, pull, max); - switch (edir) - { - case UP: - rr.y1 = c->y - r1 - max; - break; - case DOWN: - rr.y2 = c->y + r1 + max; - break; - case LEFT: - rr.x1 = c->x - r1 - max; - break; - case RIGHT: - rr.x2 = c->x + r1 + max; - break; - } - rr.x1 -= SB + 1; - rr.x2 += SB + 1; - rr.y1 -= SB + 1; - rr.y2 += SB + 1; + switch (edir) { + case UP: + rr.y1 = c->y - r1 - max; + break; + case DOWN: + rr.y2 = c->y + r1 + max; + break; + case LEFT: + rr.x1 = c->x - r1 - max; + break; + case RIGHT: + rr.x2 = c->x + r1 + max; + break; + } + rr.x1 -= SB + 1; + rr.x2 += SB + 1; + rr.y1 -= SB + 1; + rr.y2 += SB + 1; - snap = 0; - for (cb = corners; cb; cb = cb->next) - { - int sep; - if (DELETED (cb)) - continue; - r1 = corner_radius (cb); - if (cb->net == c->net && !cb->pad) - continue; - if (!pin_in_rect (&rr, cb->x, cb->y, r1)) - continue; - switch (edir) - { + snap = 0; + for (cb = corners; cb; cb = cb->next) { + int sep; + if (DELETED(cb)) + continue; + r1 = corner_radius(cb); + if (cb->net == c->net && !cb->pad) + continue; + if (!pin_in_rect(&rr, cb->x, cb->y, r1)) + continue; + switch (edir) { #define ECHK(X,Y,LT) \ for (i=0; i sep) \ { max = sep; snap = 1; }\ } - case UP: - ECHK (x, y, >=); - break; - case DOWN: - ECHK (x, y, <=); - break; - case LEFT: - ECHK (y, x, >=); - break; - case RIGHT: - ECHK (y, x, <=); - break; + case UP: + ECHK(x, y, >=); + break; + case DOWN: + ECHK(x, y, <=); + break; + case LEFT: + ECHK(y, x, >=); + break; + case RIGHT: + ECHK(y, x, <=); + break; + } } - } - /* We must now check every line segment against our corners. */ - for (l = lines; l; l = l->next) - { - int o, x1, x2, y1, y2; - if (DELETED (l)) - continue; - dprintf ("check line %#mD to %#mD\n", l->s->x, l->s->y, l->e->x, l->e->y); - if (l->s->net == c->net) - { - dprintf (" same net\n"); - continue; - } - o = line_orient (l, 0); - /* We don't need to check perpendicular lines, because their - corners already take care of it. */ - if ((fdir == RIGHT && (o == UP || o == DOWN)) - || (fdir == DOWN && (o == RIGHT || o == LEFT))) - { - dprintf (" perpendicular\n"); - continue; - } + /* We must now check every line segment against our corners. */ + for (l = lines; l; l = l->next) { + int o, x1, x2, y1, y2; + if (DELETED(l)) + continue; + dprintf("check line %#mD to %#mD\n", l->s->x, l->s->y, l->e->x, l->e->y); + if (l->s->net == c->net) { + dprintf(" same net\n"); + continue; + } + o = line_orient(l, 0); + /* We don't need to check perpendicular lines, because their + corners already take care of it. */ + if ((fdir == RIGHT && (o == UP || o == DOWN)) + || (fdir == DOWN && (o == RIGHT || o == LEFT))) { + dprintf(" perpendicular\n"); + continue; + } - /* Choose so that x1,y1 is closest to corner C */ - if ((fdir == RIGHT && l->s->x < l->e->x) - || (fdir == DOWN && l->s->y < l->e->y)) - { - x1 = l->s->x; - y1 = l->s->y; - x2 = l->e->x; - y2 = l->e->y; - } - else - { - x1 = l->e->x; - y1 = l->e->y; - x2 = l->s->x; - y2 = l->s->y; - } + /* Choose so that x1,y1 is closest to corner C */ + if ((fdir == RIGHT && l->s->x < l->e->x) + || (fdir == DOWN && l->s->y < l->e->y)) { + x1 = l->s->x; + y1 = l->s->y; + x2 = l->e->x; + y2 = l->e->y; + } + else { + x1 = l->e->x; + y1 = l->e->y; + x2 = l->s->x; + y2 = l->s->y; + } - /* Eliminate all lines outside our range */ - if ((fdir == RIGHT && (x2 < c->x || x1 > c2->x)) - || (fdir == DOWN && (y2 < c->y || y1 > c2->y))) - { - dprintf (" outside our range\n"); - continue; + /* Eliminate all lines outside our range */ + if ((fdir == RIGHT && (x2 < c->x || x1 > c2->x)) + || (fdir == DOWN && (y2 < c->y || y1 > c2->y))) { + dprintf(" outside our range\n"); + continue; + } + + /* Eliminate all lines on the wrong side of us */ + if ((edir == UP && y1 > c->y && y2 > c->y) + || (edir == DOWN && y1 < c->y && y2 < c->y) + || (edir == LEFT && x1 > c->x && x2 > c->x) + || (edir == RIGHT && x1 < c->x && x2 < c->x)) { + dprintf(" wrong side\n"); + continue; + } + + /* For now, cheat on diagonals */ + switch (edir) { + case RIGHT: + if (x1 > x2) + x1 = x2; + break; + case LEFT: + if (x1 < x2) + x1 = x2; + break; + case DOWN: + if (y1 > y2) + y1 = y2; + break; + case UP: + if (y1 < y2) + y1 = y2; + break; + } + + /* Ok, now see how far we can get for each of our corners. */ + for (i = 0; i < cn; i++) { + int r = l->line->Thickness + SB + corner_radius(cs[i]) + 1; + int len = 0; + if ((fdir == RIGHT && (x2 < cs[i]->x || x1 > cs[i]->x)) + || (fdir == DOWN && (y2 < cs[i]->y || y1 > cs[i]->y))) + continue; + if (!intersecting_layers(cs[i]->layer, l->layer)) + continue; + switch (edir) { + case RIGHT: + len = x1 - c->x; + break; + case LEFT: + len = c->x - x1; + break; + case DOWN: + len = y1 - c->y; + break; + case UP: + len = c->y - y1; + break; + } + len -= r; + dprintf(" len is %#mS vs corner at %#mD\n", len, cs[i]->x, cs[i]->y); + if (len <= 0) + return 0; + if (max > len) + max = len; + } + } - /* Eliminate all lines on the wrong side of us */ - if ((edir == UP && y1 > c->y && y2 > c->y) - || (edir == DOWN && y1 < c->y && y2 < c->y) - || (edir == LEFT && x1 > c->x && x2 > c->x) - || (edir == RIGHT && x1 < c->x && x2 < c->x)) - { - dprintf (" wrong side\n"); - continue; + /* We must make sure that if a segment isn't being completely + removed, that any vias and/or pads don't overlap. */ + done = 0; + while (!done) { + done = 1; + for (i = 0; i < cn; i++) + for (li = 0; li < cs[i]->n_lines; li++) { + line_s *l = cs[i]->lines[li]; + corner_s *oc = other_corner(l, cs[i]); + if (line_orient(l, cs[i]) != edir) + continue; + len = line_length(l); + if (!oc->pad || !cs[i]->via) { + if (!is_hole(l->s) || !is_hole(l->e)) + continue; + if (len == max) + continue; + } + len -= corner_radius(l->s); + len -= corner_radius(l->e); + len -= SB + 1; + if (max > len) { + max = len; + done = 0; + } + } } - /* For now, cheat on diagonals */ - switch (edir) - { + if (max <= 0) + return 0; + switch (edir) { + case UP: + len = c->y - max; + break; + case DOWN: + len = c->y + max; + break; + case LEFT: + len = c->x - max; + break; case RIGHT: - if (x1 > x2) - x1 = x2; - break; - case LEFT: - if (x1 < x2) - x1 = x2; - break; - case DOWN: - if (y1 > y2) - y1 = y2; - break; - case UP: - if (y1 < y2) - y1 = y2; - break; + len = c->x + max; + break; } - - /* Ok, now see how far we can get for each of our corners. */ - for (i = 0; i < cn; i++) - { - int r = l->line->Thickness + SB + corner_radius (cs[i]) + 1; - int len = 0; - if ((fdir == RIGHT && (x2 < cs[i]->x || x1 > cs[i]->x)) - || (fdir == DOWN && (y2 < cs[i]->y || y1 > cs[i]->y))) - continue; - if (!intersecting_layers (cs[i]->layer, l->layer)) - continue; - switch (edir) - { - case RIGHT: - len = x1 - c->x; - break; - case LEFT: - len = c->x - x1; - break; - case DOWN: - len = y1 - c->y; - break; - case UP: - len = c->y - y1; - break; - } - len -= r; - dprintf (" len is %#mS vs corner at %#mD\n", len, cs[i]->x, cs[i]->y); - if (len <= 0) - return 0; - if (max > len) - max = len; + if (snap && max > Settings.Grid) { + if (pull < 0) + len += Settings.Grid - 1; + len = gridsnap(len); } - - } - - /* We must make sure that if a segment isn't being completely - removed, that any vias and/or pads don't overlap. */ - done = 0; - while (!done) - { - done = 1; - for (i = 0; i < cn; i++) - for (li = 0; li < cs[i]->n_lines; li++) - { - line_s *l = cs[i]->lines[li]; - corner_s *oc = other_corner (l, cs[i]); - if (line_orient (l, cs[i]) != edir) - continue; - len = line_length (l); - if (!oc->pad || !cs[i]->via) - { - if (!is_hole (l->s) || !is_hole (l->e)) - continue; - if (len == max) - continue; - } - len -= corner_radius (l->s); - len -= corner_radius (l->e); - len -= SB + 1; - if (max > len) - { - max = len; - done = 0; - } - } - } - - if (max <= 0) - return 0; - switch (edir) - { - case UP: - len = c->y - max; - break; - case DOWN: - len = c->y + max; - break; - case LEFT: - len = c->x - max; - break; - case RIGHT: - len = c->x + max; - break; - } - if (snap && max > Settings.Grid) - { - if (pull < 0) - len += Settings.Grid - 1; - len = gridsnap (len); - } - if ((fdir == RIGHT && len == cs[0]->y) || (fdir == DOWN && len == cs[0]->x)) - return 0; - for (i = 0; i < cn; i++) - { - if (fdir == RIGHT) - { - max = len - cs[i]->y; - move_corner (cs[i], cs[i]->x, len); + if ((fdir == RIGHT && len == cs[0]->y) || (fdir == DOWN && len == cs[0]->x)) + return 0; + for (i = 0; i < cn; i++) { + if (fdir == RIGHT) { + max = len - cs[i]->y; + move_corner(cs[i], cs[i]->x, len); + } + else { + max = len - cs[i]->x; + move_corner(cs[i], len, cs[i]->y); + } } - else - { - max = len - cs[i]->x; - move_corner (cs[i], len, cs[i]->y); - } - } - return max * pull; + return max * pull; } -static int -orthopull () +static int orthopull() { - /* Look for straight runs which could be moved to reduce total trace - length. */ - int any_sel = any_line_selected (); - corner_s *c; - int rv = 0; + /* Look for straight runs which could be moved to reduce total trace + length. */ + int any_sel = any_line_selected(); + corner_s *c; + int rv = 0; - for (c = corners; c;) - { - if (DELETED (c)) - continue; - if (c->pin || c->pad) - { - c = c->next; - continue; + for (c = corners; c;) { + if (DELETED(c)) + continue; + if (c->pin || c->pad) { + c = c->next; + continue; + } + next_corner = c; + rv += orthopull_1(c, RIGHT, LEFT, any_sel); + if (c != next_corner) { + c = next_corner; + continue; + } + rv += orthopull_1(c, DOWN, UP, any_sel); + if (c != next_corner) { + c = next_corner; + continue; + } + c = c->next; } - next_corner = c; - rv += orthopull_1 (c, RIGHT, LEFT, any_sel); - if (c != next_corner) - { - c = next_corner; - continue; - } - rv += orthopull_1 (c, DOWN, UP, any_sel); - if (c != next_corner) - { - c = next_corner; - continue; - } - c = c->next; - } - if (rv) - pcb_printf ("orthopull: %ml mils saved\n", rv); - return rv; + if (rv) + pcb_printf("orthopull: %ml mils saved\n", rv); + return rv; } -static int -debumpify () +static int debumpify() { - /* Look for "U" shaped traces we can shorten (or eliminate) */ - int rv = 0; - int any_selected = any_line_selected (); - line_s *l, *l1, *l2; - corner_s *c, *c1, *c2; - rect_s rr, rp; - int o, o1, o2, step, w; - for (l = lines; l; l = l->next) - { - if (DELETED (l)) - continue; - if (!l->line) - continue; - if (any_selected && !selected (l->line)) - continue; - if (!any_selected && autorouted_only && !autorouted (l->line)) - continue; - if (l->s->pin || l->s->pad || l->e->pin || l->e->pad) - continue; - o = line_orient (l, 0); - if (o == DIAGONAL) - continue; - l1 = other_line (l->s, l); - if (!l1) - continue; - o1 = line_orient (l1, l->s); - l2 = other_line (l->e, l); - if (!l2) - continue; - o2 = line_orient (l2, l->e); - if (ORIENT (o) == ORIENT (o1) || o1 != o2 || o1 == DIAGONAL) - continue; + /* Look for "U" shaped traces we can shorten (or eliminate) */ + int rv = 0; + int any_selected = any_line_selected(); + line_s *l, *l1, *l2; + corner_s *c, *c1, *c2; + rect_s rr, rp; + int o, o1, o2, step, w; + for (l = lines; l; l = l->next) { + if (DELETED(l)) + continue; + if (!l->line) + continue; + if (any_selected && !selected(l->line)) + continue; + if (!any_selected && autorouted_only && !autorouted(l->line)) + continue; + if (l->s->pin || l->s->pad || l->e->pin || l->e->pad) + continue; + o = line_orient(l, 0); + if (o == DIAGONAL) + continue; + l1 = other_line(l->s, l); + if (!l1) + continue; + o1 = line_orient(l1, l->s); + l2 = other_line(l->e, l); + if (!l2) + continue; + o2 = line_orient(l2, l->e); + if (ORIENT(o) == ORIENT(o1) || o1 != o2 || o1 == DIAGONAL) + continue; - dprintf ("\nline: %#mD to %#mD\n", l->s->x, l->s->y, l->e->x, l->e->y); - w = l->line->Thickness / 2 + SB + 1; - empty_rect (&rr); - add_line_to_rect (&rr, l1); - add_line_to_rect (&rr, l2); - if (rr.x1 != l->s->x && rr.x1 != l->e->x) - rr.x1 -= w; - if (rr.x2 != l->s->x && rr.x2 != l->e->x) - rr.x2 += w; - if (rr.y1 != l->s->y && rr.y1 != l->e->y) - rr.y1 -= w; - if (rr.y2 != l->s->y && rr.y2 != l->e->y) - rr.y2 += w; - dprintf ("range: x %#mS..%#mS y %#mS..%#mS\n", rr.x1, rr.x2, rr.y1, rr.y2); + dprintf("\nline: %#mD to %#mD\n", l->s->x, l->s->y, l->e->x, l->e->y); + w = l->line->Thickness / 2 + SB + 1; + empty_rect(&rr); + add_line_to_rect(&rr, l1); + add_line_to_rect(&rr, l2); + if (rr.x1 != l->s->x && rr.x1 != l->e->x) + rr.x1 -= w; + if (rr.x2 != l->s->x && rr.x2 != l->e->x) + rr.x2 += w; + if (rr.y1 != l->s->y && rr.y1 != l->e->y) + rr.y1 -= w; + if (rr.y2 != l->s->y && rr.y2 != l->e->y) + rr.y2 += w; + dprintf("range: x %#mS..%#mS y %#mS..%#mS\n", rr.x1, rr.x2, rr.y1, rr.y2); - c1 = other_corner (l1, l->s); - c2 = other_corner (l2, l->e); + c1 = other_corner(l1, l->s); + c2 = other_corner(l2, l->e); - empty_rect (&rp); - for (c = corners; c; c = c->next) - { - if (DELETED (c)) - continue; - if (c->net != l->s->net - && intersecting_layers (c->layer, l->s->layer)) - add_corner_to_rect_if (&rp, c, &rr); - } - if (rp.x1 == INT_MAX) - { - rp.x1 = rr.x2; - rp.x2 = rr.x1; - rp.y1 = rr.y2; - rp.y2 = rr.y1; - } - dprintf ("pin r: x %#mS..%#mS y %#mS..%#mS\n", rp.x1, rp.x2, rp.y1, rp.y2); + empty_rect(&rp); + for (c = corners; c; c = c->next) { + if (DELETED(c)) + continue; + if (c->net != l->s->net && intersecting_layers(c->layer, l->s->layer)) + add_corner_to_rect_if(&rp, c, &rr); + } + if (rp.x1 == INT_MAX) { + rp.x1 = rr.x2; + rp.x2 = rr.x1; + rp.y1 = rr.y2; + rp.y2 = rr.y1; + } + dprintf("pin r: x %#mS..%#mS y %#mS..%#mS\n", rp.x1, rp.x2, rp.y1, rp.y2); - switch (o1) - { - case LEFT: - step = l->s->x - rp.x2 - w; - step = gridsnap (step); - if (step > l->s->x - c1->x) - step = l->s->x - c1->x; - if (step > l->s->x - c2->x) - step = l->s->x - c2->x; - if (step > 0) - { - dprintf ("left step %#mS at %#mD\n", step, l->s->x, l->s->y); - move_corner (l->s, l->s->x - step, l->s->y); - move_corner (l->e, l->e->x - step, l->e->y); - rv += step; - } - break; - case RIGHT: - step = rp.x1 - l->s->x - w; - step = gridsnap (step); - if (step > c1->x - l->s->x) - step = c1->x - l->s->x; - if (step > c2->x - l->s->x) - step = c2->x - l->s->x; - if (step > 0) - { - dprintf ("right step %#mS at %#mD\n", step, l->s->x, l->s->y); - move_corner (l->s, l->s->x + step, l->s->y); - move_corner (l->e, l->e->x + step, l->e->y); - rv += step; - } - break; - case UP: - if (rp.y2 == INT_MIN) - rp.y2 = rr.y1; - step = trim_step (l->s->y - rp.y2 - w, - l->s->y - c1->y, l->s->y - c2->y); - if (step > 0) - { - dprintf ("up step %#mS at %#mD\n", step, l->s->x, l->s->y); - move_corner (l->s, l->s->x, l->s->y - step); - move_corner (l->e, l->e->x, l->e->y - step); - rv += step; - } - break; - case DOWN: - step = rp.y1 - l->s->y - w; - step = gridsnap (step); - if (step > c1->y - l->s->y) - step = c1->y - l->s->y; - if (step > c2->y - l->s->y) - step = c2->y - l->s->y; - if (step > 0) - { - dprintf ("down step %#mS at %#mD\n", step, l->s->x, l->s->y); - move_corner (l->s, l->s->x, l->s->y + step); - move_corner (l->e, l->e->x, l->e->y + step); - rv += step; - } - break; + switch (o1) { + case LEFT: + step = l->s->x - rp.x2 - w; + step = gridsnap(step); + if (step > l->s->x - c1->x) + step = l->s->x - c1->x; + if (step > l->s->x - c2->x) + step = l->s->x - c2->x; + if (step > 0) { + dprintf("left step %#mS at %#mD\n", step, l->s->x, l->s->y); + move_corner(l->s, l->s->x - step, l->s->y); + move_corner(l->e, l->e->x - step, l->e->y); + rv += step; + } + break; + case RIGHT: + step = rp.x1 - l->s->x - w; + step = gridsnap(step); + if (step > c1->x - l->s->x) + step = c1->x - l->s->x; + if (step > c2->x - l->s->x) + step = c2->x - l->s->x; + if (step > 0) { + dprintf("right step %#mS at %#mD\n", step, l->s->x, l->s->y); + move_corner(l->s, l->s->x + step, l->s->y); + move_corner(l->e, l->e->x + step, l->e->y); + rv += step; + } + break; + case UP: + if (rp.y2 == INT_MIN) + rp.y2 = rr.y1; + step = trim_step(l->s->y - rp.y2 - w, l->s->y - c1->y, l->s->y - c2->y); + if (step > 0) { + dprintf("up step %#mS at %#mD\n", step, l->s->x, l->s->y); + move_corner(l->s, l->s->x, l->s->y - step); + move_corner(l->e, l->e->x, l->e->y - step); + rv += step; + } + break; + case DOWN: + step = rp.y1 - l->s->y - w; + step = gridsnap(step); + if (step > c1->y - l->s->y) + step = c1->y - l->s->y; + if (step > c2->y - l->s->y) + step = c2->y - l->s->y; + if (step > 0) { + dprintf("down step %#mS at %#mD\n", step, l->s->x, l->s->y); + move_corner(l->s, l->s->x, l->s->y + step); + move_corner(l->e, l->e->x, l->e->y + step); + rv += step; + } + break; + } + check(0, l); } - check (0, l); - } - rv += simple_optimizations (); - if (rv) - pcb_printf ("debumpify: %ml mils saved\n", rv / 50); - return rv; + rv += simple_optimizations(); + if (rv) + pcb_printf("debumpify: %ml mils saved\n", rv / 50); + return rv; } -static int -simple_corner (corner_s * c) +static int simple_corner(corner_s * c) { - int o1, o2; - if (c->pad || c->pin || c->via) - return 0; - if (c->n_lines != 2) - return 0; - o1 = line_orient (c->lines[0], c); - o2 = line_orient (c->lines[1], c); - if (ORIENT (o1) == ORIENT (o2)) - return 0; - if (ORIENT (o1) == DIAGONAL || ORIENT (o2) == DIAGONAL) - return 0; - return 1; + int o1, o2; + if (c->pad || c->pin || c->via) + return 0; + if (c->n_lines != 2) + return 0; + o1 = line_orient(c->lines[0], c); + o2 = line_orient(c->lines[1], c); + if (ORIENT(o1) == ORIENT(o2)) + return 0; + if (ORIENT(o1) == DIAGONAL || ORIENT(o2) == DIAGONAL) + return 0; + return 1; } -static int -unjaggy_once () +static int unjaggy_once() { - /* Look for sequences of simple corners we can reduce. */ - int rv = 0; - corner_s *c, *c0, *c1, *cc; - int l, w, sel = any_line_selected (); - int o0, o1, s0, s1; - rect_s rr, rp; - for (c = corners; c; c = c->next) - { - if (DELETED (c)) - continue; - if (!simple_corner (c)) - continue; - if (!c->lines[0]->line || !c->lines[1]->line) - continue; - if (sel && !(selected (c->lines[0]->line) - || selected (c->lines[1]->line))) - continue; - if (!sel && autorouted_only - && !(autorouted (c->lines[0]->line) - || autorouted (c->lines[1]->line))) - continue; - dprintf ("simple at %#mD\n", c->x, c->y); + /* Look for sequences of simple corners we can reduce. */ + int rv = 0; + corner_s *c, *c0, *c1, *cc; + int l, w, sel = any_line_selected(); + int o0, o1, s0, s1; + rect_s rr, rp; + for (c = corners; c; c = c->next) { + if (DELETED(c)) + continue; + if (!simple_corner(c)) + continue; + if (!c->lines[0]->line || !c->lines[1]->line) + continue; + if (sel && !(selected(c->lines[0]->line) + || selected(c->lines[1]->line))) + continue; + if (!sel && autorouted_only && !(autorouted(c->lines[0]->line) + || autorouted(c->lines[1]->line))) + continue; + dprintf("simple at %#mD\n", c->x, c->y); - c0 = other_corner (c->lines[0], c); - o0 = line_orient (c->lines[0], c); - s0 = simple_corner (c0); + c0 = other_corner(c->lines[0], c); + o0 = line_orient(c->lines[0], c); + s0 = simple_corner(c0); - c1 = other_corner (c->lines[1], c); - o1 = line_orient (c->lines[1], c); - s1 = simple_corner (c1); + c1 = other_corner(c->lines[1], c); + o1 = line_orient(c->lines[1], c); + s1 = simple_corner(c1); - if (!s0 && !s1) - continue; - dprintf ("simples at %#mD\n", c->x, c->y); + if (!s0 && !s1) + continue; + dprintf("simples at %#mD\n", c->x, c->y); - w = 1; - for (l = 0; l < c0->n_lines; l++) - if (c0->lines[l] != c->lines[0] - && c0->lines[l]->layer == c->lines[0]->layer) - { - int o = line_orient (c0->lines[l], c0); - if (o == o1) - w = 0; - } - for (l = 0; l < c1->n_lines; l++) - if (c1->lines[l] != c->lines[0] - && c1->lines[l]->layer == c->lines[0]->layer) - { - int o = line_orient (c1->lines[l], c1); - if (o == o0) - w = 0; - } - if (!w) - continue; - dprintf ("orient ok\n"); + w = 1; + for (l = 0; l < c0->n_lines; l++) + if (c0->lines[l] != c->lines[0] + && c0->lines[l]->layer == c->lines[0]->layer) { + int o = line_orient(c0->lines[l], c0); + if (o == o1) + w = 0; + } + for (l = 0; l < c1->n_lines; l++) + if (c1->lines[l] != c->lines[0] + && c1->lines[l]->layer == c->lines[0]->layer) { + int o = line_orient(c1->lines[l], c1); + if (o == o0) + w = 0; + } + if (!w) + continue; + dprintf("orient ok\n"); - w = c->lines[0]->line->Thickness / 2 + SB + 1; - empty_rect (&rr); - add_line_to_rect (&rr, c->lines[0]); - add_line_to_rect (&rr, c->lines[1]); - if (c->x != rr.x1) - rr.x1 -= w; - else - rr.x2 += w; - if (c->y != rr.y1) - rr.y1 -= w; - else - rr.y2 += w; + w = c->lines[0]->line->Thickness / 2 + SB + 1; + empty_rect(&rr); + add_line_to_rect(&rr, c->lines[0]); + add_line_to_rect(&rr, c->lines[1]); + if (c->x != rr.x1) + rr.x1 -= w; + else + rr.x2 += w; + if (c->y != rr.y1) + rr.y1 -= w; + else + rr.y2 += w; - empty_rect (&rp); - for (cc = corners; cc; cc = cc->next) - { - if (DELETED (cc)) - continue; - if (cc->net != c->net && intersecting_layers (cc->layer, c->layer)) - add_corner_to_rect_if (&rp, cc, &rr); + empty_rect(&rp); + for (cc = corners; cc; cc = cc->next) { + if (DELETED(cc)) + continue; + if (cc->net != c->net && intersecting_layers(cc->layer, c->layer)) + add_corner_to_rect_if(&rp, cc, &rr); + } + dprintf("rp x %#mS..%#mS y %#mS..%#mS\n", rp.x1, rp.x2, rp.y1, rp.y2); + if (rp.x1 <= rp.x2) /* something triggered */ + continue; + + dprintf("unjaggy at %#mD layer %d\n", c->x, c->y, c->layer); + if (c->x == c0->x) + move_corner(c, c1->x, c0->y); + else + move_corner(c, c0->x, c1->y); + rv++; + check(c, 0); } - dprintf ("rp x %#mS..%#mS y %#mS..%#mS\n", rp.x1, rp.x2, rp.y1, rp.y2); - if (rp.x1 <= rp.x2) /* something triggered */ - continue; - - dprintf ("unjaggy at %#mD layer %d\n", c->x, c->y, c->layer); - if (c->x == c0->x) - move_corner (c, c1->x, c0->y); - else - move_corner (c, c0->x, c1->y); - rv++; - check (c, 0); - } - rv += simple_optimizations (); - check (c, 0); - return rv; + rv += simple_optimizations(); + check(c, 0); + return rv; } -static int -unjaggy () +static int unjaggy() { - int i, r = 0, j; - for (i = 0; i < 100; i++) - { - j = unjaggy_once (); - if (j == 0) - break; - r += j; - } - if (r) - printf ("%d unjagg%s \n", r, r == 1 ? "y" : "ies"); - return r; + int i, r = 0, j; + for (i = 0; i < 100; i++) { + j = unjaggy_once(); + if (j == 0) + break; + r += j; + } + if (r) + printf("%d unjagg%s \n", r, r == 1 ? "y" : "ies"); + return r; } -static int -vianudge () +static int vianudge() { - /* Look for vias with all lines leaving the same way, try to nudge - via to eliminate one or more of them. */ - int rv = 0; - corner_s *c, *c2, *c3; - line_s *l; - unsigned char directions[MAX_LAYER]; - unsigned char counts[MAX_LAYER]; + /* Look for vias with all lines leaving the same way, try to nudge + via to eliminate one or more of them. */ + int rv = 0; + corner_s *c, *c2, *c3; + line_s *l; + unsigned char directions[MAX_LAYER]; + unsigned char counts[MAX_LAYER]; - memset (directions, 0, sizeof (directions)); - memset (counts, 0, sizeof (counts)); + memset(directions, 0, sizeof(directions)); + memset(counts, 0, sizeof(counts)); - for (c = corners; c; c = c->next) - { - int o, i, vr, cr, oboth; - int len = 0, saved = 0; + for (c = corners; c; c = c->next) { + int o, i, vr, cr, oboth; + int len = 0, saved = 0; - if (DELETED (c)) - continue; + if (DELETED(c)) + continue; - if (!c->via) - continue; + if (!c->via) + continue; - memset (directions, 0, sizeof (directions)); - memset (counts, 0, sizeof (counts)); + memset(directions, 0, sizeof(directions)); + memset(counts, 0, sizeof(counts)); - for (i = 0; i < c->n_lines; i++) - { - o = line_orient (c->lines[i], c); - counts[c->lines[i]->layer]++; - directions[c->lines[i]->layer] |= o; - } - for (o = 0, i = 0; i < max_copper_layer; i++) - if (counts[i] == 1) - { - o = directions[i]; - break; - } - switch (o) - { - case LEFT: - case RIGHT: - oboth = LEFT | RIGHT; - break; - case UP: - case DOWN: - oboth = UP | DOWN; - break; - default: - continue; - } - for (i = 0; i < max_copper_layer; i++) - if (counts[i] && directions[i] != o && directions[i] != oboth) - goto vianudge_continue; + for (i = 0; i < c->n_lines; i++) { + o = line_orient(c->lines[i], c); + counts[c->lines[i]->layer]++; + directions[c->lines[i]->layer] |= o; + } + for (o = 0, i = 0; i < max_copper_layer; i++) + if (counts[i] == 1) { + o = directions[i]; + break; + } + switch (o) { + case LEFT: + case RIGHT: + oboth = LEFT | RIGHT; + break; + case UP: + case DOWN: + oboth = UP | DOWN; + break; + default: + continue; + } + for (i = 0; i < max_copper_layer; i++) + if (counts[i] && directions[i] != o && directions[i] != oboth) + goto vianudge_continue; - c2 = 0; - for (i = 0; i < c->n_lines; i++) - { - int ll = line_length (c->lines[i]); - if (line_orient (c->lines[i], c) != o) - { - saved--; - continue; - } - saved++; - if (c2 == 0 || len > ll) - { - len = ll; - c2 = other_corner (c->lines[i], c); - } - } - if (c2->pad || c2->pin || c2->via) - continue; + c2 = 0; + for (i = 0; i < c->n_lines; i++) { + int ll = line_length(c->lines[i]); + if (line_orient(c->lines[i], c) != o) { + saved--; + continue; + } + saved++; + if (c2 == 0 || len > ll) { + len = ll; + c2 = other_corner(c->lines[i], c); + } + } + if (c2->pad || c2->pin || c2->via) + continue; - /* Now look for clearance in the new position */ - vr = c->via->Thickness / 2 + SB + 1; - for (c3 = corners; c3; c3 = c3->next) - { - if (DELETED (c3)) - continue; - if ((c3->net != c->net && (c3->pin || c3->via)) || c3->pad) - { - cr = corner_radius (c3); - if (dist (c2->x, c2->y, c3->x, c3->y) < vr + cr) - goto vianudge_continue; - } - } - for (l = lines; l; l = l->next) - { - if (DELETED (l)) - continue; - if (l->s->net != c->net) - { - int ld = dist_line_to_point (l, c2); - if (ld < l->line->Thickness / 2 + vr) - goto vianudge_continue; - } - } + /* Now look for clearance in the new position */ + vr = c->via->Thickness / 2 + SB + 1; + for (c3 = corners; c3; c3 = c3->next) { + if (DELETED(c3)) + continue; + if ((c3->net != c->net && (c3->pin || c3->via)) || c3->pad) { + cr = corner_radius(c3); + if (dist(c2->x, c2->y, c3->x, c3->y) < vr + cr) + goto vianudge_continue; + } + } + for (l = lines; l; l = l->next) { + if (DELETED(l)) + continue; + if (l->s->net != c->net) { + int ld = dist_line_to_point(l, c2); + if (ld < l->line->Thickness / 2 + vr) + goto vianudge_continue; + } + } - /* at this point, we know we can move it */ + /* at this point, we know we can move it */ - dprintf ("vianudge: nudging via at %#mD by %#mS saving %#mS\n", - c->x, c->y, len, saved); - rv += len * saved; - move_corner (c, c2->x, c2->y); + dprintf("vianudge: nudging via at %#mD by %#mS saving %#mS\n", c->x, c->y, len, saved); + rv += len * saved; + move_corner(c, c2->x, c2->y); - check (c, 0); + check(c, 0); - vianudge_continue: - continue; - } + vianudge_continue: + continue; + } - if (rv) - pcb_printf ("vianudge: %ml mils saved\n", rv); - return rv; + if (rv) + pcb_printf("vianudge: %ml mils saved\n", rv); + return rv; } -static int -viatrim () +static int viatrim() { - /* Look for traces that can be moved to the other side of the board, - to reduce the number of vias needed. For now, we look for simple - lines, not multi-segmented lines. */ - line_s *l, *l2; - int i, rv = 0, vrm = 0; - int any_sel = any_line_selected (); + /* Look for traces that can be moved to the other side of the board, + to reduce the number of vias needed. For now, we look for simple + lines, not multi-segmented lines. */ + line_s *l, *l2; + int i, rv = 0, vrm = 0; + int any_sel = any_line_selected(); - for (l = lines; l; l = l->next) - { - rect_s r; - int my_layer, other_layer; + for (l = lines; l; l = l->next) { + rect_s r; + int my_layer, other_layer; - if (DELETED (l)) - continue; - if (!l->s->via) - continue; - if (!l->e->via) - continue; - if (any_sel && !selected (l->line)) - continue; - if (!any_sel && autorouted_only && !autorouted (l->line)) - continue; + if (DELETED(l)) + continue; + if (!l->s->via) + continue; + if (!l->e->via) + continue; + if (any_sel && !selected(l->line)) + continue; + if (!any_sel && autorouted_only && !autorouted(l->line)) + continue; - my_layer = l->layer; - other_layer = -1; - dprintf ("line %p on layer %d from %#mD to %#mD\n", (void *) l, - l->layer, l->s->x, l->s->y, l->e->x, l->e->y); - for (i = 0; i < l->s->n_lines; i++) - if (l->s->lines[i] != l) - { - if (other_layer == -1) - { - other_layer = l->s->lines[i]->layer; - dprintf ("noting other line %p on layer %d\n", - (void *) (l->s->lines[i]), my_layer); - } - else if (l->s->lines[i]->layer != other_layer) - { - dprintf ("saw other line %p on layer %d (not %d)\n", - (void *) (l->s->lines[i]), l->s->lines[i]->layer, - my_layer); + my_layer = l->layer; other_layer = -1; - goto viatrim_other_corner; - } - } - viatrim_other_corner: - if (other_layer == -1) - for (i = 0; i < l->e->n_lines; i++) - if (l->e->lines[i] != l) - { - if (other_layer == -1) - { - other_layer = l->s->lines[i]->layer; - dprintf ("noting other line %p on layer %d\n", - (void *) (l->s->lines[i]), my_layer); - } - else if (l->e->lines[i]->layer != other_layer) - { - dprintf ("saw end line on layer %d (not %d)\n", - l->e->lines[i]->layer, other_layer); - goto viatrim_continue; - } - } + dprintf("line %p on layer %d from %#mD to %#mD\n", (void *) l, l->layer, l->s->x, l->s->y, l->e->x, l->e->y); + for (i = 0; i < l->s->n_lines; i++) + if (l->s->lines[i] != l) { + if (other_layer == -1) { + other_layer = l->s->lines[i]->layer; + dprintf("noting other line %p on layer %d\n", (void *) (l->s->lines[i]), my_layer); + } + else if (l->s->lines[i]->layer != other_layer) { + dprintf("saw other line %p on layer %d (not %d)\n", (void *) (l->s->lines[i]), l->s->lines[i]->layer, my_layer); + other_layer = -1; + goto viatrim_other_corner; + } + } + viatrim_other_corner: + if (other_layer == -1) + for (i = 0; i < l->e->n_lines; i++) + if (l->e->lines[i] != l) { + if (other_layer == -1) { + other_layer = l->s->lines[i]->layer; + dprintf("noting other line %p on layer %d\n", (void *) (l->s->lines[i]), my_layer); + } + else if (l->e->lines[i]->layer != other_layer) { + dprintf("saw end line on layer %d (not %d)\n", l->e->lines[i]->layer, other_layer); + goto viatrim_continue; + } + } - /* Now see if any other line intersects us. We don't need to - check corners, because they'd either be pins/vias and - already conflict, or pads, which we'll check here anyway. */ - empty_rect (&r); - add_point_to_rect (&r, l->s->x, l->s->y, l->line->Thickness); - add_point_to_rect (&r, l->e->x, l->e->y, l->line->Thickness); + /* Now see if any other line intersects us. We don't need to + check corners, because they'd either be pins/vias and + already conflict, or pads, which we'll check here anyway. */ + empty_rect(&r); + add_point_to_rect(&r, l->s->x, l->s->y, l->line->Thickness); + add_point_to_rect(&r, l->e->x, l->e->y, l->line->Thickness); - for (l2 = lines; l2; l2 = l2->next) - { - if (DELETED (l2)) - continue; - if (l2->s->net != l->s->net && l2->layer == other_layer) - { - dprintf ("checking other line %#mD to %#mD\n", l2->s->x, - l2->s->y, l2->e->x, l2->e->y); - if (line_in_rect (&r, l2)) - { - dprintf ("line from %#mD to %#mD in the way\n", - l2->s->x, l2->s->y, l2->e->x, l2->e->y); - goto viatrim_continue; + for (l2 = lines; l2; l2 = l2->next) { + if (DELETED(l2)) + continue; + if (l2->s->net != l->s->net && l2->layer == other_layer) { + dprintf("checking other line %#mD to %#mD\n", l2->s->x, l2->s->y, l2->e->x, l2->e->y); + if (line_in_rect(&r, l2)) { + dprintf("line from %#mD to %#mD in the way\n", l2->s->x, l2->s->y, l2->e->x, l2->e->y); + goto viatrim_continue; + } + } } - } - } - if (l->layer == other_layer) - continue; - move_line_to_layer (l, other_layer); - rv++; + if (l->layer == other_layer) + continue; + move_line_to_layer(l, other_layer); + rv++; - viatrim_continue: - continue; - } - vrm = simple_optimizations (); - if (rv > 0) - printf ("viatrim: %d traces moved, %d vias removed\n", rv, vrm); - return rv + vrm; + viatrim_continue: + continue; + } + vrm = simple_optimizations(); + if (rv > 0) + printf("viatrim: %d traces moved, %d vias removed\n", rv, vrm); + return rv + vrm; } -static int -automagic () +static int automagic() { - int more = 1, oldmore = 0; - int toomany = 100; - while (more != oldmore && --toomany) - { - oldmore = more; - more += debumpify (); - more += unjaggy (); - more += orthopull (); - more += vianudge (); - more += viatrim (); - } - return more - 1; + int more = 1, oldmore = 0; + int toomany = 100; + while (more != oldmore && --toomany) { + oldmore = more; + more += debumpify(); + more += unjaggy(); + more += orthopull(); + more += vianudge(); + more += viatrim(); + } + return more - 1; } -static int -miter () +static int miter() { - corner_s *c; - int done, progress; - int sel = any_line_selected (); - int saved = 0; + corner_s *c; + int done, progress; + int sel = any_line_selected(); + int saved = 0; - for (c = corners; c; c = c->next) - { - if (DELETED (c)) - continue; - c->miter = 0; - if (c->n_lines == 2 && !c->via && !c->pin && !c->via) - { - int o1 = line_orient (c->lines[0], c); - int o2 = line_orient (c->lines[1], c); - if (ORIENT (o1) != ORIENT (o2) - && o1 != DIAGONAL && o2 != DIAGONAL - && c->lines[0]->line->Thickness == c->lines[1]->line->Thickness) - c->miter = -1; + for (c = corners; c; c = c->next) { + if (DELETED(c)) + continue; + c->miter = 0; + if (c->n_lines == 2 && !c->via && !c->pin && !c->via) { + int o1 = line_orient(c->lines[0], c); + int o2 = line_orient(c->lines[1], c); + if (ORIENT(o1) != ORIENT(o2) + && o1 != DIAGONAL && o2 != DIAGONAL && c->lines[0]->line->Thickness == c->lines[1]->line->Thickness) + c->miter = -1; + } } - } - done = 0; - progress = 1; - while (!done && progress) - { - done = 1; - progress = 0; - for (c = corners; c; c = c->next) - { - if (DELETED (c)) - continue; - if (c->miter == -1) - { - int max = line_length (c->lines[0]); - int len = line_length (c->lines[1]); - int bloat; - int ref, dist; - corner_s *closest_corner = 0, *c2, *oc1, *oc2; - int mx = 0, my = 0, x, y; - int o1 = line_orient (c->lines[0], c); - int o2 = line_orient (c->lines[1], c); + done = 0; + progress = 1; + while (!done && progress) { + done = 1; + progress = 0; + for (c = corners; c; c = c->next) { + if (DELETED(c)) + continue; + if (c->miter == -1) { + int max = line_length(c->lines[0]); + int len = line_length(c->lines[1]); + int bloat; + int ref, dist; + corner_s *closest_corner = 0, *c2, *oc1, *oc2; + int mx = 0, my = 0, x, y; + int o1 = line_orient(c->lines[0], c); + int o2 = line_orient(c->lines[1], c); - if (c->pad || c->pin || c->via) - { - c->miter = 0; - progress = 1; - continue; - } + if (c->pad || c->pin || c->via) { + c->miter = 0; + progress = 1; + continue; + } - oc1 = other_corner (c->lines[0], c); - oc2 = other_corner (c->lines[1], c); + oc1 = other_corner(c->lines[0], c); + oc2 = other_corner(c->lines[1], c); #if 0 - if (oc1->pad) - oc1 = 0; - if (oc2->pad) - oc2 = 0; + if (oc1->pad) + oc1 = 0; + if (oc2->pad) + oc2 = 0; #endif - if ((sel && !(selected (c->lines[0]->line) - || selected (c->lines[1]->line))) - || (!sel && autorouted_only - && !(autorouted (c->lines[0]->line) - || autorouted (c->lines[1]->line)))) - { - c->miter = 0; - progress = 1; - continue; - } + if ((sel && !(selected(c->lines[0]->line) + || selected(c->lines[1]->line))) + || (!sel && autorouted_only && !(autorouted(c->lines[0]->line) + || autorouted(c->lines[1]->line)))) { + c->miter = 0; + progress = 1; + continue; + } - if (max > len) - max = len; - switch (o1) - { - case LEFT: - mx = -1; - break; - case RIGHT: - mx = 1; - break; - case UP: - my = -1; - break; - case DOWN: - my = 1; - break; - } - switch (o2) - { - case LEFT: - mx = -1; - break; - case RIGHT: - mx = 1; - break; - case UP: - my = -1; - break; - case DOWN: - my = 1; - break; - } - ref = c->x * mx + c->y * my; - dist = max; + if (max > len) + max = len; + switch (o1) { + case LEFT: + mx = -1; + break; + case RIGHT: + mx = 1; + break; + case UP: + my = -1; + break; + case DOWN: + my = 1; + break; + } + switch (o2) { + case LEFT: + mx = -1; + break; + case RIGHT: + mx = 1; + break; + case UP: + my = -1; + break; + case DOWN: + my = 1; + break; + } + ref = c->x * mx + c->y * my; + dist = max; - bloat = (c->lines[0]->line->Thickness / 2 + SB + 1) * 3 / 2; + bloat = (c->lines[0]->line->Thickness / 2 + SB + 1) * 3 / 2; - for (c2 = corners; c2; c2 = c2->next) - { - if (DELETED (c2)) - continue; - if (c2 != c && c2 != oc1 && c2 != oc2 - && c->x * mx <= c2->x * mx - && c->y * my <= c2->y * my - && c->net != c2->net - && intersecting_layers (c->layer, c2->layer)) - { - int cr = corner_radius (c2); - len = c2->x * mx + c2->y * my - ref - cr - bloat; - if (c->x != c2->x && c->y != c2->y) - len -= cr; - if (len < dist || (len == dist && c->miter != -1)) - { - dist = len; - closest_corner = c2; - } - } - } + for (c2 = corners; c2; c2 = c2->next) { + if (DELETED(c2)) + continue; + if (c2 != c && c2 != oc1 && c2 != oc2 + && c->x * mx <= c2->x * mx + && c->y * my <= c2->y * my && c->net != c2->net && intersecting_layers(c->layer, c2->layer)) { + int cr = corner_radius(c2); + len = c2->x * mx + c2->y * my - ref - cr - bloat; + if (c->x != c2->x && c->y != c2->y) + len -= cr; + if (len < dist || (len == dist && c->miter != -1)) { + dist = len; + closest_corner = c2; + } + } + } - if (closest_corner && closest_corner->miter == -1) - { - done = 0; - continue; - } + if (closest_corner && closest_corner->miter == -1) { + done = 0; + continue; + } #if 0 - if (dist < Settings.Grid) - { - c->miter = 0; - progress = 1; - continue; - } + if (dist < Settings.Grid) { + c->miter = 0; + progress = 1; + continue; + } - dist -= dist % Settings.Grid; + dist -= dist % Settings.Grid; #endif - if (dist <= 0) - { - c->miter = 0; - progress = 1; - continue; - } + if (dist <= 0) { + c->miter = 0; + progress = 1; + continue; + } - x = c->x; - y = c->y; - switch (o1) - { - case LEFT: - x -= dist; - break; - case RIGHT: - x += dist; - break; - case UP: - y -= dist; - break; - case DOWN: - y += dist; - break; + x = c->x; + y = c->y; + switch (o1) { + case LEFT: + x -= dist; + break; + case RIGHT: + x += dist; + break; + case UP: + y -= dist; + break; + case DOWN: + y += dist; + break; + } + c2 = find_corner(x, y, c->layer); + if (c2 != other_corner(c->lines[0], c)) + split_line(c->lines[0], c2); + x = c->x; + y = c->y; + switch (o2) { + case LEFT: + x -= dist; + break; + case RIGHT: + x += dist; + break; + case UP: + y -= dist; + break; + case DOWN: + y += dist; + break; + } + move_corner(c, x, y); + c->miter = 0; + c2->miter = 0; + progress = 1; + saved++; + } } - c2 = find_corner (x, y, c->layer); - if (c2 != other_corner (c->lines[0], c)) - split_line (c->lines[0], c2); - x = c->x; - y = c->y; - switch (o2) - { - case LEFT: - x -= dist; - break; - case RIGHT: - x += dist; - break; - case UP: - y -= dist; - break; - case DOWN: - y += dist; - break; - } - move_corner (c, x, y); - c->miter = 0; - c2->miter = 0; - progress = 1; - saved++; - } } - } - return saved; + return saved; } -static void -classify_corner (corner_s * c, int this_net) +static void classify_corner(corner_s * c, int this_net) { - int i; - if (c->net == this_net) - return; - c->net = this_net; - for (i = 0; i < c->n_lines; i++) - classify_corner (other_corner (c->lines[i], c), this_net); + int i; + if (c->net == this_net) + return; + c->net = this_net; + for (i = 0; i < c->n_lines; i++) + classify_corner(other_corner(c->lines[i], c), this_net); } -static void -classify_nets () +static void classify_nets() { - static int this_net = 1; - corner_s *c; + static int this_net = 1; + corner_s *c; - for (c = corners; c; c = c->next) - { - if (DELETED (c)) - continue; - if (c->net) - continue; - classify_corner (c, this_net); - this_net++; - } + for (c = corners; c; c = c->next) { + if (DELETED(c)) + continue; + if (c->net) + continue; + classify_corner(c, this_net); + this_net++; + } } #if 0 /* Not used */ -static void -dump_all () +static void dump_all() { - corner_s *c; - line_s *l; - for (c = corners; c; c = c->next) - { - if (DELETED (c)) - continue; - printf ("%p corner %d,%d layer %d net %d\n", - (void *) c, c->x, c->y, c->layer, c->net); - } - for (l = lines; l; l = l->next) - { - if (DELETED (l)) - continue; - printf ("%p line %p to %p layer %d\n", - (void *) l, (void *) (l->s), (void *) (l->e), l->layer); - } + corner_s *c; + line_s *l; + for (c = corners; c; c = c->next) { + if (DELETED(c)) + continue; + printf("%p corner %d,%d layer %d net %d\n", (void *) c, c->x, c->y, c->layer, c->net); + } + for (l = lines; l; l = l->next) { + if (DELETED(l)) + continue; + printf("%p line %p to %p layer %d\n", (void *) l, (void *) (l->s), (void *) (l->e), l->layer); + } } #endif #if 0 -static void -nudge_corner (corner_s * c, int dx, int dy, corner_s * prev_corner) +static void nudge_corner(corner_s * c, int dx, int dy, corner_s * prev_corner) { - int ox = c->x; - int oy = c->y; - int l; - if (prev_corner && (c->pin || c->pad)) - return; - move_corner (c, ox + dx, oy + dy); - for (l = 0; l < c->n_lines; l++) - { - corner_s *oc = other_corner (c->lines[l], c); - if (oc == prev_corner) - continue; - if (dx && oc->x == ox) - nudge_corner (oc, dx, 0, c); - if (dy && oc->y == oy) - nudge_corner (oc, 0, dy, c); - } + int ox = c->x; + int oy = c->y; + int l; + if (prev_corner && (c->pin || c->pad)) + return; + move_corner(c, ox + dx, oy + dy); + for (l = 0; l < c->n_lines; l++) { + corner_s *oc = other_corner(c->lines[l], c); + if (oc == prev_corner) + continue; + if (dx && oc->x == ox) + nudge_corner(oc, dx, 0, c); + if (dy && oc->y == oy) + nudge_corner(oc, 0, dy, c); + } } #endif -static line_s * -choose_example_line (corner_s * c1, corner_s * c2) +static line_s *choose_example_line(corner_s * c1, corner_s * c2) { - int ci, li; - corner_s *c[2]; - c[0] = c1; - c[1] = c2; - dprintf ("choose_example_line\n"); - for (ci = 0; ci < 2; ci++) - for (li = 0; li < c[ci]->n_lines; li++) - { - dprintf (" try[%d,%d] \033[36m<%#mD-%#mD t%#mS c%#mS f%s>\033[0m\n", - ci, li, - c[ci]->lines[li]->s->x, c[ci]->lines[li]->s->y, - c[ci]->lines[li]->e->x, c[ci]->lines[li]->e->y, - c[ci]->lines[li]->line->Thickness, - c[ci]->lines[li]->line->Clearance, - flags_to_string (c[ci]->lines[li]->line->Flags, LINE_TYPE)); - /* Pads are disqualified, as we want to mimic a trace line. */ - if (c[ci]->lines[li]->line == (LineTypePtr) c[ci]->pad) - { - dprintf (" bad, pad\n"); - continue; - } - /* Lines on layers that don't connect to the other pad are bad too. */ - if (!intersecting_layers (c[ci]->lines[li]->layer, c[1 - ci]->layer)) - { - dprintf (" bad, layers\n"); - continue; - } - dprintf (" good\n"); - return c[ci]->lines[li]; - } - dprintf ("choose_example_line: none found!\n"); - return 0; + int ci, li; + corner_s *c[2]; + c[0] = c1; + c[1] = c2; + dprintf("choose_example_line\n"); + for (ci = 0; ci < 2; ci++) + for (li = 0; li < c[ci]->n_lines; li++) { + dprintf(" try[%d,%d] \033[36m<%#mD-%#mD t%#mS c%#mS f%s>\033[0m\n", + ci, li, + c[ci]->lines[li]->s->x, c[ci]->lines[li]->s->y, + c[ci]->lines[li]->e->x, c[ci]->lines[li]->e->y, + c[ci]->lines[li]->line->Thickness, + c[ci]->lines[li]->line->Clearance, flags_to_string(c[ci]->lines[li]->line->Flags, LINE_TYPE)); + /* Pads are disqualified, as we want to mimic a trace line. */ + if (c[ci]->lines[li]->line == (LineTypePtr) c[ci]->pad) { + dprintf(" bad, pad\n"); + continue; + } + /* Lines on layers that don't connect to the other pad are bad too. */ + if (!intersecting_layers(c[ci]->lines[li]->layer, c[1 - ci]->layer)) { + dprintf(" bad, layers\n"); + continue; + } + dprintf(" good\n"); + return c[ci]->lines[li]; + } + dprintf("choose_example_line: none found!\n"); + return 0; } -static int -connect_corners (corner_s * c1, corner_s * c2) +static int connect_corners(corner_s * c1, corner_s * c2) { - int layer; - line_s *ex = choose_example_line (c1, c2); - LineType *example = ex->line; + int layer; + line_s *ex = choose_example_line(c1, c2); + LineType *example = ex->line; - dprintf - ("connect_corners \033[32m%#mD to %#mD, example line %#mD to %#mD l%d\033[0m\n", - c1->x, c1->y, c2->x, c2->y, ex->s->x, ex->s->y, ex->e->x, ex->e->y, - ex->layer); + dprintf + ("connect_corners \033[32m%#mD to %#mD, example line %#mD to %#mD l%d\033[0m\n", + c1->x, c1->y, c2->x, c2->y, ex->s->x, ex->s->y, ex->e->x, ex->e->y, ex->layer); - layer = ex->layer; + layer = ex->layer; - /* Assume c1 is the moveable one. */ - if (!(c1->pin || c1->pad || c1->via) && c1->n_lines == 1) - { - int nx, ny; - /* Extend the line */ - if (c1->lines[0]->s->x == c1->lines[0]->e->x) - nx = c1->x, ny = c2->y; - else - nx = c2->x, ny = c1->y; - if (nx != c2->x || ny != c2->y) - { - move_corner (c1, nx, ny); - new_line (c1, c2, layer, example); - return 1; + /* Assume c1 is the moveable one. */ + if (!(c1->pin || c1->pad || c1->via) && c1->n_lines == 1) { + int nx, ny; + /* Extend the line */ + if (c1->lines[0]->s->x == c1->lines[0]->e->x) + nx = c1->x, ny = c2->y; + else + nx = c2->x, ny = c1->y; + if (nx != c2->x || ny != c2->y) { + move_corner(c1, nx, ny); + new_line(c1, c2, layer, example); + return 1; + } + else { + move_corner(c1, nx, ny); + return 1; + } } - else - { - move_corner (c1, nx, ny); - return 1; + else { + corner_s *nc = find_corner(c1->x, c2->y, layer); + new_line(c1, nc, layer, example); + new_line(nc, c2, layer, example); + return 0; } - } - else - { - corner_s *nc = find_corner (c1->x, c2->y, layer); - new_line (c1, nc, layer, example); - new_line (nc, c2, layer, example); - return 0; - } } -static void -pinsnap () +static void pinsnap() { - corner_s *c; - int best_dist[MAX_LAYER + 1]; - corner_s *best_c[MAX_LAYER + 1]; - int l, got_one; - int left = 0, right = 0, top = 0, bottom = 0; - PinType *pin; - int again = 1; + corner_s *c; + int best_dist[MAX_LAYER + 1]; + corner_s *best_c[MAX_LAYER + 1]; + int l, got_one; + int left = 0, right = 0, top = 0, bottom = 0; + PinType *pin; + int again = 1; - int close = 0; - corner_s *c2; + int close = 0; + corner_s *c2; - /* Look for pins that have no connections. See if there's a corner - close by that should be connected to it. This usually happens - when the MUCS router needs to route to an off-grid pin. */ - while (again) - { - again = 0; - for (c = corners; c; c = c->next) - { - if (DELETED (c)) - continue; - if (!(c->pin || c->via || c->pad)) - continue; + /* Look for pins that have no connections. See if there's a corner + close by that should be connected to it. This usually happens + when the MUCS router needs to route to an off-grid pin. */ + while (again) { + again = 0; + for (c = corners; c; c = c->next) { + if (DELETED(c)) + continue; + if (!(c->pin || c->via || c->pad)) + continue; - pin = 0; + pin = 0; - dprintf ("\ncorner %s\n", corner_name (c)); - if (c->pin || c->via) - { - pin = c->pin ? c->pin : c->via; - close = pin->Thickness / 2; - left = c->x - close; - right = c->x + close; - bottom = c->y - close; - top = c->y + close; - } - else if (c->pad) - { - close = c->pad->Thickness / 2 + 1; - left = djmin (c->pad->Point1.X, c->pad->Point2.X) - close; - right = djmax (c->pad->Point1.X, c->pad->Point2.X) + close; - bottom = djmin (c->pad->Point1.Y, c->pad->Point2.Y) - close; - top = djmax (c->pad->Point1.Y, c->pad->Point2.Y) + close; - if (c->pad->Point1.X == c->pad->Point2.X) - { - int hy = (c->pad->Point1.Y + c->pad->Point2.Y) / 2; - dprintf ("pad y %#mS %#mS hy %#mS c %#mS\n", c->pad->Point1.Y, - c->pad->Point2.Y, hy, c->y); - if (c->y < hy) - top = hy; - else - bottom = hy + 1; - } - else - { - int hx = (c->pad->Point1.X + c->pad->Point2.X) / 2; - dprintf ("pad x %#mS %#mS hx %#mS c %#mS\n", c->pad->Point1.X, - c->pad->Point2.X, hx, c->x); - if (c->x < hx) - right = hx; - else - left = hx + 1; - } - } + dprintf("\ncorner %s\n", corner_name(c)); + if (c->pin || c->via) { + pin = c->pin ? c->pin : c->via; + close = pin->Thickness / 2; + left = c->x - close; + right = c->x + close; + bottom = c->y - close; + top = c->y + close; + } + else if (c->pad) { + close = c->pad->Thickness / 2 + 1; + left = djmin(c->pad->Point1.X, c->pad->Point2.X) - close; + right = djmax(c->pad->Point1.X, c->pad->Point2.X) + close; + bottom = djmin(c->pad->Point1.Y, c->pad->Point2.Y) - close; + top = djmax(c->pad->Point1.Y, c->pad->Point2.Y) + close; + if (c->pad->Point1.X == c->pad->Point2.X) { + int hy = (c->pad->Point1.Y + c->pad->Point2.Y) / 2; + dprintf("pad y %#mS %#mS hy %#mS c %#mS\n", c->pad->Point1.Y, c->pad->Point2.Y, hy, c->y); + if (c->y < hy) + top = hy; + else + bottom = hy + 1; + } + else { + int hx = (c->pad->Point1.X + c->pad->Point2.X) / 2; + dprintf("pad x %#mS %#mS hx %#mS c %#mS\n", c->pad->Point1.X, c->pad->Point2.X, hx, c->x); + if (c->x < hx) + right = hx; + else + left = hx + 1; + } + } - dprintf ("%s x %#mS-%#mS y %#mS-%#mS\n", corner_name (c), left, right, bottom, top); - for (l = 0; l <= max_copper_layer; l++) - { - best_dist[l] = close * 2; - best_c[l] = 0; - } - got_one = 0; - for (c2 = corners; c2; c2 = c2->next) - { - int lt; + dprintf("%s x %#mS-%#mS y %#mS-%#mS\n", corner_name(c), left, right, bottom, top); + for (l = 0; l <= max_copper_layer; l++) { + best_dist[l] = close * 2; + best_c[l] = 0; + } + got_one = 0; + for (c2 = corners; c2; c2 = c2->next) { + int lt; - if (DELETED (c2)) - continue; - lt = corner_radius (c2); - if (c2->n_lines - && c2 != c - && !(c2->pin || c2->pad || c2->via) - && intersecting_layers (c->layer, c2->layer) - && c2->x >= left - lt - && c2->x <= right + lt - && c2->y >= bottom - lt && c2->y <= top + lt) - { - int d = dist (c->x, c->y, c2->x, c2->y); - if (pin && d > pin->Thickness / 2 + lt) - continue; - if (c2->n_lines == 1) - { - got_one++; - dprintf ("found orphan %s vs %s\n", corner_name (c2), - corner_name (c)); - connect_corners (c, c2); - again = 1; - continue; - } - if (best_c[c2->layer] == 0 - || c2->n_lines < best_c[c2->layer]->n_lines - || (d < best_dist[c2->layer] - && c2->n_lines <= best_c[c2->layer]->n_lines)) - { - best_dist[c2->layer] = d; - best_c[c2->layer] = c2; - dprintf ("layer %d best now %s\n", c2->layer, - corner_name (c2)); - } + if (DELETED(c2)) + continue; + lt = corner_radius(c2); + if (c2->n_lines && c2 != c && !(c2->pin || c2->pad || c2->via) + && intersecting_layers(c->layer, c2->layer) + && c2->x >= left - lt && c2->x <= right + lt && c2->y >= bottom - lt && c2->y <= top + lt) { + int d = dist(c->x, c->y, c2->x, c2->y); + if (pin && d > pin->Thickness / 2 + lt) + continue; + if (c2->n_lines == 1) { + got_one++; + dprintf("found orphan %s vs %s\n", corner_name(c2), corner_name(c)); + connect_corners(c, c2); + again = 1; + continue; + } + if (best_c[c2->layer] == 0 || c2->n_lines < best_c[c2->layer]->n_lines || (d < best_dist[c2->layer] + && c2->n_lines <= + best_c[c2->layer]->n_lines)) { + best_dist[c2->layer] = d; + best_c[c2->layer] = c2; + dprintf("layer %d best now %s\n", c2->layer, corner_name(c2)); + } + } + if (!got_one && c->n_lines == (c->pad ? 1 : 0)) { + for (l = 0; l <= max_copper_layer; l++) + if (best_c[l]) + dprintf("best[%d] = %s\n", l, corner_name(best_c[l])); + for (l = 0; l <= max_copper_layer; l++) + if (best_c[l]) { + dprintf("move %s to %s\n", corner_name(best_c[l]), corner_name(c)); + connect_corners(best_c[l], c); + again = 1; + continue; + } + } + } } - if (!got_one && c->n_lines == (c->pad ? 1 : 0)) - { - for (l = 0; l <= max_copper_layer; l++) - if (best_c[l]) - dprintf ("best[%d] = %s\n", l, corner_name (best_c[l])); - for (l = 0; l <= max_copper_layer; l++) - if (best_c[l]) - { - dprintf ("move %s to %s\n", corner_name (best_c[l]), - corner_name (c)); - connect_corners (best_c[l], c); - again = 1; - continue; - } - } - } } - } - /* Now look for line ends that don't connect, see if they need to be - extended to intersect another line. */ - for (c = corners; c; c = c->next) - { - line_s *l, *t; - int lo; + /* Now look for line ends that don't connect, see if they need to be + extended to intersect another line. */ + for (c = corners; c; c = c->next) { + line_s *l, *t; + int lo; - if (DELETED (c)) - continue; - if (c->pin || c->via || c->pad) - continue; - if (c->n_lines != 1) - continue; + if (DELETED(c)) + continue; + if (c->pin || c->via || c->pad) + continue; + if (c->n_lines != 1) + continue; - l = c->lines[0]; - lo = line_orient (l, c); - dprintf ("line end %#mD orient %d\n", c->x, c->y, lo); + l = c->lines[0]; + lo = line_orient(l, c); + dprintf("line end %#mD orient %d\n", c->x, c->y, lo); - for (t = lines; t; t = t->next) - { - if (DELETED (t)) - continue; - if (t->layer != c->lines[0]->layer) - continue; - switch (lo) /* remember, orient is for the line relative to the corner */ - { - case LEFT: - if (t->s->x == t->e->x - && c->x < t->s->x - && t->s->x < - c->x + (l->line->Thickness + t->line->Thickness) / 2 - && ((t->s->y < c->y && c->y < t->e->y) - || (t->e->y < c->y && c->y < t->s->y))) - { - dprintf ("found %#mD - %#mD\n", t->s->x, t->s->y, t->e->x, t->e->y); - move_corner (c, t->s->x, c->y); + for (t = lines; t; t = t->next) { + if (DELETED(t)) + continue; + if (t->layer != c->lines[0]->layer) + continue; + switch (lo) { /* remember, orient is for the line relative to the corner */ + case LEFT: + if (t->s->x == t->e->x + && c->x < t->s->x + && t->s->x < c->x + (l->line->Thickness + t->line->Thickness) / 2 && ((t->s->y < c->y && c->y < t->e->y) + || (t->e->y < c->y && c->y < t->s->y))) { + dprintf("found %#mD - %#mD\n", t->s->x, t->s->y, t->e->x, t->e->y); + move_corner(c, t->s->x, c->y); + } + break; + case RIGHT: + if (t->s->x == t->e->x + && c->x > t->s->x + && t->s->x > c->x - (l->line->Thickness + t->line->Thickness) / 2 && ((t->s->y < c->y && c->y < t->e->y) + || (t->e->y < c->y && c->y < t->s->y))) { + dprintf("found %#mD - %#mD\n", t->s->x, t->s->y, t->e->x, t->e->y); + move_corner(c, t->s->x, c->y); + } + break; + case UP: + if (t->s->y == t->e->y + && c->y < t->s->y + && t->s->y < c->y + (l->line->Thickness + t->line->Thickness) / 2 && ((t->s->x < c->x && c->x < t->e->x) + || (t->e->x < c->x && c->x < t->s->x))) { + dprintf("found %#mD - %#mD\n", t->s->x, t->s->y, t->e->x, t->e->y); + move_corner(c, c->x, t->s->y); + } + break; + case DOWN: + if (t->s->y == t->e->y + && c->y > t->s->y + && t->s->y > c->y - (l->line->Thickness + t->line->Thickness) / 2 && ((t->s->x < c->x && c->x < t->e->x) + || (t->e->x < c->x && c->x < t->s->x))) { + dprintf("found %#mD - %#mD\n", t->s->x, t->s->y, t->e->x, t->e->y); + move_corner(c, c->x, t->s->y); + } + break; + } } - break; - case RIGHT: - if (t->s->x == t->e->x - && c->x > t->s->x - && t->s->x > - c->x - (l->line->Thickness + t->line->Thickness) / 2 - && ((t->s->y < c->y && c->y < t->e->y) - || (t->e->y < c->y && c->y < t->s->y))) - { - dprintf ("found %#mD - %#mD\n", t->s->x, t->s->y, t->e->x, t->e->y); - move_corner (c, t->s->x, c->y); - } - break; - case UP: - if (t->s->y == t->e->y - && c->y < t->s->y - && t->s->y < - c->y + (l->line->Thickness + t->line->Thickness) / 2 - && ((t->s->x < c->x && c->x < t->e->x) - || (t->e->x < c->x && c->x < t->s->x))) - { - dprintf ("found %#mD - %#mD\n", t->s->x, t->s->y, t->e->x, t->e->y); - move_corner (c, c->x, t->s->y); - } - break; - case DOWN: - if (t->s->y == t->e->y - && c->y > t->s->y - && t->s->y > - c->y - (l->line->Thickness + t->line->Thickness) / 2 - && ((t->s->x < c->x && c->x < t->e->x) - || (t->e->x < c->x && c->x < t->s->x))) - { - dprintf ("found %#mD - %#mD\n", t->s->x, t->s->y, t->e->x, t->e->y); - move_corner (c, c->x, t->s->y); - } - break; - } } - } } -static int -pad_orient (PadType * p) +static int pad_orient(PadType * p) { - if (p->Point1.X == p->Point2.X) - return O_VERT; - if (p->Point1.Y == p->Point2.Y) - return O_HORIZ; - return DIAGONAL; + if (p->Point1.X == p->Point2.X) + return O_VERT; + if (p->Point1.Y == p->Point2.Y) + return O_HORIZ; + return DIAGONAL; } -static void -padcleaner () +static void padcleaner() { - line_s *l, *nextl; - int close; - rect_s r; + line_s *l, *nextl; + int close; + rect_s r; - dprintf ("\ndj: padcleaner\n"); - for (l = lines; l; l = nextl) - { - nextl = l->next; + dprintf("\ndj: padcleaner\n"); + for (l = lines; l; l = nextl) { + nextl = l->next; - if (l->is_pad) - continue; + if (l->is_pad) + continue; - if (DELETED (l)) - continue; + if (DELETED(l)) + continue; - dprintf ("dj: line %p\n", (void *) l); - check (0, l); + dprintf("dj: line %p\n", (void *) l); + check(0, l); - if (l->s->pad && l->s->pad == l->e->pad) - continue; + if (l->s->pad && l->s->pad == l->e->pad) + continue; - ALLPAD_LOOP (PCB->Data); - { - int layerflag = - TEST_FLAG (ONSOLDERFLAG, element) ? LT_SOLDER : LT_COMPONENT; + ALLPAD_LOOP(PCB->Data); + { + int layerflag = TEST_FLAG(ONSOLDERFLAG, element) ? LT_SOLDER : LT_COMPONENT; - if (layer_type[l->layer] != layerflag) - continue; + if (layer_type[l->layer] != layerflag) + continue; - empty_rect (&r); - close = pad->Thickness / 2 + 1; - add_point_to_rect (&r, pad->Point1.X, pad->Point1.Y, close - SB / 2); - add_point_to_rect (&r, pad->Point2.X, pad->Point2.Y, close - SB / 2); - if (pin_in_rect (&r, l->s->x, l->s->y, 0) - && pin_in_rect (&r, l->e->x, l->e->y, 0) - && ORIENT (line_orient (l, 0)) == pad_orient (pad)) - { - dprintf - ("padcleaner %#mD-%#mD %#mS vs line %#mD-%#mD %#mS\n", - pad->Point1.X, pad->Point1.Y, pad->Point2.X, pad->Point2.Y, - pad->Thickness, l->s->x, l->s->y, l->e->x, l->e->y, - l->line->Thickness); - remove_line (l); - goto next_line; - } + empty_rect(&r); + close = pad->Thickness / 2 + 1; + add_point_to_rect(&r, pad->Point1.X, pad->Point1.Y, close - SB / 2); + add_point_to_rect(&r, pad->Point2.X, pad->Point2.Y, close - SB / 2); + if (pin_in_rect(&r, l->s->x, l->s->y, 0) + && pin_in_rect(&r, l->e->x, l->e->y, 0) + && ORIENT(line_orient(l, 0)) == pad_orient(pad)) { + dprintf + ("padcleaner %#mD-%#mD %#mS vs line %#mD-%#mD %#mS\n", + pad->Point1.X, pad->Point1.Y, pad->Point2.X, pad->Point2.Y, + pad->Thickness, l->s->x, l->s->y, l->e->x, l->e->y, l->line->Thickness); + remove_line(l); + goto next_line; + } + } + ENDALL_LOOP; + next_line:; } - ENDALL_LOOP; - next_line:; - } } -static void -grok_layer_groups () +static void grok_layer_groups() { - int i, j, f; - LayerGroupType *l = &(PCB->LayerGroups); + int i, j, f; + LayerGroupType *l = &(PCB->LayerGroups); - solder_layer = component_layer = -1; - for (i = 0; i < max_copper_layer; i++) - { - layer_type[i] = 0; - layer_groupings[i] = 0; - } - for (i = 0; i < max_group; i++) - { - f = 0; - for (j = 0; j < l->Number[i]; j++) - { - if (l->Entries[i][j] == solder_silk_layer) - f |= LT_SOLDER; - if (l->Entries[i][j] == component_silk_layer) - f |= LT_COMPONENT; + solder_layer = component_layer = -1; + for (i = 0; i < max_copper_layer; i++) { + layer_type[i] = 0; + layer_groupings[i] = 0; } - for (j = 0; j < l->Number[i]; j++) - { - if (l->Entries[i][j] >= 0 && l->Entries[i][j] < max_copper_layer) - { - layer_type[l->Entries[i][j]] |= f; - layer_groupings[l->Entries[i][j]] = i; - if (solder_layer == -1 && f == LT_SOLDER) - solder_layer = l->Entries[i][j]; - if (component_layer == -1 && f == LT_COMPONENT) - component_layer = l->Entries[i][j]; - } + for (i = 0; i < max_group; i++) { + f = 0; + for (j = 0; j < l->Number[i]; j++) { + if (l->Entries[i][j] == solder_silk_layer) + f |= LT_SOLDER; + if (l->Entries[i][j] == component_silk_layer) + f |= LT_COMPONENT; + } + for (j = 0; j < l->Number[i]; j++) { + if (l->Entries[i][j] >= 0 && l->Entries[i][j] < max_copper_layer) { + layer_type[l->Entries[i][j]] |= f; + layer_groupings[l->Entries[i][j]] = i; + if (solder_layer == -1 && f == LT_SOLDER) + solder_layer = l->Entries[i][j]; + if (component_layer == -1 && f == LT_COMPONENT) + component_layer = l->Entries[i][j]; + } + } } - } } static const char djopt_syntax[] = - "djopt(debumpify|unjaggy|simple|vianudge|viatrim|orthopull)\n" - "djopt(auto) - all of the above\n" - "djopt(miter)"; + "djopt(debumpify|unjaggy|simple|vianudge|viatrim|orthopull)\n" "djopt(auto) - all of the above\n" "djopt(miter)"; -static const char djopt_help[] = - "Perform various optimizations on the current board."; +static const char djopt_help[] = "Perform various optimizations on the current board."; /* %start-doc actions djopt @@ -2913,151 +2579,143 @@ %end-doc */ -static int -ActionDJopt (int argc, char **argv, Coord x, Coord y) +static int ActionDJopt(int argc, char **argv, Coord x, Coord y) { - char *arg = argc > 0 ? argv[0] : 0; - int layn, saved = 0; - corner_s *c; + char *arg = argc > 0 ? argv[0] : 0; + int layn, saved = 0; + corner_s *c; #ifdef ENDIF - SwitchDrawingWindow (PCB->Zoom, Output.drawing_area->window, - Settings.ShowSolderSide, false); + SwitchDrawingWindow(PCB->Zoom, Output.drawing_area->window, Settings.ShowSolderSide, false); #endif - hid_action("Busy"); + hid_action("Busy"); - lines = 0; - corners = 0; + lines = 0; + corners = 0; - grok_layer_groups (); + grok_layer_groups(); - ELEMENT_LOOP (PCB->Data); - PIN_LOOP (element); - { - c = find_corner (pin->X, pin->Y, -1); - c->pin = pin; - } - END_LOOP; - PAD_LOOP (element); - { - int layern = - TEST_FLAG (ONSOLDERFLAG, pad) ? solder_layer : component_layer; - line_s *ls = (line_s *) malloc (sizeof (line_s)); - ls->next = lines; - lines = ls; - ls->is_pad = 1; - ls->s = find_corner (pad->Point1.X, pad->Point1.Y, layern); - ls->s->pad = pad; - ls->e = find_corner (pad->Point2.X, pad->Point2.Y, layern); - ls->e->pad = pad; - ls->layer = layern; - ls->line = (LineTypePtr) pad; - add_line_to_corner (ls, ls->s); - add_line_to_corner (ls, ls->e); + ELEMENT_LOOP(PCB->Data); + PIN_LOOP(element); + { + c = find_corner(pin->X, pin->Y, -1); + c->pin = pin; + } + END_LOOP; + PAD_LOOP(element); + { + int layern = TEST_FLAG(ONSOLDERFLAG, pad) ? solder_layer : component_layer; + line_s *ls = (line_s *) malloc(sizeof(line_s)); + ls->next = lines; + lines = ls; + ls->is_pad = 1; + ls->s = find_corner(pad->Point1.X, pad->Point1.Y, layern); + ls->s->pad = pad; + ls->e = find_corner(pad->Point2.X, pad->Point2.Y, layern); + ls->e->pad = pad; + ls->layer = layern; + ls->line = (LineTypePtr) pad; + add_line_to_corner(ls, ls->s); + add_line_to_corner(ls, ls->e); - } - END_LOOP; - END_LOOP; - VIA_LOOP (PCB->Data); - /* hace don't mess with vias that have thermals */ - /* but then again don't bump into them - if (!TEST_FLAG(ALLTHERMFLAGS, via)) - */ - { - c = find_corner (via->X, via->Y, -1); - c->via = via; - } - END_LOOP; - check (0, 0); + } + END_LOOP; + END_LOOP; + VIA_LOOP(PCB->Data); + /* hace don't mess with vias that have thermals */ + /* but then again don't bump into them + if (!TEST_FLAG(ALLTHERMFLAGS, via)) + */ + { + c = find_corner(via->X, via->Y, -1); + c->via = via; + } + END_LOOP; + check(0, 0); - if (NSTRCMP (arg, "splitlines") == 0) - { - if (canonicalize_lines ()) - IncrementUndoSerialNumber (); - return 0; - } + if (NSTRCMP(arg, "splitlines") == 0) { + if (canonicalize_lines()) + IncrementUndoSerialNumber(); + return 0; + } - for (layn = 0; layn < max_copper_layer; layn++) - { - LayerType *layer = LAYER_PTR (layn); + for (layn = 0; layn < max_copper_layer; layn++) { + LayerType *layer = LAYER_PTR(layn); - LINE_LOOP (layer); - { - line_s *ls; + LINE_LOOP(layer); + { + line_s *ls; - if(autorouted_only && !autorouted (line)) - continue; + if (autorouted_only && !autorouted(line)) + continue; - /* don't mess with thermals */ - if (TEST_FLAG (USETHERMALFLAG, line)) - continue; + /* don't mess with thermals */ + if (TEST_FLAG(USETHERMALFLAG, line)) + continue; - if (line->Point1.X == line->Point2.X && - line->Point1.Y == line->Point2.Y) - { - RemoveLine (layer, line); - continue; - } + if (line->Point1.X == line->Point2.X && line->Point1.Y == line->Point2.Y) { + RemoveLine(layer, line); + continue; + } - ls = (line_s *) malloc (sizeof (line_s)); - ls->next = lines; - lines = ls; - ls->is_pad = 0; - ls->s = find_corner (line->Point1.X, line->Point1.Y, layn); - ls->e = find_corner (line->Point2.X, line->Point2.Y, layn); - ls->line = line; - add_line_to_corner (ls, ls->s); - add_line_to_corner (ls, ls->e); - ls->layer = layn; + ls = (line_s *) malloc(sizeof(line_s)); + ls->next = lines; + lines = ls; + ls->is_pad = 0; + ls->s = find_corner(line->Point1.X, line->Point1.Y, layn); + ls->e = find_corner(line->Point2.X, line->Point2.Y, layn); + ls->line = line; + add_line_to_corner(ls, ls->s); + add_line_to_corner(ls, ls->e); + ls->layer = layn; + } + END_LOOP; } - END_LOOP; - } - check (0, 0); - pinsnap (); - canonicalize_lines (); - check (0, 0); - classify_nets (); - /*dump_all(); */ - check (0, 0); + check(0, 0); + pinsnap(); + canonicalize_lines(); + check(0, 0); + classify_nets(); + /*dump_all(); */ + check(0, 0); - if (NSTRCMP (arg, "debumpify") == 0) - saved += debumpify (); - else if (NSTRCMP (arg, "unjaggy") == 0) - saved += unjaggy (); - else if (NSTRCMP (arg, "simple") == 0) - saved += simple_optimizations (); - else if (NSTRCMP (arg, "vianudge") == 0) - saved += vianudge (); - else if (NSTRCMP (arg, "viatrim") == 0) - saved += viatrim (); - else if (NSTRCMP (arg, "orthopull") == 0) - saved += orthopull (); - else if (NSTRCMP (arg, "auto") == 0) - saved += automagic (); - else if (NSTRCMP (arg, "miter") == 0) - saved += miter (); - else - { - printf ("unknown command: %s\n", arg); - return 1; - } + if (NSTRCMP(arg, "debumpify") == 0) + saved += debumpify(); + else if (NSTRCMP(arg, "unjaggy") == 0) + saved += unjaggy(); + else if (NSTRCMP(arg, "simple") == 0) + saved += simple_optimizations(); + else if (NSTRCMP(arg, "vianudge") == 0) + saved += vianudge(); + else if (NSTRCMP(arg, "viatrim") == 0) + saved += viatrim(); + else if (NSTRCMP(arg, "orthopull") == 0) + saved += orthopull(); + else if (NSTRCMP(arg, "auto") == 0) + saved += automagic(); + else if (NSTRCMP(arg, "miter") == 0) + saved += miter(); + else { + printf("unknown command: %s\n", arg); + return 1; + } - padcleaner (); + padcleaner(); - check (0, 0); - if (saved) - IncrementUndoSerialNumber (); - return 0; + check(0, 0); + if (saved) + IncrementUndoSerialNumber(); + return 0; } HID_Action djopt_action_list[] = { - {"djopt", 0, ActionDJopt, - djopt_help, djopt_syntax} - , - {"OptAutoOnly", 0, djopt_set_auto_only, - djopt_sao_help, djopt_sao_syntax} + {"djopt", 0, ActionDJopt, + djopt_help, djopt_syntax} + , + {"OptAutoOnly", 0, djopt_set_auto_only, + djopt_sao_help, djopt_sao_syntax} }; -REGISTER_ACTIONS (djopt_action_list) +REGISTER_ACTIONS(djopt_action_list) Index: trunk/src/djopt.h =================================================================== --- trunk/src/djopt.h (revision 1021) +++ trunk/src/djopt.h (revision 1022) @@ -31,6 +31,6 @@ #include "global.h" -int ActionDJopt (int, char **, Coord, Coord); -int djopt_set_auto_only (int, char **, Coord, Coord); +int ActionDJopt(int, char **, Coord, Coord); +int djopt_set_auto_only(int, char **, Coord, Coord); #endif Index: trunk/src/draw.c =================================================================== --- trunk/src/draw.c (revision 1021) +++ trunk/src/draw.c (revision 1022) @@ -59,7 +59,7 @@ #define MAXINT (((unsigned int)(~0))>>1) #endif -RCSID ("$Id$"); +RCSID("$Id$"); #define SMALL_SMALL_TEXT_SIZE 0 #define SMALL_TEXT_SIZE 1 @@ -71,7 +71,7 @@ /* --------------------------------------------------------------------------- * some local identifiers */ -static BoxType Block = {MAXINT, MAXINT, -MAXINT, -MAXINT}; +static BoxType Block = { MAXINT, MAXINT, -MAXINT, -MAXINT }; static int doing_pinout = 0; static bool doing_assy = false; @@ -79,36 +79,33 @@ /* --------------------------------------------------------------------------- * some local prototypes */ -static void DrawEverything (const BoxType *); -static void DrawPPV (int group, const BoxType *); -static void DrawLayerGroup (int, const BoxType *); -static void AddPart (void *); -static void SetPVColor (PinTypePtr, int); -static void DrawEMark (ElementTypePtr, Coord, Coord, bool); -static void DrawMask (int side, const BoxType *); -static void DrawPaste (int side, const BoxType *); -static void DrawRats (const BoxType *); -static void DrawSilk (int side, const BoxType *); +static void DrawEverything(const BoxType *); +static void DrawPPV(int group, const BoxType *); +static void DrawLayerGroup(int, const BoxType *); +static void AddPart(void *); +static void SetPVColor(PinTypePtr, int); +static void DrawEMark(ElementTypePtr, Coord, Coord, bool); +static void DrawMask(int side, const BoxType *); +static void DrawPaste(int side, const BoxType *); +static void DrawRats(const BoxType *); +static void DrawSilk(int side, const BoxType *); -static void -LightenColor(const char *orig, char buf[8], double factor) +static void LightenColor(const char *orig, char buf[8], double factor) { - unsigned int r, g, b; + unsigned int r, g, b; - if (orig[0] == '#') - { - sscanf(&orig[1], "%2x%2x%2x", &r, &g, &b); - r = MIN(255, r * factor); - g = MIN(255, g * factor); - b = MIN(255, b * factor); - } - else - { - r = 0xff; - g = 0xff; - b = 0xff; - } - snprintf(buf, sizeof("#XXXXXX"), "#%02x%02x%02x", r, g, b); + if (orig[0] == '#') { + sscanf(&orig[1], "%2x%2x%2x", &r, &g, &b); + r = MIN(255, r * factor); + g = MIN(255, g * factor); + b = MIN(255, b * factor); + } + else { + r = 0xff; + g = 0xff; + b = 0xff; + } + snprintf(buf, sizeof("#XXXXXX"), "#%02x%02x%02x", r, g, b); } @@ -115,595 +112,533 @@ /*-------------------------------------------------------------------------------------- * setup color for pin or via */ -static void -SetPVColor (PinTypePtr Pin, int Type) +static void SetPVColor(PinTypePtr Pin, int Type) { - char *color; - char buf[sizeof("#XXXXXX")]; + char *color; + char buf[sizeof("#XXXXXX")]; - if (Type == VIA_TYPE) - { - if (!doing_pinout - && TEST_FLAG (WARNFLAG | SELECTEDFLAG | FOUNDFLAG, Pin)) - { - if (TEST_FLAG (WARNFLAG, Pin)) - color = PCB->WarnColor; - else if (TEST_FLAG (SELECTEDFLAG, Pin)) - color = PCB->ViaSelectedColor; - else - color = PCB->ConnectedColor; + if (Type == VIA_TYPE) { + if (!doing_pinout && TEST_FLAG(WARNFLAG | SELECTEDFLAG | FOUNDFLAG, Pin)) { + if (TEST_FLAG(WARNFLAG, Pin)) + color = PCB->WarnColor; + else if (TEST_FLAG(SELECTEDFLAG, Pin)) + color = PCB->ViaSelectedColor; + else + color = PCB->ConnectedColor; - if (TEST_FLAG(ONPOINTFLAG, Pin)) - { - assert(color != NULL); - LightenColor(color, buf, 1.75); - color = buf; - } + if (TEST_FLAG(ONPOINTFLAG, Pin)) { + assert(color != NULL); + LightenColor(color, buf, 1.75); + color = buf; + } + } + else + color = PCB->ViaColor; } - else - color = PCB->ViaColor; - } - else - { - if (!doing_pinout - && TEST_FLAG (WARNFLAG | SELECTEDFLAG | FOUNDFLAG, Pin)) - { - if (TEST_FLAG (WARNFLAG, Pin)) - color = PCB->WarnColor; - else if (TEST_FLAG (SELECTEDFLAG, Pin)) - color = PCB->PinSelectedColor; - else - color = PCB->ConnectedColor; + else { + if (!doing_pinout && TEST_FLAG(WARNFLAG | SELECTEDFLAG | FOUNDFLAG, Pin)) { + if (TEST_FLAG(WARNFLAG, Pin)) + color = PCB->WarnColor; + else if (TEST_FLAG(SELECTEDFLAG, Pin)) + color = PCB->PinSelectedColor; + else + color = PCB->ConnectedColor; - if (TEST_FLAG(ONPOINTFLAG, Pin)) - { - assert(color != NULL); - LightenColor(color, buf, 1.75); - color = buf; - } + if (TEST_FLAG(ONPOINTFLAG, Pin)) { + assert(color != NULL); + LightenColor(color, buf, 1.75); + color = buf; + } + } + else + color = PCB->PinColor; } - else - color = PCB->PinColor; - } - gui->set_color (Output.fgGC, color); + gui->set_color(Output.fgGC, color); } /*--------------------------------------------------------------------------- * Adds the update rect to the update region */ -static void -AddPart (void *b) +static void AddPart(void *b) { - BoxType *box = (BoxType *) b; + BoxType *box = (BoxType *) b; - Block.X1 = MIN (Block.X1, box->X1); - Block.X2 = MAX (Block.X2, box->X2); - Block.Y1 = MIN (Block.Y1, box->Y1); - Block.Y2 = MAX (Block.Y2, box->Y2); + Block.X1 = MIN(Block.X1, box->X1); + Block.X2 = MAX(Block.X2, box->X2); + Block.Y1 = MIN(Block.Y1, box->Y1); + Block.Y2 = MAX(Block.Y2, box->Y2); } /* * initiate the actual redrawing of the updated area */ -void -Draw (void) +void Draw(void) { - if (Block.X1 <= Block.X2 && Block.Y1 <= Block.Y2) - gui->invalidate_lr (Block.X1, Block.X2, Block.Y1, Block.Y2); + if (Block.X1 <= Block.X2 && Block.Y1 <= Block.Y2) + gui->invalidate_lr(Block.X1, Block.X2, Block.Y1, Block.Y2); - /* shrink the update block */ - Block.X1 = Block.Y1 = MAXINT; - Block.X2 = Block.Y2 = -MAXINT; + /* shrink the update block */ + Block.X1 = Block.Y1 = MAXINT; + Block.X2 = Block.Y2 = -MAXINT; } /* ---------------------------------------------------------------------- * redraws all the data by the event handlers */ -void -Redraw (void) +void Redraw(void) { - gui->invalidate_all (); + gui->invalidate_all(); } -static void -_draw_pv_name (PinType *pv) +static void _draw_pv_name(PinType * pv) { - BoxType box; - bool vert; - TextType text; + BoxType box; + bool vert; + TextType text; char buff[128], *pn; - if (!pv->Name || !pv->Name[0]) - pn = EMPTY (pv->Number); - else - pn = EMPTY (TEST_FLAG (SHOWNUMBERFLAG, PCB) ? pv->Number : pv->Name); + if (!pv->Name || !pv->Name[0]) + pn = EMPTY(pv->Number); + else + pn = EMPTY(TEST_FLAG(SHOWNUMBERFLAG, PCB) ? pv->Number : pv->Name); - if (GET_INTCONN(pv) > 0) - snprintf(buff, sizeof(buff), "%s[%d]", pn, GET_INTCONN(pv)); - else - strcpy(buff, pn); - text.TextString = buff; + if (GET_INTCONN(pv) > 0) + snprintf(buff, sizeof(buff), "%s[%d]", pn, GET_INTCONN(pv)); + else + strcpy(buff, pn); + text.TextString = buff; - vert = TEST_FLAG (EDGE2FLAG, pv); + vert = TEST_FLAG(EDGE2FLAG, pv); - if (vert) - { - box.X1 = pv->X - pv->Thickness / 2 + Settings.PinoutTextOffsetY; - box.Y1 = pv->Y - pv->DrillingHole / 2 - Settings.PinoutTextOffsetX; - } - else - { - box.X1 = pv->X + pv->DrillingHole / 2 + Settings.PinoutTextOffsetX; - box.Y1 = pv->Y - pv->Thickness / 2 + Settings.PinoutTextOffsetY; - } + if (vert) { + box.X1 = pv->X - pv->Thickness / 2 + Settings.PinoutTextOffsetY; + box.Y1 = pv->Y - pv->DrillingHole / 2 - Settings.PinoutTextOffsetX; + } + else { + box.X1 = pv->X + pv->DrillingHole / 2 + Settings.PinoutTextOffsetX; + box.Y1 = pv->Y - pv->Thickness / 2 + Settings.PinoutTextOffsetY; + } - gui->set_color (Output.fgGC, PCB->PinNameColor); + gui->set_color(Output.fgGC, PCB->PinNameColor); - text.Flags = NoFlags (); - /* Set font height to approx 56% of pin thickness */ - text.Scale = 56 * pv->Thickness / FONT_CAPHEIGHT; - text.X = box.X1; - text.Y = box.Y1; - text.Direction = vert ? 1 : 0; + text.Flags = NoFlags(); + /* Set font height to approx 56% of pin thickness */ + text.Scale = 56 * pv->Thickness / FONT_CAPHEIGHT; + text.X = box.X1; + text.Y = box.Y1; + text.Direction = vert ? 1 : 0; - if (gui->gui) - doing_pinout++; - DrawTextLowLevel (&text, 0); - if (gui->gui) - doing_pinout--; + if (gui->gui) + doing_pinout++; + DrawTextLowLevel(&text, 0); + if (gui->gui) + doing_pinout--; } -static void -_draw_pv (PinTypePtr pv, bool draw_hole) +static void _draw_pv(PinTypePtr pv, bool draw_hole) { - if (TEST_FLAG (THINDRAWFLAG, PCB)) - gui->thindraw_pcb_pv (Output.fgGC, Output.fgGC, pv, draw_hole, false); - else - gui->fill_pcb_pv (Output.fgGC, Output.bgGC, pv, draw_hole, false); + if (TEST_FLAG(THINDRAWFLAG, PCB)) + gui->thindraw_pcb_pv(Output.fgGC, Output.fgGC, pv, draw_hole, false); + else + gui->fill_pcb_pv(Output.fgGC, Output.bgGC, pv, draw_hole, false); - if (!TEST_FLAG (HOLEFLAG, pv) && TEST_FLAG (DISPLAYNAMEFLAG, pv)) - _draw_pv_name (pv); + if (!TEST_FLAG(HOLEFLAG, pv) && TEST_FLAG(DISPLAYNAMEFLAG, pv)) + _draw_pv_name(pv); } -static void -draw_pin (PinTypePtr pin, bool draw_hole) +static void draw_pin(PinTypePtr pin, bool draw_hole) { - SetPVColor (pin, PIN_TYPE); - _draw_pv (pin, draw_hole); + SetPVColor(pin, PIN_TYPE); + _draw_pv(pin, draw_hole); } -static int -pin_callback (const BoxType * b, void *cl) +static int pin_callback(const BoxType * b, void *cl) { - draw_pin ((PinType *)b, false); - return 1; + draw_pin((PinType *) b, false); + return 1; } -static void -draw_via (PinTypePtr via, bool draw_hole) +static void draw_via(PinTypePtr via, bool draw_hole) { - SetPVColor (via, VIA_TYPE); - _draw_pv (via, draw_hole); + SetPVColor(via, VIA_TYPE); + _draw_pv(via, draw_hole); } -static int -via_callback (const BoxType * b, void *cl) +static int via_callback(const BoxType * b, void *cl) { - draw_via ((PinType *)b, false); - return 1; + draw_via((PinType *) b, false); + return 1; } -static void -draw_pad_name (PadType *pad) +static void draw_pad_name(PadType * pad) { - BoxType box; - bool vert; - TextType text; + BoxType box; + bool vert; + TextType text; char buff[128], *pn; - if (!pad->Name || !pad->Name[0]) - pn = EMPTY (pad->Number); - else - pn = EMPTY (TEST_FLAG (SHOWNUMBERFLAG, PCB) ? pad->Number : pad->Name); + if (!pad->Name || !pad->Name[0]) + pn = EMPTY(pad->Number); + else + pn = EMPTY(TEST_FLAG(SHOWNUMBERFLAG, PCB) ? pad->Number : pad->Name); - if (GET_INTCONN(pad) > 0) - snprintf(buff, sizeof(buff), "%s[%d]", pn, GET_INTCONN(pad)); - else - strcpy(buff, pn); - text.TextString = buff; + if (GET_INTCONN(pad) > 0) + snprintf(buff, sizeof(buff), "%s[%d]", pn, GET_INTCONN(pad)); + else + strcpy(buff, pn); + text.TextString = buff; - /* should text be vertical ? */ - vert = (pad->Point1.X == pad->Point2.X); + /* should text be vertical ? */ + vert = (pad->Point1.X == pad->Point2.X); - if (vert) - { - box.X1 = pad->Point1.X - pad->Thickness / 2; - box.Y1 = MAX (pad->Point1.Y, pad->Point2.Y) + pad->Thickness / 2; - box.X1 += Settings.PinoutTextOffsetY; - box.Y1 -= Settings.PinoutTextOffsetX; - } - else - { - box.X1 = MIN (pad->Point1.X, pad->Point2.X) - pad->Thickness / 2; - box.Y1 = pad->Point1.Y - pad->Thickness / 2; - box.X1 += Settings.PinoutTextOffsetX; - box.Y1 += Settings.PinoutTextOffsetY; - } + if (vert) { + box.X1 = pad->Point1.X - pad->Thickness / 2; + box.Y1 = MAX(pad->Point1.Y, pad->Point2.Y) + pad->Thickness / 2; + box.X1 += Settings.PinoutTextOffsetY; + box.Y1 -= Settings.PinoutTextOffsetX; + } + else { + box.X1 = MIN(pad->Point1.X, pad->Point2.X) - pad->Thickness / 2; + box.Y1 = pad->Point1.Y - pad->Thickness / 2; + box.X1 += Settings.PinoutTextOffsetX; + box.Y1 += Settings.PinoutTextOffsetY; + } - gui->set_color (Output.fgGC, PCB->PinNameColor); + gui->set_color(Output.fgGC, PCB->PinNameColor); - text.Flags = NoFlags (); - /* Set font height to approx 90% of pin thickness */ - text.Scale = 90 * pad->Thickness / FONT_CAPHEIGHT; - text.X = box.X1; - text.Y = box.Y1; - text.Direction = vert ? 1 : 0; + text.Flags = NoFlags(); + /* Set font height to approx 90% of pin thickness */ + text.Scale = 90 * pad->Thickness / FONT_CAPHEIGHT; + text.X = box.X1; + text.Y = box.Y1; + text.Direction = vert ? 1 : 0; - DrawTextLowLevel (&text, 0); + DrawTextLowLevel(&text, 0); } -static void -_draw_pad (hidGC gc, PadType *pad, bool clear, bool mask) +static void _draw_pad(hidGC gc, PadType * pad, bool clear, bool mask) { - if (clear && !mask && pad->Clearance <= 0) - return; + if (clear && !mask && pad->Clearance <= 0) + return; - if (TEST_FLAG (THINDRAWFLAG, PCB) || - (clear && TEST_FLAG (THINDRAWPOLYFLAG, PCB))) - gui->thindraw_pcb_pad (gc, pad, clear, mask); - else - gui->fill_pcb_pad (gc, pad, clear, mask); + if (TEST_FLAG(THINDRAWFLAG, PCB) || (clear && TEST_FLAG(THINDRAWPOLYFLAG, PCB))) + gui->thindraw_pcb_pad(gc, pad, clear, mask); + else + gui->fill_pcb_pad(gc, pad, clear, mask); } -static void -draw_pad (PadType *pad) +static void draw_pad(PadType * pad) { - const char *color; - char buf[sizeof("#XXXXXX")]; + const char *color; + char buf[sizeof("#XXXXXX")]; - if (doing_pinout) - gui->set_color (Output.fgGC, PCB->PinColor); - else if (TEST_FLAG (WARNFLAG | SELECTEDFLAG | FOUNDFLAG, pad)) - { - if (TEST_FLAG (WARNFLAG, pad)) - color = PCB->WarnColor; - else if (TEST_FLAG (SELECTEDFLAG, pad)) - color = PCB->PinSelectedColor; - else - color = PCB->ConnectedColor; + if (doing_pinout) + gui->set_color(Output.fgGC, PCB->PinColor); + else if (TEST_FLAG(WARNFLAG | SELECTEDFLAG | FOUNDFLAG, pad)) { + if (TEST_FLAG(WARNFLAG, pad)) + color = PCB->WarnColor; + else if (TEST_FLAG(SELECTEDFLAG, pad)) + color = PCB->PinSelectedColor; + else + color = PCB->ConnectedColor; - } - else if (FRONT (pad)) - color = PCB->PinColor; - else - color = PCB->InvisibleObjectsColor; + } + else if (FRONT(pad)) + color = PCB->PinColor; + else + color = PCB->InvisibleObjectsColor; - if (TEST_FLAG(ONPOINTFLAG, pad)) - { - assert(color != NULL); - LightenColor(color, buf, 1.75); - color = buf; - } - gui->set_color (Output.fgGC, color); + if (TEST_FLAG(ONPOINTFLAG, pad)) { + assert(color != NULL); + LightenColor(color, buf, 1.75); + color = buf; + } + gui->set_color(Output.fgGC, color); - _draw_pad (Output.fgGC, pad, false, false); + _draw_pad(Output.fgGC, pad, false, false); - if (doing_pinout || TEST_FLAG (DISPLAYNAMEFLAG, pad)) - draw_pad_name (pad); + if (doing_pinout || TEST_FLAG(DISPLAYNAMEFLAG, pad)) + draw_pad_name(pad); } -static int -pad_callback (const BoxType * b, void *cl) +static int pad_callback(const BoxType * b, void *cl) { - PadTypePtr pad = (PadTypePtr) b; - int *side = cl; + PadTypePtr pad = (PadTypePtr) b; + int *side = cl; - if (ON_SIDE (pad, *side)) - draw_pad (pad); - return 1; + if (ON_SIDE(pad, *side)) + draw_pad(pad); + return 1; } -static void -draw_element_name (ElementType *element) +static void draw_element_name(ElementType * element) { - if ((TEST_FLAG (HIDENAMESFLAG, PCB) && gui->gui) || - TEST_FLAG (HIDENAMEFLAG, element)) - return; - if (doing_pinout || doing_assy) - gui->set_color (Output.fgGC, PCB->ElementColor); - else if (TEST_FLAG (SELECTEDFLAG, &ELEMENT_TEXT (PCB, element))) - gui->set_color (Output.fgGC, PCB->ElementSelectedColor); - else if (FRONT (element)) { + if ((TEST_FLAG(HIDENAMESFLAG, PCB) && gui->gui) || TEST_FLAG(HIDENAMEFLAG, element)) + return; + if (doing_pinout || doing_assy) + gui->set_color(Output.fgGC, PCB->ElementColor); + else if (TEST_FLAG(SELECTEDFLAG, &ELEMENT_TEXT(PCB, element))) + gui->set_color(Output.fgGC, PCB->ElementSelectedColor); + else if (FRONT(element)) { /* TODO: why do we test for Name's flag here? */ - if (TEST_FLAG (NONETLISTFLAG, element)) - gui->set_color (Output.fgGC, PCB->ElementColor_nonetlist); - else - gui->set_color (Output.fgGC, PCB->ElementColor); - } - else - gui->set_color (Output.fgGC, PCB->InvisibleObjectsColor); + if (TEST_FLAG(NONETLISTFLAG, element)) + gui->set_color(Output.fgGC, PCB->ElementColor_nonetlist); + else + gui->set_color(Output.fgGC, PCB->ElementColor); + } + else + gui->set_color(Output.fgGC, PCB->InvisibleObjectsColor); - DrawTextLowLevel (&ELEMENT_TEXT (PCB, element), PCB->minSlk); + DrawTextLowLevel(&ELEMENT_TEXT(PCB, element), PCB->minSlk); } -static int -name_callback (const BoxType * b, void *cl) +static int name_callback(const BoxType * b, void *cl) { - TextTypePtr text = (TextTypePtr) b; - ElementTypePtr element = (ElementTypePtr) text->Element; - int *side = cl; + TextTypePtr text = (TextTypePtr) b; + ElementTypePtr element = (ElementTypePtr) text->Element; + int *side = cl; - if (TEST_FLAG (HIDENAMEFLAG, element)) - return 0; + if (TEST_FLAG(HIDENAMEFLAG, element)) + return 0; - if (ON_SIDE (element, *side)) - draw_element_name (element); - return 0; + if (ON_SIDE(element, *side)) + draw_element_name(element); + return 0; } -static void -draw_element_pins_and_pads (ElementType *element) +static void draw_element_pins_and_pads(ElementType * element) { - PAD_LOOP (element); - { - if (doing_pinout || doing_assy || FRONT (pad) || PCB->InvisibleObjectsOn) - draw_pad (pad); - } - END_LOOP; - PIN_LOOP (element); - { - draw_pin (pin, true); - } - END_LOOP; + PAD_LOOP(element); + { + if (doing_pinout || doing_assy || FRONT(pad) || PCB->InvisibleObjectsOn) + draw_pad(pad); + } + END_LOOP; + PIN_LOOP(element); + { + draw_pin(pin, true); + } + END_LOOP; } -static int -EMark_callback (const BoxType * b, void *cl) +static int EMark_callback(const BoxType * b, void *cl) { - ElementTypePtr element = (ElementTypePtr) b; + ElementTypePtr element = (ElementTypePtr) b; - DrawEMark (element, element->MarkX, element->MarkY, !FRONT (element)); - return 1; + DrawEMark(element, element->MarkX, element->MarkY, !FRONT(element)); + return 1; } -static int -hole_callback (const BoxType * b, void *cl) +static int hole_callback(const BoxType * b, void *cl) { - PinTypePtr pv = (PinTypePtr) b; - int plated = cl ? *(int *) cl : -1; - const char *color; - char buf[sizeof("#XXXXXX")]; + PinTypePtr pv = (PinTypePtr) b; + int plated = cl ? *(int *) cl : -1; + const char *color; + char buf[sizeof("#XXXXXX")]; - if ((plated == 0 && !TEST_FLAG (HOLEFLAG, pv)) || - (plated == 1 && TEST_FLAG (HOLEFLAG, pv))) - return 1; + if ((plated == 0 && !TEST_FLAG(HOLEFLAG, pv)) || (plated == 1 && TEST_FLAG(HOLEFLAG, pv))) + return 1; - if (TEST_FLAG (THINDRAWFLAG, PCB)) - { - if (!TEST_FLAG (HOLEFLAG, pv)) - { - gui->set_line_cap (Output.fgGC, Round_Cap); - gui->set_line_width (Output.fgGC, 0); - gui->draw_arc (Output.fgGC, - pv->X, pv->Y, pv->DrillingHole / 2, - pv->DrillingHole / 2, 0, 360); - } - } - else - gui->fill_circle (Output.bgGC, pv->X, pv->Y, pv->DrillingHole / 2); + if (TEST_FLAG(THINDRAWFLAG, PCB)) { + if (!TEST_FLAG(HOLEFLAG, pv)) { + gui->set_line_cap(Output.fgGC, Round_Cap); + gui->set_line_width(Output.fgGC, 0); + gui->draw_arc(Output.fgGC, pv->X, pv->Y, pv->DrillingHole / 2, pv->DrillingHole / 2, 0, 360); + } + } + else + gui->fill_circle(Output.bgGC, pv->X, pv->Y, pv->DrillingHole / 2); - if (TEST_FLAG (HOLEFLAG, pv)) - { - if (TEST_FLAG (WARNFLAG, pv)) - color = PCB->WarnColor; - else if (TEST_FLAG (SELECTEDFLAG, pv)) - color = PCB->ViaSelectedColor; - else - color = Settings.BlackColor; + if (TEST_FLAG(HOLEFLAG, pv)) { + if (TEST_FLAG(WARNFLAG, pv)) + color = PCB->WarnColor; + else if (TEST_FLAG(SELECTEDFLAG, pv)) + color = PCB->ViaSelectedColor; + else + color = Settings.BlackColor; - if (TEST_FLAG(ONPOINTFLAG, pv)) - { - assert(color != NULL); - LightenColor(color, buf, 1.75); - color = buf; - } - gui->set_color (Output.fgGC, color); + if (TEST_FLAG(ONPOINTFLAG, pv)) { + assert(color != NULL); + LightenColor(color, buf, 1.75); + color = buf; + } + gui->set_color(Output.fgGC, color); - gui->set_line_cap (Output.fgGC, Round_Cap); - gui->set_line_width (Output.fgGC, 0); - gui->draw_arc (Output.fgGC, - pv->X, pv->Y, pv->DrillingHole / 2, - pv->DrillingHole / 2, 0, 360); - } - return 1; + gui->set_line_cap(Output.fgGC, Round_Cap); + gui->set_line_width(Output.fgGC, 0); + gui->draw_arc(Output.fgGC, pv->X, pv->Y, pv->DrillingHole / 2, pv->DrillingHole / 2, 0, 360); + } + return 1; } -static void -DrawHoles (bool draw_plated, bool draw_unplated, const BoxType *drawn_area) +static void DrawHoles(bool draw_plated, bool draw_unplated, const BoxType * drawn_area) { - int plated = -1; + int plated = -1; - if ( draw_plated && !draw_unplated) plated = 1; - if (!draw_plated && draw_unplated) plated = 0; + if (draw_plated && !draw_unplated) + plated = 1; + if (!draw_plated && draw_unplated) + plated = 0; - r_search (PCB->Data->pin_tree, drawn_area, NULL, hole_callback, &plated); - r_search (PCB->Data->via_tree, drawn_area, NULL, hole_callback, &plated); + r_search(PCB->Data->pin_tree, drawn_area, NULL, hole_callback, &plated); + r_search(PCB->Data->via_tree, drawn_area, NULL, hole_callback, &plated); } -static void -_draw_line (LineType *line) +static void _draw_line(LineType * line) { - gui->set_line_cap (Output.fgGC, Trace_Cap); - if (TEST_FLAG (THINDRAWFLAG, PCB)) - gui->set_line_width (Output.fgGC, 0); - else - gui->set_line_width (Output.fgGC, line->Thickness); + gui->set_line_cap(Output.fgGC, Trace_Cap); + if (TEST_FLAG(THINDRAWFLAG, PCB)) + gui->set_line_width(Output.fgGC, 0); + else + gui->set_line_width(Output.fgGC, line->Thickness); - gui->draw_line (Output.fgGC, - line->Point1.X, line->Point1.Y, - line->Point2.X, line->Point2.Y); + gui->draw_line(Output.fgGC, line->Point1.X, line->Point1.Y, line->Point2.X, line->Point2.Y); } -static void -draw_line (LayerType *layer, LineType *line) +static void draw_line(LayerType * layer, LineType * line) { - const char *color; - char buf[sizeof("#XXXXXX")]; + const char *color; + char buf[sizeof("#XXXXXX")]; - if (TEST_FLAG (WARNFLAG, line)) - color = PCB->WarnColor; - else if (TEST_FLAG (SELECTEDFLAG | FOUNDFLAG, line)) - { - if (TEST_FLAG (SELECTEDFLAG, line)) - color = layer->SelectedColor; - else - color = PCB->ConnectedColor; - } - else - color = layer->Color; + if (TEST_FLAG(WARNFLAG, line)) + color = PCB->WarnColor; + else if (TEST_FLAG(SELECTEDFLAG | FOUNDFLAG, line)) { + if (TEST_FLAG(SELECTEDFLAG, line)) + color = layer->SelectedColor; + else + color = PCB->ConnectedColor; + } + else + color = layer->Color; - if (TEST_FLAG(ONPOINTFLAG, line)) - { - assert(color != NULL); - LightenColor(color, buf, 1.75); - color = buf; - } + if (TEST_FLAG(ONPOINTFLAG, line)) { + assert(color != NULL); + LightenColor(color, buf, 1.75); + color = buf; + } - gui->set_color(Output.fgGC, color); - _draw_line (line); + gui->set_color(Output.fgGC, color); + _draw_line(line); } -static int -line_callback (const BoxType * b, void *cl) +static int line_callback(const BoxType * b, void *cl) { - draw_line ((LayerType *) cl, (LineType *) b); - return 1; + draw_line((LayerType *) cl, (LineType *) b); + return 1; } -static int -rat_callback (const BoxType * b, void *cl) +static int rat_callback(const BoxType * b, void *cl) { - RatType *rat = (RatType *)b; + RatType *rat = (RatType *) b; - if (TEST_FLAG (SELECTEDFLAG | FOUNDFLAG, rat)) - { - if (TEST_FLAG (SELECTEDFLAG, rat)) - gui->set_color (Output.fgGC, PCB->RatSelectedColor); - else - gui->set_color (Output.fgGC, PCB->ConnectedColor); - } - else - gui->set_color (Output.fgGC, PCB->RatColor); + if (TEST_FLAG(SELECTEDFLAG | FOUNDFLAG, rat)) { + if (TEST_FLAG(SELECTEDFLAG, rat)) + gui->set_color(Output.fgGC, PCB->RatSelectedColor); + else + gui->set_color(Output.fgGC, PCB->ConnectedColor); + } + else + gui->set_color(Output.fgGC, PCB->RatColor); - if (Settings.RatThickness < 20) - rat->Thickness = pixel_slop * Settings.RatThickness; - /* rats.c set VIAFLAG if this rat goes to a containing poly: draw a donut */ - if (TEST_FLAG(VIAFLAG, rat)) - { - int w = rat->Thickness; + if (Settings.RatThickness < 20) + rat->Thickness = pixel_slop * Settings.RatThickness; + /* rats.c set VIAFLAG if this rat goes to a containing poly: draw a donut */ + if (TEST_FLAG(VIAFLAG, rat)) { + int w = rat->Thickness; - if (TEST_FLAG (THINDRAWFLAG, PCB)) - gui->set_line_width (Output.fgGC, 0); - else - gui->set_line_width (Output.fgGC, w); - gui->draw_arc (Output.fgGC, rat->Point1.X, rat->Point1.Y, - w * 2, w * 2, 0, 360); - } - else - _draw_line ((LineType *) rat); - return 1; + if (TEST_FLAG(THINDRAWFLAG, PCB)) + gui->set_line_width(Output.fgGC, 0); + else + gui->set_line_width(Output.fgGC, w); + gui->draw_arc(Output.fgGC, rat->Point1.X, rat->Point1.Y, w * 2, w * 2, 0, 360); + } + else + _draw_line((LineType *) rat); + return 1; } -static void -_draw_arc (ArcType *arc) +static void _draw_arc(ArcType * arc) { - if (!arc->Thickness) - return; + if (!arc->Thickness) + return; - if (TEST_FLAG (THINDRAWFLAG, PCB)) - gui->set_line_width (Output.fgGC, 0); - else - gui->set_line_width (Output.fgGC, arc->Thickness); - gui->set_line_cap (Output.fgGC, Trace_Cap); + if (TEST_FLAG(THINDRAWFLAG, PCB)) + gui->set_line_width(Output.fgGC, 0); + else + gui->set_line_width(Output.fgGC, arc->Thickness); + gui->set_line_cap(Output.fgGC, Trace_Cap); - gui->draw_arc (Output.fgGC, arc->X, arc->Y, arc->Width, - arc->Height, arc->StartAngle, arc->Delta); + gui->draw_arc(Output.fgGC, arc->X, arc->Y, arc->Width, arc->Height, arc->StartAngle, arc->Delta); } -static void -draw_arc (LayerType *layer, ArcType *arc) +static void draw_arc(LayerType * layer, ArcType * arc) { - const char *color; - char buf[sizeof("#XXXXXX")]; + const char *color; + char buf[sizeof("#XXXXXX")]; - if (TEST_FLAG (WARNFLAG, arc)) - color = PCB->WarnColor; - else if (TEST_FLAG (SELECTEDFLAG | FOUNDFLAG, arc)) - { - if (TEST_FLAG (SELECTEDFLAG, arc)) - color = layer->SelectedColor; - else - color = PCB->ConnectedColor; - } - else - color = layer->Color; + if (TEST_FLAG(WARNFLAG, arc)) + color = PCB->WarnColor; + else if (TEST_FLAG(SELECTEDFLAG | FOUNDFLAG, arc)) { + if (TEST_FLAG(SELECTEDFLAG, arc)) + color = layer->SelectedColor; + else + color = PCB->ConnectedColor; + } + else + color = layer->Color; - if (TEST_FLAG(ONPOINTFLAG, arc)) - { - assert(color != NULL); - LightenColor(color, buf, 1.75); - color = buf; - } - gui->set_color (Output.fgGC, color); - _draw_arc (arc); + if (TEST_FLAG(ONPOINTFLAG, arc)) { + assert(color != NULL); + LightenColor(color, buf, 1.75); + color = buf; + } + gui->set_color(Output.fgGC, color); + _draw_arc(arc); } -static int -arc_callback (const BoxType * b, void *cl) +static int arc_callback(const BoxType * b, void *cl) { - draw_arc ((LayerTypePtr) cl, (ArcTypePtr) b); - return 1; + draw_arc((LayerTypePtr) cl, (ArcTypePtr) b); + return 1; } -static void -draw_element_package (ElementType *element) +static void draw_element_package(ElementType * element) { - /* set color and draw lines, arcs, text and pins */ - if (doing_pinout || doing_assy) - gui->set_color (Output.fgGC, PCB->ElementColor); - else if (TEST_FLAG (SELECTEDFLAG, element)) - gui->set_color (Output.fgGC, PCB->ElementSelectedColor); - else if (FRONT (element)) - gui->set_color (Output.fgGC, PCB->ElementColor); - else - gui->set_color (Output.fgGC, PCB->InvisibleObjectsColor); + /* set color and draw lines, arcs, text and pins */ + if (doing_pinout || doing_assy) + gui->set_color(Output.fgGC, PCB->ElementColor); + else if (TEST_FLAG(SELECTEDFLAG, element)) + gui->set_color(Output.fgGC, PCB->ElementSelectedColor); + else if (FRONT(element)) + gui->set_color(Output.fgGC, PCB->ElementColor); + else + gui->set_color(Output.fgGC, PCB->InvisibleObjectsColor); - /* draw lines, arcs, text and pins */ - ELEMENTLINE_LOOP (element); - { - _draw_line (line); - } - END_LOOP; - ARC_LOOP (element); - { - _draw_arc (arc); - } - END_LOOP; + /* draw lines, arcs, text and pins */ + ELEMENTLINE_LOOP(element); + { + _draw_line(line); + } + END_LOOP; + ARC_LOOP(element); + { + _draw_arc(arc); + } + END_LOOP; } -static int -element_callback (const BoxType * b, void *cl) +static int element_callback(const BoxType * b, void *cl) { - ElementTypePtr element = (ElementTypePtr) b; - int *side = cl; + ElementTypePtr element = (ElementTypePtr) b; + int *side = cl; - if (ON_SIDE (element, *side)) - draw_element_package (element); - return 1; + if (ON_SIDE(element, *side)) + draw_element_package(element); + return 1; } /* --------------------------------------------------------------------------- @@ -710,219 +645,191 @@ * prints assembly drawing. */ -static void -PrintAssembly (int side, const BoxType * drawn_area) +static void PrintAssembly(int side, const BoxType * drawn_area) { - int side_group = GetLayerGroupNumberByNumber (max_copper_layer + side); + int side_group = GetLayerGroupNumberByNumber(max_copper_layer + side); - doing_assy = true; - gui->set_draw_faded (Output.fgGC, 1); - DrawLayerGroup (side_group, drawn_area); - gui->set_draw_faded (Output.fgGC, 0); + doing_assy = true; + gui->set_draw_faded(Output.fgGC, 1); + DrawLayerGroup(side_group, drawn_area); + gui->set_draw_faded(Output.fgGC, 0); - /* draw package */ - DrawSilk (side, drawn_area); - doing_assy = false; + /* draw package */ + DrawSilk(side, drawn_area); + doing_assy = false; } /* --------------------------------------------------------------------------- * initializes some identifiers for a new zoom factor and redraws whole screen */ -static void -DrawEverything (const BoxType *drawn_area) +static void DrawEverything(const BoxType * drawn_area) { - int i, ngroups, side; - int component, solder; - /* This is the list of layer groups we will draw. */ - int do_group[MAX_LAYER]; - /* This is the reverse of the order in which we draw them. */ - int drawn_groups[MAX_LAYER]; - int plated, unplated; - bool paste_empty; + int i, ngroups, side; + int component, solder; + /* This is the list of layer groups we will draw. */ + int do_group[MAX_LAYER]; + /* This is the reverse of the order in which we draw them. */ + int drawn_groups[MAX_LAYER]; + int plated, unplated; + bool paste_empty; - PCB->Data->SILKLAYER.Color = PCB->ElementColor; - PCB->Data->BACKSILKLAYER.Color = PCB->InvisibleObjectsColor; + PCB->Data->SILKLAYER.Color = PCB->ElementColor; + PCB->Data->BACKSILKLAYER.Color = PCB->InvisibleObjectsColor; - memset (do_group, 0, sizeof (do_group)); - for (ngroups = 0, i = 0; i < max_copper_layer; i++) - { - LayerType *l = LAYER_ON_STACK (i); - int group = GetLayerGroupNumberByNumber (LayerStack[i]); - if (l->On && !do_group[group]) - { - do_group[group] = 1; - drawn_groups[ngroups++] = group; + memset(do_group, 0, sizeof(do_group)); + for (ngroups = 0, i = 0; i < max_copper_layer; i++) { + LayerType *l = LAYER_ON_STACK(i); + int group = GetLayerGroupNumberByNumber(LayerStack[i]); + if (l->On && !do_group[group]) { + do_group[group] = 1; + drawn_groups[ngroups++] = group; + } } - } - component = GetLayerGroupNumberByNumber (component_silk_layer); - solder = GetLayerGroupNumberByNumber (solder_silk_layer); + component = GetLayerGroupNumberByNumber(component_silk_layer); + solder = GetLayerGroupNumberByNumber(solder_silk_layer); - /* - * first draw all 'invisible' stuff - */ - if (!TEST_FLAG (CHECKPLANESFLAG, PCB) - && gui->set_layer ("invisible", SL (INVISIBLE, 0), 0)) - { - side = SWAP_IDENT ? COMPONENT_LAYER : SOLDER_LAYER; - if (PCB->ElementOn) - { - r_search (PCB->Data->element_tree, drawn_area, NULL, element_callback, &side); - r_search (PCB->Data->name_tree[NAME_INDEX (PCB)], drawn_area, NULL, name_callback, &side); - DrawLayer (&(PCB->Data->Layer[max_copper_layer + side]), drawn_area); + /* + * first draw all 'invisible' stuff + */ + if (!TEST_FLAG(CHECKPLANESFLAG, PCB) + && gui->set_layer("invisible", SL(INVISIBLE, 0), 0)) { + side = SWAP_IDENT ? COMPONENT_LAYER : SOLDER_LAYER; + if (PCB->ElementOn) { + r_search(PCB->Data->element_tree, drawn_area, NULL, element_callback, &side); + r_search(PCB->Data->name_tree[NAME_INDEX(PCB)], drawn_area, NULL, name_callback, &side); + DrawLayer(&(PCB->Data->Layer[max_copper_layer + side]), drawn_area); + } + r_search(PCB->Data->pad_tree, drawn_area, NULL, pad_callback, &side); + gui->end_layer(); } - r_search (PCB->Data->pad_tree, drawn_area, NULL, pad_callback, &side); - gui->end_layer (); - } - /* draw all layers in layerstack order */ - for (i = ngroups - 1; i >= 0; i--) - { - int group = drawn_groups[i]; + /* draw all layers in layerstack order */ + for (i = ngroups - 1; i >= 0; i--) { + int group = drawn_groups[i]; - if (gui->set_layer (0, group, 0)) - { - DrawLayerGroup (group, drawn_area); - gui->end_layer (); - } - } + if (gui->set_layer(0, group, 0)) { + DrawLayerGroup(group, drawn_area); + gui->end_layer(); + } + } - if (TEST_FLAG (CHECKPLANESFLAG, PCB) && gui->gui) - return; + if (TEST_FLAG(CHECKPLANESFLAG, PCB) && gui->gui) + return; - /* Draw pins, pads, vias below silk */ - if (gui->gui) - DrawPPV (SWAP_IDENT ? solder : component, drawn_area); - else - { - CountHoles (&plated, &unplated, drawn_area); + /* Draw pins, pads, vias below silk */ + if (gui->gui) + DrawPPV(SWAP_IDENT ? solder : component, drawn_area); + else { + CountHoles(&plated, &unplated, drawn_area); - if (plated && gui->set_layer ("plated-drill", SL (PDRILL, 0), 0)) - { - DrawHoles (true, false, drawn_area); - gui->end_layer (); - } + if (plated && gui->set_layer("plated-drill", SL(PDRILL, 0), 0)) { + DrawHoles(true, false, drawn_area); + gui->end_layer(); + } - if (unplated && gui->set_layer ("unplated-drill", SL (UDRILL, 0), 0)) - { - DrawHoles (false, true, drawn_area); - gui->end_layer (); - } - } + if (unplated && gui->set_layer("unplated-drill", SL(UDRILL, 0), 0)) { + DrawHoles(false, true, drawn_area); + gui->end_layer(); + } + } - /* Draw the solder mask if turned on */ - if (gui->set_layer ("componentmask", SL (MASK, TOP), 0)) - { - DrawMask (COMPONENT_LAYER, drawn_area); - gui->end_layer (); - } + /* Draw the solder mask if turned on */ + if (gui->set_layer("componentmask", SL(MASK, TOP), 0)) { + DrawMask(COMPONENT_LAYER, drawn_area); + gui->end_layer(); + } - if (gui->set_layer ("soldermask", SL (MASK, BOTTOM), 0)) - { - DrawMask (SOLDER_LAYER, drawn_area); - gui->end_layer (); - } + if (gui->set_layer("soldermask", SL(MASK, BOTTOM), 0)) { + DrawMask(SOLDER_LAYER, drawn_area); + gui->end_layer(); + } - if (gui->set_layer ("topsilk", SL (SILK, TOP), 0)) - { - DrawSilk (COMPONENT_LAYER, drawn_area); - gui->end_layer (); - } + if (gui->set_layer("topsilk", SL(SILK, TOP), 0)) { + DrawSilk(COMPONENT_LAYER, drawn_area); + gui->end_layer(); + } - if (gui->set_layer ("bottomsilk", SL (SILK, BOTTOM), 0)) - { - DrawSilk (SOLDER_LAYER, drawn_area); - gui->end_layer (); - } + if (gui->set_layer("bottomsilk", SL(SILK, BOTTOM), 0)) { + DrawSilk(SOLDER_LAYER, drawn_area); + gui->end_layer(); + } - if (gui->gui) - { - /* Draw element Marks */ - if (PCB->PinOn) - r_search (PCB->Data->element_tree, drawn_area, NULL, EMark_callback, - NULL); - /* Draw rat lines on top */ - if (gui->set_layer ("rats", SL (RATS, 0), 0)) - { - DrawRats(drawn_area); - gui->end_layer (); - } - } + if (gui->gui) { + /* Draw element Marks */ + if (PCB->PinOn) + r_search(PCB->Data->element_tree, drawn_area, NULL, EMark_callback, NULL); + /* Draw rat lines on top */ + if (gui->set_layer("rats", SL(RATS, 0), 0)) { + DrawRats(drawn_area); + gui->end_layer(); + } + } - paste_empty = IsPasteEmpty (COMPONENT_LAYER); - if (gui->set_layer ("toppaste", SL (PASTE, TOP), paste_empty)) - { - DrawPaste (COMPONENT_LAYER, drawn_area); - gui->end_layer (); - } + paste_empty = IsPasteEmpty(COMPONENT_LAYER); + if (gui->set_layer("toppaste", SL(PASTE, TOP), paste_empty)) { + DrawPaste(COMPONENT_LAYER, drawn_area); + gui->end_layer(); + } - paste_empty = IsPasteEmpty (SOLDER_LAYER); - if (gui->set_layer ("bottompaste", SL (PASTE, BOTTOM), paste_empty)) - { - DrawPaste (SOLDER_LAYER, drawn_area); - gui->end_layer (); - } + paste_empty = IsPasteEmpty(SOLDER_LAYER); + if (gui->set_layer("bottompaste", SL(PASTE, BOTTOM), paste_empty)) { + DrawPaste(SOLDER_LAYER, drawn_area); + gui->end_layer(); + } - if (gui->set_layer ("topassembly", SL (ASSY, TOP), 0)) - { - PrintAssembly (COMPONENT_LAYER, drawn_area); - gui->end_layer (); - } + if (gui->set_layer("topassembly", SL(ASSY, TOP), 0)) { + PrintAssembly(COMPONENT_LAYER, drawn_area); + gui->end_layer(); + } - if (gui->set_layer ("bottomassembly", SL (ASSY, BOTTOM), 0)) - { - PrintAssembly (SOLDER_LAYER, drawn_area); - gui->end_layer (); - } + if (gui->set_layer("bottomassembly", SL(ASSY, BOTTOM), 0)) { + PrintAssembly(SOLDER_LAYER, drawn_area); + gui->end_layer(); + } - if (gui->set_layer ("fab", SL (FAB, 0), 0)) - { - PrintFab (Output.fgGC); - gui->end_layer (); - } + if (gui->set_layer("fab", SL(FAB, 0), 0)) { + PrintFab(Output.fgGC); + gui->end_layer(); + } } -static void -DrawEMark (ElementTypePtr e, Coord X, Coord Y, bool invisible) +static void DrawEMark(ElementTypePtr e, Coord X, Coord Y, bool invisible) { - Coord mark_size = EMARK_SIZE; - if (!PCB->InvisibleObjectsOn && invisible) - return; + Coord mark_size = EMARK_SIZE; + if (!PCB->InvisibleObjectsOn && invisible) + return; - if (e->Pin != NULL) - { - PinType *pin0 = e->Pin->data; - if (TEST_FLAG (HOLEFLAG, pin0)) - mark_size = MIN (mark_size, pin0->DrillingHole / 2); - else - mark_size = MIN (mark_size, pin0->Thickness / 2); - } + if (e->Pin != NULL) { + PinType *pin0 = e->Pin->data; + if (TEST_FLAG(HOLEFLAG, pin0)) + mark_size = MIN(mark_size, pin0->DrillingHole / 2); + else + mark_size = MIN(mark_size, pin0->Thickness / 2); + } - if (e->Pad != NULL) - { - PadType *pad0 = e->Pad->data; - mark_size = MIN (mark_size, pad0->Thickness / 2); - } + if (e->Pad != NULL) { + PadType *pad0 = e->Pad->data; + mark_size = MIN(mark_size, pad0->Thickness / 2); + } - gui->set_color (Output.fgGC, - invisible ? PCB->InvisibleMarkColor : PCB->ElementColor); - gui->set_line_cap (Output.fgGC, Trace_Cap); - gui->set_line_width (Output.fgGC, 0); - gui->draw_line (Output.fgGC, X - mark_size, Y, X, Y - mark_size); - gui->draw_line (Output.fgGC, X + mark_size, Y, X, Y - mark_size); - gui->draw_line (Output.fgGC, X - mark_size, Y, X, Y + mark_size); - gui->draw_line (Output.fgGC, X + mark_size, Y, X, Y + mark_size); + gui->set_color(Output.fgGC, invisible ? PCB->InvisibleMarkColor : PCB->ElementColor); + gui->set_line_cap(Output.fgGC, Trace_Cap); + gui->set_line_width(Output.fgGC, 0); + gui->draw_line(Output.fgGC, X - mark_size, Y, X, Y - mark_size); + gui->draw_line(Output.fgGC, X + mark_size, Y, X, Y - mark_size); + gui->draw_line(Output.fgGC, X - mark_size, Y, X, Y + mark_size); + gui->draw_line(Output.fgGC, X + mark_size, Y, X, Y + mark_size); - /* - * If an element is locked, place a "L" on top of the "diamond". - * This provides a nice visual indication that it is locked that - * works even for color blind users. - */ - if (TEST_FLAG (LOCKFLAG, e) ) - { - gui->draw_line (Output.fgGC, X, Y, X + 2 * mark_size, Y); - gui->draw_line (Output.fgGC, X, Y, X, Y - 4* mark_size); - } + /* + * If an element is locked, place a "L" on top of the "diamond". + * This provides a nice visual indication that it is locked that + * works even for color blind users. + */ + if (TEST_FLAG(LOCKFLAG, e)) { + gui->draw_line(Output.fgGC, X, Y, X + 2 * mark_size, Y); + gui->draw_line(Output.fgGC, X, Y, X, Y - 4 * mark_size); + } } /* --------------------------------------------------------------------------- @@ -929,116 +836,100 @@ * Draws pins pads and vias - Always draws for non-gui HIDs, * otherwise drawing depends on PCB->PinOn and PCB->ViaOn */ -static void -DrawPPV (int group, const BoxType *drawn_area) +static void DrawPPV(int group, const BoxType * drawn_area) { - int component_group = GetLayerGroupNumberByNumber (component_silk_layer); - int solder_group = GetLayerGroupNumberByNumber (solder_silk_layer); - int side; + int component_group = GetLayerGroupNumberByNumber(component_silk_layer); + int solder_group = GetLayerGroupNumberByNumber(solder_silk_layer); + int side; - if (PCB->PinOn || !gui->gui) - { - /* draw element pins */ - r_search (PCB->Data->pin_tree, drawn_area, NULL, pin_callback, NULL); + if (PCB->PinOn || !gui->gui) { + /* draw element pins */ + r_search(PCB->Data->pin_tree, drawn_area, NULL, pin_callback, NULL); - /* draw element pads */ - if (group == component_group) - { - side = COMPONENT_LAYER; - r_search (PCB->Data->pad_tree, drawn_area, NULL, pad_callback, &side); - } + /* draw element pads */ + if (group == component_group) { + side = COMPONENT_LAYER; + r_search(PCB->Data->pad_tree, drawn_area, NULL, pad_callback, &side); + } - if (group == solder_group) - { - side = SOLDER_LAYER; - r_search (PCB->Data->pad_tree, drawn_area, NULL, pad_callback, &side); - } - } + if (group == solder_group) { + side = SOLDER_LAYER; + r_search(PCB->Data->pad_tree, drawn_area, NULL, pad_callback, &side); + } + } - /* draw vias */ - if (PCB->ViaOn || !gui->gui) - { - r_search (PCB->Data->via_tree, drawn_area, NULL, via_callback, NULL); - r_search (PCB->Data->via_tree, drawn_area, NULL, hole_callback, NULL); - } - if (PCB->PinOn || doing_assy) - r_search (PCB->Data->pin_tree, drawn_area, NULL, hole_callback, NULL); + /* draw vias */ + if (PCB->ViaOn || !gui->gui) { + r_search(PCB->Data->via_tree, drawn_area, NULL, via_callback, NULL); + r_search(PCB->Data->via_tree, drawn_area, NULL, hole_callback, NULL); + } + if (PCB->PinOn || doing_assy) + r_search(PCB->Data->pin_tree, drawn_area, NULL, hole_callback, NULL); } -static int -clearPin_callback (const BoxType * b, void *cl) +static int clearPin_callback(const BoxType * b, void *cl) { - PinType *pin = (PinTypePtr) b; - if (TEST_FLAG (THINDRAWFLAG, PCB) || TEST_FLAG (THINDRAWPOLYFLAG, PCB)) - gui->thindraw_pcb_pv (Output.pmGC, Output.pmGC, pin, false, true); - else - gui->fill_pcb_pv (Output.pmGC, Output.pmGC, pin, false, true); - return 1; + PinType *pin = (PinTypePtr) b; + if (TEST_FLAG(THINDRAWFLAG, PCB) || TEST_FLAG(THINDRAWPOLYFLAG, PCB)) + gui->thindraw_pcb_pv(Output.pmGC, Output.pmGC, pin, false, true); + else + gui->fill_pcb_pv(Output.pmGC, Output.pmGC, pin, false, true); + return 1; } struct poly_info { - const BoxType *drawn_area; - LayerType *layer; + const BoxType *drawn_area; + LayerType *layer; }; -static int -poly_callback (const BoxType * b, void *cl) +static int poly_callback(const BoxType * b, void *cl) { - struct poly_info *i = cl; - PolygonType *polygon = (PolygonType *)b; - static char *color; - char buf[sizeof("#XXXXXX")]; + struct poly_info *i = cl; + PolygonType *polygon = (PolygonType *) b; + static char *color; + char buf[sizeof("#XXXXXX")]; - if (!polygon->Clipped) - return 0; + if (!polygon->Clipped) + return 0; - if (TEST_FLAG (WARNFLAG, polygon)) - color = PCB->WarnColor; - else if (TEST_FLAG (SELECTEDFLAG, polygon)) - color = i->layer->SelectedColor; - else if (TEST_FLAG (FOUNDFLAG, polygon)) - color = PCB->ConnectedColor; - else if (TEST_FLAG(ONPOINTFLAG, polygon)) - { - assert(color != NULL); - LightenColor(color, buf, 1.75); - color = buf; - } - else - color = i->layer->Color; - gui->set_color (Output.fgGC, color); + if (TEST_FLAG(WARNFLAG, polygon)) + color = PCB->WarnColor; + else if (TEST_FLAG(SELECTEDFLAG, polygon)) + color = i->layer->SelectedColor; + else if (TEST_FLAG(FOUNDFLAG, polygon)) + color = PCB->ConnectedColor; + else if (TEST_FLAG(ONPOINTFLAG, polygon)) { + assert(color != NULL); + LightenColor(color, buf, 1.75); + color = buf; + } + else + color = i->layer->Color; + gui->set_color(Output.fgGC, color); - if (gui->thindraw_pcb_polygon != NULL && - (TEST_FLAG (THINDRAWFLAG, PCB) || - TEST_FLAG (THINDRAWPOLYFLAG, PCB))) - gui->thindraw_pcb_polygon (Output.fgGC, polygon, i->drawn_area); - else - gui->fill_pcb_polygon (Output.fgGC, polygon, i->drawn_area); + if (gui->thindraw_pcb_polygon != NULL && (TEST_FLAG(THINDRAWFLAG, PCB) || TEST_FLAG(THINDRAWPOLYFLAG, PCB))) + gui->thindraw_pcb_polygon(Output.fgGC, polygon, i->drawn_area); + else + gui->fill_pcb_polygon(Output.fgGC, polygon, i->drawn_area); - /* If checking planes, thin-draw any pieces which have been clipped away */ - if (gui->thindraw_pcb_polygon != NULL && - TEST_FLAG (CHECKPLANESFLAG, PCB) && - !TEST_FLAG (FULLPOLYFLAG, polygon)) - { - PolygonType poly = *polygon; + /* If checking planes, thin-draw any pieces which have been clipped away */ + if (gui->thindraw_pcb_polygon != NULL && TEST_FLAG(CHECKPLANESFLAG, PCB) && !TEST_FLAG(FULLPOLYFLAG, polygon)) { + PolygonType poly = *polygon; - for (poly.Clipped = polygon->Clipped->f; - poly.Clipped != polygon->Clipped; - poly.Clipped = poly.Clipped->f) - gui->thindraw_pcb_polygon (Output.fgGC, &poly, i->drawn_area); - } + for (poly.Clipped = polygon->Clipped->f; poly.Clipped != polygon->Clipped; poly.Clipped = poly.Clipped->f) + gui->thindraw_pcb_polygon(Output.fgGC, &poly, i->drawn_area); + } - return 1; + return 1; } -static int -clearPad_callback (const BoxType * b, void *cl) +static int clearPad_callback(const BoxType * b, void *cl) { - PadTypePtr pad = (PadTypePtr) b; - int *side = cl; - if (ON_SIDE (pad, *side) && pad->Mask) - _draw_pad (Output.pmGC, pad, true, true); - return 1; + PadTypePtr pad = (PadTypePtr) b; + int *side = cl; + if (ON_SIDE(pad, *side) && pad->Mask) + _draw_pad(Output.pmGC, pad, true, true); + return 1; } /* --------------------------------------------------------------------------- @@ -1045,181 +936,162 @@ * Draws silk layer. */ -static void -DrawSilk (int side, const BoxType * drawn_area) +static void DrawSilk(int side, const BoxType * drawn_area) { #if 0 - /* This code is used when you want to mask silk to avoid exposed - pins and pads. We decided it was a bad idea to do this - unconditionally, but the code remains. */ + /* This code is used when you want to mask silk to avoid exposed + pins and pads. We decided it was a bad idea to do this + unconditionally, but the code remains. */ #endif #if 0 - if (gui->poly_before) - { - gui->use_mask (HID_MASK_BEFORE); + if (gui->poly_before) { + gui->use_mask(HID_MASK_BEFORE); #endif - DrawLayer (LAYER_PTR (max_copper_layer + side), drawn_area); - /* draw package */ - r_search (PCB->Data->element_tree, drawn_area, NULL, element_callback, &side); - r_search (PCB->Data->name_tree[NAME_INDEX (PCB)], drawn_area, NULL, name_callback, &side); + DrawLayer(LAYER_PTR(max_copper_layer + side), drawn_area); + /* draw package */ + r_search(PCB->Data->element_tree, drawn_area, NULL, element_callback, &side); + r_search(PCB->Data->name_tree[NAME_INDEX(PCB)], drawn_area, NULL, name_callback, &side); #if 0 - } + } - gui->use_mask (HID_MASK_CLEAR); - r_search (PCB->Data->pin_tree, drawn_area, NULL, clearPin_callback, NULL); - r_search (PCB->Data->via_tree, drawn_area, NULL, clearPin_callback, NULL); - r_search (PCB->Data->pad_tree, drawn_area, NULL, clearPad_callback, &side); + gui->use_mask(HID_MASK_CLEAR); + r_search(PCB->Data->pin_tree, drawn_area, NULL, clearPin_callback, NULL); + r_search(PCB->Data->via_tree, drawn_area, NULL, clearPin_callback, NULL); + r_search(PCB->Data->pad_tree, drawn_area, NULL, clearPad_callback, &side); - if (gui->poly_after) - { - gui->use_mask (HID_MASK_AFTER); - DrawLayer (LAYER_PTR (max_copper_layer + layer), drawn_area); - /* draw package */ - r_search (PCB->Data->element_tree, drawn_area, NULL, element_callback, &side); - r_search (PCB->Data->name_tree[NAME_INDEX (PCB)], drawn_area, NULL, name_callback, &side); - } - gui->use_mask (HID_MASK_OFF); + if (gui->poly_after) { + gui->use_mask(HID_MASK_AFTER); + DrawLayer(LAYER_PTR(max_copper_layer + layer), drawn_area); + /* draw package */ + r_search(PCB->Data->element_tree, drawn_area, NULL, element_callback, &side); + r_search(PCB->Data->name_tree[NAME_INDEX(PCB)], drawn_area, NULL, name_callback, &side); + } + gui->use_mask(HID_MASK_OFF); #endif } -static void -DrawMaskBoardArea (int mask_type, const BoxType *drawn_area) +static void DrawMaskBoardArea(int mask_type, const BoxType * drawn_area) { - /* Skip the mask drawing if the GUI doesn't want this type */ - if ((mask_type == HID_MASK_BEFORE && !gui->poly_before) || - (mask_type == HID_MASK_AFTER && !gui->poly_after)) - return; + /* Skip the mask drawing if the GUI doesn't want this type */ + if ((mask_type == HID_MASK_BEFORE && !gui->poly_before) || (mask_type == HID_MASK_AFTER && !gui->poly_after)) + return; - gui->use_mask (mask_type); - gui->set_color (Output.fgGC, PCB->MaskColor); - if (drawn_area == NULL) - gui->fill_rect (Output.fgGC, 0, 0, PCB->MaxWidth, PCB->MaxHeight); - else - gui->fill_rect (Output.fgGC, drawn_area->X1, drawn_area->Y1, - drawn_area->X2, drawn_area->Y2); + gui->use_mask(mask_type); + gui->set_color(Output.fgGC, PCB->MaskColor); + if (drawn_area == NULL) + gui->fill_rect(Output.fgGC, 0, 0, PCB->MaxWidth, PCB->MaxHeight); + else + gui->fill_rect(Output.fgGC, drawn_area->X1, drawn_area->Y1, drawn_area->X2, drawn_area->Y2); } /* --------------------------------------------------------------------------- * draws solder mask layer - this will cover nearly everything */ -static void -DrawMask (int side, const BoxType *screen) +static void DrawMask(int side, const BoxType * screen) { - int thin = TEST_FLAG(THINDRAWFLAG, PCB) || TEST_FLAG(THINDRAWPOLYFLAG, PCB); + int thin = TEST_FLAG(THINDRAWFLAG, PCB) || TEST_FLAG(THINDRAWPOLYFLAG, PCB); - if (thin) - gui->set_color (Output.pmGC, PCB->MaskColor); - else - { - DrawMaskBoardArea (HID_MASK_BEFORE, screen); - gui->use_mask (HID_MASK_CLEAR); - } + if (thin) + gui->set_color(Output.pmGC, PCB->MaskColor); + else { + DrawMaskBoardArea(HID_MASK_BEFORE, screen); + gui->use_mask(HID_MASK_CLEAR); + } - r_search (PCB->Data->pin_tree, screen, NULL, clearPin_callback, NULL); - r_search (PCB->Data->via_tree, screen, NULL, clearPin_callback, NULL); - r_search (PCB->Data->pad_tree, screen, NULL, clearPad_callback, &side); + r_search(PCB->Data->pin_tree, screen, NULL, clearPin_callback, NULL); + r_search(PCB->Data->via_tree, screen, NULL, clearPin_callback, NULL); + r_search(PCB->Data->pad_tree, screen, NULL, clearPad_callback, &side); - if (thin) - gui->set_color (Output.pmGC, "erase"); - else - { - DrawMaskBoardArea (HID_MASK_AFTER, screen); - gui->use_mask (HID_MASK_OFF); - } + if (thin) + gui->set_color(Output.pmGC, "erase"); + else { + DrawMaskBoardArea(HID_MASK_AFTER, screen); + gui->use_mask(HID_MASK_OFF); + } } /* --------------------------------------------------------------------------- * draws solder paste layer for a given side of the board */ -static void -DrawPaste (int side, const BoxType *drawn_area) +static void DrawPaste(int side, const BoxType * drawn_area) { - gui->set_color (Output.fgGC, PCB->ElementColor); - ALLPAD_LOOP (PCB->Data); - { - if (ON_SIDE (pad, side) && !TEST_FLAG (NOPASTEFLAG, pad) && pad->Mask > 0) - { - if (pad->Mask < pad->Thickness) - _draw_pad (Output.fgGC, pad, true, true); - else - _draw_pad (Output.fgGC, pad, false, false); - } - } - ENDALL_LOOP; + gui->set_color(Output.fgGC, PCB->ElementColor); + ALLPAD_LOOP(PCB->Data); + { + if (ON_SIDE(pad, side) && !TEST_FLAG(NOPASTEFLAG, pad) && pad->Mask > 0) { + if (pad->Mask < pad->Thickness) + _draw_pad(Output.fgGC, pad, true, true); + else + _draw_pad(Output.fgGC, pad, false, false); + } + } + ENDALL_LOOP; } -static void -DrawRats (const BoxType *drawn_area) +static void DrawRats(const BoxType * drawn_area) { - /* - * XXX lesstif allows positive AND negative drawing in HID_MASK_CLEAR. - * XXX gtk only allows negative drawing. - * XXX using the mask here is to get rat transparency - */ - int can_mask = strcmp(gui->name, "lesstif") == 0; + /* + * XXX lesstif allows positive AND negative drawing in HID_MASK_CLEAR. + * XXX gtk only allows negative drawing. + * XXX using the mask here is to get rat transparency + */ + int can_mask = strcmp(gui->name, "lesstif") == 0; - if (can_mask) - gui->use_mask (HID_MASK_CLEAR); - r_search (PCB->Data->rat_tree, drawn_area, NULL, rat_callback, NULL); - if (can_mask) - gui->use_mask (HID_MASK_OFF); + if (can_mask) + gui->use_mask(HID_MASK_CLEAR); + r_search(PCB->Data->rat_tree, drawn_area, NULL, rat_callback, NULL); + if (can_mask) + gui->use_mask(HID_MASK_OFF); } -static int -text_callback (const BoxType * b, void *cl) +static int text_callback(const BoxType * b, void *cl) { - LayerType *layer = cl; - TextType *text = (TextType *)b; - int min_silk_line; + LayerType *layer = cl; + TextType *text = (TextType *) b; + int min_silk_line; - if (TEST_FLAG (SELECTEDFLAG, text)) - gui->set_color (Output.fgGC, layer->SelectedColor); - else - gui->set_color (Output.fgGC, layer->Color); - if (layer == &PCB->Data->SILKLAYER || - layer == &PCB->Data->BACKSILKLAYER) - min_silk_line = PCB->minSlk; - else - min_silk_line = PCB->minWid; - DrawTextLowLevel (text, min_silk_line); - return 1; + if (TEST_FLAG(SELECTEDFLAG, text)) + gui->set_color(Output.fgGC, layer->SelectedColor); + else + gui->set_color(Output.fgGC, layer->Color); + if (layer == &PCB->Data->SILKLAYER || layer == &PCB->Data->BACKSILKLAYER) + min_silk_line = PCB->minSlk; + else + min_silk_line = PCB->minWid; + DrawTextLowLevel(text, min_silk_line); + return 1; } -void -DrawLayer (LayerTypePtr Layer, const BoxType * screen) +void DrawLayer(LayerTypePtr Layer, const BoxType * screen) { - struct poly_info info = {screen, Layer}; + struct poly_info info = { screen, Layer }; - /* print the non-clearing polys */ - r_search (Layer->polygon_tree, screen, NULL, poly_callback, &info); + /* print the non-clearing polys */ + r_search(Layer->polygon_tree, screen, NULL, poly_callback, &info); - if (TEST_FLAG (CHECKPLANESFLAG, PCB)) - return; + if (TEST_FLAG(CHECKPLANESFLAG, PCB)) + return; - /* draw all visible lines this layer */ - r_search (Layer->line_tree, screen, NULL, line_callback, Layer); + /* draw all visible lines this layer */ + r_search(Layer->line_tree, screen, NULL, line_callback, Layer); - /* draw the layer arcs on screen */ - r_search (Layer->arc_tree, screen, NULL, arc_callback, Layer); + /* draw the layer arcs on screen */ + r_search(Layer->arc_tree, screen, NULL, arc_callback, Layer); - /* draw the layer text on screen */ - r_search (Layer->text_tree, screen, NULL, text_callback, Layer); + /* draw the layer text on screen */ + r_search(Layer->text_tree, screen, NULL, text_callback, Layer); - /* We should check for gui->gui here, but it's kinda cool seeing the - auto-outline magically disappear when you first add something to - the "outline" layer. */ - if (IsLayerEmpty (Layer) - && (strcmp (Layer->Name, "outline") == 0 - || strcmp (Layer->Name, "route") == 0)) - { - gui->set_color (Output.fgGC, Layer->Color); - gui->set_line_width (Output.fgGC, PCB->minWid); - gui->draw_rect (Output.fgGC, - 0, 0, - PCB->MaxWidth, PCB->MaxHeight); - } + /* We should check for gui->gui here, but it's kinda cool seeing the + auto-outline magically disappear when you first add something to + the "outline" layer. */ + if (IsLayerEmpty(Layer) + && (strcmp(Layer->Name, "outline") == 0 || strcmp(Layer->Name, "route") == 0)) { + gui->set_color(Output.fgGC, Layer->Color); + gui->set_line_width(Output.fgGC, PCB->minWid); + gui->draw_rect(Output.fgGC, 0, 0, PCB->MaxWidth, PCB->MaxHeight); + } } /* --------------------------------------------------------------------------- @@ -1226,288 +1098,258 @@ * draws one layer group. If the exporter is not a GUI, * also draws the pins / pads / vias in this layer group. */ -static void -DrawLayerGroup (int group, const BoxType *drawn_area) +static void DrawLayerGroup(int group, const BoxType * drawn_area) { - int i, rv = 1; - int layernum; - LayerTypePtr Layer; - int n_entries = PCB->LayerGroups.Number[group]; - Cardinal *layers = PCB->LayerGroups.Entries[group]; + int i, rv = 1; + int layernum; + LayerTypePtr Layer; + int n_entries = PCB->LayerGroups.Number[group]; + Cardinal *layers = PCB->LayerGroups.Entries[group]; - for (i = n_entries - 1; i >= 0; i--) - { - layernum = layers[i]; - Layer = PCB->Data->Layer + layers[i]; - if (strcmp (Layer->Name, "outline") == 0 || - strcmp (Layer->Name, "route") == 0) - rv = 0; - if (layernum < max_copper_layer && Layer->On) - DrawLayer (Layer, drawn_area); - } - if (n_entries > 1) - rv = 1; + for (i = n_entries - 1; i >= 0; i--) { + layernum = layers[i]; + Layer = PCB->Data->Layer + layers[i]; + if (strcmp(Layer->Name, "outline") == 0 || strcmp(Layer->Name, "route") == 0) + rv = 0; + if (layernum < max_copper_layer && Layer->On) + DrawLayer(Layer, drawn_area); + } + if (n_entries > 1) + rv = 1; - if (rv && !gui->gui) - DrawPPV (group, drawn_area); + if (rv && !gui->gui) + DrawPPV(group, drawn_area); } -static void -GatherPVName (PinTypePtr Ptr) +static void GatherPVName(PinTypePtr Ptr) { - BoxType box; - bool vert = TEST_FLAG (EDGE2FLAG, Ptr); + BoxType box; + bool vert = TEST_FLAG(EDGE2FLAG, Ptr); - if (vert) - { - box.X1 = Ptr->X - Ptr->Thickness / 2 + Settings.PinoutTextOffsetY; - box.Y1 = Ptr->Y - Ptr->DrillingHole / 2 - Settings.PinoutTextOffsetX; - } - else - { - box.X1 = Ptr->X + Ptr->DrillingHole / 2 + Settings.PinoutTextOffsetX; - box.Y1 = Ptr->Y - Ptr->Thickness / 2 + Settings.PinoutTextOffsetY; - } + if (vert) { + box.X1 = Ptr->X - Ptr->Thickness / 2 + Settings.PinoutTextOffsetY; + box.Y1 = Ptr->Y - Ptr->DrillingHole / 2 - Settings.PinoutTextOffsetX; + } + else { + box.X1 = Ptr->X + Ptr->DrillingHole / 2 + Settings.PinoutTextOffsetX; + box.Y1 = Ptr->Y - Ptr->Thickness / 2 + Settings.PinoutTextOffsetY; + } - if (vert) - { - box.X2 = box.X1; - box.Y2 = box.Y1; - } - else - { - box.X2 = box.X1; - box.Y2 = box.Y1; - } - AddPart (&box); + if (vert) { + box.X2 = box.X1; + box.Y2 = box.Y1; + } + else { + box.X2 = box.X1; + box.Y2 = box.Y1; + } + AddPart(&box); } -static void -GatherPadName (PadTypePtr Pad) +static void GatherPadName(PadTypePtr Pad) { - BoxType box; - bool vert; + BoxType box; + bool vert; - /* should text be vertical ? */ - vert = (Pad->Point1.X == Pad->Point2.X); + /* should text be vertical ? */ + vert = (Pad->Point1.X == Pad->Point2.X); - if (vert) - { - box.X1 = Pad->Point1.X - Pad->Thickness / 2; - box.Y1 = MAX (Pad->Point1.Y, Pad->Point2.Y) + Pad->Thickness / 2; - box.X1 += Settings.PinoutTextOffsetY; - box.Y1 -= Settings.PinoutTextOffsetX; - box.X2 = box.X1; - box.Y2 = box.Y1; - } - else - { - box.X1 = MIN (Pad->Point1.X, Pad->Point2.X) - Pad->Thickness / 2; - box.Y1 = Pad->Point1.Y - Pad->Thickness / 2; - box.X1 += Settings.PinoutTextOffsetX; - box.Y1 += Settings.PinoutTextOffsetY; - box.X2 = box.X1; - box.Y2 = box.Y1; - } + if (vert) { + box.X1 = Pad->Point1.X - Pad->Thickness / 2; + box.Y1 = MAX(Pad->Point1.Y, Pad->Point2.Y) + Pad->Thickness / 2; + box.X1 += Settings.PinoutTextOffsetY; + box.Y1 -= Settings.PinoutTextOffsetX; + box.X2 = box.X1; + box.Y2 = box.Y1; + } + else { + box.X1 = MIN(Pad->Point1.X, Pad->Point2.X) - Pad->Thickness / 2; + box.Y1 = Pad->Point1.Y - Pad->Thickness / 2; + box.X1 += Settings.PinoutTextOffsetX; + box.Y1 += Settings.PinoutTextOffsetY; + box.X2 = box.X1; + box.Y2 = box.Y1; + } - AddPart (&box); - return; + AddPart(&box); + return; } /* --------------------------------------------------------------------------- * lowlevel drawing routine for text objects */ -void -DrawTextLowLevel (TextTypePtr Text, Coord min_line_width) +void DrawTextLowLevel(TextTypePtr Text, Coord min_line_width) { - Coord x = 0; - unsigned char *string = (unsigned char *) Text->TextString; - Cardinal n; - FontTypePtr font = &PCB->Font; + Coord x = 0; + unsigned char *string = (unsigned char *) Text->TextString; + Cardinal n; + FontTypePtr font = &PCB->Font; - while (string && *string) - { - /* draw lines if symbol is valid and data is present */ - if (*string <= MAX_FONTPOSITION && font->Symbol[*string].Valid) - { - LineTypePtr line = font->Symbol[*string].Line; - LineType newline; + while (string && *string) { + /* draw lines if symbol is valid and data is present */ + if (*string <= MAX_FONTPOSITION && font->Symbol[*string].Valid) { + LineTypePtr line = font->Symbol[*string].Line; + LineType newline; - for (n = font->Symbol[*string].LineN; n; n--, line++) - { - /* create one line, scale, move, rotate and swap it */ - newline = *line; - newline.Point1.X = SCALE_TEXT (newline.Point1.X + x, Text->Scale); - newline.Point1.Y = SCALE_TEXT (newline.Point1.Y, Text->Scale); - newline.Point2.X = SCALE_TEXT (newline.Point2.X + x, Text->Scale); - newline.Point2.Y = SCALE_TEXT (newline.Point2.Y, Text->Scale); - newline.Thickness = SCALE_TEXT (newline.Thickness, Text->Scale / 2); - if (newline.Thickness < min_line_width) - newline.Thickness = min_line_width; + for (n = font->Symbol[*string].LineN; n; n--, line++) { + /* create one line, scale, move, rotate and swap it */ + newline = *line; + newline.Point1.X = SCALE_TEXT(newline.Point1.X + x, Text->Scale); + newline.Point1.Y = SCALE_TEXT(newline.Point1.Y, Text->Scale); + newline.Point2.X = SCALE_TEXT(newline.Point2.X + x, Text->Scale); + newline.Point2.Y = SCALE_TEXT(newline.Point2.Y, Text->Scale); + newline.Thickness = SCALE_TEXT(newline.Thickness, Text->Scale / 2); + if (newline.Thickness < min_line_width) + newline.Thickness = min_line_width; - RotateLineLowLevel (&newline, 0, 0, Text->Direction); + RotateLineLowLevel(&newline, 0, 0, Text->Direction); - /* the labels of SMD objects on the bottom - * side haven't been swapped yet, only their offset - */ - if (TEST_FLAG (ONSOLDERFLAG, Text)) - { - newline.Point1.X = SWAP_SIGN_X (newline.Point1.X); - newline.Point1.Y = SWAP_SIGN_Y (newline.Point1.Y); - newline.Point2.X = SWAP_SIGN_X (newline.Point2.X); - newline.Point2.Y = SWAP_SIGN_Y (newline.Point2.Y); + /* the labels of SMD objects on the bottom + * side haven't been swapped yet, only their offset + */ + if (TEST_FLAG(ONSOLDERFLAG, Text)) { + newline.Point1.X = SWAP_SIGN_X(newline.Point1.X); + newline.Point1.Y = SWAP_SIGN_Y(newline.Point1.Y); + newline.Point2.X = SWAP_SIGN_X(newline.Point2.X); + newline.Point2.Y = SWAP_SIGN_Y(newline.Point2.Y); + } + /* add offset and draw line */ + newline.Point1.X += Text->X; + newline.Point1.Y += Text->Y; + newline.Point2.X += Text->X; + newline.Point2.Y += Text->Y; + _draw_line(&newline); + } + + /* move on to next cursor position */ + x += (font->Symbol[*string].Width + font->Symbol[*string].Delta); } - /* add offset and draw line */ - newline.Point1.X += Text->X; - newline.Point1.Y += Text->Y; - newline.Point2.X += Text->X; - newline.Point2.Y += Text->Y; - _draw_line (&newline); - } + else { + /* the default symbol is a filled box */ + BoxType defaultsymbol = PCB->Font.DefaultSymbol; + Coord size = (defaultsymbol.X2 - defaultsymbol.X1) * 6 / 5; - /* move on to next cursor position */ - x += (font->Symbol[*string].Width + font->Symbol[*string].Delta); - } - else - { - /* the default symbol is a filled box */ - BoxType defaultsymbol = PCB->Font.DefaultSymbol; - Coord size = (defaultsymbol.X2 - defaultsymbol.X1) * 6 / 5; + defaultsymbol.X1 = SCALE_TEXT(defaultsymbol.X1 + x, Text->Scale); + defaultsymbol.Y1 = SCALE_TEXT(defaultsymbol.Y1, Text->Scale); + defaultsymbol.X2 = SCALE_TEXT(defaultsymbol.X2 + x, Text->Scale); + defaultsymbol.Y2 = SCALE_TEXT(defaultsymbol.Y2, Text->Scale); - defaultsymbol.X1 = SCALE_TEXT (defaultsymbol.X1 + x, Text->Scale); - defaultsymbol.Y1 = SCALE_TEXT (defaultsymbol.Y1, Text->Scale); - defaultsymbol.X2 = SCALE_TEXT (defaultsymbol.X2 + x, Text->Scale); - defaultsymbol.Y2 = SCALE_TEXT (defaultsymbol.Y2, Text->Scale); + RotateBoxLowLevel(&defaultsymbol, 0, 0, Text->Direction); - RotateBoxLowLevel (&defaultsymbol, 0, 0, Text->Direction); + /* add offset and draw box */ + defaultsymbol.X1 += Text->X; + defaultsymbol.Y1 += Text->Y; + defaultsymbol.X2 += Text->X; + defaultsymbol.Y2 += Text->Y; + gui->fill_rect(Output.fgGC, defaultsymbol.X1, defaultsymbol.Y1, defaultsymbol.X2, defaultsymbol.Y2); - /* add offset and draw box */ - defaultsymbol.X1 += Text->X; - defaultsymbol.Y1 += Text->Y; - defaultsymbol.X2 += Text->X; - defaultsymbol.Y2 += Text->Y; - gui->fill_rect (Output.fgGC, - defaultsymbol.X1, defaultsymbol.Y1, - defaultsymbol.X2, defaultsymbol.Y2); - - /* move on to next cursor position */ - x += size; + /* move on to next cursor position */ + x += size; + } + string++; } - string++; - } } /* --------------------------------------------------------------------------- * draw a via object */ -void -DrawVia (PinTypePtr Via) +void DrawVia(PinTypePtr Via) { - AddPart (Via); - if (!TEST_FLAG (HOLEFLAG, Via) && TEST_FLAG (DISPLAYNAMEFLAG, Via)) - DrawViaName (Via); + AddPart(Via); + if (!TEST_FLAG(HOLEFLAG, Via) && TEST_FLAG(DISPLAYNAMEFLAG, Via)) + DrawViaName(Via); } /* --------------------------------------------------------------------------- * draws the name of a via */ -void -DrawViaName (PinTypePtr Via) +void DrawViaName(PinTypePtr Via) { - GatherPVName (Via); + GatherPVName(Via); } /* --------------------------------------------------------------------------- * draw a pin object */ -void -DrawPin (PinTypePtr Pin) +void DrawPin(PinTypePtr Pin) { - AddPart (Pin); - if ((!TEST_FLAG (HOLEFLAG, Pin) && TEST_FLAG (DISPLAYNAMEFLAG, Pin)) - || doing_pinout) - DrawPinName (Pin); + AddPart(Pin); + if ((!TEST_FLAG(HOLEFLAG, Pin) && TEST_FLAG(DISPLAYNAMEFLAG, Pin)) + || doing_pinout) + DrawPinName(Pin); } /* --------------------------------------------------------------------------- * draws the name of a pin */ -void -DrawPinName (PinTypePtr Pin) +void DrawPinName(PinTypePtr Pin) { - GatherPVName (Pin); + GatherPVName(Pin); } /* --------------------------------------------------------------------------- * draw a pad object */ -void -DrawPad (PadTypePtr Pad) +void DrawPad(PadTypePtr Pad) { - AddPart (Pad); - if (doing_pinout || TEST_FLAG (DISPLAYNAMEFLAG, Pad)) - DrawPadName (Pad); + AddPart(Pad); + if (doing_pinout || TEST_FLAG(DISPLAYNAMEFLAG, Pad)) + DrawPadName(Pad); } /* --------------------------------------------------------------------------- * draws the name of a pad */ -void -DrawPadName (PadTypePtr Pad) +void DrawPadName(PadTypePtr Pad) { - GatherPadName (Pad); + GatherPadName(Pad); } /* --------------------------------------------------------------------------- * draws a line on a layer */ -void -DrawLine (LayerTypePtr Layer, LineTypePtr Line) +void DrawLine(LayerTypePtr Layer, LineTypePtr Line) { - AddPart (Line); + AddPart(Line); } /* --------------------------------------------------------------------------- * draws a ratline */ -void -DrawRat (RatTypePtr Rat) +void DrawRat(RatTypePtr Rat) { - if (Settings.RatThickness < 20) - Rat->Thickness = pixel_slop * Settings.RatThickness; - /* rats.c set VIAFLAG if this rat goes to a containing poly: draw a donut */ - if (TEST_FLAG(VIAFLAG, Rat)) - { - Coord w = Rat->Thickness; + if (Settings.RatThickness < 20) + Rat->Thickness = pixel_slop * Settings.RatThickness; + /* rats.c set VIAFLAG if this rat goes to a containing poly: draw a donut */ + if (TEST_FLAG(VIAFLAG, Rat)) { + Coord w = Rat->Thickness; - BoxType b; + BoxType b; - b.X1 = Rat->Point1.X - w * 2 - w / 2; - b.X2 = Rat->Point1.X + w * 2 + w / 2; - b.Y1 = Rat->Point1.Y - w * 2 - w / 2; - b.Y2 = Rat->Point1.Y + w * 2 + w / 2; - AddPart (&b); - } - else - DrawLine (NULL, (LineType *)Rat); + b.X1 = Rat->Point1.X - w * 2 - w / 2; + b.X2 = Rat->Point1.X + w * 2 + w / 2; + b.Y1 = Rat->Point1.Y - w * 2 - w / 2; + b.Y2 = Rat->Point1.Y + w * 2 + w / 2; + AddPart(&b); + } + else + DrawLine(NULL, (LineType *) Rat); } /* --------------------------------------------------------------------------- * draws an arc on a layer */ -void -DrawArc (LayerTypePtr Layer, ArcTypePtr Arc) +void DrawArc(LayerTypePtr Layer, ArcTypePtr Arc) { - AddPart (Arc); + AddPart(Arc); } /* --------------------------------------------------------------------------- * draws a text on a layer */ -void -DrawText (LayerTypePtr Layer, TextTypePtr Text) +void DrawText(LayerTypePtr Layer, TextTypePtr Text) { - AddPart (Text); + AddPart(Text); } @@ -1514,76 +1356,70 @@ /* --------------------------------------------------------------------------- * draws a polygon on a layer */ -void -DrawPolygon (LayerTypePtr Layer, PolygonTypePtr Polygon) +void DrawPolygon(LayerTypePtr Layer, PolygonTypePtr Polygon) { - AddPart (Polygon); + AddPart(Polygon); } /* --------------------------------------------------------------------------- * draws an element */ -void -DrawElement (ElementTypePtr Element) +void DrawElement(ElementTypePtr Element) { - DrawElementPackage (Element); - DrawElementName (Element); - DrawElementPinsAndPads (Element); + DrawElementPackage(Element); + DrawElementName(Element); + DrawElementPinsAndPads(Element); } /* --------------------------------------------------------------------------- * draws the name of an element */ -void -DrawElementName (ElementTypePtr Element) +void DrawElementName(ElementTypePtr Element) { - if (TEST_FLAG (HIDENAMEFLAG, Element)) - return; - DrawText (NULL, &ELEMENT_TEXT (PCB, Element)); + if (TEST_FLAG(HIDENAMEFLAG, Element)) + return; + DrawText(NULL, &ELEMENT_TEXT(PCB, Element)); } /* --------------------------------------------------------------------------- * draws the package of an element */ -void -DrawElementPackage (ElementTypePtr Element) +void DrawElementPackage(ElementTypePtr Element) { - ELEMENTLINE_LOOP (Element); - { - DrawLine (NULL, line); - } - END_LOOP; - ARC_LOOP (Element); - { - DrawArc (NULL, arc); - } - END_LOOP; + ELEMENTLINE_LOOP(Element); + { + DrawLine(NULL, line); + } + END_LOOP; + ARC_LOOP(Element); + { + DrawArc(NULL, arc); + } + END_LOOP; } /* --------------------------------------------------------------------------- * draw pins of an element */ -void -DrawElementPinsAndPads (ElementTypePtr Element) +void DrawElementPinsAndPads(ElementTypePtr Element) { - PAD_LOOP (Element); - { - if (doing_pinout || doing_assy || FRONT (pad) || PCB->InvisibleObjectsOn) - DrawPad (pad); - } - END_LOOP; - PIN_LOOP (Element); - { - DrawPin (pin); - } - END_LOOP; + PAD_LOOP(Element); + { + if (doing_pinout || doing_assy || FRONT(pad) || PCB->InvisibleObjectsOn) + DrawPad(pad); + } + END_LOOP; + PIN_LOOP(Element); + { + DrawPin(pin); + } + END_LOOP; } -void -EraseFlags(FlagType *f) +void EraseFlags(FlagType * f) { unknown_flag_t *u, *next; - for(u = f->unknowns; u != NULL; u = next) { + for (u = f->unknowns; u != NULL; u = next) { free(u->str); next = u->next; free(u); @@ -1594,36 +1430,33 @@ /* --------------------------------------------------------------------------- * erase a via */ -void -EraseVia (PinTypePtr Via) +void EraseVia(PinTypePtr Via) { - AddPart (Via); - if (TEST_FLAG (DISPLAYNAMEFLAG, Via)) - EraseViaName (Via); - EraseFlags(&Via->Flags); + AddPart(Via); + if (TEST_FLAG(DISPLAYNAMEFLAG, Via)) + EraseViaName(Via); + EraseFlags(&Via->Flags); } /* --------------------------------------------------------------------------- * erase a ratline */ -void -EraseRat (RatTypePtr Rat) +void EraseRat(RatTypePtr Rat) { - if (TEST_FLAG(VIAFLAG, Rat)) - { - Coord w = Rat->Thickness; + if (TEST_FLAG(VIAFLAG, Rat)) { + Coord w = Rat->Thickness; - BoxType b; + BoxType b; - b.X1 = Rat->Point1.X - w * 2 - w / 2; - b.X2 = Rat->Point1.X + w * 2 + w / 2; - b.Y1 = Rat->Point1.Y - w * 2 - w / 2; - b.Y2 = Rat->Point1.Y + w * 2 + w / 2; - AddPart (&b); - } - else - EraseLine ((LineType *)Rat); - EraseFlags(&Rat->Flags); + b.X1 = Rat->Point1.X - w * 2 - w / 2; + b.X2 = Rat->Point1.X + w * 2 + w / 2; + b.Y1 = Rat->Point1.Y - w * 2 - w / 2; + b.Y2 = Rat->Point1.Y + w * 2 + w / 2; + AddPart(&b); + } + else + EraseLine((LineType *) Rat); + EraseFlags(&Rat->Flags); } @@ -1630,239 +1463,220 @@ /* --------------------------------------------------------------------------- * erase a via name */ -void -EraseViaName (PinTypePtr Via) +void EraseViaName(PinTypePtr Via) { - GatherPVName (Via); + GatherPVName(Via); } /* --------------------------------------------------------------------------- * erase a pad object */ -void -ErasePad (PadTypePtr Pad) +void ErasePad(PadTypePtr Pad) { - AddPart (Pad); - if (TEST_FLAG (DISPLAYNAMEFLAG, Pad)) - ErasePadName (Pad); - EraseFlags(&Pad->Flags); + AddPart(Pad); + if (TEST_FLAG(DISPLAYNAMEFLAG, Pad)) + ErasePadName(Pad); + EraseFlags(&Pad->Flags); } /* --------------------------------------------------------------------------- * erase a pad name */ -void -ErasePadName (PadTypePtr Pad) +void ErasePadName(PadTypePtr Pad) { - GatherPadName (Pad); + GatherPadName(Pad); } /* --------------------------------------------------------------------------- * erase a pin object */ -void -ErasePin (PinTypePtr Pin) +void ErasePin(PinTypePtr Pin) { - AddPart (Pin); - if (TEST_FLAG (DISPLAYNAMEFLAG, Pin)) - ErasePinName (Pin); - EraseFlags(&Pin->Flags); + AddPart(Pin); + if (TEST_FLAG(DISPLAYNAMEFLAG, Pin)) + ErasePinName(Pin); + EraseFlags(&Pin->Flags); } /* --------------------------------------------------------------------------- * erase a pin name */ -void -ErasePinName (PinTypePtr Pin) +void ErasePinName(PinTypePtr Pin) { - GatherPVName (Pin); + GatherPVName(Pin); } /* --------------------------------------------------------------------------- * erases a line on a layer */ -void -EraseLine (LineTypePtr Line) +void EraseLine(LineTypePtr Line) { - AddPart (Line); - EraseFlags(&Line->Flags); + AddPart(Line); + EraseFlags(&Line->Flags); } /* --------------------------------------------------------------------------- * erases an arc on a layer */ -void -EraseArc (ArcTypePtr Arc) +void EraseArc(ArcTypePtr Arc) { - if (!Arc->Thickness) - return; - AddPart (Arc); - EraseFlags(&Arc->Flags); + if (!Arc->Thickness) + return; + AddPart(Arc); + EraseFlags(&Arc->Flags); } /* --------------------------------------------------------------------------- * erases a text on a layer */ -void -EraseText (LayerTypePtr Layer, TextTypePtr Text) +void EraseText(LayerTypePtr Layer, TextTypePtr Text) { - AddPart (Text); + AddPart(Text); } /* --------------------------------------------------------------------------- * erases a polygon on a layer */ -void -ErasePolygon (PolygonTypePtr Polygon) +void ErasePolygon(PolygonTypePtr Polygon) { - AddPart (Polygon); - EraseFlags(&Polygon->Flags); + AddPart(Polygon); + EraseFlags(&Polygon->Flags); } /* --------------------------------------------------------------------------- * erases an element */ -void -EraseElement (ElementTypePtr Element) +void EraseElement(ElementTypePtr Element) { - ELEMENTLINE_LOOP (Element); - { - EraseLine (line); - } - END_LOOP; - ARC_LOOP (Element); - { - EraseArc (arc); - } - END_LOOP; - EraseElementName (Element); - EraseElementPinsAndPads (Element); - EraseFlags(&Element->Flags); + ELEMENTLINE_LOOP(Element); + { + EraseLine(line); + } + END_LOOP; + ARC_LOOP(Element); + { + EraseArc(arc); + } + END_LOOP; + EraseElementName(Element); + EraseElementPinsAndPads(Element); + EraseFlags(&Element->Flags); } /* --------------------------------------------------------------------------- * erases all pins and pads of an element */ -void -EraseElementPinsAndPads (ElementTypePtr Element) +void EraseElementPinsAndPads(ElementTypePtr Element) { - PIN_LOOP (Element); - { - ErasePin (pin); - } - END_LOOP; - PAD_LOOP (Element); - { - ErasePad (pad); - } - END_LOOP; + PIN_LOOP(Element); + { + ErasePin(pin); + } + END_LOOP; + PAD_LOOP(Element); + { + ErasePad(pad); + } + END_LOOP; } /* --------------------------------------------------------------------------- * erases the name of an element */ -void -EraseElementName (ElementTypePtr Element) +void EraseElementName(ElementTypePtr Element) { - if (TEST_FLAG (HIDENAMEFLAG, Element)) - return; - DrawText (NULL, &ELEMENT_TEXT (PCB, Element)); + if (TEST_FLAG(HIDENAMEFLAG, Element)) + return; + DrawText(NULL, &ELEMENT_TEXT(PCB, Element)); } -void -EraseObject (int type, void *lptr, void *ptr) +void EraseObject(int type, void *lptr, void *ptr) { - switch (type) - { - case VIA_TYPE: - case PIN_TYPE: - ErasePin ((PinTypePtr) ptr); - break; - case TEXT_TYPE: - case ELEMENTNAME_TYPE: - EraseText ((LayerTypePtr)lptr, (TextTypePtr) ptr); - break; - case POLYGON_TYPE: - ErasePolygon ((PolygonTypePtr) ptr); - break; - case ELEMENT_TYPE: - EraseElement ((ElementTypePtr) ptr); - break; - case LINE_TYPE: - case ELEMENTLINE_TYPE: - case RATLINE_TYPE: - EraseLine ((LineTypePtr) ptr); - break; - case PAD_TYPE: - ErasePad ((PadTypePtr) ptr); - break; - case ARC_TYPE: - case ELEMENTARC_TYPE: - EraseArc ((ArcTypePtr) ptr); - break; - default: - Message ("hace: Internal ERROR, trying to erase an unknown type\n"); - } + switch (type) { + case VIA_TYPE: + case PIN_TYPE: + ErasePin((PinTypePtr) ptr); + break; + case TEXT_TYPE: + case ELEMENTNAME_TYPE: + EraseText((LayerTypePtr) lptr, (TextTypePtr) ptr); + break; + case POLYGON_TYPE: + ErasePolygon((PolygonTypePtr) ptr); + break; + case ELEMENT_TYPE: + EraseElement((ElementTypePtr) ptr); + break; + case LINE_TYPE: + case ELEMENTLINE_TYPE: + case RATLINE_TYPE: + EraseLine((LineTypePtr) ptr); + break; + case PAD_TYPE: + ErasePad((PadTypePtr) ptr); + break; + case ARC_TYPE: + case ELEMENTARC_TYPE: + EraseArc((ArcTypePtr) ptr); + break; + default: + Message("hace: Internal ERROR, trying to erase an unknown type\n"); + } } -void -DrawObject (int type, void *ptr1, void *ptr2) +void DrawObject(int type, void *ptr1, void *ptr2) { - switch (type) - { - case VIA_TYPE: - if (PCB->ViaOn) - DrawVia ((PinTypePtr) ptr2); - break; - case LINE_TYPE: - if (((LayerTypePtr) ptr1)->On) - DrawLine ((LayerTypePtr) ptr1, (LineTypePtr) ptr2); - break; - case ARC_TYPE: - if (((LayerTypePtr) ptr1)->On) - DrawArc ((LayerTypePtr) ptr1, (ArcTypePtr) ptr2); - break; - case TEXT_TYPE: - if (((LayerTypePtr) ptr1)->On) - DrawText ((LayerTypePtr) ptr1, (TextTypePtr) ptr2); - break; - case POLYGON_TYPE: - if (((LayerTypePtr) ptr1)->On) - DrawPolygon ((LayerTypePtr) ptr1, (PolygonTypePtr) ptr2); - break; - case ELEMENT_TYPE: - if (PCB->ElementOn && - (FRONT ((ElementTypePtr) ptr2) || PCB->InvisibleObjectsOn)) - DrawElement ((ElementTypePtr) ptr2); - break; - case RATLINE_TYPE: - if (PCB->RatOn) - DrawRat ((RatTypePtr) ptr2); - break; - case PIN_TYPE: - if (PCB->PinOn) - DrawPin ((PinTypePtr) ptr2); - break; - case PAD_TYPE: - if (PCB->PinOn) - DrawPad ((PadTypePtr) ptr2); - break; - case ELEMENTNAME_TYPE: - if (PCB->ElementOn && - (FRONT ((ElementTypePtr) ptr2) || PCB->InvisibleObjectsOn)) - DrawElementName ((ElementTypePtr) ptr1); - break; - } + switch (type) { + case VIA_TYPE: + if (PCB->ViaOn) + DrawVia((PinTypePtr) ptr2); + break; + case LINE_TYPE: + if (((LayerTypePtr) ptr1)->On) + DrawLine((LayerTypePtr) ptr1, (LineTypePtr) ptr2); + break; + case ARC_TYPE: + if (((LayerTypePtr) ptr1)->On) + DrawArc((LayerTypePtr) ptr1, (ArcTypePtr) ptr2); + break; + case TEXT_TYPE: + if (((LayerTypePtr) ptr1)->On) + DrawText((LayerTypePtr) ptr1, (TextTypePtr) ptr2); + break; + case POLYGON_TYPE: + if (((LayerTypePtr) ptr1)->On) + DrawPolygon((LayerTypePtr) ptr1, (PolygonTypePtr) ptr2); + break; + case ELEMENT_TYPE: + if (PCB->ElementOn && (FRONT((ElementTypePtr) ptr2) || PCB->InvisibleObjectsOn)) + DrawElement((ElementTypePtr) ptr2); + break; + case RATLINE_TYPE: + if (PCB->RatOn) + DrawRat((RatTypePtr) ptr2); + break; + case PIN_TYPE: + if (PCB->PinOn) + DrawPin((PinTypePtr) ptr2); + break; + case PAD_TYPE: + if (PCB->PinOn) + DrawPad((PadTypePtr) ptr2); + break; + case ELEMENTNAME_TYPE: + if (PCB->ElementOn && (FRONT((ElementTypePtr) ptr2) || PCB->InvisibleObjectsOn)) + DrawElementName((ElementTypePtr) ptr1); + break; + } } -static void -draw_element (ElementTypePtr element) +static void draw_element(ElementTypePtr element) { - draw_element_package (element); - draw_element_name (element); - draw_element_pins_and_pads (element); + draw_element_package(element); + draw_element_name(element); + draw_element_pins_and_pads(element); } /* --------------------------------------------------------------------------- @@ -1869,30 +1683,28 @@ * HID drawing callback. */ -void -hid_expose_callback (HID * hid, BoxType * region, void *item) +void hid_expose_callback(HID * hid, BoxType * region, void *item) { - HID *old_gui = gui; + HID *old_gui = gui; - gui = hid; - Output.fgGC = gui->make_gc (); - Output.bgGC = gui->make_gc (); - Output.pmGC = gui->make_gc (); + gui = hid; + Output.fgGC = gui->make_gc(); + Output.bgGC = gui->make_gc(); + Output.pmGC = gui->make_gc(); - hid->set_color (Output.pmGC, "erase"); - hid->set_color (Output.bgGC, "drill"); + hid->set_color(Output.pmGC, "erase"); + hid->set_color(Output.bgGC, "drill"); - if (item) - { - doing_pinout = true; - draw_element ((ElementType *)item); - doing_pinout = false; - } - else - DrawEverything (region); + if (item) { + doing_pinout = true; + draw_element((ElementType *) item); + doing_pinout = false; + } + else + DrawEverything(region); - gui->destroy_gc (Output.fgGC); - gui->destroy_gc (Output.bgGC); - gui->destroy_gc (Output.pmGC); - gui = old_gui; + gui->destroy_gc(Output.fgGC); + gui->destroy_gc(Output.bgGC); + gui->destroy_gc(Output.pmGC); + gui = old_gui; } Index: trunk/src/draw.h =================================================================== --- trunk/src/draw.h (revision 1021) +++ trunk/src/draw.h (revision 1022) @@ -35,40 +35,40 @@ /*bool SwitchDrawingWindow(double, GdkDrawable *, gboolean, gboolean);*/ -void Draw (void); -void Redraw (void); -void DrawVia (PinTypePtr); -void DrawRat (RatTypePtr); -void DrawViaName (PinTypePtr); -void DrawPin (PinTypePtr); -void DrawPinName (PinTypePtr); -void DrawPad (PadTypePtr); -void DrawPadName (PadTypePtr); -void DrawLine (LayerTypePtr, LineTypePtr); -void DrawArc (LayerTypePtr, ArcTypePtr); -void DrawText (LayerTypePtr, TextTypePtr); -void DrawTextLowLevel (TextTypePtr, Coord); -void DrawPolygon (LayerTypePtr, PolygonTypePtr); -void DrawElement (ElementTypePtr); -void DrawElementName (ElementTypePtr); -void DrawElementPackage (ElementTypePtr); -void DrawElementPinsAndPads (ElementTypePtr); -void DrawObject (int, void *, void *); -void DrawLayer (LayerTypePtr, const BoxType *); -void EraseVia (PinTypePtr); -void EraseRat (RatTypePtr); -void EraseViaName (PinTypePtr); -void ErasePad (PadTypePtr); -void ErasePadName (PadTypePtr); -void ErasePin (PinTypePtr); -void ErasePinName (PinTypePtr); -void EraseLine (LineTypePtr); -void EraseArc (ArcTypePtr); -void EraseText (LayerTypePtr, TextTypePtr); -void ErasePolygon (PolygonTypePtr); -void EraseElement (ElementTypePtr); -void EraseElementPinsAndPads (ElementTypePtr); -void EraseElementName (ElementTypePtr); -void EraseObject (int, void *, void *); +void Draw(void); +void Redraw(void); +void DrawVia(PinTypePtr); +void DrawRat(RatTypePtr); +void DrawViaName(PinTypePtr); +void DrawPin(PinTypePtr); +void DrawPinName(PinTypePtr); +void DrawPad(PadTypePtr); +void DrawPadName(PadTypePtr); +void DrawLine(LayerTypePtr, LineTypePtr); +void DrawArc(LayerTypePtr, ArcTypePtr); +void DrawText(LayerTypePtr, TextTypePtr); +void DrawTextLowLevel(TextTypePtr, Coord); +void DrawPolygon(LayerTypePtr, PolygonTypePtr); +void DrawElement(ElementTypePtr); +void DrawElementName(ElementTypePtr); +void DrawElementPackage(ElementTypePtr); +void DrawElementPinsAndPads(ElementTypePtr); +void DrawObject(int, void *, void *); +void DrawLayer(LayerTypePtr, const BoxType *); +void EraseVia(PinTypePtr); +void EraseRat(RatTypePtr); +void EraseViaName(PinTypePtr); +void ErasePad(PadTypePtr); +void ErasePadName(PadTypePtr); +void ErasePin(PinTypePtr); +void ErasePinName(PinTypePtr); +void EraseLine(LineTypePtr); +void EraseArc(ArcTypePtr); +void EraseText(LayerTypePtr, TextTypePtr); +void ErasePolygon(PolygonTypePtr); +void EraseElement(ElementTypePtr); +void EraseElementPinsAndPads(ElementTypePtr); +void EraseElementName(ElementTypePtr); +void EraseObject(int, void *, void *); #endif Index: trunk/src/drill.c =================================================================== --- trunk/src/drill.c (revision 1021) +++ trunk/src/drill.c (revision 1022) @@ -38,7 +38,7 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); @@ -46,247 +46,212 @@ /* * some local prototypes */ -static void FillDrill (DrillTypePtr, ElementTypePtr, PinTypePtr); -static void InitializeDrill (DrillTypePtr, PinTypePtr, ElementTypePtr); +static void FillDrill(DrillTypePtr, ElementTypePtr, PinTypePtr); +static void InitializeDrill(DrillTypePtr, PinTypePtr, ElementTypePtr); -static void -FillDrill (DrillTypePtr Drill, ElementTypePtr Element, PinTypePtr Pin) +static void FillDrill(DrillTypePtr Drill, ElementTypePtr Element, PinTypePtr Pin) { - Cardinal n; - ElementTypeHandle ptr; - PinTypeHandle pin; + Cardinal 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; + 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 (HOLEFLAG, Pin)) - Drill->UnplatedCount++; + else + Drill->ViaCount++; + if (TEST_FLAG(HOLEFLAG, Pin)) + Drill->UnplatedCount++; } -static void -InitializeDrill (DrillTypePtr drill, PinTypePtr pin, ElementTypePtr element) +static void InitializeDrill(DrillTypePtr drill, PinTypePtr pin, ElementTypePtr element) { - void *ptr; + 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 (HOLEFLAG, pin)) - drill->UnplatedCount = 1; + 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(HOLEFLAG, pin)) + drill->UnplatedCount = 1; } -static int -DrillQSort (const void *va, const void *vb) +static int DrillQSort(const void *va, const void *vb) { - DrillType *a = (DrillType *) va; - DrillType *b = (DrillType *) vb; - return a->DrillSize - b->DrillSize; + DrillType *a = (DrillType *) va; + DrillType *b = (DrillType *) vb; + return a->DrillSize - b->DrillSize; } -DrillInfoTypePtr -GetDrillInfo (DataTypePtr top) +DrillInfoTypePtr GetDrillInfo(DataTypePtr top) { - DrillInfoTypePtr AllDrills; - DrillTypePtr Drill = NULL; - DrillType savedrill, swapdrill; - bool DrillFound = false; - bool NewDrill; + DrillInfoTypePtr AllDrills; + DrillTypePtr Drill = NULL; + DrillType savedrill, swapdrill; + bool DrillFound = false; + bool NewDrill; - AllDrills = (DrillInfoTypePtr)calloc (1, sizeof (DrillInfoType)); - ALLPIN_LOOP (top); - { - if (!DrillFound) - { - DrillFound = true; - Drill = GetDrillInfoDrillMemory (AllDrills); - InitializeDrill (Drill, pin, element); - } - else - { - if (Drill->DrillSize == pin->DrillingHole) - FillDrill (Drill, element, pin); - else - { - NewDrill = false; - DRILL_LOOP (AllDrills); - { - if (drill->DrillSize == pin->DrillingHole) - { - Drill = drill; - FillDrill (Drill, element, pin); - break; + AllDrills = (DrillInfoTypePtr) calloc(1, sizeof(DrillInfoType)); + ALLPIN_LOOP(top); + { + if (!DrillFound) { + DrillFound = true; + Drill = GetDrillInfoDrillMemory(AllDrills); + InitializeDrill(Drill, pin, element); } - else if (drill->DrillSize > pin->DrillingHole) - { - if (!NewDrill) - { - NewDrill = true; - InitializeDrill (&swapdrill, pin, element); - Drill = GetDrillInfoDrillMemory (AllDrills); - Drill->DrillSize = pin->DrillingHole + 1; - Drill = drill; - } - savedrill = *drill; - *drill = swapdrill; - swapdrill = savedrill; + else { + if (Drill->DrillSize == pin->DrillingHole) + FillDrill(Drill, element, pin); + else { + NewDrill = 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 = 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); + } + } } - } - 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 = 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; + } + ENDALL_LOOP; + VIA_LOOP(top); + { + if (!DrillFound) { + DrillFound = true; + Drill = GetDrillInfoDrillMemory(AllDrills); + Drill->DrillSize = via->DrillingHole; + FillDrill(Drill, NULL, via); } - } - 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); + 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) +void RoundDrillInfo(DrillInfoTypePtr d, int roundto) { - unsigned int i = 0; + 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); + 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; + 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)); + 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; + 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].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].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; + d->Drill[i].DrillSize = diam1; - memmove (d->Drill + i + 1, - d->Drill + i + 2, - (d->DrillN - i - 2) * sizeof (DrillType)); - d->DrillN--; + memmove(d->Drill + i + 1, d->Drill + i + 2, (d->DrillN - i - 2) * sizeof(DrillType)); + d->DrillN--; + } + else { + d->Drill[i].DrillSize = diam1; + i++; + } } - else - { - d->Drill[i].DrillSize = diam1; - i++; - } - } } -void -FreeDrillInfo (DrillInfoTypePtr Drills) +void FreeDrillInfo(DrillInfoTypePtr Drills) { - DRILL_LOOP (Drills); - { - free (drill->Element); - free (drill->Pin); - } - END_LOOP; - free (Drills->Drill); - free (Drills); + DRILL_LOOP(Drills); + { + free(drill->Element); + free(drill->Pin); + } + END_LOOP; + free(Drills->Drill); + free(Drills); } Index: trunk/src/drill.h =================================================================== --- trunk/src/drill.h (revision 1021) +++ trunk/src/drill.h (revision 1022) @@ -28,6 +28,6 @@ * */ -DrillInfoTypePtr GetDrillInfo (DataTypePtr); -void FreeDrillInfo (DrillInfoTypePtr); -void RoundDrillInfo (DrillInfoTypePtr, int); +DrillInfoTypePtr GetDrillInfo(DataTypePtr); +void FreeDrillInfo(DrillInfoTypePtr); +void RoundDrillInfo(DrillInfoTypePtr, int); Index: trunk/src/ds.c =================================================================== --- trunk/src/ds.c (revision 1021) +++ trunk/src/ds.c (revision 1022) @@ -4,53 +4,47 @@ /* --------------------------------------------------------------------------- * reallocates memory for a dynamic length string if necessary */ -static void -DSRealloc (DynamicStringTypePtr Ptr, size_t Length) +static void DSRealloc(DynamicStringTypePtr Ptr, size_t Length) { - int input_null = (Ptr->Data == NULL); - if (input_null || Length >= Ptr->MaxLength) - { - Ptr->MaxLength = Length + 512; - Ptr->Data = (char *)realloc (Ptr->Data, Ptr->MaxLength); - if (input_null) - Ptr->Data[0] = '\0'; - } + int input_null = (Ptr->Data == NULL); + if (input_null || Length >= Ptr->MaxLength) { + Ptr->MaxLength = Length + 512; + Ptr->Data = (char *) realloc(Ptr->Data, Ptr->MaxLength); + if (input_null) + Ptr->Data[0] = '\0'; + } } /* --------------------------------------------------------------------------- * adds one character to a dynamic string */ -void -DSAddCharacter (DynamicStringTypePtr Ptr, char Char) +void DSAddCharacter(DynamicStringTypePtr Ptr, char Char) { - size_t position = Ptr->Data ? strlen (Ptr->Data) : 0; + size_t position = Ptr->Data ? strlen(Ptr->Data) : 0; - DSRealloc (Ptr, position + 1); - Ptr->Data[position++] = Char; - Ptr->Data[position] = '\0'; + DSRealloc(Ptr, position + 1); + Ptr->Data[position++] = Char; + Ptr->Data[position] = '\0'; } /* --------------------------------------------------------------------------- * add a string to a dynamic string */ -void -DSAddString (DynamicStringTypePtr Ptr, const char *S) +void DSAddString(DynamicStringTypePtr Ptr, const char *S) { - size_t position = Ptr->Data ? strlen (Ptr->Data) : 0; + size_t position = Ptr->Data ? strlen(Ptr->Data) : 0; - if (S && *S) - { - DSRealloc (Ptr, position + 1 + strlen (S)); - strcat (&Ptr->Data[position], S); - } + if (S && *S) { + DSRealloc(Ptr, position + 1 + strlen(S)); + strcat(&Ptr->Data[position], S); + } } /* ---------------------------------------------------------------------- * clears a dynamic string */ -void -DSClearString (DynamicStringTypePtr Ptr) +void DSClearString(DynamicStringTypePtr Ptr) { - if (Ptr->Data) - Ptr->Data[0] = '\0'; + if (Ptr->Data) + Ptr->Data[0] = '\0'; } Index: trunk/src/ds.h =================================================================== --- trunk/src/ds.h (revision 1021) +++ trunk/src/ds.h (revision 1022) @@ -1,11 +1,10 @@ #include -typedef struct -{ - size_t MaxLength; - char *Data; +typedef struct { + size_t MaxLength; + char *Data; } DynamicStringType, *DynamicStringTypePtr; -void DSAddCharacter (DynamicStringTypePtr, char); -void DSAddString (DynamicStringTypePtr, const char *); -void DSClearString (DynamicStringTypePtr); +void DSAddCharacter(DynamicStringTypePtr, char); +void DSAddString(DynamicStringTypePtr, const char *); +void DSClearString(DynamicStringTypePtr); Index: trunk/src/edif.c =================================================================== --- trunk/src/edif.c (revision 1021) +++ trunk/src/edif.c (revision 1022) @@ -107,8 +107,8 @@ #include "global.h" #include "data.h" /* from mymem.h, not include because of the malloc junk */ -LibraryMenuTypePtr GetLibraryMenuMemory (LibraryTypePtr); -LibraryEntryTypePtr GetLibraryEntryMemory (LibraryMenuTypePtr); +LibraryMenuTypePtr GetLibraryMenuMemory(LibraryTypePtr); +LibraryEntryTypePtr GetLibraryEntryMemory(LibraryMenuTypePtr); /* * Local definitions. @@ -119,151 +119,141 @@ #define Getc(s) getc(s) #define Ungetc(c) ungetc(c,Input) - typedef struct _str_pair - { - char* str1; - char* str2; - struct _str_pair* next; - } str_pair; +typedef struct _str_pair { + char *str1; + char *str2; + struct _str_pair *next; +} str_pair; - typedef struct _pair_list - { - char* name; - str_pair* list; - } pair_list; +typedef struct _pair_list { + char *name; + str_pair *list; +} pair_list; - str_pair* new_str_pair(char* s1, char* s2) - { - str_pair* ps = (str_pair *)malloc(sizeof(str_pair)); - ps->str1 = s1; - ps->str2 = s2; - ps->next = NULL; - return ps; - } - - pair_list* new_pair_list(str_pair* ps) - { - pair_list* pl = (pair_list *)malloc(sizeof(pair_list)); - pl->list = ps; - pl->name = NULL; - return pl; - } +str_pair *new_str_pair(char *s1, char *s2) +{ + str_pair *ps = (str_pair *) malloc(sizeof(str_pair)); + ps->str1 = s1; + ps->str2 = s2; + ps->next = NULL; + return ps; +} - void str_pair_free(str_pair* ps) - { - str_pair* node; - while ( ps ) - { - free(ps->str1); - free(ps->str2); - node = ps; - ps = ps->next; - free(node); - } - } - - void pair_list_free(pair_list* pl) - { - str_pair_free(pl->list); - free(pl->name); - free(pl); - } +pair_list *new_pair_list(str_pair * ps) +{ + pair_list *pl = (pair_list *) malloc(sizeof(pair_list)); + pl->list = ps; + pl->name = NULL; + return pl; +} - void define_pcb_net(str_pair* name, pair_list* nodes) - { - int tl; - str_pair* done_node; - str_pair* node; - char* buf; - char* p; - LibraryEntryTypePtr entry; - LibraryMenuTypePtr menu = GetLibraryMenuMemory (&(PCB->NetlistLib[NETLIST_EDITED])); +void str_pair_free(str_pair * ps) +{ + str_pair *node; + while (ps) { + free(ps->str1); + free(ps->str2); + node = ps; + ps = ps->next; + free(node); + } +} - if ( !name->str1 ) - { - /* no net name given, stop now */ - /* if renamed str2 also exists and must be freed */ - if ( name->str2 ) free(name->str2); - free(name); - pair_list_free(nodes); - return; - } - menu->Name = strdup (name->str1); - free(name->str1); - /* if renamed str2 also exists and must be freed */ - if ( name->str2 ) free(name->str2); - free(name); - buf = (char *)malloc(256); - if ( !buf ) - { - /* no memory */ - pair_list_free(nodes); - return; - } +void pair_list_free(pair_list * pl) +{ + str_pair_free(pl->list); + free(pl->name); + free(pl); +} - node = nodes->list; - free(nodes->name); - free(nodes); - while ( node ) - { - /* check for node with no instance */ - if ( !node->str1 ) - { - /* toss it and move on */ - free(node->str2); - done_node = node; - node = node->next; - free(done_node); - continue; - } - tl = strlen(node->str1) + strlen(node->str2); - if ( tl + 3 > 256 ) - { - free(buf); - buf = (char *)malloc(tl+3); - if ( !buf ) - { - /* no memory */ - str_pair_free(node); - return; - } - } - strcpy(buf,node->str1); - /* make all upper case, because of PCB funky behaviour */ - p=buf; - while ( *p ) - { - *p = toupper( (int) *p); - p++; - } - /* add dash separating designator from node */ - *(buf+strlen(node->str1)) = '-'; - /* check for the edif number prefix */ - if ( node->str2[0] == '&' ) - { - /* skip number prefix */ - strcpy(buf+strlen(node->str1)+1,node->str2 +1); - } - else - { - strcpy(buf+strlen(node->str1)+1,node->str2); - } - /* free the strings */ - free(node->str1); - free(node->str2); - entry = GetLibraryEntryMemory (menu); - entry->ListEntry = strdup(buf); - done_node = node; - node = node->next; - free(done_node); - } - } - - +void define_pcb_net(str_pair * name, pair_list * nodes) +{ + int tl; + str_pair *done_node; + str_pair *node; + char *buf; + char *p; + LibraryEntryTypePtr entry; + LibraryMenuTypePtr menu = GetLibraryMenuMemory(&(PCB->NetlistLib[NETLIST_EDITED])); + + if (!name->str1) { + /* no net name given, stop now */ + /* if renamed str2 also exists and must be freed */ + if (name->str2) + free(name->str2); + free(name); + pair_list_free(nodes); + return; + } + menu->Name = strdup(name->str1); + free(name->str1); + /* if renamed str2 also exists and must be freed */ + if (name->str2) + free(name->str2); + free(name); + buf = (char *) malloc(256); + if (!buf) { + /* no memory */ + pair_list_free(nodes); + return; + } + + node = nodes->list; + free(nodes->name); + free(nodes); + while (node) { + /* check for node with no instance */ + if (!node->str1) { + /* toss it and move on */ + free(node->str2); + done_node = node; + node = node->next; + free(done_node); + continue; + } + tl = strlen(node->str1) + strlen(node->str2); + if (tl + 3 > 256) { + free(buf); + buf = (char *) malloc(tl + 3); + if (!buf) { + /* no memory */ + str_pair_free(node); + return; + } + } + strcpy(buf, node->str1); + /* make all upper case, because of PCB funky behaviour */ + p = buf; + while (*p) { + *p = toupper((int) *p); + p++; + } + /* add dash separating designator from node */ + *(buf + strlen(node->str1)) = '-'; + /* check for the edif number prefix */ + if (node->str2[0] == '&') { + /* skip number prefix */ + strcpy(buf + strlen(node->str1) + 1, node->str2 + 1); + } + else { + strcpy(buf + strlen(node->str1) + 1, node->str2); + } + /* free the strings */ + free(node->str1); + free(node->str2); + entry = GetLibraryEntryMemory(menu); + entry->ListEntry = strdup(buf); + done_node = node; + node = node->next; + free(done_node); + } +} + + /* forward function declarations */ - static int yylex(void); - static void yyerror(const char *); - static void PopC(void); +static int yylex(void); +static void yyerror(const char *); +static void PopC(void); /* Line 189 of yacc.c */ @@ -271,322 +261,322 @@ /* Enabling traces. */ #ifndef YYDEBUG -# define YYDEBUG 0 +#define YYDEBUG 0 #endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 +#undef YYERROR_VERBOSE +#define YYERROR_VERBOSE 1 #else -# define YYERROR_VERBOSE 0 +#define YYERROR_VERBOSE 0 #endif /* Enabling the token table. */ #ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 0 +#define YYTOKEN_TABLE 0 #endif /* Tokens. */ #ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - EDIF_TOK_IDENT = 258, - EDIF_TOK_INT = 259, - EDIF_TOK_KEYWORD = 260, - EDIF_TOK_STR = 261, - EDIF_TOK_ANGLE = 262, - EDIF_TOK_BEHAVIOR = 263, - EDIF_TOK_CALCULATED = 264, - EDIF_TOK_CAPACITANCE = 265, - EDIF_TOK_CENTERCENTER = 266, - EDIF_TOK_CENTERLEFT = 267, - EDIF_TOK_CENTERRIGHT = 268, - EDIF_TOK_CHARGE = 269, - EDIF_TOK_CONDUCTANCE = 270, - EDIF_TOK_CURRENT = 271, - EDIF_TOK_DISTANCE = 272, - EDIF_TOK_DOCUMENT = 273, - EDIF_TOK_ENERGY = 274, - EDIF_TOK_EXTEND = 275, - EDIF_TOK_FLUX = 276, - EDIF_TOK_FREQUENCY = 277, - EDIF_TOK_GENERIC = 278, - EDIF_TOK_GRAPHIC = 279, - EDIF_TOK_INDUCTANCE = 280, - EDIF_TOK_INOUT = 281, - EDIF_TOK_INPUT = 282, - EDIF_TOK_LOGICMODEL = 283, - EDIF_TOK_LOWERCENTER = 284, - EDIF_TOK_LOWERLEFT = 285, - EDIF_TOK_LOWERRIGHT = 286, - EDIF_TOK_MASKLAYOUT = 287, - EDIF_TOK_MASS = 288, - EDIF_TOK_MEASURED = 289, - EDIF_TOK_MX = 290, - EDIF_TOK_MXR90 = 291, - EDIF_TOK_MY = 292, - EDIF_TOK_MYR90 = 293, - EDIF_TOK_NETLIST = 294, - EDIF_TOK_OUTPUT = 295, - EDIF_TOK_PCBLAYOUT = 296, - EDIF_TOK_POWER = 297, - EDIF_TOK_R0 = 298, - EDIF_TOK_R180 = 299, - EDIF_TOK_R270 = 300, - EDIF_TOK_R90 = 301, - EDIF_TOK_REQUIRED = 302, - EDIF_TOK_RESISTANCE = 303, - EDIF_TOK_RIPPER = 304, - EDIF_TOK_ROUND = 305, - EDIF_TOK_SCHEMATIC = 306, - EDIF_TOK_STRANGER = 307, - EDIF_TOK_SYMBOLIC = 308, - EDIF_TOK_TEMPERATURE = 309, - EDIF_TOK_TIE = 310, - EDIF_TOK_TIME = 311, - EDIF_TOK_TRUNCATE = 312, - EDIF_TOK_UPPERCENTER = 313, - EDIF_TOK_UPPERLEFT = 314, - EDIF_TOK_UPPERRIGHT = 315, - EDIF_TOK_VOLTAGE = 316, - EDIF_TOK_ACLOAD = 317, - EDIF_TOK_AFTER = 318, - EDIF_TOK_ANNOTATE = 319, - EDIF_TOK_APPLY = 320, - EDIF_TOK_ARC = 321, - EDIF_TOK_ARRAY = 322, - EDIF_TOK_ARRAYMACRO = 323, - EDIF_TOK_ARRAYRELATEDINFO = 324, - EDIF_TOK_ARRAYSITE = 325, - EDIF_TOK_ATLEAST = 326, - EDIF_TOK_ATMOST = 327, - EDIF_TOK_AUTHOR = 328, - EDIF_TOK_BASEARRAY = 329, - EDIF_TOK_BECOMES = 330, - EDIF_TOK_BETWEEN = 331, - EDIF_TOK_BOOLEAN = 332, - EDIF_TOK_BOOLEANDISPLAY = 333, - EDIF_TOK_BOOLEANMAP = 334, - EDIF_TOK_BORDERPATTERN = 335, - EDIF_TOK_BORDERWIDTH = 336, - EDIF_TOK_BOUNDINGBOX = 337, - EDIF_TOK_CELL = 338, - EDIF_TOK_CELLREF = 339, - EDIF_TOK_CELLTYPE = 340, - EDIF_TOK_CHANGE = 341, - EDIF_TOK_CIRCLE = 342, - EDIF_TOK_COLOR = 343, - EDIF_TOK_COMMENT = 344, - EDIF_TOK_COMMENTGRAPHICS = 345, - EDIF_TOK_COMPOUND = 346, - EDIF_TOK_CONNECTLOCATION = 347, - EDIF_TOK_CONTENTS = 348, - EDIF_TOK_CORNERTYPE = 349, - EDIF_TOK_CRITICALITY = 350, - EDIF_TOK_CURRENTMAP = 351, - EDIF_TOK_CURVE = 352, - EDIF_TOK_CYCLE = 353, - EDIF_TOK_DATAORIGIN = 354, - EDIF_TOK_DCFANINLOAD = 355, - EDIF_TOK_DCFANOUTLOAD = 356, - EDIF_TOK_DCMAXFANIN = 357, - EDIF_TOK_DCMAXFANOUT = 358, - EDIF_TOK_DELAY = 359, - EDIF_TOK_DELTA = 360, - EDIF_TOK_DERIVATION = 361, - EDIF_TOK_DESIGN = 362, - EDIF_TOK_DESIGNATOR = 363, - EDIF_TOK_DIFFERENCE = 364, - EDIF_TOK_DIRECTION = 365, - EDIF_TOK_DISPLAY = 366, - EDIF_TOK_DOMINATES = 367, - EDIF_TOK_DOT = 368, - EDIF_TOK_DURATION = 369, - EDIF_TOK_E = 370, - EDIF_TOK_EDIF = 371, - EDIF_TOK_EDIFLEVEL = 372, - EDIF_TOK_EDIFVERSION = 373, - EDIF_TOK_ENCLOSUREDISTANCE = 374, - EDIF_TOK_ENDTYPE = 375, - EDIF_TOK_ENTRY = 376, - EDIF_TOK_EVENT = 377, - EDIF_TOK_EXACTLY = 378, - EDIF_TOK_EXTERNAL = 379, - EDIF_TOK_FABRICATE = 380, - EDIF_TOK_FALSE = 381, - EDIF_TOK_FIGURE = 382, - EDIF_TOK_FIGUREAREA = 383, - EDIF_TOK_FIGUREGROUP = 384, - EDIF_TOK_FIGUREGROUPOBJECT = 385, - EDIF_TOK_FIGUREGROUPOVERRIDE = 386, - EDIF_TOK_FIGUREGROUPREF = 387, - EDIF_TOK_FIGUREPERIMETER = 388, - EDIF_TOK_FIGUREWIDTH = 389, - EDIF_TOK_FILLPATTERN = 390, - EDIF_TOK_FOLLOW = 391, - EDIF_TOK_FORBIDDENEVENT = 392, - EDIF_TOK_GLOBALPORTREF = 393, - EDIF_TOK_GREATERTHAN = 394, - EDIF_TOK_GRIDMAP = 395, - EDIF_TOK_IGNORE = 396, - EDIF_TOK_INCLUDEFIGUREGROUP = 397, - EDIF_TOK_INITIAL = 398, - EDIF_TOK_INSTANCE = 399, - EDIF_TOK_INSTANCEBACKANNOTATE = 400, - EDIF_TOK_INSTANCEGROUP = 401, - EDIF_TOK_INSTANCEMAP = 402, - EDIF_TOK_INSTANCEREF = 403, - EDIF_TOK_INTEGER = 404, - EDIF_TOK_INTEGERDISPLAY = 405, - EDIF_TOK_INTERFACE = 406, - EDIF_TOK_INTERFIGUREGROUPSPACING = 407, - EDIF_TOK_INTERSECTION = 408, - EDIF_TOK_INTRAFIGUREGROUPSPACING = 409, - EDIF_TOK_INVERSE = 410, - EDIF_TOK_ISOLATED = 411, - EDIF_TOK_JOINED = 412, - EDIF_TOK_JUSTIFY = 413, - EDIF_TOK_KEYWORDDISPLAY = 414, - EDIF_TOK_KEYWORDLEVEL = 415, - EDIF_TOK_KEYWORDMAP = 416, - EDIF_TOK_LESSTHAN = 417, - EDIF_TOK_LIBRARY = 418, - EDIF_TOK_LIBRARYREF = 419, - EDIF_TOK_LISTOFNETS = 420, - EDIF_TOK_LISTOFPORTS = 421, - EDIF_TOK_LOADDELAY = 422, - EDIF_TOK_LOGICASSIGN = 423, - EDIF_TOK_LOGICINPUT = 424, - EDIF_TOK_LOGICLIST = 425, - EDIF_TOK_LOGICMAPINPUT = 426, - EDIF_TOK_LOGICMAPOUTPUT = 427, - EDIF_TOK_LOGICONEOF = 428, - EDIF_TOK_LOGICOUTPUT = 429, - EDIF_TOK_LOGICPORT = 430, - EDIF_TOK_LOGICREF = 431, - EDIF_TOK_LOGICVALUE = 432, - EDIF_TOK_LOGICWAVEFORM = 433, - EDIF_TOK_MAINTAIN = 434, - EDIF_TOK_MATCH = 435, - EDIF_TOK_MEMBER = 436, - EDIF_TOK_MINOMAX = 437, - EDIF_TOK_MINOMAXDISPLAY = 438, - EDIF_TOK_MNM = 439, - EDIF_TOK_MULTIPLEVALUESET = 440, - EDIF_TOK_MUSTJOIN = 441, - EDIF_TOK_NAME = 442, - EDIF_TOK_NET = 443, - EDIF_TOK_NETBACKANNOTATE = 444, - EDIF_TOK_NETBUNDLE = 445, - EDIF_TOK_NETDELAY = 446, - EDIF_TOK_NETGROUP = 447, - EDIF_TOK_NETMAP = 448, - EDIF_TOK_NETREF = 449, - EDIF_TOK_NOCHANGE = 450, - EDIF_TOK_NONPERMUTABLE = 451, - EDIF_TOK_NOTALLOWED = 452, - EDIF_TOK_NOTCHSPACING = 453, - EDIF_TOK_NUMBER = 454, - EDIF_TOK_NUMBERDEFINITION = 455, - EDIF_TOK_NUMBERDISPLAY = 456, - EDIF_TOK_OFFPAGECONNECTOR = 457, - EDIF_TOK_OFFSETEVENT = 458, - EDIF_TOK_OPENSHAPE = 459, - EDIF_TOK_ORIENTATION = 460, - EDIF_TOK_ORIGIN = 461, - EDIF_TOK_OVERHANGDISTANCE = 462, - EDIF_TOK_OVERLAPDISTANCE = 463, - EDIF_TOK_OVERSIZE = 464, - EDIF_TOK_OWNER = 465, - EDIF_TOK_PAGE = 466, - EDIF_TOK_PAGESIZE = 467, - EDIF_TOK_PARAMETER = 468, - EDIF_TOK_PARAMETERASSIGN = 469, - EDIF_TOK_PARAMETERDISPLAY = 470, - EDIF_TOK_PATH = 471, - EDIF_TOK_PATHDELAY = 472, - EDIF_TOK_PATHWIDTH = 473, - EDIF_TOK_PERMUTABLE = 474, - EDIF_TOK_PHYSICALDESIGNRULE = 475, - EDIF_TOK_PLUG = 476, - EDIF_TOK_POINT = 477, - EDIF_TOK_POINTDISPLAY = 478, - EDIF_TOK_POINTLIST = 479, - EDIF_TOK_POLYGON = 480, - EDIF_TOK_PORT = 481, - EDIF_TOK_PORTBACKANNOTATE = 482, - EDIF_TOK_PORTBUNDLE = 483, - EDIF_TOK_PORTDELAY = 484, - EDIF_TOK_PORTGROUP = 485, - EDIF_TOK_PORTIMPLEMENTATION = 486, - EDIF_TOK_PORTINSTANCE = 487, - EDIF_TOK_PORTLIST = 488, - EDIF_TOK_PORTLISTALIAS = 489, - EDIF_TOK_PORTMAP = 490, - EDIF_TOK_PORTREF = 491, - EDIF_TOK_PROGRAM = 492, - EDIF_TOK_PROPERTY = 493, - EDIF_TOK_PROPERTYDISPLAY = 494, - EDIF_TOK_PROTECTIONFRAME = 495, - EDIF_TOK_PT = 496, - EDIF_TOK_RANGEVECTOR = 497, - EDIF_TOK_RECTANGLE = 498, - EDIF_TOK_RECTANGLESIZE = 499, - EDIF_TOK_RENAME = 500, - EDIF_TOK_RESOLVES = 501, - EDIF_TOK_SCALE = 502, - EDIF_TOK_SCALEX = 503, - EDIF_TOK_SCALEY = 504, - EDIF_TOK_SECTION = 505, - EDIF_TOK_SHAPE = 506, - EDIF_TOK_SIMULATE = 507, - EDIF_TOK_SIMULATIONINFO = 508, - EDIF_TOK_SINGLEVALUESET = 509, - EDIF_TOK_SITE = 510, - EDIF_TOK_SOCKET = 511, - EDIF_TOK_SOCKETSET = 512, - EDIF_TOK_STATUS = 513, - EDIF_TOK_STEADY = 514, - EDIF_TOK_STRING = 515, - EDIF_TOK_STRINGDISPLAY = 516, - EDIF_TOK_STRONG = 517, - EDIF_TOK_SYMBOL = 518, - EDIF_TOK_SYMMETRY = 519, - EDIF_TOK_TABLE = 520, - EDIF_TOK_TABLEDEFAULT = 521, - EDIF_TOK_TECHNOLOGY = 522, - EDIF_TOK_TEXTHEIGHT = 523, - EDIF_TOK_TIMEINTERVAL = 524, - EDIF_TOK_TIMESTAMP = 525, - EDIF_TOK_TIMING = 526, - EDIF_TOK_TRANSFORM = 527, - EDIF_TOK_TRANSITION = 528, - EDIF_TOK_TRIGGER = 529, - EDIF_TOK_TRUE = 530, - EDIF_TOK_UNCONSTRAINED = 531, - EDIF_TOK_UNDEFINED = 532, - EDIF_TOK_UNION = 533, - EDIF_TOK_UNIT = 534, - EDIF_TOK_UNUSED = 535, - EDIF_TOK_USERDATA = 536, - EDIF_TOK_VERSION = 537, - EDIF_TOK_VIEW = 538, - EDIF_TOK_VIEWLIST = 539, - EDIF_TOK_VIEWMAP = 540, - EDIF_TOK_VIEWREF = 541, - EDIF_TOK_VIEWTYPE = 542, - EDIF_TOK_VISIBLE = 543, - EDIF_TOK_VOLTAGEMAP = 544, - EDIF_TOK_WAVEVALUE = 545, - EDIF_TOK_WEAK = 546, - EDIF_TOK_WEAKJOINED = 547, - EDIF_TOK_WHEN = 548, - EDIF_TOK_WRITTEN = 549 - }; +#define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ +enum yytokentype { + EDIF_TOK_IDENT = 258, + EDIF_TOK_INT = 259, + EDIF_TOK_KEYWORD = 260, + EDIF_TOK_STR = 261, + EDIF_TOK_ANGLE = 262, + EDIF_TOK_BEHAVIOR = 263, + EDIF_TOK_CALCULATED = 264, + EDIF_TOK_CAPACITANCE = 265, + EDIF_TOK_CENTERCENTER = 266, + EDIF_TOK_CENTERLEFT = 267, + EDIF_TOK_CENTERRIGHT = 268, + EDIF_TOK_CHARGE = 269, + EDIF_TOK_CONDUCTANCE = 270, + EDIF_TOK_CURRENT = 271, + EDIF_TOK_DISTANCE = 272, + EDIF_TOK_DOCUMENT = 273, + EDIF_TOK_ENERGY = 274, + EDIF_TOK_EXTEND = 275, + EDIF_TOK_FLUX = 276, + EDIF_TOK_FREQUENCY = 277, + EDIF_TOK_GENERIC = 278, + EDIF_TOK_GRAPHIC = 279, + EDIF_TOK_INDUCTANCE = 280, + EDIF_TOK_INOUT = 281, + EDIF_TOK_INPUT = 282, + EDIF_TOK_LOGICMODEL = 283, + EDIF_TOK_LOWERCENTER = 284, + EDIF_TOK_LOWERLEFT = 285, + EDIF_TOK_LOWERRIGHT = 286, + EDIF_TOK_MASKLAYOUT = 287, + EDIF_TOK_MASS = 288, + EDIF_TOK_MEASURED = 289, + EDIF_TOK_MX = 290, + EDIF_TOK_MXR90 = 291, + EDIF_TOK_MY = 292, + EDIF_TOK_MYR90 = 293, + EDIF_TOK_NETLIST = 294, + EDIF_TOK_OUTPUT = 295, + EDIF_TOK_PCBLAYOUT = 296, + EDIF_TOK_POWER = 297, + EDIF_TOK_R0 = 298, + EDIF_TOK_R180 = 299, + EDIF_TOK_R270 = 300, + EDIF_TOK_R90 = 301, + EDIF_TOK_REQUIRED = 302, + EDIF_TOK_RESISTANCE = 303, + EDIF_TOK_RIPPER = 304, + EDIF_TOK_ROUND = 305, + EDIF_TOK_SCHEMATIC = 306, + EDIF_TOK_STRANGER = 307, + EDIF_TOK_SYMBOLIC = 308, + EDIF_TOK_TEMPERATURE = 309, + EDIF_TOK_TIE = 310, + EDIF_TOK_TIME = 311, + EDIF_TOK_TRUNCATE = 312, + EDIF_TOK_UPPERCENTER = 313, + EDIF_TOK_UPPERLEFT = 314, + EDIF_TOK_UPPERRIGHT = 315, + EDIF_TOK_VOLTAGE = 316, + EDIF_TOK_ACLOAD = 317, + EDIF_TOK_AFTER = 318, + EDIF_TOK_ANNOTATE = 319, + EDIF_TOK_APPLY = 320, + EDIF_TOK_ARC = 321, + EDIF_TOK_ARRAY = 322, + EDIF_TOK_ARRAYMACRO = 323, + EDIF_TOK_ARRAYRELATEDINFO = 324, + EDIF_TOK_ARRAYSITE = 325, + EDIF_TOK_ATLEAST = 326, + EDIF_TOK_ATMOST = 327, + EDIF_TOK_AUTHOR = 328, + EDIF_TOK_BASEARRAY = 329, + EDIF_TOK_BECOMES = 330, + EDIF_TOK_BETWEEN = 331, + EDIF_TOK_BOOLEAN = 332, + EDIF_TOK_BOOLEANDISPLAY = 333, + EDIF_TOK_BOOLEANMAP = 334, + EDIF_TOK_BORDERPATTERN = 335, + EDIF_TOK_BORDERWIDTH = 336, + EDIF_TOK_BOUNDINGBOX = 337, + EDIF_TOK_CELL = 338, + EDIF_TOK_CELLREF = 339, + EDIF_TOK_CELLTYPE = 340, + EDIF_TOK_CHANGE = 341, + EDIF_TOK_CIRCLE = 342, + EDIF_TOK_COLOR = 343, + EDIF_TOK_COMMENT = 344, + EDIF_TOK_COMMENTGRAPHICS = 345, + EDIF_TOK_COMPOUND = 346, + EDIF_TOK_CONNECTLOCATION = 347, + EDIF_TOK_CONTENTS = 348, + EDIF_TOK_CORNERTYPE = 349, + EDIF_TOK_CRITICALITY = 350, + EDIF_TOK_CURRENTMAP = 351, + EDIF_TOK_CURVE = 352, + EDIF_TOK_CYCLE = 353, + EDIF_TOK_DATAORIGIN = 354, + EDIF_TOK_DCFANINLOAD = 355, + EDIF_TOK_DCFANOUTLOAD = 356, + EDIF_TOK_DCMAXFANIN = 357, + EDIF_TOK_DCMAXFANOUT = 358, + EDIF_TOK_DELAY = 359, + EDIF_TOK_DELTA = 360, + EDIF_TOK_DERIVATION = 361, + EDIF_TOK_DESIGN = 362, + EDIF_TOK_DESIGNATOR = 363, + EDIF_TOK_DIFFERENCE = 364, + EDIF_TOK_DIRECTION = 365, + EDIF_TOK_DISPLAY = 366, + EDIF_TOK_DOMINATES = 367, + EDIF_TOK_DOT = 368, + EDIF_TOK_DURATION = 369, + EDIF_TOK_E = 370, + EDIF_TOK_EDIF = 371, + EDIF_TOK_EDIFLEVEL = 372, + EDIF_TOK_EDIFVERSION = 373, + EDIF_TOK_ENCLOSUREDISTANCE = 374, + EDIF_TOK_ENDTYPE = 375, + EDIF_TOK_ENTRY = 376, + EDIF_TOK_EVENT = 377, + EDIF_TOK_EXACTLY = 378, + EDIF_TOK_EXTERNAL = 379, + EDIF_TOK_FABRICATE = 380, + EDIF_TOK_FALSE = 381, + EDIF_TOK_FIGURE = 382, + EDIF_TOK_FIGUREAREA = 383, + EDIF_TOK_FIGUREGROUP = 384, + EDIF_TOK_FIGUREGROUPOBJECT = 385, + EDIF_TOK_FIGUREGROUPOVERRIDE = 386, + EDIF_TOK_FIGUREGROUPREF = 387, + EDIF_TOK_FIGUREPERIMETER = 388, + EDIF_TOK_FIGUREWIDTH = 389, + EDIF_TOK_FILLPATTERN = 390, + EDIF_TOK_FOLLOW = 391, + EDIF_TOK_FORBIDDENEVENT = 392, + EDIF_TOK_GLOBALPORTREF = 393, + EDIF_TOK_GREATERTHAN = 394, + EDIF_TOK_GRIDMAP = 395, + EDIF_TOK_IGNORE = 396, + EDIF_TOK_INCLUDEFIGUREGROUP = 397, + EDIF_TOK_INITIAL = 398, + EDIF_TOK_INSTANCE = 399, + EDIF_TOK_INSTANCEBACKANNOTATE = 400, + EDIF_TOK_INSTANCEGROUP = 401, + EDIF_TOK_INSTANCEMAP = 402, + EDIF_TOK_INSTANCEREF = 403, + EDIF_TOK_INTEGER = 404, + EDIF_TOK_INTEGERDISPLAY = 405, + EDIF_TOK_INTERFACE = 406, + EDIF_TOK_INTERFIGUREGROUPSPACING = 407, + EDIF_TOK_INTERSECTION = 408, + EDIF_TOK_INTRAFIGUREGROUPSPACING = 409, + EDIF_TOK_INVERSE = 410, + EDIF_TOK_ISOLATED = 411, + EDIF_TOK_JOINED = 412, + EDIF_TOK_JUSTIFY = 413, + EDIF_TOK_KEYWORDDISPLAY = 414, + EDIF_TOK_KEYWORDLEVEL = 415, + EDIF_TOK_KEYWORDMAP = 416, + EDIF_TOK_LESSTHAN = 417, + EDIF_TOK_LIBRARY = 418, + EDIF_TOK_LIBRARYREF = 419, + EDIF_TOK_LISTOFNETS = 420, + EDIF_TOK_LISTOFPORTS = 421, + EDIF_TOK_LOADDELAY = 422, + EDIF_TOK_LOGICASSIGN = 423, + EDIF_TOK_LOGICINPUT = 424, + EDIF_TOK_LOGICLIST = 425, + EDIF_TOK_LOGICMAPINPUT = 426, + EDIF_TOK_LOGICMAPOUTPUT = 427, + EDIF_TOK_LOGICONEOF = 428, + EDIF_TOK_LOGICOUTPUT = 429, + EDIF_TOK_LOGICPORT = 430, + EDIF_TOK_LOGICREF = 431, + EDIF_TOK_LOGICVALUE = 432, + EDIF_TOK_LOGICWAVEFORM = 433, + EDIF_TOK_MAINTAIN = 434, + EDIF_TOK_MATCH = 435, + EDIF_TOK_MEMBER = 436, + EDIF_TOK_MINOMAX = 437, + EDIF_TOK_MINOMAXDISPLAY = 438, + EDIF_TOK_MNM = 439, + EDIF_TOK_MULTIPLEVALUESET = 440, + EDIF_TOK_MUSTJOIN = 441, + EDIF_TOK_NAME = 442, + EDIF_TOK_NET = 443, + EDIF_TOK_NETBACKANNOTATE = 444, + EDIF_TOK_NETBUNDLE = 445, + EDIF_TOK_NETDELAY = 446, + EDIF_TOK_NETGROUP = 447, + EDIF_TOK_NETMAP = 448, + EDIF_TOK_NETREF = 449, + EDIF_TOK_NOCHANGE = 450, + EDIF_TOK_NONPERMUTABLE = 451, + EDIF_TOK_NOTALLOWED = 452, + EDIF_TOK_NOTCHSPACING = 453, + EDIF_TOK_NUMBER = 454, + EDIF_TOK_NUMBERDEFINITION = 455, + EDIF_TOK_NUMBERDISPLAY = 456, + EDIF_TOK_OFFPAGECONNECTOR = 457, + EDIF_TOK_OFFSETEVENT = 458, + EDIF_TOK_OPENSHAPE = 459, + EDIF_TOK_ORIENTATION = 460, + EDIF_TOK_ORIGIN = 461, + EDIF_TOK_OVERHANGDISTANCE = 462, + EDIF_TOK_OVERLAPDISTANCE = 463, + EDIF_TOK_OVERSIZE = 464, + EDIF_TOK_OWNER = 465, + EDIF_TOK_PAGE = 466, + EDIF_TOK_PAGESIZE = 467, + EDIF_TOK_PARAMETER = 468, + EDIF_TOK_PARAMETERASSIGN = 469, + EDIF_TOK_PARAMETERDISPLAY = 470, + EDIF_TOK_PATH = 471, + EDIF_TOK_PATHDELAY = 472, + EDIF_TOK_PATHWIDTH = 473, + EDIF_TOK_PERMUTABLE = 474, + EDIF_TOK_PHYSICALDESIGNRULE = 475, + EDIF_TOK_PLUG = 476, + EDIF_TOK_POINT = 477, + EDIF_TOK_POINTDISPLAY = 478, + EDIF_TOK_POINTLIST = 479, + EDIF_TOK_POLYGON = 480, + EDIF_TOK_PORT = 481, + EDIF_TOK_PORTBACKANNOTATE = 482, + EDIF_TOK_PORTBUNDLE = 483, + EDIF_TOK_PORTDELAY = 484, + EDIF_TOK_PORTGROUP = 485, + EDIF_TOK_PORTIMPLEMENTATION = 486, + EDIF_TOK_PORTINSTANCE = 487, + EDIF_TOK_PORTLIST = 488, + EDIF_TOK_PORTLISTALIAS = 489, + EDIF_TOK_PORTMAP = 490, + EDIF_TOK_PORTREF = 491, + EDIF_TOK_PROGRAM = 492, + EDIF_TOK_PROPERTY = 493, + EDIF_TOK_PROPERTYDISPLAY = 494, + EDIF_TOK_PROTECTIONFRAME = 495, + EDIF_TOK_PT = 496, + EDIF_TOK_RANGEVECTOR = 497, + EDIF_TOK_RECTANGLE = 498, + EDIF_TOK_RECTANGLESIZE = 499, + EDIF_TOK_RENAME = 500, + EDIF_TOK_RESOLVES = 501, + EDIF_TOK_SCALE = 502, + EDIF_TOK_SCALEX = 503, + EDIF_TOK_SCALEY = 504, + EDIF_TOK_SECTION = 505, + EDIF_TOK_SHAPE = 506, + EDIF_TOK_SIMULATE = 507, + EDIF_TOK_SIMULATIONINFO = 508, + EDIF_TOK_SINGLEVALUESET = 509, + EDIF_TOK_SITE = 510, + EDIF_TOK_SOCKET = 511, + EDIF_TOK_SOCKETSET = 512, + EDIF_TOK_STATUS = 513, + EDIF_TOK_STEADY = 514, + EDIF_TOK_STRING = 515, + EDIF_TOK_STRINGDISPLAY = 516, + EDIF_TOK_STRONG = 517, + EDIF_TOK_SYMBOL = 518, + EDIF_TOK_SYMMETRY = 519, + EDIF_TOK_TABLE = 520, + EDIF_TOK_TABLEDEFAULT = 521, + EDIF_TOK_TECHNOLOGY = 522, + EDIF_TOK_TEXTHEIGHT = 523, + EDIF_TOK_TIMEINTERVAL = 524, + EDIF_TOK_TIMESTAMP = 525, + EDIF_TOK_TIMING = 526, + EDIF_TOK_TRANSFORM = 527, + EDIF_TOK_TRANSITION = 528, + EDIF_TOK_TRIGGER = 529, + EDIF_TOK_TRUE = 530, + EDIF_TOK_UNCONSTRAINED = 531, + EDIF_TOK_UNDEFINED = 532, + EDIF_TOK_UNION = 533, + EDIF_TOK_UNIT = 534, + EDIF_TOK_UNUSED = 535, + EDIF_TOK_USERDATA = 536, + EDIF_TOK_VERSION = 537, + EDIF_TOK_VIEW = 538, + EDIF_TOK_VIEWLIST = 539, + EDIF_TOK_VIEWMAP = 540, + EDIF_TOK_VIEWREF = 541, + EDIF_TOK_VIEWTYPE = 542, + EDIF_TOK_VISIBLE = 543, + EDIF_TOK_VOLTAGEMAP = 544, + EDIF_TOK_WAVEVALUE = 545, + EDIF_TOK_WEAK = 546, + EDIF_TOK_WEAKJOINED = 547, + EDIF_TOK_WHEN = 548, + EDIF_TOK_WRITTEN = 549 +}; #endif /* Tokens. */ #define EDIF_TOK_IDENT 258 @@ -886,15 +876,14 @@ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE -{ +typedef union YYSTYPE { /* Line 214 of yacc.c */ #line 193 "edif.y" - char* s; - pair_list* pl; - str_pair* ps; + char *s; + pair_list *pl; + str_pair *ps; @@ -901,9 +890,9 @@ /* Line 214 of yacc.c */ #line 903 "edif.c" } YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 +#define YYSTYPE_IS_TRIVIAL 1 +#define yystype YYSTYPE /* obsolescent; will be withdrawn */ +#define YYSTYPE_IS_DECLARED 1 #endif @@ -914,7 +903,7 @@ #line 915 "edif.c" #ifdef short -# undef short +#undef short #endif #ifdef YYTYPE_UINT8 @@ -945,55 +934,53 @@ #endif #ifndef YYSIZE_T -# ifdef __SIZE_TYPE__ -# define YYSIZE_T __SIZE_TYPE__ -# elif defined size_t -# define YYSIZE_T size_t -# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ +#ifdef __SIZE_TYPE__ +#define YYSIZE_T __SIZE_TYPE__ +#elif defined size_t +#define YYSIZE_T size_t +#elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# else -# define YYSIZE_T unsigned int -# endif +#include /* INFRINGES ON USER NAME SPACE */ +#define YYSIZE_T size_t +#else +#define YYSIZE_T unsigned int #endif +#endif #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS -# if ENABLE_NLS -# include /* INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) -# endif -# endif -# ifndef YY_ -# define YY_(msgid) msgid -# endif +#if defined YYENABLE_NLS && YYENABLE_NLS +#if ENABLE_NLS +#include /* INFRINGES ON USER NAME SPACE */ +#define YY_(msgid) dgettext ("bison-runtime", msgid) #endif +#endif +#ifndef YY_ +#define YY_(msgid) msgid +#endif +#endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ -# define YYUSE(e) ((void) (e)) +#define YYUSE(e) ((void) (e)) #else -# define YYUSE(e) /* empty */ +#define YYUSE(e) /* empty */ #endif /* Identity function, used to suppress warnings about constant conditions. */ #ifndef lint -# define YYID(n) (n) +#define YYID(n) (n) #else #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) -static int -YYID (int yyi) +static int YYID(int yyi) #else -static int -YYID (yyi) - int yyi; +static int YYID(yyi) + int yyi; #endif { - return yyi; + return yyi; } #endif @@ -1001,69 +988,69 @@ /* The parser invokes alloca or malloc; define the necessary symbols. */ -# ifdef YYSTACK_USE_ALLOCA -# if YYSTACK_USE_ALLOCA -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# elif defined __BUILTIN_VA_ARG_INCR -# include /* INFRINGES ON USER NAME SPACE */ -# elif defined _AIX -# define YYSTACK_ALLOC __alloca -# elif defined _MSC_VER -# include /* INFRINGES ON USER NAME SPACE */ -# define alloca _alloca -# else -# define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ +#ifdef YYSTACK_USE_ALLOCA +#if YYSTACK_USE_ALLOCA +#ifdef __GNUC__ +#define YYSTACK_ALLOC __builtin_alloca +#elif defined __BUILTIN_VA_ARG_INCR +#include /* INFRINGES ON USER NAME SPACE */ +#elif defined _AIX +#define YYSTACK_ALLOC __alloca +#elif defined _MSC_VER +#include /* INFRINGES ON USER NAME SPACE */ +#define alloca _alloca +#else +#define YYSTACK_ALLOC alloca +#if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 -# endif -# endif -# endif -# endif -# endif +#include /* INFRINGES ON USER NAME SPACE */ +#ifndef _STDLIB_H +#define _STDLIB_H 1 +#endif +#endif +#endif +#endif +#endif -# ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) -# ifndef YYSTACK_ALLOC_MAXIMUM - /* The OS might guarantee only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - invoke alloca (N) if N exceeds 4096. Use a slightly smaller number - to allow for a few compiler-allocated temporary stack slots. */ -# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ -# endif -# else -# define YYSTACK_ALLOC YYMALLOC -# define YYSTACK_FREE YYFREE -# ifndef YYSTACK_ALLOC_MAXIMUM -# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM -# endif -# if (defined __cplusplus && ! defined _STDLIB_H \ +#ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +#define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +#ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +#define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +#endif +#else +#define YYSTACK_ALLOC YYMALLOC +#define YYSTACK_FREE YYFREE +#ifndef YYSTACK_ALLOC_MAXIMUM +#define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +#endif +#if (defined __cplusplus && ! defined _STDLIB_H \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 -# endif -# endif -# ifndef YYMALLOC -# define YYMALLOC malloc -# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ +#include /* INFRINGES ON USER NAME SPACE */ +#ifndef _STDLIB_H +#define _STDLIB_H 1 +#endif +#endif +#ifndef YYMALLOC +#define YYMALLOC malloc +#if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) -void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# ifndef YYFREE -# define YYFREE free -# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ +void *malloc(YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +#endif +#endif +#ifndef YYFREE +#define YYFREE free +#if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) -void free (void *); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# endif +void free(void *); /* INFRINGES ON USER NAME SPACE */ +#endif +#endif +#endif #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ @@ -1072,29 +1059,28 @@ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ -union yyalloc -{ - yytype_int16 yyss_alloc; - YYSTYPE yyvs_alloc; +union yyalloc { + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) +#define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ -# define YYSTACK_BYTES(N) \ +#define YYSTACK_BYTES(N) \ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ -# ifndef YYCOPY -# if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ +#ifndef YYCOPY +#if defined __GNUC__ && 1 < __GNUC__ +#define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ +#else +#define YYCOPY(To, From, Count) \ do \ { \ YYSIZE_T yyi; \ @@ -1102,8 +1088,8 @@ (To)[yyi] = (From)[yyi]; \ } \ while (YYID (0)) -# endif -# endif +#endif +#endif /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of @@ -1110,7 +1096,7 @@ elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ +#define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ @@ -1145,628 +1131,624 @@ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const yytype_uint16 yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 295, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, - 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, - 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, - 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, - 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, - 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, - 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, - 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, - 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, - 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, - 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, - 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, - 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, - 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, - 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, - 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, - 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, - 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294 +static const yytype_uint16 yytranslate[] = { + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 295, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, + 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, + 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, + 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, + 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, + 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, + 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, + 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, + 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, + 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, + 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, + 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, + 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, + 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, + 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, + 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, + 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, + 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, + 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294 }; #if YYDEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ -static const yytype_uint16 yyprhs[] = -{ - 0, 0, 3, 5, 13, 14, 17, 20, 23, 26, - 29, 32, 34, 38, 44, 48, 50, 52, 56, 58, - 61, 64, 67, 70, 73, 77, 79, 81, 85, 87, - 90, 93, 96, 99, 105, 111, 112, 114, 118, 122, - 124, 126, 128, 131, 134, 138, 142, 146, 150, 153, - 157, 159, 161, 163, 168, 170, 172, 174, 176, 180, - 181, 184, 187, 190, 194, 196, 199, 203, 205, 207, - 213, 217, 221, 226, 228, 231, 234, 237, 240, 243, - 246, 248, 253, 254, 256, 258, 262, 264, 266, 268, - 273, 275, 277, 279, 280, 282, 284, 290, 291, 294, - 300, 304, 305, 308, 312, 313, 316, 319, 322, 325, - 328, 331, 334, 338, 342, 343, 346, 349, 352, 355, - 358, 361, 364, 367, 370, 373, 376, 379, 382, 385, - 388, 391, 394, 398, 399, 401, 405, 407, 409, 411, - 415, 417, 419, 423, 427, 428, 431, 434, 439, 440, - 442, 447, 448, 450, 454, 456, 458, 462, 464, 466, - 470, 472, 474, 478, 480, 482, 486, 488, 490, 494, - 495, 498, 502, 504, 506, 508, 513, 515, 518, 521, - 524, 527, 531, 533, 535, 537, 541, 542, 545, 548, - 551, 554, 557, 560, 563, 566, 569, 572, 575, 578, - 581, 584, 588, 590, 592, 595, 598, 602, 604, 606, - 608, 615, 617, 619, 620, 622, 623, 625, 626, 628, - 632, 633, 636, 640, 642, 645, 649, 656, 658, 660, - 663, 666, 670, 672, 674, 676, 682, 684, 686, 688, - 690, 692, 694, 696, 697, 699, 701, 705, 707, 709, - 711, 713, 715, 718, 721, 725, 731, 733, 736, 739, - 742, 745, 750, 753, 757, 759, 762, 765, 768, 771, - 774, 777, 780, 783, 786, 789, 792, 795, 798, 800, - 802, 806, 808, 810, 812, 816, 818, 821, 824, 827, - 830, 833, 836, 839, 842, 845, 848, 851, 854, 859, - 860, 862, 866, 868, 870, 873, 876, 879, 882, 885, - 888, 891, 894, 897, 903, 905, 907, 910, 913, 915, - 917, 919, 921, 923, 929, 931, 933, 936, 939, 945, - 947, 949, 952, 955, 961, 966, 968, 970, 972, 974, - 977, 980, 984, 986, 989, 993, 994, 997, 1000, 1003, - 1006, 1010, 1014, 1019, 1022, 1026, 1028, 1030, 1033, 1038, - 1040, 1042, 1045, 1048, 1051, 1054, 1057, 1060, 1063, 1066, - 1071, 1072, 1074, 1076, 1080, 1082, 1085, 1088, 1091, 1094, - 1098, 1099, 1102, 1106, 1107, 1110, 1113, 1116, 1119, 1121, - 1123, 1125, 1127, 1131, 1133, 1136, 1140, 1141, 1144, 1147, - 1150, 1154, 1155, 1158, 1161, 1164, 1167, 1170, 1173, 1176, - 1179, 1182, 1185, 1188, 1191, 1194, 1197, 1200, 1203, 1210, - 1212, 1214, 1217, 1220, 1224, 1226, 1228, 1231, 1234, 1240, - 1242, 1244, 1247, 1250, 1254, 1256, 1258, 1261, 1265, 1266, - 1269, 1272, 1275, 1279, 1281, 1283, 1285, 1287, 1289, 1291, - 1293, 1295, 1297, 1301, 1303, 1306, 1310, 1314, 1316, 1319, - 1321, 1323, 1327, 1329, 1331, 1337, 1339, 1342, 1345, 1348, - 1351, 1355, 1359, 1360, 1363, 1367, 1368, 1371, 1374, 1379, - 1381, 1383, 1389, 1391, 1393, 1395, 1397, 1399, 1400, 1402, - 1404, 1408, 1410, 1412, 1414, 1417, 1421, 1422, 1425, 1428, - 1431, 1435, 1436, 1439, 1443, 1444, 1447, 1449, 1451, 1455, - 1456, 1459, 1462, 1466, 1468, 1470, 1472, 1475, 1479, 1481, - 1484, 1487, 1490, 1495, 1496, 1498, 1502, 1504, 1507, 1510, - 1513, 1516, 1519, 1522, 1525, 1528, 1531, 1534, 1537, 1540, - 1543, 1546, 1550, 1551, 1554, 1557, 1560, 1563, 1568, 1570, - 1572, 1573, 1575, 1577, 1582, 1584, 1586, 1588, 1590, 1592, - 1594, 1599, 1601, 1604, 1608, 1609, 1612, 1615, 1618, 1622, - 1624, 1627, 1629, 1631, 1637, 1639, 1641, 1643, 1647, 1648, - 1651, 1655, 1656, 1659, 1662, 1665, 1668, 1672, 1674, 1677, - 1679, 1681, 1683, 1685, 1687, 1692, 1694, 1697, 1700, 1703, - 1706, 1709, 1712, 1715, 1718, 1721, 1725, 1727, 1730, 1733, - 1736, 1739, 1744, 1746, 1749, 1752, 1755, 1758, 1761, 1766, - 1768, 1771, 1774, 1778, 1779, 1782, 1785, 1789, 1790, 1793, - 1796, 1799, 1802, 1804, 1806, 1808, 1810, 1815, 1816, 1818, - 1820, 1822, 1825, 1829, 1830, 1833, 1836, 1841, 1843, 1846, - 1849, 1855, 1857, 1859, 1862, 1865, 1869, 1870, 1873, 1876, - 1879, 1883, 1885, 1888, 1892, 1893, 1896, 1899, 1902, 1906, - 1908, 1911, 1914, 1917, 1920, 1925, 1929, 1931, 1934, 1938, - 1940, 1942, 1944, 1946, 1948, 1950, 1952, 1954, 1958, 1965, - 1967, 1969, 1972, 1975, 1982, 1984, 1986, 1989, 1992, 1998, - 2000, 2002, 2006, 2010, 2012, 2015, 2018, 2021, 2024, 2027, - 2030, 2033, 2036, 2039, 2043, 2047, 2049, 2052, 2058, 2059, - 2061, 2066, 2070, 2072, 2075, 2079, 2081, 2084, 2088, 2092, - 2093, 2096, 2099, 2102, 2106, 2107, 2110, 2114, 2115, 2118, - 2121, 2124, 2128, 2130, 2133, 2137, 2138, 2141, 2146, 2150, - 2152, 2155, 2159, 2161, 2164, 2167, 2170, 2173, 2176, 2179, - 2182, 2185, 2188, 2191, 2194, 2197, 2201, 2203, 2206, 2209, - 2212, 2215, 2218, 2221, 2224, 2227, 2230, 2235, 2237, 2240, - 2243, 2246, 2251, 2253, 2255, 2258, 2261, 2265, 2266, 2269, - 2272, 2276, 2278, 2280, 2283, 2286, 2289, 2292, 2295, 2298, - 2301, 2304, 2307, 2311, 2313, 2315, 2318, 2321, 2324, 2327, - 2330, 2333, 2336, 2339, 2342, 2345, 2348, 2352, 2353, 2356, - 2359, 2364, 2368, 2369, 2372, 2375, 2378, 2381, 2383, 2385, - 2387, 2389, 2394, 2395, 2397, 2399, 2401, 2406, 2407, 2409, - 2413, 2415, 2418, 2423, 2425, 2428, 2431, 2434, 2437, 2439, - 2441, 2445, 2446, 2449, 2452, 2455, 2458, 2461, 2464, 2467, - 2470, 2473, 2476, 2479, 2481, 2483, 2485, 2487, 2489, 2491, - 2495, 2496, 2499, 2502, 2507, 2509, 2512, 2518, 2520, 2522, - 2525, 2528, 2533, 2535, 2537, 2539, 2541, 2545, 2546, 2549, - 2551, 2557, 2559, 2564, 2569, 2574, 2578, 2580, 2583, 2586, - 2589, 2593, 2595, 2598, 2600, 2604, 2606, 2609, 2612, 2615, - 2618, 2621, 2625, 2626, 2629, 2632, 2635, 2639, 2640, 2642, - 2647, 2648, 2650, 2654, 2655, 2657, 2661, 2663, 2666, 2670, - 2671, 2674, 2677, 2680, 2685, 2687, 2689, 2691, 2693, 2696, - 2699, 2703, 2707, 2708, 2711, 2714, 2717, 2719, 2722, 2726, - 2730, 2731, 2734, 2737, 2740, 2743, 2746, 2749, 2752, 2755, - 2758, 2761, 2764, 2767, 2770, 2774, 2775, 2778, 2782, 2783, - 2786, 2789, 2794, 2796, 2798, 2800, 2802, 2803, 2805, 2807, - 2811, 2813, 2816, 2819, 2822, 2825, 2828, 2831, 2835, 2840, - 2842, 2844, 2846, 2848, 2850, 2859, 2863, 2865, 2868, 2871, - 2874, 2877, 2885, 2886, 2888, 2889, 2891, 2892, 2894, 2895, - 2897, 2898, 2900, 2905, 2907, 2909, 2911, 2915, 2916, 2919, - 2922, 2925, 2928, 2930, 2932, 2934, 2936, 2938, 2940, 2943, - 2946, 2950, 2952, 2954, 2957, 2960, 2964, 2966, 2968, 2970, - 2972, 2974, 2976, 2978, 2980, 2982, 2984, 2986, 2988, 2990, - 2992, 2994, 2996, 2999, 3003, 3005, 3008, 3011, 3014, 3017, - 3019, 3021, 3023, 3025, 3029, 3035, 3037, 3040, 3043, 3046, - 3049, 3052, 3056, 3057, 3060, 3063, 3067, 3068, 3071, 3074, - 3077, 3080, 3083, 3086, 3089, 3092, 3094, 3096, 3101, 3102, - 3104, 3108, 3110, 3112, 3114, 3116, 3118, 3120, 3122, 3124, - 3126, 3128, 3132, 3136, 3142, 3146, 3150, 3151, 3154, 3157, - 3160, 3164, 3166, 3169, 3172, 3175, 3178, 3181, 3184, 3188, - 3190, 3193, 3196, 3199, 3202, 3205, 3208, 3210, 3212, 3214 +static const yytype_uint16 yyprhs[] = { + 0, 0, 3, 5, 13, 14, 17, 20, 23, 26, + 29, 32, 34, 38, 44, 48, 50, 52, 56, 58, + 61, 64, 67, 70, 73, 77, 79, 81, 85, 87, + 90, 93, 96, 99, 105, 111, 112, 114, 118, 122, + 124, 126, 128, 131, 134, 138, 142, 146, 150, 153, + 157, 159, 161, 163, 168, 170, 172, 174, 176, 180, + 181, 184, 187, 190, 194, 196, 199, 203, 205, 207, + 213, 217, 221, 226, 228, 231, 234, 237, 240, 243, + 246, 248, 253, 254, 256, 258, 262, 264, 266, 268, + 273, 275, 277, 279, 280, 282, 284, 290, 291, 294, + 300, 304, 305, 308, 312, 313, 316, 319, 322, 325, + 328, 331, 334, 338, 342, 343, 346, 349, 352, 355, + 358, 361, 364, 367, 370, 373, 376, 379, 382, 385, + 388, 391, 394, 398, 399, 401, 405, 407, 409, 411, + 415, 417, 419, 423, 427, 428, 431, 434, 439, 440, + 442, 447, 448, 450, 454, 456, 458, 462, 464, 466, + 470, 472, 474, 478, 480, 482, 486, 488, 490, 494, + 495, 498, 502, 504, 506, 508, 513, 515, 518, 521, + 524, 527, 531, 533, 535, 537, 541, 542, 545, 548, + 551, 554, 557, 560, 563, 566, 569, 572, 575, 578, + 581, 584, 588, 590, 592, 595, 598, 602, 604, 606, + 608, 615, 617, 619, 620, 622, 623, 625, 626, 628, + 632, 633, 636, 640, 642, 645, 649, 656, 658, 660, + 663, 666, 670, 672, 674, 676, 682, 684, 686, 688, + 690, 692, 694, 696, 697, 699, 701, 705, 707, 709, + 711, 713, 715, 718, 721, 725, 731, 733, 736, 739, + 742, 745, 750, 753, 757, 759, 762, 765, 768, 771, + 774, 777, 780, 783, 786, 789, 792, 795, 798, 800, + 802, 806, 808, 810, 812, 816, 818, 821, 824, 827, + 830, 833, 836, 839, 842, 845, 848, 851, 854, 859, + 860, 862, 866, 868, 870, 873, 876, 879, 882, 885, + 888, 891, 894, 897, 903, 905, 907, 910, 913, 915, + 917, 919, 921, 923, 929, 931, 933, 936, 939, 945, + 947, 949, 952, 955, 961, 966, 968, 970, 972, 974, + 977, 980, 984, 986, 989, 993, 994, 997, 1000, 1003, + 1006, 1010, 1014, 1019, 1022, 1026, 1028, 1030, 1033, 1038, + 1040, 1042, 1045, 1048, 1051, 1054, 1057, 1060, 1063, 1066, + 1071, 1072, 1074, 1076, 1080, 1082, 1085, 1088, 1091, 1094, + 1098, 1099, 1102, 1106, 1107, 1110, 1113, 1116, 1119, 1121, + 1123, 1125, 1127, 1131, 1133, 1136, 1140, 1141, 1144, 1147, + 1150, 1154, 1155, 1158, 1161, 1164, 1167, 1170, 1173, 1176, + 1179, 1182, 1185, 1188, 1191, 1194, 1197, 1200, 1203, 1210, + 1212, 1214, 1217, 1220, 1224, 1226, 1228, 1231, 1234, 1240, + 1242, 1244, 1247, 1250, 1254, 1256, 1258, 1261, 1265, 1266, + 1269, 1272, 1275, 1279, 1281, 1283, 1285, 1287, 1289, 1291, + 1293, 1295, 1297, 1301, 1303, 1306, 1310, 1314, 1316, 1319, + 1321, 1323, 1327, 1329, 1331, 1337, 1339, 1342, 1345, 1348, + 1351, 1355, 1359, 1360, 1363, 1367, 1368, 1371, 1374, 1379, + 1381, 1383, 1389, 1391, 1393, 1395, 1397, 1399, 1400, 1402, + 1404, 1408, 1410, 1412, 1414, 1417, 1421, 1422, 1425, 1428, + 1431, 1435, 1436, 1439, 1443, 1444, 1447, 1449, 1451, 1455, + 1456, 1459, 1462, 1466, 1468, 1470, 1472, 1475, 1479, 1481, + 1484, 1487, 1490, 1495, 1496, 1498, 1502, 1504, 1507, 1510, + 1513, 1516, 1519, 1522, 1525, 1528, 1531, 1534, 1537, 1540, + 1543, 1546, 1550, 1551, 1554, 1557, 1560, 1563, 1568, 1570, + 1572, 1573, 1575, 1577, 1582, 1584, 1586, 1588, 1590, 1592, + 1594, 1599, 1601, 1604, 1608, 1609, 1612, 1615, 1618, 1622, + 1624, 1627, 1629, 1631, 1637, 1639, 1641, 1643, 1647, 1648, + 1651, 1655, 1656, 1659, 1662, 1665, 1668, 1672, 1674, 1677, + 1679, 1681, 1683, 1685, 1687, 1692, 1694, 1697, 1700, 1703, + 1706, 1709, 1712, 1715, 1718, 1721, 1725, 1727, 1730, 1733, + 1736, 1739, 1744, 1746, 1749, 1752, 1755, 1758, 1761, 1766, + 1768, 1771, 1774, 1778, 1779, 1782, 1785, 1789, 1790, 1793, + 1796, 1799, 1802, 1804, 1806, 1808, 1810, 1815, 1816, 1818, + 1820, 1822, 1825, 1829, 1830, 1833, 1836, 1841, 1843, 1846, + 1849, 1855, 1857, 1859, 1862, 1865, 1869, 1870, 1873, 1876, + 1879, 1883, 1885, 1888, 1892, 1893, 1896, 1899, 1902, 1906, + 1908, 1911, 1914, 1917, 1920, 1925, 1929, 1931, 1934, 1938, + 1940, 1942, 1944, 1946, 1948, 1950, 1952, 1954, 1958, 1965, + 1967, 1969, 1972, 1975, 1982, 1984, 1986, 1989, 1992, 1998, + 2000, 2002, 2006, 2010, 2012, 2015, 2018, 2021, 2024, 2027, + 2030, 2033, 2036, 2039, 2043, 2047, 2049, 2052, 2058, 2059, + 2061, 2066, 2070, 2072, 2075, 2079, 2081, 2084, 2088, 2092, + 2093, 2096, 2099, 2102, 2106, 2107, 2110, 2114, 2115, 2118, + 2121, 2124, 2128, 2130, 2133, 2137, 2138, 2141, 2146, 2150, + 2152, 2155, 2159, 2161, 2164, 2167, 2170, 2173, 2176, 2179, + 2182, 2185, 2188, 2191, 2194, 2197, 2201, 2203, 2206, 2209, + 2212, 2215, 2218, 2221, 2224, 2227, 2230, 2235, 2237, 2240, + 2243, 2246, 2251, 2253, 2255, 2258, 2261, 2265, 2266, 2269, + 2272, 2276, 2278, 2280, 2283, 2286, 2289, 2292, 2295, 2298, + 2301, 2304, 2307, 2311, 2313, 2315, 2318, 2321, 2324, 2327, + 2330, 2333, 2336, 2339, 2342, 2345, 2348, 2352, 2353, 2356, + 2359, 2364, 2368, 2369, 2372, 2375, 2378, 2381, 2383, 2385, + 2387, 2389, 2394, 2395, 2397, 2399, 2401, 2406, 2407, 2409, + 2413, 2415, 2418, 2423, 2425, 2428, 2431, 2434, 2437, 2439, + 2441, 2445, 2446, 2449, 2452, 2455, 2458, 2461, 2464, 2467, + 2470, 2473, 2476, 2479, 2481, 2483, 2485, 2487, 2489, 2491, + 2495, 2496, 2499, 2502, 2507, 2509, 2512, 2518, 2520, 2522, + 2525, 2528, 2533, 2535, 2537, 2539, 2541, 2545, 2546, 2549, + 2551, 2557, 2559, 2564, 2569, 2574, 2578, 2580, 2583, 2586, + 2589, 2593, 2595, 2598, 2600, 2604, 2606, 2609, 2612, 2615, + 2618, 2621, 2625, 2626, 2629, 2632, 2635, 2639, 2640, 2642, + 2647, 2648, 2650, 2654, 2655, 2657, 2661, 2663, 2666, 2670, + 2671, 2674, 2677, 2680, 2685, 2687, 2689, 2691, 2693, 2696, + 2699, 2703, 2707, 2708, 2711, 2714, 2717, 2719, 2722, 2726, + 2730, 2731, 2734, 2737, 2740, 2743, 2746, 2749, 2752, 2755, + 2758, 2761, 2764, 2767, 2770, 2774, 2775, 2778, 2782, 2783, + 2786, 2789, 2794, 2796, 2798, 2800, 2802, 2803, 2805, 2807, + 2811, 2813, 2816, 2819, 2822, 2825, 2828, 2831, 2835, 2840, + 2842, 2844, 2846, 2848, 2850, 2859, 2863, 2865, 2868, 2871, + 2874, 2877, 2885, 2886, 2888, 2889, 2891, 2892, 2894, 2895, + 2897, 2898, 2900, 2905, 2907, 2909, 2911, 2915, 2916, 2919, + 2922, 2925, 2928, 2930, 2932, 2934, 2936, 2938, 2940, 2943, + 2946, 2950, 2952, 2954, 2957, 2960, 2964, 2966, 2968, 2970, + 2972, 2974, 2976, 2978, 2980, 2982, 2984, 2986, 2988, 2990, + 2992, 2994, 2996, 2999, 3003, 3005, 3008, 3011, 3014, 3017, + 3019, 3021, 3023, 3025, 3029, 3035, 3037, 3040, 3043, 3046, + 3049, 3052, 3056, 3057, 3060, 3063, 3067, 3068, 3071, 3074, + 3077, 3080, 3083, 3086, 3089, 3092, 3094, 3096, 3101, 3102, + 3104, 3108, 3110, 3112, 3114, 3116, 3118, 3120, 3122, 3124, + 3126, 3128, 3132, 3136, 3142, 3146, 3150, 3151, 3154, 3157, + 3160, 3164, 3166, 3169, 3172, 3175, 3178, 3181, 3184, 3188, + 3190, 3193, 3196, 3199, 3202, 3205, 3208, 3210, 3212, 3214 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yytype_int16 yyrhs[] = -{ - 298, 0, -1, 295, -1, 116, 300, 302, 301, 488, - 299, 297, -1, -1, 299, 690, -1, 299, 416, -1, - 299, 495, -1, 299, 384, -1, 299, 350, -1, 299, - 737, -1, 551, -1, 117, 766, 297, -1, 118, 766, - 766, 766, 297, -1, 62, 304, 297, -1, 542, -1, - 540, -1, 63, 306, 297, -1, 542, -1, 306, 440, - -1, 306, 530, -1, 306, 504, -1, 306, 350, -1, - 306, 737, -1, 64, 308, 297, -1, 765, -1, 695, - -1, 65, 310, 297, -1, 366, -1, 310, 508, -1, - 310, 520, -1, 310, 350, -1, 310, 737, -1, 66, - 620, 620, 620, 297, -1, 67, 551, 766, 313, 297, - -1, -1, 766, -1, 68, 612, 297, -1, 69, 316, - 297, -1, 321, -1, 317, -1, 314, -1, 316, 350, - -1, 316, 737, -1, 70, 686, 297, -1, 71, 670, - 297, -1, 72, 670, 297, -1, 73, 765, 297, -1, - 74, 297, -1, 75, 323, 297, -1, 517, -1, 510, - -1, 518, -1, 76, 325, 326, 297, -1, 318, -1, - 448, -1, 319, -1, 492, -1, 77, 328, 297, -1, - -1, 328, 332, -1, 328, 329, -1, 328, 327, -1, - 78, 330, 297, -1, 332, -1, 330, 395, -1, 79, - 332, 297, -1, 728, -1, 419, -1, 80, 766, 766, - 327, 297, -1, 81, 766, 297, -1, 82, 659, 297, - -1, 83, 338, 337, 297, -1, 342, -1, 337, 690, - -1, 337, 746, -1, 337, 742, -1, 337, 350, -1, - 337, 737, -1, 337, 650, -1, 551, -1, 84, 341, - 340, 297, -1, -1, 497, -1, 552, -1, 85, 343, - 297, -1, 55, -1, 49, -1, 23, -1, 86, 345, - 346, 297, -1, 643, -1, 644, -1, 637, -1, -1, - 322, -1, 724, -1, 87, 620, 620, 348, 297, -1, - -1, 348, 650, -1, 88, 670, 670, 670, 297, -1, - 89, 351, 297, -1, -1, 351, 765, -1, 90, 353, - 297, -1, -1, 353, 307, -1, 353, 430, -1, 353, - 454, -1, 353, 335, -1, 353, 650, -1, 353, 350, - -1, 353, 737, -1, 91, 517, 297, -1, 93, 356, - 297, -1, -1, 356, 454, -1, 356, 582, -1, 356, - 430, -1, 356, 673, -1, 356, 553, -1, 356, 557, - -1, 356, 597, -1, 356, 352, -1, 356, 633, -1, - 356, 716, -1, 356, 678, -1, 356, 760, -1, 356, - 440, -1, 356, 522, -1, 356, 335, -1, 356, 350, - -1, 356, 737, -1, 92, 358, 297, -1, -1, 430, - -1, 94, 360, 297, -1, 20, -1, 50, -1, 57, - -1, 95, 362, 297, -1, 766, -1, 466, -1, 96, - 542, 297, -1, 97, 365, 297, -1, -1, 365, 311, - -1, 365, 620, -1, 98, 766, 367, 297, -1, -1, - 404, -1, 99, 765, 369, 297, -1, -1, 741, -1, - 100, 371, 297, -1, 670, -1, 578, -1, 101, 373, - 297, -1, 670, -1, 578, -1, 102, 375, 297, -1, - 670, -1, 578, -1, 103, 377, 297, -1, 670, -1, - 578, -1, 104, 379, 297, -1, 542, -1, 540, -1, - 105, 381, 297, -1, -1, 381, 620, -1, 106, 383, - 297, -1, 9, -1, 34, -1, 47, -1, 107, 388, - 385, 297, -1, 339, -1, 385, 690, -1, 385, 350, - -1, 385, 650, -1, 385, 737, -1, 108, 387, 297, - -1, 765, -1, 695, -1, 551, -1, 220, 390, 297, - -1, -1, 390, 437, -1, 390, 432, -1, 390, 661, - -1, 390, 435, -1, 390, 592, -1, 390, 590, -1, - 390, 405, -1, 390, 472, -1, 390, 476, -1, 390, - 574, -1, 390, 572, -1, 390, 420, -1, 390, 350, - -1, 390, 737, -1, 109, 392, 297, -1, 428, -1, - 434, -1, 392, 428, -1, 392, 434, -1, 110, 394, - 297, -1, 26, -1, 27, -1, 40, -1, 111, 396, - 397, 398, 399, 297, -1, 423, -1, 426, -1, -1, - 483, -1, -1, 587, -1, -1, 589, -1, 112, 401, - 297, -1, -1, 401, 517, -1, 113, 403, 297, -1, - 620, -1, 403, 650, -1, 114, 670, 297, -1, 119, - 668, 424, 424, 406, 297, -1, 656, -1, 682, -1, - 406, 350, -1, 406, 737, -1, 120, 408, 297, -1, - 20, -1, 50, -1, 57, -1, 121, 410, 411, 412, - 297, -1, 533, -1, 344, -1, 692, -1, 524, -1, - 644, -1, 569, -1, 704, -1, -1, 378, -1, 502, - -1, 122, 414, 297, -1, 644, -1, 637, -1, 631, - -1, 567, -1, 561, -1, 414, 724, -1, 414, 322, - -1, 123, 670, 297, -1, 124, 493, 301, 417, 297, - -1, 709, -1, 417, 690, -1, 417, 336, -1, 417, - 350, -1, 417, 737, -1, 125, 491, 423, 297, -1, - 126, 297, -1, 129, 421, 297, -1, 422, -1, 421, - 359, -1, 421, 407, -1, 421, 609, -1, 421, 334, - -1, 421, 349, -1, 421, 439, -1, 421, 333, -1, - 421, 711, -1, 421, 754, -1, 421, 350, -1, 421, - 650, -1, 421, 737, -1, 421, 451, -1, 551, -1, - 552, -1, 130, 425, 297, -1, 423, -1, 428, -1, - 434, -1, 131, 427, 297, -1, 423, -1, 427, 359, - -1, 427, 407, -1, 427, 609, -1, 427, 334, -1, - 427, 349, -1, 427, 439, -1, 427, 333, -1, 427, - 711, -1, 427, 754, -1, 427, 350, -1, 427, 650, - -1, 427, 737, -1, 132, 423, 429, 297, -1, -1, - 497, -1, 127, 431, 297, -1, 422, -1, 426, -1, - 431, 347, -1, 431, 402, -1, 431, 585, -1, 431, - 605, -1, 431, 621, -1, 431, 659, -1, 431, 675, - -1, 431, 350, -1, 431, 737, -1, 128, 668, 424, - 433, 297, -1, 656, -1, 682, -1, 433, 350, -1, - 433, 737, -1, 474, -1, 732, -1, 391, -1, 478, - -1, 594, -1, 133, 668, 424, 436, 297, -1, 656, - -1, 682, -1, 436, 350, -1, 436, 737, -1, 134, - 668, 424, 438, 297, -1, 656, -1, 682, -1, 438, - 350, -1, 438, 737, -1, 135, 766, 766, 327, 297, - -1, 136, 441, 442, 297, -1, 643, -1, 644, -1, - 644, -1, 704, -1, 442, 378, -1, 442, 502, -1, - 137, 444, 297, -1, 712, -1, 444, 413, -1, 767, - 446, 295, -1, -1, 446, 766, -1, 446, 765, -1, - 446, 764, -1, 446, 445, -1, 138, 643, 297, -1, - 139, 670, 297, -1, 140, 670, 670, 297, -1, 141, - 297, -1, 142, 452, 297, -1, 428, -1, 434, -1, - 143, 297, -1, 144, 464, 455, 297, -1, 750, -1, - 744, -1, 455, 718, -1, 455, 604, -1, 455, 635, - -1, 455, 716, -1, 455, 386, -1, 455, 650, -1, - 455, 350, -1, 455, 737, -1, 148, 465, 457, 297, - -1, -1, 456, -1, 750, -1, 145, 459, 297, -1, - 456, -1, 459, 386, -1, 459, 716, -1, 459, 650, - -1, 459, 350, -1, 146, 461, 297, -1, -1, 461, - 456, -1, 147, 463, 297, -1, -1, 463, 456, -1, - 463, 460, -1, 463, 350, -1, 463, 737, -1, 551, - -1, 312, -1, 552, -1, 536, -1, 150, 467, 297, - -1, 766, -1, 467, 395, -1, 149, 469, 297, -1, - -1, 469, 766, -1, 469, 466, -1, 469, 468, -1, - 151, 471, 297, -1, -1, 471, 623, -1, 471, 627, - -1, 471, 700, -1, 471, 654, -1, 471, 315, -1, - 471, 602, -1, 471, 481, -1, 471, 547, -1, 471, - 758, -1, 471, 610, -1, 471, 716, -1, 471, 678, - -1, 471, 386, -1, 471, 650, -1, 471, 350, -1, - 471, 737, -1, 152, 668, 424, 424, 473, 297, -1, - 656, -1, 682, -1, 473, 350, -1, 473, 737, -1, - 153, 475, 297, -1, 428, -1, 434, -1, 475, 428, - -1, 475, 434, -1, 154, 668, 424, 477, 297, -1, - 656, -1, 682, -1, 477, 350, -1, 477, 737, -1, - 155, 479, 297, -1, 428, -1, 434, -1, 156, 297, - -1, 157, 482, 297, -1, -1, 482, 644, -1, 482, - 637, -1, 482, 447, -1, 158, 484, 297, -1, 11, - -1, 12, -1, 13, -1, 29, -1, 30, -1, 31, - -1, 58, -1, 59, -1, 60, -1, 159, 486, 297, - -1, 490, -1, 486, 395, -1, 160, 766, 297, -1, - 161, 489, 297, -1, 487, -1, 489, 350, -1, 764, - -1, 551, -1, 162, 670, 297, -1, 551, -1, 552, - -1, 163, 493, 301, 496, 297, -1, 709, -1, 496, - 690, -1, 496, 336, -1, 496, 350, -1, 496, 737, - -1, 164, 494, 297, -1, 165, 499, 297, -1, -1, - 499, 553, -1, 166, 501, 297, -1, -1, 501, 623, - -1, 501, 627, -1, 167, 503, 503, 297, -1, 542, - -1, 540, -1, 168, 505, 506, 507, 297, -1, 643, - -1, 644, -1, 644, -1, 524, -1, 704, -1, -1, - 378, -1, 502, -1, 169, 509, 297, -1, 637, -1, - 644, -1, 643, -1, 509, 528, -1, 170, 511, 297, - -1, -1, 511, 517, -1, 511, 518, -1, 511, 450, - -1, 171, 513, 297, -1, -1, 513, 517, -1, 172, - 515, 297, -1, -1, 515, 517, -1, 551, -1, 552, - -1, 173, 519, 297, -1, -1, 519, 517, -1, 519, - 510, -1, 174, 521, 297, -1, 637, -1, 644, -1, - 643, -1, 521, 528, -1, 175, 523, 297, -1, 642, - -1, 523, 650, -1, 523, 350, -1, 523, 737, -1, - 176, 517, 525, 297, -1, -1, 497, -1, 177, 527, - 297, -1, 516, -1, 527, 755, -1, 527, 363, -1, - 527, 331, -1, 527, 354, -1, 527, 757, -1, 527, - 699, -1, 527, 400, -1, 527, 514, -1, 527, 512, - -1, 527, 480, -1, 527, 666, -1, 527, 650, -1, - 527, 350, -1, 527, 737, -1, 178, 529, 297, -1, - -1, 529, 517, -1, 529, 510, -1, 529, 518, -1, - 529, 450, -1, 179, 531, 532, 297, -1, 643, -1, - 644, -1, -1, 378, -1, 502, -1, 180, 534, 535, - 297, -1, 643, -1, 644, -1, 637, -1, 517, -1, - 510, -1, 518, -1, 181, 552, 537, 297, -1, 766, - -1, 537, 766, -1, 182, 539, 297, -1, -1, 539, - 542, -1, 539, 540, -1, 539, 538, -1, 183, 541, - 297, -1, 542, -1, 541, 395, -1, 543, -1, 670, - -1, 184, 544, 544, 544, 297, -1, 670, -1, 731, - -1, 730, -1, 185, 546, 297, -1, -1, 546, 657, - -1, 186, 548, 297, -1, -1, 548, 644, -1, 548, - 637, -1, 548, 758, -1, 548, 481, -1, 187, 550, - 297, -1, 764, -1, 550, 395, -1, 764, -1, 549, - -1, 663, -1, 764, -1, 549, -1, 188, 565, 554, - 297, -1, 481, -1, 554, 361, -1, 554, 559, -1, - 554, 430, -1, 554, 553, -1, 554, 454, -1, 554, - 352, -1, 554, 650, -1, 554, 350, -1, 554, 737, - -1, 189, 556, 297, -1, 567, -1, 556, 559, -1, - 556, 361, -1, 556, 650, -1, 556, 350, -1, 190, - 565, 558, 297, -1, 498, -1, 558, 430, -1, 558, - 352, -1, 558, 650, -1, 558, 350, -1, 558, 737, - -1, 191, 382, 560, 297, -1, 378, -1, 560, 724, - -1, 560, 322, -1, 192, 562, 297, -1, -1, 562, - 566, -1, 562, 567, -1, 193, 564, 297, -1, -1, - 564, 567, -1, 564, 561, -1, 564, 350, -1, 564, - 737, -1, 551, -1, 312, -1, 552, -1, 536, -1, - 194, 566, 568, 297, -1, -1, 567, -1, 456, -1, - 750, -1, 195, 297, -1, 196, 571, 297, -1, -1, - 571, 644, -1, 571, 610, -1, 197, 668, 573, 297, - -1, 424, -1, 573, 350, -1, 573, 737, -1, 198, - 668, 424, 575, 297, -1, 656, -1, 682, -1, 575, - 350, -1, 575, 737, -1, 199, 577, 297, -1, -1, - 577, 670, -1, 577, 578, -1, 577, 576, -1, 201, - 579, 297, -1, 670, -1, 579, 395, -1, 200, 581, - 297, -1, -1, 581, 669, -1, 581, 449, -1, 581, - 350, -1, 202, 583, 297, -1, 642, -1, 583, 736, - -1, 583, 650, -1, 583, 350, -1, 583, 737, -1, - 203, 413, 670, 297, -1, 204, 586, 297, -1, 364, - -1, 586, 650, -1, 205, 588, 297, -1, 43, -1, - 46, -1, 44, -1, 45, -1, 35, -1, 37, -1, - 38, -1, 36, -1, 206, 620, 297, -1, 207, 668, - 424, 424, 591, 297, -1, 656, -1, 682, -1, 591, - 350, -1, 591, 737, -1, 208, 668, 424, 424, 593, - 297, -1, 656, -1, 682, -1, 593, 350, -1, 593, - 737, -1, 209, 766, 595, 359, 297, -1, 428, -1, - 434, -1, 210, 765, 297, -1, 211, 598, 297, -1, - 464, -1, 598, 454, -1, 598, 553, -1, 598, 557, - -1, 598, 352, -1, 598, 633, -1, 598, 599, -1, - 598, 335, -1, 598, 350, -1, 598, 737, -1, 212, - 659, 297, -1, 215, 601, 297, -1, 740, -1, 601, - 395, -1, 213, 739, 729, 603, 297, -1, -1, 734, - -1, 214, 740, 729, 297, -1, 216, 606, 297, -1, - 618, -1, 606, 650, -1, 217, 608, 297, -1, 378, - -1, 608, 413, -1, 218, 766, 297, -1, 219, 611, - 297, -1, -1, 611, 644, -1, 611, 610, -1, 611, - 570, -1, 221, 613, 297, -1, -1, 613, 688, -1, - 222, 615, 297, -1, -1, 615, 620, -1, 615, 616, - -1, 615, 614, -1, 223, 617, 297, -1, 620, -1, - 617, 395, -1, 224, 619, 297, -1, -1, 619, 620, - -1, 241, 766, 766, 297, -1, 225, 622, 297, -1, - 618, -1, 622, 650, -1, 226, 624, 297, -1, 642, - -1, 624, 393, -1, 624, 736, -1, 624, 629, -1, - 624, 386, -1, 624, 370, -1, 624, 372, -1, 624, - 374, -1, 624, 376, -1, 624, 303, -1, 624, 650, - -1, 624, 350, -1, 624, 737, -1, 227, 626, 297, - -1, 644, -1, 626, 386, -1, 626, 629, -1, 626, - 370, -1, 626, 372, -1, 626, 374, -1, 626, 376, - -1, 626, 303, -1, 626, 650, -1, 626, 350, -1, - 228, 642, 628, 297, -1, 500, -1, 628, 650, -1, - 628, 350, -1, 628, 737, -1, 229, 382, 630, 297, - -1, 378, -1, 502, -1, 630, 724, -1, 630, 322, - -1, 230, 632, 297, -1, -1, 632, 643, -1, 632, - 644, -1, 231, 634, 297, -1, 644, -1, 643, -1, - 634, 357, -1, 634, 430, -1, 634, 454, -1, 634, - 352, -1, 634, 648, -1, 634, 485, -1, 634, 650, - -1, 634, 737, -1, 634, 350, -1, 232, 636, 297, - -1, 644, -1, 643, -1, 636, 736, -1, 636, 629, - -1, 636, 386, -1, 636, 370, -1, 636, 372, -1, - 636, 374, -1, 636, 376, -1, 636, 303, -1, 636, - 650, -1, 636, 350, -1, 636, 737, -1, 233, 638, - 297, -1, -1, 638, 644, -1, 638, 643, -1, 234, - 642, 637, 297, -1, 235, 641, 297, -1, -1, 641, - 644, -1, 641, 631, -1, 641, 350, -1, 641, 737, - -1, 551, -1, 312, -1, 552, -1, 536, -1, 236, - 643, 645, 297, -1, -1, 644, -1, 456, -1, 750, - -1, 237, 765, 647, 297, -1, -1, 741, -1, 239, - 649, 297, -1, 653, -1, 649, 395, -1, 238, 652, - 651, 297, -1, 729, -1, 651, 596, -1, 651, 734, - -1, 651, 650, -1, 651, 350, -1, 551, -1, 552, - -1, 240, 655, 297, -1, -1, 655, 633, -1, 655, - 430, -1, 655, 454, -1, 655, 352, -1, 655, 335, - -1, 655, 648, -1, 655, 485, -1, 655, 600, -1, - 655, 650, -1, 655, 350, -1, 655, 737, -1, 492, - -1, 448, -1, 319, -1, 318, -1, 415, -1, 324, - -1, 242, 658, 297, -1, -1, 658, 656, -1, 658, - 682, -1, 243, 620, 660, 297, -1, 620, -1, 660, - 650, -1, 244, 668, 424, 662, 297, -1, 657, -1, - 545, -1, 662, 350, -1, 662, 737, -1, 245, 664, - 665, 297, -1, 764, -1, 549, -1, 765, -1, 695, - -1, 246, 667, 297, -1, -1, 667, 517, -1, 551, - -1, 247, 670, 670, 734, 297, -1, 766, -1, 115, - 766, 766, 297, -1, 248, 766, 766, 297, -1, 249, - 766, 766, 297, -1, 250, 674, 297, -1, 765, -1, - 674, 673, -1, 674, 765, -1, 674, 454, -1, 251, - 676, 297, -1, 364, -1, 676, 650, -1, 551, -1, - 252, 679, 297, -1, 677, -1, 679, 639, -1, 679, - 756, -1, 679, 309, -1, 679, 350, -1, 679, 737, - -1, 253, 681, 297, -1, -1, 681, 526, -1, 681, - 350, -1, 681, 737, -1, 254, 683, 297, -1, -1, - 656, -1, 255, 750, 685, 297, -1, -1, 718, -1, - 256, 687, 297, -1, -1, 702, -1, 257, 689, 297, - -1, 702, -1, 689, 684, -1, 258, 691, 297, -1, - -1, 691, 762, -1, 691, 350, -1, 691, 737, -1, - 259, 693, 694, 297, -1, 643, -1, 644, -1, 637, - -1, 404, -1, 694, 724, -1, 694, 322, -1, 261, - 698, 297, -1, 260, 697, 297, -1, -1, 697, 765, - -1, 697, 695, -1, 697, 696, -1, 765, -1, 698, - 395, -1, 262, 517, 297, -1, 263, 701, 297, -1, - -1, 701, 633, -1, 701, 430, -1, 701, 454, -1, - 701, 352, -1, 701, 307, -1, 701, 599, -1, 701, - 335, -1, 701, 648, -1, 701, 485, -1, 701, 600, - -1, 701, 650, -1, 701, 350, -1, 701, 737, -1, - 264, 703, 297, -1, -1, 703, 718, -1, 265, 705, - 297, -1, -1, 705, 409, -1, 705, 706, -1, 266, - 707, 708, 297, -1, 524, -1, 644, -1, 569, -1, - 704, -1, -1, 378, -1, 502, -1, 267, 710, 297, - -1, 580, -1, 710, 420, -1, 710, 418, -1, 710, - 680, -1, 710, 389, -1, 710, 350, -1, 710, 737, - -1, 268, 766, 297, -1, 269, 713, 714, 297, -1, - 413, -1, 584, -1, 413, -1, 584, -1, 404, -1, - 270, 766, 766, 766, 766, 766, 766, 297, -1, 271, - 717, 297, -1, 382, -1, 717, 607, -1, 717, 443, - -1, 717, 350, -1, 717, 737, -1, 272, 719, 720, - 721, 722, 723, 297, -1, -1, 671, -1, -1, 672, - -1, -1, 380, -1, -1, 587, -1, -1, 589, -1, - 273, 725, 725, 297, -1, 517, -1, 510, -1, 518, - -1, 274, 727, 297, -1, -1, 727, 344, -1, 727, - 692, -1, 727, 453, -1, 275, 297, -1, 327, -1, - 468, -1, 538, -1, 576, -1, 614, -1, 696, -1, - 276, 297, -1, 277, 297, -1, 278, 733, 297, -1, - 428, -1, 434, -1, 733, 428, -1, 733, 434, -1, - 279, 735, 297, -1, 17, -1, 10, -1, 16, -1, - 48, -1, 54, -1, 56, -1, 61, -1, 33, -1, - 22, -1, 25, -1, 19, -1, 42, -1, 14, -1, - 15, -1, 21, -1, 7, -1, 280, 297, -1, 281, - 738, 297, -1, 764, -1, 738, 766, -1, 738, 765, - -1, 738, 764, -1, 738, 445, -1, 551, -1, 312, - -1, 552, -1, 536, -1, 282, 765, 297, -1, 283, - 748, 752, 743, 297, -1, 470, -1, 743, 690, -1, - 743, 355, -1, 743, 350, -1, 743, 650, -1, 743, - 737, -1, 284, 745, 297, -1, -1, 745, 750, -1, - 745, 744, -1, 285, 747, 297, -1, -1, 747, 640, - -1, 747, 625, -1, 747, 462, -1, 747, 458, -1, - 747, 563, -1, 747, 555, -1, 747, 350, -1, 747, - 737, -1, 551, -1, 552, -1, 286, 749, 751, 297, - -1, -1, 339, -1, 287, 753, 297, -1, 32, -1, - 41, -1, 39, -1, 51, -1, 53, -1, 8, -1, - 28, -1, 18, -1, 24, -1, 52, -1, 288, 332, - 297, -1, 289, 542, 297, -1, 290, 516, 670, 528, - 297, -1, 291, 517, 297, -1, 292, 759, 297, -1, - -1, 759, 644, -1, 759, 637, -1, 759, 481, -1, - 293, 761, 297, -1, 726, -1, 761, 305, -1, 761, - 440, -1, 761, 530, -1, 761, 504, -1, 761, 350, - -1, 761, 737, -1, 294, 763, 297, -1, 715, -1, - 763, 320, -1, 763, 646, -1, 763, 368, -1, 763, - 650, -1, 763, 350, -1, 763, 737, -1, 3, -1, - 6, -1, 4, -1, 5, -1 +static const yytype_int16 yyrhs[] = { + 298, 0, -1, 295, -1, 116, 300, 302, 301, 488, + 299, 297, -1, -1, 299, 690, -1, 299, 416, -1, + 299, 495, -1, 299, 384, -1, 299, 350, -1, 299, + 737, -1, 551, -1, 117, 766, 297, -1, 118, 766, + 766, 766, 297, -1, 62, 304, 297, -1, 542, -1, + 540, -1, 63, 306, 297, -1, 542, -1, 306, 440, + -1, 306, 530, -1, 306, 504, -1, 306, 350, -1, + 306, 737, -1, 64, 308, 297, -1, 765, -1, 695, + -1, 65, 310, 297, -1, 366, -1, 310, 508, -1, + 310, 520, -1, 310, 350, -1, 310, 737, -1, 66, + 620, 620, 620, 297, -1, 67, 551, 766, 313, 297, + -1, -1, 766, -1, 68, 612, 297, -1, 69, 316, + 297, -1, 321, -1, 317, -1, 314, -1, 316, 350, + -1, 316, 737, -1, 70, 686, 297, -1, 71, 670, + 297, -1, 72, 670, 297, -1, 73, 765, 297, -1, + 74, 297, -1, 75, 323, 297, -1, 517, -1, 510, + -1, 518, -1, 76, 325, 326, 297, -1, 318, -1, + 448, -1, 319, -1, 492, -1, 77, 328, 297, -1, + -1, 328, 332, -1, 328, 329, -1, 328, 327, -1, + 78, 330, 297, -1, 332, -1, 330, 395, -1, 79, + 332, 297, -1, 728, -1, 419, -1, 80, 766, 766, + 327, 297, -1, 81, 766, 297, -1, 82, 659, 297, + -1, 83, 338, 337, 297, -1, 342, -1, 337, 690, + -1, 337, 746, -1, 337, 742, -1, 337, 350, -1, + 337, 737, -1, 337, 650, -1, 551, -1, 84, 341, + 340, 297, -1, -1, 497, -1, 552, -1, 85, 343, + 297, -1, 55, -1, 49, -1, 23, -1, 86, 345, + 346, 297, -1, 643, -1, 644, -1, 637, -1, -1, + 322, -1, 724, -1, 87, 620, 620, 348, 297, -1, + -1, 348, 650, -1, 88, 670, 670, 670, 297, -1, + 89, 351, 297, -1, -1, 351, 765, -1, 90, 353, + 297, -1, -1, 353, 307, -1, 353, 430, -1, 353, + 454, -1, 353, 335, -1, 353, 650, -1, 353, 350, + -1, 353, 737, -1, 91, 517, 297, -1, 93, 356, + 297, -1, -1, 356, 454, -1, 356, 582, -1, 356, + 430, -1, 356, 673, -1, 356, 553, -1, 356, 557, + -1, 356, 597, -1, 356, 352, -1, 356, 633, -1, + 356, 716, -1, 356, 678, -1, 356, 760, -1, 356, + 440, -1, 356, 522, -1, 356, 335, -1, 356, 350, + -1, 356, 737, -1, 92, 358, 297, -1, -1, 430, + -1, 94, 360, 297, -1, 20, -1, 50, -1, 57, + -1, 95, 362, 297, -1, 766, -1, 466, -1, 96, + 542, 297, -1, 97, 365, 297, -1, -1, 365, 311, + -1, 365, 620, -1, 98, 766, 367, 297, -1, -1, + 404, -1, 99, 765, 369, 297, -1, -1, 741, -1, + 100, 371, 297, -1, 670, -1, 578, -1, 101, 373, + 297, -1, 670, -1, 578, -1, 102, 375, 297, -1, + 670, -1, 578, -1, 103, 377, 297, -1, 670, -1, + 578, -1, 104, 379, 297, -1, 542, -1, 540, -1, + 105, 381, 297, -1, -1, 381, 620, -1, 106, 383, + 297, -1, 9, -1, 34, -1, 47, -1, 107, 388, + 385, 297, -1, 339, -1, 385, 690, -1, 385, 350, + -1, 385, 650, -1, 385, 737, -1, 108, 387, 297, + -1, 765, -1, 695, -1, 551, -1, 220, 390, 297, + -1, -1, 390, 437, -1, 390, 432, -1, 390, 661, + -1, 390, 435, -1, 390, 592, -1, 390, 590, -1, + 390, 405, -1, 390, 472, -1, 390, 476, -1, 390, + 574, -1, 390, 572, -1, 390, 420, -1, 390, 350, + -1, 390, 737, -1, 109, 392, 297, -1, 428, -1, + 434, -1, 392, 428, -1, 392, 434, -1, 110, 394, + 297, -1, 26, -1, 27, -1, 40, -1, 111, 396, + 397, 398, 399, 297, -1, 423, -1, 426, -1, -1, + 483, -1, -1, 587, -1, -1, 589, -1, 112, 401, + 297, -1, -1, 401, 517, -1, 113, 403, 297, -1, + 620, -1, 403, 650, -1, 114, 670, 297, -1, 119, + 668, 424, 424, 406, 297, -1, 656, -1, 682, -1, + 406, 350, -1, 406, 737, -1, 120, 408, 297, -1, + 20, -1, 50, -1, 57, -1, 121, 410, 411, 412, + 297, -1, 533, -1, 344, -1, 692, -1, 524, -1, + 644, -1, 569, -1, 704, -1, -1, 378, -1, 502, + -1, 122, 414, 297, -1, 644, -1, 637, -1, 631, + -1, 567, -1, 561, -1, 414, 724, -1, 414, 322, + -1, 123, 670, 297, -1, 124, 493, 301, 417, 297, + -1, 709, -1, 417, 690, -1, 417, 336, -1, 417, + 350, -1, 417, 737, -1, 125, 491, 423, 297, -1, + 126, 297, -1, 129, 421, 297, -1, 422, -1, 421, + 359, -1, 421, 407, -1, 421, 609, -1, 421, 334, + -1, 421, 349, -1, 421, 439, -1, 421, 333, -1, + 421, 711, -1, 421, 754, -1, 421, 350, -1, 421, + 650, -1, 421, 737, -1, 421, 451, -1, 551, -1, + 552, -1, 130, 425, 297, -1, 423, -1, 428, -1, + 434, -1, 131, 427, 297, -1, 423, -1, 427, 359, + -1, 427, 407, -1, 427, 609, -1, 427, 334, -1, + 427, 349, -1, 427, 439, -1, 427, 333, -1, 427, + 711, -1, 427, 754, -1, 427, 350, -1, 427, 650, + -1, 427, 737, -1, 132, 423, 429, 297, -1, -1, + 497, -1, 127, 431, 297, -1, 422, -1, 426, -1, + 431, 347, -1, 431, 402, -1, 431, 585, -1, 431, + 605, -1, 431, 621, -1, 431, 659, -1, 431, 675, + -1, 431, 350, -1, 431, 737, -1, 128, 668, 424, + 433, 297, -1, 656, -1, 682, -1, 433, 350, -1, + 433, 737, -1, 474, -1, 732, -1, 391, -1, 478, + -1, 594, -1, 133, 668, 424, 436, 297, -1, 656, + -1, 682, -1, 436, 350, -1, 436, 737, -1, 134, + 668, 424, 438, 297, -1, 656, -1, 682, -1, 438, + 350, -1, 438, 737, -1, 135, 766, 766, 327, 297, + -1, 136, 441, 442, 297, -1, 643, -1, 644, -1, + 644, -1, 704, -1, 442, 378, -1, 442, 502, -1, + 137, 444, 297, -1, 712, -1, 444, 413, -1, 767, + 446, 295, -1, -1, 446, 766, -1, 446, 765, -1, + 446, 764, -1, 446, 445, -1, 138, 643, 297, -1, + 139, 670, 297, -1, 140, 670, 670, 297, -1, 141, + 297, -1, 142, 452, 297, -1, 428, -1, 434, -1, + 143, 297, -1, 144, 464, 455, 297, -1, 750, -1, + 744, -1, 455, 718, -1, 455, 604, -1, 455, 635, + -1, 455, 716, -1, 455, 386, -1, 455, 650, -1, + 455, 350, -1, 455, 737, -1, 148, 465, 457, 297, + -1, -1, 456, -1, 750, -1, 145, 459, 297, -1, + 456, -1, 459, 386, -1, 459, 716, -1, 459, 650, + -1, 459, 350, -1, 146, 461, 297, -1, -1, 461, + 456, -1, 147, 463, 297, -1, -1, 463, 456, -1, + 463, 460, -1, 463, 350, -1, 463, 737, -1, 551, + -1, 312, -1, 552, -1, 536, -1, 150, 467, 297, + -1, 766, -1, 467, 395, -1, 149, 469, 297, -1, + -1, 469, 766, -1, 469, 466, -1, 469, 468, -1, + 151, 471, 297, -1, -1, 471, 623, -1, 471, 627, + -1, 471, 700, -1, 471, 654, -1, 471, 315, -1, + 471, 602, -1, 471, 481, -1, 471, 547, -1, 471, + 758, -1, 471, 610, -1, 471, 716, -1, 471, 678, + -1, 471, 386, -1, 471, 650, -1, 471, 350, -1, + 471, 737, -1, 152, 668, 424, 424, 473, 297, -1, + 656, -1, 682, -1, 473, 350, -1, 473, 737, -1, + 153, 475, 297, -1, 428, -1, 434, -1, 475, 428, + -1, 475, 434, -1, 154, 668, 424, 477, 297, -1, + 656, -1, 682, -1, 477, 350, -1, 477, 737, -1, + 155, 479, 297, -1, 428, -1, 434, -1, 156, 297, + -1, 157, 482, 297, -1, -1, 482, 644, -1, 482, + 637, -1, 482, 447, -1, 158, 484, 297, -1, 11, + -1, 12, -1, 13, -1, 29, -1, 30, -1, 31, + -1, 58, -1, 59, -1, 60, -1, 159, 486, 297, + -1, 490, -1, 486, 395, -1, 160, 766, 297, -1, + 161, 489, 297, -1, 487, -1, 489, 350, -1, 764, + -1, 551, -1, 162, 670, 297, -1, 551, -1, 552, + -1, 163, 493, 301, 496, 297, -1, 709, -1, 496, + 690, -1, 496, 336, -1, 496, 350, -1, 496, 737, + -1, 164, 494, 297, -1, 165, 499, 297, -1, -1, + 499, 553, -1, 166, 501, 297, -1, -1, 501, 623, + -1, 501, 627, -1, 167, 503, 503, 297, -1, 542, + -1, 540, -1, 168, 505, 506, 507, 297, -1, 643, + -1, 644, -1, 644, -1, 524, -1, 704, -1, -1, + 378, -1, 502, -1, 169, 509, 297, -1, 637, -1, + 644, -1, 643, -1, 509, 528, -1, 170, 511, 297, + -1, -1, 511, 517, -1, 511, 518, -1, 511, 450, + -1, 171, 513, 297, -1, -1, 513, 517, -1, 172, + 515, 297, -1, -1, 515, 517, -1, 551, -1, 552, + -1, 173, 519, 297, -1, -1, 519, 517, -1, 519, + 510, -1, 174, 521, 297, -1, 637, -1, 644, -1, + 643, -1, 521, 528, -1, 175, 523, 297, -1, 642, + -1, 523, 650, -1, 523, 350, -1, 523, 737, -1, + 176, 517, 525, 297, -1, -1, 497, -1, 177, 527, + 297, -1, 516, -1, 527, 755, -1, 527, 363, -1, + 527, 331, -1, 527, 354, -1, 527, 757, -1, 527, + 699, -1, 527, 400, -1, 527, 514, -1, 527, 512, + -1, 527, 480, -1, 527, 666, -1, 527, 650, -1, + 527, 350, -1, 527, 737, -1, 178, 529, 297, -1, + -1, 529, 517, -1, 529, 510, -1, 529, 518, -1, + 529, 450, -1, 179, 531, 532, 297, -1, 643, -1, + 644, -1, -1, 378, -1, 502, -1, 180, 534, 535, + 297, -1, 643, -1, 644, -1, 637, -1, 517, -1, + 510, -1, 518, -1, 181, 552, 537, 297, -1, 766, + -1, 537, 766, -1, 182, 539, 297, -1, -1, 539, + 542, -1, 539, 540, -1, 539, 538, -1, 183, 541, + 297, -1, 542, -1, 541, 395, -1, 543, -1, 670, + -1, 184, 544, 544, 544, 297, -1, 670, -1, 731, + -1, 730, -1, 185, 546, 297, -1, -1, 546, 657, + -1, 186, 548, 297, -1, -1, 548, 644, -1, 548, + 637, -1, 548, 758, -1, 548, 481, -1, 187, 550, + 297, -1, 764, -1, 550, 395, -1, 764, -1, 549, + -1, 663, -1, 764, -1, 549, -1, 188, 565, 554, + 297, -1, 481, -1, 554, 361, -1, 554, 559, -1, + 554, 430, -1, 554, 553, -1, 554, 454, -1, 554, + 352, -1, 554, 650, -1, 554, 350, -1, 554, 737, + -1, 189, 556, 297, -1, 567, -1, 556, 559, -1, + 556, 361, -1, 556, 650, -1, 556, 350, -1, 190, + 565, 558, 297, -1, 498, -1, 558, 430, -1, 558, + 352, -1, 558, 650, -1, 558, 350, -1, 558, 737, + -1, 191, 382, 560, 297, -1, 378, -1, 560, 724, + -1, 560, 322, -1, 192, 562, 297, -1, -1, 562, + 566, -1, 562, 567, -1, 193, 564, 297, -1, -1, + 564, 567, -1, 564, 561, -1, 564, 350, -1, 564, + 737, -1, 551, -1, 312, -1, 552, -1, 536, -1, + 194, 566, 568, 297, -1, -1, 567, -1, 456, -1, + 750, -1, 195, 297, -1, 196, 571, 297, -1, -1, + 571, 644, -1, 571, 610, -1, 197, 668, 573, 297, + -1, 424, -1, 573, 350, -1, 573, 737, -1, 198, + 668, 424, 575, 297, -1, 656, -1, 682, -1, 575, + 350, -1, 575, 737, -1, 199, 577, 297, -1, -1, + 577, 670, -1, 577, 578, -1, 577, 576, -1, 201, + 579, 297, -1, 670, -1, 579, 395, -1, 200, 581, + 297, -1, -1, 581, 669, -1, 581, 449, -1, 581, + 350, -1, 202, 583, 297, -1, 642, -1, 583, 736, + -1, 583, 650, -1, 583, 350, -1, 583, 737, -1, + 203, 413, 670, 297, -1, 204, 586, 297, -1, 364, + -1, 586, 650, -1, 205, 588, 297, -1, 43, -1, + 46, -1, 44, -1, 45, -1, 35, -1, 37, -1, + 38, -1, 36, -1, 206, 620, 297, -1, 207, 668, + 424, 424, 591, 297, -1, 656, -1, 682, -1, 591, + 350, -1, 591, 737, -1, 208, 668, 424, 424, 593, + 297, -1, 656, -1, 682, -1, 593, 350, -1, 593, + 737, -1, 209, 766, 595, 359, 297, -1, 428, -1, + 434, -1, 210, 765, 297, -1, 211, 598, 297, -1, + 464, -1, 598, 454, -1, 598, 553, -1, 598, 557, + -1, 598, 352, -1, 598, 633, -1, 598, 599, -1, + 598, 335, -1, 598, 350, -1, 598, 737, -1, 212, + 659, 297, -1, 215, 601, 297, -1, 740, -1, 601, + 395, -1, 213, 739, 729, 603, 297, -1, -1, 734, + -1, 214, 740, 729, 297, -1, 216, 606, 297, -1, + 618, -1, 606, 650, -1, 217, 608, 297, -1, 378, + -1, 608, 413, -1, 218, 766, 297, -1, 219, 611, + 297, -1, -1, 611, 644, -1, 611, 610, -1, 611, + 570, -1, 221, 613, 297, -1, -1, 613, 688, -1, + 222, 615, 297, -1, -1, 615, 620, -1, 615, 616, + -1, 615, 614, -1, 223, 617, 297, -1, 620, -1, + 617, 395, -1, 224, 619, 297, -1, -1, 619, 620, + -1, 241, 766, 766, 297, -1, 225, 622, 297, -1, + 618, -1, 622, 650, -1, 226, 624, 297, -1, 642, + -1, 624, 393, -1, 624, 736, -1, 624, 629, -1, + 624, 386, -1, 624, 370, -1, 624, 372, -1, 624, + 374, -1, 624, 376, -1, 624, 303, -1, 624, 650, + -1, 624, 350, -1, 624, 737, -1, 227, 626, 297, + -1, 644, -1, 626, 386, -1, 626, 629, -1, 626, + 370, -1, 626, 372, -1, 626, 374, -1, 626, 376, + -1, 626, 303, -1, 626, 650, -1, 626, 350, -1, + 228, 642, 628, 297, -1, 500, -1, 628, 650, -1, + 628, 350, -1, 628, 737, -1, 229, 382, 630, 297, + -1, 378, -1, 502, -1, 630, 724, -1, 630, 322, + -1, 230, 632, 297, -1, -1, 632, 643, -1, 632, + 644, -1, 231, 634, 297, -1, 644, -1, 643, -1, + 634, 357, -1, 634, 430, -1, 634, 454, -1, 634, + 352, -1, 634, 648, -1, 634, 485, -1, 634, 650, + -1, 634, 737, -1, 634, 350, -1, 232, 636, 297, + -1, 644, -1, 643, -1, 636, 736, -1, 636, 629, + -1, 636, 386, -1, 636, 370, -1, 636, 372, -1, + 636, 374, -1, 636, 376, -1, 636, 303, -1, 636, + 650, -1, 636, 350, -1, 636, 737, -1, 233, 638, + 297, -1, -1, 638, 644, -1, 638, 643, -1, 234, + 642, 637, 297, -1, 235, 641, 297, -1, -1, 641, + 644, -1, 641, 631, -1, 641, 350, -1, 641, 737, + -1, 551, -1, 312, -1, 552, -1, 536, -1, 236, + 643, 645, 297, -1, -1, 644, -1, 456, -1, 750, + -1, 237, 765, 647, 297, -1, -1, 741, -1, 239, + 649, 297, -1, 653, -1, 649, 395, -1, 238, 652, + 651, 297, -1, 729, -1, 651, 596, -1, 651, 734, + -1, 651, 650, -1, 651, 350, -1, 551, -1, 552, + -1, 240, 655, 297, -1, -1, 655, 633, -1, 655, + 430, -1, 655, 454, -1, 655, 352, -1, 655, 335, + -1, 655, 648, -1, 655, 485, -1, 655, 600, -1, + 655, 650, -1, 655, 350, -1, 655, 737, -1, 492, + -1, 448, -1, 319, -1, 318, -1, 415, -1, 324, + -1, 242, 658, 297, -1, -1, 658, 656, -1, 658, + 682, -1, 243, 620, 660, 297, -1, 620, -1, 660, + 650, -1, 244, 668, 424, 662, 297, -1, 657, -1, + 545, -1, 662, 350, -1, 662, 737, -1, 245, 664, + 665, 297, -1, 764, -1, 549, -1, 765, -1, 695, + -1, 246, 667, 297, -1, -1, 667, 517, -1, 551, + -1, 247, 670, 670, 734, 297, -1, 766, -1, 115, + 766, 766, 297, -1, 248, 766, 766, 297, -1, 249, + 766, 766, 297, -1, 250, 674, 297, -1, 765, -1, + 674, 673, -1, 674, 765, -1, 674, 454, -1, 251, + 676, 297, -1, 364, -1, 676, 650, -1, 551, -1, + 252, 679, 297, -1, 677, -1, 679, 639, -1, 679, + 756, -1, 679, 309, -1, 679, 350, -1, 679, 737, + -1, 253, 681, 297, -1, -1, 681, 526, -1, 681, + 350, -1, 681, 737, -1, 254, 683, 297, -1, -1, + 656, -1, 255, 750, 685, 297, -1, -1, 718, -1, + 256, 687, 297, -1, -1, 702, -1, 257, 689, 297, + -1, 702, -1, 689, 684, -1, 258, 691, 297, -1, + -1, 691, 762, -1, 691, 350, -1, 691, 737, -1, + 259, 693, 694, 297, -1, 643, -1, 644, -1, 637, + -1, 404, -1, 694, 724, -1, 694, 322, -1, 261, + 698, 297, -1, 260, 697, 297, -1, -1, 697, 765, + -1, 697, 695, -1, 697, 696, -1, 765, -1, 698, + 395, -1, 262, 517, 297, -1, 263, 701, 297, -1, + -1, 701, 633, -1, 701, 430, -1, 701, 454, -1, + 701, 352, -1, 701, 307, -1, 701, 599, -1, 701, + 335, -1, 701, 648, -1, 701, 485, -1, 701, 600, + -1, 701, 650, -1, 701, 350, -1, 701, 737, -1, + 264, 703, 297, -1, -1, 703, 718, -1, 265, 705, + 297, -1, -1, 705, 409, -1, 705, 706, -1, 266, + 707, 708, 297, -1, 524, -1, 644, -1, 569, -1, + 704, -1, -1, 378, -1, 502, -1, 267, 710, 297, + -1, 580, -1, 710, 420, -1, 710, 418, -1, 710, + 680, -1, 710, 389, -1, 710, 350, -1, 710, 737, + -1, 268, 766, 297, -1, 269, 713, 714, 297, -1, + 413, -1, 584, -1, 413, -1, 584, -1, 404, -1, + 270, 766, 766, 766, 766, 766, 766, 297, -1, 271, + 717, 297, -1, 382, -1, 717, 607, -1, 717, 443, + -1, 717, 350, -1, 717, 737, -1, 272, 719, 720, + 721, 722, 723, 297, -1, -1, 671, -1, -1, 672, + -1, -1, 380, -1, -1, 587, -1, -1, 589, -1, + 273, 725, 725, 297, -1, 517, -1, 510, -1, 518, + -1, 274, 727, 297, -1, -1, 727, 344, -1, 727, + 692, -1, 727, 453, -1, 275, 297, -1, 327, -1, + 468, -1, 538, -1, 576, -1, 614, -1, 696, -1, + 276, 297, -1, 277, 297, -1, 278, 733, 297, -1, + 428, -1, 434, -1, 733, 428, -1, 733, 434, -1, + 279, 735, 297, -1, 17, -1, 10, -1, 16, -1, + 48, -1, 54, -1, 56, -1, 61, -1, 33, -1, + 22, -1, 25, -1, 19, -1, 42, -1, 14, -1, + 15, -1, 21, -1, 7, -1, 280, 297, -1, 281, + 738, 297, -1, 764, -1, 738, 766, -1, 738, 765, + -1, 738, 764, -1, 738, 445, -1, 551, -1, 312, + -1, 552, -1, 536, -1, 282, 765, 297, -1, 283, + 748, 752, 743, 297, -1, 470, -1, 743, 690, -1, + 743, 355, -1, 743, 350, -1, 743, 650, -1, 743, + 737, -1, 284, 745, 297, -1, -1, 745, 750, -1, + 745, 744, -1, 285, 747, 297, -1, -1, 747, 640, + -1, 747, 625, -1, 747, 462, -1, 747, 458, -1, + 747, 563, -1, 747, 555, -1, 747, 350, -1, 747, + 737, -1, 551, -1, 552, -1, 286, 749, 751, 297, + -1, -1, 339, -1, 287, 753, 297, -1, 32, -1, + 41, -1, 39, -1, 51, -1, 53, -1, 8, -1, + 28, -1, 18, -1, 24, -1, 52, -1, 288, 332, + 297, -1, 289, 542, 297, -1, 290, 516, 670, 528, + 297, -1, 291, 517, 297, -1, 292, 759, 297, -1, + -1, 759, 644, -1, 759, 637, -1, 759, 481, -1, + 293, 761, 297, -1, 726, -1, 761, 305, -1, 761, + 440, -1, 761, 530, -1, 761, 504, -1, 761, 350, + -1, 761, 737, -1, 294, 763, 297, -1, 715, -1, + 763, 320, -1, 763, 646, -1, 763, 368, -1, 763, + 650, -1, 763, 350, -1, 763, 737, -1, 3, -1, + 6, -1, 4, -1, 5, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const yytype_uint16 yyrline[] = -{ - 0, 505, 505, 508, 511, 512, 513, 514, 515, 516, - 517, 520, 523, 526, 530, 533, 534, 537, 540, 541, - 542, 543, 544, 545, 548, 551, 552, 555, 558, 559, - 560, 561, 562, 565, 568, 571, 572, 575, 578, 581, - 582, 583, 584, 585, 588, 591, 594, 597, 600, 603, - 606, 607, 608, 611, 614, 615, 618, 619, 622, 625, - 626, 627, 628, 631, 634, 635, 638, 641, 642, 645, - 648, 651, 654, 657, 658, 659, 660, 661, 662, 663, - 666, 669, 672, 673, 676, 679, 682, 683, 684, 687, - 690, 691, 692, 695, 696, 697, 700, 703, 704, 707, - 710, 713, 714, 717, 720, 721, 722, 723, 724, 725, - 726, 727, 730, 733, 736, 737, 738, 739, 740, 741, - 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, - 752, 753, 756, 759, 760, 763, 766, 767, 768, 771, - 774, 775, 778, 781, 784, 785, 786, 789, 792, 793, - 796, 799, 800, 803, 806, 807, 810, 813, 814, 817, - 820, 821, 824, 827, 828, 831, 834, 835, 838, 841, - 842, 845, 848, 849, 850, 853, 856, 857, 858, 859, - 860, 863, 866, 867, 870, 873, 876, 877, 878, 879, - 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, - 890, 893, 896, 897, 898, 899, 902, 905, 906, 907, - 910, 913, 914, 917, 918, 921, 922, 925, 926, 929, - 932, 933, 936, 939, 940, 943, 946, 950, 951, 952, - 953, 956, 959, 960, 961, 964, 968, 969, 970, 973, - 974, 975, 976, 979, 980, 981, 984, 987, 988, 989, - 990, 991, 992, 993, 996, 999, 1002, 1003, 1004, 1005, - 1006, 1009, 1012, 1015, 1018, 1019, 1020, 1021, 1022, 1023, - 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1034, 1037, - 1040, 1043, 1044, 1045, 1048, 1051, 1052, 1053, 1054, 1055, - 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1066, 1069, - 1070, 1073, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, - 1084, 1085, 1086, 1089, 1092, 1093, 1094, 1095, 1098, 1099, - 1100, 1101, 1102, 1105, 1108, 1109, 1110, 1111, 1114, 1117, - 1118, 1119, 1120, 1123, 1126, 1129, 1130, 1133, 1134, 1135, - 1136, 1139, 1142, 1143, 1146, 1149, 1150, 1151, 1152, 1153, - 1156, 1159, 1162, 1165, 1168, 1171, 1172, 1175, 1178, 1181, - 1182, 1183, 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1193, - 1196, 1197, 1198, 1201, 1204, 1205, 1206, 1207, 1208, 1211, - 1214, 1215, 1218, 1221, 1222, 1223, 1224, 1225, 1228, 1229, - 1232, 1233, 1236, 1239, 1240, 1243, 1246, 1247, 1248, 1249, - 1252, 1255, 1256, 1257, 1258, 1259, 1260, 1261, 1262, 1263, - 1264, 1265, 1266, 1267, 1268, 1269, 1270, 1271, 1274, 1278, - 1279, 1280, 1281, 1284, 1287, 1288, 1289, 1290, 1293, 1296, - 1297, 1298, 1299, 1302, 1305, 1306, 1309, 1312, 1315, 1316, - 1317, 1318, 1321, 1324, 1325, 1326, 1327, 1328, 1329, 1330, - 1331, 1332, 1335, 1338, 1339, 1342, 1345, 1348, 1349, 1352, - 1355, 1358, 1361, 1364, 1367, 1370, 1371, 1372, 1373, 1374, - 1377, 1380, 1383, 1384, 1387, 1390, 1391, 1392, 1395, 1398, - 1399, 1402, 1405, 1406, 1409, 1410, 1411, 1414, 1415, 1416, - 1419, 1422, 1423, 1424, 1425, 1428, 1431, 1432, 1433, 1434, - 1437, 1440, 1441, 1444, 1447, 1448, 1451, 1454, 1457, 1460, - 1461, 1462, 1465, 1468, 1469, 1470, 1471, 1474, 1477, 1478, - 1479, 1480, 1483, 1486, 1487, 1490, 1493, 1494, 1495, 1496, - 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, - 1507, 1510, 1513, 1514, 1515, 1516, 1517, 1520, 1523, 1524, - 1527, 1528, 1529, 1532, 1535, 1536, 1537, 1540, 1541, 1542, - 1545, 1548, 1549, 1552, 1555, 1556, 1557, 1558, 1561, 1564, - 1565, 1568, 1569, 1572, 1575, 1576, 1577, 1580, 1583, 1584, - 1587, 1590, 1591, 1592, 1593, 1594, 1597, 1600, 1601, 1604, - 1605, 1606, 1609, 1610, 1613, 1616, 1617, 1618, 1619, 1620, - 1621, 1622, 1623, 1624, 1625, 1628, 1631, 1632, 1633, 1634, - 1635, 1638, 1641, 1642, 1643, 1644, 1645, 1646, 1649, 1652, - 1653, 1654, 1657, 1660, 1661, 1662, 1665, 1668, 1669, 1670, - 1671, 1672, 1675, 1676, 1680, 1681, 1684, 1687, 1688, 1689, - 1690, 1693, 1696, 1699, 1700, 1701, 1704, 1707, 1708, 1709, - 1712, 1715, 1716, 1717, 1718, 1721, 1724, 1725, 1726, 1727, - 1730, 1733, 1734, 1737, 1740, 1741, 1742, 1743, 1746, 1749, - 1750, 1751, 1752, 1753, 1756, 1759, 1762, 1763, 1766, 1769, - 1770, 1771, 1772, 1773, 1774, 1775, 1776, 1779, 1782, 1786, - 1787, 1788, 1789, 1792, 1796, 1797, 1798, 1799, 1802, 1805, - 1806, 1809, 1812, 1815, 1816, 1817, 1818, 1819, 1820, 1821, - 1822, 1823, 1824, 1827, 1830, 1833, 1834, 1837, 1840, 1841, - 1844, 1847, 1850, 1851, 1854, 1857, 1858, 1861, 1864, 1867, - 1868, 1869, 1870, 1873, 1876, 1877, 1880, 1883, 1884, 1885, - 1886, 1889, 1892, 1893, 1896, 1899, 1900, 1903, 1906, 1909, - 1910, 1913, 1916, 1917, 1918, 1919, 1920, 1921, 1922, 1923, - 1924, 1925, 1926, 1927, 1928, 1931, 1934, 1935, 1936, 1937, - 1938, 1939, 1940, 1941, 1942, 1943, 1946, 1949, 1950, 1951, - 1952, 1955, 1958, 1959, 1960, 1961, 1964, 1967, 1968, 1969, - 1972, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, - 1984, 1985, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, - 1998, 1999, 2000, 2001, 2002, 2003, 2006, 2009, 2010, 2011, - 2014, 2017, 2020, 2021, 2022, 2023, 2024, 2027, 2028, 2031, - 2032, 2035, 2050, 2051, 2052, 2053, 2056, 2059, 2060, 2063, - 2066, 2067, 2070, 2073, 2074, 2075, 2076, 2077, 2080, 2083, - 2086, 2089, 2090, 2091, 2092, 2093, 2094, 2095, 2096, 2097, - 2098, 2099, 2100, 2103, 2104, 2105, 2106, 2107, 2108, 2111, - 2114, 2115, 2116, 2119, 2122, 2123, 2126, 2129, 2130, 2131, - 2132, 2135, 2139, 2140, 2143, 2144, 2147, 2150, 2151, 2154, - 2157, 2160, 2161, 2164, 2167, 2170, 2173, 2174, 2175, 2176, - 2179, 2182, 2183, 2186, 2189, 2192, 2193, 2194, 2195, 2196, - 2197, 2200, 2203, 2204, 2205, 2206, 2209, 2212, 2213, 2216, - 2219, 2220, 2223, 2226, 2227, 2230, 2233, 2234, 2237, 2240, - 2241, 2242, 2243, 2246, 2249, 2250, 2251, 2254, 2255, 2256, - 2259, 2262, 2265, 2266, 2267, 2268, 2271, 2272, 2275, 2278, - 2281, 2282, 2283, 2284, 2285, 2286, 2287, 2288, 2289, 2290, - 2291, 2292, 2293, 2294, 2297, 2300, 2301, 2304, 2307, 2308, - 2309, 2312, 2315, 2316, 2317, 2318, 2321, 2322, 2323, 2326, - 2329, 2330, 2331, 2332, 2333, 2334, 2335, 2338, 2341, 2344, - 2345, 2348, 2349, 2350, 2353, 2357, 2360, 2361, 2362, 2363, - 2364, 2367, 2371, 2372, 2375, 2376, 2379, 2380, 2383, 2384, - 2387, 2388, 2391, 2394, 2395, 2396, 2399, 2402, 2403, 2404, - 2405, 2408, 2411, 2412, 2413, 2414, 2415, 2416, 2419, 2422, - 2425, 2428, 2429, 2430, 2431, 2434, 2437, 2438, 2439, 2440, - 2441, 2442, 2443, 2444, 2445, 2446, 2447, 2448, 2449, 2450, - 2451, 2452, 2455, 2458, 2461, 2462, 2463, 2464, 2465, 2468, - 2469, 2472, 2473, 2476, 2479, 2482, 2483, 2484, 2485, 2486, - 2487, 2490, 2493, 2494, 2495, 2498, 2501, 2502, 2503, 2504, - 2505, 2506, 2507, 2508, 2509, 2512, 2515, 2518, 2521, 2522, - 2525, 2528, 2529, 2530, 2531, 2532, 2533, 2534, 2535, 2536, - 2537, 2540, 2543, 2546, 2549, 2552, 2555, 2556, 2557, 2558, - 2561, 2564, 2565, 2566, 2567, 2568, 2569, 2570, 2573, 2576, - 2577, 2578, 2579, 2580, 2581, 2582, 2585, 2588, 2591, 2594 +static const yytype_uint16 yyrline[] = { + 0, 505, 505, 508, 511, 512, 513, 514, 515, 516, + 517, 520, 523, 526, 530, 533, 534, 537, 540, 541, + 542, 543, 544, 545, 548, 551, 552, 555, 558, 559, + 560, 561, 562, 565, 568, 571, 572, 575, 578, 581, + 582, 583, 584, 585, 588, 591, 594, 597, 600, 603, + 606, 607, 608, 611, 614, 615, 618, 619, 622, 625, + 626, 627, 628, 631, 634, 635, 638, 641, 642, 645, + 648, 651, 654, 657, 658, 659, 660, 661, 662, 663, + 666, 669, 672, 673, 676, 679, 682, 683, 684, 687, + 690, 691, 692, 695, 696, 697, 700, 703, 704, 707, + 710, 713, 714, 717, 720, 721, 722, 723, 724, 725, + 726, 727, 730, 733, 736, 737, 738, 739, 740, 741, + 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, + 752, 753, 756, 759, 760, 763, 766, 767, 768, 771, + 774, 775, 778, 781, 784, 785, 786, 789, 792, 793, + 796, 799, 800, 803, 806, 807, 810, 813, 814, 817, + 820, 821, 824, 827, 828, 831, 834, 835, 838, 841, + 842, 845, 848, 849, 850, 853, 856, 857, 858, 859, + 860, 863, 866, 867, 870, 873, 876, 877, 878, 879, + 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, + 890, 893, 896, 897, 898, 899, 902, 905, 906, 907, + 910, 913, 914, 917, 918, 921, 922, 925, 926, 929, + 932, 933, 936, 939, 940, 943, 946, 950, 951, 952, + 953, 956, 959, 960, 961, 964, 968, 969, 970, 973, + 974, 975, 976, 979, 980, 981, 984, 987, 988, 989, + 990, 991, 992, 993, 996, 999, 1002, 1003, 1004, 1005, + 1006, 1009, 1012, 1015, 1018, 1019, 1020, 1021, 1022, 1023, + 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1034, 1037, + 1040, 1043, 1044, 1045, 1048, 1051, 1052, 1053, 1054, 1055, + 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1066, 1069, + 1070, 1073, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, + 1084, 1085, 1086, 1089, 1092, 1093, 1094, 1095, 1098, 1099, + 1100, 1101, 1102, 1105, 1108, 1109, 1110, 1111, 1114, 1117, + 1118, 1119, 1120, 1123, 1126, 1129, 1130, 1133, 1134, 1135, + 1136, 1139, 1142, 1143, 1146, 1149, 1150, 1151, 1152, 1153, + 1156, 1159, 1162, 1165, 1168, 1171, 1172, 1175, 1178, 1181, + 1182, 1183, 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1193, + 1196, 1197, 1198, 1201, 1204, 1205, 1206, 1207, 1208, 1211, + 1214, 1215, 1218, 1221, 1222, 1223, 1224, 1225, 1228, 1229, + 1232, 1233, 1236, 1239, 1240, 1243, 1246, 1247, 1248, 1249, + 1252, 1255, 1256, 1257, 1258, 1259, 1260, 1261, 1262, 1263, + 1264, 1265, 1266, 1267, 1268, 1269, 1270, 1271, 1274, 1278, + 1279, 1280, 1281, 1284, 1287, 1288, 1289, 1290, 1293, 1296, + 1297, 1298, 1299, 1302, 1305, 1306, 1309, 1312, 1315, 1316, + 1317, 1318, 1321, 1324, 1325, 1326, 1327, 1328, 1329, 1330, + 1331, 1332, 1335, 1338, 1339, 1342, 1345, 1348, 1349, 1352, + 1355, 1358, 1361, 1364, 1367, 1370, 1371, 1372, 1373, 1374, + 1377, 1380, 1383, 1384, 1387, 1390, 1391, 1392, 1395, 1398, + 1399, 1402, 1405, 1406, 1409, 1410, 1411, 1414, 1415, 1416, + 1419, 1422, 1423, 1424, 1425, 1428, 1431, 1432, 1433, 1434, + 1437, 1440, 1441, 1444, 1447, 1448, 1451, 1454, 1457, 1460, + 1461, 1462, 1465, 1468, 1469, 1470, 1471, 1474, 1477, 1478, + 1479, 1480, 1483, 1486, 1487, 1490, 1493, 1494, 1495, 1496, + 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, + 1507, 1510, 1513, 1514, 1515, 1516, 1517, 1520, 1523, 1524, + 1527, 1528, 1529, 1532, 1535, 1536, 1537, 1540, 1541, 1542, + 1545, 1548, 1549, 1552, 1555, 1556, 1557, 1558, 1561, 1564, + 1565, 1568, 1569, 1572, 1575, 1576, 1577, 1580, 1583, 1584, + 1587, 1590, 1591, 1592, 1593, 1594, 1597, 1600, 1601, 1604, + 1605, 1606, 1609, 1610, 1613, 1616, 1617, 1618, 1619, 1620, + 1621, 1622, 1623, 1624, 1625, 1628, 1631, 1632, 1633, 1634, + 1635, 1638, 1641, 1642, 1643, 1644, 1645, 1646, 1649, 1652, + 1653, 1654, 1657, 1660, 1661, 1662, 1665, 1668, 1669, 1670, + 1671, 1672, 1675, 1676, 1680, 1681, 1684, 1687, 1688, 1689, + 1690, 1693, 1696, 1699, 1700, 1701, 1704, 1707, 1708, 1709, + 1712, 1715, 1716, 1717, 1718, 1721, 1724, 1725, 1726, 1727, + 1730, 1733, 1734, 1737, 1740, 1741, 1742, 1743, 1746, 1749, + 1750, 1751, 1752, 1753, 1756, 1759, 1762, 1763, 1766, 1769, + 1770, 1771, 1772, 1773, 1774, 1775, 1776, 1779, 1782, 1786, + 1787, 1788, 1789, 1792, 1796, 1797, 1798, 1799, 1802, 1805, + 1806, 1809, 1812, 1815, 1816, 1817, 1818, 1819, 1820, 1821, + 1822, 1823, 1824, 1827, 1830, 1833, 1834, 1837, 1840, 1841, + 1844, 1847, 1850, 1851, 1854, 1857, 1858, 1861, 1864, 1867, + 1868, 1869, 1870, 1873, 1876, 1877, 1880, 1883, 1884, 1885, + 1886, 1889, 1892, 1893, 1896, 1899, 1900, 1903, 1906, 1909, + 1910, 1913, 1916, 1917, 1918, 1919, 1920, 1921, 1922, 1923, + 1924, 1925, 1926, 1927, 1928, 1931, 1934, 1935, 1936, 1937, + 1938, 1939, 1940, 1941, 1942, 1943, 1946, 1949, 1950, 1951, + 1952, 1955, 1958, 1959, 1960, 1961, 1964, 1967, 1968, 1969, + 1972, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, + 1984, 1985, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, + 1998, 1999, 2000, 2001, 2002, 2003, 2006, 2009, 2010, 2011, + 2014, 2017, 2020, 2021, 2022, 2023, 2024, 2027, 2028, 2031, + 2032, 2035, 2050, 2051, 2052, 2053, 2056, 2059, 2060, 2063, + 2066, 2067, 2070, 2073, 2074, 2075, 2076, 2077, 2080, 2083, + 2086, 2089, 2090, 2091, 2092, 2093, 2094, 2095, 2096, 2097, + 2098, 2099, 2100, 2103, 2104, 2105, 2106, 2107, 2108, 2111, + 2114, 2115, 2116, 2119, 2122, 2123, 2126, 2129, 2130, 2131, + 2132, 2135, 2139, 2140, 2143, 2144, 2147, 2150, 2151, 2154, + 2157, 2160, 2161, 2164, 2167, 2170, 2173, 2174, 2175, 2176, + 2179, 2182, 2183, 2186, 2189, 2192, 2193, 2194, 2195, 2196, + 2197, 2200, 2203, 2204, 2205, 2206, 2209, 2212, 2213, 2216, + 2219, 2220, 2223, 2226, 2227, 2230, 2233, 2234, 2237, 2240, + 2241, 2242, 2243, 2246, 2249, 2250, 2251, 2254, 2255, 2256, + 2259, 2262, 2265, 2266, 2267, 2268, 2271, 2272, 2275, 2278, + 2281, 2282, 2283, 2284, 2285, 2286, 2287, 2288, 2289, 2290, + 2291, 2292, 2293, 2294, 2297, 2300, 2301, 2304, 2307, 2308, + 2309, 2312, 2315, 2316, 2317, 2318, 2321, 2322, 2323, 2326, + 2329, 2330, 2331, 2332, 2333, 2334, 2335, 2338, 2341, 2344, + 2345, 2348, 2349, 2350, 2353, 2357, 2360, 2361, 2362, 2363, + 2364, 2367, 2371, 2372, 2375, 2376, 2379, 2380, 2383, 2384, + 2387, 2388, 2391, 2394, 2395, 2396, 2399, 2402, 2403, 2404, + 2405, 2408, 2411, 2412, 2413, 2414, 2415, 2416, 2419, 2422, + 2425, 2428, 2429, 2430, 2431, 2434, 2437, 2438, 2439, 2440, + 2441, 2442, 2443, 2444, 2445, 2446, 2447, 2448, 2449, 2450, + 2451, 2452, 2455, 2458, 2461, 2462, 2463, 2464, 2465, 2468, + 2469, 2472, 2473, 2476, 2479, 2482, 2483, 2484, 2485, 2486, + 2487, 2490, 2493, 2494, 2495, 2498, 2501, 2502, 2503, 2504, + 2505, 2506, 2507, 2508, 2509, 2512, 2515, 2518, 2521, 2522, + 2525, 2528, 2529, 2530, 2531, 2532, 2533, 2534, 2535, 2536, + 2537, 2540, 2543, 2546, 2549, 2552, 2555, 2556, 2557, 2558, + 2561, 2564, 2565, 2566, 2567, 2568, 2569, 2570, 2573, 2576, + 2577, 2578, 2579, 2580, 2581, 2582, 2585, 2588, 2591, 2594 }; #endif @@ -1773,918 +1755,910 @@ #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "$end", "error", "$undefined", "EDIF_TOK_IDENT", "EDIF_TOK_INT", - "EDIF_TOK_KEYWORD", "EDIF_TOK_STR", "EDIF_TOK_ANGLE", - "EDIF_TOK_BEHAVIOR", "EDIF_TOK_CALCULATED", "EDIF_TOK_CAPACITANCE", - "EDIF_TOK_CENTERCENTER", "EDIF_TOK_CENTERLEFT", "EDIF_TOK_CENTERRIGHT", - "EDIF_TOK_CHARGE", "EDIF_TOK_CONDUCTANCE", "EDIF_TOK_CURRENT", - "EDIF_TOK_DISTANCE", "EDIF_TOK_DOCUMENT", "EDIF_TOK_ENERGY", - "EDIF_TOK_EXTEND", "EDIF_TOK_FLUX", "EDIF_TOK_FREQUENCY", - "EDIF_TOK_GENERIC", "EDIF_TOK_GRAPHIC", "EDIF_TOK_INDUCTANCE", - "EDIF_TOK_INOUT", "EDIF_TOK_INPUT", "EDIF_TOK_LOGICMODEL", - "EDIF_TOK_LOWERCENTER", "EDIF_TOK_LOWERLEFT", "EDIF_TOK_LOWERRIGHT", - "EDIF_TOK_MASKLAYOUT", "EDIF_TOK_MASS", "EDIF_TOK_MEASURED", - "EDIF_TOK_MX", "EDIF_TOK_MXR90", "EDIF_TOK_MY", "EDIF_TOK_MYR90", - "EDIF_TOK_NETLIST", "EDIF_TOK_OUTPUT", "EDIF_TOK_PCBLAYOUT", - "EDIF_TOK_POWER", "EDIF_TOK_R0", "EDIF_TOK_R180", "EDIF_TOK_R270", - "EDIF_TOK_R90", "EDIF_TOK_REQUIRED", "EDIF_TOK_RESISTANCE", - "EDIF_TOK_RIPPER", "EDIF_TOK_ROUND", "EDIF_TOK_SCHEMATIC", - "EDIF_TOK_STRANGER", "EDIF_TOK_SYMBOLIC", "EDIF_TOK_TEMPERATURE", - "EDIF_TOK_TIE", "EDIF_TOK_TIME", "EDIF_TOK_TRUNCATE", - "EDIF_TOK_UPPERCENTER", "EDIF_TOK_UPPERLEFT", "EDIF_TOK_UPPERRIGHT", - "EDIF_TOK_VOLTAGE", "EDIF_TOK_ACLOAD", "EDIF_TOK_AFTER", - "EDIF_TOK_ANNOTATE", "EDIF_TOK_APPLY", "EDIF_TOK_ARC", "EDIF_TOK_ARRAY", - "EDIF_TOK_ARRAYMACRO", "EDIF_TOK_ARRAYRELATEDINFO", "EDIF_TOK_ARRAYSITE", - "EDIF_TOK_ATLEAST", "EDIF_TOK_ATMOST", "EDIF_TOK_AUTHOR", - "EDIF_TOK_BASEARRAY", "EDIF_TOK_BECOMES", "EDIF_TOK_BETWEEN", - "EDIF_TOK_BOOLEAN", "EDIF_TOK_BOOLEANDISPLAY", "EDIF_TOK_BOOLEANMAP", - "EDIF_TOK_BORDERPATTERN", "EDIF_TOK_BORDERWIDTH", "EDIF_TOK_BOUNDINGBOX", - "EDIF_TOK_CELL", "EDIF_TOK_CELLREF", "EDIF_TOK_CELLTYPE", - "EDIF_TOK_CHANGE", "EDIF_TOK_CIRCLE", "EDIF_TOK_COLOR", - "EDIF_TOK_COMMENT", "EDIF_TOK_COMMENTGRAPHICS", "EDIF_TOK_COMPOUND", - "EDIF_TOK_CONNECTLOCATION", "EDIF_TOK_CONTENTS", "EDIF_TOK_CORNERTYPE", - "EDIF_TOK_CRITICALITY", "EDIF_TOK_CURRENTMAP", "EDIF_TOK_CURVE", - "EDIF_TOK_CYCLE", "EDIF_TOK_DATAORIGIN", "EDIF_TOK_DCFANINLOAD", - "EDIF_TOK_DCFANOUTLOAD", "EDIF_TOK_DCMAXFANIN", "EDIF_TOK_DCMAXFANOUT", - "EDIF_TOK_DELAY", "EDIF_TOK_DELTA", "EDIF_TOK_DERIVATION", - "EDIF_TOK_DESIGN", "EDIF_TOK_DESIGNATOR", "EDIF_TOK_DIFFERENCE", - "EDIF_TOK_DIRECTION", "EDIF_TOK_DISPLAY", "EDIF_TOK_DOMINATES", - "EDIF_TOK_DOT", "EDIF_TOK_DURATION", "EDIF_TOK_E", "EDIF_TOK_EDIF", - "EDIF_TOK_EDIFLEVEL", "EDIF_TOK_EDIFVERSION", - "EDIF_TOK_ENCLOSUREDISTANCE", "EDIF_TOK_ENDTYPE", "EDIF_TOK_ENTRY", - "EDIF_TOK_EVENT", "EDIF_TOK_EXACTLY", "EDIF_TOK_EXTERNAL", - "EDIF_TOK_FABRICATE", "EDIF_TOK_FALSE", "EDIF_TOK_FIGURE", - "EDIF_TOK_FIGUREAREA", "EDIF_TOK_FIGUREGROUP", - "EDIF_TOK_FIGUREGROUPOBJECT", "EDIF_TOK_FIGUREGROUPOVERRIDE", - "EDIF_TOK_FIGUREGROUPREF", "EDIF_TOK_FIGUREPERIMETER", - "EDIF_TOK_FIGUREWIDTH", "EDIF_TOK_FILLPATTERN", "EDIF_TOK_FOLLOW", - "EDIF_TOK_FORBIDDENEVENT", "EDIF_TOK_GLOBALPORTREF", - "EDIF_TOK_GREATERTHAN", "EDIF_TOK_GRIDMAP", "EDIF_TOK_IGNORE", - "EDIF_TOK_INCLUDEFIGUREGROUP", "EDIF_TOK_INITIAL", "EDIF_TOK_INSTANCE", - "EDIF_TOK_INSTANCEBACKANNOTATE", "EDIF_TOK_INSTANCEGROUP", - "EDIF_TOK_INSTANCEMAP", "EDIF_TOK_INSTANCEREF", "EDIF_TOK_INTEGER", - "EDIF_TOK_INTEGERDISPLAY", "EDIF_TOK_INTERFACE", - "EDIF_TOK_INTERFIGUREGROUPSPACING", "EDIF_TOK_INTERSECTION", - "EDIF_TOK_INTRAFIGUREGROUPSPACING", "EDIF_TOK_INVERSE", - "EDIF_TOK_ISOLATED", "EDIF_TOK_JOINED", "EDIF_TOK_JUSTIFY", - "EDIF_TOK_KEYWORDDISPLAY", "EDIF_TOK_KEYWORDLEVEL", - "EDIF_TOK_KEYWORDMAP", "EDIF_TOK_LESSTHAN", "EDIF_TOK_LIBRARY", - "EDIF_TOK_LIBRARYREF", "EDIF_TOK_LISTOFNETS", "EDIF_TOK_LISTOFPORTS", - "EDIF_TOK_LOADDELAY", "EDIF_TOK_LOGICASSIGN", "EDIF_TOK_LOGICINPUT", - "EDIF_TOK_LOGICLIST", "EDIF_TOK_LOGICMAPINPUT", - "EDIF_TOK_LOGICMAPOUTPUT", "EDIF_TOK_LOGICONEOF", "EDIF_TOK_LOGICOUTPUT", - "EDIF_TOK_LOGICPORT", "EDIF_TOK_LOGICREF", "EDIF_TOK_LOGICVALUE", - "EDIF_TOK_LOGICWAVEFORM", "EDIF_TOK_MAINTAIN", "EDIF_TOK_MATCH", - "EDIF_TOK_MEMBER", "EDIF_TOK_MINOMAX", "EDIF_TOK_MINOMAXDISPLAY", - "EDIF_TOK_MNM", "EDIF_TOK_MULTIPLEVALUESET", "EDIF_TOK_MUSTJOIN", - "EDIF_TOK_NAME", "EDIF_TOK_NET", "EDIF_TOK_NETBACKANNOTATE", - "EDIF_TOK_NETBUNDLE", "EDIF_TOK_NETDELAY", "EDIF_TOK_NETGROUP", - "EDIF_TOK_NETMAP", "EDIF_TOK_NETREF", "EDIF_TOK_NOCHANGE", - "EDIF_TOK_NONPERMUTABLE", "EDIF_TOK_NOTALLOWED", "EDIF_TOK_NOTCHSPACING", - "EDIF_TOK_NUMBER", "EDIF_TOK_NUMBERDEFINITION", "EDIF_TOK_NUMBERDISPLAY", - "EDIF_TOK_OFFPAGECONNECTOR", "EDIF_TOK_OFFSETEVENT", - "EDIF_TOK_OPENSHAPE", "EDIF_TOK_ORIENTATION", "EDIF_TOK_ORIGIN", - "EDIF_TOK_OVERHANGDISTANCE", "EDIF_TOK_OVERLAPDISTANCE", - "EDIF_TOK_OVERSIZE", "EDIF_TOK_OWNER", "EDIF_TOK_PAGE", - "EDIF_TOK_PAGESIZE", "EDIF_TOK_PARAMETER", "EDIF_TOK_PARAMETERASSIGN", - "EDIF_TOK_PARAMETERDISPLAY", "EDIF_TOK_PATH", "EDIF_TOK_PATHDELAY", - "EDIF_TOK_PATHWIDTH", "EDIF_TOK_PERMUTABLE", - "EDIF_TOK_PHYSICALDESIGNRULE", "EDIF_TOK_PLUG", "EDIF_TOK_POINT", - "EDIF_TOK_POINTDISPLAY", "EDIF_TOK_POINTLIST", "EDIF_TOK_POLYGON", - "EDIF_TOK_PORT", "EDIF_TOK_PORTBACKANNOTATE", "EDIF_TOK_PORTBUNDLE", - "EDIF_TOK_PORTDELAY", "EDIF_TOK_PORTGROUP", - "EDIF_TOK_PORTIMPLEMENTATION", "EDIF_TOK_PORTINSTANCE", - "EDIF_TOK_PORTLIST", "EDIF_TOK_PORTLISTALIAS", "EDIF_TOK_PORTMAP", - "EDIF_TOK_PORTREF", "EDIF_TOK_PROGRAM", "EDIF_TOK_PROPERTY", - "EDIF_TOK_PROPERTYDISPLAY", "EDIF_TOK_PROTECTIONFRAME", "EDIF_TOK_PT", - "EDIF_TOK_RANGEVECTOR", "EDIF_TOK_RECTANGLE", "EDIF_TOK_RECTANGLESIZE", - "EDIF_TOK_RENAME", "EDIF_TOK_RESOLVES", "EDIF_TOK_SCALE", - "EDIF_TOK_SCALEX", "EDIF_TOK_SCALEY", "EDIF_TOK_SECTION", - "EDIF_TOK_SHAPE", "EDIF_TOK_SIMULATE", "EDIF_TOK_SIMULATIONINFO", - "EDIF_TOK_SINGLEVALUESET", "EDIF_TOK_SITE", "EDIF_TOK_SOCKET", - "EDIF_TOK_SOCKETSET", "EDIF_TOK_STATUS", "EDIF_TOK_STEADY", - "EDIF_TOK_STRING", "EDIF_TOK_STRINGDISPLAY", "EDIF_TOK_STRONG", - "EDIF_TOK_SYMBOL", "EDIF_TOK_SYMMETRY", "EDIF_TOK_TABLE", - "EDIF_TOK_TABLEDEFAULT", "EDIF_TOK_TECHNOLOGY", "EDIF_TOK_TEXTHEIGHT", - "EDIF_TOK_TIMEINTERVAL", "EDIF_TOK_TIMESTAMP", "EDIF_TOK_TIMING", - "EDIF_TOK_TRANSFORM", "EDIF_TOK_TRANSITION", "EDIF_TOK_TRIGGER", - "EDIF_TOK_TRUE", "EDIF_TOK_UNCONSTRAINED", "EDIF_TOK_UNDEFINED", - "EDIF_TOK_UNION", "EDIF_TOK_UNIT", "EDIF_TOK_UNUSED", - "EDIF_TOK_USERDATA", "EDIF_TOK_VERSION", "EDIF_TOK_VIEW", - "EDIF_TOK_VIEWLIST", "EDIF_TOK_VIEWMAP", "EDIF_TOK_VIEWREF", - "EDIF_TOK_VIEWTYPE", "EDIF_TOK_VISIBLE", "EDIF_TOK_VOLTAGEMAP", - "EDIF_TOK_WAVEVALUE", "EDIF_TOK_WEAK", "EDIF_TOK_WEAKJOINED", - "EDIF_TOK_WHEN", "EDIF_TOK_WRITTEN", "')'", "$accept", "PopC", "Edif", - "_Edif", "EdifFileName", "EdifLevel", "EdifVersion", "AcLoad", "_AcLoad", - "After", "_After", "Annotate", "_Annotate", "Apply", "_Apply", "Arc", - "Array", "_Array", "ArrayMacro", "ArrayRelInfo", "_ArrayRelInfo", - "ArraySite", "AtLeast", "AtMost", "Author", "BaseArray", "Becomes", - "_Becomes", "Between", "__Between", "_Between", "Boolean", "_Boolean", - "BooleanDisp", "_BooleanDisp", "BooleanMap", "BooleanValue", "BorderPat", - "BorderWidth", "BoundBox", "Cell", "_Cell", "CellNameDef", "CellRef", - "_CellRef", "CellNameRef", "CellType", "_CellType", "Change", "__Change", - "_Change", "Circle", "_Circle", "Color", "Comment", "_Comment", - "CommGraph", "_CommGraph", "Compound", "Contents", "_Contents", - "ConnectLoc", "_ConnectLoc", "CornerType", "_CornerType", "Criticality", - "_Criticality", "CurrentMap", "Curve", "_Curve", "Cycle", "_Cycle", - "DataOrigin", "_DataOrigin", "DcFanInLoad", "_DcFanInLoad", - "DcFanOutLoad", "_DcFanOutLoad", "DcMaxFanIn", "_DcMaxFanIn", - "DcMaxFanOut", "_DcMaxFanOut", "Delay", "_Delay", "Delta", "_Delta", - "Derivation", "_Derivation", "Design", "_Design", "Designator", - "_Designator", "DesignNameDef", "DesignRule", "_DesignRule", - "Difference", "_Difference", "Direction", "_Direction", "Display", - "_Display", "_DisplayJust", "_DisplayOrien", "_DisplayOrg", "Dominates", - "_Dominates", "Dot", "_Dot", "Duration", "EncloseDist", "_EncloseDist", - "EndType", "_EndType", "Entry", "___Entry", "__Entry", "_Entry", "Event", - "_Event", "Exactly", "External", "_External", "Fabricate", "False", - "FigGrp", "_FigGrp", "FigGrpNameDef", "FigGrpNameRef", "FigGrpObj", - "_FigGrpObj", "FigGrpOver", "_FigGrpOver", "FigGrpRef", "_FigGrpRef", - "Figure", "_Figure", "FigureArea", "_FigureArea", "FigureOp", - "FigurePerim", "_FigurePerim", "FigureWidth", "_FigureWidth", - "FillPattern", "Follow", "__Follow", "_Follow", "Forbidden", - "_Forbidden", "Form", "_Form", "GlobPortRef", "GreaterThan", "GridMap", - "Ignore", "IncFigGrp", "_IncFigGrp", "Initial", "Instance", "_Instance", - "InstanceRef", "_InstanceRef", "InstBackAn", "_InstBackAn", "InstGroup", - "_InstGroup", "InstMap", "_InstMap", "InstNameDef", "InstNameRef", - "IntDisplay", "_IntDisplay", "Integer", "_Integer", "Interface", - "_Interface", "InterFigGrp", "_InterFigGrp", "Intersection", - "_Intersection", "IntraFigGrp", "_IntraFigGrp", "Inverse", "_Inverse", - "Isolated", "Joined", "_Joined", "Justify", "_Justify", "KeywordDisp", - "_KeywordDisp", "KeywordLevel", "KeywordMap", "_KeywordMap", - "KeywordName", "LayerNameDef", "LessThan", "LibNameDef", "LibNameRef", - "Library", "_Library", "LibraryRef", "ListOfNets", "_ListOfNets", - "ListOfPorts", "_ListOfPorts", "LoadDelay", "_LoadDelay", "LogicAssn", - "___LogicAssn", "__LogicAssn", "_LogicAssn", "LogicIn", "_LogicIn", - "LogicList", "_LogicList", "LogicMapIn", "_LogicMapIn", "LogicMapOut", - "_LogicMapOut", "LogicNameDef", "LogicNameRef", "LogicOneOf", - "_LogicOneOf", "LogicOut", "_LogicOut", "LogicPort", "_LogicPort", - "LogicRef", "_LogicRef", "LogicValue", "_LogicValue", "LogicWave", - "_LogicWave", "Maintain", "__Maintain", "_Maintain", "Match", "__Match", - "_Match", "Member", "_Member", "MiNoMa", "_MiNoMa", "MiNoMaDisp", - "_MiNoMaDisp", "MiNoMaValue", "Mnm", "_Mnm", "MultValSet", "_MultValSet", - "MustJoin", "_MustJoin", "Name", "_Name", "NameDef", "NameRef", "Net", - "_Net", "NetBackAn", "_NetBackAn", "NetBundle", "_NetBundle", "NetDelay", - "_NetDelay", "NetGroup", "_NetGroup", "NetMap", "_NetMap", "NetNameDef", - "NetNameRef", "NetRef", "_NetRef", "NoChange", "NonPermut", "_NonPermut", - "NotAllowed", "_NotAllowed", "NotchSpace", "_NotchSpace", "Number", - "_Number", "NumbDisplay", "_NumbDisplay", "NumberDefn", "_NumberDefn", - "OffPageConn", "_OffPageConn", "OffsetEvent", "OpenShape", "_OpenShape", - "Orientation", "_Orientation", "Origin", "OverhngDist", "_OverhngDist", - "OverlapDist", "_OverlapDist", "Oversize", "_Oversize", "Owner", "Page", - "_Page", "PageSize", "ParamDisp", "_ParamDisp", "Parameter", - "_Parameter", "ParamAssign", "Path", "_Path", "PathDelay", "_PathDelay", - "PathWidth", "Permutable", "_Permutable", "Plug", "_Plug", "Point", - "_Point", "PointDisp", "_PointDisp", "PointList", "_PointList", - "PointValue", "Polygon", "_Polygon", "Port", "_Port", "PortBackAn", - "_PortBackAn", "PortBundle", "_PortBundle", "PortDelay", "_PortDelay", - "PortGroup", "_PortGroup", "PortImpl", "_PortImpl", "PortInst", - "_PortInst", "PortList", "_PortList", "PortListAls", "PortMap", - "_PortMap", "PortNameDef", "PortNameRef", "PortRef", "_PortRef", - "Program", "_Program", "PropDisplay", "_PropDisplay", "Property", - "_Property", "PropNameDef", "PropNameRef", "ProtectFrame", - "_ProtectFrame", "Range", "RangeVector", "_RangeVector", "Rectangle", - "_Rectangle", "RectSize", "_RectSize", "Rename", "__Rename", "_Rename", - "Resolves", "_Resolves", "RuleNameDef", "Scale", "ScaledInt", "ScaleX", - "ScaleY", "Section", "_Section", "Shape", "_Shape", "SimNameDef", - "Simulate", "_Simulate", "SimulInfo", "_SimulInfo", "SingleValSet", - "_SingleValSet", "Site", "_Site", "Socket", "_Socket", "SocketSet", - "_SocketSet", "Status", "_Status", "Steady", "__Steady", "_Steady", - "StrDisplay", "String", "_String", "_StrDisplay", "Strong", "Symbol", - "_Symbol", "Symmetry", "_Symmetry", "Table", "_Table", "TableDeflt", - "__TableDeflt", "_TableDeflt", "Technology", "_Technology", "TextHeight", - "TimeIntval", "__TimeIntval", "_TimeIntval", "TimeStamp", "Timing", - "_Timing", "Transform", "_TransX", "_TransY", "_TransDelta", - "_TransOrien", "_TransOrg", "Transition", "_Transition", "Trigger", - "_Trigger", "True", "TypedValue", "Unconstrained", "Undefined", "Union", - "_Union", "Unit", "_Unit", "Unused", "UserData", "_UserData", - "ValueNameDef", "ValueNameRef", "Version", "View", "_View", "ViewList", - "_ViewList", "ViewMap", "_ViewMap", "ViewNameDef", "ViewNameRef", - "ViewRef", "_ViewRef", "ViewType", "_ViewType", "Visible", "VoltageMap", - "WaveValue", "Weak", "WeakJoined", "_WeakJoined", "When", "_When", - "Written", "_Written", "Ident", "Str", "Int", "Keyword", 0 +static const char *const yytname[] = { + "$end", "error", "$undefined", "EDIF_TOK_IDENT", "EDIF_TOK_INT", + "EDIF_TOK_KEYWORD", "EDIF_TOK_STR", "EDIF_TOK_ANGLE", + "EDIF_TOK_BEHAVIOR", "EDIF_TOK_CALCULATED", "EDIF_TOK_CAPACITANCE", + "EDIF_TOK_CENTERCENTER", "EDIF_TOK_CENTERLEFT", "EDIF_TOK_CENTERRIGHT", + "EDIF_TOK_CHARGE", "EDIF_TOK_CONDUCTANCE", "EDIF_TOK_CURRENT", + "EDIF_TOK_DISTANCE", "EDIF_TOK_DOCUMENT", "EDIF_TOK_ENERGY", + "EDIF_TOK_EXTEND", "EDIF_TOK_FLUX", "EDIF_TOK_FREQUENCY", + "EDIF_TOK_GENERIC", "EDIF_TOK_GRAPHIC", "EDIF_TOK_INDUCTANCE", + "EDIF_TOK_INOUT", "EDIF_TOK_INPUT", "EDIF_TOK_LOGICMODEL", + "EDIF_TOK_LOWERCENTER", "EDIF_TOK_LOWERLEFT", "EDIF_TOK_LOWERRIGHT", + "EDIF_TOK_MASKLAYOUT", "EDIF_TOK_MASS", "EDIF_TOK_MEASURED", + "EDIF_TOK_MX", "EDIF_TOK_MXR90", "EDIF_TOK_MY", "EDIF_TOK_MYR90", + "EDIF_TOK_NETLIST", "EDIF_TOK_OUTPUT", "EDIF_TOK_PCBLAYOUT", + "EDIF_TOK_POWER", "EDIF_TOK_R0", "EDIF_TOK_R180", "EDIF_TOK_R270", + "EDIF_TOK_R90", "EDIF_TOK_REQUIRED", "EDIF_TOK_RESISTANCE", + "EDIF_TOK_RIPPER", "EDIF_TOK_ROUND", "EDIF_TOK_SCHEMATIC", + "EDIF_TOK_STRANGER", "EDIF_TOK_SYMBOLIC", "EDIF_TOK_TEMPERATURE", + "EDIF_TOK_TIE", "EDIF_TOK_TIME", "EDIF_TOK_TRUNCATE", + "EDIF_TOK_UPPERCENTER", "EDIF_TOK_UPPERLEFT", "EDIF_TOK_UPPERRIGHT", + "EDIF_TOK_VOLTAGE", "EDIF_TOK_ACLOAD", "EDIF_TOK_AFTER", + "EDIF_TOK_ANNOTATE", "EDIF_TOK_APPLY", "EDIF_TOK_ARC", "EDIF_TOK_ARRAY", + "EDIF_TOK_ARRAYMACRO", "EDIF_TOK_ARRAYRELATEDINFO", "EDIF_TOK_ARRAYSITE", + "EDIF_TOK_ATLEAST", "EDIF_TOK_ATMOST", "EDIF_TOK_AUTHOR", + "EDIF_TOK_BASEARRAY", "EDIF_TOK_BECOMES", "EDIF_TOK_BETWEEN", + "EDIF_TOK_BOOLEAN", "EDIF_TOK_BOOLEANDISPLAY", "EDIF_TOK_BOOLEANMAP", + "EDIF_TOK_BORDERPATTERN", "EDIF_TOK_BORDERWIDTH", "EDIF_TOK_BOUNDINGBOX", + "EDIF_TOK_CELL", "EDIF_TOK_CELLREF", "EDIF_TOK_CELLTYPE", + "EDIF_TOK_CHANGE", "EDIF_TOK_CIRCLE", "EDIF_TOK_COLOR", + "EDIF_TOK_COMMENT", "EDIF_TOK_COMMENTGRAPHICS", "EDIF_TOK_COMPOUND", + "EDIF_TOK_CONNECTLOCATION", "EDIF_TOK_CONTENTS", "EDIF_TOK_CORNERTYPE", + "EDIF_TOK_CRITICALITY", "EDIF_TOK_CURRENTMAP", "EDIF_TOK_CURVE", + "EDIF_TOK_CYCLE", "EDIF_TOK_DATAORIGIN", "EDIF_TOK_DCFANINLOAD", + "EDIF_TOK_DCFANOUTLOAD", "EDIF_TOK_DCMAXFANIN", "EDIF_TOK_DCMAXFANOUT", + "EDIF_TOK_DELAY", "EDIF_TOK_DELTA", "EDIF_TOK_DERIVATION", + "EDIF_TOK_DESIGN", "EDIF_TOK_DESIGNATOR", "EDIF_TOK_DIFFERENCE", + "EDIF_TOK_DIRECTION", "EDIF_TOK_DISPLAY", "EDIF_TOK_DOMINATES", + "EDIF_TOK_DOT", "EDIF_TOK_DURATION", "EDIF_TOK_E", "EDIF_TOK_EDIF", + "EDIF_TOK_EDIFLEVEL", "EDIF_TOK_EDIFVERSION", + "EDIF_TOK_ENCLOSUREDISTANCE", "EDIF_TOK_ENDTYPE", "EDIF_TOK_ENTRY", + "EDIF_TOK_EVENT", "EDIF_TOK_EXACTLY", "EDIF_TOK_EXTERNAL", + "EDIF_TOK_FABRICATE", "EDIF_TOK_FALSE", "EDIF_TOK_FIGURE", + "EDIF_TOK_FIGUREAREA", "EDIF_TOK_FIGUREGROUP", + "EDIF_TOK_FIGUREGROUPOBJECT", "EDIF_TOK_FIGUREGROUPOVERRIDE", + "EDIF_TOK_FIGUREGROUPREF", "EDIF_TOK_FIGUREPERIMETER", + "EDIF_TOK_FIGUREWIDTH", "EDIF_TOK_FILLPATTERN", "EDIF_TOK_FOLLOW", + "EDIF_TOK_FORBIDDENEVENT", "EDIF_TOK_GLOBALPORTREF", + "EDIF_TOK_GREATERTHAN", "EDIF_TOK_GRIDMAP", "EDIF_TOK_IGNORE", + "EDIF_TOK_INCLUDEFIGUREGROUP", "EDIF_TOK_INITIAL", "EDIF_TOK_INSTANCE", + "EDIF_TOK_INSTANCEBACKANNOTATE", "EDIF_TOK_INSTANCEGROUP", + "EDIF_TOK_INSTANCEMAP", "EDIF_TOK_INSTANCEREF", "EDIF_TOK_INTEGER", + "EDIF_TOK_INTEGERDISPLAY", "EDIF_TOK_INTERFACE", + "EDIF_TOK_INTERFIGUREGROUPSPACING", "EDIF_TOK_INTERSECTION", + "EDIF_TOK_INTRAFIGUREGROUPSPACING", "EDIF_TOK_INVERSE", + "EDIF_TOK_ISOLATED", "EDIF_TOK_JOINED", "EDIF_TOK_JUSTIFY", + "EDIF_TOK_KEYWORDDISPLAY", "EDIF_TOK_KEYWORDLEVEL", + "EDIF_TOK_KEYWORDMAP", "EDIF_TOK_LESSTHAN", "EDIF_TOK_LIBRARY", + "EDIF_TOK_LIBRARYREF", "EDIF_TOK_LISTOFNETS", "EDIF_TOK_LISTOFPORTS", + "EDIF_TOK_LOADDELAY", "EDIF_TOK_LOGICASSIGN", "EDIF_TOK_LOGICINPUT", + "EDIF_TOK_LOGICLIST", "EDIF_TOK_LOGICMAPINPUT", + "EDIF_TOK_LOGICMAPOUTPUT", "EDIF_TOK_LOGICONEOF", "EDIF_TOK_LOGICOUTPUT", + "EDIF_TOK_LOGICPORT", "EDIF_TOK_LOGICREF", "EDIF_TOK_LOGICVALUE", + "EDIF_TOK_LOGICWAVEFORM", "EDIF_TOK_MAINTAIN", "EDIF_TOK_MATCH", + "EDIF_TOK_MEMBER", "EDIF_TOK_MINOMAX", "EDIF_TOK_MINOMAXDISPLAY", + "EDIF_TOK_MNM", "EDIF_TOK_MULTIPLEVALUESET", "EDIF_TOK_MUSTJOIN", + "EDIF_TOK_NAME", "EDIF_TOK_NET", "EDIF_TOK_NETBACKANNOTATE", + "EDIF_TOK_NETBUNDLE", "EDIF_TOK_NETDELAY", "EDIF_TOK_NETGROUP", + "EDIF_TOK_NETMAP", "EDIF_TOK_NETREF", "EDIF_TOK_NOCHANGE", + "EDIF_TOK_NONPERMUTABLE", "EDIF_TOK_NOTALLOWED", "EDIF_TOK_NOTCHSPACING", + "EDIF_TOK_NUMBER", "EDIF_TOK_NUMBERDEFINITION", "EDIF_TOK_NUMBERDISPLAY", + "EDIF_TOK_OFFPAGECONNECTOR", "EDIF_TOK_OFFSETEVENT", + "EDIF_TOK_OPENSHAPE", "EDIF_TOK_ORIENTATION", "EDIF_TOK_ORIGIN", + "EDIF_TOK_OVERHANGDISTANCE", "EDIF_TOK_OVERLAPDISTANCE", + "EDIF_TOK_OVERSIZE", "EDIF_TOK_OWNER", "EDIF_TOK_PAGE", + "EDIF_TOK_PAGESIZE", "EDIF_TOK_PARAMETER", "EDIF_TOK_PARAMETERASSIGN", + "EDIF_TOK_PARAMETERDISPLAY", "EDIF_TOK_PATH", "EDIF_TOK_PATHDELAY", + "EDIF_TOK_PATHWIDTH", "EDIF_TOK_PERMUTABLE", + "EDIF_TOK_PHYSICALDESIGNRULE", "EDIF_TOK_PLUG", "EDIF_TOK_POINT", + "EDIF_TOK_POINTDISPLAY", "EDIF_TOK_POINTLIST", "EDIF_TOK_POLYGON", + "EDIF_TOK_PORT", "EDIF_TOK_PORTBACKANNOTATE", "EDIF_TOK_PORTBUNDLE", + "EDIF_TOK_PORTDELAY", "EDIF_TOK_PORTGROUP", + "EDIF_TOK_PORTIMPLEMENTATION", "EDIF_TOK_PORTINSTANCE", + "EDIF_TOK_PORTLIST", "EDIF_TOK_PORTLISTALIAS", "EDIF_TOK_PORTMAP", + "EDIF_TOK_PORTREF", "EDIF_TOK_PROGRAM", "EDIF_TOK_PROPERTY", + "EDIF_TOK_PROPERTYDISPLAY", "EDIF_TOK_PROTECTIONFRAME", "EDIF_TOK_PT", + "EDIF_TOK_RANGEVECTOR", "EDIF_TOK_RECTANGLE", "EDIF_TOK_RECTANGLESIZE", + "EDIF_TOK_RENAME", "EDIF_TOK_RESOLVES", "EDIF_TOK_SCALE", + "EDIF_TOK_SCALEX", "EDIF_TOK_SCALEY", "EDIF_TOK_SECTION", + "EDIF_TOK_SHAPE", "EDIF_TOK_SIMULATE", "EDIF_TOK_SIMULATIONINFO", + "EDIF_TOK_SINGLEVALUESET", "EDIF_TOK_SITE", "EDIF_TOK_SOCKET", + "EDIF_TOK_SOCKETSET", "EDIF_TOK_STATUS", "EDIF_TOK_STEADY", + "EDIF_TOK_STRING", "EDIF_TOK_STRINGDISPLAY", "EDIF_TOK_STRONG", + "EDIF_TOK_SYMBOL", "EDIF_TOK_SYMMETRY", "EDIF_TOK_TABLE", + "EDIF_TOK_TABLEDEFAULT", "EDIF_TOK_TECHNOLOGY", "EDIF_TOK_TEXTHEIGHT", + "EDIF_TOK_TIMEINTERVAL", "EDIF_TOK_TIMESTAMP", "EDIF_TOK_TIMING", + "EDIF_TOK_TRANSFORM", "EDIF_TOK_TRANSITION", "EDIF_TOK_TRIGGER", + "EDIF_TOK_TRUE", "EDIF_TOK_UNCONSTRAINED", "EDIF_TOK_UNDEFINED", + "EDIF_TOK_UNION", "EDIF_TOK_UNIT", "EDIF_TOK_UNUSED", + "EDIF_TOK_USERDATA", "EDIF_TOK_VERSION", "EDIF_TOK_VIEW", + "EDIF_TOK_VIEWLIST", "EDIF_TOK_VIEWMAP", "EDIF_TOK_VIEWREF", + "EDIF_TOK_VIEWTYPE", "EDIF_TOK_VISIBLE", "EDIF_TOK_VOLTAGEMAP", + "EDIF_TOK_WAVEVALUE", "EDIF_TOK_WEAK", "EDIF_TOK_WEAKJOINED", + "EDIF_TOK_WHEN", "EDIF_TOK_WRITTEN", "')'", "$accept", "PopC", "Edif", + "_Edif", "EdifFileName", "EdifLevel", "EdifVersion", "AcLoad", "_AcLoad", + "After", "_After", "Annotate", "_Annotate", "Apply", "_Apply", "Arc", + "Array", "_Array", "ArrayMacro", "ArrayRelInfo", "_ArrayRelInfo", + "ArraySite", "AtLeast", "AtMost", "Author", "BaseArray", "Becomes", + "_Becomes", "Between", "__Between", "_Between", "Boolean", "_Boolean", + "BooleanDisp", "_BooleanDisp", "BooleanMap", "BooleanValue", "BorderPat", + "BorderWidth", "BoundBox", "Cell", "_Cell", "CellNameDef", "CellRef", + "_CellRef", "CellNameRef", "CellType", "_CellType", "Change", "__Change", + "_Change", "Circle", "_Circle", "Color", "Comment", "_Comment", + "CommGraph", "_CommGraph", "Compound", "Contents", "_Contents", + "ConnectLoc", "_ConnectLoc", "CornerType", "_CornerType", "Criticality", + "_Criticality", "CurrentMap", "Curve", "_Curve", "Cycle", "_Cycle", + "DataOrigin", "_DataOrigin", "DcFanInLoad", "_DcFanInLoad", + "DcFanOutLoad", "_DcFanOutLoad", "DcMaxFanIn", "_DcMaxFanIn", + "DcMaxFanOut", "_DcMaxFanOut", "Delay", "_Delay", "Delta", "_Delta", + "Derivation", "_Derivation", "Design", "_Design", "Designator", + "_Designator", "DesignNameDef", "DesignRule", "_DesignRule", + "Difference", "_Difference", "Direction", "_Direction", "Display", + "_Display", "_DisplayJust", "_DisplayOrien", "_DisplayOrg", "Dominates", + "_Dominates", "Dot", "_Dot", "Duration", "EncloseDist", "_EncloseDist", + "EndType", "_EndType", "Entry", "___Entry", "__Entry", "_Entry", "Event", + "_Event", "Exactly", "External", "_External", "Fabricate", "False", + "FigGrp", "_FigGrp", "FigGrpNameDef", "FigGrpNameRef", "FigGrpObj", + "_FigGrpObj", "FigGrpOver", "_FigGrpOver", "FigGrpRef", "_FigGrpRef", + "Figure", "_Figure", "FigureArea", "_FigureArea", "FigureOp", + "FigurePerim", "_FigurePerim", "FigureWidth", "_FigureWidth", + "FillPattern", "Follow", "__Follow", "_Follow", "Forbidden", + "_Forbidden", "Form", "_Form", "GlobPortRef", "GreaterThan", "GridMap", + "Ignore", "IncFigGrp", "_IncFigGrp", "Initial", "Instance", "_Instance", + "InstanceRef", "_InstanceRef", "InstBackAn", "_InstBackAn", "InstGroup", + "_InstGroup", "InstMap", "_InstMap", "InstNameDef", "InstNameRef", + "IntDisplay", "_IntDisplay", "Integer", "_Integer", "Interface", + "_Interface", "InterFigGrp", "_InterFigGrp", "Intersection", + "_Intersection", "IntraFigGrp", "_IntraFigGrp", "Inverse", "_Inverse", + "Isolated", "Joined", "_Joined", "Justify", "_Justify", "KeywordDisp", + "_KeywordDisp", "KeywordLevel", "KeywordMap", "_KeywordMap", + "KeywordName", "LayerNameDef", "LessThan", "LibNameDef", "LibNameRef", + "Library", "_Library", "LibraryRef", "ListOfNets", "_ListOfNets", + "ListOfPorts", "_ListOfPorts", "LoadDelay", "_LoadDelay", "LogicAssn", + "___LogicAssn", "__LogicAssn", "_LogicAssn", "LogicIn", "_LogicIn", + "LogicList", "_LogicList", "LogicMapIn", "_LogicMapIn", "LogicMapOut", + "_LogicMapOut", "LogicNameDef", "LogicNameRef", "LogicOneOf", + "_LogicOneOf", "LogicOut", "_LogicOut", "LogicPort", "_LogicPort", + "LogicRef", "_LogicRef", "LogicValue", "_LogicValue", "LogicWave", + "_LogicWave", "Maintain", "__Maintain", "_Maintain", "Match", "__Match", + "_Match", "Member", "_Member", "MiNoMa", "_MiNoMa", "MiNoMaDisp", + "_MiNoMaDisp", "MiNoMaValue", "Mnm", "_Mnm", "MultValSet", "_MultValSet", + "MustJoin", "_MustJoin", "Name", "_Name", "NameDef", "NameRef", "Net", + "_Net", "NetBackAn", "_NetBackAn", "NetBundle", "_NetBundle", "NetDelay", + "_NetDelay", "NetGroup", "_NetGroup", "NetMap", "_NetMap", "NetNameDef", + "NetNameRef", "NetRef", "_NetRef", "NoChange", "NonPermut", "_NonPermut", + "NotAllowed", "_NotAllowed", "NotchSpace", "_NotchSpace", "Number", + "_Number", "NumbDisplay", "_NumbDisplay", "NumberDefn", "_NumberDefn", + "OffPageConn", "_OffPageConn", "OffsetEvent", "OpenShape", "_OpenShape", + "Orientation", "_Orientation", "Origin", "OverhngDist", "_OverhngDist", + "OverlapDist", "_OverlapDist", "Oversize", "_Oversize", "Owner", "Page", + "_Page", "PageSize", "ParamDisp", "_ParamDisp", "Parameter", + "_Parameter", "ParamAssign", "Path", "_Path", "PathDelay", "_PathDelay", + "PathWidth", "Permutable", "_Permutable", "Plug", "_Plug", "Point", + "_Point", "PointDisp", "_PointDisp", "PointList", "_PointList", + "PointValue", "Polygon", "_Polygon", "Port", "_Port", "PortBackAn", + "_PortBackAn", "PortBundle", "_PortBundle", "PortDelay", "_PortDelay", + "PortGroup", "_PortGroup", "PortImpl", "_PortImpl", "PortInst", + "_PortInst", "PortList", "_PortList", "PortListAls", "PortMap", + "_PortMap", "PortNameDef", "PortNameRef", "PortRef", "_PortRef", + "Program", "_Program", "PropDisplay", "_PropDisplay", "Property", + "_Property", "PropNameDef", "PropNameRef", "ProtectFrame", + "_ProtectFrame", "Range", "RangeVector", "_RangeVector", "Rectangle", + "_Rectangle", "RectSize", "_RectSize", "Rename", "__Rename", "_Rename", + "Resolves", "_Resolves", "RuleNameDef", "Scale", "ScaledInt", "ScaleX", + "ScaleY", "Section", "_Section", "Shape", "_Shape", "SimNameDef", + "Simulate", "_Simulate", "SimulInfo", "_SimulInfo", "SingleValSet", + "_SingleValSet", "Site", "_Site", "Socket", "_Socket", "SocketSet", + "_SocketSet", "Status", "_Status", "Steady", "__Steady", "_Steady", + "StrDisplay", "String", "_String", "_StrDisplay", "Strong", "Symbol", + "_Symbol", "Symmetry", "_Symmetry", "Table", "_Table", "TableDeflt", + "__TableDeflt", "_TableDeflt", "Technology", "_Technology", "TextHeight", + "TimeIntval", "__TimeIntval", "_TimeIntval", "TimeStamp", "Timing", + "_Timing", "Transform", "_TransX", "_TransY", "_TransDelta", + "_TransOrien", "_TransOrg", "Transition", "_Transition", "Trigger", + "_Trigger", "True", "TypedValue", "Unconstrained", "Undefined", "Union", + "_Union", "Unit", "_Unit", "Unused", "UserData", "_UserData", + "ValueNameDef", "ValueNameRef", "Version", "View", "_View", "ViewList", + "_ViewList", "ViewMap", "_ViewMap", "ViewNameDef", "ViewNameRef", + "ViewRef", "_ViewRef", "ViewType", "_ViewType", "Visible", "VoltageMap", + "WaveValue", "Weak", "WeakJoined", "_WeakJoined", "When", "_When", + "Written", "_Written", "Ident", "Str", "Int", "Keyword", 0 }; #endif -# ifdef YYPRINT +#ifdef YYPRINT /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to token YYLEX-NUM. */ -static const yytype_uint16 yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, - 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, - 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, - 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, - 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, - 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, - 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, - 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, - 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, - 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, - 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, - 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, - 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, - 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, - 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, - 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, - 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, - 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, - 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, - 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, - 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, - 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, - 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, - 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, - 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, - 545, 546, 547, 548, 549, 41 +static const yytype_uint16 yytoknum[] = { + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, + 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, + 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, + 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, + 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, + 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, + 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, + 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, + 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, + 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, + 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, + 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, + 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, + 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, + 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, + 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, + 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, + 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, + 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, + 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, + 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, + 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, + 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, + 545, 546, 547, 548, 549, 41 }; -# endif +#endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint16 yyr1[] = -{ - 0, 296, 297, 298, 299, 299, 299, 299, 299, 299, - 299, 300, 301, 302, 303, 304, 304, 305, 306, 306, - 306, 306, 306, 306, 307, 308, 308, 309, 310, 310, - 310, 310, 310, 311, 312, 313, 313, 314, 315, 316, - 316, 316, 316, 316, 317, 318, 319, 320, 321, 322, - 323, 323, 323, 324, 325, 325, 326, 326, 327, 328, - 328, 328, 328, 329, 330, 330, 331, 332, 332, 333, - 334, 335, 336, 337, 337, 337, 337, 337, 337, 337, - 338, 339, 340, 340, 341, 342, 343, 343, 343, 344, - 345, 345, 345, 346, 346, 346, 347, 348, 348, 349, - 350, 351, 351, 352, 353, 353, 353, 353, 353, 353, - 353, 353, 354, 355, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 357, 358, 358, 359, 360, 360, 360, 361, - 362, 362, 363, 364, 365, 365, 365, 366, 367, 367, - 368, 369, 369, 370, 371, 371, 372, 373, 373, 374, - 375, 375, 376, 377, 377, 378, 379, 379, 380, 381, - 381, 382, 383, 383, 383, 384, 385, 385, 385, 385, - 385, 386, 387, 387, 388, 389, 390, 390, 390, 390, - 390, 390, 390, 390, 390, 390, 390, 390, 390, 390, - 390, 391, 392, 392, 392, 392, 393, 394, 394, 394, - 395, 396, 396, 397, 397, 398, 398, 399, 399, 400, - 401, 401, 402, 403, 403, 404, 405, 406, 406, 406, - 406, 407, 408, 408, 408, 409, 410, 410, 410, 411, - 411, 411, 411, 412, 412, 412, 413, 414, 414, 414, - 414, 414, 414, 414, 415, 416, 417, 417, 417, 417, - 417, 418, 419, 420, 421, 421, 421, 421, 421, 421, - 421, 421, 421, 421, 421, 421, 421, 421, 422, 423, - 424, 425, 425, 425, 426, 427, 427, 427, 427, 427, - 427, 427, 427, 427, 427, 427, 427, 427, 428, 429, - 429, 430, 431, 431, 431, 431, 431, 431, 431, 431, - 431, 431, 431, 432, 433, 433, 433, 433, 434, 434, - 434, 434, 434, 435, 436, 436, 436, 436, 437, 438, - 438, 438, 438, 439, 440, 441, 441, 442, 442, 442, - 442, 443, 444, 444, 445, 446, 446, 446, 446, 446, - 447, 448, 449, 450, 451, 452, 452, 453, 454, 455, - 455, 455, 455, 455, 455, 455, 455, 455, 455, 456, - 457, 457, 457, 458, 459, 459, 459, 459, 459, 460, - 461, 461, 462, 463, 463, 463, 463, 463, 464, 464, - 465, 465, 466, 467, 467, 468, 469, 469, 469, 469, - 470, 471, 471, 471, 471, 471, 471, 471, 471, 471, - 471, 471, 471, 471, 471, 471, 471, 471, 472, 473, - 473, 473, 473, 474, 475, 475, 475, 475, 476, 477, - 477, 477, 477, 478, 479, 479, 480, 481, 482, 482, - 482, 482, 483, 484, 484, 484, 484, 484, 484, 484, - 484, 484, 485, 486, 486, 487, 488, 489, 489, 490, - 491, 492, 493, 494, 495, 496, 496, 496, 496, 496, - 497, 498, 499, 499, 500, 501, 501, 501, 502, 503, - 503, 504, 505, 505, 506, 506, 506, 507, 507, 507, - 508, 509, 509, 509, 509, 510, 511, 511, 511, 511, - 512, 513, 513, 514, 515, 515, 516, 517, 518, 519, - 519, 519, 520, 521, 521, 521, 521, 522, 523, 523, - 523, 523, 524, 525, 525, 526, 527, 527, 527, 527, - 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, - 527, 528, 529, 529, 529, 529, 529, 530, 531, 531, - 532, 532, 532, 533, 534, 534, 534, 535, 535, 535, - 536, 537, 537, 538, 539, 539, 539, 539, 540, 541, - 541, 542, 542, 543, 544, 544, 544, 545, 546, 546, - 547, 548, 548, 548, 548, 548, 549, 550, 550, 551, - 551, 551, 552, 552, 553, 554, 554, 554, 554, 554, - 554, 554, 554, 554, 554, 555, 556, 556, 556, 556, - 556, 557, 558, 558, 558, 558, 558, 558, 559, 560, - 560, 560, 561, 562, 562, 562, 563, 564, 564, 564, - 564, 564, 565, 565, 566, 566, 567, 568, 568, 568, - 568, 569, 570, 571, 571, 571, 572, 573, 573, 573, - 574, 575, 575, 575, 575, 576, 577, 577, 577, 577, - 578, 579, 579, 580, 581, 581, 581, 581, 582, 583, - 583, 583, 583, 583, 584, 585, 586, 586, 587, 588, - 588, 588, 588, 588, 588, 588, 588, 589, 590, 591, - 591, 591, 591, 592, 593, 593, 593, 593, 594, 595, - 595, 596, 597, 598, 598, 598, 598, 598, 598, 598, - 598, 598, 598, 599, 600, 601, 601, 602, 603, 603, - 604, 605, 606, 606, 607, 608, 608, 609, 610, 611, - 611, 611, 611, 612, 613, 613, 614, 615, 615, 615, - 615, 616, 617, 617, 618, 619, 619, 620, 621, 622, - 622, 623, 624, 624, 624, 624, 624, 624, 624, 624, - 624, 624, 624, 624, 624, 625, 626, 626, 626, 626, - 626, 626, 626, 626, 626, 626, 627, 628, 628, 628, - 628, 629, 630, 630, 630, 630, 631, 632, 632, 632, - 633, 634, 634, 634, 634, 634, 634, 634, 634, 634, - 634, 634, 635, 636, 636, 636, 636, 636, 636, 636, - 636, 636, 636, 636, 636, 636, 637, 638, 638, 638, - 639, 640, 641, 641, 641, 641, 641, 642, 642, 643, - 643, 644, 645, 645, 645, 645, 646, 647, 647, 648, - 649, 649, 650, 651, 651, 651, 651, 651, 652, 653, - 654, 655, 655, 655, 655, 655, 655, 655, 655, 655, - 655, 655, 655, 656, 656, 656, 656, 656, 656, 657, - 658, 658, 658, 659, 660, 660, 661, 662, 662, 662, - 662, 663, 664, 664, 665, 665, 666, 667, 667, 668, - 669, 670, 670, 671, 672, 673, 674, 674, 674, 674, - 675, 676, 676, 677, 678, 679, 679, 679, 679, 679, - 679, 680, 681, 681, 681, 681, 682, 683, 683, 684, - 685, 685, 686, 687, 687, 688, 689, 689, 690, 691, - 691, 691, 691, 692, 693, 693, 693, 694, 694, 694, - 695, 696, 697, 697, 697, 697, 698, 698, 699, 700, - 701, 701, 701, 701, 701, 701, 701, 701, 701, 701, - 701, 701, 701, 701, 702, 703, 703, 704, 705, 705, - 705, 706, 707, 707, 707, 707, 708, 708, 708, 709, - 710, 710, 710, 710, 710, 710, 710, 711, 712, 713, - 713, 714, 714, 714, 715, 716, 717, 717, 717, 717, - 717, 718, 719, 719, 720, 720, 721, 721, 722, 722, - 723, 723, 724, 725, 725, 725, 726, 727, 727, 727, - 727, 728, 729, 729, 729, 729, 729, 729, 730, 731, - 732, 733, 733, 733, 733, 734, 735, 735, 735, 735, - 735, 735, 735, 735, 735, 735, 735, 735, 735, 735, - 735, 735, 736, 737, 738, 738, 738, 738, 738, 739, - 739, 740, 740, 741, 742, 743, 743, 743, 743, 743, - 743, 744, 745, 745, 745, 746, 747, 747, 747, 747, - 747, 747, 747, 747, 747, 748, 749, 750, 751, 751, - 752, 753, 753, 753, 753, 753, 753, 753, 753, 753, - 753, 754, 755, 756, 757, 758, 759, 759, 759, 759, - 760, 761, 761, 761, 761, 761, 761, 761, 762, 763, - 763, 763, 763, 763, 763, 763, 764, 765, 766, 767 +static const yytype_uint16 yyr1[] = { + 0, 296, 297, 298, 299, 299, 299, 299, 299, 299, + 299, 300, 301, 302, 303, 304, 304, 305, 306, 306, + 306, 306, 306, 306, 307, 308, 308, 309, 310, 310, + 310, 310, 310, 311, 312, 313, 313, 314, 315, 316, + 316, 316, 316, 316, 317, 318, 319, 320, 321, 322, + 323, 323, 323, 324, 325, 325, 326, 326, 327, 328, + 328, 328, 328, 329, 330, 330, 331, 332, 332, 333, + 334, 335, 336, 337, 337, 337, 337, 337, 337, 337, + 338, 339, 340, 340, 341, 342, 343, 343, 343, 344, + 345, 345, 345, 346, 346, 346, 347, 348, 348, 349, + 350, 351, 351, 352, 353, 353, 353, 353, 353, 353, + 353, 353, 354, 355, 356, 356, 356, 356, 356, 356, + 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, + 356, 356, 357, 358, 358, 359, 360, 360, 360, 361, + 362, 362, 363, 364, 365, 365, 365, 366, 367, 367, + 368, 369, 369, 370, 371, 371, 372, 373, 373, 374, + 375, 375, 376, 377, 377, 378, 379, 379, 380, 381, + 381, 382, 383, 383, 383, 384, 385, 385, 385, 385, + 385, 386, 387, 387, 388, 389, 390, 390, 390, 390, + 390, 390, 390, 390, 390, 390, 390, 390, 390, 390, + 390, 391, 392, 392, 392, 392, 393, 394, 394, 394, + 395, 396, 396, 397, 397, 398, 398, 399, 399, 400, + 401, 401, 402, 403, 403, 404, 405, 406, 406, 406, + 406, 407, 408, 408, 408, 409, 410, 410, 410, 411, + 411, 411, 411, 412, 412, 412, 413, 414, 414, 414, + 414, 414, 414, 414, 415, 416, 417, 417, 417, 417, + 417, 418, 419, 420, 421, 421, 421, 421, 421, 421, + 421, 421, 421, 421, 421, 421, 421, 421, 422, 423, + 424, 425, 425, 425, 426, 427, 427, 427, 427, 427, + 427, 427, 427, 427, 427, 427, 427, 427, 428, 429, + 429, 430, 431, 431, 431, 431, 431, 431, 431, 431, + 431, 431, 431, 432, 433, 433, 433, 433, 434, 434, + 434, 434, 434, 435, 436, 436, 436, 436, 437, 438, + 438, 438, 438, 439, 440, 441, 441, 442, 442, 442, + 442, 443, 444, 444, 445, 446, 446, 446, 446, 446, + 447, 448, 449, 450, 451, 452, 452, 453, 454, 455, + 455, 455, 455, 455, 455, 455, 455, 455, 455, 456, + 457, 457, 457, 458, 459, 459, 459, 459, 459, 460, + 461, 461, 462, 463, 463, 463, 463, 463, 464, 464, + 465, 465, 466, 467, 467, 468, 469, 469, 469, 469, + 470, 471, 471, 471, 471, 471, 471, 471, 471, 471, + 471, 471, 471, 471, 471, 471, 471, 471, 472, 473, + 473, 473, 473, 474, 475, 475, 475, 475, 476, 477, + 477, 477, 477, 478, 479, 479, 480, 481, 482, 482, + 482, 482, 483, 484, 484, 484, 484, 484, 484, 484, + 484, 484, 485, 486, 486, 487, 488, 489, 489, 490, + 491, 492, 493, 494, 495, 496, 496, 496, 496, 496, + 497, 498, 499, 499, 500, 501, 501, 501, 502, 503, + 503, 504, 505, 505, 506, 506, 506, 507, 507, 507, + 508, 509, 509, 509, 509, 510, 511, 511, 511, 511, + 512, 513, 513, 514, 515, 515, 516, 517, 518, 519, + 519, 519, 520, 521, 521, 521, 521, 522, 523, 523, + 523, 523, 524, 525, 525, 526, 527, 527, 527, 527, + 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, + 527, 528, 529, 529, 529, 529, 529, 530, 531, 531, + 532, 532, 532, 533, 534, 534, 534, 535, 535, 535, + 536, 537, 537, 538, 539, 539, 539, 539, 540, 541, + 541, 542, 542, 543, 544, 544, 544, 545, 546, 546, + 547, 548, 548, 548, 548, 548, 549, 550, 550, 551, + 551, 551, 552, 552, 553, 554, 554, 554, 554, 554, + 554, 554, 554, 554, 554, 555, 556, 556, 556, 556, + 556, 557, 558, 558, 558, 558, 558, 558, 559, 560, + 560, 560, 561, 562, 562, 562, 563, 564, 564, 564, + 564, 564, 565, 565, 566, 566, 567, 568, 568, 568, + 568, 569, 570, 571, 571, 571, 572, 573, 573, 573, + 574, 575, 575, 575, 575, 576, 577, 577, 577, 577, + 578, 579, 579, 580, 581, 581, 581, 581, 582, 583, + 583, 583, 583, 583, 584, 585, 586, 586, 587, 588, + 588, 588, 588, 588, 588, 588, 588, 589, 590, 591, + 591, 591, 591, 592, 593, 593, 593, 593, 594, 595, + 595, 596, 597, 598, 598, 598, 598, 598, 598, 598, + 598, 598, 598, 599, 600, 601, 601, 602, 603, 603, + 604, 605, 606, 606, 607, 608, 608, 609, 610, 611, + 611, 611, 611, 612, 613, 613, 614, 615, 615, 615, + 615, 616, 617, 617, 618, 619, 619, 620, 621, 622, + 622, 623, 624, 624, 624, 624, 624, 624, 624, 624, + 624, 624, 624, 624, 624, 625, 626, 626, 626, 626, + 626, 626, 626, 626, 626, 626, 627, 628, 628, 628, + 628, 629, 630, 630, 630, 630, 631, 632, 632, 632, + 633, 634, 634, 634, 634, 634, 634, 634, 634, 634, + 634, 634, 635, 636, 636, 636, 636, 636, 636, 636, + 636, 636, 636, 636, 636, 636, 637, 638, 638, 638, + 639, 640, 641, 641, 641, 641, 641, 642, 642, 643, + 643, 644, 645, 645, 645, 645, 646, 647, 647, 648, + 649, 649, 650, 651, 651, 651, 651, 651, 652, 653, + 654, 655, 655, 655, 655, 655, 655, 655, 655, 655, + 655, 655, 655, 656, 656, 656, 656, 656, 656, 657, + 658, 658, 658, 659, 660, 660, 661, 662, 662, 662, + 662, 663, 664, 664, 665, 665, 666, 667, 667, 668, + 669, 670, 670, 671, 672, 673, 674, 674, 674, 674, + 675, 676, 676, 677, 678, 679, 679, 679, 679, 679, + 679, 680, 681, 681, 681, 681, 682, 683, 683, 684, + 685, 685, 686, 687, 687, 688, 689, 689, 690, 691, + 691, 691, 691, 692, 693, 693, 693, 694, 694, 694, + 695, 696, 697, 697, 697, 697, 698, 698, 699, 700, + 701, 701, 701, 701, 701, 701, 701, 701, 701, 701, + 701, 701, 701, 701, 702, 703, 703, 704, 705, 705, + 705, 706, 707, 707, 707, 707, 708, 708, 708, 709, + 710, 710, 710, 710, 710, 710, 710, 711, 712, 713, + 713, 714, 714, 714, 715, 716, 717, 717, 717, 717, + 717, 718, 719, 719, 720, 720, 721, 721, 722, 722, + 723, 723, 724, 725, 725, 725, 726, 727, 727, 727, + 727, 728, 729, 729, 729, 729, 729, 729, 730, 731, + 732, 733, 733, 733, 733, 734, 735, 735, 735, 735, + 735, 735, 735, 735, 735, 735, 735, 735, 735, 735, + 735, 735, 736, 737, 738, 738, 738, 738, 738, 739, + 739, 740, 740, 741, 742, 743, 743, 743, 743, 743, + 743, 744, 745, 745, 745, 746, 747, 747, 747, 747, + 747, 747, 747, 747, 747, 748, 749, 750, 751, 751, + 752, 753, 753, 753, 753, 753, 753, 753, 753, 753, + 753, 754, 755, 756, 757, 758, 759, 759, 759, 759, + 760, 761, 761, 761, 761, 761, 761, 761, 762, 763, + 763, 763, 763, 763, 763, 763, 764, 765, 766, 767 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = -{ - 0, 2, 1, 7, 0, 2, 2, 2, 2, 2, - 2, 1, 3, 5, 3, 1, 1, 3, 1, 2, - 2, 2, 2, 2, 3, 1, 1, 3, 1, 2, - 2, 2, 2, 5, 5, 0, 1, 3, 3, 1, - 1, 1, 2, 2, 3, 3, 3, 3, 2, 3, - 1, 1, 1, 4, 1, 1, 1, 1, 3, 0, - 2, 2, 2, 3, 1, 2, 3, 1, 1, 5, - 3, 3, 4, 1, 2, 2, 2, 2, 2, 2, - 1, 4, 0, 1, 1, 3, 1, 1, 1, 4, - 1, 1, 1, 0, 1, 1, 5, 0, 2, 5, - 3, 0, 2, 3, 0, 2, 2, 2, 2, 2, - 2, 2, 3, 3, 0, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 3, 0, 1, 3, 1, 1, 1, 3, - 1, 1, 3, 3, 0, 2, 2, 4, 0, 1, - 4, 0, 1, 3, 1, 1, 3, 1, 1, 3, - 1, 1, 3, 1, 1, 3, 1, 1, 3, 0, - 2, 3, 1, 1, 1, 4, 1, 2, 2, 2, - 2, 3, 1, 1, 1, 3, 0, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 3, 1, 1, 2, 2, 3, 1, 1, 1, - 6, 1, 1, 0, 1, 0, 1, 0, 1, 3, - 0, 2, 3, 1, 2, 3, 6, 1, 1, 2, - 2, 3, 1, 1, 1, 5, 1, 1, 1, 1, - 1, 1, 1, 0, 1, 1, 3, 1, 1, 1, - 1, 1, 2, 2, 3, 5, 1, 2, 2, 2, - 2, 4, 2, 3, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, - 3, 1, 1, 1, 3, 1, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 4, 0, - 1, 3, 1, 1, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 5, 1, 1, 2, 2, 1, 1, - 1, 1, 1, 5, 1, 1, 2, 2, 5, 1, - 1, 2, 2, 5, 4, 1, 1, 1, 1, 2, - 2, 3, 1, 2, 3, 0, 2, 2, 2, 2, - 3, 3, 4, 2, 3, 1, 1, 2, 4, 1, - 1, 2, 2, 2, 2, 2, 2, 2, 2, 4, - 0, 1, 1, 3, 1, 2, 2, 2, 2, 3, - 0, 2, 3, 0, 2, 2, 2, 2, 1, 1, - 1, 1, 3, 1, 2, 3, 0, 2, 2, 2, - 3, 0, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 6, 1, - 1, 2, 2, 3, 1, 1, 2, 2, 5, 1, - 1, 2, 2, 3, 1, 1, 2, 3, 0, 2, - 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 3, 1, 2, 3, 3, 1, 2, 1, - 1, 3, 1, 1, 5, 1, 2, 2, 2, 2, - 3, 3, 0, 2, 3, 0, 2, 2, 4, 1, - 1, 5, 1, 1, 1, 1, 1, 0, 1, 1, - 3, 1, 1, 1, 2, 3, 0, 2, 2, 2, - 3, 0, 2, 3, 0, 2, 1, 1, 3, 0, - 2, 2, 3, 1, 1, 1, 2, 3, 1, 2, - 2, 2, 4, 0, 1, 3, 1, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 3, 0, 2, 2, 2, 2, 4, 1, 1, - 0, 1, 1, 4, 1, 1, 1, 1, 1, 1, - 4, 1, 2, 3, 0, 2, 2, 2, 3, 1, - 2, 1, 1, 5, 1, 1, 1, 3, 0, 2, - 3, 0, 2, 2, 2, 2, 3, 1, 2, 1, - 1, 1, 1, 1, 4, 1, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 3, 1, 2, 2, 2, - 2, 4, 1, 2, 2, 2, 2, 2, 4, 1, - 2, 2, 3, 0, 2, 2, 3, 0, 2, 2, - 2, 2, 1, 1, 1, 1, 4, 0, 1, 1, - 1, 2, 3, 0, 2, 2, 4, 1, 2, 2, - 5, 1, 1, 2, 2, 3, 0, 2, 2, 2, - 3, 1, 2, 3, 0, 2, 2, 2, 3, 1, - 2, 2, 2, 2, 4, 3, 1, 2, 3, 1, - 1, 1, 1, 1, 1, 1, 1, 3, 6, 1, - 1, 2, 2, 6, 1, 1, 2, 2, 5, 1, - 1, 3, 3, 1, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 3, 3, 1, 2, 5, 0, 1, - 4, 3, 1, 2, 3, 1, 2, 3, 3, 0, - 2, 2, 2, 3, 0, 2, 3, 0, 2, 2, - 2, 3, 1, 2, 3, 0, 2, 4, 3, 1, - 2, 3, 1, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 3, 1, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 4, 1, 2, 2, - 2, 4, 1, 1, 2, 2, 3, 0, 2, 2, - 3, 1, 1, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 3, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 0, 2, 2, - 4, 3, 0, 2, 2, 2, 2, 1, 1, 1, - 1, 4, 0, 1, 1, 1, 4, 0, 1, 3, - 1, 2, 4, 1, 2, 2, 2, 2, 1, 1, - 3, 0, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 1, 1, 1, 1, 1, 1, 3, - 0, 2, 2, 4, 1, 2, 5, 1, 1, 2, - 2, 4, 1, 1, 1, 1, 3, 0, 2, 1, - 5, 1, 4, 4, 4, 3, 1, 2, 2, 2, - 3, 1, 2, 1, 3, 1, 2, 2, 2, 2, - 2, 3, 0, 2, 2, 2, 3, 0, 1, 4, - 0, 1, 3, 0, 1, 3, 1, 2, 3, 0, - 2, 2, 2, 4, 1, 1, 1, 1, 2, 2, - 3, 3, 0, 2, 2, 2, 1, 2, 3, 3, - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 3, 0, 2, 3, 0, 2, - 2, 4, 1, 1, 1, 1, 0, 1, 1, 3, - 1, 2, 2, 2, 2, 2, 2, 3, 4, 1, - 1, 1, 1, 1, 8, 3, 1, 2, 2, 2, - 2, 7, 0, 1, 0, 1, 0, 1, 0, 1, - 0, 1, 4, 1, 1, 1, 3, 0, 2, 2, - 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, - 3, 1, 1, 2, 2, 3, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 2, 3, 1, 2, 2, 2, 2, 1, - 1, 1, 1, 3, 5, 1, 2, 2, 2, 2, - 2, 3, 0, 2, 2, 3, 0, 2, 2, 2, - 2, 2, 2, 2, 2, 1, 1, 4, 0, 1, - 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 3, 3, 5, 3, 3, 0, 2, 2, 2, - 3, 1, 2, 2, 2, 2, 2, 2, 3, 1, - 2, 2, 2, 2, 2, 2, 1, 1, 1, 1 +static const yytype_uint8 yyr2[] = { + 0, 2, 1, 7, 0, 2, 2, 2, 2, 2, + 2, 1, 3, 5, 3, 1, 1, 3, 1, 2, + 2, 2, 2, 2, 3, 1, 1, 3, 1, 2, + 2, 2, 2, 5, 5, 0, 1, 3, 3, 1, + 1, 1, 2, 2, 3, 3, 3, 3, 2, 3, + 1, 1, 1, 4, 1, 1, 1, 1, 3, 0, + 2, 2, 2, 3, 1, 2, 3, 1, 1, 5, + 3, 3, 4, 1, 2, 2, 2, 2, 2, 2, + 1, 4, 0, 1, 1, 3, 1, 1, 1, 4, + 1, 1, 1, 0, 1, 1, 5, 0, 2, 5, + 3, 0, 2, 3, 0, 2, 2, 2, 2, 2, + 2, 2, 3, 3, 0, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 3, 0, 1, 3, 1, 1, 1, 3, + 1, 1, 3, 3, 0, 2, 2, 4, 0, 1, + 4, 0, 1, 3, 1, 1, 3, 1, 1, 3, + 1, 1, 3, 1, 1, 3, 1, 1, 3, 0, + 2, 3, 1, 1, 1, 4, 1, 2, 2, 2, + 2, 3, 1, 1, 1, 3, 0, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 3, 1, 1, 2, 2, 3, 1, 1, 1, + 6, 1, 1, 0, 1, 0, 1, 0, 1, 3, + 0, 2, 3, 1, 2, 3, 6, 1, 1, 2, + 2, 3, 1, 1, 1, 5, 1, 1, 1, 1, + 1, 1, 1, 0, 1, 1, 3, 1, 1, 1, + 1, 1, 2, 2, 3, 5, 1, 2, 2, 2, + 2, 4, 2, 3, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, + 3, 1, 1, 1, 3, 1, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 4, 0, + 1, 3, 1, 1, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 5, 1, 1, 2, 2, 1, 1, + 1, 1, 1, 5, 1, 1, 2, 2, 5, 1, + 1, 2, 2, 5, 4, 1, 1, 1, 1, 2, + 2, 3, 1, 2, 3, 0, 2, 2, 2, 2, + 3, 3, 4, 2, 3, 1, 1, 2, 4, 1, + 1, 2, 2, 2, 2, 2, 2, 2, 2, 4, + 0, 1, 1, 3, 1, 2, 2, 2, 2, 3, + 0, 2, 3, 0, 2, 2, 2, 2, 1, 1, + 1, 1, 3, 1, 2, 3, 0, 2, 2, 2, + 3, 0, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 6, 1, + 1, 2, 2, 3, 1, 1, 2, 2, 5, 1, + 1, 2, 2, 3, 1, 1, 2, 3, 0, 2, + 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 3, 1, 2, 3, 3, 1, 2, 1, + 1, 3, 1, 1, 5, 1, 2, 2, 2, 2, + 3, 3, 0, 2, 3, 0, 2, 2, 4, 1, + 1, 5, 1, 1, 1, 1, 1, 0, 1, 1, + 3, 1, 1, 1, 2, 3, 0, 2, 2, 2, + 3, 0, 2, 3, 0, 2, 1, 1, 3, 0, + 2, 2, 3, 1, 1, 1, 2, 3, 1, 2, + 2, 2, 4, 0, 1, 3, 1, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 3, 0, 2, 2, 2, 2, 4, 1, 1, + 0, 1, 1, 4, 1, 1, 1, 1, 1, 1, + 4, 1, 2, 3, 0, 2, 2, 2, 3, 1, + 2, 1, 1, 5, 1, 1, 1, 3, 0, 2, + 3, 0, 2, 2, 2, 2, 3, 1, 2, 1, + 1, 1, 1, 1, 4, 1, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 3, 1, 2, 2, 2, + 2, 4, 1, 2, 2, 2, 2, 2, 4, 1, + 2, 2, 3, 0, 2, 2, 3, 0, 2, 2, + 2, 2, 1, 1, 1, 1, 4, 0, 1, 1, + 1, 2, 3, 0, 2, 2, 4, 1, 2, 2, + 5, 1, 1, 2, 2, 3, 0, 2, 2, 2, + 3, 1, 2, 3, 0, 2, 2, 2, 3, 1, + 2, 2, 2, 2, 4, 3, 1, 2, 3, 1, + 1, 1, 1, 1, 1, 1, 1, 3, 6, 1, + 1, 2, 2, 6, 1, 1, 2, 2, 5, 1, + 1, 3, 3, 1, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 3, 3, 1, 2, 5, 0, 1, + 4, 3, 1, 2, 3, 1, 2, 3, 3, 0, + 2, 2, 2, 3, 0, 2, 3, 0, 2, 2, + 2, 3, 1, 2, 3, 0, 2, 4, 3, 1, + 2, 3, 1, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 3, 1, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 4, 1, 2, 2, + 2, 4, 1, 1, 2, 2, 3, 0, 2, 2, + 3, 1, 1, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 3, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 0, 2, 2, + 4, 3, 0, 2, 2, 2, 2, 1, 1, 1, + 1, 4, 0, 1, 1, 1, 4, 0, 1, 3, + 1, 2, 4, 1, 2, 2, 2, 2, 1, 1, + 3, 0, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 1, 1, 1, 1, 1, 1, 3, + 0, 2, 2, 4, 1, 2, 5, 1, 1, 2, + 2, 4, 1, 1, 1, 1, 3, 0, 2, 1, + 5, 1, 4, 4, 4, 3, 1, 2, 2, 2, + 3, 1, 2, 1, 3, 1, 2, 2, 2, 2, + 2, 3, 0, 2, 2, 2, 3, 0, 1, 4, + 0, 1, 3, 0, 1, 3, 1, 2, 3, 0, + 2, 2, 2, 4, 1, 1, 1, 1, 2, 2, + 3, 3, 0, 2, 2, 2, 1, 2, 3, 3, + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 3, 0, 2, 3, 0, 2, + 2, 4, 1, 1, 1, 1, 0, 1, 1, 3, + 1, 2, 2, 2, 2, 2, 2, 3, 4, 1, + 1, 1, 1, 1, 8, 3, 1, 2, 2, 2, + 2, 7, 0, 1, 0, 1, 0, 1, 0, 1, + 0, 1, 4, 1, 1, 1, 3, 0, 2, 2, + 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, + 3, 1, 1, 2, 2, 3, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 2, 3, 1, 2, 2, 2, 2, 1, + 1, 1, 1, 3, 5, 1, 2, 2, 2, 2, + 2, 3, 0, 2, 2, 3, 0, 2, 2, 2, + 2, 2, 2, 2, 2, 1, 1, 4, 0, 1, + 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 3, 3, 5, 3, 3, 0, 2, 2, 2, + 3, 1, 2, 2, 2, 2, 2, 2, 3, 1, + 2, 2, 2, 2, 2, 2, 1, 1, 1, 1 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state STATE-NUM when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ -static const yytype_uint16 yydefact[] = -{ - 0, 0, 0, 1126, 0, 0, 0, 590, 11, 591, - 589, 1, 0, 587, 883, 0, 882, 0, 0, 0, - 2, 586, 588, 1127, 0, 0, 885, 884, 1128, 0, - 0, 0, 0, 213, 211, 212, 593, 279, 592, 0, - 946, 881, 0, 0, 0, 4, 285, 0, 0, 215, - 214, 940, 947, 0, 12, 0, 457, 0, 0, 0, - 0, 0, 101, 0, 0, 0, 0, 0, 0, 0, - 0, 284, 292, 289, 290, 295, 286, 287, 291, 288, - 296, 293, 297, 294, 443, 444, 445, 446, 447, 448, - 449, 450, 451, 0, 0, 217, 216, 13, 0, 456, - 458, 0, 0, 0, 929, 3, 9, 8, 6, 7, - 5, 10, 0, 0, 0, 0, 891, 0, 136, 137, - 138, 0, 232, 233, 234, 0, 0, 0, 848, 0, - 0, 0, 1054, 0, 0, 0, 68, 67, 442, 683, - 686, 684, 685, 679, 681, 682, 680, 0, 0, 0, - 218, 455, 0, 184, 0, 462, 0, 0, 0, 70, - 0, 0, 100, 102, 135, 231, 0, 727, 59, 396, - 564, 656, 737, 942, 1022, 1023, 1024, 1025, 1026, 0, - 1027, 843, 987, 1129, 1053, 1058, 1057, 1056, 1055, 345, - 262, 1021, 1101, 678, 0, 0, 210, 0, 176, 0, - 0, 0, 0, 928, 931, 932, 930, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 842, - 847, 844, 846, 845, 0, 0, 687, 82, 84, 175, - 178, 179, 177, 180, 0, 0, 256, 0, 465, 0, - 1119, 0, 69, 892, 99, 333, 0, 58, 62, 61, - 60, 0, 395, 398, 399, 397, 0, 0, 563, 567, - 566, 565, 571, 572, 0, 655, 659, 658, 657, 0, - 736, 740, 739, 738, 941, 944, 945, 943, 0, 1051, - 1037, 1048, 1049, 1038, 1036, 1046, 1050, 1044, 1045, 1043, - 1047, 1039, 1040, 1041, 1042, 0, 344, 349, 348, 347, - 346, 0, 0, 0, 83, 664, 980, 0, 0, 255, - 258, 259, 257, 260, 464, 467, 468, 466, 469, 0, - 0, 0, 0, 1118, 1120, 1124, 1122, 1121, 1123, 1125, - 0, 64, 0, 393, 0, 569, 0, 0, 0, 574, - 576, 575, 0, 661, 0, 742, 701, 1035, 747, 0, - 463, 81, 0, 0, 0, 186, 912, 979, 985, 984, - 982, 981, 983, 986, 0, 80, 0, 0, 151, 837, - 63, 65, 392, 394, 568, 570, 1028, 1029, 0, 660, - 662, 741, 743, 470, 0, 0, 663, 667, 666, 665, - 0, 460, 0, 264, 278, 0, 0, 0, 0, 73, - 0, 47, 0, 0, 152, 0, 838, 0, 0, 0, - 0, 0, 263, 271, 268, 269, 274, 265, 266, 270, - 277, 267, 275, 272, 276, 273, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 185, 199, 193, - 198, 188, 190, 187, 194, 195, 197, 196, 192, 191, - 189, 200, 0, 911, 914, 913, 915, 88, 87, 86, - 0, 0, 1076, 72, 77, 79, 74, 78, 76, 75, - 0, 0, 150, 836, 573, 0, 0, 261, 0, 0, - 0, 0, 0, 0, 320, 355, 356, 0, 318, 321, - 322, 319, 889, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 526, 0, 506, 85, 1085, 0, - 0, 0, 1063, 352, 0, 0, 202, 203, 299, 424, - 425, 0, 434, 435, 0, 0, 1031, 1032, 0, 354, - 0, 0, 0, 0, 0, 0, 0, 647, 0, 0, - 0, 0, 0, 0, 0, 0, 220, 0, 501, 504, - 887, 0, 0, 0, 525, 529, 539, 530, 528, 533, - 536, 535, 534, 538, 537, 532, 540, 527, 531, 0, - 0, 0, 383, 0, 627, 0, 822, 1075, 1083, 1080, - 1079, 1082, 1081, 1078, 1077, 1084, 0, 890, 201, 204, - 205, 0, 300, 423, 426, 427, 433, 699, 700, 0, - 1030, 1033, 1034, 281, 0, 282, 283, 0, 0, 0, - 0, 0, 0, 0, 917, 866, 865, 868, 867, 0, - 864, 863, 314, 315, 0, 324, 325, 0, 329, 330, - 0, 0, 429, 430, 646, 648, 649, 0, 651, 652, - 0, 0, 578, 870, 878, 877, 0, 0, 0, 507, - 0, 0, 436, 0, 0, 0, 0, 0, 0, 1096, - 1098, 1099, 1097, 1091, 1093, 1092, 1094, 1100, 1095, 0, - 401, 1065, 0, 0, 374, 0, 0, 0, 0, 606, - 0, 0, 0, 766, 0, 994, 298, 0, 280, 0, - 227, 228, 0, 0, 54, 0, 55, 0, 0, 0, - 918, 0, 313, 316, 317, 323, 326, 327, 328, 331, - 332, 0, 419, 420, 428, 431, 432, 650, 653, 654, - 0, 689, 690, 0, 694, 695, 0, 0, 876, 879, - 880, 66, 112, 142, 219, 221, 500, 502, 503, 505, - 886, 888, 948, 1102, 1104, 1090, 0, 114, 1064, 1068, - 1067, 1069, 1066, 1070, 0, 370, 391, 390, 0, 0, - 373, 378, 375, 377, 376, 380, 382, 386, 384, 385, - 387, 635, 634, 637, 0, 0, 605, 610, 608, 607, - 609, 623, 626, 630, 629, 628, 631, 830, 829, 832, - 0, 0, 0, 0, 0, 0, 765, 773, 775, 769, - 770, 771, 772, 767, 768, 774, 787, 821, 825, 824, - 823, 826, 698, 226, 229, 230, 45, 46, 56, 0, - 57, 254, 351, 461, 916, 418, 421, 422, 688, 691, - 692, 693, 696, 697, 577, 579, 869, 871, 872, 0, - 438, 581, 0, 729, 0, 0, 851, 0, 950, 1106, - 400, 406, 416, 414, 408, 409, 407, 411, 402, 403, - 415, 405, 413, 404, 412, 417, 410, 0, 0, 0, - 371, 0, 372, 0, 183, 182, 0, 996, 0, 0, - 639, 638, 0, 640, 0, 141, 140, 0, 0, 834, - 833, 0, 835, 0, 16, 15, 0, 155, 154, 0, - 158, 157, 0, 161, 160, 0, 164, 163, 0, 0, - 53, 0, 0, 0, 41, 0, 40, 39, 0, 0, - 0, 1060, 1059, 0, 0, 828, 827, 0, 752, 0, - 0, 903, 905, 0, 0, 0, 0, 104, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 113, - 129, 130, 122, 117, 127, 115, 128, 119, 120, 116, - 121, 123, 118, 125, 124, 131, 126, 0, 561, 1086, - 1088, 369, 181, 172, 173, 174, 0, 0, 0, 995, - 999, 998, 997, 1000, 379, 381, 636, 139, 0, 619, - 0, 622, 624, 625, 831, 14, 153, 156, 159, 162, - 0, 782, 783, 0, 786, 788, 789, 734, 0, 923, - 0, 48, 38, 42, 43, 0, 817, 437, 441, 440, - 439, 580, 585, 583, 582, 584, 0, 718, 643, 728, - 732, 731, 730, 0, 0, 751, 761, 763, 757, 758, - 759, 760, 756, 753, 755, 762, 754, 764, 475, 777, - 0, 0, 0, 0, 850, 856, 861, 855, 853, 854, - 858, 859, 852, 857, 860, 862, 0, 0, 0, 904, - 908, 909, 906, 910, 907, 0, 0, 949, 955, 957, - 962, 954, 952, 953, 959, 956, 960, 951, 958, 961, - 963, 1105, 1109, 1108, 1107, 0, 0, 0, 302, 303, - 0, 0, 335, 336, 389, 0, 388, 0, 518, 633, - 632, 0, 0, 0, 669, 703, 0, 0, 792, 791, - 0, 896, 1017, 1111, 0, 560, 562, 1089, 0, 171, - 0, 0, 342, 725, 0, 0, 167, 166, 0, 0, - 618, 621, 620, 0, 480, 479, 781, 785, 784, 0, - 37, 965, 0, 924, 44, 0, 0, 35, 0, 719, - 0, 207, 208, 209, 0, 1052, 0, 776, 779, 778, - 780, 0, 453, 459, 1062, 1061, 0, 715, 849, 0, - 840, 0, 0, 28, 0, 0, 0, 26, 25, 0, - 0, 71, 103, 105, 108, 110, 106, 107, 109, 111, - 0, 0, 0, 0, 0, 0, 301, 304, 311, 305, - 306, 307, 308, 309, 310, 312, 968, 0, 337, 338, - 1072, 0, 360, 359, 517, 520, 519, 521, 595, 0, - 472, 612, 0, 668, 672, 671, 670, 673, 702, 710, - 711, 707, 704, 705, 706, 709, 708, 712, 133, 790, - 801, 796, 793, 794, 795, 798, 797, 799, 800, 895, - 899, 897, 898, 0, 0, 0, 0, 1110, 1112, 1116, - 1113, 1115, 1114, 1117, 1087, 0, 0, 989, 990, 0, - 341, 343, 724, 726, 165, 496, 509, 0, 51, 50, - 52, 1014, 1013, 1015, 0, 0, 0, 733, 735, 0, - 922, 350, 816, 819, 818, 0, 36, 717, 642, 645, - 644, 206, 474, 476, 477, 452, 454, 714, 716, 839, - 841, 148, 0, 0, 27, 31, 29, 30, 32, 0, - 0, 24, 713, 874, 0, 0, 0, 223, 144, 676, - 0, 745, 0, 722, 749, 0, 901, 0, 0, 334, - 339, 340, 0, 0, 0, 1002, 358, 367, 365, 362, - 363, 366, 364, 361, 368, 594, 603, 601, 596, 598, - 600, 599, 597, 602, 604, 0, 611, 616, 614, 613, - 615, 617, 0, 134, 0, 0, 0, 1016, 1018, 1020, - 1019, 0, 18, 0, 482, 483, 550, 548, 549, 0, - 251, 250, 249, 248, 247, 0, 0, 993, 991, 992, - 0, 0, 0, 49, 0, 478, 0, 926, 964, 966, - 34, 0, 149, 0, 491, 493, 492, 0, 513, 515, - 514, 820, 542, 0, 873, 875, 97, 222, 224, 0, - 675, 677, 0, 721, 723, 748, 750, 900, 902, 0, - 0, 967, 969, 970, 1071, 1074, 1073, 0, 0, 804, - 803, 0, 1003, 1004, 471, 473, 132, 93, 92, 90, - 91, 357, 936, 934, 935, 0, 17, 22, 19, 21, - 20, 23, 0, 487, 485, 484, 486, 551, 552, 0, - 246, 253, 252, 0, 0, 988, 0, 495, 499, 497, - 498, 508, 511, 510, 1012, 0, 925, 927, 147, 490, - 494, 512, 516, 0, 1103, 0, 0, 143, 145, 146, - 744, 746, 0, 237, 0, 236, 238, 0, 972, 974, - 973, 975, 976, 0, 802, 812, 814, 808, 809, 810, - 811, 807, 806, 813, 805, 815, 0, 0, 1005, 1006, - 94, 0, 95, 937, 0, 523, 488, 489, 0, 547, - 674, 225, 353, 920, 541, 546, 544, 543, 545, 96, - 98, 0, 0, 556, 554, 555, 243, 239, 241, 240, - 242, 641, 977, 978, 0, 720, 0, 0, 169, 1007, - 1008, 89, 933, 939, 938, 524, 0, 481, 0, 921, - 0, 558, 557, 559, 0, 244, 0, 245, 971, 893, - 0, 0, 1009, 1010, 522, 919, 0, 553, 235, 894, - 168, 170, 1011, 0, 33, 1001 +static const yytype_uint16 yydefact[] = { + 0, 0, 0, 1126, 0, 0, 0, 590, 11, 591, + 589, 1, 0, 587, 883, 0, 882, 0, 0, 0, + 2, 586, 588, 1127, 0, 0, 885, 884, 1128, 0, + 0, 0, 0, 213, 211, 212, 593, 279, 592, 0, + 946, 881, 0, 0, 0, 4, 285, 0, 0, 215, + 214, 940, 947, 0, 12, 0, 457, 0, 0, 0, + 0, 0, 101, 0, 0, 0, 0, 0, 0, 0, + 0, 284, 292, 289, 290, 295, 286, 287, 291, 288, + 296, 293, 297, 294, 443, 444, 445, 446, 447, 448, + 449, 450, 451, 0, 0, 217, 216, 13, 0, 456, + 458, 0, 0, 0, 929, 3, 9, 8, 6, 7, + 5, 10, 0, 0, 0, 0, 891, 0, 136, 137, + 138, 0, 232, 233, 234, 0, 0, 0, 848, 0, + 0, 0, 1054, 0, 0, 0, 68, 67, 442, 683, + 686, 684, 685, 679, 681, 682, 680, 0, 0, 0, + 218, 455, 0, 184, 0, 462, 0, 0, 0, 70, + 0, 0, 100, 102, 135, 231, 0, 727, 59, 396, + 564, 656, 737, 942, 1022, 1023, 1024, 1025, 1026, 0, + 1027, 843, 987, 1129, 1053, 1058, 1057, 1056, 1055, 345, + 262, 1021, 1101, 678, 0, 0, 210, 0, 176, 0, + 0, 0, 0, 928, 931, 932, 930, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 842, + 847, 844, 846, 845, 0, 0, 687, 82, 84, 175, + 178, 179, 177, 180, 0, 0, 256, 0, 465, 0, + 1119, 0, 69, 892, 99, 333, 0, 58, 62, 61, + 60, 0, 395, 398, 399, 397, 0, 0, 563, 567, + 566, 565, 571, 572, 0, 655, 659, 658, 657, 0, + 736, 740, 739, 738, 941, 944, 945, 943, 0, 1051, + 1037, 1048, 1049, 1038, 1036, 1046, 1050, 1044, 1045, 1043, + 1047, 1039, 1040, 1041, 1042, 0, 344, 349, 348, 347, + 346, 0, 0, 0, 83, 664, 980, 0, 0, 255, + 258, 259, 257, 260, 464, 467, 468, 466, 469, 0, + 0, 0, 0, 1118, 1120, 1124, 1122, 1121, 1123, 1125, + 0, 64, 0, 393, 0, 569, 0, 0, 0, 574, + 576, 575, 0, 661, 0, 742, 701, 1035, 747, 0, + 463, 81, 0, 0, 0, 186, 912, 979, 985, 984, + 982, 981, 983, 986, 0, 80, 0, 0, 151, 837, + 63, 65, 392, 394, 568, 570, 1028, 1029, 0, 660, + 662, 741, 743, 470, 0, 0, 663, 667, 666, 665, + 0, 460, 0, 264, 278, 0, 0, 0, 0, 73, + 0, 47, 0, 0, 152, 0, 838, 0, 0, 0, + 0, 0, 263, 271, 268, 269, 274, 265, 266, 270, + 277, 267, 275, 272, 276, 273, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 185, 199, 193, + 198, 188, 190, 187, 194, 195, 197, 196, 192, 191, + 189, 200, 0, 911, 914, 913, 915, 88, 87, 86, + 0, 0, 1076, 72, 77, 79, 74, 78, 76, 75, + 0, 0, 150, 836, 573, 0, 0, 261, 0, 0, + 0, 0, 0, 0, 320, 355, 356, 0, 318, 321, + 322, 319, 889, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 526, 0, 506, 85, 1085, 0, + 0, 0, 1063, 352, 0, 0, 202, 203, 299, 424, + 425, 0, 434, 435, 0, 0, 1031, 1032, 0, 354, + 0, 0, 0, 0, 0, 0, 0, 647, 0, 0, + 0, 0, 0, 0, 0, 0, 220, 0, 501, 504, + 887, 0, 0, 0, 525, 529, 539, 530, 528, 533, + 536, 535, 534, 538, 537, 532, 540, 527, 531, 0, + 0, 0, 383, 0, 627, 0, 822, 1075, 1083, 1080, + 1079, 1082, 1081, 1078, 1077, 1084, 0, 890, 201, 204, + 205, 0, 300, 423, 426, 427, 433, 699, 700, 0, + 1030, 1033, 1034, 281, 0, 282, 283, 0, 0, 0, + 0, 0, 0, 0, 917, 866, 865, 868, 867, 0, + 864, 863, 314, 315, 0, 324, 325, 0, 329, 330, + 0, 0, 429, 430, 646, 648, 649, 0, 651, 652, + 0, 0, 578, 870, 878, 877, 0, 0, 0, 507, + 0, 0, 436, 0, 0, 0, 0, 0, 0, 1096, + 1098, 1099, 1097, 1091, 1093, 1092, 1094, 1100, 1095, 0, + 401, 1065, 0, 0, 374, 0, 0, 0, 0, 606, + 0, 0, 0, 766, 0, 994, 298, 0, 280, 0, + 227, 228, 0, 0, 54, 0, 55, 0, 0, 0, + 918, 0, 313, 316, 317, 323, 326, 327, 328, 331, + 332, 0, 419, 420, 428, 431, 432, 650, 653, 654, + 0, 689, 690, 0, 694, 695, 0, 0, 876, 879, + 880, 66, 112, 142, 219, 221, 500, 502, 503, 505, + 886, 888, 948, 1102, 1104, 1090, 0, 114, 1064, 1068, + 1067, 1069, 1066, 1070, 0, 370, 391, 390, 0, 0, + 373, 378, 375, 377, 376, 380, 382, 386, 384, 385, + 387, 635, 634, 637, 0, 0, 605, 610, 608, 607, + 609, 623, 626, 630, 629, 628, 631, 830, 829, 832, + 0, 0, 0, 0, 0, 0, 765, 773, 775, 769, + 770, 771, 772, 767, 768, 774, 787, 821, 825, 824, + 823, 826, 698, 226, 229, 230, 45, 46, 56, 0, + 57, 254, 351, 461, 916, 418, 421, 422, 688, 691, + 692, 693, 696, 697, 577, 579, 869, 871, 872, 0, + 438, 581, 0, 729, 0, 0, 851, 0, 950, 1106, + 400, 406, 416, 414, 408, 409, 407, 411, 402, 403, + 415, 405, 413, 404, 412, 417, 410, 0, 0, 0, + 371, 0, 372, 0, 183, 182, 0, 996, 0, 0, + 639, 638, 0, 640, 0, 141, 140, 0, 0, 834, + 833, 0, 835, 0, 16, 15, 0, 155, 154, 0, + 158, 157, 0, 161, 160, 0, 164, 163, 0, 0, + 53, 0, 0, 0, 41, 0, 40, 39, 0, 0, + 0, 1060, 1059, 0, 0, 828, 827, 0, 752, 0, + 0, 903, 905, 0, 0, 0, 0, 104, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 113, + 129, 130, 122, 117, 127, 115, 128, 119, 120, 116, + 121, 123, 118, 125, 124, 131, 126, 0, 561, 1086, + 1088, 369, 181, 172, 173, 174, 0, 0, 0, 995, + 999, 998, 997, 1000, 379, 381, 636, 139, 0, 619, + 0, 622, 624, 625, 831, 14, 153, 156, 159, 162, + 0, 782, 783, 0, 786, 788, 789, 734, 0, 923, + 0, 48, 38, 42, 43, 0, 817, 437, 441, 440, + 439, 580, 585, 583, 582, 584, 0, 718, 643, 728, + 732, 731, 730, 0, 0, 751, 761, 763, 757, 758, + 759, 760, 756, 753, 755, 762, 754, 764, 475, 777, + 0, 0, 0, 0, 850, 856, 861, 855, 853, 854, + 858, 859, 852, 857, 860, 862, 0, 0, 0, 904, + 908, 909, 906, 910, 907, 0, 0, 949, 955, 957, + 962, 954, 952, 953, 959, 956, 960, 951, 958, 961, + 963, 1105, 1109, 1108, 1107, 0, 0, 0, 302, 303, + 0, 0, 335, 336, 389, 0, 388, 0, 518, 633, + 632, 0, 0, 0, 669, 703, 0, 0, 792, 791, + 0, 896, 1017, 1111, 0, 560, 562, 1089, 0, 171, + 0, 0, 342, 725, 0, 0, 167, 166, 0, 0, + 618, 621, 620, 0, 480, 479, 781, 785, 784, 0, + 37, 965, 0, 924, 44, 0, 0, 35, 0, 719, + 0, 207, 208, 209, 0, 1052, 0, 776, 779, 778, + 780, 0, 453, 459, 1062, 1061, 0, 715, 849, 0, + 840, 0, 0, 28, 0, 0, 0, 26, 25, 0, + 0, 71, 103, 105, 108, 110, 106, 107, 109, 111, + 0, 0, 0, 0, 0, 0, 301, 304, 311, 305, + 306, 307, 308, 309, 310, 312, 968, 0, 337, 338, + 1072, 0, 360, 359, 517, 520, 519, 521, 595, 0, + 472, 612, 0, 668, 672, 671, 670, 673, 702, 710, + 711, 707, 704, 705, 706, 709, 708, 712, 133, 790, + 801, 796, 793, 794, 795, 798, 797, 799, 800, 895, + 899, 897, 898, 0, 0, 0, 0, 1110, 1112, 1116, + 1113, 1115, 1114, 1117, 1087, 0, 0, 989, 990, 0, + 341, 343, 724, 726, 165, 496, 509, 0, 51, 50, + 52, 1014, 1013, 1015, 0, 0, 0, 733, 735, 0, + 922, 350, 816, 819, 818, 0, 36, 717, 642, 645, + 644, 206, 474, 476, 477, 452, 454, 714, 716, 839, + 841, 148, 0, 0, 27, 31, 29, 30, 32, 0, + 0, 24, 713, 874, 0, 0, 0, 223, 144, 676, + 0, 745, 0, 722, 749, 0, 901, 0, 0, 334, + 339, 340, 0, 0, 0, 1002, 358, 367, 365, 362, + 363, 366, 364, 361, 368, 594, 603, 601, 596, 598, + 600, 599, 597, 602, 604, 0, 611, 616, 614, 613, + 615, 617, 0, 134, 0, 0, 0, 1016, 1018, 1020, + 1019, 0, 18, 0, 482, 483, 550, 548, 549, 0, + 251, 250, 249, 248, 247, 0, 0, 993, 991, 992, + 0, 0, 0, 49, 0, 478, 0, 926, 964, 966, + 34, 0, 149, 0, 491, 493, 492, 0, 513, 515, + 514, 820, 542, 0, 873, 875, 97, 222, 224, 0, + 675, 677, 0, 721, 723, 748, 750, 900, 902, 0, + 0, 967, 969, 970, 1071, 1074, 1073, 0, 0, 804, + 803, 0, 1003, 1004, 471, 473, 132, 93, 92, 90, + 91, 357, 936, 934, 935, 0, 17, 22, 19, 21, + 20, 23, 0, 487, 485, 484, 486, 551, 552, 0, + 246, 253, 252, 0, 0, 988, 0, 495, 499, 497, + 498, 508, 511, 510, 1012, 0, 925, 927, 147, 490, + 494, 512, 516, 0, 1103, 0, 0, 143, 145, 146, + 744, 746, 0, 237, 0, 236, 238, 0, 972, 974, + 973, 975, 976, 0, 802, 812, 814, 808, 809, 810, + 811, 807, 806, 813, 805, 815, 0, 0, 1005, 1006, + 94, 0, 95, 937, 0, 523, 488, 489, 0, 547, + 674, 225, 353, 920, 541, 546, 544, 543, 545, 96, + 98, 0, 0, 556, 554, 555, 243, 239, 241, 240, + 242, 641, 977, 978, 0, 720, 0, 0, 169, 1007, + 1008, 89, 933, 939, 938, 524, 0, 481, 0, 921, + 0, 558, 557, 559, 0, 244, 0, 245, 971, 893, + 0, 0, 1009, 1010, 522, 919, 0, 553, 235, 894, + 168, 170, 1011, 0, 33, 1001 }; /* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int16 yydefgoto[] = -{ - -1, 21, 2, 58, 6, 31, 18, 797, 893, 1268, - 1391, 1078, 1186, 1070, 1182, 1518, 925, 1305, 914, 851, - 915, 916, 615, 616, 324, 917, 1141, 1287, 617, 695, - 819, 174, 211, 249, 330, 555, 135, 72, 73, 950, - 310, 398, 364, 198, 303, 227, 399, 460, 1388, 1467, - 1551, 1207, 1515, 74, 75, 117, 952, 1097, 557, 750, - 867, 1252, 1382, 76, 121, 778, 884, 558, 1339, 1439, - 1183, 1421, 326, 403, 799, 896, 800, 899, 801, 902, - 802, 905, 989, 1135, 1589, 1611, 877, 976, 107, 199, - 762, 873, 152, 359, 395, 484, 515, 1043, 1164, 22, - 33, 49, 95, 149, 559, 651, 1209, 1336, 1407, 439, - 689, 77, 125, 1452, 1524, 1576, 1606, 1277, 1399, 618, - 108, 235, 360, 136, 361, 392, 393, 34, 531, 604, - 35, 47, 485, 591, 953, 1100, 441, 619, 486, 442, - 624, 443, 627, 78, 954, 1101, 1217, 981, 1131, 185, - 224, 1018, 620, 388, 1498, 420, 487, 1389, 955, 1221, - 674, 871, 579, 675, 769, 879, 580, 676, 1105, 755, - 253, 332, 175, 212, 671, 746, 444, 711, 488, 521, - 445, 631, 489, 524, 560, 854, 918, 50, 93, 1060, - 1171, 56, 45, 57, 1172, 390, 621, 154, 349, 109, - 237, 304, 1231, 1375, 1049, 1166, 1002, 1143, 1271, 1393, - 1483, 1558, 1326, 1423, 1291, 1411, 561, 653, 562, 654, - 504, 1292, 1293, 1412, 1327, 1427, 956, 1107, 1484, 1596, - 455, 505, 1433, 1513, 1272, 1396, 1489, 1525, 1572, 1604, - 787, 967, 176, 213, 1144, 334, 1145, 262, 338, 644, - 726, 855, 919, 36, 12, 492, 649, 957, 1229, 581, - 678, 958, 1232, 779, 990, 784, 888, 582, 680, 1111, - 773, 679, 882, 1529, 1030, 1160, 446, 538, 447, 637, - 177, 214, 267, 342, 306, 352, 959, 1113, 1278, 1210, - 1340, 96, 147, 150, 448, 720, 449, 723, 490, 599, - 221, 960, 1116, 1085, 1061, 1176, 856, 1158, 1359, 1211, - 1342, 982, 1134, 79, 857, 924, 1008, 1149, 178, 215, - 272, 344, 1343, 1442, 195, 1212, 1345, 858, 927, 583, - 682, 859, 1050, 804, 1003, 809, 909, 961, 1117, 1360, - 1458, 1019, 1156, 1072, 584, 684, 928, 789, 683, 891, - 327, 405, 1063, 1179, 80, 179, 129, 1180, 861, 930, - 622, 645, 727, 1096, 1334, 450, 646, 9, 15, 25, - 564, 655, 493, 389, 263, 1462, 1548, 962, 1120, 1214, - 1347, 932, 862, 933, 362, 396, 623, 701, 1507, 1598, - 1010, 1152, 1298, 1416, 110, 157, 1390, 1475, 1554, 26, - 180, 216, 39, 565, 863, 934, 1153, 1299, 1219, 1348, - 1453, 1532, 1584, 236, 307, 81, 1132, 1279, 1410, 240, - 764, 878, 1363, 1463, 1549, 1590, 1613, 1623, 1142, 1294, - 1123, 1263, 137, 181, 340, 341, 491, 528, 223, 295, - 1046, 82, 131, 923, 1177, 404, 468, 672, 1222, 1352, - 469, 510, 509, 970, 872, 1128, 570, 669, 83, 567, - 1074, 568, 866, 935, 966, 1124, 206, 241, 38, 27, - 116, 189 +static const yytype_int16 yydefgoto[] = { + -1, 21, 2, 58, 6, 31, 18, 797, 893, 1268, + 1391, 1078, 1186, 1070, 1182, 1518, 925, 1305, 914, 851, + 915, 916, 615, 616, 324, 917, 1141, 1287, 617, 695, + 819, 174, 211, 249, 330, 555, 135, 72, 73, 950, + 310, 398, 364, 198, 303, 227, 399, 460, 1388, 1467, + 1551, 1207, 1515, 74, 75, 117, 952, 1097, 557, 750, + 867, 1252, 1382, 76, 121, 778, 884, 558, 1339, 1439, + 1183, 1421, 326, 403, 799, 896, 800, 899, 801, 902, + 802, 905, 989, 1135, 1589, 1611, 877, 976, 107, 199, + 762, 873, 152, 359, 395, 484, 515, 1043, 1164, 22, + 33, 49, 95, 149, 559, 651, 1209, 1336, 1407, 439, + 689, 77, 125, 1452, 1524, 1576, 1606, 1277, 1399, 618, + 108, 235, 360, 136, 361, 392, 393, 34, 531, 604, + 35, 47, 485, 591, 953, 1100, 441, 619, 486, 442, + 624, 443, 627, 78, 954, 1101, 1217, 981, 1131, 185, + 224, 1018, 620, 388, 1498, 420, 487, 1389, 955, 1221, + 674, 871, 579, 675, 769, 879, 580, 676, 1105, 755, + 253, 332, 175, 212, 671, 746, 444, 711, 488, 521, + 445, 631, 489, 524, 560, 854, 918, 50, 93, 1060, + 1171, 56, 45, 57, 1172, 390, 621, 154, 349, 109, + 237, 304, 1231, 1375, 1049, 1166, 1002, 1143, 1271, 1393, + 1483, 1558, 1326, 1423, 1291, 1411, 561, 653, 562, 654, + 504, 1292, 1293, 1412, 1327, 1427, 956, 1107, 1484, 1596, + 455, 505, 1433, 1513, 1272, 1396, 1489, 1525, 1572, 1604, + 787, 967, 176, 213, 1144, 334, 1145, 262, 338, 644, + 726, 855, 919, 36, 12, 492, 649, 957, 1229, 581, + 678, 958, 1232, 779, 990, 784, 888, 582, 680, 1111, + 773, 679, 882, 1529, 1030, 1160, 446, 538, 447, 637, + 177, 214, 267, 342, 306, 352, 959, 1113, 1278, 1210, + 1340, 96, 147, 150, 448, 720, 449, 723, 490, 599, + 221, 960, 1116, 1085, 1061, 1176, 856, 1158, 1359, 1211, + 1342, 982, 1134, 79, 857, 924, 1008, 1149, 178, 215, + 272, 344, 1343, 1442, 195, 1212, 1345, 858, 927, 583, + 682, 859, 1050, 804, 1003, 809, 909, 961, 1117, 1360, + 1458, 1019, 1156, 1072, 584, 684, 928, 789, 683, 891, + 327, 405, 1063, 1179, 80, 179, 129, 1180, 861, 930, + 622, 645, 727, 1096, 1334, 450, 646, 9, 15, 25, + 564, 655, 493, 389, 263, 1462, 1548, 962, 1120, 1214, + 1347, 932, 862, 933, 362, 396, 623, 701, 1507, 1598, + 1010, 1152, 1298, 1416, 110, 157, 1390, 1475, 1554, 26, + 180, 216, 39, 565, 863, 934, 1153, 1299, 1219, 1348, + 1453, 1532, 1584, 236, 307, 81, 1132, 1279, 1410, 240, + 764, 878, 1363, 1463, 1549, 1590, 1613, 1623, 1142, 1294, + 1123, 1263, 137, 181, 340, 341, 491, 528, 223, 295, + 1046, 82, 131, 923, 1177, 404, 468, 672, 1222, 1352, + 469, 510, 509, 970, 872, 1128, 570, 669, 83, 567, + 1074, 568, 866, 935, 966, 1124, 206, 241, 38, 27, + 116, 189 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ #define YYPACT_NINF -1333 -static const yytype_int16 yypact[] = -{ - 41, 152, 149, -1333, 176, 81, 305, -1333, -1333, -1333, - -1333, -1333, 33, -1333, -1333, 59, -1333, 148, 317, 101, - -1333, -1333, -1333, -1333, 437, 150, -1333, -1333, -1333, 148, - 148, 304, 81, 312, -1333, -1333, -1333, -1333, -1333, 33, - -1333, -1333, 148, 150, 316, -1333, -1333, 1508, 1780, 272, - -1333, -1333, -1333, 150, -1333, 148, -1333, 122, 715, 148, - 148, 111, -1333, 997, 1020, 148, 148, 152, 148, 176, - 300, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, 150, 1588, 280, -1333, -1333, 150, -1333, - -1333, 152, 152, 152, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, 148, 150, 148, 111, -1333, 36, -1333, -1333, - -1333, 150, -1333, -1333, -1333, 150, 148, 150, -1333, 1023, - 150, 66, -1333, 150, 150, 150, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, 150, 260, 150, - -1333, -1333, 424, -1333, 317, -1333, 317, 273, 439, -1333, - 148, 111, -1333, -1333, -1333, -1333, 439, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 310, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, 148, 150, -1333, 81, -1333, 441, - 254, 254, 266, -1333, -1333, -1333, -1333, 150, 150, 150, - 150, 416, 49, 115, 91, 801, 77, 437, 2006, -1333, - -1333, -1333, -1333, -1333, 71, 148, -1333, 376, -1333, -1333, - -1333, -1333, -1333, -1333, 343, 445, -1333, 445, -1333, 148, - -1333, 158, -1333, -1333, -1333, -1333, 300, -1333, -1333, -1333, - -1333, 148, -1333, -1333, -1333, -1333, 276, 144, -1333, -1333, - -1333, -1333, -1333, -1333, 111, -1333, -1333, -1333, -1333, 260, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 150, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, 150, -1333, -1333, -1333, -1333, - -1333, 150, 81, 150, -1333, -1333, -1333, 546, 152, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 148, - 437, 437, 437, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - 33, -1333, 33, -1333, 33, -1333, 150, 150, 144, -1333, - -1333, -1333, 33, -1333, 33, -1333, -1333, -1333, -1333, 150, - -1333, -1333, 132, 152, 152, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, 468, -1333, 148, 150, 306, 306, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 144, -1333, - -1333, -1333, -1333, -1333, 111, 111, -1333, -1333, -1333, -1333, - 81, -1333, 1442, -1333, -1333, 1794, 519, 832, 940, -1333, - 148, -1333, 437, 150, -1333, 150, -1333, 150, 111, 111, - 150, 1196, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, 152, 152, 152, 152, - 152, 152, 152, 152, 152, 152, 152, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, 152, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - 150, 152, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - 148, 150, -1333, -1333, -1333, 150, 321, -1333, 1196, 81, - 1196, 1196, 148, 1196, -1333, -1333, -1333, 150, -1333, -1333, - -1333, -1333, -1333, 461, 461, 461, 461, 461, 461, 461, - 461, 461, 461, 461, -1333, 1198, -1333, -1333, -1333, 322, - 867, 148, -1333, -1333, 150, 1263, -1333, -1333, 376, -1333, - -1333, 1263, -1333, -1333, 150, 1196, -1333, -1333, 1263, -1333, - 342, 461, 1545, 1545, 1545, 461, 1545, -1333, 130, 1545, - 461, 461, -29, 300, 81, 276, -1333, 150, -1333, -1333, - -1333, 81, 276, 81, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 1879, - 444, 466, -1333, 425, -1333, 382, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, 150, -1333, -1333, -1333, - -1333, 150, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 540, - -1333, -1333, -1333, -1333, 150, -1333, -1333, 1545, 111, 111, - 42, 111, 111, 111, 1276, -1333, -1333, -1333, -1333, 130, - -1333, -1333, -1333, -1333, 130, -1333, -1333, 130, -1333, -1333, - 1545, 130, -1333, -1333, -1333, -1333, -1333, 130, -1333, -1333, - 1545, 1545, -1333, -1333, -1333, -1333, 130, 150, 150, -1333, - 150, 63, -1333, 63, 63, 63, 150, 150, 150, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 150, - -1333, -1333, 186, 529, -1333, 653, 833, 529, 605, -1333, - 171, 529, 581, -1333, 783, -1333, -1333, 150, -1333, 130, - -1333, -1333, 150, 150, -1333, 53, -1333, 150, 150, 150, - -1333, 150, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, 130, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - 130, -1333, -1333, 130, -1333, -1333, -75, 361, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, 990, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, 81, -34, -1333, -1333, 59, 548, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, 442, 460, 548, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 539, - 523, 93, 93, 93, 93, 548, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 150, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 543, - -1333, -1333, 108, -1333, 108, 108, -1333, 152, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, 1584, 148, 81, - -1333, 150, -1333, 150, -1333, -1333, 894, -1333, 708, 252, - -1333, -1333, 150, -1333, 150, -1333, -1333, 561, 46, -1333, - -1333, 150, -1333, 150, -1333, -1333, 150, -1333, -1333, 150, - -1333, -1333, 150, -1333, -1333, 150, -1333, -1333, 26, 86, - -1333, 431, 421, 150, -1333, 130, -1333, -1333, 531, 281, - 152, -1333, -1333, 1023, -73, -1333, -1333, 631, -1333, 512, - 762, -1333, -1333, 481, 365, 588, 454, -1333, 76, 104, - 108, 108, 108, 108, 108, 108, 104, 437, 418, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, 51, -1333, -1333, - 424, -1333, -1333, -1333, -1333, -1333, 150, 436, 561, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 523, -1333, - -31, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - 523, -1333, -1333, -31, -1333, -1333, -1333, -1333, 150, 453, - 150, -1333, -1333, -1333, -1333, 529, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, 148, 321, -1333, -1333, - -1333, -1333, -1333, 711, 150, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - 726, 176, 529, 81, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, 620, 108, 152, -1333, - -1333, -1333, -1333, -1333, -1333, 59, 454, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, 260, 150, 691, -1333, -1333, - 751, -85, -1333, -1333, -1333, -115, -1333, 726, -1333, -1333, - -1333, 568, 562, 635, -1333, -1333, 449, 1253, -1333, -1333, - 97, -1333, -1333, -1333, 448, -1333, -1333, -1333, 150, -1333, - 384, -24, -1333, -1333, -24, 150, -1333, -1333, 950, 950, - -1333, -1333, -1333, 523, -1333, -1333, -1333, -1333, -1333, -122, - -1333, -1333, 150, -1333, -1333, 150, 86, 148, 150, -1333, - -77, -1333, -1333, -1333, 150, -1333, -90, -1333, -1333, -1333, - -1333, 33, -1333, -1333, -1333, -1333, 33, -1333, -1333, 33, - -1333, 148, 409, -1333, 530, 111, 150, -1333, -1333, 150, - 260, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - 260, 260, 675, 553, 553, 675, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, 99, -1333, -1333, - -1333, 812, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 679, - -1333, -1333, 946, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 651, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, 34, 276, 104, 104, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, 1014, 671, -1333, -1333, 634, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, 150, -1333, -1333, - -1333, -1333, -1333, -1333, 950, 150, 453, -1333, -1333, -119, - -1333, -1333, -1333, -1333, -1333, 150, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, 684, 255, 255, -1333, -1333, -1333, -1333, -1333, 150, - 624, -1333, -1333, -1333, -117, 260, -117, -1333, -1333, -1333, - -117, -1333, -117, -1333, -1333, -117, -1333, -117, 269, -1333, - -1333, -1333, 428, 529, 104, 560, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -98, -1333, -1333, -1333, -1333, - -1333, -1333, 150, -1333, 255, 150, 255, -1333, -1333, -1333, - -1333, 739, -1333, -64, -1333, -1333, 26, -1333, -1333, -31, - -1333, -1333, -1333, -1333, -1333, 111, 111, -1333, -1333, -1333, - 150, 114, 64, -1333, 150, -1333, -127, -1333, -1333, -1333, - -1333, 150, -1333, -52, -1333, -1333, -1333, -52, -1333, -1333, - -1333, -1333, -1333, 150, -1333, -1333, -1333, -1333, -1333, 28, - -1333, -1333, -46, -1333, -1333, -1333, -1333, -1333, -1333, 383, - 890, -1333, -1333, -1333, -1333, -1333, -1333, 1023, 657, -1333, - -1333, 148, -1333, 564, -1333, -1333, -1333, 11, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, 684, -1333, -1333, -1333, -1333, - -1333, -1333, 81, 26, -1333, -1333, -1333, -1333, -1333, 150, - -1333, -1333, -1333, 150, 150, -1333, 150, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, 534, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, 113, -1333, -117, 260, -1333, -1333, -1333, - -1333, -1333, 255, -1333, 890, -1333, -1333, 150, -1333, -1333, - -1333, -1333, 26, 150, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -1333, 148, 148, -1333, 725, - -1333, 150, -1333, -1333, -31, 376, -1333, -1333, 150, -1333, - -1333, -1333, -1333, 577, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, 260, 950, -1333, -1333, -1333, 26, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, 150, -1333, 150, 148, -1333, -1333, - 272, -1333, -1333, -1333, -1333, -1333, 150, -1333, 150, -1333, - 260, -1333, -1333, -1333, 150, -1333, 150, -1333, -1333, -1333, - 150, -46, -1333, 280, -1333, -1333, 150, -1333, -1333, -1333, - -1333, -1333, -1333, 150, -1333, -1333 +static const yytype_int16 yypact[] = { + 41, 152, 149, -1333, 176, 81, 305, -1333, -1333, -1333, + -1333, -1333, 33, -1333, -1333, 59, -1333, 148, 317, 101, + -1333, -1333, -1333, -1333, 437, 150, -1333, -1333, -1333, 148, + 148, 304, 81, 312, -1333, -1333, -1333, -1333, -1333, 33, + -1333, -1333, 148, 150, 316, -1333, -1333, 1508, 1780, 272, + -1333, -1333, -1333, 150, -1333, 148, -1333, 122, 715, 148, + 148, 111, -1333, 997, 1020, 148, 148, 152, 148, 176, + 300, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, 150, 1588, 280, -1333, -1333, 150, -1333, + -1333, 152, 152, 152, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, 148, 150, 148, 111, -1333, 36, -1333, -1333, + -1333, 150, -1333, -1333, -1333, 150, 148, 150, -1333, 1023, + 150, 66, -1333, 150, 150, 150, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, 150, 260, 150, + -1333, -1333, 424, -1333, 317, -1333, 317, 273, 439, -1333, + 148, 111, -1333, -1333, -1333, -1333, 439, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 310, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, 148, 150, -1333, 81, -1333, 441, + 254, 254, 266, -1333, -1333, -1333, -1333, 150, 150, 150, + 150, 416, 49, 115, 91, 801, 77, 437, 2006, -1333, + -1333, -1333, -1333, -1333, 71, 148, -1333, 376, -1333, -1333, + -1333, -1333, -1333, -1333, 343, 445, -1333, 445, -1333, 148, + -1333, 158, -1333, -1333, -1333, -1333, 300, -1333, -1333, -1333, + -1333, 148, -1333, -1333, -1333, -1333, 276, 144, -1333, -1333, + -1333, -1333, -1333, -1333, 111, -1333, -1333, -1333, -1333, 260, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 150, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, 150, -1333, -1333, -1333, -1333, + -1333, 150, 81, 150, -1333, -1333, -1333, 546, 152, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 148, + 437, 437, 437, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + 33, -1333, 33, -1333, 33, -1333, 150, 150, 144, -1333, + -1333, -1333, 33, -1333, 33, -1333, -1333, -1333, -1333, 150, + -1333, -1333, 132, 152, 152, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, 468, -1333, 148, 150, 306, 306, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 144, -1333, + -1333, -1333, -1333, -1333, 111, 111, -1333, -1333, -1333, -1333, + 81, -1333, 1442, -1333, -1333, 1794, 519, 832, 940, -1333, + 148, -1333, 437, 150, -1333, 150, -1333, 150, 111, 111, + 150, 1196, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, 152, 152, 152, 152, + 152, 152, 152, 152, 152, 152, 152, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, 152, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + 150, 152, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + 148, 150, -1333, -1333, -1333, 150, 321, -1333, 1196, 81, + 1196, 1196, 148, 1196, -1333, -1333, -1333, 150, -1333, -1333, + -1333, -1333, -1333, 461, 461, 461, 461, 461, 461, 461, + 461, 461, 461, 461, -1333, 1198, -1333, -1333, -1333, 322, + 867, 148, -1333, -1333, 150, 1263, -1333, -1333, 376, -1333, + -1333, 1263, -1333, -1333, 150, 1196, -1333, -1333, 1263, -1333, + 342, 461, 1545, 1545, 1545, 461, 1545, -1333, 130, 1545, + 461, 461, -29, 300, 81, 276, -1333, 150, -1333, -1333, + -1333, 81, 276, 81, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 1879, + 444, 466, -1333, 425, -1333, 382, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, 150, -1333, -1333, -1333, + -1333, 150, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 540, + -1333, -1333, -1333, -1333, 150, -1333, -1333, 1545, 111, 111, + 42, 111, 111, 111, 1276, -1333, -1333, -1333, -1333, 130, + -1333, -1333, -1333, -1333, 130, -1333, -1333, 130, -1333, -1333, + 1545, 130, -1333, -1333, -1333, -1333, -1333, 130, -1333, -1333, + 1545, 1545, -1333, -1333, -1333, -1333, 130, 150, 150, -1333, + 150, 63, -1333, 63, 63, 63, 150, 150, 150, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 150, + -1333, -1333, 186, 529, -1333, 653, 833, 529, 605, -1333, + 171, 529, 581, -1333, 783, -1333, -1333, 150, -1333, 130, + -1333, -1333, 150, 150, -1333, 53, -1333, 150, 150, 150, + -1333, 150, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, 130, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + 130, -1333, -1333, 130, -1333, -1333, -75, 361, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, 990, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, 81, -34, -1333, -1333, 59, 548, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, 442, 460, 548, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 539, + 523, 93, 93, 93, 93, 548, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 150, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 543, + -1333, -1333, 108, -1333, 108, 108, -1333, 152, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, 1584, 148, 81, + -1333, 150, -1333, 150, -1333, -1333, 894, -1333, 708, 252, + -1333, -1333, 150, -1333, 150, -1333, -1333, 561, 46, -1333, + -1333, 150, -1333, 150, -1333, -1333, 150, -1333, -1333, 150, + -1333, -1333, 150, -1333, -1333, 150, -1333, -1333, 26, 86, + -1333, 431, 421, 150, -1333, 130, -1333, -1333, 531, 281, + 152, -1333, -1333, 1023, -73, -1333, -1333, 631, -1333, 512, + 762, -1333, -1333, 481, 365, 588, 454, -1333, 76, 104, + 108, 108, 108, 108, 108, 108, 104, 437, 418, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, 51, -1333, -1333, + 424, -1333, -1333, -1333, -1333, -1333, 150, 436, 561, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 523, -1333, + -31, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + 523, -1333, -1333, -31, -1333, -1333, -1333, -1333, 150, 453, + 150, -1333, -1333, -1333, -1333, 529, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, 148, 321, -1333, -1333, + -1333, -1333, -1333, 711, 150, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + 726, 176, 529, 81, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, 620, 108, 152, -1333, + -1333, -1333, -1333, -1333, -1333, 59, 454, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, 260, 150, 691, -1333, -1333, + 751, -85, -1333, -1333, -1333, -115, -1333, 726, -1333, -1333, + -1333, 568, 562, 635, -1333, -1333, 449, 1253, -1333, -1333, + 97, -1333, -1333, -1333, 448, -1333, -1333, -1333, 150, -1333, + 384, -24, -1333, -1333, -24, 150, -1333, -1333, 950, 950, + -1333, -1333, -1333, 523, -1333, -1333, -1333, -1333, -1333, -122, + -1333, -1333, 150, -1333, -1333, 150, 86, 148, 150, -1333, + -77, -1333, -1333, -1333, 150, -1333, -90, -1333, -1333, -1333, + -1333, 33, -1333, -1333, -1333, -1333, 33, -1333, -1333, 33, + -1333, 148, 409, -1333, 530, 111, 150, -1333, -1333, 150, + 260, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + 260, 260, 675, 553, 553, 675, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, 99, -1333, -1333, + -1333, 812, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 679, + -1333, -1333, 946, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 651, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, 34, 276, 104, 104, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, 1014, 671, -1333, -1333, 634, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, 150, -1333, -1333, + -1333, -1333, -1333, -1333, 950, 150, 453, -1333, -1333, -119, + -1333, -1333, -1333, -1333, -1333, 150, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, 684, 255, 255, -1333, -1333, -1333, -1333, -1333, 150, + 624, -1333, -1333, -1333, -117, 260, -117, -1333, -1333, -1333, + -117, -1333, -117, -1333, -1333, -117, -1333, -117, 269, -1333, + -1333, -1333, 428, 529, 104, 560, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -98, -1333, -1333, -1333, -1333, + -1333, -1333, 150, -1333, 255, 150, 255, -1333, -1333, -1333, + -1333, 739, -1333, -64, -1333, -1333, 26, -1333, -1333, -31, + -1333, -1333, -1333, -1333, -1333, 111, 111, -1333, -1333, -1333, + 150, 114, 64, -1333, 150, -1333, -127, -1333, -1333, -1333, + -1333, 150, -1333, -52, -1333, -1333, -1333, -52, -1333, -1333, + -1333, -1333, -1333, 150, -1333, -1333, -1333, -1333, -1333, 28, + -1333, -1333, -46, -1333, -1333, -1333, -1333, -1333, -1333, 383, + 890, -1333, -1333, -1333, -1333, -1333, -1333, 1023, 657, -1333, + -1333, 148, -1333, 564, -1333, -1333, -1333, 11, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, 684, -1333, -1333, -1333, -1333, + -1333, -1333, 81, 26, -1333, -1333, -1333, -1333, -1333, 150, + -1333, -1333, -1333, 150, 150, -1333, 150, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, 534, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, 113, -1333, -117, 260, -1333, -1333, -1333, + -1333, -1333, 255, -1333, 890, -1333, -1333, 150, -1333, -1333, + -1333, -1333, 26, 150, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -1333, 148, 148, -1333, 725, + -1333, 150, -1333, -1333, -31, 376, -1333, -1333, 150, -1333, + -1333, -1333, -1333, 577, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, 260, 950, -1333, -1333, -1333, 26, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, 150, -1333, 150, 148, -1333, -1333, + 272, -1333, -1333, -1333, -1333, -1333, 150, -1333, 150, -1333, + 260, -1333, -1333, -1333, 150, -1333, 150, -1333, -1333, -1333, + 150, -46, -1333, 280, -1333, -1333, 150, -1333, -1333, -1333, + -1333, -1333, -1333, 150, -1333, -1333 }; /* YYPGOTO[NTERM-NUM]. */ -static const yytype_int16 yypgoto[] = -{ - -1333, -25, -1333, -1333, -1333, 8, -1333, -906, -1333, -1333, - -1333, -265, -1333, -1333, -1333, -1333, 173, -1333, -1333, -1333, - -1333, -1333, 223, 139, -1333, -1333, -996, -1333, -1333, -1333, - -1333, 645, -1333, -1333, -1333, -1333, -168, 470, 473, -285, - 599, -1333, -1333, -91, -1333, -1333, -1333, -1333, -557, -1333, - -1333, -1333, -1333, 504, 1011, -1333, -878, -1333, -1333, -1333, - -1333, -1333, -1333, -310, -1333, -316, -1333, -1333, -291, -1333, - -1333, -1333, -1333, -1333, -902, -1333, -901, -1333, -896, -1333, - -893, -1333, -891, -1333, -1333, -1333, -630, -1333, -1333, -1333, - -666, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -26, - -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -890, -1333, - -1333, 527, -1333, -1333, -1333, -1333, -1333, -284, -1333, -1333, - -1333, -1333, -1333, -1333, 528, -1333, -11, 3, 1663, -1333, - -7, -1333, 1085, -1333, -880, -1333, -1333, -1333, 1301, -1333, - -1333, -1333, -1333, 544, -1043, -1333, -1333, -1333, -1333, 716, - -1333, -1333, 329, -1333, -570, -1333, -1333, -1333, -872, -1333, - 308, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 4, -1333, - 180, -1333, 745, -1333, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -1333, -834, -1333, -1333, -1333, -871, - -1333, -1333, -1333, -1333, -1333, -1333, 263, 858, -1333, -1333, - -1333, -517, -1333, -1333, -1333, -1333, -1202, -181, -428, -1333, - -1333, -1333, -1333, -1333, -1109, -1333, -1333, -1333, -1333, -1333, - -99, -514, -1097, -1333, -1333, -1333, -1333, -1333, -1332, -1333, - -1333, -1333, -1227, -1333, -420, -1333, -1333, -1333, -1333, -1333, - -665, -1333, 769, -1333, -193, -1333, -209, -1333, 90, -1333, - -1333, -1333, -1333, 355, -1333, 903, 128, -1025, -1333, -1333, - -1333, -141, -1333, -242, -1333, -287, -1333, -1333, -1333, 55, - 123, -674, -1333, -502, -1333, -1333, -1333, -1333, -1333, -1333, - 813, -1333, 472, -1333, -1333, -1333, -1333, -1333, -251, -1333, - -1333, -560, -1333, -582, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, -83, 105, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, -1333, 656, -864, -1333, -1333, -1333, 830, -1333, - -1333, -1333, -155, -1333, -210, -1333, -1333, -113, -1333, -1333, - -1333, -105, -1333, -889, -1333, -213, -1333, -803, -1333, -1333, - -1333, -874, -1333, -1333, -1333, -1333, -679, -882, 502, -1333, - -1333, -1333, -699, -1333, 767, -1333, -1333, -1333, -1333, -1333, - 845, 339, -1333, -942, -1333, -1333, -1333, -1333, -1333, -1333, - -1333, -1333, 902, -1333, 141, -1333, -1333, -44, -1333, -1333, - -1333, -1333, 213, -1333, -1333, -1333, 411, -1333, -1333, -1333, - -1333, -1333, -1333, -1333, -189, -1333, -363, -1333, -1333, -214, - 873, -1333, -1333, -1333, -1333, -1333, -195, -1333, -1300, -1333, - -1333, -1333, -1333, 904, -1333, 712, -1333, -1333, -1333, -1333, - -706, -1333, -1248, -1333, -1333, -1333, -1333, -1333, -980, -186, - -1333, -1333, -1333, -912, -1333, -1333, -1333, -1333, -467, -1333, - -1089, 1032, -1333, -1333, -241, 742, -1333, -1333, -235, -1333, - -1333, -1333, -1333, -1333, -770, -1333, -1333, -1333, 727, -1333, - -1333, -1333, 203, -1333, -1333, -1333, -1333, -1333, 1551, 12, - 347, -1333 +static const yytype_int16 yypgoto[] = { + -1333, -25, -1333, -1333, -1333, 8, -1333, -906, -1333, -1333, + -1333, -265, -1333, -1333, -1333, -1333, 173, -1333, -1333, -1333, + -1333, -1333, 223, 139, -1333, -1333, -996, -1333, -1333, -1333, + -1333, 645, -1333, -1333, -1333, -1333, -168, 470, 473, -285, + 599, -1333, -1333, -91, -1333, -1333, -1333, -1333, -557, -1333, + -1333, -1333, -1333, 504, 1011, -1333, -878, -1333, -1333, -1333, + -1333, -1333, -1333, -310, -1333, -316, -1333, -1333, -291, -1333, + -1333, -1333, -1333, -1333, -902, -1333, -901, -1333, -896, -1333, + -893, -1333, -891, -1333, -1333, -1333, -630, -1333, -1333, -1333, + -666, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -26, + -1333, -1333, -1333, -1333, -1333, -1333, -1333, -1333, -890, -1333, + -1333, 527, -1333, -1333, -1333, -1333, -1333, -284, -1333, -1333, + -1333, -1333, -1333, -1333, 528, -1333, -11, 3, 1663, -1333, + -7, -1333, 1085, -1333, -880, -1333, -1333, -1333, 1301, -1333, + -1333, -1333, -1333, 544, -1043, -1333, -1333, -1333, -1333, 716, + -1333, -1333, 329, -1333, -570, -1333, -1333, -1333, -872, -1333, + 308, -1333, -1333, -1333, -1333, -1333, -1333, -1333, 4, -1333, + 180, -1333, 745, -1333, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -1333, -834, -1333, -1333, -1333, -871, + -1333, -1333, -1333, -1333, -1333, -1333, 263, 858, -1333, -1333, + -1333, -517, -1333, -1333, -1333, -1333, -1202, -181, -428, -1333, + -1333, -1333, -1333, -1333, -1109, -1333, -1333, -1333, -1333, -1333, + -99, -514, -1097, -1333, -1333, -1333, -1333, -1333, -1332, -1333, + -1333, -1333, -1227, -1333, -420, -1333, -1333, -1333, -1333, -1333, + -665, -1333, 769, -1333, -193, -1333, -209, -1333, 90, -1333, + -1333, -1333, -1333, 355, -1333, 903, 128, -1025, -1333, -1333, + -1333, -141, -1333, -242, -1333, -287, -1333, -1333, -1333, 55, + 123, -674, -1333, -502, -1333, -1333, -1333, -1333, -1333, -1333, + 813, -1333, 472, -1333, -1333, -1333, -1333, -1333, -251, -1333, + -1333, -560, -1333, -582, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, -83, 105, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, -1333, 656, -864, -1333, -1333, -1333, 830, -1333, + -1333, -1333, -155, -1333, -210, -1333, -1333, -113, -1333, -1333, + -1333, -105, -1333, -889, -1333, -213, -1333, -803, -1333, -1333, + -1333, -874, -1333, -1333, -1333, -1333, -679, -882, 502, -1333, + -1333, -1333, -699, -1333, 767, -1333, -1333, -1333, -1333, -1333, + 845, 339, -1333, -942, -1333, -1333, -1333, -1333, -1333, -1333, + -1333, -1333, 902, -1333, 141, -1333, -1333, -44, -1333, -1333, + -1333, -1333, 213, -1333, -1333, -1333, 411, -1333, -1333, -1333, + -1333, -1333, -1333, -1333, -189, -1333, -363, -1333, -1333, -214, + 873, -1333, -1333, -1333, -1333, -1333, -195, -1333, -1300, -1333, + -1333, -1333, -1333, 904, -1333, 712, -1333, -1333, -1333, -1333, + -706, -1333, -1248, -1333, -1333, -1333, -1333, -1333, -980, -186, + -1333, -1333, -1333, -912, -1333, -1333, -1333, -1333, -467, -1333, + -1089, 1032, -1333, -1333, -241, 742, -1333, -1333, -235, -1333, + -1333, -1333, -1333, -1333, -770, -1333, -1333, -1333, 727, -1333, + -1333, -1333, 203, -1333, -1333, -1333, -1333, -1333, 1551, 12, + 347, -1333 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -2692,705 +2666,702 @@ number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -1 -static const yytype_uint16 yytable[] = -{ - 41, 592, 275, 883, 261, 273, 785, 1147, 756, 514, - 232, 1027, 771, 52, 51, 1351, 803, 1001, 54, 892, - 260, 1036, 71, 1148, 1236, 1038, 1039, 1005, 97, 1288, - 648, 1040, 99, 105, 1041, 46, 40, 656, 1044, 658, - 864, 1290, 23, 250, 1138, 1023, 312, 335, 317, 3, - 1058, 1419, 1057, 28, 1082, 28, 1081, 1102, 1059, 345, - 1031, 1093, 1083, 1084, 1118, 23, 3, 3, 138, 3, - 28, 183, 23, 151, 3, 28, 183, 23, 331, 3, - 853, 1270, 417, 23, 3, 1022, 1138, 1133, 159, 3, - 942, 1243, 162, 1486, 1516, 28, 164, 28, 1275, 881, - 165, 1092, 167, 23, 3, 182, 184, 3, 190, 191, - 192, 3, 1482, 608, 673, 28, 3, 3, 1528, 28, - 1384, 67, 193, 1028, 196, 609, 1432, 1062, 1505, 163, - 988, 1087, 203, 1155, 1189, 1296, 844, 735, 845, 737, - 739, 741, 843, 187, 19, 887, 843, 37, 28, 11, - 1531, 681, 28, 1355, 219, 3, 642, 1, 1213, 681, - 37, 964, 200, 681, 201, 908, 929, 643, 20, 1220, - 226, 869, 681, 20, 229, 920, 20, 1385, 20, 3, - 1216, 612, 242, 243, 244, 245, 247, 252, 258, 265, - 270, 274, 1577, 1000, 1488, 194, 1510, 20, 169, 251, - 1512, 1216, 115, 988, 1371, 20, 114, 32, 114, 466, - 309, 62, 314, 643, 993, 613, 323, 1196, 20, 62, - 20, 62, 20, 771, 1580, 1197, 114, 754, 277, 278, - 114, 320, 32, 4, 1285, 1088, 299, 1253, 1241, 1251, - 677, 940, 1139, 20, 1242, 1254, 1255, 62, 1260, 20, - 4, 4, 869, 346, 1496, 1496, 161, 321, 3, 114, - 62, 1042, 1108, 4, 20, 1114, 1000, 754, 4, 194, - 347, 20, 384, 4, 1303, 62, 348, 1228, 351, 747, - 28, 1557, 357, 1285, 1139, 754, 1286, 1286, 4, 687, - 171, 4, 264, 1386, 264, 4, 1309, 170, 256, 257, - 4, 4, 209, 1502, 371, 370, 373, 372, 375, 374, - 1329, 376, 377, 1246, 1500, 1599, 380, 379, 382, 381, - 24, 5, 681, 20, 383, 228, 1350, 386, 20, 20, - 1583, 20, 367, 368, 369, 1223, 650, 173, 24, 4, - 681, 20, 401, 657, 20, 3, 20, 947, 1478, 1369, - 1465, 1367, 1379, 5, 1378, 268, 7, 1370, 20, 20, - 14, 20, 62, 781, 29, 677, 296, 412, 1383, 1544, - 437, 453, 20, 463, 1607, 647, 42, 43, 472, 385, - 473, 20, 474, 1394, 1397, 477, 20, 1174, 1184, 53, - 1449, 114, 20, 410, 20, 322, 67, 5, 339, 62, - 673, 1403, 98, 1491, 1566, 343, 112, 113, 20, 20, - 20, 69, 126, 127, 471, 130, 1568, 20, 1256, 1492, - 336, 337, 7, 17, 67, 20, 133, 20, 378, 1075, - 350, 1422, 608, 609, 30, 507, 754, 610, 840, 69, - 1425, 1429, 4, 23, 104, 20, 512, 936, 1424, 1428, - 513, 478, 69, 20, 62, 937, 7, 7, 7, 158, - 257, 160, 529, 1601, 28, 44, 20, 69, 407, 1384, - 48, 1550, 1459, 166, 479, 1603, 55, 94, 188, 339, - 554, 20, 518, 752, 611, 577, 148, 1552, 1016, 587, - 588, 681, 938, 168, 246, 480, 593, 481, 62, 596, - 612, 194, 1469, 600, 1473, 1487, 1275, 208, 197, 940, - 1468, 1264, 1472, 634, 1016, 1362, 168, 681, 37, 339, - 217, 234, 652, 613, 1051, 408, 409, 28, 308, 4, - 62, 936, 3, 603, 62, 1450, 239, 62, 62, 937, - 302, 225, 133, 305, 874, 1533, 1066, 20, 67, 475, - 476, 482, 1535, 397, 69, 1358, 1537, 1538, 1593, 255, - 1159, 685, 1539, 1522, 20, 1540, 686, 202, 20, 1542, - 62, 300, 301, 849, 1594, 134, 20, 1076, 1322, 688, - 1052, 895, 1456, 1323, 939, 1553, 319, 1276, 402, 218, - 673, 530, 1556, 940, 702, 670, 946, 894, 333, 705, - 218, 1401, 708, 67, 1053, 20, 714, 37, 62, 569, - 251, 911, 717, 912, 673, 614, 1265, 913, 681, 677, - 483, 728, 731, 732, 1289, 733, 734, 1266, 736, 738, - 740, 742, 743, 744, 63, 62, 677, 942, 114, 943, - 1574, 1582, 1386, 790, 745, 1055, 69, 748, 1573, 1079, - 760, 766, 1007, 776, 876, 782, 20, 796, 37, 807, - 20, 1076, 812, 7, 813, 988, 366, 816, 817, 1015, - 62, 353, 821, 822, 823, 354, 824, 1009, 1048, 67, - 946, 791, 792, 793, 794, 1605, 825, 673, 1174, 758, - 69, 134, 1122, 790, 62, 828, 452, 1095, 831, 104, - 774, 834, 836, 104, 20, 1130, 256, 257, 7, 7, - 754, 20, 1220, 400, 869, 1067, 4, 1151, 1181, 790, - 62, 850, 69, 20, 62, 840, 69, 1230, 869, 69, - 69, 791, 792, 793, 794, 1563, 20, 1161, 1162, 758, - 20, 1033, 62, 20, 20, 840, 62, 470, 1406, 692, - 693, 1163, 697, 698, 699, 1075, 1275, 791, 792, 793, - 794, 758, 69, 1016, 1016, 758, 355, 681, 62, 937, - 875, 1068, 1338, 936, 774, 681, 20, 1341, 938, 1137, - 62, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 1541, 1275, 910, 1136, 775, 62, 1406, 356, - 69, 757, 1432, 207, 62, 772, 938, 7, 1461, 788, - 795, 210, 1194, 1547, 20, 62, 7, 511, 938, 67, - 869, 1016, 101, 940, 681, 869, 20, 69, 62, 525, - 1588, 1239, 1193, 694, 818, 940, 315, 1276, 1200, 102, - 62, 20, 949, 67, 936, 977, 971, 1281, 972, 1355, - 1283, 62, 937, 979, 984, 457, 248, 986, 586, 987, - 795, 1187, 413, 991, 1201, 414, 994, 942, 995, 67, - 775, 996, 62, 67, 997, 939, 20, 998, 103, 1127, - 999, 458, 868, 20, 1004, 1190, 795, 459, 1011, 938, - 1012, 67, 1523, 1017, 1021, 67, 415, 1499, 1503, 1029, - 20, 62, 1035, 973, 8, 1054, 940, 1265, 1069, 1077, - 1091, 1034, 69, 1368, 1346, 1034, 69, 67, 1266, 418, - 758, 1051, 62, 440, 759, 978, 20, 1098, 974, 67, - 20, 1099, 898, 901, 904, 907, 419, 1034, 69, 696, - 297, 975, 1125, 1565, 626, 629, 222, 633, 20, 1115, - 639, 1129, 20, 3, 885, 1202, 62, 254, 820, 1121, - 69, 156, 1295, 1479, 67, 1140, 231, 1203, 1555, 1185, - 128, 1480, 69, 104, 20, 1244, 1204, 1052, 1146, 765, - 1333, 673, 259, 1150, 768, 1154, 20, 1372, 1400, 69, - 1335, 1337, 1405, 946, 1095, 1408, 69, 969, 1112, 1567, - 67, 1053, 1205, 20, 153, 155, 155, 69, 328, 1165, - 20, 992, 571, 806, 572, 921, 772, 118, 691, 681, - 69, 20, 1578, 172, 269, 1167, 1353, 266, 1409, 62, - 1612, 1622, 69, 1245, 20, 62, 937, 788, 1595, 1086, - 122, 713, 194, 69, 1354, 271, 20, 119, 421, 1344, - 67, 722, 725, 1313, 120, 1392, 573, 20, 1602, 839, - 574, 1314, 1402, 870, 69, 835, 1482, 788, 100, 106, - 123, 1191, 1192, 938, 788, 1206, 1261, 124, 20, 62, - 963, 880, 1224, 759, 1355, 1527, 1526, 1188, 1233, 276, - 111, 1238, 1249, 69, 575, 1259, 20, 889, 758, 1267, - 168, 1417, 576, 1274, 423, 238, 1280, 20, 1414, 1282, - 1284, 406, 1457, 1104, 69, 1109, 1109, 1455, 1104, 425, - 1285, 886, 1025, 1286, 1297, 1436, 681, 1300, 20, 0, - 1301, 1302, 1262, 1307, 0, 1308, 0, 4, 838, 1311, - 0, 1312, 0, 788, 0, 1316, 1315, 840, 69, 0, - 1318, 1317, 0, 1320, 1319, 1216, 0, 1324, 0, 422, - 0, 1331, 20, 0, 1332, 465, 0, 0, 204, 0, - 0, 0, 169, 0, 0, 0, 841, 0, 67, 0, - 1175, 1178, 0, 0, 67, 0, 810, 985, 0, 205, - 220, 0, 1349, 0, 0, 0, 1356, 7, 104, 7, - 7, 0, 7, 842, 1365, 170, 781, 1376, 677, 843, - 230, 365, 0, 0, 0, 968, 844, 0, 845, 0, - 0, 69, 171, 461, 0, 462, 0, 69, 67, 1519, - 846, 233, 1521, 0, 0, 20, 0, 0, 1387, 0, - 0, 20, 847, 0, 806, 172, 311, 1016, 316, 0, - 681, 0, 325, 848, 0, 0, 391, 394, 0, 0, - 0, 759, 1413, 897, 900, 903, 906, 313, 0, 318, - 1415, 69, 563, 329, 1418, 7, 0, 543, 0, 0, - 1420, 0, 849, 173, 788, 20, 0, 62, 0, 544, - 0, 890, 0, 7, 545, 7, 7, 7, 7, 7, - 7, 0, 0, 0, 1431, 478, 1571, 0, 0, 1434, - 546, 1437, 0, 0, 1126, 1440, 0, 1443, 358, 0, - 1445, 0, 1447, 1451, 0, 0, 1330, 1454, 479, 494, - 495, 496, 497, 498, 499, 500, 501, 502, 503, 363, - 0, 0, 62, 937, 0, 1248, 0, 608, 609, 480, - 1464, 481, 610, 0, 547, 506, 0, 1466, 0, 0, - 1471, 1600, 0, 387, 508, 0, 1476, 0, 0, 548, - 549, 0, 478, 1157, 1490, 0, 0, 0, 625, 628, - 938, 632, 0, 0, 638, 1495, 1497, 1501, 0, 1504, - 1616, 1506, 0, 788, 788, 479, 1508, 940, 1509, 611, - 0, 1621, 1511, 416, 0, 482, 438, 454, 1514, 464, - 0, 1006, 1051, 0, 1517, 612, 480, 1520, 481, 0, - 1020, 1024, 7, 7, 424, 0, 1032, 451, 456, 0, - 467, 0, 0, 1534, 0, 0, 67, 1094, 613, 751, - 0, 1103, 763, 0, 550, 780, 0, 0, 1119, 805, - 788, 788, 690, 0, 0, 0, 0, 0, 0, 700, - 551, 0, 0, 0, 1559, 0, 0, 0, 1560, 1561, - 0, 1562, 482, 0, 483, 712, 0, 0, 0, 69, - 0, 1175, 788, 0, 0, 721, 724, 552, 1564, 553, - 1569, 67, 1053, 20, 0, 0, 0, 0, 0, 0, - 0, 0, 1581, 0, 1306, 0, 0, 0, 1585, 0, - 0, 0, 788, 860, 788, 0, 556, 0, 0, 0, - 0, 578, 59, 60, 0, 0, 1591, 0, 1321, 1592, - 61, 62, 0, 1597, 69, 0, 63, 566, 0, 0, - 0, 483, 585, 0, 0, 0, 1493, 1494, 20, 635, - 0, 0, 10, 0, 0, 13, 16, 0, 20, 1608, - 0, 1609, 64, 516, 0, 519, 522, 0, 526, 0, - 636, 1614, 837, 1615, 0, 0, 0, 65, 0, 1617, - 0, 1618, 0, 0, 411, 1619, 1620, 0, 59, 60, - 0, 1624, 0, 0, 0, 0, 61, 62, 1625, 0, - 589, 0, 63, 1218, 0, 0, 594, 0, 0, 0, - 597, 0, 0, 601, 0, 605, 608, 609, 10, 0, - 132, 610, 0, 139, 140, 141, 142, 0, 64, 0, - 703, 143, 144, 145, 146, 706, 0, 0, 709, 0, - 0, 0, 715, 65, 0, 0, 0, 0, 718, 0, - 788, 704, 10, 10, 10, 0, 707, 729, 1304, 710, - 66, 0, 1310, 716, 0, 0, 936, 0, 611, 719, - 0, 0, 0, 62, 937, 0, 0, 0, 730, 0, - 67, 0, 186, 749, 612, 0, 761, 767, 0, 777, - 0, 783, 0, 798, 1045, 808, 0, 1064, 0, 0, - 814, 1089, 0, 0, 753, 0, 0, 613, 770, 0, - 68, 938, 786, 0, 0, 0, 811, 0, 0, 0, - 939, 815, 826, 69, 0, 0, 66, 0, 940, 0, - 70, 829, 0, 0, 832, 0, 0, 20, 0, 0, - 0, 0, 0, 827, 0, 922, 67, 926, 926, 0, - 931, 0, 830, 0, 0, 833, 0, 852, 0, 941, - 0, 0, 0, 0, 0, 0, 0, 1395, 1398, 0, - 0, 0, 942, 0, 943, 298, 68, 1404, 865, 517, - 0, 520, 523, 0, 527, 0, 944, 0, 0, 69, - 0, 84, 85, 86, 0, 945, 70, 0, 0, 614, - 0, 0, 0, 20, 0, 0, 0, 0, 1546, 87, - 88, 89, 0, 0, 0, 946, 590, 1169, 0, 0, - 0, 0, 595, 1026, 1426, 1430, 598, 0, 0, 602, - 0, 606, 0, 0, 947, 0, 847, 0, 90, 91, - 92, 394, 0, 1106, 926, 1110, 1110, 926, 1106, 0, - 0, 0, 0, 0, 0, 759, 1460, 0, 0, 10, - 0, 0, 0, 0, 1198, 69, 0, 0, 0, 0, - 0, 0, 0, 0, 1226, 0, 0, 948, 951, 20, - 1235, 0, 0, 62, 1257, 0, 1470, 659, 1474, 980, - 0, 0, 0, 1586, 1587, 1485, 0, 660, 0, 965, - 0, 0, 0, 661, 10, 10, 0, 662, 0, 0, - 983, 663, 0, 426, 0, 0, 0, 0, 664, 0, - 665, 0, 427, 354, 0, 0, 1013, 428, 429, 0, - 666, 667, 668, 0, 1610, 0, 0, 0, 1037, 0, - 0, 1056, 0, 0, 1071, 1080, 430, 1014, 431, 0, - 0, 0, 1530, 0, 0, 0, 0, 0, 0, 1047, - 0, 0, 1065, 0, 0, 1073, 1090, 0, 0, 0, - 926, 506, 0, 0, 0, 0, 0, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 1361, 0, - 0, 432, 433, 0, 0, 0, 1373, 0, 0, 1380, - 0, 434, 435, 10, 0, 0, 0, 0, 0, 0, - 0, 0, 10, 279, 0, 0, 280, 0, 0, 0, - 281, 282, 283, 284, 1575, 285, 1579, 286, 287, 0, - 0, 288, 0, 0, 0, 0, 0, 0, 436, 289, - 0, 0, 0, 0, 0, 0, 0, 0, 290, 0, - 0, 0, 0, 0, 291, 0, 0, 0, 0, 0, - 292, 1168, 293, 0, 0, 0, 0, 294, 0, 0, - 0, 0, 0, 0, 0, 69, 0, 0, 0, 0, - 0, 0, 1170, 0, 0, 0, 0, 0, 0, 20, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1435, 0, 1438, 0, 0, 0, 1441, 1195, 1444, - 0, 1208, 1446, 0, 1448, 0, 0, 0, 1225, 0, - 0, 0, 0, 0, 1234, 0, 0, 1240, 1250, 1199, - 0, 0, 1215, 0, 0, 1269, 0, 0, 0, 1227, - 0, 0, 0, 0, 0, 1237, 0, 0, 1247, 1258, - 0, 0, 0, 0, 0, 0, 1273, 532, 533, 534, - 535, 536, 537, 539, 540, 541, 542, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1325, 607, 0, 0, 0, 630, 0, - 0, 0, 0, 640, 641, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1328, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1543, 0, 0, 0, 0, - 0, 0, 1357, 0, 0, 0, 0, 0, 0, 0, - 1366, 0, 0, 1377, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1364, 0, 0, 0, 0, 0, 0, - 0, 1374, 0, 0, 1381, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1570, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 0, 10, 10, 0, 10, 0, - 0, 0, 1477, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1481, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1536, - 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, - 1545, 10, 10, 10, 10, 10, 10, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1173, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 10, 10 +static const yytype_uint16 yytable[] = { + 41, 592, 275, 883, 261, 273, 785, 1147, 756, 514, + 232, 1027, 771, 52, 51, 1351, 803, 1001, 54, 892, + 260, 1036, 71, 1148, 1236, 1038, 1039, 1005, 97, 1288, + 648, 1040, 99, 105, 1041, 46, 40, 656, 1044, 658, + 864, 1290, 23, 250, 1138, 1023, 312, 335, 317, 3, + 1058, 1419, 1057, 28, 1082, 28, 1081, 1102, 1059, 345, + 1031, 1093, 1083, 1084, 1118, 23, 3, 3, 138, 3, + 28, 183, 23, 151, 3, 28, 183, 23, 331, 3, + 853, 1270, 417, 23, 3, 1022, 1138, 1133, 159, 3, + 942, 1243, 162, 1486, 1516, 28, 164, 28, 1275, 881, + 165, 1092, 167, 23, 3, 182, 184, 3, 190, 191, + 192, 3, 1482, 608, 673, 28, 3, 3, 1528, 28, + 1384, 67, 193, 1028, 196, 609, 1432, 1062, 1505, 163, + 988, 1087, 203, 1155, 1189, 1296, 844, 735, 845, 737, + 739, 741, 843, 187, 19, 887, 843, 37, 28, 11, + 1531, 681, 28, 1355, 219, 3, 642, 1, 1213, 681, + 37, 964, 200, 681, 201, 908, 929, 643, 20, 1220, + 226, 869, 681, 20, 229, 920, 20, 1385, 20, 3, + 1216, 612, 242, 243, 244, 245, 247, 252, 258, 265, + 270, 274, 1577, 1000, 1488, 194, 1510, 20, 169, 251, + 1512, 1216, 115, 988, 1371, 20, 114, 32, 114, 466, + 309, 62, 314, 643, 993, 613, 323, 1196, 20, 62, + 20, 62, 20, 771, 1580, 1197, 114, 754, 277, 278, + 114, 320, 32, 4, 1285, 1088, 299, 1253, 1241, 1251, + 677, 940, 1139, 20, 1242, 1254, 1255, 62, 1260, 20, + 4, 4, 869, 346, 1496, 1496, 161, 321, 3, 114, + 62, 1042, 1108, 4, 20, 1114, 1000, 754, 4, 194, + 347, 20, 384, 4, 1303, 62, 348, 1228, 351, 747, + 28, 1557, 357, 1285, 1139, 754, 1286, 1286, 4, 687, + 171, 4, 264, 1386, 264, 4, 1309, 170, 256, 257, + 4, 4, 209, 1502, 371, 370, 373, 372, 375, 374, + 1329, 376, 377, 1246, 1500, 1599, 380, 379, 382, 381, + 24, 5, 681, 20, 383, 228, 1350, 386, 20, 20, + 1583, 20, 367, 368, 369, 1223, 650, 173, 24, 4, + 681, 20, 401, 657, 20, 3, 20, 947, 1478, 1369, + 1465, 1367, 1379, 5, 1378, 268, 7, 1370, 20, 20, + 14, 20, 62, 781, 29, 677, 296, 412, 1383, 1544, + 437, 453, 20, 463, 1607, 647, 42, 43, 472, 385, + 473, 20, 474, 1394, 1397, 477, 20, 1174, 1184, 53, + 1449, 114, 20, 410, 20, 322, 67, 5, 339, 62, + 673, 1403, 98, 1491, 1566, 343, 112, 113, 20, 20, + 20, 69, 126, 127, 471, 130, 1568, 20, 1256, 1492, + 336, 337, 7, 17, 67, 20, 133, 20, 378, 1075, + 350, 1422, 608, 609, 30, 507, 754, 610, 840, 69, + 1425, 1429, 4, 23, 104, 20, 512, 936, 1424, 1428, + 513, 478, 69, 20, 62, 937, 7, 7, 7, 158, + 257, 160, 529, 1601, 28, 44, 20, 69, 407, 1384, + 48, 1550, 1459, 166, 479, 1603, 55, 94, 188, 339, + 554, 20, 518, 752, 611, 577, 148, 1552, 1016, 587, + 588, 681, 938, 168, 246, 480, 593, 481, 62, 596, + 612, 194, 1469, 600, 1473, 1487, 1275, 208, 197, 940, + 1468, 1264, 1472, 634, 1016, 1362, 168, 681, 37, 339, + 217, 234, 652, 613, 1051, 408, 409, 28, 308, 4, + 62, 936, 3, 603, 62, 1450, 239, 62, 62, 937, + 302, 225, 133, 305, 874, 1533, 1066, 20, 67, 475, + 476, 482, 1535, 397, 69, 1358, 1537, 1538, 1593, 255, + 1159, 685, 1539, 1522, 20, 1540, 686, 202, 20, 1542, + 62, 300, 301, 849, 1594, 134, 20, 1076, 1322, 688, + 1052, 895, 1456, 1323, 939, 1553, 319, 1276, 402, 218, + 673, 530, 1556, 940, 702, 670, 946, 894, 333, 705, + 218, 1401, 708, 67, 1053, 20, 714, 37, 62, 569, + 251, 911, 717, 912, 673, 614, 1265, 913, 681, 677, + 483, 728, 731, 732, 1289, 733, 734, 1266, 736, 738, + 740, 742, 743, 744, 63, 62, 677, 942, 114, 943, + 1574, 1582, 1386, 790, 745, 1055, 69, 748, 1573, 1079, + 760, 766, 1007, 776, 876, 782, 20, 796, 37, 807, + 20, 1076, 812, 7, 813, 988, 366, 816, 817, 1015, + 62, 353, 821, 822, 823, 354, 824, 1009, 1048, 67, + 946, 791, 792, 793, 794, 1605, 825, 673, 1174, 758, + 69, 134, 1122, 790, 62, 828, 452, 1095, 831, 104, + 774, 834, 836, 104, 20, 1130, 256, 257, 7, 7, + 754, 20, 1220, 400, 869, 1067, 4, 1151, 1181, 790, + 62, 850, 69, 20, 62, 840, 69, 1230, 869, 69, + 69, 791, 792, 793, 794, 1563, 20, 1161, 1162, 758, + 20, 1033, 62, 20, 20, 840, 62, 470, 1406, 692, + 693, 1163, 697, 698, 699, 1075, 1275, 791, 792, 793, + 794, 758, 69, 1016, 1016, 758, 355, 681, 62, 937, + 875, 1068, 1338, 936, 774, 681, 20, 1341, 938, 1137, + 62, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 1541, 1275, 910, 1136, 775, 62, 1406, 356, + 69, 757, 1432, 207, 62, 772, 938, 7, 1461, 788, + 795, 210, 1194, 1547, 20, 62, 7, 511, 938, 67, + 869, 1016, 101, 940, 681, 869, 20, 69, 62, 525, + 1588, 1239, 1193, 694, 818, 940, 315, 1276, 1200, 102, + 62, 20, 949, 67, 936, 977, 971, 1281, 972, 1355, + 1283, 62, 937, 979, 984, 457, 248, 986, 586, 987, + 795, 1187, 413, 991, 1201, 414, 994, 942, 995, 67, + 775, 996, 62, 67, 997, 939, 20, 998, 103, 1127, + 999, 458, 868, 20, 1004, 1190, 795, 459, 1011, 938, + 1012, 67, 1523, 1017, 1021, 67, 415, 1499, 1503, 1029, + 20, 62, 1035, 973, 8, 1054, 940, 1265, 1069, 1077, + 1091, 1034, 69, 1368, 1346, 1034, 69, 67, 1266, 418, + 758, 1051, 62, 440, 759, 978, 20, 1098, 974, 67, + 20, 1099, 898, 901, 904, 907, 419, 1034, 69, 696, + 297, 975, 1125, 1565, 626, 629, 222, 633, 20, 1115, + 639, 1129, 20, 3, 885, 1202, 62, 254, 820, 1121, + 69, 156, 1295, 1479, 67, 1140, 231, 1203, 1555, 1185, + 128, 1480, 69, 104, 20, 1244, 1204, 1052, 1146, 765, + 1333, 673, 259, 1150, 768, 1154, 20, 1372, 1400, 69, + 1335, 1337, 1405, 946, 1095, 1408, 69, 969, 1112, 1567, + 67, 1053, 1205, 20, 153, 155, 155, 69, 328, 1165, + 20, 992, 571, 806, 572, 921, 772, 118, 691, 681, + 69, 20, 1578, 172, 269, 1167, 1353, 266, 1409, 62, + 1612, 1622, 69, 1245, 20, 62, 937, 788, 1595, 1086, + 122, 713, 194, 69, 1354, 271, 20, 119, 421, 1344, + 67, 722, 725, 1313, 120, 1392, 573, 20, 1602, 839, + 574, 1314, 1402, 870, 69, 835, 1482, 788, 100, 106, + 123, 1191, 1192, 938, 788, 1206, 1261, 124, 20, 62, + 963, 880, 1224, 759, 1355, 1527, 1526, 1188, 1233, 276, + 111, 1238, 1249, 69, 575, 1259, 20, 889, 758, 1267, + 168, 1417, 576, 1274, 423, 238, 1280, 20, 1414, 1282, + 1284, 406, 1457, 1104, 69, 1109, 1109, 1455, 1104, 425, + 1285, 886, 1025, 1286, 1297, 1436, 681, 1300, 20, 0, + 1301, 1302, 1262, 1307, 0, 1308, 0, 4, 838, 1311, + 0, 1312, 0, 788, 0, 1316, 1315, 840, 69, 0, + 1318, 1317, 0, 1320, 1319, 1216, 0, 1324, 0, 422, + 0, 1331, 20, 0, 1332, 465, 0, 0, 204, 0, + 0, 0, 169, 0, 0, 0, 841, 0, 67, 0, + 1175, 1178, 0, 0, 67, 0, 810, 985, 0, 205, + 220, 0, 1349, 0, 0, 0, 1356, 7, 104, 7, + 7, 0, 7, 842, 1365, 170, 781, 1376, 677, 843, + 230, 365, 0, 0, 0, 968, 844, 0, 845, 0, + 0, 69, 171, 461, 0, 462, 0, 69, 67, 1519, + 846, 233, 1521, 0, 0, 20, 0, 0, 1387, 0, + 0, 20, 847, 0, 806, 172, 311, 1016, 316, 0, + 681, 0, 325, 848, 0, 0, 391, 394, 0, 0, + 0, 759, 1413, 897, 900, 903, 906, 313, 0, 318, + 1415, 69, 563, 329, 1418, 7, 0, 543, 0, 0, + 1420, 0, 849, 173, 788, 20, 0, 62, 0, 544, + 0, 890, 0, 7, 545, 7, 7, 7, 7, 7, + 7, 0, 0, 0, 1431, 478, 1571, 0, 0, 1434, + 546, 1437, 0, 0, 1126, 1440, 0, 1443, 358, 0, + 1445, 0, 1447, 1451, 0, 0, 1330, 1454, 479, 494, + 495, 496, 497, 498, 499, 500, 501, 502, 503, 363, + 0, 0, 62, 937, 0, 1248, 0, 608, 609, 480, + 1464, 481, 610, 0, 547, 506, 0, 1466, 0, 0, + 1471, 1600, 0, 387, 508, 0, 1476, 0, 0, 548, + 549, 0, 478, 1157, 1490, 0, 0, 0, 625, 628, + 938, 632, 0, 0, 638, 1495, 1497, 1501, 0, 1504, + 1616, 1506, 0, 788, 788, 479, 1508, 940, 1509, 611, + 0, 1621, 1511, 416, 0, 482, 438, 454, 1514, 464, + 0, 1006, 1051, 0, 1517, 612, 480, 1520, 481, 0, + 1020, 1024, 7, 7, 424, 0, 1032, 451, 456, 0, + 467, 0, 0, 1534, 0, 0, 67, 1094, 613, 751, + 0, 1103, 763, 0, 550, 780, 0, 0, 1119, 805, + 788, 788, 690, 0, 0, 0, 0, 0, 0, 700, + 551, 0, 0, 0, 1559, 0, 0, 0, 1560, 1561, + 0, 1562, 482, 0, 483, 712, 0, 0, 0, 69, + 0, 1175, 788, 0, 0, 721, 724, 552, 1564, 553, + 1569, 67, 1053, 20, 0, 0, 0, 0, 0, 0, + 0, 0, 1581, 0, 1306, 0, 0, 0, 1585, 0, + 0, 0, 788, 860, 788, 0, 556, 0, 0, 0, + 0, 578, 59, 60, 0, 0, 1591, 0, 1321, 1592, + 61, 62, 0, 1597, 69, 0, 63, 566, 0, 0, + 0, 483, 585, 0, 0, 0, 1493, 1494, 20, 635, + 0, 0, 10, 0, 0, 13, 16, 0, 20, 1608, + 0, 1609, 64, 516, 0, 519, 522, 0, 526, 0, + 636, 1614, 837, 1615, 0, 0, 0, 65, 0, 1617, + 0, 1618, 0, 0, 411, 1619, 1620, 0, 59, 60, + 0, 1624, 0, 0, 0, 0, 61, 62, 1625, 0, + 589, 0, 63, 1218, 0, 0, 594, 0, 0, 0, + 597, 0, 0, 601, 0, 605, 608, 609, 10, 0, + 132, 610, 0, 139, 140, 141, 142, 0, 64, 0, + 703, 143, 144, 145, 146, 706, 0, 0, 709, 0, + 0, 0, 715, 65, 0, 0, 0, 0, 718, 0, + 788, 704, 10, 10, 10, 0, 707, 729, 1304, 710, + 66, 0, 1310, 716, 0, 0, 936, 0, 611, 719, + 0, 0, 0, 62, 937, 0, 0, 0, 730, 0, + 67, 0, 186, 749, 612, 0, 761, 767, 0, 777, + 0, 783, 0, 798, 1045, 808, 0, 1064, 0, 0, + 814, 1089, 0, 0, 753, 0, 0, 613, 770, 0, + 68, 938, 786, 0, 0, 0, 811, 0, 0, 0, + 939, 815, 826, 69, 0, 0, 66, 0, 940, 0, + 70, 829, 0, 0, 832, 0, 0, 20, 0, 0, + 0, 0, 0, 827, 0, 922, 67, 926, 926, 0, + 931, 0, 830, 0, 0, 833, 0, 852, 0, 941, + 0, 0, 0, 0, 0, 0, 0, 1395, 1398, 0, + 0, 0, 942, 0, 943, 298, 68, 1404, 865, 517, + 0, 520, 523, 0, 527, 0, 944, 0, 0, 69, + 0, 84, 85, 86, 0, 945, 70, 0, 0, 614, + 0, 0, 0, 20, 0, 0, 0, 0, 1546, 87, + 88, 89, 0, 0, 0, 946, 590, 1169, 0, 0, + 0, 0, 595, 1026, 1426, 1430, 598, 0, 0, 602, + 0, 606, 0, 0, 947, 0, 847, 0, 90, 91, + 92, 394, 0, 1106, 926, 1110, 1110, 926, 1106, 0, + 0, 0, 0, 0, 0, 759, 1460, 0, 0, 10, + 0, 0, 0, 0, 1198, 69, 0, 0, 0, 0, + 0, 0, 0, 0, 1226, 0, 0, 948, 951, 20, + 1235, 0, 0, 62, 1257, 0, 1470, 659, 1474, 980, + 0, 0, 0, 1586, 1587, 1485, 0, 660, 0, 965, + 0, 0, 0, 661, 10, 10, 0, 662, 0, 0, + 983, 663, 0, 426, 0, 0, 0, 0, 664, 0, + 665, 0, 427, 354, 0, 0, 1013, 428, 429, 0, + 666, 667, 668, 0, 1610, 0, 0, 0, 1037, 0, + 0, 1056, 0, 0, 1071, 1080, 430, 1014, 431, 0, + 0, 0, 1530, 0, 0, 0, 0, 0, 0, 1047, + 0, 0, 1065, 0, 0, 1073, 1090, 0, 0, 0, + 926, 506, 0, 0, 0, 0, 0, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 1361, 0, + 0, 432, 433, 0, 0, 0, 1373, 0, 0, 1380, + 0, 434, 435, 10, 0, 0, 0, 0, 0, 0, + 0, 0, 10, 279, 0, 0, 280, 0, 0, 0, + 281, 282, 283, 284, 1575, 285, 1579, 286, 287, 0, + 0, 288, 0, 0, 0, 0, 0, 0, 436, 289, + 0, 0, 0, 0, 0, 0, 0, 0, 290, 0, + 0, 0, 0, 0, 291, 0, 0, 0, 0, 0, + 292, 1168, 293, 0, 0, 0, 0, 294, 0, 0, + 0, 0, 0, 0, 0, 69, 0, 0, 0, 0, + 0, 0, 1170, 0, 0, 0, 0, 0, 0, 20, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1435, 0, 1438, 0, 0, 0, 1441, 1195, 1444, + 0, 1208, 1446, 0, 1448, 0, 0, 0, 1225, 0, + 0, 0, 0, 0, 1234, 0, 0, 1240, 1250, 1199, + 0, 0, 1215, 0, 0, 1269, 0, 0, 0, 1227, + 0, 0, 0, 0, 0, 1237, 0, 0, 1247, 1258, + 0, 0, 0, 0, 0, 0, 1273, 532, 533, 534, + 535, 536, 537, 539, 540, 541, 542, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1325, 607, 0, 0, 0, 630, 0, + 0, 0, 0, 640, 641, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1328, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1543, 0, 0, 0, 0, + 0, 0, 1357, 0, 0, 0, 0, 0, 0, 0, + 1366, 0, 0, 1377, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1364, 0, 0, 0, 0, 0, 0, + 0, 1374, 0, 0, 1381, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1570, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, 10, 10, 0, 10, 0, + 0, 0, 1477, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1481, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1536, + 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, + 1545, 10, 10, 10, 10, 10, 10, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1173, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 10, 10 }; -static const yytype_int16 yycheck[] = -{ - 25, 518, 216, 773, 213, 215, 680, 1003, 673, 476, - 199, 923, 677, 39, 39, 1217, 682, 908, 43, 789, - 213, 927, 47, 1003, 1113, 927, 927, 909, 53, 1138, - 544, 927, 57, 58, 927, 32, 24, 551, 927, 553, - 746, 1138, 6, 211, 75, 919, 235, 256, 237, 3, - 930, 1299, 930, 4, 934, 4, 934, 939, 930, 269, - 924, 935, 934, 934, 946, 6, 3, 3, 93, 3, - 4, 5, 6, 98, 3, 4, 5, 6, 246, 3, - 746, 1124, 392, 6, 3, 919, 75, 978, 113, 3, - 188, 1116, 117, 1393, 66, 4, 121, 4, 122, 773, - 125, 935, 127, 6, 3, 130, 131, 3, 133, 134, - 135, 3, 176, 71, 148, 4, 3, 3, 1450, 4, - 86, 238, 147, 196, 149, 72, 178, 930, 255, 117, - 104, 934, 157, 1015, 1076, 257, 226, 651, 228, 653, - 654, 655, 219, 131, 111, 775, 219, 19, 4, 0, - 1450, 236, 4, 272, 179, 3, 185, 116, 1100, 236, - 32, 867, 154, 236, 156, 795, 845, 242, 295, 284, - 195, 286, 236, 295, 199, 67, 295, 143, 295, 3, - 265, 139, 207, 208, 209, 210, 211, 212, 213, 214, - 215, 216, 1524, 167, 1396, 241, 1423, 295, 149, 150, - 1427, 265, 61, 104, 1229, 295, 115, 131, 115, 398, - 235, 89, 237, 242, 888, 162, 241, 1097, 295, 89, - 295, 89, 295, 888, 1524, 1097, 115, 181, 216, 217, - 115, 73, 131, 187, 170, 934, 224, 1117, 1116, 1117, - 194, 144, 273, 295, 1116, 1117, 1117, 89, 1120, 295, - 187, 187, 286, 278, 141, 141, 115, 99, 3, 115, - 89, 927, 941, 187, 295, 944, 167, 181, 187, 241, - 295, 295, 140, 187, 1156, 89, 301, 1111, 303, 93, - 4, 1483, 307, 170, 273, 181, 173, 173, 187, 599, - 199, 187, 201, 259, 201, 187, 1160, 182, 183, 184, - 187, 187, 161, 1412, 330, 330, 332, 332, 334, 334, - 1184, 336, 337, 1116, 1411, 1563, 342, 342, 344, 344, - 261, 245, 236, 295, 349, 197, 1217, 352, 295, 295, - 1532, 295, 320, 321, 322, 1105, 545, 260, 261, 187, - 236, 295, 367, 552, 295, 3, 295, 250, 1391, 1229, - 1375, 1229, 1232, 245, 1232, 214, 1, 1229, 295, 295, - 5, 295, 89, 192, 17, 194, 295, 392, 1248, 1458, - 395, 396, 295, 398, 1576, 543, 29, 30, 403, 247, - 405, 295, 407, 1265, 1266, 410, 295, 1052, 1067, 42, - 121, 115, 295, 390, 295, 237, 238, 245, 257, 89, - 148, 1275, 55, 1399, 1513, 264, 59, 60, 295, 295, - 295, 281, 65, 66, 402, 68, 1513, 295, 1117, 1399, - 276, 277, 67, 118, 238, 295, 126, 295, 338, 64, - 302, 1321, 71, 72, 117, 460, 181, 76, 157, 281, - 1322, 1323, 187, 6, 258, 295, 471, 82, 1322, 1323, - 475, 109, 281, 295, 89, 90, 101, 102, 103, 112, - 184, 114, 487, 1572, 4, 161, 295, 281, 378, 86, - 158, 1467, 1354, 126, 132, 1572, 160, 205, 131, 338, - 505, 295, 479, 672, 123, 510, 206, 1467, 233, 514, - 515, 236, 127, 77, 78, 153, 521, 155, 89, 524, - 139, 241, 1384, 528, 1386, 1396, 122, 160, 84, 144, - 1384, 63, 1386, 538, 233, 1221, 77, 236, 390, 378, - 210, 267, 547, 162, 159, 384, 385, 4, 83, 187, - 89, 82, 3, 530, 89, 266, 270, 89, 89, 90, - 164, 194, 126, 200, 758, 1457, 65, 295, 238, 408, - 409, 209, 1458, 85, 281, 1221, 1458, 1458, 1554, 212, - 1027, 586, 1458, 180, 295, 1458, 591, 294, 295, 1458, - 89, 224, 225, 292, 1554, 275, 295, 212, 169, 604, - 215, 790, 1352, 174, 136, 1475, 239, 203, 282, 279, - 148, 130, 1483, 144, 619, 151, 231, 790, 251, 624, - 279, 1275, 627, 238, 239, 295, 631, 479, 89, 287, - 150, 68, 637, 70, 148, 254, 168, 74, 236, 194, - 278, 646, 647, 648, 1138, 650, 651, 179, 653, 654, - 655, 656, 657, 658, 94, 89, 194, 188, 115, 190, - 1522, 1532, 259, 62, 669, 930, 281, 672, 1522, 934, - 675, 676, 221, 678, 106, 680, 295, 682, 530, 684, - 295, 212, 687, 308, 689, 104, 319, 692, 693, 138, - 89, 125, 697, 698, 699, 129, 701, 256, 166, 238, - 231, 100, 101, 102, 103, 1576, 711, 148, 1353, 108, - 281, 275, 274, 62, 89, 720, 177, 243, 723, 258, - 95, 726, 727, 258, 295, 269, 183, 184, 353, 354, - 181, 295, 284, 366, 286, 234, 187, 264, 98, 62, - 89, 746, 281, 295, 89, 157, 281, 165, 286, 281, - 281, 100, 101, 102, 103, 1505, 295, 26, 27, 108, - 295, 110, 89, 295, 295, 157, 89, 400, 114, 608, - 609, 40, 611, 612, 613, 64, 122, 100, 101, 102, - 103, 108, 281, 233, 233, 108, 220, 236, 89, 90, - 758, 290, 97, 82, 95, 236, 295, 224, 127, 988, - 89, 426, 427, 428, 429, 430, 431, 432, 433, 434, - 435, 436, 1458, 122, 819, 988, 191, 89, 114, 253, - 281, 673, 178, 158, 89, 677, 127, 452, 248, 681, - 229, 166, 1097, 249, 295, 89, 461, 470, 127, 238, - 286, 233, 107, 144, 236, 286, 295, 281, 89, 482, - 105, 1116, 1097, 610, 695, 144, 237, 203, 87, 124, - 89, 295, 867, 238, 82, 137, 871, 1131, 873, 272, - 1134, 89, 90, 878, 879, 23, 211, 882, 511, 884, - 229, 1075, 392, 888, 113, 392, 891, 188, 893, 238, - 191, 896, 89, 238, 899, 136, 295, 902, 163, 970, - 905, 49, 754, 295, 909, 1095, 229, 55, 913, 127, - 915, 238, 1449, 918, 919, 238, 392, 1411, 1412, 924, - 295, 89, 927, 9, 1, 930, 144, 168, 933, 934, - 935, 280, 281, 1229, 1205, 280, 281, 238, 179, 392, - 108, 159, 89, 395, 271, 217, 295, 938, 34, 238, - 295, 938, 791, 792, 793, 794, 392, 280, 281, 610, - 224, 47, 967, 1513, 533, 534, 179, 536, 295, 945, - 539, 976, 295, 3, 774, 204, 89, 212, 695, 947, - 281, 103, 1143, 1391, 238, 990, 199, 216, 1482, 1068, - 67, 1391, 281, 258, 295, 1116, 225, 215, 1003, 146, - 1190, 148, 213, 1008, 676, 1010, 295, 1229, 1275, 281, - 1200, 1201, 1276, 231, 243, 1279, 281, 869, 943, 1513, - 238, 239, 251, 295, 101, 102, 103, 281, 241, 1034, - 295, 888, 145, 230, 147, 842, 888, 20, 607, 236, - 281, 295, 1524, 222, 223, 1050, 214, 214, 1279, 89, - 1590, 1613, 281, 1116, 295, 89, 90, 909, 1555, 934, - 20, 630, 241, 281, 232, 215, 295, 50, 392, 1204, - 238, 640, 641, 1166, 57, 1264, 189, 295, 1572, 69, - 193, 1166, 1275, 755, 281, 726, 176, 939, 57, 58, - 50, 1096, 1097, 127, 946, 1100, 1120, 57, 295, 89, - 867, 773, 1107, 271, 272, 195, 1449, 1075, 1113, 216, - 58, 1116, 1117, 281, 227, 1120, 295, 789, 108, 1124, - 77, 1296, 235, 1128, 392, 201, 1131, 295, 1294, 1134, - 1135, 369, 1353, 940, 281, 942, 943, 1352, 945, 392, - 170, 774, 919, 173, 1149, 1335, 236, 1152, 295, -1, - 1155, 1156, 1120, 1158, -1, 1160, -1, 187, 727, 1164, - -1, 1166, -1, 1015, -1, 1171, 1171, 157, 281, -1, - 1176, 1176, -1, 1179, 1179, 265, -1, 1182, -1, 392, - -1, 1186, 295, -1, 1189, 398, -1, -1, 157, -1, - -1, -1, 149, -1, -1, -1, 186, -1, 238, -1, - 1052, 1053, -1, -1, 238, -1, 684, 879, -1, 157, - 179, -1, 1217, -1, -1, -1, 1221, 842, 258, 844, - 845, -1, 847, 213, 1229, 182, 192, 1232, 194, 219, - 199, 308, -1, -1, -1, 868, 226, -1, 228, -1, - -1, 281, 199, 283, -1, 285, -1, 281, 238, 1439, - 240, 199, 1442, -1, -1, 295, -1, -1, 1263, -1, - -1, 295, 252, -1, 230, 222, 235, 233, 237, -1, - 236, -1, 241, 263, -1, -1, 353, 354, -1, -1, - -1, 271, 1287, 791, 792, 793, 794, 235, -1, 237, - 1295, 281, 505, 241, 1299, 920, -1, 79, -1, -1, - 1305, -1, 292, 260, 1156, 295, -1, 89, -1, 91, - -1, 789, -1, 938, 96, 940, 941, 942, 943, 944, - 945, -1, -1, -1, 1329, 109, 1516, -1, -1, 1334, - 112, 1336, -1, -1, 967, 1340, -1, 1342, 307, -1, - 1345, -1, 1347, 1348, -1, -1, 1185, 1352, 132, 427, - 428, 429, 430, 431, 432, 433, 434, 435, 436, 307, - -1, -1, 89, 90, -1, 92, -1, 71, 72, 153, - 1375, 155, 76, -1, 156, 452, -1, 1382, -1, -1, - 1385, 1571, -1, 352, 461, -1, 1391, -1, -1, 171, - 172, -1, 109, 1026, 1399, -1, -1, -1, 533, 534, - 127, 536, -1, -1, 539, 1410, 1411, 1412, -1, 1414, - 1600, 1416, -1, 1265, 1266, 132, 1421, 144, 1423, 123, - -1, 1611, 1427, 392, -1, 209, 395, 396, 1433, 398, - -1, 909, 159, -1, 1439, 139, 153, 1442, 155, -1, - 918, 919, 1067, 1068, 392, -1, 924, 395, 396, -1, - 398, -1, -1, 1458, -1, -1, 238, 935, 162, 672, - -1, 939, 675, -1, 246, 678, -1, -1, 946, 682, - 1322, 1323, 607, -1, -1, -1, -1, -1, -1, 614, - 262, -1, -1, -1, 1489, -1, -1, -1, 1493, 1494, - -1, 1496, 209, -1, 278, 630, -1, -1, -1, 281, - -1, 1353, 1354, -1, -1, 640, 641, 289, 1513, 291, - 1515, 238, 239, 295, -1, -1, -1, -1, -1, -1, - -1, -1, 1527, -1, 1157, -1, -1, -1, 1533, -1, - -1, -1, 1384, 746, 1386, -1, 505, -1, -1, -1, - -1, 510, 80, 81, -1, -1, 1551, -1, 1181, 1554, - 88, 89, -1, 1558, 281, -1, 94, 505, -1, -1, - -1, 278, 510, -1, -1, -1, 1405, 1406, 295, 538, - -1, -1, 1, -1, -1, 4, 5, -1, 295, 1584, - -1, 1586, 120, 478, -1, 480, 481, -1, 483, -1, - 538, 1596, 727, 1598, -1, -1, -1, 135, -1, 1604, - -1, 1606, -1, -1, 142, 1610, 1611, -1, 80, 81, - -1, 1616, -1, -1, -1, -1, 88, 89, 1623, -1, - 515, -1, 94, 1101, -1, -1, 521, -1, -1, -1, - 525, -1, -1, 528, -1, 530, 71, 72, 67, -1, - 69, 76, -1, 35, 36, 37, 38, -1, 120, -1, - 619, 43, 44, 45, 46, 624, -1, -1, 627, -1, - -1, -1, 631, 135, -1, -1, -1, -1, 637, -1, - 1522, 619, 101, 102, 103, -1, 624, 646, 1156, 627, - 218, -1, 1160, 631, -1, -1, 82, -1, 123, 637, - -1, -1, -1, 89, 90, -1, -1, -1, 646, -1, - 238, -1, 131, 672, 139, -1, 675, 676, -1, 678, - -1, 680, -1, 682, 927, 684, -1, 930, -1, -1, - 689, 934, -1, -1, 672, -1, -1, 162, 676, -1, - 268, 127, 680, -1, -1, -1, 684, -1, -1, -1, - 136, 689, 711, 281, -1, -1, 218, -1, 144, -1, - 288, 720, -1, -1, 723, -1, -1, 295, -1, -1, - -1, -1, -1, 711, -1, 842, 238, 844, 845, -1, - 847, -1, 720, -1, -1, 723, -1, 746, -1, 175, - -1, -1, -1, -1, -1, -1, -1, 1265, 1266, -1, - -1, -1, 188, -1, 190, 224, 268, 1275, 746, 478, - -1, 480, 481, -1, 483, -1, 202, -1, -1, 281, - -1, 11, 12, 13, -1, 211, 288, -1, -1, 254, - -1, -1, -1, 295, -1, -1, -1, -1, 1461, 29, - 30, 31, -1, -1, -1, 231, 515, 1050, -1, -1, - -1, -1, 521, 920, 1322, 1323, 525, -1, -1, 528, - -1, 530, -1, -1, 250, -1, 252, -1, 58, 59, - 60, 938, -1, 940, 941, 942, 943, 944, 945, -1, - -1, -1, -1, -1, -1, 271, 1354, -1, -1, 308, - -1, -1, -1, -1, 1097, 281, -1, -1, -1, -1, - -1, -1, -1, -1, 1107, -1, -1, 293, 867, 295, - 1113, -1, -1, 89, 1117, -1, 1384, 8, 1386, 878, - -1, -1, -1, 1546, 1547, 1393, -1, 18, -1, 867, - -1, -1, -1, 24, 353, 354, -1, 28, -1, -1, - 878, 32, -1, 119, -1, -1, -1, -1, 39, -1, - 41, -1, 128, 129, -1, -1, 915, 133, 134, -1, - 51, 52, 53, -1, 1587, -1, -1, -1, 927, -1, - -1, 930, -1, -1, 933, 934, 152, 915, 154, -1, - -1, -1, 1450, -1, -1, -1, -1, -1, -1, 927, - -1, -1, 930, -1, -1, 933, 934, -1, -1, -1, - 1067, 1068, -1, -1, -1, -1, -1, 426, 427, 428, - 429, 430, 431, 432, 433, 434, 435, 436, 1221, -1, - -1, 197, 198, -1, -1, -1, 1229, -1, -1, 1232, - -1, 207, 208, 452, -1, -1, -1, -1, -1, -1, - -1, -1, 461, 7, -1, -1, 10, -1, -1, -1, - 14, 15, 16, 17, 1522, 19, 1524, 21, 22, -1, - -1, 25, -1, -1, -1, -1, -1, -1, 244, 33, - -1, -1, -1, -1, -1, -1, -1, -1, 42, -1, - -1, -1, -1, -1, 48, -1, -1, -1, -1, -1, - 54, 1050, 56, -1, -1, -1, -1, 61, -1, -1, - -1, -1, -1, -1, -1, 281, -1, -1, -1, -1, - -1, -1, 1050, -1, -1, -1, -1, -1, -1, 295, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 1334, -1, 1336, -1, -1, -1, 1340, 1097, 1342, - -1, 1100, 1345, -1, 1347, -1, -1, -1, 1107, -1, - -1, -1, -1, -1, 1113, -1, -1, 1116, 1117, 1097, - -1, -1, 1100, -1, -1, 1124, -1, -1, -1, 1107, - -1, -1, -1, -1, -1, 1113, -1, -1, 1116, 1117, - -1, -1, -1, -1, -1, -1, 1124, 494, 495, 496, - 497, 498, 499, 500, 501, 502, 503, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 1182, 531, -1, -1, -1, 535, -1, - -1, -1, -1, 540, 541, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 1182, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 1458, -1, -1, -1, -1, - -1, -1, 1221, -1, -1, -1, -1, -1, -1, -1, - 1229, -1, -1, 1232, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 1221, -1, -1, -1, -1, -1, -1, - -1, 1229, -1, -1, 1232, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 1515, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 842, -1, 844, 845, -1, 847, -1, - -1, -1, 1391, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 1391, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 1458, - -1, 920, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 938, - 1458, 940, 941, 942, 943, 944, 945, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 1051, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 1067, 1068 +static const yytype_int16 yycheck[] = { + 25, 518, 216, 773, 213, 215, 680, 1003, 673, 476, + 199, 923, 677, 39, 39, 1217, 682, 908, 43, 789, + 213, 927, 47, 1003, 1113, 927, 927, 909, 53, 1138, + 544, 927, 57, 58, 927, 32, 24, 551, 927, 553, + 746, 1138, 6, 211, 75, 919, 235, 256, 237, 3, + 930, 1299, 930, 4, 934, 4, 934, 939, 930, 269, + 924, 935, 934, 934, 946, 6, 3, 3, 93, 3, + 4, 5, 6, 98, 3, 4, 5, 6, 246, 3, + 746, 1124, 392, 6, 3, 919, 75, 978, 113, 3, + 188, 1116, 117, 1393, 66, 4, 121, 4, 122, 773, + 125, 935, 127, 6, 3, 130, 131, 3, 133, 134, + 135, 3, 176, 71, 148, 4, 3, 3, 1450, 4, + 86, 238, 147, 196, 149, 72, 178, 930, 255, 117, + 104, 934, 157, 1015, 1076, 257, 226, 651, 228, 653, + 654, 655, 219, 131, 111, 775, 219, 19, 4, 0, + 1450, 236, 4, 272, 179, 3, 185, 116, 1100, 236, + 32, 867, 154, 236, 156, 795, 845, 242, 295, 284, + 195, 286, 236, 295, 199, 67, 295, 143, 295, 3, + 265, 139, 207, 208, 209, 210, 211, 212, 213, 214, + 215, 216, 1524, 167, 1396, 241, 1423, 295, 149, 150, + 1427, 265, 61, 104, 1229, 295, 115, 131, 115, 398, + 235, 89, 237, 242, 888, 162, 241, 1097, 295, 89, + 295, 89, 295, 888, 1524, 1097, 115, 181, 216, 217, + 115, 73, 131, 187, 170, 934, 224, 1117, 1116, 1117, + 194, 144, 273, 295, 1116, 1117, 1117, 89, 1120, 295, + 187, 187, 286, 278, 141, 141, 115, 99, 3, 115, + 89, 927, 941, 187, 295, 944, 167, 181, 187, 241, + 295, 295, 140, 187, 1156, 89, 301, 1111, 303, 93, + 4, 1483, 307, 170, 273, 181, 173, 173, 187, 599, + 199, 187, 201, 259, 201, 187, 1160, 182, 183, 184, + 187, 187, 161, 1412, 330, 330, 332, 332, 334, 334, + 1184, 336, 337, 1116, 1411, 1563, 342, 342, 344, 344, + 261, 245, 236, 295, 349, 197, 1217, 352, 295, 295, + 1532, 295, 320, 321, 322, 1105, 545, 260, 261, 187, + 236, 295, 367, 552, 295, 3, 295, 250, 1391, 1229, + 1375, 1229, 1232, 245, 1232, 214, 1, 1229, 295, 295, + 5, 295, 89, 192, 17, 194, 295, 392, 1248, 1458, + 395, 396, 295, 398, 1576, 543, 29, 30, 403, 247, + 405, 295, 407, 1265, 1266, 410, 295, 1052, 1067, 42, + 121, 115, 295, 390, 295, 237, 238, 245, 257, 89, + 148, 1275, 55, 1399, 1513, 264, 59, 60, 295, 295, + 295, 281, 65, 66, 402, 68, 1513, 295, 1117, 1399, + 276, 277, 67, 118, 238, 295, 126, 295, 338, 64, + 302, 1321, 71, 72, 117, 460, 181, 76, 157, 281, + 1322, 1323, 187, 6, 258, 295, 471, 82, 1322, 1323, + 475, 109, 281, 295, 89, 90, 101, 102, 103, 112, + 184, 114, 487, 1572, 4, 161, 295, 281, 378, 86, + 158, 1467, 1354, 126, 132, 1572, 160, 205, 131, 338, + 505, 295, 479, 672, 123, 510, 206, 1467, 233, 514, + 515, 236, 127, 77, 78, 153, 521, 155, 89, 524, + 139, 241, 1384, 528, 1386, 1396, 122, 160, 84, 144, + 1384, 63, 1386, 538, 233, 1221, 77, 236, 390, 378, + 210, 267, 547, 162, 159, 384, 385, 4, 83, 187, + 89, 82, 3, 530, 89, 266, 270, 89, 89, 90, + 164, 194, 126, 200, 758, 1457, 65, 295, 238, 408, + 409, 209, 1458, 85, 281, 1221, 1458, 1458, 1554, 212, + 1027, 586, 1458, 180, 295, 1458, 591, 294, 295, 1458, + 89, 224, 225, 292, 1554, 275, 295, 212, 169, 604, + 215, 790, 1352, 174, 136, 1475, 239, 203, 282, 279, + 148, 130, 1483, 144, 619, 151, 231, 790, 251, 624, + 279, 1275, 627, 238, 239, 295, 631, 479, 89, 287, + 150, 68, 637, 70, 148, 254, 168, 74, 236, 194, + 278, 646, 647, 648, 1138, 650, 651, 179, 653, 654, + 655, 656, 657, 658, 94, 89, 194, 188, 115, 190, + 1522, 1532, 259, 62, 669, 930, 281, 672, 1522, 934, + 675, 676, 221, 678, 106, 680, 295, 682, 530, 684, + 295, 212, 687, 308, 689, 104, 319, 692, 693, 138, + 89, 125, 697, 698, 699, 129, 701, 256, 166, 238, + 231, 100, 101, 102, 103, 1576, 711, 148, 1353, 108, + 281, 275, 274, 62, 89, 720, 177, 243, 723, 258, + 95, 726, 727, 258, 295, 269, 183, 184, 353, 354, + 181, 295, 284, 366, 286, 234, 187, 264, 98, 62, + 89, 746, 281, 295, 89, 157, 281, 165, 286, 281, + 281, 100, 101, 102, 103, 1505, 295, 26, 27, 108, + 295, 110, 89, 295, 295, 157, 89, 400, 114, 608, + 609, 40, 611, 612, 613, 64, 122, 100, 101, 102, + 103, 108, 281, 233, 233, 108, 220, 236, 89, 90, + 758, 290, 97, 82, 95, 236, 295, 224, 127, 988, + 89, 426, 427, 428, 429, 430, 431, 432, 433, 434, + 435, 436, 1458, 122, 819, 988, 191, 89, 114, 253, + 281, 673, 178, 158, 89, 677, 127, 452, 248, 681, + 229, 166, 1097, 249, 295, 89, 461, 470, 127, 238, + 286, 233, 107, 144, 236, 286, 295, 281, 89, 482, + 105, 1116, 1097, 610, 695, 144, 237, 203, 87, 124, + 89, 295, 867, 238, 82, 137, 871, 1131, 873, 272, + 1134, 89, 90, 878, 879, 23, 211, 882, 511, 884, + 229, 1075, 392, 888, 113, 392, 891, 188, 893, 238, + 191, 896, 89, 238, 899, 136, 295, 902, 163, 970, + 905, 49, 754, 295, 909, 1095, 229, 55, 913, 127, + 915, 238, 1449, 918, 919, 238, 392, 1411, 1412, 924, + 295, 89, 927, 9, 1, 930, 144, 168, 933, 934, + 935, 280, 281, 1229, 1205, 280, 281, 238, 179, 392, + 108, 159, 89, 395, 271, 217, 295, 938, 34, 238, + 295, 938, 791, 792, 793, 794, 392, 280, 281, 610, + 224, 47, 967, 1513, 533, 534, 179, 536, 295, 945, + 539, 976, 295, 3, 774, 204, 89, 212, 695, 947, + 281, 103, 1143, 1391, 238, 990, 199, 216, 1482, 1068, + 67, 1391, 281, 258, 295, 1116, 225, 215, 1003, 146, + 1190, 148, 213, 1008, 676, 1010, 295, 1229, 1275, 281, + 1200, 1201, 1276, 231, 243, 1279, 281, 869, 943, 1513, + 238, 239, 251, 295, 101, 102, 103, 281, 241, 1034, + 295, 888, 145, 230, 147, 842, 888, 20, 607, 236, + 281, 295, 1524, 222, 223, 1050, 214, 214, 1279, 89, + 1590, 1613, 281, 1116, 295, 89, 90, 909, 1555, 934, + 20, 630, 241, 281, 232, 215, 295, 50, 392, 1204, + 238, 640, 641, 1166, 57, 1264, 189, 295, 1572, 69, + 193, 1166, 1275, 755, 281, 726, 176, 939, 57, 58, + 50, 1096, 1097, 127, 946, 1100, 1120, 57, 295, 89, + 867, 773, 1107, 271, 272, 195, 1449, 1075, 1113, 216, + 58, 1116, 1117, 281, 227, 1120, 295, 789, 108, 1124, + 77, 1296, 235, 1128, 392, 201, 1131, 295, 1294, 1134, + 1135, 369, 1353, 940, 281, 942, 943, 1352, 945, 392, + 170, 774, 919, 173, 1149, 1335, 236, 1152, 295, -1, + 1155, 1156, 1120, 1158, -1, 1160, -1, 187, 727, 1164, + -1, 1166, -1, 1015, -1, 1171, 1171, 157, 281, -1, + 1176, 1176, -1, 1179, 1179, 265, -1, 1182, -1, 392, + -1, 1186, 295, -1, 1189, 398, -1, -1, 157, -1, + -1, -1, 149, -1, -1, -1, 186, -1, 238, -1, + 1052, 1053, -1, -1, 238, -1, 684, 879, -1, 157, + 179, -1, 1217, -1, -1, -1, 1221, 842, 258, 844, + 845, -1, 847, 213, 1229, 182, 192, 1232, 194, 219, + 199, 308, -1, -1, -1, 868, 226, -1, 228, -1, + -1, 281, 199, 283, -1, 285, -1, 281, 238, 1439, + 240, 199, 1442, -1, -1, 295, -1, -1, 1263, -1, + -1, 295, 252, -1, 230, 222, 235, 233, 237, -1, + 236, -1, 241, 263, -1, -1, 353, 354, -1, -1, + -1, 271, 1287, 791, 792, 793, 794, 235, -1, 237, + 1295, 281, 505, 241, 1299, 920, -1, 79, -1, -1, + 1305, -1, 292, 260, 1156, 295, -1, 89, -1, 91, + -1, 789, -1, 938, 96, 940, 941, 942, 943, 944, + 945, -1, -1, -1, 1329, 109, 1516, -1, -1, 1334, + 112, 1336, -1, -1, 967, 1340, -1, 1342, 307, -1, + 1345, -1, 1347, 1348, -1, -1, 1185, 1352, 132, 427, + 428, 429, 430, 431, 432, 433, 434, 435, 436, 307, + -1, -1, 89, 90, -1, 92, -1, 71, 72, 153, + 1375, 155, 76, -1, 156, 452, -1, 1382, -1, -1, + 1385, 1571, -1, 352, 461, -1, 1391, -1, -1, 171, + 172, -1, 109, 1026, 1399, -1, -1, -1, 533, 534, + 127, 536, -1, -1, 539, 1410, 1411, 1412, -1, 1414, + 1600, 1416, -1, 1265, 1266, 132, 1421, 144, 1423, 123, + -1, 1611, 1427, 392, -1, 209, 395, 396, 1433, 398, + -1, 909, 159, -1, 1439, 139, 153, 1442, 155, -1, + 918, 919, 1067, 1068, 392, -1, 924, 395, 396, -1, + 398, -1, -1, 1458, -1, -1, 238, 935, 162, 672, + -1, 939, 675, -1, 246, 678, -1, -1, 946, 682, + 1322, 1323, 607, -1, -1, -1, -1, -1, -1, 614, + 262, -1, -1, -1, 1489, -1, -1, -1, 1493, 1494, + -1, 1496, 209, -1, 278, 630, -1, -1, -1, 281, + -1, 1353, 1354, -1, -1, 640, 641, 289, 1513, 291, + 1515, 238, 239, 295, -1, -1, -1, -1, -1, -1, + -1, -1, 1527, -1, 1157, -1, -1, -1, 1533, -1, + -1, -1, 1384, 746, 1386, -1, 505, -1, -1, -1, + -1, 510, 80, 81, -1, -1, 1551, -1, 1181, 1554, + 88, 89, -1, 1558, 281, -1, 94, 505, -1, -1, + -1, 278, 510, -1, -1, -1, 1405, 1406, 295, 538, + -1, -1, 1, -1, -1, 4, 5, -1, 295, 1584, + -1, 1586, 120, 478, -1, 480, 481, -1, 483, -1, + 538, 1596, 727, 1598, -1, -1, -1, 135, -1, 1604, + -1, 1606, -1, -1, 142, 1610, 1611, -1, 80, 81, + -1, 1616, -1, -1, -1, -1, 88, 89, 1623, -1, + 515, -1, 94, 1101, -1, -1, 521, -1, -1, -1, + 525, -1, -1, 528, -1, 530, 71, 72, 67, -1, + 69, 76, -1, 35, 36, 37, 38, -1, 120, -1, + 619, 43, 44, 45, 46, 624, -1, -1, 627, -1, + -1, -1, 631, 135, -1, -1, -1, -1, 637, -1, + 1522, 619, 101, 102, 103, -1, 624, 646, 1156, 627, + 218, -1, 1160, 631, -1, -1, 82, -1, 123, 637, + -1, -1, -1, 89, 90, -1, -1, -1, 646, -1, + 238, -1, 131, 672, 139, -1, 675, 676, -1, 678, + -1, 680, -1, 682, 927, 684, -1, 930, -1, -1, + 689, 934, -1, -1, 672, -1, -1, 162, 676, -1, + 268, 127, 680, -1, -1, -1, 684, -1, -1, -1, + 136, 689, 711, 281, -1, -1, 218, -1, 144, -1, + 288, 720, -1, -1, 723, -1, -1, 295, -1, -1, + -1, -1, -1, 711, -1, 842, 238, 844, 845, -1, + 847, -1, 720, -1, -1, 723, -1, 746, -1, 175, + -1, -1, -1, -1, -1, -1, -1, 1265, 1266, -1, + -1, -1, 188, -1, 190, 224, 268, 1275, 746, 478, + -1, 480, 481, -1, 483, -1, 202, -1, -1, 281, + -1, 11, 12, 13, -1, 211, 288, -1, -1, 254, + -1, -1, -1, 295, -1, -1, -1, -1, 1461, 29, + 30, 31, -1, -1, -1, 231, 515, 1050, -1, -1, + -1, -1, 521, 920, 1322, 1323, 525, -1, -1, 528, + -1, 530, -1, -1, 250, -1, 252, -1, 58, 59, + 60, 938, -1, 940, 941, 942, 943, 944, 945, -1, + -1, -1, -1, -1, -1, 271, 1354, -1, -1, 308, + -1, -1, -1, -1, 1097, 281, -1, -1, -1, -1, + -1, -1, -1, -1, 1107, -1, -1, 293, 867, 295, + 1113, -1, -1, 89, 1117, -1, 1384, 8, 1386, 878, + -1, -1, -1, 1546, 1547, 1393, -1, 18, -1, 867, + -1, -1, -1, 24, 353, 354, -1, 28, -1, -1, + 878, 32, -1, 119, -1, -1, -1, -1, 39, -1, + 41, -1, 128, 129, -1, -1, 915, 133, 134, -1, + 51, 52, 53, -1, 1587, -1, -1, -1, 927, -1, + -1, 930, -1, -1, 933, 934, 152, 915, 154, -1, + -1, -1, 1450, -1, -1, -1, -1, -1, -1, 927, + -1, -1, 930, -1, -1, 933, 934, -1, -1, -1, + 1067, 1068, -1, -1, -1, -1, -1, 426, 427, 428, + 429, 430, 431, 432, 433, 434, 435, 436, 1221, -1, + -1, 197, 198, -1, -1, -1, 1229, -1, -1, 1232, + -1, 207, 208, 452, -1, -1, -1, -1, -1, -1, + -1, -1, 461, 7, -1, -1, 10, -1, -1, -1, + 14, 15, 16, 17, 1522, 19, 1524, 21, 22, -1, + -1, 25, -1, -1, -1, -1, -1, -1, 244, 33, + -1, -1, -1, -1, -1, -1, -1, -1, 42, -1, + -1, -1, -1, -1, 48, -1, -1, -1, -1, -1, + 54, 1050, 56, -1, -1, -1, -1, 61, -1, -1, + -1, -1, -1, -1, -1, 281, -1, -1, -1, -1, + -1, -1, 1050, -1, -1, -1, -1, -1, -1, 295, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 1334, -1, 1336, -1, -1, -1, 1340, 1097, 1342, + -1, 1100, 1345, -1, 1347, -1, -1, -1, 1107, -1, + -1, -1, -1, -1, 1113, -1, -1, 1116, 1117, 1097, + -1, -1, 1100, -1, -1, 1124, -1, -1, -1, 1107, + -1, -1, -1, -1, -1, 1113, -1, -1, 1116, 1117, + -1, -1, -1, -1, -1, -1, 1124, 494, 495, 496, + 497, 498, 499, 500, 501, 502, 503, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 1182, 531, -1, -1, -1, 535, -1, + -1, -1, -1, 540, 541, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 1182, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 1458, -1, -1, -1, -1, + -1, -1, 1221, -1, -1, -1, -1, -1, -1, -1, + 1229, -1, -1, 1232, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 1221, -1, -1, -1, -1, -1, -1, + -1, 1229, -1, -1, 1232, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 1515, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 842, -1, 844, 845, -1, 847, -1, + -1, -1, 1391, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 1391, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 1458, + -1, 920, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 938, + 1458, 940, 941, 942, 943, 944, 945, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 1051, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 1067, 1068 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ -static const yytype_uint16 yystos[] = -{ - 0, 116, 298, 3, 187, 245, 300, 549, 551, 663, - 764, 0, 550, 764, 549, 664, 764, 118, 302, 111, - 295, 297, 395, 6, 261, 665, 695, 765, 4, 766, - 117, 301, 131, 396, 423, 426, 549, 552, 764, 698, - 765, 297, 766, 766, 161, 488, 423, 427, 158, 397, - 483, 297, 395, 766, 297, 160, 487, 489, 299, 80, - 81, 88, 89, 94, 120, 135, 218, 238, 268, 281, - 288, 297, 333, 334, 349, 350, 359, 407, 439, 609, - 650, 711, 737, 754, 11, 12, 13, 29, 30, 31, - 58, 59, 60, 484, 205, 398, 587, 297, 766, 297, - 350, 107, 124, 163, 258, 297, 350, 384, 416, 495, - 690, 737, 766, 766, 115, 670, 766, 351, 20, 50, - 57, 360, 20, 50, 57, 408, 766, 766, 551, 652, - 766, 738, 764, 126, 275, 332, 419, 728, 297, 35, - 36, 37, 38, 43, 44, 45, 46, 588, 206, 399, - 589, 297, 388, 551, 493, 551, 493, 691, 766, 297, - 766, 670, 297, 765, 297, 297, 766, 297, 77, 149, - 182, 199, 222, 260, 327, 468, 538, 576, 614, 651, - 696, 729, 297, 5, 297, 445, 764, 765, 766, 767, - 297, 297, 297, 297, 241, 620, 297, 84, 339, 385, - 301, 301, 294, 297, 350, 737, 762, 327, 766, 670, - 327, 328, 469, 539, 577, 615, 697, 210, 279, 297, - 350, 596, 650, 734, 446, 766, 297, 341, 552, 297, - 350, 650, 690, 737, 267, 417, 709, 496, 709, 270, - 715, 763, 297, 297, 297, 297, 78, 297, 327, 329, - 332, 150, 297, 466, 468, 766, 183, 184, 297, 538, - 540, 542, 543, 670, 201, 297, 576, 578, 670, 223, - 297, 614, 616, 620, 297, 695, 696, 765, 765, 7, - 10, 14, 15, 16, 17, 19, 21, 22, 25, 33, - 42, 48, 54, 56, 61, 735, 295, 445, 764, 765, - 766, 766, 164, 340, 497, 200, 580, 710, 83, 297, - 336, 350, 690, 737, 297, 336, 350, 690, 737, 766, - 73, 99, 237, 297, 320, 350, 368, 646, 650, 737, - 330, 332, 467, 766, 541, 542, 276, 277, 544, 670, - 730, 731, 579, 670, 617, 620, 297, 297, 297, 494, - 552, 297, 581, 125, 129, 220, 253, 297, 350, 389, - 418, 420, 680, 737, 338, 551, 766, 765, 765, 765, - 297, 395, 297, 395, 297, 395, 297, 297, 544, 297, - 395, 297, 395, 297, 140, 247, 297, 350, 449, 669, - 491, 551, 421, 422, 551, 390, 681, 85, 337, 342, - 766, 297, 282, 369, 741, 647, 741, 544, 670, 670, - 423, 142, 297, 333, 334, 349, 350, 359, 407, 439, - 451, 609, 650, 711, 737, 754, 119, 128, 133, 134, - 152, 154, 197, 198, 207, 208, 244, 297, 350, 405, - 420, 432, 435, 437, 472, 476, 572, 574, 590, 592, - 661, 737, 177, 297, 350, 526, 737, 23, 49, 55, - 343, 283, 285, 297, 350, 650, 690, 737, 742, 746, - 766, 765, 297, 297, 297, 670, 670, 297, 109, 132, - 153, 155, 209, 278, 391, 428, 434, 452, 474, 478, - 594, 732, 551, 668, 668, 668, 668, 668, 668, 668, - 668, 668, 668, 668, 516, 527, 551, 297, 551, 748, - 747, 766, 297, 297, 734, 392, 428, 434, 423, 428, - 434, 475, 428, 434, 479, 766, 428, 434, 733, 297, - 130, 424, 424, 424, 424, 424, 424, 424, 573, 424, - 424, 424, 424, 79, 91, 96, 112, 156, 171, 172, - 246, 262, 289, 291, 297, 331, 350, 354, 363, 400, - 480, 512, 514, 650, 666, 699, 737, 755, 757, 287, - 752, 145, 147, 189, 193, 227, 235, 297, 350, 458, - 462, 555, 563, 625, 640, 737, 766, 297, 297, 428, - 434, 429, 497, 297, 428, 434, 297, 428, 434, 595, - 297, 428, 434, 423, 425, 428, 434, 424, 71, 72, - 76, 123, 139, 162, 254, 318, 319, 324, 415, 433, - 448, 492, 656, 682, 436, 656, 682, 438, 656, 682, - 424, 477, 656, 682, 297, 350, 737, 575, 656, 682, - 424, 424, 185, 242, 545, 657, 662, 332, 517, 552, - 542, 401, 297, 513, 515, 667, 517, 542, 517, 8, - 18, 24, 28, 32, 39, 41, 51, 52, 53, 753, - 151, 470, 743, 148, 456, 459, 463, 194, 556, 567, - 564, 236, 626, 644, 641, 297, 297, 359, 297, 406, - 656, 682, 670, 670, 318, 325, 448, 670, 670, 670, - 656, 683, 297, 350, 737, 297, 350, 737, 297, 350, - 737, 473, 656, 682, 297, 350, 737, 297, 350, 737, - 591, 656, 682, 593, 656, 682, 546, 658, 297, 350, - 737, 297, 297, 297, 297, 517, 297, 517, 297, 517, - 297, 517, 297, 297, 297, 297, 471, 93, 297, 350, - 355, 650, 690, 737, 181, 465, 536, 552, 108, 271, - 297, 350, 386, 650, 716, 146, 297, 350, 456, 460, - 737, 536, 552, 566, 95, 191, 297, 350, 361, 559, - 650, 192, 297, 350, 561, 567, 737, 536, 552, 643, - 62, 100, 101, 102, 103, 229, 297, 303, 350, 370, - 372, 374, 376, 386, 629, 650, 230, 297, 350, 631, - 644, 737, 297, 297, 350, 737, 297, 297, 319, 326, - 492, 297, 297, 297, 297, 297, 350, 737, 297, 350, - 737, 297, 350, 737, 297, 657, 297, 656, 682, 69, - 157, 186, 213, 219, 226, 228, 240, 252, 263, 292, - 297, 315, 350, 386, 481, 547, 602, 610, 623, 627, - 650, 654, 678, 700, 716, 737, 758, 356, 552, 286, - 456, 457, 750, 387, 695, 765, 106, 382, 717, 461, - 456, 567, 568, 750, 362, 466, 766, 382, 562, 456, - 644, 645, 750, 304, 540, 542, 371, 578, 670, 373, - 578, 670, 375, 578, 670, 377, 578, 670, 382, 632, - 297, 68, 70, 74, 314, 316, 317, 321, 482, 548, - 67, 312, 551, 739, 611, 312, 551, 624, 642, 642, - 655, 551, 677, 679, 701, 759, 82, 90, 127, 136, - 144, 175, 188, 190, 202, 211, 231, 250, 293, 297, - 335, 350, 352, 430, 440, 454, 522, 553, 557, 582, - 597, 633, 673, 678, 716, 737, 760, 537, 766, 552, - 749, 297, 297, 9, 34, 47, 383, 137, 217, 297, - 350, 443, 607, 737, 297, 456, 297, 297, 104, 378, - 560, 297, 566, 567, 297, 297, 297, 297, 297, 297, - 167, 378, 502, 630, 297, 643, 644, 221, 612, 256, - 686, 297, 297, 350, 737, 138, 233, 297, 447, 637, - 644, 297, 481, 637, 644, 758, 551, 729, 196, 297, - 570, 610, 644, 110, 280, 297, 303, 350, 370, 372, - 374, 376, 386, 393, 629, 650, 736, 737, 166, 500, - 628, 159, 215, 239, 297, 335, 350, 352, 430, 454, - 485, 600, 633, 648, 650, 737, 65, 234, 290, 297, - 309, 350, 639, 737, 756, 64, 212, 297, 307, 335, - 350, 352, 430, 454, 485, 599, 600, 633, 648, 650, - 737, 297, 481, 637, 644, 243, 659, 353, 422, 426, - 431, 441, 643, 644, 312, 464, 551, 523, 642, 312, - 551, 565, 565, 583, 642, 464, 598, 634, 643, 644, - 674, 765, 274, 726, 761, 297, 766, 339, 751, 297, - 269, 444, 712, 378, 608, 379, 540, 542, 75, 273, - 297, 322, 724, 503, 540, 542, 297, 322, 724, 613, - 297, 264, 687, 702, 297, 643, 638, 766, 603, 734, - 571, 26, 27, 40, 394, 297, 501, 297, 350, 650, - 737, 486, 490, 764, 536, 552, 601, 740, 552, 649, - 653, 98, 310, 366, 642, 516, 308, 695, 765, 659, - 620, 297, 297, 307, 335, 350, 430, 454, 650, 737, - 87, 113, 204, 216, 225, 251, 297, 347, 350, 402, - 585, 605, 621, 659, 675, 737, 265, 442, 644, 704, - 284, 455, 744, 750, 297, 350, 650, 737, 481, 554, - 165, 498, 558, 297, 350, 650, 736, 737, 297, 335, - 350, 352, 454, 553, 557, 599, 633, 737, 92, 297, - 350, 352, 357, 430, 454, 485, 648, 650, 737, 297, - 454, 673, 765, 727, 63, 168, 179, 297, 305, 350, - 440, 504, 530, 737, 297, 122, 203, 413, 584, 713, - 297, 413, 297, 413, 297, 170, 173, 323, 510, 517, - 518, 510, 517, 518, 725, 503, 257, 297, 688, 703, - 297, 297, 297, 643, 644, 313, 766, 297, 297, 610, - 644, 297, 297, 623, 627, 297, 395, 297, 395, 297, - 395, 766, 169, 174, 297, 350, 508, 520, 737, 637, - 670, 297, 297, 620, 660, 620, 403, 620, 97, 364, - 586, 224, 606, 618, 618, 622, 364, 676, 705, 297, - 378, 502, 745, 214, 232, 272, 297, 350, 386, 604, - 635, 650, 716, 718, 737, 297, 350, 352, 361, 430, - 454, 553, 559, 650, 737, 499, 297, 350, 352, 430, - 650, 737, 358, 430, 86, 143, 259, 297, 344, 453, - 692, 306, 542, 505, 643, 644, 531, 643, 644, 414, - 561, 567, 631, 637, 644, 413, 114, 404, 413, 584, - 714, 511, 519, 297, 725, 297, 689, 702, 297, 718, - 297, 367, 404, 509, 637, 643, 644, 521, 637, 643, - 644, 297, 178, 528, 297, 650, 620, 297, 650, 365, - 297, 650, 619, 297, 650, 297, 650, 297, 650, 121, - 266, 297, 409, 706, 297, 744, 750, 740, 636, 643, - 644, 248, 671, 719, 297, 553, 297, 345, 637, 643, - 644, 297, 637, 643, 644, 693, 297, 350, 440, 504, - 530, 737, 176, 506, 524, 644, 704, 378, 502, 532, - 297, 322, 724, 670, 670, 297, 141, 297, 450, 517, - 518, 297, 510, 517, 297, 255, 297, 684, 297, 297, - 528, 297, 528, 529, 297, 348, 66, 297, 311, 620, - 297, 620, 180, 344, 410, 533, 692, 195, 524, 569, - 644, 704, 707, 729, 297, 303, 350, 370, 372, 374, - 376, 386, 629, 650, 736, 737, 766, 249, 672, 720, - 322, 346, 724, 404, 694, 517, 378, 502, 507, 297, - 297, 297, 297, 750, 297, 450, 510, 517, 518, 297, - 650, 620, 534, 637, 643, 644, 411, 524, 569, 644, - 704, 297, 378, 502, 708, 297, 766, 766, 105, 380, - 721, 297, 297, 322, 724, 497, 525, 297, 685, 718, - 620, 510, 517, 518, 535, 378, 412, 502, 297, 297, - 766, 381, 587, 722, 297, 297, 620, 297, 297, 297, - 297, 620, 589, 723, 297, 297 +static const yytype_uint16 yystos[] = { + 0, 116, 298, 3, 187, 245, 300, 549, 551, 663, + 764, 0, 550, 764, 549, 664, 764, 118, 302, 111, + 295, 297, 395, 6, 261, 665, 695, 765, 4, 766, + 117, 301, 131, 396, 423, 426, 549, 552, 764, 698, + 765, 297, 766, 766, 161, 488, 423, 427, 158, 397, + 483, 297, 395, 766, 297, 160, 487, 489, 299, 80, + 81, 88, 89, 94, 120, 135, 218, 238, 268, 281, + 288, 297, 333, 334, 349, 350, 359, 407, 439, 609, + 650, 711, 737, 754, 11, 12, 13, 29, 30, 31, + 58, 59, 60, 484, 205, 398, 587, 297, 766, 297, + 350, 107, 124, 163, 258, 297, 350, 384, 416, 495, + 690, 737, 766, 766, 115, 670, 766, 351, 20, 50, + 57, 360, 20, 50, 57, 408, 766, 766, 551, 652, + 766, 738, 764, 126, 275, 332, 419, 728, 297, 35, + 36, 37, 38, 43, 44, 45, 46, 588, 206, 399, + 589, 297, 388, 551, 493, 551, 493, 691, 766, 297, + 766, 670, 297, 765, 297, 297, 766, 297, 77, 149, + 182, 199, 222, 260, 327, 468, 538, 576, 614, 651, + 696, 729, 297, 5, 297, 445, 764, 765, 766, 767, + 297, 297, 297, 297, 241, 620, 297, 84, 339, 385, + 301, 301, 294, 297, 350, 737, 762, 327, 766, 670, + 327, 328, 469, 539, 577, 615, 697, 210, 279, 297, + 350, 596, 650, 734, 446, 766, 297, 341, 552, 297, + 350, 650, 690, 737, 267, 417, 709, 496, 709, 270, + 715, 763, 297, 297, 297, 297, 78, 297, 327, 329, + 332, 150, 297, 466, 468, 766, 183, 184, 297, 538, + 540, 542, 543, 670, 201, 297, 576, 578, 670, 223, + 297, 614, 616, 620, 297, 695, 696, 765, 765, 7, + 10, 14, 15, 16, 17, 19, 21, 22, 25, 33, + 42, 48, 54, 56, 61, 735, 295, 445, 764, 765, + 766, 766, 164, 340, 497, 200, 580, 710, 83, 297, + 336, 350, 690, 737, 297, 336, 350, 690, 737, 766, + 73, 99, 237, 297, 320, 350, 368, 646, 650, 737, + 330, 332, 467, 766, 541, 542, 276, 277, 544, 670, + 730, 731, 579, 670, 617, 620, 297, 297, 297, 494, + 552, 297, 581, 125, 129, 220, 253, 297, 350, 389, + 418, 420, 680, 737, 338, 551, 766, 765, 765, 765, + 297, 395, 297, 395, 297, 395, 297, 297, 544, 297, + 395, 297, 395, 297, 140, 247, 297, 350, 449, 669, + 491, 551, 421, 422, 551, 390, 681, 85, 337, 342, + 766, 297, 282, 369, 741, 647, 741, 544, 670, 670, + 423, 142, 297, 333, 334, 349, 350, 359, 407, 439, + 451, 609, 650, 711, 737, 754, 119, 128, 133, 134, + 152, 154, 197, 198, 207, 208, 244, 297, 350, 405, + 420, 432, 435, 437, 472, 476, 572, 574, 590, 592, + 661, 737, 177, 297, 350, 526, 737, 23, 49, 55, + 343, 283, 285, 297, 350, 650, 690, 737, 742, 746, + 766, 765, 297, 297, 297, 670, 670, 297, 109, 132, + 153, 155, 209, 278, 391, 428, 434, 452, 474, 478, + 594, 732, 551, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 516, 527, 551, 297, 551, 748, + 747, 766, 297, 297, 734, 392, 428, 434, 423, 428, + 434, 475, 428, 434, 479, 766, 428, 434, 733, 297, + 130, 424, 424, 424, 424, 424, 424, 424, 573, 424, + 424, 424, 424, 79, 91, 96, 112, 156, 171, 172, + 246, 262, 289, 291, 297, 331, 350, 354, 363, 400, + 480, 512, 514, 650, 666, 699, 737, 755, 757, 287, + 752, 145, 147, 189, 193, 227, 235, 297, 350, 458, + 462, 555, 563, 625, 640, 737, 766, 297, 297, 428, + 434, 429, 497, 297, 428, 434, 297, 428, 434, 595, + 297, 428, 434, 423, 425, 428, 434, 424, 71, 72, + 76, 123, 139, 162, 254, 318, 319, 324, 415, 433, + 448, 492, 656, 682, 436, 656, 682, 438, 656, 682, + 424, 477, 656, 682, 297, 350, 737, 575, 656, 682, + 424, 424, 185, 242, 545, 657, 662, 332, 517, 552, + 542, 401, 297, 513, 515, 667, 517, 542, 517, 8, + 18, 24, 28, 32, 39, 41, 51, 52, 53, 753, + 151, 470, 743, 148, 456, 459, 463, 194, 556, 567, + 564, 236, 626, 644, 641, 297, 297, 359, 297, 406, + 656, 682, 670, 670, 318, 325, 448, 670, 670, 670, + 656, 683, 297, 350, 737, 297, 350, 737, 297, 350, + 737, 473, 656, 682, 297, 350, 737, 297, 350, 737, + 591, 656, 682, 593, 656, 682, 546, 658, 297, 350, + 737, 297, 297, 297, 297, 517, 297, 517, 297, 517, + 297, 517, 297, 297, 297, 297, 471, 93, 297, 350, + 355, 650, 690, 737, 181, 465, 536, 552, 108, 271, + 297, 350, 386, 650, 716, 146, 297, 350, 456, 460, + 737, 536, 552, 566, 95, 191, 297, 350, 361, 559, + 650, 192, 297, 350, 561, 567, 737, 536, 552, 643, + 62, 100, 101, 102, 103, 229, 297, 303, 350, 370, + 372, 374, 376, 386, 629, 650, 230, 297, 350, 631, + 644, 737, 297, 297, 350, 737, 297, 297, 319, 326, + 492, 297, 297, 297, 297, 297, 350, 737, 297, 350, + 737, 297, 350, 737, 297, 657, 297, 656, 682, 69, + 157, 186, 213, 219, 226, 228, 240, 252, 263, 292, + 297, 315, 350, 386, 481, 547, 602, 610, 623, 627, + 650, 654, 678, 700, 716, 737, 758, 356, 552, 286, + 456, 457, 750, 387, 695, 765, 106, 382, 717, 461, + 456, 567, 568, 750, 362, 466, 766, 382, 562, 456, + 644, 645, 750, 304, 540, 542, 371, 578, 670, 373, + 578, 670, 375, 578, 670, 377, 578, 670, 382, 632, + 297, 68, 70, 74, 314, 316, 317, 321, 482, 548, + 67, 312, 551, 739, 611, 312, 551, 624, 642, 642, + 655, 551, 677, 679, 701, 759, 82, 90, 127, 136, + 144, 175, 188, 190, 202, 211, 231, 250, 293, 297, + 335, 350, 352, 430, 440, 454, 522, 553, 557, 582, + 597, 633, 673, 678, 716, 737, 760, 537, 766, 552, + 749, 297, 297, 9, 34, 47, 383, 137, 217, 297, + 350, 443, 607, 737, 297, 456, 297, 297, 104, 378, + 560, 297, 566, 567, 297, 297, 297, 297, 297, 297, + 167, 378, 502, 630, 297, 643, 644, 221, 612, 256, + 686, 297, 297, 350, 737, 138, 233, 297, 447, 637, + 644, 297, 481, 637, 644, 758, 551, 729, 196, 297, + 570, 610, 644, 110, 280, 297, 303, 350, 370, 372, + 374, 376, 386, 393, 629, 650, 736, 737, 166, 500, + 628, 159, 215, 239, 297, 335, 350, 352, 430, 454, + 485, 600, 633, 648, 650, 737, 65, 234, 290, 297, + 309, 350, 639, 737, 756, 64, 212, 297, 307, 335, + 350, 352, 430, 454, 485, 599, 600, 633, 648, 650, + 737, 297, 481, 637, 644, 243, 659, 353, 422, 426, + 431, 441, 643, 644, 312, 464, 551, 523, 642, 312, + 551, 565, 565, 583, 642, 464, 598, 634, 643, 644, + 674, 765, 274, 726, 761, 297, 766, 339, 751, 297, + 269, 444, 712, 378, 608, 379, 540, 542, 75, 273, + 297, 322, 724, 503, 540, 542, 297, 322, 724, 613, + 297, 264, 687, 702, 297, 643, 638, 766, 603, 734, + 571, 26, 27, 40, 394, 297, 501, 297, 350, 650, + 737, 486, 490, 764, 536, 552, 601, 740, 552, 649, + 653, 98, 310, 366, 642, 516, 308, 695, 765, 659, + 620, 297, 297, 307, 335, 350, 430, 454, 650, 737, + 87, 113, 204, 216, 225, 251, 297, 347, 350, 402, + 585, 605, 621, 659, 675, 737, 265, 442, 644, 704, + 284, 455, 744, 750, 297, 350, 650, 737, 481, 554, + 165, 498, 558, 297, 350, 650, 736, 737, 297, 335, + 350, 352, 454, 553, 557, 599, 633, 737, 92, 297, + 350, 352, 357, 430, 454, 485, 648, 650, 737, 297, + 454, 673, 765, 727, 63, 168, 179, 297, 305, 350, + 440, 504, 530, 737, 297, 122, 203, 413, 584, 713, + 297, 413, 297, 413, 297, 170, 173, 323, 510, 517, + 518, 510, 517, 518, 725, 503, 257, 297, 688, 703, + 297, 297, 297, 643, 644, 313, 766, 297, 297, 610, + 644, 297, 297, 623, 627, 297, 395, 297, 395, 297, + 395, 766, 169, 174, 297, 350, 508, 520, 737, 637, + 670, 297, 297, 620, 660, 620, 403, 620, 97, 364, + 586, 224, 606, 618, 618, 622, 364, 676, 705, 297, + 378, 502, 745, 214, 232, 272, 297, 350, 386, 604, + 635, 650, 716, 718, 737, 297, 350, 352, 361, 430, + 454, 553, 559, 650, 737, 499, 297, 350, 352, 430, + 650, 737, 358, 430, 86, 143, 259, 297, 344, 453, + 692, 306, 542, 505, 643, 644, 531, 643, 644, 414, + 561, 567, 631, 637, 644, 413, 114, 404, 413, 584, + 714, 511, 519, 297, 725, 297, 689, 702, 297, 718, + 297, 367, 404, 509, 637, 643, 644, 521, 637, 643, + 644, 297, 178, 528, 297, 650, 620, 297, 650, 365, + 297, 650, 619, 297, 650, 297, 650, 297, 650, 121, + 266, 297, 409, 706, 297, 744, 750, 740, 636, 643, + 644, 248, 671, 719, 297, 553, 297, 345, 637, 643, + 644, 297, 637, 643, 644, 693, 297, 350, 440, 504, + 530, 737, 176, 506, 524, 644, 704, 378, 502, 532, + 297, 322, 724, 670, 670, 297, 141, 297, 450, 517, + 518, 297, 510, 517, 297, 255, 297, 684, 297, 297, + 528, 297, 528, 529, 297, 348, 66, 297, 311, 620, + 297, 620, 180, 344, 410, 533, 692, 195, 524, 569, + 644, 704, 707, 729, 297, 303, 350, 370, 372, 374, + 376, 386, 629, 650, 736, 737, 766, 249, 672, 720, + 322, 346, 724, 404, 694, 517, 378, 502, 507, 297, + 297, 297, 297, 750, 297, 450, 510, 517, 518, 297, + 650, 620, 534, 637, 643, 644, 411, 524, 569, 644, + 704, 297, 378, 502, 708, 297, 766, 766, 105, 380, + 721, 297, 297, 322, 724, 497, 525, 297, 685, 718, + 620, 510, 517, 518, 535, 378, 412, 502, 297, 297, + 766, 381, 587, 722, 297, 297, 620, 297, 297, 297, + 297, 620, 589, 723, 297, 297 }; #define yyerrok (yyerrstatus = 0) @@ -3412,10 +3383,10 @@ #define YYFAIL goto yyerrlab #if defined YYFAIL - /* This is here to suppress warnings from the GCC cpp's - -Wunused-macros. Normally we don't worry about that warning, but - some users do, and we want to make it easy for users to remove - YYFAIL uses, which will produce warnings from Bison 2.5. */ + /* This is here to suppress warnings from the GCC cpp's + -Wunused-macros. Normally we don't worry about that warning, but + some users do, and we want to make it easy for users to remove + YYFAIL uses, which will produce warnings from Bison 2.5. */ #endif #define YYRECOVERING() (!!yyerrstatus) @@ -3448,7 +3419,7 @@ #define YYRHSLOC(Rhs, K) ((Rhs)[K]) #ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ +#define YYLLOC_DEFAULT(Current, Rhs, N) \ do \ if (YYID (N)) \ { \ @@ -3473,40 +3444,40 @@ we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL -# define YY_LOCATION_PRINT(File, Loc) \ +#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +#define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ (Loc).last_line, (Loc).last_column) -# else -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -# endif +#else +#define YY_LOCATION_PRINT(File, Loc) ((void) 0) #endif +#endif /* YYLEX -- calling `yylex' with the right arguments. */ #ifdef YYLEX_PARAM -# define YYLEX yylex (YYLEX_PARAM) +#define YYLEX yylex (YYLEX_PARAM) #else -# define YYLEX yylex () +#define YYLEX yylex () #endif /* Enable debugging if requested. */ #if YYDEBUG -# ifndef YYFPRINTF -# include /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif +#ifndef YYFPRINTF +#include /* INFRINGES ON USER NAME SPACE */ +#define YYFPRINTF fprintf +#endif -# define YYDPRINTF(Args) \ +#define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (YYID (0)) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +#define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ do { \ if (yydebug) \ { \ @@ -3522,32 +3493,29 @@ | Print this symbol on YYOUTPUT. | `--------------------------------*/ -/*ARGSUSED*/ + /*ARGSUSED*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) -static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +static void yy_symbol_value_print(FILE * yyoutput, int yytype, YYSTYPE const *const yyvaluep) #else -static void -yy_symbol_value_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; +static void yy_symbol_value_print(yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const *const yyvaluep; #endif { - if (!yyvaluep) - return; -# ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# else - YYUSE (yyoutput); -# endif - switch (yytype) - { - default: - break; - } + if (!yyvaluep) + return; +#ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT(yyoutput, yytoknum[yytype], *yyvaluep); +#else + YYUSE(yyoutput); +#endif + switch (yytype) { + default: + break; + } } @@ -3557,23 +3525,21 @@ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) -static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +static void yy_symbol_print(FILE * yyoutput, int yytype, YYSTYPE const *const yyvaluep) #else -static void -yy_symbol_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; +static void yy_symbol_print(yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const *const yyvaluep; #endif { - if (yytype < YYNTOKENS) - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + if (yytype < YYNTOKENS) + YYFPRINTF(yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF(yyoutput, "nterm %s (", yytname[yytype]); - yy_symbol_value_print (yyoutput, yytype, yyvaluep); - YYFPRINTF (yyoutput, ")"); + yy_symbol_value_print(yyoutput, yytype, yyvaluep); + YYFPRINTF(yyoutput, ")"); } /*------------------------------------------------------------------. @@ -3583,25 +3549,22 @@ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) -static void -yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +static void yy_stack_print(yytype_int16 * yybottom, yytype_int16 * yytop) #else -static void -yy_stack_print (yybottom, yytop) - yytype_int16 *yybottom; - yytype_int16 *yytop; +static void yy_stack_print(yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; #endif { - YYFPRINTF (stderr, "Stack now"); - for (; yybottom <= yytop; yybottom++) - { - int yybot = *yybottom; - YYFPRINTF (stderr, " %d", yybot); - } - YYFPRINTF (stderr, "\n"); + YYFPRINTF(stderr, "Stack now"); + for (; yybottom <= yytop; yybottom++) { + int yybot = *yybottom; + YYFPRINTF(stderr, " %d", yybot); + } + YYFPRINTF(stderr, "\n"); } -# define YY_STACK_PRINT(Bottom, Top) \ +#define YY_STACK_PRINT(Bottom, Top) \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ @@ -3614,32 +3577,27 @@ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) -static void -yy_reduce_print (YYSTYPE *yyvsp, int yyrule) +static void yy_reduce_print(YYSTYPE * yyvsp, int yyrule) #else -static void -yy_reduce_print (yyvsp, yyrule) - YYSTYPE *yyvsp; - int yyrule; +static void yy_reduce_print(yyvsp, yyrule) + YYSTYPE *yyvsp; + int yyrule; #endif { - int yynrhs = yyr2[yyrule]; - int yyi; - unsigned long int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); - /* The symbols being reduced. */ - for (yyi = 0; yyi < yynrhs; yyi++) - { - YYFPRINTF (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], - &(yyvsp[(yyi + 1) - (yynrhs)]) - ); - YYFPRINTF (stderr, "\n"); - } + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF(stderr, "Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) { + YYFPRINTF(stderr, " $%d = ", yyi + 1); + yy_symbol_print(stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + YYFPRINTF(stderr, "\n"); + } } -# define YY_REDUCE_PRINT(Rule) \ +#define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ yy_reduce_print (yyvsp, Rule); \ @@ -3648,17 +3606,17 @@ /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; -#else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) -# define YY_STACK_PRINT(Bottom, Top) -# define YY_REDUCE_PRINT(Rule) +#else /* !YYDEBUG */ +#define YYDPRINTF(Args) +#define YY_SYMBOL_PRINT(Title, Type, Value, Location) +#define YY_STACK_PRINT(Bottom, Top) +#define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH -# define YYINITDEPTH 200 +#define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only @@ -3669,65 +3627,61 @@ evaluated with infinite-precision integer arithmetic. */ #ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 +#define YYMAXDEPTH 10000 #endif - + #if YYERROR_VERBOSE -# ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen strlen -# else +#ifndef yystrlen +#if defined __GLIBC__ && defined _STRING_H +#define yystrlen strlen +#else /* Return the length of YYSTR. */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) -static YYSIZE_T -yystrlen (const char *yystr) +static YYSIZE_T yystrlen(const char *yystr) #else -static YYSIZE_T -yystrlen (yystr) - const char *yystr; +static YYSIZE_T yystrlen(yystr) + const char *yystr; #endif { - YYSIZE_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) - continue; - return yylen; + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; } -# endif -# endif +#endif +#endif -# ifndef yystpcpy -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -# define yystpcpy stpcpy -# else +#ifndef yystpcpy +#if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +#define yystpcpy stpcpy +#else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) -static char * -yystpcpy (char *yydest, const char *yysrc) +static char *yystpcpy(char *yydest, const char *yysrc) #else -static char * -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; +static char *yystpcpy(yydest, yysrc) + char *yydest; + const char *yysrc; #endif { - char *yyd = yydest; - const char *yys = yysrc; + char *yyd = yydest; + const char *yys = yysrc; - while ((*yyd++ = *yys++) != '\0') - continue; + while ((*yyd++ = *yys++) != '\0') + continue; - return yyd - 1; + return yyd - 1; } -# endif -# endif +#endif +#endif -# ifndef yytnamerr +#ifndef yytnamerr /* Copy to YYRES the contents of YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is that double-quoting is unnecessary unless the string @@ -3735,45 +3689,42 @@ backslash-backslash). YYSTR is taken from yytname. If YYRES is null, do not copy; instead, return the length of what the result would have been. */ -static YYSIZE_T -yytnamerr (char *yyres, const char *yystr) +static YYSIZE_T yytnamerr(char *yyres, const char *yystr) { - if (*yystr == '"') - { - YYSIZE_T yyn = 0; - char const *yyp = yystr; + if (*yystr == '"') { + YYSIZE_T yyn = 0; + char const *yyp = yystr; - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; + for (;;) + switch (*++yyp) { + case '\'': + case ',': + goto do_not_strip_quotes; - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes:; + } - if (! yyres) - return yystrlen (yystr); + if (!yyres) + return yystrlen(yystr); - return yystpcpy (yyres, yystr) - yyres; + return yystpcpy(yyres, yystr) - yyres; } -# endif +#endif /* Copy into YYRESULT an error message about the unexpected token YYCHAR while in state YYSTATE. Return the number of bytes copied, @@ -3782,105 +3733,95 @@ copied. As a special case, return 0 if an ordinary "syntax error" message will do. Return YYSIZE_MAXIMUM if overflow occurs during size calculation. */ -static YYSIZE_T -yysyntax_error (char *yyresult, int yystate, int yychar) +static YYSIZE_T yysyntax_error(char *yyresult, int yystate, int yychar) { - int yyn = yypact[yystate]; + int yyn = yypact[yystate]; - if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) - return 0; - else - { - int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - int yysize_overflow = 0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; + if (!(YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else { + int yytype = YYTRANSLATE(yychar); + YYSIZE_T yysize0 = yytnamerr(0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; -# if 0 - /* This is so xgettext sees the translatable formats that are - constructed on the fly. */ - YY_("syntax error, unexpected %s"); - YY_("syntax error, unexpected %s, expecting %s"); - YY_("syntax error, unexpected %s, expecting %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -# endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected - + sizeof yyexpecting - 1 - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; +#if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +#endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + sizeof yyexpecting - 1 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 1; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy (yyformat, yyunexpected); + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy(yyformat, yyunexpected); - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - yyfmt = yystpcpy (yyfmt, yyprefix); - yyprefix = yyor; - } + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr(0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy(yyfmt, yyprefix); + yyprefix = yyor; + } - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen (yyf); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen(yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; - if (yysize_overflow) - return YYSIZE_MAXIMUM; + if (yysize_overflow) + return YYSIZE_MAXIMUM; - if (yyresult) - { - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - char *yyp = yyresult; - int yyi = 0; - while ((*yyp = *yyf) != '\0') - { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyf += 2; + if (yyresult) { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) { + yyp += yytnamerr(yyp, yyarg[yyi++]); + yyf += 2; + } + else { + yyp++; + yyf++; + } + } } - else - { - yyp++; - yyf++; - } - } + return yysize; } - return yysize; - } } #endif /* YYERROR_VERBOSE */ @@ -3889,45 +3830,42 @@ | Release the memory associated to this symbol. | `-----------------------------------------------*/ -/*ARGSUSED*/ + /*ARGSUSED*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) -static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +static void yydestruct(const char *yymsg, int yytype, YYSTYPE * yyvaluep) #else -static void -yydestruct (yymsg, yytype, yyvaluep) - const char *yymsg; - int yytype; - YYSTYPE *yyvaluep; +static void yydestruct(yymsg, yytype, yyvaluep) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; #endif { - YYUSE (yyvaluep); + YYUSE(yyvaluep); - if (!yymsg) - yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT(yymsg, yytype, yyvaluep, yylocationp); - switch (yytype) - { + switch (yytype) { - default: - break; - } + default: + break; + } } /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus -int yyparse (void *YYPARSE_PARAM); +int yyparse(void *YYPARSE_PARAM); #else -int yyparse (); +int yyparse(); #endif -#else /* ! YYPARSE_PARAM */ +#else /* ! YYPARSE_PARAM */ #if defined __STDC__ || defined __cplusplus -int yyparse (void); +int yyparse(void); #else -int yyparse (); +int yyparse(); #endif #endif /* ! YYPARSE_PARAM */ @@ -3950,170 +3888,159 @@ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) -int -yyparse (void *YYPARSE_PARAM) +int yyparse(void *YYPARSE_PARAM) #else -int -yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; +int yyparse(YYPARSE_PARAM) + void *YYPARSE_PARAM; #endif -#else /* ! YYPARSE_PARAM */ +#else /* ! YYPARSE_PARAM */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) -int -yyparse (void) +int yyparse(void) #else -int -yyparse () - +int yyparse() #endif #endif { - int yystate; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; - /* The stacks and their tools: - `yyss': related to states. - `yyvs': related to semantic values. + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss; - yytype_int16 *yyssp; + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs; - YYSTYPE *yyvsp; + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; - YYSIZE_T yystacksize; + YYSIZE_T yystacksize; - int yyn; - int yyresult; - /* Lookahead token as an internal (translated) token number. */ - int yytoken; - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; #if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) - /* The number of symbols on the RHS of the reduced rule. - Keep to zero when no symbol should be popped. */ - int yylen = 0; + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; - yytoken = 0; - yyss = yyssa; - yyvs = yyvsa; - yystacksize = YYINITDEPTH; + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yystacksize = YYINITDEPTH; - YYDPRINTF ((stderr, "Starting parse\n")); + YYDPRINTF((stderr, "Starting parse\n")); - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - yyssp = yyss; - yyvsp = yyvs; + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + yyssp = yyss; + yyvsp = yyvs; - goto yysetstate; + goto yysetstate; /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ - yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. So pushing a state here evens the stacks. */ - yyssp++; +yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; - yysetstate: - *yyssp = yystate; +yysetstate: + *yyssp = yystate; - if (yyss + yystacksize - 1 <= yyssp) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; + if (yyss + yystacksize - 1 <= yyssp) { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow(YY_("memory exhausted"), &yyss1, yysize * sizeof(*yyssp), &yyvs1, yysize * sizeof(*yyvsp), &yystacksize); - yyss = yyss1; - yyvs = yyvs1; - } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else - /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; - yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +#ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +#else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; - { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss_alloc, yyss); - YYSTACK_RELOCATE (yyvs_alloc, yyvs); -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC(YYSTACK_BYTES(yystacksize)); + if (!yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE(yyss_alloc, yyss); + YYSTACK_RELOCATE(yyvs_alloc, yyvs); +#undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE(yyss1); + } +#endif #endif /* no yyoverflow */ - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + YYDPRINTF((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); - if (yyss + yystacksize - 1 <= yyssp) - YYABORT; - } + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + YYDPRINTF((stderr, "Entering state %d\n", yystate)); - if (yystate == YYFINAL) - YYACCEPT; + if (yystate == YYFINAL) + YYACCEPT; - goto yybackup; + goto yybackup; /*-----------. | yybackup. | @@ -4120,63 +4047,59 @@ `-----------*/ yybackup: - /* Do appropriate processing given the current state. Read a - lookahead token if we need one and don't already have one. */ + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ - /* First try to decide what to do without reference to lookahead token. */ - yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) - goto yydefault; + /* First try to decide what to do without reference to lookahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; - /* Not known => get a lookahead token if don't already have one. */ + /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ - if (yychar == YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; - } + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) { + YYDPRINTF((stderr, "Reading a token: ")); + yychar = YYLEX; + } - if (yychar <= YYEOF) - { - yychar = yytoken = YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - else - { - yytoken = YYTRANSLATE (yychar); - YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); - } + if (yychar <= YYEOF) { + yychar = yytoken = YYEOF; + YYDPRINTF((stderr, "Now at end of input.\n")); + } + else { + yytoken = YYTRANSLATE(yychar); + YY_SYMBOL_PRINT("Next token is", yytoken, &yylval, &yylloc); + } - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) - goto yydefault; - yyn = yytable[yyn]; - if (yyn <= 0) - { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; - /* Shift the lookahead token. */ - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT("Shifting", yytoken, &yylval, &yylloc); - /* Discard the shifted token. */ - yychar = YYEMPTY; + /* Discard the shifted token. */ + yychar = YYEMPTY; - yystate = yyn; - *++yyvsp = yylval; + yystate = yyn; + *++yyvsp = yylval; - goto yynewstate; + goto yynewstate; /*-----------------------------------------------------------. @@ -4183,10 +4106,10 @@ | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; /*-----------------------------. @@ -4193,971 +4116,1242 @@ | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: - /* yyn is the number of a rule to reduce with. */ - yylen = yyr2[yyn]; + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; - /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1 - yylen]; - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 2: + YY_REDUCE_PRINT(yyn); + switch (yyn) { + case 2: /* Line 1464 of yacc.c */ #line 505 "edif.y" - { PopC(); } - break; + { + PopC(); + } + break; - case 11: + case 11: /* Line 1464 of yacc.c */ #line 520 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 12: + case 12: /* Line 1464 of yacc.c */ #line 523 "edif.y" - { free((yyvsp[(2) - (3)].s)); } - break; + { + free((yyvsp[(2) - (3)].s)); + } + break; - case 13: + case 13: /* Line 1464 of yacc.c */ #line 527 "edif.y" - { free((yyvsp[(2) - (5)].s)); free((yyvsp[(3) - (5)].s)); free((yyvsp[(4) - (5)].s)); } - break; + { + free((yyvsp[(2) - (5)].s)); + free((yyvsp[(3) - (5)].s)); + free((yyvsp[(4) - (5)].s)); + } + break; - case 25: + case 25: /* Line 1464 of yacc.c */ #line 551 "edif.y" - { free((yyvsp[(1) - (1)].s)); } - break; + { + free((yyvsp[(1) - (1)].s)); + } + break; - case 34: + case 34: /* Line 1464 of yacc.c */ #line 568 "edif.y" - { str_pair_free((yyvsp[(2) - (5)].ps)); free((yyvsp[(3) - (5)].s)); } - break; + { + str_pair_free((yyvsp[(2) - (5)].ps)); + free((yyvsp[(3) - (5)].s)); + } + break; - case 36: + case 36: /* Line 1464 of yacc.c */ #line 572 "edif.y" - { free((yyvsp[(1) - (1)].s)); } - break; + { + free((yyvsp[(1) - (1)].s)); + } + break; - case 47: + case 47: /* Line 1464 of yacc.c */ #line 597 "edif.y" - { free((yyvsp[(2) - (3)].s)); } - break; + { + free((yyvsp[(2) - (3)].s)); + } + break; - case 69: + case 69: /* Line 1464 of yacc.c */ #line 645 "edif.y" - { free((yyvsp[(2) - (5)].s)); free((yyvsp[(3) - (5)].s)); } - break; + { + free((yyvsp[(2) - (5)].s)); + free((yyvsp[(3) - (5)].s)); + } + break; - case 70: + case 70: /* Line 1464 of yacc.c */ #line 648 "edif.y" - { free((yyvsp[(2) - (3)].s)); } - break; + { + free((yyvsp[(2) - (3)].s)); + } + break; - case 80: + case 80: /* Line 1464 of yacc.c */ #line 666 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 84: + case 84: /* Line 1464 of yacc.c */ #line 676 "edif.y" - { free((yyvsp[(1) - (1)].s)); } - break; + { + free((yyvsp[(1) - (1)].s)); + } + break; - case 91: + case 91: /* Line 1464 of yacc.c */ #line 691 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 102: + case 102: /* Line 1464 of yacc.c */ #line 714 "edif.y" - { free((yyvsp[(2) - (2)].s)); } - break; + { + free((yyvsp[(2) - (2)].s)); + } + break; - case 140: + case 140: /* Line 1464 of yacc.c */ #line 774 "edif.y" - { free((yyvsp[(1) - (1)].s)); } - break; + { + free((yyvsp[(1) - (1)].s)); + } + break; - case 147: + case 147: /* Line 1464 of yacc.c */ #line 789 "edif.y" - { free((yyvsp[(2) - (4)].s)); } - break; + { + free((yyvsp[(2) - (4)].s)); + } + break; - case 150: + case 150: /* Line 1464 of yacc.c */ #line 796 "edif.y" - { free((yyvsp[(2) - (4)].s)); } - break; + { + free((yyvsp[(2) - (4)].s)); + } + break; - case 182: + case 182: /* Line 1464 of yacc.c */ #line 866 "edif.y" - { free((yyvsp[(1) - (1)].s)); } - break; + { + free((yyvsp[(1) - (1)].s)); + } + break; - case 184: + case 184: /* Line 1464 of yacc.c */ #line 870 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 240: + case 240: /* Line 1464 of yacc.c */ #line 974 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 247: + case 247: /* Line 1464 of yacc.c */ #line 987 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 278: + case 278: /* Line 1464 of yacc.c */ #line 1034 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 279: + case 279: /* Line 1464 of yacc.c */ #line 1037 "edif.y" - { free((yyvsp[(1) - (1)].s)); } - break; + { + free((yyvsp[(1) - (1)].s)); + } + break; - case 333: + case 333: /* Line 1464 of yacc.c */ #line 1123 "edif.y" - { free((yyvsp[(2) - (5)].s)); free((yyvsp[(3) - (5)].s)); } - break; + { + free((yyvsp[(2) - (5)].s)); + free((yyvsp[(3) - (5)].s)); + } + break; - case 336: + case 336: /* Line 1464 of yacc.c */ #line 1130 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 337: + case 337: /* Line 1464 of yacc.c */ #line 1133 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 344: + case 344: /* Line 1464 of yacc.c */ #line 1146 "edif.y" - { free((yyvsp[(1) - (3)].s)); } - break; + { + free((yyvsp[(1) - (3)].s)); + } + break; - case 346: + case 346: /* Line 1464 of yacc.c */ #line 1150 "edif.y" - { free((yyvsp[(2) - (2)].s)); } - break; + { + free((yyvsp[(2) - (2)].s)); + } + break; - case 347: + case 347: /* Line 1464 of yacc.c */ #line 1151 "edif.y" - { free((yyvsp[(2) - (2)].s)); } - break; + { + free((yyvsp[(2) - (2)].s)); + } + break; - case 348: + case 348: /* Line 1464 of yacc.c */ #line 1152 "edif.y" - { free((yyvsp[(2) - (2)].s)); } - break; + { + free((yyvsp[(2) - (2)].s)); + } + break; - case 369: + case 369: /* Line 1464 of yacc.c */ #line 1193 "edif.y" - { (yyval.s)=(yyvsp[(2) - (4)].s); } - break; + { + (yyval.s) = (yyvsp[(2) - (4)].s); + } + break; - case 371: + case 371: /* Line 1464 of yacc.c */ #line 1197 "edif.y" - { free((yyvsp[(1) - (1)].s)); } - break; + { + free((yyvsp[(1) - (1)].s)); + } + break; - case 374: + case 374: /* Line 1464 of yacc.c */ #line 1204 "edif.y" - { free((yyvsp[(1) - (1)].s)); } - break; + { + free((yyvsp[(1) - (1)].s)); + } + break; - case 381: + case 381: /* Line 1464 of yacc.c */ #line 1215 "edif.y" - { free((yyvsp[(2) - (2)].s)); } - break; + { + free((yyvsp[(2) - (2)].s)); + } + break; - case 384: + case 384: /* Line 1464 of yacc.c */ #line 1222 "edif.y" - { free((yyvsp[(2) - (2)].s)); } - break; + { + free((yyvsp[(2) - (2)].s)); + } + break; - case 388: + case 388: /* Line 1464 of yacc.c */ #line 1228 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 390: + case 390: /* Line 1464 of yacc.c */ #line 1232 "edif.y" - { (yyval.s)=(yyvsp[(1) - (1)].s); } - break; + { + (yyval.s) = (yyvsp[(1) - (1)].s); + } + break; - case 393: + case 393: /* Line 1464 of yacc.c */ #line 1239 "edif.y" - { free((yyvsp[(1) - (1)].s)); } - break; + { + free((yyvsp[(1) - (1)].s)); + } + break; - case 397: + case 397: /* Line 1464 of yacc.c */ #line 1247 "edif.y" - { free((yyvsp[(2) - (2)].s)); } - break; + { + free((yyvsp[(2) - (2)].s)); + } + break; - case 408: + case 408: /* Line 1464 of yacc.c */ #line 1262 "edif.y" - { pair_list_free((yyvsp[(2) - (2)].pl)); } - break; + { + pair_list_free((yyvsp[(2) - (2)].pl)); + } + break; - case 437: + case 437: /* Line 1464 of yacc.c */ #line 1312 "edif.y" - { (yyval.pl) = new_pair_list((yyvsp[(2) - (3)].ps)); } - break; + { + (yyval.pl) = new_pair_list((yyvsp[(2) - (3)].ps)); + } + break; - case 438: + case 438: /* Line 1464 of yacc.c */ #line 1315 "edif.y" - { (yyval.ps)=NULL; } - break; + { + (yyval.ps) = NULL; + } + break; - case 439: + case 439: /* Line 1464 of yacc.c */ #line 1316 "edif.y" - { (yyvsp[(2) - (2)].ps)->next = (yyvsp[(1) - (2)].ps); (yyval.ps) = (yyvsp[(2) - (2)].ps); } - break; + { + (yyvsp[(2) - (2)].ps)->next = (yyvsp[(1) - (2)].ps); + (yyval.ps) = (yyvsp[(2) - (2)].ps); + } + break; - case 455: + case 455: /* Line 1464 of yacc.c */ #line 1342 "edif.y" - { free((yyvsp[(2) - (3)].s)); } - break; + { + free((yyvsp[(2) - (3)].s)); + } + break; - case 459: + case 459: /* Line 1464 of yacc.c */ #line 1352 "edif.y" - { free((yyvsp[(1) - (1)].s)); } - break; + { + free((yyvsp[(1) - (1)].s)); + } + break; - case 460: + case 460: /* Line 1464 of yacc.c */ #line 1355 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 462: + case 462: /* Line 1464 of yacc.c */ #line 1361 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 463: + case 463: /* Line 1464 of yacc.c */ #line 1364 "edif.y" - { free((yyvsp[(1) - (1)].s)); } - break; + { + free((yyvsp[(1) - (1)].s)); + } + break; - case 483: + case 483: /* Line 1464 of yacc.c */ #line 1406 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 484: + case 484: /* Line 1464 of yacc.c */ #line 1409 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 492: + case 492: /* Line 1464 of yacc.c */ #line 1423 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 506: + case 506: /* Line 1464 of yacc.c */ #line 1451 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 507: + case 507: /* Line 1464 of yacc.c */ #line 1454 "edif.y" - { free((yyvsp[(1) - (1)].s)); } - break; + { + free((yyvsp[(1) - (1)].s)); + } + break; - case 514: + case 514: /* Line 1464 of yacc.c */ #line 1469 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 549: + case 549: /* Line 1464 of yacc.c */ #line 1524 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 555: + case 555: /* Line 1464 of yacc.c */ #line 1536 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 560: + case 560: /* Line 1464 of yacc.c */ #line 1545 "edif.y" - { free((yyvsp[(2) - (4)].s)); } - break; + { + free((yyvsp[(2) - (4)].s)); + } + break; - case 561: + case 561: /* Line 1464 of yacc.c */ #line 1548 "edif.y" - { free((yyvsp[(1) - (1)].s)); } - break; + { + free((yyvsp[(1) - (1)].s)); + } + break; - case 562: + case 562: /* Line 1464 of yacc.c */ #line 1549 "edif.y" - { free((yyvsp[(2) - (2)].s)); } - break; + { + free((yyvsp[(2) - (2)].s)); + } + break; - case 582: + case 582: /* Line 1464 of yacc.c */ #line 1591 "edif.y" - { str_pair_free((yyvsp[(2) - (2)].ps)); } - break; + { + str_pair_free((yyvsp[(2) - (2)].ps)); + } + break; - case 585: + case 585: /* Line 1464 of yacc.c */ #line 1594 "edif.y" - { pair_list_free((yyvsp[(2) - (2)].pl)); } - break; + { + pair_list_free((yyvsp[(2) - (2)].pl)); + } + break; - case 586: + case 586: /* Line 1464 of yacc.c */ #line 1597 "edif.y" - { (yyval.s)=(yyvsp[(2) - (3)].s); } - break; + { + (yyval.s) = (yyvsp[(2) - (3)].s); + } + break; - case 587: + case 587: /* Line 1464 of yacc.c */ #line 1600 "edif.y" - { (yyval.s)=(yyvsp[(1) - (1)].s); } - break; + { + (yyval.s) = (yyvsp[(1) - (1)].s); + } + break; - case 589: + case 589: /* Line 1464 of yacc.c */ #line 1604 "edif.y" - { (yyval.ps) = new_str_pair((yyvsp[(1) - (1)].s),NULL); } - break; + { + (yyval.ps) = new_str_pair((yyvsp[(1) - (1)].s), NULL); + } + break; - case 590: + case 590: /* Line 1464 of yacc.c */ #line 1605 "edif.y" - { (yyval.ps) = new_str_pair((yyvsp[(1) - (1)].s),NULL); } - break; + { + (yyval.ps) = new_str_pair((yyvsp[(1) - (1)].s), NULL); + } + break; - case 591: + case 591: /* Line 1464 of yacc.c */ #line 1606 "edif.y" - { (yyval.ps)=(yyvsp[(1) - (1)].ps); } - break; + { + (yyval.ps) = (yyvsp[(1) - (1)].ps); + } + break; - case 592: + case 592: /* Line 1464 of yacc.c */ #line 1609 "edif.y" - { (yyval.s)=(yyvsp[(1) - (1)].s); } - break; + { + (yyval.s) = (yyvsp[(1) - (1)].s); + } + break; - case 593: + case 593: /* Line 1464 of yacc.c */ #line 1610 "edif.y" - { (yyval.s)=(yyvsp[(1) - (1)].s); } - break; + { + (yyval.s) = (yyvsp[(1) - (1)].s); + } + break; - case 594: + case 594: /* Line 1464 of yacc.c */ #line 1613 "edif.y" - { define_pcb_net((yyvsp[(2) - (4)].ps), (yyvsp[(3) - (4)].pl)); } - break; + { + define_pcb_net((yyvsp[(2) - (4)].ps), (yyvsp[(3) - (4)].pl)); + } + break; - case 595: + case 595: /* Line 1464 of yacc.c */ #line 1616 "edif.y" - { (yyval.pl)=(yyvsp[(1) - (1)].pl); } - break; + { + (yyval.pl) = (yyvsp[(1) - (1)].pl); + } + break; - case 611: + case 611: /* Line 1464 of yacc.c */ #line 1638 "edif.y" - { str_pair_free((yyvsp[(2) - (4)].ps)); } - break; + { + str_pair_free((yyvsp[(2) - (4)].ps)); + } + break; - case 632: + case 632: /* Line 1464 of yacc.c */ #line 1675 "edif.y" - { (yyval.ps)=(yyvsp[(1) - (1)].ps); } - break; + { + (yyval.ps) = (yyvsp[(1) - (1)].ps); + } + break; - case 633: + case 633: /* Line 1464 of yacc.c */ #line 1676 "edif.y" - { (yyval.ps)=NULL; } - break; + { + (yyval.ps) = NULL; + } + break; - case 634: + case 634: /* Line 1464 of yacc.c */ #line 1680 "edif.y" - { free((yyvsp[(1) - (1)].s)); } - break; + { + free((yyvsp[(1) - (1)].s)); + } + break; - case 639: + case 639: /* Line 1464 of yacc.c */ #line 1689 "edif.y" - { free((yyvsp[(1) - (1)].s)); } - break; + { + free((yyvsp[(1) - (1)].s)); + } + break; - case 644: + case 644: /* Line 1464 of yacc.c */ #line 1700 "edif.y" - { str_pair_free((yyvsp[(2) - (2)].ps)); } - break; + { + str_pair_free((yyvsp[(2) - (2)].ps)); + } + break; - case 698: + case 698: /* Line 1464 of yacc.c */ #line 1802 "edif.y" - { free((yyvsp[(2) - (5)].s)); } - break; + { + free((yyvsp[(2) - (5)].s)); + } + break; - case 701: + case 701: /* Line 1464 of yacc.c */ #line 1809 "edif.y" - { free((yyvsp[(2) - (3)].s)); } - break; + { + free((yyvsp[(2) - (3)].s)); + } + break; - case 727: + case 727: /* Line 1464 of yacc.c */ #line 1861 "edif.y" - { free((yyvsp[(2) - (3)].s)); } - break; + { + free((yyvsp[(2) - (3)].s)); + } + break; - case 730: + case 730: /* Line 1464 of yacc.c */ #line 1868 "edif.y" - { str_pair_free((yyvsp[(2) - (2)].ps)); } - break; + { + str_pair_free((yyvsp[(2) - (2)].ps)); + } + break; - case 747: + case 747: /* Line 1464 of yacc.c */ #line 1903 "edif.y" - { free((yyvsp[(2) - (4)].s)); free((yyvsp[(3) - (4)].s)); } - break; + { + free((yyvsp[(2) - (4)].s)); + free((yyvsp[(3) - (4)].s)); + } + break; - case 766: + case 766: /* Line 1464 of yacc.c */ #line 1934 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 789: + case 789: /* Line 1464 of yacc.c */ #line 1969 "edif.y" - { str_pair_free((yyvsp[(2) - (2)].ps)); } - break; + { + str_pair_free((yyvsp[(2) - (2)].ps)); + } + break; - case 791: + case 791: /* Line 1464 of yacc.c */ #line 1975 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 803: + case 803: /* Line 1464 of yacc.c */ #line 1991 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 818: + case 818: /* Line 1464 of yacc.c */ #line 2010 "edif.y" - { str_pair_free((yyvsp[(2) - (2)].ps)); } - break; + { + str_pair_free((yyvsp[(2) - (2)].ps)); + } + break; - case 823: + case 823: /* Line 1464 of yacc.c */ #line 2021 "edif.y" - { str_pair_free((yyvsp[(2) - (2)].ps)); } - break; + { + str_pair_free((yyvsp[(2) - (2)].ps)); + } + break; - case 827: + case 827: /* Line 1464 of yacc.c */ #line 2027 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 829: + case 829: /* Line 1464 of yacc.c */ #line 2031 "edif.y" - { (yyval.s)=(yyvsp[(1) - (1)].s); } - break; + { + (yyval.s) = (yyvsp[(1) - (1)].s); + } + break; - case 831: + case 831: /* Line 1464 of yacc.c */ #line 2036 "edif.y" - { - if ((yyvsp[(3) - (4)].ps)) - { - (yyval.ps) = new_str_pair((yyvsp[(3) - (4)].ps)->str1,(yyvsp[(2) - (4)].s)); - free((yyvsp[(3) - (4)].ps)); - } - else - { - /* handle port with no instance by passing up the chain */ - (yyval.ps) = new_str_pair(NULL,(yyvsp[(2) - (4)].s)); - } -} - break; + { + if ((yyvsp[(3) - (4)].ps)) { + (yyval.ps) = new_str_pair((yyvsp[(3) - (4)].ps)->str1, (yyvsp[(2) - (4)].s)); + free((yyvsp[(3) - (4)].ps)); + } + else { + /* handle port with no instance by passing up the chain */ + (yyval.ps) = new_str_pair(NULL, (yyvsp[(2) - (4)].s)); + } + } + break; - case 832: + case 832: /* Line 1464 of yacc.c */ #line 2050 "edif.y" - { (yyval.ps)=NULL; } - break; + { + (yyval.ps) = NULL; + } + break; - case 833: + case 833: /* Line 1464 of yacc.c */ #line 2051 "edif.y" - { (yyval.ps)=(yyvsp[(1) - (1)].ps); } - break; + { + (yyval.ps) = (yyvsp[(1) - (1)].ps); + } + break; - case 834: + case 834: /* Line 1464 of yacc.c */ #line 2052 "edif.y" - { (yyval.ps) = new_str_pair((yyvsp[(1) - (1)].s),NULL); } - break; + { + (yyval.ps) = new_str_pair((yyvsp[(1) - (1)].s), NULL); + } + break; - case 835: + case 835: /* Line 1464 of yacc.c */ #line 2053 "edif.y" - { (yyval.ps)=NULL; } - break; + { + (yyval.ps) = NULL; + } + break; - case 848: + case 848: /* Line 1464 of yacc.c */ #line 2080 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 849: + case 849: /* Line 1464 of yacc.c */ #line 2083 "edif.y" - { free((yyvsp[(1) - (1)].s)); } - break; + { + free((yyvsp[(1) - (1)].s)); + } + break; - case 881: + case 881: /* Line 1464 of yacc.c */ #line 2136 "edif.y" - { (yyval.ps) = new_str_pair((yyvsp[(2) - (4)].s),(yyvsp[(3) - (4)].s)); } - break; + { + (yyval.ps) = new_str_pair((yyvsp[(2) - (4)].s), (yyvsp[(3) - (4)].s)); + } + break; - case 882: + case 882: /* Line 1464 of yacc.c */ #line 2139 "edif.y" - { (yyval.s)=(yyvsp[(1) - (1)].s); } - break; + { + (yyval.s) = (yyvsp[(1) - (1)].s); + } + break; - case 883: + case 883: /* Line 1464 of yacc.c */ #line 2140 "edif.y" - { (yyval.s)=(yyvsp[(1) - (1)].s); } - break; + { + (yyval.s) = (yyvsp[(1) - (1)].s); + } + break; - case 884: + case 884: /* Line 1464 of yacc.c */ #line 2143 "edif.y" - { (yyval.s)=(yyvsp[(1) - (1)].s); } - break; + { + (yyval.s) = (yyvsp[(1) - (1)].s); + } + break; - case 885: + case 885: /* Line 1464 of yacc.c */ #line 2144 "edif.y" - { (yyval.s)=NULL; } - break; + { + (yyval.s) = NULL; + } + break; - case 889: + case 889: /* Line 1464 of yacc.c */ #line 2154 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 891: + case 891: /* Line 1464 of yacc.c */ #line 2160 "edif.y" - { free((yyvsp[(1) - (1)].s)); } - break; + { + free((yyvsp[(1) - (1)].s)); + } + break; - case 892: + case 892: /* Line 1464 of yacc.c */ #line 2161 "edif.y" - { free((yyvsp[(2) - (4)].s)); free((yyvsp[(3) - (4)].s)); } - break; + { + free((yyvsp[(2) - (4)].s)); + free((yyvsp[(3) - (4)].s)); + } + break; - case 893: + case 893: /* Line 1464 of yacc.c */ #line 2164 "edif.y" - { free((yyvsp[(2) - (4)].s)); free((yyvsp[(3) - (4)].s)); } - break; + { + free((yyvsp[(2) - (4)].s)); + free((yyvsp[(3) - (4)].s)); + } + break; - case 894: + case 894: /* Line 1464 of yacc.c */ #line 2167 "edif.y" - { free((yyvsp[(2) - (4)].s)); free((yyvsp[(3) - (4)].s)); } - break; + { + free((yyvsp[(2) - (4)].s)); + free((yyvsp[(3) - (4)].s)); + } + break; - case 896: + case 896: /* Line 1464 of yacc.c */ #line 2173 "edif.y" - { free((yyvsp[(1) - (1)].s)); } - break; + { + free((yyvsp[(1) - (1)].s)); + } + break; - case 898: + case 898: /* Line 1464 of yacc.c */ #line 2175 "edif.y" - { free((yyvsp[(2) - (2)].s)); } - break; + { + free((yyvsp[(2) - (2)].s)); + } + break; - case 903: + case 903: /* Line 1464 of yacc.c */ #line 2186 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 935: + case 935: /* Line 1464 of yacc.c */ #line 2250 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 943: + case 943: /* Line 1464 of yacc.c */ #line 2266 "edif.y" - { free((yyvsp[(2) - (2)].s)); } - break; + { + free((yyvsp[(2) - (2)].s)); + } + break; - case 946: + case 946: /* Line 1464 of yacc.c */ #line 2271 "edif.y" - { free((yyvsp[(1) - (1)].s)); } - break; + { + free((yyvsp[(1) - (1)].s)); + } + break; - case 973: + case 973: /* Line 1464 of yacc.c */ #line 2316 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 987: + case 987: /* Line 1464 of yacc.c */ #line 2338 "edif.y" - { free((yyvsp[(2) - (3)].s)); } - break; + { + free((yyvsp[(2) - (3)].s)); + } + break; - case 994: + case 994: /* Line 1464 of yacc.c */ #line 2354 "edif.y" - { free((yyvsp[(2) - (8)].s)); free((yyvsp[(3) - (8)].s)); free((yyvsp[(4) - (8)].s)); free((yyvsp[(5) - (8)].s)); free((yyvsp[(6) - (8)].s)); free((yyvsp[(7) - (8)].s)); } - break; + { + free((yyvsp[(2) - (8)].s)); + free((yyvsp[(3) - (8)].s)); + free((yyvsp[(4) - (8)].s)); + free((yyvsp[(5) - (8)].s)); + free((yyvsp[(6) - (8)].s)); + free((yyvsp[(7) - (8)].s)); + } + break; - case 1054: + case 1054: /* Line 1464 of yacc.c */ #line 2461 "edif.y" - { free((yyvsp[(1) - (1)].s)); } - break; + { + free((yyvsp[(1) - (1)].s)); + } + break; - case 1055: + case 1055: /* Line 1464 of yacc.c */ #line 2462 "edif.y" - { free((yyvsp[(2) - (2)].s)); } - break; + { + free((yyvsp[(2) - (2)].s)); + } + break; - case 1056: + case 1056: /* Line 1464 of yacc.c */ #line 2463 "edif.y" - { free((yyvsp[(2) - (2)].s)); } - break; + { + free((yyvsp[(2) - (2)].s)); + } + break; - case 1057: + case 1057: /* Line 1464 of yacc.c */ #line 2464 "edif.y" - { free((yyvsp[(2) - (2)].s)); } - break; + { + free((yyvsp[(2) - (2)].s)); + } + break; - case 1059: + case 1059: /* Line 1464 of yacc.c */ #line 2468 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 1061: + case 1061: /* Line 1464 of yacc.c */ #line 2472 "edif.y" - { free((yyvsp[(1) - (1)].s)); } - break; + { + free((yyvsp[(1) - (1)].s)); + } + break; - case 1063: + case 1063: /* Line 1464 of yacc.c */ #line 2476 "edif.y" - { free((yyvsp[(2) - (3)].s)); } - break; + { + free((yyvsp[(2) - (3)].s)); + } + break; - case 1085: + case 1085: /* Line 1464 of yacc.c */ #line 2512 "edif.y" - { str_pair_free((yyvsp[(1) - (1)].ps)); } - break; + { + str_pair_free((yyvsp[(1) - (1)].ps)); + } + break; - case 1086: + case 1086: /* Line 1464 of yacc.c */ #line 2515 "edif.y" - { free((yyvsp[(1) - (1)].s)); } - break; + { + free((yyvsp[(1) - (1)].s)); + } + break; - case 1107: + case 1107: /* Line 1464 of yacc.c */ #line 2556 "edif.y" - { str_pair_free((yyvsp[(2) - (2)].ps)); } - break; + { + str_pair_free((yyvsp[(2) - (2)].ps)); + } + break; - case 1109: + case 1109: /* Line 1464 of yacc.c */ #line 2558 "edif.y" - { pair_list_free((yyvsp[(2) - (2)].pl)); } - break; + { + pair_list_free((yyvsp[(2) - (2)].pl)); + } + break; - case 1126: + case 1126: /* Line 1464 of yacc.c */ #line 2585 "edif.y" - { (yyval.s)=(yyvsp[(1) - (1)].s); } - break; + { + (yyval.s) = (yyvsp[(1) - (1)].s); + } + break; - case 1127: + case 1127: /* Line 1464 of yacc.c */ #line 2588 "edif.y" - { (yyval.s)=(yyvsp[(1) - (1)].s); } - break; + { + (yyval.s) = (yyvsp[(1) - (1)].s); + } + break; - case 1128: + case 1128: /* Line 1464 of yacc.c */ #line 2591 "edif.y" - { (yyval.s)=(yyvsp[(1) - (1)].s); } - break; + { + (yyval.s) = (yyvsp[(1) - (1)].s); + } + break; - case 1129: + case 1129: /* Line 1464 of yacc.c */ #line 2594 "edif.y" - { (yyval.s)=(yyvsp[(1) - (1)].s); } - break; + { + (yyval.s) = (yyvsp[(1) - (1)].s); + } + break; /* Line 1464 of yacc.c */ #line 5138 "edif.c" - default: break; - } - YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + default: + break; + } + YY_SYMBOL_PRINT("-> $$ =", yyr1[yyn], &yyval, &yyloc); - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); + YYPOPSTACK(yylen); + yylen = 0; + YY_STACK_PRINT(yyss, yyssp); - *++yyvsp = yyval; + *++yyvsp = yyval; - /* Now `shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ - yyn = yyr1[yyn]; + yyn = yyr1[yyn]; - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; - goto yynewstate; + goto yynewstate; /*------------------------------------. @@ -5164,71 +5358,62 @@ | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) { + ++yynerrs; #if ! YYERROR_VERBOSE - yyerror (YY_("syntax error")); + yyerror(YY_("syntax error")); #else - { - YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); - if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) - { - YYSIZE_T yyalloc = 2 * yysize; - if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) - yyalloc = YYSTACK_ALLOC_MAXIMUM; - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yyalloc); - if (yymsg) - yymsg_alloc = yyalloc; - else - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - } - } + { + YYSIZE_T yysize = yysyntax_error(0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) { + YYSIZE_T yyalloc = 2 * yysize; + if (!(yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE(yymsg); + yymsg = (char *) YYSTACK_ALLOC(yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } - if (0 < yysize && yysize <= yymsg_alloc) - { - (void) yysyntax_error (yymsg, yystate, yychar); - yyerror (yymsg); - } - else - { - yyerror (YY_("syntax error")); - if (yysize != 0) - goto yyexhaustedlab; - } - } + if (0 < yysize && yysize <= yymsg_alloc) { + (void) yysyntax_error(yymsg, yystate, yychar); + yyerror(yymsg); + } + else { + yyerror(YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } #endif - } + } - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ + if (yyerrstatus == 3) { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ - if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; + if (yychar <= YYEOF) { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else { + yydestruct("Error: discarding", yytoken, &yylval); + yychar = YYEMPTY; + } } - else - { - yydestruct ("Error: discarding", - yytoken, &yylval); - yychar = YYEMPTY; - } - } - /* Else will try to reuse lookahead token after shifting the error - token. */ - goto yyerrlab1; + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; /*---------------------------------------------------. @@ -5236,19 +5421,19 @@ `---------------------------------------------------*/ yyerrorlab: - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if ( /*CONSTCOND*/ 0) + goto yyerrorlab; - /* Do not reclaim the symbols of the rule which action triggered - this YYERROR. */ - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - yystate = *yyssp; - goto yyerrlab1; + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK(yylen); + yylen = 0; + YY_STACK_PRINT(yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; /*-------------------------------------------------------------. @@ -5255,42 +5440,38 @@ | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ + yyerrstatus = 3; /* Each real token shifted decrements this. */ - for (;;) - { - yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } + for (;;) { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; - yydestruct ("Error: popping", - yystos[yystate], yyvsp); - YYPOPSTACK (1); - yystate = *yyssp; - YY_STACK_PRINT (yyss, yyssp); - } + yydestruct("Error: popping", yystos[yystate], yyvsp); + YYPOPSTACK(1); + yystate = *yyssp; + YY_STACK_PRINT(yyss, yyssp); + } - *++yyvsp = yylval; + *++yyvsp = yylval; - /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + /* Shift the error token. */ + YY_SYMBOL_PRINT("Shifting", yystos[yyn], yyvsp, yylsp); - yystate = yyn; - goto yynewstate; + yystate = yyn; + goto yynewstate; /*-------------------------------------. @@ -5297,15 +5478,15 @@ | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ yyacceptlab: - yyresult = 0; - goto yyreturn; + yyresult = 0; + goto yyreturn; /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: - yyresult = 1; - goto yyreturn; + yyresult = 1; + goto yyreturn; #if !defined(yyoverflow) || YYERROR_VERBOSE /*-------------------------------------------------. @@ -5312,35 +5493,32 @@ | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: - yyerror (YY_("memory exhausted")); - yyresult = 2; - /* Fall through. */ + yyerror(YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ #endif yyreturn: - if (yychar != YYEMPTY) - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval); - /* Do not reclaim the symbols of the rule which action triggered - this YYABORT or YYACCEPT. */ - YYPOPSTACK (yylen); - YY_STACK_PRINT (yyss, yyssp); - while (yyssp != yyss) - { - yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); - YYPOPSTACK (1); - } + if (yychar != YYEMPTY) + yydestruct("Cleanup: discarding lookahead", yytoken, &yylval); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK(yylen); + YY_STACK_PRINT(yyss, yyssp); + while (yyssp != yyss) { + yydestruct("Cleanup: popping", yystos[*yyssp], yyvsp); + YYPOPSTACK(1); + } #ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); + if (yyss != yyssa) + YYSTACK_FREE(yyss); #endif #if YYERROR_VERBOSE - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); + if (yymsg != yymsgbuf) + YYSTACK_FREE(yymsg); #endif - /* Make sure YYID is used. */ - return YYID (yyresult); + /* Make sure YYID is used. */ + return YYID(yyresult); } @@ -5355,8 +5533,9 @@ */ char *xmalloc(int siz) { - return ((char *)Malloc(siz)); + return ((char *) Malloc(siz)); } + /* * Token & context carriers: * @@ -5364,20 +5543,20 @@ * for converting identifiers into parser tokens. */ typedef struct TokenCar { - struct TokenCar *Next; /* pointer to next carrier */ - struct Token *Token; /* associated token */ + struct TokenCar *Next; /* pointer to next carrier */ + struct Token *Token; /* associated token */ } TokenCar; typedef struct UsedCar { - struct UsedCar *Next; /* pointer to next carrier */ - short Code; /* used '%token' value */ + struct UsedCar *Next; /* pointer to next carrier */ + short Code; /* used '%token' value */ } UsedCar; typedef struct ContextCar { - struct ContextCar *Next; /* pointer to next carrier */ - struct Context *Context; /* associated context */ - union { - int Single; /* single usage flag (context tree) */ - struct UsedCar *Used; /* single used list (context stack) */ - } u; + struct ContextCar *Next; /* pointer to next carrier */ + struct Context *Context; /* associated context */ + union { + int Single; /* single usage flag (context tree) */ + struct UsedCar *Used; /* single used list (context stack) */ + } u; } ContextCar; /* * Token definitions: @@ -5387,67 +5566,68 @@ * strings must be in lower case. */ typedef struct Token { - char *Name; /* token name */ - int Code; /* '%token' value */ - struct Token *Next; /* hash table linkage */ + char *Name; /* token name */ + int Code; /* '%token' value */ + struct Token *Next; /* hash table linkage */ } Token; static Token TokenDef[] = { - {"angle", EDIF_TOK_ANGLE}, - {"behavior", EDIF_TOK_BEHAVIOR}, - {"calculated", EDIF_TOK_CALCULATED}, - {"capacitance", EDIF_TOK_CAPACITANCE}, - {"centercenter", EDIF_TOK_CENTERCENTER}, - {"centerleft", EDIF_TOK_CENTERLEFT}, - {"centerright", EDIF_TOK_CENTERRIGHT}, - {"charge", EDIF_TOK_CHARGE}, - {"conductance", EDIF_TOK_CONDUCTANCE}, - {"current", EDIF_TOK_CURRENT}, - {"distance", EDIF_TOK_DISTANCE}, - {"document", EDIF_TOK_DOCUMENT}, - {"energy", EDIF_TOK_ENERGY}, - {"extend", EDIF_TOK_EXTEND}, - {"flux", EDIF_TOK_FLUX}, - {"frequency", EDIF_TOK_FREQUENCY}, - {"generic", EDIF_TOK_GENERIC}, - {"graphic", EDIF_TOK_GRAPHIC}, - {"inductance", EDIF_TOK_INDUCTANCE}, - {"inout", EDIF_TOK_INOUT}, - {"input", EDIF_TOK_INPUT}, - {"logicmodel", EDIF_TOK_LOGICMODEL}, - {"lowercenter", EDIF_TOK_LOWERCENTER}, - {"lowerleft", EDIF_TOK_LOWERLEFT}, - {"lowerright", EDIF_TOK_LOWERRIGHT}, - {"masklayout", EDIF_TOK_MASKLAYOUT}, - {"mass", EDIF_TOK_MASS}, - {"measured", EDIF_TOK_MEASURED}, - {"mx", EDIF_TOK_MX}, - {"mxr90", EDIF_TOK_MXR90}, - {"my", EDIF_TOK_MY}, - {"myr90", EDIF_TOK_MYR90}, - {"netlist", EDIF_TOK_NETLIST}, - {"output", EDIF_TOK_OUTPUT}, - {"pcblayout", EDIF_TOK_PCBLAYOUT}, - {"power", EDIF_TOK_POWER}, - {"r0", EDIF_TOK_R0}, - {"r180", EDIF_TOK_R180}, - {"r270", EDIF_TOK_R270}, - {"r90", EDIF_TOK_R90}, - {"required", EDIF_TOK_REQUIRED}, - {"resistance", EDIF_TOK_RESISTANCE}, - {"ripper", EDIF_TOK_RIPPER}, - {"round", EDIF_TOK_ROUND}, - {"schematic", EDIF_TOK_SCHEMATIC}, - {"stranger", EDIF_TOK_STRANGER}, - {"symbolic", EDIF_TOK_SYMBOLIC}, - {"temperature", EDIF_TOK_TEMPERATURE}, - {"tie", EDIF_TOK_TIE}, - {"time", EDIF_TOK_TIME}, - {"truncate", EDIF_TOK_TRUNCATE}, - {"uppercenter", EDIF_TOK_UPPERCENTER}, - {"upperleft", EDIF_TOK_UPPERLEFT}, - {"upperright", EDIF_TOK_UPPERRIGHT}, - {"voltage", EDIF_TOK_VOLTAGE} + {"angle", EDIF_TOK_ANGLE}, + {"behavior", EDIF_TOK_BEHAVIOR}, + {"calculated", EDIF_TOK_CALCULATED}, + {"capacitance", EDIF_TOK_CAPACITANCE}, + {"centercenter", EDIF_TOK_CENTERCENTER}, + {"centerleft", EDIF_TOK_CENTERLEFT}, + {"centerright", EDIF_TOK_CENTERRIGHT}, + {"charge", EDIF_TOK_CHARGE}, + {"conductance", EDIF_TOK_CONDUCTANCE}, + {"current", EDIF_TOK_CURRENT}, + {"distance", EDIF_TOK_DISTANCE}, + {"document", EDIF_TOK_DOCUMENT}, + {"energy", EDIF_TOK_ENERGY}, + {"extend", EDIF_TOK_EXTEND}, + {"flux", EDIF_TOK_FLUX}, + {"frequency", EDIF_TOK_FREQUENCY}, + {"generic", EDIF_TOK_GENERIC}, + {"graphic", EDIF_TOK_GRAPHIC}, + {"inductance", EDIF_TOK_INDUCTANCE}, + {"inout", EDIF_TOK_INOUT}, + {"input", EDIF_TOK_INPUT}, + {"logicmodel", EDIF_TOK_LOGICMODEL}, + {"lowercenter", EDIF_TOK_LOWERCENTER}, + {"lowerleft", EDIF_TOK_LOWERLEFT}, + {"lowerright", EDIF_TOK_LOWERRIGHT}, + {"masklayout", EDIF_TOK_MASKLAYOUT}, + {"mass", EDIF_TOK_MASS}, + {"measured", EDIF_TOK_MEASURED}, + {"mx", EDIF_TOK_MX}, + {"mxr90", EDIF_TOK_MXR90}, + {"my", EDIF_TOK_MY}, + {"myr90", EDIF_TOK_MYR90}, + {"netlist", EDIF_TOK_NETLIST}, + {"output", EDIF_TOK_OUTPUT}, + {"pcblayout", EDIF_TOK_PCBLAYOUT}, + {"power", EDIF_TOK_POWER}, + {"r0", EDIF_TOK_R0}, + {"r180", EDIF_TOK_R180}, + {"r270", EDIF_TOK_R270}, + {"r90", EDIF_TOK_R90}, + {"required", EDIF_TOK_REQUIRED}, + {"resistance", EDIF_TOK_RESISTANCE}, + {"ripper", EDIF_TOK_RIPPER}, + {"round", EDIF_TOK_ROUND}, + {"schematic", EDIF_TOK_SCHEMATIC}, + {"stranger", EDIF_TOK_STRANGER}, + {"symbolic", EDIF_TOK_SYMBOLIC}, + {"temperature", EDIF_TOK_TEMPERATURE}, + {"tie", EDIF_TOK_TIE}, + {"time", EDIF_TOK_TIME}, + {"truncate", EDIF_TOK_TRUNCATE}, + {"uppercenter", EDIF_TOK_UPPERCENTER}, + {"upperleft", EDIF_TOK_UPPERLEFT}, + {"upperright", EDIF_TOK_UPPERRIGHT}, + {"voltage", EDIF_TOK_VOLTAGE} }; + static int TokenDefSize = sizeof(TokenDef) / sizeof(Token); /* * Token enable definitions: @@ -5456,35 +5636,52 @@ * particular context (barf). Another array is used to bind * these arrays to a context. */ -static short e_CellType[] = {EDIF_TOK_TIE, EDIF_TOK_RIPPER, EDIF_TOK_GENERIC}; -static short e_CornerType[] = {EDIF_TOK_EXTEND, EDIF_TOK_TRUNCATE, - EDIF_TOK_ROUND}; -static short e_Derivation[] = {EDIF_TOK_CALCULATED, EDIF_TOK_MEASURED, - EDIF_TOK_REQUIRED}; -static short e_Direction[] = {EDIF_TOK_INPUT, EDIF_TOK_OUTPUT, - EDIF_TOK_INOUT}; -static short e_EndType[] = {EDIF_TOK_EXTEND, EDIF_TOK_TRUNCATE, - EDIF_TOK_ROUND}; -static short e_Justify[] = {EDIF_TOK_CENTERCENTER, EDIF_TOK_CENTERLEFT, - EDIF_TOK_CENTERRIGHT, EDIF_TOK_LOWERCENTER, - EDIF_TOK_LOWERLEFT, EDIF_TOK_LOWERRIGHT, - EDIF_TOK_UPPERCENTER, EDIF_TOK_UPPERLEFT, - EDIF_TOK_UPPERRIGHT}; -static short e_Orientation[] = {EDIF_TOK_R0, EDIF_TOK_R90, EDIF_TOK_R180, - EDIF_TOK_R270, EDIF_TOK_MX, EDIF_TOK_MY, - EDIF_TOK_MXR90, EDIF_TOK_MYR90}; -static short e_Unit[] = {EDIF_TOK_DISTANCE, EDIF_TOK_CAPACITANCE, - EDIF_TOK_CURRENT, EDIF_TOK_RESISTANCE, - EDIF_TOK_TEMPERATURE, EDIF_TOK_TIME, - EDIF_TOK_VOLTAGE, EDIF_TOK_MASS, EDIF_TOK_FREQUENCY, - EDIF_TOK_INDUCTANCE, EDIF_TOK_ENERGY, - EDIF_TOK_POWER, EDIF_TOK_CHARGE, - EDIF_TOK_CONDUCTANCE, EDIF_TOK_FLUX, EDIF_TOK_ANGLE}; -static short e_ViewType[] = {EDIF_TOK_MASKLAYOUT, EDIF_TOK_PCBLAYOUT, - EDIF_TOK_NETLIST, EDIF_TOK_SCHEMATIC, - EDIF_TOK_SYMBOLIC, EDIF_TOK_BEHAVIOR, - EDIF_TOK_LOGICMODEL, EDIF_TOK_DOCUMENT, - EDIF_TOK_GRAPHIC, EDIF_TOK_STRANGER}; +static short e_CellType[] = { EDIF_TOK_TIE, EDIF_TOK_RIPPER, EDIF_TOK_GENERIC }; + +static short e_CornerType[] = { EDIF_TOK_EXTEND, EDIF_TOK_TRUNCATE, + EDIF_TOK_ROUND +}; + +static short e_Derivation[] = { EDIF_TOK_CALCULATED, EDIF_TOK_MEASURED, + EDIF_TOK_REQUIRED +}; + +static short e_Direction[] = { EDIF_TOK_INPUT, EDIF_TOK_OUTPUT, + EDIF_TOK_INOUT +}; + +static short e_EndType[] = { EDIF_TOK_EXTEND, EDIF_TOK_TRUNCATE, + EDIF_TOK_ROUND +}; + +static short e_Justify[] = { EDIF_TOK_CENTERCENTER, EDIF_TOK_CENTERLEFT, + EDIF_TOK_CENTERRIGHT, EDIF_TOK_LOWERCENTER, + EDIF_TOK_LOWERLEFT, EDIF_TOK_LOWERRIGHT, + EDIF_TOK_UPPERCENTER, EDIF_TOK_UPPERLEFT, + EDIF_TOK_UPPERRIGHT +}; + +static short e_Orientation[] = { EDIF_TOK_R0, EDIF_TOK_R90, EDIF_TOK_R180, + EDIF_TOK_R270, EDIF_TOK_MX, EDIF_TOK_MY, + EDIF_TOK_MXR90, EDIF_TOK_MYR90 +}; + +static short e_Unit[] = { EDIF_TOK_DISTANCE, EDIF_TOK_CAPACITANCE, + EDIF_TOK_CURRENT, EDIF_TOK_RESISTANCE, + EDIF_TOK_TEMPERATURE, EDIF_TOK_TIME, + EDIF_TOK_VOLTAGE, EDIF_TOK_MASS, EDIF_TOK_FREQUENCY, + EDIF_TOK_INDUCTANCE, EDIF_TOK_ENERGY, + EDIF_TOK_POWER, EDIF_TOK_CHARGE, + EDIF_TOK_CONDUCTANCE, EDIF_TOK_FLUX, EDIF_TOK_ANGLE +}; + +static short e_ViewType[] = { EDIF_TOK_MASKLAYOUT, EDIF_TOK_PCBLAYOUT, + EDIF_TOK_NETLIST, EDIF_TOK_SCHEMATIC, + EDIF_TOK_SYMBOLIC, EDIF_TOK_BEHAVIOR, + EDIF_TOK_LOGICMODEL, EDIF_TOK_DOCUMENT, + EDIF_TOK_GRAPHIC, EDIF_TOK_STRANGER +}; + /* * Token tying table: * @@ -5491,22 +5688,23 @@ * This binds enabled tokens to a context. */ typedef struct Tie { - short *Enable; /* pointer to enable array */ - short Origin; /* '%token' value of context */ - short EnableSize; /* size of enabled array */ + short *Enable; /* pointer to enable array */ + short Origin; /* '%token' value of context */ + short EnableSize; /* size of enabled array */ } Tie; #define TE(e,o) {e,o,sizeof(e)/sizeof(short)} static Tie TieDef[] = { - TE(e_CellType, EDIF_TOK_CELLTYPE), - TE(e_CornerType, EDIF_TOK_CORNERTYPE), - TE(e_Derivation, EDIF_TOK_DERIVATION), - TE(e_Direction, EDIF_TOK_DIRECTION), - TE(e_EndType, EDIF_TOK_ENDTYPE), - TE(e_Justify, EDIF_TOK_JUSTIFY), - TE(e_Orientation, EDIF_TOK_ORIENTATION), - TE(e_Unit, EDIF_TOK_UNIT), - TE(e_ViewType, EDIF_TOK_VIEWTYPE) + TE(e_CellType, EDIF_TOK_CELLTYPE), + TE(e_CornerType, EDIF_TOK_CORNERTYPE), + TE(e_Derivation, EDIF_TOK_DERIVATION), + TE(e_Direction, EDIF_TOK_DIRECTION), + TE(e_EndType, EDIF_TOK_ENDTYPE), + TE(e_Justify, EDIF_TOK_JUSTIFY), + TE(e_Orientation, EDIF_TOK_ORIENTATION), + TE(e_Unit, EDIF_TOK_UNIT), + TE(e_ViewType, EDIF_TOK_VIEWTYPE) }; + static int TieDefSize = sizeof(TieDef) / sizeof(Tie); /* * Context definitions: @@ -5517,248 +5715,249 @@ * must be lower case. */ typedef struct Context { - char *Name; /* keyword name */ - short Code; /* '%token' value */ - short Flags; /* special operation flags */ - struct ContextCar *Context; /* contexts which can be moved to */ - struct TokenCar *Token; /* active tokens */ - struct Context *Next; /* hash table linkage */ + char *Name; /* keyword name */ + short Code; /* '%token' value */ + short Flags; /* special operation flags */ + struct ContextCar *Context; /* contexts which can be moved to */ + struct TokenCar *Token; /* active tokens */ + struct Context *Next; /* hash table linkage */ } Context; static Context ContextDef[] = { - {"", 0}, /* start context */ - {"acload", EDIF_TOK_ACLOAD}, - {"after", EDIF_TOK_AFTER}, - {"annotate", EDIF_TOK_ANNOTATE}, - {"apply", EDIF_TOK_APPLY}, - {"arc", EDIF_TOK_ARC}, - {"array", EDIF_TOK_ARRAY}, - {"arraymacro", EDIF_TOK_ARRAYMACRO}, - {"arrayrelatedinfo", EDIF_TOK_ARRAYRELATEDINFO}, - {"arraysite", EDIF_TOK_ARRAYSITE}, - {"atleast", EDIF_TOK_ATLEAST}, - {"atmost", EDIF_TOK_ATMOST}, - {"author", EDIF_TOK_AUTHOR}, - {"basearray", EDIF_TOK_BASEARRAY}, - {"becomes", EDIF_TOK_BECOMES}, - {"between", EDIF_TOK_BETWEEN}, - {"boolean", EDIF_TOK_BOOLEAN}, - {"booleandisplay", EDIF_TOK_BOOLEANDISPLAY}, - {"booleanmap", EDIF_TOK_BOOLEANMAP}, - {"borderpattern", EDIF_TOK_BORDERPATTERN}, - {"borderwidth", EDIF_TOK_BORDERWIDTH}, - {"boundingbox", EDIF_TOK_BOUNDINGBOX}, - {"cell", EDIF_TOK_CELL}, - {"cellref", EDIF_TOK_CELLREF}, - {"celltype", EDIF_TOK_CELLTYPE}, - {"change", EDIF_TOK_CHANGE}, - {"circle", EDIF_TOK_CIRCLE}, - {"color", EDIF_TOK_COLOR}, - {"comment", EDIF_TOK_COMMENT}, - {"commentgraphics", EDIF_TOK_COMMENTGRAPHICS}, - {"compound", EDIF_TOK_COMPOUND}, - {"connectlocation", EDIF_TOK_CONNECTLOCATION}, - {"contents", EDIF_TOK_CONTENTS}, - {"cornertype", EDIF_TOK_CORNERTYPE}, - {"criticality", EDIF_TOK_CRITICALITY}, - {"currentmap", EDIF_TOK_CURRENTMAP}, - {"curve", EDIF_TOK_CURVE}, - {"cycle", EDIF_TOK_CYCLE}, - {"dataorigin", EDIF_TOK_DATAORIGIN}, - {"dcfaninload", EDIF_TOK_DCFANINLOAD}, - {"dcfanoutload", EDIF_TOK_DCFANOUTLOAD}, - {"dcmaxfanin", EDIF_TOK_DCMAXFANIN}, - {"dcmaxfanout", EDIF_TOK_DCMAXFANOUT}, - {"delay", EDIF_TOK_DELAY}, - {"delta", EDIF_TOK_DELTA}, - {"derivation", EDIF_TOK_DERIVATION}, - {"design", EDIF_TOK_DESIGN}, - {"designator", EDIF_TOK_DESIGNATOR}, - {"difference", EDIF_TOK_DIFFERENCE}, - {"direction", EDIF_TOK_DIRECTION}, - {"display", EDIF_TOK_DISPLAY}, - {"dominates", EDIF_TOK_DOMINATES}, - {"dot", EDIF_TOK_DOT}, - {"duration", EDIF_TOK_DURATION}, - {"e", EDIF_TOK_E}, - {"edif", EDIF_TOK_EDIF}, - {"ediflevel", EDIF_TOK_EDIFLEVEL}, - {"edifversion", EDIF_TOK_EDIFVERSION}, - {"enclosuredistance", EDIF_TOK_ENCLOSUREDISTANCE}, - {"endtype", EDIF_TOK_ENDTYPE}, - {"entry", EDIF_TOK_ENTRY}, - {"exactly", EDIF_TOK_EXACTLY}, - {"external", EDIF_TOK_EXTERNAL}, - {"fabricate", EDIF_TOK_FABRICATE}, - {"false", EDIF_TOK_FALSE}, - {"figure", EDIF_TOK_FIGURE}, - {"figurearea", EDIF_TOK_FIGUREAREA}, - {"figuregroup", EDIF_TOK_FIGUREGROUP}, - {"figuregroupobject", EDIF_TOK_FIGUREGROUPOBJECT}, - {"figuregroupoverride", EDIF_TOK_FIGUREGROUPOVERRIDE}, - {"figuregroupref", EDIF_TOK_FIGUREGROUPREF}, - {"figureperimeter", EDIF_TOK_FIGUREPERIMETER}, - {"figurewidth", EDIF_TOK_FIGUREWIDTH}, - {"fillpattern", EDIF_TOK_FILLPATTERN}, - {"follow", EDIF_TOK_FOLLOW}, - {"forbiddenevent", EDIF_TOK_FORBIDDENEVENT}, - {"globalportref", EDIF_TOK_GLOBALPORTREF}, - {"greaterthan", EDIF_TOK_GREATERTHAN}, - {"gridmap", EDIF_TOK_GRIDMAP}, - {"ignore", EDIF_TOK_IGNORE}, - {"includefiguregroup", EDIF_TOK_INCLUDEFIGUREGROUP}, - {"initial", EDIF_TOK_INITIAL}, - {"instance", EDIF_TOK_INSTANCE}, - {"instancebackannotate", EDIF_TOK_INSTANCEBACKANNOTATE}, - {"instancegroup", EDIF_TOK_INSTANCEGROUP}, - {"instancemap", EDIF_TOK_INSTANCEMAP}, - {"instanceref", EDIF_TOK_INSTANCEREF}, - {"integer", EDIF_TOK_INTEGER}, - {"integerdisplay", EDIF_TOK_INTEGERDISPLAY}, - {"interface", EDIF_TOK_INTERFACE}, - {"interfiguregroupspacing", EDIF_TOK_INTERFIGUREGROUPSPACING}, - {"intersection", EDIF_TOK_INTERSECTION}, - {"intrafiguregroupspacing", EDIF_TOK_INTRAFIGUREGROUPSPACING}, - {"inverse", EDIF_TOK_INVERSE}, - {"isolated", EDIF_TOK_ISOLATED}, - {"joined", EDIF_TOK_JOINED}, - {"justify", EDIF_TOK_JUSTIFY}, - {"keyworddisplay", EDIF_TOK_KEYWORDDISPLAY}, - {"keywordlevel", EDIF_TOK_KEYWORDLEVEL}, - {"keywordmap", EDIF_TOK_KEYWORDMAP}, - {"lessthan", EDIF_TOK_LESSTHAN}, - {"library", EDIF_TOK_LIBRARY}, - {"libraryref", EDIF_TOK_LIBRARYREF}, - {"listofnets", EDIF_TOK_LISTOFNETS}, - {"listofports", EDIF_TOK_LISTOFPORTS}, - {"loaddelay", EDIF_TOK_LOADDELAY}, - {"logicassign", EDIF_TOK_LOGICASSIGN}, - {"logicinput", EDIF_TOK_LOGICINPUT}, - {"logiclist", EDIF_TOK_LOGICLIST}, - {"logicmapinput", EDIF_TOK_LOGICMAPINPUT}, - {"logicmapoutput", EDIF_TOK_LOGICMAPOUTPUT}, - {"logiconeof", EDIF_TOK_LOGICONEOF}, - {"logicoutput", EDIF_TOK_LOGICOUTPUT}, - {"logicport", EDIF_TOK_LOGICPORT}, - {"logicref", EDIF_TOK_LOGICREF}, - {"logicvalue", EDIF_TOK_LOGICVALUE}, - {"logicwaveform", EDIF_TOK_LOGICWAVEFORM}, - {"maintain", EDIF_TOK_MAINTAIN}, - {"match", EDIF_TOK_MATCH}, - {"member", EDIF_TOK_MEMBER}, - {"minomax", EDIF_TOK_MINOMAX}, - {"minomaxdisplay", EDIF_TOK_MINOMAXDISPLAY}, - {"mnm", EDIF_TOK_MNM}, - {"multiplevalueset", EDIF_TOK_MULTIPLEVALUESET}, - {"mustjoin", EDIF_TOK_MUSTJOIN}, - {"name", EDIF_TOK_NAME}, - {"net", EDIF_TOK_NET}, - {"netbackannotate", EDIF_TOK_NETBACKANNOTATE}, - {"netbundle", EDIF_TOK_NETBUNDLE}, - {"netdelay", EDIF_TOK_NETDELAY}, - {"netgroup", EDIF_TOK_NETGROUP}, - {"netmap", EDIF_TOK_NETMAP}, - {"netref", EDIF_TOK_NETREF}, - {"nochange", EDIF_TOK_NOCHANGE}, - {"nonpermutable", EDIF_TOK_NONPERMUTABLE}, - {"notallowed", EDIF_TOK_NOTALLOWED}, - {"notchspacing", EDIF_TOK_NOTCHSPACING}, - {"number", EDIF_TOK_NUMBER}, - {"numberdefinition", EDIF_TOK_NUMBERDEFINITION}, - {"numberdisplay", EDIF_TOK_NUMBERDISPLAY}, - {"offpageconnector", EDIF_TOK_OFFPAGECONNECTOR}, - {"offsetevent", EDIF_TOK_OFFSETEVENT}, - {"openshape", EDIF_TOK_OPENSHAPE}, - {"orientation", EDIF_TOK_ORIENTATION}, - {"origin", EDIF_TOK_ORIGIN}, - {"overhangdistance", EDIF_TOK_OVERHANGDISTANCE}, - {"overlapdistance", EDIF_TOK_OVERLAPDISTANCE}, - {"oversize", EDIF_TOK_OVERSIZE}, - {"owner", EDIF_TOK_OWNER}, - {"page", EDIF_TOK_PAGE}, - {"pagesize", EDIF_TOK_PAGESIZE}, - {"parameter", EDIF_TOK_PARAMETER}, - {"parameterassign", EDIF_TOK_PARAMETERASSIGN}, - {"parameterdisplay", EDIF_TOK_PARAMETERDISPLAY}, - {"path", EDIF_TOK_PATH}, - {"pathdelay", EDIF_TOK_PATHDELAY}, - {"pathwidth", EDIF_TOK_PATHWIDTH}, - {"permutable", EDIF_TOK_PERMUTABLE}, - {"physicaldesignrule", EDIF_TOK_PHYSICALDESIGNRULE}, - {"plug", EDIF_TOK_PLUG}, - {"point", EDIF_TOK_POINT}, - {"pointdisplay", EDIF_TOK_POINTDISPLAY}, - {"pointlist", EDIF_TOK_POINTLIST}, - {"polygon", EDIF_TOK_POLYGON}, - {"port", EDIF_TOK_PORT}, - {"portbackannotate", EDIF_TOK_PORTBACKANNOTATE}, - {"portbundle", EDIF_TOK_PORTBUNDLE}, - {"portdelay", EDIF_TOK_PORTDELAY}, - {"portgroup", EDIF_TOK_PORTGROUP}, - {"portimplementation", EDIF_TOK_PORTIMPLEMENTATION}, - {"portinstance", EDIF_TOK_PORTINSTANCE}, - {"portlist", EDIF_TOK_PORTLIST}, - {"portlistalias", EDIF_TOK_PORTLISTALIAS}, - {"portmap", EDIF_TOK_PORTMAP}, - {"portref", EDIF_TOK_PORTREF}, - {"program", EDIF_TOK_PROGRAM}, - {"property", EDIF_TOK_PROPERTY}, - {"propertydisplay", EDIF_TOK_PROPERTYDISPLAY}, - {"protectionframe", EDIF_TOK_PROTECTIONFRAME}, - {"pt", EDIF_TOK_PT}, - {"rangevector", EDIF_TOK_RANGEVECTOR}, - {"rectangle", EDIF_TOK_RECTANGLE}, - {"rectanglesize", EDIF_TOK_RECTANGLESIZE}, - {"rename", EDIF_TOK_RENAME}, - {"resolves", EDIF_TOK_RESOLVES}, - {"scale", EDIF_TOK_SCALE}, - {"scalex", EDIF_TOK_SCALEX}, - {"scaley", EDIF_TOK_SCALEY}, - {"section", EDIF_TOK_SECTION}, - {"shape", EDIF_TOK_SHAPE}, - {"simulate", EDIF_TOK_SIMULATE}, - {"simulationinfo", EDIF_TOK_SIMULATIONINFO}, - {"singlevalueset", EDIF_TOK_SINGLEVALUESET}, - {"site", EDIF_TOK_SITE}, - {"socket", EDIF_TOK_SOCKET}, - {"socketset", EDIF_TOK_SOCKETSET}, - {"status", EDIF_TOK_STATUS}, - {"steady", EDIF_TOK_STEADY}, - {"string", EDIF_TOK_STRING}, - {"stringdisplay", EDIF_TOK_STRINGDISPLAY}, - {"strong", EDIF_TOK_STRONG}, - {"symbol", EDIF_TOK_SYMBOL}, - {"symmetry", EDIF_TOK_SYMMETRY}, - {"table", EDIF_TOK_TABLE}, - {"tabledefault", EDIF_TOK_TABLEDEFAULT}, - {"technology", EDIF_TOK_TECHNOLOGY}, - {"textheight", EDIF_TOK_TEXTHEIGHT}, - {"timeinterval", EDIF_TOK_TIMEINTERVAL}, - {"timestamp", EDIF_TOK_TIMESTAMP}, - {"timing", EDIF_TOK_TIMING}, - {"transform", EDIF_TOK_TRANSFORM}, - {"transition", EDIF_TOK_TRANSITION}, - {"trigger", EDIF_TOK_TRIGGER}, - {"true", EDIF_TOK_TRUE}, - {"unconstrained", EDIF_TOK_UNCONSTRAINED}, - {"undefined", EDIF_TOK_UNDEFINED}, - {"union", EDIF_TOK_UNION}, - {"unit", EDIF_TOK_UNIT}, - {"unused", EDIF_TOK_UNUSED}, - {"userdata", EDIF_TOK_USERDATA}, - {"version", EDIF_TOK_VERSION}, - {"view", EDIF_TOK_VIEW}, - {"viewlist", EDIF_TOK_VIEWLIST}, - {"viewmap", EDIF_TOK_VIEWMAP}, - {"viewref", EDIF_TOK_VIEWREF}, - {"viewtype", EDIF_TOK_VIEWTYPE}, - {"visible", EDIF_TOK_VISIBLE}, - {"voltagemap", EDIF_TOK_VOLTAGEMAP}, - {"wavevalue", EDIF_TOK_WAVEVALUE}, - {"weak", EDIF_TOK_WEAK}, - {"weakjoined", EDIF_TOK_WEAKJOINED}, - {"when", EDIF_TOK_WHEN}, - {"written", EDIF_TOK_WRITTEN} + {"", 0}, /* start context */ + {"acload", EDIF_TOK_ACLOAD}, + {"after", EDIF_TOK_AFTER}, + {"annotate", EDIF_TOK_ANNOTATE}, + {"apply", EDIF_TOK_APPLY}, + {"arc", EDIF_TOK_ARC}, + {"array", EDIF_TOK_ARRAY}, + {"arraymacro", EDIF_TOK_ARRAYMACRO}, + {"arrayrelatedinfo", EDIF_TOK_ARRAYRELATEDINFO}, + {"arraysite", EDIF_TOK_ARRAYSITE}, + {"atleast", EDIF_TOK_ATLEAST}, + {"atmost", EDIF_TOK_ATMOST}, + {"author", EDIF_TOK_AUTHOR}, + {"basearray", EDIF_TOK_BASEARRAY}, + {"becomes", EDIF_TOK_BECOMES}, + {"between", EDIF_TOK_BETWEEN}, + {"boolean", EDIF_TOK_BOOLEAN}, + {"booleandisplay", EDIF_TOK_BOOLEANDISPLAY}, + {"booleanmap", EDIF_TOK_BOOLEANMAP}, + {"borderpattern", EDIF_TOK_BORDERPATTERN}, + {"borderwidth", EDIF_TOK_BORDERWIDTH}, + {"boundingbox", EDIF_TOK_BOUNDINGBOX}, + {"cell", EDIF_TOK_CELL}, + {"cellref", EDIF_TOK_CELLREF}, + {"celltype", EDIF_TOK_CELLTYPE}, + {"change", EDIF_TOK_CHANGE}, + {"circle", EDIF_TOK_CIRCLE}, + {"color", EDIF_TOK_COLOR}, + {"comment", EDIF_TOK_COMMENT}, + {"commentgraphics", EDIF_TOK_COMMENTGRAPHICS}, + {"compound", EDIF_TOK_COMPOUND}, + {"connectlocation", EDIF_TOK_CONNECTLOCATION}, + {"contents", EDIF_TOK_CONTENTS}, + {"cornertype", EDIF_TOK_CORNERTYPE}, + {"criticality", EDIF_TOK_CRITICALITY}, + {"currentmap", EDIF_TOK_CURRENTMAP}, + {"curve", EDIF_TOK_CURVE}, + {"cycle", EDIF_TOK_CYCLE}, + {"dataorigin", EDIF_TOK_DATAORIGIN}, + {"dcfaninload", EDIF_TOK_DCFANINLOAD}, + {"dcfanoutload", EDIF_TOK_DCFANOUTLOAD}, + {"dcmaxfanin", EDIF_TOK_DCMAXFANIN}, + {"dcmaxfanout", EDIF_TOK_DCMAXFANOUT}, + {"delay", EDIF_TOK_DELAY}, + {"delta", EDIF_TOK_DELTA}, + {"derivation", EDIF_TOK_DERIVATION}, + {"design", EDIF_TOK_DESIGN}, + {"designator", EDIF_TOK_DESIGNATOR}, + {"difference", EDIF_TOK_DIFFERENCE}, + {"direction", EDIF_TOK_DIRECTION}, + {"display", EDIF_TOK_DISPLAY}, + {"dominates", EDIF_TOK_DOMINATES}, + {"dot", EDIF_TOK_DOT}, + {"duration", EDIF_TOK_DURATION}, + {"e", EDIF_TOK_E}, + {"edif", EDIF_TOK_EDIF}, + {"ediflevel", EDIF_TOK_EDIFLEVEL}, + {"edifversion", EDIF_TOK_EDIFVERSION}, + {"enclosuredistance", EDIF_TOK_ENCLOSUREDISTANCE}, + {"endtype", EDIF_TOK_ENDTYPE}, + {"entry", EDIF_TOK_ENTRY}, + {"exactly", EDIF_TOK_EXACTLY}, + {"external", EDIF_TOK_EXTERNAL}, + {"fabricate", EDIF_TOK_FABRICATE}, + {"false", EDIF_TOK_FALSE}, + {"figure", EDIF_TOK_FIGURE}, + {"figurearea", EDIF_TOK_FIGUREAREA}, + {"figuregroup", EDIF_TOK_FIGUREGROUP}, + {"figuregroupobject", EDIF_TOK_FIGUREGROUPOBJECT}, + {"figuregroupoverride", EDIF_TOK_FIGUREGROUPOVERRIDE}, + {"figuregroupref", EDIF_TOK_FIGUREGROUPREF}, + {"figureperimeter", EDIF_TOK_FIGUREPERIMETER}, + {"figurewidth", EDIF_TOK_FIGUREWIDTH}, + {"fillpattern", EDIF_TOK_FILLPATTERN}, + {"follow", EDIF_TOK_FOLLOW}, + {"forbiddenevent", EDIF_TOK_FORBIDDENEVENT}, + {"globalportref", EDIF_TOK_GLOBALPORTREF}, + {"greaterthan", EDIF_TOK_GREATERTHAN}, + {"gridmap", EDIF_TOK_GRIDMAP}, + {"ignore", EDIF_TOK_IGNORE}, + {"includefiguregroup", EDIF_TOK_INCLUDEFIGUREGROUP}, + {"initial", EDIF_TOK_INITIAL}, + {"instance", EDIF_TOK_INSTANCE}, + {"instancebackannotate", EDIF_TOK_INSTANCEBACKANNOTATE}, + {"instancegroup", EDIF_TOK_INSTANCEGROUP}, + {"instancemap", EDIF_TOK_INSTANCEMAP}, + {"instanceref", EDIF_TOK_INSTANCEREF}, + {"integer", EDIF_TOK_INTEGER}, + {"integerdisplay", EDIF_TOK_INTEGERDISPLAY}, + {"interface", EDIF_TOK_INTERFACE}, + {"interfiguregroupspacing", EDIF_TOK_INTERFIGUREGROUPSPACING}, + {"intersection", EDIF_TOK_INTERSECTION}, + {"intrafiguregroupspacing", EDIF_TOK_INTRAFIGUREGROUPSPACING}, + {"inverse", EDIF_TOK_INVERSE}, + {"isolated", EDIF_TOK_ISOLATED}, + {"joined", EDIF_TOK_JOINED}, + {"justify", EDIF_TOK_JUSTIFY}, + {"keyworddisplay", EDIF_TOK_KEYWORDDISPLAY}, + {"keywordlevel", EDIF_TOK_KEYWORDLEVEL}, + {"keywordmap", EDIF_TOK_KEYWORDMAP}, + {"lessthan", EDIF_TOK_LESSTHAN}, + {"library", EDIF_TOK_LIBRARY}, + {"libraryref", EDIF_TOK_LIBRARYREF}, + {"listofnets", EDIF_TOK_LISTOFNETS}, + {"listofports", EDIF_TOK_LISTOFPORTS}, + {"loaddelay", EDIF_TOK_LOADDELAY}, + {"logicassign", EDIF_TOK_LOGICASSIGN}, + {"logicinput", EDIF_TOK_LOGICINPUT}, + {"logiclist", EDIF_TOK_LOGICLIST}, + {"logicmapinput", EDIF_TOK_LOGICMAPINPUT}, + {"logicmapoutput", EDIF_TOK_LOGICMAPOUTPUT}, + {"logiconeof", EDIF_TOK_LOGICONEOF}, + {"logicoutput", EDIF_TOK_LOGICOUTPUT}, + {"logicport", EDIF_TOK_LOGICPORT}, + {"logicref", EDIF_TOK_LOGICREF}, + {"logicvalue", EDIF_TOK_LOGICVALUE}, + {"logicwaveform", EDIF_TOK_LOGICWAVEFORM}, + {"maintain", EDIF_TOK_MAINTAIN}, + {"match", EDIF_TOK_MATCH}, + {"member", EDIF_TOK_MEMBER}, + {"minomax", EDIF_TOK_MINOMAX}, + {"minomaxdisplay", EDIF_TOK_MINOMAXDISPLAY}, + {"mnm", EDIF_TOK_MNM}, + {"multiplevalueset", EDIF_TOK_MULTIPLEVALUESET}, + {"mustjoin", EDIF_TOK_MUSTJOIN}, + {"name", EDIF_TOK_NAME}, + {"net", EDIF_TOK_NET}, + {"netbackannotate", EDIF_TOK_NETBACKANNOTATE}, + {"netbundle", EDIF_TOK_NETBUNDLE}, + {"netdelay", EDIF_TOK_NETDELAY}, + {"netgroup", EDIF_TOK_NETGROUP}, + {"netmap", EDIF_TOK_NETMAP}, + {"netref", EDIF_TOK_NETREF}, + {"nochange", EDIF_TOK_NOCHANGE}, + {"nonpermutable", EDIF_TOK_NONPERMUTABLE}, + {"notallowed", EDIF_TOK_NOTALLOWED}, + {"notchspacing", EDIF_TOK_NOTCHSPACING}, + {"number", EDIF_TOK_NUMBER}, + {"numberdefinition", EDIF_TOK_NUMBERDEFINITION}, + {"numberdisplay", EDIF_TOK_NUMBERDISPLAY}, + {"offpageconnector", EDIF_TOK_OFFPAGECONNECTOR}, + {"offsetevent", EDIF_TOK_OFFSETEVENT}, + {"openshape", EDIF_TOK_OPENSHAPE}, + {"orientation", EDIF_TOK_ORIENTATION}, + {"origin", EDIF_TOK_ORIGIN}, + {"overhangdistance", EDIF_TOK_OVERHANGDISTANCE}, + {"overlapdistance", EDIF_TOK_OVERLAPDISTANCE}, + {"oversize", EDIF_TOK_OVERSIZE}, + {"owner", EDIF_TOK_OWNER}, + {"page", EDIF_TOK_PAGE}, + {"pagesize", EDIF_TOK_PAGESIZE}, + {"parameter", EDIF_TOK_PARAMETER}, + {"parameterassign", EDIF_TOK_PARAMETERASSIGN}, + {"parameterdisplay", EDIF_TOK_PARAMETERDISPLAY}, + {"path", EDIF_TOK_PATH}, + {"pathdelay", EDIF_TOK_PATHDELAY}, + {"pathwidth", EDIF_TOK_PATHWIDTH}, + {"permutable", EDIF_TOK_PERMUTABLE}, + {"physicaldesignrule", EDIF_TOK_PHYSICALDESIGNRULE}, + {"plug", EDIF_TOK_PLUG}, + {"point", EDIF_TOK_POINT}, + {"pointdisplay", EDIF_TOK_POINTDISPLAY}, + {"pointlist", EDIF_TOK_POINTLIST}, + {"polygon", EDIF_TOK_POLYGON}, + {"port", EDIF_TOK_PORT}, + {"portbackannotate", EDIF_TOK_PORTBACKANNOTATE}, + {"portbundle", EDIF_TOK_PORTBUNDLE}, + {"portdelay", EDIF_TOK_PORTDELAY}, + {"portgroup", EDIF_TOK_PORTGROUP}, + {"portimplementation", EDIF_TOK_PORTIMPLEMENTATION}, + {"portinstance", EDIF_TOK_PORTINSTANCE}, + {"portlist", EDIF_TOK_PORTLIST}, + {"portlistalias", EDIF_TOK_PORTLISTALIAS}, + {"portmap", EDIF_TOK_PORTMAP}, + {"portref", EDIF_TOK_PORTREF}, + {"program", EDIF_TOK_PROGRAM}, + {"property", EDIF_TOK_PROPERTY}, + {"propertydisplay", EDIF_TOK_PROPERTYDISPLAY}, + {"protectionframe", EDIF_TOK_PROTECTIONFRAME}, + {"pt", EDIF_TOK_PT}, + {"rangevector", EDIF_TOK_RANGEVECTOR}, + {"rectangle", EDIF_TOK_RECTANGLE}, + {"rectanglesize", EDIF_TOK_RECTANGLESIZE}, + {"rename", EDIF_TOK_RENAME}, + {"resolves", EDIF_TOK_RESOLVES}, + {"scale", EDIF_TOK_SCALE}, + {"scalex", EDIF_TOK_SCALEX}, + {"scaley", EDIF_TOK_SCALEY}, + {"section", EDIF_TOK_SECTION}, + {"shape", EDIF_TOK_SHAPE}, + {"simulate", EDIF_TOK_SIMULATE}, + {"simulationinfo", EDIF_TOK_SIMULATIONINFO}, + {"singlevalueset", EDIF_TOK_SINGLEVALUESET}, + {"site", EDIF_TOK_SITE}, + {"socket", EDIF_TOK_SOCKET}, + {"socketset", EDIF_TOK_SOCKETSET}, + {"status", EDIF_TOK_STATUS}, + {"steady", EDIF_TOK_STEADY}, + {"string", EDIF_TOK_STRING}, + {"stringdisplay", EDIF_TOK_STRINGDISPLAY}, + {"strong", EDIF_TOK_STRONG}, + {"symbol", EDIF_TOK_SYMBOL}, + {"symmetry", EDIF_TOK_SYMMETRY}, + {"table", EDIF_TOK_TABLE}, + {"tabledefault", EDIF_TOK_TABLEDEFAULT}, + {"technology", EDIF_TOK_TECHNOLOGY}, + {"textheight", EDIF_TOK_TEXTHEIGHT}, + {"timeinterval", EDIF_TOK_TIMEINTERVAL}, + {"timestamp", EDIF_TOK_TIMESTAMP}, + {"timing", EDIF_TOK_TIMING}, + {"transform", EDIF_TOK_TRANSFORM}, + {"transition", EDIF_TOK_TRANSITION}, + {"trigger", EDIF_TOK_TRIGGER}, + {"true", EDIF_TOK_TRUE}, + {"unconstrained", EDIF_TOK_UNCONSTRAINED}, + {"undefined", EDIF_TOK_UNDEFINED}, + {"union", EDIF_TOK_UNION}, + {"unit", EDIF_TOK_UNIT}, + {"unused", EDIF_TOK_UNUSED}, + {"userdata", EDIF_TOK_USERDATA}, + {"version", EDIF_TOK_VERSION}, + {"view", EDIF_TOK_VIEW}, + {"viewlist", EDIF_TOK_VIEWLIST}, + {"viewmap", EDIF_TOK_VIEWMAP}, + {"viewref", EDIF_TOK_VIEWREF}, + {"viewtype", EDIF_TOK_VIEWTYPE}, + {"visible", EDIF_TOK_VISIBLE}, + {"voltagemap", EDIF_TOK_VOLTAGEMAP}, + {"wavevalue", EDIF_TOK_WAVEVALUE}, + {"weak", EDIF_TOK_WEAK}, + {"weakjoined", EDIF_TOK_WEAKJOINED}, + {"when", EDIF_TOK_WHEN}, + {"written", EDIF_TOK_WRITTEN} }; + static int ContextDefSize = sizeof(ContextDef) / sizeof(Context); /* * Context follower tables: @@ -5776,514 +5975,723 @@ * A negative entry means that the follow can only occur once within * the specified context. */ -static short f_NULL[] = {EDIF_TOK_EDIF}; -static short f_Edif[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_EDIFVERSION, - EDIF_TOK_EDIFLEVEL, EDIF_TOK_KEYWORDMAP, - -EDIF_TOK_STATUS, EDIF_TOK_EXTERNAL, - EDIF_TOK_LIBRARY, EDIF_TOK_DESIGN, EDIF_TOK_COMMENT, - EDIF_TOK_USERDATA}; -static short f_AcLoad[] = {EDIF_TOK_MNM, EDIF_TOK_E, EDIF_TOK_MINOMAXDISPLAY}; -static short f_After[] = {EDIF_TOK_MNM, EDIF_TOK_E, EDIF_TOK_FOLLOW, - EDIF_TOK_MAINTAIN, EDIF_TOK_LOGICASSIGN, - EDIF_TOK_COMMENT, EDIF_TOK_USERDATA}; -static short f_Annotate[] = {EDIF_TOK_STRINGDISPLAY}; -static short f_Apply[] = {EDIF_TOK_CYCLE, EDIF_TOK_LOGICINPUT, - EDIF_TOK_LOGICOUTPUT, EDIF_TOK_COMMENT, - EDIF_TOK_USERDATA}; -static short f_Arc[] = {EDIF_TOK_PT}; -static short f_Array[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME}; -static short f_ArrayMacro[] = {EDIF_TOK_PLUG}; -static short f_ArrayRelatedInfo[] = {EDIF_TOK_BASEARRAY, EDIF_TOK_ARRAYSITE, - EDIF_TOK_ARRAYMACRO, EDIF_TOK_COMMENT, - EDIF_TOK_USERDATA}; -static short f_ArraySite[] = {EDIF_TOK_SOCKET}; -static short f_AtLeast[] = {EDIF_TOK_E}; -static short f_AtMost[] = {EDIF_TOK_E}; -static short f_Becomes[] = {EDIF_TOK_NAME, EDIF_TOK_LOGICLIST, - EDIF_TOK_LOGICONEOF}; +static short f_NULL[] = { EDIF_TOK_EDIF }; + +static short f_Edif[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_EDIFVERSION, + EDIF_TOK_EDIFLEVEL, EDIF_TOK_KEYWORDMAP, + -EDIF_TOK_STATUS, EDIF_TOK_EXTERNAL, + EDIF_TOK_LIBRARY, EDIF_TOK_DESIGN, EDIF_TOK_COMMENT, + EDIF_TOK_USERDATA +}; +static short f_AcLoad[] = { EDIF_TOK_MNM, EDIF_TOK_E, EDIF_TOK_MINOMAXDISPLAY }; + +static short f_After[] = { EDIF_TOK_MNM, EDIF_TOK_E, EDIF_TOK_FOLLOW, + EDIF_TOK_MAINTAIN, EDIF_TOK_LOGICASSIGN, + EDIF_TOK_COMMENT, EDIF_TOK_USERDATA +}; +static short f_Annotate[] = { EDIF_TOK_STRINGDISPLAY }; + +static short f_Apply[] = { EDIF_TOK_CYCLE, EDIF_TOK_LOGICINPUT, + EDIF_TOK_LOGICOUTPUT, EDIF_TOK_COMMENT, + EDIF_TOK_USERDATA +}; +static short f_Arc[] = { EDIF_TOK_PT }; +static short f_Array[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME }; +static short f_ArrayMacro[] = { EDIF_TOK_PLUG }; + +static short f_ArrayRelatedInfo[] = { EDIF_TOK_BASEARRAY, EDIF_TOK_ARRAYSITE, + EDIF_TOK_ARRAYMACRO, EDIF_TOK_COMMENT, + EDIF_TOK_USERDATA +}; +static short f_ArraySite[] = { EDIF_TOK_SOCKET }; +static short f_AtLeast[] = { EDIF_TOK_E }; +static short f_AtMost[] = { EDIF_TOK_E }; + +static short f_Becomes[] = { EDIF_TOK_NAME, EDIF_TOK_LOGICLIST, + EDIF_TOK_LOGICONEOF +}; + /* static short f_Between[] = {EDIF_TOK_ATLEAST, EDIF_TOK_GREATERTHAN, EDIF_TOK_ATMOST, EDIF_TOK_LESSTHAN}; */ -static short f_Boolean[] = {EDIF_TOK_FALSE, EDIF_TOK_TRUE, - EDIF_TOK_BOOLEANDISPLAY, EDIF_TOK_BOOLEAN}; -static short f_BooleanDisplay[] = {EDIF_TOK_FALSE, EDIF_TOK_TRUE, - EDIF_TOK_DISPLAY}; -static short f_BooleanMap[] = {EDIF_TOK_FALSE, EDIF_TOK_TRUE}; -static short f_BorderPattern[] = {EDIF_TOK_BOOLEAN}; -static short f_BoundingBox[] = {EDIF_TOK_RECTANGLE}; -static short f_Cell[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_CELLTYPE, - -EDIF_TOK_STATUS, -EDIF_TOK_VIEWMAP, EDIF_TOK_VIEW, - EDIF_TOK_COMMENT, EDIF_TOK_USERDATA, - EDIF_TOK_PROPERTY}; -static short f_CellRef[] = {EDIF_TOK_NAME, EDIF_TOK_LIBRARYREF}; -static short f_Change[] = {EDIF_TOK_NAME, EDIF_TOK_PORTREF, EDIF_TOK_PORTLIST, - EDIF_TOK_BECOMES, EDIF_TOK_TRANSITION}; -static short f_Circle[] = {EDIF_TOK_PT, EDIF_TOK_PROPERTY}; -static short f_Color[] = {EDIF_TOK_E}; -static short f_CommentGraphics[] = {EDIF_TOK_ANNOTATE, EDIF_TOK_FIGURE, - EDIF_TOK_INSTANCE, -EDIF_TOK_BOUNDINGBOX, - EDIF_TOK_PROPERTY, EDIF_TOK_COMMENT, - EDIF_TOK_USERDATA}; -static short f_Compound[] = {EDIF_TOK_NAME}; -static short f_ConnectLocation[] = {EDIF_TOK_FIGURE}; -static short f_Contents[] = {EDIF_TOK_INSTANCE, EDIF_TOK_OFFPAGECONNECTOR, - EDIF_TOK_FIGURE, EDIF_TOK_SECTION, EDIF_TOK_NET, - EDIF_TOK_NETBUNDLE, EDIF_TOK_PAGE, - EDIF_TOK_COMMENTGRAPHICS, - EDIF_TOK_PORTIMPLEMENTATION, - EDIF_TOK_TIMING, EDIF_TOK_SIMULATE, - EDIF_TOK_WHEN, EDIF_TOK_FOLLOW, - EDIF_TOK_LOGICPORT, -EDIF_TOK_BOUNDINGBOX, - EDIF_TOK_COMMENT, EDIF_TOK_USERDATA}; -static short f_Criticality[] = {EDIF_TOK_INTEGERDISPLAY}; -static short f_CurrentMap[] = {EDIF_TOK_MNM, EDIF_TOK_E}; -static short f_Curve[] = {EDIF_TOK_ARC, EDIF_TOK_PT}; -static short f_Cycle[] = {EDIF_TOK_DURATION}; -static short f_DataOrigin[] = {EDIF_TOK_VERSION}; -static short f_DcFanInLoad[] = {EDIF_TOK_E, EDIF_TOK_NUMBERDISPLAY}; -static short f_DcFanOutLoad[] = {EDIF_TOK_E, EDIF_TOK_NUMBERDISPLAY}; -static short f_DcMaxFanIn[] = {EDIF_TOK_E, EDIF_TOK_NUMBERDISPLAY}; -static short f_DcMaxFanOut[] = {EDIF_TOK_E, EDIF_TOK_NUMBERDISPLAY}; -static short f_Delay[] = {EDIF_TOK_MNM, EDIF_TOK_E}; -static short f_Delta[] = {EDIF_TOK_PT}; -static short f_Design[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_CELLREF, - EDIF_TOK_STATUS, EDIF_TOK_COMMENT, - EDIF_TOK_PROPERTY, EDIF_TOK_USERDATA}; -static short f_Designator[] = {EDIF_TOK_STRINGDISPLAY}; -static short f_Difference[] = {EDIF_TOK_FIGUREGROUPREF, EDIF_TOK_INTERSECTION, - EDIF_TOK_UNION, EDIF_TOK_DIFFERENCE, - EDIF_TOK_INVERSE, EDIF_TOK_OVERSIZE}; -static short f_Display[] = {EDIF_TOK_NAME, EDIF_TOK_FIGUREGROUPOVERRIDE, - EDIF_TOK_JUSTIFY, EDIF_TOK_ORIENTATION, - EDIF_TOK_ORIGIN}; -static short f_Dominates[] = {EDIF_TOK_NAME}; -static short f_Dot[] = {EDIF_TOK_PT, EDIF_TOK_PROPERTY}; -static short f_Duration[] = {EDIF_TOK_E}; -static short f_EnclosureDistance[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, - EDIF_TOK_FIGUREGROUPOBJECT, - EDIF_TOK_LESSTHAN, EDIF_TOK_GREATERTHAN, - EDIF_TOK_ATMOST, EDIF_TOK_ATLEAST, - EDIF_TOK_EXACTLY, EDIF_TOK_BETWEEN, - EDIF_TOK_SINGLEVALUESET, - EDIF_TOK_COMMENT, EDIF_TOK_USERDATA}; -static short f_Entry[] = {EDIF_TOK_MATCH, EDIF_TOK_CHANGE, EDIF_TOK_STEADY, - EDIF_TOK_LOGICREF, EDIF_TOK_PORTREF, - EDIF_TOK_NOCHANGE, EDIF_TOK_TABLE, - EDIF_TOK_DELAY, EDIF_TOK_LOADDELAY}; -static short f_Exactly[] = {EDIF_TOK_E}; -static short f_External[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, - EDIF_TOK_EDIFLEVEL, EDIF_TOK_TECHNOLOGY, - -EDIF_TOK_STATUS, EDIF_TOK_CELL, EDIF_TOK_COMMENT, - EDIF_TOK_USERDATA}; -static short f_Fabricate[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME}; -static short f_Figure[] = {EDIF_TOK_NAME, EDIF_TOK_FIGUREGROUPOVERRIDE, - EDIF_TOK_CIRCLE, EDIF_TOK_DOT, EDIF_TOK_OPENSHAPE, - EDIF_TOK_PATH, EDIF_TOK_POLYGON, - EDIF_TOK_RECTANGLE, EDIF_TOK_SHAPE, - EDIF_TOK_COMMENT, EDIF_TOK_USERDATA}; -static short f_FigureArea[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, - EDIF_TOK_FIGUREGROUPOBJECT, EDIF_TOK_LESSTHAN, - EDIF_TOK_GREATERTHAN, EDIF_TOK_ATMOST, - EDIF_TOK_ATLEAST, EDIF_TOK_EXACTLY, - EDIF_TOK_BETWEEN, EDIF_TOK_SINGLEVALUESET, - EDIF_TOK_COMMENT, EDIF_TOK_USERDATA}; -static short f_FigureGroup[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, - -EDIF_TOK_CORNERTYPE, -EDIF_TOK_ENDTYPE, - -EDIF_TOK_PATHWIDTH, -EDIF_TOK_BORDERWIDTH, - -EDIF_TOK_COLOR, -EDIF_TOK_FILLPATTERN, - -EDIF_TOK_BORDERPATTERN, -EDIF_TOK_TEXTHEIGHT, - -EDIF_TOK_VISIBLE, EDIF_TOK_INCLUDEFIGUREGROUP, - EDIF_TOK_COMMENT, EDIF_TOK_PROPERTY, - EDIF_TOK_USERDATA}; -static short f_FigureGroupObject[] = {EDIF_TOK_NAME, - EDIF_TOK_FIGUREGROUPOBJECT, - EDIF_TOK_INTERSECTION, EDIF_TOK_UNION, - EDIF_TOK_DIFFERENCE, EDIF_TOK_INVERSE, - EDIF_TOK_OVERSIZE}; -static short f_FigureGroupOverride[] = {EDIF_TOK_NAME, -EDIF_TOK_CORNERTYPE, - -EDIF_TOK_ENDTYPE, -EDIF_TOK_PATHWIDTH, - -EDIF_TOK_BORDERWIDTH, -EDIF_TOK_COLOR, - -EDIF_TOK_FILLPATTERN, - -EDIF_TOK_TEXTHEIGHT, - -EDIF_TOK_BORDERPATTERN, - EDIF_TOK_VISIBLE, EDIF_TOK_COMMENT, - EDIF_TOK_PROPERTY, EDIF_TOK_USERDATA}; -static short f_FigureGroupRef[] = {EDIF_TOK_NAME, EDIF_TOK_LIBRARYREF}; -static short f_FigurePerimeter[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, - EDIF_TOK_FIGUREGROUPOBJECT, - EDIF_TOK_LESSTHAN, EDIF_TOK_GREATERTHAN, - EDIF_TOK_ATMOST, EDIF_TOK_ATLEAST, - EDIF_TOK_EXACTLY, EDIF_TOK_BETWEEN, - EDIF_TOK_SINGLEVALUESET, EDIF_TOK_COMMENT, - EDIF_TOK_USERDATA}; -static short f_FigureWidth[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, - EDIF_TOK_FIGUREGROUPOBJECT, EDIF_TOK_LESSTHAN, - EDIF_TOK_GREATERTHAN, EDIF_TOK_ATMOST, - EDIF_TOK_ATLEAST, EDIF_TOK_EXACTLY, - EDIF_TOK_BETWEEN, EDIF_TOK_SINGLEVALUESET, - EDIF_TOK_COMMENT, EDIF_TOK_USERDATA}; -static short f_FillPattern[] = {EDIF_TOK_BOOLEAN}; -static short f_Follow[] = {EDIF_TOK_NAME, EDIF_TOK_PORTREF, EDIF_TOK_TABLE, - EDIF_TOK_DELAY, EDIF_TOK_LOADDELAY}; -static short f_ForbiddenEvent[] = {EDIF_TOK_TIMEINTERVAL, EDIF_TOK_EVENT}; -static short f_GlobalPortRef[] = {EDIF_TOK_NAME}; -static short f_GreaterThan[] = {EDIF_TOK_E}; -static short f_GridMap[] = {EDIF_TOK_E}; -static short f_IncludeFigureGroup[] = {EDIF_TOK_FIGUREGROUPREF, - EDIF_TOK_INTERSECTION, EDIF_TOK_UNION, - EDIF_TOK_DIFFERENCE, EDIF_TOK_INVERSE, - EDIF_TOK_OVERSIZE}; -static short f_Instance[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_ARRAY, - EDIF_TOK_VIEWREF, EDIF_TOK_VIEWLIST, - -EDIF_TOK_TRANSFORM, EDIF_TOK_PARAMETERASSIGN, - EDIF_TOK_PORTINSTANCE, EDIF_TOK_TIMING, - -EDIF_TOK_DESIGNATOR, EDIF_TOK_PROPERTY, - EDIF_TOK_COMMENT, EDIF_TOK_USERDATA}; -static short f_InstanceBackAnnotate[] = {EDIF_TOK_INSTANCEREF, - -EDIF_TOK_DESIGNATOR, EDIF_TOK_TIMING, - EDIF_TOK_PROPERTY, EDIF_TOK_COMMENT}; -static short f_InstanceGroup[] = {EDIF_TOK_INSTANCEREF}; -static short f_InstanceMap[] = {EDIF_TOK_INSTANCEREF, EDIF_TOK_INSTANCEGROUP, - EDIF_TOK_COMMENT, EDIF_TOK_USERDATA}; -static short f_InstanceRef[] = {EDIF_TOK_NAME, EDIF_TOK_MEMBER, - EDIF_TOK_INSTANCEREF, EDIF_TOK_VIEWREF}; -static short f_Integer[] = {EDIF_TOK_INTEGERDISPLAY, EDIF_TOK_INTEGER}; -static short f_IntegerDisplay[] = {EDIF_TOK_DISPLAY}; -static short f_Interface[] = {EDIF_TOK_PORT, EDIF_TOK_PORTBUNDLE, - -EDIF_TOK_SYMBOL, -EDIF_TOK_PROTECTIONFRAME, - -EDIF_TOK_ARRAYRELATEDINFO, EDIF_TOK_PARAMETER, - EDIF_TOK_JOINED, EDIF_TOK_MUSTJOIN, - EDIF_TOK_WEAKJOINED, EDIF_TOK_PERMUTABLE, - EDIF_TOK_TIMING, EDIF_TOK_SIMULATE, - -EDIF_TOK_DESIGNATOR, EDIF_TOK_PROPERTY, - EDIF_TOK_COMMENT, EDIF_TOK_USERDATA}; -static short f_InterFigureGroupSpacing[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, - EDIF_TOK_FIGUREGROUPOBJECT, - EDIF_TOK_LESSTHAN, - EDIF_TOK_GREATERTHAN, - EDIF_TOK_ATMOST, - EDIF_TOK_ATLEAST, EDIF_TOK_EXACTLY, - EDIF_TOK_BETWEEN, - EDIF_TOK_SINGLEVALUESET, - EDIF_TOK_COMMENT, - EDIF_TOK_USERDATA}; -static short f_Intersection[] = {EDIF_TOK_FIGUREGROUPREF, - EDIF_TOK_INTERSECTION, EDIF_TOK_UNION, - EDIF_TOK_DIFFERENCE, EDIF_TOK_INVERSE, - EDIF_TOK_OVERSIZE}; -static short f_IntraFigureGroupSpacing[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, - EDIF_TOK_FIGUREGROUPOBJECT, - EDIF_TOK_LESSTHAN, - EDIF_TOK_GREATERTHAN, - EDIF_TOK_ATMOST, EDIF_TOK_ATLEAST, - EDIF_TOK_EXACTLY, EDIF_TOK_BETWEEN, - EDIF_TOK_SINGLEVALUESET, - EDIF_TOK_COMMENT, - EDIF_TOK_USERDATA}; -static short f_Inverse[] = {EDIF_TOK_FIGUREGROUPREF, EDIF_TOK_INTERSECTION, - EDIF_TOK_UNION, EDIF_TOK_DIFFERENCE, - EDIF_TOK_INVERSE, EDIF_TOK_OVERSIZE}; -static short f_Joined[] = {EDIF_TOK_PORTREF, EDIF_TOK_PORTLIST, - EDIF_TOK_GLOBALPORTREF}; -static short f_KeywordDisplay[] = {EDIF_TOK_DISPLAY}; -static short f_KeywordMap[] = {EDIF_TOK_KEYWORDLEVEL, EDIF_TOK_COMMENT}; -static short f_LessThan[] = {EDIF_TOK_E}; -static short f_Library[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_EDIFLEVEL, - EDIF_TOK_TECHNOLOGY, -EDIF_TOK_STATUS, - EDIF_TOK_CELL, EDIF_TOK_COMMENT, - EDIF_TOK_USERDATA}; -static short f_LibraryRef[] = {EDIF_TOK_NAME}; -static short f_ListOfNets[] = {EDIF_TOK_NET}; -static short f_ListOfPorts[] = {EDIF_TOK_PORT, EDIF_TOK_PORTBUNDLE}; -static short f_LoadDelay[] = {EDIF_TOK_MNM, EDIF_TOK_E, EDIF_TOK_MINOMAXDISPLAY}; -static short f_LogicAssign[] = {EDIF_TOK_NAME, EDIF_TOK_PORTREF, - EDIF_TOK_LOGICREF, EDIF_TOK_TABLE, - EDIF_TOK_DELAY, EDIF_TOK_LOADDELAY}; -static short f_LogicInput[] = {EDIF_TOK_PORTLIST, EDIF_TOK_PORTREF, - EDIF_TOK_NAME, EDIF_TOK_LOGICWAVEFORM}; -static short f_LogicList[] = {EDIF_TOK_NAME, EDIF_TOK_LOGICONEOF, - EDIF_TOK_IGNORE}; -static short f_LogicMapInput[] = {EDIF_TOK_LOGICREF}; -static short f_LogicMapOutput[] = {EDIF_TOK_LOGICREF}; -static short f_LogicOneOf[] = {EDIF_TOK_NAME, EDIF_TOK_LOGICLIST}; -static short f_LogicOutput[] = {EDIF_TOK_PORTLIST, EDIF_TOK_PORTREF, - EDIF_TOK_NAME, EDIF_TOK_LOGICWAVEFORM}; -static short f_LogicPort[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, - EDIF_TOK_PROPERTY, EDIF_TOK_COMMENT, - EDIF_TOK_USERDATA}; -static short f_LogicRef[] = {EDIF_TOK_NAME, EDIF_TOK_LIBRARYREF}; -static short f_LogicValue[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, - -EDIF_TOK_VOLTAGEMAP, -EDIF_TOK_CURRENTMAP, - -EDIF_TOK_BOOLEANMAP, -EDIF_TOK_COMPOUND, - -EDIF_TOK_WEAK ,-EDIF_TOK_STRONG, - -EDIF_TOK_DOMINATES, -EDIF_TOK_LOGICMAPOUTPUT, - -EDIF_TOK_LOGICMAPINPUT, - -EDIF_TOK_ISOLATED, EDIF_TOK_RESOLVES, - EDIF_TOK_PROPERTY, EDIF_TOK_COMMENT, - EDIF_TOK_USERDATA}; -static short f_LogicWaveform[] = {EDIF_TOK_NAME, EDIF_TOK_LOGICLIST, - EDIF_TOK_LOGICONEOF, EDIF_TOK_IGNORE}; -static short f_Maintain[] = {EDIF_TOK_NAME, EDIF_TOK_PORTREF, EDIF_TOK_DELAY, - EDIF_TOK_LOADDELAY}; -static short f_Match[] = {EDIF_TOK_NAME, EDIF_TOK_PORTREF, EDIF_TOK_PORTLIST, - EDIF_TOK_LOGICLIST, EDIF_TOK_LOGICONEOF}; -static short f_Member[] = {EDIF_TOK_NAME}; -static short f_MiNoMax[] = {EDIF_TOK_MNM, EDIF_TOK_E, EDIF_TOK_MINOMAXDISPLAY, - EDIF_TOK_MINOMAX}; -static short f_MiNoMaxDisplay[] = {EDIF_TOK_MNM, EDIF_TOK_E, EDIF_TOK_DISPLAY}; -static short f_Mnm[] = {EDIF_TOK_E, EDIF_TOK_UNDEFINED, - EDIF_TOK_UNCONSTRAINED}; -static short f_MultipleValueSet[] = {EDIF_TOK_RANGEVECTOR}; -static short f_MustJoin[] = {EDIF_TOK_PORTREF, EDIF_TOK_PORTLIST, - EDIF_TOK_WEAKJOINED, EDIF_TOK_JOINED}; -static short f_Name[] = {EDIF_TOK_DISPLAY}; -static short f_Net[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, -EDIF_TOK_CRITICALITY, - EDIF_TOK_NETDELAY, EDIF_TOK_FIGURE, EDIF_TOK_NET, - EDIF_TOK_INSTANCE, EDIF_TOK_COMMENTGRAPHICS, - EDIF_TOK_PROPERTY, EDIF_TOK_COMMENT, - EDIF_TOK_USERDATA, EDIF_TOK_JOINED, EDIF_TOK_ARRAY}; -static short f_NetBackAnnotate[] = {EDIF_TOK_NETREF, EDIF_TOK_NETDELAY, - -EDIF_TOK_CRITICALITY, EDIF_TOK_PROPERTY, - EDIF_TOK_COMMENT}; -static short f_NetBundle[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_ARRAY, - EDIF_TOK_LISTOFNETS, EDIF_TOK_FIGURE, - EDIF_TOK_COMMENTGRAPHICS, EDIF_TOK_PROPERTY, - EDIF_TOK_COMMENT, EDIF_TOK_USERDATA}; -static short f_NetDelay[] = {EDIF_TOK_DERIVATION, EDIF_TOK_DELAY, - EDIF_TOK_TRANSITION, EDIF_TOK_BECOMES}; -static short f_NetGroup[] = {EDIF_TOK_NAME, EDIF_TOK_MEMBER, EDIF_TOK_NETREF}; -static short f_NetMap[] = {EDIF_TOK_NETREF, EDIF_TOK_NETGROUP, - EDIF_TOK_COMMENT, EDIF_TOK_USERDATA}; -static short f_NetRef[] = {EDIF_TOK_NAME, EDIF_TOK_MEMBER, EDIF_TOK_NETREF, - EDIF_TOK_INSTANCEREF, EDIF_TOK_VIEWREF}; -static short f_NonPermutable[] = {EDIF_TOK_PORTREF, EDIF_TOK_PERMUTABLE}; -static short f_NotAllowed[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, - EDIF_TOK_FIGUREGROUPOBJECT, EDIF_TOK_COMMENT, - EDIF_TOK_USERDATA}; -static short f_NotchSpacing[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, - EDIF_TOK_FIGUREGROUPOBJECT, EDIF_TOK_LESSTHAN, - EDIF_TOK_GREATERTHAN, EDIF_TOK_ATMOST, - EDIF_TOK_ATLEAST, EDIF_TOK_EXACTLY, - EDIF_TOK_BETWEEN, EDIF_TOK_SINGLEVALUESET, - EDIF_TOK_COMMENT, EDIF_TOK_USERDATA}; -static short f_Number[] = {EDIF_TOK_E, EDIF_TOK_NUMBERDISPLAY, EDIF_TOK_NUMBER}; -static short f_NumberDefinition[] = {EDIF_TOK_SCALE, -EDIF_TOK_GRIDMAP, - EDIF_TOK_COMMENT}; -static short f_NumberDisplay[] = {EDIF_TOK_E, EDIF_TOK_DISPLAY}; -static short f_OffPageConnector[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, - -EDIF_TOK_UNUSED, EDIF_TOK_PROPERTY, - EDIF_TOK_COMMENT, EDIF_TOK_USERDATA}; -static short f_OffsetEvent[] = {EDIF_TOK_EVENT, EDIF_TOK_E}; -static short f_OpenShape[] = {EDIF_TOK_CURVE, EDIF_TOK_PROPERTY}; -static short f_Origin[] = {EDIF_TOK_PT}; -static short f_OverhangDistance[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, - EDIF_TOK_FIGUREGROUPOBJECT, EDIF_TOK_LESSTHAN, - EDIF_TOK_GREATERTHAN, EDIF_TOK_ATMOST, - EDIF_TOK_ATLEAST, EDIF_TOK_EXACTLY, - EDIF_TOK_BETWEEN, EDIF_TOK_SINGLEVALUESET, - EDIF_TOK_COMMENT, EDIF_TOK_USERDATA}; -static short f_OverlapDistance[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, - EDIF_TOK_FIGUREGROUPOBJECT, EDIF_TOK_LESSTHAN, - EDIF_TOK_GREATERTHAN, EDIF_TOK_ATMOST, - EDIF_TOK_ATLEAST, EDIF_TOK_EXACTLY, - EDIF_TOK_BETWEEN, EDIF_TOK_SINGLEVALUESET, - EDIF_TOK_COMMENT, EDIF_TOK_USERDATA}; -static short f_Oversize[] = {EDIF_TOK_FIGUREGROUPREF, EDIF_TOK_INTERSECTION, - EDIF_TOK_UNION, EDIF_TOK_DIFFERENCE, - EDIF_TOK_INVERSE, EDIF_TOK_OVERSIZE, - EDIF_TOK_CORNERTYPE}; -static short f_Page[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_ARRAY, - EDIF_TOK_INSTANCE, EDIF_TOK_NET, EDIF_TOK_NETBUNDLE, - EDIF_TOK_COMMENTGRAPHICS, EDIF_TOK_PORTIMPLEMENTATION, - -EDIF_TOK_PAGESIZE, -EDIF_TOK_BOUNDINGBOX, - EDIF_TOK_COMMENT, EDIF_TOK_USERDATA}; -static short f_PageSize[] = {EDIF_TOK_RECTANGLE}; -static short f_Parameter[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_ARRAY, - EDIF_TOK_BOOLEAN, EDIF_TOK_INTEGER, - EDIF_TOK_MINOMAX, EDIF_TOK_NUMBER, - EDIF_TOK_POINT, EDIF_TOK_STRING}; -static short f_ParameterAssign[] = {EDIF_TOK_NAME, EDIF_TOK_MEMBER, - EDIF_TOK_BOOLEAN, EDIF_TOK_INTEGER, - EDIF_TOK_MINOMAX, EDIF_TOK_NUMBER, EDIF_TOK_POINT, - EDIF_TOK_STRING}; -static short f_ParameterDisplay[] = {EDIF_TOK_NAME, EDIF_TOK_MEMBER, - EDIF_TOK_DISPLAY}; -static short f_Path[] = {EDIF_TOK_POINTLIST, EDIF_TOK_PROPERTY}; -static short f_PathDelay[] = {EDIF_TOK_DELAY, EDIF_TOK_EVENT}; -static short f_Permutable[] = {EDIF_TOK_PORTREF, EDIF_TOK_PERMUTABLE, - EDIF_TOK_NONPERMUTABLE}; -static short f_PhysicalDesignRule[] = {EDIF_TOK_FIGUREWIDTH, - EDIF_TOK_FIGUREAREA, - EDIF_TOK_RECTANGLESIZE, - EDIF_TOK_FIGUREPERIMETER, - EDIF_TOK_OVERLAPDISTANCE, - EDIF_TOK_OVERHANGDISTANCE, - EDIF_TOK_ENCLOSUREDISTANCE, - EDIF_TOK_INTERFIGUREGROUPSPACING, - EDIF_TOK_NOTCHSPACING, - EDIF_TOK_INTRAFIGUREGROUPSPACING, - EDIF_TOK_NOTALLOWED, - EDIF_TOK_FIGUREGROUP, EDIF_TOK_COMMENT, - EDIF_TOK_USERDATA}; -static short f_Plug[] = {EDIF_TOK_SOCKETSET}; -static short f_Point[] = {EDIF_TOK_PT, EDIF_TOK_POINTDISPLAY, - EDIF_TOK_POINT}; -static short f_PointDisplay[] = {EDIF_TOK_PT, EDIF_TOK_DISPLAY}; -static short f_PointList[] = {EDIF_TOK_PT}; -static short f_Polygon[] = {EDIF_TOK_POINTLIST, EDIF_TOK_PROPERTY}; -static short f_Port[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_ARRAY, - -EDIF_TOK_DIRECTION, -EDIF_TOK_UNUSED, - EDIF_TOK_PORTDELAY, -EDIF_TOK_DESIGNATOR, - -EDIF_TOK_DCFANINLOAD, -EDIF_TOK_DCFANOUTLOAD, - -EDIF_TOK_DCMAXFANIN, -EDIF_TOK_DCMAXFANOUT, - -EDIF_TOK_ACLOAD, EDIF_TOK_PROPERTY, - EDIF_TOK_COMMENT, EDIF_TOK_USERDATA}; -static short f_PortBackAnnotate[] = {EDIF_TOK_PORTREF, -EDIF_TOK_DESIGNATOR, - EDIF_TOK_PORTDELAY, -EDIF_TOK_DCFANINLOAD, - -EDIF_TOK_DCFANOUTLOAD, - -EDIF_TOK_DCMAXFANIN, - -EDIF_TOK_DCMAXFANOUT, -EDIF_TOK_ACLOAD, - EDIF_TOK_PROPERTY, EDIF_TOK_COMMENT}; -static short f_PortBundle[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_ARRAY, - EDIF_TOK_LISTOFPORTS, EDIF_TOK_PROPERTY, - EDIF_TOK_COMMENT, EDIF_TOK_USERDATA}; -static short f_PortDelay[] = {EDIF_TOK_DERIVATION, EDIF_TOK_DELAY, - EDIF_TOK_LOADDELAY, EDIF_TOK_TRANSITION, - EDIF_TOK_BECOMES}; -static short f_PortGroup[] = {EDIF_TOK_NAME, EDIF_TOK_MEMBER, - EDIF_TOK_PORTREF}; -static short f_PortImplementation[] = {EDIF_TOK_PORTREF, EDIF_TOK_NAME, EDIF_TOK_MEMBER, - -EDIF_TOK_CONNECTLOCATION, - EDIF_TOK_FIGURE, EDIF_TOK_INSTANCE, - EDIF_TOK_COMMENTGRAPHICS, - EDIF_TOK_PROPERTYDISPLAY, - EDIF_TOK_KEYWORDDISPLAY, - EDIF_TOK_PROPERTY, - EDIF_TOK_USERDATA, EDIF_TOK_COMMENT}; -static short f_PortInstance[] = {EDIF_TOK_PORTREF, EDIF_TOK_NAME, - EDIF_TOK_MEMBER, -EDIF_TOK_UNUSED, - EDIF_TOK_PORTDELAY, -EDIF_TOK_DESIGNATOR, - -EDIF_TOK_DCFANINLOAD, - -EDIF_TOK_DCFANOUTLOAD, -EDIF_TOK_DCMAXFANIN, - -EDIF_TOK_DCMAXFANOUT, -EDIF_TOK_ACLOAD, - EDIF_TOK_PROPERTY, EDIF_TOK_COMMENT, - EDIF_TOK_USERDATA}; -static short f_PortList[] = {EDIF_TOK_PORTREF, EDIF_TOK_NAME, - EDIF_TOK_MEMBER}; -static short f_PortListAlias[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, - EDIF_TOK_ARRAY, EDIF_TOK_PORTLIST}; -static short f_PortMap[] = {EDIF_TOK_PORTREF, EDIF_TOK_PORTGROUP, - EDIF_TOK_COMMENT, EDIF_TOK_USERDATA}; -static short f_PortRef[] = {EDIF_TOK_NAME, EDIF_TOK_MEMBER, - EDIF_TOK_PORTREF, EDIF_TOK_INSTANCEREF, - EDIF_TOK_VIEWREF}; -static short f_Program[] = {EDIF_TOK_VERSION}; -static short f_Property[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_BOOLEAN, - EDIF_TOK_INTEGER, EDIF_TOK_MINOMAX, - EDIF_TOK_NUMBER, EDIF_TOK_POINT, EDIF_TOK_STRING, - -EDIF_TOK_OWNER, -EDIF_TOK_UNIT, - EDIF_TOK_PROPERTY, EDIF_TOK_COMMENT}; -static short f_PropertyDisplay[] = {EDIF_TOK_NAME, EDIF_TOK_DISPLAY}; -static short f_ProtectionFrame[] = {EDIF_TOK_PORTIMPLEMENTATION, - EDIF_TOK_FIGURE, EDIF_TOK_INSTANCE, - EDIF_TOK_COMMENTGRAPHICS, - -EDIF_TOK_BOUNDINGBOX, - EDIF_TOK_PROPERTYDISPLAY, - EDIF_TOK_KEYWORDDISPLAY, - EDIF_TOK_PARAMETERDISPLAY, - EDIF_TOK_PROPERTY, EDIF_TOK_COMMENT, - EDIF_TOK_USERDATA}; -static short f_RangeVector[] = {EDIF_TOK_LESSTHAN, EDIF_TOK_GREATERTHAN, - EDIF_TOK_ATMOST, EDIF_TOK_ATLEAST, - EDIF_TOK_EXACTLY, EDIF_TOK_BETWEEN, - EDIF_TOK_SINGLEVALUESET}; -static short f_Rectangle[] = {EDIF_TOK_PT, EDIF_TOK_PROPERTY}; -static short f_RectangleSize[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, - EDIF_TOK_FIGUREGROUPOBJECT, - EDIF_TOK_RANGEVECTOR, - EDIF_TOK_MULTIPLEVALUESET,EDIF_TOK_COMMENT, - EDIF_TOK_USERDATA}; -static short f_Rename[] = {EDIF_TOK_NAME, EDIF_TOK_STRINGDISPLAY}; -static short f_Resolves[] = {EDIF_TOK_NAME}; -static short f_Scale[] = {EDIF_TOK_E, EDIF_TOK_UNIT}; -static short f_Section[] = {EDIF_TOK_SECTION, EDIF_TOK_INSTANCE}; -static short f_Shape[] = {EDIF_TOK_CURVE, EDIF_TOK_PROPERTY}; -static short f_Simulate[] = {EDIF_TOK_NAME, EDIF_TOK_PORTLISTALIAS, - EDIF_TOK_WAVEVALUE, EDIF_TOK_APPLY, - EDIF_TOK_COMMENT, EDIF_TOK_USERDATA}; -static short f_SimulationInfo[] = {EDIF_TOK_LOGICVALUE, EDIF_TOK_COMMENT, - EDIF_TOK_USERDATA}; -static short f_SingleValueSet[] = {EDIF_TOK_LESSTHAN, EDIF_TOK_GREATERTHAN, - EDIF_TOK_ATMOST, EDIF_TOK_ATLEAST, - EDIF_TOK_EXACTLY, EDIF_TOK_BETWEEN}; -static short f_Site[] = {EDIF_TOK_VIEWREF, EDIF_TOK_TRANSFORM}; -static short f_Socket[] = {EDIF_TOK_SYMMETRY}; -static short f_SocketSet[] = {EDIF_TOK_SYMMETRY, EDIF_TOK_SITE}; -static short f_Status[] = {EDIF_TOK_WRITTEN, EDIF_TOK_COMMENT, - EDIF_TOK_USERDATA}; -static short f_Steady[] = {EDIF_TOK_NAME, EDIF_TOK_MEMBER, EDIF_TOK_PORTREF, - EDIF_TOK_PORTLIST, EDIF_TOK_DURATION, - EDIF_TOK_TRANSITION, EDIF_TOK_BECOMES}; -static short f_String[] = {EDIF_TOK_STRINGDISPLAY, EDIF_TOK_STRING}; -static short f_StringDisplay[] = {EDIF_TOK_DISPLAY}; -static short f_Strong[] = {EDIF_TOK_NAME}; -static short f_Symbol[] = {EDIF_TOK_PORTIMPLEMENTATION, EDIF_TOK_FIGURE, - EDIF_TOK_INSTANCE, EDIF_TOK_COMMENTGRAPHICS, - EDIF_TOK_ANNOTATE, -EDIF_TOK_PAGESIZE, - -EDIF_TOK_BOUNDINGBOX, EDIF_TOK_PROPERTYDISPLAY, - EDIF_TOK_KEYWORDDISPLAY, EDIF_TOK_PARAMETERDISPLAY, - EDIF_TOK_PROPERTY, EDIF_TOK_COMMENT, - EDIF_TOK_USERDATA}; -static short f_Symmetry[] = {EDIF_TOK_TRANSFORM}; -static short f_Table[] = {EDIF_TOK_ENTRY, EDIF_TOK_TABLEDEFAULT}; -static short f_TableDefault[] = {EDIF_TOK_LOGICREF, EDIF_TOK_PORTREF, - EDIF_TOK_NOCHANGE, EDIF_TOK_TABLE, - EDIF_TOK_DELAY, EDIF_TOK_LOADDELAY}; -static short f_Technology[] = {EDIF_TOK_NUMBERDEFINITION, EDIF_TOK_FIGUREGROUP, - EDIF_TOK_FABRICATE, -EDIF_TOK_SIMULATIONINFO, - EDIF_TOK_COMMENT, EDIF_TOK_USERDATA, - -EDIF_TOK_PHYSICALDESIGNRULE}; -static short f_TimeInterval[] = {EDIF_TOK_EVENT, EDIF_TOK_OFFSETEVENT, - EDIF_TOK_DURATION}; -static short f_Timing[] = {EDIF_TOK_DERIVATION, EDIF_TOK_PATHDELAY, - EDIF_TOK_FORBIDDENEVENT, EDIF_TOK_COMMENT, - EDIF_TOK_USERDATA}; -static short f_Transform[] = {EDIF_TOK_SCALEX, EDIF_TOK_SCALEY, EDIF_TOK_DELTA, - EDIF_TOK_ORIENTATION, EDIF_TOK_ORIGIN}; -static short f_Transition[] = {EDIF_TOK_NAME, EDIF_TOK_LOGICLIST, - EDIF_TOK_LOGICONEOF}; -static short f_Trigger[] = {EDIF_TOK_CHANGE, EDIF_TOK_STEADY, - EDIF_TOK_INITIAL}; -static short f_Union[] = {EDIF_TOK_FIGUREGROUPREF, EDIF_TOK_INTERSECTION, - EDIF_TOK_UNION, EDIF_TOK_DIFFERENCE, - EDIF_TOK_INVERSE, EDIF_TOK_OVERSIZE}; -static short f_View[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_VIEWTYPE, - EDIF_TOK_INTERFACE, -EDIF_TOK_STATUS, - -EDIF_TOK_CONTENTS, EDIF_TOK_COMMENT, - EDIF_TOK_PROPERTY, EDIF_TOK_USERDATA}; -static short f_ViewList[] = {EDIF_TOK_VIEWREF, EDIF_TOK_VIEWLIST}; -static short f_ViewMap[] = {EDIF_TOK_PORTMAP, EDIF_TOK_PORTBACKANNOTATE, - EDIF_TOK_INSTANCEMAP, - EDIF_TOK_INSTANCEBACKANNOTATE, EDIF_TOK_NETMAP, - EDIF_TOK_NETBACKANNOTATE, EDIF_TOK_COMMENT, - EDIF_TOK_USERDATA}; -static short f_ViewRef[] = {EDIF_TOK_NAME, EDIF_TOK_CELLREF}; -static short f_Visible[] = {EDIF_TOK_FALSE, EDIF_TOK_TRUE}; -static short f_VoltageMap[] = {EDIF_TOK_MNM, EDIF_TOK_E}; -static short f_WaveValue[] = {EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_E, - EDIF_TOK_LOGICWAVEFORM}; -static short f_Weak[] = {EDIF_TOK_NAME}; -static short f_WeakJoined[] = {EDIF_TOK_PORTREF, EDIF_TOK_PORTLIST, - EDIF_TOK_JOINED}; -static short f_When[] = {EDIF_TOK_TRIGGER, EDIF_TOK_AFTER, - EDIF_TOK_FOLLOW, EDIF_TOK_MAINTAIN, - EDIF_TOK_LOGICASSIGN, EDIF_TOK_COMMENT, - EDIF_TOK_USERDATA}; -static short f_Written[] = {EDIF_TOK_TIMESTAMP, EDIF_TOK_AUTHOR, - EDIF_TOK_PROGRAM, EDIF_TOK_DATAORIGIN, - EDIF_TOK_PROPERTY, EDIF_TOK_COMMENT, - EDIF_TOK_USERDATA}; +static short f_Boolean[] = { EDIF_TOK_FALSE, EDIF_TOK_TRUE, + EDIF_TOK_BOOLEANDISPLAY, EDIF_TOK_BOOLEAN +}; + +static short f_BooleanDisplay[] = { EDIF_TOK_FALSE, EDIF_TOK_TRUE, + EDIF_TOK_DISPLAY +}; +static short f_BooleanMap[] = { EDIF_TOK_FALSE, EDIF_TOK_TRUE }; +static short f_BorderPattern[] = { EDIF_TOK_BOOLEAN }; +static short f_BoundingBox[] = { EDIF_TOK_RECTANGLE }; + +static short f_Cell[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_CELLTYPE, + -EDIF_TOK_STATUS, -EDIF_TOK_VIEWMAP, EDIF_TOK_VIEW, + EDIF_TOK_COMMENT, EDIF_TOK_USERDATA, + EDIF_TOK_PROPERTY +}; +static short f_CellRef[] = { EDIF_TOK_NAME, EDIF_TOK_LIBRARYREF }; + +static short f_Change[] = { EDIF_TOK_NAME, EDIF_TOK_PORTREF, EDIF_TOK_PORTLIST, + EDIF_TOK_BECOMES, EDIF_TOK_TRANSITION +}; +static short f_Circle[] = { EDIF_TOK_PT, EDIF_TOK_PROPERTY }; +static short f_Color[] = { EDIF_TOK_E }; + +static short f_CommentGraphics[] = { EDIF_TOK_ANNOTATE, EDIF_TOK_FIGURE, + EDIF_TOK_INSTANCE, -EDIF_TOK_BOUNDINGBOX, + EDIF_TOK_PROPERTY, EDIF_TOK_COMMENT, + EDIF_TOK_USERDATA +}; +static short f_Compound[] = { EDIF_TOK_NAME }; +static short f_ConnectLocation[] = { EDIF_TOK_FIGURE }; + +static short f_Contents[] = { EDIF_TOK_INSTANCE, EDIF_TOK_OFFPAGECONNECTOR, + EDIF_TOK_FIGURE, EDIF_TOK_SECTION, EDIF_TOK_NET, + EDIF_TOK_NETBUNDLE, EDIF_TOK_PAGE, + EDIF_TOK_COMMENTGRAPHICS, + EDIF_TOK_PORTIMPLEMENTATION, + EDIF_TOK_TIMING, EDIF_TOK_SIMULATE, + EDIF_TOK_WHEN, EDIF_TOK_FOLLOW, + EDIF_TOK_LOGICPORT, -EDIF_TOK_BOUNDINGBOX, + EDIF_TOK_COMMENT, EDIF_TOK_USERDATA +}; +static short f_Criticality[] = { EDIF_TOK_INTEGERDISPLAY }; +static short f_CurrentMap[] = { EDIF_TOK_MNM, EDIF_TOK_E }; +static short f_Curve[] = { EDIF_TOK_ARC, EDIF_TOK_PT }; +static short f_Cycle[] = { EDIF_TOK_DURATION }; +static short f_DataOrigin[] = { EDIF_TOK_VERSION }; +static short f_DcFanInLoad[] = { EDIF_TOK_E, EDIF_TOK_NUMBERDISPLAY }; +static short f_DcFanOutLoad[] = { EDIF_TOK_E, EDIF_TOK_NUMBERDISPLAY }; +static short f_DcMaxFanIn[] = { EDIF_TOK_E, EDIF_TOK_NUMBERDISPLAY }; +static short f_DcMaxFanOut[] = { EDIF_TOK_E, EDIF_TOK_NUMBERDISPLAY }; +static short f_Delay[] = { EDIF_TOK_MNM, EDIF_TOK_E }; +static short f_Delta[] = { EDIF_TOK_PT }; + +static short f_Design[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_CELLREF, + EDIF_TOK_STATUS, EDIF_TOK_COMMENT, + EDIF_TOK_PROPERTY, EDIF_TOK_USERDATA +}; +static short f_Designator[] = { EDIF_TOK_STRINGDISPLAY }; + +static short f_Difference[] = { EDIF_TOK_FIGUREGROUPREF, EDIF_TOK_INTERSECTION, + EDIF_TOK_UNION, EDIF_TOK_DIFFERENCE, + EDIF_TOK_INVERSE, EDIF_TOK_OVERSIZE +}; + +static short f_Display[] = { EDIF_TOK_NAME, EDIF_TOK_FIGUREGROUPOVERRIDE, + EDIF_TOK_JUSTIFY, EDIF_TOK_ORIENTATION, + EDIF_TOK_ORIGIN +}; +static short f_Dominates[] = { EDIF_TOK_NAME }; +static short f_Dot[] = { EDIF_TOK_PT, EDIF_TOK_PROPERTY }; +static short f_Duration[] = { EDIF_TOK_E }; + +static short f_EnclosureDistance[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, + EDIF_TOK_FIGUREGROUPOBJECT, + EDIF_TOK_LESSTHAN, EDIF_TOK_GREATERTHAN, + EDIF_TOK_ATMOST, EDIF_TOK_ATLEAST, + EDIF_TOK_EXACTLY, EDIF_TOK_BETWEEN, + EDIF_TOK_SINGLEVALUESET, + EDIF_TOK_COMMENT, EDIF_TOK_USERDATA +}; + +static short f_Entry[] = { EDIF_TOK_MATCH, EDIF_TOK_CHANGE, EDIF_TOK_STEADY, + EDIF_TOK_LOGICREF, EDIF_TOK_PORTREF, + EDIF_TOK_NOCHANGE, EDIF_TOK_TABLE, + EDIF_TOK_DELAY, EDIF_TOK_LOADDELAY +}; +static short f_Exactly[] = { EDIF_TOK_E }; + +static short f_External[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, + EDIF_TOK_EDIFLEVEL, EDIF_TOK_TECHNOLOGY, + -EDIF_TOK_STATUS, EDIF_TOK_CELL, EDIF_TOK_COMMENT, + EDIF_TOK_USERDATA +}; +static short f_Fabricate[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME }; + +static short f_Figure[] = { EDIF_TOK_NAME, EDIF_TOK_FIGUREGROUPOVERRIDE, + EDIF_TOK_CIRCLE, EDIF_TOK_DOT, EDIF_TOK_OPENSHAPE, + EDIF_TOK_PATH, EDIF_TOK_POLYGON, + EDIF_TOK_RECTANGLE, EDIF_TOK_SHAPE, + EDIF_TOK_COMMENT, EDIF_TOK_USERDATA +}; + +static short f_FigureArea[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, + EDIF_TOK_FIGUREGROUPOBJECT, EDIF_TOK_LESSTHAN, + EDIF_TOK_GREATERTHAN, EDIF_TOK_ATMOST, + EDIF_TOK_ATLEAST, EDIF_TOK_EXACTLY, + EDIF_TOK_BETWEEN, EDIF_TOK_SINGLEVALUESET, + EDIF_TOK_COMMENT, EDIF_TOK_USERDATA +}; + +static short f_FigureGroup[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, + -EDIF_TOK_CORNERTYPE, -EDIF_TOK_ENDTYPE, + -EDIF_TOK_PATHWIDTH, -EDIF_TOK_BORDERWIDTH, + -EDIF_TOK_COLOR, -EDIF_TOK_FILLPATTERN, + -EDIF_TOK_BORDERPATTERN, -EDIF_TOK_TEXTHEIGHT, + -EDIF_TOK_VISIBLE, EDIF_TOK_INCLUDEFIGUREGROUP, + EDIF_TOK_COMMENT, EDIF_TOK_PROPERTY, + EDIF_TOK_USERDATA +}; + +static short f_FigureGroupObject[] = { EDIF_TOK_NAME, + EDIF_TOK_FIGUREGROUPOBJECT, + EDIF_TOK_INTERSECTION, EDIF_TOK_UNION, + EDIF_TOK_DIFFERENCE, EDIF_TOK_INVERSE, + EDIF_TOK_OVERSIZE +}; + +static short f_FigureGroupOverride[] = { EDIF_TOK_NAME, -EDIF_TOK_CORNERTYPE, + -EDIF_TOK_ENDTYPE, -EDIF_TOK_PATHWIDTH, + -EDIF_TOK_BORDERWIDTH, -EDIF_TOK_COLOR, + -EDIF_TOK_FILLPATTERN, + -EDIF_TOK_TEXTHEIGHT, + -EDIF_TOK_BORDERPATTERN, + EDIF_TOK_VISIBLE, EDIF_TOK_COMMENT, + EDIF_TOK_PROPERTY, EDIF_TOK_USERDATA +}; +static short f_FigureGroupRef[] = { EDIF_TOK_NAME, EDIF_TOK_LIBRARYREF }; + +static short f_FigurePerimeter[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, + EDIF_TOK_FIGUREGROUPOBJECT, + EDIF_TOK_LESSTHAN, EDIF_TOK_GREATERTHAN, + EDIF_TOK_ATMOST, EDIF_TOK_ATLEAST, + EDIF_TOK_EXACTLY, EDIF_TOK_BETWEEN, + EDIF_TOK_SINGLEVALUESET, EDIF_TOK_COMMENT, + EDIF_TOK_USERDATA +}; + +static short f_FigureWidth[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, + EDIF_TOK_FIGUREGROUPOBJECT, EDIF_TOK_LESSTHAN, + EDIF_TOK_GREATERTHAN, EDIF_TOK_ATMOST, + EDIF_TOK_ATLEAST, EDIF_TOK_EXACTLY, + EDIF_TOK_BETWEEN, EDIF_TOK_SINGLEVALUESET, + EDIF_TOK_COMMENT, EDIF_TOK_USERDATA +}; +static short f_FillPattern[] = { EDIF_TOK_BOOLEAN }; + +static short f_Follow[] = { EDIF_TOK_NAME, EDIF_TOK_PORTREF, EDIF_TOK_TABLE, + EDIF_TOK_DELAY, EDIF_TOK_LOADDELAY +}; +static short f_ForbiddenEvent[] = { EDIF_TOK_TIMEINTERVAL, EDIF_TOK_EVENT }; +static short f_GlobalPortRef[] = { EDIF_TOK_NAME }; +static short f_GreaterThan[] = { EDIF_TOK_E }; +static short f_GridMap[] = { EDIF_TOK_E }; + +static short f_IncludeFigureGroup[] = { EDIF_TOK_FIGUREGROUPREF, + EDIF_TOK_INTERSECTION, EDIF_TOK_UNION, + EDIF_TOK_DIFFERENCE, EDIF_TOK_INVERSE, + EDIF_TOK_OVERSIZE +}; + +static short f_Instance[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_ARRAY, + EDIF_TOK_VIEWREF, EDIF_TOK_VIEWLIST, + -EDIF_TOK_TRANSFORM, EDIF_TOK_PARAMETERASSIGN, + EDIF_TOK_PORTINSTANCE, EDIF_TOK_TIMING, + -EDIF_TOK_DESIGNATOR, EDIF_TOK_PROPERTY, + EDIF_TOK_COMMENT, EDIF_TOK_USERDATA +}; + +static short f_InstanceBackAnnotate[] = { EDIF_TOK_INSTANCEREF, + -EDIF_TOK_DESIGNATOR, EDIF_TOK_TIMING, + EDIF_TOK_PROPERTY, EDIF_TOK_COMMENT +}; +static short f_InstanceGroup[] = { EDIF_TOK_INSTANCEREF }; + +static short f_InstanceMap[] = { EDIF_TOK_INSTANCEREF, EDIF_TOK_INSTANCEGROUP, + EDIF_TOK_COMMENT, EDIF_TOK_USERDATA +}; + +static short f_InstanceRef[] = { EDIF_TOK_NAME, EDIF_TOK_MEMBER, + EDIF_TOK_INSTANCEREF, EDIF_TOK_VIEWREF +}; +static short f_Integer[] = { EDIF_TOK_INTEGERDISPLAY, EDIF_TOK_INTEGER }; +static short f_IntegerDisplay[] = { EDIF_TOK_DISPLAY }; + +static short f_Interface[] = { EDIF_TOK_PORT, EDIF_TOK_PORTBUNDLE, + -EDIF_TOK_SYMBOL, -EDIF_TOK_PROTECTIONFRAME, + -EDIF_TOK_ARRAYRELATEDINFO, EDIF_TOK_PARAMETER, + EDIF_TOK_JOINED, EDIF_TOK_MUSTJOIN, + EDIF_TOK_WEAKJOINED, EDIF_TOK_PERMUTABLE, + EDIF_TOK_TIMING, EDIF_TOK_SIMULATE, + -EDIF_TOK_DESIGNATOR, EDIF_TOK_PROPERTY, + EDIF_TOK_COMMENT, EDIF_TOK_USERDATA +}; + +static short f_InterFigureGroupSpacing[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, + EDIF_TOK_FIGUREGROUPOBJECT, + EDIF_TOK_LESSTHAN, + EDIF_TOK_GREATERTHAN, + EDIF_TOK_ATMOST, + EDIF_TOK_ATLEAST, EDIF_TOK_EXACTLY, + EDIF_TOK_BETWEEN, + EDIF_TOK_SINGLEVALUESET, + EDIF_TOK_COMMENT, + EDIF_TOK_USERDATA +}; + +static short f_Intersection[] = { EDIF_TOK_FIGUREGROUPREF, + EDIF_TOK_INTERSECTION, EDIF_TOK_UNION, + EDIF_TOK_DIFFERENCE, EDIF_TOK_INVERSE, + EDIF_TOK_OVERSIZE +}; + +static short f_IntraFigureGroupSpacing[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, + EDIF_TOK_FIGUREGROUPOBJECT, + EDIF_TOK_LESSTHAN, + EDIF_TOK_GREATERTHAN, + EDIF_TOK_ATMOST, EDIF_TOK_ATLEAST, + EDIF_TOK_EXACTLY, EDIF_TOK_BETWEEN, + EDIF_TOK_SINGLEVALUESET, + EDIF_TOK_COMMENT, + EDIF_TOK_USERDATA +}; + +static short f_Inverse[] = { EDIF_TOK_FIGUREGROUPREF, EDIF_TOK_INTERSECTION, + EDIF_TOK_UNION, EDIF_TOK_DIFFERENCE, + EDIF_TOK_INVERSE, EDIF_TOK_OVERSIZE +}; + +static short f_Joined[] = { EDIF_TOK_PORTREF, EDIF_TOK_PORTLIST, + EDIF_TOK_GLOBALPORTREF +}; +static short f_KeywordDisplay[] = { EDIF_TOK_DISPLAY }; +static short f_KeywordMap[] = { EDIF_TOK_KEYWORDLEVEL, EDIF_TOK_COMMENT }; +static short f_LessThan[] = { EDIF_TOK_E }; + +static short f_Library[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_EDIFLEVEL, + EDIF_TOK_TECHNOLOGY, -EDIF_TOK_STATUS, + EDIF_TOK_CELL, EDIF_TOK_COMMENT, + EDIF_TOK_USERDATA +}; +static short f_LibraryRef[] = { EDIF_TOK_NAME }; +static short f_ListOfNets[] = { EDIF_TOK_NET }; +static short f_ListOfPorts[] = { EDIF_TOK_PORT, EDIF_TOK_PORTBUNDLE }; +static short f_LoadDelay[] = { EDIF_TOK_MNM, EDIF_TOK_E, EDIF_TOK_MINOMAXDISPLAY }; + +static short f_LogicAssign[] = { EDIF_TOK_NAME, EDIF_TOK_PORTREF, + EDIF_TOK_LOGICREF, EDIF_TOK_TABLE, + EDIF_TOK_DELAY, EDIF_TOK_LOADDELAY +}; + +static short f_LogicInput[] = { EDIF_TOK_PORTLIST, EDIF_TOK_PORTREF, + EDIF_TOK_NAME, EDIF_TOK_LOGICWAVEFORM +}; + +static short f_LogicList[] = { EDIF_TOK_NAME, EDIF_TOK_LOGICONEOF, + EDIF_TOK_IGNORE +}; +static short f_LogicMapInput[] = { EDIF_TOK_LOGICREF }; +static short f_LogicMapOutput[] = { EDIF_TOK_LOGICREF }; +static short f_LogicOneOf[] = { EDIF_TOK_NAME, EDIF_TOK_LOGICLIST }; + +static short f_LogicOutput[] = { EDIF_TOK_PORTLIST, EDIF_TOK_PORTREF, + EDIF_TOK_NAME, EDIF_TOK_LOGICWAVEFORM +}; + +static short f_LogicPort[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, + EDIF_TOK_PROPERTY, EDIF_TOK_COMMENT, + EDIF_TOK_USERDATA +}; +static short f_LogicRef[] = { EDIF_TOK_NAME, EDIF_TOK_LIBRARYREF }; + +static short f_LogicValue[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, + -EDIF_TOK_VOLTAGEMAP, -EDIF_TOK_CURRENTMAP, + -EDIF_TOK_BOOLEANMAP, -EDIF_TOK_COMPOUND, + -EDIF_TOK_WEAK, -EDIF_TOK_STRONG, + -EDIF_TOK_DOMINATES, -EDIF_TOK_LOGICMAPOUTPUT, + -EDIF_TOK_LOGICMAPINPUT, + -EDIF_TOK_ISOLATED, EDIF_TOK_RESOLVES, + EDIF_TOK_PROPERTY, EDIF_TOK_COMMENT, + EDIF_TOK_USERDATA +}; + +static short f_LogicWaveform[] = { EDIF_TOK_NAME, EDIF_TOK_LOGICLIST, + EDIF_TOK_LOGICONEOF, EDIF_TOK_IGNORE +}; + +static short f_Maintain[] = { EDIF_TOK_NAME, EDIF_TOK_PORTREF, EDIF_TOK_DELAY, + EDIF_TOK_LOADDELAY +}; + +static short f_Match[] = { EDIF_TOK_NAME, EDIF_TOK_PORTREF, EDIF_TOK_PORTLIST, + EDIF_TOK_LOGICLIST, EDIF_TOK_LOGICONEOF +}; +static short f_Member[] = { EDIF_TOK_NAME }; + +static short f_MiNoMax[] = { EDIF_TOK_MNM, EDIF_TOK_E, EDIF_TOK_MINOMAXDISPLAY, + EDIF_TOK_MINOMAX +}; +static short f_MiNoMaxDisplay[] = { EDIF_TOK_MNM, EDIF_TOK_E, EDIF_TOK_DISPLAY }; + +static short f_Mnm[] = { EDIF_TOK_E, EDIF_TOK_UNDEFINED, + EDIF_TOK_UNCONSTRAINED +}; +static short f_MultipleValueSet[] = { EDIF_TOK_RANGEVECTOR }; + +static short f_MustJoin[] = { EDIF_TOK_PORTREF, EDIF_TOK_PORTLIST, + EDIF_TOK_WEAKJOINED, EDIF_TOK_JOINED +}; +static short f_Name[] = { EDIF_TOK_DISPLAY }; + +static short f_Net[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, -EDIF_TOK_CRITICALITY, + EDIF_TOK_NETDELAY, EDIF_TOK_FIGURE, EDIF_TOK_NET, + EDIF_TOK_INSTANCE, EDIF_TOK_COMMENTGRAPHICS, + EDIF_TOK_PROPERTY, EDIF_TOK_COMMENT, + EDIF_TOK_USERDATA, EDIF_TOK_JOINED, EDIF_TOK_ARRAY +}; + +static short f_NetBackAnnotate[] = { EDIF_TOK_NETREF, EDIF_TOK_NETDELAY, + -EDIF_TOK_CRITICALITY, EDIF_TOK_PROPERTY, + EDIF_TOK_COMMENT +}; + +static short f_NetBundle[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_ARRAY, + EDIF_TOK_LISTOFNETS, EDIF_TOK_FIGURE, + EDIF_TOK_COMMENTGRAPHICS, EDIF_TOK_PROPERTY, + EDIF_TOK_COMMENT, EDIF_TOK_USERDATA +}; + +static short f_NetDelay[] = { EDIF_TOK_DERIVATION, EDIF_TOK_DELAY, + EDIF_TOK_TRANSITION, EDIF_TOK_BECOMES +}; +static short f_NetGroup[] = { EDIF_TOK_NAME, EDIF_TOK_MEMBER, EDIF_TOK_NETREF }; + +static short f_NetMap[] = { EDIF_TOK_NETREF, EDIF_TOK_NETGROUP, + EDIF_TOK_COMMENT, EDIF_TOK_USERDATA +}; + +static short f_NetRef[] = { EDIF_TOK_NAME, EDIF_TOK_MEMBER, EDIF_TOK_NETREF, + EDIF_TOK_INSTANCEREF, EDIF_TOK_VIEWREF +}; +static short f_NonPermutable[] = { EDIF_TOK_PORTREF, EDIF_TOK_PERMUTABLE }; + +static short f_NotAllowed[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, + EDIF_TOK_FIGUREGROUPOBJECT, EDIF_TOK_COMMENT, + EDIF_TOK_USERDATA +}; + +static short f_NotchSpacing[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, + EDIF_TOK_FIGUREGROUPOBJECT, EDIF_TOK_LESSTHAN, + EDIF_TOK_GREATERTHAN, EDIF_TOK_ATMOST, + EDIF_TOK_ATLEAST, EDIF_TOK_EXACTLY, + EDIF_TOK_BETWEEN, EDIF_TOK_SINGLEVALUESET, + EDIF_TOK_COMMENT, EDIF_TOK_USERDATA +}; +static short f_Number[] = { EDIF_TOK_E, EDIF_TOK_NUMBERDISPLAY, EDIF_TOK_NUMBER }; + +static short f_NumberDefinition[] = { EDIF_TOK_SCALE, -EDIF_TOK_GRIDMAP, + EDIF_TOK_COMMENT +}; +static short f_NumberDisplay[] = { EDIF_TOK_E, EDIF_TOK_DISPLAY }; + +static short f_OffPageConnector[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, + -EDIF_TOK_UNUSED, EDIF_TOK_PROPERTY, + EDIF_TOK_COMMENT, EDIF_TOK_USERDATA +}; +static short f_OffsetEvent[] = { EDIF_TOK_EVENT, EDIF_TOK_E }; +static short f_OpenShape[] = { EDIF_TOK_CURVE, EDIF_TOK_PROPERTY }; +static short f_Origin[] = { EDIF_TOK_PT }; + +static short f_OverhangDistance[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, + EDIF_TOK_FIGUREGROUPOBJECT, EDIF_TOK_LESSTHAN, + EDIF_TOK_GREATERTHAN, EDIF_TOK_ATMOST, + EDIF_TOK_ATLEAST, EDIF_TOK_EXACTLY, + EDIF_TOK_BETWEEN, EDIF_TOK_SINGLEVALUESET, + EDIF_TOK_COMMENT, EDIF_TOK_USERDATA +}; + +static short f_OverlapDistance[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, + EDIF_TOK_FIGUREGROUPOBJECT, EDIF_TOK_LESSTHAN, + EDIF_TOK_GREATERTHAN, EDIF_TOK_ATMOST, + EDIF_TOK_ATLEAST, EDIF_TOK_EXACTLY, + EDIF_TOK_BETWEEN, EDIF_TOK_SINGLEVALUESET, + EDIF_TOK_COMMENT, EDIF_TOK_USERDATA +}; + +static short f_Oversize[] = { EDIF_TOK_FIGUREGROUPREF, EDIF_TOK_INTERSECTION, + EDIF_TOK_UNION, EDIF_TOK_DIFFERENCE, + EDIF_TOK_INVERSE, EDIF_TOK_OVERSIZE, + EDIF_TOK_CORNERTYPE +}; + +static short f_Page[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_ARRAY, + EDIF_TOK_INSTANCE, EDIF_TOK_NET, EDIF_TOK_NETBUNDLE, + EDIF_TOK_COMMENTGRAPHICS, EDIF_TOK_PORTIMPLEMENTATION, + -EDIF_TOK_PAGESIZE, -EDIF_TOK_BOUNDINGBOX, + EDIF_TOK_COMMENT, EDIF_TOK_USERDATA +}; +static short f_PageSize[] = { EDIF_TOK_RECTANGLE }; + +static short f_Parameter[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_ARRAY, + EDIF_TOK_BOOLEAN, EDIF_TOK_INTEGER, + EDIF_TOK_MINOMAX, EDIF_TOK_NUMBER, + EDIF_TOK_POINT, EDIF_TOK_STRING +}; + +static short f_ParameterAssign[] = { EDIF_TOK_NAME, EDIF_TOK_MEMBER, + EDIF_TOK_BOOLEAN, EDIF_TOK_INTEGER, + EDIF_TOK_MINOMAX, EDIF_TOK_NUMBER, EDIF_TOK_POINT, + EDIF_TOK_STRING +}; + +static short f_ParameterDisplay[] = { EDIF_TOK_NAME, EDIF_TOK_MEMBER, + EDIF_TOK_DISPLAY +}; +static short f_Path[] = { EDIF_TOK_POINTLIST, EDIF_TOK_PROPERTY }; +static short f_PathDelay[] = { EDIF_TOK_DELAY, EDIF_TOK_EVENT }; + +static short f_Permutable[] = { EDIF_TOK_PORTREF, EDIF_TOK_PERMUTABLE, + EDIF_TOK_NONPERMUTABLE +}; + +static short f_PhysicalDesignRule[] = { EDIF_TOK_FIGUREWIDTH, + EDIF_TOK_FIGUREAREA, + EDIF_TOK_RECTANGLESIZE, + EDIF_TOK_FIGUREPERIMETER, + EDIF_TOK_OVERLAPDISTANCE, + EDIF_TOK_OVERHANGDISTANCE, + EDIF_TOK_ENCLOSUREDISTANCE, + EDIF_TOK_INTERFIGUREGROUPSPACING, + EDIF_TOK_NOTCHSPACING, + EDIF_TOK_INTRAFIGUREGROUPSPACING, + EDIF_TOK_NOTALLOWED, + EDIF_TOK_FIGUREGROUP, EDIF_TOK_COMMENT, + EDIF_TOK_USERDATA +}; +static short f_Plug[] = { EDIF_TOK_SOCKETSET }; + +static short f_Point[] = { EDIF_TOK_PT, EDIF_TOK_POINTDISPLAY, + EDIF_TOK_POINT +}; +static short f_PointDisplay[] = { EDIF_TOK_PT, EDIF_TOK_DISPLAY }; +static short f_PointList[] = { EDIF_TOK_PT }; +static short f_Polygon[] = { EDIF_TOK_POINTLIST, EDIF_TOK_PROPERTY }; + +static short f_Port[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_ARRAY, + -EDIF_TOK_DIRECTION, -EDIF_TOK_UNUSED, + EDIF_TOK_PORTDELAY, -EDIF_TOK_DESIGNATOR, + -EDIF_TOK_DCFANINLOAD, -EDIF_TOK_DCFANOUTLOAD, + -EDIF_TOK_DCMAXFANIN, -EDIF_TOK_DCMAXFANOUT, + -EDIF_TOK_ACLOAD, EDIF_TOK_PROPERTY, + EDIF_TOK_COMMENT, EDIF_TOK_USERDATA +}; + +static short f_PortBackAnnotate[] = { EDIF_TOK_PORTREF, -EDIF_TOK_DESIGNATOR, + EDIF_TOK_PORTDELAY, -EDIF_TOK_DCFANINLOAD, + -EDIF_TOK_DCFANOUTLOAD, + -EDIF_TOK_DCMAXFANIN, + -EDIF_TOK_DCMAXFANOUT, -EDIF_TOK_ACLOAD, + EDIF_TOK_PROPERTY, EDIF_TOK_COMMENT +}; + +static short f_PortBundle[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_ARRAY, + EDIF_TOK_LISTOFPORTS, EDIF_TOK_PROPERTY, + EDIF_TOK_COMMENT, EDIF_TOK_USERDATA +}; + +static short f_PortDelay[] = { EDIF_TOK_DERIVATION, EDIF_TOK_DELAY, + EDIF_TOK_LOADDELAY, EDIF_TOK_TRANSITION, + EDIF_TOK_BECOMES +}; + +static short f_PortGroup[] = { EDIF_TOK_NAME, EDIF_TOK_MEMBER, + EDIF_TOK_PORTREF +}; + +static short f_PortImplementation[] = { EDIF_TOK_PORTREF, EDIF_TOK_NAME, EDIF_TOK_MEMBER, + -EDIF_TOK_CONNECTLOCATION, + EDIF_TOK_FIGURE, EDIF_TOK_INSTANCE, + EDIF_TOK_COMMENTGRAPHICS, + EDIF_TOK_PROPERTYDISPLAY, + EDIF_TOK_KEYWORDDISPLAY, + EDIF_TOK_PROPERTY, + EDIF_TOK_USERDATA, EDIF_TOK_COMMENT +}; + +static short f_PortInstance[] = { EDIF_TOK_PORTREF, EDIF_TOK_NAME, + EDIF_TOK_MEMBER, -EDIF_TOK_UNUSED, + EDIF_TOK_PORTDELAY, -EDIF_TOK_DESIGNATOR, + -EDIF_TOK_DCFANINLOAD, + -EDIF_TOK_DCFANOUTLOAD, -EDIF_TOK_DCMAXFANIN, + -EDIF_TOK_DCMAXFANOUT, -EDIF_TOK_ACLOAD, + EDIF_TOK_PROPERTY, EDIF_TOK_COMMENT, + EDIF_TOK_USERDATA +}; + +static short f_PortList[] = { EDIF_TOK_PORTREF, EDIF_TOK_NAME, + EDIF_TOK_MEMBER +}; + +static short f_PortListAlias[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, + EDIF_TOK_ARRAY, EDIF_TOK_PORTLIST +}; + +static short f_PortMap[] = { EDIF_TOK_PORTREF, EDIF_TOK_PORTGROUP, + EDIF_TOK_COMMENT, EDIF_TOK_USERDATA +}; + +static short f_PortRef[] = { EDIF_TOK_NAME, EDIF_TOK_MEMBER, + EDIF_TOK_PORTREF, EDIF_TOK_INSTANCEREF, + EDIF_TOK_VIEWREF +}; +static short f_Program[] = { EDIF_TOK_VERSION }; + +static short f_Property[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_BOOLEAN, + EDIF_TOK_INTEGER, EDIF_TOK_MINOMAX, + EDIF_TOK_NUMBER, EDIF_TOK_POINT, EDIF_TOK_STRING, + -EDIF_TOK_OWNER, -EDIF_TOK_UNIT, + EDIF_TOK_PROPERTY, EDIF_TOK_COMMENT +}; +static short f_PropertyDisplay[] = { EDIF_TOK_NAME, EDIF_TOK_DISPLAY }; + +static short f_ProtectionFrame[] = { EDIF_TOK_PORTIMPLEMENTATION, + EDIF_TOK_FIGURE, EDIF_TOK_INSTANCE, + EDIF_TOK_COMMENTGRAPHICS, + -EDIF_TOK_BOUNDINGBOX, + EDIF_TOK_PROPERTYDISPLAY, + EDIF_TOK_KEYWORDDISPLAY, + EDIF_TOK_PARAMETERDISPLAY, + EDIF_TOK_PROPERTY, EDIF_TOK_COMMENT, + EDIF_TOK_USERDATA +}; + +static short f_RangeVector[] = { EDIF_TOK_LESSTHAN, EDIF_TOK_GREATERTHAN, + EDIF_TOK_ATMOST, EDIF_TOK_ATLEAST, + EDIF_TOK_EXACTLY, EDIF_TOK_BETWEEN, + EDIF_TOK_SINGLEVALUESET +}; +static short f_Rectangle[] = { EDIF_TOK_PT, EDIF_TOK_PROPERTY }; + +static short f_RectangleSize[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, + EDIF_TOK_FIGUREGROUPOBJECT, + EDIF_TOK_RANGEVECTOR, + EDIF_TOK_MULTIPLEVALUESET, EDIF_TOK_COMMENT, + EDIF_TOK_USERDATA +}; +static short f_Rename[] = { EDIF_TOK_NAME, EDIF_TOK_STRINGDISPLAY }; +static short f_Resolves[] = { EDIF_TOK_NAME }; +static short f_Scale[] = { EDIF_TOK_E, EDIF_TOK_UNIT }; +static short f_Section[] = { EDIF_TOK_SECTION, EDIF_TOK_INSTANCE }; +static short f_Shape[] = { EDIF_TOK_CURVE, EDIF_TOK_PROPERTY }; + +static short f_Simulate[] = { EDIF_TOK_NAME, EDIF_TOK_PORTLISTALIAS, + EDIF_TOK_WAVEVALUE, EDIF_TOK_APPLY, + EDIF_TOK_COMMENT, EDIF_TOK_USERDATA +}; + +static short f_SimulationInfo[] = { EDIF_TOK_LOGICVALUE, EDIF_TOK_COMMENT, + EDIF_TOK_USERDATA +}; + +static short f_SingleValueSet[] = { EDIF_TOK_LESSTHAN, EDIF_TOK_GREATERTHAN, + EDIF_TOK_ATMOST, EDIF_TOK_ATLEAST, + EDIF_TOK_EXACTLY, EDIF_TOK_BETWEEN +}; +static short f_Site[] = { EDIF_TOK_VIEWREF, EDIF_TOK_TRANSFORM }; +static short f_Socket[] = { EDIF_TOK_SYMMETRY }; +static short f_SocketSet[] = { EDIF_TOK_SYMMETRY, EDIF_TOK_SITE }; + +static short f_Status[] = { EDIF_TOK_WRITTEN, EDIF_TOK_COMMENT, + EDIF_TOK_USERDATA +}; + +static short f_Steady[] = { EDIF_TOK_NAME, EDIF_TOK_MEMBER, EDIF_TOK_PORTREF, + EDIF_TOK_PORTLIST, EDIF_TOK_DURATION, + EDIF_TOK_TRANSITION, EDIF_TOK_BECOMES +}; +static short f_String[] = { EDIF_TOK_STRINGDISPLAY, EDIF_TOK_STRING }; +static short f_StringDisplay[] = { EDIF_TOK_DISPLAY }; +static short f_Strong[] = { EDIF_TOK_NAME }; + +static short f_Symbol[] = { EDIF_TOK_PORTIMPLEMENTATION, EDIF_TOK_FIGURE, + EDIF_TOK_INSTANCE, EDIF_TOK_COMMENTGRAPHICS, + EDIF_TOK_ANNOTATE, -EDIF_TOK_PAGESIZE, + -EDIF_TOK_BOUNDINGBOX, EDIF_TOK_PROPERTYDISPLAY, + EDIF_TOK_KEYWORDDISPLAY, EDIF_TOK_PARAMETERDISPLAY, + EDIF_TOK_PROPERTY, EDIF_TOK_COMMENT, + EDIF_TOK_USERDATA +}; +static short f_Symmetry[] = { EDIF_TOK_TRANSFORM }; +static short f_Table[] = { EDIF_TOK_ENTRY, EDIF_TOK_TABLEDEFAULT }; + +static short f_TableDefault[] = { EDIF_TOK_LOGICREF, EDIF_TOK_PORTREF, + EDIF_TOK_NOCHANGE, EDIF_TOK_TABLE, + EDIF_TOK_DELAY, EDIF_TOK_LOADDELAY +}; + +static short f_Technology[] = { EDIF_TOK_NUMBERDEFINITION, EDIF_TOK_FIGUREGROUP, + EDIF_TOK_FABRICATE, -EDIF_TOK_SIMULATIONINFO, + EDIF_TOK_COMMENT, EDIF_TOK_USERDATA, + -EDIF_TOK_PHYSICALDESIGNRULE +}; + +static short f_TimeInterval[] = { EDIF_TOK_EVENT, EDIF_TOK_OFFSETEVENT, + EDIF_TOK_DURATION +}; + +static short f_Timing[] = { EDIF_TOK_DERIVATION, EDIF_TOK_PATHDELAY, + EDIF_TOK_FORBIDDENEVENT, EDIF_TOK_COMMENT, + EDIF_TOK_USERDATA +}; + +static short f_Transform[] = { EDIF_TOK_SCALEX, EDIF_TOK_SCALEY, EDIF_TOK_DELTA, + EDIF_TOK_ORIENTATION, EDIF_TOK_ORIGIN +}; + +static short f_Transition[] = { EDIF_TOK_NAME, EDIF_TOK_LOGICLIST, + EDIF_TOK_LOGICONEOF +}; + +static short f_Trigger[] = { EDIF_TOK_CHANGE, EDIF_TOK_STEADY, + EDIF_TOK_INITIAL +}; + +static short f_Union[] = { EDIF_TOK_FIGUREGROUPREF, EDIF_TOK_INTERSECTION, + EDIF_TOK_UNION, EDIF_TOK_DIFFERENCE, + EDIF_TOK_INVERSE, EDIF_TOK_OVERSIZE +}; + +static short f_View[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_VIEWTYPE, + EDIF_TOK_INTERFACE, -EDIF_TOK_STATUS, + -EDIF_TOK_CONTENTS, EDIF_TOK_COMMENT, + EDIF_TOK_PROPERTY, EDIF_TOK_USERDATA +}; +static short f_ViewList[] = { EDIF_TOK_VIEWREF, EDIF_TOK_VIEWLIST }; + +static short f_ViewMap[] = { EDIF_TOK_PORTMAP, EDIF_TOK_PORTBACKANNOTATE, + EDIF_TOK_INSTANCEMAP, + EDIF_TOK_INSTANCEBACKANNOTATE, EDIF_TOK_NETMAP, + EDIF_TOK_NETBACKANNOTATE, EDIF_TOK_COMMENT, + EDIF_TOK_USERDATA +}; +static short f_ViewRef[] = { EDIF_TOK_NAME, EDIF_TOK_CELLREF }; +static short f_Visible[] = { EDIF_TOK_FALSE, EDIF_TOK_TRUE }; +static short f_VoltageMap[] = { EDIF_TOK_MNM, EDIF_TOK_E }; + +static short f_WaveValue[] = { EDIF_TOK_NAME, EDIF_TOK_RENAME, EDIF_TOK_E, + EDIF_TOK_LOGICWAVEFORM +}; +static short f_Weak[] = { EDIF_TOK_NAME }; + +static short f_WeakJoined[] = { EDIF_TOK_PORTREF, EDIF_TOK_PORTLIST, + EDIF_TOK_JOINED +}; + +static short f_When[] = { EDIF_TOK_TRIGGER, EDIF_TOK_AFTER, + EDIF_TOK_FOLLOW, EDIF_TOK_MAINTAIN, + EDIF_TOK_LOGICASSIGN, EDIF_TOK_COMMENT, + EDIF_TOK_USERDATA +}; + +static short f_Written[] = { EDIF_TOK_TIMESTAMP, EDIF_TOK_AUTHOR, + EDIF_TOK_PROGRAM, EDIF_TOK_DATAORIGIN, + EDIF_TOK_PROPERTY, EDIF_TOK_COMMENT, + EDIF_TOK_USERDATA +}; + /* * Context binding table: * @@ -6290,210 +6698,211 @@ * This binds context follower arrays to their originating context. */ typedef struct Binder { - short *Follower; /* pointer to follower array */ - short Origin; /* '%token' value of origin */ - short FollowerSize; /* size of follower array */ + short *Follower; /* pointer to follower array */ + short Origin; /* '%token' value of origin */ + short FollowerSize; /* size of follower array */ } Binder; #define BE(f,o) {f,o,sizeof(f)/sizeof(short)} static Binder BinderDef[] = { - BE(f_NULL, 0), - BE(f_Edif, EDIF_TOK_EDIF), - BE(f_AcLoad, EDIF_TOK_ACLOAD), - BE(f_After, EDIF_TOK_AFTER), - BE(f_Annotate, EDIF_TOK_ANNOTATE), - BE(f_Apply, EDIF_TOK_APPLY), - BE(f_Arc, EDIF_TOK_ARC), - BE(f_Array, EDIF_TOK_ARRAY), - BE(f_ArrayMacro, EDIF_TOK_ARRAYMACRO), - BE(f_ArrayRelatedInfo, EDIF_TOK_ARRAYRELATEDINFO), - BE(f_ArraySite, EDIF_TOK_ARRAYSITE), - BE(f_AtLeast, EDIF_TOK_ATLEAST), - BE(f_AtMost, EDIF_TOK_ATMOST), - BE(f_Becomes, EDIF_TOK_BECOMES), - BE(f_Boolean, EDIF_TOK_BOOLEAN), - BE(f_BooleanDisplay, EDIF_TOK_BOOLEANDISPLAY), - BE(f_BooleanMap, EDIF_TOK_BOOLEANMAP), - BE(f_BorderPattern, EDIF_TOK_BORDERPATTERN), - BE(f_BoundingBox, EDIF_TOK_BOUNDINGBOX), - BE(f_Cell, EDIF_TOK_CELL), - BE(f_CellRef, EDIF_TOK_CELLREF), - BE(f_Change, EDIF_TOK_CHANGE), - BE(f_Circle, EDIF_TOK_CIRCLE), - BE(f_Color, EDIF_TOK_COLOR), - BE(f_CommentGraphics, EDIF_TOK_COMMENTGRAPHICS), - BE(f_Compound, EDIF_TOK_COMPOUND), - BE(f_ConnectLocation, EDIF_TOK_CONNECTLOCATION), - BE(f_Contents, EDIF_TOK_CONTENTS), - BE(f_Criticality, EDIF_TOK_CRITICALITY), - BE(f_CurrentMap, EDIF_TOK_CURRENTMAP), - BE(f_Curve, EDIF_TOK_CURVE), - BE(f_Cycle, EDIF_TOK_CYCLE), - BE(f_DataOrigin, EDIF_TOK_DATAORIGIN), - BE(f_DcFanInLoad, EDIF_TOK_DCFANINLOAD), - BE(f_DcFanOutLoad, EDIF_TOK_DCFANOUTLOAD), - BE(f_DcMaxFanIn, EDIF_TOK_DCMAXFANIN), - BE(f_DcMaxFanOut, EDIF_TOK_DCMAXFANOUT), - BE(f_Delay, EDIF_TOK_DELAY), - BE(f_Delta, EDIF_TOK_DELTA), - BE(f_Design, EDIF_TOK_DESIGN), - BE(f_Designator, EDIF_TOK_DESIGNATOR), - BE(f_Difference, EDIF_TOK_DIFFERENCE), - BE(f_Display, EDIF_TOK_DISPLAY), - BE(f_Dominates, EDIF_TOK_DOMINATES), - BE(f_Dot, EDIF_TOK_DOT), - BE(f_Duration, EDIF_TOK_DURATION), - BE(f_EnclosureDistance, EDIF_TOK_ENCLOSUREDISTANCE), - BE(f_Entry, EDIF_TOK_ENTRY), - BE(f_Exactly, EDIF_TOK_EXACTLY), - BE(f_External, EDIF_TOK_EXTERNAL), - BE(f_Fabricate, EDIF_TOK_FABRICATE), - BE(f_Figure, EDIF_TOK_FIGURE), - BE(f_FigureArea, EDIF_TOK_FIGUREAREA), - BE(f_FigureGroup, EDIF_TOK_FIGUREGROUP), - BE(f_FigureGroupObject, EDIF_TOK_FIGUREGROUPOBJECT), - BE(f_FigureGroupOverride, EDIF_TOK_FIGUREGROUPOVERRIDE), - BE(f_FigureGroupRef, EDIF_TOK_FIGUREGROUPREF), - BE(f_FigurePerimeter, EDIF_TOK_FIGUREPERIMETER), - BE(f_FigureWidth, EDIF_TOK_FIGUREWIDTH), - BE(f_FillPattern, EDIF_TOK_FILLPATTERN), - BE(f_Follow, EDIF_TOK_FOLLOW), - BE(f_ForbiddenEvent, EDIF_TOK_FORBIDDENEVENT), - BE(f_GlobalPortRef, EDIF_TOK_GLOBALPORTREF), - BE(f_GreaterThan, EDIF_TOK_GREATERTHAN), - BE(f_GridMap, EDIF_TOK_GRIDMAP), - BE(f_IncludeFigureGroup, EDIF_TOK_INCLUDEFIGUREGROUP), - BE(f_Instance, EDIF_TOK_INSTANCE), - BE(f_InstanceBackAnnotate, EDIF_TOK_INSTANCEBACKANNOTATE), - BE(f_InstanceGroup, EDIF_TOK_INSTANCEGROUP), - BE(f_InstanceMap, EDIF_TOK_INSTANCEMAP), - BE(f_InstanceRef, EDIF_TOK_INSTANCEREF), - BE(f_Integer, EDIF_TOK_INTEGER), - BE(f_IntegerDisplay, EDIF_TOK_INTEGERDISPLAY), - BE(f_InterFigureGroupSpacing, EDIF_TOK_INTERFIGUREGROUPSPACING), - BE(f_Interface, EDIF_TOK_INTERFACE), - BE(f_Intersection, EDIF_TOK_INTERSECTION), - BE(f_IntraFigureGroupSpacing, EDIF_TOK_INTRAFIGUREGROUPSPACING), - BE(f_Inverse, EDIF_TOK_INVERSE), - BE(f_Joined, EDIF_TOK_JOINED), - BE(f_KeywordDisplay, EDIF_TOK_KEYWORDDISPLAY), - BE(f_KeywordMap, EDIF_TOK_KEYWORDMAP), - BE(f_LessThan, EDIF_TOK_LESSTHAN), - BE(f_Library, EDIF_TOK_LIBRARY), - BE(f_LibraryRef, EDIF_TOK_LIBRARYREF), - BE(f_ListOfNets, EDIF_TOK_LISTOFNETS), - BE(f_ListOfPorts, EDIF_TOK_LISTOFPORTS), - BE(f_LoadDelay, EDIF_TOK_LOADDELAY), - BE(f_LogicAssign, EDIF_TOK_LOGICASSIGN), - BE(f_LogicInput, EDIF_TOK_LOGICINPUT), - BE(f_LogicList, EDIF_TOK_LOGICLIST), - BE(f_LogicMapInput, EDIF_TOK_LOGICMAPINPUT), - BE(f_LogicMapOutput, EDIF_TOK_LOGICMAPOUTPUT), - BE(f_LogicOneOf, EDIF_TOK_LOGICONEOF), - BE(f_LogicOutput, EDIF_TOK_LOGICOUTPUT), - BE(f_LogicPort, EDIF_TOK_LOGICPORT), - BE(f_LogicRef, EDIF_TOK_LOGICREF), - BE(f_LogicValue, EDIF_TOK_LOGICVALUE), - BE(f_LogicWaveform, EDIF_TOK_LOGICWAVEFORM), - BE(f_Maintain, EDIF_TOK_MAINTAIN), - BE(f_Match, EDIF_TOK_MATCH), - BE(f_Member, EDIF_TOK_MEMBER), - BE(f_MiNoMax, EDIF_TOK_MINOMAX), - BE(f_MiNoMaxDisplay, EDIF_TOK_MINOMAXDISPLAY), - BE(f_Mnm, EDIF_TOK_MNM), - BE(f_MultipleValueSet, EDIF_TOK_MULTIPLEVALUESET), - BE(f_MustJoin, EDIF_TOK_MUSTJOIN), - BE(f_Name, EDIF_TOK_NAME), - BE(f_Net, EDIF_TOK_NET), - BE(f_NetBackAnnotate, EDIF_TOK_NETBACKANNOTATE), - BE(f_NetBundle, EDIF_TOK_NETBUNDLE), - BE(f_NetDelay, EDIF_TOK_NETDELAY), - BE(f_NetGroup, EDIF_TOK_NETGROUP), - BE(f_NetMap, EDIF_TOK_NETMAP), - BE(f_NetRef, EDIF_TOK_NETREF), - BE(f_NonPermutable, EDIF_TOK_NONPERMUTABLE), - BE(f_NotAllowed, EDIF_TOK_NOTALLOWED), - BE(f_NotchSpacing, EDIF_TOK_NOTCHSPACING), - BE(f_Number, EDIF_TOK_NUMBER), - BE(f_NumberDefinition, EDIF_TOK_NUMBERDEFINITION), - BE(f_NumberDisplay, EDIF_TOK_NUMBERDISPLAY), - BE(f_OffPageConnector, EDIF_TOK_OFFPAGECONNECTOR), - BE(f_OffsetEvent, EDIF_TOK_OFFSETEVENT), - BE(f_OpenShape, EDIF_TOK_OPENSHAPE), - BE(f_Origin, EDIF_TOK_ORIGIN), - BE(f_OverhangDistance, EDIF_TOK_OVERHANGDISTANCE), - BE(f_OverlapDistance, EDIF_TOK_OVERLAPDISTANCE), - BE(f_Oversize, EDIF_TOK_OVERSIZE), - BE(f_Page, EDIF_TOK_PAGE), - BE(f_PageSize, EDIF_TOK_PAGESIZE), - BE(f_Parameter, EDIF_TOK_PARAMETER), - BE(f_ParameterAssign, EDIF_TOK_PARAMETERASSIGN), - BE(f_ParameterDisplay, EDIF_TOK_PARAMETERDISPLAY), - BE(f_Path, EDIF_TOK_PATH), - BE(f_PathDelay, EDIF_TOK_PATHDELAY), - BE(f_Permutable, EDIF_TOK_PERMUTABLE), - BE(f_PhysicalDesignRule, EDIF_TOK_PHYSICALDESIGNRULE), - BE(f_Plug, EDIF_TOK_PLUG), - BE(f_Point, EDIF_TOK_POINT), - BE(f_PointDisplay, EDIF_TOK_POINTDISPLAY), - BE(f_PointList, EDIF_TOK_POINTLIST), - BE(f_Polygon, EDIF_TOK_POLYGON), - BE(f_Port, EDIF_TOK_PORT), - BE(f_PortBackAnnotate, EDIF_TOK_PORTBACKANNOTATE), - BE(f_PortBundle, EDIF_TOK_PORTBUNDLE), - BE(f_PortDelay, EDIF_TOK_PORTDELAY), - BE(f_PortGroup, EDIF_TOK_PORTGROUP), - BE(f_PortImplementation, EDIF_TOK_PORTIMPLEMENTATION), - BE(f_PortInstance, EDIF_TOK_PORTINSTANCE), - BE(f_PortList, EDIF_TOK_PORTLIST), - BE(f_PortListAlias, EDIF_TOK_PORTLISTALIAS), - BE(f_PortMap, EDIF_TOK_PORTMAP), - BE(f_PortRef, EDIF_TOK_PORTREF), - BE(f_Program, EDIF_TOK_PROGRAM), - BE(f_Property, EDIF_TOK_PROPERTY), - BE(f_PropertyDisplay, EDIF_TOK_PROPERTYDISPLAY), - BE(f_ProtectionFrame, EDIF_TOK_PROTECTIONFRAME), - BE(f_RangeVector, EDIF_TOK_RANGEVECTOR), - BE(f_Rectangle, EDIF_TOK_RECTANGLE), - BE(f_RectangleSize, EDIF_TOK_RECTANGLESIZE), - BE(f_Rename, EDIF_TOK_RENAME), - BE(f_Resolves, EDIF_TOK_RESOLVES), - BE(f_Scale, EDIF_TOK_SCALE), - BE(f_Section, EDIF_TOK_SECTION), - BE(f_Shape, EDIF_TOK_SHAPE), - BE(f_Simulate, EDIF_TOK_SIMULATE), - BE(f_SimulationInfo, EDIF_TOK_SIMULATIONINFO), - BE(f_SingleValueSet, EDIF_TOK_SINGLEVALUESET), - BE(f_Site, EDIF_TOK_SITE), - BE(f_Socket, EDIF_TOK_SOCKET), - BE(f_SocketSet, EDIF_TOK_SOCKETSET), - BE(f_Status, EDIF_TOK_STATUS), - BE(f_Steady, EDIF_TOK_STEADY), - BE(f_String, EDIF_TOK_STRING), - BE(f_StringDisplay, EDIF_TOK_STRINGDISPLAY), - BE(f_Strong, EDIF_TOK_STRONG), - BE(f_Symbol, EDIF_TOK_SYMBOL), - BE(f_Symmetry, EDIF_TOK_SYMMETRY), - BE(f_Table, EDIF_TOK_TABLE), - BE(f_TableDefault, EDIF_TOK_TABLEDEFAULT), - BE(f_Technology, EDIF_TOK_TECHNOLOGY), - BE(f_TimeInterval, EDIF_TOK_TIMEINTERVAL), - BE(f_Timing, EDIF_TOK_TIMING), - BE(f_Transform, EDIF_TOK_TRANSFORM), - BE(f_Transition, EDIF_TOK_TRANSITION), - BE(f_Trigger, EDIF_TOK_TRIGGER), - BE(f_Union, EDIF_TOK_UNION), - BE(f_View, EDIF_TOK_VIEW), - BE(f_ViewList, EDIF_TOK_VIEWLIST), - BE(f_ViewMap, EDIF_TOK_VIEWMAP), - BE(f_ViewRef, EDIF_TOK_VIEWREF), - BE(f_Visible, EDIF_TOK_VISIBLE), - BE(f_VoltageMap, EDIF_TOK_VOLTAGEMAP), - BE(f_WaveValue, EDIF_TOK_WAVEVALUE), - BE(f_Weak, EDIF_TOK_WEAK), - BE(f_WeakJoined, EDIF_TOK_WEAKJOINED), - BE(f_When, EDIF_TOK_WHEN), - BE(f_Written, EDIF_TOK_WRITTEN) + BE(f_NULL, 0), + BE(f_Edif, EDIF_TOK_EDIF), + BE(f_AcLoad, EDIF_TOK_ACLOAD), + BE(f_After, EDIF_TOK_AFTER), + BE(f_Annotate, EDIF_TOK_ANNOTATE), + BE(f_Apply, EDIF_TOK_APPLY), + BE(f_Arc, EDIF_TOK_ARC), + BE(f_Array, EDIF_TOK_ARRAY), + BE(f_ArrayMacro, EDIF_TOK_ARRAYMACRO), + BE(f_ArrayRelatedInfo, EDIF_TOK_ARRAYRELATEDINFO), + BE(f_ArraySite, EDIF_TOK_ARRAYSITE), + BE(f_AtLeast, EDIF_TOK_ATLEAST), + BE(f_AtMost, EDIF_TOK_ATMOST), + BE(f_Becomes, EDIF_TOK_BECOMES), + BE(f_Boolean, EDIF_TOK_BOOLEAN), + BE(f_BooleanDisplay, EDIF_TOK_BOOLEANDISPLAY), + BE(f_BooleanMap, EDIF_TOK_BOOLEANMAP), + BE(f_BorderPattern, EDIF_TOK_BORDERPATTERN), + BE(f_BoundingBox, EDIF_TOK_BOUNDINGBOX), + BE(f_Cell, EDIF_TOK_CELL), + BE(f_CellRef, EDIF_TOK_CELLREF), + BE(f_Change, EDIF_TOK_CHANGE), + BE(f_Circle, EDIF_TOK_CIRCLE), + BE(f_Color, EDIF_TOK_COLOR), + BE(f_CommentGraphics, EDIF_TOK_COMMENTGRAPHICS), + BE(f_Compound, EDIF_TOK_COMPOUND), + BE(f_ConnectLocation, EDIF_TOK_CONNECTLOCATION), + BE(f_Contents, EDIF_TOK_CONTENTS), + BE(f_Criticality, EDIF_TOK_CRITICALITY), + BE(f_CurrentMap, EDIF_TOK_CURRENTMAP), + BE(f_Curve, EDIF_TOK_CURVE), + BE(f_Cycle, EDIF_TOK_CYCLE), + BE(f_DataOrigin, EDIF_TOK_DATAORIGIN), + BE(f_DcFanInLoad, EDIF_TOK_DCFANINLOAD), + BE(f_DcFanOutLoad, EDIF_TOK_DCFANOUTLOAD), + BE(f_DcMaxFanIn, EDIF_TOK_DCMAXFANIN), + BE(f_DcMaxFanOut, EDIF_TOK_DCMAXFANOUT), + BE(f_Delay, EDIF_TOK_DELAY), + BE(f_Delta, EDIF_TOK_DELTA), + BE(f_Design, EDIF_TOK_DESIGN), + BE(f_Designator, EDIF_TOK_DESIGNATOR), + BE(f_Difference, EDIF_TOK_DIFFERENCE), + BE(f_Display, EDIF_TOK_DISPLAY), + BE(f_Dominates, EDIF_TOK_DOMINATES), + BE(f_Dot, EDIF_TOK_DOT), + BE(f_Duration, EDIF_TOK_DURATION), + BE(f_EnclosureDistance, EDIF_TOK_ENCLOSUREDISTANCE), + BE(f_Entry, EDIF_TOK_ENTRY), + BE(f_Exactly, EDIF_TOK_EXACTLY), + BE(f_External, EDIF_TOK_EXTERNAL), + BE(f_Fabricate, EDIF_TOK_FABRICATE), + BE(f_Figure, EDIF_TOK_FIGURE), + BE(f_FigureArea, EDIF_TOK_FIGUREAREA), + BE(f_FigureGroup, EDIF_TOK_FIGUREGROUP), + BE(f_FigureGroupObject, EDIF_TOK_FIGUREGROUPOBJECT), + BE(f_FigureGroupOverride, EDIF_TOK_FIGUREGROUPOVERRIDE), + BE(f_FigureGroupRef, EDIF_TOK_FIGUREGROUPREF), + BE(f_FigurePerimeter, EDIF_TOK_FIGUREPERIMETER), + BE(f_FigureWidth, EDIF_TOK_FIGUREWIDTH), + BE(f_FillPattern, EDIF_TOK_FILLPATTERN), + BE(f_Follow, EDIF_TOK_FOLLOW), + BE(f_ForbiddenEvent, EDIF_TOK_FORBIDDENEVENT), + BE(f_GlobalPortRef, EDIF_TOK_GLOBALPORTREF), + BE(f_GreaterThan, EDIF_TOK_GREATERTHAN), + BE(f_GridMap, EDIF_TOK_GRIDMAP), + BE(f_IncludeFigureGroup, EDIF_TOK_INCLUDEFIGUREGROUP), + BE(f_Instance, EDIF_TOK_INSTANCE), + BE(f_InstanceBackAnnotate, EDIF_TOK_INSTANCEBACKANNOTATE), + BE(f_InstanceGroup, EDIF_TOK_INSTANCEGROUP), + BE(f_InstanceMap, EDIF_TOK_INSTANCEMAP), + BE(f_InstanceRef, EDIF_TOK_INSTANCEREF), + BE(f_Integer, EDIF_TOK_INTEGER), + BE(f_IntegerDisplay, EDIF_TOK_INTEGERDISPLAY), + BE(f_InterFigureGroupSpacing, EDIF_TOK_INTERFIGUREGROUPSPACING), + BE(f_Interface, EDIF_TOK_INTERFACE), + BE(f_Intersection, EDIF_TOK_INTERSECTION), + BE(f_IntraFigureGroupSpacing, EDIF_TOK_INTRAFIGUREGROUPSPACING), + BE(f_Inverse, EDIF_TOK_INVERSE), + BE(f_Joined, EDIF_TOK_JOINED), + BE(f_KeywordDisplay, EDIF_TOK_KEYWORDDISPLAY), + BE(f_KeywordMap, EDIF_TOK_KEYWORDMAP), + BE(f_LessThan, EDIF_TOK_LESSTHAN), + BE(f_Library, EDIF_TOK_LIBRARY), + BE(f_LibraryRef, EDIF_TOK_LIBRARYREF), + BE(f_ListOfNets, EDIF_TOK_LISTOFNETS), + BE(f_ListOfPorts, EDIF_TOK_LISTOFPORTS), + BE(f_LoadDelay, EDIF_TOK_LOADDELAY), + BE(f_LogicAssign, EDIF_TOK_LOGICASSIGN), + BE(f_LogicInput, EDIF_TOK_LOGICINPUT), + BE(f_LogicList, EDIF_TOK_LOGICLIST), + BE(f_LogicMapInput, EDIF_TOK_LOGICMAPINPUT), + BE(f_LogicMapOutput, EDIF_TOK_LOGICMAPOUTPUT), + BE(f_LogicOneOf, EDIF_TOK_LOGICONEOF), + BE(f_LogicOutput, EDIF_TOK_LOGICOUTPUT), + BE(f_LogicPort, EDIF_TOK_LOGICPORT), + BE(f_LogicRef, EDIF_TOK_LOGICREF), + BE(f_LogicValue, EDIF_TOK_LOGICVALUE), + BE(f_LogicWaveform, EDIF_TOK_LOGICWAVEFORM), + BE(f_Maintain, EDIF_TOK_MAINTAIN), + BE(f_Match, EDIF_TOK_MATCH), + BE(f_Member, EDIF_TOK_MEMBER), + BE(f_MiNoMax, EDIF_TOK_MINOMAX), + BE(f_MiNoMaxDisplay, EDIF_TOK_MINOMAXDISPLAY), + BE(f_Mnm, EDIF_TOK_MNM), + BE(f_MultipleValueSet, EDIF_TOK_MULTIPLEVALUESET), + BE(f_MustJoin, EDIF_TOK_MUSTJOIN), + BE(f_Name, EDIF_TOK_NAME), + BE(f_Net, EDIF_TOK_NET), + BE(f_NetBackAnnotate, EDIF_TOK_NETBACKANNOTATE), + BE(f_NetBundle, EDIF_TOK_NETBUNDLE), + BE(f_NetDelay, EDIF_TOK_NETDELAY), + BE(f_NetGroup, EDIF_TOK_NETGROUP), + BE(f_NetMap, EDIF_TOK_NETMAP), + BE(f_NetRef, EDIF_TOK_NETREF), + BE(f_NonPermutable, EDIF_TOK_NONPERMUTABLE), + BE(f_NotAllowed, EDIF_TOK_NOTALLOWED), + BE(f_NotchSpacing, EDIF_TOK_NOTCHSPACING), + BE(f_Number, EDIF_TOK_NUMBER), + BE(f_NumberDefinition, EDIF_TOK_NUMBERDEFINITION), + BE(f_NumberDisplay, EDIF_TOK_NUMBERDISPLAY), + BE(f_OffPageConnector, EDIF_TOK_OFFPAGECONNECTOR), + BE(f_OffsetEvent, EDIF_TOK_OFFSETEVENT), + BE(f_OpenShape, EDIF_TOK_OPENSHAPE), + BE(f_Origin, EDIF_TOK_ORIGIN), + BE(f_OverhangDistance, EDIF_TOK_OVERHANGDISTANCE), + BE(f_OverlapDistance, EDIF_TOK_OVERLAPDISTANCE), + BE(f_Oversize, EDIF_TOK_OVERSIZE), + BE(f_Page, EDIF_TOK_PAGE), + BE(f_PageSize, EDIF_TOK_PAGESIZE), + BE(f_Parameter, EDIF_TOK_PARAMETER), + BE(f_ParameterAssign, EDIF_TOK_PARAMETERASSIGN), + BE(f_ParameterDisplay, EDIF_TOK_PARAMETERDISPLAY), + BE(f_Path, EDIF_TOK_PATH), + BE(f_PathDelay, EDIF_TOK_PATHDELAY), + BE(f_Permutable, EDIF_TOK_PERMUTABLE), + BE(f_PhysicalDesignRule, EDIF_TOK_PHYSICALDESIGNRULE), + BE(f_Plug, EDIF_TOK_PLUG), + BE(f_Point, EDIF_TOK_POINT), + BE(f_PointDisplay, EDIF_TOK_POINTDISPLAY), + BE(f_PointList, EDIF_TOK_POINTLIST), + BE(f_Polygon, EDIF_TOK_POLYGON), + BE(f_Port, EDIF_TOK_PORT), + BE(f_PortBackAnnotate, EDIF_TOK_PORTBACKANNOTATE), + BE(f_PortBundle, EDIF_TOK_PORTBUNDLE), + BE(f_PortDelay, EDIF_TOK_PORTDELAY), + BE(f_PortGroup, EDIF_TOK_PORTGROUP), + BE(f_PortImplementation, EDIF_TOK_PORTIMPLEMENTATION), + BE(f_PortInstance, EDIF_TOK_PORTINSTANCE), + BE(f_PortList, EDIF_TOK_PORTLIST), + BE(f_PortListAlias, EDIF_TOK_PORTLISTALIAS), + BE(f_PortMap, EDIF_TOK_PORTMAP), + BE(f_PortRef, EDIF_TOK_PORTREF), + BE(f_Program, EDIF_TOK_PROGRAM), + BE(f_Property, EDIF_TOK_PROPERTY), + BE(f_PropertyDisplay, EDIF_TOK_PROPERTYDISPLAY), + BE(f_ProtectionFrame, EDIF_TOK_PROTECTIONFRAME), + BE(f_RangeVector, EDIF_TOK_RANGEVECTOR), + BE(f_Rectangle, EDIF_TOK_RECTANGLE), + BE(f_RectangleSize, EDIF_TOK_RECTANGLESIZE), + BE(f_Rename, EDIF_TOK_RENAME), + BE(f_Resolves, EDIF_TOK_RESOLVES), + BE(f_Scale, EDIF_TOK_SCALE), + BE(f_Section, EDIF_TOK_SECTION), + BE(f_Shape, EDIF_TOK_SHAPE), + BE(f_Simulate, EDIF_TOK_SIMULATE), + BE(f_SimulationInfo, EDIF_TOK_SIMULATIONINFO), + BE(f_SingleValueSet, EDIF_TOK_SINGLEVALUESET), + BE(f_Site, EDIF_TOK_SITE), + BE(f_Socket, EDIF_TOK_SOCKET), + BE(f_SocketSet, EDIF_TOK_SOCKETSET), + BE(f_Status, EDIF_TOK_STATUS), + BE(f_Steady, EDIF_TOK_STEADY), + BE(f_String, EDIF_TOK_STRING), + BE(f_StringDisplay, EDIF_TOK_STRINGDISPLAY), + BE(f_Strong, EDIF_TOK_STRONG), + BE(f_Symbol, EDIF_TOK_SYMBOL), + BE(f_Symmetry, EDIF_TOK_SYMMETRY), + BE(f_Table, EDIF_TOK_TABLE), + BE(f_TableDefault, EDIF_TOK_TABLEDEFAULT), + BE(f_Technology, EDIF_TOK_TECHNOLOGY), + BE(f_TimeInterval, EDIF_TOK_TIMEINTERVAL), + BE(f_Timing, EDIF_TOK_TIMING), + BE(f_Transform, EDIF_TOK_TRANSFORM), + BE(f_Transition, EDIF_TOK_TRANSITION), + BE(f_Trigger, EDIF_TOK_TRIGGER), + BE(f_Union, EDIF_TOK_UNION), + BE(f_View, EDIF_TOK_VIEW), + BE(f_ViewList, EDIF_TOK_VIEWLIST), + BE(f_ViewMap, EDIF_TOK_VIEWMAP), + BE(f_ViewRef, EDIF_TOK_VIEWREF), + BE(f_Visible, EDIF_TOK_VISIBLE), + BE(f_VoltageMap, EDIF_TOK_VOLTAGEMAP), + BE(f_WaveValue, EDIF_TOK_WAVEVALUE), + BE(f_Weak, EDIF_TOK_WEAK), + BE(f_WeakJoined, EDIF_TOK_WEAKJOINED), + BE(f_When, EDIF_TOK_WHEN), + BE(f_Written, EDIF_TOK_WRITTEN) }; + static int BinderDefSize = sizeof(BinderDef) / sizeof(Binder); /* * Keyword table: @@ -6503,10 +6912,10 @@ * and 'context' strings. */ typedef struct Keyword { - struct Keyword *Next; /* pointer to next entry */ - char *String; /* pointer to associated string */ + struct Keyword *Next; /* pointer to next entry */ + char *String; /* pointer to associated string */ } Keyword; -#define KEYWORD_HASH 127 /* hash table size */ +#define KEYWORD_HASH 127 /* hash table size */ static Keyword *KeywordTable[KEYWORD_HASH]; /* * Enter keyword: @@ -6513,23 +6922,24 @@ * * The passed string is entered into the keyword hash table. */ -static void EnterKeyword(char * str) +static void EnterKeyword(char *str) { - /* - * Locals. - */ - register Keyword *key; - register unsigned int hsh; - register char *cp; - /* - * Create the hash code, and add an entry to the table. - */ - for (hsh = 0, cp = str; *cp; hsh += hsh + *cp++); - hsh %= KEYWORD_HASH; - key = (Keyword *) Malloc(sizeof(Keyword)); - key->Next = KeywordTable[hsh]; - (KeywordTable[hsh] = key)->String = str; + /* + * Locals. + */ + register Keyword *key; + register unsigned int hsh; + register char *cp; + /* + * Create the hash code, and add an entry to the table. + */ + for (hsh = 0, cp = str; *cp; hsh += hsh + *cp++); + hsh %= KEYWORD_HASH; + key = (Keyword *) Malloc(sizeof(Keyword)); + key->Next = KeywordTable[hsh]; + (KeywordTable[hsh] = key)->String = str; } + /* * Find keyword: * @@ -6538,43 +6948,44 @@ * is real useful for doing string comparisons by pointer value later. * If there is no match, a NULL is returned. */ -static char *FindKeyword(char * str) +static char *FindKeyword(char *str) { - /* - * Locals. - */ - register Keyword *wlk,*owk; - register unsigned int hsh; - register char *cp; - char lower[IDENT_LENGTH + 1]; - /* - * Create a lower case copy of the string. - */ - for (cp = lower; *str;) - if (isupper( (int) *str)) - *cp++ = tolower( (int) *str++); - else - *cp++ = *str++; - *cp = '\0'; - /* - * Search the hash table for a match. - */ - for (hsh = 0, cp = lower; *cp; hsh += hsh + *cp++); - hsh %= KEYWORD_HASH; - for (owk = NULL, wlk = KeywordTable[hsh]; wlk; wlk = (owk = wlk)->Next) - if (!strcmp(wlk->String,lower)){ - /* - * Readjust the LRU. - */ - if (owk){ - owk->Next = wlk->Next; - wlk->Next = KeywordTable[hsh]; - KeywordTable[hsh] = wlk; - } - return (wlk->String); - } - return (NULL); + /* + * Locals. + */ + register Keyword *wlk, *owk; + register unsigned int hsh; + register char *cp; + char lower[IDENT_LENGTH + 1]; + /* + * Create a lower case copy of the string. + */ + for (cp = lower; *str;) + if (isupper((int) *str)) + *cp++ = tolower((int) *str++); + else + *cp++ = *str++; + *cp = '\0'; + /* + * Search the hash table for a match. + */ + for (hsh = 0, cp = lower; *cp; hsh += hsh + *cp++); + hsh %= KEYWORD_HASH; + for (owk = NULL, wlk = KeywordTable[hsh]; wlk; wlk = (owk = wlk)->Next) + if (!strcmp(wlk->String, lower)) { + /* + * Readjust the LRU. + */ + if (owk) { + owk->Next = wlk->Next; + wlk->Next = KeywordTable[hsh]; + KeywordTable[hsh] = wlk; + } + return (wlk->String); + } + return (NULL); } + /* * Token hash table. */ @@ -6588,26 +6999,27 @@ */ static Token *FindToken(register int cod) { - /* - * Locals. - */ - register Token *wlk,*owk; - register unsigned int hsh; - /* - * Search the hash table for a matching token. - */ - hsh = cod % TOKEN_HASH; - for (owk = NULL, wlk = TokenHash[hsh]; wlk; wlk = (owk = wlk)->Next) - if (cod == wlk->Code){ - if (owk){ - owk->Next = wlk->Next; - wlk->Next = TokenHash[hsh]; - TokenHash[hsh] = wlk; - } - break; - } - return (wlk); + /* + * Locals. + */ + register Token *wlk, *owk; + register unsigned int hsh; + /* + * Search the hash table for a matching token. + */ + hsh = cod % TOKEN_HASH; + for (owk = NULL, wlk = TokenHash[hsh]; wlk; wlk = (owk = wlk)->Next) + if (cod == wlk->Code) { + if (owk) { + owk->Next = wlk->Next; + wlk->Next = TokenHash[hsh]; + TokenHash[hsh] = wlk; + } + break; + } + return (wlk); } + /* * Context hash table. */ @@ -6621,26 +7033,27 @@ */ static Context *FindContext(register int cod) { - /* - * Locals. - */ - register Context *wlk,*owk; - register unsigned int hsh; - /* - * Search the hash table for a matching context. - */ - hsh = cod % CONTEXT_HASH; - for (owk = NULL, wlk = ContextHash[hsh]; wlk; wlk = (owk = wlk)->Next) - if (cod == wlk->Code){ - if (owk){ - owk->Next = wlk->Next; - wlk->Next = ContextHash[hsh]; - ContextHash[hsh] = wlk; - } - break; - } - return (wlk); + /* + * Locals. + */ + register Context *wlk, *owk; + register unsigned int hsh; + /* + * Search the hash table for a matching context. + */ + hsh = cod % CONTEXT_HASH; + for (owk = NULL, wlk = ContextHash[hsh]; wlk; wlk = (owk = wlk)->Next) + if (cod == wlk->Code) { + if (owk) { + owk->Next = wlk->Next; + wlk->Next = ContextHash[hsh]; + ContextHash[hsh] = wlk; + } + break; + } + return (wlk); } + /* * Token stacking variables. */ @@ -6656,17 +7069,18 @@ * Add a token to the debug stack. The passed string and type are * what is to be pushed. */ -static Stack(char * str, int typ) +static Stack(char *str, int typ) { - /* - * Free any previous string, then push. - */ - if (TokenStack[TSP & TS_MASK]) - Free(TokenStack[TSP & TS_MASK]); - TokenStack[TSP & TS_MASK] = strcpy((char *)Malloc(strlen(str) + 1),str); - TokenType[TSP & TS_MASK] = typ; - TSP += 1; + /* + * Free any previous string, then push. + */ + if (TokenStack[TSP & TS_MASK]) + Free(TokenStack[TSP & TS_MASK]); + TokenStack[TSP & TS_MASK] = strcpy((char *) Malloc(strlen(str) + 1), str); + TokenType[TSP & TS_MASK] = typ; + TSP += 1; } + /* * Dump stack: * @@ -6674,52 +7088,62 @@ */ static DumpStack() { - /* - * Locals. - */ - register int i; - register Context *cxt; - register Token *tok; - register char *nam; - /* - * Run through the list displaying the oldest first. - */ - fprintf(Error,"\n\n"); - for (i = 0; i < TS_DEPTH; i += 1) - if (TokenStack[(TSP + i) & TS_MASK]){ - /* - * Get the type name string. - */ - if (cxt = FindContext(TokenType[(TSP + i) & TS_MASK])) - nam = cxt->Name; - else if (tok = FindToken(TokenType[(TSP + i) & TS_MASK])) - nam = tok->Name; - else switch (TokenType[(TSP + i) & TS_MASK]){ - case IDENT: nam = "IDENT"; break; - case INT: nam = "INT"; break; - case KEYWORD: nam = "KEYWORD"; break; - case STR: nam = "STR"; break; - default: nam = "?"; break; - } - /* - * Now print the token state. - */ - fprintf(Error,"%2d %-16.16s '%s'\n",TS_DEPTH - i,nam, - TokenStack[(TSP + i) & TS_MASK]); - } - fprintf(Error,"\n"); + /* + * Locals. + */ + register int i; + register Context *cxt; + register Token *tok; + register char *nam; + /* + * Run through the list displaying the oldest first. + */ + fprintf(Error, "\n\n"); + for (i = 0; i < TS_DEPTH; i += 1) + if (TokenStack[(TSP + i) & TS_MASK]) { + /* + * Get the type name string. + */ + if (cxt = FindContext(TokenType[(TSP + i) & TS_MASK])) + nam = cxt->Name; + else if (tok = FindToken(TokenType[(TSP + i) & TS_MASK])) + nam = tok->Name; + else + switch (TokenType[(TSP + i) & TS_MASK]) { + case IDENT: + nam = "IDENT"; + break; + case INT: + nam = "INT"; + break; + case KEYWORD: + nam = "KEYWORD"; + break; + case STR: + nam = "STR"; + break; + default: + nam = "?"; + break; + } + /* + * Now print the token state. + */ + fprintf(Error, "%2d %-16.16s '%s'\n", TS_DEPTH - i, nam, TokenStack[(TSP + i) & TS_MASK]); + } + fprintf(Error, "\n"); } #else #define Stack(s,t) -#endif /* DEBUG */ +#endif /* DEBUG */ /* * Parser state variables. */ -static FILE *Input = NULL; /* input stream */ -static FILE *Error = NULL; /* error stream */ -static char *InFile; /* file name on the input stream */ -static long LineNumber; /* current input line number */ -static ContextCar *CSP = NULL; /* top of context stack */ +static FILE *Input = NULL; /* input stream */ +static FILE *Error = NULL; /* error stream */ +static char *InFile; /* file name on the input stream */ +static long LineNumber; /* current input line number */ +static ContextCar *CSP = NULL; /* top of context stack */ static char yytext[IDENT_LENGTH + 1]; /* token buffer */ static char CharBuf[IDENT_LENGTH + 1]; /* garbage buffer */ /* @@ -6731,21 +7155,22 @@ static void yyerror(const char *ers) { #ifdef DEBUG - DumpStack(); -#endif /* DEBUG */ - fprintf(Error,"%s, line %ld: %s\n",InFile,LineNumber,ers); + DumpStack(); +#endif /* DEBUG */ + fprintf(Error, "%s, line %ld: %s\n", InFile, LineNumber, ers); } + /* * String bucket definitions. */ #define BUCKET_SIZE 64 typedef struct Bucket { - struct Bucket *Next; /* pointer to next bucket */ - int Index; /* pointer to next free slot */ - char Data[BUCKET_SIZE]; /* string data */ + struct Bucket *Next; /* pointer to next bucket */ + int Index; /* pointer to next free slot */ + char Data[BUCKET_SIZE]; /* string data */ } Bucket; static Bucket *CurrentBucket = NULL; /* string bucket list */ -static int StringSize = 0; /* current string length */ +static int StringSize = 0; /* current string length */ /* * Push string: * @@ -6753,24 +7178,25 @@ */ static void PushString(char chr) { - /* - * Locals. - */ - register Bucket *bck; - /* - * Make sure there is room for the push. - */ - if ((bck = CurrentBucket)->Index >= BUCKET_SIZE){ - bck = (Bucket *) Malloc(sizeof(Bucket)); - bck->Next = CurrentBucket; - (CurrentBucket = bck)->Index = 0; - } - /* - * Push the character. - */ - bck->Data[bck->Index++] = chr; - StringSize += 1; + /* + * Locals. + */ + register Bucket *bck; + /* + * Make sure there is room for the push. + */ + if ((bck = CurrentBucket)->Index >= BUCKET_SIZE) { + bck = (Bucket *) Malloc(sizeof(Bucket)); + bck->Next = CurrentBucket; + (CurrentBucket = bck)->Index = 0; + } + /* + * Push the character. + */ + bck->Data[bck->Index++] = chr; + StringSize += 1; } + /* * Form string: * @@ -6779,33 +7205,34 @@ */ static char *FormString() { - /* - * Locals. - */ - register Bucket *bck; - register char *cp; - /* - * Allocate space for the string, set the pointer at the end. - */ - cp = (char *) Malloc(StringSize + 1); - - cp += StringSize; - *cp-- = '\0'; - /* - * Yank characters out of the bucket. - */ - for (bck = CurrentBucket; bck->Index || bck->Next;){ - if (!bck->Index){ - CurrentBucket = bck->Next; - Free(bck); - bck = CurrentBucket; - } - *cp-- = bck->Data[--bck->Index]; - } - /* reset buffer size to zero */ - StringSize =0; - return (cp + 1); + /* + * Locals. + */ + register Bucket *bck; + register char *cp; + /* + * Allocate space for the string, set the pointer at the end. + */ + cp = (char *) Malloc(StringSize + 1); + + cp += StringSize; + *cp-- = '\0'; + /* + * Yank characters out of the bucket. + */ + for (bck = CurrentBucket; bck->Index || bck->Next;) { + if (!bck->Index) { + CurrentBucket = bck->Next; + Free(bck); + bck = CurrentBucket; + } + *cp-- = bck->Data[--bck->Index]; + } + /* reset buffer size to zero */ + StringSize = 0; + return (cp + 1); } + /* * Parse EDIF: * @@ -6813,108 +7240,108 @@ * It is passed two file streams, the first is where the input comes * from; the second is where error messages get printed. */ -void ParseEDIF(char* filename,FILE* err) +void ParseEDIF(char *filename, FILE * err) { - /* - * Locals. - */ - register int i; - static int ContextDefined = 1; - /* - * Set up the file state to something useful. - */ - InFile = filename; - Input = fopen(filename,"r"); - Error = err; - LineNumber = 1; - /* - * Define both the enabled token and context strings. - */ - if (ContextDefined){ - for (i = TokenDefSize; i--; EnterKeyword(TokenDef[i].Name)){ - register unsigned int hsh; - hsh = TokenDef[i].Code % TOKEN_HASH; - TokenDef[i].Next = TokenHash[hsh]; - TokenHash[hsh] = &TokenDef[i]; - } - for (i = ContextDefSize; i--; EnterKeyword(ContextDef[i].Name)){ - register unsigned int hsh; - hsh = ContextDef[i].Code % CONTEXT_HASH; - ContextDef[i].Next = ContextHash[hsh]; - ContextHash[hsh] = &ContextDef[i]; - } - /* - * Build the context tree. - */ - for (i = BinderDefSize; i--;){ - register Context *cxt; - register int j; - /* - * Define the current context to have carriers bound to it. - */ - cxt = FindContext(BinderDef[i].Origin); - for (j = BinderDef[i].FollowerSize; j--;){ - register ContextCar *cc; - /* - * Add carriers to the current context. - */ - cc = (ContextCar *) Malloc(sizeof(ContextCar)); - cc->Next = cxt->Context; - (cxt->Context = cc)->Context = - FindContext(ABS(BinderDef[i].Follower[j])); - cc->u.Single = BinderDef[i].Follower[j] < 0; - } - } - /* - * Build the token tree. - */ - for (i = TieDefSize; i--;){ - register Context *cxt; - register int j; - /* - * Define the current context to have carriers bound to it. - */ - cxt = FindContext(TieDef[i].Origin); - for (j = TieDef[i].EnableSize; j--;){ - register TokenCar *tc; - /* - * Add carriers to the current context. - */ - tc = (TokenCar *) Malloc(sizeof(TokenCar)); - tc->Next = cxt->Token; - (cxt->Token = tc)->Token = FindToken(TieDef[i].Enable[j]); - } - } - /* - * Put a bogus context on the stack which has 'EDIF' as its - * follower. - */ - CSP = (ContextCar *) Malloc(sizeof(ContextCar)); - CSP->Next = NULL; - CSP->Context = FindContext(0); - CSP->u.Used = NULL; - ContextDefined = 0; - } - /* - * Create an initial, empty string bucket. - */ - CurrentBucket = (Bucket *) Malloc(sizeof(Bucket)); - CurrentBucket->Next = 0; - CurrentBucket->Index = 0; - /* - * Fill the token stack with NULLs if debugging is enabled. - */ + /* + * Locals. + */ + register int i; + static int ContextDefined = 1; + /* + * Set up the file state to something useful. + */ + InFile = filename; + Input = fopen(filename, "r"); + Error = err; + LineNumber = 1; + /* + * Define both the enabled token and context strings. + */ + if (ContextDefined) { + for (i = TokenDefSize; i--; EnterKeyword(TokenDef[i].Name)) { + register unsigned int hsh; + hsh = TokenDef[i].Code % TOKEN_HASH; + TokenDef[i].Next = TokenHash[hsh]; + TokenHash[hsh] = &TokenDef[i]; + } + for (i = ContextDefSize; i--; EnterKeyword(ContextDef[i].Name)) { + register unsigned int hsh; + hsh = ContextDef[i].Code % CONTEXT_HASH; + ContextDef[i].Next = ContextHash[hsh]; + ContextHash[hsh] = &ContextDef[i]; + } + /* + * Build the context tree. + */ + for (i = BinderDefSize; i--;) { + register Context *cxt; + register int j; + /* + * Define the current context to have carriers bound to it. + */ + cxt = FindContext(BinderDef[i].Origin); + for (j = BinderDef[i].FollowerSize; j--;) { + register ContextCar *cc; + /* + * Add carriers to the current context. + */ + cc = (ContextCar *) Malloc(sizeof(ContextCar)); + cc->Next = cxt->Context; + (cxt->Context = cc)->Context = FindContext(ABS(BinderDef[i].Follower[j])); + cc->u.Single = BinderDef[i].Follower[j] < 0; + } + } + /* + * Build the token tree. + */ + for (i = TieDefSize; i--;) { + register Context *cxt; + register int j; + /* + * Define the current context to have carriers bound to it. + */ + cxt = FindContext(TieDef[i].Origin); + for (j = TieDef[i].EnableSize; j--;) { + register TokenCar *tc; + /* + * Add carriers to the current context. + */ + tc = (TokenCar *) Malloc(sizeof(TokenCar)); + tc->Next = cxt->Token; + (cxt->Token = tc)->Token = FindToken(TieDef[i].Enable[j]); + } + } + /* + * Put a bogus context on the stack which has 'EDIF' as its + * follower. + */ + CSP = (ContextCar *) Malloc(sizeof(ContextCar)); + CSP->Next = NULL; + CSP->Context = FindContext(0); + CSP->u.Used = NULL; + ContextDefined = 0; + } + /* + * Create an initial, empty string bucket. + */ + CurrentBucket = (Bucket *) Malloc(sizeof(Bucket)); + CurrentBucket->Next = 0; + CurrentBucket->Index = 0; + /* + * Fill the token stack with NULLs if debugging is enabled. + */ #ifdef DEBUG - for (i = TS_DEPTH; i--; TokenStack[i] = NULL) - if (TokenStack[i]) - Free(TokenStack[i]); - TSP = 0; -#endif /* DEBUG */ - /* - * Go parse things! - */ - edifparse(); + for (i = TS_DEPTH; i--; TokenStack[i] = NULL) + if (TokenStack[i]) + Free(TokenStack[i]); + TSP = 0; +#endif /* DEBUG */ + /* + * Go parse things! + */ + edifparse(); } + /* * Match token: * @@ -6922,28 +7349,29 @@ * list to see if it is enabled. If so the token value is returned, * if not then zero. */ -static int MatchToken(register char * str) +static int MatchToken(register char *str) { - /* - * Locals. - */ - register TokenCar *wlk,*owk; - /* - * Convert the string to the proper form, then search the token - * carrier list for a match. - */ - str = FindKeyword(str); - for (owk = NULL, wlk = CSP->Context->Token; wlk; wlk = (owk = wlk)->Next) - if (str == wlk->Token->Name){ - if (owk){ - owk->Next = wlk->Next; - wlk->Next = CSP->Context->Token; - CSP->Context->Token = wlk; - } - return (wlk->Token->Code); - } - return (0); + /* + * Locals. + */ + register TokenCar *wlk, *owk; + /* + * Convert the string to the proper form, then search the token + * carrier list for a match. + */ + str = FindKeyword(str); + for (owk = NULL, wlk = CSP->Context->Token; wlk; wlk = (owk = wlk)->Next) + if (str == wlk->Token->Name) { + if (owk) { + owk->Next = wlk->Next; + wlk->Next = CSP->Context->Token; + CSP->Context->Token = wlk; + } + return (wlk->Token->Code); + } + return (0); } + /* * Match context: * @@ -6950,52 +7378,53 @@ * If the passed keyword string is within the current context, the * new context is pushed and token value is returned. A zero otherwise. */ -static int MatchContext(register char * str) +static int MatchContext(register char *str) { - /* - * Locals. - */ - register ContextCar *wlk,*owk; - /* - * See if the context is present. - */ - str = FindKeyword(str); - for (owk = NULL, wlk = CSP->Context->Context; wlk; wlk = (owk = wlk)->Next) - if (str == wlk->Context->Name){ - if (owk){ - owk->Next = wlk->Next; - wlk->Next = CSP->Context->Context; - CSP->Context->Context = wlk; - } - /* - * If a single context, make sure it isn't already used. - */ - if (wlk->u.Single){ - register UsedCar *usc; - for (usc = CSP->u.Used; usc; usc = usc->Next) - if (usc->Code == wlk->Context->Code) - break; - if (usc){ - sprintf(CharBuf,"'%s' is used more than once within '%s'", - str,CSP->Context->Name); - yyerror(CharBuf); - } else { - usc = (UsedCar *) Malloc(sizeof(UsedCar)); - usc->Next = CSP->u.Used; - (CSP->u.Used = usc)->Code = wlk->Context->Code; - } - } - /* - * Push the new context. - */ - owk = (ContextCar *) Malloc(sizeof(ContextCar)); - owk->Next = CSP; - (CSP = owk)->Context = wlk->Context; - owk->u.Used = NULL; - return (wlk->Context->Code); - } - return (0); + /* + * Locals. + */ + register ContextCar *wlk, *owk; + /* + * See if the context is present. + */ + str = FindKeyword(str); + for (owk = NULL, wlk = CSP->Context->Context; wlk; wlk = (owk = wlk)->Next) + if (str == wlk->Context->Name) { + if (owk) { + owk->Next = wlk->Next; + wlk->Next = CSP->Context->Context; + CSP->Context->Context = wlk; + } + /* + * If a single context, make sure it isn't already used. + */ + if (wlk->u.Single) { + register UsedCar *usc; + for (usc = CSP->u.Used; usc; usc = usc->Next) + if (usc->Code == wlk->Context->Code) + break; + if (usc) { + sprintf(CharBuf, "'%s' is used more than once within '%s'", str, CSP->Context->Name); + yyerror(CharBuf); + } + else { + usc = (UsedCar *) Malloc(sizeof(UsedCar)); + usc->Next = CSP->u.Used; + (CSP->u.Used = usc)->Code = wlk->Context->Code; + } + } + /* + * Push the new context. + */ + owk = (ContextCar *) Malloc(sizeof(ContextCar)); + owk->Next = CSP; + (CSP = owk)->Context = wlk->Context; + owk->u.Used = NULL; + return (wlk->Context->Code); + } + return (0); } + /* * PopC: * @@ -7003,22 +7432,23 @@ */ static void PopC() { - /* - * Locals. - */ - register UsedCar *usc; - register ContextCar *csp; - /* - * Release single markers and pop context. - */ - while ( (usc = CSP->u.Used) ){ - CSP->u.Used = usc->Next; - Free(usc); - } - csp = CSP->Next; - Free(CSP); - CSP = csp; + /* + * Locals. + */ + register UsedCar *usc; + register ContextCar *csp; + /* + * Release single markers and pop context. + */ + while ((usc = CSP->u.Used)) { + CSP->u.Used = usc->Next; + Free(usc); + } + csp = CSP->Next; + Free(CSP); + CSP = csp; } + /* * Lexical analyzer states. */ @@ -7045,151 +7475,155 @@ */ static int yylex() { - /* - * Locals. - */ - register int c,s,l; - /* - * Keep on sucking up characters until we find something which - * explicitly forces us out of this function. - */ - for (s = L_START, l = 0; 1;){ - yytext[l++] = c = Getc(Input); - switch (s){ - /* - * Starting state, look for something resembling a token. - */ - case L_START: - if (isdigit(c) || c == '-') - s = L_INT; - else if (isalpha(c) || c == '&') - s = L_IDENT; - else if (isspace(c)){ - if (c == '\n') - LineNumber += 1; - l = 0; - } else if (c == '('){ - l = 0; - s = L_KEYWORD; - } else if (c == '"') - s = L_STRING; - else if (c == '+'){ - l = 0; /* strip '+' */ - s = L_INT; - } else if (c == EOF) - return ('\0'); - else { - yytext[1] = '\0'; - Stack(yytext,c); - return (c); - } - break; - /* - * Suck up the integer digits. - */ - case L_INT: - if (isdigit(c)) - break; - Ungetc(c); - yytext[--l] = '\0'; - yylval.s = strcpy((char *)Malloc(l + 1),yytext); - Stack(yytext,EDIF_TOK_INT); - return (EDIF_TOK_INT); - /* - * Grab an identifier, see if the current context enables - * it with a specific token value. - */ - case L_IDENT: - if (isalpha(c) || isdigit(c) || c == '_') - break; - Ungetc(c); - yytext[--l] = '\0'; - if (CSP->Context->Token && (c = MatchToken(yytext))){ - Stack(yytext,c); - return (c); - } - yylval.s = strcpy((char *)Malloc(l + 1),yytext); - Stack(yytext, EDIF_TOK_IDENT); - return (EDIF_TOK_IDENT); - /* - * Scan until you find the start of an identifier, discard - * any whitespace found. On no identifier, return a '('. - */ - case L_KEYWORD: - if (isalpha(c) || c == '&'){ - s = L_KEYWORD2; - break; - } else if (isspace(c)){ - l = 0; - break; - } - Ungetc(c); - Stack("(",'('); - return ('('); - /* - * Suck up the keyword identifier, if it matches the set of - * allowable contexts then return its token value and push - * the context, otherwise just return the identifier string. - */ - case L_KEYWORD2: - if (isalpha(c) || isdigit(c) || c == '_') - break; - Ungetc(c); - yytext[--l] = '\0'; - if ( (c = MatchContext(yytext)) ){ - Stack(yytext,c); - return (c); - } - yylval.s = strcpy((char *)Malloc(l + 1),yytext); - Stack(yytext, EDIF_TOK_KEYWORD); - return (EDIF_TOK_KEYWORD); - /* - * Suck up string characters but once resolved they should - * be deposited in the string bucket because they can be - * arbitrarily long. - */ - case L_STRING: - if (c == '\n') - LineNumber += 1; - else if (c == '\r') - ; - else if (c == '"' || c == EOF){ - yylval.s = FormString(); - Stack(yylval.s, EDIF_TOK_STR); - return (EDIF_TOK_STR); - } else if (c == '%') - s = L_ASCIICHAR; - else - PushString(c); - l = 0; - break; - /* - * Skip white space and look for integers to be pushed - * as characters. - */ - case L_ASCIICHAR: - if (isdigit(c)){ - s = L_ASCIICHAR2; - break; - } else if (c == '%' || c == EOF) - s = L_STRING; - else if (c == '\n') - LineNumber += 1; - l = 0; - break; - /* - * Convert the accumulated integer into a char and push. - */ - case L_ASCIICHAR2: - if (isdigit(c)) - break; - Ungetc(c); - yytext[--l] = '\0'; - PushString(atoi(yytext)); - s = L_ASCIICHAR; - l = 0; - break; - } - } + /* + * Locals. + */ + register int c, s, l; + /* + * Keep on sucking up characters until we find something which + * explicitly forces us out of this function. + */ + for (s = L_START, l = 0; 1;) { + yytext[l++] = c = Getc(Input); + switch (s) { + /* + * Starting state, look for something resembling a token. + */ + case L_START: + if (isdigit(c) || c == '-') + s = L_INT; + else if (isalpha(c) || c == '&') + s = L_IDENT; + else if (isspace(c)) { + if (c == '\n') + LineNumber += 1; + l = 0; + } + else if (c == '(') { + l = 0; + s = L_KEYWORD; + } + else if (c == '"') + s = L_STRING; + else if (c == '+') { + l = 0; /* strip '+' */ + s = L_INT; + } + else if (c == EOF) + return ('\0'); + else { + yytext[1] = '\0'; + Stack(yytext, c); + return (c); + } + break; + /* + * Suck up the integer digits. + */ + case L_INT: + if (isdigit(c)) + break; + Ungetc(c); + yytext[--l] = '\0'; + yylval.s = strcpy((char *) Malloc(l + 1), yytext); + Stack(yytext, EDIF_TOK_INT); + return (EDIF_TOK_INT); + /* + * Grab an identifier, see if the current context enables + * it with a specific token value. + */ + case L_IDENT: + if (isalpha(c) || isdigit(c) || c == '_') + break; + Ungetc(c); + yytext[--l] = '\0'; + if (CSP->Context->Token && (c = MatchToken(yytext))) { + Stack(yytext, c); + return (c); + } + yylval.s = strcpy((char *) Malloc(l + 1), yytext); + Stack(yytext, EDIF_TOK_IDENT); + return (EDIF_TOK_IDENT); + /* + * Scan until you find the start of an identifier, discard + * any whitespace found. On no identifier, return a '('. + */ + case L_KEYWORD: + if (isalpha(c) || c == '&') { + s = L_KEYWORD2; + break; + } + else if (isspace(c)) { + l = 0; + break; + } + Ungetc(c); + Stack("(", '('); + return ('('); + /* + * Suck up the keyword identifier, if it matches the set of + * allowable contexts then return its token value and push + * the context, otherwise just return the identifier string. + */ + case L_KEYWORD2: + if (isalpha(c) || isdigit(c) || c == '_') + break; + Ungetc(c); + yytext[--l] = '\0'; + if ((c = MatchContext(yytext))) { + Stack(yytext, c); + return (c); + } + yylval.s = strcpy((char *) Malloc(l + 1), yytext); + Stack(yytext, EDIF_TOK_KEYWORD); + return (EDIF_TOK_KEYWORD); + /* + * Suck up string characters but once resolved they should + * be deposited in the string bucket because they can be + * arbitrarily long. + */ + case L_STRING: + if (c == '\n') + LineNumber += 1; + else if (c == '\r'); + else if (c == '"' || c == EOF) { + yylval.s = FormString(); + Stack(yylval.s, EDIF_TOK_STR); + return (EDIF_TOK_STR); + } + else if (c == '%') + s = L_ASCIICHAR; + else + PushString(c); + l = 0; + break; + /* + * Skip white space and look for integers to be pushed + * as characters. + */ + case L_ASCIICHAR: + if (isdigit(c)) { + s = L_ASCIICHAR2; + break; + } + else if (c == '%' || c == EOF) + s = L_STRING; + else if (c == '\n') + LineNumber += 1; + l = 0; + break; + /* + * Convert the accumulated integer into a char and push. + */ + case L_ASCIICHAR2: + if (isdigit(c)) + break; + Ungetc(c); + yytext[--l] = '\0'; + PushString(atoi(yytext)); + s = L_ASCIICHAR; + l = 0; + break; + } + } } - Index: trunk/src/edif.h =================================================================== --- trunk/src/edif.h (revision 1021) +++ trunk/src/edif.h (revision 1022) @@ -34,303 +34,303 @@ /* Tokens. */ #ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - EDIF_TOK_IDENT = 258, - EDIF_TOK_INT = 259, - EDIF_TOK_KEYWORD = 260, - EDIF_TOK_STR = 261, - EDIF_TOK_ANGLE = 262, - EDIF_TOK_BEHAVIOR = 263, - EDIF_TOK_CALCULATED = 264, - EDIF_TOK_CAPACITANCE = 265, - EDIF_TOK_CENTERCENTER = 266, - EDIF_TOK_CENTERLEFT = 267, - EDIF_TOK_CENTERRIGHT = 268, - EDIF_TOK_CHARGE = 269, - EDIF_TOK_CONDUCTANCE = 270, - EDIF_TOK_CURRENT = 271, - EDIF_TOK_DISTANCE = 272, - EDIF_TOK_DOCUMENT = 273, - EDIF_TOK_ENERGY = 274, - EDIF_TOK_EXTEND = 275, - EDIF_TOK_FLUX = 276, - EDIF_TOK_FREQUENCY = 277, - EDIF_TOK_GENERIC = 278, - EDIF_TOK_GRAPHIC = 279, - EDIF_TOK_INDUCTANCE = 280, - EDIF_TOK_INOUT = 281, - EDIF_TOK_INPUT = 282, - EDIF_TOK_LOGICMODEL = 283, - EDIF_TOK_LOWERCENTER = 284, - EDIF_TOK_LOWERLEFT = 285, - EDIF_TOK_LOWERRIGHT = 286, - EDIF_TOK_MASKLAYOUT = 287, - EDIF_TOK_MASS = 288, - EDIF_TOK_MEASURED = 289, - EDIF_TOK_MX = 290, - EDIF_TOK_MXR90 = 291, - EDIF_TOK_MY = 292, - EDIF_TOK_MYR90 = 293, - EDIF_TOK_NETLIST = 294, - EDIF_TOK_OUTPUT = 295, - EDIF_TOK_PCBLAYOUT = 296, - EDIF_TOK_POWER = 297, - EDIF_TOK_R0 = 298, - EDIF_TOK_R180 = 299, - EDIF_TOK_R270 = 300, - EDIF_TOK_R90 = 301, - EDIF_TOK_REQUIRED = 302, - EDIF_TOK_RESISTANCE = 303, - EDIF_TOK_RIPPER = 304, - EDIF_TOK_ROUND = 305, - EDIF_TOK_SCHEMATIC = 306, - EDIF_TOK_STRANGER = 307, - EDIF_TOK_SYMBOLIC = 308, - EDIF_TOK_TEMPERATURE = 309, - EDIF_TOK_TIE = 310, - EDIF_TOK_TIME = 311, - EDIF_TOK_TRUNCATE = 312, - EDIF_TOK_UPPERCENTER = 313, - EDIF_TOK_UPPERLEFT = 314, - EDIF_TOK_UPPERRIGHT = 315, - EDIF_TOK_VOLTAGE = 316, - EDIF_TOK_ACLOAD = 317, - EDIF_TOK_AFTER = 318, - EDIF_TOK_ANNOTATE = 319, - EDIF_TOK_APPLY = 320, - EDIF_TOK_ARC = 321, - EDIF_TOK_ARRAY = 322, - EDIF_TOK_ARRAYMACRO = 323, - EDIF_TOK_ARRAYRELATEDINFO = 324, - EDIF_TOK_ARRAYSITE = 325, - EDIF_TOK_ATLEAST = 326, - EDIF_TOK_ATMOST = 327, - EDIF_TOK_AUTHOR = 328, - EDIF_TOK_BASEARRAY = 329, - EDIF_TOK_BECOMES = 330, - EDIF_TOK_BETWEEN = 331, - EDIF_TOK_BOOLEAN = 332, - EDIF_TOK_BOOLEANDISPLAY = 333, - EDIF_TOK_BOOLEANMAP = 334, - EDIF_TOK_BORDERPATTERN = 335, - EDIF_TOK_BORDERWIDTH = 336, - EDIF_TOK_BOUNDINGBOX = 337, - EDIF_TOK_CELL = 338, - EDIF_TOK_CELLREF = 339, - EDIF_TOK_CELLTYPE = 340, - EDIF_TOK_CHANGE = 341, - EDIF_TOK_CIRCLE = 342, - EDIF_TOK_COLOR = 343, - EDIF_TOK_COMMENT = 344, - EDIF_TOK_COMMENTGRAPHICS = 345, - EDIF_TOK_COMPOUND = 346, - EDIF_TOK_CONNECTLOCATION = 347, - EDIF_TOK_CONTENTS = 348, - EDIF_TOK_CORNERTYPE = 349, - EDIF_TOK_CRITICALITY = 350, - EDIF_TOK_CURRENTMAP = 351, - EDIF_TOK_CURVE = 352, - EDIF_TOK_CYCLE = 353, - EDIF_TOK_DATAORIGIN = 354, - EDIF_TOK_DCFANINLOAD = 355, - EDIF_TOK_DCFANOUTLOAD = 356, - EDIF_TOK_DCMAXFANIN = 357, - EDIF_TOK_DCMAXFANOUT = 358, - EDIF_TOK_DELAY = 359, - EDIF_TOK_DELTA = 360, - EDIF_TOK_DERIVATION = 361, - EDIF_TOK_DESIGN = 362, - EDIF_TOK_DESIGNATOR = 363, - EDIF_TOK_DIFFERENCE = 364, - EDIF_TOK_DIRECTION = 365, - EDIF_TOK_DISPLAY = 366, - EDIF_TOK_DOMINATES = 367, - EDIF_TOK_DOT = 368, - EDIF_TOK_DURATION = 369, - EDIF_TOK_E = 370, - EDIF_TOK_EDIF = 371, - EDIF_TOK_EDIFLEVEL = 372, - EDIF_TOK_EDIFVERSION = 373, - EDIF_TOK_ENCLOSUREDISTANCE = 374, - EDIF_TOK_ENDTYPE = 375, - EDIF_TOK_ENTRY = 376, - EDIF_TOK_EVENT = 377, - EDIF_TOK_EXACTLY = 378, - EDIF_TOK_EXTERNAL = 379, - EDIF_TOK_FABRICATE = 380, - EDIF_TOK_FALSE = 381, - EDIF_TOK_FIGURE = 382, - EDIF_TOK_FIGUREAREA = 383, - EDIF_TOK_FIGUREGROUP = 384, - EDIF_TOK_FIGUREGROUPOBJECT = 385, - EDIF_TOK_FIGUREGROUPOVERRIDE = 386, - EDIF_TOK_FIGUREGROUPREF = 387, - EDIF_TOK_FIGUREPERIMETER = 388, - EDIF_TOK_FIGUREWIDTH = 389, - EDIF_TOK_FILLPATTERN = 390, - EDIF_TOK_FOLLOW = 391, - EDIF_TOK_FORBIDDENEVENT = 392, - EDIF_TOK_GLOBALPORTREF = 393, - EDIF_TOK_GREATERTHAN = 394, - EDIF_TOK_GRIDMAP = 395, - EDIF_TOK_IGNORE = 396, - EDIF_TOK_INCLUDEFIGUREGROUP = 397, - EDIF_TOK_INITIAL = 398, - EDIF_TOK_INSTANCE = 399, - EDIF_TOK_INSTANCEBACKANNOTATE = 400, - EDIF_TOK_INSTANCEGROUP = 401, - EDIF_TOK_INSTANCEMAP = 402, - EDIF_TOK_INSTANCEREF = 403, - EDIF_TOK_INTEGER = 404, - EDIF_TOK_INTEGERDISPLAY = 405, - EDIF_TOK_INTERFACE = 406, - EDIF_TOK_INTERFIGUREGROUPSPACING = 407, - EDIF_TOK_INTERSECTION = 408, - EDIF_TOK_INTRAFIGUREGROUPSPACING = 409, - EDIF_TOK_INVERSE = 410, - EDIF_TOK_ISOLATED = 411, - EDIF_TOK_JOINED = 412, - EDIF_TOK_JUSTIFY = 413, - EDIF_TOK_KEYWORDDISPLAY = 414, - EDIF_TOK_KEYWORDLEVEL = 415, - EDIF_TOK_KEYWORDMAP = 416, - EDIF_TOK_LESSTHAN = 417, - EDIF_TOK_LIBRARY = 418, - EDIF_TOK_LIBRARYREF = 419, - EDIF_TOK_LISTOFNETS = 420, - EDIF_TOK_LISTOFPORTS = 421, - EDIF_TOK_LOADDELAY = 422, - EDIF_TOK_LOGICASSIGN = 423, - EDIF_TOK_LOGICINPUT = 424, - EDIF_TOK_LOGICLIST = 425, - EDIF_TOK_LOGICMAPINPUT = 426, - EDIF_TOK_LOGICMAPOUTPUT = 427, - EDIF_TOK_LOGICONEOF = 428, - EDIF_TOK_LOGICOUTPUT = 429, - EDIF_TOK_LOGICPORT = 430, - EDIF_TOK_LOGICREF = 431, - EDIF_TOK_LOGICVALUE = 432, - EDIF_TOK_LOGICWAVEFORM = 433, - EDIF_TOK_MAINTAIN = 434, - EDIF_TOK_MATCH = 435, - EDIF_TOK_MEMBER = 436, - EDIF_TOK_MINOMAX = 437, - EDIF_TOK_MINOMAXDISPLAY = 438, - EDIF_TOK_MNM = 439, - EDIF_TOK_MULTIPLEVALUESET = 440, - EDIF_TOK_MUSTJOIN = 441, - EDIF_TOK_NAME = 442, - EDIF_TOK_NET = 443, - EDIF_TOK_NETBACKANNOTATE = 444, - EDIF_TOK_NETBUNDLE = 445, - EDIF_TOK_NETDELAY = 446, - EDIF_TOK_NETGROUP = 447, - EDIF_TOK_NETMAP = 448, - EDIF_TOK_NETREF = 449, - EDIF_TOK_NOCHANGE = 450, - EDIF_TOK_NONPERMUTABLE = 451, - EDIF_TOK_NOTALLOWED = 452, - EDIF_TOK_NOTCHSPACING = 453, - EDIF_TOK_NUMBER = 454, - EDIF_TOK_NUMBERDEFINITION = 455, - EDIF_TOK_NUMBERDISPLAY = 456, - EDIF_TOK_OFFPAGECONNECTOR = 457, - EDIF_TOK_OFFSETEVENT = 458, - EDIF_TOK_OPENSHAPE = 459, - EDIF_TOK_ORIENTATION = 460, - EDIF_TOK_ORIGIN = 461, - EDIF_TOK_OVERHANGDISTANCE = 462, - EDIF_TOK_OVERLAPDISTANCE = 463, - EDIF_TOK_OVERSIZE = 464, - EDIF_TOK_OWNER = 465, - EDIF_TOK_PAGE = 466, - EDIF_TOK_PAGESIZE = 467, - EDIF_TOK_PARAMETER = 468, - EDIF_TOK_PARAMETERASSIGN = 469, - EDIF_TOK_PARAMETERDISPLAY = 470, - EDIF_TOK_PATH = 471, - EDIF_TOK_PATHDELAY = 472, - EDIF_TOK_PATHWIDTH = 473, - EDIF_TOK_PERMUTABLE = 474, - EDIF_TOK_PHYSICALDESIGNRULE = 475, - EDIF_TOK_PLUG = 476, - EDIF_TOK_POINT = 477, - EDIF_TOK_POINTDISPLAY = 478, - EDIF_TOK_POINTLIST = 479, - EDIF_TOK_POLYGON = 480, - EDIF_TOK_PORT = 481, - EDIF_TOK_PORTBACKANNOTATE = 482, - EDIF_TOK_PORTBUNDLE = 483, - EDIF_TOK_PORTDELAY = 484, - EDIF_TOK_PORTGROUP = 485, - EDIF_TOK_PORTIMPLEMENTATION = 486, - EDIF_TOK_PORTINSTANCE = 487, - EDIF_TOK_PORTLIST = 488, - EDIF_TOK_PORTLISTALIAS = 489, - EDIF_TOK_PORTMAP = 490, - EDIF_TOK_PORTREF = 491, - EDIF_TOK_PROGRAM = 492, - EDIF_TOK_PROPERTY = 493, - EDIF_TOK_PROPERTYDISPLAY = 494, - EDIF_TOK_PROTECTIONFRAME = 495, - EDIF_TOK_PT = 496, - EDIF_TOK_RANGEVECTOR = 497, - EDIF_TOK_RECTANGLE = 498, - EDIF_TOK_RECTANGLESIZE = 499, - EDIF_TOK_RENAME = 500, - EDIF_TOK_RESOLVES = 501, - EDIF_TOK_SCALE = 502, - EDIF_TOK_SCALEX = 503, - EDIF_TOK_SCALEY = 504, - EDIF_TOK_SECTION = 505, - EDIF_TOK_SHAPE = 506, - EDIF_TOK_SIMULATE = 507, - EDIF_TOK_SIMULATIONINFO = 508, - EDIF_TOK_SINGLEVALUESET = 509, - EDIF_TOK_SITE = 510, - EDIF_TOK_SOCKET = 511, - EDIF_TOK_SOCKETSET = 512, - EDIF_TOK_STATUS = 513, - EDIF_TOK_STEADY = 514, - EDIF_TOK_STRING = 515, - EDIF_TOK_STRINGDISPLAY = 516, - EDIF_TOK_STRONG = 517, - EDIF_TOK_SYMBOL = 518, - EDIF_TOK_SYMMETRY = 519, - EDIF_TOK_TABLE = 520, - EDIF_TOK_TABLEDEFAULT = 521, - EDIF_TOK_TECHNOLOGY = 522, - EDIF_TOK_TEXTHEIGHT = 523, - EDIF_TOK_TIMEINTERVAL = 524, - EDIF_TOK_TIMESTAMP = 525, - EDIF_TOK_TIMING = 526, - EDIF_TOK_TRANSFORM = 527, - EDIF_TOK_TRANSITION = 528, - EDIF_TOK_TRIGGER = 529, - EDIF_TOK_TRUE = 530, - EDIF_TOK_UNCONSTRAINED = 531, - EDIF_TOK_UNDEFINED = 532, - EDIF_TOK_UNION = 533, - EDIF_TOK_UNIT = 534, - EDIF_TOK_UNUSED = 535, - EDIF_TOK_USERDATA = 536, - EDIF_TOK_VERSION = 537, - EDIF_TOK_VIEW = 538, - EDIF_TOK_VIEWLIST = 539, - EDIF_TOK_VIEWMAP = 540, - EDIF_TOK_VIEWREF = 541, - EDIF_TOK_VIEWTYPE = 542, - EDIF_TOK_VISIBLE = 543, - EDIF_TOK_VOLTAGEMAP = 544, - EDIF_TOK_WAVEVALUE = 545, - EDIF_TOK_WEAK = 546, - EDIF_TOK_WEAKJOINED = 547, - EDIF_TOK_WHEN = 548, - EDIF_TOK_WRITTEN = 549 - }; +#define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ +enum yytokentype { + EDIF_TOK_IDENT = 258, + EDIF_TOK_INT = 259, + EDIF_TOK_KEYWORD = 260, + EDIF_TOK_STR = 261, + EDIF_TOK_ANGLE = 262, + EDIF_TOK_BEHAVIOR = 263, + EDIF_TOK_CALCULATED = 264, + EDIF_TOK_CAPACITANCE = 265, + EDIF_TOK_CENTERCENTER = 266, + EDIF_TOK_CENTERLEFT = 267, + EDIF_TOK_CENTERRIGHT = 268, + EDIF_TOK_CHARGE = 269, + EDIF_TOK_CONDUCTANCE = 270, + EDIF_TOK_CURRENT = 271, + EDIF_TOK_DISTANCE = 272, + EDIF_TOK_DOCUMENT = 273, + EDIF_TOK_ENERGY = 274, + EDIF_TOK_EXTEND = 275, + EDIF_TOK_FLUX = 276, + EDIF_TOK_FREQUENCY = 277, + EDIF_TOK_GENERIC = 278, + EDIF_TOK_GRAPHIC = 279, + EDIF_TOK_INDUCTANCE = 280, + EDIF_TOK_INOUT = 281, + EDIF_TOK_INPUT = 282, + EDIF_TOK_LOGICMODEL = 283, + EDIF_TOK_LOWERCENTER = 284, + EDIF_TOK_LOWERLEFT = 285, + EDIF_TOK_LOWERRIGHT = 286, + EDIF_TOK_MASKLAYOUT = 287, + EDIF_TOK_MASS = 288, + EDIF_TOK_MEASURED = 289, + EDIF_TOK_MX = 290, + EDIF_TOK_MXR90 = 291, + EDIF_TOK_MY = 292, + EDIF_TOK_MYR90 = 293, + EDIF_TOK_NETLIST = 294, + EDIF_TOK_OUTPUT = 295, + EDIF_TOK_PCBLAYOUT = 296, + EDIF_TOK_POWER = 297, + EDIF_TOK_R0 = 298, + EDIF_TOK_R180 = 299, + EDIF_TOK_R270 = 300, + EDIF_TOK_R90 = 301, + EDIF_TOK_REQUIRED = 302, + EDIF_TOK_RESISTANCE = 303, + EDIF_TOK_RIPPER = 304, + EDIF_TOK_ROUND = 305, + EDIF_TOK_SCHEMATIC = 306, + EDIF_TOK_STRANGER = 307, + EDIF_TOK_SYMBOLIC = 308, + EDIF_TOK_TEMPERATURE = 309, + EDIF_TOK_TIE = 310, + EDIF_TOK_TIME = 311, + EDIF_TOK_TRUNCATE = 312, + EDIF_TOK_UPPERCENTER = 313, + EDIF_TOK_UPPERLEFT = 314, + EDIF_TOK_UPPERRIGHT = 315, + EDIF_TOK_VOLTAGE = 316, + EDIF_TOK_ACLOAD = 317, + EDIF_TOK_AFTER = 318, + EDIF_TOK_ANNOTATE = 319, + EDIF_TOK_APPLY = 320, + EDIF_TOK_ARC = 321, + EDIF_TOK_ARRAY = 322, + EDIF_TOK_ARRAYMACRO = 323, + EDIF_TOK_ARRAYRELATEDINFO = 324, + EDIF_TOK_ARRAYSITE = 325, + EDIF_TOK_ATLEAST = 326, + EDIF_TOK_ATMOST = 327, + EDIF_TOK_AUTHOR = 328, + EDIF_TOK_BASEARRAY = 329, + EDIF_TOK_BECOMES = 330, + EDIF_TOK_BETWEEN = 331, + EDIF_TOK_BOOLEAN = 332, + EDIF_TOK_BOOLEANDISPLAY = 333, + EDIF_TOK_BOOLEANMAP = 334, + EDIF_TOK_BORDERPATTERN = 335, + EDIF_TOK_BORDERWIDTH = 336, + EDIF_TOK_BOUNDINGBOX = 337, + EDIF_TOK_CELL = 338, + EDIF_TOK_CELLREF = 339, + EDIF_TOK_CELLTYPE = 340, + EDIF_TOK_CHANGE = 341, + EDIF_TOK_CIRCLE = 342, + EDIF_TOK_COLOR = 343, + EDIF_TOK_COMMENT = 344, + EDIF_TOK_COMMENTGRAPHICS = 345, + EDIF_TOK_COMPOUND = 346, + EDIF_TOK_CONNECTLOCATION = 347, + EDIF_TOK_CONTENTS = 348, + EDIF_TOK_CORNERTYPE = 349, + EDIF_TOK_CRITICALITY = 350, + EDIF_TOK_CURRENTMAP = 351, + EDIF_TOK_CURVE = 352, + EDIF_TOK_CYCLE = 353, + EDIF_TOK_DATAORIGIN = 354, + EDIF_TOK_DCFANINLOAD = 355, + EDIF_TOK_DCFANOUTLOAD = 356, + EDIF_TOK_DCMAXFANIN = 357, + EDIF_TOK_DCMAXFANOUT = 358, + EDIF_TOK_DELAY = 359, + EDIF_TOK_DELTA = 360, + EDIF_TOK_DERIVATION = 361, + EDIF_TOK_DESIGN = 362, + EDIF_TOK_DESIGNATOR = 363, + EDIF_TOK_DIFFERENCE = 364, + EDIF_TOK_DIRECTION = 365, + EDIF_TOK_DISPLAY = 366, + EDIF_TOK_DOMINATES = 367, + EDIF_TOK_DOT = 368, + EDIF_TOK_DURATION = 369, + EDIF_TOK_E = 370, + EDIF_TOK_EDIF = 371, + EDIF_TOK_EDIFLEVEL = 372, + EDIF_TOK_EDIFVERSION = 373, + EDIF_TOK_ENCLOSUREDISTANCE = 374, + EDIF_TOK_ENDTYPE = 375, + EDIF_TOK_ENTRY = 376, + EDIF_TOK_EVENT = 377, + EDIF_TOK_EXACTLY = 378, + EDIF_TOK_EXTERNAL = 379, + EDIF_TOK_FABRICATE = 380, + EDIF_TOK_FALSE = 381, + EDIF_TOK_FIGURE = 382, + EDIF_TOK_FIGUREAREA = 383, + EDIF_TOK_FIGUREGROUP = 384, + EDIF_TOK_FIGUREGROUPOBJECT = 385, + EDIF_TOK_FIGUREGROUPOVERRIDE = 386, + EDIF_TOK_FIGUREGROUPREF = 387, + EDIF_TOK_FIGUREPERIMETER = 388, + EDIF_TOK_FIGUREWIDTH = 389, + EDIF_TOK_FILLPATTERN = 390, + EDIF_TOK_FOLLOW = 391, + EDIF_TOK_FORBIDDENEVENT = 392, + EDIF_TOK_GLOBALPORTREF = 393, + EDIF_TOK_GREATERTHAN = 394, + EDIF_TOK_GRIDMAP = 395, + EDIF_TOK_IGNORE = 396, + EDIF_TOK_INCLUDEFIGUREGROUP = 397, + EDIF_TOK_INITIAL = 398, + EDIF_TOK_INSTANCE = 399, + EDIF_TOK_INSTANCEBACKANNOTATE = 400, + EDIF_TOK_INSTANCEGROUP = 401, + EDIF_TOK_INSTANCEMAP = 402, + EDIF_TOK_INSTANCEREF = 403, + EDIF_TOK_INTEGER = 404, + EDIF_TOK_INTEGERDISPLAY = 405, + EDIF_TOK_INTERFACE = 406, + EDIF_TOK_INTERFIGUREGROUPSPACING = 407, + EDIF_TOK_INTERSECTION = 408, + EDIF_TOK_INTRAFIGUREGROUPSPACING = 409, + EDIF_TOK_INVERSE = 410, + EDIF_TOK_ISOLATED = 411, + EDIF_TOK_JOINED = 412, + EDIF_TOK_JUSTIFY = 413, + EDIF_TOK_KEYWORDDISPLAY = 414, + EDIF_TOK_KEYWORDLEVEL = 415, + EDIF_TOK_KEYWORDMAP = 416, + EDIF_TOK_LESSTHAN = 417, + EDIF_TOK_LIBRARY = 418, + EDIF_TOK_LIBRARYREF = 419, + EDIF_TOK_LISTOFNETS = 420, + EDIF_TOK_LISTOFPORTS = 421, + EDIF_TOK_LOADDELAY = 422, + EDIF_TOK_LOGICASSIGN = 423, + EDIF_TOK_LOGICINPUT = 424, + EDIF_TOK_LOGICLIST = 425, + EDIF_TOK_LOGICMAPINPUT = 426, + EDIF_TOK_LOGICMAPOUTPUT = 427, + EDIF_TOK_LOGICONEOF = 428, + EDIF_TOK_LOGICOUTPUT = 429, + EDIF_TOK_LOGICPORT = 430, + EDIF_TOK_LOGICREF = 431, + EDIF_TOK_LOGICVALUE = 432, + EDIF_TOK_LOGICWAVEFORM = 433, + EDIF_TOK_MAINTAIN = 434, + EDIF_TOK_MATCH = 435, + EDIF_TOK_MEMBER = 436, + EDIF_TOK_MINOMAX = 437, + EDIF_TOK_MINOMAXDISPLAY = 438, + EDIF_TOK_MNM = 439, + EDIF_TOK_MULTIPLEVALUESET = 440, + EDIF_TOK_MUSTJOIN = 441, + EDIF_TOK_NAME = 442, + EDIF_TOK_NET = 443, + EDIF_TOK_NETBACKANNOTATE = 444, + EDIF_TOK_NETBUNDLE = 445, + EDIF_TOK_NETDELAY = 446, + EDIF_TOK_NETGROUP = 447, + EDIF_TOK_NETMAP = 448, + EDIF_TOK_NETREF = 449, + EDIF_TOK_NOCHANGE = 450, + EDIF_TOK_NONPERMUTABLE = 451, + EDIF_TOK_NOTALLOWED = 452, + EDIF_TOK_NOTCHSPACING = 453, + EDIF_TOK_NUMBER = 454, + EDIF_TOK_NUMBERDEFINITION = 455, + EDIF_TOK_NUMBERDISPLAY = 456, + EDIF_TOK_OFFPAGECONNECTOR = 457, + EDIF_TOK_OFFSETEVENT = 458, + EDIF_TOK_OPENSHAPE = 459, + EDIF_TOK_ORIENTATION = 460, + EDIF_TOK_ORIGIN = 461, + EDIF_TOK_OVERHANGDISTANCE = 462, + EDIF_TOK_OVERLAPDISTANCE = 463, + EDIF_TOK_OVERSIZE = 464, + EDIF_TOK_OWNER = 465, + EDIF_TOK_PAGE = 466, + EDIF_TOK_PAGESIZE = 467, + EDIF_TOK_PARAMETER = 468, + EDIF_TOK_PARAMETERASSIGN = 469, + EDIF_TOK_PARAMETERDISPLAY = 470, + EDIF_TOK_PATH = 471, + EDIF_TOK_PATHDELAY = 472, + EDIF_TOK_PATHWIDTH = 473, + EDIF_TOK_PERMUTABLE = 474, + EDIF_TOK_PHYSICALDESIGNRULE = 475, + EDIF_TOK_PLUG = 476, + EDIF_TOK_POINT = 477, + EDIF_TOK_POINTDISPLAY = 478, + EDIF_TOK_POINTLIST = 479, + EDIF_TOK_POLYGON = 480, + EDIF_TOK_PORT = 481, + EDIF_TOK_PORTBACKANNOTATE = 482, + EDIF_TOK_PORTBUNDLE = 483, + EDIF_TOK_PORTDELAY = 484, + EDIF_TOK_PORTGROUP = 485, + EDIF_TOK_PORTIMPLEMENTATION = 486, + EDIF_TOK_PORTINSTANCE = 487, + EDIF_TOK_PORTLIST = 488, + EDIF_TOK_PORTLISTALIAS = 489, + EDIF_TOK_PORTMAP = 490, + EDIF_TOK_PORTREF = 491, + EDIF_TOK_PROGRAM = 492, + EDIF_TOK_PROPERTY = 493, + EDIF_TOK_PROPERTYDISPLAY = 494, + EDIF_TOK_PROTECTIONFRAME = 495, + EDIF_TOK_PT = 496, + EDIF_TOK_RANGEVECTOR = 497, + EDIF_TOK_RECTANGLE = 498, + EDIF_TOK_RECTANGLESIZE = 499, + EDIF_TOK_RENAME = 500, + EDIF_TOK_RESOLVES = 501, + EDIF_TOK_SCALE = 502, + EDIF_TOK_SCALEX = 503, + EDIF_TOK_SCALEY = 504, + EDIF_TOK_SECTION = 505, + EDIF_TOK_SHAPE = 506, + EDIF_TOK_SIMULATE = 507, + EDIF_TOK_SIMULATIONINFO = 508, + EDIF_TOK_SINGLEVALUESET = 509, + EDIF_TOK_SITE = 510, + EDIF_TOK_SOCKET = 511, + EDIF_TOK_SOCKETSET = 512, + EDIF_TOK_STATUS = 513, + EDIF_TOK_STEADY = 514, + EDIF_TOK_STRING = 515, + EDIF_TOK_STRINGDISPLAY = 516, + EDIF_TOK_STRONG = 517, + EDIF_TOK_SYMBOL = 518, + EDIF_TOK_SYMMETRY = 519, + EDIF_TOK_TABLE = 520, + EDIF_TOK_TABLEDEFAULT = 521, + EDIF_TOK_TECHNOLOGY = 522, + EDIF_TOK_TEXTHEIGHT = 523, + EDIF_TOK_TIMEINTERVAL = 524, + EDIF_TOK_TIMESTAMP = 525, + EDIF_TOK_TIMING = 526, + EDIF_TOK_TRANSFORM = 527, + EDIF_TOK_TRANSITION = 528, + EDIF_TOK_TRIGGER = 529, + EDIF_TOK_TRUE = 530, + EDIF_TOK_UNCONSTRAINED = 531, + EDIF_TOK_UNDEFINED = 532, + EDIF_TOK_UNION = 533, + EDIF_TOK_UNIT = 534, + EDIF_TOK_UNUSED = 535, + EDIF_TOK_USERDATA = 536, + EDIF_TOK_VERSION = 537, + EDIF_TOK_VIEW = 538, + EDIF_TOK_VIEWLIST = 539, + EDIF_TOK_VIEWMAP = 540, + EDIF_TOK_VIEWREF = 541, + EDIF_TOK_VIEWTYPE = 542, + EDIF_TOK_VISIBLE = 543, + EDIF_TOK_VOLTAGEMAP = 544, + EDIF_TOK_WAVEVALUE = 545, + EDIF_TOK_WEAK = 546, + EDIF_TOK_WEAKJOINED = 547, + EDIF_TOK_WHEN = 548, + EDIF_TOK_WRITTEN = 549 +}; #endif /* Tokens. */ #define EDIF_TOK_IDENT 258 @@ -630,15 +630,14 @@ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE -{ +typedef union YYSTYPE { /* Line 1685 of yacc.c */ #line 193 "edif.y" - char* s; - pair_list* pl; - str_pair* ps; + char *s; + pair_list *pl; + str_pair *ps; @@ -645,11 +644,9 @@ /* Line 1685 of yacc.c */ #line 647 "edif.h" } YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 +#define YYSTYPE_IS_TRIVIAL 1 +#define yystype YYSTYPE /* obsolescent; will be withdrawn */ +#define YYSTYPE_IS_DECLARED 1 #endif extern YYSTYPE ediflval; - - Index: trunk/src/edif_parse.h =================================================================== --- trunk/src/edif_parse.h (revision 1021) +++ trunk/src/edif_parse.h (revision 1022) @@ -23,8 +23,7 @@ #ifndef PCB_EDIF_PARSE_H #define PCB_EDIF_PARSE_H -void ParseEDIF(char* filename,FILE* err); +void ParseEDIF(char *filename, FILE * err); #endif /* PCB_EDIF_PARSE_H */ - Index: trunk/src/error.c =================================================================== --- trunk/src/error.c (revision 1021) +++ trunk/src/error.c (revision 1022) @@ -62,7 +62,7 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); #define utf8_dup_string(a,b) *(a) = strdup(b) @@ -72,7 +72,7 @@ */ #if !defined(HAVE_STRERROR) -extern int sys_nerr; /* number of messages available from array */ +extern int sys_nerr; /* number of messages available from array */ #define USE_SYS_ERRLIST #endif @@ -79,7 +79,7 @@ /* the list is already defined for some OS */ #if !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__linux__) && !defined(__DragonFly__) #ifdef USE_SYS_ERRLIST -extern char *sys_errlist[]; /* array of error messages */ +extern char *sys_errlist[]; /* array of error messages */ #endif #endif @@ -87,21 +87,20 @@ /* --------------------------------------------------------------------------- * output of message in a dialog window or log window */ -void -Message (const char *Format, ...) +void Message(const char *Format, ...) { - va_list args; + va_list args; - if (gui != NULL) { - va_start (args, Format); - gui->logv (Format, args); - va_end (args); - } + if (gui != NULL) { + va_start(args, Format); + gui->logv(Format, args); + va_end(args); + } #ifdef HAVE_STDARG_H - va_start (args, Format); - vfprintf(stderr, Format, args); - va_end (args); + va_start(args, Format); + vfprintf(stderr, Format, args); + va_end(args); #endif } @@ -109,137 +108,121 @@ /* --------------------------------------------------------------------------- * print standard 'open error' */ -void -OpenErrorMessage (const char *Filename) +void OpenErrorMessage(const char *Filename) { - char *utf8 = NULL; + char *utf8 = NULL; - utf8_dup_string (&utf8, Filename); + utf8_dup_string(&utf8, Filename); #ifdef USE_SYS_ERRLIST - Message (_("Can't open file\n" - " '%s'\nfopen() returned: '%s'\n"), - utf8, errno <= sys_nerr ? sys_errlist[errno] : "???"); + Message(_("Can't open file\n" " '%s'\nfopen() returned: '%s'\n"), utf8, errno <= sys_nerr ? sys_errlist[errno] : "???"); #else - Message (_("Can't open file\n" - " '%s'\nfopen() returned: '%s'\n"), utf8, strerror (errno)); + Message(_("Can't open file\n" " '%s'\nfopen() returned: '%s'\n"), utf8, strerror(errno)); #endif - free (utf8); + free(utf8); } /* --------------------------------------------------------------------------- * print standard 'popen error' */ -void -PopenErrorMessage (const char *Filename) +void PopenErrorMessage(const char *Filename) { - char *utf8 = NULL; + char *utf8 = NULL; - utf8_dup_string (&utf8, Filename); + utf8_dup_string(&utf8, Filename); #ifdef USE_SYS_ERRLIST - Message (_("Can't execute command\n" - " '%s'\npopen() returned: '%s'\n"), - utf8, errno <= sys_nerr ? sys_errlist[errno] : "???"); + Message(_("Can't execute command\n" + " '%s'\npopen() returned: '%s'\n"), utf8, errno <= sys_nerr ? sys_errlist[errno] : "???"); #else - Message (_("Can't execute command\n" - " '%s'\npopen() returned: '%s'\n"), utf8, strerror (errno)); + Message(_("Can't execute command\n" " '%s'\npopen() returned: '%s'\n"), utf8, strerror(errno)); #endif - free (utf8); + free(utf8); } /* --------------------------------------------------------------------------- * print standard 'opendir' */ -void -OpendirErrorMessage (const char *DirName) +void OpendirErrorMessage(const char *DirName) { - char *utf8 = NULL; + char *utf8 = NULL; - utf8_dup_string (&utf8, DirName); + utf8_dup_string(&utf8, DirName); #ifdef USE_SYS_ERRLIST - Message (_("Can't scan directory\n" - " '%s'\nopendir() returned: '%s'\n"), - utf8, errno <= sys_nerr ? sys_errlist[errno] : "???"); + Message(_("Can't scan directory\n" + " '%s'\nopendir() returned: '%s'\n"), utf8, errno <= sys_nerr ? sys_errlist[errno] : "???"); #else - Message (_("Can't scan directory\n" - " '%s'\nopendir() returned: '%s'\n"), utf8, strerror (errno)); + Message(_("Can't scan directory\n" " '%s'\nopendir() returned: '%s'\n"), utf8, strerror(errno)); #endif - free (utf8); + free(utf8); } /* --------------------------------------------------------------------------- * print standard 'chdir error' */ -void -ChdirErrorMessage (const char *DirName) +void ChdirErrorMessage(const char *DirName) { - char *utf8 = NULL; + char *utf8 = NULL; - utf8_dup_string (&utf8, DirName); + utf8_dup_string(&utf8, DirName); #ifdef USE_SYS_ERRLIST - Message (_("Can't change working directory to\n" - " '%s'\nchdir() returned: '%s'\n"), - utf8, errno <= sys_nerr ? sys_errlist[errno] : "???"); + Message(_("Can't change working directory to\n" + " '%s'\nchdir() returned: '%s'\n"), utf8, errno <= sys_nerr ? sys_errlist[errno] : "???"); #else - Message (_("Can't change working directory to\n" - " '%s'\nchdir() returned: '%s'\n"), utf8, strerror (errno)); + Message(_("Can't change working directory to\n" " '%s'\nchdir() returned: '%s'\n"), utf8, strerror(errno)); #endif - free (utf8); + free(utf8); } /* --------------------------------------------------------------------------- * output of fatal error message */ -void -MyFatal (const char *Format, ...) +void MyFatal(const char *Format, ...) { - va_list args; + va_list args; - va_start (args, Format); + va_start(args, Format); - /* try to save the layout and do some cleanup */ - EmergencySave (); - fprintf (stderr, "%s (%i): fatal, ", Progname, (int) getpid ()); - vfprintf (stderr, Format, args); - fflush (stderr); - va_end (args); - exit (1); + /* try to save the layout and do some cleanup */ + EmergencySave(); + fprintf(stderr, "%s (%i): fatal, ", Progname, (int) getpid()); + vfprintf(stderr, Format, args); + fflush(stderr); + va_end(args); + exit(1); } /* --------------------------------------------------------------------------- * catches signals which abort the program */ -void -CatchSignal (int Signal) +void CatchSignal(int Signal) { - char *s; + char *s; - switch (Signal) - { + switch (Signal) { #ifdef SIGHUP - case SIGHUP: - s = "SIGHUP"; - break; + case SIGHUP: + s = "SIGHUP"; + break; #endif - case SIGINT: - s = "SIGINT"; - break; + case SIGINT: + s = "SIGINT"; + break; #ifdef SIGQUIT - case SIGQUIT: - s = "SIGQUIT"; - break; + case SIGQUIT: + s = "SIGQUIT"; + break; #endif - case SIGABRT: - s = "SIGABRT"; - break; - case SIGTERM: - s = "SIGTERM"; - break; - case SIGSEGV: - s = "SIGSEGV"; - break; - default: - s = "unknown"; - break; - } - MyFatal ("aborted by %s signal\n", s); + case SIGABRT: + s = "SIGABRT"; + break; + case SIGTERM: + s = "SIGTERM"; + break; + case SIGSEGV: + s = "SIGSEGV"; + break; + default: + s = "unknown"; + break; + } + MyFatal("aborted by %s signal\n", s); } Index: trunk/src/error.h =================================================================== --- trunk/src/error.h (revision 1021) +++ trunk/src/error.h (revision 1022) @@ -36,12 +36,12 @@ #define STATUS_BREAK 1 #define STATUS_ERROR -1 -void Message (const char *Format, ...); -void MyFatal (const char *Format, ...); -void OpenErrorMessage (const char *); -void PopenErrorMessage (const char *); -void OpendirErrorMessage (const char *); -void ChdirErrorMessage (const char *); -void CatchSignal (int); +void Message(const char *Format, ...); +void MyFatal(const char *Format, ...); +void OpenErrorMessage(const char *); +void PopenErrorMessage(const char *); +void OpendirErrorMessage(const char *); +void ChdirErrorMessage(const char *); +void CatchSignal(int); #endif Index: trunk/src/event.c =================================================================== --- trunk/src/event.c (revision 1021) +++ trunk/src/event.c (revision 1022) @@ -16,7 +16,7 @@ #define event_valid(ev) (((ev) >= 0) && ((ev) < EVENT_last)) -void event_bind(event_id_t ev, event_handler_t *handler, void *user_data, void *cookie) +void event_bind(event_id_t ev, event_handler_t * handler, void *user_data, void *cookie) { event_t *e; @@ -33,17 +33,17 @@ events[ev] = e; } -static void event_destroy(event_t *ev) +static void event_destroy(event_t * ev) { free(ev); } -void event_unbind(event_id_t ev, event_handler_t *handler) +void event_unbind(event_id_t ev, event_handler_t * handler) { event_t *prev = NULL, *e, *next; if (!(event_valid(ev))) return; - for(e = events[ev]; e != NULL; prev=e, e = next) { + for (e = events[ev]; e != NULL; prev = e, e = next) { next = e->next; if (e->handler == handler) { event_destroy(e); @@ -60,7 +60,7 @@ event_t *prev = NULL, *e, *next; if (!(event_valid(ev))) return; - for(e = events[ev]; e != NULL; prev=e, e = next) { + for (e = events[ev]; e != NULL; prev = e, e = next) { next = e->next; if (e->cookie == cookie) { event_destroy(e); @@ -76,7 +76,7 @@ void event_unbind_allcookie(void *cookie) { event_id_t n; - for(n = 0; n < EVENT_last; n++) + for (n = 0; n < EVENT_last; n++) event_unbind_cookie(n, cookie); } @@ -95,34 +95,34 @@ if (fmt != NULL) { va_start(ap, fmt); - for(a++; *fmt != '\0'; fmt++,a++,argc++) { + for (a++; *fmt != '\0'; fmt++, a++, argc++) { if (argc >= EVENT_MAX_ARG) { Message("event(): too many arguments\n"); break; } - switch(*fmt) { - case 'i': - a->type = ARG_INT; - a->d.i = va_arg(ap, int); - break; - case 'd': - a->type = ARG_DOUBLE; - a->d.d = va_arg(ap, double); - break; - case 's': - a->type = ARG_STR; - a->d.s = va_arg(ap, const char *); - break; - default: - a->type = ARG_INT; - a->d.i = 0; - Message("event(): invalid argument type '%c'\n", *fmt); - break; + switch (*fmt) { + case 'i': + a->type = ARG_INT; + a->d.i = va_arg(ap, int); + break; + case 'd': + a->type = ARG_DOUBLE; + a->d.d = va_arg(ap, double); + break; + case 's': + a->type = ARG_STR; + a->d.s = va_arg(ap, const char *); + break; + default: + a->type = ARG_INT; + a->d.i = 0; + Message("event(): invalid argument type '%c'\n", *fmt); + break; } } va_end(ap); } - for(e = events[ev]; e != NULL; e = e->next) - e->handler(e->user_data, argc, (event_arg_t **)&argv); + for (e = events[ev]; e != NULL; e = e->next) + e->handler(e->user_data, argc, (event_arg_t **) & argv); } Index: trunk/src/event.h =================================================================== --- trunk/src/event.h (revision 1021) +++ trunk/src/event.h (revision 1022) @@ -1,8 +1,8 @@ typedef enum { - EVENT_GUI_INIT, /* finished initializing the GUI called right before the main loop of the GUI; args: (void) */ - EVENT_CLI_ENTER, /* the user pressed enter on a CLI command - called before parsing the line for actions; args: (str commandline) */ + EVENT_GUI_INIT, /* finished initializing the GUI called right before the main loop of the GUI; args: (void) */ + EVENT_CLI_ENTER, /* the user pressed enter on a CLI command - called before parsing the line for actions; args: (str commandline) */ - EVENT_last /* not a real event */ + EVENT_last /* not a real event */ } event_id_t; /* Maximum number of arguments for an event handler, auto-set argv[0] included */ @@ -10,9 +10,9 @@ /* Argument types in event's argv[] */ typedef enum { - ARG_INT, /* format char: i */ - ARG_DOUBLE, /* format char: d */ - ARG_STR /* format char: s */ + ARG_INT, /* format char: i */ + ARG_DOUBLE, /* format char: d */ + ARG_STR /* format char: s */ } event_argtype_t; @@ -28,14 +28,14 @@ /* Event callback prototype; user_data is the same as in event_bind(). argv[0] is always an ARG_INT with the event id that triggered the event. */ -typedef void (event_handler_t)(void *user_data, int argc, event_arg_t *argv[]); +typedef void (event_handler_t) (void *user_data, int argc, event_arg_t * argv[]); /* Bind: add a handler to the call-list of an event; the cookie is also remembered so that mass-unbind is easier later. user_data is passed to the handler. */ -void event_bind(event_id_t ev, event_handler_t *handler, void *user_data, void *cookie); +void event_bind(event_id_t ev, event_handler_t * handler, void *user_data, void *cookie); /* Unbind: remove a handler from an event */ -void event_unbind(event_id_t ev, event_handler_t *handler); +void event_unbind(event_id_t ev, event_handler_t * handler); /* Unbind by cookie: remove all handlers from an event matching the cookie */ void event_unbind_cookie(event_id_t ev, void *cookie); Index: trunk/src/file.c =================================================================== --- trunk/src/file.c (revision 1021) +++ trunk/src/file.c (revision 1022) @@ -103,7 +103,7 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); #if !defined(HAS_ATEXIT) && !defined(HAS_ON_EXIT) /* --------------------------------------------------------------------------- @@ -116,20 +116,20 @@ /* --------------------------------------------------------------------------- * some local prototypes */ -static void PrintQuotedString (FILE *, char *); -static void WritePCBInfoHeader (FILE *); -static void WritePCBDataHeader (FILE *); -static void WritePCBFontData (FILE *); -static void WriteViaData (FILE *, DataTypePtr); -static void WritePCBRatData (FILE *); -static void WriteElementData (FILE *, DataTypePtr); -static void WriteLayerData (FILE *, Cardinal, LayerTypePtr); -static int WritePCB (FILE *); -static int WritePCBFile (char *); -static int WritePipe (char *, bool); -static int ParseLibraryTree (void); +static void PrintQuotedString(FILE *, char *); +static void WritePCBInfoHeader(FILE *); +static void WritePCBDataHeader(FILE *); +static void WritePCBFontData(FILE *); +static void WriteViaData(FILE *, DataTypePtr); +static void WritePCBRatData(FILE *); +static void WriteElementData(FILE *, DataTypePtr); +static void WriteLayerData(FILE *, Cardinal, LayerTypePtr); +static int WritePCB(FILE *); +static int WritePCBFile(char *); +static int WritePipe(char *, bool); +static int ParseLibraryTree(void); static int LoadNewlibFootprintsFromDir(const char *subdir, const char *toppath, int is_root); -static const char *pcb_basename (const char *p); +static const char *pcb_basename(const char *p); /* --------------------------------------------------------------------------- * Flag helper functions @@ -165,205 +165,182 @@ /* First version ever saved. */ #define PCB_FILE_VERSION_BASELINE 20070407 -int -PCBFileVersionNeeded (void) +int PCBFileVersionNeeded(void) { - ALLPOLYGON_LOOP (PCB->Data); - { - if (polygon->HoleIndexN > 0) - return PCB_FILE_VERSION_HOLES; - } - ENDALL_LOOP; + ALLPOLYGON_LOOP(PCB->Data); + { + if (polygon->HoleIndexN > 0) + return PCB_FILE_VERSION_HOLES; + } + ENDALL_LOOP; - return PCB_FILE_VERSION_BASELINE; + return PCB_FILE_VERSION_BASELINE; } /* --------------------------------------------------------------------------- */ -static int -string_cmp (const char *a, const char *b) +static int string_cmp(const char *a, const char *b) { - while (*a && *b) - { - if (isdigit ((int) *a) && isdigit ((int) *b)) - { - int ia = atoi (a); - int ib = atoi (b); - if (ia != ib) - return ia - ib; - while (isdigit ((int) *a) && *(a+1)) - a++; - while (isdigit ((int) *b) && *(b+1)) - b++; + while (*a && *b) { + if (isdigit((int) *a) && isdigit((int) *b)) { + int ia = atoi(a); + int ib = atoi(b); + if (ia != ib) + return ia - ib; + while (isdigit((int) *a) && *(a + 1)) + a++; + while (isdigit((int) *b) && *(b + 1)) + b++; + } + else if (tolower((int) *a) != tolower((int) *b)) + return tolower((int) *a) - tolower((int) *b); + a++; + b++; } - else if (tolower ((int) *a) != tolower ((int) *b)) - return tolower ((int) *a) - tolower ((int) *b); - a++; - b++; - } - if (*a) - return 1; - if (*b) - return -1; - return 0; + if (*a) + return 1; + if (*b) + return -1; + return 0; } static int netlist_sort_offset = 0; -static int -netlist_sort (const void *va, const void *vb) +static int netlist_sort(const void *va, const void *vb) { - LibraryMenuType *am = (LibraryMenuType *) va; - LibraryMenuType *bm = (LibraryMenuType *) vb; - char *a = am->Name; - char *b = bm->Name; - if (*a == '~') - a++; - if (*b == '~') - b++; - return string_cmp (a, b); + LibraryMenuType *am = (LibraryMenuType *) va; + LibraryMenuType *bm = (LibraryMenuType *) vb; + char *a = am->Name; + char *b = bm->Name; + if (*a == '~') + a++; + if (*b == '~') + b++; + return string_cmp(a, b); } -static int -netnode_sort (const void *va, const void *vb) +static int netnode_sort(const void *va, const void *vb) { - LibraryEntryType *am = (LibraryEntryType *) va; - LibraryEntryType *bm = (LibraryEntryType *) vb; - char *a = am->ListEntry; - char *b = bm->ListEntry; - return string_cmp (a, b); + LibraryEntryType *am = (LibraryEntryType *) va; + LibraryEntryType *bm = (LibraryEntryType *) vb; + char *a = am->ListEntry; + char *b = bm->ListEntry; + return string_cmp(a, b); } -static void -sort_library (LibraryTypePtr lib) +static void sort_library(LibraryTypePtr lib) { - int i; - qsort (lib->Menu, lib->MenuN, sizeof (lib->Menu[0]), netlist_sort); - for (i = 0; i < lib->MenuN; i++) - qsort (lib->Menu[i].Entry, - lib->Menu[i].EntryN, sizeof (lib->Menu[i].Entry[0]), netnode_sort); + int i; + qsort(lib->Menu, lib->MenuN, sizeof(lib->Menu[0]), netlist_sort); + for (i = 0; i < lib->MenuN; i++) + qsort(lib->Menu[i].Entry, lib->Menu[i].EntryN, sizeof(lib->Menu[i].Entry[0]), netnode_sort); } -void -sort_netlist () +void sort_netlist() { - netlist_sort_offset = 2; - sort_library (&(PCB->NetlistLib[NETLIST_INPUT])); - netlist_sort_offset = 0; + netlist_sort_offset = 2; + sort_library(&(PCB->NetlistLib[NETLIST_INPUT])); + netlist_sort_offset = 0; } /* --------------------------------------------------------------------------- * opens a file and check if it exists */ -FILE * -CheckAndOpenFile (char *Filename, bool Confirm, bool AllButton, - bool * WasAllButton, bool * WasCancelButton) +FILE *CheckAndOpenFile(char *Filename, bool Confirm, bool AllButton, bool * WasAllButton, bool * WasCancelButton) { - FILE *fp = NULL; - struct stat buffer; - char message[MAXPATHLEN + 80]; - int response; + FILE *fp = NULL; + struct stat buffer; + char message[MAXPATHLEN + 80]; + int response; - if (Filename && *Filename) - { - if (!stat (Filename, &buffer) && Confirm) - { - sprintf (message, _("File '%s' exists, use anyway?"), Filename); - if (WasAllButton) - *WasAllButton = false; - if (WasCancelButton) - *WasCancelButton = false; - if (AllButton) - response = - gui->confirm_dialog (message, "Cancel", "Ok", - AllButton ? "Sequence OK" : 0); - else - response = - gui->confirm_dialog (message, "Cancel", "Ok", "Sequence OK"); + if (Filename && *Filename) { + if (!stat(Filename, &buffer) && Confirm) { + sprintf(message, _("File '%s' exists, use anyway?"), Filename); + if (WasAllButton) + *WasAllButton = false; + if (WasCancelButton) + *WasCancelButton = false; + if (AllButton) + response = gui->confirm_dialog(message, "Cancel", "Ok", AllButton ? "Sequence OK" : 0); + else + response = gui->confirm_dialog(message, "Cancel", "Ok", "Sequence OK"); - switch (response) - { - case 2: - if (WasAllButton) - *WasAllButton = true; - break; - case 0: - if (WasCancelButton) - *WasCancelButton = true; - } + switch (response) { + case 2: + if (WasAllButton) + *WasAllButton = true; + break; + case 0: + if (WasCancelButton) + *WasCancelButton = true; + } + } + if ((fp = fopen(Filename, "w")) == NULL) + OpenErrorMessage(Filename); } - if ((fp = fopen (Filename, "w")) == NULL) - OpenErrorMessage (Filename); - } - return (fp); + return (fp); } /* --------------------------------------------------------------------------- * opens a file for saving connection data */ -FILE * -OpenConnectionDataFile (void) +FILE *OpenConnectionDataFile(void) { - char *fname; - FILE *fp; - static char * default_file = NULL; - bool result; /* not used */ + char *fname; + FILE *fp; + static char *default_file = NULL; + bool result; /* not used */ - /* CheckAndOpenFile deals with the case where fname already exists */ - fname = gui->fileselect (_("Save Connection Data As ..."), - _("Choose a file to save all connection data to."), - default_file, ".net", "connection_data", - 0); - if (fname == NULL) - return NULL; + /* CheckAndOpenFile deals with the case where fname already exists */ + fname = gui->fileselect(_("Save Connection Data As ..."), + _("Choose a file to save all connection data to."), default_file, ".net", "connection_data", 0); + if (fname == NULL) + return NULL; - if (default_file != NULL) - { - free (default_file); - default_file = NULL; - } + if (default_file != NULL) { + free(default_file); + default_file = NULL; + } - if (fname && *fname) - default_file = strdup (fname); + if (fname && *fname) + default_file = strdup(fname); - fp = CheckAndOpenFile (fname, true, false, &result, NULL); - free (fname); + fp = CheckAndOpenFile(fname, true, false, &result, NULL); + free(fname); - return fp; + return fp; } /* --------------------------------------------------------------------------- * save elements in the current buffer */ -int -SaveBufferElements (char *Filename) +int SaveBufferElements(char *Filename) { - int result; + int result; - if (SWAP_IDENT) - SwapBuffers (); - result = WritePipe (Filename, false); - if (SWAP_IDENT) - SwapBuffers (); - return (result); + if (SWAP_IDENT) + SwapBuffers(); + result = WritePipe(Filename, false); + if (SWAP_IDENT) + SwapBuffers(); + return (result); } /* --------------------------------------------------------------------------- * save PCB */ -int -SavePCB (char *file) +int SavePCB(char *file) { - int retcode; + int retcode; - if (gui->notify_save_pcb == NULL) - return WritePipe (file, true); + if (gui->notify_save_pcb == NULL) + return WritePipe(file, true); - gui->notify_save_pcb (file, false); - retcode = WritePipe (file, true); - gui->notify_save_pcb (file, true); + gui->notify_save_pcb(file, false); + retcode = WritePipe(file, true); + gui->notify_save_pcb(file, true); - return retcode; + return retcode; } /* --------------------------------------------------------------------------- @@ -371,15 +348,14 @@ * happen to match any. This way, "revert" won't change the route * style. */ -static void -set_some_route_style () +static void set_some_route_style() { - if (hid_get_flag ("style")) - return; - SetLineSize (PCB->RouteStyle[0].Thick); - SetViaSize (PCB->RouteStyle[0].Diameter, true); - SetViaDrillingHole (PCB->RouteStyle[0].Hole, true); - SetKeepawayWidth (PCB->RouteStyle[0].Keepaway); + if (hid_get_flag("style")) + return; + SetLineSize(PCB->RouteStyle[0].Thick); + SetViaSize(PCB->RouteStyle[0].Diameter, true); + SetViaDrillingHole(PCB->RouteStyle[0].Hole, true); + SetKeepawayWidth(PCB->RouteStyle[0].Keepaway); } /* --------------------------------------------------------------------------- @@ -390,111 +366,102 @@ * If revert is true, we pass "revert" as a parameter * to the HID's PCBChanged action. */ -static int -real_load_pcb (char *Filename, bool revert, bool require_font) +static int real_load_pcb(char *Filename, bool revert, bool require_font) { - const char *unit_suffix; - char *new_filename; - PCBTypePtr newPCB = CreateNewPCB_ (false); - PCBTypePtr oldPCB; + const char *unit_suffix; + char *new_filename; + PCBTypePtr newPCB = CreateNewPCB_(false); + PCBTypePtr oldPCB; #ifdef DEBUG - double elapsed; - clock_t start, end; + double elapsed; + clock_t start, end; - start = clock (); + start = clock(); #endif resolve_path(Filename, &new_filename); - oldPCB = PCB; - PCB = newPCB; + oldPCB = PCB; + PCB = newPCB; - /* mark the default font invalid to know if the file has one */ - newPCB->Font.Valid = false; + /* mark the default font invalid to know if the file has one */ + newPCB->Font.Valid = false; - /* new data isn't added to the undo list */ - if (!ParsePCB (PCB, new_filename)) - { - RemovePCB (oldPCB); + /* new data isn't added to the undo list */ + if (!ParsePCB(PCB, new_filename)) { + RemovePCB(oldPCB); - CreateNewPCBPost (PCB, 0); - ResetStackAndVisibility (); + CreateNewPCBPost(PCB, 0); + ResetStackAndVisibility(); - /* update cursor location */ - Crosshair.X = CLAMP (PCB->CursorX, 0, PCB->MaxWidth); - Crosshair.Y = CLAMP (PCB->CursorY, 0, PCB->MaxHeight); + /* update cursor location */ + Crosshair.X = CLAMP(PCB->CursorX, 0, PCB->MaxWidth); + Crosshair.Y = CLAMP(PCB->CursorY, 0, PCB->MaxHeight); - /* update cursor confinement and output area (scrollbars) */ - ChangePCBSize (PCB->MaxWidth, PCB->MaxHeight); + /* update cursor confinement and output area (scrollbars) */ + ChangePCBSize(PCB->MaxWidth, PCB->MaxHeight); - /* enable default font if necessary */ - if (!PCB->Font.Valid) - { - if (require_font) - Message (_ - ("File '%s' has no font information, using default font\n"), - new_filename); - PCB->Font.Valid = true; - } + /* enable default font if necessary */ + if (!PCB->Font.Valid) { + if (require_font) + Message(_("File '%s' has no font information, using default font\n"), new_filename); + PCB->Font.Valid = true; + } - /* clear 'changed flag' */ - SetChangedFlag (false); - PCB->Filename = new_filename; - /* just in case a bad file saved file is loaded */ + /* clear 'changed flag' */ + SetChangedFlag(false); + PCB->Filename = new_filename; + /* just in case a bad file saved file is loaded */ - /* Use attribute PCB::grid::unit as unit, if we can */ - unit_suffix = AttributeGet (PCB, "PCB::grid::unit"); - if (unit_suffix && *unit_suffix) - { - const Unit *new_unit = get_unit_struct (unit_suffix); - if (new_unit) - Settings.grid_unit = new_unit; - } - AttributePut (PCB, "PCB::grid::unit", Settings.grid_unit->suffix); - - sort_netlist (); - rats_patch_make_edited(PCB); + /* Use attribute PCB::grid::unit as unit, if we can */ + unit_suffix = AttributeGet(PCB, "PCB::grid::unit"); + if (unit_suffix && *unit_suffix) { + const Unit *new_unit = get_unit_struct(unit_suffix); + if (new_unit) + Settings.grid_unit = new_unit; + } + AttributePut(PCB, "PCB::grid::unit", Settings.grid_unit->suffix); - set_some_route_style (); + sort_netlist(); + rats_patch_make_edited(PCB); - if (revert) - hid_actionl ("PCBChanged", "revert", NULL); - else - hid_action ("PCBChanged"); + set_some_route_style(); + if (revert) + hid_actionl("PCBChanged", "revert", NULL); + else + hid_action("PCBChanged"); + #ifdef DEBUG - end = clock (); - elapsed = ((double) (end - start)) / CLOCKS_PER_SEC; - gui->log ("Loading file %s took %f seconds of CPU time\n", - new_filename, elapsed); + end = clock(); + elapsed = ((double) (end - start)) / CLOCKS_PER_SEC; + gui->log("Loading file %s took %f seconds of CPU time\n", new_filename, elapsed); #endif - return (0); - } - PCB = oldPCB; - hid_action ("PCBChanged"); + return (0); + } + PCB = oldPCB; + hid_action("PCBChanged"); - /* release unused memory */ - RemovePCB (newPCB); - return (1); + /* release unused memory */ + RemovePCB(newPCB); + return (1); } /* --------------------------------------------------------------------------- * Load PCB */ -int -LoadPCB (char *file, bool require_font) +int LoadPCB(char *file, bool require_font) { - return real_load_pcb (file, false, require_font); + return real_load_pcb(file, false, require_font); } /* --------------------------------------------------------------------------- * Revert PCB */ -int -RevertPCB (void) +int RevertPCB(void) { - return real_load_pcb (PCB->Filename, true, true); + return real_load_pcb(PCB->Filename, true, true); } /* --------------------------------------------------------------------------- @@ -501,81 +468,74 @@ * functions for loading elements-as-pcb */ -extern PCBTypePtr yyPCB; -extern DataTypePtr yyData; -extern FontTypePtr yyFont; +extern PCBTypePtr yyPCB; +extern DataTypePtr yyData; +extern FontTypePtr yyFont; -void -PreLoadElementPCB () +void PreLoadElementPCB() { - if (!yyPCB) - return; + if (!yyPCB) + return; - yyFont = &yyPCB->Font; - yyData = yyPCB->Data; - yyData->pcb = yyPCB; - yyData->LayerN = 0; + yyFont = &yyPCB->Font; + yyData = yyPCB->Data; + yyData->pcb = yyPCB; + yyData->LayerN = 0; } -void -PostLoadElementPCB () +void PostLoadElementPCB() { - PCBTypePtr pcb_save = PCB; - ElementTypePtr e; + PCBTypePtr pcb_save = PCB; + ElementTypePtr e; - if (!yyPCB) - return; + if (!yyPCB) + return; - CreateNewPCBPost (yyPCB, 0); - ParseGroupString("1,c:2,s", &yyPCB->LayerGroups, yyData->LayerN); - e = yyPCB->Data->Element->data; /* we know there's only one */ - PCB = yyPCB; - MoveElementLowLevel (yyPCB->Data, - e, -e->BoundingBox.X1, -e->BoundingBox.Y1); - PCB = pcb_save; - yyPCB->MaxWidth = e->BoundingBox.X2; - yyPCB->MaxHeight = e->BoundingBox.Y2; - yyPCB->is_footprint = 1; + CreateNewPCBPost(yyPCB, 0); + ParseGroupString("1,c:2,s", &yyPCB->LayerGroups, yyData->LayerN); + e = yyPCB->Data->Element->data; /* we know there's only one */ + PCB = yyPCB; + MoveElementLowLevel(yyPCB->Data, e, -e->BoundingBox.X1, -e->BoundingBox.Y1); + PCB = pcb_save; + yyPCB->MaxWidth = e->BoundingBox.X2; + yyPCB->MaxHeight = e->BoundingBox.Y2; + yyPCB->is_footprint = 1; } /* --------------------------------------------------------------------------- * writes the quoted string created by another subroutine */ -static void -PrintQuotedString (FILE * FP, char *S) +static void PrintQuotedString(FILE * FP, char *S) { - static DynamicStringType ds; + static DynamicStringType ds; - CreateQuotedString (&ds, S); - fputs (ds.Data, FP); + CreateQuotedString(&ds, S); + fputs(ds.Data, FP); } /* --------------------------------------------------------------------------- * writes out an attribute list */ -static void -WriteAttributeList (FILE * FP, AttributeListTypePtr list, char *prefix) +static void WriteAttributeList(FILE * FP, AttributeListTypePtr list, char *prefix) { - int i; + int i; - for (i = 0; i < list->Number; i++) - fprintf (FP, "%sAttribute(\"%s\" \"%s\")\n", - prefix, list->List[i].name, list->List[i].value); + for (i = 0; i < list->Number; i++) + fprintf(FP, "%sAttribute(\"%s\" \"%s\")\n", prefix, list->List[i].name, list->List[i].value); } /* --------------------------------------------------------------------------- * writes layout header information */ -static void -WritePCBInfoHeader (FILE * FP) +static void WritePCBInfoHeader(FILE * FP) { - /* write some useful comments */ - fprintf (FP, "# release: %s " VERSION "\n", Progname); + /* write some useful comments */ + fprintf(FP, "# release: %s " VERSION "\n", Progname); - /* avoid writing things like user name or date, as these cause merge - * conflicts in collaborative environments using version control systems - */ + /* avoid writing things like user name or date, as these cause merge + * conflicts in collaborative environments using version control systems + */ } /* --------------------------------------------------------------------------- @@ -583,159 +543,142 @@ * the name of the PCB, cursor location, zoom and grid * layergroups and some flags */ -static void -WritePCBDataHeader (FILE * FP) +static void WritePCBDataHeader(FILE * FP) { - Cardinal group; + Cardinal group; - /* - * ************************** README ******************* - * ************************** README ******************* - * - * If the file format is modified in any way, update - * PCB_FILE_VERSION in file.h as well as PCBFileVersionNeeded() - * at the top of this file. - * - * ************************** README ******************* - * ************************** README ******************* - */ + /* + * ************************** README ******************* + * ************************** README ******************* + * + * If the file format is modified in any way, update + * PCB_FILE_VERSION in file.h as well as PCBFileVersionNeeded() + * at the top of this file. + * + * ************************** README ******************* + * ************************** README ******************* + */ - fprintf (FP, "\n# To read pcb files, the pcb version (or the git source date) must be >= the file version\n"); - fprintf (FP, "FileVersion[%i]\n", PCBFileVersionNeeded ()); + fprintf(FP, "\n# To read pcb files, the pcb version (or the git source date) must be >= the file version\n"); + fprintf(FP, "FileVersion[%i]\n", PCBFileVersionNeeded()); - fputs ("\nPCB[", FP); - PrintQuotedString (FP, (char *)EMPTY (PCB->Name)); - pcb_fprintf (FP, " %mr %mr]\n\n", PCB->MaxWidth, PCB->MaxHeight); - pcb_fprintf (FP, "Grid[%.1mr %mr %mr %d]\n", PCB->Grid, PCB->GridOffsetX, PCB->GridOffsetY, Settings.DrawGrid); - pcb_fprintf (FP, "Cursor[%mr %mr %s]\n", - Crosshair.X, Crosshair.Y, c_dtostr (PCB->Zoom)); - /* PolyArea should be output in square cmils, no suffix */ - fprintf (FP, "PolyArea[%s]\n", c_dtostr (COORD_TO_MIL (COORD_TO_MIL (PCB->IsleArea) * 100) * 100)); - pcb_fprintf (FP, "Thermal[%s]\n", c_dtostr (PCB->ThermScale)); - pcb_fprintf (FP, "DRC[%mr %mr %mr %mr %mr %mr]\n", PCB->Bloat, PCB->Shrink, - PCB->minWid, PCB->minSlk, PCB->minDrill, PCB->minRing); - fprintf (FP, "Flags(%s)\n", pcbflags_to_string(PCB->Flags)); - fprintf (FP, "Groups(\"%s\")\n", LayerGroupsToString (&PCB->LayerGroups)); - fputs ("Styles[\"", FP); - for (group = 0; group < NUM_STYLES - 1; group++) - pcb_fprintf (FP, "%s,%mr,%mr,%mr,%mr:", PCB->RouteStyle[group].Name, - PCB->RouteStyle[group].Thick, - PCB->RouteStyle[group].Diameter, - PCB->RouteStyle[group].Hole, PCB->RouteStyle[group].Keepaway); - pcb_fprintf (FP, "%s,%mr,%mr,%mr,%mr\"]\n\n", PCB->RouteStyle[group].Name, - PCB->RouteStyle[group].Thick, - PCB->RouteStyle[group].Diameter, - PCB->RouteStyle[group].Hole, PCB->RouteStyle[group].Keepaway); + fputs("\nPCB[", FP); + PrintQuotedString(FP, (char *) EMPTY(PCB->Name)); + pcb_fprintf(FP, " %mr %mr]\n\n", PCB->MaxWidth, PCB->MaxHeight); + pcb_fprintf(FP, "Grid[%.1mr %mr %mr %d]\n", PCB->Grid, PCB->GridOffsetX, PCB->GridOffsetY, Settings.DrawGrid); + pcb_fprintf(FP, "Cursor[%mr %mr %s]\n", Crosshair.X, Crosshair.Y, c_dtostr(PCB->Zoom)); + /* PolyArea should be output in square cmils, no suffix */ + fprintf(FP, "PolyArea[%s]\n", c_dtostr(COORD_TO_MIL(COORD_TO_MIL(PCB->IsleArea) * 100) * 100)); + pcb_fprintf(FP, "Thermal[%s]\n", c_dtostr(PCB->ThermScale)); + pcb_fprintf(FP, "DRC[%mr %mr %mr %mr %mr %mr]\n", PCB->Bloat, PCB->Shrink, + PCB->minWid, PCB->minSlk, PCB->minDrill, PCB->minRing); + fprintf(FP, "Flags(%s)\n", pcbflags_to_string(PCB->Flags)); + fprintf(FP, "Groups(\"%s\")\n", LayerGroupsToString(&PCB->LayerGroups)); + fputs("Styles[\"", FP); + for (group = 0; group < NUM_STYLES - 1; group++) + pcb_fprintf(FP, "%s,%mr,%mr,%mr,%mr:", PCB->RouteStyle[group].Name, + PCB->RouteStyle[group].Thick, + PCB->RouteStyle[group].Diameter, PCB->RouteStyle[group].Hole, PCB->RouteStyle[group].Keepaway); + pcb_fprintf(FP, "%s,%mr,%mr,%mr,%mr\"]\n\n", PCB->RouteStyle[group].Name, + PCB->RouteStyle[group].Thick, + PCB->RouteStyle[group].Diameter, PCB->RouteStyle[group].Hole, PCB->RouteStyle[group].Keepaway); } /* --------------------------------------------------------------------------- * writes font data of non empty symbols */ -static void -WritePCBFontData (FILE * FP) +static void WritePCBFontData(FILE * FP) { - Cardinal i, j; - LineTypePtr line; - FontTypePtr font; + Cardinal i, j; + LineTypePtr line; + FontTypePtr font; - for (font = &PCB->Font, i = 0; i <= MAX_FONTPOSITION; i++) - { - if (!font->Symbol[i].Valid) - continue; + for (font = &PCB->Font, i = 0; i <= MAX_FONTPOSITION; i++) { + if (!font->Symbol[i].Valid) + continue; - if (isprint (i)) - pcb_fprintf (FP, "Symbol['%c' %mr]\n(\n", i, font->Symbol[i].Delta); - else - pcb_fprintf (FP, "Symbol[%i %mr]\n(\n", i, font->Symbol[i].Delta); + if (isprint(i)) + pcb_fprintf(FP, "Symbol['%c' %mr]\n(\n", i, font->Symbol[i].Delta); + else + pcb_fprintf(FP, "Symbol[%i %mr]\n(\n", i, font->Symbol[i].Delta); - line = font->Symbol[i].Line; - for (j = font->Symbol[i].LineN; j; j--, line++) - pcb_fprintf (FP, "\tSymbolLine[%mr %mr %mr %mr %mr]\n", - line->Point1.X, line->Point1.Y, - line->Point2.X, line->Point2.Y, line->Thickness); - fputs (")\n", FP); - } + line = font->Symbol[i].Line; + for (j = font->Symbol[i].LineN; j; j--, line++) + pcb_fprintf(FP, "\tSymbolLine[%mr %mr %mr %mr %mr]\n", + line->Point1.X, line->Point1.Y, line->Point2.X, line->Point2.Y, line->Thickness); + fputs(")\n", FP); + } } /* --------------------------------------------------------------------------- * writes via data */ -static void -WriteViaData (FILE * FP, DataTypePtr Data) +static void WriteViaData(FILE * FP, DataTypePtr Data) { - GList *iter; - /* write information about vias */ - for (iter = Data->Via; iter != NULL; iter = g_list_next (iter)) - { - PinType *via = iter->data; - pcb_fprintf (FP, "Via[%mr %mr %mr %mr %mr %mr ", via->X, via->Y, - via->Thickness, via->Clearance, via->Mask, via->DrillingHole); - PrintQuotedString (FP, (char *)EMPTY (via->Name)); - fprintf (FP, " %s]\n", F2S (via, VIA_TYPE)); - } + GList *iter; + /* write information about vias */ + for (iter = Data->Via; iter != NULL; iter = g_list_next(iter)) { + PinType *via = iter->data; + pcb_fprintf(FP, "Via[%mr %mr %mr %mr %mr %mr ", via->X, via->Y, + via->Thickness, via->Clearance, via->Mask, via->DrillingHole); + PrintQuotedString(FP, (char *) EMPTY(via->Name)); + fprintf(FP, " %s]\n", F2S(via, VIA_TYPE)); + } } /* --------------------------------------------------------------------------- * writes rat-line data */ -static void -WritePCBRatData (FILE * FP) +static void WritePCBRatData(FILE * FP) { - GList *iter; - /* write information about rats */ - for (iter = PCB->Data->Rat; iter != NULL; iter = g_list_next (iter)) - { - RatType *line = iter->data; - pcb_fprintf (FP, "Rat[%mr %mr %d %mr %mr %d ", - line->Point1.X, line->Point1.Y, line->group1, - line->Point2.X, line->Point2.Y, line->group2); - fprintf (FP, " %s]\n", F2S (line, RATLINE_TYPE)); - } + GList *iter; + /* write information about rats */ + for (iter = PCB->Data->Rat; iter != NULL; iter = g_list_next(iter)) { + RatType *line = iter->data; + pcb_fprintf(FP, "Rat[%mr %mr %d %mr %mr %d ", + line->Point1.X, line->Point1.Y, line->group1, line->Point2.X, line->Point2.Y, line->group2); + fprintf(FP, " %s]\n", F2S(line, RATLINE_TYPE)); + } } /* --------------------------------------------------------------------------- * writes netlist data */ -static void -WritePCBNetlistData (FILE * FP) +static void WritePCBNetlistData(FILE * FP) { - /* write out the netlist if it exists */ - if (PCB->NetlistLib[NETLIST_INPUT].MenuN) - { - int n, p; - fprintf (FP, "NetList()\n(\n"); + /* write out the netlist if it exists */ + if (PCB->NetlistLib[NETLIST_INPUT].MenuN) { + int n, p; + fprintf(FP, "NetList()\n(\n"); - for (n = 0; n < PCB->NetlistLib[NETLIST_INPUT].MenuN; n++) - { - LibraryMenuTypePtr menu = &PCB->NetlistLib[NETLIST_INPUT].Menu[n]; - fprintf (FP, "\tNet("); - PrintQuotedString(FP, &menu->Name[2]); - fprintf (FP, " "); - PrintQuotedString(FP, (char *)UNKNOWN (menu->Style)); - fprintf (FP, ")\n\t(\n"); - for (p = 0; p < menu->EntryN; p++) - { - LibraryEntryTypePtr entry = &menu->Entry[p]; - fprintf (FP, "\t\tConnect("); - PrintQuotedString (FP, entry->ListEntry); - fprintf (FP, ")\n"); - } - fprintf (FP, "\t)\n"); + for (n = 0; n < PCB->NetlistLib[NETLIST_INPUT].MenuN; n++) { + LibraryMenuTypePtr menu = &PCB->NetlistLib[NETLIST_INPUT].Menu[n]; + fprintf(FP, "\tNet("); + PrintQuotedString(FP, &menu->Name[2]); + fprintf(FP, " "); + PrintQuotedString(FP, (char *) UNKNOWN(menu->Style)); + fprintf(FP, ")\n\t(\n"); + for (p = 0; p < menu->EntryN; p++) { + LibraryEntryTypePtr entry = &menu->Entry[p]; + fprintf(FP, "\t\tConnect("); + PrintQuotedString(FP, entry->ListEntry); + fprintf(FP, ")\n"); + } + fprintf(FP, "\t)\n"); + } + fprintf(FP, ")\n"); } - fprintf (FP, ")\n"); - } } /* --------------------------------------------------------------------------- * writes netlist patch data */ -static void -WritePCBNetlistPatchData (FILE * FP) +static void WritePCBNetlistPatchData(FILE * FP) { if (PCB->NetlistPatches != NULL) { - fprintf (FP, "NetListPatch()\n(\n"); + fprintf(FP, "NetListPatch()\n(\n"); rats_patch_fexport(PCB, FP, 1); - fprintf (FP, ")\n"); + fprintf(FP, ")\n"); } } @@ -742,220 +685,182 @@ /* --------------------------------------------------------------------------- * writes element data */ -static void -WriteElementData (FILE * FP, DataTypePtr Data) +static void WriteElementData(FILE * FP, DataTypePtr Data) { - GList *n, *p; - for (n = Data->Element; n != NULL; n = g_list_next (n)) - { - ElementType *element = n->data; + GList *n, *p; + for (n = Data->Element; n != NULL; n = g_list_next(n)) { + ElementType *element = n->data; - /* only non empty elements */ - if (!element->LineN && !element->PinN && !element->ArcN - && !element->PadN) - continue; - /* the coordinates and text-flags are the same for - * both names of an element - */ - fprintf (FP, "\nElement[%s ", F2S (element, ELEMENT_TYPE)); - PrintQuotedString (FP, (char *)EMPTY (DESCRIPTION_NAME (element))); - fputc (' ', FP); - PrintQuotedString (FP, (char *)EMPTY (NAMEONPCB_NAME (element))); - fputc (' ', FP); - PrintQuotedString (FP, (char *)EMPTY (VALUE_NAME (element))); - pcb_fprintf (FP, " %mr %mr %mr %mr %d %d %s]\n(\n", - element->MarkX, element->MarkY, - DESCRIPTION_TEXT (element).X - element->MarkX, - DESCRIPTION_TEXT (element).Y - element->MarkY, - DESCRIPTION_TEXT (element).Direction, - DESCRIPTION_TEXT (element).Scale, - F2S (&(DESCRIPTION_TEXT (element)), ELEMENTNAME_TYPE)); - WriteAttributeList (FP, &element->Attributes, "\t"); - for (p = element->Pin; p != NULL; p = g_list_next (p)) - { - PinType *pin = p->data; - pcb_fprintf (FP, "\tPin[%mr %mr %mr %mr %mr %mr ", - pin->X - element->MarkX, - pin->Y - element->MarkY, - pin->Thickness, pin->Clearance, - pin->Mask, pin->DrillingHole); - PrintQuotedString (FP, (char *)EMPTY (pin->Name)); - fprintf (FP, " "); - PrintQuotedString (FP, (char *)EMPTY (pin->Number)); - fprintf (FP, " %s]\n", F2S (pin, PIN_TYPE)); + /* only non empty elements */ + if (!element->LineN && !element->PinN && !element->ArcN && !element->PadN) + continue; + /* the coordinates and text-flags are the same for + * both names of an element + */ + fprintf(FP, "\nElement[%s ", F2S(element, ELEMENT_TYPE)); + PrintQuotedString(FP, (char *) EMPTY(DESCRIPTION_NAME(element))); + fputc(' ', FP); + PrintQuotedString(FP, (char *) EMPTY(NAMEONPCB_NAME(element))); + fputc(' ', FP); + PrintQuotedString(FP, (char *) EMPTY(VALUE_NAME(element))); + pcb_fprintf(FP, " %mr %mr %mr %mr %d %d %s]\n(\n", + element->MarkX, element->MarkY, + DESCRIPTION_TEXT(element).X - element->MarkX, + DESCRIPTION_TEXT(element).Y - element->MarkY, + DESCRIPTION_TEXT(element).Direction, + DESCRIPTION_TEXT(element).Scale, F2S(&(DESCRIPTION_TEXT(element)), ELEMENTNAME_TYPE)); + WriteAttributeList(FP, &element->Attributes, "\t"); + for (p = element->Pin; p != NULL; p = g_list_next(p)) { + PinType *pin = p->data; + pcb_fprintf(FP, "\tPin[%mr %mr %mr %mr %mr %mr ", + pin->X - element->MarkX, + pin->Y - element->MarkY, pin->Thickness, pin->Clearance, pin->Mask, pin->DrillingHole); + PrintQuotedString(FP, (char *) EMPTY(pin->Name)); + fprintf(FP, " "); + PrintQuotedString(FP, (char *) EMPTY(pin->Number)); + fprintf(FP, " %s]\n", F2S(pin, PIN_TYPE)); + } + for (p = element->Pad; p != NULL; p = g_list_next(p)) { + PadType *pad = p->data; + pcb_fprintf(FP, "\tPad[%mr %mr %mr %mr %mr %mr %mr ", + pad->Point1.X - element->MarkX, + pad->Point1.Y - element->MarkY, + pad->Point2.X - element->MarkX, pad->Point2.Y - element->MarkY, pad->Thickness, pad->Clearance, pad->Mask); + PrintQuotedString(FP, (char *) EMPTY(pad->Name)); + fprintf(FP, " "); + PrintQuotedString(FP, (char *) EMPTY(pad->Number)); + fprintf(FP, " %s]\n", F2S(pad, PAD_TYPE)); + } + for (p = element->Line; p != NULL; p = g_list_next(p)) { + LineType *line = p->data; + pcb_fprintf(FP, "\tElementLine [%mr %mr %mr %mr %mr]\n", + line->Point1.X - element->MarkX, + line->Point1.Y - element->MarkY, + line->Point2.X - element->MarkX, line->Point2.Y - element->MarkY, line->Thickness); + } + for (p = element->Arc; p != NULL; p = g_list_next(p)) { + ArcType *arc = p->data; + pcb_fprintf(FP, "\tElementArc [%mr %mr %mr %mr %ma %ma %mr]\n", + arc->X - element->MarkX, + arc->Y - element->MarkY, arc->Width, arc->Height, arc->StartAngle, arc->Delta, arc->Thickness); + } + fputs("\n\t)\n", FP); } - for (p = element->Pad; p != NULL; p = g_list_next (p)) - { - PadType *pad = p->data; - pcb_fprintf (FP, "\tPad[%mr %mr %mr %mr %mr %mr %mr ", - pad->Point1.X - element->MarkX, - pad->Point1.Y - element->MarkY, - pad->Point2.X - element->MarkX, - pad->Point2.Y - element->MarkY, - pad->Thickness, pad->Clearance, pad->Mask); - PrintQuotedString (FP, (char *)EMPTY (pad->Name)); - fprintf (FP, " "); - PrintQuotedString (FP, (char *)EMPTY (pad->Number)); - fprintf (FP, " %s]\n", F2S (pad, PAD_TYPE)); - } - for (p = element->Line; p != NULL; p = g_list_next (p)) - { - LineType *line = p->data; - pcb_fprintf (FP, "\tElementLine [%mr %mr %mr %mr %mr]\n", - line->Point1.X - element->MarkX, - line->Point1.Y - element->MarkY, - line->Point2.X - element->MarkX, - line->Point2.Y - element->MarkY, - line->Thickness); - } - for (p = element->Arc; p != NULL; p = g_list_next (p)) - { - ArcType *arc = p->data; - pcb_fprintf (FP, "\tElementArc [%mr %mr %mr %mr %ma %ma %mr]\n", - arc->X - element->MarkX, - arc->Y - element->MarkY, - arc->Width, arc->Height, - arc->StartAngle, arc->Delta, - arc->Thickness); - } - fputs ("\n\t)\n", FP); - } } /* --------------------------------------------------------------------------- * writes layer data */ -static void -WriteLayerData (FILE * FP, Cardinal Number, LayerTypePtr layer) +static void WriteLayerData(FILE * FP, Cardinal Number, LayerTypePtr layer) { - GList *n; - /* write information about non empty layers */ - if (layer->LineN || layer->ArcN || layer->TextN || layer->PolygonN || - (layer->Name && *layer->Name)) - { - fprintf (FP, "Layer(%i ", (int) Number + 1); - PrintQuotedString (FP, (char *)EMPTY (layer->Name)); - fputs (")\n(\n", FP); - WriteAttributeList (FP, &layer->Attributes, "\t"); + GList *n; + /* write information about non empty layers */ + if (layer->LineN || layer->ArcN || layer->TextN || layer->PolygonN || (layer->Name && *layer->Name)) { + fprintf(FP, "Layer(%i ", (int) Number + 1); + PrintQuotedString(FP, (char *) EMPTY(layer->Name)); + fputs(")\n(\n", FP); + WriteAttributeList(FP, &layer->Attributes, "\t"); - for (n = layer->Line; n != NULL; n = g_list_next (n)) - { - LineType *line = n->data; - pcb_fprintf (FP, "\tLine[%mr %mr %mr %mr %mr %mr %s]\n", - line->Point1.X, line->Point1.Y, - line->Point2.X, line->Point2.Y, - line->Thickness, line->Clearance, - F2S (line, LINE_TYPE)); - } - for (n = layer->Arc; n != NULL; n = g_list_next (n)) - { - ArcType *arc = n->data; - pcb_fprintf (FP, "\tArc[%mr %mr %mr %mr %mr %mr %ma %ma %s]\n", - arc->X, arc->Y, arc->Width, - arc->Height, arc->Thickness, - arc->Clearance, arc->StartAngle, - arc->Delta, F2S (arc, ARC_TYPE)); - } - for (n = layer->Text; n != NULL; n = g_list_next (n)) - { - TextType *text = n->data; - pcb_fprintf (FP, "\tText[%mr %mr %d %d ", - text->X, text->Y, - text->Direction, text->Scale); - PrintQuotedString (FP, (char *)EMPTY (text->TextString)); - fprintf (FP, " %s]\n", F2S (text, TEXT_TYPE)); - } - for (n = layer->Polygon; n != NULL; n = g_list_next (n)) - { - PolygonType *polygon = n->data; - int p, i = 0; - Cardinal hole = 0; - fprintf (FP, "\tPolygon(%s)\n\t(", F2S (polygon, POLYGON_TYPE)); - for (p = 0; p < polygon->PointN; p++) - { - PointTypePtr point = &polygon->Points[p]; - - if (hole < polygon->HoleIndexN && - p == polygon->HoleIndex[hole]) - { - if (hole > 0) - fputs ("\n\t\t)", FP); - fputs ("\n\t\tHole (", FP); - hole++; - i = 0; + for (n = layer->Line; n != NULL; n = g_list_next(n)) { + LineType *line = n->data; + pcb_fprintf(FP, "\tLine[%mr %mr %mr %mr %mr %mr %s]\n", + line->Point1.X, line->Point1.Y, + line->Point2.X, line->Point2.Y, line->Thickness, line->Clearance, F2S(line, LINE_TYPE)); } + for (n = layer->Arc; n != NULL; n = g_list_next(n)) { + ArcType *arc = n->data; + pcb_fprintf(FP, "\tArc[%mr %mr %mr %mr %mr %mr %ma %ma %s]\n", + arc->X, arc->Y, arc->Width, + arc->Height, arc->Thickness, arc->Clearance, arc->StartAngle, arc->Delta, F2S(arc, ARC_TYPE)); + } + for (n = layer->Text; n != NULL; n = g_list_next(n)) { + TextType *text = n->data; + pcb_fprintf(FP, "\tText[%mr %mr %d %d ", text->X, text->Y, text->Direction, text->Scale); + PrintQuotedString(FP, (char *) EMPTY(text->TextString)); + fprintf(FP, " %s]\n", F2S(text, TEXT_TYPE)); + } + for (n = layer->Polygon; n != NULL; n = g_list_next(n)) { + PolygonType *polygon = n->data; + int p, i = 0; + Cardinal hole = 0; + fprintf(FP, "\tPolygon(%s)\n\t(", F2S(polygon, POLYGON_TYPE)); + for (p = 0; p < polygon->PointN; p++) { + PointTypePtr point = &polygon->Points[p]; - if (i++ % 5 == 0) - { - fputs ("\n\t\t", FP); - if (hole) - fputs ("\t", FP); + if (hole < polygon->HoleIndexN && p == polygon->HoleIndex[hole]) { + if (hole > 0) + fputs("\n\t\t)", FP); + fputs("\n\t\tHole (", FP); + hole++; + i = 0; + } + + if (i++ % 5 == 0) { + fputs("\n\t\t", FP); + if (hole) + fputs("\t", FP); + } + pcb_fprintf(FP, "[%mr %mr] ", point->X, point->Y); + } + if (hole > 0) + fputs("\n\t\t)", FP); + fputs("\n\t)\n", FP); } - pcb_fprintf (FP, "[%mr %mr] ", point->X, point->Y); - } - if (hole > 0) - fputs ("\n\t\t)", FP); - fputs ("\n\t)\n", FP); + fputs(")\n", FP); } - fputs (")\n", FP); - } } /* --------------------------------------------------------------------------- * writes just the elements in the buffer to file */ -static int -WriteBuffer (FILE * FP) +static int WriteBuffer(FILE * FP) { - Cardinal i; + Cardinal i; - WriteViaData (FP, PASTEBUFFER->Data); - WriteElementData (FP, PASTEBUFFER->Data); - for (i = 0; i < max_copper_layer + 2; i++) - WriteLayerData (FP, i, &(PASTEBUFFER->Data->Layer[i])); - return (STATUS_OK); + WriteViaData(FP, PASTEBUFFER->Data); + WriteElementData(FP, PASTEBUFFER->Data); + for (i = 0; i < max_copper_layer + 2; i++) + WriteLayerData(FP, i, &(PASTEBUFFER->Data->Layer[i])); + return (STATUS_OK); } /* --------------------------------------------------------------------------- * writes PCB to file */ -static int -WritePCB (FILE * FP) +static int WritePCB(FILE * FP) { - Cardinal i; + Cardinal i; - WritePCBInfoHeader (FP); - WritePCBDataHeader (FP); - WritePCBFontData (FP); - WriteAttributeList (FP, &PCB->Attributes, ""); - WriteViaData (FP, PCB->Data); - WriteElementData (FP, PCB->Data); - WritePCBRatData (FP); - for (i = 0; i < max_copper_layer + 2; i++) - WriteLayerData (FP, i, &(PCB->Data->Layer[i])); - WritePCBNetlistData (FP); - WritePCBNetlistPatchData (FP); + WritePCBInfoHeader(FP); + WritePCBDataHeader(FP); + WritePCBFontData(FP); + WriteAttributeList(FP, &PCB->Attributes, ""); + WriteViaData(FP, PCB->Data); + WriteElementData(FP, PCB->Data); + WritePCBRatData(FP); + for (i = 0; i < max_copper_layer + 2; i++) + WriteLayerData(FP, i, &(PCB->Data->Layer[i])); + WritePCBNetlistData(FP); + WritePCBNetlistPatchData(FP); - return (STATUS_OK); + return (STATUS_OK); } /* --------------------------------------------------------------------------- * writes PCB to file */ -static int -WritePCBFile (char *Filename) +static int WritePCBFile(char *Filename) { - FILE *fp; - int result; + FILE *fp; + int result; - if ((fp = fopen (Filename, "w")) == NULL) - { - OpenErrorMessage (Filename); - return (STATUS_ERROR); - } - result = WritePCB (fp); - fclose (fp); - return (result); + if ((fp = fopen(Filename, "w")) == NULL) { + OpenErrorMessage(Filename); + return (STATUS_ERROR); + } + result = WritePCB(fp); + fclose(fp); + return (result); } /* --------------------------------------------------------------------------- @@ -962,66 +867,57 @@ * writes to pipe using the command defined by Settings.SaveCommand * %f are replaced by the passed filename */ -static int -WritePipe (char *Filename, bool thePcb) +static int WritePipe(char *Filename, bool thePcb) { - FILE *fp; - int result; - char *p; - static DynamicStringType command; - int used_popen = 0; + FILE *fp; + int result; + char *p; + static DynamicStringType command; + int used_popen = 0; - if (EMPTY_STRING_P (Settings.SaveCommand)) - { - fp = fopen (Filename, "w"); - if (fp == 0) - { - Message ("Unable to write to file %s\n", Filename); - return STATUS_ERROR; + if (EMPTY_STRING_P(Settings.SaveCommand)) { + fp = fopen(Filename, "w"); + if (fp == 0) { + Message("Unable to write to file %s\n", Filename); + return STATUS_ERROR; + } } - } - else - { - used_popen = 1; - /* setup commandline */ - DSClearString (&command); - for (p = Settings.SaveCommand; *p; p++) - { - /* copy character if not special or add string to command */ - if (!(*p == '%' && *(p + 1) == 'f')) - DSAddCharacter (&command, *p); - else - { - DSAddString (&command, Filename); + else { + used_popen = 1; + /* setup commandline */ + DSClearString(&command); + for (p = Settings.SaveCommand; *p; p++) { + /* copy character if not special or add string to command */ + if (!(*p == '%' && *(p + 1) == 'f')) + DSAddCharacter(&command, *p); + else { + DSAddString(&command, Filename); - /* skip the character */ - p++; - } + /* skip the character */ + p++; + } + } + DSAddCharacter(&command, '\0'); + printf("write to pipe \"%s\"\n", command.Data); + if ((fp = popen(command.Data, "w")) == NULL) { + PopenErrorMessage(command.Data); + return (STATUS_ERROR); + } } - DSAddCharacter (&command, '\0'); - printf ("write to pipe \"%s\"\n", command.Data); - if ((fp = popen (command.Data, "w")) == NULL) - { - PopenErrorMessage (command.Data); - return (STATUS_ERROR); + if (thePcb) { + if (PCB->is_footprint) { + WriteElementData(fp, PCB->Data); + result = 0; + } + else + result = WritePCB(fp); } - } - if (thePcb) - { - if (PCB->is_footprint) - { - WriteElementData (fp, PCB->Data); - result = 0; - } - else - result = WritePCB (fp); - } - else - result = WriteBuffer (fp); + else + result = WriteBuffer(fp); - if (used_popen) - return (pclose (fp) ? STATUS_ERROR : result); - return (fclose (fp) ? STATUS_ERROR : result); + if (used_popen) + return (pclose(fp) ? STATUS_ERROR : result); + return (fclose(fp) ? STATUS_ERROR : result); } /* --------------------------------------------------------------------------- @@ -1029,18 +925,16 @@ * this is used for fatal errors and does not call the program specified * in 'saveCommand' for safety reasons */ -void -SaveInTMP (void) +void SaveInTMP(void) { - char filename[80]; + char filename[80]; - /* memory might have been released before this function is called */ - if (PCB && PCB->Changed) - { - sprintf (filename, EMERGENCY_NAME, (int) getpid ()); - Message (_("Trying to save your layout in '%s'\n"), filename); - WritePCBFile (filename); - } + /* memory might have been released before this function is called */ + if (PCB && PCB->Changed) { + sprintf(filename, EMERGENCY_NAME, (int) getpid()); + Message(_("Trying to save your layout in '%s'\n"), filename); + WritePCBFile(filename); + } } /* --------------------------------------------------------------------------- @@ -1048,21 +942,18 @@ * just makes sure that the routine is only called once */ static bool dont_save_any_more = false; -void -EmergencySave (void) +void EmergencySave(void) { - if (!dont_save_any_more) - { - SaveInTMP (); - dont_save_any_more = true; - } + if (!dont_save_any_more) { + SaveInTMP(); + dont_save_any_more = true; + } } - void -DisableEmergencySave (void) +void DisableEmergencySave(void) { - dont_save_any_more = true; + dont_save_any_more = true; } /* ---------------------------------------------------------------------- @@ -1076,33 +967,28 @@ * we do nothing and it is up to the GUI to call EnableAutosave() * after setting Settings.BackupInterval > 0 again. */ -static void -backup_cb (hidval data) +static void backup_cb(hidval data) { - backup_timer.ptr = NULL; - Backup (); - if (Settings.BackupInterval > 0 && gui->add_timer) - backup_timer = gui->add_timer (backup_cb, - 1000 * Settings.BackupInterval, data); + backup_timer.ptr = NULL; + Backup(); + if (Settings.BackupInterval > 0 && gui->add_timer) + backup_timer = gui->add_timer(backup_cb, 1000 * Settings.BackupInterval, data); } -void -EnableAutosave (void) +void EnableAutosave(void) { - hidval x; + hidval x; - x.ptr = NULL; + x.ptr = NULL; - /* If we already have a timer going, then cancel it out */ - if (backup_timer.ptr != NULL && gui->stop_timer) - gui->stop_timer (backup_timer); + /* If we already have a timer going, then cancel it out */ + if (backup_timer.ptr != NULL && gui->stop_timer) + gui->stop_timer(backup_timer); - backup_timer.ptr = NULL; - /* Start up a new timer */ - if (Settings.BackupInterval > 0 && gui->add_timer) - backup_timer = gui->add_timer (backup_cb, - 1000 * Settings.BackupInterval, - x); + backup_timer.ptr = NULL; + /* Start up a new timer */ + if (Settings.BackupInterval > 0 && gui->add_timer) + backup_timer = gui->add_timer(backup_cb, 1000 * Settings.BackupInterval, x); } /* --------------------------------------------------------------------------- @@ -1110,35 +996,30 @@ * a "-" appended (like "foo.pcb-") and if we don't have a pcb file name * then use the template in BACKUP_NAME */ -void -Backup (void) +void Backup(void) { - char *filename = NULL; + char *filename = NULL; - if( PCB && PCB->Filename ) - { - filename = (char *) malloc (sizeof (char) * (strlen (PCB->Filename) + 2)); - if (filename == NULL) - { - fprintf (stderr, "Backup(): malloc failed\n"); - exit (1); + if (PCB && PCB->Filename) { + filename = (char *) malloc(sizeof(char) * (strlen(PCB->Filename) + 2)); + if (filename == NULL) { + fprintf(stderr, "Backup(): malloc failed\n"); + exit(1); + } + sprintf(filename, "%s-", PCB->Filename); } - sprintf (filename, "%s-", PCB->Filename); - } - else - { - /* BACKUP_NAME has %.8i which will be replaced by the process ID */ - filename = (char *) malloc (sizeof (char) * (strlen (BACKUP_NAME) + 8)); - if (filename == NULL) - { - fprintf (stderr, "Backup(): malloc failed\n"); - exit (1); + else { + /* BACKUP_NAME has %.8i which will be replaced by the process ID */ + filename = (char *) malloc(sizeof(char) * (strlen(BACKUP_NAME) + 8)); + if (filename == NULL) { + fprintf(stderr, "Backup(): malloc failed\n"); + exit(1); + } + sprintf(filename, BACKUP_NAME, (int) getpid()); } - sprintf (filename, BACKUP_NAME, (int) getpid ()); - } - WritePCBFile (filename); - free (filename); + WritePCBFile(filename); + free(filename); } #if !defined(HAS_ATEXIT) && !defined(HAS_ON_EXIT) @@ -1148,20 +1029,18 @@ * before LEX and YACC functions are called because they are able to abort * the program. */ -void -SaveTMPData (void) +void SaveTMPData(void) { - sprintf (TMPFilename, EMERGENCY_NAME, (int) getpid ()); - WritePCBFile (TMPFilename); + sprintf(TMPFilename, EMERGENCY_NAME, (int) getpid()); + WritePCBFile(TMPFilename); } /* --------------------------------------------------------------------------- * removes the temporary copy of the data file */ -void -RemoveTMPData (void) +void RemoveTMPData(void) { - unlink (TMPFilename); + unlink(TMPFilename); } #endif @@ -1170,13 +1049,12 @@ */ /* Helper function for ParseLibraryTree */ -static const char * -pcb_basename (const char *p) +static const char *pcb_basename(const char *p) { - char *rv = strrchr (p, '/'); - if (rv) - return rv + 1; - return p; + char *rv = strrchr(p, '/'); + if (rv) + return rv + 1; + return p; } typedef struct list_dir_s list_dir_t; @@ -1196,8 +1074,8 @@ static int list_cb(void *cookie, const char *subdir, const char *name, pcb_fp_type_t type, void *tags[]) { - list_st_t *l = (list_st_t *)cookie; - LibraryEntryTypePtr entry; /* Pointer to individual menu entry */ + list_st_t *l = (list_st_t *) cookie; + LibraryEntryTypePtr entry; /* Pointer to individual menu entry */ size_t len; if (type == PCB_FP_DIR) { @@ -1214,7 +1092,7 @@ } l->children++; - entry = GetLibraryEntryMemory (l->menu); + entry = GetLibraryEntryMemory(l->menu); /* * entry->AllocatedMemory points to abs path to the footprint. @@ -1221,16 +1099,15 @@ * entry->ListEntry points to fp name itself. */ len = strlen(subdir) + strlen("/") + strlen(name) + 8; - entry->AllocatedMemory = (char *)calloc (1, len); - strcat (entry->AllocatedMemory, subdir); - strcat (entry->AllocatedMemory, PCB_DIR_SEPARATOR_S); + entry->AllocatedMemory = (char *) calloc(1, len); + strcat(entry->AllocatedMemory, subdir); + strcat(entry->AllocatedMemory, PCB_DIR_SEPARATOR_S); /* store pointer to start of footprint name */ - entry->ListEntry = entry->AllocatedMemory - + strlen (entry->AllocatedMemory); + entry->ListEntry = entry->AllocatedMemory + strlen(entry->AllocatedMemory); /* Now place footprint name into AllocatedMemory */ - strcat (entry->AllocatedMemory, name); + strcat(entry->AllocatedMemory, name); if (type == PCB_FP_PARAMETRIC) strcat(entry->AllocatedMemory, "()"); @@ -1244,34 +1121,34 @@ static int LoadNewlibFootprintsFromDir(const char *subdir, const char *toppath, int is_root) { - LibraryMenuTypePtr menu = NULL; /* Pointer to PCB's library menu structure */ + LibraryMenuTypePtr menu = NULL; /* Pointer to PCB's library menu structure */ list_st_t l; list_dir_t *d, *nextd; - char working_[MAXPATHLEN + 1]; - char *working; /* String holding abs path to working dir */ + char working_[MAXPATHLEN + 1]; + char *working; /* String holding abs path to working dir */ int menuidx; - sprintf(working_, "%s%c%s", toppath, PCB_DIR_SEPARATOR_C, subdir); + sprintf(working_, "%s%c%s", toppath, PCB_DIR_SEPARATOR_C, subdir); resolve_path(working_, &working); - /* Get pointer to memory holding menu */ - menu = GetLibraryMenuMemory (&Library, &menuidx); + /* Get pointer to memory holding menu */ + menu = GetLibraryMenuMemory(&Library, &menuidx); - /* Populate menuname and path vars */ - menu->Name = strdup (pcb_basename(subdir)); - menu->directory = strdup (pcb_basename(toppath)); + /* Populate menuname and path vars */ + menu->Name = strdup(pcb_basename(subdir)); + menu->directory = strdup(pcb_basename(toppath)); - l.menu = menu; - l.subdirs = NULL; + l.menu = menu; + l.subdirs = NULL; l.children = 0; - pcb_fp_list(working, 0, list_cb, &l, is_root, 1); + pcb_fp_list(working, 0, list_cb, &l, is_root, 1); /* now recurse to each subdirectory mapped in the previous call; by now we don't care if menu is ruined by the realloc() in GetLibraryMenuMemory() */ - for(d = l.subdirs; d != NULL; d = nextd) { - l.children+=LoadNewlibFootprintsFromDir(d->subdir, d->parent, 0); + for (d = l.subdirs; d != NULL; d = nextd) { + l.children += LoadNewlibFootprintsFromDir(d->subdir, d->parent, 0); nextd = d->next; free(d->subdir); free(d->parent); @@ -1278,7 +1155,7 @@ free(d); } if (l.children == 0) { - DeleteLibraryMenuMemory (&Library, menuidx); + DeleteLibraryMenuMemory(&Library, menuidx); } free(working); return l.children; @@ -1293,64 +1170,59 @@ * LoadNewlibFootprintsFromDir to put the footprints into PCB's internal * datastructures. */ -static int -ParseLibraryTree (void) +static int ParseLibraryTree(void) { - char toppath[MAXPATHLEN + 1]; /* String holding abs path to top level library dir */ - char *libpaths; /* String holding list of library paths to search */ - char *p; /* Helper string used in iteration */ - DIR *dirobj; /* Iterable directory object */ - struct dirent *direntry = NULL; /* Object holding individual directory entries */ - struct stat buffer; /* buffer used in stat */ - int n_footprints = 0; /* Running count of footprints found */ + char toppath[MAXPATHLEN + 1]; /* String holding abs path to top level library dir */ + char *libpaths; /* String holding list of library paths to search */ + char *p; /* Helper string used in iteration */ + DIR *dirobj; /* Iterable directory object */ + struct dirent *direntry = NULL; /* Object holding individual directory entries */ + struct stat buffer; /* buffer used in stat */ + int n_footprints = 0; /* Running count of footprints found */ - /* Initialize path, working by writing 0 into every byte. */ - memset (toppath, 0, sizeof toppath); + /* Initialize path, working by writing 0 into every byte. */ + memset(toppath, 0, sizeof toppath); - /* Additional loop to allow for multiple 'newlib' style library directories - * called out in Settings.LibraryTree - */ - libpaths = strdup (Settings.LibrarySearchPaths); - for (p = strtok (libpaths, PCB_PATH_DELIMETER); p && *p; p = strtok (NULL, PCB_PATH_DELIMETER)) - { - /* remove trailing path delimeter */ - strncpy (toppath, p, sizeof (toppath) - 1); + /* Additional loop to allow for multiple 'newlib' style library directories + * called out in Settings.LibraryTree + */ + libpaths = strdup(Settings.LibrarySearchPaths); + for (p = strtok(libpaths, PCB_PATH_DELIMETER); p && *p; p = strtok(NULL, PCB_PATH_DELIMETER)) { + /* remove trailing path delimeter */ + strncpy(toppath, p, sizeof(toppath) - 1); #ifdef DEBUG - printf("In ParseLibraryTree, looking for newlib footprints inside top level directory %s ... \n", - toppath); + printf("In ParseLibraryTree, looking for newlib footprints inside top level directory %s ... \n", toppath); #endif - /* Next read in any footprints in the top level dir */ - n_footprints += LoadNewlibFootprintsFromDir(".", toppath, 1); - } + /* Next read in any footprints in the top level dir */ + n_footprints += LoadNewlibFootprintsFromDir(".", toppath, 1); + } #ifdef DEBUG - printf("Leaving ParseLibraryTree, found %d footprints.\n", n_footprints); + printf("Leaving ParseLibraryTree, found %d footprints.\n", n_footprints); #endif - return n_footprints; + return n_footprints; } -int -ReadLibraryContents (void) +int ReadLibraryContents(void) { - static char *command = NULL; - char inputline[MAX_LIBRARY_LINE_LENGTH + 1]; - FILE *resultFP = NULL; - LibraryMenuTypePtr menu = NULL; - LibraryEntryTypePtr entry; + static char *command = NULL; + char inputline[MAX_LIBRARY_LINE_LENGTH + 1]; + FILE *resultFP = NULL; + LibraryMenuTypePtr menu = NULL; + LibraryEntryTypePtr entry; - /* List all footprint libraries. Then sort the whole - * library. - */ - if (ParseLibraryTree () > 0 || resultFP != NULL) - { - sort_library (&Library); - return 0; - } - - return (1); + /* List all footprint libraries. Then sort the whole + * library. + */ + if (ParseLibraryTree() > 0 || resultFP != NULL) { + sort_library(&Library); + return 0; + } + + return (1); } #define BLANK(x) ((x) == ' ' || (x) == '\t' || (x) == '\n' \ @@ -1360,159 +1232,145 @@ * Read in a netlist and store it in the netlist menu */ -int -ReadNetlist (char *filename) +int ReadNetlist(char *filename) { - static char *command = NULL; - char inputline[MAX_NETLIST_LINE_LENGTH + 1]; - char temp[MAX_NETLIST_LINE_LENGTH + 1]; - FILE *fp; - LibraryMenuTypePtr menu = NULL; - LibraryEntryTypePtr entry; - int i, j, lines, kind; - bool continued; - int used_popen = 0; + static char *command = NULL; + char inputline[MAX_NETLIST_LINE_LENGTH + 1]; + char temp[MAX_NETLIST_LINE_LENGTH + 1]; + FILE *fp; + LibraryMenuTypePtr menu = NULL; + LibraryEntryTypePtr entry; + int i, j, lines, kind; + bool continued; + int used_popen = 0; - if (!filename) - return (1); /* nothing to do */ + if (!filename) + return (1); /* nothing to do */ - Message (_("Importing PCB netlist %s\n"), filename); + Message(_("Importing PCB netlist %s\n"), filename); - if (EMPTY_STRING_P (Settings.RatCommand)) - { - fp = fopen (filename, "r"); - if (!fp) - { - Message("Cannot open %s for reading", filename); - return 1; + if (EMPTY_STRING_P(Settings.RatCommand)) { + fp = fopen(filename, "r"); + if (!fp) { + Message("Cannot open %s for reading", filename); + return 1; + } } - } - else - { - used_popen = 1; - free (command); - command = EvaluateFilename (Settings.RatCommand, - Settings.RatPath, filename, NULL); + else { + used_popen = 1; + free(command); + command = EvaluateFilename(Settings.RatCommand, Settings.RatPath, filename, NULL); - /* open pipe to stdout of command */ - if (*command == '\0' || (fp = popen (command, "r")) == NULL) - { - PopenErrorMessage (command); - return (1); + /* open pipe to stdout of command */ + if (*command == '\0' || (fp = popen(command, "r")) == NULL) { + PopenErrorMessage(command); + return (1); + } } - } - lines = 0; - /* kind = 0 is net name - * kind = 1 is route style name - * kind = 2 is connection - */ - kind = 0; - while (fgets (inputline, MAX_NETLIST_LINE_LENGTH, fp)) - { - size_t len = strlen (inputline); - /* check for maximum length line */ - if (len) - { - if (inputline[--len] != '\n') - Message (_("Line length (%i) exceeded in netlist file.\n" - "additional characters will be ignored.\n"), - MAX_NETLIST_LINE_LENGTH); - else - inputline[len] = '\0'; - } - continued = (inputline[len - 1] == '\\') ? true : false; - if (continued) - inputline[len - 1] = '\0'; - lines++; - i = 0; - while (inputline[i] != '\0') - { - j = 0; - /* skip leading blanks */ - while (inputline[i] != '\0' && BLANK (inputline[i])) - i++; - if (kind == 0) - { - /* add two spaces for included/unincluded */ - temp[j++] = ' '; - temp[j++] = ' '; - } - while (!BLANK (inputline[i])) - temp[j++] = inputline[i++]; - temp[j] = '\0'; - while (inputline[i] != '\0' && BLANK (inputline[i])) - i++; - if (kind == 0) - { - menu = GetLibraryMenuMemory (&PCB->NetlistLib[NETLIST_INPUT], NULL); - menu->Name = strdup (temp); - menu->flag = 1; - kind++; - } - else - { - if (kind == 1 && strchr (temp, '-') == NULL) - { - kind++; - menu->Style = strdup (temp); + lines = 0; + /* kind = 0 is net name + * kind = 1 is route style name + * kind = 2 is connection + */ + kind = 0; + while (fgets(inputline, MAX_NETLIST_LINE_LENGTH, fp)) { + size_t len = strlen(inputline); + /* check for maximum length line */ + if (len) { + if (inputline[--len] != '\n') + Message(_("Line length (%i) exceeded in netlist file.\n" + "additional characters will be ignored.\n"), MAX_NETLIST_LINE_LENGTH); + else + inputline[len] = '\0'; } - else - { - entry = GetLibraryEntryMemory (menu); - entry->ListEntry = strdup (temp); + continued = (inputline[len - 1] == '\\') ? true : false; + if (continued) + inputline[len - 1] = '\0'; + lines++; + i = 0; + while (inputline[i] != '\0') { + j = 0; + /* skip leading blanks */ + while (inputline[i] != '\0' && BLANK(inputline[i])) + i++; + if (kind == 0) { + /* add two spaces for included/unincluded */ + temp[j++] = ' '; + temp[j++] = ' '; + } + while (!BLANK(inputline[i])) + temp[j++] = inputline[i++]; + temp[j] = '\0'; + while (inputline[i] != '\0' && BLANK(inputline[i])) + i++; + if (kind == 0) { + menu = GetLibraryMenuMemory(&PCB->NetlistLib[NETLIST_INPUT], NULL); + menu->Name = strdup(temp); + menu->flag = 1; + kind++; + } + else { + if (kind == 1 && strchr(temp, '-') == NULL) { + kind++; + menu->Style = strdup(temp); + } + else { + entry = GetLibraryEntryMemory(menu); + entry->ListEntry = strdup(temp); + } + } } - } + if (!continued) + kind = 0; } - if (!continued) - kind = 0; - } - if (!lines) - { - Message (_("Empty netlist file!\n")); - pclose (fp); - return (1); - } - if (used_popen) - pclose (fp); - else - fclose (fp); - sort_netlist (); - rats_patch_make_edited(PCB); - return (0); + if (!lines) { + Message(_("Empty netlist file!\n")); + pclose(fp); + return (1); + } + if (used_popen) + pclose(fp); + else + fclose(fp); + sort_netlist(); + rats_patch_make_edited(PCB); + return (0); } -static int ReadEdifNetlist (char *filename); +static int ReadEdifNetlist(char *filename); -int ImportNetlist (char *filename) +int ImportNetlist(char *filename) { - FILE *fp; - char buf[16]; - int i; - char* p; - + FILE *fp; + char buf[16]; + int i; + char *p; - if (!filename) return (1); /* nothing to do */ - fp = fopen (filename, "r"); - if (!fp) return (1); /* bad filename */ - i = fread (buf, 1, sizeof(buf)-1, fp); - fclose(fp); - buf[i] = '\0'; - p=buf; - while ( *p ) - { - *p = tolower ((int) *p); - p++; - } - p = strstr (buf, "edif"); - if (!p) return ReadNetlist (filename); - else return ReadEdifNetlist (filename); + + if (!filename) + return (1); /* nothing to do */ + fp = fopen(filename, "r"); + if (!fp) + return (1); /* bad filename */ + i = fread(buf, 1, sizeof(buf) - 1, fp); + fclose(fp); + buf[i] = '\0'; + p = buf; + while (*p) { + *p = tolower((int) *p); + p++; + } + p = strstr(buf, "edif"); + if (!p) + return ReadNetlist(filename); + else + return ReadEdifNetlist(filename); } -static int ReadEdifNetlist (char *filename) +static int ReadEdifNetlist(char *filename) { - Message (_("Importing edif netlist %s\n"), filename); - ParseEDIF(filename, NULL); - - return 0; + Message(_("Importing edif netlist %s\n"), filename); + ParseEDIF(filename, NULL); + + return 0; } - Index: trunk/src/file.h =================================================================== --- trunk/src/file.h (revision 1021) +++ trunk/src/file.h (revision 1022) @@ -30,25 +30,25 @@ #ifndef PCB_FILE_H #define PCB_FILE_H -#include /* needed to define 'FILE *' */ +#include /* needed to define 'FILE *' */ #include "global.h" -FILE *CheckAndOpenFile (char *, bool, bool, bool *, bool *); -FILE *OpenConnectionDataFile (void); -int SavePCB (char *); -int LoadPCB (char *, bool); -int RevertPCB (void); -void EnableAutosave (void); -void Backup (void); -void SaveInTMP (void); -void EmergencySave (void); -void DisableEmergencySave (void); -int ReadLibraryContents (void); /* walk through all lib paths and build the library menu */ -int ImportNetlist (char *); -int SaveBufferElements (char *); -void PreLoadElementPCB (void); -void PostLoadElementPCB (void); -void sort_netlist (void); +FILE *CheckAndOpenFile(char *, bool, bool, bool *, bool *); +FILE *OpenConnectionDataFile(void); +int SavePCB(char *); +int LoadPCB(char *, bool); +int RevertPCB(void); +void EnableAutosave(void); +void Backup(void); +void SaveInTMP(void); +void EmergencySave(void); +void DisableEmergencySave(void); +int ReadLibraryContents(void); /* walk through all lib paths and build the library menu */ +int ImportNetlist(char *); +int SaveBufferElements(char *); +void PreLoadElementPCB(void); +void PostLoadElementPCB(void); +void sort_netlist(void); /* * Whenever the pcb file format is modified, this version number @@ -59,7 +59,7 @@ */ /* This is the version needed by the file we're saving. */ -int PCBFileVersionNeeded (void); +int PCBFileVersionNeeded(void); /* This is the version we support. */ #define PCB_FILE_VERSION 20110603 @@ -67,10 +67,10 @@ #ifndef HAS_ATEXIT #ifdef HAS_ON_EXIT -void GlueEmergencySave (int, caddr_t); +void GlueEmergencySave(int, caddr_t); #else -void SaveTMPData (void); -void RemoveTMPData (void); +void SaveTMPData(void); +void RemoveTMPData(void); #endif #endif Index: trunk/src/find.c =================================================================== --- trunk/src/find.c (revision 1021) +++ trunk/src/find.c (revision 1022) @@ -100,7 +100,7 @@ #undef DEBUG -RCSID ("$Id$"); +RCSID("$Id$"); @@ -157,93 +157,80 @@ ( IsPointInPad((PV)->X, (PV)->Y, MAX((PV)->Thickness/2 +Bloat,0), (Pad))) static DrcViolationType -*pcb_drc_violation_new (const char *title, - const char *explanation, - Coord x, Coord y, - Angle angle, - bool have_measured, - Coord measured_value, - Coord required_value, - int object_count, - long int *object_id_list, - int *object_type_list) + * pcb_drc_violation_new(const char *title, + const char *explanation, + Coord x, Coord y, + Angle angle, + bool have_measured, + Coord measured_value, + Coord required_value, int object_count, long int *object_id_list, int *object_type_list) { - DrcViolationType *violation = (DrcViolationType *)malloc (sizeof (DrcViolationType)); + DrcViolationType *violation = (DrcViolationType *) malloc(sizeof(DrcViolationType)); - violation->title = strdup (title); - violation->explanation = strdup (explanation); - violation->x = x; - violation->y = y; - violation->angle = angle; - violation->have_measured = have_measured; - violation->measured_value = measured_value; - violation->required_value = required_value; - violation->object_count = object_count; - violation->object_id_list = object_id_list; - violation->object_type_list = object_type_list; + violation->title = strdup(title); + violation->explanation = strdup(explanation); + violation->x = x; + violation->y = y; + violation->angle = angle; + violation->have_measured = have_measured; + violation->measured_value = measured_value; + violation->required_value = required_value; + violation->object_count = object_count; + violation->object_id_list = object_id_list; + violation->object_type_list = object_type_list; - return violation; + return violation; } -static void -pcb_drc_violation_free (DrcViolationType *violation) +static void pcb_drc_violation_free(DrcViolationType * violation) { - free (violation->title); - free (violation->explanation); - free (violation); + free(violation->title); + free(violation->explanation); + free(violation); } static GString *drc_dialog_message; -static void -reset_drc_dialog_message(void) +static void reset_drc_dialog_message(void) { - if (drc_dialog_message) - g_string_free (drc_dialog_message, FALSE); - drc_dialog_message = g_string_new (""); - if (gui->drc_gui != NULL) - { - gui->drc_gui->reset_drc_dialog_message (); - } + if (drc_dialog_message) + g_string_free(drc_dialog_message, FALSE); + drc_dialog_message = g_string_new(""); + if (gui->drc_gui != NULL) { + gui->drc_gui->reset_drc_dialog_message(); + } } -static void -append_drc_dialog_message(const char *fmt, ...) + +static void append_drc_dialog_message(const char *fmt, ...) { - gchar *new_str; - va_list ap; - va_start (ap, fmt); - new_str = pcb_vprintf (fmt, ap); - g_string_append (drc_dialog_message, new_str); - va_end (ap); - g_free (new_str); + gchar *new_str; + va_list ap; + va_start(ap, fmt); + new_str = pcb_vprintf(fmt, ap); + g_string_append(drc_dialog_message, new_str); + va_end(ap); + g_free(new_str); } -static void GotoError (void); +static void GotoError(void); -static void -append_drc_violation (DrcViolationType *violation) +static void append_drc_violation(DrcViolationType * violation) { - if (gui->drc_gui != NULL) - { - gui->drc_gui->append_drc_violation (violation); - } - else - { - /* Fallback to formatting the violation message as text */ - append_drc_dialog_message ("%s\n", violation->title); - append_drc_dialog_message (_("%m+near %$mD\n"), - Settings.grid_unit->allow, - violation->x, violation->y); - GotoError (); - } + if (gui->drc_gui != NULL) { + gui->drc_gui->append_drc_violation(violation); + } + else { + /* Fallback to formatting the violation message as text */ + append_drc_dialog_message("%s\n", violation->title); + append_drc_dialog_message(_("%m+near %$mD\n"), Settings.grid_unit->allow, violation->x, violation->y); + GotoError(); + } - if (gui->drc_gui == NULL || gui->drc_gui->log_drc_violations ) - { - Message (_("WARNING! Design Rule error - %s\n"), violation->title); - Message (_("%m+near location %$mD\n"), - Settings.grid_unit->allow, - violation->x, violation->y); - } + if (gui->drc_gui == NULL || gui->drc_gui->log_drc_violations) { + Message(_("WARNING! Design Rule error - %s\n"), violation->title); + Message(_("%m+near location %$mD\n"), Settings.grid_unit->allow, violation->x, violation->y); + } } + /* * message when asked about continuing DRC checks after next * violation is found. @@ -252,23 +239,20 @@ #define DRC_NEXT _("Next") #define DRC_CANCEL _("Cancel") -static int -throw_drc_dialog(void) +static int throw_drc_dialog(void) { - int r; + int r; - if (gui->drc_gui != NULL) - { - r = gui->drc_gui->throw_drc_dialog (); - } - else - { - /* Fallback to formatting the violation message as text */ - append_drc_dialog_message (DRC_CONTINUE); - r = gui->confirm_dialog (drc_dialog_message->str, DRC_CANCEL, DRC_NEXT); - reset_drc_dialog_message(); - } - return r; + if (gui->drc_gui != NULL) { + r = gui->drc_gui->throw_drc_dialog(); + } + else { + /* Fallback to formatting the violation message as text */ + append_drc_dialog_message(DRC_CONTINUE); + r = gui->confirm_dialog(drc_dialog_message->str, DRC_CANCEL, DRC_NEXT); + reset_drc_dialog_message(); + } + return r; } /* --------------------------------------------------------------------------- @@ -277,14 +261,12 @@ * the two 'dummy' structs for PVs and Pads are necessary for creating * connection lists which include the element's name */ -typedef struct -{ - void **Data; /* pointer to index data */ - Cardinal Location, /* currently used position */ - DrawLocation, Number, /* number of objects in list */ - Size; -} -ListType, *ListTypePtr; +typedef struct { + void **Data; /* pointer to index data */ + Cardinal Location, /* currently used position */ + DrawLocation, Number, /* number of objects in list */ + Size; +} ListType, *ListTypePtr; /* --------------------------------------------------------------------------- * some local identifiers @@ -301,204 +283,184 @@ find_callback(current_type, current_ptr, from_type, from_ptr, type); \ } while(0) -static bool User = false; /* user action causing this */ -static bool drc = false; /* whether to stop if finding something not found */ +static bool User = false; /* user action causing this */ +static bool drc = false; /* whether to stop if finding something not found */ static bool IsBad = false; -static Cardinal drcerr_count; /* count of drc errors */ +static Cardinal drcerr_count; /* count of drc errors */ static Cardinal TotalP, TotalV, NumberOfPads[2]; -static ListType LineList[MAX_LAYER], /* list of objects to */ +static ListType LineList[MAX_LAYER], /* list of objects to */ PolygonList[MAX_LAYER], ArcList[MAX_LAYER], PadList[2], RatList, PVList; /* --------------------------------------------------------------------------- * some local prototypes */ -static bool LookupLOConnectionsToPVList (bool); -static bool LookupLOConnectionsToLOList (bool); -static bool LookupPVConnectionsToLOList (bool); -static bool LookupPVConnectionsToPVList (void); -static bool LookupLOConnectionsToLine (LineTypePtr, Cardinal, bool); -static bool LookupLOConnectionsToPad (PadTypePtr, Cardinal); -static bool LookupLOConnectionsToPolygon (PolygonTypePtr, Cardinal); -static bool LookupLOConnectionsToArc (ArcTypePtr, Cardinal); -static bool LookupLOConnectionsToRatEnd (PointTypePtr, Cardinal); -static bool IsRatPointOnLineEnd (PointTypePtr, LineTypePtr); -static bool ArcArcIntersect (ArcTypePtr, ArcTypePtr); -static bool PrepareNextLoop (FILE *); -static bool PrintElementConnections (ElementTypePtr, FILE *, bool); -static bool ListsEmpty (bool); -static bool DoIt (bool, bool); -static void PrintElementNameList (ElementTypePtr, FILE *); -static void PrintConnectionElementName (ElementTypePtr, FILE *); -static void PrintConnectionListEntry (char *, ElementTypePtr, - bool, FILE *); -static void PrintPadConnections (Cardinal, FILE *, bool); -static void PrintPinConnections (FILE *, bool); -static bool PrintAndSelectUnusedPinsAndPadsOfElement (ElementTypePtr, - FILE *); -static void DrawNewConnections (void); -static void DumpList (void); -static void LocateError (Coord *, Coord *); -static void BuildObjectList (int *, long int **, int **); -static void GotoError (void); -static bool DRCFind (int, void *, void *, void *); -static bool ListStart (int, void *, void *, void *); -static bool LOTouchesLine (LineTypePtr Line, Cardinal LayerGroup); -static bool PVTouchesLine (LineTypePtr line); -static bool SetThing (int, void *, void *, void *); +static bool LookupLOConnectionsToPVList(bool); +static bool LookupLOConnectionsToLOList(bool); +static bool LookupPVConnectionsToLOList(bool); +static bool LookupPVConnectionsToPVList(void); +static bool LookupLOConnectionsToLine(LineTypePtr, Cardinal, bool); +static bool LookupLOConnectionsToPad(PadTypePtr, Cardinal); +static bool LookupLOConnectionsToPolygon(PolygonTypePtr, Cardinal); +static bool LookupLOConnectionsToArc(ArcTypePtr, Cardinal); +static bool LookupLOConnectionsToRatEnd(PointTypePtr, Cardinal); +static bool IsRatPointOnLineEnd(PointTypePtr, LineTypePtr); +static bool ArcArcIntersect(ArcTypePtr, ArcTypePtr); +static bool PrepareNextLoop(FILE *); +static bool PrintElementConnections(ElementTypePtr, FILE *, bool); +static bool ListsEmpty(bool); +static bool DoIt(bool, bool); +static void PrintElementNameList(ElementTypePtr, FILE *); +static void PrintConnectionElementName(ElementTypePtr, FILE *); +static void PrintConnectionListEntry(char *, ElementTypePtr, bool, FILE *); +static void PrintPadConnections(Cardinal, FILE *, bool); +static void PrintPinConnections(FILE *, bool); +static bool PrintAndSelectUnusedPinsAndPadsOfElement(ElementTypePtr, FILE *); +static void DrawNewConnections(void); +static void DumpList(void); +static void LocateError(Coord *, Coord *); +static void BuildObjectList(int *, long int **, int **); +static void GotoError(void); +static bool DRCFind(int, void *, void *, void *); +static bool ListStart(int, void *, void *, void *); +static bool LOTouchesLine(LineTypePtr Line, Cardinal LayerGroup); +static bool PVTouchesLine(LineTypePtr line); +static bool SetThing(int, void *, void *, void *); /* --------------------------------------------------------------------------- * some of the 'pad' routines are the same as for lines because the 'pad' * struct starts with a line struct. See global.h for details */ -bool -LinePadIntersect (LineTypePtr Line, PadTypePtr Pad) +bool LinePadIntersect(LineTypePtr Line, PadTypePtr Pad) { - return LineLineIntersect ((Line), (LineTypePtr)Pad); + return LineLineIntersect((Line), (LineTypePtr) Pad); } -bool -ArcPadIntersect (ArcTypePtr Arc, PadTypePtr Pad) +bool ArcPadIntersect(ArcTypePtr Arc, PadTypePtr Pad) { - return LineArcIntersect ((LineTypePtr) (Pad), (Arc)); + return LineArcIntersect((LineTypePtr) (Pad), (Arc)); } -static bool -ADD_PV_TO_LIST (PinTypePtr Pin, int from_type, void *from_ptr, found_conn_type_t type) +static bool ADD_PV_TO_LIST(PinTypePtr Pin, int from_type, void *from_ptr, found_conn_type_t type) { - if (User) - AddObjectToFlagUndoList (Pin->Element ? PIN_TYPE : VIA_TYPE, - Pin->Element ? Pin->Element : Pin, Pin, Pin); - SET_FLAG (TheFlag, Pin); - make_callback(PIN_TYPE, Pin, from_type, from_ptr, type); - PVLIST_ENTRY (PVList.Number) = Pin; - PVList.Number++; + if (User) + AddObjectToFlagUndoList(Pin->Element ? PIN_TYPE : VIA_TYPE, Pin->Element ? Pin->Element : Pin, Pin, Pin); + SET_FLAG(TheFlag, Pin); + make_callback(PIN_TYPE, Pin, from_type, from_ptr, type); + PVLIST_ENTRY(PVList.Number) = Pin; + PVList.Number++; #ifdef DEBUG - if (PVList.Number > PVList.Size) - printf ("ADD_PV_TO_LIST overflow! num=%d size=%d\n", PVList.Number, - PVList.Size); + if (PVList.Number > PVList.Size) + printf("ADD_PV_TO_LIST overflow! num=%d size=%d\n", PVList.Number, PVList.Size); #endif - if (drc && !TEST_FLAG (SELECTEDFLAG, Pin)) - return (SetThing (PIN_TYPE, Pin->Element, Pin, Pin)); - return false; + if (drc && !TEST_FLAG(SELECTEDFLAG, Pin)) + return (SetThing(PIN_TYPE, Pin->Element, Pin, Pin)); + return false; } -static bool -ADD_PAD_TO_LIST (Cardinal L, PadTypePtr Pad, int from_type, void *from_ptr, found_conn_type_t type) +static bool ADD_PAD_TO_LIST(Cardinal L, PadTypePtr Pad, int from_type, void *from_ptr, found_conn_type_t type) { /*fprintf(stderr, "ADD_PAD_TO_LIST cardinal %d %p %d\n", L, Pad, from_type);*/ - if (User) - AddObjectToFlagUndoList (PAD_TYPE, Pad->Element, Pad, Pad); - SET_FLAG (TheFlag, Pad); - make_callback(PAD_TYPE, Pad, from_type, from_ptr, type); - PADLIST_ENTRY ((L), PadList[(L)].Number) = Pad; - PadList[(L)].Number++; + if (User) + AddObjectToFlagUndoList(PAD_TYPE, Pad->Element, Pad, Pad); + SET_FLAG(TheFlag, Pad); + make_callback(PAD_TYPE, Pad, from_type, from_ptr, type); + PADLIST_ENTRY((L), PadList[(L)].Number) = Pad; + PadList[(L)].Number++; #ifdef DEBUG - if (PadList[(L)].Number > PadList[(L)].Size) - printf ("ADD_PAD_TO_LIST overflow! lay=%d, num=%d size=%d\n", L, - PadList[(L)].Number, PadList[(L)].Size); + if (PadList[(L)].Number > PadList[(L)].Size) + printf("ADD_PAD_TO_LIST overflow! lay=%d, num=%d size=%d\n", L, PadList[(L)].Number, PadList[(L)].Size); #endif - if (drc && !TEST_FLAG (SELECTEDFLAG, Pad)) - return (SetThing (PAD_TYPE, Pad->Element, Pad, Pad)); - return false; + if (drc && !TEST_FLAG(SELECTEDFLAG, Pad)) + return (SetThing(PAD_TYPE, Pad->Element, Pad, Pad)); + return false; } -static bool -ADD_LINE_TO_LIST (Cardinal L, LineTypePtr Ptr, int from_type, void *from_ptr, found_conn_type_t type) +static bool ADD_LINE_TO_LIST(Cardinal L, LineTypePtr Ptr, int from_type, void *from_ptr, found_conn_type_t type) { - if (User) - AddObjectToFlagUndoList (LINE_TYPE, LAYER_PTR (L), (Ptr), (Ptr)); - SET_FLAG (TheFlag, (Ptr)); - make_callback(LINE_TYPE, Ptr, from_type, from_ptr, type); - LINELIST_ENTRY ((L), LineList[(L)].Number) = (Ptr); - LineList[(L)].Number++; + if (User) + AddObjectToFlagUndoList(LINE_TYPE, LAYER_PTR(L), (Ptr), (Ptr)); + SET_FLAG(TheFlag, (Ptr)); + make_callback(LINE_TYPE, Ptr, from_type, from_ptr, type); + LINELIST_ENTRY((L), LineList[(L)].Number) = (Ptr); + LineList[(L)].Number++; #ifdef DEBUG - if (LineList[(L)].Number > LineList[(L)].Size) - printf ("ADD_LINE_TO_LIST overflow! lay=%d, num=%d size=%d\n", L, - LineList[(L)].Number, LineList[(L)].Size); + if (LineList[(L)].Number > LineList[(L)].Size) + printf("ADD_LINE_TO_LIST overflow! lay=%d, num=%d size=%d\n", L, LineList[(L)].Number, LineList[(L)].Size); #endif - if (drc && !TEST_FLAG (SELECTEDFLAG, (Ptr))) - return (SetThing (LINE_TYPE, LAYER_PTR (L), (Ptr), (Ptr))); - return false; + if (drc && !TEST_FLAG(SELECTEDFLAG, (Ptr))) + return (SetThing(LINE_TYPE, LAYER_PTR(L), (Ptr), (Ptr))); + return false; } -static bool -ADD_ARC_TO_LIST (Cardinal L, ArcTypePtr Ptr, int from_type, void *from_ptr, found_conn_type_t type) +static bool ADD_ARC_TO_LIST(Cardinal L, ArcTypePtr Ptr, int from_type, void *from_ptr, found_conn_type_t type) { - if (User) - AddObjectToFlagUndoList (ARC_TYPE, LAYER_PTR (L), (Ptr), (Ptr)); - SET_FLAG (TheFlag, (Ptr)); - make_callback(ARC_TYPE, Ptr, from_type, from_ptr, type); - ARCLIST_ENTRY ((L), ArcList[(L)].Number) = (Ptr); - ArcList[(L)].Number++; + if (User) + AddObjectToFlagUndoList(ARC_TYPE, LAYER_PTR(L), (Ptr), (Ptr)); + SET_FLAG(TheFlag, (Ptr)); + make_callback(ARC_TYPE, Ptr, from_type, from_ptr, type); + ARCLIST_ENTRY((L), ArcList[(L)].Number) = (Ptr); + ArcList[(L)].Number++; #ifdef DEBUG - if (ArcList[(L)].Number > ArcList[(L)].Size) - printf ("ADD_ARC_TO_LIST overflow! lay=%d, num=%d size=%d\n", L, - ArcList[(L)].Number, ArcList[(L)].Size); + if (ArcList[(L)].Number > ArcList[(L)].Size) + printf("ADD_ARC_TO_LIST overflow! lay=%d, num=%d size=%d\n", L, ArcList[(L)].Number, ArcList[(L)].Size); #endif - if (drc && !TEST_FLAG (SELECTEDFLAG, (Ptr))) - return (SetThing (ARC_TYPE, LAYER_PTR (L), (Ptr), (Ptr))); - return false; + if (drc && !TEST_FLAG(SELECTEDFLAG, (Ptr))) + return (SetThing(ARC_TYPE, LAYER_PTR(L), (Ptr), (Ptr))); + return false; } -static bool -ADD_RAT_TO_LIST (RatTypePtr Ptr, int from_type, void *from_ptr, found_conn_type_t type) +static bool ADD_RAT_TO_LIST(RatTypePtr Ptr, int from_type, void *from_ptr, found_conn_type_t type) { - if (User) - AddObjectToFlagUndoList (RATLINE_TYPE, (Ptr), (Ptr), (Ptr)); - SET_FLAG (TheFlag, (Ptr)); - make_callback(RATLINE_TYPE, Ptr, from_type, from_ptr, type); - RATLIST_ENTRY (RatList.Number) = (Ptr); - RatList.Number++; + if (User) + AddObjectToFlagUndoList(RATLINE_TYPE, (Ptr), (Ptr), (Ptr)); + SET_FLAG(TheFlag, (Ptr)); + make_callback(RATLINE_TYPE, Ptr, from_type, from_ptr, type); + RATLIST_ENTRY(RatList.Number) = (Ptr); + RatList.Number++; #ifdef DEBUG - if (RatList.Number > RatList.Size) - printf ("ADD_RAT_TO_LIST overflow! num=%d size=%d\n", - RatList.Number, RatList.Size); + if (RatList.Number > RatList.Size) + printf("ADD_RAT_TO_LIST overflow! num=%d size=%d\n", RatList.Number, RatList.Size); #endif - if (drc && !TEST_FLAG (SELECTEDFLAG, (Ptr))) - return (SetThing (RATLINE_TYPE, (Ptr), (Ptr), (Ptr))); - return false; + if (drc && !TEST_FLAG(SELECTEDFLAG, (Ptr))) + return (SetThing(RATLINE_TYPE, (Ptr), (Ptr), (Ptr))); + return false; } -static bool -ADD_POLYGON_TO_LIST (Cardinal L, PolygonTypePtr Ptr, int from_type, void *from_ptr, found_conn_type_t type) +static bool ADD_POLYGON_TO_LIST(Cardinal L, PolygonTypePtr Ptr, int from_type, void *from_ptr, found_conn_type_t type) { - if (User) - AddObjectToFlagUndoList (POLYGON_TYPE, LAYER_PTR (L), (Ptr), (Ptr)); - SET_FLAG (TheFlag, (Ptr)); - make_callback(POLYGON_TYPE, Ptr, from_type, from_ptr, type); - POLYGONLIST_ENTRY ((L), PolygonList[(L)].Number) = (Ptr); - PolygonList[(L)].Number++; + if (User) + AddObjectToFlagUndoList(POLYGON_TYPE, LAYER_PTR(L), (Ptr), (Ptr)); + SET_FLAG(TheFlag, (Ptr)); + make_callback(POLYGON_TYPE, Ptr, from_type, from_ptr, type); + POLYGONLIST_ENTRY((L), PolygonList[(L)].Number) = (Ptr); + PolygonList[(L)].Number++; #ifdef DEBUG - if (PolygonList[(L)].Number > PolygonList[(L)].Size) - printf ("ADD_ARC_TO_LIST overflow! lay=%d, num=%d size=%d\n", L, - PolygonList[(L)].Number, PolygonList[(L)].Size); + if (PolygonList[(L)].Number > PolygonList[(L)].Size) + printf("ADD_ARC_TO_LIST overflow! lay=%d, num=%d size=%d\n", L, PolygonList[(L)].Number, PolygonList[(L)].Size); #endif - if (drc && !TEST_FLAG (SELECTEDFLAG, (Ptr))) - return (SetThing (POLYGON_TYPE, LAYER_PTR (L), (Ptr), (Ptr))); - return false; + if (drc && !TEST_FLAG(SELECTEDFLAG, (Ptr))) + return (SetThing(POLYGON_TYPE, LAYER_PTR(L), (Ptr), (Ptr))); + return false; } -bool -PinLineIntersect (PinTypePtr PV, LineTypePtr Line) +bool PinLineIntersect(PinTypePtr PV, LineTypePtr Line) { - if (TEST_FLAG (SQUAREFLAG, PV)) { + if (TEST_FLAG(SQUAREFLAG, PV)) { int shape = GET_SQUARE(PV); if (shape <= 1) { /* the original square case */ /* IsLineInRectangle already has Bloat factor */ - return IsLineInRectangle (PV->X - (PIN_SIZE (PV) + 1) / 2, - PV->Y - (PIN_SIZE (PV) + 1) / 2, - PV->X + (PIN_SIZE (PV) + 1) / 2, - PV->Y + (PIN_SIZE (PV) + 1) / 2, - Line); - } + return IsLineInRectangle(PV->X - (PIN_SIZE(PV) + 1) / 2, + PV->Y - (PIN_SIZE(PV) + 1) / 2, + PV->X + (PIN_SIZE(PV) + 1) / 2, PV->Y + (PIN_SIZE(PV) + 1) / 2, Line); + } { - /* shaped pin case */ + /* shaped pin case */ POLYAREA *pl, *lp; int ret; - pl = PinPoly(PV, PIN_SIZE (PV), 0); + pl = PinPoly(PV, PIN_SIZE(PV), 0); lp = LinePoly(Line, Line->Thickness + Bloat); ret = Touching(lp, pl); poly_Free(&pl); @@ -510,47 +472,41 @@ /* the original round pin version */ - return IsPointInPad (PV->X, PV->Y, MAX (PIN_SIZE (PV) / 2.0 + Bloat, 0.0), - (PadTypePtr)Line); + return IsPointInPad(PV->X, PV->Y, MAX(PIN_SIZE(PV) / 2.0 + Bloat, 0.0), (PadTypePtr) Line); } -bool -SetThing (int type, void *ptr1, void *ptr2, void *ptr3) +bool SetThing(int type, void *ptr1, void *ptr2, void *ptr3) { - thing_ptr1 = ptr1; - thing_ptr2 = ptr2; - thing_ptr3 = ptr3; - thing_type = type; - if (type == PIN_TYPE && ptr1 == NULL) - { - thing_ptr1 = ptr3; - thing_type = VIA_TYPE; - } - return true; + thing_ptr1 = ptr1; + thing_ptr2 = ptr2; + thing_ptr3 = ptr3; + thing_type = type; + if (type == PIN_TYPE && ptr1 == NULL) { + thing_ptr1 = ptr3; + thing_type = VIA_TYPE; + } + return true; } -bool -BoxBoxIntersection (BoxTypePtr b1, BoxTypePtr b2) +bool BoxBoxIntersection(BoxTypePtr b1, BoxTypePtr b2) { - if (b2->X2 < b1->X1 || b2->X1 > b1->X2) - return false; - if (b2->Y2 < b1->Y1 || b2->Y1 > b1->Y2) - return false; - return true; + if (b2->X2 < b1->X1 || b2->X1 > b1->X2) + return false; + if (b2->Y2 < b1->Y1 || b2->Y1 > b1->Y2) + return false; + return true; } -static bool -PadPadIntersect (PadTypePtr p1, PadTypePtr p2) +static bool PadPadIntersect(PadTypePtr p1, PadTypePtr p2) { - return LinePadIntersect ((LineTypePtr) p1, p2); + return LinePadIntersect((LineTypePtr) p1, p2); } -static inline bool -PV_TOUCH_PV (PinTypePtr PV1, PinTypePtr PV2) +static inline bool PV_TOUCH_PV(PinTypePtr PV1, PinTypePtr PV2) { - double t1, t2; - BoxType b1, b2; + double t1, t2; + BoxType b1, b2; int shape1, shape2; shape1 = GET_SQUARE(PV1); @@ -560,8 +516,8 @@ POLYAREA *pl1, *pl2; int ret; - pl1 = PinPoly(PV1, PIN_SIZE (PV1)+Bloat, 0); - pl2 = PinPoly(PV2, PIN_SIZE (PV2)+Bloat, 0); + pl1 = PinPoly(PV1, PIN_SIZE(PV1) + Bloat, 0); + pl2 = PinPoly(PV2, PIN_SIZE(PV2) + Bloat, 0); ret = Touching(pl1, pl2); poly_Free(&pl1); poly_Free(&pl2); @@ -569,57 +525,54 @@ } - t1 = MAX (PV1->Thickness / 2.0 + Bloat, 0); - t2 = MAX (PV2->Thickness / 2.0 + Bloat, 0); - if (IsPointOnPin (PV1->X, PV1->Y, t1, PV2) - || IsPointOnPin (PV2->X, PV2->Y, t2, PV1)) - return true; - if (!TEST_FLAG (SQUAREFLAG, PV1) || !TEST_FLAG (SQUAREFLAG, PV2)) - return false; - /* check for square/square overlap */ - b1.X1 = PV1->X - t1; - b1.X2 = PV1->X + t1; - b1.Y1 = PV1->Y - t1; - b1.Y2 = PV1->Y + t1; - t2 = PV2->Thickness / 2.0; - b2.X1 = PV2->X - t2; - b2.X2 = PV2->X + t2; - b2.Y1 = PV2->Y - t2; - b2.Y2 = PV2->Y + t2; - return BoxBoxIntersection (&b1, &b2); + t1 = MAX(PV1->Thickness / 2.0 + Bloat, 0); + t2 = MAX(PV2->Thickness / 2.0 + Bloat, 0); + if (IsPointOnPin(PV1->X, PV1->Y, t1, PV2) + || IsPointOnPin(PV2->X, PV2->Y, t2, PV1)) + return true; + if (!TEST_FLAG(SQUAREFLAG, PV1) || !TEST_FLAG(SQUAREFLAG, PV2)) + return false; + /* check for square/square overlap */ + b1.X1 = PV1->X - t1; + b1.X2 = PV1->X + t1; + b1.Y1 = PV1->Y - t1; + b1.Y2 = PV1->Y + t1; + t2 = PV2->Thickness / 2.0; + b2.X1 = PV2->X - t2; + b2.X2 = PV2->X + t2; + b2.Y1 = PV2->Y - t2; + b2.Y2 = PV2->Y + t2; + return BoxBoxIntersection(&b1, &b2); } /* --------------------------------------------------------------------------- * releases all allocated memory */ -void -FreeLayoutLookupMemory (void) +void FreeLayoutLookupMemory(void) { - Cardinal i; + Cardinal i; - for (i = 0; i < max_copper_layer; i++) - { - free (LineList[i].Data); - LineList[i].Data = NULL; - free (ArcList[i].Data); - ArcList[i].Data = NULL; - free (PolygonList[i].Data); - PolygonList[i].Data = NULL; - } - free (PVList.Data); - PVList.Data = NULL; - free (RatList.Data); - RatList.Data = NULL; + for (i = 0; i < max_copper_layer; i++) { + free(LineList[i].Data); + LineList[i].Data = NULL; + free(ArcList[i].Data); + ArcList[i].Data = NULL; + free(PolygonList[i].Data); + PolygonList[i].Data = NULL; + } + free(PVList.Data); + PVList.Data = NULL; + free(RatList.Data); + RatList.Data = NULL; } -void -FreeComponentLookupMemory (void) +void FreeComponentLookupMemory(void) { /*fprintf(stderr, "PadList free both\n");*/ - free (PadList[0].Data); - PadList[0].Data = NULL; - free (PadList[1].Data); - PadList[1].Data = NULL; + free(PadList[0].Data); + PadList[0].Data = NULL; + free(PadList[1].Data); + PadList[1].Data = NULL; } /* --------------------------------------------------------------------------- @@ -626,36 +579,34 @@ * allocates memory for component related stacks ... * initializes index and sorts it by X1 and X2 */ -void -InitComponentLookup (void) +void InitComponentLookup(void) { - Cardinal i; + Cardinal i; - /* initialize pad data; start by counting the total number - * on each of the two possible layers - */ - NumberOfPads[COMPONENT_LAYER] = NumberOfPads[SOLDER_LAYER] = 0; - ALLPAD_LOOP (PCB->Data); - { - if (TEST_FLAG (ONSOLDERFLAG, pad)) - NumberOfPads[SOLDER_LAYER]++; - else - NumberOfPads[COMPONENT_LAYER]++; - } - ENDALL_LOOP; - for (i = 0; i < 2; i++) - { + /* initialize pad data; start by counting the total number + * on each of the two possible layers + */ + NumberOfPads[COMPONENT_LAYER] = NumberOfPads[SOLDER_LAYER] = 0; + ALLPAD_LOOP(PCB->Data); + { + if (TEST_FLAG(ONSOLDERFLAG, pad)) + NumberOfPads[SOLDER_LAYER]++; + else + NumberOfPads[COMPONENT_LAYER]++; + } + ENDALL_LOOP; + for (i = 0; i < 2; i++) { /*fprintf(stderr, "PadList alloc %d: %d\n", i, NumberOfPads[i]);*/ - /* allocate memory for working list */ - PadList[i].Data = (void **)calloc (NumberOfPads[i], sizeof (PadTypePtr)); + /* allocate memory for working list */ + PadList[i].Data = (void **) calloc(NumberOfPads[i], sizeof(PadTypePtr)); - /* clear some struct members */ - PadList[i].Location = 0; - PadList[i].DrawLocation = 0; - PadList[i].Number = 0; - PadList[i].Size = NumberOfPads[i]; - } + /* clear some struct members */ + PadList[i].Location = 0; + PadList[i].DrawLocation = 0; + PadList[i].Number = 0; + PadList[i].Size = NumberOfPads[i]; + } } /* --------------------------------------------------------------------------- @@ -662,174 +613,152 @@ * allocates memory for component related stacks ... * initializes index and sorts it by X1 and X2 */ -void -InitLayoutLookup (void) +void InitLayoutLookup(void) { - Cardinal i; + Cardinal i; - /* initialize line arc and polygon data */ - for (i = 0; i < max_copper_layer; i++) - { - LayerTypePtr layer = LAYER_PTR (i); + /* initialize line arc and polygon data */ + for (i = 0; i < max_copper_layer; i++) { + LayerTypePtr layer = LAYER_PTR(i); - if (layer->LineN) - { - /* allocate memory for line pointer lists */ - LineList[i].Data = (void **)calloc (layer->LineN, sizeof (LineTypePtr)); - LineList[i].Size = layer->LineN; - } - if (layer->ArcN) - { - ArcList[i].Data = (void **)calloc (layer->ArcN, sizeof (ArcTypePtr)); - ArcList[i].Size = layer->ArcN; - } + if (layer->LineN) { + /* allocate memory for line pointer lists */ + LineList[i].Data = (void **) calloc(layer->LineN, sizeof(LineTypePtr)); + LineList[i].Size = layer->LineN; + } + if (layer->ArcN) { + ArcList[i].Data = (void **) calloc(layer->ArcN, sizeof(ArcTypePtr)); + ArcList[i].Size = layer->ArcN; + } - /* allocate memory for polygon list */ - if (layer->PolygonN) - { - PolygonList[i].Data = (void **)calloc (layer->PolygonN, sizeof (PolygonTypePtr)); - PolygonList[i].Size = layer->PolygonN; - } + /* allocate memory for polygon list */ + if (layer->PolygonN) { + PolygonList[i].Data = (void **) calloc(layer->PolygonN, sizeof(PolygonTypePtr)); + PolygonList[i].Size = layer->PolygonN; + } - /* clear some struct members */ - LineList[i].Location = 0; - LineList[i].DrawLocation = 0; - LineList[i].Number = 0; - ArcList[i].Location = 0; - ArcList[i].DrawLocation = 0; - ArcList[i].Number = 0; - PolygonList[i].Location = 0; - PolygonList[i].DrawLocation = 0; - PolygonList[i].Number = 0; - } + /* clear some struct members */ + LineList[i].Location = 0; + LineList[i].DrawLocation = 0; + LineList[i].Number = 0; + ArcList[i].Location = 0; + ArcList[i].DrawLocation = 0; + ArcList[i].Number = 0; + PolygonList[i].Location = 0; + PolygonList[i].DrawLocation = 0; + PolygonList[i].Number = 0; + } - if (PCB->Data->pin_tree) - TotalP = PCB->Data->pin_tree->size; - else - TotalP = 0; - if (PCB->Data->via_tree) - TotalV = PCB->Data->via_tree->size; - else - TotalV = 0; - /* allocate memory for 'new PV to check' list and clear struct */ - PVList.Data = (void **)calloc (TotalP + TotalV, sizeof (PinTypePtr)); - PVList.Size = TotalP + TotalV; - PVList.Location = 0; - PVList.DrawLocation = 0; - PVList.Number = 0; - /* Initialize ratline data */ - RatList.Data = (void **)calloc (PCB->Data->RatN, sizeof (RatTypePtr)); - RatList.Size = PCB->Data->RatN; - RatList.Location = 0; - RatList.DrawLocation = 0; - RatList.Number = 0; + if (PCB->Data->pin_tree) + TotalP = PCB->Data->pin_tree->size; + else + TotalP = 0; + if (PCB->Data->via_tree) + TotalV = PCB->Data->via_tree->size; + else + TotalV = 0; + /* allocate memory for 'new PV to check' list and clear struct */ + PVList.Data = (void **) calloc(TotalP + TotalV, sizeof(PinTypePtr)); + PVList.Size = TotalP + TotalV; + PVList.Location = 0; + PVList.DrawLocation = 0; + PVList.Number = 0; + /* Initialize ratline data */ + RatList.Data = (void **) calloc(PCB->Data->RatN, sizeof(RatTypePtr)); + RatList.Size = PCB->Data->RatN; + RatList.Location = 0; + RatList.DrawLocation = 0; + RatList.Number = 0; } -struct pv_info -{ - Cardinal layer; - PinType pv; - jmp_buf env; +struct pv_info { + Cardinal layer; + PinType pv; + jmp_buf env; }; -static int -LOCtoPVline_callback (const BoxType * b, void *cl) +static int LOCtoPVline_callback(const BoxType * b, void *cl) { - LineTypePtr line = (LineTypePtr) b; - struct pv_info *i = (struct pv_info *) cl; + LineTypePtr line = (LineTypePtr) b; + struct pv_info *i = (struct pv_info *) cl; - if (!TEST_FLAG (TheFlag, line) && PinLineIntersect (&i->pv, line) && - !TEST_FLAG (HOLEFLAG, &i->pv)) - { - if (ADD_LINE_TO_LIST (i->layer, line, PIN_TYPE, &i->pv, FCT_COPPER)) - longjmp (i->env, 1); - } - return 0; + if (!TEST_FLAG(TheFlag, line) && PinLineIntersect(&i->pv, line) && !TEST_FLAG(HOLEFLAG, &i->pv)) { + if (ADD_LINE_TO_LIST(i->layer, line, PIN_TYPE, &i->pv, FCT_COPPER)) + longjmp(i->env, 1); + } + return 0; } -static int -LOCtoPVarc_callback (const BoxType * b, void *cl) +static int LOCtoPVarc_callback(const BoxType * b, void *cl) { - ArcTypePtr arc = (ArcTypePtr) b; - struct pv_info *i = (struct pv_info *) cl; + ArcTypePtr arc = (ArcTypePtr) b; + struct pv_info *i = (struct pv_info *) cl; - if (!TEST_FLAG (TheFlag, arc) && IS_PV_ON_ARC (&i->pv, arc) && - !TEST_FLAG (HOLEFLAG, &i->pv)) - { - if (ADD_ARC_TO_LIST (i->layer, arc, PIN_TYPE, &i->pv, FCT_COPPER)) - longjmp (i->env, 1); - } - return 0; + if (!TEST_FLAG(TheFlag, arc) && IS_PV_ON_ARC(&i->pv, arc) && !TEST_FLAG(HOLEFLAG, &i->pv)) { + if (ADD_ARC_TO_LIST(i->layer, arc, PIN_TYPE, &i->pv, FCT_COPPER)) + longjmp(i->env, 1); + } + return 0; } -static int -LOCtoPVpad_callback (const BoxType * b, void *cl) +static int LOCtoPVpad_callback(const BoxType * b, void *cl) { - PadTypePtr pad = (PadTypePtr) b; - struct pv_info *i = (struct pv_info *) cl; + PadTypePtr pad = (PadTypePtr) b; + struct pv_info *i = (struct pv_info *) cl; - if (!TEST_FLAG (TheFlag, pad) && IS_PV_ON_PAD (&i->pv, pad) && - !TEST_FLAG (HOLEFLAG, &i->pv) && - ADD_PAD_TO_LIST (TEST_FLAG (ONSOLDERFLAG, pad) ? SOLDER_LAYER : - COMPONENT_LAYER, pad, PIN_TYPE, &i->pv, FCT_COPPER)) - longjmp (i->env, 1); - return 0; + if (!TEST_FLAG(TheFlag, pad) && IS_PV_ON_PAD(&i->pv, pad) && + !TEST_FLAG(HOLEFLAG, &i->pv) && + ADD_PAD_TO_LIST(TEST_FLAG(ONSOLDERFLAG, pad) ? SOLDER_LAYER : COMPONENT_LAYER, pad, PIN_TYPE, &i->pv, FCT_COPPER)) + longjmp(i->env, 1); + return 0; } -static int -LOCtoPVrat_callback (const BoxType * b, void *cl) +static int LOCtoPVrat_callback(const BoxType * b, void *cl) { - RatTypePtr rat = (RatTypePtr) b; - struct pv_info *i = (struct pv_info *) cl; + RatTypePtr rat = (RatTypePtr) b; + struct pv_info *i = (struct pv_info *) cl; - if (!TEST_FLAG (TheFlag, rat) && IS_PV_ON_RAT (&i->pv, rat) && - ADD_RAT_TO_LIST (rat, PIN_TYPE, &i->pv, FCT_RAT)) - longjmp (i->env, 1); - return 0; + if (!TEST_FLAG(TheFlag, rat) && IS_PV_ON_RAT(&i->pv, rat) && ADD_RAT_TO_LIST(rat, PIN_TYPE, &i->pv, FCT_RAT)) + longjmp(i->env, 1); + return 0; } -static int -LOCtoPVpoly_callback (const BoxType * b, void *cl) + +static int LOCtoPVpoly_callback(const BoxType * b, void *cl) { - PolygonTypePtr polygon = (PolygonTypePtr) b; - struct pv_info *i = (struct pv_info *) cl; + PolygonTypePtr polygon = (PolygonTypePtr) b; + struct pv_info *i = (struct pv_info *) cl; - /* if the pin doesn't have a therm and polygon is clearing - * then it can't touch due to clearance, so skip the expensive - * test. If it does have a therm, you still need to test - * because it might not be inside the polygon, or it could - * be on an edge such that it doesn't actually touch. - */ - if (!TEST_FLAG (TheFlag, polygon) && !TEST_FLAG (HOLEFLAG, &i->pv) && - (TEST_THERM (i->layer, &i->pv) || - !TEST_FLAG (CLEARPOLYFLAG, - polygon) - || !i->pv.Clearance)) - { - double wide = MAX (0.5 * i->pv.Thickness + Bloat, 0); - if (TEST_FLAG (SQUAREFLAG, &i->pv)) - { - Coord x1 = i->pv.X - (i->pv.Thickness + 1 + Bloat) / 2; - Coord x2 = i->pv.X + (i->pv.Thickness + 1 + Bloat) / 2; - Coord y1 = i->pv.Y - (i->pv.Thickness + 1 + Bloat) / 2; - Coord y2 = i->pv.Y + (i->pv.Thickness + 1 + Bloat) / 2; - if (IsRectangleInPolygon (x1, y1, x2, y2, polygon) - && ADD_POLYGON_TO_LIST (i->layer, polygon, PIN_TYPE, &i->pv, FCT_COPPER)) - longjmp (i->env, 1); - } - else if (TEST_FLAG (OCTAGONFLAG, &i->pv)) - { - POLYAREA *oct = OctagonPoly (i->pv.X, i->pv.Y, i->pv.Thickness / 2, GET_SQUARE(&i->pv)); - if (isects (oct, polygon, true) - && ADD_POLYGON_TO_LIST (i->layer, polygon, PIN_TYPE, &i->pv, FCT_COPPER)) - longjmp (i->env, 1); - } - else if (IsPointInPolygon (i->pv.X, i->pv.Y, wide, - polygon) - && ADD_POLYGON_TO_LIST (i->layer, polygon, PIN_TYPE, &i->pv, FCT_COPPER)) - longjmp (i->env, 1); - } - return 0; + /* if the pin doesn't have a therm and polygon is clearing + * then it can't touch due to clearance, so skip the expensive + * test. If it does have a therm, you still need to test + * because it might not be inside the polygon, or it could + * be on an edge such that it doesn't actually touch. + */ + if (!TEST_FLAG(TheFlag, polygon) && !TEST_FLAG(HOLEFLAG, &i->pv) && + (TEST_THERM(i->layer, &i->pv) || !TEST_FLAG(CLEARPOLYFLAG, polygon) + || !i->pv.Clearance)) { + double wide = MAX(0.5 * i->pv.Thickness + Bloat, 0); + if (TEST_FLAG(SQUAREFLAG, &i->pv)) { + Coord x1 = i->pv.X - (i->pv.Thickness + 1 + Bloat) / 2; + Coord x2 = i->pv.X + (i->pv.Thickness + 1 + Bloat) / 2; + Coord y1 = i->pv.Y - (i->pv.Thickness + 1 + Bloat) / 2; + Coord y2 = i->pv.Y + (i->pv.Thickness + 1 + Bloat) / 2; + if (IsRectangleInPolygon(x1, y1, x2, y2, polygon) + && ADD_POLYGON_TO_LIST(i->layer, polygon, PIN_TYPE, &i->pv, FCT_COPPER)) + longjmp(i->env, 1); + } + else if (TEST_FLAG(OCTAGONFLAG, &i->pv)) { + POLYAREA *oct = OctagonPoly(i->pv.X, i->pv.Y, i->pv.Thickness / 2, GET_SQUARE(&i->pv)); + if (isects(oct, polygon, true) + && ADD_POLYGON_TO_LIST(i->layer, polygon, PIN_TYPE, &i->pv, FCT_COPPER)) + longjmp(i->env, 1); + } + else if (IsPointInPolygon(i->pv.X, i->pv.Y, wide, polygon) + && ADD_POLYGON_TO_LIST(i->layer, polygon, PIN_TYPE, &i->pv, FCT_COPPER)) + longjmp(i->env, 1); + } + return 0; } /* --------------------------------------------------------------------------- @@ -836,384 +765,327 @@ * checks if a PV is connected to LOs, if it is, the LO is added to * the appropriate list and the 'used' flag is set */ -static bool -LookupLOConnectionsToPVList (bool AndRats) +static bool LookupLOConnectionsToPVList(bool AndRats) { - Cardinal layer; - struct pv_info info; + Cardinal layer; + struct pv_info info; - /* loop over all PVs currently on list */ - while (PVList.Location < PVList.Number) - { - /* get pointer to data */ - info.pv = *(PVLIST_ENTRY (PVList.Location)); - EXPAND_BOUNDS (&info.pv); + /* loop over all PVs currently on list */ + while (PVList.Location < PVList.Number) { + /* get pointer to data */ + info.pv = *(PVLIST_ENTRY(PVList.Location)); + EXPAND_BOUNDS(&info.pv); - /* check pads */ - if (setjmp (info.env) == 0) - r_search (PCB->Data->pad_tree, (BoxType *) & info.pv, NULL, - LOCtoPVpad_callback, &info); - else - return true; + /* check pads */ + if (setjmp(info.env) == 0) + r_search(PCB->Data->pad_tree, (BoxType *) & info.pv, NULL, LOCtoPVpad_callback, &info); + else + return true; - /* now all lines, arcs and polygons of the several layers */ - for (layer = 0; layer < max_copper_layer; layer++) - { - if (LAYER_PTR (layer)->no_drc) - continue; - info.layer = layer; - /* add touching lines */ - if (setjmp (info.env) == 0) - r_search (LAYER_PTR (layer)->line_tree, (BoxType *) & info.pv, - NULL, LOCtoPVline_callback, &info); - else - return true; - /* add touching arcs */ - if (setjmp (info.env) == 0) - r_search (LAYER_PTR (layer)->arc_tree, (BoxType *) & info.pv, - NULL, LOCtoPVarc_callback, &info); - else - return true; - /* check all polygons */ - if (setjmp (info.env) == 0) - r_search (LAYER_PTR (layer)->polygon_tree, (BoxType *) & info.pv, - NULL, LOCtoPVpoly_callback, &info); - else - return true; - } - /* Check for rat-lines that may intersect the PV */ - if (AndRats) - { - if (setjmp (info.env) == 0) - r_search (PCB->Data->rat_tree, (BoxType *) & info.pv, NULL, - LOCtoPVrat_callback, &info); - else - return true; - } - PVList.Location++; - } - return false; + /* now all lines, arcs and polygons of the several layers */ + for (layer = 0; layer < max_copper_layer; layer++) { + if (LAYER_PTR(layer)->no_drc) + continue; + info.layer = layer; + /* add touching lines */ + if (setjmp(info.env) == 0) + r_search(LAYER_PTR(layer)->line_tree, (BoxType *) & info.pv, NULL, LOCtoPVline_callback, &info); + else + return true; + /* add touching arcs */ + if (setjmp(info.env) == 0) + r_search(LAYER_PTR(layer)->arc_tree, (BoxType *) & info.pv, NULL, LOCtoPVarc_callback, &info); + else + return true; + /* check all polygons */ + if (setjmp(info.env) == 0) + r_search(LAYER_PTR(layer)->polygon_tree, (BoxType *) & info.pv, NULL, LOCtoPVpoly_callback, &info); + else + return true; + } + /* Check for rat-lines that may intersect the PV */ + if (AndRats) { + if (setjmp(info.env) == 0) + r_search(PCB->Data->rat_tree, (BoxType *) & info.pv, NULL, LOCtoPVrat_callback, &info); + else + return true; + } + PVList.Location++; + } + return false; } /* --------------------------------------------------------------------------- * find all connections between LO at the current list position and new LOs */ -static bool -LookupLOConnectionsToLOList (bool AndRats) +static bool LookupLOConnectionsToLOList(bool AndRats) { - bool done; - Cardinal i, group, layer, ratposition, - lineposition[MAX_LAYER], - polyposition[MAX_LAYER], arcposition[MAX_LAYER], padposition[2]; + bool done; + Cardinal i, group, layer, ratposition, + lineposition[MAX_LAYER], polyposition[MAX_LAYER], arcposition[MAX_LAYER], padposition[2]; - /* copy the current LO list positions; the original data is changed - * by 'LookupPVConnectionsToLOList()' which has to check the same - * list entries plus the new ones - */ - for (i = 0; i < max_copper_layer; i++) - { - lineposition[i] = LineList[i].Location; - polyposition[i] = PolygonList[i].Location; - arcposition[i] = ArcList[i].Location; - } - for (i = 0; i < 2; i++) - padposition[i] = PadList[i].Location; - ratposition = RatList.Location; + /* copy the current LO list positions; the original data is changed + * by 'LookupPVConnectionsToLOList()' which has to check the same + * list entries plus the new ones + */ + for (i = 0; i < max_copper_layer; i++) { + lineposition[i] = LineList[i].Location; + polyposition[i] = PolygonList[i].Location; + arcposition[i] = ArcList[i].Location; + } + for (i = 0; i < 2; i++) + padposition[i] = PadList[i].Location; + ratposition = RatList.Location; - /* loop over all new LOs in the list; recurse until no - * more new connections in the layergroup were found - */ - do - { - Cardinal *position; + /* loop over all new LOs in the list; recurse until no + * more new connections in the layergroup were found + */ + do { + Cardinal *position; - if (AndRats) - { - position = &ratposition; - for (; *position < RatList.Number; (*position)++) - { - group = RATLIST_ENTRY (*position)->group1; - if (LookupLOConnectionsToRatEnd - (&(RATLIST_ENTRY (*position)->Point1), group)) - return (true); - group = RATLIST_ENTRY (*position)->group2; - if (LookupLOConnectionsToRatEnd - (&(RATLIST_ENTRY (*position)->Point2), group)) - return (true); - } - } - /* loop over all layergroups */ - for (group = 0; group < max_group; group++) - { - Cardinal entry; + if (AndRats) { + position = &ratposition; + for (; *position < RatList.Number; (*position)++) { + group = RATLIST_ENTRY(*position)->group1; + if (LookupLOConnectionsToRatEnd(&(RATLIST_ENTRY(*position)->Point1), group)) + return (true); + group = RATLIST_ENTRY(*position)->group2; + if (LookupLOConnectionsToRatEnd(&(RATLIST_ENTRY(*position)->Point2), group)) + return (true); + } + } + /* loop over all layergroups */ + for (group = 0; group < max_group; group++) { + Cardinal entry; - for (entry = 0; entry < PCB->LayerGroups.Number[group]; entry++) - { - layer = PCB->LayerGroups.Entries[group][entry]; + for (entry = 0; entry < PCB->LayerGroups.Number[group]; entry++) { + layer = PCB->LayerGroups.Entries[group][entry]; - /* be aware that the layer number equal max_copper_layer - * and max_copper_layer+1 have a special meaning for pads - */ - if (layer < max_copper_layer) - { - /* try all new lines */ - position = &lineposition[layer]; - for (; *position < LineList[layer].Number; (*position)++) - if (LookupLOConnectionsToLine - (LINELIST_ENTRY (layer, *position), group, true)) - return (true); + /* be aware that the layer number equal max_copper_layer + * and max_copper_layer+1 have a special meaning for pads + */ + if (layer < max_copper_layer) { + /* try all new lines */ + position = &lineposition[layer]; + for (; *position < LineList[layer].Number; (*position)++) + if (LookupLOConnectionsToLine(LINELIST_ENTRY(layer, *position), group, true)) + return (true); - /* try all new arcs */ - position = &arcposition[layer]; - for (; *position < ArcList[layer].Number; (*position)++) - if (LookupLOConnectionsToArc - (ARCLIST_ENTRY (layer, *position), group)) - return (true); + /* try all new arcs */ + position = &arcposition[layer]; + for (; *position < ArcList[layer].Number; (*position)++) + if (LookupLOConnectionsToArc(ARCLIST_ENTRY(layer, *position), group)) + return (true); - /* try all new polygons */ - position = &polyposition[layer]; - for (; *position < PolygonList[layer].Number; (*position)++) - if (LookupLOConnectionsToPolygon - (POLYGONLIST_ENTRY (layer, *position), group)) - return (true); - } - else - { - /* try all new pads */ - layer -= max_copper_layer; - if (layer > 1) - { - Message (_("bad layer number %d max_copper_layer=%d in find.c\n"), - layer, max_copper_layer); - return false; - } - position = &padposition[layer]; - for (; *position < PadList[layer].Number; (*position)++) - if (LookupLOConnectionsToPad - (PADLIST_ENTRY (layer, *position), group)) - return (true); - } - } - } + /* try all new polygons */ + position = &polyposition[layer]; + for (; *position < PolygonList[layer].Number; (*position)++) + if (LookupLOConnectionsToPolygon(POLYGONLIST_ENTRY(layer, *position), group)) + return (true); + } + else { + /* try all new pads */ + layer -= max_copper_layer; + if (layer > 1) { + Message(_("bad layer number %d max_copper_layer=%d in find.c\n"), layer, max_copper_layer); + return false; + } + position = &padposition[layer]; + for (; *position < PadList[layer].Number; (*position)++) + if (LookupLOConnectionsToPad(PADLIST_ENTRY(layer, *position), group)) + return (true); + } + } + } - /* check if all lists are done; Later for-loops - * may have changed the prior lists - */ - done = !AndRats || ratposition >= RatList.Number; - for (layer = 0; layer < max_copper_layer + 2; layer++) - { - if (layer < max_copper_layer) - done = done && - lineposition[layer] >= LineList[layer].Number - && arcposition[layer] >= ArcList[layer].Number - && polyposition[layer] >= PolygonList[layer].Number; - else - done = done - && padposition[layer - max_copper_layer] >= - PadList[layer - max_copper_layer].Number; - } - } - while (!done); - return (false); + /* check if all lists are done; Later for-loops + * may have changed the prior lists + */ + done = !AndRats || ratposition >= RatList.Number; + for (layer = 0; layer < max_copper_layer + 2; layer++) { + if (layer < max_copper_layer) + done = done && + lineposition[layer] >= LineList[layer].Number + && arcposition[layer] >= ArcList[layer].Number && polyposition[layer] >= PolygonList[layer].Number; + else + done = done && padposition[layer - max_copper_layer] >= PadList[layer - max_copper_layer].Number; + } + } + while (!done); + return (false); } -static int -pv_pv_callback (const BoxType * b, void *cl) +static int pv_pv_callback(const BoxType * b, void *cl) { - PinTypePtr pin = (PinTypePtr) b; - struct pv_info *i = (struct pv_info *) cl; + PinTypePtr pin = (PinTypePtr) b; + struct pv_info *i = (struct pv_info *) cl; - if (!TEST_FLAG (TheFlag, pin) && PV_TOUCH_PV (&i->pv, pin)) - { - if (TEST_FLAG (HOLEFLAG, pin) || TEST_FLAG (HOLEFLAG, &i->pv)) - { - SET_FLAG (WARNFLAG, pin); - Settings.RatWarn = true; - if (pin->Element) - Message (_("WARNING: Hole too close to pin.\n")); - else - Message (_("WARNING: Hole too close to via.\n")); - } - else if (ADD_PV_TO_LIST (pin, PIN_TYPE, &i->pv, FCT_COPPER)) - longjmp (i->env, 1); - } - return 0; + if (!TEST_FLAG(TheFlag, pin) && PV_TOUCH_PV(&i->pv, pin)) { + if (TEST_FLAG(HOLEFLAG, pin) || TEST_FLAG(HOLEFLAG, &i->pv)) { + SET_FLAG(WARNFLAG, pin); + Settings.RatWarn = true; + if (pin->Element) + Message(_("WARNING: Hole too close to pin.\n")); + else + Message(_("WARNING: Hole too close to via.\n")); + } + else if (ADD_PV_TO_LIST(pin, PIN_TYPE, &i->pv, FCT_COPPER)) + longjmp(i->env, 1); + } + return 0; } /* --------------------------------------------------------------------------- * searches for new PVs that are connected to PVs on the list */ -static bool -LookupPVConnectionsToPVList (void) +static bool LookupPVConnectionsToPVList(void) { - Cardinal save_place; - struct pv_info info; + Cardinal save_place; + struct pv_info info; - /* loop over all PVs on list */ - save_place = PVList.Location; - while (PVList.Location < PVList.Number) - { - int ic; - PinType *orig_pin; - /* get pointer to data */ - orig_pin = (PVLIST_ENTRY (PVList.Location)); - info.pv = *orig_pin; + /* loop over all PVs on list */ + save_place = PVList.Location; + while (PVList.Location < PVList.Number) { + int ic; + PinType *orig_pin; + /* get pointer to data */ + orig_pin = (PVLIST_ENTRY(PVList.Location)); + info.pv = *orig_pin; - /* Internal connection: if pins in the same element have the same - internal connection group number, they are connected */ - ic = GET_INTCONN(orig_pin); - if ((info.pv.Element != NULL) && (ic > 0)) { - ElementType *e = info.pv.Element; - PIN_LOOP (e); - { - if ((orig_pin != pin) && (ic == GET_INTCONN(pin))) { - if (!TEST_FLAG (TheFlag, pin)) - ADD_PV_TO_LIST (pin, PIN_TYPE, orig_pin, FCT_INTERNAL); - } + /* Internal connection: if pins in the same element have the same + internal connection group number, they are connected */ + ic = GET_INTCONN(orig_pin); + if ((info.pv.Element != NULL) && (ic > 0)) { + ElementType *e = info.pv.Element; + PIN_LOOP(e); + { + if ((orig_pin != pin) && (ic == GET_INTCONN(pin))) { + if (!TEST_FLAG(TheFlag, pin)) + ADD_PV_TO_LIST(pin, PIN_TYPE, orig_pin, FCT_INTERNAL); } - END_LOOP; } + END_LOOP; + } - EXPAND_BOUNDS (&info.pv); - if (setjmp (info.env) == 0) - r_search (PCB->Data->via_tree, (BoxType *) & info.pv, NULL, - pv_pv_callback, &info); - else - return true; - if (setjmp (info.env) == 0) - r_search (PCB->Data->pin_tree, (BoxType *) & info.pv, NULL, - pv_pv_callback, &info); - else - return true; - PVList.Location++; - } - PVList.Location = save_place; - return (false); + EXPAND_BOUNDS(&info.pv); + if (setjmp(info.env) == 0) + r_search(PCB->Data->via_tree, (BoxType *) & info.pv, NULL, pv_pv_callback, &info); + else + return true; + if (setjmp(info.env) == 0) + r_search(PCB->Data->pin_tree, (BoxType *) & info.pv, NULL, pv_pv_callback, &info); + else + return true; + PVList.Location++; + } + PVList.Location = save_place; + return (false); } -struct lo_info -{ - Cardinal layer; - LineType line; - PadType pad; - ArcType arc; - PolygonType polygon; - RatType rat; - jmp_buf env; +struct lo_info { + Cardinal layer; + LineType line; + PadType pad; + ArcType arc; + PolygonType polygon; + RatType rat; + jmp_buf env; }; -static int -pv_line_callback (const BoxType * b, void *cl) +static int pv_line_callback(const BoxType * b, void *cl) { - PinTypePtr pv = (PinTypePtr) b; - struct lo_info *i = (struct lo_info *) cl; + PinTypePtr pv = (PinTypePtr) b; + struct lo_info *i = (struct lo_info *) cl; - if (!TEST_FLAG (TheFlag, pv) && PinLineIntersect (pv, &i->line)) - { - if (TEST_FLAG (HOLEFLAG, pv)) - { - SET_FLAG (WARNFLAG, pv); - Settings.RatWarn = true; - Message (_("WARNING: Hole too close to line.\n")); - } - else if (ADD_PV_TO_LIST (pv, LINE_TYPE, &i->line, FCT_COPPER)) - longjmp (i->env, 1); - } - return 0; + if (!TEST_FLAG(TheFlag, pv) && PinLineIntersect(pv, &i->line)) { + if (TEST_FLAG(HOLEFLAG, pv)) { + SET_FLAG(WARNFLAG, pv); + Settings.RatWarn = true; + Message(_("WARNING: Hole too close to line.\n")); + } + else if (ADD_PV_TO_LIST(pv, LINE_TYPE, &i->line, FCT_COPPER)) + longjmp(i->env, 1); + } + return 0; } -static int -pv_pad_callback (const BoxType * b, void *cl) +static int pv_pad_callback(const BoxType * b, void *cl) { - PinTypePtr pv = (PinTypePtr) b; - struct lo_info *i = (struct lo_info *) cl; + PinTypePtr pv = (PinTypePtr) b; + struct lo_info *i = (struct lo_info *) cl; - if (!TEST_FLAG (TheFlag, pv) && IS_PV_ON_PAD (pv, &i->pad)) - { - if (TEST_FLAG (HOLEFLAG, pv)) - { - SET_FLAG (WARNFLAG, pv); - Settings.RatWarn = true; - Message (_("WARNING: Hole too close to pad.\n")); - } - else if (ADD_PV_TO_LIST (pv, PAD_TYPE, &i->pad, FCT_COPPER)) - longjmp (i->env, 1); - } - return 0; + if (!TEST_FLAG(TheFlag, pv) && IS_PV_ON_PAD(pv, &i->pad)) { + if (TEST_FLAG(HOLEFLAG, pv)) { + SET_FLAG(WARNFLAG, pv); + Settings.RatWarn = true; + Message(_("WARNING: Hole too close to pad.\n")); + } + else if (ADD_PV_TO_LIST(pv, PAD_TYPE, &i->pad, FCT_COPPER)) + longjmp(i->env, 1); + } + return 0; } -static int -pv_arc_callback (const BoxType * b, void *cl) +static int pv_arc_callback(const BoxType * b, void *cl) { - PinTypePtr pv = (PinTypePtr) b; - struct lo_info *i = (struct lo_info *) cl; + PinTypePtr pv = (PinTypePtr) b; + struct lo_info *i = (struct lo_info *) cl; - if (!TEST_FLAG (TheFlag, pv) && IS_PV_ON_ARC (pv, &i->arc)) - { - if (TEST_FLAG (HOLEFLAG, pv)) - { - SET_FLAG (WARNFLAG, pv); - Settings.RatWarn = true; - Message (_("WARNING: Hole touches arc.\n")); - } - else if (ADD_PV_TO_LIST (pv, ARC_TYPE, &i->arc, FCT_COPPER)) - longjmp (i->env, 1); - } - return 0; + if (!TEST_FLAG(TheFlag, pv) && IS_PV_ON_ARC(pv, &i->arc)) { + if (TEST_FLAG(HOLEFLAG, pv)) { + SET_FLAG(WARNFLAG, pv); + Settings.RatWarn = true; + Message(_("WARNING: Hole touches arc.\n")); + } + else if (ADD_PV_TO_LIST(pv, ARC_TYPE, &i->arc, FCT_COPPER)) + longjmp(i->env, 1); + } + return 0; } -static int -pv_poly_callback (const BoxType * b, void *cl) +static int pv_poly_callback(const BoxType * b, void *cl) { - PinTypePtr pv = (PinTypePtr) b; - struct lo_info *i = (struct lo_info *) cl; + PinTypePtr pv = (PinTypePtr) b; + struct lo_info *i = (struct lo_info *) cl; - /* note that holes in polygons are ok, so they don't generate warnings. */ - if (!TEST_FLAG (TheFlag, pv) && !TEST_FLAG (HOLEFLAG, pv) && - (TEST_THERM (i->layer, pv) || - !TEST_FLAG (CLEARPOLYFLAG, &i->polygon) || - !pv->Clearance)) - { - if (TEST_FLAG (SQUAREFLAG, pv)) - { - Coord x1, x2, y1, y2; - x1 = pv->X - (PIN_SIZE (pv) + 1 + Bloat) / 2; - x2 = pv->X + (PIN_SIZE (pv) + 1 + Bloat) / 2; - y1 = pv->Y - (PIN_SIZE (pv) + 1 + Bloat) / 2; - y2 = pv->Y + (PIN_SIZE (pv) + 1 + Bloat) / 2; - if (IsRectangleInPolygon (x1, y1, x2, y2, &i->polygon) - && ADD_PV_TO_LIST (pv, POLYGON_TYPE, &i->polygon, FCT_COPPER)) - longjmp (i->env, 1); - } - else if (TEST_FLAG (OCTAGONFLAG, pv)) - { - POLYAREA *oct = OctagonPoly (pv->X, pv->Y, PIN_SIZE (pv) / 2, GET_SQUARE(pv)); - if (isects (oct, &i->polygon, true) && ADD_PV_TO_LIST (pv, POLYGON_TYPE, &i->polygon, FCT_COPPER)) - longjmp (i->env, 1); - } - else - { - if (IsPointInPolygon - (pv->X, pv->Y, PIN_SIZE (pv) * 0.5 + Bloat, &i->polygon) - && ADD_PV_TO_LIST (pv, POLYGON_TYPE, &i->polygon, FCT_COPPER)) - longjmp (i->env, 1); - } - } - return 0; + /* note that holes in polygons are ok, so they don't generate warnings. */ + if (!TEST_FLAG(TheFlag, pv) && !TEST_FLAG(HOLEFLAG, pv) && + (TEST_THERM(i->layer, pv) || !TEST_FLAG(CLEARPOLYFLAG, &i->polygon) || !pv->Clearance)) { + if (TEST_FLAG(SQUAREFLAG, pv)) { + Coord x1, x2, y1, y2; + x1 = pv->X - (PIN_SIZE(pv) + 1 + Bloat) / 2; + x2 = pv->X + (PIN_SIZE(pv) + 1 + Bloat) / 2; + y1 = pv->Y - (PIN_SIZE(pv) + 1 + Bloat) / 2; + y2 = pv->Y + (PIN_SIZE(pv) + 1 + Bloat) / 2; + if (IsRectangleInPolygon(x1, y1, x2, y2, &i->polygon) + && ADD_PV_TO_LIST(pv, POLYGON_TYPE, &i->polygon, FCT_COPPER)) + longjmp(i->env, 1); + } + else if (TEST_FLAG(OCTAGONFLAG, pv)) { + POLYAREA *oct = OctagonPoly(pv->X, pv->Y, PIN_SIZE(pv) / 2, GET_SQUARE(pv)); + if (isects(oct, &i->polygon, true) && ADD_PV_TO_LIST(pv, POLYGON_TYPE, &i->polygon, FCT_COPPER)) + longjmp(i->env, 1); + } + else { + if (IsPointInPolygon(pv->X, pv->Y, PIN_SIZE(pv) * 0.5 + Bloat, &i->polygon) + && ADD_PV_TO_LIST(pv, POLYGON_TYPE, &i->polygon, FCT_COPPER)) + longjmp(i->env, 1); + } + } + return 0; } -static int -pv_rat_callback (const BoxType * b, void *cl) +static int pv_rat_callback(const BoxType * b, void *cl) { - PinTypePtr pv = (PinTypePtr) b; - struct lo_info *i = (struct lo_info *) cl; + PinTypePtr pv = (PinTypePtr) b; + struct lo_info *i = (struct lo_info *) cl; - /* rats can't cause DRC so there is no early exit */ - if (!TEST_FLAG (TheFlag, pv) && IS_PV_ON_RAT (pv, &i->rat)) - ADD_PV_TO_LIST (pv, RATLINE_TYPE, &i->rat, FCT_RAT); - return 0; + /* rats can't cause DRC so there is no early exit */ + if (!TEST_FLAG(TheFlag, pv) && IS_PV_ON_RAT(pv, &i->rat)) + ADD_PV_TO_LIST(pv, RATLINE_TYPE, &i->rat, FCT_RAT); + return 0; } /* --------------------------------------------------------------------------- @@ -1220,207 +1092,176 @@ * searches for new PVs that are connected to NEW LOs on the list * This routine updates the position counter of the lists too. */ -static bool -LookupPVConnectionsToLOList (bool AndRats) +static bool LookupPVConnectionsToLOList(bool AndRats) { - Cardinal layer; - struct lo_info info; + Cardinal layer; + struct lo_info info; - /* loop over all layers */ - for (layer = 0; layer < max_copper_layer; layer++) - { - if (LAYER_PTR (layer)->no_drc) - continue; - /* do nothing if there are no PV's */ - if (TotalP + TotalV == 0) - { - LineList[layer].Location = LineList[layer].Number; - ArcList[layer].Location = ArcList[layer].Number; - PolygonList[layer].Location = PolygonList[layer].Number; - continue; - } + /* loop over all layers */ + for (layer = 0; layer < max_copper_layer; layer++) { + if (LAYER_PTR(layer)->no_drc) + continue; + /* do nothing if there are no PV's */ + if (TotalP + TotalV == 0) { + LineList[layer].Location = LineList[layer].Number; + ArcList[layer].Location = ArcList[layer].Number; + PolygonList[layer].Location = PolygonList[layer].Number; + continue; + } - /* check all lines */ - while (LineList[layer].Location < LineList[layer].Number) - { - info.line = *(LINELIST_ENTRY (layer, LineList[layer].Location)); - EXPAND_BOUNDS (&info.line); - if (setjmp (info.env) == 0) - r_search (PCB->Data->via_tree, (BoxType *) & info.line, NULL, - pv_line_callback, &info); - else - return true; - if (setjmp (info.env) == 0) - r_search (PCB->Data->pin_tree, (BoxType *) & info.line, NULL, - pv_line_callback, &info); - else - return true; - LineList[layer].Location++; - } + /* check all lines */ + while (LineList[layer].Location < LineList[layer].Number) { + info.line = *(LINELIST_ENTRY(layer, LineList[layer].Location)); + EXPAND_BOUNDS(&info.line); + if (setjmp(info.env) == 0) + r_search(PCB->Data->via_tree, (BoxType *) & info.line, NULL, pv_line_callback, &info); + else + return true; + if (setjmp(info.env) == 0) + r_search(PCB->Data->pin_tree, (BoxType *) & info.line, NULL, pv_line_callback, &info); + else + return true; + LineList[layer].Location++; + } - /* check all arcs */ - while (ArcList[layer].Location < ArcList[layer].Number) - { - info.arc = *(ARCLIST_ENTRY (layer, ArcList[layer].Location)); - EXPAND_BOUNDS (&info.arc); - if (setjmp (info.env) == 0) - r_search (PCB->Data->via_tree, (BoxType *) & info.arc, NULL, - pv_arc_callback, &info); - else - return true; - if (setjmp (info.env) == 0) - r_search (PCB->Data->pin_tree, (BoxType *) & info.arc, NULL, - pv_arc_callback, &info); - else - return true; - ArcList[layer].Location++; - } + /* check all arcs */ + while (ArcList[layer].Location < ArcList[layer].Number) { + info.arc = *(ARCLIST_ENTRY(layer, ArcList[layer].Location)); + EXPAND_BOUNDS(&info.arc); + if (setjmp(info.env) == 0) + r_search(PCB->Data->via_tree, (BoxType *) & info.arc, NULL, pv_arc_callback, &info); + else + return true; + if (setjmp(info.env) == 0) + r_search(PCB->Data->pin_tree, (BoxType *) & info.arc, NULL, pv_arc_callback, &info); + else + return true; + ArcList[layer].Location++; + } - /* now all polygons */ - info.layer = layer; - while (PolygonList[layer].Location < PolygonList[layer].Number) - { - info.polygon = - *(POLYGONLIST_ENTRY (layer, PolygonList[layer].Location)); - EXPAND_BOUNDS (&info.polygon); - if (setjmp (info.env) == 0) - r_search (PCB->Data->via_tree, (BoxType *) & info.polygon, NULL, - pv_poly_callback, &info); - else - return true; - if (setjmp (info.env) == 0) - r_search (PCB->Data->pin_tree, (BoxType *) & info.polygon, NULL, - pv_poly_callback, &info); - else - return true; - PolygonList[layer].Location++; - } - } + /* now all polygons */ + info.layer = layer; + while (PolygonList[layer].Location < PolygonList[layer].Number) { + info.polygon = *(POLYGONLIST_ENTRY(layer, PolygonList[layer].Location)); + EXPAND_BOUNDS(&info.polygon); + if (setjmp(info.env) == 0) + r_search(PCB->Data->via_tree, (BoxType *) & info.polygon, NULL, pv_poly_callback, &info); + else + return true; + if (setjmp(info.env) == 0) + r_search(PCB->Data->pin_tree, (BoxType *) & info.polygon, NULL, pv_poly_callback, &info); + else + return true; + PolygonList[layer].Location++; + } + } - /* loop over all pad-layers */ - for (layer = 0; layer < 2; layer++) - { - /* do nothing if there are no PV's */ - if (TotalP + TotalV == 0) - { - PadList[layer].Location = PadList[layer].Number; - continue; - } + /* loop over all pad-layers */ + for (layer = 0; layer < 2; layer++) { + /* do nothing if there are no PV's */ + if (TotalP + TotalV == 0) { + PadList[layer].Location = PadList[layer].Number; + continue; + } - /* check all pads; for a detailed description see - * the handling of lines in this subroutine - */ - while (PadList[layer].Location < PadList[layer].Number) - { - info.pad = *(PADLIST_ENTRY (layer, PadList[layer].Location)); - EXPAND_BOUNDS (&info.pad); - if (setjmp (info.env) == 0) - r_search (PCB->Data->via_tree, (BoxType *) & info.pad, NULL, - pv_pad_callback, &info); - else - return true; - if (setjmp (info.env) == 0) - r_search (PCB->Data->pin_tree, (BoxType *) & info.pad, NULL, - pv_pad_callback, &info); - else - return true; - PadList[layer].Location++; - } - } + /* check all pads; for a detailed description see + * the handling of lines in this subroutine + */ + while (PadList[layer].Location < PadList[layer].Number) { + info.pad = *(PADLIST_ENTRY(layer, PadList[layer].Location)); + EXPAND_BOUNDS(&info.pad); + if (setjmp(info.env) == 0) + r_search(PCB->Data->via_tree, (BoxType *) & info.pad, NULL, pv_pad_callback, &info); + else + return true; + if (setjmp(info.env) == 0) + r_search(PCB->Data->pin_tree, (BoxType *) & info.pad, NULL, pv_pad_callback, &info); + else + return true; + PadList[layer].Location++; + } + } - /* do nothing if there are no PV's */ - if (TotalP + TotalV == 0) - RatList.Location = RatList.Number; + /* do nothing if there are no PV's */ + if (TotalP + TotalV == 0) + RatList.Location = RatList.Number; - /* check all rat-lines */ - if (AndRats) - { - while (RatList.Location < RatList.Number) - { - info.rat = *(RATLIST_ENTRY (RatList.Location)); - r_search_pt (PCB->Data->via_tree, & info.rat.Point1, 1, NULL, - pv_rat_callback, &info); - r_search_pt (PCB->Data->via_tree, & info.rat.Point2, 1, NULL, - pv_rat_callback, &info); - r_search_pt (PCB->Data->pin_tree, & info.rat.Point1, 1, NULL, - pv_rat_callback, &info); - r_search_pt (PCB->Data->pin_tree, & info.rat.Point2, 1, NULL, - pv_rat_callback, &info); + /* check all rat-lines */ + if (AndRats) { + while (RatList.Location < RatList.Number) { + info.rat = *(RATLIST_ENTRY(RatList.Location)); + r_search_pt(PCB->Data->via_tree, &info.rat.Point1, 1, NULL, pv_rat_callback, &info); + r_search_pt(PCB->Data->via_tree, &info.rat.Point2, 1, NULL, pv_rat_callback, &info); + r_search_pt(PCB->Data->pin_tree, &info.rat.Point1, 1, NULL, pv_rat_callback, &info); + r_search_pt(PCB->Data->pin_tree, &info.rat.Point2, 1, NULL, pv_rat_callback, &info); - RatList.Location++; - } - } - return (false); + RatList.Location++; + } + } + return (false); } -int -pv_touch_callback (const BoxType * b, void *cl) +int pv_touch_callback(const BoxType * b, void *cl) { - PinTypePtr pin = (PinTypePtr) b; - struct lo_info *i = (struct lo_info *) cl; + PinTypePtr pin = (PinTypePtr) b; + struct lo_info *i = (struct lo_info *) cl; - if (!TEST_FLAG (TheFlag, pin) && PinLineIntersect (pin, &i->line)) - longjmp (i->env, 1); - return 0; + if (!TEST_FLAG(TheFlag, pin) && PinLineIntersect(pin, &i->line)) + longjmp(i->env, 1); + return 0; } -static bool -PVTouchesLine (LineTypePtr line) +static bool PVTouchesLine(LineTypePtr line) { - struct lo_info info; + struct lo_info info; - info.line = *line; - EXPAND_BOUNDS (&info.line); - if (setjmp (info.env) == 0) - r_search (PCB->Data->via_tree, (BoxType *) & info.line, NULL, - pv_touch_callback, &info); - else - return true; - if (setjmp (info.env) == 0) - r_search (PCB->Data->pin_tree, (BoxType *) & info.line, NULL, - pv_touch_callback, &info); - else - return true; + info.line = *line; + EXPAND_BOUNDS(&info.line); + if (setjmp(info.env) == 0) + r_search(PCB->Data->via_tree, (BoxType *) & info.line, NULL, pv_touch_callback, &info); + else + return true; + if (setjmp(info.env) == 0) + r_search(PCB->Data->pin_tree, (BoxType *) & info.line, NULL, pv_touch_callback, &info); + else + return true; - return (false); + return (false); } /* reduce arc start angle and delta to 0..360 */ -static void -normalize_angles (Angle *sa, Angle *d) +static void normalize_angles(Angle * sa, Angle * d) { - if (*d < 0) - { - *sa += *d; - *d = - *d; - } - if (*d > 360) /* full circle */ - *d = 360; - *sa = NormalizeAngle (*sa); + if (*d < 0) { + *sa += *d; + *d = -*d; + } + if (*d > 360) /* full circle */ + *d = 360; + *sa = NormalizeAngle(*sa); } -static int -radius_crosses_arc (double x, double y, ArcTypePtr arc) +static int radius_crosses_arc(double x, double y, ArcTypePtr arc) { - double alpha = atan2 (y - arc->Y, -x + arc->X) * RAD_TO_DEG; - Angle sa = arc->StartAngle, d = arc->Delta; + double alpha = atan2(y - arc->Y, -x + arc->X) * RAD_TO_DEG; + Angle sa = arc->StartAngle, d = arc->Delta; - normalize_angles (&sa, &d); - if (alpha < 0) - alpha += 360; - if (sa <= alpha) - return (sa + d) >= alpha; - return (sa + d - 360) >= alpha; + normalize_angles(&sa, &d); + if (alpha < 0) + alpha += 360; + if (sa <= alpha) + return (sa + d) >= alpha; + return (sa + d - 360) >= alpha; } -static void -get_arc_ends (Coord *box, ArcTypePtr arc) +static void get_arc_ends(Coord * box, ArcTypePtr arc) { - box[0] = arc->X - arc->Width * cos (M180 * arc->StartAngle); - box[1] = arc->Y + arc->Height * sin (M180 * arc->StartAngle); - box[2] = arc->X - arc->Width * cos (M180 * (arc->StartAngle + arc->Delta)); - box[3] = arc->Y + arc->Height * sin (M180 * (arc->StartAngle + arc->Delta)); + box[0] = arc->X - arc->Width * cos(M180 * arc->StartAngle); + box[1] = arc->Y + arc->Height * sin(M180 * arc->StartAngle); + box[2] = arc->X - arc->Width * cos(M180 * (arc->StartAngle + arc->Delta)); + box[3] = arc->Y + arc->Height * sin(M180 * (arc->StartAngle + arc->Delta)); } + /* --------------------------------------------------------------------------- * check if two arcs intersect * first we check for circle intersections, @@ -1446,157 +1287,150 @@ * * */ -static bool -ArcArcIntersect (ArcTypePtr Arc1, ArcTypePtr Arc2) +static bool ArcArcIntersect(ArcTypePtr Arc1, ArcTypePtr Arc2) { - double x, y, dx, dy, r1, r2, a, d, l, t, t1, t2, dl; - Coord pdx, pdy; - Coord box[8]; + double x, y, dx, dy, r1, r2, a, d, l, t, t1, t2, dl; + Coord pdx, pdy; + Coord box[8]; - t = 0.5 * Arc1->Thickness + Bloat; - t2 = 0.5 * Arc2->Thickness; - t1 = t2 + Bloat; + t = 0.5 * Arc1->Thickness + Bloat; + t2 = 0.5 * Arc2->Thickness; + t1 = t2 + Bloat; - /* too thin arc */ - if (t < 0 || t1 < 0) - return false; + /* too thin arc */ + if (t < 0 || t1 < 0) + return false; - /* try the end points first */ - get_arc_ends (&box[0], Arc1); - get_arc_ends (&box[4], Arc2); - if (IsPointOnArc (box[0], box[1], t, Arc2) - || IsPointOnArc (box[2], box[3], t, Arc2) - || IsPointOnArc (box[4], box[5], t, Arc1) - || IsPointOnArc (box[6], box[7], t, Arc1)) - return true; + /* try the end points first */ + get_arc_ends(&box[0], Arc1); + get_arc_ends(&box[4], Arc2); + if (IsPointOnArc(box[0], box[1], t, Arc2) + || IsPointOnArc(box[2], box[3], t, Arc2) + || IsPointOnArc(box[4], box[5], t, Arc1) + || IsPointOnArc(box[6], box[7], t, Arc1)) + return true; - pdx = Arc2->X - Arc1->X; - pdy = Arc2->Y - Arc1->Y; - dl = Distance (Arc1->X, Arc1->Y, Arc2->X, Arc2->Y); - /* concentric arcs, simpler intersection conditions */ - if (dl < 0.5) - { - if ((Arc1->Width - t >= Arc2->Width - t2 - && Arc1->Width - t <= Arc2->Width + t2) - || (Arc1->Width + t >= Arc2->Width - t2 - && Arc1->Width + t <= Arc2->Width + t2)) - { - Angle sa1 = Arc1->StartAngle, d1 = Arc1->Delta; - Angle sa2 = Arc2->StartAngle, d2 = Arc2->Delta; - /* NB the endpoints have already been checked, - so we just compare the angles */ + pdx = Arc2->X - Arc1->X; + pdy = Arc2->Y - Arc1->Y; + dl = Distance(Arc1->X, Arc1->Y, Arc2->X, Arc2->Y); + /* concentric arcs, simpler intersection conditions */ + if (dl < 0.5) { + if ((Arc1->Width - t >= Arc2->Width - t2 && Arc1->Width - t <= Arc2->Width + t2) + || (Arc1->Width + t >= Arc2->Width - t2 && Arc1->Width + t <= Arc2->Width + t2)) { + Angle sa1 = Arc1->StartAngle, d1 = Arc1->Delta; + Angle sa2 = Arc2->StartAngle, d2 = Arc2->Delta; + /* NB the endpoints have already been checked, + so we just compare the angles */ - normalize_angles (&sa1, &d1); - normalize_angles (&sa2, &d2); - /* sa1 == sa2 was caught when checking endpoints */ - if (sa1 > sa2) - if (sa1 < sa2 + d2 || sa1 + d1 - 360 > sa2) - return true; - if (sa2 > sa1) - if (sa2 < sa1 + d1 || sa2 + d2 - 360 > sa1) - return true; - } - return false; - } - r1 = Arc1->Width; - r2 = Arc2->Width; - /* arcs centerlines are too far or too near */ - if (dl > r1 + r2 || dl + r1 < r2 || dl + r2 < r1) - { - /* check the nearest to the other arc's center point */ - dx = pdx * r1 / dl; - dy = pdy * r1 / dl; - if (dl + r1 < r2) /* Arc1 inside Arc2 */ - { - dx = - dx; - dy = - dy; + normalize_angles(&sa1, &d1); + normalize_angles(&sa2, &d2); + /* sa1 == sa2 was caught when checking endpoints */ + if (sa1 > sa2) + if (sa1 < sa2 + d2 || sa1 + d1 - 360 > sa2) + return true; + if (sa2 > sa1) + if (sa2 < sa1 + d1 || sa2 + d2 - 360 > sa1) + return true; + } + return false; } + r1 = Arc1->Width; + r2 = Arc2->Width; + /* arcs centerlines are too far or too near */ + if (dl > r1 + r2 || dl + r1 < r2 || dl + r2 < r1) { + /* check the nearest to the other arc's center point */ + dx = pdx * r1 / dl; + dy = pdy * r1 / dl; + if (dl + r1 < r2) { /* Arc1 inside Arc2 */ + dx = -dx; + dy = -dy; + } - if (radius_crosses_arc (Arc1->X + dx, Arc1->Y + dy, Arc1) - && IsPointOnArc (Arc1->X + dx, Arc1->Y + dy, t, Arc2)) - return true; + if (radius_crosses_arc(Arc1->X + dx, Arc1->Y + dy, Arc1) + && IsPointOnArc(Arc1->X + dx, Arc1->Y + dy, t, Arc2)) + return true; - dx = - pdx * r2 / dl; - dy = - pdy * r2 / dl; - if (dl + r2 < r1) /* Arc2 inside Arc1 */ - { - dx = - dx; - dy = - dy; + dx = -pdx * r2 / dl; + dy = -pdy * r2 / dl; + if (dl + r2 < r1) { /* Arc2 inside Arc1 */ + dx = -dx; + dy = -dy; + } + + if (radius_crosses_arc(Arc2->X + dx, Arc2->Y + dy, Arc2) + && IsPointOnArc(Arc2->X + dx, Arc2->Y + dy, t1, Arc1)) + return true; + return false; } - if (radius_crosses_arc (Arc2->X + dx, Arc2->Y + dy, Arc2) - && IsPointOnArc (Arc2->X + dx, Arc2->Y + dy, t1, Arc1)) - return true; - return false; - } + l = dl * dl; + r1 *= r1; + r2 *= r2; + a = 0.5 * (r1 - r2 + l) / l; + r1 = r1 / l; + d = r1 - a * a; + /* the circles are too far apart to touch or probably just touch: + check the nearest point */ + if (d < 0) + d = 0; + else + d = sqrt(d); + x = Arc1->X + a * pdx; + y = Arc1->Y + a * pdy; + dx = d * pdx; + dy = d * pdy; + if (radius_crosses_arc(x + dy, y - dx, Arc1) + && IsPointOnArc(x + dy, y - dx, t, Arc2)) + return true; + if (radius_crosses_arc(x + dy, y - dx, Arc2) + && IsPointOnArc(x + dy, y - dx, t1, Arc1)) + return true; - l = dl * dl; - r1 *= r1; - r2 *= r2; - a = 0.5 * (r1 - r2 + l) / l; - r1 = r1 / l; - d = r1 - a * a; - /* the circles are too far apart to touch or probably just touch: - check the nearest point */ - if (d < 0) - d = 0; - else - d = sqrt (d); - x = Arc1->X + a * pdx; - y = Arc1->Y + a * pdy; - dx = d * pdx; - dy = d * pdy; - if (radius_crosses_arc (x + dy, y - dx, Arc1) - && IsPointOnArc (x + dy, y - dx, t, Arc2)) - return true; - if (radius_crosses_arc (x + dy, y - dx, Arc2) - && IsPointOnArc (x + dy, y - dx, t1, Arc1)) - return true; - - if (radius_crosses_arc (x - dy, y + dx, Arc1) - && IsPointOnArc (x - dy, y + dx, t, Arc2)) - return true; - if (radius_crosses_arc (x - dy, y + dx, Arc2) - && IsPointOnArc (x - dy, y + dx, t1, Arc1)) - return true; - return false; + if (radius_crosses_arc(x - dy, y + dx, Arc1) + && IsPointOnArc(x - dy, y + dx, t, Arc2)) + return true; + if (radius_crosses_arc(x - dy, y + dx, Arc2) + && IsPointOnArc(x - dy, y + dx, t1, Arc1)) + return true; + return false; } /* --------------------------------------------------------------------------- * Tests if point is same as line end point */ -static bool -IsRatPointOnLineEnd (PointTypePtr Point, LineTypePtr Line) +static bool IsRatPointOnLineEnd(PointTypePtr Point, LineTypePtr Line) { - if ((Point->X == Line->Point1.X - && Point->Y == Line->Point1.Y) - || (Point->X == Line->Point2.X && Point->Y == Line->Point2.Y)) - return (true); - return (false); + if ((Point->X == Line->Point1.X && Point->Y == Line->Point1.Y) + || (Point->X == Line->Point2.X && Point->Y == Line->Point2.Y)) + return (true); + return (false); } -static void -form_slanted_rectangle (PointType p[4], LineTypePtr l) +static void form_slanted_rectangle(PointType p[4], LineTypePtr l) /* writes vertices of a squared line */ { - double dwx = 0, dwy = 0; - if (l->Point1.Y == l->Point2.Y) - dwx = l->Thickness / 2.0; - else if (l->Point1.X == l->Point2.X) - dwy = l->Thickness / 2.0; - else - { - Coord dX = l->Point2.X - l->Point1.X; - Coord dY = l->Point2.Y - l->Point1.Y; - double r = Distance (l->Point1.X, l->Point1.Y, l->Point2.X, l->Point2.Y); - dwx = l->Thickness / 2.0 / r * dX; - dwy = l->Thickness / 2.0 / r * dY; - } - p[0].X = l->Point1.X - dwx + dwy; p[0].Y = l->Point1.Y - dwy - dwx; - p[1].X = l->Point1.X - dwx - dwy; p[1].Y = l->Point1.Y - dwy + dwx; - p[2].X = l->Point2.X + dwx - dwy; p[2].Y = l->Point2.Y + dwy + dwx; - p[3].X = l->Point2.X + dwx + dwy; p[3].Y = l->Point2.Y + dwy - dwx; + double dwx = 0, dwy = 0; + if (l->Point1.Y == l->Point2.Y) + dwx = l->Thickness / 2.0; + else if (l->Point1.X == l->Point2.X) + dwy = l->Thickness / 2.0; + else { + Coord dX = l->Point2.X - l->Point1.X; + Coord dY = l->Point2.Y - l->Point1.Y; + double r = Distance(l->Point1.X, l->Point1.Y, l->Point2.X, l->Point2.Y); + dwx = l->Thickness / 2.0 / r * dX; + dwy = l->Thickness / 2.0 / r * dY; + } + p[0].X = l->Point1.X - dwx + dwy; + p[0].Y = l->Point1.Y - dwy - dwx; + p[1].X = l->Point1.X - dwx - dwy; + p[1].Y = l->Point1.Y - dwy + dwx; + p[2].X = l->Point2.X + dwx - dwy; + p[2].Y = l->Point2.Y + dwy + dwx; + p[3].X = l->Point2.X + dwx + dwy; + p[3].Y = l->Point2.Y + dwy - dwx; } + /* --------------------------------------------------------------------------- * checks if two lines intersect * from news FAQ: @@ -1652,84 +1486,72 @@ * Also note that the denominators of eqn 1 & 2 are identical. * */ -bool -LineLineIntersect (LineTypePtr Line1, LineTypePtr Line2) +bool LineLineIntersect(LineTypePtr Line1, LineTypePtr Line2) { - double s, r; - double line1_dx, line1_dy, line2_dx, line2_dy, - point1_dx, point1_dy; - if (TEST_FLAG (SQUAREFLAG, Line1))/* pretty reckless recursion */ - { - PointType p[4]; - form_slanted_rectangle (p, Line1); - return IsLineInQuadrangle (p, Line2); - } - /* here come only round Line1 because IsLineInQuadrangle() - calls LineLineIntersect() with first argument rounded*/ - if (TEST_FLAG (SQUAREFLAG, Line2)) - { - PointType p[4]; - form_slanted_rectangle (p, Line2); - return IsLineInQuadrangle (p, Line1); - } - /* now all lines are round */ + double s, r; + double line1_dx, line1_dy, line2_dx, line2_dy, point1_dx, point1_dy; + if (TEST_FLAG(SQUAREFLAG, Line1)) { /* pretty reckless recursion */ + PointType p[4]; + form_slanted_rectangle(p, Line1); + return IsLineInQuadrangle(p, Line2); + } + /* here come only round Line1 because IsLineInQuadrangle() + calls LineLineIntersect() with first argument rounded */ + if (TEST_FLAG(SQUAREFLAG, Line2)) { + PointType p[4]; + form_slanted_rectangle(p, Line2); + return IsLineInQuadrangle(p, Line1); + } + /* now all lines are round */ - /* Check endpoints: this provides a quick exit, catches - * cases where the "real" lines don't intersect but the - * thick lines touch, and ensures that the dx/dy business - * below does not cause a divide-by-zero. */ - if (IsPointInPad (Line2->Point1.X, Line2->Point1.Y, - MAX (Line2->Thickness / 2 + Bloat, 0), - (PadTypePtr) Line1) - || IsPointInPad (Line2->Point2.X, Line2->Point2.Y, - MAX (Line2->Thickness / 2 + Bloat, 0), - (PadTypePtr) Line1) - || IsPointInPad (Line1->Point1.X, Line1->Point1.Y, - MAX (Line1->Thickness / 2 + Bloat, 0), - (PadTypePtr) Line2) - || IsPointInPad (Line1->Point2.X, Line1->Point2.Y, - MAX (Line1->Thickness / 2 + Bloat, 0), - (PadTypePtr) Line2)) - return true; + /* Check endpoints: this provides a quick exit, catches + * cases where the "real" lines don't intersect but the + * thick lines touch, and ensures that the dx/dy business + * below does not cause a divide-by-zero. */ + if (IsPointInPad(Line2->Point1.X, Line2->Point1.Y, MAX(Line2->Thickness / 2 + Bloat, 0), (PadTypePtr) Line1) + || IsPointInPad(Line2->Point2.X, Line2->Point2.Y, MAX(Line2->Thickness / 2 + Bloat, 0), (PadTypePtr) Line1) + || IsPointInPad(Line1->Point1.X, Line1->Point1.Y, MAX(Line1->Thickness / 2 + Bloat, 0), (PadTypePtr) Line2) + || IsPointInPad(Line1->Point2.X, Line1->Point2.Y, MAX(Line1->Thickness / 2 + Bloat, 0), (PadTypePtr) Line2)) + return true; - /* setup some constants */ - line1_dx = Line1->Point2.X - Line1->Point1.X; - line1_dy = Line1->Point2.Y - Line1->Point1.Y; - line2_dx = Line2->Point2.X - Line2->Point1.X; - line2_dy = Line2->Point2.Y - Line2->Point1.Y; - point1_dx = Line1->Point1.X - Line2->Point1.X; - point1_dy = Line1->Point1.Y - Line2->Point1.Y; + /* setup some constants */ + line1_dx = Line1->Point2.X - Line1->Point1.X; + line1_dy = Line1->Point2.Y - Line1->Point1.Y; + line2_dx = Line2->Point2.X - Line2->Point1.X; + line2_dy = Line2->Point2.Y - Line2->Point1.Y; + point1_dx = Line1->Point1.X - Line2->Point1.X; + point1_dy = Line1->Point1.Y - Line2->Point1.Y; - /* If either line is a point, we have failed already, since the - * endpoint check above will have caught an "intersection". */ - if ((line1_dx == 0 && line1_dy == 0) - || (line2_dx == 0 && line2_dy == 0)) - return false; + /* If either line is a point, we have failed already, since the + * endpoint check above will have caught an "intersection". */ + if ((line1_dx == 0 && line1_dy == 0) + || (line2_dx == 0 && line2_dy == 0)) + return false; - /* set s to cross product of Line1 and the line - * Line1.Point1--Line2.Point1 (as vectors) */ - s = point1_dy * line1_dx - point1_dx * line1_dy; + /* set s to cross product of Line1 and the line + * Line1.Point1--Line2.Point1 (as vectors) */ + s = point1_dy * line1_dx - point1_dx * line1_dy; - /* set r to cross product of both lines (as vectors) */ - r = line1_dx * line2_dy - line1_dy * line2_dx; + /* set r to cross product of both lines (as vectors) */ + r = line1_dx * line2_dy - line1_dy * line2_dx; - /* No cross product means parallel lines, or maybe Line2 is - * zero-length. In either case, since we did a bounding-box - * check before getting here, the above IsPointInPad() checks - * will have caught any intersections. */ - if (r == 0.0) - return false; + /* No cross product means parallel lines, or maybe Line2 is + * zero-length. In either case, since we did a bounding-box + * check before getting here, the above IsPointInPad() checks + * will have caught any intersections. */ + if (r == 0.0) + return false; - s /= r; - r = (point1_dy * line2_dx - point1_dx * line2_dy) / r; + s /= r; + r = (point1_dy * line2_dx - point1_dx * line2_dy) / r; - /* intersection is at least on AB */ - if (r >= 0.0 && r <= 1.0) - return (s >= 0.0 && s <= 1.0); + /* intersection is at least on AB */ + if (r >= 0.0 && r <= 1.0) + return (s >= 0.0 && s <= 1.0); - /* intersection is at least on CD */ - /* [removed this case since it always returns false --asp] */ - return false; + /* intersection is at least on CD */ + /* [removed this case since it always returns false --asp] */ + return false; } /*--------------------------------------------------- @@ -1761,104 +1583,88 @@ * * The end points are hell so they are checked individually */ -bool -LineArcIntersect (LineTypePtr Line, ArcTypePtr Arc) +bool LineArcIntersect(LineTypePtr Line, ArcTypePtr Arc) { - double dx, dy, dx1, dy1, l, d, r, r2, Radius; - BoxTypePtr box; + double dx, dy, dx1, dy1, l, d, r, r2, Radius; + BoxTypePtr box; - dx = Line->Point2.X - Line->Point1.X; - dy = Line->Point2.Y - Line->Point1.Y; - dx1 = Line->Point1.X - Arc->X; - dy1 = Line->Point1.Y - Arc->Y; - l = dx * dx + dy * dy; - d = dx * dy1 - dy * dx1; - d *= d; + dx = Line->Point2.X - Line->Point1.X; + dy = Line->Point2.Y - Line->Point1.Y; + dx1 = Line->Point1.X - Arc->X; + dy1 = Line->Point1.Y - Arc->Y; + l = dx * dx + dy * dy; + d = dx * dy1 - dy * dx1; + d *= d; - /* use the larger diameter circle first */ - Radius = - Arc->Width + MAX (0.5 * (Arc->Thickness + Line->Thickness) + Bloat, 0.0); - Radius *= Radius; - r2 = Radius * l - d; - /* projection doesn't even intersect circle when r2 < 0 */ - if (r2 < 0) - return (false); - /* check the ends of the line in case the projected point */ - /* of intersection is beyond the line end */ - if (IsPointOnArc - (Line->Point1.X, Line->Point1.Y, - MAX (0.5 * Line->Thickness + Bloat, 0.0), Arc)) - return (true); - if (IsPointOnArc - (Line->Point2.X, Line->Point2.Y, - MAX (0.5 * Line->Thickness + Bloat, 0.0), Arc)) - return (true); - if (l == 0.0) - return (false); - r2 = sqrt (r2); - Radius = -(dx * dx1 + dy * dy1); - r = (Radius + r2) / l; - if (r >= 0 && r <= 1 - && IsPointOnArc (Line->Point1.X + r * dx, - Line->Point1.Y + r * dy, - MAX (0.5 * Line->Thickness + Bloat, 0.0), Arc)) - return (true); - r = (Radius - r2) / l; - if (r >= 0 && r <= 1 - && IsPointOnArc (Line->Point1.X + r * dx, - Line->Point1.Y + r * dy, - MAX (0.5 * Line->Thickness + Bloat, 0.0), Arc)) - return (true); - /* check arc end points */ - box = GetArcEnds (Arc); - if (IsPointInPad (box->X1, box->Y1, Arc->Thickness * 0.5 + Bloat, (PadTypePtr)Line)) - return true; - if (IsPointInPad (box->X2, box->Y2, Arc->Thickness * 0.5 + Bloat, (PadTypePtr)Line)) - return true; - return false; + /* use the larger diameter circle first */ + Radius = Arc->Width + MAX(0.5 * (Arc->Thickness + Line->Thickness) + Bloat, 0.0); + Radius *= Radius; + r2 = Radius * l - d; + /* projection doesn't even intersect circle when r2 < 0 */ + if (r2 < 0) + return (false); + /* check the ends of the line in case the projected point */ + /* of intersection is beyond the line end */ + if (IsPointOnArc(Line->Point1.X, Line->Point1.Y, MAX(0.5 * Line->Thickness + Bloat, 0.0), Arc)) + return (true); + if (IsPointOnArc(Line->Point2.X, Line->Point2.Y, MAX(0.5 * Line->Thickness + Bloat, 0.0), Arc)) + return (true); + if (l == 0.0) + return (false); + r2 = sqrt(r2); + Radius = -(dx * dx1 + dy * dy1); + r = (Radius + r2) / l; + if (r >= 0 && r <= 1 + && IsPointOnArc(Line->Point1.X + r * dx, Line->Point1.Y + r * dy, MAX(0.5 * Line->Thickness + Bloat, 0.0), Arc)) + return (true); + r = (Radius - r2) / l; + if (r >= 0 && r <= 1 + && IsPointOnArc(Line->Point1.X + r * dx, Line->Point1.Y + r * dy, MAX(0.5 * Line->Thickness + Bloat, 0.0), Arc)) + return (true); + /* check arc end points */ + box = GetArcEnds(Arc); + if (IsPointInPad(box->X1, box->Y1, Arc->Thickness * 0.5 + Bloat, (PadTypePtr) Line)) + return true; + if (IsPointInPad(box->X2, box->Y2, Arc->Thickness * 0.5 + Bloat, (PadTypePtr) Line)) + return true; + return false; } -static int -LOCtoArcLine_callback (const BoxType * b, void *cl) +static int LOCtoArcLine_callback(const BoxType * b, void *cl) { - LineTypePtr line = (LineTypePtr) b; - struct lo_info *i = (struct lo_info *) cl; + LineTypePtr line = (LineTypePtr) b; + struct lo_info *i = (struct lo_info *) cl; - if (!TEST_FLAG (TheFlag, line) && LineArcIntersect (line, &i->arc)) - { - if (ADD_LINE_TO_LIST (i->layer, line, ARC_TYPE, &i->arc, FCT_COPPER)) - longjmp (i->env, 1); - } - return 0; + if (!TEST_FLAG(TheFlag, line) && LineArcIntersect(line, &i->arc)) { + if (ADD_LINE_TO_LIST(i->layer, line, ARC_TYPE, &i->arc, FCT_COPPER)) + longjmp(i->env, 1); + } + return 0; } -static int -LOCtoArcArc_callback (const BoxType * b, void *cl) +static int LOCtoArcArc_callback(const BoxType * b, void *cl) { - ArcTypePtr arc = (ArcTypePtr) b; - struct lo_info *i = (struct lo_info *) cl; + ArcTypePtr arc = (ArcTypePtr) b; + struct lo_info *i = (struct lo_info *) cl; - if (!arc->Thickness) - return 0; - if (!TEST_FLAG (TheFlag, arc) && ArcArcIntersect (&i->arc, arc)) - { - if (ADD_ARC_TO_LIST (i->layer, arc, ARC_TYPE, &i->arc, FCT_COPPER)) - longjmp (i->env, 1); - } - return 0; + if (!arc->Thickness) + return 0; + if (!TEST_FLAG(TheFlag, arc) && ArcArcIntersect(&i->arc, arc)) { + if (ADD_ARC_TO_LIST(i->layer, arc, ARC_TYPE, &i->arc, FCT_COPPER)) + longjmp(i->env, 1); + } + return 0; } -static int -LOCtoArcPad_callback (const BoxType * b, void *cl) +static int LOCtoArcPad_callback(const BoxType * b, void *cl) { - PadTypePtr pad = (PadTypePtr) b; - struct lo_info *i = (struct lo_info *) cl; + PadTypePtr pad = (PadTypePtr) b; + struct lo_info *i = (struct lo_info *) cl; - if (!TEST_FLAG (TheFlag, pad) && i->layer == - (TEST_FLAG (ONSOLDERFLAG, pad) ? SOLDER_LAYER : COMPONENT_LAYER) - && ArcPadIntersect (&i->arc, pad) && ADD_PAD_TO_LIST (i->layer, pad, ARC_TYPE, &i->arc, FCT_COPPER)) - longjmp (i->env, 1); - return 0; + if (!TEST_FLAG(TheFlag, pad) && i->layer == (TEST_FLAG(ONSOLDERFLAG, pad) ? SOLDER_LAYER : COMPONENT_LAYER) + && ArcPadIntersect(&i->arc, pad) && ADD_PAD_TO_LIST(i->layer, pad, ARC_TYPE, &i->arc, FCT_COPPER)) + longjmp(i->env, 1); + return 0; } /* --------------------------------------------------------------------------- @@ -1868,127 +1674,108 @@ * the notation that is used is: * Xij means Xj at arc i */ -static bool -LookupLOConnectionsToArc (ArcTypePtr Arc, Cardinal LayerGroup) +static bool LookupLOConnectionsToArc(ArcTypePtr Arc, Cardinal LayerGroup) { - Cardinal entry; - struct lo_info info; + Cardinal entry; + struct lo_info info; - info.arc = *Arc; - EXPAND_BOUNDS (&info.arc); - /* loop over all layers of the group */ - for (entry = 0; entry < PCB->LayerGroups.Number[LayerGroup]; entry++) - { - Cardinal layer; - GList *i; + info.arc = *Arc; + EXPAND_BOUNDS(&info.arc); + /* loop over all layers of the group */ + for (entry = 0; entry < PCB->LayerGroups.Number[LayerGroup]; entry++) { + Cardinal layer; + GList *i; - layer = PCB->LayerGroups.Entries[LayerGroup][entry]; + layer = PCB->LayerGroups.Entries[LayerGroup][entry]; - /* handle normal layers */ - if (layer < max_copper_layer) - { - info.layer = layer; - /* add arcs */ - if (setjmp (info.env) == 0) - r_search (LAYER_PTR (layer)->line_tree, &info.arc.BoundingBox, - NULL, LOCtoArcLine_callback, &info); - else - return true; + /* handle normal layers */ + if (layer < max_copper_layer) { + info.layer = layer; + /* add arcs */ + if (setjmp(info.env) == 0) + r_search(LAYER_PTR(layer)->line_tree, &info.arc.BoundingBox, NULL, LOCtoArcLine_callback, &info); + else + return true; - if (setjmp (info.env) == 0) - r_search (LAYER_PTR (layer)->arc_tree, &info.arc.BoundingBox, - NULL, LOCtoArcArc_callback, &info); - else - return true; + if (setjmp(info.env) == 0) + r_search(LAYER_PTR(layer)->arc_tree, &info.arc.BoundingBox, NULL, LOCtoArcArc_callback, &info); + else + return true; - /* now check all polygons */ - for (i = PCB->Data->Layer[layer].Polygon; - i != NULL; i = g_list_next (i)) - { - PolygonType *polygon = i->data; - if (!TEST_FLAG (TheFlag, polygon) && IsArcInPolygon (Arc, polygon) - && ADD_POLYGON_TO_LIST (layer, polygon, ARC_TYPE, Arc, FCT_COPPER)) - return true; - } - } - else - { - info.layer = layer - max_copper_layer; - if (setjmp (info.env) == 0) - r_search (PCB->Data->pad_tree, &info.arc.BoundingBox, NULL, - LOCtoArcPad_callback, &info); - else - return true; - } - } - return (false); + /* now check all polygons */ + for (i = PCB->Data->Layer[layer].Polygon; i != NULL; i = g_list_next(i)) { + PolygonType *polygon = i->data; + if (!TEST_FLAG(TheFlag, polygon) && IsArcInPolygon(Arc, polygon) + && ADD_POLYGON_TO_LIST(layer, polygon, ARC_TYPE, Arc, FCT_COPPER)) + return true; + } + } + else { + info.layer = layer - max_copper_layer; + if (setjmp(info.env) == 0) + r_search(PCB->Data->pad_tree, &info.arc.BoundingBox, NULL, LOCtoArcPad_callback, &info); + else + return true; + } + } + return (false); } -static int -LOCtoLineLine_callback (const BoxType * b, void *cl) +static int LOCtoLineLine_callback(const BoxType * b, void *cl) { - LineTypePtr line = (LineTypePtr) b; - struct lo_info *i = (struct lo_info *) cl; + LineTypePtr line = (LineTypePtr) b; + struct lo_info *i = (struct lo_info *) cl; - if (!TEST_FLAG (TheFlag, line) && LineLineIntersect (&i->line, line)) - { - if (ADD_LINE_TO_LIST (i->layer, line, LINE_TYPE, &i->line, FCT_COPPER)) - longjmp (i->env, 1); - } - return 0; + if (!TEST_FLAG(TheFlag, line) && LineLineIntersect(&i->line, line)) { + if (ADD_LINE_TO_LIST(i->layer, line, LINE_TYPE, &i->line, FCT_COPPER)) + longjmp(i->env, 1); + } + return 0; } -static int -LOCtoLineArc_callback (const BoxType * b, void *cl) +static int LOCtoLineArc_callback(const BoxType * b, void *cl) { - ArcTypePtr arc = (ArcTypePtr) b; - struct lo_info *i = (struct lo_info *) cl; + ArcTypePtr arc = (ArcTypePtr) b; + struct lo_info *i = (struct lo_info *) cl; - if (!arc->Thickness) - return 0; - if (!TEST_FLAG (TheFlag, arc) && LineArcIntersect (&i->line, arc)) - { - if (ADD_ARC_TO_LIST (i->layer, arc, LINE_TYPE, &i->line, FCT_COPPER)) - longjmp (i->env, 1); - } - return 0; + if (!arc->Thickness) + return 0; + if (!TEST_FLAG(TheFlag, arc) && LineArcIntersect(&i->line, arc)) { + if (ADD_ARC_TO_LIST(i->layer, arc, LINE_TYPE, &i->line, FCT_COPPER)) + longjmp(i->env, 1); + } + return 0; } -static int -LOCtoLineRat_callback (const BoxType * b, void *cl) +static int LOCtoLineRat_callback(const BoxType * b, void *cl) { - RatTypePtr rat = (RatTypePtr) b; - struct lo_info *i = (struct lo_info *) cl; + RatTypePtr rat = (RatTypePtr) b; + struct lo_info *i = (struct lo_info *) cl; - if (!TEST_FLAG (TheFlag, rat)) - { - if ((rat->group1 == i->layer) - && IsRatPointOnLineEnd (&rat->Point1, &i->line)) - { - if (ADD_RAT_TO_LIST (rat, LINE_TYPE, &i->line, FCT_RAT)) - longjmp (i->env, 1); - } - else if ((rat->group2 == i->layer) - && IsRatPointOnLineEnd (&rat->Point2, &i->line)) - { - if (ADD_RAT_TO_LIST (rat, LINE_TYPE, &i->line, FCT_RAT)) - longjmp (i->env, 1); - } - } - return 0; + if (!TEST_FLAG(TheFlag, rat)) { + if ((rat->group1 == i->layer) + && IsRatPointOnLineEnd(&rat->Point1, &i->line)) { + if (ADD_RAT_TO_LIST(rat, LINE_TYPE, &i->line, FCT_RAT)) + longjmp(i->env, 1); + } + else if ((rat->group2 == i->layer) + && IsRatPointOnLineEnd(&rat->Point2, &i->line)) { + if (ADD_RAT_TO_LIST(rat, LINE_TYPE, &i->line, FCT_RAT)) + longjmp(i->env, 1); + } + } + return 0; } -static int -LOCtoLinePad_callback (const BoxType * b, void *cl) +static int LOCtoLinePad_callback(const BoxType * b, void *cl) { - PadTypePtr pad = (PadTypePtr) b; - struct lo_info *i = (struct lo_info *) cl; + PadTypePtr pad = (PadTypePtr) b; + struct lo_info *i = (struct lo_info *) cl; - if (!TEST_FLAG (TheFlag, pad) && i->layer == - (TEST_FLAG (ONSOLDERFLAG, pad) ? SOLDER_LAYER : COMPONENT_LAYER) - && LinePadIntersect (&i->line, pad) && ADD_PAD_TO_LIST (i->layer, pad, LINE_TYPE, &i->line, FCT_COPPER)) - longjmp (i->env, 1); - return 0; + if (!TEST_FLAG(TheFlag, pad) && i->layer == (TEST_FLAG(ONSOLDERFLAG, pad) ? SOLDER_LAYER : COMPONENT_LAYER) + && LinePadIntersect(&i->line, pad) && ADD_PAD_TO_LIST(i->layer, pad, LINE_TYPE, &i->line, FCT_COPPER)) + longjmp(i->env, 1); + return 0; } /* --------------------------------------------------------------------------- @@ -1998,225 +1785,193 @@ * the notation that is used is: * Xij means Xj at line i */ -static bool -LookupLOConnectionsToLine (LineTypePtr Line, Cardinal LayerGroup, - bool PolysTo) +static bool LookupLOConnectionsToLine(LineTypePtr Line, Cardinal LayerGroup, bool PolysTo) { - Cardinal entry; - struct lo_info info; + Cardinal entry; + struct lo_info info; - info.line = *Line; - info.layer = LayerGroup; - EXPAND_BOUNDS (&info.line) - /* add the new rat lines */ - if (setjmp (info.env) == 0) - r_search (PCB->Data->rat_tree, &info.line.BoundingBox, NULL, - LOCtoLineRat_callback, &info); - else - return true; + info.line = *Line; + info.layer = LayerGroup; + EXPAND_BOUNDS(&info.line) + /* add the new rat lines */ + if (setjmp(info.env) == 0) + r_search(PCB->Data->rat_tree, &info.line.BoundingBox, NULL, LOCtoLineRat_callback, &info); + else + return true; - /* loop over all layers of the group */ - for (entry = 0; entry < PCB->LayerGroups.Number[LayerGroup]; entry++) - { - Cardinal layer; + /* loop over all layers of the group */ + for (entry = 0; entry < PCB->LayerGroups.Number[LayerGroup]; entry++) { + Cardinal layer; - layer = PCB->LayerGroups.Entries[LayerGroup][entry]; + layer = PCB->LayerGroups.Entries[LayerGroup][entry]; - /* handle normal layers */ - if (layer < max_copper_layer) - { - info.layer = layer; - /* add lines */ - if (setjmp (info.env) == 0) - r_search (LAYER_PTR (layer)->line_tree, (BoxType *) & info.line, - NULL, LOCtoLineLine_callback, &info); - else - return true; - /* add arcs */ - if (setjmp (info.env) == 0) - r_search (LAYER_PTR (layer)->arc_tree, (BoxType *) & info.line, - NULL, LOCtoLineArc_callback, &info); - else - return true; - /* now check all polygons */ - if (PolysTo) - { - GList *i; - for (i = PCB->Data->Layer[layer].Polygon; - i != NULL; i = g_list_next (i)) - { - PolygonType *polygon = i->data; - if (!TEST_FLAG - (TheFlag, polygon) && IsLineInPolygon (Line, polygon) - && ADD_POLYGON_TO_LIST (layer, polygon, LINE_TYPE, Line, FCT_COPPER)) - return true; - } - } - } - else - { - /* handle special 'pad' layers */ - info.layer = layer - max_copper_layer; - if (setjmp (info.env) == 0) - r_search (PCB->Data->pad_tree, &info.line.BoundingBox, NULL, - LOCtoLinePad_callback, &info); - else - return true; - } - } - return (false); + /* handle normal layers */ + if (layer < max_copper_layer) { + info.layer = layer; + /* add lines */ + if (setjmp(info.env) == 0) + r_search(LAYER_PTR(layer)->line_tree, (BoxType *) & info.line, NULL, LOCtoLineLine_callback, &info); + else + return true; + /* add arcs */ + if (setjmp(info.env) == 0) + r_search(LAYER_PTR(layer)->arc_tree, (BoxType *) & info.line, NULL, LOCtoLineArc_callback, &info); + else + return true; + /* now check all polygons */ + if (PolysTo) { + GList *i; + for (i = PCB->Data->Layer[layer].Polygon; i != NULL; i = g_list_next(i)) { + PolygonType *polygon = i->data; + if (!TEST_FLAG(TheFlag, polygon) && IsLineInPolygon(Line, polygon) + && ADD_POLYGON_TO_LIST(layer, polygon, LINE_TYPE, Line, FCT_COPPER)) + return true; + } + } + } + else { + /* handle special 'pad' layers */ + info.layer = layer - max_copper_layer; + if (setjmp(info.env) == 0) + r_search(PCB->Data->pad_tree, &info.line.BoundingBox, NULL, LOCtoLinePad_callback, &info); + else + return true; + } + } + return (false); } -static int -LOT_Linecallback (const BoxType * b, void *cl) +static int LOT_Linecallback(const BoxType * b, void *cl) { - LineTypePtr line = (LineTypePtr) b; - struct lo_info *i = (struct lo_info *) cl; + LineTypePtr line = (LineTypePtr) b; + struct lo_info *i = (struct lo_info *) cl; - if (!TEST_FLAG (TheFlag, line) && LineLineIntersect (&i->line, line)) - longjmp (i->env, 1); - return 0; + if (!TEST_FLAG(TheFlag, line) && LineLineIntersect(&i->line, line)) + longjmp(i->env, 1); + return 0; } -static int -LOT_Arccallback (const BoxType * b, void *cl) +static int LOT_Arccallback(const BoxType * b, void *cl) { - ArcTypePtr arc = (ArcTypePtr) b; - struct lo_info *i = (struct lo_info *) cl; + ArcTypePtr arc = (ArcTypePtr) b; + struct lo_info *i = (struct lo_info *) cl; - if (!arc->Thickness) - return 0; - if (!TEST_FLAG (TheFlag, arc) && LineArcIntersect (&i->line, arc)) - longjmp (i->env, 1); - return 0; + if (!arc->Thickness) + return 0; + if (!TEST_FLAG(TheFlag, arc) && LineArcIntersect(&i->line, arc)) + longjmp(i->env, 1); + return 0; } -static int -LOT_Padcallback (const BoxType * b, void *cl) +static int LOT_Padcallback(const BoxType * b, void *cl) { - PadTypePtr pad = (PadTypePtr) b; - struct lo_info *i = (struct lo_info *) cl; + PadTypePtr pad = (PadTypePtr) b; + struct lo_info *i = (struct lo_info *) cl; - if (!TEST_FLAG (TheFlag, pad) && i->layer == - (TEST_FLAG (ONSOLDERFLAG, pad) ? SOLDER_LAYER : COMPONENT_LAYER) - && LinePadIntersect (&i->line, pad)) - longjmp (i->env, 1); - return 0; + if (!TEST_FLAG(TheFlag, pad) && i->layer == (TEST_FLAG(ONSOLDERFLAG, pad) ? SOLDER_LAYER : COMPONENT_LAYER) + && LinePadIntersect(&i->line, pad)) + longjmp(i->env, 1); + return 0; } -static bool -LOTouchesLine (LineTypePtr Line, Cardinal LayerGroup) +static bool LOTouchesLine(LineTypePtr Line, Cardinal LayerGroup) { - Cardinal entry; - struct lo_info info; + Cardinal entry; + struct lo_info info; - /* the maximum possible distance */ + /* the maximum possible distance */ - info.line = *Line; - EXPAND_BOUNDS (&info.line); + info.line = *Line; + EXPAND_BOUNDS(&info.line); - /* loop over all layers of the group */ - for (entry = 0; entry < PCB->LayerGroups.Number[LayerGroup]; entry++) - { - Cardinal layer = PCB->LayerGroups.Entries[LayerGroup][entry]; + /* loop over all layers of the group */ + for (entry = 0; entry < PCB->LayerGroups.Number[LayerGroup]; entry++) { + Cardinal layer = PCB->LayerGroups.Entries[LayerGroup][entry]; - /* handle normal layers */ - if (layer < max_copper_layer) - { - GList *i; + /* handle normal layers */ + if (layer < max_copper_layer) { + GList *i; - /* find the first line that touches coordinates */ + /* find the first line that touches coordinates */ - if (setjmp (info.env) == 0) - r_search (LAYER_PTR (layer)->line_tree, (BoxType *) & info.line, - NULL, LOT_Linecallback, &info); - else - return (true); - if (setjmp (info.env) == 0) - r_search (LAYER_PTR (layer)->arc_tree, (BoxType *) & info.line, - NULL, LOT_Arccallback, &info); - else - return (true); + if (setjmp(info.env) == 0) + r_search(LAYER_PTR(layer)->line_tree, (BoxType *) & info.line, NULL, LOT_Linecallback, &info); + else + return (true); + if (setjmp(info.env) == 0) + r_search(LAYER_PTR(layer)->arc_tree, (BoxType *) & info.line, NULL, LOT_Arccallback, &info); + else + return (true); - /* now check all polygons */ - for (i = PCB->Data->Layer[layer].Polygon; - i != NULL; i = g_list_next (i)) - { - PolygonType *polygon = i->data; - if (!TEST_FLAG (TheFlag, polygon) - && IsLineInPolygon (Line, polygon)) - return (true); - } - } - else - { - /* handle special 'pad' layers */ - info.layer = layer - max_copper_layer; - if (setjmp (info.env) == 0) - r_search (PCB->Data->pad_tree, &info.line.BoundingBox, NULL, - LOT_Padcallback, &info); - else - return true; - } - } - return (false); + /* now check all polygons */ + for (i = PCB->Data->Layer[layer].Polygon; i != NULL; i = g_list_next(i)) { + PolygonType *polygon = i->data; + if (!TEST_FLAG(TheFlag, polygon) + && IsLineInPolygon(Line, polygon)) + return (true); + } + } + else { + /* handle special 'pad' layers */ + info.layer = layer - max_copper_layer; + if (setjmp(info.env) == 0) + r_search(PCB->Data->pad_tree, &info.line.BoundingBox, NULL, LOT_Padcallback, &info); + else + return true; + } + } + return (false); } -struct rat_info -{ - Cardinal layer; - PointTypePtr Point; - jmp_buf env; +struct rat_info { + Cardinal layer; + PointTypePtr Point; + jmp_buf env; }; -static int -LOCtoRat_callback (const BoxType * b, void *cl) +static int LOCtoRat_callback(const BoxType * b, void *cl) { - LineTypePtr line = (LineTypePtr) b; - struct rat_info *i = (struct rat_info *) cl; + LineTypePtr line = (LineTypePtr) b; + struct rat_info *i = (struct rat_info *) cl; - if (!TEST_FLAG (TheFlag, line) && - ((line->Point1.X == i->Point->X && - line->Point1.Y == i->Point->Y) || - (line->Point2.X == i->Point->X && line->Point2.Y == i->Point->Y))) - { - if (ADD_LINE_TO_LIST (i->layer, line, RATLINE_TYPE, &i->Point, FCT_RAT)) - longjmp (i->env, 1); - } - return 0; + if (!TEST_FLAG(TheFlag, line) && + ((line->Point1.X == i->Point->X && + line->Point1.Y == i->Point->Y) || (line->Point2.X == i->Point->X && line->Point2.Y == i->Point->Y))) { + if (ADD_LINE_TO_LIST(i->layer, line, RATLINE_TYPE, &i->Point, FCT_RAT)) + longjmp(i->env, 1); + } + return 0; } -static int -PolygonToRat_callback (const BoxType * b, void *cl) + +static int PolygonToRat_callback(const BoxType * b, void *cl) { - PolygonTypePtr polygon = (PolygonTypePtr) b; - struct rat_info *i = (struct rat_info *) cl; + PolygonTypePtr polygon = (PolygonTypePtr) b; + struct rat_info *i = (struct rat_info *) cl; - if (!TEST_FLAG (TheFlag, polygon) && polygon->Clipped && - (i->Point->X == polygon->Clipped->contours->head.point[0]) && - (i->Point->Y == polygon->Clipped->contours->head.point[1])) - { - if (ADD_POLYGON_TO_LIST (i->layer, polygon, RATLINE_TYPE, &i->Point, FCT_RAT)) - longjmp (i->env, 1); - } - return 0; + if (!TEST_FLAG(TheFlag, polygon) && polygon->Clipped && + (i->Point->X == polygon->Clipped->contours->head.point[0]) && + (i->Point->Y == polygon->Clipped->contours->head.point[1])) { + if (ADD_POLYGON_TO_LIST(i->layer, polygon, RATLINE_TYPE, &i->Point, FCT_RAT)) + longjmp(i->env, 1); + } + return 0; } -static int -LOCtoPad_callback (const BoxType * b, void *cl) +static int LOCtoPad_callback(const BoxType * b, void *cl) { - PadTypePtr pad = (PadTypePtr) b; - struct rat_info *i = (struct rat_info *) cl; + PadTypePtr pad = (PadTypePtr) b; + struct rat_info *i = (struct rat_info *) cl; - if (!TEST_FLAG (TheFlag, pad) && i->layer == - (TEST_FLAG (ONSOLDERFLAG, pad) ? SOLDER_LAYER : COMPONENT_LAYER) && - ((pad->Point1.X == i->Point->X && pad->Point1.Y == i->Point->Y) || - (pad->Point2.X == i->Point->X && pad->Point2.Y == i->Point->Y) || - ((pad->Point1.X + pad->Point2.X) / 2 == i->Point->X && - (pad->Point1.Y + pad->Point2.Y) / 2 == i->Point->Y)) && - ADD_PAD_TO_LIST (i->layer, pad, RATLINE_TYPE, &i->Point, FCT_RAT)) - longjmp (i->env, 1); - return 0; + if (!TEST_FLAG(TheFlag, pad) && i->layer == + (TEST_FLAG(ONSOLDERFLAG, pad) ? SOLDER_LAYER : COMPONENT_LAYER) && + ((pad->Point1.X == i->Point->X && pad->Point1.Y == i->Point->Y) || + (pad->Point2.X == i->Point->X && pad->Point2.Y == i->Point->Y) || + ((pad->Point1.X + pad->Point2.X) / 2 == i->Point->X && + (pad->Point1.Y + pad->Point2.Y) / 2 == i->Point->Y)) && + ADD_PAD_TO_LIST(i->layer, pad, RATLINE_TYPE, &i->Point, FCT_RAT)) + longjmp(i->env, 1); + return 0; } /* --------------------------------------------------------------------------- @@ -2226,138 +1981,117 @@ * the notation that is used is: * Xij means Xj at line i */ -static bool -LookupLOConnectionsToRatEnd (PointTypePtr Point, Cardinal LayerGroup) +static bool LookupLOConnectionsToRatEnd(PointTypePtr Point, Cardinal LayerGroup) { - Cardinal entry; - struct rat_info info; + Cardinal entry; + struct rat_info info; - info.Point = Point; - /* loop over all layers of this group */ - for (entry = 0; entry < PCB->LayerGroups.Number[LayerGroup]; entry++) - { - Cardinal layer; + info.Point = Point; + /* loop over all layers of this group */ + for (entry = 0; entry < PCB->LayerGroups.Number[LayerGroup]; entry++) { + Cardinal layer; - layer = PCB->LayerGroups.Entries[LayerGroup][entry]; - /* handle normal layers - rats don't ever touch - arcs by definition - */ + layer = PCB->LayerGroups.Entries[LayerGroup][entry]; + /* handle normal layers + rats don't ever touch + arcs by definition + */ - if (layer < max_copper_layer) - { - info.layer = layer; - if (setjmp (info.env) == 0) - r_search_pt (LAYER_PTR (layer)->line_tree, Point, 1, NULL, - LOCtoRat_callback, &info); - else - return true; - if (setjmp (info.env) == 0) - r_search_pt (LAYER_PTR (layer)->polygon_tree, Point, 1, - NULL, PolygonToRat_callback, &info); - } - else - { - /* handle special 'pad' layers */ - info.layer = layer - max_copper_layer; - if (setjmp (info.env) == 0) - r_search_pt (PCB->Data->pad_tree, Point, 1, NULL, - LOCtoPad_callback, &info); - else - return true; - } - } - return (false); + if (layer < max_copper_layer) { + info.layer = layer; + if (setjmp(info.env) == 0) + r_search_pt(LAYER_PTR(layer)->line_tree, Point, 1, NULL, LOCtoRat_callback, &info); + else + return true; + if (setjmp(info.env) == 0) + r_search_pt(LAYER_PTR(layer)->polygon_tree, Point, 1, NULL, PolygonToRat_callback, &info); + } + else { + /* handle special 'pad' layers */ + info.layer = layer - max_copper_layer; + if (setjmp(info.env) == 0) + r_search_pt(PCB->Data->pad_tree, Point, 1, NULL, LOCtoPad_callback, &info); + else + return true; + } + } + return (false); } -static int -LOCtoPadLine_callback (const BoxType * b, void *cl) +static int LOCtoPadLine_callback(const BoxType * b, void *cl) { - LineTypePtr line = (LineTypePtr) b; - struct lo_info *i = (struct lo_info *) cl; + LineTypePtr line = (LineTypePtr) b; + struct lo_info *i = (struct lo_info *) cl; - if (!TEST_FLAG (TheFlag, line) && LinePadIntersect (line, &i->pad)) - { - if (ADD_LINE_TO_LIST (i->layer, line, PAD_TYPE, &i->pad, FCT_COPPER)) - longjmp (i->env, 1); - } - return 0; + if (!TEST_FLAG(TheFlag, line) && LinePadIntersect(line, &i->pad)) { + if (ADD_LINE_TO_LIST(i->layer, line, PAD_TYPE, &i->pad, FCT_COPPER)) + longjmp(i->env, 1); + } + return 0; } -static int -LOCtoPadArc_callback (const BoxType * b, void *cl) +static int LOCtoPadArc_callback(const BoxType * b, void *cl) { - ArcTypePtr arc = (ArcTypePtr) b; - struct lo_info *i = (struct lo_info *) cl; + ArcTypePtr arc = (ArcTypePtr) b; + struct lo_info *i = (struct lo_info *) cl; - if (!arc->Thickness) - return 0; - if (!TEST_FLAG (TheFlag, arc) && ArcPadIntersect (arc, &i->pad)) - { - if (ADD_ARC_TO_LIST (i->layer, arc, PAD_TYPE, &i->pad, FCT_COPPER)) - longjmp (i->env, 1); - } - return 0; + if (!arc->Thickness) + return 0; + if (!TEST_FLAG(TheFlag, arc) && ArcPadIntersect(arc, &i->pad)) { + if (ADD_ARC_TO_LIST(i->layer, arc, PAD_TYPE, &i->pad, FCT_COPPER)) + longjmp(i->env, 1); + } + return 0; } -static int -LOCtoPadPoly_callback (const BoxType * b, void *cl) +static int LOCtoPadPoly_callback(const BoxType * b, void *cl) { - PolygonTypePtr polygon = (PolygonTypePtr) b; - struct lo_info *i = (struct lo_info *) cl; + PolygonTypePtr polygon = (PolygonTypePtr) b; + struct lo_info *i = (struct lo_info *) cl; - if (!TEST_FLAG (TheFlag, polygon) && - (!TEST_FLAG (CLEARPOLYFLAG, polygon) || !i->pad.Clearance)) - { - if (IsPadInPolygon (&i->pad, polygon) && - ADD_POLYGON_TO_LIST (i->layer, polygon, PAD_TYPE, &i->pad, FCT_COPPER)) - longjmp (i->env, 1); - } - return 0; + if (!TEST_FLAG(TheFlag, polygon) && (!TEST_FLAG(CLEARPOLYFLAG, polygon) || !i->pad.Clearance)) { + if (IsPadInPolygon(&i->pad, polygon) && ADD_POLYGON_TO_LIST(i->layer, polygon, PAD_TYPE, &i->pad, FCT_COPPER)) + longjmp(i->env, 1); + } + return 0; } -static int -LOCtoPadRat_callback (const BoxType * b, void *cl) +static int LOCtoPadRat_callback(const BoxType * b, void *cl) { - RatTypePtr rat = (RatTypePtr) b; - struct lo_info *i = (struct lo_info *) cl; + RatTypePtr rat = (RatTypePtr) b; + struct lo_info *i = (struct lo_info *) cl; - if (!TEST_FLAG (TheFlag, rat)) - { - if (rat->group1 == i->layer && - ((rat->Point1.X == i->pad.Point1.X && rat->Point1.Y == i->pad.Point1.Y) || - (rat->Point1.X == i->pad.Point2.X && rat->Point1.Y == i->pad.Point2.Y) || - (rat->Point1.X == (i->pad.Point1.X + i->pad.Point2.X) / 2 && - rat->Point1.Y == (i->pad.Point1.Y + i->pad.Point2.Y) / 2))) - { - if (ADD_RAT_TO_LIST (rat, PAD_TYPE, &i->pad, FCT_RAT)) - longjmp (i->env, 1); - } - else if (rat->group2 == i->layer && - ((rat->Point2.X == i->pad.Point1.X && rat->Point2.Y == i->pad.Point1.Y) || - (rat->Point2.X == i->pad.Point2.X && rat->Point2.Y == i->pad.Point2.Y) || - (rat->Point2.X == (i->pad.Point1.X + i->pad.Point2.X) / 2 && - rat->Point2.Y == (i->pad.Point1.Y + i->pad.Point2.Y) / 2))) - { - if (ADD_RAT_TO_LIST (rat, PAD_TYPE, &i->pad, FCT_RAT)) - longjmp (i->env, 1); - } - } - return 0; + if (!TEST_FLAG(TheFlag, rat)) { + if (rat->group1 == i->layer && + ((rat->Point1.X == i->pad.Point1.X && rat->Point1.Y == i->pad.Point1.Y) || + (rat->Point1.X == i->pad.Point2.X && rat->Point1.Y == i->pad.Point2.Y) || + (rat->Point1.X == (i->pad.Point1.X + i->pad.Point2.X) / 2 && + rat->Point1.Y == (i->pad.Point1.Y + i->pad.Point2.Y) / 2))) { + if (ADD_RAT_TO_LIST(rat, PAD_TYPE, &i->pad, FCT_RAT)) + longjmp(i->env, 1); + } + else if (rat->group2 == i->layer && + ((rat->Point2.X == i->pad.Point1.X && rat->Point2.Y == i->pad.Point1.Y) || + (rat->Point2.X == i->pad.Point2.X && rat->Point2.Y == i->pad.Point2.Y) || + (rat->Point2.X == (i->pad.Point1.X + i->pad.Point2.X) / 2 && + rat->Point2.Y == (i->pad.Point1.Y + i->pad.Point2.Y) / 2))) { + if (ADD_RAT_TO_LIST(rat, PAD_TYPE, &i->pad, FCT_RAT)) + longjmp(i->env, 1); + } + } + return 0; } -static int -LOCtoPadPad_callback (const BoxType * b, void *cl) +static int LOCtoPadPad_callback(const BoxType * b, void *cl) { - PadTypePtr pad = (PadTypePtr) b; - struct lo_info *i = (struct lo_info *) cl; + PadTypePtr pad = (PadTypePtr) b; + struct lo_info *i = (struct lo_info *) cl; - if (!TEST_FLAG (TheFlag, pad) && i->layer == - (TEST_FLAG (ONSOLDERFLAG, pad) ? SOLDER_LAYER : COMPONENT_LAYER) - && PadPadIntersect (pad, &i->pad) && ADD_PAD_TO_LIST (i->layer, pad, PAD_TYPE, &i->pad, FCT_COPPER)) - longjmp (i->env, 1); - return 0; + if (!TEST_FLAG(TheFlag, pad) && i->layer == (TEST_FLAG(ONSOLDERFLAG, pad) ? SOLDER_LAYER : COMPONENT_LAYER) + && PadPadIntersect(pad, &i->pad) && ADD_PAD_TO_LIST(i->layer, pad, PAD_TYPE, &i->pad, FCT_COPPER)) + longjmp(i->env, 1); + return 0; } /* --------------------------------------------------------------------------- @@ -2364,44 +2098,43 @@ * searches all LOs that are connected to the given pad on the given * layergroup. All found connections are added to the list */ -static bool -LookupLOConnectionsToPad (PadTypePtr Pad, Cardinal LayerGroup) +static bool LookupLOConnectionsToPad(PadTypePtr Pad, Cardinal LayerGroup) { - Cardinal entry; - struct lo_info info; - int ic; - bool retv = false; + Cardinal entry; + struct lo_info info; + int ic; + bool retv = false; /* Internal connection: if pads in the same element have the same internal connection group number, they are connected */ - ic = GET_INTCONN(Pad); - if ((Pad->Element != NULL) && (ic > 0)) { - ElementType *e = Pad->Element; - PadTypePtr orig_pad = Pad; - int tlayer = -1; + ic = GET_INTCONN(Pad); + if ((Pad->Element != NULL) && (ic > 0)) { + ElementType *e = Pad->Element; + PadTypePtr orig_pad = Pad; + int tlayer = -1; /*fprintf(stderr, "lg===\n");*/ - for (entry = 0; entry < PCB->LayerGroups.Number[LayerGroup]; entry++) { - Cardinal layer; - layer = PCB->LayerGroups.Entries[LayerGroup][entry]; + for (entry = 0; entry < PCB->LayerGroups.Number[LayerGroup]; entry++) { + Cardinal layer; + layer = PCB->LayerGroups.Entries[LayerGroup][entry]; /*fprintf(stderr, "lg: %d\n", layer);*/ - if (layer == COMPONENT_LAYER) - tlayer = COMPONENT_LAYER; - else if (layer == SOLDER_LAYER) - tlayer = SOLDER_LAYER; - } + if (layer == COMPONENT_LAYER) + tlayer = COMPONENT_LAYER; + else if (layer == SOLDER_LAYER) + tlayer = SOLDER_LAYER; + } /*fprintf(stderr, "tlayer=%d\n", tlayer);*/ - if (tlayer >= 0) { - PAD_LOOP (e); + if (tlayer >= 0) { + PAD_LOOP(e); { if ((orig_pad != pad) && (ic == GET_INTCONN(pad))) { - int padlayer = TEST_FLAG (ONSOLDERFLAG, pad) ? SOLDER_LAYER : COMPONENT_LAYER; + int padlayer = TEST_FLAG(ONSOLDERFLAG, pad) ? SOLDER_LAYER : COMPONENT_LAYER; /*fprintf(stderr, "layergroup1: %d {%d %d %d} %d \n", tlayer, TEST_FLAG(ONSOLDERFLAG, pad), SOLDER_LAYER, COMPONENT_LAYER, padlayer);*/ - if ((!TEST_FLAG (TheFlag, pad)) && (tlayer != padlayer)) { + if ((!TEST_FLAG(TheFlag, pad)) && (tlayer != padlayer)) { /*fprintf(stderr, "layergroup2\n");*/ - ADD_PAD_TO_LIST (padlayer, pad, PAD_TYPE, orig_pad, FCT_INTERNAL); + ADD_PAD_TO_LIST(padlayer, pad, PAD_TYPE, orig_pad, FCT_INTERNAL); if (LookupLOConnectionsToPad(pad, LayerGroup)) retv = true; } @@ -2408,131 +2141,113 @@ } } END_LOOP; - } } + } - if (!TEST_FLAG (SQUAREFLAG, Pad)) - return (LookupLOConnectionsToLine ((LineTypePtr) Pad, LayerGroup, false)); + if (!TEST_FLAG(SQUAREFLAG, Pad)) + return (LookupLOConnectionsToLine((LineTypePtr) Pad, LayerGroup, false)); - info.pad = *Pad; - EXPAND_BOUNDS (&info.pad); - /* add the new rat lines */ - info.layer = LayerGroup; - if (setjmp (info.env) == 0) - r_search (PCB->Data->rat_tree, &info.pad.BoundingBox, NULL, - LOCtoPadRat_callback, &info); - else - return true; + info.pad = *Pad; + EXPAND_BOUNDS(&info.pad); + /* add the new rat lines */ + info.layer = LayerGroup; + if (setjmp(info.env) == 0) + r_search(PCB->Data->rat_tree, &info.pad.BoundingBox, NULL, LOCtoPadRat_callback, &info); + else + return true; - /* loop over all layers of the group */ - for (entry = 0; entry < PCB->LayerGroups.Number[LayerGroup]; entry++) - { - Cardinal layer; + /* loop over all layers of the group */ + for (entry = 0; entry < PCB->LayerGroups.Number[LayerGroup]; entry++) { + Cardinal layer; - layer = PCB->LayerGroups.Entries[LayerGroup][entry]; - /* handle normal layers */ - if (layer < max_copper_layer) - { - info.layer = layer; - /* add lines */ - if (setjmp (info.env) == 0) - r_search (LAYER_PTR (layer)->line_tree, &info.pad.BoundingBox, - NULL, LOCtoPadLine_callback, &info); - else - return true; - /* add arcs */ - if (setjmp (info.env) == 0) - r_search (LAYER_PTR (layer)->arc_tree, &info.pad.BoundingBox, - NULL, LOCtoPadArc_callback, &info); - else - return true; - /* add polygons */ - if (setjmp (info.env) == 0) - r_search (LAYER_PTR (layer)->polygon_tree, &info.pad.BoundingBox, - NULL, LOCtoPadPoly_callback, &info); - else - return true; - } - else - { - /* handle special 'pad' layers */ - info.layer = layer - max_copper_layer; - if (setjmp (info.env) == 0) - r_search (PCB->Data->pad_tree, (BoxType *) & info.pad, NULL, - LOCtoPadPad_callback, &info); - else - return true; - } + layer = PCB->LayerGroups.Entries[LayerGroup][entry]; + /* handle normal layers */ + if (layer < max_copper_layer) { + info.layer = layer; + /* add lines */ + if (setjmp(info.env) == 0) + r_search(LAYER_PTR(layer)->line_tree, &info.pad.BoundingBox, NULL, LOCtoPadLine_callback, &info); + else + return true; + /* add arcs */ + if (setjmp(info.env) == 0) + r_search(LAYER_PTR(layer)->arc_tree, &info.pad.BoundingBox, NULL, LOCtoPadArc_callback, &info); + else + return true; + /* add polygons */ + if (setjmp(info.env) == 0) + r_search(LAYER_PTR(layer)->polygon_tree, &info.pad.BoundingBox, NULL, LOCtoPadPoly_callback, &info); + else + return true; + } + else { + /* handle special 'pad' layers */ + info.layer = layer - max_copper_layer; + if (setjmp(info.env) == 0) + r_search(PCB->Data->pad_tree, (BoxType *) & info.pad, NULL, LOCtoPadPad_callback, &info); + else + return true; + } - } - return retv; + } + return retv; } -static int -LOCtoPolyLine_callback (const BoxType * b, void *cl) +static int LOCtoPolyLine_callback(const BoxType * b, void *cl) { - LineTypePtr line = (LineTypePtr) b; - struct lo_info *i = (struct lo_info *) cl; + LineTypePtr line = (LineTypePtr) b; + struct lo_info *i = (struct lo_info *) cl; - if (!TEST_FLAG (TheFlag, line) && IsLineInPolygon (line, &i->polygon)) - { - if (ADD_LINE_TO_LIST (i->layer, line, POLYGON_TYPE, &i->polygon, FCT_COPPER)) - longjmp (i->env, 1); - } - return 0; + if (!TEST_FLAG(TheFlag, line) && IsLineInPolygon(line, &i->polygon)) { + if (ADD_LINE_TO_LIST(i->layer, line, POLYGON_TYPE, &i->polygon, FCT_COPPER)) + longjmp(i->env, 1); + } + return 0; } -static int -LOCtoPolyArc_callback (const BoxType * b, void *cl) +static int LOCtoPolyArc_callback(const BoxType * b, void *cl) { - ArcTypePtr arc = (ArcTypePtr) b; - struct lo_info *i = (struct lo_info *) cl; + ArcTypePtr arc = (ArcTypePtr) b; + struct lo_info *i = (struct lo_info *) cl; - if (!arc->Thickness) - return 0; - if (!TEST_FLAG (TheFlag, arc) && IsArcInPolygon (arc, &i->polygon)) - { - if (ADD_ARC_TO_LIST (i->layer, arc, POLYGON_TYPE, &i->polygon, FCT_COPPER)) - longjmp (i->env, 1); - } - return 0; + if (!arc->Thickness) + return 0; + if (!TEST_FLAG(TheFlag, arc) && IsArcInPolygon(arc, &i->polygon)) { + if (ADD_ARC_TO_LIST(i->layer, arc, POLYGON_TYPE, &i->polygon, FCT_COPPER)) + longjmp(i->env, 1); + } + return 0; } -static int -LOCtoPolyPad_callback (const BoxType * b, void *cl) +static int LOCtoPolyPad_callback(const BoxType * b, void *cl) { - PadTypePtr pad = (PadTypePtr) b; - struct lo_info *i = (struct lo_info *) cl; + PadTypePtr pad = (PadTypePtr) b; + struct lo_info *i = (struct lo_info *) cl; - if (!TEST_FLAG (TheFlag, pad) && i->layer == - (TEST_FLAG (ONSOLDERFLAG, pad) ? SOLDER_LAYER : COMPONENT_LAYER) - && IsPadInPolygon (pad, &i->polygon)) - { - if (ADD_PAD_TO_LIST (i->layer, pad, POLYGON_TYPE, &i->polygon, FCT_COPPER)) - longjmp (i->env, 1); - } - return 0; + if (!TEST_FLAG(TheFlag, pad) && i->layer == (TEST_FLAG(ONSOLDERFLAG, pad) ? SOLDER_LAYER : COMPONENT_LAYER) + && IsPadInPolygon(pad, &i->polygon)) { + if (ADD_PAD_TO_LIST(i->layer, pad, POLYGON_TYPE, &i->polygon, FCT_COPPER)) + longjmp(i->env, 1); + } + return 0; } -static int -LOCtoPolyRat_callback (const BoxType * b, void *cl) +static int LOCtoPolyRat_callback(const BoxType * b, void *cl) { - RatTypePtr rat = (RatTypePtr) b; - struct lo_info *i = (struct lo_info *) cl; + RatTypePtr rat = (RatTypePtr) b; + struct lo_info *i = (struct lo_info *) cl; - if (!TEST_FLAG (TheFlag, rat)) - { - if ((rat->Point1.X == (i->polygon.Clipped->contours->head.point[0]) && - rat->Point1.Y == (i->polygon.Clipped->contours->head.point[1]) && - rat->group1 == i->layer) || - (rat->Point2.X == (i->polygon.Clipped->contours->head.point[0]) && - rat->Point2.Y == (i->polygon.Clipped->contours->head.point[1]) && - rat->group2 == i->layer)) - if (ADD_RAT_TO_LIST (rat, POLYGON_TYPE, &i->polygon, FCT_RAT)) - longjmp (i->env, 1); - } - return 0; + if (!TEST_FLAG(TheFlag, rat)) { + if ((rat->Point1.X == (i->polygon.Clipped->contours->head.point[0]) && + rat->Point1.Y == (i->polygon.Clipped->contours->head.point[1]) && + rat->group1 == i->layer) || + (rat->Point2.X == (i->polygon.Clipped->contours->head.point[0]) && + rat->Point2.Y == (i->polygon.Clipped->contours->head.point[1]) && rat->group2 == i->layer)) + if (ADD_RAT_TO_LIST(rat, POLYGON_TYPE, &i->polygon, FCT_RAT)) + longjmp(i->env, 1); + } + return 0; } @@ -2540,72 +2255,61 @@ * looks up LOs that are connected to the given polygon * on the given layergroup. All found connections are added to the list */ -static bool -LookupLOConnectionsToPolygon (PolygonTypePtr Polygon, Cardinal LayerGroup) +static bool LookupLOConnectionsToPolygon(PolygonTypePtr Polygon, Cardinal LayerGroup) { - Cardinal entry; - struct lo_info info; + Cardinal entry; + struct lo_info info; - if (!Polygon->Clipped) - return false; - info.polygon = *Polygon; - EXPAND_BOUNDS (&info.polygon); - info.layer = LayerGroup; - /* check rats */ - if (setjmp (info.env) == 0) - r_search (PCB->Data->rat_tree, (BoxType *) & info.polygon, NULL, - LOCtoPolyRat_callback, &info); - else - return true; + if (!Polygon->Clipped) + return false; + info.polygon = *Polygon; + EXPAND_BOUNDS(&info.polygon); + info.layer = LayerGroup; + /* check rats */ + if (setjmp(info.env) == 0) + r_search(PCB->Data->rat_tree, (BoxType *) & info.polygon, NULL, LOCtoPolyRat_callback, &info); + else + return true; /* loop over all layers of the group */ - for (entry = 0; entry < PCB->LayerGroups.Number[LayerGroup]; entry++) - { - Cardinal layer; + for (entry = 0; entry < PCB->LayerGroups.Number[LayerGroup]; entry++) { + Cardinal layer; - layer = PCB->LayerGroups.Entries[LayerGroup][entry]; + layer = PCB->LayerGroups.Entries[LayerGroup][entry]; - /* handle normal layers */ - if (layer < max_copper_layer) - { - GList *i; + /* handle normal layers */ + if (layer < max_copper_layer) { + GList *i; - /* check all polygons */ - for (i = PCB->Data->Layer[layer].Polygon; - i != NULL; i = g_list_next (i)) - { - PolygonType *polygon = i->data; - if (!TEST_FLAG (TheFlag, polygon) - && IsPolygonInPolygon (polygon, Polygon) - && ADD_POLYGON_TO_LIST (layer, polygon, POLYGON_TYPE, Polygon, FCT_COPPER)) - return true; - } + /* check all polygons */ + for (i = PCB->Data->Layer[layer].Polygon; i != NULL; i = g_list_next(i)) { + PolygonType *polygon = i->data; + if (!TEST_FLAG(TheFlag, polygon) + && IsPolygonInPolygon(polygon, Polygon) + && ADD_POLYGON_TO_LIST(layer, polygon, POLYGON_TYPE, Polygon, FCT_COPPER)) + return true; + } - info.layer = layer; - /* check all lines */ - if (setjmp (info.env) == 0) - r_search (LAYER_PTR (layer)->line_tree, - (BoxType *) & info.polygon, NULL, - LOCtoPolyLine_callback, &info); - else - return true; - /* check all arcs */ - if (setjmp (info.env) == 0) - r_search (LAYER_PTR (layer)->arc_tree, (BoxType *) & info.polygon, - NULL, LOCtoPolyArc_callback, &info); - else - return true; - } - else - { - info.layer = layer - max_copper_layer; - if (setjmp (info.env) == 0) - r_search (PCB->Data->pad_tree, (BoxType *) & info.polygon, - NULL, LOCtoPolyPad_callback, &info); - else - return true; - } - } - return (false); + info.layer = layer; + /* check all lines */ + if (setjmp(info.env) == 0) + r_search(LAYER_PTR(layer)->line_tree, (BoxType *) & info.polygon, NULL, LOCtoPolyLine_callback, &info); + else + return true; + /* check all arcs */ + if (setjmp(info.env) == 0) + r_search(LAYER_PTR(layer)->arc_tree, (BoxType *) & info.polygon, NULL, LOCtoPolyArc_callback, &info); + else + return true; + } + else { + info.layer = layer - max_copper_layer; + if (setjmp(info.env) == 0) + r_search(PCB->Data->pad_tree, (BoxType *) & info.polygon, NULL, LOCtoPolyPad_callback, &info); + else + return true; + } + } + return (false); } /* --------------------------------------------------------------------------- @@ -2616,28 +2320,25 @@ * - check the two end points of the arc. If none of them matches * - check all segments of the polygon against the arc. */ -bool -IsArcInPolygon (ArcTypePtr Arc, PolygonTypePtr Polygon) +bool IsArcInPolygon(ArcTypePtr Arc, PolygonTypePtr Polygon) { - BoxTypePtr Box = (BoxType *) Arc; + BoxTypePtr Box = (BoxType *) Arc; - /* arcs with clearance never touch polys */ - if (TEST_FLAG (CLEARPOLYFLAG, Polygon) && TEST_FLAG (CLEARLINEFLAG, Arc)) - return false; - if (!Polygon->Clipped) - return false; - if (Box->X1 <= Polygon->Clipped->contours->xmax + Bloat - && Box->X2 >= Polygon->Clipped->contours->xmin - Bloat - && Box->Y1 <= Polygon->Clipped->contours->ymax + Bloat - && Box->Y2 >= Polygon->Clipped->contours->ymin - Bloat) - { - POLYAREA *ap; + /* arcs with clearance never touch polys */ + if (TEST_FLAG(CLEARPOLYFLAG, Polygon) && TEST_FLAG(CLEARLINEFLAG, Arc)) + return false; + if (!Polygon->Clipped) + return false; + if (Box->X1 <= Polygon->Clipped->contours->xmax + Bloat + && Box->X2 >= Polygon->Clipped->contours->xmin - Bloat + && Box->Y1 <= Polygon->Clipped->contours->ymax + Bloat && Box->Y2 >= Polygon->Clipped->contours->ymin - Bloat) { + POLYAREA *ap; - if (!(ap = ArcPoly (Arc, Arc->Thickness + Bloat))) - return false; /* error */ - return isects (ap, Polygon, true); - } - return false; + if (!(ap = ArcPoly(Arc, Arc->Thickness + Bloat))) + return false; /* error */ + return isects(ap, Polygon, true); + } + return false; } /* --------------------------------------------------------------------------- @@ -2648,38 +2349,34 @@ * - check the two end points of the line. If none of them matches * - check all segments of the polygon against the line. */ -bool -IsLineInPolygon (LineTypePtr Line, PolygonTypePtr Polygon) +bool IsLineInPolygon(LineTypePtr Line, PolygonTypePtr Polygon) { - BoxTypePtr Box = (BoxType *) Line; - POLYAREA *lp; + BoxTypePtr Box = (BoxType *) Line; + POLYAREA *lp; - /* lines with clearance never touch polygons */ - if (TEST_FLAG (CLEARPOLYFLAG, Polygon) && TEST_FLAG (CLEARLINEFLAG, Line)) - return false; - if (!Polygon->Clipped) - return false; - if (TEST_FLAG(SQUAREFLAG,Line)&&(Line->Point1.X==Line->Point2.X||Line->Point1.Y==Line->Point2.Y)) - { - Coord wid = (Line->Thickness + Bloat + 1) / 2; - Coord x1, x2, y1, y2; + /* lines with clearance never touch polygons */ + if (TEST_FLAG(CLEARPOLYFLAG, Polygon) && TEST_FLAG(CLEARLINEFLAG, Line)) + return false; + if (!Polygon->Clipped) + return false; + if (TEST_FLAG(SQUAREFLAG, Line) && (Line->Point1.X == Line->Point2.X || Line->Point1.Y == Line->Point2.Y)) { + Coord wid = (Line->Thickness + Bloat + 1) / 2; + Coord x1, x2, y1, y2; - x1 = MIN (Line->Point1.X, Line->Point2.X) - wid; - y1 = MIN (Line->Point1.Y, Line->Point2.Y) - wid; - x2 = MAX (Line->Point1.X, Line->Point2.X) + wid; - y2 = MAX (Line->Point1.Y, Line->Point2.Y) + wid; - return IsRectangleInPolygon (x1, y1, x2, y2, Polygon); - } - if (Box->X1 <= Polygon->Clipped->contours->xmax + Bloat - && Box->X2 >= Polygon->Clipped->contours->xmin - Bloat - && Box->Y1 <= Polygon->Clipped->contours->ymax + Bloat - && Box->Y2 >= Polygon->Clipped->contours->ymin - Bloat) - { - if (!(lp = LinePoly (Line, Line->Thickness + Bloat))) - return FALSE; /* error */ - return isects (lp, Polygon, true); - } - return false; + x1 = MIN(Line->Point1.X, Line->Point2.X) - wid; + y1 = MIN(Line->Point1.Y, Line->Point2.Y) - wid; + x2 = MAX(Line->Point1.X, Line->Point2.X) + wid; + y2 = MAX(Line->Point1.Y, Line->Point2.Y) + wid; + return IsRectangleInPolygon(x1, y1, x2, y2, Polygon); + } + if (Box->X1 <= Polygon->Clipped->contours->xmax + Bloat + && Box->X2 >= Polygon->Clipped->contours->xmin - Bloat + && Box->Y1 <= Polygon->Clipped->contours->ymax + Bloat && Box->Y2 >= Polygon->Clipped->contours->ymin - Bloat) { + if (!(lp = LinePoly(Line, Line->Thickness + Bloat))) + return FALSE; /* error */ + return isects(lp, Polygon, true); + } + return false; } /* --------------------------------------------------------------------------- @@ -2687,10 +2384,9 @@ * * The polygon is assumed to already have been proven non-clearing */ -bool -IsPadInPolygon (PadTypePtr pad, PolygonTypePtr polygon) +bool IsPadInPolygon(PadTypePtr pad, PolygonTypePtr polygon) { - return IsLineInPolygon ((LineTypePtr) pad, polygon); + return IsLineInPolygon((LineTypePtr) pad, polygon); } /* --------------------------------------------------------------------------- @@ -2699,106 +2395,95 @@ * First check all points out of P1 against P2 and vice versa. * If both fail check all lines of P1 against the ones of P2 */ -bool -IsPolygonInPolygon (PolygonTypePtr P1, PolygonTypePtr P2) +bool IsPolygonInPolygon(PolygonTypePtr P1, PolygonTypePtr P2) { - if (!P1->Clipped || !P2->Clipped) - return false; - assert (P1->Clipped->contours); - assert (P2->Clipped->contours); + if (!P1->Clipped || !P2->Clipped) + return false; + assert(P1->Clipped->contours); + assert(P2->Clipped->contours); - /* first check if both bounding boxes intersect. If not, return quickly */ - if (P1->Clipped->contours->xmin - Bloat > P2->Clipped->contours->xmax || - P1->Clipped->contours->xmax + Bloat < P2->Clipped->contours->xmin || - P1->Clipped->contours->ymin - Bloat > P2->Clipped->contours->ymax || - P1->Clipped->contours->ymax + Bloat < P2->Clipped->contours->ymin) - return false; + /* first check if both bounding boxes intersect. If not, return quickly */ + if (P1->Clipped->contours->xmin - Bloat > P2->Clipped->contours->xmax || + P1->Clipped->contours->xmax + Bloat < P2->Clipped->contours->xmin || + P1->Clipped->contours->ymin - Bloat > P2->Clipped->contours->ymax || + P1->Clipped->contours->ymax + Bloat < P2->Clipped->contours->ymin) + return false; - /* first check un-bloated case */ - if (isects (P1->Clipped, P2, false)) - return TRUE; + /* first check un-bloated case */ + if (isects(P1->Clipped, P2, false)) + return TRUE; - /* now the difficult case of bloated */ - if (Bloat > 0) - { - PLINE *c; - for (c = P1->Clipped->contours; c; c = c->next) - { - LineType line; - VNODE *v = &c->head; - if (c->xmin - Bloat <= P2->Clipped->contours->xmax && - c->xmax + Bloat >= P2->Clipped->contours->xmin && - c->ymin - Bloat <= P2->Clipped->contours->ymax && - c->ymax + Bloat >= P2->Clipped->contours->ymin) - { + /* now the difficult case of bloated */ + if (Bloat > 0) { + PLINE *c; + for (c = P1->Clipped->contours; c; c = c->next) { + LineType line; + VNODE *v = &c->head; + if (c->xmin - Bloat <= P2->Clipped->contours->xmax && + c->xmax + Bloat >= P2->Clipped->contours->xmin && + c->ymin - Bloat <= P2->Clipped->contours->ymax && c->ymax + Bloat >= P2->Clipped->contours->ymin) { - line.Point1.X = v->point[0]; - line.Point1.Y = v->point[1]; - line.Thickness = 2 * Bloat; - line.Clearance = 0; - line.Flags = NoFlags (); - for (v = v->next; v != &c->head; v = v->next) - { - line.Point2.X = v->point[0]; - line.Point2.Y = v->point[1]; - SetLineBoundingBox (&line); - if (IsLineInPolygon (&line, P2)) - return (true); - line.Point1.X = line.Point2.X; - line.Point1.Y = line.Point2.Y; - } - } - } - } + line.Point1.X = v->point[0]; + line.Point1.Y = v->point[1]; + line.Thickness = 2 * Bloat; + line.Clearance = 0; + line.Flags = NoFlags(); + for (v = v->next; v != &c->head; v = v->next) { + line.Point2.X = v->point[0]; + line.Point2.Y = v->point[1]; + SetLineBoundingBox(&line); + if (IsLineInPolygon(&line, P2)) + return (true); + line.Point1.X = line.Point2.X; + line.Point1.Y = line.Point2.Y; + } + } + } + } - return (false); + return (false); } /* --------------------------------------------------------------------------- * writes the several names of an element to a file */ -static void -PrintElementNameList (ElementTypePtr Element, FILE * FP) +static void PrintElementNameList(ElementTypePtr Element, FILE * FP) { - static DynamicStringType cname, pname, vname; + static DynamicStringType cname, pname, vname; - CreateQuotedString (&cname, (char *)EMPTY (DESCRIPTION_NAME (Element))); - CreateQuotedString (&pname, (char *)EMPTY (NAMEONPCB_NAME (Element))); - CreateQuotedString (&vname, (char *)EMPTY (VALUE_NAME (Element))); - fprintf (FP, "(%s %s %s)\n", cname.Data, pname.Data, vname.Data); + CreateQuotedString(&cname, (char *) EMPTY(DESCRIPTION_NAME(Element))); + CreateQuotedString(&pname, (char *) EMPTY(NAMEONPCB_NAME(Element))); + CreateQuotedString(&vname, (char *) EMPTY(VALUE_NAME(Element))); + fprintf(FP, "(%s %s %s)\n", cname.Data, pname.Data, vname.Data); } /* --------------------------------------------------------------------------- * writes the several names of an element to a file */ -static void -PrintConnectionElementName (ElementTypePtr Element, FILE * FP) +static void PrintConnectionElementName(ElementTypePtr Element, FILE * FP) { - fputs ("Element", FP); - PrintElementNameList (Element, FP); - fputs ("{\n", FP); + fputs("Element", FP); + PrintElementNameList(Element, FP); + fputs("{\n", FP); } /* --------------------------------------------------------------------------- * prints one {pin,pad,via}/element entry of connection lists */ -static void -PrintConnectionListEntry (char *ObjName, ElementTypePtr Element, - bool FirstOne, FILE * FP) +static void PrintConnectionListEntry(char *ObjName, ElementTypePtr Element, bool FirstOne, FILE * FP) { - static DynamicStringType oname; + static DynamicStringType oname; - CreateQuotedString (&oname, ObjName); - if (FirstOne) - fprintf (FP, "\t%s\n\t{\n", oname.Data); - else - { - fprintf (FP, "\t\t%s ", oname.Data); - if (Element) - PrintElementNameList (Element, FP); - else - fputs ("(__VIA__)\n", FP); - } + CreateQuotedString(&oname, ObjName); + if (FirstOne) + fprintf(FP, "\t%s\n\t{\n", oname.Data); + else { + fprintf(FP, "\t\t%s ", oname.Data); + if (Element) + PrintElementNameList(Element, FP); + else + fputs("(__VIA__)\n", FP); + } } /* --------------------------------------------------------------------------- @@ -2805,36 +2490,33 @@ * prints all found connections of a pads to file FP * the connections are stacked in 'PadList' */ -static void -PrintPadConnections (Cardinal Layer, FILE * FP, bool IsFirst) +static void PrintPadConnections(Cardinal Layer, FILE * FP, bool IsFirst) { - Cardinal i; - PadTypePtr ptr; + Cardinal i; + PadTypePtr ptr; - if (!PadList[Layer].Number) - return; + if (!PadList[Layer].Number) + return; - /* the starting pad */ - if (IsFirst) - { - ptr = PADLIST_ENTRY (Layer, 0); - if (ptr != NULL) - PrintConnectionListEntry ((char *)UNKNOWN (ptr->Name), NULL, true, FP); - else - printf ("Skipping NULL ptr in 1st part of PrintPadConnections\n"); - } + /* the starting pad */ + if (IsFirst) { + ptr = PADLIST_ENTRY(Layer, 0); + if (ptr != NULL) + PrintConnectionListEntry((char *) UNKNOWN(ptr->Name), NULL, true, FP); + else + printf("Skipping NULL ptr in 1st part of PrintPadConnections\n"); + } - /* we maybe have to start with i=1 if we are handling the - * starting-pad itself - */ - for (i = IsFirst ? 1 : 0; i < PadList[Layer].Number; i++) - { - ptr = PADLIST_ENTRY (Layer, i); - if (ptr != NULL) - PrintConnectionListEntry ((char *)EMPTY (ptr->Name), (ElementTypePtr)ptr->Element, false, FP); - else - printf ("Skipping NULL ptr in 2nd part of PrintPadConnections\n"); - } + /* we maybe have to start with i=1 if we are handling the + * starting-pad itself + */ + for (i = IsFirst ? 1 : 0; i < PadList[Layer].Number; i++) { + ptr = PADLIST_ENTRY(Layer, i); + if (ptr != NULL) + PrintConnectionListEntry((char *) EMPTY(ptr->Name), (ElementTypePtr) ptr->Element, false, FP); + else + printf("Skipping NULL ptr in 2nd part of PrintPadConnections\n"); + } } /* --------------------------------------------------------------------------- @@ -2841,62 +2523,55 @@ * prints all found connections of a pin to file FP * the connections are stacked in 'PVList' */ -static void -PrintPinConnections (FILE * FP, bool IsFirst) +static void PrintPinConnections(FILE * FP, bool IsFirst) { - Cardinal i; - PinTypePtr pv; + Cardinal i; + PinTypePtr pv; - if (!PVList.Number) - return; + if (!PVList.Number) + return; - if (IsFirst) - { - /* the starting pin */ - pv = PVLIST_ENTRY (0); - PrintConnectionListEntry ((char *)EMPTY (pv->Name), NULL, true, FP); - } + if (IsFirst) { + /* the starting pin */ + pv = PVLIST_ENTRY(0); + PrintConnectionListEntry((char *) EMPTY(pv->Name), NULL, true, FP); + } - /* we maybe have to start with i=1 if we are handling the - * starting-pin itself - */ - for (i = IsFirst ? 1 : 0; i < PVList.Number; i++) - { - /* get the elements name or assume that its a via */ - pv = PVLIST_ENTRY (i); - PrintConnectionListEntry ((char *)EMPTY (pv->Name), (ElementTypePtr)pv->Element, false, FP); - } + /* we maybe have to start with i=1 if we are handling the + * starting-pin itself + */ + for (i = IsFirst ? 1 : 0; i < PVList.Number; i++) { + /* get the elements name or assume that its a via */ + pv = PVLIST_ENTRY(i); + PrintConnectionListEntry((char *) EMPTY(pv->Name), (ElementTypePtr) pv->Element, false, FP); + } } /* --------------------------------------------------------------------------- * checks if all lists of new objects are handled */ -static bool -ListsEmpty (bool AndRats) +static bool ListsEmpty(bool AndRats) { - bool empty; - int i; + bool empty; + int i; - empty = (PVList.Location >= PVList.Number); - if (AndRats) - empty = empty && (RatList.Location >= RatList.Number); - for (i = 0; i < max_copper_layer && empty; i++) - empty = empty && LineList[i].Location >= LineList[i].Number - && ArcList[i].Location >= ArcList[i].Number - && PolygonList[i].Location >= PolygonList[i].Number; - return (empty); + empty = (PVList.Location >= PVList.Number); + if (AndRats) + empty = empty && (RatList.Location >= RatList.Number); + for (i = 0; i < max_copper_layer && empty; i++) + empty = empty && LineList[i].Location >= LineList[i].Number + && ArcList[i].Location >= ArcList[i].Number && PolygonList[i].Location >= PolygonList[i].Number; + return (empty); } -static void -reassign_no_drc_flags (void) +static void reassign_no_drc_flags(void) { - int layer; + int layer; - for (layer = 0; layer < max_copper_layer; layer++) - { - LayerTypePtr l = LAYER_PTR (layer); - l->no_drc = AttributeGet (l, "PCB::skip-drc") != NULL; - } + for (layer = 0; layer < max_copper_layer; layer++) { + LayerTypePtr l = LAYER_PTR(layer); + l->no_drc = AttributeGet(l, "PCB::skip-drc") != NULL; + } } @@ -2905,27 +2580,23 @@ /* --------------------------------------------------------------------------- * loops till no more connections are found */ -static bool -DoIt (bool AndRats, bool AndDraw) +static bool DoIt(bool AndRats, bool AndDraw) { - bool newone = false; - reassign_no_drc_flags (); - do - { - /* lookup connections; these are the steps (2) to (4) - * from the description - */ - newone = LookupPVConnectionsToPVList () || - LookupLOConnectionsToPVList (AndRats) || - LookupLOConnectionsToLOList (AndRats) || - LookupPVConnectionsToLOList (AndRats); - if (AndDraw) - DrawNewConnections (); - } - while (!newone && !ListsEmpty (AndRats)); - if (AndDraw) - Draw (); - return (newone); + bool newone = false; + reassign_no_drc_flags(); + do { + /* lookup connections; these are the steps (2) to (4) + * from the description + */ + newone = LookupPVConnectionsToPVList() || + LookupLOConnectionsToPVList(AndRats) || LookupLOConnectionsToLOList(AndRats) || LookupPVConnectionsToLOList(AndRats); + if (AndDraw) + DrawNewConnections(); + } + while (!newone && !ListsEmpty(AndRats)); + if (AndDraw) + Draw(); + return (newone); } /* returns true if nothing un-found touches the passed line @@ -2933,148 +2604,134 @@ * doesn't include rat-lines in the search */ -bool -lineClear (LineTypePtr line, Cardinal group) +bool lineClear(LineTypePtr line, Cardinal group) { - if (LOTouchesLine (line, group)) - return (false); - if (PVTouchesLine (line)) - return (false); - return (true); + if (LOTouchesLine(line, group)) + return (false); + if (PVTouchesLine(line)) + return (false); + return (true); } /* --------------------------------------------------------------------------- * prints all unused pins of an element to file FP */ -static bool -PrintAndSelectUnusedPinsAndPadsOfElement (ElementTypePtr Element, FILE * FP) +static bool PrintAndSelectUnusedPinsAndPadsOfElement(ElementTypePtr Element, FILE * FP) { - bool first = true; - Cardinal number; - static DynamicStringType oname; + bool first = true; + Cardinal number; + static DynamicStringType oname; - /* check all pins in element */ + /* check all pins in element */ - PIN_LOOP (Element); - { - if (!TEST_FLAG (HOLEFLAG, pin)) - { - /* pin might have bee checked before, add to list if not */ - if (!TEST_FLAG (TheFlag, pin) && FP) - { - int i; - if (ADD_PV_TO_LIST (pin, 0, NULL, 0)) - return true; - DoIt (true, true); - number = PadList[COMPONENT_LAYER].Number - + PadList[SOLDER_LAYER].Number + PVList.Number; - /* the pin has no connection if it's the only - * list entry; don't count vias - */ - for (i = 0; i < PVList.Number; i++) - if (!PVLIST_ENTRY (i)->Element) - number--; - if (number == 1) - { - /* output of element name if not already done */ - if (first) - { - PrintConnectionElementName (Element, FP); - first = false; - } + PIN_LOOP(Element); + { + if (!TEST_FLAG(HOLEFLAG, pin)) { + /* pin might have bee checked before, add to list if not */ + if (!TEST_FLAG(TheFlag, pin) && FP) { + int i; + if (ADD_PV_TO_LIST(pin, 0, NULL, 0)) + return true; + DoIt(true, true); + number = PadList[COMPONENT_LAYER].Number + PadList[SOLDER_LAYER].Number + PVList.Number; + /* the pin has no connection if it's the only + * list entry; don't count vias + */ + for (i = 0; i < PVList.Number; i++) + if (!PVLIST_ENTRY(i)->Element) + number--; + if (number == 1) { + /* output of element name if not already done */ + if (first) { + PrintConnectionElementName(Element, FP); + first = false; + } - /* write name to list and draw selected object */ - CreateQuotedString (&oname, (char *)EMPTY (pin->Name)); - fprintf (FP, "\t%s\n", oname.Data); - SET_FLAG (SELECTEDFLAG, pin); - DrawPin (pin); - } + /* write name to list and draw selected object */ + CreateQuotedString(&oname, (char *) EMPTY(pin->Name)); + fprintf(FP, "\t%s\n", oname.Data); + SET_FLAG(SELECTEDFLAG, pin); + DrawPin(pin); + } - /* reset found objects for the next pin */ - if (PrepareNextLoop (FP)) - return (true); - } - } - } - END_LOOP; + /* reset found objects for the next pin */ + if (PrepareNextLoop(FP)) + return (true); + } + } + } + END_LOOP; - /* check all pads in element */ - PAD_LOOP (Element); - { - /* lookup pad in list */ - /* pad might has bee checked before, add to list if not */ - if (!TEST_FLAG (TheFlag, pad) && FP) - { - int i; - if (ADD_PAD_TO_LIST (TEST_FLAG (ONSOLDERFLAG, pad) - ? SOLDER_LAYER : COMPONENT_LAYER, pad, 0, NULL, 0)) - return true; - DoIt (true, true); - number = PadList[COMPONENT_LAYER].Number - + PadList[SOLDER_LAYER].Number + PVList.Number; - /* the pin has no connection if it's the only - * list entry; don't count vias - */ - for (i = 0; i < PVList.Number; i++) - if (!PVLIST_ENTRY (i)->Element) - number--; - if (number == 1) - { - /* output of element name if not already done */ - if (first) - { - PrintConnectionElementName (Element, FP); - first = false; - } + /* check all pads in element */ + PAD_LOOP(Element); + { + /* lookup pad in list */ + /* pad might has bee checked before, add to list if not */ + if (!TEST_FLAG(TheFlag, pad) && FP) { + int i; + if (ADD_PAD_TO_LIST(TEST_FLAG(ONSOLDERFLAG, pad) + ? SOLDER_LAYER : COMPONENT_LAYER, pad, 0, NULL, 0)) + return true; + DoIt(true, true); + number = PadList[COMPONENT_LAYER].Number + PadList[SOLDER_LAYER].Number + PVList.Number; + /* the pin has no connection if it's the only + * list entry; don't count vias + */ + for (i = 0; i < PVList.Number; i++) + if (!PVLIST_ENTRY(i)->Element) + number--; + if (number == 1) { + /* output of element name if not already done */ + if (first) { + PrintConnectionElementName(Element, FP); + first = false; + } - /* write name to list and draw selected object */ - CreateQuotedString (&oname, (char *)EMPTY (pad->Name)); - fprintf (FP, "\t%s\n", oname.Data); - SET_FLAG (SELECTEDFLAG, pad); - DrawPad (pad); - } + /* write name to list and draw selected object */ + CreateQuotedString(&oname, (char *) EMPTY(pad->Name)); + fprintf(FP, "\t%s\n", oname.Data); + SET_FLAG(SELECTEDFLAG, pad); + DrawPad(pad); + } - /* reset found objects for the next pin */ - if (PrepareNextLoop (FP)) - return (true); - } - } - END_LOOP; + /* reset found objects for the next pin */ + if (PrepareNextLoop(FP)) + return (true); + } + } + END_LOOP; - /* print separator if element has unused pins or pads */ - if (!first) - { - fputs ("}\n\n", FP); - SEPARATE (FP); - } - return (false); + /* print separator if element has unused pins or pads */ + if (!first) { + fputs("}\n\n", FP); + SEPARATE(FP); + } + return (false); } /* --------------------------------------------------------------------------- * resets some flags for looking up the next pin/pad */ -static bool -PrepareNextLoop (FILE * FP) +static bool PrepareNextLoop(FILE * FP) { - Cardinal layer; + Cardinal layer; - /* reset found LOs for the next pin */ - for (layer = 0; layer < max_copper_layer; layer++) - { - LineList[layer].Location = LineList[layer].Number = 0; - ArcList[layer].Location = ArcList[layer].Number = 0; - PolygonList[layer].Location = PolygonList[layer].Number = 0; - } + /* reset found LOs for the next pin */ + for (layer = 0; layer < max_copper_layer; layer++) { + LineList[layer].Location = LineList[layer].Number = 0; + ArcList[layer].Location = ArcList[layer].Number = 0; + PolygonList[layer].Location = PolygonList[layer].Number = 0; + } - /* reset found pads */ - for (layer = 0; layer < 2; layer++) - PadList[layer].Location = PadList[layer].Number = 0; + /* reset found pads */ + for (layer = 0; layer < 2; layer++) + PadList[layer].Location = PadList[layer].Number = 0; - /* reset PVs */ - PVList.Number = PVList.Location = 0; - RatList.Number = RatList.Location = 0; + /* reset PVs */ + PVList.Number = PVList.Location = 0; + RatList.Number = RatList.Location = 0; - return (false); + return (false); } /* --------------------------------------------------------------------------- @@ -3082,62 +2739,57 @@ * The result is written to file FP * Returns true if operation was aborted */ -static bool -PrintElementConnections (ElementTypePtr Element, FILE * FP, bool AndDraw) +static bool PrintElementConnections(ElementTypePtr Element, FILE * FP, bool AndDraw) { - PrintConnectionElementName (Element, FP); + PrintConnectionElementName(Element, FP); - /* check all pins in element */ - PIN_LOOP (Element); - { - /* pin might have been checked before, add to list if not */ - if (TEST_FLAG (TheFlag, pin)) - { - PrintConnectionListEntry ((char *)EMPTY (pin->Name), NULL, true, FP); - fputs ("\t\t__CHECKED_BEFORE__\n\t}\n", FP); - continue; - } - if (ADD_PV_TO_LIST (pin, ELEMENT_TYPE, Element, FCT_ELEMENT)) - return true; - DoIt (true, AndDraw); - /* printout all found connections */ - PrintPinConnections (FP, true); - PrintPadConnections (COMPONENT_LAYER, FP, false); - PrintPadConnections (SOLDER_LAYER, FP, false); - fputs ("\t}\n", FP); - if (PrepareNextLoop (FP)) - return (true); - } - END_LOOP; + /* check all pins in element */ + PIN_LOOP(Element); + { + /* pin might have been checked before, add to list if not */ + if (TEST_FLAG(TheFlag, pin)) { + PrintConnectionListEntry((char *) EMPTY(pin->Name), NULL, true, FP); + fputs("\t\t__CHECKED_BEFORE__\n\t}\n", FP); + continue; + } + if (ADD_PV_TO_LIST(pin, ELEMENT_TYPE, Element, FCT_ELEMENT)) + return true; + DoIt(true, AndDraw); + /* printout all found connections */ + PrintPinConnections(FP, true); + PrintPadConnections(COMPONENT_LAYER, FP, false); + PrintPadConnections(SOLDER_LAYER, FP, false); + fputs("\t}\n", FP); + if (PrepareNextLoop(FP)) + return (true); + } + END_LOOP; - /* check all pads in element */ - PAD_LOOP (Element); - { - Cardinal layer; - /* pad might have been checked before, add to list if not */ - if (TEST_FLAG (TheFlag, pad)) - { - PrintConnectionListEntry ((char *)EMPTY (pad->Name), NULL, true, FP); - fputs ("\t\t__CHECKED_BEFORE__\n\t}\n", FP); - continue; - } - layer = TEST_FLAG (ONSOLDERFLAG, pad) ? SOLDER_LAYER : COMPONENT_LAYER; - if (ADD_PAD_TO_LIST (layer, pad, ELEMENT_TYPE, Element, FCT_ELEMENT)) - return true; - DoIt (true, AndDraw); - /* print all found connections */ - PrintPadConnections (layer, FP, true); - PrintPadConnections (layer == - (COMPONENT_LAYER ? SOLDER_LAYER : COMPONENT_LAYER), - FP, false); - PrintPinConnections (FP, false); - fputs ("\t}\n", FP); - if (PrepareNextLoop (FP)) - return (true); - } - END_LOOP; - fputs ("}\n\n", FP); - return (false); + /* check all pads in element */ + PAD_LOOP(Element); + { + Cardinal layer; + /* pad might have been checked before, add to list if not */ + if (TEST_FLAG(TheFlag, pad)) { + PrintConnectionListEntry((char *) EMPTY(pad->Name), NULL, true, FP); + fputs("\t\t__CHECKED_BEFORE__\n\t}\n", FP); + continue; + } + layer = TEST_FLAG(ONSOLDERFLAG, pad) ? SOLDER_LAYER : COMPONENT_LAYER; + if (ADD_PAD_TO_LIST(layer, pad, ELEMENT_TYPE, Element, FCT_ELEMENT)) + return true; + DoIt(true, AndDraw); + /* print all found connections */ + PrintPadConnections(layer, FP, true); + PrintPadConnections(layer == (COMPONENT_LAYER ? SOLDER_LAYER : COMPONENT_LAYER), FP, false); + PrintPinConnections(FP, false); + fputs("\t}\n", FP); + if (PrepareNextLoop(FP)) + return (true); + } + END_LOOP; + fputs("}\n\n", FP); + return (false); } /* --------------------------------------------------------------------------- @@ -3144,191 +2796,178 @@ * draws all new connections which have been found since the * routine was called the last time */ -static void -DrawNewConnections (void) +static void DrawNewConnections(void) { - int i; - Cardinal position; + int i; + Cardinal position; - /* decrement 'i' to keep layerstack order */ - for (i = max_copper_layer - 1; i != -1; i--) - { - Cardinal layer = LayerStack[i]; + /* decrement 'i' to keep layerstack order */ + for (i = max_copper_layer - 1; i != -1; i--) { + Cardinal layer = LayerStack[i]; - if (PCB->Data->Layer[layer].On) - { - /* draw all new lines */ - position = LineList[layer].DrawLocation; - for (; position < LineList[layer].Number; position++) - DrawLine (LAYER_PTR (layer), LINELIST_ENTRY (layer, position)); - LineList[layer].DrawLocation = LineList[layer].Number; + if (PCB->Data->Layer[layer].On) { + /* draw all new lines */ + position = LineList[layer].DrawLocation; + for (; position < LineList[layer].Number; position++) + DrawLine(LAYER_PTR(layer), LINELIST_ENTRY(layer, position)); + LineList[layer].DrawLocation = LineList[layer].Number; - /* draw all new arcs */ - position = ArcList[layer].DrawLocation; - for (; position < ArcList[layer].Number; position++) - DrawArc (LAYER_PTR (layer), ARCLIST_ENTRY (layer, position)); - ArcList[layer].DrawLocation = ArcList[layer].Number; + /* draw all new arcs */ + position = ArcList[layer].DrawLocation; + for (; position < ArcList[layer].Number; position++) + DrawArc(LAYER_PTR(layer), ARCLIST_ENTRY(layer, position)); + ArcList[layer].DrawLocation = ArcList[layer].Number; - /* draw all new polygons */ - position = PolygonList[layer].DrawLocation; - for (; position < PolygonList[layer].Number; position++) - DrawPolygon (LAYER_PTR (layer), POLYGONLIST_ENTRY (layer, position)); - PolygonList[layer].DrawLocation = PolygonList[layer].Number; - } - } + /* draw all new polygons */ + position = PolygonList[layer].DrawLocation; + for (; position < PolygonList[layer].Number; position++) + DrawPolygon(LAYER_PTR(layer), POLYGONLIST_ENTRY(layer, position)); + PolygonList[layer].DrawLocation = PolygonList[layer].Number; + } + } - /* draw all new pads */ - if (PCB->PinOn) - for (i = 0; i < 2; i++) - { - position = PadList[i].DrawLocation; + /* draw all new pads */ + if (PCB->PinOn) + for (i = 0; i < 2; i++) { + position = PadList[i].DrawLocation; - for (; position < PadList[i].Number; position++) - DrawPad (PADLIST_ENTRY (i, position)); - PadList[i].DrawLocation = PadList[i].Number; - } + for (; position < PadList[i].Number; position++) + DrawPad(PADLIST_ENTRY(i, position)); + PadList[i].DrawLocation = PadList[i].Number; + } - /* draw all new PVs; 'PVList' holds a list of pointers to the - * sorted array pointers to PV data - */ - while (PVList.DrawLocation < PVList.Number) - { - PinTypePtr pv = PVLIST_ENTRY (PVList.DrawLocation); + /* draw all new PVs; 'PVList' holds a list of pointers to the + * sorted array pointers to PV data + */ + while (PVList.DrawLocation < PVList.Number) { + PinTypePtr pv = PVLIST_ENTRY(PVList.DrawLocation); - if (TEST_FLAG (PINFLAG, pv)) - { - if (PCB->PinOn) - DrawPin (pv); - } - else if (PCB->ViaOn) - DrawVia (pv); - PVList.DrawLocation++; - } - /* draw the new rat-lines */ - if (PCB->RatOn) - { - position = RatList.DrawLocation; - for (; position < RatList.Number; position++) - DrawRat (RATLIST_ENTRY (position)); - RatList.DrawLocation = RatList.Number; - } + if (TEST_FLAG(PINFLAG, pv)) { + if (PCB->PinOn) + DrawPin(pv); + } + else if (PCB->ViaOn) + DrawVia(pv); + PVList.DrawLocation++; + } + /* draw the new rat-lines */ + if (PCB->RatOn) { + position = RatList.DrawLocation; + for (; position < RatList.Number; position++) + DrawRat(RATLIST_ENTRY(position)); + RatList.DrawLocation = RatList.Number; + } } /* --------------------------------------------------------------------------- * find all connections to pins within one element */ -void -LookupElementConnections (ElementTypePtr Element, FILE * FP) +void LookupElementConnections(ElementTypePtr Element, FILE * FP) { - /* reset all currently marked connections */ - User = true; - TheFlag = FOUNDFLAG; - ResetConnections (true); - InitConnectionLookup (); - PrintElementConnections (Element, FP, true); - SetChangedFlag (true); - if (Settings.RingBellWhenFinished) - gui->beep (); - FreeConnectionLookupMemory (); - IncrementUndoSerialNumber (); - User = false; - Draw (); + /* reset all currently marked connections */ + User = true; + TheFlag = FOUNDFLAG; + ResetConnections(true); + InitConnectionLookup(); + PrintElementConnections(Element, FP, true); + SetChangedFlag(true); + if (Settings.RingBellWhenFinished) + gui->beep(); + FreeConnectionLookupMemory(); + IncrementUndoSerialNumber(); + User = false; + Draw(); } /* --------------------------------------------------------------------------- * find all connections to pins of all element */ -void -LookupConnectionsToAllElements (FILE * FP) +void LookupConnectionsToAllElements(FILE * FP) { - /* reset all currently marked connections */ - User = false; - TheFlag = FOUNDFLAG; - ResetConnections (false); - InitConnectionLookup (); + /* reset all currently marked connections */ + User = false; + TheFlag = FOUNDFLAG; + ResetConnections(false); + InitConnectionLookup(); - ELEMENT_LOOP (PCB->Data); - { - /* break if abort dialog returned true */ - if (PrintElementConnections (element, FP, false)) - break; - SEPARATE (FP); - if (Settings.ResetAfterElement && n != 1) - ResetConnections (false); - } - END_LOOP; - if (Settings.RingBellWhenFinished) - gui->beep (); - ResetConnections (false); - FreeConnectionLookupMemory (); - Redraw (); + ELEMENT_LOOP(PCB->Data); + { + /* break if abort dialog returned true */ + if (PrintElementConnections(element, FP, false)) + break; + SEPARATE(FP); + if (Settings.ResetAfterElement && n != 1) + ResetConnections(false); + } + END_LOOP; + if (Settings.RingBellWhenFinished) + gui->beep(); + ResetConnections(false); + FreeConnectionLookupMemory(); + Redraw(); } /*--------------------------------------------------------------------------- * add the starting object to the list of found objects */ -static bool -ListStart (int type, void *ptr1, void *ptr2, void *ptr3) +static bool ListStart(int type, void *ptr1, void *ptr2, void *ptr3) { - DumpList (); - switch (type) - { - case PIN_TYPE: - case VIA_TYPE: - { - if (ADD_PV_TO_LIST ((PinTypePtr) ptr2, 0, NULL, FCT_START)) - return true; - break; - } + DumpList(); + switch (type) { + case PIN_TYPE: + case VIA_TYPE: + { + if (ADD_PV_TO_LIST((PinTypePtr) ptr2, 0, NULL, FCT_START)) + return true; + break; + } - case RATLINE_TYPE: - { - if (ADD_RAT_TO_LIST ((RatTypePtr) ptr1, 0, NULL, FCT_START)) - return true; - break; - } + case RATLINE_TYPE: + { + if (ADD_RAT_TO_LIST((RatTypePtr) ptr1, 0, NULL, FCT_START)) + return true; + break; + } - case LINE_TYPE: - { - int layer = GetLayerNumber (PCB->Data, - (LayerTypePtr) ptr1); + case LINE_TYPE: + { + int layer = GetLayerNumber(PCB->Data, + (LayerTypePtr) ptr1); - if (ADD_LINE_TO_LIST (layer, (LineTypePtr) ptr2, 0, NULL, FCT_START)) - return true; - break; - } + if (ADD_LINE_TO_LIST(layer, (LineTypePtr) ptr2, 0, NULL, FCT_START)) + return true; + break; + } - case ARC_TYPE: - { - int layer = GetLayerNumber (PCB->Data, - (LayerTypePtr) ptr1); + case ARC_TYPE: + { + int layer = GetLayerNumber(PCB->Data, + (LayerTypePtr) ptr1); - if (ADD_ARC_TO_LIST (layer, (ArcTypePtr) ptr2, 0, NULL, FCT_START)) - return true; - break; - } + if (ADD_ARC_TO_LIST(layer, (ArcTypePtr) ptr2, 0, NULL, FCT_START)) + return true; + break; + } - case POLYGON_TYPE: - { - int layer = GetLayerNumber (PCB->Data, - (LayerTypePtr) ptr1); + case POLYGON_TYPE: + { + int layer = GetLayerNumber(PCB->Data, + (LayerTypePtr) ptr1); - if (ADD_POLYGON_TO_LIST (layer, (PolygonTypePtr) ptr2, 0, NULL, FCT_START)) - return true; - break; - } + if (ADD_POLYGON_TO_LIST(layer, (PolygonTypePtr) ptr2, 0, NULL, FCT_START)) + return true; + break; + } - case PAD_TYPE: - { - PadTypePtr pad = (PadTypePtr) ptr2; - if (ADD_PAD_TO_LIST - (TEST_FLAG - (ONSOLDERFLAG, pad) ? SOLDER_LAYER : COMPONENT_LAYER, pad, 0, NULL, FCT_START)) - return true; - break; - } - } - return (false); + case PAD_TYPE: + { + PadTypePtr pad = (PadTypePtr) ptr2; + if (ADD_PAD_TO_LIST(TEST_FLAG(ONSOLDERFLAG, pad) ? SOLDER_LAYER : COMPONENT_LAYER, pad, 0, NULL, FCT_START)) + return true; + break; + } + } + return (false); } @@ -3338,62 +2977,54 @@ * the objects are re-drawn if AndDraw is true * also the action is marked as undoable if AndDraw is true */ -void -LookupConnection (Coord X, Coord Y, bool AndDraw, Coord Range, int which_flag) +void LookupConnection(Coord X, Coord Y, bool AndDraw, Coord Range, int which_flag) { - void *ptr1, *ptr2, *ptr3; - char *name; - int type; + void *ptr1, *ptr2, *ptr3; + char *name; + int type; - /* check if there are any pins or pads at that position */ + /* check if there are any pins or pads at that position */ - reassign_no_drc_flags (); + reassign_no_drc_flags(); - type - = SearchObjectByLocation (LOOKUP_FIRST, &ptr1, &ptr2, &ptr3, X, Y, Range); - if (type == NO_TYPE) - { - type - = - SearchObjectByLocation - (LOOKUP_MORE, &ptr1, &ptr2, &ptr3, X, Y, Range); - if (type == NO_TYPE) - return; - if (type & SILK_TYPE) - { - int laynum = GetLayerNumber (PCB->Data, - (LayerTypePtr) ptr1); + type = SearchObjectByLocation(LOOKUP_FIRST, &ptr1, &ptr2, &ptr3, X, Y, Range); + if (type == NO_TYPE) { + type = SearchObjectByLocation(LOOKUP_MORE, &ptr1, &ptr2, &ptr3, X, Y, Range); + if (type == NO_TYPE) + return; + if (type & SILK_TYPE) { + int laynum = GetLayerNumber(PCB->Data, + (LayerTypePtr) ptr1); - /* don't mess with non-conducting objects! */ - if (laynum >= max_copper_layer || ((LayerTypePtr)ptr1)->no_drc) - return; - } - } - else - { - name = ConnectionName (type, ptr1, ptr2); - hid_actionl ("NetlistShow", name, NULL); - } + /* don't mess with non-conducting objects! */ + if (laynum >= max_copper_layer || ((LayerTypePtr) ptr1)->no_drc) + return; + } + } + else { + name = ConnectionName(type, ptr1, ptr2); + hid_actionl("NetlistShow", name, NULL); + } - TheFlag = which_flag; - User = AndDraw; - InitConnectionLookup (); + TheFlag = which_flag; + User = AndDraw; + InitConnectionLookup(); - /* now add the object to the appropriate list and start scanning - * This is step (1) from the description - */ - ListStart (type, ptr1, ptr2, ptr3); - DoIt (true, AndDraw); - if (User) - IncrementUndoSerialNumber (); - User = false; + /* now add the object to the appropriate list and start scanning + * This is step (1) from the description + */ + ListStart(type, ptr1, ptr2, ptr3); + DoIt(true, AndDraw); + if (User) + IncrementUndoSerialNumber(); + User = false; - /* we are done */ - if (AndDraw) - Draw (); - if (AndDraw && Settings.RingBellWhenFinished) - gui->beep (); - FreeConnectionLookupMemory (); + /* we are done */ + if (AndDraw) + Draw(); + if (AndDraw && Settings.RingBellWhenFinished) + gui->beep(); + FreeConnectionLookupMemory(); } /* --------------------------------------------------------------------------- @@ -3400,214 +3031,198 @@ * find connections for rats nesting * assumes InitConnectionLookup() has already been done */ -void -RatFindHook (int type, void *ptr1, void *ptr2, void *ptr3, - bool undo, bool AndRats) +void RatFindHook(int type, void *ptr1, void *ptr2, void *ptr3, bool undo, bool AndRats) { - User = undo; - DumpList (); - ListStart (type, ptr1, ptr2, ptr3); - DoIt (AndRats, false); - User = false; + User = undo; + DumpList(); + ListStart(type, ptr1, ptr2, ptr3); + DoIt(AndRats, false); + User = false; } /* --------------------------------------------------------------------------- * find all unused pins of all element */ -void -LookupUnusedPins (FILE * FP) +void LookupUnusedPins(FILE * FP) { - /* reset all currently marked connections */ - User = true; - ResetConnections (true); - InitConnectionLookup (); + /* reset all currently marked connections */ + User = true; + ResetConnections(true); + InitConnectionLookup(); - ELEMENT_LOOP (PCB->Data); - { - /* break if abort dialog returned true; - * passing NULL as filedescriptor discards the normal output - */ - if (PrintAndSelectUnusedPinsAndPadsOfElement (element, FP)) - break; - } - END_LOOP; + ELEMENT_LOOP(PCB->Data); + { + /* break if abort dialog returned true; + * passing NULL as filedescriptor discards the normal output + */ + if (PrintAndSelectUnusedPinsAndPadsOfElement(element, FP)) + break; + } + END_LOOP; - if (Settings.RingBellWhenFinished) - gui->beep (); - FreeConnectionLookupMemory (); - IncrementUndoSerialNumber (); - User = false; - Draw (); + if (Settings.RingBellWhenFinished) + gui->beep(); + FreeConnectionLookupMemory(); + IncrementUndoSerialNumber(); + User = false; + Draw(); } /* --------------------------------------------------------------------------- * resets all used flags of pins and vias */ -bool -ResetFoundPinsViasAndPads (bool AndDraw) +bool ResetFoundPinsViasAndPads(bool AndDraw) { - bool change = false; + bool change = false; - VIA_LOOP (PCB->Data); - { - if (TEST_FLAG (TheFlag, via)) - { - if (AndDraw) - AddObjectToFlagUndoList (VIA_TYPE, via, via, via); - CLEAR_FLAG (TheFlag, via); - if (AndDraw) - DrawVia (via); - change = true; - } - } - END_LOOP; - ELEMENT_LOOP (PCB->Data); - { - PIN_LOOP (element); - { - if (TEST_FLAG (TheFlag, pin)) - { - if (AndDraw) - AddObjectToFlagUndoList (PIN_TYPE, element, pin, pin); - CLEAR_FLAG (TheFlag, pin); - if (AndDraw) - DrawPin (pin); - change = true; - } - } - END_LOOP; - PAD_LOOP (element); - { - if (TEST_FLAG (TheFlag, pad)) - { - if (AndDraw) - AddObjectToFlagUndoList (PAD_TYPE, element, pad, pad); - CLEAR_FLAG (TheFlag, pad); - if (AndDraw) - DrawPad (pad); - change = true; - } - } - END_LOOP; - } - END_LOOP; - if (change) - SetChangedFlag (true); - return change; + VIA_LOOP(PCB->Data); + { + if (TEST_FLAG(TheFlag, via)) { + if (AndDraw) + AddObjectToFlagUndoList(VIA_TYPE, via, via, via); + CLEAR_FLAG(TheFlag, via); + if (AndDraw) + DrawVia(via); + change = true; + } + } + END_LOOP; + ELEMENT_LOOP(PCB->Data); + { + PIN_LOOP(element); + { + if (TEST_FLAG(TheFlag, pin)) { + if (AndDraw) + AddObjectToFlagUndoList(PIN_TYPE, element, pin, pin); + CLEAR_FLAG(TheFlag, pin); + if (AndDraw) + DrawPin(pin); + change = true; + } + } + END_LOOP; + PAD_LOOP(element); + { + if (TEST_FLAG(TheFlag, pad)) { + if (AndDraw) + AddObjectToFlagUndoList(PAD_TYPE, element, pad, pad); + CLEAR_FLAG(TheFlag, pad); + if (AndDraw) + DrawPad(pad); + change = true; + } + } + END_LOOP; + } + END_LOOP; + if (change) + SetChangedFlag(true); + return change; } /* --------------------------------------------------------------------------- * resets all used flags of LOs */ -bool -ResetFoundLinesAndPolygons (bool AndDraw) +bool ResetFoundLinesAndPolygons(bool AndDraw) { - bool change = false; + bool change = false; - RAT_LOOP (PCB->Data); - { - if (TEST_FLAG (TheFlag, line)) - { - if (AndDraw) - AddObjectToFlagUndoList (RATLINE_TYPE, line, line, line); - CLEAR_FLAG (TheFlag, line); - if (AndDraw) - DrawRat (line); - change = true; - } - } - END_LOOP; - COPPERLINE_LOOP (PCB->Data); - { - if (TEST_FLAG (TheFlag, line)) - { - if (AndDraw) - AddObjectToFlagUndoList (LINE_TYPE, layer, line, line); - CLEAR_FLAG (TheFlag, line); - if (AndDraw) - DrawLine (layer, line); - change = true; - } - } - ENDALL_LOOP; - COPPERARC_LOOP (PCB->Data); - { - if (TEST_FLAG (TheFlag, arc)) - { - if (AndDraw) - AddObjectToFlagUndoList (ARC_TYPE, layer, arc, arc); - CLEAR_FLAG (TheFlag, arc); - if (AndDraw) - DrawArc (layer, arc); - change = true; - } - } - ENDALL_LOOP; - COPPERPOLYGON_LOOP (PCB->Data); - { - if (TEST_FLAG (TheFlag, polygon)) - { - if (AndDraw) - AddObjectToFlagUndoList (POLYGON_TYPE, layer, polygon, polygon); - CLEAR_FLAG (TheFlag, polygon); - if (AndDraw) - DrawPolygon (layer, polygon); - change = true; - } - } - ENDALL_LOOP; - if (change) - SetChangedFlag (true); - return change; + RAT_LOOP(PCB->Data); + { + if (TEST_FLAG(TheFlag, line)) { + if (AndDraw) + AddObjectToFlagUndoList(RATLINE_TYPE, line, line, line); + CLEAR_FLAG(TheFlag, line); + if (AndDraw) + DrawRat(line); + change = true; + } + } + END_LOOP; + COPPERLINE_LOOP(PCB->Data); + { + if (TEST_FLAG(TheFlag, line)) { + if (AndDraw) + AddObjectToFlagUndoList(LINE_TYPE, layer, line, line); + CLEAR_FLAG(TheFlag, line); + if (AndDraw) + DrawLine(layer, line); + change = true; + } + } + ENDALL_LOOP; + COPPERARC_LOOP(PCB->Data); + { + if (TEST_FLAG(TheFlag, arc)) { + if (AndDraw) + AddObjectToFlagUndoList(ARC_TYPE, layer, arc, arc); + CLEAR_FLAG(TheFlag, arc); + if (AndDraw) + DrawArc(layer, arc); + change = true; + } + } + ENDALL_LOOP; + COPPERPOLYGON_LOOP(PCB->Data); + { + if (TEST_FLAG(TheFlag, polygon)) { + if (AndDraw) + AddObjectToFlagUndoList(POLYGON_TYPE, layer, polygon, polygon); + CLEAR_FLAG(TheFlag, polygon); + if (AndDraw) + DrawPolygon(layer, polygon); + change = true; + } + } + ENDALL_LOOP; + if (change) + SetChangedFlag(true); + return change; } /* --------------------------------------------------------------------------- * resets all found connections */ -bool -ResetConnections (bool AndDraw) +bool ResetConnections(bool AndDraw) { - bool change = false; + bool change = false; - change = ResetFoundPinsViasAndPads (AndDraw) || change; - change = ResetFoundLinesAndPolygons (AndDraw) || change; + change = ResetFoundPinsViasAndPads(AndDraw) || change; + change = ResetFoundLinesAndPolygons(AndDraw) || change; - return change; + return change; } /*---------------------------------------------------------------------------- * Dumps the list contents */ -static void -DumpList (void) +static void DumpList(void) { - Cardinal i; + Cardinal i; - for (i = 0; i < 2; i++) - { - PadList[i].Number = 0; - PadList[i].Location = 0; - PadList[i].DrawLocation = 0; - } + for (i = 0; i < 2; i++) { + PadList[i].Number = 0; + PadList[i].Location = 0; + PadList[i].DrawLocation = 0; + } - PVList.Number = 0; - PVList.Location = 0; + PVList.Number = 0; + PVList.Location = 0; - for (i = 0; i < max_copper_layer; i++) - { - LineList[i].Location = 0; - LineList[i].DrawLocation = 0; - LineList[i].Number = 0; - ArcList[i].Location = 0; - ArcList[i].DrawLocation = 0; - ArcList[i].Number = 0; - PolygonList[i].Location = 0; - PolygonList[i].DrawLocation = 0; - PolygonList[i].Number = 0; - } - RatList.Number = 0; - RatList.Location = 0; - RatList.DrawLocation = 0; + for (i = 0; i < max_copper_layer; i++) { + LineList[i].Location = 0; + LineList[i].DrawLocation = 0; + LineList[i].Number = 0; + ArcList[i].Location = 0; + ArcList[i].DrawLocation = 0; + ArcList[i].Number = 0; + PolygonList[i].Location = 0; + PolygonList[i].DrawLocation = 0; + PolygonList[i].Number = 0; + } + RatList.Number = 0; + RatList.Location = 0; + RatList.DrawLocation = 0; } /*----------------------------------------------------------------------------- @@ -3614,266 +3229,230 @@ * Check for DRC violations on a single net starting from the pad or pin * sees if the connectivity changes when everything is bloated, or shrunk */ -static bool -DRCFind (int What, void *ptr1, void *ptr2, void *ptr3) +static bool DRCFind(int What, void *ptr1, void *ptr2, void *ptr3) { - Coord x, y; - int object_count; - long int *object_id_list; - int *object_type_list; - DrcViolationType *violation; + Coord x, y; + int object_count; + long int *object_id_list; + int *object_type_list; + DrcViolationType *violation; - if (PCB->Shrink != 0) - { - Bloat = -PCB->Shrink; - TheFlag = DRCFLAG | SELECTEDFLAG; - ListStart (What, ptr1, ptr2, ptr3); - DoIt (true, false); - /* ok now the shrunk net has the SELECTEDFLAG set */ - DumpList (); - TheFlag = FOUNDFLAG; - ListStart (What, ptr1, ptr2, ptr3); - Bloat = 0; - drc = true; /* abort the search if we find anything not already found */ - if (DoIt (true, false)) - { - DumpList (); - /* make the flag changes undoable */ - TheFlag = FOUNDFLAG | SELECTEDFLAG; - ResetConnections (false); - User = true; - drc = false; - Bloat = -PCB->Shrink; - TheFlag = SELECTEDFLAG; - ListStart (What, ptr1, ptr2, ptr3); - DoIt (true, true); - DumpList (); - ListStart (What, ptr1, ptr2, ptr3); - TheFlag = FOUNDFLAG; - Bloat = 0; - drc = true; - DoIt (true, true); - DumpList (); - User = false; - drc = false; - drcerr_count++; - LocateError (&x, &y); - BuildObjectList (&object_count, &object_id_list, &object_type_list); - violation = pcb_drc_violation_new (_("Potential for broken trace"), - _("Insufficient overlap between objects can lead to broken tracks\n" - "due to registration errors with old wheel style photo-plotters."), - x, y, - 0, /* ANGLE OF ERROR UNKNOWN */ - FALSE, /* MEASUREMENT OF ERROR UNKNOWN */ - 0, /* MAGNITUDE OF ERROR UNKNOWN */ - PCB->Shrink, - object_count, - object_id_list, - object_type_list); - append_drc_violation (violation); - pcb_drc_violation_free (violation); - free (object_id_list); - free (object_type_list); + if (PCB->Shrink != 0) { + Bloat = -PCB->Shrink; + TheFlag = DRCFLAG | SELECTEDFLAG; + ListStart(What, ptr1, ptr2, ptr3); + DoIt(true, false); + /* ok now the shrunk net has the SELECTEDFLAG set */ + DumpList(); + TheFlag = FOUNDFLAG; + ListStart(What, ptr1, ptr2, ptr3); + Bloat = 0; + drc = true; /* abort the search if we find anything not already found */ + if (DoIt(true, false)) { + DumpList(); + /* make the flag changes undoable */ + TheFlag = FOUNDFLAG | SELECTEDFLAG; + ResetConnections(false); + User = true; + drc = false; + Bloat = -PCB->Shrink; + TheFlag = SELECTEDFLAG; + ListStart(What, ptr1, ptr2, ptr3); + DoIt(true, true); + DumpList(); + ListStart(What, ptr1, ptr2, ptr3); + TheFlag = FOUNDFLAG; + Bloat = 0; + drc = true; + DoIt(true, true); + DumpList(); + User = false; + drc = false; + drcerr_count++; + LocateError(&x, &y); + BuildObjectList(&object_count, &object_id_list, &object_type_list); + violation = pcb_drc_violation_new(_("Potential for broken trace"), _("Insufficient overlap between objects can lead to broken tracks\n" "due to registration errors with old wheel style photo-plotters."), x, y, 0, /* ANGLE OF ERROR UNKNOWN */ + FALSE, /* MEASUREMENT OF ERROR UNKNOWN */ + 0, /* MAGNITUDE OF ERROR UNKNOWN */ + PCB->Shrink, object_count, object_id_list, object_type_list); + append_drc_violation(violation); + pcb_drc_violation_free(violation); + free(object_id_list); + free(object_type_list); - if (!throw_drc_dialog()) - return (true); - IncrementUndoSerialNumber (); - Undo (true); - } - DumpList (); - } - /* now check the bloated condition */ - drc = false; - ResetConnections (false); - TheFlag = FOUNDFLAG; - ListStart (What, ptr1, ptr2, ptr3); - Bloat = PCB->Bloat; - drc = true; - while (DoIt (true, false)) - { - DumpList (); - /* make the flag changes undoable */ - TheFlag = FOUNDFLAG | SELECTEDFLAG; - ResetConnections (false); - User = true; - drc = false; - Bloat = 0; - TheFlag = SELECTEDFLAG; - ListStart (What, ptr1, ptr2, ptr3); - DoIt (true, true); - DumpList (); - TheFlag = FOUNDFLAG; - ListStart (What, ptr1, ptr2, ptr3); - Bloat = PCB->Bloat; - drc = true; - DoIt (true, true); - DumpList (); - drcerr_count++; - LocateError (&x, &y); - BuildObjectList (&object_count, &object_id_list, &object_type_list); - violation = pcb_drc_violation_new (_("Copper areas too close"), - _("Circuits that are too close may bridge during imaging, etching,\n" - "plating, or soldering processes resulting in a direct short."), - x, y, - 0, /* ANGLE OF ERROR UNKNOWN */ - FALSE, /* MEASUREMENT OF ERROR UNKNOWN */ - 0, /* MAGNITUDE OF ERROR UNKNOWN */ - PCB->Bloat, - object_count, - object_id_list, - object_type_list); - append_drc_violation (violation); - pcb_drc_violation_free (violation); - free (object_id_list); - free (object_type_list); - User = false; - drc = false; - if (!throw_drc_dialog()) - return (true); - IncrementUndoSerialNumber (); - Undo (true); - /* highlight the rest of the encroaching net so it's not reported again */ - TheFlag |= SELECTEDFLAG; - Bloat = 0; - ListStart (thing_type, thing_ptr1, thing_ptr2, thing_ptr3); - DoIt (true, true); - DumpList (); - drc = true; - Bloat = PCB->Bloat; - ListStart (What, ptr1, ptr2, ptr3); - } - drc = false; - DumpList (); - TheFlag = FOUNDFLAG | SELECTEDFLAG; - ResetConnections (false); - return (false); + if (!throw_drc_dialog()) + return (true); + IncrementUndoSerialNumber(); + Undo(true); + } + DumpList(); + } + /* now check the bloated condition */ + drc = false; + ResetConnections(false); + TheFlag = FOUNDFLAG; + ListStart(What, ptr1, ptr2, ptr3); + Bloat = PCB->Bloat; + drc = true; + while (DoIt(true, false)) { + DumpList(); + /* make the flag changes undoable */ + TheFlag = FOUNDFLAG | SELECTEDFLAG; + ResetConnections(false); + User = true; + drc = false; + Bloat = 0; + TheFlag = SELECTEDFLAG; + ListStart(What, ptr1, ptr2, ptr3); + DoIt(true, true); + DumpList(); + TheFlag = FOUNDFLAG; + ListStart(What, ptr1, ptr2, ptr3); + Bloat = PCB->Bloat; + drc = true; + DoIt(true, true); + DumpList(); + drcerr_count++; + LocateError(&x, &y); + BuildObjectList(&object_count, &object_id_list, &object_type_list); + violation = pcb_drc_violation_new(_("Copper areas too close"), _("Circuits that are too close may bridge during imaging, etching,\n" "plating, or soldering processes resulting in a direct short."), x, y, 0, /* ANGLE OF ERROR UNKNOWN */ + FALSE, /* MEASUREMENT OF ERROR UNKNOWN */ + 0, /* MAGNITUDE OF ERROR UNKNOWN */ + PCB->Bloat, object_count, object_id_list, object_type_list); + append_drc_violation(violation); + pcb_drc_violation_free(violation); + free(object_id_list); + free(object_type_list); + User = false; + drc = false; + if (!throw_drc_dialog()) + return (true); + IncrementUndoSerialNumber(); + Undo(true); + /* highlight the rest of the encroaching net so it's not reported again */ + TheFlag |= SELECTEDFLAG; + Bloat = 0; + ListStart(thing_type, thing_ptr1, thing_ptr2, thing_ptr3); + DoIt(true, true); + DumpList(); + drc = true; + Bloat = PCB->Bloat; + ListStart(What, ptr1, ptr2, ptr3); + } + drc = false; + DumpList(); + TheFlag = FOUNDFLAG | SELECTEDFLAG; + ResetConnections(false); + return (false); } /*---------------------------------------------------------------------------- * set up a temporary flag to use */ -void -SaveFindFlag (int NewFlag) +void SaveFindFlag(int NewFlag) { - OldFlag = TheFlag; - TheFlag = NewFlag; + OldFlag = TheFlag; + TheFlag = NewFlag; } /*---------------------------------------------------------------------------- * restore flag */ -void -RestoreFindFlag (void) +void RestoreFindFlag(void) { - TheFlag = OldFlag; + TheFlag = OldFlag; } /* DRC clearance callback */ -static int -drc_callback (DataTypePtr data, LayerTypePtr layer, PolygonTypePtr polygon, - int type, void *ptr1, void *ptr2) +static int drc_callback(DataTypePtr data, LayerTypePtr layer, PolygonTypePtr polygon, int type, void *ptr1, void *ptr2) { - char *message; - Coord x, y; - int object_count; - long int *object_id_list; - int *object_type_list; - DrcViolationType *violation; + char *message; + Coord x, y; + int object_count; + long int *object_id_list; + int *object_type_list; + DrcViolationType *violation; - LineTypePtr line = (LineTypePtr) ptr2; - ArcTypePtr arc = (ArcTypePtr) ptr2; - PinTypePtr pin = (PinTypePtr) ptr2; - PadTypePtr pad = (PadTypePtr) ptr2; + LineTypePtr line = (LineTypePtr) ptr2; + ArcTypePtr arc = (ArcTypePtr) ptr2; + PinTypePtr pin = (PinTypePtr) ptr2; + PadTypePtr pad = (PadTypePtr) ptr2; - thing_type = type; - thing_ptr1 = ptr1; - thing_ptr2 = ptr2; - thing_ptr3 = ptr2; - switch (type) - { - case LINE_TYPE: - if (line->Clearance < 2 * PCB->Bloat) - { - AddObjectToFlagUndoList (type, ptr1, ptr2, ptr2); - SET_FLAG (TheFlag, line); - message = _("Line with insufficient clearance inside polygon\n"); - goto doIsBad; - } - break; - case ARC_TYPE: - if (arc->Clearance < 2 * PCB->Bloat) - { - AddObjectToFlagUndoList (type, ptr1, ptr2, ptr2); - SET_FLAG (TheFlag, arc); - message = _("Arc with insufficient clearance inside polygon\n"); - goto doIsBad; - } - break; - case PAD_TYPE: - if (pad->Clearance && pad->Clearance < 2 * PCB->Bloat) - if (IsPadInPolygon(pad,polygon)) - { - AddObjectToFlagUndoList (type, ptr1, ptr2, ptr2); - SET_FLAG (TheFlag, pad); - message = _("Pad with insufficient clearance inside polygon\n"); - goto doIsBad; - } - break; - case PIN_TYPE: - if (pin->Clearance && pin->Clearance < 2 * PCB->Bloat) - { - AddObjectToFlagUndoList (type, ptr1, ptr2, ptr2); - SET_FLAG (TheFlag, pin); - message = _("Pin with insufficient clearance inside polygon\n"); - goto doIsBad; - } - break; - case VIA_TYPE: - if (pin->Clearance && pin->Clearance < 2 * PCB->Bloat) - { - AddObjectToFlagUndoList (type, ptr1, ptr2, ptr2); - SET_FLAG (TheFlag, pin); - message = _("Via with insufficient clearance inside polygon\n"); - goto doIsBad; - } - break; - default: - Message ("hace: Bad Plow object in callback\n"); - } - return 0; + thing_type = type; + thing_ptr1 = ptr1; + thing_ptr2 = ptr2; + thing_ptr3 = ptr2; + switch (type) { + case LINE_TYPE: + if (line->Clearance < 2 * PCB->Bloat) { + AddObjectToFlagUndoList(type, ptr1, ptr2, ptr2); + SET_FLAG(TheFlag, line); + message = _("Line with insufficient clearance inside polygon\n"); + goto doIsBad; + } + break; + case ARC_TYPE: + if (arc->Clearance < 2 * PCB->Bloat) { + AddObjectToFlagUndoList(type, ptr1, ptr2, ptr2); + SET_FLAG(TheFlag, arc); + message = _("Arc with insufficient clearance inside polygon\n"); + goto doIsBad; + } + break; + case PAD_TYPE: + if (pad->Clearance && pad->Clearance < 2 * PCB->Bloat) + if (IsPadInPolygon(pad, polygon)) { + AddObjectToFlagUndoList(type, ptr1, ptr2, ptr2); + SET_FLAG(TheFlag, pad); + message = _("Pad with insufficient clearance inside polygon\n"); + goto doIsBad; + } + break; + case PIN_TYPE: + if (pin->Clearance && pin->Clearance < 2 * PCB->Bloat) { + AddObjectToFlagUndoList(type, ptr1, ptr2, ptr2); + SET_FLAG(TheFlag, pin); + message = _("Pin with insufficient clearance inside polygon\n"); + goto doIsBad; + } + break; + case VIA_TYPE: + if (pin->Clearance && pin->Clearance < 2 * PCB->Bloat) { + AddObjectToFlagUndoList(type, ptr1, ptr2, ptr2); + SET_FLAG(TheFlag, pin); + message = _("Via with insufficient clearance inside polygon\n"); + goto doIsBad; + } + break; + default: + Message("hace: Bad Plow object in callback\n"); + } + return 0; doIsBad: - AddObjectToFlagUndoList (POLYGON_TYPE, layer, polygon, polygon); - SET_FLAG (FOUNDFLAG, polygon); - DrawPolygon (layer, polygon); - DrawObject (type, ptr1, ptr2); - drcerr_count++; - LocateError (&x, &y); - BuildObjectList (&object_count, &object_id_list, &object_type_list); - violation = pcb_drc_violation_new (message, - _("Circuits that are too close may bridge during imaging, etching,\n" - "plating, or soldering processes resulting in a direct short."), - x, y, - 0, /* ANGLE OF ERROR UNKNOWN */ - FALSE, /* MEASUREMENT OF ERROR UNKNOWN */ - 0, /* MAGNITUDE OF ERROR UNKNOWN */ - PCB->Bloat, - object_count, - object_id_list, - object_type_list); - append_drc_violation (violation); - pcb_drc_violation_free (violation); - free (object_id_list); - free (object_type_list); - if (!throw_drc_dialog()) - { - IsBad = true; - return 1; - } - IncrementUndoSerialNumber (); - Undo (true); - return 0; + AddObjectToFlagUndoList(POLYGON_TYPE, layer, polygon, polygon); + SET_FLAG(FOUNDFLAG, polygon); + DrawPolygon(layer, polygon); + DrawObject(type, ptr1, ptr2); + drcerr_count++; + LocateError(&x, &y); + BuildObjectList(&object_count, &object_id_list, &object_type_list); + violation = pcb_drc_violation_new(message, _("Circuits that are too close may bridge during imaging, etching,\n" "plating, or soldering processes resulting in a direct short."), x, y, 0, /* ANGLE OF ERROR UNKNOWN */ + FALSE, /* MEASUREMENT OF ERROR UNKNOWN */ + 0, /* MAGNITUDE OF ERROR UNKNOWN */ + PCB->Bloat, object_count, object_id_list, object_type_list); + append_drc_violation(violation); + pcb_drc_violation_free(violation); + free(object_id_list); + free(object_type_list); + if (!throw_drc_dialog()) { + IsBad = true; + return 1; + } + IncrementUndoSerialNumber(); + Undo(true); + return 0; } /*----------------------------------------------------------------------------- @@ -3880,547 +3459,438 @@ * Check for DRC violations * see if the connectivity changes when everything is bloated, or shrunk */ -int -DRCAll (void) +int DRCAll(void) { - Coord x, y; - int object_count; - long int *object_id_list; - int *object_type_list; - DrcViolationType *violation; - int tmpcnt; - int nopastecnt = 0; + Coord x, y; + int object_count; + long int *object_id_list; + int *object_type_list; + DrcViolationType *violation; + int tmpcnt; + int nopastecnt = 0; - reset_drc_dialog_message(); + reset_drc_dialog_message(); - IsBad = false; - drcerr_count = 0; - SaveStackAndVisibility (); - ResetStackAndVisibility (); - hid_action ("LayersChanged"); - InitConnectionLookup (); + IsBad = false; + drcerr_count = 0; + SaveStackAndVisibility(); + ResetStackAndVisibility(); + hid_action("LayersChanged"); + InitConnectionLookup(); - TheFlag = FOUNDFLAG | DRCFLAG | SELECTEDFLAG; + TheFlag = FOUNDFLAG | DRCFLAG | SELECTEDFLAG; - if (ResetConnections (true)) - { - IncrementUndoSerialNumber (); - Draw (); - } + if (ResetConnections(true)) { + IncrementUndoSerialNumber(); + Draw(); + } - User = false; + User = false; - ELEMENT_LOOP (PCB->Data); - { - PIN_LOOP (element); - { - if (!TEST_FLAG (DRCFLAG, pin) - && DRCFind (PIN_TYPE, (void *) element, (void *) pin, (void *) pin)) - { - IsBad = true; - break; - } - } - END_LOOP; - if (IsBad) - break; - PAD_LOOP (element); - { + ELEMENT_LOOP(PCB->Data); + { + PIN_LOOP(element); + { + if (!TEST_FLAG(DRCFLAG, pin) + && DRCFind(PIN_TYPE, (void *) element, (void *) pin, (void *) pin)) { + IsBad = true; + break; + } + } + END_LOOP; + if (IsBad) + break; + PAD_LOOP(element); + { - /* count up how many pads have no solderpaste openings */ - if (TEST_FLAG (NOPASTEFLAG, pad)) - nopastecnt++; + /* count up how many pads have no solderpaste openings */ + if (TEST_FLAG(NOPASTEFLAG, pad)) + nopastecnt++; - if (!TEST_FLAG (DRCFLAG, pad) - && DRCFind (PAD_TYPE, (void *) element, (void *) pad, (void *) pad)) - { - IsBad = true; - break; - } - } - END_LOOP; - if (IsBad) - break; - } - END_LOOP; - if (!IsBad) - VIA_LOOP (PCB->Data); - { - if (!TEST_FLAG (DRCFLAG, via) - && DRCFind (VIA_TYPE, (void *) via, (void *) via, (void *) via)) - { - IsBad = true; - break; - } - } - END_LOOP; + if (!TEST_FLAG(DRCFLAG, pad) + && DRCFind(PAD_TYPE, (void *) element, (void *) pad, (void *) pad)) { + IsBad = true; + break; + } + } + END_LOOP; + if (IsBad) + break; + } + END_LOOP; + if (!IsBad) + VIA_LOOP(PCB->Data); + { + if (!TEST_FLAG(DRCFLAG, via) + && DRCFind(VIA_TYPE, (void *) via, (void *) via, (void *) via)) { + IsBad = true; + break; + } + } + END_LOOP; - TheFlag = (IsBad) ? DRCFLAG : (FOUNDFLAG | DRCFLAG | SELECTEDFLAG); - ResetConnections (false); - TheFlag = SELECTEDFLAG; - /* check minimum widths and polygon clearances */ - if (!IsBad) - { - COPPERLINE_LOOP (PCB->Data); - { - /* check line clearances in polygons */ - PlowsPolygon (PCB->Data, LINE_TYPE, layer, line, drc_callback); - if (IsBad) - break; - if (line->Thickness < PCB->minWid) - { - AddObjectToFlagUndoList (LINE_TYPE, layer, line, line); - SET_FLAG (TheFlag, line); - DrawLine (layer, line); - drcerr_count++; - SetThing (LINE_TYPE, layer, line, line); - LocateError (&x, &y); - BuildObjectList (&object_count, &object_id_list, &object_type_list); - violation = pcb_drc_violation_new (_("Line width is too thin"), - _("Process specifications dictate a minimum feature-width\n" - "that can reliably be reproduced"), - x, y, - 0, /* ANGLE OF ERROR UNKNOWN */ - TRUE, /* MEASUREMENT OF ERROR KNOWN */ - line->Thickness, - PCB->minWid, - object_count, - object_id_list, - object_type_list); - append_drc_violation (violation); - pcb_drc_violation_free (violation); - free (object_id_list); - free (object_type_list); - if (!throw_drc_dialog()) - { - IsBad = true; - break; - } - IncrementUndoSerialNumber (); - Undo (false); - } - } - ENDALL_LOOP; - } - if (!IsBad) - { - COPPERARC_LOOP (PCB->Data); - { - PlowsPolygon (PCB->Data, ARC_TYPE, layer, arc, drc_callback); - if (IsBad) - break; - if (arc->Thickness < PCB->minWid) - { - AddObjectToFlagUndoList (ARC_TYPE, layer, arc, arc); - SET_FLAG (TheFlag, arc); - DrawArc (layer, arc); - drcerr_count++; - SetThing (ARC_TYPE, layer, arc, arc); - LocateError (&x, &y); - BuildObjectList (&object_count, &object_id_list, &object_type_list); - violation = pcb_drc_violation_new (_("Arc width is too thin"), - _("Process specifications dictate a minimum feature-width\n" - "that can reliably be reproduced"), - x, y, - 0, /* ANGLE OF ERROR UNKNOWN */ - TRUE, /* MEASUREMENT OF ERROR KNOWN */ - arc->Thickness, - PCB->minWid, - object_count, - object_id_list, - object_type_list); - append_drc_violation (violation); - pcb_drc_violation_free (violation); - free (object_id_list); - free (object_type_list); - if (!throw_drc_dialog()) - { - IsBad = true; - break; - } - IncrementUndoSerialNumber (); - Undo (false); - } - } - ENDALL_LOOP; - } - if (!IsBad) - { - ALLPIN_LOOP (PCB->Data); - { - PlowsPolygon (PCB->Data, PIN_TYPE, element, pin, drc_callback); - if (IsBad) - break; - if (!TEST_FLAG (HOLEFLAG, pin) && - pin->Thickness - pin->DrillingHole < 2 * PCB->minRing) - { - AddObjectToFlagUndoList (PIN_TYPE, element, pin, pin); - SET_FLAG (TheFlag, pin); - DrawPin (pin); - drcerr_count++; - SetThing (PIN_TYPE, element, pin, pin); - LocateError (&x, &y); - BuildObjectList (&object_count, &object_id_list, &object_type_list); - violation = pcb_drc_violation_new (_("Pin annular ring too small"), - _("Annular rings that are too small may erode during etching,\n" - "resulting in a broken connection"), - x, y, - 0, /* ANGLE OF ERROR UNKNOWN */ - TRUE, /* MEASUREMENT OF ERROR KNOWN */ - (pin->Thickness - pin->DrillingHole) / 2, - PCB->minRing, - object_count, - object_id_list, - object_type_list); - append_drc_violation (violation); - pcb_drc_violation_free (violation); - free (object_id_list); - free (object_type_list); - if (!throw_drc_dialog()) - { - IsBad = true; - break; - } - IncrementUndoSerialNumber (); - Undo (false); - } - if (pin->DrillingHole < PCB->minDrill) - { - AddObjectToFlagUndoList (PIN_TYPE, element, pin, pin); - SET_FLAG (TheFlag, pin); - DrawPin (pin); - drcerr_count++; - SetThing (PIN_TYPE, element, pin, pin); - LocateError (&x, &y); - BuildObjectList (&object_count, &object_id_list, &object_type_list); - violation = pcb_drc_violation_new (_("Pin drill size is too small"), - _("Process rules dictate the minimum drill size which can be used"), - x, y, - 0, /* ANGLE OF ERROR UNKNOWN */ - TRUE, /* MEASUREMENT OF ERROR KNOWN */ - pin->DrillingHole, - PCB->minDrill, - object_count, - object_id_list, - object_type_list); - append_drc_violation (violation); - pcb_drc_violation_free (violation); - free (object_id_list); - free (object_type_list); - if (!throw_drc_dialog()) - { - IsBad = true; - break; - } - IncrementUndoSerialNumber (); - Undo (false); - } - } - ENDALL_LOOP; - } - if (!IsBad) - { - ALLPAD_LOOP (PCB->Data); - { - PlowsPolygon (PCB->Data, PAD_TYPE, element, pad, drc_callback); - if (IsBad) - break; - if (pad->Thickness < PCB->minWid) - { - AddObjectToFlagUndoList (PAD_TYPE, element, pad, pad); - SET_FLAG (TheFlag, pad); - DrawPad (pad); - drcerr_count++; - SetThing (PAD_TYPE, element, pad, pad); - LocateError (&x, &y); - BuildObjectList (&object_count, &object_id_list, &object_type_list); - violation = pcb_drc_violation_new (_("Pad is too thin"), - _("Pads which are too thin may erode during etching,\n" - "resulting in a broken or unreliable connection"), - x, y, - 0, /* ANGLE OF ERROR UNKNOWN */ - TRUE, /* MEASUREMENT OF ERROR KNOWN */ - pad->Thickness, - PCB->minWid, - object_count, - object_id_list, - object_type_list); - append_drc_violation (violation); - pcb_drc_violation_free (violation); - free (object_id_list); - free (object_type_list); - if (!throw_drc_dialog()) - { - IsBad = true; - break; - } - IncrementUndoSerialNumber (); - Undo (false); - } - } - ENDALL_LOOP; - } - if (!IsBad) - { - VIA_LOOP (PCB->Data); - { - PlowsPolygon (PCB->Data, VIA_TYPE, via, via, drc_callback); - if (IsBad) - break; - if (!TEST_FLAG (HOLEFLAG, via) && - via->Thickness - via->DrillingHole < 2 * PCB->minRing) - { - AddObjectToFlagUndoList (VIA_TYPE, via, via, via); - SET_FLAG (TheFlag, via); - DrawVia (via); - drcerr_count++; - SetThing (VIA_TYPE, via, via, via); - LocateError (&x, &y); - BuildObjectList (&object_count, &object_id_list, &object_type_list); - violation = pcb_drc_violation_new (_("Via annular ring too small"), - _("Annular rings that are too small may erode during etching,\n" - "resulting in a broken connection"), - x, y, - 0, /* ANGLE OF ERROR UNKNOWN */ - TRUE, /* MEASUREMENT OF ERROR KNOWN */ - (via->Thickness - via->DrillingHole) / 2, - PCB->minRing, - object_count, - object_id_list, - object_type_list); - append_drc_violation (violation); - pcb_drc_violation_free (violation); - free (object_id_list); - free (object_type_list); - if (!throw_drc_dialog()) - { - IsBad = true; - break; - } - IncrementUndoSerialNumber (); - Undo (false); - } - if (via->DrillingHole < PCB->minDrill) - { - AddObjectToFlagUndoList (VIA_TYPE, via, via, via); - SET_FLAG (TheFlag, via); - DrawVia (via); - drcerr_count++; - SetThing (VIA_TYPE, via, via, via); - LocateError (&x, &y); - BuildObjectList (&object_count, &object_id_list, &object_type_list); - violation = pcb_drc_violation_new (_("Via drill size is too small"), - _("Process rules dictate the minimum drill size which can be used"), - x, y, - 0, /* ANGLE OF ERROR UNKNOWN */ - TRUE, /* MEASUREMENT OF ERROR KNOWN */ - via->DrillingHole, - PCB->minDrill, - object_count, - object_id_list, - object_type_list); - append_drc_violation (violation); - pcb_drc_violation_free (violation); - free (object_id_list); - free (object_type_list); - if (!throw_drc_dialog()) - { - IsBad = true; - break; - } - IncrementUndoSerialNumber (); - Undo (false); - } - } - END_LOOP; - } + TheFlag = (IsBad) ? DRCFLAG : (FOUNDFLAG | DRCFLAG | SELECTEDFLAG); + ResetConnections(false); + TheFlag = SELECTEDFLAG; + /* check minimum widths and polygon clearances */ + if (!IsBad) { + COPPERLINE_LOOP(PCB->Data); + { + /* check line clearances in polygons */ + PlowsPolygon(PCB->Data, LINE_TYPE, layer, line, drc_callback); + if (IsBad) + break; + if (line->Thickness < PCB->minWid) { + AddObjectToFlagUndoList(LINE_TYPE, layer, line, line); + SET_FLAG(TheFlag, line); + DrawLine(layer, line); + drcerr_count++; + SetThing(LINE_TYPE, layer, line, line); + LocateError(&x, &y); + BuildObjectList(&object_count, &object_id_list, &object_type_list); + violation = pcb_drc_violation_new(_("Line width is too thin"), _("Process specifications dictate a minimum feature-width\n" "that can reliably be reproduced"), x, y, 0, /* ANGLE OF ERROR UNKNOWN */ + TRUE, /* MEASUREMENT OF ERROR KNOWN */ + line->Thickness, PCB->minWid, object_count, object_id_list, object_type_list); + append_drc_violation(violation); + pcb_drc_violation_free(violation); + free(object_id_list); + free(object_type_list); + if (!throw_drc_dialog()) { + IsBad = true; + break; + } + IncrementUndoSerialNumber(); + Undo(false); + } + } + ENDALL_LOOP; + } + if (!IsBad) { + COPPERARC_LOOP(PCB->Data); + { + PlowsPolygon(PCB->Data, ARC_TYPE, layer, arc, drc_callback); + if (IsBad) + break; + if (arc->Thickness < PCB->minWid) { + AddObjectToFlagUndoList(ARC_TYPE, layer, arc, arc); + SET_FLAG(TheFlag, arc); + DrawArc(layer, arc); + drcerr_count++; + SetThing(ARC_TYPE, layer, arc, arc); + LocateError(&x, &y); + BuildObjectList(&object_count, &object_id_list, &object_type_list); + violation = pcb_drc_violation_new(_("Arc width is too thin"), _("Process specifications dictate a minimum feature-width\n" "that can reliably be reproduced"), x, y, 0, /* ANGLE OF ERROR UNKNOWN */ + TRUE, /* MEASUREMENT OF ERROR KNOWN */ + arc->Thickness, PCB->minWid, object_count, object_id_list, object_type_list); + append_drc_violation(violation); + pcb_drc_violation_free(violation); + free(object_id_list); + free(object_type_list); + if (!throw_drc_dialog()) { + IsBad = true; + break; + } + IncrementUndoSerialNumber(); + Undo(false); + } + } + ENDALL_LOOP; + } + if (!IsBad) { + ALLPIN_LOOP(PCB->Data); + { + PlowsPolygon(PCB->Data, PIN_TYPE, element, pin, drc_callback); + if (IsBad) + break; + if (!TEST_FLAG(HOLEFLAG, pin) && pin->Thickness - pin->DrillingHole < 2 * PCB->minRing) { + AddObjectToFlagUndoList(PIN_TYPE, element, pin, pin); + SET_FLAG(TheFlag, pin); + DrawPin(pin); + drcerr_count++; + SetThing(PIN_TYPE, element, pin, pin); + LocateError(&x, &y); + BuildObjectList(&object_count, &object_id_list, &object_type_list); + violation = pcb_drc_violation_new(_("Pin annular ring too small"), _("Annular rings that are too small may erode during etching,\n" "resulting in a broken connection"), x, y, 0, /* ANGLE OF ERROR UNKNOWN */ + TRUE, /* MEASUREMENT OF ERROR KNOWN */ + (pin->Thickness - pin->DrillingHole) / 2, + PCB->minRing, object_count, object_id_list, object_type_list); + append_drc_violation(violation); + pcb_drc_violation_free(violation); + free(object_id_list); + free(object_type_list); + if (!throw_drc_dialog()) { + IsBad = true; + break; + } + IncrementUndoSerialNumber(); + Undo(false); + } + if (pin->DrillingHole < PCB->minDrill) { + AddObjectToFlagUndoList(PIN_TYPE, element, pin, pin); + SET_FLAG(TheFlag, pin); + DrawPin(pin); + drcerr_count++; + SetThing(PIN_TYPE, element, pin, pin); + LocateError(&x, &y); + BuildObjectList(&object_count, &object_id_list, &object_type_list); + violation = pcb_drc_violation_new(_("Pin drill size is too small"), _("Process rules dictate the minimum drill size which can be used"), x, y, 0, /* ANGLE OF ERROR UNKNOWN */ + TRUE, /* MEASUREMENT OF ERROR KNOWN */ + pin->DrillingHole, PCB->minDrill, object_count, object_id_list, object_type_list); + append_drc_violation(violation); + pcb_drc_violation_free(violation); + free(object_id_list); + free(object_type_list); + if (!throw_drc_dialog()) { + IsBad = true; + break; + } + IncrementUndoSerialNumber(); + Undo(false); + } + } + ENDALL_LOOP; + } + if (!IsBad) { + ALLPAD_LOOP(PCB->Data); + { + PlowsPolygon(PCB->Data, PAD_TYPE, element, pad, drc_callback); + if (IsBad) + break; + if (pad->Thickness < PCB->minWid) { + AddObjectToFlagUndoList(PAD_TYPE, element, pad, pad); + SET_FLAG(TheFlag, pad); + DrawPad(pad); + drcerr_count++; + SetThing(PAD_TYPE, element, pad, pad); + LocateError(&x, &y); + BuildObjectList(&object_count, &object_id_list, &object_type_list); + violation = pcb_drc_violation_new(_("Pad is too thin"), _("Pads which are too thin may erode during etching,\n" "resulting in a broken or unreliable connection"), x, y, 0, /* ANGLE OF ERROR UNKNOWN */ + TRUE, /* MEASUREMENT OF ERROR KNOWN */ + pad->Thickness, PCB->minWid, object_count, object_id_list, object_type_list); + append_drc_violation(violation); + pcb_drc_violation_free(violation); + free(object_id_list); + free(object_type_list); + if (!throw_drc_dialog()) { + IsBad = true; + break; + } + IncrementUndoSerialNumber(); + Undo(false); + } + } + ENDALL_LOOP; + } + if (!IsBad) { + VIA_LOOP(PCB->Data); + { + PlowsPolygon(PCB->Data, VIA_TYPE, via, via, drc_callback); + if (IsBad) + break; + if (!TEST_FLAG(HOLEFLAG, via) && via->Thickness - via->DrillingHole < 2 * PCB->minRing) { + AddObjectToFlagUndoList(VIA_TYPE, via, via, via); + SET_FLAG(TheFlag, via); + DrawVia(via); + drcerr_count++; + SetThing(VIA_TYPE, via, via, via); + LocateError(&x, &y); + BuildObjectList(&object_count, &object_id_list, &object_type_list); + violation = pcb_drc_violation_new(_("Via annular ring too small"), _("Annular rings that are too small may erode during etching,\n" "resulting in a broken connection"), x, y, 0, /* ANGLE OF ERROR UNKNOWN */ + TRUE, /* MEASUREMENT OF ERROR KNOWN */ + (via->Thickness - via->DrillingHole) / 2, + PCB->minRing, object_count, object_id_list, object_type_list); + append_drc_violation(violation); + pcb_drc_violation_free(violation); + free(object_id_list); + free(object_type_list); + if (!throw_drc_dialog()) { + IsBad = true; + break; + } + IncrementUndoSerialNumber(); + Undo(false); + } + if (via->DrillingHole < PCB->minDrill) { + AddObjectToFlagUndoList(VIA_TYPE, via, via, via); + SET_FLAG(TheFlag, via); + DrawVia(via); + drcerr_count++; + SetThing(VIA_TYPE, via, via, via); + LocateError(&x, &y); + BuildObjectList(&object_count, &object_id_list, &object_type_list); + violation = pcb_drc_violation_new(_("Via drill size is too small"), _("Process rules dictate the minimum drill size which can be used"), x, y, 0, /* ANGLE OF ERROR UNKNOWN */ + TRUE, /* MEASUREMENT OF ERROR KNOWN */ + via->DrillingHole, PCB->minDrill, object_count, object_id_list, object_type_list); + append_drc_violation(violation); + pcb_drc_violation_free(violation); + free(object_id_list); + free(object_type_list); + if (!throw_drc_dialog()) { + IsBad = true; + break; + } + IncrementUndoSerialNumber(); + Undo(false); + } + } + END_LOOP; + } - FreeConnectionLookupMemory (); - TheFlag = FOUNDFLAG; - Bloat = 0; + FreeConnectionLookupMemory(); + TheFlag = FOUNDFLAG; + Bloat = 0; - /* check silkscreen minimum widths outside of elements */ - /* XXX - need to check text and polygons too! */ - TheFlag = SELECTEDFLAG; - if (!IsBad) - { - SILKLINE_LOOP (PCB->Data); - { - if (line->Thickness < PCB->minSlk) - { - SET_FLAG (TheFlag, line); - DrawLine (layer, line); - drcerr_count++; - SetThing (LINE_TYPE, layer, line, line); - LocateError (&x, &y); - BuildObjectList (&object_count, &object_id_list, &object_type_list); - violation = pcb_drc_violation_new (_("Silk line is too thin"), - _("Process specifications dictate a minimum silkscreen feature-width\n" - "that can reliably be reproduced"), - x, y, - 0, /* ANGLE OF ERROR UNKNOWN */ - TRUE, /* MEASUREMENT OF ERROR KNOWN */ - line->Thickness, - PCB->minSlk, - object_count, - object_id_list, - object_type_list); - append_drc_violation (violation); - pcb_drc_violation_free (violation); - free (object_id_list); - free (object_type_list); - if (!throw_drc_dialog()) - { - IsBad = true; - break; - } - } - } - ENDALL_LOOP; - } + /* check silkscreen minimum widths outside of elements */ + /* XXX - need to check text and polygons too! */ + TheFlag = SELECTEDFLAG; + if (!IsBad) { + SILKLINE_LOOP(PCB->Data); + { + if (line->Thickness < PCB->minSlk) { + SET_FLAG(TheFlag, line); + DrawLine(layer, line); + drcerr_count++; + SetThing(LINE_TYPE, layer, line, line); + LocateError(&x, &y); + BuildObjectList(&object_count, &object_id_list, &object_type_list); + violation = pcb_drc_violation_new(_("Silk line is too thin"), _("Process specifications dictate a minimum silkscreen feature-width\n" "that can reliably be reproduced"), x, y, 0, /* ANGLE OF ERROR UNKNOWN */ + TRUE, /* MEASUREMENT OF ERROR KNOWN */ + line->Thickness, PCB->minSlk, object_count, object_id_list, object_type_list); + append_drc_violation(violation); + pcb_drc_violation_free(violation); + free(object_id_list); + free(object_type_list); + if (!throw_drc_dialog()) { + IsBad = true; + break; + } + } + } + ENDALL_LOOP; + } - /* check silkscreen minimum widths inside of elements */ - /* XXX - need to check text and polygons too! */ - TheFlag = SELECTEDFLAG; - if (!IsBad) - { - ELEMENT_LOOP (PCB->Data); - { - tmpcnt = 0; - ELEMENTLINE_LOOP (element); - { - if (line->Thickness < PCB->minSlk) - tmpcnt++; - } - END_LOOP; - if (tmpcnt > 0) - { - char *title; - char *name; - char *buffer; - int buflen; + /* check silkscreen minimum widths inside of elements */ + /* XXX - need to check text and polygons too! */ + TheFlag = SELECTEDFLAG; + if (!IsBad) { + ELEMENT_LOOP(PCB->Data); + { + tmpcnt = 0; + ELEMENTLINE_LOOP(element); + { + if (line->Thickness < PCB->minSlk) + tmpcnt++; + } + END_LOOP; + if (tmpcnt > 0) { + char *title; + char *name; + char *buffer; + int buflen; - SET_FLAG (TheFlag, element); - DrawElement (element); - drcerr_count++; - SetThing (ELEMENT_TYPE, element, element, element); - LocateError (&x, &y); - BuildObjectList (&object_count, &object_id_list, &object_type_list); + SET_FLAG(TheFlag, element); + DrawElement(element); + drcerr_count++; + SetThing(ELEMENT_TYPE, element, element, element); + LocateError(&x, &y); + BuildObjectList(&object_count, &object_id_list, &object_type_list); - title = _("Element %s has %i silk lines which are too thin"); - name = (char *)UNKNOWN (NAMEONPCB_NAME (element)); + title = _("Element %s has %i silk lines which are too thin"); + name = (char *) UNKNOWN(NAMEONPCB_NAME(element)); - /* -4 is for the %s and %i place-holders */ - /* +11 is the max printed length for a 32 bit integer */ - /* +1 is for the \0 termination */ - buflen = strlen (title) - 4 + strlen (name) + 11 + 1; - buffer = (char *)malloc (buflen); - snprintf (buffer, buflen, title, name, tmpcnt); + /* -4 is for the %s and %i place-holders */ + /* +11 is the max printed length for a 32 bit integer */ + /* +1 is for the \0 termination */ + buflen = strlen(title) - 4 + strlen(name) + 11 + 1; + buffer = (char *) malloc(buflen); + snprintf(buffer, buflen, title, name, tmpcnt); - violation = pcb_drc_violation_new (buffer, - _("Process specifications dictate a minimum silkscreen\n" - "feature-width that can reliably be reproduced"), - x, y, - 0, /* ANGLE OF ERROR UNKNOWN */ - TRUE, /* MEASUREMENT OF ERROR KNOWN */ - 0, /* MINIMUM OFFENDING WIDTH UNKNOWN */ - PCB->minSlk, - object_count, - object_id_list, - object_type_list); - free (buffer); - append_drc_violation (violation); - pcb_drc_violation_free (violation); - free (object_id_list); - free (object_type_list); - if (!throw_drc_dialog()) - { - IsBad = true; - break; - } - } - } - END_LOOP; - } + violation = pcb_drc_violation_new(buffer, _("Process specifications dictate a minimum silkscreen\n" "feature-width that can reliably be reproduced"), x, y, 0, /* ANGLE OF ERROR UNKNOWN */ + TRUE, /* MEASUREMENT OF ERROR KNOWN */ + 0, /* MINIMUM OFFENDING WIDTH UNKNOWN */ + PCB->minSlk, object_count, object_id_list, object_type_list); + free(buffer); + append_drc_violation(violation); + pcb_drc_violation_free(violation); + free(object_id_list); + free(object_type_list); + if (!throw_drc_dialog()) { + IsBad = true; + break; + } + } + } + END_LOOP; + } - if (IsBad) - { - IncrementUndoSerialNumber (); - } + if (IsBad) { + IncrementUndoSerialNumber(); + } - RestoreStackAndVisibility (); - hid_action ("LayersChanged"); - gui->invalidate_all (); + RestoreStackAndVisibility(); + hid_action("LayersChanged"); + gui->invalidate_all(); - if (nopastecnt > 0) - { - Message (_("Warning: %d pad%s the nopaste flag set.\n"), - nopastecnt, - nopastecnt > 1 ? "s have" : " has"); - } - return IsBad ? -drcerr_count : drcerr_count; + if (nopastecnt > 0) { + Message(_("Warning: %d pad%s the nopaste flag set.\n"), nopastecnt, nopastecnt > 1 ? "s have" : " has"); + } + return IsBad ? -drcerr_count : drcerr_count; } /*---------------------------------------------------------------------------- * Locate the coordinatates of offending item (thing) */ -static void -LocateError (Coord *x, Coord *y) +static void LocateError(Coord * x, Coord * y) { - switch (thing_type) - { - case LINE_TYPE: - { - LineTypePtr line = (LineTypePtr) thing_ptr3; - *x = (line->Point1.X + line->Point2.X) / 2; - *y = (line->Point1.Y + line->Point2.Y) / 2; - break; - } - case ARC_TYPE: - { - ArcTypePtr arc = (ArcTypePtr) thing_ptr3; - *x = arc->X; - *y = arc->Y; - break; - } - case POLYGON_TYPE: - { - PolygonTypePtr polygon = (PolygonTypePtr) thing_ptr3; - *x = - (polygon->Clipped->contours->xmin + - polygon->Clipped->contours->xmax) / 2; - *y = - (polygon->Clipped->contours->ymin + - polygon->Clipped->contours->ymax) / 2; - break; - } - case PIN_TYPE: - case VIA_TYPE: - { - PinTypePtr pin = (PinTypePtr) thing_ptr3; - *x = pin->X; - *y = pin->Y; - break; - } - case PAD_TYPE: - { - PadTypePtr pad = (PadTypePtr) thing_ptr3; - *x = (pad->Point1.X + pad->Point2.X) / 2; - *y = (pad->Point1.Y + pad->Point2.Y) / 2; - break; - } - case ELEMENT_TYPE: - { - ElementTypePtr element = (ElementTypePtr) thing_ptr3; - *x = element->MarkX; - *y = element->MarkY; - break; - } - default: - return; - } + switch (thing_type) { + case LINE_TYPE: + { + LineTypePtr line = (LineTypePtr) thing_ptr3; + *x = (line->Point1.X + line->Point2.X) / 2; + *y = (line->Point1.Y + line->Point2.Y) / 2; + break; + } + case ARC_TYPE: + { + ArcTypePtr arc = (ArcTypePtr) thing_ptr3; + *x = arc->X; + *y = arc->Y; + break; + } + case POLYGON_TYPE: + { + PolygonTypePtr polygon = (PolygonTypePtr) thing_ptr3; + *x = (polygon->Clipped->contours->xmin + polygon->Clipped->contours->xmax) / 2; + *y = (polygon->Clipped->contours->ymin + polygon->Clipped->contours->ymax) / 2; + break; + } + case PIN_TYPE: + case VIA_TYPE: + { + PinTypePtr pin = (PinTypePtr) thing_ptr3; + *x = pin->X; + *y = pin->Y; + break; + } + case PAD_TYPE: + { + PadTypePtr pad = (PadTypePtr) thing_ptr3; + *x = (pad->Point1.X + pad->Point2.X) / 2; + *y = (pad->Point1.Y + pad->Point2.Y) / 2; + break; + } + case ELEMENT_TYPE: + { + ElementTypePtr element = (ElementTypePtr) thing_ptr3; + *x = element->MarkX; + *y = element->MarkY; + break; + } + default: + return; + } } @@ -4427,35 +3897,31 @@ /*---------------------------------------------------------------------------- * Build a list of the of offending items by ID. (Currently just "thing") */ -static void -BuildObjectList (int *object_count, long int **object_id_list, int **object_type_list) +static void BuildObjectList(int *object_count, long int **object_id_list, int **object_type_list) { - *object_count = 0; - *object_id_list = NULL; - *object_type_list = NULL; + *object_count = 0; + *object_id_list = NULL; + *object_type_list = NULL; - switch (thing_type) - { - case LINE_TYPE: - case ARC_TYPE: - case POLYGON_TYPE: - case PIN_TYPE: - case VIA_TYPE: - case PAD_TYPE: - case ELEMENT_TYPE: - case RATLINE_TYPE: - *object_count = 1; - *object_id_list = (long int *)malloc (sizeof (long int)); - *object_type_list = (int *)malloc (sizeof (int)); - **object_id_list = ((AnyObjectType *)thing_ptr3)->ID; - **object_type_list = thing_type; - return; + switch (thing_type) { + case LINE_TYPE: + case ARC_TYPE: + case POLYGON_TYPE: + case PIN_TYPE: + case VIA_TYPE: + case PAD_TYPE: + case ELEMENT_TYPE: + case RATLINE_TYPE: + *object_count = 1; + *object_id_list = (long int *) malloc(sizeof(long int)); + *object_type_list = (int *) malloc(sizeof(int)); + **object_id_list = ((AnyObjectType *) thing_ptr3)->ID; + **object_type_list = thing_type; + return; - default: - fprintf (stderr, - _("Internal error in BuildObjectList: unknown object type %i\n"), - thing_type); - } + default: + fprintf(stderr, _("Internal error in BuildObjectList: unknown object type %i\n"), thing_type); + } } @@ -4462,35 +3928,29 @@ /*---------------------------------------------------------------------------- * center the display to show the offending item (thing) */ -static void -GotoError (void) +static void GotoError(void) { - Coord X, Y; + Coord X, Y; - LocateError (&X, &Y); + LocateError(&X, &Y); - switch (thing_type) - { - case LINE_TYPE: - case ARC_TYPE: - case POLYGON_TYPE: - ChangeGroupVisibility (GetLayerNumber - (PCB->Data, (LayerTypePtr) thing_ptr1), true, - true); - } - CenterDisplay (X, Y); + switch (thing_type) { + case LINE_TYPE: + case ARC_TYPE: + case POLYGON_TYPE: + ChangeGroupVisibility(GetLayerNumber(PCB->Data, (LayerTypePtr) thing_ptr1), true, true); + } + CenterDisplay(X, Y); } -void -InitConnectionLookup (void) +void InitConnectionLookup(void) { - InitComponentLookup (); - InitLayoutLookup (); + InitComponentLookup(); + InitLayoutLookup(); } -void -FreeConnectionLookupMemory (void) +void FreeConnectionLookupMemory(void) { - FreeComponentLookupMemory (); - FreeLayoutLookupMemory (); + FreeComponentLookupMemory(); + FreeLayoutLookupMemory(); } Index: trunk/src/find.h =================================================================== --- trunk/src/find.h (revision 1021) +++ trunk/src/find.h (revision 1022) @@ -31,18 +31,19 @@ #ifndef PCB_FIND_H #define PCB_FIND_H -#include /* needed to define 'FILE *' */ +#include /* needed to define 'FILE *' */ #include "global.h" typedef enum { - FCT_COPPER = 1, /* copper connection */ - FCT_INTERNAL = 2, /* element-internal connection */ - FCT_RAT = 4, /* connected by a rat line */ - FCT_ELEMENT = 8, /* pin/pad is part of an element whose pins/pads are being listed */ - FCT_START = 16, /* starting object of a query */ + FCT_COPPER = 1, /* copper connection */ + FCT_INTERNAL = 2, /* element-internal connection */ + FCT_RAT = 4, /* connected by a rat line */ + FCT_ELEMENT = 8, /* pin/pad is part of an element whose pins/pads are being listed */ + FCT_START = 16, /* starting object of a query */ } found_conn_type_t; -typedef void (*find_callback_t)(int current_type, void *current_ptr, int from_type, void *from_ptr, found_conn_type_t conn_type); +typedef void (*find_callback_t) (int current_type, void *current_ptr, int from_type, void *from_ptr, + found_conn_type_t conn_type); /* if not NULL, this function is called whenever something is found @@ -61,32 +62,32 @@ #define SILK_TYPE \ (LINE_TYPE | ARC_TYPE | POLYGON_TYPE) -bool LineLineIntersect (LineTypePtr, LineTypePtr); -bool LineArcIntersect (LineTypePtr, ArcTypePtr); -bool PinLineIntersect (PinTypePtr, LineTypePtr); -bool LinePadIntersect (LineTypePtr, PadTypePtr); -bool ArcPadIntersect (ArcTypePtr, PadTypePtr); -bool IsPolygonInPolygon (PolygonTypePtr, PolygonTypePtr); -void LookupElementConnections (ElementTypePtr, FILE *); -void LookupConnectionsToAllElements (FILE *); -void LookupConnection (Coord, Coord, bool, Coord, int); -void LookupUnusedPins (FILE *); -bool ResetFoundLinesAndPolygons (bool); -bool ResetFoundPinsViasAndPads (bool); -bool ResetConnections (bool); -void InitConnectionLookup (void); -void InitComponentLookup (void); -void InitLayoutLookup (void); -void FreeConnectionLookupMemory (void); -void FreeComponentLookupMemory (void); -void FreeLayoutLookupMemory (void); -void RatFindHook (int, void *, void *, void *, bool, bool); -void SaveFindFlag (int); -void RestoreFindFlag (void); -int DRCAll (void); -bool lineClear (LineTypePtr, Cardinal); -bool IsLineInPolygon (LineTypePtr, PolygonTypePtr); -bool IsArcInPolygon (ArcTypePtr, PolygonTypePtr); -bool IsPadInPolygon (PadTypePtr, PolygonTypePtr); +bool LineLineIntersect(LineTypePtr, LineTypePtr); +bool LineArcIntersect(LineTypePtr, ArcTypePtr); +bool PinLineIntersect(PinTypePtr, LineTypePtr); +bool LinePadIntersect(LineTypePtr, PadTypePtr); +bool ArcPadIntersect(ArcTypePtr, PadTypePtr); +bool IsPolygonInPolygon(PolygonTypePtr, PolygonTypePtr); +void LookupElementConnections(ElementTypePtr, FILE *); +void LookupConnectionsToAllElements(FILE *); +void LookupConnection(Coord, Coord, bool, Coord, int); +void LookupUnusedPins(FILE *); +bool ResetFoundLinesAndPolygons(bool); +bool ResetFoundPinsViasAndPads(bool); +bool ResetConnections(bool); +void InitConnectionLookup(void); +void InitComponentLookup(void); +void InitLayoutLookup(void); +void FreeConnectionLookupMemory(void); +void FreeComponentLookupMemory(void); +void FreeLayoutLookupMemory(void); +void RatFindHook(int, void *, void *, void *, bool, bool); +void SaveFindFlag(int); +void RestoreFindFlag(void); +int DRCAll(void); +bool lineClear(LineTypePtr, Cardinal); +bool IsLineInPolygon(LineTypePtr, PolygonTypePtr); +bool IsArcInPolygon(ArcTypePtr, PolygonTypePtr); +bool IsPadInPolygon(PadTypePtr, PolygonTypePtr); #endif Index: trunk/src/flags.c =================================================================== --- trunk/src/flags.c (revision 1021) +++ trunk/src/flags.c (revision 1022) @@ -40,144 +40,129 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); -static int -FlagCurrentStyle (int dummy) +static int FlagCurrentStyle(int dummy) { - STYLE_LOOP (PCB); - { - if (style->Thick == Settings.LineThickness && - style->Diameter == Settings.ViaThickness && - style->Hole == Settings.ViaDrillingHole && - style->Keepaway == Settings.Keepaway) - return n + 1; - } - END_LOOP; - return 0; + STYLE_LOOP(PCB); + { + if (style->Thick == Settings.LineThickness && + style->Diameter == Settings.ViaThickness && + style->Hole == Settings.ViaDrillingHole && style->Keepaway == Settings.Keepaway) + return n + 1; + } + END_LOOP; + return 0; } -static int -FlagGrid (int dummy) +static int FlagGrid(int dummy) { - return PCB->Grid > 1; + return PCB->Grid > 1; } -static int -FlagGridSize (int dummy) +static int FlagGridSize(int dummy) { - return PCB->Grid; + return PCB->Grid; } -static int -FlagUnitsMm (int dummy) +static int FlagUnitsMm(int dummy) { - static const Unit *u = NULL; - if (u == NULL) - u = get_unit_struct ("mm"); - return (Settings.grid_unit == u); + static const Unit *u = NULL; + if (u == NULL) + u = get_unit_struct("mm"); + return (Settings.grid_unit == u); } -static int -FlagUnitsMil (int dummy) +static int FlagUnitsMil(int dummy) { - static const Unit *u = NULL; - if (u == NULL) - u = get_unit_struct ("mil"); - return (Settings.grid_unit == u); + static const Unit *u = NULL; + if (u == NULL) + u = get_unit_struct("mil"); + return (Settings.grid_unit == u); } -static int -FlagBuffer (int dummy) +static int FlagBuffer(int dummy) { - return (int) (Settings.BufferNumber + 1); + return (int) (Settings.BufferNumber + 1); } -static int -FlagElementName (int dummy) +static int FlagElementName(int dummy) { - if (TEST_FLAG (NAMEONPCBFLAG, PCB)) - return 2; - if (TEST_FLAG (DESCRIPTIONFLAG, PCB)) - return 1; - return 3; + if (TEST_FLAG(NAMEONPCBFLAG, PCB)) + return 2; + if (TEST_FLAG(DESCRIPTIONFLAG, PCB)) + return 1; + return 3; } -static int -FlagTESTFLAG (int bit) +static int FlagTESTFLAG(int bit) { - return TEST_FLAG (bit, PCB) ? 1 : 0; + return TEST_FLAG(bit, PCB) ? 1 : 0; } -static int -FlagSETTINGS (int ofs) +static int FlagSETTINGS(int ofs) { - return *(bool *) ((char *) (&Settings) + ofs); + return *(bool *) ((char *) (&Settings) + ofs); } -static int -FlagMode (int x) +static int FlagMode(int x) { - if (x == -1) - return Settings.Mode; - return Settings.Mode == x; + if (x == -1) + return Settings.Mode; + return Settings.Mode == x; } -static int -FlagHaveRegex (int x) +static int FlagHaveRegex(int x) { #if defined(HAVE_REGCOMP) || defined(HAVE_RE_COMP) - return 1; + return 1; #else - return 0; + return 0; #endif } enum { - FL_SILK = -6, - FL_PINS, - FL_RATS, - FL_VIAS, - FL_BACK, - FL_MASK + FL_SILK = -6, + FL_PINS, + FL_RATS, + FL_VIAS, + FL_BACK, + FL_MASK }; -static int -FlagLayerShown (int n) +static int FlagLayerShown(int n) { - switch (n) - { - case FL_SILK: - return PCB->ElementOn; - case FL_PINS: - return PCB->PinOn; - case FL_RATS: - return PCB->RatOn; - case FL_VIAS: - return PCB->ViaOn; - case FL_BACK: - return PCB->InvisibleObjectsOn; - case FL_MASK: - return TEST_FLAG (SHOWMASKFLAG, PCB); - default: - if (n >= 0 && n < max_copper_layer) - return PCB->Data->Layer[n].On; - } - return 0; + switch (n) { + case FL_SILK: + return PCB->ElementOn; + case FL_PINS: + return PCB->PinOn; + case FL_RATS: + return PCB->RatOn; + case FL_VIAS: + return PCB->ViaOn; + case FL_BACK: + return PCB->InvisibleObjectsOn; + case FL_MASK: + return TEST_FLAG(SHOWMASKFLAG, PCB); + default: + if (n >= 0 && n < max_copper_layer) + return PCB->Data->Layer[n].On; + } + return 0; } -static int -FlagLayerActive (int n) +static int FlagLayerActive(int n) { - int current_layer; - if (PCB->RatDraw) - current_layer = FL_RATS; - else if (PCB->SilkActive) - current_layer = FL_SILK; - else - return 0; + int current_layer; + if (PCB->RatDraw) + current_layer = FL_RATS; + else if (PCB->SilkActive) + current_layer = FL_SILK; + else + return 0; - return current_layer == n; + return current_layer == n; } /* The cast to (int) is ONLY valid because we know we are @@ -188,92 +173,166 @@ #define OffsetOf(a,b) (int)(size_t)(&(((a *)0)->b)) HID_Flag flags_flag_list[] = { - {"style", FlagCurrentStyle, 0}, - {"grid", FlagGrid, 0}, - {"gridsize", FlagGridSize, 0}, - {"elementname", FlagElementName, 0}, - {"have_regex", FlagHaveRegex, 0}, + {"style", FlagCurrentStyle, 0} + , + {"grid", FlagGrid, 0} + , + {"gridsize", FlagGridSize, 0} + , + {"elementname", FlagElementName, 0} + , + {"have_regex", FlagHaveRegex, 0} + , - {"silk_shown", FlagLayerShown, FL_SILK}, - {"pins_shown", FlagLayerShown, FL_PINS}, - {"rats_shown", FlagLayerShown, FL_RATS}, - {"vias_shown", FlagLayerShown, FL_VIAS}, - {"back_shown", FlagLayerShown, FL_BACK}, - {"mask_shown", FlagLayerShown, FL_MASK}, - {"silk_active", FlagLayerActive, FL_SILK}, - {"rats_active", FlagLayerActive, FL_RATS}, + {"silk_shown", FlagLayerShown, FL_SILK} + , + {"pins_shown", FlagLayerShown, FL_PINS} + , + {"rats_shown", FlagLayerShown, FL_RATS} + , + {"vias_shown", FlagLayerShown, FL_VIAS} + , + {"back_shown", FlagLayerShown, FL_BACK} + , + {"mask_shown", FlagLayerShown, FL_MASK} + , + {"silk_active", FlagLayerActive, FL_SILK} + , + {"rats_active", FlagLayerActive, FL_RATS} + , - {"mode", FlagMode, -1}, - {"nomode", FlagMode, NO_MODE}, - {"arcmode", FlagMode, ARC_MODE}, - {"arrowmode", FlagMode, ARROW_MODE}, - {"copymode", FlagMode, COPY_MODE}, - {"insertpointmode", FlagMode, INSERTPOINT_MODE}, - {"linemode", FlagMode, LINE_MODE}, - {"lockmode", FlagMode, LOCK_MODE}, - {"movemode", FlagMode, MOVE_MODE}, - {"pastebuffermode", FlagMode, PASTEBUFFER_MODE}, - {"polygonmode", FlagMode, POLYGON_MODE}, - {"polygonholemode", FlagMode, POLYGONHOLE_MODE}, - {"rectanglemode", FlagMode, RECTANGLE_MODE}, - {"removemode", FlagMode, REMOVE_MODE}, - {"rotatemode", FlagMode, ROTATE_MODE}, - {"rubberbandmovemode", FlagMode, RUBBERBANDMOVE_MODE}, - {"textmode", FlagMode, TEXT_MODE}, - {"thermalmode", FlagMode, THERMAL_MODE}, - {"viamode", FlagMode, VIA_MODE}, + {"mode", FlagMode, -1} + , + {"nomode", FlagMode, NO_MODE} + , + {"arcmode", FlagMode, ARC_MODE} + , + {"arrowmode", FlagMode, ARROW_MODE} + , + {"copymode", FlagMode, COPY_MODE} + , + {"insertpointmode", FlagMode, INSERTPOINT_MODE} + , + {"linemode", FlagMode, LINE_MODE} + , + {"lockmode", FlagMode, LOCK_MODE} + , + {"movemode", FlagMode, MOVE_MODE} + , + {"pastebuffermode", FlagMode, PASTEBUFFER_MODE} + , + {"polygonmode", FlagMode, POLYGON_MODE} + , + {"polygonholemode", FlagMode, POLYGONHOLE_MODE} + , + {"rectanglemode", FlagMode, RECTANGLE_MODE} + , + {"removemode", FlagMode, REMOVE_MODE} + , + {"rotatemode", FlagMode, ROTATE_MODE} + , + {"rubberbandmovemode", FlagMode, RUBBERBANDMOVE_MODE} + , + {"textmode", FlagMode, TEXT_MODE} + , + {"thermalmode", FlagMode, THERMAL_MODE} + , + {"viamode", FlagMode, VIA_MODE} + , - {"shownumber", FlagTESTFLAG, SHOWNUMBERFLAG}, - {"localref", FlagTESTFLAG, LOCALREFFLAG}, - {"checkplanes", FlagTESTFLAG, CHECKPLANESFLAG}, - {"showdrc", FlagTESTFLAG, SHOWDRCFLAG}, - {"rubberband", FlagTESTFLAG, RUBBERBANDFLAG}, - {"description", FlagTESTFLAG, DESCRIPTIONFLAG}, - {"nameonpcb", FlagTESTFLAG, NAMEONPCBFLAG}, - {"autodrc", FlagTESTFLAG, AUTODRCFLAG}, - {"alldirection", FlagTESTFLAG, ALLDIRECTIONFLAG}, - {"swapstartdir", FlagTESTFLAG, SWAPSTARTDIRFLAG}, - {"uniquename", FlagTESTFLAG, UNIQUENAMEFLAG}, - {"clearnew", FlagTESTFLAG, CLEARNEWFLAG}, - {"snappin", FlagTESTFLAG, SNAPPINFLAG}, - {"showmask", FlagTESTFLAG, SHOWMASKFLAG}, - {"thindraw", FlagTESTFLAG, THINDRAWFLAG}, - {"orthomove", FlagTESTFLAG, ORTHOMOVEFLAG}, - {"liveroute", FlagTESTFLAG, LIVEROUTEFLAG}, - {"thindrawpoly", FlagTESTFLAG, THINDRAWPOLYFLAG}, - {"locknames", FlagTESTFLAG, LOCKNAMESFLAG}, - {"onlynames", FlagTESTFLAG, ONLYNAMESFLAG}, - {"newfullpoly", FlagTESTFLAG, NEWFULLPOLYFLAG}, - {"hidenames", FlagTESTFLAG, HIDENAMESFLAG}, - {"enablemincut", FlagTESTFLAG, ENABLEMINCUTFLAG}, - {"snapoffgridline", FlagTESTFLAG, SNAPOFFGRIDLINEFLAG}, - {"highlightonpoint", FlagTESTFLAG, HIGHLIGHTONPOINTFLAG}, + {"shownumber", FlagTESTFLAG, SHOWNUMBERFLAG} + , + {"localref", FlagTESTFLAG, LOCALREFFLAG} + , + {"checkplanes", FlagTESTFLAG, CHECKPLANESFLAG} + , + {"showdrc", FlagTESTFLAG, SHOWDRCFLAG} + , + {"rubberband", FlagTESTFLAG, RUBBERBANDFLAG} + , + {"description", FlagTESTFLAG, DESCRIPTIONFLAG} + , + {"nameonpcb", FlagTESTFLAG, NAMEONPCBFLAG} + , + {"autodrc", FlagTESTFLAG, AUTODRCFLAG} + , + {"alldirection", FlagTESTFLAG, ALLDIRECTIONFLAG} + , + {"swapstartdir", FlagTESTFLAG, SWAPSTARTDIRFLAG} + , + {"uniquename", FlagTESTFLAG, UNIQUENAMEFLAG} + , + {"clearnew", FlagTESTFLAG, CLEARNEWFLAG} + , + {"snappin", FlagTESTFLAG, SNAPPINFLAG} + , + {"showmask", FlagTESTFLAG, SHOWMASKFLAG} + , + {"thindraw", FlagTESTFLAG, THINDRAWFLAG} + , + {"orthomove", FlagTESTFLAG, ORTHOMOVEFLAG} + , + {"liveroute", FlagTESTFLAG, LIVEROUTEFLAG} + , + {"thindrawpoly", FlagTESTFLAG, THINDRAWPOLYFLAG} + , + {"locknames", FlagTESTFLAG, LOCKNAMESFLAG} + , + {"onlynames", FlagTESTFLAG, ONLYNAMESFLAG} + , + {"newfullpoly", FlagTESTFLAG, NEWFULLPOLYFLAG} + , + {"hidenames", FlagTESTFLAG, HIDENAMESFLAG} + , + {"enablemincut", FlagTESTFLAG, ENABLEMINCUTFLAG} + , + {"snapoffgridline", FlagTESTFLAG, SNAPOFFGRIDLINEFLAG} + , + {"highlightonpoint", FlagTESTFLAG, HIGHLIGHTONPOINTFLAG} + , - {"fullpoly", FlagSETTINGS, OffsetOf (SettingType, FullPoly)}, - {"grid_units_mm", FlagUnitsMm, -1}, - {"grid_units_mil", FlagUnitsMil, -1}, - {"clearline", FlagSETTINGS, OffsetOf (SettingType, ClearLine)}, - {"uniquenames", FlagSETTINGS, OffsetOf (SettingType, UniqueNames)}, - {"showsolderside", FlagSETTINGS, OffsetOf (SettingType, ShowSolderSide)}, - {"savelastcommand", FlagSETTINGS, OffsetOf (SettingType, SaveLastCommand)}, - {"saveintmp", FlagSETTINGS, OffsetOf (SettingType, SaveInTMP)}, - {"drawgrid", FlagSETTINGS, OffsetOf (SettingType, DrawGrid)}, - {"ratwarn", FlagSETTINGS, OffsetOf (SettingType, RatWarn)}, - {"stipplepolygons", FlagSETTINGS, OffsetOf (SettingType, StipplePolygons)}, - {"alldirectionlines", FlagSETTINGS, - OffsetOf (SettingType, AllDirectionLines)}, - {"rubberbandmode", FlagSETTINGS, OffsetOf (SettingType, RubberBandMode)}, - {"swapstartdirection", FlagSETTINGS, - OffsetOf (SettingType, SwapStartDirection)}, - {"showdrcmode", FlagSETTINGS, OffsetOf (SettingType, ShowDRC)}, - {"resetafterelement", FlagSETTINGS, - OffsetOf (SettingType, ResetAfterElement)}, - {"ringbellwhenfinished", FlagSETTINGS, - OffsetOf (SettingType, RingBellWhenFinished)}, + {"fullpoly", FlagSETTINGS, OffsetOf(SettingType, FullPoly)} + , + {"grid_units_mm", FlagUnitsMm, -1} + , + {"grid_units_mil", FlagUnitsMil, -1} + , + {"clearline", FlagSETTINGS, OffsetOf(SettingType, ClearLine)} + , + {"uniquenames", FlagSETTINGS, OffsetOf(SettingType, UniqueNames)} + , + {"showsolderside", FlagSETTINGS, OffsetOf(SettingType, ShowSolderSide)} + , + {"savelastcommand", FlagSETTINGS, OffsetOf(SettingType, SaveLastCommand)} + , + {"saveintmp", FlagSETTINGS, OffsetOf(SettingType, SaveInTMP)} + , + {"drawgrid", FlagSETTINGS, OffsetOf(SettingType, DrawGrid)} + , + {"ratwarn", FlagSETTINGS, OffsetOf(SettingType, RatWarn)} + , + {"stipplepolygons", FlagSETTINGS, OffsetOf(SettingType, StipplePolygons)} + , + {"alldirectionlines", FlagSETTINGS, + OffsetOf(SettingType, AllDirectionLines)} + , + {"rubberbandmode", FlagSETTINGS, OffsetOf(SettingType, RubberBandMode)} + , + {"swapstartdirection", FlagSETTINGS, + OffsetOf(SettingType, SwapStartDirection)} + , + {"showdrcmode", FlagSETTINGS, OffsetOf(SettingType, ShowDRC)} + , + {"resetafterelement", FlagSETTINGS, + OffsetOf(SettingType, ResetAfterElement)} + , + {"ringbellwhenfinished", FlagSETTINGS, + OffsetOf(SettingType, RingBellWhenFinished)} + , - {"buffer", FlagBuffer, 0}, + {"buffer", FlagBuffer, 0} + , }; -REGISTER_FLAGS (flags_flag_list) - +REGISTER_FLAGS(flags_flag_list) Index: trunk/src/fontmode.c =================================================================== --- trunk/src/fontmode.c (revision 1021) +++ trunk/src/fontmode.c (revision 1022) @@ -50,7 +50,7 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); /* FIXME - we currently hardcode the grid and PCB size. What we should do in the future is scan the font for its extents, and size @@ -66,105 +66,90 @@ static const char fontedit_syntax[] = "FontEdit()"; -static const char fontedit_help[] = - "Convert the current font to a PCB for editing."; +static const char fontedit_help[] = "Convert the current font to a PCB for editing."; /* %start-doc actions FontEdit %end-doc */ -static int -FontEdit (int argc, char **argv, Coord Ux, Coord Uy) +static int FontEdit(int argc, char **argv, Coord Ux, Coord Uy) { - FontType *font; - SymbolType *symbol; - LayerTypePtr lfont, lorig, lwidth, lgrid; - int s, l; + FontType *font; + SymbolType *symbol; + LayerTypePtr lfont, lorig, lwidth, lgrid; + int s, l; - if (hid_actionl ("New", "Font", 0)) - return 1; + if (hid_actionl("New", "Font", 0)) + return 1; - Settings.grid_unit = get_unit_struct("mil"); - Settings.Bloat = PCB->Bloat = 1; - Settings.Shrink = PCB->Shrink = 1; - Settings.minWid = PCB->minWid = 1; - Settings.minSlk = PCB->minSlk = 1; + Settings.grid_unit = get_unit_struct("mil"); + Settings.Bloat = PCB->Bloat = 1; + Settings.Shrink = PCB->Shrink = 1; + Settings.minWid = PCB->minWid = 1; + Settings.minSlk = PCB->minSlk = 1; - MoveLayerToGroup (max_copper_layer + COMPONENT_LAYER, 0); - MoveLayerToGroup (max_copper_layer + SOLDER_LAYER, 1); + MoveLayerToGroup(max_copper_layer + COMPONENT_LAYER, 0); + MoveLayerToGroup(max_copper_layer + SOLDER_LAYER, 1); - while (PCB->Data->LayerN > 4) - MoveLayer (4, -1); - for (l = 0; l < 4; l++) - { - MoveLayerToGroup (l, l); - } - PCB->MaxWidth = CELL_SIZE * 18; - PCB->MaxHeight = CELL_SIZE * ((MAX_FONTPOSITION + 15) / 16 + 2); - PCB->Grid = MIL_TO_COORD (5); - PCB->Data->Layer[0].Name = strdup ("Font"); - PCB->Data->Layer[1].Name = strdup ("OrigFont"); - PCB->Data->Layer[2].Name = strdup ("Width"); - PCB->Data->Layer[3].Name = strdup ("Grid"); - hid_action ("PCBChanged"); - hid_action ("LayersChanged"); + while (PCB->Data->LayerN > 4) + MoveLayer(4, -1); + for (l = 0; l < 4; l++) { + MoveLayerToGroup(l, l); + } + PCB->MaxWidth = CELL_SIZE * 18; + PCB->MaxHeight = CELL_SIZE * ((MAX_FONTPOSITION + 15) / 16 + 2); + PCB->Grid = MIL_TO_COORD(5); + PCB->Data->Layer[0].Name = strdup("Font"); + PCB->Data->Layer[1].Name = strdup("OrigFont"); + PCB->Data->Layer[2].Name = strdup("Width"); + PCB->Data->Layer[3].Name = strdup("Grid"); + hid_action("PCBChanged"); + hid_action("LayersChanged"); - lfont = PCB->Data->Layer + 0; - lorig = PCB->Data->Layer + 1; - lwidth = PCB->Data->Layer + 2; - lgrid = PCB->Data->Layer + 3; + lfont = PCB->Data->Layer + 0; + lorig = PCB->Data->Layer + 1; + lwidth = PCB->Data->Layer + 2; + lgrid = PCB->Data->Layer + 3; - font = &PCB->Font; - for (s = 0; s <= MAX_FONTPOSITION; s++) - { - Coord ox = (s % 16 + 1) * CELL_SIZE; - Coord oy = (s / 16 + 1) * CELL_SIZE; - Coord w, miny, maxy, maxx = 0; + font = &PCB->Font; + for (s = 0; s <= MAX_FONTPOSITION; s++) { + Coord ox = (s % 16 + 1) * CELL_SIZE; + Coord oy = (s / 16 + 1) * CELL_SIZE; + Coord w, miny, maxy, maxx = 0; - symbol = &font->Symbol[s]; + symbol = &font->Symbol[s]; - miny = MIL_TO_COORD (5); - maxy = font->MaxHeight; + miny = MIL_TO_COORD(5); + maxy = font->MaxHeight; - for (l = 0; l < symbol->LineN; l++) - { - CreateDrawnLineOnLayer (lfont, - symbol->Line[l].Point1.X + ox, - symbol->Line[l].Point1.Y + oy, - symbol->Line[l].Point2.X + ox, - symbol->Line[l].Point2.Y + oy, - symbol->Line[l].Thickness, - symbol->Line[l].Thickness, NoFlags ()); - CreateDrawnLineOnLayer (lorig, symbol->Line[l].Point1.X + ox, - symbol->Line[l].Point1.Y + oy, - symbol->Line[l].Point2.X + ox, - symbol->Line[l].Point2.Y + oy, - symbol->Line[l].Thickness, - symbol->Line[l].Thickness, NoFlags ()); - if (maxx < symbol->Line[l].Point1.X) - maxx = symbol->Line[l].Point1.X; - if (maxx < symbol->Line[l].Point2.X) - maxx = symbol->Line[l].Point2.X; + for (l = 0; l < symbol->LineN; l++) { + CreateDrawnLineOnLayer(lfont, + symbol->Line[l].Point1.X + ox, + symbol->Line[l].Point1.Y + oy, + symbol->Line[l].Point2.X + ox, + symbol->Line[l].Point2.Y + oy, symbol->Line[l].Thickness, symbol->Line[l].Thickness, NoFlags()); + CreateDrawnLineOnLayer(lorig, symbol->Line[l].Point1.X + ox, + symbol->Line[l].Point1.Y + oy, + symbol->Line[l].Point2.X + ox, + symbol->Line[l].Point2.Y + oy, symbol->Line[l].Thickness, symbol->Line[l].Thickness, NoFlags()); + if (maxx < symbol->Line[l].Point1.X) + maxx = symbol->Line[l].Point1.X; + if (maxx < symbol->Line[l].Point2.X) + maxx = symbol->Line[l].Point2.X; + } + w = maxx + symbol->Delta + ox; + CreateDrawnLineOnLayer(lwidth, w, miny + oy, w, maxy + oy, MIL_TO_COORD(1), MIL_TO_COORD(1), NoFlags()); } - w = maxx + symbol->Delta + ox; - CreateDrawnLineOnLayer (lwidth, - w, miny + oy, - w, maxy + oy, MIL_TO_COORD (1), MIL_TO_COORD (1), NoFlags ()); - } - for (l = 0; l < 16; l++) - { - int x = (l + 1) * CELL_SIZE; - CreateDrawnLineOnLayer (lgrid, x, 0, x, PCB->MaxHeight, MIL_TO_COORD (1), - MIL_TO_COORD (1), NoFlags ()); - } - for (l = 0; l <= MAX_FONTPOSITION / 16 + 1; l++) - { - int y = (l + 1) * CELL_SIZE; - CreateDrawnLineOnLayer (lgrid, 0, y, PCB->MaxWidth, y, MIL_TO_COORD (1), - MIL_TO_COORD (1), NoFlags ()); - } - return 0; + for (l = 0; l < 16; l++) { + int x = (l + 1) * CELL_SIZE; + CreateDrawnLineOnLayer(lgrid, x, 0, x, PCB->MaxHeight, MIL_TO_COORD(1), MIL_TO_COORD(1), NoFlags()); + } + for (l = 0; l <= MAX_FONTPOSITION / 16 + 1; l++) { + int y = (l + 1) * CELL_SIZE; + CreateDrawnLineOnLayer(lgrid, 0, y, PCB->MaxWidth, y, MIL_TO_COORD(1), MIL_TO_COORD(1), NoFlags()); + } + return 0; } static const char fontsave_syntax[] = "FontSave()"; @@ -175,80 +160,77 @@ %end-doc */ -static int -FontSave (int argc, char **argv, Coord Ux, Coord Uy) +static int FontSave(int argc, char **argv, Coord Ux, Coord Uy) { - FontTypePtr font; - SymbolTypePtr symbol; - int i; - GList *ii; - LayerTypePtr lfont, lwidth; + FontTypePtr font; + SymbolTypePtr symbol; + int i; + GList *ii; + LayerTypePtr lfont, lwidth; - font = &PCB->Font; - lfont = PCB->Data->Layer + 0; - lwidth = PCB->Data->Layer + 2; + font = &PCB->Font; + lfont = PCB->Data->Layer + 0; + lwidth = PCB->Data->Layer + 2; - for (i = 0; i <= MAX_FONTPOSITION; i++) - { - font->Symbol[i].LineN = 0; - font->Symbol[i].Valid = 0; - font->Symbol[i].Width = 0; - } + for (i = 0; i <= MAX_FONTPOSITION; i++) { + font->Symbol[i].LineN = 0; + font->Symbol[i].Valid = 0; + font->Symbol[i].Width = 0; + } - for (ii = lfont->Line; ii != NULL; ii = g_list_next (ii)) - { - LineType *l = ii->data; - int x1 = l->Point1.X; - int y1 = l->Point1.Y; - int x2 = l->Point2.X; - int y2 = l->Point2.Y; - int ox, oy, s; + for (ii = lfont->Line; ii != NULL; ii = g_list_next(ii)) { + LineType *l = ii->data; + int x1 = l->Point1.X; + int y1 = l->Point1.Y; + int x2 = l->Point2.X; + int y2 = l->Point2.Y; + int ox, oy, s; - s = XYtoSym (x1, y1); - ox = (s % 16 + 1) * CELL_SIZE; - oy = (s / 16 + 1) * CELL_SIZE; - symbol = &PCB->Font.Symbol[s]; + s = XYtoSym(x1, y1); + ox = (s % 16 + 1) * CELL_SIZE; + oy = (s / 16 + 1) * CELL_SIZE; + symbol = &PCB->Font.Symbol[s]; - x1 -= ox; - y1 -= oy; - x2 -= ox; - y2 -= oy; + x1 -= ox; + y1 -= oy; + x2 -= ox; + y2 -= oy; - if (symbol->Width < x1) - symbol->Width = x1; - if (symbol->Width < x2) - symbol->Width = x2; - symbol->Valid = 1; + if (symbol->Width < x1) + symbol->Width = x1; + if (symbol->Width < x2) + symbol->Width = x2; + symbol->Valid = 1; - CreateNewLineInSymbol (symbol, x1, y1, x2, y2, l->Thickness); - } + CreateNewLineInSymbol(symbol, x1, y1, x2, y2, l->Thickness); + } - for (ii = lwidth->Line; ii != NULL; ii = g_list_next (ii)) - { - LineType *l = ii->data; - Coord x1 = l->Point1.X; - Coord y1 = l->Point1.Y; - Coord ox, s; + for (ii = lwidth->Line; ii != NULL; ii = g_list_next(ii)) { + LineType *l = ii->data; + Coord x1 = l->Point1.X; + Coord y1 = l->Point1.Y; + Coord ox, s; - s = XYtoSym (x1, y1); - ox = (s % 16 + 1) * CELL_SIZE; - symbol = &PCB->Font.Symbol[s]; + s = XYtoSym(x1, y1); + ox = (s % 16 + 1) * CELL_SIZE; + symbol = &PCB->Font.Symbol[s]; - x1 -= ox; + x1 -= ox; - symbol->Delta = x1 - symbol->Width; - } + symbol->Delta = x1 - symbol->Width; + } - SetFontInfo (font); - - return 0; + SetFontInfo(font); + + return 0; } HID_Action fontmode_action_list[] = { - {"FontEdit", 0, FontEdit, - fontedit_help, fontedit_syntax}, - {"FontSave", 0, FontSave, - fontsave_help, fontsave_syntax} + {"FontEdit", 0, FontEdit, + fontedit_help, fontedit_syntax} + , + {"FontSave", 0, FontSave, + fontsave_help, fontsave_syntax} }; -REGISTER_ACTIONS (fontmode_action_list) +REGISTER_ACTIONS(fontmode_action_list) Index: trunk/src/free_atexit.c =================================================================== --- trunk/src/free_atexit.c (revision 1021) +++ trunk/src/free_atexit.c (revision 1022) @@ -36,65 +36,65 @@ not multiple of it, the alignment will be messed up, potentially causing slower memory access. */ typedef union { - leaky_idx_t idx; - void *ptr; + leaky_idx_t idx; + void *ptr; } leaky_admin_t; -static void **free_list = NULL; -static leaky_idx_t free_size = 0; +static void **free_list = NULL; +static leaky_idx_t free_size = 0; -void *leaky_malloc (size_t size) +void *leaky_malloc(size_t size) { - void *new_memory = malloc(size + sizeof(leaky_admin_t)); + void *new_memory = malloc(size + sizeof(leaky_admin_t)); - free_list = (void **)realloc (free_list, (free_size + 1) * sizeof(void *)); - free_list[free_size] = new_memory; - *(leaky_idx_t *)new_memory = free_size; + free_list = (void **) realloc(free_list, (free_size + 1) * sizeof(void *)); + free_list[free_size] = new_memory; + *(leaky_idx_t *) new_memory = free_size; - free_size++; - return new_memory + sizeof(leaky_admin_t); + free_size++; + return new_memory + sizeof(leaky_admin_t); } -void *leaky_calloc (size_t nmemb, size_t size) +void *leaky_calloc(size_t nmemb, size_t size) { - size_t size_ = size * nmemb; - void *new_memory = leaky_malloc (size_); + size_t size_ = size * nmemb; + void *new_memory = leaky_malloc(size_); - memset (new_memory, 0, size_); - return new_memory; + memset(new_memory, 0, size_); + return new_memory; } -void *leaky_realloc (void* old_memory, size_t size) +void *leaky_realloc(void *old_memory, size_t size) { - void *new_memory; - leaky_idx_t i; + void *new_memory; + leaky_idx_t i; - if (old_memory == NULL) - return leaky_malloc (size); + if (old_memory == NULL) + return leaky_malloc(size); - old_memory -= sizeof(leaky_admin_t); + old_memory -= sizeof(leaky_admin_t); - i = *(leaky_idx_t *)old_memory; + i = *(leaky_idx_t *) old_memory; - new_memory = realloc (old_memory, size + sizeof(leaky_admin_t)); - free_list[i] = new_memory; + new_memory = realloc(old_memory, size + sizeof(leaky_admin_t)); + free_list[i] = new_memory; - return new_memory + sizeof(leaky_admin_t); + return new_memory + sizeof(leaky_admin_t); } -void leaky_uninit (void) +void leaky_uninit(void) { - int i; + int i; - for (i = 0; i < free_size; i++) - free (free_list[i]); + for (i = 0; i < free_size; i++) + free(free_list[i]); - free (free_list); - free_size = 0; + free(free_list); + free_size = 0; } -void leaky_init (void) +void leaky_init(void) { - atexit(leaky_uninit); + atexit(leaky_uninit); } Index: trunk/src/free_atexit.h =================================================================== --- trunk/src/free_atexit.h (revision 1021) +++ trunk/src/free_atexit.h (revision 1022) @@ -16,19 +16,19 @@ #else /* set up atexit() hook - can be avoided if leaky_uninit() is called by hand */ -void leaky_init (void); +void leaky_init(void); /* free all allocations */ -void leaky_uninit (void); +void leaky_uninit(void); /* allocate memory, remember the pointer and free it after exit from the application */ -void *leaky_malloc (size_t size); +void *leaky_malloc(size_t size); /* same as leaky_malloc but this one wraps calloc() */ -void *leaky_calloc (size_t nmemb, size_t size); +void *leaky_calloc(size_t nmemb, size_t size); /* reallocate memory, remember the new pointer and free it after exit from the application */ -void *leaky_realloc (void* old_memory, size_t size); +void *leaky_realloc(void *old_memory, size_t size); #endif Index: trunk/src/global.h =================================================================== --- trunk/src/global.h (revision 1021) +++ trunk/src/global.h (revision 1022) @@ -70,8 +70,8 @@ typedef struct unit Unit; typedef struct increments Increments; -typedef COORD_TYPE Coord; /* pcb base unit */ -typedef double Angle; /* degrees */ +typedef COORD_TYPE Coord; /* pcb base unit */ +typedef double Angle; /* degrees */ #include "hid.h" #include "polyarea.h" @@ -78,29 +78,29 @@ /* Internationalization support. */ #ifdef ENABLE_NLS -# include -# define _(S) gettext(S) -# if defined(gettext_noop) -# define N_(S) gettext_noop(S) -# else -# define N_(S) (S) -# endif +#include +#define _(S) gettext(S) +#if defined(gettext_noop) +#define N_(S) gettext_noop(S) #else -# define _(S) (S) -# define N_(S) (S) -# define textdomain(S) (S) -# define gettext(S) (S) -# define dgettext(D, S) (S) -# define dcgettext(D, S, T) (S) -# define bindtextdomain(D, Dir) (D) +#define N_(S) (S) +#endif +#else +#define _(S) (S) +#define N_(S) (S) +#define textdomain(S) (S) +#define gettext(S) (S) +#define dgettext(D, S) (S) +#define dcgettext(D, S, T) (S) +#define bindtextdomain(D, Dir) (D) #endif /* ENABLE_NLS */ /* This is used by the lexer/parser */ typedef struct { - int ival; - Coord bval; - double dval; - char has_units; + int ival; + Coord bval; + double dval; + char has_units; } PLMeasure; #ifndef XtSpecificationRelease @@ -121,13 +121,12 @@ unknown_flag_t *next; }; -typedef struct -{ - unsigned long f; /* generic flags */ - unsigned char t[(MAX_LAYER + 1) / 2]; /* thermals */ - unsigned char q; /* square geometry flag */ - unsigned char int_conn_grp; - unknown_flag_t *unknowns; +typedef struct { + unsigned long f; /* generic flags */ + unsigned char t[(MAX_LAYER + 1) / 2]; /* thermals */ + unsigned char q; /* square geometry flag */ + unsigned char int_conn_grp; + unknown_flag_t *unknowns; } FlagType, *FlagTypePtr; #ifndef __GNUC__ @@ -181,7 +180,7 @@ BoxType BoundingBox; \ long int ID; \ FlagType Flags - /* struct LibraryEntryType *net*/ + /* struct LibraryEntryType *net */ /* Lines, pads, and rats all use this so they can be cross-cast. */ #define ANYLINEFIELDS \ @@ -194,46 +193,39 @@ /* --------------------------------------------------------------------------- * some useful values of our widgets */ -typedef struct /* holds information about output window */ -{ - hidGC bgGC, /* background and foreground; */ - fgGC, /* changed from some routines */ - pmGC; /* depth 1 pixmap GC to store clip */ -} -OutputType, *OutputTypePtr; +typedef struct { /* holds information about output window */ + hidGC bgGC, /* background and foreground; */ + fgGC, /* changed from some routines */ + pmGC; /* depth 1 pixmap GC to store clip */ +} OutputType, *OutputTypePtr; /* ---------------------------------------------------------------------- * layer group. A layer group identifies layers which are always switched * on/off together. */ -typedef struct -{ - Cardinal Number[MAX_LAYER], /* number of entries per groups */ - Entries[MAX_LAYER][MAX_LAYER + 2]; +typedef struct { + Cardinal Number[MAX_LAYER], /* number of entries per groups */ + Entries[MAX_LAYER][MAX_LAYER + 2]; } LayerGroupType, *LayerGroupTypePtr; -struct BoxType /* a bounding box */ -{ - Coord X1, Y1; /* upper left */ - Coord X2, Y2; /* and lower right corner */ +struct BoxType { /* a bounding box */ + Coord X1, Y1; /* upper left */ + Coord X2, Y2; /* and lower right corner */ }; -typedef struct -{ - Coord x, y; - Coord width, height; +typedef struct { + Coord x, y; + Coord width, height; } RectangleType, *RectangleTypePtr; -typedef struct -{ - char *name; - char *value; +typedef struct { + char *name; + char *value; } AttributeType, *AttributeTypePtr; -struct AttributeListType -{ - int Number, Max; - AttributeType *List; +struct AttributeListType { + int Number, Max; + AttributeType *List; }; /* --------------------------------------------------------------------------- @@ -243,109 +235,98 @@ /* All on-pcb objects (elements, lines, pads, vias, rats, etc) are based on this. */ typedef struct { - ANYOBJECTFIELDS; + ANYOBJECTFIELDS; } AnyObjectType, *AnyObjectTypePtr; -typedef struct /* a line/polygon point */ -{ - Coord X, Y, X2, Y2; /* so Point type can be cast as BoxType */ - long int ID; +typedef struct { /* a line/polygon point */ + Coord X, Y, X2, Y2; /* so Point type can be cast as BoxType */ + long int ID; } PointType, *PointTypePtr; /* Lines, rats, pads, etc. */ typedef struct { - ANYLINEFIELDS; + ANYLINEFIELDS; } AnyLineObjectType, *AnyLineObjectTypePtr; -typedef struct /* holds information about one line */ -{ - ANYLINEFIELDS; - char *Number; +typedef struct { /* holds information about one line */ + ANYLINEFIELDS; + char *Number; } LineType, *LineTypePtr; -typedef struct -{ - ANYOBJECTFIELDS; - int Scale; /* text scaling in percent */ - Coord X, Y; /* origin */ - BYTE Direction; - char *TextString; /* string */ - void *Element; +typedef struct { + ANYOBJECTFIELDS; + int Scale; /* text scaling in percent */ + Coord X, Y; /* origin */ + BYTE Direction; + char *TextString; /* string */ + void *Element; } TextType, *TextTypePtr; -struct polygon_st /* holds information about a polygon */ -{ - ANYOBJECTFIELDS; - Cardinal PointN, /* number of points in polygon */ - PointMax; /* max number from malloc() */ - POLYAREA *Clipped; /* the clipped region of this polygon */ - PLINE *NoHoles; /* the polygon broken into hole-less regions */ - int NoHolesValid; /* Is the NoHoles polygon up to date? */ - PointTypePtr Points; /* data */ - Cardinal *HoleIndex; /* Index of hole data within the Points array */ - Cardinal HoleIndexN; /* number of holes in polygon */ - Cardinal HoleIndexMax; /* max number from malloc() */ +struct polygon_st { /* holds information about a polygon */ + ANYOBJECTFIELDS; + Cardinal PointN, /* number of points in polygon */ + PointMax; /* max number from malloc() */ + POLYAREA *Clipped; /* the clipped region of this polygon */ + PLINE *NoHoles; /* the polygon broken into hole-less regions */ + int NoHolesValid; /* Is the NoHoles polygon up to date? */ + PointTypePtr Points; /* data */ + Cardinal *HoleIndex; /* Index of hole data within the Points array */ + Cardinal HoleIndexN; /* number of holes in polygon */ + Cardinal HoleIndexMax; /* max number from malloc() */ }; -typedef struct /* holds information about arcs */ -{ - ANYOBJECTFIELDS; - Coord Thickness, Clearance; - Coord Width, Height, /* length of axis */ - X, Y; /* center coordinates */ - Angle StartAngle, Delta; /* the two limiting angles in degrees */ +typedef struct { /* holds information about arcs */ + ANYOBJECTFIELDS; + Coord Thickness, Clearance; + Coord Width, Height, /* length of axis */ + X, Y; /* center coordinates */ + Angle StartAngle, Delta; /* the two limiting angles in degrees */ } ArcType, *ArcTypePtr; -struct rtree -{ - struct rtree_node *root; - int size; /* number of entries in tree */ +struct rtree { + struct rtree_node *root; + int size; /* number of entries in tree */ }; -typedef struct /* holds information about one layer */ -{ - char *Name; /* layer name */ - Cardinal LineN, /* number of lines */ - TextN, /* labels */ - PolygonN, /* polygons */ - ArcN; /* and arcs */ - GList *Line; - GList *Text; - GList *Polygon; - GList *Arc; - rtree_t *line_tree, *text_tree, *polygon_tree, *arc_tree; - bool On; /* visible flag */ - char *Color, /* color */ - *SelectedColor; - AttributeListType Attributes; - int no_drc; /* whether to ignore the layer when checking the design rules */ -} -LayerType, *LayerTypePtr; +typedef struct { /* holds information about one layer */ + char *Name; /* layer name */ + Cardinal LineN, /* number of lines */ + TextN, /* labels */ + PolygonN, /* polygons */ + ArcN; /* and arcs */ + GList *Line; + GList *Text; + GList *Polygon; + GList *Arc; + rtree_t *line_tree, *text_tree, *polygon_tree, *arc_tree; + bool On; /* visible flag */ + char *Color, /* color */ + *SelectedColor; + AttributeListType Attributes; + int no_drc; /* whether to ignore the layer when checking the design rules */ +} LayerType, *LayerTypePtr; -typedef struct /* a rat-line */ -{ - ANYLINEFIELDS; - Cardinal group1, group2; /* the layer group each point is on */ +typedef struct { /* a rat-line */ + ANYLINEFIELDS; + Cardinal group1, group2; /* the layer group each point is on */ } RatType, *RatTypePtr; -struct pad_st /* a SMD pad */ -{ - ANYLINEFIELDS; - Coord Mask; - char *Name, *Number; /* 'Line' */ - void *Element; - void *Spare; +struct pad_st { /* a SMD pad */ + ANYLINEFIELDS; + Coord Mask; + char *Name, *Number; /* 'Line' */ + void *Element; + void *Spare; }; -struct pin_st -{ - ANYOBJECTFIELDS; - Coord Thickness, Clearance, Mask, DrillingHole; - Coord X, Y; /* center and diameter */ - char *Name, *Number; - void *Element; - void *Spare; +struct pin_st { + ANYOBJECTFIELDS; + Coord Thickness, Clearance, Mask, DrillingHole; + Coord X, Y; /* center and diameter */ + char *Name, *Number; + void *Element; + void *Spare; }; /* This is the extents of a Pin or Via, depending on whether it's a @@ -354,93 +335,86 @@ ? (pinptr)->DrillingHole \ : (pinptr)->Thickness) -typedef struct -{ - ANYOBJECTFIELDS; - TextType Name[MAX_ELEMENTNAMES]; /* the elements names; */ - /* description text */ - /* name on PCB second, */ - /* value third */ - /* see macro.h */ - Coord MarkX, MarkY; /* position mark */ - Cardinal PinN; /* number of pins */ - Cardinal PadN; /* number of pads */ - Cardinal LineN; /* number of lines */ - Cardinal ArcN; /* number of arcs */ - GList *Pin; - GList *Pad; - GList *Line; - GList *Arc; - BoxType VBox; - AttributeListType Attributes; +typedef struct { + ANYOBJECTFIELDS; + TextType Name[MAX_ELEMENTNAMES]; /* the elements names; */ + /* description text */ + /* name on PCB second, */ + /* value third */ + /* see macro.h */ + Coord MarkX, MarkY; /* position mark */ + Cardinal PinN; /* number of pins */ + Cardinal PadN; /* number of pads */ + Cardinal LineN; /* number of lines */ + Cardinal ArcN; /* number of arcs */ + GList *Pin; + GList *Pad; + GList *Line; + GList *Arc; + BoxType VBox; + AttributeListType Attributes; } ElementType, *ElementTypePtr, **ElementTypeHandle; /* --------------------------------------------------------------------------- * symbol and font related stuff */ -typedef struct /* a single symbol */ -{ - LineTypePtr Line; - bool Valid; - Cardinal LineN, /* number of lines */ - LineMax; - Coord Width, Height, /* size of cell */ - Delta; /* distance to next symbol */ +typedef struct { /* a single symbol */ + LineTypePtr Line; + bool Valid; + Cardinal LineN, /* number of lines */ + LineMax; + Coord Width, Height, /* size of cell */ + Delta; /* distance to next symbol */ } SymbolType, *SymbolTypePtr; -typedef struct /* complete set of symbols */ -{ - Coord MaxHeight, /* maximum cell width and height */ - MaxWidth; - BoxType DefaultSymbol; /* the default symbol is a filled box */ - SymbolType Symbol[MAX_FONTPOSITION + 1]; - bool Valid; +typedef struct { /* complete set of symbols */ + Coord MaxHeight, /* maximum cell width and height */ + MaxWidth; + BoxType DefaultSymbol; /* the default symbol is a filled box */ + SymbolType Symbol[MAX_FONTPOSITION + 1]; + bool Valid; } FontType, *FontTypePtr; -typedef struct /* holds all objects */ -{ - Cardinal ViaN, /* number of vias */ - ElementN, /* and elements */ - RatN; /* and rat-lines */ - int LayerN; /* number of layers in this board */ - GList *Via; - GList *Element; - GList *Rat; - rtree_t *via_tree, *element_tree, *pin_tree, *pad_tree, *name_tree[3], /* for element names */ - *rat_tree; - struct PCBType *pcb; - LayerType Layer[MAX_LAYER + 2]; /* add 2 silkscreen layers */ +typedef struct { /* holds all objects */ + Cardinal ViaN, /* number of vias */ + ElementN, /* and elements */ + RatN; /* and rat-lines */ + int LayerN; /* number of layers in this board */ + GList *Via; + GList *Element; + GList *Rat; + rtree_t *via_tree, *element_tree, *pin_tree, *pad_tree, *name_tree[3], /* for element names */ + *rat_tree; + struct PCBType *pcb; + LayerType Layer[MAX_LAYER + 2]; /* add 2 silkscreen layers */ } DataType, *DataTypePtr; -typedef struct /* holds drill information */ -{ - Coord DrillSize; /* this drill's diameter */ - Cardinal 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 */ +typedef struct { /* holds drill information */ + Coord DrillSize; /* this drill's diameter */ + Cardinal 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 */ -{ - Cardinal DrillN, /* number of drill sizes */ - DrillMax; /* max number from malloc() */ - DrillTypePtr Drill; /* plated holes */ +typedef struct { /* holds a range of Drill Infos */ + Cardinal DrillN, /* number of drill sizes */ + DrillMax; /* max number from malloc() */ + DrillTypePtr Drill; /* plated holes */ } DrillInfoType, *DrillInfoTypePtr; -typedef struct -{ - Coord Thick, /* line thickness */ - Diameter, /* via diameter */ - Hole, /* via drill hole */ - Keepaway; /* min. separation from other nets */ - char *Name; - int index; +typedef struct { + Coord Thick, /* line thickness */ + Diameter, /* via diameter */ + Hole, /* via drill hole */ + Keepaway; /* min. separation from other nets */ + char *Name; + int index; } RouteStyleType, *RouteStyleTypePtr; #include "libpcb_fp.h" @@ -447,16 +421,15 @@ /* --------------------------------------------------------------------------- * structure used by library routines */ -typedef struct -{ - char *ListEntry; /* the string for the selection box */ - char *AllocatedMemory, /* pointer to allocated memory; all others */ - /* point to parts of the string */ - *Package, /* package */ - *Value, /* the value field */ - *Description; /* some descritional text */ - pcb_fp_type_t Type; - void **Tags; /* an array of void * tag IDs; last tag ID is NULL */ +typedef struct { + char *ListEntry; /* the string for the selection box */ + char *AllocatedMemory, /* pointer to allocated memory; all others */ + /* point to parts of the string */ + *Package, /* package */ + *Value, /* the value field */ + *Description; /* some descritional text */ + pcb_fp_type_t Type; + void **Tags; /* an array of void * tag IDs; last tag ID is NULL */ } LibraryEntryType, *LibraryEntryTypePtr; /*typedef LibraryEntryType *LibraryEntryTypePtr;*/ @@ -465,94 +438,87 @@ CreateLibraryEntry. These "internal" entries are used for electrical paths that aren't yet assigned to a real net. */ -typedef struct -{ - char *Name, /* name of the menu entry */ - *directory, /* Directory name library elements are from */ - *Style; /* routing style */ - Cardinal EntryN, /* number of objects */ - EntryMax; /* number of reserved memory locations */ - LibraryEntryTypePtr Entry; /* the entries */ - char flag; /* used by the netlist window to enable/disable nets */ - char internal; /* if set, this is an internal-only entry, not - part of the global netlist. */ +typedef struct { + char *Name, /* name of the menu entry */ + *directory, /* Directory name library elements are from */ + *Style; /* routing style */ + Cardinal EntryN, /* number of objects */ + EntryMax; /* number of reserved memory locations */ + LibraryEntryTypePtr Entry; /* the entries */ + char flag; /* used by the netlist window to enable/disable nets */ + char internal; /* if set, this is an internal-only entry, not + part of the global netlist. */ } LibraryMenuType, *LibraryMenuTypePtr; -typedef struct -{ - Cardinal MenuN; /* number of objects */ - Cardinal MenuMax; /* number of reserved memory locations */ - LibraryMenuTypePtr Menu; /* the entries */ +typedef struct { + Cardinal MenuN; /* number of objects */ + Cardinal MenuMax; /* number of reserved memory locations */ + LibraryMenuTypePtr Menu; /* the entries */ } LibraryType, *LibraryTypePtr; enum { - NETLIST_INPUT = 0, /* index of the original netlist as imported */ - NETLIST_EDITED = 1, /* index of the netlist produced by applying netlist patches on [NETLIST_INPUT] */ - NUM_NETLISTS /* so that we know how many netlists we are dealing with */ + NETLIST_INPUT = 0, /* index of the original netlist as imported */ + NETLIST_EDITED = 1, /* index of the netlist produced by applying netlist patches on [NETLIST_INPUT] */ + NUM_NETLISTS /* so that we know how many netlists we are dealing with */ }; - /* The PCBType struct holds information about board layout most of which is - | saved with the layout. A new PCB layout struct is first initialized - | with values from the user configurable Settings struct and then reset - | to the saved layout values when a layout is loaded. - | This struct is also used for the remove list and for buffer handling - */ -typedef struct PCBType -{ - long ID; /* see macro.h */ - FlagType Flags; - char *Name, /* name of board */ - *Filename, /* name of file (from load) */ - *PrintFilename, /* from print dialog */ - *Netlistname, /* name of netlist file */ - ThermStyle; /* type of thermal to place with thermal tool */ - bool Changed, /* layout has been changed */ - ViaOn, /* visibility flags */ - ElementOn, RatOn, InvisibleObjectsOn, PinOn, SilkActive, /* active layer is actually silk */ - RatDraw; /* we're drawing rats */ - char *ViaColor, /* some colors */ - *ViaSelectedColor, - *PinColor, - *PinSelectedColor, - *PinNameColor, - *ElementColor, - *ElementColor_nonetlist, - *RatColor, - *InvisibleObjectsColor, - *InvisibleMarkColor, - *ElementSelectedColor, - *RatSelectedColor, *ConnectedColor, *WarnColor, *MaskColor; - long CursorX, /* cursor position as saved with layout */ - CursorY, Clipping; - Coord Bloat, /* drc sizes saved with layout */ - Shrink, minWid, minSlk, minDrill, minRing; - Coord GridOffsetX, /* as saved with layout */ - GridOffsetY, MaxWidth, /* allowed size */ - MaxHeight; + /* The PCBType struct holds information about board layout most of which is + | saved with the layout. A new PCB layout struct is first initialized + | with values from the user configurable Settings struct and then reset + | to the saved layout values when a layout is loaded. + | This struct is also used for the remove list and for buffer handling + */ +typedef struct PCBType { + long ID; /* see macro.h */ + FlagType Flags; + char *Name, /* name of board */ + *Filename, /* name of file (from load) */ + *PrintFilename, /* from print dialog */ + *Netlistname, /* name of netlist file */ + ThermStyle; /* type of thermal to place with thermal tool */ + bool Changed, /* layout has been changed */ + ViaOn, /* visibility flags */ + ElementOn, RatOn, InvisibleObjectsOn, PinOn, SilkActive, /* active layer is actually silk */ + RatDraw; /* we're drawing rats */ + char *ViaColor, /* some colors */ + *ViaSelectedColor, + *PinColor, + *PinSelectedColor, + *PinNameColor, + *ElementColor, + *ElementColor_nonetlist, + *RatColor, + *InvisibleObjectsColor, + *InvisibleMarkColor, *ElementSelectedColor, *RatSelectedColor, *ConnectedColor, *WarnColor, *MaskColor; + long CursorX, /* cursor position as saved with layout */ + CursorY, Clipping; + Coord Bloat, /* drc sizes saved with layout */ + Shrink, minWid, minSlk, minDrill, minRing; + Coord GridOffsetX, /* as saved with layout */ + GridOffsetY, MaxWidth, /* allowed size */ + MaxHeight; - Coord Grid; /* used grid with offsets */ - double Zoom, /* zoom factor */ - IsleArea, /* minimum poly island to retain */ - ThermScale; /* scale factor used with thermals */ - FontType Font; - LayerGroupType LayerGroups; - RouteStyleType RouteStyle[NUM_STYLES]; - LibraryType NetlistLib[NUM_NETLISTS]; - rats_patch_line_t *NetlistPatches, *NetlistPatchLast; - AttributeListType Attributes; - DataTypePtr Data; /* entire database */ + Coord Grid; /* used grid with offsets */ + double Zoom, /* zoom factor */ + IsleArea, /* minimum poly island to retain */ + ThermScale; /* scale factor used with thermals */ + FontType Font; + LayerGroupType LayerGroups; + RouteStyleType RouteStyle[NUM_STYLES]; + LibraryType NetlistLib[NUM_NETLISTS]; + rats_patch_line_t *NetlistPatches, *NetlistPatchLast; + AttributeListType Attributes; + DataTypePtr Data; /* entire database */ - bool is_footprint; /* If set, the user has loaded a footprint, not a pcb. */ -} -PCBType, *PCBTypePtr; + bool is_footprint; /* If set, the user has loaded a footprint, not a pcb. */ +} PCBType, *PCBTypePtr; -typedef struct /* information about the paste buffer */ -{ - Coord X, Y; /* offset */ - BoxType BoundingBox; - DataTypePtr Data; /* data; not all members of PCBType */ - /* are used */ +typedef struct { /* information about the paste buffer */ + Coord X, Y; /* offset */ + BoxType BoundingBox; + DataTypePtr Data; /* data; not all members of PCBType */ + /* are used */ } BufferType, *BufferTypePtr; /* --------------------------------------------------------------------------- @@ -559,76 +525,69 @@ * some types for cursor drawing, setting of block and lines * as well as for merging of elements */ -typedef struct /* rubberband lines for element moves */ -{ - LayerTypePtr Layer; /* layer that holds the line */ - LineTypePtr Line; /* the line itself */ - PointTypePtr MovedPoint; /* and finally the point */ +typedef struct { /* rubberband lines for element moves */ + LayerTypePtr Layer; /* layer that holds the line */ + LineTypePtr Line; /* the line itself */ + PointTypePtr MovedPoint; /* and finally the point */ } RubberbandType, *RubberbandTypePtr; -typedef struct /* current marked line */ -{ - PointType Point1, /* start- and end-position */ - Point2; - long int State; - bool draw; +typedef struct { /* current marked line */ + PointType Point1, /* start- and end-position */ + Point2; + long int State; + bool draw; } AttachedLineType, *AttachedLineTypePtr; -typedef struct /* currently marked block */ -{ - PointType Point1, /* start- and end-position */ - Point2; - long int State; - bool otherway; +typedef struct { /* currently marked block */ + PointType Point1, /* start- and end-position */ + Point2; + long int State; + bool otherway; } AttachedBoxType, *AttachedBoxTypePtr; -typedef struct /* currently attached object */ -{ - Coord X, Y; /* saved position when MOVE_MODE */ - BoxType BoundingBox; - long int Type, /* object type */ - State; - void *Ptr1, /* three pointers to data, see */ - *Ptr2, /* search.c */ - *Ptr3; - Cardinal RubberbandN, /* number of lines in array */ - RubberbandMax; - RubberbandTypePtr Rubberband; +typedef struct { /* currently attached object */ + Coord X, Y; /* saved position when MOVE_MODE */ + BoxType BoundingBox; + long int Type, /* object type */ + State; + void *Ptr1, /* three pointers to data, see */ + *Ptr2, /* search.c */ + *Ptr3; + Cardinal RubberbandN, /* number of lines in array */ + RubberbandMax; + RubberbandTypePtr Rubberband; } AttachedObjectType, *AttachedObjectTypePtr; -enum crosshair_shape -{ - Basic_Crosshair_Shape = 0, /* 4-ray */ - Union_Jack_Crosshair_Shape, /* 8-ray */ - Dozen_Crosshair_Shape, /* 12-ray */ - Crosshair_Shapes_Number +enum crosshair_shape { + Basic_Crosshair_Shape = 0, /* 4-ray */ + Union_Jack_Crosshair_Shape, /* 8-ray */ + Dozen_Crosshair_Shape, /* 12-ray */ + Crosshair_Shapes_Number }; -typedef struct /* holds cursor information */ -{ - hidGC GC, /* GC for cursor drawing */ - AttachGC; /* and for displaying buffer contents */ - Coord X, Y, /* position in PCB coordinates */ - MinX, MinY, /* lowest and highest coordinates */ - MaxX, MaxY; - AttachedLineType AttachedLine; /* data of new lines... */ - AttachedBoxType AttachedBox; - PolygonType AttachedPolygon; - AttachedObjectType AttachedObject; /* data of attached objects */ - enum crosshair_shape shape; /* shape of crosshair */ - GList *onpoint_objs; /* list of associated lines/arc */ - GList *onpoint_objs_types; /* ..and a list of their respective types */ +typedef struct { /* holds cursor information */ + hidGC GC, /* GC for cursor drawing */ + AttachGC; /* and for displaying buffer contents */ + Coord X, Y, /* position in PCB coordinates */ + MinX, MinY, /* lowest and highest coordinates */ + MaxX, MaxY; + AttachedLineType AttachedLine; /* data of new lines... */ + AttachedBoxType AttachedBox; + PolygonType AttachedPolygon; + AttachedObjectType AttachedObject; /* data of attached objects */ + enum crosshair_shape shape; /* shape of crosshair */ + GList *onpoint_objs; /* list of associated lines/arc */ + GList *onpoint_objs_types; /* ..and a list of their respective types */ - /* list of object IDs that could have been dragged so that they can be cycled */ - long int *drags; - int drags_len, drags_current; - Coord dragx, dragy; /* the point where drag started */ + /* list of object IDs that could have been dragged so that they can be cycled */ + long int *drags; + int drags_len, drags_current; + Coord dragx, dragy; /* the point where drag started */ } CrosshairType, *CrosshairTypePtr; -typedef struct -{ - bool status; - Coord X, Y; +typedef struct { + bool status; + Coord X, Y; } MarkType, *MarkTypePtr; /* --------------------------------------------------------------------------- @@ -635,115 +594,103 @@ * our resources * most of them are used as default when a new design is started */ -typedef struct /* some resources... */ -{ - const Unit *grid_unit; - Increments *increments; +typedef struct { /* some resources... */ + const Unit *grid_unit; + Increments *increments; - int verbose; + int verbose; - char *BlackColor, *WhiteColor, *BackgroundColor, /* background and cursor color ... */ - *CrosshairColor, /* different object colors */ - *CrossColor, - *ViaColor, - *ViaSelectedColor, - *PinColor, - *PinSelectedColor, - *PinNameColor, - *ElementColor, - *ElementColor_nonetlist, - *RatColor, - *InvisibleObjectsColor, - *InvisibleMarkColor, - *ElementSelectedColor, - *RatSelectedColor, - *ConnectedColor, - *OffLimitColor, - *GridColor, - *LayerColor[MAX_LAYER], - *LayerSelectedColor[MAX_LAYER], *WarnColor, *MaskColor; - Coord ViaThickness, /* some preset values */ - ViaDrillingHole, LineThickness, RatThickness, Keepaway, /* default size of a new layout */ - MaxWidth, MaxHeight, - AlignmentDistance, Bloat, /* default drc sizes */ - Shrink, minWid, minSlk, minDrill, minRing; - int TextScale; /* text scaling in % */ - Coord Grid; /* grid in pcb-units */ - double Zoom, - IsleArea, /* polygon min area */ - PinoutZoom; /* same for pinout windows */ - int PinoutNameLength, /* max displayed length of a pinname */ - Volume, /* the speakers volume -100..100 */ - CharPerLine, /* width of an output line in characters */ - Mode, /* currently active mode */ - BufferNumber; /* number of the current buffer */ - int BackupInterval; /* time between two backups in seconds */ - char *DefaultLayerName[MAX_LAYER], *FontCommand, /* commands for file loading... */ - *FileCommand, *PrintFile, *LibraryShell, *LibrarySearchPaths, - *SaveCommand, *FontFile, /* name of default font file */ - *DefaultPcbFile, - *Groups, /* string with layergroups */ - *Routes, /* string with route styles */ - *FilePath, *RatPath, *RatCommand, *FontPath, *PinoutFont, *ElementPath, *Size, /* geometry string for size */ - *BackgroundImage, /* PPM file for board background */ - *ScriptFilename, /* PCB Actions script to execute on startup */ - *ActionString, /* PCB Actions string to execute on startup */ - *FabAuthor, /* Full name of author for FAB drawings */ - *GnetlistProgram, /* gnetlist program name */ - *MakeProgram, /* make program name */ - *InitialLayerStack; /* If set, the initial layer stack is set to this */ - Coord PinoutOffsetX, /* offset of origin */ - PinoutOffsetY; - Coord PinoutTextOffsetX, /* offset of text from pin center */ - PinoutTextOffsetY; - RouteStyleType RouteStyle[NUM_STYLES]; /* default routing styles */ - LayerGroupType LayerGroups; /* default layer groups */ - bool ClearLine, FullPoly, - UniqueNames, /* force unique names */ - SnapPin, /* snap to pins and pads */ - SnapOffGridLine, /*!< Snap to certain off-grid points along a line. */ - HighlightOnPoint, /*!< Highlight if crosshair is on endpoints. */ - ShowSolderSide, /* mirror output */ - SaveLastCommand, /* save the last command entered by user */ - SaveInTMP, /* always save data in /tmp */ - DrawGrid, /* draw grid points */ - RatWarn, /* rats nest has set warnings */ - StipplePolygons, /* draw polygons with stipple */ - AllDirectionLines, /* enable lines to all directions */ - RubberBandMode, /* move, rotate use rubberband connections */ - SwapStartDirection, /* change starting direction after each click */ - ShowDRC, /* show drc region on crosshair */ - AutoDRC, /* */ - ShowNumber, /* pinout shows number */ - OrthogonalMoves, /* */ - ResetAfterElement, /* reset connections after each element */ - liveRouting, /* autorouter shows tracks in progress */ - RingBellWhenFinished, /* flag if a signal should be */ - /* produced when searching of */ - /* connections is done */ - AutoPlace, /* flag which says we should force placement of the - windows on startup */ - EnableMincut; /* Enable calculating mincut on shorts (rats_mincut.c) when non-zero */ -} -SettingType, *SettingTypePtr; + char *BlackColor, *WhiteColor, *BackgroundColor, /* background and cursor color ... */ + *CrosshairColor, /* different object colors */ + *CrossColor, + *ViaColor, + *ViaSelectedColor, + *PinColor, + *PinSelectedColor, + *PinNameColor, + *ElementColor, + *ElementColor_nonetlist, + *RatColor, + *InvisibleObjectsColor, + *InvisibleMarkColor, + *ElementSelectedColor, + *RatSelectedColor, + *ConnectedColor, *OffLimitColor, *GridColor, *LayerColor[MAX_LAYER], *LayerSelectedColor[MAX_LAYER], *WarnColor, *MaskColor; + Coord ViaThickness, /* some preset values */ + ViaDrillingHole, LineThickness, RatThickness, Keepaway, /* default size of a new layout */ + MaxWidth, MaxHeight, AlignmentDistance, Bloat, /* default drc sizes */ + Shrink, minWid, minSlk, minDrill, minRing; + int TextScale; /* text scaling in % */ + Coord Grid; /* grid in pcb-units */ + double Zoom, IsleArea, /* polygon min area */ + PinoutZoom; /* same for pinout windows */ + int PinoutNameLength, /* max displayed length of a pinname */ + Volume, /* the speakers volume -100..100 */ + CharPerLine, /* width of an output line in characters */ + Mode, /* currently active mode */ + BufferNumber; /* number of the current buffer */ + int BackupInterval; /* time between two backups in seconds */ + char *DefaultLayerName[MAX_LAYER], *FontCommand, /* commands for file loading... */ + *FileCommand, *PrintFile, *LibraryShell, *LibrarySearchPaths, *SaveCommand, *FontFile, /* name of default font file */ + *DefaultPcbFile, *Groups, /* string with layergroups */ + *Routes, /* string with route styles */ + *FilePath, *RatPath, *RatCommand, *FontPath, *PinoutFont, *ElementPath, *Size, /* geometry string for size */ + *BackgroundImage, /* PPM file for board background */ + *ScriptFilename, /* PCB Actions script to execute on startup */ + *ActionString, /* PCB Actions string to execute on startup */ + *FabAuthor, /* Full name of author for FAB drawings */ + *GnetlistProgram, /* gnetlist program name */ + *MakeProgram, /* make program name */ + *InitialLayerStack; /* If set, the initial layer stack is set to this */ + Coord PinoutOffsetX, /* offset of origin */ + PinoutOffsetY; + Coord PinoutTextOffsetX, /* offset of text from pin center */ + PinoutTextOffsetY; + RouteStyleType RouteStyle[NUM_STYLES]; /* default routing styles */ + LayerGroupType LayerGroups; /* default layer groups */ + bool ClearLine, FullPoly, UniqueNames, /* force unique names */ + SnapPin, /* snap to pins and pads */ + SnapOffGridLine, /*!< Snap to certain off-grid points along a line. */ + HighlightOnPoint, /*!< Highlight if crosshair is on endpoints. */ + ShowSolderSide, /* mirror output */ + SaveLastCommand, /* save the last command entered by user */ + SaveInTMP, /* always save data in /tmp */ + DrawGrid, /* draw grid points */ + RatWarn, /* rats nest has set warnings */ + StipplePolygons, /* draw polygons with stipple */ + AllDirectionLines, /* enable lines to all directions */ + RubberBandMode, /* move, rotate use rubberband connections */ + SwapStartDirection, /* change starting direction after each click */ + ShowDRC, /* show drc region on crosshair */ + AutoDRC, /* */ + ShowNumber, /* pinout shows number */ + OrthogonalMoves, /* */ + ResetAfterElement, /* reset connections after each element */ + liveRouting, /* autorouter shows tracks in progress */ + RingBellWhenFinished, /* flag if a signal should be */ + /* produced when searching of */ + /* connections is done */ + AutoPlace, /* flag which says we should force placement of the + windows on startup */ + EnableMincut; /* Enable calculating mincut on shorts (rats_mincut.c) when non-zero */ +} SettingType, *SettingTypePtr; /* ---------------------------------------------------------------------- * pointer to low-level copy, move and rotate functions */ -typedef struct -{ - void *(*Line) (LayerTypePtr, LineTypePtr); - void *(*Text) (LayerTypePtr, TextTypePtr); - void *(*Polygon) (LayerTypePtr, PolygonTypePtr); - void *(*Via) (PinTypePtr); - void *(*Element) (ElementTypePtr); - void *(*ElementName) (ElementTypePtr); - void *(*Pin) (ElementTypePtr, PinTypePtr); - void *(*Pad) (ElementTypePtr, PadTypePtr); - void *(*LinePoint) (LayerTypePtr, LineTypePtr, PointTypePtr); - void *(*Point) (LayerTypePtr, PolygonTypePtr, PointTypePtr); - void *(*Arc) (LayerTypePtr, ArcTypePtr); - void *(*Rat) (RatTypePtr); +typedef struct { + void *(*Line) (LayerTypePtr, LineTypePtr); + void *(*Text) (LayerTypePtr, TextTypePtr); + void *(*Polygon) (LayerTypePtr, PolygonTypePtr); + void *(*Via) (PinTypePtr); + void *(*Element) (ElementTypePtr); + void *(*ElementName) (ElementTypePtr); + void *(*Pin) (ElementTypePtr, PinTypePtr); + void *(*Pad) (ElementTypePtr, PadTypePtr); + void *(*LinePoint) (LayerTypePtr, LineTypePtr, PointTypePtr); + void *(*Point) (LayerTypePtr, PolygonTypePtr, PointTypePtr); + void *(*Arc) (LayerTypePtr, ArcTypePtr); + void *(*Rat) (RatTypePtr); } ObjectFunctionType, *ObjectFunctionTypePtr; /* --------------------------------------------------------------------------- @@ -750,64 +697,57 @@ * structure used by device drivers */ -typedef struct /* holds a connection */ -{ - Coord X, Y; /* coordinate of connection */ - long int type; /* type of object in ptr1 - 3 */ - void *ptr1, *ptr2; /* the object of the connection */ - Cardinal group; /* the layer group of the connection */ - LibraryMenuType *menu; /* the netmenu this *SHOULD* belong too */ +typedef struct { /* holds a connection */ + Coord X, Y; /* coordinate of connection */ + long int type; /* type of object in ptr1 - 3 */ + void *ptr1, *ptr2; /* the object of the connection */ + Cardinal group; /* the layer group of the connection */ + LibraryMenuType *menu; /* the netmenu this *SHOULD* belong too */ } ConnectionType, *ConnectionTypePtr; -typedef struct /* holds a net of connections */ -{ - Cardinal ConnectionN, /* the number of connections contained */ - ConnectionMax; /* max connections from malloc */ - ConnectionTypePtr Connection; - RouteStyleTypePtr Style; +typedef struct { /* holds a net of connections */ + Cardinal ConnectionN, /* the number of connections contained */ + ConnectionMax; /* max connections from malloc */ + ConnectionTypePtr Connection; + RouteStyleTypePtr Style; } NetType, *NetTypePtr; -typedef struct /* holds a list of nets */ -{ - Cardinal NetN, /* the number of subnets contained */ - NetMax; /* max subnets from malloc */ - NetTypePtr Net; +typedef struct { /* holds a list of nets */ + Cardinal NetN, /* the number of subnets contained */ + NetMax; /* max subnets from malloc */ + NetTypePtr Net; } NetListType, *NetListTypePtr; -typedef struct /* holds a list of net lists */ -{ - Cardinal NetListN, /* the number of net lists contained */ - NetListMax; /* max net lists from malloc */ - NetListTypePtr NetList; +typedef struct { /* holds a list of net lists */ + Cardinal NetListN, /* the number of net lists contained */ + NetListMax; /* max net lists from malloc */ + NetListTypePtr NetList; } NetListListType, *NetListListTypePtr; -typedef struct /* holds a generic list of pointers */ -{ - Cardinal PtrN, /* the number of pointers contained */ - PtrMax; /* max subnets from malloc */ - void **Ptr; +typedef struct { /* holds a generic list of pointers */ + Cardinal PtrN, /* the number of pointers contained */ + PtrMax; /* max subnets from malloc */ + void **Ptr; } PointerListType, *PointerListTypePtr; -typedef struct -{ - Cardinal BoxN, /* the number of boxes contained */ - BoxMax; /* max boxes from malloc */ - BoxTypePtr Box; +typedef struct { + Cardinal BoxN, /* the number of boxes contained */ + BoxMax; /* max boxes from malloc */ + BoxTypePtr Box; } BoxListType, *BoxListTypePtr; -struct drc_violation_st -{ - char *title; - char *explanation; - Coord x, y; - Angle angle; - int have_measured; - Coord measured_value; - Coord required_value; - int object_count; - long int *object_id_list; - int *object_type_list; +struct drc_violation_st { + char *title; + char *explanation; + Coord x, y; + Angle angle; + int have_measured; + Coord measured_value; + Coord required_value; + int object_count; + long int *object_id_list; + int *object_type_list; }; typedef enum { @@ -835,7 +775,7 @@ * note these must be separate bits now */ #define UNDO_CHANGENAME 0x0001 /* change of names */ -#define UNDO_MOVE 0x0002 /* moving objects */ +#define UNDO_MOVE 0x0002 /* moving objects */ #define UNDO_REMOVE 0x0004 /* removing objects */ #define UNDO_REMOVE_POINT 0x0008 /* removing polygon/... points */ #define UNDO_INSERT_POINT 0x0010 /* inserting polygon/... points */ @@ -844,7 +784,7 @@ #define UNDO_ROTATE 0x0080 /* rotations */ #define UNDO_CREATE 0x0100 /* creation of objects */ #define UNDO_MOVETOLAYER 0x0200 /* moving objects to */ -#define UNDO_FLAG 0x0400 /* toggling SELECTED flag */ +#define UNDO_FLAG 0x0400 /* toggling SELECTED flag */ #define UNDO_CHANGESIZE 0x0800 /* change size of object */ #define UNDO_CHANGE2NDSIZE 0x1000 /* change 2ndSize of object */ #define UNDO_MIRROR 0x2000 /* change side of board */ @@ -886,7 +826,7 @@ * Variables with absolute paths to various directories. These are deduced * at runtime to allow pcb to be relocatable */ -extern char *bindir; /* The dir in which PCB installation was found */ +extern char *bindir; /* The dir in which PCB installation was found */ extern char *pcblibdir; extern char *exec_prefix; extern char *homedir; Index: trunk/src/gpcb-menu.h =================================================================== --- trunk/src/gpcb-menu.h (revision 1021) +++ trunk/src/gpcb-menu.h (revision 1022) @@ -1,539 +1,540 @@ /* AUTOMATICALLY GENERATED FROM gpcb-menu.res DO NOT EDIT */ const char *gpcb_menu_default[] = { -"# -*- c -*-", -"# Note - gpcb-menu.res is used to build gpcb-menu.h", -"# Note - parameters are sensitive to extra spaces around the commas", -"", -"Mouse =", -"{", -" Left = {", -" Mode(Notify)", -" ctrl = { Mode(Save) Mode(None) Mode(Restore) Mode(Notify) }", -" shift-ctrl = { Mode(Save) Mode(Remove) Mode(Notify) Mode(Restore) }", -" up = Mode(Release)", -" }", -" Right = {", -" Pan(1)", -" up = Pan(0)", -" shift = Popup(Popup1)", -" ctrl = Display(CycleCrosshair)", -" }", -" Middle = {", -" Mode(Stroke)", -" up = Mode(Release)", -" ctrl = { Mode(Save) Mode(Copy) Mode(Notify) }", -" up-ctrl = { Mode(Notify) Mode(Restore) }", -" shift-ctrl = { Display(ToggleRubberbandMode) Mode(Save) Mode(Move) Mode(Notify) }", -" up-shift-ctrl = { Mode(Notify) Mode(Restore) Display(ToggleRubberbandMode) }", -" }", -" Up = {", -" Zoom(0.8)", -" shift = Scroll(up)", -" ctrl = Scroll(left)", -" }", -" Down = {", -" Zoom(1.25)", -" shift = Scroll(down)", -" ctrl = Scroll(right)", -" }", -"# If you want zoom to center, do this instead.", -" #Up = { {Zoom(0.8) Center()} }", -" #Down = { {Zoom(1.25) Center()} }", -"}", -"", -"MainMenu =", -"{", -"", -"#", -"# File Menu", -"#", -" {\"File\" m=F", -" {\"Save Layout\" Save(Layout) tip=\"Saves current layout\" m=S a={\"Ctrl-S\" \"Ctrls\"}}", -" {\"Save Layout As...\" Save(LayoutAs) tip=\"Saves current layout into a new file\" m=A a={\"Shift Ctrl-S\" \"Shift Ctrls\"}}", -" -", -" {\"Revert\" Load(Revert,none) tip=\"Revert to the layout stored on disk\"}", -" -", -" {\"Import Schematics\" Import() }", -" {\"Load layout\" Load(Layout) tip=\"Load a layout from a file\"}", -" {\"Load element data to paste-buffer\" PasteBuffer(Clear) Load(ElementTobuffer)}", -" {\"Load layout data to paste-buffer\" PasteBuffer(Clear) Load(LayoutTobuffer)}", -" {\"Load netlist file\" Load(Netlist)}", -" {\"Load vendor resource file\" LoadVendorFrom()}", -" -", -" {\"Save connection data of\"", -" {\" a single element\" GetXY(Click to set the element mark <>) Save(ElementConnections)}", -" {\" all elements\" Save(AllConnections)}", -" {\" unused pins\" Save(AllUnusedPins)}", -" }", -" -", -" {\"Print layout...\" Print()}", -" {\"Export layout...\" Export()}", -" {\"Calibrate Printer...\" PrintCalibrate()}", -" -", -" {\"Start New Layout\" New() a={\"Ctrl-N\" \"Ctrln\"}}", -" -", -" {\"Preferences...\" DoWindows(Preferences)}", -" -", -" {\"Quit Program\" Quit() a={\"Ctrl-Q\" \"Ctrlq\"}}", -" }", -"", -"#", -"# Edit Menu", -"#", -" {\"Edit\" m=E", -" {\"Undo last operation\" Undo() a={\"U\" \"u\"}}", -" {\"Redo last undone operation\" Redo() a={\"Shift-R\" \"Shiftr\"}}", -" {\"Clear undo-buffer\" Undo(ClearList) a={\"Shift-Ctrl-U\" \"Shift Ctrlu\"}}", -" -", -" {\"Cut selection to buffer\" GetXY(Click to set the snap point for this buffer)", -" PasteBuffer(Clear) PasteBuffer(AddSelected) RemoveSelected() Mode(PasteBuffer)", -" a={\"Ctrl-X\" \"Ctrlx\"}}", -" {\"Copy selection to buffer\" GetXY(Click to set the snap point for this buffer)", -" PasteBuffer(Clear) PasteBuffer(AddSelected) Unselect(All) Mode(PasteBuffer)", -" a={\"Ctrl-C\" \"Ctrlc\"}}", -" {\"Paste buffer to layout\" Mode(PasteBuffer) a={\"Ctrl-V\" \"Ctrlv\"}}", -" -", -" {\"Unselect all\" Unselect(All) a={\"Shift-Alt-A\" \"Shift Alta\"}}", -" {\"Select all visible\" Select(All) a={\"Alt-A\" \"Alta\"}}", -" -", -" {\"Edit name of\"", -" {\"text on layout\" ChangeName(Object) a={\"N\" \"n\"}}", -" {\"layout\" ChangeName(Layout)}", -" {\"active layer\" ChangeName(Layer)}", -" }", -" {\"Edit attributes of\"", -" {\"Layout\" Attributes(Layout)}", -" {\"CurrentLayer\" Attributes(Layer)}", -" {\"Element\" Attributes(Element)}", -" }", -" {\"Change flags\"", -" {\"Nonetlist\" ChangeNonetlist(Element) a={\"Alt-N\" \"Altn\"}}", -" }", -" -", -" {\"Route Styles\" @routestyles", -" -", -" {\"Edit...\" AdjustStyle(0)}", -" }", -" }", -"", -"#", -"# View Menu", -"#", -" {\"View\" m=V", -" {\"Enable visible grid\" checked=drawgrid Display(Grid)}", -" {\"Grid units\"", -" {\"mil\" checked=grid_units_mil,1 SetUnits(mil)}", -" {\"mm\" checked=grid_units_mm,1 SetUnits(mm)}", -" }", -" {\"Grid size\"", -" {\"No Grid\" checked=grid,0 SetValue(Grid,1)}", -" -", -" { \"0.1 mil\" checked=gridsize,0.1mil SetUnits(mil) SetValue(Grid,0.1mil)}", -" { \"1 mil\" checked=gridsize,1mil SetUnits(mil) SetValue(Grid,1mil)}", -" { \"5 mil\" checked=gridsize,5mil SetUnits(mil) SetValue(Grid,5mil)}", -" { \"10 mil\" checked=gridsize,10mil SetUnits(mil) SetValue(Grid,10mil)}", -" { \"25 mil\" checked=gridsize,25mil SetUnits(mil) SetValue(Grid,25mil)}", -" { \"50 mil\" checked=gridsize,50mil SetUnits(mil) SetValue(Grid,50mil)}", -" {\"100 mil\" checked=gridsize,100mil SetUnits(mil) SetValue(Grid,100mil)}", -" -", -" {\"0.01 mm\" checked=gridsize,0.01mm SetUnits(mm) SetValue(Grid,0.01mm)}", -" {\"0.05 mm\" checked=gridsize,0.05mm SetUnits(mm) SetValue(Grid,0.05mm)}", -" {\"0.1 mm\" checked=gridsize,0.10mm SetUnits(mm) SetValue(Grid,0.1mm)}", -" {\"0.25 mm\" checked=gridsize,0.25mm SetUnits(mm) SetValue(Grid,0.25mm)}", -" {\"0.5 mm\" checked=gridsize,0.50mm SetUnits(mm) SetValue(Grid,0.5mm)}", -" {\"1 mm\" checked=gridsize,1mm SetUnits(mm) SetValue(Grid,1mm)}", -" -", -" {\"Grid -5mil\" SetValue(Grid,-5,mil) a={\"Shift-G\" \"Shiftg\"}}", -" {\"Grid +5mil\" SetValue(Grid,+5,mil) a={\"G\" \"g\"}}", -" {\"Grid -0.05mm\" SetValue(Grid,-0.05,mm) a={\"Shift-Ctrl-G\" \"Shift Ctrlg\"}}", -" {\"Grid +0.05mm\" SetValue(Grid,+0.05,mm) a={\"Ctrl-G\" \"Ctrlg\"}}", -" }", -" {\"Realign grid\" GetXY(Click to set the grid origin) Display(ToggleGrid)}", -" -", -" {\"Displayed element name\"", -" {\"Description\" Display(Description) checked=elementname,1}", -" {\"Reference Designator\" Display(NameOnPCB) checked=elementname,2}", -" {\"Value\" Display(Value) checked=elementname,3}", -" }", -" {\"Enable Pinout shows number\" checked=shownumber Display(ToggleName)}", -" {\"Pins/Via show Name/Number\" Display(PinOrPadName) a={\"D\" \"d\"}}", -" -", -" {\"Zoom In 20%\" Zoom(-1.2) m=Z a={\"Z\" \"z\"}}", -" {\"Zoom Out 20%\" Zoom(+1.2) m=O a={\"Shift-Z\" \"Shiftz\"}}", -" {\"More zooms and view changes\"", -" {\"Zoom Max\" Zoom() m=M a={\"V\" \"v\"}}", -" {\"Zoom In 2X\" Zoom(-2)}", -" {\"Zoom Out 2X\" Zoom(+2)}", -" {\"Zoom to 0.1mil/px\" Zoom(=0.1mil)}", -" {\"Zoom to 0.01mm/px\" Zoom(=0.01mm)}", -" {\"Zoom to 1mil/px\" Zoom(=1mil)}", -" {\"Zoom to 0.05mm/px\" Zoom(=0.05mm)}", -" {\"Zoom to 2.5mil/px\" Zoom(=2.5mil)}", -" {\"Zoom to 0.1mm/px\" Zoom(=0.1mm)}", -" {\"Zoom to 10mil/px\" Zoom(=10mil)}", -" {\"Zoom In 20% and center\" Zoom(-1.2) Center() m=Z }", -" {\"Zoom Out 20% and center\" Zoom(+1.2) Center() m=O }", -" {\"Flip up/down\" checked=flip_y SwapSides(V) a={\"Tab\" \"Tab\"}}", -" {\"Flip left/right\" checked=flip_x SwapSides(H) a={\"Shift-Tab\" \"ShiftTab\"}}", -" {\"Spin 180 degrees\" SwapSides(R) a={\"Ctrl-Tab\" \"CtrlTab\"}}", -" {\"Swap Sides\" SwapSides() a={\"Ctrl-Shift-Tab\" \"Ctrl ShiftTab\"}}", -" {\"Center cursor\" Center() a={\"C\" \"c\"}}", -" }", -" -", -" {\"Shown Layers\"", -" @layerview", -" -", -" {\"Edit Layer Groups\" EditLayerGroups()}", -" }", -" {\"Current Layer\"", -" @layerpick", -" -", -" {\"Delete current layer\" MoveLayer(c,-1)}", -" {\"Add new layer\" MoveLayer(-1,c)}", -" {\"Move current layer up\" MoveLayer(c,up)}", -" {\"Move current layer down\" MoveLayer(c,down)}", -" }", -" }", -"", -"#", -"# Settings menu", -"#", -" {\"Settings\" m=S", -" {\"'All-direction' lines\" checked=alldirection Display(Toggle45Degree) a={\".\" \".\"}}", -" {\"Auto swap line start angle\" checked=swapstartdir Display(ToggleStartDirection)}", -" {\"Orthogonal moves\" checked=orthomove Display(ToggleOrthoMove)}", -" {\"Crosshair snaps to pins and pads\" checked=snappin Display(ToggleSnapPin)}", -" {\"Crosshair shows DRC clearance\" checked=showdrc Display(ToggleShowDRC)}", -" {\"Auto enforce DRC clearance\" checked=autodrc Display(ToggleAutoDRC)}", -" {\"Lock Names\" checked=locknames Display(ToggleLockNames)}", -" {\"Only Names\" checked=onlynames Display(ToggleOnlyNames)}", -" {\"Hide Names\" checked=hidenames Display(ToggleHideNames)}", -" {\"Mincut on shorts\" checked=enablemincut Display(ToggleMinCut)}", -" -", -" {\"Rubber band mode\" checked=rubberband Display(ToggleRubberBandMode)}", -" {\"Require unique element names\" checked=uniquename Display(ToggleUniqueNames)}", -" {\"Auto-zero delta measurements\" checked=localref Display(ToggleLocalRef)}", -" {\"New lines, arcs clear polygons\" checked=clearnew Display(ToggleClearLine)}", -" {\"New polygons are full ones\" checked=newfullpoly Display(ToggleFullPoly)}", -" {\"Show autorouter trials\" checked=liveroute Display(ToggleLiveRoute)}", -" {\"Thin draw\" checked=thindraw Display(ToggleThindraw) a={\"|\" \"|\"}}", -" {\"Thin draw poly\" checked=thindrawpoly Display(ToggleThindrawPoly) a={\"Ctrl-Shift-P\" \"Ctrl Shiftp\"}}", -" {\"Check polygons\" checked=checkplanes Display(ToggleCheckPlanes)}", -" -", -" {\"Vendor drill mapping\" ToggleVendor() checked=VendorMapOn}", -" {\"Import New Elements at\" m=I", -" {\" Center\" Import(setnewpoint,center) m=C}", -" {\" Mark\" Import(setnewpoint,mark) m=M}", -" {\" Crosshair\" Import(setnewpoint) m=h}", -" -", -" {\"Set Dispersion\" Import(setdisperse) m=D}", -" }", -" }", -"", -"#", -"# Select menu", -"#", -" {\"Select\" m=l", -" {\"Select all visible objects\" Select(All)}", -" {\"Select all connected objects\" Select(Connection)}", -" -", -" {\"Unselect all objects\" Unselect(All)}", -" {\"unselect all connected objects\" Unselect(Connection)}", -" -", -" {\"Select by name\"", -" {\"All objects\" Select(ObjectByName) active=have_regex}", -" {\"Elements\" Select(ElementByName) active=have_regex}", -" {\"Pads\" Select(PadByName) active=have_regex}", -" {\"Pins\" Select(PinByName) active=have_regex}", -" {\"Text\" Select(TextByName) active=have_regex}", -" {\"Vias\" Select(ViaByName) active=have_regex}", -" }", -" -", -" {\"Auto-place selected elements\" AutoPlaceSelected() a={\"Ctrl-P\" \"Ctrlp\"}}", -" {\"Disperse all elements\" DisperseElements(All)}", -" {\"Disperse selected elements\" DisperseElements(Selected)}", -" -", -" {\"Move selected elements to other side\" Flip(SelectedElements) a={\"Shift-B\" \"Shiftb\"}}", -" {\"Move selected to current layer\" MoveToCurrentLayer(Selected) a={\"Shift-M\" \"Shiftm\"}}", -" {\"Remove selected objects\" RemoveSelected() a={\"Shift-Delete\" \"ShiftDelete\"}}", -" {\"Convert selection to element\" Select(Convert)}", -" -", -" {\"Optimize selected rats\" DeleteRats(SelectedRats) AddRats(SelectedRats)}", -" {\"Auto-route selected rats\" AutoRoute(SelectedRats) a={\"Alt-R\" \"Altr\"}}", -" {\"Rip up selected auto-routed tracks\" RipUp(Selected)}", -" -", -" {\"Change size of selected objects\"", -" {\"Lines -10 mil\" ChangeSize(SelectedLines,-10,mil) ChangeSize(SelectedArcs,-10,mil)}", -" {\"Lines +10 mil\" ChangeSize(SelectedLines,+10,mil) ChangeSize(SelectedArcs,+10,mil)}", -" {\"Pads -10 mil\" ChangeSize(SelectedPads,-10,mil)}", -" {\"Pads +10 mil\" ChangeSize(SelectedPads,+10,mil)}", -" {\"Pins -10 mil\" ChangeSize(SelectedPins,-10,mil)}", -" {\"Pins +10 mil\" ChangeSize(SelectedPins,+10,mil)}", -" {\"Texts -10 mil\" ChangeSize(SelectedTexts,-10,mil)}", -" {\"Texts +10 mil\" ChangeSize(SelectedTexts,+10,mil)}", -" {\"Vias -10 mil\" ChangeSize(SelectedVias,-10,mil)}", -" {\"Vias +10 mil\" ChangeSize(SelectedVias,+10,mil)}", -" }", -" -", -" {\"Change drilling hole of selected objects\"", -" {\"Vias -10 mil\" ChangeDrillSize(SelectedVias,-10,mil)}", -" {\"Vias +10 mil\" ChangeDrillSize(SelectedVias,+10,mil)}", -" {\"Pins -10 mil\" ChangeDrillSize(SelectedPins,-10,mil)}", -" {\"Pins +10 mil\" ChangeDrillSize(SelectedPins,+10,mil)}", -" }", -" -", -" {\"Change square-flag of selected objects\"", -" {\"Elements\" ChangeSquare(SelectedElements)}", -" {\"Pins\" ChangeSquare(SelectedPins)}", -" }", -" }", -"", -"#", -"# Buffer menu", -"#", -" {\"Buffer\" m=B", -" {\"Cut selection to buffer\" GetXY(Click to set the snap point for this buffer)", -" PasteBuffer(Clear) PasteBuffer(AddSelected) RemoveSelected() Mode(PasteBuffer)}", -" {\"Paste buffer to layout\" Mode(PasteBuffer)}", -" -", -" {\"Rotate buffer 90 deg CCW\" Mode(PasteBuffer) PasteBuffer(Rotate,1)", -" a={\"Shift-F7\" \"ShiftF7\"}}", -" {\"Rotate buffer 90 deg CW\" Mode(PasteBuffer) PasteBuffer(Rotate,3)}", -" {\"Arbitrarily Rotate Buffer\" Mode(PasteBuffer) FreeRotateBuffer()}", -" {\"Mirror buffer (up/down)\" Mode(PasteBuffer) PasteBuffer(Mirror)}", -" {\"Mirror buffer (left/right)\" Mode(PasteBuffer) PasteBuffer(Rotate,1)", -" PasteBuffer(Mirror) PasteBuffer(Rotate,3)}", -" -", -" {\"Clear buffer\" PasteBuffer(Clear)}", -" {\"Convert buffer to element\" PasteBuffer(Convert)}", -" {\"Break buffer elements to pieces\" PasteBuffer(Restore)}", -" {\"Save buffer elements to file\" Save(PasteBuffer)}", -" -", -" {\"Select Buffer #1\" checked=buffer,1 PasteBuffer(1) m=1 a={\"Shift-1\" \"Shift1\"}}", -" {\"Select Buffer #2\" checked=buffer,2 PasteBuffer(2) m=2 a={\"Shift-2\" \"Shift2\"}}", -" {\"Select Buffer #3\" checked=buffer,3 PasteBuffer(3) m=3 a={\"Shift-3\" \"Shift3\"}}", -" {\"Select Buffer #4\" checked=buffer,4 PasteBuffer(4) m=4 a={\"Shift-4\" \"Shift4\"}}", -" {\"Select Buffer #5\" checked=buffer,5 PasteBuffer(5) m=5 a={\"Shift-5\" \"Shift5\"}}", -" }", -"", -"#", -"# Connects menu", -"#", -" {\"Connects\" m=C", -" {\"Lookup connection to object\" GetXY(Click on the object) Connection(Find) a={\"Ctrl-F\" \"Ctrlf\"}}", -" {\"Reset scanned pads/pins/vias\" Connection(ResetPinsViasAndPads) Display(Redraw)}", -" {\"Reset scanned lines/polygons\" Connection(ResetLinesAndPolygons) Display(Redraw)}", -" {\"Reset all connections\" Connection(Reset) Display(Redraw) a={\"Shift-F\" \"Shiftf\"}}", -" -", -" {\"Optimize rats nest\" Atomic(Save) DeleteRats(AllRats)", -" Atomic(Restore) AddRats(AllRats) Atomic(Block) a={\"O\" \"o\"}}", -" {\"Erase rats nest\" DeleteRats(AllRats) a={\"E\" \"e\"}}", -" {\"Erase selected rats\" DeleteRats(SelectedRats) a={\"Shift-E\" \"Shifte\"}}", -" -", -" {\"Auto-route selected rats\" AutoRoute(Selected)}", -" {\"Auto-route all rats\" AutoRoute(AllRats)}", -" {\"Rip up all auto-routed tracks\" RipUp(All)}", -" -", -" {\"Optimize routed tracks\"", -" {\"Auto-Optimize\" djopt(auto) a={\"Shift-=\" \"Shift=\"}}", -" {\"Debumpify\" djopt(debumpify) }", -" {\"Unjaggy\" djopt(unjaggy) }", -" {\"Vianudge\" djopt(vianudge) }", -" {\"Viatrim\" djopt(viatrim) }", -" {\"Ortho pull\" djopt(orthopull) }", -" {\"Simple optimization\" djopt(simple) a={\"=\" \"=\"}}", -" {\"Miter\" djopt(miter) }", -" {\"Puller\" a={\"Y\" \"y\"} Puller() }", -" {\"Global Puller\"", -" {\"Selected\" GlobalPuller(selected) }", -" {\"Found\" GlobalPuller(found) }", -" {\"All\" GlobalPuller() }", -" }", -" -", -" {\"Only autorouted nets\" OptAutoOnly() checked=optautoonly}", -" }", -" -", -" {\"Design Rule Checker\" DRC()}", -" -", -" {\"Apply vendor drill mapping\" ApplyVendor()}", -" }", -"", -"#", -"# Info Menu", -"#", -" {\"Info\" m=I", -" {\"Generate object report\" ReportObject() a={\"Ctrl-R\" \"Ctrlr\"}}", -" {\"Generate drill summary\" Report(DrillReport)}", -" {\"Report found pins/pads\" Report(FoundPins)}", -" {\"Key Bindings\"", -" {\"Remove\" a={\"Delete\" \"Delete\"}", -" Mode(Save)", -" Mode(Remove)", -" Mode(Notify)", -" Mode(Restore)", -" }", -" {\"Remove Selected\" a={\"Backspace\" \"BackSpace\"}", -" RemoveSelected()", -" }", -" {\"Remove Connected\" a={\"Shift-Backspace\" \"ShiftBackSpace\"}", -" Atomic(Save)", -" Connection(Reset)", -" Atomic(Restore)", -" Unselect(All)", -" Atomic(Restore)", -" Connection(Find)", -" Atomic(Restore)", -" Select(Connection)", -" Atomic(Restore)", -" RemoveSelected()", -" Atomic(Restore)", -" Connection(Reset)", -" Atomic(Restore)", -" Unselect(All)", -" Atomic(Block)", -" }", -" {\"Remove Connected\"", -" Atomic(Save)", -" Connection(Reset)", -" Atomic(Restore)", -" Unselect(All)", -" Atomic(Restore)", -" Connection(Find)", -" Atomic(Restore)", -" Select(Connection)", -" Atomic(Restore)", -" RemoveSelected()", -" Atomic(Restore)", -" Connection(Reset)", -" Atomic(Restore)", -" Unselect(All)", -" Atomic(Block)", -" }", -" {\"Set Same\" a={\"A\" \"a\"} SetSame()}", -" {\"Flip Object\" a={\"B\" \"b\"} Flip(Object)}", -" {\"Find Connections\" a={\"F\" \"f\"} Connection(Reset) Connection(Find)}", -" {\"ToggleHideName Object\" a={\"H\" \"h\"} ToggleHideName(Object)}", -" {\"ToggleHideName SelectedElement\" a={\"Shift-H\" \"Shifth\"} ToggleHideName(SelectedElements)}", -" {\"ChangeHole Object\" a={\"Ctrl-H\" \"Ctrlh\"} ChangeHole(Object)}", -" {\"ChangeJoin Object\" a={\"J\" \"j\"} ChangeJoin(Object)}", -" {\"ChangeJoin SelectedObject\" a={\"Shift-J\" \"Shiftj\"} ChangeJoin(SelectedObjects)}", -" {\"Clear Object +2 mil\" a={\"K\" \"k\"} ChangeClearSize(Object,+2,mil)}", -" {\"Clear Object -2 mil\" a={\"Shift-K\" \"Shiftk\"} ChangeClearSize(Object,-2,mil)}", -" {\"Clear Selected +2 mil\" a={\"Ctrl-K\" \"Ctrlk\"} ChangeClearSize(SelectedObjects,+2,mil)}", -" {\"Clear Selected -2 mil\" a={\"Shift-Ctrl-K\" \"Shift Ctrlk\"} ChangeClearSize(SelectedObjects,-2,mil)}", -" {\"Line Tool size +5 mil\" a={\"L\" \"l\"} SetValue(LineSize,+5,mil)}", -" {\"Line Tool size -5 mil\" a={\"Shift-L\" \"Shiftl\"} SetValue(LineSize,-5,mil)}", -" {\"Move Object to current layer\" a={\"M\" \"m\"} MoveToCurrentLayer(Object)}", -" {\"MarkCrosshair\" a={\"Ctrl-M\" \"Ctrlm\"} MarkCrosshair()}", -" {\"Select shortest rat\" a={\"Shift-N\" \"Shiftn\"} AddRats(Close)}", -" {\"AddRats to selected pins\" a={\"Shift-O\" \"Shifto\"}", -" Atomic(Save)", -" DeleteRats(AllRats)", -" Atomic(Restore)", -" AddRats(SelectedRats)", -" Atomic(Block) }", -" {\"ChangeOctagon Object\" a={\"Ctrl-O\" \"Ctrlo\"} ChangeOctagon(Object)}", -" {\"Polygon PreviousPoint\" a={\"P\" \"p\"} Polygon(PreviousPoint)}", -" {\"Polygon Close\" a={\"Shift-P\" \"Shiftp\"} Polygon(Close)}", -" {\"ChangeSquare Object\" a={\"Q\" \"q\"} ChangeSquare(ToggleObject)}", -" {\"ChangeSize +5 mil\" a={\"S\" \"s\"} ChangeSize(Object,+5,mil)}", -" {\"ChangeSize -5 mil\" a={\"Shift-S\" \"Shifts\"} ChangeSize(Object,-5,mil)}", -" {\"ChangeDrill +5 mil\" a={\"Alt-S\" \"Alts\"} ChangeDrillSize(Object,+5,mil)}", -" {\"ChangeDrill -5 mil\" a={\"Alt-Shift-S\" \"Alt Shifts\"} ChangeDrillSize(Object,-5,mil)}", -" {\"Text Tool scale +10 mil\" a={\"T\" \"t\"} SetValue(TextScale,+10,mil)}", -" {\"Text Tool scale -10 mil\" a={\"Shift-T\" \"Shiftt\"} SetValue(TextScale,-10,mil)}", -" {\"Via Tool size +5 mil\" a={\"Shift-V\" \"Shiftv\"} SetValue(ViaSize,+5,mil)}", -" {\"Via Tool size -5 mil\" a={\"Shift-Ctrl-V\" \"Shift Ctrlv\"} SetValue(ViaSize,-5,mil)}", -" {\"Via Tool drill +5 mil\" a={\"Alt-V\" \"Altv\"} SetValue(ViaDrillingHole,+5,mil)}", -" {\"Via Tool drill -5 mil\" a={\"Alt-Shift-V\" \"Alt Shiftv\"} SetValue(ViaDrillingHole,-5,mil)}", -" {\"AddRats Selected\" a={\"Shift-W\" \"Shiftw\"} AddRats(SelectedRats)}", -" {\"Add All Rats\" a={\"W\" \"w\"} AddRats(AllRats)}", -" {\"Cycle Clip\" a={\"/\" \"/\"} Display(CycleClip)}", -" {\"Arrow Mode\" a={\"Space\" \"space\"} Mode(Arrow) checked=arrowmode,1}", -" {\"Temp Arrow ON\" a={\"[\" \"[\"} Mode(Save) Mode(Arrow) Mode(Notify)}", -" {\"Temp Arrow OFF\" a={\"]\" \"]\"} Mode(Release) Mode(Restore)}", -" -", -" {\"Step Up\" a={\"Up\" \"Up\"} Cursor(Warp,0,1,grid)}", -" {\"Step Down\" a={\"Down\" \"Down\"} Cursor(Warp,0,-1,grid)}", -" {\"Step Left\" a={\"Left\" \"Left\"} Cursor(Warp,-1,0,grid)}", -" {\"Step Right\" a={\"Right\" \"Right\"} Cursor(Warp,1,0,grid)}", -" {\"Step +Up\" a={\"Up\" \"ShiftUp\"} Cursor(Pan,0,50,view)}", -" {\"Step +Down\" a={\"Down\" \"ShiftDown\"} Cursor(Pan,0,-50,view)}", -" {\"Step +Left\" a={\"Left\" \"ShiftLeft\"} Cursor(Pan,-50,0,view)}", -" {\"Step +Right\" a={\"Right\" \"ShiftRight\"} Cursor(Pan,50,0,view)}", -" {'\"Click\"' a={\"Enter\" \"Enter\"} Mode(Notify) Mode(Release)}", -" -", -" }", -" }", -"", -"#", -"# Window Menu", -"#", -" {\"Window\" m=W", -" {\"Library\" DoWindows(Library) a={\"i\" \"i\"}}", -" {\"Message Log\" DoWindows(Log)}", -" {\"DRC Check\" DoWindows(DRC)}", -" {\"Netlist\" DoWindows(Netlist)}", -" {\"Command Entry\" Command() a={\":\" \":\"}}", -" {\"Pinout\" Display(Pinout) a={\"Shift-D\" \"Shiftd\"}}", -" -", -" {\"About...\" About()}", -" }", -"}", -"", -"PopupMenus =", -" {", -" Popup1 =", -" {", -" {\"Operations on selections\"", -" {\"Unselect all objects\" Unselect(All)}", -" {\"Remove selected objects\" RemoveSelected()}", -" {\"Copy selection to buffer\"", -" GetXY(Click to set the snap point for this buffer)", -" PasteBuffer(Clear)", -" PasteBuffer(AddSelected)", -" Mode(PasteBuffer)", -" }", -" {\"Cut selection to buffer\"", -" GetXY(Click to set the snap point for this buffer)", -" PasteBuffer(Clear)", -" PasteBuffer(AddSelected)", -" RemoveSelected()", -" Mode(PasteBuffer)", -" }", -" {\"Convert selection to element\" Select(Convert)}", -" {\"Auto place selected elements\" AutoPlaceSelected()}", -" {\"Autoroute selected elements\" AutoRoute(SelectedRats)}", -" {\"Rip up selected auto-routed tracks\" RipUp(Selected)}", -" }", -" {\"Operations on this location\"", -" {\"Generate object report\" GetXY(Click on the object) Report(Object)}", -" }", -" -", -" {\"Undo last operation\" Undo()}", -" {\"Redo last undone operation\" Redo()}", -" -", -" {Tools", -" {\"None\" checked=nomode,1 Mode(None)}", -" {\"Via\" checked=viamode,1 Mode(Via) a={\"F1\" \"F1\"}}", -" {\"Line\" checked=linemode,1 Mode(Line) a={\"F2\" \"F2\"}}", -" {\"Arc\" checked=arcmode,1 Mode(Arc) a={\"F3\" \"F3\"}}", -" {\"Text\" checked=textmode,1 Mode(Text) a={\"F4\" \"F4\"}}", -" {\"Rectangle\" checked=rectanglemode,1 Mode(Rectangle) a={\"F5\" \"F5\"}}", -" {\"Polygon\" checked=polygonmode,1 Mode(Polygon) a={\"F6\" \"F6\"}}", -" {\"Polygon Hole\" checked=polygonholemode,1 Mode(PolygonHole)}", -" {\"Buffer\" checked=pastebuffermode,1 Mode(PasteBuffer) a={\"F7\" \"F7\"}}", -" {\"Remove\" checked=removemode,1 Mode(Remove) a={\"F8\" \"F8\"}}", -" {\"Rotate\" checked=rotatemode,1 Mode(Rotate) a={\"F9\" \"F9\"}}", -" {\"Thermal\" checked=thermalmode,1 Mode(Thermal) a={\"F10\" \"F10\"}}", -" {\"Arrow\" checked=arrowmode,1 Mode(Arrow) a={\"F11\" \"F11\"}}", -" {\"Insert Point\" checked=insertpointmode,1 Mode(InsertPoint) a={\"Insert\" \"Insert\"}}", -" {\"Move\" checked=movemode,1 Mode(Move)}", -" {\"Copy\" checked=copymode,1 Mode(Copy)}", -" {\"Lock\" checked=lockmode,1 Mode(Lock) a={\"F12\" \"F12\"}}", -" {\"Cancel\" Mode(Escape) a={\"Esc\" \"Escape\"}}", -" }", -" }", -" }", -"", -0}; + "# -*- c -*-", + "# Note - gpcb-menu.res is used to build gpcb-menu.h", + "# Note - parameters are sensitive to extra spaces around the commas", + "", + "Mouse =", + "{", + " Left = {", + " Mode(Notify)", + " ctrl = { Mode(Save) Mode(None) Mode(Restore) Mode(Notify) }", + " shift-ctrl = { Mode(Save) Mode(Remove) Mode(Notify) Mode(Restore) }", + " up = Mode(Release)", + " }", + " Right = {", + " Pan(1)", + " up = Pan(0)", + " shift = Popup(Popup1)", + " ctrl = Display(CycleCrosshair)", + " }", + " Middle = {", + " Mode(Stroke)", + " up = Mode(Release)", + " ctrl = { Mode(Save) Mode(Copy) Mode(Notify) }", + " up-ctrl = { Mode(Notify) Mode(Restore) }", + " shift-ctrl = { Display(ToggleRubberbandMode) Mode(Save) Mode(Move) Mode(Notify) }", + " up-shift-ctrl = { Mode(Notify) Mode(Restore) Display(ToggleRubberbandMode) }", + " }", + " Up = {", + " Zoom(0.8)", + " shift = Scroll(up)", + " ctrl = Scroll(left)", + " }", + " Down = {", + " Zoom(1.25)", + " shift = Scroll(down)", + " ctrl = Scroll(right)", + " }", + "# If you want zoom to center, do this instead.", + " #Up = { {Zoom(0.8) Center()} }", + " #Down = { {Zoom(1.25) Center()} }", + "}", + "", + "MainMenu =", + "{", + "", + "#", + "# File Menu", + "#", + " {\"File\" m=F", + " {\"Save Layout\" Save(Layout) tip=\"Saves current layout\" m=S a={\"Ctrl-S\" \"Ctrls\"}}", + " {\"Save Layout As...\" Save(LayoutAs) tip=\"Saves current layout into a new file\" m=A a={\"Shift Ctrl-S\" \"Shift Ctrls\"}}", + " -", + " {\"Revert\" Load(Revert,none) tip=\"Revert to the layout stored on disk\"}", + " -", + " {\"Import Schematics\" Import() }", + " {\"Load layout\" Load(Layout) tip=\"Load a layout from a file\"}", + " {\"Load element data to paste-buffer\" PasteBuffer(Clear) Load(ElementTobuffer)}", + " {\"Load layout data to paste-buffer\" PasteBuffer(Clear) Load(LayoutTobuffer)}", + " {\"Load netlist file\" Load(Netlist)}", + " {\"Load vendor resource file\" LoadVendorFrom()}", + " -", + " {\"Save connection data of\"", + " {\" a single element\" GetXY(Click to set the element mark <>) Save(ElementConnections)}", + " {\" all elements\" Save(AllConnections)}", + " {\" unused pins\" Save(AllUnusedPins)}", + " }", + " -", + " {\"Print layout...\" Print()}", + " {\"Export layout...\" Export()}", + " {\"Calibrate Printer...\" PrintCalibrate()}", + " -", + " {\"Start New Layout\" New() a={\"Ctrl-N\" \"Ctrln\"}}", + " -", + " {\"Preferences...\" DoWindows(Preferences)}", + " -", + " {\"Quit Program\" Quit() a={\"Ctrl-Q\" \"Ctrlq\"}}", + " }", + "", + "#", + "# Edit Menu", + "#", + " {\"Edit\" m=E", + " {\"Undo last operation\" Undo() a={\"U\" \"u\"}}", + " {\"Redo last undone operation\" Redo() a={\"Shift-R\" \"Shiftr\"}}", + " {\"Clear undo-buffer\" Undo(ClearList) a={\"Shift-Ctrl-U\" \"Shift Ctrlu\"}}", + " -", + " {\"Cut selection to buffer\" GetXY(Click to set the snap point for this buffer)", + " PasteBuffer(Clear) PasteBuffer(AddSelected) RemoveSelected() Mode(PasteBuffer)", + " a={\"Ctrl-X\" \"Ctrlx\"}}", + " {\"Copy selection to buffer\" GetXY(Click to set the snap point for this buffer)", + " PasteBuffer(Clear) PasteBuffer(AddSelected) Unselect(All) Mode(PasteBuffer)", + " a={\"Ctrl-C\" \"Ctrlc\"}}", + " {\"Paste buffer to layout\" Mode(PasteBuffer) a={\"Ctrl-V\" \"Ctrlv\"}}", + " -", + " {\"Unselect all\" Unselect(All) a={\"Shift-Alt-A\" \"Shift Alta\"}}", + " {\"Select all visible\" Select(All) a={\"Alt-A\" \"Alta\"}}", + " -", + " {\"Edit name of\"", + " {\"text on layout\" ChangeName(Object) a={\"N\" \"n\"}}", + " {\"layout\" ChangeName(Layout)}", + " {\"active layer\" ChangeName(Layer)}", + " }", + " {\"Edit attributes of\"", + " {\"Layout\" Attributes(Layout)}", + " {\"CurrentLayer\" Attributes(Layer)}", + " {\"Element\" Attributes(Element)}", + " }", + " {\"Change flags\"", + " {\"Nonetlist\" ChangeNonetlist(Element) a={\"Alt-N\" \"Altn\"}}", + " }", + " -", + " {\"Route Styles\" @routestyles", + " -", + " {\"Edit...\" AdjustStyle(0)}", + " }", + " }", + "", + "#", + "# View Menu", + "#", + " {\"View\" m=V", + " {\"Enable visible grid\" checked=drawgrid Display(Grid)}", + " {\"Grid units\"", + " {\"mil\" checked=grid_units_mil,1 SetUnits(mil)}", + " {\"mm\" checked=grid_units_mm,1 SetUnits(mm)}", + " }", + " {\"Grid size\"", + " {\"No Grid\" checked=grid,0 SetValue(Grid,1)}", + " -", + " { \"0.1 mil\" checked=gridsize,0.1mil SetUnits(mil) SetValue(Grid,0.1mil)}", + " { \"1 mil\" checked=gridsize,1mil SetUnits(mil) SetValue(Grid,1mil)}", + " { \"5 mil\" checked=gridsize,5mil SetUnits(mil) SetValue(Grid,5mil)}", + " { \"10 mil\" checked=gridsize,10mil SetUnits(mil) SetValue(Grid,10mil)}", + " { \"25 mil\" checked=gridsize,25mil SetUnits(mil) SetValue(Grid,25mil)}", + " { \"50 mil\" checked=gridsize,50mil SetUnits(mil) SetValue(Grid,50mil)}", + " {\"100 mil\" checked=gridsize,100mil SetUnits(mil) SetValue(Grid,100mil)}", + " -", + " {\"0.01 mm\" checked=gridsize,0.01mm SetUnits(mm) SetValue(Grid,0.01mm)}", + " {\"0.05 mm\" checked=gridsize,0.05mm SetUnits(mm) SetValue(Grid,0.05mm)}", + " {\"0.1 mm\" checked=gridsize,0.10mm SetUnits(mm) SetValue(Grid,0.1mm)}", + " {\"0.25 mm\" checked=gridsize,0.25mm SetUnits(mm) SetValue(Grid,0.25mm)}", + " {\"0.5 mm\" checked=gridsize,0.50mm SetUnits(mm) SetValue(Grid,0.5mm)}", + " {\"1 mm\" checked=gridsize,1mm SetUnits(mm) SetValue(Grid,1mm)}", + " -", + " {\"Grid -5mil\" SetValue(Grid,-5,mil) a={\"Shift-G\" \"Shiftg\"}}", + " {\"Grid +5mil\" SetValue(Grid,+5,mil) a={\"G\" \"g\"}}", + " {\"Grid -0.05mm\" SetValue(Grid,-0.05,mm) a={\"Shift-Ctrl-G\" \"Shift Ctrlg\"}}", + " {\"Grid +0.05mm\" SetValue(Grid,+0.05,mm) a={\"Ctrl-G\" \"Ctrlg\"}}", + " }", + " {\"Realign grid\" GetXY(Click to set the grid origin) Display(ToggleGrid)}", + " -", + " {\"Displayed element name\"", + " {\"Description\" Display(Description) checked=elementname,1}", + " {\"Reference Designator\" Display(NameOnPCB) checked=elementname,2}", + " {\"Value\" Display(Value) checked=elementname,3}", + " }", + " {\"Enable Pinout shows number\" checked=shownumber Display(ToggleName)}", + " {\"Pins/Via show Name/Number\" Display(PinOrPadName) a={\"D\" \"d\"}}", + " -", + " {\"Zoom In 20%\" Zoom(-1.2) m=Z a={\"Z\" \"z\"}}", + " {\"Zoom Out 20%\" Zoom(+1.2) m=O a={\"Shift-Z\" \"Shiftz\"}}", + " {\"More zooms and view changes\"", + " {\"Zoom Max\" Zoom() m=M a={\"V\" \"v\"}}", + " {\"Zoom In 2X\" Zoom(-2)}", + " {\"Zoom Out 2X\" Zoom(+2)}", + " {\"Zoom to 0.1mil/px\" Zoom(=0.1mil)}", + " {\"Zoom to 0.01mm/px\" Zoom(=0.01mm)}", + " {\"Zoom to 1mil/px\" Zoom(=1mil)}", + " {\"Zoom to 0.05mm/px\" Zoom(=0.05mm)}", + " {\"Zoom to 2.5mil/px\" Zoom(=2.5mil)}", + " {\"Zoom to 0.1mm/px\" Zoom(=0.1mm)}", + " {\"Zoom to 10mil/px\" Zoom(=10mil)}", + " {\"Zoom In 20% and center\" Zoom(-1.2) Center() m=Z }", + " {\"Zoom Out 20% and center\" Zoom(+1.2) Center() m=O }", + " {\"Flip up/down\" checked=flip_y SwapSides(V) a={\"Tab\" \"Tab\"}}", + " {\"Flip left/right\" checked=flip_x SwapSides(H) a={\"Shift-Tab\" \"ShiftTab\"}}", + " {\"Spin 180 degrees\" SwapSides(R) a={\"Ctrl-Tab\" \"CtrlTab\"}}", + " {\"Swap Sides\" SwapSides() a={\"Ctrl-Shift-Tab\" \"Ctrl ShiftTab\"}}", + " {\"Center cursor\" Center() a={\"C\" \"c\"}}", + " }", + " -", + " {\"Shown Layers\"", + " @layerview", + " -", + " {\"Edit Layer Groups\" EditLayerGroups()}", + " }", + " {\"Current Layer\"", + " @layerpick", + " -", + " {\"Delete current layer\" MoveLayer(c,-1)}", + " {\"Add new layer\" MoveLayer(-1,c)}", + " {\"Move current layer up\" MoveLayer(c,up)}", + " {\"Move current layer down\" MoveLayer(c,down)}", + " }", + " }", + "", + "#", + "# Settings menu", + "#", + " {\"Settings\" m=S", + " {\"'All-direction' lines\" checked=alldirection Display(Toggle45Degree) a={\".\" \".\"}}", + " {\"Auto swap line start angle\" checked=swapstartdir Display(ToggleStartDirection)}", + " {\"Orthogonal moves\" checked=orthomove Display(ToggleOrthoMove)}", + " {\"Crosshair snaps to pins and pads\" checked=snappin Display(ToggleSnapPin)}", + " {\"Crosshair shows DRC clearance\" checked=showdrc Display(ToggleShowDRC)}", + " {\"Auto enforce DRC clearance\" checked=autodrc Display(ToggleAutoDRC)}", + " {\"Lock Names\" checked=locknames Display(ToggleLockNames)}", + " {\"Only Names\" checked=onlynames Display(ToggleOnlyNames)}", + " {\"Hide Names\" checked=hidenames Display(ToggleHideNames)}", + " {\"Mincut on shorts\" checked=enablemincut Display(ToggleMinCut)}", + " -", + " {\"Rubber band mode\" checked=rubberband Display(ToggleRubberBandMode)}", + " {\"Require unique element names\" checked=uniquename Display(ToggleUniqueNames)}", + " {\"Auto-zero delta measurements\" checked=localref Display(ToggleLocalRef)}", + " {\"New lines, arcs clear polygons\" checked=clearnew Display(ToggleClearLine)}", + " {\"New polygons are full ones\" checked=newfullpoly Display(ToggleFullPoly)}", + " {\"Show autorouter trials\" checked=liveroute Display(ToggleLiveRoute)}", + " {\"Thin draw\" checked=thindraw Display(ToggleThindraw) a={\"|\" \"|\"}}", + " {\"Thin draw poly\" checked=thindrawpoly Display(ToggleThindrawPoly) a={\"Ctrl-Shift-P\" \"Ctrl Shiftp\"}}", + " {\"Check polygons\" checked=checkplanes Display(ToggleCheckPlanes)}", + " -", + " {\"Vendor drill mapping\" ToggleVendor() checked=VendorMapOn}", + " {\"Import New Elements at\" m=I", + " {\" Center\" Import(setnewpoint,center) m=C}", + " {\" Mark\" Import(setnewpoint,mark) m=M}", + " {\" Crosshair\" Import(setnewpoint) m=h}", + " -", + " {\"Set Dispersion\" Import(setdisperse) m=D}", + " }", + " }", + "", + "#", + "# Select menu", + "#", + " {\"Select\" m=l", + " {\"Select all visible objects\" Select(All)}", + " {\"Select all connected objects\" Select(Connection)}", + " -", + " {\"Unselect all objects\" Unselect(All)}", + " {\"unselect all connected objects\" Unselect(Connection)}", + " -", + " {\"Select by name\"", + " {\"All objects\" Select(ObjectByName) active=have_regex}", + " {\"Elements\" Select(ElementByName) active=have_regex}", + " {\"Pads\" Select(PadByName) active=have_regex}", + " {\"Pins\" Select(PinByName) active=have_regex}", + " {\"Text\" Select(TextByName) active=have_regex}", + " {\"Vias\" Select(ViaByName) active=have_regex}", + " }", + " -", + " {\"Auto-place selected elements\" AutoPlaceSelected() a={\"Ctrl-P\" \"Ctrlp\"}}", + " {\"Disperse all elements\" DisperseElements(All)}", + " {\"Disperse selected elements\" DisperseElements(Selected)}", + " -", + " {\"Move selected elements to other side\" Flip(SelectedElements) a={\"Shift-B\" \"Shiftb\"}}", + " {\"Move selected to current layer\" MoveToCurrentLayer(Selected) a={\"Shift-M\" \"Shiftm\"}}", + " {\"Remove selected objects\" RemoveSelected() a={\"Shift-Delete\" \"ShiftDelete\"}}", + " {\"Convert selection to element\" Select(Convert)}", + " -", + " {\"Optimize selected rats\" DeleteRats(SelectedRats) AddRats(SelectedRats)}", + " {\"Auto-route selected rats\" AutoRoute(SelectedRats) a={\"Alt-R\" \"Altr\"}}", + " {\"Rip up selected auto-routed tracks\" RipUp(Selected)}", + " -", + " {\"Change size of selected objects\"", + " {\"Lines -10 mil\" ChangeSize(SelectedLines,-10,mil) ChangeSize(SelectedArcs,-10,mil)}", + " {\"Lines +10 mil\" ChangeSize(SelectedLines,+10,mil) ChangeSize(SelectedArcs,+10,mil)}", + " {\"Pads -10 mil\" ChangeSize(SelectedPads,-10,mil)}", + " {\"Pads +10 mil\" ChangeSize(SelectedPads,+10,mil)}", + " {\"Pins -10 mil\" ChangeSize(SelectedPins,-10,mil)}", + " {\"Pins +10 mil\" ChangeSize(SelectedPins,+10,mil)}", + " {\"Texts -10 mil\" ChangeSize(SelectedTexts,-10,mil)}", + " {\"Texts +10 mil\" ChangeSize(SelectedTexts,+10,mil)}", + " {\"Vias -10 mil\" ChangeSize(SelectedVias,-10,mil)}", + " {\"Vias +10 mil\" ChangeSize(SelectedVias,+10,mil)}", + " }", + " -", + " {\"Change drilling hole of selected objects\"", + " {\"Vias -10 mil\" ChangeDrillSize(SelectedVias,-10,mil)}", + " {\"Vias +10 mil\" ChangeDrillSize(SelectedVias,+10,mil)}", + " {\"Pins -10 mil\" ChangeDrillSize(SelectedPins,-10,mil)}", + " {\"Pins +10 mil\" ChangeDrillSize(SelectedPins,+10,mil)}", + " }", + " -", + " {\"Change square-flag of selected objects\"", + " {\"Elements\" ChangeSquare(SelectedElements)}", + " {\"Pins\" ChangeSquare(SelectedPins)}", + " }", + " }", + "", + "#", + "# Buffer menu", + "#", + " {\"Buffer\" m=B", + " {\"Cut selection to buffer\" GetXY(Click to set the snap point for this buffer)", + " PasteBuffer(Clear) PasteBuffer(AddSelected) RemoveSelected() Mode(PasteBuffer)}", + " {\"Paste buffer to layout\" Mode(PasteBuffer)}", + " -", + " {\"Rotate buffer 90 deg CCW\" Mode(PasteBuffer) PasteBuffer(Rotate,1)", + " a={\"Shift-F7\" \"ShiftF7\"}}", + " {\"Rotate buffer 90 deg CW\" Mode(PasteBuffer) PasteBuffer(Rotate,3)}", + " {\"Arbitrarily Rotate Buffer\" Mode(PasteBuffer) FreeRotateBuffer()}", + " {\"Mirror buffer (up/down)\" Mode(PasteBuffer) PasteBuffer(Mirror)}", + " {\"Mirror buffer (left/right)\" Mode(PasteBuffer) PasteBuffer(Rotate,1)", + " PasteBuffer(Mirror) PasteBuffer(Rotate,3)}", + " -", + " {\"Clear buffer\" PasteBuffer(Clear)}", + " {\"Convert buffer to element\" PasteBuffer(Convert)}", + " {\"Break buffer elements to pieces\" PasteBuffer(Restore)}", + " {\"Save buffer elements to file\" Save(PasteBuffer)}", + " -", + " {\"Select Buffer #1\" checked=buffer,1 PasteBuffer(1) m=1 a={\"Shift-1\" \"Shift1\"}}", + " {\"Select Buffer #2\" checked=buffer,2 PasteBuffer(2) m=2 a={\"Shift-2\" \"Shift2\"}}", + " {\"Select Buffer #3\" checked=buffer,3 PasteBuffer(3) m=3 a={\"Shift-3\" \"Shift3\"}}", + " {\"Select Buffer #4\" checked=buffer,4 PasteBuffer(4) m=4 a={\"Shift-4\" \"Shift4\"}}", + " {\"Select Buffer #5\" checked=buffer,5 PasteBuffer(5) m=5 a={\"Shift-5\" \"Shift5\"}}", + " }", + "", + "#", + "# Connects menu", + "#", + " {\"Connects\" m=C", + " {\"Lookup connection to object\" GetXY(Click on the object) Connection(Find) a={\"Ctrl-F\" \"Ctrlf\"}}", + " {\"Reset scanned pads/pins/vias\" Connection(ResetPinsViasAndPads) Display(Redraw)}", + " {\"Reset scanned lines/polygons\" Connection(ResetLinesAndPolygons) Display(Redraw)}", + " {\"Reset all connections\" Connection(Reset) Display(Redraw) a={\"Shift-F\" \"Shiftf\"}}", + " -", + " {\"Optimize rats nest\" Atomic(Save) DeleteRats(AllRats)", + " Atomic(Restore) AddRats(AllRats) Atomic(Block) a={\"O\" \"o\"}}", + " {\"Erase rats nest\" DeleteRats(AllRats) a={\"E\" \"e\"}}", + " {\"Erase selected rats\" DeleteRats(SelectedRats) a={\"Shift-E\" \"Shifte\"}}", + " -", + " {\"Auto-route selected rats\" AutoRoute(Selected)}", + " {\"Auto-route all rats\" AutoRoute(AllRats)}", + " {\"Rip up all auto-routed tracks\" RipUp(All)}", + " -", + " {\"Optimize routed tracks\"", + " {\"Auto-Optimize\" djopt(auto) a={\"Shift-=\" \"Shift=\"}}", + " {\"Debumpify\" djopt(debumpify) }", + " {\"Unjaggy\" djopt(unjaggy) }", + " {\"Vianudge\" djopt(vianudge) }", + " {\"Viatrim\" djopt(viatrim) }", + " {\"Ortho pull\" djopt(orthopull) }", + " {\"Simple optimization\" djopt(simple) a={\"=\" \"=\"}}", + " {\"Miter\" djopt(miter) }", + " {\"Puller\" a={\"Y\" \"y\"} Puller() }", + " {\"Global Puller\"", + " {\"Selected\" GlobalPuller(selected) }", + " {\"Found\" GlobalPuller(found) }", + " {\"All\" GlobalPuller() }", + " }", + " -", + " {\"Only autorouted nets\" OptAutoOnly() checked=optautoonly}", + " }", + " -", + " {\"Design Rule Checker\" DRC()}", + " -", + " {\"Apply vendor drill mapping\" ApplyVendor()}", + " }", + "", + "#", + "# Info Menu", + "#", + " {\"Info\" m=I", + " {\"Generate object report\" ReportObject() a={\"Ctrl-R\" \"Ctrlr\"}}", + " {\"Generate drill summary\" Report(DrillReport)}", + " {\"Report found pins/pads\" Report(FoundPins)}", + " {\"Key Bindings\"", + " {\"Remove\" a={\"Delete\" \"Delete\"}", + " Mode(Save)", + " Mode(Remove)", + " Mode(Notify)", + " Mode(Restore)", + " }", + " {\"Remove Selected\" a={\"Backspace\" \"BackSpace\"}", + " RemoveSelected()", + " }", + " {\"Remove Connected\" a={\"Shift-Backspace\" \"ShiftBackSpace\"}", + " Atomic(Save)", + " Connection(Reset)", + " Atomic(Restore)", + " Unselect(All)", + " Atomic(Restore)", + " Connection(Find)", + " Atomic(Restore)", + " Select(Connection)", + " Atomic(Restore)", + " RemoveSelected()", + " Atomic(Restore)", + " Connection(Reset)", + " Atomic(Restore)", + " Unselect(All)", + " Atomic(Block)", + " }", + " {\"Remove Connected\"", + " Atomic(Save)", + " Connection(Reset)", + " Atomic(Restore)", + " Unselect(All)", + " Atomic(Restore)", + " Connection(Find)", + " Atomic(Restore)", + " Select(Connection)", + " Atomic(Restore)", + " RemoveSelected()", + " Atomic(Restore)", + " Connection(Reset)", + " Atomic(Restore)", + " Unselect(All)", + " Atomic(Block)", + " }", + " {\"Set Same\" a={\"A\" \"a\"} SetSame()}", + " {\"Flip Object\" a={\"B\" \"b\"} Flip(Object)}", + " {\"Find Connections\" a={\"F\" \"f\"} Connection(Reset) Connection(Find)}", + " {\"ToggleHideName Object\" a={\"H\" \"h\"} ToggleHideName(Object)}", + " {\"ToggleHideName SelectedElement\" a={\"Shift-H\" \"Shifth\"} ToggleHideName(SelectedElements)}", + " {\"ChangeHole Object\" a={\"Ctrl-H\" \"Ctrlh\"} ChangeHole(Object)}", + " {\"ChangeJoin Object\" a={\"J\" \"j\"} ChangeJoin(Object)}", + " {\"ChangeJoin SelectedObject\" a={\"Shift-J\" \"Shiftj\"} ChangeJoin(SelectedObjects)}", + " {\"Clear Object +2 mil\" a={\"K\" \"k\"} ChangeClearSize(Object,+2,mil)}", + " {\"Clear Object -2 mil\" a={\"Shift-K\" \"Shiftk\"} ChangeClearSize(Object,-2,mil)}", + " {\"Clear Selected +2 mil\" a={\"Ctrl-K\" \"Ctrlk\"} ChangeClearSize(SelectedObjects,+2,mil)}", + " {\"Clear Selected -2 mil\" a={\"Shift-Ctrl-K\" \"Shift Ctrlk\"} ChangeClearSize(SelectedObjects,-2,mil)}", + " {\"Line Tool size +5 mil\" a={\"L\" \"l\"} SetValue(LineSize,+5,mil)}", + " {\"Line Tool size -5 mil\" a={\"Shift-L\" \"Shiftl\"} SetValue(LineSize,-5,mil)}", + " {\"Move Object to current layer\" a={\"M\" \"m\"} MoveToCurrentLayer(Object)}", + " {\"MarkCrosshair\" a={\"Ctrl-M\" \"Ctrlm\"} MarkCrosshair()}", + " {\"Select shortest rat\" a={\"Shift-N\" \"Shiftn\"} AddRats(Close)}", + " {\"AddRats to selected pins\" a={\"Shift-O\" \"Shifto\"}", + " Atomic(Save)", + " DeleteRats(AllRats)", + " Atomic(Restore)", + " AddRats(SelectedRats)", + " Atomic(Block) }", + " {\"ChangeOctagon Object\" a={\"Ctrl-O\" \"Ctrlo\"} ChangeOctagon(Object)}", + " {\"Polygon PreviousPoint\" a={\"P\" \"p\"} Polygon(PreviousPoint)}", + " {\"Polygon Close\" a={\"Shift-P\" \"Shiftp\"} Polygon(Close)}", + " {\"ChangeSquare Object\" a={\"Q\" \"q\"} ChangeSquare(ToggleObject)}", + " {\"ChangeSize +5 mil\" a={\"S\" \"s\"} ChangeSize(Object,+5,mil)}", + " {\"ChangeSize -5 mil\" a={\"Shift-S\" \"Shifts\"} ChangeSize(Object,-5,mil)}", + " {\"ChangeDrill +5 mil\" a={\"Alt-S\" \"Alts\"} ChangeDrillSize(Object,+5,mil)}", + " {\"ChangeDrill -5 mil\" a={\"Alt-Shift-S\" \"Alt Shifts\"} ChangeDrillSize(Object,-5,mil)}", + " {\"Text Tool scale +10 mil\" a={\"T\" \"t\"} SetValue(TextScale,+10,mil)}", + " {\"Text Tool scale -10 mil\" a={\"Shift-T\" \"Shiftt\"} SetValue(TextScale,-10,mil)}", + " {\"Via Tool size +5 mil\" a={\"Shift-V\" \"Shiftv\"} SetValue(ViaSize,+5,mil)}", + " {\"Via Tool size -5 mil\" a={\"Shift-Ctrl-V\" \"Shift Ctrlv\"} SetValue(ViaSize,-5,mil)}", + " {\"Via Tool drill +5 mil\" a={\"Alt-V\" \"Altv\"} SetValue(ViaDrillingHole,+5,mil)}", + " {\"Via Tool drill -5 mil\" a={\"Alt-Shift-V\" \"Alt Shiftv\"} SetValue(ViaDrillingHole,-5,mil)}", + " {\"AddRats Selected\" a={\"Shift-W\" \"Shiftw\"} AddRats(SelectedRats)}", + " {\"Add All Rats\" a={\"W\" \"w\"} AddRats(AllRats)}", + " {\"Cycle Clip\" a={\"/\" \"/\"} Display(CycleClip)}", + " {\"Arrow Mode\" a={\"Space\" \"space\"} Mode(Arrow) checked=arrowmode,1}", + " {\"Temp Arrow ON\" a={\"[\" \"[\"} Mode(Save) Mode(Arrow) Mode(Notify)}", + " {\"Temp Arrow OFF\" a={\"]\" \"]\"} Mode(Release) Mode(Restore)}", + " -", + " {\"Step Up\" a={\"Up\" \"Up\"} Cursor(Warp,0,1,grid)}", + " {\"Step Down\" a={\"Down\" \"Down\"} Cursor(Warp,0,-1,grid)}", + " {\"Step Left\" a={\"Left\" \"Left\"} Cursor(Warp,-1,0,grid)}", + " {\"Step Right\" a={\"Right\" \"Right\"} Cursor(Warp,1,0,grid)}", + " {\"Step +Up\" a={\"Up\" \"ShiftUp\"} Cursor(Pan,0,50,view)}", + " {\"Step +Down\" a={\"Down\" \"ShiftDown\"} Cursor(Pan,0,-50,view)}", + " {\"Step +Left\" a={\"Left\" \"ShiftLeft\"} Cursor(Pan,-50,0,view)}", + " {\"Step +Right\" a={\"Right\" \"ShiftRight\"} Cursor(Pan,50,0,view)}", + " {'\"Click\"' a={\"Enter\" \"Enter\"} Mode(Notify) Mode(Release)}", + " -", + " }", + " }", + "", + "#", + "# Window Menu", + "#", + " {\"Window\" m=W", + " {\"Library\" DoWindows(Library) a={\"i\" \"i\"}}", + " {\"Message Log\" DoWindows(Log)}", + " {\"DRC Check\" DoWindows(DRC)}", + " {\"Netlist\" DoWindows(Netlist)}", + " {\"Command Entry\" Command() a={\":\" \":\"}}", + " {\"Pinout\" Display(Pinout) a={\"Shift-D\" \"Shiftd\"}}", + " -", + " {\"About...\" About()}", + " }", + "}", + "", + "PopupMenus =", + " {", + " Popup1 =", + " {", + " {\"Operations on selections\"", + " {\"Unselect all objects\" Unselect(All)}", + " {\"Remove selected objects\" RemoveSelected()}", + " {\"Copy selection to buffer\"", + " GetXY(Click to set the snap point for this buffer)", + " PasteBuffer(Clear)", + " PasteBuffer(AddSelected)", + " Mode(PasteBuffer)", + " }", + " {\"Cut selection to buffer\"", + " GetXY(Click to set the snap point for this buffer)", + " PasteBuffer(Clear)", + " PasteBuffer(AddSelected)", + " RemoveSelected()", + " Mode(PasteBuffer)", + " }", + " {\"Convert selection to element\" Select(Convert)}", + " {\"Auto place selected elements\" AutoPlaceSelected()}", + " {\"Autoroute selected elements\" AutoRoute(SelectedRats)}", + " {\"Rip up selected auto-routed tracks\" RipUp(Selected)}", + " }", + " {\"Operations on this location\"", + " {\"Generate object report\" GetXY(Click on the object) Report(Object)}", + " }", + " -", + " {\"Undo last operation\" Undo()}", + " {\"Redo last undone operation\" Redo()}", + " -", + " {Tools", + " {\"None\" checked=nomode,1 Mode(None)}", + " {\"Via\" checked=viamode,1 Mode(Via) a={\"F1\" \"F1\"}}", + " {\"Line\" checked=linemode,1 Mode(Line) a={\"F2\" \"F2\"}}", + " {\"Arc\" checked=arcmode,1 Mode(Arc) a={\"F3\" \"F3\"}}", + " {\"Text\" checked=textmode,1 Mode(Text) a={\"F4\" \"F4\"}}", + " {\"Rectangle\" checked=rectanglemode,1 Mode(Rectangle) a={\"F5\" \"F5\"}}", + " {\"Polygon\" checked=polygonmode,1 Mode(Polygon) a={\"F6\" \"F6\"}}", + " {\"Polygon Hole\" checked=polygonholemode,1 Mode(PolygonHole)}", + " {\"Buffer\" checked=pastebuffermode,1 Mode(PasteBuffer) a={\"F7\" \"F7\"}}", + " {\"Remove\" checked=removemode,1 Mode(Remove) a={\"F8\" \"F8\"}}", + " {\"Rotate\" checked=rotatemode,1 Mode(Rotate) a={\"F9\" \"F9\"}}", + " {\"Thermal\" checked=thermalmode,1 Mode(Thermal) a={\"F10\" \"F10\"}}", + " {\"Arrow\" checked=arrowmode,1 Mode(Arrow) a={\"F11\" \"F11\"}}", + " {\"Insert Point\" checked=insertpointmode,1 Mode(InsertPoint) a={\"Insert\" \"Insert\"}}", + " {\"Move\" checked=movemode,1 Mode(Move)}", + " {\"Copy\" checked=copymode,1 Mode(Copy)}", + " {\"Lock\" checked=lockmode,1 Mode(Lock) a={\"F12\" \"F12\"}}", + " {\"Cancel\" Mode(Escape) a={\"Esc\" \"Escape\"}}", + " }", + " }", + " }", + "", + 0 +}; Index: trunk/src/heap.c =================================================================== --- trunk/src/heap.c (revision 1021) +++ trunk/src/heap.c (revision 1022) @@ -46,7 +46,7 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); /* define this for more thorough self-checking of data structures */ @@ -59,15 +59,13 @@ /* --------------------------------------------------------------------------- * some local types */ -struct heap_element -{ - cost_t cost; - void *data; +struct heap_element { + cost_t cost; + void *data; }; -struct heap_struct -{ - struct heap_element *element; - int size, max; +struct heap_struct { + struct heap_element *element; + int size, max; }; /* --------------------------------------------------------------------------- @@ -81,111 +79,101 @@ /* helper functions for assertions */ #ifndef NDEBUG #ifdef SLOW_ASSERTIONS -static int -__heap_is_good_slow (heap_t * heap) +static int __heap_is_good_slow(heap_t * heap) { - int i; - /* heap condition: key in each node should be smaller than in its children */ - /* alternatively (and this is what we check): key in each node should be - * larger than (or equal to) key of its parent. */ - /* note that array element[0] is not used (except as a sentinel) */ - for (i = 2; i < heap->size; i++) - if (heap->element[i].cost < heap->element[i / 2].cost) - return 0; - return 1; + int i; + /* heap condition: key in each node should be smaller than in its children */ + /* alternatively (and this is what we check): key in each node should be + * larger than (or equal to) key of its parent. */ + /* note that array element[0] is not used (except as a sentinel) */ + for (i = 2; i < heap->size; i++) + if (heap->element[i].cost < heap->element[i / 2].cost) + return 0; + return 1; } #endif /* SLOW_ASSERTIONS */ -static int -__heap_is_good (heap_t * heap) +static int __heap_is_good(heap_t * heap) { - return heap && (heap->max == 0 || heap->element) && - (heap->max >= 0) && (heap->size >= 0) && - (heap->max == 0 || heap->size < heap->max) && + return heap && (heap->max == 0 || heap->element) && + (heap->max >= 0) && (heap->size >= 0) && (heap->max == 0 || heap->size < heap->max) && #ifdef SLOW_ASSERTIONS - __heap_is_good_slow (heap) && + __heap_is_good_slow(heap) && #endif - 1; + 1; } #endif /* ! NDEBUG */ /* create an empty heap */ -heap_t * -heap_create () +heap_t *heap_create() { - heap_t *heap; - /* initialize MIN_COST if necessary */ - if (MIN_COST == 0) - MIN_COST = -1e23; - assert (MIN_COST < 0); - /* okay, create empty heap */ - heap = (heap_t *)calloc (1, sizeof (*heap)); - assert (heap); - assert (__heap_is_good (heap)); - return heap; + heap_t *heap; + /* initialize MIN_COST if necessary */ + if (MIN_COST == 0) + MIN_COST = -1e23; + assert(MIN_COST < 0); + /* okay, create empty heap */ + heap = (heap_t *) calloc(1, sizeof(*heap)); + assert(heap); + assert(__heap_is_good(heap)); + return heap; } /* destroy a heap */ -void -heap_destroy (heap_t ** heap) +void heap_destroy(heap_t ** heap) { - assert (heap && *heap); - assert (__heap_is_good (*heap)); - if ((*heap)->element) - free ((*heap)->element); - free (*heap); - *heap = NULL; + assert(heap && *heap); + assert(__heap_is_good(*heap)); + if ((*heap)->element) + free((*heap)->element); + free(*heap); + *heap = NULL; } /* free all elements in the heap */ -void heap_free (heap_t *heap, void (*freefunc) (void *)) +void heap_free(heap_t * heap, void (*freefunc) (void *)) { - assert (heap); - assert (__heap_is_good (heap)); - for ( ; heap->size; heap->size--) - { - if (heap->element[heap->size].data) - freefunc (heap->element[heap->size].data); - } + assert(heap); + assert(__heap_is_good(heap)); + for (; heap->size; heap->size--) { + if (heap->element[heap->size].data) + freefunc(heap->element[heap->size].data); + } } /* -- mutation -- */ -static void -__upheap (heap_t * heap, int k) +static void __upheap(heap_t * heap, int k) { - struct heap_element v; + struct heap_element v; - assert (heap && heap->size < heap->max); - assert (k <= heap->size); + assert(heap && heap->size < heap->max); + assert(k <= heap->size); - v = heap->element[k]; - heap->element[0].cost = MIN_COST; - for (v = heap->element[k]; heap->element[k / 2].cost > v.cost; k = k / 2) - heap->element[k] = heap->element[k / 2]; - heap->element[k] = v; + v = heap->element[k]; + heap->element[0].cost = MIN_COST; + for (v = heap->element[k]; heap->element[k / 2].cost > v.cost; k = k / 2) + heap->element[k] = heap->element[k / 2]; + heap->element[k] = v; } -void -heap_insert (heap_t * heap, cost_t cost, void *data) +void heap_insert(heap_t * heap, cost_t cost, void *data) { - assert (heap && __heap_is_good (heap)); - assert (cost >= MIN_COST); + assert(heap && __heap_is_good(heap)); + assert(cost >= MIN_COST); - /* determine whether we need to grow the heap */ - if (heap->size + 1 >= heap->max) - { - heap->max *= 2; - if (heap->max == 0) - heap->max = 256; /* default initial heap size */ - heap->element = - (struct heap_element *)realloc (heap->element, heap->max * sizeof (*heap->element)); - } - heap->size++; - assert (heap->size < heap->max); - heap->element[heap->size].cost = cost; - heap->element[heap->size].data = data; - __upheap (heap, heap->size); /* fix heap condition violation */ - assert (__heap_is_good (heap)); - return; + /* determine whether we need to grow the heap */ + if (heap->size + 1 >= heap->max) { + heap->max *= 2; + if (heap->max == 0) + heap->max = 256; /* default initial heap size */ + heap->element = (struct heap_element *) realloc(heap->element, heap->max * sizeof(*heap->element)); + } + heap->size++; + assert(heap->size < heap->max); + heap->element[heap->size].cost = cost; + heap->element[heap->size].data = data; + __upheap(heap, heap->size); /* fix heap condition violation */ + assert(__heap_is_good(heap)); + return; } /* this procedure moves down the heap, exchanging the node at position @@ -192,77 +180,70 @@ * k with the smaller of its two children as necessary and stopping when * the node at k is smaller than both children or the bottom is reached. */ -static void -__downheap (heap_t * heap, int k) +static void __downheap(heap_t * heap, int k) { - struct heap_element v; + struct heap_element v; - assert (heap && heap->size < heap->max); - assert (k <= heap->size); + assert(heap && heap->size < heap->max); + assert(k <= heap->size); - v = heap->element[k]; - while (k <= heap->size / 2) - { - int j = k + k; - if (j < heap->size && heap->element[j].cost > heap->element[j + 1].cost) - j++; - if (v.cost < heap->element[j].cost) - break; - heap->element[k] = heap->element[j]; - k = j; - } - heap->element[k] = v; + v = heap->element[k]; + while (k <= heap->size / 2) { + int j = k + k; + if (j < heap->size && heap->element[j].cost > heap->element[j + 1].cost) + j++; + if (v.cost < heap->element[j].cost) + break; + heap->element[k] = heap->element[j]; + k = j; + } + heap->element[k] = v; } -void * -heap_remove_smallest (heap_t * heap) +void *heap_remove_smallest(heap_t * heap) { - struct heap_element v; - assert (heap && __heap_is_good (heap)); - assert (heap->size > 0); - assert (heap->max > 1); + struct heap_element v; + assert(heap && __heap_is_good(heap)); + assert(heap->size > 0); + assert(heap->max > 1); - v = heap->element[1]; - heap->element[1] = heap->element[heap->size--]; - if (heap->size > 0) - __downheap (heap, 1); + v = heap->element[1]; + heap->element[1] = heap->element[heap->size--]; + if (heap->size > 0) + __downheap(heap, 1); - assert (__heap_is_good (heap)); - return v.data; + assert(__heap_is_good(heap)); + return v.data; } -void * -heap_replace (heap_t * heap, cost_t cost, void *data) +void *heap_replace(heap_t * heap, cost_t cost, void *data) { - assert (heap && __heap_is_good (heap)); + assert(heap && __heap_is_good(heap)); - if (heap_is_empty (heap)) - return data; + if (heap_is_empty(heap)) + return data; - assert (heap->size > 0); - assert (heap->max > 1); + assert(heap->size > 0); + assert(heap->max > 1); - heap->element[0].cost = cost; - heap->element[0].data = data; - __downheap (heap, 0); /* ooh, tricky! */ + heap->element[0].cost = cost; + heap->element[0].data = data; + __downheap(heap, 0); /* ooh, tricky! */ - assert (__heap_is_good (heap)); - return heap->element[0].data; + assert(__heap_is_good(heap)); + return heap->element[0].data; } /* -- interrogation -- */ -int -heap_is_empty (heap_t * heap) +int heap_is_empty(heap_t * heap) { - assert (__heap_is_good (heap)); - return heap->size == 0; + assert(__heap_is_good(heap)); + return heap->size == 0; } /* -- size -- */ -int -heap_size (heap_t * heap) +int heap_size(heap_t * heap) { - assert (__heap_is_good (heap)); - return heap->size; + assert(__heap_is_good(heap)); + return heap->size; } - Index: trunk/src/heap.h =================================================================== --- trunk/src/heap.h (revision 1021) +++ trunk/src/heap.h (revision 1022) @@ -45,21 +45,21 @@ typedef struct heap_struct heap_t; /* create an empty heap */ -heap_t *heap_create (); +heap_t *heap_create(); /* destroy a heap */ -void heap_destroy (heap_t ** heap); +void heap_destroy(heap_t ** heap); /* free all elements in a heap */ -void heap_free (heap_t * heap, void (*funcfree) (void *)); +void heap_free(heap_t * heap, void (*funcfree) (void *)); /* -- mutation -- */ -void heap_insert (heap_t * heap, cost_t cost, void *data); -void *heap_remove_smallest (heap_t * heap); +void heap_insert(heap_t * heap, cost_t cost, void *data); +void *heap_remove_smallest(heap_t * heap); /* replace the smallest item with a new item and return the smallest item. * (if the new item is the smallest, than return it, instead.) */ -void *heap_replace (heap_t * heap, cost_t cost, void *data); +void *heap_replace(heap_t * heap, cost_t cost, void *data); /* -- interrogation -- */ -int heap_is_empty (heap_t * heap); -int heap_size (heap_t * heap); +int heap_is_empty(heap_t * heap); +int heap_size(heap_t * heap); #endif /* PCB_HEAP_H */ Index: trunk/src/hid/batch/batch.c =================================================================== --- trunk/src/hid/batch/batch.c (revision 1021) +++ trunk/src/hid/batch/batch.c (revision 1022) @@ -25,20 +25,18 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); /* This is a text-line "batch" HID, which exists for scripting and non-GUI needs. */ -typedef struct hid_gc_struct -{ - int nothing_interesting_here; +typedef struct hid_gc_struct { + int nothing_interesting_here; } hid_gc_struct; -static HID_Attribute * -batch_get_export_options (int *n_ret) +static HID_Attribute *batch_get_export_options(int *n_ret) { - return 0; + return 0; } /* ----------------------------------------------------------------------------- */ @@ -45,291 +43,250 @@ static char *prompt = NULL; -static int -nop (int argc, char **argv, Coord x, Coord y) +static int nop(int argc, char **argv, Coord x, Coord y) { - return 0; + return 0; } -static int -PCBChanged (int argc, char **argv, Coord x, Coord y) +static int PCBChanged(int argc, char **argv, Coord x, Coord y) { if (prompt != NULL) free(prompt); - if (PCB && PCB->Filename) - { - prompt = strrchr(PCB->Filename, '/'); - if (prompt) - prompt ++; - else - prompt = PCB->Filename; - if (prompt != NULL) - prompt = strdup(prompt); - } - else - prompt = strdup("no-board"); - return 0; + if (PCB && PCB->Filename) { + prompt = strrchr(PCB->Filename, '/'); + if (prompt) + prompt++; + else + prompt = PCB->Filename; + if (prompt != NULL) + prompt = strdup(prompt); + } + else + prompt = strdup("no-board"); + return 0; } -static int -help (int argc, char **argv, Coord x, Coord y) +static int help(int argc, char **argv, Coord x, Coord y) { - print_actions (); - return 0; + print_actions(); + return 0; } -static int -info (int argc, char **argv, Coord x, Coord y) +static int info(int argc, char **argv, Coord x, Coord y) { - int i, j; - int cg, sg; - if (!PCB || !PCB->Data || !PCB->Filename) - { - printf("No PCB loaded.\n"); - return 0; - } - printf("Filename: %s\n", PCB->Filename); - pcb_printf("Size: %ml x %ml mils, %mm x %mm mm\n", - PCB->MaxWidth, PCB->MaxHeight, - PCB->MaxWidth, PCB->MaxHeight); - cg = GetLayerGroupNumberByNumber (component_silk_layer); - sg = GetLayerGroupNumberByNumber (solder_silk_layer); - for (i=0; iData->Layer[i].Name); - } - return 0; + int i, j; + int cg, sg; + if (!PCB || !PCB->Data || !PCB->Filename) { + printf("No PCB loaded.\n"); + return 0; + } + printf("Filename: %s\n", PCB->Filename); + pcb_printf("Size: %ml x %ml mils, %mm x %mm mm\n", PCB->MaxWidth, PCB->MaxHeight, PCB->MaxWidth, PCB->MaxHeight); + cg = GetLayerGroupNumberByNumber(component_silk_layer); + sg = GetLayerGroupNumberByNumber(solder_silk_layer); + for (i = 0; i < MAX_LAYER; i++) { + + int lg = GetLayerGroupNumberByNumber(i); + for (j = 0; j < MAX_LAYER; j++) + putchar(j == lg ? '#' : '-'); + printf(" %c %s\n", lg == cg ? 'c' : lg == sg ? 's' : '-', PCB->Data->Layer[i].Name); + } + return 0; } HID_Action batch_action_list[] = { - {"PCBChanged", 0, PCBChanged }, - {"RouteStylesChanged", 0, nop }, - {"NetlistChanged", 0, nop }, - {"LayersChanged", 0, nop }, - {"LibraryChanged", 0, nop }, - {"Busy", 0, nop }, - {"Help", 0, help }, - {"Info", 0, info } + {"PCBChanged", 0, PCBChanged} + , + {"RouteStylesChanged", 0, nop} + , + {"NetlistChanged", 0, nop} + , + {"LayersChanged", 0, nop} + , + {"LibraryChanged", 0, nop} + , + {"Busy", 0, nop} + , + {"Help", 0, help} + , + {"Info", 0, info} }; -REGISTER_ACTIONS (batch_action_list) +REGISTER_ACTIONS(batch_action_list) /* ----------------------------------------------------------------------------- */ - -static void -batch_do_export (HID_Attr_Val * options) + static void + batch_do_export(HID_Attr_Val * options) { - int interactive; - char line[1000]; + int interactive; + char line[1000]; - if (isatty (0)) - interactive = 1; - else - interactive = 0; + if (isatty(0)) + interactive = 1; + else + interactive = 0; - if (interactive) - { - printf("Entering %s version %s batch mode.\n", PACKAGE, VERSION); - printf("See http://pcb.gpleda.org for project information\n"); - } - while (1) - { - if (interactive) - { - printf("%s> ", prompt); - fflush(stdout); + if (interactive) { + printf("Entering %s version %s batch mode.\n", PACKAGE, VERSION); + printf("See http://pcb.gpleda.org for project information\n"); } - if (fgets(line, sizeof(line)-1, stdin) == NULL) - return; - hid_parse_command (line); - } + while (1) { + if (interactive) { + printf("%s> ", prompt); + fflush(stdout); + } + if (fgets(line, sizeof(line) - 1, stdin) == NULL) + return; + hid_parse_command(line); + } } -static void -batch_parse_arguments (int *argc, char ***argv) +static void batch_parse_arguments(int *argc, char ***argv) { - hid_parse_command_line (argc, argv); + hid_parse_command_line(argc, argv); } -static void -batch_invalidate_lr (int l, int r, int t, int b) +static void batch_invalidate_lr(int l, int r, int t, int b) { } -static void -batch_invalidate_all (void) +static void batch_invalidate_all(void) { } -static int -batch_set_layer (const char *name, int idx, int empty) +static int batch_set_layer(const char *name, int idx, int empty) { - return 0; + return 0; } -static hidGC -batch_make_gc (void) +static hidGC batch_make_gc(void) { - return 0; + return 0; } -static void -batch_destroy_gc (hidGC gc) +static void batch_destroy_gc(hidGC gc) { } -static void -batch_use_mask (int use_it) +static void batch_use_mask(int use_it) { } -static void -batch_set_color (hidGC gc, const char *name) +static void batch_set_color(hidGC gc, const char *name) { } -static void -batch_set_line_cap (hidGC gc, EndCapStyle style) +static void batch_set_line_cap(hidGC gc, EndCapStyle style) { } -static void -batch_set_line_width (hidGC gc, Coord width) +static void batch_set_line_width(hidGC gc, Coord width) { } -static void -batch_set_draw_xor (hidGC gc, int xor_set) +static void batch_set_draw_xor(hidGC gc, int xor_set) { } -static void -batch_draw_line (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) +static void batch_draw_line(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) { } -static void -batch_draw_arc (hidGC gc, Coord cx, Coord cy, Coord width, Coord height, - Angle start_angle, Angle end_angle) +static void batch_draw_arc(hidGC gc, Coord cx, Coord cy, Coord width, Coord height, Angle start_angle, Angle end_angle) { } -static void -batch_draw_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) +static void batch_draw_rect(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) { } -static void -batch_fill_circle (hidGC gc, Coord cx, Coord cy, Coord radius) +static void batch_fill_circle(hidGC gc, Coord cx, Coord cy, Coord radius) { } -static void -batch_fill_polygon (hidGC gc, int n_coords, Coord *x, Coord *y) +static void batch_fill_polygon(hidGC gc, int n_coords, Coord * x, Coord * y) { } -static void -batch_fill_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) +static void batch_fill_rect(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) { } -static void -batch_calibrate (double xval, double yval) +static void batch_calibrate(double xval, double yval) { } -static int -batch_shift_is_pressed (void) +static int batch_shift_is_pressed(void) { - return 0; + return 0; } -static int -batch_control_is_pressed (void) +static int batch_control_is_pressed(void) { - return 0; + return 0; } -static int -batch_mod1_is_pressed (void) +static int batch_mod1_is_pressed(void) { - return 0; + return 0; } -static void -batch_get_coords (const char *msg, Coord *x, Coord *y) +static void batch_get_coords(const char *msg, Coord * x, Coord * y) { } -static void -batch_set_crosshair (int x, int y, int action) +static void batch_set_crosshair(int x, int y, int action) { } -static hidval -batch_add_timer (void (*func) (hidval user_data), - unsigned long milliseconds, hidval user_data) +static hidval batch_add_timer(void (*func) (hidval user_data), unsigned long milliseconds, hidval user_data) { - hidval rv; - rv.lval = 0; - return rv; + hidval rv; + rv.lval = 0; + return rv; } -static void -batch_stop_timer (hidval timer) +static void batch_stop_timer(hidval timer) { } hidval -batch_watch_file (int fd, unsigned int condition, void (*func) (hidval watch, int fd, unsigned int condition, hidval user_data), - hidval user_data) +batch_watch_file(int fd, unsigned int condition, void (*func) (hidval watch, int fd, unsigned int condition, hidval user_data), + hidval user_data) { - hidval ret; - ret.ptr = NULL; - return ret; + hidval ret; + ret.ptr = NULL; + return ret; } -void -batch_unwatch_file (hidval data) +void batch_unwatch_file(hidval data) { } -static hidval -batch_add_block_hook (void (*func) (hidval data), hidval user_data ) +static hidval batch_add_block_hook(void (*func) (hidval data), hidval user_data) { - hidval ret; - ret.ptr = NULL; - return ret; + hidval ret; + ret.ptr = NULL; + return ret; } -static void -batch_stop_block_hook (hidval mlpoll) +static void batch_stop_block_hook(hidval mlpoll) { } static int -batch_attribute_dialog (HID_Attribute * attrs_, - int n_attrs_, HID_Attr_Val * results_, - const char *title_, const char *descr_) +batch_attribute_dialog(HID_Attribute * attrs_, int n_attrs_, HID_Attr_Val * results_, const char *title_, const char *descr_) { - return 0; + return 0; } -static void -batch_show_item (void *item) +static void batch_show_item(void *item) { } -static void -batch_create_menu (const char *menu[], const char *action, const char *mnemonic, const char *accel, const char *tip) +static void batch_create_menu(const char *menu[], const char *action, const char *mnemonic, const char *accel, const char *tip) { } @@ -337,53 +294,52 @@ static HID batch_hid; -void -hid_batch_init () +void hid_batch_init() { - memset (&batch_hid, 0, sizeof (HID)); + memset(&batch_hid, 0, sizeof(HID)); - common_nogui_init (&batch_hid); - common_draw_helpers_init (&batch_hid); + common_nogui_init(&batch_hid); + common_draw_helpers_init(&batch_hid); - batch_hid.struct_size = sizeof (HID); - batch_hid.name = "batch"; - batch_hid.description = "Batch-mode GUI for non-interactive use."; - batch_hid.gui = 1; + batch_hid.struct_size = sizeof(HID); + batch_hid.name = "batch"; + batch_hid.description = "Batch-mode GUI for non-interactive use."; + batch_hid.gui = 1; - batch_hid.get_export_options = batch_get_export_options; - batch_hid.do_export = batch_do_export; - batch_hid.parse_arguments = batch_parse_arguments; - batch_hid.invalidate_lr = batch_invalidate_lr; - batch_hid.invalidate_all = batch_invalidate_all; - batch_hid.set_layer = batch_set_layer; - batch_hid.make_gc = batch_make_gc; - batch_hid.destroy_gc = batch_destroy_gc; - batch_hid.use_mask = batch_use_mask; - batch_hid.set_color = batch_set_color; - batch_hid.set_line_cap = batch_set_line_cap; - batch_hid.set_line_width = batch_set_line_width; - batch_hid.set_draw_xor = batch_set_draw_xor; - batch_hid.draw_line = batch_draw_line; - batch_hid.draw_arc = batch_draw_arc; - batch_hid.draw_rect = batch_draw_rect; - batch_hid.fill_circle = batch_fill_circle; - batch_hid.fill_polygon = batch_fill_polygon; - batch_hid.fill_rect = batch_fill_rect; - batch_hid.calibrate = batch_calibrate; - batch_hid.shift_is_pressed = batch_shift_is_pressed; - batch_hid.control_is_pressed = batch_control_is_pressed; - batch_hid.mod1_is_pressed = batch_mod1_is_pressed; - batch_hid.get_coords = batch_get_coords; - batch_hid.set_crosshair = batch_set_crosshair; - batch_hid.add_timer = batch_add_timer; - batch_hid.stop_timer = batch_stop_timer; - batch_hid.watch_file = batch_watch_file; - batch_hid.unwatch_file = batch_unwatch_file; - batch_hid.add_block_hook = batch_add_block_hook; - batch_hid.stop_block_hook = batch_stop_block_hook; - batch_hid.attribute_dialog = batch_attribute_dialog; - batch_hid.show_item = batch_show_item; - batch_hid.create_menu = batch_create_menu; + batch_hid.get_export_options = batch_get_export_options; + batch_hid.do_export = batch_do_export; + batch_hid.parse_arguments = batch_parse_arguments; + batch_hid.invalidate_lr = batch_invalidate_lr; + batch_hid.invalidate_all = batch_invalidate_all; + batch_hid.set_layer = batch_set_layer; + batch_hid.make_gc = batch_make_gc; + batch_hid.destroy_gc = batch_destroy_gc; + batch_hid.use_mask = batch_use_mask; + batch_hid.set_color = batch_set_color; + batch_hid.set_line_cap = batch_set_line_cap; + batch_hid.set_line_width = batch_set_line_width; + batch_hid.set_draw_xor = batch_set_draw_xor; + batch_hid.draw_line = batch_draw_line; + batch_hid.draw_arc = batch_draw_arc; + batch_hid.draw_rect = batch_draw_rect; + batch_hid.fill_circle = batch_fill_circle; + batch_hid.fill_polygon = batch_fill_polygon; + batch_hid.fill_rect = batch_fill_rect; + batch_hid.calibrate = batch_calibrate; + batch_hid.shift_is_pressed = batch_shift_is_pressed; + batch_hid.control_is_pressed = batch_control_is_pressed; + batch_hid.mod1_is_pressed = batch_mod1_is_pressed; + batch_hid.get_coords = batch_get_coords; + batch_hid.set_crosshair = batch_set_crosshair; + batch_hid.add_timer = batch_add_timer; + batch_hid.stop_timer = batch_stop_timer; + batch_hid.watch_file = batch_watch_file; + batch_hid.unwatch_file = batch_unwatch_file; + batch_hid.add_block_hook = batch_add_block_hook; + batch_hid.stop_block_hook = batch_stop_block_hook; + batch_hid.attribute_dialog = batch_attribute_dialog; + batch_hid.show_item = batch_show_item; + batch_hid.create_menu = batch_create_menu; - hid_register_hid (&batch_hid); + hid_register_hid(&batch_hid); } Index: trunk/src/hid/bom/bom.c =================================================================== --- trunk/src/hid/bom/bom.c (revision 1021) +++ trunk/src/hid/bom/bom.c (revision 1022) @@ -22,7 +22,7 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); static HID_Attribute bom_options[] = { /* %start-doc options "8 BOM Creation" @@ -32,8 +32,8 @@ @end ftable %end-doc */ - {"bomfile", "Name of the BOM output file", - HID_String, 0, 0, {0, 0, 0}, 0, 0}, + {"bomfile", "Name of the BOM output file", + HID_String, 0, 0, {0, 0, 0}, 0, 0}, #define HA_bomfile 0 /* %start-doc options "8 BOM Creation" @ftable @code @@ -42,8 +42,8 @@ @end ftable %end-doc */ - {"xyfile", "Name of the XY output file", - HID_String, 0, 0, {0, 0, 0}, 0, 0}, + {"xyfile", "Name of the XY output file", + HID_String, 0, 0, {0, 0, 0}, 0, 0}, #define HA_xyfile 1 /* %start-doc options "8 BOM Creation" @@ -53,11 +53,11 @@ @end ftable %end-doc */ - {"xy-unit", "XY units", - HID_Unit, 0, 0, {-1, 0, 0}, NULL, 0}, + {"xy-unit", "XY units", + HID_Unit, 0, 0, {-1, 0, 0}, NULL, 0}, #define HA_unit 2 - {"xy-in-mm", ATTR_UNDOCUMENTED, - HID_Boolean, 0, 0, {0, 0, 0}, 0, 0}, + {"xy-in-mm", ATTR_UNDOCUMENTED, + HID_Boolean, 0, 0, {0, 0, 0}, 0, 0}, #define HA_xymm 3 }; @@ -69,44 +69,40 @@ static const char *xy_filename; static const Unit *xy_unit; -typedef struct _StringList -{ - char *str; - struct _StringList *next; +typedef struct _StringList { + char *str; + struct _StringList *next; } StringList; -typedef struct _BomList -{ - char *descr; - char *value; - int num; - StringList *refdes; - struct _BomList *next; +typedef struct _BomList { + char *descr; + char *value; + int num; + StringList *refdes; + struct _BomList *next; } BomList; -static HID_Attribute * -bom_get_export_options (int *n) +static HID_Attribute *bom_get_export_options(int *n) { - static char *last_bom_filename = 0; - static char *last_xy_filename = 0; - static int last_unit_value = -1; + static char *last_bom_filename = 0; + static char *last_xy_filename = 0; + static int last_unit_value = -1; - if (bom_options[HA_unit].default_val.int_value == last_unit_value) - { - if (Settings.grid_unit) - bom_options[HA_unit].default_val.int_value = Settings.grid_unit->index; - else - bom_options[HA_unit].default_val.int_value = get_unit_struct ("mil")->index; - last_unit_value = bom_options[HA_unit].default_val.int_value; - } - if (PCB) { - derive_default_filename(PCB->Filename, &bom_options[HA_bomfile], ".bom", &last_bom_filename); - derive_default_filename(PCB->Filename, &bom_options[HA_xyfile ], ".xy" , &last_xy_filename ); - } + if (bom_options[HA_unit].default_val.int_value == last_unit_value) { + if (Settings.grid_unit) + bom_options[HA_unit].default_val.int_value = Settings.grid_unit->index; + else + bom_options[HA_unit].default_val.int_value = get_unit_struct("mil")->index; + last_unit_value = bom_options[HA_unit].default_val.int_value; + } + if (PCB) { + derive_default_filename(PCB->Filename, &bom_options[HA_bomfile], ".bom", &last_bom_filename); + derive_default_filename(PCB->Filename, &bom_options[HA_xyfile], ".xy", &last_xy_filename); + } - if (n) - *n = NUM_OPTIONS; - return bom_options; + if (n) + *n = NUM_OPTIONS; + return bom_options; } /* --------------------------------------------------------------------------- @@ -119,146 +115,129 @@ */ -static char * -CleanBOMString (char *in) +static char *CleanBOMString(char *in) { - char *out; - int i; + char *out; + int i; - if ((out = (char *)malloc ((strlen (in) + 1) * sizeof (char))) == NULL) - { - fprintf (stderr, "Error: CleanBOMString() malloc() failed\n"); - exit (1); - } + if ((out = (char *) malloc((strlen(in) + 1) * sizeof(char))) == NULL) { + fprintf(stderr, "Error: CleanBOMString() malloc() failed\n"); + exit(1); + } - /* - * copy over in to out with some character conversions. - * Go all the way to then end to get the terminating \0 - */ - for (i = 0; i <= strlen (in); i++) - { - switch (in[i]) - { - case '"': - out[i] = '\''; - break; - default: - out[i] = in[i]; + /* + * copy over in to out with some character conversions. + * Go all the way to then end to get the terminating \0 + */ + for (i = 0; i <= strlen(in); i++) { + switch (in[i]) { + case '"': + out[i] = '\''; + break; + default: + out[i] = in[i]; + } } - } - return out; + return out; } -static double -xyToAngle (double x, double y) +static double xyToAngle(double x, double y) { - double theta; + double theta; - if ((x > 0.0) && (y >= 0.0)) - theta = 180.0; - else if ((x <= 0.0) && (y > 0.0)) - theta = 90.0; - else if ((x < 0.0) && (y <= 0.0)) - theta = 0.0; - else if ((x >= 0.0) && (y < 0.0)) - theta = 270.0; - else - { - theta = 0.0; - Message ("xyToAngle(): unable to figure out angle of element\n" - " because the pin is at the centroid of the part.\n" - " This is a BUG!!!\n" - " Setting to %g degrees\n", theta); - } + if ((x > 0.0) && (y >= 0.0)) + theta = 180.0; + else if ((x <= 0.0) && (y > 0.0)) + theta = 90.0; + else if ((x < 0.0) && (y <= 0.0)) + theta = 0.0; + else if ((x >= 0.0) && (y < 0.0)) + theta = 270.0; + else { + theta = 0.0; + Message("xyToAngle(): unable to figure out angle of element\n" + " because the pin is at the centroid of the part.\n" + " This is a BUG!!!\n" " Setting to %g degrees\n", theta); + } - return (theta); + return (theta); } -static StringList * -string_insert (char *str, StringList * list) +static StringList *string_insert(char *str, StringList * list) { - StringList *newlist, *cur; + StringList *newlist, *cur; - if ((newlist = (StringList *) malloc (sizeof (StringList))) == NULL) - { - fprintf (stderr, "malloc() failed in string_insert()\n"); - exit (1); - } + if ((newlist = (StringList *) malloc(sizeof(StringList))) == NULL) { + fprintf(stderr, "malloc() failed in string_insert()\n"); + exit(1); + } - newlist->next = NULL; - newlist->str = strdup (str); + newlist->next = NULL; + newlist->str = strdup(str); - if (list == NULL) - return (newlist); + if (list == NULL) + return (newlist); - cur = list; - while (cur->next != NULL) - cur = cur->next; + cur = list; + while (cur->next != NULL) + cur = cur->next; - cur->next = newlist; + cur->next = newlist; - return (list); + return (list); } -static BomList * -bom_insert (char *refdes, char *descr, char *value, BomList * bom) +static BomList *bom_insert(char *refdes, char *descr, char *value, BomList * bom) { - BomList *newlist, *cur, *prev = NULL; + BomList *newlist, *cur, *prev = NULL; - if (bom == NULL) - { - /* this is the first element so automatically create an entry */ - if ((newlist = (BomList *) malloc (sizeof (BomList))) == NULL) - { - fprintf (stderr, "malloc() failed in bom_insert()\n"); - exit (1); - } + if (bom == NULL) { + /* this is the first element so automatically create an entry */ + if ((newlist = (BomList *) malloc(sizeof(BomList))) == NULL) { + fprintf(stderr, "malloc() failed in bom_insert()\n"); + exit(1); + } - newlist->next = NULL; - newlist->descr = strdup (descr); - newlist->value = strdup (value); - newlist->num = 1; - newlist->refdes = string_insert (refdes, NULL); - return (newlist); - } - - /* search and see if we already have used one of these - components */ - cur = bom; - while (cur != NULL) - { - if ((NSTRCMP (descr, cur->descr) == 0) && - (NSTRCMP (value, cur->value) == 0)) - { - cur->num++; - cur->refdes = string_insert (refdes, cur->refdes); - break; + newlist->next = NULL; + newlist->descr = strdup(descr); + newlist->value = strdup(value); + newlist->num = 1; + newlist->refdes = string_insert(refdes, NULL); + return (newlist); } - prev = cur; - cur = cur->next; - } - if (cur == NULL) - { - if ((newlist = (BomList *) malloc (sizeof (BomList))) == NULL) - { - fprintf (stderr, "malloc() failed in bom_insert()\n"); - exit (1); + /* search and see if we already have used one of these + components */ + cur = bom; + while (cur != NULL) { + if ((NSTRCMP(descr, cur->descr) == 0) && (NSTRCMP(value, cur->value) == 0)) { + cur->num++; + cur->refdes = string_insert(refdes, cur->refdes); + break; + } + prev = cur; + cur = cur->next; } - prev->next = newlist; + if (cur == NULL) { + if ((newlist = (BomList *) malloc(sizeof(BomList))) == NULL) { + fprintf(stderr, "malloc() failed in bom_insert()\n"); + exit(1); + } - newlist->next = NULL; - newlist->descr = strdup (descr); - newlist->value = strdup (value); - newlist->num = 1; - newlist->refdes = string_insert (refdes, NULL); - } + prev->next = newlist; - return (bom); + newlist->next = NULL; + newlist->descr = strdup(descr); + newlist->value = strdup(value); + newlist->num = 1; + newlist->refdes = string_insert(refdes, NULL); + } + return (bom); + } /* @@ -265,313 +244,283 @@ * If fp is not NULL then print out the bill of materials contained in * bom. Either way, free all memory which has been allocated for bom. */ -static void -print_and_free (FILE *fp, BomList *bom) +static void print_and_free(FILE * fp, BomList * bom) { - BomList *lastb; - StringList *lasts; - char *descr, *value; + BomList *lastb; + StringList *lasts; + char *descr, *value; - while (bom != NULL) - { - if (fp) - { - descr = CleanBOMString (bom->descr); - value = CleanBOMString (bom->value); - fprintf (fp, "%d,\"%s\",\"%s\",", bom->num, descr, value); - free (descr); - free (value); + while (bom != NULL) { + if (fp) { + descr = CleanBOMString(bom->descr); + value = CleanBOMString(bom->value); + fprintf(fp, "%d,\"%s\",\"%s\",", bom->num, descr, value); + free(descr); + free(value); + } + + while (bom->refdes != NULL) { + if (fp) { + fprintf(fp, "%s ", bom->refdes->str); + } + free(bom->refdes->str); + lasts = bom->refdes; + bom->refdes = bom->refdes->next; + free(lasts); + } + if (fp) { + fprintf(fp, "\n"); + } + lastb = bom; + bom = bom->next; + free(lastb); } - - while (bom->refdes != NULL) - { - if (fp) - { - fprintf (fp, "%s ", bom->refdes->str); - } - free (bom->refdes->str); - lasts = bom->refdes; - bom->refdes = bom->refdes->next; - free (lasts); - } - if (fp) - { - fprintf (fp, "\n"); - } - lastb = bom; - bom = bom->next; - free (lastb); - } } -static int -PrintBOM (void) +static int PrintBOM(void) { - char utcTime[64]; - Coord x, y; - double theta = 0.0; - double sumx, sumy; - double pin1x = 0.0, pin1y = 0.0, pin1angle = 0.0; - double pin2x = 0.0, pin2y = 0.0; - int found_pin1; - int found_pin2; - int pin_cnt; - time_t currenttime; - FILE *fp; - BomList *bom = NULL; - char *name, *descr, *value; + char utcTime[64]; + Coord x, y; + double theta = 0.0; + double sumx, sumy; + double pin1x = 0.0, pin1y = 0.0, pin1angle = 0.0; + double pin2x = 0.0, pin2y = 0.0; + int found_pin1; + int found_pin2; + int pin_cnt; + time_t currenttime; + FILE *fp; + BomList *bom = NULL; + char *name, *descr, *value; - fp = fopen (xy_filename, "w"); - if (!fp) - { - gui->log ("Cannot open file %s for writing\n", xy_filename); - return 1; - } + fp = fopen(xy_filename, "w"); + if (!fp) { + gui->log("Cannot open file %s for writing\n", xy_filename); + return 1; + } - /* Create a portable timestamp. */ - currenttime = time (NULL); - { - /* avoid gcc complaints */ - const char *fmt = "%c UTC"; - strftime (utcTime, sizeof (utcTime), fmt, gmtime (¤ttime)); - } - fprintf (fp, "# $Id"); - fprintf (fp, "$\n"); - fprintf (fp, "# PcbXY Version 1.0\n"); - fprintf (fp, "# Date: %s\n", utcTime); - fprintf (fp, "# Author: %s\n", pcb_author ()); - fprintf (fp, "# Title: %s - PCB X-Y\n", UNKNOWN (PCB->Name)); - fprintf (fp, "# RefDes, Description, Value, X, Y, rotation, top/bottom\n"); - fprintf (fp, "# X,Y in %s. rotation in degrees.\n", xy_unit->in_suffix); - fprintf (fp, "# --------------------------------------------\n"); + /* Create a portable timestamp. */ + currenttime = time(NULL); + { + /* avoid gcc complaints */ + const char *fmt = "%c UTC"; + strftime(utcTime, sizeof(utcTime), fmt, gmtime(¤ttime)); + } + fprintf(fp, "# $Id"); + fprintf(fp, "$\n"); + fprintf(fp, "# PcbXY Version 1.0\n"); + fprintf(fp, "# Date: %s\n", utcTime); + fprintf(fp, "# Author: %s\n", pcb_author()); + fprintf(fp, "# Title: %s - PCB X-Y\n", UNKNOWN(PCB->Name)); + fprintf(fp, "# RefDes, Description, Value, X, Y, rotation, top/bottom\n"); + fprintf(fp, "# X,Y in %s. rotation in degrees.\n", xy_unit->in_suffix); + fprintf(fp, "# --------------------------------------------\n"); - /* - * For each element we calculate the centroid of the footprint. - * In addition, we need to extract some notion of rotation. - * While here generate the BOM list - */ + /* + * For each element we calculate the centroid of the footprint. + * In addition, we need to extract some notion of rotation. + * While here generate the BOM list + */ - ELEMENT_LOOP (PCB->Data); - { + ELEMENT_LOOP(PCB->Data); + { - /* initialize our pin count and our totals for finding the - centriod */ - pin_cnt = 0; - sumx = 0.0; - sumy = 0.0; - found_pin1 = 0; - found_pin2 = 0; + /* initialize our pin count and our totals for finding the + centriod */ + pin_cnt = 0; + sumx = 0.0; + sumy = 0.0; + found_pin1 = 0; + found_pin2 = 0; - /* insert this component into the bill of materials list */ - bom = bom_insert ((char *)UNKNOWN (NAMEONPCB_NAME (element)), - (char *)UNKNOWN (DESCRIPTION_NAME (element)), - (char *)UNKNOWN (VALUE_NAME (element)), bom); + /* insert this component into the bill of materials list */ + bom = bom_insert((char *) UNKNOWN(NAMEONPCB_NAME(element)), + (char *) UNKNOWN(DESCRIPTION_NAME(element)), (char *) UNKNOWN(VALUE_NAME(element)), bom); - /* - * iterate over the pins and pads keeping a running count of how - * many pins/pads total and the sum of x and y coordinates - * - * While we're at it, store the location of pin/pad #1 and #2 if - * we can find them - */ + /* + * iterate over the pins and pads keeping a running count of how + * many pins/pads total and the sum of x and y coordinates + * + * While we're at it, store the location of pin/pad #1 and #2 if + * we can find them + */ - PIN_LOOP (element); - { - sumx += (double) pin->X; - sumy += (double) pin->Y; - pin_cnt++; + PIN_LOOP(element); + { + sumx += (double) pin->X; + sumy += (double) pin->Y; + pin_cnt++; - if (NSTRCMP (pin->Number, "1") == 0) - { - pin1x = (double) pin->X; - pin1y = (double) pin->Y; - pin1angle = 0.0; /* pins have no notion of angle */ - found_pin1 = 1; - } - else if (NSTRCMP (pin->Number, "2") == 0) - { - pin2x = (double) pin->X; - pin2y = (double) pin->Y; - found_pin2 = 1; - } - } - END_LOOP; + if (NSTRCMP(pin->Number, "1") == 0) { + pin1x = (double) pin->X; + pin1y = (double) pin->Y; + pin1angle = 0.0; /* pins have no notion of angle */ + found_pin1 = 1; + } + else if (NSTRCMP(pin->Number, "2") == 0) { + pin2x = (double) pin->X; + pin2y = (double) pin->Y; + found_pin2 = 1; + } + } + END_LOOP; - PAD_LOOP (element); - { - sumx += (pad->Point1.X + pad->Point2.X) / 2.0; - sumy += (pad->Point1.Y + pad->Point2.Y) / 2.0; - pin_cnt++; + PAD_LOOP(element); + { + sumx += (pad->Point1.X + pad->Point2.X) / 2.0; + sumy += (pad->Point1.Y + pad->Point2.Y) / 2.0; + pin_cnt++; - if (NSTRCMP (pad->Number, "1") == 0) - { - pin1x = (double) (pad->Point1.X + pad->Point2.X) / 2.0; - pin1y = (double) (pad->Point1.Y + pad->Point2.Y) / 2.0; - /* - * NOTE: We swap the Y points because in PCB, the Y-axis - * is inverted. Increasing Y moves down. We want to deal - * in the usual increasing Y moves up coordinates though. - */ - pin1angle = (180.0 / M_PI) * atan2 (pad->Point1.Y - pad->Point2.Y, - pad->Point2.X - pad->Point1.X); - found_pin1 = 1; - } - else if (NSTRCMP (pad->Number, "2") == 0) - { - pin2x = (double) (pad->Point1.X + pad->Point2.X) / 2.0; - pin2y = (double) (pad->Point1.Y + pad->Point2.Y) / 2.0; - found_pin2 = 1; - } + if (NSTRCMP(pad->Number, "1") == 0) { + pin1x = (double) (pad->Point1.X + pad->Point2.X) / 2.0; + pin1y = (double) (pad->Point1.Y + pad->Point2.Y) / 2.0; + /* + * NOTE: We swap the Y points because in PCB, the Y-axis + * is inverted. Increasing Y moves down. We want to deal + * in the usual increasing Y moves up coordinates though. + */ + pin1angle = (180.0 / M_PI) * atan2(pad->Point1.Y - pad->Point2.Y, pad->Point2.X - pad->Point1.X); + found_pin1 = 1; + } + else if (NSTRCMP(pad->Number, "2") == 0) { + pin2x = (double) (pad->Point1.X + pad->Point2.X) / 2.0; + pin2y = (double) (pad->Point1.Y + pad->Point2.Y) / 2.0; + found_pin2 = 1; + } - } - END_LOOP; + } + END_LOOP; - if (pin_cnt > 0) - { - x = sumx / (double) pin_cnt; - y = sumy / (double) pin_cnt; + if (pin_cnt > 0) { + x = sumx / (double) pin_cnt; + y = sumy / (double) pin_cnt; - if (found_pin1) - { - /* recenter pin #1 onto the axis which cross at the part - centroid */ - pin1x -= x; - pin1y -= y; - pin1y = -1.0 * pin1y; + if (found_pin1) { + /* recenter pin #1 onto the axis which cross at the part + centroid */ + pin1x -= x; + pin1y -= y; + pin1y = -1.0 * pin1y; - /* if only 1 pin, use pin 1's angle */ - if (pin_cnt == 1) - theta = pin1angle; - else - { - /* if pin #1 is at (0,0) use pin #2 for rotation */ - if ((pin1x == 0.0) && (pin1y == 0.0)) - { - if (found_pin2) - theta = xyToAngle (pin2x, pin2y); - else - { - Message - ("PrintBOM(): unable to figure out angle of element\n" - " %s because pin #1 is at the centroid of the part.\n" - " and I could not find pin #2's location\n" - " Setting to %g degrees\n", - UNKNOWN (NAMEONPCB_NAME (element)), theta); - } - } - else - theta = xyToAngle (pin1x, pin1y); - } - } - /* we did not find pin #1 */ - else - { - theta = 0.0; - Message - ("PrintBOM(): unable to figure out angle because I could\n" - " not find pin #1 of element %s\n" - " Setting to %g degrees\n", - UNKNOWN (NAMEONPCB_NAME (element)), theta); - } + /* if only 1 pin, use pin 1's angle */ + if (pin_cnt == 1) + theta = pin1angle; + else { + /* if pin #1 is at (0,0) use pin #2 for rotation */ + if ((pin1x == 0.0) && (pin1y == 0.0)) { + if (found_pin2) + theta = xyToAngle(pin2x, pin2y); + else { + Message + ("PrintBOM(): unable to figure out angle of element\n" + " %s because pin #1 is at the centroid of the part.\n" + " and I could not find pin #2's location\n" + " Setting to %g degrees\n", UNKNOWN(NAMEONPCB_NAME(element)), theta); + } + } + else + theta = xyToAngle(pin1x, pin1y); + } + } + /* we did not find pin #1 */ + else { + theta = 0.0; + Message + ("PrintBOM(): unable to figure out angle because I could\n" + " not find pin #1 of element %s\n" " Setting to %g degrees\n", UNKNOWN(NAMEONPCB_NAME(element)), theta); + } - name = CleanBOMString ((char *)UNKNOWN (NAMEONPCB_NAME (element))); - descr = CleanBOMString ((char *)UNKNOWN (DESCRIPTION_NAME (element))); - value = CleanBOMString ((char *)UNKNOWN (VALUE_NAME (element))); + name = CleanBOMString((char *) UNKNOWN(NAMEONPCB_NAME(element))); + descr = CleanBOMString((char *) UNKNOWN(DESCRIPTION_NAME(element))); + value = CleanBOMString((char *) UNKNOWN(VALUE_NAME(element))); - y = PCB->MaxHeight - y; - pcb_fprintf (fp, "%m+%s,\"%s\",\"%s\",%mS,%.2mS,%g,%s\n", - xy_unit->allow, name, descr, value, x, y, - theta, FRONT (element) == 1 ? "top" : "bottom"); - free (name); - free (descr); - free (value); - } - } - END_LOOP; + y = PCB->MaxHeight - y; + pcb_fprintf(fp, "%m+%s,\"%s\",\"%s\",%mS,%.2mS,%g,%s\n", + xy_unit->allow, name, descr, value, x, y, theta, FRONT(element) == 1 ? "top" : "bottom"); + free(name); + free(descr); + free(value); + } + } + END_LOOP; - fclose (fp); + fclose(fp); - /* Now print out a Bill of Materials file */ + /* Now print out a Bill of Materials file */ - fp = fopen (bom_filename, "w"); - if (!fp) - { - gui->log ("Cannot open file %s for writing\n", bom_filename); - print_and_free (NULL, bom); - return 1; - } + fp = fopen(bom_filename, "w"); + if (!fp) { + gui->log("Cannot open file %s for writing\n", bom_filename); + print_and_free(NULL, bom); + return 1; + } - fprintf (fp, "# $Id"); - fprintf (fp, "$\n"); - fprintf (fp, "# PcbBOM Version 1.0\n"); - fprintf (fp, "# Date: %s\n", utcTime); - fprintf (fp, "# Author: %s\n", pcb_author ()); - fprintf (fp, "# Title: %s - PCB BOM\n", UNKNOWN (PCB->Name)); - fprintf (fp, "# Quantity, Description, Value, RefDes\n"); - fprintf (fp, "# --------------------------------------------\n"); + fprintf(fp, "# $Id"); + fprintf(fp, "$\n"); + fprintf(fp, "# PcbBOM Version 1.0\n"); + fprintf(fp, "# Date: %s\n", utcTime); + fprintf(fp, "# Author: %s\n", pcb_author()); + fprintf(fp, "# Title: %s - PCB BOM\n", UNKNOWN(PCB->Name)); + fprintf(fp, "# Quantity, Description, Value, RefDes\n"); + fprintf(fp, "# --------------------------------------------\n"); - print_and_free (fp, bom); + print_and_free(fp, bom); - fclose (fp); + fclose(fp); - return (0); + return (0); } -static void -bom_do_export (HID_Attr_Val * options) +static void bom_do_export(HID_Attr_Val * options) { - int i; + int i; - if (!options) - { - bom_get_export_options (0); - for (i = 0; i < NUM_OPTIONS; i++) - bom_values[i] = bom_options[i].default_val; - options = bom_values; - } + if (!options) { + bom_get_export_options(0); + for (i = 0; i < NUM_OPTIONS; i++) + bom_values[i] = bom_options[i].default_val; + options = bom_values; + } - bom_filename = options[HA_bomfile].str_value; - if (!bom_filename) - bom_filename = "pcb-out.bom"; + bom_filename = options[HA_bomfile].str_value; + if (!bom_filename) + bom_filename = "pcb-out.bom"; - xy_filename = options[HA_xyfile].str_value; - if (!xy_filename) - xy_filename = "pcb-out.xy"; + xy_filename = options[HA_xyfile].str_value; + if (!xy_filename) + xy_filename = "pcb-out.xy"; - if (options[HA_unit].int_value == -1) - xy_unit = options[HA_xymm].int_value ? get_unit_struct ("mm") - : get_unit_struct ("mil"); - else - xy_unit = &get_unit_list ()[options[HA_unit].int_value]; - PrintBOM (); + if (options[HA_unit].int_value == -1) + xy_unit = options[HA_xymm].int_value ? get_unit_struct("mm") + : get_unit_struct("mil"); + else + xy_unit = &get_unit_list()[options[HA_unit].int_value]; + PrintBOM(); } -static void -bom_parse_arguments (int *argc, char ***argv) +static void bom_parse_arguments(int *argc, char ***argv) { - hid_register_attributes (bom_options, - sizeof (bom_options) / sizeof (bom_options[0])); - hid_parse_command_line (argc, argv); + hid_register_attributes(bom_options, sizeof(bom_options) / sizeof(bom_options[0])); + hid_parse_command_line(argc, argv); } HID bom_hid; -void -hid_bom_init () +void hid_bom_init() { - memset (&bom_hid, 0, sizeof (HID)); + memset(&bom_hid, 0, sizeof(HID)); - common_nogui_init (&bom_hid); + common_nogui_init(&bom_hid); - bom_hid.struct_size = sizeof (HID); - bom_hid.name = "bom"; - bom_hid.description = "Exports a Bill of Materials"; - bom_hid.exporter = 1; + bom_hid.struct_size = sizeof(HID); + bom_hid.name = "bom"; + bom_hid.description = "Exports a Bill of Materials"; + bom_hid.exporter = 1; - bom_hid.get_export_options = bom_get_export_options; - bom_hid.do_export = bom_do_export; - bom_hid.parse_arguments = bom_parse_arguments; + bom_hid.get_export_options = bom_get_export_options; + bom_hid.do_export = bom_do_export; + bom_hid.parse_arguments = bom_parse_arguments; - hid_register_hid (&bom_hid); + hid_register_hid(&bom_hid); } Index: trunk/src/hid/common/actions.c =================================================================== --- trunk/src/hid/common/actions.c (revision 1021) +++ trunk/src/hid/common/actions.c (revision 1022) @@ -86,7 +86,7 @@ { if (all_actions == NULL) return NULL; - + return htsp_pop(all_actions, a->name); } Index: trunk/src/hid/common/actions.h =================================================================== --- trunk/src/hid/common/actions.h (revision 1021) +++ trunk/src/hid/common/actions.h (revision 1022) @@ -2,6 +2,6 @@ #ifndef PCB_HID_COMMON_ACTIONS_H #define PCB_HID_COMMON_ACTIONS_H -void print_actions (void); +void print_actions(void); #endif Index: trunk/src/hid/common/draw_helpers.c =================================================================== --- trunk/src/hid/common/draw_helpers.c (revision 1021) +++ trunk/src/hid/common/draw_helpers.c (revision 1022) @@ -2,105 +2,95 @@ #include "hid.h" #include "polygon.h" -static void -fill_contour (hidGC gc, PLINE *pl) +static void fill_contour(hidGC gc, PLINE * pl) { - Coord *x, *y, n, i = 0; - VNODE *v; + Coord *x, *y, n, i = 0; + VNODE *v; - n = pl->Count; - x = (Coord *)malloc (n * sizeof (*x)); - y = (Coord *)malloc (n * sizeof (*y)); + n = pl->Count; + x = (Coord *) malloc(n * sizeof(*x)); + y = (Coord *) malloc(n * sizeof(*y)); - for (v = &pl->head; i < n; v = v->next) - { - x[i] = v->point[0]; - y[i++] = v->point[1]; - } + for (v = &pl->head; i < n; v = v->next) { + x[i] = v->point[0]; + y[i++] = v->point[1]; + } - gui->fill_polygon (gc, n, x, y); + gui->fill_polygon(gc, n, x, y); - free (x); - free (y); + free(x); + free(y); } -static void -thindraw_contour (hidGC gc, PLINE *pl) +static void thindraw_contour(hidGC gc, PLINE * pl) { - VNODE *v; - Coord last_x, last_y; - Coord this_x, this_y; + VNODE *v; + Coord last_x, last_y; + Coord this_x, this_y; - gui->set_line_width (gc, 0); - gui->set_line_cap (gc, Round_Cap); + gui->set_line_width(gc, 0); + gui->set_line_cap(gc, Round_Cap); - /* If the contour is round, use an arc drawing routine. */ - if (pl->is_round) - { - gui->draw_arc (gc, pl->cx, pl->cy, pl->radius, pl->radius, 0, 360); - return; - } + /* If the contour is round, use an arc drawing routine. */ + if (pl->is_round) { + gui->draw_arc(gc, pl->cx, pl->cy, pl->radius, pl->radius, 0, 360); + return; + } - /* Need at least two points in the contour */ - if (pl->head.next == NULL) - return; + /* Need at least two points in the contour */ + if (pl->head.next == NULL) + return; - last_x = pl->head.point[0]; - last_y = pl->head.point[1]; - v = pl->head.next; + last_x = pl->head.point[0]; + last_y = pl->head.point[1]; + v = pl->head.next; - do - { - this_x = v->point[0]; - this_y = v->point[1]; + do { + this_x = v->point[0]; + this_y = v->point[1]; - gui->draw_line (gc, last_x, last_y, this_x, this_y); - /* gui->fill_circle (gc, this_x, this_y, 30); */ + gui->draw_line(gc, last_x, last_y, this_x, this_y); + /* gui->fill_circle (gc, this_x, this_y, 30); */ - last_x = this_x; - last_y = this_y; - } - while ((v = v->next) != pl->head.next); + last_x = this_x; + last_y = this_y; + } + while ((v = v->next) != pl->head.next); } -static void -fill_contour_cb (PLINE *pl, void *user_data) +static void fill_contour_cb(PLINE * pl, void *user_data) { - hidGC gc = (hidGC)user_data; - PLINE *local_pl = pl; + hidGC gc = (hidGC) user_data; + PLINE *local_pl = pl; - fill_contour (gc, pl); - poly_FreeContours (&local_pl); + fill_contour(gc, pl); + poly_FreeContours(&local_pl); } -static void -fill_clipped_contour (hidGC gc, PLINE *pl, const BoxType *clip_box) +static void fill_clipped_contour(hidGC gc, PLINE * pl, const BoxType * clip_box) { - PLINE *pl_copy; - POLYAREA *clip_poly; - POLYAREA *piece_poly; - POLYAREA *clipped_pieces; - POLYAREA *draw_piece; - int x; + PLINE *pl_copy; + POLYAREA *clip_poly; + POLYAREA *piece_poly; + POLYAREA *clipped_pieces; + POLYAREA *draw_piece; + int x; - clip_poly = RectPoly (clip_box->X1, clip_box->X2, - clip_box->Y1, clip_box->Y2); - poly_CopyContour (&pl_copy, pl); - piece_poly = poly_Create (); - poly_InclContour (piece_poly, pl_copy); - x = poly_Boolean_free (piece_poly, clip_poly, - &clipped_pieces, PBO_ISECT); - if (x != err_ok || clipped_pieces == NULL) - return; + clip_poly = RectPoly(clip_box->X1, clip_box->X2, clip_box->Y1, clip_box->Y2); + poly_CopyContour(&pl_copy, pl); + piece_poly = poly_Create(); + poly_InclContour(piece_poly, pl_copy); + x = poly_Boolean_free(piece_poly, clip_poly, &clipped_pieces, PBO_ISECT); + if (x != err_ok || clipped_pieces == NULL) + return; - draw_piece = clipped_pieces; - do - { - /* NB: The polygon won't have any holes in it */ - fill_contour (gc, draw_piece->contours); - } - while ((draw_piece = draw_piece->f) != clipped_pieces); - poly_Free (&clipped_pieces); + draw_piece = clipped_pieces; + do { + /* NB: The polygon won't have any holes in it */ + fill_contour(gc, draw_piece->contours); + } + while ((draw_piece = draw_piece->f) != clipped_pieces); + poly_Free(&clipped_pieces); } /* If at least 50% of the bounding box of the polygon is on the screen, @@ -107,196 +97,172 @@ * lets compute the complete no-holes polygon. */ #define BOUNDS_INSIDE_CLIP_THRESHOLD 0.5 -static int -should_compute_no_holes (PolygonType *poly, const BoxType *clip_box) +static int should_compute_no_holes(PolygonType * poly, const BoxType * clip_box) { - Coord x1, x2, y1, y2; - double poly_bounding_area; - double clipped_poly_area; + Coord x1, x2, y1, y2; + double poly_bounding_area; + double clipped_poly_area; - /* If there is no passed clip box, compute the whole thing */ - if (clip_box == NULL) - return 1; + /* If there is no passed clip box, compute the whole thing */ + if (clip_box == NULL) + return 1; - x1 = MAX (poly->BoundingBox.X1, clip_box->X1); - x2 = MIN (poly->BoundingBox.X2, clip_box->X2); - y1 = MAX (poly->BoundingBox.Y1, clip_box->Y1); - y2 = MIN (poly->BoundingBox.Y2, clip_box->Y2); + x1 = MAX(poly->BoundingBox.X1, clip_box->X1); + x2 = MIN(poly->BoundingBox.X2, clip_box->X2); + y1 = MAX(poly->BoundingBox.Y1, clip_box->Y1); + y2 = MIN(poly->BoundingBox.Y2, clip_box->Y2); - /* Check if the polygon is outside the clip box */ - if ((x2 <= x1) || (y2 <= y1)) - return 0; + /* Check if the polygon is outside the clip box */ + if ((x2 <= x1) || (y2 <= y1)) + return 0; - poly_bounding_area = (double)(poly->BoundingBox.X2 - poly->BoundingBox.X1) * - (double)(poly->BoundingBox.Y2 - poly->BoundingBox.Y1); + poly_bounding_area = (double) (poly->BoundingBox.X2 - poly->BoundingBox.X1) * + (double) (poly->BoundingBox.Y2 - poly->BoundingBox.Y1); - clipped_poly_area = (double)(x2 - x1) * (double)(y2 - y1); + clipped_poly_area = (double) (x2 - x1) * (double) (y2 - y1); - if (clipped_poly_area / poly_bounding_area >= BOUNDS_INSIDE_CLIP_THRESHOLD) - return 1; + if (clipped_poly_area / poly_bounding_area >= BOUNDS_INSIDE_CLIP_THRESHOLD) + return 1; - return 0; + return 0; } + #undef BOUNDS_INSIDE_CLIP_THRESHOLD -void -common_fill_pcb_polygon (hidGC gc, PolygonType *poly, const BoxType *clip_box) +void common_fill_pcb_polygon(hidGC gc, PolygonType * poly, const BoxType * clip_box) { - if (!poly->NoHolesValid) - { - /* If enough of the polygon is on-screen, compute the entire - * NoHoles version and cache it for later rendering, otherwise - * just compute what we need to render now. - */ - if (should_compute_no_holes (poly, clip_box)) - ComputeNoHoles (poly); - else - NoHolesPolygonDicer (poly, clip_box, fill_contour_cb, gc); - } - if (poly->NoHolesValid && poly->NoHoles) - { - PLINE *pl; + if (!poly->NoHolesValid) { + /* If enough of the polygon is on-screen, compute the entire + * NoHoles version and cache it for later rendering, otherwise + * just compute what we need to render now. + */ + if (should_compute_no_holes(poly, clip_box)) + ComputeNoHoles(poly); + else + NoHolesPolygonDicer(poly, clip_box, fill_contour_cb, gc); + } + if (poly->NoHolesValid && poly->NoHoles) { + PLINE *pl; - for (pl = poly->NoHoles; pl != NULL; pl = pl->next) - { - if (clip_box == NULL) - fill_contour (gc, pl); - else - fill_clipped_contour (gc, pl, clip_box); - } - } + for (pl = poly->NoHoles; pl != NULL; pl = pl->next) { + if (clip_box == NULL) + fill_contour(gc, pl); + else + fill_clipped_contour(gc, pl, clip_box); + } + } - /* Draw other parts of the polygon if fullpoly flag is set */ - /* NB: No "NoHoles" cache for these */ - if (TEST_FLAG (FULLPOLYFLAG, poly)) - { - PolygonType p = *poly; + /* Draw other parts of the polygon if fullpoly flag is set */ + /* NB: No "NoHoles" cache for these */ + if (TEST_FLAG(FULLPOLYFLAG, poly)) { + PolygonType p = *poly; - for (p.Clipped = poly->Clipped->f; - p.Clipped != poly->Clipped; - p.Clipped = p.Clipped->f) - NoHolesPolygonDicer (&p, clip_box, fill_contour_cb, gc); - } + for (p.Clipped = poly->Clipped->f; p.Clipped != poly->Clipped; p.Clipped = p.Clipped->f) + NoHolesPolygonDicer(&p, clip_box, fill_contour_cb, gc); + } } -static int -thindraw_hole_cb (PLINE *pl, void *user_data) +static int thindraw_hole_cb(PLINE * pl, void *user_data) { - hidGC gc = (hidGC)user_data; - thindraw_contour (gc, pl); - return 0; + hidGC gc = (hidGC) user_data; + thindraw_contour(gc, pl); + return 0; } -void -common_thindraw_pcb_polygon (hidGC gc, PolygonType *poly, - const BoxType *clip_box) +void common_thindraw_pcb_polygon(hidGC gc, PolygonType * poly, const BoxType * clip_box) { - thindraw_contour (gc, poly->Clipped->contours); - PolygonHoles (poly, clip_box, thindraw_hole_cb, gc); + thindraw_contour(gc, poly->Clipped->contours); + PolygonHoles(poly, clip_box, thindraw_hole_cb, gc); } -void -common_thindraw_pcb_pad (hidGC gc, PadType *pad, bool clear, bool mask) +void common_thindraw_pcb_pad(hidGC gc, PadType * pad, bool clear, bool mask) { - Coord w = clear ? (mask ? pad->Mask - : pad->Thickness + pad->Clearance) - : pad->Thickness; - Coord x1, y1, x2, y2; - Coord t = w / 2; - x1 = pad->Point1.X; - y1 = pad->Point1.Y; - x2 = pad->Point2.X; - y2 = pad->Point2.Y; - if (x1 > x2 || y1 > y2) - { - Coord temp_x = x1; - Coord temp_y = y1; - x1 = x2; x2 = temp_x; - y1 = y2; y2 = temp_y; - } - gui->set_line_cap (gc, Round_Cap); - gui->set_line_width (gc, 0); - if (TEST_FLAG (SQUAREFLAG, pad)) - { - /* slanted square pad */ - double tx, ty, theta; + Coord w = clear ? (mask ? pad->Mask : pad->Thickness + pad->Clearance) + : pad->Thickness; + Coord x1, y1, x2, y2; + Coord t = w / 2; + x1 = pad->Point1.X; + y1 = pad->Point1.Y; + x2 = pad->Point2.X; + y2 = pad->Point2.Y; + if (x1 > x2 || y1 > y2) { + Coord temp_x = x1; + Coord temp_y = y1; + x1 = x2; + x2 = temp_x; + y1 = y2; + y2 = temp_y; + } + gui->set_line_cap(gc, Round_Cap); + gui->set_line_width(gc, 0); + if (TEST_FLAG(SQUAREFLAG, pad)) { + /* slanted square pad */ + double tx, ty, theta; - if (x1 == x2 && y1 == y2) - theta = 0; - else - theta = atan2 (y2 - y1, x2 - x1); + if (x1 == x2 && y1 == y2) + theta = 0; + else + theta = atan2(y2 - y1, x2 - x1); - /* T is a vector half a thickness long, in the direction of - one of the corners. */ - tx = t * cos (theta + M_PI / 4) * sqrt (2.0); - ty = t * sin (theta + M_PI / 4) * sqrt (2.0); + /* T is a vector half a thickness long, in the direction of + one of the corners. */ + tx = t * cos(theta + M_PI / 4) * sqrt(2.0); + ty = t * sin(theta + M_PI / 4) * sqrt(2.0); - gui->draw_line (gc, x1 - tx, y1 - ty, x2 + ty, y2 - tx); - gui->draw_line (gc, x2 + ty, y2 - tx, x2 + tx, y2 + ty); - gui->draw_line (gc, x2 + tx, y2 + ty, x1 - ty, y1 + tx); - gui->draw_line (gc, x1 - ty, y1 + tx, x1 - tx, y1 - ty); - } - else if (x1 == x2 && y1 == y2) - { - gui->draw_arc (gc, x1, y1, t, t, 0, 360); - } - else - { - /* Slanted round-end pads. */ - Coord dx, dy, ox, oy; - double h; + gui->draw_line(gc, x1 - tx, y1 - ty, x2 + ty, y2 - tx); + gui->draw_line(gc, x2 + ty, y2 - tx, x2 + tx, y2 + ty); + gui->draw_line(gc, x2 + tx, y2 + ty, x1 - ty, y1 + tx); + gui->draw_line(gc, x1 - ty, y1 + tx, x1 - tx, y1 - ty); + } + else if (x1 == x2 && y1 == y2) { + gui->draw_arc(gc, x1, y1, t, t, 0, 360); + } + else { + /* Slanted round-end pads. */ + Coord dx, dy, ox, oy; + double h; - dx = x2 - x1; - dy = y2 - y1; - h = t / sqrt (SQUARE (dx) + SQUARE (dy)); - ox = dy * h + 0.5 * SGN (dy); - oy = -(dx * h + 0.5 * SGN (dx)); + dx = x2 - x1; + dy = y2 - y1; + h = t / sqrt(SQUARE(dx) + SQUARE(dy)); + ox = dy * h + 0.5 * SGN(dy); + oy = -(dx * h + 0.5 * SGN(dx)); - gui->draw_line (gc, x1 + ox, y1 + oy, x2 + ox, y2 + oy); + gui->draw_line(gc, x1 + ox, y1 + oy, x2 + ox, y2 + oy); - if (abs (ox) >= pixel_slop || abs (oy) >= pixel_slop) - { - Angle angle = atan2 (dx, dy) * 57.295779; - gui->draw_line (gc, x1 - ox, y1 - oy, x2 - ox, y2 - oy); - gui->draw_arc (gc, x1, y1, t, t, angle - 180, 180); - gui->draw_arc (gc, x2, y2, t, t, angle, 180); - } - } + if (abs(ox) >= pixel_slop || abs(oy) >= pixel_slop) { + Angle angle = atan2(dx, dy) * 57.295779; + gui->draw_line(gc, x1 - ox, y1 - oy, x2 - ox, y2 - oy); + gui->draw_arc(gc, x1, y1, t, t, angle - 180, 180); + gui->draw_arc(gc, x2, y2, t, t, angle, 180); + } + } } -void -common_fill_pcb_pad (hidGC gc, PadType *pad, bool clear, bool mask) +void common_fill_pcb_pad(hidGC gc, PadType * pad, bool clear, bool mask) { - Coord w = clear ? (mask ? pad->Mask - : pad->Thickness + pad->Clearance) - : pad->Thickness; + Coord w = clear ? (mask ? pad->Mask : pad->Thickness + pad->Clearance) + : pad->Thickness; - if (pad->Point1.X == pad->Point2.X && - pad->Point1.Y == pad->Point2.Y) - { - if (TEST_FLAG (SQUAREFLAG, pad)) - { - Coord l, r, t, b; - l = pad->Point1.X - w / 2; - b = pad->Point1.Y - w / 2; - r = l + w; - t = b + w; - gui->fill_rect (gc, l, b, r, t); - } - else - { - gui->fill_circle (gc, pad->Point1.X, pad->Point1.Y, w / 2); - } - } - else - { - gui->set_line_cap (gc, TEST_FLAG (SQUAREFLAG, pad) ? - Square_Cap : Round_Cap); - gui->set_line_width (gc, w); + if (pad->Point1.X == pad->Point2.X && pad->Point1.Y == pad->Point2.Y) { + if (TEST_FLAG(SQUAREFLAG, pad)) { + Coord l, r, t, b; + l = pad->Point1.X - w / 2; + b = pad->Point1.Y - w / 2; + r = l + w; + t = b + w; + gui->fill_rect(gc, l, b, r, t); + } + else { + gui->fill_circle(gc, pad->Point1.X, pad->Point1.Y, w / 2); + } + } + else { + gui->set_line_cap(gc, TEST_FLAG(SQUAREFLAG, pad) ? Square_Cap : Round_Cap); + gui->set_line_width(gc, w); - gui->draw_line (gc, pad->Point1.X, pad->Point1.Y, - pad->Point2.X, pad->Point2.Y); - } + gui->draw_line(gc, pad->Point1.X, pad->Point1.Y, pad->Point2.X, pad->Point2.Y); + } } /* --------------------------------------------------------------------------- @@ -313,181 +279,158 @@ * 2 --- 1 */ -typedef struct -{ - double X, Y; -} -FloatPolyType; +typedef struct { + double X, Y; +} FloatPolyType; -static void -draw_square_pin_poly (hidGC gc, Coord X, Coord Y, - Coord Thickness, Coord thin_draw, int style) +static void draw_square_pin_poly(hidGC gc, Coord X, Coord Y, Coord Thickness, Coord thin_draw, int style) { - static FloatPolyType p[8] = { - { 0.5, -TAN_22_5_DEGREE_2}, - { TAN_22_5_DEGREE_2, -0.5 }, - {-TAN_22_5_DEGREE_2, -0.5 }, - {-0.5, -TAN_22_5_DEGREE_2}, - {-0.5, TAN_22_5_DEGREE_2}, - {-TAN_22_5_DEGREE_2, 0.5 }, - { TAN_22_5_DEGREE_2, 0.5 }, - { 0.5, TAN_22_5_DEGREE_2} - }; - static int special_size = 0; - static int scaled_x[8]; - static int scaled_y[8]; - Coord polygon_x[9]; - Coord polygon_y[9]; - double xm[8], ym[8]; - int i; + static FloatPolyType p[8] = { + {0.5, -TAN_22_5_DEGREE_2}, + {TAN_22_5_DEGREE_2, -0.5}, + {-TAN_22_5_DEGREE_2, -0.5}, + {-0.5, -TAN_22_5_DEGREE_2}, + {-0.5, TAN_22_5_DEGREE_2}, + {-TAN_22_5_DEGREE_2, 0.5}, + {TAN_22_5_DEGREE_2, 0.5}, + {0.5, TAN_22_5_DEGREE_2} + }; + static int special_size = 0; + static int scaled_x[8]; + static int scaled_y[8]; + Coord polygon_x[9]; + Coord polygon_y[9]; + double xm[8], ym[8]; + int i; square_pin_factors(style, xm, ym); - if (Thickness != special_size) - { - special_size = Thickness; - for (i = 0; i < 8; i++) - { - scaled_x[i] = p[i].X * special_size; - scaled_y[i] = p[i].Y * special_size; - } - } - /* add line offset */ - for (i = 0; i < 8; i++) - { - polygon_x[i] = X + scaled_x[i]*xm[i]; - polygon_y[i] = Y + scaled_y[i]*ym[i]; - } + if (Thickness != special_size) { + special_size = Thickness; + for (i = 0; i < 8; i++) { + scaled_x[i] = p[i].X * special_size; + scaled_y[i] = p[i].Y * special_size; + } + } + /* add line offset */ + for (i = 0; i < 8; i++) { + polygon_x[i] = X + scaled_x[i] * xm[i]; + polygon_y[i] = Y + scaled_y[i] * ym[i]; + } - if (thin_draw) - { - int i; - gui->set_line_cap (gc, Round_Cap); - gui->set_line_width (gc, 0); - polygon_x[8] = X + scaled_x[0]*xm[0]; - polygon_y[8] = Y + scaled_y[0]*ym[0]; - for (i = 0; i < 8; i++) - gui->draw_line (gc, polygon_x[i ], polygon_y[i ], - polygon_x[i + 1], polygon_y[i + 1]); - } - else - gui->fill_polygon (gc, 8, polygon_x, polygon_y); + if (thin_draw) { + int i; + gui->set_line_cap(gc, Round_Cap); + gui->set_line_width(gc, 0); + polygon_x[8] = X + scaled_x[0] * xm[0]; + polygon_y[8] = Y + scaled_y[0] * ym[0]; + for (i = 0; i < 8; i++) + gui->draw_line(gc, polygon_x[i], polygon_y[i], polygon_x[i + 1], polygon_y[i + 1]); + } + else + gui->fill_polygon(gc, 8, polygon_x, polygon_y); } -static void -draw_octagon_poly (hidGC gc, Coord X, Coord Y, - Coord Thickness, Coord thin_draw) +static void draw_octagon_poly(hidGC gc, Coord X, Coord Y, Coord Thickness, Coord thin_draw) { - draw_square_pin_poly (gc, X, Y, Thickness, thin_draw, 17); + draw_square_pin_poly(gc, X, Y, Thickness, thin_draw, 17); } -void -common_fill_pcb_pv (hidGC fg_gc, hidGC bg_gc, PinType *pv, bool drawHole, bool mask) +void common_fill_pcb_pv(hidGC fg_gc, hidGC bg_gc, PinType * pv, bool drawHole, bool mask) { - Coord w = mask ? pv->Mask : pv->Thickness; - Coord r = w / 2; + Coord w = mask ? pv->Mask : pv->Thickness; + Coord r = w / 2; - if (TEST_FLAG (HOLEFLAG, pv)) - { - if (mask) - gui->fill_circle (bg_gc, pv->X, pv->Y, r); - if (drawHole) - { - gui->fill_circle (bg_gc, pv->X, pv->Y, r); - gui->set_line_cap (fg_gc, Round_Cap); - gui->set_line_width (fg_gc, 0); - gui->draw_arc (fg_gc, pv->X, pv->Y, r, r, 0, 360); - } - return; - } + if (TEST_FLAG(HOLEFLAG, pv)) { + if (mask) + gui->fill_circle(bg_gc, pv->X, pv->Y, r); + if (drawHole) { + gui->fill_circle(bg_gc, pv->X, pv->Y, r); + gui->set_line_cap(fg_gc, Round_Cap); + gui->set_line_width(fg_gc, 0); + gui->draw_arc(fg_gc, pv->X, pv->Y, r, r, 0, 360); + } + return; + } - if (TEST_FLAG (SQUAREFLAG, pv)) - { - /* use the original code for now */ - if ((GET_SQUARE(pv) == 0) || (GET_SQUARE(pv) == 1)) { - Coord l = pv->X - r; - Coord b = pv->Y - r; - Coord r = l + w; - Coord t = b + w; - gui->fill_rect (fg_gc, l, b, r, t); - } - else - draw_square_pin_poly (fg_gc, pv->X, pv->Y, w, false, GET_SQUARE(pv)); - } - else if (TEST_FLAG (OCTAGONFLAG, pv)) - draw_octagon_poly (fg_gc, pv->X, pv->Y, w, false); - else /* draw a round pin or via */ - gui->fill_circle (fg_gc, pv->X, pv->Y, r); + if (TEST_FLAG(SQUAREFLAG, pv)) { + /* use the original code for now */ + if ((GET_SQUARE(pv) == 0) || (GET_SQUARE(pv) == 1)) { + Coord l = pv->X - r; + Coord b = pv->Y - r; + Coord r = l + w; + Coord t = b + w; + gui->fill_rect(fg_gc, l, b, r, t); + } + else + draw_square_pin_poly(fg_gc, pv->X, pv->Y, w, false, GET_SQUARE(pv)); + } + else if (TEST_FLAG(OCTAGONFLAG, pv)) + draw_octagon_poly(fg_gc, pv->X, pv->Y, w, false); + else /* draw a round pin or via */ + gui->fill_circle(fg_gc, pv->X, pv->Y, r); - /* and the drilling hole (which is always round) */ - if (drawHole) - gui->fill_circle (bg_gc, pv->X, pv->Y, pv->DrillingHole / 2); + /* and the drilling hole (which is always round) */ + if (drawHole) + gui->fill_circle(bg_gc, pv->X, pv->Y, pv->DrillingHole / 2); } -void -common_thindraw_pcb_pv (hidGC fg_gc, hidGC bg_gc, PinType *pv, bool drawHole, bool mask) +void common_thindraw_pcb_pv(hidGC fg_gc, hidGC bg_gc, PinType * pv, bool drawHole, bool mask) { - Coord w = mask ? pv->Mask : pv->Thickness; - Coord r = w / 2; + Coord w = mask ? pv->Mask : pv->Thickness; + Coord r = w / 2; - if (TEST_FLAG (HOLEFLAG, pv)) - { - if (mask) - gui->draw_arc (fg_gc, pv->X, pv->Y, r, r, 0, 360); - if (drawHole) - { - r = pv->DrillingHole / 2; - gui->set_line_cap (bg_gc, Round_Cap); - gui->set_line_width (bg_gc, 0); - gui->draw_arc (bg_gc, pv->X, pv->Y, r, r, 0, 360); - } - return; - } + if (TEST_FLAG(HOLEFLAG, pv)) { + if (mask) + gui->draw_arc(fg_gc, pv->X, pv->Y, r, r, 0, 360); + if (drawHole) { + r = pv->DrillingHole / 2; + gui->set_line_cap(bg_gc, Round_Cap); + gui->set_line_width(bg_gc, 0); + gui->draw_arc(bg_gc, pv->X, pv->Y, r, r, 0, 360); + } + return; + } - if (TEST_FLAG (SQUAREFLAG, pv)) - { - Coord l = pv->X - r; - Coord b = pv->Y - r; - Coord r = l + w; - Coord t = b + w; + if (TEST_FLAG(SQUAREFLAG, pv)) { + Coord l = pv->X - r; + Coord b = pv->Y - r; + Coord r = l + w; + Coord t = b + w; - gui->set_line_cap (fg_gc, Round_Cap); - gui->set_line_width (fg_gc, 0); - gui->draw_line (fg_gc, r, t, r, b); - gui->draw_line (fg_gc, l, t, l, b); - gui->draw_line (fg_gc, r, t, l, t); - gui->draw_line (fg_gc, r, b, l, b); + gui->set_line_cap(fg_gc, Round_Cap); + gui->set_line_width(fg_gc, 0); + gui->draw_line(fg_gc, r, t, r, b); + gui->draw_line(fg_gc, l, t, l, b); + gui->draw_line(fg_gc, r, t, l, t); + gui->draw_line(fg_gc, r, b, l, b); - } - else if (TEST_FLAG (OCTAGONFLAG, pv)) - { - draw_octagon_poly (fg_gc, pv->X, pv->Y, w, true); - } - else /* draw a round pin or via */ - { - gui->set_line_cap (fg_gc, Round_Cap); - gui->set_line_width (fg_gc, 0); - gui->draw_arc (fg_gc, pv->X, pv->Y, r, r, 0, 360); - } + } + else if (TEST_FLAG(OCTAGONFLAG, pv)) { + draw_octagon_poly(fg_gc, pv->X, pv->Y, w, true); + } + else { /* draw a round pin or via */ - /* and the drilling hole (which is always round */ - if (drawHole) - { - gui->set_line_cap (bg_gc, Round_Cap); - gui->set_line_width (bg_gc, 0); - gui->draw_arc (bg_gc, pv->X, pv->Y, pv->DrillingHole / 2, - pv->DrillingHole / 2, 0, 360); - } + gui->set_line_cap(fg_gc, Round_Cap); + gui->set_line_width(fg_gc, 0); + gui->draw_arc(fg_gc, pv->X, pv->Y, r, r, 0, 360); + } + + /* and the drilling hole (which is always round */ + if (drawHole) { + gui->set_line_cap(bg_gc, Round_Cap); + gui->set_line_width(bg_gc, 0); + gui->draw_arc(bg_gc, pv->X, pv->Y, pv->DrillingHole / 2, pv->DrillingHole / 2, 0, 360); + } } -void -common_draw_helpers_init (HID *hid) +void common_draw_helpers_init(HID * hid) { - hid->fill_pcb_polygon = common_fill_pcb_polygon; - hid->thindraw_pcb_polygon = common_thindraw_pcb_polygon; - hid->fill_pcb_pad = common_fill_pcb_pad; - hid->thindraw_pcb_pad = common_thindraw_pcb_pad; - hid->fill_pcb_pv = common_fill_pcb_pv; - hid->thindraw_pcb_pv = common_thindraw_pcb_pv; + hid->fill_pcb_polygon = common_fill_pcb_polygon; + hid->thindraw_pcb_polygon = common_thindraw_pcb_polygon; + hid->fill_pcb_pad = common_fill_pcb_pad; + hid->thindraw_pcb_pad = common_thindraw_pcb_pad; + hid->fill_pcb_pv = common_fill_pcb_pv; + hid->thindraw_pcb_pv = common_thindraw_pcb_pv; } Index: trunk/src/hid/common/draw_helpers.h =================================================================== --- trunk/src/hid/common/draw_helpers.h (revision 1021) +++ trunk/src/hid/common/draw_helpers.h (revision 1022) @@ -1,9 +1,7 @@ -void common_fill_pcb_polygon (hidGC gc, PolygonType *poly, - const BoxType *clip_box); -void common_thindraw_pcb_polygon (hidGC gc, PolygonType *poly, - const BoxType *clip_box); -void common_fill_pcb_pad (hidGC gc, PadType *pad, bool clear, bool mask); -void common_thindraw_pcb_pad (hidGC gc, PadType *pad, bool clear, bool mask); -void common_fill_pcb_pv (hidGC gc, PinType *pv, bool drawHole, bool mask); -void common_thindraw_pcb_pv (hidGC fg_gc, hidGC bg_gc, PinType *pv, bool drawHole, bool mask); -void common_draw_helpers_init (HID *hid); +void common_fill_pcb_polygon(hidGC gc, PolygonType * poly, const BoxType * clip_box); +void common_thindraw_pcb_polygon(hidGC gc, PolygonType * poly, const BoxType * clip_box); +void common_fill_pcb_pad(hidGC gc, PadType * pad, bool clear, bool mask); +void common_thindraw_pcb_pad(hidGC gc, PadType * pad, bool clear, bool mask); +void common_fill_pcb_pv(hidGC gc, PinType * pv, bool drawHole, bool mask); +void common_thindraw_pcb_pv(hidGC fg_gc, hidGC bg_gc, PinType * pv, bool drawHole, bool mask); +void common_draw_helpers_init(HID * hid); Index: trunk/src/hid/common/extents.c =================================================================== --- trunk/src/hid/common/extents.c (revision 1021) +++ trunk/src/hid/common/extents.c (revision 1022) @@ -18,7 +18,7 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); #ifndef MAXINT #define MAXINT (((unsigned int)(~0))>>1) @@ -26,75 +26,63 @@ static BoxType box; -typedef struct hid_gc_struct -{ - int width; +typedef struct hid_gc_struct { + int width; } hid_gc_struct; -static int -extents_set_layer (const char *name, int group, int empty) +static int extents_set_layer(const char *name, int group, int empty) { - int idx = group; - if (idx >= 0 && idx < max_group) - { - idx = PCB->LayerGroups.Entries[idx][0]; - } - if (idx >= 0 && idx < max_copper_layer + 2) - return 1; - if (idx < 0) - { - switch (SL_TYPE (idx)) - { - case SL_INVISIBLE: - case SL_MASK: - case SL_ASSY: - return 0; - case SL_SILK: - case SL_PDRILL: - case SL_UDRILL: - return 1; + int idx = group; + if (idx >= 0 && idx < max_group) { + idx = PCB->LayerGroups.Entries[idx][0]; } - } - return 0; + if (idx >= 0 && idx < max_copper_layer + 2) + return 1; + if (idx < 0) { + switch (SL_TYPE(idx)) { + case SL_INVISIBLE: + case SL_MASK: + case SL_ASSY: + return 0; + case SL_SILK: + case SL_PDRILL: + case SL_UDRILL: + return 1; + } + } + return 0; } -static hidGC -extents_make_gc (void) +static hidGC extents_make_gc(void) { - hidGC rv = (hidGC)malloc (sizeof (hid_gc_struct)); - memset (rv, 0, sizeof (hid_gc_struct)); - return rv; + hidGC rv = (hidGC) malloc(sizeof(hid_gc_struct)); + memset(rv, 0, sizeof(hid_gc_struct)); + return rv; } -static void -extents_destroy_gc (hidGC gc) +static void extents_destroy_gc(hidGC gc) { - free (gc); + free(gc); } -static void -extents_use_mask (int use_it) +static void extents_use_mask(int use_it) { } -static void -extents_set_color (hidGC gc, const char *name) +static void extents_set_color(hidGC gc, const char *name) { } -static void -extents_set_line_cap (hidGC gc, EndCapStyle style) +static void extents_set_line_cap(hidGC gc, EndCapStyle style) { } -static void -extents_set_line_width (hidGC gc, Coord width) +static void extents_set_line_width(hidGC gc, Coord width) { - gc->width = width; + gc->width = width; } -static void -extents_set_draw_xor (hidGC gc, int xor_) +static void extents_set_draw_xor(hidGC gc, int xor_) { } @@ -103,115 +91,105 @@ #define PEY(y,w) if (box.Y1 > (y)-(w)) box.Y1 = (y)-(w); \ if (box.Y2 < (y)+(w)) box.Y2 = (y)+(w) -static void -extents_draw_line (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) +static void extents_draw_line(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) { - PEX (x1, gc->width); - PEY (y1, gc->width); - PEX (x2, gc->width); - PEY (y2, gc->width); + PEX(x1, gc->width); + PEY(y1, gc->width); + PEX(x2, gc->width); + PEY(y2, gc->width); } -static void -extents_draw_arc (hidGC gc, Coord cx, Coord cy, Coord width, Coord height, - Angle start_angle, Angle end_angle) +static void extents_draw_arc(hidGC gc, Coord cx, Coord cy, Coord width, Coord height, Angle start_angle, Angle end_angle) { - /* Naive but good enough. */ - PEX (cx, width + gc->width); - PEY (cy, height + gc->width); + /* Naive but good enough. */ + PEX(cx, width + gc->width); + PEY(cy, height + gc->width); } -static void -extents_draw_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) +static void extents_draw_rect(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) { - PEX (x1, gc->width); - PEY (y1, gc->width); - PEX (x2, gc->width); - PEY (y2, gc->width); + PEX(x1, gc->width); + PEY(y1, gc->width); + PEX(x2, gc->width); + PEY(y2, gc->width); } -static void -extents_fill_circle (hidGC gc, Coord cx, Coord cy, Coord radius) +static void extents_fill_circle(hidGC gc, Coord cx, Coord cy, Coord radius) { - PEX (cx, radius); - PEY (cy, radius); + PEX(cx, radius); + PEY(cy, radius); } -static void -extents_fill_polygon (hidGC gc, int n_coords, Coord *x, Coord *y) +static void extents_fill_polygon(hidGC gc, int n_coords, Coord * x, Coord * y) { - int i; - for (i = 0; i < n_coords; i++) - { - PEX (x[i], 0); - PEY (y[i], 0); - } + int i; + for (i = 0; i < n_coords; i++) { + PEX(x[i], 0); + PEY(y[i], 0); + } } -static void -extents_fill_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) +static void extents_fill_rect(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) { - PEX (x1, 0); - PEY (y1, 0); - PEX (x2, 0); - PEY (y2, 0); + PEX(x1, 0); + PEY(y1, 0); + PEX(x2, 0); + PEY(y2, 0); } static HID extents_hid; -void -hid_extents_init (void) +void hid_extents_init(void) { - static bool initialised = false; + static bool initialised = false; - if (initialised) - return; + if (initialised) + return; - memset (&extents_hid, 0, sizeof (HID)); + memset(&extents_hid, 0, sizeof(HID)); - common_draw_helpers_init (&extents_hid); + common_draw_helpers_init(&extents_hid); - extents_hid.struct_size = sizeof (HID); - extents_hid.name = "extents-extents"; - extents_hid.description = "used to calculate extents"; - extents_hid.poly_before = 1; + extents_hid.struct_size = sizeof(HID); + extents_hid.name = "extents-extents"; + extents_hid.description = "used to calculate extents"; + extents_hid.poly_before = 1; - extents_hid.set_layer = extents_set_layer; - extents_hid.make_gc = extents_make_gc; - extents_hid.destroy_gc = extents_destroy_gc; - extents_hid.use_mask = extents_use_mask; - extents_hid.set_color = extents_set_color; - extents_hid.set_line_cap = extents_set_line_cap; - extents_hid.set_line_width = extents_set_line_width; - extents_hid.set_draw_xor = extents_set_draw_xor; - extents_hid.draw_line = extents_draw_line; - extents_hid.draw_arc = extents_draw_arc; - extents_hid.draw_rect = extents_draw_rect; - extents_hid.fill_circle = extents_fill_circle; - extents_hid.fill_polygon = extents_fill_polygon; - extents_hid.fill_rect = extents_fill_rect; + extents_hid.set_layer = extents_set_layer; + extents_hid.make_gc = extents_make_gc; + extents_hid.destroy_gc = extents_destroy_gc; + extents_hid.use_mask = extents_use_mask; + extents_hid.set_color = extents_set_color; + extents_hid.set_line_cap = extents_set_line_cap; + extents_hid.set_line_width = extents_set_line_width; + extents_hid.set_draw_xor = extents_set_draw_xor; + extents_hid.draw_line = extents_draw_line; + extents_hid.draw_arc = extents_draw_arc; + extents_hid.draw_rect = extents_draw_rect; + extents_hid.fill_circle = extents_fill_circle; + extents_hid.fill_polygon = extents_fill_polygon; + extents_hid.fill_rect = extents_fill_rect; - initialised = true; + initialised = true; } -BoxType * -hid_get_extents (void *item) +BoxType *hid_get_extents(void *item) { - BoxType region; + BoxType region; - /* As this isn't a real "HID", we need to ensure we are initialised. */ - hid_extents_init (); + /* As this isn't a real "HID", we need to ensure we are initialised. */ + hid_extents_init(); - box.X1 = MAXINT; - box.Y1 = MAXINT; - box.X2 = -MAXINT; - box.Y2 = -MAXINT; + box.X1 = MAXINT; + box.Y1 = MAXINT; + box.X2 = -MAXINT; + box.Y2 = -MAXINT; - region.X1 = -MAXINT; - region.Y1 = -MAXINT; - region.X2 = MAXINT; - region.Y2 = MAXINT; - hid_expose_callback (&extents_hid, ®ion, item); + region.X1 = -MAXINT; + region.Y1 = -MAXINT; + region.X2 = MAXINT; + region.Y2 = MAXINT; + hid_expose_callback(&extents_hid, ®ion, item); - return &box; + return &box; } Index: trunk/src/hid/common/flags.c =================================================================== --- trunk/src/hid/common/flags.c (revision 1021) +++ trunk/src/hid/common/flags.c (revision 1022) @@ -17,13 +17,12 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); -typedef struct HID_FlagNode -{ - struct HID_FlagNode *next; - HID_Flag *flags; - int n; +typedef struct HID_FlagNode { + struct HID_FlagNode *next; + HID_Flag *flags; + int n; } HID_FlagNode; HID_FlagNode *hid_flag_nodes = 0; @@ -30,191 +29,166 @@ static int n_flags = 0; static HID_Flag *all_flags = 0; -void -hid_register_flags (HID_Flag * a, int n) +void hid_register_flags(HID_Flag * a, int n) { - HID_FlagNode *ha; + HID_FlagNode *ha; - /* printf("%d flag%s registered\n", n, n==1 ? "" : "s"); */ - ha = (HID_FlagNode *) malloc (sizeof (HID_FlagNode)); - ha->next = hid_flag_nodes; - hid_flag_nodes = ha; - ha->flags = a; - ha->n = n; - n_flags += n; - if (all_flags) - { - free (all_flags); - all_flags = 0; - } + /* printf("%d flag%s registered\n", n, n==1 ? "" : "s"); */ + ha = (HID_FlagNode *) malloc(sizeof(HID_FlagNode)); + ha->next = hid_flag_nodes; + hid_flag_nodes = ha; + ha->flags = a; + ha->n = n; + n_flags += n; + if (all_flags) { + free(all_flags); + all_flags = 0; + } } -static int -flag_sort (const void *va, const void *vb) +static int flag_sort(const void *va, const void *vb) { - HID_Flag *a = (HID_Flag *) va; - HID_Flag *b = (HID_Flag *) vb; - return strcmp (a->name, b->name); + HID_Flag *a = (HID_Flag *) va; + HID_Flag *b = (HID_Flag *) vb; + return strcmp(a->name, b->name); } -HID_Flag * -hid_find_flag (const char *name) +HID_Flag *hid_find_flag(const char *name) { - HID_FlagNode *hf; - int i, n, lower, upper; + HID_FlagNode *hf; + int i, n, lower, upper; - if (all_flags == 0) - { - n = 0; - all_flags = (HID_Flag *)malloc (n_flags * sizeof (HID_Flag)); - for (hf = hid_flag_nodes; hf; hf = hf->next) - for (i = 0; i < hf->n; i++) - all_flags[n++] = hf->flags[i]; - qsort (all_flags, n_flags, sizeof (HID_Flag), flag_sort); - } + if (all_flags == 0) { + n = 0; + all_flags = (HID_Flag *) malloc(n_flags * sizeof(HID_Flag)); + for (hf = hid_flag_nodes; hf; hf = hf->next) + for (i = 0; i < hf->n; i++) + all_flags[n++] = hf->flags[i]; + qsort(all_flags, n_flags, sizeof(HID_Flag), flag_sort); + } - lower = -1; - upper = n_flags + 1; - /*printf("search flag %s\n", name); */ - while (lower < upper - 1) - { - i = (lower + upper) / 2; - n = strcmp (all_flags[i].name, name); - /*printf("try [%d].%s, cmp %d\n", i, all_flags[i].name, n); */ - if (n == 0) - return all_flags + i; - if (n > 0) - upper = i; - else - lower = i; - } - printf ("unknown flag `%s'\n", name); - return 0; + lower = -1; + upper = n_flags + 1; + /*printf("search flag %s\n", name); */ + while (lower < upper - 1) { + i = (lower + upper) / 2; + n = strcmp(all_flags[i].name, name); + /*printf("try [%d].%s, cmp %d\n", i, all_flags[i].name, n); */ + if (n == 0) + return all_flags + i; + if (n > 0) + upper = i; + else + lower = i; + } + printf("unknown flag `%s'\n", name); + return 0; } -int -hid_get_flag (const char *name) +int hid_get_flag(const char *name) { - static char *buf = 0; - static int nbuf = 0; - const char *cp; - HID_Flag *f; + static char *buf = 0; + static int nbuf = 0; + const char *cp; + HID_Flag *f; - cp = strchr (name, ','); - if (cp) - { - int wv; + cp = strchr(name, ','); + if (cp) { + int wv; - if (nbuf < (cp - name + 1)) - { - nbuf = cp - name + 10; - buf = (char *)realloc (buf, nbuf); + if (nbuf < (cp - name + 1)) { + nbuf = cp - name + 10; + buf = (char *) realloc(buf, nbuf); + } + memcpy(buf, name, cp - name); + buf[cp - name] = 0; + /* A number without units is just a number. */ + wv = GetValueEx(cp + 1, NULL, NULL, NULL, NULL); + f = hid_find_flag(buf); + if (!f) + return 0; + return f->function(f->parm) == wv; } - memcpy (buf, name, cp - name); - buf[cp - name] = 0; - /* A number without units is just a number. */ - wv = GetValueEx (cp + 1, NULL, NULL, NULL, NULL); - f = hid_find_flag (buf); - if (!f) - return 0; - return f->function (f->parm) == wv; - } - f = hid_find_flag (name); - if (!f) - return 0; - return f->function (f->parm); + f = hid_find_flag(name); + if (!f) + return 0; + return f->function(f->parm); } -void -hid_save_and_show_layer_ons (int *save_array) +void hid_save_and_show_layer_ons(int *save_array) { - int i; - for (i = 0; i < max_copper_layer + 2; i++) - { - save_array[i] = PCB->Data->Layer[i].On; - PCB->Data->Layer[i].On = 1; - } + int i; + for (i = 0; i < max_copper_layer + 2; i++) { + save_array[i] = PCB->Data->Layer[i].On; + PCB->Data->Layer[i].On = 1; + } } -void -hid_restore_layer_ons (int *save_array) +void hid_restore_layer_ons(int *save_array) { - int i; - for (i = 0; i < max_copper_layer + 2; i++) - PCB->Data->Layer[i].On = save_array[i]; + int i; + for (i = 0; i < max_copper_layer + 2; i++) + PCB->Data->Layer[i].On = save_array[i]; } -const char * -layer_type_to_file_name (int idx, int style) +const char *layer_type_to_file_name(int idx, int style) { - int group; - int nlayers; - const char *single_name; + int group; + int nlayers; + const char *single_name; - switch (idx) - { - case SL (SILK, TOP): - return "topsilk"; - case SL (SILK, BOTTOM): - return "bottomsilk"; - case SL (MASK, TOP): - return "topmask"; - case SL (MASK, BOTTOM): - return "bottommask"; - case SL (PDRILL, 0): - return "plated-drill"; - case SL (UDRILL, 0): - return "unplated-drill"; - case SL (PASTE, TOP): - return "toppaste"; - case SL (PASTE, BOTTOM): - return "bottompaste"; - case SL (INVISIBLE, 0): - return "invisible"; - case SL (FAB, 0): - return "fab"; - case SL (ASSY, TOP): - return "topassembly"; - case SL (ASSY, BOTTOM): - return "bottomassembly"; - default: - group = GetLayerGroupNumberByNumber(idx); - nlayers = PCB->LayerGroups.Number[group]; - single_name = PCB->Data->Layer[idx].Name; - if (group == GetLayerGroupNumberByNumber(component_silk_layer)) - { - if (style == FNS_first - || (style == FNS_single - && nlayers == 2)) - return single_name; - return "top"; + switch (idx) { + case SL(SILK, TOP): + return "topsilk"; + case SL(SILK, BOTTOM): + return "bottomsilk"; + case SL(MASK, TOP): + return "topmask"; + case SL(MASK, BOTTOM): + return "bottommask"; + case SL(PDRILL, 0): + return "plated-drill"; + case SL(UDRILL, 0): + return "unplated-drill"; + case SL(PASTE, TOP): + return "toppaste"; + case SL(PASTE, BOTTOM): + return "bottompaste"; + case SL(INVISIBLE, 0): + return "invisible"; + case SL(FAB, 0): + return "fab"; + case SL(ASSY, TOP): + return "topassembly"; + case SL(ASSY, BOTTOM): + return "bottomassembly"; + default: + group = GetLayerGroupNumberByNumber(idx); + nlayers = PCB->LayerGroups.Number[group]; + single_name = PCB->Data->Layer[idx].Name; + if (group == GetLayerGroupNumberByNumber(component_silk_layer)) { + if (style == FNS_first || (style == FNS_single && nlayers == 2)) + return single_name; + return "top"; + } + else if (group == GetLayerGroupNumberByNumber(solder_silk_layer)) { + if (style == FNS_first || (style == FNS_single && nlayers == 2)) + return single_name; + return "bottom"; + } + else if (nlayers == 1 + && (strcmp(PCB->Data->Layer[idx].Name, "route") == 0 || strcmp(PCB->Data->Layer[idx].Name, "outline") == 0)) { + return "outline"; + } + else { + static char buf[20]; + if (style == FNS_first || (style == FNS_single && nlayers == 1)) + return single_name; + sprintf(buf, "group%d", group); + return buf; + } + break; } - else if (group == GetLayerGroupNumberByNumber(solder_silk_layer)) - { - if (style == FNS_first - || (style == FNS_single - && nlayers == 2)) - return single_name; - return "bottom"; - } - else if (nlayers == 1 - && (strcmp (PCB->Data->Layer[idx].Name, "route") == 0 || - strcmp (PCB->Data->Layer[idx].Name, "outline") == 0)) - { - return "outline"; - } - else - { - static char buf[20]; - if (style == FNS_first - || (style == FNS_single - && nlayers == 1)) - return single_name; - sprintf (buf, "group%d", group); - return buf; - } - break; - } } Index: trunk/src/hid/common/hid_resource.c =================================================================== --- trunk/src/hid/common/hid_resource.c (revision 1021) +++ trunk/src/hid/common/hid_resource.c (revision 1022) @@ -9,200 +9,187 @@ /* #define DEBUG_HID_RESOURCE */ -static int button_count; /* number of buttons we have actions for */ -static int *button_nums; /* list of button numbers */ -static int *mod_count; /* how many mods they have */ -static unsigned *mods; /* mods, in order, one button after another */ -static Resource** actions; /* actions, in order, one button after another */ +static int button_count; /* number of buttons we have actions for */ +static int *button_nums; /* list of button numbers */ +static int *mod_count; /* how many mods they have */ +static unsigned *mods; /* mods, in order, one button after another */ +static Resource **actions; /* actions, in order, one button after another */ -static Resource * -res_wrap (char *value) +static Resource *res_wrap(char *value) { - Resource *tmp; - tmp = resource_create (0); - resource_add_val (tmp, 0, value, 0); - return tmp; + Resource *tmp; + tmp = resource_create(0); + resource_add_val(tmp, 0, value, 0); + return tmp; } -static unsigned -parse_mods (char *value) +static unsigned parse_mods(char *value) { - unsigned m = 0; - long int mod_num; - char *s; + unsigned m = 0; + long int mod_num; + char *s; - for (s=value; *s; s++) - *s = tolower(*s); + for (s = value; *s; s++) + *s = tolower(*s); - s = strstr(value, "mod"); - if (s) - { - s += 3; /* skip "mod" to get to number */ - errno = 0; - mod_num = strtol(s, (char**) NULL, 0); - if (!errno) - m |= M_Mod(mod_num); - } - if (strstr(value, "shift")) - m |= M_Shift; - if (strstr(value, "ctrl")) - m |= M_Ctrl; - if (strstr(value, "alt")) - m |= M_Alt; - if (strstr(value, "up")) - m |= M_Release; - return m; + s = strstr(value, "mod"); + if (s) { + s += 3; /* skip "mod" to get to number */ + errno = 0; + mod_num = strtol(s, (char **) NULL, 0); + if (!errno) + m |= M_Mod(mod_num); + } + if (strstr(value, "shift")) + m |= M_Shift; + if (strstr(value, "ctrl")) + m |= M_Ctrl; + if (strstr(value, "alt")) + m |= M_Alt; + if (strstr(value, "up")) + m |= M_Release; + return m; } -static int -button_name_to_num (const char *name) +static int button_name_to_num(const char *name) { - /* All mouse-related resources must be named. The name is the - mouse button number. */ - if (!name) - return -1; - else if (strcasecmp (name, "left") == 0) - return 1; - else if (strcasecmp (name, "middle") == 0) - return 2; - else if (strcasecmp (name, "right") == 0) - return 3; - else if (strcasecmp (name, "up") == 0) - return 4; - else if (strcasecmp (name, "down") == 0) - return 5; - else - return atoi (name); + /* All mouse-related resources must be named. The name is the + mouse button number. */ + if (!name) + return -1; + else if (strcasecmp(name, "left") == 0) + return 1; + else if (strcasecmp(name, "middle") == 0) + return 2; + else if (strcasecmp(name, "right") == 0) + return 3; + else if (strcasecmp(name, "up") == 0) + return 4; + else if (strcasecmp(name, "down") == 0) + return 5; + else + return atoi(name); } -void -load_mouse_resource (const Resource *res) +void load_mouse_resource(const Resource * res) { - int bi, mi, a; - int action_count; + int bi, mi, a; + int action_count; #ifdef DEBUG_HID_RESOURCE - fprintf(stderr, "note mouse resource:\n"); - resource_dump (res); + fprintf(stderr, "note mouse resource:\n"); + resource_dump(res); #endif - button_count = res->c; - button_nums = (int *)malloc(res->c * sizeof(int)); - mod_count = (int *)malloc(res->c * sizeof(int)); - action_count = 0; - for (bi=0; bic; bi++) - { - if (res->v[bi].value) - action_count++; + button_count = res->c; + button_nums = (int *) malloc(res->c * sizeof(int)); + mod_count = (int *) malloc(res->c * sizeof(int)); + action_count = 0; + for (bi = 0; bi < res->c; bi++) { + if (res->v[bi].value) + action_count++; - if (res->v[bi].subres) - action_count += res->v[bi].subres->c; + if (res->v[bi].subres) + action_count += res->v[bi].subres->c; - } - mods = (unsigned int *)malloc(action_count * sizeof(int)); - actions = (Resource **)malloc(action_count * sizeof(Resource*)); + } + mods = (unsigned int *) malloc(action_count * sizeof(int)); + actions = (Resource **) malloc(action_count * sizeof(Resource *)); - a = 0; - for (bi=0; bic; bi++) - { - int button_num = button_name_to_num(res->v[bi].name); + a = 0; + for (bi = 0; bi < res->c; bi++) { + int button_num = button_name_to_num(res->v[bi].name); - if (button_num < 0) - continue; + if (button_num < 0) + continue; - button_nums[bi] = button_num; - mod_count[bi] = 0; + button_nums[bi] = button_num; + mod_count[bi] = 0; - if (res->v[bi].value) - { - mods[a] = 0; - actions[a++] = res_wrap (res->v[bi].value); - mod_count[bi] = 1; - } + if (res->v[bi].value) { + mods[a] = 0; + actions[a++] = res_wrap(res->v[bi].value); + mod_count[bi] = 1; + } - if (res->v[bi].subres) - { - Resource *m = res->v[bi].subres; - mod_count[bi] += m->c; + if (res->v[bi].subres) { + Resource *m = res->v[bi].subres; + mod_count[bi] += m->c; - for (mi=0; mic; mi++, a++) - { - switch (resource_type (m->v[mi])) - { - case 1: /* subres only */ - mods[a] = 0; - actions[a] = m->v[mi].subres; - break; + for (mi = 0; mi < m->c; mi++, a++) { + switch (resource_type(m->v[mi])) { + case 1: /* subres only */ + mods[a] = 0; + actions[a] = m->v[mi].subres; + break; - case 10: /* value only */ - mods[a] = 0; - actions[a] = res_wrap (m->v[mi].value); - break; + case 10: /* value only */ + mods[a] = 0; + actions[a] = res_wrap(m->v[mi].value); + break; - case 101: /* name = subres */ - mods[a] = parse_mods (m->v[mi].name); - actions[a] = m->v[mi].subres; - break; + case 101: /* name = subres */ + mods[a] = parse_mods(m->v[mi].name); + actions[a] = m->v[mi].subres; + break; - case 110: /* name = value */ - mods[a] = parse_mods (m->v[mi].name); - actions[a] = res_wrap (m->v[mi].value); - break; + case 110: /* name = value */ + mods[a] = parse_mods(m->v[mi].name); + actions[a] = res_wrap(m->v[mi].value); + break; + } + } } - } } - } } -static Resource* -find_best_action (int button, int start, unsigned mod_mask) +static Resource *find_best_action(int button, int start, unsigned mod_mask) { - int i, j; - int count = mod_count[button]; - unsigned search_mask = mod_mask & ~M_Release; - unsigned release_mask = mod_mask & M_Release; + int i, j; + int count = mod_count[button]; + unsigned search_mask = mod_mask & ~M_Release; + unsigned release_mask = mod_mask & M_Release; - /* look for exact mod match */ - for (i=start; i=0; j--) - if ((j & search_mask) == j) /* this would work */ - for (i=start; i= 0; j--) + if ((j & search_mask) == j) /* this would work */ + for (i = start; i < start + count; i++) /* search for it */ + if (mods[i] == (j | release_mask)) + return actions[i]; - return NULL; + return NULL; } -void -do_mouse_action (int button, int mod_mask) +void do_mouse_action(int button, int mod_mask) { - Resource *action = NULL; - int bi, i, a; + Resource *action = NULL; + int bi, i, a; - /* find the right set of actions; */ - a = 0; - for (bi=0; bic; i++) - if (action->v[i].value) - if (hid_parse_actions (action->v[i].value)) - return; + for (i = 0; i < action->c; i++) + if (action->v[i].value) + if (hid_parse_actions(action->v[i].value)) + return; } -Resource *resource_create_menu(const char *name, const char *action, const char *mnemonic, const char *accel, const char *tip, int flags) +Resource *resource_create_menu(const char *name, const char *action, const char *mnemonic, const char *accel, const char *tip, + int flags) { Resource *resp, *res; ResourceVal *rvp, *rv; @@ -239,7 +226,7 @@ ResourceVal *arv; ares = calloc(sizeof(Resource), 1); - arv = malloc(sizeof(ResourceVal)*2); + arv = malloc(sizeof(ResourceVal) * 2); ares->c = 2; ares->v = arv; ares->flags = 0; Index: trunk/src/hid/common/hid_resource.h =================================================================== --- trunk/src/hid/common/hid_resource.h (revision 1021) +++ trunk/src/hid/common/hid_resource.h (revision 1022) @@ -9,12 +9,13 @@ #define M_Mod(n) (1<<(n+1)) #define M_Alt M_Mod(1) #define M_Multi M_Mod(2) -#define M_Release (~((unsigned)-1>>1)) /* set the top bit */ +#define M_Release (~((unsigned)-1>>1)) /* set the top bit */ -void load_mouse_resource (const Resource *res); -void do_mouse_action (int button, int mods); +void load_mouse_resource(const Resource * res); +void do_mouse_action(int button, int mods); /* Create a set of resources representing a single menu item */ -Resource *resource_create_menu(const char *name, const char *action, const char *mnemonic, const char *accel, const char *tip, int flags); +Resource *resource_create_menu(const char *name, const char *action, const char *mnemonic, const char *accel, const char *tip, + int flags); #endif Index: trunk/src/hid/common/hidgl.c =================================================================== --- trunk/src/hid/common/hidgl.c (revision 1021) +++ trunk/src/hid/common/hidgl.c (revision 1022) @@ -37,15 +37,15 @@ */ #define GL_GLEXT_PROTOTYPES 1 #ifdef HAVE_OPENGL_GL_H -# include +#include #else -# include +#include #endif #ifdef HAVE_OPENGL_GLU_H -# include +#include #else -# include +#include #endif #include "action.h" @@ -68,346 +68,324 @@ triangle_buffer buffer; float global_depth = 0; -void -hidgl_init_triangle_array (triangle_buffer *buffer) +void hidgl_init_triangle_array(triangle_buffer * buffer) { - buffer->triangle_count = 0; - buffer->coord_comp_count = 0; + buffer->triangle_count = 0; + buffer->coord_comp_count = 0; } -void -hidgl_flush_triangles (triangle_buffer *buffer) +void hidgl_flush_triangles(triangle_buffer * buffer) { - if (buffer->triangle_count == 0) - return; + if (buffer->triangle_count == 0) + return; - glEnableClientState (GL_VERTEX_ARRAY); - glVertexPointer (3, GL_FLOAT, 0, buffer->triangle_array); - glDrawArrays (GL_TRIANGLES, 0, buffer->triangle_count * 3); - glDisableClientState (GL_VERTEX_ARRAY); + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(3, GL_FLOAT, 0, buffer->triangle_array); + glDrawArrays(GL_TRIANGLES, 0, buffer->triangle_count * 3); + glDisableClientState(GL_VERTEX_ARRAY); - buffer->triangle_count = 0; - buffer->coord_comp_count = 0; + buffer->triangle_count = 0; + buffer->coord_comp_count = 0; } -void -hidgl_ensure_triangle_space (triangle_buffer *buffer, int count) +void hidgl_ensure_triangle_space(triangle_buffer * buffer, int count) { - if (count > TRIANGLE_ARRAY_SIZE) - { - fprintf (stderr, "Not enough space in vertex buffer\n"); - fprintf (stderr, "Requested %i triangles, %i available\n", - count, TRIANGLE_ARRAY_SIZE); - exit (1); - } - if (count > TRIANGLE_ARRAY_SIZE - buffer->triangle_count) - hidgl_flush_triangles (buffer); + if (count > TRIANGLE_ARRAY_SIZE) { + fprintf(stderr, "Not enough space in vertex buffer\n"); + fprintf(stderr, "Requested %i triangles, %i available\n", count, TRIANGLE_ARRAY_SIZE); + exit(1); + } + if (count > TRIANGLE_ARRAY_SIZE - buffer->triangle_count) + hidgl_flush_triangles(buffer); } -void -hidgl_set_depth (float depth) +void hidgl_set_depth(float depth) { - global_depth = depth; + global_depth = depth; } -void -hidgl_draw_grid (BoxType *drawn_area) +void hidgl_draw_grid(BoxType * drawn_area) { - static GLfloat *points = 0; - static int npoints = 0; - Coord x1, y1, x2, y2, n, i; - double x, y; + static GLfloat *points = 0; + static int npoints = 0; + Coord x1, y1, x2, y2, n, i; + double x, y; - if (!Settings.DrawGrid) - return; + if (!Settings.DrawGrid) + return; - x1 = GridFit (MAX (0, drawn_area->X1), PCB->Grid, PCB->GridOffsetX); - y1 = GridFit (MAX (0, drawn_area->Y1), PCB->Grid, PCB->GridOffsetY); - x2 = GridFit (MIN (PCB->MaxWidth, drawn_area->X2), PCB->Grid, PCB->GridOffsetX); - y2 = GridFit (MIN (PCB->MaxHeight, drawn_area->Y2), PCB->Grid, PCB->GridOffsetY); + x1 = GridFit(MAX(0, drawn_area->X1), PCB->Grid, PCB->GridOffsetX); + y1 = GridFit(MAX(0, drawn_area->Y1), PCB->Grid, PCB->GridOffsetY); + x2 = GridFit(MIN(PCB->MaxWidth, drawn_area->X2), PCB->Grid, PCB->GridOffsetX); + y2 = GridFit(MIN(PCB->MaxHeight, drawn_area->Y2), PCB->Grid, PCB->GridOffsetY); - if (x1 > x2) - { - Coord tmp = x1; - x1 = x2; - x2 = tmp; - } + if (x1 > x2) { + Coord tmp = x1; + x1 = x2; + x2 = tmp; + } - if (y1 > y2) - { - Coord tmp = y1; - y1 = y2; - y2 = tmp; - } + if (y1 > y2) { + Coord tmp = y1; + y1 = y2; + y2 = tmp; + } - n = (int) ((x2 - x1) / PCB->Grid + 0.5) + 1; - if (n > npoints) - { - npoints = n + 10; - points = realloc (points, npoints * 3 * sizeof (GLfloat)); - } + n = (int) ((x2 - x1) / PCB->Grid + 0.5) + 1; + if (n > npoints) { + npoints = n + 10; + points = realloc(points, npoints * 3 * sizeof(GLfloat)); + } - glEnableClientState (GL_VERTEX_ARRAY); - glVertexPointer (3, GL_FLOAT, 0, points); + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(3, GL_FLOAT, 0, points); - n = 0; - for (x = x1; x <= x2; x += PCB->Grid) - { - points[3 * n + 0] = x; - points[3 * n + 2] = global_depth; - n++; - } - for (y = y1; y <= y2; y += PCB->Grid) - { - for (i = 0; i < n; i++) - points[3 * i + 1] = y; - glDrawArrays (GL_POINTS, 0, n); - } + n = 0; + for (x = x1; x <= x2; x += PCB->Grid) { + points[3 * n + 0] = x; + points[3 * n + 2] = global_depth; + n++; + } + for (y = y1; y <= y2; y += PCB->Grid) { + for (i = 0; i < n; i++) + points[3 * i + 1] = y; + glDrawArrays(GL_POINTS, 0, n); + } - glDisableClientState (GL_VERTEX_ARRAY); + glDisableClientState(GL_VERTEX_ARRAY); } #define MAX_PIXELS_ARC_TO_CHORD 0.5 #define MIN_SLICES 6 -int calc_slices (float pix_radius, float sweep_angle) +int calc_slices(float pix_radius, float sweep_angle) { - float slices; + float slices; - if (pix_radius <= MAX_PIXELS_ARC_TO_CHORD) - return MIN_SLICES; + if (pix_radius <= MAX_PIXELS_ARC_TO_CHORD) + return MIN_SLICES; - slices = sweep_angle / acosf (1 - MAX_PIXELS_ARC_TO_CHORD / pix_radius) / 2.; - return (int)ceilf (slices); + slices = sweep_angle / acosf(1 - MAX_PIXELS_ARC_TO_CHORD / pix_radius) / 2.; + return (int) ceilf(slices); } #define MIN_TRIANGLES_PER_CAP 3 #define MAX_TRIANGLES_PER_CAP 90 -static void draw_cap (Coord width, Coord x, Coord y, Angle angle, double scale) +static void draw_cap(Coord width, Coord x, Coord y, Angle angle, double scale) { - float last_capx, last_capy; - float capx, capy; - float radius = width / 2.; - int slices = calc_slices (radius / scale, M_PI); - int i; + float last_capx, last_capy; + float capx, capy; + float radius = width / 2.; + int slices = calc_slices(radius / scale, M_PI); + int i; - if (slices < MIN_TRIANGLES_PER_CAP) - slices = MIN_TRIANGLES_PER_CAP; + if (slices < MIN_TRIANGLES_PER_CAP) + slices = MIN_TRIANGLES_PER_CAP; - if (slices > MAX_TRIANGLES_PER_CAP) - slices = MAX_TRIANGLES_PER_CAP; + if (slices > MAX_TRIANGLES_PER_CAP) + slices = MAX_TRIANGLES_PER_CAP; - hidgl_ensure_triangle_space (&buffer, slices); + hidgl_ensure_triangle_space(&buffer, slices); - last_capx = radius * cosf (angle * M_PI / 180.) + x; - last_capy = -radius * sinf (angle * M_PI / 180.) + y; - for (i = 0; i < slices; i++) { - capx = radius * cosf (angle * M_PI / 180. + ((float)(i + 1)) * M_PI / (float)slices) + x; - capy = -radius * sinf (angle * M_PI / 180. + ((float)(i + 1)) * M_PI / (float)slices) + y; - hidgl_add_triangle (&buffer, last_capx, last_capy, capx, capy, x, y); - last_capx = capx; - last_capy = capy; - } + last_capx = radius * cosf(angle * M_PI / 180.) + x; + last_capy = -radius * sinf(angle * M_PI / 180.) + y; + for (i = 0; i < slices; i++) { + capx = radius * cosf(angle * M_PI / 180. + ((float) (i + 1)) * M_PI / (float) slices) + x; + capy = -radius * sinf(angle * M_PI / 180. + ((float) (i + 1)) * M_PI / (float) slices) + y; + hidgl_add_triangle(&buffer, last_capx, last_capy, capx, capy, x, y); + last_capx = capx; + last_capy = capy; + } } -void -hidgl_draw_line (int cap, Coord width, Coord x1, Coord y1, Coord x2, Coord y2, double scale) +void hidgl_draw_line(int cap, Coord width, Coord x1, Coord y1, Coord x2, Coord y2, double scale) { - double angle; - float deltax, deltay, length; - float wdx, wdy; - int circular_caps = 0; - int hairline = 0; + double angle; + float deltax, deltay, length; + float wdx, wdy; + int circular_caps = 0; + int hairline = 0; - if (width == 0.0) - hairline = 1; + if (width == 0.0) + hairline = 1; - if (width < scale) - width = scale; + if (width < scale) + width = scale; - deltax = x2 - x1; - deltay = y2 - y1; + deltax = x2 - x1; + deltay = y2 - y1; - length = sqrt (deltax * deltax + deltay * deltay); + length = sqrt(deltax * deltax + deltay * deltay); - if (length == 0) { - /* Assume the orientation of the line is horizontal */ - angle = 0; - wdx = -width / 2.; - wdy = 0; - length = 1.; - deltax = 1.; - deltay = 0.; - } else { - wdy = deltax * width / 2. / length; - wdx = -deltay * width / 2. / length; + if (length == 0) { + /* Assume the orientation of the line is horizontal */ + angle = 0; + wdx = -width / 2.; + wdy = 0; + length = 1.; + deltax = 1.; + deltay = 0.; + } + else { + wdy = deltax * width / 2. / length; + wdx = -deltay * width / 2. / length; - if (deltay == 0.) - angle = (deltax < 0) ? 270. : 90.; - else - angle = 180. / M_PI * atanl (deltax / deltay); + if (deltay == 0.) + angle = (deltax < 0) ? 270. : 90.; + else + angle = 180. / M_PI * atanl(deltax / deltay); - if (deltay < 0) - angle += 180.; - } + if (deltay < 0) + angle += 180.; + } - switch (cap) { - case Trace_Cap: - case Round_Cap: - circular_caps = 1; - break; + switch (cap) { + case Trace_Cap: + case Round_Cap: + circular_caps = 1; + break; - case Square_Cap: - case Beveled_Cap: - x1 -= deltax * width / 2. / length; - y1 -= deltay * width / 2. / length; - x2 += deltax * width / 2. / length; - y2 += deltay * width / 2. / length; - break; - } + case Square_Cap: + case Beveled_Cap: + x1 -= deltax * width / 2. / length; + y1 -= deltay * width / 2. / length; + x2 += deltax * width / 2. / length; + y2 += deltay * width / 2. / length; + break; + } - hidgl_ensure_triangle_space (&buffer, 2); - hidgl_add_triangle (&buffer, x1 - wdx, y1 - wdy, - x2 - wdx, y2 - wdy, - x2 + wdx, y2 + wdy); - hidgl_add_triangle (&buffer, x1 - wdx, y1 - wdy, - x2 + wdx, y2 + wdy, - x1 + wdx, y1 + wdy); + hidgl_ensure_triangle_space(&buffer, 2); + hidgl_add_triangle(&buffer, x1 - wdx, y1 - wdy, x2 - wdx, y2 - wdy, x2 + wdx, y2 + wdy); + hidgl_add_triangle(&buffer, x1 - wdx, y1 - wdy, x2 + wdx, y2 + wdy, x1 + wdx, y1 + wdy); - /* Don't bother capping hairlines */ - if (circular_caps && !hairline) - { - draw_cap (width, x1, y1, angle, scale); - draw_cap (width, x2, y2, angle + 180., scale); - } + /* Don't bother capping hairlines */ + if (circular_caps && !hairline) { + draw_cap(width, x1, y1, angle, scale); + draw_cap(width, x2, y2, angle + 180., scale); + } } #define MIN_SLICES_PER_ARC 6 #define MAX_SLICES_PER_ARC 360 -void -hidgl_draw_arc (Coord width, Coord x, Coord y, Coord rx, Coord ry, - Angle start_angle, Angle delta_angle, double scale) +void hidgl_draw_arc(Coord width, Coord x, Coord y, Coord rx, Coord ry, Angle start_angle, Angle delta_angle, double scale) { - float last_inner_x, last_inner_y; - float last_outer_x, last_outer_y; - float inner_x, inner_y; - float outer_x, outer_y; - float inner_r; - float outer_r; - float cos_ang, sin_ang; - float start_angle_rad; - float delta_angle_rad; - float angle_incr_rad; - int slices; - int i; - int hairline = 0; + float last_inner_x, last_inner_y; + float last_outer_x, last_outer_y; + float inner_x, inner_y; + float outer_x, outer_y; + float inner_r; + float outer_r; + float cos_ang, sin_ang; + float start_angle_rad; + float delta_angle_rad; + float angle_incr_rad; + int slices; + int i; + int hairline = 0; - if (width == 0.0) - hairline = 1; + if (width == 0.0) + hairline = 1; - if (width < scale) - width = scale; + if (width < scale) + width = scale; - inner_r = rx - width / 2.; - outer_r = rx + width / 2.; + inner_r = rx - width / 2.; + outer_r = rx + width / 2.; - if (delta_angle < 0) { - start_angle += delta_angle; - delta_angle = - delta_angle; - } + if (delta_angle < 0) { + start_angle += delta_angle; + delta_angle = -delta_angle; + } - start_angle_rad = start_angle * M_PI / 180.; - delta_angle_rad = delta_angle * M_PI / 180.; + start_angle_rad = start_angle * M_PI / 180.; + delta_angle_rad = delta_angle * M_PI / 180.; - slices = calc_slices ((rx + width / 2.) / scale, delta_angle_rad); + slices = calc_slices((rx + width / 2.) / scale, delta_angle_rad); - if (slices < MIN_SLICES_PER_ARC) - slices = MIN_SLICES_PER_ARC; + if (slices < MIN_SLICES_PER_ARC) + slices = MIN_SLICES_PER_ARC; - if (slices > MAX_SLICES_PER_ARC) - slices = MAX_SLICES_PER_ARC; + if (slices > MAX_SLICES_PER_ARC) + slices = MAX_SLICES_PER_ARC; - hidgl_ensure_triangle_space (&buffer, 2 * slices); + hidgl_ensure_triangle_space(&buffer, 2 * slices); - angle_incr_rad = delta_angle_rad / (float)slices; + angle_incr_rad = delta_angle_rad / (float) slices; - cos_ang = cosf (start_angle_rad); - sin_ang = sinf (start_angle_rad); - last_inner_x = -inner_r * cos_ang + x; last_inner_y = inner_r * sin_ang + y; - last_outer_x = -outer_r * cos_ang + x; last_outer_y = outer_r * sin_ang + y; - for (i = 1; i <= slices; i++) { - cos_ang = cosf (start_angle_rad + ((float)(i)) * angle_incr_rad); - sin_ang = sinf (start_angle_rad + ((float)(i)) * angle_incr_rad); - inner_x = -inner_r * cos_ang + x; inner_y = inner_r * sin_ang + y; - outer_x = -outer_r * cos_ang + x; outer_y = outer_r * sin_ang + y; - hidgl_add_triangle (&buffer, last_inner_x, last_inner_y, - last_outer_x, last_outer_y, - outer_x, outer_y); - hidgl_add_triangle (&buffer, last_inner_x, last_inner_y, - inner_x, inner_y, - outer_x, outer_y); - last_inner_x = inner_x; last_inner_y = inner_y; - last_outer_x = outer_x; last_outer_y = outer_y; - } + cos_ang = cosf(start_angle_rad); + sin_ang = sinf(start_angle_rad); + last_inner_x = -inner_r * cos_ang + x; + last_inner_y = inner_r * sin_ang + y; + last_outer_x = -outer_r * cos_ang + x; + last_outer_y = outer_r * sin_ang + y; + for (i = 1; i <= slices; i++) { + cos_ang = cosf(start_angle_rad + ((float) (i)) * angle_incr_rad); + sin_ang = sinf(start_angle_rad + ((float) (i)) * angle_incr_rad); + inner_x = -inner_r * cos_ang + x; + inner_y = inner_r * sin_ang + y; + outer_x = -outer_r * cos_ang + x; + outer_y = outer_r * sin_ang + y; + hidgl_add_triangle(&buffer, last_inner_x, last_inner_y, last_outer_x, last_outer_y, outer_x, outer_y); + hidgl_add_triangle(&buffer, last_inner_x, last_inner_y, inner_x, inner_y, outer_x, outer_y); + last_inner_x = inner_x; + last_inner_y = inner_y; + last_outer_x = outer_x; + last_outer_y = outer_y; + } - /* Don't bother capping hairlines */ - if (hairline) - return; + /* Don't bother capping hairlines */ + if (hairline) + return; - draw_cap (width, x + rx * -cosf (start_angle_rad), - y + rx * sinf (start_angle_rad), - start_angle, scale); - draw_cap (width, x + rx * -cosf (start_angle_rad + delta_angle_rad), - y + rx * sinf (start_angle_rad + delta_angle_rad), - start_angle + delta_angle + 180., scale); + draw_cap(width, x + rx * -cosf(start_angle_rad), y + rx * sinf(start_angle_rad), start_angle, scale); + draw_cap(width, x + rx * -cosf(start_angle_rad + delta_angle_rad), + y + rx * sinf(start_angle_rad + delta_angle_rad), start_angle + delta_angle + 180., scale); } -void -hidgl_draw_rect (Coord x1, Coord y1, Coord x2, Coord y2) +void hidgl_draw_rect(Coord x1, Coord y1, Coord x2, Coord y2) { - glBegin (GL_LINE_LOOP); - glVertex3f (x1, y1, global_depth); - glVertex3f (x1, y2, global_depth); - glVertex3f (x2, y2, global_depth); - glVertex3f (x2, y1, global_depth); - glEnd (); + glBegin(GL_LINE_LOOP); + glVertex3f(x1, y1, global_depth); + glVertex3f(x1, y2, global_depth); + glVertex3f(x2, y2, global_depth); + glVertex3f(x2, y1, global_depth); + glEnd(); } -void -hidgl_fill_circle (Coord vx, Coord vy, Coord vr, double scale) +void hidgl_fill_circle(Coord vx, Coord vy, Coord vr, double scale) { #define MIN_TRIANGLES_PER_CIRCLE 6 #define MAX_TRIANGLES_PER_CIRCLE 360 - float last_x, last_y; - float radius = vr; - int slices; - int i; + float last_x, last_y; + float radius = vr; + int slices; + int i; - slices = calc_slices (vr / scale, 2 * M_PI); + slices = calc_slices(vr / scale, 2 * M_PI); - if (slices < MIN_TRIANGLES_PER_CIRCLE) - slices = MIN_TRIANGLES_PER_CIRCLE; + if (slices < MIN_TRIANGLES_PER_CIRCLE) + slices = MIN_TRIANGLES_PER_CIRCLE; - if (slices > MAX_TRIANGLES_PER_CIRCLE) - slices = MAX_TRIANGLES_PER_CIRCLE; + if (slices > MAX_TRIANGLES_PER_CIRCLE) + slices = MAX_TRIANGLES_PER_CIRCLE; - hidgl_ensure_triangle_space (&buffer, slices); + hidgl_ensure_triangle_space(&buffer, slices); - last_x = vx + vr; - last_y = vy; + last_x = vx + vr; + last_y = vy; - for (i = 0; i < slices; i++) { - float x, y; - x = radius * cosf (((float)(i + 1)) * 2. * M_PI / (float)slices) + vx; - y = radius * sinf (((float)(i + 1)) * 2. * M_PI / (float)slices) + vy; - hidgl_add_triangle (&buffer, vx, vy, last_x, last_y, x, y); - last_x = x; - last_y = y; - } + for (i = 0; i < slices; i++) { + float x, y; + x = radius * cosf(((float) (i + 1)) * 2. * M_PI / (float) slices) + vx; + y = radius * sinf(((float) (i + 1)) * 2. * M_PI / (float) slices) + vy; + hidgl_add_triangle(&buffer, vx, vy, last_x, last_y, x, y); + last_x = x; + last_y = y; + } } #define MAX_COMBINED_MALLOCS 2500 -static void *combined_to_free [MAX_COMBINED_MALLOCS]; +static void *combined_to_free[MAX_COMBINED_MALLOCS]; static int combined_num_to_free = 0; static GLenum tessVertexType; @@ -415,200 +393,179 @@ static int triangle_comp_idx; -static void -myError (GLenum errno) +static void myError(GLenum errno) { - printf ("gluTess error: %s\n", gluErrorString (errno)); + printf("gluTess error: %s\n", gluErrorString(errno)); } -static void -myFreeCombined () +static void myFreeCombined() { - while (combined_num_to_free) - free (combined_to_free [-- combined_num_to_free]); + while (combined_num_to_free) + free(combined_to_free[--combined_num_to_free]); } -static void -myCombine ( GLdouble coords[3], void *vertex_data[4], GLfloat weight[4], void **dataOut ) +static void myCombine(GLdouble coords[3], void *vertex_data[4], GLfloat weight[4], void **dataOut) { #define MAX_COMBINED_VERTICES 2500 - static GLdouble combined_vertices [3 * MAX_COMBINED_VERTICES]; - static int num_combined_vertices = 0; + static GLdouble combined_vertices[3 * MAX_COMBINED_VERTICES]; + static int num_combined_vertices = 0; - GLdouble *new_vertex; + GLdouble *new_vertex; - if (num_combined_vertices < MAX_COMBINED_VERTICES) - { - new_vertex = &combined_vertices [3 * num_combined_vertices]; - num_combined_vertices ++; - } - else - { - new_vertex = malloc (3 * sizeof (GLdouble)); + if (num_combined_vertices < MAX_COMBINED_VERTICES) { + new_vertex = &combined_vertices[3 * num_combined_vertices]; + num_combined_vertices++; + } + else { + new_vertex = malloc(3 * sizeof(GLdouble)); - if (combined_num_to_free < MAX_COMBINED_MALLOCS) - combined_to_free [combined_num_to_free ++] = new_vertex; - else - printf ("myCombine leaking %lu bytes of memory\n", 3 * sizeof (GLdouble)); - } + if (combined_num_to_free < MAX_COMBINED_MALLOCS) + combined_to_free[combined_num_to_free++] = new_vertex; + else + printf("myCombine leaking %lu bytes of memory\n", 3 * sizeof(GLdouble)); + } - new_vertex[0] = coords[0]; - new_vertex[1] = coords[1]; - new_vertex[2] = coords[2]; + new_vertex[0] = coords[0]; + new_vertex[1] = coords[1]; + new_vertex[2] = coords[2]; - *dataOut = new_vertex; + *dataOut = new_vertex; } -static void -myBegin (GLenum type) +static void myBegin(GLenum type) { - tessVertexType = type; - stashed_vertices = 0; - triangle_comp_idx = 0; + tessVertexType = type; + stashed_vertices = 0; + triangle_comp_idx = 0; } static double global_scale; -static void -myVertex (GLdouble *vertex_data) +static void myVertex(GLdouble * vertex_data) { - static GLfloat triangle_vertices [2 * 3]; + static GLfloat triangle_vertices[2 * 3]; - if (tessVertexType == GL_TRIANGLE_STRIP || - tessVertexType == GL_TRIANGLE_FAN) - { - if (stashed_vertices < 2) - { - triangle_vertices [triangle_comp_idx ++] = vertex_data [0]; - triangle_vertices [triangle_comp_idx ++] = vertex_data [1]; - stashed_vertices ++; - } - else - { - hidgl_ensure_triangle_space (&buffer, 1); - hidgl_add_triangle (&buffer, - triangle_vertices [0], triangle_vertices [1], - triangle_vertices [2], triangle_vertices [3], - vertex_data [0], vertex_data [1]); + if (tessVertexType == GL_TRIANGLE_STRIP || tessVertexType == GL_TRIANGLE_FAN) { + if (stashed_vertices < 2) { + triangle_vertices[triangle_comp_idx++] = vertex_data[0]; + triangle_vertices[triangle_comp_idx++] = vertex_data[1]; + stashed_vertices++; + } + else { + hidgl_ensure_triangle_space(&buffer, 1); + hidgl_add_triangle(&buffer, + triangle_vertices[0], triangle_vertices[1], + triangle_vertices[2], triangle_vertices[3], vertex_data[0], vertex_data[1]); - if (tessVertexType == GL_TRIANGLE_STRIP) - { - /* STRIP saves the last two vertices for re-use in the next triangle */ - triangle_vertices [0] = triangle_vertices [2]; - triangle_vertices [1] = triangle_vertices [3]; - } - /* Both FAN and STRIP save the last vertex for re-use in the next triangle */ - triangle_vertices [2] = vertex_data [0]; - triangle_vertices [3] = vertex_data [1]; - } - } - else if (tessVertexType == GL_TRIANGLES) - { - triangle_vertices [triangle_comp_idx ++] = vertex_data [0]; - triangle_vertices [triangle_comp_idx ++] = vertex_data [1]; - stashed_vertices ++; - if (stashed_vertices == 3) - { - hidgl_ensure_triangle_space (&buffer, 1); - hidgl_add_triangle (&buffer, - triangle_vertices [0], triangle_vertices [1], - triangle_vertices [2], triangle_vertices [3], - triangle_vertices [4], triangle_vertices [5]); - triangle_comp_idx = 0; - stashed_vertices = 0; - } - } - else - printf ("Vertex received with unknown type\n"); + if (tessVertexType == GL_TRIANGLE_STRIP) { + /* STRIP saves the last two vertices for re-use in the next triangle */ + triangle_vertices[0] = triangle_vertices[2]; + triangle_vertices[1] = triangle_vertices[3]; + } + /* Both FAN and STRIP save the last vertex for re-use in the next triangle */ + triangle_vertices[2] = vertex_data[0]; + triangle_vertices[3] = vertex_data[1]; + } + } + else if (tessVertexType == GL_TRIANGLES) { + triangle_vertices[triangle_comp_idx++] = vertex_data[0]; + triangle_vertices[triangle_comp_idx++] = vertex_data[1]; + stashed_vertices++; + if (stashed_vertices == 3) { + hidgl_ensure_triangle_space(&buffer, 1); + hidgl_add_triangle(&buffer, + triangle_vertices[0], triangle_vertices[1], + triangle_vertices[2], triangle_vertices[3], triangle_vertices[4], triangle_vertices[5]); + triangle_comp_idx = 0; + stashed_vertices = 0; + } + } + else + printf("Vertex received with unknown type\n"); } -void -hidgl_fill_polygon (int n_coords, Coord *x, Coord *y) +void hidgl_fill_polygon(int n_coords, Coord * x, Coord * y) { - int i; - GLUtesselator *tobj; - GLdouble *vertices; + int i; + GLUtesselator *tobj; + GLdouble *vertices; - assert (n_coords > 0); + assert(n_coords > 0); - vertices = malloc (sizeof(GLdouble) * n_coords * 3); + vertices = malloc(sizeof(GLdouble) * n_coords * 3); - tobj = gluNewTess (); - gluTessCallback(tobj, GLU_TESS_BEGIN, (_GLUfuncptr)myBegin); - gluTessCallback(tobj, GLU_TESS_VERTEX, (_GLUfuncptr)myVertex); - gluTessCallback(tobj, GLU_TESS_COMBINE, (_GLUfuncptr)myCombine); - gluTessCallback(tobj, GLU_TESS_ERROR, (_GLUfuncptr)myError); + tobj = gluNewTess(); + gluTessCallback(tobj, GLU_TESS_BEGIN, (_GLUfuncptr) myBegin); + gluTessCallback(tobj, GLU_TESS_VERTEX, (_GLUfuncptr) myVertex); + gluTessCallback(tobj, GLU_TESS_COMBINE, (_GLUfuncptr) myCombine); + gluTessCallback(tobj, GLU_TESS_ERROR, (_GLUfuncptr) myError); - gluTessBeginPolygon (tobj, NULL); - gluTessBeginContour (tobj); + gluTessBeginPolygon(tobj, NULL); + gluTessBeginContour(tobj); - for (i = 0; i < n_coords; i++) - { - vertices [0 + i * 3] = x[i]; - vertices [1 + i * 3] = y[i]; - vertices [2 + i * 3] = 0.; - gluTessVertex (tobj, &vertices [i * 3], &vertices [i * 3]); - } + for (i = 0; i < n_coords; i++) { + vertices[0 + i * 3] = x[i]; + vertices[1 + i * 3] = y[i]; + vertices[2 + i * 3] = 0.; + gluTessVertex(tobj, &vertices[i * 3], &vertices[i * 3]); + } - gluTessEndContour (tobj); - gluTessEndPolygon (tobj); - gluDeleteTess (tobj); + gluTessEndContour(tobj); + gluTessEndPolygon(tobj); + gluDeleteTess(tobj); - myFreeCombined (); - free (vertices); + myFreeCombined(); + free(vertices); } -void -tesselate_contour (GLUtesselator *tobj, PLINE *contour, GLdouble *vertices, - double scale) +void tesselate_contour(GLUtesselator * tobj, PLINE * contour, GLdouble * vertices, double scale) { - VNODE *vn = &contour->head; - int offset = 0; + VNODE *vn = &contour->head; + int offset = 0; - /* If the contour is round, and hidgl_fill_circle would use - * less slices than we have vertices to draw it, then call - * hidgl_fill_circle to draw this contour. - */ - if (contour->is_round) { - double slices = calc_slices (contour->radius / scale, 2 * M_PI); - if (slices < contour->Count) { - hidgl_fill_circle (contour->cx, contour->cy, contour->radius, scale); - return; - } - } + /* If the contour is round, and hidgl_fill_circle would use + * less slices than we have vertices to draw it, then call + * hidgl_fill_circle to draw this contour. + */ + if (contour->is_round) { + double slices = calc_slices(contour->radius / scale, 2 * M_PI); + if (slices < contour->Count) { + hidgl_fill_circle(contour->cx, contour->cy, contour->radius, scale); + return; + } + } - gluTessBeginPolygon (tobj, NULL); - gluTessBeginContour (tobj); - do { - vertices [0 + offset] = vn->point[0]; - vertices [1 + offset] = vn->point[1]; - vertices [2 + offset] = 0.; - gluTessVertex (tobj, &vertices [offset], &vertices [offset]); - offset += 3; - } while ((vn = vn->next) != &contour->head); - gluTessEndContour (tobj); - gluTessEndPolygon (tobj); + gluTessBeginPolygon(tobj, NULL); + gluTessBeginContour(tobj); + do { + vertices[0 + offset] = vn->point[0]; + vertices[1 + offset] = vn->point[1]; + vertices[2 + offset] = 0.; + gluTessVertex(tobj, &vertices[offset], &vertices[offset]); + offset += 3; + } while ((vn = vn->next) != &contour->head); + gluTessEndContour(tobj); + gluTessEndPolygon(tobj); } struct do_hole_info { - GLUtesselator *tobj; - GLdouble *vertices; - double scale; + GLUtesselator *tobj; + GLdouble *vertices; + double scale; }; -static int -do_hole (const BoxType *b, void *cl) +static int do_hole(const BoxType * b, void *cl) { - struct do_hole_info *info = cl; - PLINE *curc = (PLINE *) b; + struct do_hole_info *info = cl; + PLINE *curc = (PLINE *) b; - /* Ignore the outer contour - we draw it first explicitly*/ - if (curc->Flags.orient == PLF_DIR) { - return 0; - } + /* Ignore the outer contour - we draw it first explicitly */ + if (curc->Flags.orient == PLF_DIR) { + return 0; + } - tesselate_contour (info->tobj, curc, info->vertices, info->scale); - return 1; + tesselate_contour(info->tobj, curc, info->vertices, info->scale); + return 1; } static GLint stencil_bits; @@ -616,176 +573,156 @@ static int assigned_bits = 0; /* FIXME: JUST DRAWS THE FIRST PIECE.. TODO: SUPPORT FOR FULLPOLY POLYGONS */ -void -hidgl_fill_pcb_polygon (PolygonType *poly, const BoxType *clip_box, double scale) +void hidgl_fill_pcb_polygon(PolygonType * poly, const BoxType * clip_box, double scale) { - int vertex_count = 0; - PLINE *contour; - struct do_hole_info info; - int stencil_bit; + int vertex_count = 0; + PLINE *contour; + struct do_hole_info info; + int stencil_bit; - info.scale = scale; - global_scale = scale; + info.scale = scale; + global_scale = scale; - if (poly->Clipped == NULL) - { - fprintf (stderr, "hidgl_fill_pcb_polygon: poly->Clipped == NULL\n"); - return; - } + if (poly->Clipped == NULL) { + fprintf(stderr, "hidgl_fill_pcb_polygon: poly->Clipped == NULL\n"); + return; + } - stencil_bit = hidgl_assign_clear_stencil_bit (); - if (!stencil_bit) - { - printf ("hidgl_fill_pcb_polygon: No free stencil bits, aborting polygon\n"); - return; - } + stencil_bit = hidgl_assign_clear_stencil_bit(); + if (!stencil_bit) { + printf("hidgl_fill_pcb_polygon: No free stencil bits, aborting polygon\n"); + return; + } - /* Flush out any existing geoemtry to be rendered */ - hidgl_flush_triangles (&buffer); + /* Flush out any existing geoemtry to be rendered */ + hidgl_flush_triangles(&buffer); - /* Walk the polygon structure, counting vertices */ - /* This gives an upper bound on the amount of storage required */ - for (contour = poly->Clipped->contours; - contour != NULL; contour = contour->next) - vertex_count = MAX (vertex_count, contour->Count); + /* Walk the polygon structure, counting vertices */ + /* This gives an upper bound on the amount of storage required */ + for (contour = poly->Clipped->contours; contour != NULL; contour = contour->next) + vertex_count = MAX(vertex_count, contour->Count); - info.vertices = malloc (sizeof(GLdouble) * vertex_count * 3); - info.tobj = gluNewTess (); - gluTessCallback(info.tobj, GLU_TESS_BEGIN, (_GLUfuncptr)myBegin); - gluTessCallback(info.tobj, GLU_TESS_VERTEX, (_GLUfuncptr)myVertex); - gluTessCallback(info.tobj, GLU_TESS_COMBINE, (_GLUfuncptr)myCombine); - gluTessCallback(info.tobj, GLU_TESS_ERROR, (_GLUfuncptr)myError); + info.vertices = malloc(sizeof(GLdouble) * vertex_count * 3); + info.tobj = gluNewTess(); + gluTessCallback(info.tobj, GLU_TESS_BEGIN, (_GLUfuncptr) myBegin); + gluTessCallback(info.tobj, GLU_TESS_VERTEX, (_GLUfuncptr) myVertex); + gluTessCallback(info.tobj, GLU_TESS_COMBINE, (_GLUfuncptr) myCombine); + gluTessCallback(info.tobj, GLU_TESS_ERROR, (_GLUfuncptr) myError); - glPushAttrib (GL_STENCIL_BUFFER_BIT); /* Save the write mask etc.. for final restore */ - glEnable (GL_STENCIL_TEST); - glPushAttrib (GL_STENCIL_BUFFER_BIT | /* Resave the stencil write-mask etc.., and */ - GL_COLOR_BUFFER_BIT); /* the colour buffer write mask etc.. for part way restore */ - glStencilMask (stencil_bit); /* Only write to our stencil bit */ - glStencilFunc (GL_ALWAYS, stencil_bit, stencil_bit); /* Always pass stencil test, ref value is our bit */ - glColorMask (0, 0, 0, 0); /* Disable writting in color buffer */ + glPushAttrib(GL_STENCIL_BUFFER_BIT); /* Save the write mask etc.. for final restore */ + glEnable(GL_STENCIL_TEST); + glPushAttrib(GL_STENCIL_BUFFER_BIT | /* Resave the stencil write-mask etc.., and */ + GL_COLOR_BUFFER_BIT); /* the colour buffer write mask etc.. for part way restore */ + glStencilMask(stencil_bit); /* Only write to our stencil bit */ + glStencilFunc(GL_ALWAYS, stencil_bit, stencil_bit); /* Always pass stencil test, ref value is our bit */ + glColorMask(0, 0, 0, 0); /* Disable writting in color buffer */ - glStencilOp (GL_KEEP, GL_KEEP, GL_REPLACE); /* Stencil pass => replace stencil value */ + glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); /* Stencil pass => replace stencil value */ - /* Drawing operations now set our reference bit in the stencil buffer */ + /* Drawing operations now set our reference bit in the stencil buffer */ - r_search (poly->Clipped->contour_tree, clip_box, NULL, do_hole, &info); - hidgl_flush_triangles (&buffer); + r_search(poly->Clipped->contour_tree, clip_box, NULL, do_hole, &info); + hidgl_flush_triangles(&buffer); - glPopAttrib (); /* Restore the colour and stencil buffer write-mask etc.. */ + glPopAttrib(); /* Restore the colour and stencil buffer write-mask etc.. */ - glStencilOp (GL_KEEP, GL_KEEP, GL_INVERT); /* This allows us to toggle the bit on any subcompositing bitplane */ - /* If the stencil test has passed, we know that bit is 0, so we're */ - /* effectively just setting it to 1. */ + glStencilOp(GL_KEEP, GL_KEEP, GL_INVERT); /* This allows us to toggle the bit on any subcompositing bitplane */ + /* If the stencil test has passed, we know that bit is 0, so we're */ + /* effectively just setting it to 1. */ - glStencilFunc (GL_GEQUAL, 0, assigned_bits); /* Pass stencil test if all assigned bits clear, */ - /* reference is all assigned bits so we set */ - /* any bits permitted by the stencil writemask */ + glStencilFunc(GL_GEQUAL, 0, assigned_bits); /* Pass stencil test if all assigned bits clear, */ + /* reference is all assigned bits so we set */ + /* any bits permitted by the stencil writemask */ - /* Drawing operations as masked to areas where the stencil buffer is '0' */ + /* Drawing operations as masked to areas where the stencil buffer is '0' */ - /* Draw the polygon outer */ - tesselate_contour (info.tobj, poly->Clipped->contours, info.vertices, scale); - hidgl_flush_triangles (&buffer); + /* Draw the polygon outer */ + tesselate_contour(info.tobj, poly->Clipped->contours, info.vertices, scale); + hidgl_flush_triangles(&buffer); - /* Unassign our stencil buffer bit */ - hidgl_return_stencil_bit (stencil_bit); + /* Unassign our stencil buffer bit */ + hidgl_return_stencil_bit(stencil_bit); - glPopAttrib (); /* Restore the stencil buffer write-mask etc.. */ + glPopAttrib(); /* Restore the stencil buffer write-mask etc.. */ - gluDeleteTess (info.tobj); - myFreeCombined (); - free (info.vertices); + gluDeleteTess(info.tobj); + myFreeCombined(); + free(info.vertices); } -void -hidgl_fill_rect (Coord x1, Coord y1, Coord x2, Coord y2) +void hidgl_fill_rect(Coord x1, Coord y1, Coord x2, Coord y2) { - hidgl_ensure_triangle_space (&buffer, 2); - hidgl_add_triangle (&buffer, x1, y1, x1, y2, x2, y2); - hidgl_add_triangle (&buffer, x2, y1, x2, y2, x1, y1); + hidgl_ensure_triangle_space(&buffer, 2); + hidgl_add_triangle(&buffer, x1, y1, x1, y2, x2, y2); + hidgl_add_triangle(&buffer, x2, y1, x2, y2, x1, y1); } -void -hidgl_init (void) +void hidgl_init(void) { - glGetIntegerv (GL_STENCIL_BITS, &stencil_bits); + glGetIntegerv(GL_STENCIL_BITS, &stencil_bits); - if (stencil_bits == 0) - { - printf ("No stencil bits available.\n" - "Cannot mask polygon holes or subcomposite layers\n"); - /* TODO: Flag this to the HID so it can revert to the dicer? */ - } - else if (stencil_bits == 1) - { - printf ("Only one stencil bitplane avilable\n" - "Cannot use stencil buffer to sub-composite layers.\n"); - /* Do we need to disable that somewhere? */ - } + if (stencil_bits == 0) { + printf("No stencil bits available.\n" "Cannot mask polygon holes or subcomposite layers\n"); + /* TODO: Flag this to the HID so it can revert to the dicer? */ + } + else if (stencil_bits == 1) { + printf("Only one stencil bitplane avilable\n" "Cannot use stencil buffer to sub-composite layers.\n"); + /* Do we need to disable that somewhere? */ + } } -int -hidgl_stencil_bits (void) +int hidgl_stencil_bits(void) { - return stencil_bits; + return stencil_bits; } -static void -hidgl_clean_unassigned_stencil (void) +static void hidgl_clean_unassigned_stencil(void) { - glPushAttrib (GL_STENCIL_BUFFER_BIT); - glStencilMask (~assigned_bits); - glClearStencil (0); - glClear (GL_STENCIL_BUFFER_BIT); - glPopAttrib (); + glPushAttrib(GL_STENCIL_BUFFER_BIT); + glStencilMask(~assigned_bits); + glClearStencil(0); + glClear(GL_STENCIL_BUFFER_BIT); + glPopAttrib(); } -int -hidgl_assign_clear_stencil_bit (void) +int hidgl_assign_clear_stencil_bit(void) { - int stencil_bitmask = (1 << stencil_bits) - 1; - int test; - int first_dirty = 0; + int stencil_bitmask = (1 << stencil_bits) - 1; + int test; + int first_dirty = 0; - if (assigned_bits == stencil_bitmask) - { - printf ("No more stencil bits available, total of %i already assigned\n", - stencil_bits); - return 0; - } + if (assigned_bits == stencil_bitmask) { + printf("No more stencil bits available, total of %i already assigned\n", stencil_bits); + return 0; + } - /* Look for a bitplane we don't have to clear */ - for (test = 1; test & stencil_bitmask; test <<= 1) - { - if (!(test & dirty_bits)) - { - assigned_bits |= test; - dirty_bits |= test; - return test; - } - else if (!first_dirty && !(test & assigned_bits)) - { - first_dirty = test; - } - } + /* Look for a bitplane we don't have to clear */ + for (test = 1; test & stencil_bitmask; test <<= 1) { + if (!(test & dirty_bits)) { + assigned_bits |= test; + dirty_bits |= test; + return test; + } + else if (!first_dirty && !(test & assigned_bits)) { + first_dirty = test; + } + } - /* Didn't find any non dirty planes. Clear those dirty ones which aren't in use */ - hidgl_clean_unassigned_stencil (); - assigned_bits |= first_dirty; - dirty_bits = assigned_bits; + /* Didn't find any non dirty planes. Clear those dirty ones which aren't in use */ + hidgl_clean_unassigned_stencil(); + assigned_bits |= first_dirty; + dirty_bits = assigned_bits; - return first_dirty; + return first_dirty; } -void -hidgl_return_stencil_bit (int bit) +void hidgl_return_stencil_bit(int bit) { - assigned_bits &= ~bit; + assigned_bits &= ~bit; } -void -hidgl_reset_stencil_usage (void) +void hidgl_reset_stencil_usage(void) { - assigned_bits = 0; - dirty_bits = 0; + assigned_bits = 0; + dirty_bits = 0; } Index: trunk/src/hid/common/hidgl.h =================================================================== --- trunk/src/hid/common/hidgl.h (revision 1021) +++ trunk/src/hid/common/hidgl.h (revision 1022) @@ -25,61 +25,55 @@ #define TRIANGLE_ARRAY_SIZE 5461 typedef struct { - GLfloat triangle_array [3 * 3 * TRIANGLE_ARRAY_SIZE]; - unsigned int triangle_count; - unsigned int coord_comp_count; + GLfloat triangle_array[3 * 3 * TRIANGLE_ARRAY_SIZE]; + unsigned int triangle_count; + unsigned int coord_comp_count; } triangle_buffer; extern triangle_buffer buffer; extern float global_depth; -void hidgl_init_triangle_array (triangle_buffer *buffer); -void hidgl_flush_triangles (triangle_buffer *buffer); -void hidgl_ensure_triangle_space (triangle_buffer *buffer, int count); +void hidgl_init_triangle_array(triangle_buffer * buffer); +void hidgl_flush_triangles(triangle_buffer * buffer); +void hidgl_ensure_triangle_space(triangle_buffer * buffer, int count); static inline void -hidgl_add_triangle_3D (triangle_buffer *buffer, - GLfloat x1, GLfloat y1, GLfloat z1, - GLfloat x2, GLfloat y2, GLfloat z2, - GLfloat x3, GLfloat y3, GLfloat z3) +hidgl_add_triangle_3D(triangle_buffer * buffer, + GLfloat x1, GLfloat y1, GLfloat z1, + GLfloat x2, GLfloat y2, GLfloat z2, GLfloat x3, GLfloat y3, GLfloat z3) { - buffer->triangle_array [buffer->coord_comp_count++] = x1; - buffer->triangle_array [buffer->coord_comp_count++] = y1; - buffer->triangle_array [buffer->coord_comp_count++] = z1; - buffer->triangle_array [buffer->coord_comp_count++] = x2; - buffer->triangle_array [buffer->coord_comp_count++] = y2; - buffer->triangle_array [buffer->coord_comp_count++] = z2; - buffer->triangle_array [buffer->coord_comp_count++] = x3; - buffer->triangle_array [buffer->coord_comp_count++] = y3; - buffer->triangle_array [buffer->coord_comp_count++] = z3; - buffer->triangle_count++; + buffer->triangle_array[buffer->coord_comp_count++] = x1; + buffer->triangle_array[buffer->coord_comp_count++] = y1; + buffer->triangle_array[buffer->coord_comp_count++] = z1; + buffer->triangle_array[buffer->coord_comp_count++] = x2; + buffer->triangle_array[buffer->coord_comp_count++] = y2; + buffer->triangle_array[buffer->coord_comp_count++] = z2; + buffer->triangle_array[buffer->coord_comp_count++] = x3; + buffer->triangle_array[buffer->coord_comp_count++] = y3; + buffer->triangle_array[buffer->coord_comp_count++] = z3; + buffer->triangle_count++; } static inline void -hidgl_add_triangle (triangle_buffer *buffer, - GLfloat x1, GLfloat y1, - GLfloat x2, GLfloat y2, - GLfloat x3, GLfloat y3) +hidgl_add_triangle(triangle_buffer * buffer, GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2, GLfloat x3, GLfloat y3) { - hidgl_add_triangle_3D (buffer, x1, y1, global_depth, - x2, y2, global_depth, - x3, y3, global_depth); + hidgl_add_triangle_3D(buffer, x1, y1, global_depth, x2, y2, global_depth, x3, y3, global_depth); } -void hidgl_draw_grid (BoxType *drawn_area); -void hidgl_set_depth (float depth); -void hidgl_draw_line (int cap, Coord width, Coord x1, Coord y1, Coord x2, Coord y2, double scale); -void hidgl_draw_arc (Coord width, Coord vx, Coord vy, Coord vrx, Coord vry, Angle start_angle, Angle delta_angle, double scale); -void hidgl_draw_rect (Coord x1, Coord y1, Coord x2, Coord y2); -void hidgl_fill_circle (Coord vx, Coord vy, Coord vr, double scale); -void hidgl_fill_polygon (int n_coords, Coord *x, Coord *y); -void hidgl_fill_pcb_polygon (PolygonType *poly, const BoxType *clip_box, double scale); -void hidgl_fill_rect (Coord x1, Coord y1, Coord x2, Coord y2); +void hidgl_draw_grid(BoxType * drawn_area); +void hidgl_set_depth(float depth); +void hidgl_draw_line(int cap, Coord width, Coord x1, Coord y1, Coord x2, Coord y2, double scale); +void hidgl_draw_arc(Coord width, Coord vx, Coord vy, Coord vrx, Coord vry, Angle start_angle, Angle delta_angle, double scale); +void hidgl_draw_rect(Coord x1, Coord y1, Coord x2, Coord y2); +void hidgl_fill_circle(Coord vx, Coord vy, Coord vr, double scale); +void hidgl_fill_polygon(int n_coords, Coord * x, Coord * y); +void hidgl_fill_pcb_polygon(PolygonType * poly, const BoxType * clip_box, double scale); +void hidgl_fill_rect(Coord x1, Coord y1, Coord x2, Coord y2); -void hidgl_init (void); -int hidgl_stencil_bits (void); -int hidgl_assign_clear_stencil_bit (void); -void hidgl_return_stencil_bit (int bit); -void hidgl_reset_stencil_usage (void); +void hidgl_init(void); +int hidgl_stencil_bits(void); +int hidgl_assign_clear_stencil_bit(void); +void hidgl_return_stencil_bit(int bit); +void hidgl_reset_stencil_usage(void); #endif /* PCB_HID_COMMON_HIDGL_H */ Index: trunk/src/hid/common/hidinit.c =================================================================== --- trunk/src/hid/common/hidinit.c (revision 1021) +++ trunk/src/hid/common/hidinit.c (revision 1022) @@ -30,7 +30,7 @@ #include "error.h" #include "global.h" #include "misc.h" -#include "portability.h" /* MKDIR() */ +#include "portability.h" /* MKDIR() */ #include "pcb-printf.h" #include "plugins.h" @@ -38,7 +38,7 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); #define HID_DEF(x) extern void hid_ ## x ## _init(void); #include "hid/common/hidlist.h" @@ -52,152 +52,128 @@ int pixel_slop = 1; -static void -hid_load_dir (char *dirname) +static void hid_load_dir(char *dirname) { - DIR *dir; - struct dirent *de; + DIR *dir; + struct dirent *de; - dir = opendir (dirname); - if (!dir) - { - free (dirname); - return; - } - while ((de = readdir (dir)) != NULL) - { - void *sym; - void (*symv)(); - void *so; - char *basename, *path, *symname; - struct stat st; + dir = opendir(dirname); + if (!dir) { + free(dirname); + return; + } + while ((de = readdir(dir)) != NULL) { + void *sym; + void (*symv) (); + void *so; + char *basename, *path, *symname; + struct stat st; - basename = strdup (de->d_name); - if (strlen (basename) > 3 - && strcasecmp (basename+strlen(basename)-3, ".so") == 0) - basename[strlen(basename)-3] = 0; - else if (strlen (basename) > 4 - && strcasecmp (basename+strlen(basename)-4, ".dll") == 0) - basename[strlen(basename)-4] = 0; - path = Concat (dirname, PCB_DIR_SEPARATOR_S, de->d_name, NULL); + basename = strdup(de->d_name); + if (strlen(basename) > 3 && strcasecmp(basename + strlen(basename) - 3, ".so") == 0) + basename[strlen(basename) - 3] = 0; + else if (strlen(basename) > 4 && strcasecmp(basename + strlen(basename) - 4, ".dll") == 0) + basename[strlen(basename) - 4] = 0; + path = Concat(dirname, PCB_DIR_SEPARATOR_S, de->d_name, NULL); - if (stat (path, &st) == 0 - && ( + if (stat(path, &st) == 0 && ( /* mingw and win32 do not support S_IXGRP or S_IXOTH */ #if defined(S_IXGRP) - (st.st_mode & S_IXGRP) || + (st.st_mode & S_IXGRP) || #endif #if defined(S_IXOTH) - (st.st_mode & S_IXOTH) || + (st.st_mode & S_IXOTH) || #endif - (st.st_mode & S_IXUSR) ) - && S_ISREG (st.st_mode)) - { - if ((so = dlopen (path, RTLD_NOW | RTLD_GLOBAL)) == NULL) - { - fprintf(stderr, "dl_error: %s\n", dlerror ()); - } - else - { - symname = Concat ("hid_", basename, "_init", NULL); - if ((sym = dlsym (so, symname)) != NULL) - { - symv = (void (*)()) sym; - symv(); + (st.st_mode & S_IXUSR)) + && S_ISREG(st.st_mode)) { + if ((so = dlopen(path, RTLD_NOW | RTLD_GLOBAL)) == NULL) { + fprintf(stderr, "dl_error: %s\n", dlerror()); + } + else { + symname = Concat("hid_", basename, "_init", NULL); + if ((sym = dlsym(so, symname)) != NULL) { + symv = (void (*)()) sym; + symv(); + } + else if ((sym = dlsym(so, "pcb_plugin_init")) != NULL) { + symv = (void (*)()) sym; + symv(); + } + plugin_register(basename, path, so, 1); + free(symname); + } } - else if ((sym = dlsym (so, "pcb_plugin_init")) != NULL) - { - symv = (void (*)()) sym; - symv(); - } - plugin_register(basename, path, so, 1); - free (symname); - } + free(basename); + free(path); } - free (basename); - free (path); - } - free (dirname); + free(dirname); } -void -hid_init () +void hid_init() { - /* Setup a "nogui" default HID */ - gui = hid_nogui_get_hid (); + /* Setup a "nogui" default HID */ + gui = hid_nogui_get_hid(); #define HID_DEF(x) hid_ ## x ## _init(); #include "hid/common/hidlist.h" #undef HID_DEF - hid_load_dir (Concat (exec_prefix, PCB_DIR_SEPARATOR_S, "lib", - PCB_DIR_SEPARATOR_S, "pcb", - PCB_DIR_SEPARATOR_S, "plugins", - PCB_DIR_SEPARATOR_S, HOST, NULL)); - hid_load_dir (Concat (exec_prefix, PCB_DIR_SEPARATOR_S, "lib", - PCB_DIR_SEPARATOR_S, "pcb", - PCB_DIR_SEPARATOR_S, "plugins", NULL)); + hid_load_dir(Concat(exec_prefix, PCB_DIR_SEPARATOR_S, "lib", + PCB_DIR_SEPARATOR_S, "pcb", PCB_DIR_SEPARATOR_S, "plugins", PCB_DIR_SEPARATOR_S, HOST, NULL)); + hid_load_dir(Concat(exec_prefix, PCB_DIR_SEPARATOR_S, "lib", + PCB_DIR_SEPARATOR_S, "pcb", PCB_DIR_SEPARATOR_S, "plugins", NULL)); - /* homedir is set by the core immediately on startup */ - if (homedir != NULL) - { - hid_load_dir (Concat (homedir, PCB_DIR_SEPARATOR_S, ".pcb", - PCB_DIR_SEPARATOR_S, "plugins", - PCB_DIR_SEPARATOR_S, HOST, NULL)); - hid_load_dir (Concat (homedir, PCB_DIR_SEPARATOR_S, ".pcb", - PCB_DIR_SEPARATOR_S, "plugins", NULL)); - } - hid_load_dir (Concat ("plugins", PCB_DIR_SEPARATOR_S, HOST, NULL)); - hid_load_dir (Concat ("plugins", NULL)); + /* homedir is set by the core immediately on startup */ + if (homedir != NULL) { + hid_load_dir(Concat(homedir, PCB_DIR_SEPARATOR_S, ".pcb", PCB_DIR_SEPARATOR_S, "plugins", PCB_DIR_SEPARATOR_S, HOST, NULL)); + hid_load_dir(Concat(homedir, PCB_DIR_SEPARATOR_S, ".pcb", PCB_DIR_SEPARATOR_S, "plugins", NULL)); + } + hid_load_dir(Concat("plugins", PCB_DIR_SEPARATOR_S, HOST, NULL)); + hid_load_dir(Concat("plugins", NULL)); } -void -hid_register_hid (HID * hid) +void hid_register_hid(HID * hid) { - int i; - int sz = (hid_num_hids + 2) * sizeof (HID *); + int i; + int sz = (hid_num_hids + 2) * sizeof(HID *); - if (hid->struct_size != sizeof (HID)) - { - fprintf (stderr, "Warning: hid \"%s\" has an incompatible ABI.\n", - hid->name); - return; - } + if (hid->struct_size != sizeof(HID)) { + fprintf(stderr, "Warning: hid \"%s\" has an incompatible ABI.\n", hid->name); + return; + } - for (i=0; iprinter && !hid_list[i]->exporter) - return hid_list[i]; + for (i = 0; i < hid_num_hids; i++) + if (!hid_list[i]->printer && !hid_list[i]->exporter) + return hid_list[i]; - fprintf (stderr, "Error: No GUI available.\n"); - exit (1); + fprintf(stderr, "Error: No GUI available.\n"); + exit(1); } -HID * -hid_find_printer () +HID *hid_find_printer() { - int i; + int i; - for (i = 0; i < hid_num_hids; i++) - if (hid_list[i]->printer) - return hid_list[i]; + for (i = 0; i < hid_num_hids; i++) + if (hid_list[i]->printer) + return hid_list[i]; - return 0; + return 0; } -HID * -hid_find_exporter (const char *which) +HID *hid_find_exporter(const char *which) { - int i; + int i; - for (i = 0; i < hid_num_hids; i++) - if (hid_list[i]->exporter && strcmp (which, hid_list[i]->name) == 0) - return hid_list[i]; + for (i = 0; i < hid_num_hids; i++) + if (hid_list[i]->exporter && strcmp(which, hid_list[i]->name) == 0) + return hid_list[i]; - fprintf (stderr, "Invalid exporter %s, available ones:", which); - for (i = 0; i < hid_num_hids; i++) - if (hid_list[i]->exporter) - fprintf (stderr, " %s", hid_list[i]->name); - fprintf (stderr, "\n"); + fprintf(stderr, "Invalid exporter %s, available ones:", which); + for (i = 0; i < hid_num_hids; i++) + if (hid_list[i]->exporter) + fprintf(stderr, " %s", hid_list[i]->name); + fprintf(stderr, "\n"); - return 0; + return 0; } -HID ** -hid_enumerate () +HID **hid_enumerate() { - return hid_list; + return hid_list; } HID_AttrNode *hid_attr_nodes = 0; -void -hid_register_attributes (HID_Attribute * a, int n) +void hid_register_attributes(HID_Attribute * a, int n) { - HID_AttrNode *ha; + HID_AttrNode *ha; - /* printf("%d attributes registered\n", n); */ - ha = (HID_AttrNode *) malloc (sizeof (HID_AttrNode)); - ha->next = hid_attr_nodes; - hid_attr_nodes = ha; - ha->attributes = a; - ha->n = n; + /* printf("%d attributes registered\n", n); */ + ha = (HID_AttrNode *) malloc(sizeof(HID_AttrNode)); + ha->next = hid_attr_nodes; + hid_attr_nodes = ha; + ha->attributes = a; + ha->n = n; } -void -hid_parse_command_line (int *argc, char ***argv) +void hid_parse_command_line(int *argc, char ***argv) { - HID_AttrNode *ha; - int i, e, ok; + HID_AttrNode *ha; + int i, e, ok; - (*argc)--; - (*argv)++; + (*argc)--; + (*argv)++; - for (ha = hid_attr_nodes; ha; ha = ha->next) - for (i = 0; i < ha->n; i++) - { - HID_Attribute *a = ha->attributes + i; - switch (a->type) - { - case HID_Label: - break; - case HID_Integer: - if (a->value) - *(int *) a->value = a->default_val.int_value; - break; - case HID_Coord: - if (a->value) - *(Coord *) a->value = a->default_val.coord_value; - break; - case HID_Boolean: - if (a->value) - *(char *) a->value = a->default_val.int_value; - break; - case HID_Real: - if (a->value) - *(double *) a->value = a->default_val.real_value; - break; - case HID_String: - if (a->value) - *(const char **) a->value = a->default_val.str_value; - break; - case HID_Enum: - if (a->value) - *(int *) a->value = a->default_val.int_value; - break; - case HID_Mixed: - if (a->value) { - *(HID_Attr_Val *) a->value = a->default_val; - case HID_Unit: - if (a->value) - *(int *) a->value = a->default_val.int_value; - break; - } - break; - default: - abort (); - } - } + for (ha = hid_attr_nodes; ha; ha = ha->next) + for (i = 0; i < ha->n; i++) { + HID_Attribute *a = ha->attributes + i; + switch (a->type) { + case HID_Label: + break; + case HID_Integer: + if (a->value) + *(int *) a->value = a->default_val.int_value; + break; + case HID_Coord: + if (a->value) + *(Coord *) a->value = a->default_val.coord_value; + break; + case HID_Boolean: + if (a->value) + *(char *) a->value = a->default_val.int_value; + break; + case HID_Real: + if (a->value) + *(double *) a->value = a->default_val.real_value; + break; + case HID_String: + if (a->value) + *(const char **) a->value = a->default_val.str_value; + break; + case HID_Enum: + if (a->value) + *(int *) a->value = a->default_val.int_value; + break; + case HID_Mixed: + if (a->value) { + *(HID_Attr_Val *) a->value = a->default_val; + case HID_Unit: + if (a->value) + *(int *) a->value = a->default_val.int_value; + break; + } + break; + default: + abort(); + } + } - while (*argc && (*argv)[0][0] == '-' && (*argv)[0][1] == '-') - { - int bool_val; - int arg_ofs; + while (*argc && (*argv)[0][0] == '-' && (*argv)[0][1] == '-') { + int bool_val; + int arg_ofs; - bool_val = 1; - arg_ofs = 2; - try_no_arg: - for (ha = hid_attr_nodes; ha; ha = ha->next) - for (i = 0; i < ha->n; i++) - if (strcmp ((*argv)[0] + arg_ofs, ha->attributes[i].name) == 0) - { - HID_Attribute *a = ha->attributes + i; - char *ep; - const Unit *unit; - switch (ha->attributes[i].type) - { - case HID_Label: - break; - case HID_Integer: - if (a->value) - *(int *) a->value = strtol ((*argv)[1], 0, 0); - else - a->default_val.int_value = strtol ((*argv)[1], 0, 0); - (*argc)--; - (*argv)++; - break; - case HID_Coord: - if (a->value) - *(Coord *) a->value = GetValue ((*argv)[1], NULL, NULL); - else - a->default_val.coord_value = GetValue ((*argv)[1], NULL, NULL); - (*argc)--; - (*argv)++; - break; - case HID_Real: - if (a->value) - *(double *) a->value = strtod ((*argv)[1], 0); - else - a->default_val.real_value = strtod ((*argv)[1], 0); - (*argc)--; - (*argv)++; - break; - case HID_String: - if (a->value) - *(char **) a->value = (*argv)[1]; - else - a->default_val.str_value = (*argv)[1]; - (*argc)--; - (*argv)++; - break; - case HID_Boolean: - if (a->value) - *(char *) a->value = bool_val; - else - a->default_val.int_value = bool_val; - break; - case HID_Mixed: - a->default_val.real_value = strtod ((*argv)[1], &ep); - goto do_enum; - case HID_Enum: - ep = (*argv)[1]; - do_enum: - ok = 0; - for (e = 0; a->enumerations[e]; e++) - if (strcmp (a->enumerations[e], ep) == 0) - { - ok = 1; - a->default_val.int_value = e; - a->default_val.str_value = ep; - break; - } - if (!ok) - { - fprintf (stderr, - "ERROR: \"%s\" is an unknown value for the --%s option\n", - (*argv)[1], a->name); - exit (1); - } - (*argc)--; - (*argv)++; - break; - case HID_Path: - abort (); - a->default_val.str_value = (*argv)[1]; - (*argc)--; - (*argv)++; - break; - case HID_Unit: - unit = get_unit_struct ((*argv)[1]); - if (unit == NULL) - { - fprintf (stderr, - "ERROR: unit \"%s\" is unknown to pcb (option --%s)\n", - (*argv)[1], a->name); - exit (1); - } - a->default_val.int_value = unit->index; - a->default_val.str_value = unit->suffix; - (*argc)--; - (*argv)++; - break; + bool_val = 1; + arg_ofs = 2; + try_no_arg: + for (ha = hid_attr_nodes; ha; ha = ha->next) + for (i = 0; i < ha->n; i++) + if (strcmp((*argv)[0] + arg_ofs, ha->attributes[i].name) == 0) { + HID_Attribute *a = ha->attributes + i; + char *ep; + const Unit *unit; + switch (ha->attributes[i].type) { + case HID_Label: + break; + case HID_Integer: + if (a->value) + *(int *) a->value = strtol((*argv)[1], 0, 0); + else + a->default_val.int_value = strtol((*argv)[1], 0, 0); + (*argc)--; + (*argv)++; + break; + case HID_Coord: + if (a->value) + *(Coord *) a->value = GetValue((*argv)[1], NULL, NULL); + else + a->default_val.coord_value = GetValue((*argv)[1], NULL, NULL); + (*argc)--; + (*argv)++; + break; + case HID_Real: + if (a->value) + *(double *) a->value = strtod((*argv)[1], 0); + else + a->default_val.real_value = strtod((*argv)[1], 0); + (*argc)--; + (*argv)++; + break; + case HID_String: + if (a->value) + *(char **) a->value = (*argv)[1]; + else + a->default_val.str_value = (*argv)[1]; + (*argc)--; + (*argv)++; + break; + case HID_Boolean: + if (a->value) + *(char *) a->value = bool_val; + else + a->default_val.int_value = bool_val; + break; + case HID_Mixed: + a->default_val.real_value = strtod((*argv)[1], &ep); + goto do_enum; + case HID_Enum: + ep = (*argv)[1]; + do_enum: + ok = 0; + for (e = 0; a->enumerations[e]; e++) + if (strcmp(a->enumerations[e], ep) == 0) { + ok = 1; + a->default_val.int_value = e; + a->default_val.str_value = ep; + break; + } + if (!ok) { + fprintf(stderr, "ERROR: \"%s\" is an unknown value for the --%s option\n", (*argv)[1], a->name); + exit(1); + } + (*argc)--; + (*argv)++; + break; + case HID_Path: + abort(); + a->default_val.str_value = (*argv)[1]; + (*argc)--; + (*argv)++; + break; + case HID_Unit: + unit = get_unit_struct((*argv)[1]); + if (unit == NULL) { + fprintf(stderr, "ERROR: unit \"%s\" is unknown to pcb (option --%s)\n", (*argv)[1], a->name); + exit(1); + } + a->default_val.int_value = unit->index; + a->default_val.str_value = unit->suffix; + (*argc)--; + (*argv)++; + break; + } + (*argc)--; + (*argv)++; + ha = 0; + goto got_match; + } + if (bool_val == 1 && strncmp((*argv)[0], "--no-", 5) == 0) { + bool_val = 0; + arg_ofs = 5; + goto try_no_arg; } - (*argc)--; - (*argv)++; - ha = 0; - goto got_match; - } - if (bool_val == 1 && strncmp ((*argv)[0], "--no-", 5) == 0) - { - bool_val = 0; - arg_ofs = 5; - goto try_no_arg; + fprintf(stderr, "unrecognized option: %s\n", (*argv)[0]); + exit(1); + got_match:; } - fprintf (stderr, "unrecognized option: %s\n", (*argv)[0]); - exit (1); - got_match:; - } - (*argc)++; - (*argv)--; + (*argc)++; + (*argv)--; } -static int -attr_hash (HID_Attribute *a) +static int attr_hash(HID_Attribute * a) { - unsigned char *cp = (unsigned char *)a; - int i, rv=0; - for (i=0; i<(int)((char *)&(a->hash) - (char *)a); i++) - rv = (rv * 13) ^ (rv >> 16) ^ cp[i]; - return rv; + unsigned char *cp = (unsigned char *) a; + int i, rv = 0; + for (i = 0; i < (int) ((char *) &(a->hash) - (char *) a); i++) + rv = (rv * 13) ^ (rv >> 16) ^ cp[i]; + return rv; } -void -hid_save_settings (int locally) +void hid_save_settings(int locally) { - char *fname; - struct stat st; - FILE *f; - HID_AttrNode *ha; - int i; + char *fname; + struct stat st; + FILE *f; + HID_AttrNode *ha; + int i; - if (locally) - { - fname = Concat ("pcb.settings", NULL); - } - else - { - if (homedir == NULL) - return; - fname = Concat (homedir, PCB_DIR_SEPARATOR_S, ".pcb", NULL); + if (locally) { + fname = Concat("pcb.settings", NULL); + } + else { + if (homedir == NULL) + return; + fname = Concat(homedir, PCB_DIR_SEPARATOR_S, ".pcb", NULL); - if (stat (fname, &st)) - if (MKDIR (fname, 0777)) - { - free (fname); - return; - } - free (fname); + if (stat(fname, &st)) + if (MKDIR(fname, 0777)) { + free(fname); + return; + } + free(fname); - fname = Concat (homedir, PCB_DIR_SEPARATOR_S, ".pcb", - PCB_DIR_SEPARATOR_S, "settings", NULL); - } + fname = Concat(homedir, PCB_DIR_SEPARATOR_S, ".pcb", PCB_DIR_SEPARATOR_S, "settings", NULL); + } - f = fopen (fname, "w"); - if (!f) - { - Message ("Can't open %s", fname); - free (fname); - return; - } + f = fopen(fname, "w"); + if (!f) { + Message("Can't open %s", fname); + free(fname); + return; + } - for (ha = hid_attr_nodes; ha; ha = ha->next) - { - for (i = 0; i < ha->n; i++) - { - const char *str; - HID_Attribute *a = ha->attributes + i; + for (ha = hid_attr_nodes; ha; ha = ha->next) { + for (i = 0; i < ha->n; i++) { + const char *str; + HID_Attribute *a = ha->attributes + i; - if (a->hash == attr_hash (a)) - fprintf (f, "# "); - switch (a->type) - { - case HID_Label: - break; - case HID_Integer: - fprintf (f, "%s = %d\n", - a->name, - a->value ? *(int *)a->value : a->default_val.int_value); - break; - case HID_Coord: - pcb_fprintf (f, "%s = %$mS\n", - a->name, - a->value ? *(Coord *)a->value : a->default_val.coord_value); - break; - case HID_Boolean: - fprintf (f, "%s = %d\n", - a->name, - a->value ? *(char *)a->value : a->default_val.int_value); - break; - case HID_Real: - fprintf (f, "%s = %f\n", - a->name, - a->value ? *(double *)a->value : a->default_val.real_value); - break; - case HID_String: - case HID_Path: - str = a->value ? *(char **)a->value : a->default_val.str_value; - fprintf (f, "%s = %s\n", a->name, str ? str : ""); - break; - case HID_Enum: - fprintf (f, "%s = %s\n", - a->name, - a->enumerations[a->value ? *(int *)a->value : a->default_val.int_value]); - break; - case HID_Mixed: - { - HID_Attr_Val *value = - a->value ? (HID_Attr_Val*) a->value : &(a->default_val); - fprintf (f, "%s = %g%s\n", - a->name, - value->real_value, - a->enumerations[value->int_value]); - } - break; - case HID_Unit: - fprintf (f, "%s = %s\n", - a->name, - get_unit_list()[a->value ? *(int *)a->value : a->default_val.int_value].suffix); - break; - } + if (a->hash == attr_hash(a)) + fprintf(f, "# "); + switch (a->type) { + case HID_Label: + break; + case HID_Integer: + fprintf(f, "%s = %d\n", a->name, a->value ? *(int *) a->value : a->default_val.int_value); + break; + case HID_Coord: + pcb_fprintf(f, "%s = %$mS\n", a->name, a->value ? *(Coord *) a->value : a->default_val.coord_value); + break; + case HID_Boolean: + fprintf(f, "%s = %d\n", a->name, a->value ? *(char *) a->value : a->default_val.int_value); + break; + case HID_Real: + fprintf(f, "%s = %f\n", a->name, a->value ? *(double *) a->value : a->default_val.real_value); + break; + case HID_String: + case HID_Path: + str = a->value ? *(char **) a->value : a->default_val.str_value; + fprintf(f, "%s = %s\n", a->name, str ? str : ""); + break; + case HID_Enum: + fprintf(f, "%s = %s\n", a->name, a->enumerations[a->value ? *(int *) a->value : a->default_val.int_value]); + break; + case HID_Mixed: + { + HID_Attr_Val *value = a->value ? (HID_Attr_Val *) a->value : &(a->default_val); + fprintf(f, "%s = %g%s\n", a->name, value->real_value, a->enumerations[value->int_value]); + } + break; + case HID_Unit: + fprintf(f, "%s = %s\n", a->name, get_unit_list()[a->value ? *(int *) a->value : a->default_val.int_value].suffix); + break; + } + } + fprintf(f, "\n"); } - fprintf (f, "\n"); - } - fclose (f); - free (fname); + fclose(f); + free(fname); } -static void -hid_set_attribute (char *name, char *value) +static void hid_set_attribute(char *name, char *value) { - const Unit *unit; - HID_AttrNode *ha; - int i, e, ok; + const Unit *unit; + HID_AttrNode *ha; + int i, e, ok; - for (ha = hid_attr_nodes; ha; ha = ha->next) - for (i = 0; i < ha->n; i++) - if (strcmp (name, ha->attributes[i].name) == 0) - { - HID_Attribute *a = ha->attributes + i; - switch (ha->attributes[i].type) - { - case HID_Label: - break; - case HID_Integer: - a->default_val.int_value = strtol (value, 0, 0); - break; - case HID_Coord: - a->default_val.coord_value = GetValue (value, NULL, NULL); - break; - case HID_Real: - a->default_val.real_value = strtod (value, 0); - break; - case HID_String: - a->default_val.str_value = strdup (value); - break; - case HID_Boolean: - a->default_val.int_value = 1; - break; - case HID_Mixed: - a->default_val.real_value = strtod (value, &value); - /* fall through */ - case HID_Enum: - ok = 0; - for (e = 0; a->enumerations[e]; e++) - if (strcmp (a->enumerations[e], value) == 0) - { - ok = 1; - a->default_val.int_value = e; - a->default_val.str_value = value; - break; - } - if (!ok) - { - fprintf (stderr, - "ERROR: \"%s\" is an unknown value for the %s option\n", - value, a->name); - exit (1); - } - break; - case HID_Path: - a->default_val.str_value = value; - break; - case HID_Unit: - unit = get_unit_struct (value); - if (unit == NULL) - { - fprintf (stderr, - "ERROR: unit \"%s\" is unknown to pcb (option --%s)\n", - value, a->name); - exit (1); - } - a->default_val.int_value = unit->index; - a->default_val.str_value = unit->suffix; - break; - } - } + for (ha = hid_attr_nodes; ha; ha = ha->next) + for (i = 0; i < ha->n; i++) + if (strcmp(name, ha->attributes[i].name) == 0) { + HID_Attribute *a = ha->attributes + i; + switch (ha->attributes[i].type) { + case HID_Label: + break; + case HID_Integer: + a->default_val.int_value = strtol(value, 0, 0); + break; + case HID_Coord: + a->default_val.coord_value = GetValue(value, NULL, NULL); + break; + case HID_Real: + a->default_val.real_value = strtod(value, 0); + break; + case HID_String: + a->default_val.str_value = strdup(value); + break; + case HID_Boolean: + a->default_val.int_value = 1; + break; + case HID_Mixed: + a->default_val.real_value = strtod(value, &value); + /* fall through */ + case HID_Enum: + ok = 0; + for (e = 0; a->enumerations[e]; e++) + if (strcmp(a->enumerations[e], value) == 0) { + ok = 1; + a->default_val.int_value = e; + a->default_val.str_value = value; + break; + } + if (!ok) { + fprintf(stderr, "ERROR: \"%s\" is an unknown value for the %s option\n", value, a->name); + exit(1); + } + break; + case HID_Path: + a->default_val.str_value = value; + break; + case HID_Unit: + unit = get_unit_struct(value); + if (unit == NULL) { + fprintf(stderr, "ERROR: unit \"%s\" is unknown to pcb (option --%s)\n", value, a->name); + exit(1); + } + a->default_val.int_value = unit->index; + a->default_val.str_value = unit->suffix; + break; + } + } } -static void -hid_load_settings_1 (char *fname) +static void hid_load_settings_1(char *fname) { - char line[1024], *namep, *valp, *cp; - FILE *f; + char line[1024], *namep, *valp, *cp; + FILE *f; - f = fopen (fname, "r"); - if (!f) - { - free (fname); - return; - } + f = fopen(fname, "r"); + if (!f) { + free(fname); + return; + } - free (fname); - while (fgets (line, sizeof(line), f) != NULL) - { - for (namep=line; *namep && isspace ((int) *namep); namep++) - ; - if (*namep == '#') - continue; - for (valp=namep; *valp && !isspace((int) *valp); valp++) - ; - if (! *valp) - continue; - *valp++ = 0; - while (*valp && (isspace ((int) *valp) || *valp == '=')) - valp ++; - if (! *valp) - continue; - cp = valp + strlen(valp) - 1; - while (cp >= valp && isspace ((int) *cp)) - *cp-- = 0; - hid_set_attribute (namep, valp); - } + free(fname); + while (fgets(line, sizeof(line), f) != NULL) { + for (namep = line; *namep && isspace((int) *namep); namep++); + if (*namep == '#') + continue; + for (valp = namep; *valp && !isspace((int) *valp); valp++); + if (!*valp) + continue; + *valp++ = 0; + while (*valp && (isspace((int) *valp) || *valp == '=')) + valp++; + if (!*valp) + continue; + cp = valp + strlen(valp) - 1; + while (cp >= valp && isspace((int) *cp)) + *cp-- = 0; + hid_set_attribute(namep, valp); + } - fclose (f); + fclose(f); } -void -hid_load_settings () +void hid_load_settings() { - HID_AttrNode *ha; - int i; + HID_AttrNode *ha; + int i; - for (ha = hid_attr_nodes; ha; ha = ha->next) - for (i = 0; i < ha->n; i++) - ha->attributes[i].hash = attr_hash (ha->attributes+i); + for (ha = hid_attr_nodes; ha; ha = ha->next) + for (i = 0; i < ha->n; i++) + ha->attributes[i].hash = attr_hash(ha->attributes + i); - hid_load_settings_1 (Concat (pcblibdir, PCB_DIR_SEPARATOR_S, "settings", NULL)); - if (homedir != NULL) - hid_load_settings_1 (Concat (homedir, PCB_DIR_SEPARATOR_S, ".pcb", - PCB_DIR_SEPARATOR_S, "settings", NULL)); - hid_load_settings_1 (Concat ("pcb.settings", NULL)); + hid_load_settings_1(Concat(pcblibdir, PCB_DIR_SEPARATOR_S, "settings", NULL)); + if (homedir != NULL) + hid_load_settings_1(Concat(homedir, PCB_DIR_SEPARATOR_S, ".pcb", PCB_DIR_SEPARATOR_S, "settings", NULL)); + hid_load_settings_1(Concat("pcb.settings", NULL)); } #define HASH_SIZE 31 -typedef struct ecache -{ - struct ecache *next; - const char *name; - hidval val; +typedef struct ecache { + struct ecache *next; + const char *name; + hidval val; } ecache; -typedef struct ccache -{ - ecache *colors[HASH_SIZE]; - ecache *lru; +typedef struct ccache { + ecache *colors[HASH_SIZE]; + ecache *lru; } ccache; -static void -copy_color (int set, hidval * cval, hidval * aval) +static void copy_color(int set, hidval * cval, hidval * aval) { - if (set) - memcpy (cval, aval, sizeof (hidval)); - else - memcpy (aval, cval, sizeof (hidval)); + if (set) + memcpy(cval, aval, sizeof(hidval)); + else + memcpy(aval, cval, sizeof(hidval)); } -int -hid_cache_color (int set, const char *name, hidval * val, void **vcache) +int hid_cache_color(int set, const char *name, hidval * val, void **vcache) { - unsigned long hash; - const char *cp; - ccache *cache; - ecache *e; + unsigned long hash; + const char *cp; + ccache *cache; + ecache *e; - cache = (ccache *) * vcache; - if (cache == 0) { - cache = (ccache *) calloc (sizeof (ccache), 1); - *vcache = cache; - } - if (cache->lru && strcmp (cache->lru->name, name) == 0) - { - copy_color (set, &(cache->lru->val), val); - return 1; - } + cache = (ccache *) * vcache; + if (cache == 0) { + cache = (ccache *) calloc(sizeof(ccache), 1); + *vcache = cache; + } + if (cache->lru && strcmp(cache->lru->name, name) == 0) { + copy_color(set, &(cache->lru->val), val); + return 1; + } - /* djb2: this algorithm (k=33) was first reported by dan bernstein many - * years ago in comp.lang.c. another version of this algorithm (now favored - * by bernstein) uses xor: hash(i) = hash(i - 1) * 33 ^ str[i]; the magic - * of number 33 (why it works better than many other constants, prime or - * not) has never been adequately explained. - */ - hash = 5381; - for (cp = name, hash = 0; *cp; cp++) - hash = ((hash << 5) + hash) + (*cp & 0xff); /* hash * 33 + c */ - hash %= HASH_SIZE; + /* djb2: this algorithm (k=33) was first reported by dan bernstein many + * years ago in comp.lang.c. another version of this algorithm (now favored + * by bernstein) uses xor: hash(i) = hash(i - 1) * 33 ^ str[i]; the magic + * of number 33 (why it works better than many other constants, prime or + * not) has never been adequately explained. + */ + hash = 5381; + for (cp = name, hash = 0; *cp; cp++) + hash = ((hash << 5) + hash) + (*cp & 0xff); /* hash * 33 + c */ + hash %= HASH_SIZE; - for (e = cache->colors[hash]; e; e = e->next) - if (strcmp (e->name, name) == 0) - { - copy_color (set, &(e->val), val); + for (e = cache->colors[hash]; e; e = e->next) + if (strcmp(e->name, name) == 0) { + copy_color(set, &(e->val), val); + cache->lru = e; + return 1; + } + if (!set) + return 0; + + e = (ecache *) malloc(sizeof(ecache)); + e->next = cache->colors[hash]; + cache->colors[hash] = e; + e->name = strdup(name); + memcpy(&(e->val), val, sizeof(hidval)); cache->lru = e; + return 1; - } - if (!set) - return 0; - - e = (ecache *) malloc (sizeof (ecache)); - e->next = cache->colors[hash]; - cache->colors[hash] = e; - e->name = strdup (name); - memcpy (&(e->val), val, sizeof (hidval)); - cache->lru = e; - - return 1; } /* otherwise homeless function, refactored out of the five export HIDs */ -void -derive_default_filename(const char *pcbfile, HID_Attribute *filename_attrib, const char *suffix, char **memory) +void derive_default_filename(const char *pcbfile, HID_Attribute * filename_attrib, const char *suffix, char **memory) { char *buf; char *pf; if (pcbfile == NULL) - pf = strdup ("unknown.pcb"); + pf = strdup("unknown.pcb"); else - pf = strdup (pcbfile); + pf = strdup(pcbfile); - if (!pf || (memory && filename_attrib->default_val.str_value != *memory)) return; + if (!pf || (memory && filename_attrib->default_val.str_value != *memory)) + return; - buf = (char *)malloc (strlen (pf) + strlen(suffix) + 1); - if (memory) *memory = buf; + buf = (char *) malloc(strlen(pf) + strlen(suffix) + 1); + if (memory) + *memory = buf; if (buf) { size_t bl; - strcpy (buf, pf); + strcpy(buf, pf); bl = strlen(buf); - if (bl > 4 && strcmp (buf + bl - 4, ".pcb") == 0) + if (bl > 4 && strcmp(buf + bl - 4, ".pcb") == 0) buf[bl - 4] = 0; strcat(buf, suffix); if (filename_attrib->default_val.str_value) - free ((void *) filename_attrib->default_val.str_value); + free((void *) filename_attrib->default_val.str_value); filename_attrib->default_val.str_value = buf; } - free (pf); + free(pf); } Index: trunk/src/hid/common/hidinit.h =================================================================== --- trunk/src/hid/common/hidinit.h (revision 1021) +++ trunk/src/hid/common/hidinit.h (revision 1022) @@ -1,6 +1,6 @@ #ifndef PCB_HID_COMMON_HIDINIT_H #define PCB_HID_COMMON_HIDINIT_H -void hid_parse_command_line (int *argc, char ***argv); +void hid_parse_command_line(int *argc, char ***argv); #endif Index: trunk/src/hid/common/hidnogui.c =================================================================== --- trunk/src/hid/common/hidnogui.c (revision 1021) +++ trunk/src/hid/common/hidnogui.c (revision 1022) @@ -14,7 +14,7 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); /* This is the "gui" that is installed at startup, and is used when there is no other real GUI to use. For the most part, it just @@ -23,265 +23,223 @@ #define CRASH fprintf(stderr, "HID error: pcb called GUI function %s without having a GUI available.\n", __FUNCTION__); abort() -typedef struct hid_gc_struct -{ - int nothing_interesting_here; +typedef struct hid_gc_struct { + int nothing_interesting_here; } hid_gc_struct; -static HID_Attribute * -nogui_get_export_options (int *n_ret) +static HID_Attribute *nogui_get_export_options(int *n_ret) { - CRASH; - return 0; + CRASH; + return 0; } -static void -nogui_do_export (HID_Attr_Val * options) +static void nogui_do_export(HID_Attr_Val * options) { - CRASH; + CRASH; } -static void -nogui_parse_arguments (int *argc, char ***argv) +static void nogui_parse_arguments(int *argc, char ***argv) { - CRASH; + CRASH; } -static void -nogui_invalidate_lr (int l, int r, int t, int b) +static void nogui_invalidate_lr(int l, int r, int t, int b) { - CRASH; + CRASH; } -static void -nogui_invalidate_all (void) +static void nogui_invalidate_all(void) { - CRASH; + CRASH; } -static int -nogui_set_layer (const char *name, int idx, int empty) +static int nogui_set_layer(const char *name, int idx, int empty) { - CRASH; - return 0; + CRASH; + return 0; } -static void -nogui_end_layer (void) +static void nogui_end_layer(void) { } -static hidGC -nogui_make_gc (void) +static hidGC nogui_make_gc(void) { - return 0; + return 0; } -static void -nogui_destroy_gc (hidGC gc) +static void nogui_destroy_gc(hidGC gc) { } -static void -nogui_use_mask (int use_it) +static void nogui_use_mask(int use_it) { - CRASH; + CRASH; } -static void -nogui_set_color (hidGC gc, const char *name) +static void nogui_set_color(hidGC gc, const char *name) { - CRASH; + CRASH; } -static void -nogui_set_line_cap (hidGC gc, EndCapStyle style) +static void nogui_set_line_cap(hidGC gc, EndCapStyle style) { - CRASH; + CRASH; } -static void -nogui_set_line_width (hidGC gc, Coord width) +static void nogui_set_line_width(hidGC gc, Coord width) { - CRASH; + CRASH; } -static void -nogui_set_draw_xor (hidGC gc, int xor_) +static void nogui_set_draw_xor(hidGC gc, int xor_) { - CRASH; + CRASH; } -static void -nogui_set_draw_faded (hidGC gc, int faded) +static void nogui_set_draw_faded(hidGC gc, int faded) { } -static void -nogui_draw_line (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) +static void nogui_draw_line(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) { - CRASH; + CRASH; } -static void -nogui_draw_arc (hidGC gc, Coord cx, Coord cy, Coord width, Coord height, - Angle start_angle, Angle end_angle) +static void nogui_draw_arc(hidGC gc, Coord cx, Coord cy, Coord width, Coord height, Angle start_angle, Angle end_angle) { - CRASH; + CRASH; } -static void -nogui_draw_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) +static void nogui_draw_rect(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) { - CRASH; + CRASH; } -static void -nogui_fill_circle (hidGC gc, Coord cx, Coord cy, Coord radius) +static void nogui_fill_circle(hidGC gc, Coord cx, Coord cy, Coord radius) { - CRASH; + CRASH; } -static void -nogui_fill_polygon (hidGC gc, int n_coords, Coord *x, Coord *y) +static void nogui_fill_polygon(hidGC gc, int n_coords, Coord * x, Coord * y) { - CRASH; + CRASH; } -static void -nogui_fill_pcb_polygon (hidGC gc, PolygonType *poly, const BoxType *clip_box) +static void nogui_fill_pcb_polygon(hidGC gc, PolygonType * poly, const BoxType * clip_box) { - CRASH; + CRASH; } -static void -nogui_fill_pcb_pad (hidGC gc, PadType *pad, bool clear, bool mask) +static void nogui_fill_pcb_pad(hidGC gc, PadType * pad, bool clear, bool mask) { - CRASH; + CRASH; } -static void -nogui_thindraw_pcb_pad (hidGC gc, PadType *pad, bool clear, bool mask) +static void nogui_thindraw_pcb_pad(hidGC gc, PadType * pad, bool clear, bool mask) { - CRASH; + CRASH; } -static void -nogui_fill_pcb_pv (hidGC fg_gc, hidGC bg_gc, PinType *pad, bool drawHole, bool mask) +static void nogui_fill_pcb_pv(hidGC fg_gc, hidGC bg_gc, PinType * pad, bool drawHole, bool mask) { - CRASH; + CRASH; } -static void -nogui_thindraw_pcb_pv (hidGC fg_gc, hidGC bg_gc, PinType *pad, bool drawHole, bool mask) +static void nogui_thindraw_pcb_pv(hidGC fg_gc, hidGC bg_gc, PinType * pad, bool drawHole, bool mask) { - CRASH; + CRASH; } -static void -nogui_fill_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) +static void nogui_fill_rect(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) { - CRASH; + CRASH; } -static void -nogui_calibrate (double xval, double yval) +static void nogui_calibrate(double xval, double yval) { - CRASH; + CRASH; } -static int -nogui_shift_is_pressed (void) +static int nogui_shift_is_pressed(void) { - /* This is called from FitCrosshairIntoGrid() when the board is loaded. */ - return 0; + /* This is called from FitCrosshairIntoGrid() when the board is loaded. */ + return 0; } -static int -nogui_control_is_pressed (void) +static int nogui_control_is_pressed(void) { - CRASH; - return 0; + CRASH; + return 0; } -static int -nogui_mod1_is_pressed (void) +static int nogui_mod1_is_pressed(void) { - CRASH; - return 0; + CRASH; + return 0; } -static void -nogui_get_coords (const char *msg, Coord *x, Coord *y) +static void nogui_get_coords(const char *msg, Coord * x, Coord * y) { - CRASH; + CRASH; } -static void -nogui_set_crosshair (int x, int y, int action) +static void nogui_set_crosshair(int x, int y, int action) { } -static hidval -nogui_add_timer (void (*func) (hidval user_data), - unsigned long milliseconds, hidval user_data) +static hidval nogui_add_timer(void (*func) (hidval user_data), unsigned long milliseconds, hidval user_data) { - hidval rv; - CRASH; - rv.lval = 0; - return rv; + hidval rv; + CRASH; + rv.lval = 0; + return rv; } -static void -nogui_stop_timer (hidval timer) +static void nogui_stop_timer(hidval timer) { - CRASH; + CRASH; } static hidval -nogui_watch_file (int fd, unsigned int condition, void (*func) (hidval watch, int fd, unsigned int condition, hidval user_data), - hidval user_data) +nogui_watch_file(int fd, unsigned int condition, void (*func) (hidval watch, int fd, unsigned int condition, hidval user_data), + hidval user_data) { - hidval rv; - CRASH; - rv.lval = 0; - return rv; + hidval rv; + CRASH; + rv.lval = 0; + return rv; } -static void -nogui_unwatch_file (hidval watch) +static void nogui_unwatch_file(hidval watch) { - CRASH; + CRASH; } -static hidval -nogui_add_block_hook (void (*func) (hidval data), hidval data) +static hidval nogui_add_block_hook(void (*func) (hidval data), hidval data) { - hidval rv; - CRASH; - rv.ptr = NULL; - return rv; + hidval rv; + CRASH; + rv.ptr = NULL; + return rv; } -static void -nogui_stop_block_hook (hidval block_hook) +static void nogui_stop_block_hook(hidval block_hook) { - CRASH; + CRASH; } -static void -nogui_log (const char *fmt, ...) +static void nogui_log(const char *fmt, ...) { - va_list ap; - va_start (ap, fmt); - vprintf (fmt, ap); - va_end (ap); + va_list ap; + va_start(ap, fmt); + vprintf(fmt, ap); + va_end(ap); } -static void -nogui_logv (const char *fmt, va_list ap) +static void nogui_logv(const char *fmt, va_list ap) { - vprintf (fmt, ap); + vprintf(fmt, ap); } /* Return a line of user input text, stripped of any newline characters. @@ -288,240 +246,218 @@ * Returns NULL if the user simply presses enter, or otherwise gives no input. */ #define MAX_LINE_LENGTH 1024 -static char * -read_stdin_line (void) +static char *read_stdin_line(void) { - static char buf[MAX_LINE_LENGTH]; - char *s; - int i; + static char buf[MAX_LINE_LENGTH]; + char *s; + int i; - s = fgets (buf, MAX_LINE_LENGTH, stdin); - if (s == NULL) - { - printf ("\n"); - return NULL; - } + s = fgets(buf, MAX_LINE_LENGTH, stdin); + if (s == NULL) { + printf("\n"); + return NULL; + } - /* Strip any trailing newline characters */ - for (i = strlen (s) - 1; i >= 0; i--) - if (s[i] == '\r' || s[i] == '\n') - s[i] = '\0'; + /* Strip any trailing newline characters */ + for (i = strlen(s) - 1; i >= 0; i--) + if (s[i] == '\r' || s[i] == '\n') + s[i] = '\0'; - if (s[0] == '\0') - return NULL; + if (s[0] == '\0') + return NULL; - return strdup (s); + return strdup(s); } + #undef MAX_LINE_LENGTH -static int -nogui_confirm_dialog (const char *msg, ...) +static int nogui_confirm_dialog(const char *msg, ...) { - char *answer; - int ret = 0; - bool valid_answer = false; - va_list args; + char *answer; + int ret = 0; + bool valid_answer = false; + va_list args; - do - { - va_start (args, msg); - vprintf (msg, args); - va_end (args); + do { + va_start(args, msg); + vprintf(msg, args); + va_end(args); - printf (" ? 0=cancel 1 = ok : "); + printf(" ? 0=cancel 1 = ok : "); - answer = read_stdin_line (); + answer = read_stdin_line(); - if (answer == NULL) - continue; + if (answer == NULL) + continue; - if (answer[0] == '0' && answer[1] == '\0') - { - ret = 0; - valid_answer = true; - } + if (answer[0] == '0' && answer[1] == '\0') { + ret = 0; + valid_answer = true; + } - if (answer[0] == '1' && answer[1] == '\0') - { - ret = 1; - valid_answer = true; - } + if (answer[0] == '1' && answer[1] == '\0') { + ret = 1; + valid_answer = true; + } - free (answer); - } - while (!valid_answer); - return ret; + free(answer); + } + while (!valid_answer); + return ret; } -static int -nogui_close_confirm_dialog () +static int nogui_close_confirm_dialog() { - return nogui_confirm_dialog (_("OK to lose data ?"), NULL); + return nogui_confirm_dialog(_("OK to lose data ?"), NULL); } -static void -nogui_report_dialog (const char *title, const char *msg) +static void nogui_report_dialog(const char *title, const char *msg) { - printf ("--- %s ---\n%s\n", title, msg); + printf("--- %s ---\n%s\n", title, msg); } -static char * -nogui_prompt_for (const char *msg, const char *default_string) +static char *nogui_prompt_for(const char *msg, const char *default_string) { - char *answer; + char *answer; - if (default_string) - printf ("%s [%s] : ", msg, default_string); - else - printf ("%s : ", msg); + if (default_string) + printf("%s [%s] : ", msg, default_string); + else + printf("%s : ", msg); - answer = read_stdin_line (); - if (answer == NULL) - return strdup ((default_string != NULL) ? default_string : ""); - else - return strdup (answer); + answer = read_stdin_line(); + if (answer == NULL) + return strdup((default_string != NULL) ? default_string : ""); + else + return strdup(answer); } /* FIXME - this could use some enhancement to actually use the other args */ -static char * -nogui_fileselect (const char *title, const char *descr, - char *default_file, char *default_ext, - const char *history_tag, int flags) +static char *nogui_fileselect(const char *title, const char *descr, + char *default_file, char *default_ext, const char *history_tag, int flags) { - char *answer; + char *answer; - if (default_file) - printf ("%s [%s] : ", title, default_file); - else - printf ("%s : ", title); + if (default_file) + printf("%s [%s] : ", title, default_file); + else + printf("%s : ", title); - answer = read_stdin_line (); - if (answer == NULL) - return (default_file != NULL) ? strdup (default_file) : NULL; - else - return strdup (answer); + answer = read_stdin_line(); + if (answer == NULL) + return (default_file != NULL) ? strdup(default_file) : NULL; + else + return strdup(answer); } static int -nogui_attribute_dialog (HID_Attribute * attrs, - int n_attrs, HID_Attr_Val * results, - const char * title, const char * descr) +nogui_attribute_dialog(HID_Attribute * attrs, int n_attrs, HID_Attr_Val * results, const char *title, const char *descr) { - CRASH; + CRASH; } -static void -nogui_show_item (void *item) +static void nogui_show_item(void *item) { - CRASH; + CRASH; } -static void -nogui_beep (void) +static void nogui_beep(void) { - putchar (7); - fflush (stdout); + putchar(7); + fflush(stdout); } -static int -nogui_progress (int so_far, int total, const char *message) +static int nogui_progress(int so_far, int total, const char *message) { - return 0; + return 0; } -static HID * -nogui_request_debug_draw (void) +static HID *nogui_request_debug_draw(void) { - return NULL; + return NULL; } -static void -nogui_flush_debug_draw (void) +static void nogui_flush_debug_draw(void) { } -static void -nogui_finish_debug_draw (void) +static void nogui_finish_debug_draw(void) { } -static void -nogui_create_menu(const char *menu[], const char *action, const char *mnemonic, const char *accel, const char *tip) +static void nogui_create_menu(const char *menu[], const char *action, const char *mnemonic, const char *accel, const char *tip) { } -void -common_nogui_init (HID *hid) +void common_nogui_init(HID * hid) { - hid->get_export_options = nogui_get_export_options; - hid->do_export = nogui_do_export; - hid->parse_arguments = nogui_parse_arguments; - hid->invalidate_lr = nogui_invalidate_lr; - hid->invalidate_all = nogui_invalidate_all; - hid->set_layer = nogui_set_layer; - hid->end_layer = nogui_end_layer; - hid->make_gc = nogui_make_gc; - hid->destroy_gc = nogui_destroy_gc; - hid->use_mask = nogui_use_mask; - hid->set_color = nogui_set_color; - hid->set_line_cap = nogui_set_line_cap; - hid->set_line_width = nogui_set_line_width; - hid->set_draw_xor = nogui_set_draw_xor; - hid->set_draw_faded = nogui_set_draw_faded; - hid->draw_line = nogui_draw_line; - hid->draw_arc = nogui_draw_arc; - hid->draw_rect = nogui_draw_rect; - hid->fill_circle = nogui_fill_circle; - hid->fill_polygon = nogui_fill_polygon; - hid->fill_pcb_polygon = nogui_fill_pcb_polygon; - hid->fill_pcb_pad = nogui_fill_pcb_pad; - hid->thindraw_pcb_pad = nogui_thindraw_pcb_pad; - hid->fill_pcb_pv = nogui_fill_pcb_pv; - hid->thindraw_pcb_pv = nogui_thindraw_pcb_pv; - hid->fill_rect = nogui_fill_rect; - hid->calibrate = nogui_calibrate; - hid->shift_is_pressed = nogui_shift_is_pressed; - hid->control_is_pressed = nogui_control_is_pressed; - hid->mod1_is_pressed = nogui_mod1_is_pressed; - hid->get_coords = nogui_get_coords; - hid->set_crosshair = nogui_set_crosshair; - hid->add_timer = nogui_add_timer; - hid->stop_timer = nogui_stop_timer; - hid->watch_file = nogui_watch_file; - hid->unwatch_file = nogui_unwatch_file; - hid->add_block_hook = nogui_add_block_hook; - hid->stop_block_hook = nogui_stop_block_hook; - hid->log = nogui_log; - hid->logv = nogui_logv; - hid->confirm_dialog = nogui_confirm_dialog; - hid->close_confirm_dialog = nogui_close_confirm_dialog; - hid->report_dialog = nogui_report_dialog; - hid->prompt_for = nogui_prompt_for; - hid->fileselect = nogui_fileselect; - hid->attribute_dialog = nogui_attribute_dialog; - hid->show_item = nogui_show_item; - hid->beep = nogui_beep; - hid->progress = nogui_progress; - hid->request_debug_draw = nogui_request_debug_draw; - hid->flush_debug_draw = nogui_flush_debug_draw; - hid->finish_debug_draw = nogui_finish_debug_draw; - hid->create_menu = nogui_create_menu; + hid->get_export_options = nogui_get_export_options; + hid->do_export = nogui_do_export; + hid->parse_arguments = nogui_parse_arguments; + hid->invalidate_lr = nogui_invalidate_lr; + hid->invalidate_all = nogui_invalidate_all; + hid->set_layer = nogui_set_layer; + hid->end_layer = nogui_end_layer; + hid->make_gc = nogui_make_gc; + hid->destroy_gc = nogui_destroy_gc; + hid->use_mask = nogui_use_mask; + hid->set_color = nogui_set_color; + hid->set_line_cap = nogui_set_line_cap; + hid->set_line_width = nogui_set_line_width; + hid->set_draw_xor = nogui_set_draw_xor; + hid->set_draw_faded = nogui_set_draw_faded; + hid->draw_line = nogui_draw_line; + hid->draw_arc = nogui_draw_arc; + hid->draw_rect = nogui_draw_rect; + hid->fill_circle = nogui_fill_circle; + hid->fill_polygon = nogui_fill_polygon; + hid->fill_pcb_polygon = nogui_fill_pcb_polygon; + hid->fill_pcb_pad = nogui_fill_pcb_pad; + hid->thindraw_pcb_pad = nogui_thindraw_pcb_pad; + hid->fill_pcb_pv = nogui_fill_pcb_pv; + hid->thindraw_pcb_pv = nogui_thindraw_pcb_pv; + hid->fill_rect = nogui_fill_rect; + hid->calibrate = nogui_calibrate; + hid->shift_is_pressed = nogui_shift_is_pressed; + hid->control_is_pressed = nogui_control_is_pressed; + hid->mod1_is_pressed = nogui_mod1_is_pressed; + hid->get_coords = nogui_get_coords; + hid->set_crosshair = nogui_set_crosshair; + hid->add_timer = nogui_add_timer; + hid->stop_timer = nogui_stop_timer; + hid->watch_file = nogui_watch_file; + hid->unwatch_file = nogui_unwatch_file; + hid->add_block_hook = nogui_add_block_hook; + hid->stop_block_hook = nogui_stop_block_hook; + hid->log = nogui_log; + hid->logv = nogui_logv; + hid->confirm_dialog = nogui_confirm_dialog; + hid->close_confirm_dialog = nogui_close_confirm_dialog; + hid->report_dialog = nogui_report_dialog; + hid->prompt_for = nogui_prompt_for; + hid->fileselect = nogui_fileselect; + hid->attribute_dialog = nogui_attribute_dialog; + hid->show_item = nogui_show_item; + hid->beep = nogui_beep; + hid->progress = nogui_progress; + hid->request_debug_draw = nogui_request_debug_draw; + hid->flush_debug_draw = nogui_flush_debug_draw; + hid->finish_debug_draw = nogui_finish_debug_draw; + hid->create_menu = nogui_create_menu; } static HID nogui_hid; -HID * -hid_nogui_get_hid (void) +HID *hid_nogui_get_hid(void) { - memset (&nogui_hid, 0, sizeof (HID)); + memset(&nogui_hid, 0, sizeof(HID)); - nogui_hid.struct_size = sizeof (HID); - nogui_hid.name = "nogui"; - nogui_hid.description = "Default GUI when no other GUI is present. " - "Does nothing."; + nogui_hid.struct_size = sizeof(HID); + nogui_hid.name = "nogui"; + nogui_hid.description = "Default GUI when no other GUI is present. " "Does nothing."; - common_nogui_init (&nogui_hid); + common_nogui_init(&nogui_hid); - return &nogui_hid; + return &nogui_hid; } Index: trunk/src/hid/common/hidnogui.h =================================================================== --- trunk/src/hid/common/hidnogui.h (revision 1021) +++ trunk/src/hid/common/hidnogui.h (revision 1022) @@ -1,7 +1,7 @@ #ifndef PCB_HID_COMMON_HIDNOGUI_H #define PCB_HID_COMMON_HIDNOGUI_H -void common_nogui_init (HID *hid); -HID *hid_nogui_get_hid (void); +void common_nogui_init(HID * hid); +HID *hid_nogui_get_hid(void); #endif Index: trunk/src/hid/gcode/auxiliary.h =================================================================== --- trunk/src/hid/gcode/auxiliary.h (revision 1021) +++ trunk/src/hid/gcode/auxiliary.h (revision 1022) @@ -15,10 +15,9 @@ #include "potracelib.h" -struct point_s -{ - long x; - long y; +struct point_s { + long x; + long y; }; typedef struct point_s point_t; @@ -25,24 +24,22 @@ typedef potrace_dpoint_t dpoint_t; /* convert point_t to dpoint_t */ -static inline dpoint_t -dpoint (point_t p) +static inline dpoint_t dpoint(point_t p) { - dpoint_t res; - res.x = p.x; - res.y = p.y; - return res; + dpoint_t res; + res.x = p.x; + res.y = p.y; + return res; } /* range over the straight line segment [a,b] when lambda ranges over [0,1] */ -static inline dpoint_t -interval (double lambda, dpoint_t a, dpoint_t b) +static inline dpoint_t interval(double lambda, dpoint_t a, dpoint_t b) { - dpoint_t res; + dpoint_t res; - res.x = a.x + lambda * (b.x - a.x); - res.y = a.y + lambda * (b.y - a.y); - return res; + res.x = a.x + lambda * (b.x - a.x); + res.y = a.y + lambda * (b.y - a.y); + return res; } /* ---------------------------------------------------------------------- */ @@ -56,16 +53,14 @@ /* integer arithmetic */ -static inline int -mod (int a, int n) +static inline int mod(int a, int n) { - return a >= n ? a % n : a >= 0 ? a : n - 1 - (-1 - a) % n; + return a >= n ? a % n : a >= 0 ? a : n - 1 - (-1 - a) % n; } -static inline int -floordiv (int a, int n) +static inline int floordiv(int a, int n) { - return a >= 0 ? a / n : -1 - (-1 - a) / n; + return a >= 0 ? a / n : -1 - (-1 - a) / n; } /* Note: the following work for integers and other numeric types. */ Index: trunk/src/hid/gcode/bitmap.h =================================================================== --- trunk/src/hid/gcode/bitmap.h (revision 1021) +++ trunk/src/hid/gcode/bitmap.h (revision 1022) @@ -46,69 +46,59 @@ #define BM_PUT(bm, x, y, b) (bm_safe(bm, x, y) ? BM_UPUT(bm, x, y, b) : 0) /* free the given bitmap. Leaves errno untouched. */ -static inline void -bm_free (potrace_bitmap_t * bm) +static inline void bm_free(potrace_bitmap_t * bm) { - if (bm) - { - free (bm->map); - } - free (bm); + if (bm) { + free(bm->map); + } + free(bm); } /* return new un-initialized bitmap. NULL with errno on error */ -static inline potrace_bitmap_t * -bm_new (int w, int h) +static inline potrace_bitmap_t *bm_new(int w, int h) { - potrace_bitmap_t *bm; - int dy = (w + BM_WORDBITS - 1) / BM_WORDBITS; + potrace_bitmap_t *bm; + int dy = (w + BM_WORDBITS - 1) / BM_WORDBITS; - bm = (potrace_bitmap_t *) malloc (sizeof (potrace_bitmap_t)); - if (!bm) - { - return NULL; - } - bm->w = w; - bm->h = h; - bm->dy = dy; - bm->map = (potrace_word *) malloc (dy * h * BM_WORDSIZE); - if (!bm->map) - { - free (bm); - return NULL; - } - return bm; + bm = (potrace_bitmap_t *) malloc(sizeof(potrace_bitmap_t)); + if (!bm) { + return NULL; + } + bm->w = w; + bm->h = h; + bm->dy = dy; + bm->map = (potrace_word *) malloc(dy * h * BM_WORDSIZE); + if (!bm->map) { + free(bm); + return NULL; + } + return bm; } /* clear the given bitmap. Set all bits to c. */ -static inline void -bm_clear (potrace_bitmap_t * bm, int c) +static inline void bm_clear(potrace_bitmap_t * bm, int c) { - memset (bm->map, c ? -1 : 0, bm->dy * bm->h * BM_WORDSIZE); + memset(bm->map, c ? -1 : 0, bm->dy * bm->h * BM_WORDSIZE); } /* duplicate the given bitmap. Return NULL on error with errno set. */ -static inline potrace_bitmap_t * -bm_dup (const potrace_bitmap_t * bm) +static inline potrace_bitmap_t *bm_dup(const potrace_bitmap_t * bm) { - potrace_bitmap_t *bm1 = bm_new (bm->w, bm->h); - if (!bm1) - { - return NULL; - } - memcpy (bm1->map, bm->map, bm->dy * bm->h * BM_WORDSIZE); - return bm1; + potrace_bitmap_t *bm1 = bm_new(bm->w, bm->h); + if (!bm1) { + return NULL; + } + memcpy(bm1->map, bm->map, bm->dy * bm->h * BM_WORDSIZE); + return bm1; } /* invert the given bitmap. */ -static inline void -bm_invert (potrace_bitmap_t * bm) +static inline void bm_invert(potrace_bitmap_t * bm) { - int i; - for (i = 0; i < bm->dy * bm->h; i++) - { - bm->map[i] ^= BM_ALLBITS; - } + int i; + for (i = 0; i < bm->dy * bm->h; i++) { + bm->map[i] ^= BM_ALLBITS; + } } #endif /* BITMAP_H */ Index: trunk/src/hid/gcode/curve.c =================================================================== --- trunk/src/hid/gcode/curve.c (revision 1021) +++ trunk/src/hid/gcode/curve.c (revision 1022) @@ -19,68 +19,61 @@ /* ---------------------------------------------------------------------- */ /* allocate and free path objects */ -path_t * -path_new (void) +path_t *path_new(void) { - path_t *p = NULL; - privpath_t *priv = NULL; + path_t *p = NULL; + privpath_t *priv = NULL; - SAFE_MALLOC (p, 1, path_t); - memset (p, 0, sizeof (path_t)); - SAFE_MALLOC (priv, 1, privpath_t); - memset (priv, 0, sizeof (privpath_t)); - p->priv = priv; - return p; + SAFE_MALLOC(p, 1, path_t); + memset(p, 0, sizeof(path_t)); + SAFE_MALLOC(priv, 1, privpath_t); + memset(priv, 0, sizeof(privpath_t)); + p->priv = priv; + return p; malloc_error: - free (p); - free (priv); - return NULL; + free(p); + free(priv); + return NULL; } /* free the members of the given curve structure. Leave errno unchanged. */ -static void -privcurve_free_members (privcurve_t * curve) +static void privcurve_free_members(privcurve_t * curve) { - free (curve->tag); - free (curve->c); - free (curve->vertex); - free (curve->alpha); - free (curve->alpha0); - free (curve->beta); + free(curve->tag); + free(curve->c); + free(curve->vertex); + free(curve->alpha); + free(curve->alpha0); + free(curve->beta); } /* free a path. Leave errno untouched. */ -void -path_free (path_t * p) +void path_free(path_t * p) { - if (p) - { - if (p->priv) - { - free (p->priv->pt); - free (p->priv->lon); - free (p->priv->sums); - free (p->priv->po); - privcurve_free_members (&p->priv->curve); - privcurve_free_members (&p->priv->ocurve); + if (p) { + if (p->priv) { + free(p->priv->pt); + free(p->priv->lon); + free(p->priv->sums); + free(p->priv->po); + privcurve_free_members(&p->priv->curve); + privcurve_free_members(&p->priv->ocurve); + } + free(p->priv); + /* do not free p->fcurve ! */ } - free (p->priv); - /* do not free p->fcurve ! */ - } - free (p); + free(p); } /* free a pathlist, leaving errno untouched. */ -void -pathlist_free (path_t * plist) +void pathlist_free(path_t * plist) { - path_t *p; + path_t *p; - list_forall_unlink (p, plist) - { - path_free (p); - } + list_forall_unlink(p, plist) { + path_free(p); + } } /* ---------------------------------------------------------------------- */ @@ -90,34 +83,32 @@ /* initialize the members of the given curve structure to size m. Return 0 on success, 1 on error with errno set. */ -int -privcurve_init (privcurve_t * curve, int n) +int privcurve_init(privcurve_t * curve, int n) { - memset (curve, 0, sizeof (privcurve_t)); - curve->n = n; - SAFE_MALLOC (curve->tag, n, int); - SAFE_MALLOC (curve->c, n, dpoint3_t); - SAFE_MALLOC (curve->vertex, n, dpoint_t); - SAFE_MALLOC (curve->alpha, n, double); - SAFE_MALLOC (curve->alpha0, n, double); - SAFE_MALLOC (curve->beta, n, double); - return 0; + memset(curve, 0, sizeof(privcurve_t)); + curve->n = n; + SAFE_MALLOC(curve->tag, n, int); + SAFE_MALLOC(curve->c, n, dpoint3_t); + SAFE_MALLOC(curve->vertex, n, dpoint_t); + SAFE_MALLOC(curve->alpha, n, double); + SAFE_MALLOC(curve->alpha0, n, double); + SAFE_MALLOC(curve->beta, n, double); + return 0; malloc_error: - free (curve->tag); - free (curve->c); - free (curve->vertex); - free (curve->alpha); - free (curve->alpha0); - free (curve->beta); - return 1; + free(curve->tag); + free(curve->c); + free(curve->vertex); + free(curve->alpha); + free(curve->alpha0); + free(curve->beta); + return 1; } /* copy private to public curve structure */ -void -privcurve_to_curve (privcurve_t * pc, potrace_curve_t * c) +void privcurve_to_curve(privcurve_t * pc, potrace_curve_t * c) { - c->n = pc->n; - c->tag = pc->tag; - c->c = pc->c; + c->n = pc->n; + c->tag = pc->tag; + c->c = pc->c; } Index: trunk/src/hid/gcode/curve.h =================================================================== --- trunk/src/hid/gcode/curve.h (revision 1021) +++ trunk/src/hid/gcode/curve.h (revision 1022) @@ -15,30 +15,28 @@ Beta is so that (.beta[i])[.vertex[i],.vertex[i+1]] = .c[i][2]. */ -struct privcurve_s -{ - int n; /* number of segments */ - int *tag; /* tag[n]: POTRACE_CORNER or POTRACE_CURVETO */ - dpoint_t (*c)[3]; /* c[n][i]: control points. - c[n][0] is unused for tag[n]=POTRACE_CORNER */ - /* the remainder of this structure is special to privcurve, and is - used in EPS debug output and special EPS "short coding". These - fields are valid only if "alphacurve" is set. */ - int alphacurve; /* have the following fields been initialized? */ - dpoint_t *vertex; /* for POTRACE_CORNER, this equals c[1] */ - double *alpha; /* only for POTRACE_CURVETO */ - double *alpha0; /* "uncropped" alpha parameter - for debug output only */ - double *beta; +struct privcurve_s { + int n; /* number of segments */ + int *tag; /* tag[n]: POTRACE_CORNER or POTRACE_CURVETO */ + dpoint_t(*c)[3]; /* c[n][i]: control points. + c[n][0] is unused for tag[n]=POTRACE_CORNER */ + /* the remainder of this structure is special to privcurve, and is + used in EPS debug output and special EPS "short coding". These + fields are valid only if "alphacurve" is set. */ + int alphacurve; /* have the following fields been initialized? */ + dpoint_t *vertex; /* for POTRACE_CORNER, this equals c[1] */ + double *alpha; /* only for POTRACE_CURVETO */ + double *alpha0; /* "uncropped" alpha parameter - for debug output only */ + double *beta; }; typedef struct privcurve_s privcurve_t; -struct sums_s -{ - double x; - double y; - double x2; - double xy; - double y2; +struct sums_s { + double x; + double y; + double x2; + double xy; + double y2; }; typedef struct sums_s sums_t; @@ -47,22 +45,21 @@ Potrace algorithm. Backends only need to read the fcurve and fm fields of this data structure, but debugging backends may read other fields. */ -struct potrace_privpath_s -{ - int len; - point_t *pt; /* pt[len]: path as extracted from bitmap */ - int *lon; /* lon[len]: (i,lon[i]) = longest straight line from i */ +struct potrace_privpath_s { + int len; + point_t *pt; /* pt[len]: path as extracted from bitmap */ + int *lon; /* lon[len]: (i,lon[i]) = longest straight line from i */ - int x0, y0; /* origin for sums */ - sums_t *sums; /* sums[len+1]: cache for fast summing */ + int x0, y0; /* origin for sums */ + sums_t *sums; /* sums[len+1]: cache for fast summing */ - int m; /* length of optimal polygon */ - int *po; /* po[m]: optimal polygon */ + int m; /* length of optimal polygon */ + int *po; /* po[m]: optimal polygon */ - privcurve_t curve; /* curve[m]: array of curve elements */ - privcurve_t ocurve; /* ocurve[om]: array of curve elements */ - privcurve_t *fcurve; /* final curve: this points to either curve or - ocurve. Do not free this separately. */ + privcurve_t curve; /* curve[m]: array of curve elements */ + privcurve_t ocurve; /* ocurve[om]: array of curve elements */ + privcurve_t *fcurve; /* final curve: this points to either curve or + ocurve. Do not free this separately. */ }; typedef struct potrace_privpath_s potrace_privpath_t; @@ -70,10 +67,10 @@ typedef potrace_privpath_t privpath_t; typedef potrace_path_t path_t; -path_t *path_new (void); -void path_free (path_t * p); -void pathlist_free (path_t * plist); -int privcurve_init (privcurve_t * curve, int n); -void privcurve_to_curve (privcurve_t * pc, potrace_curve_t * c); +path_t *path_new(void); +void path_free(path_t * p); +void pathlist_free(path_t * plist); +int privcurve_init(privcurve_t * curve, int n); +void privcurve_to_curve(privcurve_t * pc, potrace_curve_t * c); #endif /* CURVE_H */ Index: trunk/src/hid/gcode/decompose.c =================================================================== --- trunk/src/hid/gcode/decompose.c (revision 1021) +++ trunk/src/hid/gcode/decompose.c (revision 1022) @@ -21,44 +21,37 @@ /* auxiliary bitmap manipulations */ /* set the excess padding to 0 */ -static void -bm_clearexcess (potrace_bitmap_t * bm) +static void bm_clearexcess(potrace_bitmap_t * bm) { - potrace_word mask; - int y; + potrace_word mask; + int y; - if (bm->w % BM_WORDBITS != 0) - { - mask = BM_ALLBITS << (BM_WORDBITS - (bm->w % BM_WORDBITS)); - for (y = 0; y < bm->h; y++) - { - *bm_index (bm, bm->w, y) &= mask; + if (bm->w % BM_WORDBITS != 0) { + mask = BM_ALLBITS << (BM_WORDBITS - (bm->w % BM_WORDBITS)); + for (y = 0; y < bm->h; y++) { + *bm_index(bm, bm->w, y) &= mask; + } } - } } -struct bbox_s -{ - int x0, x1, y0, y1; /* bounding box */ +struct bbox_s { + int x0, x1, y0, y1; /* bounding box */ }; typedef struct bbox_s bbox_t; /* clear the bm, assuming the bounding box is set correctly (faster than clearing the whole bitmap) */ -static void -clear_bm_with_bbox (potrace_bitmap_t * bm, bbox_t * bbox) +static void clear_bm_with_bbox(potrace_bitmap_t * bm, bbox_t * bbox) { - int imin = (bbox->x0 / BM_WORDBITS); - int imax = ((bbox->x1 + BM_WORDBITS - 1) / BM_WORDBITS); - int i, y; + int imin = (bbox->x0 / BM_WORDBITS); + int imax = ((bbox->x1 + BM_WORDBITS - 1) / BM_WORDBITS); + int i, y; - for (y = bbox->y0; y < bbox->y1; y++) - { - for (i = imin; i < imax; i++) - { - bm_scanline (bm, y)[i] = 0; + for (y = bbox->y0; y < bbox->y1; y++) { + for (i = imin; i < imax; i++) { + bm_scanline(bm, y)[i] = 0; + } } - } } /* ---------------------------------------------------------------------- */ @@ -65,62 +58,54 @@ /* auxiliary functions */ /* deterministically and efficiently hash (x,y) into a pseudo-random bit */ -static inline int -detrand (int x, int y) +static inline int detrand(int x, int y) { - unsigned int z; - static const unsigned char t[256] = { - /* non-linear sequence: constant term of inverse in GF(8), - mod x^8+x^4+x^3+x+1 */ - 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, - 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, - 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, - 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, - 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, - 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, - 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, - 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, - 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, - 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, - 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - }; + unsigned int z; + static const unsigned char t[256] = { + /* non-linear sequence: constant term of inverse in GF(8), + mod x^8+x^4+x^3+x+1 */ + 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, + 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, + 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, + 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, + 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, + 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, + 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, + 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, + 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + }; - /* 0x04b3e375 and 0x05a8ef93 are chosen to contain every possible - 5-bit sequence */ - z = ((0x04b3e375 * x) ^ y) * 0x05a8ef93; - z = - t[z & 0xff] ^ t[(z >> 8) & 0xff] ^ t[(z >> 16) & 0xff] ^ t[(z >> 24) & - 0xff]; - return z & 1; + /* 0x04b3e375 and 0x05a8ef93 are chosen to contain every possible + 5-bit sequence */ + z = ((0x04b3e375 * x) ^ y) * 0x05a8ef93; + z = t[z & 0xff] ^ t[(z >> 8) & 0xff] ^ t[(z >> 16) & 0xff] ^ t[(z >> 24) & 0xff]; + return z & 1; } /* return the "majority" value of bitmap bm at intersection (x,y). We assume that the bitmap is balanced at "radius" 1. */ -static int -majority (potrace_bitmap_t * bm, int x, int y) +static int majority(potrace_bitmap_t * bm, int x, int y) { - int i, a, ct; + int i, a, ct; - for (i = 2; i < 5; i++) - { /* check at "radius" i */ - ct = 0; - for (a = -i + 1; a <= i - 1; a++) - { - ct += BM_GET (bm, x + a, y + i - 1) ? 1 : -1; - ct += BM_GET (bm, x + i - 1, y + a - 1) ? 1 : -1; - ct += BM_GET (bm, x + a - 1, y - i) ? 1 : -1; - ct += BM_GET (bm, x - i, y + a) ? 1 : -1; + for (i = 2; i < 5; i++) { /* check at "radius" i */ + ct = 0; + for (a = -i + 1; a <= i - 1; a++) { + ct += BM_GET(bm, x + a, y + i - 1) ? 1 : -1; + ct += BM_GET(bm, x + i - 1, y + a - 1) ? 1 : -1; + ct += BM_GET(bm, x + a - 1, y - i) ? 1 : -1; + ct += BM_GET(bm, x - i, y + a) ? 1 : -1; + } + if (ct > 0) { + return 1; + } + else if (ct < 0) { + return 0; + } } - if (ct > 0) - { - return 1; - } - else if (ct < 0) - { - return 0; - } - } - return 0; + return 0; } /* ---------------------------------------------------------------------- */ @@ -128,33 +113,27 @@ /* efficiently invert bits [x,infty) and [xa,infty) in line y. Here xa must be a multiple of BM_WORDBITS. */ -static void -xor_to_ref (potrace_bitmap_t * bm, int x, int y, int xa) +static void xor_to_ref(potrace_bitmap_t * bm, int x, int y, int xa) { - int xhi = x & -BM_WORDBITS; - int xlo = x & (BM_WORDBITS - 1); /* = x % BM_WORDBITS */ - int i; + int xhi = x & -BM_WORDBITS; + int xlo = x & (BM_WORDBITS - 1); /* = x % BM_WORDBITS */ + int i; - if (xhi < xa) - { - for (i = xhi; i < xa; i += BM_WORDBITS) - { - *bm_index (bm, i, y) ^= BM_ALLBITS; + if (xhi < xa) { + for (i = xhi; i < xa; i += BM_WORDBITS) { + *bm_index(bm, i, y) ^= BM_ALLBITS; + } } - } - else - { - for (i = xa; i < xhi; i += BM_WORDBITS) - { - *bm_index (bm, i, y) ^= BM_ALLBITS; + else { + for (i = xa; i < xhi; i += BM_WORDBITS) { + *bm_index(bm, i, y) ^= BM_ALLBITS; + } } - } - /* note: the following "if" is needed because x86 treats a<priv->len <= 0) - { /* a path of length 0 is silly, but legal */ - return; - } + if (p->priv->len <= 0) { /* a path of length 0 is silly, but legal */ + return; + } - y1 = p->priv->pt[p->priv->len - 1].y; + y1 = p->priv->pt[p->priv->len - 1].y; - xa = p->priv->pt[0].x & -BM_WORDBITS; - for (k = 0; k < p->priv->len; k++) - { - x = p->priv->pt[k].x; - y = p->priv->pt[k].y; + xa = p->priv->pt[0].x & -BM_WORDBITS; + for (k = 0; k < p->priv->len; k++) { + x = p->priv->pt[k].x; + y = p->priv->pt[k].y; - if (y != y1) - { - /* efficiently invert the rectangle [x,xa] x [y,y1] */ - xor_to_ref (bm, x, min (y, y1), xa); - y1 = y; + if (y != y1) { + /* efficiently invert the rectangle [x,xa] x [y,y1] */ + xor_to_ref(bm, x, min(y, y1), xa); + y1 = y; + } } - } } /* Find the bounding box of a given path. Path is assumed to be of non-zero length. */ -static void -setbbox_path (bbox_t * bbox, path_t * p) +static void setbbox_path(bbox_t * bbox, path_t * p) { - int x, y; - int k; + int x, y; + int k; - bbox->y0 = INT_MAX; - bbox->y1 = 0; - bbox->x0 = INT_MAX; - bbox->x1 = 0; + bbox->y0 = INT_MAX; + bbox->y1 = 0; + bbox->x0 = INT_MAX; + bbox->x1 = 0; - for (k = 0; k < p->priv->len; k++) - { - x = p->priv->pt[k].x; - y = p->priv->pt[k].y; + for (k = 0; k < p->priv->len; k++) { + x = p->priv->pt[k].x; + y = p->priv->pt[k].y; - if (x < bbox->x0) - { - bbox->x0 = x; + if (x < bbox->x0) { + bbox->x0 = x; + } + if (x > bbox->x1) { + bbox->x1 = x; + } + if (y < bbox->y0) { + bbox->y0 = y; + } + if (y > bbox->y1) { + bbox->y1 = y; + } } - if (x > bbox->x1) - { - bbox->x1 = x; - } - if (y < bbox->y0) - { - bbox->y0 = y; - } - if (y > bbox->y1) - { - bbox->y1 = y; - } - } } /* compute a path in the given pixmap, separating black from white. @@ -235,109 +204,95 @@ new path_t object, or NULL on error (note that a legitimate path cannot have length 0). Sign is required for correct interpretation of turnpolicies. */ -static path_t * -findpath (potrace_bitmap_t * bm, int x0, int y0, int sign, int turnpolicy) +static path_t *findpath(potrace_bitmap_t * bm, int x0, int y0, int sign, int turnpolicy) { - int x, y, dirx, diry, len, size, area; - int c, d, tmp; - point_t *pt, *pt1; - path_t *p = NULL; + int x, y, dirx, diry, len, size, area; + int c, d, tmp; + point_t *pt, *pt1; + path_t *p = NULL; - x = x0; - y = y0; - dirx = 0; - diry = -1; + x = x0; + y = y0; + dirx = 0; + diry = -1; - len = size = 0; - pt = NULL; - area = 0; + len = size = 0; + pt = NULL; + area = 0; - while (1) - { - /* add point to path */ - if (len >= size) - { - size += 100; - size = (int) (1.3 * size); - pt1 = (point_t *) realloc (pt, size * sizeof (point_t)); - if (!pt1) - { - goto error; - } - pt = pt1; - } - pt[len].x = x; - pt[len].y = y; - len++; + while (1) { + /* add point to path */ + if (len >= size) { + size += 100; + size = (int) (1.3 * size); + pt1 = (point_t *) realloc(pt, size * sizeof(point_t)); + if (!pt1) { + goto error; + } + pt = pt1; + } + pt[len].x = x; + pt[len].y = y; + len++; - /* move to next point */ - x += dirx; - y += diry; - area += x * diry; + /* move to next point */ + x += dirx; + y += diry; + area += x * diry; - /* path complete? */ - if (x == x0 && y == y0) - { - break; - } + /* path complete? */ + if (x == x0 && y == y0) { + break; + } - /* determine next direction */ - c = BM_GET (bm, x + (dirx + diry - 1) / 2, y + (diry - dirx - 1) / 2); - d = BM_GET (bm, x + (dirx - diry - 1) / 2, y + (diry + dirx - 1) / 2); + /* determine next direction */ + c = BM_GET(bm, x + (dirx + diry - 1) / 2, y + (diry - dirx - 1) / 2); + d = BM_GET(bm, x + (dirx - diry - 1) / 2, y + (diry + dirx - 1) / 2); - if (c && !d) - { /* ambiguous turn */ - if (turnpolicy == POTRACE_TURNPOLICY_RIGHT - || (turnpolicy == POTRACE_TURNPOLICY_BLACK && sign == '+') - || (turnpolicy == POTRACE_TURNPOLICY_WHITE && sign == '-') - || (turnpolicy == POTRACE_TURNPOLICY_RANDOM && detrand (x, y)) - || (turnpolicy == POTRACE_TURNPOLICY_MAJORITY - && majority (bm, x, y)) - || (turnpolicy == POTRACE_TURNPOLICY_MINORITY - && !majority (bm, x, y))) - { - tmp = dirx; /* right turn */ - dirx = diry; - diry = -tmp; - } - else - { - tmp = dirx; /* left turn */ - dirx = -diry; - diry = tmp; - } + if (c && !d) { /* ambiguous turn */ + if (turnpolicy == POTRACE_TURNPOLICY_RIGHT || (turnpolicy == POTRACE_TURNPOLICY_BLACK && sign == '+') + || (turnpolicy == POTRACE_TURNPOLICY_WHITE && sign == '-') + || (turnpolicy == POTRACE_TURNPOLICY_RANDOM && detrand(x, y)) + || (turnpolicy == POTRACE_TURNPOLICY_MAJORITY && majority(bm, x, y)) + || (turnpolicy == POTRACE_TURNPOLICY_MINORITY && !majority(bm, x, y))) { + tmp = dirx; /* right turn */ + dirx = diry; + diry = -tmp; + } + else { + tmp = dirx; /* left turn */ + dirx = -diry; + diry = tmp; + } + } + else if (c) { /* right turn */ + tmp = dirx; + dirx = diry; + diry = -tmp; + } + else if (!d) { /* left turn */ + tmp = dirx; + dirx = -diry; + diry = tmp; + } + } /* while this path */ + + /* allocate new path object */ + p = path_new(); + if (!p) { + goto error; } - else if (c) - { /* right turn */ - tmp = dirx; - dirx = diry; - diry = -tmp; - } - else if (!d) - { /* left turn */ - tmp = dirx; - dirx = -diry; - diry = tmp; - } - } /* while this path */ - /* allocate new path object */ - p = path_new (); - if (!p) - { - goto error; - } + p->priv->pt = pt; + p->priv->len = len; + p->area = area; + p->sign = sign; - p->priv->pt = pt; - p->priv->len = len; - p->area = area; - p->sign = sign; + return p; - return p; - error: - free (pt); - return NULL; + free(pt); + return NULL; } /* Give a tree structure to the given path list, based on "insideness" @@ -356,137 +311,122 @@ and will be used as scratch space. Return 0 on success or -1 on error with errno set. */ -static void -pathlist_to_tree (path_t * plist, potrace_bitmap_t * bm) +static void pathlist_to_tree(path_t * plist, potrace_bitmap_t * bm) { - path_t *p, *p1; - path_t *heap, *heap1; - path_t *cur; - path_t *head; - path_t **hook, **hook_in, **hook_out; /* for fast appending to linked list */ - bbox_t bbox; + path_t *p, *p1; + path_t *heap, *heap1; + path_t *cur; + path_t *head; + path_t **hook, **hook_in, **hook_out; /* for fast appending to linked list */ + bbox_t bbox; - bm_clear (bm, 0); + bm_clear(bm, 0); - /* save original "next" pointers */ - list_forall (p, plist) - { - p->sibling = p->next; - p->childlist = NULL; - } + /* save original "next" pointers */ + list_forall(p, plist) { + p->sibling = p->next; + p->childlist = NULL; + } - heap = plist; + heap = plist; - /* the heap holds a list of lists of paths. Use "childlist" field - for outer list, "next" field for inner list. Each of the sublists - is to be turned into a tree. This code is messy, but it is - actually fast. Each path is rendered exactly once. We use the - heap to get a tail recursive algorithm: the heap holds a list of - pathlists which still need to be transformed. */ + /* the heap holds a list of lists of paths. Use "childlist" field + for outer list, "next" field for inner list. Each of the sublists + is to be turned into a tree. This code is messy, but it is + actually fast. Each path is rendered exactly once. We use the + heap to get a tail recursive algorithm: the heap holds a list of + pathlists which still need to be transformed. */ - while (heap) - { - /* unlink first sublist */ - cur = heap; - heap = heap->childlist; - cur->childlist = NULL; + while (heap) { + /* unlink first sublist */ + cur = heap; + heap = heap->childlist; + cur->childlist = NULL; - /* unlink first path */ - head = cur; - cur = cur->next; - head->next = NULL; + /* unlink first path */ + head = cur; + cur = cur->next; + head->next = NULL; - /* render path */ - xor_path (bm, head); - setbbox_path (&bbox, head); + /* render path */ + xor_path(bm, head); + setbbox_path(&bbox, head); - /* now do insideness test for each element of cur; append it to - head->childlist if it's inside head, else append it to - head->next. */ - hook_in = &head->childlist; - hook_out = &head->next; - list_forall_unlink (p, cur) - { - if (p->priv->pt[0].y <= bbox.y0) - { - list_insert_beforehook (p, hook_out); - /* append the remainder of the list to hook_out */ - *hook_out = cur; - break; - } - if (BM_GET (bm, p->priv->pt[0].x, p->priv->pt[0].y - 1)) - { - list_insert_beforehook (p, hook_in); - } - else - { - list_insert_beforehook (p, hook_out); - } - } + /* now do insideness test for each element of cur; append it to + head->childlist if it's inside head, else append it to + head->next. */ + hook_in = &head->childlist; + hook_out = &head->next; + list_forall_unlink(p, cur) { + if (p->priv->pt[0].y <= bbox.y0) { + list_insert_beforehook(p, hook_out); + /* append the remainder of the list to hook_out */ + *hook_out = cur; + break; + } + if (BM_GET(bm, p->priv->pt[0].x, p->priv->pt[0].y - 1)) { + list_insert_beforehook(p, hook_in); + } + else { + list_insert_beforehook(p, hook_out); + } + } - /* clear bm */ - clear_bm_with_bbox (bm, &bbox); + /* clear bm */ + clear_bm_with_bbox(bm, &bbox); - /* now schedule head->childlist and head->next for further - processing */ - if (head->next) - { - head->next->childlist = heap; - heap = head->next; + /* now schedule head->childlist and head->next for further + processing */ + if (head->next) { + head->next->childlist = heap; + heap = head->next; + } + if (head->childlist) { + head->childlist->childlist = heap; + heap = head->childlist; + } } - if (head->childlist) - { - head->childlist->childlist = heap; - heap = head->childlist; + + /* copy sibling structure from "next" to "sibling" component */ + p = plist; + while (p) { + p1 = p->sibling; + p->sibling = p->next; + p = p1; } - } - /* copy sibling structure from "next" to "sibling" component */ - p = plist; - while (p) - { - p1 = p->sibling; - p->sibling = p->next; - p = p1; - } + /* reconstruct a new linked list ("next") structure from tree + ("childlist", "sibling") structure. This code is slightly messy, + because we use a heap to make it tail recursive: the heap + contains a list of childlists which still need to be + processed. */ + heap = plist; + if (heap) { + heap->next = NULL; /* heap is a linked list of childlists */ + } + plist = NULL; + hook = &plist; + while (heap) { + heap1 = heap->next; + for (p = heap; p; p = p->sibling) { + /* p is a positive path */ + /* append to linked list */ + list_insert_beforehook(p, hook); - /* reconstruct a new linked list ("next") structure from tree - ("childlist", "sibling") structure. This code is slightly messy, - because we use a heap to make it tail recursive: the heap - contains a list of childlists which still need to be - processed. */ - heap = plist; - if (heap) - { - heap->next = NULL; /* heap is a linked list of childlists */ - } - plist = NULL; - hook = &plist; - while (heap) - { - heap1 = heap->next; - for (p = heap; p; p = p->sibling) - { - /* p is a positive path */ - /* append to linked list */ - list_insert_beforehook (p, hook); - - /* go through its children */ - for (p1 = p->childlist; p1; p1 = p1->sibling) - { - /* append to linked list */ - list_insert_beforehook (p1, hook); - /* append its childlist to heap, if non-empty */ - if (p1->childlist) - { - list_append (path_t, heap1, p1->childlist); + /* go through its children */ + for (p1 = p->childlist; p1; p1 = p1->sibling) { + /* append to linked list */ + list_insert_beforehook(p1, hook); + /* append its childlist to heap, if non-empty */ + if (p1->childlist) { + list_append(path_t, heap1, p1->childlist); + } + } } - } + heap = heap1; } - heap = heap1; - } - return; + return; } /* find the next set pixel in a row <= y. Pixels are searched first @@ -494,31 +434,26 @@ or y=y' and x= 0; y--) - { - for (x = 0; x < bm->w; x += BM_WORDBITS) - { - if (*bm_index (bm, x, y)) - { - while (!BM_GET (bm, x, y)) - { - x++; + for (y = *yp; y >= 0; y--) { + for (x = 0; x < bm->w; x += BM_WORDBITS) { + if (*bm_index(bm, x, y)) { + while (!BM_GET(bm, x, y)) { + x++; + } + /* found */ + *xp = x; + *yp = y; + return 0; + } } - /* found */ - *xp = x; - *yp = y; - return 0; - } } - } - /* not found */ - return 1; + /* not found */ + return 1; } /* Decompose the given bitmap into paths. Returns a linked list of @@ -526,74 +461,65 @@ in. Returns 0 on success with plistp set, or -1 on error with errno set. */ -int -bm_to_pathlist (const potrace_bitmap_t * bm, path_t ** plistp, - const potrace_param_t * param) +int bm_to_pathlist(const potrace_bitmap_t * bm, path_t ** plistp, const potrace_param_t * param) { - int x; - int y; - path_t *p; - path_t *plist = NULL; /* linked list of path objects */ - path_t **hook = &plist; /* used to speed up appending to linked list */ - potrace_bitmap_t *bm1 = NULL; - int sign; + int x; + int y; + path_t *p; + path_t *plist = NULL; /* linked list of path objects */ + path_t **hook = &plist; /* used to speed up appending to linked list */ + potrace_bitmap_t *bm1 = NULL; + int sign; - bm1 = bm_dup (bm); - if (!bm1) - { - goto error; - } + bm1 = bm_dup(bm); + if (!bm1) { + goto error; + } - /* be sure the byte padding on the right is set to 0, as the fast - pixel search below relies on it */ - bm_clearexcess (bm1); + /* be sure the byte padding on the right is set to 0, as the fast + pixel search below relies on it */ + bm_clearexcess(bm1); - /* iterate through components */ - y = bm1->h - 1; - while (findnext (bm1, &x, &y) == 0) - { - /* calculate the sign by looking at the original */ - sign = BM_GET (bm, x, y) ? '+' : '-'; + /* iterate through components */ + y = bm1->h - 1; + while (findnext(bm1, &x, &y) == 0) { + /* calculate the sign by looking at the original */ + sign = BM_GET(bm, x, y) ? '+' : '-'; - /* calculate the path */ - p = findpath (bm1, x, y + 1, sign, param->turnpolicy); - if (p == NULL) - { - goto error; - } + /* calculate the path */ + p = findpath(bm1, x, y + 1, sign, param->turnpolicy); + if (p == NULL) { + goto error; + } - /* update buffered image */ - xor_path (bm1, p); + /* update buffered image */ + xor_path(bm1, p); - /* if it's a turd, eliminate it, else append it to the list */ - if (p->area <= param->turdsize) - { - path_free (p); - } - else - { - list_insert_beforehook (p, hook); - } + /* if it's a turd, eliminate it, else append it to the list */ + if (p->area <= param->turdsize) { + path_free(p); + } + else { + list_insert_beforehook(p, hook); + } - if (bm1->h > 0) - { /* to be sure */ - /*progress_update(1-y/(double)bm1->h, progress);*/ + if (bm1->h > 0) { /* to be sure */ + /*progress_update(1-y/(double)bm1->h, progress); */ + } } - } - pathlist_to_tree (plist, bm1); - bm_free (bm1); - *plistp = plist; + pathlist_to_tree(plist, bm1); + bm_free(bm1); + *plistp = plist; /* progress_update(1.0, progress);*/ - return 0; + return 0; error: - bm_free (bm1); - list_forall_unlink (p, plist) - { - path_free (p); - } - return -1; + bm_free(bm1); + list_forall_unlink(p, plist) { + path_free(p); + } + return -1; } Index: trunk/src/hid/gcode/decompose.h =================================================================== --- trunk/src/hid/gcode/decompose.h (revision 1021) +++ trunk/src/hid/gcode/decompose.h (revision 1022) @@ -10,7 +10,6 @@ #include "potracelib.h" /*#include "progress.h"*/ -int bm_to_pathlist (const potrace_bitmap_t * bm, path_t ** plistp, - const potrace_param_t * param); +int bm_to_pathlist(const potrace_bitmap_t * bm, path_t ** plistp, const potrace_param_t * param); #endif /* DECOMPOSE_H */ Index: trunk/src/hid/gcode/gcode.c =================================================================== --- trunk/src/hid/gcode/gcode.c (revision 1021) +++ trunk/src/hid/gcode/gcode.c (revision 1022) @@ -43,7 +43,7 @@ #include #include "global.h" -#include "error.h" /* Message() */ +#include "error.h" /* Message() */ #include "data.h" #include "misc.h" #include "rats.h" @@ -68,30 +68,28 @@ #endif #define CRASH fprintf(stderr, "HID error: pcb called unimplemented GCODE function %s.\n", __FUNCTION__); abort() -struct color_struct -{ - /* the descriptor used by the gd library */ - int c; +struct color_struct { + /* the descriptor used by the gd library */ + int c; - /* so I can figure out what rgb value c refers to */ - unsigned int r, g, b; + /* so I can figure out what rgb value c refers to */ + unsigned int r, g, b; }; -struct hid_gc_struct -{ - HID *me_pointer; - EndCapStyle cap; - int width; - unsigned char r, g, b; - int erase; - int faded; - struct color_struct *color; - gdImagePtr brush; +struct hid_gc_struct { + HID *me_pointer; + EndCapStyle cap; + int width; + unsigned char r, g, b; + int erase; + int faded; + struct color_struct *color; + gdImagePtr brush; }; static struct color_struct *black = NULL, *white = NULL; static int linewidth = -1; -static gdImagePtr lastbrush = (gdImagePtr)((void *) -1); +static gdImagePtr lastbrush = (gdImagePtr) ((void *) -1); static int lastcolor = -1; /* gd image and file for PNG export */ @@ -124,50 +122,49 @@ static int save_drill = 0; static int n_drill = 0; static int nmax_drill = 0; -struct drill_struct -{ - double x; - double y; +struct drill_struct { + double x; + double y; }; static struct drill_struct *drill = 0; static const char *units[] = { - "mm", - "mil", - "um", - "inch", - NULL + "mm", + "mil", + "um", + "inch", + NULL }; HID_Attribute gcode_attribute_list[] = { - /* other HIDs expect this to be first. */ - {"basename", "File name prefix", - HID_String, 0, 0, {0, 0, 0}, 0, 0}, + /* other HIDs expect this to be first. */ + {"basename", "File name prefix", + HID_String, 0, 0, {0, 0, 0}, 0, 0}, #define HA_basename 0 - {"dpi", "Resolution of intermediate image (pixels/inch)", - HID_Integer, 0, 2000, {600, 0, 0}, 0, 0}, + {"dpi", "Resolution of intermediate image (pixels/inch)", + HID_Integer, 0, 2000, {600, 0, 0}, 0, 0}, #define HA_dpi 1 - {"mill-depth", "Milling depth", - HID_Real, -1000, 1000, {0, 0, -0.05}, 0, 0}, + {"mill-depth", "Milling depth", + HID_Real, -1000, 1000, {0, 0, -0.05}, 0, 0}, #define HA_cutdepth 2 - {"safe-Z", "Safe Z for traverse move", - HID_Real, -1000, 10000, {0, 0, 2}, 0, 0}, + {"safe-Z", "Safe Z for traverse move", + HID_Real, -1000, 10000, {0, 0, 2}, 0, 0}, #define HA_safeZ 3 - {"tool-radius", "Milling tool radius compensation", - HID_Real, 0, 10000, {0, 0, 0.1}, 0, 0}, + {"tool-radius", "Milling tool radius compensation", + HID_Real, 0, 10000, {0, 0, 0.1}, 0, 0}, #define HA_toolradius 4 - {"drill-depth", "Drilling depth", - HID_Real, -10000, 10000, {0, 0, -2}, 0, 0}, + {"drill-depth", "Drilling depth", + HID_Real, -10000, 10000, {0, 0, -2}, 0, 0}, #define HA_drilldepth 5 - {"measurement-unit", "Measurement unit", - HID_Unit, 0, 0, {-1, 0, 0}, units, 0}, + {"measurement-unit", "Measurement unit", + HID_Unit, 0, 0, {-1, 0, 0}, units, 0}, #define HA_unit 6 }; @@ -174,816 +171,688 @@ #define NUM_OPTIONS (sizeof(gcode_attribute_list)/sizeof(gcode_attribute_list[0])) -REGISTER_ATTRIBUTES (gcode_attribute_list) - static HID_Attr_Val gcode_values[NUM_OPTIONS]; +REGISTER_ATTRIBUTES(gcode_attribute_list) + static HID_Attr_Val gcode_values[NUM_OPTIONS]; /* *** Utility funcions **************************************************** */ /* convert from default PCB units to gcode units */ -static int pcb_to_gcode (int pcb) + static int pcb_to_gcode(int pcb) { - return round(COORD_TO_INCH(pcb) * gcode_dpi); + return round(COORD_TO_INCH(pcb) * gcode_dpi); } -static char * -gcode_get_png_name (const char *basename, const char *suffix) +static char *gcode_get_png_name(const char *basename, const char *suffix) { - return g_strdup_printf ("%s.%s.png", basename, suffix); + return g_strdup_printf("%s.%s.png", basename, suffix); } /* Sorts drills in order of distance from the origin */ -struct drill_struct * -sort_drill (struct drill_struct *drill, int n_drill) +struct drill_struct *sort_drill(struct drill_struct *drill, int n_drill) { - int i, j, imin; - double dmin, d; - struct drill_struct p = { 0, 0 }; - struct drill_struct *temp = (struct drill_struct *)malloc (n_drill * sizeof (struct drill_struct)); - for (j = 0; j < n_drill; j++) - { - dmin = 1e20; - imin = 0; - for (i = 0; i < n_drill - j; i++) - { - d = - (drill[i].x - p.x) * (drill[i].x - p.x) + (drill[i].y - - p.y) * (drill[i].y - - p.y); - if (d < dmin) - { - imin = i; - dmin = d; - } + int i, j, imin; + double dmin, d; + struct drill_struct p = { 0, 0 }; + struct drill_struct *temp = (struct drill_struct *) malloc(n_drill * sizeof(struct drill_struct)); + for (j = 0; j < n_drill; j++) { + dmin = 1e20; + imin = 0; + for (i = 0; i < n_drill - j; i++) { + d = (drill[i].x - p.x) * (drill[i].x - p.x) + (drill[i].y - p.y) * (drill[i].y - p.y); + if (d < dmin) { + imin = i; + dmin = d; + } + } + /* printf("j=%d imin=%d dmin=%f p=(%f,%f)\n",j,imin,dmin,p.x,p.y); */ + temp[j] = drill[imin]; + drill[imin] = drill[n_drill - j - 1]; + p = temp[j]; } - /* printf("j=%d imin=%d dmin=%f p=(%f,%f)\n",j,imin,dmin,p.x,p.y); */ - temp[j] = drill[imin]; - drill[imin] = drill[n_drill - j - 1]; - p = temp[j]; - } - free (drill); - return temp; + free(drill); + return temp; } /* *** Main export callback ************************************************ */ -static void -gcode_parse_arguments (int *argc, char ***argv) +static void gcode_parse_arguments(int *argc, char ***argv) { - hid_register_attributes (gcode_attribute_list, - sizeof (gcode_attribute_list) / - sizeof (gcode_attribute_list[0])); - hid_parse_command_line (argc, argv); + hid_register_attributes(gcode_attribute_list, sizeof(gcode_attribute_list) / sizeof(gcode_attribute_list[0])); + hid_parse_command_line(argc, argv); } -static HID_Attribute * -gcode_get_export_options (int *n) +static HID_Attribute *gcode_get_export_options(int *n) { - static char *last_made_filename = 0; - static int last_unit_value = -1; + static char *last_made_filename = 0; + static int last_unit_value = -1; - if (gcode_attribute_list[HA_unit].default_val.int_value == last_unit_value) - { - if (Settings.grid_unit) - gcode_attribute_list[HA_unit].default_val.int_value = Settings.grid_unit->index; - else - gcode_attribute_list[HA_unit].default_val.int_value = get_unit_struct ("mil")->index; - last_unit_value = gcode_attribute_list[HA_unit].default_val.int_value; - } + if (gcode_attribute_list[HA_unit].default_val.int_value == last_unit_value) { + if (Settings.grid_unit) + gcode_attribute_list[HA_unit].default_val.int_value = Settings.grid_unit->index; + else + gcode_attribute_list[HA_unit].default_val.int_value = get_unit_struct("mil")->index; + last_unit_value = gcode_attribute_list[HA_unit].default_val.int_value; + } - if (PCB) - { - derive_default_filename (PCB->Filename, - &gcode_attribute_list[HA_basename], - ".gcode", &last_made_filename); - } - if (n) - { - *n = NUM_OPTIONS; - } - return gcode_attribute_list; + if (PCB) { + derive_default_filename(PCB->Filename, &gcode_attribute_list[HA_basename], ".gcode", &last_made_filename); + } + if (n) { + *n = NUM_OPTIONS; + } + return gcode_attribute_list; } /* Populates gcode_export_group array */ -void -gcode_choose_groups () +void gcode_choose_groups() { - int n, m; - LayerType *layer; + int n, m; + LayerType *layer; - /* Set entire array to 0 (don't export any layer groups by default */ - memset (gcode_export_group, 0, sizeof (gcode_export_group)); + /* Set entire array to 0 (don't export any layer groups by default */ + memset(gcode_export_group, 0, sizeof(gcode_export_group)); - for (n = 0; n < max_copper_layer; n++) - { - layer = &PCB->Data->Layer[n]; + for (n = 0; n < max_copper_layer; n++) { + layer = &PCB->Data->Layer[n]; - if (layer->LineN || layer->TextN || layer->ArcN || layer->PolygonN) - { - /* layer isn't empty */ + if (layer->LineN || layer->TextN || layer->ArcN || layer->PolygonN) { + /* layer isn't empty */ - /* - * is this check necessary? It seems that special - * layers have negative indexes? - */ + /* + * is this check necessary? It seems that special + * layers have negative indexes? + */ - if (SL_TYPE (n) == 0) - { - /* layer is a copper layer */ - m = GetLayerGroupNumberByNumber (n); + if (SL_TYPE(n) == 0) { + /* layer is a copper layer */ + m = GetLayerGroupNumberByNumber(n); - /* the export layer */ - gcode_export_group[m] = 1; - } + /* the export layer */ + gcode_export_group[m] = 1; + } + } } - } } -static void -gcode_alloc_colors () +static void gcode_alloc_colors() { - /* - * Allocate white and black -- the first color allocated becomes the - * background color - */ + /* + * Allocate white and black -- the first color allocated becomes the + * background color + */ - white = (struct color_struct *) malloc (sizeof (*white)); - white->r = white->g = white->b = 255; - white->c = gdImageColorAllocate (gcode_im, white->r, white->g, white->b); + white = (struct color_struct *) malloc(sizeof(*white)); + white->r = white->g = white->b = 255; + white->c = gdImageColorAllocate(gcode_im, white->r, white->g, white->b); - black = (struct color_struct *) malloc (sizeof (*black)); - black->r = black->g = black->b = 0; - black->c = gdImageColorAllocate (gcode_im, black->r, black->g, black->b); + black = (struct color_struct *) malloc(sizeof(*black)); + black->r = black->g = black->b = 0; + black->c = gdImageColorAllocate(gcode_im, black->r, black->g, black->b); } -static void -gcode_start_png (const char *basename, const char *suffix) +static void gcode_start_png(const char *basename, const char *suffix) { - int h, w; - char *buf; + int h, w; + char *buf; - buf = gcode_get_png_name (basename, suffix); + buf = gcode_get_png_name(basename, suffix); - h = pcb_to_gcode (PCB->MaxHeight); - w = pcb_to_gcode (PCB->MaxWidth); + h = pcb_to_gcode(PCB->MaxHeight); + w = pcb_to_gcode(PCB->MaxWidth); - /* Nelma only works with true color images */ - gcode_im = gdImageCreate (w, h); - gcode_f = fopen (buf, "wb"); + /* Nelma only works with true color images */ + gcode_im = gdImageCreate(w, h); + gcode_f = fopen(buf, "wb"); - gcode_alloc_colors (); + gcode_alloc_colors(); - free (buf); + free(buf); } -static void -gcode_finish_png () +static void gcode_finish_png() { #ifdef HAVE_GDIMAGEPNG - gdImagePng (gcode_im, gcode_f); + gdImagePng(gcode_im, gcode_f); #else - Message ("GCODE: PNG not supported by gd. Can't write layer mask.\n"); + Message("GCODE: PNG not supported by gd. Can't write layer mask.\n"); #endif - gdImageDestroy (gcode_im); - fclose (gcode_f); + gdImageDestroy(gcode_im); + fclose(gcode_f); - free (white); - free (black); + free(white); + free(black); - gcode_im = NULL; - gcode_f = NULL; + gcode_im = NULL; + gcode_f = NULL; } -void -gcode_start_png_export () +void gcode_start_png_export() { - BoxType region; + BoxType region; - region.X1 = 0; - region.Y1 = 0; - region.X2 = PCB->MaxWidth; - region.Y2 = PCB->MaxHeight; + region.X1 = 0; + region.Y1 = 0; + region.X2 = PCB->MaxWidth; + region.Y2 = PCB->MaxHeight; - linewidth = -1; - lastbrush = (gdImagePtr)((void *) -1); - lastcolor = -1; + linewidth = -1; + lastbrush = (gdImagePtr) ((void *) -1); + lastcolor = -1; - hid_expose_callback (&gcode_hid, ®ion, 0); + hid_expose_callback(&gcode_hid, ®ion, 0); } -static void -gcode_do_export (HID_Attr_Val * options) +static void gcode_do_export(HID_Attr_Val * options) { - int save_ons[MAX_LAYER + 2]; - int i, idx; - time_t t; - const Unit *unit; - double scale = 0, d = 0; - int r, c, v, p, metric; - char *filename; - path_t *plist = NULL; - potrace_bitmap_t *bm = NULL; - potrace_param_t param_default = { - 2, /* turnsize */ - POTRACE_TURNPOLICY_MINORITY, /* turnpolicy */ - 1.0, /* alphamax */ - 1, /* opticurve */ - 0.2, /* opttolerance */ - { - NULL, /* callback function */ - NULL, /* callback data */ - 0.0, 1.0, /* progress range */ - 0.0, /* granularity */ - }, - }; + int save_ons[MAX_LAYER + 2]; + int i, idx; + time_t t; + const Unit *unit; + double scale = 0, d = 0; + int r, c, v, p, metric; + char *filename; + path_t *plist = NULL; + potrace_bitmap_t *bm = NULL; + potrace_param_t param_default = { + 2, /* turnsize */ + POTRACE_TURNPOLICY_MINORITY, /* turnpolicy */ + 1.0, /* alphamax */ + 1, /* opticurve */ + 0.2, /* opttolerance */ + { + NULL, /* callback function */ + NULL, /* callback data */ + 0.0, 1.0, /* progress range */ + 0.0, /* granularity */ + }, + }; - if (!options) - { - gcode_get_export_options (0); - for (i = 0; i < NUM_OPTIONS; i++) - { - gcode_values[i] = gcode_attribute_list[i].default_val; + if (!options) { + gcode_get_export_options(0); + for (i = 0; i < NUM_OPTIONS; i++) { + gcode_values[i] = gcode_attribute_list[i].default_val; + } + options = gcode_values; } - options = gcode_values; - } - gcode_basename = options[HA_basename].str_value; - if (!gcode_basename) - { - gcode_basename = "pcb-out"; - } - gcode_dpi = options[HA_dpi].int_value; - if (gcode_dpi < 0) - { - fprintf (stderr, "ERROR: dpi may not be < 0\n"); - return; - } - unit = &(get_unit_list() [options[HA_unit].int_value]); - metric = (unit->family == METRIC); - scale = metric ? 1.0 / coord_to_unit (unit, MM_TO_COORD (1.0)) - : 1.0 / coord_to_unit (unit, INCH_TO_COORD (1.0)); + gcode_basename = options[HA_basename].str_value; + if (!gcode_basename) { + gcode_basename = "pcb-out"; + } + gcode_dpi = options[HA_dpi].int_value; + if (gcode_dpi < 0) { + fprintf(stderr, "ERROR: dpi may not be < 0\n"); + return; + } + unit = &(get_unit_list()[options[HA_unit].int_value]); + metric = (unit->family == METRIC); + scale = metric ? 1.0 / coord_to_unit(unit, MM_TO_COORD(1.0)) + : 1.0 / coord_to_unit(unit, INCH_TO_COORD(1.0)); - gcode_cutdepth = options[HA_cutdepth].real_value * scale; - gcode_drilldepth = options[HA_drilldepth].real_value * scale; - gcode_safeZ = options[HA_safeZ].real_value * scale; - gcode_toolradius = metric - ? MM_TO_COORD(options[HA_toolradius].real_value * scale) - : INCH_TO_COORD(options[HA_toolradius].real_value * scale); - gcode_choose_groups (); + gcode_cutdepth = options[HA_cutdepth].real_value * scale; + gcode_drilldepth = options[HA_drilldepth].real_value * scale; + gcode_safeZ = options[HA_safeZ].real_value * scale; + gcode_toolradius = metric ? MM_TO_COORD(options[HA_toolradius].real_value * scale) + : INCH_TO_COORD(options[HA_toolradius].real_value * scale); + gcode_choose_groups(); - for (i = 0; i < MAX_LAYER; i++) - { - if (gcode_export_group[i]) - { + for (i = 0; i < MAX_LAYER; i++) { + if (gcode_export_group[i]) { - gcode_cur_group = i; + gcode_cur_group = i; - /* magic */ - idx = (i >= 0 && i < max_group) ? - PCB->LayerGroups.Entries[i][0] : i; - printf ("idx=%d %s\n", idx, layer_type_to_file_name (idx, FNS_fixed)); - is_solder = - (GetLayerGroupNumberByNumber (idx) == - GetLayerGroupNumberByNumber (solder_silk_layer)) ? 1 : 0; - save_drill = is_solder; /* save drills for one layer only */ - gcode_start_png (gcode_basename, layer_type_to_file_name (idx, FNS_fixed)); - hid_save_and_show_layer_ons (save_ons); - gcode_start_png_export (); - hid_restore_layer_ons (save_ons); + /* magic */ + idx = (i >= 0 && i < max_group) ? PCB->LayerGroups.Entries[i][0] : i; + printf("idx=%d %s\n", idx, layer_type_to_file_name(idx, FNS_fixed)); + is_solder = (GetLayerGroupNumberByNumber(idx) == GetLayerGroupNumberByNumber(solder_silk_layer)) ? 1 : 0; + save_drill = is_solder; /* save drills for one layer only */ + gcode_start_png(gcode_basename, layer_type_to_file_name(idx, FNS_fixed)); + hid_save_and_show_layer_ons(save_ons); + gcode_start_png_export(); + hid_restore_layer_ons(save_ons); /* ***************** gcode conversion *************************** */ /* potrace uses a different kind of bitmap; for simplicity gcode_im is copied to this format */ - bm = bm_new (gdImageSX (gcode_im), gdImageSY (gcode_im)); - filename = (char *)malloc (MAXPATHLEN); - plist = NULL; - if (is_solder) - { /* only for back layer */ - gdImagePtr temp_im = - gdImageCreate (gdImageSX (gcode_im), gdImageSY (gcode_im)); - gdImageCopy (temp_im, gcode_im, 0, 0, 0, 0, - gdImageSX (gcode_im), gdImageSY (gcode_im)); - for (r = 0; r < gdImageSX (gcode_im); r++) - { - for (c = 0; c < gdImageSY (gcode_im); c++) - { - gdImageSetPixel (gcode_im, r, c, - gdImageGetPixel (temp_im, - gdImageSX (gcode_im) - - 1 - r, c)); - } - } - gdImageDestroy (temp_im); - } - sprintf (filename, "%s.%s.cnc", gcode_basename, - layer_type_to_file_name (idx, FNS_fixed)); - for (r = 0; r < gdImageSX (gcode_im); r++) - { - for (c = 0; c < gdImageSY (gcode_im); c++) - { - v = - gdImageGetPixel (gcode_im, r, - gdImageSY (gcode_im) - 1 - c); - p = (gcode_im->red[v] || gcode_im->green[v] - || gcode_im->blue[v]) ? 0 : 0xFFFFFF; - BM_PUT (bm, r, c, p); - } - } - gcode_f2 = fopen (filename, "wb"); - if (!gcode_f2) - { - perror (filename); - return; - } - fprintf (gcode_f2, "(Created by G-code exporter)\n"); - t = time (NULL); - sprintf (filename, "%s", ctime (&t)); - filename[strlen (filename) - 1] = 0; - fprintf (gcode_f2, "( %s )\n", filename); - fprintf (gcode_f2, "(%d dpi)\n", gcode_dpi); - fprintf (gcode_f2, "(Unit: %s)\n", metric ? "mm" : "inch"); - if (metric) - pcb_fprintf (gcode_f2, "(Board size: %.2mmx%.2mm mm)", PCB->MaxWidth, PCB->MaxHeight); - else - pcb_fprintf (gcode_f2, "(Board size: %.2mix%.2mi inches)", PCB->MaxWidth, PCB->MaxHeight); - fprintf (gcode_f2, "#100=%f (safe Z)\n", gcode_safeZ); - fprintf (gcode_f2, "#101=%f (cutting depth)\n", gcode_cutdepth); - fprintf (gcode_f2, "(---------------------------------)\n"); - fprintf (gcode_f2, "G17 G%d G90 G64 P0.003 M3 S3000 M7 F%d\n", - metric ? 21 : 20, metric ? 25 : 1); - fprintf (gcode_f2, "G0 Z#100\n"); - /* extract contour points from image */ - r = bm_to_pathlist (bm, &plist, ¶m_default); - if (r) - { - fprintf (stderr, "ERROR: pathlist function failed\n"); - return; - } - /* generate best polygon and write vertices in g-code format */ - d = - process_path (plist, ¶m_default, bm, gcode_f2, - metric ? 25.4 / gcode_dpi : 1.0 / gcode_dpi); - if (d < 0) - { - fprintf (stderr, "ERROR: path process function failed\n"); - return; - } - if (metric) - fprintf (gcode_f2, "(end, total distance %.2fmm = %.2fin)\n", d, - d * 1 / 25.4); - else - fprintf (gcode_f2, "(end, total distance %.2fmm = %.2fin)\n", - 25.4 * d, d); - fprintf (gcode_f2, "M5 M9 M2\n"); - pathlist_free (plist); - bm_free (bm); - fclose (gcode_f2); - if (save_drill) - { - d = 0; - drill = sort_drill (drill, n_drill); - sprintf (filename, "%s.drill.cnc", gcode_basename); - gcode_f2 = fopen (filename, "wb"); - if (!gcode_f2) - { - perror (filename); - return; - } - fprintf (gcode_f2, "(Created by G-code exporter)\n"); - fprintf (gcode_f2, "(drill file: %d drills)\n", n_drill); - sprintf (filename, "%s", ctime (&t)); - filename[strlen (filename) - 1] = 0; - fprintf (gcode_f2, "( %s )\n", filename); - fprintf (gcode_f2, "(Unit: %s)\n", metric ? "mm" : "inch"); - if (metric) - pcb_fprintf (gcode_f2, "(Board size: %.2mmx%.2mm mm)", PCB->MaxWidth, PCB->MaxHeight); - else - pcb_fprintf (gcode_f2, "(Board size: %.2mix%.2mi inches)", PCB->MaxWidth, PCB->MaxHeight); - fprintf (gcode_f2, "#100=%f (safe Z)\n", gcode_safeZ); - fprintf (gcode_f2, "#101=%f (drill depth)\n", - gcode_drilldepth); - fprintf (gcode_f2, "(---------------------------------)\n"); - fprintf (gcode_f2, "G17 G%d G90 G64 P0.003 M3 S3000 M7 F%d\n", - metric ? 21 : 20, metric ? 25 : 1); + bm = bm_new(gdImageSX(gcode_im), gdImageSY(gcode_im)); + filename = (char *) malloc(MAXPATHLEN); + plist = NULL; + if (is_solder) { /* only for back layer */ + gdImagePtr temp_im = gdImageCreate(gdImageSX(gcode_im), gdImageSY(gcode_im)); + gdImageCopy(temp_im, gcode_im, 0, 0, 0, 0, gdImageSX(gcode_im), gdImageSY(gcode_im)); + for (r = 0; r < gdImageSX(gcode_im); r++) { + for (c = 0; c < gdImageSY(gcode_im); c++) { + gdImageSetPixel(gcode_im, r, c, gdImageGetPixel(temp_im, gdImageSX(gcode_im) - 1 - r, c)); + } + } + gdImageDestroy(temp_im); + } + sprintf(filename, "%s.%s.cnc", gcode_basename, layer_type_to_file_name(idx, FNS_fixed)); + for (r = 0; r < gdImageSX(gcode_im); r++) { + for (c = 0; c < gdImageSY(gcode_im); c++) { + v = gdImageGetPixel(gcode_im, r, gdImageSY(gcode_im) - 1 - c); + p = (gcode_im->red[v] || gcode_im->green[v] + || gcode_im->blue[v]) ? 0 : 0xFFFFFF; + BM_PUT(bm, r, c, p); + } + } + gcode_f2 = fopen(filename, "wb"); + if (!gcode_f2) { + perror(filename); + return; + } + fprintf(gcode_f2, "(Created by G-code exporter)\n"); + t = time(NULL); + sprintf(filename, "%s", ctime(&t)); + filename[strlen(filename) - 1] = 0; + fprintf(gcode_f2, "( %s )\n", filename); + fprintf(gcode_f2, "(%d dpi)\n", gcode_dpi); + fprintf(gcode_f2, "(Unit: %s)\n", metric ? "mm" : "inch"); + if (metric) + pcb_fprintf(gcode_f2, "(Board size: %.2mmx%.2mm mm)", PCB->MaxWidth, PCB->MaxHeight); + else + pcb_fprintf(gcode_f2, "(Board size: %.2mix%.2mi inches)", PCB->MaxWidth, PCB->MaxHeight); + fprintf(gcode_f2, "#100=%f (safe Z)\n", gcode_safeZ); + fprintf(gcode_f2, "#101=%f (cutting depth)\n", gcode_cutdepth); + fprintf(gcode_f2, "(---------------------------------)\n"); + fprintf(gcode_f2, "G17 G%d G90 G64 P0.003 M3 S3000 M7 F%d\n", metric ? 21 : 20, metric ? 25 : 1); + fprintf(gcode_f2, "G0 Z#100\n"); + /* extract contour points from image */ + r = bm_to_pathlist(bm, &plist, ¶m_default); + if (r) { + fprintf(stderr, "ERROR: pathlist function failed\n"); + return; + } + /* generate best polygon and write vertices in g-code format */ + d = process_path(plist, ¶m_default, bm, gcode_f2, metric ? 25.4 / gcode_dpi : 1.0 / gcode_dpi); + if (d < 0) { + fprintf(stderr, "ERROR: path process function failed\n"); + return; + } + if (metric) + fprintf(gcode_f2, "(end, total distance %.2fmm = %.2fin)\n", d, d * 1 / 25.4); + else + fprintf(gcode_f2, "(end, total distance %.2fmm = %.2fin)\n", 25.4 * d, d); + fprintf(gcode_f2, "M5 M9 M2\n"); + pathlist_free(plist); + bm_free(bm); + fclose(gcode_f2); + if (save_drill) { + d = 0; + drill = sort_drill(drill, n_drill); + sprintf(filename, "%s.drill.cnc", gcode_basename); + gcode_f2 = fopen(filename, "wb"); + if (!gcode_f2) { + perror(filename); + return; + } + fprintf(gcode_f2, "(Created by G-code exporter)\n"); + fprintf(gcode_f2, "(drill file: %d drills)\n", n_drill); + sprintf(filename, "%s", ctime(&t)); + filename[strlen(filename) - 1] = 0; + fprintf(gcode_f2, "( %s )\n", filename); + fprintf(gcode_f2, "(Unit: %s)\n", metric ? "mm" : "inch"); + if (metric) + pcb_fprintf(gcode_f2, "(Board size: %.2mmx%.2mm mm)", PCB->MaxWidth, PCB->MaxHeight); + else + pcb_fprintf(gcode_f2, "(Board size: %.2mix%.2mi inches)", PCB->MaxWidth, PCB->MaxHeight); + fprintf(gcode_f2, "#100=%f (safe Z)\n", gcode_safeZ); + fprintf(gcode_f2, "#101=%f (drill depth)\n", gcode_drilldepth); + fprintf(gcode_f2, "(---------------------------------)\n"); + fprintf(gcode_f2, "G17 G%d G90 G64 P0.003 M3 S3000 M7 F%d\n", metric ? 21 : 20, metric ? 25 : 1); /* fprintf(gcode_f2,"G0 Z#100\n"); */ - for (r = 0; r < n_drill; r++) - { + for (r = 0; r < n_drill; r++) { /* if(metric) fprintf(gcode_f2,"G0 X%f Y%f\n",drill[r].x*25.4,drill[r].y*25.4); */ /* else fprintf(gcode_f2,"G0 X%f Y%f\n",drill[r].x,drill[r].y); */ - if (metric) - fprintf (gcode_f2, "G81 X%f Y%f Z#101 R#100\n", - drill[r].x * 25.4, drill[r].y * 25.4); - else - fprintf (gcode_f2, "G81 X%f Y%f Z#101 R#100\n", - drill[r].x, drill[r].y); + if (metric) + fprintf(gcode_f2, "G81 X%f Y%f Z#101 R#100\n", drill[r].x * 25.4, drill[r].y * 25.4); + else + fprintf(gcode_f2, "G81 X%f Y%f Z#101 R#100\n", drill[r].x, drill[r].y); /* fprintf(gcode_f2,"G1 Z#101\n"); */ /* fprintf(gcode_f2,"G0 Z#100\n"); */ - if (r > 0) - d += - sqrt ((drill[r].x - drill[r - 1].x) * (drill[r].x - - drill[r - 1].x) + - (drill[r].y - drill[r - 1].y) * (drill[r].y - - drill[r - 1].y)); - } - fprintf (gcode_f2, "M5 M9 M2\n"); - fprintf (gcode_f2, "(end, total distance %.2fmm = %.2fin)\n", - 25.4 * d, d); - fclose (gcode_f2); - free (drill); - drill = NULL; - n_drill = nmax_drill = 0; - } - free (filename); + if (r > 0) + d += + sqrt((drill[r].x - drill[r - 1].x) * (drill[r].x - + drill[r - 1].x) + + (drill[r].y - drill[r - 1].y) * (drill[r].y - drill[r - 1].y)); + } + fprintf(gcode_f2, "M5 M9 M2\n"); + fprintf(gcode_f2, "(end, total distance %.2fmm = %.2fin)\n", 25.4 * d, d); + fclose(gcode_f2); + free(drill); + drill = NULL; + n_drill = nmax_drill = 0; + } + free(filename); /* ******************* end gcode conversion **************************** */ - gcode_finish_png (); + gcode_finish_png(); + } } - } } /* *** PNG export (slightly modified code from PNG export HID) ************* */ -static int -gcode_set_layer (const char *name, int group, int empty) +static int gcode_set_layer(const char *name, int group, int empty) { - int idx = (group >= 0 && group < max_group) ? - PCB->LayerGroups.Entries[group][0] : group; + int idx = (group >= 0 && group < max_group) ? PCB->LayerGroups.Entries[group][0] : group; - if (name == 0) - { - name = PCB->Data->Layer[idx].Name; - } - if (strcmp (name, "invisible") == 0) - { - return 0; - } - is_drill = (SL_TYPE (idx) == SL_PDRILL || SL_TYPE (idx) == SL_UDRILL); - is_mask = (SL_TYPE (idx) == SL_MASK); + if (name == 0) { + name = PCB->Data->Layer[idx].Name; + } + if (strcmp(name, "invisible") == 0) { + return 0; + } + is_drill = (SL_TYPE(idx) == SL_PDRILL || SL_TYPE(idx) == SL_UDRILL); + is_mask = (SL_TYPE(idx) == SL_MASK); - if (is_mask) - { - /* Don't print masks */ - return 0; - } - if (is_drill) - { - /* - * Print 'holes', so that we can fill gaps in the copper - * layer - */ - return 1; - } - if (group == gcode_cur_group) - { - return 1; - } - return 0; + if (is_mask) { + /* Don't print masks */ + return 0; + } + if (is_drill) { + /* + * Print 'holes', so that we can fill gaps in the copper + * layer + */ + return 1; + } + if (group == gcode_cur_group) { + return 1; + } + return 0; } -static hidGC -gcode_make_gc (void) +static hidGC gcode_make_gc(void) { - hidGC rv = (hidGC) malloc (sizeof (struct hid_gc_struct)); - rv->me_pointer = &gcode_hid; - rv->cap = Trace_Cap; - rv->width = 1; - rv->color = (struct color_struct *) malloc (sizeof (*rv->color)); - rv->color->r = rv->color->g = rv->color->b = 0; - rv->color->c = 0; - return rv; + hidGC rv = (hidGC) malloc(sizeof(struct hid_gc_struct)); + rv->me_pointer = &gcode_hid; + rv->cap = Trace_Cap; + rv->width = 1; + rv->color = (struct color_struct *) malloc(sizeof(*rv->color)); + rv->color->r = rv->color->g = rv->color->b = 0; + rv->color->c = 0; + return rv; } -static void -gcode_destroy_gc (hidGC gc) +static void gcode_destroy_gc(hidGC gc) { - free (gc); + free(gc); } -static void -gcode_use_mask (int use_it) +static void gcode_use_mask(int use_it) { - /* does nothing */ + /* does nothing */ } -static void -gcode_set_color (hidGC gc, const char *name) +static void gcode_set_color(hidGC gc, const char *name) { - if (gcode_im == NULL) - { - return; - } - if (name == NULL) - { - name = "#ff0000"; - } - if (!strcmp (name, "drill")) - { - gc->color = black; - gc->erase = 0; - return; - } - if (!strcmp (name, "erase")) - { - /* FIXME -- should be background, not white */ - gc->color = white; - gc->erase = 1; - return; - } - gc->color = black; - gc->erase = 0; - return; + if (gcode_im == NULL) { + return; + } + if (name == NULL) { + name = "#ff0000"; + } + if (!strcmp(name, "drill")) { + gc->color = black; + gc->erase = 0; + return; + } + if (!strcmp(name, "erase")) { + /* FIXME -- should be background, not white */ + gc->color = white; + gc->erase = 1; + return; + } + gc->color = black; + gc->erase = 0; + return; } -static void -gcode_set_line_cap (hidGC gc, EndCapStyle style) +static void gcode_set_line_cap(hidGC gc, EndCapStyle style) { - gc->cap = style; + gc->cap = style; } -static void -gcode_set_line_width (hidGC gc, Coord width) +static void gcode_set_line_width(hidGC gc, Coord width) { - gc->width = width; + gc->width = width; } -static void -gcode_set_draw_xor (hidGC gc, int xor_) +static void gcode_set_draw_xor(hidGC gc, int xor_) { - ; + ; } -static void -gcode_set_draw_faded (hidGC gc, int faded) +static void gcode_set_draw_faded(hidGC gc, int faded) { - gc->faded = faded; + gc->faded = faded; } -static void -use_gc (hidGC gc) +static void use_gc(hidGC gc) { - int need_brush = 0; + int need_brush = 0; - if (gc->me_pointer != &gcode_hid) - { - fprintf (stderr, "Fatal: GC from another HID passed to gcode HID\n"); - abort (); - } - if (linewidth != gc->width) - { - /* Make sure the scaling doesn't erase lines completely */ - /* - if (SCALE (gc->width) == 0 && gc->width > 0) - gdImageSetThickness (im, 1); - else - */ - gdImageSetThickness (gcode_im, - pcb_to_gcode (gc->width + 2 * gcode_toolradius)); - linewidth = gc->width; - need_brush = 1; - } - if (lastbrush != gc->brush || need_brush) - { - static void *bcache = 0; - hidval bval; - char name[256]; - char type; - int r; - - switch (gc->cap) - { - case Round_Cap: - case Trace_Cap: - type = 'C'; - r = pcb_to_gcode (gc->width / 2 + gcode_toolradius); - break; - default: - case Square_Cap: - r = pcb_to_gcode (gc->width + gcode_toolradius * 2); - type = 'S'; - break; + if (gc->me_pointer != &gcode_hid) { + fprintf(stderr, "Fatal: GC from another HID passed to gcode HID\n"); + abort(); } - sprintf (name, "#%.2x%.2x%.2x_%c_%d", gc->color->r, gc->color->g, - gc->color->b, type, r); - - if (hid_cache_color (0, name, &bval, &bcache)) - { - gc->brush = (gdImagePtr)bval.ptr; + if (linewidth != gc->width) { + /* Make sure the scaling doesn't erase lines completely */ + /* + if (SCALE (gc->width) == 0 && gc->width > 0) + gdImageSetThickness (im, 1); + else + */ + gdImageSetThickness(gcode_im, pcb_to_gcode(gc->width + 2 * gcode_toolradius)); + linewidth = gc->width; + need_brush = 1; } - else - { - int bg, fg; - if (type == 'C') - gc->brush = gdImageCreate (2 * r + 1, 2 * r + 1); - else - gc->brush = gdImageCreate (r + 1, r + 1); - bg = gdImageColorAllocate (gc->brush, 255, 255, 255); - fg = - gdImageColorAllocate (gc->brush, gc->color->r, gc->color->g, - gc->color->b); - gdImageColorTransparent (gc->brush, bg); + if (lastbrush != gc->brush || need_brush) { + static void *bcache = 0; + hidval bval; + char name[256]; + char type; + int r; - /* - * if we shrunk to a radius/box width of zero, then just use - * a single pixel to draw with. - */ - if (r == 0) - gdImageFilledRectangle (gc->brush, 0, 0, 0, 0, fg); - else - { - if (type == 'C') - gdImageFilledEllipse (gc->brush, r, r, 2 * r, 2 * r, fg); - else - gdImageFilledRectangle (gc->brush, 0, 0, r, r, fg); - } - bval.ptr = gc->brush; - hid_cache_color (1, name, &bval, &bcache); - } + switch (gc->cap) { + case Round_Cap: + case Trace_Cap: + type = 'C'; + r = pcb_to_gcode(gc->width / 2 + gcode_toolradius); + break; + default: + case Square_Cap: + r = pcb_to_gcode(gc->width + gcode_toolradius * 2); + type = 'S'; + break; + } + sprintf(name, "#%.2x%.2x%.2x_%c_%d", gc->color->r, gc->color->g, gc->color->b, type, r); - gdImageSetBrush (gcode_im, gc->brush); - lastbrush = gc->brush; + if (hid_cache_color(0, name, &bval, &bcache)) { + gc->brush = (gdImagePtr) bval.ptr; + } + else { + int bg, fg; + if (type == 'C') + gc->brush = gdImageCreate(2 * r + 1, 2 * r + 1); + else + gc->brush = gdImageCreate(r + 1, r + 1); + bg = gdImageColorAllocate(gc->brush, 255, 255, 255); + fg = gdImageColorAllocate(gc->brush, gc->color->r, gc->color->g, gc->color->b); + gdImageColorTransparent(gc->brush, bg); - } + /* + * if we shrunk to a radius/box width of zero, then just use + * a single pixel to draw with. + */ + if (r == 0) + gdImageFilledRectangle(gc->brush, 0, 0, 0, 0, fg); + else { + if (type == 'C') + gdImageFilledEllipse(gc->brush, r, r, 2 * r, 2 * r, fg); + else + gdImageFilledRectangle(gc->brush, 0, 0, r, r, fg); + } + bval.ptr = gc->brush; + hid_cache_color(1, name, &bval, &bcache); + } + + gdImageSetBrush(gcode_im, gc->brush); + lastbrush = gc->brush; + + } #define CBLEND(gc) (((gc->r)<<24)|((gc->g)<<16)|((gc->b)<<8)|(gc->faded)) - if (lastcolor != CBLEND (gc)) - { - if (is_drill || is_mask) - { + if (lastcolor != CBLEND(gc)) { + if (is_drill || is_mask) { #ifdef FIXME - fprintf (f, "%d gray\n", gc->erase ? 0 : 1); + fprintf(f, "%d gray\n", gc->erase ? 0 : 1); #endif - lastcolor = 0; - } - else - { - double r, g, b; - r = gc->r; - g = gc->g; - b = gc->b; - if (gc->faded) - { - r = 0.8 * 255 + 0.2 * r; - g = 0.8 * 255 + 0.2 * g; - b = 0.8 * 255 + 0.2 * b; - } + lastcolor = 0; + } + else { + double r, g, b; + r = gc->r; + g = gc->g; + b = gc->b; + if (gc->faded) { + r = 0.8 * 255 + 0.2 * r; + g = 0.8 * 255 + 0.2 * g; + b = 0.8 * 255 + 0.2 * b; + } #ifdef FIXME - if (gc->r == gc->g && gc->g == gc->b) - fprintf (f, "%g gray\n", r / 255.0); - else - fprintf (f, "%g %g %g rgb\n", r / 255.0, g / 255.0, b / 255.0); + if (gc->r == gc->g && gc->g == gc->b) + fprintf(f, "%g gray\n", r / 255.0); + else + fprintf(f, "%g %g %g rgb\n", r / 255.0, g / 255.0, b / 255.0); #endif - lastcolor = CBLEND (gc); + lastcolor = CBLEND(gc); + } } - } } -static void -gcode_draw_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) +static void gcode_draw_rect(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) { - use_gc (gc); - gdImageRectangle (gcode_im, - pcb_to_gcode (x1 - gcode_toolradius), - pcb_to_gcode (y1 - gcode_toolradius), - pcb_to_gcode (x2 + gcode_toolradius), - pcb_to_gcode (y2 + gcode_toolradius), gc->color->c); + use_gc(gc); + gdImageRectangle(gcode_im, + pcb_to_gcode(x1 - gcode_toolradius), + pcb_to_gcode(y1 - gcode_toolradius), + pcb_to_gcode(x2 + gcode_toolradius), pcb_to_gcode(y2 + gcode_toolradius), gc->color->c); /* printf("Rect %d %d %d %d\n",x1,y1,x2,y2); */ } -static void -gcode_fill_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) +static void gcode_fill_rect(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) { - use_gc (gc); - gdImageSetThickness (gcode_im, 0); - linewidth = 0; - gdImageFilledRectangle (gcode_im, - pcb_to_gcode (x1 - gcode_toolradius), - pcb_to_gcode (y1 - gcode_toolradius), - pcb_to_gcode (x2 + gcode_toolradius), - pcb_to_gcode (y2 + gcode_toolradius), gc->color->c); + use_gc(gc); + gdImageSetThickness(gcode_im, 0); + linewidth = 0; + gdImageFilledRectangle(gcode_im, + pcb_to_gcode(x1 - gcode_toolradius), + pcb_to_gcode(y1 - gcode_toolradius), + pcb_to_gcode(x2 + gcode_toolradius), pcb_to_gcode(y2 + gcode_toolradius), gc->color->c); /* printf("FillRect %d %d %d %d\n",x1,y1,x2,y2); */ } -static void -gcode_draw_line (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) +static void gcode_draw_line(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) { - if (x1 == x2 && y1 == y2) - { - Coord w = gc->width / 2; - gcode_fill_rect (gc, x1 - w, y1 - w, x1 + w, y1 + w); - return; - } - use_gc (gc); + if (x1 == x2 && y1 == y2) { + Coord w = gc->width / 2; + gcode_fill_rect(gc, x1 - w, y1 - w, x1 + w, y1 + w); + return; + } + use_gc(gc); - gdImageSetThickness (gcode_im, 0); - linewidth = 0; - gdImageLine (gcode_im, pcb_to_gcode (x1), pcb_to_gcode (y1), - pcb_to_gcode (x2), pcb_to_gcode (y2), gdBrushed); + gdImageSetThickness(gcode_im, 0); + linewidth = 0; + gdImageLine(gcode_im, pcb_to_gcode(x1), pcb_to_gcode(y1), pcb_to_gcode(x2), pcb_to_gcode(y2), gdBrushed); } -static void -gcode_draw_arc (hidGC gc, Coord cx, Coord cy, Coord width, Coord height, - Angle start_angle, Angle delta_angle) +static void gcode_draw_arc(hidGC gc, Coord cx, Coord cy, Coord width, Coord height, Angle start_angle, Angle delta_angle) { - Angle sa, ea; + Angle sa, ea; - /* - * in gdImageArc, 0 degrees is to the right and +90 degrees is down - * in pcb, 0 degrees is to the left and +90 degrees is down - */ - start_angle = 180 - start_angle; - delta_angle = -delta_angle; - if (delta_angle > 0) - { - sa = start_angle; - ea = start_angle + delta_angle; - } - else - { - sa = start_angle + delta_angle; - ea = start_angle; - } + /* + * in gdImageArc, 0 degrees is to the right and +90 degrees is down + * in pcb, 0 degrees is to the left and +90 degrees is down + */ + start_angle = 180 - start_angle; + delta_angle = -delta_angle; + if (delta_angle > 0) { + sa = start_angle; + ea = start_angle + delta_angle; + } + else { + sa = start_angle + delta_angle; + ea = start_angle; + } - /* - * make sure we start between 0 and 360 otherwise gd does strange - * things - */ - sa = NormalizeAngle (sa); - ea = NormalizeAngle (ea); + /* + * make sure we start between 0 and 360 otherwise gd does strange + * things + */ + sa = NormalizeAngle(sa); + ea = NormalizeAngle(ea); #if 0 - printf ("draw_arc %d,%d %dx%d %d..%d %d..%d\n", - cx, cy, width, height, start_angle, delta_angle, sa, ea); - printf ("gdImageArc (%p, %d, %d, %d, %d, %d, %d, %d)\n", - im, SCALE_X (cx), SCALE_Y (cy), - SCALE (width), SCALE (height), sa, ea, gc->color->c); + printf("draw_arc %d,%d %dx%d %d..%d %d..%d\n", cx, cy, width, height, start_angle, delta_angle, sa, ea); + printf("gdImageArc (%p, %d, %d, %d, %d, %d, %d, %d)\n", + im, SCALE_X(cx), SCALE_Y(cy), SCALE(width), SCALE(height), sa, ea, gc->color->c); #endif - use_gc (gc); - gdImageSetThickness (gcode_im, 0); - linewidth = 0; - gdImageArc (gcode_im, pcb_to_gcode (cx), pcb_to_gcode (cy), - pcb_to_gcode (2 * width + gcode_toolradius * 2), - pcb_to_gcode (2 * height + gcode_toolradius * 2), sa, ea, - gdBrushed); + use_gc(gc); + gdImageSetThickness(gcode_im, 0); + linewidth = 0; + gdImageArc(gcode_im, pcb_to_gcode(cx), pcb_to_gcode(cy), + pcb_to_gcode(2 * width + gcode_toolradius * 2), + pcb_to_gcode(2 * height + gcode_toolradius * 2), sa, ea, gdBrushed); } -static void -gcode_fill_circle (hidGC gc, Coord cx, Coord cy, Coord radius) +static void gcode_fill_circle(hidGC gc, Coord cx, Coord cy, Coord radius) { - use_gc (gc); + use_gc(gc); - gdImageSetThickness (gcode_im, 0); - linewidth = 0; - gdImageFilledEllipse (gcode_im, pcb_to_gcode (cx), pcb_to_gcode (cy), - pcb_to_gcode (2 * radius + gcode_toolradius * 2), - pcb_to_gcode (2 * radius + gcode_toolradius * 2), - gc->color->c); - if (save_drill && is_drill) - { - if (n_drill == nmax_drill) - { - drill = - (struct drill_struct *) realloc (drill, - (nmax_drill + - 100) * - sizeof (struct drill_struct)); - nmax_drill += 100; + gdImageSetThickness(gcode_im, 0); + linewidth = 0; + gdImageFilledEllipse(gcode_im, pcb_to_gcode(cx), pcb_to_gcode(cy), + pcb_to_gcode(2 * radius + gcode_toolradius * 2), + pcb_to_gcode(2 * radius + gcode_toolradius * 2), gc->color->c); + if (save_drill && is_drill) { + if (n_drill == nmax_drill) { + drill = (struct drill_struct *) realloc(drill, (nmax_drill + 100) * sizeof(struct drill_struct)); + nmax_drill += 100; + } + drill[n_drill].x = COORD_TO_INCH(PCB->MaxWidth - cx); /* convert to inch, flip: will drill from bottom side */ + drill[n_drill].y = COORD_TO_INCH(PCB->MaxHeight - cy); /* PCB reverses y axis */ + n_drill++; +/* printf("Circle %d %d\n",cx,cy); */ } - drill[n_drill].x = COORD_TO_INCH(PCB->MaxWidth - cx); /* convert to inch, flip: will drill from bottom side */ - drill[n_drill].y = COORD_TO_INCH(PCB->MaxHeight - cy); /* PCB reverses y axis */ - n_drill++; -/* printf("Circle %d %d\n",cx,cy); */ - } } -static void -gcode_fill_polygon (hidGC gc, int n_coords, Coord *x, Coord *y) +static void gcode_fill_polygon(hidGC gc, int n_coords, Coord * x, Coord * y) { - int i; - gdPoint *points; + int i; + gdPoint *points; - points = (gdPoint *) malloc (n_coords * sizeof (gdPoint)); - if (points == NULL) - { - fprintf (stderr, "ERROR: gcode_fill_polygon(): malloc failed\n"); - exit (1); - } - use_gc (gc); - for (i = 0; i < n_coords; i++) - { - points[i].x = pcb_to_gcode (x[i]); - points[i].y = pcb_to_gcode (y[i]); - } - gdImageSetThickness (gcode_im, 0); - linewidth = 0; - gdImageFilledPolygon (gcode_im, points, n_coords, gc->color->c); - free (points); + points = (gdPoint *) malloc(n_coords * sizeof(gdPoint)); + if (points == NULL) { + fprintf(stderr, "ERROR: gcode_fill_polygon(): malloc failed\n"); + exit(1); + } + use_gc(gc); + for (i = 0; i < n_coords; i++) { + points[i].x = pcb_to_gcode(x[i]); + points[i].y = pcb_to_gcode(y[i]); + } + gdImageSetThickness(gcode_im, 0); + linewidth = 0; + gdImageFilledPolygon(gcode_im, points, n_coords, gc->color->c); + free(points); /* printf("FillPoly\n"); */ } -static void -gcode_calibrate (double xval, double yval) +static void gcode_calibrate(double xval, double yval) { - CRASH; + CRASH; } -static void -gcode_set_crosshair (int x, int y, int a) +static void gcode_set_crosshair(int x, int y, int a) { } @@ -993,41 +862,39 @@ HID gcode_hid; -void -hid_gcode_init () +void hid_gcode_init() { - memset (&gcode_hid, 0, sizeof (HID)); + memset(&gcode_hid, 0, sizeof(HID)); - common_nogui_init (&gcode_hid); - common_draw_helpers_init (&gcode_hid); + common_nogui_init(&gcode_hid); + common_draw_helpers_init(&gcode_hid); - gcode_hid.struct_size = sizeof (HID); - gcode_hid.name = "gcode"; - gcode_hid.description = "G-CODE export"; - gcode_hid.exporter = 1; - gcode_hid.poly_before = 1; + gcode_hid.struct_size = sizeof(HID); + gcode_hid.name = "gcode"; + gcode_hid.description = "G-CODE export"; + gcode_hid.exporter = 1; + gcode_hid.poly_before = 1; - gcode_hid.get_export_options = gcode_get_export_options; - gcode_hid.do_export = gcode_do_export; - gcode_hid.parse_arguments = gcode_parse_arguments; - gcode_hid.set_layer = gcode_set_layer; - gcode_hid.make_gc = gcode_make_gc; - gcode_hid.destroy_gc = gcode_destroy_gc; - gcode_hid.use_mask = gcode_use_mask; - gcode_hid.set_color = gcode_set_color; - gcode_hid.set_line_cap = gcode_set_line_cap; - gcode_hid.set_line_width = gcode_set_line_width; - gcode_hid.set_draw_xor = gcode_set_draw_xor; - gcode_hid.set_draw_faded = gcode_set_draw_faded; - gcode_hid.draw_line = gcode_draw_line; - gcode_hid.draw_arc = gcode_draw_arc; - gcode_hid.draw_rect = gcode_draw_rect; - gcode_hid.fill_circle = gcode_fill_circle; - gcode_hid.fill_polygon = gcode_fill_polygon; - gcode_hid.fill_rect = gcode_fill_rect; - gcode_hid.calibrate = gcode_calibrate; - gcode_hid.set_crosshair = gcode_set_crosshair; + gcode_hid.get_export_options = gcode_get_export_options; + gcode_hid.do_export = gcode_do_export; + gcode_hid.parse_arguments = gcode_parse_arguments; + gcode_hid.set_layer = gcode_set_layer; + gcode_hid.make_gc = gcode_make_gc; + gcode_hid.destroy_gc = gcode_destroy_gc; + gcode_hid.use_mask = gcode_use_mask; + gcode_hid.set_color = gcode_set_color; + gcode_hid.set_line_cap = gcode_set_line_cap; + gcode_hid.set_line_width = gcode_set_line_width; + gcode_hid.set_draw_xor = gcode_set_draw_xor; + gcode_hid.set_draw_faded = gcode_set_draw_faded; + gcode_hid.draw_line = gcode_draw_line; + gcode_hid.draw_arc = gcode_draw_arc; + gcode_hid.draw_rect = gcode_draw_rect; + gcode_hid.fill_circle = gcode_fill_circle; + gcode_hid.fill_polygon = gcode_fill_polygon; + gcode_hid.fill_rect = gcode_fill_rect; + gcode_hid.calibrate = gcode_calibrate; + gcode_hid.set_crosshair = gcode_set_crosshair; - hid_register_hid (&gcode_hid); + hid_register_hid(&gcode_hid); } - Index: trunk/src/hid/gcode/potracelib.h =================================================================== --- trunk/src/hid/gcode/potracelib.h (revision 1021) +++ trunk/src/hid/gcode/potracelib.h (revision 1022) @@ -21,24 +21,22 @@ #define POTRACE_TURNPOLICY_RANDOM 6 /* structure to hold progress bar callback data */ -struct potrace_progress_s -{ - void (*callback) (double progress, void *privdata); /* callback fn */ - void *data; /* callback function's private data */ - double min, max; /* desired range of progress, e.g. 0.0 to 1.0 */ - double epsilon; /* granularity: can skip smaller increments */ +struct potrace_progress_s { + void (*callback) (double progress, void *privdata); /* callback fn */ + void *data; /* callback function's private data */ + double min, max; /* desired range of progress, e.g. 0.0 to 1.0 */ + double epsilon; /* granularity: can skip smaller increments */ }; typedef struct potrace_progress_s potrace_progress_t; /* structure to hold tracing parameters */ -struct potrace_param_s -{ - int turdsize; /* area of largest path to be ignored */ - int turnpolicy; /* resolves ambiguous turns in path decomposition */ - double alphamax; /* corner threshold */ - int opticurve; /* use curve optimization? */ - double opttolerance; /* curve optimization tolerance */ - potrace_progress_t progress; /* progress callback function */ +struct potrace_param_s { + int turdsize; /* area of largest path to be ignored */ + int turnpolicy; /* resolves ambiguous turns in path decomposition */ + double alphamax; /* corner threshold */ + int opticurve; /* use curve optimization? */ + double opttolerance; /* curve optimization tolerance */ + potrace_progress_t progress; /* progress callback function */ }; typedef struct potrace_param_s potrace_param_t; @@ -52,11 +50,10 @@ (map + n*dy). Raster data is stored as a sequence of potrace_words (NOT bytes). The leftmost bit of scanline n is the most significant bit of scanline(n)[0]. */ -struct potrace_bitmap_s -{ - int w, h; /* width and height, in pixels */ - int dy; /* words per scanline (not bytes) */ - potrace_word *map; /* raw data, dy*h words */ +struct potrace_bitmap_s { + int w, h; /* width and height, in pixels */ + int dy; /* words per scanline (not bytes) */ + potrace_word *map; /* raw data, dy*h words */ }; typedef struct potrace_bitmap_s potrace_bitmap_t; @@ -64,9 +61,8 @@ /* curves */ /* point */ -struct potrace_dpoint_s -{ - double x, y; +struct potrace_dpoint_s { + double x, y; }; typedef struct potrace_dpoint_s potrace_dpoint_t; @@ -75,28 +71,26 @@ #define POTRACE_CORNER 2 /* closed curve segment */ -struct potrace_curve_s -{ - int n; /* number of segments */ - int *tag; /* tag[n]: POTRACE_CURVETO or POTRACE_CORNER */ - potrace_dpoint_t (*c)[3]; /* c[n][3]: control points. - c[n][0] is unused for tag[n]=POTRACE_CORNER */ +struct potrace_curve_s { + int n; /* number of segments */ + int *tag; /* tag[n]: POTRACE_CURVETO or POTRACE_CORNER */ + potrace_dpoint_t(*c)[3]; /* c[n][3]: control points. + c[n][0] is unused for tag[n]=POTRACE_CORNER */ }; typedef struct potrace_curve_s potrace_curve_t; /* Linked list of signed curve segments. Also carries a tree structure. */ -struct potrace_path_s -{ - int area; /* area of the bitmap path */ - int sign; /* '+' or '-', depending on orientation */ - potrace_curve_t curve; /* this path's vector data */ +struct potrace_path_s { + int area; /* area of the bitmap path */ + int sign; /* '+' or '-', depending on orientation */ + potrace_curve_t curve; /* this path's vector data */ - struct potrace_path_s *next; /* linked list structure */ + struct potrace_path_s *next; /* linked list structure */ - struct potrace_path_s *childlist; /* tree structure */ - struct potrace_path_s *sibling; /* tree structure */ + struct potrace_path_s *childlist; /* tree structure */ + struct potrace_path_s *sibling; /* tree structure */ - struct potrace_privpath_s *priv; /* private state */ + struct potrace_privpath_s *priv; /* private state */ }; typedef struct potrace_path_s potrace_path_t; @@ -106,12 +100,11 @@ #define POTRACE_STATUS_OK 0 #define POTRACE_STATUS_INCOMPLETE 1 -struct potrace_state_s -{ - int status; - potrace_path_t *plist; /* vector data */ +struct potrace_state_s { + int status; + potrace_path_t *plist; /* vector data */ - struct potrace_privstate_s *priv; /* private state */ + struct potrace_privstate_s *priv; /* private state */ }; typedef struct potrace_state_s potrace_state_t; @@ -119,20 +112,19 @@ /* API functions */ /* get default parameters */ -potrace_param_t *potrace_param_default (void); +potrace_param_t *potrace_param_default(void); /* free parameter set */ -void potrace_param_free (potrace_param_t * p); +void potrace_param_free(potrace_param_t * p); /* trace a bitmap*/ -potrace_state_t *potrace_trace (const potrace_param_t * param, - const potrace_bitmap_t * bm); +potrace_state_t *potrace_trace(const potrace_param_t * param, const potrace_bitmap_t * bm); /* free a Potrace state */ -void potrace_state_free (potrace_state_t * st); +void potrace_state_free(potrace_state_t * st); /* return a static plain text version string identifying this version of potracelib */ -char *potrace_version (void); +char *potrace_version(void); #endif /* POTRACELIB_H */ Index: trunk/src/hid/gcode/trace.c =================================================================== --- trunk/src/hid/gcode/trace.c (revision 1021) +++ trunk/src/hid/gcode/trace.c (revision 1022) @@ -20,8 +20,8 @@ #include "trace.h" /*#include "progress.h"*/ -#define INFTY 10000000 /* it suffices that this is longer than any - path; it need not be really infinite */ +#define INFTY 10000000 /* it suffices that this is longer than any + path; it need not be really infinite */ #define COS179 -0.999847695156 /* the cosine of 179 degrees */ /* ---------------------------------------------------------------------- */ @@ -33,134 +33,118 @@ /* return a direction that is 90 degrees counterclockwise from p2-p0, but then restricted to one of the major wind directions (n, nw, w, etc) */ -static inline point_t -dorth_infty (dpoint_t p0, dpoint_t p2) +static inline point_t dorth_infty(dpoint_t p0, dpoint_t p2) { - point_t r; + point_t r; - r.y = sign (p2.x - p0.x); - r.x = -sign (p2.y - p0.y); + r.y = sign(p2.x - p0.x); + r.x = -sign(p2.y - p0.y); - return r; + return r; } /* return (p1-p0)x(p2-p0), the area of the parallelogram */ -static inline double -dpara (dpoint_t p0, dpoint_t p1, dpoint_t p2) +static inline double dpara(dpoint_t p0, dpoint_t p1, dpoint_t p2) { - double x1, y1, x2, y2; + double x1, y1, x2, y2; - x1 = p1.x - p0.x; - y1 = p1.y - p0.y; - x2 = p2.x - p0.x; - y2 = p2.y - p0.y; + x1 = p1.x - p0.x; + y1 = p1.y - p0.y; + x2 = p2.x - p0.x; + y2 = p2.y - p0.y; - return x1 * y2 - x2 * y1; + return x1 * y2 - x2 * y1; } /* ddenom/dpara have the property that the square of radius 1 centered at p1 intersects the line p0p2 iff |dpara(p0,p1,p2)| <= ddenom(p0,p2) */ -static inline double -ddenom (dpoint_t p0, dpoint_t p2) +static inline double ddenom(dpoint_t p0, dpoint_t p2) { - point_t r = dorth_infty (p0, p2); + point_t r = dorth_infty(p0, p2); - return r.y * (p2.x - p0.x) - r.x * (p2.y - p0.y); + return r.y * (p2.x - p0.x) - r.x * (p2.y - p0.y); } /* return 1 if a <= b < c < a, in a cyclic sense (mod n) */ -static inline int -cyclic (int a, int b, int c) +static inline int cyclic(int a, int b, int c) { - if (a <= c) - { - return (a <= b && b < c); - } - else - { - return (a <= b || b < c); - } + if (a <= c) { + return (a <= b && b < c); + } + else { + return (a <= b || b < c); + } } /* determine the center and slope of the line i..j. Assume ilen; - sums_t *sums = pp->sums; + int n = pp->len; + sums_t *sums = pp->sums; - double x, y, x2, xy, y2; - double k; - double a, b, c, lambda2, l; - int r = 0; /* rotations from i to j */ + double x, y, x2, xy, y2; + double k; + double a, b, c, lambda2, l; + int r = 0; /* rotations from i to j */ - while (j >= n) - { - j -= n; - r += 1; - } - while (i >= n) - { - i -= n; - r -= 1; - } - while (j < 0) - { - j += n; - r -= 1; - } - while (i < 0) - { - i += n; - r += 1; - } + while (j >= n) { + j -= n; + r += 1; + } + while (i >= n) { + i -= n; + r -= 1; + } + while (j < 0) { + j += n; + r -= 1; + } + while (i < 0) { + i += n; + r += 1; + } - x = sums[j + 1].x - sums[i].x + r * sums[n].x; - y = sums[j + 1].y - sums[i].y + r * sums[n].y; - x2 = sums[j + 1].x2 - sums[i].x2 + r * sums[n].x2; - xy = sums[j + 1].xy - sums[i].xy + r * sums[n].xy; - y2 = sums[j + 1].y2 - sums[i].y2 + r * sums[n].y2; - k = j + 1 - i + r * n; + x = sums[j + 1].x - sums[i].x + r * sums[n].x; + y = sums[j + 1].y - sums[i].y + r * sums[n].y; + x2 = sums[j + 1].x2 - sums[i].x2 + r * sums[n].x2; + xy = sums[j + 1].xy - sums[i].xy + r * sums[n].xy; + y2 = sums[j + 1].y2 - sums[i].y2 + r * sums[n].y2; + k = j + 1 - i + r * n; - ctr->x = x / k; - ctr->y = y / k; + ctr->x = x / k; + ctr->y = y / k; - a = (x2 - (double) x * x / k) / k; - b = (xy - (double) x * y / k) / k; - c = (y2 - (double) y * y / k) / k; + a = (x2 - (double) x * x / k) / k; + b = (xy - (double) x * y / k) / k; + c = (y2 - (double) y * y / k) / k; - lambda2 = (a + c + sqrt ((a - c) * (a - c) + 4 * b * b)) / 2; /* larger e.value */ + lambda2 = (a + c + sqrt((a - c) * (a - c) + 4 * b * b)) / 2; /* larger e.value */ - /* now find e.vector for lambda2 */ - a -= lambda2; - c -= lambda2; + /* now find e.vector for lambda2 */ + a -= lambda2; + c -= lambda2; - if (fabs (a) >= fabs (c)) - { - l = sqrt (a * a + b * b); - if (l != 0) - { - dir->x = -b / l; - dir->y = a / l; + if (fabs(a) >= fabs(c)) { + l = sqrt(a * a + b * b); + if (l != 0) { + dir->x = -b / l; + dir->y = a / l; + } } - } - else - { - l = sqrt (c * c + b * b); - if (l != 0) - { - dir->x = -c / l; - dir->y = b / l; + else { + l = sqrt(c * c + b * b); + if (l != 0) { + dir->x = -c / l; + dir->y = b / l; + } } - } - if (l == 0) - { - dir->x = dir->y = 0; /* sometimes this can happen when k=4: - the two eigenvalues coincide */ - } + if (l == 0) { + dir->x = dir->y = 0; /* sometimes this can happen when k=4: + the two eigenvalues coincide */ + } } /* the type of (affine) quadratic forms, represented as symmetric 3x3 @@ -169,148 +153,129 @@ typedef double quadform_t[3][3]; /* Apply quadratic form Q to vector w = (w.x,w.y) */ -static inline double -quadform (quadform_t Q, dpoint_t w) +static inline double quadform(quadform_t Q, dpoint_t w) { - double v[3]; - int i, j; - double sum; + double v[3]; + int i, j; + double sum; - v[0] = w.x; - v[1] = w.y; - v[2] = 1; - sum = 0.0; + v[0] = w.x; + v[1] = w.y; + v[2] = 1; + sum = 0.0; - for (i = 0; i < 3; i++) - { - for (j = 0; j < 3; j++) - { - sum += v[i] * Q[i][j] * v[j]; + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + sum += v[i] * Q[i][j] * v[j]; + } } - } - return sum; + return sum; } /* calculate p1 x p2 */ -static inline int -xprod (point_t p1, point_t p2) +static inline int xprod(point_t p1, point_t p2) { - return p1.x * p2.y - p1.y * p2.x; + return p1.x * p2.y - p1.y * p2.x; } /* calculate (p1-p0)x(p3-p2) */ -static inline double -cprod (dpoint_t p0, dpoint_t p1, dpoint_t p2, dpoint_t p3) +static inline double cprod(dpoint_t p0, dpoint_t p1, dpoint_t p2, dpoint_t p3) { - double x1, y1, x2, y2; + double x1, y1, x2, y2; - x1 = p1.x - p0.x; - y1 = p1.y - p0.y; - x2 = p3.x - p2.x; - y2 = p3.y - p2.y; + x1 = p1.x - p0.x; + y1 = p1.y - p0.y; + x2 = p3.x - p2.x; + y2 = p3.y - p2.y; - return x1 * y2 - x2 * y1; + return x1 * y2 - x2 * y1; } /* calculate (p1-p0)*(p2-p0) */ -static inline double -iprod (dpoint_t p0, dpoint_t p1, dpoint_t p2) +static inline double iprod(dpoint_t p0, dpoint_t p1, dpoint_t p2) { - double x1, y1, x2, y2; + double x1, y1, x2, y2; - x1 = p1.x - p0.x; - y1 = p1.y - p0.y; - x2 = p2.x - p0.x; - y2 = p2.y - p0.y; + x1 = p1.x - p0.x; + y1 = p1.y - p0.y; + x2 = p2.x - p0.x; + y2 = p2.y - p0.y; - return x1 * x2 + y1 * y2; + return x1 * x2 + y1 * y2; } /* calculate (p1-p0)*(p3-p2) */ -static inline double -iprod1 (dpoint_t p0, dpoint_t p1, dpoint_t p2, dpoint_t p3) +static inline double iprod1(dpoint_t p0, dpoint_t p1, dpoint_t p2, dpoint_t p3) { - double x1, y1, x2, y2; + double x1, y1, x2, y2; - x1 = p1.x - p0.x; - y1 = p1.y - p0.y; - x2 = p3.x - p2.x; - y2 = p3.y - p2.y; + x1 = p1.x - p0.x; + y1 = p1.y - p0.y; + x2 = p3.x - p2.x; + y2 = p3.y - p2.y; - return x1 * x2 + y1 * y2; + return x1 * x2 + y1 * y2; } /* calculate distance between two points */ -static inline double -ddist (dpoint_t p, dpoint_t q) +static inline double ddist(dpoint_t p, dpoint_t q) { - return sqrt (sq (p.x - q.x) + sq (p.y - q.y)); + return sqrt(sq(p.x - q.x) + sq(p.y - q.y)); } /* calculate point of a bezier curve */ -static inline dpoint_t -bezier (double t, dpoint_t p0, dpoint_t p1, dpoint_t p2, dpoint_t p3) +static inline dpoint_t bezier(double t, dpoint_t p0, dpoint_t p1, dpoint_t p2, dpoint_t p3) { - double s = 1 - t; - dpoint_t res; + double s = 1 - t; + dpoint_t res; - /* Note: a good optimizing compiler (such as gcc-3) reduces the - following to 16 multiplications, using common subexpression - elimination. */ + /* Note: a good optimizing compiler (such as gcc-3) reduces the + following to 16 multiplications, using common subexpression + elimination. */ - res.x = - s * s * s * p0.x + 3 * (s * s * t) * p1.x + 3 * (t * t * s) * p2.x + - t * t * t * p3.x; - res.y = - s * s * s * p0.y + 3 * (s * s * t) * p1.y + 3 * (t * t * s) * p2.y + - t * t * t * p3.y; + res.x = s * s * s * p0.x + 3 * (s * s * t) * p1.x + 3 * (t * t * s) * p2.x + t * t * t * p3.x; + res.y = s * s * s * p0.y + 3 * (s * s * t) * p1.y + 3 * (t * t * s) * p2.y + t * t * t * p3.y; - return res; + return res; } /* calculate the point t in [0..1] on the (convex) bezier curve (p0,p1,p2,p3) which is tangent to q1-q0. Return -1.0 if there is no solution in [0..1]. */ -static double -tangent (dpoint_t p0, dpoint_t p1, dpoint_t p2, dpoint_t p3, dpoint_t q0, - dpoint_t q1) +static double tangent(dpoint_t p0, dpoint_t p1, dpoint_t p2, dpoint_t p3, dpoint_t q0, dpoint_t q1) { - double A, B, C; /* (1-t)^2 A + 2(1-t)t B + t^2 C = 0 */ - double a, b, c; /* a t^2 + b t + c = 0 */ - double d, s, r1, r2; + double A, B, C; /* (1-t)^2 A + 2(1-t)t B + t^2 C = 0 */ + double a, b, c; /* a t^2 + b t + c = 0 */ + double d, s, r1, r2; - A = cprod (p0, p1, q0, q1); - B = cprod (p1, p2, q0, q1); - C = cprod (p2, p3, q0, q1); + A = cprod(p0, p1, q0, q1); + B = cprod(p1, p2, q0, q1); + C = cprod(p2, p3, q0, q1); - a = A - 2 * B + C; - b = -2 * A + 2 * B; - c = A; + a = A - 2 * B + C; + b = -2 * A + 2 * B; + c = A; - d = b * b - 4 * a * c; + d = b * b - 4 * a * c; - if (a == 0 || d < 0) - { - return -1.0; - } + if (a == 0 || d < 0) { + return -1.0; + } - s = sqrt (d); + s = sqrt(d); - r1 = (-b + s) / (2 * a); - r2 = (-b - s) / (2 * a); + r1 = (-b + s) / (2 * a); + r2 = (-b - s) / (2 * a); - if (r1 >= 0 && r1 <= 1) - { - return r1; - } - else if (r2 >= 0 && r2 <= 1) - { - return r2; - } - else - { - return -1.0; - } + if (r1 >= 0 && r1 <= 1) { + return r1; + } + else if (r2 >= 0 && r2 <= 1) { + return r2; + } + else { + return -1.0; + } } /* ---------------------------------------------------------------------- */ @@ -317,35 +282,32 @@ /* Preparation: fill in the sum* fields of a path (used for later rapid summing). Return 0 on success, 1 with errno set on failure. */ -static int -calc_sums (privpath_t * pp) +static int calc_sums(privpath_t * pp) { - int i, x, y; - int n = pp->len; + int i, x, y; + int n = pp->len; - SAFE_MALLOC (pp->sums, pp->len + 1, sums_t); + SAFE_MALLOC(pp->sums, pp->len + 1, sums_t); - /* origin */ - pp->x0 = pp->pt[0].x; - pp->y0 = pp->pt[0].y; + /* origin */ + pp->x0 = pp->pt[0].x; + pp->y0 = pp->pt[0].y; - /* preparatory computation for later fast summing */ - pp->sums[0].x2 = pp->sums[0].xy = pp->sums[0].y2 = pp->sums[0].x = - pp->sums[0].y = 0; - for (i = 0; i < n; i++) - { - x = pp->pt[i].x - pp->x0; - y = pp->pt[i].y - pp->y0; - pp->sums[i + 1].x = pp->sums[i].x + x; - pp->sums[i + 1].y = pp->sums[i].y + y; - pp->sums[i + 1].x2 = pp->sums[i].x2 + x * x; - pp->sums[i + 1].xy = pp->sums[i].xy + x * y; - pp->sums[i + 1].y2 = pp->sums[i].y2 + y * y; - } - return 0; + /* preparatory computation for later fast summing */ + pp->sums[0].x2 = pp->sums[0].xy = pp->sums[0].y2 = pp->sums[0].x = pp->sums[0].y = 0; + for (i = 0; i < n; i++) { + x = pp->pt[i].x - pp->x0; + y = pp->pt[i].y - pp->y0; + pp->sums[i + 1].x = pp->sums[i].x + x; + pp->sums[i + 1].y = pp->sums[i].y + y; + pp->sums[i + 1].x2 = pp->sums[i].x2 + x * x; + pp->sums[i + 1].xy = pp->sums[i].xy + x * y; + pp->sums[i + 1].y2 = pp->sums[i].y2 + y * y; + } + return 0; malloc_error: - return 1; + return 1; } /* ---------------------------------------------------------------------- */ @@ -378,178 +340,152 @@ substantial. */ /* returns 0 on success, 1 on error with errno set */ -static int -calc_lon (privpath_t * pp) +static int calc_lon(privpath_t * pp) { - point_t *pt = pp->pt; - int n = pp->len; - int i, j, k, k1; - int ct[4], dir; - point_t constraint[2]; - point_t cur; - point_t off; - int *pivk = NULL; /* pivk[n] */ - int *nc = NULL; /* nc[n]: next corner */ - point_t dk; /* direction of k-k1 */ - int a, b, c, d; + point_t *pt = pp->pt; + int n = pp->len; + int i, j, k, k1; + int ct[4], dir; + point_t constraint[2]; + point_t cur; + point_t off; + int *pivk = NULL; /* pivk[n] */ + int *nc = NULL; /* nc[n]: next corner */ + point_t dk; /* direction of k-k1 */ + int a, b, c, d; - SAFE_MALLOC (pivk, n, int); - SAFE_MALLOC (nc, n, int); + SAFE_MALLOC(pivk, n, int); + SAFE_MALLOC(nc, n, int); - /* initialize the nc data structure. Point from each point to the - furthest future point to which it is connected by a vertical or - horizontal segment. We take advantage of the fact that there is - always a direction change at 0 (due to the path decomposition - algorithm). But even if this were not so, there is no harm, as - in practice, correctness does not depend on the word "furthest" - above. */ - k = 0; - for (i = n - 1; i >= 0; i--) - { - if (pt[i].x != pt[k].x && pt[i].y != pt[k].y) - { - k = i + 1; /* necessarily i= 0; i--) { + if (pt[i].x != pt[k].x && pt[i].y != pt[k].y) { + k = i + 1; /* necessarily ilon, n, int); + SAFE_MALLOC(pp->lon, n, int); - /* determine pivot points: for each i, let pivk[i] be the furthest k - such that all j with i= 0; i--) - { - ct[0] = ct[1] = ct[2] = ct[3] = 0; + for (i = n - 1; i >= 0; i--) { + ct[0] = ct[1] = ct[2] = ct[3] = 0; - /* keep track of "directions" that have occurred */ - dir = - (3 + 3 * (pt[mod (i + 1, n)].x - pt[i].x) + - (pt[mod (i + 1, n)].y - pt[i].y)) / 2; - ct[dir]++; + /* keep track of "directions" that have occurred */ + dir = (3 + 3 * (pt[mod(i + 1, n)].x - pt[i].x) + (pt[mod(i + 1, n)].y - pt[i].y)) / 2; + ct[dir]++; - constraint[0].x = 0; - constraint[0].y = 0; - constraint[1].x = 0; - constraint[1].y = 0; + constraint[0].x = 0; + constraint[0].y = 0; + constraint[1].x = 0; + constraint[1].y = 0; - /* find the next k such that no straight line from i to k */ - k = nc[i]; - k1 = i; - while (1) - { + /* find the next k such that no straight line from i to k */ + k = nc[i]; + k1 = i; + while (1) { - dir = - (3 + 3 * sign (pt[k].x - pt[k1].x) + - sign (pt[k].y - pt[k1].y)) / 2; - ct[dir]++; + dir = (3 + 3 * sign(pt[k].x - pt[k1].x) + sign(pt[k].y - pt[k1].y)) / 2; + ct[dir]++; - /* if all four "directions" have occurred, cut this path */ - if (ct[0] && ct[1] && ct[2] && ct[3]) - { - pivk[i] = k1; - goto foundk; - } + /* if all four "directions" have occurred, cut this path */ + if (ct[0] && ct[1] && ct[2] && ct[3]) { + pivk[i] = k1; + goto foundk; + } - cur.x = pt[k].x - pt[i].x; - cur.y = pt[k].y - pt[i].y; + cur.x = pt[k].x - pt[i].x; + cur.y = pt[k].y - pt[i].y; - /* see if current constraint is violated */ - if (xprod (constraint[0], cur) < 0 - || xprod (constraint[1], cur) > 0) - { - goto constraint_viol; - } + /* see if current constraint is violated */ + if (xprod(constraint[0], cur) < 0 || xprod(constraint[1], cur) > 0) { + goto constraint_viol; + } - /* else, update constraint */ - if (abs (cur.x) <= 1 && abs (cur.y) <= 1) - { - /* no constraint */ - } - else - { - off.x = - cur.x + ((cur.y >= 0 && (cur.y > 0 || cur.x < 0)) ? 1 : -1); - off.y = - cur.y + ((cur.x <= 0 && (cur.x < 0 || cur.y < 0)) ? 1 : -1); - if (xprod (constraint[0], off) >= 0) - { - constraint[0] = off; + /* else, update constraint */ + if (abs(cur.x) <= 1 && abs(cur.y) <= 1) { + /* no constraint */ + } + else { + off.x = cur.x + ((cur.y >= 0 && (cur.y > 0 || cur.x < 0)) ? 1 : -1); + off.y = cur.y + ((cur.x <= 0 && (cur.x < 0 || cur.y < 0)) ? 1 : -1); + if (xprod(constraint[0], off) >= 0) { + constraint[0] = off; + } + off.x = cur.x + ((cur.y <= 0 && (cur.y < 0 || cur.x < 0)) ? 1 : -1); + off.y = cur.y + ((cur.x >= 0 && (cur.x > 0 || cur.y < 0)) ? 1 : -1); + if (xprod(constraint[1], off) <= 0) { + constraint[1] = off; + } + } + k1 = k; + k = nc[k1]; + if (!cyclic(k, i, k1)) { + break; + } } - off.x = - cur.x + ((cur.y <= 0 && (cur.y < 0 || cur.x < 0)) ? 1 : -1); - off.y = - cur.y + ((cur.x >= 0 && (cur.x > 0 || cur.y < 0)) ? 1 : -1); - if (xprod (constraint[1], off) <= 0) - { - constraint[1] = off; + constraint_viol: + /* k1 was the last "corner" satisfying the current constraint, and + k is the first one violating it. We now need to find the last + point along k1..k which satisfied the constraint. */ + dk.x = sign(pt[k].x - pt[k1].x); + dk.y = sign(pt[k].y - pt[k1].y); + cur.x = pt[k1].x - pt[i].x; + cur.y = pt[k1].y - pt[i].y; + /* find largest integer j such that xprod(constraint[0], cur+j*dk) + >= 0 and xprod(constraint[1], cur+j*dk) <= 0. Use bilinearity + of xprod. */ + a = xprod(constraint[0], cur); + b = xprod(constraint[0], dk); + c = xprod(constraint[1], cur); + d = xprod(constraint[1], dk); + /* find largest integer j such that a+j*b>=0 and c+j*d<=0. This + can be solved with integer arithmetic. */ + j = INFTY; + if (b < 0) { + j = floordiv(a, -b); } - } - k1 = k; - k = nc[k1]; - if (!cyclic (k, i, k1)) - { - break; - } - } - constraint_viol: - /* k1 was the last "corner" satisfying the current constraint, and - k is the first one violating it. We now need to find the last - point along k1..k which satisfied the constraint. */ - dk.x = sign (pt[k].x - pt[k1].x); - dk.y = sign (pt[k].y - pt[k1].y); - cur.x = pt[k1].x - pt[i].x; - cur.y = pt[k1].y - pt[i].y; - /* find largest integer j such that xprod(constraint[0], cur+j*dk) - >= 0 and xprod(constraint[1], cur+j*dk) <= 0. Use bilinearity - of xprod. */ - a = xprod (constraint[0], cur); - b = xprod (constraint[0], dk); - c = xprod (constraint[1], cur); - d = xprod (constraint[1], dk); - /* find largest integer j such that a+j*b>=0 and c+j*d<=0. This - can be solved with integer arithmetic. */ - j = INFTY; - if (b < 0) - { - j = floordiv (a, -b); - } - if (d > 0) - { - j = min (j, floordiv (-c, d)); - } - pivk[i] = mod (k1 + j, n); - foundk: - ; - } /* for i */ + if (d > 0) { + j = min(j, floordiv(-c, d)); + } + pivk[i] = mod(k1 + j, n); + foundk: + ; + } /* for i */ - /* clean up: for each i, let lon[i] be the largest k such that for - all i' with i<=i'lon[n - 1] = j; - for (i = n - 2; i >= 0; i--) - { - if (cyclic (i + 1, pivk[i], j)) - { - j = pivk[i]; + j = pivk[n - 1]; + pp->lon[n - 1] = j; + for (i = n - 2; i >= 0; i--) { + if (cyclic(i + 1, pivk[i], j)) { + j = pivk[i]; + } + pp->lon[i] = j; } - pp->lon[i] = j; - } - for (i = n - 1; cyclic (mod (i + 1, n), j, pp->lon[i]); i--) - { - pp->lon[i] = j; - } + for (i = n - 1; cyclic(mod(i + 1, n), j, pp->lon[i]); i--) { + pp->lon[i] = j; + } - free (pivk); - free (nc); - return 0; + free(pivk); + free(nc); + return 0; malloc_error: - free (pivk); - free (nc); - return 1; + free(pivk); + free(nc); + return 1; } @@ -559,171 +495,155 @@ /* Auxiliary function: calculate the penalty of an edge from i to j in the given path. This needs the "lon" and "sum*" data. */ -static double -penalty3 (privpath_t * pp, int i, int j) +static double penalty3(privpath_t * pp, int i, int j) { - int n = pp->len; - point_t *pt = pp->pt; - sums_t *sums = pp->sums; + int n = pp->len; + point_t *pt = pp->pt; + sums_t *sums = pp->sums; - /* assume 0<=i= n) - { - j -= n; - r += 1; - } + if (j >= n) { + j -= n; + r += 1; + } - x = sums[j + 1].x - sums[i].x + r * sums[n].x; - y = sums[j + 1].y - sums[i].y + r * sums[n].y; - x2 = sums[j + 1].x2 - sums[i].x2 + r * sums[n].x2; - xy = sums[j + 1].xy - sums[i].xy + r * sums[n].xy; - y2 = sums[j + 1].y2 - sums[i].y2 + r * sums[n].y2; - k = j + 1 - i + r * n; + x = sums[j + 1].x - sums[i].x + r * sums[n].x; + y = sums[j + 1].y - sums[i].y + r * sums[n].y; + x2 = sums[j + 1].x2 - sums[i].x2 + r * sums[n].x2; + xy = sums[j + 1].xy - sums[i].xy + r * sums[n].xy; + y2 = sums[j + 1].y2 - sums[i].y2 + r * sums[n].y2; + k = j + 1 - i + r * n; - px = (pt[i].x + pt[j].x) / 2.0 - pt[0].x; - py = (pt[i].y + pt[j].y) / 2.0 - pt[0].y; - ey = (pt[j].x - pt[i].x); - ex = -(pt[j].y - pt[i].y); + px = (pt[i].x + pt[j].x) / 2.0 - pt[0].x; + py = (pt[i].y + pt[j].y) / 2.0 - pt[0].y; + ey = (pt[j].x - pt[i].x); + ex = -(pt[j].y - pt[i].y); - a = ((x2 - 2 * x * px) / k + px * px); - b = ((xy - x * py - y * px) / k + px * py); - c = ((y2 - 2 * y * py) / k + py * py); + a = ((x2 - 2 * x * px) / k + px * px); + b = ((xy - x * py - y * px) / k + px * py); + c = ((y2 - 2 * y * py) / k + py * py); - s = ex * ex * a + 2 * ex * ey * b + ey * ey * c; + s = ex * ex * a + 2 * ex * ey * b + ey * ey * c; - return sqrt (s); + return sqrt(s); } /* find the optimal polygon. Fill in the m and po components. Return 1 on failure with errno set, else 0. Non-cyclic version: assumes i=0 is in the polygon. Fixme: ### implement cyclic version. */ -static int -bestpolygon (privpath_t * pp) +static int bestpolygon(privpath_t * pp) { - int i, j, m, k; - int n = pp->len; - double *pen = NULL; /* pen[n+1]: penalty vector */ - int *prev = NULL; /* prev[n+1]: best path pointer vector */ - int *clip0 = NULL; /* clip0[n]: longest segment pointer, non-cyclic */ - int *clip1 = NULL; /* clip1[n+1]: backwards segment pointer, non-cyclic */ - int *seg0 = NULL; /* seg0[m+1]: forward segment bounds, m<=n */ - int *seg1 = NULL; /* seg1[m+1]: backward segment bounds, m<=n */ - double thispen; - double best; - int c; + int i, j, m, k; + int n = pp->len; + double *pen = NULL; /* pen[n+1]: penalty vector */ + int *prev = NULL; /* prev[n+1]: best path pointer vector */ + int *clip0 = NULL; /* clip0[n]: longest segment pointer, non-cyclic */ + int *clip1 = NULL; /* clip1[n+1]: backwards segment pointer, non-cyclic */ + int *seg0 = NULL; /* seg0[m+1]: forward segment bounds, m<=n */ + int *seg1 = NULL; /* seg1[m+1]: backward segment bounds, m<=n */ + double thispen; + double best; + int c; - SAFE_MALLOC (pen, n + 1, double); - SAFE_MALLOC (prev, n + 1, int); - SAFE_MALLOC (clip0, n, int); - SAFE_MALLOC (clip1, n + 1, int); - SAFE_MALLOC (seg0, n + 1, int); - SAFE_MALLOC (seg1, n + 1, int); + SAFE_MALLOC(pen, n + 1, double); + SAFE_MALLOC(prev, n + 1, int); + SAFE_MALLOC(clip0, n, int); + SAFE_MALLOC(clip1, n + 1, int); + SAFE_MALLOC(seg0, n + 1, int); + SAFE_MALLOC(seg1, n + 1, int); - /* calculate clipped paths */ - for (i = 0; i < n; i++) - { - c = mod (pp->lon[mod (i - 1, n)] - 1, n); - if (c == i) - { - c = mod (i + 1, n); + /* calculate clipped paths */ + for (i = 0; i < n; i++) { + c = mod(pp->lon[mod(i - 1, n)] - 1, n); + if (c == i) { + c = mod(i + 1, n); + } + if (c < i) { + clip0[i] = n; + } + else { + clip0[i] = c; + } } - if (c < i) - { - clip0[i] = n; + + /* calculate backwards path clipping, non-cyclic. j <= clip0[i] iff + clip1[j] <= i, for i,j=0..n. */ + j = 1; + for (i = 0; i < n; i++) { + while (j <= clip0[i]) { + clip1[j] = i; + j++; + } } - else - { - clip0[i] = c; + + /* calculate seg0[j] = longest path from 0 with j segments */ + i = 0; + for (j = 0; i < n; j++) { + seg0[j] = i; + i = clip0[i]; } - } + seg0[j] = n; + m = j; - /* calculate backwards path clipping, non-cyclic. j <= clip0[i] iff - clip1[j] <= i, for i,j=0..n. */ - j = 1; - for (i = 0; i < n; i++) - { - while (j <= clip0[i]) - { - clip1[j] = i; - j++; + /* calculate seg1[j] = longest path to n with m-j segments */ + i = n; + for (j = m; j > 0; j--) { + seg1[j] = i; + i = clip1[i]; } - } + seg1[0] = 0; - /* calculate seg0[j] = longest path from 0 with j segments */ - i = 0; - for (j = 0; i < n; j++) - { - seg0[j] = i; - i = clip0[i]; - } - seg0[j] = n; - m = j; - - /* calculate seg1[j] = longest path to n with m-j segments */ - i = n; - for (j = m; j > 0; j--) - { - seg1[j] = i; - i = clip1[i]; - } - seg1[0] = 0; - - /* now find the shortest path with m segments, based on penalty3 */ - /* note: the outer 2 loops jointly have at most n interations, thus - the worst-case behavior here is quadratic. In practice, it is - close to linear since the inner loop tends to be short. */ - pen[0] = 0; - for (j = 1; j <= m; j++) - { - for (i = seg1[j]; i <= seg0[j]; i++) - { - best = -1; - for (k = seg0[j - 1]; k >= clip1[i]; k--) - { - thispen = penalty3 (pp, k, i) + pen[k]; - if (best < 0 || thispen < best) - { - prev[i] = k; - best = thispen; + /* now find the shortest path with m segments, based on penalty3 */ + /* note: the outer 2 loops jointly have at most n interations, thus + the worst-case behavior here is quadratic. In practice, it is + close to linear since the inner loop tends to be short. */ + pen[0] = 0; + for (j = 1; j <= m; j++) { + for (i = seg1[j]; i <= seg0[j]; i++) { + best = -1; + for (k = seg0[j - 1]; k >= clip1[i]; k--) { + thispen = penalty3(pp, k, i) + pen[k]; + if (best < 0 || thispen < best) { + prev[i] = k; + best = thispen; + } + } + pen[i] = best; } - } - pen[i] = best; } - } - pp->m = m; - SAFE_MALLOC (pp->po, m, int); + pp->m = m; + SAFE_MALLOC(pp->po, m, int); - /* read off shortest path */ - for (i = n, j = m - 1; i > 0; j--) - { - i = prev[i]; - pp->po[j] = i; - } + /* read off shortest path */ + for (i = n, j = m - 1; i > 0; j--) { + i = prev[i]; + pp->po[j] = i; + } - free (pen); - free (prev); - free (clip0); - free (clip1); - free (seg0); - free (seg1); - return 0; + free(pen); + free(prev); + free(clip0); + free(clip1); + free(seg0); + free(seg1); + return 0; malloc_error: - free (pen); - free (prev); - free (clip0); - free (clip1); - free (seg0); - free (seg1); - return 1; + free(pen); + free(prev); + free(clip0); + free(clip1); + free(seg0); + free(seg1); + return 1; } /* ---------------------------------------------------------------------- */ @@ -734,234 +654,204 @@ if it lies outside. Return 1 with errno set on error; 0 on success. */ -static int -adjust_vertices (privpath_t * pp) +static int adjust_vertices(privpath_t * pp) { - int m = pp->m; - int *po = pp->po; - int n = pp->len; - point_t *pt = pp->pt; - int x0 = pp->x0; - int y0 = pp->y0; + int m = pp->m; + int *po = pp->po; + int n = pp->len; + point_t *pt = pp->pt; + int x0 = pp->x0; + int y0 = pp->y0; - dpoint_t *ctr = NULL; /* ctr[m] */ - dpoint_t *dir = NULL; /* dir[m] */ - quadform_t *q = NULL; /* q[m] */ - double v[3]; - double d; - int i, j, k, l; - dpoint_t s; - int r; + dpoint_t *ctr = NULL; /* ctr[m] */ + dpoint_t *dir = NULL; /* dir[m] */ + quadform_t *q = NULL; /* q[m] */ + double v[3]; + double d; + int i, j, k, l; + dpoint_t s; + int r; - SAFE_MALLOC (ctr, m, dpoint_t); - SAFE_MALLOC (dir, m, dpoint_t); - SAFE_MALLOC (q, m, quadform_t); + SAFE_MALLOC(ctr, m, dpoint_t); + SAFE_MALLOC(dir, m, dpoint_t); + SAFE_MALLOC(q, m, quadform_t); - r = privcurve_init (&pp->curve, m); - if (r) - { - goto malloc_error; - } + r = privcurve_init(&pp->curve, m); + if (r) { + goto malloc_error; + } - /* calculate "optimal" point-slope representation for each line - segment */ - for (i = 0; i < m; i++) - { - j = po[mod (i + 1, m)]; - j = mod (j - po[i], n) + po[i]; - pointslope (pp, po[i], j, &ctr[i], &dir[i]); - } + /* calculate "optimal" point-slope representation for each line + segment */ + for (i = 0; i < m; i++) { + j = po[mod(i + 1, m)]; + j = mod(j - po[i], n) + po[i]; + pointslope(pp, po[i], j, &ctr[i], &dir[i]); + } - /* represent each line segment as a singular quadratic form; the - distance of a point (x,y) from the line segment will be - (x,y,1)Q(x,y,1)^t, where Q=q[i]. */ - for (i = 0; i < m; i++) - { - d = sq (dir[i].x) + sq (dir[i].y); - if (d == 0.0) - { - for (j = 0; j < 3; j++) - { - for (k = 0; k < 3; k++) - { - q[i][j][k] = 0; + /* represent each line segment as a singular quadratic form; the + distance of a point (x,y) from the line segment will be + (x,y,1)Q(x,y,1)^t, where Q=q[i]. */ + for (i = 0; i < m; i++) { + d = sq(dir[i].x) + sq(dir[i].y); + if (d == 0.0) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 3; k++) { + q[i][j][k] = 0; + } + } } - } - } - else - { - v[0] = dir[i].y; - v[1] = -dir[i].x; - v[2] = -v[1] * ctr[i].y - v[0] * ctr[i].x; - for (l = 0; l < 3; l++) - { - for (k = 0; k < 3; k++) - { - q[i][l][k] = v[l] * v[k] / d; + else { + v[0] = dir[i].y; + v[1] = -dir[i].x; + v[2] = -v[1] * ctr[i].y - v[0] * ctr[i].x; + for (l = 0; l < 3; l++) { + for (k = 0; k < 3; k++) { + q[i][l][k] = v[l] * v[k] / d; + } + } } - } } - } - /* now calculate the "intersections" of consecutive segments. - Instead of using the actual intersection, we find the point - within a given unit square which minimizes the square distance to - the two lines. */ - for (i = 0; i < m; i++) - { - quadform_t Q; - dpoint_t w; - double dx, dy; - double det; - double min, cand; /* minimum and candidate for minimum of quad. form */ - double xmin, ymin; /* coordinates of minimum */ - int z; + /* now calculate the "intersections" of consecutive segments. + Instead of using the actual intersection, we find the point + within a given unit square which minimizes the square distance to + the two lines. */ + for (i = 0; i < m; i++) { + quadform_t Q; + dpoint_t w; + double dx, dy; + double det; + double min, cand; /* minimum and candidate for minimum of quad. form */ + double xmin, ymin; /* coordinates of minimum */ + int z; - /* let s be the vertex, in coordinates relative to x0/y0 */ - s.x = pt[po[i]].x - x0; - s.y = pt[po[i]].y - y0; + /* let s be the vertex, in coordinates relative to x0/y0 */ + s.x = pt[po[i]].x - x0; + s.y = pt[po[i]].y - y0; - /* intersect segments i-1 and i */ + /* intersect segments i-1 and i */ - j = mod (i - 1, m); + j = mod(i - 1, m); - /* add quadratic forms */ - for (l = 0; l < 3; l++) - { - for (k = 0; k < 3; k++) - { - Q[l][k] = q[j][l][k] + q[i][l][k]; - } - } + /* add quadratic forms */ + for (l = 0; l < 3; l++) { + for (k = 0; k < 3; k++) { + Q[l][k] = q[j][l][k] + q[i][l][k]; + } + } - while (1) - { - /* minimize the quadratic form Q on the unit square */ - /* find intersection */ + while (1) { + /* minimize the quadratic form Q on the unit square */ + /* find intersection */ #ifdef HAVE_GCC_LOOP_BUG - /* work around gcc bug #12243 */ - free (NULL); + /* work around gcc bug #12243 */ + free(NULL); #endif - det = Q[0][0] * Q[1][1] - Q[0][1] * Q[1][0]; - if (det != 0.0) - { - w.x = (-Q[0][2] * Q[1][1] + Q[1][2] * Q[0][1]) / det; - w.y = (Q[0][2] * Q[1][0] - Q[1][2] * Q[0][0]) / det; - break; - } + det = Q[0][0] * Q[1][1] - Q[0][1] * Q[1][0]; + if (det != 0.0) { + w.x = (-Q[0][2] * Q[1][1] + Q[1][2] * Q[0][1]) / det; + w.y = (Q[0][2] * Q[1][0] - Q[1][2] * Q[0][0]) / det; + break; + } - /* matrix is singular - lines are parallel. Add another, - orthogonal axis, through the center of the unit square */ - if (Q[0][0] > Q[1][1]) - { - v[0] = -Q[0][1]; - v[1] = Q[0][0]; - } - else if (Q[1][1]) - { - v[0] = -Q[1][1]; - v[1] = Q[1][0]; - } - else - { - v[0] = 1; - v[1] = 0; - } - d = sq (v[0]) + sq (v[1]); - v[2] = -v[1] * s.y - v[0] * s.x; - for (l = 0; l < 3; l++) - { - for (k = 0; k < 3; k++) - { - Q[l][k] += v[l] * v[k] / d; + /* matrix is singular - lines are parallel. Add another, + orthogonal axis, through the center of the unit square */ + if (Q[0][0] > Q[1][1]) { + v[0] = -Q[0][1]; + v[1] = Q[0][0]; + } + else if (Q[1][1]) { + v[0] = -Q[1][1]; + v[1] = Q[1][0]; + } + else { + v[0] = 1; + v[1] = 0; + } + d = sq(v[0]) + sq(v[1]); + v[2] = -v[1] * s.y - v[0] * s.x; + for (l = 0; l < 3; l++) { + for (k = 0; k < 3; k++) { + Q[l][k] += v[l] * v[k] / d; + } + } } - } - } - dx = fabs (w.x - s.x); - dy = fabs (w.y - s.y); - if (dx <= .5 && dy <= .5) - { - pp->curve.vertex[i].x = w.x + x0; - pp->curve.vertex[i].y = w.y + y0; - continue; - } + dx = fabs(w.x - s.x); + dy = fabs(w.y - s.y); + if (dx <= .5 && dy <= .5) { + pp->curve.vertex[i].x = w.x + x0; + pp->curve.vertex[i].y = w.y + y0; + continue; + } - /* the minimum was not in the unit square; now minimize quadratic - on boundary of square */ - min = quadform (Q, s); - xmin = s.x; - ymin = s.y; + /* the minimum was not in the unit square; now minimize quadratic + on boundary of square */ + min = quadform(Q, s); + xmin = s.x; + ymin = s.y; - if (Q[0][0] == 0.0) - { - goto fixx; - } - for (z = 0; z < 2; z++) - { /* value of the y-coordinate */ - w.y = s.y - 0.5 + z; - w.x = -(Q[0][1] * w.y + Q[0][2]) / Q[0][0]; - dx = fabs (w.x - s.x); - cand = quadform (Q, w); - if (dx <= .5 && cand < min) - { - min = cand; - xmin = w.x; - ymin = w.y; - } - } - fixx: - if (Q[1][1] == 0.0) - { - goto corners; - } - for (z = 0; z < 2; z++) - { /* value of the x-coordinate */ - w.x = s.x - 0.5 + z; - w.y = -(Q[1][0] * w.x + Q[1][2]) / Q[1][1]; - dy = fabs (w.y - s.y); - cand = quadform (Q, w); - if (dy <= .5 && cand < min) - { - min = cand; - xmin = w.x; - ymin = w.y; - } - } - corners: - /* check four corners */ - for (l = 0; l < 2; l++) - { - for (k = 0; k < 2; k++) - { - w.x = s.x - 0.5 + l; - w.y = s.y - 0.5 + k; - cand = quadform (Q, w); - if (cand < min) - { - min = cand; - xmin = w.x; - ymin = w.y; + if (Q[0][0] == 0.0) { + goto fixx; } - } + for (z = 0; z < 2; z++) { /* value of the y-coordinate */ + w.y = s.y - 0.5 + z; + w.x = -(Q[0][1] * w.y + Q[0][2]) / Q[0][0]; + dx = fabs(w.x - s.x); + cand = quadform(Q, w); + if (dx <= .5 && cand < min) { + min = cand; + xmin = w.x; + ymin = w.y; + } + } + fixx: + if (Q[1][1] == 0.0) { + goto corners; + } + for (z = 0; z < 2; z++) { /* value of the x-coordinate */ + w.x = s.x - 0.5 + z; + w.y = -(Q[1][0] * w.x + Q[1][2]) / Q[1][1]; + dy = fabs(w.y - s.y); + cand = quadform(Q, w); + if (dy <= .5 && cand < min) { + min = cand; + xmin = w.x; + ymin = w.y; + } + } + corners: + /* check four corners */ + for (l = 0; l < 2; l++) { + for (k = 0; k < 2; k++) { + w.x = s.x - 0.5 + l; + w.y = s.y - 0.5 + k; + cand = quadform(Q, w); + if (cand < min) { + min = cand; + xmin = w.x; + ymin = w.y; + } + } + } + + pp->curve.vertex[i].x = xmin + x0; + pp->curve.vertex[i].y = ymin + y0; + continue; } - pp->curve.vertex[i].x = xmin + x0; - pp->curve.vertex[i].y = ymin + y0; - continue; - } + free(ctr); + free(dir); + free(q); + return 0; - free (ctr); - free (dir); - free (q); - return 0; - malloc_error: - free (ctr); - free (dir); - free (q); - return 1; + free(ctr); + free(dir); + free(q); + return 1; } /* ---------------------------------------------------------------------- */ @@ -969,78 +859,67 @@ /* Always succeeds and returns 0 */ static int -ATTRIBUTE_UNUSED smooth (privcurve_t * curve, int sign, double alphamax) +ATTRIBUTE_UNUSED smooth(privcurve_t * curve, int sign, double alphamax) { - int m = curve->n; + int m = curve->n; - int i, j, k; - double dd, denom, alpha; - dpoint_t p2, p3, p4; + int i, j, k; + double dd, denom, alpha; + dpoint_t p2, p3, p4; - if (sign == '-') - { - /* reverse orientation of negative paths */ - for (i = 0, j = m - 1; i < j; i++, j--) - { - dpoint_t tmp; - tmp = curve->vertex[i]; - curve->vertex[i] = curve->vertex[j]; - curve->vertex[j] = tmp; + if (sign == '-') { + /* reverse orientation of negative paths */ + for (i = 0, j = m - 1; i < j; i++, j--) { + dpoint_t tmp; + tmp = curve->vertex[i]; + curve->vertex[i] = curve->vertex[j]; + curve->vertex[j] = tmp; + } } - } - /* examine each vertex and find its best fit */ - for (i = 0; i < m; i++) - { - j = mod (i + 1, m); - k = mod (i + 2, m); - p4 = interval (1 / 2.0, curve->vertex[k], curve->vertex[j]); + /* examine each vertex and find its best fit */ + for (i = 0; i < m; i++) { + j = mod(i + 1, m); + k = mod(i + 2, m); + p4 = interval(1 / 2.0, curve->vertex[k], curve->vertex[j]); - denom = ddenom (curve->vertex[i], curve->vertex[k]); - if (denom != 0.0) - { - dd = - dpara (curve->vertex[i], curve->vertex[j], - curve->vertex[k]) / denom; - dd = fabs (dd); - alpha = dd > 1 ? (1 - 1.0 / dd) : 0; - alpha = alpha / 0.75; - } - else - { - alpha = 4 / 3.0; - } - curve->alpha0[j] = alpha; /* remember "original" value of alpha */ + denom = ddenom(curve->vertex[i], curve->vertex[k]); + if (denom != 0.0) { + dd = dpara(curve->vertex[i], curve->vertex[j], curve->vertex[k]) / denom; + dd = fabs(dd); + alpha = dd > 1 ? (1 - 1.0 / dd) : 0; + alpha = alpha / 0.75; + } + else { + alpha = 4 / 3.0; + } + curve->alpha0[j] = alpha; /* remember "original" value of alpha */ - if (alpha > alphamax) - { /* pointed corner */ - curve->tag[j] = POTRACE_CORNER; - curve->c[j][1] = curve->vertex[j]; - curve->c[j][2] = p4; + if (alpha > alphamax) { /* pointed corner */ + curve->tag[j] = POTRACE_CORNER; + curve->c[j][1] = curve->vertex[j]; + curve->c[j][2] = p4; + } + else { + if (alpha < 0.55) { + alpha = 0.55; + } + else if (alpha > 1) { + alpha = 1; + } + p2 = interval(.5 + .5 * alpha, curve->vertex[i], curve->vertex[j]); + p3 = interval(.5 + .5 * alpha, curve->vertex[k], curve->vertex[j]); + curve->tag[j] = POTRACE_CURVETO; + curve->c[j][0] = p2; + curve->c[j][1] = p3; + curve->c[j][2] = p4; + } + curve->alpha[j] = alpha; /* store the "cropped" value of alpha */ + curve->beta[j] = 0.5; } - else - { - if (alpha < 0.55) - { - alpha = 0.55; - } - else if (alpha > 1) - { - alpha = 1; - } - p2 = interval (.5 + .5 * alpha, curve->vertex[i], curve->vertex[j]); - p3 = interval (.5 + .5 * alpha, curve->vertex[k], curve->vertex[j]); - curve->tag[j] = POTRACE_CURVETO; - curve->c[j][0] = p2; - curve->c[j][1] = p3; - curve->c[j][2] = p4; - } - curve->alpha[j] = alpha; /* store the "cropped" value of alpha */ - curve->beta[j] = 0.5; - } - curve->alphacurve = 1; + curve->alphacurve = 1; - return 0; + return 0; } /* ---------------------------------------------------------------------- */ @@ -1047,12 +926,11 @@ /* Stage 5: Curve optimization (Sec. 2.4) */ /* a private type for the result of opti_penalty */ -struct opti_s -{ - double pen; /* penalty */ - dpoint_t c[2]; /* curve parameters */ - double t, s; /* curve parameters */ - double alpha; /* curve parameter */ +struct opti_s { + double pen; /* penalty */ + dpoint_t c[2]; /* curve parameters */ + double t, s; /* curve parameters */ + double alpha; /* curve parameter */ }; typedef struct opti_s opti_t; @@ -1059,175 +937,145 @@ /* calculate best fit from i+.5 to j+.5. Assume icurve.n; - int k, k1, k2, conv, i1; - double area, alpha, d, d1, d2; - dpoint_t p0, p1, p2, p3, pt; - double A, R, A1, A2, A3, A4; - double s, t; + int m = pp->curve.n; + int k, k1, k2, conv, i1; + double area, alpha, d, d1, d2; + dpoint_t p0, p1, p2, p3, pt; + double A, R, A1, A2, A3, A4; + double s, t; - /* check convexity, corner-freeness, and maximum bend < 179 degrees */ + /* check convexity, corner-freeness, and maximum bend < 179 degrees */ - if (i == j) - { /* sanity - a full loop can never be an opticurve */ - return 1; - } + if (i == j) { /* sanity - a full loop can never be an opticurve */ + return 1; + } - k = i; - i1 = mod (i + 1, m); - k1 = mod (k + 1, m); - conv = convc[k1]; - if (conv == 0) - { - return 1; - } - d = ddist (pp->curve.vertex[i], pp->curve.vertex[i1]); - for (k = k1; k != j; k = k1) - { - k1 = mod (k + 1, m); - k2 = mod (k + 2, m); - if (convc[k1] != conv) - { - return 1; + k = i; + i1 = mod(i + 1, m); + k1 = mod(k + 1, m); + conv = convc[k1]; + if (conv == 0) { + return 1; } - if (sign - (cprod - (pp->curve.vertex[i], pp->curve.vertex[i1], pp->curve.vertex[k1], - pp->curve.vertex[k2])) != conv) - { - return 1; + d = ddist(pp->curve.vertex[i], pp->curve.vertex[i1]); + for (k = k1; k != j; k = k1) { + k1 = mod(k + 1, m); + k2 = mod(k + 2, m); + if (convc[k1] != conv) { + return 1; + } + if (sign(cprod(pp->curve.vertex[i], pp->curve.vertex[i1], pp->curve.vertex[k1], pp->curve.vertex[k2])) != conv) { + return 1; + } + if (iprod1 + (pp->curve.vertex[i], pp->curve.vertex[i1], pp->curve.vertex[k1], + pp->curve.vertex[k2]) < d * ddist(pp->curve.vertex[k1], pp->curve.vertex[k2]) * COS179) { + return 1; + } } - if (iprod1 - (pp->curve.vertex[i], pp->curve.vertex[i1], pp->curve.vertex[k1], - pp->curve.vertex[k2]) < d * ddist (pp->curve.vertex[k1], - pp->curve.vertex[k2]) * COS179) - { - return 1; - } - } - /* the curve we're working in: */ - p0 = pp->curve.c[mod (i, m)][2]; - p1 = pp->curve.vertex[mod (i + 1, m)]; - p2 = pp->curve.vertex[mod (j, m)]; - p3 = pp->curve.c[mod (j, m)][2]; + /* the curve we're working in: */ + p0 = pp->curve.c[mod(i, m)][2]; + p1 = pp->curve.vertex[mod(i + 1, m)]; + p2 = pp->curve.vertex[mod(j, m)]; + p3 = pp->curve.c[mod(j, m)][2]; - /* determine its area */ - area = areac[j] - areac[i]; - area -= - dpara (pp->curve.vertex[0], pp->curve.c[i][2], pp->curve.c[j][2]) / 2; - if (i >= j) - { - area += areac[m]; - } + /* determine its area */ + area = areac[j] - areac[i]; + area -= dpara(pp->curve.vertex[0], pp->curve.c[i][2], pp->curve.c[j][2]) / 2; + if (i >= j) { + area += areac[m]; + } - /* find intersection o of p0p1 and p2p3. Let t,s such that o = - interval(t,p0,p1) = interval(s,p3,p2). Let A be the area of the - triangle (p0,o,p3). */ + /* find intersection o of p0p1 and p2p3. Let t,s such that o = + interval(t,p0,p1) = interval(s,p3,p2). Let A be the area of the + triangle (p0,o,p3). */ - A1 = dpara (p0, p1, p2); - A2 = dpara (p0, p1, p3); - A3 = dpara (p0, p2, p3); - /* A4 = dpara(p1, p2, p3); */ - A4 = A1 + A3 - A2; + A1 = dpara(p0, p1, p2); + A2 = dpara(p0, p1, p3); + A3 = dpara(p0, p2, p3); + /* A4 = dpara(p1, p2, p3); */ + A4 = A1 + A3 - A2; - if (A2 == A1) - { /* this should never happen */ - return 1; - } + if (A2 == A1) { /* this should never happen */ + return 1; + } - t = A3 / (A3 - A4); - s = A2 / (A2 - A1); - A = A2 * t / 2.0; + t = A3 / (A3 - A4); + s = A2 / (A2 - A1); + A = A2 * t / 2.0; - if (A == 0.0) - { /* this should never happen */ - return 1; - } + if (A == 0.0) { /* this should never happen */ + return 1; + } - R = area / A; /* relative area */ - alpha = 2 - sqrt (4 - R / 0.3); /* overall alpha for p0-o-p3 curve */ + R = area / A; /* relative area */ + alpha = 2 - sqrt(4 - R / 0.3); /* overall alpha for p0-o-p3 curve */ - res->c[0] = interval (t * alpha, p0, p1); - res->c[1] = interval (s * alpha, p3, p2); - res->alpha = alpha; - res->t = t; - res->s = s; + res->c[0] = interval(t * alpha, p0, p1); + res->c[1] = interval(s * alpha, p3, p2); + res->alpha = alpha; + res->t = t; + res->s = s; - p1 = res->c[0]; - p2 = res->c[1]; /* the proposed curve is now (p0,p1,p2,p3) */ + p1 = res->c[0]; + p2 = res->c[1]; /* the proposed curve is now (p0,p1,p2,p3) */ - res->pen = 0; + res->pen = 0; - /* calculate penalty */ - /* check tangency with edges */ - for (k = mod (i + 1, m); k != j; k = k1) - { - k1 = mod (k + 1, m); - t = tangent (p0, p1, p2, p3, pp->curve.vertex[k], pp->curve.vertex[k1]); - if (t < -.5) - { - return 1; + /* calculate penalty */ + /* check tangency with edges */ + for (k = mod(i + 1, m); k != j; k = k1) { + k1 = mod(k + 1, m); + t = tangent(p0, p1, p2, p3, pp->curve.vertex[k], pp->curve.vertex[k1]); + if (t < -.5) { + return 1; + } + pt = bezier(t, p0, p1, p2, p3); + d = ddist(pp->curve.vertex[k], pp->curve.vertex[k1]); + if (d == 0.0) { /* this should never happen */ + return 1; + } + d1 = dpara(pp->curve.vertex[k], pp->curve.vertex[k1], pt) / d; + if (fabs(d1) > opttolerance) { + return 1; + } + if (iprod(pp->curve.vertex[k], pp->curve.vertex[k1], pt) < 0 || iprod(pp->curve.vertex[k1], pp->curve.vertex[k], pt) < 0) { + return 1; + } + res->pen += sq(d1); } - pt = bezier (t, p0, p1, p2, p3); - d = ddist (pp->curve.vertex[k], pp->curve.vertex[k1]); - if (d == 0.0) - { /* this should never happen */ - return 1; - } - d1 = dpara (pp->curve.vertex[k], pp->curve.vertex[k1], pt) / d; - if (fabs (d1) > opttolerance) - { - return 1; - } - if (iprod (pp->curve.vertex[k], pp->curve.vertex[k1], pt) < 0 - || iprod (pp->curve.vertex[k1], pp->curve.vertex[k], pt) < 0) - { - return 1; - } - res->pen += sq (d1); - } - /* check corners */ - for (k = i; k != j; k = k1) - { - k1 = mod (k + 1, m); - t = tangent (p0, p1, p2, p3, pp->curve.c[k][2], pp->curve.c[k1][2]); - if (t < -.5) - { - return 1; + /* check corners */ + for (k = i; k != j; k = k1) { + k1 = mod(k + 1, m); + t = tangent(p0, p1, p2, p3, pp->curve.c[k][2], pp->curve.c[k1][2]); + if (t < -.5) { + return 1; + } + pt = bezier(t, p0, p1, p2, p3); + d = ddist(pp->curve.c[k][2], pp->curve.c[k1][2]); + if (d == 0.0) { /* this should never happen */ + return 1; + } + d1 = dpara(pp->curve.c[k][2], pp->curve.c[k1][2], pt) / d; + d2 = dpara(pp->curve.c[k][2], pp->curve.c[k1][2], pp->curve.vertex[k1]) / d; + d2 *= 0.75 * pp->curve.alpha[k1]; + if (d2 < 0) { + d1 = -d1; + d2 = -d2; + } + if (d1 < d2 - opttolerance) { + return 1; + } + if (d1 < d2) { + res->pen += sq(d1 - d2); + } } - pt = bezier (t, p0, p1, p2, p3); - d = ddist (pp->curve.c[k][2], pp->curve.c[k1][2]); - if (d == 0.0) - { /* this should never happen */ - return 1; - } - d1 = dpara (pp->curve.c[k][2], pp->curve.c[k1][2], pt) / d; - d2 = - dpara (pp->curve.c[k][2], pp->curve.c[k1][2], - pp->curve.vertex[k1]) / d; - d2 *= 0.75 * pp->curve.alpha[k1]; - if (d2 < 0) - { - d1 = -d1; - d2 = -d2; - } - if (d1 < d2 - opttolerance) - { - return 1; - } - if (d1 < d2) - { - res->pen += sq (d1 - d2); - } - } - return 0; + return 0; } /* optimize the path p, replacing sequences of Bezier segments by a @@ -1234,233 +1082,198 @@ single segment when possible. Return 0 on success, 1 with errno set on failure. */ static int -ATTRIBUTE_UNUSED opticurve (privpath_t * pp, double opttolerance) +ATTRIBUTE_UNUSED opticurve(privpath_t * pp, double opttolerance) { - int m = pp->curve.n; - int *pt = NULL; /* pt[m+1] */ - double *pen = NULL; /* pen[m+1] */ - int *len = NULL; /* len[m+1] */ - opti_t *opt = NULL; /* opt[m+1] */ - int om; - int i, j, r; - opti_t o; - dpoint_t p0; - int i1; - double area; - double alpha; - double *s = NULL; - double *t = NULL; + int m = pp->curve.n; + int *pt = NULL; /* pt[m+1] */ + double *pen = NULL; /* pen[m+1] */ + int *len = NULL; /* len[m+1] */ + opti_t *opt = NULL; /* opt[m+1] */ + int om; + int i, j, r; + opti_t o; + dpoint_t p0; + int i1; + double area; + double alpha; + double *s = NULL; + double *t = NULL; - int *convc = NULL; /* conv[m]: pre-computed convexities */ - double *areac = NULL; /* cumarea[m+1]: cache for fast area computation */ + int *convc = NULL; /* conv[m]: pre-computed convexities */ + double *areac = NULL; /* cumarea[m+1]: cache for fast area computation */ - SAFE_MALLOC (pt, m + 1, int); - SAFE_MALLOC (pen, m + 1, double); - SAFE_MALLOC (len, m + 1, int); - SAFE_MALLOC (opt, m + 1, opti_t); - SAFE_MALLOC (convc, m, int); - SAFE_MALLOC (areac, m + 1, double); + SAFE_MALLOC(pt, m + 1, int); + SAFE_MALLOC(pen, m + 1, double); + SAFE_MALLOC(len, m + 1, int); + SAFE_MALLOC(opt, m + 1, opti_t); + SAFE_MALLOC(convc, m, int); + SAFE_MALLOC(areac, m + 1, double); - /* pre-calculate convexity: +1 = right turn, -1 = left turn, 0 = corner */ - for (i = 0; i < m; i++) - { - if (pp->curve.tag[i] == POTRACE_CURVETO) - { - convc[i] = - sign (dpara - (pp->curve.vertex[mod (i - 1, m)], pp->curve.vertex[i], - pp->curve.vertex[mod (i + 1, m)])); + /* pre-calculate convexity: +1 = right turn, -1 = left turn, 0 = corner */ + for (i = 0; i < m; i++) { + if (pp->curve.tag[i] == POTRACE_CURVETO) { + convc[i] = sign(dpara(pp->curve.vertex[mod(i - 1, m)], pp->curve.vertex[i], pp->curve.vertex[mod(i + 1, m)])); + } + else { + convc[i] = 0; + } } - else - { - convc[i] = 0; - } - } - /* pre-calculate areas */ - area = 0.0; - areac[0] = 0.0; - p0 = pp->curve.vertex[0]; - for (i = 0; i < m; i++) - { - i1 = mod (i + 1, m); - if (pp->curve.tag[i1] == POTRACE_CURVETO) - { - alpha = pp->curve.alpha[i1]; - area += - 0.3 * alpha * (4 - alpha) * dpara (pp->curve.c[i][2], - pp->curve.vertex[i1], - pp->curve.c[i1][2]) / 2; - area += dpara (p0, pp->curve.c[i][2], pp->curve.c[i1][2]) / 2; + /* pre-calculate areas */ + area = 0.0; + areac[0] = 0.0; + p0 = pp->curve.vertex[0]; + for (i = 0; i < m; i++) { + i1 = mod(i + 1, m); + if (pp->curve.tag[i1] == POTRACE_CURVETO) { + alpha = pp->curve.alpha[i1]; + area += 0.3 * alpha * (4 - alpha) * dpara(pp->curve.c[i][2], pp->curve.vertex[i1], pp->curve.c[i1][2]) / 2; + area += dpara(p0, pp->curve.c[i][2], pp->curve.c[i1][2]) / 2; + } + areac[i + 1] = area; } - areac[i + 1] = area; - } - pt[0] = -1; - pen[0] = 0; - len[0] = 0; + pt[0] = -1; + pen[0] = 0; + len[0] = 0; - /* Fixme: we always start from a fixed point -- should find the best - curve cyclically ### */ + /* Fixme: we always start from a fixed point -- should find the best + curve cyclically ### */ - for (j = 1; j <= m; j++) - { - /* calculate best path from 0 to j */ - pt[j] = j - 1; - pen[j] = pen[j - 1]; - len[j] = len[j - 1] + 1; + for (j = 1; j <= m; j++) { + /* calculate best path from 0 to j */ + pt[j] = j - 1; + pen[j] = pen[j - 1]; + len[j] = len[j - 1] + 1; - for (i = j - 2; i >= 0; i--) - { - r = - opti_penalty (pp, i, mod (j, m), &o, opttolerance, convc, areac); - if (r) - { - break; - } - if (len[j] > len[i] + 1 - || (len[j] == len[i] + 1 && pen[j] > pen[i] + o.pen)) - { - pt[j] = i; - pen[j] = pen[i] + o.pen; - len[j] = len[i] + 1; - opt[j] = o; - } + for (i = j - 2; i >= 0; i--) { + r = opti_penalty(pp, i, mod(j, m), &o, opttolerance, convc, areac); + if (r) { + break; + } + if (len[j] > len[i] + 1 || (len[j] == len[i] + 1 && pen[j] > pen[i] + o.pen)) { + pt[j] = i; + pen[j] = pen[i] + o.pen; + len[j] = len[i] + 1; + opt[j] = o; + } + } } - } - om = len[m]; - r = privcurve_init (&pp->ocurve, om); - if (r) - { - goto malloc_error; - } - SAFE_MALLOC (s, om, double); - SAFE_MALLOC (t, om, double); + om = len[m]; + r = privcurve_init(&pp->ocurve, om); + if (r) { + goto malloc_error; + } + SAFE_MALLOC(s, om, double); + SAFE_MALLOC(t, om, double); - j = m; - for (i = om - 1; i >= 0; i--) - { - if (pt[j] == j - 1) - { - pp->ocurve.tag[i] = pp->curve.tag[mod (j, m)]; - pp->ocurve.c[i][0] = pp->curve.c[mod (j, m)][0]; - pp->ocurve.c[i][1] = pp->curve.c[mod (j, m)][1]; - pp->ocurve.c[i][2] = pp->curve.c[mod (j, m)][2]; - pp->ocurve.vertex[i] = pp->curve.vertex[mod (j, m)]; - pp->ocurve.alpha[i] = pp->curve.alpha[mod (j, m)]; - pp->ocurve.alpha0[i] = pp->curve.alpha0[mod (j, m)]; - pp->ocurve.beta[i] = pp->curve.beta[mod (j, m)]; - s[i] = t[i] = 1.0; + j = m; + for (i = om - 1; i >= 0; i--) { + if (pt[j] == j - 1) { + pp->ocurve.tag[i] = pp->curve.tag[mod(j, m)]; + pp->ocurve.c[i][0] = pp->curve.c[mod(j, m)][0]; + pp->ocurve.c[i][1] = pp->curve.c[mod(j, m)][1]; + pp->ocurve.c[i][2] = pp->curve.c[mod(j, m)][2]; + pp->ocurve.vertex[i] = pp->curve.vertex[mod(j, m)]; + pp->ocurve.alpha[i] = pp->curve.alpha[mod(j, m)]; + pp->ocurve.alpha0[i] = pp->curve.alpha0[mod(j, m)]; + pp->ocurve.beta[i] = pp->curve.beta[mod(j, m)]; + s[i] = t[i] = 1.0; + } + else { + pp->ocurve.tag[i] = POTRACE_CURVETO; + pp->ocurve.c[i][0] = opt[j].c[0]; + pp->ocurve.c[i][1] = opt[j].c[1]; + pp->ocurve.c[i][2] = pp->curve.c[mod(j, m)][2]; + pp->ocurve.vertex[i] = interval(opt[j].s, pp->curve.c[mod(j, m)][2], pp->curve.vertex[mod(j, m)]); + pp->ocurve.alpha[i] = opt[j].alpha; + pp->ocurve.alpha0[i] = opt[j].alpha; + s[i] = opt[j].s; + t[i] = opt[j].t; + } + j = pt[j]; } - else - { - pp->ocurve.tag[i] = POTRACE_CURVETO; - pp->ocurve.c[i][0] = opt[j].c[0]; - pp->ocurve.c[i][1] = opt[j].c[1]; - pp->ocurve.c[i][2] = pp->curve.c[mod (j, m)][2]; - pp->ocurve.vertex[i] = - interval (opt[j].s, pp->curve.c[mod (j, m)][2], - pp->curve.vertex[mod (j, m)]); - pp->ocurve.alpha[i] = opt[j].alpha; - pp->ocurve.alpha0[i] = opt[j].alpha; - s[i] = opt[j].s; - t[i] = opt[j].t; + + /* calculate beta parameters */ + for (i = 0; i < om; i++) { + i1 = mod(i + 1, om); + pp->ocurve.beta[i] = s[i] / (s[i] + t[i1]); } - j = pt[j]; - } + pp->ocurve.alphacurve = 1; - /* calculate beta parameters */ - for (i = 0; i < om; i++) - { - i1 = mod (i + 1, om); - pp->ocurve.beta[i] = s[i] / (s[i] + t[i1]); - } - pp->ocurve.alphacurve = 1; + free(pt); + free(pen); + free(len); + free(opt); + free(s); + free(t); + free(convc); + free(areac); + return 0; - free (pt); - free (pen); - free (len); - free (opt); - free (s); - free (t); - free (convc); - free (areac); - return 0; - malloc_error: - free (pt); - free (pen); - free (len); - free (opt); - free (s); - free (t); - free (convc); - free (areac); - return 1; + free(pt); + free(pen); + free(len); + free(opt); + free(s); + free(t); + free(convc); + free(areac); + return 1; } /* ---------------------------------------------------------------------- */ -double -plotpolygon (privpath_t * pp, FILE * f, double scale) +double plotpolygon(privpath_t * pp, FILE * f, double scale) { - int i; - int m = pp->m; - int *po = pp->po; - point_t *pt = pp->pt; - /* double scale=1.0/dpi; */ - double dm = 0; + int i; + int m = pp->m; + int *po = pp->po; + point_t *pt = pp->pt; + /* double scale=1.0/dpi; */ + double dm = 0; - if (!m) - return 0; + if (!m) + return 0; - po = pp->po; - pt = pp->pt; + po = pp->po; + pt = pp->pt; - fprintf (f, "G0 X%f Y%f (start point)\n", pt[po[0]].x * scale, - pt[po[0]].y * scale); - fprintf (f, "G1 Z#101\n"); - for (i = 1; i < m; i++) - { - fprintf (f, "G1 X%f Y%f\n", pt[po[i]].x * scale, pt[po[i]].y * scale); - dm += - sqrt ((pt[po[i]].x - pt[po[i - 1]].x) * scale * (pt[po[i]].x - - pt[po[i - 1]].x) * - scale + (pt[po[i]].y - pt[po[i - 1]].y) * scale * (pt[po[i]].y - - pt[po - [i - - 1]].y) * - scale); - } - fprintf (f, "G1 X%f Y%f\n", pt[po[0]].x * scale, pt[po[0]].y * scale); - fprintf (f, "G0 Z#100\n"); - dm += - sqrt ((pt[po[m - 1]].x - pt[po[0]].x) * scale * (pt[po[m - 1]].x - - pt[po[0]].x) * scale + - (pt[po[m - 1]].y - pt[po[0]].y) * scale * (pt[po[m - 1]].y - - pt[po[0]].y) * scale); - fprintf (f, "(polygon end, distance %.2f)\n", dm); - return dm; + fprintf(f, "G0 X%f Y%f (start point)\n", pt[po[0]].x * scale, pt[po[0]].y * scale); + fprintf(f, "G1 Z#101\n"); + for (i = 1; i < m; i++) { + fprintf(f, "G1 X%f Y%f\n", pt[po[i]].x * scale, pt[po[i]].y * scale); + dm += + sqrt((pt[po[i]].x - pt[po[i - 1]].x) * scale * (pt[po[i]].x - + pt[po[i - 1]].x) * + scale + (pt[po[i]].y - pt[po[i - 1]].y) * scale * (pt[po[i]].y - pt[po[i - 1]].y) * scale); + } + fprintf(f, "G1 X%f Y%f\n", pt[po[0]].x * scale, pt[po[0]].y * scale); + fprintf(f, "G0 Z#100\n"); + dm += + sqrt((pt[po[m - 1]].x - pt[po[0]].x) * scale * (pt[po[m - 1]].x - + pt[po[0]].x) * scale + + (pt[po[m - 1]].y - pt[po[0]].y) * scale * (pt[po[m - 1]].y - pt[po[0]].y) * scale); + fprintf(f, "(polygon end, distance %.2f)\n", dm); + return dm; } #define TRY(x) if (x) goto try_error /* return distance on success, -1 on error with errno set. */ -double -process_path (path_t * plist, const potrace_param_t * param, - const potrace_bitmap_t * bm, FILE * f, double scale) +double process_path(path_t * plist, const potrace_param_t * param, const potrace_bitmap_t * bm, FILE * f, double scale) { - path_t *p; - double dm = 0; - int n = 0; - /* call downstream function with each path */ - list_forall (p, plist) - { - TRY (calc_sums (p->priv)); - TRY (calc_lon (p->priv)); - TRY (bestpolygon (p->priv)); - TRY (adjust_vertices (p->priv)); - fprintf (f, "(polygon %d)\n", ++n); - dm += plotpolygon (p->priv, f, scale); + path_t *p; + double dm = 0; + int n = 0; + /* call downstream function with each path */ + list_forall(p, plist) { + TRY(calc_sums(p->priv)); + TRY(calc_lon(p->priv)); + TRY(bestpolygon(p->priv)); + TRY(adjust_vertices(p->priv)); + fprintf(f, "(polygon %d)\n", ++n); + dm += plotpolygon(p->priv, f, scale); /* No need to extract curves TRY(smooth(&p->priv->curve, p->sign, param->alphamax)); if (param->opticurve) { @@ -1470,10 +1283,10 @@ p->priv->fcurve = &p->priv->curve; } privcurve_to_curve(p->priv->fcurve, &p->curve);*/ - } + } /* fprintf(f,"(end, total distance %.2fmm = %.2fin)\n",25.4*dm,dm); */ - return dm; + return dm; try_error: - return -1; + return -1; } Index: trunk/src/hid/gcode/trace.h =================================================================== --- trunk/src/hid/gcode/trace.h (revision 1021) +++ trunk/src/hid/gcode/trace.h (revision 1022) @@ -9,7 +9,6 @@ #include "potracelib.h" -double process_path (path_t * plist, const potrace_param_t * param, - const potrace_bitmap_t * bm, FILE * f, double scale); +double process_path(path_t * plist, const potrace_param_t * param, const potrace_bitmap_t * bm, FILE * f, double scale); #endif /* TRACE_H */ Index: trunk/src/hid/gerber/gerber.c =================================================================== --- trunk/src/hid/gerber/gerber.c (revision 1021) +++ trunk/src/hid/gerber/gerber.c (revision 1022) @@ -36,7 +36,7 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); #define CRASH fprintf(stderr, "HID error: pcb called unimplemented Gerber function %s.\n", __FUNCTION__); abort() @@ -44,25 +44,25 @@ /* Function prototypes */ /*----------------------------------------------------------------------------*/ -static HID_Attribute * gerber_get_export_options (int *n); -static void gerber_do_export (HID_Attr_Val * options); -static void gerber_parse_arguments (int *argc, char ***argv); -static int gerber_set_layer (const char *name, int group, int empty); -static hidGC gerber_make_gc (void); -static void gerber_destroy_gc (hidGC gc); -static void gerber_use_mask (int use_it); -static void gerber_set_color (hidGC gc, const char *name); -static void gerber_set_line_cap (hidGC gc, EndCapStyle style); -static void gerber_set_line_width (hidGC gc, Coord width); -static void gerber_set_draw_xor (hidGC gc, int _xor); -static void gerber_draw_line (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2); -static void gerber_draw_arc (hidGC gc, Coord cx, Coord cy, Coord width, Coord height, Angle start_angle, Angle delta_angle); -static void gerber_draw_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2); -static void gerber_fill_circle (hidGC gc, Coord cx, Coord cy, Coord radius); -static void gerber_fill_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2); -static void gerber_calibrate (double xval, double yval); -static void gerber_set_crosshair (int x, int y, int action); -static void gerber_fill_polygon (hidGC gc, int n_coords, Coord *x, Coord *y); +static HID_Attribute *gerber_get_export_options(int *n); +static void gerber_do_export(HID_Attr_Val * options); +static void gerber_parse_arguments(int *argc, char ***argv); +static int gerber_set_layer(const char *name, int group, int empty); +static hidGC gerber_make_gc(void); +static void gerber_destroy_gc(hidGC gc); +static void gerber_use_mask(int use_it); +static void gerber_set_color(hidGC gc, const char *name); +static void gerber_set_line_cap(hidGC gc, EndCapStyle style); +static void gerber_set_line_width(hidGC gc, Coord width); +static void gerber_set_draw_xor(hidGC gc, int _xor); +static void gerber_draw_line(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2); +static void gerber_draw_arc(hidGC gc, Coord cx, Coord cy, Coord width, Coord height, Angle start_angle, Angle delta_angle); +static void gerber_draw_rect(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2); +static void gerber_fill_circle(hidGC gc, Coord cx, Coord cy, Coord radius); +static void gerber_fill_rect(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2); +static void gerber_calibrate(double xval, double yval); +static void gerber_set_crosshair(int x, int y, int action); +static void gerber_fill_polygon(hidGC gc, int n_coords, Coord * x, Coord * y); /*----------------------------------------------------------------------------*/ /* Utility routines */ @@ -92,14 +92,13 @@ static int name_style; static LayerTypePtr outline_layer; -enum ApertureShape -{ - ROUND, /* Shaped like a circle */ - OCTAGON, /* octagonal shape */ - SQUARE, /* Shaped like a square */ - ROUNDCLEAR, /* clearance in negatives */ - SQUARECLEAR, - THERMAL /* negative thermal relief */ +enum ApertureShape { + ROUND, /* Shaped like a circle */ + OCTAGON, /* octagonal shape */ + SQUARE, /* Shaped like a square */ + ROUNDCLEAR, /* clearance in negatives */ + SQUARECLEAR, + THERMAL /* negative thermal relief */ }; typedef enum ApertureShape ApertureShape; @@ -107,19 +106,16 @@ dcode and macro numbers. */ #define DCODE_BASE 11 -typedef struct aperture -{ - int dCode; /* The RS-274X D code */ - Coord width; /* Size in pcb units */ - ApertureShape shape; /* ROUND/SQUARE etc */ - struct aperture *next; -} -Aperture; +typedef struct aperture { + int dCode; /* The RS-274X D code */ + Coord width; /* Size in pcb units */ + ApertureShape shape; /* ROUND/SQUARE etc */ + struct aperture *next; +} Aperture; -typedef struct -{ - Aperture *data; - int count; +typedef struct { + Aperture *data; + int count; } ApertureList; static ApertureList *layer_aptr_list; @@ -127,11 +123,10 @@ static int layer_list_max; static int layer_list_idx; -typedef struct -{ - Coord diam; - Coord x; - Coord y; +typedef struct { + Coord diam; + Coord x; + Coord y; } PendingDrills; PendingDrills *pending_drills = NULL; int n_pending_drills = 0, max_pending_drills = 0; @@ -139,7 +134,7 @@ /*----------------------------------------------------------------------------*/ /* Defined Constants */ /*----------------------------------------------------------------------------*/ -#define AUTO_OUTLINE_WIDTH MIL_TO_COORD(8) /* Auto-geneated outline width of 8 mils */ +#define AUTO_OUTLINE_WIDTH MIL_TO_COORD(8) /* Auto-geneated outline width of 8 mils */ /*----------------------------------------------------------------------------*/ /* Aperture Routines */ @@ -146,136 +141,122 @@ /*----------------------------------------------------------------------------*/ /* Initialize aperture list */ -static void -initApertureList (ApertureList *list) +static void initApertureList(ApertureList * list) { - list->data = NULL; - list->count = 0; + list->data = NULL; + list->count = 0; } -static void -deinitApertureList (ApertureList *list) +static void deinitApertureList(ApertureList * list) { - Aperture *search = list->data; - Aperture *next; - while (search) - { - next = search->next; - free(search); - search = next; - } - initApertureList (list); + Aperture *search = list->data; + Aperture *next; + while (search) { + next = search->next; + free(search); + search = next; + } + initApertureList(list); } static void resetApertures() { - int i; - for (i = 0; i < layer_list_max; ++i) - deinitApertureList (&layer_aptr_list[i]); - free (layer_aptr_list); - layer_aptr_list = NULL; - curr_aptr_list = NULL; - layer_list_max = 0; - layer_list_idx = 0; + int i; + for (i = 0; i < layer_list_max; ++i) + deinitApertureList(&layer_aptr_list[i]); + free(layer_aptr_list); + layer_aptr_list = NULL; + curr_aptr_list = NULL; + layer_list_max = 0; + layer_list_idx = 0; } /* Create and add a new aperture to the list */ -static Aperture * -addAperture (ApertureList *list, Coord width, ApertureShape shape) +static Aperture *addAperture(ApertureList * list, Coord width, ApertureShape shape) { - static int aperture_count; + static int aperture_count; - Aperture *app = (Aperture *) malloc (sizeof *app); - if (app == NULL) - return NULL; + Aperture *app = (Aperture *) malloc(sizeof *app); + if (app == NULL) + return NULL; - app->width = width; - app->shape = shape; - app->dCode = DCODE_BASE + aperture_count++; - app->next = list->data; + app->width = width; + app->shape = shape; + app->dCode = DCODE_BASE + aperture_count++; + app->next = list->data; - list->data = app; - ++list->count; + list->data = app; + ++list->count; - return app; + return app; } /* Fetch an aperture from the list with the specified * width/shape, creating a new one if none exists */ -static Aperture * -findAperture (ApertureList *list, Coord width, ApertureShape shape) +static Aperture *findAperture(ApertureList * list, Coord width, ApertureShape shape) { - Aperture *search; + Aperture *search; - /* we never draw zero-width lines */ - if (width == 0) - return NULL; + /* we never draw zero-width lines */ + if (width == 0) + return NULL; - /* Search for an appropriate aperture. */ - for (search = list->data; search; search = search->next) - if (search->width == width && search->shape == shape) - return search; + /* Search for an appropriate aperture. */ + for (search = list->data; search; search = search->next) + if (search->width == width && search->shape == shape) + return search; - /* Failing that, create a new one */ - return addAperture (list, width, shape); + /* Failing that, create a new one */ + return addAperture(list, width, shape); } /* Output aperture data to the file */ -static void -fprintAperture (FILE *f, Aperture *aptr) +static void fprintAperture(FILE * f, Aperture * aptr) { - switch (aptr->shape) - { - case ROUND: - pcb_fprintf (f, "%%ADD%dC,%.4mi*%%\r\n", aptr->dCode, aptr->width); - break; - case SQUARE: - pcb_fprintf (f, "%%ADD%dR,%.4miX%.4mi*%%\r\n", aptr->dCode, aptr->width, aptr->width); - break; - case OCTAGON: - pcb_fprintf (f, "%%AMOCT%d*5,0,8,0,0,%.4mi,22.5*%%\r\n" - "%%ADD%dOCT%d*%%\r\n", aptr->dCode, - (Coord) ((double) aptr->width / COS_22_5_DEGREE), aptr->dCode, - aptr->dCode); - break; + switch (aptr->shape) { + case ROUND: + pcb_fprintf(f, "%%ADD%dC,%.4mi*%%\r\n", aptr->dCode, aptr->width); + break; + case SQUARE: + pcb_fprintf(f, "%%ADD%dR,%.4miX%.4mi*%%\r\n", aptr->dCode, aptr->width, aptr->width); + break; + case OCTAGON: + pcb_fprintf(f, "%%AMOCT%d*5,0,8,0,0,%.4mi,22.5*%%\r\n" + "%%ADD%dOCT%d*%%\r\n", aptr->dCode, (Coord) ((double) aptr->width / COS_22_5_DEGREE), aptr->dCode, aptr->dCode); + break; #if 0 - case THERMAL: - fprintf (f, "%%AMTHERM%d*7,0,0,%.4f,%.4f,%.4f,45*%%\r\n" - "%%ADD%dTHERM%d*%%\r\n", dCode, gap / 100000.0, - width / 100000.0, finger / 100000.0, dCode, dCode); - break; - case ROUNDCLEAR: - fprintf (f, "%%ADD%dC,%.4fX%.4f*%%\r\n", - dCode, gap / 100000.0, width / 100000.0); - break; - case SQUARECLEAR: - fprintf (f, "%%ADD%dR,%.4fX%.4fX%.4fX%.4f*%%\r\n", - dCode, gap / 100000.0, gap / 100000.0, - width / 100000.0, width / 100000.0); - break; + case THERMAL: + fprintf(f, "%%AMTHERM%d*7,0,0,%.4f,%.4f,%.4f,45*%%\r\n" + "%%ADD%dTHERM%d*%%\r\n", dCode, gap / 100000.0, width / 100000.0, finger / 100000.0, dCode, dCode); + break; + case ROUNDCLEAR: + fprintf(f, "%%ADD%dC,%.4fX%.4f*%%\r\n", dCode, gap / 100000.0, width / 100000.0); + break; + case SQUARECLEAR: + fprintf(f, "%%ADD%dR,%.4fX%.4fX%.4fX%.4f*%%\r\n", + dCode, gap / 100000.0, gap / 100000.0, width / 100000.0, width / 100000.0); + break; #else - default: - break; + default: + break; #endif - } + } } /* Set the aperture list for the current layer, * expanding the list buffer if needed */ -static ApertureList * -setLayerApertureList (int layer_idx) +static ApertureList *setLayerApertureList(int layer_idx) { - if (layer_idx >= layer_list_max) - { - int i = layer_list_max; - layer_list_max = 2 * (layer_idx + 1); - layer_aptr_list = (ApertureList *) - realloc (layer_aptr_list, layer_list_max * sizeof (*layer_aptr_list)); - for (; i < layer_list_max; ++i) - initApertureList (&layer_aptr_list[i]); - } - curr_aptr_list = &layer_aptr_list[layer_idx]; - return curr_aptr_list; + if (layer_idx >= layer_list_max) { + int i = layer_list_max; + layer_list_max = 2 * (layer_idx + 1); + layer_aptr_list = (ApertureList *) + realloc(layer_aptr_list, layer_list_max * sizeof(*layer_aptr_list)); + for (; i < layer_list_max; ++i) + initApertureList(&layer_aptr_list[i]); + } + curr_aptr_list = &layer_aptr_list[layer_idx]; + return curr_aptr_list; } /* --------------------------------------------------------------------------- */ @@ -282,13 +263,12 @@ static HID gerber_hid; -typedef struct hid_gc_struct -{ - EndCapStyle cap; - int width; - int color; - int erase; - int drill; +typedef struct hid_gc_struct { + EndCapStyle cap; + int width; + int color; + int erase; + int drill; } hid_gc_struct; static FILE *f = NULL; @@ -305,30 +285,30 @@ static int lastcolor = -1; static int print_group[MAX_LAYER]; static int print_layer[MAX_LAYER]; -static int lastX, lastY; /* the last X and Y coordinate */ +static int lastX, lastY; /* the last X and Y coordinate */ static const char *copy_outline_names[] = { #define COPY_OUTLINE_NONE 0 - "none", + "none", #define COPY_OUTLINE_MASK 1 - "mask", + "mask", #define COPY_OUTLINE_SILK 2 - "silk", + "silk", #define COPY_OUTLINE_ALL 3 - "all", - NULL + "all", + NULL }; static const char *name_style_names[] = { #define NAME_STYLE_FIXED 0 - "fixed", + "fixed", #define NAME_STYLE_SINGLE 1 - "single", + "single", #define NAME_STYLE_FIRST 2 - "first", + "first", #define NAME_STYLE_EAGLE 3 - "eagle", - NULL + "eagle", + NULL }; static HID_Attribute gerber_options[] = { @@ -340,8 +320,8 @@ @end ftable %end-doc */ - {"gerberfile", "Gerber output file base", - HID_String, 0, 0, {0, 0, 0}, 0, 0}, + {"gerberfile", "Gerber output file base", + HID_String, 0, 0, {0, 0, 0}, 0, 0}, #define HA_gerberfile 0 /* %start-doc options "90 Gerber Export" @@ -351,8 +331,8 @@ @end ftable %end-doc */ - {"all-layers", "Output all layers, even empty ones", - HID_Boolean, 0, 0, {0, 0, 0}, 0, 0}, + {"all-layers", "Output all layers, even empty ones", + HID_Boolean, 0, 0, {0, 0, 0}, 0, 0}, #define HA_all_layers 1 /* %start-doc options "90 Gerber Export" @@ -362,14 +342,14 @@ @end ftable %end-doc */ - {"verbose", "Print file names and aperture counts on stdout", - HID_Boolean, 0, 0, {0, 0, 0}, 0, 0}, + {"verbose", "Print file names and aperture counts on stdout", + HID_Boolean, 0, 0, {0, 0, 0}, 0, 0}, #define HA_verbose 2 - {"copy-outline", "Copy outline onto other layers", - HID_Enum, 0, 0, {0, 0, 0}, copy_outline_names, 0}, + {"copy-outline", "Copy outline onto other layers", + HID_Enum, 0, 0, {0, 0, 0}, copy_outline_names, 0}, #define HA_copy_outline 3 - {"name-style", "Naming style for individual gerber files", - HID_Enum, 0, 0, {0, 0, 0}, name_style_names, 0}, + {"name-style", "Naming style for individual gerber files", + HID_Enum, 0, 0, {0, 0, 0}, name_style_names, 0}, #define HA_name_style 4 }; @@ -377,48 +357,44 @@ static HID_Attr_Val gerber_values[NUM_OPTIONS]; -static HID_Attribute * -gerber_get_export_options (int *n) +static HID_Attribute *gerber_get_export_options(int *n) { - static char *last_made_filename = NULL; - if (PCB) derive_default_filename(PCB->Filename, &gerber_options[HA_gerberfile], "", &last_made_filename); + static char *last_made_filename = NULL; + if (PCB) + derive_default_filename(PCB->Filename, &gerber_options[HA_gerberfile], "", &last_made_filename); - if (n) - *n = NUM_OPTIONS; - return gerber_options; + if (n) + *n = NUM_OPTIONS; + return gerber_options; } -static int -group_for_layer (int l) +static int group_for_layer(int l) { - if (l < max_copper_layer + 2 && l >= 0) - return GetLayerGroupNumberByNumber (l); - /* else something unique */ - return max_group + 3 + l; + if (l < max_copper_layer + 2 && l >= 0) + return GetLayerGroupNumberByNumber(l); + /* else something unique */ + return max_group + 3 + l; } -static int -layer_sort (const void *va, const void *vb) +static int layer_sort(const void *va, const void *vb) { - int a = *(int *) va; - int b = *(int *) vb; - int d = group_for_layer (b) - group_for_layer (a); - if (d) - return d; - return b - a; + int a = *(int *) va; + int b = *(int *) vb; + int d = group_for_layer(b) - group_for_layer(a); + if (d) + return d; + return b - a; } -static void -maybe_close_f (FILE *f) +static void maybe_close_f(FILE * f) { - if (f) - { - if (was_drill) - fprintf (f, "M30\r\n"); - else - fprintf (f, "M02*\r\n"); - fclose (f); - } + if (f) { + if (was_drill) + fprintf(f, "M30\r\n"); + else + fprintf(f, "M02*\r\n"); + fclose(f); + } } static BoxType region; @@ -425,872 +401,805 @@ /* Very similar to layer_type_to_file_name() but appends only a three-character suffix compatible with Eagle's defaults. */ -static void -assign_eagle_file_suffix (char *dest, int idx) +static void assign_eagle_file_suffix(char *dest, int idx) { - int group; - int nlayers; - char *suff = "out"; + int group; + int nlayers; + char *suff = "out"; - switch (idx) - { - case SL (SILK, TOP): suff = "plc"; break; - case SL (SILK, BOTTOM): suff = "pls"; break; - case SL (MASK, TOP): suff = "stc"; break; - case SL (MASK, BOTTOM): suff = "sts"; break; - case SL (PDRILL, 0): suff = "drd"; break; - case SL (UDRILL, 0): suff = "dru"; break; - case SL (PASTE, TOP): suff = "crc"; break; - case SL (PASTE, BOTTOM): suff = "crs"; break; - case SL (INVISIBLE, 0): suff = "inv"; break; - case SL (FAB, 0): suff = "fab"; break; - case SL (ASSY, TOP): suff = "ast"; break; - case SL (ASSY, BOTTOM): suff = "asb"; break; + switch (idx) { + case SL(SILK, TOP): + suff = "plc"; + break; + case SL(SILK, BOTTOM): + suff = "pls"; + break; + case SL(MASK, TOP): + suff = "stc"; + break; + case SL(MASK, BOTTOM): + suff = "sts"; + break; + case SL(PDRILL, 0): + suff = "drd"; + break; + case SL(UDRILL, 0): + suff = "dru"; + break; + case SL(PASTE, TOP): + suff = "crc"; + break; + case SL(PASTE, BOTTOM): + suff = "crs"; + break; + case SL(INVISIBLE, 0): + suff = "inv"; + break; + case SL(FAB, 0): + suff = "fab"; + break; + case SL(ASSY, TOP): + suff = "ast"; + break; + case SL(ASSY, BOTTOM): + suff = "asb"; + break; - default: - group = GetLayerGroupNumberByNumber(idx); - nlayers = PCB->LayerGroups.Number[group]; - if (group == GetLayerGroupNumberByNumber(component_silk_layer)) - { - suff = "cmp"; + default: + group = GetLayerGroupNumberByNumber(idx); + nlayers = PCB->LayerGroups.Number[group]; + if (group == GetLayerGroupNumberByNumber(component_silk_layer)) { + suff = "cmp"; + } + else if (group == GetLayerGroupNumberByNumber(solder_silk_layer)) { + suff = "sol"; + } + else if (nlayers == 1 + && (strcmp(PCB->Data->Layer[idx].Name, "route") == 0 || strcmp(PCB->Data->Layer[idx].Name, "outline") == 0)) { + suff = "oln"; + } + else { + static char buf[20]; + sprintf(buf, "ly%d", group); + suff = buf; + } + break; } - else if (group == GetLayerGroupNumberByNumber(solder_silk_layer)) - { - suff = "sol"; - } - else if (nlayers == 1 - && (strcmp (PCB->Data->Layer[idx].Name, "route") == 0 || - strcmp (PCB->Data->Layer[idx].Name, "outline") == 0)) - { - suff = "oln"; - } - else - { - static char buf[20]; - sprintf (buf, "ly%d", group); - suff = buf; - } - break; - } - strcpy (dest, suff); + strcpy(dest, suff); } -static void -assign_file_suffix (char *dest, int idx) +static void assign_file_suffix(char *dest, int idx) { - int fns_style; - const char *sext = ".gbr"; + int fns_style; + const char *sext = ".gbr"; - switch (name_style) - { - default: - case NAME_STYLE_FIXED: fns_style = FNS_fixed; break; - case NAME_STYLE_SINGLE: fns_style = FNS_single; break; - case NAME_STYLE_FIRST: fns_style = FNS_first; break; - case NAME_STYLE_EAGLE: - assign_eagle_file_suffix (dest, idx); - return; - } + switch (name_style) { + default: + case NAME_STYLE_FIXED: + fns_style = FNS_fixed; + break; + case NAME_STYLE_SINGLE: + fns_style = FNS_single; + break; + case NAME_STYLE_FIRST: + fns_style = FNS_first; + break; + case NAME_STYLE_EAGLE: + assign_eagle_file_suffix(dest, idx); + return; + } - switch (idx) - { - case SL (PDRILL, 0): - sext = ".cnc"; - break; - case SL (UDRILL, 0): - sext = ".cnc"; - break; - } + switch (idx) { + case SL(PDRILL, 0): + sext = ".cnc"; + break; + case SL(UDRILL, 0): + sext = ".cnc"; + break; + } - strcpy (dest, layer_type_to_file_name (idx, fns_style)); - strcat (dest, sext); + strcpy(dest, layer_type_to_file_name(idx, fns_style)); + strcat(dest, sext); } -static void -gerber_do_export (HID_Attr_Val * options) +static void gerber_do_export(HID_Attr_Val * options) { - const char *fnbase; - int i; - static int saved_layer_stack[MAX_LAYER]; - int save_ons[MAX_LAYER + 2]; - FlagType save_thindraw; + const char *fnbase; + int i; + static int saved_layer_stack[MAX_LAYER]; + int save_ons[MAX_LAYER + 2]; + FlagType save_thindraw; - save_thindraw = PCB->Flags; - CLEAR_FLAG(THINDRAWFLAG, PCB); - CLEAR_FLAG(THINDRAWPOLYFLAG, PCB); - CLEAR_FLAG(CHECKPLANESFLAG, PCB); + save_thindraw = PCB->Flags; + CLEAR_FLAG(THINDRAWFLAG, PCB); + CLEAR_FLAG(THINDRAWPOLYFLAG, PCB); + CLEAR_FLAG(CHECKPLANESFLAG, PCB); - if (!options) - { - gerber_get_export_options (NULL); - for (i = 0; i < NUM_OPTIONS; i++) - gerber_values[i] = gerber_options[i].default_val; - options = gerber_values; - } + if (!options) { + gerber_get_export_options(NULL); + for (i = 0; i < NUM_OPTIONS; i++) + gerber_values[i] = gerber_options[i].default_val; + options = gerber_values; + } - fnbase = options[HA_gerberfile].str_value; - if (!fnbase) - fnbase = "pcb-out"; + fnbase = options[HA_gerberfile].str_value; + if (!fnbase) + fnbase = "pcb-out"; - verbose = options[HA_verbose].int_value; - all_layers = options[HA_all_layers].int_value; + verbose = options[HA_verbose].int_value; + all_layers = options[HA_all_layers].int_value; - copy_outline_mode = options[HA_copy_outline].int_value; - name_style = options[HA_name_style].int_value; + copy_outline_mode = options[HA_copy_outline].int_value; + name_style = options[HA_name_style].int_value; - outline_layer = NULL; + outline_layer = NULL; - for (i = 0; i < max_copper_layer; i++) - { - LayerType *layer = PCB->Data->Layer + i; - if (strcmp (layer->Name, "outline") == 0 || - strcmp (layer->Name, "route") == 0) - { - outline_layer = layer; + for (i = 0; i < max_copper_layer; i++) { + LayerType *layer = PCB->Data->Layer + i; + if (strcmp(layer->Name, "outline") == 0 || strcmp(layer->Name, "route") == 0) { + outline_layer = layer; + } } - } - i = strlen (fnbase); - filename = (char *)realloc (filename, i + 40); - strcpy (filename, fnbase); - strcat (filename, "."); - filesuff = filename + strlen (filename); + i = strlen(fnbase); + filename = (char *) realloc(filename, i + 40); + strcpy(filename, fnbase); + strcat(filename, "."); + filesuff = filename + strlen(filename); - if (all_layers) - { - memset (print_group, 1, sizeof (print_group)); - memset (print_layer, 1, sizeof (print_layer)); - } - else - { - memset (print_group, 0, sizeof (print_group)); - memset (print_layer, 0, sizeof (print_layer)); - } + if (all_layers) { + memset(print_group, 1, sizeof(print_group)); + memset(print_layer, 1, sizeof(print_layer)); + } + else { + memset(print_group, 0, sizeof(print_group)); + memset(print_layer, 0, sizeof(print_layer)); + } - hid_save_and_show_layer_ons (save_ons); - for (i = 0; i < max_copper_layer; i++) - { - LayerType *layer = PCB->Data->Layer + i; - if (layer->LineN || layer->TextN || layer->ArcN || layer->PolygonN) - print_group[GetLayerGroupNumberByNumber (i)] = 1; - } - print_group[GetLayerGroupNumberByNumber (solder_silk_layer)] = 1; - print_group[GetLayerGroupNumberByNumber (component_silk_layer)] = 1; - for (i = 0; i < max_copper_layer; i++) - if (print_group[GetLayerGroupNumberByNumber (i)]) - print_layer[i] = 1; + hid_save_and_show_layer_ons(save_ons); + for (i = 0; i < max_copper_layer; i++) { + LayerType *layer = PCB->Data->Layer + i; + if (layer->LineN || layer->TextN || layer->ArcN || layer->PolygonN) + print_group[GetLayerGroupNumberByNumber(i)] = 1; + } + print_group[GetLayerGroupNumberByNumber(solder_silk_layer)] = 1; + print_group[GetLayerGroupNumberByNumber(component_silk_layer)] = 1; + for (i = 0; i < max_copper_layer; i++) + if (print_group[GetLayerGroupNumberByNumber(i)]) + print_layer[i] = 1; - memcpy (saved_layer_stack, LayerStack, sizeof (LayerStack)); - qsort (LayerStack, max_copper_layer, sizeof (LayerStack[0]), layer_sort); - linewidth = -1; - lastcap = -1; - lastgroup = -1; - lastcolor = -1; + memcpy(saved_layer_stack, LayerStack, sizeof(LayerStack)); + qsort(LayerStack, max_copper_layer, sizeof(LayerStack[0]), layer_sort); + linewidth = -1; + lastcap = -1; + lastgroup = -1; + lastcolor = -1; - region.X1 = 0; - region.Y1 = 0; - region.X2 = PCB->MaxWidth; - region.Y2 = PCB->MaxHeight; + region.X1 = 0; + region.Y1 = 0; + region.X2 = PCB->MaxWidth; + region.Y2 = PCB->MaxHeight; - pagecount = 1; - resetApertures (); + pagecount = 1; + resetApertures(); - lastgroup = -1; - layer_list_idx = 0; - finding_apertures = 1; - hid_expose_callback (&gerber_hid, ®ion, 0); + lastgroup = -1; + layer_list_idx = 0; + finding_apertures = 1; + hid_expose_callback(&gerber_hid, ®ion, 0); - layer_list_idx = 0; - finding_apertures = 0; - hid_expose_callback (&gerber_hid, ®ion, 0); + layer_list_idx = 0; + finding_apertures = 0; + hid_expose_callback(&gerber_hid, ®ion, 0); - memcpy (LayerStack, saved_layer_stack, sizeof (LayerStack)); + memcpy(LayerStack, saved_layer_stack, sizeof(LayerStack)); - maybe_close_f (f); - f = NULL; - hid_restore_layer_ons (save_ons); - PCB->Flags = save_thindraw; + maybe_close_f(f); + f = NULL; + hid_restore_layer_ons(save_ons); + PCB->Flags = save_thindraw; } -static void -gerber_parse_arguments (int *argc, char ***argv) +static void gerber_parse_arguments(int *argc, char ***argv) { - hid_register_attributes (gerber_options, NUM_OPTIONS); - hid_parse_command_line (argc, argv); + hid_register_attributes(gerber_options, NUM_OPTIONS); + hid_parse_command_line(argc, argv); } -static int -drill_sort (const void *va, const void *vb) +static int drill_sort(const void *va, const void *vb) { - PendingDrills *a = (PendingDrills *) va; - PendingDrills *b = (PendingDrills *) vb; - if (a->diam != b->diam) - return a->diam - b->diam; - if (a->x != b->x) - return a->x - a->x; - return b->y - b->y; + PendingDrills *a = (PendingDrills *) va; + PendingDrills *b = (PendingDrills *) vb; + if (a->diam != b->diam) + return a->diam - b->diam; + if (a->x != b->x) + return a->x - a->x; + return b->y - b->y; } -static int -gerber_set_layer (const char *name, int group, int empty) +static int gerber_set_layer(const char *name, int group, int empty) { - int want_outline; - char *cp; - int idx = (group >= 0 - && group < - max_group) ? PCB->LayerGroups.Entries[group][0] : group; + int want_outline; + char *cp; + int idx = (group >= 0 && group < max_group) ? PCB->LayerGroups.Entries[group][0] : group; - if (name == NULL) - name = PCB->Data->Layer[idx].Name; + if (name == NULL) + name = PCB->Data->Layer[idx].Name; - if (idx >= 0 && idx < max_copper_layer && !print_layer[idx]) - return 0; + if (idx >= 0 && idx < max_copper_layer && !print_layer[idx]) + return 0; - if (strcmp (name, "invisible") == 0) - return 0; - if (SL_TYPE (idx) == SL_ASSY) - return 0; + if (strcmp(name, "invisible") == 0) + return 0; + if (SL_TYPE(idx) == SL_ASSY) + return 0; - flash_drills = 0; - if (strcmp (name, "outline") == 0 || - strcmp (name, "route") == 0) - flash_drills = 1; + flash_drills = 0; + if (strcmp(name, "outline") == 0 || strcmp(name, "route") == 0) + flash_drills = 1; - if (is_drill && n_pending_drills) - { - int i; - /* dump pending drills in sequence */ - qsort (pending_drills, n_pending_drills, sizeof (pending_drills[0]), - drill_sort); - for (i = 0; i < n_pending_drills; i++) - { - if (i == 0 || pending_drills[i].diam != pending_drills[i - 1].diam) - { - Aperture *ap = findAperture (curr_aptr_list, pending_drills[i].diam, ROUND); - fprintf (f, "T%02d\r\n", ap->dCode); - } - pcb_fprintf (f, "X%06.0mlY%06.0ml\r\n", - gerberDrX (PCB, pending_drills[i].x), - gerberDrY (PCB, pending_drills[i].y)); + if (is_drill && n_pending_drills) { + int i; + /* dump pending drills in sequence */ + qsort(pending_drills, n_pending_drills, sizeof(pending_drills[0]), drill_sort); + for (i = 0; i < n_pending_drills; i++) { + if (i == 0 || pending_drills[i].diam != pending_drills[i - 1].diam) { + Aperture *ap = findAperture(curr_aptr_list, pending_drills[i].diam, ROUND); + fprintf(f, "T%02d\r\n", ap->dCode); + } + pcb_fprintf(f, "X%06.0mlY%06.0ml\r\n", gerberDrX(PCB, pending_drills[i].x), gerberDrY(PCB, pending_drills[i].y)); + } + free(pending_drills); + n_pending_drills = max_pending_drills = 0; + pending_drills = NULL; } - free (pending_drills); - n_pending_drills = max_pending_drills = 0; - pending_drills = NULL; - } - is_drill = (SL_TYPE (idx) == SL_PDRILL || SL_TYPE (idx) == SL_UDRILL); - is_mask = (SL_TYPE (idx) == SL_MASK); - current_mask = 0; + is_drill = (SL_TYPE(idx) == SL_PDRILL || SL_TYPE(idx) == SL_UDRILL); + is_mask = (SL_TYPE(idx) == SL_MASK); + current_mask = 0; #if 0 - printf ("Layer %s group %d drill %d mask %d\n", name, group, is_drill, - is_mask); + printf("Layer %s group %d drill %d mask %d\n", name, group, is_drill, is_mask); #endif - if (group < 0 || group != lastgroup) - { - time_t currenttime; - char utcTime[64]; + if (group < 0 || group != lastgroup) { + time_t currenttime; + char utcTime[64]; #ifdef HAVE_GETPWUID - struct passwd *pwentry; + struct passwd *pwentry; #endif - ApertureList *aptr_list; - Aperture *search; + ApertureList *aptr_list; + Aperture *search; - lastgroup = group; - lastX = -1; - lastY = -1; - lastcolor = 0; - linewidth = -1; - lastcap = -1; + lastgroup = group; + lastX = -1; + lastY = -1; + lastcolor = 0; + linewidth = -1; + lastcap = -1; - aptr_list = setLayerApertureList (layer_list_idx++); + aptr_list = setLayerApertureList(layer_list_idx++); - if (finding_apertures) - goto emit_outline; + if (finding_apertures) + goto emit_outline; - if (aptr_list->count == 0 && !all_layers) - return 0; + if (aptr_list->count == 0 && !all_layers) + return 0; - maybe_close_f (f); - f = NULL; + maybe_close_f(f); + f = NULL; - pagecount++; - assign_file_suffix (filesuff, idx); - f = fopen (filename, "wb"); /* Binary needed to force CR-LF */ - if (f == NULL) - { - Message ( "Error: Could not open %s for writing.\n", filename); - return 1; - } + pagecount++; + assign_file_suffix(filesuff, idx); + f = fopen(filename, "wb"); /* Binary needed to force CR-LF */ + if (f == NULL) { + Message("Error: Could not open %s for writing.\n", filename); + return 1; + } - was_drill = is_drill; + was_drill = is_drill; - if (verbose) - { - int c = aptr_list->count; - printf ("Gerber: %d aperture%s in %s\n", c, - c == 1 ? "" : "s", filename); - } + if (verbose) { + int c = aptr_list->count; + printf("Gerber: %d aperture%s in %s\n", c, c == 1 ? "" : "s", filename); + } - if (is_drill) - { - /* We omit the ,TZ here because we are not omitting trailing zeros. Our format is - always six-digit 0.1 mil resolution (i.e. 001100 = 0.11")*/ - fprintf (f, "M48\r\n" "INCH\r\n"); - for (search = aptr_list->data; search; search = search->next) - pcb_fprintf (f, "T%02dC%.3mi\r\n", search->dCode, search->width); - fprintf (f, "%%\r\n"); - /* FIXME */ - return 1; - } + if (is_drill) { + /* We omit the ,TZ here because we are not omitting trailing zeros. Our format is + always six-digit 0.1 mil resolution (i.e. 001100 = 0.11") */ + fprintf(f, "M48\r\n" "INCH\r\n"); + for (search = aptr_list->data; search; search = search->next) + pcb_fprintf(f, "T%02dC%.3mi\r\n", search->dCode, search->width); + fprintf(f, "%%\r\n"); + /* FIXME */ + return 1; + } - fprintf (f, "G04 start of page %d for group %d idx %d *\r\n", - pagecount, group, idx); + fprintf(f, "G04 start of page %d for group %d idx %d *\r\n", pagecount, group, idx); - /* Create a portable timestamp. */ - currenttime = time (NULL); - { - /* avoid gcc complaints */ - const char *fmt = "%c UTC"; - strftime (utcTime, sizeof utcTime, fmt, gmtime (¤ttime)); - } - /* Print a cute file header at the beginning of each file. */ - fprintf (f, "G04 Title: %s, %s *\r\n", UNKNOWN (PCB->Name), - UNKNOWN (name)); - fprintf (f, "G04 Creator: %s " VERSION " *\r\n", Progname); - fprintf (f, "G04 CreationDate: %s *\r\n", utcTime); + /* Create a portable timestamp. */ + currenttime = time(NULL); + { + /* avoid gcc complaints */ + const char *fmt = "%c UTC"; + strftime(utcTime, sizeof utcTime, fmt, gmtime(¤ttime)); + } + /* Print a cute file header at the beginning of each file. */ + fprintf(f, "G04 Title: %s, %s *\r\n", UNKNOWN(PCB->Name), UNKNOWN(name)); + fprintf(f, "G04 Creator: %s " VERSION " *\r\n", Progname); + fprintf(f, "G04 CreationDate: %s *\r\n", utcTime); #ifdef HAVE_GETPWUID - /* ID the user. */ - pwentry = getpwuid (getuid ()); - fprintf (f, "G04 For: %s *\r\n", pwentry->pw_name); + /* ID the user. */ + pwentry = getpwuid(getuid()); + fprintf(f, "G04 For: %s *\r\n", pwentry->pw_name); #endif - fprintf (f, "G04 Format: Gerber/RS-274X *\r\n"); - pcb_fprintf (f, "G04 PCB-Dimensions: %.0mc %.0mc *\r\n", - PCB->MaxWidth, PCB->MaxHeight); - fprintf (f, "G04 PCB-Coordinate-Origin: lower left *\r\n"); + fprintf(f, "G04 Format: Gerber/RS-274X *\r\n"); + pcb_fprintf(f, "G04 PCB-Dimensions: %.0mc %.0mc *\r\n", PCB->MaxWidth, PCB->MaxHeight); + fprintf(f, "G04 PCB-Coordinate-Origin: lower left *\r\n"); - /* Signal data in inches. */ - fprintf (f, "%%MOIN*%%\r\n"); + /* Signal data in inches. */ + fprintf(f, "%%MOIN*%%\r\n"); - /* Signal Leading zero suppression, Absolute Data, 2.5 format */ - fprintf (f, "%%FSLAX25Y25*%%\r\n"); + /* Signal Leading zero suppression, Absolute Data, 2.5 format */ + fprintf(f, "%%FSLAX25Y25*%%\r\n"); - /* build a legal identifier. */ - if (layername) - free (layername); - layername = strdup (filesuff); - if (strrchr (layername, '.')) - * strrchr (layername, '.') = 0; + /* build a legal identifier. */ + if (layername) + free(layername); + layername = strdup(filesuff); + if (strrchr(layername, '.')) + *strrchr(layername, '.') = 0; - for (cp=layername; *cp; cp++) - { - if (isalnum((int) *cp)) - *cp = toupper((int) *cp); - else - *cp = '_'; + for (cp = layername; *cp; cp++) { + if (isalnum((int) *cp)) + *cp = toupper((int) *cp); + else + *cp = '_'; + } + fprintf(f, "%%LN%s*%%\r\n", layername); + lncount = 1; + + for (search = aptr_list->data; search; search = search->next) + fprintAperture(f, search); + if (aptr_list->count == 0) + /* We need to put *something* in the file to make it be parsed + as RS-274X instead of RS-274D. */ + fprintf(f, "%%ADD11C,0.0100*%%\r\n"); } - fprintf (f, "%%LN%s*%%\r\n", layername); - lncount = 1; - for (search = aptr_list->data; search; search = search->next) - fprintAperture(f, search); - if (aptr_list->count == 0) - /* We need to put *something* in the file to make it be parsed - as RS-274X instead of RS-274D. */ - fprintf (f, "%%ADD11C,0.0100*%%\r\n"); - } +emit_outline: + /* If we're printing a copper layer other than the outline layer, + and we want to "print outlines", and we have an outline layer, + print the outline layer on this layer also. */ + want_outline = 0; + if (copy_outline_mode == COPY_OUTLINE_MASK && SL_TYPE(idx) == SL_MASK) + want_outline = 1; + if (copy_outline_mode == COPY_OUTLINE_SILK && SL_TYPE(idx) == SL_SILK) + want_outline = 1; + if (copy_outline_mode == COPY_OUTLINE_ALL + && (SL_TYPE(idx) == SL_SILK + || SL_TYPE(idx) == SL_MASK || SL_TYPE(idx) == SL_FAB || SL_TYPE(idx) == SL_ASSY || SL_TYPE(idx) == 0)) + want_outline = 1; - emit_outline: - /* If we're printing a copper layer other than the outline layer, - and we want to "print outlines", and we have an outline layer, - print the outline layer on this layer also. */ - want_outline = 0; - if (copy_outline_mode == COPY_OUTLINE_MASK - && SL_TYPE (idx) == SL_MASK) - want_outline = 1; - if (copy_outline_mode == COPY_OUTLINE_SILK - && SL_TYPE (idx) == SL_SILK) - want_outline = 1; - if (copy_outline_mode == COPY_OUTLINE_ALL - && (SL_TYPE (idx) == SL_SILK - || SL_TYPE (idx) == SL_MASK - || SL_TYPE (idx) == SL_FAB - || SL_TYPE (idx) == SL_ASSY - || SL_TYPE (idx) == 0)) - want_outline = 1; - - if (want_outline - && strcmp (name, "outline") - && strcmp (name, "route")) - { - if (outline_layer - && outline_layer != PCB->Data->Layer+idx) - DrawLayer (outline_layer, ®ion); - else if (!outline_layer) - { - hidGC gc = gui->make_gc (); - printf("name %s idx %d\n", name, idx); - if (SL_TYPE (idx) == SL_SILK) - gui->set_line_width (gc, PCB->minSlk); - else if (group >= 0) - gui->set_line_width (gc, PCB->minWid); - else - gui->set_line_width (gc, AUTO_OUTLINE_WIDTH); - 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); - gui->destroy_gc (gc); + if (want_outline && strcmp(name, "outline") + && strcmp(name, "route")) { + if (outline_layer && outline_layer != PCB->Data->Layer + idx) + DrawLayer(outline_layer, ®ion); + else if (!outline_layer) { + hidGC gc = gui->make_gc(); + printf("name %s idx %d\n", name, idx); + if (SL_TYPE(idx) == SL_SILK) + gui->set_line_width(gc, PCB->minSlk); + else if (group >= 0) + gui->set_line_width(gc, PCB->minWid); + else + gui->set_line_width(gc, AUTO_OUTLINE_WIDTH); + 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); + gui->destroy_gc(gc); + } } - } - return 1; + return 1; } -static hidGC -gerber_make_gc (void) +static hidGC gerber_make_gc(void) { - hidGC rv = (hidGC) calloc (1, sizeof (*rv)); - rv->cap = Trace_Cap; - return rv; + hidGC rv = (hidGC) calloc(1, sizeof(*rv)); + rv->cap = Trace_Cap; + return rv; } -static void -gerber_destroy_gc (hidGC gc) +static void gerber_destroy_gc(hidGC gc) { - free (gc); + free(gc); } -static void -gerber_use_mask (int use_it) +static void gerber_use_mask(int use_it) { - current_mask = use_it; + current_mask = use_it; } -static void -gerber_set_color (hidGC gc, const char *name) +static void gerber_set_color(hidGC gc, const char *name) { - if (strcmp (name, "erase") == 0) - { - gc->color = 1; - gc->erase = 1; - gc->drill = 0; - } - else if (strcmp (name, "drill") == 0) - { - gc->color = 1; - gc->erase = 0; - gc->drill = 1; - } - else - { - gc->color = 0; - gc->erase = 0; - gc->drill = 0; - } + if (strcmp(name, "erase") == 0) { + gc->color = 1; + gc->erase = 1; + gc->drill = 0; + } + else if (strcmp(name, "drill") == 0) { + gc->color = 1; + gc->erase = 0; + gc->drill = 1; + } + else { + gc->color = 0; + gc->erase = 0; + gc->drill = 0; + } } -static void -gerber_set_line_cap (hidGC gc, EndCapStyle style) +static void gerber_set_line_cap(hidGC gc, EndCapStyle style) { - gc->cap = style; + gc->cap = style; } -static void -gerber_set_line_width (hidGC gc, Coord width) +static void gerber_set_line_width(hidGC gc, Coord width) { - gc->width = width; + gc->width = width; } -static void -gerber_set_draw_xor (hidGC gc, int xor_) +static void gerber_set_draw_xor(hidGC gc, int xor_) { - ; + ; } -static void -use_gc (hidGC gc, int radius) +static void use_gc(hidGC gc, int radius) { - if (radius) - { - radius *= 2; - if (radius != linewidth || lastcap != Round_Cap) - { - Aperture *aptr = findAperture (curr_aptr_list, radius, ROUND); - if (aptr == NULL) - pcb_fprintf (stderr, "error: aperture for radius %$mS type ROUND is null\n", radius); - else if (f && !is_drill) - fprintf (f, "G54D%d*", aptr->dCode); - linewidth = radius; - lastcap = Round_Cap; + if (radius) { + radius *= 2; + if (radius != linewidth || lastcap != Round_Cap) { + Aperture *aptr = findAperture(curr_aptr_list, radius, ROUND); + if (aptr == NULL) + pcb_fprintf(stderr, "error: aperture for radius %$mS type ROUND is null\n", radius); + else if (f && !is_drill) + fprintf(f, "G54D%d*", aptr->dCode); + linewidth = radius; + lastcap = Round_Cap; + } } - } - else if (linewidth != gc->width || lastcap != gc->cap) - { - Aperture *aptr; - ApertureShape shape; + else if (linewidth != gc->width || lastcap != gc->cap) { + Aperture *aptr; + ApertureShape shape; - linewidth = gc->width; - lastcap = gc->cap; - switch (gc->cap) - { - case Round_Cap: - case Trace_Cap: - shape = ROUND; - break; - default: - case Square_Cap: - shape = SQUARE; - break; + linewidth = gc->width; + lastcap = gc->cap; + switch (gc->cap) { + case Round_Cap: + case Trace_Cap: + shape = ROUND; + break; + default: + case Square_Cap: + shape = SQUARE; + break; + } + aptr = findAperture(curr_aptr_list, linewidth, shape); + if (aptr == NULL) + pcb_fprintf(stderr, "error: aperture for width %$mS type %s is null\n", linewidth, shape == ROUND ? "ROUND" : "SQUARE"); + if (f) + fprintf(f, "G54D%d*", aptr->dCode); } - aptr = findAperture (curr_aptr_list, linewidth, shape); - if (aptr == NULL) - pcb_fprintf (stderr, "error: aperture for width %$mS type %s is null\n", - linewidth, shape == ROUND ? "ROUND" : "SQUARE"); - if (f) - fprintf (f, "G54D%d*", aptr->dCode); - } #if 0 - if (lastcolor != gc->color) - { - c = gc->color; - if (is_drill) - return; - if (is_mask) - c = (gc->erase ? 0 : 1); - lastcolor = gc->color; - if (f) - { - if (c) - { - fprintf (f, "%%LN%s_C%d*%%\r\n", layername, lncount++); - fprintf (f, "%%LPC*%%\r\n"); - } - else - { - fprintf (f, "%%LN%s_D%d*%%\r\n", layername, lncount++); - fprintf (f, "%%LPD*%%\r\n"); - } + if (lastcolor != gc->color) { + c = gc->color; + if (is_drill) + return; + if (is_mask) + c = (gc->erase ? 0 : 1); + lastcolor = gc->color; + if (f) { + if (c) { + fprintf(f, "%%LN%s_C%d*%%\r\n", layername, lncount++); + fprintf(f, "%%LPC*%%\r\n"); + } + else { + fprintf(f, "%%LN%s_D%d*%%\r\n", layername, lncount++); + fprintf(f, "%%LPD*%%\r\n"); + } + } } - } #endif } -static void -gerber_draw_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) +static void gerber_draw_rect(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) { - gerber_draw_line (gc, x1, y1, x1, y2); - gerber_draw_line (gc, x1, y1, x2, y1); - gerber_draw_line (gc, x1, y2, x2, y2); - gerber_draw_line (gc, x2, y1, x2, y2); + gerber_draw_line(gc, x1, y1, x1, y2); + gerber_draw_line(gc, x1, y1, x2, y1); + gerber_draw_line(gc, x1, y2, x2, y2); + gerber_draw_line(gc, x2, y1, x2, y2); } -static void -gerber_draw_line (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) +static void gerber_draw_line(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) { - bool m = false; + bool m = false; - if (x1 != x2 && y1 != y2 && gc->cap == Square_Cap) - { - Coord x[5], y[5]; - double tx, ty, theta; + if (x1 != x2 && y1 != y2 && gc->cap == Square_Cap) { + Coord x[5], y[5]; + double tx, ty, theta; - theta = atan2 (y2-y1, x2-x1); + theta = atan2(y2 - y1, x2 - x1); - /* T is a vector half a thickness long, in the direction of - one of the corners. */ - tx = gc->width / 2.0 * cos (theta + M_PI/4) * sqrt(2.0); - ty = gc->width / 2.0 * sin (theta + M_PI/4) * sqrt(2.0); + /* T is a vector half a thickness long, in the direction of + one of the corners. */ + tx = gc->width / 2.0 * cos(theta + M_PI / 4) * sqrt(2.0); + ty = gc->width / 2.0 * sin(theta + M_PI / 4) * sqrt(2.0); - x[0] = x1 - tx; y[0] = y1 - ty; - x[1] = x2 + ty; y[1] = y2 - tx; - x[2] = x2 + tx; y[2] = y2 + ty; - x[3] = x1 - ty; y[3] = y1 + tx; + x[0] = x1 - tx; + y[0] = y1 - ty; + x[1] = x2 + ty; + y[1] = y2 - tx; + x[2] = x2 + tx; + y[2] = y2 + ty; + x[3] = x1 - ty; + y[3] = y1 + tx; - x[4] = x[0]; y[4] = y[0]; - gerber_fill_polygon (gc, 5, x, y); - return; - } + x[4] = x[0]; + y[4] = y[0]; + gerber_fill_polygon(gc, 5, x, y); + return; + } - use_gc (gc, 0); - if (!f) - return; + use_gc(gc, 0); + if (!f) + return; - if (x1 != lastX) - { - m = true; - lastX = x1; - pcb_fprintf (f, "X%.0mc", gerberX (PCB, lastX)); - } - if (y1 != lastY) - { - m = true; - lastY = y1; - pcb_fprintf (f, "Y%.0mc", gerberY (PCB, lastY)); - } - if ((x1 == x2) && (y1 == y2)) - fprintf (f, "D03*\r\n"); - else - { - if (m) - fprintf (f, "D02*"); - if (x2 != lastX) - { - lastX = x2; - pcb_fprintf (f, "X%.0mc", gerberX (PCB, lastX)); + if (x1 != lastX) { + m = true; + lastX = x1; + pcb_fprintf(f, "X%.0mc", gerberX(PCB, lastX)); } - if (y2 != lastY) - { - lastY = y2; - pcb_fprintf (f, "Y%.0mc", gerberY (PCB, lastY)); + if (y1 != lastY) { + m = true; + lastY = y1; + pcb_fprintf(f, "Y%.0mc", gerberY(PCB, lastY)); + } + if ((x1 == x2) && (y1 == y2)) + fprintf(f, "D03*\r\n"); + else { + if (m) + fprintf(f, "D02*"); + if (x2 != lastX) { + lastX = x2; + pcb_fprintf(f, "X%.0mc", gerberX(PCB, lastX)); + } + if (y2 != lastY) { + lastY = y2; + pcb_fprintf(f, "Y%.0mc", gerberY(PCB, lastY)); + } + fprintf(f, "D01*\r\n"); } - fprintf (f, "D01*\r\n"); - } } -static void -gerber_draw_arc (hidGC gc, Coord cx, Coord cy, Coord width, Coord height, - Angle start_angle, Angle delta_angle) +static void gerber_draw_arc(hidGC gc, Coord cx, Coord cy, Coord width, Coord height, Angle start_angle, Angle delta_angle) { - bool m = false; - double arcStartX, arcStopX, arcStartY, arcStopY; + bool m = false; + double arcStartX, arcStopX, arcStartY, arcStopY; - /* we never draw zero-width lines */ - if (gc->width == 0) - return; + /* we never draw zero-width lines */ + if (gc->width == 0) + return; - use_gc (gc, 0); - if (!f) - return; + use_gc(gc, 0); + if (!f) + return; - arcStartX = cx - width * cos (TO_RADIANS (start_angle)); - arcStartY = cy + height * sin (TO_RADIANS (start_angle)); + arcStartX = cx - width * cos(TO_RADIANS(start_angle)); + arcStartY = cy + height * sin(TO_RADIANS(start_angle)); - /* I checked three different gerber viewers, and they all disagreed - on how ellipses should be drawn. The spec just calls G74/G75 - "circular interpolation" so there's a chance it just doesn't - support ellipses at all. Thus, we draw them out with line - segments. Note that most arcs in pcb are circles anyway. */ - if (width != height) - { - double step, angle; - Coord max = width > height ? width : height; - Coord minr = max - gc->width / 10; - int nsteps; - Coord x0, y0, x1, y1; + /* I checked three different gerber viewers, and they all disagreed + on how ellipses should be drawn. The spec just calls G74/G75 + "circular interpolation" so there's a chance it just doesn't + support ellipses at all. Thus, we draw them out with line + segments. Note that most arcs in pcb are circles anyway. */ + if (width != height) { + double step, angle; + Coord max = width > height ? width : height; + Coord minr = max - gc->width / 10; + int nsteps; + Coord x0, y0, x1, y1; - if (minr >= max) - minr = max - 1; - step = acos((double)minr/(double)max) * 180.0/M_PI; - if (step > 5) - step = 5; - nsteps = abs(delta_angle) / step + 1; - step = (double)delta_angle / nsteps; + if (minr >= max) + minr = max - 1; + step = acos((double) minr / (double) max) * 180.0 / M_PI; + if (step > 5) + step = 5; + nsteps = abs(delta_angle) / step + 1; + step = (double) delta_angle / nsteps; - x0 = arcStartX; - y0 = arcStartY; - angle = start_angle; - while (nsteps > 0) - { - nsteps --; - x1 = cx - width * cos (TO_RADIANS (angle+step)); - y1 = cy + height * sin (TO_RADIANS (angle+step)); - gerber_draw_line (gc, x0, y0, x1, y1); - x0 = x1; - y0 = y1; - angle += step; + x0 = arcStartX; + y0 = arcStartY; + angle = start_angle; + while (nsteps > 0) { + nsteps--; + x1 = cx - width * cos(TO_RADIANS(angle + step)); + y1 = cy + height * sin(TO_RADIANS(angle + step)); + gerber_draw_line(gc, x0, y0, x1, y1); + x0 = x1; + y0 = y1; + angle += step; + } + return; } - return; - } - arcStopX = cx - width * cos (TO_RADIANS (start_angle + delta_angle)); - arcStopY = cy + height * sin (TO_RADIANS (start_angle + delta_angle)); - if (arcStartX != lastX) - { - m = true; - lastX = arcStartX; - pcb_fprintf (f, "X%.0mc", gerberX (PCB, lastX)); - } - if (arcStartY != lastY) - { - m = true; - lastY = arcStartY; - pcb_fprintf (f, "Y%.0mc", gerberY (PCB, lastY)); - } - if (m) - fprintf (f, "D02*"); - pcb_fprintf (f, - "G75*G0%1dX%.0mcY%.0mcI%.0mcJ%.0mcD01*G01*\r\n", - (delta_angle < 0) ? 2 : 3, - gerberX (PCB, arcStopX), gerberY (PCB, arcStopY), - gerberXOffset (PCB, cx - arcStartX), - gerberYOffset (PCB, cy - arcStartY)); - lastX = arcStopX; - lastY = arcStopY; + arcStopX = cx - width * cos(TO_RADIANS(start_angle + delta_angle)); + arcStopY = cy + height * sin(TO_RADIANS(start_angle + delta_angle)); + if (arcStartX != lastX) { + m = true; + lastX = arcStartX; + pcb_fprintf(f, "X%.0mc", gerberX(PCB, lastX)); + } + if (arcStartY != lastY) { + m = true; + lastY = arcStartY; + pcb_fprintf(f, "Y%.0mc", gerberY(PCB, lastY)); + } + if (m) + fprintf(f, "D02*"); + pcb_fprintf(f, + "G75*G0%1dX%.0mcY%.0mcI%.0mcJ%.0mcD01*G01*\r\n", + (delta_angle < 0) ? 2 : 3, + gerberX(PCB, arcStopX), gerberY(PCB, arcStopY), + gerberXOffset(PCB, cx - arcStartX), gerberYOffset(PCB, cy - arcStartY)); + lastX = arcStopX; + lastY = arcStopY; } -static void -gerber_fill_circle (hidGC gc, Coord cx, Coord cy, Coord radius) +static void gerber_fill_circle(hidGC gc, Coord cx, Coord cy, Coord radius) { - if (radius <= 0) - return; - if (is_drill) - radius = 50 * round (radius / 50.0); - use_gc (gc, radius); - if (!f) - return; - if (is_drill) - { - if (n_pending_drills >= max_pending_drills) - { - max_pending_drills += 100; - pending_drills = (PendingDrills *) realloc(pending_drills, - max_pending_drills * - sizeof (pending_drills[0])); + if (radius <= 0) + return; + if (is_drill) + radius = 50 * round(radius / 50.0); + use_gc(gc, radius); + if (!f) + return; + if (is_drill) { + if (n_pending_drills >= max_pending_drills) { + max_pending_drills += 100; + pending_drills = (PendingDrills *) realloc(pending_drills, max_pending_drills * sizeof(pending_drills[0])); + } + pending_drills[n_pending_drills].x = cx; + pending_drills[n_pending_drills].y = cy; + pending_drills[n_pending_drills].diam = radius * 2; + n_pending_drills++; + return; } - pending_drills[n_pending_drills].x = cx; - pending_drills[n_pending_drills].y = cy; - pending_drills[n_pending_drills].diam = radius * 2; - n_pending_drills++; - return; - } - else if (gc->drill && !flash_drills) - return; - if (cx != lastX) - { - lastX = cx; - pcb_fprintf (f, "X%.0mc", gerberX (PCB, lastX)); - } - if (cy != lastY) - { - lastY = cy; - pcb_fprintf (f, "Y%.0mc", gerberY (PCB, lastY)); - } - fprintf (f, "D03*\r\n"); + else if (gc->drill && !flash_drills) + return; + if (cx != lastX) { + lastX = cx; + pcb_fprintf(f, "X%.0mc", gerberX(PCB, lastX)); + } + if (cy != lastY) { + lastY = cy; + pcb_fprintf(f, "Y%.0mc", gerberY(PCB, lastY)); + } + fprintf(f, "D03*\r\n"); } -static void -gerber_fill_polygon (hidGC gc, int n_coords, Coord *x, Coord *y) +static void gerber_fill_polygon(hidGC gc, int n_coords, Coord * x, Coord * y) { - bool m = false; - int i; - int firstTime = 1; - Coord startX = 0, startY = 0; + bool m = false; + int i; + int firstTime = 1; + Coord startX = 0, startY = 0; - if (is_mask && current_mask == HID_MASK_BEFORE) - return; + if (is_mask && current_mask == HID_MASK_BEFORE) + return; - use_gc (gc, 10 * 100); - if (!f) - return; - fprintf (f, "G36*\r\n"); - for (i = 0; i < n_coords; i++) - { - if (x[i] != lastX) - { - m = true; - lastX = x[i]; - pcb_fprintf (f, "X%.0mc", gerberX (PCB, lastX)); + use_gc(gc, 10 * 100); + if (!f) + return; + fprintf(f, "G36*\r\n"); + for (i = 0; i < n_coords; i++) { + if (x[i] != lastX) { + m = true; + lastX = x[i]; + pcb_fprintf(f, "X%.0mc", gerberX(PCB, lastX)); + } + if (y[i] != lastY) { + m = true; + lastY = y[i]; + pcb_fprintf(f, "Y%.0mc", gerberY(PCB, lastY)); + } + if (firstTime) { + firstTime = 0; + startX = x[i]; + startY = y[i]; + if (m) + fprintf(f, "D02*"); + } + else if (m) + fprintf(f, "D01*\r\n"); + m = false; } - if (y[i] != lastY) - { - m = true; - lastY = y[i]; - pcb_fprintf (f, "Y%.0mc", gerberY (PCB, lastY)); + if (startX != lastX) { + m = true; + lastX = startX; + pcb_fprintf(f, "X%.0mc", gerberX(PCB, startX)); } - if (firstTime) - { - firstTime = 0; - startX = x[i]; - startY = y[i]; - if (m) - fprintf (f, "D02*"); + if (startY != lastY) { + m = true; + lastY = startY; + pcb_fprintf(f, "Y%.0mc", gerberY(PCB, lastY)); } - else if (m) - fprintf (f, "D01*\r\n"); - m = false; - } - if (startX != lastX) - { - m = true; - lastX = startX; - pcb_fprintf (f, "X%.0mc", gerberX (PCB, startX)); - } - if (startY != lastY) - { - m = true; - lastY = startY; - pcb_fprintf (f, "Y%.0mc", gerberY (PCB, lastY)); - } - if (m) - fprintf (f, "D01*\r\n"); - fprintf (f, "G37*\r\n"); + if (m) + fprintf(f, "D01*\r\n"); + fprintf(f, "G37*\r\n"); } -static void -gerber_fill_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) +static void gerber_fill_rect(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) { - Coord x[5]; - Coord y[5]; - x[0] = x[4] = x1; - y[0] = y[4] = y1; - x[1] = x1; - y[1] = y2; - x[2] = x2; - y[2] = y2; - x[3] = x2; - y[3] = y1; - gerber_fill_polygon (gc, 5, x, y); + Coord x[5]; + Coord y[5]; + x[0] = x[4] = x1; + y[0] = y[4] = y1; + x[1] = x1; + y[1] = y2; + x[2] = x2; + y[2] = y2; + x[3] = x2; + y[3] = y1; + gerber_fill_polygon(gc, 5, x, y); } -static void -gerber_calibrate (double xval, double yval) +static void gerber_calibrate(double xval, double yval) { - CRASH; + CRASH; } -static void -gerber_set_crosshair (int x, int y, int action) +static void gerber_set_crosshair(int x, int y, int action) { } -void -hid_gerber_init () +void hid_gerber_init() { - memset (&gerber_hid, 0, sizeof (gerber_hid)); + memset(&gerber_hid, 0, sizeof(gerber_hid)); - common_nogui_init (&gerber_hid); - common_draw_helpers_init (&gerber_hid); + common_nogui_init(&gerber_hid); + common_draw_helpers_init(&gerber_hid); - gerber_hid.struct_size = sizeof (gerber_hid); - gerber_hid.name = "gerber"; - gerber_hid.description = "RS-274X (Gerber) export"; - gerber_hid.exporter = 1; + gerber_hid.struct_size = sizeof(gerber_hid); + gerber_hid.name = "gerber"; + gerber_hid.description = "RS-274X (Gerber) export"; + gerber_hid.exporter = 1; - gerber_hid.get_export_options = gerber_get_export_options; - gerber_hid.do_export = gerber_do_export; - gerber_hid.parse_arguments = gerber_parse_arguments; - gerber_hid.set_layer = gerber_set_layer; - gerber_hid.make_gc = gerber_make_gc; - gerber_hid.destroy_gc = gerber_destroy_gc; - gerber_hid.use_mask = gerber_use_mask; - gerber_hid.set_color = gerber_set_color; - gerber_hid.set_line_cap = gerber_set_line_cap; - gerber_hid.set_line_width = gerber_set_line_width; - gerber_hid.set_draw_xor = gerber_set_draw_xor; - gerber_hid.draw_line = gerber_draw_line; - gerber_hid.draw_arc = gerber_draw_arc; - gerber_hid.draw_rect = gerber_draw_rect; - gerber_hid.fill_circle = gerber_fill_circle; - gerber_hid.fill_polygon = gerber_fill_polygon; - gerber_hid.fill_rect = gerber_fill_rect; - gerber_hid.calibrate = gerber_calibrate; - gerber_hid.set_crosshair = gerber_set_crosshair; + gerber_hid.get_export_options = gerber_get_export_options; + gerber_hid.do_export = gerber_do_export; + gerber_hid.parse_arguments = gerber_parse_arguments; + gerber_hid.set_layer = gerber_set_layer; + gerber_hid.make_gc = gerber_make_gc; + gerber_hid.destroy_gc = gerber_destroy_gc; + gerber_hid.use_mask = gerber_use_mask; + gerber_hid.set_color = gerber_set_color; + gerber_hid.set_line_cap = gerber_set_line_cap; + gerber_hid.set_line_width = gerber_set_line_width; + gerber_hid.set_draw_xor = gerber_set_draw_xor; + gerber_hid.draw_line = gerber_draw_line; + gerber_hid.draw_arc = gerber_draw_arc; + gerber_hid.draw_rect = gerber_draw_rect; + gerber_hid.fill_circle = gerber_fill_circle; + gerber_hid.fill_polygon = gerber_fill_polygon; + gerber_hid.fill_rect = gerber_fill_rect; + gerber_hid.calibrate = gerber_calibrate; + gerber_hid.set_crosshair = gerber_set_crosshair; - hid_register_hid (&gerber_hid); + hid_register_hid(&gerber_hid); } Index: trunk/src/hid/gtk/ghid-cell-renderer-visibility.c =================================================================== --- trunk/src/hid/gtk/ghid-cell-renderer-visibility.c (revision 1021) +++ trunk/src/hid/gtk/ghid-cell-renderer-visibility.c (revision 1022) @@ -16,233 +16,193 @@ #include "ghid-cell-renderer-visibility.h" enum { - TOGGLED, - LAST_SIGNAL + TOGGLED, + LAST_SIGNAL }; static guint toggle_cell_signals[LAST_SIGNAL] = { 0 }; enum { - PROP_ACTIVE = 1, - PROP_COLOR + PROP_ACTIVE = 1, + PROP_COLOR }; -struct _GHidCellRendererVisibility -{ - GtkCellRenderer parent; +struct _GHidCellRendererVisibility { + GtkCellRenderer parent; - gboolean active; - gchar *color; + gboolean active; + gchar *color; }; -struct _GHidCellRendererVisibilityClass -{ - GtkCellRendererClass parent_class; +struct _GHidCellRendererVisibilityClass { + GtkCellRendererClass parent_class; - void (* toggled) (GHidCellRendererVisibility *cell, const gchar *path); + void (*toggled) (GHidCellRendererVisibility * cell, const gchar * path); }; /* RENDERER FUNCTIONS */ /*! \brief Calculates the window area the renderer will use */ static void -ghid_cell_renderer_visibility_get_size (GtkCellRenderer *cell, - GtkWidget *widget, - GdkRectangle *cell_area, - gint *x_offset, - gint *y_offset, - gint *width, - gint *height) +ghid_cell_renderer_visibility_get_size(GtkCellRenderer * cell, + GtkWidget * widget, + GdkRectangle * cell_area, gint * x_offset, gint * y_offset, gint * width, gint * height) { - GtkStyle *style = gtk_widget_get_style (widget); - gint w, h; - gint xpad, ypad; - gfloat xalign, yalign; + GtkStyle *style = gtk_widget_get_style(widget); + gint w, h; + gint xpad, ypad; + gfloat xalign, yalign; - gtk_cell_renderer_get_padding (cell, &xpad, &ypad); - gtk_cell_renderer_get_alignment (cell, &xalign, &yalign); + gtk_cell_renderer_get_padding(cell, &xpad, &ypad); + gtk_cell_renderer_get_alignment(cell, &xalign, &yalign); - w = VISIBILITY_TOGGLE_SIZE + 2 * (xpad + style->xthickness); - h = VISIBILITY_TOGGLE_SIZE + 2 * (ypad + style->ythickness); + w = VISIBILITY_TOGGLE_SIZE + 2 * (xpad + style->xthickness); + h = VISIBILITY_TOGGLE_SIZE + 2 * (ypad + style->ythickness); - if (width) - *width = w; - if (height) - *height = h; + if (width) + *width = w; + if (height) + *height = h; - if (cell_area) - { - if (x_offset) - { - if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - xalign = 1. - xalign; - *x_offset = MAX (0, xalign * (cell_area->width - w)); - } - if (y_offset) - *y_offset = MAX(0, yalign * (cell_area->height - h)); - } + if (cell_area) { + if (x_offset) { + if (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL) + xalign = 1. - xalign; + *x_offset = MAX(0, xalign * (cell_area->width - w)); + } + if (y_offset) + *y_offset = MAX(0, yalign * (cell_area->height - h)); + } } /*! \brief Actually renders the swatch */ static void -ghid_cell_renderer_visibility_render (GtkCellRenderer *cell, - GdkWindow *window, - GtkWidget *widget, - GdkRectangle *background_area, - GdkRectangle *cell_area, - GdkRectangle *expose_area, - GtkCellRendererState flags) +ghid_cell_renderer_visibility_render(GtkCellRenderer * cell, + GdkWindow * window, + GtkWidget * widget, + GdkRectangle * background_area, + GdkRectangle * cell_area, GdkRectangle * expose_area, GtkCellRendererState flags) { - GHidCellRendererVisibility *pcb_cell; - GdkRectangle toggle_rect; - GdkRectangle draw_rect; - gint xpad, ypad; + GHidCellRendererVisibility *pcb_cell; + GdkRectangle toggle_rect; + GdkRectangle draw_rect; + gint xpad, ypad; - pcb_cell = GHID_CELL_RENDERER_VISIBILITY (cell); - ghid_cell_renderer_visibility_get_size (cell, widget, cell_area, - &toggle_rect.x, - &toggle_rect.y, - &toggle_rect.width, - &toggle_rect.height); - gtk_cell_renderer_get_padding (cell, &xpad, &ypad); + pcb_cell = GHID_CELL_RENDERER_VISIBILITY(cell); + ghid_cell_renderer_visibility_get_size(cell, widget, cell_area, + &toggle_rect.x, &toggle_rect.y, &toggle_rect.width, &toggle_rect.height); + gtk_cell_renderer_get_padding(cell, &xpad, &ypad); - toggle_rect.x += cell_area->x + xpad; - toggle_rect.y += cell_area->y + ypad; - toggle_rect.width -= xpad * 2; - toggle_rect.height -= ypad * 2; + toggle_rect.x += cell_area->x + xpad; + toggle_rect.y += cell_area->y + ypad; + toggle_rect.width -= xpad * 2; + toggle_rect.height -= ypad * 2; - if (toggle_rect.width <= 0 || toggle_rect.height <= 0) - return; + if (toggle_rect.width <= 0 || toggle_rect.height <= 0) + return; - if (gdk_rectangle_intersect (expose_area, cell_area, &draw_rect)) - { - GdkColor color; - cairo_t *cr = gdk_cairo_create (window); - if (expose_area) - { - gdk_cairo_rectangle (cr, expose_area); - cairo_clip (cr); - } - cairo_set_line_width (cr, 1); + if (gdk_rectangle_intersect(expose_area, cell_area, &draw_rect)) { + GdkColor color; + cairo_t *cr = gdk_cairo_create(window); + if (expose_area) { + gdk_cairo_rectangle(cr, expose_area); + cairo_clip(cr); + } + cairo_set_line_width(cr, 1); - cairo_rectangle (cr, toggle_rect.x + 0.5, toggle_rect.y + 0.5, - toggle_rect.width - 1, toggle_rect.height - 1); - cairo_set_source_rgb (cr, 1, 1, 1); - cairo_fill_preserve (cr); - cairo_set_source_rgb (cr, 0, 0, 0); - cairo_stroke (cr); + cairo_rectangle(cr, toggle_rect.x + 0.5, toggle_rect.y + 0.5, toggle_rect.width - 1, toggle_rect.height - 1); + cairo_set_source_rgb(cr, 1, 1, 1); + cairo_fill_preserve(cr); + cairo_set_source_rgb(cr, 0, 0, 0); + cairo_stroke(cr); - gdk_color_parse (pcb_cell->color, &color); - if (flags & GTK_CELL_RENDERER_PRELIT) - { - color.red = (4*color.red + 65535) / 5; - color.green = (4*color.green + 65535) / 5; - color.blue = (4*color.blue + 65535) / 5; - } - gdk_cairo_set_source_color (cr, &color); - if (pcb_cell->active) - cairo_rectangle (cr, toggle_rect.x + 0.5, toggle_rect.y + 0.5, - toggle_rect.width - 1, toggle_rect.height - 1); - else - { - cairo_move_to (cr, toggle_rect.x + 1, toggle_rect.y + 1); - cairo_rel_line_to (cr, toggle_rect.width / 2, 0); - cairo_rel_line_to (cr, -toggle_rect.width / 2, toggle_rect.width / 2); - cairo_close_path (cr); - } - cairo_fill (cr); + gdk_color_parse(pcb_cell->color, &color); + if (flags & GTK_CELL_RENDERER_PRELIT) { + color.red = (4 * color.red + 65535) / 5; + color.green = (4 * color.green + 65535) / 5; + color.blue = (4 * color.blue + 65535) / 5; + } + gdk_cairo_set_source_color(cr, &color); + if (pcb_cell->active) + cairo_rectangle(cr, toggle_rect.x + 0.5, toggle_rect.y + 0.5, toggle_rect.width - 1, toggle_rect.height - 1); + else { + cairo_move_to(cr, toggle_rect.x + 1, toggle_rect.y + 1); + cairo_rel_line_to(cr, toggle_rect.width / 2, 0); + cairo_rel_line_to(cr, -toggle_rect.width / 2, toggle_rect.width / 2); + cairo_close_path(cr); + } + cairo_fill(cr); - cairo_destroy (cr); - } + cairo_destroy(cr); + } } /*! \brief Toggless the swatch */ static gint -ghid_cell_renderer_visibility_activate (GtkCellRenderer *cell, - GdkEvent *event, - GtkWidget *widget, - const gchar *path, - GdkRectangle *background_area, - GdkRectangle *cell_area, - GtkCellRendererState flags) +ghid_cell_renderer_visibility_activate(GtkCellRenderer * cell, + GdkEvent * event, + GtkWidget * widget, + const gchar * path, + GdkRectangle * background_area, GdkRectangle * cell_area, GtkCellRendererState flags) { - g_signal_emit (cell, toggle_cell_signals[TOGGLED], 0, path); - return TRUE; + g_signal_emit(cell, toggle_cell_signals[TOGGLED], 0, path); + return TRUE; } /* Setter/Getter */ -static void -ghid_cell_renderer_visibility_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec) +static void ghid_cell_renderer_visibility_get_property(GObject * object, guint param_id, GValue * value, GParamSpec * pspec) { - GHidCellRendererVisibility *pcb_cell = - GHID_CELL_RENDERER_VISIBILITY (object); + GHidCellRendererVisibility *pcb_cell = GHID_CELL_RENDERER_VISIBILITY(object); - switch (param_id) - { - case PROP_ACTIVE: - g_value_set_boolean (value, pcb_cell->active); - break; - case PROP_COLOR: - g_value_set_string (value, pcb_cell->color); - break; - } + switch (param_id) { + case PROP_ACTIVE: + g_value_set_boolean(value, pcb_cell->active); + break; + case PROP_COLOR: + g_value_set_string(value, pcb_cell->color); + break; + } } static void -ghid_cell_renderer_visibility_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec) +ghid_cell_renderer_visibility_set_property(GObject * object, guint param_id, const GValue * value, GParamSpec * pspec) { - GHidCellRendererVisibility *pcb_cell = - GHID_CELL_RENDERER_VISIBILITY (object); + GHidCellRendererVisibility *pcb_cell = GHID_CELL_RENDERER_VISIBILITY(object); - switch (param_id) - { - case PROP_ACTIVE: - pcb_cell->active = g_value_get_boolean (value); - break; - case PROP_COLOR: - g_free (pcb_cell->color); - pcb_cell->color = g_value_dup_string (value); - break; - } + switch (param_id) { + case PROP_ACTIVE: + pcb_cell->active = g_value_get_boolean(value); + break; + case PROP_COLOR: + g_free(pcb_cell->color); + pcb_cell->color = g_value_dup_string(value); + break; + } } /* CONSTRUCTOR */ -static void -ghid_cell_renderer_visibility_init (GHidCellRendererVisibility *ls) +static void ghid_cell_renderer_visibility_init(GHidCellRendererVisibility * ls) { - g_object_set (ls, "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, NULL); + g_object_set(ls, "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, NULL); } -static void -ghid_cell_renderer_visibility_class_init (GHidCellRendererVisibilityClass *klass) +static void ghid_cell_renderer_visibility_class_init(GHidCellRendererVisibilityClass * klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); + GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS(klass); - object_class->get_property = ghid_cell_renderer_visibility_get_property; - object_class->set_property = ghid_cell_renderer_visibility_set_property; + object_class->get_property = ghid_cell_renderer_visibility_get_property; + object_class->set_property = ghid_cell_renderer_visibility_set_property; - cell_class->get_size = ghid_cell_renderer_visibility_get_size; - cell_class->render = ghid_cell_renderer_visibility_render; - cell_class->activate = ghid_cell_renderer_visibility_activate; + cell_class->get_size = ghid_cell_renderer_visibility_get_size; + cell_class->render = ghid_cell_renderer_visibility_render; + cell_class->activate = ghid_cell_renderer_visibility_activate; - g_object_class_install_property (object_class, PROP_ACTIVE, - g_param_spec_boolean ("active", - _("Visibility state"), - _("Visibility of the layer"), - FALSE, - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, PROP_COLOR, - g_param_spec_string ("color", - _("Layer color"), - _("Layer color"), - FALSE, - G_PARAM_READWRITE)); + g_object_class_install_property(object_class, PROP_ACTIVE, + g_param_spec_boolean("active", + _("Visibility state"), + _("Visibility of the layer"), FALSE, G_PARAM_READWRITE)); + g_object_class_install_property(object_class, PROP_COLOR, + g_param_spec_string("color", _("Layer color"), _("Layer color"), FALSE, G_PARAM_READWRITE)); /** @@ -253,55 +213,43 @@ * * The ::toggled signal is emitted when the cell is toggled. **/ - toggle_cell_signals[TOGGLED] = - g_signal_new (_("toggled"), - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GHidCellRendererVisibilityClass, toggled), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); + toggle_cell_signals[TOGGLED] = + g_signal_new(_("toggled"), + G_OBJECT_CLASS_TYPE(object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(GHidCellRendererVisibilityClass, toggled), + NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); } /* PUBLIC FUNCTIONS */ -GType -ghid_cell_renderer_visibility_get_type (void) +GType ghid_cell_renderer_visibility_get_type(void) { - static GType ls_type = 0; + static GType ls_type = 0; - if (!ls_type) - { - const GTypeInfo ls_info = - { - sizeof (GHidCellRendererVisibilityClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) ghid_cell_renderer_visibility_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GHidCellRendererVisibility), - 0, /* n_preallocs */ - (GInstanceInitFunc) ghid_cell_renderer_visibility_init, - }; + if (!ls_type) { + const GTypeInfo ls_info = { + sizeof(GHidCellRendererVisibilityClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) ghid_cell_renderer_visibility_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(GHidCellRendererVisibility), + 0, /* n_preallocs */ + (GInstanceInitFunc) ghid_cell_renderer_visibility_init, + }; - ls_type = g_type_register_static (GTK_TYPE_CELL_RENDERER, - "GHidCellRendererVisibility", - &ls_info, - 0); - } + ls_type = g_type_register_static(GTK_TYPE_CELL_RENDERER, "GHidCellRendererVisibility", &ls_info, 0); + } - return ls_type; + return ls_type; } -GtkCellRenderer * -ghid_cell_renderer_visibility_new (void) +GtkCellRenderer *ghid_cell_renderer_visibility_new(void) { - GHidCellRendererVisibility *rv = - g_object_new (GHID_CELL_RENDERER_VISIBILITY_TYPE, NULL); + GHidCellRendererVisibility *rv = g_object_new(GHID_CELL_RENDERER_VISIBILITY_TYPE, NULL); - rv->active = FALSE; + rv->active = FALSE; - return GTK_CELL_RENDERER (rv); + return GTK_CELL_RENDERER(rv); } - Index: trunk/src/hid/gtk/ghid-cell-renderer-visibility.h =================================================================== --- trunk/src/hid/gtk/ghid-cell-renderer-visibility.h (revision 1021) +++ trunk/src/hid/gtk/ghid-cell-renderer-visibility.h (revision 1022) @@ -4,21 +4,18 @@ #include #include -G_BEGIN_DECLS /* keep c++ happy */ - +G_BEGIN_DECLS /* keep c++ happy */ #define VISIBILITY_TOGGLE_SIZE 16 - #define GHID_CELL_RENDERER_VISIBILITY_TYPE (ghid_cell_renderer_visibility_get_type ()) #define GHID_CELL_RENDERER_VISIBILITY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GHID_CELL_RENDERER_VISIBILITY_TYPE, GHidCellRendererVisibility)) #define GHID_CELL_RENDERER_VISIBILITY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GHID_CELL_RENDERER_VISIBILITY_TYPE, GHidCellRendererVisibilityClass)) #define IS_GHID_CELL_RENDERER_VISIBILITY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GHID_CELL_RENDERER_VISIBILITY_TYPE)) #define IS_GHID_CELL_RENDERER_VISIBILITY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GHID_CELL_RENDERER_VISIBILITY_TYPE)) +typedef struct _GHidCellRendererVisibility GHidCellRendererVisibility; +typedef struct _GHidCellRendererVisibilityClass GHidCellRendererVisibilityClass; -typedef struct _GHidCellRendererVisibility GHidCellRendererVisibility; -typedef struct _GHidCellRendererVisibilityClass GHidCellRendererVisibilityClass; +GType ghid_cell_renderer_visibility_get_type(void); +GtkCellRenderer *ghid_cell_renderer_visibility_new(void); -GType ghid_cell_renderer_visibility_get_type (void); -GtkCellRenderer *ghid_cell_renderer_visibility_new (void); - -G_END_DECLS /* keep c++ happy */ +G_END_DECLS /* keep c++ happy */ #endif Index: trunk/src/hid/gtk/ghid-coord-entry.c =================================================================== --- trunk/src/hid/gtk/ghid-coord-entry.c (revision 1021) +++ trunk/src/hid/gtk/ghid-coord-entry.c (revision 1022) @@ -21,125 +21,115 @@ #include "ghid-coord-entry.h" enum { - UNIT_CHANGE_SIGNAL, - LAST_SIGNAL + UNIT_CHANGE_SIGNAL, + LAST_SIGNAL }; static guint ghid_coord_entry_signals[LAST_SIGNAL] = { 0 }; -struct _GHidCoordEntry -{ - GtkSpinButton parent; +struct _GHidCoordEntry { + GtkSpinButton parent; - Coord min_value; - Coord max_value; - Coord value; + Coord min_value; + Coord max_value; + Coord value; - enum ce_step_size step_size; - const Unit *unit; + enum ce_step_size step_size; + const Unit *unit; }; -struct _GHidCoordEntryClass -{ - GtkSpinButtonClass parent_class; +struct _GHidCoordEntryClass { + GtkSpinButtonClass parent_class; - void (* change_unit) (GHidCoordEntry *, const Unit *); + void (*change_unit) (GHidCoordEntry *, const Unit *); }; /* SIGNAL HANDLERS */ /*! \brief Callback for "Change Unit" menu click */ -static void -menu_item_activate_cb (GtkMenuItem *item, GHidCoordEntry *ce) +static void menu_item_activate_cb(GtkMenuItem * item, GHidCoordEntry * ce) { - const char *text = gtk_menu_item_get_label (item); - const Unit *unit = get_unit_struct (text); - - g_signal_emit (ce, ghid_coord_entry_signals[UNIT_CHANGE_SIGNAL], 0, unit); + const char *text = gtk_menu_item_get_label(item); + const Unit *unit = get_unit_struct(text); + + g_signal_emit(ce, ghid_coord_entry_signals[UNIT_CHANGE_SIGNAL], 0, unit); } /*! \brief Callback for context menu creation */ -static void -ghid_coord_entry_popup_cb (GHidCoordEntry *ce, GtkMenu *menu, gpointer data) +static void ghid_coord_entry_popup_cb(GHidCoordEntry * ce, GtkMenu * menu, gpointer data) { - int i, n; - const Unit *unit_list; - GtkWidget *menu_item, *submenu; + int i, n; + const Unit *unit_list; + GtkWidget *menu_item, *submenu; - /* Build submenu */ - n = get_n_units (); - unit_list = get_unit_list (); + /* Build submenu */ + n = get_n_units(); + unit_list = get_unit_list(); - submenu = gtk_menu_new (); - for (i = 0; i < n; ++i) - { - menu_item = gtk_menu_item_new_with_label (unit_list[i].suffix); - g_signal_connect (G_OBJECT (menu_item), "activate", - G_CALLBACK (menu_item_activate_cb), ce); - gtk_menu_shell_append (GTK_MENU_SHELL (submenu), menu_item); - gtk_widget_show (menu_item); - } + submenu = gtk_menu_new(); + for (i = 0; i < n; ++i) { + menu_item = gtk_menu_item_new_with_label(unit_list[i].suffix); + g_signal_connect(G_OBJECT(menu_item), "activate", G_CALLBACK(menu_item_activate_cb), ce); + gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menu_item); + gtk_widget_show(menu_item); + } - /* Add submenu to menu */ - menu_item = gtk_separator_menu_item_new (); - gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item); - gtk_widget_show (menu_item); + /* Add submenu to menu */ + menu_item = gtk_separator_menu_item_new(); + gtk_menu_shell_prepend(GTK_MENU_SHELL(menu), menu_item); + gtk_widget_show(menu_item); - menu_item = gtk_menu_item_new_with_label (_("Change Units")); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), submenu); - gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item); - gtk_widget_show (menu_item); + menu_item = gtk_menu_item_new_with_label(_("Change Units")); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), submenu); + gtk_menu_shell_prepend(GTK_MENU_SHELL(menu), menu_item); + gtk_widget_show(menu_item); } /*! \brief Callback for user output */ -static gboolean -ghid_coord_entry_output_cb (GHidCoordEntry *ce, gpointer data) +static gboolean ghid_coord_entry_output_cb(GHidCoordEntry * ce, gpointer data) { - GtkAdjustment *adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (ce)); - double value = gtk_adjustment_get_value (adj); - gchar *text; + GtkAdjustment *adj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(ce)); + double value = gtk_adjustment_get_value(adj); + gchar *text; - text = pcb_g_strdup_printf ("%.*f %s", ce->unit->default_prec, value, ce->unit->suffix); - gtk_entry_set_text (GTK_ENTRY (ce), text); - g_free (text); - - return TRUE; + text = pcb_g_strdup_printf("%.*f %s", ce->unit->default_prec, value, ce->unit->suffix); + gtk_entry_set_text(GTK_ENTRY(ce), text); + g_free(text); + + return TRUE; } /*! \brief Callback for user input */ -static gboolean -ghid_coord_text_changed_cb (GHidCoordEntry *entry, gpointer data) +static gboolean ghid_coord_text_changed_cb(GHidCoordEntry * entry, gpointer data) { - const char *text; - char *suffix; - const Unit *new_unit; - double value; + const char *text; + char *suffix; + const Unit *new_unit; + double value; - /* Check if units have changed */ - text = gtk_entry_get_text (GTK_ENTRY (entry)); - value = strtod (text, &suffix); - new_unit = get_unit_struct (suffix); - if (new_unit && new_unit != entry->unit) - { - entry->value = unit_to_coord (new_unit, value); - g_signal_emit (entry, ghid_coord_entry_signals[UNIT_CHANGE_SIGNAL], 0, new_unit); - } + /* Check if units have changed */ + text = gtk_entry_get_text(GTK_ENTRY(entry)); + value = strtod(text, &suffix); + new_unit = get_unit_struct(suffix); + if (new_unit && new_unit != entry->unit) { + entry->value = unit_to_coord(new_unit, value); + g_signal_emit(entry, ghid_coord_entry_signals[UNIT_CHANGE_SIGNAL], 0, new_unit); + } - return FALSE; + return FALSE; } /*! \brief Callback for change in value (input or ^v clicks) */ -static gboolean -ghid_coord_value_changed_cb (GHidCoordEntry *ce, gpointer data) +static gboolean ghid_coord_value_changed_cb(GHidCoordEntry * ce, gpointer data) { - GtkAdjustment *adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (ce)); + GtkAdjustment *adj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(ce)); - /* Re-calculate internal value */ - double value = gtk_adjustment_get_value (adj); - ce->value = unit_to_coord (ce->unit, value); - /* Handle potential unit changes */ - ghid_coord_text_changed_cb (ce, data); + /* Re-calculate internal value */ + double value = gtk_adjustment_get_value(adj); + ce->value = unit_to_coord(ce->unit, value); + /* Handle potential unit changes */ + ghid_coord_text_changed_cb(ce, data); - return FALSE; + return FALSE; } /*! \brief Change the unit used by a coord entry @@ -147,93 +137,81 @@ * \param [in] ce The entry to be acted on * \parin [in] new_unit The new unit to be used */ -static void -ghid_coord_entry_change_unit (GHidCoordEntry *ce, const Unit *new_unit) +static void ghid_coord_entry_change_unit(GHidCoordEntry * ce, const Unit * new_unit) { - double climb_rate = 0.0; - GtkAdjustment *adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (ce)); + double climb_rate = 0.0; + GtkAdjustment *adj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(ce)); - ce->unit = new_unit; - /* Re-calculate min/max values for spinbox */ - gtk_adjustment_configure (adj, coord_to_unit (new_unit, ce->value), - coord_to_unit (new_unit, ce->min_value), - coord_to_unit (new_unit, ce->max_value), - ce->unit->step_small, - ce->unit->step_medium, - 0.0); + ce->unit = new_unit; + /* Re-calculate min/max values for spinbox */ + gtk_adjustment_configure(adj, coord_to_unit(new_unit, ce->value), + coord_to_unit(new_unit, ce->min_value), + coord_to_unit(new_unit, ce->max_value), ce->unit->step_small, ce->unit->step_medium, 0.0); - switch (ce->step_size) - { - case CE_TINY: climb_rate = new_unit->step_tiny; break; - case CE_SMALL: climb_rate = new_unit->step_small; break; - case CE_MEDIUM: climb_rate = new_unit->step_medium; break; - case CE_LARGE: climb_rate = new_unit->step_large; break; - } - gtk_spin_button_configure (GTK_SPIN_BUTTON (ce), adj, climb_rate, - new_unit->default_prec + strlen (new_unit->suffix)); + switch (ce->step_size) { + case CE_TINY: + climb_rate = new_unit->step_tiny; + break; + case CE_SMALL: + climb_rate = new_unit->step_small; + break; + case CE_MEDIUM: + climb_rate = new_unit->step_medium; + break; + case CE_LARGE: + climb_rate = new_unit->step_large; + break; + } + gtk_spin_button_configure(GTK_SPIN_BUTTON(ce), adj, climb_rate, new_unit->default_prec + strlen(new_unit->suffix)); } /* CONSTRUCTOR */ -static void -ghid_coord_entry_init (GHidCoordEntry *ce) +static void ghid_coord_entry_init(GHidCoordEntry * ce) { - /* Hookup signal handlers */ - g_signal_connect (G_OBJECT (ce), "focus_out_event", - G_CALLBACK (ghid_coord_text_changed_cb), NULL); - g_signal_connect (G_OBJECT (ce), "value_changed", - G_CALLBACK (ghid_coord_value_changed_cb), NULL); - g_signal_connect (G_OBJECT (ce), "populate_popup", - G_CALLBACK (ghid_coord_entry_popup_cb), NULL); - g_signal_connect (G_OBJECT (ce), "output", - G_CALLBACK (ghid_coord_entry_output_cb), NULL); + /* Hookup signal handlers */ + g_signal_connect(G_OBJECT(ce), "focus_out_event", G_CALLBACK(ghid_coord_text_changed_cb), NULL); + g_signal_connect(G_OBJECT(ce), "value_changed", G_CALLBACK(ghid_coord_value_changed_cb), NULL); + g_signal_connect(G_OBJECT(ce), "populate_popup", G_CALLBACK(ghid_coord_entry_popup_cb), NULL); + g_signal_connect(G_OBJECT(ce), "output", G_CALLBACK(ghid_coord_entry_output_cb), NULL); } -static void -ghid_coord_entry_class_init (GHidCoordEntryClass *klass) +static void ghid_coord_entry_class_init(GHidCoordEntryClass * klass) { - klass->change_unit = ghid_coord_entry_change_unit; + klass->change_unit = ghid_coord_entry_change_unit; - /* GtkAutoComplete *ce : the object acted on */ - /* const Unit *new_unit: the new unit that was set */ - ghid_coord_entry_signals[UNIT_CHANGE_SIGNAL] = - g_signal_new ("change-unit", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (GHidCoordEntryClass, change_unit), - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, - 1, G_TYPE_POINTER); + /* GtkAutoComplete *ce : the object acted on */ + /* const Unit *new_unit: the new unit that was set */ + ghid_coord_entry_signals[UNIT_CHANGE_SIGNAL] = + g_signal_new("change-unit", + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET(GHidCoordEntryClass, change_unit), + NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); } /* PUBLIC FUNCTIONS */ -GType -ghid_coord_entry_get_type (void) +GType ghid_coord_entry_get_type(void) { - static GType ce_type = 0; + static GType ce_type = 0; - if (!ce_type) - { - const GTypeInfo ce_info = - { - sizeof (GHidCoordEntryClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) ghid_coord_entry_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GHidCoordEntry), - 0, /* n_preallocs */ - (GInstanceInitFunc) ghid_coord_entry_init, - }; + if (!ce_type) { + const GTypeInfo ce_info = { + sizeof(GHidCoordEntryClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) ghid_coord_entry_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(GHidCoordEntry), + 0, /* n_preallocs */ + (GInstanceInitFunc) ghid_coord_entry_init, + }; - ce_type = g_type_register_static (GTK_TYPE_SPIN_BUTTON, - "GHidCoordEntry", - &ce_info, - 0); - } + ce_type = g_type_register_static(GTK_TYPE_SPIN_BUTTON, "GHidCoordEntry", &ce_info, 0); + } - return ce_type; + return ce_type; } /*! \brief Create a new GHidCoordEntry @@ -246,67 +224,58 @@ * * \return a freshly-allocated GHidCoordEntry */ -GtkWidget * -ghid_coord_entry_new (Coord min_val, Coord max_val, Coord value, - const Unit *unit, enum ce_step_size step_size) +GtkWidget *ghid_coord_entry_new(Coord min_val, Coord max_val, Coord value, const Unit * unit, enum ce_step_size step_size) { - /* Setup spinbox min/max values */ - double small_step, big_step; - GtkAdjustment *adj; - GHidCoordEntry *ce = g_object_new (GHID_COORD_ENTRY_TYPE, NULL); + /* Setup spinbox min/max values */ + double small_step, big_step; + GtkAdjustment *adj; + GHidCoordEntry *ce = g_object_new(GHID_COORD_ENTRY_TYPE, NULL); - ce->unit = unit; - ce->min_value = min_val; - ce->max_value = max_val; - ce->value = value; + ce->unit = unit; + ce->min_value = min_val; + ce->max_value = max_val; + ce->value = value; - ce->step_size = step_size; - switch (step_size) - { - case CE_TINY: - small_step = unit->step_tiny; - big_step = unit->step_small; - break; - case CE_SMALL: - small_step = unit->step_small; - big_step = unit->step_medium; - break; - case CE_MEDIUM: - small_step = unit->step_medium; - big_step = unit->step_large; - break; - case CE_LARGE: - small_step = unit->step_large; - big_step = unit->step_huge; - break; - default: - small_step = big_step = 0; - break; - } + ce->step_size = step_size; + switch (step_size) { + case CE_TINY: + small_step = unit->step_tiny; + big_step = unit->step_small; + break; + case CE_SMALL: + small_step = unit->step_small; + big_step = unit->step_medium; + break; + case CE_MEDIUM: + small_step = unit->step_medium; + big_step = unit->step_large; + break; + case CE_LARGE: + small_step = unit->step_large; + big_step = unit->step_huge; + break; + default: + small_step = big_step = 0; + break; + } - adj = GTK_ADJUSTMENT (gtk_adjustment_new (coord_to_unit (unit, value), - coord_to_unit (unit, min_val), - coord_to_unit (unit, max_val), - small_step, big_step, 0.0)); - gtk_spin_button_configure (GTK_SPIN_BUTTON (ce), adj, small_step, - unit->default_prec + strlen (unit->suffix)); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (ce), FALSE); + adj = GTK_ADJUSTMENT(gtk_adjustment_new(coord_to_unit(unit, value), + coord_to_unit(unit, min_val), + coord_to_unit(unit, max_val), small_step, big_step, 0.0)); + gtk_spin_button_configure(GTK_SPIN_BUTTON(ce), adj, small_step, unit->default_prec + strlen(unit->suffix)); + gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(ce), FALSE); - return GTK_WIDGET (ce); + return GTK_WIDGET(ce); } /*! \brief Gets a GHidCoordEntry's value, in pcb coords */ -Coord -ghid_coord_entry_get_value (GHidCoordEntry *ce) +Coord ghid_coord_entry_get_value(GHidCoordEntry * ce) { - return ce->value; + return ce->value; } /*! \brief Sets a GHidCoordEntry's value, in pcb coords */ -void -ghid_coord_entry_set_value (GHidCoordEntry *ce, Coord val) +void ghid_coord_entry_set_value(GHidCoordEntry * ce, Coord val) { - gtk_spin_button_set_value (GTK_SPIN_BUTTON (ce), - coord_to_unit (ce->unit, val)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(ce), coord_to_unit(ce->unit, val)); } - Index: trunk/src/hid/gtk/ghid-coord-entry.h =================================================================== --- trunk/src/hid/gtk/ghid-coord-entry.h (revision 1021) +++ trunk/src/hid/gtk/ghid-coord-entry.h (revision 1022) @@ -8,28 +8,25 @@ #include #include -G_BEGIN_DECLS /* keep c++ happy */ - +G_BEGIN_DECLS /* keep c++ happy */ #define GHID_COORD_ENTRY_TYPE (ghid_coord_entry_get_type ()) #define GHID_COORD_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GHID_COORD_ENTRY_TYPE, GHidCoordEntry)) #define GHID_COORD_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GHID_COORD_ENTRY_TYPE, GHidCoordEntryClass)) #define IS_GHID_COORD_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GHID_COORD_ENTRY_TYPE)) #define IS_GHID_COORD_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GHID_COORD_ENTRY_TYPE)) +typedef struct _GHidCoordEntry GHidCoordEntry; +typedef struct _GHidCoordEntryClass GHidCoordEntryClass; -typedef struct _GHidCoordEntry GHidCoordEntry; -typedef struct _GHidCoordEntryClass GHidCoordEntryClass; - /* Step sizes */ enum ce_step_size { CE_TINY, CE_SMALL, CE_MEDIUM, CE_LARGE }; -GType ghid_coord_entry_get_type (void); -GtkWidget* ghid_coord_entry_new (Coord min_val, Coord max_val, Coord value, - const Unit *unit, enum ce_step_size step_size); -void ghid_coord_entry_add_entry (GHidCoordEntry *ce, const gchar *name, const gchar *desc); -gchar *ghid_coord_entry_get_last_command (GHidCoordEntry *ce); +GType ghid_coord_entry_get_type(void); +GtkWidget *ghid_coord_entry_new(Coord min_val, Coord max_val, Coord value, const Unit * unit, enum ce_step_size step_size); +void ghid_coord_entry_add_entry(GHidCoordEntry * ce, const gchar * name, const gchar * desc); +gchar *ghid_coord_entry_get_last_command(GHidCoordEntry * ce); -Coord ghid_coord_entry_get_value (GHidCoordEntry *ce); -void ghid_coord_entry_set_value (GHidCoordEntry *ce, Coord val); +Coord ghid_coord_entry_get_value(GHidCoordEntry * ce); +void ghid_coord_entry_set_value(GHidCoordEntry * ce, Coord val); -G_END_DECLS /* keep c++ happy */ +G_END_DECLS /* keep c++ happy */ #endif Index: trunk/src/hid/gtk/ghid-layer-selector.c =================================================================== --- trunk/src/hid/gtk/ghid-layer-selector.c (revision 1021) +++ trunk/src/hid/gtk/ghid-layer-selector.c (revision 1022) @@ -22,114 +22,100 @@ /* Forward dec'ls */ struct _layer; -static void ghid_layer_selector_finalize (GObject *object); -static void menu_pick_cb (GtkRadioAction *action, struct _layer *ldata); +static void ghid_layer_selector_finalize(GObject * object); +static void menu_pick_cb(GtkRadioAction * action, struct _layer *ldata); /*! \brief Signals exposed by the widget */ enum { - SELECT_LAYER_SIGNAL, - TOGGLE_LAYER_SIGNAL, - LAST_SIGNAL + SELECT_LAYER_SIGNAL, + TOGGLE_LAYER_SIGNAL, + LAST_SIGNAL }; /*! \brief Columns used for internal data store */ enum { - STRUCT_COL, - USER_ID_COL, - VISIBLE_COL, - COLOR_COL, - TEXT_COL, - FONT_COL, - ACTIVATABLE_COL, - SEPARATOR_COL, - N_COLS + STRUCT_COL, + USER_ID_COL, + VISIBLE_COL, + COLOR_COL, + TEXT_COL, + FONT_COL, + ACTIVATABLE_COL, + SEPARATOR_COL, + N_COLS }; static GtkTreeView *ghid_layer_selector_parent_class; static guint ghid_layer_selector_signals[LAST_SIGNAL] = { 0 }; -struct _GHidLayerSelector -{ - GtkTreeView parent; +struct _GHidLayerSelector { + GtkTreeView parent; - GtkListStore *list_store; - GtkTreeSelection *selection; - GtkTreeViewColumn *visibility_column; + GtkListStore *list_store; + GtkTreeSelection *selection; + GtkTreeViewColumn *visibility_column; - GtkActionGroup *action_group; - GtkAccelGroup *accel_group; + GtkActionGroup *action_group; + GtkAccelGroup *accel_group; - GSList *radio_group; - int n_actions; + GSList *radio_group; + int n_actions; - gboolean accel_available[20]; + gboolean accel_available[20]; - gboolean last_activatable; + gboolean last_activatable; - gulong selection_changed_sig_id; + gulong selection_changed_sig_id; }; -struct _GHidLayerSelectorClass -{ - GtkTreeViewClass parent_class; +struct _GHidLayerSelectorClass { + GtkTreeViewClass parent_class; - void (* select_layer) (GHidLayerSelector *, gint); - void (* toggle_layer) (GHidLayerSelector *, gint); + void (*select_layer) (GHidLayerSelector *, gint); + void (*toggle_layer) (GHidLayerSelector *, gint); }; -struct _layer -{ - gint accel_index; /* Index into ls->accel_available */ - GtkWidget *pick_item; - GtkWidget *view_item; - GtkToggleAction *view_action; - GtkRadioAction *pick_action; - GtkTreeRowReference *rref; +struct _layer { + gint accel_index; /* Index into ls->accel_available */ + GtkWidget *pick_item; + GtkWidget *view_item; + GtkToggleAction *view_action; + GtkRadioAction *pick_action; + GtkTreeRowReference *rref; }; /*! \brief Deletes the action and accelerator from a layer */ -static void -free_ldata (GHidLayerSelector *ls, struct _layer *ldata) +static void free_ldata(GHidLayerSelector * ls, struct _layer *ldata) { - if (ldata->pick_action) - { - gtk_action_disconnect_accelerator - (GTK_ACTION (ldata->pick_action)); - gtk_action_group_remove_action (ls->action_group, - GTK_ACTION (ldata->pick_action)); + if (ldata->pick_action) { + gtk_action_disconnect_accelerator(GTK_ACTION(ldata->pick_action)); + gtk_action_group_remove_action(ls->action_group, GTK_ACTION(ldata->pick_action)); /* TODO: make this work without wrecking the radio action group * g_object_unref (G_OBJECT (ldata->pick_action)); * */ - } - if (ldata->view_action) - { - gtk_action_disconnect_accelerator - (GTK_ACTION (ldata->view_action)); - gtk_action_group_remove_action (ls->action_group, - GTK_ACTION (ldata->view_action)); - g_object_unref (G_OBJECT (ldata->view_action)); - } - gtk_tree_row_reference_free (ldata->rref); - if (ldata->accel_index >= 0) - ls->accel_available[ldata->accel_index] = TRUE; - g_free (ldata); + } + if (ldata->view_action) { + gtk_action_disconnect_accelerator(GTK_ACTION(ldata->view_action)); + gtk_action_group_remove_action(ls->action_group, GTK_ACTION(ldata->view_action)); + g_object_unref(G_OBJECT(ldata->view_action)); + } + gtk_tree_row_reference_free(ldata->rref); + if (ldata->accel_index >= 0) + ls->accel_available[ldata->accel_index] = TRUE; + g_free(ldata); } /*! \brief internal set-visibility function -- emits no signals */ -static void -set_visibility (GHidLayerSelector *ls, GtkTreeIter *iter, - struct _layer *ldata, gboolean state) +static void set_visibility(GHidLayerSelector * ls, GtkTreeIter * iter, struct _layer *ldata, gboolean state) { - gtk_list_store_set (ls->list_store, iter, VISIBLE_COL, state, -1); - - if (ldata) - { - gtk_action_block_activate (GTK_ACTION (ldata->view_action)); - gtk_check_menu_item_set_active - (GTK_CHECK_MENU_ITEM (ldata->view_item), state); - gtk_action_unblock_activate (GTK_ACTION (ldata->view_action)); - } + gtk_list_store_set(ls->list_store, iter, VISIBLE_COL, state, -1); + + if (ldata) { + gtk_action_block_activate(GTK_ACTION(ldata->view_action)); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ldata->view_item), state); + gtk_action_unblock_activate(GTK_ACTION(ldata->view_action)); + } } /*! \brief Flip the visibility state of a given layer @@ -141,239 +127,198 @@ * \param [in] iter A GtkTreeIter pointed at the relevant layer * \param [in] emit Whether or not to emit a signal */ -static void -toggle_visibility (GHidLayerSelector *ls, GtkTreeIter *iter, gboolean emit) +static void toggle_visibility(GHidLayerSelector * ls, GtkTreeIter * iter, gboolean emit) { - gint user_id; - struct _layer *ldata; - gboolean toggle; - gtk_tree_model_get (GTK_TREE_MODEL (ls->list_store), iter, - USER_ID_COL, &user_id, VISIBLE_COL, &toggle, - STRUCT_COL, &ldata, -1); - set_visibility (ls, iter, ldata, !toggle); - if (emit) - g_signal_emit (ls, ghid_layer_selector_signals[TOGGLE_LAYER_SIGNAL], - 0, user_id); + gint user_id; + struct _layer *ldata; + gboolean toggle; + gtk_tree_model_get(GTK_TREE_MODEL(ls->list_store), iter, USER_ID_COL, &user_id, VISIBLE_COL, &toggle, STRUCT_COL, &ldata, -1); + set_visibility(ls, iter, ldata, !toggle); + if (emit) + g_signal_emit(ls, ghid_layer_selector_signals[TOGGLE_LAYER_SIGNAL], 0, user_id); } /*! \brief Decide if a GtkListStore entry is a layer or separator */ -static gboolean -tree_view_separator_func (GtkTreeModel *model, GtkTreeIter *iter, - gpointer data) +static gboolean tree_view_separator_func(GtkTreeModel * model, GtkTreeIter * iter, gpointer data) { - gboolean ret_val; - gtk_tree_model_get (model, iter, SEPARATOR_COL, &ret_val, -1); - return ret_val; + gboolean ret_val; + gtk_tree_model_get(model, iter, SEPARATOR_COL, &ret_val, -1); + return ret_val; } /*! \brief Decide if a GtkListStore entry may be selected */ static gboolean -tree_selection_func (GtkTreeSelection *selection, GtkTreeModel *model, - GtkTreePath *path, gboolean selected, gpointer data) +tree_selection_func(GtkTreeSelection * selection, GtkTreeModel * model, GtkTreePath * path, gboolean selected, gpointer data) { - GtkTreeIter iter; + GtkTreeIter iter; - if (gtk_tree_model_get_iter (model, &iter, path)) - { - gboolean activatable; - gtk_tree_model_get (model, &iter, ACTIVATABLE_COL, &activatable, -1); - return activatable; - } + if (gtk_tree_model_get_iter(model, &iter, path)) { + gboolean activatable; + gtk_tree_model_get(model, &iter, ACTIVATABLE_COL, &activatable, -1); + return activatable; + } - return FALSE; + return FALSE; } /* SIGNAL HANDLERS */ /*! \brief Callback for mouse-click: toggle visibility */ -static gboolean -button_press_cb (GHidLayerSelector *ls, GdkEventButton *event) +static gboolean button_press_cb(GHidLayerSelector * ls, GdkEventButton * event) { - /* Handle visibility independently to prevent changing the active - * layer, which will happen if we let this event propagate. */ - GtkTreeViewColumn *column; - GtkTreePath *path; + /* Handle visibility independently to prevent changing the active + * layer, which will happen if we let this event propagate. */ + GtkTreeViewColumn *column; + GtkTreePath *path; - /* Ignore the synthetic presses caused by double and tripple clicks, and - * also ignore all but left-clicks - */ - if (event->type != GDK_BUTTON_PRESS || - event->button != 1) - return TRUE; + /* Ignore the synthetic presses caused by double and tripple clicks, and + * also ignore all but left-clicks + */ + if (event->type != GDK_BUTTON_PRESS || event->button != 1) + return TRUE; - if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (ls), - event->x, event->y, - &path, &column, NULL, NULL)) - { - GtkTreeIter iter; - gboolean activatable, separator; - gtk_tree_model_get_iter (GTK_TREE_MODEL (ls->list_store), &iter, path); - gtk_tree_model_get (GTK_TREE_MODEL (ls->list_store), &iter, - ACTIVATABLE_COL, &activatable, - SEPARATOR_COL, &separator, -1); - /* Toggle visibility for non-activatable layers no matter - * where you click. */ - if (!separator && (column == ls->visibility_column || !activatable)) - { - toggle_visibility (ls, &iter, TRUE); - return TRUE; - } - } - return FALSE; + if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(ls), event->x, event->y, &path, &column, NULL, NULL)) { + GtkTreeIter iter; + gboolean activatable, separator; + gtk_tree_model_get_iter(GTK_TREE_MODEL(ls->list_store), &iter, path); + gtk_tree_model_get(GTK_TREE_MODEL(ls->list_store), &iter, ACTIVATABLE_COL, &activatable, SEPARATOR_COL, &separator, -1); + /* Toggle visibility for non-activatable layers no matter + * where you click. */ + if (!separator && (column == ls->visibility_column || !activatable)) { + toggle_visibility(ls, &iter, TRUE); + return TRUE; + } + } + return FALSE; } /*! \brief Callback for layer selection change: sync menu, emit signal */ -static void -selection_changed_cb (GtkTreeSelection *selection, GHidLayerSelector *ls) +static void selection_changed_cb(GtkTreeSelection * selection, GHidLayerSelector * ls) { - GtkTreeIter iter; - if (gtk_tree_selection_get_selected (selection, NULL, &iter)) - { - gint user_id; - struct _layer *ldata; - gtk_tree_model_get (GTK_TREE_MODEL (ls->list_store), &iter, - STRUCT_COL, &ldata, USER_ID_COL, &user_id, -1); + GtkTreeIter iter; + if (gtk_tree_selection_get_selected(selection, NULL, &iter)) { + gint user_id; + struct _layer *ldata; + gtk_tree_model_get(GTK_TREE_MODEL(ls->list_store), &iter, STRUCT_COL, &ldata, USER_ID_COL, &user_id, -1); - if (ldata && ldata->pick_action) - { - gtk_action_block_activate (GTK_ACTION (ldata->pick_action)); - gtk_radio_action_set_current_value (ldata->pick_action, user_id); - gtk_action_unblock_activate (GTK_ACTION (ldata->pick_action)); - } - g_signal_emit (ls, ghid_layer_selector_signals[SELECT_LAYER_SIGNAL], - 0, user_id); - } + if (ldata && ldata->pick_action) { + gtk_action_block_activate(GTK_ACTION(ldata->pick_action)); + gtk_radio_action_set_current_value(ldata->pick_action, user_id); + gtk_action_unblock_activate(GTK_ACTION(ldata->pick_action)); + } + g_signal_emit(ls, ghid_layer_selector_signals[SELECT_LAYER_SIGNAL], 0, user_id); + } } /*! \brief Callback for menu actions: sync layer selection list, emit signal */ -static void -menu_view_cb (GtkToggleAction *action, struct _layer *ldata) +static void menu_view_cb(GtkToggleAction * action, struct _layer *ldata) { - GHidLayerSelector *ls; - GtkTreeModel *model = gtk_tree_row_reference_get_model (ldata->rref); - GtkTreePath *path = gtk_tree_row_reference_get_path (ldata->rref); - gboolean state = gtk_toggle_action_get_active (action); - GtkTreeIter iter; - gint user_id; + GHidLayerSelector *ls; + GtkTreeModel *model = gtk_tree_row_reference_get_model(ldata->rref); + GtkTreePath *path = gtk_tree_row_reference_get_path(ldata->rref); + gboolean state = gtk_toggle_action_get_active(action); + GtkTreeIter iter; + gint user_id; - gtk_tree_model_get_iter (model, &iter, path); - gtk_list_store_set (GTK_LIST_STORE (model), &iter, VISIBLE_COL, state, -1); - gtk_tree_model_get (model, &iter, USER_ID_COL, &user_id, -1); + gtk_tree_model_get_iter(model, &iter, path); + gtk_list_store_set(GTK_LIST_STORE(model), &iter, VISIBLE_COL, state, -1); + gtk_tree_model_get(model, &iter, USER_ID_COL, &user_id, -1); - ls = g_object_get_data (G_OBJECT (model), "layer-selector"); - g_signal_emit (ls, ghid_layer_selector_signals[TOGGLE_LAYER_SIGNAL], - 0, user_id); + ls = g_object_get_data(G_OBJECT(model), "layer-selector"); + g_signal_emit(ls, ghid_layer_selector_signals[TOGGLE_LAYER_SIGNAL], 0, user_id); } /*! \brief Callback for menu actions: sync layer selection list, emit signal */ -static void -menu_pick_cb (GtkRadioAction *action, struct _layer *ldata) +static void menu_pick_cb(GtkRadioAction * action, struct _layer *ldata) { - /* We only care about the activation signal (as opposed to deactivation). - * A row we are /deactivating/ might not even exist anymore! */ - if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) - { - GHidLayerSelector *ls; - GtkTreeModel *model = gtk_tree_row_reference_get_model (ldata->rref); - GtkTreePath *path = gtk_tree_row_reference_get_path (ldata->rref); - GtkTreeIter iter; - gint user_id; + /* We only care about the activation signal (as opposed to deactivation). + * A row we are /deactivating/ might not even exist anymore! */ + if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action))) { + GHidLayerSelector *ls; + GtkTreeModel *model = gtk_tree_row_reference_get_model(ldata->rref); + GtkTreePath *path = gtk_tree_row_reference_get_path(ldata->rref); + GtkTreeIter iter; + gint user_id; - gtk_tree_model_get_iter (model, &iter, path); - gtk_tree_model_get (model, &iter, USER_ID_COL, &user_id, -1); + gtk_tree_model_get_iter(model, &iter, path); + gtk_tree_model_get(model, &iter, USER_ID_COL, &user_id, -1); - ls = g_object_get_data (G_OBJECT (model), "layer-selector"); - g_signal_handler_block (ls->selection, ls->selection_changed_sig_id); - gtk_tree_selection_select_path (ls->selection, path); - g_signal_handler_unblock (ls->selection, ls->selection_changed_sig_id); - g_signal_emit (ls, ghid_layer_selector_signals[SELECT_LAYER_SIGNAL], - 0, user_id); - } + ls = g_object_get_data(G_OBJECT(model), "layer-selector"); + g_signal_handler_block(ls->selection, ls->selection_changed_sig_id); + gtk_tree_selection_select_path(ls->selection, path); + g_signal_handler_unblock(ls->selection, ls->selection_changed_sig_id); + g_signal_emit(ls, ghid_layer_selector_signals[SELECT_LAYER_SIGNAL], 0, user_id); + } } /* CONSTRUCTOR */ -static void -ghid_layer_selector_init (GHidLayerSelector *ls) +static void ghid_layer_selector_init(GHidLayerSelector * ls) { - /* Hookup signal handlers */ + /* Hookup signal handlers */ } -static void -ghid_layer_selector_class_init (GHidLayerSelectorClass *klass) +static void ghid_layer_selector_class_init(GHidLayerSelectorClass * klass) { - GObjectClass *object_class = (GObjectClass *) klass; + GObjectClass *object_class = (GObjectClass *) klass; - ghid_layer_selector_signals[SELECT_LAYER_SIGNAL] = - g_signal_new ("select-layer", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (GHidLayerSelectorClass, select_layer), - NULL, NULL, - g_cclosure_marshal_VOID__INT, G_TYPE_NONE, - 1, G_TYPE_INT); - ghid_layer_selector_signals[TOGGLE_LAYER_SIGNAL] = - g_signal_new ("toggle-layer", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (GHidLayerSelectorClass, toggle_layer), - NULL, NULL, - g_cclosure_marshal_VOID__INT, G_TYPE_NONE, - 1, G_TYPE_INT); + ghid_layer_selector_signals[SELECT_LAYER_SIGNAL] = + g_signal_new("select-layer", + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET(GHidLayerSelectorClass, select_layer), + NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT); + ghid_layer_selector_signals[TOGGLE_LAYER_SIGNAL] = + g_signal_new("toggle-layer", + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET(GHidLayerSelectorClass, toggle_layer), + NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT); - object_class->finalize = ghid_layer_selector_finalize; + object_class->finalize = ghid_layer_selector_finalize; } /*! \brief Clean up object before garbage collection */ -static void -ghid_layer_selector_finalize (GObject *object) +static void ghid_layer_selector_finalize(GObject * object) { - GtkTreeIter iter; - GHidLayerSelector *ls = (GHidLayerSelector *) object; + GtkTreeIter iter; + GHidLayerSelector *ls = (GHidLayerSelector *) object; - g_object_unref (ls->accel_group); - g_object_unref (ls->action_group); + g_object_unref(ls->accel_group); + g_object_unref(ls->action_group); - gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ls->list_store), &iter); - do - { - struct _layer *ldata; - gtk_tree_model_get (GTK_TREE_MODEL (ls->list_store), - &iter, STRUCT_COL, &ldata, -1); - free_ldata (ls, ldata); - } - while (gtk_tree_model_iter_next (GTK_TREE_MODEL (ls->list_store), &iter)); + gtk_tree_model_get_iter_first(GTK_TREE_MODEL(ls->list_store), &iter); + do { + struct _layer *ldata; + gtk_tree_model_get(GTK_TREE_MODEL(ls->list_store), &iter, STRUCT_COL, &ldata, -1); + free_ldata(ls, ldata); + } + while (gtk_tree_model_iter_next(GTK_TREE_MODEL(ls->list_store), &iter)); - G_OBJECT_CLASS (ghid_layer_selector_parent_class)->finalize (object); + G_OBJECT_CLASS(ghid_layer_selector_parent_class)->finalize(object); } /* PUBLIC FUNCTIONS */ -GType -ghid_layer_selector_get_type (void) +GType ghid_layer_selector_get_type(void) { - static GType ls_type = 0; + static GType ls_type = 0; - if (!ls_type) - { - const GTypeInfo ls_info = - { - sizeof (GHidLayerSelectorClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) ghid_layer_selector_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GHidLayerSelector), - 0, /* n_preallocs */ - (GInstanceInitFunc) ghid_layer_selector_init, - }; + if (!ls_type) { + const GTypeInfo ls_info = { + sizeof(GHidLayerSelectorClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) ghid_layer_selector_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(GHidLayerSelector), + 0, /* n_preallocs */ + (GInstanceInitFunc) ghid_layer_selector_init, + }; - ls_type = g_type_register_static (GTK_TYPE_TREE_VIEW, - "GHidLayerSelector", - &ls_info, - 0); - } + ls_type = g_type_register_static(GTK_TYPE_TREE_VIEW, "GHidLayerSelector", &ls_info, 0); + } - return ls_type; + return ls_type; } /*! \brief Create a new GHidLayerSelector @@ -380,60 +325,50 @@ * * \return a freshly-allocated GHidLayerSelector. */ -GtkWidget * -ghid_layer_selector_new (void) +GtkWidget *ghid_layer_selector_new(void) { - int i; - GtkCellRenderer *renderer1 = ghid_cell_renderer_visibility_new (); - GtkCellRenderer *renderer2 = gtk_cell_renderer_text_new (); - GtkTreeViewColumn *opacity_col = - gtk_tree_view_column_new_with_attributes ("", renderer1, - "active", VISIBLE_COL, - "color", COLOR_COL, NULL); - GtkTreeViewColumn *name_col = - gtk_tree_view_column_new_with_attributes ("", renderer2, - "text", TEXT_COL, - "font", FONT_COL, - NULL); + int i; + GtkCellRenderer *renderer1 = ghid_cell_renderer_visibility_new(); + GtkCellRenderer *renderer2 = gtk_cell_renderer_text_new(); + GtkTreeViewColumn *opacity_col = gtk_tree_view_column_new_with_attributes("", renderer1, + "active", VISIBLE_COL, + "color", COLOR_COL, NULL); + GtkTreeViewColumn *name_col = gtk_tree_view_column_new_with_attributes("", renderer2, + "text", TEXT_COL, + "font", FONT_COL, + NULL); - GHidLayerSelector *ls = g_object_new (GHID_LAYER_SELECTOR_TYPE, NULL); + GHidLayerSelector *ls = g_object_new(GHID_LAYER_SELECTOR_TYPE, NULL); - /* action index, active, color, text, font, is_separator */ - ls->list_store = gtk_list_store_new (N_COLS, G_TYPE_POINTER, G_TYPE_INT, - G_TYPE_BOOLEAN, G_TYPE_STRING, - G_TYPE_STRING, G_TYPE_STRING, - G_TYPE_BOOLEAN, G_TYPE_BOOLEAN); - gtk_tree_view_insert_column (GTK_TREE_VIEW (ls), opacity_col, -1); - gtk_tree_view_insert_column (GTK_TREE_VIEW (ls), name_col, -1); - gtk_tree_view_set_model (GTK_TREE_VIEW (ls), GTK_TREE_MODEL (ls->list_store)); - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (ls), FALSE); + /* action index, active, color, text, font, is_separator */ + ls->list_store = gtk_list_store_new(N_COLS, G_TYPE_POINTER, G_TYPE_INT, + G_TYPE_BOOLEAN, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN); + gtk_tree_view_insert_column(GTK_TREE_VIEW(ls), opacity_col, -1); + gtk_tree_view_insert_column(GTK_TREE_VIEW(ls), name_col, -1); + gtk_tree_view_set_model(GTK_TREE_VIEW(ls), GTK_TREE_MODEL(ls->list_store)); + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(ls), FALSE); - ls->last_activatable = TRUE; - ls->visibility_column = opacity_col; - ls->selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (ls)); - ls->accel_group = gtk_accel_group_new (); - ls->action_group = gtk_action_group_new ("LayerSelector"); - ls->n_actions = 0; - for (i = 0; i < 20; ++i) - ls->accel_available[i] = TRUE; + ls->last_activatable = TRUE; + ls->visibility_column = opacity_col; + ls->selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ls)); + ls->accel_group = gtk_accel_group_new(); + ls->action_group = gtk_action_group_new("LayerSelector"); + ls->n_actions = 0; + for (i = 0; i < 20; ++i) + ls->accel_available[i] = TRUE; - gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (ls), - tree_view_separator_func, - NULL, NULL); - gtk_tree_selection_set_select_function (ls->selection, tree_selection_func, - NULL, NULL); - gtk_tree_selection_set_mode (ls->selection, GTK_SELECTION_BROWSE); + gtk_tree_view_set_row_separator_func(GTK_TREE_VIEW(ls), tree_view_separator_func, NULL, NULL); + gtk_tree_selection_set_select_function(ls->selection, tree_selection_func, NULL, NULL); + gtk_tree_selection_set_mode(ls->selection, GTK_SELECTION_BROWSE); - g_object_set_data (G_OBJECT (ls->list_store), "layer-selector", ls); - g_signal_connect (ls, "button_press_event", - G_CALLBACK (button_press_cb), NULL); - ls->selection_changed_sig_id = - g_signal_connect (ls->selection, "changed", - G_CALLBACK (selection_changed_cb), ls); + g_object_set_data(G_OBJECT(ls->list_store), "layer-selector", ls); + g_signal_connect(ls, "button_press_event", G_CALLBACK(button_press_cb), NULL); + ls->selection_changed_sig_id = g_signal_connect(ls->selection, "changed", G_CALLBACK(selection_changed_cb), ls); - g_object_ref (ls->accel_group); + g_object_ref(ls->accel_group); - return GTK_WIDGET (ls); + return GTK_WIDGET(ls); } /*! \brief Add a layer to a GHidLayerSelector. @@ -454,162 +389,130 @@ * \param [in] activatable Whether the layer appears in menus and can be selected */ void -ghid_layer_selector_add_layer (GHidLayerSelector *ls, - gint user_id, - const gchar *name, - const gchar *color_string, - gboolean visible, - gboolean activatable) +ghid_layer_selector_add_layer(GHidLayerSelector * ls, + gint user_id, + const gchar * name, const gchar * color_string, gboolean visible, gboolean activatable) { - struct _layer *new_layer = NULL; - gchar *pname, *vname; - gboolean new_iter = TRUE; - gboolean last_activatable = TRUE; - GtkTreePath *path; - GtkTreeIter iter; - int i; + struct _layer *new_layer = NULL; + gchar *pname, *vname; + gboolean new_iter = TRUE; + gboolean last_activatable = TRUE; + GtkTreePath *path; + GtkTreeIter iter; + int i; - /* Look for existing layer with this ID */ - if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ls->list_store), &iter)) - do - { - gboolean is_sep, active; - gint read_id; - gtk_tree_model_get (GTK_TREE_MODEL (ls->list_store), - &iter, USER_ID_COL, &read_id, - SEPARATOR_COL, &is_sep, - ACTIVATABLE_COL, &active, -1); - if (!is_sep) - { - last_activatable = active; - if(read_id == user_id) - { - new_iter = FALSE; - break; - } - } - } - while (gtk_tree_model_iter_next (GTK_TREE_MODEL (ls->list_store), &iter)); + /* Look for existing layer with this ID */ + if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(ls->list_store), &iter)) + do { + gboolean is_sep, active; + gint read_id; + gtk_tree_model_get(GTK_TREE_MODEL(ls->list_store), + &iter, USER_ID_COL, &read_id, SEPARATOR_COL, &is_sep, ACTIVATABLE_COL, &active, -1); + if (!is_sep) { + last_activatable = active; + if (read_id == user_id) { + new_iter = FALSE; + break; + } + } + } + while (gtk_tree_model_iter_next(GTK_TREE_MODEL(ls->list_store), &iter)); - /* Handle separator addition */ - if (new_iter) - { - if (activatable != last_activatable) - { - /* Add separator between activatable/non-activatable boundaries */ - gtk_list_store_append (ls->list_store, &iter); - gtk_list_store_set (ls->list_store, &iter, - STRUCT_COL, NULL, - SEPARATOR_COL, TRUE, -1); - } - /* Create new layer */ - new_layer = malloc (sizeof (*new_layer)); - gtk_list_store_append (ls->list_store, &iter); - gtk_list_store_set (ls->list_store, &iter, - STRUCT_COL, new_layer, - USER_ID_COL, user_id, - VISIBLE_COL, visible, - COLOR_COL, color_string, - TEXT_COL, name, - FONT_COL, activatable ? NULL : "Italic", - ACTIVATABLE_COL, activatable, - SEPARATOR_COL, FALSE, - -1); - } - else - { - /* If the row exists, we clear out its ldata to create - * a new action, accelerator and menu item. */ - gtk_tree_model_get (GTK_TREE_MODEL (ls->list_store), &iter, - STRUCT_COL, &new_layer, -1); - free_ldata (ls, new_layer); - new_layer = malloc (sizeof (*new_layer)); + /* Handle separator addition */ + if (new_iter) { + if (activatable != last_activatable) { + /* Add separator between activatable/non-activatable boundaries */ + gtk_list_store_append(ls->list_store, &iter); + gtk_list_store_set(ls->list_store, &iter, STRUCT_COL, NULL, SEPARATOR_COL, TRUE, -1); + } + /* Create new layer */ + new_layer = malloc(sizeof(*new_layer)); + gtk_list_store_append(ls->list_store, &iter); + gtk_list_store_set(ls->list_store, &iter, + STRUCT_COL, new_layer, + USER_ID_COL, user_id, + VISIBLE_COL, visible, + COLOR_COL, color_string, + TEXT_COL, name, + FONT_COL, activatable ? NULL : "Italic", ACTIVATABLE_COL, activatable, SEPARATOR_COL, FALSE, -1); + } + else { + /* If the row exists, we clear out its ldata to create + * a new action, accelerator and menu item. */ + gtk_tree_model_get(GTK_TREE_MODEL(ls->list_store), &iter, STRUCT_COL, &new_layer, -1); + free_ldata(ls, new_layer); + new_layer = malloc(sizeof(*new_layer)); - gtk_list_store_set (ls->list_store, &iter, - STRUCT_COL, new_layer, - VISIBLE_COL, visible, - COLOR_COL, color_string, - TEXT_COL, name, - FONT_COL, activatable ? NULL : "Italic", - ACTIVATABLE_COL, activatable, - -1); - } + gtk_list_store_set(ls->list_store, &iter, + STRUCT_COL, new_layer, + VISIBLE_COL, visible, + COLOR_COL, color_string, + TEXT_COL, name, FONT_COL, activatable ? NULL : "Italic", ACTIVATABLE_COL, activatable, -1); + } - /* -- Setup new actions -- */ - vname = g_strdup_printf ("LayerView%d", ls->n_actions); - pname = g_strdup_printf ("LayerPick%d", ls->n_actions); + /* -- Setup new actions -- */ + vname = g_strdup_printf("LayerView%d", ls->n_actions); + pname = g_strdup_printf("LayerPick%d", ls->n_actions); - /* Create row reference for actions */ - path = gtk_tree_model_get_path (GTK_TREE_MODEL (ls->list_store), &iter); - new_layer->rref = gtk_tree_row_reference_new - (GTK_TREE_MODEL (ls->list_store), path); - gtk_tree_path_free (path); + /* Create row reference for actions */ + path = gtk_tree_model_get_path(GTK_TREE_MODEL(ls->list_store), &iter); + new_layer->rref = gtk_tree_row_reference_new(GTK_TREE_MODEL(ls->list_store), path); + gtk_tree_path_free(path); - /* Create selection action */ - if (activatable) - { - new_layer->pick_action - = gtk_radio_action_new (pname, name, NULL, NULL, user_id); - gtk_radio_action_set_group (new_layer->pick_action, ls->radio_group); - ls->radio_group = gtk_radio_action_get_group (new_layer->pick_action); - } - else - new_layer->pick_action = NULL; + /* Create selection action */ + if (activatable) { + new_layer->pick_action = gtk_radio_action_new(pname, name, NULL, NULL, user_id); + gtk_radio_action_set_group(new_layer->pick_action, ls->radio_group); + ls->radio_group = gtk_radio_action_get_group(new_layer->pick_action); + } + else + new_layer->pick_action = NULL; - /* Create visibility action */ - new_layer->view_action = gtk_toggle_action_new (vname, name, NULL, NULL); - gtk_toggle_action_set_active (new_layer->view_action, visible); + /* Create visibility action */ + new_layer->view_action = gtk_toggle_action_new(vname, name, NULL, NULL); + gtk_toggle_action_set_active(new_layer->view_action, visible); - /* Determine keyboard accelerators */ - for (i = 0; i < 20; ++i) - if (ls->accel_available[i]) - break; - if (i < 20) - { - /* Map 1-0 to actions 1-10 (with '0' meaning 10) */ - gchar *accel1 = g_strdup_printf ("%s%d", - i < 10 ? "" : "", - (i + 1) % 10); - gchar *accel2 = g_strdup_printf ("%s%d", - i < 10 ? "" : "", - (i + 1) % 10); + /* Determine keyboard accelerators */ + for (i = 0; i < 20; ++i) + if (ls->accel_available[i]) + break; + if (i < 20) { + /* Map 1-0 to actions 1-10 (with '0' meaning 10) */ + gchar *accel1 = g_strdup_printf("%s%d", + i < 10 ? "" : "", + (i + 1) % 10); + gchar *accel2 = g_strdup_printf("%s%d", + i < 10 ? "" : "", + (i + 1) % 10); - if (activatable) - { - GtkAction *action = GTK_ACTION (new_layer->pick_action); - gtk_action_set_accel_group (action, ls->accel_group); - gtk_action_group_add_action_with_accel (ls->action_group, - action, - accel1); - gtk_action_connect_accelerator (action); - g_signal_connect (G_OBJECT (action), "activate", - G_CALLBACK (menu_pick_cb), new_layer); - } - gtk_action_set_accel_group (GTK_ACTION (new_layer->view_action), - ls->accel_group); - gtk_action_group_add_action_with_accel - (ls->action_group, GTK_ACTION (new_layer->view_action), accel2); - gtk_action_connect_accelerator (GTK_ACTION (new_layer->view_action)); - g_signal_connect (G_OBJECT (new_layer->view_action), "activate", - G_CALLBACK (menu_view_cb), new_layer); + if (activatable) { + GtkAction *action = GTK_ACTION(new_layer->pick_action); + gtk_action_set_accel_group(action, ls->accel_group); + gtk_action_group_add_action_with_accel(ls->action_group, action, accel1); + gtk_action_connect_accelerator(action); + g_signal_connect(G_OBJECT(action), "activate", G_CALLBACK(menu_pick_cb), new_layer); + } + gtk_action_set_accel_group(GTK_ACTION(new_layer->view_action), ls->accel_group); + gtk_action_group_add_action_with_accel(ls->action_group, GTK_ACTION(new_layer->view_action), accel2); + gtk_action_connect_accelerator(GTK_ACTION(new_layer->view_action)); + g_signal_connect(G_OBJECT(new_layer->view_action), "activate", G_CALLBACK(menu_view_cb), new_layer); - ls->accel_available[i] = FALSE; - new_layer->accel_index = i; - g_free (accel2); - g_free (accel1); - } - else - { - new_layer->accel_index = -1; - } - /* finalize new layer struct */ - new_layer->pick_item = new_layer->view_item = NULL; + ls->accel_available[i] = FALSE; + new_layer->accel_index = i; + g_free(accel2); + g_free(accel1); + } + else { + new_layer->accel_index = -1; + } + /* finalize new layer struct */ + new_layer->pick_item = new_layer->view_item = NULL; - /* cleanup */ - g_free (vname); - g_free (pname); + /* cleanup */ + g_free(vname); + g_free(pname); - ls->n_actions++; + ls->n_actions++; } /*! \brief Install the "Current Layer" menu items for a layer selector @@ -623,30 +526,25 @@ * * \return the number of items installed */ -gint -ghid_layer_selector_install_pick_items (GHidLayerSelector *ls, - GtkMenuShell *shell, gint pos) +gint ghid_layer_selector_install_pick_items(GHidLayerSelector * ls, GtkMenuShell * shell, gint pos) { - GtkTreeIter iter; - int n = 0; + GtkTreeIter iter; + int n = 0; - gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ls->list_store), &iter); - do - { - struct _layer *ldata; - gtk_tree_model_get (GTK_TREE_MODEL (ls->list_store), - &iter, STRUCT_COL, &ldata, -1); - if (ldata && ldata->pick_action) - { - GtkAction *action = GTK_ACTION (ldata->pick_action); - ldata->pick_item = gtk_action_create_menu_item (action); - gtk_menu_shell_insert (shell, ldata->pick_item, pos + n); - ++n; - } - } - while (gtk_tree_model_iter_next (GTK_TREE_MODEL (ls->list_store), &iter)); + gtk_tree_model_get_iter_first(GTK_TREE_MODEL(ls->list_store), &iter); + do { + struct _layer *ldata; + gtk_tree_model_get(GTK_TREE_MODEL(ls->list_store), &iter, STRUCT_COL, &ldata, -1); + if (ldata && ldata->pick_action) { + GtkAction *action = GTK_ACTION(ldata->pick_action); + ldata->pick_item = gtk_action_create_menu_item(action); + gtk_menu_shell_insert(shell, ldata->pick_item, pos + n); + ++n; + } + } + while (gtk_tree_model_iter_next(GTK_TREE_MODEL(ls->list_store), &iter)); - return n; + return n; } /*! \brief Install the "Shown Layers" menu items for a layer selector @@ -660,30 +558,25 @@ * * \return the number of items installed */ -gint -ghid_layer_selector_install_view_items (GHidLayerSelector *ls, - GtkMenuShell *shell, gint pos) +gint ghid_layer_selector_install_view_items(GHidLayerSelector * ls, GtkMenuShell * shell, gint pos) { - GtkTreeIter iter; - int n = 0; + GtkTreeIter iter; + int n = 0; - gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ls->list_store), &iter); - do - { - struct _layer *ldata; - gtk_tree_model_get (GTK_TREE_MODEL (ls->list_store), - &iter, STRUCT_COL, &ldata, -1); - if (ldata && ldata->view_action) - { - GtkAction *action = GTK_ACTION (ldata->view_action); - ldata->view_item = gtk_action_create_menu_item (action); - gtk_menu_shell_insert (shell, ldata->view_item, pos + n); - ++n; - } - } - while (gtk_tree_model_iter_next (GTK_TREE_MODEL (ls->list_store), &iter)); + gtk_tree_model_get_iter_first(GTK_TREE_MODEL(ls->list_store), &iter); + do { + struct _layer *ldata; + gtk_tree_model_get(GTK_TREE_MODEL(ls->list_store), &iter, STRUCT_COL, &ldata, -1); + if (ldata && ldata->view_action) { + GtkAction *action = GTK_ACTION(ldata->view_action); + ldata->view_item = gtk_action_create_menu_item(action); + gtk_menu_shell_insert(shell, ldata->view_item, pos + n); + ++n; + } + } + while (gtk_tree_model_iter_next(GTK_TREE_MODEL(ls->list_store), &iter)); - return n; + return n; } /*! \brief Returns the GtkAccelGroup of a layer selector @@ -693,28 +586,24 @@ * * \return the accel group of the selector */ -GtkAccelGroup * -ghid_layer_selector_get_accel_group (GHidLayerSelector *ls) +GtkAccelGroup *ghid_layer_selector_get_accel_group(GHidLayerSelector * ls) { - return ls->accel_group; + return ls->accel_group; } /*! \brief used internally */ -static gboolean -toggle_foreach_func (GtkTreeModel *model, GtkTreePath *path, - GtkTreeIter *iter, gpointer data) +static gboolean toggle_foreach_func(GtkTreeModel * model, GtkTreePath * path, GtkTreeIter * iter, gpointer data) { - gint id; - GHidLayerSelector *ls = g_object_get_data (G_OBJECT (model), - "layer-selector"); - - gtk_tree_model_get (model, iter, USER_ID_COL, &id, -1); - if (id == *(gint *) data) - { - toggle_visibility (ls, iter, TRUE); - return TRUE; - } - return FALSE; + gint id; + GHidLayerSelector *ls = g_object_get_data(G_OBJECT(model), + "layer-selector"); + + gtk_tree_model_get(model, iter, USER_ID_COL, &id, -1); + if (id == *(gint *) data) { + toggle_visibility(ls, iter, TRUE); + return TRUE; + } + return FALSE; } /*! \brief Toggle a layer's visibility @@ -724,29 +613,24 @@ * \param [in] ls The selector to be acted on * \param [in] user_id The ID of the layer to be affected */ -void -ghid_layer_selector_toggle_layer (GHidLayerSelector *ls, gint user_id) +void ghid_layer_selector_toggle_layer(GHidLayerSelector * ls, gint user_id) { - gtk_tree_model_foreach (GTK_TREE_MODEL (ls->list_store), - toggle_foreach_func, &user_id); + gtk_tree_model_foreach(GTK_TREE_MODEL(ls->list_store), toggle_foreach_func, &user_id); } /*! \brief used internally */ -static gboolean -select_foreach_func (GtkTreeModel *model, GtkTreePath *path, - GtkTreeIter *iter, gpointer data) +static gboolean select_foreach_func(GtkTreeModel * model, GtkTreePath * path, GtkTreeIter * iter, gpointer data) { - gint id; - GHidLayerSelector *ls = g_object_get_data (G_OBJECT (model), - "layer-selector"); - - gtk_tree_model_get (model, iter, USER_ID_COL, &id, -1); - if (id == *(gint *) data) - { - gtk_tree_selection_select_path (ls->selection, path); - return TRUE; - } - return FALSE; + gint id; + GHidLayerSelector *ls = g_object_get_data(G_OBJECT(model), + "layer-selector"); + + gtk_tree_model_get(model, iter, USER_ID_COL, &id, -1); + if (id == *(gint *) data) { + gtk_tree_selection_select_path(ls->selection, path); + return TRUE; + } + return FALSE; } /*! \brief Select a layer @@ -756,11 +640,9 @@ * \param [in] ls The selector to be acted on * \param [in] user_id The ID of the layer to be affected */ -void -ghid_layer_selector_select_layer (GHidLayerSelector *ls, gint user_id) +void ghid_layer_selector_select_layer(GHidLayerSelector * ls, gint user_id) { - gtk_tree_model_foreach (GTK_TREE_MODEL (ls->list_store), - select_foreach_func, &user_id); + gtk_tree_model_foreach(GTK_TREE_MODEL(ls->list_store), select_foreach_func, &user_id); } /*! \brief Selects the next visible layer @@ -774,46 +656,36 @@ * * \return TRUE on success, FALSE if all selectable layers are hidden */ -gboolean -ghid_layer_selector_select_next_visible (GHidLayerSelector *ls) +gboolean ghid_layer_selector_select_next_visible(GHidLayerSelector * ls) { - GtkTreeIter iter; - if (gtk_tree_selection_get_selected (ls->selection, NULL, &iter)) - { - /* Scan forward, looking for selectable iter */ - do - { - gboolean visible, activatable; - gtk_tree_model_get (GTK_TREE_MODEL (ls->list_store), - &iter, VISIBLE_COL, &visible, - ACTIVATABLE_COL, &activatable, -1); - if (visible && activatable) - { - gtk_tree_selection_select_iter (ls->selection, &iter); - return TRUE; - } - } - while (gtk_tree_model_iter_next (GTK_TREE_MODEL (ls->list_store), &iter)); - /* Move iter to start, and repeat. */ - gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ls->list_store), &iter); - do - { - gboolean visible, activatable; - gtk_tree_model_get (GTK_TREE_MODEL (ls->list_store), - &iter, VISIBLE_COL, &visible, - ACTIVATABLE_COL, &activatable, -1); - if (visible && activatable) - { - gtk_tree_selection_select_iter (ls->selection, &iter); - return TRUE; - } - } - while (gtk_tree_model_iter_next (GTK_TREE_MODEL (ls->list_store), &iter)); - /* Failing this, just emit a selected signal on the original layer. */ - selection_changed_cb (ls->selection, ls); - } - /* If we get here, nothing is selectable, so fail. */ - return FALSE; + GtkTreeIter iter; + if (gtk_tree_selection_get_selected(ls->selection, NULL, &iter)) { + /* Scan forward, looking for selectable iter */ + do { + gboolean visible, activatable; + gtk_tree_model_get(GTK_TREE_MODEL(ls->list_store), &iter, VISIBLE_COL, &visible, ACTIVATABLE_COL, &activatable, -1); + if (visible && activatable) { + gtk_tree_selection_select_iter(ls->selection, &iter); + return TRUE; + } + } + while (gtk_tree_model_iter_next(GTK_TREE_MODEL(ls->list_store), &iter)); + /* Move iter to start, and repeat. */ + gtk_tree_model_get_iter_first(GTK_TREE_MODEL(ls->list_store), &iter); + do { + gboolean visible, activatable; + gtk_tree_model_get(GTK_TREE_MODEL(ls->list_store), &iter, VISIBLE_COL, &visible, ACTIVATABLE_COL, &activatable, -1); + if (visible && activatable) { + gtk_tree_selection_select_iter(ls->selection, &iter); + return TRUE; + } + } + while (gtk_tree_model_iter_next(GTK_TREE_MODEL(ls->list_store), &iter)); + /* Failing this, just emit a selected signal on the original layer. */ + selection_changed_cb(ls->selection, ls); + } + /* If we get here, nothing is selectable, so fail. */ + return FALSE; } /*! \brief Makes the selected layer visible @@ -823,18 +695,15 @@ * * \param [in] ls The selector to be acted on */ -void -ghid_layer_selector_make_selected_visible (GHidLayerSelector *ls) +void ghid_layer_selector_make_selected_visible(GHidLayerSelector * ls) { - GtkTreeIter iter; - if (gtk_tree_selection_get_selected (ls->selection, NULL, &iter)) - { - gboolean visible; - gtk_tree_model_get (GTK_TREE_MODEL (ls->list_store), - &iter, VISIBLE_COL, &visible, -1); - if (!visible) - toggle_visibility (ls, &iter, FALSE); - } + GtkTreeIter iter; + if (gtk_tree_selection_get_selected(ls->selection, NULL, &iter)) { + gboolean visible; + gtk_tree_model_get(GTK_TREE_MODEL(ls->list_store), &iter, VISIBLE_COL, &visible, -1); + if (!visible) + toggle_visibility(ls, &iter, FALSE); + } } /*! \brief Sets the colors of all layers in a layer-selector @@ -847,23 +716,19 @@ * \param [in] ls The selector to be acted on * \param [in] callback Takes the user_id of the layer and returns a color string */ -void -ghid_layer_selector_update_colors (GHidLayerSelector *ls, - const gchar *(*callback)(int user_id)) +void ghid_layer_selector_update_colors(GHidLayerSelector * ls, const gchar * (*callback) (int user_id)) { - GtkTreeIter iter; - gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ls->list_store), &iter); - do - { - gint user_id; - const gchar *new_color; - gtk_tree_model_get (GTK_TREE_MODEL (ls->list_store), - &iter, USER_ID_COL, &user_id, -1); - new_color = callback (user_id); - if (new_color != NULL) - gtk_list_store_set (ls->list_store, &iter, COLOR_COL, new_color, -1); - } - while (gtk_tree_model_iter_next (GTK_TREE_MODEL (ls->list_store), &iter)); + GtkTreeIter iter; + gtk_tree_model_get_iter_first(GTK_TREE_MODEL(ls->list_store), &iter); + do { + gint user_id; + const gchar *new_color; + gtk_tree_model_get(GTK_TREE_MODEL(ls->list_store), &iter, USER_ID_COL, &user_id, -1); + new_color = callback(user_id); + if (new_color != NULL) + gtk_list_store_set(ls->list_store, &iter, COLOR_COL, new_color, -1); + } + while (gtk_tree_model_iter_next(GTK_TREE_MODEL(ls->list_store), &iter)); } /*! \brief Deletes layers from a layer selector @@ -878,49 +743,41 @@ * \param [in] ls The selector to be acted on * \param [in] callback Takes the user_id of the layer and returns a boolean */ -void -ghid_layer_selector_delete_layers (GHidLayerSelector *ls, - gboolean (*callback)(int user_id)) +void ghid_layer_selector_delete_layers(GHidLayerSelector * ls, gboolean(*callback) (int user_id)) { - GtkTreeIter iter, last_iter; - - gboolean iter_valid = - gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ls->list_store), &iter); - while (iter_valid) - { - struct _layer *ldata; - gboolean sep, was_sep = FALSE; - gint user_id; + GtkTreeIter iter, last_iter; - /* Find next iter to delete */ - while (iter_valid) - { - gtk_tree_model_get (GTK_TREE_MODEL (ls->list_store), - &iter, USER_ID_COL, &user_id, - STRUCT_COL, &ldata, SEPARATOR_COL, &sep, -1); - if (!sep && callback (user_id)) - break; + gboolean iter_valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(ls->list_store), &iter); + while (iter_valid) { + struct _layer *ldata; + gboolean sep, was_sep = FALSE; + gint user_id; - /* save iter in case it's a bad separator */ - was_sep = sep; - last_iter = iter; - /* iterate */ - iter_valid = - gtk_tree_model_iter_next (GTK_TREE_MODEL (ls->list_store), &iter); - } + /* Find next iter to delete */ + while (iter_valid) { + gtk_tree_model_get(GTK_TREE_MODEL(ls->list_store), + &iter, USER_ID_COL, &user_id, STRUCT_COL, &ldata, SEPARATOR_COL, &sep, -1); + if (!sep && callback(user_id)) + break; - if (iter_valid) - { - /* remove preceeding separator */ - if (was_sep) - gtk_list_store_remove (ls->list_store, &last_iter); + /* save iter in case it's a bad separator */ + was_sep = sep; + last_iter = iter; + /* iterate */ + iter_valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(ls->list_store), &iter); + } - /*** remove row ***/ - iter_valid = gtk_list_store_remove (ls->list_store, &iter); - free_ldata (ls, ldata); - } - last_iter = iter; - } + if (iter_valid) { + /* remove preceeding separator */ + if (was_sep) + gtk_list_store_remove(ls->list_store, &last_iter); + + /*** remove row ***/ + iter_valid = gtk_list_store_remove(ls->list_store, &iter); + free_ldata(ls, ldata); + } + last_iter = iter; + } } /*! \brief Sets the visibility toggle-state of all layers @@ -931,28 +788,19 @@ * \param [in] ls The selector to be acted on * \param [in] callback Takes the user_id of the layer and returns a boolean */ -void -ghid_layer_selector_show_layers (GHidLayerSelector *ls, - gboolean (*callback)(int user_id)) +void ghid_layer_selector_show_layers(GHidLayerSelector * ls, gboolean(*callback) (int user_id)) { - GtkTreeIter iter; - gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ls->list_store), &iter); - do - { - struct _layer *ldata; - gboolean sep; - gint user_id; + GtkTreeIter iter; + gtk_tree_model_get_iter_first(GTK_TREE_MODEL(ls->list_store), &iter); + do { + struct _layer *ldata; + gboolean sep; + gint user_id; - gtk_tree_model_get (GTK_TREE_MODEL (ls->list_store), - &iter, USER_ID_COL, &user_id, - STRUCT_COL, &ldata, - SEPARATOR_COL, &sep, -1); - if (!sep) - set_visibility (ls, &iter, ldata, callback (user_id)); - } - while (gtk_tree_model_iter_next (GTK_TREE_MODEL (ls->list_store), &iter)); + gtk_tree_model_get(GTK_TREE_MODEL(ls->list_store), + &iter, USER_ID_COL, &user_id, STRUCT_COL, &ldata, SEPARATOR_COL, &sep, -1); + if (!sep) + set_visibility(ls, &iter, ldata, callback(user_id)); + } + while (gtk_tree_model_iter_next(GTK_TREE_MODEL(ls->list_store), &iter)); } - - - - Index: trunk/src/hid/gtk/ghid-layer-selector.h =================================================================== --- trunk/src/hid/gtk/ghid-layer-selector.h (revision 1021) +++ trunk/src/hid/gtk/ghid-layer-selector.h (revision 1022) @@ -5,46 +5,34 @@ #include #include -G_BEGIN_DECLS /* keep c++ happy */ - +G_BEGIN_DECLS /* keep c++ happy */ #define GHID_LAYER_SELECTOR_TYPE (ghid_layer_selector_get_type ()) #define GHID_LAYER_SELECTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GHID_LAYER_SELECTOR_TYPE, GHidLayerSelector)) #define GHID_LAYER_SELECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GHID_LAYER_SELECTOR_TYPE, GHidLayerSelectorClass)) #define IS_GHID_LAYER_SELECTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GHID_LAYER_SELECTOR_TYPE)) #define IS_GHID_LAYER_SELECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GHID_LAYER_SELECTOR_TYPE)) +typedef struct _GHidLayerSelector GHidLayerSelector; +typedef struct _GHidLayerSelectorClass GHidLayerSelectorClass; -typedef struct _GHidLayerSelector GHidLayerSelector; -typedef struct _GHidLayerSelectorClass GHidLayerSelectorClass; +GType ghid_layer_selector_get_type(void); +GtkWidget *ghid_layer_selector_new(void); -GType ghid_layer_selector_get_type (void); -GtkWidget* ghid_layer_selector_new (void); +void ghid_layer_selector_add_layer(GHidLayerSelector * ls, + gint user_id, + const gchar * name, const gchar * color_string, gboolean visible, gboolean activatable); -void ghid_layer_selector_add_layer (GHidLayerSelector *ls, - gint user_id, - const gchar *name, - const gchar *color_string, - gboolean visible, - gboolean activatable); +gint ghid_layer_selector_install_pick_items(GHidLayerSelector * ls, GtkMenuShell * shell, gint pos); +gint ghid_layer_selector_install_view_items(GHidLayerSelector * ls, GtkMenuShell * shell, gint pos); -gint ghid_layer_selector_install_pick_items (GHidLayerSelector *ls, - GtkMenuShell *shell, gint pos); -gint ghid_layer_selector_install_view_items (GHidLayerSelector *ls, - GtkMenuShell *shell, gint pos); +GtkAccelGroup *ghid_layer_selector_get_accel_group(GHidLayerSelector * ls); -GtkAccelGroup *ghid_layer_selector_get_accel_group (GHidLayerSelector *ls); +void ghid_layer_selector_toggle_layer(GHidLayerSelector * ls, gint user_id); +void ghid_layer_selector_select_layer(GHidLayerSelector * ls, gint user_id); +gboolean ghid_layer_selector_select_next_visible(GHidLayerSelector * ls); +void ghid_layer_selector_make_selected_visible(GHidLayerSelector * ls); +void ghid_layer_selector_update_colors(GHidLayerSelector * ls, const gchar * (*callback) (int user_id)); +void ghid_layer_selector_delete_layers(GHidLayerSelector * ls, gboolean(*callback) (int user_id)); +void ghid_layer_selector_show_layers(GHidLayerSelector * ls, gboolean(*callback) (int user_id)); -void ghid_layer_selector_toggle_layer (GHidLayerSelector *ls, - gint user_id); -void ghid_layer_selector_select_layer (GHidLayerSelector *ls, - gint user_id); -gboolean ghid_layer_selector_select_next_visible (GHidLayerSelector *ls); -void ghid_layer_selector_make_selected_visible (GHidLayerSelector *ls); -void ghid_layer_selector_update_colors (GHidLayerSelector *ls, - const gchar *(*callback)(int user_id)); -void ghid_layer_selector_delete_layers (GHidLayerSelector *ls, - gboolean (*callback)(int user_id)); -void ghid_layer_selector_show_layers (GHidLayerSelector *ls, - gboolean (*callback)(int user_id)); - -G_END_DECLS /* keep c++ happy */ +G_END_DECLS /* keep c++ happy */ #endif Index: trunk/src/hid/gtk/ghid-main-menu.c =================================================================== --- trunk/src/hid/gtk/ghid-main-menu.c (revision 1021) +++ trunk/src/hid/gtk/ghid-main-menu.c (revision 1022) @@ -16,40 +16,37 @@ #include "ghid-layer-selector.h" #include "ghid-route-style-selector.h" -void Message (const char *, ...); +void Message(const char *, ...); static int action_counter; -struct _GHidMainMenu -{ - GtkMenuBar parent; +struct _GHidMainMenu { + GtkMenuBar parent; - GtkActionGroup *action_group; - GtkAccelGroup *accel_group; + GtkActionGroup *action_group; + GtkAccelGroup *accel_group; - gint layer_view_pos; - gint layer_pick_pos; - gint route_style_pos; + gint layer_view_pos; + gint layer_pick_pos; + gint route_style_pos; - GtkMenuShell *layer_view_shell; - GtkMenuShell *layer_pick_shell; - GtkMenuShell *route_style_shell; + GtkMenuShell *layer_view_shell; + GtkMenuShell *layer_pick_shell; + GtkMenuShell *route_style_shell; - GList *actions; - GHashTable *popup_table; + GList *actions; + GHashTable *popup_table; - gint n_layer_views; - gint n_layer_picks; - gint n_route_styles; + gint n_layer_views; + gint n_layer_picks; + gint n_route_styles; - GCallback action_cb; - void (*special_key_cb) (const char *accel, GtkAction *action, - const Resource *node); + GCallback action_cb; + void (*special_key_cb) (const char *accel, GtkAction * action, const Resource * node); }; -struct _GHidMainMenuClass -{ - GtkMenuBarClass parent_class; +struct _GHidMainMenuClass { + GtkMenuBarClass parent_class; }; /* TODO: write finalize function */ @@ -67,254 +64,218 @@ * gtk source distribution) to figure out the names that go with the * codes. */ -static gchar * -translate_accelerator (const char *text) +static gchar *translate_accelerator(const char *text) { - GString *ret_val = g_string_new (""); - static struct { const char *in, *out; } key_table[] = - { - {"Enter", "Return"}, - {"Alt", ""}, - {"Shift", ""}, - {"Ctrl", ""}, - {" ", ""}, - {":", "colon"}, - {"=", "equal"}, - {"/", "slash"}, - {"[", "bracketleft"}, - {"]", "bracketright"}, - {".", "period"}, - {"|", "bar"}, - {NULL, NULL} - }; + GString *ret_val = g_string_new(""); + static struct { + const char *in, *out; + } key_table[] = { + { + "Enter", "Return"}, { + "Alt", ""}, { + "Shift", ""}, { + "Ctrl", ""}, { + " ", ""}, { + ":", "colon"}, { + "=", "equal"}, { + "/", "slash"}, { + "[", "bracketleft"}, { + "]", "bracketright"}, { + ".", "period"}, { + "|", "bar"}, { + NULL, NULL} + }; - enum {MOD, KEY} state = MOD; - while (*text != '\0') - { - static gboolean gave_msg; - gboolean found = FALSE; - int i; + enum { MOD, KEY } state = MOD; + while (*text != '\0') { + static gboolean gave_msg; + gboolean found = FALSE; + int i; - if (state == MOD && strncmp (text, "", 5) == 0) - { - state = KEY; - text += 5; - } - for (i = 0; key_table[i].in != NULL; ++i) - { - int len = strlen (key_table[i].in); - if (strncmp (text, key_table[i].in, len) == 0) - { - found = TRUE; - g_string_append (ret_val, key_table[i].out); - text += len; - } - } - if (found == FALSE) - switch (state) - { - case MOD: - Message (_("Don't know how to parse \"%s\" as an " - "accelerator in the menu resource file.\n"), - text); - if (!gave_msg) - { - gave_msg = TRUE; - Message (_("Format is:\n" - "modifiersk\n" - "where \"modifiers\" is a space " - "separated list of key modifiers\n" - "and \"k\" is the name of the key.\n" - "Allowed modifiers are:\n" - " Ctrl\n" - " Shift\n" - " Alt\n" - "Please note that case is important.\n")); - } - text++; - break; - case KEY: - g_string_append_c (ret_val, *text); - ++text; - break; - } - } - return g_string_free (ret_val, FALSE); + if (state == MOD && strncmp(text, "", 5) == 0) { + state = KEY; + text += 5; + } + for (i = 0; key_table[i].in != NULL; ++i) { + int len = strlen(key_table[i].in); + if (strncmp(text, key_table[i].in, len) == 0) { + found = TRUE; + g_string_append(ret_val, key_table[i].out); + text += len; + } + } + if (found == FALSE) + switch (state) { + case MOD: + Message(_("Don't know how to parse \"%s\" as an " "accelerator in the menu resource file.\n"), text); + if (!gave_msg) { + gave_msg = TRUE; + Message(_("Format is:\n" + "modifiersk\n" + "where \"modifiers\" is a space " + "separated list of key modifiers\n" + "and \"k\" is the name of the key.\n" + "Allowed modifiers are:\n" " Ctrl\n" " Shift\n" " Alt\n" "Please note that case is important.\n")); + } + text++; + break; + case KEY: + g_string_append_c(ret_val, *text); + ++text; + break; + } + } + return g_string_free(ret_val, FALSE); } /*! \brief Check that translated accelerators are unique; warn otherwise. */ -static const char * -check_unique_accel (const char *accelerator) +static const char *check_unique_accel(const char *accelerator) { - static GHashTable *accel_table; + static GHashTable *accel_table; - if (!accelerator ||*accelerator) - return accelerator; + if (!accelerator || *accelerator) + return accelerator; - if (!accel_table) - accel_table = g_hash_table_new (g_str_hash, g_str_equal); + if (!accel_table) + accel_table = g_hash_table_new(g_str_hash, g_str_equal); - if (g_hash_table_lookup (accel_table, accelerator)) - { - Message (_("Duplicate accelerator found: \"%s\"\n" - "The second occurance will be dropped\n"), - accelerator); - return NULL; - } + if (g_hash_table_lookup(accel_table, accelerator)) { + Message(_("Duplicate accelerator found: \"%s\"\n" "The second occurance will be dropped\n"), accelerator); + return NULL; + } - g_hash_table_insert (accel_table, - (gpointer) accelerator, (gpointer) accelerator); + g_hash_table_insert(accel_table, (gpointer) accelerator, (gpointer) accelerator); - return accelerator; + return accelerator; } -void -ghid_main_menu_real_add_resource (GHidMainMenu *menu, GtkMenuShell *shell, - const Resource *res, const char *path); +void ghid_main_menu_real_add_resource(GHidMainMenu * menu, GtkMenuShell * shell, const Resource * res, const char *path); -static GHashTable *menu_hash = NULL; /* path->GtkWidget */ +static GHashTable *menu_hash = NULL; /* path->GtkWidget */ -static GtkAction *ghid_add_menu(GHidMainMenu *menu, GtkMenuShell *shell, - const Resource *sub_res, const char *path) +static GtkAction *ghid_add_menu(GHidMainMenu * menu, GtkMenuShell * shell, const Resource * sub_res, const char *path) { - const char *res_val; - const Resource *tmp_res; - gchar mnemonic = 0; - int j; - GtkAction *action = NULL; - const gchar *accel = NULL; - char *menu_label; - char *npath; + const char *res_val; + const Resource *tmp_res; + gchar mnemonic = 0; + int j; + GtkAction *action = NULL; + const gchar *accel = NULL; + char *menu_label; + char *npath; - if (!menu_hash) - menu_hash = g_hash_table_new (g_str_hash, g_str_equal); + if (!menu_hash) + menu_hash = g_hash_table_new(g_str_hash, g_str_equal); - tmp_res = resource_subres (sub_res, "a"); /* accelerator */ - res_val = resource_value (sub_res, "m"); /* mnemonic */ + tmp_res = resource_subres(sub_res, "a"); /* accelerator */ + res_val = resource_value(sub_res, "m"); /* mnemonic */ - if (res_val) - mnemonic = res_val[0]; - /* The accelerator resource will have two values, like - * a={"Ctrl-Q" "Ctrlq"} - * The first Gtk ignores. The second needs to be translated. */ - if (tmp_res) - accel = check_unique_accel - (translate_accelerator (tmp_res->v[1].value)); + if (res_val) + mnemonic = res_val[0]; + /* The accelerator resource will have two values, like + * a={"Ctrl-Q" "Ctrlq"} + * The first Gtk ignores. The second needs to be translated. */ + if (tmp_res) + accel = check_unique_accel(translate_accelerator(tmp_res->v[1].value)); - /* Now look for the first unnamed value (not a subresource) to - * figure out the name of the menu or the menuitem. */ - res_val = "button"; - for (j = 0; j < sub_res->c; ++j) - if (resource_type (sub_res->v[j]) == 10) - { - res_val = sub_res->v[j].value; - break; - } - /* Hack '_' in based on mnemonic value */ - if (!mnemonic) - menu_label = g_strdup (res_val); - else - { - char *post_ = strchr (res_val, mnemonic); - if (post_ == NULL) - menu_label = g_strdup (res_val); - else - { - GString *tmp = g_string_new (""); - g_string_append_len (tmp, res_val, post_ - res_val); - g_string_append_c (tmp, '_'); - g_string_append (tmp, post_); - menu_label = g_string_free (tmp, FALSE); - } - } + /* Now look for the first unnamed value (not a subresource) to + * figure out the name of the menu or the menuitem. */ + res_val = "button"; + for (j = 0; j < sub_res->c; ++j) + if (resource_type(sub_res->v[j]) == 10) { + res_val = sub_res->v[j].value; + break; + } + /* Hack '_' in based on mnemonic value */ + if (!mnemonic) + menu_label = g_strdup(res_val); + else { + char *post_ = strchr(res_val, mnemonic); + if (post_ == NULL) + menu_label = g_strdup(res_val); + else { + GString *tmp = g_string_new(""); + g_string_append_len(tmp, res_val, post_ - res_val); + g_string_append_c(tmp, '_'); + g_string_append(tmp, post_); + menu_label = g_string_free(tmp, FALSE); + } + } - npath = Concat(path, "/", res_val, NULL); + npath = Concat(path, "/", res_val, NULL); - /* If the subresource we're processing also has unnamed - * subresources, it's a submenu, not a regular menuitem. */ - if (sub_res->flags & FLAG_S) - { - /* SUBMENU */ - GtkWidget *submenu = gtk_menu_new (); - GtkWidget *item = gtk_menu_item_new_with_mnemonic (menu_label); - GtkWidget *tearoff = gtk_tearoff_menu_item_new (); + /* If the subresource we're processing also has unnamed + * subresources, it's a submenu, not a regular menuitem. */ + if (sub_res->flags & FLAG_S) { + /* SUBMENU */ + GtkWidget *submenu = gtk_menu_new(); + GtkWidget *item = gtk_menu_item_new_with_mnemonic(menu_label); + GtkWidget *tearoff = gtk_tearoff_menu_item_new(); - gtk_menu_shell_append (shell, item); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu); + gtk_menu_shell_append(shell, item); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); - /* add tearoff to menu */ - gtk_menu_shell_append (GTK_MENU_SHELL (submenu), tearoff); + /* add tearoff to menu */ + gtk_menu_shell_append(GTK_MENU_SHELL(submenu), tearoff); - g_hash_table_insert (menu_hash, (gpointer)npath, (gpointer)submenu); + g_hash_table_insert(menu_hash, (gpointer) npath, (gpointer) submenu); - /* recurse on the newly-added submenu */ - ghid_main_menu_real_add_resource (menu, - GTK_MENU_SHELL (submenu), - sub_res, npath); + /* recurse on the newly-added submenu */ + ghid_main_menu_real_add_resource(menu, GTK_MENU_SHELL(submenu), sub_res, npath); - } - else - { - /* NON-SUBMENU: MENU ITEM */ - const char *checked = resource_value (sub_res, "checked"); - const char *label = resource_value (sub_res, "sensitive"); - const char *tip = resource_value (sub_res, "tip"); - if (checked) - { - /* TOGGLE ITEM */ - gchar *name = g_strdup_printf ("MainMenuAction%d", - action_counter++); + } + else { + /* NON-SUBMENU: MENU ITEM */ + const char *checked = resource_value(sub_res, "checked"); + const char *label = resource_value(sub_res, "sensitive"); + const char *tip = resource_value(sub_res, "tip"); + if (checked) { + /* TOGGLE ITEM */ + gchar *name = g_strdup_printf("MainMenuAction%d", + action_counter++); - action = GTK_ACTION (gtk_toggle_action_new (name, menu_label, - tip, NULL)); - /* checked=foo is a binary flag (checkbox) - * checked=foo,bar is a flag compared to a value (radio) */ - gtk_toggle_action_set_draw_as_radio - (GTK_TOGGLE_ACTION (action), !!strchr (checked, ',')); - } - else if (label && strcmp (label, "false") == 0) - { - /* INSENSITIVE ITEM */ - GtkWidget *item = gtk_menu_item_new_with_label (menu_label); - gtk_widget_set_sensitive (item, FALSE); - gtk_menu_shell_append (shell, item); - g_hash_table_insert (menu_hash, (gpointer)npath, (gpointer)item); - } - else - { - /* NORMAL ITEM */ - gchar *name = g_strdup_printf ("MainMenuAction%d", action_counter++); - action = gtk_action_new (name, menu_label, tip, NULL); - } - } + action = GTK_ACTION(gtk_toggle_action_new(name, menu_label, tip, NULL)); + /* checked=foo is a binary flag (checkbox) + * checked=foo,bar is a flag compared to a value (radio) */ + gtk_toggle_action_set_draw_as_radio(GTK_TOGGLE_ACTION(action), ! !strchr(checked, ',')); + } + else if (label && strcmp(label, "false") == 0) { + /* INSENSITIVE ITEM */ + GtkWidget *item = gtk_menu_item_new_with_label(menu_label); + gtk_widget_set_sensitive(item, FALSE); + gtk_menu_shell_append(shell, item); + g_hash_table_insert(menu_hash, (gpointer) npath, (gpointer) item); + } + else { + /* NORMAL ITEM */ + gchar *name = g_strdup_printf("MainMenuAction%d", action_counter++); + action = gtk_action_new(name, menu_label, tip, NULL); + } + } - /* Connect accelerator, if there is one */ - if (action) - { - GtkWidget *item; - gtk_action_set_accel_group (action, menu->accel_group); - gtk_action_group_add_action_with_accel (menu->action_group, - action, accel); - gtk_action_connect_accelerator (action); - g_signal_connect (G_OBJECT (action), "activate", menu->action_cb, - (gpointer) sub_res); - g_object_set_data (G_OBJECT (action), "resource", - (gpointer) sub_res); - item = gtk_action_create_menu_item (action); - gtk_menu_shell_append (shell, item); - menu->actions = g_list_append (menu->actions, action); - menu->special_key_cb (accel, action, sub_res); + /* Connect accelerator, if there is one */ + if (action) { + GtkWidget *item; + gtk_action_set_accel_group(action, menu->accel_group); + gtk_action_group_add_action_with_accel(menu->action_group, action, accel); + gtk_action_connect_accelerator(action); + g_signal_connect(G_OBJECT(action), "activate", menu->action_cb, (gpointer) sub_res); + g_object_set_data(G_OBJECT(action), "resource", (gpointer) sub_res); + item = gtk_action_create_menu_item(action); + gtk_menu_shell_append(shell, item); + menu->actions = g_list_append(menu->actions, action); + menu->special_key_cb(accel, action, sub_res); - g_hash_table_insert (menu_hash, (gpointer)npath, (gpointer)item); - } + g_hash_table_insert(menu_hash, (gpointer) npath, (gpointer) item); + } /* keep npath for the hash so do not free(npath); */ - return action; + return action; } @@ -324,149 +285,124 @@ * \param [in] shall The base menu shell (a menu bar or popup menu) * \param [in] res The base of the resource tree * */ -void -ghid_main_menu_real_add_resource (GHidMainMenu *menu, GtkMenuShell *shell, - const Resource *res, const char *path) +void ghid_main_menu_real_add_resource(GHidMainMenu * menu, GtkMenuShell * shell, const Resource * res, const char *path) { - int i, j; - GtkAction *action = NULL; + int i, j; + GtkAction *action = NULL; - for (i = 0; i < res->c; ++i) - { - const Resource *sub_res = res->v[i].subres; + for (i = 0; i < res->c; ++i) { + const Resource *sub_res = res->v[i].subres; - switch (resource_type (res->v[i])) - { - case 101: /* name, subres: passthrough */ - ghid_main_menu_real_add_resource (menu, shell, sub_res, path); - break; - case 1: /* no name, subres */ - action = ghid_add_menu(menu, shell, sub_res, path); - /* Scan rest of resource in case there is more work */ - for (j = 0; j < sub_res->c; j++) - { - const char *res_name; - /* named value = X resource */ - if (resource_type (sub_res->v[j]) == 110) - { - res_name = sub_res->v[j].name; + switch (resource_type(res->v[i])) { + case 101: /* name, subres: passthrough */ + ghid_main_menu_real_add_resource(menu, shell, sub_res, path); + break; + case 1: /* no name, subres */ + action = ghid_add_menu(menu, shell, sub_res, path); + /* Scan rest of resource in case there is more work */ + for (j = 0; j < sub_res->c; j++) { + const char *res_name; + /* named value = X resource */ + if (resource_type(sub_res->v[j]) == 110) { + res_name = sub_res->v[j].name; - /* translate bg, fg to background, foreground */ - if (strcmp (res_name, "fg") == 0) res_name = "foreground"; - if (strcmp (res_name, "bg") == 0) res_name = "background"; + /* translate bg, fg to background, foreground */ + if (strcmp(res_name, "fg") == 0) + res_name = "foreground"; + if (strcmp(res_name, "bg") == 0) + res_name = "background"; - /* ignore special named values (m, a, sensitive) */ - if (strcmp (res_name, "m") == 0 - || strcmp (res_name, "a") == 0 - || strcmp (res_name, "sensitive") == 0 - || strcmp (res_name, "tip") == 0) - break; + /* ignore special named values (m, a, sensitive) */ + if (strcmp(res_name, "m") == 0 + || strcmp(res_name, "a") == 0 || strcmp(res_name, "sensitive") == 0 || strcmp(res_name, "tip") == 0) + break; - /* log checked and active special values */ - if (action && strcmp (res_name, "checked") == 0) - g_object_set_data (G_OBJECT (action), "checked-flag", - sub_res->v[j].value); - else if (action && strcmp (res_name, "active") == 0) - g_object_set_data (G_OBJECT (action), "active-flag", - sub_res->v[j].value); - else - /* if we got this far it is supposed to be an X - * resource. For now ignore it and warn the user */ - Message (_("The gtk gui currently ignores \"%s\"" - "as part of a menuitem resource.\n" - "Feel free to provide patches\n"), - sub_res->v[j].value); - } - } - break; - case 10: /* no name, value */ - /* If we get here, the resource is "-" or "@foo" for some foo */ - if (res->v[i].value[0] == '@') - { - GList *children; - int pos; + /* log checked and active special values */ + if (action && strcmp(res_name, "checked") == 0) + g_object_set_data(G_OBJECT(action), "checked-flag", sub_res->v[j].value); + else if (action && strcmp(res_name, "active") == 0) + g_object_set_data(G_OBJECT(action), "active-flag", sub_res->v[j].value); + else + /* if we got this far it is supposed to be an X + * resource. For now ignore it and warn the user */ + Message(_("The gtk gui currently ignores \"%s\"" + "as part of a menuitem resource.\n" "Feel free to provide patches\n"), sub_res->v[j].value); + } + } + break; + case 10: /* no name, value */ + /* If we get here, the resource is "-" or "@foo" for some foo */ + if (res->v[i].value[0] == '@') { + GList *children; + int pos; - children = gtk_container_get_children (GTK_CONTAINER (shell)); - pos = g_list_length (children); - g_list_free (children); + children = gtk_container_get_children(GTK_CONTAINER(shell)); + pos = g_list_length(children); + g_list_free(children); - if (strcmp (res->v[i].value, "@layerview") == 0) - { - menu->layer_view_shell = shell; - menu->layer_view_pos = pos; - } - else if (strcmp (res->v[i].value, "@layerpick") == 0) - { - menu->layer_pick_shell = shell; - menu->layer_pick_pos = pos; - } - else if (strcmp (res->v[i].value, "@routestyles") == 0) - { - menu->route_style_shell = shell; - menu->route_style_pos = pos; - } - else - Message (_("GTK GUI currently ignores \"%s\" in the menu\n" - "resource file.\n"), res->v[i].value); - } - else if (strcmp (res->v[i].value, "-") == 0) - { - GtkWidget *item = gtk_separator_menu_item_new (); - gtk_menu_shell_append (shell, item); - } - else if (i > 0) - { - /* This is an action-less menuitem. It is really only useful - * when you're starting to build a new menu and you're looking - * to get the layout right. */ - GtkWidget *item - = gtk_menu_item_new_with_label (res->v[i].value); - gtk_menu_shell_append (shell, item); - } - break; - } - } + if (strcmp(res->v[i].value, "@layerview") == 0) { + menu->layer_view_shell = shell; + menu->layer_view_pos = pos; + } + else if (strcmp(res->v[i].value, "@layerpick") == 0) { + menu->layer_pick_shell = shell; + menu->layer_pick_pos = pos; + } + else if (strcmp(res->v[i].value, "@routestyles") == 0) { + menu->route_style_shell = shell; + menu->route_style_pos = pos; + } + else + Message(_("GTK GUI currently ignores \"%s\" in the menu\n" "resource file.\n"), res->v[i].value); + } + else if (strcmp(res->v[i].value, "-") == 0) { + GtkWidget *item = gtk_separator_menu_item_new(); + gtk_menu_shell_append(shell, item); + } + else if (i > 0) { + /* This is an action-less menuitem. It is really only useful + * when you're starting to build a new menu and you're looking + * to get the layout right. */ + GtkWidget *item = gtk_menu_item_new_with_label(res->v[i].value); + gtk_menu_shell_append(shell, item); + } + break; + } + } } /* CONSTRUCTOR */ -static void -ghid_main_menu_init (GHidMainMenu *mm) +static void ghid_main_menu_init(GHidMainMenu * mm) { - /* Hookup signal handlers */ + /* Hookup signal handlers */ } -static void -ghid_main_menu_class_init (GHidMainMenuClass *klass) +static void ghid_main_menu_class_init(GHidMainMenuClass * klass) { } /* PUBLIC FUNCTIONS */ -GType -ghid_main_menu_get_type (void) +GType ghid_main_menu_get_type(void) { - static GType mm_type = 0; + static GType mm_type = 0; - if (!mm_type) - { - const GTypeInfo mm_info = - { - sizeof (GHidMainMenuClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) ghid_main_menu_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GHidMainMenu), - 0, /* n_preallocs */ - (GInstanceInitFunc) ghid_main_menu_init, - }; + if (!mm_type) { + const GTypeInfo mm_info = { + sizeof(GHidMainMenuClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) ghid_main_menu_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(GHidMainMenu), + 0, /* n_preallocs */ + (GInstanceInitFunc) ghid_main_menu_init, + }; - mm_type = g_type_register_static (GTK_TYPE_MENU_BAR, - "GHidMainMenu", - &mm_info, 0); - } + mm_type = g_type_register_static(GTK_TYPE_MENU_BAR, "GHidMainMenu", &mm_info, 0); + } - return mm_type; + return mm_type; } /*! \brief Create a new GHidMainMenu @@ -473,59 +409,52 @@ * * \return a freshly-allocated GHidMainMenu */ -GtkWidget * -ghid_main_menu_new (GCallback action_cb, - void (*special_key_cb) (const char *accel, - GtkAction *action, - const Resource *node)) +GtkWidget *ghid_main_menu_new(GCallback action_cb, + void (*special_key_cb) (const char *accel, GtkAction * action, const Resource * node)) { - GHidMainMenu *mm = g_object_new (GHID_MAIN_MENU_TYPE, NULL); + GHidMainMenu *mm = g_object_new(GHID_MAIN_MENU_TYPE, NULL); - mm->accel_group = gtk_accel_group_new (); - mm->action_group = gtk_action_group_new ("MainMenu"); + mm->accel_group = gtk_accel_group_new(); + mm->action_group = gtk_action_group_new("MainMenu"); - mm->layer_view_pos = 0; - mm->layer_pick_pos = 0; - mm->route_style_pos = 0; - mm->n_layer_views = 0; - mm->n_layer_picks = 0; - mm->n_route_styles = 0; - mm->layer_view_shell = NULL; - mm->layer_pick_shell = NULL; - mm->route_style_shell = NULL; + mm->layer_view_pos = 0; + mm->layer_pick_pos = 0; + mm->route_style_pos = 0; + mm->n_layer_views = 0; + mm->n_layer_picks = 0; + mm->n_route_styles = 0; + mm->layer_view_shell = NULL; + mm->layer_pick_shell = NULL; + mm->route_style_shell = NULL; - mm->special_key_cb = special_key_cb; - mm->action_cb = action_cb; - mm->actions = NULL; - mm->popup_table = g_hash_table_new (g_str_hash, g_str_equal); + mm->special_key_cb = special_key_cb; + mm->action_cb = action_cb; + mm->actions = NULL; + mm->popup_table = g_hash_table_new(g_str_hash, g_str_equal); - return GTK_WIDGET (mm); + return GTK_WIDGET(mm); } /*! \brief Turn a pcb resource into the main menu */ -void -ghid_main_menu_add_resource (GHidMainMenu *menu, const Resource *res) +void ghid_main_menu_add_resource(GHidMainMenu * menu, const Resource * res) { - ghid_main_menu_real_add_resource (menu, GTK_MENU_SHELL (menu), res, ""); + ghid_main_menu_real_add_resource(menu, GTK_MENU_SHELL(menu), res, ""); } /*! \brief Turn a pcb resource into a popup menu */ -void -ghid_main_menu_add_popup_resource (GHidMainMenu *menu, const char *name, - const Resource *res) +void ghid_main_menu_add_popup_resource(GHidMainMenu * menu, const char *name, const Resource * res) { - GtkWidget *new_menu = gtk_menu_new (); - g_object_ref_sink (new_menu); - ghid_main_menu_real_add_resource (menu, GTK_MENU_SHELL (new_menu), res, ""); - g_hash_table_insert (menu->popup_table, (gpointer) name, new_menu); - gtk_widget_show_all (new_menu); + GtkWidget *new_menu = gtk_menu_new(); + g_object_ref_sink(new_menu); + ghid_main_menu_real_add_resource(menu, GTK_MENU_SHELL(new_menu), res, ""); + g_hash_table_insert(menu->popup_table, (gpointer) name, new_menu); + gtk_widget_show_all(new_menu); } /*! \brief Returns a registered popup menu by name */ -GtkMenu * -ghid_main_menu_get_popup (GHidMainMenu *menu, const char *name) +GtkMenu *ghid_main_menu_get_popup(GHidMainMenu * menu, const char *name) { - return g_hash_table_lookup (menu->popup_table, name); + return g_hash_table_lookup(menu->popup_table, name); } @@ -540,104 +469,79 @@ * \param [in] cb The callback that toggles the actions */ void -ghid_main_menu_update_toggle_state (GHidMainMenu *menu, - void (*cb) (GtkAction *, - const char *toggle_flag, - const char *active_flag)) +ghid_main_menu_update_toggle_state(GHidMainMenu * menu, + void (*cb) (GtkAction *, const char *toggle_flag, const char *active_flag)) { - GList *list; - for (list = menu->actions; list; list = list->next) - { - Resource *res = g_object_get_data (G_OBJECT (list->data), "resource"); - const char *tf = g_object_get_data (G_OBJECT (list->data), - "checked-flag"); - const char *af = g_object_get_data (G_OBJECT (list->data), - "active-flag"); - g_signal_handlers_block_by_func (G_OBJECT (list->data), - menu->action_cb, res); - cb (GTK_ACTION (list->data), tf, af); - g_signal_handlers_unblock_by_func (G_OBJECT (list->data), - menu->action_cb, res); - } + GList *list; + for (list = menu->actions; list; list = list->next) { + Resource *res = g_object_get_data(G_OBJECT(list->data), "resource"); + const char *tf = g_object_get_data(G_OBJECT(list->data), + "checked-flag"); + const char *af = g_object_get_data(G_OBJECT(list->data), + "active-flag"); + g_signal_handlers_block_by_func(G_OBJECT(list->data), menu->action_cb, res); + cb(GTK_ACTION(list->data), tf, af); + g_signal_handlers_unblock_by_func(G_OBJECT(list->data), menu->action_cb, res); + } } /*! \brief Installs or updates layer selector items */ -void -ghid_main_menu_install_layer_selector (GHidMainMenu *mm, - GHidLayerSelector *ls) +void ghid_main_menu_install_layer_selector(GHidMainMenu * mm, GHidLayerSelector * ls) { - GList *children, *iter; + GList *children, *iter; - /* @layerview */ - if (mm->layer_view_shell) - { - /* Remove old children */ - children = gtk_container_get_children - (GTK_CONTAINER (mm->layer_view_shell)); - for (iter = g_list_nth (children, mm->layer_view_pos); - iter != NULL && mm->n_layer_views > 0; - iter = g_list_next (iter), mm->n_layer_views --) - gtk_container_remove (GTK_CONTAINER (mm->layer_view_shell), - iter->data); - g_list_free (children); + /* @layerview */ + if (mm->layer_view_shell) { + /* Remove old children */ + children = gtk_container_get_children(GTK_CONTAINER(mm->layer_view_shell)); + for (iter = g_list_nth(children, mm->layer_view_pos); + iter != NULL && mm->n_layer_views > 0; iter = g_list_next(iter), mm->n_layer_views--) + gtk_container_remove(GTK_CONTAINER(mm->layer_view_shell), iter->data); + g_list_free(children); - /* Install new ones */ - mm->n_layer_views = ghid_layer_selector_install_view_items - (ls, mm->layer_view_shell, mm->layer_view_pos); - } + /* Install new ones */ + mm->n_layer_views = ghid_layer_selector_install_view_items(ls, mm->layer_view_shell, mm->layer_view_pos); + } - /* @layerpick */ - if (mm->layer_pick_shell) - { - /* Remove old children */ - children = gtk_container_get_children - (GTK_CONTAINER (mm->layer_pick_shell)); - for (iter = g_list_nth (children, mm->layer_pick_pos); - iter != NULL && mm->n_layer_picks > 0; - iter = g_list_next (iter), mm->n_layer_picks --) - gtk_container_remove (GTK_CONTAINER (mm->layer_pick_shell), - iter->data); - g_list_free (children); + /* @layerpick */ + if (mm->layer_pick_shell) { + /* Remove old children */ + children = gtk_container_get_children(GTK_CONTAINER(mm->layer_pick_shell)); + for (iter = g_list_nth(children, mm->layer_pick_pos); + iter != NULL && mm->n_layer_picks > 0; iter = g_list_next(iter), mm->n_layer_picks--) + gtk_container_remove(GTK_CONTAINER(mm->layer_pick_shell), iter->data); + g_list_free(children); - /* Install new ones */ - mm->n_layer_picks = ghid_layer_selector_install_pick_items - (ls, mm->layer_pick_shell, mm->layer_pick_pos); - } + /* Install new ones */ + mm->n_layer_picks = ghid_layer_selector_install_pick_items(ls, mm->layer_pick_shell, mm->layer_pick_pos); + } } /*! \brief Installs or updates route style selector items */ -void -ghid_main_menu_install_route_style_selector (GHidMainMenu *mm, - GHidRouteStyleSelector *rss) +void ghid_main_menu_install_route_style_selector(GHidMainMenu * mm, GHidRouteStyleSelector * rss) { - GList *children, *iter; - /* @routestyles */ - if (mm->route_style_shell) - { - /* Remove old children */ - children = gtk_container_get_children - (GTK_CONTAINER (mm->route_style_shell)); - for (iter = g_list_nth (children, mm->route_style_pos); - iter != NULL && mm->n_route_styles > 0; - iter = g_list_next (iter), mm->n_route_styles --) - gtk_container_remove (GTK_CONTAINER (mm->route_style_shell), - iter->data); - g_list_free (children); - /* Install new ones */ - mm->n_route_styles = ghid_route_style_selector_install_items - (rss, mm->route_style_shell, mm->route_style_pos); - } + GList *children, *iter; + /* @routestyles */ + if (mm->route_style_shell) { + /* Remove old children */ + children = gtk_container_get_children(GTK_CONTAINER(mm->route_style_shell)); + for (iter = g_list_nth(children, mm->route_style_pos); + iter != NULL && mm->n_route_styles > 0; iter = g_list_next(iter), mm->n_route_styles--) + gtk_container_remove(GTK_CONTAINER(mm->route_style_shell), iter->data); + g_list_free(children); + /* Install new ones */ + mm->n_route_styles = ghid_route_style_selector_install_items(rss, mm->route_style_shell, mm->route_style_pos); + } } /*! \brief Returns the menu bar's accelerator group */ -GtkAccelGroup * -ghid_main_menu_get_accel_group (GHidMainMenu *menu) +GtkAccelGroup *ghid_main_menu_get_accel_group(GHidMainMenu * menu) { - if (menu == NULL) { - Message("ghid: can't initialize the menu - is your gpcb-menu.res valid?\n"); - exit(1); - } - return menu->accel_group; + if (menu == NULL) { + Message("ghid: can't initialize the menu - is your gpcb-menu.res valid?\n"); + exit(1); + } + return menu->accel_group; } @@ -646,15 +550,15 @@ char *path, *path_end; int n, plen; - plen = 1; /* for the \0 */ - for(n = 0; menu[n] != NULL; n++) - plen += strlen(menu[n])+1; /* +1 for the leading slash */ + plen = 1; /* for the \0 */ + for (n = 0; menu[n] != NULL; n++) + plen += strlen(menu[n]) + 1; /* +1 for the leading slash */ path = path_end = malloc(plen); *path = '\0'; - for(n = 0; menu[n] != NULL; n++) { - int last = (menu[n+1] == NULL); + for (n = 0; menu[n] != NULL; n++) { + int last = (menu[n + 1] == NULL); int first = (n == 0); GtkWidget *w; Resource *res; @@ -679,20 +583,20 @@ w = g_hash_table_lookup(menu_hash, path); if (!last) { - int flags = first ? (FLAG_S | FLAG_NV | FLAG_V) /* 7 */ : (FLAG_V | FLAG_S) /* 5 */; + int flags = first ? (FLAG_S | FLAG_NV | FLAG_V) /* 7 */ : (FLAG_V | FLAG_S) /* 5 */ ; res = resource_create_menu(menu[n], NULL, NULL, NULL, NULL, flags); } else res = resource_create_menu(menu[n], action, mnemonic, accel, tip, FLAG_NS | FLAG_NV | FLAG_V); - ghid_main_menu_real_add_resource (GHID_MAIN_MENU(ghidgui->menu_bar), GTK_MENU_SHELL(w), res, path); + ghid_main_menu_real_add_resource(GHID_MAIN_MENU(ghidgui->menu_bar), GTK_MENU_SHELL(w), res, path); *path_end = '/'; - path_end += strlen(menu[n])+1; + path_end += strlen(menu[n]) + 1; } /* make sure new menu items appear on screen */ - gtk_widget_show_all (ghidgui->menu_bar); + gtk_widget_show_all(ghidgui->menu_bar); free(path); } Index: trunk/src/hid/gtk/ghid-main-menu.h =================================================================== --- trunk/src/hid/gtk/ghid-main-menu.h (revision 1021) +++ trunk/src/hid/gtk/ghid-main-menu.h (revision 1022) @@ -9,39 +9,30 @@ #include "ghid-route-style-selector.h" #include "resource.h" -G_BEGIN_DECLS /* keep c++ happy */ - +G_BEGIN_DECLS /* keep c++ happy */ #define GHID_MAIN_MENU_TYPE (ghid_main_menu_get_type ()) #define GHID_MAIN_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GHID_MAIN_MENU_TYPE, GHidMainMenu)) #define GHID_MAIN_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GHID_MAIN_MENU_TYPE, GHidMainMenuClass)) #define IS_GHID_MAIN_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GHID_MAIN_MENU_TYPE)) #define IS_GHID_MAIN_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GHID_MAIN_MENU_TYPE)) +typedef struct _GHidMainMenu GHidMainMenu; +typedef struct _GHidMainMenuClass GHidMainMenuClass; -typedef struct _GHidMainMenu GHidMainMenu; -typedef struct _GHidMainMenuClass GHidMainMenuClass; +GType ghid_main_menu_get_type(void); +GtkWidget *ghid_main_menu_new(GCallback action_cb, + void (*special_key_cb) (const char *accel, GtkAction * action, const Resource * node)); +void ghid_main_menu_add_resource(GHidMainMenu * menu, const Resource * res); +GtkAccelGroup *ghid_main_menu_get_accel_group(GHidMainMenu * menu); +void ghid_main_menu_update_toggle_state(GHidMainMenu * menu, + void (*cb) (GtkAction *, const char *toggle_flag, const char *active_flag)); -GType ghid_main_menu_get_type (void); -GtkWidget *ghid_main_menu_new (GCallback action_cb, - void (*special_key_cb) (const char *accel, - GtkAction *action, - const Resource *node)); -void ghid_main_menu_add_resource (GHidMainMenu *menu, const Resource *res); -GtkAccelGroup *ghid_main_menu_get_accel_group (GHidMainMenu *menu); -void ghid_main_menu_update_toggle_state (GHidMainMenu *menu, - void (*cb) (GtkAction *, - const char *toggle_flag, - const char *active_flag)); +void ghid_main_menu_add_popup_resource(GHidMainMenu * menu, const char *name, const Resource * res); +GtkMenu *ghid_main_menu_get_popup(GHidMainMenu * menu, const char *name); -void ghid_main_menu_add_popup_resource (GHidMainMenu *menu, const char *name, - const Resource *res); -GtkMenu *ghid_main_menu_get_popup (GHidMainMenu *menu, const char *name); +void ghid_main_menu_install_layer_selector(GHidMainMenu * mm, GHidLayerSelector * ls); +void ghid_main_menu_install_route_style_selector(GHidMainMenu * mm, GHidRouteStyleSelector * rss); -void ghid_main_menu_install_layer_selector (GHidMainMenu *mm, - GHidLayerSelector *ls); -void ghid_main_menu_install_route_style_selector (GHidMainMenu *mm, - GHidRouteStyleSelector *rss); - void ghid_create_menu(const char *menu[], const char *action, const char *mnemonic, const char *accel, const char *tip); -G_END_DECLS /* keep c++ happy */ +G_END_DECLS /* keep c++ happy */ #endif Index: trunk/src/hid/gtk/ghid-route-style-selector.c =================================================================== --- trunk/src/hid/gtk/ghid-route-style-selector.c (revision 1021) +++ trunk/src/hid/gtk/ghid-route-style-selector.c (revision 1022) @@ -18,9 +18,8 @@ /* Forward dec'ls */ struct _route_style; -struct _route_style *ghid_route_style_selector_real_add_route_style - (GHidRouteStyleSelector *, RouteStyleType *, gboolean temp); -static void ghid_route_style_selector_finalize (GObject *object); +struct _route_style *ghid_route_style_selector_real_add_route_style(GHidRouteStyleSelector *, RouteStyleType *, gboolean temp); +static void ghid_route_style_selector_finalize(GObject * object); /*! \brief Global action creation counter */ static gint action_count; @@ -27,75 +26,69 @@ /*! \brief Signals exposed by the widget */ enum { - SELECT_STYLE_SIGNAL, - STYLE_EDITED_SIGNAL, - LAST_SIGNAL + SELECT_STYLE_SIGNAL, + STYLE_EDITED_SIGNAL, + LAST_SIGNAL }; /*! \brief Columns used for internal data store */ enum { - TEXT_COL, - DATA_COL, - N_COLS + TEXT_COL, + DATA_COL, + N_COLS }; static GtkVBox *ghid_route_style_selector_parent_class; static guint ghid_route_style_selector_signals[LAST_SIGNAL] = { 0 }; -struct _GHidRouteStyleSelector -{ - GtkVBox parent; +struct _GHidRouteStyleSelector { + GtkVBox parent; - GSList *button_radio_group; - GSList *action_radio_group; - GtkWidget *edit_button; + GSList *button_radio_group; + GSList *action_radio_group; + GtkWidget *edit_button; - GtkActionGroup *action_group; - GtkAccelGroup *accel_group; + GtkActionGroup *action_group; + GtkAccelGroup *accel_group; - GtkListStore *model; - struct _route_style *active_style; + GtkListStore *model; + struct _route_style *active_style; }; -struct _GHidRouteStyleSelectorClass -{ - GtkVBoxClass parent_class; +struct _GHidRouteStyleSelectorClass { + GtkVBoxClass parent_class; - void (* select_style) (GHidRouteStyleSelector *, RouteStyleType *); - void (* style_edited) (GHidRouteStyleSelector *, gboolean); + void (*select_style) (GHidRouteStyleSelector *, RouteStyleType *); + void (*style_edited) (GHidRouteStyleSelector *, gboolean); }; -struct _route_style -{ - gboolean temporary; /* TODO: actually use this for something */ - GtkRadioAction *action; - GtkWidget *button; - GtkWidget *menu_item; - GtkTreeRowReference *rref; - RouteStyleType *rst; - gulong sig_id; +struct _route_style { + gboolean temporary; /* TODO: actually use this for something */ + GtkRadioAction *action; + GtkWidget *button; + GtkWidget *menu_item; + GtkTreeRowReference *rref; + RouteStyleType *rst; + gulong sig_id; }; /* SIGNAL HANDLERS */ /*! \brief Callback for user selection of a route style */ -static void -radio_select_cb (GtkToggleAction *action, GHidRouteStyleSelector *rss) +static void radio_select_cb(GtkToggleAction * action, GHidRouteStyleSelector * rss) { - rss->active_style = g_object_get_data (G_OBJECT (action), "route-style"); - if (gtk_toggle_action_get_active (action)) - g_signal_emit (rss, ghid_route_style_selector_signals[SELECT_STYLE_SIGNAL], - 0, rss->active_style->rst); + rss->active_style = g_object_get_data(G_OBJECT(action), "route-style"); + if (gtk_toggle_action_get_active(action)) + g_signal_emit(rss, ghid_route_style_selector_signals[SELECT_STYLE_SIGNAL], 0, rss->active_style->rst); } /* EDIT DIALOG */ -struct _dialog -{ - GHidRouteStyleSelector *rss; - GtkWidget *name_entry; - GtkWidget *line_entry; - GtkWidget *via_hole_entry; - GtkWidget *via_size_entry; - GtkWidget *clearance_entry; +struct _dialog { + GHidRouteStyleSelector *rss; + GtkWidget *name_entry; + GtkWidget *line_entry; + GtkWidget *via_hole_entry; + GtkWidget *via_size_entry; + GtkWidget *clearance_entry; }; /*! \brief Callback for dialog box's combobox being changed @@ -108,270 +101,216 @@ * \param [in] combo The combobox * \param [in] dialog The rest of the widgets to be updated */ -static void -dialog_style_changed_cb (GtkComboBox *combo, struct _dialog *dialog) +static void dialog_style_changed_cb(GtkComboBox * combo, struct _dialog *dialog) { - struct _route_style *style; - GtkTreeIter iter; - gtk_combo_box_get_active_iter (combo, &iter); - gtk_tree_model_get (GTK_TREE_MODEL (dialog->rss->model), - &iter, DATA_COL, &style, -1); + struct _route_style *style; + GtkTreeIter iter; + gtk_combo_box_get_active_iter(combo, &iter); + gtk_tree_model_get(GTK_TREE_MODEL(dialog->rss->model), &iter, DATA_COL, &style, -1); - if (style == NULL) - { - gtk_entry_set_text (GTK_ENTRY (dialog->name_entry), - _("New Style")); - return; - } + if (style == NULL) { + gtk_entry_set_text(GTK_ENTRY(dialog->name_entry), _("New Style")); + return; + } - gtk_entry_set_text (GTK_ENTRY (dialog->name_entry), style->rst->Name); - ghid_coord_entry_set_value (GHID_COORD_ENTRY (dialog->line_entry), - style->rst->Thick); - ghid_coord_entry_set_value (GHID_COORD_ENTRY (dialog->via_hole_entry), - style->rst->Hole); - ghid_coord_entry_set_value (GHID_COORD_ENTRY (dialog->via_size_entry), - style->rst->Diameter); - ghid_coord_entry_set_value (GHID_COORD_ENTRY (dialog->clearance_entry), - style->rst->Keepaway); + gtk_entry_set_text(GTK_ENTRY(dialog->name_entry), style->rst->Name); + ghid_coord_entry_set_value(GHID_COORD_ENTRY(dialog->line_entry), style->rst->Thick); + ghid_coord_entry_set_value(GHID_COORD_ENTRY(dialog->via_hole_entry), style->rst->Hole); + ghid_coord_entry_set_value(GHID_COORD_ENTRY(dialog->via_size_entry), style->rst->Diameter); + ghid_coord_entry_set_value(GHID_COORD_ENTRY(dialog->clearance_entry), style->rst->Keepaway); } /* \brief Helper for edit_button_cb */ -static void -_table_attach (GtkWidget *table, gint row, const gchar *label, - GtkWidget **entry, Coord min, Coord max) +static void _table_attach(GtkWidget * table, gint row, const gchar * label, GtkWidget ** entry, Coord min, Coord max) { - GtkWidget *label_w = gtk_label_new (label); - gtk_misc_set_alignment (GTK_MISC (label_w), 1.0, 0.5); + GtkWidget *label_w = gtk_label_new(label); + gtk_misc_set_alignment(GTK_MISC(label_w), 1.0, 0.5); - *entry = ghid_coord_entry_new (min, max, 0, Settings.grid_unit, CE_SMALL); - gtk_table_attach (GTK_TABLE (table), label_w, 0, 1, row, row + 1, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2); - gtk_table_attach (GTK_TABLE (table), *entry, 1, 2, row, row + 1, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2); + *entry = ghid_coord_entry_new(min, max, 0, Settings.grid_unit, CE_SMALL); + gtk_table_attach(GTK_TABLE(table), label_w, 0, 1, row, row + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2); + gtk_table_attach(GTK_TABLE(table), *entry, 1, 2, row, row + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2); } /* \brief Builds and runs the "edit route styles" dialog */ -void -ghid_route_style_selector_edit_dialog (GHidRouteStyleSelector *rss) +void ghid_route_style_selector_edit_dialog(GHidRouteStyleSelector * rss) { - GtkTreePath *path; - GtkTreeIter iter, tmp_iter; - struct _dialog dialog_data; - GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); - GtkWidget *window = gtk_widget_get_toplevel (GTK_WIDGET (rss)); - GtkWidget *dialog; - GtkWidget *content_area; - GtkWidget *vbox, *hbox, *sub_vbox, *table; - GtkWidget *label, *select_box, *check_box; + GtkTreePath *path; + GtkTreeIter iter, tmp_iter; + struct _dialog dialog_data; + GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); + GtkWidget *window = gtk_widget_get_toplevel(GTK_WIDGET(rss)); + GtkWidget *dialog; + GtkWidget *content_area; + GtkWidget *vbox, *hbox, *sub_vbox, *table; + GtkWidget *label, *select_box, *check_box; - /* Build dialog */ - dialog = gtk_dialog_new_with_buttons (_("Edit Route Styles"), - GTK_WINDOW (window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CANCEL, GTK_RESPONSE_NONE, - GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); + /* Build dialog */ + dialog = gtk_dialog_new_with_buttons(_("Edit Route Styles"), + GTK_WINDOW(window), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_CANCEL, GTK_RESPONSE_NONE, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); - label = gtk_label_new (_("Edit Style:")); - gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + label = gtk_label_new(_("Edit Style:")); + gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); - select_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (rss->model)); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (select_box), renderer, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT(select_box), renderer, - "text", TEXT_COL, NULL); + select_box = gtk_combo_box_new_with_model(GTK_TREE_MODEL(rss->model)); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(select_box), renderer, TRUE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(select_box), renderer, "text", TEXT_COL, NULL); - content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); + content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); - hbox = gtk_hbox_new (FALSE, 4); - gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 4); - vbox = gtk_vbox_new (FALSE, 4); - gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 4); + hbox = gtk_hbox_new(FALSE, 4); + gtk_box_pack_start(GTK_BOX(content_area), hbox, TRUE, TRUE, 4); + vbox = gtk_vbox_new(FALSE, 4); + gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 4); - hbox = gtk_hbox_new (FALSE, 4); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 4); - gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (hbox), select_box, TRUE, TRUE, 0); + hbox = gtk_hbox_new(FALSE, 4); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 4); + gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(hbox), select_box, TRUE, TRUE, 0); - sub_vbox = ghid_category_vbox (vbox, _("Route Style Data"), - 4, 2, TRUE, TRUE); - table = gtk_table_new (5, 2, FALSE); - gtk_box_pack_start (GTK_BOX (sub_vbox), table, TRUE, TRUE, 4); - label = gtk_label_new (_("Name:")); - gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); - dialog_data.name_entry = gtk_entry_new (); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2); - gtk_table_attach (GTK_TABLE (table), dialog_data.name_entry, 1, 2, 0, 1, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2); + sub_vbox = ghid_category_vbox(vbox, _("Route Style Data"), 4, 2, TRUE, TRUE); + table = gtk_table_new(5, 2, FALSE); + gtk_box_pack_start(GTK_BOX(sub_vbox), table, TRUE, TRUE, 4); + label = gtk_label_new(_("Name:")); + gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); + dialog_data.name_entry = gtk_entry_new(); + gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2); + gtk_table_attach(GTK_TABLE(table), dialog_data.name_entry, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2); - _table_attach (table, 1, _("Line width:"), - &dialog_data.line_entry, - MIN_LINESIZE, MAX_LINESIZE); - _table_attach (table, 2, _("Via hole size:"), - &dialog_data.via_hole_entry, - MIN_PINORVIAHOLE, MAX_PINORVIASIZE - MIN_PINORVIACOPPER); - _table_attach (table, 3, _("Via ring size:"), - &dialog_data.via_size_entry, - MIN_PINORVIAHOLE + MIN_PINORVIACOPPER, MAX_PINORVIASIZE); - _table_attach (table, 4, _("Clearance:"), - &dialog_data.clearance_entry, - MIN_LINESIZE, MAX_LINESIZE); + _table_attach(table, 1, _("Line width:"), &dialog_data.line_entry, MIN_LINESIZE, MAX_LINESIZE); + _table_attach(table, 2, _("Via hole size:"), + &dialog_data.via_hole_entry, MIN_PINORVIAHOLE, MAX_PINORVIASIZE - MIN_PINORVIACOPPER); + _table_attach(table, 3, _("Via ring size:"), + &dialog_data.via_size_entry, MIN_PINORVIAHOLE + MIN_PINORVIACOPPER, MAX_PINORVIASIZE); + _table_attach(table, 4, _("Clearance:"), &dialog_data.clearance_entry, MIN_LINESIZE, MAX_LINESIZE); - sub_vbox = ghid_category_vbox (vbox, _("Set as Default"), - 4, 2, TRUE, TRUE); - check_box = gtk_check_button_new_with_label - (_("Save route style settings as default")); - gtk_box_pack_start (GTK_BOX (sub_vbox), check_box, TRUE, TRUE, 0); + sub_vbox = ghid_category_vbox(vbox, _("Set as Default"), 4, 2, TRUE, TRUE); + check_box = gtk_check_button_new_with_label(_("Save route style settings as default")); + gtk_box_pack_start(GTK_BOX(sub_vbox), check_box, TRUE, TRUE, 0); - /* Add "new style" option to list */ - gtk_list_store_append (rss->model, &tmp_iter); - gtk_list_store_set (rss->model, &tmp_iter, TEXT_COL, - _("New (this session only)"), DATA_COL, NULL, -1); + /* Add "new style" option to list */ + gtk_list_store_append(rss->model, &tmp_iter); + gtk_list_store_set(rss->model, &tmp_iter, TEXT_COL, _("New (this session only)"), DATA_COL, NULL, -1); - /* Display dialog */ - dialog_data.rss = rss; - path = gtk_tree_row_reference_get_path (rss->active_style->rref); - gtk_tree_model_get_iter (GTK_TREE_MODEL (rss->model), &iter, path); - g_signal_connect (G_OBJECT (select_box), "changed", - G_CALLBACK (dialog_style_changed_cb), &dialog_data); - gtk_combo_box_set_active_iter (GTK_COMBO_BOX (select_box), &iter); - gtk_widget_show_all (dialog); - if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) - { - RouteStyleType *rst; - struct _route_style *style; - gboolean save; - gtk_combo_box_get_active_iter (GTK_COMBO_BOX (select_box), &iter); - gtk_tree_model_get (GTK_TREE_MODEL (rss->model), - &iter, DATA_COL, &style, -1); - if (style == NULL) - rst = g_malloc (sizeof *rst); - else - { - rst = style->rst; - free (rst->Name); - } + /* Display dialog */ + dialog_data.rss = rss; + path = gtk_tree_row_reference_get_path(rss->active_style->rref); + gtk_tree_model_get_iter(GTK_TREE_MODEL(rss->model), &iter, path); + g_signal_connect(G_OBJECT(select_box), "changed", G_CALLBACK(dialog_style_changed_cb), &dialog_data); + gtk_combo_box_set_active_iter(GTK_COMBO_BOX(select_box), &iter); + gtk_widget_show_all(dialog); + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { + RouteStyleType *rst; + struct _route_style *style; + gboolean save; + gtk_combo_box_get_active_iter(GTK_COMBO_BOX(select_box), &iter); + gtk_tree_model_get(GTK_TREE_MODEL(rss->model), &iter, DATA_COL, &style, -1); + if (style == NULL) + rst = g_malloc(sizeof *rst); + else { + rst = style->rst; + free(rst->Name); + } - rst->Name = StripWhiteSpaceAndDup - (gtk_entry_get_text (GTK_ENTRY (dialog_data.name_entry))); - rst->Thick = ghid_coord_entry_get_value - (GHID_COORD_ENTRY (dialog_data.line_entry)); - rst->Hole = ghid_coord_entry_get_value - (GHID_COORD_ENTRY (dialog_data.via_hole_entry)); - rst->Diameter = ghid_coord_entry_get_value - (GHID_COORD_ENTRY (dialog_data.via_size_entry)); - rst->Keepaway = ghid_coord_entry_get_value - (GHID_COORD_ENTRY (dialog_data.clearance_entry)); - save = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_box)); + rst->Name = StripWhiteSpaceAndDup(gtk_entry_get_text(GTK_ENTRY(dialog_data.name_entry))); + rst->Thick = ghid_coord_entry_get_value(GHID_COORD_ENTRY(dialog_data.line_entry)); + rst->Hole = ghid_coord_entry_get_value(GHID_COORD_ENTRY(dialog_data.via_hole_entry)); + rst->Diameter = ghid_coord_entry_get_value(GHID_COORD_ENTRY(dialog_data.via_size_entry)); + rst->Keepaway = ghid_coord_entry_get_value(GHID_COORD_ENTRY(dialog_data.clearance_entry)); + save = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_box)); - if (style == NULL) - style = ghid_route_style_selector_real_add_route_style - (rss, rst, TRUE); - else - { - gtk_action_set_label (GTK_ACTION (style->action), rst->Name); - gtk_list_store_set (rss->model, &iter, TEXT_COL, rst->Name, -1); - } + if (style == NULL) + style = ghid_route_style_selector_real_add_route_style(rss, rst, TRUE); + else { + gtk_action_set_label(GTK_ACTION(style->action), rst->Name); + gtk_list_store_set(rss->model, &iter, TEXT_COL, rst->Name, -1); + } - /* Cleanup */ - gtk_widget_destroy (dialog); - gtk_list_store_remove (rss->model, &tmp_iter); - /* Emit change signals */ - ghid_route_style_selector_select_style (rss, rst); - g_signal_emit - (rss, ghid_route_style_selector_signals[STYLE_EDITED_SIGNAL], - 0, save); - } - else - { - gtk_widget_destroy (dialog); - gtk_list_store_remove (rss->model, &tmp_iter); - } + /* Cleanup */ + gtk_widget_destroy(dialog); + gtk_list_store_remove(rss->model, &tmp_iter); + /* Emit change signals */ + ghid_route_style_selector_select_style(rss, rst); + g_signal_emit(rss, ghid_route_style_selector_signals[STYLE_EDITED_SIGNAL], 0, save); + } + else { + gtk_widget_destroy(dialog); + gtk_list_store_remove(rss->model, &tmp_iter); + } } + /* end EDIT DIALOG */ -static void -edit_button_cb (GtkButton *btn, GHidRouteStyleSelector *rss) +static void edit_button_cb(GtkButton * btn, GHidRouteStyleSelector * rss) { - ghid_route_style_selector_edit_dialog (rss); + ghid_route_style_selector_edit_dialog(rss); } /* CONSTRUCTOR */ -static void -ghid_route_style_selector_init (GHidRouteStyleSelector *rss) +static void ghid_route_style_selector_init(GHidRouteStyleSelector * rss) { } -static void -ghid_route_style_selector_class_init (GHidRouteStyleSelectorClass *klass) +static void ghid_route_style_selector_class_init(GHidRouteStyleSelectorClass * klass) { - GObjectClass *object_class = (GObjectClass *) klass; + GObjectClass *object_class = (GObjectClass *) klass; - ghid_route_style_selector_parent_class = g_type_class_peek_parent (klass); + ghid_route_style_selector_parent_class = g_type_class_peek_parent(klass); - ghid_route_style_selector_signals[SELECT_STYLE_SIGNAL] = - g_signal_new ("select-style", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (GHidRouteStyleSelectorClass, select_style), - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, - 1, G_TYPE_POINTER); - ghid_route_style_selector_signals[STYLE_EDITED_SIGNAL] = - g_signal_new ("style-edited", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (GHidRouteStyleSelectorClass, style_edited), - NULL, NULL, - g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, - 1, G_TYPE_BOOLEAN); + ghid_route_style_selector_signals[SELECT_STYLE_SIGNAL] = + g_signal_new("select-style", + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET(GHidRouteStyleSelectorClass, select_style), + NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); + ghid_route_style_selector_signals[STYLE_EDITED_SIGNAL] = + g_signal_new("style-edited", + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET(GHidRouteStyleSelectorClass, style_edited), + NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN); - object_class->finalize = ghid_route_style_selector_finalize; + object_class->finalize = ghid_route_style_selector_finalize; } /*! \brief Clean up object before garbage collection */ -static void -ghid_route_style_selector_finalize (GObject *object) +static void ghid_route_style_selector_finalize(GObject * object) { - GHidRouteStyleSelector *rss = (GHidRouteStyleSelector *) object; + GHidRouteStyleSelector *rss = (GHidRouteStyleSelector *) object; - ghid_route_style_selector_empty (rss); + ghid_route_style_selector_empty(rss); - g_object_unref (rss->accel_group); - g_object_unref (rss->action_group); + g_object_unref(rss->accel_group); + g_object_unref(rss->action_group); - G_OBJECT_CLASS (ghid_route_style_selector_parent_class)->finalize (object); + G_OBJECT_CLASS(ghid_route_style_selector_parent_class)->finalize(object); } /* PUBLIC FUNCTIONS */ -GType -ghid_route_style_selector_get_type (void) +GType ghid_route_style_selector_get_type(void) { - static GType rss_type = 0; + static GType rss_type = 0; - if (!rss_type) - { - const GTypeInfo rss_info = - { - sizeof (GHidRouteStyleSelectorClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) ghid_route_style_selector_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GHidRouteStyleSelector), - 0, /* n_preallocs */ - (GInstanceInitFunc) ghid_route_style_selector_init, - }; + if (!rss_type) { + const GTypeInfo rss_info = { + sizeof(GHidRouteStyleSelectorClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) ghid_route_style_selector_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(GHidRouteStyleSelector), + 0, /* n_preallocs */ + (GInstanceInitFunc) ghid_route_style_selector_init, + }; - rss_type = g_type_register_static (GTK_TYPE_VBOX, - "GHidRouteStyleSelector", - &rss_info, - 0); - } + rss_type = g_type_register_static(GTK_TYPE_VBOX, "GHidRouteStyleSelector", &rss_info, 0); + } - return rss_type; + return rss_type; } /*! \brief Create a new GHidRouteStyleSelector @@ -378,27 +317,24 @@ * * \return a freshly-allocated GHidRouteStyleSelector. */ -GtkWidget * -ghid_route_style_selector_new () +GtkWidget *ghid_route_style_selector_new() { - GHidRouteStyleSelector *rss = - g_object_new (GHID_ROUTE_STYLE_SELECTOR_TYPE, NULL); + GHidRouteStyleSelector *rss = g_object_new(GHID_ROUTE_STYLE_SELECTOR_TYPE, NULL); - rss->active_style = NULL; - rss->action_radio_group = NULL; - rss->button_radio_group = NULL; - rss->model = gtk_list_store_new (N_COLS, G_TYPE_STRING, G_TYPE_POINTER); + rss->active_style = NULL; + rss->action_radio_group = NULL; + rss->button_radio_group = NULL; + rss->model = gtk_list_store_new(N_COLS, G_TYPE_STRING, G_TYPE_POINTER); - rss->accel_group = gtk_accel_group_new (); - rss->action_group = gtk_action_group_new ("RouteStyleSelector"); + rss->accel_group = gtk_accel_group_new(); + rss->action_group = gtk_action_group_new("RouteStyleSelector"); - /* Create edit button */ - rss->edit_button = gtk_button_new_with_label (_("Route Styles")); - g_signal_connect (G_OBJECT (rss->edit_button), "clicked", - G_CALLBACK (edit_button_cb), rss); - gtk_box_pack_start (GTK_BOX (rss), rss->edit_button, FALSE, FALSE, 0); + /* Create edit button */ + rss->edit_button = gtk_button_new_with_label(_("Route Styles")); + g_signal_connect(G_OBJECT(rss->edit_button), "clicked", G_CALLBACK(edit_button_cb), rss); + gtk_box_pack_start(GTK_BOX(rss), rss->edit_button, FALSE, FALSE, 0); - return GTK_WIDGET (rss); + return GTK_WIDGET(rss); } /*! \brief Create a new GHidRouteStyleSelector @@ -407,59 +343,46 @@ * \param [in] data PCB's route style object that will be edited * \param [in] temp Whether the style is "real" or session-only */ -struct _route_style * -ghid_route_style_selector_real_add_route_style (GHidRouteStyleSelector *rss, - RouteStyleType *data, - gboolean temp) +struct _route_style *ghid_route_style_selector_real_add_route_style(GHidRouteStyleSelector * rss, + RouteStyleType * data, gboolean temp) { - GtkTreeIter iter; - GtkTreePath *path; - gchar *action_name = g_strdup_printf ("RouteStyle%d", action_count); - struct _route_style *new_style = g_malloc (sizeof (*new_style)); + GtkTreeIter iter; + GtkTreePath *path; + gchar *action_name = g_strdup_printf("RouteStyle%d", action_count); + struct _route_style *new_style = g_malloc(sizeof(*new_style)); - /* Key the route style data with the RouteStyleType it controls */ - new_style->rst = data; - new_style->temporary = temp; - new_style->action = gtk_radio_action_new (action_name, data->Name, - NULL, NULL, action_count); - gtk_radio_action_set_group (new_style->action, rss->action_radio_group); - rss->action_radio_group = gtk_radio_action_get_group (new_style->action); - new_style->button = gtk_radio_button_new (rss->button_radio_group); - rss->button_radio_group = gtk_radio_button_get_group - (GTK_RADIO_BUTTON (new_style->button)); - gtk_activatable_set_related_action (GTK_ACTIVATABLE (new_style->button), - GTK_ACTION (new_style->action)); + /* Key the route style data with the RouteStyleType it controls */ + new_style->rst = data; + new_style->temporary = temp; + new_style->action = gtk_radio_action_new(action_name, data->Name, NULL, NULL, action_count); + gtk_radio_action_set_group(new_style->action, rss->action_radio_group); + rss->action_radio_group = gtk_radio_action_get_group(new_style->action); + new_style->button = gtk_radio_button_new(rss->button_radio_group); + rss->button_radio_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(new_style->button)); + gtk_activatable_set_related_action(GTK_ACTIVATABLE(new_style->button), GTK_ACTION(new_style->action)); - gtk_list_store_append (rss->model, &iter); - gtk_list_store_set (rss->model, &iter, TEXT_COL, data->Name, - DATA_COL, new_style, -1); - path = gtk_tree_model_get_path (GTK_TREE_MODEL (rss->model), &iter); - new_style->rref = gtk_tree_row_reference_new (GTK_TREE_MODEL (rss->model), - path); - gtk_tree_path_free (path); + gtk_list_store_append(rss->model, &iter); + gtk_list_store_set(rss->model, &iter, TEXT_COL, data->Name, DATA_COL, new_style, -1); + path = gtk_tree_model_get_path(GTK_TREE_MODEL(rss->model), &iter); + new_style->rref = gtk_tree_row_reference_new(GTK_TREE_MODEL(rss->model), path); + gtk_tree_path_free(path); - /* Setup accelerator */ - if (action_count < 12) - { - gchar *accel = g_strdup_printf ("F%d", action_count + 1); - gtk_action_set_accel_group (GTK_ACTION (new_style->action), - rss->accel_group); - gtk_action_group_add_action_with_accel (rss->action_group, - GTK_ACTION (new_style->action), - accel); - g_free (accel); - } + /* Setup accelerator */ + if (action_count < 12) { + gchar *accel = g_strdup_printf("F%d", action_count + 1); + gtk_action_set_accel_group(GTK_ACTION(new_style->action), rss->accel_group); + gtk_action_group_add_action_with_accel(rss->action_group, GTK_ACTION(new_style->action), accel); + g_free(accel); + } - /* Hookup and install radio button */ - g_object_set_data (G_OBJECT (new_style->action), "route-style", new_style); - new_style->sig_id = g_signal_connect (G_OBJECT (new_style->action), - "activate", - G_CALLBACK (radio_select_cb), rss); - gtk_box_pack_start (GTK_BOX (rss), new_style->button, FALSE, FALSE, 0); + /* Hookup and install radio button */ + g_object_set_data(G_OBJECT(new_style->action), "route-style", new_style); + new_style->sig_id = g_signal_connect(G_OBJECT(new_style->action), "activate", G_CALLBACK(radio_select_cb), rss); + gtk_box_pack_start(GTK_BOX(rss), new_style->button, FALSE, FALSE, 0); - g_free (action_name); - ++action_count; - return new_style; + g_free(action_name); + ++action_count; + return new_style; } /*! \brief Adds a route style to a GHidRouteStyleSelector @@ -471,11 +394,9 @@ * \param [in] rss The selector to be acted on * \param [in] data PCB's route style object describing the style */ -void -ghid_route_style_selector_add_route_style (GHidRouteStyleSelector *rss, - RouteStyleType *data) +void ghid_route_style_selector_add_route_style(GHidRouteStyleSelector * rss, RouteStyleType * data) { - ghid_route_style_selector_real_add_route_style (rss, data, FALSE); + ghid_route_style_selector_real_add_route_style(rss, data, FALSE); } @@ -492,29 +413,25 @@ * * \return the number of items installed */ -gint -ghid_route_style_selector_install_items (GHidRouteStyleSelector *rss, - GtkMenuShell *shell, gint pos) +gint ghid_route_style_selector_install_items(GHidRouteStyleSelector * rss, GtkMenuShell * shell, gint pos) { - gint n = 0; - GtkTreeIter iter; + gint n = 0; + GtkTreeIter iter; - gtk_tree_model_get_iter_first (GTK_TREE_MODEL (rss->model), &iter); - do - { - GtkAction *action; - struct _route_style *style; + gtk_tree_model_get_iter_first(GTK_TREE_MODEL(rss->model), &iter); + do { + GtkAction *action; + struct _route_style *style; - gtk_tree_model_get (GTK_TREE_MODEL (rss->model), - &iter, DATA_COL, &style, -1); - action = GTK_ACTION (style->action); - style->menu_item = gtk_action_create_menu_item (action); - gtk_menu_shell_insert (shell, style->menu_item, pos + n); - ++n; - } - while (gtk_tree_model_iter_next (GTK_TREE_MODEL (rss->model), &iter)); + gtk_tree_model_get(GTK_TREE_MODEL(rss->model), &iter, DATA_COL, &style, -1); + action = GTK_ACTION(style->action); + style->menu_item = gtk_action_create_menu_item(action); + gtk_menu_shell_insert(shell, style->menu_item, pos + n); + ++n; + } + while (gtk_tree_model_iter_next(GTK_TREE_MODEL(rss->model), &iter)); - return n; + return n; } /*! \brief Selects a route style and emits a select-style signal @@ -524,33 +441,25 @@ * * \return TRUE if a style was selected, FALSE otherwise */ -gboolean -ghid_route_style_selector_select_style (GHidRouteStyleSelector *rss, - RouteStyleType *rst) +gboolean ghid_route_style_selector_select_style(GHidRouteStyleSelector * rss, RouteStyleType * rst) { - GtkTreeIter iter; - gtk_tree_model_get_iter_first (GTK_TREE_MODEL (rss->model), &iter); - do - { - struct _route_style *style; - gtk_tree_model_get (GTK_TREE_MODEL (rss->model), - &iter, DATA_COL, &style, -1); - if (style->rst == rst) - { - g_signal_handler_block (G_OBJECT (style->action), style->sig_id); - gtk_toggle_action_set_active - (GTK_TOGGLE_ACTION (style->action), TRUE); - g_signal_handler_unblock (G_OBJECT (style->action), style->sig_id); - rss->active_style = style; - g_signal_emit - (rss, ghid_route_style_selector_signals[SELECT_STYLE_SIGNAL], - 0, rss->active_style->rst); - return TRUE; - } - } - while (gtk_tree_model_iter_next (GTK_TREE_MODEL (rss->model), &iter)); + GtkTreeIter iter; + gtk_tree_model_get_iter_first(GTK_TREE_MODEL(rss->model), &iter); + do { + struct _route_style *style; + gtk_tree_model_get(GTK_TREE_MODEL(rss->model), &iter, DATA_COL, &style, -1); + if (style->rst == rst) { + g_signal_handler_block(G_OBJECT(style->action), style->sig_id); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(style->action), TRUE); + g_signal_handler_unblock(G_OBJECT(style->action), style->sig_id); + rss->active_style = style; + g_signal_emit(rss, ghid_route_style_selector_signals[SELECT_STYLE_SIGNAL], 0, rss->active_style->rst); + return TRUE; + } + } + while (gtk_tree_model_iter_next(GTK_TREE_MODEL(rss->model), &iter)); - return FALSE; + return FALSE; } /*! \brief Returns the GtkAccelGroup of a route style selector @@ -560,10 +469,9 @@ * * \return the accel group of the selector */ -GtkAccelGroup * -ghid_route_style_selector_get_accel_group (GHidRouteStyleSelector *rss) +GtkAccelGroup *ghid_route_style_selector_get_accel_group(GHidRouteStyleSelector * rss) { - return rss->accel_group; + return rss->accel_group; } /*! \brief Sets a GHidRouteStyleSelector selection to given values @@ -579,58 +487,43 @@ * \param [in] Diameter Coord to match selection to * \param [in] Keepaway Coord to match selection to */ -void -ghid_route_style_selector_sync (GHidRouteStyleSelector *rss, - Coord Thick, Coord Hole, - Coord Diameter, Coord Keepaway) +void ghid_route_style_selector_sync(GHidRouteStyleSelector * rss, Coord Thick, Coord Hole, Coord Diameter, Coord Keepaway) { - GtkTreeIter iter; - gtk_tree_model_get_iter_first (GTK_TREE_MODEL (rss->model), &iter); - do - { - struct _route_style *style; - gtk_tree_model_get (GTK_TREE_MODEL (rss->model), - &iter, DATA_COL, &style, -1); - if (style->rst->Thick == Thick && - style->rst->Hole == Hole && - style->rst->Diameter == Diameter && - style->rst->Keepaway == Keepaway) - { - g_signal_handler_block (G_OBJECT (style->action), style->sig_id); - gtk_toggle_action_set_active - (GTK_TOGGLE_ACTION (style->action), TRUE); - g_signal_handler_unblock (G_OBJECT (style->action), style->sig_id); - rss->active_style = style; - } - } - while (gtk_tree_model_iter_next (GTK_TREE_MODEL (rss->model), &iter)); + GtkTreeIter iter; + gtk_tree_model_get_iter_first(GTK_TREE_MODEL(rss->model), &iter); + do { + struct _route_style *style; + gtk_tree_model_get(GTK_TREE_MODEL(rss->model), &iter, DATA_COL, &style, -1); + if (style->rst->Thick == Thick && + style->rst->Hole == Hole && style->rst->Diameter == Diameter && style->rst->Keepaway == Keepaway) { + g_signal_handler_block(G_OBJECT(style->action), style->sig_id); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(style->action), TRUE); + g_signal_handler_unblock(G_OBJECT(style->action), style->sig_id); + rss->active_style = style; + } + } + while (gtk_tree_model_iter_next(GTK_TREE_MODEL(rss->model), &iter)); } /*! \brief Removes all styles from a route style selector */ -void -ghid_route_style_selector_empty (GHidRouteStyleSelector *rss) +void ghid_route_style_selector_empty(GHidRouteStyleSelector * rss) { - GtkTreeIter iter; - gtk_tree_model_get_iter_first (GTK_TREE_MODEL (rss->model), &iter); - do - { - struct _route_style *rsdata; - gtk_tree_model_get (GTK_TREE_MODEL (rss->model), - &iter, DATA_COL, &rsdata, -1); - if (rsdata->action) - { - gtk_action_disconnect_accelerator (GTK_ACTION (rsdata->action)); - gtk_action_group_remove_action (rss->action_group, - GTK_ACTION (rsdata->action)); - g_object_unref (G_OBJECT (rsdata->action)); - } - if (rsdata->button) - gtk_widget_destroy (GTK_WIDGET (rsdata->button));; - gtk_tree_row_reference_free (rsdata->rref); - free (rsdata); - } - while (gtk_list_store_remove (rss->model, &iter)); - rss->action_radio_group = NULL; - rss->button_radio_group = NULL; + GtkTreeIter iter; + gtk_tree_model_get_iter_first(GTK_TREE_MODEL(rss->model), &iter); + do { + struct _route_style *rsdata; + gtk_tree_model_get(GTK_TREE_MODEL(rss->model), &iter, DATA_COL, &rsdata, -1); + if (rsdata->action) { + gtk_action_disconnect_accelerator(GTK_ACTION(rsdata->action)); + gtk_action_group_remove_action(rss->action_group, GTK_ACTION(rsdata->action)); + g_object_unref(G_OBJECT(rsdata->action)); + } + if (rsdata->button) + gtk_widget_destroy(GTK_WIDGET(rsdata->button));; + gtk_tree_row_reference_free(rsdata->rref); + free(rsdata); + } + while (gtk_list_store_remove(rss->model, &iter)); + rss->action_radio_group = NULL; + rss->button_radio_group = NULL; } - Index: trunk/src/hid/gtk/ghid-route-style-selector.h =================================================================== --- trunk/src/hid/gtk/ghid-route-style-selector.h (revision 1021) +++ trunk/src/hid/gtk/ghid-route-style-selector.h (revision 1022) @@ -7,36 +7,28 @@ #include "global.h" -G_BEGIN_DECLS /* keep c++ happy */ - +G_BEGIN_DECLS /* keep c++ happy */ #define GHID_ROUTE_STYLE_SELECTOR_TYPE (ghid_route_style_selector_get_type ()) #define GHID_ROUTE_STYLE_SELECTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GHID_ROUTE_STYLE_SELECTOR_TYPE, GHidRouteStyleSelector)) #define GHID_ROUTE_STYLE_SELECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GHID_ROUTE_STYLE_SELECTOR_TYPE, GHidRouteStyleSelectorClass)) #define IS_GHID_ROUTE_STYLE_SELECTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GHID_ROUTE_STYLE_SELECTOR_TYPE)) #define IS_GHID_ROUTE_STYLE_SELECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GHID_ROUTE_STYLE_SELECTOR_TYPE)) +typedef struct _GHidRouteStyleSelector GHidRouteStyleSelector; +typedef struct _GHidRouteStyleSelectorClass GHidRouteStyleSelectorClass; -typedef struct _GHidRouteStyleSelector GHidRouteStyleSelector; -typedef struct _GHidRouteStyleSelectorClass GHidRouteStyleSelectorClass; +GType ghid_route_style_selector_get_type(void); +GtkWidget *ghid_route_style_selector_new(void); -GType ghid_route_style_selector_get_type (void); -GtkWidget* ghid_route_style_selector_new (void); +gint ghid_route_style_selector_install_items(GHidRouteStyleSelector * rss, GtkMenuShell * shell, gint pos); -gint ghid_route_style_selector_install_items (GHidRouteStyleSelector *rss, - GtkMenuShell *shell, gint pos); +void ghid_route_style_selector_add_route_style(GHidRouteStyleSelector * rss, RouteStyleType * data); +gboolean ghid_route_style_selector_select_style(GHidRouteStyleSelector * rss, RouteStyleType * rst); +void ghid_route_style_selector_edit_dialog(GHidRouteStyleSelector * rss); -void ghid_route_style_selector_add_route_style (GHidRouteStyleSelector *rss, - RouteStyleType *data); -gboolean ghid_route_style_selector_select_style (GHidRouteStyleSelector *rss, - RouteStyleType *rst); -void ghid_route_style_selector_edit_dialog (GHidRouteStyleSelector *rss); +GtkAccelGroup *ghid_route_style_selector_get_accel_group(GHidRouteStyleSelector * rss); -GtkAccelGroup *ghid_route_style_selector_get_accel_group - (GHidRouteStyleSelector *rss); +void ghid_route_style_selector_sync(GHidRouteStyleSelector * rss, Coord Thick, Coord Hole, Coord Diameter, Coord Keepaway); +void ghid_route_style_selector_empty(GHidRouteStyleSelector * rss); -void ghid_route_style_selector_sync (GHidRouteStyleSelector *rss, - Coord Thick, Coord Hole, - Coord Diameter, Coord Keepaway); -void ghid_route_style_selector_empty (GHidRouteStyleSelector *rss); - -G_END_DECLS /* keep c++ happy */ +G_END_DECLS /* keep c++ happy */ #endif Index: trunk/src/hid/gtk/gtk_debug.h =================================================================== --- trunk/src/hid/gtk/gtk_debug.h (revision 1021) +++ trunk/src/hid/gtk/gtk_debug.h (revision 1022) @@ -3,10 +3,12 @@ #include #include -static void print_widget(GtkWidget *w) +static void print_widget(GtkWidget * w) { - fprintf(stderr, " %p %d;%d %d;%d %d;%d\n", w, w->allocation.x, w->allocation.y, w->allocation.width, w->allocation.height, w->requisition.width, w->requisition.height); - fprintf(stderr, " flags=%x typ=%d realized=%d vis=%d\n", GTK_WIDGET_FLAGS(w), GTK_WIDGET_TYPE(w), GTK_WIDGET_REALIZED(w), GTK_WIDGET_VISIBLE(w)); + fprintf(stderr, " %p %d;%d %d;%d %d;%d\n", w, w->allocation.x, w->allocation.y, w->allocation.width, w->allocation.height, + w->requisition.width, w->requisition.height); + fprintf(stderr, " flags=%x typ=%d realized=%d vis=%d\n", GTK_WIDGET_FLAGS(w), GTK_WIDGET_TYPE(w), GTK_WIDGET_REALIZED(w), + GTK_WIDGET_VISIBLE(w)); } @@ -16,10 +18,9 @@ print_widget(w); } -static void print_menu_shell(GtkMenuShell *sh) +static void print_menu_shell(GtkMenuShell * sh) { GList *children; - children = gtk_container_get_children (GTK_CONTAINER (sh)); + children = gtk_container_get_children(GTK_CONTAINER(sh)); g_list_foreach(children, print_menu_shell_cb, NULL); } - Index: trunk/src/hid/gtk/gtkhid-gdk.c =================================================================== --- trunk/src/hid/gtk/gtkhid-gdk.c (revision 1021) +++ trunk/src/hid/gtk/gtkhid-gdk.c (revision 1022) @@ -15,7 +15,7 @@ #endif -RCSID ("$Id$"); +RCSID("$Id$"); extern HID ghid_hid; @@ -28,1382 +28,1229 @@ static int mask_seq = 0; typedef struct render_priv { - GdkGC *bg_gc; - GdkGC *offlimits_gc; - GdkGC *mask_gc; - GdkGC *u_gc; - GdkGC *grid_gc; - bool clip; - GdkRectangle clip_rect; - int attached_invalidate_depth; - int mark_invalidate_depth; + GdkGC *bg_gc; + GdkGC *offlimits_gc; + GdkGC *mask_gc; + GdkGC *u_gc; + GdkGC *grid_gc; + bool clip; + GdkRectangle clip_rect; + int attached_invalidate_depth; + int mark_invalidate_depth; - /* Feature for leading the user to a particular location */ - guint lead_user_timeout; - GTimer *lead_user_timer; - bool lead_user; - Coord lead_user_radius; - Coord lead_user_x; - Coord lead_user_y; + /* Feature for leading the user to a particular location */ + guint lead_user_timeout; + GTimer *lead_user_timer; + bool lead_user; + Coord lead_user_radius; + Coord lead_user_x; + Coord lead_user_y; } render_priv; -typedef struct hid_gc_struct -{ - HID *me_pointer; - GdkGC *gc; +typedef struct hid_gc_struct { + HID *me_pointer; + GdkGC *gc; - gchar *colorname; - Coord width; - gint cap, join; - gchar xor_mask; - gint mask_seq; -} -hid_gc_struct; + gchar *colorname; + Coord width; + gint cap, join; + gchar xor_mask; + gint mask_seq; +} hid_gc_struct; -static void draw_lead_user (render_priv *priv); +static void draw_lead_user(render_priv * priv); -int -ghid_set_layer (const char *name, int group, int empty) +int ghid_set_layer(const char *name, int group, int empty) { - int idx = group; - if (idx >= 0 && idx < max_group) - { - int n = PCB->LayerGroups.Number[group]; - for (idx = 0; idx < n-1; idx ++) - { - int ni = PCB->LayerGroups.Entries[group][idx]; - if (ni >= 0 && ni < max_copper_layer + 2 - && PCB->Data->Layer[ni].On) - break; + int idx = group; + if (idx >= 0 && idx < max_group) { + int n = PCB->LayerGroups.Number[group]; + for (idx = 0; idx < n - 1; idx++) { + int ni = PCB->LayerGroups.Entries[group][idx]; + if (ni >= 0 && ni < max_copper_layer + 2 && PCB->Data->Layer[ni].On) + break; + } + idx = PCB->LayerGroups.Entries[group][idx]; } - idx = PCB->LayerGroups.Entries[group][idx]; - } - if (idx >= 0 && idx < max_copper_layer + 2) - return /*pinout ? 1 : */ PCB->Data->Layer[idx].On; - if (idx < 0) - { - switch (SL_TYPE (idx)) - { - case SL_INVISIBLE: - return /* pinout ? 0 : */ PCB->InvisibleObjectsOn; - case SL_MASK: - if (SL_MYSIDE (idx) /*&& !pinout */ ) - return TEST_FLAG (SHOWMASKFLAG, PCB); - return 0; - case SL_SILK: - if (SL_MYSIDE (idx) /*|| pinout */ ) - return PCB->ElementOn; - return 0; - case SL_ASSY: - return 0; - case SL_PDRILL: - case SL_UDRILL: - return 1; - case SL_RATS: - return PCB->RatOn; + if (idx >= 0 && idx < max_copper_layer + 2) + return /*pinout ? 1 : */ PCB->Data->Layer[idx].On; + if (idx < 0) { + switch (SL_TYPE(idx)) { + case SL_INVISIBLE: + return /* pinout ? 0 : */ PCB->InvisibleObjectsOn; + case SL_MASK: + if (SL_MYSIDE(idx) /*&& !pinout */ ) + return TEST_FLAG(SHOWMASKFLAG, PCB); + return 0; + case SL_SILK: + if (SL_MYSIDE(idx) /*|| pinout */ ) + return PCB->ElementOn; + return 0; + case SL_ASSY: + return 0; + case SL_PDRILL: + case SL_UDRILL: + return 1; + case SL_RATS: + return PCB->RatOn; + } } - } - return 0; + return 0; } -void -ghid_destroy_gc (hidGC gc) +void ghid_destroy_gc(hidGC gc) { - if (gc->gc) - g_object_unref (gc->gc); - if (gc->colorname != NULL) - g_free(gc->colorname); - g_free (gc); + if (gc->gc) + g_object_unref(gc->gc); + if (gc->colorname != NULL) + g_free(gc->colorname); + g_free(gc); } -hidGC -ghid_make_gc (void) +hidGC ghid_make_gc(void) { - hidGC rv; + hidGC rv; - rv = g_new0 (hid_gc_struct, 1); - rv->me_pointer = &ghid_hid; - rv->colorname = g_strdup(Settings.BackgroundColor); - return rv; + rv = g_new0(hid_gc_struct, 1); + rv->me_pointer = &ghid_hid; + rv->colorname = g_strdup(Settings.BackgroundColor); + return rv; } -static void -set_clip (render_priv *priv, GdkGC *gc) +static void set_clip(render_priv * priv, GdkGC * gc) { - if (gc == NULL) - return; + if (gc == NULL) + return; - if (priv->clip) - gdk_gc_set_clip_rectangle (gc, &priv->clip_rect); - else - gdk_gc_set_clip_mask (gc, NULL); + if (priv->clip) + gdk_gc_set_clip_rectangle(gc, &priv->clip_rect); + else + gdk_gc_set_clip_mask(gc, NULL); } -static void -ghid_draw_grid (void) +static void ghid_draw_grid(void) { - static GdkPoint *points = 0; - static int npoints = 0; - Coord x1, y1, x2, y2, x, y; - int n, i; - render_priv *priv = gport->render_priv; + static GdkPoint *points = 0; + static int npoints = 0; + Coord x1, y1, x2, y2, x, y; + int n, i; + render_priv *priv = gport->render_priv; - if (!Settings.DrawGrid) - return; - if (Vz (PCB->Grid) < MIN_GRID_DISTANCE) - return; - if (!priv->grid_gc) - { - if (gdk_color_parse (Settings.GridColor, &gport->grid_color)) - { - gport->grid_color.red ^= gport->bg_color.red; - gport->grid_color.green ^= gport->bg_color.green; - gport->grid_color.blue ^= gport->bg_color.blue; - gdk_color_alloc (gport->colormap, &gport->grid_color); + if (!Settings.DrawGrid) + return; + if (Vz(PCB->Grid) < MIN_GRID_DISTANCE) + return; + if (!priv->grid_gc) { + if (gdk_color_parse(Settings.GridColor, &gport->grid_color)) { + gport->grid_color.red ^= gport->bg_color.red; + gport->grid_color.green ^= gport->bg_color.green; + gport->grid_color.blue ^= gport->bg_color.blue; + gdk_color_alloc(gport->colormap, &gport->grid_color); + } + priv->grid_gc = gdk_gc_new(gport->drawable); + gdk_gc_set_function(priv->grid_gc, GDK_XOR); + gdk_gc_set_foreground(priv->grid_gc, &gport->grid_color); + gdk_gc_set_clip_origin(priv->grid_gc, 0, 0); + set_clip(priv, priv->grid_gc); } - priv->grid_gc = gdk_gc_new (gport->drawable); - gdk_gc_set_function (priv->grid_gc, GDK_XOR); - gdk_gc_set_foreground (priv->grid_gc, &gport->grid_color); - gdk_gc_set_clip_origin (priv->grid_gc, 0, 0); - set_clip (priv, priv->grid_gc); - } - x1 = GridFit (SIDE_X (gport->view.x0), PCB->Grid, PCB->GridOffsetX); - y1 = GridFit (SIDE_Y (gport->view.y0), PCB->Grid, PCB->GridOffsetY); - x2 = GridFit (SIDE_X (gport->view.x0 + gport->view.width - 1), - PCB->Grid, PCB->GridOffsetX); - y2 = GridFit (SIDE_Y (gport->view.y0 + gport->view.height - 1), - PCB->Grid, PCB->GridOffsetY); - if (x1 > x2) - { - Coord tmp = x1; - x1 = x2; - x2 = tmp; - } - if (y1 > y2) - { - Coord tmp = y1; - y1 = y2; - y2 = tmp; - } - if (Vx (x1) < 0) - x1 += PCB->Grid; - if (Vy (y1) < 0) - y1 += PCB->Grid; - if (Vx (x2) >= gport->width) - x2 -= PCB->Grid; - if (Vy (y2) >= gport->height) - y2 -= PCB->Grid; - n = (x2 - x1) / PCB->Grid + 1; - if (n > npoints) - { - npoints = n + 10; - points = (GdkPoint *)realloc (points, npoints * sizeof (GdkPoint)); - } - n = 0; - for (x = x1; x <= x2; x += PCB->Grid) - { - points[n].x = Vx (x); - n++; - } - if (n == 0) - return; - for (y = y1; y <= y2; y += PCB->Grid) - { - for (i = 0; i < n; i++) - points[i].y = Vy (y); - gdk_draw_points (gport->drawable, priv->grid_gc, points, n); - } + x1 = GridFit(SIDE_X(gport->view.x0), PCB->Grid, PCB->GridOffsetX); + y1 = GridFit(SIDE_Y(gport->view.y0), PCB->Grid, PCB->GridOffsetY); + x2 = GridFit(SIDE_X(gport->view.x0 + gport->view.width - 1), PCB->Grid, PCB->GridOffsetX); + y2 = GridFit(SIDE_Y(gport->view.y0 + gport->view.height - 1), PCB->Grid, PCB->GridOffsetY); + if (x1 > x2) { + Coord tmp = x1; + x1 = x2; + x2 = tmp; + } + if (y1 > y2) { + Coord tmp = y1; + y1 = y2; + y2 = tmp; + } + if (Vx(x1) < 0) + x1 += PCB->Grid; + if (Vy(y1) < 0) + y1 += PCB->Grid; + if (Vx(x2) >= gport->width) + x2 -= PCB->Grid; + if (Vy(y2) >= gport->height) + y2 -= PCB->Grid; + n = (x2 - x1) / PCB->Grid + 1; + if (n > npoints) { + npoints = n + 10; + points = (GdkPoint *) realloc(points, npoints * sizeof(GdkPoint)); + } + n = 0; + for (x = x1; x <= x2; x += PCB->Grid) { + points[n].x = Vx(x); + n++; + } + if (n == 0) + return; + for (y = y1; y <= y2; y += PCB->Grid) { + for (i = 0; i < n; i++) + points[i].y = Vy(y); + gdk_draw_points(gport->drawable, priv->grid_gc, points, n); + } } /* ------------------------------------------------------------ */ -static void -ghid_draw_bg_image (void) +static void ghid_draw_bg_image(void) { - static GdkPixbuf *pixbuf; - GdkInterpType interp_type; - gint x, y, w, h, w_src, h_src; - static gint w_scaled, h_scaled; - render_priv *priv = gport->render_priv; + static GdkPixbuf *pixbuf; + GdkInterpType interp_type; + gint x, y, w, h, w_src, h_src; + static gint w_scaled, h_scaled; + render_priv *priv = gport->render_priv; - if (!ghidgui->bg_pixbuf) - return; + if (!ghidgui->bg_pixbuf) + return; - w = PCB->MaxWidth / gport->view.coord_per_px; - h = PCB->MaxHeight / gport->view.coord_per_px; - x = gport->view.x0 / gport->view.coord_per_px; - y = gport->view.y0 / gport->view.coord_per_px; + w = PCB->MaxWidth / gport->view.coord_per_px; + h = PCB->MaxHeight / gport->view.coord_per_px; + x = gport->view.x0 / gport->view.coord_per_px; + y = gport->view.y0 / gport->view.coord_per_px; - if (w_scaled != w || h_scaled != h) - { - if (pixbuf) - g_object_unref (G_OBJECT (pixbuf)); + if (w_scaled != w || h_scaled != h) { + if (pixbuf) + g_object_unref(G_OBJECT(pixbuf)); - w_src = gdk_pixbuf_get_width (ghidgui->bg_pixbuf); - h_src = gdk_pixbuf_get_height (ghidgui->bg_pixbuf); - if (w > w_src && h > h_src) - interp_type = GDK_INTERP_NEAREST; - else - interp_type = GDK_INTERP_BILINEAR; + w_src = gdk_pixbuf_get_width(ghidgui->bg_pixbuf); + h_src = gdk_pixbuf_get_height(ghidgui->bg_pixbuf); + if (w > w_src && h > h_src) + interp_type = GDK_INTERP_NEAREST; + else + interp_type = GDK_INTERP_BILINEAR; - pixbuf = - gdk_pixbuf_scale_simple (ghidgui->bg_pixbuf, w, h, interp_type); - w_scaled = w; - h_scaled = h; - } - if (pixbuf) - gdk_pixbuf_render_to_drawable (pixbuf, gport->drawable, priv->bg_gc, - x, y, 0, 0, - w - x, h - y, GDK_RGB_DITHER_NORMAL, 0, 0); + pixbuf = gdk_pixbuf_scale_simple(ghidgui->bg_pixbuf, w, h, interp_type); + w_scaled = w; + h_scaled = h; + } + if (pixbuf) + gdk_pixbuf_render_to_drawable(pixbuf, gport->drawable, priv->bg_gc, x, y, 0, 0, w - x, h - y, GDK_RGB_DITHER_NORMAL, 0, 0); } #define WHICH_GC(gc) (cur_mask == HID_MASK_CLEAR ? priv->mask_gc : (gc)->gc) -void -ghid_use_mask (int use_it) +void ghid_use_mask(int use_it) { - static int mask_seq_id = 0; - GdkColor color; - render_priv *priv = gport->render_priv; + static int mask_seq_id = 0; + GdkColor color; + render_priv *priv = gport->render_priv; - if (!gport->pixmap) - return; - if (use_it == cur_mask) - return; - switch (use_it) - { - case HID_MASK_OFF: - gport->drawable = gport->pixmap; - mask_seq = 0; - break; + if (!gport->pixmap) + return; + if (use_it == cur_mask) + return; + switch (use_it) { + case HID_MASK_OFF: + gport->drawable = gport->pixmap; + mask_seq = 0; + break; - case HID_MASK_BEFORE: - /* The HID asks not to receive this mask type, so warn if we get it */ - g_return_if_reached (); + case HID_MASK_BEFORE: + /* The HID asks not to receive this mask type, so warn if we get it */ + g_return_if_reached(); - case HID_MASK_CLEAR: - if (!gport->mask) - gport->mask = gdk_pixmap_new (0, gport->width, gport->height, 1); - gport->drawable = gport->mask; - mask_seq = 0; - if (!priv->mask_gc) - { - priv->mask_gc = gdk_gc_new (gport->drawable); - gdk_gc_set_clip_origin (priv->mask_gc, 0, 0); - set_clip (priv, priv->mask_gc); - } - color.pixel = 1; - gdk_gc_set_foreground (priv->mask_gc, &color); - gdk_draw_rectangle (gport->drawable, priv->mask_gc, TRUE, 0, 0, - gport->width, gport->height); - color.pixel = 0; - gdk_gc_set_foreground (priv->mask_gc, &color); - break; + case HID_MASK_CLEAR: + if (!gport->mask) + gport->mask = gdk_pixmap_new(0, gport->width, gport->height, 1); + gport->drawable = gport->mask; + mask_seq = 0; + if (!priv->mask_gc) { + priv->mask_gc = gdk_gc_new(gport->drawable); + gdk_gc_set_clip_origin(priv->mask_gc, 0, 0); + set_clip(priv, priv->mask_gc); + } + color.pixel = 1; + gdk_gc_set_foreground(priv->mask_gc, &color); + gdk_draw_rectangle(gport->drawable, priv->mask_gc, TRUE, 0, 0, gport->width, gport->height); + color.pixel = 0; + gdk_gc_set_foreground(priv->mask_gc, &color); + break; - case HID_MASK_AFTER: - mask_seq_id++; - if (!mask_seq_id) - mask_seq_id = 1; - mask_seq = mask_seq_id; + case HID_MASK_AFTER: + mask_seq_id++; + if (!mask_seq_id) + mask_seq_id = 1; + mask_seq = mask_seq_id; - gport->drawable = gport->pixmap; - break; + gport->drawable = gport->pixmap; + break; - } - cur_mask = use_it; + } + cur_mask = use_it; } -typedef struct -{ - int color_set; - GdkColor color; - int xor_set; - GdkColor xor_color; +typedef struct { + int color_set; + GdkColor color; + int xor_set; + GdkColor xor_color; } ColorCache; - /* Config helper functions for when the user changes color preferences. - | set_special colors used in the gtkhid. - */ -static void -set_special_grid_color (void) + /* Config helper functions for when the user changes color preferences. + | set_special colors used in the gtkhid. + */ +static void set_special_grid_color(void) { - render_priv *priv = gport->render_priv; + render_priv *priv = gport->render_priv; - if (!gport->colormap) - return; - gport->grid_color.red ^= gport->bg_color.red; - gport->grid_color.green ^= gport->bg_color.green; - gport->grid_color.blue ^= gport->bg_color.blue; - gdk_color_alloc (gport->colormap, &gport->grid_color); - if (priv->grid_gc) - gdk_gc_set_foreground (priv->grid_gc, &gport->grid_color); + if (!gport->colormap) + return; + gport->grid_color.red ^= gport->bg_color.red; + gport->grid_color.green ^= gport->bg_color.green; + gport->grid_color.blue ^= gport->bg_color.blue; + gdk_color_alloc(gport->colormap, &gport->grid_color); + if (priv->grid_gc) + gdk_gc_set_foreground(priv->grid_gc, &gport->grid_color); } -void -ghid_set_special_colors (HID_Attribute * ha) +void ghid_set_special_colors(HID_Attribute * ha) { - render_priv *priv = gport->render_priv; + render_priv *priv = gport->render_priv; - if (!ha->name || !ha->value) - return; - if (!strcmp (ha->name, "background-color") && priv->bg_gc) - { - ghid_map_color_string (*(char **) ha->value, &gport->bg_color); - gdk_gc_set_foreground (priv->bg_gc, &gport->bg_color); - set_special_grid_color (); - } - else if (!strcmp (ha->name, "off-limit-color") && priv->offlimits_gc) - { - ghid_map_color_string (*(char **) ha->value, &gport->offlimits_color); - gdk_gc_set_foreground (priv->offlimits_gc, &gport->offlimits_color); - } - else if (!strcmp (ha->name, "grid-color") && priv->grid_gc) - { - ghid_map_color_string (*(char **) ha->value, &gport->grid_color); - set_special_grid_color (); - } + if (!ha->name || !ha->value) + return; + if (!strcmp(ha->name, "background-color") && priv->bg_gc) { + ghid_map_color_string(*(char **) ha->value, &gport->bg_color); + gdk_gc_set_foreground(priv->bg_gc, &gport->bg_color); + set_special_grid_color(); + } + else if (!strcmp(ha->name, "off-limit-color") && priv->offlimits_gc) { + ghid_map_color_string(*(char **) ha->value, &gport->offlimits_color); + gdk_gc_set_foreground(priv->offlimits_gc, &gport->offlimits_color); + } + else if (!strcmp(ha->name, "grid-color") && priv->grid_gc) { + ghid_map_color_string(*(char **) ha->value, &gport->grid_color); + set_special_grid_color(); + } } -void -ghid_set_color (hidGC gc, const char *name) +void ghid_set_color(hidGC gc, const char *name) { - static void *cache = 0; - hidval cval; + static void *cache = 0; + hidval cval; - if (name == NULL) - { - fprintf (stderr, "%s(): name = NULL, setting to magenta\n", - __FUNCTION__); - name = "magenta"; - } + if (name == NULL) { + fprintf(stderr, "%s(): name = NULL, setting to magenta\n", __FUNCTION__); + name = "magenta"; + } - if (name != gc->colorname) - { - if (gc->colorname != NULL) - g_free(gc->colorname); - gc->colorname = g_strdup(name); - } + if (name != gc->colorname) { + if (gc->colorname != NULL) + g_free(gc->colorname); + gc->colorname = g_strdup(name); + } - if (!gc->gc) - return; - if (gport->colormap == 0) - gport->colormap = gtk_widget_get_colormap (gport->top_window); + if (!gc->gc) + return; + if (gport->colormap == 0) + gport->colormap = gtk_widget_get_colormap(gport->top_window); - if (strcmp (name, "erase") == 0) - { - gdk_gc_set_foreground (gc->gc, &gport->bg_color); - } - else if (strcmp (name, "drill") == 0) - { - gdk_gc_set_foreground (gc->gc, &gport->offlimits_color); - } - else - { - ColorCache *cc; - if (hid_cache_color (0, name, &cval, &cache)) - cc = (ColorCache *) cval.ptr; - else - { - cc = (ColorCache *) malloc (sizeof (ColorCache)); - memset (cc, 0, sizeof (*cc)); - cval.ptr = cc; - hid_cache_color (1, name, &cval, &cache); + if (strcmp(name, "erase") == 0) { + gdk_gc_set_foreground(gc->gc, &gport->bg_color); } + else if (strcmp(name, "drill") == 0) { + gdk_gc_set_foreground(gc->gc, &gport->offlimits_color); + } + else { + ColorCache *cc; + if (hid_cache_color(0, name, &cval, &cache)) + cc = (ColorCache *) cval.ptr; + else { + cc = (ColorCache *) malloc(sizeof(ColorCache)); + memset(cc, 0, sizeof(*cc)); + cval.ptr = cc; + hid_cache_color(1, name, &cval, &cache); + } - if (!cc->color_set) - { - if (gdk_color_parse (name, &cc->color)) - gdk_color_alloc (gport->colormap, &cc->color); - else - gdk_color_white (gport->colormap, &cc->color); - cc->color_set = 1; + if (!cc->color_set) { + if (gdk_color_parse(name, &cc->color)) + gdk_color_alloc(gport->colormap, &cc->color); + else + gdk_color_white(gport->colormap, &cc->color); + cc->color_set = 1; + } + if (gc->xor_mask) { + if (!cc->xor_set) { + cc->xor_color.red = cc->color.red ^ gport->bg_color.red; + cc->xor_color.green = cc->color.green ^ gport->bg_color.green; + cc->xor_color.blue = cc->color.blue ^ gport->bg_color.blue; + gdk_color_alloc(gport->colormap, &cc->xor_color); + cc->xor_set = 1; + } + gdk_gc_set_foreground(gc->gc, &cc->xor_color); + } + else { + gdk_gc_set_foreground(gc->gc, &cc->color); + } } - if (gc->xor_mask) - { - if (!cc->xor_set) - { - cc->xor_color.red = cc->color.red ^ gport->bg_color.red; - cc->xor_color.green = cc->color.green ^ gport->bg_color.green; - cc->xor_color.blue = cc->color.blue ^ gport->bg_color.blue; - gdk_color_alloc (gport->colormap, &cc->xor_color); - cc->xor_set = 1; - } - gdk_gc_set_foreground (gc->gc, &cc->xor_color); - } - else - { - gdk_gc_set_foreground (gc->gc, &cc->color); - } - } } -void -ghid_set_line_cap (hidGC gc, EndCapStyle style) +void ghid_set_line_cap(hidGC gc, EndCapStyle style) { - render_priv *priv = gport->render_priv; + render_priv *priv = gport->render_priv; - switch (style) - { - case Trace_Cap: - case Round_Cap: - gc->cap = GDK_CAP_ROUND; - gc->join = GDK_JOIN_ROUND; - break; - case Square_Cap: - case Beveled_Cap: - gc->cap = GDK_CAP_PROJECTING; - gc->join = GDK_JOIN_MITER; - break; - } - if (gc->gc) - gdk_gc_set_line_attributes (WHICH_GC (gc), - Vz (gc->width), GDK_LINE_SOLID, - (GdkCapStyle)gc->cap, (GdkJoinStyle)gc->join); + switch (style) { + case Trace_Cap: + case Round_Cap: + gc->cap = GDK_CAP_ROUND; + gc->join = GDK_JOIN_ROUND; + break; + case Square_Cap: + case Beveled_Cap: + gc->cap = GDK_CAP_PROJECTING; + gc->join = GDK_JOIN_MITER; + break; + } + if (gc->gc) + gdk_gc_set_line_attributes(WHICH_GC(gc), Vz(gc->width), GDK_LINE_SOLID, (GdkCapStyle) gc->cap, (GdkJoinStyle) gc->join); } -void -ghid_set_line_width (hidGC gc, Coord width) +void ghid_set_line_width(hidGC gc, Coord width) { - render_priv *priv = gport->render_priv; + render_priv *priv = gport->render_priv; - gc->width = width; - if (gc->gc) - gdk_gc_set_line_attributes (WHICH_GC (gc), - Vz (gc->width), GDK_LINE_SOLID, - (GdkCapStyle)gc->cap, (GdkJoinStyle)gc->join); + gc->width = width; + if (gc->gc) + gdk_gc_set_line_attributes(WHICH_GC(gc), Vz(gc->width), GDK_LINE_SOLID, (GdkCapStyle) gc->cap, (GdkJoinStyle) gc->join); } -void -ghid_set_draw_xor (hidGC gc, int xor_mask) +void ghid_set_draw_xor(hidGC gc, int xor_mask) { - gc->xor_mask = xor_mask; - if (!gc->gc) - return; - gdk_gc_set_function (gc->gc, xor_mask ? GDK_XOR : GDK_COPY); - ghid_set_color (gc, gc->colorname); + gc->xor_mask = xor_mask; + if (!gc->gc) + return; + gdk_gc_set_function(gc->gc, xor_mask ? GDK_XOR : GDK_COPY); + ghid_set_color(gc, gc->colorname); } -static int -use_gc (hidGC gc) +static int use_gc(hidGC gc) { - render_priv *priv = gport->render_priv; - GdkWindow *window = gtk_widget_get_window (gport->top_window); + render_priv *priv = gport->render_priv; + GdkWindow *window = gtk_widget_get_window(gport->top_window); - if (gc->me_pointer != &ghid_hid) - { - fprintf (stderr, "Fatal: GC from another HID passed to GTK HID\n"); - abort (); - } + if (gc->me_pointer != &ghid_hid) { + fprintf(stderr, "Fatal: GC from another HID passed to GTK HID\n"); + abort(); + } - if (!gport->pixmap) - return 0; - if (!gc->gc) - { - gc->gc = gdk_gc_new (window); - ghid_set_color (gc, gc->colorname); - ghid_set_line_width (gc, gc->width); - ghid_set_line_cap (gc, (EndCapStyle)gc->cap); - ghid_set_draw_xor (gc, gc->xor_mask); - gdk_gc_set_clip_origin (gc->gc, 0, 0); - } - if (gc->mask_seq != mask_seq) - { - if (mask_seq) - gdk_gc_set_clip_mask (gc->gc, gport->mask); - else - set_clip (priv, gc->gc); - gc->mask_seq = mask_seq; - } - priv->u_gc = WHICH_GC (gc); - return 1; + if (!gport->pixmap) + return 0; + if (!gc->gc) { + gc->gc = gdk_gc_new(window); + ghid_set_color(gc, gc->colorname); + ghid_set_line_width(gc, gc->width); + ghid_set_line_cap(gc, (EndCapStyle) gc->cap); + ghid_set_draw_xor(gc, gc->xor_mask); + gdk_gc_set_clip_origin(gc->gc, 0, 0); + } + if (gc->mask_seq != mask_seq) { + if (mask_seq) + gdk_gc_set_clip_mask(gc->gc, gport->mask); + else + set_clip(priv, gc->gc); + gc->mask_seq = mask_seq; + } + priv->u_gc = WHICH_GC(gc); + return 1; } -void -ghid_draw_line (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) +void ghid_draw_line(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) { - double dx1, dy1, dx2, dy2; - render_priv *priv = gport->render_priv; + double dx1, dy1, dx2, dy2; + render_priv *priv = gport->render_priv; - dx1 = Vx ((double) x1); - dy1 = Vy ((double) y1); - dx2 = Vx ((double) x2); - dy2 = Vy ((double) y2); + dx1 = Vx((double) x1); + dy1 = Vy((double) y1); + dx2 = Vx((double) x2); + dy2 = Vy((double) y2); - if (!ClipLine (0, 0, gport->width, gport->height, - &dx1, &dy1, &dx2, &dy2, gc->width / gport->view.coord_per_px)) - return; + if (!ClipLine(0, 0, gport->width, gport->height, &dx1, &dy1, &dx2, &dy2, gc->width / gport->view.coord_per_px)) + return; - USE_GC (gc); - gdk_draw_line (gport->drawable, priv->u_gc, dx1, dy1, dx2, dy2); + USE_GC(gc); + gdk_draw_line(gport->drawable, priv->u_gc, dx1, dy1, dx2, dy2); } -void -ghid_draw_arc (hidGC gc, Coord cx, Coord cy, - Coord xradius, Coord yradius, Angle start_angle, Angle delta_angle) +void ghid_draw_arc(hidGC gc, Coord cx, Coord cy, Coord xradius, Coord yradius, Angle start_angle, Angle delta_angle) { - gint vrx, vry; - gint w, h, radius; - render_priv *priv = gport->render_priv; + gint vrx, vry; + gint w, h, radius; + render_priv *priv = gport->render_priv; - w = gport->width * gport->view.coord_per_px; - h = gport->height * gport->view.coord_per_px; - radius = (xradius > yradius) ? xradius : yradius; - if (SIDE_X (cx) < gport->view.x0 - radius - || SIDE_X (cx) > gport->view.x0 + w + radius - || SIDE_Y (cy) < gport->view.y0 - radius - || SIDE_Y (cy) > gport->view.y0 + h + radius) - return; + w = gport->width * gport->view.coord_per_px; + h = gport->height * gport->view.coord_per_px; + radius = (xradius > yradius) ? xradius : yradius; + if (SIDE_X(cx) < gport->view.x0 - radius + || SIDE_X(cx) > gport->view.x0 + w + radius + || SIDE_Y(cy) < gport->view.y0 - radius || SIDE_Y(cy) > gport->view.y0 + h + radius) + return; - USE_GC (gc); - vrx = Vz (xradius); - vry = Vz (yradius); + USE_GC(gc); + vrx = Vz(xradius); + vry = Vz(yradius); - if (gport->view.flip_x) - { - start_angle = 180 - start_angle; - delta_angle = -delta_angle; - } - if (gport->view.flip_y) - { - start_angle = -start_angle; - delta_angle = -delta_angle; - } - /* make sure we fall in the -180 to +180 range */ - start_angle = NormalizeAngle (start_angle); - if (start_angle >= 180) start_angle -= 360; + if (gport->view.flip_x) { + start_angle = 180 - start_angle; + delta_angle = -delta_angle; + } + if (gport->view.flip_y) { + start_angle = -start_angle; + delta_angle = -delta_angle; + } + /* make sure we fall in the -180 to +180 range */ + start_angle = NormalizeAngle(start_angle); + if (start_angle >= 180) + start_angle -= 360; - gdk_draw_arc (gport->drawable, priv->u_gc, 0, - Vx (cx) - vrx, Vy (cy) - vry, - vrx * 2, vry * 2, (start_angle + 180) * 64, delta_angle * 64); + gdk_draw_arc(gport->drawable, priv->u_gc, 0, + Vx(cx) - vrx, Vy(cy) - vry, vrx * 2, vry * 2, (start_angle + 180) * 64, delta_angle * 64); } -void -ghid_draw_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) +void ghid_draw_rect(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) { - gint w, h, lw; - render_priv *priv = gport->render_priv; + gint w, h, lw; + render_priv *priv = gport->render_priv; - lw = gc->width; - w = gport->width * gport->view.coord_per_px; - h = gport->height * gport->view.coord_per_px; + lw = gc->width; + w = gport->width * gport->view.coord_per_px; + h = gport->height * gport->view.coord_per_px; - if ((SIDE_X (x1) < gport->view.x0 - lw - && SIDE_X (x2) < gport->view.x0 - lw) - || (SIDE_X (x1) > gport->view.x0 + w + lw - && SIDE_X (x2) > gport->view.x0 + w + lw) - || (SIDE_Y (y1) < gport->view.y0 - lw - && SIDE_Y (y2) < gport->view.y0 - lw) - || (SIDE_Y (y1) > gport->view.y0 + h + lw - && SIDE_Y (y2) > gport->view.y0 + h + lw)) - return; + if ((SIDE_X(x1) < gport->view.x0 - lw && SIDE_X(x2) < gport->view.x0 - lw) + || (SIDE_X(x1) > gport->view.x0 + w + lw && SIDE_X(x2) > gport->view.x0 + w + lw) + || (SIDE_Y(y1) < gport->view.y0 - lw && SIDE_Y(y2) < gport->view.y0 - lw) + || (SIDE_Y(y1) > gport->view.y0 + h + lw && SIDE_Y(y2) > gport->view.y0 + h + lw)) + return; - x1 = Vx (x1); - y1 = Vy (y1); - x2 = Vx (x2); - y2 = Vy (y2); + x1 = Vx(x1); + y1 = Vy(y1); + x2 = Vx(x2); + y2 = Vy(y2); - if (x1 > x2) - { - gint xt = x1; - x1 = x2; - x2 = xt; - } - if (y1 > y2) - { - gint yt = y1; - y1 = y2; - y2 = yt; - } + if (x1 > x2) { + gint xt = x1; + x1 = x2; + x2 = xt; + } + if (y1 > y2) { + gint yt = y1; + y1 = y2; + y2 = yt; + } - USE_GC (gc); - gdk_draw_rectangle (gport->drawable, priv->u_gc, FALSE, - x1, y1, x2 - x1 + 1, y2 - y1 + 1); + USE_GC(gc); + gdk_draw_rectangle(gport->drawable, priv->u_gc, FALSE, x1, y1, x2 - x1 + 1, y2 - y1 + 1); } -void -ghid_fill_circle (hidGC gc, Coord cx, Coord cy, Coord radius) +void ghid_fill_circle(hidGC gc, Coord cx, Coord cy, Coord radius) { - gint w, h, vr; - render_priv *priv = gport->render_priv; + gint w, h, vr; + render_priv *priv = gport->render_priv; - w = gport->width * gport->view.coord_per_px; - h = gport->height * gport->view.coord_per_px; - if (SIDE_X (cx) < gport->view.x0 - radius - || SIDE_X (cx) > gport->view.x0 + w + radius - || SIDE_Y (cy) < gport->view.y0 - radius - || SIDE_Y (cy) > gport->view.y0 + h + radius) - return; + w = gport->width * gport->view.coord_per_px; + h = gport->height * gport->view.coord_per_px; + if (SIDE_X(cx) < gport->view.x0 - radius + || SIDE_X(cx) > gport->view.x0 + w + radius + || SIDE_Y(cy) < gport->view.y0 - radius || SIDE_Y(cy) > gport->view.y0 + h + radius) + return; - USE_GC (gc); - vr = Vz (radius); - gdk_draw_arc (gport->drawable, priv->u_gc, TRUE, - Vx (cx) - vr, Vy (cy) - vr, vr * 2, vr * 2, 0, 360 * 64); + USE_GC(gc); + vr = Vz(radius); + gdk_draw_arc(gport->drawable, priv->u_gc, TRUE, Vx(cx) - vr, Vy(cy) - vr, vr * 2, vr * 2, 0, 360 * 64); } -void -ghid_fill_polygon (hidGC gc, int n_coords, Coord *x, Coord *y) +void ghid_fill_polygon(hidGC gc, int n_coords, Coord * x, Coord * y) { - static GdkPoint *points = 0; - static int npoints = 0; - int i; - render_priv *priv = gport->render_priv; - USE_GC (gc); + static GdkPoint *points = 0; + static int npoints = 0; + int i; + render_priv *priv = gport->render_priv; + USE_GC(gc); - if (npoints < n_coords) - { - npoints = n_coords + 1; - points = (GdkPoint *)realloc (points, npoints * sizeof (GdkPoint)); - } - for (i = 0; i < n_coords; i++) - { - points[i].x = Vx (x[i]); - points[i].y = Vy (y[i]); - } - gdk_draw_polygon (gport->drawable, priv->u_gc, 1, points, n_coords); + if (npoints < n_coords) { + npoints = n_coords + 1; + points = (GdkPoint *) realloc(points, npoints * sizeof(GdkPoint)); + } + for (i = 0; i < n_coords; i++) { + points[i].x = Vx(x[i]); + points[i].y = Vy(y[i]); + } + gdk_draw_polygon(gport->drawable, priv->u_gc, 1, points, n_coords); } -void -ghid_fill_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) +void ghid_fill_rect(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) { - gint w, h, lw, xx, yy; - render_priv *priv = gport->render_priv; + gint w, h, lw, xx, yy; + render_priv *priv = gport->render_priv; - lw = gc->width; - w = gport->width * gport->view.coord_per_px; - h = gport->height * gport->view.coord_per_px; + lw = gc->width; + w = gport->width * gport->view.coord_per_px; + h = gport->height * gport->view.coord_per_px; - if ((SIDE_X (x1) < gport->view.x0 - lw - && SIDE_X (x2) < gport->view.x0 - lw) - || (SIDE_X (x1) > gport->view.x0 + w + lw - && SIDE_X (x2) > gport->view.x0 + w + lw) - || (SIDE_Y (y1) < gport->view.y0 - lw - && SIDE_Y (y2) < gport->view.y0 - lw) - || (SIDE_Y (y1) > gport->view.y0 + h + lw - && SIDE_Y (y2) > gport->view.y0 + h + lw)) - return; + if ((SIDE_X(x1) < gport->view.x0 - lw && SIDE_X(x2) < gport->view.x0 - lw) + || (SIDE_X(x1) > gport->view.x0 + w + lw && SIDE_X(x2) > gport->view.x0 + w + lw) + || (SIDE_Y(y1) < gport->view.y0 - lw && SIDE_Y(y2) < gport->view.y0 - lw) + || (SIDE_Y(y1) > gport->view.y0 + h + lw && SIDE_Y(y2) > gport->view.y0 + h + lw)) + return; - x1 = Vx (x1); - y1 = Vy (y1); - x2 = Vx (x2); - y2 = Vy (y2); - if (x2 < x1) - { - xx = x1; - x1 = x2; - x2 = xx; - } - if (y2 < y1) - { - yy = y1; - y1 = y2; - y2 = yy; - } - USE_GC (gc); - gdk_draw_rectangle (gport->drawable, priv->u_gc, TRUE, - x1, y1, x2 - x1 + 1, y2 - y1 + 1); + x1 = Vx(x1); + y1 = Vy(y1); + x2 = Vx(x2); + y2 = Vy(y2); + if (x2 < x1) { + xx = x1; + x1 = x2; + x2 = xx; + } + if (y2 < y1) { + yy = y1; + y1 = y2; + y2 = yy; + } + USE_GC(gc); + gdk_draw_rectangle(gport->drawable, priv->u_gc, TRUE, x1, y1, x2 - x1 + 1, y2 - y1 + 1); } -static void -redraw_region (GdkRectangle *rect) +static void redraw_region(GdkRectangle * rect) { - int eleft, eright, etop, ebottom; - BoxType region; - render_priv *priv = gport->render_priv; + int eleft, eright, etop, ebottom; + BoxType region; + render_priv *priv = gport->render_priv; - if (!gport->pixmap) - return; + if (!gport->pixmap) + return; - if (rect != NULL) - { - priv->clip_rect = *rect; - priv->clip = true; - } - else - { - priv->clip_rect.x = 0; - priv->clip_rect.y = 0; - priv->clip_rect.width = gport->width; - priv->clip_rect.height = gport->height; - priv->clip = false; - } + if (rect != NULL) { + priv->clip_rect = *rect; + priv->clip = true; + } + else { + priv->clip_rect.x = 0; + priv->clip_rect.y = 0; + priv->clip_rect.width = gport->width; + priv->clip_rect.height = gport->height; + priv->clip = false; + } - set_clip (priv, priv->bg_gc); - set_clip (priv, priv->offlimits_gc); - set_clip (priv, priv->mask_gc); - set_clip (priv, priv->grid_gc); + set_clip(priv, priv->bg_gc); + set_clip(priv, priv->offlimits_gc); + set_clip(priv, priv->mask_gc); + set_clip(priv, priv->grid_gc); - region.X1 = MIN(Px(priv->clip_rect.x), - Px(priv->clip_rect.x + priv->clip_rect.width + 1)); - region.Y1 = MIN(Py(priv->clip_rect.y), - Py(priv->clip_rect.y + priv->clip_rect.height + 1)); - region.X2 = MAX(Px(priv->clip_rect.x), - Px(priv->clip_rect.x + priv->clip_rect.width + 1)); - region.Y2 = MAX(Py(priv->clip_rect.y), - Py(priv->clip_rect.y + priv->clip_rect.height + 1)); + region.X1 = MIN(Px(priv->clip_rect.x), Px(priv->clip_rect.x + priv->clip_rect.width + 1)); + region.Y1 = MIN(Py(priv->clip_rect.y), Py(priv->clip_rect.y + priv->clip_rect.height + 1)); + region.X2 = MAX(Px(priv->clip_rect.x), Px(priv->clip_rect.x + priv->clip_rect.width + 1)); + region.Y2 = MAX(Py(priv->clip_rect.y), Py(priv->clip_rect.y + priv->clip_rect.height + 1)); - region.X1 = MAX (0, MIN (PCB->MaxWidth, region.X1)); - region.X2 = MAX (0, MIN (PCB->MaxWidth, region.X2)); - region.Y1 = MAX (0, MIN (PCB->MaxHeight, region.Y1)); - region.Y2 = MAX (0, MIN (PCB->MaxHeight, region.Y2)); + region.X1 = MAX(0, MIN(PCB->MaxWidth, region.X1)); + region.X2 = MAX(0, MIN(PCB->MaxWidth, region.X2)); + region.Y1 = MAX(0, MIN(PCB->MaxHeight, region.Y1)); + region.Y2 = MAX(0, MIN(PCB->MaxHeight, region.Y2)); - eleft = Vx (0); - eright = Vx (PCB->MaxWidth); - etop = Vy (0); - ebottom = Vy (PCB->MaxHeight); - if (eleft > eright) - { - int tmp = eleft; - eleft = eright; - eright = tmp; - } - if (etop > ebottom) - { - int tmp = etop; - etop = ebottom; - ebottom = tmp; - } + eleft = Vx(0); + eright = Vx(PCB->MaxWidth); + etop = Vy(0); + ebottom = Vy(PCB->MaxHeight); + if (eleft > eright) { + int tmp = eleft; + eleft = eright; + eright = tmp; + } + if (etop > ebottom) { + int tmp = etop; + etop = ebottom; + ebottom = tmp; + } - if (eleft > 0) - gdk_draw_rectangle (gport->drawable, priv->offlimits_gc, - 1, 0, 0, eleft, gport->height); - else - eleft = 0; - if (eright < gport->width) - gdk_draw_rectangle (gport->drawable, priv->offlimits_gc, - 1, eright, 0, gport->width - eright, gport->height); - else - eright = gport->width; - if (etop > 0) - gdk_draw_rectangle (gport->drawable, priv->offlimits_gc, - 1, eleft, 0, eright - eleft + 1, etop); - else - etop = 0; - if (ebottom < gport->height) - gdk_draw_rectangle (gport->drawable, priv->offlimits_gc, - 1, eleft, ebottom, eright - eleft + 1, - gport->height - ebottom); - else - ebottom = gport->height; + if (eleft > 0) + gdk_draw_rectangle(gport->drawable, priv->offlimits_gc, 1, 0, 0, eleft, gport->height); + else + eleft = 0; + if (eright < gport->width) + gdk_draw_rectangle(gport->drawable, priv->offlimits_gc, 1, eright, 0, gport->width - eright, gport->height); + else + eright = gport->width; + if (etop > 0) + gdk_draw_rectangle(gport->drawable, priv->offlimits_gc, 1, eleft, 0, eright - eleft + 1, etop); + else + etop = 0; + if (ebottom < gport->height) + gdk_draw_rectangle(gport->drawable, priv->offlimits_gc, 1, eleft, ebottom, eright - eleft + 1, gport->height - ebottom); + else + ebottom = gport->height; - gdk_draw_rectangle (gport->drawable, priv->bg_gc, 1, - eleft, etop, eright - eleft + 1, ebottom - etop + 1); + gdk_draw_rectangle(gport->drawable, priv->bg_gc, 1, eleft, etop, eright - eleft + 1, ebottom - etop + 1); - ghid_draw_bg_image(); + ghid_draw_bg_image(); - hid_expose_callback (&ghid_hid, ®ion, 0); - ghid_draw_grid (); + hid_expose_callback(&ghid_hid, ®ion, 0); + ghid_draw_grid(); - /* In some cases we are called with the crosshair still off */ - if (priv->attached_invalidate_depth == 0) - DrawAttached (); + /* In some cases we are called with the crosshair still off */ + if (priv->attached_invalidate_depth == 0) + DrawAttached(); - /* In some cases we are called with the mark still off */ - if (priv->mark_invalidate_depth == 0) - DrawMark (); + /* In some cases we are called with the mark still off */ + if (priv->mark_invalidate_depth == 0) + DrawMark(); - draw_lead_user (priv); + draw_lead_user(priv); - priv->clip = false; + priv->clip = false; - /* Rest the clip for bg_gc, as it is used outside this function */ - gdk_gc_set_clip_mask (priv->bg_gc, NULL); + /* Rest the clip for bg_gc, as it is used outside this function */ + gdk_gc_set_clip_mask(priv->bg_gc, NULL); } -void -ghid_invalidate_lr (int left, int right, int top, int bottom) +void ghid_invalidate_lr(int left, int right, int top, int bottom) { - int dleft, dright, dtop, dbottom; - int minx, maxx, miny, maxy; - GdkRectangle rect; + int dleft, dright, dtop, dbottom; + int minx, maxx, miny, maxy; + GdkRectangle rect; - dleft = Vx (left); - dright = Vx (right); - dtop = Vy (top); - dbottom = Vy (bottom); + dleft = Vx(left); + dright = Vx(right); + dtop = Vy(top); + dbottom = Vy(bottom); - minx = MIN (dleft, dright); - maxx = MAX (dleft, dright); - miny = MIN (dtop, dbottom); - maxy = MAX (dtop, dbottom); + minx = MIN(dleft, dright); + maxx = MAX(dleft, dright); + miny = MIN(dtop, dbottom); + maxy = MAX(dtop, dbottom); - rect.x = minx; - rect.y = miny; - rect.width = maxx - minx; - rect.height = maxy - miny; + rect.x = minx; + rect.y = miny; + rect.width = maxx - minx; + rect.height = maxy - miny; - redraw_region (&rect); - ghid_screen_update (); + redraw_region(&rect); + ghid_screen_update(); } -void -ghid_invalidate_all () +void ghid_invalidate_all() { - redraw_region (NULL); - ghid_screen_update (); + redraw_region(NULL); + ghid_screen_update(); } -void -ghid_notify_crosshair_change (bool changes_complete) +void ghid_notify_crosshair_change(bool changes_complete) { - render_priv *priv = gport->render_priv; + render_priv *priv = gport->render_priv; - /* We sometimes get called before the GUI is up */ - if (gport->drawing_area == NULL) - return; + /* We sometimes get called before the GUI is up */ + if (gport->drawing_area == NULL) + return; - if (changes_complete) - priv->attached_invalidate_depth --; + if (changes_complete) + priv->attached_invalidate_depth--; - if (priv->attached_invalidate_depth < 0) - { - priv->attached_invalidate_depth = 0; - /* A mismatch of changes_complete == false and == true notifications - * is not expected to occur, but we will try to handle it gracefully. - * As we know the crosshair will have been shown already, we must - * repaint the entire view to be sure not to leave an artaefact. - */ - ghid_invalidate_all (); - return; - } + if (priv->attached_invalidate_depth < 0) { + priv->attached_invalidate_depth = 0; + /* A mismatch of changes_complete == false and == true notifications + * is not expected to occur, but we will try to handle it gracefully. + * As we know the crosshair will have been shown already, we must + * repaint the entire view to be sure not to leave an artaefact. + */ + ghid_invalidate_all(); + return; + } - if (priv->attached_invalidate_depth == 0) - DrawAttached (); + if (priv->attached_invalidate_depth == 0) + DrawAttached(); - if (!changes_complete) - { - priv->attached_invalidate_depth ++; - } - else if (gport->drawing_area != NULL) - { - /* Queue a GTK expose when changes are complete */ - ghid_draw_area_update (gport, NULL); - } + if (!changes_complete) { + priv->attached_invalidate_depth++; + } + else if (gport->drawing_area != NULL) { + /* Queue a GTK expose when changes are complete */ + ghid_draw_area_update(gport, NULL); + } } -void -ghid_notify_mark_change (bool changes_complete) +void ghid_notify_mark_change(bool changes_complete) { - render_priv *priv = gport->render_priv; + render_priv *priv = gport->render_priv; - /* We sometimes get called before the GUI is up */ - if (gport->drawing_area == NULL) - return; + /* We sometimes get called before the GUI is up */ + if (gport->drawing_area == NULL) + return; - if (changes_complete) - priv->mark_invalidate_depth --; + if (changes_complete) + priv->mark_invalidate_depth--; - if (priv->mark_invalidate_depth < 0) - { - priv->mark_invalidate_depth = 0; - /* A mismatch of changes_complete == false and == true notifications - * is not expected to occur, but we will try to handle it gracefully. - * As we know the mark will have been shown already, we must - * repaint the entire view to be sure not to leave an artaefact. - */ - ghid_invalidate_all (); - return; - } + if (priv->mark_invalidate_depth < 0) { + priv->mark_invalidate_depth = 0; + /* A mismatch of changes_complete == false and == true notifications + * is not expected to occur, but we will try to handle it gracefully. + * As we know the mark will have been shown already, we must + * repaint the entire view to be sure not to leave an artaefact. + */ + ghid_invalidate_all(); + return; + } - if (priv->mark_invalidate_depth == 0) - DrawMark (); + if (priv->mark_invalidate_depth == 0) + DrawMark(); - if (!changes_complete) - { - priv->mark_invalidate_depth ++; - } - else if (gport->drawing_area != NULL) - { - /* Queue a GTK expose when changes are complete */ - ghid_draw_area_update (gport, NULL); - } + if (!changes_complete) { + priv->mark_invalidate_depth++; + } + else if (gport->drawing_area != NULL) { + /* Queue a GTK expose when changes are complete */ + ghid_draw_area_update(gport, NULL); + } } -static void -draw_right_cross (GdkGC *xor_gc, gint x, gint y) +static void draw_right_cross(GdkGC * xor_gc, gint x, gint y) { - GdkWindow *window = gtk_widget_get_window (gport->drawing_area); + GdkWindow *window = gtk_widget_get_window(gport->drawing_area); - gdk_draw_line (window, xor_gc, x, 0, x, gport->height); - gdk_draw_line (window, xor_gc, 0, y, gport->width, y); + gdk_draw_line(window, xor_gc, x, 0, x, gport->height); + gdk_draw_line(window, xor_gc, 0, y, gport->width, y); } -static void -draw_slanted_cross (GdkGC *xor_gc, gint x, gint y) +static void draw_slanted_cross(GdkGC * xor_gc, gint x, gint y) { - GdkWindow *window = gtk_widget_get_window (gport->drawing_area); - gint x0, y0, x1, y1; + GdkWindow *window = gtk_widget_get_window(gport->drawing_area); + gint x0, y0, x1, y1; - x0 = x + (gport->height - y); - x0 = MAX(0, MIN (x0, gport->width)); - x1 = x - y; - x1 = MAX(0, MIN (x1, gport->width)); - y0 = y + (gport->width - x); - y0 = MAX(0, MIN (y0, gport->height)); - y1 = y - x; - y1 = MAX(0, MIN (y1, gport->height)); - gdk_draw_line (window, xor_gc, x0, y0, x1, y1); + x0 = x + (gport->height - y); + x0 = MAX(0, MIN(x0, gport->width)); + x1 = x - y; + x1 = MAX(0, MIN(x1, gport->width)); + y0 = y + (gport->width - x); + y0 = MAX(0, MIN(y0, gport->height)); + y1 = y - x; + y1 = MAX(0, MIN(y1, gport->height)); + gdk_draw_line(window, xor_gc, x0, y0, x1, y1); - x0 = x - (gport->height - y); - x0 = MAX(0, MIN (x0, gport->width)); - x1 = x + y; - x1 = MAX(0, MIN (x1, gport->width)); - y0 = y + x; - y0 = MAX(0, MIN (y0, gport->height)); - y1 = y - (gport->width - x); - y1 = MAX(0, MIN (y1, gport->height)); - gdk_draw_line (window, xor_gc, x0, y0, x1, y1); + x0 = x - (gport->height - y); + x0 = MAX(0, MIN(x0, gport->width)); + x1 = x + y; + x1 = MAX(0, MIN(x1, gport->width)); + y0 = y + x; + y0 = MAX(0, MIN(y0, gport->height)); + y1 = y - (gport->width - x); + y1 = MAX(0, MIN(y1, gport->height)); + gdk_draw_line(window, xor_gc, x0, y0, x1, y1); } -static void -draw_dozen_cross (GdkGC *xor_gc, gint x, gint y) +static void draw_dozen_cross(GdkGC * xor_gc, gint x, gint y) { - GdkWindow *window = gtk_widget_get_window (gport->drawing_area); - gint x0, y0, x1, y1; - gdouble tan60 = sqrt (3); + GdkWindow *window = gtk_widget_get_window(gport->drawing_area); + gint x0, y0, x1, y1; + gdouble tan60 = sqrt(3); - x0 = x + (gport->height - y) / tan60; - x0 = MAX(0, MIN (x0, gport->width)); - x1 = x - y / tan60; - x1 = MAX(0, MIN (x1, gport->width)); - y0 = y + (gport->width - x) * tan60; - y0 = MAX(0, MIN (y0, gport->height)); - y1 = y - x * tan60; - y1 = MAX(0, MIN (y1, gport->height)); - gdk_draw_line (window, xor_gc, x0, y0, x1, y1); + x0 = x + (gport->height - y) / tan60; + x0 = MAX(0, MIN(x0, gport->width)); + x1 = x - y / tan60; + x1 = MAX(0, MIN(x1, gport->width)); + y0 = y + (gport->width - x) * tan60; + y0 = MAX(0, MIN(y0, gport->height)); + y1 = y - x * tan60; + y1 = MAX(0, MIN(y1, gport->height)); + gdk_draw_line(window, xor_gc, x0, y0, x1, y1); - x0 = x + (gport->height - y) * tan60; - x0 = MAX(0, MIN (x0, gport->width)); - x1 = x - y * tan60; - x1 = MAX(0, MIN (x1, gport->width)); - y0 = y + (gport->width - x) / tan60; - y0 = MAX(0, MIN (y0, gport->height)); - y1 = y - x / tan60; - y1 = MAX(0, MIN (y1, gport->height)); - gdk_draw_line (window, xor_gc, x0, y0, x1, y1); + x0 = x + (gport->height - y) * tan60; + x0 = MAX(0, MIN(x0, gport->width)); + x1 = x - y * tan60; + x1 = MAX(0, MIN(x1, gport->width)); + y0 = y + (gport->width - x) / tan60; + y0 = MAX(0, MIN(y0, gport->height)); + y1 = y - x / tan60; + y1 = MAX(0, MIN(y1, gport->height)); + gdk_draw_line(window, xor_gc, x0, y0, x1, y1); - x0 = x - (gport->height - y) / tan60; - x0 = MAX(0, MIN (x0, gport->width)); - x1 = x + y / tan60; - x1 = MAX(0, MIN (x1, gport->width)); - y0 = y + x * tan60; - y0 = MAX(0, MIN (y0, gport->height)); - y1 = y - (gport->width - x) * tan60; - y1 = MAX(0, MIN (y1, gport->height)); - gdk_draw_line (window, xor_gc, x0, y0, x1, y1); + x0 = x - (gport->height - y) / tan60; + x0 = MAX(0, MIN(x0, gport->width)); + x1 = x + y / tan60; + x1 = MAX(0, MIN(x1, gport->width)); + y0 = y + x * tan60; + y0 = MAX(0, MIN(y0, gport->height)); + y1 = y - (gport->width - x) * tan60; + y1 = MAX(0, MIN(y1, gport->height)); + gdk_draw_line(window, xor_gc, x0, y0, x1, y1); - x0 = x - (gport->height - y) * tan60; - x0 = MAX(0, MIN (x0, gport->width)); - x1 = x + y * tan60; - x1 = MAX(0, MIN (x1, gport->width)); - y0 = y + x / tan60; - y0 = MAX(0, MIN (y0, gport->height)); - y1 = y - (gport->width - x) / tan60; - y1 = MAX(0, MIN (y1, gport->height)); - gdk_draw_line (window, xor_gc, x0, y0, x1, y1); + x0 = x - (gport->height - y) * tan60; + x0 = MAX(0, MIN(x0, gport->width)); + x1 = x + y * tan60; + x1 = MAX(0, MIN(x1, gport->width)); + y0 = y + x / tan60; + y0 = MAX(0, MIN(y0, gport->height)); + y1 = y - (gport->width - x) / tan60; + y1 = MAX(0, MIN(y1, gport->height)); + gdk_draw_line(window, xor_gc, x0, y0, x1, y1); } -static void -draw_crosshair (GdkGC *xor_gc, gint x, gint y) +static void draw_crosshair(GdkGC * xor_gc, gint x, gint y) { - static enum crosshair_shape prev = Basic_Crosshair_Shape; + static enum crosshair_shape prev = Basic_Crosshair_Shape; - draw_right_cross (xor_gc, x, y); - if (prev == Union_Jack_Crosshair_Shape) - draw_slanted_cross (xor_gc, x, y); - if (prev == Dozen_Crosshair_Shape) - draw_dozen_cross (xor_gc, x, y); - prev = Crosshair.shape; + draw_right_cross(xor_gc, x, y); + if (prev == Union_Jack_Crosshair_Shape) + draw_slanted_cross(xor_gc, x, y); + if (prev == Dozen_Crosshair_Shape) + draw_dozen_cross(xor_gc, x, y); + prev = Crosshair.shape; } -static void -show_crosshair (gboolean paint_new_location) +static void show_crosshair(gboolean paint_new_location) { - render_priv *priv = gport->render_priv; - GdkWindow *window = gtk_widget_get_window (gport->drawing_area); - GtkStyle *style = gtk_widget_get_style (gport->drawing_area); - gint x, y; - static gint x_prev = -1, y_prev = -1; - static GdkGC *xor_gc; - static GdkColor cross_color; + render_priv *priv = gport->render_priv; + GdkWindow *window = gtk_widget_get_window(gport->drawing_area); + GtkStyle *style = gtk_widget_get_style(gport->drawing_area); + gint x, y; + static gint x_prev = -1, y_prev = -1; + static GdkGC *xor_gc; + static GdkColor cross_color; - if (gport->crosshair_x < 0 || ghidgui->creating || !gport->has_entered) - return; + if (gport->crosshair_x < 0 || ghidgui->creating || !gport->has_entered) + return; - if (!xor_gc) - { - xor_gc = gdk_gc_new (window); - gdk_gc_copy (xor_gc, style->white_gc); - gdk_gc_set_function (xor_gc, GDK_XOR); - gdk_gc_set_clip_origin (xor_gc, 0, 0); - set_clip (priv, xor_gc); - /* FIXME: when CrossColor changed from config */ - ghid_map_color_string (Settings.CrossColor, &cross_color); - } - x = DRAW_X (gport->crosshair_x); - y = DRAW_Y (gport->crosshair_y); + if (!xor_gc) { + xor_gc = gdk_gc_new(window); + gdk_gc_copy(xor_gc, style->white_gc); + gdk_gc_set_function(xor_gc, GDK_XOR); + gdk_gc_set_clip_origin(xor_gc, 0, 0); + set_clip(priv, xor_gc); + /* FIXME: when CrossColor changed from config */ + ghid_map_color_string(Settings.CrossColor, &cross_color); + } + x = DRAW_X(gport->crosshair_x); + y = DRAW_Y(gport->crosshair_y); - gdk_gc_set_foreground (xor_gc, &cross_color); + gdk_gc_set_foreground(xor_gc, &cross_color); - if (x_prev >= 0 && !paint_new_location) - draw_crosshair (xor_gc, x_prev, y_prev); + if (x_prev >= 0 && !paint_new_location) + draw_crosshair(xor_gc, x_prev, y_prev); - if (x >= 0 && paint_new_location) - { - draw_crosshair (xor_gc, x, y); - x_prev = x; - y_prev = y; - } - else - x_prev = y_prev = -1; + if (x >= 0 && paint_new_location) { + draw_crosshair(xor_gc, x, y); + x_prev = x; + y_prev = y; + } + else + x_prev = y_prev = -1; } -void -ghid_init_renderer (int *argc, char ***argv, GHidPort *port) +void ghid_init_renderer(int *argc, char ***argv, GHidPort * port) { - /* Init any GC's required */ - port->render_priv = g_new0 (render_priv, 1); + /* Init any GC's required */ + port->render_priv = g_new0(render_priv, 1); } -void -ghid_shutdown_renderer (GHidPort *port) +void ghid_shutdown_renderer(GHidPort * port) { - ghid_cancel_lead_user (); - g_free (port->render_priv); - port->render_priv = NULL; + ghid_cancel_lead_user(); + g_free(port->render_priv); + port->render_priv = NULL; } -void -ghid_init_drawing_widget (GtkWidget *widget, GHidPort *port) +void ghid_init_drawing_widget(GtkWidget * widget, GHidPort * port) { } -void -ghid_drawing_area_configure_hook (GHidPort *port) +void ghid_drawing_area_configure_hook(GHidPort * port) { - static int done_once = 0; - render_priv *priv = port->render_priv; + static int done_once = 0; + render_priv *priv = port->render_priv; - if (!done_once) - { - priv->bg_gc = gdk_gc_new (port->drawable); - gdk_gc_set_foreground (priv->bg_gc, &port->bg_color); - gdk_gc_set_clip_origin (priv->bg_gc, 0, 0); + if (!done_once) { + priv->bg_gc = gdk_gc_new(port->drawable); + gdk_gc_set_foreground(priv->bg_gc, &port->bg_color); + gdk_gc_set_clip_origin(priv->bg_gc, 0, 0); - priv->offlimits_gc = gdk_gc_new (port->drawable); - gdk_gc_set_foreground (priv->offlimits_gc, &port->offlimits_color); - gdk_gc_set_clip_origin (priv->offlimits_gc, 0, 0); - done_once = 1; - } + priv->offlimits_gc = gdk_gc_new(port->drawable); + gdk_gc_set_foreground(priv->offlimits_gc, &port->offlimits_color); + gdk_gc_set_clip_origin(priv->offlimits_gc, 0, 0); + done_once = 1; + } - if (port->mask) - { - gdk_pixmap_unref (port->mask); - port->mask = gdk_pixmap_new (0, port->width, port->height, 1); - } + if (port->mask) { + gdk_pixmap_unref(port->mask); + port->mask = gdk_pixmap_new(0, port->width, port->height, 1); + } } -void -ghid_screen_update (void) +void ghid_screen_update(void) { - render_priv *priv = gport->render_priv; - GdkWindow *window = gtk_widget_get_window (gport->drawing_area); + render_priv *priv = gport->render_priv; + GdkWindow *window = gtk_widget_get_window(gport->drawing_area); - if (gport->pixmap == NULL) - return; + if (gport->pixmap == NULL) + return; - gdk_draw_drawable (window, priv->bg_gc, gport->pixmap, - 0, 0, 0, 0, gport->width, gport->height); - show_crosshair (TRUE); + gdk_draw_drawable(window, priv->bg_gc, gport->pixmap, 0, 0, 0, 0, gport->width, gport->height); + show_crosshair(TRUE); } -gboolean -ghid_drawing_area_expose_cb (GtkWidget *widget, - GdkEventExpose *ev, - GHidPort *port) +gboolean ghid_drawing_area_expose_cb(GtkWidget * widget, GdkEventExpose * ev, GHidPort * port) { - render_priv *priv = port->render_priv; - GdkWindow *window = gtk_widget_get_window (gport->drawing_area); + render_priv *priv = port->render_priv; + GdkWindow *window = gtk_widget_get_window(gport->drawing_area); - gdk_draw_drawable (window, priv->bg_gc, port->pixmap, - ev->area.x, ev->area.y, ev->area.x, ev->area.y, - ev->area.width, ev->area.height); - show_crosshair (TRUE); - return FALSE; + gdk_draw_drawable(window, priv->bg_gc, port->pixmap, + ev->area.x, ev->area.y, ev->area.x, ev->area.y, ev->area.width, ev->area.height); + show_crosshair(TRUE); + return FALSE; } -void -ghid_port_drawing_realize_cb (GtkWidget *widget, gpointer data) +void ghid_port_drawing_realize_cb(GtkWidget * widget, gpointer data) { } -gboolean -ghid_pinout_preview_expose (GtkWidget *widget, - GdkEventExpose *ev) +gboolean ghid_pinout_preview_expose(GtkWidget * widget, GdkEventExpose * ev) { - GhidPinoutPreview *pinout = GHID_PINOUT_PREVIEW (widget); - GdkWindow *window = gtk_widget_get_window (widget); - GdkDrawable *save_drawable; - GtkAllocation allocation; - view_data save_view; - int save_width, save_height; - double xz, yz; - render_priv *priv = gport->render_priv; + GhidPinoutPreview *pinout = GHID_PINOUT_PREVIEW(widget); + GdkWindow *window = gtk_widget_get_window(widget); + GdkDrawable *save_drawable; + GtkAllocation allocation; + view_data save_view; + int save_width, save_height; + double xz, yz; + render_priv *priv = gport->render_priv; - /* Setup drawable and zoom factor for drawing routines - */ - save_drawable = gport->drawable; - save_view = gport->view; - save_width = gport->width; - save_height = gport->height; + /* Setup drawable and zoom factor for drawing routines + */ + save_drawable = gport->drawable; + save_view = gport->view; + save_width = gport->width; + save_height = gport->height; - gtk_widget_get_allocation (widget, &allocation); - xz = (double) pinout->x_max / allocation.width; - yz = (double) pinout->y_max / allocation.height; - if (xz > yz) - gport->view.coord_per_px = xz; - else - gport->view.coord_per_px = yz; + gtk_widget_get_allocation(widget, &allocation); + xz = (double) pinout->x_max / allocation.width; + yz = (double) pinout->y_max / allocation.height; + if (xz > yz) + gport->view.coord_per_px = xz; + else + gport->view.coord_per_px = yz; - gport->drawable = window; - gport->width = allocation.width; - gport->height = allocation.height; - gport->view.width = allocation.width * gport->view.coord_per_px; - gport->view.height = allocation.height * gport->view.coord_per_px; - gport->view.x0 = (pinout->x_max - gport->view.width) / 2; - gport->view.y0 = (pinout->y_max - gport->view.height) / 2; + gport->drawable = window; + gport->width = allocation.width; + gport->height = allocation.height; + gport->view.width = allocation.width * gport->view.coord_per_px; + gport->view.height = allocation.height * gport->view.coord_per_px; + gport->view.x0 = (pinout->x_max - gport->view.width) / 2; + gport->view.y0 = (pinout->y_max - gport->view.height) / 2; - /* clear background */ - gdk_draw_rectangle (window, priv->bg_gc, TRUE, - 0, 0, allocation.width, allocation.height); + /* clear background */ + gdk_draw_rectangle(window, priv->bg_gc, TRUE, 0, 0, allocation.width, allocation.height); - /* call the drawing routine */ - hid_expose_callback (&ghid_hid, NULL, &pinout->element); + /* call the drawing routine */ + hid_expose_callback(&ghid_hid, NULL, &pinout->element); - gport->drawable = save_drawable; - gport->view = save_view; - gport->width = save_width; - gport->height = save_height; + gport->drawable = save_drawable; + gport->view = save_view; + gport->width = save_width; + gport->height = save_height; - return FALSE; + return FALSE; } -GdkPixmap * -ghid_render_pixmap (int cx, int cy, double zoom, int width, int height, int depth) +GdkPixmap *ghid_render_pixmap(int cx, int cy, double zoom, int width, int height, int depth) { - GdkPixmap *pixmap; - GdkDrawable *save_drawable; - view_data save_view; - int save_width, save_height; - BoxType region; - render_priv *priv = gport->render_priv; + GdkPixmap *pixmap; + GdkDrawable *save_drawable; + view_data save_view; + int save_width, save_height; + BoxType region; + render_priv *priv = gport->render_priv; - save_drawable = gport->drawable; - save_view = gport->view; - save_width = gport->width; - save_height = gport->height; + save_drawable = gport->drawable; + save_view = gport->view; + save_width = gport->width; + save_height = gport->height; - pixmap = gdk_pixmap_new (NULL, width, height, depth); + pixmap = gdk_pixmap_new(NULL, width, height, depth); - /* Setup drawable and zoom factor for drawing routines - */ + /* Setup drawable and zoom factor for drawing routines + */ - gport->drawable = pixmap; - gport->view.coord_per_px = zoom; - gport->width = width; - gport->height = height; - gport->view.width = width * gport->view.coord_per_px; - gport->view.height = height * gport->view.coord_per_px; - gport->view.x0 = gport->view.flip_x ? PCB->MaxWidth - cx : cx; - gport->view.x0 -= gport->view.height / 2; - gport->view.y0 = gport->view.flip_y ? PCB->MaxHeight - cy : cy; - gport->view.y0 -= gport->view.width / 2; + gport->drawable = pixmap; + gport->view.coord_per_px = zoom; + gport->width = width; + gport->height = height; + gport->view.width = width * gport->view.coord_per_px; + gport->view.height = height * gport->view.coord_per_px; + gport->view.x0 = gport->view.flip_x ? PCB->MaxWidth - cx : cx; + gport->view.x0 -= gport->view.height / 2; + gport->view.y0 = gport->view.flip_y ? PCB->MaxHeight - cy : cy; + gport->view.y0 -= gport->view.width / 2; - /* clear background */ - gdk_draw_rectangle (pixmap, priv->bg_gc, TRUE, 0, 0, width, height); + /* clear background */ + gdk_draw_rectangle(pixmap, priv->bg_gc, TRUE, 0, 0, width, height); - /* call the drawing routine */ - region.X1 = MIN(Px(0), Px(gport->width + 1)); - region.Y1 = MIN(Py(0), Py(gport->height + 1)); - region.X2 = MAX(Px(0), Px(gport->width + 1)); - region.Y2 = MAX(Py(0), Py(gport->height + 1)); + /* call the drawing routine */ + region.X1 = MIN(Px(0), Px(gport->width + 1)); + region.Y1 = MIN(Py(0), Py(gport->height + 1)); + region.X2 = MAX(Px(0), Px(gport->width + 1)); + region.Y2 = MAX(Py(0), Py(gport->height + 1)); - region.X1 = MAX (0, MIN (PCB->MaxWidth, region.X1)); - region.X2 = MAX (0, MIN (PCB->MaxWidth, region.X2)); - region.Y1 = MAX (0, MIN (PCB->MaxHeight, region.Y1)); - region.Y2 = MAX (0, MIN (PCB->MaxHeight, region.Y2)); + region.X1 = MAX(0, MIN(PCB->MaxWidth, region.X1)); + region.X2 = MAX(0, MIN(PCB->MaxWidth, region.X2)); + region.Y1 = MAX(0, MIN(PCB->MaxHeight, region.Y1)); + region.Y2 = MAX(0, MIN(PCB->MaxHeight, region.Y2)); - hid_expose_callback (&ghid_hid, ®ion, NULL); + hid_expose_callback(&ghid_hid, ®ion, NULL); - gport->drawable = save_drawable; - gport->view = save_view; - gport->width = save_width; - gport->height = save_height; + gport->drawable = save_drawable; + gport->view = save_view; + gport->width = save_width; + gport->height = save_height; - return pixmap; + return pixmap; } -HID * -ghid_request_debug_draw (void) +HID *ghid_request_debug_draw(void) { - /* No special setup requirements, drawing goes into - * the backing pixmap. */ - return &ghid_hid; + /* No special setup requirements, drawing goes into + * the backing pixmap. */ + return &ghid_hid; } -void -ghid_flush_debug_draw (void) +void ghid_flush_debug_draw(void) { - ghid_screen_update (); - gdk_flush (); + ghid_screen_update(); + gdk_flush(); } -void -ghid_finish_debug_draw (void) +void ghid_finish_debug_draw(void) { - ghid_flush_debug_draw (); - /* No special tear down requirements - */ + ghid_flush_debug_draw(); + /* No special tear down requirements + */ } -bool -ghid_event_to_pcb_coords (int event_x, int event_y, Coord *pcb_x, Coord *pcb_y) +bool ghid_event_to_pcb_coords(int event_x, int event_y, Coord * pcb_x, Coord * pcb_y) { - *pcb_x = EVENT_TO_PCB_X (event_x); - *pcb_y = EVENT_TO_PCB_Y (event_y); + *pcb_x = EVENT_TO_PCB_X(event_x); + *pcb_y = EVENT_TO_PCB_Y(event_y); - return true; + return true; } -bool -ghid_pcb_to_event_coords (Coord pcb_x, Coord pcb_y, int *event_x, int *event_y) +bool ghid_pcb_to_event_coords(Coord pcb_x, Coord pcb_y, int *event_x, int *event_y) { - *event_x = DRAW_X (pcb_x); - *event_y = DRAW_Y (pcb_y); + *event_x = DRAW_X(pcb_x); + *event_y = DRAW_Y(pcb_y); - return true; + return true; } -#define LEAD_USER_WIDTH 0.2 /* millimeters */ -#define LEAD_USER_PERIOD (1000 / 5) /* 5fps (in ms) */ -#define LEAD_USER_VELOCITY 3. /* millimeters per second */ +#define LEAD_USER_WIDTH 0.2 /* millimeters */ +#define LEAD_USER_PERIOD (1000 / 5) /* 5fps (in ms) */ +#define LEAD_USER_VELOCITY 3. /* millimeters per second */ #define LEAD_USER_ARC_COUNT 3 -#define LEAD_USER_ARC_SEPARATION 3. /* millimeters */ -#define LEAD_USER_INITIAL_RADIUS 10. /* millimetres */ +#define LEAD_USER_ARC_SEPARATION 3. /* millimeters */ +#define LEAD_USER_INITIAL_RADIUS 10. /* millimetres */ #define LEAD_USER_COLOR_R 1. #define LEAD_USER_COLOR_G 1. #define LEAD_USER_COLOR_B 0. -static void -draw_lead_user (render_priv *priv) +static void draw_lead_user(render_priv * priv) { - GdkWindow *window = gtk_widget_get_window (gport->drawing_area); - GtkStyle *style = gtk_widget_get_style (gport->drawing_area); - int i; - Coord radius = priv->lead_user_radius; - Coord width = MM_TO_COORD (LEAD_USER_WIDTH); - Coord separation = MM_TO_COORD (LEAD_USER_ARC_SEPARATION); - static GdkGC *lead_gc = NULL; - GdkColor lead_color; + GdkWindow *window = gtk_widget_get_window(gport->drawing_area); + GtkStyle *style = gtk_widget_get_style(gport->drawing_area); + int i; + Coord radius = priv->lead_user_radius; + Coord width = MM_TO_COORD(LEAD_USER_WIDTH); + Coord separation = MM_TO_COORD(LEAD_USER_ARC_SEPARATION); + static GdkGC *lead_gc = NULL; + GdkColor lead_color; - if (!priv->lead_user) - return; + if (!priv->lead_user) + return; - if (lead_gc == NULL) - { - lead_gc = gdk_gc_new (window); - gdk_gc_copy (lead_gc, style->white_gc); - gdk_gc_set_function (lead_gc, GDK_XOR); - gdk_gc_set_clip_origin (lead_gc, 0, 0); - lead_color.pixel = 0; - lead_color.red = (int)(65535. * LEAD_USER_COLOR_R); - lead_color.green = (int)(65535. * LEAD_USER_COLOR_G); - lead_color.blue = (int)(65535. * LEAD_USER_COLOR_B); - gdk_color_alloc (gport->colormap, &lead_color); - gdk_gc_set_foreground (lead_gc, &lead_color); - } + if (lead_gc == NULL) { + lead_gc = gdk_gc_new(window); + gdk_gc_copy(lead_gc, style->white_gc); + gdk_gc_set_function(lead_gc, GDK_XOR); + gdk_gc_set_clip_origin(lead_gc, 0, 0); + lead_color.pixel = 0; + lead_color.red = (int) (65535. * LEAD_USER_COLOR_R); + lead_color.green = (int) (65535. * LEAD_USER_COLOR_G); + lead_color.blue = (int) (65535. * LEAD_USER_COLOR_B); + gdk_color_alloc(gport->colormap, &lead_color); + gdk_gc_set_foreground(lead_gc, &lead_color); + } - set_clip (priv, lead_gc); - gdk_gc_set_line_attributes (lead_gc, Vz (width), - GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER); + set_clip(priv, lead_gc); + gdk_gc_set_line_attributes(lead_gc, Vz(width), GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER); - /* arcs at the approrpriate radii */ + /* arcs at the approrpriate radii */ - for (i = 0; i < LEAD_USER_ARC_COUNT; i++, radius -= separation) - { - if (radius < width) - radius += MM_TO_COORD (LEAD_USER_INITIAL_RADIUS); + for (i = 0; i < LEAD_USER_ARC_COUNT; i++, radius -= separation) { + if (radius < width) + radius += MM_TO_COORD(LEAD_USER_INITIAL_RADIUS); - /* Draw an arc at radius */ - gdk_draw_arc (gport->drawable, lead_gc, FALSE, - Vx (priv->lead_user_x - radius), - Vy (priv->lead_user_y - radius), - Vz (2. * radius), Vz (2. * radius), - 0, 360 * 64); - } + /* Draw an arc at radius */ + gdk_draw_arc(gport->drawable, lead_gc, FALSE, + Vx(priv->lead_user_x - radius), Vy(priv->lead_user_y - radius), Vz(2. * radius), Vz(2. * radius), 0, 360 * 64); + } } -gboolean -lead_user_cb (gpointer data) +gboolean lead_user_cb(gpointer data) { - render_priv *priv = data; - Coord step; - double elapsed_time; + render_priv *priv = data; + Coord step; + double elapsed_time; - /* Queue a redraw */ - ghid_invalidate_all (); + /* Queue a redraw */ + ghid_invalidate_all(); - /* Update radius */ - elapsed_time = g_timer_elapsed (priv->lead_user_timer, NULL); - g_timer_start (priv->lead_user_timer); + /* Update radius */ + elapsed_time = g_timer_elapsed(priv->lead_user_timer, NULL); + g_timer_start(priv->lead_user_timer); - step = MM_TO_COORD (LEAD_USER_VELOCITY * elapsed_time); - if (priv->lead_user_radius > step) - priv->lead_user_radius -= step; - else - priv->lead_user_radius = MM_TO_COORD (LEAD_USER_INITIAL_RADIUS); + step = MM_TO_COORD(LEAD_USER_VELOCITY * elapsed_time); + if (priv->lead_user_radius > step) + priv->lead_user_radius -= step; + else + priv->lead_user_radius = MM_TO_COORD(LEAD_USER_INITIAL_RADIUS); - return TRUE; + return TRUE; } -void -ghid_lead_user_to_location (Coord x, Coord y) +void ghid_lead_user_to_location(Coord x, Coord y) { - render_priv *priv = gport->render_priv; + render_priv *priv = gport->render_priv; - ghid_cancel_lead_user (); + ghid_cancel_lead_user(); - priv->lead_user = true; - priv->lead_user_x = x; - priv->lead_user_y = y; - priv->lead_user_radius = MM_TO_COORD (LEAD_USER_INITIAL_RADIUS); - priv->lead_user_timeout = g_timeout_add (LEAD_USER_PERIOD, lead_user_cb, priv); - priv->lead_user_timer = g_timer_new (); + priv->lead_user = true; + priv->lead_user_x = x; + priv->lead_user_y = y; + priv->lead_user_radius = MM_TO_COORD(LEAD_USER_INITIAL_RADIUS); + priv->lead_user_timeout = g_timeout_add(LEAD_USER_PERIOD, lead_user_cb, priv); + priv->lead_user_timer = g_timer_new(); } -void -ghid_cancel_lead_user (void) +void ghid_cancel_lead_user(void) { - render_priv *priv = gport->render_priv; + render_priv *priv = gport->render_priv; - if (priv->lead_user_timeout) - g_source_remove (priv->lead_user_timeout); + if (priv->lead_user_timeout) + g_source_remove(priv->lead_user_timeout); - if (priv->lead_user_timer) - g_timer_destroy (priv->lead_user_timer); + if (priv->lead_user_timer) + g_timer_destroy(priv->lead_user_timer); - if (priv->lead_user) - ghid_invalidate_all (); + if (priv->lead_user) + ghid_invalidate_all(); - priv->lead_user_timeout = 0; - priv->lead_user_timer = NULL; - priv->lead_user = false; + priv->lead_user_timeout = 0; + priv->lead_user_timer = NULL; + priv->lead_user = false; } Index: trunk/src/hid/gtk/gtkhid-gl.c =================================================================== --- trunk/src/hid/gtk/gtkhid-gl.c (revision 1021) +++ trunk/src/hid/gtk/gtkhid-gl.c (revision 1022) @@ -18,9 +18,9 @@ #define GL_GLEXT_PROTOTYPES 1 #ifdef HAVE_OPENGL_GL_H -# include +#include #else -# include +#include #endif #include @@ -31,7 +31,7 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); extern HID ghid_hid; @@ -45,934 +45,840 @@ static int cur_mask = -1; typedef struct render_priv { - GdkGLConfig *glconfig; - bool trans_lines; - bool in_context; - int subcomposite_stencil_bit; - char *current_colorname; - double current_alpha_mult; + GdkGLConfig *glconfig; + bool trans_lines; + bool in_context; + int subcomposite_stencil_bit; + char *current_colorname; + double current_alpha_mult; - /* Feature for leading the user to a particular location */ - guint lead_user_timeout; - GTimer *lead_user_timer; - bool lead_user; - Coord lead_user_radius; - Coord lead_user_x; - Coord lead_user_y; + /* Feature for leading the user to a particular location */ + guint lead_user_timeout; + GTimer *lead_user_timer; + bool lead_user; + Coord lead_user_radius; + Coord lead_user_x; + Coord lead_user_y; } render_priv; -typedef struct hid_gc_struct -{ - HID *me_pointer; +typedef struct hid_gc_struct { + HID *me_pointer; - const char *colorname; - double alpha_mult; - Coord width; - gint cap, join; - gchar xor; -} -hid_gc_struct; + const char *colorname; + double alpha_mult; + Coord width; + gint cap, join; + gchar xor; +} hid_gc_struct; -static void draw_lead_user (render_priv *priv); +static void draw_lead_user(render_priv * priv); -static void -start_subcomposite (void) +static void start_subcomposite(void) { - render_priv *priv = gport->render_priv; - int stencil_bit; + render_priv *priv = gport->render_priv; + int stencil_bit; - /* Flush out any existing geoemtry to be rendered */ - hidgl_flush_triangles (&buffer); + /* Flush out any existing geoemtry to be rendered */ + hidgl_flush_triangles(&buffer); - glEnable (GL_STENCIL_TEST); /* Enable Stencil test */ - glStencilOp (GL_KEEP, GL_KEEP, GL_REPLACE); /* Stencil pass => replace stencil value (with 1) */ + glEnable(GL_STENCIL_TEST); /* Enable Stencil test */ + glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); /* Stencil pass => replace stencil value (with 1) */ - stencil_bit = hidgl_assign_clear_stencil_bit(); /* Get a new (clean) bitplane to stencil with */ - glStencilMask (stencil_bit); /* Only write to our subcompositing stencil bitplane */ - glStencilFunc (GL_GREATER, stencil_bit, stencil_bit); /* Pass stencil test if our assigned bit is clear */ + stencil_bit = hidgl_assign_clear_stencil_bit(); /* Get a new (clean) bitplane to stencil with */ + glStencilMask(stencil_bit); /* Only write to our subcompositing stencil bitplane */ + glStencilFunc(GL_GREATER, stencil_bit, stencil_bit); /* Pass stencil test if our assigned bit is clear */ - priv->subcomposite_stencil_bit = stencil_bit; + priv->subcomposite_stencil_bit = stencil_bit; } -static void -end_subcomposite (void) +static void end_subcomposite(void) { - render_priv *priv = gport->render_priv; + render_priv *priv = gport->render_priv; - /* Flush out any existing geoemtry to be rendered */ - hidgl_flush_triangles (&buffer); + /* Flush out any existing geoemtry to be rendered */ + hidgl_flush_triangles(&buffer); - hidgl_return_stencil_bit (priv->subcomposite_stencil_bit); /* Relinquish any bitplane we previously used */ + hidgl_return_stencil_bit(priv->subcomposite_stencil_bit); /* Relinquish any bitplane we previously used */ - glStencilMask (0); - glStencilFunc (GL_ALWAYS, 0, 0); /* Always pass stencil test */ - glDisable (GL_STENCIL_TEST); /* Disable Stencil test */ + glStencilMask(0); + glStencilFunc(GL_ALWAYS, 0, 0); /* Always pass stencil test */ + glDisable(GL_STENCIL_TEST); /* Disable Stencil test */ - priv->subcomposite_stencil_bit = 0; + priv->subcomposite_stencil_bit = 0; } -int -ghid_set_layer (const char *name, int group, int empty) +int ghid_set_layer(const char *name, int group, int empty) { - render_priv *priv = gport->render_priv; - int idx = group; - if (idx >= 0 && idx < max_group) - { - int n = PCB->LayerGroups.Number[group]; - for (idx = 0; idx < n-1; idx ++) - { - int ni = PCB->LayerGroups.Entries[group][idx]; - if (ni >= 0 && ni < max_copper_layer + 2 - && PCB->Data->Layer[ni].On) - break; + render_priv *priv = gport->render_priv; + int idx = group; + if (idx >= 0 && idx < max_group) { + int n = PCB->LayerGroups.Number[group]; + for (idx = 0; idx < n - 1; idx++) { + int ni = PCB->LayerGroups.Entries[group][idx]; + if (ni >= 0 && ni < max_copper_layer + 2 && PCB->Data->Layer[ni].On) + break; + } + idx = PCB->LayerGroups.Entries[group][idx]; } - idx = PCB->LayerGroups.Entries[group][idx]; - } - end_subcomposite (); - start_subcomposite (); + end_subcomposite(); + start_subcomposite(); - if (idx >= 0 && idx < max_copper_layer + 2) - { - priv->trans_lines = true; - return PCB->Data->Layer[idx].On; - } - if (idx < 0) - { - switch (SL_TYPE (idx)) - { - case SL_INVISIBLE: - return PCB->InvisibleObjectsOn; - case SL_MASK: - if (SL_MYSIDE (idx)) - return TEST_FLAG (SHOWMASKFLAG, PCB); - return 0; - case SL_SILK: - priv->trans_lines = true; - if (SL_MYSIDE (idx)) - return PCB->ElementOn; - return 0; - case SL_ASSY: - return 0; - case SL_PDRILL: - case SL_UDRILL: - return 1; - case SL_RATS: - if (PCB->RatOn) - priv->trans_lines = true; - return PCB->RatOn; + if (idx >= 0 && idx < max_copper_layer + 2) { + priv->trans_lines = true; + return PCB->Data->Layer[idx].On; } - } - return 0; + if (idx < 0) { + switch (SL_TYPE(idx)) { + case SL_INVISIBLE: + return PCB->InvisibleObjectsOn; + case SL_MASK: + if (SL_MYSIDE(idx)) + return TEST_FLAG(SHOWMASKFLAG, PCB); + return 0; + case SL_SILK: + priv->trans_lines = true; + if (SL_MYSIDE(idx)) + return PCB->ElementOn; + return 0; + case SL_ASSY: + return 0; + case SL_PDRILL: + case SL_UDRILL: + return 1; + case SL_RATS: + if (PCB->RatOn) + priv->trans_lines = true; + return PCB->RatOn; + } + } + return 0; } -static void -ghid_end_layer (void) +static void ghid_end_layer(void) { - end_subcomposite (); + end_subcomposite(); } -void -ghid_destroy_gc (hidGC gc) +void ghid_destroy_gc(hidGC gc) { - g_free (gc); + g_free(gc); } -hidGC -ghid_make_gc (void) +hidGC ghid_make_gc(void) { - hidGC rv; + hidGC rv; - rv = g_new0 (hid_gc_struct, 1); - rv->me_pointer = &ghid_hid; - rv->colorname = Settings.BackgroundColor; - rv->alpha_mult = 1.0; - return rv; + rv = g_new0(hid_gc_struct, 1); + rv->me_pointer = &ghid_hid; + rv->colorname = Settings.BackgroundColor; + rv->alpha_mult = 1.0; + return rv; } -static void -ghid_draw_grid (BoxTypePtr drawn_area) +static void ghid_draw_grid(BoxTypePtr drawn_area) { - if (Vz (PCB->Grid) < MIN_GRID_DISTANCE) - return; + if (Vz(PCB->Grid) < MIN_GRID_DISTANCE) + return; - if (gdk_color_parse (Settings.GridColor, &gport->grid_color)) - { - gport->grid_color.red ^= gport->bg_color.red; - gport->grid_color.green ^= gport->bg_color.green; - gport->grid_color.blue ^= gport->bg_color.blue; - } + if (gdk_color_parse(Settings.GridColor, &gport->grid_color)) { + gport->grid_color.red ^= gport->bg_color.red; + gport->grid_color.green ^= gport->bg_color.green; + gport->grid_color.blue ^= gport->bg_color.blue; + } - glEnable (GL_COLOR_LOGIC_OP); - glLogicOp (GL_XOR); + glEnable(GL_COLOR_LOGIC_OP); + glLogicOp(GL_XOR); - glColor3f (gport->grid_color.red / 65535., - gport->grid_color.green / 65535., - gport->grid_color.blue / 65535.); + glColor3f(gport->grid_color.red / 65535., gport->grid_color.green / 65535., gport->grid_color.blue / 65535.); - hidgl_draw_grid (drawn_area); + hidgl_draw_grid(drawn_area); - glDisable (GL_COLOR_LOGIC_OP); + glDisable(GL_COLOR_LOGIC_OP); } -static void -ghid_draw_bg_image (void) +static void ghid_draw_bg_image(void) { - static GLuint texture_handle = 0; + static GLuint texture_handle = 0; - if (!ghidgui->bg_pixbuf) - return; + if (!ghidgui->bg_pixbuf) + return; - if (texture_handle == 0) - { - int width = gdk_pixbuf_get_width (ghidgui->bg_pixbuf); - int height = gdk_pixbuf_get_height (ghidgui->bg_pixbuf); - int rowstride = gdk_pixbuf_get_rowstride (ghidgui->bg_pixbuf); - int bits_per_sample = gdk_pixbuf_get_bits_per_sample (ghidgui->bg_pixbuf); - int n_channels = gdk_pixbuf_get_n_channels (ghidgui->bg_pixbuf); - unsigned char *pixels = gdk_pixbuf_get_pixels (ghidgui->bg_pixbuf); + if (texture_handle == 0) { + int width = gdk_pixbuf_get_width(ghidgui->bg_pixbuf); + int height = gdk_pixbuf_get_height(ghidgui->bg_pixbuf); + int rowstride = gdk_pixbuf_get_rowstride(ghidgui->bg_pixbuf); + int bits_per_sample = gdk_pixbuf_get_bits_per_sample(ghidgui->bg_pixbuf); + int n_channels = gdk_pixbuf_get_n_channels(ghidgui->bg_pixbuf); + unsigned char *pixels = gdk_pixbuf_get_pixels(ghidgui->bg_pixbuf); - g_warn_if_fail (bits_per_sample == 8); - g_warn_if_fail (rowstride == width * n_channels); + g_warn_if_fail(bits_per_sample == 8); + g_warn_if_fail(rowstride == width * n_channels); - glGenTextures (1, &texture_handle); - glBindTexture (GL_TEXTURE_2D, texture_handle); + glGenTextures(1, &texture_handle); + glBindTexture(GL_TEXTURE_2D, texture_handle); - /* XXX: We should proabbly determine what the maxmimum texture supported is, - * and if our image is larger, shrink it down using GDK pixbuf routines - * rather than having it fail below. - */ + /* XXX: We should proabbly determine what the maxmimum texture supported is, + * and if our image is larger, shrink it down using GDK pixbuf routines + * rather than having it fail below. + */ - glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, - (n_channels == 4) ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, pixels); - } + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, (n_channels == 4) ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, pixels); + } - glBindTexture (GL_TEXTURE_2D, texture_handle); + glBindTexture(GL_TEXTURE_2D, texture_handle); - glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); - glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); - glEnable (GL_TEXTURE_2D); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glEnable(GL_TEXTURE_2D); - /* Render a quad with the background as a texture */ + /* Render a quad with the background as a texture */ - glBegin (GL_QUADS); - glTexCoord2d (0., 0.); - glVertex3i (0, 0, 0); - glTexCoord2d (1., 0.); - glVertex3i (PCB->MaxWidth, 0, 0); - glTexCoord2d (1., 1.); - glVertex3i (PCB->MaxWidth, PCB->MaxHeight, 0); - glTexCoord2d (0., 1.); - glVertex3i (0, PCB->MaxHeight, 0); - glEnd (); + glBegin(GL_QUADS); + glTexCoord2d(0., 0.); + glVertex3i(0, 0, 0); + glTexCoord2d(1., 0.); + glVertex3i(PCB->MaxWidth, 0, 0); + glTexCoord2d(1., 1.); + glVertex3i(PCB->MaxWidth, PCB->MaxHeight, 0); + glTexCoord2d(0., 1.); + glVertex3i(0, PCB->MaxHeight, 0); + glEnd(); - glDisable (GL_TEXTURE_2D); + glDisable(GL_TEXTURE_2D); } -void -ghid_use_mask (int use_it) +void ghid_use_mask(int use_it) { - static int stencil_bit = 0; + static int stencil_bit = 0; - if (use_it == cur_mask) - return; + if (use_it == cur_mask) + return; - /* Flush out any existing geoemtry to be rendered */ - hidgl_flush_triangles (&buffer); + /* Flush out any existing geoemtry to be rendered */ + hidgl_flush_triangles(&buffer); - switch (use_it) - { - case HID_MASK_BEFORE: - /* The HID asks not to receive this mask type, so warn if we get it */ - g_return_if_reached (); + switch (use_it) { + case HID_MASK_BEFORE: + /* The HID asks not to receive this mask type, so warn if we get it */ + g_return_if_reached(); - case HID_MASK_CLEAR: - /* Write '1' to the stencil buffer where the solder-mask should not be drawn. */ - glColorMask (0, 0, 0, 0); /* Disable writting in color buffer */ - glEnable (GL_STENCIL_TEST); /* Enable Stencil test */ - stencil_bit = hidgl_assign_clear_stencil_bit(); /* Get a new (clean) bitplane to stencil with */ - glStencilFunc (GL_ALWAYS, stencil_bit, stencil_bit); /* Always pass stencil test, write stencil_bit */ - glStencilMask (stencil_bit); /* Only write to our subcompositing stencil bitplane */ - glStencilOp (GL_KEEP, GL_KEEP, GL_REPLACE); /* Stencil pass => replace stencil value (with 1) */ - break; + case HID_MASK_CLEAR: + /* Write '1' to the stencil buffer where the solder-mask should not be drawn. */ + glColorMask(0, 0, 0, 0); /* Disable writting in color buffer */ + glEnable(GL_STENCIL_TEST); /* Enable Stencil test */ + stencil_bit = hidgl_assign_clear_stencil_bit(); /* Get a new (clean) bitplane to stencil with */ + glStencilFunc(GL_ALWAYS, stencil_bit, stencil_bit); /* Always pass stencil test, write stencil_bit */ + glStencilMask(stencil_bit); /* Only write to our subcompositing stencil bitplane */ + glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); /* Stencil pass => replace stencil value (with 1) */ + break; - case HID_MASK_AFTER: - /* Drawing operations as masked to areas where the stencil buffer is '0' */ - glColorMask (1, 1, 1, 1); /* Enable drawing of r, g, b & a */ - glStencilFunc (GL_GEQUAL, 0, stencil_bit); /* Draw only where our bit of the stencil buffer is clear */ - glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP); /* Stencil buffer read only */ - break; + case HID_MASK_AFTER: + /* Drawing operations as masked to areas where the stencil buffer is '0' */ + glColorMask(1, 1, 1, 1); /* Enable drawing of r, g, b & a */ + glStencilFunc(GL_GEQUAL, 0, stencil_bit); /* Draw only where our bit of the stencil buffer is clear */ + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); /* Stencil buffer read only */ + break; - case HID_MASK_OFF: - /* Disable stenciling */ - hidgl_return_stencil_bit (stencil_bit); /* Relinquish any bitplane we previously used */ - glDisable (GL_STENCIL_TEST); /* Disable Stencil test */ - break; - } - cur_mask = use_it; + case HID_MASK_OFF: + /* Disable stenciling */ + hidgl_return_stencil_bit(stencil_bit); /* Relinquish any bitplane we previously used */ + glDisable(GL_STENCIL_TEST); /* Disable Stencil test */ + break; + } + cur_mask = use_it; } - /* Config helper functions for when the user changes color preferences. - | set_special colors used in the gtkhid. - */ -static void -set_special_grid_color (void) + /* Config helper functions for when the user changes color preferences. + | set_special colors used in the gtkhid. + */ +static void set_special_grid_color(void) { - if (!gport->colormap) - return; - gport->grid_color.red ^= gport->bg_color.red; - gport->grid_color.green ^= gport->bg_color.green; - gport->grid_color.blue ^= gport->bg_color.blue; + if (!gport->colormap) + return; + gport->grid_color.red ^= gport->bg_color.red; + gport->grid_color.green ^= gport->bg_color.green; + gport->grid_color.blue ^= gport->bg_color.blue; } -void -ghid_set_special_colors (HID_Attribute * ha) +void ghid_set_special_colors(HID_Attribute * ha) { - if (!ha->name || !ha->value) - return; - if (!strcmp (ha->name, "background-color")) - { - ghid_map_color_string (*(char **) ha->value, &gport->bg_color); - set_special_grid_color (); - } - else if (!strcmp (ha->name, "off-limit-color")) - { - ghid_map_color_string (*(char **) ha->value, &gport->offlimits_color); - } - else if (!strcmp (ha->name, "grid-color")) - { - ghid_map_color_string (*(char **) ha->value, &gport->grid_color); - set_special_grid_color (); - } + if (!ha->name || !ha->value) + return; + if (!strcmp(ha->name, "background-color")) { + ghid_map_color_string(*(char **) ha->value, &gport->bg_color); + set_special_grid_color(); + } + else if (!strcmp(ha->name, "off-limit-color")) { + ghid_map_color_string(*(char **) ha->value, &gport->offlimits_color); + } + else if (!strcmp(ha->name, "grid-color")) { + ghid_map_color_string(*(char **) ha->value, &gport->grid_color); + set_special_grid_color(); + } } -typedef struct -{ - int color_set; - GdkColor color; - int xor_set; - GdkColor xor_color; - double red; - double green; - double blue; +typedef struct { + int color_set; + GdkColor color; + int xor_set; + GdkColor xor_color; + double red; + double green; + double blue; } ColorCache; -static void -set_gl_color_for_gc (hidGC gc) +static void set_gl_color_for_gc(hidGC gc) { - render_priv *priv = gport->render_priv; - static void *cache = NULL; - hidval cval; - ColorCache *cc; - double r, g, b, a; + render_priv *priv = gport->render_priv; + static void *cache = NULL; + hidval cval; + ColorCache *cc; + double r, g, b, a; - if (priv->current_colorname != NULL && - strcmp (priv->current_colorname, gc->colorname) == 0 && - priv->current_alpha_mult == gc->alpha_mult) - return; + if (priv->current_colorname != NULL && + strcmp(priv->current_colorname, gc->colorname) == 0 && priv->current_alpha_mult == gc->alpha_mult) + return; - free (priv->current_colorname); - priv->current_colorname = strdup (gc->colorname); - priv->current_alpha_mult = gc->alpha_mult; + free(priv->current_colorname); + priv->current_colorname = strdup(gc->colorname); + priv->current_alpha_mult = gc->alpha_mult; - if (gport->colormap == NULL) - gport->colormap = gtk_widget_get_colormap (gport->top_window); - if (strcmp (gc->colorname, "erase") == 0) - { - r = gport->bg_color.red / 65535.; - g = gport->bg_color.green / 65535.; - b = gport->bg_color.blue / 65535.; - a = 1.0; - } - else if (strcmp (gc->colorname, "drill") == 0) - { - r = gport->offlimits_color.red / 65535.; - g = gport->offlimits_color.green / 65535.; - b = gport->offlimits_color.blue / 65535.; - a = 0.85; - } - else - { - if (hid_cache_color (0, gc->colorname, &cval, &cache)) - cc = (ColorCache *) cval.ptr; - else - { - cc = (ColorCache *) malloc (sizeof (ColorCache)); - memset (cc, 0, sizeof (*cc)); - cval.ptr = cc; - hid_cache_color (1, gc->colorname, &cval, &cache); - } + if (gport->colormap == NULL) + gport->colormap = gtk_widget_get_colormap(gport->top_window); + if (strcmp(gc->colorname, "erase") == 0) { + r = gport->bg_color.red / 65535.; + g = gport->bg_color.green / 65535.; + b = gport->bg_color.blue / 65535.; + a = 1.0; + } + else if (strcmp(gc->colorname, "drill") == 0) { + r = gport->offlimits_color.red / 65535.; + g = gport->offlimits_color.green / 65535.; + b = gport->offlimits_color.blue / 65535.; + a = 0.85; + } + else { + if (hid_cache_color(0, gc->colorname, &cval, &cache)) + cc = (ColorCache *) cval.ptr; + else { + cc = (ColorCache *) malloc(sizeof(ColorCache)); + memset(cc, 0, sizeof(*cc)); + cval.ptr = cc; + hid_cache_color(1, gc->colorname, &cval, &cache); + } - if (!cc->color_set) - { - if (gdk_color_parse (gc->colorname, &cc->color)) - gdk_color_alloc (gport->colormap, &cc->color); - else - gdk_color_white (gport->colormap, &cc->color); - cc->red = cc->color.red / 65535.; - cc->green = cc->color.green / 65535.; - cc->blue = cc->color.blue / 65535.; - cc->color_set = 1; - } - if (gc->xor) - { - if (!cc->xor_set) - { - cc->xor_color.red = cc->color.red ^ gport->bg_color.red; - cc->xor_color.green = cc->color.green ^ gport->bg_color.green; - cc->xor_color.blue = cc->color.blue ^ gport->bg_color.blue; - gdk_color_alloc (gport->colormap, &cc->xor_color); - cc->red = cc->color.red / 65535.; - cc->green = cc->color.green / 65535.; - cc->blue = cc->color.blue / 65535.; - cc->xor_set = 1; - } - } - r = cc->red; - g = cc->green; - b = cc->blue; - a = 0.7; - } - if (1) { - double maxi, mult; - a *= gc->alpha_mult; - if (!priv->trans_lines) - a = 1.0; - maxi = r; - if (g > maxi) maxi = g; - if (b > maxi) maxi = b; - mult = MIN (1 / a, 1 / maxi); + if (!cc->color_set) { + if (gdk_color_parse(gc->colorname, &cc->color)) + gdk_color_alloc(gport->colormap, &cc->color); + else + gdk_color_white(gport->colormap, &cc->color); + cc->red = cc->color.red / 65535.; + cc->green = cc->color.green / 65535.; + cc->blue = cc->color.blue / 65535.; + cc->color_set = 1; + } + if (gc->xor) { + if (!cc->xor_set) { + cc->xor_color.red = cc->color.red ^ gport->bg_color.red; + cc->xor_color.green = cc->color.green ^ gport->bg_color.green; + cc->xor_color.blue = cc->color.blue ^ gport->bg_color.blue; + gdk_color_alloc(gport->colormap, &cc->xor_color); + cc->red = cc->color.red / 65535.; + cc->green = cc->color.green / 65535.; + cc->blue = cc->color.blue / 65535.; + cc->xor_set = 1; + } + } + r = cc->red; + g = cc->green; + b = cc->blue; + a = 0.7; + } + if (1) { + double maxi, mult; + a *= gc->alpha_mult; + if (!priv->trans_lines) + a = 1.0; + maxi = r; + if (g > maxi) + maxi = g; + if (b > maxi) + maxi = b; + mult = MIN(1 / a, 1 / maxi); #if 1 - r = r * mult; - g = g * mult; - b = b * mult; + r = r * mult; + g = g * mult; + b = b * mult; #endif - } + } - if(!priv->in_context) - return; + if (!priv->in_context) + return; - hidgl_flush_triangles (&buffer); - glColor4d (r, g, b, a); + hidgl_flush_triangles(&buffer); + glColor4d(r, g, b, a); } -void -ghid_set_color (hidGC gc, const char *name) +void ghid_set_color(hidGC gc, const char *name) { - gc->colorname = name; - set_gl_color_for_gc (gc); + gc->colorname = name; + set_gl_color_for_gc(gc); } -void -ghid_set_alpha_mult (hidGC gc, double alpha_mult) +void ghid_set_alpha_mult(hidGC gc, double alpha_mult) { - gc->alpha_mult = alpha_mult; - set_gl_color_for_gc (gc); + gc->alpha_mult = alpha_mult; + set_gl_color_for_gc(gc); } -void -ghid_set_line_cap (hidGC gc, EndCapStyle style) +void ghid_set_line_cap(hidGC gc, EndCapStyle style) { - gc->cap = style; + gc->cap = style; } -void -ghid_set_line_width (hidGC gc, Coord width) +void ghid_set_line_width(hidGC gc, Coord width) { - gc->width = width; + gc->width = width; } -void -ghid_set_draw_xor (hidGC gc, int xor) +void ghid_set_draw_xor(hidGC gc, int xor) { - /* NOT IMPLEMENTED */ + /* NOT IMPLEMENTED */ - /* Only presently called when setting up a crosshair GC. - * We manage our own drawing model for that anyway. */ + /* Only presently called when setting up a crosshair GC. + * We manage our own drawing model for that anyway. */ } -void -ghid_set_draw_faded (hidGC gc, int faded) +void ghid_set_draw_faded(hidGC gc, int faded) { - printf ("ghid_set_draw_faded(%p,%d) -- not implemented\n", gc, faded); + printf("ghid_set_draw_faded(%p,%d) -- not implemented\n", gc, faded); } -void -ghid_set_line_cap_angle (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) +void ghid_set_line_cap_angle(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) { - printf ("ghid_set_line_cap_angle() -- not implemented\n"); + printf("ghid_set_line_cap_angle() -- not implemented\n"); } -static void -ghid_invalidate_current_gc (void) +static void ghid_invalidate_current_gc(void) { - current_gc = NULL; + current_gc = NULL; } -static int -use_gc (hidGC gc) +static int use_gc(hidGC gc) { - if (gc->me_pointer != &ghid_hid) - { - fprintf (stderr, "Fatal: GC from another HID passed to GTK HID\n"); - abort (); - } + if (gc->me_pointer != &ghid_hid) { + fprintf(stderr, "Fatal: GC from another HID passed to GTK HID\n"); + abort(); + } - if (current_gc == gc) - return 1; + if (current_gc == gc) + return 1; - current_gc = gc; + current_gc = gc; - set_gl_color_for_gc (gc); - return 1; + set_gl_color_for_gc(gc); + return 1; } -void -ghid_draw_line (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) +void ghid_draw_line(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) { - USE_GC (gc); + USE_GC(gc); - hidgl_draw_line (gc->cap, gc->width, x1, y1, x2, y2, gport->view.coord_per_px); + hidgl_draw_line(gc->cap, gc->width, x1, y1, x2, y2, gport->view.coord_per_px); } -void -ghid_draw_arc (hidGC gc, Coord cx, Coord cy, Coord xradius, Coord yradius, - Angle start_angle, Angle delta_angle) +void ghid_draw_arc(hidGC gc, Coord cx, Coord cy, Coord xradius, Coord yradius, Angle start_angle, Angle delta_angle) { - USE_GC (gc); + USE_GC(gc); - hidgl_draw_arc (gc->width, cx, cy, xradius, yradius, - start_angle, delta_angle, gport->view.coord_per_px); + hidgl_draw_arc(gc->width, cx, cy, xradius, yradius, start_angle, delta_angle, gport->view.coord_per_px); } -void -ghid_draw_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) +void ghid_draw_rect(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) { - USE_GC (gc); + USE_GC(gc); - hidgl_draw_rect (x1, y1, x2, y2); + hidgl_draw_rect(x1, y1, x2, y2); } -void -ghid_fill_circle (hidGC gc, Coord cx, Coord cy, Coord radius) +void ghid_fill_circle(hidGC gc, Coord cx, Coord cy, Coord radius) { - USE_GC (gc); + USE_GC(gc); - hidgl_fill_circle (cx, cy, radius, gport->view.coord_per_px); + hidgl_fill_circle(cx, cy, radius, gport->view.coord_per_px); } -void -ghid_fill_polygon (hidGC gc, int n_coords, Coord *x, Coord *y) +void ghid_fill_polygon(hidGC gc, int n_coords, Coord * x, Coord * y) { - USE_GC (gc); + USE_GC(gc); - hidgl_fill_polygon (n_coords, x, y); + hidgl_fill_polygon(n_coords, x, y); } -void -ghid_fill_pcb_polygon (hidGC gc, PolygonType *poly, const BoxType *clip_box) +void ghid_fill_pcb_polygon(hidGC gc, PolygonType * poly, const BoxType * clip_box) { - USE_GC (gc); + USE_GC(gc); - hidgl_fill_pcb_polygon (poly, clip_box, gport->view.coord_per_px); + hidgl_fill_pcb_polygon(poly, clip_box, gport->view.coord_per_px); } -void -ghid_thindraw_pcb_polygon (hidGC gc, PolygonType *poly, const BoxType *clip_box) +void ghid_thindraw_pcb_polygon(hidGC gc, PolygonType * poly, const BoxType * clip_box) { - common_thindraw_pcb_polygon (gc, poly, clip_box); - ghid_set_alpha_mult (gc, 0.25); - ghid_fill_pcb_polygon (gc, poly, clip_box); - ghid_set_alpha_mult (gc, 1.0); + common_thindraw_pcb_polygon(gc, poly, clip_box); + ghid_set_alpha_mult(gc, 0.25); + ghid_fill_pcb_polygon(gc, poly, clip_box); + ghid_set_alpha_mult(gc, 1.0); } -void -ghid_fill_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) +void ghid_fill_rect(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) { - USE_GC (gc); + USE_GC(gc); - hidgl_fill_rect (x1, y1, x2, y2); + hidgl_fill_rect(x1, y1, x2, y2); } -void -ghid_invalidate_lr (int left, int right, int top, int bottom) +void ghid_invalidate_lr(int left, int right, int top, int bottom) { - ghid_invalidate_all (); + ghid_invalidate_all(); } -void -ghid_invalidate_all () +void ghid_invalidate_all() { - ghid_draw_area_update (gport, NULL); + ghid_draw_area_update(gport, NULL); } -void -ghid_notify_crosshair_change (bool changes_complete) +void ghid_notify_crosshair_change(bool changes_complete) { - /* We sometimes get called before the GUI is up */ - if (gport->drawing_area == NULL) - return; + /* We sometimes get called before the GUI is up */ + if (gport->drawing_area == NULL) + return; - /* FIXME: We could just invalidate the bounds of the crosshair attached objects? */ - ghid_invalidate_all (); + /* FIXME: We could just invalidate the bounds of the crosshair attached objects? */ + ghid_invalidate_all(); } -void -ghid_notify_mark_change (bool changes_complete) +void ghid_notify_mark_change(bool changes_complete) { - /* We sometimes get called before the GUI is up */ - if (gport->drawing_area == NULL) - return; + /* We sometimes get called before the GUI is up */ + if (gport->drawing_area == NULL) + return; - /* FIXME: We could just invalidate the bounds of the mark? */ - ghid_invalidate_all (); + /* FIXME: We could just invalidate the bounds of the mark? */ + ghid_invalidate_all(); } -static void -draw_right_cross (gint x, gint y, gint z) +static void draw_right_cross(gint x, gint y, gint z) { - glVertex3i (x, 0, z); - glVertex3i (x, PCB->MaxHeight, z); - glVertex3i (0, y, z); - glVertex3i (PCB->MaxWidth, y, z); + glVertex3i(x, 0, z); + glVertex3i(x, PCB->MaxHeight, z); + glVertex3i(0, y, z); + glVertex3i(PCB->MaxWidth, y, z); } -static void -draw_slanted_cross (gint x, gint y, gint z) +static void draw_slanted_cross(gint x, gint y, gint z) { - gint x0, y0, x1, y1; + gint x0, y0, x1, y1; - x0 = x + (PCB->MaxHeight - y); - x0 = MAX(0, MIN (x0, PCB->MaxWidth)); - x1 = x - y; - x1 = MAX(0, MIN (x1, PCB->MaxWidth)); - y0 = y + (PCB->MaxWidth - x); - y0 = MAX(0, MIN (y0, PCB->MaxHeight)); - y1 = y - x; - y1 = MAX(0, MIN (y1, PCB->MaxHeight)); - glVertex3i (x0, y0, z); - glVertex3i (x1, y1, z); + x0 = x + (PCB->MaxHeight - y); + x0 = MAX(0, MIN(x0, PCB->MaxWidth)); + x1 = x - y; + x1 = MAX(0, MIN(x1, PCB->MaxWidth)); + y0 = y + (PCB->MaxWidth - x); + y0 = MAX(0, MIN(y0, PCB->MaxHeight)); + y1 = y - x; + y1 = MAX(0, MIN(y1, PCB->MaxHeight)); + glVertex3i(x0, y0, z); + glVertex3i(x1, y1, z); - x0 = x - (PCB->MaxHeight - y); - x0 = MAX(0, MIN (x0, PCB->MaxWidth)); - x1 = x + y; - x1 = MAX(0, MIN (x1, PCB->MaxWidth)); - y0 = y + x; - y0 = MAX(0, MIN (y0, PCB->MaxHeight)); - y1 = y - (PCB->MaxWidth - x); - y1 = MAX(0, MIN (y1, PCB->MaxHeight)); - glVertex3i (x0, y0, z); - glVertex3i (x1, y1, z); + x0 = x - (PCB->MaxHeight - y); + x0 = MAX(0, MIN(x0, PCB->MaxWidth)); + x1 = x + y; + x1 = MAX(0, MIN(x1, PCB->MaxWidth)); + y0 = y + x; + y0 = MAX(0, MIN(y0, PCB->MaxHeight)); + y1 = y - (PCB->MaxWidth - x); + y1 = MAX(0, MIN(y1, PCB->MaxHeight)); + glVertex3i(x0, y0, z); + glVertex3i(x1, y1, z); } -static void -draw_dozen_cross (gint x, gint y, gint z) +static void draw_dozen_cross(gint x, gint y, gint z) { - gint x0, y0, x1, y1; - gdouble tan60 = sqrt (3); + gint x0, y0, x1, y1; + gdouble tan60 = sqrt(3); - x0 = x + (PCB->MaxHeight - y) / tan60; - x0 = MAX(0, MIN (x0, PCB->MaxWidth)); - x1 = x - y / tan60; - x1 = MAX(0, MIN (x1, PCB->MaxWidth)); - y0 = y + (PCB->MaxWidth - x) * tan60; - y0 = MAX(0, MIN (y0, PCB->MaxHeight)); - y1 = y - x * tan60; - y1 = MAX(0, MIN (y1, PCB->MaxHeight)); - glVertex3i (x0, y0, z); - glVertex3i (x1, y1, z); + x0 = x + (PCB->MaxHeight - y) / tan60; + x0 = MAX(0, MIN(x0, PCB->MaxWidth)); + x1 = x - y / tan60; + x1 = MAX(0, MIN(x1, PCB->MaxWidth)); + y0 = y + (PCB->MaxWidth - x) * tan60; + y0 = MAX(0, MIN(y0, PCB->MaxHeight)); + y1 = y - x * tan60; + y1 = MAX(0, MIN(y1, PCB->MaxHeight)); + glVertex3i(x0, y0, z); + glVertex3i(x1, y1, z); - x0 = x + (PCB->MaxHeight - y) * tan60; - x0 = MAX(0, MIN (x0, PCB->MaxWidth)); - x1 = x - y * tan60; - x1 = MAX(0, MIN (x1, PCB->MaxWidth)); - y0 = y + (PCB->MaxWidth - x) / tan60; - y0 = MAX(0, MIN (y0, PCB->MaxHeight)); - y1 = y - x / tan60; - y1 = MAX(0, MIN (y1, PCB->MaxHeight)); - glVertex3i (x0, y0, z); - glVertex3i (x1, y1, z); + x0 = x + (PCB->MaxHeight - y) * tan60; + x0 = MAX(0, MIN(x0, PCB->MaxWidth)); + x1 = x - y * tan60; + x1 = MAX(0, MIN(x1, PCB->MaxWidth)); + y0 = y + (PCB->MaxWidth - x) / tan60; + y0 = MAX(0, MIN(y0, PCB->MaxHeight)); + y1 = y - x / tan60; + y1 = MAX(0, MIN(y1, PCB->MaxHeight)); + glVertex3i(x0, y0, z); + glVertex3i(x1, y1, z); - x0 = x - (PCB->MaxHeight - y) / tan60; - x0 = MAX(0, MIN (x0, PCB->MaxWidth)); - x1 = x + y / tan60; - x1 = MAX(0, MIN (x1, PCB->MaxWidth)); - y0 = y + x * tan60; - y0 = MAX(0, MIN (y0, PCB->MaxHeight)); - y1 = y - (PCB->MaxWidth - x) * tan60; - y1 = MAX(0, MIN (y1, PCB->MaxHeight)); - glVertex3i (x0, y0, z); - glVertex3i (x1, y1, z); + x0 = x - (PCB->MaxHeight - y) / tan60; + x0 = MAX(0, MIN(x0, PCB->MaxWidth)); + x1 = x + y / tan60; + x1 = MAX(0, MIN(x1, PCB->MaxWidth)); + y0 = y + x * tan60; + y0 = MAX(0, MIN(y0, PCB->MaxHeight)); + y1 = y - (PCB->MaxWidth - x) * tan60; + y1 = MAX(0, MIN(y1, PCB->MaxHeight)); + glVertex3i(x0, y0, z); + glVertex3i(x1, y1, z); - x0 = x - (PCB->MaxHeight - y) * tan60; - x0 = MAX(0, MIN (x0, PCB->MaxWidth)); - x1 = x + y * tan60; - x1 = MAX(0, MIN (x1, PCB->MaxWidth)); - y0 = y + x / tan60; - y0 = MAX(0, MIN (y0, PCB->MaxHeight)); - y1 = y - (PCB->MaxWidth - x) / tan60; - y1 = MAX(0, MIN (y1, PCB->MaxHeight)); - glVertex3i (x0, y0, z); - glVertex3i (x1, y1, z); + x0 = x - (PCB->MaxHeight - y) * tan60; + x0 = MAX(0, MIN(x0, PCB->MaxWidth)); + x1 = x + y * tan60; + x1 = MAX(0, MIN(x1, PCB->MaxWidth)); + y0 = y + x / tan60; + y0 = MAX(0, MIN(y0, PCB->MaxHeight)); + y1 = y - (PCB->MaxWidth - x) / tan60; + y1 = MAX(0, MIN(y1, PCB->MaxHeight)); + glVertex3i(x0, y0, z); + glVertex3i(x1, y1, z); } -static void -draw_crosshair (gint x, gint y, gint z) +static void draw_crosshair(gint x, gint y, gint z) { - static enum crosshair_shape prev = Basic_Crosshair_Shape; + static enum crosshair_shape prev = Basic_Crosshair_Shape; - draw_right_cross (x, y, z); - if (prev == Union_Jack_Crosshair_Shape) - draw_slanted_cross (x, y, z); - if (prev == Dozen_Crosshair_Shape) - draw_dozen_cross (x, y, z); - prev = Crosshair.shape; + draw_right_cross(x, y, z); + if (prev == Union_Jack_Crosshair_Shape) + draw_slanted_cross(x, y, z); + if (prev == Dozen_Crosshair_Shape) + draw_dozen_cross(x, y, z); + prev = Crosshair.shape; } -void -ghid_show_crosshair (gboolean paint_new_location) +void ghid_show_crosshair(gboolean paint_new_location) { - gint x, y, z; - static int done_once = 0; - static GdkColor cross_color; + gint x, y, z; + static int done_once = 0; + static GdkColor cross_color; - if (!paint_new_location) - return; + if (!paint_new_location) + return; - if (!done_once) - { - done_once = 1; - /* FIXME: when CrossColor changed from config */ - ghid_map_color_string (Settings.CrossColor, &cross_color); - } - x = gport->crosshair_x; - y = gport->crosshair_y; - z = 0; + if (!done_once) { + done_once = 1; + /* FIXME: when CrossColor changed from config */ + ghid_map_color_string(Settings.CrossColor, &cross_color); + } + x = gport->crosshair_x; + y = gport->crosshair_y; + z = 0; - glEnable (GL_COLOR_LOGIC_OP); - glLogicOp (GL_XOR); + glEnable(GL_COLOR_LOGIC_OP); + glLogicOp(GL_XOR); - glColor3f (cross_color.red / 65535., - cross_color.green / 65535., - cross_color.blue / 65535.); + glColor3f(cross_color.red / 65535., cross_color.green / 65535., cross_color.blue / 65535.); - if (x >= 0 && paint_new_location) - { - glBegin (GL_LINES); - draw_crosshair (x, y, z); - glEnd (); - } + if (x >= 0 && paint_new_location) { + glBegin(GL_LINES); + draw_crosshair(x, y, z); + glEnd(); + } - glDisable (GL_COLOR_LOGIC_OP); + glDisable(GL_COLOR_LOGIC_OP); } -void -ghid_init_renderer (int *argc, char ***argv, GHidPort *port) +void ghid_init_renderer(int *argc, char ***argv, GHidPort * port) { - render_priv *priv; + render_priv *priv; - port->render_priv = priv = g_new0 (render_priv, 1); + port->render_priv = priv = g_new0(render_priv, 1); - gtk_gl_init(argc, argv); + gtk_gl_init(argc, argv); - /* setup GL-context */ - priv->glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGBA | - GDK_GL_MODE_STENCIL | - GDK_GL_MODE_DOUBLE); - if (!priv->glconfig) - { - printf ("Could not setup GL-context!\n"); - return; /* Should we abort? */ - } + /* setup GL-context */ + priv->glconfig = gdk_gl_config_new_by_mode(GDK_GL_MODE_RGBA | GDK_GL_MODE_STENCIL | GDK_GL_MODE_DOUBLE); + if (!priv->glconfig) { + printf("Could not setup GL-context!\n"); + return; /* Should we abort? */ + } - /* Setup HID function pointers specific to the GL renderer*/ - ghid_hid.end_layer = ghid_end_layer; - ghid_hid.fill_pcb_polygon = ghid_fill_pcb_polygon; - ghid_hid.thindraw_pcb_polygon = ghid_thindraw_pcb_polygon; + /* Setup HID function pointers specific to the GL renderer */ + ghid_hid.end_layer = ghid_end_layer; + ghid_hid.fill_pcb_polygon = ghid_fill_pcb_polygon; + ghid_hid.thindraw_pcb_polygon = ghid_thindraw_pcb_polygon; } -void -ghid_shutdown_renderer (GHidPort *port) +void ghid_shutdown_renderer(GHidPort * port) { - ghid_cancel_lead_user (); - g_free (port->render_priv); - port->render_priv = NULL; + ghid_cancel_lead_user(); + g_free(port->render_priv); + port->render_priv = NULL; } -void -ghid_init_drawing_widget (GtkWidget *widget, GHidPort *port) +void ghid_init_drawing_widget(GtkWidget * widget, GHidPort * port) { - render_priv *priv = port->render_priv; + render_priv *priv = port->render_priv; - gtk_widget_set_gl_capability (widget, - priv->glconfig, - NULL, - TRUE, - GDK_GL_RGBA_TYPE); + gtk_widget_set_gl_capability(widget, priv->glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE); } -void -ghid_drawing_area_configure_hook (GHidPort *port) +void ghid_drawing_area_configure_hook(GHidPort * port) { } -gboolean -ghid_start_drawing (GHidPort *port) +gboolean ghid_start_drawing(GHidPort * port) { - GtkWidget *widget = port->drawing_area; - GdkGLContext *pGlContext = gtk_widget_get_gl_context (widget); - GdkGLDrawable *pGlDrawable = gtk_widget_get_gl_drawable (widget); + GtkWidget *widget = port->drawing_area; + GdkGLContext *pGlContext = gtk_widget_get_gl_context(widget); + GdkGLDrawable *pGlDrawable = gtk_widget_get_gl_drawable(widget); - /* make GL-context "current" */ - if (!gdk_gl_drawable_gl_begin (pGlDrawable, pGlContext)) - return FALSE; + /* make GL-context "current" */ + if (!gdk_gl_drawable_gl_begin(pGlDrawable, pGlContext)) + return FALSE; - port->render_priv->in_context = true; + port->render_priv->in_context = true; - return TRUE; + return TRUE; } -void -ghid_end_drawing (GHidPort *port) +void ghid_end_drawing(GHidPort * port) { - GtkWidget *widget = port->drawing_area; - GdkGLDrawable *pGlDrawable = gtk_widget_get_gl_drawable (widget); + GtkWidget *widget = port->drawing_area; + GdkGLDrawable *pGlDrawable = gtk_widget_get_gl_drawable(widget); - if (gdk_gl_drawable_is_double_buffered (pGlDrawable)) - gdk_gl_drawable_swap_buffers (pGlDrawable); - else - glFlush (); + if (gdk_gl_drawable_is_double_buffered(pGlDrawable)) + gdk_gl_drawable_swap_buffers(pGlDrawable); + else + glFlush(); - port->render_priv->in_context = false; + port->render_priv->in_context = false; - /* end drawing to current GL-context */ - gdk_gl_drawable_gl_end (pGlDrawable); + /* end drawing to current GL-context */ + gdk_gl_drawable_gl_end(pGlDrawable); } -void -ghid_screen_update (void) +void ghid_screen_update(void) { } #define Z_NEAR 3.0 -gboolean -ghid_drawing_area_expose_cb (GtkWidget *widget, - GdkEventExpose *ev, - GHidPort *port) +gboolean ghid_drawing_area_expose_cb(GtkWidget * widget, GdkEventExpose * ev, GHidPort * port) { - render_priv *priv = port->render_priv; - GtkAllocation allocation; - BoxType region; + render_priv *priv = port->render_priv; + GtkAllocation allocation; + BoxType region; - gtk_widget_get_allocation (widget, &allocation); + gtk_widget_get_allocation(widget, &allocation); - ghid_start_drawing (port); + ghid_start_drawing(port); - hidgl_init (); + hidgl_init(); - /* If we don't have any stencil bits available, - we can't use the hidgl polygon drawing routine */ - /* TODO: We could use the GLU tessellator though */ - if (hidgl_stencil_bits() == 0) - ghid_hid.fill_pcb_polygon = common_fill_pcb_polygon; + /* If we don't have any stencil bits available, + we can't use the hidgl polygon drawing routine */ + /* TODO: We could use the GLU tessellator though */ + if (hidgl_stencil_bits() == 0) + ghid_hid.fill_pcb_polygon = common_fill_pcb_polygon; - glEnable (GL_BLEND); - glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glViewport (0, 0, allocation.width, allocation.height); + glViewport(0, 0, allocation.width, allocation.height); - glEnable (GL_SCISSOR_TEST); - glScissor (ev->area.x, - allocation.height - ev->area.height - ev->area.y, - ev->area.width, ev->area.height); + glEnable(GL_SCISSOR_TEST); + glScissor(ev->area.x, allocation.height - ev->area.height - ev->area.y, ev->area.width, ev->area.height); - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); - glOrtho (0, allocation.width, allocation.height, 0, 0, 100); - glMatrixMode (GL_MODELVIEW); - glLoadIdentity (); - glTranslatef (0.0f, 0.0f, -Z_NEAR); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, allocation.width, allocation.height, 0, 0, 100); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0f, 0.0f, -Z_NEAR); - glScalef ((port->view.flip_x ? -1. : 1.) / port->view.coord_per_px, - (port->view.flip_y ? -1. : 1.) / port->view.coord_per_px, - ((port->view.flip_x == port->view.flip_y) ? 1. : -1.) / port->view.coord_per_px); - glTranslatef (port->view.flip_x ? port->view.x0 - PCB->MaxWidth : - -port->view.x0, - port->view.flip_y ? port->view.y0 - PCB->MaxHeight : - -port->view.y0, 0); + glScalef((port->view.flip_x ? -1. : 1.) / port->view.coord_per_px, + (port->view.flip_y ? -1. : 1.) / port->view.coord_per_px, + ((port->view.flip_x == port->view.flip_y) ? 1. : -1.) / port->view.coord_per_px); + glTranslatef(port->view.flip_x ? port->view.x0 - PCB->MaxWidth : + -port->view.x0, port->view.flip_y ? port->view.y0 - PCB->MaxHeight : -port->view.y0, 0); - glEnable (GL_STENCIL_TEST); - glClearColor (port->offlimits_color.red / 65535., - port->offlimits_color.green / 65535., - port->offlimits_color.blue / 65535., - 1.); - glStencilMask (~0); - glClearStencil (0); - glClear (GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - hidgl_reset_stencil_usage (); + glEnable(GL_STENCIL_TEST); + glClearColor(port->offlimits_color.red / 65535., + port->offlimits_color.green / 65535., port->offlimits_color.blue / 65535., 1.); + glStencilMask(~0); + glClearStencil(0); + glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + hidgl_reset_stencil_usage(); - /* Disable the stencil test until we need it - otherwise it gets dirty */ - glDisable (GL_STENCIL_TEST); - glStencilMask (0); - glStencilFunc (GL_ALWAYS, 0, 0); + /* Disable the stencil test until we need it - otherwise it gets dirty */ + glDisable(GL_STENCIL_TEST); + glStencilMask(0); + glStencilFunc(GL_ALWAYS, 0, 0); - region.X1 = MIN (Px (ev->area.x), Px (ev->area.x + ev->area.width + 1)); - region.X2 = MAX (Px (ev->area.x), Px (ev->area.x + ev->area.width + 1)); - region.Y1 = MIN (Py (ev->area.y), Py (ev->area.y + ev->area.height + 1)); - region.Y2 = MAX (Py (ev->area.y), Py (ev->area.y + ev->area.height + 1)); + region.X1 = MIN(Px(ev->area.x), Px(ev->area.x + ev->area.width + 1)); + region.X2 = MAX(Px(ev->area.x), Px(ev->area.x + ev->area.width + 1)); + region.Y1 = MIN(Py(ev->area.y), Py(ev->area.y + ev->area.height + 1)); + region.Y2 = MAX(Py(ev->area.y), Py(ev->area.y + ev->area.height + 1)); - region.X1 = MAX (0, MIN (PCB->MaxWidth, region.X1)); - region.X2 = MAX (0, MIN (PCB->MaxWidth, region.X2)); - region.Y1 = MAX (0, MIN (PCB->MaxHeight, region.Y1)); - region.Y2 = MAX (0, MIN (PCB->MaxHeight, region.Y2)); + region.X1 = MAX(0, MIN(PCB->MaxWidth, region.X1)); + region.X2 = MAX(0, MIN(PCB->MaxWidth, region.X2)); + region.Y1 = MAX(0, MIN(PCB->MaxHeight, region.Y1)); + region.Y2 = MAX(0, MIN(PCB->MaxHeight, region.Y2)); - glColor3f (port->bg_color.red / 65535., - port->bg_color.green / 65535., - port->bg_color.blue / 65535.); + glColor3f(port->bg_color.red / 65535., port->bg_color.green / 65535., port->bg_color.blue / 65535.); - glBegin (GL_QUADS); - glVertex3i (0, 0, 0); - glVertex3i (PCB->MaxWidth, 0, 0); - glVertex3i (PCB->MaxWidth, PCB->MaxHeight, 0); - glVertex3i (0, PCB->MaxHeight, 0); - glEnd (); + glBegin(GL_QUADS); + glVertex3i(0, 0, 0); + glVertex3i(PCB->MaxWidth, 0, 0); + glVertex3i(PCB->MaxWidth, PCB->MaxHeight, 0); + glVertex3i(0, PCB->MaxHeight, 0); + glEnd(); - ghid_draw_bg_image (); + ghid_draw_bg_image(); - hidgl_init_triangle_array (&buffer); - ghid_invalidate_current_gc (); - hid_expose_callback (&ghid_hid, ®ion, 0); - hidgl_flush_triangles (&buffer); + hidgl_init_triangle_array(&buffer); + ghid_invalidate_current_gc(); + hid_expose_callback(&ghid_hid, ®ion, 0); + hidgl_flush_triangles(&buffer); - ghid_draw_grid (®ion); + ghid_draw_grid(®ion); - ghid_invalidate_current_gc (); + ghid_invalidate_current_gc(); - DrawAttached (); - DrawMark (); - hidgl_flush_triangles (&buffer); + DrawAttached(); + DrawMark(); + hidgl_flush_triangles(&buffer); - ghid_show_crosshair (TRUE); + ghid_show_crosshair(TRUE); - hidgl_flush_triangles (&buffer); + hidgl_flush_triangles(&buffer); - draw_lead_user (priv); + draw_lead_user(priv); - ghid_end_drawing (port); + ghid_end_drawing(port); - return FALSE; + return FALSE; } /* This realize callback is used to work around a crash bug in some mesa @@ -980,405 +886,373 @@ * obvious why it helps, but somehow fiddling with the GL context here solves * the issue. The problem appears to have been fixed in recent mesa versions. */ -void -ghid_port_drawing_realize_cb (GtkWidget *widget, gpointer data) +void ghid_port_drawing_realize_cb(GtkWidget * widget, gpointer data) { - GdkGLContext *glcontext = gtk_widget_get_gl_context (widget); - GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (widget); + GdkGLContext *glcontext = gtk_widget_get_gl_context(widget); + GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget); - if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext)) - return; + if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext)) + return; - gdk_gl_drawable_gl_end (gldrawable); - return; + gdk_gl_drawable_gl_end(gldrawable); + return; } -gboolean -ghid_pinout_preview_expose (GtkWidget *widget, - GdkEventExpose *ev) +gboolean ghid_pinout_preview_expose(GtkWidget * widget, GdkEventExpose * ev) { - GdkGLContext* pGlContext = gtk_widget_get_gl_context (widget); - GdkGLDrawable* pGlDrawable = gtk_widget_get_gl_drawable (widget); - GhidPinoutPreview *pinout = GHID_PINOUT_PREVIEW (widget); - GtkAllocation allocation; - view_data save_view; - int save_width, save_height; - double xz, yz; + GdkGLContext *pGlContext = gtk_widget_get_gl_context(widget); + GdkGLDrawable *pGlDrawable = gtk_widget_get_gl_drawable(widget); + GhidPinoutPreview *pinout = GHID_PINOUT_PREVIEW(widget); + GtkAllocation allocation; + view_data save_view; + int save_width, save_height; + double xz, yz; - save_view = gport->view; - save_width = gport->width; - save_height = gport->height; + save_view = gport->view; + save_width = gport->width; + save_height = gport->height; - /* Setup zoom factor for drawing routines */ + /* Setup zoom factor for drawing routines */ - gtk_widget_get_allocation (widget, &allocation); - xz = (double) pinout->x_max / allocation.width; - yz = (double) pinout->y_max / allocation.height; - if (xz > yz) - gport->view.coord_per_px = xz; - else - gport->view.coord_per_px = yz; + gtk_widget_get_allocation(widget, &allocation); + xz = (double) pinout->x_max / allocation.width; + yz = (double) pinout->y_max / allocation.height; + if (xz > yz) + gport->view.coord_per_px = xz; + else + gport->view.coord_per_px = yz; - gport->width = allocation.width; - gport->height = allocation.height; - gport->view.width = allocation.width * gport->view.coord_per_px; - gport->view.height = allocation.height * gport->view.coord_per_px; - gport->view.x0 = (pinout->x_max - gport->view.width) / 2; - gport->view.y0 = (pinout->y_max - gport->view.height) / 2; + gport->width = allocation.width; + gport->height = allocation.height; + gport->view.width = allocation.width * gport->view.coord_per_px; + gport->view.height = allocation.height * gport->view.coord_per_px; + gport->view.x0 = (pinout->x_max - gport->view.width) / 2; + gport->view.y0 = (pinout->y_max - gport->view.height) / 2; - /* make GL-context "current" */ - if (!gdk_gl_drawable_gl_begin (pGlDrawable, pGlContext)) { - return FALSE; - } - gport->render_priv->in_context = true; + /* make GL-context "current" */ + if (!gdk_gl_drawable_gl_begin(pGlDrawable, pGlContext)) { + return FALSE; + } + gport->render_priv->in_context = true; - glEnable (GL_BLEND); - glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glViewport (0, 0, allocation.width, allocation.height); + glViewport(0, 0, allocation.width, allocation.height); - glEnable (GL_SCISSOR_TEST); - glScissor (ev->area.x, - allocation.height - ev->area.height - ev->area.y, - ev->area.width, ev->area.height); + glEnable(GL_SCISSOR_TEST); + glScissor(ev->area.x, allocation.height - ev->area.height - ev->area.y, ev->area.width, ev->area.height); - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); - glOrtho (0, allocation.width, allocation.height, 0, 0, 100); - glMatrixMode (GL_MODELVIEW); - glLoadIdentity (); - glTranslatef (0.0f, 0.0f, -Z_NEAR); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, allocation.width, allocation.height, 0, 0, 100); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0f, 0.0f, -Z_NEAR); - glClearColor (gport->bg_color.red / 65535., - gport->bg_color.green / 65535., - gport->bg_color.blue / 65535., - 1.); - glStencilMask (~0); - glClearStencil (0); - glClear (GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + glClearColor(gport->bg_color.red / 65535., gport->bg_color.green / 65535., gport->bg_color.blue / 65535., 1.); + glStencilMask(~0); + glClearStencil(0); + glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - hidgl_reset_stencil_usage (); + hidgl_reset_stencil_usage(); - /* call the drawing routine */ - hidgl_init_triangle_array (&buffer); - ghid_invalidate_current_gc (); - glPushMatrix (); - glScalef ((gport->view.flip_x ? -1. : 1.) / gport->view.coord_per_px, - (gport->view.flip_y ? -1. : 1.) / gport->view.coord_per_px, 1); - glTranslatef (gport->view.flip_x ? gport->view.x0 - PCB->MaxWidth : - -gport->view.x0, - gport->view.flip_y ? gport->view.y0 - PCB->MaxHeight : - -gport->view.y0, 0); - hid_expose_callback (&ghid_hid, NULL, &pinout->element); - hidgl_flush_triangles (&buffer); - glPopMatrix (); + /* call the drawing routine */ + hidgl_init_triangle_array(&buffer); + ghid_invalidate_current_gc(); + glPushMatrix(); + glScalef((gport->view.flip_x ? -1. : 1.) / gport->view.coord_per_px, + (gport->view.flip_y ? -1. : 1.) / gport->view.coord_per_px, 1); + glTranslatef(gport->view.flip_x ? gport->view.x0 - PCB->MaxWidth : + -gport->view.x0, gport->view.flip_y ? gport->view.y0 - PCB->MaxHeight : -gport->view.y0, 0); + hid_expose_callback(&ghid_hid, NULL, &pinout->element); + hidgl_flush_triangles(&buffer); + glPopMatrix(); - if (gdk_gl_drawable_is_double_buffered (pGlDrawable)) - gdk_gl_drawable_swap_buffers (pGlDrawable); - else - glFlush (); + if (gdk_gl_drawable_is_double_buffered(pGlDrawable)) + gdk_gl_drawable_swap_buffers(pGlDrawable); + else + glFlush(); - /* end drawing to current GL-context */ - gport->render_priv->in_context = false; - gdk_gl_drawable_gl_end (pGlDrawable); + /* end drawing to current GL-context */ + gport->render_priv->in_context = false; + gdk_gl_drawable_gl_end(pGlDrawable); - gport->view = save_view; - gport->width = save_width; - gport->height = save_height; + gport->view = save_view; + gport->width = save_width; + gport->height = save_height; - return FALSE; + return FALSE; } -GdkPixmap * -ghid_render_pixmap (int cx, int cy, double zoom, int width, int height, int depth) +GdkPixmap *ghid_render_pixmap(int cx, int cy, double zoom, int width, int height, int depth) { - GdkGLConfig *glconfig; - GdkPixmap *pixmap; - GdkGLPixmap *glpixmap; - GdkGLContext* glcontext; - GdkGLDrawable* gldrawable; - view_data save_view; - int save_width, save_height; - BoxType region; + GdkGLConfig *glconfig; + GdkPixmap *pixmap; + GdkGLPixmap *glpixmap; + GdkGLContext *glcontext; + GdkGLDrawable *gldrawable; + view_data save_view; + int save_width, save_height; + BoxType region; - save_view = gport->view; - save_width = gport->width; - save_height = gport->height; + save_view = gport->view; + save_width = gport->width; + save_height = gport->height; - /* Setup rendering context for drawing routines - */ + /* Setup rendering context for drawing routines + */ - glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB | - GDK_GL_MODE_STENCIL | - GDK_GL_MODE_SINGLE); + glconfig = gdk_gl_config_new_by_mode(GDK_GL_MODE_RGB | GDK_GL_MODE_STENCIL | GDK_GL_MODE_SINGLE); - pixmap = gdk_pixmap_new (NULL, width, height, depth); - glpixmap = gdk_pixmap_set_gl_capability (pixmap, glconfig, NULL); - gldrawable = GDK_GL_DRAWABLE (glpixmap); - glcontext = gdk_gl_context_new (gldrawable, NULL, FALSE, GDK_GL_RGBA_TYPE); + pixmap = gdk_pixmap_new(NULL, width, height, depth); + glpixmap = gdk_pixmap_set_gl_capability(pixmap, glconfig, NULL); + gldrawable = GDK_GL_DRAWABLE(glpixmap); + glcontext = gdk_gl_context_new(gldrawable, NULL, FALSE, GDK_GL_RGBA_TYPE); - /* Setup zoom factor for drawing routines */ + /* Setup zoom factor for drawing routines */ - gport->view.coord_per_px = zoom; - gport->width = width; - gport->height = height; - gport->view.width = width * gport->view.coord_per_px; - gport->view.height = height * gport->view.coord_per_px; - gport->view.x0 = gport->view.flip_x ? PCB->MaxWidth - cx : cx; - gport->view.x0 -= gport->view.height / 2; - gport->view.y0 = gport->view.flip_y ? PCB->MaxHeight - cy : cy; - gport->view.y0 -= gport->view.width / 2; + gport->view.coord_per_px = zoom; + gport->width = width; + gport->height = height; + gport->view.width = width * gport->view.coord_per_px; + gport->view.height = height * gport->view.coord_per_px; + gport->view.x0 = gport->view.flip_x ? PCB->MaxWidth - cx : cx; + gport->view.x0 -= gport->view.height / 2; + gport->view.y0 = gport->view.flip_y ? PCB->MaxHeight - cy : cy; + gport->view.y0 -= gport->view.width / 2; - /* make GL-context "current" */ - if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext)) { - return NULL; - } - gport->render_priv->in_context = true; + /* make GL-context "current" */ + if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext)) { + return NULL; + } + gport->render_priv->in_context = true; - glEnable (GL_BLEND); - glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glViewport (0, 0, width, height); + glViewport(0, 0, width, height); - glEnable (GL_SCISSOR_TEST); - glScissor (0, 0, width, height); + glEnable(GL_SCISSOR_TEST); + glScissor(0, 0, width, height); - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); - glOrtho (0, width, height, 0, 0, 100); - glMatrixMode (GL_MODELVIEW); - glLoadIdentity (); - glTranslatef (0.0f, 0.0f, -Z_NEAR); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, width, height, 0, 0, 100); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0f, 0.0f, -Z_NEAR); - glClearColor (gport->bg_color.red / 65535., - gport->bg_color.green / 65535., - gport->bg_color.blue / 65535., - 1.); - glStencilMask (~0); - glClearStencil (0); - glClear (GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - hidgl_reset_stencil_usage (); + glClearColor(gport->bg_color.red / 65535., gport->bg_color.green / 65535., gport->bg_color.blue / 65535., 1.); + glStencilMask(~0); + glClearStencil(0); + glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + hidgl_reset_stencil_usage(); - /* call the drawing routine */ - hidgl_init_triangle_array (&buffer); - ghid_invalidate_current_gc (); - glPushMatrix (); - glScalef ((gport->view.flip_x ? -1. : 1.) / gport->view.coord_per_px, - (gport->view.flip_y ? -1. : 1.) / gport->view.coord_per_px, 1); - glTranslatef (gport->view.flip_x ? gport->view.x0 - PCB->MaxWidth : - -gport->view.x0, - gport->view.flip_y ? gport->view.y0 - PCB->MaxHeight : - -gport->view.y0, 0); + /* call the drawing routine */ + hidgl_init_triangle_array(&buffer); + ghid_invalidate_current_gc(); + glPushMatrix(); + glScalef((gport->view.flip_x ? -1. : 1.) / gport->view.coord_per_px, + (gport->view.flip_y ? -1. : 1.) / gport->view.coord_per_px, 1); + glTranslatef(gport->view.flip_x ? gport->view.x0 - PCB->MaxWidth : + -gport->view.x0, gport->view.flip_y ? gport->view.y0 - PCB->MaxHeight : -gport->view.y0, 0); - region.X1 = MIN(Px(0), Px(gport->width + 1)); - region.Y1 = MIN(Py(0), Py(gport->height + 1)); - region.X2 = MAX(Px(0), Px(gport->width + 1)); - region.Y2 = MAX(Py(0), Py(gport->height + 1)); + region.X1 = MIN(Px(0), Px(gport->width + 1)); + region.Y1 = MIN(Py(0), Py(gport->height + 1)); + region.X2 = MAX(Px(0), Px(gport->width + 1)); + region.Y2 = MAX(Py(0), Py(gport->height + 1)); - region.X1 = MAX (0, MIN (PCB->MaxWidth, region.X1)); - region.X2 = MAX (0, MIN (PCB->MaxWidth, region.X2)); - region.Y1 = MAX (0, MIN (PCB->MaxHeight, region.Y1)); - region.Y2 = MAX (0, MIN (PCB->MaxHeight, region.Y2)); + region.X1 = MAX(0, MIN(PCB->MaxWidth, region.X1)); + region.X2 = MAX(0, MIN(PCB->MaxWidth, region.X2)); + region.Y1 = MAX(0, MIN(PCB->MaxHeight, region.Y1)); + region.Y2 = MAX(0, MIN(PCB->MaxHeight, region.Y2)); - hid_expose_callback (&ghid_hid, ®ion, NULL); - hidgl_flush_triangles (&buffer); - glPopMatrix (); + hid_expose_callback(&ghid_hid, ®ion, NULL); + hidgl_flush_triangles(&buffer); + glPopMatrix(); - glFlush (); + glFlush(); - /* end drawing to current GL-context */ - gport->render_priv->in_context = false; - gdk_gl_drawable_gl_end (gldrawable); + /* end drawing to current GL-context */ + gport->render_priv->in_context = false; + gdk_gl_drawable_gl_end(gldrawable); - gdk_pixmap_unset_gl_capability (pixmap); + gdk_pixmap_unset_gl_capability(pixmap); - g_object_unref (glconfig); - g_object_unref (glcontext); + g_object_unref(glconfig); + g_object_unref(glcontext); - gport->view = save_view; - gport->width = save_width; - gport->height = save_height; + gport->view = save_view; + gport->width = save_width; + gport->height = save_height; - return pixmap; + return pixmap; } -HID * -ghid_request_debug_draw (void) +HID *ghid_request_debug_draw(void) { - GHidPort *port = gport; - GtkWidget *widget = port->drawing_area; - GtkAllocation allocation; + GHidPort *port = gport; + GtkWidget *widget = port->drawing_area; + GtkAllocation allocation; - gtk_widget_get_allocation (widget, &allocation); + gtk_widget_get_allocation(widget, &allocation); - ghid_start_drawing (port); + ghid_start_drawing(port); - glViewport (0, 0, allocation.width, allocation.height); + glViewport(0, 0, allocation.width, allocation.height); - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); - glOrtho (0, allocation.width, allocation.height, 0, 0, 100); - glMatrixMode (GL_MODELVIEW); - glLoadIdentity (); - glTranslatef (0.0f, 0.0f, -Z_NEAR); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, allocation.width, allocation.height, 0, 0, 100); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0f, 0.0f, -Z_NEAR); - hidgl_init_triangle_array (&buffer); - ghid_invalidate_current_gc (); + hidgl_init_triangle_array(&buffer); + ghid_invalidate_current_gc(); - /* Setup stenciling */ - glDisable (GL_STENCIL_TEST); + /* Setup stenciling */ + glDisable(GL_STENCIL_TEST); - glPushMatrix (); - glScalef ((port->view.flip_x ? -1. : 1.) / port->view.coord_per_px, - (port->view.flip_y ? -1. : 1.) / port->view.coord_per_px, - (port->view.flip_x == port->view.flip_y) ? 1. : -1.); - glTranslatef (port->view.flip_x ? port->view.x0 - PCB->MaxWidth : - -port->view.x0, - port->view.flip_y ? port->view.y0 - PCB->MaxHeight : - -port->view.y0, 0); + glPushMatrix(); + glScalef((port->view.flip_x ? -1. : 1.) / port->view.coord_per_px, + (port->view.flip_y ? -1. : 1.) / port->view.coord_per_px, (port->view.flip_x == port->view.flip_y) ? 1. : -1.); + glTranslatef(port->view.flip_x ? port->view.x0 - PCB->MaxWidth : + -port->view.x0, port->view.flip_y ? port->view.y0 - PCB->MaxHeight : -port->view.y0, 0); - return &ghid_hid; + return &ghid_hid; } -void -ghid_flush_debug_draw (void) +void ghid_flush_debug_draw(void) { - GtkWidget *widget = gport->drawing_area; - GdkGLDrawable *pGlDrawable = gtk_widget_get_gl_drawable (widget); + GtkWidget *widget = gport->drawing_area; + GdkGLDrawable *pGlDrawable = gtk_widget_get_gl_drawable(widget); - hidgl_flush_triangles (&buffer); + hidgl_flush_triangles(&buffer); - if (gdk_gl_drawable_is_double_buffered (pGlDrawable)) - gdk_gl_drawable_swap_buffers (pGlDrawable); - else - glFlush (); + if (gdk_gl_drawable_is_double_buffered(pGlDrawable)) + gdk_gl_drawable_swap_buffers(pGlDrawable); + else + glFlush(); } -void -ghid_finish_debug_draw (void) +void ghid_finish_debug_draw(void) { - hidgl_flush_triangles (&buffer); - glPopMatrix (); + hidgl_flush_triangles(&buffer); + glPopMatrix(); - ghid_end_drawing (gport); + ghid_end_drawing(gport); } -bool -ghid_event_to_pcb_coords (int event_x, int event_y, Coord *pcb_x, Coord *pcb_y) +bool ghid_event_to_pcb_coords(int event_x, int event_y, Coord * pcb_x, Coord * pcb_y) { - *pcb_x = EVENT_TO_PCB_X (event_x); - *pcb_y = EVENT_TO_PCB_Y (event_y); + *pcb_x = EVENT_TO_PCB_X(event_x); + *pcb_y = EVENT_TO_PCB_Y(event_y); - return true; + return true; } -bool -ghid_pcb_to_event_coords (Coord pcb_x, Coord pcb_y, int *event_x, int *event_y) +bool ghid_pcb_to_event_coords(Coord pcb_x, Coord pcb_y, int *event_x, int *event_y) { - *event_x = DRAW_X (pcb_x); - *event_y = DRAW_Y (pcb_y); + *event_x = DRAW_X(pcb_x); + *event_y = DRAW_Y(pcb_y); - return true; + return true; } -#define LEAD_USER_WIDTH 0.2 /* millimeters */ -#define LEAD_USER_PERIOD (1000 / 20) /* 20fps (in ms) */ -#define LEAD_USER_VELOCITY 3. /* millimeters per second */ +#define LEAD_USER_WIDTH 0.2 /* millimeters */ +#define LEAD_USER_PERIOD (1000 / 20) /* 20fps (in ms) */ +#define LEAD_USER_VELOCITY 3. /* millimeters per second */ #define LEAD_USER_ARC_COUNT 3 -#define LEAD_USER_ARC_SEPARATION 3. /* millimeters */ -#define LEAD_USER_INITIAL_RADIUS 10. /* millimetres */ +#define LEAD_USER_ARC_SEPARATION 3. /* millimeters */ +#define LEAD_USER_INITIAL_RADIUS 10. /* millimetres */ #define LEAD_USER_COLOR_R 1. #define LEAD_USER_COLOR_G 1. #define LEAD_USER_COLOR_B 0. -static void -draw_lead_user (render_priv *priv) +static void draw_lead_user(render_priv * priv) { - int i; - double radius = priv->lead_user_radius; - double width = MM_TO_COORD (LEAD_USER_WIDTH); - double separation = MM_TO_COORD (LEAD_USER_ARC_SEPARATION); + int i; + double radius = priv->lead_user_radius; + double width = MM_TO_COORD(LEAD_USER_WIDTH); + double separation = MM_TO_COORD(LEAD_USER_ARC_SEPARATION); - if (!priv->lead_user) - return; + if (!priv->lead_user) + return; - glPushAttrib (GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT); - glEnable (GL_COLOR_LOGIC_OP); - glLogicOp (GL_XOR); - glColor3f (LEAD_USER_COLOR_R, LEAD_USER_COLOR_G,LEAD_USER_COLOR_B); + glPushAttrib(GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT); + glEnable(GL_COLOR_LOGIC_OP); + glLogicOp(GL_XOR); + glColor3f(LEAD_USER_COLOR_R, LEAD_USER_COLOR_G, LEAD_USER_COLOR_B); - /* arcs at the approrpriate radii */ + /* arcs at the approrpriate radii */ - for (i = 0; i < LEAD_USER_ARC_COUNT; i++, radius -= separation) - { - if (radius < width) - radius += MM_TO_COORD (LEAD_USER_INITIAL_RADIUS); + for (i = 0; i < LEAD_USER_ARC_COUNT; i++, radius -= separation) { + if (radius < width) + radius += MM_TO_COORD(LEAD_USER_INITIAL_RADIUS); - /* Draw an arc at radius */ - hidgl_draw_arc (width, priv->lead_user_x, priv->lead_user_y, - radius, radius, 0, 360, gport->view.coord_per_px); - } + /* Draw an arc at radius */ + hidgl_draw_arc(width, priv->lead_user_x, priv->lead_user_y, radius, radius, 0, 360, gport->view.coord_per_px); + } - hidgl_flush_triangles (&buffer); - glPopAttrib (); + hidgl_flush_triangles(&buffer); + glPopAttrib(); } -gboolean -lead_user_cb (gpointer data) +gboolean lead_user_cb(gpointer data) { - render_priv *priv = data; - Coord step; - double elapsed_time; + render_priv *priv = data; + Coord step; + double elapsed_time; - /* Queue a redraw */ - ghid_invalidate_all (); + /* Queue a redraw */ + ghid_invalidate_all(); - /* Update radius */ - elapsed_time = g_timer_elapsed (priv->lead_user_timer, NULL); - g_timer_start (priv->lead_user_timer); + /* Update radius */ + elapsed_time = g_timer_elapsed(priv->lead_user_timer, NULL); + g_timer_start(priv->lead_user_timer); - step = MM_TO_COORD (LEAD_USER_VELOCITY * elapsed_time); - if (priv->lead_user_radius > step) - priv->lead_user_radius -= step; - else - priv->lead_user_radius = MM_TO_COORD (LEAD_USER_INITIAL_RADIUS); + step = MM_TO_COORD(LEAD_USER_VELOCITY * elapsed_time); + if (priv->lead_user_radius > step) + priv->lead_user_radius -= step; + else + priv->lead_user_radius = MM_TO_COORD(LEAD_USER_INITIAL_RADIUS); - return TRUE; + return TRUE; } -void -ghid_lead_user_to_location (Coord x, Coord y) +void ghid_lead_user_to_location(Coord x, Coord y) { - render_priv *priv = gport->render_priv; + render_priv *priv = gport->render_priv; - ghid_cancel_lead_user (); + ghid_cancel_lead_user(); - priv->lead_user = true; - priv->lead_user_x = x; - priv->lead_user_y = y; - priv->lead_user_radius = MM_TO_COORD (LEAD_USER_INITIAL_RADIUS); - priv->lead_user_timeout = g_timeout_add (LEAD_USER_PERIOD, lead_user_cb, priv); - priv->lead_user_timer = g_timer_new (); + priv->lead_user = true; + priv->lead_user_x = x; + priv->lead_user_y = y; + priv->lead_user_radius = MM_TO_COORD(LEAD_USER_INITIAL_RADIUS); + priv->lead_user_timeout = g_timeout_add(LEAD_USER_PERIOD, lead_user_cb, priv); + priv->lead_user_timer = g_timer_new(); } -void -ghid_cancel_lead_user (void) +void ghid_cancel_lead_user(void) { - render_priv *priv = gport->render_priv; + render_priv *priv = gport->render_priv; - if (priv->lead_user_timeout) - g_source_remove (priv->lead_user_timeout); + if (priv->lead_user_timeout) + g_source_remove(priv->lead_user_timeout); - if (priv->lead_user_timer) - g_timer_destroy (priv->lead_user_timer); + if (priv->lead_user_timer) + g_timer_destroy(priv->lead_user_timer); - if (priv->lead_user) - ghid_invalidate_all (); + if (priv->lead_user) + ghid_invalidate_all(); - priv->lead_user_timeout = 0; - priv->lead_user_timer = NULL; - priv->lead_user = false; + priv->lead_user_timeout = 0; + priv->lead_user_timer = NULL; + priv->lead_user = false; } Index: trunk/src/hid/gtk/gtkhid-main.c =================================================================== --- trunk/src/hid/gtk/gtkhid-main.c (revision 1021) +++ trunk/src/hid/gtk/gtkhid-main.c (revision 1022) @@ -26,54 +26,51 @@ #endif -RCSID ("$Id$"); +RCSID("$Id$"); -static void -pan_common (GHidPort *port) +static void pan_common(GHidPort * port) { - int event_x, event_y; + int event_x, event_y; - /* We need to fix up the PCB coordinates corresponding to the last - * event so convert it back to event coordinates temporarily. */ - ghid_pcb_to_event_coords (gport->pcb_x, gport->pcb_y, &event_x, &event_y); + /* We need to fix up the PCB coordinates corresponding to the last + * event so convert it back to event coordinates temporarily. */ + ghid_pcb_to_event_coords(gport->pcb_x, gport->pcb_y, &event_x, &event_y); - /* Don't pan so far the board is completely off the screen */ - port->view.x0 = MAX (-port->view.width, port->view.x0); - port->view.y0 = MAX (-port->view.height, port->view.y0); - port->view.x0 = MIN ( port->view.x0, PCB->MaxWidth); - port->view.y0 = MIN ( port->view.y0, PCB->MaxHeight); + /* Don't pan so far the board is completely off the screen */ + port->view.x0 = MAX(-port->view.width, port->view.x0); + port->view.y0 = MAX(-port->view.height, port->view.y0); + port->view.x0 = MIN(port->view.x0, PCB->MaxWidth); + port->view.y0 = MIN(port->view.y0, PCB->MaxHeight); - /* Fix up noted event coordinates to match where we clamped. Alternatively - * we could call ghid_note_event_location (NULL); to get a new pointer - * location, but this costs us an xserver round-trip (on X11 platforms) - */ - ghid_event_to_pcb_coords (event_x, event_y, &gport->pcb_x, &gport->pcb_y); + /* Fix up noted event coordinates to match where we clamped. Alternatively + * we could call ghid_note_event_location (NULL); to get a new pointer + * location, but this costs us an xserver round-trip (on X11 platforms) + */ + ghid_event_to_pcb_coords(event_x, event_y, &gport->pcb_x, &gport->pcb_y); - ghidgui->adjustment_changed_holdoff = TRUE; - gtk_range_set_value (GTK_RANGE (ghidgui->h_range), gport->view.x0); - gtk_range_set_value (GTK_RANGE (ghidgui->v_range), gport->view.y0); - ghidgui->adjustment_changed_holdoff = FALSE; + ghidgui->adjustment_changed_holdoff = TRUE; + gtk_range_set_value(GTK_RANGE(ghidgui->h_range), gport->view.x0); + gtk_range_set_value(GTK_RANGE(ghidgui->v_range), gport->view.y0); + ghidgui->adjustment_changed_holdoff = FALSE; - ghid_port_ranges_changed(); + ghid_port_ranges_changed(); } -static void -ghid_pan_view_abs (Coord pcb_x, Coord pcb_y, int widget_x, int widget_y) +static void ghid_pan_view_abs(Coord pcb_x, Coord pcb_y, int widget_x, int widget_y) { - gport->view.x0 = SIDE_X (pcb_x) - widget_x * gport->view.coord_per_px; - gport->view.y0 = SIDE_Y (pcb_y) - widget_y * gport->view.coord_per_px; + gport->view.x0 = SIDE_X(pcb_x) - widget_x * gport->view.coord_per_px; + gport->view.y0 = SIDE_Y(pcb_y) - widget_y * gport->view.coord_per_px; - pan_common (gport); + pan_common(gport); } -void -ghid_pan_view_rel (Coord dx, Coord dy) +void ghid_pan_view_rel(Coord dx, Coord dy) { - gport->view.x0 += dx; - gport->view.y0 += dy; + gport->view.x0 += dx; + gport->view.y0 += dy; - pan_common (gport); + pan_common(gport); } @@ -84,81 +81,71 @@ * gport->view_width and gport->view_height are in PCB coordinates */ -#define ALLOW_ZOOM_OUT_BY 10 /* Arbitrary, and same as the lesstif HID */ -static void -ghid_zoom_view_abs (Coord center_x, Coord center_y, double new_zoom) +#define ALLOW_ZOOM_OUT_BY 10 /* Arbitrary, and same as the lesstif HID */ +static void ghid_zoom_view_abs(Coord center_x, Coord center_y, double new_zoom) { - double min_zoom, max_zoom; - double xtmp, ytmp; + double min_zoom, max_zoom; + double xtmp, ytmp; - /* Limit the "minimum" zoom constant (maximum zoom), at 1 pixel per PCB - * unit, and set the "maximum" zoom constant (minimum zoom), such that - * the entire board just fits inside the viewport - */ - min_zoom = 1; - max_zoom = MAX (PCB->MaxWidth / gport->width, - PCB->MaxHeight / gport->height) * ALLOW_ZOOM_OUT_BY; - new_zoom = MIN (MAX (min_zoom, new_zoom), max_zoom); + /* Limit the "minimum" zoom constant (maximum zoom), at 1 pixel per PCB + * unit, and set the "maximum" zoom constant (minimum zoom), such that + * the entire board just fits inside the viewport + */ + min_zoom = 1; + max_zoom = MAX(PCB->MaxWidth / gport->width, PCB->MaxHeight / gport->height) * ALLOW_ZOOM_OUT_BY; + new_zoom = MIN(MAX(min_zoom, new_zoom), max_zoom); - if (gport->view.coord_per_px == new_zoom) - return; + if (gport->view.coord_per_px == new_zoom) + return; - xtmp = (SIDE_X (center_x) - gport->view.x0) / (double)gport->view.width; - ytmp = (SIDE_Y (center_y) - gport->view.y0) / (double)gport->view.height; + xtmp = (SIDE_X(center_x) - gport->view.x0) / (double) gport->view.width; + ytmp = (SIDE_Y(center_y) - gport->view.y0) / (double) gport->view.height; - gport->view.coord_per_px = new_zoom; - pixel_slop = new_zoom; - ghid_port_ranges_scale (); + gport->view.coord_per_px = new_zoom; + pixel_slop = new_zoom; + ghid_port_ranges_scale(); - gport->view.x0 = SIDE_X (center_x) - xtmp * gport->view.width; - gport->view.y0 = SIDE_Y (center_y) - ytmp * gport->view.height; + gport->view.x0 = SIDE_X(center_x) - xtmp * gport->view.width; + gport->view.y0 = SIDE_Y(center_y) - ytmp * gport->view.height; - pan_common (gport); + pan_common(gport); - ghid_set_status_line_label (); + ghid_set_status_line_label(); } -static void -ghid_zoom_view_rel (Coord center_x, Coord center_y, double factor) +static void ghid_zoom_view_rel(Coord center_x, Coord center_y, double factor) { - ghid_zoom_view_abs (center_x, center_y, gport->view.coord_per_px * factor); + ghid_zoom_view_abs(center_x, center_y, gport->view.coord_per_px * factor); } -static void -ghid_zoom_view_fit (void) +static void ghid_zoom_view_fit(void) { - ghid_pan_view_abs (SIDE_X (0), SIDE_Y (0), 0, 0); - ghid_zoom_view_abs (SIDE_X (0), SIDE_Y (0), - MAX (PCB->MaxWidth / gport->width, - PCB->MaxHeight / gport->height)); + ghid_pan_view_abs(SIDE_X(0), SIDE_Y(0), 0, 0); + ghid_zoom_view_abs(SIDE_X(0), SIDE_Y(0), MAX(PCB->MaxWidth / gport->width, PCB->MaxHeight / gport->height)); } -static void -ghid_flip_view (Coord center_x, Coord center_y, bool flip_x, bool flip_y) +static void ghid_flip_view(Coord center_x, Coord center_y, bool flip_x, bool flip_y) { - int widget_x, widget_y; + int widget_x, widget_y; - /* Work out where on the screen the flip point is */ - ghid_pcb_to_event_coords (center_x, center_y, &widget_x, &widget_y); + /* Work out where on the screen the flip point is */ + ghid_pcb_to_event_coords(center_x, center_y, &widget_x, &widget_y); - gport->view.flip_x = gport->view.flip_x != flip_x; - gport->view.flip_y = gport->view.flip_y != flip_y; + gport->view.flip_x = gport->view.flip_x != flip_x; + gport->view.flip_y = gport->view.flip_y != flip_y; - /* Pan the board so the center location remains in the same place */ - ghid_pan_view_abs (center_x, center_y, widget_x, widget_y); + /* Pan the board so the center location remains in the same place */ + ghid_pan_view_abs(center_x, center_y, widget_x, widget_y); - ghid_invalidate_all (); + ghid_invalidate_all(); } /* ------------------------------------------------------------ */ -static const char zoom_syntax[] = -"Zoom()\n" -"Zoom(factor)"; +static const char zoom_syntax[] = "Zoom()\n" "Zoom(factor)"; -static const char zoom_help[] = -N_("Various zoom factor changes."); +static const char zoom_help[] = N_("Various zoom factor changes."); /* %start-doc actions Zoom Changes the zoom (magnification) of the view of the board. If no @@ -198,658 +185,579 @@ %end-doc */ -static int -Zoom (int argc, char **argv, Coord x, Coord y) +static int Zoom(int argc, char **argv, Coord x, Coord y) { - const char *vp; - double v; + const char *vp; + double v; - if (argc > 1) - AFAIL (zoom); + if (argc > 1) + AFAIL(zoom); - if (argc < 1) - { - ghid_zoom_view_fit (); - return 0; - } + if (argc < 1) { + ghid_zoom_view_fit(); + return 0; + } - vp = argv[0]; - if (*vp == '+' || *vp == '-' || *vp == '=') - vp++; - v = g_ascii_strtod (vp, 0); - if (v <= 0) - return 1; - switch (argv[0][0]) - { - case '-': - ghid_zoom_view_rel (x, y, 1 / v); - break; - default: - case '+': - ghid_zoom_view_rel (x, y, v); - break; - case '=': - ghid_zoom_view_abs (x, y, v); - break; - } + vp = argv[0]; + if (*vp == '+' || *vp == '-' || *vp == '=') + vp++; + v = g_ascii_strtod(vp, 0); + if (v <= 0) + return 1; + switch (argv[0][0]) { + case '-': + ghid_zoom_view_rel(x, y, 1 / v); + break; + default: + case '+': + ghid_zoom_view_rel(x, y, v); + break; + case '=': + ghid_zoom_view_abs(x, y, v); + break; + } - return 0; + return 0; } /* ------------------------------------------------------------ */ -void -ghid_calibrate (double xval, double yval) +void ghid_calibrate(double xval, double yval) { - printf (_("ghid_calibrate() -- not implemented\n")); + printf(_("ghid_calibrate() -- not implemented\n")); } static int ghid_gui_is_up = 0; -void -ghid_notify_gui_is_up () +void ghid_notify_gui_is_up() { - ghid_gui_is_up = 1; + ghid_gui_is_up = 1; } -int -ghid_shift_is_pressed () +int ghid_shift_is_pressed() { - GdkModifierType mask; - GHidPort *out = &ghid_port; + GdkModifierType mask; + GHidPort *out = &ghid_port; - if( ! ghid_gui_is_up ) - return 0; + if (!ghid_gui_is_up) + return 0; - gdk_window_get_pointer (gtk_widget_get_window (out->drawing_area), - NULL, NULL, &mask); - return (mask & GDK_SHIFT_MASK) ? TRUE : FALSE; + gdk_window_get_pointer(gtk_widget_get_window(out->drawing_area), NULL, NULL, &mask); + return (mask & GDK_SHIFT_MASK) ? TRUE : FALSE; } -int -ghid_control_is_pressed () +int ghid_control_is_pressed() { - GdkModifierType mask; - GHidPort *out = &ghid_port; + GdkModifierType mask; + GHidPort *out = &ghid_port; - if( ! ghid_gui_is_up ) - return 0; + if (!ghid_gui_is_up) + return 0; - gdk_window_get_pointer (gtk_widget_get_window (out->drawing_area), - NULL, NULL, &mask); - return (mask & GDK_CONTROL_MASK) ? TRUE : FALSE; + gdk_window_get_pointer(gtk_widget_get_window(out->drawing_area), NULL, NULL, &mask); + return (mask & GDK_CONTROL_MASK) ? TRUE : FALSE; } -int -ghid_mod1_is_pressed () +int ghid_mod1_is_pressed() { - GdkModifierType mask; - GHidPort *out = &ghid_port; + GdkModifierType mask; + GHidPort *out = &ghid_port; - if( ! ghid_gui_is_up ) - return 0; + if (!ghid_gui_is_up) + return 0; - gdk_window_get_pointer (gtk_widget_get_window (out->drawing_area), - NULL, NULL, &mask); + gdk_window_get_pointer(gtk_widget_get_window(out->drawing_area), NULL, NULL, &mask); #ifdef __APPLE__ - return (mask & ( 1 << 13 ) ) ? TRUE : FALSE; /* The option key is not MOD1, although it should be...*/ + return (mask & (1 << 13)) ? TRUE : FALSE; /* The option key is not MOD1, although it should be... */ #else - return (mask & GDK_MOD1_MASK) ? TRUE : FALSE; + return (mask & GDK_MOD1_MASK) ? TRUE : FALSE; #endif } -void -ghid_set_crosshair (int x, int y, int action) +void ghid_set_crosshair(int x, int y, int action) { - GdkDisplay *display; - GdkScreen *screen; - int offset_x, offset_y; - int widget_x, widget_y; - int pointer_x, pointer_y; - Coord pcb_x, pcb_y; + GdkDisplay *display; + GdkScreen *screen; + int offset_x, offset_y; + int widget_x, widget_y; + int pointer_x, pointer_y; + Coord pcb_x, pcb_y; - if (gport->crosshair_x != x || gport->crosshair_y != y) - { - ghid_set_cursor_position_labels (); - gport->crosshair_x = x; - gport->crosshair_y = y; + if (gport->crosshair_x != x || gport->crosshair_y != y) { + ghid_set_cursor_position_labels(); + gport->crosshair_x = x; + gport->crosshair_y = y; - /* FIXME - does this trigger the idle_proc stuff? It is in the - * lesstif HID. Maybe something is needed here? - * - * need_idle_proc (); - */ - } + /* FIXME - does this trigger the idle_proc stuff? It is in the + * lesstif HID. Maybe something is needed here? + * + * need_idle_proc (); + */ + } - if (action != HID_SC_PAN_VIEWPORT && - action != HID_SC_WARP_POINTER) - return; + if (action != HID_SC_PAN_VIEWPORT && action != HID_SC_WARP_POINTER) + return; - /* Find out where the drawing area is on the screen. gdk_display_get_pointer - * and gdk_display_warp_pointer work relative to the whole display, whilst - * our coordinates are relative to the drawing area origin. - */ - gdk_window_get_origin (gtk_widget_get_window (gport->drawing_area), - &offset_x, &offset_y); - display = gdk_display_get_default (); + /* Find out where the drawing area is on the screen. gdk_display_get_pointer + * and gdk_display_warp_pointer work relative to the whole display, whilst + * our coordinates are relative to the drawing area origin. + */ + gdk_window_get_origin(gtk_widget_get_window(gport->drawing_area), &offset_x, &offset_y); + display = gdk_display_get_default(); - switch (action) { - case HID_SC_PAN_VIEWPORT: - /* Pan the board in the viewport so that the crosshair (who's location - * relative on the board was set above) lands where the pointer is. - * We pass the request to pan a particular point on the board to a - * given widget coordinate of the viewport into the rendering code - */ + switch (action) { + case HID_SC_PAN_VIEWPORT: + /* Pan the board in the viewport so that the crosshair (who's location + * relative on the board was set above) lands where the pointer is. + * We pass the request to pan a particular point on the board to a + * given widget coordinate of the viewport into the rendering code + */ - /* Find out where the pointer is relative to the display */ - gdk_display_get_pointer (display, NULL, &pointer_x, &pointer_y, NULL); + /* Find out where the pointer is relative to the display */ + gdk_display_get_pointer(display, NULL, &pointer_x, &pointer_y, NULL); - widget_x = pointer_x - offset_x; - widget_y = pointer_y - offset_y; + widget_x = pointer_x - offset_x; + widget_y = pointer_y - offset_y; - ghid_event_to_pcb_coords (widget_x, widget_y, &pcb_x, &pcb_y); - ghid_pan_view_abs (pcb_x, pcb_y, widget_x, widget_y); + ghid_event_to_pcb_coords(widget_x, widget_y, &pcb_x, &pcb_y); + ghid_pan_view_abs(pcb_x, pcb_y, widget_x, widget_y); - /* Just in case we couldn't pan the board the whole way, - * we warp the pointer to where the crosshair DID land. - */ - /* Fall through */ + /* Just in case we couldn't pan the board the whole way, + * we warp the pointer to where the crosshair DID land. + */ + /* Fall through */ - case HID_SC_WARP_POINTER: - screen = gdk_display_get_default_screen (display); + case HID_SC_WARP_POINTER: + screen = gdk_display_get_default_screen(display); - ghid_pcb_to_event_coords (x, y, &widget_x, &widget_y); + ghid_pcb_to_event_coords(x, y, &widget_x, &widget_y); - pointer_x = offset_x + widget_x; - pointer_y = offset_y + widget_y; + pointer_x = offset_x + widget_x; + pointer_y = offset_y + widget_y; - gdk_display_warp_pointer (display, screen, pointer_x, pointer_y); + gdk_display_warp_pointer(display, screen, pointer_x, pointer_y); - break; - } + break; + } } -typedef struct -{ - void (*func) (hidval); - guint id; - hidval user_data; -} -GuiTimer; +typedef struct { + void (*func) (hidval); + guint id; + hidval user_data; +} GuiTimer; - /* We need a wrapper around the hid timer because a gtk timer needs - | to return FALSE else the timer will be restarted. - */ -static gboolean -ghid_timer (GuiTimer * timer) + /* We need a wrapper around the hid timer because a gtk timer needs + | to return FALSE else the timer will be restarted. + */ +static gboolean ghid_timer(GuiTimer * timer) { - (*timer->func) (timer->user_data); - ghid_mode_cursor (Settings.Mode); - return FALSE; /* Turns timer off */ + (*timer->func) (timer->user_data); + ghid_mode_cursor(Settings.Mode); + return FALSE; /* Turns timer off */ } -hidval -ghid_add_timer (void (*func) (hidval user_data), - unsigned long milliseconds, hidval user_data) +hidval ghid_add_timer(void (*func) (hidval user_data), unsigned long milliseconds, hidval user_data) { - GuiTimer *timer = g_new0 (GuiTimer, 1); - hidval ret; + GuiTimer *timer = g_new0(GuiTimer, 1); + hidval ret; - timer->func = func; - timer->user_data = user_data; - timer->id = g_timeout_add (milliseconds, (GSourceFunc) ghid_timer, timer); - ret.ptr = (void *) timer; - return ret; + timer->func = func; + timer->user_data = user_data; + timer->id = g_timeout_add(milliseconds, (GSourceFunc) ghid_timer, timer); + ret.ptr = (void *) timer; + return ret; } -void -ghid_stop_timer (hidval timer) +void ghid_stop_timer(hidval timer) { - void *ptr = timer.ptr; + void *ptr = timer.ptr; - g_source_remove (((GuiTimer *) ptr)->id); - g_free( ptr ); + g_source_remove(((GuiTimer *) ptr)->id); + g_free(ptr); } -typedef struct -{ - void (*func) ( hidval, int, unsigned int, hidval ); - hidval user_data; - int fd; - GIOChannel *channel; - gint id; -} -GuiWatch; +typedef struct { + void (*func) (hidval, int, unsigned int, hidval); + hidval user_data; + int fd; + GIOChannel *channel; + gint id; +} GuiWatch; - /* We need a wrapper around the hid file watch to pass the correct flags - */ -static gboolean -ghid_watch (GIOChannel *source, GIOCondition condition, gpointer data) + /* We need a wrapper around the hid file watch to pass the correct flags + */ +static gboolean ghid_watch(GIOChannel * source, GIOCondition condition, gpointer data) { - unsigned int pcb_condition = 0; - hidval x; - GuiWatch *watch = (GuiWatch*)data; + unsigned int pcb_condition = 0; + hidval x; + GuiWatch *watch = (GuiWatch *) data; - if (condition & G_IO_IN) - pcb_condition |= PCB_WATCH_READABLE; - if (condition & G_IO_OUT) - pcb_condition |= PCB_WATCH_WRITABLE; - if (condition & G_IO_ERR) - pcb_condition |= PCB_WATCH_ERROR; - if (condition & G_IO_HUP) - pcb_condition |= PCB_WATCH_HANGUP; + if (condition & G_IO_IN) + pcb_condition |= PCB_WATCH_READABLE; + if (condition & G_IO_OUT) + pcb_condition |= PCB_WATCH_WRITABLE; + if (condition & G_IO_ERR) + pcb_condition |= PCB_WATCH_ERROR; + if (condition & G_IO_HUP) + pcb_condition |= PCB_WATCH_HANGUP; - x.ptr = (void *) watch; - watch->func (x, watch->fd, pcb_condition, watch->user_data); - ghid_mode_cursor (Settings.Mode); + x.ptr = (void *) watch; + watch->func(x, watch->fd, pcb_condition, watch->user_data); + ghid_mode_cursor(Settings.Mode); - return TRUE; /* Leave watch on */ + return TRUE; /* Leave watch on */ } hidval -ghid_watch_file (int fd, unsigned int condition, void (*func) (hidval watch, int fd, unsigned int condition, hidval user_data), - hidval user_data) +ghid_watch_file(int fd, unsigned int condition, void (*func) (hidval watch, int fd, unsigned int condition, hidval user_data), + hidval user_data) { - GuiWatch *watch = g_new0 (GuiWatch, 1); - hidval ret; - unsigned int glib_condition = 0; + GuiWatch *watch = g_new0(GuiWatch, 1); + hidval ret; + unsigned int glib_condition = 0; - if (condition & PCB_WATCH_READABLE) - glib_condition |= G_IO_IN; - if (condition & PCB_WATCH_WRITABLE) - glib_condition |= G_IO_OUT; - if (condition & PCB_WATCH_ERROR) - glib_condition |= G_IO_ERR; - if (condition & PCB_WATCH_HANGUP) - glib_condition |= G_IO_HUP; + if (condition & PCB_WATCH_READABLE) + glib_condition |= G_IO_IN; + if (condition & PCB_WATCH_WRITABLE) + glib_condition |= G_IO_OUT; + if (condition & PCB_WATCH_ERROR) + glib_condition |= G_IO_ERR; + if (condition & PCB_WATCH_HANGUP) + glib_condition |= G_IO_HUP; - watch->func = func; - watch->user_data = user_data; - watch->fd = fd; - watch->channel = g_io_channel_unix_new( fd ); - watch->id = g_io_add_watch( watch->channel, (GIOCondition)glib_condition, ghid_watch, watch ); + watch->func = func; + watch->user_data = user_data; + watch->fd = fd; + watch->channel = g_io_channel_unix_new(fd); + watch->id = g_io_add_watch(watch->channel, (GIOCondition) glib_condition, ghid_watch, watch); - ret.ptr = (void *) watch; - return ret; + ret.ptr = (void *) watch; + return ret; } -void -ghid_unwatch_file (hidval data) +void ghid_unwatch_file(hidval data) { - GuiWatch *watch = (GuiWatch*)data.ptr; + GuiWatch *watch = (GuiWatch *) data.ptr; - g_io_channel_shutdown( watch->channel, TRUE, NULL ); - g_io_channel_unref( watch->channel ); - g_free( watch ); + g_io_channel_shutdown(watch->channel, TRUE, NULL); + g_io_channel_unref(watch->channel); + g_free(watch); } -typedef struct -{ - GSource source; - void (*func) (hidval user_data); - hidval user_data; +typedef struct { + GSource source; + void (*func) (hidval user_data); + hidval user_data; } BlockHookSource; -static gboolean ghid_block_hook_prepare (GSource *source, - gint *timeout); -static gboolean ghid_block_hook_check (GSource *source); -static gboolean ghid_block_hook_dispatch (GSource *source, - GSourceFunc callback, - gpointer user_data); +static gboolean ghid_block_hook_prepare(GSource * source, gint * timeout); +static gboolean ghid_block_hook_check(GSource * source); +static gboolean ghid_block_hook_dispatch(GSource * source, GSourceFunc callback, gpointer user_data); static GSourceFuncs ghid_block_hook_funcs = { - ghid_block_hook_prepare, - ghid_block_hook_check, - ghid_block_hook_dispatch, - NULL /* No destroy notification */ + ghid_block_hook_prepare, + ghid_block_hook_check, + ghid_block_hook_dispatch, + NULL /* No destroy notification */ }; -static gboolean -ghid_block_hook_prepare (GSource *source, - gint *timeout) +static gboolean ghid_block_hook_prepare(GSource * source, gint * timeout) { - hidval data = ((BlockHookSource *)source)->user_data; - ((BlockHookSource *)source)->func( data ); - return FALSE; + hidval data = ((BlockHookSource *) source)->user_data; + ((BlockHookSource *) source)->func(data); + return FALSE; } -static gboolean -ghid_block_hook_check (GSource *source) +static gboolean ghid_block_hook_check(GSource * source) { - return FALSE; + return FALSE; } -static gboolean -ghid_block_hook_dispatch (GSource *source, - GSourceFunc callback, - gpointer user_data) +static gboolean ghid_block_hook_dispatch(GSource * source, GSourceFunc callback, gpointer user_data) { - return FALSE; + return FALSE; } -static hidval -ghid_add_block_hook (void (*func) (hidval data), - hidval user_data) +static hidval ghid_add_block_hook(void (*func) (hidval data), hidval user_data) { - hidval ret; - BlockHookSource *source; + hidval ret; + BlockHookSource *source; - source = (BlockHookSource *)g_source_new (&ghid_block_hook_funcs, sizeof( BlockHookSource )); + source = (BlockHookSource *) g_source_new(&ghid_block_hook_funcs, sizeof(BlockHookSource)); - source->func = func; - source->user_data = user_data; + source->func = func; + source->user_data = user_data; - g_source_attach ((GSource *)source, NULL); + g_source_attach((GSource *) source, NULL); - ret.ptr = (void *) source; - return ret; + ret.ptr = (void *) source; + return ret; } -static void -ghid_stop_block_hook (hidval mlpoll) +static void ghid_stop_block_hook(hidval mlpoll) { - GSource *source = (GSource *)mlpoll.ptr; - g_source_destroy( source ); + GSource *source = (GSource *) mlpoll.ptr; + g_source_destroy(source); } -int -ghid_confirm_dialog (const char *msg, ...) +int ghid_confirm_dialog(const char *msg, ...) { - int rv = 0; - va_list ap; - char *cancelmsg = NULL, *okmsg = NULL; - static gint x = -1, y = -1; - GtkWidget *dialog; - GHidPort *out = &ghid_port; + int rv = 0; + va_list ap; + char *cancelmsg = NULL, *okmsg = NULL; + static gint x = -1, y = -1; + GtkWidget *dialog; + GHidPort *out = &ghid_port; - va_start (ap, msg); - cancelmsg = va_arg (ap, char *); - okmsg = va_arg (ap, char *); - va_end (ap); + va_start(ap, msg); + cancelmsg = va_arg(ap, char *); + okmsg = va_arg(ap, char *); + va_end(ap); - if (!cancelmsg) - { - cancelmsg = _("_Cancel"); - okmsg = _("_OK"); - } + if (!cancelmsg) { + cancelmsg = _("_Cancel"); + okmsg = _("_OK"); + } - dialog = gtk_message_dialog_new (GTK_WINDOW (out->top_window), - (GtkDialogFlags) (GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT), - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_NONE, - "%s", msg); - gtk_dialog_add_button (GTK_DIALOG (dialog), - cancelmsg, GTK_RESPONSE_CANCEL); - if (okmsg) - { - gtk_dialog_add_button (GTK_DIALOG (dialog), - okmsg, GTK_RESPONSE_OK); - } + dialog = gtk_message_dialog_new(GTK_WINDOW(out->top_window), + (GtkDialogFlags) (GTK_DIALOG_MODAL | + GTK_DIALOG_DESTROY_WITH_PARENT), + GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, "%s", msg); + gtk_dialog_add_button(GTK_DIALOG(dialog), cancelmsg, GTK_RESPONSE_CANCEL); + if (okmsg) { + gtk_dialog_add_button(GTK_DIALOG(dialog), okmsg, GTK_RESPONSE_OK); + } - if(x != -1) { - gtk_window_move(GTK_WINDOW (dialog), x, y); - } + if (x != -1) { + gtk_window_move(GTK_WINDOW(dialog), x, y); + } - if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) - rv = 1; + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) + rv = 1; - gtk_window_get_position(GTK_WINDOW (dialog), &x, &y); + gtk_window_get_position(GTK_WINDOW(dialog), &x, &y); - gtk_widget_destroy (dialog); - return rv; + gtk_widget_destroy(dialog); + return rv; } -int -ghid_close_confirm_dialog () +int ghid_close_confirm_dialog() { - switch (ghid_dialog_close_confirm ()) - { - case GUI_DIALOG_CLOSE_CONFIRM_SAVE: - { - if (hid_actionl ("Save", NULL)) - { /* Save failed */ - return 0; /* Cancel */ - } else { - return 1; /* Close */ - } - } - case GUI_DIALOG_CLOSE_CONFIRM_NOSAVE: - { - return 1; /* Close */ - } - case GUI_DIALOG_CLOSE_CONFIRM_CANCEL: - default: - { - return 0; /* Cancel */ - } - } + switch (ghid_dialog_close_confirm()) { + case GUI_DIALOG_CLOSE_CONFIRM_SAVE: + { + if (hid_actionl("Save", NULL)) { /* Save failed */ + return 0; /* Cancel */ + } + else { + return 1; /* Close */ + } + } + case GUI_DIALOG_CLOSE_CONFIRM_NOSAVE: + { + return 1; /* Close */ + } + case GUI_DIALOG_CLOSE_CONFIRM_CANCEL: + default: + { + return 0; /* Cancel */ + } + } } -void -ghid_report_dialog (const char *title, const char *msg) +void ghid_report_dialog(const char *title, const char *msg) { - ghid_dialog_report (title, msg); + ghid_dialog_report(title, msg); } -char * -ghid_prompt_for (const char *msg, const char *default_string) +char *ghid_prompt_for(const char *msg, const char *default_string) { - char *rv; + char *rv; - rv = ghid_dialog_input (msg, default_string); - return rv; + rv = ghid_dialog_input(msg, default_string); + return rv; } /* FIXME -- implement a proper file select dialog */ #ifdef FIXME -char * -ghid_fileselect (const char *title, const char *descr, - char *default_file, char *default_ext, - const char *history_tag, int flags) +char *ghid_fileselect(const char *title, const char *descr, + char *default_file, char *default_ext, const char *history_tag, int flags) { - char *rv; + char *rv; - rv = ghid_dialog_input (title, default_file); - return rv; + rv = ghid_dialog_input(title, default_file); + return rv; } #endif -void -ghid_show_item (void *item) +void ghid_show_item(void *item) { - ghid_pinout_window_show (&ghid_port, (ElementTypePtr) item); + ghid_pinout_window_show(&ghid_port, (ElementTypePtr) item); } -void -ghid_beep () +void ghid_beep() { - gdk_beep (); + gdk_beep(); } -struct progress_dialog -{ - GtkWidget *dialog; - GtkWidget *message; - GtkWidget *progress; - gint response_id; - GMainLoop *loop; - gboolean destroyed; - gboolean started; - GTimer *timer; +struct progress_dialog { + GtkWidget *dialog; + GtkWidget *message; + GtkWidget *progress; + gint response_id; + GMainLoop *loop; + gboolean destroyed; + gboolean started; + GTimer *timer; - gulong response_handler; - gulong destroy_handler; - gulong delete_handler; + gulong response_handler; + gulong destroy_handler; + gulong delete_handler; }; -static void -run_response_handler (GtkDialog *dialog, - gint response_id, - gpointer data) +static void run_response_handler(GtkDialog * dialog, gint response_id, gpointer data) { - struct progress_dialog *pd = data; + struct progress_dialog *pd = data; - pd->response_id = response_id; + pd->response_id = response_id; } -static gint -run_delete_handler (GtkDialog *dialog, - GdkEventAny *event, - gpointer data) +static gint run_delete_handler(GtkDialog * dialog, GdkEventAny * event, gpointer data) { - struct progress_dialog *pd = data; + struct progress_dialog *pd = data; - pd->response_id = GTK_RESPONSE_DELETE_EVENT; + pd->response_id = GTK_RESPONSE_DELETE_EVENT; - return TRUE; /* Do not destroy */ + return TRUE; /* Do not destroy */ } -static void -run_destroy_handler (GtkDialog *dialog, gpointer data) +static void run_destroy_handler(GtkDialog * dialog, gpointer data) { - struct progress_dialog *pd = data; + struct progress_dialog *pd = data; - pd->destroyed = TRUE; + pd->destroyed = TRUE; } -static struct progress_dialog * -make_progress_dialog (void) +static struct progress_dialog *make_progress_dialog(void) { - struct progress_dialog *pd; - GtkWidget *content_area; - GtkWidget *alignment; - GtkWidget *vbox; + struct progress_dialog *pd; + GtkWidget *content_area; + GtkWidget *alignment; + GtkWidget *vbox; - pd = g_new0 (struct progress_dialog, 1); - pd->response_id = GTK_RESPONSE_NONE; + pd = g_new0(struct progress_dialog, 1); + pd->response_id = GTK_RESPONSE_NONE; - pd->dialog = gtk_dialog_new_with_buttons (_("Progress"), - GTK_WINDOW (gport->top_window), - /* Modal so nothing else can get events whilst - the main mainloop isn't running */ - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, - NULL); + pd->dialog = gtk_dialog_new_with_buttons(_("Progress"), GTK_WINDOW(gport->top_window), + /* Modal so nothing else can get events whilst + the main mainloop isn't running */ + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); - gtk_window_set_deletable (GTK_WINDOW (pd->dialog), FALSE); - gtk_window_set_skip_pager_hint (GTK_WINDOW (pd->dialog), TRUE); - gtk_window_set_skip_taskbar_hint (GTK_WINDOW (pd->dialog), TRUE); - gtk_widget_set_size_request (pd->dialog, 300, -1); + gtk_window_set_deletable(GTK_WINDOW(pd->dialog), FALSE); + gtk_window_set_skip_pager_hint(GTK_WINDOW(pd->dialog), TRUE); + gtk_window_set_skip_taskbar_hint(GTK_WINDOW(pd->dialog), TRUE); + gtk_widget_set_size_request(pd->dialog, 300, -1); - pd->message = gtk_label_new (NULL); - gtk_misc_set_alignment (GTK_MISC (pd->message), 0., 0.); + pd->message = gtk_label_new(NULL); + gtk_misc_set_alignment(GTK_MISC(pd->message), 0., 0.); - pd->progress = gtk_progress_bar_new (); - gtk_widget_set_size_request (pd->progress, -1, 26); + pd->progress = gtk_progress_bar_new(); + gtk_widget_set_size_request(pd->progress, -1, 26); - vbox = gtk_vbox_new (false, 0); - gtk_box_pack_start (GTK_BOX (vbox), pd->message, true, true, 8); - gtk_box_pack_start (GTK_BOX (vbox), pd->progress, false, true, 8); + vbox = gtk_vbox_new(false, 0); + gtk_box_pack_start(GTK_BOX(vbox), pd->message, true, true, 8); + gtk_box_pack_start(GTK_BOX(vbox), pd->progress, false, true, 8); - alignment = gtk_alignment_new (0., 0., 1., 1.); - gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 8, 8, 8, 8); - gtk_container_add (GTK_CONTAINER (alignment), vbox); + alignment = gtk_alignment_new(0., 0., 1., 1.); + gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 8, 8, 8, 8); + gtk_container_add(GTK_CONTAINER(alignment), vbox); - content_area = gtk_dialog_get_content_area (GTK_DIALOG (pd->dialog)); - gtk_box_pack_start (GTK_BOX (content_area), alignment, true, true, 0); + content_area = gtk_dialog_get_content_area(GTK_DIALOG(pd->dialog)); + gtk_box_pack_start(GTK_BOX(content_area), alignment, true, true, 0); - gtk_widget_show_all (alignment); + gtk_widget_show_all(alignment); - g_object_ref (pd->dialog); - gtk_window_present (GTK_WINDOW (pd->dialog)); + g_object_ref(pd->dialog); + gtk_window_present(GTK_WINDOW(pd->dialog)); - pd->response_handler = - g_signal_connect (pd->dialog, "response", - G_CALLBACK (run_response_handler), pd); - pd->delete_handler = - g_signal_connect (pd->dialog, "delete-event", - G_CALLBACK (run_delete_handler), pd); - pd->destroy_handler = - g_signal_connect (pd->dialog, "destroy", - G_CALLBACK (run_destroy_handler), pd); + pd->response_handler = g_signal_connect(pd->dialog, "response", G_CALLBACK(run_response_handler), pd); + pd->delete_handler = g_signal_connect(pd->dialog, "delete-event", G_CALLBACK(run_delete_handler), pd); + pd->destroy_handler = g_signal_connect(pd->dialog, "destroy", G_CALLBACK(run_destroy_handler), pd); - pd->loop = g_main_loop_new (NULL, FALSE); - pd->timer = g_timer_new (); + pd->loop = g_main_loop_new(NULL, FALSE); + pd->timer = g_timer_new(); - return pd; + return pd; } -static void -destroy_progress_dialog (struct progress_dialog *pd) +static void destroy_progress_dialog(struct progress_dialog *pd) { - if (pd == NULL) - return; + if (pd == NULL) + return; - if (!pd->destroyed) - { - g_signal_handler_disconnect (pd->dialog, pd->response_handler); - g_signal_handler_disconnect (pd->dialog, pd->delete_handler); - g_signal_handler_disconnect (pd->dialog, pd->destroy_handler); - } + if (!pd->destroyed) { + g_signal_handler_disconnect(pd->dialog, pd->response_handler); + g_signal_handler_disconnect(pd->dialog, pd->delete_handler); + g_signal_handler_disconnect(pd->dialog, pd->destroy_handler); + } - g_timer_destroy (pd->timer); - g_object_unref (pd->dialog); - g_main_loop_unref (pd->loop); + g_timer_destroy(pd->timer); + g_object_unref(pd->dialog); + g_main_loop_unref(pd->loop); - gtk_widget_destroy (pd->dialog); + gtk_widget_destroy(pd->dialog); - pd->loop = NULL; - g_free (pd); + pd->loop = NULL; + g_free(pd); } -static void -handle_progress_dialog_events (struct progress_dialog *pd) +static void handle_progress_dialog_events(struct progress_dialog *pd) { - GMainContext * context = g_main_loop_get_context (pd->loop); + GMainContext *context = g_main_loop_get_context(pd->loop); - /* Process events */ - while (g_main_context_pending (context)) - { - g_main_context_iteration (context, FALSE); - } + /* Process events */ + while (g_main_context_pending(context)) { + g_main_context_iteration(context, FALSE); + } } -#define MIN_TIME_SEPARATION (50./1000.) /* 50ms */ -static int -ghid_progress (int so_far, int total, const char *message) +#define MIN_TIME_SEPARATION (50./1000.) /* 50ms */ +static int ghid_progress(int so_far, int total, const char *message) { - static struct progress_dialog *pd = NULL; + static struct progress_dialog *pd = NULL; - /* If we are finished, destroy any dialog */ - if (so_far == 0 && total == 0 && message == NULL) - { - destroy_progress_dialog (pd); - pd = NULL; - return 0; - } + /* If we are finished, destroy any dialog */ + if (so_far == 0 && total == 0 && message == NULL) { + destroy_progress_dialog(pd); + pd = NULL; + return 0; + } - if (pd == NULL) - pd = make_progress_dialog (); + if (pd == NULL) + pd = make_progress_dialog(); - /* We don't want to keep the underlying process too busy whilst we - * process events. If we get called quickly after the last progress - * update, wait a little bit before we respond - perhaps the next - * time progress is reported. + /* We don't want to keep the underlying process too busy whilst we + * process events. If we get called quickly after the last progress + * update, wait a little bit before we respond - perhaps the next + * time progress is reported. - * The exception here is that we always want to process the first - * batch of events after having shown the dialog for the first time - */ - if (pd->started && g_timer_elapsed (pd->timer, NULL) < MIN_TIME_SEPARATION) - return 0; + * The exception here is that we always want to process the first + * batch of events after having shown the dialog for the first time + */ + if (pd->started && g_timer_elapsed(pd->timer, NULL) < MIN_TIME_SEPARATION) + return 0; - gtk_label_set_text (GTK_LABEL (pd->message), message); - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (pd->progress), - (double)so_far / (double)total); + gtk_label_set_text(GTK_LABEL(pd->message), message); + gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pd->progress), (double) so_far / (double) total); - handle_progress_dialog_events (pd); - g_timer_start (pd->timer); + handle_progress_dialog_events(pd); + g_timer_start(pd->timer); - pd->started = TRUE; + pd->started = TRUE; - return (pd->response_id == GTK_RESPONSE_CANCEL || - pd->response_id == GTK_RESPONSE_DELETE_EVENT) ? 1 : 0; + return (pd->response_id == GTK_RESPONSE_CANCEL || pd->response_id == GTK_RESPONSE_DELETE_EVENT) ? 1 : 0; } /* ---------------------------------------------------------------------- */ @@ -856,9 +764,9 @@ typedef struct { - GtkWidget *del; - GtkWidget *w_name; - GtkWidget *w_value; + GtkWidget *del; + GtkWidget *w_name; + GtkWidget *w_value; } AttrRow; static AttrRow *attr_row = 0; @@ -867,219 +775,186 @@ static AttributeListType *attributes_list; static GtkWidget *attributes_dialog, *attr_table; -static void attributes_delete_callback (GtkWidget *w, void *v); +static void attributes_delete_callback(GtkWidget * w, void *v); #define GA_RESPONSE_REVERT 1 #define GA_RESPONSE_NEW 2 -static void -ghid_attr_set_table_size () +static void ghid_attr_set_table_size() { - gtk_table_resize (GTK_TABLE (attr_table), attr_num_rows > 0 ? attr_num_rows : 1, 3); + gtk_table_resize(GTK_TABLE(attr_table), attr_num_rows > 0 ? attr_num_rows : 1, 3); } -static void -ghid_attributes_need_rows (int new_max) +static void ghid_attributes_need_rows(int new_max) { - if (attr_max_rows < new_max) - { - if (attr_row) - attr_row = (AttrRow *) realloc (attr_row, new_max * sizeof(AttrRow)); - else - attr_row = (AttrRow *) malloc (new_max * sizeof(AttrRow)); - } - while (attr_max_rows < new_max) - { - /* add [attr_max_rows] */ - attr_row[attr_max_rows].del = gtk_button_new_with_label ("del"); - gtk_table_attach (GTK_TABLE (attr_table), attr_row[attr_max_rows].del, - 0, 1, - attr_max_rows, attr_max_rows+1, - (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), - GTK_FILL, - 0, 0); - g_signal_connect (G_OBJECT (attr_row[attr_max_rows].del), "clicked", - G_CALLBACK (attributes_delete_callback), GINT_TO_POINTER (attr_max_rows) ); + if (attr_max_rows < new_max) { + if (attr_row) + attr_row = (AttrRow *) realloc(attr_row, new_max * sizeof(AttrRow)); + else + attr_row = (AttrRow *) malloc(new_max * sizeof(AttrRow)); + } + while (attr_max_rows < new_max) { + /* add [attr_max_rows] */ + attr_row[attr_max_rows].del = gtk_button_new_with_label("del"); + gtk_table_attach(GTK_TABLE(attr_table), attr_row[attr_max_rows].del, + 0, 1, attr_max_rows, attr_max_rows + 1, (GtkAttachOptions) (GTK_FILL | GTK_EXPAND), GTK_FILL, 0, 0); + g_signal_connect(G_OBJECT(attr_row[attr_max_rows].del), "clicked", + G_CALLBACK(attributes_delete_callback), GINT_TO_POINTER(attr_max_rows)); - attr_row[attr_max_rows].w_name = gtk_entry_new (); - gtk_table_attach (GTK_TABLE (attr_table), attr_row[attr_max_rows].w_name, - 1, 2, - attr_max_rows, attr_max_rows+1, - (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), - GTK_FILL, - 0, 0); + attr_row[attr_max_rows].w_name = gtk_entry_new(); + gtk_table_attach(GTK_TABLE(attr_table), attr_row[attr_max_rows].w_name, + 1, 2, attr_max_rows, attr_max_rows + 1, (GtkAttachOptions) (GTK_FILL | GTK_EXPAND), GTK_FILL, 0, 0); - attr_row[attr_max_rows].w_value = gtk_entry_new (); - gtk_table_attach (GTK_TABLE (attr_table), attr_row[attr_max_rows].w_value, - 2, 3, - attr_max_rows, attr_max_rows+1, - (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), - GTK_FILL, - 0, 0); + attr_row[attr_max_rows].w_value = gtk_entry_new(); + gtk_table_attach(GTK_TABLE(attr_table), attr_row[attr_max_rows].w_value, + 2, 3, attr_max_rows, attr_max_rows + 1, (GtkAttachOptions) (GTK_FILL | GTK_EXPAND), GTK_FILL, 0, 0); - attr_max_rows ++; - } + attr_max_rows++; + } - /* Manage any previously unused rows we now need to show. */ - while (attr_num_rows < new_max) - { - /* manage attr_num_rows */ - gtk_widget_show (attr_row[attr_num_rows].del); - gtk_widget_show (attr_row[attr_num_rows].w_name); - gtk_widget_show (attr_row[attr_num_rows].w_value); - attr_num_rows ++; - } + /* Manage any previously unused rows we now need to show. */ + while (attr_num_rows < new_max) { + /* manage attr_num_rows */ + gtk_widget_show(attr_row[attr_num_rows].del); + gtk_widget_show(attr_row[attr_num_rows].w_name); + gtk_widget_show(attr_row[attr_num_rows].w_value); + attr_num_rows++; + } } -static void -ghid_attributes_revert () +static void ghid_attributes_revert() { - int i; + int i; - ghid_attributes_need_rows (attributes_list->Number); + ghid_attributes_need_rows(attributes_list->Number); - /* Unmanage any previously used rows we don't need. */ - while (attr_num_rows > attributes_list->Number) - { - attr_num_rows --; - gtk_widget_hide (attr_row[attr_num_rows].del); - gtk_widget_hide (attr_row[attr_num_rows].w_name); - gtk_widget_hide (attr_row[attr_num_rows].w_value); - } + /* Unmanage any previously used rows we don't need. */ + while (attr_num_rows > attributes_list->Number) { + attr_num_rows--; + gtk_widget_hide(attr_row[attr_num_rows].del); + gtk_widget_hide(attr_row[attr_num_rows].w_name); + gtk_widget_hide(attr_row[attr_num_rows].w_value); + } - /* Fill in values */ - for (i=0; iNumber; i++) - { - /* create row [i] */ - gtk_entry_set_text (GTK_ENTRY (attr_row[i].w_name), attributes_list->List[i].name); - gtk_entry_set_text (GTK_ENTRY (attr_row[i].w_value), attributes_list->List[i].value); + /* Fill in values */ + for (i = 0; i < attributes_list->Number; i++) { + /* create row [i] */ + gtk_entry_set_text(GTK_ENTRY(attr_row[i].w_name), attributes_list->List[i].name); + gtk_entry_set_text(GTK_ENTRY(attr_row[i].w_value), attributes_list->List[i].value); #if 0 #endif - } - ghid_attr_set_table_size (); + } + ghid_attr_set_table_size(); } -static void -attributes_delete_callback (GtkWidget *w, void *v) +static void attributes_delete_callback(GtkWidget * w, void *v) { - int i, n; + int i, n; - n = GPOINTER_TO_INT (v); + n = GPOINTER_TO_INT(v); - for (i=n; iNumber, 3, 0); + attr_table = gtk_table_new(attrs->Number, 3, 0); - content_area = gtk_dialog_get_content_area (GTK_DIALOG (attributes_dialog)); - gtk_box_pack_start (GTK_BOX (content_area), attr_table, FALSE, FALSE, 0); + content_area = gtk_dialog_get_content_area(GTK_DIALOG(attributes_dialog)); + gtk_box_pack_start(GTK_BOX(content_area), attr_table, FALSE, FALSE, 0); - gtk_widget_show (attr_table); + gtk_widget_show(attr_table); - ghid_attributes_revert (); + ghid_attributes_revert(); - while (1) - { - response = gtk_dialog_run (GTK_DIALOG (attributes_dialog)); + while (1) { + response = gtk_dialog_run(GTK_DIALOG(attributes_dialog)); - if (response == GTK_RESPONSE_CANCEL) - break; + if (response == GTK_RESPONSE_CANCEL) + break; - if (response == GTK_RESPONSE_OK) - { - int i; - /* Copy the values back */ - for (i=0; iNumber; i++) - { - if (attributes_list->List[i].name) - free (attributes_list->List[i].name); - if (attributes_list->List[i].value) - free (attributes_list->List[i].value); - } - if (attributes_list->Max < attr_num_rows) - { - int sz = attr_num_rows * sizeof (AttributeType); - if (attributes_list->List == NULL) - attributes_list->List = (AttributeType *) malloc (sz); - else - attributes_list->List = (AttributeType *) realloc (attributes_list->List, sz); - attributes_list->Max = attr_num_rows; - } - for (i=0; iList[i].name = strdup (gtk_entry_get_text (GTK_ENTRY (attr_row[i].w_name))); - attributes_list->List[i].value = strdup (gtk_entry_get_text (GTK_ENTRY (attr_row[i].w_value))); - attributes_list->Number = attr_num_rows; - } + if (response == GTK_RESPONSE_OK) { + int i; + /* Copy the values back */ + for (i = 0; i < attributes_list->Number; i++) { + if (attributes_list->List[i].name) + free(attributes_list->List[i].name); + if (attributes_list->List[i].value) + free(attributes_list->List[i].value); + } + if (attributes_list->Max < attr_num_rows) { + int sz = attr_num_rows * sizeof(AttributeType); + if (attributes_list->List == NULL) + attributes_list->List = (AttributeType *) malloc(sz); + else + attributes_list->List = (AttributeType *) realloc(attributes_list->List, sz); + attributes_list->Max = attr_num_rows; + } + for (i = 0; i < attr_num_rows; i++) { + attributes_list->List[i].name = strdup(gtk_entry_get_text(GTK_ENTRY(attr_row[i].w_name))); + attributes_list->List[i].value = strdup(gtk_entry_get_text(GTK_ENTRY(attr_row[i].w_value))); + attributes_list->Number = attr_num_rows; + } - break; - } + break; + } - if (response == GA_RESPONSE_REVERT) - { - /* Revert */ - ghid_attributes_revert (); - } + if (response == GA_RESPONSE_REVERT) { + /* Revert */ + ghid_attributes_revert(); + } - if (response == GA_RESPONSE_NEW) - { - ghid_attributes_need_rows (attr_num_rows + 1); /* also bumps attr_num_rows */ + if (response == GA_RESPONSE_NEW) { + ghid_attributes_need_rows(attr_num_rows + 1); /* also bumps attr_num_rows */ - gtk_entry_set_text (GTK_ENTRY (attr_row[attr_num_rows-1].w_name), ""); - gtk_entry_set_text (GTK_ENTRY (attr_row[attr_num_rows-1].w_value), ""); + gtk_entry_set_text(GTK_ENTRY(attr_row[attr_num_rows - 1].w_name), ""); + gtk_entry_set_text(GTK_ENTRY(attr_row[attr_num_rows - 1].w_value), ""); - ghid_attr_set_table_size (); + ghid_attr_set_table_size(); + } } - } - gtk_widget_destroy (attributes_dialog); - free (attr_row); - attr_row = NULL; + gtk_widget_destroy(attributes_dialog); + free(attr_row); + attr_row = NULL; } /* ---------------------------------------------------------------------- */ HID_DRC_GUI ghid_drc_gui = { - 1, /* log_drc_overview */ - 0, /* log_drc_details */ - ghid_drc_window_reset_message, - ghid_drc_window_append_violation, - ghid_drc_window_throw_dialog, + 1, /* log_drc_overview */ + 0, /* log_drc_details */ + ghid_drc_window_reset_message, + ghid_drc_window_append_violation, + ghid_drc_window_throw_dialog, }; -extern HID_Attribute *ghid_get_export_options (int *); +extern HID_Attribute *ghid_get_export_options(int *); /* ------------------------------------------------------------ @@ -1090,11 +965,9 @@ /* ------------------------------------------------------------ */ -static const char about_syntax[] = -"About()"; +static const char about_syntax[] = "About()"; -static const char about_help[] = -N_("Tell the user about this version of PCB."); +static const char about_help[] = N_("Tell the user about this version of PCB."); /* %start-doc actions About @@ -1104,19 +977,16 @@ %end-doc */ -static int -About (int argc, char **argv, Coord x, Coord y) +static int About(int argc, char **argv, Coord x, Coord y) { - ghid_dialog_about (); - return 0; + ghid_dialog_about(); + return 0; } /* ------------------------------------------------------------ */ -static const char getxy_syntax[] = -"GetXY()"; +static const char getxy_syntax[] = "GetXY()"; -static const char getxy_help[] = -N_("Get a coordinate."); +static const char getxy_help[] = N_("Get a coordinate."); /* %start-doc actions GetXY @@ -1124,172 +994,143 @@ %end-doc */ -static int -GetXY (int argc, char **argv, Coord x, Coord y) +static int GetXY(int argc, char **argv, Coord x, Coord y) { - return 0; + return 0; } /* ---------------------------------------------------------------------- */ -static int PointCursor (int argc, char **argv, Coord x, Coord y) +static int PointCursor(int argc, char **argv, Coord x, Coord y) { - if (!ghidgui) - return 0; + if (!ghidgui) + return 0; - if (argc > 0) - ghid_point_cursor (); - else - ghid_mode_cursor (Settings.Mode); - return 0; + if (argc > 0) + ghid_point_cursor(); + else + ghid_mode_cursor(Settings.Mode); + return 0; } /* ---------------------------------------------------------------------- */ -static int -RouteStylesChanged (int argc, char **argv, Coord x, Coord y) +static int RouteStylesChanged(int argc, char **argv, Coord x, Coord y) { - if (!ghidgui || !ghidgui->route_style_selector) - return 0; + if (!ghidgui || !ghidgui->route_style_selector) + return 0; - ghid_route_style_selector_sync - (GHID_ROUTE_STYLE_SELECTOR (ghidgui->route_style_selector), - Settings.LineThickness, Settings.ViaDrillingHole, - Settings.ViaThickness, Settings.Keepaway); + ghid_route_style_selector_sync + (GHID_ROUTE_STYLE_SELECTOR(ghidgui->route_style_selector), + Settings.LineThickness, Settings.ViaDrillingHole, Settings.ViaThickness, Settings.Keepaway); - return 0; + return 0; } /* ---------------------------------------------------------------------- */ -int -PCBChanged (int argc, char **argv, Coord x, Coord y) +int PCBChanged(int argc, char **argv, Coord x, Coord y) { - if (!ghidgui) - return 0; + if (!ghidgui) + return 0; - if (PCB != NULL) - ghid_window_set_name_label (PCB->Name); + if (PCB != NULL) + ghid_window_set_name_label(PCB->Name); - if (!gport->pixmap) - return 0; + if (!gport->pixmap) + return 0; - if (ghidgui->route_style_selector) - { - ghid_route_style_selector_empty - (GHID_ROUTE_STYLE_SELECTOR (ghidgui->route_style_selector)); - make_route_style_buttons - (GHID_ROUTE_STYLE_SELECTOR (ghidgui->route_style_selector)); - } - RouteStylesChanged (0, NULL, 0, 0); + if (ghidgui->route_style_selector) { + ghid_route_style_selector_empty(GHID_ROUTE_STYLE_SELECTOR(ghidgui->route_style_selector)); + make_route_style_buttons(GHID_ROUTE_STYLE_SELECTOR(ghidgui->route_style_selector)); + } + RouteStylesChanged(0, NULL, 0, 0); - ghid_port_ranges_scale (); - ghid_zoom_view_fit (); - ghid_sync_with_new_layout (); - return 0; + ghid_port_ranges_scale(); + ghid_zoom_view_fit(); + ghid_sync_with_new_layout(); + return 0; } /* ---------------------------------------------------------------------- */ -static int -LayerGroupsChanged (int argc, char **argv, Coord x, Coord y) +static int LayerGroupsChanged(int argc, char **argv, Coord x, Coord y) { - printf (_("LayerGroupsChanged -- not implemented\n")); - return 0; + printf(_("LayerGroupsChanged -- not implemented\n")); + return 0; } /* ---------------------------------------------------------------------- */ -static int -LibraryChanged (int argc, char **argv, Coord x, Coord y) +static int LibraryChanged(int argc, char **argv, Coord x, Coord y) { - /* No need to show the library window every time it changes... - * ghid_library_window_show (&ghid_port, FALSE); - */ - return 0; + /* No need to show the library window every time it changes... + * ghid_library_window_show (&ghid_port, FALSE); + */ + return 0; } /* ---------------------------------------------------------------------- */ -static int -Command (int argc, char **argv, Coord x, Coord y) +static int Command(int argc, char **argv, Coord x, Coord y) { - ghid_handle_user_command (TRUE); - return 0; + ghid_handle_user_command(TRUE); + return 0; } /* ---------------------------------------------------------------------- */ -static int -Load (int argc, char **argv, Coord x, Coord y) +static int Load(int argc, char **argv, Coord x, Coord y) { - char *function; - char *name = NULL; + char *function; + char *name = NULL; - static gchar *current_element_dir = NULL; - static gchar *current_layout_dir = NULL; - static gchar *current_netlist_dir = NULL; + static gchar *current_element_dir = NULL; + static gchar *current_layout_dir = NULL; + static gchar *current_netlist_dir = NULL; - if(!current_element_dir) - current_element_dir = get_current_dir_name(); - if(!current_layout_dir) - current_layout_dir = get_current_dir_name(); - if(!current_netlist_dir) - current_netlist_dir = get_current_dir_name(); + if (!current_element_dir) + current_element_dir = get_current_dir_name(); + if (!current_layout_dir) + current_layout_dir = get_current_dir_name(); + if (!current_netlist_dir) + current_netlist_dir = get_current_dir_name(); - /* we've been given the file name */ - if (argc > 1) - return hid_actionv ("LoadFrom", argc, argv); + /* we've been given the file name */ + if (argc > 1) + return hid_actionv("LoadFrom", argc, argv); - function = argc ? argv[0] : (char *)"Layout"; + function = argc ? argv[0] : (char *) "Layout"; - if (strcasecmp (function, "Netlist") == 0) - { - name = ghid_dialog_file_select_open (_("Load netlist file"), - ¤t_netlist_dir, - Settings.FilePath); - } - else if (strcasecmp (function, "ElementToBuffer") == 0) - { - name = ghid_dialog_file_select_open (_("Load element to buffer"), - ¤t_element_dir, - Settings.LibrarySearchPaths); - } - else if (strcasecmp (function, "LayoutToBuffer") == 0) - { - name = ghid_dialog_file_select_open (_("Load layout file to buffer"), - ¤t_layout_dir, - Settings.FilePath); - } - else if (strcasecmp (function, "Layout") == 0) - { - name = ghid_dialog_file_select_open (_("Load layout file"), - ¤t_layout_dir, - Settings.FilePath); - } + if (strcasecmp(function, "Netlist") == 0) { + name = ghid_dialog_file_select_open(_("Load netlist file"), ¤t_netlist_dir, Settings.FilePath); + } + else if (strcasecmp(function, "ElementToBuffer") == 0) { + name = ghid_dialog_file_select_open(_("Load element to buffer"), ¤t_element_dir, Settings.LibrarySearchPaths); + } + else if (strcasecmp(function, "LayoutToBuffer") == 0) { + name = ghid_dialog_file_select_open(_("Load layout file to buffer"), ¤t_layout_dir, Settings.FilePath); + } + else if (strcasecmp(function, "Layout") == 0) { + name = ghid_dialog_file_select_open(_("Load layout file"), ¤t_layout_dir, Settings.FilePath); + } - if (name) - { - if (Settings.verbose) - fprintf (stderr, "%s: Calling LoadFrom(%s, %s)\n", __FUNCTION__, - function, name); - hid_actionl ("LoadFrom", function, name, NULL); - g_free (name); - } + if (name) { + if (Settings.verbose) + fprintf(stderr, "%s: Calling LoadFrom(%s, %s)\n", __FUNCTION__, function, name); + hid_actionl("LoadFrom", function, name, NULL); + g_free(name); + } - return 0; + return 0; } /* ---------------------------------------------------------------------- */ static const char save_syntax[] = -"Save()\n" -"Save(Layout|LayoutAs)\n" -"Save(AllConnections|AllUnusedPins|ElementConnections)\n" -"Save(PasteBuffer)"; + "Save()\n" "Save(Layout|LayoutAs)\n" "Save(AllConnections|AllUnusedPins|ElementConnections)\n" "Save(PasteBuffer)"; -static const char save_help[] = -N_("Save layout and/or element data to a user-selected file."); +static const char save_help[] = N_("Save layout and/or element data to a user-selected file."); /* %start-doc actions Save @@ -1301,73 +1142,64 @@ %end-doc */ -static int -Save (int argc, char **argv, Coord x, Coord y) +static int Save(int argc, char **argv, Coord x, Coord y) { - char *function; - char *name; - char *prompt; + char *function; + char *name; + char *prompt; - static gchar *current_dir = NULL; + static gchar *current_dir = NULL; - if(!current_dir) - current_dir = get_current_dir_name(); + if (!current_dir) + current_dir = get_current_dir_name(); - if (argc > 1) - return hid_actionv ("SaveTo", argc, argv); + if (argc > 1) + return hid_actionv("SaveTo", argc, argv); - function = argc ? argv[0] : (char *)"Layout"; + function = argc ? argv[0] : (char *) "Layout"; - if (strcasecmp (function, "Layout") == 0) - if (PCB->Filename) - return hid_actionl ("SaveTo", "Layout", PCB->Filename, NULL); + if (strcasecmp(function, "Layout") == 0) + if (PCB->Filename) + return hid_actionl("SaveTo", "Layout", PCB->Filename, NULL); - if (strcasecmp (function, "PasteBuffer") == 0) - prompt = _("Save element as"); - else - prompt = _("Save layout as"); - - name = ghid_dialog_file_select_save (prompt, - ¤t_dir, - PCB->Filename, Settings.FilePath); - - if (name) - { - if (Settings.verbose) - fprintf (stderr, "%s: Calling SaveTo(%s, %s)\n", - __FUNCTION__, function, name); - - if (strcasecmp (function, "PasteBuffer") == 0) - hid_actionl ("PasteBuffer", "Save", name, NULL); - else - { - /* - * if we got this far and the function is Layout, then - * we really needed it to be a LayoutAs. Otherwise - * ActionSaveTo() will ignore the new file name we - * just obtained. - */ - if (strcasecmp (function, "Layout") == 0) - hid_actionl ("SaveTo", "LayoutAs", name, NULL); - else - hid_actionl ("SaveTo", function, name, NULL); + if (strcasecmp(function, "PasteBuffer") == 0) + prompt = _("Save element as"); + else + prompt = _("Save layout as"); + + name = ghid_dialog_file_select_save(prompt, ¤t_dir, PCB->Filename, Settings.FilePath); + + if (name) { + if (Settings.verbose) + fprintf(stderr, "%s: Calling SaveTo(%s, %s)\n", __FUNCTION__, function, name); + + if (strcasecmp(function, "PasteBuffer") == 0) + hid_actionl("PasteBuffer", "Save", name, NULL); + else { + /* + * if we got this far and the function is Layout, then + * we really needed it to be a LayoutAs. Otherwise + * ActionSaveTo() will ignore the new file name we + * just obtained. + */ + if (strcasecmp(function, "Layout") == 0) + hid_actionl("SaveTo", "LayoutAs", name, NULL); + else + hid_actionl("SaveTo", function, name, NULL); + } + g_free(name); } - g_free (name); - } - else - { - return 1; - } + else { + return 1; + } - return 0; + return 0; } /* ---------------------------------------------------------------------- */ -static const char swapsides_syntax[] = -"SwapSides(|v|h|r)"; +static const char swapsides_syntax[] = "SwapSides(|v|h|r)"; -static const char swapsides_help[] = -N_("Swaps the side of the board you're looking at."); +static const char swapsides_help[] = N_("Swaps the side of the board you're looking at."); /* %start-doc actions SwapSides @@ -1403,59 +1235,51 @@ %end-doc */ -static int -SwapSides (int argc, char **argv, Coord x, Coord y) +static int SwapSides(int argc, char **argv, Coord x, Coord y) { - int active_group = GetLayerGroupNumberByNumber (LayerStack[0]); - int comp_group = GetLayerGroupNumberByNumber (component_silk_layer); - int solder_group = GetLayerGroupNumberByNumber (solder_silk_layer); - bool comp_on = LAYER_PTR (PCB->LayerGroups.Entries[comp_group][0])->On; - bool solder_on = LAYER_PTR (PCB->LayerGroups.Entries[solder_group][0])->On; + int active_group = GetLayerGroupNumberByNumber(LayerStack[0]); + int comp_group = GetLayerGroupNumberByNumber(component_silk_layer); + int solder_group = GetLayerGroupNumberByNumber(solder_silk_layer); + bool comp_on = LAYER_PTR(PCB->LayerGroups.Entries[comp_group][0])->On; + bool solder_on = LAYER_PTR(PCB->LayerGroups.Entries[solder_group][0])->On; - if (argc > 0) - { - switch (argv[0][0]) { - case 'h': - case 'H': - ghid_flip_view (gport->pcb_x, gport->pcb_y, true, false); - break; - case 'v': - case 'V': - ghid_flip_view (gport->pcb_x, gport->pcb_y, false, true); - break; - case 'r': - case 'R': - ghid_flip_view (gport->pcb_x, gport->pcb_y, true, true); - Settings.ShowSolderSide = !Settings.ShowSolderSide; /* Swapped back below */ - break; - default: - return 1; - } - } + if (argc > 0) { + switch (argv[0][0]) { + case 'h': + case 'H': + ghid_flip_view(gport->pcb_x, gport->pcb_y, true, false); + break; + case 'v': + case 'V': + ghid_flip_view(gport->pcb_x, gport->pcb_y, false, true); + break; + case 'r': + case 'R': + ghid_flip_view(gport->pcb_x, gport->pcb_y, true, true); + Settings.ShowSolderSide = !Settings.ShowSolderSide; /* Swapped back below */ + break; + default: + return 1; + } + } - Settings.ShowSolderSide = !Settings.ShowSolderSide; + Settings.ShowSolderSide = !Settings.ShowSolderSide; - if ((active_group == comp_group && comp_on && !solder_on) || - (active_group == solder_group && solder_on && !comp_on)) - { - bool new_solder_vis = Settings.ShowSolderSide; + if ((active_group == comp_group && comp_on && !solder_on) || (active_group == solder_group && solder_on && !comp_on)) { + bool new_solder_vis = Settings.ShowSolderSide; - ChangeGroupVisibility (PCB->LayerGroups.Entries[comp_group][0], - !new_solder_vis, !new_solder_vis); - ChangeGroupVisibility (PCB->LayerGroups.Entries[solder_group][0], - new_solder_vis, new_solder_vis); - } + ChangeGroupVisibility(PCB->LayerGroups.Entries[comp_group][0], !new_solder_vis, !new_solder_vis); + ChangeGroupVisibility(PCB->LayerGroups.Entries[solder_group][0], new_solder_vis, new_solder_vis); + } - return 0; + return 0; } /* ------------------------------------------------------------ */ -static const char print_syntax[] = -"Print()"; +static const char print_syntax[] = "Print()"; -static const char print_help[] = -N_("Print the layout."); +static const char print_help[] = N_("Print the layout."); /* %start-doc actions Print @@ -1464,56 +1288,50 @@ %end-doc */ -static int -Print (int argc, char **argv, Coord x, Coord y) +static int Print(int argc, char **argv, Coord x, Coord y) { - HID **hids; - int i; - HID *printer = NULL; + HID **hids; + int i; + HID *printer = NULL; - hids = hid_enumerate (); - for (i = 0; hids[i]; i++) - { - if (hids[i]->printer) - printer = hids[i]; - } + hids = hid_enumerate(); + for (i = 0; hids[i]; i++) { + if (hids[i]->printer) + printer = hids[i]; + } - if (printer == NULL) - { - gui->log (_("Can't find a suitable printer HID")); - return -1; - } + if (printer == NULL) { + gui->log(_("Can't find a suitable printer HID")); + return -1; + } - /* check if layout is empty */ - if (!IsDataEmpty (PCB->Data)) - { - ghid_dialog_print (printer); - } - else - gui->log (_("Can't print empty layout")); + /* check if layout is empty */ + if (!IsDataEmpty(PCB->Data)) { + ghid_dialog_print(printer); + } + else + gui->log(_("Can't print empty layout")); - return 0; + return 0; } /* ------------------------------------------------------------ */ -static HID_Attribute -printer_calibrate_attrs[] = { - {N_("Enter Values here:"), "", - HID_Label, 0, 0, {0, 0, 0}, 0, 0}, - {N_("x-calibration"), N_("X scale for calibrating your printer"), - HID_Real, 0.5, 25, {0, 0, 1.00}, 0, 0}, - {N_("y-calibration"), N_("Y scale for calibrating your printer"), - HID_Real, 0.5, 25, {0, 0, 1.00}, 0, 0} +static HID_Attribute printer_calibrate_attrs[] = { + {N_("Enter Values here:"), "", + HID_Label, 0, 0, {0, 0, 0}, 0, 0}, + {N_("x-calibration"), N_("X scale for calibrating your printer"), + HID_Real, 0.5, 25, {0, 0, 1.00}, 0, 0}, + {N_("y-calibration"), N_("Y scale for calibrating your printer"), + HID_Real, 0.5, 25, {0, 0, 1.00}, 0, 0} }; + static HID_Attr_Val printer_calibrate_values[3]; -static const char printcalibrate_syntax[] = -"PrintCalibrate()"; +static const char printcalibrate_syntax[] = "PrintCalibrate()"; -static const char printcalibrate_help[] = -N_("Calibrate the printer."); +static const char printcalibrate_help[] = N_("Calibrate the printer."); /* %start-doc actions PrintCalibrate @@ -1522,74 +1340,64 @@ %end-doc */ -static int -PrintCalibrate (int argc, char **argv, Coord x, Coord y) +static int PrintCalibrate(int argc, char **argv, Coord x, Coord y) { - HID *printer = hid_find_printer (); - printer->calibrate (0.0, 0.0); + HID *printer = hid_find_printer(); + printer->calibrate(0.0, 0.0); - if (gui->attribute_dialog (printer_calibrate_attrs, 3, - printer_calibrate_values, - _("Printer Calibration Values"), - _("Enter calibration values for your printer"))) - return 1; - printer->calibrate (printer_calibrate_values[1].real_value, - printer_calibrate_values[2].real_value); - return 0; + if (gui->attribute_dialog(printer_calibrate_attrs, 3, + printer_calibrate_values, + _("Printer Calibration Values"), _("Enter calibration values for your printer"))) + return 1; + printer->calibrate(printer_calibrate_values[1].real_value, printer_calibrate_values[2].real_value); + return 0; } /* ------------------------------------------------------------ */ -static int -Export (int argc, char **argv, Coord x, Coord y) +static int Export(int argc, char **argv, Coord x, Coord y) { - /* check if layout is empty */ - if (!IsDataEmpty (PCB->Data)) - { - ghid_dialog_export (); - } - else - gui->log (_("Can't export empty layout")); + /* check if layout is empty */ + if (!IsDataEmpty(PCB->Data)) { + ghid_dialog_export(); + } + else + gui->log(_("Can't export empty layout")); - return 0; + return 0; } /* ------------------------------------------------------------ */ -static int -Benchmark (int argc, char **argv, Coord x, Coord y) +static int Benchmark(int argc, char **argv, Coord x, Coord y) { - int i = 0; - time_t start, end; - GdkDisplay *display; + int i = 0; + time_t start, end; + GdkDisplay *display; - display = gdk_drawable_get_display (gport->drawable); + display = gdk_drawable_get_display(gport->drawable); - gdk_display_sync (display); - time (&start); - do - { - ghid_invalidate_all (); - gdk_window_process_updates (gtk_widget_get_window (gport->drawing_area), - FALSE); - time (&end); - i++; - } - while (end - start < 10); + gdk_display_sync(display); + time(&start); + do { + ghid_invalidate_all(); + gdk_window_process_updates(gtk_widget_get_window(gport->drawing_area), FALSE); + time(&end); + i++; + } + while (end - start < 10); - printf (_("%g redraws per second\n"), i / 10.0); + printf(_("%g redraws per second\n"), i / 10.0); - return 0; + return 0; } /* ------------------------------------------------------------ */ -static const char center_syntax[] = -"Center()\n"; +static const char center_syntax[] = "Center()\n"; -static const char center_help[] = -N_("Moves the pointer to the center of the window."); +static const char center_help[] = N_("Moves the pointer to the center of the window."); /* %start-doc actions Center @@ -1598,50 +1406,46 @@ %end-doc */ -static int -Center(int argc, char **argv, Coord pcb_x, Coord pcb_y) +static int Center(int argc, char **argv, Coord pcb_x, Coord pcb_y) { - GdkDisplay *display; - GdkScreen *screen; - int offset_x, offset_y; - int widget_x, widget_y; - int pointer_x, pointer_y; + GdkDisplay *display; + GdkScreen *screen; + int offset_x, offset_y; + int widget_x, widget_y; + int pointer_x, pointer_y; - if (argc != 0) - AFAIL (center); + if (argc != 0) + AFAIL(center); - /* Aim to put the given x, y PCB coordinates in the center of the widget */ - widget_x = gport->width / 2; - widget_y = gport->height / 2; + /* Aim to put the given x, y PCB coordinates in the center of the widget */ + widget_x = gport->width / 2; + widget_y = gport->height / 2; - ghid_pan_view_abs (pcb_x, pcb_y, widget_x, widget_y); + ghid_pan_view_abs(pcb_x, pcb_y, widget_x, widget_y); - /* Now move the mouse pointer to the place where the board location - * actually ended up. - * - * XXX: Should only do this if we confirm we are inside our window? - */ + /* Now move the mouse pointer to the place where the board location + * actually ended up. + * + * XXX: Should only do this if we confirm we are inside our window? + */ - ghid_pcb_to_event_coords (pcb_x, pcb_y, &widget_x, &widget_y); - gdk_window_get_origin (gtk_widget_get_window (gport->drawing_area), - &offset_x, &offset_y); + ghid_pcb_to_event_coords(pcb_x, pcb_y, &widget_x, &widget_y); + gdk_window_get_origin(gtk_widget_get_window(gport->drawing_area), &offset_x, &offset_y); - pointer_x = offset_x + widget_x; - pointer_y = offset_y + widget_y; + pointer_x = offset_x + widget_x; + pointer_y = offset_y + widget_y; - display = gdk_display_get_default (); - screen = gdk_display_get_default_screen (display); - gdk_display_warp_pointer (display, screen, pointer_x, pointer_y); + display = gdk_display_get_default(); + screen = gdk_display_get_default_screen(display); + gdk_display_warp_pointer(display, screen, pointer_x, pointer_y); - return 0; + return 0; } /* ------------------------------------------------------------ */ -static const char cursor_syntax[] = -"Cursor(Type,DeltaUp,DeltaRight,Units)"; +static const char cursor_syntax[] = "Cursor(Type,DeltaUp,DeltaRight,Units)"; -static const char cursor_help[] = -N_("Move the cursor."); +static const char cursor_help[] = N_("Move the cursor."); /* %start-doc actions Cursor @@ -1678,54 +1482,51 @@ %end-doc */ -static int -CursorAction(int argc, char **argv, Coord x, Coord y) +static int CursorAction(int argc, char **argv, Coord x, Coord y) { - UnitList extra_units_x = { - { "grid", PCB->Grid, 0 }, - { "view", gport->view.width, UNIT_PERCENT }, - { "board", PCB->MaxWidth, UNIT_PERCENT }, - { "", 0, 0 } - }; - UnitList extra_units_y = { - { "grid", PCB->Grid, 0 }, - { "view", gport->view.height, UNIT_PERCENT }, - { "board", PCB->MaxHeight, UNIT_PERCENT }, - { "", 0, 0 } - }; - int pan_warp = HID_SC_DO_NOTHING; - double dx, dy; + UnitList extra_units_x = { + {"grid", PCB->Grid, 0}, + {"view", gport->view.width, UNIT_PERCENT}, + {"board", PCB->MaxWidth, UNIT_PERCENT}, + {"", 0, 0} + }; + UnitList extra_units_y = { + {"grid", PCB->Grid, 0}, + {"view", gport->view.height, UNIT_PERCENT}, + {"board", PCB->MaxHeight, UNIT_PERCENT}, + {"", 0, 0} + }; + int pan_warp = HID_SC_DO_NOTHING; + double dx, dy; - if (argc != 4) - AFAIL (cursor); + if (argc != 4) + AFAIL(cursor); - if (strcasecmp (argv[0], "pan") == 0) - pan_warp = HID_SC_PAN_VIEWPORT; - else if (strcasecmp (argv[0], "warp") == 0) - pan_warp = HID_SC_WARP_POINTER; - else - AFAIL (cursor); + if (strcasecmp(argv[0], "pan") == 0) + pan_warp = HID_SC_PAN_VIEWPORT; + else if (strcasecmp(argv[0], "warp") == 0) + pan_warp = HID_SC_WARP_POINTER; + else + AFAIL(cursor); - dx = GetValueEx (argv[1], argv[3], NULL, extra_units_x, ""); - if (gport->view.flip_x) - dx = -dx; - dy = GetValueEx (argv[2], argv[3], NULL, extra_units_y, ""); - if (!gport->view.flip_y) - dy = -dy; + dx = GetValueEx(argv[1], argv[3], NULL, extra_units_x, ""); + if (gport->view.flip_x) + dx = -dx; + dy = GetValueEx(argv[2], argv[3], NULL, extra_units_y, ""); + if (!gport->view.flip_y) + dy = -dy; - EventMoveCrosshair (Crosshair.X + dx, Crosshair.Y + dy); - gui->set_crosshair (Crosshair.X, Crosshair.Y, pan_warp); + EventMoveCrosshair(Crosshair.X + dx, Crosshair.Y + dy); + gui->set_crosshair(Crosshair.X, Crosshair.Y, pan_warp); - return 0; + return 0; } + /* ------------------------------------------------------------ */ -static const char dowindows_syntax[] = -"DoWindows(1|2|3|4|5|6)\n" -"DoWindows(Layout|Library|Log|Netlist|Preferences|DRC)"; +static const char dowindows_syntax[] = "DoWindows(1|2|3|4|5|6)\n" "DoWindows(Layout|Library|Log|Netlist|Preferences|DRC)"; -static const char dowindows_help[] = -N_("Open various GUI windows."); +static const char dowindows_help[] = N_("Open various GUI windows."); /* %start-doc actions DoWindows @@ -1760,48 +1561,38 @@ %end-doc */ -static int -DoWindows (int argc, char **argv, Coord x, Coord y) +static int DoWindows(int argc, char **argv, Coord x, Coord y) { - char *a = argc == 1 ? argv[0] : (char *)""; + char *a = argc == 1 ? argv[0] : (char *) ""; - if (strcmp (a, "1") == 0 || strcasecmp (a, "Layout") == 0) - { - } - else if (strcmp (a, "2") == 0 || strcasecmp (a, "Library") == 0) - { - ghid_library_window_show (gport, TRUE); - } - else if (strcmp (a, "3") == 0 || strcasecmp (a, "Log") == 0) - { - ghid_log_window_show (TRUE); - } - else if (strcmp (a, "4") == 0 || strcasecmp (a, "Netlist") == 0) - { - ghid_netlist_window_show (gport, TRUE); - } - else if (strcmp (a, "5") == 0 || strcasecmp (a, "Preferences") == 0) - { - ghid_config_window_show (); - } - else if (strcmp (a, "6") == 0 || strcasecmp (a, "DRC") == 0) - { - ghid_drc_window_show (TRUE); - } - else - { - AFAIL (dowindows); - } + if (strcmp(a, "1") == 0 || strcasecmp(a, "Layout") == 0) { + } + else if (strcmp(a, "2") == 0 || strcasecmp(a, "Library") == 0) { + ghid_library_window_show(gport, TRUE); + } + else if (strcmp(a, "3") == 0 || strcasecmp(a, "Log") == 0) { + ghid_log_window_show(TRUE); + } + else if (strcmp(a, "4") == 0 || strcasecmp(a, "Netlist") == 0) { + ghid_netlist_window_show(gport, TRUE); + } + else if (strcmp(a, "5") == 0 || strcasecmp(a, "Preferences") == 0) { + ghid_config_window_show(); + } + else if (strcmp(a, "6") == 0 || strcasecmp(a, "DRC") == 0) { + ghid_drc_window_show(TRUE); + } + else { + AFAIL(dowindows); + } - return 0; + return 0; } /* ------------------------------------------------------------ */ -static const char setunits_syntax[] = -"SetUnits(mm|mil)"; +static const char setunits_syntax[] = "SetUnits(mm|mil)"; -static const char setunits_help[] = -N_("Set the default measurement units."); +static const char setunits_help[] = N_("Set the default measurement units."); /* %start-doc actions SetUnits @@ -1817,38 +1608,34 @@ %end-doc */ -static int -SetUnits (int argc, char **argv, Coord x, Coord y) +static int SetUnits(int argc, char **argv, Coord x, Coord y) { - const Unit *new_unit; - if (argc == 0) - return 0; + const Unit *new_unit; + if (argc == 0) + return 0; - new_unit = get_unit_struct (argv[0]); - if (new_unit != NULL && new_unit->allow != NO_PRINT) - { - Settings.grid_unit = new_unit; - Settings.increments = get_increments_struct (Settings.grid_unit->suffix); - AttributePut (PCB, "PCB::grid::unit", argv[0]); - } + new_unit = get_unit_struct(argv[0]); + if (new_unit != NULL && new_unit->allow != NO_PRINT) { + Settings.grid_unit = new_unit; + Settings.increments = get_increments_struct(Settings.grid_unit->suffix); + AttributePut(PCB, "PCB::grid::unit", argv[0]); + } - ghid_config_handle_units_changed (); + ghid_config_handle_units_changed(); - ghid_set_status_line_label (); + ghid_set_status_line_label(); - /* FIXME ? - * lesstif_sizes_reset (); - * lesstif_styles_update_values (); - */ - return 0; + /* FIXME ? + * lesstif_sizes_reset (); + * lesstif_styles_update_values (); + */ + return 0; } /* ------------------------------------------------------------ */ -static const char scroll_syntax[] = -"Scroll(up|down|left|right, [div])"; +static const char scroll_syntax[] = "Scroll(up|down|left|right, [div])"; -static const char scroll_help[] = -N_("Scroll the viewport."); +static const char scroll_help[] = N_("Scroll the viewport."); /* % start-doc actions Scroll @@ -1862,44 +1649,41 @@ %end-doc */ -static int -ScrollAction (int argc, char **argv, Coord x, Coord y) +static int ScrollAction(int argc, char **argv, Coord x, Coord y) { - gdouble dx = 0.0, dy = 0.0; - int div = 40; + gdouble dx = 0.0, dy = 0.0; + int div = 40; - if (!ghidgui) - return 0; + if (!ghidgui) + return 0; - if (argc != 1 && argc != 2) - AFAIL (scroll); + if (argc != 1 && argc != 2) + AFAIL(scroll); - if (argc == 2) - div = atoi(argv[1]); + if (argc == 2) + div = atoi(argv[1]); - if (strcasecmp (argv[0], "up") == 0) - dy = -gport->view.height / div; - else if (strcasecmp (argv[0], "down") == 0) - dy = gport->view.height / div; - else if (strcasecmp (argv[0], "right") == 0) - dx = gport->view.width / div; - else if (strcasecmp (argv[0], "left") == 0) - dx = -gport->view.width / div; - else - AFAIL (scroll); + if (strcasecmp(argv[0], "up") == 0) + dy = -gport->view.height / div; + else if (strcasecmp(argv[0], "down") == 0) + dy = gport->view.height / div; + else if (strcasecmp(argv[0], "right") == 0) + dx = gport->view.width / div; + else if (strcasecmp(argv[0], "left") == 0) + dx = -gport->view.width / div; + else + AFAIL(scroll); - ghid_pan_view_rel (dx, dy); + ghid_pan_view_rel(dx, dy); - return 0; + return 0; } /* ------------------------------------------------------------ */ -static const char pan_syntax[] = -"Pan([thumb], Mode)"; +static const char pan_syntax[] = "Pan([thumb], Mode)"; static const char pan_help[] = -N_("Start or stop panning (Mode = 1 to start, 0 to stop)\n" -"Optional thumb argument is ignored for now in gtk hid.\n"); +N_("Start or stop panning (Mode = 1 to start, 0 to stop)\n" "Optional thumb argument is ignored for now in gtk hid.\n"); /* %start-doc actions Pan @@ -1908,39 +1692,35 @@ %end-doc */ -static int -PanAction (int argc, char **argv, Coord x, Coord y) +static int PanAction(int argc, char **argv, Coord x, Coord y) { - int mode; + int mode; - if (!ghidgui) - return 0; + if (!ghidgui) + return 0; - if (argc != 1 && argc != 2) - AFAIL (pan); + if (argc != 1 && argc != 2) + AFAIL(pan); - if (argc == 1) - mode = atoi(argv[0]); - else - { - mode = atoi(argv[1]); - Message (_("The gtk gui currently ignores the optional first argument " - "to the Pan action.\nFeel free to provide patches.\n")); - } + if (argc == 1) + mode = atoi(argv[0]); + else { + mode = atoi(argv[1]); + Message(_("The gtk gui currently ignores the optional first argument " + "to the Pan action.\nFeel free to provide patches.\n")); + } - gport->panning = mode; + gport->panning = mode; - return 0; + return 0; } /* ------------------------------------------------------------ */ -static const char popup_syntax[] = -"Popup(MenuName, [Button])"; +static const char popup_syntax[] = "Popup(MenuName, [Button])"; static const char popup_help[] = N_("Bring up the popup menu specified by @code{MenuName}.\n" -"If called by a mouse event then the mouse button number\n" -"must be specified as the optional second argument."); + "If called by a mouse event then the mouse button number\n" "must be specified as the optional second argument."); /* %start-doc actions Popup @@ -1951,35 +1731,30 @@ %end-doc */ -static int -Popup (int argc, char **argv, Coord x, Coord y) +static int Popup(int argc, char **argv, Coord x, Coord y) { - GtkMenu *menu; + GtkMenu *menu; - if (argc != 1 && argc != 2) - AFAIL (popup); + if (argc != 1 && argc != 2) + AFAIL(popup); - menu = ghid_main_menu_get_popup (GHID_MAIN_MENU (ghidgui->menu_bar), argv[0]); - if (! GTK_IS_MENU (menu)) - { - Message (_("The specified popup menu \"%s\" has not been defined.\n"), argv[0]); - return 1; - } - else - { - ghidgui->in_popup = TRUE; - gtk_widget_grab_focus (ghid_port.drawing_area); - gtk_menu_popup (menu, NULL, NULL, NULL, NULL, 0, - gtk_get_current_event_time()); - } - return 0; + menu = ghid_main_menu_get_popup(GHID_MAIN_MENU(ghidgui->menu_bar), argv[0]); + if (!GTK_IS_MENU(menu)) { + Message(_("The specified popup menu \"%s\" has not been defined.\n"), argv[0]); + return 1; + } + else { + ghidgui->in_popup = TRUE; + gtk_widget_grab_focus(ghid_port.drawing_area); + gtk_menu_popup(menu, NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time()); + } + return 0; } + /* ------------------------------------------------------------ */ -static const char importgui_syntax[] = -"ImportGUI()"; +static const char importgui_syntax[] = "ImportGUI()"; -static const char importgui_help[] = -N_("Asks user which schematics to import into PCB.\n"); +static const char importgui_help[] = N_("Asks user which schematics to import into PCB.\n"); /* %start-doc actions ImportGUI @@ -1988,101 +1763,119 @@ %end-doc */ -static int -ImportGUI (int argc, char **argv, Coord x, Coord y) +static int ImportGUI(int argc, char **argv, Coord x, Coord y) { - char *name = NULL; - static gchar *current_layout_dir = NULL; - static int I_am_recursing = 0; - int rv; + char *name = NULL; + static gchar *current_layout_dir = NULL; + static int I_am_recursing = 0; + int rv; - if(!current_layout_dir) - current_layout_dir = get_current_dir_name(); + if (!current_layout_dir) + current_layout_dir = get_current_dir_name(); - if (I_am_recursing) - return 1; + if (I_am_recursing) + return 1; - name = ghid_dialog_file_select_open (_("Load schematics"), - ¤t_layout_dir, - Settings.FilePath); + name = ghid_dialog_file_select_open(_("Load schematics"), ¤t_layout_dir, Settings.FilePath); #ifdef DEBUG - printf("File selected = %s\n", name); + printf("File selected = %s\n", name); #endif - AttributePut (PCB, "import::src0", name); - free (name); + AttributePut(PCB, "import::src0", name); + free(name); - I_am_recursing = 1; - rv = hid_action ("Import"); - I_am_recursing = 0; + I_am_recursing = 1; + rv = hid_action("Import"); + I_am_recursing = 0; - return rv; + return rv; } /* ------------------------------------------------------------ */ -static int -Busy (int argc, char **argv, Coord x, Coord y) +static int Busy(int argc, char **argv, Coord x, Coord y) { - ghid_watch_cursor (); - return 0; + ghid_watch_cursor(); + return 0; } HID_Action ghid_main_action_list[] = { - {"About", 0, About, about_help, about_syntax}, - {"Benchmark", 0, Benchmark}, - {"Busy", 0, Busy}, - {"Center", N_("Click on a location to center"), Center, center_help, center_syntax}, - {"Command", 0, Command}, - {"Cursor", 0, CursorAction, cursor_help, cursor_syntax}, - {"DoWindows", 0, DoWindows, dowindows_help, dowindows_syntax}, - {"Export", 0, Export}, - {"GetXY", "", GetXY, getxy_help, getxy_syntax}, - {"ImportGUI", 0, ImportGUI, importgui_help, importgui_syntax}, - {"LayerGroupsChanged", 0, LayerGroupsChanged}, - {"LibraryChanged", 0, LibraryChanged}, - {"Load", 0, Load}, - {"Pan", 0, PanAction, pan_help, pan_syntax}, - {"PCBChanged", 0, PCBChanged}, - {"PointCursor", 0, PointCursor}, - {"Popup", 0, Popup, popup_help, popup_syntax}, - {"Print", 0, Print, - print_help, print_syntax}, - {"PrintCalibrate", 0, PrintCalibrate, - printcalibrate_help, printcalibrate_syntax}, - {"RouteStylesChanged", 0, RouteStylesChanged}, - {"Save", 0, Save, save_help, save_syntax}, - {"Scroll", N_("Click on a place to scroll"), ScrollAction, scroll_help, scroll_syntax}, - {"SetUnits", 0, SetUnits, setunits_help, setunits_syntax}, - {"SwapSides", 0, SwapSides, swapsides_help, swapsides_syntax}, - {"Zoom", N_("Click on zoom focus"), Zoom, zoom_help, zoom_syntax} + {"About", 0, About, about_help, about_syntax} + , + {"Benchmark", 0, Benchmark} + , + {"Busy", 0, Busy} + , + {"Center", N_("Click on a location to center"), Center, center_help, center_syntax} + , + {"Command", 0, Command} + , + {"Cursor", 0, CursorAction, cursor_help, cursor_syntax} + , + {"DoWindows", 0, DoWindows, dowindows_help, dowindows_syntax} + , + {"Export", 0, Export} + , + {"GetXY", "", GetXY, getxy_help, getxy_syntax} + , + {"ImportGUI", 0, ImportGUI, importgui_help, importgui_syntax} + , + {"LayerGroupsChanged", 0, LayerGroupsChanged} + , + {"LibraryChanged", 0, LibraryChanged} + , + {"Load", 0, Load} + , + {"Pan", 0, PanAction, pan_help, pan_syntax} + , + {"PCBChanged", 0, PCBChanged} + , + {"PointCursor", 0, PointCursor} + , + {"Popup", 0, Popup, popup_help, popup_syntax} + , + {"Print", 0, Print, + print_help, print_syntax} + , + {"PrintCalibrate", 0, PrintCalibrate, + printcalibrate_help, printcalibrate_syntax} + , + {"RouteStylesChanged", 0, RouteStylesChanged} + , + {"Save", 0, Save, save_help, save_syntax} + , + {"Scroll", N_("Click on a place to scroll"), ScrollAction, scroll_help, scroll_syntax} + , + {"SetUnits", 0, SetUnits, setunits_help, setunits_syntax} + , + {"SwapSides", 0, SwapSides, swapsides_help, swapsides_syntax} + , + {"Zoom", N_("Click on zoom focus"), Zoom, zoom_help, zoom_syntax} }; -REGISTER_ACTIONS (ghid_main_action_list) +REGISTER_ACTIONS(ghid_main_action_list) -static int -flag_flipx (int x) + static int + flag_flipx(int x) { - return gport->view.flip_x; + return gport->view.flip_x; } -static int -flag_flipy (int x) +static int flag_flipy(int x) { - return gport->view.flip_y; + return gport->view.flip_y; } HID_Flag ghid_main_flag_list[] = { - {"flip_x", flag_flipx, 0}, - {"flip_y", flag_flipy, 0} + {"flip_x", flag_flipx, 0} + , + {"flip_y", flag_flipy, 0} }; -REGISTER_FLAGS (ghid_main_flag_list) - +REGISTER_FLAGS(ghid_main_flag_list) #include "dolists.h" - /* * We will need these for finding the windows installation * directory. Without that we can't find our fonts and @@ -2092,113 +1885,105 @@ #include #include #endif + HID ghid_hid; -HID ghid_hid; - -void -hid_gtk_init () + void + hid_gtk_init() { #ifdef WIN32 - char * tmps; - char * share_dir; - char *loader_cache; - FILE *loader_file; + char *tmps; + char *share_dir; + char *loader_cache; + FILE *loader_file; #endif #ifdef WIN32 - tmps = g_win32_get_package_installation_directory (PACKAGE "-" VERSION, NULL); + tmps = g_win32_get_package_installation_directory(PACKAGE "-" VERSION, NULL); #define REST_OF_PATH G_DIR_SEPARATOR_S "share" G_DIR_SEPARATOR_S PACKAGE #define REST_OF_CACHE G_DIR_SEPARATOR_S "loaders.cache" - share_dir = (char *) malloc(strlen(tmps) + - strlen(REST_OF_PATH) + - 1); - sprintf (share_dir, "%s%s", tmps, REST_OF_PATH); + share_dir = (char *) malloc(strlen(tmps) + strlen(REST_OF_PATH) + 1); + sprintf(share_dir, "%s%s", tmps, REST_OF_PATH); - /* Point to our gdk-pixbuf loader cache. */ - loader_cache = (char *) malloc (strlen (bindir) + - strlen (REST_OF_CACHE) + - 1); - sprintf (loader_cache, "%s%s", bindir, REST_OF_CACHE); - loader_file = fopen (loader_cache, "r"); - if (loader_file) - { - fclose (loader_file); - g_setenv ("GDK_PIXBUF_MODULE_FILE", loader_cache, TRUE); - } + /* Point to our gdk-pixbuf loader cache. */ + loader_cache = (char *) malloc(strlen(bindir) + strlen(REST_OF_CACHE) + 1); + sprintf(loader_cache, "%s%s", bindir, REST_OF_CACHE); + loader_file = fopen(loader_cache, "r"); + if (loader_file) { + fclose(loader_file); + g_setenv("GDK_PIXBUF_MODULE_FILE", loader_cache, TRUE); + } - free (tmps); + free(tmps); #undef REST_OF_PATH - printf ("\"Share\" installation path is \"%s\"\n", share_dir); + printf("\"Share\" installation path is \"%s\"\n", share_dir); #endif - memset (&ghid_hid, 0, sizeof (HID)); + memset(&ghid_hid, 0, sizeof(HID)); - common_nogui_init (&ghid_hid); - common_draw_helpers_init (&ghid_hid); + common_nogui_init(&ghid_hid); + common_draw_helpers_init(&ghid_hid); - ghid_hid.struct_size = sizeof (HID); - ghid_hid.name = "gtk"; - ghid_hid.description = "Gtk - The Gimp Toolkit"; - ghid_hid.gui = 1; - ghid_hid.poly_after = 1; + ghid_hid.struct_size = sizeof(HID); + ghid_hid.name = "gtk"; + ghid_hid.description = "Gtk - The Gimp Toolkit"; + ghid_hid.gui = 1; + ghid_hid.poly_after = 1; - ghid_hid.get_export_options = ghid_get_export_options; - ghid_hid.do_export = ghid_do_export; - ghid_hid.parse_arguments = ghid_parse_arguments; - ghid_hid.invalidate_lr = ghid_invalidate_lr; - ghid_hid.invalidate_all = ghid_invalidate_all; - ghid_hid.notify_crosshair_change = ghid_notify_crosshair_change; - ghid_hid.notify_mark_change = ghid_notify_mark_change; - ghid_hid.set_layer = ghid_set_layer; - ghid_hid.make_gc = ghid_make_gc; - ghid_hid.destroy_gc = ghid_destroy_gc; - ghid_hid.use_mask = ghid_use_mask; - ghid_hid.set_color = ghid_set_color; - ghid_hid.set_line_cap = ghid_set_line_cap; - ghid_hid.set_line_width = ghid_set_line_width; - ghid_hid.set_draw_xor = ghid_set_draw_xor; - ghid_hid.draw_line = ghid_draw_line; - ghid_hid.draw_arc = ghid_draw_arc; - ghid_hid.draw_rect = ghid_draw_rect; - ghid_hid.fill_circle = ghid_fill_circle; - ghid_hid.fill_polygon = ghid_fill_polygon; - ghid_hid.fill_rect = ghid_fill_rect; + ghid_hid.get_export_options = ghid_get_export_options; + ghid_hid.do_export = ghid_do_export; + ghid_hid.parse_arguments = ghid_parse_arguments; + ghid_hid.invalidate_lr = ghid_invalidate_lr; + ghid_hid.invalidate_all = ghid_invalidate_all; + ghid_hid.notify_crosshair_change = ghid_notify_crosshair_change; + ghid_hid.notify_mark_change = ghid_notify_mark_change; + ghid_hid.set_layer = ghid_set_layer; + ghid_hid.make_gc = ghid_make_gc; + ghid_hid.destroy_gc = ghid_destroy_gc; + ghid_hid.use_mask = ghid_use_mask; + ghid_hid.set_color = ghid_set_color; + ghid_hid.set_line_cap = ghid_set_line_cap; + ghid_hid.set_line_width = ghid_set_line_width; + ghid_hid.set_draw_xor = ghid_set_draw_xor; + ghid_hid.draw_line = ghid_draw_line; + ghid_hid.draw_arc = ghid_draw_arc; + ghid_hid.draw_rect = ghid_draw_rect; + ghid_hid.fill_circle = ghid_fill_circle; + ghid_hid.fill_polygon = ghid_fill_polygon; + ghid_hid.fill_rect = ghid_fill_rect; - ghid_hid.calibrate = ghid_calibrate; - ghid_hid.shift_is_pressed = ghid_shift_is_pressed; - ghid_hid.control_is_pressed = ghid_control_is_pressed; - ghid_hid.mod1_is_pressed = ghid_mod1_is_pressed, - ghid_hid.get_coords = ghid_get_coords; - ghid_hid.set_crosshair = ghid_set_crosshair; - ghid_hid.add_timer = ghid_add_timer; - ghid_hid.stop_timer = ghid_stop_timer; - ghid_hid.watch_file = ghid_watch_file; - ghid_hid.unwatch_file = ghid_unwatch_file; - ghid_hid.add_block_hook = ghid_add_block_hook; - ghid_hid.stop_block_hook = ghid_stop_block_hook; + ghid_hid.calibrate = ghid_calibrate; + ghid_hid.shift_is_pressed = ghid_shift_is_pressed; + ghid_hid.control_is_pressed = ghid_control_is_pressed; + ghid_hid.mod1_is_pressed = ghid_mod1_is_pressed, ghid_hid.get_coords = ghid_get_coords; + ghid_hid.set_crosshair = ghid_set_crosshair; + ghid_hid.add_timer = ghid_add_timer; + ghid_hid.stop_timer = ghid_stop_timer; + ghid_hid.watch_file = ghid_watch_file; + ghid_hid.unwatch_file = ghid_unwatch_file; + ghid_hid.add_block_hook = ghid_add_block_hook; + ghid_hid.stop_block_hook = ghid_stop_block_hook; - ghid_hid.log = ghid_log; - ghid_hid.logv = ghid_logv; - ghid_hid.confirm_dialog = ghid_confirm_dialog; - ghid_hid.close_confirm_dialog = ghid_close_confirm_dialog; - ghid_hid.report_dialog = ghid_report_dialog; - ghid_hid.prompt_for = ghid_prompt_for; - ghid_hid.fileselect = ghid_fileselect; - ghid_hid.attribute_dialog = ghid_attribute_dialog; - ghid_hid.show_item = ghid_show_item; - ghid_hid.beep = ghid_beep; - ghid_hid.progress = ghid_progress; - ghid_hid.drc_gui = &ghid_drc_gui, - ghid_hid.edit_attributes = ghid_attributes; + ghid_hid.log = ghid_log; + ghid_hid.logv = ghid_logv; + ghid_hid.confirm_dialog = ghid_confirm_dialog; + ghid_hid.close_confirm_dialog = ghid_close_confirm_dialog; + ghid_hid.report_dialog = ghid_report_dialog; + ghid_hid.prompt_for = ghid_prompt_for; + ghid_hid.fileselect = ghid_fileselect; + ghid_hid.attribute_dialog = ghid_attribute_dialog; + ghid_hid.show_item = ghid_show_item; + ghid_hid.beep = ghid_beep; + ghid_hid.progress = ghid_progress; + ghid_hid.drc_gui = &ghid_drc_gui, ghid_hid.edit_attributes = ghid_attributes; - ghid_hid.request_debug_draw = ghid_request_debug_draw; - ghid_hid.flush_debug_draw = ghid_flush_debug_draw; - ghid_hid.finish_debug_draw = ghid_finish_debug_draw; + ghid_hid.request_debug_draw = ghid_request_debug_draw; + ghid_hid.flush_debug_draw = ghid_flush_debug_draw; + ghid_hid.finish_debug_draw = ghid_finish_debug_draw; - ghid_hid.notify_save_pcb = ghid_notify_save_pcb; - ghid_hid.notify_filename_changed = ghid_notify_filename_changed; + ghid_hid.notify_save_pcb = ghid_notify_save_pcb; + ghid_hid.notify_filename_changed = ghid_notify_filename_changed; - ghid_hid.create_menu = ghid_create_menu; + ghid_hid.create_menu = ghid_create_menu; - hid_register_hid (&ghid_hid); + hid_register_hid(&ghid_hid); } Index: trunk/src/hid/gtk/gui-command-window.c =================================================================== --- trunk/src/hid/gtk/gui-command-window.c (revision 1021) +++ trunk/src/hid/gtk/gui-command-window.c (revision 1022) @@ -40,7 +40,7 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); static GtkWidget *command_window; static GtkWidget *combo_vbox; @@ -70,407 +70,368 @@ */ - /* When using a command window for command entry, provide a quick and - | abbreviated reference to available commands. - | This is currently just a start and can be expanded if it proves useful. - */ + /* When using a command window for command entry, provide a quick and + | abbreviated reference to available commands. + | This is currently just a start and can be expanded if it proves useful. + */ static gchar *command_ref_text[] = { - N_("Common commands easily accessible via the gui may not be included here.\n"), - "\n", - N_("In user commands below, 'size' values may be absolute or relative\n" - "if preceded by a '+' or '-'. Where 'units' are indicated, use \n" - "'mil' or 'mm' otherwise PCB internal units will be used.\n"), - "\n", - "changesize(target, size, units)\n", - "\ttarget = {selectedlines | selectedpins | selectedvias | selectedpads \n" - "\t\t\t| selectedtexts | selectednames | selectedelements | selected}\n", - "\n", - "changedrillsize(target, size, units)\n", - "\ttarget = {selectedpins | selectedvias | selectedobjects | selected}\n", - "\n", - "changeclearsize(target, size, units)\n", - "\ttarget = {selectedpins | selectedpads | selectedvias | selectedlines\n" - "\t\t\t| selectedarcs | selectedobjects | selected}\n", - N_("\tChanges the clearance of objects.\n"), - "\n", - "setvalue(target, size, units)\n", - "\ttarget = {grid | zoom | line | textscale | viadrillinghole\n" - "\t\t\t| viadrillinghole | via}\n", - N_("\tChanges values. Omit 'units' for 'grid' and 'zoom'.\n"), - "\n", - "changejoin(target)\n", - "\ttarget = {object | selectedlines | selectedarcs | selected}\n", - N_("\tChanges the join (clearance through polygons) of objects.\n"), - "\n", - "changesquare(target)\n", - "setsquare(target)\n", - "clearsquare(target)\n", - "\ttarget = {object | selectedelements | selectedpins | selected}\n", - N_("\tToggles, sets, or clears the square flag of objects.\n"), - "\n", - "changeoctagon(target)\n", - "setoctagon(target)\n", - "clearoctagon(target)\n", - "\ttarget = {object | selectedelements | selectedpins selectedvias | selected}\n", - N_("\tToggles, sets, or clears the octagon flag of objects.\n"), - "\n", - "changehole(target)\n", - "\ttarget = {object | selectedvias | selected}\n", - N_("\tChanges the hole flag of objects.\n"), - "\n", - "flip(target)\n", - "\ttarget = {object | selectedelements | selected}\n", - N_("\tFlip elements to the opposite side of the board.\n"), - "\n", - "togglethermal(target)\n", - "setthermal(target)\n", - "clearthermal(target)\n", - "\ttarget = {object | selectedpins | selectedvias | selected}\n", - N_("\tToggle, set or clear a thermal (on the current layer) to pins or vias.\n"), - "\n", - "loadvendor(target)\n", - "\ttarget = [filename]\n", - N_("\tLoad a vendor file. If 'filename' omitted, pop up file select dialog.\n"), + N_("Common commands easily accessible via the gui may not be included here.\n"), + "\n", + N_("In user commands below, 'size' values may be absolute or relative\n" + "if preceded by a '+' or '-'. Where 'units' are indicated, use \n" + "'mil' or 'mm' otherwise PCB internal units will be used.\n"), + "\n", + "changesize(target, size, units)\n", + "\ttarget = {selectedlines | selectedpins | selectedvias | selectedpads \n" + "\t\t\t| selectedtexts | selectednames | selectedelements | selected}\n", + "\n", + "changedrillsize(target, size, units)\n", + "\ttarget = {selectedpins | selectedvias | selectedobjects | selected}\n", + "\n", + "changeclearsize(target, size, units)\n", + "\ttarget = {selectedpins | selectedpads | selectedvias | selectedlines\n" + "\t\t\t| selectedarcs | selectedobjects | selected}\n", + N_("\tChanges the clearance of objects.\n"), + "\n", + "setvalue(target, size, units)\n", + "\ttarget = {grid | zoom | line | textscale | viadrillinghole\n" "\t\t\t| viadrillinghole | via}\n", + N_("\tChanges values. Omit 'units' for 'grid' and 'zoom'.\n"), + "\n", + "changejoin(target)\n", + "\ttarget = {object | selectedlines | selectedarcs | selected}\n", + N_("\tChanges the join (clearance through polygons) of objects.\n"), + "\n", + "changesquare(target)\n", + "setsquare(target)\n", + "clearsquare(target)\n", + "\ttarget = {object | selectedelements | selectedpins | selected}\n", + N_("\tToggles, sets, or clears the square flag of objects.\n"), + "\n", + "changeoctagon(target)\n", + "setoctagon(target)\n", + "clearoctagon(target)\n", + "\ttarget = {object | selectedelements | selectedpins selectedvias | selected}\n", + N_("\tToggles, sets, or clears the octagon flag of objects.\n"), + "\n", + "changehole(target)\n", + "\ttarget = {object | selectedvias | selected}\n", + N_("\tChanges the hole flag of objects.\n"), + "\n", + "flip(target)\n", + "\ttarget = {object | selectedelements | selected}\n", + N_("\tFlip elements to the opposite side of the board.\n"), + "\n", + "togglethermal(target)\n", + "setthermal(target)\n", + "clearthermal(target)\n", + "\ttarget = {object | selectedpins | selectedvias | selected}\n", + N_("\tToggle, set or clear a thermal (on the current layer) to pins or vias.\n"), + "\n", + "loadvendor(target)\n", + "\ttarget = [filename]\n", + N_("\tLoad a vendor file. If 'filename' omitted, pop up file select dialog.\n"), }; - /* Put an allocated string on the history list and combo text list - | if it is not a duplicate. The history_list is just a shadow of the - | combo list, but I think is needed because I don't see an api for reading - | the combo strings. The combo box strings take "const gchar *", so the - | same allocated string can go in both the history list and the combo list. - | If removed from both lists, a string can be freed. - */ -static void -command_history_add (gchar * cmd) + /* Put an allocated string on the history list and combo text list + | if it is not a duplicate. The history_list is just a shadow of the + | combo list, but I think is needed because I don't see an api for reading + | the combo strings. The combo box strings take "const gchar *", so the + | same allocated string can go in both the history list and the combo list. + | If removed from both lists, a string can be freed. + */ +static void command_history_add(gchar * cmd) { - GList *list; - gchar *s; - gint i; + GList *list; + gchar *s; + gint i; - if (!cmd || !*cmd) - return; + if (!cmd || !*cmd) + return; - /* Check for a duplicate command. If found, move it to the - | top of the list and similarly modify the combo box strings. - */ - for (i = 0, list = history_list; list; list = list->next, ++i) - { - s = (gchar *) list->data; - if (!strcmp (cmd, s)) - { - history_list = g_list_remove (history_list, s); - history_list = g_list_prepend (history_list, s); - gtk_combo_box_remove_text (GTK_COMBO_BOX - (ghidgui->command_combo_box), i); - gtk_combo_box_prepend_text (GTK_COMBO_BOX - (ghidgui->command_combo_box), s); - return; + /* Check for a duplicate command. If found, move it to the + | top of the list and similarly modify the combo box strings. + */ + for (i = 0, list = history_list; list; list = list->next, ++i) { + s = (gchar *) list->data; + if (!strcmp(cmd, s)) { + history_list = g_list_remove(history_list, s); + history_list = g_list_prepend(history_list, s); + gtk_combo_box_remove_text(GTK_COMBO_BOX(ghidgui->command_combo_box), i); + gtk_combo_box_prepend_text(GTK_COMBO_BOX(ghidgui->command_combo_box), s); + return; + } } - } - /* Not a duplicate, so put first in history list and combo box text list. - */ - s = g_strdup (cmd); - history_list = g_list_prepend (history_list, s); - gtk_combo_box_prepend_text (GTK_COMBO_BOX (ghidgui->command_combo_box), s); + /* Not a duplicate, so put first in history list and combo box text list. + */ + s = g_strdup(cmd); + history_list = g_list_prepend(history_list, s); + gtk_combo_box_prepend_text(GTK_COMBO_BOX(ghidgui->command_combo_box), s); - /* And keep the lists trimmed! - */ - if (g_list_length (history_list) > ghidgui->history_size) - { - s = (gchar *) g_list_nth_data (history_list, ghidgui->history_size); - history_list = g_list_remove (history_list, s); - gtk_combo_box_remove_text (GTK_COMBO_BOX (ghidgui->command_combo_box), - ghidgui->history_size); - g_free (s); - } + /* And keep the lists trimmed! + */ + if (g_list_length(history_list) > ghidgui->history_size) { + s = (gchar *) g_list_nth_data(history_list, ghidgui->history_size); + history_list = g_list_remove(history_list, s); + gtk_combo_box_remove_text(GTK_COMBO_BOX(ghidgui->command_combo_box), ghidgui->history_size); + g_free(s); + } } - /* Called when user hits "Enter" key in command entry. The action to take - | depends on where the combo box is. If it's in the command window, we can - | immediately execute the command and carry on. If it's in the status - | line hbox, then we need stop the command entry g_main_loop from running - | and save the allocated string so it can be returned from - | ghid_command_entry_get() - */ -static void -command_entry_activate_cb (GtkWidget * widget, gpointer data) + /* Called when user hits "Enter" key in command entry. The action to take + | depends on where the combo box is. If it's in the command window, we can + | immediately execute the command and carry on. If it's in the status + | line hbox, then we need stop the command entry g_main_loop from running + | and save the allocated string so it can be returned from + | ghid_command_entry_get() + */ +static void command_entry_activate_cb(GtkWidget * widget, gpointer data) { - gchar *command; + gchar *command; - command = - g_strdup (ghid_entry_get_text (GTK_WIDGET (ghidgui->command_entry))); - gtk_entry_set_text (ghidgui->command_entry, ""); + command = g_strdup(ghid_entry_get_text(GTK_WIDGET(ghidgui->command_entry))); + gtk_entry_set_text(ghidgui->command_entry, ""); - if (*command) - command_history_add (command); + if (*command) + command_history_add(command); - if (ghidgui->use_command_window) - { - hid_parse_command (command); - g_free (command); - } - else - { - if (loop && g_main_loop_is_running (loop)) /* should always be */ - g_main_loop_quit (loop); - command_entered = command; /* Caller will free it */ - } + if (ghidgui->use_command_window) { + hid_parse_command(command); + g_free(command); + } + else { + if (loop && g_main_loop_is_running(loop)) /* should always be */ + g_main_loop_quit(loop); + command_entered = command; /* Caller will free it */ + } } - /* Create the command_combo_box. Called once, either by - | ghid_command_window_show() or ghid_command_entry_get(). Then as long as - | ghidgui->use_command_window is TRUE, the command_combo_box will live - | in a command window vbox or float if the command window is not up. - | But if ghidgui->use_command_window is FALSE, the command_combo_box - | will live in the status_line_hbox either shown or hidden. - | Since it's never destroyed, the combo history strings never need - | rebuilding and history is maintained if the combo box location is moved. - */ -static void -command_combo_box_entry_create (void) + /* Create the command_combo_box. Called once, either by + | ghid_command_window_show() or ghid_command_entry_get(). Then as long as + | ghidgui->use_command_window is TRUE, the command_combo_box will live + | in a command window vbox or float if the command window is not up. + | But if ghidgui->use_command_window is FALSE, the command_combo_box + | will live in the status_line_hbox either shown or hidden. + | Since it's never destroyed, the combo history strings never need + | rebuilding and history is maintained if the combo box location is moved. + */ +static void command_combo_box_entry_create(void) { - ghidgui->command_combo_box = gtk_combo_box_entry_new_text (); - ghidgui->command_entry = - GTK_ENTRY (gtk_bin_get_child (GTK_BIN (ghidgui->command_combo_box))); + ghidgui->command_combo_box = gtk_combo_box_entry_new_text(); + ghidgui->command_entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(ghidgui->command_combo_box))); - gtk_entry_set_width_chars (ghidgui->command_entry, 40); - gtk_entry_set_activates_default (ghidgui->command_entry, TRUE); + gtk_entry_set_width_chars(ghidgui->command_entry, 40); + gtk_entry_set_activates_default(ghidgui->command_entry, TRUE); - g_signal_connect (G_OBJECT (ghidgui->command_entry), "activate", - G_CALLBACK (command_entry_activate_cb), NULL); + g_signal_connect(G_OBJECT(ghidgui->command_entry), "activate", G_CALLBACK(command_entry_activate_cb), NULL); - g_object_ref (G_OBJECT (ghidgui->command_combo_box)); /* so can move it */ + g_object_ref(G_OBJECT(ghidgui->command_combo_box)); /* so can move it */ } -static void -command_window_close_cb (void) +static void command_window_close_cb(void) { - if (command_window) - { - gtk_container_remove (GTK_CONTAINER (combo_vbox), /* Float it */ - ghidgui->command_combo_box); - gtk_widget_destroy (command_window); - } - combo_vbox = NULL; - command_window = NULL; + if (command_window) { + gtk_container_remove(GTK_CONTAINER(combo_vbox), /* Float it */ + ghidgui->command_combo_box); + gtk_widget_destroy(command_window); + } + combo_vbox = NULL; + command_window = NULL; } -static void -command_destroy_cb (GtkWidget * widget, gpointer data) +static void command_destroy_cb(GtkWidget * widget, gpointer data) { - command_window = NULL; + command_window = NULL; } - /* If ghidgui->use_command_window toggles, the config code calls - | this to ensure the command_combo_box is set up for living in the - | right place. - */ -void -ghid_command_use_command_window_sync (void) + /* If ghidgui->use_command_window toggles, the config code calls + | this to ensure the command_combo_box is set up for living in the + | right place. + */ +void ghid_command_use_command_window_sync(void) { - /* The combo box will be NULL and not living anywhere until the - | first command entry. - */ - if (!ghidgui->command_combo_box) - return; + /* The combo box will be NULL and not living anywhere until the + | first command entry. + */ + if (!ghidgui->command_combo_box) + return; - if (ghidgui->use_command_window) - gtk_container_remove (GTK_CONTAINER (ghidgui->status_line_hbox), - ghidgui->command_combo_box); - else - { - /* Destroy the window (if it's up) which floats the command_combo_box - | so we can pack it back into the status line hbox. If the window - | wasn't up, the command_combo_box was already floating. - */ - command_window_close_cb (); - gtk_widget_hide (ghidgui->command_combo_box); - gtk_box_pack_start (GTK_BOX (ghidgui->status_line_hbox), - ghidgui->command_combo_box, FALSE, FALSE, 0); - } + if (ghidgui->use_command_window) + gtk_container_remove(GTK_CONTAINER(ghidgui->status_line_hbox), ghidgui->command_combo_box); + else { + /* Destroy the window (if it's up) which floats the command_combo_box + | so we can pack it back into the status line hbox. If the window + | wasn't up, the command_combo_box was already floating. + */ + command_window_close_cb(); + gtk_widget_hide(ghidgui->command_combo_box); + gtk_box_pack_start(GTK_BOX(ghidgui->status_line_hbox), ghidgui->command_combo_box, FALSE, FALSE, 0); + } } - /* If ghidgui->use_command_window is TRUE this will get called from - | ActionCommand() to show the command window. - */ -void -ghid_command_window_show (gboolean raise) + /* If ghidgui->use_command_window is TRUE this will get called from + | ActionCommand() to show the command window. + */ +void ghid_command_window_show(gboolean raise) { - GtkWidget *vbox, *vbox1, *hbox, *button, *expander, *text; - gint i; + GtkWidget *vbox, *vbox1, *hbox, *button, *expander, *text; + gint i; - if (command_window) - { - if (raise) - gtk_window_present (GTK_WINDOW(command_window)); - return; - } - command_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - g_signal_connect (G_OBJECT (command_window), "destroy", - G_CALLBACK (command_destroy_cb), NULL); - gtk_window_set_title (GTK_WINDOW (command_window), _("PCB Command Entry")); - gtk_window_set_wmclass (GTK_WINDOW (command_window), "PCB_Command", "PCB"); - gtk_window_set_resizable (GTK_WINDOW (command_window), FALSE); + if (command_window) { + if (raise) + gtk_window_present(GTK_WINDOW(command_window)); + return; + } + command_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + g_signal_connect(G_OBJECT(command_window), "destroy", G_CALLBACK(command_destroy_cb), NULL); + gtk_window_set_title(GTK_WINDOW(command_window), _("PCB Command Entry")); + gtk_window_set_wmclass(GTK_WINDOW(command_window), "PCB_Command", "PCB"); + gtk_window_set_resizable(GTK_WINDOW(command_window), FALSE); - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); - gtk_container_add (GTK_CONTAINER (command_window), vbox); + vbox = gtk_vbox_new(FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); + gtk_container_add(GTK_CONTAINER(command_window), vbox); - if (!ghidgui->command_combo_box) - command_combo_box_entry_create (); + if (!ghidgui->command_combo_box) + command_combo_box_entry_create(); - gtk_box_pack_start (GTK_BOX (vbox), ghidgui->command_combo_box, - FALSE, FALSE, 0); - combo_vbox = vbox; + gtk_box_pack_start(GTK_BOX(vbox), ghidgui->command_combo_box, FALSE, FALSE, 0); + combo_vbox = vbox; - /* Make the command reference scrolled text view. Use high level - | utility functions in gui-utils.c - */ - expander = gtk_expander_new (_("Command Reference")); - gtk_box_pack_start (GTK_BOX (vbox), expander, TRUE, TRUE, 2); - vbox1 = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (expander), vbox1); - gtk_widget_set_size_request (vbox1, -1, 350); + /* Make the command reference scrolled text view. Use high level + | utility functions in gui-utils.c + */ + expander = gtk_expander_new(_("Command Reference")); + gtk_box_pack_start(GTK_BOX(vbox), expander, TRUE, TRUE, 2); + vbox1 = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(expander), vbox1); + gtk_widget_set_size_request(vbox1, -1, 350); - text = ghid_scrolled_text_view (vbox1, NULL, - GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - for (i = 0; i < sizeof (command_ref_text) / sizeof (gchar *); ++i) - ghid_text_view_append (text, _(command_ref_text[i])); + text = ghid_scrolled_text_view(vbox1, NULL, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + for (i = 0; i < sizeof(command_ref_text) / sizeof(gchar *); ++i) + ghid_text_view_append(text, _(command_ref_text[i])); - /* The command window close button. - */ - 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, 3); - button = gtk_button_new_from_stock (GTK_STOCK_CLOSE); - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (command_window_close_cb), NULL); - gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); + /* The command window close button. + */ + 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, 3); + button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); + g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(command_window_close_cb), NULL); + gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); - gtk_widget_show_all (command_window); + gtk_widget_show_all(command_window); } -static gboolean -command_escape_cb (GtkWidget * widget, GdkEventKey * kev, gpointer data) +static gboolean command_escape_cb(GtkWidget * widget, GdkEventKey * kev, gpointer data) { - gint ksym = kev->keyval; + gint ksym = kev->keyval; - if (ksym != GDK_Escape) - return FALSE; + if (ksym != GDK_Escape) + return FALSE; - if (loop && g_main_loop_is_running (loop)) /* should always be */ - g_main_loop_quit (loop); - command_entered = NULL; /* We are aborting */ + if (loop && g_main_loop_is_running(loop)) /* should always be */ + g_main_loop_quit(loop); + command_entered = NULL; /* We are aborting */ - return TRUE; + return TRUE; } - /* This is the command entry function called from ActionCommand() when - | ghidgui->use_command_window is FALSE. The command_combo_box is already - | packed into the status line label hbox in this case. - */ -gchar * -ghid_command_entry_get (gchar * prompt, gchar * command) + /* This is the command entry function called from ActionCommand() when + | ghidgui->use_command_window is FALSE. The command_combo_box is already + | packed into the status line label hbox in this case. + */ +gchar *ghid_command_entry_get(gchar * prompt, gchar * command) { - gchar *s; - gint escape_sig_id; - GHidPort *out = &ghid_port; + gchar *s; + gint escape_sig_id; + GHidPort *out = &ghid_port; - /* If this is the first user command entry, we have to create the - | command_combo_box and pack it into the status_line_hbox. - */ - if (!ghidgui->command_combo_box) - { - command_combo_box_entry_create (); - gtk_box_pack_start (GTK_BOX (ghidgui->status_line_hbox), - ghidgui->command_combo_box, FALSE, FALSE, 0); - } + /* If this is the first user command entry, we have to create the + | command_combo_box and pack it into the status_line_hbox. + */ + if (!ghidgui->command_combo_box) { + command_combo_box_entry_create(); + gtk_box_pack_start(GTK_BOX(ghidgui->status_line_hbox), ghidgui->command_combo_box, FALSE, FALSE, 0); + } - /* Make the prompt bold and set the label before showing the combo to - | avoid window resizing wider. - */ - s = g_strdup_printf ("%s", prompt ? prompt : ""); - ghid_status_line_set_text (s); - g_free (s); + /* Make the prompt bold and set the label before showing the combo to + | avoid window resizing wider. + */ + s = g_strdup_printf("%s", prompt ? prompt : ""); + ghid_status_line_set_text(s); + g_free(s); - /* Flag so output drawing area won't try to get focus away from us and - | so resetting the status line label can be blocked when resize - | callbacks are invokded from the resize caused by showing the combo box. - */ - ghidgui->command_entry_status_line_active = TRUE; + /* Flag so output drawing area won't try to get focus away from us and + | so resetting the status line label can be blocked when resize + | callbacks are invokded from the resize caused by showing the combo box. + */ + ghidgui->command_entry_status_line_active = TRUE; - gtk_entry_set_text (ghidgui->command_entry, command ? command : ""); - gtk_widget_show_all (ghidgui->command_combo_box); + gtk_entry_set_text(ghidgui->command_entry, command ? command : ""); + gtk_widget_show_all(ghidgui->command_combo_box); - /* Remove the top window accel group so keys intended for the entry - | don't get intercepted by the menu system. Set the interface - | insensitive so all the user can do is enter a command, grab focus - | and connect a handler to look for the escape key. - */ - ghid_remove_accel_groups (GTK_WINDOW (gport->top_window), ghidgui); - ghid_interface_input_signals_disconnect (); - ghid_interface_set_sensitive (FALSE); - gtk_widget_grab_focus (GTK_WIDGET (ghidgui->command_entry)); - escape_sig_id = g_signal_connect (G_OBJECT (ghidgui->command_entry), - "key_press_event", - G_CALLBACK (command_escape_cb), NULL); + /* Remove the top window accel group so keys intended for the entry + | don't get intercepted by the menu system. Set the interface + | insensitive so all the user can do is enter a command, grab focus + | and connect a handler to look for the escape key. + */ + ghid_remove_accel_groups(GTK_WINDOW(gport->top_window), ghidgui); + ghid_interface_input_signals_disconnect(); + ghid_interface_set_sensitive(FALSE); + gtk_widget_grab_focus(GTK_WIDGET(ghidgui->command_entry)); + escape_sig_id = g_signal_connect(G_OBJECT(ghidgui->command_entry), "key_press_event", G_CALLBACK(command_escape_cb), NULL); - loop = g_main_loop_new (NULL, FALSE); - g_main_loop_run (loop); + loop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(loop); - g_main_loop_unref (loop); - loop = NULL; + g_main_loop_unref(loop); + loop = NULL; - ghidgui->command_entry_status_line_active = FALSE; + ghidgui->command_entry_status_line_active = FALSE; - /* Restore the damage we did before entering the loop. - */ - g_signal_handler_disconnect (ghidgui->command_entry, escape_sig_id); - ghid_interface_input_signals_connect (); - ghid_interface_set_sensitive (TRUE); - ghid_install_accel_groups (GTK_WINDOW (gport->top_window), ghidgui); + /* Restore the damage we did before entering the loop. + */ + g_signal_handler_disconnect(ghidgui->command_entry, escape_sig_id); + ghid_interface_input_signals_connect(); + ghid_interface_set_sensitive(TRUE); + ghid_install_accel_groups(GTK_WINDOW(gport->top_window), ghidgui); - /* Restore the status line label and give focus back to the drawing area - */ - gtk_widget_hide (ghidgui->command_combo_box); - gtk_widget_grab_focus (out->drawing_area); + /* Restore the status line label and give focus back to the drawing area + */ + gtk_widget_hide(ghidgui->command_combo_box); + gtk_widget_grab_focus(out->drawing_area); - return command_entered; + return command_entered; } -void -ghid_handle_user_command (gboolean raise) +void ghid_handle_user_command(gboolean raise) { - char *command; - static char *previous = NULL; + char *command; + static char *previous = NULL; - if (ghidgui->use_command_window) - ghid_command_window_show (raise); - else - { - command = ghid_command_entry_get (_("Enter command:"), - (Settings.SaveLastCommand && previous) ? previous : (gchar *)""); - if (command != NULL) - { - /* copy new comand line to save buffer */ - g_free (previous); - previous = g_strdup (command); - hid_parse_command (command); - g_free (command); + if (ghidgui->use_command_window) + ghid_command_window_show(raise); + else { + command = ghid_command_entry_get(_("Enter command:"), (Settings.SaveLastCommand && previous) ? previous : (gchar *) ""); + if (command != NULL) { + /* copy new comand line to save buffer */ + g_free(previous); + previous = g_strdup(command); + hid_parse_command(command); + g_free(command); + } + else if (previous) { + command = g_strdup(previous); + hid_parse_command(command); + g_free(command); + } } - else if (previous) - { - command = g_strdup (previous); - hid_parse_command (command); - g_free (command); - } - } - ghid_window_set_name_label (PCB->Name); - ghid_set_status_line_label (); + ghid_window_set_name_label(PCB->Name); + ghid_set_status_line_label(); } Index: trunk/src/hid/gtk/gui-config.c =================================================================== --- trunk/src/hid/gtk/gui-config.c (revision 1021) +++ trunk/src/hid/gtk/gui-config.c (revision 1022) @@ -44,7 +44,7 @@ #include "error.h" #include "draw.h" #include "misc.h" -#include "portability.h" /* MKDIR() */ +#include "portability.h" /* MKDIR() */ #include "pcb-printf.h" #include "set.h" @@ -55,46 +55,40 @@ #include #endif -extern int MoveLayerAction(int argc, char **argv, int x, int y); +extern int MoveLayerAction(int argc, char **argv, int x, int y); -RCSID ("$Id$"); +RCSID("$Id$"); -enum ConfigType -{ - CONFIG_Boolean, - CONFIG_Integer, - CONFIG_Coord, - CONFIG_Real, - CONFIG_String, - CONFIG_Unused +enum ConfigType { + CONFIG_Boolean, + CONFIG_Integer, + CONFIG_Coord, + CONFIG_Real, + CONFIG_String, + CONFIG_Unused }; -typedef struct -{ - gchar *name; - enum ConfigType type; - void *value; -} -ConfigAttribute; +typedef struct { + gchar *name; + enum ConfigType type; + void *value; +} ConfigAttribute; -enum ColorTypes -{ - MISC_COLOR, - MISC_SELECTED_COLOR, - LAYER_COLOR, - LAYER_SELECTED_COLOR +enum ColorTypes { + MISC_COLOR, + MISC_SELECTED_COLOR, + LAYER_COLOR, + LAYER_SELECTED_COLOR }; -typedef struct -{ - HID_Attribute *attributes; - enum ColorTypes type; - GdkColor color; - gboolean color_is_mapped; -} -ConfigColor; +typedef struct { + HID_Attribute *attributes; + enum ColorTypes type; + GdkColor color; + gboolean color_is_mapped; +} ConfigColor; static GList *config_color_list, *lib_newlib_list; @@ -103,7 +97,7 @@ static gchar *color_file; -extern void ghid_set_special_colors (HID_Attribute * ha); +extern void ghid_set_special_colors(HID_Attribute * ha); #define PCB_CONFIG_DIR ".pcb" @@ -112,680 +106,620 @@ static gchar *config_dir, *color_dir; - /* CONFIG_Unused types are expected to be found in main_attribute_list and - | will be assigned the type found there. NULL value pointers here are - | also expected to be assigned values from the main_attribute_list. - */ - /* PinoutFont also not used anymore */ + /* CONFIG_Unused types are expected to be found in main_attribute_list and + | will be assigned the type found there. NULL value pointers here are + | also expected to be assigned values from the main_attribute_list. + */ + /* PinoutFont also not used anymore */ static ConfigAttribute config_attributes[] = { - {"gui-compact-horizontal", CONFIG_Boolean, &_ghidgui.compact_horizontal}, - {"gui-compact-vertical", CONFIG_Boolean, &_ghidgui.compact_vertical}, - {"use-command-window", CONFIG_Boolean, &_ghidgui.use_command_window}, - {"save-in-tmp", CONFIG_Unused, NULL}, - {"grid-units", CONFIG_Unused, NULL}, - {"grid", CONFIG_Unused, NULL}, + {"gui-compact-horizontal", CONFIG_Boolean, &_ghidgui.compact_horizontal}, + {"gui-compact-vertical", CONFIG_Boolean, &_ghidgui.compact_vertical}, + {"use-command-window", CONFIG_Boolean, &_ghidgui.use_command_window}, + {"save-in-tmp", CONFIG_Unused, NULL}, + {"grid-units", CONFIG_Unused, NULL}, + {"grid", CONFIG_Unused, NULL}, - {"history-size", CONFIG_Integer, &_ghidgui.history_size}, - {"top-window-width", CONFIG_Integer, &_ghidgui.top_window_width}, - {"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}, - {"keyref-window-width", CONFIG_Integer, &_ghidgui.keyref_window_width}, - {"keyref-window-height", CONFIG_Integer, &_ghidgui.keyref_window_height}, - {"text-scale", CONFIG_Unused, NULL}, - {"via-thickness", CONFIG_Unused, NULL}, - {"via-drilling-hole", CONFIG_Unused, NULL}, - {"backup-interval", CONFIG_Unused, NULL}, - {"line-thickness", CONFIG_Unused, NULL}, - {"rat-thickness", CONFIG_Unused, NULL}, - {"bloat", CONFIG_Unused, NULL}, - {"shrink", CONFIG_Unused, NULL}, - {"min-width", CONFIG_Unused, NULL}, - {"min-silk", CONFIG_Unused, NULL}, - {"min-drill", CONFIG_Unused, NULL}, - {"min-ring", CONFIG_Unused, NULL}, - {"default-PCB-width", CONFIG_Unused, NULL}, - {"default-PCB-height", CONFIG_Unused, NULL}, + {"history-size", CONFIG_Integer, &_ghidgui.history_size}, + {"top-window-width", CONFIG_Integer, &_ghidgui.top_window_width}, + {"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}, + {"keyref-window-width", CONFIG_Integer, &_ghidgui.keyref_window_width}, + {"keyref-window-height", CONFIG_Integer, &_ghidgui.keyref_window_height}, + {"text-scale", CONFIG_Unused, NULL}, + {"via-thickness", CONFIG_Unused, NULL}, + {"via-drilling-hole", CONFIG_Unused, NULL}, + {"backup-interval", CONFIG_Unused, NULL}, + {"line-thickness", CONFIG_Unused, NULL}, + {"rat-thickness", CONFIG_Unused, NULL}, + {"bloat", CONFIG_Unused, NULL}, + {"shrink", CONFIG_Unused, NULL}, + {"min-width", CONFIG_Unused, NULL}, + {"min-silk", CONFIG_Unused, NULL}, + {"min-drill", CONFIG_Unused, NULL}, + {"min-ring", CONFIG_Unused, NULL}, + {"default-PCB-width", CONFIG_Unused, NULL}, + {"default-PCB-height", CONFIG_Unused, NULL}, - {"groups", CONFIG_Unused, NULL}, - {"route-styles", CONFIG_Unused, NULL}, - {"library-newlib", CONFIG_String, &lib_newlib_config}, - {"color-file", CONFIG_String, &color_file}, + {"groups", CONFIG_Unused, NULL}, + {"route-styles", CONFIG_Unused, NULL}, + {"library-newlib", CONFIG_String, &lib_newlib_config}, + {"color-file", CONFIG_String, &color_file}, /* FIXME: construct layer-names- in a list */ - {"layer-name-1", CONFIG_Unused, NULL}, - {"layer-name-2", CONFIG_Unused, NULL}, - {"layer-name-3", CONFIG_Unused, NULL}, - {"layer-name-4", CONFIG_Unused, NULL}, - {"layer-name-5", CONFIG_Unused, NULL}, - {"layer-name-6", CONFIG_Unused, NULL}, - {"layer-name-7", CONFIG_Unused, NULL}, - {"layer-name-8", CONFIG_Unused, NULL}, + {"layer-name-1", CONFIG_Unused, NULL}, + {"layer-name-2", CONFIG_Unused, NULL}, + {"layer-name-3", CONFIG_Unused, NULL}, + {"layer-name-4", CONFIG_Unused, NULL}, + {"layer-name-5", CONFIG_Unused, NULL}, + {"layer-name-6", CONFIG_Unused, NULL}, + {"layer-name-7", CONFIG_Unused, NULL}, + {"layer-name-8", CONFIG_Unused, NULL}, }; -static FILE * -config_file_open (gchar * mode) +static FILE *config_file_open(gchar * mode) { - FILE *f; - gchar *homedir, *fname; + FILE *f; + gchar *homedir, *fname; - homedir = (gchar *) g_get_home_dir (); - if (!homedir) - { - g_message ("config_file_open: Can't get home directory!"); - return NULL; - } + homedir = (gchar *) g_get_home_dir(); + if (!homedir) { + g_message("config_file_open: Can't get home directory!"); + return NULL; + } - if (!config_dir) - { - config_dir = - g_build_path (G_DIR_SEPARATOR_S, homedir, PCB_CONFIG_DIR, NULL); - if (!g_file_test (config_dir, G_FILE_TEST_IS_DIR) - && MKDIR (config_dir, 0755) < 0) - { - g_message ("config_file_open: Can't make \"%s\" directory!", - config_dir); - g_free (config_dir); - config_dir = NULL; - return NULL; + if (!config_dir) { + config_dir = g_build_path(G_DIR_SEPARATOR_S, homedir, PCB_CONFIG_DIR, NULL); + if (!g_file_test(config_dir, G_FILE_TEST_IS_DIR) + && MKDIR(config_dir, 0755) < 0) { + g_message("config_file_open: Can't make \"%s\" directory!", config_dir); + g_free(config_dir); + config_dir = NULL; + return NULL; + } } - } - if (!color_dir) /* Convenient to make the color dir here */ - { - color_dir = - g_build_path (G_DIR_SEPARATOR_S, config_dir, PCB_COLORS_DIR, NULL); - if (!g_file_test (color_dir, G_FILE_TEST_IS_DIR)) - { - if (MKDIR (color_dir, 0755) < 0) - { - g_message ("config_file_open: Can't make \"%s\" directory!", - color_dir); - g_free (color_dir); - color_dir = NULL; - } - fname = g_build_path (G_DIR_SEPARATOR_S, - color_dir, "Default", NULL); - dup_string (&color_file, fname); - g_free (fname); + if (!color_dir) { /* Convenient to make the color dir here */ + color_dir = g_build_path(G_DIR_SEPARATOR_S, config_dir, PCB_COLORS_DIR, NULL); + if (!g_file_test(color_dir, G_FILE_TEST_IS_DIR)) { + if (MKDIR(color_dir, 0755) < 0) { + g_message("config_file_open: Can't make \"%s\" directory!", color_dir); + g_free(color_dir); + color_dir = NULL; + } + fname = g_build_path(G_DIR_SEPARATOR_S, color_dir, "Default", NULL); + dup_string(&color_file, fname); + g_free(fname); + } } - } - fname = g_build_path (G_DIR_SEPARATOR_S, config_dir, PCB_CONFIG_FILE, NULL); - f = fopen (fname, mode); + fname = g_build_path(G_DIR_SEPARATOR_S, config_dir, PCB_CONFIG_FILE, NULL); + f = fopen(fname, mode); - g_free (fname); - return f; + g_free(fname); + return f; } -static ConfigAttribute * -lookup_config_attribute (gchar * name, gboolean if_null_value) +static ConfigAttribute *lookup_config_attribute(gchar * name, gboolean if_null_value) { - ConfigAttribute *ca; + ConfigAttribute *ca; - for (ca = &config_attributes[0]; - ca < &config_attributes[0] + G_N_ELEMENTS (config_attributes); ++ca) - { - if (name && (!strcmp (name, ca->name))) - { - if (ca->value && if_null_value) - break; - return ca; + for (ca = &config_attributes[0]; ca < &config_attributes[0] + G_N_ELEMENTS(config_attributes); ++ca) { + if (name && (!strcmp(name, ca->name))) { + if (ca->value && if_null_value) + break; + return ca; + } } - } - return NULL; + return NULL; } -void -ghid_config_init (void) +void ghid_config_init(void) { - HID_AttrNode *ha; - HID_Attribute *a; - ConfigAttribute *ca, dummy_attribute; - ConfigColor *cc; - gint len; + HID_AttrNode *ha; + HID_Attribute *a; + ConfigAttribute *ca, dummy_attribute; + ConfigColor *cc; + gint len; - ghidgui->n_mode_button_columns = 3; - ghidgui->small_label_markup = TRUE; - ghidgui->history_size = 5; - dup_string (&color_file, ""); + ghidgui->n_mode_button_columns = 3; + ghidgui->small_label_markup = TRUE; + ghidgui->history_size = 5; + dup_string(&color_file, ""); - for (ha = hid_attr_nodes; ha; ha = ha->next) - { - for (a = ha->attributes; a < ha->attributes + ha->n; ++a) - { - if (!a->value) - continue; - if ((ca = lookup_config_attribute (a->name, TRUE)) == NULL) - ca = &dummy_attribute; - ca->value = a->value; /* Typically &Setting.xxx */ - ca->type = CONFIG_Unused; - switch (a->type) - { - case HID_Boolean: - *(char *) a->value = a->default_val.int_value; - ca->type = CONFIG_Boolean; - break; - case HID_Integer: - *(int *) a->value = a->default_val.int_value; - ca->type = CONFIG_Integer; - break; - case HID_Coord: - *(Coord *) a->value = a->default_val.coord_value; - ca->type = CONFIG_Coord; - break; - case HID_Real: - *(double *) a->value = a->default_val.real_value; - ca->type = CONFIG_Real; - break; + for (ha = hid_attr_nodes; ha; ha = ha->next) { + for (a = ha->attributes; a < ha->attributes + ha->n; ++a) { + if (!a->value) + continue; + if ((ca = lookup_config_attribute(a->name, TRUE)) == NULL) + ca = &dummy_attribute; + ca->value = a->value; /* Typically &Setting.xxx */ + ca->type = CONFIG_Unused; + switch (a->type) { + case HID_Boolean: + *(char *) a->value = a->default_val.int_value; + ca->type = CONFIG_Boolean; + break; + case HID_Integer: + *(int *) a->value = a->default_val.int_value; + ca->type = CONFIG_Integer; + break; + case HID_Coord: + *(Coord *) a->value = a->default_val.coord_value; + ca->type = CONFIG_Coord; + break; + case HID_Real: + *(double *) a->value = a->default_val.real_value; + ca->type = CONFIG_Real; + break; - case HID_String: - if (!a->name) - break; - *(char **) a->value = g_strdup (a->default_val.str_value); - ca->type = CONFIG_String; + case HID_String: + if (!a->name) + break; + *(char **) a->value = g_strdup(a->default_val.str_value); + ca->type = CONFIG_String; - len = strlen (a->name); - if (len < 7 || strstr (a->name, "color") == NULL) - break; + len = strlen(a->name); + if (len < 7 || strstr(a->name, "color") == NULL) + break; - cc = g_new0 (ConfigColor, 1); - cc->attributes = a; + cc = g_new0(ConfigColor, 1); + cc->attributes = a; - if (!strncmp (a->name, "layer-color", 11)) - cc->type = LAYER_COLOR; - else if (!strncmp (a->name, "layer-selected-color", 20)) - cc->type = LAYER_SELECTED_COLOR; - else if (!strncmp (a->name + len - 14, "selected-color", 14)) - cc->type = MISC_SELECTED_COLOR; - else - cc->type = MISC_COLOR; + if (!strncmp(a->name, "layer-color", 11)) + cc->type = LAYER_COLOR; + else if (!strncmp(a->name, "layer-selected-color", 20)) + cc->type = LAYER_SELECTED_COLOR; + else if (!strncmp(a->name + len - 14, "selected-color", 14)) + cc->type = MISC_SELECTED_COLOR; + else + cc->type = MISC_COLOR; - config_color_list = g_list_append (config_color_list, cc); - break; + config_color_list = g_list_append(config_color_list, cc); + break; - case HID_Enum: - case HID_Unit: - *(int *) a->value = a->default_val.int_value; - break; + case HID_Enum: + case HID_Unit: + *(int *) a->value = a->default_val.int_value; + break; - case HID_Label: - case HID_Mixed: - case HID_Path: - break; - default: - abort (); - } - } - } + case HID_Label: + case HID_Mixed: + case HID_Path: + break; + default: + abort(); + } + } + } } -static gint -parse_option_line (gchar * line, gchar ** option_result, gchar ** arg_result) +static gint parse_option_line(gchar * line, gchar ** option_result, gchar ** arg_result) { - gchar *s, *ss, option[64], arg[512]; - gint argc = 1; + gchar *s, *ss, option[64], arg[512]; + gint argc = 1; - if (option_result) - *option_result = NULL; - if (arg_result) - *arg_result = NULL; + if (option_result) + *option_result = NULL; + if (arg_result) + *arg_result = NULL; - s = line; - while (*s == ' ' || *s == '\t') - ++s; - if (!*s || *s == '\n' || *s == '#' || *s == '[') - return 0; - if ((ss = strchr (s, '\n')) != NULL) - *ss = '\0'; - arg[0] = '\0'; - sscanf (s, "%63s %511[^\n]", option, arg); + s = line; + while (*s == ' ' || *s == '\t') + ++s; + if (!*s || *s == '\n' || *s == '#' || *s == '[') + return 0; + if ((ss = strchr(s, '\n')) != NULL) + *ss = '\0'; + arg[0] = '\0'; + sscanf(s, "%63s %511[^\n]", option, arg); - s = option; /* Strip trailing ':' or '=' */ - while (*s && *s != ':' && *s != '=') - ++s; - *s = '\0'; + s = option; /* Strip trailing ':' or '=' */ + while (*s && *s != ':' && *s != '=') + ++s; + *s = '\0'; - s = arg; /* Strip leading ':', '=', and whitespace */ - while (*s == ' ' || *s == '\t' || *s == ':' || *s == '=' || *s == '"') - ++s; - if ((ss = strchr (s, '"')) != NULL) - *ss = '\0'; + s = arg; /* Strip leading ':', '=', and whitespace */ + while (*s == ' ' || *s == '\t' || *s == ':' || *s == '=' || *s == '"') + ++s; + if ((ss = strchr(s, '"')) != NULL) + *ss = '\0'; - if (option_result) - *option_result = g_strdup (option); - if (arg_result && *s) - { - *arg_result = g_strdup (s); - ++argc; - } - return argc; + if (option_result) + *option_result = g_strdup(option); + if (arg_result && *s) { + *arg_result = g_strdup(s); + ++argc; + } + return argc; } -static gboolean -set_config_attribute (gchar * option, gchar * arg) +static gboolean set_config_attribute(gchar * option, gchar * arg) { - ConfigAttribute *ca; + ConfigAttribute *ca; #if 0 - struct lconv *lc; - gchar locale_point, *comma_point, *period_point; + struct lconv *lc; + gchar locale_point, *comma_point, *period_point; - /* Until LC_NUMERIC is totally resolved, check if we need to decimal - | point convert. Ultimately, data files will be POSIX and gui - | presentation (hence the config file reals) will be in the users locale. - */ - lc = localeconv (); - locale_point = *lc->decimal_point; + /* Until LC_NUMERIC is totally resolved, check if we need to decimal + | point convert. Ultimately, data files will be POSIX and gui + | presentation (hence the config file reals) will be in the users locale. + */ + lc = localeconv(); + locale_point = *lc->decimal_point; #endif - if ((ca = lookup_config_attribute (option, FALSE)) == NULL) - return FALSE; - switch (ca->type) - { - case CONFIG_Boolean: - *(gchar *) ca->value = (gchar) atoi (arg); - break; + if ((ca = lookup_config_attribute(option, FALSE)) == NULL) + return FALSE; + switch (ca->type) { + case CONFIG_Boolean: + *(gchar *) ca->value = (gchar) atoi(arg); + break; - case CONFIG_Integer: - *(gint *) ca->value = atoi (arg); - break; + case CONFIG_Integer: + *(gint *) ca->value = atoi(arg); + break; - case CONFIG_Real: - /* Hopefully temporary locale decimal point check: - */ + case CONFIG_Real: + /* Hopefully temporary locale decimal point check: + */ #if 0 - comma_point = strrchr (arg, ','); - period_point = strrchr (arg, '.'); - if (comma_point && *comma_point != locale_point) - *comma_point = locale_point; - else if (period_point && *period_point != locale_point) - *period_point = locale_point; + comma_point = strrchr(arg, ','); + period_point = strrchr(arg, '.'); + if (comma_point && *comma_point != locale_point) + *comma_point = locale_point; + else if (period_point && *period_point != locale_point) + *period_point = locale_point; #endif - *(double *) ca->value = atof (arg); - break; + *(double *) ca->value = atof(arg); + break; - case CONFIG_String: - dup_string ((gchar **) ca->value, arg ? arg : (gchar *)""); - break; - case CONFIG_Coord: - *(Coord *) ca->value = GetValue (arg, NULL, NULL); - break; - default: - break; - } - return TRUE; + case CONFIG_String: + dup_string((gchar **) ca->value, arg ? arg : (gchar *) ""); + break; + case CONFIG_Coord: + *(Coord *) ca->value = GetValue(arg, NULL, NULL); + break; + default: + break; + } + return TRUE; } -static void -config_file_read (void) +static void config_file_read(void) { - FILE *f; - gchar buf[512], *option, *arg; + FILE *f; + gchar buf[512], *option, *arg; - if ((f = config_file_open ("r")) == NULL) - return; + if ((f = config_file_open("r")) == NULL) + return; - buf[0] = '\0'; - while (fgets (buf, sizeof (buf), f)) - { - if (parse_option_line (buf, &option, &arg) > 0) - set_config_attribute (option, arg); - g_free (option); - g_free (arg); - } + buf[0] = '\0'; + while (fgets(buf, sizeof(buf), f)) { + if (parse_option_line(buf, &option, &arg) > 0) + set_config_attribute(option, arg); + g_free(option); + g_free(arg); + } - fclose (f); + fclose(f); } -static void -config_colors_write (gchar * path) +static void config_colors_write(gchar * path) { - FILE *f; - GList *list; - HID_Attribute *ha; - ConfigColor *cc; + FILE *f; + GList *list; + HID_Attribute *ha; + ConfigColor *cc; - if ((f = fopen (path, "w")) == NULL) - return; - for (list = config_color_list; list; list = list->next) - { - cc = (ConfigColor *) list->data; - ha = cc->attributes; - fprintf (f, "%s =\t%s\n", ha->name, *(char **) ha->value); - } - fclose (f); + if ((f = fopen(path, "w")) == NULL) + return; + for (list = config_color_list; list; list = list->next) { + cc = (ConfigColor *) list->data; + ha = cc->attributes; + fprintf(f, "%s =\t%s\n", ha->name, *(char **) ha->value); + } + fclose(f); } -static gboolean -config_colors_read (gchar * path) +static gboolean config_colors_read(gchar * path) { - FILE *f; - GList *list; - ConfigColor *cc; - HID_Attribute *ha; - gchar *s, buf[512], option[64], arg[512]; + FILE *f; + GList *list; + ConfigColor *cc; + HID_Attribute *ha; + gchar *s, buf[512], option[64], arg[512]; - if (!path || !*path || (f = fopen (path, "r")) == NULL) - return FALSE; + if (!path || !*path || (f = fopen(path, "r")) == NULL) + return FALSE; - while (fgets (buf, sizeof (buf), f)) - { - sscanf (buf, "%63s %511[^\n]", option, arg); - s = option; /* Strip trailing ':' or '=' */ - while (*s && *s != ':' && *s != '=') - ++s; - *s = '\0'; - s = arg; /* Strip leading ':', '=', and whitespace */ - while (*s == ' ' || *s == '\t' || *s == ':' || *s == '=') - ++s; + while (fgets(buf, sizeof(buf), f)) { + sscanf(buf, "%63s %511[^\n]", option, arg); + s = option; /* Strip trailing ':' or '=' */ + while (*s && *s != ':' && *s != '=') + ++s; + *s = '\0'; + s = arg; /* Strip leading ':', '=', and whitespace */ + while (*s == ' ' || *s == '\t' || *s == ':' || *s == '=') + ++s; - for (list = config_color_list; list; list = list->next) - { - cc = (ConfigColor *) list->data; - ha = cc->attributes; - if (!strcmp (option, ha->name)) - { - *(char **) ha->value = g_strdup (s); - cc->color_is_mapped = FALSE; - ghid_set_special_colors (ha); - break; - } + for (list = config_color_list; list; list = list->next) { + cc = (ConfigColor *) list->data; + ha = cc->attributes; + if (!strcmp(option, ha->name)) { + *(char **) ha->value = g_strdup(s); + cc->color_is_mapped = FALSE; + ghid_set_special_colors(ha); + break; + } + } } - } - fclose (f); + fclose(f); - return TRUE; + return TRUE; } -static gchar * -expand_dir (gchar * dir) +static gchar *expand_dir(gchar * dir) { - gchar *s; + gchar *s; - if (*dir == '~') - s = g_build_filename ((gchar *) g_get_home_dir (), dir + 1, NULL); - else - s = g_strdup (dir); - return s; + if (*dir == '~') + s = g_build_filename((gchar *) g_get_home_dir(), dir + 1, NULL); + else + s = g_strdup(dir); + return s; } -static void -add_to_paths_list (GList ** list, gchar * path_string) +static void add_to_paths_list(GList ** list, gchar * path_string) { - gchar *p, *paths; + gchar *p, *paths; - paths = g_strdup (path_string); - for (p = strtok (paths, PCB_PATH_DELIMETER); p && *p; p = strtok (NULL, PCB_PATH_DELIMETER)) - *list = g_list_prepend (*list, expand_dir (p)); - g_free (paths); + paths = g_strdup(path_string); + for (p = strtok(paths, PCB_PATH_DELIMETER); p && *p; p = strtok(NULL, PCB_PATH_DELIMETER)) + *list = g_list_prepend(*list, expand_dir(p)); + g_free(paths); } - /* Parse command line code borrowed from hid/common/hidinit.c - */ -static void -parse_optionv (gint * argc, gchar *** argv, gboolean from_cmd_line) + /* Parse command line code borrowed from hid/common/hidinit.c + */ +static void parse_optionv(gint * argc, gchar *** argv, gboolean from_cmd_line) { - HID_AttrNode *ha; - HID_Attribute *a; - const Unit *unit; - gchar *ep; - gint e, ok, offset; - gboolean matched = FALSE; + HID_AttrNode *ha; + HID_Attribute *a; + const Unit *unit; + gchar *ep; + gint e, ok, offset; + gboolean matched = FALSE; - offset = from_cmd_line ? 2 : 0; + offset = from_cmd_line ? 2 : 0; - while (*argc - && (((*argv)[0][0] == '-' && (*argv)[0][1] == '-') - || !from_cmd_line)) - { - for (ha = hid_attr_nodes; ha; ha = ha->next) - { - for (a = ha->attributes; a < ha->attributes + ha->n; ++a) - { - if (!a->name || strcmp ((*argv)[0] + offset, a->name)) - continue; - switch (a->type) - { - case HID_Label: - break; - case HID_Integer: - if (a->value) - *(int *) a->value = strtol ((*argv)[1], 0, 0); - else - a->default_val.int_value = strtol ((*argv)[1], 0, 0); - (*argc)--; - (*argv)++; - break; - case HID_Coord: - if (a->value) - *(Coord *) a->value = GetValue ((*argv)[1], 0, 0); - else - a->default_val.coord_value = GetValue ((*argv)[1], 0, 0); - (*argc)--; - (*argv)++; - break; - case HID_Real: - if (a->value) - *(double *) a->value = strtod ((*argv)[1], 0); - else - a->default_val.real_value = strtod ((*argv)[1], 0); - (*argc)--; - (*argv)++; - break; - case HID_String: - if (a->value) - *(char **) a->value = g_strdup((*argv)[1]); - else - a->default_val.str_value = g_strdup((*argv)[1]); - (*argc)--; - (*argv)++; - break; - case HID_Boolean: - if (a->value) - *(char *) a->value = 1; - else - a->default_val.int_value = 1; - break; - case HID_Mixed: - a->default_val.real_value = strtod ((*argv)[1], &ep); - goto do_enum; - case HID_Enum: - ep = (*argv)[1]; - do_enum: - ok = 0; - for (e = 0; a->enumerations[e]; e++) - if (strcmp (a->enumerations[e], ep) == 0) - { - ok = 1; - a->default_val.int_value = e; - a->default_val.str_value = ep; - break; - } - if (!ok) - { - fprintf (stderr, - "ERROR: \"%s\" is an unknown value for the --%s option\n", - (*argv)[1], a->name); - exit (1); - } - (*argc)--; - (*argv)++; - break; - case HID_Path: - abort (); - a->default_val.str_value = (*argv)[1]; - (*argc)--; - (*argv)++; - break; - case HID_Unit: - unit = get_unit_struct ((*argv)[1]); - if (unit == NULL) - { - fprintf (stderr, - "ERROR: unit \"%s\" is unknown to pcb (option --%s)\n", - (*argv)[1], a->name); - exit (1); - } - a->default_val.int_value = unit->index; - a->default_val.str_value = unit->suffix; - (*argc)--; - (*argv)++; - break; + while (*argc && (((*argv)[0][0] == '-' && (*argv)[0][1] == '-') + || !from_cmd_line)) { + for (ha = hid_attr_nodes; ha; ha = ha->next) { + for (a = ha->attributes; a < ha->attributes + ha->n; ++a) { + if (!a->name || strcmp((*argv)[0] + offset, a->name)) + continue; + switch (a->type) { + case HID_Label: + break; + case HID_Integer: + if (a->value) + *(int *) a->value = strtol((*argv)[1], 0, 0); + else + a->default_val.int_value = strtol((*argv)[1], 0, 0); + (*argc)--; + (*argv)++; + break; + case HID_Coord: + if (a->value) + *(Coord *) a->value = GetValue((*argv)[1], 0, 0); + else + a->default_val.coord_value = GetValue((*argv)[1], 0, 0); + (*argc)--; + (*argv)++; + break; + case HID_Real: + if (a->value) + *(double *) a->value = strtod((*argv)[1], 0); + else + a->default_val.real_value = strtod((*argv)[1], 0); + (*argc)--; + (*argv)++; + break; + case HID_String: + if (a->value) + *(char **) a->value = g_strdup((*argv)[1]); + else + a->default_val.str_value = g_strdup((*argv)[1]); + (*argc)--; + (*argv)++; + break; + case HID_Boolean: + if (a->value) + *(char *) a->value = 1; + else + a->default_val.int_value = 1; + break; + case HID_Mixed: + a->default_val.real_value = strtod((*argv)[1], &ep); + goto do_enum; + case HID_Enum: + ep = (*argv)[1]; + do_enum: + ok = 0; + for (e = 0; a->enumerations[e]; e++) + if (strcmp(a->enumerations[e], ep) == 0) { + ok = 1; + a->default_val.int_value = e; + a->default_val.str_value = ep; + break; + } + if (!ok) { + fprintf(stderr, "ERROR: \"%s\" is an unknown value for the --%s option\n", (*argv)[1], a->name); + exit(1); + } + (*argc)--; + (*argv)++; + break; + case HID_Path: + abort(); + a->default_val.str_value = (*argv)[1]; + (*argc)--; + (*argv)++; + break; + case HID_Unit: + unit = get_unit_struct((*argv)[1]); + if (unit == NULL) { + fprintf(stderr, "ERROR: unit \"%s\" is unknown to pcb (option --%s)\n", (*argv)[1], a->name); + exit(1); + } + a->default_val.int_value = unit->index; + a->default_val.str_value = unit->suffix; + (*argc)--; + (*argv)++; + break; + } + (*argc)--; + (*argv)++; + ha = 0; + goto got_match; + } + if (a < ha->attributes + ha->n) + matched = TRUE; } - (*argc)--; - (*argv)++; - ha = 0; - goto got_match; - } - if (a < ha->attributes + ha->n) - matched = TRUE; - } - if (!matched) - { - if (from_cmd_line) - { - fprintf (stderr, "unrecognized option: %s\n", (*argv)[0]); - exit (1); - } - else + if (!matched) { + if (from_cmd_line) { + fprintf(stderr, "unrecognized option: %s\n", (*argv)[0]); + exit(1); + } + else /* ghid_log("unrecognized option: %s\n", (*argv)[0]);*/ - fprintf (stderr, "unrecognized option: %s\n", (*argv)[0]); + fprintf(stderr, "unrecognized option: %s\n", (*argv)[0]); + } + got_match:; } - got_match:; - } - (*argc)++; - (*argv)--; + (*argc)++; + (*argv)--; } -static void -load_rc_file (gchar * path) +static void load_rc_file(gchar * path) { - FILE *f; - gchar buf[1024], *av[2], **argv; - gint argc; + FILE *f; + gchar buf[1024], *av[2], **argv; + gint argc; - f = fopen (path, "r"); - if (!f) - return; + f = fopen(path, "r"); + if (!f) + return; - if (Settings.verbose) - printf ("Loading pcbrc file: %s\n", path); - while (fgets (buf, sizeof (buf), f)) - { - argv = &(av[0]); - if ((argc = parse_option_line (buf, &av[0], &av[1])) > 0) - parse_optionv (&argc, &argv, FALSE); - g_free (av[0]); - g_free (av[1]); - } - fclose (f); + if (Settings.verbose) + printf("Loading pcbrc file: %s\n", path); + while (fgets(buf, sizeof(buf), f)) { + argv = &(av[0]); + if ((argc = parse_option_line(buf, &av[0], &av[1])) > 0) + parse_optionv(&argc, &argv, FALSE); + g_free(av[0]); + g_free(av[1]); + } + fclose(f); } -static void -load_rc_files (void) +static void load_rc_files(void) { - gchar *path; + gchar *path; - load_rc_file ("/etc/pcbrc"); - load_rc_file ("/usr/local/etc/pcbrc"); + load_rc_file("/etc/pcbrc"); + load_rc_file("/usr/local/etc/pcbrc"); - path = g_build_filename (pcblibdir, "pcbrc", NULL); - load_rc_file (path); - g_free (path); + path = g_build_filename(pcblibdir, "pcbrc", NULL); + load_rc_file(path); + g_free(path); - path = g_build_filename ((gchar *) g_get_home_dir (), ".pcb/pcbrc", NULL); - load_rc_file (path); - g_free (path); + path = g_build_filename((gchar *) g_get_home_dir(), ".pcb/pcbrc", NULL); + load_rc_file(path); + g_free(path); - load_rc_file ("pcbrc"); + load_rc_file("pcbrc"); } -void -ghid_config_files_read (gint * argc, gchar *** argv) +void ghid_config_files_read(gint * argc, gchar *** argv) { - GList *list; - gchar *str, *dir; - gint width, height; + GList *list; + gchar *str, *dir; + gint width, height; - ghidgui = &_ghidgui; + ghidgui = &_ghidgui; - ghid_config_init (); - load_rc_files (); - config_file_read (); - config_colors_read (color_file); - (*argc)--; - (*argv)++; - parse_optionv (argc, argv, TRUE); + ghid_config_init(); + load_rc_files(); + config_file_read(); + config_colors_read(color_file); + (*argc)--; + (*argv)++; + parse_optionv(argc, argv, TRUE); - if (board_size_override - && sscanf (board_size_override, "%dx%d", &width, &height) == 2) - { - Settings.MaxWidth = TO_PCB_UNITS (width); - Settings.MaxHeight = TO_PCB_UNITS (height); - } + if (board_size_override && sscanf(board_size_override, "%dx%d", &width, &height) == 2) { + Settings.MaxWidth = TO_PCB_UNITS(width); + Settings.MaxHeight = TO_PCB_UNITS(height); + } - if (lib_newlib_config && *lib_newlib_config) - add_to_paths_list (&lib_newlib_list, lib_newlib_config); + if (lib_newlib_config && *lib_newlib_config) + add_to_paths_list(&lib_newlib_list, lib_newlib_config); - for (list = lib_newlib_list; list; list = list->next) - { - str = Settings.LibrarySearchPaths; - dir = expand_dir ((gchar *) list->data); - Settings.LibrarySearchPaths = g_strconcat (str, PCB_PATH_DELIMETER, dir, NULL); - g_free (dir); - g_free (str); - } + for (list = lib_newlib_list; list; list = list->next) { + str = Settings.LibrarySearchPaths; + dir = expand_dir((gchar *) list->data); + Settings.LibrarySearchPaths = g_strconcat(str, PCB_PATH_DELIMETER, dir, NULL); + g_free(dir); + g_free(str); + } } -void -ghid_config_files_write (void) +void ghid_config_files_write(void) { - FILE *f; - ConfigAttribute *ca; + FILE *f; + ConfigAttribute *ca; - if (!ghidgui->config_modified || (f = config_file_open ("w")) == NULL) - return; + if (!ghidgui->config_modified || (f = config_file_open("w")) == NULL) + return; - fprintf (f, "### PCB configuration file. ###\n"); + fprintf(f, "### PCB configuration file. ###\n"); - for (ca = &config_attributes[0]; - ca < &config_attributes[0] + G_N_ELEMENTS (config_attributes); ++ca) - { - switch (ca->type) - { - case CONFIG_Boolean: - fprintf (f, "%s = %d\n", ca->name, (gint) * (gchar *) ca->value); - break; + for (ca = &config_attributes[0]; ca < &config_attributes[0] + G_N_ELEMENTS(config_attributes); ++ca) { + switch (ca->type) { + case CONFIG_Boolean: + fprintf(f, "%s = %d\n", ca->name, (gint) * (gchar *) ca->value); + break; - case CONFIG_Integer: - fprintf (f, "%s = %d\n", ca->name, *(gint *) ca->value); - break; + case CONFIG_Integer: + fprintf(f, "%s = %d\n", ca->name, *(gint *) ca->value); + break; - case CONFIG_Real: - fprintf (f, "%s = %f\n", ca->name, *(double *) ca->value); - break; + case CONFIG_Real: + fprintf(f, "%s = %f\n", ca->name, *(double *) ca->value); + break; - case CONFIG_String: - if (*(char **) ca->value == NULL) - fprintf (f, "# %s = NULL\n", ca->name); - else - fprintf (f, "%s = %s\n", ca->name, *(char **) ca->value); - break; - default: - break; + case CONFIG_String: + if (*(char **) ca->value == NULL) + fprintf(f, "# %s = NULL\n", ca->name); + else + fprintf(f, "%s = %s\n", ca->name, *(char **) ca->value); + break; + default: + break; + } } - } - fclose (f); + fclose(f); - ghidgui->config_modified = FALSE; + ghidgui->config_modified = FALSE; } /* =================== OK, now the gui stuff ====================== @@ -792,437 +726,370 @@ */ static GtkWidget *config_window; - /* -------------- The General config page ---------------- - */ + /* -------------- The General config page ---------------- + */ -static void -config_command_window_toggle_cb (GtkToggleButton * button, gpointer data) +static void config_command_window_toggle_cb(GtkToggleButton * button, gpointer data) { - gboolean active = gtk_toggle_button_get_active (button); - static gboolean holdoff; + gboolean active = gtk_toggle_button_get_active(button); + static gboolean holdoff; - if (holdoff) - return; + if (holdoff) + return; - /* Can't toggle into command window mode if the status line command - | entry is active. - */ - if (ghidgui->command_entry_status_line_active) - { - holdoff = TRUE; - gtk_toggle_button_set_active (button, FALSE); - holdoff = FALSE; - return; - } - ghidgui->use_command_window = active; - ghid_command_use_command_window_sync (); + /* Can't toggle into command window mode if the status line command + | entry is active. + */ + if (ghidgui->command_entry_status_line_active) { + holdoff = TRUE; + gtk_toggle_button_set_active(button, FALSE); + holdoff = FALSE; + return; + } + ghidgui->use_command_window = active; + ghid_command_use_command_window_sync(); } -static void -config_compact_horizontal_toggle_cb (GtkToggleButton * button, gpointer data) +static void config_compact_horizontal_toggle_cb(GtkToggleButton * button, gpointer data) { - gboolean active = gtk_toggle_button_get_active (button); + gboolean active = gtk_toggle_button_get_active(button); - ghidgui->compact_horizontal = active; - ghid_set_status_line_label (); - ghidgui->config_modified = TRUE; + ghidgui->compact_horizontal = active; + ghid_set_status_line_label(); + ghidgui->config_modified = TRUE; } -static void -config_compact_vertical_toggle_cb (GtkToggleButton * button, gpointer data) +static void config_compact_vertical_toggle_cb(GtkToggleButton * button, gpointer data) { - gboolean active = gtk_toggle_button_get_active (button); + gboolean active = gtk_toggle_button_get_active(button); - ghidgui->compact_vertical = active; - ghid_pack_mode_buttons(); - ghidgui->config_modified = TRUE; + ghidgui->compact_vertical = active; + ghid_pack_mode_buttons(); + ghidgui->config_modified = TRUE; } -static void -config_general_toggle_cb (GtkToggleButton * button, void * setting) +static void config_general_toggle_cb(GtkToggleButton * button, void *setting) { - *(gint *)setting = gtk_toggle_button_get_active (button); - ghidgui->config_modified = TRUE; + *(gint *) setting = gtk_toggle_button_get_active(button); + ghidgui->config_modified = TRUE; } -static void -config_backup_spin_button_cb (GtkSpinButton * spin_button, gpointer data) +static void config_backup_spin_button_cb(GtkSpinButton * spin_button, gpointer data) { - Settings.BackupInterval = gtk_spin_button_get_value_as_int (spin_button); - EnableAutosave (); - ghidgui->config_modified = TRUE; + Settings.BackupInterval = gtk_spin_button_get_value_as_int(spin_button); + EnableAutosave(); + ghidgui->config_modified = TRUE; } -static void -config_history_spin_button_cb (GtkSpinButton * spin_button, gpointer data) +static void config_history_spin_button_cb(GtkSpinButton * spin_button, gpointer data) { - ghidgui->history_size = gtk_spin_button_get_value_as_int (spin_button); - ghidgui->config_modified = TRUE; + ghidgui->history_size = gtk_spin_button_get_value_as_int(spin_button); + ghidgui->config_modified = TRUE; } -static void -config_general_tab_create (GtkWidget * tab_vbox) +static void config_general_tab_create(GtkWidget * tab_vbox) { - GtkWidget *vbox; + GtkWidget *vbox; - gtk_container_set_border_width (GTK_CONTAINER (tab_vbox), 6); + gtk_container_set_border_width(GTK_CONTAINER(tab_vbox), 6); - vbox = ghid_category_vbox (tab_vbox, _("Enables"), 4, 2, TRUE, TRUE); + vbox = ghid_category_vbox(tab_vbox, _("Enables"), 4, 2, TRUE, TRUE); - ghid_check_button_connected (vbox, NULL, ghidgui->use_command_window, - TRUE, FALSE, FALSE, 2, - config_command_window_toggle_cb, NULL, - _("Use separate window for command entry")); + ghid_check_button_connected(vbox, NULL, ghidgui->use_command_window, + TRUE, FALSE, FALSE, 2, + config_command_window_toggle_cb, NULL, _("Use separate window for command entry")); - ghid_check_button_connected (vbox, NULL, ghidgui->compact_horizontal, - TRUE, FALSE, FALSE, 2, - config_compact_horizontal_toggle_cb, NULL, - _("Alternate window layout to allow smaller horizontal size")); + ghid_check_button_connected(vbox, NULL, ghidgui->compact_horizontal, + TRUE, FALSE, FALSE, 2, + config_compact_horizontal_toggle_cb, NULL, + _("Alternate window layout to allow smaller horizontal size")); - ghid_check_button_connected (vbox, NULL, ghidgui->compact_vertical, - TRUE, FALSE, FALSE, 2, - config_compact_vertical_toggle_cb, NULL, - _("Alternate window layout to allow smaller vertical size")); + ghid_check_button_connected(vbox, NULL, ghidgui->compact_vertical, + TRUE, FALSE, FALSE, 2, + config_compact_vertical_toggle_cb, NULL, + _("Alternate window layout to allow smaller vertical size")); - vbox = ghid_category_vbox (tab_vbox, _("Backups"), 4, 2, TRUE, TRUE); - ghid_check_button_connected (vbox, NULL, Settings.SaveInTMP, - TRUE, FALSE, FALSE, 2, - config_general_toggle_cb, &Settings.SaveInTMP, - _("If layout is modified at exit, save into PCB.%i.save")); - ghid_spin_button (vbox, NULL, Settings.BackupInterval, 0.0, 60 * 60, 60.0, - 600.0, 0, 0, config_backup_spin_button_cb, NULL, FALSE, - _("Seconds between auto backups\n" - "(set to zero to disable auto backups)")); + vbox = ghid_category_vbox(tab_vbox, _("Backups"), 4, 2, TRUE, TRUE); + ghid_check_button_connected(vbox, NULL, Settings.SaveInTMP, + TRUE, FALSE, FALSE, 2, + config_general_toggle_cb, &Settings.SaveInTMP, + _("If layout is modified at exit, save into PCB.%i.save")); + ghid_spin_button(vbox, NULL, Settings.BackupInterval, 0.0, 60 * 60, 60.0, + 600.0, 0, 0, config_backup_spin_button_cb, NULL, FALSE, + _("Seconds between auto backups\n" "(set to zero to disable auto backups)")); - vbox = ghid_category_vbox (tab_vbox, _("Misc"), 4, 2, TRUE, TRUE); - ghid_spin_button (vbox, NULL, ghidgui->history_size, - 5.0, 25.0, 1.0, 1.0, 0, 0, - config_history_spin_button_cb, NULL, FALSE, - _("Number of commands to remember in the history list")); + vbox = ghid_category_vbox(tab_vbox, _("Misc"), 4, 2, TRUE, TRUE); + ghid_spin_button(vbox, NULL, ghidgui->history_size, + 5.0, 25.0, 1.0, 1.0, 0, 0, + config_history_spin_button_cb, NULL, FALSE, _("Number of commands to remember in the history list")); } -static void -config_general_apply (void) +static void config_general_apply(void) { - /* save the settings */ - ghid_config_files_write (); + /* save the settings */ + ghid_config_files_write(); } - /* -------------- The Sizes config page ---------------- - */ + /* -------------- The Sizes config page ---------------- + */ -static GtkWidget *config_sizes_vbox, - *config_sizes_tab_vbox, *config_text_spin_button; +static GtkWidget *config_sizes_vbox, *config_sizes_tab_vbox, *config_text_spin_button; -static GtkWidget *use_board_size_default_button, - *use_drc_sizes_default_button; +static GtkWidget *use_board_size_default_button, *use_drc_sizes_default_button; static Coord new_board_width, new_board_height; -static void -config_sizes_apply (void) +static void config_sizes_apply(void) { - gboolean active; + gboolean active; - active = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON - (use_board_size_default_button)); - if (active) - { - Settings.MaxWidth = new_board_width; - Settings.MaxHeight = new_board_height; - ghidgui->config_modified = TRUE; - } + active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(use_board_size_default_button)); + if (active) { + Settings.MaxWidth = new_board_width; + Settings.MaxHeight = new_board_height; + ghidgui->config_modified = TRUE; + } - active = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON - (use_drc_sizes_default_button)); - if (active) - { - Settings.Bloat = PCB->Bloat; - Settings.Shrink = PCB->Shrink; - Settings.minWid = PCB->minWid; - Settings.minSlk = PCB->minSlk; - Settings.IsleArea = PCB->IsleArea; - Settings.minDrill = PCB->minDrill; - Settings.minRing = PCB->minRing; - ghidgui->config_modified = TRUE; - } + active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(use_drc_sizes_default_button)); + if (active) { + Settings.Bloat = PCB->Bloat; + Settings.Shrink = PCB->Shrink; + Settings.minWid = PCB->minWid; + Settings.minSlk = PCB->minSlk; + Settings.IsleArea = PCB->IsleArea; + Settings.minDrill = PCB->minDrill; + Settings.minRing = PCB->minRing; + ghidgui->config_modified = TRUE; + } - if (PCB->MaxWidth != new_board_width || PCB->MaxHeight != new_board_height) - ChangePCBSize (new_board_width, new_board_height); + if (PCB->MaxWidth != new_board_width || PCB->MaxHeight != new_board_height) + ChangePCBSize(new_board_width, new_board_height); } -static void -text_spin_button_cb (GtkSpinButton * spin, void * dst) +static void text_spin_button_cb(GtkSpinButton * spin, void *dst) { - *(gint *)dst = gtk_spin_button_get_value_as_int (spin); - ghidgui->config_modified = TRUE; - ghid_set_status_line_label (); + *(gint *) dst = gtk_spin_button_get_value_as_int(spin); + ghidgui->config_modified = TRUE; + ghid_set_status_line_label(); } -static void -coord_entry_cb (GHidCoordEntry * ce, void * dst) +static void coord_entry_cb(GHidCoordEntry * ce, void *dst) { - *(Coord *) dst = ghid_coord_entry_get_value (ce); - ghidgui->config_modified = TRUE; + *(Coord *) dst = ghid_coord_entry_get_value(ce); + ghidgui->config_modified = TRUE; } -static void -config_sizes_tab_create (GtkWidget * tab_vbox) +static void config_sizes_tab_create(GtkWidget * tab_vbox) { - GtkWidget *table, *vbox, *hbox; + GtkWidget *table, *vbox, *hbox; - /* Need a vbox we can destroy if user changes grid units. - */ - if (!config_sizes_vbox) - { - vbox = gtk_vbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (tab_vbox), vbox, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); - config_sizes_vbox = vbox; - config_sizes_tab_vbox = tab_vbox; - } + /* Need a vbox we can destroy if user changes grid units. + */ + if (!config_sizes_vbox) { + vbox = gtk_vbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(tab_vbox), vbox, FALSE, FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); + config_sizes_vbox = vbox; + config_sizes_tab_vbox = tab_vbox; + } - /* ---- Board Size ---- */ - vbox = ghid_category_vbox (config_sizes_vbox, _("Board Size"), - 4, 2, TRUE, TRUE); - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - table = gtk_table_new (2, 2, FALSE); - gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0); - gtk_table_set_col_spacings (GTK_TABLE (table), 6); - gtk_table_set_row_spacings (GTK_TABLE (table), 3); + /* ---- Board Size ---- */ + vbox = ghid_category_vbox(config_sizes_vbox, _("Board Size"), 4, 2, TRUE, TRUE); + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + table = gtk_table_new(2, 2, FALSE); + gtk_box_pack_start(GTK_BOX(hbox), table, FALSE, FALSE, 0); + gtk_table_set_col_spacings(GTK_TABLE(table), 6); + gtk_table_set_row_spacings(GTK_TABLE(table), 3); - new_board_width = PCB->MaxWidth; - new_board_height = PCB->MaxHeight; - ghid_table_coord_entry (table, 0, 0, NULL, - PCB->MaxWidth, MIN_SIZE, MAX_COORD, - CE_LARGE, 0, coord_entry_cb, - &new_board_width, FALSE, _("Width")); + new_board_width = PCB->MaxWidth; + new_board_height = PCB->MaxHeight; + ghid_table_coord_entry(table, 0, 0, NULL, + PCB->MaxWidth, MIN_SIZE, MAX_COORD, CE_LARGE, 0, coord_entry_cb, &new_board_width, FALSE, _("Width")); - ghid_table_coord_entry (table, 1, 0, NULL, - PCB->MaxHeight, MIN_SIZE, MAX_COORD, - CE_LARGE, 0, coord_entry_cb, - &new_board_height, FALSE, _("Height")); - ghid_check_button_connected (vbox, &use_board_size_default_button, FALSE, - TRUE, FALSE, FALSE, 0, NULL, NULL, - _("Use this board size as the default for new layouts")); + ghid_table_coord_entry(table, 1, 0, NULL, + PCB->MaxHeight, MIN_SIZE, MAX_COORD, + CE_LARGE, 0, coord_entry_cb, &new_board_height, FALSE, _("Height")); + ghid_check_button_connected(vbox, &use_board_size_default_button, FALSE, + TRUE, FALSE, FALSE, 0, NULL, NULL, _("Use this board size as the default for new layouts")); - /* ---- Text Scale ---- */ - vbox = ghid_category_vbox (config_sizes_vbox, _("Text Scale"), - 4, 2, TRUE, TRUE); - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - table = gtk_table_new (4, 2, FALSE); - gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0); - gtk_table_set_col_spacings (GTK_TABLE (table), 6); - gtk_table_set_row_spacings (GTK_TABLE (table), 3); + /* ---- Text Scale ---- */ + vbox = ghid_category_vbox(config_sizes_vbox, _("Text Scale"), 4, 2, TRUE, TRUE); + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + table = gtk_table_new(4, 2, FALSE); + gtk_box_pack_start(GTK_BOX(hbox), table, FALSE, FALSE, 0); + gtk_table_set_col_spacings(GTK_TABLE(table), 6); + gtk_table_set_row_spacings(GTK_TABLE(table), 3); - ghid_table_spin_button (table, 0, 0, &config_text_spin_button, - Settings.TextScale, - MIN_TEXTSCALE, MAX_TEXTSCALE, - 10.0, 10.0, - 0, 0, text_spin_button_cb, - &Settings.TextScale, FALSE, "%"); + ghid_table_spin_button(table, 0, 0, &config_text_spin_button, + Settings.TextScale, + MIN_TEXTSCALE, MAX_TEXTSCALE, 10.0, 10.0, 0, 0, text_spin_button_cb, &Settings.TextScale, FALSE, "%"); - /* ---- DRC Sizes ---- */ - vbox = ghid_category_vbox (config_sizes_vbox, _("Design Rule Checking"), - 4, 2, TRUE, TRUE); - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - table = gtk_table_new (4, 2, FALSE); - gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0); - gtk_table_set_col_spacings (GTK_TABLE (table), 6); - gtk_table_set_row_spacings (GTK_TABLE (table), 3); + /* ---- DRC Sizes ---- */ + vbox = ghid_category_vbox(config_sizes_vbox, _("Design Rule Checking"), 4, 2, TRUE, TRUE); + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + table = gtk_table_new(4, 2, FALSE); + gtk_box_pack_start(GTK_BOX(hbox), table, FALSE, FALSE, 0); + gtk_table_set_col_spacings(GTK_TABLE(table), 6); + gtk_table_set_row_spacings(GTK_TABLE(table), 3); - ghid_table_coord_entry (table, 0, 0, NULL, - PCB->Bloat, MIN_DRC_VALUE, MAX_DRC_VALUE, - CE_SMALL, 0, coord_entry_cb, - &PCB->Bloat, FALSE, - _("Minimum copper spacing")); + ghid_table_coord_entry(table, 0, 0, NULL, + PCB->Bloat, MIN_DRC_VALUE, MAX_DRC_VALUE, + CE_SMALL, 0, coord_entry_cb, &PCB->Bloat, FALSE, _("Minimum copper spacing")); - ghid_table_coord_entry (table, 1, 0, NULL, - PCB->minWid, MIN_DRC_VALUE, MAX_DRC_VALUE, - CE_SMALL, 0, coord_entry_cb, - &PCB->minWid, FALSE, - _("Minimum copper width")); + ghid_table_coord_entry(table, 1, 0, NULL, + PCB->minWid, MIN_DRC_VALUE, MAX_DRC_VALUE, + CE_SMALL, 0, coord_entry_cb, &PCB->minWid, FALSE, _("Minimum copper width")); - ghid_table_coord_entry (table, 2, 0, NULL, - PCB->Shrink, MIN_DRC_VALUE, MAX_DRC_VALUE, - CE_SMALL, 0, coord_entry_cb, - &PCB->Shrink, FALSE, - _("Minimum touching copper overlap")); + ghid_table_coord_entry(table, 2, 0, NULL, + PCB->Shrink, MIN_DRC_VALUE, MAX_DRC_VALUE, + CE_SMALL, 0, coord_entry_cb, &PCB->Shrink, FALSE, _("Minimum touching copper overlap")); - ghid_table_coord_entry (table, 3, 0, NULL, - PCB->minSlk, MIN_DRC_VALUE, MAX_DRC_VALUE, - CE_SMALL, 0, coord_entry_cb, - &PCB->minSlk, FALSE, - _("Minimum silk width")); + ghid_table_coord_entry(table, 3, 0, NULL, + PCB->minSlk, MIN_DRC_VALUE, MAX_DRC_VALUE, + CE_SMALL, 0, coord_entry_cb, &PCB->minSlk, FALSE, _("Minimum silk width")); - ghid_table_coord_entry (table, 4, 0, NULL, - PCB->minDrill, MIN_DRC_VALUE, MAX_DRC_VALUE, - CE_SMALL, 0, coord_entry_cb, - &PCB->minDrill, FALSE, - _("Minimum drill diameter")); + ghid_table_coord_entry(table, 4, 0, NULL, + PCB->minDrill, MIN_DRC_VALUE, MAX_DRC_VALUE, + CE_SMALL, 0, coord_entry_cb, &PCB->minDrill, FALSE, _("Minimum drill diameter")); - ghid_table_coord_entry (table, 5, 0, NULL, - PCB->minRing, MIN_DRC_VALUE, MAX_DRC_VALUE, - CE_SMALL, 0, coord_entry_cb, - &PCB->minRing, FALSE, - _("Minimum annular ring")); + ghid_table_coord_entry(table, 5, 0, NULL, + PCB->minRing, MIN_DRC_VALUE, MAX_DRC_VALUE, + CE_SMALL, 0, coord_entry_cb, &PCB->minRing, FALSE, _("Minimum annular ring")); - ghid_check_button_connected (vbox, &use_drc_sizes_default_button, FALSE, - TRUE, FALSE, FALSE, 0, NULL, NULL, - _ - ("Use DRC values as the default for new layouts")); + ghid_check_button_connected(vbox, &use_drc_sizes_default_button, FALSE, + TRUE, FALSE, FALSE, 0, NULL, NULL, _("Use DRC values as the default for new layouts")); - gtk_widget_show_all (config_sizes_vbox); + gtk_widget_show_all(config_sizes_vbox); } - /* -------------- The Increments config page ---------------- - */ - /* Increment/decrement values are kept in mil and mm units and not in - | PCB units. - */ + /* -------------- The Increments config page ---------------- + */ + /* Increment/decrement values are kept in mil and mm units and not in + | PCB units. + */ static GtkWidget *config_increments_vbox, *config_increments_tab_vbox; -static void -increment_spin_button_cb (GHidCoordEntry * ce, void * dst) +static void increment_spin_button_cb(GHidCoordEntry * ce, void *dst) { - *(Coord *)dst = ghid_coord_entry_get_value (ce); - ghidgui->config_modified = TRUE; + *(Coord *) dst = ghid_coord_entry_get_value(ce); + ghidgui->config_modified = TRUE; } -static void -config_increments_tab_create (GtkWidget * tab_vbox) +static void config_increments_tab_create(GtkWidget * tab_vbox) { - GtkWidget *vbox; - Coord *target; + GtkWidget *vbox; + Coord *target; - /* Need a vbox we can destroy if user changes grid units. - */ - if (!config_increments_vbox) - { - vbox = gtk_vbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (tab_vbox), vbox, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); - config_increments_vbox = vbox; - config_increments_tab_vbox = tab_vbox; - } + /* Need a vbox we can destroy if user changes grid units. + */ + if (!config_increments_vbox) { + vbox = gtk_vbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(tab_vbox), vbox, FALSE, FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); + config_increments_vbox = vbox; + config_increments_tab_vbox = tab_vbox; + } - /* ---- Grid Increment/Decrement ---- */ - vbox = ghid_category_vbox (config_increments_vbox, - _("Grid Increment/Decrement"), 4, 2, TRUE, TRUE); + /* ---- Grid Increment/Decrement ---- */ + vbox = ghid_category_vbox(config_increments_vbox, _("Grid Increment/Decrement"), 4, 2, TRUE, TRUE); - target = &Settings.increments->grid; - ghid_coord_entry (vbox, NULL, - Settings.increments->grid, - Settings.increments->grid_min, - Settings.increments->grid_max, - CE_SMALL, 0, increment_spin_button_cb, - target, FALSE, - _("For 'g' and 'g' grid change actions")); + target = &Settings.increments->grid; + ghid_coord_entry(vbox, NULL, + Settings.increments->grid, + Settings.increments->grid_min, + Settings.increments->grid_max, + CE_SMALL, 0, increment_spin_button_cb, target, FALSE, _("For 'g' and 'g' grid change actions")); - /* ---- Size Increment/Decrement ---- */ - vbox = ghid_category_vbox (config_increments_vbox, - _("Size Increment/Decrement"), 4, 2, TRUE, TRUE); + /* ---- Size Increment/Decrement ---- */ + vbox = ghid_category_vbox(config_increments_vbox, _("Size Increment/Decrement"), 4, 2, TRUE, TRUE); - target = &Settings.increments->size; - ghid_coord_entry (vbox, NULL, - Settings.increments->size, - Settings.increments->size_min, - Settings.increments->size_max, - CE_SMALL, 0, increment_spin_button_cb, - target, FALSE, - _("For 's' and 's' size change actions on lines,\n" - "pads, pins and text.\n" - "Use 's' and 's' for drill holes.")); + target = &Settings.increments->size; + ghid_coord_entry(vbox, NULL, + Settings.increments->size, + Settings.increments->size_min, + Settings.increments->size_max, + CE_SMALL, 0, increment_spin_button_cb, + target, FALSE, + _("For 's' and 's' size change actions on lines,\n" + "pads, pins and text.\n" "Use 's' and 's' for drill holes.")); - /* ---- Line Increment/Decrement ---- */ - vbox = ghid_category_vbox (config_increments_vbox, - _("Line Increment/Decrement"), 4, 2, TRUE, TRUE); + /* ---- Line Increment/Decrement ---- */ + vbox = ghid_category_vbox(config_increments_vbox, _("Line Increment/Decrement"), 4, 2, TRUE, TRUE); - target = &Settings.increments->line; - ghid_coord_entry (vbox, NULL, - Settings.increments->line, - Settings.increments->line_min, - Settings.increments->line_max, - CE_SMALL, 0, increment_spin_button_cb, - target, FALSE, - _("For 'l' and 'l' routing line width change actions")); + target = &Settings.increments->line; + ghid_coord_entry(vbox, NULL, + Settings.increments->line, + Settings.increments->line_min, + Settings.increments->line_max, + CE_SMALL, 0, increment_spin_button_cb, + target, FALSE, _("For 'l' and 'l' routing line width change actions")); - /* ---- Clear Increment/Decrement ---- */ - vbox = ghid_category_vbox (config_increments_vbox, - _("Clear Increment/Decrement"), 4, 2, TRUE, TRUE); + /* ---- Clear Increment/Decrement ---- */ + vbox = ghid_category_vbox(config_increments_vbox, _("Clear Increment/Decrement"), 4, 2, TRUE, TRUE); - target = &Settings.increments->clear; - ghid_coord_entry (vbox, NULL, - Settings.increments->clear, - Settings.increments->clear_min, - Settings.increments->clear_max, - CE_SMALL, 0, increment_spin_button_cb, - target, FALSE, - _("For 'k' and 'k' line clearance inside polygon size\n" - "change actions")); + target = &Settings.increments->clear; + ghid_coord_entry(vbox, NULL, + Settings.increments->clear, + Settings.increments->clear_min, + Settings.increments->clear_max, + CE_SMALL, 0, increment_spin_button_cb, + target, FALSE, _("For 'k' and 'k' line clearance inside polygon size\n" "change actions")); - gtk_widget_show_all (config_increments_vbox); + gtk_widget_show_all(config_increments_vbox); } - /* -------------- The Library config page ---------------- - */ + /* -------------- The Library config page ---------------- + */ static GtkWidget *library_newlib_entry; -static void -config_library_apply (void) +static void config_library_apply(void) { - if (dup_string - (&lib_newlib_config, ghid_entry_get_text (library_newlib_entry))) - ghidgui->config_modified = TRUE; + if (dup_string(&lib_newlib_config, ghid_entry_get_text(library_newlib_entry))) + ghidgui->config_modified = TRUE; } -static void -config_library_tab_create (GtkWidget * tab_vbox) +static void config_library_tab_create(GtkWidget * tab_vbox) { - GtkWidget *vbox, *label, *entry; + GtkWidget *vbox, *label, *entry; - gtk_container_set_border_width (GTK_CONTAINER (tab_vbox), 6); - vbox = ghid_category_vbox (tab_vbox, _("Element Directories"), - 4, 2, TRUE, TRUE); - label = gtk_label_new (""); - gtk_label_set_use_markup (GTK_LABEL (label), TRUE); - gtk_label_set_markup (GTK_LABEL (label), - _ - ("Enter a \"" - PCB_PATH_DELIMETER - "\" separated list of custom top level\n" - "element directories. For example:\n" - "\t~/gaf/pcb-elements" - PCB_PATH_DELIMETER - "packages" - PCB_PATH_DELIMETER - "/usr/local/pcb-elements\n" - "Elements should be organized into subdirectories below each\n" - "top level directory. Restart program for changes to take effect." - "")); + gtk_container_set_border_width(GTK_CONTAINER(tab_vbox), 6); + vbox = ghid_category_vbox(tab_vbox, _("Element Directories"), 4, 2, TRUE, TRUE); + label = gtk_label_new(""); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_label_set_markup(GTK_LABEL(label), + _ + ("Enter a \"" + PCB_PATH_DELIMETER + "\" separated list of custom top level\n" + "element directories. For example:\n" + "\t~/gaf/pcb-elements" + PCB_PATH_DELIMETER + "packages" + PCB_PATH_DELIMETER + "/usr/local/pcb-elements\n" + "Elements should be organized into subdirectories below each\n" + "top level directory. Restart program for changes to take effect." "")); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); - entry = gtk_entry_new (); - library_newlib_entry = entry; - gtk_entry_set_text (GTK_ENTRY (entry), lib_newlib_config); - gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 4); + gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); + entry = gtk_entry_new(); + library_newlib_entry = entry; + gtk_entry_set_text(GTK_ENTRY(entry), lib_newlib_config); + gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 4); } - /* -------------- The Layers Group config page ---------------- - */ -static GtkWidget *config_groups_table, *config_groups_vbox, *config_groups_window; + /* -------------- The Layers Group config page ---------------- + */ +static GtkWidget *config_groups_table, *config_groups_vbox, *config_groups_window; static GtkWidget *layer_entry[MAX_LAYER]; static GtkWidget *group_button[MAX_LAYER + 2][MAX_LAYER]; @@ -1234,340 +1101,298 @@ static gint config_layer_group[MAX_LAYER + 2]; static LayerGroupType layer_groups, /* Working copy */ - *lg_monitor; /* Keep track if our working copy */ + *lg_monitor; /* Keep track if our working copy */ /* needs to be changed (new layout) */ static gboolean groups_modified, groups_holdoff, layers_applying; static gchar *layer_info_text[] = { - N_("Layer Names\n"), - N_("You may enter layer names for the layers drawn on the screen.\n" - "The special 'component side' and 'solder side' are layers which\n" - "will be printed out, so they must have in their group at least one\n" - "of the other layers that are drawn on the screen.\n"), - "\n", - N_("Layer Groups\n"), - N_("Each layer on the screen may be in its own group which allows the\n" - "maximum number of board layers. However, for boards with fewer\n" - "layers, you may group layers together which will then print as a\n" - "single layer on a printout. This allows a visual color distinction\n" - "to be displayed on the screen for signal groups which will print as\n" - "a single layer\n"), - "\n", - N_("For example, for a 4 layer board a useful layer group arrangement\n" - "can be to have 3 screen displayed layers grouped into the same group\n" - "as the 'component side' and 'solder side' printout layers. Then\n" - "groups such as signals, ground, and supply traces can be color\n" - "coded on the screen while printing as a single layer. For this\n" - "you would select buttons and enter names on the Setup page to\n" - "structure four layer groups similar to this:\n"), - "\n", - N_("Group 1:"), - "\n\t", - N_("solder"), - "\n\t", - N_("GND-solder"), - "\n\t", - N_("Vcc-solder"), - "\n\t", - N_("solder side"), - "\n", - N_("Group 2:"), - "\n\t", - N_("component"), - "\n\t", - N_("GND-component"), - "\n\t", - N_("Vcc-component"), - "\n\t", - N_("component side"), - "\n", - N_("Group 3:"), - "\n\t", - N_("signal1"), - "\n", - N_("Group 4:"), - "\n\t", - N_("signal2"), - "\n" + N_("Layer Names\n"), + N_("You may enter layer names for the layers drawn on the screen.\n" + "The special 'component side' and 'solder side' are layers which\n" + "will be printed out, so they must have in their group at least one\n" + "of the other layers that are drawn on the screen.\n"), + "\n", + N_("Layer Groups\n"), + N_("Each layer on the screen may be in its own group which allows the\n" + "maximum number of board layers. However, for boards with fewer\n" + "layers, you may group layers together which will then print as a\n" + "single layer on a printout. This allows a visual color distinction\n" + "to be displayed on the screen for signal groups which will print as\n" "a single layer\n"), + "\n", + N_("For example, for a 4 layer board a useful layer group arrangement\n" + "can be to have 3 screen displayed layers grouped into the same group\n" + "as the 'component side' and 'solder side' printout layers. Then\n" + "groups such as signals, ground, and supply traces can be color\n" + "coded on the screen while printing as a single layer. For this\n" + "you would select buttons and enter names on the Setup page to\n" "structure four layer groups similar to this:\n"), + "\n", + N_("Group 1:"), + "\n\t", + N_("solder"), + "\n\t", + N_("GND-solder"), + "\n\t", + N_("Vcc-solder"), + "\n\t", + N_("solder side"), + "\n", + N_("Group 2:"), + "\n\t", + N_("component"), + "\n\t", + N_("GND-component"), + "\n\t", + N_("Vcc-component"), + "\n\t", + N_("component side"), + "\n", + N_("Group 3:"), + "\n\t", + N_("signal1"), + "\n", + N_("Group 4:"), + "\n\t", + N_("signal2"), + "\n" }; -static void -config_layer_groups_radio_button_cb (GtkToggleButton * button, gpointer data) +static void config_layer_groups_radio_button_cb(GtkToggleButton * button, gpointer data) { - gint layer = GPOINTER_TO_INT (data) >> 8; - gint group = GPOINTER_TO_INT (data) & 0xff; + gint layer = GPOINTER_TO_INT(data) >> 8; + gint group = GPOINTER_TO_INT(data) & 0xff; - if (!gtk_toggle_button_get_active (button) || groups_holdoff) - return; - config_layer_group[layer] = group; - groups_modified = TRUE; - ghidgui->config_modified = TRUE; + if (!gtk_toggle_button_get_active(button) || groups_holdoff) + return; + config_layer_group[layer] = group; + groups_modified = TRUE; + ghidgui->config_modified = TRUE; } - /* Construct a layer group string. Follow logic in WritePCBDataHeader(), - | but use g_string functions. - */ -static gchar * -make_layer_group_string (LayerGroupType * lg) + /* Construct a layer group string. Follow logic in WritePCBDataHeader(), + | but use g_string functions. + */ +static gchar *make_layer_group_string(LayerGroupType * lg) { - GString *string; - gint group, entry, layer; + GString *string; + gint group, entry, layer; - string = g_string_new (""); + string = g_string_new(""); - for (group = 0; group < max_group; group++) - { - if (lg->Number[group] == 0) - continue; - for (entry = 0; entry < lg->Number[group]; entry++) - { - layer = lg->Entries[group][entry]; - if (layer == component_silk_layer) - string = g_string_append (string, "c"); - else if (layer == solder_silk_layer) - string = g_string_append (string, "s"); - else - g_string_append_printf (string, "%d", layer + 1); + for (group = 0; group < max_group; group++) { + if (lg->Number[group] == 0) + continue; + for (entry = 0; entry < lg->Number[group]; entry++) { + layer = lg->Entries[group][entry]; + if (layer == component_silk_layer) + string = g_string_append(string, "c"); + else if (layer == solder_silk_layer) + string = g_string_append(string, "s"); + else + g_string_append_printf(string, "%d", layer + 1); - if (entry != lg->Number[group] - 1) - string = g_string_append (string, ","); + if (entry != lg->Number[group] - 1) + string = g_string_append(string, ","); + } + if (group != max_group - 1) + string = g_string_append(string, ":"); } - if (group != max_group - 1) - string = g_string_append (string, ":"); - } - return g_string_free (string, FALSE); /* Don't free string->str */ + return g_string_free(string, FALSE); /* Don't free string->str */ } -static void -config_layers_apply (void) +static void config_layers_apply(void) { - LayerType *layer; - gchar *s; - gint group, i; - gint componentgroup = 0, soldergroup = 0; - gboolean use_as_default = FALSE, layers_modified = FALSE; + LayerType *layer; + gchar *s; + gint group, i; + gint componentgroup = 0, soldergroup = 0; + gboolean use_as_default = FALSE, layers_modified = FALSE; #if FIXME - use_as_default = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON - (use_layer_default_button)); + use_as_default = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(use_layer_default_button)); #endif - /* Get each layer name entry and dup if modified into the PCB layer names - | and, if to use as default, the Settings layer names. - */ - for (i = 0; i < max_copper_layer; ++i) - { - layer = &PCB->Data->Layer[i]; - s = ghid_entry_get_text (layer_entry[i]); - if (dup_string (&layer->Name, s)) - layers_modified = TRUE; + /* Get each layer name entry and dup if modified into the PCB layer names + | and, if to use as default, the Settings layer names. + */ + for (i = 0; i < max_copper_layer; ++i) { + layer = &PCB->Data->Layer[i]; + s = ghid_entry_get_text(layer_entry[i]); + if (dup_string(&layer->Name, s)) + layers_modified = TRUE; /* FIXME */ - if (use_as_default && dup_string (&Settings.DefaultLayerName[i], s)) - ghidgui->config_modified = TRUE; + if (use_as_default && dup_string(&Settings.DefaultLayerName[i], s)) + ghidgui->config_modified = TRUE; - } - /* Layer names can be changed from the menus and that can update the - | config. So holdoff the loop. - */ - layers_applying = TRUE; - if (layers_modified) - ghid_layer_buttons_update (); - layers_applying = FALSE; + } + /* Layer names can be changed from the menus and that can update the + | config. So holdoff the loop. + */ + layers_applying = TRUE; + if (layers_modified) + ghid_layer_buttons_update(); + layers_applying = FALSE; - if (groups_modified) /* If any group radio buttons were toggled. */ - { - /* clear all entries and read layer by layer - */ - for (group = 0; group < max_group; group++) - layer_groups.Number[group] = 0; + if (groups_modified) { /* If any group radio buttons were toggled. */ + /* clear all entries and read layer by layer + */ + for (group = 0; group < max_group; group++) + layer_groups.Number[group] = 0; - for (i = 0; i < max_copper_layer + 2; i++) - { - group = config_layer_group[i] - 1; - layer_groups.Entries[group][layer_groups.Number[group]++] = i; + for (i = 0; i < max_copper_layer + 2; i++) { + group = config_layer_group[i] - 1; + layer_groups.Entries[group][layer_groups.Number[group]++] = i; - if (i == component_silk_layer) - componentgroup = group; - else if (i == solder_silk_layer) - soldergroup = group; - } + if (i == component_silk_layer) + componentgroup = group; + else if (i == solder_silk_layer) + soldergroup = group; + } - /* do some cross-checking - | solder-side and component-side must be in different groups - | solder-side and component-side must not be the only one in the group - */ - if (layer_groups.Number[soldergroup] <= 1 - || layer_groups.Number[componentgroup] <= 1) - { - Message (_ - ("Both 'solder side' or 'component side' layers must have at least\n" - "\tone other layer in their group.\n")); - return; + /* do some cross-checking + | solder-side and component-side must be in different groups + | solder-side and component-side must not be the only one in the group + */ + if (layer_groups.Number[soldergroup] <= 1 || layer_groups.Number[componentgroup] <= 1) { + Message(_("Both 'solder side' or 'component side' layers must have at least\n" "\tone other layer in their group.\n")); + return; + } + else if (soldergroup == componentgroup) { + Message(_("The 'solder side' and 'component side' layers are not allowed\n" "\tto be in the same layer group #\n")); + return; + } + PCB->LayerGroups = layer_groups; + ghid_invalidate_all(); + groups_modified = FALSE; } - else if (soldergroup == componentgroup) - { - Message (_ - ("The 'solder side' and 'component side' layers are not allowed\n" - "\tto be in the same layer group #\n")); - return; + if (use_as_default) { + s = make_layer_group_string(&PCB->LayerGroups); + if (dup_string(&Settings.Groups, s)) { + ParseGroupString(Settings.Groups, &Settings.LayerGroups, max_copper_layer); + ghidgui->config_modified = TRUE; + } + g_free(s); } - PCB->LayerGroups = layer_groups; - ghid_invalidate_all(); - groups_modified = FALSE; - } - if (use_as_default) - { - s = make_layer_group_string (&PCB->LayerGroups); - if (dup_string (&Settings.Groups, s)) - { - ParseGroupString (Settings.Groups, &Settings.LayerGroups, max_copper_layer); - ghidgui->config_modified = TRUE; - } - g_free (s); - } } -static void -config_layer_group_button_state_update (void) +static void config_layer_group_button_state_update(void) { - gint g, i; + gint g, i; - /* Set button active corresponding to layer group state. - */ - groups_holdoff = TRUE; - for (g = 0; g < max_group; g++) - for (i = 0; i < layer_groups.Number[g]; i++) - { + /* Set button active corresponding to layer group state. + */ + groups_holdoff = TRUE; + for (g = 0; g < max_group; g++) + for (i = 0; i < layer_groups.Number[g]; i++) { /* printf("layer %d in group %d\n", layer_groups.Entries[g][i], g +1); */ - config_layer_group[layer_groups.Entries[g][i]] = g + 1; - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (group_button - [layer_groups.Entries[g][i]][g]), - TRUE); - } - groups_holdoff = FALSE; + config_layer_group[layer_groups.Entries[g][i]] = g + 1; + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(group_button[layer_groups.Entries[g][i]][g]), TRUE); + } + groups_holdoff = FALSE; } -static void -layer_name_entry_cb(GtkWidget *entry, gpointer data) +static void layer_name_entry_cb(GtkWidget * entry, gpointer data) { - gint i = GPOINTER_TO_INT(data); - LayerType *layer; - gchar *name; + gint i = GPOINTER_TO_INT(data); + LayerType *layer; + gchar *name; layer = &PCB->Data->Layer[i]; name = ghid_entry_get_text(entry); - if (dup_string (&layer->Name, name)) + if (dup_string(&layer->Name, name)) ghid_layer_buttons_update(); } -void -ghid_config_groups_changed(void) +void ghid_config_groups_changed(void) { - GtkWidget *vbox, *table, *button, *label, *scrolled_window; - GSList *group; - gchar buf[32], *name; - gint layer, i; + GtkWidget *vbox, *table, *button, *label, *scrolled_window; + GSList *group; + gchar buf[32], *name; + gint layer, i; - if (!config_groups_vbox) - return; - vbox = config_groups_vbox; + if (!config_groups_vbox) + return; + vbox = config_groups_vbox; - if (config_groups_table) - gtk_widget_destroy(config_groups_table); - if (config_groups_window) - gtk_widget_destroy(config_groups_window); + if (config_groups_table) + gtk_widget_destroy(config_groups_table); + if (config_groups_window) + gtk_widget_destroy(config_groups_window); - config_groups_window = scrolled_window = - gtk_scrolled_window_new (NULL, NULL); - gtk_widget_set_size_request (scrolled_window, 34, 408); - gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 3); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); - gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0); - gtk_widget_show (scrolled_window); + config_groups_window = scrolled_window = gtk_scrolled_window_new(NULL, NULL); + gtk_widget_set_size_request(scrolled_window, 34, 408); + gtk_container_set_border_width(GTK_CONTAINER(scrolled_window), 3); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); + gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0); + gtk_widget_show(scrolled_window); - table = gtk_table_new (max_copper_layer + 3, max_group + 1, FALSE); - config_groups_table = table; - gtk_table_set_row_spacings (GTK_TABLE (table), 3); - gtk_scrolled_window_add_with_viewport ( - GTK_SCROLLED_WINDOW (scrolled_window), table); - gtk_widget_show (table); + table = gtk_table_new(max_copper_layer + 3, max_group + 1, FALSE); + config_groups_table = table; + gtk_table_set_row_spacings(GTK_TABLE(table), 3); + gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), table); + gtk_widget_show(table); - layer_groups = PCB->LayerGroups; /* working copy */ - lg_monitor = &PCB->LayerGroups; /* So can know if PCB changes on us */ + layer_groups = PCB->LayerGroups; /* working copy */ + lg_monitor = &PCB->LayerGroups; /* So can know if PCB changes on us */ - label = gtk_label_new (_("Group #")); - gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 0, 1); - gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + label = gtk_label_new(_("Group #")); + gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); + gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); - for (i = 1; i < max_group + 1; ++i) - { - if (i < 10) - snprintf (buf, sizeof (buf), " %d", i); - else - snprintf (buf, sizeof (buf), "%d", i); - label = gtk_label_new (buf); - gtk_table_attach_defaults (GTK_TABLE (table), label, i, i + 1, 0, 1); - } + for (i = 1; i < max_group + 1; ++i) { + if (i < 10) + snprintf(buf, sizeof(buf), " %d", i); + else + snprintf(buf, sizeof(buf), "%d", i); + label = gtk_label_new(buf); + gtk_table_attach_defaults(GTK_TABLE(table), label, i, i + 1, 0, 1); + } - /* Create a row of radio toggle buttons for layer. So each layer - | can have an active radio button set for the group it needs to be in. - */ - for (layer = 0; layer < max_copper_layer + 2; ++layer) - { - if (layer == component_silk_layer) - name = _("component side"); - else if (layer == solder_silk_layer) - name = _("solder side"); - else - name = (gchar *) UNKNOWN (PCB->Data->Layer[layer].Name); + /* Create a row of radio toggle buttons for layer. So each layer + | can have an active radio button set for the group it needs to be in. + */ + for (layer = 0; layer < max_copper_layer + 2; ++layer) { + if (layer == component_silk_layer) + name = _("component side"); + else if (layer == solder_silk_layer) + name = _("solder side"); + else + name = (gchar *) UNKNOWN(PCB->Data->Layer[layer].Name); - if (layer >= max_copper_layer) - { - label = gtk_label_new (name); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), label, - 0, 1, layer + 1, layer + 2); - } - else - { - layer_entry[layer] = gtk_entry_new (); - gtk_entry_set_text (GTK_ENTRY (layer_entry[layer]), name); - gtk_table_attach_defaults (GTK_TABLE (table), layer_entry[layer], - 0, 1, layer + 1, layer + 2); - g_signal_connect(G_OBJECT(layer_entry[layer]), "activate", - G_CALLBACK(layer_name_entry_cb), GINT_TO_POINTER(layer)); - } + if (layer >= max_copper_layer) { + label = gtk_label_new(name); + gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); + gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, layer + 1, layer + 2); + } + else { + layer_entry[layer] = gtk_entry_new(); + gtk_entry_set_text(GTK_ENTRY(layer_entry[layer]), name); + gtk_table_attach_defaults(GTK_TABLE(table), layer_entry[layer], 0, 1, layer + 1, layer + 2); + g_signal_connect(G_OBJECT(layer_entry[layer]), "activate", G_CALLBACK(layer_name_entry_cb), GINT_TO_POINTER(layer)); + } - group = NULL; - for (i = 0; i < max_group; ++i) - { - snprintf (buf, sizeof (buf), "%2.2d", i+1); - button = gtk_radio_button_new_with_label (group, buf); + group = NULL; + for (i = 0; i < max_group; ++i) { + snprintf(buf, sizeof(buf), "%2.2d", i + 1); + button = gtk_radio_button_new_with_label(group, buf); - gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE); - group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)); - gtk_table_attach_defaults (GTK_TABLE (table), button, - i + 1, i + 2, layer + 1, layer + 2); - g_signal_connect (G_OBJECT (button), "toggled", - G_CALLBACK (config_layer_groups_radio_button_cb), - GINT_TO_POINTER ((layer << 8) | (i + 1))); - group_button[layer][i] = button; + gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button), FALSE); + group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button)); + gtk_table_attach_defaults(GTK_TABLE(table), button, i + 1, i + 2, layer + 1, layer + 2); + g_signal_connect(G_OBJECT(button), "toggled", + G_CALLBACK(config_layer_groups_radio_button_cb), GINT_TO_POINTER((layer << 8) | (i + 1))); + group_button[layer][i] = button; + } } - } - gtk_widget_show_all(config_groups_vbox); - config_layer_group_button_state_update (); + gtk_widget_show_all(config_groups_vbox); + config_layer_group_button_state_update(); } -static void -edit_layer_button_cb(GtkWidget *widget, gchar *data) +static void edit_layer_button_cb(GtkWidget * widget, gchar * data) { - gchar **argv; + gchar **argv; if (PCB->RatDraw || PCB->SilkActive) return; @@ -1577,592 +1402,529 @@ g_strfreev(argv); } -static void -config_layers_tab_create (GtkWidget * tab_vbox) +static void config_layers_tab_create(GtkWidget * tab_vbox) { - GtkWidget *tabs, *vbox, *vbox1, *button, *text, *sep; - GtkWidget *hbox, *arrow; - gint i; + GtkWidget *tabs, *vbox, *vbox1, *button, *text, *sep; + GtkWidget *hbox, *arrow; + gint i; - tabs = gtk_notebook_new (); - gtk_box_pack_start (GTK_BOX (tab_vbox), tabs, TRUE, TRUE, 0); + tabs = gtk_notebook_new(); + gtk_box_pack_start(GTK_BOX(tab_vbox), tabs, TRUE, TRUE, 0); /* -- Change tab */ - vbox = ghid_notebook_page(tabs, _("Change"), 0, 6); - vbox1 = ghid_category_vbox(vbox, - _("Operations on currently selected layer:"), - 4, 2, TRUE, TRUE); + vbox = ghid_notebook_page(tabs, _("Change"), 0, 6); + vbox1 = ghid_category_vbox(vbox, _("Operations on currently selected layer:"), 4, 2, TRUE, TRUE); - button = gtk_button_new(); - arrow = gtk_arrow_new(GTK_ARROW_UP, GTK_SHADOW_ETCHED_IN); - gtk_container_add(GTK_CONTAINER(button), arrow); - g_signal_connect(G_OBJECT(button), (gchar *)"clicked", - G_CALLBACK(edit_layer_button_cb), (gchar *)"c,up"); - hbox = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox1), hbox, TRUE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); + button = gtk_button_new(); + arrow = gtk_arrow_new(GTK_ARROW_UP, GTK_SHADOW_ETCHED_IN); + gtk_container_add(GTK_CONTAINER(button), arrow); + g_signal_connect(G_OBJECT(button), (gchar *) "clicked", G_CALLBACK(edit_layer_button_cb), (gchar *) "c,up"); + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox1), hbox, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); - button = gtk_button_new(); - arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_ETCHED_IN); - gtk_container_add(GTK_CONTAINER(button), arrow); - g_signal_connect(G_OBJECT(button), (gchar *)"clicked", - G_CALLBACK(edit_layer_button_cb), (gchar *)"c,down"); - hbox = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox1), hbox, TRUE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); + button = gtk_button_new(); + arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_ETCHED_IN); + gtk_container_add(GTK_CONTAINER(button), arrow); + g_signal_connect(G_OBJECT(button), (gchar *) "clicked", G_CALLBACK(edit_layer_button_cb), (gchar *) "c,down"); + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox1), hbox, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); - button = gtk_button_new_from_stock(GTK_STOCK_DELETE); - g_signal_connect(G_OBJECT(button), (gchar *)"clicked", - G_CALLBACK(edit_layer_button_cb), (gchar *)"c,-1"); - hbox = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox1), hbox, TRUE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); + button = gtk_button_new_from_stock(GTK_STOCK_DELETE); + g_signal_connect(G_OBJECT(button), (gchar *) "clicked", G_CALLBACK(edit_layer_button_cb), (gchar *) "c,-1"); + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox1), hbox, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); - vbox1 = ghid_category_vbox(vbox, - _("Add new layer above currently selected layer:"), - 4, 2, TRUE, TRUE); - button = gtk_button_new_from_stock(GTK_STOCK_ADD); - g_signal_connect(G_OBJECT(button), (gchar *)"clicked", - G_CALLBACK(edit_layer_button_cb), (gchar *)"-1,c"); - hbox = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox1), hbox, TRUE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); + vbox1 = ghid_category_vbox(vbox, _("Add new layer above currently selected layer:"), 4, 2, TRUE, TRUE); + button = gtk_button_new_from_stock(GTK_STOCK_ADD); + g_signal_connect(G_OBJECT(button), (gchar *) "clicked", G_CALLBACK(edit_layer_button_cb), (gchar *) "-1,c"); + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox1), hbox, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); /* -- Groups tab */ - vbox = ghid_notebook_page (tabs, _("Groups"), 0, 6); - config_groups_vbox = gtk_vbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), config_groups_vbox, FALSE, FALSE, 0); - ghid_config_groups_changed(); - - sep = gtk_hseparator_new (); - gtk_box_pack_start (GTK_BOX (vbox), sep, FALSE, FALSE, 4); + vbox = ghid_notebook_page(tabs, _("Groups"), 0, 6); + config_groups_vbox = gtk_vbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), config_groups_vbox, FALSE, FALSE, 0); + ghid_config_groups_changed(); + sep = gtk_hseparator_new(); + gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 4); + #if FIXME - ghid_check_button_connected (vbox, &use_layer_default_button, FALSE, - TRUE, FALSE, FALSE, 8, NULL, NULL, - ("Use these layer settings as the default for new layouts")); + ghid_check_button_connected(vbox, &use_layer_default_button, FALSE, + TRUE, FALSE, FALSE, 8, NULL, NULL, ("Use these layer settings as the default for new layouts")); #endif /* -- Info tab */ - vbox = ghid_notebook_page (tabs, _("Info"), 0, 6); + vbox = ghid_notebook_page(tabs, _("Info"), 0, 6); - text = ghid_scrolled_text_view (vbox, NULL, - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - for (i = 0; i < sizeof (layer_info_text) / sizeof (gchar *); ++i) - ghid_text_view_append (text, _(layer_info_text[i])); + text = ghid_scrolled_text_view(vbox, NULL, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + for (i = 0; i < sizeof(layer_info_text) / sizeof(gchar *); ++i) + ghid_text_view_append(text, _(layer_info_text[i])); } -void -ghid_config_layer_name_update (gchar * name, gint layer) +void ghid_config_layer_name_update(gchar * name, gint layer) { - if (!config_window || layers_applying || !name) - return; - gtk_entry_set_text (GTK_ENTRY (layer_entry[layer]), name); + if (!config_window || layers_applying || !name) + return; + gtk_entry_set_text(GTK_ENTRY(layer_entry[layer]), name); - /* If we get a config layer name change because a new PCB is loaded - | or new layout started, need to change our working layer group copy. - */ - if (lg_monitor != &PCB->LayerGroups) - { - layer_groups = PCB->LayerGroups; - lg_monitor = &PCB->LayerGroups; - config_layer_group_button_state_update (); - groups_modified = FALSE; - } + /* If we get a config layer name change because a new PCB is loaded + | or new layout started, need to change our working layer group copy. + */ + if (lg_monitor != &PCB->LayerGroups) { + layer_groups = PCB->LayerGroups; + lg_monitor = &PCB->LayerGroups; + config_layer_group_button_state_update(); + groups_modified = FALSE; + } } - /* -------------- The Colors config page ---------------- - */ + /* -------------- The Colors config page ---------------- + */ static GtkWidget *config_colors_vbox, - *config_colors_tab_vbox, - *config_colors_save_button, - *config_color_file_label, *config_color_warn_label; + *config_colors_tab_vbox, *config_colors_save_button, *config_color_file_label, *config_color_warn_label; -static void config_colors_tab_create (GtkWidget * tab_vbox); +static void config_colors_tab_create(GtkWidget * tab_vbox); static gboolean config_colors_modified; -static void -config_color_file_set_label (void) +static void config_color_file_set_label(void) { - gchar *str, *name; + gchar *str, *name; - if (!*color_file) - name = g_strdup ("defaults"); - else - name = g_path_get_basename (color_file); + if (!*color_file) + name = g_strdup("defaults"); + else + name = g_path_get_basename(color_file); - str = g_strdup_printf (_("Current colors loaded: %s"), name); - gtk_label_set_markup (GTK_LABEL (config_color_file_label), str); - g_free (name); - g_free (str); + str = g_strdup_printf(_("Current colors loaded: %s"), name); + gtk_label_set_markup(GTK_LABEL(config_color_file_label), str); + g_free(name); + g_free(str); } -static void -config_color_defaults_cb (gpointer data) +static void config_color_defaults_cb(gpointer data) { - GList *list; - ConfigColor *cc; - HID_Attribute *ha; + GList *list; + ConfigColor *cc; + HID_Attribute *ha; - for (list = config_color_list; list; list = list->next) - { - cc = (ConfigColor *) list->data; - ha = cc->attributes; - dup_string ((char **) ha->value, ha->default_val.str_value); - cc->color_is_mapped = FALSE; - ghid_set_special_colors (ha); - } + for (list = config_color_list; list; list = list->next) { + cc = (ConfigColor *) list->data; + ha = cc->attributes; + dup_string((char **) ha->value, ha->default_val.str_value); + cc->color_is_mapped = FALSE; + ghid_set_special_colors(ha); + } - dup_string (&color_file, ""); - ghidgui->config_modified = TRUE; + dup_string(&color_file, ""); + ghidgui->config_modified = TRUE; - gtk_widget_set_sensitive (config_colors_save_button, FALSE); - gtk_widget_set_sensitive (config_color_warn_label, FALSE); - config_color_file_set_label (); - config_colors_modified = FALSE; + gtk_widget_set_sensitive(config_colors_save_button, FALSE); + gtk_widget_set_sensitive(config_color_warn_label, FALSE); + config_color_file_set_label(); + config_colors_modified = FALSE; - ghid_layer_buttons_color_update (); + ghid_layer_buttons_color_update(); - /* Receate the colors config page to pick up new colors. - */ - gtk_widget_destroy (config_colors_vbox); - config_colors_tab_create (config_colors_tab_vbox); + /* Receate the colors config page to pick up new colors. + */ + gtk_widget_destroy(config_colors_vbox); + config_colors_tab_create(config_colors_tab_vbox); - ghid_invalidate_all(); + ghid_invalidate_all(); } -static void -config_color_load_cb (gpointer data) +static void config_color_load_cb(gpointer data) { - gchar *path, *dir = g_strdup (color_dir); + gchar *path, *dir = g_strdup(color_dir); - path = ghid_dialog_file_select_open (_("Load Color File"), &dir, NULL); - if (path) - { - config_colors_read (path); - dup_string (&color_file, path); - ghidgui->config_modified = TRUE; + path = ghid_dialog_file_select_open(_("Load Color File"), &dir, NULL); + if (path) { + config_colors_read(path); + dup_string(&color_file, path); + ghidgui->config_modified = TRUE; - gtk_widget_set_sensitive (config_colors_save_button, FALSE); - gtk_widget_set_sensitive (config_color_warn_label, FALSE); - config_color_file_set_label (); - config_colors_modified = FALSE; - } - g_free (path); - g_free (dir); + gtk_widget_set_sensitive(config_colors_save_button, FALSE); + gtk_widget_set_sensitive(config_color_warn_label, FALSE); + config_color_file_set_label(); + config_colors_modified = FALSE; + } + g_free(path); + g_free(dir); - /* Receate the colors config page to pick up new colors. - */ - gtk_widget_destroy (config_colors_vbox); - config_colors_tab_create (config_colors_tab_vbox); + /* Receate the colors config page to pick up new colors. + */ + gtk_widget_destroy(config_colors_vbox); + config_colors_tab_create(config_colors_tab_vbox); - ghid_layer_buttons_color_update (); - ghid_invalidate_all(); + ghid_layer_buttons_color_update(); + ghid_invalidate_all(); } -static void -config_color_save_cb (gpointer data) +static void config_color_save_cb(gpointer data) { - gchar *name, *path, *dir = g_strdup (color_dir); + gchar *name, *path, *dir = g_strdup(color_dir); - path = - ghid_dialog_file_select_save (_("Save Color File"), &dir, NULL, NULL); - if (path) - { - name = g_path_get_basename (path); - if (!strcmp (name, "default")) - ghid_dialog_message (_ - ("Sorry, not overwriting the default color file!")); - else - { - config_colors_write (path); - dup_string (&color_file, path); - ghidgui->config_modified = TRUE; + path = ghid_dialog_file_select_save(_("Save Color File"), &dir, NULL, NULL); + if (path) { + name = g_path_get_basename(path); + if (!strcmp(name, "default")) + ghid_dialog_message(_("Sorry, not overwriting the default color file!")); + else { + config_colors_write(path); + dup_string(&color_file, path); + ghidgui->config_modified = TRUE; - gtk_widget_set_sensitive (config_colors_save_button, FALSE); - gtk_widget_set_sensitive (config_color_warn_label, FALSE); - config_color_file_set_label (); - config_colors_modified = FALSE; + gtk_widget_set_sensitive(config_colors_save_button, FALSE); + gtk_widget_set_sensitive(config_color_warn_label, FALSE); + config_color_file_set_label(); + config_colors_modified = FALSE; + } + g_free(name); } - g_free (name); - } - g_free (path); - g_free (dir); + g_free(path); + g_free(dir); } -static void -config_color_set_cb (GtkWidget * button, ConfigColor * cc) +static void config_color_set_cb(GtkWidget * button, ConfigColor * cc) { - GdkColor new_color; - HID_Attribute *ha = cc->attributes; - gchar *str; + GdkColor new_color; + HID_Attribute *ha = cc->attributes; + gchar *str; - gtk_color_button_get_color (GTK_COLOR_BUTTON (button), &new_color); - str = ghid_get_color_name (&new_color); - ghid_map_color_string (str, &cc->color); - *(char **) ha->value = str; + gtk_color_button_get_color(GTK_COLOR_BUTTON(button), &new_color); + str = ghid_get_color_name(&new_color); + ghid_map_color_string(str, &cc->color); + *(char **) ha->value = str; /* g_free(str); Memory leak */ - config_colors_modified = TRUE; - gtk_widget_set_sensitive (config_colors_save_button, TRUE); - gtk_widget_set_sensitive (config_color_warn_label, TRUE); + config_colors_modified = TRUE; + gtk_widget_set_sensitive(config_colors_save_button, TRUE); + gtk_widget_set_sensitive(config_color_warn_label, TRUE); - ghid_set_special_colors (ha); - ghid_layer_buttons_color_update (); - ghid_invalidate_all(); + ghid_set_special_colors(ha); + ghid_layer_buttons_color_update(); + ghid_invalidate_all(); } -static void -config_color_button_create (GtkWidget * box, ConfigColor * cc) +static void config_color_button_create(GtkWidget * box, ConfigColor * cc) { - GtkWidget *button, *hbox, *label; - HID_Attribute *ha = cc->attributes; - gchar *title; + GtkWidget *button, *hbox, *label; + HID_Attribute *ha = cc->attributes; + gchar *title; - hbox = gtk_hbox_new (FALSE, 6); - gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0); + hbox = gtk_hbox_new(FALSE, 6); + gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0); - if (!cc->color_is_mapped) - ghid_map_color_string (*(char **) ha->value, &cc->color); - cc->color_is_mapped = TRUE; + if (!cc->color_is_mapped) + ghid_map_color_string(*(char **) ha->value, &cc->color); + cc->color_is_mapped = TRUE; - title = g_strdup_printf (_("PCB %s Color"), ha->name); - button = gtk_color_button_new_with_color (&cc->color); - gtk_color_button_set_title (GTK_COLOR_BUTTON (button), title); - g_free (title); + title = g_strdup_printf(_("PCB %s Color"), ha->name); + button = gtk_color_button_new_with_color(&cc->color); + gtk_color_button_set_title(GTK_COLOR_BUTTON(button), title); + g_free(title); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - label = gtk_label_new (ha->name); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (button), "color-set", - G_CALLBACK (config_color_set_cb), cc); + gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); + label = gtk_label_new(ha->name); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + g_signal_connect(G_OBJECT(button), "color-set", G_CALLBACK(config_color_set_cb), cc); } -static void -config_colors_tab_create (GtkWidget * tab_vbox) +static void config_colors_tab_create(GtkWidget * tab_vbox) { - GtkWidget *scrolled_vbox, *vbox, *hbox, *expander, *sep; - GList *list; - ConfigColor *cc; + GtkWidget *scrolled_vbox, *vbox, *hbox, *expander, *sep; + GList *list; + ConfigColor *cc; - vbox = gtk_vbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (tab_vbox), vbox, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); + vbox = gtk_vbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(tab_vbox), vbox, TRUE, TRUE, 0); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); - config_colors_vbox = vbox; /* can be destroyed if color file loaded */ - config_colors_tab_vbox = tab_vbox; + config_colors_vbox = vbox; /* can be destroyed if color file loaded */ + config_colors_tab_vbox = tab_vbox; - scrolled_vbox = ghid_scrolled_vbox (config_colors_vbox, NULL, - GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + scrolled_vbox = ghid_scrolled_vbox(config_colors_vbox, NULL, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - /* ---- Main colors ---- */ - expander = gtk_expander_new (_("Main colors")); - gtk_box_pack_start (GTK_BOX (scrolled_vbox), expander, FALSE, FALSE, 2); - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (expander), vbox); - vbox = ghid_category_vbox (vbox, NULL, 0, 2, TRUE, FALSE); + /* ---- Main colors ---- */ + expander = gtk_expander_new(_("Main colors")); + gtk_box_pack_start(GTK_BOX(scrolled_vbox), expander, FALSE, FALSE, 2); + vbox = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(expander), vbox); + vbox = ghid_category_vbox(vbox, NULL, 0, 2, TRUE, FALSE); - for (list = config_color_list; list; list = list->next) - { - cc = (ConfigColor *) list->data; - if (cc->type != MISC_COLOR) - continue; - config_color_button_create (vbox, cc); - } + for (list = config_color_list; list; list = list->next) { + cc = (ConfigColor *) list->data; + if (cc->type != MISC_COLOR) + continue; + config_color_button_create(vbox, cc); + } - /* ---- Layer colors ---- */ - expander = gtk_expander_new (_("Layer colors")); - gtk_box_pack_start (GTK_BOX (scrolled_vbox), expander, FALSE, FALSE, 2); - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (expander), vbox); - vbox = ghid_category_vbox (vbox, NULL, 0, 2, TRUE, FALSE); + /* ---- Layer colors ---- */ + expander = gtk_expander_new(_("Layer colors")); + gtk_box_pack_start(GTK_BOX(scrolled_vbox), expander, FALSE, FALSE, 2); + vbox = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(expander), vbox); + vbox = ghid_category_vbox(vbox, NULL, 0, 2, TRUE, FALSE); - for (list = config_color_list; list; list = list->next) - { - cc = (ConfigColor *) list->data; - if (cc->type != LAYER_COLOR) - continue; - config_color_button_create (vbox, cc); - } + for (list = config_color_list; list; list = list->next) { + cc = (ConfigColor *) list->data; + if (cc->type != LAYER_COLOR) + continue; + config_color_button_create(vbox, cc); + } - /* ---- Selected colors ---- */ - expander = gtk_expander_new (_("Selected colors")); - gtk_box_pack_start (GTK_BOX (scrolled_vbox), expander, FALSE, FALSE, 2); - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (expander), vbox); - vbox = ghid_category_vbox (vbox, NULL, 0, 2, TRUE, FALSE); + /* ---- Selected colors ---- */ + expander = gtk_expander_new(_("Selected colors")); + gtk_box_pack_start(GTK_BOX(scrolled_vbox), expander, FALSE, FALSE, 2); + vbox = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(expander), vbox); + vbox = ghid_category_vbox(vbox, NULL, 0, 2, TRUE, FALSE); - for (list = config_color_list; list; list = list->next) - { - cc = (ConfigColor *) list->data; - if (cc->type != MISC_SELECTED_COLOR) - continue; - config_color_button_create (vbox, cc); - } - sep = gtk_hseparator_new (); - gtk_box_pack_start (GTK_BOX (vbox), sep, FALSE, FALSE, 2); - for (list = config_color_list; list; list = list->next) - { - cc = (ConfigColor *) list->data; - if (cc->type != LAYER_SELECTED_COLOR) - continue; - config_color_button_create (vbox, cc); - } + for (list = config_color_list; list; list = list->next) { + cc = (ConfigColor *) list->data; + if (cc->type != MISC_SELECTED_COLOR) + continue; + config_color_button_create(vbox, cc); + } + sep = gtk_hseparator_new(); + gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 2); + for (list = config_color_list; list; list = list->next) { + cc = (ConfigColor *) list->data; + if (cc->type != LAYER_SELECTED_COLOR) + continue; + config_color_button_create(vbox, cc); + } - config_color_warn_label = gtk_label_new (""); - gtk_label_set_use_markup (GTK_LABEL (config_color_warn_label), TRUE); - gtk_label_set_markup (GTK_LABEL (config_color_warn_label), - _("Warning: unsaved color changes will be lost" - " at program exit.")); - gtk_box_pack_start (GTK_BOX (config_colors_vbox), config_color_warn_label, - FALSE, FALSE, 4); + config_color_warn_label = gtk_label_new(""); + gtk_label_set_use_markup(GTK_LABEL(config_color_warn_label), TRUE); + gtk_label_set_markup(GTK_LABEL(config_color_warn_label), + _("Warning: unsaved color changes will be lost" " at program exit.")); + gtk_box_pack_start(GTK_BOX(config_colors_vbox), config_color_warn_label, FALSE, FALSE, 4); - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (config_colors_vbox), hbox, FALSE, FALSE, 6); + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(config_colors_vbox), hbox, FALSE, FALSE, 6); - config_color_file_label = gtk_label_new (""); - gtk_label_set_use_markup (GTK_LABEL (config_color_file_label), TRUE); - config_color_file_set_label (); - gtk_box_pack_start (GTK_BOX (hbox), config_color_file_label, - FALSE, FALSE, 0); + config_color_file_label = gtk_label_new(""); + gtk_label_set_use_markup(GTK_LABEL(config_color_file_label), TRUE); + config_color_file_set_label(); + gtk_box_pack_start(GTK_BOX(hbox), config_color_file_label, FALSE, FALSE, 0); - ghid_button_connected (hbox, NULL, FALSE, FALSE, FALSE, 4, - config_color_load_cb, NULL, _("Load")); - ghid_button_connected (hbox, &config_colors_save_button, - FALSE, FALSE, FALSE, 4, - config_color_save_cb, NULL, _("Save")); - ghid_button_connected (hbox, NULL, FALSE, FALSE, FALSE, 4, - config_color_defaults_cb, NULL, _("Defaults")); + ghid_button_connected(hbox, NULL, FALSE, FALSE, FALSE, 4, config_color_load_cb, NULL, _("Load")); + ghid_button_connected(hbox, &config_colors_save_button, FALSE, FALSE, FALSE, 4, config_color_save_cb, NULL, _("Save")); + ghid_button_connected(hbox, NULL, FALSE, FALSE, FALSE, 4, config_color_defaults_cb, NULL, _("Defaults")); - gtk_widget_set_sensitive (config_colors_save_button, - config_colors_modified); - gtk_widget_set_sensitive (config_color_warn_label, config_colors_modified); - gtk_widget_show_all (config_colors_vbox); + gtk_widget_set_sensitive(config_colors_save_button, config_colors_modified); + gtk_widget_set_sensitive(config_color_warn_label, config_colors_modified); + gtk_widget_show_all(config_colors_vbox); } - /* --------------- The main config page ----------------- - */ -enum -{ - CONFIG_NAME_COLUMN, - CONFIG_PAGE_COLUMN, - N_CONFIG_COLUMNS + /* --------------- The main config page ----------------- + */ +enum { + CONFIG_NAME_COLUMN, + CONFIG_PAGE_COLUMN, + N_CONFIG_COLUMNS }; static GtkNotebook *config_notebook; -static GtkWidget * -config_page_create (GtkTreeStore * tree, GtkTreeIter * iter, - GtkNotebook * notebook) +static GtkWidget *config_page_create(GtkTreeStore * tree, GtkTreeIter * iter, GtkNotebook * notebook) { - GtkWidget *vbox; - gint page; + GtkWidget *vbox; + gint page; - vbox = gtk_vbox_new (FALSE, 0); - gtk_notebook_append_page (notebook, vbox, NULL); - page = gtk_notebook_get_n_pages (notebook) - 1; - gtk_tree_store_set (tree, iter, CONFIG_PAGE_COLUMN, page, -1); - return vbox; + vbox = gtk_vbox_new(FALSE, 0); + gtk_notebook_append_page(notebook, vbox, NULL); + page = gtk_notebook_get_n_pages(notebook) - 1; + gtk_tree_store_set(tree, iter, CONFIG_PAGE_COLUMN, page, -1); + return vbox; } -void -ghid_config_handle_units_changed (void) +void ghid_config_handle_units_changed(void) { - gchar *text = pcb_g_strdup_printf ("%s", - Settings.grid_unit->in_suffix); - ghid_set_cursor_position_labels (); - gtk_label_set_markup (GTK_LABEL (ghidgui->grid_units_label), text); - g_free (text); + gchar *text = pcb_g_strdup_printf("%s", + Settings.grid_unit->in_suffix); + ghid_set_cursor_position_labels(); + gtk_label_set_markup(GTK_LABEL(ghidgui->grid_units_label), text); + g_free(text); - if (config_sizes_vbox) - { - gtk_widget_destroy (config_sizes_vbox); - config_sizes_vbox = NULL; - config_sizes_tab_create (config_sizes_tab_vbox); - } - if (config_increments_vbox) - { - gtk_widget_destroy (config_increments_vbox); - config_increments_vbox = NULL; - config_increments_tab_create (config_increments_tab_vbox); - } - ghidgui->config_modified = TRUE; + if (config_sizes_vbox) { + gtk_widget_destroy(config_sizes_vbox); + config_sizes_vbox = NULL; + config_sizes_tab_create(config_sizes_tab_vbox); + } + if (config_increments_vbox) { + gtk_widget_destroy(config_increments_vbox); + config_increments_vbox = NULL; + config_increments_tab_create(config_increments_tab_vbox); + } + ghidgui->config_modified = TRUE; } -void -ghid_config_text_scale_update (void) +void ghid_config_text_scale_update(void) { - if (config_window) - gtk_spin_button_set_value (GTK_SPIN_BUTTON (config_text_spin_button), - (gdouble) Settings.TextScale); + if (config_window) + gtk_spin_button_set_value(GTK_SPIN_BUTTON(config_text_spin_button), (gdouble) Settings.TextScale); } -static void -config_close_cb (gpointer data) +static void config_close_cb(gpointer data) { - /* Config pages may need to check for modified entries, use as default - | options, etc when the config window is closed. - */ - config_sizes_apply (); - config_layers_apply (); - config_library_apply (); - config_general_apply (); + /* Config pages may need to check for modified entries, use as default + | options, etc when the config window is closed. + */ + config_sizes_apply(); + config_layers_apply(); + config_library_apply(); + config_general_apply(); - config_sizes_vbox = NULL; - config_increments_vbox = NULL; + config_sizes_vbox = NULL; + config_increments_vbox = NULL; - config_groups_vbox = config_groups_table = NULL; - config_groups_window = NULL; + config_groups_vbox = config_groups_table = NULL; + config_groups_window = NULL; - gtk_widget_destroy (config_window); - config_window = NULL; + gtk_widget_destroy(config_window); + config_window = NULL; } -static void -config_destroy_cb (gpointer data) +static void config_destroy_cb(gpointer data) { - config_sizes_vbox = NULL; - config_increments_vbox = NULL; - config_groups_vbox = config_groups_table = NULL; - config_groups_window = NULL; - gtk_widget_destroy (config_window); - config_window = NULL; + config_sizes_vbox = NULL; + config_increments_vbox = NULL; + config_groups_vbox = config_groups_table = NULL; + config_groups_window = NULL; + gtk_widget_destroy(config_window); + config_window = NULL; } -static void -config_selection_changed_cb (GtkTreeSelection * selection, gpointer data) +static void config_selection_changed_cb(GtkTreeSelection * selection, gpointer data) { - GtkTreeIter iter; - GtkTreeModel *model; - gint page; + GtkTreeIter iter; + GtkTreeModel *model; + gint page; - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) - return; - gtk_tree_model_get (model, &iter, CONFIG_PAGE_COLUMN, &page, -1); - gtk_notebook_set_current_page (config_notebook, page); + if (!gtk_tree_selection_get_selected(selection, &model, &iter)) + return; + gtk_tree_model_get(model, &iter, CONFIG_PAGE_COLUMN, &page, -1); + gtk_notebook_set_current_page(config_notebook, page); } -void -ghid_config_window_show (void) +void ghid_config_window_show(void) { - GtkWidget *widget, *main_vbox, *vbox, *config_hbox, *hbox; - GtkWidget *scrolled; - GtkWidget *button; - GtkTreeStore *model; - GtkTreeView *treeview; - GtkTreeIter iter; - GtkCellRenderer *renderer; - GtkTreeViewColumn *column; - GtkTreeSelection *select; + GtkWidget *widget, *main_vbox, *vbox, *config_hbox, *hbox; + GtkWidget *scrolled; + GtkWidget *button; + GtkTreeStore *model; + GtkTreeView *treeview; + GtkTreeIter iter; + GtkCellRenderer *renderer; + GtkTreeViewColumn *column; + GtkTreeSelection *select; - if (config_window) - { - gtk_window_present (GTK_WINDOW (config_window)); - return; - } + if (config_window) { + gtk_window_present(GTK_WINDOW(config_window)); + return; + } - config_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - g_signal_connect (G_OBJECT (config_window), "delete_event", - G_CALLBACK (config_destroy_cb), NULL); + config_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + g_signal_connect(G_OBJECT(config_window), "delete_event", G_CALLBACK(config_destroy_cb), NULL); - gtk_window_set_title (GTK_WINDOW (config_window), _("PCB Preferences")); - gtk_window_set_wmclass (GTK_WINDOW (config_window), "Pcb_Conf", "PCB"); - gtk_container_set_border_width (GTK_CONTAINER (config_window), 2); + gtk_window_set_title(GTK_WINDOW(config_window), _("PCB Preferences")); + gtk_window_set_wmclass(GTK_WINDOW(config_window), "Pcb_Conf", "PCB"); + gtk_container_set_border_width(GTK_CONTAINER(config_window), 2); - config_hbox = gtk_hbox_new (FALSE, 4); - gtk_container_add (GTK_CONTAINER (config_window), config_hbox); + config_hbox = gtk_hbox_new(FALSE, 4); + gtk_container_add(GTK_CONTAINER(config_window), config_hbox); - scrolled = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), - GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - gtk_box_pack_start (GTK_BOX (config_hbox), scrolled, FALSE, FALSE, 0); + scrolled = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + gtk_box_pack_start(GTK_BOX(config_hbox), scrolled, FALSE, FALSE, 0); - main_vbox = gtk_vbox_new (FALSE, 4); - gtk_box_pack_start (GTK_BOX (config_hbox), main_vbox, TRUE, TRUE, 0); + main_vbox = gtk_vbox_new(FALSE, 4); + gtk_box_pack_start(GTK_BOX(config_hbox), main_vbox, TRUE, TRUE, 0); - widget = gtk_notebook_new (); - gtk_box_pack_start (GTK_BOX (main_vbox), widget, TRUE, TRUE, 0); - config_notebook = GTK_NOTEBOOK (widget); - gtk_notebook_set_show_tabs (config_notebook, FALSE); + widget = gtk_notebook_new(); + gtk_box_pack_start(GTK_BOX(main_vbox), widget, TRUE, TRUE, 0); + config_notebook = GTK_NOTEBOOK(widget); + gtk_notebook_set_show_tabs(config_notebook, FALSE); - model = gtk_tree_store_new (N_CONFIG_COLUMNS, G_TYPE_STRING, G_TYPE_INT); + model = gtk_tree_store_new(N_CONFIG_COLUMNS, G_TYPE_STRING, G_TYPE_INT); - /* -- General -- */ - gtk_tree_store_append (model, &iter, NULL); - gtk_tree_store_set (model, &iter, CONFIG_NAME_COLUMN, _("General"), -1); - vbox = config_page_create (model, &iter, config_notebook); - config_general_tab_create (vbox); + /* -- General -- */ + gtk_tree_store_append(model, &iter, NULL); + gtk_tree_store_set(model, &iter, CONFIG_NAME_COLUMN, _("General"), -1); + vbox = config_page_create(model, &iter, config_notebook); + config_general_tab_create(vbox); - /* -- Sizes -- */ - gtk_tree_store_append (model, &iter, NULL); - gtk_tree_store_set (model, &iter, CONFIG_NAME_COLUMN, _("Sizes"), -1); - vbox = config_page_create (model, &iter, config_notebook); - config_sizes_tab_create (vbox); + /* -- Sizes -- */ + gtk_tree_store_append(model, &iter, NULL); + gtk_tree_store_set(model, &iter, CONFIG_NAME_COLUMN, _("Sizes"), -1); + vbox = config_page_create(model, &iter, config_notebook); + config_sizes_tab_create(vbox); - /* -- Increments -- */ - gtk_tree_store_append (model, &iter, NULL); - gtk_tree_store_set (model, &iter, CONFIG_NAME_COLUMN, _("Increments"), -1); - vbox = config_page_create (model, &iter, config_notebook); - config_increments_tab_create (vbox); + /* -- Increments -- */ + gtk_tree_store_append(model, &iter, NULL); + gtk_tree_store_set(model, &iter, CONFIG_NAME_COLUMN, _("Increments"), -1); + vbox = config_page_create(model, &iter, config_notebook); + config_increments_tab_create(vbox); - /* -- Library -- */ - gtk_tree_store_append (model, &iter, NULL); - gtk_tree_store_set (model, &iter, CONFIG_NAME_COLUMN, _("Library"), -1); - vbox = config_page_create (model, &iter, config_notebook); - config_library_tab_create (vbox); + /* -- Library -- */ + gtk_tree_store_append(model, &iter, NULL); + gtk_tree_store_set(model, &iter, CONFIG_NAME_COLUMN, _("Library"), -1); + vbox = config_page_create(model, &iter, config_notebook); + config_library_tab_create(vbox); - /* -- Layer names and groups -- */ - gtk_tree_store_append (model, &iter, NULL); - gtk_tree_store_set (model, &iter, CONFIG_NAME_COLUMN, _("Layers"), -1); - vbox = config_page_create (model, &iter, config_notebook); - config_layers_tab_create (vbox); + /* -- Layer names and groups -- */ + gtk_tree_store_append(model, &iter, NULL); + gtk_tree_store_set(model, &iter, CONFIG_NAME_COLUMN, _("Layers"), -1); + vbox = config_page_create(model, &iter, config_notebook); + config_layers_tab_create(vbox); - /* -- Colors -- */ - gtk_tree_store_append (model, &iter, NULL); - gtk_tree_store_set (model, &iter, CONFIG_NAME_COLUMN, _("Colors"), -1); - vbox = config_page_create (model, &iter, config_notebook); - config_colors_tab_create (vbox); + /* -- Colors -- */ + gtk_tree_store_append(model, &iter, NULL); + gtk_tree_store_set(model, &iter, CONFIG_NAME_COLUMN, _("Colors"), -1); + vbox = config_page_create(model, &iter, config_notebook); + config_colors_tab_create(vbox); - /* Create the tree view - */ - treeview = - GTK_TREE_VIEW (gtk_tree_view_new_with_model (GTK_TREE_MODEL (model))); - g_object_unref (G_OBJECT (model)); /* Don't need the model anymore */ + /* Create the tree view + */ + treeview = GTK_TREE_VIEW(gtk_tree_view_new_with_model(GTK_TREE_MODEL(model))); + g_object_unref(G_OBJECT(model)); /* Don't need the model anymore */ - renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (NULL, renderer, - "text", - CONFIG_NAME_COLUMN, - NULL); - gtk_tree_view_append_column (treeview, column); - gtk_container_add (GTK_CONTAINER (scrolled), GTK_WIDGET (treeview)); + renderer = gtk_cell_renderer_text_new(); + column = gtk_tree_view_column_new_with_attributes(NULL, renderer, "text", CONFIG_NAME_COLUMN, NULL); + gtk_tree_view_append_column(treeview, column); + gtk_container_add(GTK_CONTAINER(scrolled), GTK_WIDGET(treeview)); - select = gtk_tree_view_get_selection (treeview); - gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE); - g_signal_connect (G_OBJECT (select), "changed", - G_CALLBACK (config_selection_changed_cb), NULL); + select = gtk_tree_view_get_selection(treeview); + gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE); + g_signal_connect(G_OBJECT(select), "changed", G_CALLBACK(config_selection_changed_cb), NULL); - hbox = gtk_hbutton_box_new (); - gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_END); - gtk_box_set_spacing (GTK_BOX (hbox), 5); - gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0); + hbox = gtk_hbutton_box_new(); + gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_END); + gtk_box_set_spacing(GTK_BOX(hbox), 5); + gtk_box_pack_start(GTK_BOX(main_vbox), hbox, FALSE, FALSE, 0); - button = gtk_button_new_from_stock (GTK_STOCK_OK); - gtk_widget_set_can_default (button, TRUE); - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (config_close_cb), NULL); - gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); - gtk_widget_grab_default (button); + button = gtk_button_new_from_stock(GTK_STOCK_OK); + gtk_widget_set_can_default(button, TRUE); + g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(config_close_cb), NULL); + gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); + gtk_widget_grab_default(button); - gtk_widget_show_all (config_window); + gtk_widget_show_all(config_window); } Index: trunk/src/hid/gtk/gui-dialog-print.c =================================================================== --- trunk/src/hid/gtk/gui-dialog-print.c (revision 1021) +++ trunk/src/hid/gtk/gui-dialog-print.c (revision 1022) @@ -41,426 +41,372 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); static GtkWidget *export_dialog = NULL; -static void -set_flag_cb (GtkToggleButton * button, void * flag) +static void set_flag_cb(GtkToggleButton * button, void *flag) { - *(gboolean *)flag = gtk_toggle_button_get_active (button); + *(gboolean *) flag = gtk_toggle_button_get_active(button); } -static void -intspinner_changed_cb (GtkSpinButton * spin_button, gpointer data) +static void intspinner_changed_cb(GtkSpinButton * spin_button, gpointer data) { - int *ival = (int *)data; + int *ival = (int *) data; - *ival = gtk_spin_button_get_value (GTK_SPIN_BUTTON ((GtkWidget *)spin_button)); + *ival = gtk_spin_button_get_value(GTK_SPIN_BUTTON((GtkWidget *) spin_button)); } -static void -coordentry_changed_cb (GtkEntry * entry, Coord * res) +static void coordentry_changed_cb(GtkEntry * entry, Coord * res) { - const gchar *s = gtk_entry_get_text (entry); - *res = GetValue (s, NULL, NULL); + const gchar *s = gtk_entry_get_text(entry); + *res = GetValue(s, NULL, NULL); } -static void -dblspinner_changed_cb (GtkSpinButton * spin_button, gpointer data) +static void dblspinner_changed_cb(GtkSpinButton * spin_button, gpointer data) { - double *dval = (double *)data; + double *dval = (double *) data; - *dval = gtk_spin_button_get_value (GTK_SPIN_BUTTON ((GtkWidget *)spin_button)); + *dval = gtk_spin_button_get_value(GTK_SPIN_BUTTON((GtkWidget *) spin_button)); } -static void -entry_changed_cb (GtkEntry * entry, char **str) +static void entry_changed_cb(GtkEntry * entry, char **str) { - const gchar *s; + const gchar *s; - s = gtk_entry_get_text (entry); + s = gtk_entry_get_text(entry); - if (*str) - free (*str); - *str = strdup (s); + if (*str) + free(*str); + *str = strdup(s); } -static void -enum_changed_cb (GtkWidget * combo_box, int *val) +static void enum_changed_cb(GtkWidget * combo_box, int *val) { - gint active; + gint active; - active = gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box)); - *val = active; + active = gtk_combo_box_get_active(GTK_COMBO_BOX(combo_box)); + *val = active; } -int -ghid_attribute_dialog (HID_Attribute * attrs, - int n_attrs, HID_Attr_Val * results, - const char * title, - const char * descr) +int ghid_attribute_dialog(HID_Attribute * attrs, int n_attrs, HID_Attr_Val * results, const char *title, const char *descr) { - GtkWidget *dialog; - GtkWidget *content_area; - GtkWidget *main_vbox, *vbox, *vbox1, *hbox, *entry; - GtkWidget *combo; - GtkWidget *widget; - GHidPort *out = &ghid_port; - int i, j, n; - int rc = 0; + GtkWidget *dialog; + GtkWidget *content_area; + GtkWidget *main_vbox, *vbox, *vbox1, *hbox, *entry; + GtkWidget *combo; + GtkWidget *widget; + GHidPort *out = &ghid_port; + int i, j, n; + int rc = 0; - dialog = gtk_dialog_new_with_buttons (_(title), - GTK_WINDOW (out->top_window), - (GtkDialogFlags)(GTK_DIALOG_MODAL - | GTK_DIALOG_DESTROY_WITH_PARENT), - GTK_STOCK_CANCEL, GTK_RESPONSE_NONE, - GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); - gtk_window_set_wmclass (GTK_WINDOW (dialog), "PCB_attribute_editor", "PCB"); + dialog = gtk_dialog_new_with_buttons(_(title), + GTK_WINDOW(out->top_window), + (GtkDialogFlags) (GTK_DIALOG_MODAL + | GTK_DIALOG_DESTROY_WITH_PARENT), + GTK_STOCK_CANCEL, GTK_RESPONSE_NONE, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); + gtk_window_set_wmclass(GTK_WINDOW(dialog), "PCB_attribute_editor", "PCB"); - content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); + content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); - main_vbox = gtk_vbox_new (FALSE, 6); - gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 6); - gtk_container_add (GTK_CONTAINER (content_area), main_vbox); + main_vbox = gtk_vbox_new(FALSE, 6); + gtk_container_set_border_width(GTK_CONTAINER(main_vbox), 6); + gtk_container_add(GTK_CONTAINER(content_area), main_vbox); - vbox = ghid_category_vbox (main_vbox, descr != NULL ? descr : "", - 4, 2, TRUE, TRUE); + vbox = ghid_category_vbox(main_vbox, descr != NULL ? descr : "", 4, 2, TRUE, TRUE); - /* - * Iterate over all the export options and build up a dialog box - * that lets us control all of the options. By doing things this - * way, any changes to the exporter HID's automatically are - * reflected in this dialog box. - */ - for (j = 0; j < n_attrs; j++) - { - const Unit *unit_list; - if (attrs[j].help_text == ATTR_UNDOCUMENTED) - continue; - switch (attrs[j].type) - { - case HID_Label: - widget = gtk_label_new (attrs[j].name); - gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); - gtk_widget_set_tooltip_text (widget, attrs[j].help_text); - break; + /* + * Iterate over all the export options and build up a dialog box + * that lets us control all of the options. By doing things this + * way, any changes to the exporter HID's automatically are + * reflected in this dialog box. + */ + for (j = 0; j < n_attrs; j++) { + const Unit *unit_list; + if (attrs[j].help_text == ATTR_UNDOCUMENTED) + continue; + switch (attrs[j].type) { + case HID_Label: + widget = gtk_label_new(attrs[j].name); + gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, FALSE, 0); + gtk_widget_set_tooltip_text(widget, attrs[j].help_text); + break; - case HID_Integer: - hbox = gtk_hbox_new (FALSE, 4); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + case HID_Integer: + hbox = gtk_hbox_new(FALSE, 4); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - /* - * FIXME - * need to pick the "digits" argument based on min/max - * values - */ - ghid_spin_button (hbox, &widget, attrs[j].default_val.int_value, - attrs[j].min_val, attrs[j].max_val, 1.0, 1.0, 0, 0, - intspinner_changed_cb, - &(attrs[j].default_val.int_value), FALSE, NULL); - gtk_widget_set_tooltip_text (widget, attrs[j].help_text); + /* + * FIXME + * need to pick the "digits" argument based on min/max + * values + */ + ghid_spin_button(hbox, &widget, attrs[j].default_val.int_value, + attrs[j].min_val, attrs[j].max_val, 1.0, 1.0, 0, 0, + intspinner_changed_cb, &(attrs[j].default_val.int_value), FALSE, NULL); + gtk_widget_set_tooltip_text(widget, attrs[j].help_text); - widget = gtk_label_new (attrs[j].name); - gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0); - break; + widget = gtk_label_new(attrs[j].name); + gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, FALSE, 0); + break; - case HID_Coord: - hbox = gtk_hbox_new (FALSE, 4); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + case HID_Coord: + hbox = gtk_hbox_new(FALSE, 4); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - entry = ghid_coord_entry_new (attrs[j].min_val, attrs[j].max_val, - attrs[j].default_val.coord_value, - Settings.grid_unit, CE_SMALL); - gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0); - if(attrs[j].default_val.str_value != NULL) - gtk_entry_set_text (GTK_ENTRY (entry), - attrs[j].default_val.str_value); - gtk_widget_set_tooltip_text (entry, attrs[j].help_text); - g_signal_connect (G_OBJECT (entry), "changed", - G_CALLBACK (coordentry_changed_cb), - &(attrs[j].default_val.coord_value)); + entry = ghid_coord_entry_new(attrs[j].min_val, attrs[j].max_val, + attrs[j].default_val.coord_value, Settings.grid_unit, CE_SMALL); + gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); + if (attrs[j].default_val.str_value != NULL) + gtk_entry_set_text(GTK_ENTRY(entry), attrs[j].default_val.str_value); + gtk_widget_set_tooltip_text(entry, attrs[j].help_text); + g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(coordentry_changed_cb), &(attrs[j].default_val.coord_value)); - widget = gtk_label_new (attrs[j].name); - gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0); - break; + widget = gtk_label_new(attrs[j].name); + gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, FALSE, 0); + break; - case HID_Real: - hbox = gtk_hbox_new (FALSE, 4); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + case HID_Real: + hbox = gtk_hbox_new(FALSE, 4); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - /* - * FIXME - * need to pick the "digits" and step size argument more - * intelligently - */ - ghid_spin_button (hbox, &widget, attrs[j].default_val.real_value, - attrs[j].min_val, attrs[j].max_val, 0.01, 0.01, 3, - 0, - dblspinner_changed_cb, - &(attrs[j].default_val.real_value), FALSE, NULL); + /* + * FIXME + * need to pick the "digits" and step size argument more + * intelligently + */ + ghid_spin_button(hbox, &widget, attrs[j].default_val.real_value, + attrs[j].min_val, attrs[j].max_val, 0.01, 0.01, 3, + 0, dblspinner_changed_cb, &(attrs[j].default_val.real_value), FALSE, NULL); - gtk_widget_set_tooltip_text (widget, attrs[j].help_text); + gtk_widget_set_tooltip_text(widget, attrs[j].help_text); - widget = gtk_label_new (attrs[j].name); - gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0); - break; + widget = gtk_label_new(attrs[j].name); + gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, FALSE, 0); + break; - case HID_String: - hbox = gtk_hbox_new (FALSE, 4); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + case HID_String: + hbox = gtk_hbox_new(FALSE, 4); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - entry = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0); - if(attrs[j].default_val.str_value != NULL) - gtk_entry_set_text (GTK_ENTRY (entry), - attrs[j].default_val.str_value); - gtk_widget_set_tooltip_text (entry, attrs[j].help_text); - g_signal_connect (G_OBJECT (entry), "changed", - G_CALLBACK (entry_changed_cb), - &(attrs[j].default_val.str_value)); + entry = gtk_entry_new(); + gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); + if (attrs[j].default_val.str_value != NULL) + gtk_entry_set_text(GTK_ENTRY(entry), attrs[j].default_val.str_value); + gtk_widget_set_tooltip_text(entry, attrs[j].help_text); + g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(entry_changed_cb), &(attrs[j].default_val.str_value)); - widget = gtk_label_new (attrs[j].name); - gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0); - break; + widget = gtk_label_new(attrs[j].name); + gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, FALSE, 0); + break; - case HID_Boolean: - /* put this in a check button */ - ghid_check_button_connected (vbox, &widget, - attrs[j].default_val.int_value, - TRUE, FALSE, FALSE, 0, set_flag_cb, - &(attrs[j].default_val.int_value), - attrs[j].name); - gtk_widget_set_tooltip_text (widget, attrs[j].help_text); - break; + case HID_Boolean: + /* put this in a check button */ + ghid_check_button_connected(vbox, &widget, + attrs[j].default_val.int_value, + TRUE, FALSE, FALSE, 0, set_flag_cb, &(attrs[j].default_val.int_value), attrs[j].name); + gtk_widget_set_tooltip_text(widget, attrs[j].help_text); + break; - case HID_Enum: - hbox = gtk_hbox_new (FALSE, 4); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + case HID_Enum: + hbox = gtk_hbox_new(FALSE, 4); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - do_enum: - combo = gtk_combo_box_new_text (); - gtk_widget_set_tooltip_text (combo, attrs[j].help_text); - gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (combo), "changed", - G_CALLBACK (enum_changed_cb), - &(attrs[j].default_val.int_value)); + do_enum: + combo = gtk_combo_box_new_text(); + gtk_widget_set_tooltip_text(combo, attrs[j].help_text); + gtk_box_pack_start(GTK_BOX(hbox), combo, FALSE, FALSE, 0); + g_signal_connect(G_OBJECT(combo), "changed", G_CALLBACK(enum_changed_cb), &(attrs[j].default_val.int_value)); - /* - * Iterate through each value and add them to the - * combo box - */ - i = 0; - while (attrs[j].enumerations[i]) - { - gtk_combo_box_append_text (GTK_COMBO_BOX (combo), - attrs[j].enumerations[i]); - i++; - } - gtk_combo_box_set_active (GTK_COMBO_BOX (combo), - attrs[j].default_val.int_value); - widget = gtk_label_new (attrs[j].name); - gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0); - break; + /* + * Iterate through each value and add them to the + * combo box + */ + i = 0; + while (attrs[j].enumerations[i]) { + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), attrs[j].enumerations[i]); + i++; + } + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), attrs[j].default_val.int_value); + widget = gtk_label_new(attrs[j].name); + gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, FALSE, 0); + break; - case HID_Mixed: - hbox = gtk_hbox_new (FALSE, 4); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - - /* - * FIXME - * need to pick the "digits" and step size argument more - * intelligently - */ - ghid_spin_button (hbox, &widget, attrs[j].default_val.real_value, - attrs[j].min_val, attrs[j].max_val, 0.01, 0.01, 3, - 0, - dblspinner_changed_cb, - &(attrs[j].default_val.real_value), FALSE, NULL); - gtk_widget_set_tooltip_text (widget, attrs[j].help_text); + case HID_Mixed: + hbox = gtk_hbox_new(FALSE, 4); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - goto do_enum; - break; + /* + * FIXME + * need to pick the "digits" and step size argument more + * intelligently + */ + ghid_spin_button(hbox, &widget, attrs[j].default_val.real_value, + attrs[j].min_val, attrs[j].max_val, 0.01, 0.01, 3, + 0, dblspinner_changed_cb, &(attrs[j].default_val.real_value), FALSE, NULL); + gtk_widget_set_tooltip_text(widget, attrs[j].help_text); - case HID_Path: - vbox1 = ghid_category_vbox (vbox, attrs[j].name, 4, 2, TRUE, TRUE); - entry = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (vbox1), entry, FALSE, FALSE, 0); - gtk_entry_set_text (GTK_ENTRY (entry), - attrs[j].default_val.str_value); - g_signal_connect (G_OBJECT (entry), "changed", - G_CALLBACK (entry_changed_cb), - &(attrs[j].default_val.str_value)); + goto do_enum; + break; - gtk_widget_set_tooltip_text (entry, attrs[j].help_text); - break; + case HID_Path: + vbox1 = ghid_category_vbox(vbox, attrs[j].name, 4, 2, TRUE, TRUE); + entry = gtk_entry_new(); + gtk_box_pack_start(GTK_BOX(vbox1), entry, FALSE, FALSE, 0); + gtk_entry_set_text(GTK_ENTRY(entry), attrs[j].default_val.str_value); + g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(entry_changed_cb), &(attrs[j].default_val.str_value)); - case HID_Unit: - unit_list = get_unit_list (); - n = get_n_units (); + gtk_widget_set_tooltip_text(entry, attrs[j].help_text); + break; - hbox = gtk_hbox_new (FALSE, 4); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + case HID_Unit: + unit_list = get_unit_list(); + n = get_n_units(); - combo = gtk_combo_box_new_text (); - gtk_widget_set_tooltip_text (combo, attrs[j].help_text); - gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (combo), "changed", - G_CALLBACK (enum_changed_cb), - &(attrs[j].default_val.int_value)); + hbox = gtk_hbox_new(FALSE, 4); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - /* - * Iterate through each value and add them to the - * combo box - */ - for (i = 0; i < n; ++i) - gtk_combo_box_append_text (GTK_COMBO_BOX (combo), - unit_list[i].in_suffix); - gtk_combo_box_set_active (GTK_COMBO_BOX (combo), - attrs[j].default_val.int_value); - widget = gtk_label_new (attrs[j].name); - gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0); - break; - default: - printf ("%s: unknown type of HID attribute\n", __FUNCTION__); - break; + combo = gtk_combo_box_new_text(); + gtk_widget_set_tooltip_text(combo, attrs[j].help_text); + gtk_box_pack_start(GTK_BOX(hbox), combo, FALSE, FALSE, 0); + g_signal_connect(G_OBJECT(combo), "changed", G_CALLBACK(enum_changed_cb), &(attrs[j].default_val.int_value)); + + /* + * Iterate through each value and add them to the + * combo box + */ + for (i = 0; i < n; ++i) + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), unit_list[i].in_suffix); + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), attrs[j].default_val.int_value); + widget = gtk_label_new(attrs[j].name); + gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, FALSE, 0); + break; + default: + printf("%s: unknown type of HID attribute\n", __FUNCTION__); + break; + } } - } - gtk_widget_show_all (dialog); + gtk_widget_show_all(dialog); - if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) - { - /* copy over the results */ - for (i = 0; i < n_attrs; i++) - { - results[i] = attrs[i].default_val; - if (results[i].str_value) - results[i].str_value = strdup (results[i].str_value); + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { + /* copy over the results */ + for (i = 0; i < n_attrs; i++) { + results[i] = attrs[i].default_val; + if (results[i].str_value) + results[i].str_value = strdup(results[i].str_value); + } + rc = 0; } - rc = 0; - } - else - rc = 1; + else + rc = 1; - gtk_widget_destroy (dialog); + gtk_widget_destroy(dialog); - return rc; + return rc; } -static void -exporter_clicked_cb (GtkButton * button, HID * exporter) +static void exporter_clicked_cb(GtkButton * button, HID * exporter) { - ghid_dialog_print (exporter); + ghid_dialog_print(exporter); } -void -ghid_dialog_print (HID *hid) +void ghid_dialog_print(HID * hid) { - HID_Attribute *attr; - int n = 0; - int i; - HID_Attr_Val * results = NULL; + HID_Attribute *attr; + int n = 0; + int i; + HID_Attr_Val *results = NULL; - /* signal the initial export select dialog that it should close */ - if (export_dialog) - gtk_dialog_response (GTK_DIALOG (export_dialog), GTK_RESPONSE_CANCEL); + /* signal the initial export select dialog that it should close */ + if (export_dialog) + gtk_dialog_response(GTK_DIALOG(export_dialog), GTK_RESPONSE_CANCEL); - exporter = hid; + exporter = hid; - attr = exporter->get_export_options (&n); - if (n > 0) - { - results = (HID_Attr_Val *) malloc (n * sizeof (HID_Attr_Val)); - if (results == NULL) - { - fprintf (stderr, "%s() -- malloc failed\n", __FUNCTION__); - exit (1); + attr = exporter->get_export_options(&n); + if (n > 0) { + results = (HID_Attr_Val *) malloc(n * sizeof(HID_Attr_Val)); + if (results == NULL) { + fprintf(stderr, "%s() -- malloc failed\n", __FUNCTION__); + exit(1); + } + + /* non-zero means cancel was picked */ + if (ghid_attribute_dialog(attr, n, results, _("PCB Print Layout"), exporter->description)) + return; + } - - /* non-zero means cancel was picked */ - if (ghid_attribute_dialog (attr, n, results, _("PCB Print Layout"), - exporter->description)) - return; - - } - exporter->do_export (results); - - for (i = 0; i < n; i++) - { - if (results[i].str_value) - free ((void *) results[i].str_value); - } + exporter->do_export(results); - if (results) - free (results); + for (i = 0; i < n; i++) { + if (results[i].str_value) + free((void *) results[i].str_value); + } - exporter = NULL; + if (results) + free(results); + + exporter = NULL; } -void -ghid_dialog_export (void) +void ghid_dialog_export(void) { - GtkWidget *content_area; - GtkWidget *vbox, *button; - GHidPort *out = &ghid_port; - int i; - HID **hids; - gboolean no_exporter = TRUE; + GtkWidget *content_area; + GtkWidget *vbox, *button; + GHidPort *out = &ghid_port; + int i; + HID **hids; + gboolean no_exporter = TRUE; - export_dialog = gtk_dialog_new_with_buttons (_("PCB Export Layout"), - GTK_WINDOW (out->top_window), - (GtkDialogFlags)(GTK_DIALOG_MODAL - | - GTK_DIALOG_DESTROY_WITH_PARENT), - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, NULL); - gtk_window_set_wmclass (GTK_WINDOW (export_dialog), "PCB_Export", "PCB"); + export_dialog = gtk_dialog_new_with_buttons(_("PCB Export Layout"), + GTK_WINDOW(out->top_window), + (GtkDialogFlags) (GTK_DIALOG_MODAL + | + GTK_DIALOG_DESTROY_WITH_PARENT), + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); + gtk_window_set_wmclass(GTK_WINDOW(export_dialog), "PCB_Export", "PCB"); - content_area = gtk_dialog_get_content_area (GTK_DIALOG (export_dialog)); + content_area = gtk_dialog_get_content_area(GTK_DIALOG(export_dialog)); - vbox = gtk_vbox_new (FALSE, 6); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); - gtk_container_add (GTK_CONTAINER (content_area), vbox); + vbox = gtk_vbox_new(FALSE, 6); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); + gtk_container_add(GTK_CONTAINER(content_area), vbox); - /* - * Iterate over all the export HID's and build up a dialog box that - * lets us choose which one we want to use. - * This way, any additions to the exporter HID's automatically are - * reflected in this dialog box. - */ + /* + * Iterate over all the export HID's and build up a dialog box that + * lets us choose which one we want to use. + * This way, any additions to the exporter HID's automatically are + * reflected in this dialog box. + */ - hids = hid_enumerate (); - for (i = 0; hids[i]; i++) - { - if (hids[i]->exporter) - { - no_exporter = FALSE; - button = gtk_button_new_with_label (hids[i]->name); - gtk_widget_set_tooltip_text (button, hids[i]->description); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (exporter_clicked_cb), hids[i]); + hids = hid_enumerate(); + for (i = 0; hids[i]; i++) { + if (hids[i]->exporter) { + no_exporter = FALSE; + button = gtk_button_new_with_label(hids[i]->name); + gtk_widget_set_tooltip_text(button, hids[i]->description); + gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); + g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(exporter_clicked_cb), hids[i]); + } } - } - if (no_exporter) - { - gui->log (_("Can't find a suitable exporter HID")); - } + if (no_exporter) { + gui->log(_("Can't find a suitable exporter HID")); + } - gtk_widget_show_all (export_dialog); - gtk_dialog_run (GTK_DIALOG (export_dialog)); + gtk_widget_show_all(export_dialog); + gtk_dialog_run(GTK_DIALOG(export_dialog)); - if (export_dialog != NULL) - gtk_widget_destroy (export_dialog); - export_dialog = NULL; + if (export_dialog != NULL) + gtk_widget_destroy(export_dialog); + export_dialog = NULL; } Index: trunk/src/hid/gtk/gui-dialog.c =================================================================== --- trunk/src/hid/gtk/gui-dialog.c (revision 1021) +++ trunk/src/hid/gtk/gui-dialog.c (revision 1022) @@ -40,388 +40,331 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); /* ---------------------------------------------- */ -gchar * -ghid_dialog_input (const char * prompt, const char * initial) +gchar *ghid_dialog_input(const char *prompt, const char *initial) { - GtkWidget *dialog; - GtkWidget *content_area; - GtkWidget *vbox, *label, *entry; - gchar *string; - gboolean response; - GHidPort *out = &ghid_port; + GtkWidget *dialog; + GtkWidget *content_area; + GtkWidget *vbox, *label, *entry; + gchar *string; + gboolean response; + GHidPort *out = &ghid_port; - dialog = gtk_dialog_new_with_buttons ("PCB User Input", - GTK_WINDOW (out->top_window), - GTK_DIALOG_MODAL, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); + dialog = gtk_dialog_new_with_buttons("PCB User Input", + GTK_WINDOW(out->top_window), + GTK_DIALOG_MODAL, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); - vbox = gtk_vbox_new (FALSE, 4); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); - label = gtk_label_new (""); - gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0); + gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); + vbox = gtk_vbox_new(FALSE, 4); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); + label = gtk_label_new(""); + gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); - gtk_label_set_use_markup (GTK_LABEL (label), TRUE); - gtk_label_set_markup (GTK_LABEL (label), - prompt ? prompt : "Enter something"); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_label_set_markup(GTK_LABEL(label), prompt ? prompt : "Enter something"); - entry = gtk_entry_new (); - if (initial) - gtk_entry_set_text (GTK_ENTRY (entry), initial); + entry = gtk_entry_new(); + if (initial) + gtk_entry_set_text(GTK_ENTRY(entry), initial); - gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); - gtk_box_pack_start (GTK_BOX (vbox), entry, TRUE, TRUE, 0); + gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); + gtk_box_pack_start(GTK_BOX(vbox), entry, TRUE, TRUE, 0); - content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); - gtk_container_add (GTK_CONTAINER (content_area), vbox); - gtk_widget_show_all (dialog); + content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); + gtk_container_add(GTK_CONTAINER(content_area), vbox); + gtk_widget_show_all(dialog); - response = gtk_dialog_run (GTK_DIALOG (dialog)); - if (response != GTK_RESPONSE_OK) - string = g_strdup (initial ? initial : ""); - else - string = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1); + response = gtk_dialog_run(GTK_DIALOG(dialog)); + if (response != GTK_RESPONSE_OK) + string = g_strdup(initial ? initial : ""); + else + string = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); - gtk_widget_destroy (dialog); - return string; + gtk_widget_destroy(dialog); + return string; } /* ---------------------------------------------- */ -void -ghid_dialog_about (void) +void ghid_dialog_about(void) { - GtkWidget *dialog; - GHidPort *out = &ghid_port; - dialog = gtk_message_dialog_new (GTK_WINDOW (out->top_window), - (GtkDialogFlags)(GTK_DIALOG_MODAL - | GTK_DIALOG_DESTROY_WITH_PARENT), - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - "%s", GetInfoString ()); + GtkWidget *dialog; + GHidPort *out = &ghid_port; + dialog = gtk_message_dialog_new(GTK_WINDOW(out->top_window), + (GtkDialogFlags) (GTK_DIALOG_MODAL + | GTK_DIALOG_DESTROY_WITH_PARENT), + GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "%s", GetInfoString()); - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); + gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_widget_destroy(dialog); } /* ---------------------------------------------- */ -gint -ghid_dialog_confirm_all (gchar * all_message) +gint ghid_dialog_confirm_all(gchar * all_message) { - GtkWidget *dialog; - GtkWidget *content_area; - GtkWidget *label, *vbox; - gint response; - GHidPort *out = &ghid_port; + GtkWidget *dialog; + GtkWidget *content_area; + GtkWidget *label, *vbox; + gint response; + GHidPort *out = &ghid_port; - dialog = gtk_dialog_new_with_buttons ("Confirm", - GTK_WINDOW (out->top_window), - (GtkDialogFlags)(GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT), - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, - "Sequence OK", - GUI_DIALOG_RESPONSE_ALL, NULL); + dialog = gtk_dialog_new_with_buttons("Confirm", + GTK_WINDOW(out->top_window), + (GtkDialogFlags) (GTK_DIALOG_MODAL | + GTK_DIALOG_DESTROY_WITH_PARENT), + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OK, GTK_RESPONSE_OK, "Sequence OK", GUI_DIALOG_RESPONSE_ALL, NULL); - content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); - vbox = ghid_framed_vbox (content_area, NULL, 6, FALSE, 4, 6); + content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); + vbox = ghid_framed_vbox(content_area, NULL, 6, FALSE, 4, 6); - label = gtk_label_new (all_message); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 3); - gtk_widget_show_all (dialog); + label = gtk_label_new(all_message); + gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 3); + gtk_widget_show_all(dialog); - response = gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); + response = gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_widget_destroy(dialog); - return response; + return response; } /* ---------------------------------------------- */ -void -ghid_dialog_message (gchar * message) +void ghid_dialog_message(gchar * message) { - GtkWidget *dialog; - GHidPort *out = &ghid_port; + GtkWidget *dialog; + GHidPort *out = &ghid_port; - dialog = gtk_message_dialog_new (GTK_WINDOW (out->top_window), - (GtkDialogFlags)(GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT), - GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, - "%s", message); + dialog = gtk_message_dialog_new(GTK_WINDOW(out->top_window), + (GtkDialogFlags) (GTK_DIALOG_MODAL | + GTK_DIALOG_DESTROY_WITH_PARENT), + GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, "%s", message); - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); + gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_widget_destroy(dialog); } /* ---------------------------------------------- */ -gboolean -ghid_dialog_confirm (gchar * message, gchar * cancelmsg, gchar * okmsg) +gboolean ghid_dialog_confirm(gchar * message, gchar * cancelmsg, gchar * okmsg) { - static gint x = -1, y = -1; - GtkWidget *dialog; - gboolean confirm = FALSE; - GHidPort *out = &ghid_port; + static gint x = -1, y = -1; + GtkWidget *dialog; + gboolean confirm = FALSE; + GHidPort *out = &ghid_port; - if (cancelmsg == NULL) - { - cancelmsg = _("_Cancel"); - } - if (okmsg == NULL) - { - okmsg = _("_OK"); - } + if (cancelmsg == NULL) { + cancelmsg = _("_Cancel"); + } + if (okmsg == NULL) { + okmsg = _("_OK"); + } - dialog = gtk_message_dialog_new (GTK_WINDOW (out->top_window), - (GtkDialogFlags)(GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT), - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_NONE, - "%s", message); - gtk_dialog_add_buttons (GTK_DIALOG (dialog), - cancelmsg, GTK_RESPONSE_CANCEL, - okmsg, GTK_RESPONSE_OK, - NULL); + dialog = gtk_message_dialog_new(GTK_WINDOW(out->top_window), + (GtkDialogFlags) (GTK_DIALOG_MODAL | + GTK_DIALOG_DESTROY_WITH_PARENT), + GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, "%s", message); + gtk_dialog_add_buttons(GTK_DIALOG(dialog), cancelmsg, GTK_RESPONSE_CANCEL, okmsg, GTK_RESPONSE_OK, NULL); - if(x != -1) { - gtk_window_move(GTK_WINDOW (dialog), x, y); - } + if (x != -1) { + gtk_window_move(GTK_WINDOW(dialog), x, y); + } - if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) - confirm = TRUE; + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) + confirm = TRUE; - gtk_window_get_position(GTK_WINDOW (dialog), &x, &y); + gtk_window_get_position(GTK_WINDOW(dialog), &x, &y); - gtk_widget_destroy (dialog); - return confirm; + gtk_widget_destroy(dialog); + return confirm; } /* ---------------------------------------------- */ -gint -ghid_dialog_close_confirm () +gint ghid_dialog_close_confirm() { - GtkWidget *dialog; - gint rv; - GHidPort *out = &ghid_port; - gchar *tmp; - gchar *str; + GtkWidget *dialog; + gint rv; + GHidPort *out = &ghid_port; + gchar *tmp; + gchar *str; - if (PCB->Filename == NULL) - { - tmp = g_strdup_printf ( - _("Save the changes to layout before closing?")); - } else { - tmp = g_strdup_printf ( - _("Save the changes to layout \"%s\" before closing?"), - PCB->Filename); - } - str = g_strconcat ("", tmp, "", NULL); - g_free (tmp); - tmp = _("If you don't save, all your changes will be permanently lost."); - str = g_strconcat (str, "\n\n", tmp, NULL); + if (PCB->Filename == NULL) { + tmp = g_strdup_printf(_("Save the changes to layout before closing?")); + } + else { + tmp = g_strdup_printf(_("Save the changes to layout \"%s\" before closing?"), PCB->Filename); + } + str = g_strconcat("", tmp, "", NULL); + g_free(tmp); + tmp = _("If you don't save, all your changes will be permanently lost."); + str = g_strconcat(str, "\n\n", tmp, NULL); - dialog = gtk_message_dialog_new (GTK_WINDOW (out->top_window), - (GtkDialogFlags)(GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT), - GTK_MESSAGE_WARNING, - GTK_BUTTONS_NONE, NULL); - gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), str); - gtk_dialog_add_buttons (GTK_DIALOG (dialog), - _("Close _without saving"), GTK_RESPONSE_NO, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, GTK_RESPONSE_YES, - NULL); + dialog = gtk_message_dialog_new(GTK_WINDOW(out->top_window), + (GtkDialogFlags) (GTK_DIALOG_MODAL | + GTK_DIALOG_DESTROY_WITH_PARENT), + GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE, NULL); + gtk_message_dialog_set_markup(GTK_MESSAGE_DIALOG(dialog), str); + gtk_dialog_add_buttons(GTK_DIALOG(dialog), + _("Close _without saving"), GTK_RESPONSE_NO, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_YES, NULL); - /* Set the alternative button order (ok, cancel, help) for other systems */ - gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog), - GTK_RESPONSE_YES, - GTK_RESPONSE_NO, - GTK_RESPONSE_CANCEL, - -1); + /* Set the alternative button order (ok, cancel, help) for other systems */ + gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog), GTK_RESPONSE_YES, GTK_RESPONSE_NO, GTK_RESPONSE_CANCEL, -1); - switch (gtk_dialog_run (GTK_DIALOG (dialog))) - { - case GTK_RESPONSE_NO: - { - rv = GUI_DIALOG_CLOSE_CONFIRM_NOSAVE; - break; - } - case GTK_RESPONSE_YES: - { - rv = GUI_DIALOG_CLOSE_CONFIRM_SAVE; - break; - } - case GTK_RESPONSE_CANCEL: - default: - { - rv = GUI_DIALOG_CLOSE_CONFIRM_CANCEL; - break; - } - } - gtk_widget_destroy (dialog); - return rv; + switch (gtk_dialog_run(GTK_DIALOG(dialog))) { + case GTK_RESPONSE_NO: + { + rv = GUI_DIALOG_CLOSE_CONFIRM_NOSAVE; + break; + } + case GTK_RESPONSE_YES: + { + rv = GUI_DIALOG_CLOSE_CONFIRM_SAVE; + break; + } + case GTK_RESPONSE_CANCEL: + default: + { + rv = GUI_DIALOG_CLOSE_CONFIRM_CANCEL; + break; + } + } + gtk_widget_destroy(dialog); + return rv; } /* ---------------------------------------------- */ /* Caller must g_free() the returned filename.*/ -gchar * -ghid_dialog_file_select_open (gchar * title, gchar ** path, gchar * shortcuts) +gchar *ghid_dialog_file_select_open(gchar * title, gchar ** path, gchar * shortcuts) { - GtkWidget *dialog; - gchar *result = NULL, *folder, *seed; - GHidPort *out = &ghid_port; - GtkFileFilter *no_filter; + GtkWidget *dialog; + gchar *result = NULL, *folder, *seed; + GHidPort *out = &ghid_port; + GtkFileFilter *no_filter; - dialog = gtk_file_chooser_dialog_new (title, - GTK_WINDOW (out->top_window), - GTK_FILE_CHOOSER_ACTION_OPEN, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, - NULL); + dialog = gtk_file_chooser_dialog_new(title, + GTK_WINDOW(out->top_window), + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); + gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); - /* add a default filter for not filtering files */ - no_filter = gtk_file_filter_new (); - gtk_file_filter_set_name (no_filter, "all"); - gtk_file_filter_add_pattern (no_filter, "*.*"); - gtk_file_filter_add_pattern (no_filter, "*"); - gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), no_filter); + /* add a default filter for not filtering files */ + no_filter = gtk_file_filter_new(); + gtk_file_filter_set_name(no_filter, "all"); + gtk_file_filter_add_pattern(no_filter, "*.*"); + gtk_file_filter_add_pattern(no_filter, "*"); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), no_filter); - /* in case we have a dialog for loading a footprint file */ - if (strcmp (title, _("Load element to buffer")) == 0) - { - /* add a filter for footprint files */ - GtkFileFilter *fp_filter; - fp_filter = gtk_file_filter_new (); - gtk_file_filter_set_name (fp_filter, "fp"); - gtk_file_filter_add_mime_type (fp_filter, "application/x-pcb-footprint"); - gtk_file_filter_add_pattern (fp_filter, "*.fp"); - gtk_file_filter_add_pattern (fp_filter, "*.FP"); - gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), fp_filter); - } + /* in case we have a dialog for loading a footprint file */ + if (strcmp(title, _("Load element to buffer")) == 0) { + /* add a filter for footprint files */ + GtkFileFilter *fp_filter; + fp_filter = gtk_file_filter_new(); + gtk_file_filter_set_name(fp_filter, "fp"); + gtk_file_filter_add_mime_type(fp_filter, "application/x-pcb-footprint"); + gtk_file_filter_add_pattern(fp_filter, "*.fp"); + gtk_file_filter_add_pattern(fp_filter, "*.FP"); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), fp_filter); + } - /* in case we have a dialog for loading a layout file */ - if ((strcmp (title, _("Load layout file")) == 0) - || (strcmp (title, _("Load layout file to buffer")) == 0)) - { - /* add a filter for layout files */ - GtkFileFilter *pcb_filter; - pcb_filter = gtk_file_filter_new (); - gtk_file_filter_set_name (pcb_filter, "pcb"); - gtk_file_filter_add_mime_type (pcb_filter, "application/x-pcb-layout"); - gtk_file_filter_add_pattern (pcb_filter, "*.pcb"); - gtk_file_filter_add_pattern (pcb_filter, "*.PCB"); - gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), pcb_filter); - } + /* in case we have a dialog for loading a layout file */ + if ((strcmp(title, _("Load layout file")) == 0) + || (strcmp(title, _("Load layout file to buffer")) == 0)) { + /* add a filter for layout files */ + GtkFileFilter *pcb_filter; + pcb_filter = gtk_file_filter_new(); + gtk_file_filter_set_name(pcb_filter, "pcb"); + gtk_file_filter_add_mime_type(pcb_filter, "application/x-pcb-layout"); + gtk_file_filter_add_pattern(pcb_filter, "*.pcb"); + gtk_file_filter_add_pattern(pcb_filter, "*.PCB"); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), pcb_filter); + } - /* in case we have a dialog for loading a netlist file */ - if (strcmp (title, _("Load netlist file")) == 0) - { - /* add a filter for netlist files */ - GtkFileFilter *net_filter; - net_filter = gtk_file_filter_new (); - gtk_file_filter_set_name (net_filter, "netlist"); - gtk_file_filter_add_mime_type (net_filter, "application/x-pcb-netlist"); - gtk_file_filter_add_pattern (net_filter, "*.net"); - gtk_file_filter_add_pattern (net_filter, "*.NET"); - gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), net_filter); - } + /* in case we have a dialog for loading a netlist file */ + if (strcmp(title, _("Load netlist file")) == 0) { + /* add a filter for netlist files */ + GtkFileFilter *net_filter; + net_filter = gtk_file_filter_new(); + gtk_file_filter_set_name(net_filter, "netlist"); + gtk_file_filter_add_mime_type(net_filter, "application/x-pcb-netlist"); + gtk_file_filter_add_pattern(net_filter, "*.net"); + gtk_file_filter_add_pattern(net_filter, "*.NET"); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), net_filter); + } - if (path && *path) - gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), *path); + if (path && *path) + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), *path); - if (shortcuts && *shortcuts) - { - folder = g_strdup (shortcuts); - seed = folder; - while ((folder = strtok (seed, ":")) != NULL) - { - gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (dialog), - folder, NULL); - seed = NULL; + if (shortcuts && *shortcuts) { + folder = g_strdup(shortcuts); + seed = folder; + while ((folder = strtok(seed, ":")) != NULL) { + gtk_file_chooser_add_shortcut_folder(GTK_FILE_CHOOSER(dialog), folder, NULL); + seed = NULL; + } + g_free(folder); } - g_free (folder); - } - if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) - { - result = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); - folder = - gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog)); - if (folder && path) - { - dup_string (path, folder); - g_free (folder); + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { + result = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); + folder = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(dialog)); + if (folder && path) { + dup_string(path, folder); + g_free(folder); + } } - } - gtk_widget_destroy (dialog); + gtk_widget_destroy(dialog); - return result; + return result; } /* ---------------------------------------------- */ /* Caller must g_free() the returned filename. */ -gchar * -ghid_dialog_file_select_save (gchar * title, gchar ** path, gchar * file, - gchar * shortcuts) +gchar *ghid_dialog_file_select_save(gchar * title, gchar ** path, gchar * file, gchar * shortcuts) { - GtkWidget *dialog; - gchar *result = NULL, *folder, *seed; - GHidPort *out = &ghid_port; + GtkWidget *dialog; + gchar *result = NULL, *folder, *seed; + GHidPort *out = &ghid_port; - dialog = gtk_file_chooser_dialog_new (title, - GTK_WINDOW (out->top_window), - GTK_FILE_CHOOSER_ACTION_SAVE, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, - NULL); + dialog = gtk_file_chooser_dialog_new(title, + GTK_WINDOW(out->top_window), + GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); - gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), - TRUE); - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); + gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE); + gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); - if (path && *path && **path) - gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), *path); + if (path && *path && **path) + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), *path); - if (file && *file) - { - gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), - g_path_get_basename(file)); - gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), - g_path_get_dirname (file)); - } + if (file && *file) { + gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), g_path_get_basename(file)); + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), g_path_get_dirname(file)); + } - if (shortcuts && *shortcuts) - { - folder = g_strdup (shortcuts); - seed = folder; - while ((folder = strtok (seed, ":")) != NULL) - { - gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (dialog), - folder, NULL); - seed = NULL; + if (shortcuts && *shortcuts) { + folder = g_strdup(shortcuts); + seed = folder; + while ((folder = strtok(seed, ":")) != NULL) { + gtk_file_chooser_add_shortcut_folder(GTK_FILE_CHOOSER(dialog), folder, NULL); + seed = NULL; + } + g_free(folder); } - g_free (folder); - } - if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) - { - result = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); - folder = - gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog)); - if (folder && path) - { - dup_string (path, folder); - g_free (folder); + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { + result = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); + folder = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(dialog)); + if (folder && path) { + dup_string(path, folder); + g_free(folder); + } } - } - gtk_widget_destroy (dialog); + gtk_widget_destroy(dialog); - return result; + return result; } @@ -428,194 +371,165 @@ /* ---------------------------------------------- */ /* how many files and directories to keep for the shortcuts */ #define NHIST 8 -typedef struct ghid_file_history_struct -{ - /* - * an identifier as to which recent files pool this is. For example - * "boards", "eco", "netlists", etc. - */ - char * id; +typedef struct ghid_file_history_struct { + /* + * an identifier as to which recent files pool this is. For example + * "boards", "eco", "netlists", etc. + */ + char *id; - /* - * the array of files or directories - */ - char * history[NHIST]; + /* + * the array of files or directories + */ + char *history[NHIST]; } ghid_file_history; static int n_recent_dirs = 0; -static ghid_file_history * recent_dirs = NULL; +static ghid_file_history *recent_dirs = NULL; /* ---------------------------------------------- */ /* Caller must g_free() the returned filename. */ -gchar * -ghid_fileselect (const char *title, const char *descr, - char *default_file, char *default_ext, - const char *history_tag, int flags) +gchar *ghid_fileselect(const char *title, const char *descr, + char *default_file, char *default_ext, const char *history_tag, int flags) { - GtkWidget *dialog; - gchar *result = NULL; - GHidPort *out = &ghid_port; - gchar *path = NULL, *base = NULL; - int history_pool = -1; - int i; - - if (history_tag && *history_tag) - { - /* - * I used a simple linear search here because the number of - * entries in the array is likely to be quite small (5, maybe 10 at - * the absolute most) and this function is used when pulling up - * a file dialog box instead of something called over and over - * again as part of moving elements or autorouting. So, keep it - * simple.... - */ - history_pool = 0; - while (history_pool < n_recent_dirs && - strcmp (recent_dirs[history_pool].id, history_tag) != 0) - { - history_pool++; - } - - /* - * If we counted all the way to n_recent_dirs, that means we - * didn't find our entry - */ - if (history_pool >= n_recent_dirs) - { - n_recent_dirs++; + GtkWidget *dialog; + gchar *result = NULL; + GHidPort *out = &ghid_port; + gchar *path = NULL, *base = NULL; + int history_pool = -1; + int i; - recent_dirs = (ghid_file_history *)realloc (recent_dirs, - n_recent_dirs * sizeof (ghid_file_history)); + if (history_tag && *history_tag) { + /* + * I used a simple linear search here because the number of + * entries in the array is likely to be quite small (5, maybe 10 at + * the absolute most) and this function is used when pulling up + * a file dialog box instead of something called over and over + * again as part of moving elements or autorouting. So, keep it + * simple.... + */ + history_pool = 0; + while (history_pool < n_recent_dirs && strcmp(recent_dirs[history_pool].id, history_tag) != 0) { + history_pool++; + } - if (recent_dirs == NULL) - { - fprintf (stderr, "%s(): realloc failed\n", __FUNCTION__); - exit (1); - } - - recent_dirs[history_pool].id = strdup (history_tag); + /* + * If we counted all the way to n_recent_dirs, that means we + * didn't find our entry + */ + if (history_pool >= n_recent_dirs) { + n_recent_dirs++; - /* Initialize the entries in our history list to all be NULL */ - for (i = 0; i < NHIST; i++) - { - recent_dirs[history_pool].history[i] = NULL; - } + recent_dirs = (ghid_file_history *) realloc(recent_dirs, n_recent_dirs * sizeof(ghid_file_history)); + + if (recent_dirs == NULL) { + fprintf(stderr, "%s(): realloc failed\n", __FUNCTION__); + exit(1); + } + + recent_dirs[history_pool].id = strdup(history_tag); + + /* Initialize the entries in our history list to all be NULL */ + for (i = 0; i < NHIST; i++) { + recent_dirs[history_pool].history[i] = NULL; + } + } } - } - if (default_file && *default_file) - { - path = g_path_get_dirname (default_file); - base = g_path_get_basename (default_file); - } + if (default_file && *default_file) { + path = g_path_get_dirname(default_file); + base = g_path_get_basename(default_file); + } - dialog = gtk_file_chooser_dialog_new (title, - GTK_WINDOW (out->top_window), - (flags & HID_FILESELECT_READ) ? - GTK_FILE_CHOOSER_ACTION_OPEN : - GTK_FILE_CHOOSER_ACTION_SAVE, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, - NULL); + dialog = gtk_file_chooser_dialog_new(title, + GTK_WINDOW(out->top_window), + (flags & HID_FILESELECT_READ) ? + GTK_FILE_CHOOSER_ACTION_OPEN : + GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); + gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); - if (path && *path ) - { - gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), path); - g_free (path); - } + if (path && *path) { + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), path); + g_free(path); + } - if (base && *base) - { - /* default file is only supposed to be for writing, not reading */ - if (!(flags & HID_FILESELECT_READ)) - { - gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), base); + if (base && *base) { + /* default file is only supposed to be for writing, not reading */ + if (!(flags & HID_FILESELECT_READ)) { + gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), base); + } + g_free(base); } - g_free (base); - } - for (i = 0; i < NHIST && recent_dirs[history_pool].history[i] != NULL ; i++) - { - gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (dialog), - recent_dirs[history_pool].history[i], - NULL); - } + for (i = 0; i < NHIST && recent_dirs[history_pool].history[i] != NULL; i++) { + gtk_file_chooser_add_shortcut_folder(GTK_FILE_CHOOSER(dialog), recent_dirs[history_pool].history[i], NULL); + } - if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) - { - result = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); - if (result != NULL) - path = g_path_get_dirname (result); - else - path = NULL; + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { + result = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); + if (result != NULL) + path = g_path_get_dirname(result); + else + path = NULL; - /* update the history list */ - if (path != NULL) - { - char *tmps, *tmps2; - int k = 0; + /* update the history list */ + if (path != NULL) { + char *tmps, *tmps2; + int k = 0; - /* - * Put this at the top of the list and bump everything else - * down but skip any old entry of this directory - * - */ - while ( k < NHIST && - recent_dirs[history_pool].history[k] != NULL && - strcmp ( recent_dirs[history_pool].history[k], path) == 0) - { - k++; - } - tmps = recent_dirs[history_pool].history[k]; - recent_dirs[history_pool].history[0] = path; - for (i = 1 ; i < NHIST ; i++) - { - /* store our current entry, but skip duplicates */ - while (i + k < NHIST && - recent_dirs[history_pool].history[i + k] != NULL && - strcmp ( recent_dirs[history_pool].history[i + k], path) == 0) - { - k++; - } - - if (i + k < NHIST) - tmps2 = recent_dirs[history_pool].history[i + k]; - else - tmps2 = NULL; + /* + * Put this at the top of the list and bump everything else + * down but skip any old entry of this directory + * + */ + while (k < NHIST && + recent_dirs[history_pool].history[k] != NULL && strcmp(recent_dirs[history_pool].history[k], path) == 0) { + k++; + } + tmps = recent_dirs[history_pool].history[k]; + recent_dirs[history_pool].history[0] = path; + for (i = 1; i < NHIST; i++) { + /* store our current entry, but skip duplicates */ + while (i + k < NHIST && + recent_dirs[history_pool].history[i + k] != NULL && + strcmp(recent_dirs[history_pool].history[i + k], path) == 0) { + k++; + } - /* move down the one we stored last time */ - recent_dirs[history_pool].history[i] = tmps; + if (i + k < NHIST) + tmps2 = recent_dirs[history_pool].history[i + k]; + else + tmps2 = NULL; - /* and remember the displace entry */ - tmps = tmps2; - } + /* move down the one we stored last time */ + recent_dirs[history_pool].history[i] = tmps; - /* - * the last one has fallen off the end of the history list - * so we need to free() it. - */ - if (tmps) - { - free (tmps); - } - } - + /* and remember the displace entry */ + tmps = tmps2; + } + + /* + * the last one has fallen off the end of the history list + * so we need to free() it. + */ + if (tmps) { + free(tmps); + } + } + #ifdef DEBUG - printf ("\n\n-----\n\n"); - for (i = 0 ; i < NHIST ; i++) - { - printf ("After update recent_dirs[%d].history[%d] = \"%s\"\n", - history_pool, i, recent_dirs[history_pool].history[i] != NULL ? - recent_dirs[history_pool].history[i] : "NULL"); - } + printf("\n\n-----\n\n"); + for (i = 0; i < NHIST; i++) { + printf("After update recent_dirs[%d].history[%d] = \"%s\"\n", + history_pool, i, recent_dirs[history_pool].history[i] != NULL ? recent_dirs[history_pool].history[i] : "NULL"); + } #endif - } - gtk_widget_destroy (dialog); + } + gtk_widget_destroy(dialog); - return result; + return result; } - Index: trunk/src/hid/gtk/gui-drc-window.c =================================================================== --- trunk/src/hid/gtk/gui-drc-window.c (revision 1021) +++ trunk/src/hid/gtk/gui-drc-window.c (revision 1022) @@ -45,7 +45,7 @@ #define VIOLATION_PIXMAP_PIXEL_BORDER 5 #define VIOLATION_PIXMAP_PCB_SIZE MIL_TO_COORD (100) -RCSID ("$Id$"); +RCSID("$Id$"); static GtkWidget *drc_window, *drc_list; static GtkListStore *drc_list_model = NULL; @@ -52,232 +52,207 @@ static int num_violations = 0; /* Remember user window resizes. */ -static gint -drc_window_configure_event_cb (GtkWidget * widget, - GdkEventConfigure * ev, gpointer data) +static gint drc_window_configure_event_cb(GtkWidget * widget, GdkEventConfigure * ev, gpointer data) { - GtkAllocation allocation; + GtkAllocation allocation; - gtk_widget_get_allocation (widget, &allocation); - ghidgui->drc_window_width = allocation.width; - ghidgui->drc_window_height = allocation.height; - ghidgui->config_modified = TRUE; + gtk_widget_get_allocation(widget, &allocation); + ghidgui->drc_window_width = allocation.width; + ghidgui->drc_window_height = allocation.height; + ghidgui->config_modified = TRUE; - return FALSE; + return FALSE; } -static void -drc_close_cb (gpointer data) +static void drc_close_cb(gpointer data) { - gtk_widget_destroy (drc_window); - drc_window = NULL; + gtk_widget_destroy(drc_window); + drc_window = NULL; } -static void -drc_refresh_cb (gpointer data) +static void drc_refresh_cb(gpointer data) { - hid_actionl ("DRC", NULL); + hid_actionl("DRC", NULL); } -static void -drc_destroy_cb (GtkWidget * widget, gpointer data) +static void drc_destroy_cb(GtkWidget * widget, gpointer data) { - drc_window = NULL; + drc_window = NULL; } enum { - DRC_VIOLATION_NUM_COL = 0, - DRC_VIOLATION_OBJ_COL, - NUM_DRC_COLUMNS + DRC_VIOLATION_NUM_COL = 0, + DRC_VIOLATION_OBJ_COL, + NUM_DRC_COLUMNS }; -static void -unset_found_flags (int AndDraw) +static void unset_found_flags(int AndDraw) { - int flag = FOUNDFLAG; - int change = 0; + int flag = FOUNDFLAG; + int change = 0; - VIA_LOOP (PCB->Data); - { - if (TEST_FLAG (flag, via)) - { - AddObjectToFlagUndoList (VIA_TYPE, via, via, via); - CLEAR_FLAG (flag, via); - DrawVia (via); - change = true; - } - } - END_LOOP; - ELEMENT_LOOP (PCB->Data); - { - PIN_LOOP (element); - { - if (TEST_FLAG (flag, pin)) + VIA_LOOP(PCB->Data); { - AddObjectToFlagUndoList (PIN_TYPE, element, pin, pin); - CLEAR_FLAG (flag, pin); - DrawPin (pin); - change = true; + if (TEST_FLAG(flag, via)) { + AddObjectToFlagUndoList(VIA_TYPE, via, via, via); + CLEAR_FLAG(flag, via); + DrawVia(via); + change = true; + } } - } - END_LOOP; - PAD_LOOP (element); - { - if (TEST_FLAG (flag, pad)) + END_LOOP; + ELEMENT_LOOP(PCB->Data); { - AddObjectToFlagUndoList (PAD_TYPE, element, pad, pad); - CLEAR_FLAG (flag, pad); - DrawPad (pad); - change = true; + PIN_LOOP(element); + { + if (TEST_FLAG(flag, pin)) { + AddObjectToFlagUndoList(PIN_TYPE, element, pin, pin); + CLEAR_FLAG(flag, pin); + DrawPin(pin); + change = true; + } + } + END_LOOP; + PAD_LOOP(element); + { + if (TEST_FLAG(flag, pad)) { + AddObjectToFlagUndoList(PAD_TYPE, element, pad, pad); + CLEAR_FLAG(flag, pad); + DrawPad(pad); + change = true; + } + } + END_LOOP; } - } - END_LOOP; - } - END_LOOP; - RAT_LOOP (PCB->Data); - { - if (TEST_FLAG (flag, line)) - { - AddObjectToFlagUndoList (RATLINE_TYPE, line, line, line); - CLEAR_FLAG (flag, line); - DrawRat (line); - change = true; - } - } - END_LOOP; - COPPERLINE_LOOP (PCB->Data); - { - if (TEST_FLAG (flag, line)) - { - AddObjectToFlagUndoList (LINE_TYPE, layer, line, line); - CLEAR_FLAG (flag, line); - DrawLine (layer, line); - change = true; - } - } - ENDALL_LOOP; - COPPERARC_LOOP (PCB->Data); - { - if (TEST_FLAG (flag, arc)) - { - AddObjectToFlagUndoList (ARC_TYPE, layer, arc, arc); - CLEAR_FLAG (flag, arc); - DrawArc (layer, arc); - change = true; - } - } - ENDALL_LOOP; - COPPERPOLYGON_LOOP (PCB->Data); - { - if (TEST_FLAG (flag, polygon)) - { - AddObjectToFlagUndoList (POLYGON_TYPE, layer, polygon, polygon); - CLEAR_FLAG (flag, polygon); - DrawPolygon (layer, polygon); - change = true; - } - } - ENDALL_LOOP; - if (change) - { - SetChangedFlag (true); - if (AndDraw) + END_LOOP; + RAT_LOOP(PCB->Data); { - IncrementUndoSerialNumber (); - Draw (); + if (TEST_FLAG(flag, line)) { + AddObjectToFlagUndoList(RATLINE_TYPE, line, line, line); + CLEAR_FLAG(flag, line); + DrawRat(line); + change = true; + } } - } + END_LOOP; + COPPERLINE_LOOP(PCB->Data); + { + if (TEST_FLAG(flag, line)) { + AddObjectToFlagUndoList(LINE_TYPE, layer, line, line); + CLEAR_FLAG(flag, line); + DrawLine(layer, line); + change = true; + } + } + ENDALL_LOOP; + COPPERARC_LOOP(PCB->Data); + { + if (TEST_FLAG(flag, arc)) { + AddObjectToFlagUndoList(ARC_TYPE, layer, arc, arc); + CLEAR_FLAG(flag, arc); + DrawArc(layer, arc); + change = true; + } + } + ENDALL_LOOP; + COPPERPOLYGON_LOOP(PCB->Data); + { + if (TEST_FLAG(flag, polygon)) { + AddObjectToFlagUndoList(POLYGON_TYPE, layer, polygon, polygon); + CLEAR_FLAG(flag, polygon); + DrawPolygon(layer, polygon); + change = true; + } + } + ENDALL_LOOP; + if (change) { + SetChangedFlag(true); + if (AndDraw) { + IncrementUndoSerialNumber(); + Draw(); + } + } } -static void -selection_changed_cb (GtkTreeSelection *selection, gpointer user_data) +static void selection_changed_cb(GtkTreeSelection * selection, gpointer user_data) { - GtkTreeModel *model; - GtkTreeIter iter; - GhidDrcViolation *violation; - int i; + GtkTreeModel *model; + GtkTreeIter iter; + GhidDrcViolation *violation; + int i; - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) - { - unset_found_flags (true); - return; - } + if (!gtk_tree_selection_get_selected(selection, &model, &iter)) { + unset_found_flags(true); + return; + } - /* Check the selected node has children, if so; return. */ - if (gtk_tree_model_iter_has_child (model, &iter)) - return; + /* Check the selected node has children, if so; return. */ + if (gtk_tree_model_iter_has_child(model, &iter)) + return; - gtk_tree_model_get (model, &iter, DRC_VIOLATION_OBJ_COL, &violation, -1); + gtk_tree_model_get(model, &iter, DRC_VIOLATION_OBJ_COL, &violation, -1); - unset_found_flags (false); + unset_found_flags(false); - if (violation == NULL) - return; + if (violation == NULL) + return; - /* Flag the objects listed against this DRC violation */ - for (i = 0; i < violation->object_count; i++) - { - int object_id = violation->object_id_list[i]; - int object_type = violation->object_type_list[i]; - int found_type; - void *ptr1, *ptr2, *ptr3; + /* Flag the objects listed against this DRC violation */ + for (i = 0; i < violation->object_count; i++) { + int object_id = violation->object_id_list[i]; + int object_type = violation->object_type_list[i]; + int found_type; + void *ptr1, *ptr2, *ptr3; - found_type = SearchObjectByID (PCB->Data, &ptr1, &ptr2, &ptr3, - object_id, object_type); - if (found_type == NO_TYPE) - { - Message (_("Object ID %i identified during DRC was not found. Stale DRC window?\n"), - object_id); - continue; + found_type = SearchObjectByID(PCB->Data, &ptr1, &ptr2, &ptr3, object_id, object_type); + if (found_type == NO_TYPE) { + Message(_("Object ID %i identified during DRC was not found. Stale DRC window?\n"), object_id); + continue; + } + AddObjectToFlagUndoList(object_type, ptr1, ptr2, ptr3); + SET_FLAG(FOUNDFLAG, (AnyObjectType *) ptr2); + switch (violation->object_type_list[i]) { + case LINE_TYPE: + case ARC_TYPE: + case POLYGON_TYPE: + ChangeGroupVisibility(GetLayerNumber(PCB->Data, (LayerTypePtr) ptr1), true, true); + } + DrawObject(object_type, ptr1, ptr2); } - AddObjectToFlagUndoList (object_type, ptr1, ptr2, ptr3); - SET_FLAG (FOUNDFLAG, (AnyObjectType *)ptr2); - switch (violation->object_type_list[i]) - { - case LINE_TYPE: - case ARC_TYPE: - case POLYGON_TYPE: - ChangeGroupVisibility (GetLayerNumber (PCB->Data, (LayerTypePtr) ptr1), true, true); - } - DrawObject (object_type, ptr1, ptr2); - } - SetChangedFlag (true); - IncrementUndoSerialNumber (); - Draw(); + SetChangedFlag(true); + IncrementUndoSerialNumber(); + Draw(); } -static void -row_activated_cb (GtkTreeView *view, GtkTreePath *path, - GtkTreeViewColumn *column, gpointer user_data) +static void row_activated_cb(GtkTreeView * view, GtkTreePath * path, GtkTreeViewColumn * column, gpointer user_data) { - GtkTreeModel *model = gtk_tree_view_get_model (view); - GtkTreeIter iter; - GhidDrcViolation *violation; + GtkTreeModel *model = gtk_tree_view_get_model(view); + GtkTreeIter iter; + GhidDrcViolation *violation; - gtk_tree_model_get_iter (model, &iter, path); + gtk_tree_model_get_iter(model, &iter, path); - gtk_tree_model_get (model, &iter, DRC_VIOLATION_OBJ_COL, &violation, -1); + gtk_tree_model_get(model, &iter, DRC_VIOLATION_OBJ_COL, &violation, -1); - if (violation == NULL) - return; + if (violation == NULL) + return; - CenterDisplay (violation->x_coord, violation->y_coord); + CenterDisplay(violation->x_coord, violation->y_coord); } -enum -{ - PROP_TITLE = 1, - PROP_EXPLANATION, - PROP_X_COORD, - PROP_Y_COORD, - PROP_ANGLE, - PROP_HAVE_MEASURED, - PROP_MEASURED_VALUE, - PROP_REQUIRED_VALUE, - PROP_OBJECT_LIST, - PROP_PIXMAP +enum { + PROP_TITLE = 1, + PROP_EXPLANATION, + PROP_X_COORD, + PROP_Y_COORD, + PROP_ANGLE, + PROP_HAVE_MEASURED, + PROP_MEASURED_VALUE, + PROP_REQUIRED_VALUE, + PROP_OBJECT_LIST, + PROP_PIXMAP }; @@ -292,26 +267,24 @@ * * \param [in] widget The GObject being finalized. */ -static void -ghid_drc_violation_finalize (GObject * object) +static void ghid_drc_violation_finalize(GObject * object) { - GhidDrcViolation *violation = GHID_DRC_VIOLATION (object); + GhidDrcViolation *violation = GHID_DRC_VIOLATION(object); - g_free (violation->title); - g_free (violation->explanation); - g_free (violation->object_id_list); - g_free (violation->object_type_list); - if (violation->pixmap != NULL) - g_object_unref (violation->pixmap); + g_free(violation->title); + g_free(violation->explanation); + g_free(violation->object_id_list); + g_free(violation->object_type_list); + if (violation->pixmap != NULL) + g_object_unref(violation->pixmap); - G_OBJECT_CLASS (ghid_drc_violation_parent_class)->finalize (object); + G_OBJECT_CLASS(ghid_drc_violation_parent_class)->finalize(object); } -typedef struct object_list -{ - int count; - long int *id_list; - int *type_list; +typedef struct object_list { + int count; + long int *id_list; + int *type_list; } object_list; /*! \brief GObject property setter function @@ -326,63 +299,58 @@ * \param [in] value The GValue the property is being set from * \param [in] pspec A GParamSpec describing the property being set */ -static void -ghid_drc_violation_set_property (GObject * object, guint property_id, - const GValue * value, GParamSpec * pspec) +static void ghid_drc_violation_set_property(GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) { - GhidDrcViolation *violation = GHID_DRC_VIOLATION (object); - object_list *obj_list; + GhidDrcViolation *violation = GHID_DRC_VIOLATION(object); + object_list *obj_list; - switch (property_id) - { - case PROP_TITLE: - g_free (violation->title); - violation->title = g_value_dup_string (value); - break; - case PROP_EXPLANATION: - g_free (violation->explanation); - violation->explanation = g_value_dup_string (value); - break; - case PROP_X_COORD: - violation->x_coord = g_value_get_int (value); - break; - case PROP_Y_COORD: - violation->y_coord = g_value_get_int (value); - break; - case PROP_ANGLE: - violation->angle = g_value_get_double (value); - break; - case PROP_HAVE_MEASURED: - violation->have_measured = g_value_get_boolean (value); - break; - case PROP_MEASURED_VALUE: - violation->measured_value = g_value_get_int (value); - break; - case PROP_REQUIRED_VALUE: - violation->required_value = g_value_get_int (value); - break; - case PROP_OBJECT_LIST: - /* Copy the passed data to make new lists */ - g_free (violation->object_id_list); - g_free (violation->object_type_list); - obj_list = (object_list *)g_value_get_pointer (value); - violation->object_count = obj_list->count; - violation->object_id_list = g_new (long int, obj_list->count); - violation->object_type_list = g_new (int, obj_list->count); - memcpy (violation->object_id_list, obj_list->id_list, - sizeof (long int) * obj_list->count); - memcpy (violation->object_type_list, obj_list->type_list, - sizeof (int) * obj_list->count); - break; - case PROP_PIXMAP: - if (violation->pixmap) - g_object_unref (violation->pixmap); /* Frees our old reference */ - violation->pixmap = (GdkDrawable *)g_value_dup_object (value); /* Takes a new reference */ - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - return; - } + switch (property_id) { + case PROP_TITLE: + g_free(violation->title); + violation->title = g_value_dup_string(value); + break; + case PROP_EXPLANATION: + g_free(violation->explanation); + violation->explanation = g_value_dup_string(value); + break; + case PROP_X_COORD: + violation->x_coord = g_value_get_int(value); + break; + case PROP_Y_COORD: + violation->y_coord = g_value_get_int(value); + break; + case PROP_ANGLE: + violation->angle = g_value_get_double(value); + break; + case PROP_HAVE_MEASURED: + violation->have_measured = g_value_get_boolean(value); + break; + case PROP_MEASURED_VALUE: + violation->measured_value = g_value_get_int(value); + break; + case PROP_REQUIRED_VALUE: + violation->required_value = g_value_get_int(value); + break; + case PROP_OBJECT_LIST: + /* Copy the passed data to make new lists */ + g_free(violation->object_id_list); + g_free(violation->object_type_list); + obj_list = (object_list *) g_value_get_pointer(value); + violation->object_count = obj_list->count; + violation->object_id_list = g_new(long int, obj_list->count); + violation->object_type_list = g_new(int, obj_list->count); + memcpy(violation->object_id_list, obj_list->id_list, sizeof(long int) * obj_list->count); + memcpy(violation->object_type_list, obj_list->type_list, sizeof(int) * obj_list->count); + break; + case PROP_PIXMAP: + if (violation->pixmap) + g_object_unref(violation->pixmap); /* Frees our old reference */ + violation->pixmap = (GdkDrawable *) g_value_dup_object(value); /* Takes a new reference */ + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); + return; + } } @@ -398,15 +366,12 @@ * \param [out] value The GValue in which to return the value of the property * \param [in] pspec A GParamSpec describing the property being got */ -static void -ghid_drc_violation_get_property (GObject * object, guint property_id, - GValue * value, GParamSpec * pspec) +static void ghid_drc_violation_get_property(GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { - switch (property_id) - { - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } + switch (property_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); + } } @@ -419,86 +384,35 @@ * * \param [in] klass The GhidDrcViolationClass we are initialising */ -static void -ghid_drc_violation_class_init (GhidViolationRendererClass * klass) +static void ghid_drc_violation_class_init(GhidViolationRendererClass * klass) { - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - gobject_class->finalize = ghid_drc_violation_finalize; - gobject_class->set_property = ghid_drc_violation_set_property; - gobject_class->get_property = ghid_drc_violation_get_property; + gobject_class->finalize = ghid_drc_violation_finalize; + gobject_class->set_property = ghid_drc_violation_set_property; + gobject_class->get_property = ghid_drc_violation_get_property; - ghid_drc_violation_parent_class = (GObjectClass *)g_type_class_peek_parent (klass); + ghid_drc_violation_parent_class = (GObjectClass *) g_type_class_peek_parent(klass); - g_object_class_install_property (gobject_class, PROP_TITLE, - g_param_spec_string ("title", - "", - "", - "", - G_PARAM_WRITABLE)); - g_object_class_install_property (gobject_class, PROP_EXPLANATION, - g_param_spec_string ("explanation", - "", - "", - "", - G_PARAM_WRITABLE)); - g_object_class_install_property (gobject_class, PROP_X_COORD, - g_param_spec_int ("x-coord", - "", - "", - G_MININT, - G_MAXINT, - 0, - G_PARAM_WRITABLE)); - g_object_class_install_property (gobject_class, PROP_Y_COORD, - g_param_spec_int ("y-coord", - "", - "", - G_MININT, - G_MAXINT, - 0, - G_PARAM_WRITABLE)); - g_object_class_install_property (gobject_class, PROP_ANGLE, - g_param_spec_double ("angle", - "", - "", - G_MININT, - G_MAXINT, - 0, - G_PARAM_WRITABLE)); - g_object_class_install_property (gobject_class, PROP_HAVE_MEASURED, - g_param_spec_boolean ("have-measured", - "", - "", - 0, - G_PARAM_WRITABLE)); - g_object_class_install_property (gobject_class, PROP_MEASURED_VALUE, - g_param_spec_int ("measured-value", - "", - "", - G_MININT, - G_MAXINT, - 0., - G_PARAM_WRITABLE)); - g_object_class_install_property (gobject_class, PROP_REQUIRED_VALUE, - g_param_spec_int ("required-value", - "", - "", - G_MININT, - G_MAXINT, - 0., - G_PARAM_WRITABLE)); - g_object_class_install_property (gobject_class, PROP_OBJECT_LIST, - g_param_spec_pointer ("object-list", - "", - "", - G_PARAM_WRITABLE)); - g_object_class_install_property (gobject_class, PROP_PIXMAP, - g_param_spec_object ("pixmap", - "", - "", - GDK_TYPE_DRAWABLE, - G_PARAM_WRITABLE)); + g_object_class_install_property(gobject_class, PROP_TITLE, g_param_spec_string("title", "", "", "", G_PARAM_WRITABLE)); + g_object_class_install_property(gobject_class, PROP_EXPLANATION, + g_param_spec_string("explanation", "", "", "", G_PARAM_WRITABLE)); + g_object_class_install_property(gobject_class, PROP_X_COORD, + g_param_spec_int("x-coord", "", "", G_MININT, G_MAXINT, 0, G_PARAM_WRITABLE)); + g_object_class_install_property(gobject_class, PROP_Y_COORD, + g_param_spec_int("y-coord", "", "", G_MININT, G_MAXINT, 0, G_PARAM_WRITABLE)); + g_object_class_install_property(gobject_class, PROP_ANGLE, + g_param_spec_double("angle", "", "", G_MININT, G_MAXINT, 0, G_PARAM_WRITABLE)); + g_object_class_install_property(gobject_class, PROP_HAVE_MEASURED, + g_param_spec_boolean("have-measured", "", "", 0, G_PARAM_WRITABLE)); + g_object_class_install_property(gobject_class, PROP_MEASURED_VALUE, + g_param_spec_int("measured-value", "", "", G_MININT, G_MAXINT, 0., G_PARAM_WRITABLE)); + g_object_class_install_property(gobject_class, PROP_REQUIRED_VALUE, + g_param_spec_int("required-value", "", "", G_MININT, G_MAXINT, 0., G_PARAM_WRITABLE)); + g_object_class_install_property(gobject_class, PROP_OBJECT_LIST, + g_param_spec_pointer("object-list", "", "", G_PARAM_WRITABLE)); + g_object_class_install_property(gobject_class, PROP_PIXMAP, + g_param_spec_object("pixmap", "", "", GDK_TYPE_DRAWABLE, G_PARAM_WRITABLE)); } @@ -512,60 +426,53 @@ * * \return the GType identifier associated with GhidViolationRenderer. */ -GType -ghid_drc_violation_get_type () +GType ghid_drc_violation_get_type() { - static GType ghid_drc_violation_type = 0; + static GType ghid_drc_violation_type = 0; - if (!ghid_drc_violation_type) - { - static const GTypeInfo ghid_drc_violation_info = { - sizeof (GhidDrcViolationClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) ghid_drc_violation_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GhidDrcViolation), - 0, /* n_preallocs */ - NULL, /* instance_init */ - }; + if (!ghid_drc_violation_type) { + static const GTypeInfo ghid_drc_violation_info = { + sizeof(GhidDrcViolationClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) ghid_drc_violation_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(GhidDrcViolation), + 0, /* n_preallocs */ + NULL, /* instance_init */ + }; - ghid_drc_violation_type = - g_type_register_static (G_TYPE_OBJECT, "GhidDrcViolation", - &ghid_drc_violation_info, (GTypeFlags)0); - } + ghid_drc_violation_type = + g_type_register_static(G_TYPE_OBJECT, "GhidDrcViolation", &ghid_drc_violation_info, (GTypeFlags) 0); + } - return ghid_drc_violation_type; + return ghid_drc_violation_type; } -GhidDrcViolation *ghid_drc_violation_new (DrcViolationType *violation, - GdkDrawable *pixmap) +GhidDrcViolation *ghid_drc_violation_new(DrcViolationType * violation, GdkDrawable * pixmap) { - object_list obj_list; + object_list obj_list; - obj_list.count = violation->object_count; - obj_list.id_list = violation->object_id_list; - obj_list.type_list = violation->object_type_list; + obj_list.count = violation->object_count; + obj_list.id_list = violation->object_id_list; + obj_list.type_list = violation->object_type_list; - return (GhidDrcViolation *)g_object_new (GHID_TYPE_DRC_VIOLATION, - "title", violation->title, - "explanation", violation->explanation, - "x-coord", violation->x, - "y-coord", violation->y, - "angle", violation->angle, - "have-measured", violation->have_measured, - "measured-value", violation->measured_value, - "required-value", violation->required_value, - "object-list", &obj_list, - "pixmap", pixmap, - NULL); + return (GhidDrcViolation *) g_object_new(GHID_TYPE_DRC_VIOLATION, + "title", violation->title, + "explanation", violation->explanation, + "x-coord", violation->x, + "y-coord", violation->y, + "angle", violation->angle, + "have-measured", violation->have_measured, + "measured-value", violation->measured_value, + "required-value", violation->required_value, + "object-list", &obj_list, "pixmap", pixmap, NULL); } -enum -{ - PROP_VIOLATION = 1, +enum { + PROP_VIOLATION = 1, }; @@ -580,15 +487,14 @@ * * \param [in] widget The GObject being finalized. */ -static void -ghid_violation_renderer_finalize (GObject * object) +static void ghid_violation_renderer_finalize(GObject * object) { - GhidViolationRenderer *renderer = GHID_VIOLATION_RENDERER (object); + GhidViolationRenderer *renderer = GHID_VIOLATION_RENDERER(object); - if (renderer->violation != NULL) - g_object_unref (renderer->violation); + if (renderer->violation != NULL) + g_object_unref(renderer->violation); - G_OBJECT_CLASS (ghid_violation_renderer_parent_class)->finalize (object); + G_OBJECT_CLASS(ghid_violation_renderer_parent_class)->finalize(object); } @@ -604,60 +510,53 @@ * \param [in] value The GValue the property is being set from * \param [in] pspec A GParamSpec describing the property being set */ -static void -ghid_violation_renderer_set_property (GObject * object, guint property_id, - const GValue * value, GParamSpec * pspec) +static void ghid_violation_renderer_set_property(GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) { - GhidViolationRenderer *renderer = GHID_VIOLATION_RENDERER (object); - char *markup; + GhidViolationRenderer *renderer = GHID_VIOLATION_RENDERER(object); + char *markup; - switch (property_id) - { - case PROP_VIOLATION: - if (renderer->violation != NULL) - g_object_unref (renderer->violation); - renderer->violation = (GhidDrcViolation *)g_value_dup_object (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - return; - } + switch (property_id) { + case PROP_VIOLATION: + if (renderer->violation != NULL) + g_object_unref(renderer->violation); + renderer->violation = (GhidDrcViolation *) g_value_dup_object(value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); + return; + } - if (renderer->violation == NULL) - return; + if (renderer->violation == NULL) + return; - if (renderer->violation->have_measured) - { - markup = pcb_g_strdup_printf ("%m+%s (%$mS)\n" - " \n" - "" - "%s\n" - " \n" - "Required: %$mS" - "", - Settings.grid_unit->allow, - renderer->violation->title, - renderer->violation->measured_value, - renderer->violation->explanation, - renderer->violation->required_value); - } - else - { - markup = pcb_g_strdup_printf ("%m+%s\n" - " \n" - "" - "%s\n" - " \n" - "Required: %$mS" - "", - Settings.grid_unit->allow, - renderer->violation->title, - renderer->violation->explanation, - renderer->violation->required_value); - } + if (renderer->violation->have_measured) { + markup = pcb_g_strdup_printf("%m+%s (%$mS)\n" + " \n" + "" + "%s\n" + " \n" + "Required: %$mS" + "", + Settings.grid_unit->allow, + renderer->violation->title, + renderer->violation->measured_value, + renderer->violation->explanation, renderer->violation->required_value); + } + else { + markup = pcb_g_strdup_printf("%m+%s\n" + " \n" + "" + "%s\n" + " \n" + "Required: %$mS" + "", + Settings.grid_unit->allow, + renderer->violation->title, + renderer->violation->explanation, renderer->violation->required_value); + } - g_object_set (object, "markup", markup, NULL); - g_free (markup); + g_object_set(object, "markup", markup, NULL); + g_free(markup); } @@ -672,88 +571,69 @@ * \param [out] value The GValue in which to return the value of the property * \param [in] pspec A GParamSpec describing the property being got */ -static void -ghid_violation_renderer_get_property (GObject * object, guint property_id, - GValue * value, GParamSpec * pspec) +static void ghid_violation_renderer_get_property(GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { - switch (property_id) - { - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } + switch (property_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); + } } static void -ghid_violation_renderer_get_size (GtkCellRenderer *cell, - GtkWidget *widget, - GdkRectangle *cell_area, - gint *x_offset, - gint *y_offset, - gint *width, - gint *height) +ghid_violation_renderer_get_size(GtkCellRenderer * cell, + GtkWidget * widget, + GdkRectangle * cell_area, gint * x_offset, gint * y_offset, gint * width, gint * height) { - GTK_CELL_RENDERER_CLASS (ghid_violation_renderer_parent_class)->get_size (cell, - widget, - cell_area, - x_offset, - y_offset, - width, - height); - if (width != NULL) - *width += VIOLATION_PIXMAP_PIXEL_SIZE; - if (height != NULL) - *height = MAX (*height, VIOLATION_PIXMAP_PIXEL_SIZE); + GTK_CELL_RENDERER_CLASS(ghid_violation_renderer_parent_class)->get_size(cell, + widget, cell_area, x_offset, y_offset, width, height); + if (width != NULL) + *width += VIOLATION_PIXMAP_PIXEL_SIZE; + if (height != NULL) + *height = MAX(*height, VIOLATION_PIXMAP_PIXEL_SIZE); } static void -ghid_violation_renderer_render (GtkCellRenderer *cell, - GdkDrawable *window, - GtkWidget *widget, - GdkRectangle *background_area, - GdkRectangle *cell_area, - GdkRectangle *expose_area, - GtkCellRendererState flags) +ghid_violation_renderer_render(GtkCellRenderer * cell, + GdkDrawable * window, + GtkWidget * widget, + GdkRectangle * background_area, + GdkRectangle * cell_area, GdkRectangle * expose_area, GtkCellRendererState flags) { - GdkDrawable *mydrawable; - GtkStyle *style = gtk_widget_get_style (widget); - GhidViolationRenderer *renderer = GHID_VIOLATION_RENDERER (cell); - GhidDrcViolation *violation = renderer->violation; - int pixmap_size = VIOLATION_PIXMAP_PIXEL_SIZE - 2 * VIOLATION_PIXMAP_PIXEL_BORDER; + GdkDrawable *mydrawable; + GtkStyle *style = gtk_widget_get_style(widget); + GhidViolationRenderer *renderer = GHID_VIOLATION_RENDERER(cell); + GhidDrcViolation *violation = renderer->violation; + int pixmap_size = VIOLATION_PIXMAP_PIXEL_SIZE - 2 * VIOLATION_PIXMAP_PIXEL_BORDER; - cell_area->width -= VIOLATION_PIXMAP_PIXEL_SIZE; - GTK_CELL_RENDERER_CLASS (ghid_violation_renderer_parent_class)->render (cell, - window, - widget, - background_area, - cell_area, - expose_area, - flags); + cell_area->width -= VIOLATION_PIXMAP_PIXEL_SIZE; + GTK_CELL_RENDERER_CLASS(ghid_violation_renderer_parent_class)->render(cell, + window, + widget, background_area, cell_area, expose_area, flags); - if (violation == NULL) - return; + if (violation == NULL) + return; - if (violation->pixmap == NULL) - { - GdkPixmap *pixmap = ghid_render_pixmap (violation->x_coord, - violation->y_coord, - VIOLATION_PIXMAP_PCB_SIZE / pixmap_size, - pixmap_size, pixmap_size, - gdk_drawable_get_depth (window)); - g_object_set (violation, "pixmap", pixmap, NULL); - g_object_unref (pixmap); - } + if (violation->pixmap == NULL) { + GdkPixmap *pixmap = ghid_render_pixmap(violation->x_coord, + violation->y_coord, + VIOLATION_PIXMAP_PCB_SIZE / pixmap_size, + pixmap_size, pixmap_size, + gdk_drawable_get_depth(window)); + g_object_set(violation, "pixmap", pixmap, NULL); + g_object_unref(pixmap); + } - if (violation->pixmap == NULL) - return; + if (violation->pixmap == NULL) + return; - mydrawable = GDK_DRAWABLE (violation->pixmap); + mydrawable = GDK_DRAWABLE(violation->pixmap); - gdk_draw_drawable (window, style->fg_gc[gtk_widget_get_state (widget)], - mydrawable, 0, 0, - cell_area->x + cell_area->width + VIOLATION_PIXMAP_PIXEL_BORDER, - cell_area->y + VIOLATION_PIXMAP_PIXEL_BORDER, -1, -1); + gdk_draw_drawable(window, style->fg_gc[gtk_widget_get_state(widget)], + mydrawable, 0, 0, + cell_area->x + cell_area->width + VIOLATION_PIXMAP_PIXEL_BORDER, + cell_area->y + VIOLATION_PIXMAP_PIXEL_BORDER, -1, -1); } @@ -765,27 +645,22 @@ * * \param [in] klass The GhidViolationRendererClass we are initialising */ -static void -ghid_violation_renderer_class_init (GhidViolationRendererClass * klass) +static void ghid_violation_renderer_class_init(GhidViolationRendererClass * klass) { - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GtkCellRendererClass *cellrenderer_class = GTK_CELL_RENDERER_CLASS (klass); + GObjectClass *gobject_class = G_OBJECT_CLASS(klass); + GtkCellRendererClass *cellrenderer_class = GTK_CELL_RENDERER_CLASS(klass); - gobject_class->finalize = ghid_violation_renderer_finalize; - gobject_class->set_property = ghid_violation_renderer_set_property; - gobject_class->get_property = ghid_violation_renderer_get_property; + gobject_class->finalize = ghid_violation_renderer_finalize; + gobject_class->set_property = ghid_violation_renderer_set_property; + gobject_class->get_property = ghid_violation_renderer_get_property; - cellrenderer_class->get_size = ghid_violation_renderer_get_size; - cellrenderer_class->render = ghid_violation_renderer_render; + cellrenderer_class->get_size = ghid_violation_renderer_get_size; + cellrenderer_class->render = ghid_violation_renderer_render; - ghid_violation_renderer_parent_class = (GObjectClass *)g_type_class_peek_parent (klass); + ghid_violation_renderer_parent_class = (GObjectClass *) g_type_class_peek_parent(klass); - g_object_class_install_property (gobject_class, PROP_VIOLATION, - g_param_spec_object ("violation", - "", - "", - GHID_TYPE_DRC_VIOLATION, - G_PARAM_WRITABLE)); + g_object_class_install_property(gobject_class, PROP_VIOLATION, + g_param_spec_object("violation", "", "", GHID_TYPE_DRC_VIOLATION, G_PARAM_WRITABLE)); } @@ -798,31 +673,29 @@ * * \return the GType identifier associated with GhidViolationRenderer. */ -GType -ghid_violation_renderer_get_type () +GType ghid_violation_renderer_get_type() { - static GType ghid_violation_renderer_type = 0; + static GType ghid_violation_renderer_type = 0; - if (!ghid_violation_renderer_type) - { - static const GTypeInfo ghid_violation_renderer_info = { - sizeof (GhidViolationRendererClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) ghid_violation_renderer_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GhidViolationRenderer), - 0, /* n_preallocs */ - NULL, /* instance_init */ - }; + if (!ghid_violation_renderer_type) { + static const GTypeInfo ghid_violation_renderer_info = { + sizeof(GhidViolationRendererClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) ghid_violation_renderer_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(GhidViolationRenderer), + 0, /* n_preallocs */ + NULL, /* instance_init */ + }; - ghid_violation_renderer_type = - g_type_register_static (GTK_TYPE_CELL_RENDERER_TEXT, "GhidViolationRenderer", - &ghid_violation_renderer_info, (GTypeFlags)0); - } + ghid_violation_renderer_type = + g_type_register_static(GTK_TYPE_CELL_RENDERER_TEXT, "GhidViolationRenderer", + &ghid_violation_renderer_info, (GTypeFlags) 0); + } - return ghid_violation_renderer_type; + return ghid_violation_renderer_type; } @@ -833,136 +706,111 @@ * * \return The GhidViolationRenderer created. */ -GtkCellRenderer * -ghid_violation_renderer_new (void) +GtkCellRenderer *ghid_violation_renderer_new(void) { - GhidViolationRenderer *renderer; + GhidViolationRenderer *renderer; - renderer = (GhidViolationRenderer *)g_object_new (GHID_TYPE_VIOLATION_RENDERER, - "ypad", 6, - NULL); + renderer = (GhidViolationRenderer *) g_object_new(GHID_TYPE_VIOLATION_RENDERER, "ypad", 6, NULL); - return GTK_CELL_RENDERER (renderer); + return GTK_CELL_RENDERER(renderer); } -void -ghid_drc_window_show (gboolean raise) +void ghid_drc_window_show(gboolean raise) { - GtkWidget *vbox, *hbox, *button, *scrolled_window; - GtkCellRenderer *violation_renderer; + GtkWidget *vbox, *hbox, *button, *scrolled_window; + GtkCellRenderer *violation_renderer; - if (drc_window) - { - if (raise) - gtk_window_present(GTK_WINDOW(drc_window)); - return; - } + 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); + 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_add (GTK_CONTAINER (drc_window), vbox); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); - gtk_box_set_spacing (GTK_BOX (vbox), 6); + vbox = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(drc_window), vbox); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); + gtk_box_set_spacing(GTK_BOX(vbox), 6); - drc_list_model = gtk_list_store_new (NUM_DRC_COLUMNS, - G_TYPE_INT, /* DRC_VIOLATION_NUM_COL */ - G_TYPE_OBJECT); /* DRC_VIOLATION_OBJ_COL */ + drc_list_model = gtk_list_store_new(NUM_DRC_COLUMNS, G_TYPE_INT, /* DRC_VIOLATION_NUM_COL */ + G_TYPE_OBJECT); /* DRC_VIOLATION_OBJ_COL */ - scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, - TRUE /* EXPAND */, TRUE /* FILL */, 0 /* PADDING */); + scrolled_window = gtk_scrolled_window_new(NULL, NULL); + gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE /* EXPAND */ , TRUE /* FILL */ , 0 /* PADDING */ ); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - drc_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (drc_list_model)); - gtk_container_add (GTK_CONTAINER (scrolled_window), drc_list); + drc_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(drc_list_model)); + gtk_container_add(GTK_CONTAINER(scrolled_window), drc_list); - gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (drc_list), TRUE); - g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (drc_list)), "changed", - G_CALLBACK (selection_changed_cb), NULL); - g_signal_connect (drc_list, "row-activated", - G_CALLBACK (row_activated_cb), NULL); + gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(drc_list), TRUE); + g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW(drc_list)), "changed", G_CALLBACK(selection_changed_cb), NULL); + g_signal_connect(drc_list, "row-activated", G_CALLBACK(row_activated_cb), NULL); - violation_renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (drc_list), - -1, /* APPEND */ - _("No."), /* TITLE */ - violation_renderer, - "text", DRC_VIOLATION_NUM_COL, - NULL); + violation_renderer = gtk_cell_renderer_text_new(); + gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(drc_list), -1, /* APPEND */ + _("No."), /* TITLE */ + violation_renderer, "text", DRC_VIOLATION_NUM_COL, NULL); - violation_renderer = ghid_violation_renderer_new (); - gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (drc_list), - -1, /* APPEND */ - _("Violation details"), /* TITLE */ - violation_renderer, - "violation", DRC_VIOLATION_OBJ_COL, - NULL); + violation_renderer = ghid_violation_renderer_new(); + gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(drc_list), -1, /* APPEND */ + _("Violation details"), /* TITLE */ + violation_renderer, "violation", DRC_VIOLATION_OBJ_COL, NULL); - 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); + 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); - gtk_box_set_spacing (GTK_BOX (hbox), 6); + gtk_box_set_spacing(GTK_BOX(hbox), 6); - button = gtk_button_new_from_stock (GTK_STOCK_REFRESH); - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (drc_refresh_cb), NULL); - gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); + button = gtk_button_new_from_stock(GTK_STOCK_REFRESH); + g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(drc_refresh_cb), NULL); + gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 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); + 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_window_move (GTK_WINDOW (drc_window), 10, 10); - gtk_widget_show_all (drc_window); + gtk_widget_realize(drc_window); + if (Settings.AutoPlace) + gtk_window_move(GTK_WINDOW(drc_window), 10, 10); + gtk_widget_show_all(drc_window); } -void ghid_drc_window_append_violation (DrcViolationType *violation) +void ghid_drc_window_append_violation(DrcViolationType * violation) { - GhidDrcViolation *violation_obj; - GtkTreeIter iter; + GhidDrcViolation *violation_obj; + GtkTreeIter iter; - /* Ensure the required structures are setup */ - ghid_drc_window_show (FALSE); + /* Ensure the required structures are setup */ + ghid_drc_window_show(FALSE); - num_violations++; + num_violations++; - violation_obj = ghid_drc_violation_new (violation, /* pixmap */ NULL); + violation_obj = ghid_drc_violation_new(violation, /* pixmap */ NULL); - gtk_list_store_append (drc_list_model, &iter); - gtk_list_store_set (drc_list_model, &iter, - DRC_VIOLATION_NUM_COL, num_violations, - DRC_VIOLATION_OBJ_COL, violation_obj, - -1); + gtk_list_store_append(drc_list_model, &iter); + gtk_list_store_set(drc_list_model, &iter, DRC_VIOLATION_NUM_COL, num_violations, DRC_VIOLATION_OBJ_COL, violation_obj, -1); - g_object_unref (violation_obj); /* The list store takes its own reference */ + g_object_unref(violation_obj); /* The list store takes its own reference */ } -void ghid_drc_window_reset_message (void) +void ghid_drc_window_reset_message(void) { - if (drc_list_model != NULL) - gtk_list_store_clear (drc_list_model); - num_violations = 0; + if (drc_list_model != NULL) + gtk_list_store_clear(drc_list_model); + num_violations = 0; } -int ghid_drc_window_throw_dialog (void) +int ghid_drc_window_throw_dialog(void) { - ghid_drc_window_show (TRUE); - return 1; + ghid_drc_window_show(TRUE); + return 1; } Index: trunk/src/hid/gtk/gui-drc-window.h =================================================================== --- trunk/src/hid/gtk/gui-drc-window.h (revision 1021) +++ trunk/src/hid/gtk/gui-drc-window.h (revision 1022) @@ -40,34 +40,31 @@ typedef struct _GhidDrcViolation GhidDrcViolation; -struct _GhidDrcViolationClass -{ - GObjectClass parent_class; +struct _GhidDrcViolationClass { + GObjectClass parent_class; }; -struct _GhidDrcViolation -{ - GObject parent_instance; +struct _GhidDrcViolation { + GObject parent_instance; - char *title; - char *explanation; - Coord x_coord; - Coord y_coord; - Angle angle; - bool have_measured; - Coord measured_value; - Coord required_value; - int object_count; - long int *object_id_list; - int *object_type_list; - GdkDrawable *pixmap; + char *title; + char *explanation; + Coord x_coord; + Coord y_coord; + Angle angle; + bool have_measured; + Coord measured_value; + Coord required_value; + int object_count; + long int *object_id_list; + int *object_type_list; + GdkDrawable *pixmap; }; -GType ghid_drc_violation_get_type (void); +GType ghid_drc_violation_get_type(void); -GhidDrcViolation *ghid_drc_violation_new (DrcViolationType *violation, - GdkDrawable *pixmap); +GhidDrcViolation *ghid_drc_violation_new(DrcViolationType * violation, GdkDrawable * pixmap); #define GHID_TYPE_VIOLATION_RENDERER (ghid_violation_renderer_get_type()) @@ -80,21 +77,19 @@ typedef struct _GhidViolationRenderer GhidViolationRenderer; -struct _GhidViolationRendererClass -{ - GtkCellRendererTextClass parent_class; +struct _GhidViolationRendererClass { + GtkCellRendererTextClass parent_class; }; -struct _GhidViolationRenderer -{ - GtkCellRendererText parent_instance; +struct _GhidViolationRenderer { + GtkCellRendererText parent_instance; - GhidDrcViolation *violation; + GhidDrcViolation *violation; }; -GType ghid_violation_renderer_get_type (void); +GType ghid_violation_renderer_get_type(void); -GtkCellRenderer *ghid_violation_renderer_new (void); +GtkCellRenderer *ghid_violation_renderer_new(void); #endif /* PCB_HID_GTK_GUI_DRC_WINDOW_H */ Index: trunk/src/hid/gtk/gui-keyref-window.c =================================================================== --- trunk/src/hid/gtk/gui-keyref-window.c (revision 1021) +++ trunk/src/hid/gtk/gui-keyref-window.c (revision 1022) @@ -36,347 +36,330 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); static GtkWidget *keyref_window; static gchar *key_ref_text[] = { - "", - N_("Keyboard\n"), - N_("Keyboard shortcuts and actions available in PCB.\n"), - N_("In below key actions, is , is \n"), - N_("and is or \n"), - "\n", + "", + N_("Keyboard\n"), + N_("Keyboard shortcuts and actions available in PCB.\n"), + N_("In below key actions, is , is \n"), + N_("and is or \n"), + "\n", - "\ta\t", - N_("Set layer and size from line or arc\n"), - "\n", + "\ta\t", + N_("Set layer and size from line or arc\n"), + "\n", - "a ", - N_("Unselect all objects\n"), - "\n", + "a ", + N_("Unselect all objects\n"), + "\n", - "\tb\t", - N_("Flip element to opposite side of the board\n"), - "\tb\t", - N_("Flip selected objects to opposite side of the board\n"), - "\n", + "\tb\t", + N_("Flip element to opposite side of the board\n"), + "\tb\t", + N_("Flip selected objects to opposite side of the board\n"), + "\n", - "\tc\t", - N_("Copy selected to buffer and unselect\n"), - "\n", + "\tc\t", + N_("Copy selected to buffer and unselect\n"), + "\n", - "\td\t", - N_("Display pin/pad names (numbers with View->Enable pinout shows number)\n"), - "\td\t", - N_("Open pinout window for element under cursor\n"), - "\n", + "\td\t", + N_("Display pin/pad names (numbers with View->Enable pinout shows number)\n"), + "\td\t", + N_("Open pinout window for element under cursor\n"), + "\n", - "\te\t", - N_("Delete all rats\n"), - "\te\t", - N_("Delete selected rats\n"), - "\n", + "\te\t", + N_("Delete all rats\n"), + "\te\t", + N_("Delete selected rats\n"), + "\n", - "\tf\t", - N_("Highlight connections to object\n"), - "\tf\t", - N_("Reset highlighted connections\n"), - "\tf\t", - N_("Cumulative highlight connections to object\n"), - "\n", + "\tf\t", + N_("Highlight connections to object\n"), + "\tf\t", + N_("Reset highlighted connections\n"), + "\tf\t", + N_("Cumulative highlight connections to object\n"), + "\n", - "\tg\t", - N_("Increment grid by configured grid increment\n"), + "\tg\t", + N_("Increment grid by configured grid increment\n"), - "\tg\t", - N_("Decrement grid by configured grid increment\n"), - "\n", + "\tg\t", + N_("Decrement grid by configured grid increment\n"), + "\n", - "\th\t", - N_("Toggle visibility of element name under cursor\n"), + "\th\t", + N_("Toggle visibility of element name under cursor\n"), - "\th\t", - N_("Toggle visibility of selected element names\n"), + "\th\t", + N_("Toggle visibility of selected element names\n"), - "\th\t", - N_("Toggle the hole flag of object under cursor\n"), - "\n", + "\th\t", + N_("Toggle the hole flag of object under cursor\n"), + "\n", - "\tj\t", - N_("Toggle line/arc should clear polygons flag of object under cursor\n"), + "\tj\t", + N_("Toggle line/arc should clear polygons flag of object under cursor\n"), - "\tj\t", - N_("Toggle line/arc should clear polygons flag of selected\n"), - "\n", + "\tj\t", + N_("Toggle line/arc should clear polygons flag of selected\n"), + "\n", - "\tk\t", - N_("Increase clearance of object by configured clearance\n"), + "\tk\t", + N_("Increase clearance of object by configured clearance\n"), - "\tk\t", - N_("Decrease clearance of object by configured clearance\n"), + "\tk\t", + N_("Decrease clearance of object by configured clearance\n"), - "\tk\t", - N_("Increase clearance of selected objects by configured clearance\n"), + "\tk\t", + N_("Increase clearance of selected objects by configured clearance\n"), - "k ", - N_("Decrease clearance of selected objects by configured clearance\n"), - "\n", + "k ", + N_("Decrease clearance of selected objects by configured clearance\n"), + "\n", - "\tl\t", - N_("Increment current route style line size by configured line increment\n"), + "\tl\t", + N_("Increment current route style line size by configured line increment\n"), - "\tl\t", - N_("Decrement current route style line size by configured line increment\n"), - "\n", + "\tl\t", + N_("Decrement current route style line size by configured line increment\n"), + "\n", - "\tm\t", - N_("Move object to current layer\n"), + "\tm\t", + N_("Move object to current layer\n"), - "\tm\t", - N_("Move selected objects to current layer\n"), + "\tm\t", + N_("Move selected objects to current layer\n"), - "\tm\t", - N_("Mark at cursor location for showing relative offsets\n"), - "\n", + "\tm\t", + N_("Mark at cursor location for showing relative offsets\n"), + "\n", - "\tn\t", - N_("Select the shortest unselected rat on the board\n"), - "\n", + "\tn\t", + N_("Select the shortest unselected rat on the board\n"), + "\n", - "\to\t", - N_("Optimize and draw all rats\n"), + "\to\t", + N_("Optimize and draw all rats\n"), - "\to\t", - N_("Optimize and draw selected rats\n"), - "\n", + "\to\t", + N_("Optimize and draw selected rats\n"), + "\n", - "\to\t", - N_("Change octagon flag of object\n"), - "\n", + "\to\t", + N_("Change octagon flag of object\n"), + "\n", - "\tp\t", - N_("Backup polygon drawing to previous point\n"), + "\tp\t", + N_("Backup polygon drawing to previous point\n"), - "\tp\t", - N_("Close polygon\n"), - "\n", + "\tp\t", + N_("Close polygon\n"), + "\n", - "\tq\t", - N_("Toggle the square flag of an object\n"), - "\n", + "\tq\t", + N_("Toggle the square flag of an object\n"), + "\n", - "\tr\t", - N_("Redo last undone operation\n"), - "\n", + "\tr\t", + N_("Redo last undone operation\n"), + "\n", - "\ts\t", - N_("Increment size of an object by configured size increment\n"), - "\ts\t", - N_("Decrement size of an object by configured size increment\n"), - "\ts\t", - N_("Increment drill size of a pin or via\n"), - "s ", - N_("Decrement drill size of a pin or via\n"), - "\n", + "\ts\t", + N_("Increment size of an object by configured size increment\n"), + "\ts\t", + N_("Decrement size of an object by configured size increment\n"), + "\ts\t", + N_("Increment drill size of a pin or via\n"), + "s ", + N_("Decrement drill size of a pin or via\n"), + "\n", - "\tt\t", - N_("Adjust text scale so new text increases by the configured size increment\n"), - "\tt\t", - N_("Adjust text scale so new text decreases by the configured size increment\n"), - "\n", + "\tt\t", + N_("Adjust text scale so new text increases by the configured size increment\n"), + "\tt\t", + N_("Adjust text scale so new text decreases by the configured size increment\n"), + "\n", - "\tu\t", - N_("Undo last operation\n"), - "\n", + "\tu\t", + N_("Undo last operation\n"), + "\n", - "\tv\t", - N_("Zoom to board extents\n"), - "\tv\t", - N_("Increment current route style via size\n"), - "v ", - N_("Decrement current route style via size\n"), - "\tv\t", - N_("Increment current route style via hole size\n"), - "v ", - N_("Decrement current route style via hole size\n"), - "\n", + "\tv\t", + N_("Zoom to board extents\n"), + "\tv\t", + N_("Increment current route style via size\n"), + "v ", + N_("Decrement current route style via size\n"), + "\tv\t", + N_("Increment current route style via hole size\n"), + "v ", + N_("Decrement current route style via hole size\n"), + "\n", - "\tx\t", - N_("Copy selection to buffer and enter pastebuffer mode\n"), - "x ", - N_("Cut selection to buffer and enter pastebuffer mode\n"), - "\n", + "\tx\t", + N_("Copy selection to buffer and enter pastebuffer mode\n"), + "x ", + N_("Cut selection to buffer and enter pastebuffer mode\n"), + "\n", - "\tz\t", - N_("Zoom in\n"), - "\tz\t", - N_("Zoom out\n"), - "\n", + "\tz\t", + N_("Zoom in\n"), + "\tz\t", + N_("Zoom out\n"), + "\n", - "\t|\t", - N_("Toggle thin draw mode\n"), - "\n", + "\t|\t", + N_("Toggle thin draw mode\n"), + "\n", - "\t/\t", - N_("Cycle multiline mode (Using overrides)\n"), - "\n", + "\t/\t", + N_("Cycle multiline mode (Using overrides)\n"), + "\n", - "\t.\t", - N_("Toggle all direction lines mode\n"), - "\n", + "\t.\t", + N_("Toggle all direction lines mode\n"), + "\n", - "\tEsc\t", - N_("If drawing an object, return to a neutral state.\n"), - "\n", + "\tEsc\t", + N_("If drawing an object, return to a neutral state.\n"), + "\n", - "\tTab\t", - N_("Switch view to other side\n"), - "\n", + "\tTab\t", + N_("Switch view to other side\n"), + "\n", - " Space\t", - N_("Switch to select mode\n"), - "\n", + " Space\t", + N_("Switch to select mode\n"), + "\n", - "\t:\t", - N_("Enter user command or pop up command window\n"), - "\n", + "\t:\t", + N_("Enter user command or pop up command window\n"), + "\n", - "\tDEL\t", - N_("Delete object\n"), - "\n", + "\tDEL\t", + N_("Delete object\n"), + "\n", - "\t1-9\t", - N_("Select drawing layers\n"), - "\n", + "\t1-9\t", + N_("Select drawing layers\n"), + "\n", - "\t1-5\t", - N_("Select current buffer\n"), - "\n", - "\n", - "", - N_("Mouse\n"), - N_("Modifier key use can be combined with mouse button presses\n" - "to modify mouse button actions.\n"), - "\n", - N_("Left button\n"), - N_("\tPerform or initiate action determined by current mode.\n"), - "\n", - "\t", - N_(""), - N_(" - change rotation direction for rotation tool actions.\n"), - "\n", - N_("\tAfter a draw operation has been left mouse button initiated,\n" - "\tmodifier key effects:\n"), - "\t", - N_(""), - N_(" - change line 45 degree direction and arc angle direction,\n"), - "\n", - N_("Middle button\n"), - N_("\tIf a line, arc, rectangle, or polygon draw operation has been\n" - "\tinitiated, a click restarts the draw operation at the cursor position.\n"), - "\n", - N_("\tIf such a draw has not been initiated, a click selects objects and\n" - "\ta press and drag moves objects.\n"), - "\n", - N_("Right button\n"), - N_("\tPress and drag to pan.\n" - "\tWhile drawing or moving, a click without a drag toggles auto pan mode.\n"), - "\n\t", - N_(""), - N_(" - Popup a menu.\n"), - "\n", - N_("Scroll wheel\n"), - N_("\tZoom in/out.\n"), - "\n\t", - N_(""), - N_(" - pan vertically.\n"), - "\t", - N_(""), - N_(" - pan horizontally.\n"), - "\n", - N_("Usage:\n"), - N_("\tMouse actions can typically be combined. For example: while moving\n" - "\tan object (with left or middle press and drag), the right button may\n" - "\tbe simultaneously clicked to toggle auto pan or pressed and dragged\n" - "\tto manually pan. Mouse moving or drawing may also be combined with\n" - "\tkey actions.\n"), + "\t1-5\t", + N_("Select current buffer\n"), + "\n", + "\n", + "", + N_("Mouse\n"), + N_("Modifier key use can be combined with mouse button presses\n" "to modify mouse button actions.\n"), + "\n", + N_("Left button\n"), + N_("\tPerform or initiate action determined by current mode.\n"), + "\n", + "\t", + N_(""), + N_(" - change rotation direction for rotation tool actions.\n"), + "\n", + N_("\tAfter a draw operation has been left mouse button initiated,\n" "\tmodifier key effects:\n"), + "\t", + N_(""), + N_(" - change line 45 degree direction and arc angle direction,\n"), + "\n", + N_("Middle button\n"), + N_("\tIf a line, arc, rectangle, or polygon draw operation has been\n" + "\tinitiated, a click restarts the draw operation at the cursor position.\n"), + "\n", + N_("\tIf such a draw has not been initiated, a click selects objects and\n" "\ta press and drag moves objects.\n"), + "\n", + N_("Right button\n"), + N_("\tPress and drag to pan.\n" "\tWhile drawing or moving, a click without a drag toggles auto pan mode.\n"), + "\n\t", + N_(""), + N_(" - Popup a menu.\n"), + "\n", + N_("Scroll wheel\n"), + N_("\tZoom in/out.\n"), + "\n\t", + N_(""), + N_(" - pan vertically.\n"), + "\t", + N_(""), + N_(" - pan horizontally.\n"), + "\n", + N_("Usage:\n"), + N_("\tMouse actions can typically be combined. For example: while moving\n" + "\tan object (with left or middle press and drag), the right button may\n" + "\tbe simultaneously clicked to toggle auto pan or pressed and dragged\n" + "\tto manually pan. Mouse moving or drawing may also be combined with\n" "\tkey actions.\n"), }; - /* Remember user window resizes. - */ -static gint -keyref_window_configure_event_cb (GtkWidget * widget, GdkEventConfigure * ev, - gpointer data) + /* Remember user window resizes. + */ +static gint keyref_window_configure_event_cb(GtkWidget * widget, GdkEventConfigure * ev, gpointer data) { - GtkAllocation allocation; + GtkAllocation allocation; - gtk_widget_get_allocation (widget, &allocation); - ghidgui->keyref_window_width = allocation.width; - ghidgui->keyref_window_height = allocation.height; - ghidgui->config_modified = TRUE; - return FALSE; + gtk_widget_get_allocation(widget, &allocation); + ghidgui->keyref_window_width = allocation.width; + ghidgui->keyref_window_height = allocation.height; + ghidgui->config_modified = TRUE; + return FALSE; } -static void -keyref_close_cb (gpointer data) +static void keyref_close_cb(gpointer data) { - gtk_widget_destroy (keyref_window); - keyref_window = NULL; + gtk_widget_destroy(keyref_window); + keyref_window = NULL; } -static void -keyref_destroy_cb (GtkWidget * widget, gpointer data) +static void keyref_destroy_cb(GtkWidget * widget, gpointer data) { - keyref_window = NULL; + keyref_window = NULL; } -void -ghid_keyref_window_show (gboolean raise) +void ghid_keyref_window_show(gboolean raise) { - GtkWidget *vbox, *hbox, *button, *text; - gint i; + GtkWidget *vbox, *hbox, *button, *text; + gint i; - if (keyref_window) - { - if (raise) - gtk_window_present(GTK_WINDOW(keyref_window)); - return; - } - keyref_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - g_signal_connect (G_OBJECT (keyref_window), "destroy", - G_CALLBACK (keyref_destroy_cb), NULL); - g_signal_connect (G_OBJECT (keyref_window), "configure_event", - G_CALLBACK (keyref_window_configure_event_cb), NULL); - gtk_window_set_title (GTK_WINDOW (keyref_window), _("PCB Key Reference")); - gtk_window_set_wmclass (GTK_WINDOW (keyref_window), "PCB_Keyref", "PCB"); - gtk_window_set_default_size (GTK_WINDOW (keyref_window), - ghidgui->keyref_window_width, - ghidgui->keyref_window_height); + if (keyref_window) { + if (raise) + gtk_window_present(GTK_WINDOW(keyref_window)); + return; + } + keyref_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + g_signal_connect(G_OBJECT(keyref_window), "destroy", G_CALLBACK(keyref_destroy_cb), NULL); + g_signal_connect(G_OBJECT(keyref_window), "configure_event", G_CALLBACK(keyref_window_configure_event_cb), NULL); + gtk_window_set_title(GTK_WINDOW(keyref_window), _("PCB Key Reference")); + gtk_window_set_wmclass(GTK_WINDOW(keyref_window), "PCB_Keyref", "PCB"); + gtk_window_set_default_size(GTK_WINDOW(keyref_window), ghidgui->keyref_window_width, ghidgui->keyref_window_height); - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); - gtk_container_add (GTK_CONTAINER (keyref_window), vbox); + vbox = gtk_vbox_new(FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); + gtk_container_add(GTK_CONTAINER(keyref_window), vbox); - text = ghid_scrolled_text_view (vbox, NULL, - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - for (i = 0; i < sizeof (key_ref_text) / sizeof (gchar *); ++i) - ghid_text_view_append (text, _(key_ref_text[i])); + text = ghid_scrolled_text_view(vbox, NULL, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + for (i = 0; i < sizeof(key_ref_text) / sizeof(gchar *); ++i) + ghid_text_view_append(text, _(key_ref_text[i])); - /* The keyref window close button. - */ - 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, 3); - button = gtk_button_new_from_stock (GTK_STOCK_CLOSE); - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (keyref_close_cb), NULL); - gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); + /* The keyref window close button. + */ + 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, 3); + button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); + g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(keyref_close_cb), NULL); + gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); - gtk_widget_show_all (keyref_window); + gtk_widget_show_all(keyref_window); } Index: trunk/src/hid/gtk/gui-library-window.c =================================================================== --- trunk/src/hid/gtk/gui-library-window.c (revision 1021) +++ trunk/src/hid/gtk/gui-library-window.c (revision 1022) @@ -67,7 +67,7 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); static GtkWidget *library_window; @@ -87,26 +87,23 @@ #define LIBRARY_FILTER_INTERVAL 200 -static gint -library_window_configure_event_cb (GtkWidget * widget, GdkEventConfigure * ev, - gpointer data) +static gint library_window_configure_event_cb(GtkWidget * widget, GdkEventConfigure * ev, gpointer data) { - GtkAllocation allocation; + GtkAllocation allocation; - gtk_widget_get_allocation (widget, &allocation); - ghidgui->library_window_width = allocation.width; - ghidgui->library_window_height = allocation.height; - ghidgui->config_modified = TRUE; - return FALSE; + gtk_widget_get_allocation(widget, &allocation); + ghidgui->library_window_width = allocation.width; + ghidgui->library_window_height = allocation.height; + ghidgui->config_modified = TRUE; + return FALSE; } -enum -{ - MENU_NAME_COLUMN, /* Text to display in the tree */ - MENU_LIBRARY_COLUMN, /* Pointer to the LibraryMenuType */ - MENU_ENTRY_COLUMN, /* Pointer to the LibraryEntryType */ - N_MENU_COLUMNS +enum { + MENU_NAME_COLUMN, /* Text to display in the tree */ + MENU_LIBRARY_COLUMN, /* Pointer to the LibraryMenuType */ + MENU_ENTRY_COLUMN, /* Pointer to the LibraryEntryType */ + N_MENU_COLUMNS }; @@ -122,23 +119,20 @@ * \param [in] arg1 The response ID. * \param [in] user_data */ -static void -library_window_callback_response (GtkDialog * dialog, - gint arg1, gpointer user_data) +static void library_window_callback_response(GtkDialog * dialog, gint arg1, gpointer user_data) { - switch (arg1) - { - case GTK_RESPONSE_CLOSE: - case GTK_RESPONSE_DELETE_EVENT: - gtk_widget_destroy (GTK_WIDGET (library_window)); - library_window = NULL; - break; + switch (arg1) { + case GTK_RESPONSE_CLOSE: + case GTK_RESPONSE_DELETE_EVENT: + gtk_widget_destroy(GTK_WIDGET(library_window)); + library_window = NULL; + break; - default: - /* Do nothing, in case there's another handler function which - can handle the response ID received. */ - break; - } + default: + /* Do nothing, in case there's another handler function which + can handle the response ID received. */ + break; + } } @@ -148,50 +142,37 @@ * It does not show the dialog, use ghid_library_window_show for that. * */ -void -ghid_library_window_create (GHidPort * out) +void ghid_library_window_create(GHidPort * out) { - GtkWidget *current_tab, *entry_filter; - GtkNotebook *notebook; + GtkWidget *current_tab, *entry_filter; + GtkNotebook *notebook; - if (library_window) - return; + if (library_window) + return; - library_window = (GtkWidget *)g_object_new (GHID_TYPE_LIBRARY_WINDOW, NULL); + library_window = (GtkWidget *) g_object_new(GHID_TYPE_LIBRARY_WINDOW, NULL); - g_signal_connect (library_window, - "response", - G_CALLBACK (library_window_callback_response), NULL); - g_signal_connect (G_OBJECT (library_window), "configure_event", - G_CALLBACK (library_window_configure_event_cb), NULL); - gtk_window_set_default_size (GTK_WINDOW (library_window), - ghidgui->library_window_width, - ghidgui->library_window_height); + g_signal_connect(library_window, "response", G_CALLBACK(library_window_callback_response), NULL); + g_signal_connect(G_OBJECT(library_window), "configure_event", G_CALLBACK(library_window_configure_event_cb), NULL); + gtk_window_set_default_size(GTK_WINDOW(library_window), ghidgui->library_window_width, ghidgui->library_window_height); - gtk_window_set_title (GTK_WINDOW (library_window), _("PCB Library")); - gtk_window_set_wmclass (GTK_WINDOW (library_window), "PCB_Library", - "PCB"); + gtk_window_set_title(GTK_WINDOW(library_window), _("PCB Library")); + gtk_window_set_wmclass(GTK_WINDOW(library_window), "PCB_Library", "PCB"); - gtk_widget_realize (library_window); - if (Settings.AutoPlace) - gtk_window_move (GTK_WINDOW (library_window), 10, 10); + gtk_widget_realize(library_window); + if (Settings.AutoPlace) + gtk_window_move(GTK_WINDOW(library_window), 10, 10); - gtk_editable_select_region (GTK_EDITABLE - (GHID_LIBRARY_WINDOW (library_window)-> - entry_filter), 0, -1); + gtk_editable_select_region(GTK_EDITABLE(GHID_LIBRARY_WINDOW(library_window)->entry_filter), 0, -1); - /* Set the focus to the filter entry only if it is in the current - displayed tab */ - notebook = GTK_NOTEBOOK (GHID_LIBRARY_WINDOW (library_window)->viewtabs); - current_tab = gtk_notebook_get_nth_page (notebook, - gtk_notebook_get_current_page - (notebook)); - entry_filter = - GTK_WIDGET (GHID_LIBRARY_WINDOW (library_window)->entry_filter); - if (gtk_widget_is_ancestor (entry_filter, current_tab)) - { - gtk_widget_grab_focus (entry_filter); - } + /* Set the focus to the filter entry only if it is in the current + displayed tab */ + notebook = GTK_NOTEBOOK(GHID_LIBRARY_WINDOW(library_window)->viewtabs); + current_tab = gtk_notebook_get_nth_page(notebook, gtk_notebook_get_current_page(notebook)); + entry_filter = GTK_WIDGET(GHID_LIBRARY_WINDOW(library_window)->entry_filter); + if (gtk_widget_is_ancestor(entry_filter, current_tab)) { + gtk_widget_grab_focus(entry_filter); + } } /*! \brief Show the library dialog. @@ -200,13 +181,12 @@ * already created, and presents it to the user (brings it to the * front with focus). */ -void -ghid_library_window_show (GHidPort * out, gboolean raise) +void ghid_library_window_show(GHidPort * out, gboolean raise) { - ghid_library_window_create (out); - gtk_widget_show_all (library_window); - if (raise) - gtk_window_present (GTK_WINDOW(library_window)); + ghid_library_window_create(out); + gtk_widget_show_all(library_window); + if (raise) + gtk_window_present(GTK_WINDOW(library_window)); } static GObjectClass *library_window_parent_class = NULL; @@ -222,26 +202,23 @@ * \param [in] data The library dialog. * \returns TRUE if item should be visible, FALSE otherwise. */ -static gboolean -lib_model_filter_visible_func (GtkTreeModel * model, - GtkTreeIter * iter, gpointer data) +static gboolean lib_model_filter_visible_func(GtkTreeModel * model, GtkTreeIter * iter, gpointer data) { - GhidLibraryWindow *library_window = (GhidLibraryWindow *) data; - const gchar *compname; - gchar *compname_upper, *text_upper, *pattern; - const gchar *text_; - char text[1024]; - gboolean ret; + GhidLibraryWindow *library_window = (GhidLibraryWindow *) data; + const gchar *compname; + gchar *compname_upper, *text_upper, *pattern; + const gchar *text_; + char text[1024]; + gboolean ret; char *p, *tags; int len, is_para = 0; - g_assert (GHID_IS_LIBRARY_WINDOW (data)); + g_assert(GHID_IS_LIBRARY_WINDOW(data)); - text_ = gtk_entry_get_text (library_window->entry_filter); - if (g_ascii_strcasecmp (text_, "") == 0) - { - return TRUE; - } + text_ = gtk_entry_get_text(library_window->entry_filter); + if (g_ascii_strcasecmp(text_, "") == 0) { + return TRUE; + } /* TODO: do these only once.... */ p = strchr(text_, '('); @@ -250,7 +227,7 @@ is_para = 1; } else - len = sizeof(text)-1; + len = sizeof(text) - 1; strncpy(text, text_, len); text[len] = '\0'; @@ -261,7 +238,8 @@ if (tags != NULL) { *tags = '\0'; tags++; - while(isspace(*tags)) tags++; + while (isspace(*tags)) + tags++; if (*tags == '\0') tags = NULL; } @@ -269,83 +247,80 @@ else tags = NULL; - /* If this is a source, only display it if it has children that - * match */ - if (gtk_tree_model_iter_has_child (model, iter)) - { - GtkTreeIter iter2; + /* If this is a source, only display it if it has children that + * match */ + if (gtk_tree_model_iter_has_child(model, iter)) { + GtkTreeIter iter2; - gtk_tree_model_iter_children (model, &iter2, iter); - ret = FALSE; - do - { - if (lib_model_filter_visible_func (model, &iter2, data)) - { - ret = TRUE; - break; - } + gtk_tree_model_iter_children(model, &iter2, iter); + ret = FALSE; + do { + if (lib_model_filter_visible_func(model, &iter2, data)) { + ret = TRUE; + break; + } + } + while (gtk_tree_model_iter_next(model, &iter2)); } - while (gtk_tree_model_iter_next (model, &iter2)); - } - else - { - gtk_tree_model_get (model, iter, MENU_NAME_COLUMN, &compname, -1); - /* Do a case insensitive comparison, converting the strings - to uppercase */ - compname_upper = g_ascii_strup (compname, -1); - text_upper = g_ascii_strup (text, -1); - if (is_para) - pattern = g_strconcat ("*", text_upper, "(*", NULL); - else - pattern = g_strconcat ("*", text_upper, "*", NULL); + else { + gtk_tree_model_get(model, iter, MENU_NAME_COLUMN, &compname, -1); + /* Do a case insensitive comparison, converting the strings + to uppercase */ + compname_upper = g_ascii_strup(compname, -1); + text_upper = g_ascii_strup(text, -1); + if (is_para) + pattern = g_strconcat("*", text_upper, "(*", NULL); + else + pattern = g_strconcat("*", text_upper, "*", NULL); - ret = g_pattern_match_simple (pattern, compname_upper); + ret = g_pattern_match_simple(pattern, compname_upper); - if ((tags != NULL) && ret) { - LibraryEntryType *entry = NULL; - gtk_tree_model_get(model, iter, MENU_ENTRY_COLUMN, &entry, -1); - if ((entry != NULL) && (entry->Tags != NULL)) { - char *next, *tag; - int found; - void **t; - const void *need; + if ((tags != NULL) && ret) { + LibraryEntryType *entry = NULL; + gtk_tree_model_get(model, iter, MENU_ENTRY_COLUMN, &entry, -1); + if ((entry != NULL) && (entry->Tags != NULL)) { + char *next, *tag; + int found; + void **t; + const void *need; - for(tag = tags; tag != NULL; tag = next) { - next = strpbrk(tag, " \t\r\n"); - if (next != NULL) { - *next = '\0'; + for (tag = tags; tag != NULL; tag = next) { + next = strpbrk(tag, " \t\r\n"); + if (next != NULL) { + *next = '\0'; + next++; + while (isspace(*next)) next++; - while(isspace(*next)) next++; - } - need = pcb_fp_tag(tag, 0); - fprintf(stderr, "TAG: '%s' %p\n", tag, need); - if (need == NULL) { - ret = FALSE; + } + need = pcb_fp_tag(tag, 0); + fprintf(stderr, "TAG: '%s' %p\n", tag, need); + if (need == NULL) { + ret = FALSE; + break; + } + found = 0; + for (t = entry->Tags; *t != NULL; t++) { + if (*t == need) { + found = 1; break; } - found = 0; - for(t = entry->Tags; *t != NULL; t++) { - if (*t == need) { - found = 1; - break; - } - } - if (!found) { - ret = FALSE; - break; - } } + if (!found) { + ret = FALSE; + break; + } } - else - ret = FALSE; } + else + ret = FALSE; + } - g_free (compname_upper); - g_free (text_upper); - g_free (pattern); - } + g_free(compname_upper); + g_free(text_upper); + g_free(pattern); + } - return ret; + return ret; } @@ -359,25 +334,21 @@ * \param [in] column The GtkTreeViewColumn in which the activation occurre * \param [in] user_data The component selection dialog. */ -static void -tree_row_activated (GtkTreeView *tree_view, - GtkTreePath *path, - GtkTreeViewColumn *column, - gpointer user_data) +static void tree_row_activated(GtkTreeView * tree_view, GtkTreePath * path, GtkTreeViewColumn * column, gpointer user_data) { - GtkTreeModel *model; - GtkTreeIter iter; + GtkTreeModel *model; + GtkTreeIter iter; - model = gtk_tree_view_get_model (tree_view); - gtk_tree_model_get_iter (model, &iter, path); + model = gtk_tree_view_get_model(tree_view); + gtk_tree_model_get_iter(model, &iter, path); - if (!gtk_tree_model_iter_has_child (model, &iter)) - return; + if (!gtk_tree_model_iter_has_child(model, &iter)) + return; - if (gtk_tree_view_row_expanded (tree_view, path)) - gtk_tree_view_collapse_row (tree_view, path); - else - gtk_tree_view_expand_row (tree_view, path, FALSE); + if (gtk_tree_view_row_expanded(tree_view, path)) + gtk_tree_view_collapse_row(tree_view, path); + else + gtk_tree_view_expand_row(tree_view, path, FALSE); } /*! \brief Handles CTRL-C keypress in the TreeView @@ -390,74 +361,69 @@ * \param [in] user_data Not used. * \return TRUE if CTRL-C event was handled, FALSE otherwise. */ -static gboolean -tree_row_key_pressed (GtkTreeView *tree_view, - GdkEventKey *event, - gpointer user_data) +static gboolean tree_row_key_pressed(GtkTreeView * tree_view, GdkEventKey * event, gpointer user_data) { - GtkTreeSelection *selection; - GtkTreeModel *model; - GtkTreeIter iter; - GtkClipboard *clipboard; - const gchar *compname; - guint default_mod_mask = gtk_accelerator_get_default_mod_mask(); + GtkTreeSelection *selection; + GtkTreeModel *model; + GtkTreeIter iter; + GtkClipboard *clipboard; + const gchar *compname; + guint default_mod_mask = gtk_accelerator_get_default_mod_mask(); - /* Handle both lower- and uppercase `c' */ - if (((event->state & default_mod_mask) != GDK_CONTROL_MASK) - || ((event->keyval != GDK_c) && (event->keyval != GDK_C))) - return FALSE; + /* Handle both lower- and uppercase `c' */ + if (((event->state & default_mod_mask) != GDK_CONTROL_MASK) + || ((event->keyval != GDK_c) && (event->keyval != GDK_C))) + return FALSE; - selection = gtk_tree_view_get_selection (tree_view); - g_return_val_if_fail (selection != NULL, TRUE); + selection = gtk_tree_view_get_selection(tree_view); + g_return_val_if_fail(selection != NULL, TRUE); - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) - return TRUE; + if (!gtk_tree_selection_get_selected(selection, &model, &iter)) + return TRUE; - gtk_tree_model_get (model, &iter, MENU_NAME_COLUMN, &compname, -1); + gtk_tree_model_get(model, &iter, MENU_NAME_COLUMN, &compname, -1); - clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); - g_return_val_if_fail (clipboard != NULL, TRUE); + clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); + g_return_val_if_fail(clipboard != NULL, TRUE); - gtk_clipboard_set_text (clipboard, compname, -1); + gtk_clipboard_set_text(clipboard, compname, -1); - return TRUE; + return TRUE; } -static void library_window_preview_refresh(GhidLibraryWindow *library_window, const char *name, LibraryEntryType *entry) +static void library_window_preview_refresh(GhidLibraryWindow * library_window, const char *name, LibraryEntryType * entry) { - GString *pt; + GString *pt; - /* -1 flags this is an element file part and the file path is in - | entry->AllocateMemory. - */ - if (LoadElementToBuffer (PASTEBUFFER, name == NULL ? entry->AllocatedMemory : name)) - SetMode (PASTEBUFFER_MODE); + /* -1 flags this is an element file part and the file path is in + | entry->AllocateMemory. + */ + if (LoadElementToBuffer(PASTEBUFFER, name == NULL ? entry->AllocatedMemory : name)) + SetMode(PASTEBUFFER_MODE); - /* update the preview with new symbol data */ + /* update the preview with new symbol data */ if ((PASTEBUFFER->Data != NULL) && (PASTEBUFFER->Data->Element != NULL) && (PASTEBUFFER->Data->Element->data != NULL)) - g_object_set (library_window->preview, - "element-data", PASTEBUFFER->Data->Element->data, NULL); + g_object_set(library_window->preview, "element-data", PASTEBUFFER->Data->Element->data, NULL); else { - g_object_set (library_window->preview, - "element-data", NULL, NULL); + g_object_set(library_window->preview, "element-data", NULL, NULL); } /* update the text */ - pt = g_string_new ("Tags:"); + pt = g_string_new("Tags:"); if ((entry != NULL) && (entry->Tags != NULL)) { void **t; - - for(t = entry->Tags; *t != NULL; t++) { + + for (t = entry->Tags; *t != NULL; t++) { const char *name = pcb_fp_tagname(*t); if (name != NULL) { - g_string_append (pt, "\n "); - g_string_append (pt, name); + g_string_append(pt, "\n "); + g_string_append(pt, name); } } } - g_string_append (pt, "\n"); - gtk_label_set_text(GTK_LABEL (library_window->preview_text), g_string_free(pt, FALSE)); + g_string_append(pt, "\n"); + gtk_label_set_text(GTK_LABEL(library_window->preview_text), g_string_free(pt, FALSE)); } /*! \brief Handles changes in the treeview selection. @@ -471,22 +437,20 @@ * \param [in] selection The current selection in the treeview. * \param [in] user_data The library dialog. */ -static void -library_window_callback_tree_selection_changed (GtkTreeSelection * selection, - gpointer user_data) +static void library_window_callback_tree_selection_changed(GtkTreeSelection * selection, gpointer user_data) { - GtkTreeModel *model; - GtkTreeIter iter; - GhidLibraryWindow *library_window = (GhidLibraryWindow *) user_data; - LibraryEntryType *entry = NULL; + GtkTreeModel *model; + GtkTreeIter iter; + GhidLibraryWindow *library_window = (GhidLibraryWindow *) user_data; + LibraryEntryType *entry = NULL; - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) - return; + if (!gtk_tree_selection_get_selected(selection, &model, &iter)) + return; - gtk_tree_model_get (model, &iter, MENU_ENTRY_COLUMN, &entry, -1); + gtk_tree_model_get(model, &iter, MENU_ENTRY_COLUMN, &entry, -1); - if (entry == NULL) - return; + if (entry == NULL) + return; library_window_preview_refresh(library_window, NULL, entry); } @@ -502,42 +466,40 @@ * \param [in] data The library dialog. * \returns FALSE to remove the timeout. */ -static gboolean -library_window_filter_timeout (gpointer data) +static gboolean library_window_filter_timeout(gpointer data) { - GhidLibraryWindow *library_window = GHID_LIBRARY_WINDOW (data); - GtkTreeModel *model; + GhidLibraryWindow *library_window = GHID_LIBRARY_WINDOW(data); + GtkTreeModel *model; - /* resets the source id in library_window */ - library_window->filter_timeout = 0; + /* resets the source id in library_window */ + library_window->filter_timeout = 0; - model = gtk_tree_view_get_model (library_window->libtreeview); + model = gtk_tree_view_get_model(library_window->libtreeview); - if (model != NULL) - { - const gchar *text = gtk_entry_get_text (library_window->entry_filter); - gtk_tree_model_filter_refilter ((GtkTreeModelFilter *) model); - if (strcmp (text, "") != 0) - { - /* filter text not-empty */ - gtk_tree_view_expand_all (library_window->libtreeview); + if (model != NULL) { + const gchar *text = gtk_entry_get_text(library_window->entry_filter); + gtk_tree_model_filter_refilter((GtkTreeModelFilter *) model); + if (strcmp(text, "") != 0) { + /* filter text not-empty */ + gtk_tree_view_expand_all(library_window->libtreeview); - /* parametric footprints need to be refreshed on edit */ - if (strchr(text, ')') != NULL) - library_window_preview_refresh(library_window, text, NULL); + /* parametric footprints need to be refreshed on edit */ + if (strchr(text, ')') != NULL) + library_window_preview_refresh(library_window, text, NULL); - } else { - /* filter text is empty, collapse expanded tree */ - gtk_tree_view_collapse_all (library_window->libtreeview); - } + } + else { + /* filter text is empty, collapse expanded tree */ + gtk_tree_view_collapse_all(library_window->libtreeview); + } - } + } - /* return FALSE to remove the source */ - return FALSE; + /* return FALSE to remove the source */ + return FALSE; } /*! \brief Callback function for the changed signal of the filter entry. @@ -551,31 +513,25 @@ * \param [in] editable The filter text entry. * \param [in] user_data The library dialog. */ -static void -library_window_callback_filter_entry_changed (GtkEditable * editable, - gpointer user_data) +static void library_window_callback_filter_entry_changed(GtkEditable * editable, gpointer user_data) { - GhidLibraryWindow *library_window = GHID_LIBRARY_WINDOW (user_data); - GtkWidget *button; - gboolean sensitive; + GhidLibraryWindow *library_window = GHID_LIBRARY_WINDOW(user_data); + GtkWidget *button; + gboolean sensitive; - /* turns button off if filter entry is empty */ - /* turns it on otherwise */ - button = GTK_WIDGET (library_window->button_clear); - sensitive = - (g_ascii_strcasecmp (gtk_entry_get_text (library_window->entry_filter), - "") != 0); - gtk_widget_set_sensitive (button, sensitive); + /* turns button off if filter entry is empty */ + /* turns it on otherwise */ + button = GTK_WIDGET(library_window->button_clear); + sensitive = (g_ascii_strcasecmp(gtk_entry_get_text(library_window->entry_filter), "") != 0); + gtk_widget_set_sensitive(button, sensitive); - /* Cancel any pending update of the footprint list filter */ - if (library_window->filter_timeout != 0) - g_source_remove (library_window->filter_timeout); + /* Cancel any pending update of the footprint list filter */ + if (library_window->filter_timeout != 0) + g_source_remove(library_window->filter_timeout); - /* Schedule an update of the footprint list filter in - * LIBRARY_FILTER_INTERVAL milliseconds */ - library_window->filter_timeout = g_timeout_add (LIBRARY_FILTER_INTERVAL, - library_window_filter_timeout, - library_window); + /* Schedule an update of the footprint list filter in + * LIBRARY_FILTER_INTERVAL milliseconds */ + library_window->filter_timeout = g_timeout_add(LIBRARY_FILTER_INTERVAL, library_window_filter_timeout, library_window); } @@ -590,14 +546,12 @@ * \param [in] editable The filter text entry. * \param [in] user_data The library dialog. */ -static void -library_window_callback_filter_button_clicked (GtkButton * button, - gpointer user_data) +static void library_window_callback_filter_button_clicked(GtkButton * button, gpointer user_data) { - GhidLibraryWindow *library_window = GHID_LIBRARY_WINDOW (user_data); + GhidLibraryWindow *library_window = GHID_LIBRARY_WINDOW(user_data); - /* clears text in text entry for filter */ - gtk_entry_set_text (library_window->entry_filter, ""); + /* clears text in text entry for filter */ + gtk_entry_set_text(library_window->entry_filter, ""); } @@ -606,68 +560,55 @@ * Creates a tree where the branches are the available library * sources and the leaves are the footprints. */ -static GtkTreeModel * -create_lib_tree_model (GhidLibraryWindow * library_window) +static GtkTreeModel *create_lib_tree_model(GhidLibraryWindow * library_window) { - GtkTreeStore *tree; - GtkTreeIter iter, p_iter, e_iter, c_iter; - gchar *name; - gboolean exists; + GtkTreeStore *tree; + GtkTreeIter iter, p_iter, e_iter, c_iter; + gchar *name; + gboolean exists; - tree = gtk_tree_store_new (N_MENU_COLUMNS, - G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_POINTER); + tree = gtk_tree_store_new(N_MENU_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_POINTER); - MENU_LOOP (&Library); - { - /* Watch for directory changes of library parts and create new - | parent iter at each change. - */ - if (!menu->directory) /* Shouldn't happen */ - menu->directory = g_strdup ("???"); - - exists = FALSE; - if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (tree), &e_iter)) - do + MENU_LOOP(&Library); { - gtk_tree_model_get (GTK_TREE_MODEL (tree), &e_iter, - MENU_NAME_COLUMN, &name, -1); - if (!strcmp (name, menu->directory)) - { - exists = TRUE; - break; - } - } - while (gtk_tree_model_iter_next (GTK_TREE_MODEL (tree), &e_iter)); + /* Watch for directory changes of library parts and create new + | parent iter at each change. + */ + if (!menu->directory) /* Shouldn't happen */ + menu->directory = g_strdup("???"); - if (exists) - p_iter = e_iter; - else - { - gtk_tree_store_append (tree, &p_iter, NULL); - gtk_tree_store_set (tree, &p_iter, - MENU_NAME_COLUMN, menu->directory, - MENU_LIBRARY_COLUMN, NULL, - MENU_ENTRY_COLUMN, NULL, -1); - } - gtk_tree_store_append (tree, &iter, &p_iter); - gtk_tree_store_set (tree, &iter, - MENU_NAME_COLUMN, menu->Name, - MENU_LIBRARY_COLUMN, menu, - MENU_ENTRY_COLUMN, NULL, -1); - ENTRY_LOOP (menu); - { - gtk_tree_store_append (tree, &c_iter, &iter); - gtk_tree_store_set (tree, &c_iter, - MENU_NAME_COLUMN, entry->ListEntry, - MENU_LIBRARY_COLUMN, menu, - MENU_ENTRY_COLUMN, entry, -1); - } - END_LOOP; + exists = FALSE; + if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(tree), &e_iter)) + do { + gtk_tree_model_get(GTK_TREE_MODEL(tree), &e_iter, MENU_NAME_COLUMN, &name, -1); + if (!strcmp(name, menu->directory)) { + exists = TRUE; + break; + } + } + while (gtk_tree_model_iter_next(GTK_TREE_MODEL(tree), &e_iter)); - } - END_LOOP; + if (exists) + p_iter = e_iter; + else { + gtk_tree_store_append(tree, &p_iter, NULL); + gtk_tree_store_set(tree, &p_iter, + MENU_NAME_COLUMN, menu->directory, MENU_LIBRARY_COLUMN, NULL, MENU_ENTRY_COLUMN, NULL, -1); + } + gtk_tree_store_append(tree, &iter, &p_iter); + gtk_tree_store_set(tree, &iter, MENU_NAME_COLUMN, menu->Name, MENU_LIBRARY_COLUMN, menu, MENU_ENTRY_COLUMN, NULL, -1); + ENTRY_LOOP(menu); + { + gtk_tree_store_append(tree, &c_iter, &iter); + gtk_tree_store_set(tree, &c_iter, + MENU_NAME_COLUMN, entry->ListEntry, MENU_LIBRARY_COLUMN, menu, MENU_ENTRY_COLUMN, entry, -1); + } + END_LOOP; - return (GtkTreeModel *) tree; + } + END_LOOP; + + return (GtkTreeModel *) tree; } @@ -677,345 +618,283 @@ * Requests a rescan of the footprint library in order to pick up any * new signals, and then updates the library window. */ -static void -library_window_callback_refresh_library (GtkButton * button, - gpointer user_data) +static void library_window_callback_refresh_library(GtkButton * button, gpointer user_data) { - GhidLibraryWindow *library_window = GHID_LIBRARY_WINDOW (user_data); - GtkTreeModel *model; + GhidLibraryWindow *library_window = GHID_LIBRARY_WINDOW(user_data); + GtkTreeModel *model; - /* Rescan the libraries for symbols */ - /* TODO: How do we do this in PCB? */ + /* Rescan the libraries for symbols */ + /* TODO: How do we do this in PCB? */ - /* Refresh the "Library" view */ - model = (GtkTreeModel *) - g_object_new (GTK_TYPE_TREE_MODEL_FILTER, - "child-model", create_lib_tree_model (library_window), - "virtual-root", NULL, NULL); + /* Refresh the "Library" view */ + model = (GtkTreeModel *) + g_object_new(GTK_TYPE_TREE_MODEL_FILTER, "child-model", create_lib_tree_model(library_window), "virtual-root", NULL, NULL); - gtk_tree_model_filter_set_visible_func ((GtkTreeModelFilter *) model, - lib_model_filter_visible_func, - library_window, NULL); + gtk_tree_model_filter_set_visible_func((GtkTreeModelFilter *) model, lib_model_filter_visible_func, library_window, NULL); - gtk_tree_view_set_model (library_window->libtreeview, model); + gtk_tree_view_set_model(library_window->libtreeview, model); } #endif /*! \brief Creates the treeview for the "Library" view */ -static GtkWidget * -create_lib_treeview (GhidLibraryWindow * library_window) +static GtkWidget *create_lib_treeview(GhidLibraryWindow * library_window) { - GtkWidget *libtreeview, *vbox, *scrolled_win, *label, - *hbox, *entry, *button; - GtkTreeModel *child_model, *model; - GtkTreeSelection *selection; - GtkCellRenderer *renderer; - GtkTreeViewColumn *column; + GtkWidget *libtreeview, *vbox, *scrolled_win, *label, *hbox, *entry, *button; + GtkTreeModel *child_model, *model; + GtkTreeSelection *selection; + GtkCellRenderer *renderer; + GtkTreeViewColumn *column; - /* -- library selection view -- */ + /* -- library selection view -- */ - /* vertical box for footprint selection and search entry */ - vbox = GTK_WIDGET (g_object_new (GTK_TYPE_VBOX, - /* GtkContainer */ - "border-width", 5, - /* GtkBox */ - "homogeneous", FALSE, "spacing", 5, NULL)); + /* vertical box for footprint selection and search entry */ + vbox = GTK_WIDGET(g_object_new(GTK_TYPE_VBOX, + /* GtkContainer */ + "border-width", 5, + /* GtkBox */ + "homogeneous", FALSE, "spacing", 5, NULL)); - child_model = create_lib_tree_model (library_window); - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (child_model), - MENU_NAME_COLUMN, GTK_SORT_ASCENDING); - model = (GtkTreeModel *) g_object_new (GTK_TYPE_TREE_MODEL_FILTER, - "child-model", child_model, - "virtual-root", NULL, NULL); + child_model = create_lib_tree_model(library_window); + gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(child_model), MENU_NAME_COLUMN, GTK_SORT_ASCENDING); + model = (GtkTreeModel *) g_object_new(GTK_TYPE_TREE_MODEL_FILTER, "child-model", child_model, "virtual-root", NULL, NULL); - scrolled_win = GTK_WIDGET (g_object_new (GTK_TYPE_SCROLLED_WINDOW, - /* GtkScrolledWindow */ - "hscrollbar-policy", - GTK_POLICY_AUTOMATIC, - "vscrollbar-policy", - GTK_POLICY_ALWAYS, "shadow-type", - GTK_SHADOW_ETCHED_IN, NULL)); - /* create the treeview */ - libtreeview = GTK_WIDGET (g_object_new (GTK_TYPE_TREE_VIEW, - /* GtkTreeView */ - "model", model, - "rules-hint", TRUE, - "headers-visible", FALSE, NULL)); + scrolled_win = GTK_WIDGET(g_object_new(GTK_TYPE_SCROLLED_WINDOW, + /* GtkScrolledWindow */ + "hscrollbar-policy", + GTK_POLICY_AUTOMATIC, + "vscrollbar-policy", GTK_POLICY_ALWAYS, "shadow-type", GTK_SHADOW_ETCHED_IN, NULL)); + /* create the treeview */ + libtreeview = GTK_WIDGET(g_object_new(GTK_TYPE_TREE_VIEW, + /* GtkTreeView */ + "model", model, "rules-hint", TRUE, "headers-visible", FALSE, NULL)); - g_signal_connect (libtreeview, - "row-activated", - G_CALLBACK (tree_row_activated), - NULL); + g_signal_connect(libtreeview, "row-activated", G_CALLBACK(tree_row_activated), NULL); - g_signal_connect (libtreeview, - "key-press-event", - G_CALLBACK (tree_row_key_pressed), - NULL); + g_signal_connect(libtreeview, "key-press-event", G_CALLBACK(tree_row_key_pressed), NULL); - /* connect callback to selection */ - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (libtreeview)); - gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); - g_signal_connect (selection, - "changed", - G_CALLBACK - (library_window_callback_tree_selection_changed), - library_window); + /* connect callback to selection */ + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(libtreeview)); + gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); + g_signal_connect(selection, "changed", G_CALLBACK(library_window_callback_tree_selection_changed), library_window); - /* insert a column to treeview for library/symbol name */ - renderer = GTK_CELL_RENDERER (g_object_new (GTK_TYPE_CELL_RENDERER_TEXT, - /* GtkCellRendererText */ - "editable", FALSE, NULL)); - column = GTK_TREE_VIEW_COLUMN (g_object_new (GTK_TYPE_TREE_VIEW_COLUMN, - /* GtkTreeViewColumn */ - "title", _("Components"), - NULL)); - gtk_tree_view_column_pack_start (column, renderer, TRUE); - gtk_tree_view_column_set_attributes (column, renderer, - "text", MENU_NAME_COLUMN, NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (libtreeview), column); + /* insert a column to treeview for library/symbol name */ + renderer = GTK_CELL_RENDERER(g_object_new(GTK_TYPE_CELL_RENDERER_TEXT, + /* GtkCellRendererText */ + "editable", FALSE, NULL)); + column = GTK_TREE_VIEW_COLUMN(g_object_new(GTK_TYPE_TREE_VIEW_COLUMN, + /* GtkTreeViewColumn */ + "title", _("Components"), NULL)); + gtk_tree_view_column_pack_start(column, renderer, TRUE); + gtk_tree_view_column_set_attributes(column, renderer, "text", MENU_NAME_COLUMN, NULL); + gtk_tree_view_append_column(GTK_TREE_VIEW(libtreeview), column); - /* add the treeview to the scrolled window */ - gtk_container_add (GTK_CONTAINER (scrolled_win), libtreeview); - /* set directory/footprint treeview of library_window */ - library_window->libtreeview = GTK_TREE_VIEW (libtreeview); + /* add the treeview to the scrolled window */ + gtk_container_add(GTK_CONTAINER(scrolled_win), libtreeview); + /* set directory/footprint treeview of library_window */ + library_window->libtreeview = GTK_TREE_VIEW(libtreeview); - /* add the scrolled window for directories to the vertical box */ - gtk_box_pack_start (GTK_BOX (vbox), scrolled_win, TRUE, TRUE, 0); + /* add the scrolled window for directories to the vertical box */ + gtk_box_pack_start(GTK_BOX(vbox), scrolled_win, TRUE, TRUE, 0); - /* -- filter area -- */ - hbox = GTK_WIDGET (g_object_new (GTK_TYPE_HBOX, - /* GtkBox */ - "homogeneous", FALSE, "spacing", 3, NULL)); + /* -- filter area -- */ + hbox = GTK_WIDGET(g_object_new(GTK_TYPE_HBOX, + /* GtkBox */ + "homogeneous", FALSE, "spacing", 3, NULL)); - /* create the entry label */ - label = GTK_WIDGET (g_object_new (GTK_TYPE_LABEL, - /* GtkMisc */ - "xalign", 0.0, - /* GtkLabel */ - "label", _("Filter:"), NULL)); - /* add the search label to the filter area */ - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + /* create the entry label */ + label = GTK_WIDGET(g_object_new(GTK_TYPE_LABEL, + /* GtkMisc */ + "xalign", 0.0, + /* GtkLabel */ + "label", _("Filter:"), NULL)); + /* add the search label to the filter area */ + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - /* create the text entry for filter in footprints */ - entry = GTK_WIDGET (g_object_new (GTK_TYPE_ENTRY, - /* GtkEntry */ - "text", "", NULL)); - g_signal_connect (entry, - "changed", - G_CALLBACK (library_window_callback_filter_entry_changed), - library_window); + /* create the text entry for filter in footprints */ + entry = GTK_WIDGET(g_object_new(GTK_TYPE_ENTRY, + /* GtkEntry */ + "text", "", NULL)); + g_signal_connect(entry, "changed", G_CALLBACK(library_window_callback_filter_entry_changed), library_window); - /* now that that we have an entry, set the filter func of model */ - gtk_tree_model_filter_set_visible_func ((GtkTreeModelFilter *) model, - lib_model_filter_visible_func, - library_window, NULL); + /* now that that we have an entry, set the filter func of model */ + gtk_tree_model_filter_set_visible_func((GtkTreeModelFilter *) model, lib_model_filter_visible_func, library_window, NULL); - /* add the filter entry to the filter area */ - gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0); - /* set filter entry of library_window */ - library_window->entry_filter = GTK_ENTRY (entry); - /* and init the event source for footprint filter */ - library_window->filter_timeout = 0; + /* add the filter entry to the filter area */ + gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0); + /* set filter entry of library_window */ + library_window->entry_filter = GTK_ENTRY(entry); + /* and init the event source for footprint filter */ + library_window->filter_timeout = 0; - /* create the erase button for filter entry */ - button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON, - /* GtkWidget */ - "sensitive", FALSE, - /* GtkButton */ - "relief", GTK_RELIEF_NONE, NULL)); + /* create the erase button for filter entry */ + button = GTK_WIDGET(g_object_new(GTK_TYPE_BUTTON, + /* GtkWidget */ + "sensitive", FALSE, + /* GtkButton */ + "relief", GTK_RELIEF_NONE, NULL)); - gtk_container_add (GTK_CONTAINER (button), - gtk_image_new_from_stock (GTK_STOCK_CLEAR, - GTK_ICON_SIZE_SMALL_TOOLBAR)); - g_signal_connect (button, - "clicked", - G_CALLBACK - (library_window_callback_filter_button_clicked), - library_window); - /* add the clear button to the filter area */ - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - /* set clear button of library_window */ - library_window->button_clear = GTK_BUTTON (button); + gtk_container_add(GTK_CONTAINER(button), gtk_image_new_from_stock(GTK_STOCK_CLEAR, GTK_ICON_SIZE_SMALL_TOOLBAR)); + g_signal_connect(button, "clicked", G_CALLBACK(library_window_callback_filter_button_clicked), library_window); + /* add the clear button to the filter area */ + gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); + /* set clear button of library_window */ + library_window->button_clear = GTK_BUTTON(button); #if 0 - /* create the refresh button */ - button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON, - /* GtkWidget */ - "sensitive", TRUE, - /* GtkButton */ - "relief", GTK_RELIEF_NONE, NULL)); - gtk_container_add (GTK_CONTAINER (button), - gtk_image_new_from_stock (GTK_STOCK_REFRESH, - GTK_ICON_SIZE_SMALL_TOOLBAR)); - /* add the refresh button to the filter area */ - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - g_signal_connect (button, - "clicked", - G_CALLBACK (library_window_callback_refresh_library), - library_window); + /* create the refresh button */ + button = GTK_WIDGET(g_object_new(GTK_TYPE_BUTTON, + /* GtkWidget */ + "sensitive", TRUE, + /* GtkButton */ + "relief", GTK_RELIEF_NONE, NULL)); + gtk_container_add(GTK_CONTAINER(button), gtk_image_new_from_stock(GTK_STOCK_REFRESH, GTK_ICON_SIZE_SMALL_TOOLBAR)); + /* add the refresh button to the filter area */ + gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); + g_signal_connect(button, "clicked", G_CALLBACK(library_window_callback_refresh_library), library_window); #endif - /* add the filter area to the vertical box */ - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + /* add the filter area to the vertical box */ + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - library_window->libtreeview = GTK_TREE_VIEW (libtreeview); + library_window->libtreeview = GTK_TREE_VIEW(libtreeview); - return vbox; + return vbox; } -static GObject * -library_window_constructor (GType type, - guint n_construct_properties, - GObjectConstructParam * construct_params) +static GObject *library_window_constructor(GType type, guint n_construct_properties, GObjectConstructParam * construct_params) { - GObject *object; - GhidLibraryWindow *library_window; - GtkWidget *content_area; - GtkWidget *hpaned, *notebook; - GtkWidget *libview; - GtkWidget *preview, *preview_text; - GtkWidget *alignment, *frame; + GObject *object; + GhidLibraryWindow *library_window; + GtkWidget *content_area; + GtkWidget *hpaned, *notebook; + GtkWidget *libview; + GtkWidget *preview, *preview_text; + GtkWidget *alignment, *frame; - /* chain up to constructor of parent class */ - object = G_OBJECT_CLASS (library_window_parent_class)-> - constructor (type, n_construct_properties, construct_params); - library_window = GHID_LIBRARY_WINDOW (object); + /* chain up to constructor of parent class */ + object = G_OBJECT_CLASS(library_window_parent_class)->constructor(type, n_construct_properties, construct_params); + library_window = GHID_LIBRARY_WINDOW(object); - /* dialog initialization */ - g_object_set (object, - /* GtkWindow */ - "type", GTK_WINDOW_TOPLEVEL, - "title", _("Select Footprint..."), - "default-height", 300, - "default-width", 400, - "modal", FALSE, "window-position", GTK_WIN_POS_NONE, - /* GtkDialog */ - "has-separator", TRUE, NULL); - g_object_set (gtk_dialog_get_content_area (GTK_DIALOG (library_window)), - "homogeneous", FALSE, NULL); + /* dialog initialization */ + g_object_set(object, + /* GtkWindow */ + "type", GTK_WINDOW_TOPLEVEL, + "title", _("Select Footprint..."), + "default-height", 300, "default-width", 400, "modal", FALSE, "window-position", GTK_WIN_POS_NONE, + /* GtkDialog */ + "has-separator", TRUE, NULL); + g_object_set(gtk_dialog_get_content_area(GTK_DIALOG(library_window)), "homogeneous", FALSE, NULL); - /* horizontal pane containing selection and preview */ - hpaned = GTK_WIDGET (g_object_new (GTK_TYPE_HPANED, - /* GtkContainer */ - "border-width", 5, NULL)); - library_window->hpaned = hpaned; + /* horizontal pane containing selection and preview */ + hpaned = GTK_WIDGET(g_object_new(GTK_TYPE_HPANED, + /* GtkContainer */ + "border-width", 5, NULL)); + library_window->hpaned = hpaned; - /* notebook for library views */ - notebook = GTK_WIDGET (g_object_new (GTK_TYPE_NOTEBOOK, - "show-tabs", FALSE, NULL)); - library_window->viewtabs = GTK_NOTEBOOK (notebook); + /* notebook for library views */ + notebook = GTK_WIDGET(g_object_new(GTK_TYPE_NOTEBOOK, "show-tabs", FALSE, NULL)); + library_window->viewtabs = GTK_NOTEBOOK(notebook); - libview = create_lib_treeview (library_window); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), libview, - gtk_label_new (_("Libraries"))); + libview = create_lib_treeview(library_window); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), libview, gtk_label_new(_("Libraries"))); - /* include the vertical box in horizontal box */ - gtk_paned_pack1 (GTK_PANED (hpaned), notebook, TRUE, FALSE); + /* include the vertical box in horizontal box */ + gtk_paned_pack1(GTK_PANED(hpaned), notebook, TRUE, FALSE); - /* -- preview area -- */ - frame = GTK_WIDGET (g_object_new (GTK_TYPE_FRAME, - /* GtkFrame */ - "label", _("Preview"), NULL)); - alignment = GTK_WIDGET (g_object_new (GTK_TYPE_ALIGNMENT, - /* GtkAlignment */ - "left-padding", 5, - "right-padding", 5, - "top-padding", 5, - "bottom-padding", 5, - "xscale", 1.0, - "yscale", 1.0, - "xalign", 0.5, "yalign", 0.5, NULL)); - preview = (GtkWidget *)g_object_new (GHID_TYPE_PINOUT_PREVIEW, - /* GhidPinoutPreview */ - "element-data", NULL, - /* GtkWidget */ - "width-request", 150, "height-request", 150, NULL); + /* -- preview area -- */ + frame = GTK_WIDGET(g_object_new(GTK_TYPE_FRAME, + /* GtkFrame */ + "label", _("Preview"), NULL)); + alignment = GTK_WIDGET(g_object_new(GTK_TYPE_ALIGNMENT, + /* GtkAlignment */ + "left-padding", 5, + "right-padding", 5, + "top-padding", 5, + "bottom-padding", 5, "xscale", 1.0, "yscale", 1.0, "xalign", 0.5, "yalign", 0.5, NULL)); + preview = (GtkWidget *) g_object_new(GHID_TYPE_PINOUT_PREVIEW, + /* GhidPinoutPreview */ + "element-data", NULL, + /* GtkWidget */ + "width-request", 150, "height-request", 150, NULL); - preview_text = gtk_label_new (""); + preview_text = gtk_label_new(""); { - GtkWidget *vbox = gtk_vbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), preview, TRUE, TRUE, 0); - gtk_box_pack_end (GTK_BOX (vbox), preview_text, FALSE, FALSE, 0); + GtkWidget *vbox = gtk_vbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), preview, TRUE, TRUE, 0); + gtk_box_pack_end(GTK_BOX(vbox), preview_text, FALSE, FALSE, 0); - gtk_container_add (GTK_CONTAINER (alignment), vbox); - gtk_container_add (GTK_CONTAINER (frame), alignment); + gtk_container_add(GTK_CONTAINER(alignment), vbox); + gtk_container_add(GTK_CONTAINER(frame), alignment); } - /* set preview of library_window */ - library_window->preview = preview; - library_window->preview_text = preview_text; + /* set preview of library_window */ + library_window->preview = preview; + library_window->preview_text = preview_text; - gtk_paned_pack2 (GTK_PANED (hpaned), frame, FALSE, FALSE); + gtk_paned_pack2(GTK_PANED(hpaned), frame, FALSE, FALSE); - /* add the hpaned to the dialog content area */ - content_area = gtk_dialog_get_content_area (GTK_DIALOG (library_window)); - gtk_box_pack_start (GTK_BOX (content_area), hpaned, TRUE, TRUE, 0); - gtk_widget_show_all (hpaned); + /* add the hpaned to the dialog content area */ + content_area = gtk_dialog_get_content_area(GTK_DIALOG(library_window)); + gtk_box_pack_start(GTK_BOX(content_area), hpaned, TRUE, TRUE, 0); + gtk_widget_show_all(hpaned); - /* now add buttons in the action area */ - gtk_dialog_add_buttons (GTK_DIALOG (library_window), - /* - close button */ - GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); + /* now add buttons in the action area */ + gtk_dialog_add_buttons(GTK_DIALOG(library_window), + /* - close button */ + GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); - return object; + return object; } -static void -library_window_finalize (GObject * object) +static void library_window_finalize(GObject * object) { - GhidLibraryWindow *library_window = GHID_LIBRARY_WINDOW (object); + GhidLibraryWindow *library_window = GHID_LIBRARY_WINDOW(object); - if (library_window->filter_timeout != 0) - { - g_source_remove (library_window->filter_timeout); - library_window->filter_timeout = 0; - } + if (library_window->filter_timeout != 0) { + g_source_remove(library_window->filter_timeout); + library_window->filter_timeout = 0; + } - G_OBJECT_CLASS (library_window_parent_class)->finalize (object); + G_OBJECT_CLASS(library_window_parent_class)->finalize(object); } -static void -library_window_class_init (GhidLibraryWindowClass * klass) +static void library_window_class_init(GhidLibraryWindowClass * klass) { - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - gobject_class->constructor = library_window_constructor; - gobject_class->finalize = library_window_finalize; + gobject_class->constructor = library_window_constructor; + gobject_class->finalize = library_window_finalize; - library_window_parent_class = (GObjectClass *)g_type_class_peek_parent (klass); + library_window_parent_class = (GObjectClass *) g_type_class_peek_parent(klass); } -GType -ghid_library_window_get_type () +GType ghid_library_window_get_type() { - static GType library_window_type = 0; + static GType library_window_type = 0; - if (!library_window_type) - { - static const GTypeInfo library_window_info = { - sizeof (GhidLibraryWindowClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) library_window_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GhidLibraryWindow), - 0, /* n_preallocs */ - NULL /* instance_init */ - }; + if (!library_window_type) { + static const GTypeInfo library_window_info = { + sizeof(GhidLibraryWindowClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) library_window_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(GhidLibraryWindow), + 0, /* n_preallocs */ + NULL /* instance_init */ + }; - library_window_type = g_type_register_static (GTK_TYPE_DIALOG, - "GhidLibraryWindow", - &library_window_info, (GTypeFlags)0); - } + library_window_type = g_type_register_static(GTK_TYPE_DIALOG, "GhidLibraryWindow", &library_window_info, (GTypeFlags) 0); + } - return library_window_type; + return library_window_type; } Index: trunk/src/hid/gtk/gui-library-window.h =================================================================== --- trunk/src/hid/gtk/gui-library-window.h (revision 1021) +++ trunk/src/hid/gtk/gui-library-window.h (revision 1022) @@ -36,26 +36,24 @@ typedef struct _GhidLibraryWindow GhidLibraryWindow; -struct _GhidLibraryWindowClass -{ - GtkDialogClass parent_class; +struct _GhidLibraryWindowClass { + GtkDialogClass parent_class; }; -struct _GhidLibraryWindow -{ - GtkDialog parent_instance; +struct _GhidLibraryWindow { + GtkDialog parent_instance; - GtkWidget *hpaned; - GtkTreeView *libtreeview; - GtkNotebook *viewtabs; - GtkWidget *preview; - GtkWidget *preview_text; - GtkEntry *entry_filter; - GtkButton *button_clear; - guint filter_timeout; + GtkWidget *hpaned; + GtkTreeView *libtreeview; + GtkNotebook *viewtabs; + GtkWidget *preview; + GtkWidget *preview_text; + GtkEntry *entry_filter; + GtkButton *button_clear; + guint filter_timeout; }; -GType ghid_library_window_get_type (void); +GType ghid_library_window_get_type(void); #endif /* PCB_HID_GTK_GUI_LIBRARY_WINDOW_H */ Index: trunk/src/hid/gtk/gui-log-window.c =================================================================== --- trunk/src/hid/gtk/gui-log-window.c (revision 1021) +++ trunk/src/hid/gtk/gui-log-window.c (revision 1022) @@ -38,143 +38,122 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); static GtkWidget *log_window, *log_text; static gboolean log_show_on_append = FALSE; /* Remember user window resizes. */ -static gint -log_window_configure_event_cb (GtkWidget * widget, - GdkEventConfigure * ev, gpointer data) +static gint log_window_configure_event_cb(GtkWidget * widget, GdkEventConfigure * ev, gpointer data) { - GtkAllocation allocation; + GtkAllocation allocation; - gtk_widget_get_allocation (widget, &allocation); - ghidgui->log_window_width = allocation.width; - ghidgui->log_window_height = allocation.height; - ghidgui->config_modified = TRUE; + gtk_widget_get_allocation(widget, &allocation); + ghidgui->log_window_width = allocation.width; + ghidgui->log_window_height = allocation.height; + ghidgui->config_modified = TRUE; - return FALSE; + return FALSE; } -static void -log_close_cb (gpointer data) +static void log_close_cb(gpointer data) { - gtk_widget_destroy (log_window); - log_window = NULL; + gtk_widget_destroy(log_window); + log_window = NULL; } -static void -log_destroy_cb (GtkWidget * widget, gpointer data) +static void log_destroy_cb(GtkWidget * widget, gpointer data) { - log_window = NULL; + log_window = NULL; } -void -ghid_log_window_create () +void ghid_log_window_create() { - GtkWidget *vbox, *hbox, *button; + GtkWidget *vbox, *hbox, *button; - if (log_window) - return; + if (log_window) + return; - log_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - g_signal_connect (G_OBJECT (log_window), "destroy", - G_CALLBACK (log_destroy_cb), NULL); - g_signal_connect (G_OBJECT (log_window), "configure_event", - G_CALLBACK (log_window_configure_event_cb), NULL); - gtk_window_set_title (GTK_WINDOW (log_window), _("PCB Log")); - gtk_window_set_wmclass (GTK_WINDOW (log_window), "PCB_Log", "PCB"); - gtk_window_set_default_size (GTK_WINDOW (log_window), - ghidgui->log_window_width, - ghidgui->log_window_height); + log_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + g_signal_connect(G_OBJECT(log_window), "destroy", G_CALLBACK(log_destroy_cb), NULL); + g_signal_connect(G_OBJECT(log_window), "configure_event", G_CALLBACK(log_window_configure_event_cb), NULL); + gtk_window_set_title(GTK_WINDOW(log_window), _("PCB Log")); + gtk_window_set_wmclass(GTK_WINDOW(log_window), "PCB_Log", "PCB"); + gtk_window_set_default_size(GTK_WINDOW(log_window), ghidgui->log_window_width, ghidgui->log_window_height); - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); - gtk_container_add (GTK_CONTAINER (log_window), vbox); + vbox = gtk_vbox_new(FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); + gtk_container_add(GTK_CONTAINER(log_window), vbox); - log_text = ghid_scrolled_text_view (vbox, NULL, - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); + log_text = 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 (log_close_cb), NULL); - gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); + 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(log_close_cb), NULL); + gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); - gtk_widget_realize (log_window); - if (Settings.AutoPlace) - gtk_window_move (GTK_WINDOW (log_window), 10, 10); + gtk_widget_realize(log_window); + if (Settings.AutoPlace) + gtk_window_move(GTK_WINDOW(log_window), 10, 10); } -void -ghid_log_window_show (gboolean raise) +void ghid_log_window_show(gboolean raise) { - ghid_log_window_create (); - gtk_widget_show_all (log_window); - if (raise) - gtk_window_present (GTK_WINDOW(log_window)); + ghid_log_window_create(); + gtk_widget_show_all(log_window); + if (raise) + gtk_window_present(GTK_WINDOW(log_window)); } -static void -ghid_log_append_string (gchar * s) +static void ghid_log_append_string(gchar * s) { - if (log_show_on_append) - ghid_log_window_show(FALSE); - else - ghid_log_window_create (); - ghid_text_view_append (log_text, s); + if (log_show_on_append) + ghid_log_window_show(FALSE); + else + ghid_log_window_create(); + ghid_text_view_append(log_text, s); } -void -ghid_log (const char *fmt, ...) +void ghid_log(const char *fmt, ...) { - va_list ap; - va_start (ap, fmt); - ghid_logv (fmt, ap); - va_end (ap); + va_list ap; + va_start(ap, fmt); + ghid_logv(fmt, ap); + va_end(ap); } -void -ghid_logv (const char *fmt, va_list args) +void ghid_logv(const char *fmt, va_list args) { - gchar *msg = pcb_vprintf (fmt, args); - ghid_log_append_string (msg); - g_free (msg); + gchar *msg = pcb_vprintf(fmt, args); + ghid_log_append_string(msg); + g_free(msg); } -static const char logshowonappend_syntax[] = - "LogShowOnAppend(true|false)"; +static const char logshowonappend_syntax[] = "LogShowOnAppend(true|false)"; -static const char logshowonappend_help[] = - "If true, the log window will be shown whenever something is appended \ +static const char logshowonappend_help[] = "If true, the log window will be shown whenever something is appended \ to it. If false, the log will still be updated, but the window won't \ be shown."; -static gint -GhidLogShowOnAppend (int argc, char **argv, Coord x, Coord y) +static gint GhidLogShowOnAppend(int argc, char **argv, Coord x, Coord y) { - char *a = argc == 1 ? argv[0] : (char *)""; + char *a = argc == 1 ? argv[0] : (char *) ""; - if (strncasecmp(a, "t", 1) == 0) - { - log_show_on_append = TRUE; - } - else if (strncasecmp(a, "f", 1) == 0) - { - log_show_on_append = FALSE; - } - return 0; + if (strncasecmp(a, "t", 1) == 0) { + log_show_on_append = TRUE; + } + else if (strncasecmp(a, "f", 1) == 0) { + log_show_on_append = FALSE; + } + return 0; } HID_Action ghid_log_action_list[] = { - {"LogShowOnAppend", 0, GhidLogShowOnAppend, - logshowonappend_help, logshowonappend_syntax} - , + {"LogShowOnAppend", 0, GhidLogShowOnAppend, + logshowonappend_help, logshowonappend_syntax} + , }; -REGISTER_ACTIONS (ghid_log_action_list) +REGISTER_ACTIONS(ghid_log_action_list) Index: trunk/src/hid/gtk/gui-misc.c =================================================================== --- trunk/src/hid/gtk/gui-misc.c (revision 1021) +++ trunk/src/hid/gtk/gui-misc.c (revision 1022) @@ -41,7 +41,7 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); #define CUSTOM_CURSOR_CLOCKWISE (GDK_LAST_CURSOR + 10) #define CUSTOM_CURSOR_DRAG (GDK_LAST_CURSOR + 11) @@ -51,408 +51,355 @@ #define ICON_Y_HOT 8 -GdkPixmap *XC_clock_source, *XC_clock_mask, - *XC_hand_source, *XC_hand_mask, *XC_lock_source, *XC_lock_mask; +GdkPixmap *XC_clock_source, *XC_clock_mask, *XC_hand_source, *XC_hand_mask, *XC_lock_source, *XC_lock_mask; static GdkCursorType oldCursor; -void -ghid_status_line_set_text (const gchar * text) +void ghid_status_line_set_text(const gchar * text) { - if (ghidgui->command_entry_status_line_active) - return; + if (ghidgui->command_entry_status_line_active) + return; - ghid_label_set_markup (ghidgui->status_line_label, text); + ghid_label_set_markup(ghidgui->status_line_label, text); } -void -ghid_cursor_position_label_set_text (gchar * text) +void ghid_cursor_position_label_set_text(gchar * text) { - ghid_label_set_markup (ghidgui->cursor_position_absolute_label, text); + ghid_label_set_markup(ghidgui->cursor_position_absolute_label, text); } -void -ghid_cursor_position_relative_label_set_text (gchar * text) +void ghid_cursor_position_relative_label_set_text(gchar * text) { - ghid_label_set_markup (ghidgui->cursor_position_relative_label, text); + ghid_label_set_markup(ghidgui->cursor_position_relative_label, text); } -static GdkCursorType -gport_set_cursor (GdkCursorType shape) +static GdkCursorType gport_set_cursor(GdkCursorType shape) { - GdkWindow *window; - GdkCursorType old_shape = gport->X_cursor_shape; - GdkColor fg = { 0, 65535, 65535, 65535 }; /* white */ - GdkColor bg = { 0, 0, 0, 0 }; /* black */ + GdkWindow *window; + GdkCursorType old_shape = gport->X_cursor_shape; + GdkColor fg = { 0, 65535, 65535, 65535 }; /* white */ + GdkColor bg = { 0, 0, 0, 0 }; /* black */ - if (gport->drawing_area == NULL) - return GDK_X_CURSOR; + if (gport->drawing_area == NULL) + return GDK_X_CURSOR; - window = gtk_widget_get_window (gport->drawing_area); + window = gtk_widget_get_window(gport->drawing_area); - if (gport->X_cursor_shape == shape) - return shape; + if (gport->X_cursor_shape == shape) + return shape; - /* check if window exists to prevent from fatal errors */ - if (window == NULL) - return GDK_X_CURSOR; + /* check if window exists to prevent from fatal errors */ + if (window == NULL) + return GDK_X_CURSOR; - gport->X_cursor_shape = shape; - if (shape > GDK_LAST_CURSOR) - { - if (shape == CUSTOM_CURSOR_CLOCKWISE) - gport->X_cursor = - gdk_cursor_new_from_pixmap (XC_clock_source, XC_clock_mask, &fg, - &bg, ICON_X_HOT, ICON_Y_HOT); - else if (shape == CUSTOM_CURSOR_DRAG) - gport->X_cursor = - gdk_cursor_new_from_pixmap (XC_hand_source, XC_hand_mask, &fg, - &bg, ICON_X_HOT, ICON_Y_HOT); - else if (shape == CUSTOM_CURSOR_LOCK) - gport->X_cursor = - gdk_cursor_new_from_pixmap (XC_lock_source, XC_lock_mask, &fg, - &bg, ICON_X_HOT, ICON_Y_HOT); - } - else - gport->X_cursor = gdk_cursor_new (shape); + gport->X_cursor_shape = shape; + if (shape > GDK_LAST_CURSOR) { + if (shape == CUSTOM_CURSOR_CLOCKWISE) + gport->X_cursor = gdk_cursor_new_from_pixmap(XC_clock_source, XC_clock_mask, &fg, &bg, ICON_X_HOT, ICON_Y_HOT); + else if (shape == CUSTOM_CURSOR_DRAG) + gport->X_cursor = gdk_cursor_new_from_pixmap(XC_hand_source, XC_hand_mask, &fg, &bg, ICON_X_HOT, ICON_Y_HOT); + else if (shape == CUSTOM_CURSOR_LOCK) + gport->X_cursor = gdk_cursor_new_from_pixmap(XC_lock_source, XC_lock_mask, &fg, &bg, ICON_X_HOT, ICON_Y_HOT); + } + else + gport->X_cursor = gdk_cursor_new(shape); - gdk_window_set_cursor (window, gport->X_cursor); - gdk_cursor_unref (gport->X_cursor); + gdk_window_set_cursor(window, gport->X_cursor); + gdk_cursor_unref(gport->X_cursor); - return old_shape; + return old_shape; } -void -ghid_point_cursor (void) +void ghid_point_cursor(void) { - oldCursor = gport_set_cursor (GDK_DRAPED_BOX); + oldCursor = gport_set_cursor(GDK_DRAPED_BOX); } -void -ghid_hand_cursor (void) +void ghid_hand_cursor(void) { - oldCursor = gport_set_cursor (GDK_HAND2); + oldCursor = gport_set_cursor(GDK_HAND2); } -void -ghid_watch_cursor (void) +void ghid_watch_cursor(void) { - GdkCursorType tmp; + GdkCursorType tmp; - tmp = gport_set_cursor (GDK_WATCH); - if (tmp != GDK_WATCH) - oldCursor = tmp; + tmp = gport_set_cursor(GDK_WATCH); + if (tmp != GDK_WATCH) + oldCursor = tmp; } -void -ghid_mode_cursor (int Mode) +void ghid_mode_cursor(int Mode) { - switch (Mode) - { - case NO_MODE: - gport_set_cursor ((GdkCursorType)CUSTOM_CURSOR_DRAG); - break; + switch (Mode) { + case NO_MODE: + gport_set_cursor((GdkCursorType) CUSTOM_CURSOR_DRAG); + break; - case VIA_MODE: - gport_set_cursor (GDK_ARROW); - break; + case VIA_MODE: + gport_set_cursor(GDK_ARROW); + break; - case LINE_MODE: - gport_set_cursor (GDK_PENCIL); - break; + case LINE_MODE: + gport_set_cursor(GDK_PENCIL); + break; - case ARC_MODE: - gport_set_cursor (GDK_QUESTION_ARROW); - break; + case ARC_MODE: + gport_set_cursor(GDK_QUESTION_ARROW); + break; - case ARROW_MODE: - gport_set_cursor (GDK_LEFT_PTR); - break; + case ARROW_MODE: + gport_set_cursor(GDK_LEFT_PTR); + break; - case POLYGON_MODE: - case POLYGONHOLE_MODE: - gport_set_cursor (GDK_SB_UP_ARROW); - break; + case POLYGON_MODE: + case POLYGONHOLE_MODE: + gport_set_cursor(GDK_SB_UP_ARROW); + break; - case PASTEBUFFER_MODE: - gport_set_cursor (GDK_HAND1); - break; + case PASTEBUFFER_MODE: + gport_set_cursor(GDK_HAND1); + break; - case TEXT_MODE: - gport_set_cursor (GDK_XTERM); - break; + case TEXT_MODE: + gport_set_cursor(GDK_XTERM); + break; - case RECTANGLE_MODE: - gport_set_cursor (GDK_UL_ANGLE); - break; + case RECTANGLE_MODE: + gport_set_cursor(GDK_UL_ANGLE); + break; - case THERMAL_MODE: - gport_set_cursor (GDK_IRON_CROSS); - break; + case THERMAL_MODE: + gport_set_cursor(GDK_IRON_CROSS); + break; - case REMOVE_MODE: - gport_set_cursor (GDK_PIRATE); - break; + case REMOVE_MODE: + gport_set_cursor(GDK_PIRATE); + break; - case ROTATE_MODE: - if (ghid_shift_is_pressed ()) - gport_set_cursor ((GdkCursorType)CUSTOM_CURSOR_CLOCKWISE); - else - gport_set_cursor (GDK_EXCHANGE); - break; + case ROTATE_MODE: + if (ghid_shift_is_pressed()) + gport_set_cursor((GdkCursorType) CUSTOM_CURSOR_CLOCKWISE); + else + gport_set_cursor(GDK_EXCHANGE); + break; - case COPY_MODE: - case MOVE_MODE: - gport_set_cursor (GDK_CROSSHAIR); - break; + case COPY_MODE: + case MOVE_MODE: + gport_set_cursor(GDK_CROSSHAIR); + break; - case INSERTPOINT_MODE: - gport_set_cursor (GDK_DOTBOX); - break; + case INSERTPOINT_MODE: + gport_set_cursor(GDK_DOTBOX); + break; - case LOCK_MODE: - gport_set_cursor ((GdkCursorType)CUSTOM_CURSOR_LOCK); - } + case LOCK_MODE: + gport_set_cursor((GdkCursorType) CUSTOM_CURSOR_LOCK); + } } -void -ghid_corner_cursor (void) +void ghid_corner_cursor(void) { - GdkCursorType shape; + GdkCursorType shape; - if (Crosshair.Y <= Crosshair.AttachedBox.Point1.Y) - shape = (Crosshair.X >= Crosshair.AttachedBox.Point1.X) ? - GDK_UR_ANGLE : GDK_UL_ANGLE; - else - shape = (Crosshair.X >= Crosshair.AttachedBox.Point1.X) ? - GDK_LR_ANGLE : GDK_LL_ANGLE; - if (gport->X_cursor_shape != shape) - gport_set_cursor (shape); + if (Crosshair.Y <= Crosshair.AttachedBox.Point1.Y) + shape = (Crosshair.X >= Crosshair.AttachedBox.Point1.X) ? GDK_UR_ANGLE : GDK_UL_ANGLE; + else + shape = (Crosshair.X >= Crosshair.AttachedBox.Point1.X) ? GDK_LR_ANGLE : GDK_LL_ANGLE; + if (gport->X_cursor_shape != shape) + gport_set_cursor(shape); } -void -ghid_restore_cursor (void) +void ghid_restore_cursor(void) { - gport_set_cursor (oldCursor); + gport_set_cursor(oldCursor); } - /* =============================================================== */ + /* =============================================================== */ static gboolean got_location; - /* If user hits a key instead of the mouse button, we'll abort unless - | it's the enter key (which accepts the current crosshair location). - */ -static gboolean -loop_key_press_cb (GtkWidget * drawing_area, GdkEventKey * kev, - GMainLoop ** loop) + /* If user hits a key instead of the mouse button, we'll abort unless + | it's the enter key (which accepts the current crosshair location). + */ +static gboolean loop_key_press_cb(GtkWidget * drawing_area, GdkEventKey * kev, GMainLoop ** loop) { - gint ksym = kev->keyval; + gint ksym = kev->keyval; - if (ghid_is_modifier_key_sym (ksym)) - return TRUE; + if (ghid_is_modifier_key_sym(ksym)) + return TRUE; - switch (ksym) - { - case GDK_Return: /* Accept cursor location */ - if (g_main_loop_is_running (*loop)) - g_main_loop_quit (*loop); - break; + switch (ksym) { + case GDK_Return: /* Accept cursor location */ + if (g_main_loop_is_running(*loop)) + g_main_loop_quit(*loop); + break; - default: /* Abort */ - got_location = FALSE; - if (g_main_loop_is_running (*loop)) - g_main_loop_quit (*loop); - break; - } - return TRUE; + default: /* Abort */ + got_location = FALSE; + if (g_main_loop_is_running(*loop)) + g_main_loop_quit(*loop); + break; + } + return TRUE; } - /* User hit a mouse button in the Output drawing area, so quit the loop - | and the cursor values when the button was pressed will be used. - */ -static gboolean -loop_button_press_cb (GtkWidget * drawing_area, GdkEventButton * ev, - GMainLoop ** loop) + /* User hit a mouse button in the Output drawing area, so quit the loop + | and the cursor values when the button was pressed will be used. + */ +static gboolean loop_button_press_cb(GtkWidget * drawing_area, GdkEventButton * ev, GMainLoop ** loop) { - if (g_main_loop_is_running (*loop)) - g_main_loop_quit (*loop); - ghid_note_event_location (ev); - return TRUE; + if (g_main_loop_is_running(*loop)) + g_main_loop_quit(*loop); + ghid_note_event_location(ev); + return TRUE; } - /* Run a glib GMainLoop which intercepts key and mouse button events from - | the top level loop. When a mouse or key is hit in the Output drawing - | area, quit the loop so the top level loop can continue and use the - | the mouse pointer coordinates at the time of the mouse button event. - */ -static gboolean -run_get_location_loop (const gchar * message) + /* Run a glib GMainLoop which intercepts key and mouse button events from + | the top level loop. When a mouse or key is hit in the Output drawing + | area, quit the loop so the top level loop can continue and use the + | the mouse pointer coordinates at the time of the mouse button event. + */ +static gboolean run_get_location_loop(const gchar * message) { - GMainLoop *loop; - gulong button_handler, key_handler; - gint oldObjState, oldLineState, oldBoxState; + GMainLoop *loop; + gulong button_handler, key_handler; + gint oldObjState, oldLineState, oldBoxState; - ghid_status_line_set_text (message); + ghid_status_line_set_text(message); - oldObjState = Crosshair.AttachedObject.State; - oldLineState = Crosshair.AttachedLine.State; - oldBoxState = Crosshair.AttachedBox.State; - notify_crosshair_change (false); - Crosshair.AttachedObject.State = STATE_FIRST; - Crosshair.AttachedLine.State = STATE_FIRST; - Crosshair.AttachedBox.State = STATE_FIRST; - ghid_hand_cursor (); - notify_crosshair_change (true); + oldObjState = Crosshair.AttachedObject.State; + oldLineState = Crosshair.AttachedLine.State; + oldBoxState = Crosshair.AttachedBox.State; + notify_crosshair_change(false); + Crosshair.AttachedObject.State = STATE_FIRST; + Crosshair.AttachedLine.State = STATE_FIRST; + Crosshair.AttachedBox.State = STATE_FIRST; + ghid_hand_cursor(); + notify_crosshair_change(true); - /* Stop the top level GMainLoop from getting user input from keyboard - | and mouse so we can install our own handlers here. Also set the - | control interface insensitive so all the user can do is hit a key - | or mouse button in the Output drawing area. - */ - ghid_interface_input_signals_disconnect (); - ghid_interface_set_sensitive (FALSE); + /* Stop the top level GMainLoop from getting user input from keyboard + | and mouse so we can install our own handlers here. Also set the + | control interface insensitive so all the user can do is hit a key + | or mouse button in the Output drawing area. + */ + ghid_interface_input_signals_disconnect(); + ghid_interface_set_sensitive(FALSE); - got_location = TRUE; /* Will be unset by hitting most keys */ - button_handler = - g_signal_connect (G_OBJECT (gport->drawing_area), - "button_press_event", - G_CALLBACK (loop_button_press_cb), &loop); - key_handler = - g_signal_connect (G_OBJECT (gport->top_window), - "key_press_event", - G_CALLBACK (loop_key_press_cb), &loop); + got_location = TRUE; /* Will be unset by hitting most keys */ + button_handler = + g_signal_connect(G_OBJECT(gport->drawing_area), "button_press_event", G_CALLBACK(loop_button_press_cb), &loop); + key_handler = g_signal_connect(G_OBJECT(gport->top_window), "key_press_event", G_CALLBACK(loop_key_press_cb), &loop); - loop = g_main_loop_new (NULL, FALSE); - g_main_loop_run (loop); + loop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(loop); - g_main_loop_unref (loop); + g_main_loop_unref(loop); - g_signal_handler_disconnect (gport->drawing_area, button_handler); - g_signal_handler_disconnect (gport->top_window, key_handler); + g_signal_handler_disconnect(gport->drawing_area, button_handler); + g_signal_handler_disconnect(gport->top_window, key_handler); - ghid_interface_input_signals_connect (); /* return to normal */ - ghid_interface_set_sensitive (TRUE); + ghid_interface_input_signals_connect(); /* return to normal */ + ghid_interface_set_sensitive(TRUE); - notify_crosshair_change (false); - Crosshair.AttachedObject.State = oldObjState; - Crosshair.AttachedLine.State = oldLineState; - Crosshair.AttachedBox.State = oldBoxState; - notify_crosshair_change (true); - ghid_restore_cursor (); + notify_crosshair_change(false); + Crosshair.AttachedObject.State = oldObjState; + Crosshair.AttachedLine.State = oldLineState; + Crosshair.AttachedBox.State = oldBoxState; + notify_crosshair_change(true); + ghid_restore_cursor(); - ghid_set_status_line_label (); + ghid_set_status_line_label(); - return got_location; + return got_location; } /* ---------------------------------------------------------------------------*/ -void -ghid_get_user_xy (const char *msg) +void ghid_get_user_xy(const char *msg) { - run_get_location_loop (msg); + run_get_location_loop(msg); } - /* XXX The abort dialog isn't implemented yet in the Gtk port - */ -void -ghid_create_abort_dialog (char *msg) + /* XXX The abort dialog isn't implemented yet in the Gtk port + */ +void ghid_create_abort_dialog(char *msg) { } -gboolean -ghid_check_abort (void) +gboolean ghid_check_abort(void) { - return FALSE; /* Abort isn't implemented, so never abort */ + return FALSE; /* Abort isn't implemented, so never abort */ } -void -ghid_end_abort (void) +void ghid_end_abort(void) { } -void -ghid_get_pointer (int *x, int *y) +void ghid_get_pointer(int *x, int *y) { - gint xp, yp; + gint xp, yp; - gdk_window_get_pointer (gtk_widget_get_window (gport->drawing_area), - &xp, &yp, NULL); - if (x) - *x = xp; - if (y) - *y = yp; + gdk_window_get_pointer(gtk_widget_get_window(gport->drawing_area), &xp, &yp, NULL); + if (x) + *x = xp; + if (y) + *y = yp; } /* --------------------------------------------------------------------------- * output of status line */ -void -ghid_set_status_line_label (void) +void ghid_set_status_line_label(void) { - gchar *flag = TEST_FLAG (ALLDIRECTIONFLAG, PCB) - ? "all" - : (PCB->Clipping == 0 - ? "45" - : (PCB->Clipping == 1 - ? "45_/" - : "45\\_")); - gchar *text = pcb_g_strdup_printf ( - _("%m+view=%s " - "grid=%$mS " - "%s%s " - "line=%mS " - "via=%mS (%mS) %s" - "clearance=%mS " - "text=%i%% " - "buffer=#%i"), - Settings.grid_unit->allow, - Settings.ShowSolderSide ? _("solder") : _("component"), - PCB->Grid, - flag, TEST_FLAG (RUBBERBANDFLAG, PCB) ? ",R " : " ", - Settings.LineThickness, - Settings.ViaThickness, - Settings.ViaDrillingHole, - ghidgui->compact_horizontal ? "\n" : "", - Settings.Keepaway, - Settings.TextScale, Settings.BufferNumber + 1); + gchar *flag = TEST_FLAG(ALLDIRECTIONFLAG, PCB) + ? "all" : (PCB->Clipping == 0 ? "45" : (PCB->Clipping == 1 ? "45_/" : "45\\_")); + gchar *text = pcb_g_strdup_printf(_("%m+view=%s " + "grid=%$mS " + "%s%s " + "line=%mS " + "via=%mS (%mS) %s" + "clearance=%mS " "text=%i%% " "buffer=#%i"), + Settings.grid_unit->allow, + Settings.ShowSolderSide ? _("solder") : _("component"), + PCB->Grid, + flag, TEST_FLAG(RUBBERBANDFLAG, PCB) ? ",R " : " ", + Settings.LineThickness, + Settings.ViaThickness, + Settings.ViaDrillingHole, + ghidgui->compact_horizontal ? "\n" : "", + Settings.Keepaway, + Settings.TextScale, Settings.BufferNumber + 1); - ghid_status_line_set_text (text); - g_free (text); + ghid_status_line_set_text(text); + g_free(text); } /* --------------------------------------------------------------------------- * output of cursor position */ -void -ghid_set_cursor_position_labels (void) +void ghid_set_cursor_position_labels(void) { - gchar *text; + gchar *text; - if (Marked.status) - { - Coord dx = Crosshair.X - Marked.X; - Coord dy = Crosshair.Y - Marked.Y; - Coord r = Distance (Crosshair.X, Crosshair.Y, Marked.X, Marked.Y); - double a = atan2 (dy, dx) * RAD_TO_DEG; + if (Marked.status) { + Coord dx = Crosshair.X - Marked.X; + Coord dy = Crosshair.Y - Marked.Y; + Coord r = Distance(Crosshair.X, Crosshair.Y, Marked.X, Marked.Y); + double a = atan2(dy, dx) * RAD_TO_DEG; - text = pcb_g_strdup_printf ("%m+r %-mS; phi %-.1f; %-mS %-mS", - Settings.grid_unit->allow, - r, a, dx, dy); - ghid_cursor_position_relative_label_set_text (text); - g_free (text); - } - else - ghid_cursor_position_relative_label_set_text ("r __.__; phi __._; __.__ __.__"); + text = pcb_g_strdup_printf("%m+r %-mS; phi %-.1f; %-mS %-mS", Settings.grid_unit->allow, r, a, dx, dy); + ghid_cursor_position_relative_label_set_text(text); + g_free(text); + } + else + ghid_cursor_position_relative_label_set_text("r __.__; phi __._; __.__ __.__"); - text = pcb_g_strdup_printf ("%m+%-mS %-mS", - Settings.grid_unit->allow, - Crosshair.X, Crosshair.Y); - ghid_cursor_position_label_set_text (text); - g_free (text); + text = pcb_g_strdup_printf("%m+%-mS %-mS", Settings.grid_unit->allow, Crosshair.X, Crosshair.Y); + ghid_cursor_position_label_set_text(text); + g_free(text); } Index: trunk/src/hid/gtk/gui-netlist-window.c =================================================================== --- trunk/src/hid/gtk/gui-netlist-window.c (revision 1021) +++ trunk/src/hid/gtk/gui-netlist-window.c (revision 1022) @@ -62,10 +62,10 @@ #define NET_HIERARCHY_SEPARATOR "/" -RCSID ("$Id$"); +RCSID("$Id$"); -static GtkWidget *netlist_window; -static GtkWidget *disable_all_button; +static GtkWidget *netlist_window; +static GtkWidget *disable_all_button; static GtkTreeModel *node_model; static GtkTreeView *node_treeview; @@ -144,42 +144,37 @@ | names would be nodes C101-1, R101-2, etc */ -LibraryEntryType *node_get_node_from_name (gchar * node_name, - LibraryMenuType ** node_net); +LibraryEntryType *node_get_node_from_name(gchar * node_name, LibraryMenuType ** node_net); -enum -{ - NODE_NAME_COLUMN, /* Name to show in the treeview */ - NODE_LIBRARY_COLUMN, /* Pointer to this node (LibraryEntryType) */ - N_NODE_COLUMNS +enum { + NODE_NAME_COLUMN, /* Name to show in the treeview */ + NODE_LIBRARY_COLUMN, /* Pointer to this node (LibraryEntryType) */ + N_NODE_COLUMNS }; /* Given a net in the netlist (a LibraryMenuType) put all the Entry[] | names (the nodes) into a newly created node tree model. */ -static GtkTreeModel * -node_model_create (LibraryMenuType * menu) +static GtkTreeModel *node_model_create(LibraryMenuType * menu) { - GtkListStore *store; - GtkTreeIter iter; + GtkListStore *store; + GtkTreeIter iter; - store = gtk_list_store_new (N_NODE_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER); + store = gtk_list_store_new(N_NODE_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER); - if (menu == NULL) - return GTK_TREE_MODEL (store); + if (menu == NULL) + return GTK_TREE_MODEL(store); - ENTRY_LOOP (menu); - { - if (!entry->ListEntry) - continue; - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, - NODE_NAME_COLUMN, entry->ListEntry, - NODE_LIBRARY_COLUMN, entry, -1); - } - END_LOOP; + ENTRY_LOOP(menu); + { + if (!entry->ListEntry) + continue; + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, NODE_NAME_COLUMN, entry->ListEntry, NODE_LIBRARY_COLUMN, entry, -1); + } + END_LOOP; - return GTK_TREE_MODEL (store); + return GTK_TREE_MODEL(store); } /* When there's a new node to display in the node treeview, call this. @@ -186,119 +181,112 @@ | Create a new model containing the nodes of the given net, insert | the model into the treeview and unref the old model. */ -static void -node_model_update (LibraryMenuType * menu) +static void node_model_update(LibraryMenuType * menu) { - GtkTreeModel *model; + GtkTreeModel *model; - model = node_model; - node_model = node_model_create (menu); - gtk_tree_view_set_model (node_treeview, node_model); + model = node_model; + node_model = node_model_create(menu); + gtk_tree_view_set_model(node_treeview, node_model); - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (node_model), - NODE_NAME_COLUMN, GTK_SORT_ASCENDING); + gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(node_model), NODE_NAME_COLUMN, GTK_SORT_ASCENDING); - /* We could be using gtk_list_store_clear() on the same model, but it's - | just as easy that we've created a new one and here unref the old one. - */ - if (model) - g_object_unref (G_OBJECT (model)); + /* We could be using gtk_list_store_clear() on the same model, but it's + | just as easy that we've created a new one and here unref the old one. + */ + if (model) + g_object_unref(G_OBJECT(model)); } -static void -toggle_pin_selected (LibraryEntryType *entry) +static void toggle_pin_selected(LibraryEntryType * entry) { - ConnectionType conn; + ConnectionType conn; - if (!SeekPad (entry, &conn, false)) - return; + if (!SeekPad(entry, &conn, false)) + return; - AddObjectToFlagUndoList (conn.type, conn.ptr1, conn.ptr2, conn.ptr2); - TOGGLE_FLAG (SELECTEDFLAG, (AnyObjectType *)conn.ptr2); - DrawObject (conn.type, conn.ptr1, conn.ptr2); + AddObjectToFlagUndoList(conn.type, conn.ptr1, conn.ptr2, conn.ptr2); + TOGGLE_FLAG(SELECTEDFLAG, (AnyObjectType *) conn.ptr2); + DrawObject(conn.type, conn.ptr1, conn.ptr2); } /* Callback when the user clicks on a PCB node in the right node treeview. */ -static void -node_selection_changed_cb (GtkTreeSelection * selection, gpointer data) +static void node_selection_changed_cb(GtkTreeSelection * selection, gpointer data) { - GtkTreeIter iter; - GtkTreeModel *model; - LibraryMenuType *node_net; - LibraryEntryType *node; - ConnectionType conn; - Coord x, y; - static gchar *node_name; + GtkTreeIter iter; + GtkTreeModel *model; + LibraryMenuType *node_net; + LibraryEntryType *node; + ConnectionType conn; + Coord x, y; + static gchar *node_name; - if (selection_holdoff) /* PCB is highlighting, user is not selecting */ - return; + if (selection_holdoff) /* PCB is highlighting, user is not selecting */ + return; - /* Toggle off the previous selection. Look up node_name to make sure - | it still exists. This toggling can get out of sync if a node is - | toggled selected, then the net that includes the node is selected - | then unselected. - */ - if ((node = node_get_node_from_name (node_name, &node_net)) != NULL) - { - /* If net node belongs to has been highlighted/unhighighed, toggling - | if off here will get our on/off toggling out of sync. - */ - if (node_net == node_selected_net) - { - toggle_pin_selected (node); - ghid_cancel_lead_user (); - } - g_free (node_name); - node_name = NULL; - } + /* Toggle off the previous selection. Look up node_name to make sure + | it still exists. This toggling can get out of sync if a node is + | toggled selected, then the net that includes the node is selected + | then unselected. + */ + if ((node = node_get_node_from_name(node_name, &node_net)) != NULL) { + /* If net node belongs to has been highlighted/unhighighed, toggling + | if off here will get our on/off toggling out of sync. + */ + if (node_net == node_selected_net) { + toggle_pin_selected(node); + ghid_cancel_lead_user(); + } + g_free(node_name); + node_name = NULL; + } - /* Get the selected treeview row. - */ - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) - { - if (node) - ghid_invalidate_all (); - return; - } + /* Get the selected treeview row. + */ + if (!gtk_tree_selection_get_selected(selection, &model, &iter)) { + if (node) + ghid_invalidate_all(); + return; + } - /* From the treeview row, extract the node pointer stored there and - | we've got a pointer to the LibraryEntryType (node) the row - | represents. - */ - gtk_tree_model_get (model, &iter, NODE_LIBRARY_COLUMN, &node, -1); + /* From the treeview row, extract the node pointer stored there and + | we've got a pointer to the LibraryEntryType (node) the row + | represents. + */ + gtk_tree_model_get(model, &iter, NODE_LIBRARY_COLUMN, &node, -1); - dup_string (&node_name, node->ListEntry); - node_selected_net = selected_net; + dup_string(&node_name, node->ListEntry); + node_selected_net = selected_net; - /* Now just toggle a select of the node on the layout - */ - toggle_pin_selected (node); - IncrementUndoSerialNumber (); + /* Now just toggle a select of the node on the layout + */ + toggle_pin_selected(node); + IncrementUndoSerialNumber(); - /* And lead the user to the location */ - if (SeekPad (node, &conn, false)) - switch (conn.type) { - case PIN_TYPE: - { - PinTypePtr pin = (PinTypePtr) conn.ptr2; - x = pin->X; - y = pin->Y; - gui->set_crosshair (x, y, 0); - ghid_lead_user_to_location (x, y); - break; - } - case PAD_TYPE: - { - PadTypePtr pad = (PadTypePtr) conn.ptr2; - x = pad->Point1.X + (pad->Point2.X - pad->Point1.X) / 2; - y = pad->Point1.Y + (pad->Point2.Y - pad->Point2.Y) / 2; - gui->set_crosshair (x, y, 0); - ghid_lead_user_to_location (x, y); - break; - } - } + /* And lead the user to the location */ + if (SeekPad(node, &conn, false)) + switch (conn.type) { + case PIN_TYPE: + { + PinTypePtr pin = (PinTypePtr) conn.ptr2; + x = pin->X; + y = pin->Y; + gui->set_crosshair(x, y, 0); + ghid_lead_user_to_location(x, y); + break; + } + case PAD_TYPE: + { + PadTypePtr pad = (PadTypePtr) conn.ptr2; + x = pad->Point1.X + (pad->Point2.X - pad->Point1.X) / 2; + y = pad->Point1.Y + (pad->Point2.Y - pad->Point2.Y) / 2; + gui->set_crosshair(x, y, 0); + ghid_lead_user_to_location(x, y); + break; + } + } } @@ -312,753 +300,675 @@ | have a "Disable all nets" toggle button and don't mess with the | model/treeview at all. */ -enum -{ - NET_ENABLED_COLUMN, /* If enabled will be ' ', if disable '*' */ - NET_NAME_COLUMN, /* Name to show in the treeview */ - NET_LIBRARY_COLUMN, /* Pointer to this net (LibraryMenuType) */ - N_NET_COLUMNS +enum { + NET_ENABLED_COLUMN, /* If enabled will be ' ', if disable '*' */ + NET_NAME_COLUMN, /* Name to show in the treeview */ + NET_LIBRARY_COLUMN, /* Pointer to this net (LibraryMenuType) */ + N_NET_COLUMNS }; static GtkTreeModel *net_model = NULL; static GtkTreeView *net_treeview; -static gboolean loading_new_netlist; +static gboolean loading_new_netlist; -static GtkTreeModel * -net_model_create (void) +static GtkTreeModel *net_model_create(void) { - GtkTreeModel *model; - GtkTreeStore *store; - GtkTreeIter new_iter; - GtkTreeIter parent_iter; - GtkTreeIter *parent_ptr; - GtkTreePath *path; - GtkTreeRowReference *row_ref; - GHashTable *prefix_hash; - char *display_name; - char *hash_string; - char **join_array; - char **path_segments; - int path_depth; - int try_depth; + GtkTreeModel *model; + GtkTreeStore *store; + GtkTreeIter new_iter; + GtkTreeIter parent_iter; + GtkTreeIter *parent_ptr; + GtkTreePath *path; + GtkTreeRowReference *row_ref; + GHashTable *prefix_hash; + char *display_name; + char *hash_string; + char **join_array; + char **path_segments; + int path_depth; + int try_depth; - store = gtk_tree_store_new (N_NET_COLUMNS, - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); + store = gtk_tree_store_new(N_NET_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); - model = GTK_TREE_MODEL (store); + model = GTK_TREE_MODEL(store); - /* Hash table stores GtkTreeRowReference for given path prefixes */ - prefix_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, - (GDestroyNotify) - gtk_tree_row_reference_free); + /* Hash table stores GtkTreeRowReference for given path prefixes */ + prefix_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify) + gtk_tree_row_reference_free); - MENU_LOOP (&PCB->NetlistLib[NETLIST_EDITED]); - { - if (!menu->Name) - continue; + MENU_LOOP(&PCB->NetlistLib[NETLIST_EDITED]); + { + if (!menu->Name) + continue; - if (loading_new_netlist) - menu->flag = TRUE; + if (loading_new_netlist) + menu->flag = TRUE; - parent_ptr = NULL; + parent_ptr = NULL; - path_segments = g_strsplit (menu->Name, NET_HIERARCHY_SEPARATOR, 0); - path_depth = g_strv_length (path_segments); + path_segments = g_strsplit(menu->Name, NET_HIERARCHY_SEPARATOR, 0); + path_depth = g_strv_length(path_segments); - for (try_depth = path_depth - 1; try_depth > 0; try_depth--) - { - join_array = g_new0 (char *, try_depth + 1); - memcpy (join_array, path_segments, sizeof (char *) * try_depth); + for (try_depth = path_depth - 1; try_depth > 0; try_depth--) { + join_array = g_new0(char *, try_depth + 1); + memcpy(join_array, path_segments, sizeof(char *) * try_depth); - /* See if this net's parent node is in the hash table */ - hash_string = g_strjoinv (NET_HIERARCHY_SEPARATOR, join_array); - g_free (join_array); + /* See if this net's parent node is in the hash table */ + hash_string = g_strjoinv(NET_HIERARCHY_SEPARATOR, join_array); + g_free(join_array); - row_ref = (GtkTreeRowReference *)g_hash_table_lookup (prefix_hash, hash_string); - g_free (hash_string); + row_ref = (GtkTreeRowReference *) g_hash_table_lookup(prefix_hash, hash_string); + g_free(hash_string); - /* If we didn't find the path at this level, keep looping */ - if (row_ref == NULL) - continue; + /* If we didn't find the path at this level, keep looping */ + if (row_ref == NULL) + continue; - path = gtk_tree_row_reference_get_path (row_ref); - gtk_tree_model_get_iter (model, &parent_iter, path); - parent_ptr = &parent_iter; - break; - } + path = gtk_tree_row_reference_get_path(row_ref); + gtk_tree_model_get_iter(model, &parent_iter, path); + parent_ptr = &parent_iter; + break; + } - /* NB: parent_ptr may still be NULL if we reached the toplevel */ + /* NB: parent_ptr may still be NULL if we reached the toplevel */ - /* Now walk up the desired path, adding the nodes */ + /* Now walk up the desired path, adding the nodes */ - for (; try_depth < path_depth - 1; try_depth++) - { - display_name = g_strconcat (path_segments[try_depth], - NET_HIERARCHY_SEPARATOR, NULL); - gtk_tree_store_append (store, &new_iter, parent_ptr); - gtk_tree_store_set (store, &new_iter, - NET_ENABLED_COLUMN, "", - NET_NAME_COLUMN, display_name, - NET_LIBRARY_COLUMN, NULL, -1); - g_free (display_name); + for (; try_depth < path_depth - 1; try_depth++) { + display_name = g_strconcat(path_segments[try_depth], NET_HIERARCHY_SEPARATOR, NULL); + gtk_tree_store_append(store, &new_iter, parent_ptr); + gtk_tree_store_set(store, &new_iter, NET_ENABLED_COLUMN, "", NET_NAME_COLUMN, display_name, NET_LIBRARY_COLUMN, NULL, -1); + g_free(display_name); - path = gtk_tree_model_get_path (model, &new_iter); - row_ref = gtk_tree_row_reference_new (model, path); - parent_iter = new_iter; - parent_ptr = &parent_iter; + path = gtk_tree_model_get_path(model, &new_iter); + row_ref = gtk_tree_row_reference_new(model, path); + parent_iter = new_iter; + parent_ptr = &parent_iter; - join_array = g_new0 (char *, try_depth + 2); - memcpy (join_array, path_segments, sizeof (char *) * (try_depth + 1)); + join_array = g_new0(char *, try_depth + 2); + memcpy(join_array, path_segments, sizeof(char *) * (try_depth + 1)); - hash_string = g_strjoinv (NET_HIERARCHY_SEPARATOR, join_array); - g_free (join_array); + hash_string = g_strjoinv(NET_HIERARCHY_SEPARATOR, join_array); + g_free(join_array); - /* Insert those node in the hash table */ - g_hash_table_insert (prefix_hash, hash_string, row_ref); - /* Don't free hash_string, it is now oened by the hash table */ - } + /* Insert those node in the hash table */ + g_hash_table_insert(prefix_hash, hash_string, row_ref); + /* Don't free hash_string, it is now oened by the hash table */ + } - gtk_tree_store_append (store, &new_iter, parent_ptr); - gtk_tree_store_set (store, &new_iter, - NET_ENABLED_COLUMN, menu->flag ? "" : "*", - NET_NAME_COLUMN, path_segments[path_depth - 1], - NET_LIBRARY_COLUMN, menu, -1); - g_strfreev (path_segments); - } - END_LOOP; + gtk_tree_store_append(store, &new_iter, parent_ptr); + gtk_tree_store_set(store, &new_iter, + NET_ENABLED_COLUMN, menu->flag ? "" : "*", + NET_NAME_COLUMN, path_segments[path_depth - 1], NET_LIBRARY_COLUMN, menu, -1); + g_strfreev(path_segments); + } + END_LOOP; - g_hash_table_destroy (prefix_hash); + g_hash_table_destroy(prefix_hash); - return model; + return model; } /* Called when the user double clicks on a net in the left treeview. */ -static void -net_selection_double_click_cb (GtkTreeView * treeview, GtkTreePath * path, - GtkTreeViewColumn * col, gpointer data) +static void net_selection_double_click_cb(GtkTreeView * treeview, GtkTreePath * path, GtkTreeViewColumn * col, gpointer data) { - GtkTreeModel *model; - GtkTreeIter iter; - gchar *str; - LibraryMenuType *menu; + GtkTreeModel *model; + GtkTreeIter iter; + gchar *str; + LibraryMenuType *menu; - model = gtk_tree_view_get_model (treeview); - if (gtk_tree_model_get_iter (model, &iter, path)) - { + model = gtk_tree_view_get_model(treeview); + if (gtk_tree_model_get_iter(model, &iter, path)) { - /* Expand / contract nodes with children */ - if (gtk_tree_model_iter_has_child (model, &iter)) - { - if (gtk_tree_view_row_expanded (treeview, path)) - gtk_tree_view_collapse_row (treeview, path); - else - gtk_tree_view_expand_row (treeview, path, FALSE); - return; - } + /* Expand / contract nodes with children */ + if (gtk_tree_model_iter_has_child(model, &iter)) { + if (gtk_tree_view_row_expanded(treeview, path)) + gtk_tree_view_collapse_row(treeview, path); + else + gtk_tree_view_expand_row(treeview, path, FALSE); + return; + } - /* Get the current enabled string and toggle it between "" and "*" - */ - gtk_tree_model_get (model, &iter, NET_ENABLED_COLUMN, &str, -1); - gtk_tree_store_set (GTK_TREE_STORE (model), &iter, - NET_ENABLED_COLUMN, !strcmp (str, "*") ? "" : "*", - -1); - /* set/clear the flag which says the net is enabled or disabled */ - gtk_tree_model_get (model, &iter, NET_LIBRARY_COLUMN, &menu, -1); - menu->flag = strcmp (str, "*") == 0 ? 1 : 0; - g_free (str); - } + /* Get the current enabled string and toggle it between "" and "*" + */ + gtk_tree_model_get(model, &iter, NET_ENABLED_COLUMN, &str, -1); + gtk_tree_store_set(GTK_TREE_STORE(model), &iter, NET_ENABLED_COLUMN, !strcmp(str, "*") ? "" : "*", -1); + /* set/clear the flag which says the net is enabled or disabled */ + gtk_tree_model_get(model, &iter, NET_LIBRARY_COLUMN, &menu, -1); + menu->flag = strcmp(str, "*") == 0 ? 1 : 0; + g_free(str); + } } /* Called when the user clicks on a net in the left treeview. */ -static void -net_selection_changed_cb (GtkTreeSelection * selection, gpointer data) +static void net_selection_changed_cb(GtkTreeSelection * selection, gpointer data) { - GtkTreeIter iter; - GtkTreeModel *model; - LibraryMenuType *net; + GtkTreeIter iter; + GtkTreeModel *model; + LibraryMenuType *net; - if (selection_holdoff) /* PCB is highlighting, user is not selecting */ - return; + if (selection_holdoff) /* PCB is highlighting, user is not selecting */ + return; - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) - { - selected_net = NULL; + if (!gtk_tree_selection_get_selected(selection, &model, &iter)) { + selected_net = NULL; - return; - } + return; + } - /* Get a pointer, net, to the LibraryMenuType of the newly selected - | netlist row, and create a new node model from the net entries - | and insert that model into the node view. Delete old entry model. - */ - gtk_tree_model_get (model, &iter, NET_LIBRARY_COLUMN, &net, -1); - node_model_update (net); + /* Get a pointer, net, to the LibraryMenuType of the newly selected + | netlist row, and create a new node model from the net entries + | and insert that model into the node view. Delete old entry model. + */ + gtk_tree_model_get(model, &iter, NET_LIBRARY_COLUMN, &net, -1); + node_model_update(net); - selected_net = net; + selected_net = net; } -static void -netlist_disable_all_cb (GtkToggleButton * button, gpointer data) +static void netlist_disable_all_cb(GtkToggleButton * button, gpointer data) { - GtkTreeIter iter; - gboolean active = gtk_toggle_button_get_active (button); - LibraryMenuType *menu; + GtkTreeIter iter; + gboolean active = gtk_toggle_button_get_active(button); + LibraryMenuType *menu; - /* Get each net iter and change the NET_ENABLED_COLUMN to a "*" or "" - | to flag it as disabled or enabled based on toggle button state. - */ - if (gtk_tree_model_get_iter_first (net_model, &iter)) - do - { - gtk_tree_store_set (GTK_TREE_STORE (net_model), &iter, - NET_ENABLED_COLUMN, active ? "*" : "", -1); - /* set/clear the flag which says the net is enabled or disabled */ - gtk_tree_model_get (net_model, &iter, NET_LIBRARY_COLUMN, &menu, -1); - menu->flag = active ? 0 : 1; - } - while (gtk_tree_model_iter_next (net_model, &iter)); + /* Get each net iter and change the NET_ENABLED_COLUMN to a "*" or "" + | to flag it as disabled or enabled based on toggle button state. + */ + if (gtk_tree_model_get_iter_first(net_model, &iter)) + do { + gtk_tree_store_set(GTK_TREE_STORE(net_model), &iter, NET_ENABLED_COLUMN, active ? "*" : "", -1); + /* set/clear the flag which says the net is enabled or disabled */ + gtk_tree_model_get(net_model, &iter, NET_LIBRARY_COLUMN, &menu, -1); + menu->flag = active ? 0 : 1; + } + while (gtk_tree_model_iter_next(net_model, &iter)); } /* Select on the layout the current net treeview selection */ -static void -netlist_select_cb (GtkWidget * widget, gpointer data) +static void netlist_select_cb(GtkWidget * widget, gpointer data) { - LibraryEntryType *entry; - ConnectionType conn; - gint i; - gboolean select_flag = GPOINTER_TO_INT (data); + LibraryEntryType *entry; + ConnectionType conn; + gint i; + gboolean select_flag = GPOINTER_TO_INT(data); - if (!selected_net) - return; - if (selected_net == node_selected_net) - node_selected_net = NULL; + if (!selected_net) + return; + if (selected_net == node_selected_net) + node_selected_net = NULL; - InitConnectionLookup (); - ResetConnections (true); + InitConnectionLookup(); + ResetConnections(true); - for (i = selected_net->EntryN, entry = selected_net->Entry; i; i--, entry++) - if (SeekPad (entry, &conn, false)) - RatFindHook (conn.type, conn.ptr1, conn.ptr2, conn.ptr2, true, true); + for (i = selected_net->EntryN, entry = selected_net->Entry; i; i--, entry++) + if (SeekPad(entry, &conn, false)) + RatFindHook(conn.type, conn.ptr1, conn.ptr2, conn.ptr2, true, true); - SelectConnection (select_flag); - ResetConnections (false); - FreeConnectionLookupMemory (); - IncrementUndoSerialNumber (); - Draw (); + SelectConnection(select_flag); + ResetConnections(false); + FreeConnectionLookupMemory(); + IncrementUndoSerialNumber(); + Draw(); } -static void -netlist_find_cb (GtkWidget * widget, gpointer data) +static void netlist_find_cb(GtkWidget * widget, gpointer data) { - char *name = NULL; + char *name = NULL; - if (!selected_net) - return; + if (!selected_net) + return; - name = selected_net->Name + 2; - hid_actionl ("connection", "reset", NULL); - hid_actionl ("netlist", "find", name, NULL); + name = selected_net->Name + 2; + hid_actionl("connection", "reset", NULL); + hid_actionl("netlist", "find", name, NULL); } -static void -netlist_rip_up_cb (GtkWidget * widget, gpointer data) +static void netlist_rip_up_cb(GtkWidget * widget, gpointer data) { - if (!selected_net) - return; - netlist_find_cb(widget, data); + if (!selected_net) + return; + netlist_find_cb(widget, data); - VISIBLELINE_LOOP (PCB->Data); - { - if (TEST_FLAG (FOUNDFLAG, line) && !TEST_FLAG (LOCKFLAG, line)) - RemoveObject (LINE_TYPE, layer, line, line); - } - ENDALL_LOOP; + VISIBLELINE_LOOP(PCB->Data); + { + if (TEST_FLAG(FOUNDFLAG, line) && !TEST_FLAG(LOCKFLAG, line)) + RemoveObject(LINE_TYPE, layer, line, line); + } + ENDALL_LOOP; - VISIBLEARC_LOOP (PCB->Data); - { - if (TEST_FLAG (FOUNDFLAG, arc) && !TEST_FLAG (LOCKFLAG, arc)) - RemoveObject (ARC_TYPE, layer, arc, arc); - } - ENDALL_LOOP; + VISIBLEARC_LOOP(PCB->Data); + { + if (TEST_FLAG(FOUNDFLAG, arc) && !TEST_FLAG(LOCKFLAG, arc)) + RemoveObject(ARC_TYPE, layer, arc, arc); + } + ENDALL_LOOP; - if (PCB->ViaOn) - VIA_LOOP (PCB->Data); - { - if (TEST_FLAG (FOUNDFLAG, via) && !TEST_FLAG (LOCKFLAG, via)) - RemoveObject (VIA_TYPE, via, via, via); - } - END_LOOP; + if (PCB->ViaOn) + VIA_LOOP(PCB->Data); + { + if (TEST_FLAG(FOUNDFLAG, via) && !TEST_FLAG(LOCKFLAG, via)) + RemoveObject(VIA_TYPE, via, via, via); + } + END_LOOP; } -/**/ -typedef struct { - LibraryEntryType *ret_val; - LibraryMenuType *node_net; - const gchar *node_name; - bool found; + /**/ typedef struct { + LibraryEntryType *ret_val; + LibraryMenuType *node_net; + const gchar *node_name; + bool found; } node_get_node_from_name_state; -static gboolean -node_get_node_from_name_helper (GtkTreeModel *model, GtkTreePath *path, - GtkTreeIter *iter, gpointer data) +static gboolean node_get_node_from_name_helper(GtkTreeModel * model, GtkTreePath * path, GtkTreeIter * iter, gpointer data) { - LibraryMenuType *net; - LibraryEntryType *node; - node_get_node_from_name_state *state = data; + LibraryMenuType *net; + LibraryEntryType *node; + node_get_node_from_name_state *state = data; - gtk_tree_model_get (net_model, iter, NET_LIBRARY_COLUMN, &net, -1); - /* Ignore non-nets (category headers) */ - if (net == NULL) - return FALSE; + gtk_tree_model_get(net_model, iter, NET_LIBRARY_COLUMN, &net, -1); + /* Ignore non-nets (category headers) */ + if (net == NULL) + return FALSE; - /* Look for the node name in this net. */ - for (node = net->Entry; node - net->Entry < net->EntryN; node++) - if (node->ListEntry && !strcmp (state->node_name, node->ListEntry)) - { - state->node_net = net; - state->ret_val = node; - /* stop iterating */ - state->found = TRUE; - return TRUE; - } - return FALSE; + /* Look for the node name in this net. */ + for (node = net->Entry; node - net->Entry < net->EntryN; node++) + if (node->ListEntry && !strcmp(state->node_name, node->ListEntry)) { + state->node_net = net; + state->ret_val = node; + /* stop iterating */ + state->found = TRUE; + return TRUE; + } + return FALSE; } -LibraryEntryType * -node_get_node_from_name (gchar * node_name, LibraryMenuType ** node_net) +LibraryEntryType *node_get_node_from_name(gchar * node_name, LibraryMenuType ** node_net) { - node_get_node_from_name_state state; + node_get_node_from_name_state state; - if (!node_name) - return NULL; + if (!node_name) + return NULL; - /* Have to force the netlist window created because we need the treeview - | models constructed to do the search. - */ - ghid_netlist_window_create (gport); + /* Have to force the netlist window created because we need the treeview + | models constructed to do the search. + */ + ghid_netlist_window_create(gport); - /* Now walk through node entries of each net in the net model looking for - | the node_name. - */ - state.found = 0; - state.node_name = node_name; - gtk_tree_model_foreach (net_model, node_get_node_from_name_helper, &state); - if (state.found) - { - if (node_net) - *node_net = state.node_net; - return state.ret_val; - } - return NULL; + /* Now walk through node entries of each net in the net model looking for + | the node_name. + */ + state.found = 0; + state.node_name = node_name; + gtk_tree_model_foreach(net_model, node_get_node_from_name_helper, &state); + if (state.found) { + if (node_net) + *node_net = state.node_net; + return state.ret_val; + } + return NULL; } -/**/ + /**/ /* ---------- Manage the GUI treeview of the data models ----------- */ -static gint -netlist_window_configure_event_cb (GtkWidget * widget, GdkEventConfigure * ev, - gpointer data) +static gint netlist_window_configure_event_cb(GtkWidget * widget, GdkEventConfigure * ev, gpointer data) { - GtkAllocation allocation; + GtkAllocation allocation; - gtk_widget_get_allocation (widget, &allocation); - ghidgui->netlist_window_height = allocation.height; - ghidgui->config_modified = TRUE; - return FALSE; + gtk_widget_get_allocation(widget, &allocation); + ghidgui->netlist_window_height = allocation.height; + ghidgui->config_modified = TRUE; + return FALSE; } -static void -netlist_close_cb (GtkWidget * widget, gpointer data) +static void netlist_close_cb(GtkWidget * widget, gpointer data) { - gtk_widget_destroy (netlist_window); - selected_net = NULL; - netlist_window = NULL; + gtk_widget_destroy(netlist_window); + selected_net = NULL; + netlist_window = NULL; - /* For now, we are the only consumer of this API, so we can just do this */ - ghid_cancel_lead_user (); + /* For now, we are the only consumer of this API, so we can just do this */ + ghid_cancel_lead_user(); } -static void -netlist_destroy_cb (GtkWidget * widget, GHidPort * out) +static void netlist_destroy_cb(GtkWidget * widget, GHidPort * out) { - selected_net = NULL; - netlist_window = NULL; + selected_net = NULL; + netlist_window = NULL; } -void -ghid_netlist_window_create (GHidPort * out) +void ghid_netlist_window_create(GHidPort * out) { - GtkWidget *vbox, *hbox, *button, *label, *sep; - GtkTreeView *treeview; - GtkTreeModel *model; - GtkTreeSelection *selection; - GtkCellRenderer *renderer; - GtkTreeViewColumn *column; + GtkWidget *vbox, *hbox, *button, *label, *sep; + GtkTreeView *treeview; + GtkTreeModel *model; + GtkTreeSelection *selection; + GtkCellRenderer *renderer; + GtkTreeViewColumn *column; - /* No point in putting up the window if no netlist is loaded. - */ - if (!PCB->NetlistLib[NETLIST_EDITED].MenuN) - return; + /* No point in putting up the window if no netlist is loaded. + */ + if (!PCB->NetlistLib[NETLIST_EDITED].MenuN) + return; - if (netlist_window) - return; + if (netlist_window) + return; - netlist_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - g_signal_connect (G_OBJECT (netlist_window), "destroy", - G_CALLBACK (netlist_destroy_cb), out); - gtk_window_set_title (GTK_WINDOW (netlist_window), _("PCB Netlist")); - gtk_window_set_wmclass (GTK_WINDOW (netlist_window), "PCB_Netlist", "PCB"); - g_signal_connect (G_OBJECT (netlist_window), "configure_event", - G_CALLBACK (netlist_window_configure_event_cb), NULL); - gtk_window_set_default_size (GTK_WINDOW (netlist_window), - -1, ghidgui->netlist_window_height); + netlist_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + g_signal_connect(G_OBJECT(netlist_window), "destroy", G_CALLBACK(netlist_destroy_cb), out); + gtk_window_set_title(GTK_WINDOW(netlist_window), _("PCB Netlist")); + gtk_window_set_wmclass(GTK_WINDOW(netlist_window), "PCB_Netlist", "PCB"); + g_signal_connect(G_OBJECT(netlist_window), "configure_event", G_CALLBACK(netlist_window_configure_event_cb), NULL); + gtk_window_set_default_size(GTK_WINDOW(netlist_window), -1, ghidgui->netlist_window_height); - gtk_container_set_border_width (GTK_CONTAINER (netlist_window), 2); + gtk_container_set_border_width(GTK_CONTAINER(netlist_window), 2); - vbox = gtk_vbox_new (FALSE, 4); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); - gtk_container_add (GTK_CONTAINER (netlist_window), vbox); - hbox = gtk_hbox_new (FALSE, 8); - gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 4); + vbox = gtk_vbox_new(FALSE, 4); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); + gtk_container_add(GTK_CONTAINER(netlist_window), vbox); + hbox = gtk_hbox_new(FALSE, 8); + gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 4); - model = net_model_create (); - treeview = GTK_TREE_VIEW (gtk_tree_view_new_with_model (model)); - net_model = model; - net_treeview = treeview; - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (net_model), - NET_NAME_COLUMN, GTK_SORT_ASCENDING); + model = net_model_create(); + treeview = GTK_TREE_VIEW(gtk_tree_view_new_with_model(model)); + net_model = model; + net_treeview = treeview; + gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(net_model), NET_NAME_COLUMN, GTK_SORT_ASCENDING); - gtk_tree_view_set_rules_hint (treeview, FALSE); - g_object_set (treeview, "enable-tree-lines", TRUE, NULL); + gtk_tree_view_set_rules_hint(treeview, FALSE); + g_object_set(treeview, "enable-tree-lines", TRUE, NULL); - renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (treeview, -1, _(" "), - renderer, - "text", NET_ENABLED_COLUMN, - NULL); + renderer = gtk_cell_renderer_text_new(); + gtk_tree_view_insert_column_with_attributes(treeview, -1, _(" "), renderer, "text", NET_ENABLED_COLUMN, NULL); - renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("Net Name"), - renderer, - "text", NET_NAME_COLUMN, NULL); - gtk_tree_view_insert_column (treeview, column, -1); - gtk_tree_view_set_expander_column (treeview, column); + renderer = gtk_cell_renderer_text_new(); + column = gtk_tree_view_column_new_with_attributes(_("Net Name"), renderer, "text", NET_NAME_COLUMN, NULL); + gtk_tree_view_insert_column(treeview, column, -1); + gtk_tree_view_set_expander_column(treeview, column); - /* TODO: dont expand all, but record expanded states when window is - | destroyed and restore state here. - */ - gtk_tree_view_expand_all (treeview); + /* TODO: dont expand all, but record expanded states when window is + | destroyed and restore state here. + */ + gtk_tree_view_expand_all(treeview); - selection = ghid_scrolled_selection (treeview, hbox, - GTK_SELECTION_SINGLE, - GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, - net_selection_changed_cb, NULL); + selection = ghid_scrolled_selection(treeview, hbox, + GTK_SELECTION_SINGLE, + GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, net_selection_changed_cb, NULL); - /* Connect to the double click event. - */ - g_signal_connect (G_OBJECT (treeview), "row-activated", - G_CALLBACK (net_selection_double_click_cb), NULL); + /* Connect to the double click event. + */ + g_signal_connect(G_OBJECT(treeview), "row-activated", G_CALLBACK(net_selection_double_click_cb), NULL); - /* Create the elements treeview and wait for a callback to populate it. - */ - treeview = GTK_TREE_VIEW (gtk_tree_view_new ()); - node_treeview = treeview; + /* Create the elements treeview and wait for a callback to populate it. + */ + treeview = GTK_TREE_VIEW(gtk_tree_view_new()); + node_treeview = treeview; - gtk_tree_view_set_rules_hint (treeview, FALSE); + gtk_tree_view_set_rules_hint(treeview, FALSE); - renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (treeview, -1, _("Nodes"), - renderer, - "text", NODE_NAME_COLUMN, - NULL); + renderer = gtk_cell_renderer_text_new(); + gtk_tree_view_insert_column_with_attributes(treeview, -1, _("Nodes"), renderer, "text", NODE_NAME_COLUMN, NULL); - selection = ghid_scrolled_selection (treeview, hbox, - GTK_SELECTION_SINGLE, - GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, - node_selection_changed_cb, NULL); - node_selection = selection; + selection = ghid_scrolled_selection(treeview, hbox, + GTK_SELECTION_SINGLE, + GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, node_selection_changed_cb, NULL); + node_selection = selection; - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - label = gtk_label_new (_("Operations on selected 'Net Name':")); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + label = gtk_label_new(_("Operations on selected 'Net Name':")); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 4); + gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 4); + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 4); - button = gtk_button_new_with_label (_("Select")); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (netlist_select_cb), GINT_TO_POINTER (1)); + button = gtk_button_new_with_label(_("Select")); + gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); + g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(netlist_select_cb), GINT_TO_POINTER(1)); - button = gtk_button_new_with_label (_("Unselect")); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (netlist_select_cb), GINT_TO_POINTER (0)); + button = gtk_button_new_with_label(_("Unselect")); + gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); + g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(netlist_select_cb), GINT_TO_POINTER(0)); - button = gtk_button_new_with_label (_("Find")); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (netlist_find_cb), GINT_TO_POINTER (0)); + button = gtk_button_new_with_label(_("Find")); + gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); + g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(netlist_find_cb), GINT_TO_POINTER(0)); - button = gtk_button_new_with_label (_("Rip Up")); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (netlist_rip_up_cb), GINT_TO_POINTER (0)); - - ghid_check_button_connected (vbox, &disable_all_button, FALSE, TRUE, FALSE, - FALSE, 0, netlist_disable_all_cb, NULL, - _("Disable all nets for adding rats")); + button = gtk_button_new_with_label(_("Rip Up")); + gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); + g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(netlist_rip_up_cb), GINT_TO_POINTER(0)); - sep = gtk_hseparator_new (); - gtk_box_pack_start (GTK_BOX (vbox), sep, FALSE, FALSE, 3); + ghid_check_button_connected(vbox, &disable_all_button, FALSE, TRUE, FALSE, + FALSE, 0, netlist_disable_all_cb, NULL, _("Disable all nets for adding rats")); - 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, 4); - button = gtk_button_new_from_stock (GTK_STOCK_CLOSE); - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (netlist_close_cb), NULL); - gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); + sep = gtk_hseparator_new(); + gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 3); + 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, 4); + button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); + g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(netlist_close_cb), NULL); + gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); - gtk_widget_realize (netlist_window); - if (Settings.AutoPlace) - gtk_window_move (GTK_WINDOW (netlist_window), 10, 10); + gtk_widget_realize(netlist_window); + if (Settings.AutoPlace) + gtk_window_move(GTK_WINDOW(netlist_window), 10, 10); + } -void -ghid_netlist_window_show (GHidPort * out, gboolean raise) +void ghid_netlist_window_show(GHidPort * out, gboolean raise) { - ghid_netlist_window_create (out); - gtk_widget_show_all (netlist_window); - ghid_netlist_window_update (TRUE); - if (raise) - gtk_window_present(GTK_WINDOW(netlist_window)); + ghid_netlist_window_create(out); + gtk_widget_show_all(netlist_window); + ghid_netlist_window_update(TRUE); + if (raise) + gtk_window_present(GTK_WINDOW(netlist_window)); } struct ggnfnn_task { - gboolean enabled_only; - gchar *node_name; - LibraryMenuType *found_net; - GtkTreeIter iter; + gboolean enabled_only; + gchar *node_name; + LibraryMenuType *found_net; + GtkTreeIter iter; }; -static gboolean -hunt_named_node (GtkTreeModel *model, GtkTreePath *path, - GtkTreeIter *iter, gpointer data) +static gboolean hunt_named_node(GtkTreeModel * model, GtkTreePath * path, GtkTreeIter * iter, gpointer data) { - struct ggnfnn_task *task = (struct ggnfnn_task *)data; - LibraryMenuType *net; - LibraryEntryType *node; - gchar *str; - gint j; - gboolean is_disabled; + struct ggnfnn_task *task = (struct ggnfnn_task *) data; + LibraryMenuType *net; + LibraryEntryType *node; + gchar *str; + gint j; + gboolean is_disabled; - /* We only want to inspect leaf nodes in the tree */ - if (gtk_tree_model_iter_has_child (model, iter)) - return FALSE; + /* We only want to inspect leaf nodes in the tree */ + if (gtk_tree_model_iter_has_child(model, iter)) + return FALSE; - gtk_tree_model_get (model, iter, NET_LIBRARY_COLUMN, &net, -1); - gtk_tree_model_get (model, iter, NET_ENABLED_COLUMN, &str, -1); - is_disabled = !strcmp (str, "*"); - g_free (str); + gtk_tree_model_get(model, iter, NET_LIBRARY_COLUMN, &net, -1); + gtk_tree_model_get(model, iter, NET_ENABLED_COLUMN, &str, -1); + is_disabled = !strcmp(str, "*"); + g_free(str); - /* Don't check net nodes of disabled nets. */ - if (task->enabled_only && is_disabled) - return FALSE; + /* Don't check net nodes of disabled nets. */ + if (task->enabled_only && is_disabled) + return FALSE; - /* Look for the node name in this net. */ - for (j = net->EntryN, node = net->Entry; j; j--, node++) - if (node->ListEntry && !strcmp (task->node_name, node->ListEntry)) - { - task->found_net = net; - task->iter = *iter; - return TRUE; - } + /* Look for the node name in this net. */ + for (j = net->EntryN, node = net->Entry; j; j--, node++) + if (node->ListEntry && !strcmp(task->node_name, node->ListEntry)) { + task->found_net = net; + task->iter = *iter; + return TRUE; + } - return FALSE; + return FALSE; } -LibraryMenuType * -ghid_get_net_from_node_name (gchar * node_name, gboolean enabled_only) +LibraryMenuType *ghid_get_net_from_node_name(gchar * node_name, gboolean enabled_only) { - GtkTreePath *path; - struct ggnfnn_task task; + GtkTreePath *path; + struct ggnfnn_task task; - if (!node_name) - return NULL; + if (!node_name) + return NULL; - /* Have to force the netlist window created because we need the treeview - | models constructed so we can find the LibraryMenuType pointer the - | caller wants. - */ - ghid_netlist_window_create (gport); + /* Have to force the netlist window created because we need the treeview + | models constructed so we can find the LibraryMenuType pointer the + | caller wants. + */ + ghid_netlist_window_create(gport); - /* If no netlist is loaded the window doesn't appear. */ - if (netlist_window == NULL) - return NULL; + /* If no netlist is loaded the window doesn't appear. */ + if (netlist_window == NULL) + return NULL; - task.enabled_only = enabled_only; - task.node_name = node_name; - task.found_net = NULL; + task.enabled_only = enabled_only; + task.node_name = node_name; + task.found_net = NULL; - /* Now walk through node entries of each net in the net model looking for - | the node_name. - */ - gtk_tree_model_foreach (net_model, hunt_named_node, &task); + /* Now walk through node entries of each net in the net model looking for + | the node_name. + */ + gtk_tree_model_foreach(net_model, hunt_named_node, &task); - /* We are asked to highlight the found net if enabled_only is TRUE. - | Set holdoff TRUE since this is just a highlight and user is not - | expecting normal select action to happen? Or should the node - | treeview also get updated? Original PCB code just tries to highlight. - */ - if (task.found_net && enabled_only) - { - selection_holdoff = TRUE; - path = gtk_tree_model_get_path (net_model, &task.iter); - gtk_tree_view_scroll_to_cell (net_treeview, path, NULL, TRUE, 0.5, 0.5); - gtk_tree_selection_select_path (gtk_tree_view_get_selection - (net_treeview), path); - selection_holdoff = FALSE; - } - return task.found_net; + /* We are asked to highlight the found net if enabled_only is TRUE. + | Set holdoff TRUE since this is just a highlight and user is not + | expecting normal select action to happen? Or should the node + | treeview also get updated? Original PCB code just tries to highlight. + */ + if (task.found_net && enabled_only) { + selection_holdoff = TRUE; + path = gtk_tree_model_get_path(net_model, &task.iter); + gtk_tree_view_scroll_to_cell(net_treeview, path, NULL, TRUE, 0.5, 0.5); + gtk_tree_selection_select_path(gtk_tree_view_get_selection(net_treeview), path); + selection_holdoff = FALSE; + } + return task.found_net; } /* PCB LookupConnection code in find.c calls this if it wants a node | and its net highlighted. */ -void -ghid_netlist_highlight_node (gchar * node_name) +void ghid_netlist_highlight_node(gchar * node_name) { - GtkTreePath *path; - GtkTreeIter iter; - LibraryMenuType *net; - gchar *name; + GtkTreePath *path; + GtkTreeIter iter; + LibraryMenuType *net; + gchar *name; - if (!node_name) - return; + if (!node_name) + return; - if ((net = ghid_get_net_from_node_name (node_name, TRUE)) == NULL) - return; + if ((net = ghid_get_net_from_node_name(node_name, TRUE)) == NULL) + return; - /* We've found the net containing the node, so update the node treeview - | to contain the nodes from the net. Then we have to find the node - | in the new node model so we can highlight it. - */ - node_model_update (net); + /* We've found the net containing the node, so update the node treeview + | to contain the nodes from the net. Then we have to find the node + | in the new node model so we can highlight it. + */ + node_model_update(net); - if (gtk_tree_model_get_iter_first (node_model, &iter)) - do - { - gtk_tree_model_get (node_model, &iter, NODE_NAME_COLUMN, &name, -1); + if (gtk_tree_model_get_iter_first(node_model, &iter)) + do { + gtk_tree_model_get(node_model, &iter, NODE_NAME_COLUMN, &name, -1); - if (!strcmp (node_name, name)) - { /* found it, so highlight it */ - selection_holdoff = TRUE; - selected_net = net; - path = gtk_tree_model_get_path (node_model, &iter); - gtk_tree_view_scroll_to_cell (node_treeview, path, NULL, - TRUE, 0.5, 0.5); - gtk_tree_selection_select_path (gtk_tree_view_get_selection - (node_treeview), path); - selection_holdoff = FALSE; - } - g_free (name); - } - while (gtk_tree_model_iter_next (node_model, &iter)); + if (!strcmp(node_name, name)) { /* found it, so highlight it */ + selection_holdoff = TRUE; + selected_net = net; + path = gtk_tree_model_get_path(node_model, &iter); + gtk_tree_view_scroll_to_cell(node_treeview, path, NULL, TRUE, 0.5, 0.5); + gtk_tree_selection_select_path(gtk_tree_view_get_selection(node_treeview), path); + selection_holdoff = FALSE; + } + g_free(name); + } + while (gtk_tree_model_iter_next(node_model, &iter)); } /* If code in PCB should change the netlist, call this to update | what's in the netlist window. */ -void -ghid_netlist_window_update (gboolean init_nodes) +void ghid_netlist_window_update(gboolean init_nodes) { - GtkTreeModel *model; + GtkTreeModel *model; - /* Make sure there is something to update */ - ghid_netlist_window_create (gport); + /* Make sure there is something to update */ + ghid_netlist_window_create(gport); - model = net_model; - net_model = net_model_create (); - gtk_tree_view_set_model (net_treeview, net_model); - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (net_model), - NET_NAME_COLUMN, GTK_SORT_ASCENDING); - if (model) - { - gtk_tree_store_clear (GTK_TREE_STORE (model)); - g_object_unref (model); - } + model = net_model; + net_model = net_model_create(); + gtk_tree_view_set_model(net_treeview, net_model); + gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(net_model), NET_NAME_COLUMN, GTK_SORT_ASCENDING); + if (model) { + gtk_tree_store_clear(GTK_TREE_STORE(model)); + g_object_unref(model); + } - selected_net = NULL; + selected_net = NULL; - /* XXX Check if the select callback does this for us */ - if (init_nodes) - node_model_update ((&PCB->NetlistLib[NETLIST_EDITED])->Menu); + /* XXX Check if the select callback does this for us */ + if (init_nodes) + node_model_update((&PCB->NetlistLib[NETLIST_EDITED])->Menu); } -static gint -GhidNetlistChanged (int argc, char **argv, Coord x, Coord y) +static gint GhidNetlistChanged(int argc, char **argv, Coord x, Coord y) { - loading_new_netlist = TRUE; - ghid_netlist_window_update (TRUE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (disable_all_button), - FALSE); - loading_new_netlist = FALSE; - return 0; + loading_new_netlist = TRUE; + ghid_netlist_window_update(TRUE); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(disable_all_button), FALSE); + loading_new_netlist = FALSE; + return 0; } -static const char netlistshow_syntax[] = -"NetlistShow(pinname|netname)"; +static const char netlistshow_syntax[] = "NetlistShow(pinname|netname)"; -static const char netlistshow_help[] = -"Selects the given pinname or netname in the netlist window. Does not \ +static const char netlistshow_help[] = "Selects the given pinname or netname in the netlist window. Does not \ show the window if it isn't already shown."; -static gint -GhidNetlistShow (int argc, char **argv, Coord x, Coord y) +static gint GhidNetlistShow(int argc, char **argv, Coord x, Coord y) { - ghid_netlist_window_create (gport); - if (argc > 0) - ghid_netlist_highlight_node(argv[0]); - return 0; + ghid_netlist_window_create(gport); + if (argc > 0) + ghid_netlist_highlight_node(argv[0]); + return 0; } -static const char netlistpresent_syntax[] = -"NetlistPresent()"; +static const char netlistpresent_syntax[] = "NetlistPresent()"; -static const char netlistpresent_help[] = -"Presents the netlist window."; +static const char netlistpresent_help[] = "Presents the netlist window."; -static gint -GhidNetlistPresent (int argc, char **argv, Coord x, Coord y) +static gint GhidNetlistPresent(int argc, char **argv, Coord x, Coord y) { - ghid_netlist_window_show (gport, TRUE); - return 0; + ghid_netlist_window_show(gport, TRUE); + return 0; } HID_Action ghid_netlist_action_list[] = { - {"NetlistChanged", 0, GhidNetlistChanged, - netlistchanged_help, netlistchanged_syntax}, - {"NetlistShow", 0, GhidNetlistShow, - netlistshow_help, netlistshow_syntax}, - {"NetlistPresent", 0, GhidNetlistPresent, - netlistpresent_help, netlistpresent_syntax} - , + {"NetlistChanged", 0, GhidNetlistChanged, + netlistchanged_help, netlistchanged_syntax} + , + {"NetlistShow", 0, GhidNetlistShow, + netlistshow_help, netlistshow_syntax} + , + {"NetlistPresent", 0, GhidNetlistPresent, + netlistpresent_help, netlistpresent_syntax} + , }; -REGISTER_ACTIONS (ghid_netlist_action_list) +REGISTER_ACTIONS(ghid_netlist_action_list) Index: trunk/src/hid/gtk/gui-output-events.c =================================================================== --- trunk/src/hid/gtk/gui-output-events.c (revision 1021) +++ trunk/src/hid/gtk/gui-output-events.c (revision 1022) @@ -50,54 +50,50 @@ #define TOOLTIP_UPDATE_DELAY 200 -void -ghid_port_ranges_changed (void) +void ghid_port_ranges_changed(void) { - GtkAdjustment *h_adj, *v_adj; + GtkAdjustment *h_adj, *v_adj; - h_adj = gtk_range_get_adjustment (GTK_RANGE (ghidgui->h_range)); - v_adj = gtk_range_get_adjustment (GTK_RANGE (ghidgui->v_range)); - gport->view.x0 = gtk_adjustment_get_value (h_adj); - gport->view.y0 = gtk_adjustment_get_value (v_adj); + h_adj = gtk_range_get_adjustment(GTK_RANGE(ghidgui->h_range)); + v_adj = gtk_range_get_adjustment(GTK_RANGE(ghidgui->v_range)); + gport->view.x0 = gtk_adjustment_get_value(h_adj); + gport->view.y0 = gtk_adjustment_get_value(v_adj); - ghid_invalidate_all (); + ghid_invalidate_all(); } /* Do scrollbar scaling based on current port drawing area size and | overall PCB board size. */ -void -ghid_port_ranges_scale (void) +void ghid_port_ranges_scale(void) { - GtkAdjustment *adj; - gdouble page_size; + GtkAdjustment *adj; + gdouble page_size; - /* Update the scrollbars with PCB units. So Scale the current - | drawing area size in pixels to PCB units and that will be - | the page size for the Gtk adjustment. - */ - gport->view.width = gport->width * gport->view.coord_per_px; - gport->view.height = gport->height * gport->view.coord_per_px; + /* Update the scrollbars with PCB units. So Scale the current + | drawing area size in pixels to PCB units and that will be + | the page size for the Gtk adjustment. + */ + gport->view.width = gport->width * gport->view.coord_per_px; + gport->view.height = gport->height * gport->view.coord_per_px; - adj = gtk_range_get_adjustment (GTK_RANGE (ghidgui->h_range)); - page_size = MIN (gport->view.width, PCB->MaxWidth); - gtk_adjustment_configure (adj, - gtk_adjustment_get_value (adj), /* value */ - -gport->view.width, /* lower */ - PCB->MaxWidth + page_size, /* upper */ - page_size / 100.0, /* step_increment */ - page_size / 10.0, /* page_increment */ - page_size); /* page_size */ + adj = gtk_range_get_adjustment(GTK_RANGE(ghidgui->h_range)); + page_size = MIN(gport->view.width, PCB->MaxWidth); + gtk_adjustment_configure(adj, gtk_adjustment_get_value(adj), /* value */ + -gport->view.width, /* lower */ + PCB->MaxWidth + page_size, /* upper */ + page_size / 100.0, /* step_increment */ + page_size / 10.0, /* page_increment */ + page_size); /* page_size */ - adj = gtk_range_get_adjustment (GTK_RANGE (ghidgui->v_range)); - page_size = MIN (gport->view.height, PCB->MaxHeight); - gtk_adjustment_configure (adj, - gtk_adjustment_get_value (adj), /* value */ - -gport->view.height, /* lower */ - PCB->MaxHeight + page_size, /* upper */ - page_size / 100.0, /* step_increment */ - page_size / 10.0, /* page_increment */ - page_size); /* page_size */ + adj = gtk_range_get_adjustment(GTK_RANGE(ghidgui->v_range)); + page_size = MIN(gport->view.height, PCB->MaxHeight); + gtk_adjustment_configure(adj, gtk_adjustment_get_value(adj), /* value */ + -gport->view.height, /* lower */ + PCB->MaxHeight + page_size, /* upper */ + page_size / 100.0, /* step_increment */ + page_size / 10.0, /* page_increment */ + page_size); /* page_size */ } @@ -105,76 +101,65 @@ * handles all events from PCB drawing area */ -void -ghid_get_coords (const char *msg, Coord *x, Coord *y) +void ghid_get_coords(const char *msg, Coord * x, Coord * y) { - if (!ghid_port.has_entered && msg) - ghid_get_user_xy (msg); - if (ghid_port.has_entered) - { - *x = gport->pcb_x; - *y = gport->pcb_y; - } + if (!ghid_port.has_entered && msg) + ghid_get_user_xy(msg); + if (ghid_port.has_entered) { + *x = gport->pcb_x; + *y = gport->pcb_y; + } } -gboolean -ghid_note_event_location (GdkEventButton * ev) +gboolean ghid_note_event_location(GdkEventButton * ev) { - gint event_x, event_y; - gboolean moved; + gint event_x, event_y; + gboolean moved; - if (!ev) - { - gdk_window_get_pointer (gtk_widget_get_window (ghid_port.drawing_area), - &event_x, &event_y, NULL); - } - else - { - event_x = ev->x; - event_y = ev->y; - } + if (!ev) { + gdk_window_get_pointer(gtk_widget_get_window(ghid_port.drawing_area), &event_x, &event_y, NULL); + } + else { + event_x = ev->x; + event_y = ev->y; + } - ghid_event_to_pcb_coords (event_x, event_y, &gport->pcb_x, &gport->pcb_y); + ghid_event_to_pcb_coords(event_x, event_y, &gport->pcb_x, &gport->pcb_y); - moved = MoveCrosshairAbsolute (gport->pcb_x, gport->pcb_y); - if (moved) - { - AdjustAttachedObjects (); - notify_crosshair_change (true); - } - ghid_set_cursor_position_labels (); - return moved; + moved = MoveCrosshairAbsolute(gport->pcb_x, gport->pcb_y); + if (moved) { + AdjustAttachedObjects(); + notify_crosshair_change(true); + } + ghid_set_cursor_position_labels(); + return moved; } -static gboolean -ghid_idle_cb (gpointer data) +static gboolean ghid_idle_cb(gpointer data) { - if (Settings.Mode == NO_MODE) - SetMode (ARROW_MODE); - ghid_mode_cursor (Settings.Mode); - if (ghidgui->settings_mode != Settings.Mode) - { - ghid_mode_buttons_update (); - } - ghidgui->settings_mode = Settings.Mode; + if (Settings.Mode == NO_MODE) + SetMode(ARROW_MODE); + ghid_mode_cursor(Settings.Mode); + if (ghidgui->settings_mode != Settings.Mode) { + ghid_mode_buttons_update(); + } + ghidgui->settings_mode = Settings.Mode; - ghid_update_toggle_flags (); - return FALSE; + ghid_update_toggle_flags(); + return FALSE; } -gboolean -ghid_port_key_release_cb (GtkWidget * drawing_area, GdkEventKey * kev, - gpointer data) +gboolean ghid_port_key_release_cb(GtkWidget * drawing_area, GdkEventKey * kev, gpointer data) { - gint ksym = kev->keyval; + gint ksym = kev->keyval; - if (ghid_is_modifier_key_sym (ksym)) - ghid_note_event_location (NULL); + if (ghid_is_modifier_key_sym(ksym)) + ghid_note_event_location(NULL); - AdjustAttachedObjects (); - ghid_invalidate_all (); - g_idle_add (ghid_idle_cb, NULL); - return FALSE; + AdjustAttachedObjects(); + ghid_invalidate_all(); + g_idle_add(ghid_idle_cb, NULL); + return FALSE; } /* Handle user keys in the output drawing area. @@ -188,298 +173,278 @@ * arrow keys) and feed it back to the normal menu callback. */ -gboolean -ghid_port_key_press_cb (GtkWidget * drawing_area, - GdkEventKey * kev, gpointer data) +gboolean ghid_port_key_press_cb(GtkWidget * drawing_area, GdkEventKey * kev, gpointer data) { - ModifierKeysState mk; - gint ksym = kev->keyval; - gboolean handled; - extern void ghid_hotkey_cb (int); - GdkModifierType state; + ModifierKeysState mk; + gint ksym = kev->keyval; + gboolean handled; + extern void ghid_hotkey_cb(int); + GdkModifierType state; - if (ghid_is_modifier_key_sym (ksym)) - ghid_note_event_location (NULL); + if (ghid_is_modifier_key_sym(ksym)) + ghid_note_event_location(NULL); - state = (GdkModifierType) (kev->state); - mk = ghid_modifier_keys_state (&state); + state = (GdkModifierType) (kev->state); + mk = ghid_modifier_keys_state(&state); - handled = TRUE; /* Start off assuming we handle it */ - switch (ksym) - { - case GDK_Alt_L: - case GDK_Alt_R: - case GDK_Control_L: - case GDK_Control_R: - case GDK_Shift_L: - case GDK_Shift_R: - case GDK_Shift_Lock: - case GDK_ISO_Level3_Shift: - break; + handled = TRUE; /* Start off assuming we handle it */ + switch (ksym) { + case GDK_Alt_L: + case GDK_Alt_R: + case GDK_Control_L: + case GDK_Control_R: + case GDK_Shift_L: + case GDK_Shift_R: + case GDK_Shift_Lock: + case GDK_ISO_Level3_Shift: + break; - case GDK_Up: - ghid_hotkey_cb (GHID_KEY_UP); - break; - - case GDK_Down: - ghid_hotkey_cb (GHID_KEY_DOWN); - break; - case GDK_Left: - ghid_hotkey_cb (GHID_KEY_LEFT); - break; - case GDK_Right: - ghid_hotkey_cb (GHID_KEY_RIGHT); - break; + case GDK_Up: + ghid_hotkey_cb(GHID_KEY_UP); + break; - case GDK_ISO_Left_Tab: - case GDK_3270_BackTab: - switch (mk) - { - case NONE_PRESSED: - ghid_hotkey_cb (GHID_KEY_SHIFT | GHID_KEY_TAB); - break; - case CONTROL_PRESSED: - ghid_hotkey_cb (GHID_KEY_CONTROL | GHID_KEY_SHIFT | GHID_KEY_TAB); - break; - case MOD1_PRESSED: - ghid_hotkey_cb (GHID_KEY_ALT | GHID_KEY_SHIFT | GHID_KEY_TAB); - break; - case SHIFT_PRESSED: - ghid_hotkey_cb (GHID_KEY_SHIFT | GHID_KEY_TAB); - break; - case SHIFT_CONTROL_PRESSED: - ghid_hotkey_cb (GHID_KEY_CONTROL | GHID_KEY_SHIFT | GHID_KEY_TAB); - break; - case SHIFT_MOD1_PRESSED: - ghid_hotkey_cb (GHID_KEY_ALT | GHID_KEY_SHIFT | GHID_KEY_TAB); - break; - - default: - handled = FALSE; - break; - } - break; + case GDK_Down: + ghid_hotkey_cb(GHID_KEY_DOWN); + break; + case GDK_Left: + ghid_hotkey_cb(GHID_KEY_LEFT); + break; + case GDK_Right: + ghid_hotkey_cb(GHID_KEY_RIGHT); + break; - case GDK_Tab: - switch (mk) - { - case NONE_PRESSED: - ghid_hotkey_cb (GHID_KEY_TAB); - break; - case CONTROL_PRESSED: - ghid_hotkey_cb (GHID_KEY_CONTROL | GHID_KEY_TAB); - break; - case MOD1_PRESSED: - ghid_hotkey_cb (GHID_KEY_ALT | GHID_KEY_TAB); - break; - case SHIFT_PRESSED: - ghid_hotkey_cb (GHID_KEY_SHIFT | GHID_KEY_TAB); - break; - case SHIFT_CONTROL_PRESSED: - ghid_hotkey_cb (GHID_KEY_CONTROL | GHID_KEY_SHIFT | GHID_KEY_TAB); - break; - case SHIFT_MOD1_PRESSED: - ghid_hotkey_cb (GHID_KEY_ALT | GHID_KEY_SHIFT | GHID_KEY_TAB); - break; - + case GDK_ISO_Left_Tab: + case GDK_3270_BackTab: + switch (mk) { + case NONE_PRESSED: + ghid_hotkey_cb(GHID_KEY_SHIFT | GHID_KEY_TAB); + break; + case CONTROL_PRESSED: + ghid_hotkey_cb(GHID_KEY_CONTROL | GHID_KEY_SHIFT | GHID_KEY_TAB); + break; + case MOD1_PRESSED: + ghid_hotkey_cb(GHID_KEY_ALT | GHID_KEY_SHIFT | GHID_KEY_TAB); + break; + case SHIFT_PRESSED: + ghid_hotkey_cb(GHID_KEY_SHIFT | GHID_KEY_TAB); + break; + case SHIFT_CONTROL_PRESSED: + ghid_hotkey_cb(GHID_KEY_CONTROL | GHID_KEY_SHIFT | GHID_KEY_TAB); + break; + case SHIFT_MOD1_PRESSED: + ghid_hotkey_cb(GHID_KEY_ALT | GHID_KEY_SHIFT | GHID_KEY_TAB); + break; + + default: + handled = FALSE; + break; + } + break; + + case GDK_Tab: + switch (mk) { + case NONE_PRESSED: + ghid_hotkey_cb(GHID_KEY_TAB); + break; + case CONTROL_PRESSED: + ghid_hotkey_cb(GHID_KEY_CONTROL | GHID_KEY_TAB); + break; + case MOD1_PRESSED: + ghid_hotkey_cb(GHID_KEY_ALT | GHID_KEY_TAB); + break; + case SHIFT_PRESSED: + ghid_hotkey_cb(GHID_KEY_SHIFT | GHID_KEY_TAB); + break; + case SHIFT_CONTROL_PRESSED: + ghid_hotkey_cb(GHID_KEY_CONTROL | GHID_KEY_SHIFT | GHID_KEY_TAB); + break; + case SHIFT_MOD1_PRESSED: + ghid_hotkey_cb(GHID_KEY_ALT | GHID_KEY_SHIFT | GHID_KEY_TAB); + break; + + default: + handled = FALSE; + break; + } + break; + default: - handled = FALSE; - break; + handled = FALSE; } - break; - default: - handled = FALSE; - } - - return handled; + return handled; } -gboolean -ghid_port_button_press_cb (GtkWidget * drawing_area, - GdkEventButton * ev, gpointer data) +gboolean ghid_port_button_press_cb(GtkWidget * drawing_area, GdkEventButton * ev, gpointer data) { - ModifierKeysState mk; - GdkModifierType state; + ModifierKeysState mk; + GdkModifierType state; - /* Reject double and triple click events */ - if (ev->type != GDK_BUTTON_PRESS) return TRUE; + /* Reject double and triple click events */ + if (ev->type != GDK_BUTTON_PRESS) + return TRUE; - ghid_note_event_location (ev); - state = (GdkModifierType) (ev->state); - mk = ghid_modifier_keys_state (&state); + ghid_note_event_location(ev); + state = (GdkModifierType) (ev->state); + mk = ghid_modifier_keys_state(&state); - do_mouse_action(ev->button, mk); + do_mouse_action(ev->button, mk); - ghid_invalidate_all (); - ghid_window_set_name_label (PCB->Name); - ghid_set_status_line_label (); - if (!gport->panning) - g_idle_add (ghid_idle_cb, NULL); - return TRUE; + ghid_invalidate_all(); + ghid_window_set_name_label(PCB->Name); + ghid_set_status_line_label(); + if (!gport->panning) + g_idle_add(ghid_idle_cb, NULL); + return TRUE; } -gboolean -ghid_port_button_release_cb (GtkWidget * drawing_area, - GdkEventButton * ev, gpointer data) +gboolean ghid_port_button_release_cb(GtkWidget * drawing_area, GdkEventButton * ev, gpointer data) { - ModifierKeysState mk; - GdkModifierType state; + ModifierKeysState mk; + GdkModifierType state; - ghid_note_event_location (ev); - state = (GdkModifierType) (ev->state); - mk = ghid_modifier_keys_state (&state); + ghid_note_event_location(ev); + state = (GdkModifierType) (ev->state); + mk = ghid_modifier_keys_state(&state); - do_mouse_action(ev->button, mk + M_Release); + do_mouse_action(ev->button, mk + M_Release); - AdjustAttachedObjects (); - ghid_invalidate_all (); + AdjustAttachedObjects(); + ghid_invalidate_all(); - ghid_window_set_name_label (PCB->Name); - ghid_set_status_line_label (); - g_idle_add (ghid_idle_cb, NULL); - return TRUE; + ghid_window_set_name_label(PCB->Name); + ghid_set_status_line_label(); + g_idle_add(ghid_idle_cb, NULL); + return TRUE; } -gboolean -ghid_port_drawing_area_configure_event_cb (GtkWidget * widget, - GdkEventConfigure * ev, - GHidPort * out) +gboolean ghid_port_drawing_area_configure_event_cb(GtkWidget * widget, GdkEventConfigure * ev, GHidPort * out) { - static gboolean first_time_done; + static gboolean first_time_done; - gport->width = ev->width; - gport->height = ev->height; + gport->width = ev->width; + gport->height = ev->height; - if (gport->pixmap) - gdk_pixmap_unref (gport->pixmap); + if (gport->pixmap) + gdk_pixmap_unref(gport->pixmap); - gport->pixmap = gdk_pixmap_new (gtk_widget_get_window (widget), - gport->width, gport->height, -1); - gport->drawable = gport->pixmap; + gport->pixmap = gdk_pixmap_new(gtk_widget_get_window(widget), gport->width, gport->height, -1); + gport->drawable = gport->pixmap; - if (!first_time_done) - { - gport->colormap = gtk_widget_get_colormap (gport->top_window); - if (gdk_color_parse (Settings.BackgroundColor, &gport->bg_color)) - gdk_color_alloc (gport->colormap, &gport->bg_color); - else - gdk_color_white (gport->colormap, &gport->bg_color); + if (!first_time_done) { + gport->colormap = gtk_widget_get_colormap(gport->top_window); + if (gdk_color_parse(Settings.BackgroundColor, &gport->bg_color)) + gdk_color_alloc(gport->colormap, &gport->bg_color); + else + gdk_color_white(gport->colormap, &gport->bg_color); - if (gdk_color_parse (Settings.OffLimitColor, &gport->offlimits_color)) - gdk_color_alloc (gport->colormap, &gport->offlimits_color); - else - gdk_color_white (gport->colormap, &gport->offlimits_color); - first_time_done = TRUE; - ghid_drawing_area_configure_hook (out); - PCBChanged (0, NULL, 0, 0); - } - else - { - ghid_drawing_area_configure_hook (out); - } + if (gdk_color_parse(Settings.OffLimitColor, &gport->offlimits_color)) + gdk_color_alloc(gport->colormap, &gport->offlimits_color); + else + gdk_color_white(gport->colormap, &gport->offlimits_color); + first_time_done = TRUE; + ghid_drawing_area_configure_hook(out); + PCBChanged(0, NULL, 0, 0); + } + else { + ghid_drawing_area_configure_hook(out); + } - ghid_port_ranges_scale (); - ghid_invalidate_all (); - return 0; + ghid_port_ranges_scale(); + ghid_invalidate_all(); + return 0; } -static char * -describe_location (Coord X, Coord Y) +static char *describe_location(Coord X, Coord Y) { - void *ptr1, *ptr2, *ptr3; - int type; - int Range = 0; - char *elename = ""; - char *pinname; - char *netname = NULL; - char *description; + void *ptr1, *ptr2, *ptr3; + int type; + int Range = 0; + char *elename = ""; + char *pinname; + char *netname = NULL; + char *description; - /* check if there are any pins or pads at that position */ + /* check if there are any pins or pads at that position */ - type = SearchObjectByLocation (PIN_TYPE | PAD_TYPE, - &ptr1, &ptr2, &ptr3, X, Y, Range); - if (type == NO_TYPE) - return NULL; + type = SearchObjectByLocation(PIN_TYPE | PAD_TYPE, &ptr1, &ptr2, &ptr3, X, Y, Range); + if (type == NO_TYPE) + return NULL; - /* don't mess with silk objects! */ - if (type & SILK_TYPE && - GetLayerNumber (PCB->Data, (LayerTypePtr) ptr1) >= max_copper_layer) - return NULL; + /* don't mess with silk objects! */ + if (type & SILK_TYPE && GetLayerNumber(PCB->Data, (LayerTypePtr) ptr1) >= max_copper_layer) + return NULL; - if (type == PIN_TYPE || type == PAD_TYPE) - elename = (char *)UNKNOWN (NAMEONPCB_NAME ((ElementTypePtr) ptr1)); + if (type == PIN_TYPE || type == PAD_TYPE) + elename = (char *) UNKNOWN(NAMEONPCB_NAME((ElementTypePtr) ptr1)); - pinname = ConnectionName (type, ptr1, ptr2); + pinname = ConnectionName(type, ptr1, ptr2); - if (pinname == NULL) - return NULL; + if (pinname == NULL) + return NULL; - /* Find netlist entry */ - MENU_LOOP (&PCB->NetlistLib[NETLIST_EDITED]); - { - if (!menu->Name) - continue; + /* Find netlist entry */ + MENU_LOOP(&PCB->NetlistLib[NETLIST_EDITED]); + { + if (!menu->Name) + continue; - ENTRY_LOOP (menu); - { - if (!entry->ListEntry) - continue; + ENTRY_LOOP(menu); + { + if (!entry->ListEntry) + continue; - if (strcmp (entry->ListEntry, pinname) == 0) { - netname = g_strdup (menu->Name); - /* For some reason, the netname has spaces in front of it, strip them */ - g_strstrip (netname); - break; - } - } - END_LOOP; + if (strcmp(entry->ListEntry, pinname) == 0) { + netname = g_strdup(menu->Name); + /* For some reason, the netname has spaces in front of it, strip them */ + g_strstrip(netname); + break; + } + } + END_LOOP; - if (netname != NULL) - break; - } - END_LOOP; + if (netname != NULL) + break; + } + END_LOOP; - description = g_strdup_printf ("Element name: %s\n" - "Pinname : %s\n" - "Netname : %s", - elename, - (pinname != NULL) ? pinname : "--", - (netname != NULL) ? netname : "--"); + description = g_strdup_printf("Element name: %s\n" + "Pinname : %s\n" + "Netname : %s", + elename, (pinname != NULL) ? pinname : "--", (netname != NULL) ? netname : "--"); - g_free (netname); + g_free(netname); - return description; + return description; } -static gboolean check_object_tooltips (GHidPort *out) +static gboolean check_object_tooltips(GHidPort * out) { - char *description; + char *description; - /* check if there are any pins or pads at that position */ - description = describe_location (out->crosshair_x, out->crosshair_y); + /* check if there are any pins or pads at that position */ + description = describe_location(out->crosshair_x, out->crosshair_y); - if (description == NULL) - return FALSE; + if (description == NULL) + return FALSE; - gtk_widget_set_tooltip_text (out->drawing_area, description); - g_free (description); + gtk_widget_set_tooltip_text(out->drawing_area, description); + g_free(description); - return FALSE; + return FALSE; } static int tooltip_update_timeout_id = 0; -static void -cancel_tooltip_update () +static void cancel_tooltip_update() { - if (tooltip_update_timeout_id) - g_source_remove (tooltip_update_timeout_id); - tooltip_update_timeout_id = 0; + if (tooltip_update_timeout_id) + g_source_remove(tooltip_update_timeout_id); + tooltip_update_timeout_id = 0; } /* FIXME: If the GHidPort is ever destroyed, we must call @@ -486,135 +451,126 @@ * cancel_tooltip_update (), otherwise the timeout might * fire after the data it utilises has been free'd. */ -static void -queue_tooltip_update (GHidPort *out) +static void queue_tooltip_update(GHidPort * out) { - /* Zap the old tool-tip text and force it to be removed from the screen */ - gtk_widget_set_tooltip_text (out->drawing_area, NULL); - gtk_widget_trigger_tooltip_query (out->drawing_area); + /* Zap the old tool-tip text and force it to be removed from the screen */ + gtk_widget_set_tooltip_text(out->drawing_area, NULL); + gtk_widget_trigger_tooltip_query(out->drawing_area); - cancel_tooltip_update (); + cancel_tooltip_update(); - tooltip_update_timeout_id = - g_timeout_add (TOOLTIP_UPDATE_DELAY, - (GSourceFunc) check_object_tooltips, - out); + tooltip_update_timeout_id = g_timeout_add(TOOLTIP_UPDATE_DELAY, (GSourceFunc) check_object_tooltips, out); } -gint -ghid_port_window_motion_cb (GtkWidget * widget, - GdkEventMotion * ev, GHidPort * out) +gint ghid_port_window_motion_cb(GtkWidget * widget, GdkEventMotion * ev, GHidPort * out) { - gdouble dx, dy; - static gint x_prev = -1, y_prev = -1; + gdouble dx, dy; + static gint x_prev = -1, y_prev = -1; - gdk_event_request_motions (ev); + gdk_event_request_motions(ev); - if (out->panning) - { - dx = gport->view.coord_per_px * (x_prev - ev->x); - dy = gport->view.coord_per_px * (y_prev - ev->y); - if (x_prev > 0) - ghid_pan_view_rel (dx, dy); - x_prev = ev->x; - y_prev = ev->y; - return FALSE; - } - x_prev = y_prev = -1; - ghid_note_event_location ((GdkEventButton *)ev); + if (out->panning) { + dx = gport->view.coord_per_px * (x_prev - ev->x); + dy = gport->view.coord_per_px * (y_prev - ev->y); + if (x_prev > 0) + ghid_pan_view_rel(dx, dy); + x_prev = ev->x; + y_prev = ev->y; + return FALSE; + } + x_prev = y_prev = -1; + ghid_note_event_location((GdkEventButton *) ev); - queue_tooltip_update (out); + queue_tooltip_update(out); - return FALSE; + return FALSE; } -gint -ghid_port_window_enter_cb (GtkWidget * widget, - GdkEventCrossing * ev, GHidPort * out) +gint ghid_port_window_enter_cb(GtkWidget * widget, GdkEventCrossing * ev, GHidPort * out) { - /* printf("enter: mode: %d detail: %d\n", ev->mode, ev->detail); */ + /* printf("enter: mode: %d detail: %d\n", ev->mode, ev->detail); */ - /* See comment in ghid_port_window_leave_cb() */ + /* See comment in ghid_port_window_leave_cb() */ - if(ev->mode != GDK_CROSSING_NORMAL && ev->detail != GDK_NOTIFY_NONLINEAR) - { - return FALSE; - } + if (ev->mode != GDK_CROSSING_NORMAL && ev->detail != GDK_NOTIFY_NONLINEAR) { + return FALSE; + } - if (!ghidgui->command_entry_status_line_active) - { - out->has_entered = TRUE; - /* Make sure drawing area has keyboard focus when we are in it. - */ - gtk_widget_grab_focus (out->drawing_area); - } - ghidgui->in_popup = FALSE; + if (!ghidgui->command_entry_status_line_active) { + out->has_entered = TRUE; + /* Make sure drawing area has keyboard focus when we are in it. + */ + gtk_widget_grab_focus(out->drawing_area); + } + ghidgui->in_popup = FALSE; - /* Following expression is true if a you open a menu from the menu bar, - * move the mouse to the viewport and click on it. This closes the menu - * and moves the pointer to the viewport without the pointer going over - * the edge of the viewport */ - if(ev->mode == GDK_CROSSING_UNGRAB && ev->detail == GDK_NOTIFY_NONLINEAR) - { - ghid_screen_update (); - } - return FALSE; + /* Following expression is true if a you open a menu from the menu bar, + * move the mouse to the viewport and click on it. This closes the menu + * and moves the pointer to the viewport without the pointer going over + * the edge of the viewport */ + if (ev->mode == GDK_CROSSING_UNGRAB && ev->detail == GDK_NOTIFY_NONLINEAR) { + ghid_screen_update(); + } + return FALSE; } -gint -ghid_port_window_leave_cb (GtkWidget * widget, - GdkEventCrossing * ev, GHidPort * out) +gint ghid_port_window_leave_cb(GtkWidget * widget, GdkEventCrossing * ev, GHidPort * out) { - /* printf("leave mode: %d detail: %d\n", ev->mode, ev->detail); */ + /* printf("leave mode: %d detail: %d\n", ev->mode, ev->detail); */ - /* Window leave events can also be triggered because of focus grabs. Some - * X applications occasionally grab the focus and so trigger this function. - * At least GNOME's window manager is known to do this on every mouse click. - * - * See http://bugzilla.gnome.org/show_bug.cgi?id=102209 - */ + /* Window leave events can also be triggered because of focus grabs. Some + * X applications occasionally grab the focus and so trigger this function. + * At least GNOME's window manager is known to do this on every mouse click. + * + * See http://bugzilla.gnome.org/show_bug.cgi?id=102209 + */ - if(ev->mode != GDK_CROSSING_NORMAL) - { - return FALSE; - } + if (ev->mode != GDK_CROSSING_NORMAL) { + return FALSE; + } - out->has_entered = FALSE; + out->has_entered = FALSE; - ghid_screen_update (); + ghid_screen_update(); - return FALSE; + return FALSE; } - /* Mouse scroll wheel events - */ -gint -ghid_port_window_mouse_scroll_cb (GtkWidget * widget, - GdkEventScroll * ev, GHidPort * out) + /* Mouse scroll wheel events + */ +gint ghid_port_window_mouse_scroll_cb(GtkWidget * widget, GdkEventScroll * ev, GHidPort * out) { - ModifierKeysState mk; - GdkModifierType state; - int button; + ModifierKeysState mk; + GdkModifierType state; + int button; - state = (GdkModifierType) (ev->state); - mk = ghid_modifier_keys_state (&state); + state = (GdkModifierType) (ev->state); + mk = ghid_modifier_keys_state(&state); - /* X11 gtk hard codes buttons 4, 5, 6, 7 as below in - * gtk+/gdk/x11/gdkevents-x11.c:1121, but quartz and windows have - * special mouse scroll events, so this may conflict with a mouse - * who has buttons 4 - 7 that aren't the scroll wheel? - */ - switch(ev->direction) - { - case GDK_SCROLL_UP: button = 4; break; - case GDK_SCROLL_DOWN: button = 5; break; - case GDK_SCROLL_LEFT: button = 6; break; - case GDK_SCROLL_RIGHT: button = 7; break; - default: button = -1; - } + /* X11 gtk hard codes buttons 4, 5, 6, 7 as below in + * gtk+/gdk/x11/gdkevents-x11.c:1121, but quartz and windows have + * special mouse scroll events, so this may conflict with a mouse + * who has buttons 4 - 7 that aren't the scroll wheel? + */ + switch (ev->direction) { + case GDK_SCROLL_UP: + button = 4; + break; + case GDK_SCROLL_DOWN: + button = 5; + break; + case GDK_SCROLL_LEFT: + button = 6; + break; + case GDK_SCROLL_RIGHT: + button = 7; + break; + default: + button = -1; + } - do_mouse_action(button, mk); + do_mouse_action(button, mk); - return TRUE; + return TRUE; } Index: trunk/src/hid/gtk/gui-pinout-preview.c =================================================================== --- trunk/src/hid/gtk/gui-pinout-preview.c (revision 1021) +++ trunk/src/hid/gtk/gui-pinout-preview.c (revision 1022) @@ -47,85 +47,77 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); /* Just define a sensible scale, lets say (for example), 100 pixel per 150 mil */ #define SENSIBLE_VIEW_SCALE (100. / MIL_TO_COORD (150.)) -static void -pinout_set_view (GhidPinoutPreview * pinout) +static void pinout_set_view(GhidPinoutPreview * pinout) { - float scale = SENSIBLE_VIEW_SCALE; + float scale = SENSIBLE_VIEW_SCALE; - pinout->x_max = pinout->element.BoundingBox.X2 + Settings.PinoutOffsetX; - pinout->y_max = pinout->element.BoundingBox.Y2 + Settings.PinoutOffsetY; - pinout->w_pixels = scale * (pinout->element.BoundingBox.X2 - - pinout->element.BoundingBox.X1); - pinout->h_pixels = scale * (pinout->element.BoundingBox.Y2 - - pinout->element.BoundingBox.Y1); + pinout->x_max = pinout->element.BoundingBox.X2 + Settings.PinoutOffsetX; + pinout->y_max = pinout->element.BoundingBox.Y2 + Settings.PinoutOffsetY; + pinout->w_pixels = scale * (pinout->element.BoundingBox.X2 - pinout->element.BoundingBox.X1); + pinout->h_pixels = scale * (pinout->element.BoundingBox.Y2 - pinout->element.BoundingBox.Y1); } -static void -pinout_set_data (GhidPinoutPreview * pinout, ElementType * element) +static void pinout_set_data(GhidPinoutPreview * pinout, ElementType * element) { - if (element == NULL) - { - FreeElementMemory (&pinout->element); - pinout->w_pixels = 0; - pinout->h_pixels = 0; - return; - } + if (element == NULL) { + FreeElementMemory(&pinout->element); + pinout->w_pixels = 0; + pinout->h_pixels = 0; + return; + } - /* - * copy element data - * enable output of pin and padnames - * move element to a 5% offset from zero position - * set all package lines/arcs to zero width - */ - CopyElementLowLevel (NULL, &pinout->element, element, FALSE, 0, 0); - PIN_LOOP (&pinout->element); - { - SET_FLAG (DISPLAYNAMEFLAG, pin); - } - END_LOOP; + /* + * copy element data + * enable output of pin and padnames + * move element to a 5% offset from zero position + * set all package lines/arcs to zero width + */ + CopyElementLowLevel(NULL, &pinout->element, element, FALSE, 0, 0); + PIN_LOOP(&pinout->element); + { + SET_FLAG(DISPLAYNAMEFLAG, pin); + } + END_LOOP; - PAD_LOOP (&pinout->element); - { - SET_FLAG (DISPLAYNAMEFLAG, pad); - } - END_LOOP; + PAD_LOOP(&pinout->element); + { + SET_FLAG(DISPLAYNAMEFLAG, pad); + } + END_LOOP; - MoveElementLowLevel (NULL, &pinout->element, - Settings.PinoutOffsetX - - pinout->element.BoundingBox.X1, - Settings.PinoutOffsetY - - pinout->element.BoundingBox.Y1); + MoveElementLowLevel(NULL, &pinout->element, + Settings.PinoutOffsetX - + pinout->element.BoundingBox.X1, Settings.PinoutOffsetY - pinout->element.BoundingBox.Y1); - pinout_set_view (pinout); + pinout_set_view(pinout); - ELEMENTLINE_LOOP (&pinout->element); - { - line->Thickness = 0; - } - END_LOOP; + ELEMENTLINE_LOOP(&pinout->element); + { + line->Thickness = 0; + } + END_LOOP; - ARC_LOOP (&pinout->element); - { - /* - * for whatever reason setting a thickness of 0 causes the arcs to - * not display so pick 1 which does display but is still quite - * thin. - */ - arc->Thickness = 1; - } - END_LOOP; + ARC_LOOP(&pinout->element); + { + /* + * for whatever reason setting a thickness of 0 causes the arcs to + * not display so pick 1 which does display but is still quite + * thin. + */ + arc->Thickness = 1; + } + END_LOOP; } -enum -{ - PROP_ELEMENT_DATA = 1, +enum { + PROP_ELEMENT_DATA = 1, }; @@ -140,14 +132,13 @@ * * \param [in] object The pinout preview object */ -static void -ghid_pinout_preview_constructed (GObject *object) +static void ghid_pinout_preview_constructed(GObject * object) { - /* chain up to the parent class */ - if (G_OBJECT_CLASS (ghid_pinout_preview_parent_class)->constructed != NULL) - G_OBJECT_CLASS (ghid_pinout_preview_parent_class)->constructed (object); + /* chain up to the parent class */ + if (G_OBJECT_CLASS(ghid_pinout_preview_parent_class)->constructed != NULL) + G_OBJECT_CLASS(ghid_pinout_preview_parent_class)->constructed(object); - ghid_init_drawing_widget (GTK_WIDGET (object), gport); + ghid_init_drawing_widget(GTK_WIDGET(object), gport); } @@ -160,15 +151,14 @@ * * \param [in] widget The GObject being finalized. */ -static void -ghid_pinout_preview_finalize (GObject * object) +static void ghid_pinout_preview_finalize(GObject * object) { - GhidPinoutPreview *pinout = GHID_PINOUT_PREVIEW (object); + GhidPinoutPreview *pinout = GHID_PINOUT_PREVIEW(object); - /* Passing NULL for element data will free the old memory */ - pinout_set_data (pinout, NULL); + /* Passing NULL for element data will free the old memory */ + pinout_set_data(pinout, NULL); - G_OBJECT_CLASS (ghid_pinout_preview_parent_class)->finalize (object); + G_OBJECT_CLASS(ghid_pinout_preview_parent_class)->finalize(object); } @@ -184,23 +174,20 @@ * \param [in] value The GValue the property is being set from * \param [in] pspec A GParamSpec describing the property being set */ -static void -ghid_pinout_preview_set_property (GObject * object, guint property_id, - const GValue * value, GParamSpec * pspec) +static void ghid_pinout_preview_set_property(GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) { - GhidPinoutPreview *pinout = GHID_PINOUT_PREVIEW (object); - GdkWindow *window = gtk_widget_get_window (GTK_WIDGET (pinout)); + GhidPinoutPreview *pinout = GHID_PINOUT_PREVIEW(object); + GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(pinout)); - switch (property_id) - { - case PROP_ELEMENT_DATA: - pinout_set_data (pinout, (ElementType *)g_value_get_pointer (value)); - if (window != NULL) - gdk_window_invalidate_rect (window, NULL, FALSE); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } + switch (property_id) { + case PROP_ELEMENT_DATA: + pinout_set_data(pinout, (ElementType *) g_value_get_pointer(value)); + if (window != NULL) + gdk_window_invalidate_rect(window, NULL, FALSE); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); + } } @@ -217,15 +204,12 @@ * \param [out] value The GValue in which to return the value of the property * \param [in] pspec A GParamSpec describing the property being got */ -static void -ghid_pinout_preview_get_property (GObject * object, guint property_id, - GValue * value, GParamSpec * pspec) +static void ghid_pinout_preview_get_property(GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { - switch (property_id) - { - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } + switch (property_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); + } } @@ -238,26 +222,22 @@ * * \param [in] klass The GhidPinoutPreviewClass we are initialising */ -static void -ghid_pinout_preview_class_init (GhidPinoutPreviewClass * klass) +static void ghid_pinout_preview_class_init(GhidPinoutPreviewClass * klass) { - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *gtk_widget_class = GTK_WIDGET_CLASS (klass); + GObjectClass *gobject_class = G_OBJECT_CLASS(klass); + GtkWidgetClass *gtk_widget_class = GTK_WIDGET_CLASS(klass); - gobject_class->finalize = ghid_pinout_preview_finalize; - gobject_class->set_property = ghid_pinout_preview_set_property; - gobject_class->get_property = ghid_pinout_preview_get_property; - gobject_class->constructed = ghid_pinout_preview_constructed; + gobject_class->finalize = ghid_pinout_preview_finalize; + gobject_class->set_property = ghid_pinout_preview_set_property; + gobject_class->get_property = ghid_pinout_preview_get_property; + gobject_class->constructed = ghid_pinout_preview_constructed; - gtk_widget_class->expose_event = ghid_pinout_preview_expose; + gtk_widget_class->expose_event = ghid_pinout_preview_expose; - ghid_pinout_preview_parent_class = (GObjectClass *)g_type_class_peek_parent (klass); + ghid_pinout_preview_parent_class = (GObjectClass *) g_type_class_peek_parent(klass); - g_object_class_install_property (gobject_class, PROP_ELEMENT_DATA, - g_param_spec_pointer ("element-data", - "", - "", - G_PARAM_WRITABLE)); + g_object_class_install_property(gobject_class, PROP_ELEMENT_DATA, + g_param_spec_pointer("element-data", "", "", G_PARAM_WRITABLE)); } @@ -270,31 +250,28 @@ * * \return the GType identifier associated with GhidPinoutPreview. */ -GType -ghid_pinout_preview_get_type () +GType ghid_pinout_preview_get_type() { - static GType ghid_pinout_preview_type = 0; + static GType ghid_pinout_preview_type = 0; - if (!ghid_pinout_preview_type) - { - static const GTypeInfo ghid_pinout_preview_info = { - sizeof (GhidPinoutPreviewClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) ghid_pinout_preview_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GhidPinoutPreview), - 0, /* n_preallocs */ - NULL, /* instance_init */ - }; + if (!ghid_pinout_preview_type) { + static const GTypeInfo ghid_pinout_preview_info = { + sizeof(GhidPinoutPreviewClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) ghid_pinout_preview_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(GhidPinoutPreview), + 0, /* n_preallocs */ + NULL, /* instance_init */ + }; - ghid_pinout_preview_type = - g_type_register_static (GTK_TYPE_DRAWING_AREA, "GhidPinoutPreview", - &ghid_pinout_preview_info, (GTypeFlags)0); - } + ghid_pinout_preview_type = + g_type_register_static(GTK_TYPE_DRAWING_AREA, "GhidPinoutPreview", &ghid_pinout_preview_info, (GTypeFlags) 0); + } - return ghid_pinout_preview_type; + return ghid_pinout_preview_type; } @@ -305,15 +282,13 @@ * * \return The GhidPinoutPreview created. */ -GtkWidget * -ghid_pinout_preview_new (ElementType * element) +GtkWidget *ghid_pinout_preview_new(ElementType * element) { - GhidPinoutPreview *pinout_preview; + GhidPinoutPreview *pinout_preview; - pinout_preview = (GhidPinoutPreview *)g_object_new (GHID_TYPE_PINOUT_PREVIEW, - "element-data", element, NULL); + pinout_preview = (GhidPinoutPreview *) g_object_new(GHID_TYPE_PINOUT_PREVIEW, "element-data", element, NULL); - return GTK_WIDGET (pinout_preview); + return GTK_WIDGET(pinout_preview); } @@ -322,10 +297,8 @@ * \par Function Description * Convenience function to query the natural size of a pinout preview */ -void -ghid_pinout_preview_get_natural_size (GhidPinoutPreview * pinout, - int *width, int *height) +void ghid_pinout_preview_get_natural_size(GhidPinoutPreview * pinout, int *width, int *height) { - *width = pinout->w_pixels; - *height = pinout->h_pixels; + *width = pinout->w_pixels; + *height = pinout->h_pixels; } Index: trunk/src/hid/gtk/gui-pinout-preview.h =================================================================== --- trunk/src/hid/gtk/gui-pinout-preview.h (revision 1021) +++ trunk/src/hid/gtk/gui-pinout-preview.h (revision 1022) @@ -42,25 +42,22 @@ typedef struct _GhidPinoutPreview GhidPinoutPreview; -struct _GhidPinoutPreviewClass -{ - GtkDrawingAreaClass parent_class; +struct _GhidPinoutPreviewClass { + GtkDrawingAreaClass parent_class; }; -struct _GhidPinoutPreview -{ - GtkDrawingArea parent_instance; +struct _GhidPinoutPreview { + GtkDrawingArea parent_instance; - ElementType element; /* element data to display */ - gint x_max, y_max; - gint w_pixels, h_pixels; /* natural size of element preview */ + ElementType element; /* element data to display */ + gint x_max, y_max; + gint w_pixels, h_pixels; /* natural size of element preview */ }; -GType ghid_pinout_preview_get_type (void); +GType ghid_pinout_preview_get_type(void); -GtkWidget *ghid_pinout_preview_new (ElementType * element); -void ghid_pinout_preview_get_natural_size (GhidPinoutPreview * pinout, - int *width, int *height); +GtkWidget *ghid_pinout_preview_new(ElementType * element); +void ghid_pinout_preview_get_natural_size(GhidPinoutPreview * pinout, int *width, int *height); #endif /* PCB_HID_GTK_GUI_PINOUT_PREVIEW_H */ Index: trunk/src/hid/gtk/gui-pinout-window.c =================================================================== --- trunk/src/hid/gtk/gui-pinout-window.c (revision 1021) +++ trunk/src/hid/gtk/gui-pinout-window.c (revision 1022) @@ -47,59 +47,52 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); -static void -pinout_close_cb (GtkWidget * widget, GtkWidget *top_window) +static void pinout_close_cb(GtkWidget * widget, GtkWidget * top_window) { - gtk_widget_destroy (top_window); + gtk_widget_destroy(top_window); } -void -ghid_pinout_window_show (GHidPort * out, ElementType * element) +void ghid_pinout_window_show(GHidPort * out, ElementType * element) { - GtkWidget *button, *vbox, *hbox, *preview, *top_window; - gchar *title; - int width, height; + GtkWidget *button, *vbox, *hbox, *preview, *top_window; + gchar *title; + int width, height; - if (!element) - return; - title = g_strdup_printf ("%s [%s,%s]", - UNKNOWN (DESCRIPTION_NAME (element)), - UNKNOWN (NAMEONPCB_NAME (element)), - UNKNOWN (VALUE_NAME (element))); + if (!element) + return; + title = g_strdup_printf("%s [%s,%s]", + UNKNOWN(DESCRIPTION_NAME(element)), UNKNOWN(NAMEONPCB_NAME(element)), UNKNOWN(VALUE_NAME(element))); - top_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (top_window), title); - g_free (title); - gtk_window_set_wmclass (GTK_WINDOW (top_window), "PCB_Pinout", "PCB"); - gtk_container_set_border_width (GTK_CONTAINER (top_window), 4); + top_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_title(GTK_WINDOW(top_window), title); + g_free(title); + gtk_window_set_wmclass(GTK_WINDOW(top_window), "PCB_Pinout", "PCB"); + gtk_container_set_border_width(GTK_CONTAINER(top_window), 4); - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (top_window), vbox); + vbox = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(top_window), vbox); - preview = ghid_pinout_preview_new (element); - gtk_box_pack_start (GTK_BOX (vbox), preview, TRUE, TRUE, 0); + preview = ghid_pinout_preview_new(element); + gtk_box_pack_start(GTK_BOX(vbox), preview, TRUE, TRUE, 0); - ghid_pinout_preview_get_natural_size (GHID_PINOUT_PREVIEW (preview), - &width, &height); + ghid_pinout_preview_get_natural_size(GHID_PINOUT_PREVIEW(preview), &width, &height); - gtk_window_set_default_size (GTK_WINDOW (top_window), - width + 50, height + 50); + gtk_window_set_default_size(GTK_WINDOW(top_window), width + 50, height + 50); - 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 (pinout_close_cb), top_window); - gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); + 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(pinout_close_cb), top_window); + gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); - gtk_widget_realize (top_window); - if (Settings.AutoPlace) - gtk_window_move (GTK_WINDOW (top_window), 10, 10); - gtk_widget_show_all (top_window); + gtk_widget_realize(top_window); + if (Settings.AutoPlace) + gtk_window_move(GTK_WINDOW(top_window), 10, 10); + gtk_widget_show_all(top_window); } Index: trunk/src/hid/gtk/gui-top-window.c =================================================================== --- trunk/src/hid/gtk/gui-top-window.c (revision 1021) +++ trunk/src/hid/gtk/gui-top-window.c (revision 1022) @@ -27,36 +27,27 @@ #ifdef DAN_FIXME TODO: -- figure out when we need to call this: - ghid_set_status_line_label (); - Everytime? +-figure out when we need to call this: +ghid_set_status_line_label(); +Everytime ? -the old quit callback had : ghid_config_files_write(); +hid_action("Quit"); -- the old quit callback had: +-what about stuff like this: - ghid_config_files_write (); - hid_action ("Quit"); + /* Set to ! because ActionDisplay toggles it */ +Settings.DrawGrid = !gtk_toggle_action_get_active(action); +ghidgui->config_modified = TRUE; +hid_actionl("Display", "Grid", "", NULL); +ghid_set_status_line_label(); -- what about stuff like this: - /* Set to ! because ActionDisplay toggles it */ - Settings.DrawGrid = !gtk_toggle_action_get_active (action); - ghidgui->config_modified = TRUE; - hid_actionl ("Display", "Grid", "", NULL); - ghid_set_status_line_label (); - - -I NEED TO DO THE STATUS LINE THING. for example shift-alt-v to change the -via size. NOte the status line label does not get updated properly until -a zoom in/out. - +I NEED TO DO THE STATUS LINE THING.for example shift - alt - v to change the + via size.NOte the status line label does not get updated properly until a zoom in / out. #endif - /* This file was originally written by Bill Wilson for the PCB Gtk * port. It was later heavily modified by Dan McMahill to provide * user customized menus. */ - - /* gui-top-window.c | This handles creation of the top level window and all its widgets. | events for the Output.drawing_area widget are handled in a separate @@ -67,16 +58,11 @@ | we have our own shortcut table and capture the keys and send the events | there in ghid_port_key_press_cb(). */ - - #include "config.h" - #include - #ifdef HAVE_LOCALE_H #include #endif - #include "ghid-layer-selector.h" #include "ghid-route-style-selector.h" #include "gtkhid.h" @@ -84,7 +70,6 @@ #include "hid.h" #include "../hidint.h" #include "hid/common/hid_resource.h" - #include "action.h" #include "autoplace.h" #include "autoroute.h" @@ -120,19 +105,16 @@ #include "event.h" #include "free_atexit.h" #include "paths.h" - #include "gui-icons-mode-buttons.data" #include "gui-icons-misc.data" - #ifdef HAVE_LIBDMALLOC #include #endif + RCSID("$Id$"); -RCSID ("$Id$"); - static bool ignore_layer_update; -static GtkWidget *ghid_load_menus (void); +static GtkWidget *ghid_load_menus(void); GhidGui _ghidgui, *ghidgui = NULL; @@ -140,206 +122,174 @@ static gchar *bg_image_file; -static struct { GtkAction *action; const Resource *node; } - ghid_hotkey_actions[256]; +static struct { + GtkAction *action; + const Resource *node; +} ghid_hotkey_actions[256]; #define N_HOTKEY_ACTIONS \ (sizeof (ghid_hotkey_actions) / sizeof (ghid_hotkey_actions[0])) /*! \brief callback for ghid_main_menu_update_toggle_state () */ -void -menu_toggle_update_cb (GtkAction *act, const char *tflag, const char *aflag) +void menu_toggle_update_cb(GtkAction * act, const char *tflag, const char *aflag) { - if (tflag != NULL) - { - int v = hid_get_flag (tflag); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (act), !!v); - } - if (aflag != NULL) - { - int v = hid_get_flag (aflag); - gtk_action_set_sensitive (act, !!v); - } + if (tflag != NULL) { + int v = hid_get_flag(tflag); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act), ! !v); + } + if (aflag != NULL) { + int v = hid_get_flag(aflag); + gtk_action_set_sensitive(act, ! !v); + } } /*! \brief sync the menu checkboxes with actual pcb state */ -void -ghid_update_toggle_flags () +void ghid_update_toggle_flags() { - ghid_main_menu_update_toggle_state (GHID_MAIN_MENU (ghidgui->menu_bar), - menu_toggle_update_cb); + ghid_main_menu_update_toggle_state(GHID_MAIN_MENU(ghidgui->menu_bar), menu_toggle_update_cb); } -static void -h_adjustment_changed_cb (GtkAdjustment * adj, GhidGui * g) +static void h_adjustment_changed_cb(GtkAdjustment * adj, GhidGui * g) { - if (g->adjustment_changed_holdoff) - return; + if (g->adjustment_changed_holdoff) + return; - ghid_port_ranges_changed (); + ghid_port_ranges_changed(); } -static void -v_adjustment_changed_cb (GtkAdjustment * adj, GhidGui * g) +static void v_adjustment_changed_cb(GtkAdjustment * adj, GhidGui * g) { - if (g->adjustment_changed_holdoff) - return; + if (g->adjustment_changed_holdoff) + return; - ghid_port_ranges_changed (); + ghid_port_ranges_changed(); } - /* Save size of top window changes so PCB can restart at its size at exit. - */ -static gint -top_window_configure_event_cb (GtkWidget * widget, GdkEventConfigure * ev, - GHidPort * port) + /* Save size of top window changes so PCB can restart at its size at exit. + */ +static gint top_window_configure_event_cb(GtkWidget * widget, GdkEventConfigure * ev, GHidPort * port) { - GtkAllocation allocation; - gboolean new_w, new_h; + GtkAllocation allocation; + gboolean new_w, new_h; - gtk_widget_get_allocation (widget, &allocation); + gtk_widget_get_allocation(widget, &allocation); - new_w = (ghidgui->top_window_width != allocation.width); - new_h = (ghidgui->top_window_height != allocation.height); + new_w = (ghidgui->top_window_width != allocation.width); + new_h = (ghidgui->top_window_height != allocation.height); - ghidgui->top_window_width = allocation.width; - ghidgui->top_window_height = allocation.height; + ghidgui->top_window_width = allocation.width; + ghidgui->top_window_height = allocation.height; - if (new_w || new_h) - ghidgui->config_modified = TRUE; + if (new_w || new_h) + ghidgui->config_modified = TRUE; - return FALSE; + return FALSE; } -static void -info_bar_response_cb (GtkInfoBar *info_bar, - gint response_id, - GhidGui *_gui) +static void info_bar_response_cb(GtkInfoBar * info_bar, gint response_id, GhidGui * _gui) { - gtk_widget_destroy (_gui->info_bar); - _gui->info_bar = NULL; + gtk_widget_destroy(_gui->info_bar); + _gui->info_bar = NULL; - if (response_id == GTK_RESPONSE_ACCEPT) - RevertPCB (); + if (response_id == GTK_RESPONSE_ACCEPT) + RevertPCB(); } -static void -close_file_modified_externally_prompt (void) +static void close_file_modified_externally_prompt(void) { - if (ghidgui->info_bar != NULL) - gtk_widget_destroy (ghidgui->info_bar); - ghidgui->info_bar = NULL; + if (ghidgui->info_bar != NULL) + gtk_widget_destroy(ghidgui->info_bar); + ghidgui->info_bar = NULL; } -static void -show_file_modified_externally_prompt (void) +static void show_file_modified_externally_prompt(void) { - GtkWidget *button; - GtkWidget *button_image; - GtkWidget *icon; - GtkWidget *label; - GtkWidget *content_area; - char *file_path_utf8; - char *secondary_text; - char *markup; + GtkWidget *button; + GtkWidget *button_image; + GtkWidget *icon; + GtkWidget *label; + GtkWidget *content_area; + char *file_path_utf8; + char *secondary_text; + char *markup; - close_file_modified_externally_prompt (); + close_file_modified_externally_prompt(); - ghidgui->info_bar = gtk_info_bar_new (); + ghidgui->info_bar = gtk_info_bar_new(); - button = gtk_info_bar_add_button (GTK_INFO_BAR (ghidgui->info_bar), - _("Reload"), - GTK_RESPONSE_ACCEPT); - button_image = gtk_image_new_from_stock (GTK_STOCK_REFRESH, - GTK_ICON_SIZE_BUTTON); - gtk_button_set_image (GTK_BUTTON (button), button_image); + button = gtk_info_bar_add_button(GTK_INFO_BAR(ghidgui->info_bar), _("Reload"), GTK_RESPONSE_ACCEPT); + button_image = gtk_image_new_from_stock(GTK_STOCK_REFRESH, GTK_ICON_SIZE_BUTTON); + gtk_button_set_image(GTK_BUTTON(button), button_image); - gtk_info_bar_add_button (GTK_INFO_BAR (ghidgui->info_bar), - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL); - gtk_info_bar_set_message_type (GTK_INFO_BAR (ghidgui->info_bar), - GTK_MESSAGE_WARNING); - gtk_box_pack_start (GTK_BOX (ghidgui->vbox_middle), - ghidgui->info_bar, FALSE, FALSE, 0); - gtk_box_reorder_child (GTK_BOX (ghidgui->vbox_middle), ghidgui->info_bar, 0); + gtk_info_bar_add_button(GTK_INFO_BAR(ghidgui->info_bar), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); + gtk_info_bar_set_message_type(GTK_INFO_BAR(ghidgui->info_bar), GTK_MESSAGE_WARNING); + gtk_box_pack_start(GTK_BOX(ghidgui->vbox_middle), ghidgui->info_bar, FALSE, FALSE, 0); + gtk_box_reorder_child(GTK_BOX(ghidgui->vbox_middle), ghidgui->info_bar, 0); - g_signal_connect (ghidgui->info_bar, "response", - G_CALLBACK (info_bar_response_cb), ghidgui); + g_signal_connect(ghidgui->info_bar, "response", G_CALLBACK(info_bar_response_cb), ghidgui); - file_path_utf8 = g_filename_to_utf8 (PCB->Filename, -1, NULL, NULL, NULL); + file_path_utf8 = g_filename_to_utf8(PCB->Filename, -1, NULL, NULL, NULL); - secondary_text = PCB->Changed ? "Do you want to drop your changes and reload the file?" : - "Do you want to reload the file?"; + secondary_text = PCB->Changed ? "Do you want to drop your changes and reload the file?" : "Do you want to reload the file?"; - markup = g_markup_printf_escaped (_("The file %s has changed on disk\n\n%s"), - file_path_utf8, secondary_text); - g_free (file_path_utf8); + markup = g_markup_printf_escaped(_("The file %s has changed on disk\n\n%s"), file_path_utf8, secondary_text); + g_free(file_path_utf8); - content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (ghidgui->info_bar)); + content_area = gtk_info_bar_get_content_area(GTK_INFO_BAR(ghidgui->info_bar)); - icon = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, - GTK_ICON_SIZE_DIALOG); - gtk_box_pack_start (GTK_BOX (content_area), - icon, FALSE, FALSE, 0); + icon = gtk_image_new_from_stock(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG); + gtk_box_pack_start(GTK_BOX(content_area), icon, FALSE, FALSE, 0); - label = gtk_label_new (""); - gtk_box_pack_start (GTK_BOX (content_area), - label, TRUE, TRUE, 6); + label = gtk_label_new(""); + gtk_box_pack_start(GTK_BOX(content_area), label, TRUE, TRUE, 6); - gtk_label_set_use_markup (GTK_LABEL (label), TRUE); - gtk_label_set_markup (GTK_LABEL (label), markup); - g_free (markup); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_label_set_markup(GTK_LABEL(label), markup); + g_free(markup); - gtk_misc_set_alignment (GTK_MISC (label), 0., 0.5); + gtk_misc_set_alignment(GTK_MISC(label), 0., 0.5); - gtk_widget_show_all (ghidgui->info_bar); + gtk_widget_show_all(ghidgui->info_bar); } -static bool -check_externally_modified (void) +static bool check_externally_modified(void) { - GFile *file; - GFileInfo *info; - GTimeVal timeval; + GFile *file; + GFileInfo *info; + GTimeVal timeval; - /* Treat zero time as a flag to indicate we've not got an mtime yet */ - if (PCB->Filename == NULL || - (ghidgui->our_mtime.tv_sec == 0 && - ghidgui->our_mtime.tv_usec == 0)) - return false; + /* Treat zero time as a flag to indicate we've not got an mtime yet */ + if (PCB->Filename == NULL || (ghidgui->our_mtime.tv_sec == 0 && ghidgui->our_mtime.tv_usec == 0)) + return false; - file = g_file_new_for_path (PCB->Filename); - info = g_file_query_info (file, G_FILE_ATTRIBUTE_TIME_MODIFIED, - G_FILE_QUERY_INFO_NONE, NULL, NULL); - g_object_unref (file); + file = g_file_new_for_path(PCB->Filename); + info = g_file_query_info(file, G_FILE_ATTRIBUTE_TIME_MODIFIED, G_FILE_QUERY_INFO_NONE, NULL, NULL); + g_object_unref(file); - if (info == NULL || - !g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED)) - return false; + if (info == NULL || !g_file_info_has_attribute(info, G_FILE_ATTRIBUTE_TIME_MODIFIED)) + return false; - g_file_info_get_modification_time (info, &timeval); /*&ghidgui->last_seen_mtime);*/ - g_object_unref (info); + g_file_info_get_modification_time(info, &timeval); /*&ghidgui->last_seen_mtime); */ + g_object_unref(info); - /* Ignore when the file on disk is the same age as when we last looked */ - if (timeval.tv_sec == ghidgui->last_seen_mtime.tv_sec && - timeval.tv_usec == ghidgui->last_seen_mtime.tv_usec) - return false; + /* Ignore when the file on disk is the same age as when we last looked */ + if (timeval.tv_sec == ghidgui->last_seen_mtime.tv_sec && timeval.tv_usec == ghidgui->last_seen_mtime.tv_usec) + return false; - ghidgui->last_seen_mtime = timeval; + ghidgui->last_seen_mtime = timeval; - return (ghidgui->last_seen_mtime.tv_sec > ghidgui->our_mtime.tv_sec) || - (ghidgui->last_seen_mtime.tv_sec == ghidgui->our_mtime.tv_sec && - ghidgui->last_seen_mtime.tv_usec > ghidgui->our_mtime.tv_usec); + return (ghidgui->last_seen_mtime.tv_sec > ghidgui->our_mtime.tv_sec) || + (ghidgui->last_seen_mtime.tv_sec == ghidgui->our_mtime.tv_sec && + ghidgui->last_seen_mtime.tv_usec > ghidgui->our_mtime.tv_usec); } -static gboolean -top_window_enter_cb (GtkWidget *widget, GdkEvent *event, GHidPort *port) +static gboolean top_window_enter_cb(GtkWidget * widget, GdkEvent * event, GHidPort * port) { - if (check_externally_modified ()) - show_file_modified_externally_prompt (); + if (check_externally_modified()) + show_file_modified_externally_prompt(); - return FALSE; + return FALSE; } /*! \brief Menu action callback function @@ -356,106 +306,95 @@ * \param [in] The menu resource associated with the action */ -static void -ghid_menu_cb (GtkAction *action, const Resource *node) +static void ghid_menu_cb(GtkAction * action, const Resource * node) { - int i; + int i; - if (action == NULL || node == NULL) - return; + if (action == NULL || node == NULL) + return; - for (i = 1; i < node->c; i++) - if (resource_type (node->v[i]) == 10) - { + for (i = 1; i < node->c; i++) + if (resource_type(node->v[i]) == 10) { #ifdef DEBUG_MENUS - printf (" %s\n", node->v[i].value); + printf(" %s\n", node->v[i].value); #endif - hid_parse_actions (node->v[i].value); - } + hid_parse_actions(node->v[i].value); + } - /* Sync gui widgets with pcb state */ - ghid_update_toggle_flags (); - ghid_mode_buttons_update (); + /* Sync gui widgets with pcb state */ + ghid_update_toggle_flags(); + ghid_mode_buttons_update(); - /* Sync gui status display with pcb state */ - AdjustAttachedObjects (); - ghid_invalidate_all (); - ghid_window_set_name_label (PCB->Name); - ghid_set_status_line_label (); + /* Sync gui status display with pcb state */ + AdjustAttachedObjects(); + ghid_invalidate_all(); + ghid_window_set_name_label(PCB->Name); + ghid_set_status_line_label(); } /* \brief Accelerator callback for accelerators gtk tries to hide from us */ -void ghid_hotkey_cb (int which) +void ghid_hotkey_cb(int which) { - if (ghid_hotkey_actions[which].action != NULL) - ghid_menu_cb (ghid_hotkey_actions[which].action, - (gpointer) ghid_hotkey_actions[which].node); + if (ghid_hotkey_actions[which].action != NULL) + ghid_menu_cb(ghid_hotkey_actions[which].action, (gpointer) ghid_hotkey_actions[which].node); } -static void -update_board_mtime_from_disk (void) +static void update_board_mtime_from_disk(void) { - GFile *file; - GFileInfo *info; + GFile *file; + GFileInfo *info; - ghidgui->our_mtime.tv_sec = 0; - ghidgui->our_mtime.tv_usec = 0; - ghidgui->last_seen_mtime = ghidgui->our_mtime; + ghidgui->our_mtime.tv_sec = 0; + ghidgui->our_mtime.tv_usec = 0; + ghidgui->last_seen_mtime = ghidgui->our_mtime; - if (PCB->Filename == NULL) - return; + if (PCB->Filename == NULL) + return; - file = g_file_new_for_path (PCB->Filename); - info = g_file_query_info (file, G_FILE_ATTRIBUTE_TIME_MODIFIED, - G_FILE_QUERY_INFO_NONE, NULL, NULL); - g_object_unref (file); + file = g_file_new_for_path(PCB->Filename); + info = g_file_query_info(file, G_FILE_ATTRIBUTE_TIME_MODIFIED, G_FILE_QUERY_INFO_NONE, NULL, NULL); + g_object_unref(file); - if (info == NULL || - !g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED)) - return; + if (info == NULL || !g_file_info_has_attribute(info, G_FILE_ATTRIBUTE_TIME_MODIFIED)) + return; - g_file_info_get_modification_time (info, &ghidgui->our_mtime); - g_object_unref (info); + g_file_info_get_modification_time(info, &ghidgui->our_mtime); + g_object_unref(info); - ghidgui->last_seen_mtime = ghidgui->our_mtime; + ghidgui->last_seen_mtime = ghidgui->our_mtime; } - /* Sync toggle states that were saved with the layout and notify the - | config code to update Settings values it manages. - */ -void -ghid_sync_with_new_layout (void) + /* Sync toggle states that were saved with the layout and notify the + | config code to update Settings values it manages. + */ +void ghid_sync_with_new_layout(void) { - pcb_use_route_style (&PCB->RouteStyle[0]); - ghid_route_style_selector_select_style - (GHID_ROUTE_STYLE_SELECTOR (ghidgui->route_style_selector), - &PCB->RouteStyle[0]); + pcb_use_route_style(&PCB->RouteStyle[0]); + ghid_route_style_selector_select_style(GHID_ROUTE_STYLE_SELECTOR(ghidgui->route_style_selector), &PCB->RouteStyle[0]); - ghid_config_handle_units_changed (); + ghid_config_handle_units_changed(); - ghid_window_set_name_label (PCB->Name); - ghid_set_status_line_label (); - close_file_modified_externally_prompt (); - update_board_mtime_from_disk (); + ghid_window_set_name_label(PCB->Name); + ghid_set_status_line_label(); + close_file_modified_externally_prompt(); + update_board_mtime_from_disk(); } -void -ghid_notify_save_pcb (const char *filename, bool done) +void ghid_notify_save_pcb(const char *filename, bool done) { - /* Do nothing if it is not the active PCB file that is being saved. - */ - if (PCB->Filename == NULL || strcmp (filename, PCB->Filename) != 0) - return; + /* Do nothing if it is not the active PCB file that is being saved. + */ + if (PCB->Filename == NULL || strcmp(filename, PCB->Filename) != 0) + return; - if (done) - update_board_mtime_from_disk (); + if (done) + update_board_mtime_from_disk(); } -void -ghid_notify_filename_changed (void) +void ghid_notify_filename_changed(void) { - /* Pick up the mtime of the new PCB file */ - update_board_mtime_from_disk (); + /* Pick up the mtime of the new PCB file */ + update_board_mtime_from_disk(); } /* --------------------------------------------------------------------------- @@ -467,223 +406,201 @@ * used by a couple of functions. * */ -static void -layer_process (gchar **color_string, char **text, int *set, int i) +static void layer_process(gchar ** color_string, char **text, int *set, int i) { - int tmp; - char *tmps; - gchar *tmpc; + int tmp; + char *tmps; + gchar *tmpc; - /* cheap hack to let users pass in NULL for either text or set if - * they don't care about the result - */ - - if (color_string == NULL) - color_string = &tmpc; + /* cheap hack to let users pass in NULL for either text or set if + * they don't care about the result + */ - if (text == NULL) - text = &tmps; + if (color_string == NULL) + color_string = &tmpc; - if (set == NULL) - set = &tmp; - - switch (i) - { - case LAYER_BUTTON_SILK: - *color_string = Settings.ElementColor; - *text = _( "silk"); - *set = PCB->ElementOn; - break; - case LAYER_BUTTON_RATS: - *color_string = Settings.RatColor; - *text = _( "rat lines"); - *set = PCB->RatOn; - break; - case LAYER_BUTTON_PINS: - *color_string = Settings.PinColor; - *text = _( "pins/pads"); - *set = PCB->PinOn; - break; - case LAYER_BUTTON_VIAS: - *color_string = Settings.ViaColor; - *text = _( "vias"); - *set = PCB->ViaOn; - break; - case LAYER_BUTTON_FARSIDE: - *color_string = Settings.InvisibleObjectsColor; - *text = _( "far side"); - *set = PCB->InvisibleObjectsOn; - break; - case LAYER_BUTTON_MASK: - *color_string = Settings.MaskColor; - *text = _( "solder mask"); - *set = TEST_FLAG (SHOWMASKFLAG, PCB); - break; - default: /* layers */ - *color_string = Settings.LayerColor[i]; - *text = (char *)UNKNOWN (PCB->Data->Layer[i].Name); - *set = PCB->Data->Layer[i].On; - break; - } + if (text == NULL) + text = &tmps; + + if (set == NULL) + set = &tmp; + + switch (i) { + case LAYER_BUTTON_SILK: + *color_string = Settings.ElementColor; + *text = _("silk"); + *set = PCB->ElementOn; + break; + case LAYER_BUTTON_RATS: + *color_string = Settings.RatColor; + *text = _("rat lines"); + *set = PCB->RatOn; + break; + case LAYER_BUTTON_PINS: + *color_string = Settings.PinColor; + *text = _("pins/pads"); + *set = PCB->PinOn; + break; + case LAYER_BUTTON_VIAS: + *color_string = Settings.ViaColor; + *text = _("vias"); + *set = PCB->ViaOn; + break; + case LAYER_BUTTON_FARSIDE: + *color_string = Settings.InvisibleObjectsColor; + *text = _("far side"); + *set = PCB->InvisibleObjectsOn; + break; + case LAYER_BUTTON_MASK: + *color_string = Settings.MaskColor; + *text = _("solder mask"); + *set = TEST_FLAG(SHOWMASKFLAG, PCB); + break; + default: /* layers */ + *color_string = Settings.LayerColor[i]; + *text = (char *) UNKNOWN(PCB->Data->Layer[i].Name); + *set = PCB->Data->Layer[i].On; + break; + } } /*! \brief Callback for GHidLayerSelector layer selection */ -static void -layer_selector_select_callback (GHidLayerSelector *ls, int layer, gpointer d) +static void layer_selector_select_callback(GHidLayerSelector * ls, int layer, gpointer d) { - ignore_layer_update = true; - /* Select Layer */ - PCB->SilkActive = (layer == LAYER_BUTTON_SILK); - PCB->RatDraw = (layer == LAYER_BUTTON_RATS); - if (layer == LAYER_BUTTON_SILK) - { - PCB->ElementOn = true; - hid_action ("LayersChanged"); - } - else if (layer == LAYER_BUTTON_RATS) - { - PCB->RatOn = true; - hid_action ("LayersChanged"); - } - else if (layer < max_copper_layer) - ChangeGroupVisibility (layer, TRUE, true); + ignore_layer_update = true; + /* Select Layer */ + PCB->SilkActive = (layer == LAYER_BUTTON_SILK); + PCB->RatDraw = (layer == LAYER_BUTTON_RATS); + if (layer == LAYER_BUTTON_SILK) { + PCB->ElementOn = true; + hid_action("LayersChanged"); + } + else if (layer == LAYER_BUTTON_RATS) { + PCB->RatOn = true; + hid_action("LayersChanged"); + } + else if (layer < max_copper_layer) + ChangeGroupVisibility(layer, TRUE, true); - ignore_layer_update = false; + ignore_layer_update = false; - ghid_invalidate_all (); + ghid_invalidate_all(); } /*! \brief Callback for GHidLayerSelector layer toggling */ -static void -layer_selector_toggle_callback (GHidLayerSelector *ls, int layer, gpointer d) +static void layer_selector_toggle_callback(GHidLayerSelector * ls, int layer, gpointer d) { - gboolean redraw = FALSE; - gboolean active; - layer_process (NULL, NULL, &active, layer); + gboolean redraw = FALSE; + gboolean active; + layer_process(NULL, NULL, &active, layer); - active = !active; - ignore_layer_update = true; - switch (layer) - { - case LAYER_BUTTON_SILK: - PCB->ElementOn = active; - PCB->Data->SILKLAYER.On = PCB->ElementOn; - PCB->Data->BACKSILKLAYER.On = PCB->ElementOn; - redraw = 1; - break; - case LAYER_BUTTON_RATS: - PCB->RatOn = active; - redraw = 1; - break; - case LAYER_BUTTON_PINS: - PCB->PinOn = active; - redraw |= (PCB->Data->ElementN != 0); - break; - case LAYER_BUTTON_VIAS: - PCB->ViaOn = active; - redraw |= (PCB->Data->ViaN != 0); - break; - case LAYER_BUTTON_FARSIDE: - PCB->InvisibleObjectsOn = active; - PCB->Data->BACKSILKLAYER.On = (active && PCB->ElementOn); - redraw = TRUE; - break; - case LAYER_BUTTON_MASK: - if (active) - SET_FLAG (SHOWMASKFLAG, PCB); - else - CLEAR_FLAG (SHOWMASKFLAG, PCB); - redraw = TRUE; - break; - default: - /* Flip the visibility */ - ChangeGroupVisibility (layer, active, false); - redraw = TRUE; - break; - } + active = !active; + ignore_layer_update = true; + switch (layer) { + case LAYER_BUTTON_SILK: + PCB->ElementOn = active; + PCB->Data->SILKLAYER.On = PCB->ElementOn; + PCB->Data->BACKSILKLAYER.On = PCB->ElementOn; + redraw = 1; + break; + case LAYER_BUTTON_RATS: + PCB->RatOn = active; + redraw = 1; + break; + case LAYER_BUTTON_PINS: + PCB->PinOn = active; + redraw |= (PCB->Data->ElementN != 0); + break; + case LAYER_BUTTON_VIAS: + PCB->ViaOn = active; + redraw |= (PCB->Data->ViaN != 0); + break; + case LAYER_BUTTON_FARSIDE: + PCB->InvisibleObjectsOn = active; + PCB->Data->BACKSILKLAYER.On = (active && PCB->ElementOn); + redraw = TRUE; + break; + case LAYER_BUTTON_MASK: + if (active) + SET_FLAG(SHOWMASKFLAG, PCB); + else + CLEAR_FLAG(SHOWMASKFLAG, PCB); + redraw = TRUE; + break; + default: + /* Flip the visibility */ + ChangeGroupVisibility(layer, active, false); + redraw = TRUE; + break; + } - /* Select the next visible layer. (If there is none, this will - * select the currently-selected layer, triggering the selection - * callback, which will turn the visibility on.) This way we - * will never have an invisible layer selected. - */ - if (!active) - ghid_layer_selector_select_next_visible (ls); + /* Select the next visible layer. (If there is none, this will + * select the currently-selected layer, triggering the selection + * callback, which will turn the visibility on.) This way we + * will never have an invisible layer selected. + */ + if (!active) + ghid_layer_selector_select_next_visible(ls); - ignore_layer_update = false; + ignore_layer_update = false; - if (redraw) - ghid_invalidate_all(); + if (redraw) + ghid_invalidate_all(); } /*! \brief Install menu bar and accelerator groups */ -void -ghid_install_accel_groups (GtkWindow *window, GhidGui *gui) +void ghid_install_accel_groups(GtkWindow * window, GhidGui * gui) { - gtk_window_add_accel_group - (window, ghid_main_menu_get_accel_group - (GHID_MAIN_MENU (gui->menu_bar))); - gtk_window_add_accel_group - (window, ghid_layer_selector_get_accel_group - (GHID_LAYER_SELECTOR (gui->layer_selector))); - gtk_window_add_accel_group - (window, ghid_route_style_selector_get_accel_group - (GHID_ROUTE_STYLE_SELECTOR (gui->route_style_selector))); + gtk_window_add_accel_group(window, ghid_main_menu_get_accel_group(GHID_MAIN_MENU(gui->menu_bar))); + gtk_window_add_accel_group(window, ghid_layer_selector_get_accel_group(GHID_LAYER_SELECTOR(gui->layer_selector))); + gtk_window_add_accel_group + (window, ghid_route_style_selector_get_accel_group(GHID_ROUTE_STYLE_SELECTOR(gui->route_style_selector))); } /*! \brief Remove menu bar and accelerator groups */ -void -ghid_remove_accel_groups (GtkWindow *window, GhidGui *gui) +void ghid_remove_accel_groups(GtkWindow * window, GhidGui * gui) { - gtk_window_remove_accel_group - (window, ghid_main_menu_get_accel_group - (GHID_MAIN_MENU (gui->menu_bar))); - gtk_window_remove_accel_group - (window, ghid_layer_selector_get_accel_group - (GHID_LAYER_SELECTOR (gui->layer_selector))); - gtk_window_remove_accel_group - (window, ghid_route_style_selector_get_accel_group - (GHID_ROUTE_STYLE_SELECTOR (gui->route_style_selector))); + gtk_window_remove_accel_group(window, ghid_main_menu_get_accel_group(GHID_MAIN_MENU(gui->menu_bar))); + gtk_window_remove_accel_group(window, ghid_layer_selector_get_accel_group(GHID_LAYER_SELECTOR(gui->layer_selector))); + gtk_window_remove_accel_group + (window, ghid_route_style_selector_get_accel_group(GHID_ROUTE_STYLE_SELECTOR(gui->route_style_selector))); } /* Refreshes the window title bar and sets the PCB name to the * window title bar or to a seperate label */ -void -ghid_window_set_name_label (gchar * name) +void ghid_window_set_name_label(gchar * name) { - gchar *str; - gchar *filename; + gchar *str; + gchar *filename; - /* FIXME -- should this happen? It does... */ - /* This happens if we're calling an exporter from the command line */ - if (ghidgui == NULL) - return; + /* FIXME -- should this happen? It does... */ + /* This happens if we're calling an exporter from the command line */ + if (ghidgui == NULL) + return; - dup_string (&(ghidgui->name_label_string), name); - if (!ghidgui->name_label_string || !*ghidgui->name_label_string) - ghidgui->name_label_string = g_strdup (_("Unnamed")); + dup_string(&(ghidgui->name_label_string), name); + if (!ghidgui->name_label_string || !*ghidgui->name_label_string) + ghidgui->name_label_string = g_strdup(_("Unnamed")); - if (!PCB->Filename || !*PCB->Filename) - filename = g_strdup(_("Unsaved.pcb")); - else - filename = g_strdup(PCB->Filename); + if (!PCB->Filename || !*PCB->Filename) + filename = g_strdup(_("Unsaved.pcb")); + else + filename = g_strdup(PCB->Filename); - str = g_strdup_printf ("%s%s (%s) - PCB", PCB->Changed ? "*": "", - ghidgui->name_label_string, filename); - gtk_window_set_title (GTK_WINDOW (gport->top_window), str); - g_free (str); - g_free (filename); + str = g_strdup_printf("%s%s (%s) - PCB", PCB->Changed ? "*" : "", ghidgui->name_label_string, filename); + gtk_window_set_title(GTK_WINDOW(gport->top_window), str); + g_free(str); + g_free(filename); } -static void -grid_units_button_cb (GtkWidget * widget, gpointer data) +static void grid_units_button_cb(GtkWidget * widget, gpointer data) { - /* Button only toggles between mm and mil */ - if (Settings.grid_unit == get_unit_struct ("mm")) - hid_actionl ("SetUnits", "mil", NULL); - else - hid_actionl ("SetUnits", "mm", NULL); + /* Button only toggles between mm and mil */ + if (Settings.grid_unit == get_unit_struct("mm")) + hid_actionl("SetUnits", "mil", NULL); + else + hid_actionl("SetUnits", "mm", NULL); } /* @@ -691,146 +608,123 @@ * and relative cursor labels from growing and shrinking as you * move the cursor around. */ -static void -absolute_label_size_req_cb (GtkWidget * widget, - GtkRequisition *req, gpointer data) +static void absolute_label_size_req_cb(GtkWidget * widget, GtkRequisition * req, gpointer data) { - - static gint w = 0; - if (req->width > w) - w = req->width; - else - req->width = w; + + static gint w = 0; + if (req->width > w) + w = req->width; + else + req->width = w; } -static void -relative_label_size_req_cb (GtkWidget * widget, - GtkRequisition *req, gpointer data) +static void relative_label_size_req_cb(GtkWidget * widget, GtkRequisition * req, gpointer data) { - - static gint w = 0; - if (req->width > w) - w = req->width; - else - req->width = w; + + static gint w = 0; + if (req->width > w) + w = req->width; + else + req->width = w; } -static void -make_cursor_position_labels (GtkWidget * hbox, GHidPort * port) +static void make_cursor_position_labels(GtkWidget * hbox, GHidPort * port) { - GtkWidget *frame, *label; + GtkWidget *frame, *label; - /* The grid units button next to the cursor position labels. - */ - ghidgui->grid_units_button = gtk_button_new (); - label = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL (label), - Settings.grid_unit->in_suffix); - ghidgui->grid_units_label = label; - gtk_label_set_use_markup (GTK_LABEL (label), TRUE); - gtk_container_add (GTK_CONTAINER (ghidgui->grid_units_button), label); - gtk_box_pack_end (GTK_BOX (hbox), ghidgui->grid_units_button, FALSE, TRUE, 0); - g_signal_connect (ghidgui->grid_units_button, "clicked", - G_CALLBACK (grid_units_button_cb), NULL); + /* The grid units button next to the cursor position labels. + */ + ghidgui->grid_units_button = gtk_button_new(); + label = gtk_label_new(""); + gtk_label_set_markup(GTK_LABEL(label), Settings.grid_unit->in_suffix); + ghidgui->grid_units_label = label; + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_container_add(GTK_CONTAINER(ghidgui->grid_units_button), label); + gtk_box_pack_end(GTK_BOX(hbox), ghidgui->grid_units_button, FALSE, TRUE, 0); + g_signal_connect(ghidgui->grid_units_button, "clicked", G_CALLBACK(grid_units_button_cb), NULL); - /* The absolute cursor position label - */ - frame = gtk_frame_new (NULL); - gtk_box_pack_end (GTK_BOX (hbox), frame, FALSE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (frame), 2); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT); + /* The absolute cursor position label + */ + frame = gtk_frame_new(NULL); + gtk_box_pack_end(GTK_BOX(hbox), frame, FALSE, TRUE, 0); + gtk_container_set_border_width(GTK_CONTAINER(frame), 2); + gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_OUT); - label = gtk_label_new (""); - gtk_container_add (GTK_CONTAINER (frame), label); - ghidgui->cursor_position_absolute_label = label; - g_signal_connect (G_OBJECT (label), "size-request", - G_CALLBACK (absolute_label_size_req_cb), NULL); + label = gtk_label_new(""); + gtk_container_add(GTK_CONTAINER(frame), label); + ghidgui->cursor_position_absolute_label = label; + g_signal_connect(G_OBJECT(label), "size-request", G_CALLBACK(absolute_label_size_req_cb), NULL); - /* The relative cursor position label - */ - frame = gtk_frame_new (NULL); - gtk_box_pack_end (GTK_BOX (hbox), frame, FALSE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (frame), 2); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT); - label = gtk_label_new (" __.__ __.__ "); - gtk_container_add (GTK_CONTAINER (frame), label); - ghidgui->cursor_position_relative_label = label; - g_signal_connect (G_OBJECT (label), "size-request", - G_CALLBACK (relative_label_size_req_cb), NULL); + /* The relative cursor position label + */ + frame = gtk_frame_new(NULL); + gtk_box_pack_end(GTK_BOX(hbox), frame, FALSE, TRUE, 0); + gtk_container_set_border_width(GTK_CONTAINER(frame), 2); + gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_OUT); + label = gtk_label_new(" __.__ __.__ "); + gtk_container_add(GTK_CONTAINER(frame), label); + ghidgui->cursor_position_relative_label = label; + g_signal_connect(G_OBJECT(label), "size-request", G_CALLBACK(relative_label_size_req_cb), NULL); } /* \brief Add "virtual layers" to a layer selector */ -static void -make_virtual_layer_buttons (GtkWidget *layer_selector) +static void make_virtual_layer_buttons(GtkWidget * layer_selector) { - GHidLayerSelector *layersel = GHID_LAYER_SELECTOR (layer_selector); - gchar *text; - gchar *color_string; - gboolean active; - - layer_process (&color_string, &text, &active, LAYER_BUTTON_SILK); - ghid_layer_selector_add_layer (layersel, LAYER_BUTTON_SILK, - text, color_string, active, TRUE); - layer_process (&color_string, &text, &active, LAYER_BUTTON_RATS); - ghid_layer_selector_add_layer (layersel, LAYER_BUTTON_RATS, - text, color_string, active, TRUE); - layer_process (&color_string, &text, &active, LAYER_BUTTON_PINS); - ghid_layer_selector_add_layer (layersel, LAYER_BUTTON_PINS, - text, color_string, active, FALSE); - layer_process (&color_string, &text, &active, LAYER_BUTTON_VIAS); - ghid_layer_selector_add_layer (layersel, LAYER_BUTTON_VIAS, - text, color_string, active, FALSE); - layer_process (&color_string, &text, &active, LAYER_BUTTON_FARSIDE); - ghid_layer_selector_add_layer (layersel, LAYER_BUTTON_FARSIDE, - text, color_string, active, FALSE); - layer_process (&color_string, &text, &active, LAYER_BUTTON_MASK); - ghid_layer_selector_add_layer (layersel, LAYER_BUTTON_MASK, - text, color_string, active, FALSE); + GHidLayerSelector *layersel = GHID_LAYER_SELECTOR(layer_selector); + gchar *text; + gchar *color_string; + gboolean active; + + layer_process(&color_string, &text, &active, LAYER_BUTTON_SILK); + ghid_layer_selector_add_layer(layersel, LAYER_BUTTON_SILK, text, color_string, active, TRUE); + layer_process(&color_string, &text, &active, LAYER_BUTTON_RATS); + ghid_layer_selector_add_layer(layersel, LAYER_BUTTON_RATS, text, color_string, active, TRUE); + layer_process(&color_string, &text, &active, LAYER_BUTTON_PINS); + ghid_layer_selector_add_layer(layersel, LAYER_BUTTON_PINS, text, color_string, active, FALSE); + layer_process(&color_string, &text, &active, LAYER_BUTTON_VIAS); + ghid_layer_selector_add_layer(layersel, LAYER_BUTTON_VIAS, text, color_string, active, FALSE); + layer_process(&color_string, &text, &active, LAYER_BUTTON_FARSIDE); + ghid_layer_selector_add_layer(layersel, LAYER_BUTTON_FARSIDE, text, color_string, active, FALSE); + layer_process(&color_string, &text, &active, LAYER_BUTTON_MASK); + ghid_layer_selector_add_layer(layersel, LAYER_BUTTON_MASK, text, color_string, active, FALSE); } /*! \brief callback for ghid_layer_selector_update_colors */ -const gchar * -get_layer_color (gint layer) +const gchar *get_layer_color(gint layer) { - gchar *rv; - layer_process (&rv, NULL, NULL, layer); - return rv; + gchar *rv; + layer_process(&rv, NULL, NULL, layer); + return rv; } /*! \brief Update a layer selector's color scheme */ -void -ghid_layer_buttons_color_update (void) +void ghid_layer_buttons_color_update(void) { - ghid_layer_selector_update_colors - (GHID_LAYER_SELECTOR (ghidgui->layer_selector), get_layer_color); - pcb_colors_from_settings (PCB); + ghid_layer_selector_update_colors(GHID_LAYER_SELECTOR(ghidgui->layer_selector), get_layer_color); + pcb_colors_from_settings(PCB); } - + /*! \brief Populate a layer selector with all layers Gtk is aware of */ -static void -make_layer_buttons (GtkWidget *layersel) +static void make_layer_buttons(GtkWidget * layersel) { - gint i; - gchar *text; - gchar *color_string; - gboolean active = TRUE; + gint i; + gchar *text; + gchar *color_string; + gboolean active = TRUE; - for (i = 0; i < max_copper_layer; ++i) - { - layer_process (&color_string, &text, &active, i); - ghid_layer_selector_add_layer (GHID_LAYER_SELECTOR (layersel), i, - text, color_string, active, TRUE); - } + for (i = 0; i < max_copper_layer; ++i) { + layer_process(&color_string, &text, &active, i); + ghid_layer_selector_add_layer(GHID_LAYER_SELECTOR(layersel), i, text, color_string, active, TRUE); + } } /*! \brief callback for ghid_layer_selector_delete_layers */ -gboolean -get_layer_delete (gint layer) +gboolean get_layer_delete(gint layer) { - return layer >= max_copper_layer; + return layer >= max_copper_layer; } /*! \brief Synchronize layer selector widget with current PCB state @@ -838,72 +732,57 @@ * Called when user toggles layer visibility or changes drawing layer, * or when layer visibility is changed programatically. */ -void -ghid_layer_buttons_update (void) +void ghid_layer_buttons_update(void) { - gint layer; + gint layer; - if (ignore_layer_update) - return; - - ghid_layer_selector_delete_layers - (GHID_LAYER_SELECTOR (ghidgui->layer_selector), - get_layer_delete); - make_layer_buttons (ghidgui->layer_selector); - make_virtual_layer_buttons (ghidgui->layer_selector); - ghid_main_menu_install_layer_selector - (GHID_MAIN_MENU (ghidgui->menu_bar), - GHID_LAYER_SELECTOR (ghidgui->layer_selector)); + if (ignore_layer_update) + return; - /* Sync selected layer with PCB's state */ - if (PCB->RatDraw) - layer = LAYER_BUTTON_RATS; - else if (PCB->SilkActive) - layer = LAYER_BUTTON_SILK; - else - layer = LayerStack[0]; + ghid_layer_selector_delete_layers(GHID_LAYER_SELECTOR(ghidgui->layer_selector), get_layer_delete); + make_layer_buttons(ghidgui->layer_selector); + make_virtual_layer_buttons(ghidgui->layer_selector); + ghid_main_menu_install_layer_selector(GHID_MAIN_MENU(ghidgui->menu_bar), GHID_LAYER_SELECTOR(ghidgui->layer_selector)); - ghid_layer_selector_select_layer - (GHID_LAYER_SELECTOR (ghidgui->layer_selector), layer); + /* Sync selected layer with PCB's state */ + if (PCB->RatDraw) + layer = LAYER_BUTTON_RATS; + else if (PCB->SilkActive) + layer = LAYER_BUTTON_SILK; + else + layer = LayerStack[0]; + + ghid_layer_selector_select_layer(GHID_LAYER_SELECTOR(ghidgui->layer_selector), layer); } /*! \brief Called when user clicks OK on route style dialog */ -static void -route_styles_edited_cb (GHidRouteStyleSelector *rss, gboolean save, - gpointer data) +static void route_styles_edited_cb(GHidRouteStyleSelector * rss, gboolean save, gpointer data) { - if (save) - { - g_free (Settings.Routes); - Settings.Routes = make_route_string (PCB->RouteStyle, NUM_STYLES); - ghidgui->config_modified = TRUE; - ghid_config_files_write (); - } - ghid_main_menu_install_route_style_selector - (GHID_MAIN_MENU (ghidgui->menu_bar), - GHID_ROUTE_STYLE_SELECTOR (ghidgui->route_style_selector)); + if (save) { + g_free(Settings.Routes); + Settings.Routes = make_route_string(PCB->RouteStyle, NUM_STYLES); + ghidgui->config_modified = TRUE; + ghid_config_files_write(); + } + ghid_main_menu_install_route_style_selector + (GHID_MAIN_MENU(ghidgui->menu_bar), GHID_ROUTE_STYLE_SELECTOR(ghidgui->route_style_selector)); } /*! \brief Called when a route style is selected */ -static void -route_style_changed_cb (GHidRouteStyleSelector *rss, RouteStyleType *rst, - gpointer data) +static void route_style_changed_cb(GHidRouteStyleSelector * rss, RouteStyleType * rst, gpointer data) { - pcb_use_route_style (rst); - ghid_set_status_line_label(); + pcb_use_route_style(rst); + ghid_set_status_line_label(); } /*! \brief Configure the route style selector */ -void -make_route_style_buttons (GHidRouteStyleSelector *rss) +void make_route_style_buttons(GHidRouteStyleSelector * rss) { - int i; - for (i = 0; i < NUM_STYLES; ++i) - ghid_route_style_selector_add_route_style (rss, &PCB->RouteStyle[i]); - g_signal_connect (G_OBJECT (rss), "select_style", - G_CALLBACK (route_style_changed_cb), NULL); - g_signal_connect (G_OBJECT (rss), "style_edited", - G_CALLBACK (route_styles_edited_cb), NULL); + int i; + for (i = 0; i < NUM_STYLES; ++i) + ghid_route_style_selector_add_route_style(rss, &PCB->RouteStyle[i]); + g_signal_connect(G_OBJECT(rss), "select_style", G_CALLBACK(route_style_changed_cb), NULL); + g_signal_connect(G_OBJECT(rss), "style_edited", G_CALLBACK(route_styles_edited_cb), NULL); } /* @@ -910,185 +789,163 @@ * --------------------------------------------------------------- * Mode buttons */ -typedef struct -{ - GtkWidget *button; - GtkWidget *toolbar_button; - guint button_cb_id; - guint toolbar_button_cb_id; - gchar *name; - gint mode; - gchar **xpm; -} -ModeButton; +typedef struct { + GtkWidget *button; + GtkWidget *toolbar_button; + guint button_cb_id; + guint toolbar_button_cb_id; + gchar *name; + gint mode; + gchar **xpm; +} ModeButton; static ModeButton mode_buttons[] = { - {NULL, NULL, 0, 0, "via", VIA_MODE, via}, - {NULL, NULL, 0, 0, "line", LINE_MODE, line}, - {NULL, NULL, 0, 0, "arc", ARC_MODE, arc}, - {NULL, NULL, 0, 0, "text", TEXT_MODE, text}, - {NULL, NULL, 0, 0, "rectangle", RECTANGLE_MODE, rect}, - {NULL, NULL, 0, 0, "polygon", POLYGON_MODE, poly}, - {NULL, NULL, 0, 0, "polygonhole", POLYGONHOLE_MODE, polyhole}, - {NULL, NULL, 0, 0, "buffer", PASTEBUFFER_MODE, buf}, - {NULL, NULL, 0, 0, "remove", REMOVE_MODE, del}, - {NULL, NULL, 0, 0, "rotate", ROTATE_MODE, rot}, - {NULL, NULL, 0, 0, "insertPoint", INSERTPOINT_MODE, ins}, - {NULL, NULL, 0, 0, "thermal", THERMAL_MODE, thrm}, - {NULL, NULL, 0, 0, "select", ARROW_MODE, sel}, - {NULL, NULL, 0, 0, "lock", LOCK_MODE, lock} + {NULL, NULL, 0, 0, "via", VIA_MODE, via}, + {NULL, NULL, 0, 0, "line", LINE_MODE, line}, + {NULL, NULL, 0, 0, "arc", ARC_MODE, arc}, + {NULL, NULL, 0, 0, "text", TEXT_MODE, text}, + {NULL, NULL, 0, 0, "rectangle", RECTANGLE_MODE, rect}, + {NULL, NULL, 0, 0, "polygon", POLYGON_MODE, poly}, + {NULL, NULL, 0, 0, "polygonhole", POLYGONHOLE_MODE, polyhole}, + {NULL, NULL, 0, 0, "buffer", PASTEBUFFER_MODE, buf}, + {NULL, NULL, 0, 0, "remove", REMOVE_MODE, del}, + {NULL, NULL, 0, 0, "rotate", ROTATE_MODE, rot}, + {NULL, NULL, 0, 0, "insertPoint", INSERTPOINT_MODE, ins}, + {NULL, NULL, 0, 0, "thermal", THERMAL_MODE, thrm}, + {NULL, NULL, 0, 0, "select", ARROW_MODE, sel}, + {NULL, NULL, 0, 0, "lock", LOCK_MODE, lock} }; -static gint n_mode_buttons = G_N_ELEMENTS (mode_buttons); +static gint n_mode_buttons = G_N_ELEMENTS(mode_buttons); -static void -do_set_mode (int mode) +static void do_set_mode(int mode) { - SetMode (mode); - ghid_mode_cursor (mode); - ghidgui->settings_mode = mode; + SetMode(mode); + ghid_mode_cursor(mode); + ghidgui->settings_mode = mode; } -static void -mode_toolbar_button_toggled_cb (GtkToggleButton *button, ModeButton * mb) +static void mode_toolbar_button_toggled_cb(GtkToggleButton * button, ModeButton * mb) { - gboolean active = gtk_toggle_button_get_active (button); + gboolean active = gtk_toggle_button_get_active(button); - if (mb->button != NULL) - { - g_signal_handler_block (mb->button, mb->button_cb_id); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mb->button), active); - g_signal_handler_unblock (mb->button, mb->button_cb_id); - } + if (mb->button != NULL) { + g_signal_handler_block(mb->button, mb->button_cb_id); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mb->button), active); + g_signal_handler_unblock(mb->button, mb->button_cb_id); + } - if (active) - do_set_mode (mb->mode); + if (active) + do_set_mode(mb->mode); } -static void -mode_button_toggled_cb (GtkWidget * widget, ModeButton * mb) +static void mode_button_toggled_cb(GtkWidget * widget, ModeButton * mb) { - gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); + gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); - if (mb->toolbar_button != NULL) - { - g_signal_handler_block (mb->toolbar_button, mb->toolbar_button_cb_id); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mb->toolbar_button), active); - g_signal_handler_unblock (mb->toolbar_button, mb->toolbar_button_cb_id); - } + if (mb->toolbar_button != NULL) { + g_signal_handler_block(mb->toolbar_button, mb->toolbar_button_cb_id); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mb->toolbar_button), active); + g_signal_handler_unblock(mb->toolbar_button, mb->toolbar_button_cb_id); + } - if (active) - do_set_mode (mb->mode); + if (active) + do_set_mode(mb->mode); } -void -ghid_mode_buttons_update (void) +void ghid_mode_buttons_update(void) { - ModeButton *mb; - gint i; + ModeButton *mb; + gint i; - for (i = 0; i < n_mode_buttons; ++i) - { - mb = &mode_buttons[i]; - if (Settings.Mode == mb->mode) - { - g_signal_handler_block (mb->button, mb->button_cb_id); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mb->button), TRUE); - g_signal_handler_unblock (mb->button, mb->button_cb_id); + for (i = 0; i < n_mode_buttons; ++i) { + mb = &mode_buttons[i]; + if (Settings.Mode == mb->mode) { + g_signal_handler_block(mb->button, mb->button_cb_id); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mb->button), TRUE); + g_signal_handler_unblock(mb->button, mb->button_cb_id); - g_signal_handler_block (mb->toolbar_button, mb->toolbar_button_cb_id); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mb->toolbar_button), TRUE); - g_signal_handler_unblock (mb->toolbar_button, mb->toolbar_button_cb_id); - break; - } - } + g_signal_handler_block(mb->toolbar_button, mb->toolbar_button_cb_id); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mb->toolbar_button), TRUE); + g_signal_handler_unblock(mb->toolbar_button, mb->toolbar_button_cb_id); + break; + } + } } -void -ghid_pack_mode_buttons (void) +void ghid_pack_mode_buttons(void) { - if (ghidgui->compact_vertical) - { - gtk_widget_hide (ghidgui->mode_buttons_frame); - gtk_widget_show_all (ghidgui->mode_toolbar); - } - else - { - gtk_widget_hide (ghidgui->mode_toolbar); - gtk_widget_show_all (ghidgui->mode_buttons_frame); - } + if (ghidgui->compact_vertical) { + gtk_widget_hide(ghidgui->mode_buttons_frame); + gtk_widget_show_all(ghidgui->mode_toolbar); + } + else { + gtk_widget_hide(ghidgui->mode_toolbar); + gtk_widget_show_all(ghidgui->mode_buttons_frame); + } } -static void -make_mode_buttons_and_toolbar (GtkWidget **mode_frame, - GtkWidget **mode_toolbar) +static void make_mode_buttons_and_toolbar(GtkWidget ** mode_frame, GtkWidget ** mode_toolbar) { - GtkToolItem *tool_item; - GtkWidget *vbox, *hbox = NULL; - GtkWidget *image; - GdkPixbuf *pixbuf; - GSList *group = NULL; - GSList *toolbar_group = NULL; - ModeButton *mb; - int i; + GtkToolItem *tool_item; + GtkWidget *vbox, *hbox = NULL; + GtkWidget *image; + GdkPixbuf *pixbuf; + GSList *group = NULL; + GSList *toolbar_group = NULL; + ModeButton *mb; + int i; - *mode_toolbar = gtk_toolbar_new (); + *mode_toolbar = gtk_toolbar_new(); - *mode_frame = gtk_frame_new (NULL); - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (*mode_frame), vbox); + *mode_frame = gtk_frame_new(NULL); + vbox = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(*mode_frame), vbox); - for (i = 0; i < n_mode_buttons; ++i) - { - mb = &mode_buttons[i]; + for (i = 0; i < n_mode_buttons; ++i) { + mb = &mode_buttons[i]; - /* Create tool button for mode frame */ - mb->button = gtk_radio_button_new (group); - group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (mb->button)); - gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (mb->button), FALSE); + /* Create tool button for mode frame */ + mb->button = gtk_radio_button_new(group); + group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(mb->button)); + gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(mb->button), FALSE); - /* Create tool button for toolbar */ - mb->toolbar_button = gtk_radio_button_new (toolbar_group); - toolbar_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (mb->toolbar_button)); - gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (mb->toolbar_button), FALSE); + /* Create tool button for toolbar */ + mb->toolbar_button = gtk_radio_button_new(toolbar_group); + toolbar_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(mb->toolbar_button)); + gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(mb->toolbar_button), FALSE); - /* Pack mode-frame button into the frame */ - if ((i % ghidgui->n_mode_button_columns) == 0) - { - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - } - gtk_box_pack_start (GTK_BOX (hbox), mb->button, FALSE, FALSE, 0); + /* Pack mode-frame button into the frame */ + if ((i % ghidgui->n_mode_button_columns) == 0) { + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + } + gtk_box_pack_start(GTK_BOX(hbox), mb->button, FALSE, FALSE, 0); - /* Create a container for the toolbar button and add that */ - tool_item = gtk_tool_item_new (); - gtk_container_add (GTK_CONTAINER (tool_item), mb->toolbar_button); - gtk_toolbar_insert (GTK_TOOLBAR (*mode_toolbar), tool_item, -1); + /* Create a container for the toolbar button and add that */ + tool_item = gtk_tool_item_new(); + gtk_container_add(GTK_CONTAINER(tool_item), mb->toolbar_button); + gtk_toolbar_insert(GTK_TOOLBAR(*mode_toolbar), tool_item, -1); - /* Load the image for the button, create GtkImage widgets for both - * the grid button and the toolbar button, then pack into the buttons - */ - pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) mb->xpm); - image = gtk_image_new_from_pixbuf (pixbuf); - gtk_container_add (GTK_CONTAINER (mb->button), image); - image = gtk_image_new_from_pixbuf (pixbuf); - gtk_container_add (GTK_CONTAINER (mb->toolbar_button), image); - g_object_unref (pixbuf); + /* Load the image for the button, create GtkImage widgets for both + * the grid button and the toolbar button, then pack into the buttons + */ + pixbuf = gdk_pixbuf_new_from_xpm_data((const char **) mb->xpm); + image = gtk_image_new_from_pixbuf(pixbuf); + gtk_container_add(GTK_CONTAINER(mb->button), image); + image = gtk_image_new_from_pixbuf(pixbuf); + gtk_container_add(GTK_CONTAINER(mb->toolbar_button), image); + g_object_unref(pixbuf); - if (strcmp (mb->name, "select") == 0) - { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mb->button), TRUE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mb->toolbar_button), TRUE); - } + if (strcmp(mb->name, "select") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mb->button), TRUE); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mb->toolbar_button), TRUE); + } - mb->button_cb_id = - g_signal_connect (mb->button, "toggled", - G_CALLBACK (mode_button_toggled_cb), mb); - mb->toolbar_button_cb_id = - g_signal_connect (mb->toolbar_button, "toggled", - G_CALLBACK (mode_toolbar_button_toggled_cb), mb); - } + mb->button_cb_id = g_signal_connect(mb->button, "toggled", G_CALLBACK(mode_button_toggled_cb), mb); + mb->toolbar_button_cb_id = g_signal_connect(mb->toolbar_button, "toggled", G_CALLBACK(mode_toolbar_button_toggled_cb), mb); + } } @@ -1098,91 +955,83 @@ * --------------------------------------------------------------- */ -static gint -delete_chart_cb (GtkWidget * widget, GdkEvent * event, GHidPort * port) +static gint delete_chart_cb(GtkWidget * widget, GdkEvent * event, GHidPort * port) { - ghid_config_files_write (); - hid_action ("Quit"); + ghid_config_files_write(); + hid_action("Quit"); - /* - * Return TRUE to keep our app running. A FALSE here would let the - * delete signal continue on and kill our program. - */ - return TRUE; + /* + * Return TRUE to keep our app running. A FALSE here would let the + * delete signal continue on and kill our program. + */ + return TRUE; } -static void -destroy_chart_cb (GtkWidget * widget, GHidPort * port) +static void destroy_chart_cb(GtkWidget * widget, GHidPort * port) { - ghid_shutdown_renderer (port); - gtk_main_quit (); + ghid_shutdown_renderer(port); + gtk_main_quit(); } -static void -get_widget_styles (GtkStyle **menu_bar_style, - GtkStyle **tool_button_style, - GtkStyle **tool_button_label_style) +static void get_widget_styles(GtkStyle ** menu_bar_style, GtkStyle ** tool_button_style, GtkStyle ** tool_button_label_style) { - GtkWidget *tool_button; - GtkWidget *tool_button_label; - GtkToolItem *tool_item; + GtkWidget *tool_button; + GtkWidget *tool_button_label; + GtkToolItem *tool_item; - /* Build a tool item to extract the theme's styling for a toolbar button with text */ - tool_item = gtk_tool_item_new (); - gtk_toolbar_insert (GTK_TOOLBAR (ghidgui->mode_toolbar), tool_item, 0); - tool_button = gtk_button_new (); - gtk_container_add (GTK_CONTAINER (tool_item), tool_button); - tool_button_label = gtk_label_new (""); - gtk_container_add (GTK_CONTAINER (tool_button), tool_button_label); + /* Build a tool item to extract the theme's styling for a toolbar button with text */ + tool_item = gtk_tool_item_new(); + gtk_toolbar_insert(GTK_TOOLBAR(ghidgui->mode_toolbar), tool_item, 0); + tool_button = gtk_button_new(); + gtk_container_add(GTK_CONTAINER(tool_item), tool_button); + tool_button_label = gtk_label_new(""); + gtk_container_add(GTK_CONTAINER(tool_button), tool_button_label); - /* Grab the various styles we need */ - gtk_widget_ensure_style (ghidgui->menu_bar); - *menu_bar_style = gtk_widget_get_style (ghidgui->menu_bar); + /* Grab the various styles we need */ + gtk_widget_ensure_style(ghidgui->menu_bar); + *menu_bar_style = gtk_widget_get_style(ghidgui->menu_bar); - gtk_widget_ensure_style (tool_button); - *tool_button_style = gtk_widget_get_style (tool_button); + gtk_widget_ensure_style(tool_button); + *tool_button_style = gtk_widget_get_style(tool_button); - gtk_widget_ensure_style (tool_button_label); - *tool_button_label_style = gtk_widget_get_style (tool_button_label); + gtk_widget_ensure_style(tool_button_label); + *tool_button_label_style = gtk_widget_get_style(tool_button_label); - gtk_widget_destroy (GTK_WIDGET (tool_item)); + gtk_widget_destroy(GTK_WIDGET(tool_item)); } -static void -do_fix_topbar_theming (void) +static void do_fix_topbar_theming(void) { - GtkWidget *rel_pos_frame; - GtkWidget *abs_pos_frame; - GtkStyle *menu_bar_style; - GtkStyle *tool_button_style; - GtkStyle *tool_button_label_style; + GtkWidget *rel_pos_frame; + GtkWidget *abs_pos_frame; + GtkStyle *menu_bar_style; + GtkStyle *tool_button_style; + GtkStyle *tool_button_label_style; - get_widget_styles (&menu_bar_style, - &tool_button_style, - &tool_button_label_style); + get_widget_styles(&menu_bar_style, &tool_button_style, &tool_button_label_style); - /* Style the top bar background as if it were all a menu bar */ - gtk_widget_set_style (ghidgui->top_bar_background, menu_bar_style); + /* Style the top bar background as if it were all a menu bar */ + gtk_widget_set_style(ghidgui->top_bar_background, menu_bar_style); - /* Style the cursor position labels using the menu bar style as well. - * If this turns out to cause problems with certain gtk themes, we may - * need to grab the GtkStyle associated with an actual menu item to - * get a text color to render with. - */ - gtk_widget_set_style (ghidgui->cursor_position_relative_label, menu_bar_style); - gtk_widget_set_style (ghidgui->cursor_position_absolute_label, menu_bar_style); + /* Style the cursor position labels using the menu bar style as well. + * If this turns out to cause problems with certain gtk themes, we may + * need to grab the GtkStyle associated with an actual menu item to + * get a text color to render with. + */ + gtk_widget_set_style(ghidgui->cursor_position_relative_label, menu_bar_style); + gtk_widget_set_style(ghidgui->cursor_position_absolute_label, menu_bar_style); - /* Style the units button as if it were a toolbar button - hopefully - * this isn't too ugly sitting on a background themed as a menu bar. - * It is unlikely any theme defines colours for a GtkButton sitting on - * a menu bar. - */ - rel_pos_frame = gtk_widget_get_parent (ghidgui->cursor_position_relative_label); - abs_pos_frame = gtk_widget_get_parent (ghidgui->cursor_position_absolute_label); - gtk_widget_set_style (rel_pos_frame, menu_bar_style); - gtk_widget_set_style (abs_pos_frame, menu_bar_style); - gtk_widget_set_style (ghidgui->grid_units_button, tool_button_style); - gtk_widget_set_style (ghidgui->grid_units_label, tool_button_label_style); + /* Style the units button as if it were a toolbar button - hopefully + * this isn't too ugly sitting on a background themed as a menu bar. + * It is unlikely any theme defines colours for a GtkButton sitting on + * a menu bar. + */ + rel_pos_frame = gtk_widget_get_parent(ghidgui->cursor_position_relative_label); + abs_pos_frame = gtk_widget_get_parent(ghidgui->cursor_position_absolute_label); + gtk_widget_set_style(rel_pos_frame, menu_bar_style); + gtk_widget_set_style(abs_pos_frame, menu_bar_style); + gtk_widget_set_style(ghidgui->grid_units_button, tool_button_style); + gtk_widget_set_style(ghidgui->grid_units_label, tool_button_label_style); } /* Attempt to produce a conststent style for our extra menu-bar items by @@ -1190,18 +1039,15 @@ * Setup signal handlers to update our efforts if the user changes their * theme whilst we are running. */ -static void -fix_topbar_theming (void) +static void fix_topbar_theming(void) { - GtkSettings *settings; + GtkSettings *settings; - do_fix_topbar_theming (); + do_fix_topbar_theming(); - settings = gtk_widget_get_settings (ghidgui->top_bar_background); - g_signal_connect (settings, "notify::gtk-theme-name", - G_CALLBACK (do_fix_topbar_theming), NULL); - g_signal_connect (settings, "notify::gtk-font-name", - G_CALLBACK (do_fix_topbar_theming), NULL); + settings = gtk_widget_get_settings(ghidgui->top_bar_background); + g_signal_connect(settings, "notify::gtk-theme-name", G_CALLBACK(do_fix_topbar_theming), NULL); + g_signal_connect(settings, "notify::gtk-font-name", G_CALLBACK(do_fix_topbar_theming), NULL); } /* @@ -1208,277 +1054,225 @@ * Create the top_window contents. The config settings should be loaded * before this is called. */ -static void -ghid_build_pcb_top_window (void) +static void ghid_build_pcb_top_window(void) { - GtkWidget *window; - GtkWidget *vbox_main, *hbox_middle, *hbox; - GtkWidget *vbox, *frame; - GtkWidget *label; - GHidPort *port = &ghid_port; - GtkWidget *scrolled; + GtkWidget *window; + GtkWidget *vbox_main, *hbox_middle, *hbox; + GtkWidget *vbox, *frame; + GtkWidget *label; + GHidPort *port = &ghid_port; + GtkWidget *scrolled; - window = gport->top_window; + window = gport->top_window; - vbox_main = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (window), vbox_main); + vbox_main = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(window), vbox_main); - /* -- Top control bar */ - ghidgui->top_bar_background = gtk_event_box_new (); - gtk_box_pack_start (GTK_BOX (vbox_main), - ghidgui->top_bar_background, FALSE, FALSE, 0); + /* -- Top control bar */ + ghidgui->top_bar_background = gtk_event_box_new(); + gtk_box_pack_start(GTK_BOX(vbox_main), ghidgui->top_bar_background, FALSE, FALSE, 0); - ghidgui->top_hbox = gtk_hbox_new (FALSE, 4); - gtk_container_add (GTK_CONTAINER (ghidgui->top_bar_background), - ghidgui->top_hbox); + ghidgui->top_hbox = gtk_hbox_new(FALSE, 4); + gtk_container_add(GTK_CONTAINER(ghidgui->top_bar_background), ghidgui->top_hbox); - /* - * menu_hbox will be made insensitive when the gui needs - * a modal button GetLocation button press. - */ - ghidgui->menu_hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (ghidgui->top_hbox), ghidgui->menu_hbox, - FALSE, FALSE, 0); + /* + * menu_hbox will be made insensitive when the gui needs + * a modal button GetLocation button press. + */ + ghidgui->menu_hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(ghidgui->top_hbox), ghidgui->menu_hbox, FALSE, FALSE, 0); - ghidgui->menubar_toolbar_vbox = gtk_vbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (ghidgui->menu_hbox), - ghidgui->menubar_toolbar_vbox, FALSE, FALSE, 0); + ghidgui->menubar_toolbar_vbox = gtk_vbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(ghidgui->menu_hbox), ghidgui->menubar_toolbar_vbox, FALSE, FALSE, 0); - /* Build layer menus */ - ghidgui->layer_selector = ghid_layer_selector_new (); - make_layer_buttons (ghidgui->layer_selector); - make_virtual_layer_buttons (ghidgui->layer_selector); - g_signal_connect (G_OBJECT (ghidgui->layer_selector), "select_layer", - G_CALLBACK (layer_selector_select_callback), - NULL); - g_signal_connect (G_OBJECT (ghidgui->layer_selector), "toggle_layer", - G_CALLBACK (layer_selector_toggle_callback), - NULL); - /* Build main menu */ - ghidgui->menu_bar = ghid_load_menus (); - gtk_box_pack_start (GTK_BOX (ghidgui->menubar_toolbar_vbox), - ghidgui->menu_bar, FALSE, FALSE, 0); + /* Build layer menus */ + ghidgui->layer_selector = ghid_layer_selector_new(); + make_layer_buttons(ghidgui->layer_selector); + make_virtual_layer_buttons(ghidgui->layer_selector); + g_signal_connect(G_OBJECT(ghidgui->layer_selector), "select_layer", G_CALLBACK(layer_selector_select_callback), NULL); + g_signal_connect(G_OBJECT(ghidgui->layer_selector), "toggle_layer", G_CALLBACK(layer_selector_toggle_callback), NULL); + /* Build main menu */ + ghidgui->menu_bar = ghid_load_menus(); + gtk_box_pack_start(GTK_BOX(ghidgui->menubar_toolbar_vbox), ghidgui->menu_bar, FALSE, FALSE, 0); - make_mode_buttons_and_toolbar (&ghidgui->mode_buttons_frame, - &ghidgui->mode_toolbar); - gtk_box_pack_start (GTK_BOX (ghidgui->menubar_toolbar_vbox), - ghidgui->mode_toolbar, FALSE, FALSE, 0); + make_mode_buttons_and_toolbar(&ghidgui->mode_buttons_frame, &ghidgui->mode_toolbar); + gtk_box_pack_start(GTK_BOX(ghidgui->menubar_toolbar_vbox), ghidgui->mode_toolbar, FALSE, FALSE, 0); - ghidgui->position_hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_end (GTK_BOX(ghidgui->top_hbox), - ghidgui->position_hbox, FALSE, FALSE, 4); + ghidgui->position_hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_end(GTK_BOX(ghidgui->top_hbox), ghidgui->position_hbox, FALSE, FALSE, 4); - make_cursor_position_labels (ghidgui->position_hbox, port); + make_cursor_position_labels(ghidgui->position_hbox, port); - hbox_middle = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox_main), hbox_middle, TRUE, TRUE, 3); + hbox_middle = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox_main), hbox_middle, TRUE, TRUE, 3); - fix_topbar_theming (); /* Must be called after toolbar is created */ + fix_topbar_theming(); /* Must be called after toolbar is created */ - /* -- Left control bar */ - /* - * This box will be made insensitive when the gui needs - * a modal button GetLocation button press. - */ - ghidgui->left_toolbar = gtk_vbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox_middle), - ghidgui->left_toolbar, FALSE, FALSE, 3); + /* -- Left control bar */ + /* + * This box will be made insensitive when the gui needs + * a modal button GetLocation button press. + */ + ghidgui->left_toolbar = gtk_vbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(hbox_middle), ghidgui->left_toolbar, FALSE, FALSE, 3); - vbox = ghid_scrolled_vbox (ghidgui->left_toolbar, &scrolled, - GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - gtk_box_pack_start (GTK_BOX(vbox), ghidgui->layer_selector, - FALSE, FALSE, 0); + vbox = ghid_scrolled_vbox(ghidgui->left_toolbar, &scrolled, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + gtk_box_pack_start(GTK_BOX(vbox), ghidgui->layer_selector, FALSE, FALSE, 0); - /* ghidgui->mode_buttons_frame was created above in the call to - * make_mode_buttons_and_toolbar (...); - */ - gtk_box_pack_start (GTK_BOX (ghidgui->left_toolbar), - ghidgui->mode_buttons_frame, FALSE, FALSE, 0); + /* ghidgui->mode_buttons_frame was created above in the call to + * make_mode_buttons_and_toolbar (...); + */ + gtk_box_pack_start(GTK_BOX(ghidgui->left_toolbar), ghidgui->mode_buttons_frame, FALSE, FALSE, 0); - frame = gtk_frame_new(NULL); - gtk_box_pack_end (GTK_BOX (ghidgui->left_toolbar), frame, FALSE, FALSE, 0); - vbox = gtk_vbox_new(FALSE, 0); - gtk_container_add(GTK_CONTAINER(frame), vbox); - hbox = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX (vbox), hbox, FALSE, FALSE, 1); - ghidgui->route_style_selector = ghid_route_style_selector_new (); - make_route_style_buttons - (GHID_ROUTE_STYLE_SELECTOR (ghidgui->route_style_selector)); - gtk_box_pack_start(GTK_BOX(hbox), ghidgui->route_style_selector, - FALSE, FALSE, 4); + frame = gtk_frame_new(NULL); + gtk_box_pack_end(GTK_BOX(ghidgui->left_toolbar), frame, FALSE, FALSE, 0); + vbox = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(frame), vbox); + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 1); + ghidgui->route_style_selector = ghid_route_style_selector_new(); + make_route_style_buttons(GHID_ROUTE_STYLE_SELECTOR(ghidgui->route_style_selector)); + gtk_box_pack_start(GTK_BOX(hbox), ghidgui->route_style_selector, FALSE, FALSE, 4); - ghidgui->vbox_middle = gtk_vbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox_middle), - ghidgui->vbox_middle, TRUE, TRUE, 0); + ghidgui->vbox_middle = gtk_vbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(hbox_middle), ghidgui->vbox_middle, TRUE, TRUE, 0); - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (ghidgui->vbox_middle), hbox, TRUE, TRUE, 0); + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(ghidgui->vbox_middle), hbox, TRUE, TRUE, 0); - /* -- The PCB layout output drawing area */ + /* -- The PCB layout output drawing area */ - gport->drawing_area = gtk_drawing_area_new (); - ghid_init_drawing_widget (gport->drawing_area, gport); + gport->drawing_area = gtk_drawing_area_new(); + ghid_init_drawing_widget(gport->drawing_area, gport); - gtk_widget_add_events (gport->drawing_area, GDK_EXPOSURE_MASK - | GDK_LEAVE_NOTIFY_MASK | GDK_ENTER_NOTIFY_MASK - | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK - | GDK_KEY_RELEASE_MASK | GDK_KEY_PRESS_MASK - | GDK_FOCUS_CHANGE_MASK | GDK_POINTER_MOTION_MASK - | GDK_POINTER_MOTION_HINT_MASK); + gtk_widget_add_events(gport->drawing_area, GDK_EXPOSURE_MASK + | GDK_LEAVE_NOTIFY_MASK | GDK_ENTER_NOTIFY_MASK + | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK + | GDK_KEY_RELEASE_MASK | GDK_KEY_PRESS_MASK + | GDK_FOCUS_CHANGE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); - /* - * This is required to get the drawing_area key-press-event. Also the - * enter and button press callbacks grab focus to be sure we have it - * when in the drawing_area. - */ - gtk_widget_set_can_focus (gport->drawing_area, TRUE); + /* + * This is required to get the drawing_area key-press-event. Also the + * enter and button press callbacks grab focus to be sure we have it + * when in the drawing_area. + */ + gtk_widget_set_can_focus(gport->drawing_area, TRUE); - gtk_box_pack_start (GTK_BOX (hbox), gport->drawing_area, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(hbox), gport->drawing_area, TRUE, TRUE, 0); - ghidgui->v_adjustment = gtk_adjustment_new (0.0, 0.0, 100.0, - 10.0, 10.0, 10.0); - ghidgui->v_range = - gtk_vscrollbar_new (GTK_ADJUSTMENT (ghidgui->v_adjustment)); + ghidgui->v_adjustment = gtk_adjustment_new(0.0, 0.0, 100.0, 10.0, 10.0, 10.0); + ghidgui->v_range = gtk_vscrollbar_new(GTK_ADJUSTMENT(ghidgui->v_adjustment)); - gtk_box_pack_start (GTK_BOX (hbox), ghidgui->v_range, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(hbox), ghidgui->v_range, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (ghidgui->v_adjustment), "value_changed", - G_CALLBACK (v_adjustment_changed_cb), ghidgui); + g_signal_connect(G_OBJECT(ghidgui->v_adjustment), "value_changed", G_CALLBACK(v_adjustment_changed_cb), ghidgui); - ghidgui->h_adjustment = gtk_adjustment_new (0.0, 0.0, 100.0, - 10.0, 10.0, 10.0); - ghidgui->h_range = - gtk_hscrollbar_new (GTK_ADJUSTMENT (ghidgui->h_adjustment)); - gtk_box_pack_start (GTK_BOX (ghidgui->vbox_middle), - ghidgui->h_range, FALSE, FALSE, 0); + ghidgui->h_adjustment = gtk_adjustment_new(0.0, 0.0, 100.0, 10.0, 10.0, 10.0); + ghidgui->h_range = gtk_hscrollbar_new(GTK_ADJUSTMENT(ghidgui->h_adjustment)); + gtk_box_pack_start(GTK_BOX(ghidgui->vbox_middle), ghidgui->h_range, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (ghidgui->h_adjustment), "value_changed", - G_CALLBACK (h_adjustment_changed_cb), ghidgui); + g_signal_connect(G_OBJECT(ghidgui->h_adjustment), "value_changed", G_CALLBACK(h_adjustment_changed_cb), ghidgui); - /* -- The bottom status line label */ - ghidgui->status_line_hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (ghidgui->vbox_middle), - ghidgui->status_line_hbox, FALSE, FALSE, 2); + /* -- The bottom status line label */ + ghidgui->status_line_hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(ghidgui->vbox_middle), ghidgui->status_line_hbox, FALSE, FALSE, 2); - label = gtk_label_new (""); - gtk_label_set_use_markup (GTK_LABEL (label), TRUE); - gtk_box_pack_start (GTK_BOX (ghidgui->status_line_hbox), label, FALSE, - FALSE, 0); - ghidgui->status_line_label = label; + label = gtk_label_new(""); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_box_pack_start(GTK_BOX(ghidgui->status_line_hbox), label, FALSE, FALSE, 0); + ghidgui->status_line_label = label; - /* Depending on user setting, the command_combo_box may get packed into - | the status_line_hbox, but it will happen on demand the first time - | the user does a command entry. - */ + /* Depending on user setting, the command_combo_box may get packed into + | the status_line_hbox, but it will happen on demand the first time + | the user does a command entry. + */ - g_signal_connect (G_OBJECT (gport->drawing_area), "realize", - G_CALLBACK (ghid_port_drawing_realize_cb), - port); - g_signal_connect (G_OBJECT (gport->drawing_area), "expose_event", - G_CALLBACK (ghid_drawing_area_expose_cb), - port); - g_signal_connect (G_OBJECT (gport->top_window), "configure_event", - G_CALLBACK (top_window_configure_event_cb), port); - g_signal_connect (gport->top_window, "enter-notify-event", - G_CALLBACK (top_window_enter_cb), port); - g_signal_connect (G_OBJECT (gport->drawing_area), "configure_event", - G_CALLBACK (ghid_port_drawing_area_configure_event_cb), - port); + g_signal_connect(G_OBJECT(gport->drawing_area), "realize", G_CALLBACK(ghid_port_drawing_realize_cb), port); + g_signal_connect(G_OBJECT(gport->drawing_area), "expose_event", G_CALLBACK(ghid_drawing_area_expose_cb), port); + g_signal_connect(G_OBJECT(gport->top_window), "configure_event", G_CALLBACK(top_window_configure_event_cb), port); + g_signal_connect(gport->top_window, "enter-notify-event", G_CALLBACK(top_window_enter_cb), port); + g_signal_connect(G_OBJECT(gport->drawing_area), "configure_event", + G_CALLBACK(ghid_port_drawing_area_configure_event_cb), port); - /* Mouse and key events will need to be intercepted when PCB needs a - | location from the user. - */ + /* Mouse and key events will need to be intercepted when PCB needs a + | location from the user. + */ - ghid_interface_input_signals_connect (); + ghid_interface_input_signals_connect(); - g_signal_connect (G_OBJECT (gport->drawing_area), "scroll_event", - G_CALLBACK (ghid_port_window_mouse_scroll_cb), port); - g_signal_connect (G_OBJECT (gport->drawing_area), "enter_notify_event", - G_CALLBACK (ghid_port_window_enter_cb), port); - g_signal_connect (G_OBJECT (gport->drawing_area), "leave_notify_event", - G_CALLBACK (ghid_port_window_leave_cb), port); - g_signal_connect (G_OBJECT (gport->drawing_area), "motion_notify_event", - G_CALLBACK (ghid_port_window_motion_cb), port); + g_signal_connect(G_OBJECT(gport->drawing_area), "scroll_event", G_CALLBACK(ghid_port_window_mouse_scroll_cb), port); + g_signal_connect(G_OBJECT(gport->drawing_area), "enter_notify_event", G_CALLBACK(ghid_port_window_enter_cb), port); + g_signal_connect(G_OBJECT(gport->drawing_area), "leave_notify_event", G_CALLBACK(ghid_port_window_leave_cb), port); + g_signal_connect(G_OBJECT(gport->drawing_area), "motion_notify_event", G_CALLBACK(ghid_port_window_motion_cb), port); - g_signal_connect (G_OBJECT (window), "delete_event", - G_CALLBACK (delete_chart_cb), port); - g_signal_connect (G_OBJECT (window), "destroy", - G_CALLBACK (destroy_chart_cb), port); + g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(delete_chart_cb), port); + g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy_chart_cb), port); - ghidgui->creating = FALSE; + ghidgui->creating = FALSE; - gtk_widget_show_all (gport->top_window); - ghid_pack_mode_buttons (); - gdk_window_set_back_pixmap (gtk_widget_get_window (gport->drawing_area), - NULL, FALSE); + gtk_widget_show_all(gport->top_window); + ghid_pack_mode_buttons(); + gdk_window_set_back_pixmap(gtk_widget_get_window(gport->drawing_area), NULL, FALSE); } - /* Connect and disconnect just the signals a g_main_loop() will need. - | Cursor and motion events still need to be handled by the top level - | loop, so don't connect/reconnect these. - | A g_main_loop will be running when PCB wants the user to select a - | location or if command entry is needed in the status line hbox. - | During these times normal button/key presses are intercepted, either - | by new signal handlers or the command_combo_box entry. - */ -static gulong button_press_handler, button_release_handler, - key_press_handler, key_release_handler; + /* Connect and disconnect just the signals a g_main_loop() will need. + | Cursor and motion events still need to be handled by the top level + | loop, so don't connect/reconnect these. + | A g_main_loop will be running when PCB wants the user to select a + | location or if command entry is needed in the status line hbox. + | During these times normal button/key presses are intercepted, either + | by new signal handlers or the command_combo_box entry. + */ +static gulong button_press_handler, button_release_handler, key_press_handler, key_release_handler; -void -ghid_interface_input_signals_connect (void) +void ghid_interface_input_signals_connect(void) { - button_press_handler = - g_signal_connect (G_OBJECT (gport->drawing_area), "button_press_event", - G_CALLBACK (ghid_port_button_press_cb), NULL); + button_press_handler = + g_signal_connect(G_OBJECT(gport->drawing_area), "button_press_event", G_CALLBACK(ghid_port_button_press_cb), NULL); - button_release_handler = - g_signal_connect (G_OBJECT (gport->drawing_area), "button_release_event", - G_CALLBACK (ghid_port_button_release_cb), NULL); + button_release_handler = + g_signal_connect(G_OBJECT(gport->drawing_area), "button_release_event", G_CALLBACK(ghid_port_button_release_cb), NULL); - key_press_handler = - g_signal_connect (G_OBJECT (gport->drawing_area), "key_press_event", - G_CALLBACK (ghid_port_key_press_cb), NULL); + key_press_handler = + g_signal_connect(G_OBJECT(gport->drawing_area), "key_press_event", G_CALLBACK(ghid_port_key_press_cb), NULL); - key_release_handler = - g_signal_connect (G_OBJECT (gport->drawing_area), "key_release_event", - G_CALLBACK (ghid_port_key_release_cb), NULL); + key_release_handler = + g_signal_connect(G_OBJECT(gport->drawing_area), "key_release_event", G_CALLBACK(ghid_port_key_release_cb), NULL); } -void -ghid_interface_input_signals_disconnect (void) +void ghid_interface_input_signals_disconnect(void) { - if (button_press_handler) - g_signal_handler_disconnect (gport->drawing_area, button_press_handler); + if (button_press_handler) + g_signal_handler_disconnect(gport->drawing_area, button_press_handler); - if (button_release_handler) - g_signal_handler_disconnect (gport->drawing_area, button_release_handler); + if (button_release_handler) + g_signal_handler_disconnect(gport->drawing_area, button_release_handler); - if (key_press_handler) - g_signal_handler_disconnect (gport->drawing_area, key_press_handler); + if (key_press_handler) + g_signal_handler_disconnect(gport->drawing_area, key_press_handler); - if (key_release_handler) - g_signal_handler_disconnect (gport->drawing_area, key_release_handler); + if (key_release_handler) + g_signal_handler_disconnect(gport->drawing_area, key_release_handler); - button_press_handler = button_release_handler = 0; - key_press_handler = key_release_handler = 0; + button_press_handler = button_release_handler = 0; + key_press_handler = key_release_handler = 0; } - /* We'll set the interface insensitive when a g_main_loop is running so the - | Gtk menus and buttons don't respond and interfere with the special entry - | the user needs to be doing. - */ -void -ghid_interface_set_sensitive (gboolean sensitive) + /* We'll set the interface insensitive when a g_main_loop is running so the + | Gtk menus and buttons don't respond and interfere with the special entry + | the user needs to be doing. + */ +void ghid_interface_set_sensitive(gboolean sensitive) { - gtk_widget_set_sensitive (ghidgui->left_toolbar, sensitive); - gtk_widget_set_sensitive (ghidgui->menu_hbox, sensitive); + gtk_widget_set_sensitive(ghidgui->left_toolbar, sensitive); + gtk_widget_set_sensitive(ghidgui->menu_hbox, sensitive); } @@ -1485,123 +1279,97 @@ /* ---------------------------------------------------------------------- * initializes icon pixmap and also cursor bit maps */ -static void -ghid_init_icons (GHidPort * port) +static void ghid_init_icons(GHidPort * port) { - GdkWindow *window = gtk_widget_get_window (gport->top_window); + GdkWindow *window = gtk_widget_get_window(gport->top_window); - XC_clock_source = gdk_bitmap_create_from_data (window, - (char *) rotateIcon_bits, - rotateIcon_width, - rotateIcon_height); - XC_clock_mask = - gdk_bitmap_create_from_data (window, (char *) rotateMask_bits, - rotateMask_width, rotateMask_height); + XC_clock_source = gdk_bitmap_create_from_data(window, (char *) rotateIcon_bits, rotateIcon_width, rotateIcon_height); + XC_clock_mask = gdk_bitmap_create_from_data(window, (char *) rotateMask_bits, rotateMask_width, rotateMask_height); - XC_hand_source = gdk_bitmap_create_from_data (window, - (char *) handIcon_bits, - handIcon_width, - handIcon_height); - XC_hand_mask = - gdk_bitmap_create_from_data (window, (char *) handMask_bits, - handMask_width, handMask_height); + XC_hand_source = gdk_bitmap_create_from_data(window, (char *) handIcon_bits, handIcon_width, handIcon_height); + XC_hand_mask = gdk_bitmap_create_from_data(window, (char *) handMask_bits, handMask_width, handMask_height); - XC_lock_source = gdk_bitmap_create_from_data (window, - (char *) lockIcon_bits, - lockIcon_width, - lockIcon_height); - XC_lock_mask = - gdk_bitmap_create_from_data (window, (char *) lockMask_bits, - lockMask_width, lockMask_height); + XC_lock_source = gdk_bitmap_create_from_data(window, (char *) lockIcon_bits, lockIcon_width, lockIcon_height); + XC_lock_mask = gdk_bitmap_create_from_data(window, (char *) lockMask_bits, lockMask_width, lockMask_height); } -void -ghid_create_pcb_widgets (void) +void ghid_create_pcb_widgets(void) { - GHidPort *port = &ghid_port; - GError *err = NULL; + GHidPort *port = &ghid_port; + GError *err = NULL; - if (bg_image_file) - ghidgui->bg_pixbuf = gdk_pixbuf_new_from_file(bg_image_file, &err); - if (err) - { - g_error("%s", err->message); - g_error_free(err); - } - ghid_build_pcb_top_window (); - ghid_install_accel_groups (GTK_WINDOW (port->top_window), ghidgui); - ghid_update_toggle_flags (); + if (bg_image_file) + ghidgui->bg_pixbuf = gdk_pixbuf_new_from_file(bg_image_file, &err); + if (err) { + g_error("%s", err->message); + g_error_free(err); + } + ghid_build_pcb_top_window(); + ghid_install_accel_groups(GTK_WINDOW(port->top_window), ghidgui); + ghid_update_toggle_flags(); - ghid_init_icons (port); - SetMode (ARROW_MODE); - ghid_mode_buttons_update (); + ghid_init_icons(port); + SetMode(ARROW_MODE); + ghid_mode_buttons_update(); } -static gboolean -ghid_listener_cb (GIOChannel *source, - GIOCondition condition, - gpointer data) +static gboolean ghid_listener_cb(GIOChannel * source, GIOCondition condition, gpointer data) { - GIOStatus status; - gchar *str; - gsize len; - gsize term; - GError *err = NULL; + GIOStatus status; + gchar *str; + gsize len; + gsize term; + GError *err = NULL; - if (condition & G_IO_HUP) - { - gui->log ("Read end of pipe died!\n"); - return FALSE; - } + if (condition & G_IO_HUP) { + gui->log("Read end of pipe died!\n"); + return FALSE; + } - if (condition == G_IO_IN) - { - status = g_io_channel_read_line (source, &str, &len, &term, &err); - switch (status) - { - case G_IO_STATUS_NORMAL: - hid_parse_actions (str); - g_free (str); - break; + if (condition == G_IO_IN) { + status = g_io_channel_read_line(source, &str, &len, &term, &err); + switch (status) { + case G_IO_STATUS_NORMAL: + hid_parse_actions(str); + g_free(str); + break; - case G_IO_STATUS_ERROR: - gui->log ("ERROR status from g_io_channel_read_line\n"); - return FALSE; - break; + case G_IO_STATUS_ERROR: + gui->log("ERROR status from g_io_channel_read_line\n"); + return FALSE; + break; - case G_IO_STATUS_EOF: - gui->log ("Input pipe returned EOF. The --listen option is \n" - "probably not running anymore in this session.\n"); - return FALSE; - break; + case G_IO_STATUS_EOF: + gui->log("Input pipe returned EOF. The --listen option is \n" "probably not running anymore in this session.\n"); + return FALSE; + break; - case G_IO_STATUS_AGAIN: - gui->log ("AGAIN status from g_io_channel_read_line\n"); - return FALSE; - break; + case G_IO_STATUS_AGAIN: + gui->log("AGAIN status from g_io_channel_read_line\n"); + return FALSE; + break; - default: - fprintf (stderr, "ERROR: unhandled case in ghid_listener_cb\n"); - return FALSE; - break; + default: + fprintf(stderr, "ERROR: unhandled case in ghid_listener_cb\n"); + return FALSE; + break; + } + } + else + fprintf(stderr, "Unknown condition in ghid_listener_cb\n"); - } - else - fprintf (stderr, "Unknown condition in ghid_listener_cb\n"); - - return TRUE; + return TRUE; } -static void -ghid_create_listener (void) +static void ghid_create_listener(void) { - GIOChannel *channel; - int fd = fileno (stdin); + GIOChannel *channel; + int fd = fileno(stdin); - channel = g_io_channel_unix_new (fd); - g_io_add_watch (channel, G_IO_IN, ghid_listener_cb, NULL); + channel = g_io_channel_unix_new(fd); + g_io_add_watch(channel, G_IO_IN, ghid_listener_cb, NULL); } @@ -1608,7 +1376,8 @@ /* ------------------------------------------------------------ */ static int stdin_listen = 0; -static const char *pcbmenu_paths_in[] = {"gpcb-menu.res", "gpcb-menu.res", PCBSHAREDIR "/gpcb-menu.res", NULL}; +static const char *pcbmenu_paths_in[] = { "gpcb-menu.res", "gpcb-menu.res", PCBSHAREDIR "/gpcb-menu.res", NULL }; + static char **pcbmenu_paths = NULL; HID_Attribute ghid_attribute_list[] = { @@ -1620,8 +1389,8 @@ @end ftable %end-doc */ - {"listen", "Listen for actions on stdin", - HID_Boolean, 0, 0, {0, 0, 0}, 0, &stdin_listen}, + {"listen", "Listen for actions on stdin", + HID_Boolean, 0, 0, {0, 0, 0}, 0, &stdin_listen}, #define HA_listen 0 /* %start-doc options "21 GTK+ GUI Options" @@ -1633,8 +1402,8 @@ @end ftable %end-doc */ - {"bg-image", "Background Image", - HID_String, 0, 0, {0, 0, 0}, 0, &bg_image_file}, + {"bg-image", "Background Image", + HID_String, 0, 0, {0, 0, 0}, 0, &bg_image_file}, #define HA_bg_image 1 /* %start-doc options "21 GTK+ GUI Options" @@ -1644,174 +1413,159 @@ @end ftable %end-doc */ -{"pcb-menu", "Location of gpcb-menu.res file", - HID_String, 0, 0, {0, "gpcb-menu.res", 0}, 0, &pcbmenu_paths_in[0]} + {"pcb-menu", "Location of gpcb-menu.res file", + HID_String, 0, 0, {0, "gpcb-menu.res", 0}, 0, &pcbmenu_paths_in[0]} #define HA_pcbmenu 2 }; -REGISTER_ATTRIBUTES (ghid_attribute_list) +REGISTER_ATTRIBUTES(ghid_attribute_list) -HID_Attribute * -ghid_get_export_options (int *n_ret) + HID_Attribute *ghid_get_export_options(int *n_ret) { - *n_ret = sizeof (ghid_attribute_list) / sizeof (HID_Attribute); - return ghid_attribute_list; + *n_ret = sizeof(ghid_attribute_list) / sizeof(HID_Attribute); + return ghid_attribute_list; } - /* Create top level window for routines that will need top_window - | before ghid_create_pcb_widgets() is called. - */ -void -ghid_parse_arguments (int *argc, char ***argv) + /* Create top level window for routines that will need top_window + | before ghid_create_pcb_widgets() is called. + */ +void ghid_parse_arguments(int *argc, char ***argv) { - GtkWidget *window; - gint i; - GdkPixbuf *icon; + GtkWidget *window; + gint i; + GdkPixbuf *icon; - /* on windows we need to figure out the installation directory */ + /* on windows we need to figure out the installation directory */ #ifdef WIN32 - char * tmps; - char * libdir; - tmps = g_win32_get_package_installation_directory(PACKAGE "-" VERSION, NULL); + char *tmps; + char *libdir; + tmps = g_win32_get_package_installation_directory(PACKAGE "-" VERSION, NULL); #define REST_OF_PATH G_DIR_SEPARATOR_S "share" G_DIR_SEPARATOR_S PACKAGE G_DIR_SEPARATOR_S "pcblib" - libdir = (char *) malloc(strlen(tmps) + - strlen(REST_OF_PATH) + - 1); - sprintf(libdir, "%s%s", tmps, REST_OF_PATH); - free(tmps); - - Settings.LibraryTree = libdir; + libdir = (char *) malloc(strlen(tmps) + strlen(REST_OF_PATH) + 1); + sprintf(libdir, "%s%s", tmps, REST_OF_PATH); + free(tmps); + Settings.LibraryTree = libdir; + #undef REST_OF_PATH -#endif +#endif #if defined (DEBUG) - for (i = 0; i < *argc; i++) - { - printf ("ghid_parse_arguments(): *argv[%d] = \"%s\"\n", i, (*argv)[i]); - } + for (i = 0; i < *argc; i++) { + printf("ghid_parse_arguments(): *argv[%d] = \"%s\"\n", i, (*argv)[i]); + } #endif - /* Threads aren't used in PCB, but this call would go here. - */ - /* g_thread_init (NULL); */ + /* Threads aren't used in PCB, but this call would go here. + */ + /* g_thread_init (NULL); */ #if defined (ENABLE_NLS) - /* Do our own setlocale() stufff since we want to override LC_NUMERIC - */ - gtk_set_locale (); - setlocale (LC_NUMERIC, "C"); /* use decimal point instead of comma */ + /* Do our own setlocale() stufff since we want to override LC_NUMERIC + */ + gtk_set_locale(); + setlocale(LC_NUMERIC, "C"); /* use decimal point instead of comma */ #endif - /* - * Prevent gtk_init() and gtk_init_check() from automatically - * calling setlocale (LC_ALL, "") which would undo LC_NUMERIC if ENABLE_NLS - * We also don't want locale set if no ENABLE_NLS to keep "C" LC_NUMERIC. - */ - gtk_disable_setlocale (); + /* + * Prevent gtk_init() and gtk_init_check() from automatically + * calling setlocale (LC_ALL, "") which would undo LC_NUMERIC if ENABLE_NLS + * We also don't want locale set if no ENABLE_NLS to keep "C" LC_NUMERIC. + */ + gtk_disable_setlocale(); - gtk_init (argc, argv); + gtk_init(argc, argv); - gport = &ghid_port; - gport->view.coord_per_px = 300.0; - pixel_slop = 300; + gport = &ghid_port; + gport->view.coord_per_px = 300.0; + pixel_slop = 300; - ghid_init_renderer (argc, argv, gport); + ghid_init_renderer(argc, argv, gport); - ghid_config_files_read (argc, argv); + ghid_config_files_read(argc, argv); - Settings.AutoPlace = 0; - for (i = 0; i < *argc; i++) - { - if (strcmp ((*argv)[i], "-auto-place") == 0) - Settings.AutoPlace = 1; - } + Settings.AutoPlace = 0; + for (i = 0; i < *argc; i++) { + if (strcmp((*argv)[i], "-auto-place") == 0) + Settings.AutoPlace = 1; + } #ifdef ENABLE_NLS #ifdef LOCALEDIR - bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain(PACKAGE, LOCALEDIR); #endif - textdomain (PACKAGE); - bind_textdomain_codeset (PACKAGE, "UTF-8"); + textdomain(PACKAGE); + bind_textdomain_codeset(PACKAGE, "UTF-8"); #endif /* ENABLE_NLS */ - icon = gdk_pixbuf_new_from_xpm_data ((const gchar **) icon_bits); - gtk_window_set_default_icon (icon); + icon = gdk_pixbuf_new_from_xpm_data((const gchar **) icon_bits); + gtk_window_set_default_icon(icon); - window = gport->top_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (window), "PCB"); - gtk_window_set_default_size(GTK_WINDOW(window), - ghidgui->top_window_width, ghidgui->top_window_height); + window = gport->top_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_title(GTK_WINDOW(window), "PCB"); + gtk_window_set_default_size(GTK_WINDOW(window), ghidgui->top_window_width, ghidgui->top_window_height); - if (Settings.AutoPlace) - gtk_window_move (GTK_WINDOW (window), 10, 10); + if (Settings.AutoPlace) + gtk_window_move(GTK_WINDOW(window), 10, 10); - gtk_widget_show_all (gport->top_window); - ghidgui->creating = TRUE; + gtk_widget_show_all(gport->top_window); + ghidgui->creating = TRUE; } -void -ghid_do_export (HID_Attr_Val * options) +void ghid_do_export(HID_Attr_Val * options) { - ghid_create_pcb_widgets (); + ghid_create_pcb_widgets(); - /* These are needed to make sure the @layerpick and @layerview menus - * are properly initialized and synchronized with the current PCB. - */ - ghid_layer_buttons_update (); - ghid_main_menu_install_route_style_selector - (GHID_MAIN_MENU (ghidgui->menu_bar), - GHID_ROUTE_STYLE_SELECTOR (ghidgui->route_style_selector)); + /* These are needed to make sure the @layerpick and @layerview menus + * are properly initialized and synchronized with the current PCB. + */ + ghid_layer_buttons_update(); + ghid_main_menu_install_route_style_selector + (GHID_MAIN_MENU(ghidgui->menu_bar), GHID_ROUTE_STYLE_SELECTOR(ghidgui->route_style_selector)); - if (stdin_listen) - ghid_create_listener (); + if (stdin_listen) + ghid_create_listener(); - ghid_notify_gui_is_up (); + ghid_notify_gui_is_up(); - event(EVENT_GUI_INIT, NULL); + event(EVENT_GUI_INIT, NULL); - gtk_main (); - ghid_config_files_write (); + gtk_main(); + ghid_config_files_write(); } /*! \brief callback for */ -static gboolean -get_layer_visible_cb (int id) +static gboolean get_layer_visible_cb(int id) { - int visible; - layer_process (NULL, NULL, &visible, id); - return visible; + int visible; + layer_process(NULL, NULL, &visible, id); + return visible; } -gint -LayersChanged (int argc, char **argv, Coord x, Coord y) +gint LayersChanged(int argc, char **argv, Coord x, Coord y) { - if (!ghidgui || !ghidgui->menu_bar) - return 0; + if (!ghidgui || !ghidgui->menu_bar) + return 0; - ghid_config_groups_changed(); - ghid_layer_buttons_update (); - ghid_layer_selector_show_layers - (GHID_LAYER_SELECTOR (ghidgui->layer_selector), get_layer_visible_cb); + ghid_config_groups_changed(); + ghid_layer_buttons_update(); + ghid_layer_selector_show_layers(GHID_LAYER_SELECTOR(ghidgui->layer_selector), get_layer_visible_cb); - /* FIXME - if a layer is moved it should retain its color. But layers - | currently can't do that because color info is not saved in the - | pcb file. So this makes a moved layer change its color to reflect - | the way it will be when the pcb is reloaded. - */ - pcb_colors_from_settings (PCB); - return 0; + /* FIXME - if a layer is moved it should retain its color. But layers + | currently can't do that because color info is not saved in the + | pcb file. So this makes a moved layer change its color to reflect + | the way it will be when the pcb is reloaded. + */ + pcb_colors_from_settings(PCB); + return 0; } static const char toggleview_syntax[] = -"ToggleView(1..MAXLAYER)\n" -"ToggleView(layername)\n" -"ToggleView(Silk|Rats|Pins|Vias|Mask|BackSide)"; + "ToggleView(1..MAXLAYER)\n" "ToggleView(layername)\n" "ToggleView(Silk|Rats|Pins|Vias|Mask|BackSide)"; -static const char toggleview_help[] = -"Toggle the visibility of the specified layer or layer group."; +static const char toggleview_help[] = "Toggle the visibility of the specified layer or layer group."; /* %start-doc actions ToggleView @@ -1826,64 +1580,55 @@ %end-doc */ -static int -ToggleView (int argc, char **argv, Coord x, Coord y) +static int ToggleView(int argc, char **argv, Coord x, Coord y) { - int i, l; + int i, l; #ifdef DEBUG_MENUS - puts ("Starting ToggleView()."); + puts("Starting ToggleView()."); #endif - if (argc == 0) - { - AFAIL (toggleview); - } - if (isdigit ((int) argv[0][0])) - { - l = atoi (argv[0]) - 1; - } - else if (strcmp (argv[0], "Silk") == 0) - l = LAYER_BUTTON_SILK; - else if (strcmp (argv[0], "Rats") == 0) - l = LAYER_BUTTON_RATS; - else if (strcmp (argv[0], "Pins") == 0) - l = LAYER_BUTTON_PINS; - else if (strcmp (argv[0], "Vias") == 0) - l = LAYER_BUTTON_VIAS; - else if (strcmp (argv[0], "Mask") == 0) - l = LAYER_BUTTON_MASK; - else if (strcmp (argv[0], "BackSide") == 0) - l = LAYER_BUTTON_FARSIDE; - else - { - l = -1; - for (i = 0; i < max_copper_layer + 2; i++) - if (strcmp (argv[0], PCB->Data->Layer[i].Name) == 0) - { - l = i; - break; - } - if (l == -1) - { - AFAIL (toggleview); + if (argc == 0) { + AFAIL(toggleview); } + if (isdigit((int) argv[0][0])) { + l = atoi(argv[0]) - 1; + } + else if (strcmp(argv[0], "Silk") == 0) + l = LAYER_BUTTON_SILK; + else if (strcmp(argv[0], "Rats") == 0) + l = LAYER_BUTTON_RATS; + else if (strcmp(argv[0], "Pins") == 0) + l = LAYER_BUTTON_PINS; + else if (strcmp(argv[0], "Vias") == 0) + l = LAYER_BUTTON_VIAS; + else if (strcmp(argv[0], "Mask") == 0) + l = LAYER_BUTTON_MASK; + else if (strcmp(argv[0], "BackSide") == 0) + l = LAYER_BUTTON_FARSIDE; + else { + l = -1; + for (i = 0; i < max_copper_layer + 2; i++) + if (strcmp(argv[0], PCB->Data->Layer[i].Name) == 0) { + l = i; + break; + } + if (l == -1) { + AFAIL(toggleview); + } - } + } - /* Now that we've figured out which toggle button ought to control - * this layer, simply hit the button and let the pre-existing code deal - */ - ghid_layer_selector_toggle_layer - (GHID_LAYER_SELECTOR (ghidgui->layer_selector), l); - return 0; + /* Now that we've figured out which toggle button ought to control + * this layer, simply hit the button and let the pre-existing code deal + */ + ghid_layer_selector_toggle_layer(GHID_LAYER_SELECTOR(ghidgui->layer_selector), l); + return 0; } -static const char selectlayer_syntax[] = -"SelectLayer(1..MAXLAYER|Silk|Rats)"; +static const char selectlayer_syntax[] = "SelectLayer(1..MAXLAYER|Silk|Rats)"; -static const char selectlayer_help[] = -"Select which layer is the current layer."; +static const char selectlayer_help[] = "Select which layer is the current layer."; /* %start-doc actions SelectLayer @@ -1892,44 +1637,44 @@ %end-doc */ -static int -SelectLayer (int argc, char **argv, Coord x, Coord y) +static int SelectLayer(int argc, char **argv, Coord x, Coord y) { - int newl; - if (argc == 0) - AFAIL (selectlayer); + int newl; + if (argc == 0) + AFAIL(selectlayer); - if (strcasecmp (argv[0], "silk") == 0) - newl = LAYER_BUTTON_SILK; - else if (strcasecmp (argv[0], "rats") == 0) - newl = LAYER_BUTTON_RATS; - else - newl = atoi (argv[0]) - 1; + if (strcasecmp(argv[0], "silk") == 0) + newl = LAYER_BUTTON_SILK; + else if (strcasecmp(argv[0], "rats") == 0) + newl = LAYER_BUTTON_RATS; + else + newl = atoi(argv[0]) - 1; #ifdef DEBUG_MENUS - printf ("SelectLayer(): newl = %d\n", newl); + printf("SelectLayer(): newl = %d\n", newl); #endif - /* Now that we've figured out which radio button ought to select - * this layer, simply hit the button and let the pre-existing code deal - */ - ghid_layer_selector_select_layer - (GHID_LAYER_SELECTOR (ghidgui->layer_selector), newl); + /* Now that we've figured out which radio button ought to select + * this layer, simply hit the button and let the pre-existing code deal + */ + ghid_layer_selector_select_layer(GHID_LAYER_SELECTOR(ghidgui->layer_selector), newl); - return 0; + return 0; } HID_Action gtk_topwindow_action_list[] = { - {"LayersChanged", 0, LayersChanged, - layerschanged_help, layerschanged_syntax}, - {"SelectLayer", 0, SelectLayer, - selectlayer_help, selectlayer_syntax}, - {"ToggleView", 0, ToggleView, - toggleview_help, toggleview_syntax} + {"LayersChanged", 0, LayersChanged, + layerschanged_help, layerschanged_syntax} + , + {"SelectLayer", 0, SelectLayer, + selectlayer_help, selectlayer_syntax} + , + {"ToggleView", 0, ToggleView, + toggleview_help, toggleview_syntax} }; -REGISTER_ACTIONS (gtk_topwindow_action_list) +REGISTER_ACTIONS(gtk_topwindow_action_list) /* * This function is used to check if a specified hotkey in the menu @@ -1939,191 +1684,164 @@ * into the menu callbacks. This function is called as new * accelerators are added when the menus are being built */ -static void -ghid_check_special_key (const char *accel, GtkAction *action, - const Resource *node) + static void + ghid_check_special_key(const char *accel, GtkAction * action, const Resource * node) { - size_t len; - unsigned int mods; - unsigned int ind; + size_t len; + unsigned int mods; + unsigned int ind; - if (action == NULL || accel == NULL || *accel == '\0') - return ; + if (action == NULL || accel == NULL || *accel == '\0') + return; #ifdef DEBUG_MENUS - printf ("%s(\"%s\", \"%s\")\n", __FUNCTION__, accel, name); + printf("%s(\"%s\", \"%s\")\n", __FUNCTION__, accel, name); #endif - mods = 0; - if (strstr (accel, "") ) - { - mods |= GHID_KEY_ALT; - } - if (strstr (accel, "") ) - { - mods |= GHID_KEY_CONTROL; - } - if (strstr (accel, "") ) - { - mods |= GHID_KEY_SHIFT; - } + mods = 0; + if (strstr(accel, "")) { + mods |= GHID_KEY_ALT; + } + if (strstr(accel, "")) { + mods |= GHID_KEY_CONTROL; + } + if (strstr(accel, "")) { + mods |= GHID_KEY_SHIFT; + } - - len = strlen (accel); - + + len = strlen(accel); + #define CHECK_KEY(a) ((len >= strlen (a)) && (strcmp (accel + len - strlen (a), (a)) == 0)) - ind = 0; - if ( CHECK_KEY ("Tab") ) - { - ind = mods | GHID_KEY_TAB; - } - else if ( CHECK_KEY ("Up") ) - { - ind = mods | GHID_KEY_UP; - } - else if ( CHECK_KEY ("Down") ) - { - ind = mods | GHID_KEY_DOWN; - } - else if ( CHECK_KEY ("Left") ) - { - ind = mods | GHID_KEY_LEFT; - } - else if ( CHECK_KEY ("Right") ) - { - ind = mods | GHID_KEY_RIGHT; - } - - if (ind > 0) - { - if (ind >= N_HOTKEY_ACTIONS) - { - fprintf (stderr, "ERROR: overflow of the ghid_hotkey_actions array. Index = %d\n" - "Please report this.\n", ind); - exit (1); + ind = 0; + if (CHECK_KEY("Tab")) { + ind = mods | GHID_KEY_TAB; } + else if (CHECK_KEY("Up")) { + ind = mods | GHID_KEY_UP; + } + else if (CHECK_KEY("Down")) { + ind = mods | GHID_KEY_DOWN; + } + else if (CHECK_KEY("Left")) { + ind = mods | GHID_KEY_LEFT; + } + else if (CHECK_KEY("Right")) { + ind = mods | GHID_KEY_RIGHT; + } - ghid_hotkey_actions[ind].action = action; - ghid_hotkey_actions[ind].node = node; + if (ind > 0) { + if (ind >= N_HOTKEY_ACTIONS) { + fprintf(stderr, "ERROR: overflow of the ghid_hotkey_actions array. Index = %d\n" "Please report this.\n", ind); + exit(1); + } + + ghid_hotkey_actions[ind].action = action; + ghid_hotkey_actions[ind].node = node; #ifdef DEBUG_MENUS - printf ("Adding \"special\" hotkey to ghid_hotkey_actions[%u] :" - " %s (%s)\n", ind, accel, name); + printf("Adding \"special\" hotkey to ghid_hotkey_actions[%u] :" " %s (%s)\n", ind, accel, name); #endif - } + } } /*! \brief Finds the gpcb-menu.res file */ -char * -get_menu_filename (void) +char *get_menu_filename(void) { - char **s, *rv = NULL; - char *home_pcbmenu = NULL; + char **s, *rv = NULL; + char *home_pcbmenu = NULL; - /* homedir is set by the core */ - if (homedir) - { - Message (_("Note: home directory is \"%s\"\n"), homedir); - home_pcbmenu = Concat (homedir, PCB_DIR_SEPARATOR_S, ".pcb", - PCB_DIR_SEPARATOR_S, "gpcb-menu.res", NULL); - } - else - Message (_("Warning: could not determine home directory\n")); + /* homedir is set by the core */ + if (homedir) { + Message(_("Note: home directory is \"%s\"\n"), homedir); + home_pcbmenu = Concat(homedir, PCB_DIR_SEPARATOR_S, ".pcb", PCB_DIR_SEPARATOR_S, "gpcb-menu.res", NULL); + } + else + Message(_("Warning: could not determine home directory\n")); - resolve_all_paths(pcbmenu_paths_in, pcbmenu_paths); + resolve_all_paths(pcbmenu_paths_in, pcbmenu_paths); - for(s = pcbmenu_paths; *s != NULL; s++) { - if (access (*s, R_OK) == 0) - return strdup (*s); - } + for (s = pcbmenu_paths; *s != NULL; s++) { + if (access(*s, R_OK) == 0) + return strdup(*s); + } - if (home_pcbmenu != NULL && (access (home_pcbmenu, R_OK) == 0) ) - rv = home_pcbmenu; + if (home_pcbmenu != NULL && (access(home_pcbmenu, R_OK) == 0)) + rv = home_pcbmenu; - return rv; + return rv; } -static GtkWidget * -ghid_load_menus (void) +static GtkWidget *ghid_load_menus(void) { - char *filename; - const Resource *r = 0, *bir; - const Resource *mr; - GtkWidget *menu_bar = NULL; - int i; + char *filename; + const Resource *r = 0, *bir; + const Resource *mr; + GtkWidget *menu_bar = NULL; + int i; - for (i = 0; i < N_HOTKEY_ACTIONS; i++) - { - ghid_hotkey_actions[i].action = NULL; - ghid_hotkey_actions[i].node = NULL; - } - - bir = resource_parse (0, gpcb_menu_default); - if (!bir) - { - fprintf (stderr, _("Error: internal menu resource didn't parse\n")); - exit(1); - } + for (i = 0; i < N_HOTKEY_ACTIONS; i++) { + ghid_hotkey_actions[i].action = NULL; + ghid_hotkey_actions[i].node = NULL; + } - filename = get_menu_filename (); - if (filename) - { - Message ("Loading menus from %s\n", filename); - r = resource_parse (filename, 0); - } + bir = resource_parse(0, gpcb_menu_default); + if (!bir) { + fprintf(stderr, _("Error: internal menu resource didn't parse\n")); + exit(1); + } - if (!r) - { - Message ("Using default menus\n"); - r = bir; - } - free (filename); + filename = get_menu_filename(); + if (filename) { + Message("Loading menus from %s\n", filename); + r = resource_parse(filename, 0); + } - mr = resource_subres (r, "MainMenu"); - if (!mr) - mr = resource_subres (bir, "MainMenu"); - - if (mr) - { - menu_bar = ghid_main_menu_new (G_CALLBACK (ghid_menu_cb), - ghid_check_special_key); - ghid_main_menu_add_resource (GHID_MAIN_MENU (menu_bar), mr); - } + if (!r) { + Message("Using default menus\n"); + r = bir; + } + free(filename); - mr = resource_subres (r, "PopupMenus"); - if (!mr) - mr = resource_subres (bir, "PopupMenus"); + mr = resource_subres(r, "MainMenu"); + if (!mr) + mr = resource_subres(bir, "MainMenu"); - if (mr) - { - int i; - for (i = 0; i < mr->c; i++) - if (resource_type (mr->v[i]) == 101) - /* This is a named resource which defines a popup menu */ - ghid_main_menu_add_popup_resource (GHID_MAIN_MENU (menu_bar), - mr->v[i].name, mr->v[i].subres); - } + if (mr) { + menu_bar = ghid_main_menu_new(G_CALLBACK(ghid_menu_cb), ghid_check_special_key); + ghid_main_menu_add_resource(GHID_MAIN_MENU(menu_bar), mr); + } + mr = resource_subres(r, "PopupMenus"); + if (!mr) + mr = resource_subres(bir, "PopupMenus"); + + if (mr) { + int i; + for (i = 0; i < mr->c; i++) + if (resource_type(mr->v[i]) == 101) + /* This is a named resource which defines a popup menu */ + ghid_main_menu_add_popup_resource(GHID_MAIN_MENU(menu_bar), mr->v[i].name, mr->v[i].subres); + } + #ifdef DEBUG_MENUS - puts ("Finished loading menus."); + puts("Finished loading menus."); #endif - mr = resource_subres (r, "Mouse"); - if (!mr) - mr = resource_subres (bir, "Mouse"); - if (mr) - load_mouse_resource (mr); + mr = resource_subres(r, "Mouse"); + if (!mr) + mr = resource_subres(bir, "Mouse"); + if (mr) + load_mouse_resource(mr); - return menu_bar; + return menu_bar; } /* ------------------------------------------------------------ */ -static const char adjuststyle_syntax[] = -"AdjustStyle()\n"; +static const char adjuststyle_syntax[] = "AdjustStyle()\n"; -static const char adjuststyle_help[] = -"Open the window which allows editing of the route styles."; +static const char adjuststyle_help[] = "Open the window which allows editing of the route styles."; /* %start-doc actions AdjustStyle @@ -2131,24 +1849,20 @@ %end-doc */ -static int -AdjustStyle(int argc, char **argv, Coord x, Coord y) +static int AdjustStyle(int argc, char **argv, Coord x, Coord y) { - if (argc > 1) - AFAIL (adjuststyle); + if (argc > 1) + AFAIL(adjuststyle); - ghid_route_style_selector_edit_dialog - (GHID_ROUTE_STYLE_SELECTOR (ghidgui->route_style_selector)); - return 0; + ghid_route_style_selector_edit_dialog(GHID_ROUTE_STYLE_SELECTOR(ghidgui->route_style_selector)); + return 0; } /* ------------------------------------------------------------ */ -static const char editlayergroups_syntax[] = -"EditLayerGroups()\n"; +static const char editlayergroups_syntax[] = "EditLayerGroups()\n"; -static const char editlayergroups_help[] = -"Open the preferences window which allows editing of the layer groups."; +static const char editlayergroups_help[] = "Open the preferences window which allows editing of the layer groups."; /* %start-doc actions EditLayerGroups @@ -2158,24 +1872,23 @@ %end-doc */ -static int -EditLayerGroups(int argc, char **argv, Coord x, Coord y) +static int EditLayerGroups(int argc, char **argv, Coord x, Coord y) { - - if (argc != 0) - AFAIL (editlayergroups); - hid_actionl ("DoWindows", "Preferences", NULL); + if (argc != 0) + AFAIL(editlayergroups); - return 0; + hid_actionl("DoWindows", "Preferences", NULL); + + return 0; } /* ------------------------------------------------------------ */ HID_Action ghid_menu_action_list[] = { - {"AdjustStyle", 0, AdjustStyle, adjuststyle_help, adjuststyle_syntax}, - {"EditLayerGroups", 0, EditLayerGroups, editlayergroups_help, editlayergroups_syntax} + {"AdjustStyle", 0, AdjustStyle, adjuststyle_help, adjuststyle_syntax} + , + {"EditLayerGroups", 0, EditLayerGroups, editlayergroups_help, editlayergroups_syntax} }; -REGISTER_ACTIONS (ghid_menu_action_list) - +REGISTER_ACTIONS(ghid_menu_action_list) Index: trunk/src/hid/gtk/gui-utils.c =================================================================== --- trunk/src/hid/gtk/gui-utils.c (revision 1021) +++ trunk/src/hid/gtk/gui-utils.c (revision 1022) @@ -37,482 +37,422 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); /* Not a gui function, but no better place to put it... */ -gboolean -dup_string (gchar ** dst, const gchar * src) +gboolean dup_string(gchar ** dst, const gchar * src) { - if ((dst == NULL) || ((*dst == NULL) && (src == NULL))) - return FALSE; - if (*dst) - { - if (src && !strcmp (*dst, src)) - return FALSE; - g_free (*dst); - } - *dst = g_strdup (src); - return TRUE; + if ((dst == NULL) || ((*dst == NULL) && (src == NULL))) + return FALSE; + if (*dst) { + if (src && !strcmp(*dst, src)) + return FALSE; + g_free(*dst); + } + *dst = g_strdup(src); + return TRUE; } -void -free_glist_and_data (GList ** list_head) +void free_glist_and_data(GList ** list_head) { - GList *list; + GList *list; - if (*list_head == NULL) - return; - for (list = *list_head; list; list = list->next) - if (list->data) - g_free (list->data); - g_list_free (*list_head); - *list_head = NULL; + if (*list_head == NULL) + return; + for (list = *list_head; list; list = list->next) + if (list->data) + g_free(list->data); + g_list_free(*list_head); + *list_head = NULL; } -gboolean -ghid_is_modifier_key_sym (gint ksym) +gboolean ghid_is_modifier_key_sym(gint ksym) { - if (ksym == GDK_Shift_R || ksym == GDK_Shift_L - || ksym == GDK_Control_R || ksym == GDK_Control_L) - return TRUE; - return FALSE; + if (ksym == GDK_Shift_R || ksym == GDK_Shift_L || ksym == GDK_Control_R || ksym == GDK_Control_L) + return TRUE; + return FALSE; } -ModifierKeysState -ghid_modifier_keys_state (GdkModifierType * state) +ModifierKeysState ghid_modifier_keys_state(GdkModifierType * state) { - GdkModifierType mask; - ModifierKeysState mk; - gboolean shift, control, mod1; - GHidPort *out = &ghid_port; + GdkModifierType mask; + ModifierKeysState mk; + gboolean shift, control, mod1; + GHidPort *out = &ghid_port; - if (!state) - gdk_window_get_pointer (gtk_widget_get_window (out->drawing_area), - NULL, NULL, &mask); - else - mask = *state; + if (!state) + gdk_window_get_pointer(gtk_widget_get_window(out->drawing_area), NULL, NULL, &mask); + else + mask = *state; - shift = (mask & GDK_SHIFT_MASK); - control = (mask & GDK_CONTROL_MASK); - mod1 = (mask & GDK_MOD1_MASK); + shift = (mask & GDK_SHIFT_MASK); + control = (mask & GDK_CONTROL_MASK); + mod1 = (mask & GDK_MOD1_MASK); - if (shift && !control && !mod1) - mk = SHIFT_PRESSED; - else if (!shift && control && !mod1) - mk = CONTROL_PRESSED; - else if (!shift && !control && mod1) - mk = MOD1_PRESSED; - else if (shift && control && !mod1) - mk = SHIFT_CONTROL_PRESSED; - else if (shift && !control && mod1) - mk = SHIFT_MOD1_PRESSED; - else if (!shift && control && mod1) - mk = CONTROL_MOD1_PRESSED; - else if (shift && control && mod1) - mk = SHIFT_CONTROL_MOD1_PRESSED; - else - mk = NONE_PRESSED; + if (shift && !control && !mod1) + mk = SHIFT_PRESSED; + else if (!shift && control && !mod1) + mk = CONTROL_PRESSED; + else if (!shift && !control && mod1) + mk = MOD1_PRESSED; + else if (shift && control && !mod1) + mk = SHIFT_CONTROL_PRESSED; + else if (shift && !control && mod1) + mk = SHIFT_MOD1_PRESSED; + else if (!shift && control && mod1) + mk = CONTROL_MOD1_PRESSED; + else if (shift && control && mod1) + mk = SHIFT_CONTROL_MOD1_PRESSED; + else + mk = NONE_PRESSED; - return mk; + return mk; } -ButtonState -ghid_button_state (GdkModifierType * state) +ButtonState ghid_button_state(GdkModifierType * state) { - GdkModifierType mask; - ButtonState bs; - gboolean button1, button2, button3; - GHidPort *out = &ghid_port; + GdkModifierType mask; + ButtonState bs; + gboolean button1, button2, button3; + GHidPort *out = &ghid_port; - if (!state) - gdk_window_get_pointer (gtk_widget_get_window (out->drawing_area), - NULL, NULL, &mask); - else - mask = *state; + if (!state) + gdk_window_get_pointer(gtk_widget_get_window(out->drawing_area), NULL, NULL, &mask); + else + mask = *state; - button1 = (mask & GDK_BUTTON1_MASK); - button2 = (mask & GDK_BUTTON2_MASK); - button3 = (mask & GDK_BUTTON3_MASK); + button1 = (mask & GDK_BUTTON1_MASK); + button2 = (mask & GDK_BUTTON2_MASK); + button3 = (mask & GDK_BUTTON3_MASK); - if (button1) - bs = BUTTON1_PRESSED; - else if (button2) - bs = BUTTON2_PRESSED; - else if (button3) - bs = BUTTON3_PRESSED; - else - bs = NO_BUTTON_PRESSED; + if (button1) + bs = BUTTON1_PRESSED; + else if (button2) + bs = BUTTON2_PRESSED; + else if (button3) + bs = BUTTON3_PRESSED; + else + bs = NO_BUTTON_PRESSED; - return bs; + return bs; } -void -ghid_draw_area_update (GHidPort * port, GdkRectangle * rect) +void ghid_draw_area_update(GHidPort * port, GdkRectangle * rect) { - gdk_window_invalidate_rect (gtk_widget_get_window (port->drawing_area), - rect, FALSE); + gdk_window_invalidate_rect(gtk_widget_get_window(port->drawing_area), rect, FALSE); } -gchar * -ghid_get_color_name (GdkColor * color) +gchar *ghid_get_color_name(GdkColor * color) { - gchar *name; + gchar *name; - if (!color) - name = g_strdup ("#000000"); - else - name = g_strdup_printf ("#%2.2x%2.2x%2.2x", - (color->red >> 8) & 0xff, - (color->green >> 8) & 0xff, - (color->blue >> 8) & 0xff); - return name; + if (!color) + name = g_strdup("#000000"); + else + name = g_strdup_printf("#%2.2x%2.2x%2.2x", (color->red >> 8) & 0xff, (color->green >> 8) & 0xff, (color->blue >> 8) & 0xff); + return name; } -void -ghid_map_color_string (char *color_string, GdkColor * color) +void ghid_map_color_string(char *color_string, GdkColor * color) { - static GdkColormap *colormap = NULL; - GHidPort *out = &ghid_port; + static GdkColormap *colormap = NULL; + GHidPort *out = &ghid_port; - if (!color || !out->top_window) - return; - if (colormap == NULL) - colormap = gtk_widget_get_colormap (out->top_window); - if (color->red || color->green || color->blue) - gdk_colormap_free_colors (colormap, color, 1); - gdk_color_parse (color_string, color); - gdk_color_alloc (colormap, color); + if (!color || !out->top_window) + return; + if (colormap == NULL) + colormap = gtk_widget_get_colormap(out->top_window); + if (color->red || color->green || color->blue) + gdk_colormap_free_colors(colormap, color, 1); + gdk_color_parse(color_string, color); + gdk_color_alloc(colormap, color); } -gchar * -ghid_entry_get_text (GtkWidget * entry) +gchar *ghid_entry_get_text(GtkWidget * entry) { - gchar *s = ""; + gchar *s = ""; - if (entry) - s = (gchar *) gtk_entry_get_text (GTK_ENTRY (entry)); - while (*s == ' ' || *s == '\t') - ++s; - return s; + if (entry) + s = (gchar *) gtk_entry_get_text(GTK_ENTRY(entry)); + while (*s == ' ' || *s == '\t') + ++s; + return s; } void -ghid_check_button_connected (GtkWidget * box, - GtkWidget ** button, - gboolean active, - gboolean pack_start, - gboolean expand, - gboolean fill, - gint pad, - void (*cb_func) (GtkToggleButton *, gpointer), - gpointer data, gchar * string) +ghid_check_button_connected(GtkWidget * box, + GtkWidget ** button, + gboolean active, + gboolean pack_start, + gboolean expand, + gboolean fill, + gint pad, void (*cb_func) (GtkToggleButton *, gpointer), gpointer data, gchar * string) { - GtkWidget *b; + GtkWidget *b; - if (!string) - return; - b = gtk_check_button_new_with_label (string); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b), active); - if (box && pack_start) - gtk_box_pack_start (GTK_BOX (box), b, expand, fill, pad); - else if (box && !pack_start) - gtk_box_pack_end (GTK_BOX (box), b, expand, fill, pad); + if (!string) + return; + b = gtk_check_button_new_with_label(string); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b), active); + if (box && pack_start) + gtk_box_pack_start(GTK_BOX(box), b, expand, fill, pad); + else if (box && !pack_start) + gtk_box_pack_end(GTK_BOX(box), b, expand, fill, pad); - if (cb_func) - g_signal_connect (b, "clicked", G_CALLBACK (cb_func), data); - if (button) - *button = b; + if (cb_func) + g_signal_connect(b, "clicked", G_CALLBACK(cb_func), data); + if (button) + *button = b; } void -ghid_button_connected (GtkWidget * box, GtkWidget ** button, - gboolean pack_start, gboolean expand, gboolean fill, - gint pad, void (*cb_func) (gpointer), gpointer data, - gchar * string) +ghid_button_connected(GtkWidget * box, GtkWidget ** button, + gboolean pack_start, gboolean expand, gboolean fill, + gint pad, void (*cb_func) (gpointer), gpointer data, gchar * string) { - GtkWidget *b; + GtkWidget *b; - if (!string) - return; - b = gtk_button_new_with_label (string); - if (box && pack_start) - gtk_box_pack_start (GTK_BOX (box), b, expand, fill, pad); - else if (box && !pack_start) - gtk_box_pack_end (GTK_BOX (box), b, expand, fill, pad); + if (!string) + return; + b = gtk_button_new_with_label(string); + if (box && pack_start) + gtk_box_pack_start(GTK_BOX(box), b, expand, fill, pad); + else if (box && !pack_start) + gtk_box_pack_end(GTK_BOX(box), b, expand, fill, pad); - if (cb_func) - g_signal_connect (b, "clicked", G_CALLBACK (cb_func), data); - if (button) - *button = b; + if (cb_func) + g_signal_connect(b, "clicked", G_CALLBACK(cb_func), data); + if (button) + *button = b; } void -ghid_coord_entry (GtkWidget * box, GtkWidget ** coord_entry, Coord value, - Coord low, Coord high, enum ce_step_size step_size, - gint width, void (*cb_func) (GHidCoordEntry *, gpointer), - gpointer data, gboolean right_align, gchar * string) +ghid_coord_entry(GtkWidget * box, GtkWidget ** coord_entry, Coord value, + Coord low, Coord high, enum ce_step_size step_size, + gint width, void (*cb_func) (GHidCoordEntry *, gpointer), gpointer data, gboolean right_align, gchar * string) { - GtkWidget *hbox = NULL, *label, *entry_widget; - GHidCoordEntry *entry; + GtkWidget *hbox = NULL, *label, *entry_widget; + GHidCoordEntry *entry; - if (string && box) - { - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 2); - box = hbox; - } + if (string && box) { + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 2); + box = hbox; + } - entry_widget = ghid_coord_entry_new (low, high, value, Settings.grid_unit, step_size); - if (coord_entry) - *coord_entry = entry_widget; - if (width > 0) - gtk_widget_set_size_request (entry_widget, width, -1); - entry = GHID_COORD_ENTRY (entry_widget); - if (data == NULL) - data = (gpointer) entry; - if (cb_func) - g_signal_connect (G_OBJECT (entry_widget), "value_changed", - G_CALLBACK (cb_func), data); - if (box) - { - if (right_align && string) - { - label = gtk_label_new (string); - gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); - gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 2); + entry_widget = ghid_coord_entry_new(low, high, value, Settings.grid_unit, step_size); + if (coord_entry) + *coord_entry = entry_widget; + if (width > 0) + gtk_widget_set_size_request(entry_widget, width, -1); + entry = GHID_COORD_ENTRY(entry_widget); + if (data == NULL) + data = (gpointer) entry; + if (cb_func) + g_signal_connect(G_OBJECT(entry_widget), "value_changed", G_CALLBACK(cb_func), data); + if (box) { + if (right_align && string) { + label = gtk_label_new(string); + gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); + gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 2); + } + gtk_box_pack_start(GTK_BOX(box), entry_widget, FALSE, FALSE, 2); + if (!right_align && string) { + label = gtk_label_new(string); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 2); + } } - gtk_box_pack_start (GTK_BOX (box), entry_widget, FALSE, FALSE, 2); - if (!right_align && string) - { - label = gtk_label_new (string); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 2); - } - } } void -ghid_spin_button (GtkWidget * box, GtkWidget ** spin_button, gfloat value, - gfloat low, gfloat high, gfloat step0, gfloat step1, - gint digits, gint width, - void (*cb_func) (GtkSpinButton *, gpointer), gpointer data, gboolean right_align, - gchar * string) +ghid_spin_button(GtkWidget * box, GtkWidget ** spin_button, gfloat value, + gfloat low, gfloat high, gfloat step0, gfloat step1, + gint digits, gint width, + void (*cb_func) (GtkSpinButton *, gpointer), gpointer data, gboolean right_align, gchar * string) { - GtkWidget *hbox = NULL, *label, *spin_but; - GtkSpinButton *spin; - GtkAdjustment *adj; + GtkWidget *hbox = NULL, *label, *spin_but; + GtkSpinButton *spin; + GtkAdjustment *adj; - if (string && box) - { - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 2); - box = hbox; - } - adj = (GtkAdjustment *) gtk_adjustment_new (value, - low, high, step0, step1, 0.0); - spin_but = gtk_spin_button_new (adj, 0.5, digits); - if (spin_button) - *spin_button = spin_but; - if (width > 0) - gtk_widget_set_size_request (spin_but, width, -1); - spin = GTK_SPIN_BUTTON (spin_but); - gtk_spin_button_set_numeric (spin, TRUE); - if (data == NULL) - data = (gpointer) spin; - if (cb_func) - g_signal_connect (G_OBJECT (spin_but), "value_changed", - G_CALLBACK (cb_func), data); - if (box) - { - if (right_align && string) - { - label = gtk_label_new (string); - gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); - gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 2); + if (string && box) { + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 2); + box = hbox; } - gtk_box_pack_start (GTK_BOX (box), spin_but, FALSE, FALSE, 2); - if (!right_align && string) - { - label = gtk_label_new (string); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 2); + adj = (GtkAdjustment *) gtk_adjustment_new(value, low, high, step0, step1, 0.0); + spin_but = gtk_spin_button_new(adj, 0.5, digits); + if (spin_button) + *spin_button = spin_but; + if (width > 0) + gtk_widget_set_size_request(spin_but, width, -1); + spin = GTK_SPIN_BUTTON(spin_but); + gtk_spin_button_set_numeric(spin, TRUE); + if (data == NULL) + data = (gpointer) spin; + if (cb_func) + g_signal_connect(G_OBJECT(spin_but), "value_changed", G_CALLBACK(cb_func), data); + if (box) { + if (right_align && string) { + label = gtk_label_new(string); + gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); + gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 2); + } + gtk_box_pack_start(GTK_BOX(box), spin_but, FALSE, FALSE, 2); + if (!right_align && string) { + label = gtk_label_new(string); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 2); + } } - } } void -ghid_table_coord_entry (GtkWidget * table, gint row, gint column, - GtkWidget ** coord_entry, Coord value, - Coord low, Coord high, enum ce_step_size step_size, - gint width, void (*cb_func) (GHidCoordEntry *, gpointer), - gpointer data, gboolean right_align, gchar * string) +ghid_table_coord_entry(GtkWidget * table, gint row, gint column, + GtkWidget ** coord_entry, Coord value, + Coord low, Coord high, enum ce_step_size step_size, + gint width, void (*cb_func) (GHidCoordEntry *, gpointer), + gpointer data, gboolean right_align, gchar * string) { - GtkWidget *label, *entry_widget; - GHidCoordEntry *entry; + GtkWidget *label, *entry_widget; + GHidCoordEntry *entry; - if (!table) - return; + if (!table) + return; - entry_widget = ghid_coord_entry_new (low, high, value, Settings.grid_unit, step_size); - if (coord_entry) - *coord_entry = entry_widget; - if (width > 0) - gtk_widget_set_size_request (entry_widget, width, -1); - entry = GHID_COORD_ENTRY (entry_widget); - if (data == NULL) - data = (gpointer) entry; - if (cb_func) - g_signal_connect (G_OBJECT (entry), "value_changed", - G_CALLBACK (cb_func), data); + entry_widget = ghid_coord_entry_new(low, high, value, Settings.grid_unit, step_size); + if (coord_entry) + *coord_entry = entry_widget; + if (width > 0) + gtk_widget_set_size_request(entry_widget, width, -1); + entry = GHID_COORD_ENTRY(entry_widget); + if (data == NULL) + data = (gpointer) entry; + if (cb_func) + g_signal_connect(G_OBJECT(entry), "value_changed", G_CALLBACK(cb_func), data); - if (right_align) - { - gtk_table_attach_defaults (GTK_TABLE (table), entry_widget, - column + 1, column + 2, row, row + 1); - if (string) - { - label = gtk_label_new (string); - gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), label, - column, column + 1, row, row + 1); + if (right_align) { + gtk_table_attach_defaults(GTK_TABLE(table), entry_widget, column + 1, column + 2, row, row + 1); + if (string) { + label = gtk_label_new(string); + gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); + gtk_table_attach_defaults(GTK_TABLE(table), label, column, column + 1, row, row + 1); + } } - } - else - { - gtk_table_attach_defaults (GTK_TABLE (table), entry_widget, - column, column + 1, row, row + 1); - if (string) - { - label = gtk_label_new (string); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), label, - column + 1, column + 2, row, row + 1); + else { + gtk_table_attach_defaults(GTK_TABLE(table), entry_widget, column, column + 1, row, row + 1); + if (string) { + label = gtk_label_new(string); + gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); + gtk_table_attach_defaults(GTK_TABLE(table), label, column + 1, column + 2, row, row + 1); + } } - } } void -ghid_table_spin_button (GtkWidget * table, gint row, gint column, - GtkWidget ** spin_button, gfloat value, - gfloat low, gfloat high, gfloat step0, gfloat step1, - gint digits, gint width, - void (*cb_func) (GtkSpinButton *, gpointer), gpointer data, - gboolean right_align, gchar * string) +ghid_table_spin_button(GtkWidget * table, gint row, gint column, + GtkWidget ** spin_button, gfloat value, + gfloat low, gfloat high, gfloat step0, gfloat step1, + gint digits, gint width, + void (*cb_func) (GtkSpinButton *, gpointer), gpointer data, gboolean right_align, gchar * string) { - GtkWidget *label, *spin_but; - GtkSpinButton *spin; - GtkAdjustment *adj; + GtkWidget *label, *spin_but; + GtkSpinButton *spin; + GtkAdjustment *adj; - if (!table) - return; + if (!table) + return; - adj = (GtkAdjustment *) gtk_adjustment_new (value, - low, high, step0, step1, 0.0); - spin_but = gtk_spin_button_new (adj, 0.5, digits); + adj = (GtkAdjustment *) gtk_adjustment_new(value, low, high, step0, step1, 0.0); + spin_but = gtk_spin_button_new(adj, 0.5, digits); - if (spin_button) - *spin_button = spin_but; - if (width > 0) - gtk_widget_set_size_request (spin_but, width, -1); - spin = GTK_SPIN_BUTTON (spin_but); - gtk_spin_button_set_numeric (spin, TRUE); - if (data == NULL) - data = (gpointer) spin; - if (cb_func) - g_signal_connect (G_OBJECT (spin_but), "value_changed", - G_CALLBACK (cb_func), data); + if (spin_button) + *spin_button = spin_but; + if (width > 0) + gtk_widget_set_size_request(spin_but, width, -1); + spin = GTK_SPIN_BUTTON(spin_but); + gtk_spin_button_set_numeric(spin, TRUE); + if (data == NULL) + data = (gpointer) spin; + if (cb_func) + g_signal_connect(G_OBJECT(spin_but), "value_changed", G_CALLBACK(cb_func), data); - if (right_align) - { - gtk_table_attach_defaults (GTK_TABLE (table), spin_but, - column + 1, column + 2, row, row + 1); - if (string) - { - label = gtk_label_new (string); - gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), label, - column, column + 1, row, row + 1); + if (right_align) { + gtk_table_attach_defaults(GTK_TABLE(table), spin_but, column + 1, column + 2, row, row + 1); + if (string) { + label = gtk_label_new(string); + gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); + gtk_table_attach_defaults(GTK_TABLE(table), label, column, column + 1, row, row + 1); + } } - } - else - { - gtk_table_attach_defaults (GTK_TABLE (table), spin_but, - column, column + 1, row, row + 1); - if (string) - { - label = gtk_label_new (string); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), label, - column + 1, column + 2, row, row + 1); + else { + gtk_table_attach_defaults(GTK_TABLE(table), spin_but, column, column + 1, row, row + 1); + if (string) { + label = gtk_label_new(string); + gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); + gtk_table_attach_defaults(GTK_TABLE(table), label, column + 1, column + 2, row, row + 1); + } } - } } void -ghid_range_control (GtkWidget * box, GtkWidget ** scale_res, - gboolean horizontal, GtkPositionType pos, - gboolean set_draw_value, gint digits, gboolean pack_start, - gboolean expand, gboolean fill, guint pad, gfloat value, - gfloat low, gfloat high, gfloat step0, gfloat step1, - void (*cb_func) (), gpointer data) +ghid_range_control(GtkWidget * box, GtkWidget ** scale_res, + gboolean horizontal, GtkPositionType pos, + gboolean set_draw_value, gint digits, gboolean pack_start, + gboolean expand, gboolean fill, guint pad, gfloat value, + gfloat low, gfloat high, gfloat step0, gfloat step1, void (*cb_func) (), gpointer data) { - GtkWidget *scale; - GtkAdjustment *adj; + GtkWidget *scale; + GtkAdjustment *adj; - adj = (GtkAdjustment *) gtk_adjustment_new (value, - low, high, step0, step1, 0.0); + adj = (GtkAdjustment *) gtk_adjustment_new(value, low, high, step0, step1, 0.0); - if (horizontal) - scale = gtk_hscale_new (GTK_ADJUSTMENT (adj)); - else - scale = gtk_vscale_new (GTK_ADJUSTMENT (adj)); - gtk_scale_set_value_pos (GTK_SCALE (scale), pos); - gtk_scale_set_draw_value (GTK_SCALE (scale), set_draw_value); - gtk_scale_set_digits (GTK_SCALE (scale), digits); + if (horizontal) + scale = gtk_hscale_new(GTK_ADJUSTMENT(adj)); + else + scale = gtk_vscale_new(GTK_ADJUSTMENT(adj)); + gtk_scale_set_value_pos(GTK_SCALE(scale), pos); + gtk_scale_set_draw_value(GTK_SCALE(scale), set_draw_value); + gtk_scale_set_digits(GTK_SCALE(scale), digits); - /* Increments don't make sense, use -1,1 because that does closest to - | what I want: scroll down decrements slider value. - */ - gtk_range_set_increments (GTK_RANGE (scale), -1, 1); + /* Increments don't make sense, use -1,1 because that does closest to + | what I want: scroll down decrements slider value. + */ + gtk_range_set_increments(GTK_RANGE(scale), -1, 1); - if (pack_start) - gtk_box_pack_start (GTK_BOX (box), scale, expand, fill, pad); - else - gtk_box_pack_end (GTK_BOX (box), scale, expand, fill, pad); + if (pack_start) + gtk_box_pack_start(GTK_BOX(box), scale, expand, fill, pad); + else + gtk_box_pack_end(GTK_BOX(box), scale, expand, fill, pad); - if (data == NULL) - data = (gpointer) adj; - if (cb_func) - g_signal_connect (G_OBJECT (adj), "value_changed", - G_CALLBACK (cb_func), data); - if (scale_res) - *scale_res = scale; + if (data == NULL) + data = (gpointer) adj; + if (cb_func) + g_signal_connect(G_OBJECT(adj), "value_changed", G_CALLBACK(cb_func), data); + if (scale_res) + *scale_res = scale; } -GtkWidget * -ghid_scrolled_vbox (GtkWidget * box, GtkWidget ** scr, - GtkPolicyType h_policy, GtkPolicyType v_policy) +GtkWidget *ghid_scrolled_vbox(GtkWidget * box, GtkWidget ** scr, GtkPolicyType h_policy, GtkPolicyType v_policy) { - GtkWidget *scrolled, *vbox; + GtkWidget *scrolled, *vbox; - scrolled = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), - h_policy, v_policy); - gtk_box_pack_start (GTK_BOX (box), scrolled, TRUE, TRUE, 0); - vbox = gtk_vbox_new (FALSE, 0); - gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled), - vbox); - if (scr) - *scr = scrolled; - return vbox; + scrolled = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), h_policy, v_policy); + gtk_box_pack_start(GTK_BOX(box), scrolled, TRUE, TRUE, 0); + vbox = gtk_vbox_new(FALSE, 0); + gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), vbox); + if (scr) + *scr = scrolled; + return vbox; } /* frame_border_width - border around outside of frame. @@ -519,351 +459,297 @@ | vbox_pad - pad between widgets to be packed in returned vbox. | vbox_border_width - border between returned vbox and frame. */ -GtkWidget * -ghid_framed_vbox (GtkWidget * box, gchar * label, gint frame_border_width, - gboolean frame_expand, gint vbox_pad, - gint vbox_border_width) +GtkWidget *ghid_framed_vbox(GtkWidget * box, gchar * label, gint frame_border_width, + gboolean frame_expand, gint vbox_pad, gint vbox_border_width) { - GtkWidget *frame; - GtkWidget *vbox; + GtkWidget *frame; + GtkWidget *vbox; - frame = gtk_frame_new (label); - gtk_container_set_border_width (GTK_CONTAINER (frame), frame_border_width); - gtk_box_pack_start (GTK_BOX (box), frame, frame_expand, frame_expand, 0); - vbox = gtk_vbox_new (FALSE, vbox_pad); - gtk_container_set_border_width (GTK_CONTAINER (vbox), vbox_border_width); - gtk_container_add (GTK_CONTAINER (frame), vbox); - return vbox; + frame = gtk_frame_new(label); + gtk_container_set_border_width(GTK_CONTAINER(frame), frame_border_width); + gtk_box_pack_start(GTK_BOX(box), frame, frame_expand, frame_expand, 0); + vbox = gtk_vbox_new(FALSE, vbox_pad); + gtk_container_set_border_width(GTK_CONTAINER(vbox), vbox_border_width); + gtk_container_add(GTK_CONTAINER(frame), vbox); + return vbox; } -GtkWidget * -ghid_framed_vbox_end (GtkWidget * box, gchar * label, gint frame_border_width, - gboolean frame_expand, gint vbox_pad, - gint vbox_border_width) +GtkWidget *ghid_framed_vbox_end(GtkWidget * box, gchar * label, gint frame_border_width, + gboolean frame_expand, gint vbox_pad, gint vbox_border_width) { - GtkWidget *frame; - GtkWidget *vbox; + GtkWidget *frame; + GtkWidget *vbox; - frame = gtk_frame_new (label); - gtk_container_set_border_width (GTK_CONTAINER (frame), frame_border_width); - gtk_box_pack_end (GTK_BOX (box), frame, frame_expand, frame_expand, 0); - vbox = gtk_vbox_new (FALSE, vbox_pad); - gtk_container_set_border_width (GTK_CONTAINER (vbox), vbox_border_width); - gtk_container_add (GTK_CONTAINER (frame), vbox); - return vbox; + frame = gtk_frame_new(label); + gtk_container_set_border_width(GTK_CONTAINER(frame), frame_border_width); + gtk_box_pack_end(GTK_BOX(box), frame, frame_expand, frame_expand, 0); + vbox = gtk_vbox_new(FALSE, vbox_pad); + gtk_container_set_border_width(GTK_CONTAINER(vbox), vbox_border_width); + gtk_container_add(GTK_CONTAINER(frame), vbox); + return vbox; } -GtkWidget * -ghid_category_vbox (GtkWidget * box, const gchar * category_header, - gint header_pad, - gint box_pad, gboolean pack_start, gboolean bottom_pad) +GtkWidget *ghid_category_vbox(GtkWidget * box, const gchar * category_header, + gint header_pad, gint box_pad, gboolean pack_start, gboolean bottom_pad) { - GtkWidget *vbox, *vbox1, *hbox, *label; - gchar *s; + GtkWidget *vbox, *vbox1, *hbox, *label; + gchar *s; - vbox = gtk_vbox_new (FALSE, 0); - if (pack_start) - gtk_box_pack_start (GTK_BOX (box), vbox, FALSE, FALSE, 0); - else - gtk_box_pack_end (GTK_BOX (box), vbox, FALSE, FALSE, 0); + vbox = gtk_vbox_new(FALSE, 0); + if (pack_start) + gtk_box_pack_start(GTK_BOX(box), vbox, FALSE, FALSE, 0); + else + gtk_box_pack_end(GTK_BOX(box), vbox, FALSE, FALSE, 0); - if (category_header) - { - label = gtk_label_new (NULL); - s = g_strconcat ("", category_header, - "", NULL); - gtk_label_set_markup (GTK_LABEL (label), s); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, header_pad); - g_free (s); - } + if (category_header) { + label = gtk_label_new(NULL); + s = g_strconcat("", category_header, "", NULL); + gtk_label_set_markup(GTK_LABEL(label), s); + gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); + gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, header_pad); + g_free(s); + } - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - label = gtk_label_new (" "); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - vbox1 = gtk_vbox_new (FALSE, box_pad); - gtk_box_pack_start (GTK_BOX (hbox), vbox1, TRUE, TRUE, 0); + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + label = gtk_label_new(" "); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + vbox1 = gtk_vbox_new(FALSE, box_pad); + gtk_box_pack_start(GTK_BOX(hbox), vbox1, TRUE, TRUE, 0); - if (bottom_pad) - { - label = gtk_label_new (""); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); - } - return vbox1; + if (bottom_pad) { + label = gtk_label_new(""); + gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); + } + return vbox1; } -GtkTreeSelection * -ghid_scrolled_selection (GtkTreeView * treeview, GtkWidget * box, - GtkSelectionMode s_mode, - GtkPolicyType h_policy, GtkPolicyType v_policy, - void (*func_cb) (GtkTreeSelection *, gpointer), gpointer data) +GtkTreeSelection *ghid_scrolled_selection(GtkTreeView * treeview, GtkWidget * box, + GtkSelectionMode s_mode, + GtkPolicyType h_policy, GtkPolicyType v_policy, + void (*func_cb) (GtkTreeSelection *, gpointer), gpointer data) { - GtkTreeSelection *selection; - GtkWidget *scrolled; + GtkTreeSelection *selection; + GtkWidget *scrolled; - if (!box || !treeview) - return NULL; + if (!box || !treeview) + return NULL; - scrolled = gtk_scrolled_window_new (NULL, NULL); - gtk_box_pack_start (GTK_BOX (box), scrolled, TRUE, TRUE, 0); - gtk_container_add (GTK_CONTAINER (scrolled), GTK_WIDGET (treeview)); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), - h_policy, v_policy); - selection = gtk_tree_view_get_selection (treeview); - gtk_tree_selection_set_mode (selection, s_mode); - if (func_cb) - g_signal_connect (G_OBJECT (selection), "changed", - G_CALLBACK (func_cb), data); - return selection; + scrolled = gtk_scrolled_window_new(NULL, NULL); + gtk_box_pack_start(GTK_BOX(box), scrolled, TRUE, TRUE, 0); + gtk_container_add(GTK_CONTAINER(scrolled), GTK_WIDGET(treeview)); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), h_policy, v_policy); + selection = gtk_tree_view_get_selection(treeview); + gtk_tree_selection_set_mode(selection, s_mode); + if (func_cb) + g_signal_connect(G_OBJECT(selection), "changed", G_CALLBACK(func_cb), data); + return selection; } -GtkWidget * -ghid_notebook_page (GtkWidget * tabs, char *name, gint pad, gint border) +GtkWidget *ghid_notebook_page(GtkWidget * tabs, char *name, gint pad, gint border) { - GtkWidget *label; - GtkWidget *vbox; + GtkWidget *label; + GtkWidget *vbox; - vbox = gtk_vbox_new (FALSE, pad); - gtk_container_set_border_width (GTK_CONTAINER (vbox), border); + vbox = gtk_vbox_new(FALSE, pad); + gtk_container_set_border_width(GTK_CONTAINER(vbox), border); - label = gtk_label_new (name); - gtk_notebook_append_page (GTK_NOTEBOOK (tabs), vbox, label); + label = gtk_label_new(name); + gtk_notebook_append_page(GTK_NOTEBOOK(tabs), vbox, label); - return vbox; + return vbox; } -GtkWidget * -ghid_framed_notebook_page (GtkWidget * tabs, char *name, gint border, - gint frame_border, gint vbox_pad, gint vbox_border) +GtkWidget *ghid_framed_notebook_page(GtkWidget * tabs, char *name, gint border, + gint frame_border, gint vbox_pad, gint vbox_border) { - GtkWidget *vbox; + GtkWidget *vbox; - vbox = ghid_notebook_page (tabs, name, 0, border); - vbox = ghid_framed_vbox (vbox, NULL, frame_border, TRUE, - vbox_pad, vbox_border); - return vbox; + vbox = ghid_notebook_page(tabs, name, 0, border); + vbox = ghid_framed_vbox(vbox, NULL, frame_border, TRUE, vbox_pad, vbox_border); + return vbox; } -void -ghid_dialog_report (const gchar * title, const gchar * message) +void ghid_dialog_report(const gchar * title, const gchar * message) { - GtkWidget *top_win; - GtkWidget *dialog; - GtkWidget *content_area; - GtkWidget *scrolled; - GtkWidget *vbox, *vbox1; - GtkWidget *label; - const gchar *s; - gint nlines; - GHidPort *out = &ghid_port; + GtkWidget *top_win; + GtkWidget *dialog; + GtkWidget *content_area; + GtkWidget *scrolled; + GtkWidget *vbox, *vbox1; + GtkWidget *label; + const gchar *s; + gint nlines; + GHidPort *out = &ghid_port; - if (!message) - return; - top_win = out->top_window; - dialog = gtk_dialog_new_with_buttons (title ? title : "PCB", - GTK_WINDOW (top_win), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_OK, GTK_RESPONSE_NONE, - NULL); - g_signal_connect_swapped (GTK_OBJECT (dialog), "response", - G_CALLBACK (gtk_widget_destroy), - GTK_OBJECT (dialog)); - gtk_window_set_wmclass (GTK_WINDOW (dialog), "PCB_Dialog", "PCB"); + if (!message) + return; + top_win = out->top_window; + dialog = gtk_dialog_new_with_buttons(title ? title : "PCB", + GTK_WINDOW(top_win), + GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, GTK_RESPONSE_NONE, NULL); + g_signal_connect_swapped(GTK_OBJECT(dialog), "response", G_CALLBACK(gtk_widget_destroy), GTK_OBJECT(dialog)); + gtk_window_set_wmclass(GTK_WINDOW(dialog), "PCB_Dialog", "PCB"); - content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); + content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 8); - gtk_box_pack_start (GTK_BOX (content_area), vbox, FALSE, FALSE, 0); + vbox = gtk_vbox_new(FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 8); + gtk_box_pack_start(GTK_BOX(content_area), vbox, FALSE, FALSE, 0); - label = gtk_label_new (message); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); + label = gtk_label_new(message); + gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); - for (nlines = 0, s = message; *s; ++s) - if (*s == '\n') - ++nlines; - if (nlines > 20) - { - vbox1 = ghid_scrolled_vbox (vbox, &scrolled, - GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - gtk_widget_set_size_request (scrolled, -1, 300); - gtk_box_pack_start (GTK_BOX (vbox1), label, FALSE, FALSE, 0); - } - else - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + for (nlines = 0, s = message; *s; ++s) + if (*s == '\n') + ++nlines; + if (nlines > 20) { + vbox1 = ghid_scrolled_vbox(vbox, &scrolled, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + gtk_widget_set_size_request(scrolled, -1, 300); + gtk_box_pack_start(GTK_BOX(vbox1), label, FALSE, FALSE, 0); + } + else + gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - gtk_widget_show_all (dialog); + gtk_widget_show_all(dialog); } -void -ghid_label_set_markup (GtkWidget * label, const gchar * text) +void ghid_label_set_markup(GtkWidget * label, const gchar * text) { - if (label) - gtk_label_set_markup (GTK_LABEL (label), text ? text : ""); + if (label) + gtk_label_set_markup(GTK_LABEL(label), text ? text : ""); } -static void -text_view_append (GtkWidget * view, gchar * s) +static void text_view_append(GtkWidget * view, gchar * s) { - GtkTextIter iter; - GtkTextBuffer *buffer; - GtkTextMark *mark; + GtkTextIter iter; + GtkTextBuffer *buffer; + GtkTextMark *mark; - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); - gtk_text_buffer_get_end_iter (buffer, &iter); - /* gtk_text_iter_forward_to_end(&iter); */ + buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view)); + gtk_text_buffer_get_end_iter(buffer, &iter); + /* gtk_text_iter_forward_to_end(&iter); */ - if (strncmp (s, "", 3) == 0) - gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, - s + 3, -1, "bold", NULL); - else if (strncmp (s, "", 3) == 0) - gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, - s + 3, -1, "italic", NULL); - else if (strncmp (s, "", 3) == 0) - gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, - s + 3, -1, "heading", NULL); - else if (strncmp (s, "", 3) == 0) - gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, - s + 3, -1, "center", NULL); - else if (strncmp (s, "
    ", 4) == 0) - gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, - s + 4, -1, "underline", NULL); - else - gtk_text_buffer_insert (buffer, &iter, s, -1); + if (strncmp(s, "", 3) == 0) + gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, s + 3, -1, "bold", NULL); + else if (strncmp(s, "", 3) == 0) + gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, s + 3, -1, "italic", NULL); + else if (strncmp(s, "", 3) == 0) + gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, s + 3, -1, "heading", NULL); + else if (strncmp(s, "", 3) == 0) + gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, s + 3, -1, "center", NULL); + else if (strncmp(s, "
      ", 4) == 0) + gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, s + 4, -1, "underline", NULL); + else + gtk_text_buffer_insert(buffer, &iter, s, -1); - mark = gtk_text_buffer_create_mark (buffer, NULL, &iter, FALSE); - gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view), mark, - 0, TRUE, 0.0, 1.0); - gtk_text_buffer_delete_mark (buffer, mark); + mark = gtk_text_buffer_create_mark(buffer, NULL, &iter, FALSE); + gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(view), mark, 0, TRUE, 0.0, 1.0); + gtk_text_buffer_delete_mark(buffer, mark); } -void -ghid_text_view_append (GtkWidget * view, gchar * string) +void ghid_text_view_append(GtkWidget * view, gchar * string) { - static gchar *tag; - gchar *s; + static gchar *tag; + gchar *s; - s = string; - if (*s == '<' - && ((*(s + 2) == '>' && !*(s + 3)) || (*(s + 3) == '>' && !*(s + 4)))) - { - tag = g_strdup (s); - return; - } + s = string; + if (*s == '<' && ((*(s + 2) == '>' && !*(s + 3)) || (*(s + 3) == '>' && !*(s + 4)))) { + tag = g_strdup(s); + return; + } - if (tag) - { - s = g_strconcat (tag, string, NULL); - text_view_append (view, s); - g_free (s); - g_free (tag); - tag = NULL; - } - else - text_view_append (view, string); + if (tag) { + s = g_strconcat(tag, string, NULL); + text_view_append(view, s); + g_free(s); + g_free(tag); + tag = NULL; + } + else + text_view_append(view, string); } -void -ghid_text_view_append_strings (GtkWidget * view, gchar ** string, - gint n_strings) +void ghid_text_view_append_strings(GtkWidget * view, gchar ** string, gint n_strings) { - gchar *tag = NULL; - gchar *s, *t; - gint i; + gchar *tag = NULL; + gchar *s, *t; + gint i; - for (i = 0; i < n_strings; ++i) - { - s = string[i]; - if (*s == '<' - && ((*(s + 2) == '>' && !*(s + 3)) - || (*(s + 3) == '>' && !*(s + 4)))) - { - tag = g_strdup (s); - continue; - } + for (i = 0; i < n_strings; ++i) { + s = string[i]; + if (*s == '<' && ((*(s + 2) == '>' && !*(s + 3)) + || (*(s + 3) == '>' && !*(s + 4)))) { + tag = g_strdup(s); + continue; + } #if defined(ENABLE_NLS) - s = gettext (string[i]); + s = gettext(string[i]); #else - s = string[i]; + s = string[i]; #endif - if (tag) - { - t = g_strconcat (tag, s, NULL); - text_view_append (view, t); - g_free (t); - g_free (tag); - tag = NULL; + if (tag) { + t = g_strconcat(tag, s, NULL); + text_view_append(view, t); + g_free(t); + g_free(tag); + tag = NULL; + } + else + text_view_append(view, s); } - else - text_view_append (view, s); - } } -GtkWidget * -ghid_scrolled_text_view (GtkWidget * box, - GtkWidget ** scr, - GtkPolicyType h_policy, GtkPolicyType v_policy) +GtkWidget *ghid_scrolled_text_view(GtkWidget * box, GtkWidget ** scr, GtkPolicyType h_policy, GtkPolicyType v_policy) { - GtkWidget *scrolled, *view; - GtkTextBuffer *buffer; + GtkWidget *scrolled, *view; + GtkTextBuffer *buffer; - scrolled = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), - h_policy, v_policy); - gtk_box_pack_start (GTK_BOX (box), scrolled, TRUE, TRUE, 0); + scrolled = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), h_policy, v_policy); + gtk_box_pack_start(GTK_BOX(box), scrolled, TRUE, TRUE, 0); - view = gtk_text_view_new (); - gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE); - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); - gtk_text_buffer_create_tag (buffer, "heading", - "weight", PANGO_WEIGHT_BOLD, - "size", 14 * PANGO_SCALE, NULL); - gtk_text_buffer_create_tag (buffer, "italic", - "style", PANGO_STYLE_ITALIC, NULL); - gtk_text_buffer_create_tag (buffer, "bold", - "weight", PANGO_WEIGHT_BOLD, NULL); - gtk_text_buffer_create_tag (buffer, "center", - "justification", GTK_JUSTIFY_CENTER, NULL); - gtk_text_buffer_create_tag (buffer, "underline", - "underline", PANGO_UNDERLINE_SINGLE, NULL); + view = gtk_text_view_new(); + gtk_text_view_set_editable(GTK_TEXT_VIEW(view), FALSE); + buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view)); + gtk_text_buffer_create_tag(buffer, "heading", "weight", PANGO_WEIGHT_BOLD, "size", 14 * PANGO_SCALE, NULL); + gtk_text_buffer_create_tag(buffer, "italic", "style", PANGO_STYLE_ITALIC, NULL); + gtk_text_buffer_create_tag(buffer, "bold", "weight", PANGO_WEIGHT_BOLD, NULL); + gtk_text_buffer_create_tag(buffer, "center", "justification", GTK_JUSTIFY_CENTER, NULL); + gtk_text_buffer_create_tag(buffer, "underline", "underline", PANGO_UNDERLINE_SINGLE, NULL); - gtk_container_add (GTK_CONTAINER (scrolled), view); - if (scr) - *scr = scrolled; - return view; + gtk_container_add(GTK_CONTAINER(scrolled), view); + if (scr) + *scr = scrolled; + return view; } /* If src is not utf8, *dst is converted to utf8. */ -gboolean -utf8_dup_string (gchar ** dst_utf8, const gchar * src) +gboolean utf8_dup_string(gchar ** dst_utf8, const gchar * src) { - if (!dst_utf8 || (!*dst_utf8 && !src)) - return FALSE; - if (*dst_utf8) - { - if (src && !strcmp (*dst_utf8, src)) - return FALSE; - g_free (*dst_utf8); - } - if (src) - { - if (g_utf8_validate (src, -1, NULL)) - *dst_utf8 = g_strdup (src); - else - { - *dst_utf8 = g_locale_to_utf8 (src, -1, NULL, NULL, NULL); - if (!*dst_utf8) - *dst_utf8 = g_strdup (src); + if (!dst_utf8 || (!*dst_utf8 && !src)) + return FALSE; + if (*dst_utf8) { + if (src && !strcmp(*dst_utf8, src)) + return FALSE; + g_free(*dst_utf8); } - } - else - *dst_utf8 = NULL; + if (src) { + if (g_utf8_validate(src, -1, NULL)) + *dst_utf8 = g_strdup(src); + else { + *dst_utf8 = g_locale_to_utf8(src, -1, NULL, NULL, NULL); + if (!*dst_utf8) + *dst_utf8 = g_strdup(src); + } + } + else + *dst_utf8 = NULL; - return TRUE; + return TRUE; } Index: trunk/src/hid/gtk/gui.h =================================================================== --- trunk/src/hid/gtk/gui.h (revision 1021) +++ trunk/src/hid/gtk/gui.h (revision 1022) @@ -41,10 +41,10 @@ #include "gui-pinout-preview.h" - /* Silk and rats lines are the two additional selectable to draw on. - | gui code in gui-top-window.c and group code in misc.c must agree - | on what layer is what! - */ + /* Silk and rats lines are the two additional selectable to draw on. + | gui code in gui-top-window.c and group code in misc.c must agree + | on what layer is what! + */ #define LAYER_BUTTON_SILK MAX_LAYER #define LAYER_BUTTON_RATS (MAX_LAYER + 1) #define N_SELECTABLE_LAYER_BUTTONS (LAYER_BUTTON_RATS + 1) @@ -55,11 +55,11 @@ #define LAYER_BUTTON_MASK (MAX_LAYER + 5) #define N_LAYER_BUTTONS (MAX_LAYER + 6) - /* Go from from the grid units in use (millimeters or mils) to PCB units - | and back again. - | PCB keeps values internally higher precision, but gui - | widgets (spin buttons, labels, etc) need mils or millimeters. - */ + /* Go from from the grid units in use (millimeters or mils) to PCB units + | and back again. + | PCB keeps values internally higher precision, but gui + | widgets (spin buttons, labels, etc) need mils or millimeters. + */ #define FROM_PCB_UNITS(v) coord_to_unit (Settings.grid_unit, v) #define TO_PCB_UNITS(v) unit_to_coord (Settings.grid_unit, v) @@ -80,9 +80,9 @@ /* The modifier keys */ - #define GHID_KEY_ALT 0x80 - #define GHID_KEY_CONTROL 0x40 - #define GHID_KEY_SHIFT 0x20 +#define GHID_KEY_ALT 0x80 +#define GHID_KEY_CONTROL 0x40 +#define GHID_KEY_SHIFT 0x20 /* The actual keys */ #define GHID_KEY_TAB 0x01 @@ -91,215 +91,179 @@ #define GHID_KEY_LEFT 0x04 #define GHID_KEY_RIGHT 0x05 -typedef struct -{ - GtkActionGroup *main_actions, - *change_selected_actions, *displayed_name_actions; +typedef struct { + GtkActionGroup *main_actions, *change_selected_actions, *displayed_name_actions; - GtkWidget - *status_line_label, - *cursor_position_relative_label, - *cursor_position_absolute_label, - *grid_units_label, *status_line_hbox, *command_combo_box; - GtkEntry *command_entry; + GtkWidget + * status_line_label, + *cursor_position_relative_label, *cursor_position_absolute_label, *grid_units_label, *status_line_hbox, *command_combo_box; + GtkEntry *command_entry; - GtkWidget *top_hbox, - *top_bar_background, - *menu_hbox, *position_hbox, - *menubar_toolbar_vbox, - *mode_buttons_frame; - GtkWidget *left_toolbar; - GtkWidget *grid_units_button; - GtkWidget *menu_bar, *layer_selector, *route_style_selector; - GtkWidget *mode_toolbar; - GtkWidget *vbox_middle; + GtkWidget *top_hbox, *top_bar_background, *menu_hbox, *position_hbox, *menubar_toolbar_vbox, *mode_buttons_frame; + GtkWidget *left_toolbar; + GtkWidget *grid_units_button; + GtkWidget *menu_bar, *layer_selector, *route_style_selector; + GtkWidget *mode_toolbar; + GtkWidget *vbox_middle; - GtkWidget *info_bar; - GTimeVal our_mtime; - GTimeVal last_seen_mtime; + GtkWidget *info_bar; + GTimeVal our_mtime; + GTimeVal last_seen_mtime; - GtkWidget *h_range, *v_range; - GtkObject *h_adjustment, *v_adjustment; + GtkWidget *h_range, *v_range; + GtkObject *h_adjustment, *v_adjustment; - GdkPixbuf *bg_pixbuf; + GdkPixbuf *bg_pixbuf; - gchar *name_label_string; + gchar *name_label_string; - gboolean adjustment_changed_holdoff, - command_entry_status_line_active, - in_popup; + gboolean adjustment_changed_holdoff, command_entry_status_line_active, in_popup; - gboolean config_modified, - small_label_markup, - compact_horizontal, - compact_vertical, - use_command_window, - creating; + gboolean config_modified, small_label_markup, compact_horizontal, compact_vertical, use_command_window, creating; - gint n_mode_button_columns, - top_window_width, - top_window_height, - log_window_width, - log_window_height, - drc_window_width, - drc_window_height, - keyref_window_width, - keyref_window_height, - library_window_width, - library_window_height, - netlist_window_height, history_size, settings_mode; -} -GhidGui; + gint n_mode_button_columns, + top_window_width, + top_window_height, + log_window_width, + log_window_height, + drc_window_width, + drc_window_height, + keyref_window_width, + keyref_window_height, library_window_width, library_window_height, netlist_window_height, history_size, settings_mode; +} GhidGui; extern GhidGui _ghidgui, *ghidgui; -typedef struct -{ - double coord_per_px; /* Zoom level described as PCB units per screen pixel */ +typedef struct { + double coord_per_px; /* Zoom level described as PCB units per screen pixel */ - Coord x0; - Coord y0; - Coord width; - Coord height; + Coord x0; + Coord y0; + Coord width; + Coord height; - bool flip_x; - bool flip_y; + bool flip_x; + bool flip_y; } view_data; - /* The output viewport - */ -typedef struct -{ - GtkWidget *top_window, /* toplevel widget */ - *drawing_area; /* and its drawing area */ - GdkPixmap *pixmap, *mask; - GdkDrawable *drawable; /* Current drawable for drawing routines */ - gint width, height; + /* The output viewport + */ +typedef struct { + GtkWidget *top_window, /* toplevel widget */ + *drawing_area; /* and its drawing area */ + GdkPixmap *pixmap, *mask; + GdkDrawable *drawable; /* Current drawable for drawing routines */ + gint width, height; - struct render_priv *render_priv; + struct render_priv *render_priv; - GdkColor bg_color, offlimits_color, grid_color; + GdkColor bg_color, offlimits_color, grid_color; - GdkColormap *colormap; + GdkColormap *colormap; - GdkCursor *X_cursor; /* used X cursor */ - GdkCursorType X_cursor_shape; /* and its shape */ + GdkCursor *X_cursor; /* used X cursor */ + GdkCursorType X_cursor_shape; /* and its shape */ - gboolean has_entered; - gboolean panning; + gboolean has_entered; + gboolean panning; - view_data view; - Coord pcb_x, pcb_y; /* PCB coordinates of the mouse pointer */ - Coord crosshair_x, crosshair_y; /* PCB coordinates of the crosshair */ -} -GHidPort; + view_data view; + Coord pcb_x, pcb_y; /* PCB coordinates of the mouse pointer */ + Coord crosshair_x, crosshair_y; /* PCB coordinates of the crosshair */ +} GHidPort; extern GHidPort ghid_port, *gport; -typedef enum -{ - NONE_PRESSED = 0, - SHIFT_PRESSED = M_Shift, - CONTROL_PRESSED = M_Ctrl, - MOD1_PRESSED = M_Mod(1), - SHIFT_CONTROL_PRESSED = M_Shift | M_Ctrl, - SHIFT_MOD1_PRESSED = M_Shift | M_Mod(1), - CONTROL_MOD1_PRESSED = M_Ctrl | M_Mod(1), - SHIFT_CONTROL_MOD1_PRESSED = M_Shift | M_Ctrl | M_Mod(1), -} -ModifierKeysState; +typedef enum { + NONE_PRESSED = 0, + SHIFT_PRESSED = M_Shift, + CONTROL_PRESSED = M_Ctrl, + MOD1_PRESSED = M_Mod(1), + SHIFT_CONTROL_PRESSED = M_Shift | M_Ctrl, + SHIFT_MOD1_PRESSED = M_Shift | M_Mod(1), + CONTROL_MOD1_PRESSED = M_Ctrl | M_Mod(1), + SHIFT_CONTROL_MOD1_PRESSED = M_Shift | M_Ctrl | M_Mod(1), +} ModifierKeysState; -typedef enum -{ - NO_BUTTON_PRESSED, - BUTTON1_PRESSED, - BUTTON2_PRESSED, - BUTTON3_PRESSED -} -ButtonState; +typedef enum { + NO_BUTTON_PRESSED, + BUTTON1_PRESSED, + BUTTON2_PRESSED, + BUTTON3_PRESSED +} ButtonState; /* Function prototypes */ -void ghid_parse_arguments (gint * argc, gchar *** argv); -void ghid_do_export (HID_Attr_Val * options); +void ghid_parse_arguments(gint * argc, gchar *** argv); +void ghid_do_export(HID_Attr_Val * options); -void ghid_create_pcb_widgets (void); -void ghid_window_set_name_label (gchar * name); -void ghid_interface_set_sensitive (gboolean sensitive); -void ghid_interface_input_signals_connect (void); -void ghid_interface_input_signals_disconnect (void); +void ghid_create_pcb_widgets(void); +void ghid_window_set_name_label(gchar * name); +void ghid_interface_set_sensitive(gboolean sensitive); +void ghid_interface_input_signals_connect(void); +void ghid_interface_input_signals_disconnect(void); -void ghid_pcb_saved_toggle_states_set (void); -void ghid_sync_with_new_layout (void); +void ghid_pcb_saved_toggle_states_set(void); +void ghid_sync_with_new_layout(void); -void ghid_change_selected_update_menu_actions (void); +void ghid_change_selected_update_menu_actions(void); -void ghid_config_window_show (); -void ghid_config_handle_units_changed (void); -void ghid_config_start_backup_timer (void); -void ghid_config_text_scale_update (void); -void ghid_config_layer_name_update (gchar * name, gint layer); +void ghid_config_window_show(); +void ghid_config_handle_units_changed(void); +void ghid_config_start_backup_timer(void); +void ghid_config_text_scale_update(void); +void ghid_config_layer_name_update(gchar * name, gint layer); void ghid_config_groups_changed(void); -void ghid_config_init (void); -void ghid_config_files_write (void); -void ghid_config_files_read (gint * argc, gchar *** argv); +void ghid_config_init(void); +void ghid_config_files_write(void); +void ghid_config_files_read(gint * argc, gchar *** argv); -void ghid_mode_buttons_update (void); +void ghid_mode_buttons_update(void); void ghid_pack_mode_buttons(void); -void ghid_layer_buttons_update (void); -void ghid_layer_buttons_color_update (void); +void ghid_layer_buttons_update(void); +void ghid_layer_buttons_color_update(void); /* gui-misc.c function prototypes */ -void ghid_status_line_set_text (const gchar * text); -void ghid_cursor_position_label_set_text (gchar * text); -void ghid_cursor_position_relative_label_set_text (gchar * text); +void ghid_status_line_set_text(const gchar * text); +void ghid_cursor_position_label_set_text(gchar * text); +void ghid_cursor_position_relative_label_set_text(gchar * text); -void ghid_hand_cursor (void); -void ghid_point_cursor (void); -void ghid_watch_cursor (void); -void ghid_mode_cursor (gint mode); -void ghid_corner_cursor (void); -void ghid_restore_cursor (void); -void ghid_get_user_xy (const gchar * msg); -void ghid_create_abort_dialog (gchar *); -gboolean ghid_check_abort (void); -void ghid_end_abort (void); -void ghid_get_pointer (gint *, gint *); +void ghid_hand_cursor(void); +void ghid_point_cursor(void); +void ghid_watch_cursor(void); +void ghid_mode_cursor(gint mode); +void ghid_corner_cursor(void); +void ghid_restore_cursor(void); +void ghid_get_user_xy(const gchar * msg); +void ghid_create_abort_dialog(gchar *); +gboolean ghid_check_abort(void); +void ghid_end_abort(void); +void ghid_get_pointer(gint *, gint *); /* gui-output-events.c function prototypes. */ -void ghid_port_ranges_changed (void); -void ghid_port_ranges_scale (void); +void ghid_port_ranges_changed(void); +void ghid_port_ranges_scale(void); -gboolean ghid_note_event_location (GdkEventButton * ev); -gboolean ghid_port_key_press_cb (GtkWidget * drawing_area, - GdkEventKey * kev, gpointer data); -gboolean ghid_port_key_release_cb (GtkWidget * drawing_area, - GdkEventKey * kev, gpointer data); -gboolean ghid_port_button_press_cb (GtkWidget * drawing_area, - GdkEventButton * ev, gpointer data); -gboolean ghid_port_button_release_cb (GtkWidget * drawing_area, - GdkEventButton * ev, gpointer data); +gboolean ghid_note_event_location(GdkEventButton * ev); +gboolean ghid_port_key_press_cb(GtkWidget * drawing_area, GdkEventKey * kev, gpointer data); +gboolean ghid_port_key_release_cb(GtkWidget * drawing_area, GdkEventKey * kev, gpointer data); +gboolean ghid_port_button_press_cb(GtkWidget * drawing_area, GdkEventButton * ev, gpointer data); +gboolean ghid_port_button_release_cb(GtkWidget * drawing_area, GdkEventButton * ev, gpointer data); -gint ghid_port_window_enter_cb (GtkWidget * widget, - GdkEventCrossing * ev, GHidPort * out); -gint ghid_port_window_leave_cb (GtkWidget * widget, - GdkEventCrossing * ev, GHidPort * out); -gint ghid_port_window_motion_cb (GtkWidget * widget, - GdkEventMotion * ev, GHidPort * out); -gint ghid_port_window_mouse_scroll_cb (GtkWidget * widget, - GdkEventScroll * ev, GHidPort * out); +gint ghid_port_window_enter_cb(GtkWidget * widget, GdkEventCrossing * ev, GHidPort * out); +gint ghid_port_window_leave_cb(GtkWidget * widget, GdkEventCrossing * ev, GHidPort * out); +gint ghid_port_window_motion_cb(GtkWidget * widget, GdkEventMotion * ev, GHidPort * out); +gint ghid_port_window_mouse_scroll_cb(GtkWidget * widget, GdkEventScroll * ev, GHidPort * out); -gint ghid_port_drawing_area_configure_event_cb (GtkWidget * widget, - GdkEventConfigure * ev, - GHidPort * out); +gint ghid_port_drawing_area_configure_event_cb(GtkWidget * widget, GdkEventConfigure * ev, GHidPort * out); /* gui-dialog.c function prototypes. @@ -306,212 +270,190 @@ */ #define GUI_DIALOG_RESPONSE_ALL 1 -gchar *ghid_dialog_file_select_open (gchar * title, gchar ** path, - gchar * shortcuts); -gchar *ghid_dialog_file_select_save (gchar * title, gchar ** path, - gchar * file, gchar * shortcuts); -void ghid_dialog_message (gchar * message); -gboolean ghid_dialog_confirm (gchar * message, gchar *cancelmsg, gchar *okmsg); -int ghid_dialog_close_confirm (void); +gchar *ghid_dialog_file_select_open(gchar * title, gchar ** path, gchar * shortcuts); +gchar *ghid_dialog_file_select_save(gchar * title, gchar ** path, gchar * file, gchar * shortcuts); +void ghid_dialog_message(gchar * message); +gboolean ghid_dialog_confirm(gchar * message, gchar * cancelmsg, gchar * okmsg); +int ghid_dialog_close_confirm(void); #define GUI_DIALOG_CLOSE_CONFIRM_CANCEL 0 #define GUI_DIALOG_CLOSE_CONFIRM_NOSAVE 1 #define GUI_DIALOG_CLOSE_CONFIRM_SAVE 2 -gint ghid_dialog_confirm_all (gchar * message); -gchar *ghid_dialog_input (const char * prompt, const char * initial); -void ghid_dialog_about (void); +gint ghid_dialog_confirm_all(gchar * message); +gchar *ghid_dialog_input(const char *prompt, const char *initial); +void ghid_dialog_about(void); -char * ghid_fileselect (const char *, const char *, char *, char *, const char *, int); +char *ghid_fileselect(const char *, const char *, char *, char *, const char *, int); /* gui-dialog-print.c */ -void ghid_dialog_export (void); -void ghid_dialog_print (HID *); +void ghid_dialog_export(void); +void ghid_dialog_print(HID *); -int ghid_attribute_dialog (HID_Attribute *, int, HID_Attr_Val *, const char *, const char *); +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_violation (DrcViolationType *violation); -void ghid_drc_window_append_messagev (const char *fmt, va_list va); -int ghid_drc_window_throw_dialog (void); +void ghid_drc_window_show(gboolean raise); +void ghid_drc_window_reset_message(void); +void ghid_drc_window_append_violation(DrcViolationType * violation); +void ghid_drc_window_append_messagev(const char *fmt, va_list va); +int ghid_drc_window_throw_dialog(void); /* In gui-top-window.c */ -void ghid_update_toggle_flags (void); -void ghid_notify_save_pcb (const char *file, bool done); -void ghid_notify_filename_changed (void); -void ghid_install_accel_groups (GtkWindow *window, GhidGui *gui); -void ghid_remove_accel_groups (GtkWindow *window, GhidGui *gui); -void make_route_style_buttons (GHidRouteStyleSelector *rss); +void ghid_update_toggle_flags(void); +void ghid_notify_save_pcb(const char *file, bool done); +void ghid_notify_filename_changed(void); +void ghid_install_accel_groups(GtkWindow * window, GhidGui * gui); +void ghid_remove_accel_groups(GtkWindow * window, GhidGui * gui); +void make_route_style_buttons(GHidRouteStyleSelector * rss); /* gui-utils.c */ -gboolean dup_string (gchar ** dst, const gchar * src); -gboolean utf8_dup_string (gchar ** dst_utf8, const gchar * src); -void free_glist_and_data (GList ** list_head); +gboolean dup_string(gchar ** dst, const gchar * src); +gboolean utf8_dup_string(gchar ** dst_utf8, const gchar * src); +void free_glist_and_data(GList ** list_head); -ModifierKeysState ghid_modifier_keys_state (GdkModifierType * state); -ButtonState ghid_button_state (GdkModifierType * state); -gboolean ghid_is_modifier_key_sym (gint ksym); -gboolean ghid_control_is_pressed (void); -gboolean ghid_mod1_is_pressed (void); -gboolean ghid_shift_is_pressed (void); +ModifierKeysState ghid_modifier_keys_state(GdkModifierType * state); +ButtonState ghid_button_state(GdkModifierType * state); +gboolean ghid_is_modifier_key_sym(gint ksym); +gboolean ghid_control_is_pressed(void); +gboolean ghid_mod1_is_pressed(void); +gboolean ghid_shift_is_pressed(void); -void ghid_draw_area_update (GHidPort * out, GdkRectangle * rect); -gchar *ghid_get_color_name (GdkColor * color); -void ghid_map_color_string (gchar * color_string, GdkColor * color); -gchar *ghid_entry_get_text (GtkWidget * entry); -void ghid_check_button_connected (GtkWidget * box, GtkWidget ** button, - gboolean active, gboolean pack_start, - gboolean expand, gboolean fill, gint pad, - void (*cb_func) (GtkToggleButton *, gpointer), gpointer data, - gchar * string); -void ghid_button_connected (GtkWidget * box, GtkWidget ** button, - gboolean pack_start, gboolean expand, - gboolean fill, gint pad, void (*cb_func) (gpointer), - gpointer data, gchar * string); -void ghid_coord_entry (GtkWidget * box, GtkWidget ** coord_entry, Coord value, - Coord low, Coord high, enum ce_step_size step_size, - gint width, void (*cb_func) (GHidCoordEntry *, gpointer), - gpointer data, gboolean right_align, gchar * string); -void ghid_spin_button (GtkWidget * box, GtkWidget ** spin_button, - gfloat value, gfloat low, gfloat high, gfloat step0, - gfloat step1, gint digits, gint width, - void (*cb_func) (GtkSpinButton *, gpointer), gpointer data, - gboolean right_align, gchar * string); -void ghid_table_coord_entry (GtkWidget * table, gint row, gint column, - GtkWidget ** coord_entry, Coord value, - Coord low, Coord high, enum ce_step_size, gint width, - void (*cb_func) (GHidCoordEntry *, gpointer), gpointer data, - gboolean right_align, gchar * string); -void ghid_table_spin_button (GtkWidget * box, gint row, gint column, - GtkWidget ** spin_button, gfloat value, - gfloat low, gfloat high, gfloat step0, - gfloat step1, gint digits, gint width, - void (*cb_func) (GtkSpinButton *, gpointer), gpointer data, - gboolean right_align, gchar * string); +void ghid_draw_area_update(GHidPort * out, GdkRectangle * rect); +gchar *ghid_get_color_name(GdkColor * color); +void ghid_map_color_string(gchar * color_string, GdkColor * color); +gchar *ghid_entry_get_text(GtkWidget * entry); +void ghid_check_button_connected(GtkWidget * box, GtkWidget ** button, + gboolean active, gboolean pack_start, + gboolean expand, gboolean fill, gint pad, + void (*cb_func) (GtkToggleButton *, gpointer), gpointer data, gchar * string); +void ghid_button_connected(GtkWidget * box, GtkWidget ** button, + gboolean pack_start, gboolean expand, + gboolean fill, gint pad, void (*cb_func) (gpointer), gpointer data, gchar * string); +void ghid_coord_entry(GtkWidget * box, GtkWidget ** coord_entry, Coord value, + Coord low, Coord high, enum ce_step_size step_size, + gint width, void (*cb_func) (GHidCoordEntry *, gpointer), + gpointer data, gboolean right_align, gchar * string); +void ghid_spin_button(GtkWidget * box, GtkWidget ** spin_button, + gfloat value, gfloat low, gfloat high, gfloat step0, + gfloat step1, gint digits, gint width, + void (*cb_func) (GtkSpinButton *, gpointer), gpointer data, gboolean right_align, gchar * string); +void ghid_table_coord_entry(GtkWidget * table, gint row, gint column, + GtkWidget ** coord_entry, Coord value, + Coord low, Coord high, enum ce_step_size, gint width, + void (*cb_func) (GHidCoordEntry *, gpointer), gpointer data, gboolean right_align, gchar * string); +void ghid_table_spin_button(GtkWidget * box, gint row, gint column, + GtkWidget ** spin_button, gfloat value, + gfloat low, gfloat high, gfloat step0, + gfloat step1, gint digits, gint width, + void (*cb_func) (GtkSpinButton *, gpointer), gpointer data, gboolean right_align, gchar * string); -void ghid_range_control (GtkWidget * box, GtkWidget ** scale_res, - gboolean horizontal, GtkPositionType pos, - gboolean set_draw_value, gint digits, - gboolean pack_start, gboolean expand, gboolean fill, - guint pad, gfloat value, gfloat low, gfloat high, - gfloat step0, gfloat step1, void (*cb_func) (), - gpointer data); -GtkWidget *ghid_scrolled_vbox (GtkWidget * box, GtkWidget ** scr, - GtkPolicyType h_policy, - GtkPolicyType v_policy); -GtkWidget *ghid_framed_vbox (GtkWidget * box, gchar * label, - gint frame_border_width, gboolean frame_expand, - gint vbox_pad, gint vbox_border_width); -GtkWidget *ghid_framed_vbox_end (GtkWidget * box, gchar * label, - gint frame_border_width, - gboolean frame_expand, gint vbox_pad, - gint vbox_border_width); -GtkWidget *ghid_category_vbox (GtkWidget * box, const gchar * category_header, - gint header_pad, gint box_pad, - gboolean pack_start, gboolean bottom_pad); -GtkWidget *ghid_notebook_page (GtkWidget * tabs, char *name, gint pad, - gint border); -GtkWidget *ghid_framed_notebook_page (GtkWidget * tabs, char *name, - gint border, gint frame_border, - gint vbox_pad, gint vbox_border); -GtkWidget *ghid_scrolled_text_view (GtkWidget * box, GtkWidget ** scr, - GtkPolicyType h_policy, - GtkPolicyType v_policy); -void ghid_text_view_append (GtkWidget * view, gchar * string); -void ghid_text_view_append_strings (GtkWidget * view, gchar ** string, - gint n_strings); -GtkTreeSelection *ghid_scrolled_selection (GtkTreeView * treeview, - GtkWidget * box, - GtkSelectionMode s_mode, - GtkPolicyType h_policy, - GtkPolicyType v_policy, - void (*func_cb) (GtkTreeSelection *, gpointer), gpointer data); +void ghid_range_control(GtkWidget * box, GtkWidget ** scale_res, + gboolean horizontal, GtkPositionType pos, + gboolean set_draw_value, gint digits, + gboolean pack_start, gboolean expand, gboolean fill, + guint pad, gfloat value, gfloat low, gfloat high, + gfloat step0, gfloat step1, void (*cb_func) (), gpointer data); +GtkWidget *ghid_scrolled_vbox(GtkWidget * box, GtkWidget ** scr, GtkPolicyType h_policy, GtkPolicyType v_policy); +GtkWidget *ghid_framed_vbox(GtkWidget * box, gchar * label, + gint frame_border_width, gboolean frame_expand, gint vbox_pad, gint vbox_border_width); +GtkWidget *ghid_framed_vbox_end(GtkWidget * box, gchar * label, + gint frame_border_width, gboolean frame_expand, gint vbox_pad, gint vbox_border_width); +GtkWidget *ghid_category_vbox(GtkWidget * box, const gchar * category_header, + gint header_pad, gint box_pad, gboolean pack_start, gboolean bottom_pad); +GtkWidget *ghid_notebook_page(GtkWidget * tabs, char *name, gint pad, gint border); +GtkWidget *ghid_framed_notebook_page(GtkWidget * tabs, char *name, + gint border, gint frame_border, gint vbox_pad, gint vbox_border); +GtkWidget *ghid_scrolled_text_view(GtkWidget * box, GtkWidget ** scr, GtkPolicyType h_policy, GtkPolicyType v_policy); +void ghid_text_view_append(GtkWidget * view, gchar * string); +void ghid_text_view_append_strings(GtkWidget * view, gchar ** string, gint n_strings); +GtkTreeSelection *ghid_scrolled_selection(GtkTreeView * treeview, + GtkWidget * box, + GtkSelectionMode s_mode, + GtkPolicyType h_policy, + GtkPolicyType v_policy, + void (*func_cb) (GtkTreeSelection *, gpointer), gpointer data); -void ghid_dialog_report (const gchar * title, const gchar * message); -void ghid_label_set_markup (GtkWidget * label, const gchar * text); +void ghid_dialog_report(const gchar * title, const gchar * message); +void ghid_label_set_markup(GtkWidget * label, const gchar * text); -void ghid_set_cursor_position_labels (void); -void ghid_set_status_line_label (void); +void ghid_set_cursor_position_labels(void); +void ghid_set_status_line_label(void); /* gui-netlist-window.c */ -void ghid_netlist_window_create (GHidPort * out); -void ghid_netlist_window_show (GHidPort * out, gboolean raise); -void ghid_netlist_window_update (gboolean init_nodes); +void ghid_netlist_window_create(GHidPort * out); +void ghid_netlist_window_show(GHidPort * out, gboolean raise); +void ghid_netlist_window_update(gboolean init_nodes); -LibraryMenuType *ghid_get_net_from_node_name (gchar * name, gboolean); -void ghid_netlist_highlight_node (gchar * name); +LibraryMenuType *ghid_get_net_from_node_name(gchar * name, gboolean); +void ghid_netlist_highlight_node(gchar * name); /* gui-command-window.c */ -void ghid_handle_user_command (gboolean raise); -void ghid_command_window_show (gboolean raise); -gchar *ghid_command_entry_get (gchar * prompt, gchar * command); -void ghid_command_use_command_window_sync (void); +void ghid_handle_user_command(gboolean raise); +void ghid_command_window_show(gboolean raise); +gchar *ghid_command_entry_get(gchar * prompt, gchar * command); +void ghid_command_use_command_window_sync(void); /* gui-keyref-window.c */ -void ghid_keyref_window_show (gboolean raise); +void ghid_keyref_window_show(gboolean raise); /* gui-library-window.c */ -void ghid_library_window_create (GHidPort * out); -void ghid_library_window_show (GHidPort * out, gboolean raise); +void ghid_library_window_create(GHidPort * out); +void ghid_library_window_show(GHidPort * out, gboolean raise); /* gui-log-window.c */ -void ghid_log_window_create (); -void ghid_log_window_show (gboolean raise); -void ghid_log (const char *fmt, ...); -void ghid_logv (const char *fmt, va_list args); +void ghid_log_window_create(); +void ghid_log_window_show(gboolean raise); +void ghid_log(const char *fmt, ...); +void ghid_logv(const char *fmt, va_list args); /* gui-pinout-window.c */ -void ghid_pinout_window_show (GHidPort * out, ElementTypePtr Element); +void ghid_pinout_window_show(GHidPort * out, ElementTypePtr Element); /* gtkhid-gdk.c AND gtkhid-gl.c */ -int ghid_set_layer (const char *name, int group, int empty); -hidGC ghid_make_gc (void); -void ghid_destroy_gc (hidGC); -void ghid_use_mask (int use_it); -void ghid_set_color (hidGC gc, const char *name); -void ghid_set_line_cap (hidGC gc, EndCapStyle style); -void ghid_set_line_width (hidGC gc, Coord width); -void ghid_set_draw_xor (hidGC gc, int _xor); -void ghid_draw_line (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2); -void ghid_draw_arc (hidGC gc, Coord cx, Coord cy, Coord xradius, Coord yradius, - Angle start_angle, Angle delta_angle); -void ghid_draw_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2); -void ghid_fill_circle (hidGC gc, Coord cx, Coord cy, Coord radius); -void ghid_fill_polygon (hidGC gc, int n_coords, Coord *x, Coord *y); -void ghid_fill_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2); -void ghid_invalidate_lr (int left, int right, int top, int bottom); -void ghid_invalidate_all (); -void ghid_notify_crosshair_change (bool changes_complete); -void ghid_notify_mark_change (bool changes_complete); -void ghid_init_renderer (int *, char ***, GHidPort *); -void ghid_shutdown_renderer (GHidPort *); -void ghid_init_drawing_widget (GtkWidget *widget, GHidPort *); -void ghid_drawing_area_configure_hook (GHidPort *port); -void ghid_screen_update (void); -gboolean ghid_drawing_area_expose_cb (GtkWidget *, GdkEventExpose *, - GHidPort *); -void ghid_port_drawing_realize_cb (GtkWidget *, gpointer); -gboolean ghid_pinout_preview_expose (GtkWidget * widget, GdkEventExpose * ev); -GdkPixmap *ghid_render_pixmap (int cx, int cy, double zoom, - int width, int height, int depth); -HID *ghid_request_debug_draw (void); -void ghid_flush_debug_draw (void); -void ghid_finish_debug_draw (void); -bool ghid_event_to_pcb_coords (int event_x, int event_y, Coord *pcb_x, Coord *pcb_y); -bool ghid_pcb_to_event_coords (Coord pcb_x, Coord pcb_y, int *event_x, int *event_y); +int ghid_set_layer(const char *name, int group, int empty); +hidGC ghid_make_gc(void); +void ghid_destroy_gc(hidGC); +void ghid_use_mask(int use_it); +void ghid_set_color(hidGC gc, const char *name); +void ghid_set_line_cap(hidGC gc, EndCapStyle style); +void ghid_set_line_width(hidGC gc, Coord width); +void ghid_set_draw_xor(hidGC gc, int _xor); +void ghid_draw_line(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2); +void ghid_draw_arc(hidGC gc, Coord cx, Coord cy, Coord xradius, Coord yradius, Angle start_angle, Angle delta_angle); +void ghid_draw_rect(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2); +void ghid_fill_circle(hidGC gc, Coord cx, Coord cy, Coord radius); +void ghid_fill_polygon(hidGC gc, int n_coords, Coord * x, Coord * y); +void ghid_fill_rect(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2); +void ghid_invalidate_lr(int left, int right, int top, int bottom); +void ghid_invalidate_all(); +void ghid_notify_crosshair_change(bool changes_complete); +void ghid_notify_mark_change(bool changes_complete); +void ghid_init_renderer(int *, char ***, GHidPort *); +void ghid_shutdown_renderer(GHidPort *); +void ghid_init_drawing_widget(GtkWidget * widget, GHidPort *); +void ghid_drawing_area_configure_hook(GHidPort * port); +void ghid_screen_update(void); +gboolean ghid_drawing_area_expose_cb(GtkWidget *, GdkEventExpose *, GHidPort *); +void ghid_port_drawing_realize_cb(GtkWidget *, gpointer); +gboolean ghid_pinout_preview_expose(GtkWidget * widget, GdkEventExpose * ev); +GdkPixmap *ghid_render_pixmap(int cx, int cy, double zoom, int width, int height, int depth); +HID *ghid_request_debug_draw(void); +void ghid_flush_debug_draw(void); +void ghid_finish_debug_draw(void); +bool ghid_event_to_pcb_coords(int event_x, int event_y, Coord * pcb_x, Coord * pcb_y); +bool ghid_pcb_to_event_coords(Coord pcb_x, Coord pcb_y, int *event_x, int *event_y); -void ghid_lead_user_to_location (Coord x, Coord y); -void ghid_cancel_lead_user (void); +void ghid_lead_user_to_location(Coord x, Coord y); +void ghid_cancel_lead_user(void); /* gtkhid-main.c */ -void ghid_pan_view_rel (Coord dx, Coord dy); -void ghid_get_coords (const char *msg, Coord *x, Coord *y); -gint PCBChanged (int argc, char **argv, Coord x, Coord y); +void ghid_pan_view_rel(Coord dx, Coord dy); +void ghid_get_coords(const char *msg, Coord * x, Coord * y); +gint PCBChanged(int argc, char **argv, Coord x, Coord y); @@ -523,56 +465,50 @@ /* Coordinate conversions */ /* Px converts view->pcb, Vx converts pcb->view */ -static inline int -Vx (Coord x) +static inline int Vx(Coord x) { - int rv; - if (gport->view.flip_x) - rv = (PCB->MaxWidth - x - gport->view.x0) / gport->view.coord_per_px + 0.5; - else - rv = (x - gport->view.x0) / gport->view.coord_per_px + 0.5; - return rv; + int rv; + if (gport->view.flip_x) + rv = (PCB->MaxWidth - x - gport->view.x0) / gport->view.coord_per_px + 0.5; + else + rv = (x - gport->view.x0) / gport->view.coord_per_px + 0.5; + return rv; } -static inline int -Vy (Coord y) +static inline int Vy(Coord y) { - int rv; - if (gport->view.flip_y) - rv = (PCB->MaxHeight - y - gport->view.y0) / gport->view.coord_per_px + 0.5; - else - rv = (y - gport->view.y0) / gport->view.coord_per_px + 0.5; - return rv; + int rv; + if (gport->view.flip_y) + rv = (PCB->MaxHeight - y - gport->view.y0) / gport->view.coord_per_px + 0.5; + else + rv = (y - gport->view.y0) / gport->view.coord_per_px + 0.5; + return rv; } -static inline int -Vz (Coord z) +static inline int Vz(Coord z) { - return z / gport->view.coord_per_px + 0.5; + return z / gport->view.coord_per_px + 0.5; } -static inline Coord -Px (int x) +static inline Coord Px(int x) { - Coord rv = x * gport->view.coord_per_px + gport->view.x0; - if (gport->view.flip_x) - rv = PCB->MaxWidth - (x * gport->view.coord_per_px + gport->view.x0); - return rv; + Coord rv = x * gport->view.coord_per_px + gport->view.x0; + if (gport->view.flip_x) + rv = PCB->MaxWidth - (x * gport->view.coord_per_px + gport->view.x0); + return rv; } -static inline Coord -Py (int y) +static inline Coord Py(int y) { - Coord rv = y * gport->view.coord_per_px + gport->view.y0; - if (gport->view.flip_y) - rv = PCB->MaxHeight - (y * gport->view.coord_per_px + gport->view.y0); - return rv; + Coord rv = y * gport->view.coord_per_px + gport->view.y0; + if (gport->view.flip_y) + rv = PCB->MaxHeight - (y * gport->view.coord_per_px + gport->view.y0); + return rv; } -static inline Coord -Pz (int z) +static inline Coord Pz(int z) { - return (z * gport->view.coord_per_px); + return (z * gport->view.coord_per_px); } #endif /* PCB_HID_GTK_GHID_H */ Index: trunk/src/hid/hidint.h =================================================================== --- trunk/src/hid/hidint.h (revision 1021) +++ trunk/src/hid/hidint.h (revision 1022) @@ -9,8 +9,8 @@ #define SL_MYSIDE(x) ((((x) & SL_BOTTOM_SIDE)!=0) == (SWAP_IDENT != 0)) /* Called by the init funcs, used to set up hid_list. */ -extern void hid_register_hid (HID * hid); -void hid_remove_hid (HID * hid); +extern void hid_register_hid(HID * hid); +void hid_remove_hid(HID * hid); /* NULL terminated list of all static HID structures. Built by @@ -26,48 +26,47 @@ and if found sets val and returns nonzero. If not found, it returns zero. If set is nonzero, name/val is added to the cache. */ -int hid_cache_color (int set, const char *name, hidval * val, void **cache); +int hid_cache_color(int set, const char *name, hidval * val, void **cache); -typedef struct HID_AttrNode -{ - struct HID_AttrNode *next; - HID_Attribute *attributes; - int n; +typedef struct HID_AttrNode { + struct HID_AttrNode *next; + HID_Attribute *attributes; + int n; } HID_AttrNode; extern HID_AttrNode *hid_attr_nodes; -HID_Action *hid_find_action (const char *name); +HID_Action *hid_find_action(const char *name); -HID_Flag *hid_find_flag (const char *name); +HID_Flag *hid_find_flag(const char *name); /* A HID may use this if it does not need command line arguments in any special format; for example, the Lesstif HID needs to use the Xt parser, but the Postscript HID can use this function. */ -void hid_parse_command_line (int *argc, char ***argv); +void hid_parse_command_line(int *argc, char ***argv); /* Use this to temporarily enable all layers, so that they can be exported even if they're not currently visible. save_array must be MAX_LAYER+2 big. */ -void hid_save_and_show_layer_ons (int *save_array); +void hid_save_and_show_layer_ons(int *save_array); /* Use this to restore them. */ -void hid_restore_layer_ons (int *save_array); +void hid_restore_layer_ons(int *save_array); enum File_Name_Style { - /* Files for copper layers are named top, groupN, bottom. */ - FNS_fixed, - /* Groups with multiple layers are named as above, else the single - layer name is used. */ - FNS_single, - /* The name of the first layer in each group is used. */ - FNS_first, + /* Files for copper layers are named top, groupN, bottom. */ + FNS_fixed, + /* Groups with multiple layers are named as above, else the single + layer name is used. */ + FNS_single, + /* The name of the first layer in each group is used. */ + FNS_first, }; /* Returns a filename base that can be used to output the layer. */ -const char *layer_type_to_file_name (int idx, int style); +const char *layer_type_to_file_name(int idx, int style); /* Convenience function that calls the expose callback for the item, and returns the extents of what was drawn. */ -BoxType *hid_get_extents (void *item); +BoxType *hid_get_extents(void *item); -void derive_default_filename(const char *pcbfile, HID_Attribute *filename_attrib, const char *suffix, char **memory); +void derive_default_filename(const char *pcbfile, HID_Attribute * filename_attrib, const char *suffix, char **memory); Index: trunk/src/hid/lesstif/dialogs.c =================================================================== --- trunk/src/hid/lesstif/dialogs.c (revision 1021) +++ trunk/src/hid/lesstif/dialogs.c (revision 1022) @@ -24,7 +24,7 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); #define CRASH fprintf(stderr, "HID error: pcb called unimplemented GUI function %s\n", __FUNCTION__), abort() @@ -39,63 +39,53 @@ /* ------------------------------------------------------------ */ -static void -dialog_callback (Widget w, void *v, void *cbs) +static void dialog_callback(Widget w, void *v, void *cbs) { - ok = (int) (size_t) v; + ok = (int) (size_t) v; } -static int -wait_for_dialog (Widget w) +static int wait_for_dialog(Widget w) { - ok = -1; - XtManageChild (w); - while (ok == -1 && XtIsManaged (w)) - { - XEvent e; - XtAppNextEvent (app_context, &e); - XtDispatchEvent (&e); - } - XtUnmanageChild (w); - return ok; + ok = -1; + XtManageChild(w); + while (ok == -1 && XtIsManaged(w)) { + XEvent e; + XtAppNextEvent(app_context, &e); + XtDispatchEvent(&e); + } + XtUnmanageChild(w); + return ok; } /* ------------------------------------------------------------ */ static Widget fsb = 0; -static XmString xms_pcb, xms_net, xms_vend, xms_all, xms_load, xms_loadv, - xms_save, xms_fp; +static XmString xms_pcb, xms_net, xms_vend, xms_all, xms_load, xms_loadv, xms_save, xms_fp; -static void -setup_fsb_dialog () +static void setup_fsb_dialog() { - if (fsb) - return; + if (fsb) + return; - xms_pcb = XmStringCreatePCB ("*.pcb"); - xms_fp = XmStringCreatePCB ("*.fp"); - xms_net = XmStringCreatePCB ("*.net"); - xms_vend = XmStringCreatePCB ("*.vend"); - xms_all = XmStringCreatePCB ("*"); - xms_load = XmStringCreatePCB ("Load From"); - xms_loadv = XmStringCreatePCB ("Load Vendor"); - xms_save = XmStringCreatePCB ("Save As"); + xms_pcb = XmStringCreatePCB("*.pcb"); + xms_fp = XmStringCreatePCB("*.fp"); + xms_net = XmStringCreatePCB("*.net"); + xms_vend = XmStringCreatePCB("*.vend"); + xms_all = XmStringCreatePCB("*"); + xms_load = XmStringCreatePCB("Load From"); + xms_loadv = XmStringCreatePCB("Load Vendor"); + xms_save = XmStringCreatePCB("Save As"); - n = 0; - fsb = XmCreateFileSelectionDialog (mainwind, "file", args, n); + n = 0; + fsb = XmCreateFileSelectionDialog(mainwind, "file", args, n); - XtAddCallback (fsb, XmNokCallback, (XtCallbackProc) dialog_callback, - (XtPointer) 1); - XtAddCallback (fsb, XmNcancelCallback, (XtCallbackProc) dialog_callback, - (XtPointer) 0); + XtAddCallback(fsb, XmNokCallback, (XtCallbackProc) dialog_callback, (XtPointer) 1); + XtAddCallback(fsb, XmNcancelCallback, (XtCallbackProc) dialog_callback, (XtPointer) 0); } -static const char load_syntax[] = -"Load()\n" -"Load(Layout|LayoutToBuffer|ElementToBuffer|Netlist|Revert)"; +static const char load_syntax[] = "Load()\n" "Load(Layout|LayoutToBuffer|ElementToBuffer|Netlist|Revert)"; -static const char load_help[] = -"Load layout data from a user-selected file."; +static const char load_help[] = "Load layout data from a user-selected file."; /* %start-doc actions Load @@ -107,58 +97,55 @@ %end-doc */ -static int -Load (int argc, char **argv, Coord x, Coord y) +static int Load(int argc, char **argv, Coord x, Coord y) { - const char *function; - char *name; - XmString xmname, pattern; + const char *function; + char *name; + XmString xmname, pattern; - if (argc > 1) - return hid_actionv ("LoadFrom", argc, argv); + if (argc > 1) + return hid_actionv("LoadFrom", argc, argv); - function = argc ? argv[0] : "Layout"; + function = argc ? argv[0] : "Layout"; - setup_fsb_dialog (); + setup_fsb_dialog(); - if (strcasecmp (function, "Netlist") == 0) - pattern = xms_net; - else if (strcasecmp (function, "ElementToBuffer") == 0) - pattern = xms_fp; - else - pattern = xms_pcb; + if (strcasecmp(function, "Netlist") == 0) + pattern = xms_net; + else if (strcasecmp(function, "ElementToBuffer") == 0) + pattern = xms_fp; + else + pattern = xms_pcb; - n = 0; - stdarg (XmNtitle, "Load From"); - XtSetValues (XtParent (fsb), args, n); + n = 0; + stdarg(XmNtitle, "Load From"); + XtSetValues(XtParent(fsb), args, n); - n = 0; - stdarg (XmNpattern, pattern); - stdarg (XmNmustMatch, True); - stdarg (XmNselectionLabelString, xms_load); - XtSetValues (fsb, args, n); + n = 0; + stdarg(XmNpattern, pattern); + stdarg(XmNmustMatch, True); + stdarg(XmNselectionLabelString, xms_load); + XtSetValues(fsb, args, n); - if (!wait_for_dialog (fsb)) - return 1; + if (!wait_for_dialog(fsb)) + return 1; - n = 0; - stdarg (XmNdirSpec, &xmname); - XtGetValues (fsb, args, n); + n = 0; + stdarg(XmNdirSpec, &xmname); + XtGetValues(fsb, args, n); - XmStringGetLtoR (xmname, XmFONTLIST_DEFAULT_TAG, &name); + XmStringGetLtoR(xmname, XmFONTLIST_DEFAULT_TAG, &name); - hid_actionl ("LoadFrom", function, name, NULL); + hid_actionl("LoadFrom", function, name, NULL); - XtFree (name); + XtFree(name); - return 0; + return 0; } -static const char loadvendor_syntax[] = -"LoadVendor()"; +static const char loadvendor_syntax[] = "LoadVendor()"; -static const char loadvendor_help[] = -"Loads a user-selected vendor resource file."; +static const char loadvendor_help[] = "Loads a user-selected vendor resource file."; /* %start-doc actions LoadVendor @@ -168,53 +155,48 @@ %end-doc */ -static int -LoadVendor (int argc, char **argv, Coord x, Coord y) +static int LoadVendor(int argc, char **argv, Coord x, Coord y) { - char *name; - XmString xmname, pattern; + char *name; + XmString xmname, pattern; - if (argc > 0) - return hid_actionv ("LoadVendorFrom", argc, argv); + if (argc > 0) + return hid_actionv("LoadVendorFrom", argc, argv); - setup_fsb_dialog (); + setup_fsb_dialog(); - pattern = xms_vend; + pattern = xms_vend; - n = 0; - stdarg (XmNtitle, "Load Vendor"); - XtSetValues (XtParent (fsb), args, n); + n = 0; + stdarg(XmNtitle, "Load Vendor"); + XtSetValues(XtParent(fsb), args, n); - n = 0; - stdarg (XmNpattern, pattern); - stdarg (XmNmustMatch, True); - stdarg (XmNselectionLabelString, xms_loadv); - XtSetValues (fsb, args, n); + n = 0; + stdarg(XmNpattern, pattern); + stdarg(XmNmustMatch, True); + stdarg(XmNselectionLabelString, xms_loadv); + XtSetValues(fsb, args, n); - if (!wait_for_dialog (fsb)) - return 1; + if (!wait_for_dialog(fsb)) + return 1; - n = 0; - stdarg (XmNdirSpec, &xmname); - XtGetValues (fsb, args, n); + n = 0; + stdarg(XmNdirSpec, &xmname); + XtGetValues(fsb, args, n); - XmStringGetLtoR (xmname, XmFONTLIST_DEFAULT_TAG, &name); + XmStringGetLtoR(xmname, XmFONTLIST_DEFAULT_TAG, &name); - hid_actionl ("LoadVendorFrom", name, NULL); + hid_actionl("LoadVendorFrom", name, NULL); - XtFree (name); + XtFree(name); - return 0; + return 0; } static const char save_syntax[] = -"Save()\n" -"Save(Layout|LayoutAs)\n" -"Save(AllConnections|AllUnusedPins|ElementConnections)\n" -"Save(PasteBuffer)"; + "Save()\n" "Save(Layout|LayoutAs)\n" "Save(AllConnections|AllUnusedPins|ElementConnections)\n" "Save(PasteBuffer)"; -static const char save_help[] = -"Save layout data to a user-selected file."; +static const char save_help[] = "Save layout data to a user-selected file."; /* %start-doc actions Save @@ -226,65 +208,63 @@ %end-doc */ -static int -Save (int argc, char **argv, Coord x, Coord y) +static int Save(int argc, char **argv, Coord x, Coord y) { - const char *function; - char *name; - XmString xmname, pattern; + const char *function; + char *name; + XmString xmname, pattern; - if (argc > 1) - hid_actionv ("SaveTo", argc, argv); + if (argc > 1) + hid_actionv("SaveTo", argc, argv); - function = argc ? argv[0] : "Layout"; - - if (strcasecmp (function, "Layout") == 0) - if (PCB->Filename) - return hid_actionl ("SaveTo", "Layout", PCB->Filename, NULL); + function = argc ? argv[0] : "Layout"; - setup_fsb_dialog (); + if (strcasecmp(function, "Layout") == 0) + if (PCB->Filename) + return hid_actionl("SaveTo", "Layout", PCB->Filename, NULL); - pattern = xms_pcb; + setup_fsb_dialog(); - XtManageChild (fsb); + pattern = xms_pcb; - n = 0; - stdarg (XmNtitle, "Save As"); - XtSetValues (XtParent (fsb), args, n); + XtManageChild(fsb); - n = 0; - stdarg (XmNpattern, pattern); - stdarg (XmNmustMatch, False); - stdarg (XmNselectionLabelString, xms_save); - XtSetValues (fsb, args, n); + n = 0; + stdarg(XmNtitle, "Save As"); + XtSetValues(XtParent(fsb), args, n); - if (!wait_for_dialog (fsb)) - return 1; + n = 0; + stdarg(XmNpattern, pattern); + stdarg(XmNmustMatch, False); + stdarg(XmNselectionLabelString, xms_save); + XtSetValues(fsb, args, n); - n = 0; - stdarg (XmNdirSpec, &xmname); - XtGetValues (fsb, args, n); + if (!wait_for_dialog(fsb)) + return 1; - XmStringGetLtoR (xmname, XmFONTLIST_DEFAULT_TAG, &name); + n = 0; + stdarg(XmNdirSpec, &xmname); + XtGetValues(fsb, args, n); - if (strcasecmp (function, "PasteBuffer") == 0) - hid_actionl ("PasteBuffer", "Save", name, NULL); - else - { - /* - * if we got this far and the function is Layout, then - * we really needed it to be a LayoutAs. Otherwise - * ActionSaveTo() will ignore the new file name we - * just obtained. - */ - if (strcasecmp (function, "Layout") == 0) - hid_actionl ("SaveTo", "LayoutAs", name, NULL); - else - hid_actionl ("SaveTo", function, name, NULL); - } - XtFree (name); + XmStringGetLtoR(xmname, XmFONTLIST_DEFAULT_TAG, &name); - return 0; + if (strcasecmp(function, "PasteBuffer") == 0) + hid_actionl("PasteBuffer", "Save", name, NULL); + else { + /* + * if we got this far and the function is Layout, then + * we really needed it to be a LayoutAs. Otherwise + * ActionSaveTo() will ignore the new file name we + * just obtained. + */ + if (strcasecmp(function, "Layout") == 0) + hid_actionl("SaveTo", "LayoutAs", name, NULL); + else + hid_actionl("SaveTo", function, name, NULL); + } + XtFree(name); + + return 0; } /* ------------------------------------------------------------ */ @@ -293,102 +273,92 @@ static int log_size = 0; static int pending_newline = 0; -static void -log_clear (Widget w, void *up, void *cbp) +static void log_clear(Widget w, void *up, void *cbp) { - XmTextSetString (log_text, ""); - log_size = 0; - pending_newline = 0; + XmTextSetString(log_text, ""); + log_size = 0; + pending_newline = 0; } -static void -log_dismiss (Widget w, void *up, void *cbp) +static void log_dismiss(Widget w, void *up, void *cbp) { - XtUnmanageChild (log_form); + XtUnmanageChild(log_form); } -void -lesstif_logv (const char *fmt, va_list ap) +void lesstif_logv(const char *fmt, va_list ap) { - gchar *buf, *scan; - if (!mainwind) - { - vprintf (fmt, ap); - return; - } - if (!log_form) - { - Widget clear_button, dismiss_button; + gchar *buf, *scan; + if (!mainwind) { + vprintf(fmt, ap); + return; + } + if (!log_form) { + Widget clear_button, dismiss_button; - n = 0; - stdarg (XmNautoUnmanage, False); - stdarg (XmNwidth, 600); - stdarg (XmNheight, 200); - stdarg (XmNtitle, "PCB Log"); - log_form = XmCreateFormDialog (mainwind, "log", args, n); + n = 0; + stdarg(XmNautoUnmanage, False); + stdarg(XmNwidth, 600); + stdarg(XmNheight, 200); + stdarg(XmNtitle, "PCB Log"); + log_form = XmCreateFormDialog(mainwind, "log", args, n); - n = 0; - stdarg (XmNrightAttachment, XmATTACH_FORM); - stdarg (XmNbottomAttachment, XmATTACH_FORM); - clear_button = XmCreatePushButton (log_form, "clear", args, n); - XtManageChild (clear_button); - XtAddCallback (clear_button, XmNactivateCallback, - (XtCallbackProc) log_clear, 0); + n = 0; + stdarg(XmNrightAttachment, XmATTACH_FORM); + stdarg(XmNbottomAttachment, XmATTACH_FORM); + clear_button = XmCreatePushButton(log_form, "clear", args, n); + XtManageChild(clear_button); + XtAddCallback(clear_button, XmNactivateCallback, (XtCallbackProc) log_clear, 0); - n = 0; - stdarg (XmNrightAttachment, XmATTACH_WIDGET); - stdarg (XmNrightWidget, clear_button); - stdarg (XmNbottomAttachment, XmATTACH_FORM); - dismiss_button = XmCreatePushButton (log_form, "dismiss", args, n); - XtManageChild (dismiss_button); - XtAddCallback (dismiss_button, XmNactivateCallback, - (XtCallbackProc) log_dismiss, 0); + n = 0; + stdarg(XmNrightAttachment, XmATTACH_WIDGET); + stdarg(XmNrightWidget, clear_button); + stdarg(XmNbottomAttachment, XmATTACH_FORM); + dismiss_button = XmCreatePushButton(log_form, "dismiss", args, n); + XtManageChild(dismiss_button); + XtAddCallback(dismiss_button, XmNactivateCallback, (XtCallbackProc) log_dismiss, 0); - n = 0; - stdarg (XmNeditable, False); - stdarg (XmNeditMode, XmMULTI_LINE_EDIT); - stdarg (XmNcursorPositionVisible, True); - stdarg (XmNtopAttachment, XmATTACH_FORM); - stdarg (XmNleftAttachment, XmATTACH_FORM); - stdarg (XmNrightAttachment, XmATTACH_FORM); - stdarg (XmNbottomAttachment, XmATTACH_WIDGET); - stdarg (XmNbottomWidget, clear_button); - log_text = XmCreateScrolledText (log_form, "text", args, n); - XtManageChild (log_text); + n = 0; + stdarg(XmNeditable, False); + stdarg(XmNeditMode, XmMULTI_LINE_EDIT); + stdarg(XmNcursorPositionVisible, True); + stdarg(XmNtopAttachment, XmATTACH_FORM); + stdarg(XmNleftAttachment, XmATTACH_FORM); + stdarg(XmNrightAttachment, XmATTACH_FORM); + stdarg(XmNbottomAttachment, XmATTACH_WIDGET); + stdarg(XmNbottomWidget, clear_button); + log_text = XmCreateScrolledText(log_form, "text", args, n); + XtManageChild(log_text); - XtManageChild (log_form); - } - if (pending_newline) - { - XmTextInsert (log_text, log_size++, "\n"); - pending_newline = 0; - } - buf = pcb_vprintf (fmt, ap); - scan = &buf[strlen (buf) - 1]; - while (scan >= buf && *scan == '\n') - { - pending_newline++; - *scan-- = 0; - } - XmTextInsert (log_text, log_size, buf); - log_size += strlen (buf); + XtManageChild(log_form); + } + if (pending_newline) { + XmTextInsert(log_text, log_size++, "\n"); + pending_newline = 0; + } + buf = pcb_vprintf(fmt, ap); + scan = &buf[strlen(buf) - 1]; + while (scan >= buf && *scan == '\n') { + pending_newline++; + *scan-- = 0; + } + XmTextInsert(log_text, log_size, buf); + log_size += strlen(buf); - scan = strrchr(buf, '\n'); - if (scan) - scan++; - else - scan = buf; - XmTextSetCursorPosition (log_text, log_size - strlen(scan)); - g_free (buf); + scan = strrchr(buf, '\n'); + if (scan) + scan++; + else + scan = buf; + XmTextSetCursorPosition(log_text, log_size - strlen(scan)); + g_free(buf); } -void -lesstif_log (const char *fmt, ...) +void lesstif_log(const char *fmt, ...) { - va_list ap; - va_start (ap, fmt); - lesstif_logv (fmt, ap); - va_end (ap); + va_list ap; + va_start(ap, fmt); + lesstif_logv(fmt, ap); + va_end(ap); } /* ------------------------------------------------------------ */ @@ -396,90 +366,79 @@ static Widget confirm_dialog = 0; static Widget confirm_cancel, confirm_ok, confirm_label; -int -lesstif_confirm_dialog (char *msg, ...) +int lesstif_confirm_dialog(char *msg, ...) { - char *cancelmsg, *okmsg; - va_list ap; - XmString xs; + char *cancelmsg, *okmsg; + va_list ap; + XmString xs; - if (mainwind == 0) - return 1; + if (mainwind == 0) + return 1; - if (confirm_dialog == 0) - { - n = 0; - stdarg (XmNdefaultButtonType, XmDIALOG_OK_BUTTON); - stdarg (XmNtitle, "Confirm"); - confirm_dialog = XmCreateQuestionDialog (mainwind, "confirm", args, n); - XtAddCallback (confirm_dialog, XmNcancelCallback, - (XtCallbackProc) dialog_callback, (XtPointer) 0); - XtAddCallback (confirm_dialog, XmNokCallback, - (XtCallbackProc) dialog_callback, (XtPointer) 1); + if (confirm_dialog == 0) { + n = 0; + stdarg(XmNdefaultButtonType, XmDIALOG_OK_BUTTON); + stdarg(XmNtitle, "Confirm"); + confirm_dialog = XmCreateQuestionDialog(mainwind, "confirm", args, n); + XtAddCallback(confirm_dialog, XmNcancelCallback, (XtCallbackProc) dialog_callback, (XtPointer) 0); + XtAddCallback(confirm_dialog, XmNokCallback, (XtCallbackProc) dialog_callback, (XtPointer) 1); - confirm_cancel = - XmMessageBoxGetChild (confirm_dialog, XmDIALOG_CANCEL_BUTTON); - confirm_ok = XmMessageBoxGetChild (confirm_dialog, XmDIALOG_OK_BUTTON); - confirm_label = - XmMessageBoxGetChild (confirm_dialog, XmDIALOG_MESSAGE_LABEL); - XtUnmanageChild (XmMessageBoxGetChild - (confirm_dialog, XmDIALOG_HELP_BUTTON)); - } + confirm_cancel = XmMessageBoxGetChild(confirm_dialog, XmDIALOG_CANCEL_BUTTON); + confirm_ok = XmMessageBoxGetChild(confirm_dialog, XmDIALOG_OK_BUTTON); + confirm_label = XmMessageBoxGetChild(confirm_dialog, XmDIALOG_MESSAGE_LABEL); + XtUnmanageChild(XmMessageBoxGetChild(confirm_dialog, XmDIALOG_HELP_BUTTON)); + } - va_start (ap, msg); - cancelmsg = va_arg (ap, char *); - okmsg = va_arg (ap, char *); - va_end (ap); + va_start(ap, msg); + cancelmsg = va_arg(ap, char *); + okmsg = va_arg(ap, char *); + va_end(ap); - if (!cancelmsg) - { - cancelmsg = "Cancel"; - okmsg = "Ok"; - } + if (!cancelmsg) { + cancelmsg = "Cancel"; + okmsg = "Ok"; + } - n = 0; - xs = XmStringCreatePCB (cancelmsg); + n = 0; + xs = XmStringCreatePCB(cancelmsg); - if (okmsg) - { - stdarg (XmNcancelLabelString, xs); - xs = XmStringCreatePCB (okmsg); - XtManageChild (confirm_cancel); - } - else - XtUnmanageChild (confirm_cancel); + if (okmsg) { + stdarg(XmNcancelLabelString, xs); + xs = XmStringCreatePCB(okmsg); + XtManageChild(confirm_cancel); + } + else + XtUnmanageChild(confirm_cancel); - stdarg (XmNokLabelString, xs); + stdarg(XmNokLabelString, xs); - xs = XmStringCreatePCB (msg); - stdarg (XmNmessageString, xs); - XtSetValues (confirm_dialog, args, n); + xs = XmStringCreatePCB(msg); + stdarg(XmNmessageString, xs); + XtSetValues(confirm_dialog, args, n); - wait_for_dialog (confirm_dialog); + wait_for_dialog(confirm_dialog); - n = 0; - stdarg (XmNdefaultPosition, False); - XtSetValues (confirm_dialog, args, n); + n = 0; + stdarg(XmNdefaultPosition, False); + XtSetValues(confirm_dialog, args, n); - return ok; + return ok; } -static int -ConfirmAction (int argc, char **argv, Coord x, Coord y) +static int ConfirmAction(int argc, char **argv, Coord x, Coord y) { - int rv = lesstif_confirm_dialog (argc > 0 ? argv[0] : 0, - argc > 1 ? argv[1] : 0, - argc > 2 ? argv[2] : 0, - 0); - return rv; + int rv = lesstif_confirm_dialog(argc > 0 ? argv[0] : 0, + argc > 1 ? argv[1] : 0, + argc > 2 ? argv[2] : 0, + 0); + return rv; } /* ------------------------------------------------------------ */ -int -lesstif_close_confirm_dialog () +int lesstif_close_confirm_dialog() { - return lesstif_confirm_dialog ("OK to lose data ?", NULL); + return lesstif_confirm_dialog("OK to lose data ?", NULL); } /* ------------------------------------------------------------ */ @@ -486,49 +445,45 @@ static Widget report = 0, report_form; -void -lesstif_report_dialog (const char *title, const char *msg) +void lesstif_report_dialog(const char *title, const char *msg) { - if (!report) - { - if (mainwind == 0) - return; + if (!report) { + if (mainwind == 0) + return; - n = 0; - stdarg (XmNautoUnmanage, False); - stdarg (XmNwidth, 600); - stdarg (XmNheight, 200); - stdarg (XmNtitle, title); - report_form = XmCreateFormDialog (mainwind, "report", args, n); + n = 0; + stdarg(XmNautoUnmanage, False); + stdarg(XmNwidth, 600); + stdarg(XmNheight, 200); + stdarg(XmNtitle, title); + report_form = XmCreateFormDialog(mainwind, "report", args, n); - n = 0; - stdarg (XmNeditable, False); - stdarg (XmNeditMode, XmMULTI_LINE_EDIT); - stdarg (XmNcursorPositionVisible, False); - stdarg (XmNtopAttachment, XmATTACH_FORM); - stdarg (XmNleftAttachment, XmATTACH_FORM); - stdarg (XmNrightAttachment, XmATTACH_FORM); - stdarg (XmNbottomAttachment, XmATTACH_FORM); - report = XmCreateScrolledText (report_form, "text", args, n); - XtManageChild (report); - } - n = 0; - stdarg (XmNtitle, title); - XtSetValues (report_form, args, n); - XmTextSetString (report, (char *)msg); + n = 0; + stdarg(XmNeditable, False); + stdarg(XmNeditMode, XmMULTI_LINE_EDIT); + stdarg(XmNcursorPositionVisible, False); + stdarg(XmNtopAttachment, XmATTACH_FORM); + stdarg(XmNleftAttachment, XmATTACH_FORM); + stdarg(XmNrightAttachment, XmATTACH_FORM); + stdarg(XmNbottomAttachment, XmATTACH_FORM); + report = XmCreateScrolledText(report_form, "text", args, n); + XtManageChild(report); + } + n = 0; + stdarg(XmNtitle, title); + XtSetValues(report_form, args, n); + XmTextSetString(report, (char *) msg); - XtManageChild (report_form); + XtManageChild(report_form); } /* ------------------------------------------------------------ */ /* FIXME -- make this a proper file select dialog box */ -char * -lesstif_fileselect (const char *title, const char *descr, - char *default_file, char *default_ext, - const char *history_tag, int flags) +char *lesstif_fileselect(const char *title, const char *descr, + char *default_file, char *default_ext, const char *history_tag, int flags) { - return lesstif_prompt_for (title, default_file); + return lesstif_prompt_for(title, default_file); } /* ------------------------------------------------------------ */ @@ -536,58 +491,53 @@ static Widget prompt_dialog = 0; static Widget prompt_label, prompt_text; -char * -lesstif_prompt_for (const char *msg, const char *default_string) +char *lesstif_prompt_for(const char *msg, const char *default_string) { - char *rv; - XmString xs; - if (prompt_dialog == 0) - { - n = 0; - stdarg (XmNautoUnmanage, False); - stdarg (XmNtitle, "PCB Prompt"); - prompt_dialog = XmCreateFormDialog (mainwind, "prompt", args, n); + char *rv; + XmString xs; + if (prompt_dialog == 0) { + n = 0; + stdarg(XmNautoUnmanage, False); + stdarg(XmNtitle, "PCB Prompt"); + prompt_dialog = XmCreateFormDialog(mainwind, "prompt", args, n); - n = 0; - stdarg (XmNtopAttachment, XmATTACH_FORM); - stdarg (XmNleftAttachment, XmATTACH_FORM); - stdarg (XmNrightAttachment, XmATTACH_FORM); - stdarg (XmNalignment, XmALIGNMENT_BEGINNING); - prompt_label = XmCreateLabel (prompt_dialog, "label", args, n); - XtManageChild (prompt_label); + n = 0; + stdarg(XmNtopAttachment, XmATTACH_FORM); + stdarg(XmNleftAttachment, XmATTACH_FORM); + stdarg(XmNrightAttachment, XmATTACH_FORM); + stdarg(XmNalignment, XmALIGNMENT_BEGINNING); + prompt_label = XmCreateLabel(prompt_dialog, "label", args, n); + XtManageChild(prompt_label); - n = 0; - stdarg (XmNtopAttachment, XmATTACH_WIDGET); - stdarg (XmNtopWidget, prompt_label); - stdarg (XmNbottomAttachment, XmATTACH_WIDGET); - stdarg (XmNleftAttachment, XmATTACH_FORM); - stdarg (XmNrightAttachment, XmATTACH_FORM); - stdarg (XmNeditable, True); - prompt_text = XmCreateText (prompt_dialog, "text", args, n); - XtManageChild (prompt_text); - XtAddCallback (prompt_text, XmNactivateCallback, - (XtCallbackProc) dialog_callback, (XtPointer) 1); - } - if (!default_string) - default_string = ""; - if (!msg) - msg = "Enter text:"; - n = 0; - xs = XmStringCreatePCB ((char *)msg); - stdarg (XmNlabelString, xs); - XtSetValues (prompt_label, args, n); - XmTextSetString (prompt_text, (char *)default_string); - XmTextSetCursorPosition (prompt_text, strlen (default_string)); - wait_for_dialog (prompt_dialog); - rv = XmTextGetString (prompt_text); - return rv; + n = 0; + stdarg(XmNtopAttachment, XmATTACH_WIDGET); + stdarg(XmNtopWidget, prompt_label); + stdarg(XmNbottomAttachment, XmATTACH_WIDGET); + stdarg(XmNleftAttachment, XmATTACH_FORM); + stdarg(XmNrightAttachment, XmATTACH_FORM); + stdarg(XmNeditable, True); + prompt_text = XmCreateText(prompt_dialog, "text", args, n); + XtManageChild(prompt_text); + XtAddCallback(prompt_text, XmNactivateCallback, (XtCallbackProc) dialog_callback, (XtPointer) 1); + } + if (!default_string) + default_string = ""; + if (!msg) + msg = "Enter text:"; + n = 0; + xs = XmStringCreatePCB((char *) msg); + stdarg(XmNlabelString, xs); + XtSetValues(prompt_label, args, n); + XmTextSetString(prompt_text, (char *) default_string); + XmTextSetCursorPosition(prompt_text, strlen(default_string)); + wait_for_dialog(prompt_dialog); + rv = XmTextGetString(prompt_text); + return rv; } -static const char promptfor_syntax[] = -"PromptFor([message[,default]])"; +static const char promptfor_syntax[] = "PromptFor([message[,default]])"; -static const char promptfor_help[] = -"Prompt for a response."; +static const char promptfor_help[] = "Prompt for a response."; /* %start-doc actions PromptFor @@ -598,277 +548,259 @@ %end-doc */ -static int -PromptFor (int argc, char **argv, Coord x, Coord y) +static int PromptFor(int argc, char **argv, Coord x, Coord y) { - char *rv = lesstif_prompt_for (argc > 0 ? argv[0] : 0, - argc > 1 ? argv[1] : 0); - printf ("rv = `%s'\n", rv); - return 0; + char *rv = lesstif_prompt_for(argc > 0 ? argv[0] : 0, + argc > 1 ? argv[1] : 0); + printf("rv = `%s'\n", rv); + return 0; } /* ------------------------------------------------------------ */ -static Widget -create_form_ok_dialog (char *name, int ok) +static Widget create_form_ok_dialog(char *name, int ok) { - Widget dialog, topform; - n = 0; - dialog = XmCreateQuestionDialog (mainwind, name, args, n); + Widget dialog, topform; + n = 0; + dialog = XmCreateQuestionDialog(mainwind, name, args, n); - XtUnmanageChild (XmMessageBoxGetChild (dialog, XmDIALOG_SYMBOL_LABEL)); - XtUnmanageChild (XmMessageBoxGetChild (dialog, XmDIALOG_MESSAGE_LABEL)); - XtUnmanageChild (XmMessageBoxGetChild (dialog, XmDIALOG_HELP_BUTTON)); - XtAddCallback (dialog, XmNcancelCallback, (XtCallbackProc) dialog_callback, - (XtPointer) 0); - if (ok) - XtAddCallback (dialog, XmNokCallback, (XtCallbackProc) dialog_callback, - (XtPointer) 1); - else - XtUnmanageChild (XmMessageBoxGetChild (dialog, XmDIALOG_OK_BUTTON)); + XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_SYMBOL_LABEL)); + XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_MESSAGE_LABEL)); + XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON)); + XtAddCallback(dialog, XmNcancelCallback, (XtCallbackProc) dialog_callback, (XtPointer) 0); + if (ok) + XtAddCallback(dialog, XmNokCallback, (XtCallbackProc) dialog_callback, (XtPointer) 1); + else + XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_OK_BUTTON)); - n = 0; - topform = XmCreateForm (dialog, "attributes", args, n); - XtManageChild (topform); - return topform; + n = 0; + topform = XmCreateForm(dialog, "attributes", args, n); + XtManageChild(topform); + return topform; } -int -lesstif_attribute_dialog (HID_Attribute * attrs, - int n_attrs, HID_Attr_Val * results, - const char * title, const char * descr) +int lesstif_attribute_dialog(HID_Attribute * attrs, int n_attrs, HID_Attr_Val * results, const char *title, const char *descr) { - Widget dialog, topform, lform, form; - Widget *wl; - int i, rv; - static XmString empty = 0; - int actual_nattrs = 0; - int attrcount = 0; + Widget dialog, topform, lform, form; + Widget *wl; + int i, rv; + static XmString empty = 0; + int actual_nattrs = 0; + int attrcount = 0; - if (!empty) - empty = XmStringCreatePCB (" "); + if (!empty) + empty = XmStringCreatePCB(" "); - for (i = 0; i < n_attrs; i++) - { - if (attrs[i].help_text != ATTR_UNDOCUMENTED) - actual_nattrs ++; - results[i] = attrs[i].default_val; - if (results[i].str_value) - results[i].str_value = strdup (results[i].str_value); - } + for (i = 0; i < n_attrs; i++) { + if (attrs[i].help_text != ATTR_UNDOCUMENTED) + actual_nattrs++; + results[i] = attrs[i].default_val; + if (results[i].str_value) + results[i].str_value = strdup(results[i].str_value); + } - wl = (Widget *) malloc (n_attrs * sizeof (Widget)); + wl = (Widget *) malloc(n_attrs * sizeof(Widget)); - topform = create_form_ok_dialog ((char *)title, 1); - dialog = XtParent (topform); + topform = create_form_ok_dialog((char *) title, 1); + dialog = XtParent(topform); - n = 0; - stdarg (XmNfractionBase, n_attrs); - XtSetValues (topform, args, n); + n = 0; + stdarg(XmNfractionBase, n_attrs); + XtSetValues(topform, args, n); - n = 0; - stdarg (XmNtopAttachment, XmATTACH_FORM); - stdarg (XmNbottomAttachment, XmATTACH_FORM); - stdarg (XmNleftAttachment, XmATTACH_FORM); - stdarg (XmNfractionBase, actual_nattrs); - lform = XmCreateForm (topform, "attributes", args, n); - XtManageChild (lform); + n = 0; + stdarg(XmNtopAttachment, XmATTACH_FORM); + stdarg(XmNbottomAttachment, XmATTACH_FORM); + stdarg(XmNleftAttachment, XmATTACH_FORM); + stdarg(XmNfractionBase, actual_nattrs); + lform = XmCreateForm(topform, "attributes", args, n); + XtManageChild(lform); - n = 0; - stdarg (XmNtopAttachment, XmATTACH_FORM); - stdarg (XmNbottomAttachment, XmATTACH_FORM); - stdarg (XmNleftAttachment, XmATTACH_WIDGET); - stdarg (XmNleftWidget, lform); - stdarg (XmNrightAttachment, XmATTACH_FORM); - stdarg (XmNfractionBase, actual_nattrs); - form = XmCreateForm (topform, "attributes", args, n); - XtManageChild (form); + n = 0; + stdarg(XmNtopAttachment, XmATTACH_FORM); + stdarg(XmNbottomAttachment, XmATTACH_FORM); + stdarg(XmNleftAttachment, XmATTACH_WIDGET); + stdarg(XmNleftWidget, lform); + stdarg(XmNrightAttachment, XmATTACH_FORM); + stdarg(XmNfractionBase, actual_nattrs); + form = XmCreateForm(topform, "attributes", args, n); + XtManageChild(form); - attrcount = -1; - for (i = 0; i < n_attrs; i++) - { - Widget w; + attrcount = -1; + for (i = 0; i < n_attrs; i++) { + Widget w; - if (attrs[i].help_text == ATTR_UNDOCUMENTED) - continue; - attrcount ++; + if (attrs[i].help_text == ATTR_UNDOCUMENTED) + continue; + attrcount++; - n = 0; - stdarg (XmNleftAttachment, XmATTACH_FORM); - stdarg (XmNrightAttachment, XmATTACH_FORM); - stdarg (XmNtopAttachment, XmATTACH_POSITION); - stdarg (XmNtopPosition, attrcount); - stdarg (XmNbottomAttachment, XmATTACH_POSITION); - stdarg (XmNbottomPosition, attrcount + 1); - stdarg (XmNalignment, XmALIGNMENT_END); - w = XmCreateLabel (lform, attrs[i].name, args, n); - XtManageChild (w); - } + n = 0; + stdarg(XmNleftAttachment, XmATTACH_FORM); + stdarg(XmNrightAttachment, XmATTACH_FORM); + stdarg(XmNtopAttachment, XmATTACH_POSITION); + stdarg(XmNtopPosition, attrcount); + stdarg(XmNbottomAttachment, XmATTACH_POSITION); + stdarg(XmNbottomPosition, attrcount + 1); + stdarg(XmNalignment, XmALIGNMENT_END); + w = XmCreateLabel(lform, attrs[i].name, args, n); + XtManageChild(w); + } - attrcount = -1; - for (i = 0; i < n_attrs; i++) - { - static char buf[30]; - n = 0; + attrcount = -1; + for (i = 0; i < n_attrs; i++) { + static char buf[30]; + n = 0; - if (attrs[i].help_text == ATTR_UNDOCUMENTED) - continue; - attrcount ++; + if (attrs[i].help_text == ATTR_UNDOCUMENTED) + continue; + attrcount++; - stdarg (XmNleftAttachment, XmATTACH_FORM); - stdarg (XmNrightAttachment, XmATTACH_FORM); - stdarg (XmNtopAttachment, XmATTACH_POSITION); - stdarg (XmNtopPosition, attrcount); - stdarg (XmNbottomAttachment, XmATTACH_POSITION); - stdarg (XmNbottomPosition, attrcount + 1); - stdarg (XmNalignment, XmALIGNMENT_END); + stdarg(XmNleftAttachment, XmATTACH_FORM); + stdarg(XmNrightAttachment, XmATTACH_FORM); + stdarg(XmNtopAttachment, XmATTACH_POSITION); + stdarg(XmNtopPosition, attrcount); + stdarg(XmNbottomAttachment, XmATTACH_POSITION); + stdarg(XmNbottomPosition, attrcount + 1); + stdarg(XmNalignment, XmALIGNMENT_END); - switch (attrs[i].type) - { - case HID_Label: - stdarg (XmNlabelString, empty); - wl[i] = XmCreateLabel (form, attrs[i].name, args, n); - break; - case HID_Boolean: - stdarg (XmNlabelString, empty); - stdarg (XmNset, results[i].int_value); - wl[i] = XmCreateToggleButton (form, attrs[i].name, args, n); - break; - case HID_String: - stdarg (XmNcolumns, 40); - stdarg (XmNresizeWidth, True); - stdarg (XmNvalue, results[i].str_value); - wl[i] = XmCreateTextField (form, attrs[i].name, args, n); - break; - case HID_Integer: - stdarg (XmNcolumns, 13); - stdarg (XmNresizeWidth, True); - sprintf (buf, "%d", results[i].int_value); - stdarg (XmNvalue, buf); - wl[i] = XmCreateTextField (form, attrs[i].name, args, n); - break; - case HID_Coord: - stdarg (XmNcolumns, 13); - stdarg (XmNresizeWidth, True); - pcb_sprintf (buf, "%$mS", results[i].coord_value); - stdarg (XmNvalue, buf); - wl[i] = XmCreateTextField (form, attrs[i].name, args, n); - break; - case HID_Real: - stdarg (XmNcolumns, 16); - stdarg (XmNresizeWidth, True); - sprintf (buf, "%g", results[i].real_value); - stdarg (XmNvalue, buf); - wl[i] = XmCreateTextField (form, attrs[i].name, args, n); - break; - case HID_Enum: - { - static XmString empty = 0; - Widget submenu, default_button=0; - int sn = n; + switch (attrs[i].type) { + case HID_Label: + stdarg(XmNlabelString, empty); + wl[i] = XmCreateLabel(form, attrs[i].name, args, n); + break; + case HID_Boolean: + stdarg(XmNlabelString, empty); + stdarg(XmNset, results[i].int_value); + wl[i] = XmCreateToggleButton(form, attrs[i].name, args, n); + break; + case HID_String: + stdarg(XmNcolumns, 40); + stdarg(XmNresizeWidth, True); + stdarg(XmNvalue, results[i].str_value); + wl[i] = XmCreateTextField(form, attrs[i].name, args, n); + break; + case HID_Integer: + stdarg(XmNcolumns, 13); + stdarg(XmNresizeWidth, True); + sprintf(buf, "%d", results[i].int_value); + stdarg(XmNvalue, buf); + wl[i] = XmCreateTextField(form, attrs[i].name, args, n); + break; + case HID_Coord: + stdarg(XmNcolumns, 13); + stdarg(XmNresizeWidth, True); + pcb_sprintf(buf, "%$mS", results[i].coord_value); + stdarg(XmNvalue, buf); + wl[i] = XmCreateTextField(form, attrs[i].name, args, n); + break; + case HID_Real: + stdarg(XmNcolumns, 16); + stdarg(XmNresizeWidth, True); + sprintf(buf, "%g", results[i].real_value); + stdarg(XmNvalue, buf); + wl[i] = XmCreateTextField(form, attrs[i].name, args, n); + break; + case HID_Enum: + { + static XmString empty = 0; + Widget submenu, default_button = 0; + int sn = n; - if (empty == 0) - empty = XmStringCreatePCB (""); + if (empty == 0) + empty = XmStringCreatePCB(""); - submenu = XmCreatePulldownMenu (form, attrs[i].name, args+sn, n-sn); + submenu = XmCreatePulldownMenu(form, attrs[i].name, args + sn, n - sn); - n = sn; - stdarg (XmNlabelString, empty); - stdarg (XmNsubMenuId, submenu); - wl[i] = XmCreateOptionMenu (form, attrs[i].name, args, n); + n = sn; + stdarg(XmNlabelString, empty); + stdarg(XmNsubMenuId, submenu); + wl[i] = XmCreateOptionMenu(form, attrs[i].name, args, n); - for (sn=0; attrs[i].enumerations[sn]; sn++) - { - Widget btn; - XmString label; - n = 0; - label = XmStringCreatePCB ((char *)attrs[i].enumerations[sn]); - stdarg (XmNuserData, & attrs[i].enumerations[sn]); - stdarg (XmNlabelString, label); - btn = XmCreatePushButton (submenu, "menubutton", args, n); - XtManageChild (btn); - XmStringFree (label); - if (sn == attrs[i].default_val.int_value) - default_button = btn; - } - if (default_button) - { - n = 0; - stdarg (XmNmenuHistory, default_button); - XtSetValues (wl[i], args, n); - } - } - break; - default: - wl[i] = XmCreateLabel (form, "UNIMPLEMENTED", args, n); - break; + for (sn = 0; attrs[i].enumerations[sn]; sn++) { + Widget btn; + XmString label; + n = 0; + label = XmStringCreatePCB((char *) attrs[i].enumerations[sn]); + stdarg(XmNuserData, &attrs[i].enumerations[sn]); + stdarg(XmNlabelString, label); + btn = XmCreatePushButton(submenu, "menubutton", args, n); + XtManageChild(btn); + XmStringFree(label); + if (sn == attrs[i].default_val.int_value) + default_button = btn; + } + if (default_button) { + n = 0; + stdarg(XmNmenuHistory, default_button); + XtSetValues(wl[i], args, n); + } + } + break; + default: + wl[i] = XmCreateLabel(form, "UNIMPLEMENTED", args, n); + break; + } + + XtManageChild(wl[i]); } - XtManageChild (wl[i]); - } + rv = wait_for_dialog(dialog); - rv = wait_for_dialog (dialog); + for (i = 0; i < n_attrs; i++) { + char *cp; - for (i = 0; i < n_attrs; i++) - { - char *cp; + if (attrs[i].help_text == ATTR_UNDOCUMENTED) + continue; - if (attrs[i].help_text == ATTR_UNDOCUMENTED) - continue; + switch (attrs[i].type) { + case HID_Boolean: + results[i].int_value = XmToggleButtonGetState(wl[i]); + break; + case HID_String: + results[i].str_value = XmTextGetString(wl[i]); + break; + case HID_Integer: + cp = XmTextGetString(wl[i]); + sscanf(cp, "%d", &results[i].int_value); + break; + case HID_Coord: + cp = XmTextGetString(wl[i]); + results[i].coord_value = GetValue(cp, NULL, NULL); + break; + case HID_Real: + cp = XmTextGetString(wl[i]); + sscanf(cp, "%lg", &results[i].real_value); + break; + case HID_Enum: + { + const char **uptr; + Widget btn; - switch (attrs[i].type) - { - case HID_Boolean: - results[i].int_value = XmToggleButtonGetState (wl[i]); - break; - case HID_String: - results[i].str_value = XmTextGetString (wl[i]); - break; - case HID_Integer: - cp = XmTextGetString (wl[i]); - sscanf (cp, "%d", &results[i].int_value); - break; - case HID_Coord: - cp = XmTextGetString (wl[i]); - results[i].coord_value = GetValue (cp, NULL, NULL); - break; - case HID_Real: - cp = XmTextGetString (wl[i]); - sscanf (cp, "%lg", &results[i].real_value); - break; - case HID_Enum: - { - const char **uptr; - Widget btn; - - n = 0; - stdarg (XmNmenuHistory, &btn); - XtGetValues (wl[i], args, n); - n = 0; - stdarg (XmNuserData, &uptr); - XtGetValues (btn, args, n); - results[i].int_value = uptr - attrs[i].enumerations; - } - break; - default: - break; + n = 0; + stdarg(XmNmenuHistory, &btn); + XtGetValues(wl[i], args, n); + n = 0; + stdarg(XmNuserData, &uptr); + XtGetValues(btn, args, n); + results[i].int_value = uptr - attrs[i].enumerations; + } + break; + default: + break; + } } - } - free (wl); - XtDestroyWidget (dialog); + free(wl); + XtDestroyWidget(dialog); - return rv ? 0 : 1; + return rv ? 0 : 1; } /* ------------------------------------------------------------ */ -static const char dowindows_syntax[] = -"DoWindows(1|2|3|4)\n" -"DoWindows(Layout|Library|Log|Netlist)"; +static const char dowindows_syntax[] = "DoWindows(1|2|3|4)\n" "DoWindows(Layout|Library|Log|Netlist)"; -static const char dowindows_help[] = -"Open various GUI windows."; +static const char dowindows_help[] = "Open various GUI windows."; /* %start-doc actions DoWindows @@ -895,41 +827,33 @@ %end-doc */ -static int -DoWindows (int argc, char **argv, Coord x, Coord y) +static int DoWindows(int argc, char **argv, Coord x, Coord y) { - const char *a = argc == 1 ? argv[0] : ""; - if (strcmp (a, "1") == 0 || strcasecmp (a, "Layout") == 0) - { - } - else if (strcmp (a, "2") == 0 || strcasecmp (a, "Library") == 0) - { - lesstif_show_library (); - } - else if (strcmp (a, "3") == 0 || strcasecmp (a, "Log") == 0) - { - if (log_form == 0) - lesstif_log (""); - XtManageChild (log_form); - } - else if (strcmp (a, "4") == 0 || strcasecmp (a, "Netlist") == 0) - { - lesstif_show_netlist (); - } - else - { - lesstif_log ("Usage: DoWindows(1|2|3|4|Layout|Library|Log|Netlist)"); - return 1; - } - return 0; + const char *a = argc == 1 ? argv[0] : ""; + if (strcmp(a, "1") == 0 || strcasecmp(a, "Layout") == 0) { + } + else if (strcmp(a, "2") == 0 || strcasecmp(a, "Library") == 0) { + lesstif_show_library(); + } + else if (strcmp(a, "3") == 0 || strcasecmp(a, "Log") == 0) { + if (log_form == 0) + lesstif_log(""); + XtManageChild(log_form); + } + else if (strcmp(a, "4") == 0 || strcasecmp(a, "Netlist") == 0) { + lesstif_show_netlist(); + } + else { + lesstif_log("Usage: DoWindows(1|2|3|4|Layout|Library|Log|Netlist)"); + return 1; + } + return 0; } /* ------------------------------------------------------------ */ -static const char about_syntax[] = -"About()"; +static const char about_syntax[] = "About()"; -static const char about_help[] = -"Tell the user about this version of PCB."; +static const char about_help[] = "Tell the user about this version of PCB."; /* %start-doc actions About @@ -939,31 +863,27 @@ %end-doc */ -static int -About (int argc, char **argv, Coord x, Coord y) +static int About(int argc, char **argv, Coord x, Coord y) { - static Widget about = 0; - if (!about) - { - Cardinal n = 0; - XmString xs = XmStringCreatePCB (GetInfoString ()); - stdarg (XmNmessageString, xs); - stdarg (XmNtitle, "About PCB"); - about = XmCreateInformationDialog (mainwind, "about", args, n); - XtUnmanageChild (XmMessageBoxGetChild (about, XmDIALOG_CANCEL_BUTTON)); - XtUnmanageChild (XmMessageBoxGetChild (about, XmDIALOG_HELP_BUTTON)); - } - wait_for_dialog (about); - return 0; + static Widget about = 0; + if (!about) { + Cardinal n = 0; + XmString xs = XmStringCreatePCB(GetInfoString()); + stdarg(XmNmessageString, xs); + stdarg(XmNtitle, "About PCB"); + about = XmCreateInformationDialog(mainwind, "about", args, n); + XtUnmanageChild(XmMessageBoxGetChild(about, XmDIALOG_CANCEL_BUTTON)); + XtUnmanageChild(XmMessageBoxGetChild(about, XmDIALOG_HELP_BUTTON)); + } + wait_for_dialog(about); + return 0; } /* ------------------------------------------------------------ */ -static const char print_syntax[] = -"Print()"; +static const char print_syntax[] = "Print()"; -static const char print_help[] = -"Print the layout."; +static const char print_help[] = "Print the layout."; /* %start-doc actions Print @@ -972,48 +892,43 @@ %end-doc */ -static int -Print (int argc, char **argv, Coord x, Coord y) +static int Print(int argc, char **argv, Coord x, Coord y) { - HID_Attribute *opts; - HID *printer; - HID_Attr_Val *vals; - int n; + HID_Attribute *opts; + HID *printer; + HID_Attr_Val *vals; + int n; - printer = hid_find_printer (); - if (!printer) - { - lesstif_confirm_dialog ("No printer?", "Oh well", 0); - return 1; - } - opts = printer->get_export_options (&n); - vals = (HID_Attr_Val *) calloc (n, sizeof (HID_Attr_Val)); - if (lesstif_attribute_dialog (opts, n, vals, "Print", "")) - { - free (vals); - return 1; - } - printer->do_export (vals); - free (vals); - return 0; + printer = hid_find_printer(); + if (!printer) { + lesstif_confirm_dialog("No printer?", "Oh well", 0); + return 1; + } + opts = printer->get_export_options(&n); + vals = (HID_Attr_Val *) calloc(n, sizeof(HID_Attr_Val)); + if (lesstif_attribute_dialog(opts, n, vals, "Print", "")) { + free(vals); + return 1; + } + printer->do_export(vals); + free(vals); + return 0; } -static HID_Attribute -printer_calibrate_attrs[] = { - {"Enter Values here:", "", - HID_Label, 0, 0, {0, 0, 0}, 0, 0}, - {"x-calibration", "X scale for calibrating your printer", - HID_Real, 0.5, 25, {0, 0, 1.00}, 0, 0}, - {"y-calibration", "Y scale for calibrating your printer", - HID_Real, 0.5, 25, {0, 0, 1.00}, 0, 0} +static HID_Attribute printer_calibrate_attrs[] = { + {"Enter Values here:", "", + HID_Label, 0, 0, {0, 0, 0}, 0, 0}, + {"x-calibration", "X scale for calibrating your printer", + HID_Real, 0.5, 25, {0, 0, 1.00}, 0, 0}, + {"y-calibration", "Y scale for calibrating your printer", + HID_Real, 0.5, 25, {0, 0, 1.00}, 0, 0} }; + static HID_Attr_Val printer_calibrate_values[3]; -static const char printcalibrate_syntax[] = -"PrintCalibrate()"; +static const char printcalibrate_syntax[] = "PrintCalibrate()"; -static const char printcalibrate_help[] = -"Calibrate the printer."; +static const char printcalibrate_help[] = "Calibrate the printer."; /* %start-doc actions PrintCalibrate @@ -1022,25 +937,21 @@ %end-doc */ -static int -PrintCalibrate (int argc, char **argv, Coord x, Coord y) +static int PrintCalibrate(int argc, char **argv, Coord x, Coord y) { - HID *printer = hid_find_printer (); - printer->calibrate (0.0, 0.0); - if (gui->attribute_dialog (printer_calibrate_attrs, 3, - printer_calibrate_values, - "Printer Calibration Values", "Enter calibration values for your printer")) - return 1; - printer->calibrate (printer_calibrate_values[1].real_value, - printer_calibrate_values[2].real_value); - return 0; + HID *printer = hid_find_printer(); + printer->calibrate(0.0, 0.0); + if (gui->attribute_dialog(printer_calibrate_attrs, 3, + printer_calibrate_values, + "Printer Calibration Values", "Enter calibration values for your printer")) + return 1; + printer->calibrate(printer_calibrate_values[1].real_value, printer_calibrate_values[2].real_value); + return 0; } -static const char export_syntax[] = -"Export()"; +static const char export_syntax[] = "Export()"; -static const char export_help[] = -"Export the layout."; +static const char export_help[] = "Export the layout."; /* %start-doc actions Export @@ -1049,184 +960,165 @@ %end-doc */ -static int -Export (int argc, char **argv, Coord x, Coord y) +static int Export(int argc, char **argv, Coord x, Coord y) { - static Widget selector = 0; - HID_Attribute *opts; - HID *printer, **hids; - HID_Attr_Val *vals; - int n, i; - Widget prev = 0; - Widget w; + static Widget selector = 0; + HID_Attribute *opts; + HID *printer, **hids; + HID_Attr_Val *vals; + int n, i; + Widget prev = 0; + Widget w; - hids = hid_enumerate (); + hids = hid_enumerate(); - if (!selector) - { - n = 0; - stdarg (XmNtitle, "Export HIDs"); - selector = create_form_ok_dialog ("export", 0); - for (i = 0; hids[i]; i++) - { - if (hids[i]->exporter) - { - n = 0; - if (prev) - { - stdarg (XmNtopAttachment, XmATTACH_WIDGET); - stdarg (XmNtopWidget, prev); + if (!selector) { + n = 0; + stdarg(XmNtitle, "Export HIDs"); + selector = create_form_ok_dialog("export", 0); + for (i = 0; hids[i]; i++) { + if (hids[i]->exporter) { + n = 0; + if (prev) { + stdarg(XmNtopAttachment, XmATTACH_WIDGET); + stdarg(XmNtopWidget, prev); + } + else { + stdarg(XmNtopAttachment, XmATTACH_FORM); + } + stdarg(XmNrightAttachment, XmATTACH_FORM); + stdarg(XmNleftAttachment, XmATTACH_FORM); + w = XmCreatePushButton(selector, (char *) hids[i]->name, args, n); + XtManageChild(w); + XtAddCallback(w, XmNactivateCallback, (XtCallbackProc) dialog_callback, (XtPointer) ((size_t) i + 1)); + prev = w; + } } - else - { - stdarg (XmNtopAttachment, XmATTACH_FORM); - } - stdarg (XmNrightAttachment, XmATTACH_FORM); - stdarg (XmNleftAttachment, XmATTACH_FORM); - w = - XmCreatePushButton (selector, (char *) hids[i]->name, args, - n); - XtManageChild (w); - XtAddCallback (w, XmNactivateCallback, - (XtCallbackProc) dialog_callback, - (XtPointer) ((size_t) i + 1)); - prev = w; - } + selector = XtParent(selector); } - selector = XtParent (selector); - } - i = wait_for_dialog (selector); + i = wait_for_dialog(selector); - if (i <= 0) - return 1; - printer = hids[i - 1]; + if (i <= 0) + return 1; + printer = hids[i - 1]; - exporter = printer; + exporter = printer; - opts = printer->get_export_options (&n); - vals = (HID_Attr_Val *) calloc (n, sizeof (HID_Attr_Val)); - if (lesstif_attribute_dialog (opts, n, vals, "Export", NULL)) - { - free (vals); - return 1; - } - printer->do_export (vals); - free (vals); - exporter = NULL; - return 0; + opts = printer->get_export_options(&n); + vals = (HID_Attr_Val *) calloc(n, sizeof(HID_Attr_Val)); + if (lesstif_attribute_dialog(opts, n, vals, "Export", NULL)) { + free(vals); + return 1; + } + printer->do_export(vals); + free(vals); + exporter = NULL; + return 0; } /* ------------------------------------------------------------ */ static Widget sizes_dialog = 0; -static Widget sz_pcb_w, sz_pcb_h, sz_bloat, sz_shrink, sz_drc_wid, sz_drc_slk, - sz_drc_drill, sz_drc_ring; +static Widget sz_pcb_w, sz_pcb_h, sz_bloat, sz_shrink, sz_drc_wid, sz_drc_slk, sz_drc_drill, sz_drc_ring; static Widget sz_text; static Widget sz_set, sz_reset, sz_units; -static int -sz_str2val (Widget w, bool pcbu) +static int sz_str2val(Widget w, bool pcbu) { - char *buf = XmTextGetString (w); - if (!pcbu) - return strtol (buf, NULL, 0); - return GetValueEx (buf, NULL, NULL, NULL, Settings.grid_unit->suffix); + char *buf = XmTextGetString(w); + if (!pcbu) + return strtol(buf, NULL, 0); + return GetValueEx(buf, NULL, NULL, NULL, Settings.grid_unit->suffix); } -static void -sz_val2str (Widget w, Coord u, int pcbu) +static void sz_val2str(Widget w, Coord u, int pcbu) { - static char buf[40]; - if (pcbu) - pcb_sprintf (buf, "%m+%.2mS", Settings.grid_unit->allow, u); - else - pcb_sprintf (buf, "%#mS %%", u); - XmTextSetString (w, buf); + static char buf[40]; + if (pcbu) + pcb_sprintf(buf, "%m+%.2mS", Settings.grid_unit->allow, u); + else + pcb_sprintf(buf, "%#mS %%", u); + XmTextSetString(w, buf); } -static void -sizes_set () +static void sizes_set() { - PCB->MaxWidth = sz_str2val (sz_pcb_w, 1); - PCB->MaxHeight = sz_str2val (sz_pcb_h, 1); - PCB->Bloat = sz_str2val (sz_bloat, 1); - PCB->Shrink = sz_str2val (sz_shrink, 1); - PCB->minWid = sz_str2val (sz_drc_wid, 1); - PCB->minSlk = sz_str2val (sz_drc_slk, 1); - PCB->minDrill = sz_str2val (sz_drc_drill, 1); - PCB->minRing = sz_str2val (sz_drc_ring, 1); - Settings.TextScale = sz_str2val (sz_text, 0); + PCB->MaxWidth = sz_str2val(sz_pcb_w, 1); + PCB->MaxHeight = sz_str2val(sz_pcb_h, 1); + PCB->Bloat = sz_str2val(sz_bloat, 1); + PCB->Shrink = sz_str2val(sz_shrink, 1); + PCB->minWid = sz_str2val(sz_drc_wid, 1); + PCB->minSlk = sz_str2val(sz_drc_slk, 1); + PCB->minDrill = sz_str2val(sz_drc_drill, 1); + PCB->minRing = sz_str2val(sz_drc_ring, 1); + Settings.TextScale = sz_str2val(sz_text, 0); - Settings.Bloat = PCB->Bloat; - Settings.Shrink = PCB->Shrink; - Settings.minWid = PCB->minWid; - Settings.minSlk = PCB->minSlk; - Settings.minDrill = PCB->minDrill; - Settings.minRing = PCB->minRing; + Settings.Bloat = PCB->Bloat; + Settings.Shrink = PCB->Shrink; + Settings.minWid = PCB->minWid; + Settings.minSlk = PCB->minSlk; + Settings.minDrill = PCB->minDrill; + Settings.minRing = PCB->minRing; - SetCrosshairRange (0, 0, PCB->MaxWidth, PCB->MaxHeight); - lesstif_pan_fixup (); + SetCrosshairRange(0, 0, PCB->MaxWidth, PCB->MaxHeight); + lesstif_pan_fixup(); } -void -lesstif_sizes_reset () +void lesstif_sizes_reset() { - char *ls; - if (!sizes_dialog) - return; - sz_val2str (sz_pcb_w, PCB->MaxWidth, 1); - sz_val2str (sz_pcb_h, PCB->MaxHeight, 1); - sz_val2str (sz_bloat, PCB->Bloat, 1); - sz_val2str (sz_shrink, PCB->Shrink, 1); - sz_val2str (sz_drc_wid, PCB->minWid, 1); - sz_val2str (sz_drc_slk, PCB->minSlk, 1); - sz_val2str (sz_drc_drill, PCB->minDrill, 1); - sz_val2str (sz_drc_ring, PCB->minRing, 1); - sz_val2str (sz_text, Settings.TextScale, 0); + char *ls; + if (!sizes_dialog) + return; + sz_val2str(sz_pcb_w, PCB->MaxWidth, 1); + sz_val2str(sz_pcb_h, PCB->MaxHeight, 1); + sz_val2str(sz_bloat, PCB->Bloat, 1); + sz_val2str(sz_shrink, PCB->Shrink, 1); + sz_val2str(sz_drc_wid, PCB->minWid, 1); + sz_val2str(sz_drc_slk, PCB->minSlk, 1); + sz_val2str(sz_drc_drill, PCB->minDrill, 1); + sz_val2str(sz_drc_ring, PCB->minRing, 1); + sz_val2str(sz_text, Settings.TextScale, 0); - ls = g_strdup_printf (_("Units are %s."), Settings.grid_unit->in_suffix); - n = 0; - stdarg (XmNlabelString, XmStringCreatePCB (ls)); - XtSetValues (sz_units, args, n); - g_free (ls); + ls = g_strdup_printf(_("Units are %s."), Settings.grid_unit->in_suffix); + n = 0; + stdarg(XmNlabelString, XmStringCreatePCB(ls)); + XtSetValues(sz_units, args, n); + g_free(ls); } -static Widget -size_field (Widget parent, char *label, int posn) +static Widget size_field(Widget parent, char *label, int posn) { - Widget w, l; - n = 0; - stdarg (XmNrightAttachment, XmATTACH_FORM); - stdarg (XmNtopAttachment, XmATTACH_POSITION); - stdarg (XmNtopPosition, posn); - stdarg (XmNbottomAttachment, XmATTACH_POSITION); - stdarg (XmNbottomPosition, posn + 1); - stdarg (XmNcolumns, 10); - w = XmCreateTextField (parent, "field", args, n); - XtManageChild (w); + Widget w, l; + n = 0; + stdarg(XmNrightAttachment, XmATTACH_FORM); + stdarg(XmNtopAttachment, XmATTACH_POSITION); + stdarg(XmNtopPosition, posn); + stdarg(XmNbottomAttachment, XmATTACH_POSITION); + stdarg(XmNbottomPosition, posn + 1); + stdarg(XmNcolumns, 10); + w = XmCreateTextField(parent, "field", args, n); + XtManageChild(w); - n = 0; - stdarg (XmNleftAttachment, XmATTACH_FORM); - stdarg (XmNrightAttachment, XmATTACH_WIDGET); - stdarg (XmNrightWidget, w); - stdarg (XmNtopAttachment, XmATTACH_POSITION); - stdarg (XmNtopPosition, posn); - stdarg (XmNbottomAttachment, XmATTACH_POSITION); - stdarg (XmNbottomPosition, posn + 1); - stdarg (XmNlabelString, XmStringCreatePCB (label)); - stdarg (XmNalignment, XmALIGNMENT_END); - l = XmCreateLabel (parent, "label", args, n); - XtManageChild (l); + n = 0; + stdarg(XmNleftAttachment, XmATTACH_FORM); + stdarg(XmNrightAttachment, XmATTACH_WIDGET); + stdarg(XmNrightWidget, w); + stdarg(XmNtopAttachment, XmATTACH_POSITION); + stdarg(XmNtopPosition, posn); + stdarg(XmNbottomAttachment, XmATTACH_POSITION); + stdarg(XmNbottomPosition, posn + 1); + stdarg(XmNlabelString, XmStringCreatePCB(label)); + stdarg(XmNalignment, XmALIGNMENT_END); + l = XmCreateLabel(parent, "label", args, n); + XtManageChild(l); - return w; + return w; } -static const char adjustsizes_syntax[] = -"AdjustSizes()"; +static const char adjustsizes_syntax[] = "AdjustSizes()"; -static const char adjustsizes_help[] = -"Let the user change the board size, DRC parameters, etc"; +static const char adjustsizes_help[] = "Let the user change the board size, DRC parameters, etc"; /* %start-doc actions AdjustSizes @@ -1237,78 +1129,74 @@ %end-doc */ -static int -AdjustSizes (int argc, char **argv, Coord x, Coord y) +static int AdjustSizes(int argc, char **argv, Coord x, Coord y) { - if (!sizes_dialog) - { - Widget inf, sep; + if (!sizes_dialog) { + Widget inf, sep; - n = 0; - stdarg (XmNmarginWidth, 3); - stdarg (XmNmarginHeight, 3); - stdarg (XmNhorizontalSpacing, 3); - stdarg (XmNverticalSpacing, 3); - stdarg (XmNautoUnmanage, False); - stdarg (XmNtitle, "Board Sizes"); - sizes_dialog = XmCreateFormDialog (mainwind, "sizes", args, n); + n = 0; + stdarg(XmNmarginWidth, 3); + stdarg(XmNmarginHeight, 3); + stdarg(XmNhorizontalSpacing, 3); + stdarg(XmNverticalSpacing, 3); + stdarg(XmNautoUnmanage, False); + stdarg(XmNtitle, "Board Sizes"); + sizes_dialog = XmCreateFormDialog(mainwind, "sizes", args, n); - n = 0; - stdarg (XmNrightAttachment, XmATTACH_FORM); - stdarg (XmNbottomAttachment, XmATTACH_FORM); - sz_reset = XmCreatePushButton (sizes_dialog, "Reset", args, n); - XtManageChild (sz_reset); - XtAddCallback (sz_reset, XmNactivateCallback, - (XtCallbackProc) lesstif_sizes_reset, 0); + n = 0; + stdarg(XmNrightAttachment, XmATTACH_FORM); + stdarg(XmNbottomAttachment, XmATTACH_FORM); + sz_reset = XmCreatePushButton(sizes_dialog, "Reset", args, n); + XtManageChild(sz_reset); + XtAddCallback(sz_reset, XmNactivateCallback, (XtCallbackProc) lesstif_sizes_reset, 0); - n = 0; - stdarg (XmNrightAttachment, XmATTACH_WIDGET); - stdarg (XmNrightWidget, sz_reset); - stdarg (XmNbottomAttachment, XmATTACH_FORM); - sz_set = XmCreatePushButton (sizes_dialog, "Set", args, n); - XtManageChild (sz_set); - XtAddCallback (sz_set, XmNactivateCallback, (XtCallbackProc) sizes_set, - 0); + n = 0; + stdarg(XmNrightAttachment, XmATTACH_WIDGET); + stdarg(XmNrightWidget, sz_reset); + stdarg(XmNbottomAttachment, XmATTACH_FORM); + sz_set = XmCreatePushButton(sizes_dialog, "Set", args, n); + XtManageChild(sz_set); + XtAddCallback(sz_set, XmNactivateCallback, (XtCallbackProc) sizes_set, 0); - n = 0; - stdarg (XmNrightAttachment, XmATTACH_FORM); - stdarg (XmNleftAttachment, XmATTACH_FORM); - stdarg (XmNbottomAttachment, XmATTACH_WIDGET); - stdarg (XmNbottomWidget, sz_reset); - sep = XmCreateSeparator (sizes_dialog, "sep", args, n); - XtManageChild (sep); + n = 0; + stdarg(XmNrightAttachment, XmATTACH_FORM); + stdarg(XmNleftAttachment, XmATTACH_FORM); + stdarg(XmNbottomAttachment, XmATTACH_WIDGET); + stdarg(XmNbottomWidget, sz_reset); + sep = XmCreateSeparator(sizes_dialog, "sep", args, n); + XtManageChild(sep); - n = 0; - stdarg (XmNrightAttachment, XmATTACH_FORM); - stdarg (XmNleftAttachment, XmATTACH_FORM); - stdarg (XmNbottomAttachment, XmATTACH_WIDGET); - stdarg (XmNbottomWidget, sep); - sz_units = XmCreateLabel (sizes_dialog, "units", args, n); - XtManageChild (sz_units); + n = 0; + stdarg(XmNrightAttachment, XmATTACH_FORM); + stdarg(XmNleftAttachment, XmATTACH_FORM); + stdarg(XmNbottomAttachment, XmATTACH_WIDGET); + stdarg(XmNbottomWidget, sep); + sz_units = XmCreateLabel(sizes_dialog, "units", args, n); + XtManageChild(sz_units); - n = 0; - stdarg (XmNrightAttachment, XmATTACH_FORM); - stdarg (XmNleftAttachment, XmATTACH_FORM); - stdarg (XmNtopAttachment, XmATTACH_FORM); - stdarg (XmNbottomAttachment, XmATTACH_WIDGET); - stdarg (XmNbottomWidget, sz_units); - stdarg (XmNfractionBase, 9); - inf = XmCreateForm (sizes_dialog, "sizes", args, n); - XtManageChild (inf); + n = 0; + stdarg(XmNrightAttachment, XmATTACH_FORM); + stdarg(XmNleftAttachment, XmATTACH_FORM); + stdarg(XmNtopAttachment, XmATTACH_FORM); + stdarg(XmNbottomAttachment, XmATTACH_WIDGET); + stdarg(XmNbottomWidget, sz_units); + stdarg(XmNfractionBase, 9); + inf = XmCreateForm(sizes_dialog, "sizes", args, n); + XtManageChild(inf); - sz_pcb_w = size_field (inf, "PCB Width", 0); - sz_pcb_h = size_field (inf, "PCB Height", 1); - sz_bloat = size_field (inf, "Bloat", 2); - sz_shrink = size_field (inf, "Shrink", 3); - sz_drc_wid = size_field (inf, "DRC Min Wid", 4); - sz_drc_slk = size_field (inf, "DRC Min Silk", 5); - sz_drc_drill = size_field (inf, "DRC Min Drill", 6); - sz_drc_ring = size_field (inf, "DRC Min Annular Ring", 7); - sz_text = size_field (inf, "Text Scale", 8); - } - lesstif_sizes_reset (); - XtManageChild (sizes_dialog); - return 0; + sz_pcb_w = size_field(inf, "PCB Width", 0); + sz_pcb_h = size_field(inf, "PCB Height", 1); + sz_bloat = size_field(inf, "Bloat", 2); + sz_shrink = size_field(inf, "Shrink", 3); + sz_drc_wid = size_field(inf, "DRC Min Wid", 4); + sz_drc_slk = size_field(inf, "DRC Min Silk", 5); + sz_drc_drill = size_field(inf, "DRC Min Drill", 6); + sz_drc_ring = size_field(inf, "DRC Min Annular Ring", 7); + sz_text = size_field(inf, "Text Scale", 8); + } + lesstif_sizes_reset(); + XtManageChild(sizes_dialog); + return 0; } /* ------------------------------------------------------------ */ @@ -1316,10 +1204,10 @@ static Widget layer_groups_form = 0; static Widget lg_buttonform = 0; -static int lg_setcol[MAX_LAYER+2]; +static int lg_setcol[MAX_LAYER + 2]; static int lg_width, lg_height; -static int lg_r[MAX_LAYER+3]; -static int lg_c[MAX_LAYER+1]; +static int lg_r[MAX_LAYER + 3]; +static int lg_c[MAX_LAYER + 1]; static int lg_label_width, lg_fa, lg_fd; static GC lg_gc = 0; @@ -1329,225 +1217,206 @@ #endif typedef struct { - XFontStruct *font; - Pixel fg, bg, sel; + XFontStruct *font; + Pixel fg, bg, sel; } LgResource; static LgResource lgr; static XtResource lg_resources[] = { - { "font", "Font", XtRFontStruct, sizeof(XFontStruct*), XtOffset(LgResource*, font), XtRString, (void *)"fixed" }, - { "foreground", "Foreground", XtRPixel, sizeof(Pixel), XtOffset(LgResource*, fg), XtRString, (void *)"black" }, - { "selectColor", "Foreground", XtRPixel, sizeof(Pixel), XtOffset(LgResource*, sel), XtRString, (void *)"blue" }, - { "background", "Background", XtRPixel, sizeof(Pixel), XtOffset(LgResource*, bg), XtRString, (void *)"white" } + {"font", "Font", XtRFontStruct, sizeof(XFontStruct *), XtOffset(LgResource *, font), XtRString, (void *) "fixed"}, + {"foreground", "Foreground", XtRPixel, sizeof(Pixel), XtOffset(LgResource *, fg), XtRString, (void *) "black"}, + {"selectColor", "Foreground", XtRPixel, sizeof(Pixel), XtOffset(LgResource *, sel), XtRString, (void *) "blue"}, + {"background", "Background", XtRPixel, sizeof(Pixel), XtOffset(LgResource *, bg), XtRString, (void *) "white"} }; #if 0 -static void -lgbutton_cb (Widget w, int ij, void *cbs) +static void lgbutton_cb(Widget w, int ij, void *cbs) { - int layer, group, k; + int layer, group, k; - layer = ij / max_group; - group = ij % max_group; - group = MoveLayerToGroup (layer, group); - for (k = 0; k < max_group; k++) - { - if (k == group) - XmToggleButtonSetState (lgbuttons[layer][k], 1, 0); - else - XmToggleButtonSetState (lgbuttons[layer][k], 0, 0); - } + layer = ij / max_group; + group = ij % max_group; + group = MoveLayerToGroup(layer, group); + for (k = 0; k < max_group; k++) { + if (k == group) + XmToggleButtonSetState(lgbuttons[layer][k], 1, 0); + else + XmToggleButtonSetState(lgbuttons[layer][k], 0, 0); + } } #endif -static void -lgbutton_expose (Widget w, XtPointer u, XmDrawingAreaCallbackStruct *cbs) +static void lgbutton_expose(Widget w, XtPointer u, XmDrawingAreaCallbackStruct * cbs) { - int i; - Window win = XtWindow(w); + int i; + Window win = XtWindow(w); - if (cbs && cbs->event->xexpose.count) - return; - if (lg_gc == 0 && !cbs) - return; - if (lg_gc == 0 && cbs) - { - lg_gc = XCreateGC (display, win, 0, 0); - XSetFont (display, lg_gc, lgr.font->fid); - } + if (cbs && cbs->event->xexpose.count) + return; + if (lg_gc == 0 && !cbs) + return; + if (lg_gc == 0 && cbs) { + lg_gc = XCreateGC(display, win, 0, 0); + XSetFont(display, lg_gc, lgr.font->fid); + } - XSetForeground (display, lg_gc, lgr.bg); - XFillRectangle (display, win, lg_gc, 0, 0, lg_width, lg_height); - XSetForeground (display, lg_gc, lgr.fg); - for (i = 0; i < max_group; i++) - XDrawLine(display, win, lg_gc, lg_c[i], 0, lg_c[i], lg_height); - for (i = 1; i < max_copper_layer + 2; i++) - XDrawLine(display, win, lg_gc, lg_label_width, lg_r[i], lg_width, lg_r[i]); - for (i = 0; i < max_copper_layer + 2; i++) - { - int dir; - XCharStruct size; - int swidth; - const char *name; + XSetForeground(display, lg_gc, lgr.bg); + XFillRectangle(display, win, lg_gc, 0, 0, lg_width, lg_height); + XSetForeground(display, lg_gc, lgr.fg); + for (i = 0; i < max_group; i++) + XDrawLine(display, win, lg_gc, lg_c[i], 0, lg_c[i], lg_height); + for (i = 1; i < max_copper_layer + 2; i++) + XDrawLine(display, win, lg_gc, lg_label_width, lg_r[i], lg_width, lg_r[i]); + for (i = 0; i < max_copper_layer + 2; i++) { + int dir; + XCharStruct size; + int swidth; + const char *name; - if (i == solder_silk_layer) - name = SOLDER_SIDE_NAME; - else if (i == component_silk_layer) - name = COMPONENT_SIDE_NAME; - else - name = PCB->Data->Layer[i].Name; - XTextExtents (lgr.font, name, strlen(name), &dir, &lg_fa, &lg_fd, &size); - swidth = size.rbearing - size.lbearing; - XDrawString(display, win, lg_gc, - (lg_label_width - swidth)/2 - size.lbearing, - (lg_r[i] + lg_r[i+1] + lg_fd + lg_fa)/2 - 1, - name, strlen(name)); - } - XSetForeground (display, lg_gc, lgr.sel); - for (i = 0; i < max_copper_layer + 2; i++) - { - int c = lg_setcol[i]; - int x1 = lg_c[c] + 2; - int x2 = lg_c[c+1] - 2; - int y1 = lg_r[i] + 2; - int y2 = lg_r[i+1] - 2; - XFillRectangle (display, win, lg_gc, x1, y1, x2-x1+1, y2-y1+1); - } + if (i == solder_silk_layer) + name = SOLDER_SIDE_NAME; + else if (i == component_silk_layer) + name = COMPONENT_SIDE_NAME; + else + name = PCB->Data->Layer[i].Name; + XTextExtents(lgr.font, name, strlen(name), &dir, &lg_fa, &lg_fd, &size); + swidth = size.rbearing - size.lbearing; + XDrawString(display, win, lg_gc, + (lg_label_width - swidth) / 2 - size.lbearing, + (lg_r[i] + lg_r[i + 1] + lg_fd + lg_fa) / 2 - 1, name, strlen(name)); + } + XSetForeground(display, lg_gc, lgr.sel); + for (i = 0; i < max_copper_layer + 2; i++) { + int c = lg_setcol[i]; + int x1 = lg_c[c] + 2; + int x2 = lg_c[c + 1] - 2; + int y1 = lg_r[i] + 2; + int y2 = lg_r[i + 1] - 2; + XFillRectangle(display, win, lg_gc, x1, y1, x2 - x1 + 1, y2 - y1 + 1); + } } -static void -lgbutton_input (Widget w, XtPointer u, XmDrawingAreaCallbackStruct *cbs) +static void lgbutton_input(Widget w, XtPointer u, XmDrawingAreaCallbackStruct * cbs) { - int layer, group; - if (cbs->event->type != ButtonPress) - return; - layer = cbs->event->xbutton.y * (max_copper_layer + 2) / lg_height; - group = (cbs->event->xbutton.x - lg_label_width) * max_group / (lg_width - lg_label_width); - group = MoveLayerToGroup (layer, group); - lg_setcol[layer] = group; - lgbutton_expose (w, 0, 0); - gui->invalidate_all (); + int layer, group; + if (cbs->event->type != ButtonPress) + return; + layer = cbs->event->xbutton.y * (max_copper_layer + 2) / lg_height; + group = (cbs->event->xbutton.x - lg_label_width) * max_group / (lg_width - lg_label_width); + group = MoveLayerToGroup(layer, group); + lg_setcol[layer] = group; + lgbutton_expose(w, 0, 0); + gui->invalidate_all(); } -static void -lgbutton_resize (Widget w, XtPointer u, XmDrawingAreaCallbackStruct *cbs) +static void lgbutton_resize(Widget w, XtPointer u, XmDrawingAreaCallbackStruct * cbs) { - int i; - Dimension width, height; - n = 0; - stdarg(XmNwidth, &width); - stdarg(XmNheight, &height); - XtGetValues(w, args, n); - lg_width = width; - lg_height = height; + int i; + Dimension width, height; + n = 0; + stdarg(XmNwidth, &width); + stdarg(XmNheight, &height); + XtGetValues(w, args, n); + lg_width = width; + lg_height = height; - for (i=0; i<=max_group; i++) - lg_c[i] = lg_label_width + (lg_width - lg_label_width) * i / max_group; - for (i=0; i<=max_copper_layer+2; i++) - lg_r[i] = lg_height * i / (max_copper_layer + 2); - lgbutton_expose (w, 0, 0); + for (i = 0; i <= max_group; i++) + lg_c[i] = lg_label_width + (lg_width - lg_label_width) * i / max_group; + for (i = 0; i <= max_copper_layer + 2; i++) + lg_r[i] = lg_height * i / (max_copper_layer + 2); + lgbutton_expose(w, 0, 0); } -void -lesstif_update_layer_groups () +void lesstif_update_layer_groups() { - int sets[MAX_LAYER + 2][MAX_LAYER]; - int i, j, n; - LayerGroupType *l = &(PCB->LayerGroups); + int sets[MAX_LAYER + 2][MAX_LAYER]; + int i, j, n; + LayerGroupType *l = &(PCB->LayerGroups); - if (!layer_groups_form) - return; + if (!layer_groups_form) + return; - memset (sets, 0, sizeof (sets)); + memset(sets, 0, sizeof(sets)); - for (i = 0; i < max_group; i++) - for (j = 0; j < l->Number[i]; j++) - { - sets[l->Entries[i][j]][i] = 1; - lg_setcol[l->Entries[i][j]] = i; - } + for (i = 0; i < max_group; i++) + for (j = 0; j < l->Number[i]; j++) { + sets[l->Entries[i][j]][i] = 1; + lg_setcol[l->Entries[i][j]] = i; + } - lg_label_width = 0; - for (i = 0; i < max_copper_layer + 2; i++) - { - int dir; - XCharStruct size; - int swidth; - const char *name; + lg_label_width = 0; + for (i = 0; i < max_copper_layer + 2; i++) { + int dir; + XCharStruct size; + int swidth; + const char *name; - if (i == solder_silk_layer) - name = SOLDER_SIDE_NAME; - else if (i == component_silk_layer) - name = COMPONENT_SIDE_NAME; - else - name = PCB->Data->Layer[i].Name; - XTextExtents (lgr.font, name, strlen(name), &dir, &lg_fa, &lg_fd, &size); - swidth = size.rbearing - size.lbearing; - if (lg_label_width < swidth) - lg_label_width = swidth; - } - lg_label_width += 4; + if (i == solder_silk_layer) + name = SOLDER_SIDE_NAME; + else if (i == component_silk_layer) + name = COMPONENT_SIDE_NAME; + else + name = PCB->Data->Layer[i].Name; + XTextExtents(lgr.font, name, strlen(name), &dir, &lg_fa, &lg_fd, &size); + swidth = size.rbearing - size.lbearing; + if (lg_label_width < swidth) + lg_label_width = swidth; + } + lg_label_width += 4; - n = 0; - stdarg(XmNwidth, lg_label_width + (lg_fa+lg_fd) * max_group); - stdarg(XmNheight, (lg_fa+lg_fd) * (max_copper_layer + 2)); - XtSetValues(lg_buttonform, args, n); - lgbutton_expose (lg_buttonform, 0, 0); + n = 0; + stdarg(XmNwidth, lg_label_width + (lg_fa + lg_fd) * max_group); + stdarg(XmNheight, (lg_fa + lg_fd) * (max_copper_layer + 2)); + XtSetValues(lg_buttonform, args, n); + lgbutton_expose(lg_buttonform, 0, 0); #if 0 - for (i = 0; i < max_copper_layer + 2; i++) - { - char *name = "unknown"; - n = 0; - if (i < max_copper_layer) - name = PCB->Data->Layer[i].Name; - else if (i == solder_silk_layer) - name = SOLDER_SIDE_NAME; - else if (i == component_silk_layer) - name = COMPONENT_SIDE_NAME; - stdarg (XmNlabelString, XmStringCreatePCB (name)); - XtSetValues (lglabels[i], args, n); - for (j = 0; j < max_group; j++) - { - if (sets[i][j] != XmToggleButtonGetState (lgbuttons[i][j])) - { - XmToggleButtonSetState (lgbuttons[i][j], sets[i][j], 0); - } + for (i = 0; i < max_copper_layer + 2; i++) { + char *name = "unknown"; + n = 0; + if (i < max_copper_layer) + name = PCB->Data->Layer[i].Name; + else if (i == solder_silk_layer) + name = SOLDER_SIDE_NAME; + else if (i == component_silk_layer) + name = COMPONENT_SIDE_NAME; + stdarg(XmNlabelString, XmStringCreatePCB(name)); + XtSetValues(lglabels[i], args, n); + for (j = 0; j < max_group; j++) { + if (sets[i][j] != XmToggleButtonGetState(lgbuttons[i][j])) { + XmToggleButtonSetState(lgbuttons[i][j], sets[i][j], 0); + } + } } - } - XtUnmanageChild(lg_buttonform); - for (i = 0; i < MAX_LAYER + 2; i++) - for (j = 0; j < MAX_LAYER; j++) - { - if (i < max_copper_layer + 2 && j < max_group) - { - XtManageChild(lgbuttons[i][j]); - n = 0; - stdarg (XmNleftPosition, j * (max_copper_layer + 2)); - stdarg (XmNrightPosition, (j + 1) * (max_copper_layer + 2)); - stdarg (XmNtopPosition, i * max_group); - stdarg (XmNbottomPosition, (i + 1) * max_group); - XtSetValues(lgbuttons[i][j], args, n); - } - else - XtUnmanageChild(lgbuttons[i][j]); - } - n = 0; - stdarg (XmNfractionBase, max_copper_layer + 2); - XtSetValues (layer_groups_form, args, n); - n = 0; - stdarg (XmNfractionBase, max_group * (max_copper_layer + 2)); - XtSetValues (lg_buttonform, args, n); - XtManageChild(lg_buttonform); + XtUnmanageChild(lg_buttonform); + for (i = 0; i < MAX_LAYER + 2; i++) + for (j = 0; j < MAX_LAYER; j++) { + if (i < max_copper_layer + 2 && j < max_group) { + XtManageChild(lgbuttons[i][j]); + n = 0; + stdarg(XmNleftPosition, j * (max_copper_layer + 2)); + stdarg(XmNrightPosition, (j + 1) * (max_copper_layer + 2)); + stdarg(XmNtopPosition, i * max_group); + stdarg(XmNbottomPosition, (i + 1) * max_group); + XtSetValues(lgbuttons[i][j], args, n); + } + else + XtUnmanageChild(lgbuttons[i][j]); + } + n = 0; + stdarg(XmNfractionBase, max_copper_layer + 2); + XtSetValues(layer_groups_form, args, n); + n = 0; + stdarg(XmNfractionBase, max_group * (max_copper_layer + 2)); + XtSetValues(lg_buttonform, args, n); + XtManageChild(lg_buttonform); #endif } -static const char editlayergroups_syntax[] = -"EditLayerGroups()"; +static const char editlayergroups_syntax[] = "EditLayerGroups()"; -static const char editlayergroups_help[] = -"Let the user change the layer groupings"; +static const char editlayergroups_help[] = "Let the user change the layer groupings"; /* %start-doc actions EditLayerGroups @@ -1561,93 +1430,81 @@ %end-doc */ -static int -EditLayerGroups (int argc, char **argv, Coord x, Coord y) +static int EditLayerGroups(int argc, char **argv, Coord x, Coord y) { - if (!layer_groups_form) - { + if (!layer_groups_form) { - n = 0; - stdarg (XmNfractionBase, max_copper_layer + 2); - stdarg (XmNtitle, "Layer Groups"); - layer_groups_form = XmCreateFormDialog (mainwind, "layers", args, n); + n = 0; + stdarg(XmNfractionBase, max_copper_layer + 2); + stdarg(XmNtitle, "Layer Groups"); + layer_groups_form = XmCreateFormDialog(mainwind, "layers", args, n); - n = 0; - stdarg (XmNtopAttachment, XmATTACH_FORM); - stdarg (XmNbottomAttachment, XmATTACH_FORM); - stdarg (XmNrightAttachment, XmATTACH_FORM); - stdarg (XmNleftAttachment, XmATTACH_FORM); - lg_buttonform = XmCreateDrawingArea (layer_groups_form, "layers", args, n); - XtManageChild (lg_buttonform); + n = 0; + stdarg(XmNtopAttachment, XmATTACH_FORM); + stdarg(XmNbottomAttachment, XmATTACH_FORM); + stdarg(XmNrightAttachment, XmATTACH_FORM); + stdarg(XmNleftAttachment, XmATTACH_FORM); + lg_buttonform = XmCreateDrawingArea(layer_groups_form, "layers", args, n); + XtManageChild(lg_buttonform); - XtAddCallback (lg_buttonform, XmNexposeCallback, - (XtCallbackProc) lgbutton_expose, 0); - XtAddCallback (lg_buttonform, XmNinputCallback, - (XtCallbackProc) lgbutton_input, 0); - XtAddCallback (lg_buttonform, XmNresizeCallback, - (XtCallbackProc) lgbutton_resize, 0); + XtAddCallback(lg_buttonform, XmNexposeCallback, (XtCallbackProc) lgbutton_expose, 0); + XtAddCallback(lg_buttonform, XmNinputCallback, (XtCallbackProc) lgbutton_input, 0); + XtAddCallback(lg_buttonform, XmNresizeCallback, (XtCallbackProc) lgbutton_resize, 0); - XtGetSubresources (layer_groups_form, &lgr, - "layergroups", "LayerGroups", - lg_resources, XtNumber(lg_resources), 0, 0); + XtGetSubresources(layer_groups_form, &lgr, "layergroups", "LayerGroups", lg_resources, XtNumber(lg_resources), 0, 0); #if 0 - stdarg (XmNfractionBase, max_group * (MAX_LAYER + 2)); - lg_buttonform = XmCreateForm (layer_groups_form, "lgbutton", args, n); + stdarg(XmNfractionBase, max_group * (MAX_LAYER + 2)); + lg_buttonform = XmCreateForm(layer_groups_form, "lgbutton", args, n); - for (i = 0; i < MAX_LAYER + 2; i++) - { - n = 0; - stdarg (XmNleftAttachment, XmATTACH_FORM); - stdarg (XmNtopAttachment, XmATTACH_POSITION); - stdarg (XmNtopPosition, i); - stdarg (XmNbottomAttachment, XmATTACH_POSITION); - stdarg (XmNbottomPosition, i + 1); - stdarg (XmNrightAttachment, XmATTACH_WIDGET); - stdarg (XmNrightWidget, lg_buttonform); - lglabels[i] = XmCreateLabel (layer_groups_form, "layer", args, n); - XtManageChild (lglabels[i]); + for (i = 0; i < MAX_LAYER + 2; i++) { + n = 0; + stdarg(XmNleftAttachment, XmATTACH_FORM); + stdarg(XmNtopAttachment, XmATTACH_POSITION); + stdarg(XmNtopPosition, i); + stdarg(XmNbottomAttachment, XmATTACH_POSITION); + stdarg(XmNbottomPosition, i + 1); + stdarg(XmNrightAttachment, XmATTACH_WIDGET); + stdarg(XmNrightWidget, lg_buttonform); + lglabels[i] = XmCreateLabel(layer_groups_form, "layer", args, n); + XtManageChild(lglabels[i]); - for (j = 0; j < MAX_LAYER; j++) - { - n = 0; - stdarg (XmNleftAttachment, XmATTACH_POSITION); - stdarg (XmNleftPosition, j * (MAX_LAYER + 2)); - stdarg (XmNrightAttachment, XmATTACH_POSITION); - stdarg (XmNrightPosition, (j + 1) * (MAX_LAYER + 2)); - stdarg (XmNtopAttachment, XmATTACH_POSITION); - stdarg (XmNtopPosition, i * MAX_LAYER); - stdarg (XmNbottomAttachment, XmATTACH_POSITION); - stdarg (XmNbottomPosition, (i + 1) * MAX_LAYER); - stdarg (XmNlabelString, XmStringCreatePCB (" ")); - stdarg (XmNspacing, 0); - stdarg (XmNvisibleWhenOff, True); - stdarg (XmNfillOnSelect, True); - stdarg (XmNshadowThickness, 0); - stdarg (XmNmarginWidth, 0); - stdarg (XmNmarginHeight, 0); - stdarg (XmNhighlightThickness, 0); - lgbuttons[i][j] = - XmCreateToggleButton (lg_buttonform, "label", args, n); - XtManageChild (lgbuttons[i][j]); + for (j = 0; j < MAX_LAYER; j++) { + n = 0; + stdarg(XmNleftAttachment, XmATTACH_POSITION); + stdarg(XmNleftPosition, j * (MAX_LAYER + 2)); + stdarg(XmNrightAttachment, XmATTACH_POSITION); + stdarg(XmNrightPosition, (j + 1) * (MAX_LAYER + 2)); + stdarg(XmNtopAttachment, XmATTACH_POSITION); + stdarg(XmNtopPosition, i * MAX_LAYER); + stdarg(XmNbottomAttachment, XmATTACH_POSITION); + stdarg(XmNbottomPosition, (i + 1) * MAX_LAYER); + stdarg(XmNlabelString, XmStringCreatePCB(" ")); + stdarg(XmNspacing, 0); + stdarg(XmNvisibleWhenOff, True); + stdarg(XmNfillOnSelect, True); + stdarg(XmNshadowThickness, 0); + stdarg(XmNmarginWidth, 0); + stdarg(XmNmarginHeight, 0); + stdarg(XmNhighlightThickness, 0); + lgbuttons[i][j] = XmCreateToggleButton(lg_buttonform, "label", args, n); + XtManageChild(lgbuttons[i][j]); - XtAddCallback (lgbuttons[i][j], XmNvalueChangedCallback, - (XtCallbackProc) lgbutton_cb, - (XtPointer) (i * max_group + j)); - } + XtAddCallback(lgbuttons[i][j], XmNvalueChangedCallback, (XtCallbackProc) lgbutton_cb, (XtPointer) (i * max_group + j)); + } + } +#endif } -#endif - } - lesstif_update_layer_groups (); - XtManageChild (layer_groups_form); - return 1; + lesstif_update_layer_groups(); + XtManageChild(layer_groups_form); + return 1; } /* ------------------------------------------------------------ */ typedef struct { - Widget del; - Widget w_name; - Widget w_value; + Widget del; + Widget w_name; + Widget w_value; } AttrRow; static AttrRow *attr_row = 0; @@ -1656,344 +1513,308 @@ static Widget attr_dialog = NULL, f_top; static AttributeListType *attributes_list; -static void attributes_delete_callback (Widget w, void *v, void *cbs); +static void attributes_delete_callback(Widget w, void *v, void *cbs); -static void -fiddle_with_bb_layout () +static void fiddle_with_bb_layout() { - int i; - int max_height = 0; - int max_del_width = 0; - int max_name_width = 0; - int max_value_width = 0; - short ncolumns = 20; - short vcolumns = 20; + int i; + int max_height = 0; + int max_del_width = 0; + int max_name_width = 0; + int max_value_width = 0; + short ncolumns = 20; + short vcolumns = 20; - for (i=0; iNumber); + lesstif_attributes_need_rows(attributes_list->Number); - /* Unmanage any previously used rows we don't need. */ - while (attr_num_rows > attributes_list->Number) - { - attr_num_rows --; - XtUnmanageChild (attr_row[attr_num_rows].del); - XtUnmanageChild (attr_row[attr_num_rows].w_name); - XtUnmanageChild (attr_row[attr_num_rows].w_value); - } + /* Unmanage any previously used rows we don't need. */ + while (attr_num_rows > attributes_list->Number) { + attr_num_rows--; + XtUnmanageChild(attr_row[attr_num_rows].del); + XtUnmanageChild(attr_row[attr_num_rows].w_name); + XtUnmanageChild(attr_row[attr_num_rows].w_value); + } - /* Fill in values */ - for (i=0; iNumber; i++) - { - XmTextFieldSetString (attr_row[i].w_name, attributes_list->List[i].name); - XmTextFieldSetString (attr_row[i].w_value, attributes_list->List[i].value); - } + /* Fill in values */ + for (i = 0; i < attributes_list->Number; i++) { + XmTextFieldSetString(attr_row[i].w_name, attributes_list->List[i].name); + XmTextFieldSetString(attr_row[i].w_value, attributes_list->List[i].value); + } - fiddle_with_bb_layout (); + fiddle_with_bb_layout(); } -static void -attributes_new_callback (Widget w, void *v, void *cbs) +static void attributes_new_callback(Widget w, void *v, void *cbs) { - lesstif_attributes_need_rows (attr_num_rows + 1); /* also bumps attr_num_rows */ - XmTextFieldSetString (attr_row[attr_num_rows-1].w_name, ""); - XmTextFieldSetString (attr_row[attr_num_rows-1].w_value, ""); + lesstif_attributes_need_rows(attr_num_rows + 1); /* also bumps attr_num_rows */ + XmTextFieldSetString(attr_row[attr_num_rows - 1].w_name, ""); + XmTextFieldSetString(attr_row[attr_num_rows - 1].w_value, ""); - fiddle_with_bb_layout (); + fiddle_with_bb_layout(); } -static void -attributes_delete_callback (Widget w, void *v, void *cbs) +static void attributes_delete_callback(Widget w, void *v, void *cbs) { - int i, n; - Widget wn, wv; + int i, n; + Widget wn, wv; - n = (int) (size_t) v; + n = (int) (size_t) v; - wn = attr_row[n].w_name; - wv = attr_row[n].w_value; + wn = attr_row[n].w_name; + wv = attr_row[n].w_value; - for (i=n; iNumber; i++) - { - if (attributes_list->List[i].name) - free (attributes_list->List[i].name); - if (attributes_list->List[i].value) - free (attributes_list->List[i].value); + if (wait_for_dialog(attr_dialog) == 0) { + int i; + /* Copy the values back */ + for (i = 0; i < attributes_list->Number; i++) { + if (attributes_list->List[i].name) + free(attributes_list->List[i].name); + if (attributes_list->List[i].value) + free(attributes_list->List[i].value); + } + if (attributes_list->Max < attr_num_rows) { + int sz = attr_num_rows * sizeof(AttributeType); + if (attributes_list->List == NULL) + attributes_list->List = (AttributeType *) malloc(sz); + else + attributes_list->List = (AttributeType *) realloc(attributes_list->List, sz); + attributes_list->Max = attr_num_rows; + } + for (i = 0; i < attr_num_rows; i++) { + attributes_list->List[i].name = strdup(XmTextFieldGetString(attr_row[i].w_name)); + attributes_list->List[i].value = strdup(XmTextFieldGetString(attr_row[i].w_value)); + attributes_list->Number = attr_num_rows; + } } - if (attributes_list->Max < attr_num_rows) - { - int sz = attr_num_rows * sizeof (AttributeType); - if (attributes_list->List == NULL) - attributes_list->List = (AttributeType *) malloc (sz); - else - attributes_list->List = (AttributeType *) realloc (attributes_list->List, sz); - attributes_list->Max = attr_num_rows; - } - for (i=0; iList[i].name = strdup (XmTextFieldGetString (attr_row[i].w_name)); - attributes_list->List[i].value = strdup (XmTextFieldGetString (attr_row[i].w_value)); - attributes_list->Number = attr_num_rows; - } - } - return; + return; } /* ------------------------------------------------------------ */ -static const char importgui_syntax[] = -"ImportGUI()"; +static const char importgui_syntax[] = "ImportGUI()"; -static const char importgui_help[] = -"Lets the user choose the schematics to import from"; +static const char importgui_help[] = "Lets the user choose the schematics to import from"; /* %start-doc actions ImportGUI @@ -2003,106 +1824,117 @@ %end-doc */ -static int -ImportGUI (int argc, char **argv, Coord x, Coord y) +static int ImportGUI(int argc, char **argv, Coord x, Coord y) { - static int I_am_recursing = 0; - static XmString xms_sch = 0, xms_import = 0; - int rv; - XmString xmname; - char *name, *bname; - char *original_dir, *target_dir, *last_slash; + static int I_am_recursing = 0; + static XmString xms_sch = 0, xms_import = 0; + int rv; + XmString xmname; + char *name, *bname; + char *original_dir, *target_dir, *last_slash; - if (I_am_recursing) - return 1; + if (I_am_recursing) + return 1; - if (xms_sch == 0) - xms_sch = XmStringCreatePCB ("*.sch"); - if (xms_import == 0) - xms_import = XmStringCreatePCB ("Import from"); + if (xms_sch == 0) + xms_sch = XmStringCreatePCB("*.sch"); + if (xms_import == 0) + xms_import = XmStringCreatePCB("Import from"); - setup_fsb_dialog (); + setup_fsb_dialog(); - n = 0; - stdarg (XmNtitle, "Import From"); - XtSetValues (XtParent (fsb), args, n); + n = 0; + stdarg(XmNtitle, "Import From"); + XtSetValues(XtParent(fsb), args, n); - n = 0; - stdarg (XmNpattern, xms_sch); - stdarg (XmNmustMatch, True); - stdarg (XmNselectionLabelString, xms_import); - XtSetValues (fsb, args, n); + n = 0; + stdarg(XmNpattern, xms_sch); + stdarg(XmNmustMatch, True); + stdarg(XmNselectionLabelString, xms_import); + XtSetValues(fsb, args, n); - n = 0; - stdarg (XmNdirectory, &xmname); - XtGetValues (fsb, args, n); - XmStringGetLtoR (xmname, XmFONTLIST_DEFAULT_TAG, &original_dir); + n = 0; + stdarg(XmNdirectory, &xmname); + XtGetValues(fsb, args, n); + XmStringGetLtoR(xmname, XmFONTLIST_DEFAULT_TAG, &original_dir); - if (!wait_for_dialog (fsb)) - return 1; + if (!wait_for_dialog(fsb)) + return 1; - n = 0; - stdarg (XmNdirectory, &xmname); - XtGetValues (fsb, args, n); - XmStringGetLtoR (xmname, XmFONTLIST_DEFAULT_TAG, &target_dir); + n = 0; + stdarg(XmNdirectory, &xmname); + XtGetValues(fsb, args, n); + XmStringGetLtoR(xmname, XmFONTLIST_DEFAULT_TAG, &target_dir); - n = 0; - stdarg (XmNdirSpec, &xmname); - XtGetValues (fsb, args, n); + n = 0; + stdarg(XmNdirSpec, &xmname); + XtGetValues(fsb, args, n); - XmStringGetLtoR (xmname, XmFONTLIST_DEFAULT_TAG, &name); + XmStringGetLtoR(xmname, XmFONTLIST_DEFAULT_TAG, &name); - /* If the user didn't change directories, use just the base name. - This is the common case and means we don't have to get clever - about converting absolute paths into relative paths. */ - bname = name; - if (strcmp (original_dir, target_dir) == 0) - { - last_slash = strrchr (name, '/'); - if (last_slash) - bname = last_slash + 1; - } + /* If the user didn't change directories, use just the base name. + This is the common case and means we don't have to get clever + about converting absolute paths into relative paths. */ + bname = name; + if (strcmp(original_dir, target_dir) == 0) { + last_slash = strrchr(name, '/'); + if (last_slash) + bname = last_slash + 1; + } - AttributePut (PCB, "import::src0", bname); + AttributePut(PCB, "import::src0", bname); - XtFree (name); + XtFree(name); - I_am_recursing = 1; - rv = hid_action ("Import"); - I_am_recursing = 0; + I_am_recursing = 1; + rv = hid_action("Import"); + I_am_recursing = 0; - return rv; + return rv; } /* ------------------------------------------------------------ */ HID_Action lesstif_dialog_action_list[] = { - {"Load", 0, Load, - load_help, load_syntax}, - {"LoadVendor", 0, LoadVendor, - loadvendor_help, loadvendor_syntax}, - {"Save", 0, Save, - save_help, save_syntax}, - {"DoWindows", 0, DoWindows, - dowindows_help, dowindows_syntax}, - {"PromptFor", 0, PromptFor, - promptfor_help, promptfor_syntax}, - {"Confirm", 0, ConfirmAction}, - {"About", 0, About, - about_help, about_syntax}, - {"Print", 0, Print, - print_help, print_syntax}, - {"PrintCalibrate", 0, PrintCalibrate, - printcalibrate_help, printcalibrate_syntax}, - {"Export", 0, Export, - export_help, export_syntax}, - {"AdjustSizes", 0, AdjustSizes, - adjustsizes_help, adjustsizes_syntax}, - {"EditLayerGroups", 0, EditLayerGroups, - editlayergroups_help, editlayergroups_syntax}, - {"ImportGUI", 0, ImportGUI, - importgui_help, importgui_syntax}, + {"Load", 0, Load, + load_help, load_syntax} + , + {"LoadVendor", 0, LoadVendor, + loadvendor_help, loadvendor_syntax} + , + {"Save", 0, Save, + save_help, save_syntax} + , + {"DoWindows", 0, DoWindows, + dowindows_help, dowindows_syntax} + , + {"PromptFor", 0, PromptFor, + promptfor_help, promptfor_syntax} + , + {"Confirm", 0, ConfirmAction} + , + {"About", 0, About, + about_help, about_syntax} + , + {"Print", 0, Print, + print_help, print_syntax} + , + {"PrintCalibrate", 0, PrintCalibrate, + printcalibrate_help, printcalibrate_syntax} + , + {"Export", 0, Export, + export_help, export_syntax} + , + {"AdjustSizes", 0, AdjustSizes, + adjustsizes_help, adjustsizes_syntax} + , + {"EditLayerGroups", 0, EditLayerGroups, + editlayergroups_help, editlayergroups_syntax} + , + {"ImportGUI", 0, ImportGUI, + importgui_help, importgui_syntax} + , }; -REGISTER_ACTIONS (lesstif_dialog_action_list) +REGISTER_ACTIONS(lesstif_dialog_action_list) Index: trunk/src/hid/lesstif/lesstif.h =================================================================== --- trunk/src/hid/lesstif/lesstif.h (revision 1021) +++ trunk/src/hid/lesstif/lesstif.h (revision 1022) @@ -22,40 +22,38 @@ extern Widget mainwind, work_area, command, hscroll, vscroll; extern Widget m_click; -extern Widget lesstif_menu (Widget, char *, Arg *, int); -extern int lesstif_key_event (XKeyEvent *); -extern int lesstif_button_event (Widget w, XEvent * e); +extern Widget lesstif_menu(Widget, char *, Arg *, int); +extern int lesstif_key_event(XKeyEvent *); +extern int lesstif_button_event(Widget w, XEvent * e); /* Returns TRUE if the point mapped to the PCB region, FALSE (=0) if we're off-board. Note that *pcbxy is always written to, even if out of range. */ -extern int lesstif_winxy_to_pcbxy (int winx, int winy, int *pcbx, int *pcby); +extern int lesstif_winxy_to_pcbxy(int winx, int winy, int *pcbx, int *pcby); /* Returns TRUE if the point is in the window, FALSE (=0) otherwise. */ -extern int lesstif_pcbxy_to_winxy (int pcbx, int pcby, int *winx, int *winy); +extern int lesstif_pcbxy_to_winxy(int pcbx, int pcby, int *winx, int *winy); -extern void lesstif_need_idle_proc (void); -extern void lesstif_show_crosshair (int); -extern void lesstif_invalidate_all (void); -extern void lesstif_coords_to_pcb (int, int, Coord *, Coord *); -extern void lesstif_get_xy (const char *msg); -extern void lesstif_update_widget_flags (void); -extern int lesstif_call_action (const char *, int, char **); -extern void lesstif_sizes_reset (void); -extern void lesstif_pan_fixup (void); -extern void lesstif_show_library (void); -extern void lesstif_show_netlist (void); -extern Pixel lesstif_parse_color (char *value); -extern void lesstif_insert_style_buttons (Widget menu); -extern void lesstif_styles_update_values (); -extern void lesstif_update_layer_groups (); -extern void lesstif_update_status_line (); -extern char *lesstif_prompt_for (const char *, const char *); -extern char *lesstif_fileselect (const char *, const char *, - char *, char *, - const char *, int); -extern void lesstif_log (const char *fmt, ...); -extern void lesstif_attributes_dialog (char *, AttributeListType *); +extern void lesstif_need_idle_proc(void); +extern void lesstif_show_crosshair(int); +extern void lesstif_invalidate_all(void); +extern void lesstif_coords_to_pcb(int, int, Coord *, Coord *); +extern void lesstif_get_xy(const char *msg); +extern void lesstif_update_widget_flags(void); +extern int lesstif_call_action(const char *, int, char **); +extern void lesstif_sizes_reset(void); +extern void lesstif_pan_fixup(void); +extern void lesstif_show_library(void); +extern void lesstif_show_netlist(void); +extern Pixel lesstif_parse_color(char *value); +extern void lesstif_insert_style_buttons(Widget menu); +extern void lesstif_styles_update_values(); +extern void lesstif_update_layer_groups(); +extern void lesstif_update_status_line(); +extern char *lesstif_prompt_for(const char *, const char *); +extern char *lesstif_fileselect(const char *, const char *, char *, char *, const char *, int); +extern void lesstif_log(const char *fmt, ...); +extern void lesstif_attributes_dialog(char *, AttributeListType *); #ifndef XtRPCBCoord #define XtRPCBCoord "PCBCoord" @@ -64,10 +62,9 @@ #define need_idle_proc lesstif_need_idle_proc #define show_crosshair lesstif_show_crosshair -static XmString -XmStringCreatePCB (char *x) +static XmString XmStringCreatePCB(char *x) { - if (x && x[0]) - x = gettext (x); - return XmStringCreateLtoR (x, XmFONTLIST_DEFAULT_TAG); + if (x && x[0]) + x = gettext(x); + return XmStringCreateLtoR(x, XmFONTLIST_DEFAULT_TAG); } Index: trunk/src/hid/lesstif/library.c =================================================================== --- trunk/src/hid/lesstif/library.c (revision 1021) +++ trunk/src/hid/lesstif/library.c (revision 1022) @@ -24,7 +24,7 @@ #include #endif -RCSID ("$Id$"); +RCSID("$Id$"); static Arg args[30]; static int n; @@ -37,137 +37,126 @@ static XmString *libnode_strings = 0; static int last_pick = -1; -static void -pick_net (int pick) +static void pick_net(int pick) { - LibraryMenuType *menu = Library.Menu + pick; - int i; + LibraryMenuType *menu = Library.Menu + pick; + int i; - if (pick == last_pick) - return; - last_pick = pick; + if (pick == last_pick) + return; + last_pick = pick; - if (libnode_strings) - free (libnode_strings); - libnode_strings = (XmString *) malloc (menu->EntryN * sizeof (XmString)); - for (i = 0; i < menu->EntryN; i++) - libnode_strings[i] = XmStringCreatePCB (menu->Entry[i].ListEntry); - n = 0; - stdarg (XmNitems, libnode_strings); - stdarg (XmNitemCount, menu->EntryN); - XtSetValues (libnode_list, args, n); + if (libnode_strings) + free(libnode_strings); + libnode_strings = (XmString *) malloc(menu->EntryN * sizeof(XmString)); + for (i = 0; i < menu->EntryN; i++) + libnode_strings[i] = XmStringCreatePCB(menu->Entry[i].ListEntry); + n = 0; + stdarg(XmNitems, libnode_strings); + stdarg(XmNitemCount, menu->EntryN); + XtSetValues(libnode_list, args, n); } -static void -library_browse (Widget w, void *v, XmListCallbackStruct * cbs) +static void library_browse(Widget w, void *v, XmListCallbackStruct * cbs) { - pick_net (cbs->item_position - 1); + pick_net(cbs->item_position - 1); } -static void -libnode_select (Widget w, void *v, XmListCallbackStruct * cbs) +static void libnode_select(Widget w, void *v, XmListCallbackStruct * cbs) { - char *args; - LibraryEntryType *e = - Library.Menu[last_pick].Entry + cbs->item_position - 1; + char *args; + LibraryEntryType *e = Library.Menu[last_pick].Entry + cbs->item_position - 1; - if (LoadElementToBuffer (PASTEBUFFER, e->AllocatedMemory)) - SetMode (PASTEBUFFER_MODE); + if (LoadElementToBuffer(PASTEBUFFER, e->AllocatedMemory)) + SetMode(PASTEBUFFER_MODE); } -static int -build_library_dialog () +static int build_library_dialog() { - if (!mainwind) - return 1; - if (library_dialog) - return 0; + if (!mainwind) + return 1; + if (library_dialog) + return 0; - n = 0; - stdarg (XmNresizePolicy, XmRESIZE_GROW); - stdarg (XmNtitle, "Element Library"); - library_dialog = XmCreateFormDialog (mainwind, "library", args, n); + n = 0; + stdarg(XmNresizePolicy, XmRESIZE_GROW); + stdarg(XmNtitle, "Element Library"); + library_dialog = XmCreateFormDialog(mainwind, "library", args, n); - n = 0; - stdarg (XmNtopAttachment, XmATTACH_FORM); - stdarg (XmNbottomAttachment, XmATTACH_FORM); - stdarg (XmNleftAttachment, XmATTACH_FORM); - stdarg (XmNvisibleItemCount, 10); - library_list = XmCreateScrolledList (library_dialog, "nets", args, n); - XtManageChild (library_list); - XtAddCallback (library_list, XmNbrowseSelectionCallback, - (XtCallbackProc) library_browse, 0); + n = 0; + stdarg(XmNtopAttachment, XmATTACH_FORM); + stdarg(XmNbottomAttachment, XmATTACH_FORM); + stdarg(XmNleftAttachment, XmATTACH_FORM); + stdarg(XmNvisibleItemCount, 10); + library_list = XmCreateScrolledList(library_dialog, "nets", args, n); + XtManageChild(library_list); + XtAddCallback(library_list, XmNbrowseSelectionCallback, (XtCallbackProc) library_browse, 0); - n = 0; - stdarg (XmNtopAttachment, XmATTACH_FORM); - stdarg (XmNbottomAttachment, XmATTACH_FORM); - stdarg (XmNrightAttachment, XmATTACH_FORM); - stdarg (XmNleftAttachment, XmATTACH_WIDGET); - stdarg (XmNleftWidget, library_list); - libnode_list = XmCreateScrolledList (library_dialog, "nodes", args, n); - XtManageChild (libnode_list); - XtAddCallback (libnode_list, XmNbrowseSelectionCallback, - (XtCallbackProc) libnode_select, 0); + n = 0; + stdarg(XmNtopAttachment, XmATTACH_FORM); + stdarg(XmNbottomAttachment, XmATTACH_FORM); + stdarg(XmNrightAttachment, XmATTACH_FORM); + stdarg(XmNleftAttachment, XmATTACH_WIDGET); + stdarg(XmNleftWidget, library_list); + libnode_list = XmCreateScrolledList(library_dialog, "nodes", args, n); + XtManageChild(libnode_list); + XtAddCallback(libnode_list, XmNbrowseSelectionCallback, (XtCallbackProc) libnode_select, 0); - return 0; + return 0; } -static int -LibraryChanged (int argc, char **argv, Coord x, Coord y) +static int LibraryChanged(int argc, char **argv, Coord x, Coord y) { - int i; - if (!Library.MenuN) - return 0; - if (build_library_dialog ()) - return 0; - last_pick = -1; - if (library_strings) - free (library_strings); - library_strings = (XmString *) malloc (Library.MenuN * sizeof (XmString)); - for (i = 0; i < Library.MenuN; i++) - library_strings[i] = XmStringCreatePCB (Library.Menu[i].Name); - n = 0; - stdarg (XmNitems, library_strings); - stdarg (XmNitemCount, Library.MenuN); - XtSetValues (library_list, args, n); - pick_net (0); - return 0; + int i; + if (!Library.MenuN) + return 0; + if (build_library_dialog()) + return 0; + last_pick = -1; + if (library_strings) + free(library_strings); + library_strings = (XmString *) malloc(Library.MenuN * sizeof(XmString)); + for (i = 0; i < Library.MenuN; i++) + library_strings[i] = XmStringCreatePCB(Library.Menu[i].Name); + n = 0; + stdarg(XmNitems, library_strings); + stdarg(XmNitemCount, Library.MenuN); + XtSetValues(library_list, args, n); + pick_net(0); + return 0; } -static const char libraryshow_syntax[] = -"LibraryShow()"; +static const char libraryshow_syntax[] = "LibraryShow()"; -static const char libraryshow_help[] = -"Displays the library window."; +static const char libraryshow_help[] = "Displays the library window."; /* %start-doc actions LibraryShow %end-doc */ -static int -LibraryShow (int argc, char **argv, Coord x, Coord y) +static int LibraryShow(int argc, char **argv, Coord x, Coord y) { - if (build_library_dialog ()) - return 0; - return 0; + if (build_library_dialog()) + return 0; + return 0; } -void -lesstif_show_library () +void lesstif_show_library() { - if (mainwind) - { - if (!library_dialog) - LibraryChanged (0, 0, 0, 0); - XtManageChild (library_dialog); - } + if (mainwind) { + if (!library_dialog) + LibraryChanged(0, 0, 0, 0); + XtManageChild(library_dialog); + } } HID_Action lesstif_library_action_list[] = { - {"LibraryChanged", 0, LibraryChanged, - librarychanged_help, librarychanged_syntax}, - {"LibraryShow", 0, LibraryShow, - libraryshow_help, libraryshow_syntax}, + {"LibraryChanged", 0, LibraryChanged, + librarychanged_help, librarychanged_syntax} + , + {"LibraryShow", 0, LibraryShow, + libraryshow_help, libraryshow_syntax} + , }; -REGISTER_ACTIONS (lesstif_library_action_list) +REGISTER_ACTIONS(lesstif_library_action_list) Index: trunk/src/hid/lesstif/main.c =================================================================== --- trunk/src/hid/lesstif/main.c (revision 1021) +++ trunk/src/hid/lesstif/main.c (revision 1022) @@ -39,7 +39,7 @@ #include -RCSID ("$Id$"); +RCSID("$Id$"); #ifndef XtRDouble #define XtRDouble "Double" @@ -49,15 +49,14 @@ #define MAX_ZOOM_SCALE 10 #define UUNIT Settings.grid_unit->allow -typedef struct hid_gc_struct -{ - HID *me_pointer; - Pixel color; - char *colorname; - int width; - EndCapStyle cap; - char xor_set; - char erase; +typedef struct hid_gc_struct { + HID *me_pointer; + Pixel color; + char *colorname; + int width; + EndCapStyle cap; + char xor_set; + char erase; } hid_gc_struct; static HID lesstif_hid; @@ -94,8 +93,7 @@ Screen *screen_s; int screen; static Colormap colormap; -static GC my_gc = 0, bg_gc, clip_gc = 0, bset_gc = 0, bclear_gc = 0, mask_gc = - 0; +static GC my_gc = 0, bg_gc, clip_gc = 0, bset_gc = 0, bclear_gc = 0, mask_gc = 0; static Pixel bgcolor, offlimit_color, grid_color; static int bgred, bggreen, bgblue; @@ -102,16 +100,15 @@ static GC arc1_gc, arc2_gc; /* These are for the pinout windows. */ -typedef struct PinoutData -{ - struct PinoutData *prev, *next; - Widget form; - Window window; - Coord left, right, top, bottom; /* PCB extents of item */ - Coord x, y; /* PCB coordinates of upper right corner of window */ - double zoom; /* PCB units per screen pixel */ - int v_width, v_height; /* pixels */ - void *item; +typedef struct PinoutData { + struct PinoutData *prev, *next; + Widget form; + Window window; + Coord left, right, top, bottom; /* PCB extents of item */ + Coord x, y; /* PCB coordinates of upper right corner of window */ + double zoom; /* PCB units per screen pixel */ + int v_width, v_height; /* pixels */ + void *item; } PinoutData; /* Linked list of all pinout windows. */ @@ -138,63 +135,61 @@ /* Denotes PCB units per screen pixel. Larger numbers mean zooming out - the largest value means you are looking at the whole board. */ -static double view_zoom = MIL_TO_COORD (10), prev_view_zoom = MIL_TO_COORD (10); +static double view_zoom = MIL_TO_COORD(10), prev_view_zoom = MIL_TO_COORD(10); static bool flip_x = 0, flip_y = 0; static bool autofade = 0; static bool crosshair_on = true; -static void -ShowCrosshair (bool show) +static void ShowCrosshair(bool show) { - if (crosshair_on == show) - return; + if (crosshair_on == show) + return; - notify_crosshair_change (false); - if (Marked.status) - notify_mark_change (false); + notify_crosshair_change(false); + if (Marked.status) + notify_mark_change(false); - crosshair_on = show; + crosshair_on = show; - notify_crosshair_change (true); - if (Marked.status) - notify_mark_change (true); + notify_crosshair_change(true); + if (Marked.status) + notify_mark_change(true); } -static int -flag_flipx (int x) +static int flag_flipx(int x) { - return flip_x; + return flip_x; } -static int -flag_flipy (int x) + +static int flag_flipy(int x) { - return flip_y; + return flip_y; } HID_Flag lesstif_main_flag_list[] = { - {"flip_x", flag_flipx, 0}, - {"flip_y", flag_flipy, 0} + {"flip_x", flag_flipx, 0} + , + {"flip_y", flag_flipy, 0} }; -REGISTER_FLAGS (lesstif_main_flag_list) +REGISTER_FLAGS(lesstif_main_flag_list) /* This is the size of the current PCB work area. */ /* Use PCB->MaxWidth, PCB->MaxHeight. */ /* static int pcb_width, pcb_height; */ - -static Arg args[30]; -static int n; + static Arg args[30]; + static int n; #define stdarg(t,v) XtSetArg(args[n], t, v), n++ -static int use_private_colormap = 0; -static int stdin_listen = 0; -static char *background_image_file = 0; -char *lesstif_pcbmenu_path = "pcb-menu.res"; + static int use_private_colormap = 0; + static int stdin_listen = 0; + static char *background_image_file = 0; + char *lesstif_pcbmenu_path = "pcb-menu.res"; -HID_Attribute lesstif_attribute_list[] = { - {"install", "Install private colormap", - HID_Boolean, 0, 0, {0, 0, 0}, 0, &use_private_colormap}, + HID_Attribute lesstif_attribute_list[] = { + {"install", "Install private colormap", + HID_Boolean, 0, 0, {0, 0, 0}, 0, &use_private_colormap}, #define HA_colormap 0 /* %start-doc options "22 lesstif GUI Options" @@ -204,8 +199,8 @@ @end ftable %end-doc */ - {"listen", "Listen on standard input for actions", - HID_Boolean, 0, 0, {0, 0, 0}, 0, &stdin_listen}, + {"listen", "Listen on standard input for actions", + HID_Boolean, 0, 0, {0, 0, 0}, 0, &stdin_listen}, #define HA_listen 1 /* %start-doc options "22 lesstif GUI Options" @@ -217,8 +212,8 @@ @end ftable %end-doc */ - {"bg-image", "Background Image", - HID_String, 0, 0, {0, 0, 0}, 0, &background_image_file}, + {"bg-image", "Background Image", + HID_String, 0, 0, {0, 0, 0}, 0, &background_image_file}, #define HA_bg_image 2 /* %start-doc options "22 lesstif GUI Options" @@ -228,127 +223,115 @@ @end ftable %end-doc */ - {"pcb-menu", "Location of pcb-menu.res file", - HID_String, 0, 0, {0, PCBSHAREDIR "/pcb-menu.res", 0}, 0, &lesstif_pcbmenu_path} + {"pcb-menu", "Location of pcb-menu.res file", + HID_String, 0, 0, {0, PCBSHAREDIR "/pcb-menu.res", 0}, 0, &lesstif_pcbmenu_path} #define HA_pcbmenu 3 -}; + }; -REGISTER_ATTRIBUTES (lesstif_attribute_list) +REGISTER_ATTRIBUTES(lesstif_attribute_list) -static void lesstif_use_mask (int use_it); -static void zoom_max (); -static void zoom_to (double factor, int x, int y); -static void zoom_by (double factor, int x, int y); -static void zoom_toggle (int x, int y); -static void pinout_callback (Widget, PinoutData *, - XmDrawingAreaCallbackStruct *); -static void pinout_unmap (Widget, PinoutData *, void *); -static void Pan (int mode, int x, int y); + static void lesstif_use_mask(int use_it); + static void zoom_max(); + static void zoom_to(double factor, int x, int y); + static void zoom_by(double factor, int x, int y); + static void zoom_toggle(int x, int y); + static void pinout_callback(Widget, PinoutData *, XmDrawingAreaCallbackStruct *); + static void pinout_unmap(Widget, PinoutData *, void *); + static void Pan(int mode, int x, int y); /* Px converts view->pcb, Vx converts pcb->view */ -static inline int -Vx (Coord x) + static inline int + Vx(Coord x) { - int rv = (x - view_left_x) / view_zoom + 0.5; - if (flip_x) - rv = view_width - rv; - return rv; + int rv = (x - view_left_x) / view_zoom + 0.5; + if (flip_x) + rv = view_width - rv; + return rv; } -static inline int -Vy (Coord y) +static inline int Vy(Coord y) { - int rv = (y - view_top_y) / view_zoom + 0.5; - if (flip_y) - rv = view_height - rv; - return rv; + int rv = (y - view_top_y) / view_zoom + 0.5; + if (flip_y) + rv = view_height - rv; + return rv; } -static inline int -Vz (Coord z) +static inline int Vz(Coord z) { - return z / view_zoom + 0.5; + return z / view_zoom + 0.5; } -static inline Coord -Px (int x) +static inline Coord Px(int x) { - if (flip_x) - x = view_width - x; - return x * view_zoom + view_left_x; + if (flip_x) + x = view_width - x; + return x * view_zoom + view_left_x; } -static inline Coord -Py (int y) +static inline Coord Py(int y) { - if (flip_y) - y = view_height - y; - return y * view_zoom + view_top_y; + if (flip_y) + y = view_height - y; + return y * view_zoom + view_top_y; } -static inline Coord -Pz (int z) +static inline Coord Pz(int z) { - return z * view_zoom; + return z * view_zoom; } -void -lesstif_coords_to_pcb (int vx, int vy, Coord *px, Coord *py) +void lesstif_coords_to_pcb(int vx, int vy, Coord * px, Coord * py) { - *px = Px (vx); - *py = Py (vy); + *px = Px(vx); + *py = Py(vy); } -Pixel -lesstif_parse_color (char *value) +Pixel lesstif_parse_color(char *value) { - XColor color; - if (XParseColor (display, colormap, value, &color)) - if (XAllocColor (display, colormap, &color)) - return color.pixel; - return 0; + XColor color; + if (XParseColor(display, colormap, value, &color)) + if (XAllocColor(display, colormap, &color)) + return color.pixel; + return 0; } -static void -do_color (char *value, char *which) +static void do_color(char *value, char *which) { - XColor color; - if (XParseColor (display, colormap, value, &color)) - if (XAllocColor (display, colormap, &color)) - { - stdarg (which, color.pixel); - } + XColor color; + if (XParseColor(display, colormap, value, &color)) + if (XAllocColor(display, colormap, &color)) { + stdarg(which, color.pixel); + } } /* ------------------------------------------------------------ */ -static char * -cur_clip () +static char *cur_clip() { - if (TEST_FLAG (ORTHOMOVEFLAG, PCB)) - return "+"; - if (TEST_FLAG (ALLDIRECTIONFLAG, PCB)) - return "*"; - if (PCB->Clipping == 0) - return "X"; - if (PCB->Clipping == 1) - return "_/"; - return "\\_"; + if (TEST_FLAG(ORTHOMOVEFLAG, PCB)) + return "+"; + if (TEST_FLAG(ALLDIRECTIONFLAG, PCB)) + return "*"; + if (PCB->Clipping == 0) + return "X"; + if (PCB->Clipping == 1) + return "_/"; + return "\\_"; } /* Called from the core when it's busy doing something and we need to indicate that to the user. */ -static int -Busy(int argc, char **argv, Coord x, Coord y) +static int Busy(int argc, char **argv, Coord x, Coord y) { - static Cursor busy_cursor = 0; - if (busy_cursor == 0) - busy_cursor = XCreateFontCursor (display, XC_watch); - XDefineCursor (display, window, busy_cursor); - XFlush(display); - old_cursor_mode = -1; - return 0; + static Cursor busy_cursor = 0; + if (busy_cursor == 0) + busy_cursor = XCreateFontCursor(display, XC_watch); + XDefineCursor(display, window, busy_cursor); + XFlush(display); + old_cursor_mode = -1; + return 0; } /* ---------------------------------------------------------------------- */ @@ -355,60 +338,55 @@ /* Local actions. */ -static int -PointCursor (int argc, char **argv, Coord x, Coord y) +static int PointCursor(int argc, char **argv, Coord x, Coord y) { - if (argc > 0) - over_point = 1; - else - over_point = 0; - old_cursor_mode = -1; - return 0; + if (argc > 0) + over_point = 1; + else + over_point = 0; + old_cursor_mode = -1; + return 0; } -static int -PCBChanged (int argc, char **argv, Coord x, Coord y) +static int PCBChanged(int argc, char **argv, Coord x, Coord y) { - if (work_area == 0) - return 0; - /*pcb_printf("PCB Changed! %$mD\n", PCB->MaxWidth, PCB->MaxHeight); */ - n = 0; - stdarg (XmNminimum, 0); - stdarg (XmNvalue, 0); - stdarg (XmNsliderSize, PCB->MaxWidth ? PCB->MaxWidth : 1); - stdarg (XmNmaximum, PCB->MaxWidth ? PCB->MaxWidth : 1); - XtSetValues (hscroll, args, n); - n = 0; - stdarg (XmNminimum, 0); - stdarg (XmNvalue, 0); - stdarg (XmNsliderSize, PCB->MaxHeight ? PCB->MaxHeight : 1); - stdarg (XmNmaximum, PCB->MaxHeight ? PCB->MaxHeight : 1); - XtSetValues (vscroll, args, n); - zoom_max (); + if (work_area == 0) + return 0; + /*pcb_printf("PCB Changed! %$mD\n", PCB->MaxWidth, PCB->MaxHeight); */ + n = 0; + stdarg(XmNminimum, 0); + stdarg(XmNvalue, 0); + stdarg(XmNsliderSize, PCB->MaxWidth ? PCB->MaxWidth : 1); + stdarg(XmNmaximum, PCB->MaxWidth ? PCB->MaxWidth : 1); + XtSetValues(hscroll, args, n); + n = 0; + stdarg(XmNminimum, 0); + stdarg(XmNvalue, 0); + stdarg(XmNsliderSize, PCB->MaxHeight ? PCB->MaxHeight : 1); + stdarg(XmNmaximum, PCB->MaxHeight ? PCB->MaxHeight : 1); + XtSetValues(vscroll, args, n); + zoom_max(); - hid_action ("NetlistChanged"); - hid_action ("LayersChanged"); - hid_action ("RouteStylesChanged"); - lesstif_sizes_reset (); - lesstif_update_layer_groups (); - while (pinouts) - pinout_unmap (0, pinouts, 0); - if (PCB->Filename) - { - char *cp = strrchr (PCB->Filename, '/'); - n = 0; - stdarg (XmNtitle, cp ? cp + 1 : PCB->Filename); - XtSetValues (appwidget, args, n); - } - return 0; + hid_action("NetlistChanged"); + hid_action("LayersChanged"); + hid_action("RouteStylesChanged"); + lesstif_sizes_reset(); + lesstif_update_layer_groups(); + while (pinouts) + pinout_unmap(0, pinouts, 0); + if (PCB->Filename) { + char *cp = strrchr(PCB->Filename, '/'); + n = 0; + stdarg(XmNtitle, cp ? cp + 1 : PCB->Filename); + XtSetValues(appwidget, args, n); + } + return 0; } -static const char setunits_syntax[] = -"SetUnits(mm|mil)"; +static const char setunits_syntax[] = "SetUnits(mm|mil)"; -static const char setunits_help[] = -"Set the default measurement units."; +static const char setunits_help[] = "Set the default measurement units."; /* %start-doc actions SetUnits @@ -424,30 +402,25 @@ %end-doc */ -static int -SetUnits (int argc, char **argv, Coord x, Coord y) +static int SetUnits(int argc, char **argv, Coord x, Coord y) { - const Unit *new_unit; - if (argc == 0) - return 0; - new_unit = get_unit_struct (argv[0]); - if (new_unit != NULL && new_unit->allow != NO_PRINT) - { - Settings.grid_unit = new_unit; - Settings.increments = get_increments_struct (Settings.grid_unit->suffix); - AttributePut (PCB, "PCB::grid::unit", argv[0]); - } - lesstif_sizes_reset (); - lesstif_styles_update_values (); - return 0; + const Unit *new_unit; + if (argc == 0) + return 0; + new_unit = get_unit_struct(argv[0]); + if (new_unit != NULL && new_unit->allow != NO_PRINT) { + Settings.grid_unit = new_unit; + Settings.increments = get_increments_struct(Settings.grid_unit->suffix); + AttributePut(PCB, "PCB::grid::unit", argv[0]); + } + lesstif_sizes_reset(); + lesstif_styles_update_values(); + return 0; } -static const char zoom_syntax[] = -"Zoom()\n" -"Zoom(factor)"; +static const char zoom_syntax[] = "Zoom()\n" "Zoom(factor)"; -static const char zoom_help[] = -"Various zoom factor changes."; +static const char zoom_help[] = "Various zoom factor changes."; /* %start-doc actions Zoom @@ -486,80 +459,69 @@ %end-doc */ -static int -ZoomAction (int argc, char **argv, Coord x, Coord y) +static int ZoomAction(int argc, char **argv, Coord x, Coord y) { - const char *vp; - double v; - if (x == 0 && y == 0) - { - x = view_width / 2; - y = view_height / 2; - } - else - { - x = Vx (x); - y = Vy (y); - } - if (argc < 1) - { - zoom_max (); - return 0; - } - vp = argv[0]; - if (strcasecmp (vp, "toggle") == 0) - { - zoom_toggle (x, y); - return 0; - } - if (*vp == '+' || *vp == '-' || *vp == '=') - vp++; - v = g_ascii_strtod (vp, 0); - if (v <= 0) - return 1; - switch (argv[0][0]) - { - case '-': - zoom_by (1 / v, x, y); - break; - default: - case '+': - zoom_by (v, x, y); - break; - case '=': - zoom_to (v, x, y); - break; - } - return 0; + const char *vp; + double v; + if (x == 0 && y == 0) { + x = view_width / 2; + y = view_height / 2; + } + else { + x = Vx(x); + y = Vy(y); + } + if (argc < 1) { + zoom_max(); + return 0; + } + vp = argv[0]; + if (strcasecmp(vp, "toggle") == 0) { + zoom_toggle(x, y); + return 0; + } + if (*vp == '+' || *vp == '-' || *vp == '=') + vp++; + v = g_ascii_strtod(vp, 0); + if (v <= 0) + return 1; + switch (argv[0][0]) { + case '-': + zoom_by(1 / v, x, y); + break; + default: + case '+': + zoom_by(v, x, y); + break; + case '=': + zoom_to(v, x, y); + break; + } + return 0; } static int pan_thumb_mode; -static int -PanAction (int argc, char **argv, Coord x, Coord y) +static int PanAction(int argc, char **argv, Coord x, Coord y) { - int mode; + int mode; - if (argc == 2) - { - pan_thumb_mode = (strcasecmp (argv[0], "thumb") == 0) ? 1 : 0; - mode = atoi (argv[1]); - } - else - { - pan_thumb_mode = 0; - mode = atoi (argv[0]); - } - Pan (mode, Vx(x), Vy(y)); + if (argc == 2) { + pan_thumb_mode = (strcasecmp(argv[0], "thumb") == 0) ? 1 : 0; + mode = atoi(argv[1]); + } + else { + pan_thumb_mode = 0; + mode = atoi(argv[0]); + } + Pan(mode, Vx(x), Vy(y)); - return 0; + return 0; } -static const char swapsides_syntax[] = -"SwapSides(|v|h|r)"; +static const char swapsides_syntax[] = "SwapSides(|v|h|r)"; -static const char swapsides_help[] = -"Swaps the side of the board you're looking at."; +static const char swapsides_help[] = "Swaps the side of the board you're looking at."; /* %start-doc actions SwapSides @@ -594,155 +556,138 @@ %end-doc */ -static int -group_showing (int g, int *c) +static int group_showing(int g, int *c) { - int i, l; - *c = PCB->LayerGroups.Entries[g][0]; - for (i=0; iLayerGroups.Number[g]; i++) - { - l = PCB->LayerGroups.Entries[g][i]; - if (l >= 0 && l < max_copper_layer) - { - *c = l; - if (PCB->Data->Layer[l].On) - return 1; + int i, l; + *c = PCB->LayerGroups.Entries[g][0]; + for (i = 0; i < PCB->LayerGroups.Number[g]; i++) { + l = PCB->LayerGroups.Entries[g][i]; + if (l >= 0 && l < max_copper_layer) { + *c = l; + if (PCB->Data->Layer[l].On) + return 1; + } } - } - return 0; + return 0; } -static int -SwapSides (int argc, char **argv, Coord x, Coord y) +static int SwapSides(int argc, char **argv, Coord x, Coord y) { - int old_shown_side = Settings.ShowSolderSide; - int comp_group = GetLayerGroupNumberByNumber (component_silk_layer); - int solder_group = GetLayerGroupNumberByNumber (solder_silk_layer); - int active_group = GetLayerGroupNumberByNumber (LayerStack[0]); - int comp_layer; - int solder_layer; - int comp_showing = group_showing (comp_group, &comp_layer); - int solder_showing = group_showing (solder_group, &solder_layer); + int old_shown_side = Settings.ShowSolderSide; + int comp_group = GetLayerGroupNumberByNumber(component_silk_layer); + int solder_group = GetLayerGroupNumberByNumber(solder_silk_layer); + int active_group = GetLayerGroupNumberByNumber(LayerStack[0]); + int comp_layer; + int solder_layer; + int comp_showing = group_showing(comp_group, &comp_layer); + int solder_showing = group_showing(solder_group, &solder_layer); - if (argc > 0) - { - switch (argv[0][0]) { - case 'h': - case 'H': - flip_x = ! flip_x; - break; - case 'v': - case 'V': - flip_y = ! flip_y; - break; - case 'r': - case 'R': - flip_x = ! flip_x; - flip_y = ! flip_y; - break; - default: - return 1; - } - /* SwapSides will swap this */ - Settings.ShowSolderSide = (flip_x == flip_y); - } + if (argc > 0) { + switch (argv[0][0]) { + case 'h': + case 'H': + flip_x = !flip_x; + break; + case 'v': + case 'V': + flip_y = !flip_y; + break; + case 'r': + case 'R': + flip_x = !flip_x; + flip_y = !flip_y; + break; + default: + return 1; + } + /* SwapSides will swap this */ + Settings.ShowSolderSide = (flip_x == flip_y); + } - n = 0; - if (flip_x) - stdarg (XmNprocessingDirection, XmMAX_ON_LEFT); - else - stdarg (XmNprocessingDirection, XmMAX_ON_RIGHT); - XtSetValues (hscroll, args, n); + n = 0; + if (flip_x) + stdarg(XmNprocessingDirection, XmMAX_ON_LEFT); + else + stdarg(XmNprocessingDirection, XmMAX_ON_RIGHT); + XtSetValues(hscroll, args, n); - n = 0; - if (flip_y) - stdarg (XmNprocessingDirection, XmMAX_ON_TOP); - else - stdarg (XmNprocessingDirection, XmMAX_ON_BOTTOM); - XtSetValues (vscroll, args, n); + n = 0; + if (flip_y) + stdarg(XmNprocessingDirection, XmMAX_ON_TOP); + else + stdarg(XmNprocessingDirection, XmMAX_ON_BOTTOM); + XtSetValues(vscroll, args, n); - Settings.ShowSolderSide = !Settings.ShowSolderSide; + Settings.ShowSolderSide = !Settings.ShowSolderSide; - /* The idea is that if we're looking at the front side and the front - layer is active (or visa versa), switching sides should switch - layers too. We used to only do this if the other layer wasn't - shown, but we now do it always. Change it back if users get - confused. */ - if (Settings.ShowSolderSide != old_shown_side) - { - if (Settings.ShowSolderSide) - { - if (active_group == comp_group) - { - if (comp_showing && !solder_showing) - ChangeGroupVisibility (comp_layer, 0, 0); - ChangeGroupVisibility (solder_layer, 1, 1); - } + /* The idea is that if we're looking at the front side and the front + layer is active (or visa versa), switching sides should switch + layers too. We used to only do this if the other layer wasn't + shown, but we now do it always. Change it back if users get + confused. */ + if (Settings.ShowSolderSide != old_shown_side) { + if (Settings.ShowSolderSide) { + if (active_group == comp_group) { + if (comp_showing && !solder_showing) + ChangeGroupVisibility(comp_layer, 0, 0); + ChangeGroupVisibility(solder_layer, 1, 1); + } + } + else { + if (active_group == solder_group) { + if (solder_showing && !comp_showing) + ChangeGroupVisibility(solder_layer, 0, 0); + ChangeGroupVisibility(comp_layer, 1, 1); + } + } } - else - { - if (active_group == solder_group) - { - if (solder_showing && !comp_showing) - ChangeGroupVisibility (solder_layer, 0, 0); - ChangeGroupVisibility (comp_layer, 1, 1); - } - } - } - lesstif_invalidate_all (); - return 0; + lesstif_invalidate_all(); + return 0; } static Widget m_cmd = 0, m_cmd_label; -static void -command_callback (Widget w, XtPointer uptr, XmTextVerifyCallbackStruct * cbs) +static void command_callback(Widget w, XtPointer uptr, XmTextVerifyCallbackStruct * cbs) { - char *s; - switch (cbs->reason) - { - case XmCR_ACTIVATE: - s = XmTextGetString (w); - lesstif_show_crosshair (0); - hid_parse_command (s); - XtFree (s); - XmTextSetString (w, ""); - case XmCR_LOSING_FOCUS: - XtUnmanageChild (m_cmd); - XtUnmanageChild (m_cmd_label); - break; - } + char *s; + switch (cbs->reason) { + case XmCR_ACTIVATE: + s = XmTextGetString(w); + lesstif_show_crosshair(0); + hid_parse_command(s); + XtFree(s); + XmTextSetString(w, ""); + case XmCR_LOSING_FOCUS: + XtUnmanageChild(m_cmd); + XtUnmanageChild(m_cmd_label); + break; + } } -static void -command_event_handler (Widget w, XtPointer p, XEvent * e, Boolean * cont) +static void command_event_handler(Widget w, XtPointer p, XEvent * e, Boolean * cont) { - char buf[10]; - KeySym sym; - int slen; + char buf[10]; + KeySym sym; + int slen; - switch (e->type) - { - case KeyPress: - slen = XLookupString ((XKeyEvent *)e, buf, sizeof (buf), &sym, NULL); - switch (sym) - { - case XK_Escape: - XtUnmanageChild (m_cmd); - XtUnmanageChild (m_cmd_label); - XmTextSetString (w, ""); - *cont = False; - break; + switch (e->type) { + case KeyPress: + slen = XLookupString((XKeyEvent *) e, buf, sizeof(buf), &sym, NULL); + switch (sym) { + case XK_Escape: + XtUnmanageChild(m_cmd); + XtUnmanageChild(m_cmd_label); + XmTextSetString(w, ""); + *cont = False; + break; + } + break; } - break; - } } -static const char command_syntax[] = -"Command()"; +static const char command_syntax[] = "Command()"; -static const char command_help[] = -"Displays the command line input window."; +static const char command_help[] = "Displays the command line input window."; /* %start-doc actions Command @@ -780,20 +725,17 @@ %end-doc */ -static int -Command (int argc, char **argv, Coord x, Coord y) +static int Command(int argc, char **argv, Coord x, Coord y) { - XtManageChild (m_cmd_label); - XtManageChild (m_cmd); - XmProcessTraversal (m_cmd, XmTRAVERSE_CURRENT); - return 0; + XtManageChild(m_cmd_label); + XtManageChild(m_cmd); + XmProcessTraversal(m_cmd, XmTRAVERSE_CURRENT); + return 0; } -static const char benchmark_syntax[] = -"Benchmark()"; +static const char benchmark_syntax[] = "Benchmark()"; -static const char benchmark_help[] = -"Benchmark the GUI speed."; +static const char benchmark_help[] = "Benchmark the GUI speed."; /* %start-doc actions Benchmark @@ -803,62 +745,56 @@ %end-doc */ -static int -Benchmark (int argc, char **argv, Coord x, Coord y) +static int Benchmark(int argc, char **argv, Coord x, Coord y) { - int i = 0; - time_t start, end; - BoxType region; - Drawable save_main; + int i = 0; + time_t start, end; + BoxType region; + Drawable save_main; - save_main = main_pixmap; - main_pixmap = window; + save_main = main_pixmap; + main_pixmap = window; - region.X1 = 0; - region.Y1 = 0; - region.X2 = PCB->MaxWidth; - region.Y2 = PCB->MaxHeight; + region.X1 = 0; + region.Y1 = 0; + region.X2 = PCB->MaxWidth; + region.Y2 = PCB->MaxHeight; - pixmap = window; - XSync (display, 0); - time (&start); - do - { - XFillRectangle (display, pixmap, bg_gc, 0, 0, view_width, view_height); - hid_expose_callback (&lesstif_hid, ®ion, 0); - XSync (display, 0); - time (&end); - i++; - } - while (end - start < 10); + pixmap = window; + XSync(display, 0); + time(&start); + do { + XFillRectangle(display, pixmap, bg_gc, 0, 0, view_width, view_height); + hid_expose_callback(&lesstif_hid, ®ion, 0); + XSync(display, 0); + time(&end); + i++; + } + while (end - start < 10); - printf ("%g redraws per second\n", i / 10.0); + printf("%g redraws per second\n", i / 10.0); - main_pixmap = save_main; - return 0; + main_pixmap = save_main; + return 0; } -static int -Center(int argc, char **argv, Coord x, Coord y) +static int Center(int argc, char **argv, Coord x, Coord y) { - x = GridFit (x, PCB->Grid, PCB->GridOffsetX); - y = GridFit (y, PCB->Grid, PCB->GridOffsetY); - view_left_x = x - (view_width * view_zoom) / 2; - view_top_y = y - (view_height * view_zoom) / 2; - lesstif_pan_fixup (); - /* Move the pointer to the center of the window, but only if it's - currently within the window already. Watch out for edges, - though. */ - XWarpPointer (display, window, window, 0, 0, view_width, view_height, - Vx(x), Vy(y)); - return 0; + x = GridFit(x, PCB->Grid, PCB->GridOffsetX); + y = GridFit(y, PCB->Grid, PCB->GridOffsetY); + view_left_x = x - (view_width * view_zoom) / 2; + view_top_y = y - (view_height * view_zoom) / 2; + lesstif_pan_fixup(); + /* Move the pointer to the center of the window, but only if it's + currently within the window already. Watch out for edges, + though. */ + XWarpPointer(display, window, window, 0, 0, view_width, view_height, Vx(x), Vy(y)); + return 0; } -static const char cursor_syntax[] = -"Cursor(Type,DeltaUp,DeltaRight,Units)"; +static const char cursor_syntax[] = "Cursor(Type,DeltaUp,DeltaRight,Units)"; -static const char cursor_help[] = -"Move the cursor."; +static const char cursor_help[] = "Move the cursor."; /* %start-doc actions Cursor @@ -895,154 +831,156 @@ %end-doc */ -static int -CursorAction(int argc, char **argv, Coord x, Coord y) +static int CursorAction(int argc, char **argv, Coord x, Coord y) { - UnitList extra_units_x = { - { "grid", PCB->Grid, 0 }, - { "view", Pz(view_width), UNIT_PERCENT }, - { "board", PCB->MaxWidth, UNIT_PERCENT }, - { "", 0, 0 } - }; - UnitList extra_units_y = { - { "grid", PCB->Grid, 0 }, - { "view", Pz(view_height), UNIT_PERCENT }, - { "board", PCB->MaxHeight, UNIT_PERCENT }, - { "", 0, 0 } - }; - int pan_warp = HID_SC_DO_NOTHING; - double dx, dy; + UnitList extra_units_x = { + {"grid", PCB->Grid, 0}, + {"view", Pz(view_width), UNIT_PERCENT}, + {"board", PCB->MaxWidth, UNIT_PERCENT}, + {"", 0, 0} + }; + UnitList extra_units_y = { + {"grid", PCB->Grid, 0}, + {"view", Pz(view_height), UNIT_PERCENT}, + {"board", PCB->MaxHeight, UNIT_PERCENT}, + {"", 0, 0} + }; + int pan_warp = HID_SC_DO_NOTHING; + double dx, dy; - if (argc != 4) - AFAIL(cursor); + if (argc != 4) + AFAIL(cursor); - if (strcasecmp (argv[0], "pan") == 0) - pan_warp = HID_SC_PAN_VIEWPORT; - else if (strcasecmp (argv[0], "warp") == 0) - pan_warp = HID_SC_WARP_POINTER; - else - AFAIL(cursor); + if (strcasecmp(argv[0], "pan") == 0) + pan_warp = HID_SC_PAN_VIEWPORT; + else if (strcasecmp(argv[0], "warp") == 0) + pan_warp = HID_SC_WARP_POINTER; + else + AFAIL(cursor); - dx = GetValueEx (argv[1], argv[3], NULL, extra_units_x, "mil"); - if (flip_x) - dx = -dx; - dy = GetValueEx (argv[2], argv[3], NULL, extra_units_y, "mil"); - if (!flip_y) - dy = -dy; + dx = GetValueEx(argv[1], argv[3], NULL, extra_units_x, "mil"); + if (flip_x) + dx = -dx; + dy = GetValueEx(argv[2], argv[3], NULL, extra_units_y, "mil"); + if (!flip_y) + dy = -dy; - EventMoveCrosshair (Crosshair.X + dx, Crosshair.Y + dy); - gui->set_crosshair (Crosshair.X, Crosshair.Y, pan_warp); + EventMoveCrosshair(Crosshair.X + dx, Crosshair.Y + dy); + gui->set_crosshair(Crosshair.X, Crosshair.Y, pan_warp); - return 0; + return 0; } HID_Action lesstif_main_action_list[] = { - {"PCBChanged", 0, PCBChanged, - pcbchanged_help, pcbchanged_syntax}, - {"SetUnits", 0, SetUnits, - setunits_help, setunits_syntax}, - {"Zoom", "Click on a place to zoom in", ZoomAction, - zoom_help, zoom_syntax}, - {"Pan", "Click on a place to pan", PanAction, - zoom_help, zoom_syntax}, - {"SwapSides", 0, SwapSides, - swapsides_help, swapsides_syntax}, - {"Command", 0, Command, - command_help, command_syntax}, - {"Benchmark", 0, Benchmark, - benchmark_help, benchmark_syntax}, - {"PointCursor", 0, PointCursor}, - {"Center", "Click on a location to center", Center}, - {"Busy", 0, Busy}, - {"Cursor", 0, CursorAction, - cursor_help, cursor_syntax}, + {"PCBChanged", 0, PCBChanged, + pcbchanged_help, pcbchanged_syntax} + , + {"SetUnits", 0, SetUnits, + setunits_help, setunits_syntax} + , + {"Zoom", "Click on a place to zoom in", ZoomAction, + zoom_help, zoom_syntax} + , + {"Pan", "Click on a place to pan", PanAction, + zoom_help, zoom_syntax} + , + {"SwapSides", 0, SwapSides, + swapsides_help, swapsides_syntax} + , + {"Command", 0, Command, + command_help, command_syntax} + , + {"Benchmark", 0, Benchmark, + benchmark_help, benchmark_syntax} + , + {"PointCursor", 0, PointCursor} + , + {"Center", "Click on a location to center", Center} + , + {"Busy", 0, Busy} + , + {"Cursor", 0, CursorAction, + cursor_help, cursor_syntax} + , }; -REGISTER_ACTIONS (lesstif_main_action_list) +REGISTER_ACTIONS(lesstif_main_action_list) /* ---------------------------------------------------------------------- * redraws the background image */ + static int bg_w, bg_h, bgi_w, bgi_h; + static Pixel **bg = 0; + static XImage *bgi = 0; + static enum { + PT_unknown, + PT_RGB565, + PT_RGB888 + } pixel_type = PT_unknown; -static int bg_w, bg_h, bgi_w, bgi_h; -static Pixel **bg = 0; -static XImage *bgi = 0; -static enum { - PT_unknown, - PT_RGB565, - PT_RGB888 -} pixel_type = PT_unknown; - -static void -LoadBackgroundFile (FILE *f, char *filename) + static void + LoadBackgroundFile(FILE * f, char *filename) { - XVisualInfo vinfot, *vinfo; - Visual *vis; - int c, r, b; - int i, nret; - int p[3], rows, cols, maxval; + XVisualInfo vinfot, *vinfo; + Visual *vis; + int c, r, b; + int i, nret; + int p[3], rows, cols, maxval; - if (fgetc(f) != 'P') - { - printf("bgimage: %s signature not P6\n", filename); - return; - } - if (fgetc(f) != '6') - { - printf("bgimage: %s signature not P6\n", filename); - return; - } - for (i=0; i<3; i++) - { - do { - b = fgetc(f); - if (feof(f)) - return; - if (b == '#') - while (!feof(f) && b != '\n') - b = fgetc(f); - } while (!isdigit(b)); - p[i] = b - '0'; - while (isdigit(b = fgetc(f))) - p[i] = p[i]*10 + b - '0'; - } - bg_w = cols = p[0]; - bg_h = rows = p[1]; - maxval = p[2]; + if (fgetc(f) != 'P') { + printf("bgimage: %s signature not P6\n", filename); + return; + } + if (fgetc(f) != '6') { + printf("bgimage: %s signature not P6\n", filename); + return; + } + for (i = 0; i < 3; i++) { + do { + b = fgetc(f); + if (feof(f)) + return; + if (b == '#') + while (!feof(f) && b != '\n') + b = fgetc(f); + } while (!isdigit(b)); + p[i] = b - '0'; + while (isdigit(b = fgetc(f))) + p[i] = p[i] * 10 + b - '0'; + } + bg_w = cols = p[0]; + bg_h = rows = p[1]; + maxval = p[2]; - setbuf(stdout, 0); - bg = (Pixel **) malloc (rows * sizeof (Pixel *)); - if (!bg) - { - printf("Out of memory loading %s\n", filename); - return; - } - for (i=0; i= 0) - free (bg[i]); - free (bg); - bg = 0; - return; + setbuf(stdout, 0); + bg = (Pixel **) malloc(rows * sizeof(Pixel *)); + if (!bg) { + printf("Out of memory loading %s\n", filename); + return; } - } + for (i = 0; i < rows; i++) { + bg[i] = (Pixel *) malloc(cols * sizeof(Pixel)); + if (!bg[i]) { + printf("Out of memory loading %s\n", filename); + while (--i >= 0) + free(bg[i]); + free(bg); + bg = 0; + return; + } + } - vis = DefaultVisual (display, DefaultScreen(display)); + vis = DefaultVisual(display, DefaultScreen(display)); - vinfot.visualid = XVisualIDFromVisual(vis); - vinfo = XGetVisualInfo (display, VisualIDMask, &vinfot, &nret); + vinfot.visualid = XVisualIDFromVisual(vis); + vinfo = XGetVisualInfo(display, VisualIDMask, &vinfot, &nret); #if 0 - /* If you want to support more visuals below, you'll probably need - this. */ - printf("vinfo: rm %04x gm %04x bm %04x depth %d class %d\n", - vinfo->red_mask, vinfo->green_mask, vinfo->blue_mask, - vinfo->depth, vinfo->class); + /* If you want to support more visuals below, you'll probably need + this. */ + printf("vinfo: rm %04x gm %04x bm %04x depth %d class %d\n", + vinfo->red_mask, vinfo->green_mask, vinfo->blue_mask, vinfo->depth, vinfo->class); #endif #if !defined(__cplusplus) @@ -1049,226 +987,197 @@ #define c_class class #endif - if (vinfo->c_class == TrueColor - && vinfo->depth == 16 - && vinfo->red_mask == 0xf800 - && vinfo->green_mask == 0x07e0 - && vinfo->blue_mask == 0x001f) - pixel_type = PT_RGB565; + if (vinfo->c_class == TrueColor + && vinfo->depth == 16 && vinfo->red_mask == 0xf800 && vinfo->green_mask == 0x07e0 && vinfo->blue_mask == 0x001f) + pixel_type = PT_RGB565; - if (vinfo->c_class == TrueColor - && vinfo->depth == 24 - && vinfo->red_mask == 0xff0000 - && vinfo->green_mask == 0x00ff00 - && vinfo->blue_mask == 0x0000ff) - pixel_type = PT_RGB888; + if (vinfo->c_class == TrueColor + && vinfo->depth == 24 && vinfo->red_mask == 0xff0000 && vinfo->green_mask == 0x00ff00 && vinfo->blue_mask == 0x0000ff) + pixel_type = PT_RGB888; - for (r=0; r>3)<<11 | (pg>>2)<<5 | (pb>>3); - break; - case PT_RGB888: - bg[r][c] = (pr << 16) | (pg << 8) | (pb); - break; - } + switch (pixel_type) { + case PT_unknown: + pix.red = pr * 65535 / maxval; + pix.green = pg * 65535 / maxval; + pix.blue = pb * 65535 / maxval; + pix.flags = DoRed | DoGreen | DoBlue; + XAllocColor(display, colormap, &pix); + bg[r][c] = pix.pixel; + break; + case PT_RGB565: + bg[r][c] = (pr >> 3) << 11 | (pg >> 2) << 5 | (pb >> 3); + break; + case PT_RGB888: + bg[r][c] = (pr << 16) | (pg << 8) | (pb); + break; + } + } } - } } -void -LoadBackgroundImage (char *filename) +void LoadBackgroundImage(char *filename) { - FILE *f = fopen(filename, "rb"); - if (!f) - { - if (NSTRCMP (filename, "pcb-background.ppm")) - perror(filename); - return; - } - LoadBackgroundFile (f, filename); - fclose(f); + FILE *f = fopen(filename, "rb"); + if (!f) { + if (NSTRCMP(filename, "pcb-background.ppm")) + perror(filename); + return; + } + LoadBackgroundFile(f, filename); + fclose(f); } -static void -DrawBackgroundImage () +static void DrawBackgroundImage() { - int x, y, w, h; - double xscale, yscale; - int pcbwidth = PCB->MaxWidth / view_zoom; - int pcbheight = PCB->MaxHeight / view_zoom; + int x, y, w, h; + double xscale, yscale; + int pcbwidth = PCB->MaxWidth / view_zoom; + int pcbheight = PCB->MaxHeight / view_zoom; - if (!window || !bg) - return; + if (!window || !bg) + return; - if (!bgi || view_width != bgi_w || view_height != bgi_h) - { - if (bgi) - XDestroyImage (bgi); - /* Cheat - get the image, which sets up the format too. */ - bgi = XGetImage (XtDisplay(work_area), - window, - 0, 0, view_width, view_height, - -1, ZPixmap); - bgi_w = view_width; - bgi_h = view_height; - } + if (!bgi || view_width != bgi_w || view_height != bgi_h) { + if (bgi) + XDestroyImage(bgi); + /* Cheat - get the image, which sets up the format too. */ + bgi = XGetImage(XtDisplay(work_area), window, 0, 0, view_width, view_height, -1, ZPixmap); + bgi_w = view_width; + bgi_h = view_height; + } - w = MIN (view_width, pcbwidth); - h = MIN (view_height, pcbheight); + w = MIN(view_width, pcbwidth); + h = MIN(view_height, pcbheight); - xscale = (double)bg_w / PCB->MaxWidth; - yscale = (double)bg_h / PCB->MaxHeight; + xscale = (double) bg_w / PCB->MaxWidth; + yscale = (double) bg_h / PCB->MaxHeight; - for (y=0; y pcb) - sz = pcb; - n = 0; - stdarg (XmNvalue, pos); - stdarg (XmNsliderSize, sz); - stdarg (XmNincrement, view_zoom); - stdarg (XmNpageIncrement, sz); - stdarg (XmNmaximum, pcb); - XtSetValues (s, args, n); + int sz = view * view_zoom; + if (sz > pcb) + sz = pcb; + n = 0; + stdarg(XmNvalue, pos); + stdarg(XmNsliderSize, sz); + stdarg(XmNincrement, view_zoom); + stdarg(XmNpageIncrement, sz); + stdarg(XmNmaximum, pcb); + XtSetValues(s, args, n); } -void -lesstif_pan_fixup () +void lesstif_pan_fixup() { #if 0 - if (view_left_x > PCB->MaxWidth - (view_width * view_zoom)) - view_left_x = PCB->MaxWidth - (view_width * view_zoom); - if (view_top_y > PCB->MaxHeight - (view_height * view_zoom)) - view_top_y = PCB->MaxHeight - (view_height * view_zoom); - if (view_left_x < 0) - view_left_x = 0; - if (view_top_y < 0) - view_top_y = 0; - if (view_width * view_zoom > PCB->MaxWidth - && view_height * view_zoom > PCB->MaxHeight) - { - zoom_by (1, 0, 0); - return; - } + if (view_left_x > PCB->MaxWidth - (view_width * view_zoom)) + view_left_x = PCB->MaxWidth - (view_width * view_zoom); + if (view_top_y > PCB->MaxHeight - (view_height * view_zoom)) + view_top_y = PCB->MaxHeight - (view_height * view_zoom); + if (view_left_x < 0) + view_left_x = 0; + if (view_top_y < 0) + view_top_y = 0; + if (view_width * view_zoom > PCB->MaxWidth && view_height * view_zoom > PCB->MaxHeight) { + zoom_by(1, 0, 0); + return; + } #endif - set_scroll (hscroll, view_left_x, view_width, PCB->MaxWidth); - set_scroll (vscroll, view_top_y, view_height, PCB->MaxHeight); + set_scroll(hscroll, view_left_x, view_width, PCB->MaxWidth); + set_scroll(vscroll, view_top_y, view_height, PCB->MaxHeight); - lesstif_invalidate_all (); + lesstif_invalidate_all(); } -static void -zoom_max () +static void zoom_max() { - double new_zoom = PCB->MaxWidth / view_width; - if (new_zoom < PCB->MaxHeight / view_height) - new_zoom = PCB->MaxHeight / view_height; + double new_zoom = PCB->MaxWidth / view_width; + if (new_zoom < PCB->MaxHeight / view_height) + new_zoom = PCB->MaxHeight / view_height; - view_left_x = -(view_width * new_zoom - PCB->MaxWidth) / 2; - view_top_y = -(view_height * new_zoom - PCB->MaxHeight) / 2; - view_zoom = new_zoom; - pixel_slop = view_zoom; - lesstif_pan_fixup (); + view_left_x = -(view_width * new_zoom - PCB->MaxWidth) / 2; + view_top_y = -(view_height * new_zoom - PCB->MaxHeight) / 2; + view_zoom = new_zoom; + pixel_slop = view_zoom; + lesstif_pan_fixup(); } -static void -zoom_to (double new_zoom, int x, int y) +static void zoom_to(double new_zoom, int x, int y) { - double max_zoom, xfrac, yfrac; - int cx, cy; + double max_zoom, xfrac, yfrac; + int cx, cy; - xfrac = (double) x / (double) view_width; - yfrac = (double) y / (double) view_height; + xfrac = (double) x / (double) view_width; + yfrac = (double) y / (double) view_height; - if (flip_x) - xfrac = 1-xfrac; - if (flip_y) - yfrac = 1-yfrac; + if (flip_x) + xfrac = 1 - xfrac; + if (flip_y) + yfrac = 1 - yfrac; - max_zoom = PCB->MaxWidth / view_width; - if (max_zoom < PCB->MaxHeight / view_height) - max_zoom = PCB->MaxHeight / view_height; + max_zoom = PCB->MaxWidth / view_width; + if (max_zoom < PCB->MaxHeight / view_height) + max_zoom = PCB->MaxHeight / view_height; - max_zoom *= MAX_ZOOM_SCALE; + max_zoom *= MAX_ZOOM_SCALE; - if (new_zoom < 1) - new_zoom = 1; - if (new_zoom > max_zoom) - new_zoom = max_zoom; + if (new_zoom < 1) + new_zoom = 1; + if (new_zoom > max_zoom) + new_zoom = max_zoom; - cx = view_left_x + view_width * xfrac * view_zoom; - cy = view_top_y + view_height * yfrac * view_zoom; + cx = view_left_x + view_width * xfrac * view_zoom; + cy = view_top_y + view_height * yfrac * view_zoom; - if (view_zoom != new_zoom) - { - view_zoom = new_zoom; - pixel_slop = view_zoom; + if (view_zoom != new_zoom) { + view_zoom = new_zoom; + pixel_slop = view_zoom; - view_left_x = cx - view_width * xfrac * view_zoom; - view_top_y = cy - view_height * yfrac * view_zoom; - } - lesstif_pan_fixup (); + view_left_x = cx - view_width * xfrac * view_zoom; + view_top_y = cy - view_height * yfrac * view_zoom; + } + lesstif_pan_fixup(); } -static void -zoom_toggle(int x, int y) +static void zoom_toggle(int x, int y) { - double tmp; + double tmp; - tmp = prev_view_zoom; - prev_view_zoom = view_zoom; - zoom_to(tmp, x, y); + tmp = prev_view_zoom; + prev_view_zoom = view_zoom; + zoom_to(tmp, x, y); } -void -zoom_by (double factor, int x, int y) +void zoom_by(double factor, int x, int y) { - zoom_to (view_zoom * factor, x, y); + zoom_to(view_zoom * factor, x, y); } static int panning = 0; @@ -1277,66 +1186,60 @@ static int alt_pressed; /* X and Y are in screen coordinates. */ -static void -Pan (int mode, int x, int y) +static void Pan(int mode, int x, int y) { - static int ox, oy; - static int opx, opy; + static int ox, oy; + static int opx, opy; - panning = mode; - /* This is for ctrl-pan, where the viewport's position is directly - proportional to the cursor position in the window (like the Xaw - thumb panner) */ - if (pan_thumb_mode) - { - opx = x * PCB->MaxWidth / view_width; - opy = y * PCB->MaxHeight / view_height; - if (flip_x) - opx = PCB->MaxWidth - opx; - if (flip_y) - opy = PCB->MaxHeight - opy; - view_left_x = opx - view_width / 2 * view_zoom; - view_top_y = opy - view_height / 2 * view_zoom; - lesstif_pan_fixup (); - } - /* This is the start of a regular pan. On the first click, we - remember the coordinates where we "grabbed" the screen. */ - else if (mode == 1) - { - ox = x; - oy = y; - opx = view_left_x; - opy = view_top_y; - } - /* continued drag, we calculate how far we've moved the cursor and - set the position accordingly. */ - else - { - if (flip_x) - view_left_x = opx + (x - ox) * view_zoom; - else - view_left_x = opx - (x - ox) * view_zoom; - if (flip_y) - view_top_y = opy + (y - oy) * view_zoom; - else - view_top_y = opy - (y - oy) * view_zoom; - lesstif_pan_fixup (); - } + panning = mode; + /* This is for ctrl-pan, where the viewport's position is directly + proportional to the cursor position in the window (like the Xaw + thumb panner) */ + if (pan_thumb_mode) { + opx = x * PCB->MaxWidth / view_width; + opy = y * PCB->MaxHeight / view_height; + if (flip_x) + opx = PCB->MaxWidth - opx; + if (flip_y) + opy = PCB->MaxHeight - opy; + view_left_x = opx - view_width / 2 * view_zoom; + view_top_y = opy - view_height / 2 * view_zoom; + lesstif_pan_fixup(); + } + /* This is the start of a regular pan. On the first click, we + remember the coordinates where we "grabbed" the screen. */ + else if (mode == 1) { + ox = x; + oy = y; + opx = view_left_x; + opy = view_top_y; + } + /* continued drag, we calculate how far we've moved the cursor and + set the position accordingly. */ + else { + if (flip_x) + view_left_x = opx + (x - ox) * view_zoom; + else + view_left_x = opx - (x - ox) * view_zoom; + if (flip_y) + view_top_y = opy + (y - oy) * view_zoom; + else + view_top_y = opy - (y - oy) * view_zoom; + lesstif_pan_fixup(); + } } -static void -mod_changed (XKeyEvent * e, int set) +static void mod_changed(XKeyEvent * e, int set) { - switch (XKeycodeToKeysym (display, e->keycode, 0)) - { - case XK_Shift_L: - case XK_Shift_R: - shift_pressed = set; - break; - case XK_Control_L: - case XK_Control_R: - ctrl_pressed = set; - break; + switch (XKeycodeToKeysym(display, e->keycode, 0)) { + case XK_Shift_L: + case XK_Shift_R: + shift_pressed = set; + break; + case XK_Control_L: + case XK_Control_R: + ctrl_pressed = set; + break; #ifdef __APPLE__ case XK_Mode_switch: #else @@ -1343,625 +1246,572 @@ case XK_Alt_L: case XK_Alt_R: #endif - alt_pressed = set; - break; - default: - /* to include the Apple keyboard left and right command keys use XK_Meta_L and XK_Meta_R respectivly. */ - return; - } - in_move_event = 1; - notify_crosshair_change (false); - if (panning) - Pan (2, e->x, e->y); - EventMoveCrosshair (Px (e->x), Py (e->y)); - AdjustAttachedObjects (); - notify_crosshair_change (true); - in_move_event = 0; + alt_pressed = set; + break; + default: + /* to include the Apple keyboard left and right command keys use XK_Meta_L and XK_Meta_R respectivly. */ + return; + } + in_move_event = 1; + notify_crosshair_change(false); + if (panning) + Pan(2, e->x, e->y); + EventMoveCrosshair(Px(e->x), Py(e->y)); + AdjustAttachedObjects(); + notify_crosshair_change(true); + in_move_event = 0; } -static void -work_area_input (Widget w, XtPointer v, XEvent * e, Boolean * ctd) +static void work_area_input(Widget w, XtPointer v, XEvent * e, Boolean * ctd) { - static int pressed_button = 0; - static int ignore_release = 0; + static int pressed_button = 0; + static int ignore_release = 0; - show_crosshair (0); - switch (e->type) - { - case KeyPress: - mod_changed (&(e->xkey), 1); - if (lesstif_key_event (&(e->xkey))) - return; - break; + show_crosshair(0); + switch (e->type) { + case KeyPress: + mod_changed(&(e->xkey), 1); + if (lesstif_key_event(&(e->xkey))) + return; + break; - case KeyRelease: - mod_changed (&(e->xkey), 0); - break; + case KeyRelease: + mod_changed(&(e->xkey), 0); + break; - case ButtonPress: - { - int mods; - if (pressed_button) - return; - /*printf("click %d\n", e->xbutton.button); */ - if (lesstif_button_event (w, e)) - { - ignore_release = 1; - return; - } - ignore_release = 0; + case ButtonPress: + { + int mods; + if (pressed_button) + return; + /*printf("click %d\n", e->xbutton.button); */ + if (lesstif_button_event(w, e)) { + ignore_release = 1; + return; + } + ignore_release = 0; - notify_crosshair_change (false); - pressed_button = e->xbutton.button; - mods = ((e->xbutton.state & ShiftMask) ? M_Shift : 0) - + ((e->xbutton.state & ControlMask) ? M_Ctrl : 0) + notify_crosshair_change(false); + pressed_button = e->xbutton.button; + mods = ((e->xbutton.state & ShiftMask) ? M_Shift : 0) + + ((e->xbutton.state & ControlMask) ? M_Ctrl : 0) #ifdef __APPLE__ - + ((e->xbutton.state & (1<<13)) ? M_Alt : 0); + + ((e->xbutton.state & (1 << 13)) ? M_Alt : 0); #else - + ((e->xbutton.state & Mod1Mask) ? M_Alt : 0); + + ((e->xbutton.state & Mod1Mask) ? M_Alt : 0); #endif - do_mouse_action(e->xbutton.button, mods); - notify_crosshair_change (true); - break; - } + do_mouse_action(e->xbutton.button, mods); + notify_crosshair_change(true); + break; + } - case ButtonRelease: - { - int mods; - if (e->xbutton.button != pressed_button) - return; - lesstif_button_event (w, e); - notify_crosshair_change (false); - pressed_button = 0; - mods = ((e->xbutton.state & ShiftMask) ? M_Shift : 0) - + ((e->xbutton.state & ControlMask) ? M_Ctrl : 0) + case ButtonRelease: + { + int mods; + if (e->xbutton.button != pressed_button) + return; + lesstif_button_event(w, e); + notify_crosshair_change(false); + pressed_button = 0; + mods = ((e->xbutton.state & ShiftMask) ? M_Shift : 0) + + ((e->xbutton.state & ControlMask) ? M_Ctrl : 0) #ifdef __APPLE__ - + ((e->xbutton.state & (1<<13)) ? M_Alt : 0) + + ((e->xbutton.state & (1 << 13)) ? M_Alt : 0) #else - + ((e->xbutton.state & Mod1Mask) ? M_Alt : 0) + + ((e->xbutton.state & Mod1Mask) ? M_Alt : 0) #endif - + M_Release; - do_mouse_action (e->xbutton.button, mods); - notify_crosshair_change (true); - break; - } + + M_Release; + do_mouse_action(e->xbutton.button, mods); + notify_crosshair_change(true); + break; + } - case MotionNotify: - { - Window root, child; - unsigned int keys_buttons; - int root_x, root_y, pos_x, pos_y; - while (XCheckMaskEvent (display, PointerMotionMask, e)); - XQueryPointer (display, e->xmotion.window, &root, &child, - &root_x, &root_y, &pos_x, &pos_y, &keys_buttons); - shift_pressed = (keys_buttons & ShiftMask); - ctrl_pressed = (keys_buttons & ControlMask); + case MotionNotify: + { + Window root, child; + unsigned int keys_buttons; + int root_x, root_y, pos_x, pos_y; + while (XCheckMaskEvent(display, PointerMotionMask, e)); + XQueryPointer(display, e->xmotion.window, &root, &child, &root_x, &root_y, &pos_x, &pos_y, &keys_buttons); + shift_pressed = (keys_buttons & ShiftMask); + ctrl_pressed = (keys_buttons & ControlMask); #ifdef __APPLE__ - alt_pressed = (keys_buttons & (1<<13)); + alt_pressed = (keys_buttons & (1 << 13)); #else - alt_pressed = (keys_buttons & Mod1Mask); + alt_pressed = (keys_buttons & Mod1Mask); #endif - /*pcb_printf("m %#mS %#mS\n", Px(e->xmotion.x), Py(e->xmotion.y)); */ - crosshair_in_window = 1; - in_move_event = 1; - if (panning) - Pan (2, pos_x, pos_y); - EventMoveCrosshair (Px (pos_x), Py (pos_y)); - in_move_event = 0; - } - break; + /*pcb_printf("m %#mS %#mS\n", Px(e->xmotion.x), Py(e->xmotion.y)); */ + crosshair_in_window = 1; + in_move_event = 1; + if (panning) + Pan(2, pos_x, pos_y); + EventMoveCrosshair(Px(pos_x), Py(pos_y)); + in_move_event = 0; + } + break; - case LeaveNotify: - crosshair_in_window = 0; - ShowCrosshair (false); - need_idle_proc (); - break; + case LeaveNotify: + crosshair_in_window = 0; + ShowCrosshair(false); + need_idle_proc(); + break; - case EnterNotify: - crosshair_in_window = 1; - in_move_event = 1; - EventMoveCrosshair (Px (e->xcrossing.x), Py (e->xcrossing.y)); - ShowCrosshair (true); - in_move_event = 0; - need_idle_proc (); - break; + case EnterNotify: + crosshair_in_window = 1; + in_move_event = 1; + EventMoveCrosshair(Px(e->xcrossing.x), Py(e->xcrossing.y)); + ShowCrosshair(true); + in_move_event = 0; + need_idle_proc(); + break; - default: - printf ("work_area: unknown event %d\n", e->type); - break; - } + default: + printf("work_area: unknown event %d\n", e->type); + break; + } } -static void -draw_right_cross (GC xor_gc, int x, int y, - int view_width, int view_height) +static void draw_right_cross(GC xor_gc, int x, int y, int view_width, int view_height) { - XDrawLine (display, window, xor_gc, 0, y, view_width, y); - XDrawLine (display, window, xor_gc, x, 0, x, view_height); + XDrawLine(display, window, xor_gc, 0, y, view_width, y); + XDrawLine(display, window, xor_gc, x, 0, x, view_height); } -static void -draw_slanted_cross (GC xor_gc, int x, int y, - int view_width, int view_height) +static void draw_slanted_cross(GC xor_gc, int x, int y, int view_width, int view_height) { - int x0, y0, x1, y1; + int x0, y0, x1, y1; - x0 = x + (view_height - y); - x0 = MAX(0, MIN (x0, view_width)); - x1 = x - y; - x1 = MAX(0, MIN (x1, view_width)); - y0 = y + (view_width - x); - y0 = MAX(0, MIN (y0, view_height)); - y1 = y - x; - y1 = MAX(0, MIN (y1, view_height)); - XDrawLine (display, window, xor_gc, x0, y0, x1, y1); - x0 = x - (view_height - y); - x0 = MAX(0, MIN (x0, view_width)); - x1 = x + y; - x1 = MAX(0, MIN (x1, view_width)); - y0 = y + x; - y0 = MAX(0, MIN (y0, view_height)); - y1 = y - (view_width - x); - y1 = MAX(0, MIN (y1, view_height)); - XDrawLine (display, window, xor_gc, x0, y0, x1, y1); + x0 = x + (view_height - y); + x0 = MAX(0, MIN(x0, view_width)); + x1 = x - y; + x1 = MAX(0, MIN(x1, view_width)); + y0 = y + (view_width - x); + y0 = MAX(0, MIN(y0, view_height)); + y1 = y - x; + y1 = MAX(0, MIN(y1, view_height)); + XDrawLine(display, window, xor_gc, x0, y0, x1, y1); + x0 = x - (view_height - y); + x0 = MAX(0, MIN(x0, view_width)); + x1 = x + y; + x1 = MAX(0, MIN(x1, view_width)); + y0 = y + x; + y0 = MAX(0, MIN(y0, view_height)); + y1 = y - (view_width - x); + y1 = MAX(0, MIN(y1, view_height)); + XDrawLine(display, window, xor_gc, x0, y0, x1, y1); } -static void -draw_dozen_cross (GC xor_gc, int x, int y, - int view_width, int view_height) +static void draw_dozen_cross(GC xor_gc, int x, int y, int view_width, int view_height) { - int x0, y0, x1, y1; - double tan60 = sqrt (3); + int x0, y0, x1, y1; + double tan60 = sqrt(3); - x0 = x + (view_height - y) / tan60; - x0 = MAX(0, MIN (x0, view_width)); - x1 = x - y / tan60; - x1 = MAX(0, MIN (x1, view_width)); - y0 = y + (view_width - x) * tan60; - y0 = MAX(0, MIN (y0, view_height)); - y1 = y - x * tan60; - y1 = MAX(0, MIN (y1, view_height)); - XDrawLine (display, window, xor_gc, x0, y0, x1, y1); + x0 = x + (view_height - y) / tan60; + x0 = MAX(0, MIN(x0, view_width)); + x1 = x - y / tan60; + x1 = MAX(0, MIN(x1, view_width)); + y0 = y + (view_width - x) * tan60; + y0 = MAX(0, MIN(y0, view_height)); + y1 = y - x * tan60; + y1 = MAX(0, MIN(y1, view_height)); + XDrawLine(display, window, xor_gc, x0, y0, x1, y1); - x0 = x + (view_height - y) * tan60; - x0 = MAX(0, MIN (x0, view_width)); - x1 = x - y * tan60; - x1 = MAX(0, MIN (x1, view_width)); - y0 = y + (view_width - x) / tan60; - y0 = MAX(0, MIN (y0, view_height)); - y1 = y - x / tan60; - y1 = MAX(0, MIN (y1, view_height)); - XDrawLine (display, window, xor_gc, x0, y0, x1, y1); + x0 = x + (view_height - y) * tan60; + x0 = MAX(0, MIN(x0, view_width)); + x1 = x - y * tan60; + x1 = MAX(0, MIN(x1, view_width)); + y0 = y + (view_width - x) / tan60; + y0 = MAX(0, MIN(y0, view_height)); + y1 = y - x / tan60; + y1 = MAX(0, MIN(y1, view_height)); + XDrawLine(display, window, xor_gc, x0, y0, x1, y1); - x0 = x - (view_height - y) / tan60; - x0 = MAX(0, MIN (x0, view_width)); - x1 = x + y / tan60; - x1 = MAX(0, MIN (x1, view_width)); - y0 = y + x * tan60; - y0 = MAX(0, MIN (y0, view_height)); - y1 = y - (view_width - x) * tan60; - y1 = MAX(0, MIN (y1, view_height)); - XDrawLine (display, window, xor_gc, x0, y0, x1, y1); + x0 = x - (view_height - y) / tan60; + x0 = MAX(0, MIN(x0, view_width)); + x1 = x + y / tan60; + x1 = MAX(0, MIN(x1, view_width)); + y0 = y + x * tan60; + y0 = MAX(0, MIN(y0, view_height)); + y1 = y - (view_width - x) * tan60; + y1 = MAX(0, MIN(y1, view_height)); + XDrawLine(display, window, xor_gc, x0, y0, x1, y1); - x0 = x - (view_height - y) * tan60; - x0 = MAX(0, MIN (x0, view_width)); - x1 = x + y * tan60; - x1 = MAX(0, MIN (x1, view_width)); - y0 = y + x / tan60; - y0 = MAX(0, MIN (y0, view_height)); - y1 = y - (view_width - x) / tan60; - y1 = MAX(0, MIN (y1, view_height)); - XDrawLine (display, window, xor_gc, x0, y0, x1, y1); + x0 = x - (view_height - y) * tan60; + x0 = MAX(0, MIN(x0, view_width)); + x1 = x + y * tan60; + x1 = MAX(0, MIN(x1, view_width)); + y0 = y + x / tan60; + y0 = MAX(0, MIN(y0, view_height)); + y1 = y - (view_width - x) / tan60; + y1 = MAX(0, MIN(y1, view_height)); + XDrawLine(display, window, xor_gc, x0, y0, x1, y1); } -static void -draw_crosshair (GC xor_gc, int x, int y, - int view_width, int view_height) +static void draw_crosshair(GC xor_gc, int x, int y, int view_width, int view_height) { - draw_right_cross (xor_gc, x, y, view_width, view_height); - if (Crosshair.shape == Union_Jack_Crosshair_Shape) - draw_slanted_cross (xor_gc, x, y, view_width, view_height); - if (Crosshair.shape == Dozen_Crosshair_Shape) - draw_dozen_cross (xor_gc, x, y, view_width, view_height); + draw_right_cross(xor_gc, x, y, view_width, view_height); + if (Crosshair.shape == Union_Jack_Crosshair_Shape) + draw_slanted_cross(xor_gc, x, y, view_width, view_height); + if (Crosshair.shape == Dozen_Crosshair_Shape) + draw_dozen_cross(xor_gc, x, y, view_width, view_height); } -void -lesstif_show_crosshair (int show) + +void lesstif_show_crosshair(int show) { - static int showing = 0; - static int sx, sy; - static GC xor_gc = 0; - Pixel crosshair_color; + static int showing = 0; + static int sx, sy; + static GC xor_gc = 0; + Pixel crosshair_color; - if (!crosshair_in_window || !window) - return; - if (xor_gc == 0) - { - crosshair_color = lesstif_parse_color (Settings.CrosshairColor) ^ bgcolor; - xor_gc = XCreateGC (display, window, 0, 0); - XSetFunction (display, xor_gc, GXxor); - XSetForeground (display, xor_gc, crosshair_color); - } - if (show == showing) - return; - if (show) - { - sx = Vx (crosshair_x); - sy = Vy (crosshair_y); - } - else - need_idle_proc (); - draw_crosshair (xor_gc, sx, sy, view_width, view_height); - showing = show; + if (!crosshair_in_window || !window) + return; + if (xor_gc == 0) { + crosshair_color = lesstif_parse_color(Settings.CrosshairColor) ^ bgcolor; + xor_gc = XCreateGC(display, window, 0, 0); + XSetFunction(display, xor_gc, GXxor); + XSetForeground(display, xor_gc, crosshair_color); + } + if (show == showing) + return; + if (show) { + sx = Vx(crosshair_x); + sy = Vy(crosshair_y); + } + else + need_idle_proc(); + draw_crosshair(xor_gc, sx, sy, view_width, view_height); + showing = show; } -static void -work_area_expose (Widget work_area, void *me, - XmDrawingAreaCallbackStruct * cbs) +static void work_area_expose(Widget work_area, void *me, XmDrawingAreaCallbackStruct * cbs) { - XExposeEvent *e; + XExposeEvent *e; - show_crosshair (0); - e = &(cbs->event->xexpose); - XSetFunction (display, my_gc, GXcopy); - XCopyArea (display, main_pixmap, window, my_gc, - e->x, e->y, e->width, e->height, e->x, e->y); - show_crosshair (1); + show_crosshair(0); + e = &(cbs->event->xexpose); + XSetFunction(display, my_gc, GXcopy); + XCopyArea(display, main_pixmap, window, my_gc, e->x, e->y, e->width, e->height, e->x, e->y); + show_crosshair(1); } -static void -scroll_callback (Widget scroll, int *view_dim, - XmScrollBarCallbackStruct * cbs) +static void scroll_callback(Widget scroll, int *view_dim, XmScrollBarCallbackStruct * cbs) { - *view_dim = cbs->value; - lesstif_invalidate_all (); + *view_dim = cbs->value; + lesstif_invalidate_all(); } -static void -work_area_make_pixmaps (Dimension width, Dimension height) +static void work_area_make_pixmaps(Dimension width, Dimension height) { - if (main_pixmap) - XFreePixmap (display, main_pixmap); - main_pixmap = - XCreatePixmap (display, window, width, height, - XDefaultDepth (display, screen)); + if (main_pixmap) + XFreePixmap(display, main_pixmap); + main_pixmap = XCreatePixmap(display, window, width, height, XDefaultDepth(display, screen)); - if (mask_pixmap) - XFreePixmap (display, mask_pixmap); - mask_pixmap = - XCreatePixmap (display, window, width, height, - XDefaultDepth (display, screen)); + if (mask_pixmap) + XFreePixmap(display, mask_pixmap); + mask_pixmap = XCreatePixmap(display, window, width, height, XDefaultDepth(display, screen)); #ifdef HAVE_XRENDER - if (main_picture) - { - XRenderFreePicture (display, main_picture); - main_picture = 0; - } - if (mask_picture) - { - XRenderFreePicture (display, mask_picture); - mask_picture = 0; - } - if (use_xrender) - { - main_picture = XRenderCreatePicture (display, main_pixmap, - XRenderFindVisualFormat(display, - DefaultVisual(display, screen)), 0, 0); - mask_picture = XRenderCreatePicture (display, mask_pixmap, - XRenderFindVisualFormat(display, - DefaultVisual(display, screen)), 0, 0); - if (!main_picture || !mask_picture) - use_xrender = 0; - } + if (main_picture) { + XRenderFreePicture(display, main_picture); + main_picture = 0; + } + if (mask_picture) { + XRenderFreePicture(display, mask_picture); + mask_picture = 0; + } + if (use_xrender) { + main_picture = XRenderCreatePicture(display, main_pixmap, + XRenderFindVisualFormat(display, DefaultVisual(display, screen)), 0, 0); + mask_picture = XRenderCreatePicture(display, mask_pixmap, + XRenderFindVisualFormat(display, DefaultVisual(display, screen)), 0, 0); + if (!main_picture || !mask_picture) + use_xrender = 0; + } #endif /* HAVE_XRENDER */ - if (mask_bitmap) - XFreePixmap (display, mask_bitmap); - mask_bitmap = XCreatePixmap (display, window, width, height, 1); + if (mask_bitmap) + XFreePixmap(display, mask_bitmap); + mask_bitmap = XCreatePixmap(display, window, width, height, 1); - pixmap = use_mask ? main_pixmap : mask_pixmap; - pixmap_w = width; - pixmap_h = height; + pixmap = use_mask ? main_pixmap : mask_pixmap; + pixmap_w = width; + pixmap_h = height; } -static void -work_area_resize (Widget work_area, void *me, - XmDrawingAreaCallbackStruct * cbs) +static void work_area_resize(Widget work_area, void *me, XmDrawingAreaCallbackStruct * cbs) { - XColor color; - Dimension width, height; + XColor color; + Dimension width, height; - show_crosshair (0); + show_crosshair(0); - n = 0; - stdarg (XtNwidth, &width); - stdarg (XtNheight, &height); - stdarg (XmNbackground, &bgcolor); - XtGetValues (work_area, args, n); - view_width = width; - view_height = height; + n = 0; + stdarg(XtNwidth, &width); + stdarg(XtNheight, &height); + stdarg(XmNbackground, &bgcolor); + XtGetValues(work_area, args, n); + view_width = width; + view_height = height; - color.pixel = bgcolor; - XQueryColor (display, colormap, &color); - bgred = color.red; - bggreen = color.green; - bgblue = color.blue; + color.pixel = bgcolor; + XQueryColor(display, colormap, &color); + bgred = color.red; + bggreen = color.green; + bgblue = color.blue; - if (!window) - return; + if (!window) + return; - work_area_make_pixmaps (view_width, view_height); + work_area_make_pixmaps(view_width, view_height); - zoom_by (1, 0, 0); + zoom_by(1, 0, 0); } -static void -work_area_first_expose (Widget work_area, void *me, - XmDrawingAreaCallbackStruct * cbs) +static void work_area_first_expose(Widget work_area, void *me, XmDrawingAreaCallbackStruct * cbs) { - int c; - Dimension width, height; - static char dashes[] = { 4, 4 }; + int c; + Dimension width, height; + static char dashes[] = { 4, 4 }; - window = XtWindow (work_area); - my_gc = XCreateGC (display, window, 0, 0); + window = XtWindow(work_area); + my_gc = XCreateGC(display, window, 0, 0); - arc1_gc = XCreateGC (display, window, 0, 0); - c = lesstif_parse_color ("#804000"); - XSetForeground (display, arc1_gc, c); - arc2_gc = XCreateGC (display, window, 0, 0); - c = lesstif_parse_color ("#004080"); - XSetForeground (display, arc2_gc, c); - XSetLineAttributes (display, arc1_gc, 1, LineOnOffDash, 0, 0); - XSetLineAttributes (display, arc2_gc, 1, LineOnOffDash, 0, 0); - XSetDashes (display, arc1_gc, 0, dashes, 2); - XSetDashes (display, arc2_gc, 0, dashes, 2); + arc1_gc = XCreateGC(display, window, 0, 0); + c = lesstif_parse_color("#804000"); + XSetForeground(display, arc1_gc, c); + arc2_gc = XCreateGC(display, window, 0, 0); + c = lesstif_parse_color("#004080"); + XSetForeground(display, arc2_gc, c); + XSetLineAttributes(display, arc1_gc, 1, LineOnOffDash, 0, 0); + XSetLineAttributes(display, arc2_gc, 1, LineOnOffDash, 0, 0); + XSetDashes(display, arc1_gc, 0, dashes, 2); + XSetDashes(display, arc2_gc, 0, dashes, 2); - n = 0; - stdarg (XtNwidth, &width); - stdarg (XtNheight, &height); - stdarg (XmNbackground, &bgcolor); - XtGetValues (work_area, args, n); - view_width = width; - view_height = height; + n = 0; + stdarg(XtNwidth, &width); + stdarg(XtNheight, &height); + stdarg(XmNbackground, &bgcolor); + XtGetValues(work_area, args, n); + view_width = width; + view_height = height; - offlimit_color = lesstif_parse_color (Settings.OffLimitColor); - grid_color = lesstif_parse_color (Settings.GridColor); + offlimit_color = lesstif_parse_color(Settings.OffLimitColor); + grid_color = lesstif_parse_color(Settings.GridColor); - bg_gc = XCreateGC (display, window, 0, 0); - XSetForeground (display, bg_gc, bgcolor); + bg_gc = XCreateGC(display, window, 0, 0); + XSetForeground(display, bg_gc, bgcolor); - work_area_make_pixmaps (width, height); + work_area_make_pixmaps(width, height); #ifdef HAVE_XRENDER - if (use_xrender) - { - XRenderPictureAttributes pa; - XRenderColor a = {0, 0, 0, 0x8000}; + if (use_xrender) { + XRenderPictureAttributes pa; + XRenderColor a = { 0, 0, 0, 0x8000 }; - pale_pixmap = XCreatePixmap (display, window, 1, 1, 8); - pa.repeat = True; - pale_picture = XRenderCreatePicture (display, pale_pixmap, - XRenderFindStandardFormat(display, PictStandardA8), - CPRepeat, &pa); - if (pale_picture) - XRenderFillRectangle(display, PictOpSrc, pale_picture, &a, 0, 0, 1, 1); - else - use_xrender = 0; - } + pale_pixmap = XCreatePixmap(display, window, 1, 1, 8); + pa.repeat = True; + pale_picture = XRenderCreatePicture(display, pale_pixmap, + XRenderFindStandardFormat(display, PictStandardA8), CPRepeat, &pa); + if (pale_picture) + XRenderFillRectangle(display, PictOpSrc, pale_picture, &a, 0, 0, 1, 1); + else + use_xrender = 0; + } #endif /* HAVE_XRENDER */ - clip_gc = XCreateGC (display, window, 0, 0); - bset_gc = XCreateGC (display, mask_bitmap, 0, 0); - XSetForeground (display, bset_gc, 1); - bclear_gc = XCreateGC (display, mask_bitmap, 0, 0); - XSetForeground (display, bclear_gc, 0); + clip_gc = XCreateGC(display, window, 0, 0); + bset_gc = XCreateGC(display, mask_bitmap, 0, 0); + XSetForeground(display, bset_gc, 1); + bclear_gc = XCreateGC(display, mask_bitmap, 0, 0); + XSetForeground(display, bclear_gc, 0); - XtRemoveCallback (work_area, XmNexposeCallback, - (XtCallbackProc) work_area_first_expose, 0); - XtAddCallback (work_area, XmNexposeCallback, - (XtCallbackProc) work_area_expose, 0); - lesstif_invalidate_all (); + XtRemoveCallback(work_area, XmNexposeCallback, (XtCallbackProc) work_area_first_expose, 0); + XtAddCallback(work_area, XmNexposeCallback, (XtCallbackProc) work_area_expose, 0); + lesstif_invalidate_all(); } -static Widget -make_message (char *name, Widget left, int resizeable) +static Widget make_message(char *name, Widget left, int resizeable) { - Widget w, f; - n = 0; - if (left) - { - stdarg (XmNleftAttachment, XmATTACH_WIDGET); - stdarg (XmNleftWidget, XtParent(left)); - } - else - { - stdarg (XmNleftAttachment, XmATTACH_FORM); - } - stdarg (XmNtopAttachment, XmATTACH_FORM); - stdarg (XmNbottomAttachment, XmATTACH_FORM); - stdarg (XmNshadowType, XmSHADOW_IN); - stdarg (XmNshadowThickness, 1); - stdarg (XmNalignment, XmALIGNMENT_CENTER); - stdarg (XmNmarginWidth, 4); - stdarg (XmNmarginHeight, 1); - if (!resizeable) - stdarg (XmNresizePolicy, XmRESIZE_GROW); - f = XmCreateForm (messages, name, args, n); - XtManageChild (f); - n = 0; - stdarg (XmNtopAttachment, XmATTACH_FORM); - stdarg (XmNbottomAttachment, XmATTACH_FORM); - stdarg (XmNleftAttachment, XmATTACH_FORM); - stdarg (XmNrightAttachment, XmATTACH_FORM); - w = XmCreateLabel (f, name, args, n); - XtManageChild (w); - return w; + Widget w, f; + n = 0; + if (left) { + stdarg(XmNleftAttachment, XmATTACH_WIDGET); + stdarg(XmNleftWidget, XtParent(left)); + } + else { + stdarg(XmNleftAttachment, XmATTACH_FORM); + } + stdarg(XmNtopAttachment, XmATTACH_FORM); + stdarg(XmNbottomAttachment, XmATTACH_FORM); + stdarg(XmNshadowType, XmSHADOW_IN); + stdarg(XmNshadowThickness, 1); + stdarg(XmNalignment, XmALIGNMENT_CENTER); + stdarg(XmNmarginWidth, 4); + stdarg(XmNmarginHeight, 1); + if (!resizeable) + stdarg(XmNresizePolicy, XmRESIZE_GROW); + f = XmCreateForm(messages, name, args, n); + XtManageChild(f); + n = 0; + stdarg(XmNtopAttachment, XmATTACH_FORM); + stdarg(XmNbottomAttachment, XmATTACH_FORM); + stdarg(XmNleftAttachment, XmATTACH_FORM); + stdarg(XmNrightAttachment, XmATTACH_FORM); + w = XmCreateLabel(f, name, args, n); + XtManageChild(w); + return w; } extern Widget lesstif_menubar; -static void -lesstif_do_export (HID_Attr_Val * options) +static void lesstif_do_export(HID_Attr_Val * options) { - Dimension width, height; - Widget menu; - Widget work_area_frame; + Dimension width, height; + Widget menu; + Widget work_area_frame; - n = 0; - stdarg (XtNwidth, &width); - stdarg (XtNheight, &height); - XtGetValues (appwidget, args, n); + n = 0; + stdarg(XtNwidth, &width); + stdarg(XtNheight, &height); + XtGetValues(appwidget, args, n); - if (width < 1) - width = 640; - if (width > XDisplayWidth (display, screen)) - width = XDisplayWidth (display, screen); - if (height < 1) - height = 480; - if (height > XDisplayHeight (display, screen)) - height = XDisplayHeight (display, screen); + if (width < 1) + width = 640; + if (width > XDisplayWidth(display, screen)) + width = XDisplayWidth(display, screen); + if (height < 1) + height = 480; + if (height > XDisplayHeight(display, screen)) + height = XDisplayHeight(display, screen); - n = 0; - stdarg (XmNwidth, width); - stdarg (XmNheight, height); - XtSetValues (appwidget, args, n); + n = 0; + stdarg(XmNwidth, width); + stdarg(XmNheight, height); + XtSetValues(appwidget, args, n); - stdarg (XmNspacing, 0); - mainwind = XmCreateMainWindow (appwidget, "mainWind", args, n); - XtManageChild (mainwind); + stdarg(XmNspacing, 0); + mainwind = XmCreateMainWindow(appwidget, "mainWind", args, n); + XtManageChild(mainwind); - n = 0; - stdarg (XmNmarginWidth, 0); - stdarg (XmNmarginHeight, 0); - menu = lesstif_menu (mainwind, "menubar", args, n); - XtManageChild (menu); + n = 0; + stdarg(XmNmarginWidth, 0); + stdarg(XmNmarginHeight, 0); + menu = lesstif_menu(mainwind, "menubar", args, n); + XtManageChild(menu); - n = 0; - stdarg (XmNshadowType, XmSHADOW_IN); - work_area_frame = - XmCreateFrame (mainwind, "work_area_frame", args, n); - XtManageChild (work_area_frame); + n = 0; + stdarg(XmNshadowType, XmSHADOW_IN); + work_area_frame = XmCreateFrame(mainwind, "work_area_frame", args, n); + XtManageChild(work_area_frame); - n = 0; - do_color (Settings.BackgroundColor, XmNbackground); - work_area = XmCreateDrawingArea (work_area_frame, "work_area", args, n); - XtManageChild (work_area); - XtAddCallback (work_area, XmNexposeCallback, - (XtCallbackProc) work_area_first_expose, 0); - XtAddCallback (work_area, XmNresizeCallback, - (XtCallbackProc) work_area_resize, 0); - /* A regular callback won't work here, because lesstif swallows any - Ctrl