Index: trunk/src_plugins/boardflip/boardflip.c =================================================================== --- trunk/src_plugins/boardflip/boardflip.c (revision 7945) +++ trunk/src_plugins/boardflip/boardflip.c (revision 7946) @@ -56,29 +56,29 @@ rats */ -#define FLIP(y) (y) = h - (y) -#define NEG(y) (y) = - (y) +#define XFLIP(v) v = ((flip_x ? -(v) : (v)) + xo) +#define YFLIP(v) v = ((flip_y ? -(v) : (v)) + yo) +#define AFLIP(a) (a) = - (a) +#define ONLY1 ((flip_x || flip_y) && (!flip_x && !flip_y)) -static int boardflip(int argc, const char **argv, pcb_coord_t x, pcb_coord_t y) +void pcb_flip_data(pcb_data_t *data, pcb_bool flip_x, pcb_bool flip_y, pcb_coord_t xo, pcb_coord_t yo, pcb_bool elem_swap_sides) { - int h = PCB->MaxHeight; - int sides = 0; - - if (argc > 0 && pcb_strcasecmp(argv[0], "sides") == 0) - sides = 1; - printf("argc %d argv %s sides %d\n", argc, argc > 0 ? argv[0] : "", sides); - LAYER_LOOP(PCB->Data, pcb_max_layer); + LAYER_LOOP(data, pcb_max_layer); { PCB_LINE_LOOP(layer); { - FLIP(line->Point1.Y); - FLIP(line->Point2.Y); + XFLIP(line->Point1.X); + XFLIP(line->Point2.X); + YFLIP(line->Point1.Y); + YFLIP(line->Point2.Y); } PCB_END_LOOP; PCB_TEXT_LOOP(layer); { - FLIP(text->Y); - PCB_FLAG_TOGGLE(PCB_FLAG_ONSOLDER, text); + XFLIP(text->X); + YFLIP(text->Y); + if (ONLY1) + PCB_FLAG_TOGGLE(PCB_FLAG_ONSOLDER, text); } PCB_END_LOOP; PCB_POLY_LOOP(layer); @@ -86,83 +86,116 @@ int i, j; PCB_POLY_POINT_LOOP(polygon); { - FLIP(point->Y); + XFLIP(point->X); + YFLIP(point->Y); } PCB_END_LOOP; - i = 0; - j = polygon->PointN - 1; - while (i < j) { - pcb_point_t p = polygon->Points[i]; - polygon->Points[i] = polygon->Points[j]; - polygon->Points[j] = p; - i++; - j--; + if (ONLY1) { + i = 0; + j = polygon->PointN - 1; + while (i < j) { + pcb_point_t p = polygon->Points[i]; + polygon->Points[i] = polygon->Points[j]; + polygon->Points[j] = p; + i++; + j--; + } } - pcb_poly_init_clip(PCB->Data, layer, polygon); + pcb_poly_init_clip(data, layer, polygon); } PCB_END_LOOP; PCB_ARC_LOOP(layer); { - FLIP(arc->Y); - NEG(arc->StartAngle); - NEG(arc->Delta); + XFLIP(arc->X); + YFLIP(arc->Y); + if (ONLY1) { + AFLIP(arc->StartAngle); + AFLIP(arc->Delta); + } } PCB_END_LOOP; } PCB_END_LOOP; - PCB_VIA_LOOP(PCB->Data); + PCB_VIA_LOOP(data); { - FLIP(via->Y); + XFLIP(via->X); + YFLIP(via->Y); } PCB_END_LOOP; - PCB_ELEMENT_LOOP(PCB->Data); + PCB_ELEMENT_LOOP(data); { - FLIP(element->MarkY); - if (sides) + XFLIP(element->MarkX); + YFLIP(element->MarkY); + if ((elem_swap_sides) && (ONLY1)) PCB_FLAG_TOGGLE(PCB_FLAG_ONSOLDER, element); PCB_ELEMENT_PCB_TEXT_LOOP(element); { - FLIP(text->Y); - PCB_FLAG_TOGGLE(PCB_FLAG_ONSOLDER, text); + XFLIP(text->X); + YFLIP(text->Y); + if (ONLY1) + PCB_FLAG_TOGGLE(PCB_FLAG_ONSOLDER, text); } PCB_END_LOOP; PCB_ELEMENT_PCB_LINE_LOOP(element); { - FLIP(line->Point1.Y); - FLIP(line->Point2.Y); + XFLIP(line->Point1.X); + XFLIP(line->Point2.X); + YFLIP(line->Point1.Y); + YFLIP(line->Point2.Y); } PCB_END_LOOP; PCB_ELEMENT_ARC_LOOP(element); { - FLIP(arc->Y); - NEG(arc->StartAngle); - NEG(arc->Delta); + XFLIP(arc->X); + YFLIP(arc->Y); + if (ONLY1) { + AFLIP(arc->StartAngle); + AFLIP(arc->Delta); + } } PCB_END_LOOP; PCB_PIN_LOOP(element); { - FLIP(pin->Y); + XFLIP(pin->X); + YFLIP(pin->Y); } PCB_END_LOOP; PCB_PAD_LOOP(element); { - FLIP(pad->Point1.Y); - FLIP(pad->Point2.Y); - if (sides) + XFLIP(pad->Point1.X); + XFLIP(pad->Point2.X); + YFLIP(pad->Point1.Y); + YFLIP(pad->Point2.Y); + if ((elem_swap_sides) && (ONLY1)) PCB_FLAG_TOGGLE(PCB_FLAG_ONSOLDER, pad); } PCB_END_LOOP; } PCB_END_LOOP; - PCB_RAT_LOOP(PCB->Data); + PCB_RAT_LOOP(data); { - FLIP(line->Point1.Y); - FLIP(line->Point2.Y); + XFLIP(line->Point1.X); + XFLIP(line->Point2.X); + YFLIP(line->Point1.Y); + YFLIP(line->Point2.Y); } PCB_END_LOOP; return 0; } +static int boardflip(int argc, const char **argv, pcb_coord_t x, pcb_coord_t y) +{ + int h = PCB->MaxHeight; + int sides = 0; + + if (argc > 0 && pcb_strcasecmp(argv[0], "sides") == 0) + sides = 1; + printf("argc %d argv %s sides %d\n", argc, argc > 0 ? argv[0] : "", sides); + pcb_flip_data(PCB->Data, pcb_false, pcb_true, 0, h, sides); + return 0; +} + + static pcb_hid_action_t boardflip_action_list[] = { {"BoardFlip", NULL, boardflip, NULL, NULL} };