code formating, use some intermediate variables for code readability, line length limited to 124 chars

This commit is contained in:
Stefan Schippers 2020-10-04 23:55:43 +02:00
parent 3060217aec
commit 051b20c014
14 changed files with 233 additions and 218 deletions

View File

@ -268,7 +268,7 @@ void resetwin(void)
}
#endif
#ifdef HAS_CAIRO
cairo_destroy(save_ctx);
cairo_destroy(cairo_save_ctx);
cairo_surface_destroy(save_sfc);
#if HAS_XRENDER==1
@ -286,12 +286,12 @@ void resetwin(void)
fprintf(errfp, "ERROR: invalid cairo xcb surface\n");
exit(-1);
}
save_ctx = cairo_create(save_sfc);
cairo_set_line_width(save_ctx, 1);
cairo_set_line_join(save_ctx, CAIRO_LINE_JOIN_ROUND);
cairo_set_line_cap(save_ctx, CAIRO_LINE_CAP_ROUND);
cairo_select_font_face (save_ctx, cairo_font_name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (save_ctx, 20);
cairo_save_ctx = cairo_create(save_sfc);
cairo_set_line_width(cairo_save_ctx, 1);
cairo_set_line_join(cairo_save_ctx, CAIRO_LINE_JOIN_ROUND);
cairo_set_line_cap(cairo_save_ctx, CAIRO_LINE_CAP_ROUND);
cairo_select_font_face (cairo_save_ctx, cairo_font_name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cairo_save_ctx, 20);
/* 20171125 select xlib or xcb :-) */
#if HAS_XCB==1 && HAS_XRENDER==1
cairo_xcb_surface_set_size(sfc, xschem_w, xschem_h); /* 20171123 */
@ -937,7 +937,7 @@ int place_symbol(int pos, const char *symbol_name, double x, double y, int rot,
dbg(1, "place_symbol() :all inst_ptr members set\n"); /* 03-02-2000 */
if(first_call) hash_all_names(n);
if(inst_props) {
new_prop_string(n, inst_props,!first_call, disable_unique_names); /* 20171214 first_call */
new_prop_string(n, inst_props,!first_call, dis_uniq_names); /* 20171214 first_call */
}
else {
set_inst_prop(n); /* no props, get from sym template, also calls new_prop_string() */
@ -1391,7 +1391,7 @@ void calc_drawing_bbox(Box *boundbox, int selected)
updatebbox(count,boundbox,&tmp);
}
#ifdef HAS_CAIRO
if(customfont) cairo_restore(ctx);
if(customfont) cairo_restore(cairo_ctx);
#endif
}
for(i=0;i<lastinst;i++)
@ -2093,8 +2093,8 @@ int text_bbox(const char *str, double xscale, double yscale,
/* if(size*mooz>800.) { */
/* return 0; */
/* } */
cairo_set_font_size (ctx, size*mooz);
cairo_font_extents(ctx, &fext);
cairo_set_font_size (cairo_ctx, size*mooz);
cairo_font_extents(cairo_ctx, &fext);
ww=0.; hh=1.;
c=0;
@ -2107,7 +2107,7 @@ int text_bbox(const char *str, double xscale, double yscale,
hh++;
cairo_lines++;
if(str_ptr[0]!='\0') {
cairo_text_extents(ctx, str_ptr, &ext);
cairo_text_extents(cairo_ctx, str_ptr, &ext);
maxw = ext.x_advance > ext.width ? ext.x_advance : ext.width;
if(maxw > ww) ww= maxw;
}
@ -2118,7 +2118,7 @@ int text_bbox(const char *str, double xscale, double yscale,
c++;
}
if(str_ptr && str_ptr[0]!='\0') {
cairo_text_extents(ctx, str_ptr, &ext);
cairo_text_extents(cairo_ctx, str_ptr, &ext);
maxw = ext.x_advance > ext.width ? ext.x_advance : ext.width;
if(maxw > ww) ww= maxw;
}
@ -2221,8 +2221,7 @@ void place_text(int draw_text, double mx, double my)
int textlayer;
const char *str;
int save_draw;
/* 20171112 */
Text *t = &textelement[lasttext];
#ifdef HAS_CAIRO
char *textfont;
#endif
@ -2236,77 +2235,73 @@ void place_text(int draw_text, double mx, double my)
tclsetvar("vsize","0.4");
tcleval("enter_text {text:} normal");
dbg(1, "place_text(): hsize=%s vsize=%s\n",tclgetvar("hsize"),
tclgetvar("vsize") );
dbg(1, "place_text(): hsize=%s vsize=%s\n",tclgetvar("hsize"), tclgetvar("vsize") );
txt = (char *)tclgetvar("retval");
if(!strcmp(txt,"")) return; /* 01112004 dont allocate text object if empty string given */
if(!strcmp(txt,"")) return; /* dont allocate text object if empty string given */
push_undo(); /* 20150327 */
check_text_storage();
textelement[lasttext].txt_ptr=NULL;
textelement[lasttext].prop_ptr=NULL; /* 20111006 added missing initialization of pointer */
textelement[lasttext].font=NULL; /* 20171206 */
my_strdup(19, &textelement[lasttext].txt_ptr, txt);
textelement[lasttext].x0=mx;
textelement[lasttext].y0=my;
textelement[lasttext].rot=0;
textelement[lasttext].flip=0;
textelement[lasttext].sel=0;
textelement[lasttext].xscale=
atof(tclgetvar("hsize"));
textelement[lasttext].yscale=
atof(tclgetvar("vsize"));
my_strdup(20, &textelement[lasttext].prop_ptr, (char *)tclgetvar("props"));
t->txt_ptr=NULL;
t->prop_ptr=NULL; /* 20111006 added missing initialization of pointer */
t->font=NULL; /* 20171206 */
my_strdup(19, &t->txt_ptr, txt);
t->x0=mx;
t->y0=my;
t->rot=0;
t->flip=0;
t->sel=0;
t->xscale= atof(tclgetvar("hsize"));
t->yscale= atof(tclgetvar("vsize"));
my_strdup(20, &t->prop_ptr, (char *)tclgetvar("props"));
/* debug ... */
/* textelement[lasttext].prop_ptr=NULL; */
/* t->prop_ptr=NULL; */
dbg(1, "place_text(): done text input\n");
str = get_tok_value(textelement[lasttext].prop_ptr, "hcenter", 0);
textelement[lasttext].hcenter = strcmp(str, "true") ? 0 : 1;
str = get_tok_value(textelement[lasttext].prop_ptr, "vcenter", 0);
textelement[lasttext].vcenter = strcmp(str, "true") ? 0 : 1;
str = get_tok_value(t->prop_ptr, "hcenter", 0);
t->hcenter = strcmp(str, "true") ? 0 : 1;
str = get_tok_value(t->prop_ptr, "vcenter", 0);
t->vcenter = strcmp(str, "true") ? 0 : 1;
str = get_tok_value(textelement[lasttext].prop_ptr, "layer", 0);
if(str[0]) textelement[lasttext].layer = atoi(str);
else textelement[lasttext].layer = -1;
str = get_tok_value(t->prop_ptr, "layer", 0);
if(str[0]) t->layer = atoi(str);
else t->layer = -1;
textelement[lasttext].flags = 0;
str = get_tok_value(textelement[lasttext].prop_ptr, "slant", 0);
textelement[lasttext].flags |= strcmp(str, "oblique") ? 0 : TEXT_OBLIQUE;
textelement[lasttext].flags |= strcmp(str, "italic") ? 0 : TEXT_ITALIC;
str = get_tok_value(textelement[lasttext].prop_ptr, "weight", 0);
textelement[lasttext].flags |= strcmp(str, "bold") ? 0 : TEXT_BOLD;
t->flags = 0;
str = get_tok_value(t->prop_ptr, "slant", 0);
t->flags |= strcmp(str, "oblique") ? 0 : TEXT_OBLIQUE;
t->flags |= strcmp(str, "italic") ? 0 : TEXT_ITALIC;
str = get_tok_value(t->prop_ptr, "weight", 0);
t->flags |= strcmp(str, "bold") ? 0 : TEXT_BOLD;
my_strdup(21, &textelement[lasttext].font, get_tok_value(textelement[lasttext].prop_ptr, "font", 0));/* 20171206 */
textlayer = textelement[lasttext].layer;
my_strdup(21, &t->font, get_tok_value(t->prop_ptr, "font", 0));/* 20171206 */
textlayer = t->layer;
if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER;
#ifdef HAS_CAIRO
textfont = textelement[lasttext].font;
if((textfont && textfont[0]) || textelement[lasttext].flags) {
textfont = t->font;
if((textfont && textfont[0]) || t->flags) {
cairo_font_slant_t slant;
cairo_font_weight_t weight;
textfont = (textelement[lasttext].font && textelement[lasttext].font[0]) ? textelement[lasttext].font : cairo_font_name;
weight = ( textelement[lasttext].flags & TEXT_BOLD) ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL;
textfont = (t->font && t->font[0]) ? t->font : cairo_font_name;
weight = ( t->flags & TEXT_BOLD) ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL;
slant = CAIRO_FONT_SLANT_NORMAL;
if(textelement[lasttext].flags & TEXT_ITALIC) slant = CAIRO_FONT_SLANT_ITALIC;
if(textelement[lasttext].flags & TEXT_OBLIQUE) slant = CAIRO_FONT_SLANT_OBLIQUE;
cairo_save(ctx);
cairo_save(save_ctx);
cairo_select_font_face (ctx, textfont, slant, weight);
cairo_select_font_face (save_ctx, textfont, slant, weight);
if(t->flags & TEXT_ITALIC) slant = CAIRO_FONT_SLANT_ITALIC;
if(t->flags & TEXT_OBLIQUE) slant = CAIRO_FONT_SLANT_OBLIQUE;
cairo_save(cairo_ctx);
cairo_save(cairo_save_ctx);
cairo_select_font_face (cairo_ctx, textfont, slant, weight);
cairo_select_font_face (cairo_save_ctx, textfont, slant, weight);
}
#endif
save_draw=draw_window; /* 20181009 */
draw_window=1;
if(draw_text) draw_string(textlayer, NOW, textelement[lasttext].txt_ptr, 0, 0,
textelement[lasttext].hcenter, textelement[lasttext].vcenter,
textelement[lasttext].x0,textelement[lasttext].y0,
textelement[lasttext].xscale, textelement[lasttext].yscale);
if(draw_text) {
draw_string(textlayer, NOW, t->txt_ptr, 0, 0, t->hcenter, t->vcenter, t->x0,t->y0, t->xscale, t->yscale);
}
draw_window = save_draw;
#ifdef HAS_CAIRO
if((textfont && textfont[0]) || textelement[lasttext].flags) {
cairo_restore(ctx);
cairo_restore(save_ctx);
if((textfont && textfont[0]) || t->flags) {
cairo_restore(cairo_ctx);
cairo_restore(cairo_save_ctx);
}
#endif
select_text(lasttext, SELECTED, 0);

View File

@ -108,14 +108,15 @@ void print_image()
XSetTile(display, gctiled, save_pixmap);
#ifdef HAS_CAIRO
cairo_destroy(save_ctx);
cairo_destroy(cairo_save_ctx);
cairo_surface_destroy(save_sfc);
#if HAS_XRENDER==1
#if HAS_XCB==1
save_sfc = cairo_xcb_surface_create_with_xrender_format(xcbconn, screen_xcb, save_pixmap, &format_rgb, w, h);
#else
save_sfc = cairo_xlib_surface_create_with_xrender_format (display, save_pixmap, DefaultScreenOfDisplay(display), format, w, h);
save_sfc = cairo_xlib_surface_create_with_xrender_format(display,
save_pixmap, DefaultScreenOfDisplay(display), format, w, h);
#endif /*HAS_XCB */
#else
save_sfc = cairo_xlib_surface_create(display, save_pixmap, visual, w, h);
@ -124,13 +125,13 @@ void print_image()
fprintf(errfp, "ERROR: invalid cairo xcb surface\n");
exit(-1);
}
save_ctx = cairo_create(save_sfc);
cairo_set_line_width(save_ctx, 1);
cairo_set_line_join(save_ctx, CAIRO_LINE_JOIN_ROUND);
cairo_set_line_cap(save_ctx, CAIRO_LINE_CAP_ROUND);
cairo_select_font_face (save_ctx, cairo_font_name,
cairo_save_ctx = cairo_create(save_sfc);
cairo_set_line_width(cairo_save_ctx, 1);
cairo_set_line_join(cairo_save_ctx, CAIRO_LINE_JOIN_ROUND);
cairo_set_line_cap(cairo_save_ctx, CAIRO_LINE_CAP_ROUND);
cairo_select_font_face (cairo_save_ctx, cairo_font_name,
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (save_ctx, 20);
cairo_set_font_size (cairo_save_ctx, 20);
#endif /*HAS_CAIRO */
for(tmp=0;tmp<cadlayers;tmp++)
{
@ -183,14 +184,15 @@ void print_image()
#ifdef HAS_CAIRO
cairo_destroy(save_ctx);
cairo_destroy(cairo_save_ctx);
cairo_surface_destroy(save_sfc);
#if HAS_XRENDER==1
#if HAS_XCB==1
save_sfc = cairo_xcb_surface_create_with_xrender_format(xcbconn, screen_xcb, save_pixmap, &format_rgb, w, h);
#else
save_sfc = cairo_xlib_surface_create_with_xrender_format (display, save_pixmap, DefaultScreenOfDisplay(display), format, w, h);
save_sfc = cairo_xlib_surface_create_with_xrender_format (display,
save_pixmap, DefaultScreenOfDisplay(display), format, w, h);
#endif /*HAS_XCB */
#else
save_sfc = cairo_xlib_surface_create(display, save_pixmap, visual, w, h);
@ -199,12 +201,12 @@ void print_image()
fprintf(errfp, "ERROR: invalid cairo xcb surface\n");
exit(-1);
}
save_ctx = cairo_create(save_sfc);
cairo_set_line_width(save_ctx, 1);
cairo_set_line_join(save_ctx, CAIRO_LINE_JOIN_ROUND);
cairo_set_line_cap(save_ctx, CAIRO_LINE_CAP_ROUND);
cairo_select_font_face (save_ctx, cairo_font_name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (save_ctx, 20);
cairo_save_ctx = cairo_create(save_sfc);
cairo_set_line_width(cairo_save_ctx, 1);
cairo_set_line_join(cairo_save_ctx, CAIRO_LINE_JOIN_ROUND);
cairo_set_line_cap(cairo_save_ctx, CAIRO_LINE_CAP_ROUND);
cairo_select_font_face (cairo_save_ctx, cairo_font_name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cairo_save_ctx, 20);
#endif /*HAS_CAIRO */
for(tmp=0;tmp<cadlayers;tmp++)
@ -221,7 +223,7 @@ void print_image()
}
#ifdef HAS_CAIRO
/* remember to call cairo_restore(ctx) when done !! */
/* remember to call cairo_restore(cairo_ctx) when done !! */
int set_text_custom_font(Text *txt) /* 20171122 for correct text_bbox calculation */
{
char *textfont;
@ -235,8 +237,8 @@ int set_text_custom_font(Text *txt) /* 20171122 for correct text_bbox calculatio
slant = CAIRO_FONT_SLANT_NORMAL;
if(txt->flags & TEXT_ITALIC) slant = CAIRO_FONT_SLANT_ITALIC;
if(txt->flags & TEXT_OBLIQUE) slant = CAIRO_FONT_SLANT_OBLIQUE;
cairo_save(ctx);
cairo_select_font_face (ctx, textfont, slant, weight);
cairo_save(cairo_ctx);
cairo_select_font_face (cairo_ctx, textfont, slant, weight);
return 1;
}
return 0;
@ -250,7 +252,7 @@ int set_text_custom_font(Text *txt)
#ifdef HAS_CAIRO
void cairo_draw_string_line(cairo_t *ctx, char *s,
void cairo_draw_string_line(cairo_t *cairo_ctx, char *s,
double x, double y, double size, int rot, int flip,
int lineno, double fontheight, double fontascent, double fontdescent, int llength)
{
@ -266,7 +268,7 @@ void cairo_draw_string_line(cairo_t *ctx, char *s,
/* GC gcclear; */
if(s==NULL) return;
if(llength==0) return;
cairo_text_extents(ctx, s, &ext);
cairo_text_extents(cairo_ctx, s, &ext);
xadvance = ext.x_advance > ext.width? ext.x_advance : ext.width;
line_delta = lineno*fontheight*cairo_font_line_spacing;
@ -293,15 +295,15 @@ void cairo_draw_string_line(cairo_t *ctx, char *s,
else if(rot==2 && flip==1) {iy=iy-fontheight-lines+line_delta+fontascent+vc;}
else if(rot==3 && flip==1) {iy=iy+xadvance+line_offset;ix+=line_delta+fontascent-vc;}
cairo_save(ctx);
cairo_translate(ctx, ix, iy);
cairo_rotate(ctx, XSCH_PI/2*rot1);
cairo_save(cairo_ctx);
cairo_translate(cairo_ctx, ix, iy);
cairo_rotate(cairo_ctx, XSCH_PI/2*rot1);
/* fprintf(errfp, "string_line: |%s|, y_bearing: %f descent: %f ascent: %f height: %f\n", */
/* s, ext.y_bearing, fontdescent, fontascent, fontheight); */
cairo_move_to(ctx, 0,0);
cairo_show_text(ctx, s);
cairo_restore(ctx);
cairo_move_to(cairo_ctx, 0,0);
cairo_show_text(cairo_ctx, s);
cairo_restore(cairo_ctx);
}
/* CAIRO version */
@ -348,18 +350,18 @@ void draw_string(int layer, int what, const char *s, int rot, int flip, int hcen
if(rot == 3 && flip == 1 ) { x=textx1;}
}
cairo_set_source_rgb(ctx,
cairo_set_source_rgb(cairo_ctx,
(double)xcolor_array[layer].red/65535.0,
(double)xcolor_array[layer].green/65535.0,
(double)xcolor_array[layer].blue/65535.0);
cairo_set_source_rgb(save_ctx,
cairo_set_source_rgb(cairo_save_ctx,
(double)xcolor_array[layer].red/65535.0,
(double)xcolor_array[layer].green/65535.0,
(double)xcolor_array[layer].blue/65535.0);
cairo_set_font_size (ctx, size*mooz);
cairo_set_font_size (save_ctx, size*mooz);
cairo_font_extents(ctx, &fext);
cairo_set_font_size (cairo_ctx, size*mooz);
cairo_set_font_size (cairo_save_ctx, size*mooz);
cairo_font_extents(cairo_ctx, &fext);
llength=0;
my_strdup2(73, &sss, s);
tt=ss=sss;
@ -368,9 +370,9 @@ void draw_string(int layer, int what, const char *s, int rot, int flip, int hcen
if(c=='\n' || c==0) {
*ss='\0';
/*fprintf(errfp, "cairo_draw_string(): tt=%s, longest line: %d\n", tt, cairo_longest_line); */
if(draw_window) cairo_draw_string_line(ctx, tt, x, y, size, rot, flip,
if(draw_window) cairo_draw_string_line(cairo_ctx, tt, x, y, size, rot, flip,
lineno, fext.height, fext.ascent, fext.descent, llength);
if(draw_pixmap) cairo_draw_string_line(save_ctx, tt, x, y, size, rot, flip,
if(draw_pixmap) cairo_draw_string_line(cairo_save_ctx, tt, x, y, size, rot, flip,
lineno, fext.height, fext.ascent, fext.descent, llength);
lineno++;
if(c==0) break;
@ -603,10 +605,10 @@ void draw_symbol(int what,int c, int n,int layer,int tmp_flip, int rot,
if(symptr->txtptr[j].flags & TEXT_ITALIC) slant = CAIRO_FONT_SLANT_ITALIC;
if(symptr->txtptr[j].flags & TEXT_OBLIQUE) slant = CAIRO_FONT_SLANT_OBLIQUE;
cairo_save(ctx);
cairo_save(save_ctx);
cairo_select_font_face (ctx, textfont, slant, weight);
cairo_select_font_face (save_ctx, textfont, slant, weight);
cairo_save(cairo_ctx);
cairo_save(cairo_save_ctx);
cairo_select_font_face (cairo_ctx, textfont, slant, weight);
cairo_select_font_face (cairo_save_ctx, textfont, slant, weight);
}
#endif
dbg(1, "drawing string: str=%s prop=%s\n", txtptr, text.prop_ptr);
@ -620,8 +622,8 @@ void draw_symbol(int what,int c, int n,int layer,int tmp_flip, int rot,
#endif
#ifdef HAS_CAIRO
if( (textfont && textfont[0]) || symptr->txtptr[j].flags) {
cairo_restore(ctx);
cairo_restore(save_ctx);
cairo_restore(cairo_ctx);
cairo_restore(cairo_save_ctx);
}
#endif
}
@ -746,7 +748,7 @@ void draw_temp_symbol(int what, GC gc, int n,int layer,int tmp_flip, int rot,
(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);
#ifdef HAS_CAIRO
if(customfont) cairo_restore(ctx);
if(customfont) cairo_restore(cairo_ctx);
#endif
}
@ -1587,23 +1589,26 @@ void draw(void)
if(draw_single_layer!=-1 && c != draw_single_layer) continue; /* 20151117 */
if(enable_layer[c]) for(i=0;i<lastline[c];i++) {
if(line[c][i].bus)
drawline(c, THICK, line[c][i].x1, line[c][i].y1, line[c][i].x2, line[c][i].y2, line[c][i].dash);
Line *l = &line[c][i];
if(l->bus)
drawline(c, THICK, l->x1, l->y1, l->x2, l->y2, l->dash);
else
drawline(c, ADD, line[c][i].x1, line[c][i].y1, line[c][i].x2, line[c][i].y2, line[c][i].dash);
drawline(c, ADD, l->x1, l->y1, l->x2, l->y2, l->dash);
}
if(enable_layer[c]) for(i=0;i<lastrect[c];i++)
{
drawrect(c, ADD, rect[c][i].x1, rect[c][i].y1, rect[c][i].x2, rect[c][i].y2, rect[c][i].dash);
filledrect(c, ADD, rect[c][i].x1, rect[c][i].y1, rect[c][i].x2, rect[c][i].y2);
Box *r = &rect[c][i];
drawrect(c, ADD, r->x1, r->y1, r->x2, r->y2, r->dash);
filledrect(c, ADD, r->x1, r->y1, r->x2, r->y2);
}
if(enable_layer[c]) for(i=0;i<lastarc[c];i++)
{
drawarc(c, ADD, arc[c][i].x, arc[c][i].y, arc[c][i].r, arc[c][i].a, arc[c][i].b, arc[c][i].fill, arc[c][i].dash);
xArc *a = &arc[c][i];
drawarc(c, ADD, a->x, a->y, a->r, a->a, a->b, a->fill, a->dash);
}
if(enable_layer[c]) for(i=0;i<lastpolygon[c];i++) {
/* 20180914 added fill */
drawpolygon(c, NOW, polygon[c][i].x, polygon[c][i].y, polygon[c][i].points, polygon[c][i].fill, polygon[c][i].dash);
xPolygon *p = &polygon[c][i];
drawpolygon(c, NOW, p->x, p->y, p->points, p->fill, p->dash);
}
if(use_hash) {
@ -1728,10 +1733,10 @@ void draw(void)
if(textelement[i].flags & TEXT_ITALIC) slant = CAIRO_FONT_SLANT_ITALIC;
if(textelement[i].flags & TEXT_OBLIQUE) slant = CAIRO_FONT_SLANT_OBLIQUE;
cairo_save(ctx);
cairo_save(save_ctx);
cairo_select_font_face (ctx, textfont, slant, weight);
cairo_select_font_face (save_ctx, textfont, slant, weight);
cairo_save(cairo_ctx);
cairo_save(cairo_save_ctx);
cairo_select_font_face (cairo_ctx, textfont, slant, weight);
cairo_select_font_face (cairo_save_ctx, textfont, slant, weight);
}
#endif
@ -1741,8 +1746,8 @@ void draw(void)
textelement[i].xscale, textelement[i].yscale);
#ifdef HAS_CAIRO
if((textfont && textfont[0]) || textelement[i].flags ) {
cairo_restore(ctx);
cairo_restore(save_ctx);
cairo_restore(cairo_ctx);
cairo_restore(cairo_save_ctx);
}
#endif
#ifndef HAS_CAIRO

View File

@ -389,7 +389,7 @@ void set_inst_prop(int i)
my_strdup2(70, &inst_ptr[i].instname, get_tok_value(ptr, "name",0)); /* 20150409 */
if(inst_ptr[i].instname[0]) {
my_strdup(101, &tmp, inst_ptr[i].prop_ptr);
new_prop_string(i, tmp, 0, disable_unique_names);
new_prop_string(i, tmp, 0, dis_uniq_names);
my_free(724, &tmp);
}
}
@ -760,7 +760,7 @@ void edit_text_property(int x)
textelement[sel].x0, textelement[sel].y0,
&xx1,&yy1,&xx2,&yy2);
#ifdef HAS_CAIRO
if(customfont) cairo_restore(ctx);
if(customfont) cairo_restore(cairo_ctx);
#endif
bbox(ADD, xx1, yy1, xx2, yy2 );
@ -781,7 +781,7 @@ void edit_text_property(int x)
textelement[sel].x0, textelement[sel].y0,
&xx1,&yy1,&xx2,&yy2);
#ifdef HAS_CAIRO
if(customfont) cairo_restore(ctx);
if(customfont) cairo_restore(cairo_ctx);
#endif
pcx = (rect[PINLAYER][l].x1+rect[PINLAYER][l].x2)/2.0;
@ -845,7 +845,7 @@ void edit_text_property(int x)
textelement[sel].x0, textelement[sel].y0,
&xx1,&yy1,&xx2,&yy2);
#ifdef HAS_CAIRO
if(customfont) cairo_restore(ctx);
if(customfont) cairo_restore(cairo_ctx);
#endif
bbox(ADD, xx1, yy1, xx2, yy2 );
@ -1070,7 +1070,7 @@ void update_symbol(const char *result, int x)
if(!pushed) { push_undo(); pushed=1;}
if(!k) hash_all_names(i);
new_prop_string(i, ptr, k, disable_unique_names); /* set new prop_ptr */
new_prop_string(i, ptr, k, dis_uniq_names); /* set new prop_ptr */
type=instdef[inst_ptr[i].ptr].type; /* 20150409 */
cond= !type || !IS_LABEL_SH_OR_PIN(type);

View File

@ -251,9 +251,7 @@ void find_closest_element(double mx,double my)
inst_ptr[i].instname, inst_ptr[i].x1,inst_ptr[i].y1,inst_ptr[i].x2,inst_ptr[i].y2);
if( POINTINSIDE(mx,my,inst_ptr[i].x1,inst_ptr[i].y1,inst_ptr[i].x2,inst_ptr[i].y2) )
{
/* tmp=pow(mx-inst_ptr[i].x0, 2)+pow(my-inst_ptr[i].y0, 2); */
tmp=pow(mx-(inst_ptr[i].xx1 + inst_ptr[i].xx2)/2, 2)+pow(my-(inst_ptr[i].yy1 + inst_ptr[i].yy2)/2, 2);
/* dbg(0, "i=%d, xx1=%g, yy1=%g, xx2=%g, yy2=%g\n", i, inst_ptr[i].xx1, inst_ptr[i].yy1, inst_ptr[i].xx2, inst_ptr[i].yy2); */
if(tmp*0.1 < distance)
{
r = i; distance = tmp*0.1;
@ -288,7 +286,7 @@ void find_closest_text(double mx,double my)
textelement[i].x0, textelement[i].y0,
&xx1,&yy1, &xx2,&yy2);
#ifdef HAS_CAIRO
if(customfont) cairo_restore(ctx);
if(customfont) cairo_restore(cairo_ctx);
#endif
if(POINTINSIDE(mx,my,xx1,yy1, xx2, yy2))
{

View File

@ -51,7 +51,7 @@ char rcfile[PATH_MAX] = {'\0'};
char *tcl_command = NULL;
char tcl_script[PATH_MAX] = {'\0'};
int persistent_command=0; /* remember last command 20181022 */
int disable_unique_names=0; /* if set allow instances with duplicate names */
int dis_uniq_names=0; /* if set allow instances with duplicate names */
int quit=0; /* set from process_options (ex netlist from cmdline and quit) */
int debug_var=-10; /* will be set to 0 in xinit.c */
int tcp_port = 0;
@ -276,7 +276,7 @@ int show_pin_net_names = 0;
#ifdef HAS_CAIRO
cairo_surface_t *sfc, *save_sfc;
cairo_t *ctx, *save_ctx;
cairo_t *cairo_ctx, *cairo_save_ctx;
XRenderPictFormat *format;
#if HAS_XCB==1

View File

@ -336,11 +336,13 @@ void hilight_parent_pins(void)
currentsch--;
if(entry)
{
bus_hilight_lookup(find_nth(net_node, ',', ((inst_number - 1) * mult + k - 1) % net_mult + 1), entry->value, XINSERT);
bus_hilight_lookup(find_nth(net_node, ',',
((inst_number - 1) * mult + k - 1) % net_mult + 1), entry->value, XINSERT);
}
else
{
bus_hilight_lookup(find_nth(net_node, ',', ((inst_number - 1) * mult + k - 1) % net_mult + 1), 0, XDELETE);
bus_hilight_lookup(find_nth(net_node, ',',
((inst_number - 1) * mult + k - 1) % net_mult + 1), 0, XDELETE);
}
}
}
@ -376,7 +378,8 @@ void hilight_child_pins(void)
for(k = 1; k<=mult; k++) {
dbg(1, "hilight_child_pins():looking nth net:%d, k=%d, inst_number=%d, mult=%d\n",
(inst_number-1)*mult+k, k, inst_number, mult);
dbg(1, "hilight_child_pins():looking net:%s\n", find_nth(net_node, ',', ((inst_number - 1) * mult + k - 1) % net_mult + 1));
dbg(1, "hilight_child_pins():looking net:%s\n", find_nth(net_node, ',',
((inst_number - 1) * mult + k - 1) % net_mult + 1));
currentsch--;
entry = bus_hilight_lookup(find_nth(net_node, ',', ((inst_number - 1) * mult + k - 1) % net_mult + 1), 0, XLOOKUP);
currentsch++;
@ -443,8 +446,8 @@ int search(const char *tok, const char *val, int sub, int sel, int what)
if(!strcmp(tok,"cell::name")) {
has_token = (inst_ptr[i].name != NULL) && inst_ptr[i].name[0];
str = inst_ptr[i].name;
} else if(!strncmp(tok,"cell::", 6)) {
my_strdup(142, &tmpname,get_tok_value((inst_ptr[i].ptr+instdef)->prop_ptr,tok+6,0)); /* flexible cell__ search 20140408 */
} else if(!strncmp(tok,"cell::", 6)) { /* cell::xxx looks for xxx in global symbol attributes */
my_strdup(142, &tmpname,get_tok_value((inst_ptr[i].ptr+instdef)->prop_ptr,tok+6,0));
has_token = get_tok_size;
if(tmpname) {
str = tmpname;

View File

@ -217,7 +217,7 @@ void draw_selection(GC g, int interruptable)
rx1+deltax, ry1+deltay,
textelement[n].xscale, textelement[n].yscale);
#ifdef HAS_CAIRO
if(customfont) cairo_restore(ctx);
if(customfont) cairo_restore(cairo_ctx);
#endif
break;
@ -759,7 +759,7 @@ void copy_objects(int what)
textelement[n].x0, textelement[n].y0,
&rx1,&ry1, &rx2,&ry2);
#ifdef HAS_CAIRO
if(customfont) cairo_restore(ctx);
if(customfont) cairo_restore(cairo_ctx);
#endif
bbox(ADD, rx1, ry1, rx2, ry2 );
*/
@ -809,17 +809,19 @@ void copy_objects(int what)
#ifdef HAS_CAIRO
textfont = textelement[lasttext].font; /* 20171206 */
if((textfont && textfont[0]) || textelement[lasttext].flags) {
char *font = textelement[lasttext].font;
int flags = textelement[lasttext].flags;
cairo_font_slant_t slant;
cairo_font_weight_t weight;
textfont = (textelement[lasttext].font && textelement[lasttext].font[0]) ? textelement[lasttext].font : cairo_font_name;
weight = ( textelement[lasttext].flags & TEXT_BOLD) ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL;
textfont = (font && font[0]) ? font : cairo_font_name;
weight = ( flags & TEXT_BOLD) ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL;
slant = CAIRO_FONT_SLANT_NORMAL;
if(textelement[lasttext].flags & TEXT_ITALIC) slant = CAIRO_FONT_SLANT_ITALIC;
if(textelement[lasttext].flags & TEXT_OBLIQUE) slant = CAIRO_FONT_SLANT_OBLIQUE;
cairo_save(ctx);
cairo_save(save_ctx);
cairo_select_font_face (ctx, textfont, slant, weight);
cairo_select_font_face (save_ctx, textfont, slant, weight);
if(flags & TEXT_ITALIC) slant = CAIRO_FONT_SLANT_ITALIC;
if(flags & TEXT_OBLIQUE) slant = CAIRO_FONT_SLANT_OBLIQUE;
cairo_save(cairo_ctx);
cairo_save(cairo_save_ctx);
cairo_select_font_face (cairo_ctx, textfont, slant, weight);
cairo_select_font_face (cairo_save_ctx, textfont, slant, weight);
}
#endif
draw_string(textlayer, ADD, textelement[lasttext].txt_ptr, /* draw moved txt */
@ -832,8 +834,8 @@ void copy_objects(int what)
#endif
#ifdef HAS_CAIRO
if( (textfont && textfont[0]) || textelement[lasttext].flags) {
cairo_restore(ctx);
cairo_restore(save_ctx);
cairo_restore(cairo_ctx);
cairo_restore(cairo_save_ctx);
}
#endif
selectedgroup[i].n=lasttext;
@ -869,7 +871,7 @@ void copy_objects(int what)
/* the newpropcnt argument is zero for the 1st call and used in */
/* new_prop_string() for cleaning some internal caches. */
if(!newpropcnt) hash_all_names(lastinst);
new_prop_string(lastinst, inst_ptr[n].prop_ptr,newpropcnt++, disable_unique_names);
new_prop_string(lastinst, inst_ptr[n].prop_ptr,newpropcnt++, dis_uniq_names);
my_strdup2(235, &inst_ptr[lastinst].instname, get_tok_value(inst_ptr[lastinst].prop_ptr, "name", 0)); /* 20150409 */
n=selectedgroup[i].n=lastinst;
@ -1305,7 +1307,7 @@ void move_objects(int what, int merge, double dx, double dy)
textelement[n].x0, textelement[n].y0,
&rx1,&ry1, &rx2,&ry2);
#ifdef HAS_CAIRO
if(customfont) cairo_restore(ctx);
if(customfont) cairo_restore(cairo_ctx);
#endif
bbox(ADD, rx1, ry1, rx2, ry2 );
@ -1333,10 +1335,10 @@ void move_objects(int what, int merge, double dx, double dy)
slant = CAIRO_FONT_SLANT_NORMAL;
if(textelement[n].flags & TEXT_ITALIC) slant = CAIRO_FONT_SLANT_ITALIC;
if(textelement[n].flags & TEXT_OBLIQUE) slant = CAIRO_FONT_SLANT_OBLIQUE;
cairo_save(ctx);
cairo_save(save_ctx);
cairo_select_font_face (ctx, textfont, slant, weight);
cairo_select_font_face (save_ctx, textfont, slant, weight);
cairo_save(cairo_ctx);
cairo_save(cairo_save_ctx);
cairo_select_font_face (cairo_ctx, textfont, slant, weight);
cairo_select_font_face (cairo_save_ctx, textfont, slant, weight);
}
#endif
draw_string(textlayer, ADD, textelement[n].txt_ptr, /* draw moved txt */
@ -1349,8 +1351,8 @@ void move_objects(int what, int merge, double dx, double dy)
#endif
#ifdef HAS_CAIRO
if( (textfont && textfont[0]) || textelement[n].flags) {
cairo_restore(ctx);
cairo_restore(save_ctx);
cairo_restore(cairo_ctx);
cairo_restore(cairo_save_ctx);
}
#endif
break;

View File

@ -219,7 +219,7 @@ void merge_inst(int k,FILE *fd)
ptr[i].node=NULL;
load_ascii_string(&prop_ptr,fd);
if(!k) hash_all_names(i);
new_prop_string(i, prop_ptr, k, disable_unique_names);
new_prop_string(i, prop_ptr, k, dis_uniq_names);
/* the final tmp argument is zero for the 1st call and used in */
/* new_prop_string() for cleaning some internal caches. */
my_strdup2(306, &inst_ptr[i].instname, get_tok_value(inst_ptr[i].prop_ptr, "name", 0)); /* 20150409 */

View File

@ -788,8 +788,8 @@ void read_xschem_file(FILE *fd)
if(inst_ptr[lastinst-1].name) {
char *str;
my_snprintf(name_embedded, S(name_embedded),
"%s/.xschem_embedded_%d_%s", tclgetvar("XSCHEM_TMP_DIR"), getpid(), get_cell_w_ext(inst_ptr[lastinst-1].name, 0));
my_snprintf(name_embedded, S(name_embedded), "%s/.xschem_embedded_%d_%s",
tclgetvar("XSCHEM_TMP_DIR"), getpid(), get_cell_w_ext(inst_ptr[lastinst-1].name, 0));
found=0;
for(i=0;i<lastinstdef;i++)
{

View File

@ -510,10 +510,10 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
}
hash_all_names(inst);
if(argc >= 5) {
new_prop_string(inst, subst_token(inst_ptr[inst].prop_ptr, argv[3], argv[4]),0, disable_unique_names);
new_prop_string(inst, subst_token(inst_ptr[inst].prop_ptr, argv[3], argv[4]),0, dis_uniq_names);
} else {/* assume argc == 4 */
new_prop_string(inst, subst_token(inst_ptr[inst].prop_ptr, argv[3], NULL),0, disable_unique_names);
new_prop_string(inst, subst_token(inst_ptr[inst].prop_ptr, argv[3], NULL),0, dis_uniq_names);
}
my_strdup2(367, &inst_ptr[inst].instname, get_tok_value(inst_ptr[inst].prop_ptr, "name",0));
/* new symbol bbox after prop changes (may change due to text length) */
@ -579,7 +579,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
my_strdup(371, &ptr,subst_token(inst_ptr[inst].prop_ptr, "name", name) );
hash_all_names(inst);
new_prop_string(inst, ptr,0, disable_unique_names); /* set new prop_ptr */
new_prop_string(inst, ptr,0, dis_uniq_names); /* set new prop_ptr */
my_strdup2(372, &inst_ptr[inst].instname, get_tok_value(inst_ptr[inst].prop_ptr, "name",0));
type=instdef[inst_ptr[inst].ptr].type; /* 20150409 */
@ -1845,8 +1845,8 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
if(!strcmp(argv[2],"cairo_font_name")) {
if( strlen(argv[3]) < sizeof(cairo_font_name) ) {
my_strncpy(cairo_font_name, argv[3], S(cairo_font_name));
cairo_select_font_face (ctx, cairo_font_name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_select_font_face (save_ctx, cairo_font_name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_select_font_face (cairo_ctx, cairo_font_name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_select_font_face (cairo_save_ctx, cairo_font_name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
}
} else
#endif
@ -1909,9 +1909,9 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
}
else if(!strcmp(argv[2],"disable_unique_names")) { /* 20171025 */
if(!strcmp(argv[3],"1")) {
disable_unique_names=1;
dis_uniq_names=1;
} else {
disable_unique_names=0;
dis_uniq_names=0;
}
}
else if(!strcmp(argv[2],"incr_hilight")) {

View File

@ -82,7 +82,7 @@ void symbol_bbox(int i, double *x1,double *y1, double *x2, double *y2)
sym_flip ^ text.flip, text.hcenter, text.vcenter,
x0+text_x0,y0+text_y0, &xx1,&yy1,&xx2,&yy2);
#ifdef HAS_CAIRO
if(customfont) cairo_restore(ctx);
if(customfont) cairo_restore(cairo_ctx);
#endif
if(xx1<*x1) *x1=xx1;
if(yy1<*y1) *y1=yy1;
@ -275,7 +275,7 @@ void delete(void)
textelement[i].x0, textelement[i].y0,
&xx1,&yy1, &xx2,&yy2);
#ifdef HAS_CAIRO
if(customfont) cairo_restore(ctx);
if(customfont) cairo_restore(cairo_ctx);
#endif
bbox(ADD, xx1, yy1, xx2, yy2 );
my_free(935, &textelement[i].prop_ptr);
@ -451,8 +451,8 @@ void bbox(int what,double x1,double y1, double x2, double y2)
XSetClipMask(display, gcstipple[i], None); /* 20171110 optimization, clipping already done in software */
}
#ifdef HAS_CAIRO
cairo_reset_clip(ctx);
cairo_reset_clip(save_ctx);
cairo_reset_clip(cairo_ctx);
cairo_reset_clip(cairo_save_ctx);
#endif
sem=0;
break;
@ -480,10 +480,10 @@ void bbox(int what,double x1,double y1, double x2, double y2)
XSetClipRectangles(display, gctiled, 0,0, xrect, 1, Unsorted);
dbg(1, "bbox(): bbox= %d %d %d %d\n",areax1,areay1,areax2,areay2);
#ifdef HAS_CAIRO
cairo_rectangle(ctx, xrect[0].x, xrect[0].y, xrect[0].width, xrect[0].height);
cairo_clip(ctx);
cairo_rectangle(save_ctx, xrect[0].x, xrect[0].y, xrect[0].width, xrect[0].height);
cairo_clip(save_ctx);
cairo_rectangle(cairo_ctx, xrect[0].x, xrect[0].y, xrect[0].width, xrect[0].height);
cairo_clip(cairo_ctx);
cairo_rectangle(cairo_save_ctx, xrect[0].x, xrect[0].y, xrect[0].width, xrect[0].height);
cairo_clip(cairo_save_ctx);
#endif
break;
default:
@ -541,7 +541,7 @@ void unselect_all(void)
textelement[i].x0, textelement[i].y0,
textelement[i].xscale, textelement[i].yscale);
#ifdef HAS_CAIRO
if(customfont) cairo_restore(ctx);
if(customfont) cairo_restore(cairo_ctx);
#endif
}
}
@ -720,7 +720,7 @@ void select_text(int i,unsigned short select_mode, int fast)
textelement[i].x0, textelement[i].y0,
textelement[i].xscale, textelement[i].yscale);
#ifdef HAS_CAIRO
if(customfont) cairo_restore(ctx);
if(customfont) cairo_restore(cairo_ctx);
#endif
need_rebuild_selected_array=1;
}
@ -959,7 +959,7 @@ void select_inside(double x1,double y1, double x2, double y2, int sel) /* 201509
textelement[i].x0, textelement[i].y0,
&xx1,&yy1, &xx2,&yy2);
#ifdef HAS_CAIRO
if(customfont) cairo_restore(ctx);
if(customfont) cairo_restore(cairo_ctx);
#endif
if(RECTINSIDE(xx1,yy1, xx2, yy2,x1,y1,x2,y2))
{

View File

@ -688,7 +688,7 @@ char *get_pin_attr_from_inst(int inst, int pin, const char *attr)
return pin_attr_value; /* caller is responsible for freeing up storage for pin_attr_value */
}
void new_prop_string(int i, const char *old_prop, int fast, int disable_unique_names)
void new_prop_string(int i, const char *old_prop, int fast, int dis_uniq_names)
{
/* given a old_prop property string, return a new */
/* property string in inst_ptr[i].prop_ptr such that the element name is */
@ -726,7 +726,7 @@ void new_prop_string(int i, const char *old_prop, int fast, int disable_unique_n
}
prefix=old_name[0];
/* don't change old_prop if name does not conflict. */
if(disable_unique_names || (entry = inst_hash_lookup(table, old_name, i, XLOOKUP, old_name_len)) == NULL || entry->value == i)
if(dis_uniq_names || (entry = inst_hash_lookup(table, old_name, i, XLOOKUP, old_name_len)) == NULL || entry->value == i)
{
inst_hash_lookup(table, old_name, i, XINSERT, old_name_len);
my_strdup(447, &inst_ptr[i].prop_ptr, old_prop);
@ -1579,10 +1579,9 @@ void print_spice_element(FILE *fd, int inst)
}
else if(token[0]=='@' && token[1]=='@') { /* recognize single pins 15112003 */
for(i=0;i<no_of_pins;i++) {
if (!strcmp(
get_tok_value((inst_ptr[inst].ptr+instdef)->boxptr[PINLAYER][i].prop_ptr,"name",0),
token+2)) {
if(strcmp(get_tok_value((inst_ptr[inst].ptr+instdef)->boxptr[PINLAYER][i].prop_ptr,"spice_ignore",0), "true")) {
char *ptr = (inst_ptr[inst].ptr+instdef)->boxptr[PINLAYER][i].prop_ptr;
if (!strcmp( get_tok_value(ptr,"name",0), token+2)) {
if(strcmp(get_tok_value(ptr,"spice_ignore",0), "true")) {
str_ptr = net_name(inst,i, &mult, 0);
fprintf(fd, "@%d %s", mult, str_ptr);
}
@ -1663,7 +1662,8 @@ void print_tedax_element(FILE *fd, int inst)
my_strdup(489, &extra, get_tok_value((inst_ptr[inst].ptr+instdef)->prop_ptr,"extra",2));
my_strdup(41, &extra_pinnumber, get_tok_value(inst_ptr[inst].prop_ptr,"extra_pinnumber",2));
if(!extra_pinnumber) my_strdup(490, &extra_pinnumber, get_tok_value((inst_ptr[inst].ptr+instdef)->prop_ptr,"extra_pinnumber",2));
if(!extra_pinnumber) my_strdup(490, &extra_pinnumber,
get_tok_value((inst_ptr[inst].ptr+instdef)->prop_ptr,"extra_pinnumber",2));
my_strdup(491, &template,
(inst_ptr[inst].ptr+instdef)->templ); /* 20150409 */
my_strdup(492, &numslots, get_tok_value(inst_ptr[inst].prop_ptr,"numslots",2));
@ -1692,7 +1692,8 @@ void print_tedax_element(FILE *fd, int inst)
char *pinnumber;
pinnumber = get_pin_attr_from_inst(inst, i, "pinnumber");
if(!pinnumber) {
my_strdup2(500, &pinnumber, get_tok_value((inst_ptr[inst].ptr+instdef)->boxptr[PINLAYER][i].prop_ptr,"pinnumber",0));
my_strdup2(500, &pinnumber,
get_tok_value((inst_ptr[inst].ptr+instdef)->boxptr[PINLAYER][i].prop_ptr,"pinnumber",0));
}
if(!get_tok_size) my_strdup(501, &pinnumber, "--UNDEF--");
tmp = net_name(inst,i, &mult, 0);
@ -2156,8 +2157,9 @@ void print_vhdl_primitive(FILE *fd, int inst) /* netlist primitives, 20071217 *
/* 20171029 */
if( state==XBEGIN && (c=='@' || c=='$') && !escape ) state=XTOKEN;
/* 20171029 added !escape, !quote */
else if( state==XTOKEN && (space || c=='$' || c=='@' || c == '\\') && token_pos > 1 && !escape && !quote) state=XSEPARATOR;
else if( state==XTOKEN && (space || c=='$' || c=='@' || c == '\\') && token_pos > 1 && !escape && !quote) {
state=XSEPARATOR;
}
if(token_pos>=sizetok)
{
sizetok+=CADCHUNKALLOC;
@ -2235,7 +2237,8 @@ void print_vhdl_primitive(FILE *fd, int inst) /* netlist primitives, 20071217 *
else if(token[0]=='@' && token[1]=='#') {
pin_number = atoi(token+2);
if(pin_number < no_of_pins) {
if(strcmp(get_tok_value((inst_ptr[inst].ptr+instdef)->boxptr[PINLAYER][pin_number].prop_ptr,"vhdl_ignore",0), "true")) {
char *ptr = (inst_ptr[inst].ptr+instdef)->boxptr[PINLAYER][pin_number].prop_ptr;
if(strcmp(get_tok_value(ptr,"vhdl_ignore",0), "true")) {
str_ptr = net_name(inst,pin_number, &mult, 0);
fprintf(fd, "----pin(%s) ", str_ptr);
}
@ -2325,8 +2328,9 @@ void print_verilog_primitive(FILE *fd, int inst) /* netlist switch level primiti
space=SPACE(c);
if( state==XBEGIN && (c=='@' || c=='$') && !escape ) state=XTOKEN;
/* 20171029 added !escape, !quote */
else if( state==XTOKEN && (space || c == '$' || c == '@' || c == '\\') && token_pos > 1 && !escape && !quote) state=XSEPARATOR;
else if(state==XTOKEN && (space || c == '$' || c == '@' || c == '\\') && token_pos > 1 && !escape && !quote) {
state=XSEPARATOR;
}
if(token_pos>=sizetok)
{
sizetok+=CADCHUNKALLOC;
@ -2612,7 +2616,8 @@ const char *translate(int inst, char* s)
}
else if(pin_num_or_name[0]) {
for(n = 0 ; n < (inst_ptr[inst].ptr+instdef)->rects[PINLAYER]; n++) {
if(!strcmp(get_tok_value((inst_ptr[inst].ptr+instdef)->boxptr[PINLAYER][n].prop_ptr,"name",0), pin_num_or_name)) break;
char *ptr = (inst_ptr[inst].ptr+instdef)->boxptr[PINLAYER][n].prop_ptr;
if(!strcmp(get_tok_value(ptr,"name",0), pin_num_or_name)) break;
}
}
if(n>=0 && pin_attr[0] && n < (inst_ptr[inst].ptr+instdef)->rects[PINLAYER]) {
@ -2630,11 +2635,13 @@ const char *translate(int inst, char* s)
/* @#n:net_name attribute (n = pin number or name) will translate to net name attached to pin
* if 'net_name=true' attribute is set in instance or symbol */
if( !pin_attr_value && !strcmp(pin_attr, "net_name")) {
if(
show_pin_net_names && (!strcmp(get_tok_value(inst_ptr[inst].prop_ptr, "net_name", 0), "true") ||
!strcmp(get_tok_value( (inst_ptr[inst].ptr + instdef)->prop_ptr, "net_name", 0), "true")) ) {
char *instprop = inst_ptr[inst].prop_ptr;
char *symprop = (inst_ptr[inst].ptr + instdef)->prop_ptr;
if( show_pin_net_names && (!strcmp(get_tok_value(instprop, "net_name", 0), "true") ||
!strcmp(get_tok_value(symprop, "net_name", 0), "true"))) {
prepare_netlist_structs(0);
my_strdup2(1175, &pin_attr_value, inst_ptr[inst].node && inst_ptr[inst].node[n] ? inst_ptr[inst].node[n] : "?");
my_strdup2(1175, &pin_attr_value,
inst_ptr[inst].node && inst_ptr[inst].node[n] ? inst_ptr[inst].node[n] : "?");
/* do not show net_name: set to empty string */
} else {
my_strdup2(1178, &pin_attr_value, "");
@ -2842,7 +2849,9 @@ const char *translate2(struct Lcc *lcc, int level, char* s)
else escape = 0;
space = SPACE2(c);
if (state == XBEGIN && c == '@' && !escape) state = XTOKEN;
else if (state == XTOKEN && ( (space && !escape) || c == '@' || (!space && escape)) && token_pos > 1) state = XSEPARATOR;
else if (state == XTOKEN && ( (space && !escape) || c == '@' || (!space && escape)) && token_pos > 1) {
state = XSEPARATOR;
}
if (result_pos >= size) {
size += CADCHUNKALLOC;
my_realloc(662, &result, size);

View File

@ -650,8 +650,8 @@ void xwin_exit(void)
if(has_x) {
#ifdef HAS_CAIRO /* 20171105 */
cairo_destroy(ctx);
cairo_destroy(save_ctx);
cairo_destroy(cairo_ctx);
cairo_destroy(cairo_save_ctx);
cairo_surface_destroy(sfc);
cairo_surface_destroy(save_sfc);
#endif
@ -1330,11 +1330,14 @@ int Tcl_AppInit(Tcl_Interp *inter)
XGetWindowAttributes(display, window, &wattr);
#if HAS_XRENDER==1
#if HAS_XCB==1
sfc = cairo_xcb_surface_create_with_xrender_format(xcbconn, screen_xcb, window, &format_rgb, 1 , 1);
save_sfc = cairo_xcb_surface_create_with_xrender_format(xcbconn, screen_xcb, save_pixmap, &format_rgb, 1 , 1);
sfc = cairo_xcb_surface_create_with_xrender_format(xcbconn,
screen_xcb, window, &format_rgb, 1 , 1);
save_sfc = cairo_xcb_surface_create_with_xrender_format(xcbconn,
screen_xcb, save_pixmap, &format_rgb, 1 , 1);
#else
format = XRenderFindStandardFormat(display, PictStandardRGB24);
sfc = cairo_xlib_surface_create_with_xrender_format (display, window, DefaultScreenOfDisplay(display), format, 1, 1);
sfc = cairo_xlib_surface_create_with_xrender_format (display,
window, DefaultScreenOfDisplay(display), format, 1, 1);
save_sfc = cairo_xlib_surface_create_with_xrender_format(
display, save_pixmap, DefaultScreenOfDisplay(display), format, 1, 1);
#endif
@ -1350,34 +1353,34 @@ int Tcl_AppInit(Tcl_Interp *inter)
fprintf(errfp, "ERROR: invalid cairo surface\n");
return 1;
}
ctx = cairo_create(sfc);
save_ctx = cairo_create(save_sfc);
cairo_ctx = cairo_create(sfc);
cairo_save_ctx = cairo_create(save_sfc);
#if 0
{
cairo_font_options_t *cfo;
cfo = cairo_font_options_create ();
cairo_font_options_set_antialias(cfo, CAIRO_ANTIALIAS_DEFAULT); /* CAIRO_ANTIALIAS_NONE */
cairo_set_font_options (ctx, cfo);
cairo_set_font_options (save_ctx, cfo);
cairo_set_font_options (cairo_ctx, cfo);
cairo_set_font_options (cairo_save_ctx, cfo);
}
#endif
/* load font from tcl 20171112 */
tcleval("xschem set cairo_font_name $cairo_font_name");
tclsetvar("has_cairo","1");
cairo_select_font_face (ctx, cairo_font_name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (ctx, 20);
cairo_select_font_face (save_ctx, cairo_font_name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (save_ctx, 20);
cairo_select_font_face (cairo_ctx, cairo_font_name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cairo_ctx, 20);
cairo_select_font_face (cairo_save_ctx, cairo_font_name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cairo_save_ctx, 20);
save_ctx = cairo_create(save_sfc);
cairo_set_line_width(ctx, 1);
cairo_set_line_width(save_ctx, 1);
cairo_set_line_join(ctx, CAIRO_LINE_JOIN_ROUND);
cairo_set_line_cap(ctx, CAIRO_LINE_CAP_ROUND);
cairo_set_line_join(save_ctx, CAIRO_LINE_JOIN_ROUND);
cairo_set_line_cap(save_ctx, CAIRO_LINE_CAP_ROUND);
cairo_save_ctx = cairo_create(save_sfc);
cairo_set_line_width(cairo_ctx, 1);
cairo_set_line_width(cairo_save_ctx, 1);
cairo_set_line_join(cairo_ctx, CAIRO_LINE_JOIN_ROUND);
cairo_set_line_cap(cairo_ctx, CAIRO_LINE_CAP_ROUND);
cairo_set_line_join(cairo_save_ctx, CAIRO_LINE_JOIN_ROUND);
cairo_set_line_cap(cairo_save_ctx, CAIRO_LINE_CAP_ROUND);
}
#endif /* HAS_CAIRO */

View File

@ -569,7 +569,7 @@ extern char *tcl_command;
extern char tcl_script[PATH_MAX];
extern char plotfile[PATH_MAX];
extern int persistent_command;
extern int disable_unique_names;
extern int dis_uniq_names;
extern int tcp_port;
extern int debug_var;
@ -961,7 +961,7 @@ extern void *my_calloc(int id, size_t nmemb, size_t size);
extern void my_free(int id, void *ptr);
extern size_t my_strcat(int id, char **, const char *);
extern const char *subst_token(const char *s, const char *tok, const char *new_val);
extern void new_prop_string(int i, const char *old_prop,int fast, int disable_unique_names);
extern void new_prop_string(int i, const char *old_prop,int fast, int dis_uniq_names);
extern void hash_name(char *token, int remove);
extern void hash_all_names(int n);
extern void symbol_bbox(int i, double *x1,double *y1, double *x2, double *y2);
@ -1069,7 +1069,7 @@ extern const char fopen_read_mode[];
# endif /* HAS_XCB */
extern cairo_surface_t *sfc, *save_sfc;
extern cairo_t *ctx, *save_ctx;
extern cairo_t *cairo_ctx, *cairo_save_ctx;
extern XRenderPictFormat *format;