Index: trunk/doc-rnd/hacking/renames =================================================================== --- trunk/doc-rnd/hacking/renames (revision 4839) +++ trunk/doc-rnd/hacking/renames (revision 4840) @@ -132,3 +132,10 @@ AttributeGet -> pcb_attrib_get AttributePut -> pcb_attrib_put AttributeRemove -> pcb_attrib_remove +FreePCBMemory -> pcb_board_free +CreateNewPCB_ -> pcb_board_new_ +CreateNewPCB -> pcb_board_new +CreateNewPCBPost -> pcb_board_new_postproc +CountHoles -> pcb_board_count_holes +SWAP_X -> PCB_SWAP_X +SWAP_Y -> PCB_SWAP_Y Index: trunk/src/board.c =================================================================== --- trunk/src/board.c (revision 4839) +++ trunk/src/board.c (revision 4840) @@ -35,10 +35,7 @@ pcb_board_t *PCB; -/* --------------------------------------------------------------------------- - * free memory used by PCB - */ -void FreePCBMemory(pcb_board_t * pcb) +void pcb_board_free(pcb_board_t * pcb) { int i; @@ -63,7 +60,7 @@ } /* creates a new PCB */ -pcb_board_t *CreateNewPCB_(pcb_bool SetDefaultNames) +pcb_board_t *pcb_board_new_(pcb_bool SetDefaultNames) { pcb_board_t *ptr, *save; int i; @@ -109,7 +106,7 @@ return (ptr); } -pcb_board_t *CreateNewPCB(void) +pcb_board_t *pcb_board_new(void) { pcb_board_t *old, *nw; int dpcb; @@ -139,11 +136,7 @@ return nw; } - -/* This post-processing step adds the top and bottom silk layers to a - * pre-existing PCB. - */ -int CreateNewPCBPost(pcb_board_t *pcb, int use_defaults) +int pcb_board_new_postproc(pcb_board_t *pcb, int use_defaults) { /* copy default settings */ pcb_colors_from_settings(pcb); @@ -151,10 +144,6 @@ return 0; } -/* --------------------------------------------------------------------------- - * Perhaps PCB should internally just use the Settings colors? For now, - * use this to set PCB colors so the config can reassign PCB colors. - */ #warning TODO: indeed, remove this and all the board *color fields void pcb_colors_from_settings(pcb_board_t *ptr) { @@ -203,13 +192,7 @@ return R_DIR_FOUND_CONTINUE; } - -/* --------------------------------------------------------------------------- - * counts the number of plated and unplated holes in the design within - * a given area of the board. To count for the whole board, pass NULL - * within_area. - */ -void CountHoles(int *plated, int *unplated, const pcb_box_t * within_area) +void pcb_board_count_holes(int *plated, int *unplated, const pcb_box_t * within_area) { HoleCountStruct hcs = { 0, 0 }; Index: trunk/src/board.h =================================================================== --- trunk/src/board.h (revision 4839) +++ trunk/src/board.h (revision 4840) @@ -109,22 +109,31 @@ unsigned netlist_needs_update:1; }; -void FreePCBMemory(pcb_board_t *); - extern pcb_board_t *PCB; /* the board being edited */ -pcb_board_t *CreateNewPCB_(pcb_bool SetDefaultNames); -pcb_board_t *CreateNewPCB(void); +/* free memory used by a board */ +void pcb_board_free(pcb_board_t *pcb); +/* creates a new PCB - low level */ +pcb_board_t *pcb_board_new_(pcb_bool SetDefaultNames); + +/* creates a new PCB - high level (uses a template board) */ +pcb_board_t *pcb_board_new(void); + /* Called after PCB->Data->LayerN is set. Returns non-zero on error */ -int CreateNewPCBPost(pcb_board_t *pcb, int use_defaults); +int pcb_board_new_postproc(pcb_board_t *pcb, int use_defaults); +/* 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(pcb_board_t *); -void CountHoles(int *plated, int *unplated, const pcb_box_t * within_area); +/* counts the number of plated and unplated holes in the design within + a given area of the board. To count for the whole board, pass NULL + within_area. */ +void pcb_board_count_holes(int *plated, int *unplated, const pcb_box_t * within_area); -#define SWAP_X(x) (SWAP_SIGN_X(x)) -#define SWAP_Y(y) (PCB->MaxHeight +SWAP_SIGN_Y(y)) +#define PCB_SWAP_X(x) (SWAP_SIGN_X(x)) +#define PCB_SWAP_Y(y) (PCB->MaxHeight +SWAP_SIGN_Y(y)) const char *pcb_board_get_filename(void); const char *pcb_board_get_name(void); Index: trunk/src/buffer.c =================================================================== --- trunk/src/buffer.c (revision 4839) +++ trunk/src/buffer.c (revision 4840) @@ -195,7 +195,7 @@ */ pcb_bool LoadLayoutToBuffer(pcb_buffer_t *Buffer, const char *Filename, const char *fmt) { - pcb_board_t *newPCB = CreateNewPCB(); + pcb_board_t *newPCB = pcb_board_new(); /* new data isn't added to the undo list */ if (!ParsePCB(newPCB, Filename, fmt, CFR_invalid)) { @@ -413,26 +413,26 @@ } } /* set buffer offset to 'mark' position */ - Buffer->X = SWAP_X(Buffer->X); - Buffer->Y = SWAP_Y(Buffer->Y); + Buffer->X = PCB_SWAP_X(Buffer->X); + Buffer->Y = PCB_SWAP_Y(Buffer->Y); VIA_LOOP(Buffer->Data); { - via->X = SWAP_X(via->X); - via->Y = SWAP_Y(via->Y); + via->X = PCB_SWAP_X(via->X); + via->Y = PCB_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); + line->Point1.X = PCB_SWAP_X(line->Point1.X); + line->Point1.Y = PCB_SWAP_Y(line->Point1.Y); + line->Point2.X = PCB_SWAP_X(line->Point2.X); + line->Point2.Y = PCB_SWAP_Y(line->Point2.Y); } ENDALL_LOOP; ALLARC_LOOP(Buffer->Data); { - arc->X = SWAP_X(arc->X); - arc->Y = SWAP_Y(arc->Y); + arc->X = PCB_SWAP_X(arc->X); + arc->Y = PCB_SWAP_Y(arc->Y); arc->StartAngle = SWAP_ANGLE(arc->StartAngle); arc->Delta = SWAP_DELTA(arc->Delta); SetArcBoundingBox(arc); @@ -442,8 +442,8 @@ { POLYGONPOINT_LOOP(polygon); { - point->X = SWAP_X(point->X); - point->Y = SWAP_Y(point->Y); + point->X = PCB_SWAP_X(point->X); + point->Y = PCB_SWAP_Y(point->Y); } END_LOOP; SetPolygonBoundingBox(polygon); @@ -469,13 +469,13 @@ } END_LOOP; /* set buffer offset to 'mark' position */ - Buffer->X = SWAP_X(Buffer->X); - Buffer->Y = SWAP_Y(Buffer->Y); + Buffer->X = PCB_SWAP_X(Buffer->X); + Buffer->Y = PCB_SWAP_Y(Buffer->Y); VIA_LOOP(Buffer->Data); { r_delete_entry(Buffer->Data->via_tree, (pcb_box_t *) via); - via->X = SWAP_X(via->X); - via->Y = SWAP_Y(via->Y); + via->X = PCB_SWAP_X(via->X); + via->Y = PCB_SWAP_Y(via->Y); SetPinBoundingBox(via); r_insert_entry(Buffer->Data->via_tree, (pcb_box_t *) via, 0); } @@ -483,10 +483,10 @@ ALLLINE_LOOP(Buffer->Data); { r_delete_entry(layer->line_tree, (pcb_box_t *) 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); + line->Point1.X = PCB_SWAP_X(line->Point1.X); + line->Point1.Y = PCB_SWAP_Y(line->Point1.Y); + line->Point2.X = PCB_SWAP_X(line->Point2.X); + line->Point2.Y = PCB_SWAP_Y(line->Point2.Y); SetLineBoundingBox(line); r_insert_entry(layer->line_tree, (pcb_box_t *) line, 0); } @@ -494,8 +494,8 @@ ALLARC_LOOP(Buffer->Data); { r_delete_entry(layer->arc_tree, (pcb_box_t *) arc); - arc->X = SWAP_X(arc->X); - arc->Y = SWAP_Y(arc->Y); + arc->X = PCB_SWAP_X(arc->X); + arc->Y = PCB_SWAP_Y(arc->Y); arc->StartAngle = SWAP_ANGLE(arc->StartAngle); arc->Delta = SWAP_DELTA(arc->Delta); SetArcBoundingBox(arc); @@ -507,8 +507,8 @@ r_delete_entry(layer->polygon_tree, (pcb_box_t *) polygon); POLYGONPOINT_LOOP(polygon); { - point->X = SWAP_X(point->X); - point->Y = SWAP_Y(point->Y); + point->X = PCB_SWAP_X(point->X); + point->Y = PCB_SWAP_Y(point->Y); } END_LOOP; SetPolygonBoundingBox(polygon); @@ -519,8 +519,8 @@ ALLTEXT_LOOP(Buffer->Data); { r_delete_entry(layer->text_tree, (pcb_box_t *) text); - text->X = SWAP_X(text->X); - text->Y = SWAP_Y(text->Y); + text->X = PCB_SWAP_X(text->X); + text->Y = PCB_SWAP_Y(text->Y); TOGGLE_FLAG(PCB_FLAG_ONSOLDER, text); SetTextBoundingBox(&PCB->Font, text); r_insert_entry(layer->text_tree, (pcb_box_t *) text, 0); Index: trunk/src/draw.c =================================================================== --- trunk/src/draw.c (revision 4839) +++ trunk/src/draw.c (revision 4840) @@ -159,7 +159,7 @@ static void DrawEverything_holes(const pcb_box_t * drawn_area) { int plated, unplated; - CountHoles(&plated, &unplated, drawn_area); + pcb_board_count_holes(&plated, &unplated, drawn_area); if (plated && gui->set_layer("plated-drill", SL(PDRILL, 0), 0)) { DrawHoles(pcb_true, pcb_false, drawn_area); Index: trunk/src/file_act.c =================================================================== --- trunk/src/file_act.c (revision 4839) +++ trunk/src/file_act.c (revision 4840) @@ -189,8 +189,8 @@ if (PCB->Changed && conf_core.editor.save_in_tmp) SaveInTMP(); RemovePCB(PCB); - PCB = CreateNewPCB(); - CreateNewPCBPost(PCB, 1); + PCB = pcb_board_new(); + pcb_board_new_postproc(PCB, 1); /* setup the new name and reset some values to default */ free(PCB->Name); Index: trunk/src/main.c =================================================================== --- trunk/src/main.c (revision 4839) +++ trunk/src/main.c (revision 4840) @@ -223,7 +223,7 @@ * Because it removes some false positives from heap bug detectors such as * lib dmalloc. */ - FreePCBMemory(PCB); + pcb_board_free(PCB); free(PCB); PCB = NULL; @@ -436,7 +436,7 @@ gui->parse_arguments(&hid_argc, &hid_argv); /* Create a new PCB object in memory */ - PCB = CreateNewPCB(); + PCB = pcb_board_new(); if (PCB == NULL) { Message(PCB_MSG_ERROR, "Can't load the default pcb for creating an empty layout\n"); @@ -444,7 +444,7 @@ } /* Add silk layers to newly created PCB */ - CreateNewPCBPost(PCB, 1); + pcb_board_new_postproc(PCB, 1); if (hid_argc > 0) command_line_pcb = hid_argv[0]; Index: trunk/src/obj_elem.c =================================================================== --- trunk/src/obj_elem.c (revision 4839) +++ trunk/src/obj_elem.c (revision 4840) @@ -667,33 +667,33 @@ r_delete_element(Data, Element); ELEMENTLINE_LOOP(Element); { - line->Point1.X = SWAP_X(line->Point1.X); - line->Point1.Y = SWAP_Y(line->Point1.Y) + yoff; - line->Point2.X = SWAP_X(line->Point2.X); - line->Point2.Y = SWAP_Y(line->Point2.Y) + yoff; + line->Point1.X = PCB_SWAP_X(line->Point1.X); + line->Point1.Y = PCB_SWAP_Y(line->Point1.Y) + yoff; + line->Point2.X = PCB_SWAP_X(line->Point2.X); + line->Point2.Y = PCB_SWAP_Y(line->Point2.Y) + yoff; } END_LOOP; PIN_LOOP(Element); { RestoreToPolygon(Data, PCB_TYPE_PIN, Element, pin); - pin->X = SWAP_X(pin->X); - pin->Y = SWAP_Y(pin->Y) + yoff; + pin->X = PCB_SWAP_X(pin->X); + pin->Y = PCB_SWAP_Y(pin->Y) + yoff; } END_LOOP; PAD_LOOP(Element); { RestoreToPolygon(Data, PCB_TYPE_PAD, Element, pad); - pad->Point1.X = SWAP_X(pad->Point1.X); - pad->Point1.Y = SWAP_Y(pad->Point1.Y) + yoff; - pad->Point2.X = SWAP_X(pad->Point2.X); - pad->Point2.Y = SWAP_Y(pad->Point2.Y) + yoff; + pad->Point1.X = PCB_SWAP_X(pad->Point1.X); + pad->Point1.Y = PCB_SWAP_Y(pad->Point1.Y) + yoff; + pad->Point2.X = PCB_SWAP_X(pad->Point2.X); + pad->Point2.Y = PCB_SWAP_Y(pad->Point2.Y) + yoff; TOGGLE_FLAG(PCB_FLAG_ONSOLDER, pad); } END_LOOP; ARC_LOOP(Element); { - arc->X = SWAP_X(arc->X); - arc->Y = SWAP_Y(arc->Y) + yoff; + arc->X = PCB_SWAP_X(arc->X); + arc->Y = PCB_SWAP_Y(arc->Y) + yoff; arc->StartAngle = SWAP_ANGLE(arc->StartAngle); arc->Delta = SWAP_DELTA(arc->Delta); } @@ -700,13 +700,13 @@ END_LOOP; ELEMENTTEXT_LOOP(Element); { - text->X = SWAP_X(text->X); - text->Y = SWAP_Y(text->Y) + yoff; + text->X = PCB_SWAP_X(text->X); + text->Y = PCB_SWAP_Y(text->Y) + yoff; TOGGLE_FLAG(PCB_FLAG_ONSOLDER, text); } END_LOOP; - Element->MarkX = SWAP_X(Element->MarkX); - Element->MarkY = SWAP_Y(Element->MarkY) + yoff; + Element->MarkX = PCB_SWAP_X(Element->MarkX); + Element->MarkY = PCB_SWAP_Y(Element->MarkY) + yoff; /* now toggle the solder-side flag */ TOGGLE_FLAG(PCB_FLAG_ONSOLDER, Element); Index: trunk/src/plug_io.c =================================================================== --- trunk/src/plug_io.c (revision 4839) +++ trunk/src/plug_io.c (revision 4840) @@ -289,7 +289,7 @@ { const char *unit_suffix; char *new_filename; - pcb_board_t *newPCB = CreateNewPCB_(pcb_false); + pcb_board_t *newPCB = pcb_board_new_(pcb_false); pcb_board_t *oldPCB; conf_role_t settings_dest; #ifdef DEBUG @@ -318,7 +318,7 @@ if (!ParsePCB(PCB, new_filename, fmt, settings_dest)) { RemovePCB(oldPCB); - CreateNewPCBPost(PCB, 0); + pcb_board_new_postproc(PCB, 0); ResetStackAndVisibility(); if (how == 0) { @@ -378,7 +378,7 @@ PCB = oldPCB; if (PCB == NULL) { /* bozo: we are trying to revert back to a non-existing pcb... create one to avoid a segfault */ - PCB = CreateNewPCB_(pcb_false); + PCB = pcb_board_new_(pcb_false); if (PCB == NULL) { Message(PCB_MSG_DEFAULT, "FATAL: can't create a new empty pcb!"); exit(1); Index: trunk/src/remove.c =================================================================== --- trunk/src/remove.c (revision 4839) +++ trunk/src/remove.c (revision 4840) @@ -75,7 +75,7 @@ void RemovePCB(pcb_board_t *Ptr) { ClearUndoList(pcb_true); - FreePCBMemory(Ptr); + pcb_board_free(Ptr); free(Ptr); } Index: trunk/src_plugins/io_pcb/file.c =================================================================== --- trunk/src_plugins/io_pcb/file.c (revision 4839) +++ trunk/src_plugins/io_pcb/file.c (revision 4840) @@ -564,7 +564,7 @@ if (!yyPCB) return; - CreateNewPCBPost(yyPCB, 0); + pcb_board_new_postproc(yyPCB, 0); ParseGroupString("1,c:2,s", &yyPCB->LayerGroups, yyData->LayerN); e = elementlist_first(&yyPCB->Data->Element); /* we know there's only one */ PCB = yyPCB; Index: trunk/src_plugins/io_pcb/parse_y.c =================================================================== --- trunk/src_plugins/io_pcb/parse_y.c (revision 4839) +++ trunk/src_plugins/io_pcb/parse_y.c (revision 4840) @@ -1816,7 +1816,7 @@ pcb_board_t *pcb_save = PCB; if ((yy_settings_dest != CFR_invalid) && (layer_group_string != NULL)) conf_set(yy_settings_dest, "design/groups", -1, layer_group_string, POL_OVERWRITE); - CreateNewPCBPost (yyPCB, 0); + pcb_board_new_postproc(yyPCB, 0); if (ParseGroupString(layer_group_string, &yyPCB->LayerGroups, yyData->LayerN)) { Message(PCB_MSG_ERROR, "illegal layer-group string\n"); Index: trunk/src_plugins/io_pcb/parse_y.y =================================================================== --- trunk/src_plugins/io_pcb/parse_y.y (revision 4839) +++ trunk/src_plugins/io_pcb/parse_y.y (revision 4840) @@ -199,7 +199,7 @@ pcb_board_t *pcb_save = PCB; if ((yy_settings_dest != CFR_invalid) && (layer_group_string != NULL)) conf_set(yy_settings_dest, "design/groups", -1, layer_group_string, POL_OVERWRITE); - CreateNewPCBPost (yyPCB, 0); + pcb_board_new_postproc(yyPCB, 0); if (ParseGroupString(layer_group_string, &yyPCB->LayerGroups, yyData->LayerN)) { Message(PCB_MSG_ERROR, "illegal layer-group string\n");