Index: trunk/src/action.c =================================================================== --- trunk/src/action.c (revision 6) +++ trunk/src/action.c (revision 7) @@ -4855,11 +4855,18 @@ 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 (ChangeObjectSquare (type, ptr1, ptr2, ptr3)) - SetChangedFlag (true); + + type = SearchScreen (x, y, CHANGESQUARE_TYPES, + &ptr1, &ptr2, &ptr3); + { + 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; } Index: trunk/src/change.c =================================================================== --- trunk/src/change.c (revision 6) +++ trunk/src/change.c (revision 7) @@ -1448,7 +1448,11 @@ AddObjectToClearPolyUndoList (PIN_TYPE, Element, Pin, Pin, false); RestoreToPolygon (PCB->Data, PIN_TYPE, Element, Pin); AddObjectToFlagUndoList (PIN_TYPE, Element, Pin, Pin); - TOGGLE_FLAG (SQUAREFLAG, Pin); + ASSIGN_SQUARE(Absolute, Pin); + if (Absolute == 0) + CLEAR_FLAG (SQUAREFLAG, Pin); + else + SET_FLAG (SQUAREFLAG, Pin); AddObjectToClearPolyUndoList (PIN_TYPE, Element, Pin, Pin, true); ClearFromPolygon (PCB->Data, PIN_TYPE, Element, Pin); DrawPin (Pin); @@ -2159,8 +2163,9 @@ * Returns true if anything is changed */ bool -ChangeObjectSquare (int Type, void *Ptr1, void *Ptr2, void *Ptr3) +ChangeObjectSquare (int Type, void *Ptr1, void *Ptr2, void *Ptr3, int style) { + Absolute = style; if (ObjectOperation (&ChangeSquareFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL) { Index: trunk/src/change.h =================================================================== --- trunk/src/change.h (revision 6) +++ trunk/src/change.h (revision 7) @@ -98,7 +98,7 @@ bool ChangeObjectJoin (int, void *, void *, void *); bool SetObjectJoin (int, void *, void *, void *); bool ClrObjectJoin (int, void *, void *, void *); -bool ChangeObjectSquare (int, void *, void *, void *); +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 *); Index: trunk/src/global.h =================================================================== --- trunk/src/global.h (revision 6) +++ trunk/src/global.h (revision 7) @@ -120,6 +120,7 @@ { unsigned long f; /* generic flags */ unsigned char t[(MAX_LAYER + 1) / 2]; /* thermals */ + unsigned char q; /* square geometry flag */ } FlagType, *FlagTypePtr; #ifndef __GNUC__ Index: trunk/src/hid/common/draw_helpers.c =================================================================== --- trunk/src/hid/common/draw_helpers.c (revision 6) +++ trunk/src/hid/common/draw_helpers.c (revision 7) @@ -371,6 +371,94 @@ gui->fill_polygon (gc, 8, polygon_x, polygon_y); } + +/* --------------------------------------------------------------------------- + * draws one 'square' polygon distorted depending on the style + * x and y are already in display coordinates + * the points are numbered: + * + * 5 --- 6 + * / \ + * 4 7 + * | | + * 3 0 + * \ / + * 2 --- 1 + */ + +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]; + const double factor = 2.0; + int i; + + /* reset multipliers */ + for (i = 0; i < 8; i++) { + xm[i] = 1; + ym[i] = 1; + } + + style--; + if (style & 1) + xm[0] = xm[1] = xm[6] = xm[7] = factor; + if (style & 2) + xm[2] = xm[3] = xm[4] = xm[5] = factor; + if (style & 4) + ym[4] = ym[5] = ym[6] = ym[7] = factor; + if (style & 8) + ym[0] = ym[1] = ym[2] = ym[3] = factor; + + + + 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); +} + + void common_fill_pcb_pv (hidGC fg_gc, hidGC bg_gc, PinType *pv, bool drawHole, bool mask) { @@ -393,12 +481,16 @@ if (TEST_FLAG (SQUAREFLAG, pv)) { - 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); + /* 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); Index: trunk/src/macro.h =================================================================== --- trunk/src/macro.h (revision 6) +++ trunk/src/macro.h (revision 7) @@ -118,6 +118,12 @@ #define CLEAR_THERM(L,P) (P)->Flags.t[(L)/2] &= ~THERMFLAG(L) #define ASSIGN_THERM(L,V,P) (P)->Flags.t[(L)/2] = ((P)->Flags.t[(L)/2] & ~THERMFLAG(L)) | ((V) << (4 * ((L) % 2))) + +#define GET_SQUARE(P) ((P)->Flags.q) +#define CLEAR_SQUARE(P) (P)->Flags.q = 0 +#define ASSIGN_SQUARE(V,P) (P)->Flags.q = V + + extern int mem_any_set (unsigned char *, int); #define TEST_ANY_THERMS(P) mem_any_set((P)->Flags.t, sizeof((P)->Flags.t)) Index: trunk/src/polygon.c =================================================================== --- trunk/src/polygon.c (revision 6) +++ trunk/src/polygon.c (revision 7) @@ -360,6 +360,7 @@ { PLINE *contour = NULL; Vector v; + double xm[8], ym[8]; v[0] = x + ROUND (radius * 0.5); v[1] = y + ROUND (radius * TAN_22_5_DEGREE_2); Index: trunk/src/undo.h =================================================================== --- trunk/src/undo.h (revision 6) +++ trunk/src/undo.h (revision 7) @@ -33,7 +33,7 @@ #include "global.h" -#define DRAW_FLAGS (RATFLAG | SELECTEDFLAG | SQUAREFLAG \ +#define DRAW_FLAGS (RATFLAG | SELECTEDFLAG \ | HIDENAMEFLAG | HOLEFLAG | OCTAGONFLAG | FOUNDFLAG | CLEARLINEFLAG) /* different layers */