svg and pdf exports use custom layer colors as set in ~/.xschem/colors file if any.

This commit is contained in:
Stefan Schippers 2020-08-30 12:01:48 +02:00
parent a419b6aa63
commit 4e48908902
3 changed files with 34 additions and 31 deletions

View File

@ -1,4 +1,6 @@
2.9.8
- NO_CAIRO builds also use 'layer=' attribute to display text on custom layers.
- pdf and svg exports follow the enable_layer[] array to display/hide layers as does draw()
- LCC function (Local Custom Cell):
schematics (.sch) can be instantiated just like symbol (.sym) files in a parent schematic.
- Open Recent menu entry to quickly open recent edited/saved files.

View File

@ -1079,12 +1079,6 @@ int Tcl_AppInit(Tcl_Interp *inter)
my_strdup(44, &xschem_executable, get_file_path(xschem_executable));
dbg(1, "Tcl_AppInit(): resolved xschem_executable=%s\n", xschem_executable);
/* READ COLORS */
my_snprintf(name, S(name), "%s/colors", user_conf_dir);
if(!stat(name, &buf)) {
source_tcl_file(name);
}
/* set global variables fetching data from tcl code 25122002 */
if(tclgetvar("dark_colorscheme")[0] == '1') dark_colorscheme = 1;
else dark_colorscheme = 0;

View File

@ -1945,7 +1945,7 @@ proc edit_vi_netlist_prop {txtlabel} {
}
proc change_color {} {
global colors dark_colors light_colors dark_colorscheme cadlayers ctrl_down USER_CONF_DIR
global colors dark_colors light_colors dark_colorscheme cadlayers ctrl_down USER_CONF_DIR svg_colors ps_colors
set n [xschem get rectcolor]
if { $n < 0 || $n >=$cadlayers} return
@ -1963,7 +1963,12 @@ proc change_color {} {
set dark_colors $cc
} else {
set light_colors $cc
regsub -all {\"} $cc {} ps_colors
regsub -all {#} $ps_colors {0x} ps_colors
}
regsub -all {\"} $colors {} svg_colors
regsub -all {#} $svg_colors {0x} svg_colors
xschem change_colors
set savedata "#### THIS FILE IS AUTOMATICALLY GENERATED BY XSCHEM, DO NOT EDIT.\n"
set savedata "$savedata set cadlayers $cadlayers\n"
@ -3017,20 +3022,12 @@ if {!$rainbow_colors} {
"#880088" "#00ff00" "#0000cc" "#666600" "#557755"
"#aa2222" "#7ccc40" "#00ffcc" "#ce0097" "#d2d46b"
"#ef6158" "#fdb200"}
set_ne dark_colors {
"#000000" "#00ccee" "#3f3f3f" "#cccccc" "#88dd00"
"#bb2200" "#00ccee" "#ff0000" "#ffff00" "#ffffff"
"#ff00ff" "#00ff00" "#0000cc" "#aaaa00" "#aaccaa"
"#ff7777" "#bfff81" "#00ffcc" "#ce0097" "#d2d46b"
"#ef6158" "#fdb200"}
set_ne ps_colors {
0xffffff 0x0044ee 0xaaaaaa 0x222222 0x229900
0xbb2200 0x00ccee 0xff0000 0x888800 0x00aaaa
0x880088 0x00ff00 0x0000cc 0x666600 0x557755
0xaa2222 0x7ccc40 0x00ffcc 0xce0097 0xd2d46b
0xef6158 0xfdb200}
} else {
# rainbow colors for bitmapping
# skip if colors defined in ~/.xschem 20121110
@ -3045,7 +3042,6 @@ if {!$rainbow_colors} {
"#e0a000" "#e0c000" "#e0e000" "#e0e020" "#e0e040"
"#e0e060" "#e0e080" "#e0e0a0" "#e0e0c0" "#e0e0e0"
}
# same colors as above ...
set_ne dark_colors {
"#000000" "#00ccee" "#3f3f3f" "#ffffff" "#88dd00"
"#bb2200" "#0000e0" "#2000e0" "#4000e0" "#6000e0"
@ -3055,23 +3051,20 @@ if {!$rainbow_colors} {
"#e0a000" "#e0c000" "#e0e000" "#e0e020" "#e0e040"
"#e0e060" "#e0e080" "#e0e0a0" "#e0e0c0" "#e0e0e0"
}
set_ne ps_colors {
0x000000 0x0000ee 0x7f7f7f 0x000000 0x338800
0xbb2200 0x0000e0 0x2000e0 0x4000e0 0x6000e0
0x8000e0 0xa000e0 0xc000e0 0xe000e0 0xe000c0
0xe000a0 0xe00080 0xe00060 0xe00040 0xe00020
0xe00000 0xe02000 0xe04000 0xe06000 0xe08000
0xe0a000 0xe0c000 0xe0e000 0xe0e020 0xe0e040
0xe0e060 0xe0e080 0xe0e0a0 0xe0e0c0 0xe0e0e0
}
}
# for svg and pdf draw 20121108
regsub -all {\"} $dark_colors {} svg_colors
regsub -all {#} $svg_colors {0x} svg_colors
regsub -all {\"} $light_colors {} ps_colors
regsub -all {#} $ps_colors {0x} ps_colors
## pad missing colors with black
for {set i 0} { $i<$cadlayers } { incr i} {
set_ne enable_layer($i) 1
foreach j { ps_colors light_colors dark_colors } {
foreach j { svg_colors ps_colors light_colors dark_colors } {
if { ![string compare [lindex [set $j] $i] {} ] } {
if { ![string compare $j {ps_colors} ] } {
if { ![string compare $j {ps_colors} ] || ![string compare $j {svg_colors} ]} {
lappend $j {0x000000}
} else {
lappend $j {#000000}
@ -3104,10 +3097,6 @@ if {$::OS == "Windows"} {
set_ne copy_cell 0
# for svg draw 20121108
regsub -all {\"} $colors {} svg_colors
regsub -all {#} $svg_colors {0x} svg_colors
# recent files
set recentfile {}
if { [file exists $USER_CONF_DIR/recent_files] } {
@ -3705,6 +3694,24 @@ font configure Underline-Font -underline true -size 24
}
}
# read custom colors
if { [file exists ${USER_CONF_DIR}/colors] } {
source ${USER_CONF_DIR}/colors
}
if { [llength $dark_colors] < $cadlayers || [llength $light_colors] < $cadlayers } {
puts stderr { Warning: wrong number of configured layers in light_colors or dark_colors variables.}
}
if { $dark_colorscheme == 1} {
set colors $dark_colors
} else {
set colors $light_colors
}
regsub -all {\"} $light_colors {} ps_colors
regsub -all {#} $ps_colors {0x} ps_colors
regsub -all {\"} $colors {} svg_colors
regsub -all {#} $svg_colors {0x} svg_colors
if { $show_infowindow } { wm deiconify .infotext }
foreach i $tcl_files {