draw_symbol(): draw text at end as done in draw() fo preserve stacking order of objects

This commit is contained in:
stefan schippers 2025-04-05 11:27:45 +02:00
parent 8e2748905a
commit 834d2c9757
4 changed files with 21 additions and 36 deletions

View File

@ -492,6 +492,7 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot,
register xSymbol *symptr;
char *type;
int lvs_ignore = 0;
int c_for_text;
#if HAS_CAIRO==1
const char *textfont;
#endif
@ -675,25 +676,19 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot,
draw_texts:
if(
!(xctx->inst[n].flags & HIDE_SYMBOL_TEXTS) &&
(
(layer==TEXTWIRELAYER && (xctx->inst[n].flags & PIN_OR_LABEL) ) ||
(xctx->sym_txt && (layer==TEXTLAYER) && !(xctx->inst[n].flags & PIN_OR_LABEL))
)
)
{
if(xctx->inst[n].flags & PIN_OR_LABEL) c_for_text = TEXTWIRELAYER;
if(xctx->sym_txt && !(xctx->inst[n].flags & PIN_OR_LABEL)) c_for_text = TEXTLAYER;
if( !(xctx->inst[n].flags & HIDE_SYMBOL_TEXTS) && (layer == cadlayers - 1)) {
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] || xscale*FONTWIDTH*xctx->mooz<1) continue;
if(!xctx->show_hidden_texts && (text.flags & (HIDE_TEXT | HIDE_TEXT_INSTANTIATED))) 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);
textlayer = c;
textlayer = c_for_text;
/* do not allow custom text color on hilighted instances */
if(disabled == 1) textlayer = GRIDLAYER;
else if(disabled == 2) textlayer = PINLAYER;
@ -706,7 +701,7 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot,
else textlayer = symptr->text[j].layer;
}
}
if(textlayer < 0 || textlayer >= cadlayers) textlayer = c;
if(textlayer < 0 || textlayer >= cadlayers) textlayer = c_for_text;
/* display PINLAYER colored instance texts even if PINLAYER disabled */
if(xctx->inst[n].color == -PINLAYER || xctx->enable_layer[textlayer]) {
char *txtptr = NULL;
@ -5037,7 +5032,7 @@ void draw(void)
symptr->arcs[c] ||
symptr->rects[c] ||
symptr->polygons[c] ||
((c==TEXTWIRELAYER || c==TEXTLAYER) && symptr->texts) )
((c==cadlayers - 1) && symptr->texts) )
{
draw_symbol(ADD, cc, i,c, 0, 0, 0.0, 0.0); /* ... then draw current layer */
}

View File

@ -2223,7 +2223,7 @@ void draw_hilight_net(int on_window)
symptr = (xctx->inst[i].ptr+ xctx->sym);
if( c==0 || /*draw_symbol call is needed on layer 0 to avoid redundant work (outside check) */
symptr->lines[c] || symptr->rects[c] || symptr->arcs[c] || symptr->polygons[c] ||
((c==TEXTWIRELAYER || c==TEXTLAYER) && symptr->texts)) {
((c == cadlayers - 1) && symptr->texts)) {
draw_symbol(ADD, col, i,c,0,0,0.0,0.0);
}
filledrect(col, END, 0.0, 0.0, 0.0, 0.0, 2, -1, -1); /* last parameter must be 2! */

View File

@ -901,6 +901,7 @@ static void ps_draw_symbol(int c, int n,int layer, int what, short tmp_flip, sho
char *type;
int lvs_ignore = 0;
char *textfont;
int c_for_text;
type = xctx->sym[xctx->inst[n].ptr].type;
lvs_ignore=tclgetboolvar("lvs_ignore");
@ -1097,15 +1098,9 @@ static void ps_draw_symbol(int c, int n,int layer, int what, short tmp_flip, sho
} /* if( (!hide && xctx->enable_layer[layer]) || ... */
draw_texts:
if(
!(xctx->inst[n].flags & HIDE_SYMBOL_TEXTS) &&
(
(layer==TEXTWIRELAYER && (xctx->inst[n].flags & PIN_OR_LABEL) ) ||
(xctx->sym_txt && (layer==TEXTLAYER) && !(xctx->inst[n].flags & PIN_OR_LABEL))
)
)
{
if(xctx->inst[n].flags & PIN_OR_LABEL) c_for_text = TEXTWIRELAYER;
if(xctx->sym_txt && !(xctx->inst[n].flags & PIN_OR_LABEL)) c_for_text = TEXTLAYER;
if( !(xctx->inst[n].flags & HIDE_SYMBOL_TEXTS) && (layer == cadlayers - 1)) {
const char *txtptr;
for(j=0;j< (xctx->inst[n].ptr+ xctx->sym)->texts; ++j)
{
@ -1118,7 +1113,7 @@ static void ps_draw_symbol(int c, int n,int layer, int what, short tmp_flip, sho
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);
textlayer = c;
textlayer = c_for_text;
/* do not allow custom text color on hilighted instances */
if(disabled == 1) textlayer = GRIDLAYER;
else if(disabled == 2) textlayer = PINLAYER;
@ -1128,8 +1123,8 @@ static void ps_draw_symbol(int c, int n,int layer, int what, short tmp_flip, sho
if(lay != -1) textlayer = lay;
else textlayer = symptr->text[j].layer;
}
if(textlayer < 0 || textlayer >= cadlayers) textlayer = c;
if(textlayer != c) set_ps_colors(textlayer);
if(textlayer < 0 || textlayer >= cadlayers) textlayer = c_for_text;
if(textlayer != c_for_text) set_ps_colors(textlayer);
/* display PINLAYER colored instance texts even if PINLAYER disabled */
if(xctx->inst[n].color == -PINLAYER || xctx->enable_layer[textlayer]) {

View File

@ -619,6 +619,7 @@ static void svg_draw_symbol(int c, int n,int layer,short tmp_flip, short rot,
char *type;
int lvs_ignore = 0;
char *textfont;
int c_for_text;
type = xctx->sym[xctx->inst[n].ptr].type;
lvs_ignore=tclgetboolvar("lvs_ignore");
@ -777,15 +778,9 @@ static void svg_draw_symbol(int c, int n,int layer,short tmp_flip, short rot,
}
draw_texts:
if(
!(xctx->inst[n].flags & HIDE_SYMBOL_TEXTS) &&
(
(layer==TEXTWIRELAYER && (xctx->inst[n].flags & PIN_OR_LABEL) ) ||
(xctx->sym_txt && (layer==TEXTLAYER) && !(xctx->inst[n].flags & PIN_OR_LABEL))
)
)
{
if(xctx->inst[n].flags & PIN_OR_LABEL) c_for_text = TEXTWIRELAYER;
if(xctx->sym_txt && !(xctx->inst[n].flags & PIN_OR_LABEL)) c_for_text = TEXTLAYER;
if( !(xctx->inst[n].flags & HIDE_SYMBOL_TEXTS) && (layer == cadlayers - 1)) {
const char *txtptr;
for(j=0;j< symptr->texts; ++j) {
double xscale, yscale;
@ -797,7 +792,7 @@ static void svg_draw_symbol(int c, int n,int layer,short tmp_flip, short rot,
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);
textlayer = c;
textlayer = c_for_text;
/* do not allow custom text color on hilighted instances */
if(disabled == 1) textlayer = GRIDLAYER;
else if(disabled == 2) textlayer = PINLAYER;
@ -807,7 +802,7 @@ static void svg_draw_symbol(int c, int n,int layer,short tmp_flip, short rot,
if(lay != -1) textlayer = lay;
else textlayer = symptr->text[j].layer;
}
if(textlayer < 0 || textlayer >= cadlayers) textlayer = c;
if(textlayer < 0 || textlayer >= cadlayers) textlayer = c_for_text;
/* display PINLAYER colored instance texts even if PINLAYER disabled */
if(xctx->inst[n].color == PINLAYER || xctx->enable_layer[textlayer]) {