Index: trunk/src/hid_draw_helpers.c =================================================================== --- trunk/src/hid_draw_helpers.c (revision 15546) +++ trunk/src/hid_draw_helpers.c (revision 15547) @@ -2,9 +2,6 @@ #include "hid.h" #include "polygon.h" #include "macro.h" - -#include "obj_pinvia.h" -#include "obj_pad.h" #include "obj_poly.h" static void fill_contour(pcb_hid_gc_t gc, pcb_pline_t * pl) @@ -180,266 +177,8 @@ pcb_poly_holes(poly, clip_box, thindraw_hole_cb, gc); } -void pcb_dhlp_thindraw_pcb_pad(pcb_hid_gc_t gc, pcb_pad_t * pad, pcb_bool clear, pcb_bool mask) -{ - pcb_coord_t w = clear ? (mask ? pad->Mask : pad->Thickness + pad->Clearance) - : pad->Thickness; - pcb_coord_t x1, y1, x2, y2; - pcb_coord_t t = w / 2; - x1 = pad->Point1.X; - y1 = pad->Point1.Y; - x2 = pad->Point2.X; - y2 = pad->Point2.Y; - if (x1 > x2 || y1 > y2) { - pcb_coord_t temp_x = x1; - pcb_coord_t temp_y = y1; - x1 = x2; - x2 = temp_x; - y1 = y2; - y2 = temp_y; - } - pcb_gui->set_line_cap(gc, Round_Cap); - pcb_gui->set_line_width(gc, 0); - if (PCB_FLAG_TEST(PCB_FLAG_SQUARE, pad)) { - /* slanted square pad */ - double tx, ty, theta; - - 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); - - pcb_gui->draw_line(gc, x1 - tx, y1 - ty, x2 + ty, y2 - tx); - pcb_gui->draw_line(gc, x2 + ty, y2 - tx, x2 + tx, y2 + ty); - pcb_gui->draw_line(gc, x2 + tx, y2 + ty, x1 - ty, y1 + tx); - pcb_gui->draw_line(gc, x1 - ty, y1 + tx, x1 - tx, y1 - ty); - } - else if (x1 == x2 && y1 == y2) { - pcb_gui->draw_arc(gc, x1, y1, t, t, 0, 360); - } - else { - /* Slanted round-end pads. */ - pcb_coord_t dx, dy, ox, oy; - double h; - - dx = x2 - x1; - dy = y2 - y1; - h = t / sqrt(PCB_SQUARE(dx) + PCB_SQUARE(dy)); - ox = dy * h + 0.5 * SGN(dy); - oy = -(dx * h + 0.5 * SGN(dx)); - - pcb_gui->draw_line(gc, x1 + ox, y1 + oy, x2 + ox, y2 + oy); - - if (labs(ox) >= pcb_pixel_slop || coord_abs(oy) >= pcb_pixel_slop) { - pcb_angle_t angle = atan2(dx, dy) * 57.295779; - pcb_gui->draw_line(gc, x1 - ox, y1 - oy, x2 - ox, y2 - oy); - pcb_gui->draw_arc(gc, x1, y1, t, t, angle - 180, 180); - pcb_gui->draw_arc(gc, x2, y2, t, t, angle, 180); - } - } -} - -void pcb_dhlp_fill_pcb_pad(pcb_hid_gc_t gc, pcb_pad_t * pad, pcb_bool clear, pcb_bool mask) -{ - pcb_coord_t 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 (PCB_FLAG_TEST(PCB_FLAG_SQUARE, pad)) { - pcb_coord_t l, r, t, b; - l = pad->Point1.X - w / 2; - b = pad->Point1.Y - w / 2; - r = l + w; - t = b + w; - pcb_gui->fill_rect(gc, l, b, r, t); - } - else { - pcb_gui->fill_circle(gc, pad->Point1.X, pad->Point1.Y, w / 2); - } - } - else { - pcb_gui->set_line_cap(gc, PCB_FLAG_TEST(PCB_FLAG_SQUARE, pad) ? Square_Cap : Round_Cap); - pcb_gui->set_line_width(gc, w); - - pcb_gui->draw_line(gc, pad->Point1.X, pad->Point1.Y, pad->Point2.X, pad->Point2.Y); - } -} - -/* --------------------------------------------------------------------------- - * draws one polygon - * x and y are already in display coordinates - * the points are numbered: - * - * 5 --- 6 - * / \ - * 4 7 - * | | - * 3 0 - * \ / - * 2 --- 1 - */ - -typedef struct { - double X, Y; -} FloatPolyType; - -static void draw_square_pin_poly(pcb_hid_gc_t gc, pcb_coord_t X, pcb_coord_t Y, pcb_coord_t Thickness, pcb_coord_t thin_draw, int style) -{ - static FloatPolyType p[8] = { - {0.5, -PCB_TAN_22_5_DEGREE_2}, - {PCB_TAN_22_5_DEGREE_2, -0.5}, - {-PCB_TAN_22_5_DEGREE_2, -0.5}, - {-0.5, -PCB_TAN_22_5_DEGREE_2}, - {-0.5, PCB_TAN_22_5_DEGREE_2}, - {-PCB_TAN_22_5_DEGREE_2, 0.5}, - {PCB_TAN_22_5_DEGREE_2, 0.5}, - {0.5, PCB_TAN_22_5_DEGREE_2} - }; - static int special_size = 0; - static int scaled_x[8]; - static int scaled_y[8]; - pcb_coord_t polygon_x[9]; - pcb_coord_t polygon_y[9]; - double xm[8], ym[8]; - int i; - - pcb_poly_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 (thin_draw) { - int i; - pcb_gui->set_line_cap(gc, Round_Cap); - pcb_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++) - pcb_gui->draw_line(gc, polygon_x[i], polygon_y[i], polygon_x[i + 1], polygon_y[i + 1]); - } - else - pcb_gui->fill_polygon(gc, 8, polygon_x, polygon_y); -} - -static void draw_octagon_poly(pcb_hid_gc_t gc, pcb_coord_t X, pcb_coord_t Y, pcb_coord_t Thickness, pcb_coord_t thin_draw) -{ - draw_square_pin_poly(gc, X, Y, Thickness, thin_draw, 17); -} - - -void pcb_dhlp_fill_pcb_pv(pcb_hid_gc_t fg_gc, pcb_hid_gc_t bg_gc, pcb_pin_t * pv, pcb_bool drawHole, pcb_bool mask) -{ - pcb_coord_t w = mask ? pv->Mask : pv->Thickness; - pcb_coord_t r = w / 2; - - if (PCB_FLAG_TEST(PCB_FLAG_HOLE, pv)) { - if (mask) - pcb_gui->fill_circle(bg_gc, pv->X, pv->Y, r); - if (drawHole) { - pcb_gui->fill_circle(bg_gc, pv->X, pv->Y, r); - pcb_gui->set_line_cap(fg_gc, Round_Cap); - pcb_gui->set_line_width(fg_gc, 0); - pcb_gui->draw_arc(fg_gc, pv->X, pv->Y, r, r, 0, 360); - } - return; - } - - if (PCB_FLAG_TEST(PCB_FLAG_SQUARE, pv)) { - /* use the original code for now */ - if ((PCB_FLAG_SQUARE_GET(pv) == 0) || (PCB_FLAG_SQUARE_GET(pv) == 1)) { - pcb_coord_t l = pv->X - r; - pcb_coord_t b = pv->Y - r; - pcb_coord_t r = l + w; - pcb_coord_t t = b + w; - pcb_gui->fill_rect(fg_gc, l, b, r, t); - } - else - draw_square_pin_poly(fg_gc, pv->X, pv->Y, w, pcb_false, PCB_FLAG_SQUARE_GET(pv)); - } - else if (PCB_FLAG_TEST(PCB_FLAG_OCTAGON, pv)) - draw_octagon_poly(fg_gc, pv->X, pv->Y, w, pcb_false); - else /* draw a round pin or via */ - pcb_gui->fill_circle(fg_gc, pv->X, pv->Y, r); - - /* and the drilling hole (which is always round) */ - if (drawHole) - pcb_gui->fill_circle(bg_gc, pv->X, pv->Y, pv->DrillingHole / 2); -} - -void pcb_dhlp_thindraw_pcb_pv(pcb_hid_gc_t fg_gc, pcb_hid_gc_t bg_gc, pcb_pin_t * pv, pcb_bool drawHole, pcb_bool mask) -{ - pcb_coord_t w = mask ? pv->Mask : pv->Thickness; - pcb_coord_t r = w / 2; - - if (PCB_FLAG_TEST(PCB_FLAG_HOLE, pv)) { - if (mask) - pcb_gui->draw_arc(fg_gc, pv->X, pv->Y, r, r, 0, 360); - if (drawHole) { - r = pv->DrillingHole / 2; - pcb_gui->set_line_cap(bg_gc, Round_Cap); - pcb_gui->set_line_width(bg_gc, 0); - pcb_gui->draw_arc(bg_gc, pv->X, pv->Y, r, r, 0, 360); - } - return; - } - - if (PCB_FLAG_TEST(PCB_FLAG_SQUARE, pv)) { - if ((PCB_FLAG_SQUARE_GET(pv) == 0) || (PCB_FLAG_SQUARE_GET(pv) == 1)) { - pcb_coord_t l = pv->X - r; - pcb_coord_t b = pv->Y - r; - pcb_coord_t r = l + w; - pcb_coord_t t = b + w; - - pcb_gui->set_line_cap(fg_gc, Round_Cap); - pcb_gui->set_line_width(fg_gc, 0); - pcb_gui->draw_line(fg_gc, r, t, r, b); - pcb_gui->draw_line(fg_gc, l, t, l, b); - pcb_gui->draw_line(fg_gc, r, t, l, t); - pcb_gui->draw_line(fg_gc, r, b, l, b); - } - else - draw_square_pin_poly(fg_gc, pv->X, pv->Y, w, pcb_true, PCB_FLAG_SQUARE_GET(pv)); - - } - else if (PCB_FLAG_TEST(PCB_FLAG_OCTAGON, pv)) { - draw_octagon_poly(fg_gc, pv->X, pv->Y, w, pcb_true); - } - else { /* draw a round pin or via */ - - pcb_gui->set_line_cap(fg_gc, Round_Cap); - pcb_gui->set_line_width(fg_gc, 0); - pcb_gui->draw_arc(fg_gc, pv->X, pv->Y, r, r, 0, 360); - } - - /* and the drilling hole (which is always round */ - if (drawHole) { - pcb_gui->set_line_cap(bg_gc, Round_Cap); - pcb_gui->set_line_width(bg_gc, 0); - pcb_gui->draw_arc(bg_gc, pv->X, pv->Y, pv->DrillingHole / 2, pv->DrillingHole / 2, 0, 360); - } -} - void pcb_dhlp_draw_helpers_init(pcb_hid_t * hid) { hid->fill_pcb_polygon = pcb_dhlp_fill_pcb_polygon; hid->thindraw_pcb_polygon = pcb_dhlp_thindraw_pcb_polygon; - hid->fill_pcb_pad = pcb_dhlp_fill_pcb_pad; - hid->thindraw_pcb_pad = pcb_dhlp_thindraw_pcb_pad; - hid->fill_pcb_pv = pcb_dhlp_fill_pcb_pv; - hid->thindraw_pcb_pv = pcb_dhlp_thindraw_pcb_pv; } Index: trunk/src/hid_draw_helpers.h =================================================================== --- trunk/src/hid_draw_helpers.h (revision 15546) +++ trunk/src/hid_draw_helpers.h (revision 15547) @@ -2,9 +2,5 @@ #define PCB_HID_DRAW_HELPERS_H void pcb_dhlp_fill_pcb_polygon(pcb_hid_gc_t gc, pcb_poly_t * poly, const pcb_box_t * clip_box); void pcb_dhlp_thindraw_pcb_polygon(pcb_hid_gc_t gc, pcb_poly_t * poly, const pcb_box_t * clip_box); -void pcb_dhlp_fill_pcb_pad(pcb_hid_gc_t gc, pcb_pad_t * pad, pcb_bool clear, pcb_bool mask); -void pcb_dhlp_thindraw_pcb_pad(pcb_hid_gc_t gc, pcb_pad_t * pad, pcb_bool clear, pcb_bool mask); -void pcb_dhlp_fill_pcb_pv(pcb_hid_gc_t gc, pcb_pin_t * pv, pcb_bool drawHole, pcb_bool mask); -void pcb_dhlp_thindraw_pcb_pv(pcb_hid_gc_t fg_gc, pcb_hid_gc_t bg_gc, pcb_pin_t * pv, pcb_bool drawHole, pcb_bool mask); void pcb_dhlp_draw_helpers_init(pcb_hid_t * hid); #endif