diff --git a/XSchemWin/XSchemWix/heat_xschem_library.wxs b/XSchemWin/XSchemWix/heat_xschem_library.wxs index db31970b..3afea827 100644 --- a/XSchemWin/XSchemWix/heat_xschem_library.wxs +++ b/XSchemWin/XSchemWix/heat_xschem_library.wxs @@ -3,5703 +3,5715 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -5857,6 +5869,8 @@ + + @@ -5904,6 +5918,8 @@ + + diff --git a/XSchemWin/XSchemWix/xschem_library.wxs b/XSchemWin/XSchemWix/xschem_library.wxs index 8d39b85b..f4c2e3b1 100644 --- a/XSchemWin/XSchemWix/xschem_library.wxs +++ b/XSchemWin/XSchemWix/xschem_library.wxs @@ -455,6 +455,12 @@ + + + + + + @@ -596,6 +602,12 @@ + + + + + + @@ -5538,6 +5550,8 @@ + + @@ -5585,6 +5599,8 @@ + + diff --git a/src/actions.c b/src/actions.c index 9e583a46..caf6a3a4 100644 --- a/src/actions.c +++ b/src/actions.c @@ -1412,6 +1412,7 @@ void calc_drawing_bbox(xRect *boundbox, int selected) { xRect rect; int c, i; + const char *txtptr; int count=0; #if HAS_CAIRO==1 int customfont; @@ -1512,10 +1513,18 @@ void calc_drawing_bbox(xRect *boundbox, int selected) { int no_of_lines, longest_line; if(selected == 1 && !xctx->text[i].sel) continue; + if(xctx->text[i].flags & TEXT_TRANSLATE) { + const char *inst; + inst = get_tok_value(xctx->text[i].prop_ptr, "inst", 0); + txtptr = translate(atoi(inst), xctx->text[i].txt_ptr); + } else { + txtptr = xctx->text[i].txt_ptr; + } + #if HAS_CAIRO==1 customfont = set_text_custom_font(&xctx->text[i]); #endif - if(text_bbox(xctx->text[i].txt_ptr, xctx->text[i].xscale, + if(text_bbox(txtptr, xctx->text[i].xscale, xctx->text[i].yscale,xctx->text[i].rot, xctx->text[i].flip, xctx->text[i].hcenter, xctx->text[i].vcenter, xctx->text[i].x0, xctx->text[i].y0, @@ -2558,7 +2567,9 @@ int place_text(int draw_text, double mx, double my) str = get_tok_value(t->prop_ptr, "weight", 0); t->flags |= strcmp(str, "bold") ? 0 : TEXT_BOLD; str = get_tok_value(t->prop_ptr, "hide", 0); - t->flags |= strcmp(str, "true") ? 0 : HIDE_TEXT; + t->flags |= strcmp(str, "true") ? 0 : TEXT_HIDE; + str = get_tok_value(t->prop_ptr, "inst", 0); + t->flags |= str[0] ? TEXT_TRANSLATE : 0; my_strdup(21, &t->font, get_tok_value(t->prop_ptr, "font", 0)); textlayer = t->layer; diff --git a/src/draw.c b/src/draw.c index edef809d..c7eb40ef 100644 --- a/src/draw.c +++ b/src/draw.c @@ -515,7 +515,7 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, { text = symptr->text[j]; if(text.xscale*FONTWIDTH*xctx->mooz<1) continue; - if(symptr->text[j].flags & HIDE_TEXT) continue; + if(symptr->text[j].flags & TEXT_HIDE) continue; if( hide && text.txt_ptr && strcmp(text.txt_ptr, "@symname") && strcmp(text.txt_ptr, "@name") ) continue; txtptr= translate(n, text.txt_ptr); ROTATION(rot, flip, 0.0,0.0,text.x0,text.y0,x1,y1); @@ -3032,12 +3032,20 @@ void draw(void) drawline(WIRELAYER, END, 0.0, 0.0, 0.0, 0.0, 0); } if(xctx->draw_single_layer ==-1 || xctx->draw_single_layer==TEXTLAYER) { + const char *txtptr; for(i=0;itexts;i++) { textlayer = xctx->text[i].layer; - if(xctx->text[i].flags & HIDE_TEXT) continue; + if(xctx->text[i].flags & TEXT_HIDE) continue; + if(xctx->text[i].flags & TEXT_TRANSLATE) { + const char *inst; + inst = get_tok_value(xctx->text[i].prop_ptr, "inst", 0); + txtptr = translate(atoi(inst), xctx->text[i].txt_ptr); + } else { + txtptr = xctx->text[i].txt_ptr; + } if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER; - dbg(1, "draw(): drawing string %d = %s\n",i, xctx->text[i].txt_ptr); + dbg(1, "draw(): drawing string %d = %s\n",i, txtptr); #if HAS_CAIRO==1 if(!xctx->enable_layer[textlayer]) continue; textfont = xctx->text[i].font; @@ -3058,7 +3066,7 @@ void draw(void) cairo_select_font_face (xctx->cairo_save_ctx, textfont, slant, weight); } #endif - draw_string(textlayer, ADD, xctx->text[i].txt_ptr, + draw_string(textlayer, ADD, txtptr, xctx->text[i].rot, xctx->text[i].flip, xctx->text[i].hcenter, xctx->text[i].vcenter, xctx->text[i].x0,xctx->text[i].y0, xctx->text[i].xscale, xctx->text[i].yscale); diff --git a/src/editprop.c b/src/editprop.c index 47de054b..7b27e1f6 100644 --- a/src/editprop.c +++ b/src/editprop.c @@ -837,7 +837,7 @@ static void edit_text_property(int x) double xx1,yy1,xx2,yy2; double pcx,pcy; /* pin center 20070317 */ char property[1024];/* used for float 2 string conv (xscale and yscale) overflow safe */ - const char *str; + const char *str, *txtptr; char *oldprop = NULL; dbg(1, "edit_text_property(): entering\n"); @@ -884,16 +884,20 @@ static void edit_text_property(int x) sel=xctx->sel_array[k].n; rot = xctx->text[sel].rot; /* calculate bbox, some cleanup needed here */ flip = xctx->text[sel].flip; + if(xctx->text[sel].flags & TEXT_TRANSLATE) { + const char *inst; + inst = get_tok_value(xctx->text[sel].prop_ptr, "inst", 0); + txtptr = translate(atoi(inst), xctx->text[sel].txt_ptr); + } else { + txtptr = xctx->text[sel].txt_ptr; + } #if HAS_CAIRO==1 customfont = set_text_custom_font(&xctx->text[sel]); #endif - text_bbox(xctx->text[sel].txt_ptr, xctx->text[sel].xscale, + text_bbox(txtptr, xctx->text[sel].xscale, xctx->text[sel].yscale, rot, flip, xctx->text[sel].hcenter, xctx->text[sel].vcenter, xctx->text[sel].x0, xctx->text[sel].y0, &xx1,&yy1,&xx2,&yy2, &tmp, &tmp); - #if HAS_CAIRO==1 - if(customfont) cairo_restore(xctx->cairo_ctx); - #endif bbox(ADD, xx1, yy1, xx2, yy2 ); dbg(1, "edit_property(): text props: props=%s text=%s\n", tclgetvar("props"), @@ -905,16 +909,6 @@ static void edit_text_property(int x) for(l=0;lrect[PINLAYER][l].prop_ptr, "name",0)), xctx->text[sel].txt_ptr) ) { - #if HAS_CAIRO==1 - customfont = set_text_custom_font(&xctx->text[sel]); - #endif - text_bbox(xctx->text[sel].txt_ptr, xctx->text[sel].xscale, - xctx->text[sel].yscale, rot, flip, xctx->text[sel].hcenter, - xctx->text[sel].vcenter, xctx->text[sel].x0, xctx->text[sel].y0, - &xx1,&yy1,&xx2,&yy2, &tmp, &tmp); - #if HAS_CAIRO==1 - if(customfont) cairo_restore(xctx->cairo_ctx); - #endif pcx = (xctx->rect[PINLAYER][l].x1+xctx->rect[PINLAYER][l].x2)/2.0; pcy = (xctx->rect[PINLAYER][l].y1+xctx->rect[PINLAYER][l].y2)/2.0; if( @@ -938,6 +932,9 @@ static void edit_text_property(int x) } my_strdup(74, &xctx->text[sel].txt_ptr, (char *) tclgetvar("retval")); } + #if HAS_CAIRO==1 + if(customfont) cairo_restore(xctx->cairo_ctx); + #endif if(x==0) { if(oldprop && preserve) set_different_token(&xctx->text[sel].prop_ptr, (char *) tclgetvar("props"), oldprop, 0, 0); @@ -958,7 +955,10 @@ static void edit_text_property(int x) str = get_tok_value(xctx->text[sel].prop_ptr, "weight", 0); xctx->text[sel].flags |= strcmp(str, "bold") ? 0 : TEXT_BOLD; str = get_tok_value(xctx->text[sel].prop_ptr, "hide", 0); - xctx->text[sel].flags |= strcmp(str, "true") ? 0 : HIDE_TEXT; + xctx->text[sel].flags |= strcmp(str, "true") ? 0 : TEXT_HIDE; + str = get_tok_value(xctx->text[sel].prop_ptr, "inst", 0); + xctx->text[sel].flags |= str[0] ? TEXT_TRANSLATE : 0; + if(k == 0 ) { hsize =atof(tclgetvar("hsize")); vsize =atof(tclgetvar("vsize")); @@ -975,7 +975,14 @@ static void edit_text_property(int x) #if HAS_CAIRO==1 customfont = set_text_custom_font(&xctx->text[sel]); #endif - text_bbox(xctx->text[sel].txt_ptr, xctx->text[sel].xscale, + if(xctx->text[sel].flags & TEXT_TRANSLATE) { + const char *inst; + inst = get_tok_value(xctx->text[sel].prop_ptr, "inst", 0); + txtptr = translate(atoi(inst), xctx->text[sel].txt_ptr); + } else { + txtptr = xctx->text[sel].txt_ptr; + } + text_bbox(txtptr, xctx->text[sel].xscale, xctx->text[sel].yscale, rot, flip, xctx->text[sel].hcenter, xctx->text[sel].vcenter, xctx->text[sel].x0, xctx->text[sel].y0, &xx1,&yy1,&xx2,&yy2, &tmp, &tmp); diff --git a/src/findnet.c b/src/findnet.c index 776f833b..a19ae04c 100644 --- a/src/findnet.c +++ b/src/findnet.c @@ -283,6 +283,7 @@ static void find_closest_text(double mx,double my) #if HAS_CAIRO==1 int customfont; #endif + const char *txtptr; threshold = CADWIREMINDIST * CADWIREMINDIST * xctx->zoom * xctx->zoom; for(i=0;itexts;i++) { @@ -291,7 +292,14 @@ static void find_closest_text(double mx,double my) #if HAS_CAIRO==1 customfont = set_text_custom_font(&xctx->text[i]); #endif - text_bbox(xctx->text[i].txt_ptr, + if(xctx->text[i].flags & TEXT_TRANSLATE) { + const char *inst; + inst = get_tok_value(xctx->text[i].prop_ptr, "inst", 0); + txtptr = translate(atoi(inst), xctx->text[i].txt_ptr); + } else { + txtptr = xctx->text[i].txt_ptr; + } + text_bbox(txtptr, xctx->text[i].xscale, xctx->text[i].yscale, rot, flip, xctx->text[i].hcenter, xctx->text[i].vcenter, xctx->text[i].x0, xctx->text[i].y0, diff --git a/src/move.c b/src/move.c index e75ee286..41f1c729 100644 --- a/src/move.c +++ b/src/move.c @@ -192,6 +192,7 @@ void draw_selection(GC g, int interruptable) #if HAS_CAIRO==1 int customfont; #endif + const char *txtptr; if(g == xctx->gc[SELLAYER]) xctx->movelastsel = xctx->lastsel; for(i=0;imovelastsel;i++) @@ -210,7 +211,15 @@ void draw_selection(GC g, int interruptable) #if HAS_CAIRO==1 customfont = set_text_custom_font(&xctx->text[n]); #endif - draw_temp_string(g,ADD, xctx->text[n].txt_ptr, + if(xctx->text[n].flags & TEXT_TRANSLATE) { + const char *inst; + inst = get_tok_value(xctx->text[n].prop_ptr, "inst", 0); + txtptr = translate(atoi(inst), xctx->text[n].txt_ptr); + } else { + txtptr = xctx->text[n].txt_ptr; + } + + draw_temp_string(g,ADD, txtptr, (xctx->text[n].rot + ( (xctx->move_flip && (xctx->text[n].rot & 1) ) ? xctx->move_rot+2 : xctx->move_rot) ) & 0x3, xctx->text[n].flip^xctx->move_flip, xctx->text[n].hcenter, xctx->text[n].vcenter, @@ -607,7 +616,7 @@ void copy_objects(int what) #if HAS_CAIRO==1 int customfont; #endif - + const char *txtptr; if(what & START) { xctx->rotatelocal=0; @@ -919,7 +928,10 @@ void copy_objects(int what) str = get_tok_value(xctx->text[xctx->texts].prop_ptr, "weight", 0); xctx->text[xctx->texts].flags |= strcmp(str, "bold") ? 0 : TEXT_BOLD; str = get_tok_value(xctx->text[xctx->texts].prop_ptr, "hide", 0); - xctx->text[xctx->texts].flags |= strcmp(str, "true") ? 0 : HIDE_TEXT; + xctx->text[xctx->texts].flags |= strcmp(str, "true") ? 0 : TEXT_HIDE; + str = get_tok_value(xctx->text[xctx->texts].prop_ptr, "inst", 0); + xctx->text[xctx->texts].flags |= str[0] ? TEXT_TRANSLATE : 0; + xctx->text[xctx->texts].xscale=xctx->text[n].xscale; xctx->text[xctx->texts].yscale=xctx->text[n].yscale; @@ -929,7 +941,14 @@ void copy_objects(int what) #if HAS_CAIRO==1 /* bbox after copy */ customfont = set_text_custom_font(&xctx->text[l]); #endif - text_bbox(xctx->text[l].txt_ptr, xctx->text[l].xscale, + if(xctx->text[l].flags & TEXT_TRANSLATE) { + const char *inst; + inst = get_tok_value(xctx->text[l].prop_ptr, "inst", 0); + txtptr = translate(atoi(inst), xctx->text[l].txt_ptr); + } else { + txtptr = xctx->text[l].txt_ptr; + } + text_bbox(txtptr, xctx->text[l].xscale, xctx->text[l].yscale, xctx->text[l].rot,xctx->text[l].flip, xctx->text[l].hcenter, xctx->text[l].vcenter, xctx->text[l].x0, xctx->text[l].y0, @@ -951,9 +970,6 @@ void copy_objects(int what) } /* end for(k=0;klastsel; i++) { n = xctx->sel_array[i].n; if(xctx->sel_array[i].type == ELEMENT) { @@ -1035,6 +1051,7 @@ void move_objects(int what, int merge, double dx, double dy) #endif xLine ** const line = xctx->line; xWire * const wire = xctx->wire; + const char *txtptr; if(what & START) { @@ -1442,7 +1459,14 @@ void move_objects(int what, int merge, double dx, double dy) #if HAS_CAIRO==1 /* bbox before move */ customfont = set_text_custom_font(&xctx->text[n]); #endif - text_bbox(xctx->text[n].txt_ptr, xctx->text[n].xscale, + if(xctx->text[n].flags & TEXT_TRANSLATE) { + const char *inst; + inst = get_tok_value(xctx->text[n].prop_ptr, "inst", 0); + txtptr = translate(atoi(inst), xctx->text[n].txt_ptr); + } else { + txtptr = xctx->text[n].txt_ptr; + } + text_bbox(txtptr, xctx->text[n].xscale, xctx->text[n].yscale, xctx->text[n].rot,xctx->text[n].flip, xctx->text[n].hcenter, xctx->text[n].vcenter, xctx->text[n].x0, xctx->text[n].y0, &xctx->rx1,&xctx->ry1, &xctx->rx2,&xctx->ry2, &tmpint, &tmpint); @@ -1466,7 +1490,7 @@ void move_objects(int what, int merge, double dx, double dy) #if HAS_CAIRO==1 /* bbox after move */ customfont = set_text_custom_font(&xctx->text[n]); #endif - text_bbox(xctx->text[n].txt_ptr, xctx->text[n].xscale, + text_bbox(txtptr, xctx->text[n].xscale, xctx->text[n].yscale, xctx->text[n].rot,xctx->text[n].flip, xctx->text[n].hcenter, xctx->text[n].vcenter, xctx->text[n].x0, xctx->text[n].y0, &xctx->rx1,&xctx->ry1, &xctx->rx2,&xctx->ry2, &tmpint, &tmpint); diff --git a/src/paste.c b/src/paste.c index 1731499b..84532395 100644 --- a/src/paste.c +++ b/src/paste.c @@ -65,7 +65,10 @@ static void merge_text(FILE *fd) str = get_tok_value(xctx->text[i].prop_ptr, "weight", 0); xctx->text[i].flags |= strcmp(str, "bold") ? 0 : TEXT_BOLD; str = get_tok_value(xctx->text[i].prop_ptr, "hide", 0); - xctx->text[i].flags |= strcmp(str, "true") ? 0 : HIDE_TEXT; + xctx->text[i].flags |= strcmp(str, "true") ? 0 : TEXT_HIDE; + str = get_tok_value(xctx->text[i].prop_ptr, "inst", 0); + xctx->text[i].flags |= str[0] ? TEXT_TRANSLATE : 0; + select_text(i,SELECTED, 1); set_modify(1); diff --git a/src/psprint.c b/src/psprint.c index a4cca64f..91949e9a 100644 --- a/src/psprint.c +++ b/src/psprint.c @@ -671,7 +671,7 @@ static void fill_ps_colors() } -static void create_ps(char **psfile, int what) +void create_ps(char **psfile, int what) { double dx, dy, scale, scaley; int landscape=1; @@ -684,7 +684,7 @@ static void create_ps(char **psfile, int what) xRect boundbox; int c,i, textlayer; int old_grid; - const char *textfont; + const char *textfont, *txtptr; if(what & 1) { /* prolog */ numpages = 0; @@ -831,13 +831,20 @@ static void create_ps(char **psfile, int what) else if( xctx->text[i].flags & TEXT_OBLIQUE) my_snprintf(ps_font_family, S(ps_font_family), "%s-Oblique", ps_font_name); + if(xctx->text[i].flags & TEXT_TRANSLATE) { + const char *inst; + inst = get_tok_value(xctx->text[i].prop_ptr, "inst", 0); + txtptr = translate(atoi(inst), xctx->text[i].txt_ptr); + } else { + txtptr = xctx->text[i].txt_ptr; + } if(text_ps) { - ps_draw_string(textlayer, xctx->text[i].txt_ptr, + ps_draw_string(textlayer, txtptr, xctx->text[i].rot, xctx->text[i].flip, xctx->text[i].hcenter, xctx->text[i].vcenter, xctx->text[i].x0,xctx->text[i].y0, xctx->text[i].xscale, xctx->text[i].yscale); } else { - old_ps_draw_string(textlayer, xctx->text[i].txt_ptr, + old_ps_draw_string(textlayer, txtptr, xctx->text[i].rot, xctx->text[i].flip, xctx->text[i].hcenter, xctx->text[i].vcenter, xctx->text[i].x0,xctx->text[i].y0, xctx->text[i].xscale, xctx->text[i].yscale); diff --git a/src/save.c b/src/save.c index e063ce6f..a7d89f67 100644 --- a/src/save.c +++ b/src/save.c @@ -1289,7 +1289,10 @@ static void load_text(FILE *fd) str = get_tok_value(xctx->text[i].prop_ptr, "weight", 0); xctx->text[i].flags |= strcmp(str, "bold") ? 0 : TEXT_BOLD; str = get_tok_value(xctx->text[i].prop_ptr, "hide", 0); - xctx->text[i].flags |= strcmp(str, "true") ? 0 : HIDE_TEXT; + xctx->text[i].flags |= strcmp(str, "true") ? 0 : TEXT_HIDE; + str = get_tok_value(xctx->text[i].prop_ptr, "inst", 0); + xctx->text[i].flags |= str[0] ? TEXT_TRANSLATE : 0; + xctx->texts++; } @@ -2807,7 +2810,10 @@ int load_sym_def(const char *name, FILE *embed_fd) str = get_tok_value(tt[i].prop_ptr, "weight", 0); tt[i].flags |= strcmp(str, "bold") ? 0 : TEXT_BOLD; str = get_tok_value(tt[i].prop_ptr, "hide", 0); - tt[i].flags |= strcmp(str, "true") ? 0 : HIDE_TEXT; + tt[i].flags |= strcmp(str, "true") ? 0 : TEXT_HIDE; + str = get_tok_value(tt[i].prop_ptr, "inst", 0); + tt[i].flags |= str[0] ? TEXT_TRANSLATE : 0; + lastt++; break; case 'N': /* store wires as lines on layer WIRELAYER. */ diff --git a/src/select.c b/src/select.c index dc68ab78..894c2e4a 100644 --- a/src/select.c +++ b/src/select.c @@ -323,6 +323,7 @@ void delete(int to_push_undo) int customfont; #endif double xx1,yy1,xx2,yy2; + const char *txtptr; dbg(3, "delete(): start\n"); j = 0; @@ -343,7 +344,14 @@ void delete(int to_push_undo) #if HAS_CAIRO==1 customfont = set_text_custom_font(&xctx->text[i]); #endif - text_bbox(xctx->text[i].txt_ptr, xctx->text[i].xscale, + if(xctx->text[i].flags & TEXT_TRANSLATE) { + const char *inst; + inst = get_tok_value(xctx->text[i].prop_ptr, "inst", 0); + txtptr = translate(atoi(inst), xctx->text[i].txt_ptr); + } else { + txtptr = xctx->text[i].txt_ptr; + } + text_bbox(txtptr, xctx->text[i].xscale, xctx->text[i].yscale, select_rot, select_flip, xctx->text[i].hcenter, xctx->text[i].vcenter, xctx->text[i].x0, xctx->text[i].y0, &xx1,&yy1, &xx2,&yy2, &tmp, &tmp); @@ -618,11 +626,19 @@ void unselect_all(void) { if(xctx->text[i].sel == SELECTED) { + const char *txtptr; xctx->text[i].sel = 0; #if HAS_CAIRO==1 customfont = set_text_custom_font(& xctx->text[i]); /* needed for bbox calculation */ #endif - draw_temp_string(xctx->gctiled,ADD, xctx->text[i].txt_ptr, + if(xctx->text[i].flags & TEXT_TRANSLATE) { + const char *inst; + inst = get_tok_value(xctx->text[i].prop_ptr, "inst", 0); + txtptr = translate(atoi(inst), xctx->text[i].txt_ptr); + } else { + txtptr = xctx->text[i].txt_ptr; + } + draw_temp_string(xctx->gctiled,ADD, txtptr, xctx->text[i].rot, xctx->text[i].flip, xctx->text[i].hcenter, xctx->text[i].vcenter, xctx->text[i].x0, xctx->text[i].y0, xctx->text[i].xscale, xctx->text[i].yscale); @@ -779,6 +795,7 @@ void select_text(int i,unsigned short select_mode, int fast) #if HAS_CAIRO==1 int customfont; #endif + const char *txtptr; if(!fast) { my_strncpy(s,xctx->text[i].prop_ptr!=NULL?xctx->text[i].prop_ptr:"",S(s)); @@ -792,13 +809,21 @@ void select_text(int i,unsigned short select_mode, int fast) #if HAS_CAIRO==1 customfont = set_text_custom_font(&xctx->text[i]); #endif + if(xctx->text[i].flags & TEXT_TRANSLATE) { + const char *inst; + inst = get_tok_value(xctx->text[i].prop_ptr, "inst", 0); + txtptr = translate(atoi(inst), xctx->text[i].txt_ptr); + } else { + txtptr = xctx->text[i].txt_ptr; + } + if(select_mode) - draw_temp_string(xctx->gc[SELLAYER],ADD, xctx->text[i].txt_ptr, + draw_temp_string(xctx->gc[SELLAYER],ADD, txtptr, xctx->text[i].rot, xctx->text[i].flip, xctx->text[i].hcenter, xctx->text[i].vcenter, xctx->text[i].x0, xctx->text[i].y0, xctx->text[i].xscale, xctx->text[i].yscale); else - draw_temp_string(xctx->gctiled,NOW, xctx->text[i].txt_ptr, + draw_temp_string(xctx->gctiled,NOW, txtptr, xctx->text[i].rot, xctx->text[i].flip, xctx->text[i].hcenter, xctx->text[i].vcenter, xctx->text[i].x0, xctx->text[i].y0, xctx->text[i].xscale, xctx->text[i].yscale); @@ -994,6 +1019,7 @@ void select_inside(double x1,double y1, double x2, double y2, int sel) /*added u #if HAS_CAIRO==1 int customfont; #endif + const char *txtptr; en_s = tclgetboolvar("enable_stretch"); for(i=0;iwires;i++) @@ -1021,7 +1047,15 @@ void select_inside(double x1,double y1, double x2, double y2, int sel) /*added u #if HAS_CAIRO==1 customfont = set_text_custom_font(&xctx->text[i]); #endif - text_bbox(xctx->text[i].txt_ptr, + if(xctx->text[i].flags & TEXT_TRANSLATE) { + const char *inst; + inst = get_tok_value(xctx->text[i].prop_ptr, "inst", 0); + txtptr = translate(atoi(inst), xctx->text[i].txt_ptr); + } else { + txtptr = xctx->text[i].txt_ptr; + } + + text_bbox(txtptr, xctx->text[i].xscale, xctx->text[i].yscale, select_rot, select_flip, xctx->text[i].hcenter, xctx->text[i].vcenter, xctx->text[i].x0, xctx->text[i].y0, diff --git a/src/svgdraw.c b/src/svgdraw.c index 7ebca61b..5f613aff 100644 --- a/src/svgdraw.c +++ b/src/svgdraw.c @@ -606,7 +606,7 @@ void svg_draw(void) int c,i, textlayer; int old_grid; static char lastdir[PATH_MAX] = ""; - const char *r, *textfont; + const char *r, *textfont, *txtptr; int *unused_layer; int color; Hilight_hashentry *entry; @@ -744,14 +744,20 @@ void svg_draw(void) my_snprintf(svg_font_style, S(svg_font_style), "italic"); if( xctx->text[i].flags & TEXT_OBLIQUE) my_snprintf(svg_font_style, S(svg_font_style), "oblique"); - + if(xctx->text[i].flags & TEXT_TRANSLATE) { + const char *inst; + inst = get_tok_value(xctx->text[i].prop_ptr, "inst", 0); + txtptr = translate(atoi(inst), xctx->text[i].txt_ptr); + } else { + txtptr = xctx->text[i].txt_ptr; + } if(text_svg) - svg_draw_string(textlayer, xctx->text[i].txt_ptr, + svg_draw_string(textlayer, txtptr, xctx->text[i].rot, xctx->text[i].flip, xctx->text[i].hcenter, xctx->text[i].vcenter, xctx->text[i].x0,xctx->text[i].y0, xctx->text[i].xscale, xctx->text[i].yscale); else - old_svg_draw_string(textlayer, xctx->text[i].txt_ptr, + old_svg_draw_string(textlayer, txtptr, xctx->text[i].rot, xctx->text[i].flip, xctx->text[i].hcenter, xctx->text[i].vcenter, xctx->text[i].x0,xctx->text[i].y0, xctx->text[i].xscale, xctx->text[i].yscale); diff --git a/src/xschem.h b/src/xschem.h index f4dd8bb6..f9a3b2b1 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -266,7 +266,8 @@ extern char win_temp_dir[PATH_MAX]; #define TEXT_OBLIQUE 2 #define TEXT_ITALIC 4 /* flag (.flags field) to hide text in symbols when displaying instances */ -#define HIDE_TEXT 8 +#define TEXT_HIDE 8 +#define TEXT_TRANSLATE 16 #define S(a) (sizeof(a)/sizeof(a[0])) #define BUS_WIDTH 4 @@ -463,7 +464,7 @@ typedef struct int layer; /* 20171201 for cairo */ short hcenter, vcenter; char *font; /* 20171201 for cairo */ - int flags; /* TEXT_BOLD:1 TEXT_OBLIQUE:2 TEXT_ITALIC:4 HIDE_TEXT:8 */ + int flags; /* TEXT_BOLD:1 TEXT_OBLIQUE:2 TEXT_ITALIC:4 TEXT_HIDE:8 */ } xText; typedef struct @@ -1390,5 +1391,6 @@ extern void del_wire_table(void); extern void del_object_table(void); extern const char *create_tmpdir(char *prefix); extern FILE *open_tmpfile(char *prefix, char **filename); +extern void create_ps(char** psfile, int what); #endif /*CADGLOBALS */