Index: trunk/src/draw.c =================================================================== --- trunk/src/draw.c (revision 19586) +++ trunk/src/draw.c (revision 19587) @@ -1086,7 +1086,7 @@ if (pcb_gui->gui) pcb_draw_doing_pinout++; - pcb_text_draw_string(info, font, label, x, y, scale, direction, mirror, 1, 0, 0, 0, 0, PCB_TXT_TINY_HIDE); + pcb_text_draw_string(info, font, label, x, y, scale, direction*90.0, mirror, 1, 0, 0, 0, 0, PCB_TXT_TINY_HIDE); if (pcb_gui->gui) pcb_draw_doing_pinout--; } Index: trunk/src/obj_text.c =================================================================== --- trunk/src/obj_text.c (revision 19586) +++ trunk/src/obj_text.c (revision 19587) @@ -83,7 +83,7 @@ /*** utility ***/ /* creates a new text on a layer */ -pcb_text_t *pcb_text_new(pcb_layer_t *Layer, pcb_font_t *PCBFont, pcb_coord_t X, pcb_coord_t Y, unsigned Direction, int Scale, pcb_coord_t thickness, const char *TextString, pcb_flag_t Flags) +pcb_text_t *pcb_text_new(pcb_layer_t *Layer, pcb_font_t *PCBFont, pcb_coord_t X, pcb_coord_t Y, double rot, int Scale, pcb_coord_t thickness, const char *TextString, pcb_flag_t Flags) { pcb_text_t *text; @@ -99,7 +99,7 @@ */ text->X = X; text->Y = Y; - text->Direction = Direction; + text->rot = rot; text->Flags = Flags; text->Scale = Scale; text->thickness = thickness; @@ -122,7 +122,7 @@ pcb_text_t *pcb_text_dup(pcb_layer_t *dst, pcb_text_t *src) { - pcb_text_t *t = pcb_text_new(dst, pcb_font(PCB, src->fid, 1), src->X, src->Y, src->Direction, src->Scale, src->thickness, src->TextString, src->Flags); + pcb_text_t *t = pcb_text_new(dst, pcb_font(PCB, src->fid, 1), src->X, src->Y, src->rot, src->Scale, src->thickness, src->TextString, src->Flags); pcb_text_copy_meta(t, src); return t; } @@ -129,7 +129,7 @@ pcb_text_t *pcb_text_dup_at(pcb_layer_t *dst, pcb_text_t *src, pcb_coord_t dx, pcb_coord_t dy) { - pcb_text_t *t = pcb_text_new(dst, pcb_font(PCB, src->fid, 1), src->X+dx, src->Y+dy, src->Direction, src->Scale, src->thickness, src->TextString, src->Flags); + pcb_text_t *t = pcb_text_new(dst, pcb_font(PCB, src->fid, 1), src->X+dx, src->Y+dy, src->rot, src->Scale, src->thickness, src->TextString, src->Flags); pcb_text_copy_meta(t, src); return t; } @@ -226,6 +226,10 @@ pcb_bool first_time = pcb_true; pcb_poly_t *poly; +#warning textrot TODO: rewrite the bounding box calculation + int dir; + pcb_text_old_direction(&dir, Text->rot); + s = rendered; if (FontPtr == NULL) @@ -327,7 +331,7 @@ Text->bbox_naked.Y1 = Text->Y - miny; Text->bbox_naked.X2 = Text->X + maxx; Text->bbox_naked.Y2 = Text->Y - maxy; - pcb_box_rotate90(&Text->bbox_naked, Text->X, Text->Y, (4 - Text->Direction) & 0x03); + pcb_box_rotate90(&Text->bbox_naked, Text->X, Text->Y, (4 - dir) & 0x03); } else { Text->bbox_naked.X1 = Text->X + minx; @@ -334,7 +338,7 @@ Text->bbox_naked.Y1 = Text->Y + miny; Text->bbox_naked.X2 = Text->X + maxx; Text->bbox_naked.Y2 = Text->Y + maxy; - pcb_box_rotate90(&Text->bbox_naked, Text->X, Text->Y, Text->Direction); + pcb_box_rotate90(&Text->bbox_naked, Text->X, Text->Y, dir); } /* the bounding box covers the extent of influence @@ -382,7 +386,7 @@ void *pcb_textop_add_to_buffer(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_text_t *Text) { pcb_layer_t *layer = &ctx->buffer.dst->Layer[pcb_layer_id(ctx->buffer.src, Layer)]; - pcb_text_t *t = pcb_text_new(layer, pcb_font(PCB, Text->fid, 1), Text->X, Text->Y, Text->Direction, Text->Scale, Text->thickness, Text->TextString, pcb_flag_mask(Text->Flags, ctx->buffer.extraflg)); + pcb_text_t *t = pcb_text_new(layer, pcb_font(PCB, Text->fid, 1), Text->X, Text->Y, Text->rot, Text->Scale, Text->thickness, Text->TextString, pcb_flag_mask(Text->Flags, ctx->buffer.extraflg)); pcb_text_copy_meta(t, Text); return t; @@ -521,7 +525,7 @@ pcb_text_t *text; text = pcb_text_new(Layer, pcb_font(PCB, Text->fid, 1), Text->X + ctx->copy.DeltaX, - Text->Y + ctx->copy.DeltaY, Text->Direction, Text->Scale, Text->thickness, Text->TextString, pcb_flag_mask(Text->Flags, PCB_FLAG_FOUND)); + Text->Y + ctx->copy.DeltaY, Text->rot, Text->Scale, Text->thickness, Text->TextString, pcb_flag_mask(Text->Flags, PCB_FLAG_FOUND)); pcb_text_copy_meta(text, Text); pcb_text_invalidate_draw(Layer, text); pcb_undo_add_obj_to_create(PCB_OBJ_TEXT, Layer, text, text); @@ -649,16 +653,14 @@ text rotation itself is done by the drawing routines */ void pcb_text_rotate90(pcb_text_t *Text, pcb_coord_t X, pcb_coord_t Y, unsigned Number) { - pcb_uint8_t number; - - number = PCB_FLAG_TEST(PCB_FLAG_ONSOLDER, Text) ? (4 - Number) & 3 : Number; + int number = PCB_FLAG_TEST(PCB_FLAG_ONSOLDER, Text) ? (4 - Number) & 3 : Number; PCB_COORD_ROTATE90(Text->X, Text->Y, X, Y, Number); - /* set new direction, 0..3, - * 0-> to the right, 1-> straight up, - * 2-> to the left, 3-> straight down - */ - Text->Direction = ((Text->Direction + number) & 0x03); + Text->rot += number*90.0; + if (Text->rot > 360.0) + Text->rot -= 360.0; + else if (Text->rot < 0.0) + Text->rot += 360.0; /* can't optimize with box rotation because of closed boxes */ pcb_text_bbox(pcb_font(PCB, Text->fid, 1), Text); @@ -681,15 +683,14 @@ void *pcb_textop_rotate(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_text_t *Text) { - int steps; pcb_text_invalidate_erase(Layer, Text); pcb_poly_restore_to_poly(PCB->Data, PCB_OBJ_TEXT, Layer, Text); if (Layer->text_tree != NULL) pcb_r_delete_entry(Layer->text_tree, (pcb_box_t *) Text); - steps = (int)ctx->rotate.angle / 90; - if (steps > 0) - Text->Direction = ((Text->Direction + steps) & 0x03); + Text->rot = fmod(Text->rot + ctx->rotate.angle, 90.0); + if (Text->rot < 0.0) + Text->rot += 360.0; pcb_rotate(&Text->X, &Text->Y, ctx->rotate.center_x, ctx->rotate.center_y, ctx->rotate.cosa, ctx->rotate.sina); pcb_text_bbox(NULL, Text); @@ -932,13 +933,12 @@ return 0; } -static void pcb_text_draw_string_(pcb_draw_info_t *info, pcb_font_t *font, const unsigned char *string, pcb_coord_t x0, pcb_coord_t y0, int scale, int direction, int mirror, pcb_coord_t thickness, pcb_coord_t min_line_width, int xordraw, pcb_coord_t xordx, pcb_coord_t xordy, pcb_text_tiny_t tiny) +static void pcb_text_draw_string_(pcb_draw_info_t *info, pcb_font_t *font, const unsigned char *string, pcb_coord_t x0, pcb_coord_t y0, int scale, double rotdeg, int mirror, pcb_coord_t thickness, pcb_coord_t min_line_width, int xordraw, pcb_coord_t xordx, pcb_coord_t xordy, pcb_text_tiny_t tiny) { pcb_coord_t x = 0; pcb_cardinal_t n; pcb_xform_mx_t mx = PCB_XFORM_MX_IDENT; double sc = (double)scale / 100.0; - double rotdeg = 90.0 * direction; pcb_xform_mx_translate(mx, x0, y0); pcb_xform_mx_scale(mx, sc, sc); @@ -948,7 +948,7 @@ /* cheap draw */ if (tiny != PCB_TXT_TINY_ACCURATE) { - if (draw_text_cheap(font, x0, y0, scale, direction, mirror, string, xordraw, xordx, xordy, tiny)) + if (draw_text_cheap(font, x0, y0, scale, rotdeg/90, mirror, string, xordraw, xordx, xordy, tiny)) return; } @@ -1050,9 +1050,9 @@ } } -void pcb_text_draw_string(pcb_draw_info_t *info, pcb_font_t *font, const unsigned char *string, pcb_coord_t x0, pcb_coord_t y0, int scale, int direction, int mirror, pcb_coord_t thickness, pcb_coord_t min_line_width, int xordraw, pcb_coord_t xordx, pcb_coord_t xordy, pcb_text_tiny_t tiny) +void pcb_text_draw_string(pcb_draw_info_t *info, pcb_font_t *font, const unsigned char *string, pcb_coord_t x0, pcb_coord_t y0, int scale, double rotdeg, int mirror, pcb_coord_t thickness, pcb_coord_t min_line_width, int xordraw, pcb_coord_t xordx, pcb_coord_t xordy, pcb_text_tiny_t tiny) { - pcb_text_draw_string_(info, font, string, x0, y0, scale, direction, mirror, thickness, min_line_width, xordraw, xordx, xordy, tiny); + pcb_text_draw_string_(info, font, string, x0, y0, scale, rotdeg, mirror, thickness, min_line_width, xordraw, xordx, xordy, tiny); } /* lowlevel drawing routine for text objects */ @@ -1059,7 +1059,7 @@ static void DrawTextLowLevel_(pcb_draw_info_t *info, pcb_text_t *Text, pcb_coord_t min_line_width, int xordraw, pcb_coord_t xordx, pcb_coord_t xordy, pcb_text_tiny_t tiny) { unsigned char *rendered = pcb_text_render_str(Text); - pcb_text_draw_string_(info, pcb_font(PCB, Text->fid, 1), rendered, Text->X, Text->Y, Text->Scale, Text->Direction, PCB_FLAG_TEST(PCB_FLAG_ONSOLDER, Text), Text->thickness, min_line_width, xordraw, xordx, xordy, tiny); + pcb_text_draw_string_(info, pcb_font(PCB, Text->fid, 1), rendered, Text->X, Text->Y, Text->Scale, Text->rot, PCB_FLAG_TEST(PCB_FLAG_ONSOLDER, Text), Text->thickness, min_line_width, xordraw, xordx, xordy, tiny); pcb_text_free_str(Text, rendered); } Index: trunk/src/obj_text.h =================================================================== --- trunk/src/obj_text.h (revision 19586) +++ trunk/src/obj_text.h (revision 19587) @@ -35,13 +35,10 @@ #include "font.h" #include -#define PCB_TEXT_FREEROT 0x7f - struct pcb_text_s { PCB_ANY_PRIMITIVE_FIELDS; int Scale; /* text scaling in percent */ pcb_coord_t X, Y; /* origin */ - pcb_uint8_t Direction; /* if PCB_TEXT_FREEROT, use rot */ pcb_font_id_t fid; char *TextString; /* string */ pcb_coord_t thickness; /* if non-zero, thickness of line/arc within the font */ @@ -56,7 +53,7 @@ pcb_text_t *pcb_text_alloc(pcb_layer_t * layer); void pcb_text_free(pcb_text_t * data); -pcb_text_t *pcb_text_new(pcb_layer_t *Layer, pcb_font_t *PCBFont, pcb_coord_t X, pcb_coord_t Y, unsigned Direction, int Scale, pcb_coord_t thickness, const char *TextString, pcb_flag_t Flags); +pcb_text_t *pcb_text_new(pcb_layer_t *Layer, pcb_font_t *PCBFont, pcb_coord_t X, pcb_coord_t Y, double rot, int Scale, pcb_coord_t thickness, const char *TextString, pcb_flag_t Flags); pcb_text_t *pcb_text_dup(pcb_layer_t *dst, pcb_text_t *src); pcb_text_t *pcb_text_dup_at(pcb_layer_t *dst, pcb_text_t *src, pcb_coord_t dx, pcb_coord_t dy); void *pcb_text_destroy(pcb_layer_t *Layer, pcb_text_t *Text); Index: trunk/src/obj_text_draw.h =================================================================== --- trunk/src/obj_text_draw.h (revision 19586) +++ trunk/src/obj_text_draw.h (revision 19587) @@ -50,7 +50,7 @@ void pcb_text_draw_label(pcb_draw_info_t *info, pcb_text_t *text); /* lowlevel drawing routine for text strings */ -void pcb_text_draw_string(pcb_draw_info_t *info, pcb_font_t *font, const unsigned char *string, pcb_coord_t x0, pcb_coord_t y0, int scale, int direction, int mirror, pcb_coord_t thickness, pcb_coord_t min_line_width, int xordraw, pcb_coord_t xordx, pcb_coord_t xordy, pcb_text_tiny_t tiny); +void pcb_text_draw_string(pcb_draw_info_t *info, pcb_font_t *font, const unsigned char *string, pcb_coord_t x0, pcb_coord_t y0, int scale, double rotdeg, int mirror, pcb_coord_t thickness, pcb_coord_t min_line_width, int xordraw, pcb_coord_t xordx, pcb_coord_t xordy, pcb_text_tiny_t tiny); /* lowlevel text bounding box calculation */ pcb_coord_t pcb_text_width(pcb_font_t *font, int scale, const unsigned char *string); Index: trunk/src/stub_draw.c =================================================================== --- trunk/src/stub_draw.c (revision 19586) +++ trunk/src/stub_draw.c (revision 19587) @@ -40,7 +40,7 @@ t.X = 0; t.Y = 0; t.TextString = (char *)str; - t.Direction = 0; + t.rot = 0; t.fid = 0; /* use the default font */ t.Scale = 150; t.Flags = pcb_no_flags(); Index: trunk/src/tool_text.c =================================================================== --- trunk/src/tool_text.c (revision 19586) +++ trunk/src/tool_text.c (revision 19587) @@ -79,7 +79,7 @@ text.X = pcb_crosshair.X; text.Y = pcb_crosshair.Y; - text.Direction = 0; + text.rot = 0; text.Flags = pcb_flag_make(flag); text.Scale = conf_core.design.text_scale; text.thickness = conf_core.design.text_thickness; Index: trunk/src_plugins/draw_csect/draw_csect.c =================================================================== --- trunk/src_plugins/draw_csect/draw_csect.c (revision 19586) +++ trunk/src_plugins/draw_csect/draw_csect.c (revision 19587) @@ -67,7 +67,7 @@ t.X = PCB_MM_TO_COORD(x); t.Y = PCB_MM_TO_COORD(y); t.TextString = (char *)txt; - t.Direction = dir; + t.rot = 90.0*dir; t.Scale = scale; t.fid = 0; /* use the default font */ t.Flags = pcb_no_flags(); @@ -83,7 +83,7 @@ t.X = x; t.Y = y; t.TextString = (char *)txt; - t.Direction = dir; + t.rot = 90.0*dir; t.Scale = scale; t.fid = 0; /* use the default font */ t.Flags = pcb_no_flags(); @@ -99,7 +99,7 @@ t.X = PCB_MM_TO_COORD(x); t.Y = PCB_MM_TO_COORD(y); t.TextString = (char *)txt; - t.Direction = dir; + t.rot = 90.0 * dir; t.Scale = scale; t.fid = 0; /* use the default font */ t.Flags = pcb_no_flags(); Index: trunk/src_plugins/draw_fab/draw_fab.c =================================================================== --- trunk/src_plugins/draw_fab/draw_fab.c (revision 19586) +++ trunk/src_plugins/draw_fab/draw_fab.c (revision 19587) @@ -82,7 +82,7 @@ va_start(a, fmt); vsprintf(tmp, fmt, a); va_end(a); - t.Direction = 0; + t.rot = 0; t.TextString = tmp; t.Scale = PCB_COORD_TO_MIL(TEXT_SIZE); /* pcnt of 100mil base height */ t.Flags = pcb_no_flags(); Index: trunk/src_plugins/draw_fontsel/draw_fontsel.c =================================================================== --- trunk/src_plugins/draw_fontsel/draw_fontsel.c (revision 19586) +++ trunk/src_plugins/draw_fontsel/draw_fontsel.c (revision 19587) @@ -53,7 +53,7 @@ t.X = PCB_MM_TO_COORD(x); t.Y = PCB_MM_TO_COORD(y); t.TextString = (char *)txt; - t.Direction = 0; + t.rot = 0; t.Scale = scale; t.fid = fid; t.Flags = pcb_no_flags(); Index: trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_pkg/layout/create.c =================================================================== --- trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_pkg/layout/create.c (revision 19586) +++ trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_pkg/layout/create.c (revision 19587) @@ -141,7 +141,7 @@ if (layer == NULL) return NULL; - res = pcb_text_new(layer, pcb_font(PCB, 0, 1), x, y, direction, scale, 0, pcb_strdup(str), get_flags(flags)); + res = pcb_text_new(layer, pcb_font(PCB, 0, 1), x, y, 90.0*direction, scale, 0, pcb_strdup(str), get_flags(flags)); return search_persist_created(search_id, layer_id, res, OM_ARC); } Index: trunk/src_plugins/lib_compat_help/subc_help.c =================================================================== --- trunk/src_plugins/lib_compat_help/subc_help.c (revision 19586) +++ trunk/src_plugins/lib_compat_help/subc_help.c (revision 19587) @@ -31,7 +31,7 @@ pcb_layer_type_t side = bottom ? PCB_LYT_BOTTOM : PCB_LYT_TOP; pcb_layer_t *ly = pcb_subc_get_layer(sc, side | PCB_LYT_SILK, 0, pcb_true, "top-silk", pcb_false); if (ly != NULL) - return pcb_text_new(ly, pcb_font(PCB, 0, 0), x, y, direction, scale, 0, pattern, pcb_flag_make(PCB_FLAG_DYNTEXT | PCB_FLAG_FLOATER | (bottom ? PCB_FLAG_ONSOLDER : 0))); + return pcb_text_new(ly, pcb_font(PCB, 0, 0), x, y, 90.0 * direction, scale, 0, pattern, pcb_flag_make(PCB_FLAG_DYNTEXT | PCB_FLAG_FLOATER | (bottom ? PCB_FLAG_ONSOLDER : 0))); return 0; }