allow instance attribute `text_n_size=s` (where s is a double and n is an integer) to set symbol text item `n` to size `s`
This commit is contained in:
parent
6c1dadd27c
commit
6648652ae5
|
|
@ -127,6 +127,9 @@ name="mchanged_name" model=\"nmos\" w="20u" l="3u" m="10"
|
|||
<p> A <kbd>hide=true</kbd> attribute will only display the symbol bounding box.</p>
|
||||
<li><kbd>hide_texts</kbd></li>
|
||||
<p> A <kbd>hide_texts=true</kbd> attribute will hide all symbol texts.</p>
|
||||
<li><kbd>text_<n>_size</kbd></li>
|
||||
<p> This attribute sets the size of symbol text item number <kbd>n</kbd>. This allows
|
||||
instance based symbol text sizing.</p>
|
||||
<li><kbd>highlight</kbd></li>
|
||||
<p>If set to <kbd>true</kbd> the symbol will be highlighted when one of the nets attached to its pins are highlighted.</p>
|
||||
<li><kbd>net_name</kbd></li>
|
||||
|
|
|
|||
40
src/draw.c
40
src/draw.c
|
|
@ -414,6 +414,32 @@ void draw_temp_string(GC gctext, int what, const char *str, short rot, short fli
|
|||
}
|
||||
|
||||
|
||||
void get_sym_text_size(int inst, int text_n, double *xscale, double *yscale)
|
||||
{
|
||||
char attr[50];
|
||||
const char *ts;
|
||||
double size;
|
||||
int sym_n = xctx->inst[inst].ptr;
|
||||
xText *txtptr;
|
||||
|
||||
if(sym_n >= 0 && xctx->sym[sym_n].texts > text_n) {
|
||||
txtptr = &(xctx->sym[sym_n].text[text_n]);
|
||||
my_snprintf(attr, S(attr), "text_%d_size", text_n);
|
||||
ts = get_tok_value(xctx->inst[inst].prop_ptr, attr, 0);
|
||||
if(xctx->tok_size) {
|
||||
size = atof(ts);
|
||||
*xscale = size;
|
||||
*yscale = size;
|
||||
} else {
|
||||
*xscale = txtptr->xscale;
|
||||
*yscale = txtptr->yscale;
|
||||
}
|
||||
} else {
|
||||
*xscale = *yscale = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* layer: the set of symbol objects on xschem layer 'layer' to draw
|
||||
* c : the layer 'c' to draw those objects on (if != layer it is the hilight color)
|
||||
|
|
@ -644,8 +670,11 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot,
|
|||
{
|
||||
for(j=0;j< symptr->texts; ++j)
|
||||
{
|
||||
double xscale, yscale;
|
||||
|
||||
get_sym_text_size(n, j, &xscale, &yscale);
|
||||
text = symptr->text[j];
|
||||
if(!text.txt_ptr || !text.txt_ptr[0] || text.xscale*FONTWIDTH*xctx->mooz<1) continue;
|
||||
if(!text.txt_ptr || !text.txt_ptr[0] || xscale*FONTWIDTH*xctx->mooz<1) continue;
|
||||
if(!xctx->show_hidden_texts && (text.flags & HIDE_TEXT)) continue;
|
||||
if( hide && text.txt_ptr && strcmp(text.txt_ptr, "@symname") && strcmp(text.txt_ptr, "@name") ) continue;
|
||||
ROTATION(rot, flip, 0.0,0.0,text.x0,text.y0,x1,y1);
|
||||
|
|
@ -686,7 +715,7 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot,
|
|||
draw_string(textlayer, what, txtptr,
|
||||
(text.rot + ( (flip && (text.rot & 1) ) ? rot+2 : rot) ) & 0x3,
|
||||
flip^text.flip, text.hcenter, text.vcenter,
|
||||
x0+x1, y0+y1, text.xscale, text.yscale);
|
||||
x0+x1, y0+y1, xscale, yscale);
|
||||
my_free(_ALLOC_ID_, &txtptr);
|
||||
#if HAS_CAIRO!=1
|
||||
drawrect(textlayer, END, 0.0, 0.0, 0.0, 0.0, 0);
|
||||
|
|
@ -837,8 +866,11 @@ void draw_temp_symbol(int what, GC gc, int n,int layer,short tmp_flip, short rot
|
|||
char *txtptr = NULL;
|
||||
for(j=0;j< symptr->texts; ++j)
|
||||
{
|
||||
double xscale, yscale;
|
||||
|
||||
get_sym_text_size(n, j, &xscale, &yscale);
|
||||
text = symptr->text[j];
|
||||
if(!text.txt_ptr || !text.txt_ptr[0] || text.xscale*FONTWIDTH*xctx->mooz<1) continue;
|
||||
if(!text.txt_ptr || !text.txt_ptr[0] || xscale*FONTWIDTH*xctx->mooz<1) continue;
|
||||
if(!xctx->show_hidden_texts && (text.flags & HIDE_TEXT)) continue;
|
||||
ROTATION(rot, flip, 0.0,0.0,text.x0,text.y0,x1,y1);
|
||||
#if HAS_CAIRO==1
|
||||
|
|
@ -847,7 +879,7 @@ void draw_temp_symbol(int what, GC gc, int n,int layer,short tmp_flip, short rot
|
|||
my_strdup2(_ALLOC_ID_, &txtptr, translate(n, text.txt_ptr));
|
||||
if(txtptr[0]) draw_temp_string(gc, what, txtptr,
|
||||
(text.rot + ( (flip && (text.rot & 1) ) ? rot+2 : rot) ) & 0x3,
|
||||
flip^text.flip, text.hcenter, text.vcenter, x0+x1, y0+y1, text.xscale, text.yscale);
|
||||
flip^text.flip, text.hcenter, text.vcenter, x0+x1, y0+y1, xscale, yscale);
|
||||
my_free(_ALLOC_ID_, &txtptr);
|
||||
#if HAS_CAIRO==1
|
||||
if(customfont) {
|
||||
|
|
|
|||
|
|
@ -893,8 +893,11 @@ static void ps_draw_symbol(int n,int layer, int what, short tmp_flip, short rot,
|
|||
const char *txtptr;
|
||||
for(j=0;j< (xctx->inst[n].ptr+ xctx->sym)->texts; ++j)
|
||||
{
|
||||
double xscale, yscale;
|
||||
|
||||
get_sym_text_size(n, j, &xscale, &yscale);
|
||||
text = (xctx->inst[n].ptr+ xctx->sym)->text[j];
|
||||
/* if(text.xscale*FONTWIDTH* xctx->mooz<1) continue; */
|
||||
/* if(xscale*FONTWIDTH* xctx->mooz<1) continue; */
|
||||
if(!xctx->show_hidden_texts && (text.flags & HIDE_TEXT)) continue;
|
||||
if( hide && text.txt_ptr && strcmp(text.txt_ptr, "@symname") && strcmp(text.txt_ptr, "@name") ) continue;
|
||||
txtptr= translate(n, text.txt_ptr);
|
||||
|
|
@ -929,12 +932,12 @@ static void ps_draw_symbol(int n,int layer, int what, short tmp_flip, short rot,
|
|||
ps_draw_string(textlayer, txtptr,
|
||||
(text.rot + ( (flip && (text.rot & 1) ) ? rot+2 : rot) ) & 0x3,
|
||||
flip^text.flip, text.hcenter, text.vcenter,
|
||||
x0+x1, y0+y1, text.xscale, text.yscale);
|
||||
x0+x1, y0+y1, xscale, yscale);
|
||||
} else {
|
||||
old_ps_draw_string(textlayer, txtptr,
|
||||
(text.rot + ( (flip && (text.rot & 1) ) ? rot+2 : rot) ) & 0x3,
|
||||
flip^text.flip, text.hcenter, text.vcenter,
|
||||
x0+x1, y0+y1, text.xscale, text.yscale);
|
||||
x0+x1, y0+y1, xscale, yscale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4760,7 +4760,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
|
||||
/* test
|
||||
* Testmode ... */
|
||||
else if(0 && !strcmp(argv[1], "test") )
|
||||
else if(1 && !strcmp(argv[1], "test") )
|
||||
{
|
||||
Iterator_ctx ctx;
|
||||
Objectentry *objectptr;
|
||||
|
|
@ -4806,8 +4806,11 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
del_object_table();
|
||||
Tcl_ResetResult(interp);
|
||||
}
|
||||
else if(argc > 2 && atoi(argv[2]) == 2) {
|
||||
dbg(0, "cur=%d, tail=%d, head=%d\n", xctx->cur_undo_ptr, xctx->tail_undo_ptr, xctx->head_undo_ptr);
|
||||
/* test 2 inst text_n */
|
||||
else if(argc > 5 && atoi(argv[2]) == 2) {
|
||||
double sx, sy;
|
||||
get_sym_text_size(atoi(argv[3]), atoi(argv[4]), &sx, &sy);
|
||||
dbg(0, "size=%g, %g\n", sx, sy);
|
||||
Tcl_ResetResult(interp);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -352,6 +352,10 @@ void symbol_bbox(int i, double *x1,double *y1, double *x2, double *y2)
|
|||
/* strings bbox */
|
||||
for(j=0;j< (xctx->inst[i].ptr+ xctx->sym)->texts; ++j)
|
||||
{
|
||||
double xscale, yscale;
|
||||
|
||||
get_sym_text_size(i, j, &xscale, &yscale);
|
||||
|
||||
text = (xctx->inst[i].ptr+ xctx->sym)->text[j];
|
||||
if(!xctx->show_hidden_texts && (text.flags & HIDE_TEXT)) continue;
|
||||
sym_flip = flip;
|
||||
|
|
@ -363,7 +367,7 @@ void symbol_bbox(int i, double *x1,double *y1, double *x2, double *y2)
|
|||
#if HAS_CAIRO==1
|
||||
customfont=set_text_custom_font(&text);
|
||||
#endif
|
||||
text_bbox(tmp_txt, text.xscale, text.yscale,
|
||||
text_bbox(tmp_txt, xscale, yscale,
|
||||
(text.rot + ( (sym_flip && (text.rot & 1) ) ? sym_rot+2 : sym_rot)) &0x3,
|
||||
sym_flip ^ text.flip, text.hcenter, text.vcenter,
|
||||
x0+text_x0,y0+text_y0, &xx1,&yy1,&xx2,&yy2, &tmp, &dtmp);
|
||||
|
|
|
|||
|
|
@ -542,8 +542,11 @@ static void svg_draw_symbol(int c, int n,int layer,short tmp_flip, short rot,
|
|||
{
|
||||
const char *txtptr;
|
||||
for(j=0;j< symptr->texts; ++j) {
|
||||
double xscale, yscale;
|
||||
|
||||
get_sym_text_size(n, j, &xscale, &yscale);
|
||||
text = symptr->text[j];
|
||||
/* if(text.xscale*FONTWIDTH* xctx->mooz<1) continue; */
|
||||
/* if(xscale*FONTWIDTH* xctx->mooz<1) continue; */
|
||||
if(!xctx->show_hidden_texts && (symptr->text[j].flags & HIDE_TEXT)) continue;
|
||||
if( hide && text.txt_ptr && strcmp(text.txt_ptr, "@symname") && strcmp(text.txt_ptr, "@name") ) continue;
|
||||
txtptr= translate(n, text.txt_ptr);
|
||||
|
|
@ -573,12 +576,12 @@ static void svg_draw_symbol(int c, int n,int layer,short tmp_flip, short rot,
|
|||
svg_draw_string(textlayer, txtptr,
|
||||
(text.rot + ( (flip && (text.rot & 1) ) ? rot+2 : rot) ) & 0x3,
|
||||
flip^text.flip, text.hcenter, text.vcenter,
|
||||
x0+x1, y0+y1, text.xscale, text.yscale);
|
||||
x0+x1, y0+y1, xscale, yscale);
|
||||
else
|
||||
old_svg_draw_string(textlayer, txtptr,
|
||||
(text.rot + ( (flip && (text.rot & 1) ) ? rot+2 : rot) ) & 0x3,
|
||||
flip^text.flip, text.hcenter, text.vcenter,
|
||||
x0+x1, y0+y1, text.xscale, text.yscale);
|
||||
x0+x1, y0+y1, xscale, yscale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1356,6 +1356,7 @@ extern void find_closest_net_or_symbol_pin(double mx,double my, double *x, doubl
|
|||
extern void drawline(int c, int what, double x1,double y1,double x2,double y2, int dash, void *ct);
|
||||
extern void draw_string(int layer,int what, const char *str, short rot, short flip, int hcenter, int vcenter,
|
||||
double x1, double y1, double xscale, double yscale);
|
||||
extern void get_sym_text_size(int inst, int text_n, double *xscale, double *yscale);
|
||||
extern void draw_symbol(int what,int c, int n,int layer,
|
||||
short tmp_flip, short tmp_rot, double xoffset, double yoffset);
|
||||
extern void drawrect(int c, int what, double rectx1,double recty1,
|
||||
|
|
|
|||
Loading…
Reference in New Issue