svg_draw(): do not print unused layer stylesheets, error check when opening file for printing
This commit is contained in:
parent
0783ff7002
commit
1cfea4d1d3
|
|
@ -449,7 +449,7 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot,
|
|||
}
|
||||
} /* if(!hide) */
|
||||
|
||||
if( (!hide && (layer != PINLAYER || enable_layer[layer])) ||
|
||||
if( (!hide && enable_layer[layer]) ||
|
||||
(hide && layer == PINLAYER && enable_layer[layer]) ) {
|
||||
for(j=0;j< symptr->rects[layer];j++)
|
||||
{
|
||||
|
|
@ -473,11 +473,13 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot,
|
|||
ROTATION(rot, flip, 0.0,0.0,text.x0,text.y0,x1,y1);
|
||||
|
||||
textlayer = c;
|
||||
if( !(c == PINLAYER && (xctx->inst[n].color))) {
|
||||
/* do not allow custom text color on PINLAYER hilighted instances */
|
||||
if( !(xctx->inst[n].color == PINLAYER)) {
|
||||
textlayer = symptr->text[j].layer;
|
||||
if(textlayer < 0 || textlayer >= cadlayers) textlayer = c;
|
||||
}
|
||||
if((c == PINLAYER && xctx->inst[n].color) || enable_layer[textlayer]) {
|
||||
/* display PINLAYER colored instance texts even if PINLAYER disabled */
|
||||
if(xctx->inst[n].color == PINLAYER || enable_layer[textlayer]) {
|
||||
#if HAS_CAIRO==1
|
||||
textfont = symptr->text[j].font;
|
||||
if((textfont && textfont[0]) || symptr->text[j].flags) {
|
||||
|
|
|
|||
|
|
@ -799,6 +799,7 @@ void propagate_hilights(int set)
|
|||
char *type;
|
||||
|
||||
for(i = 0; i < xctx->instances; i++) {
|
||||
if(xctx->inst[i].color) hilights = 1; /* some hilight instances -> don't clear xctx->hilight_nets */
|
||||
type = (xctx->inst[i].ptr+ xctx->sym)->type;
|
||||
hilight_connected_inst = (xctx->inst[i].flags & 4) || ((xctx->inst[i].ptr+ xctx->sym)->flags & 4);
|
||||
if(hilight_connected_inst && type && !IS_LABEL_SH_OR_PIN(type)) {
|
||||
|
|
|
|||
|
|
@ -492,7 +492,7 @@ static void ps_draw_symbol(int n,int layer, short tmp_flip, short rot, double xo
|
|||
ROTATION(rot, flip, 0.0,0.0,arc.x,arc.y,x1,y1);
|
||||
ps_drawarc(layer, arc.fill, x0+x1, y0+y1, arc.r, angle, arc.b, arc.dash);
|
||||
}
|
||||
if( (layer != PINLAYER || enable_layer[layer]) ) for(j=0;j< (xctx->inst[n].ptr+ xctx->sym)->rects[layer];j++)
|
||||
if( enable_layer[layer] ) for(j=0;j< (xctx->inst[n].ptr+ xctx->sym)->rects[layer];j++)
|
||||
{
|
||||
box = ((xctx->inst[n].ptr+ xctx->sym)->rect[layer])[j];
|
||||
ROTATION(rot, flip, 0.0,0.0,box.x1,box.y1,x1,y1);
|
||||
|
|
@ -511,26 +511,26 @@ static void ps_draw_symbol(int n,int layer, short tmp_flip, short rot, double xo
|
|||
txtptr= translate(n, text.txt_ptr);
|
||||
ROTATION(rot, flip, 0.0,0.0,text.x0,text.y0,x1,y1);
|
||||
textlayer = layer;
|
||||
if( !(layer == PINLAYER && (xctx->inst[n].color))) {
|
||||
/* do not allow custom text color on PINLAYER hilighted instances */
|
||||
if( !(xctx->inst[n].color == PINLAYER)) {
|
||||
textlayer = (xctx->inst[n].ptr+ xctx->sym)->text[j].layer;
|
||||
if(textlayer < 0 || textlayer >= cadlayers) textlayer = layer;
|
||||
}
|
||||
|
||||
my_snprintf(ps_font_family, S(ps_font_name), "Helvetica");
|
||||
my_snprintf(ps_font_name, S(ps_font_name), "Helvetica");
|
||||
textfont = symptr->text[j].font;
|
||||
if( (textfont && textfont[0])) {
|
||||
my_snprintf(ps_font_family, S(ps_font_family), textfont);
|
||||
my_snprintf(ps_font_name, S(ps_font_name), textfont);
|
||||
}
|
||||
if( symptr->text[j].flags & TEXT_BOLD)
|
||||
my_snprintf(ps_font_family, S(ps_font_family), "%s-Bold", ps_font_name);
|
||||
if( symptr->text[j].flags & TEXT_ITALIC)
|
||||
my_snprintf(ps_font_family, S(ps_font_family), "%s-Oblique", ps_font_name);
|
||||
if( symptr->text[j].flags & TEXT_OBLIQUE)
|
||||
my_snprintf(ps_font_family, S(ps_font_family), "%s-Oblique", ps_font_name);
|
||||
|
||||
if((layer == PINLAYER && xctx->inst[n].color) || enable_layer[textlayer]) {
|
||||
/* display PINLAYER colored instance texts even if PINLAYER disabled */
|
||||
if(xctx->inst[n].color == PINLAYER || enable_layer[textlayer]) {
|
||||
my_snprintf(ps_font_family, S(ps_font_name), "Helvetica");
|
||||
my_snprintf(ps_font_name, S(ps_font_name), "Helvetica");
|
||||
textfont = symptr->text[j].font;
|
||||
if( (textfont && textfont[0])) {
|
||||
my_snprintf(ps_font_family, S(ps_font_family), textfont);
|
||||
my_snprintf(ps_font_name, S(ps_font_name), textfont);
|
||||
}
|
||||
if( symptr->text[j].flags & TEXT_BOLD)
|
||||
my_snprintf(ps_font_family, S(ps_font_family), "%s-Bold", ps_font_name);
|
||||
if( symptr->text[j].flags & TEXT_ITALIC)
|
||||
my_snprintf(ps_font_family, S(ps_font_family), "%s-Oblique", ps_font_name);
|
||||
if( symptr->text[j].flags & TEXT_OBLIQUE)
|
||||
my_snprintf(ps_font_family, S(ps_font_family), "%s-Oblique", ps_font_name);
|
||||
if(text_ps) {
|
||||
ps_draw_string(textlayer, txtptr,
|
||||
(text.rot + ( (flip && (text.rot & 1) ) ? rot+2 : rot) ) & 0x3,
|
||||
|
|
@ -545,7 +545,6 @@ static void ps_draw_symbol(int n,int layer, short tmp_flip, short rot, double xo
|
|||
}
|
||||
}
|
||||
}
|
||||
Tcl_SetResult(interp,"",TCL_STATIC);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -778,5 +777,6 @@ void ps_draw(void)
|
|||
tcleval( tmp);
|
||||
pop_undo(0);
|
||||
xctx->modified=modified_save;
|
||||
Tcl_SetResult(interp,"",TCL_STATIC);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1670,7 +1670,10 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
Tcl_SetResult(interp, "xschem print needs at least 1 more arguments: plot_type", TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if(argc >= 4) my_strncpy(plotfile, argv[3], S(plotfile));
|
||||
if(argc >= 4) {
|
||||
Tcl_VarEval(interp, "file normalize ", argv[3], NULL);
|
||||
my_strncpy(plotfile, Tcl_GetStringResult(interp), S(plotfile));
|
||||
}
|
||||
|
||||
if(!strcmp(argv[2],"pdf") || !strcmp(argv[2],"ps")) {
|
||||
ps_draw();
|
||||
|
|
|
|||
|
|
@ -469,7 +469,7 @@ static void svg_draw_symbol(int n,int layer,short tmp_flip, short rot,
|
|||
svg_drawarc(layer, arc.fill, x0+x1, y0+y1, arc.r, angle, arc.b, arc.dash);
|
||||
}
|
||||
|
||||
if( (layer != PINLAYER || enable_layer[layer]) ) for(j=0;j< symptr->rects[layer];j++)
|
||||
if( enable_layer[layer] ) for(j=0;j< symptr->rects[layer];j++)
|
||||
{
|
||||
box = (symptr->rect[layer])[j];
|
||||
ROTATION(rot, flip, 0.0,0.0,box.x1,box.y1,x1,y1);
|
||||
|
|
@ -488,26 +488,27 @@ static void svg_draw_symbol(int n,int layer,short tmp_flip, short rot,
|
|||
txtptr= translate(n, text.txt_ptr);
|
||||
ROTATION(rot, flip, 0.0,0.0,text.x0,text.y0,x1,y1);
|
||||
textlayer = layer;
|
||||
if( !(layer == PINLAYER && (xctx->inst[n].color))) {
|
||||
/* do not allow custom text color on PINLAYER hilighted instances */
|
||||
if( !(xctx->inst[n].color == PINLAYER)) {
|
||||
textlayer = symptr->text[j].layer;
|
||||
if(textlayer < 0 || textlayer >= cadlayers) textlayer = layer;
|
||||
}
|
||||
my_snprintf(svg_font_family, S(svg_font_family), svg_font_name);
|
||||
my_snprintf(svg_font_style, S(svg_font_style), "normal");
|
||||
my_snprintf(svg_font_weight, S(svg_font_weight), "normal");
|
||||
/* display PINLAYER colored instance texts even if PINLAYER disabled */
|
||||
if(xctx->inst[n].color == PINLAYER || enable_layer[textlayer]) {
|
||||
my_snprintf(svg_font_family, S(svg_font_family), svg_font_name);
|
||||
my_snprintf(svg_font_style, S(svg_font_style), "normal");
|
||||
my_snprintf(svg_font_weight, S(svg_font_weight), "normal");
|
||||
|
||||
textfont = symptr->text[j].font;
|
||||
if( (textfont && textfont[0])) {
|
||||
my_snprintf(svg_font_family, S(svg_font_family), textfont);
|
||||
}
|
||||
if( symptr->text[j].flags & TEXT_BOLD)
|
||||
my_snprintf(svg_font_weight, S(svg_font_weight), "bold");
|
||||
if( symptr->text[j].flags & TEXT_ITALIC)
|
||||
my_snprintf(svg_font_style, S(svg_font_style), "italic");
|
||||
if( symptr->text[j].flags & TEXT_OBLIQUE)
|
||||
my_snprintf(svg_font_style, S(svg_font_style), "oblique");
|
||||
|
||||
if((layer == PINLAYER && xctx->inst[n].color) || enable_layer[textlayer]) {
|
||||
textfont = symptr->text[j].font;
|
||||
if( (textfont && textfont[0])) {
|
||||
my_snprintf(svg_font_family, S(svg_font_family), textfont);
|
||||
}
|
||||
if( symptr->text[j].flags & TEXT_BOLD)
|
||||
my_snprintf(svg_font_weight, S(svg_font_weight), "bold");
|
||||
if( symptr->text[j].flags & TEXT_ITALIC)
|
||||
my_snprintf(svg_font_style, S(svg_font_style), "italic");
|
||||
if( symptr->text[j].flags & TEXT_OBLIQUE)
|
||||
my_snprintf(svg_font_style, S(svg_font_style), "oblique");
|
||||
if(text_svg)
|
||||
svg_draw_string(textlayer, txtptr,
|
||||
(text.rot + ( (flip && (text.rot & 1) ) ? rot+2 : rot) ) & 0x3,
|
||||
|
|
@ -521,7 +522,6 @@ static void svg_draw_symbol(int n,int layer,short tmp_flip, short rot,
|
|||
}
|
||||
}
|
||||
}
|
||||
Tcl_SetResult(interp,"",TCL_STATIC);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -592,14 +592,24 @@ void svg_draw(void)
|
|||
push_undo();
|
||||
trim_wires(); /* 20161121 add connection boxes on wires but undo at end */
|
||||
|
||||
if(plotfile[0]) fd=fopen(plotfile, "w");
|
||||
else fd=fopen("plot.svg", "w");
|
||||
if(plotfile[0]) {
|
||||
fd=fopen(plotfile, "w");
|
||||
if(!fd) {
|
||||
dbg(0, "can not open file: %s\n", plotfile);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
fd=fopen("plot.svg", "w");
|
||||
if(!fd) {
|
||||
dbg(0, "can not open file: %s\n", "plot.svg");
|
||||
return;
|
||||
}
|
||||
}
|
||||
my_strncpy(plotfile,"", S(plotfile));
|
||||
|
||||
/* Determine used layers */
|
||||
used_layer = my_calloc(873, cadlayers, sizeof(int));
|
||||
|
||||
#if 0
|
||||
/* ================================================================================ */
|
||||
used_layer[0] = 1; /* background */
|
||||
for(i=0;i<xctx->texts;i++)
|
||||
{
|
||||
textlayer = xctx->text[i].layer;
|
||||
|
|
@ -609,8 +619,9 @@ void svg_draw(void)
|
|||
for(c=0;c<cadlayers;c++)
|
||||
{
|
||||
if(xctx->lines[c] || xctx->rects[c] || xctx->arcs[c] || xctx->polygons[c]) used_layer[c] = 1;
|
||||
if(xctx->wires) used_layer[WIRELAYER] = 1;
|
||||
for(i=0;i<xctx->instances;i++) {
|
||||
symptr = (xctx->inst[i].ptr+ xctx->sym);
|
||||
symptr = (xctx->inst[i].ptr + xctx->sym);
|
||||
if( (c == PINLAYER || enable_layer[c]) && symptr->lines[c] ) used_layer[c] = 1;
|
||||
if( (c == PINLAYER || enable_layer[c]) && symptr->polygons[c] ) used_layer[c] = 1;
|
||||
if( (c == PINLAYER || enable_layer[c]) && symptr->arcs[c] ) used_layer[c] = 1;
|
||||
|
|
@ -618,29 +629,30 @@ void svg_draw(void)
|
|||
if( (c==TEXTWIRELAYER && !(xctx->inst[i].flags&2) ) ||
|
||||
(sym_txt && (c==TEXTLAYER) && (xctx->inst[i].flags&2) ) )
|
||||
{
|
||||
int j;
|
||||
for(j=0;j< symptr->texts;j++)
|
||||
{
|
||||
text = symptr->text[j];
|
||||
/* if(text.xscale*FONTWIDTH* xctx->mooz<1) continue; */
|
||||
textlayer = c;
|
||||
if( !(c == PINLAYER && (xctx->inst[i].color))) {
|
||||
textlayer = symptr->text[j].c;
|
||||
if( !(xctx->inst[i].color == PINLAYER)) {
|
||||
textlayer = symptr->text[j].layer;
|
||||
if(textlayer < 0 || textlayer >= cadlayers) textlayer = c;
|
||||
}
|
||||
used_layer[textlayer] = 1;
|
||||
/* display PINLAYER colored instance texts even if PINLAYER disabled */
|
||||
if(xctx->inst[i].color == PINLAYER || enable_layer[textlayer]) {
|
||||
used_layer[textlayer] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dbg(1, "used_layer[%d] = %d\n", c, used_layer[c]);
|
||||
}
|
||||
/* ================================================================================ */
|
||||
#endif
|
||||
my_free(1217, &used_layer);
|
||||
/* End determine used layer */
|
||||
|
||||
|
||||
fprintf(fd, "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"%g\" height=\"%g\" version=\"1.1\">\n", dx, dy);
|
||||
|
||||
fprintf(fd, "<style type=\"text/css\">\n"); /* use css stylesheet 20121119 */
|
||||
for(i=0;i<cadlayers;i++){
|
||||
if(!used_layer[i]) continue;
|
||||
fprintf(fd, ".l%d{\n", i);
|
||||
if(fill_type[i] == 1)
|
||||
fprintf(fd, " fill: #%02x%02x%02x;\n", svg_colors[i].red, svg_colors[i].green, svg_colors[i].blue);
|
||||
|
|
@ -748,8 +760,9 @@ void svg_draw(void)
|
|||
|
||||
draw_grid=old_grid;
|
||||
my_free(964, &svg_colors);
|
||||
|
||||
my_free(1217, &used_layer);
|
||||
pop_undo(0);
|
||||
xctx->modified=modified_save;
|
||||
Tcl_SetResult(interp,"",TCL_STATIC);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
v {xschem version=2.9.5_RC5 file_version=1.1}
|
||||
G {type=netlist_commands
|
||||
v {xschem version=2.9.9 file_version=1.2 }
|
||||
G {}
|
||||
K {type=netlist_commands
|
||||
template="name=s1 only_toplevel=false value=blabla"
|
||||
format="
|
||||
@value
|
||||
|
|
@ -9,5 +10,5 @@ S {}
|
|||
E {}
|
||||
L 4 0 -10 70 -10 {}
|
||||
L 4 0 -10 0 10 {}
|
||||
T {@name} 5 -25 0 0 0.3 0.3 {}
|
||||
T {@name} 5 -30 0 0 0.3 0.3 {}
|
||||
T {@value} 15 -5 0 0 0.3 0.3 {}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
v {xschem version=2.9.8 file_version=1.2}
|
||||
v {xschem version=2.9.9 file_version=1.2 }
|
||||
G {}
|
||||
K {}
|
||||
V {}
|
||||
|
|
|
|||
Loading…
Reference in New Issue