windows png/pdf export

This commit is contained in:
Stefan Frederik 2021-01-28 23:09:37 +01:00
parent 7bdc33d8c1
commit 906dc4212e
28 changed files with 2318 additions and 2190 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="Xschem" Language="1033" Version="2.9.9.3" Manufacturer="Xschem" UpgradeCode="0deb9c17-cbbd-491c-be3e-24446b27ccd5">
<Product Id="*" Name="Xschem" Language="1033" Version="2.9.9.4" Manufacturer="Xschem" UpgradeCode="0deb9c17-cbbd-491c-be3e-24446b27ccd5">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<WixVariable Id="WixUILicenseRtf"
Value="License.rtf" />

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -5066,18 +5066,27 @@
<Component Id="cmp5BFBD053346A12A4CB8146D3A1CB8F46" Guid="{B6C39F8B-843F-4908-B1AE-47E0CD8C2ADA}">
<File Id="filB8B576F3D95FC2CFD6321C7865A6D909" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\and4_1.sym" />
</Component>
<Component Id="cmp502DE4191401E3D01123A0FFEDC0F658" Guid="{26D4E444-5A42-489D-9A03-C1218F6E5263}">
<File Id="fil58FEE426321DD1EFEF26924163F7C545" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\dev-1.sym" />
</Component>
<Component Id="cmpCD0B1BE956EEA7AAF6C2D301A41ED2D6" Guid="{E01FE85D-1348-4998-8968-D07C5F49BE97}">
<File Id="fil295761403E113FB646EAA4F421734E22" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\dfrbp_1.sym" />
</Component>
<Component Id="cmp8F85892CF93EE49EAEDC65C6E55BD6AA" Guid="{0A0081EB-1E37-4631-BA98-5798787C28A3}">
<File Id="fil2136DBE0FD6FA317501188681BC1070D" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\dfrtp_1.sym" />
</Component>
<Component Id="cmpBCB98C1A0EF900FCB9DFC06BC74E63EF" Guid="{53A58C46-EAE5-4B87-A9C3-402AA818E27F}">
<File Id="fil9618CEB2402AA5D79B19628BA4BF679F" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\diode_3.sym" />
</Component>
<Component Id="cmpC3C3E8711AE6C7A3E481447BFA82E4AA" Guid="{35651EBB-9650-43A8-8621-03FE8904EC58}">
<File Id="filE79538BFDD7565852D51E2B4D286850D" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\dlrtn_1.sym" />
</Component>
<Component Id="cmpF77BE0A20858F1EF2C8A1A537B547883" Guid="{610DA6D2-3CEF-4F8E-BE8D-1EC6F7F70C3E}">
<File Id="fil90D9602C2F251E2148225A3E7B064C4A" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\dlrtp_1.sym" />
</Component>
<Component Id="cmpCDA72642DAEEE944484B0B68F524315B" Guid="{B3F77506-52DC-4284-9F58-2B2852C7E184}">
<File Id="fil3704053BF2C166DF774AAE04EFDBFB92" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\einvp_1.sym" />
</Component>
<Component Id="cmp214371EA2A26A7524708069925C41447" Guid="{2617EECF-77C9-4BC9-9C96-9CA6CCF949C3}">
<File Id="fil5DAB04761E10992E352ABE65340C7840" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\fa_1.sym" />
</Component>
@ -5087,6 +5096,9 @@
<Component Id="cmp11B0CA8AEB6E6D2FD1A3D13EE37DC89B" Guid="{049BE97B-0B0F-4567-8663-132DCD100350}">
<File Id="filFB04981EEC1993D72CE3E949A65AE02C" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\giant_label2.sym" />
</Component>
<Component Id="cmp5D12E4E2F9EAD9952B4CB5813EF2156E" Guid="{3DF1A418-A873-4475-9C0B-736CA9DF0B54}">
<File Id="fil01C50642DB24D9330717D4629A832F00" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\invert-1.sym" />
</Component>
<Component Id="cmpA4CD7B4D735CFF0E5B394019BF3A271B" Guid="{A66D3670-A901-4FC2-A679-8B826A49B4EA}">
<File Id="fil442D7A966B36D51008EE974DEA1F6B03" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\inv_2.sym" />
</Component>
@ -5096,6 +5108,12 @@
<Component Id="cmpC35EB4A5E3B3A8C8E862C51D8678C4D8" Guid="{53C600A2-7DDE-4CE5-9D03-08510A826EBB}">
<File Id="filE8F09D4598F4645B9F9F7B3F4E3D8D8C" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\logic_test.sym" />
</Component>
<Component Id="cmpB3CAE96214DE95644D5DC6392D80F761" Guid="{8E874F79-0C79-45BA-8C93-377406403640}">
<File Id="fil3986A65493FB1F465C3676A7C8F14F3E" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\mux2_1.sym" />
</Component>
<Component Id="cmpB729A77EA9F830AF94F1DF3D4A2DB41A" Guid="{2F85CB96-F416-4E30-8C96-43A6A27D50BD}">
<File Id="fil4CAFE9C2A0C052833B961474F3A34F18" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\n.sym" />
</Component>
<Component Id="cmp98CA376CBC34D346A55600C86F4EB782" Guid="{11D4C294-525B-4073-A4EE-FA5412C13C11}">
<File Id="fil6A9B9C4D26C89A1753D25FE75CA3869A" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\nand2_1.sym" />
</Component>
@ -5114,6 +5132,9 @@
<Component Id="cmpCD99BD5BF63C7DAFE6D00B696F45A7B2" Guid="{7BEC660E-6CE4-463E-B8DF-03FB35A7CCC2}">
<File Id="fil007016E8D867436FDDCACE7D14725541" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\or4_1.sym" />
</Component>
<Component Id="cmp31E3D327592A9BD59FEEF380E874DDB7" Guid="{060A081A-F958-47D0-9AD2-A6C6FFE27198}">
<File Id="filBDE99F650D20B81C8ABCE1852123BD91" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\p.sym" />
</Component>
<Component Id="cmp5C7DCAE7B9F3BA675928E20E331E39B4" Guid="{0D2F93F4-61FF-4A16-BD37-494ABDDDC65B}">
<File Id="fil39F535FE1FB62E52E53520144FB70A3A" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\segment.sym" />
</Component>
@ -5123,6 +5144,12 @@
<Component Id="cmp50F9C8C97A18DCAC9366F1710001D03B" Guid="{B6820A96-2129-40EA-976F-C9108D5565FA}">
<File Id="fil7BAA0A1B38F44EA22883322535152690" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\simulate_ff.sym" />
</Component>
<Component Id="cmp3F34431DD86B1F87D6BC74ED0CAA9EA7" Guid="{FFD287F7-B313-46D7-829D-9B4B7DC0B455}">
<File Id="filEEB317F0BFC2935E963DF899550418A5" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\switch-1.sym" />
</Component>
<Component Id="cmp426A74C263890863DC8540F7058A2731" Guid="{8E849159-C50A-4076-A6AB-F84DE1BB6FC4}">
<File Id="fil50053FEAED0B5C43DD23198A35739240" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\switch_level_sim.sch" />
</Component>
<Component Id="cmp01FA016C7A06153D92A48F784F4E97D3" Guid="{72DEDB2F-FB91-40BF-9942-317015139E25}">
<File Id="filBB6C0129C2118D89AF549CC912F5CE03" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\xor2_1.sym" />
</Component>
@ -6862,25 +6889,34 @@
<ComponentRef Id="cmp1AE169A0383ED18F714B82EA7BA988FB" />
<ComponentRef Id="cmpDFA5C50E5F33CA73144A3B548B782FFB" />
<ComponentRef Id="cmp5BFBD053346A12A4CB8146D3A1CB8F46" />
<ComponentRef Id="cmp502DE4191401E3D01123A0FFEDC0F658" />
<ComponentRef Id="cmpCD0B1BE956EEA7AAF6C2D301A41ED2D6" />
<ComponentRef Id="cmp8F85892CF93EE49EAEDC65C6E55BD6AA" />
<ComponentRef Id="cmpBCB98C1A0EF900FCB9DFC06BC74E63EF" />
<ComponentRef Id="cmpC3C3E8711AE6C7A3E481447BFA82E4AA" />
<ComponentRef Id="cmpF77BE0A20858F1EF2C8A1A537B547883" />
<ComponentRef Id="cmpCDA72642DAEEE944484B0B68F524315B" />
<ComponentRef Id="cmp214371EA2A26A7524708069925C41447" />
<ComponentRef Id="cmp0A882AA618C67177D111BF500BD3DD7D" />
<ComponentRef Id="cmp11B0CA8AEB6E6D2FD1A3D13EE37DC89B" />
<ComponentRef Id="cmp5D12E4E2F9EAD9952B4CB5813EF2156E" />
<ComponentRef Id="cmpA4CD7B4D735CFF0E5B394019BF3A271B" />
<ComponentRef Id="cmp8A236808F71F8D4304F64EAF2BB23CD5" />
<ComponentRef Id="cmpC35EB4A5E3B3A8C8E862C51D8678C4D8" />
<ComponentRef Id="cmpB3CAE96214DE95644D5DC6392D80F761" />
<ComponentRef Id="cmpB729A77EA9F830AF94F1DF3D4A2DB41A" />
<ComponentRef Id="cmp98CA376CBC34D346A55600C86F4EB782" />
<ComponentRef Id="cmpD5ACB80A3722EA99B071346DF6F5F400" />
<ComponentRef Id="cmpB1C878A05FA9BAA87A7FE188B52C980B" />
<ComponentRef Id="cmpEC6E01585F02C55A9C673CF905259230" />
<ComponentRef Id="cmpBBBE97CFCD373F3989D4AEBFBA663F2E" />
<ComponentRef Id="cmpCD99BD5BF63C7DAFE6D00B696F45A7B2" />
<ComponentRef Id="cmp31E3D327592A9BD59FEEF380E874DDB7" />
<ComponentRef Id="cmp5C7DCAE7B9F3BA675928E20E331E39B4" />
<ComponentRef Id="cmp39FC31E52444900CB5C9613BB25AA99C" />
<ComponentRef Id="cmp50F9C8C97A18DCAC9366F1710001D03B" />
<ComponentRef Id="cmp3F34431DD86B1F87D6BC74ED0CAA9EA7" />
<ComponentRef Id="cmp426A74C263890863DC8540F7058A2731" />
<ComponentRef Id="cmp01FA016C7A06153D92A48F784F4E97D3" />
<ComponentRef Id="cmp86C7FEAC33E42F537A218CAB30888F71" />
<ComponentRef Id="cmp6BE2319A78975693F24ED898D6D51AB0" />

View File

@ -92,6 +92,7 @@ int find_fs_readdir(const char *name, int logdepth, int fatal)
char *test_c =
NL "#include <stdlib.h>"
NL "#include <stdio.h>"
NL "#include <string.h>"
NL "int main() {"
NL " DIR *dirp;"
NL " struct dirent *dp;"
@ -397,6 +398,7 @@ int find_fs_getcwd(const char *name, int logdepth, int fatal)
{
char *test_c =
NL "#include <unistd.h>"
NL "#include <stdio.h>"
NL "int main() {"
NL " char b[1024];"
NL " if (getcwd(b, sizeof(b)) != NULL)"
@ -419,6 +421,7 @@ int find_fs__getcwd(const char *name, int logdepth, int fatal)
{
char *test_c =
NL "#include <stdlib.h>"
NL "#include <stdio.h>"
NL "int main() {"
NL " char b[1024];"
NL " if (_getcwd(b, sizeof(b)) != NULL)"
@ -442,6 +445,7 @@ int find_fs_getwd(const char *name, int logdepth, int fatal)
{
char *test_c =
NL "#include <unistd.h>"
NL "#include <stdio.h>"
NL "int main() {"
NL " char b[8192];"
NL " if (getwd(b) != NULL)"

View File

@ -34,6 +34,7 @@ int find_io_pipe(const char *name, int logdepth, int fatal)
{
char *test_c =
NL "#include <unistd.h>"
NL "#include <stdio.h>"
NL "int main() {"
NL " int fd[2];"
NL " if (pipe(fd) == 0)"
@ -56,6 +57,7 @@ int find_io_pipe2(const char *name, int logdepth, int fatal)
{
const char *test_c =
NL "#include <unistd.h>"
NL "#include <stdio.h>"
NL "int main() {"
NL " int fd[2];"
NL " if (pipe2(fd, 0) == 0)"
@ -77,6 +79,7 @@ int find_io_pipe2(const char *name, int logdepth, int fatal)
int find_io__pipe(const char *name, int logdepth, int fatal)
{
const char *test_c =
NL "#include <stdio.h>"
NL "int main() {"
NL " int fd[2];"
NL " if (_pipe(fd, 1024, _O_BINARY) == 0)"

View File

@ -188,6 +188,7 @@ int find_lib_errno(const char *name, int logdepth, int fatal)
{
char *test_c =
NL "#include <errno.h>"
NL "#include <stdio.h>"
NL "int main() {"
NL " errno = 0;"
NL " puts(\"OK\");"

View File

@ -37,6 +37,7 @@ int find_lib_lpthread(const char *name, int logdepth, int fatal)
char *test_c_recursive =
NL "#define _GNU_SOURCE 1 /* Needed for recursive thread-locking */"
NL "#include <pthread.h>"
NL "#include <stdio.h>"
NL "pthread_mutex_t mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;"
NL "int main() {"
NL " pthread_attr_t a;"
@ -48,6 +49,7 @@ int find_lib_lpthread(const char *name, int logdepth, int fatal)
char *test_c_simple =
NL "#include <pthread.h>"
NL "#include <stdio.h>"
NL "int main() {"
NL " pthread_attr_t a;"
NL " if (pthread_attr_init(&a) == 0)"

View File

@ -32,6 +32,7 @@ int find_time_usleep(const char *name, int logdepth, int fatal)
{
char *test_c =
NL "#include <unistd.h>"
NL "#include <stdio.h>"
NL "int main() {"
NL " if (usleep(1) == 0)"
NL " puts(\"OK\");"
@ -53,6 +54,7 @@ int find_time_usleep(const char *name, int logdepth, int fatal)
int find_time_Sleep(const char *name, int logdepth, int fatal)
{
char *test_c =
NL "#include <stdio.h>"
NL "int main() {"
NL " Sleep(1);"
NL " puts(\"OK\");"
@ -75,6 +77,7 @@ int find_time_gettimeofday(const char *name, int logdepth, int fatal)
{
char *test_c =
NL "#include <stdlib.h>"
NL "#include <stdio.h>"
NL "int main() {"
NL " struct timeval tv;"
NL " if (gettimeofday(&tv, NULL) == 0)"
@ -98,6 +101,7 @@ int find_time_gettimeofday(const char *name, int logdepth, int fatal)
int find_time_ftime(const char *name, int logdepth, int fatal)
{
char *test_c =
NL "#include <stdio.h>"
NL "int main() {"
NL " struct timeb tb;"
NL " if (ftime(&tb) == 0)"

View File

@ -93,6 +93,7 @@ int find_types_stdint(const char *name, int logdepth, int fatal)
{
char *test_c =
NL "#include <stdint.h>"
NL "#include <stdio.h>"
NL "int main() {"
NL " if (sizeof(uint8_t) == 1)"
NL " puts(\"OK\");"

View File

@ -30,6 +30,7 @@
int find_gd(const char *name, int logdepth, int fatal, const char *call, const char *arg)
{
const char *test_c =
NL "#include <stdio.h>"
NL "#include \"gd.h\""
NL "int main() {"
NL " gdImagePtr imtype;"

View File

@ -45,7 +45,7 @@ int find_gl(const char *name, int logdepth, int fatal, const char *call, const c
const char *node = "libs/gui/gl";
char **id, *incdirs[] = {"GL", "OpenGL", NULL};
char **cf, *cflgs[] = {"", "-I/usr/include/libdrm", NULL};
const char **lf, *ldflgs[] = {"-lGL", "-lopengl32", NULL};
const char **lf, *ldflgs[] = {"-lGL", "-lopengl32", "-framework OpenGL", NULL};
char *cflags = NULL;
char *ldflags = NULL;
(void) call; /* not used */

View File

@ -122,6 +122,7 @@ int find_gtk2_key_prefix(const char *name, int logdepth, int fatal)
const char *test_c_ =
NL "#include <gdk/gdkkeysyms.h>"
NL "#include <stdlib.h>"
NL "#include <stdio.h>"
NL
NL "int main(int argc, char *argv[])"
NL "{"

View File

@ -26,6 +26,7 @@
int find_script_duktape(const char *name, int logdepth, int fatal)
{
char *test_c =
NL "#include <stdio.h>"
NL "#include <duktape.h>"
NL "int main() {"
NL " duk_context *ctx = duk_create_heap_default();"

View File

@ -26,6 +26,7 @@
int find_script_fungw(const char *name, int logdepth, int fatal)
{
char *test_c =
NL "#include <stdio.h>"
NL "#include <libfungw/fungw.h>"
NL "int main() {"
NL " fgw_ctx_t ctx;"

View File

@ -26,6 +26,7 @@
int find_script_funlisp(const char *name, int logdepth, int fatal)
{
char *test_c =
NL "#include <stdio.h>"
NL "#include <funlisp.h>"
NL "int main() {"
NL " lisp_runtime *rt = lisp_runtime_new();"

View File

@ -30,6 +30,7 @@ int find_script_guile(const char *name, int logdepth, int fatal)
/* temp hack: guile/gh makes sure we have the old, 1.8 version */
char *test_c =
NL "#include <stdio.h>"
NL "#include <libguile.h>"
NL "#include <guile/gh.h>"
NL "int main(int argc, char *argv[]) {"

View File

@ -26,6 +26,7 @@
int find_script_lua(const char *name, int logdepth, int fatal)
{
char *test_c =
NL "#include <stdio.h>"
NL "#include <lua.h>"
NL "#include <lauxlib.h>"
NL "int main() {"

View File

@ -25,6 +25,7 @@
int find_script_mruby(const char *name, int logdepth, int fatal)
{
char *test_c =
NL "#include <stdio.h>"
NL "#include <mruby.h>"
NL "int main() {"
NL " mrb_state *ctx = mrb_open();"

View File

@ -27,6 +27,7 @@ int find_script_perl(const char *name, int logdepth, int fatal)
char *cflags, *ldflags, *s;
int res;
char *test_c =
NL "#include <stdio.h>"
NL "#include <EXTERN.h>"
NL "#include <perl.h>"
NL "int main() {"

View File

@ -63,6 +63,7 @@ int find_script_ruby(const char *name, int logdepth, int fatal)
const char *require18s;
char *test_c =
NL "#include <stdio.h>"
NL "#include <ruby.h>"
NL "int main() {"
NL " ruby_init();"
@ -73,6 +74,7 @@ int find_script_ruby(const char *name, int logdepth, int fatal)
NL;
char *test_c18 =
NL "#include <stdio.h>"
NL "#include <ruby.h>"
NL "#include <env.h>"
NL "int main() {"

View File

@ -27,6 +27,7 @@
int find_script_stutter(const char *name, int logdepth, int fatal)
{
char *test_c =
NL "#include <stdio.h>"
NL "#include <stutter.h>"
NL "int main() {"
NL " varctx *global;"
@ -57,6 +58,7 @@ int find_script_stutter(const char *name, int logdepth, int fatal)
int find_script_estutter(const char *name, int logdepth, int fatal)
{
char *test_c =
NL "#include <stdio.h>"
NL "#include <estutter/stutter.h>"
NL "int main() {"
NL " stt_ctx_t stt;"

View File

@ -42,6 +42,7 @@ int find_script_tcl_(const char *name, int logdepth, int fatal, int *vers, int f
};
char *test_c =
NL "#include <stdio.h>"
NL "#include <tcl.h>"
NL "int main() {"
NL " Tcl_Obj *res;"

View File

@ -79,12 +79,19 @@ void print_image()
draw();
#ifdef __unix__
XpmWriteFileFromPixmap(display, "plot.xpm", xctx->save_pixmap,0, NULL ); /* .gz ???? */
#endif
dbg(1, "print_image(): Window image saved\n");
if(plotfile[0]) {
my_snprintf(cmd, S(cmd), "convert_to_png plot.xpm %s", plotfile);
tcleval(cmd);
} else tcleval( "convert_to_png plot.xpm plot.png");
#else
char *psfile=NULL;
create_ps(&psfile);
if(plotfile[0]) {
my_snprintf(cmd, S(cmd), "convert_to_png %s %s", psfile, plotfile);
tcleval(cmd);
} else tcleval( "convert_to_png %s plot.png", psfile);
#endif
my_strncpy(plotfile,"", S(plotfile));
draw_grid=save_draw_grid;
draw_pixmap=1;

View File

@ -649,21 +649,221 @@ static void fill_ps_colors()
}
void create_ps(char **psfile)
{
double dx, dy, scale, scaley;
int landscape=1;
double margin=10; /* in postscript points, (1/72)". No need to add margin as xschem zoom full already has margins.*/
/* Legal: 612 792 */
double pagex=842;/* a4, in postscript points, (1/72)" */
double pagey=595;/* a4, in postscript points, (1/72)" */
xRect boundbox;
int c,i, textlayer;
int old_grid;
const char *textfont;
if(!(fd = open_tmpfile("psplot_", psfile)) ) {
fprintf(errfp, "ps_draw(): can not create tmpfile %s\n", *psfile);
return;
}
ps_colors=my_calloc(311, cadlayers, sizeof(Ps_color));
if(ps_colors==NULL){
fprintf(errfp, "create_ps(): calloc error\n");tcleval( "exit");
}
fill_ps_colors();
old_grid=draw_grid;
draw_grid=0;
boundbox.x1 = xctx->areax1;
boundbox.x2 = xctx->areax2;
boundbox.y1 = xctx->areay1;
boundbox.y2 = xctx->areay2;
dx=boundbox.x2-boundbox.x1;
dy=boundbox.y2-boundbox.y1;
/* xschem window aspect ratio decides if portrait or landscape */
if(dy > dx) landscape = 0;
else landscape = 1;
if(!landscape) {
double tmp;
tmp = pagex;
pagex = pagey;
pagey = tmp;
}
dbg(1, "ps_draw(): bbox: x1=%g y1=%g x2=%g y2=%g\n", boundbox.x1, boundbox.y1, boundbox.x2, boundbox.y2);
fprintf(fd, "%%!PS-Adobe-3.0\n");
/* fprintf(fd, "%%%%DocumentMedia: %s %g %g 80 () ()\n", landscape ? "a4land" : "a4", pagex, pagey); */
fprintf(fd, "%%%%DocumentMedia: %s %g %g 80 () ()\n", "a4", pagex, pagey);
fprintf(fd, "%%%%PageOrientation: %s\n", landscape ? "Landscape" : "Portrait");
fprintf(fd, "%%%%Title: xschem plot\n");
fprintf(fd, "%%%%Creator: xschem\n");
fprintf(fd, "%%%%Pages: 1\n");
fprintf(fd, "%%%%EndComments\n");
fprintf(fd, "%%%%BeginProlog\n\n");
for(i = 0; i < sizeof(utf8_enc)/sizeof(char *); i++) {
fprintf(fd, utf8_enc[i]);
}
for(i = 0; i < sizeof(utf8)/sizeof(char *); i++) {
fprintf(fd, utf8[i]);
}
fprintf(fd, "/Times /Times chararr recode\n");
fprintf(fd, "/Times-Bold /Times-Bold chararr recode\n");
fprintf(fd, "/Times-Oblique /Times-Oblique chararr recode\n");
fprintf(fd, "/Times-BoldOblique /Times-BoldOblique chararr recode\n");
fprintf(fd, "/Helvetica /Helvetica chararr recode\n");
fprintf(fd, "/Helvetica-Bold /Helvetica-Bold chararr recode\n");
fprintf(fd, "/Helvetica-Oblique /Helvetica-Oblique chararr recode\n");
fprintf(fd, "/Helvetica-BoldOblique /Helvetica-BoldOblique chararr recode\n");
fprintf(fd, "/Courier /Courier chararr recode\n");
fprintf(fd, "/Courier-Bold /Courier-Bold chararr recode\n");
fprintf(fd, "/Courier-Oblique /Courier-Oblique chararr recode\n");
fprintf(fd, "/Courier-BoldOblique /Courier-BoldOblique chararr recode\n");
fprintf(fd,"/cm {28.346457 mul} bind def\n");
fprintf(fd,"/LT {lineto} bind def\n");
fprintf(fd,"/MT {moveto} bind def\n");
fprintf(fd,"/RMT {rmoveto} bind def\n");
fprintf(fd,"/L {moveto lineto stroke} bind def\n");
fprintf(fd,"/RGB {setrgbcolor} bind def\n");
fprintf(fd,"/FF {findfont} bind def\n");
fprintf(fd,"/SF {setfont} bind def\n");
fprintf(fd,"/SCF {scalefont} bind def\n");
fprintf(fd,"/SW {stringwidth} bind def\n");
fprintf(fd,"/GS {gsave} bind def\n");
fprintf(fd,"/GR {grestore} bind def\n");
fprintf(fd,"/NP {newpath} bind def\n");
fprintf(fd,"/A {arcn} bind def\n");
fprintf(fd,"/R {rectstroke} bind def\n");
fprintf(fd,"/S {stroke} bind def\n");
fprintf(fd,"/C {closepath} bind def\n");
fprintf(fd,"/F {fill} bind def\n");
fprintf(fd,"/RF {rectfill} bind def\n");
fprintf(fd, "%%%%EndProlog\n");
fprintf(fd, "%%%%BeginSetup\n");
fprintf(fd, "<< /PageSize [%g %g] /Orientation 0 >> setpagedevice\n", pagex, pagey);
fprintf(fd, "%%%%Page: 1 1\n\n");
fprintf(fd, "%%%%BeginPageSetup\n");
fprintf(fd, "%%%%EndPageSetup\n");
scaley = scale = (pagey-2 * margin) / dy;
dbg(1, "scale=%g pagex=%g pagey=%g dx=%g dy=%g\n", scale, pagex, pagey, dx, dy);
if(dx * scale > (pagex - 2 * margin)) {
scale = (pagex - 2 * margin) / dx;
dbg(1, "scale=%g\n", scale);
}
fprintf(fd, "%g %g translate\n",
-scale * boundbox.x1 + margin, pagey - (scaley - scale) * dy - margin + scale * boundbox.y1);
fprintf(fd, "%g %g scale\n", scale, -scale);
fprintf(fd, "1 setlinejoin 1 setlinecap\n");
set_lw();
ps_drawgrid();
for(i=0;i<xctx->texts;i++)
{
textlayer = xctx->text[i].layer;
if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER;
my_snprintf(ps_font_family, S(ps_font_name), "Helvetica");
my_snprintf(ps_font_name, S(ps_font_name), "Helvetica");
textfont = xctx->text[i].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( xctx->text[i].flags & TEXT_BOLD) {
if( (xctx->text[i].flags & TEXT_ITALIC) || (xctx->text[i].flags & TEXT_OBLIQUE) ) {
my_snprintf(ps_font_family, S(ps_font_family), "%s-BoldOblique", ps_font_name);
} else {
my_snprintf(ps_font_family, S(ps_font_family), "%s-Bold", ps_font_name);
}
}
else if( xctx->text[i].flags & TEXT_ITALIC)
my_snprintf(ps_font_family, S(ps_font_family), "%s-Oblique", ps_font_name);
else if( xctx->text[i].flags & TEXT_OBLIQUE)
my_snprintf(ps_font_family, S(ps_font_family), "%s-Oblique", ps_font_name);
if(text_ps) {
ps_draw_string(textlayer, xctx->text[i].txt_ptr,
xctx->text[i].rot, xctx->text[i].flip, xctx->text[i].hcenter, xctx->text[i].vcenter,
xctx->text[i].x0,xctx->text[i].y0,
xctx->text[i].xscale, xctx->text[i].yscale);
} else {
old_ps_draw_string(textlayer, xctx->text[i].txt_ptr,
xctx->text[i].rot, xctx->text[i].flip, xctx->text[i].hcenter, xctx->text[i].vcenter,
xctx->text[i].x0,xctx->text[i].y0,
xctx->text[i].xscale, xctx->text[i].yscale);
}
}
for(c=0;c<cadlayers;c++)
{
set_ps_colors(c);
for(i=0;i<xctx->lines[c];i++)
ps_drawline(c, xctx->line[c][i].x1, xctx->line[c][i].y1,
xctx->line[c][i].x2, xctx->line[c][i].y2, xctx->line[c][i].dash);
for(i=0;i<xctx->rects[c];i++)
{
ps_filledrect(c, xctx->rect[c][i].x1, xctx->rect[c][i].y1,
xctx->rect[c][i].x2, xctx->rect[c][i].y2, xctx->rect[c][i].dash);
}
for(i=0;i<xctx->arcs[c];i++)
{
ps_drawarc(c, xctx->arc[c][i].fill, xctx->arc[c][i].x, xctx->arc[c][i].y,
xctx->arc[c][i].r, xctx->arc[c][i].a, xctx->arc[c][i].b, xctx->arc[c][i].dash);
}
for(i=0;i<xctx->polygons[c];i++) {
ps_drawpolygon(c, NOW, xctx->poly[c][i].x, xctx->poly[c][i].y, xctx->poly[c][i].points,
xctx->poly[c][i].fill, xctx->poly[c][i].dash);
}
for(i=0;i<xctx->instances;i++)
ps_draw_symbol(i,c,0,0,0.0,0.0);
}
set_ps_colors(WIRELAYER);
for(i=0;i<xctx->wires;i++)
{
ps_drawline(WIRELAYER, xctx->wire[i].x1,xctx->wire[i].y1,xctx->wire[i].x2,xctx->wire[i].y2, 0);
}
{
double x1, y1, x2, y2;
struct wireentry *wireptr;
int i;
struct iterator_ctx ctx;
update_conn_cues(0, 0);
/* draw connecting dots */
x1 = X_TO_XSCHEM(xctx->areax1);
y1 = Y_TO_XSCHEM(xctx->areay1);
x2 = X_TO_XSCHEM(xctx->areax2);
y2 = Y_TO_XSCHEM(xctx->areay2);
for(init_wire_iterator(&ctx, x1, y1, x2, y2); ( wireptr = wire_iterator_next(&ctx) ) ;) {
i = wireptr->n;
if( xctx->wire[i].end1 >1 ) { /* 20150331 draw_dots */
ps_drawarc(WIRELAYER, 1, xctx->wire[i].x1, xctx->wire[i].y1, cadhalfdotsize, 0, 360, 0);
}
if( xctx->wire[i].end2 >1 ) { /* 20150331 draw_dots */
ps_drawarc(WIRELAYER, 1, xctx->wire[i].x2, xctx->wire[i].y2, cadhalfdotsize, 0, 360, 0);
}
}
}
dbg(1, "ps_draw(): INT_WIDTH(lw)=%d plotfile=%s\n",INT_WIDTH(xctx->lw), plotfile);
fprintf(fd, "showpage\n\n");
fprintf(fd, "%%%%trailer\n");
fprintf(fd, "%%%%EOF\n");
fclose(fd);
draw_grid=old_grid;
my_free(879, &ps_colors);
}
void ps_draw(void)
{
double dx, dy, scale, scaley;
int landscape=1;
double margin=10; /* in postscript points, (1/72)". No need to add margin as xschem zoom full already has margins.*/
/* Legal: 612 792 */
double pagex=842;/* a4, in postscript points, (1/72)" */
double pagey=595;/* a4, in postscript points, (1/72)" */
xRect boundbox;
int c,i, textlayer;
char tmp[2*PATH_MAX+40];
static char lastdir[PATH_MAX] = "";
int old_grid;
const char *r, *textfont;
const char *r;
char *psfile;
if(!lastdir[0]) my_strncpy(lastdir, pwd_dir, S(lastdir));
@ -677,200 +877,7 @@ void ps_draw(void)
}
else return;
}
if(!(fd = open_tmpfile("psplot_", &psfile)) ) {
fprintf(errfp, "ps_draw(): can not create tmpfile %s\n", psfile);
return;
}
ps_colors=my_calloc(311, cadlayers, sizeof(Ps_color));
if(ps_colors==NULL){
fprintf(errfp, "ps_draw(): calloc error\n");tcleval( "exit");
}
fill_ps_colors();
old_grid=draw_grid;
draw_grid=0;
boundbox.x1 = xctx->areax1;
boundbox.x2 = xctx->areax2;
boundbox.y1 = xctx->areay1;
boundbox.y2 = xctx->areay2;
dx=boundbox.x2-boundbox.x1;
dy=boundbox.y2-boundbox.y1;
/* xschem window aspect ratio decides if portrait or landscape */
if(dy > dx) landscape = 0;
else landscape = 1;
if(!landscape) {
double tmp;
tmp = pagex;
pagex = pagey;
pagey = tmp;
}
dbg(1, "ps_draw(): bbox: x1=%g y1=%g x2=%g y2=%g\n", boundbox.x1, boundbox.y1, boundbox.x2, boundbox.y2);
fprintf(fd, "%%!PS-Adobe-3.0\n");
/* fprintf(fd, "%%%%DocumentMedia: %s %g %g 80 () ()\n", landscape ? "a4land" : "a4", pagex, pagey); */
fprintf(fd, "%%%%DocumentMedia: %s %g %g 80 () ()\n", "a4", pagex, pagey);
fprintf(fd, "%%%%PageOrientation: %s\n", landscape ? "Landscape" : "Portrait");
fprintf(fd, "%%%%Title: xschem plot\n");
fprintf(fd, "%%%%Creator: xschem\n");
fprintf(fd, "%%%%Pages: 1\n");
fprintf(fd, "%%%%EndComments\n");
fprintf(fd, "%%%%BeginProlog\n\n");
for(i = 0; i < sizeof(utf8_enc)/sizeof(char *); i++) {
fprintf(fd, utf8_enc[i]);
}
for(i = 0; i < sizeof(utf8)/sizeof(char *); i++) {
fprintf(fd, utf8[i]);
}
fprintf(fd, "/Times /Times chararr recode\n");
fprintf(fd, "/Times-Bold /Times-Bold chararr recode\n");
fprintf(fd, "/Times-Oblique /Times-Oblique chararr recode\n");
fprintf(fd, "/Times-BoldOblique /Times-BoldOblique chararr recode\n");
fprintf(fd, "/Helvetica /Helvetica chararr recode\n");
fprintf(fd, "/Helvetica-Bold /Helvetica-Bold chararr recode\n");
fprintf(fd, "/Helvetica-Oblique /Helvetica-Oblique chararr recode\n");
fprintf(fd, "/Helvetica-BoldOblique /Helvetica-BoldOblique chararr recode\n");
fprintf(fd, "/Courier /Courier chararr recode\n");
fprintf(fd, "/Courier-Bold /Courier-Bold chararr recode\n");
fprintf(fd, "/Courier-Oblique /Courier-Oblique chararr recode\n");
fprintf(fd, "/Courier-BoldOblique /Courier-BoldOblique chararr recode\n");
fprintf(fd,"/cm {28.346457 mul} bind def\n");
fprintf(fd,"/LT {lineto} bind def\n");
fprintf(fd,"/MT {moveto} bind def\n");
fprintf(fd,"/RMT {rmoveto} bind def\n");
fprintf(fd,"/L {moveto lineto stroke} bind def\n");
fprintf(fd,"/RGB {setrgbcolor} bind def\n");
fprintf(fd,"/FF {findfont} bind def\n");
fprintf(fd,"/SF {setfont} bind def\n");
fprintf(fd,"/SCF {scalefont} bind def\n");
fprintf(fd,"/SW {stringwidth} bind def\n");
fprintf(fd,"/GS {gsave} bind def\n");
fprintf(fd,"/GR {grestore} bind def\n");
fprintf(fd,"/NP {newpath} bind def\n");
fprintf(fd,"/A {arcn} bind def\n");
fprintf(fd,"/R {rectstroke} bind def\n");
fprintf(fd,"/S {stroke} bind def\n");
fprintf(fd,"/C {closepath} bind def\n");
fprintf(fd,"/F {fill} bind def\n");
fprintf(fd,"/RF {rectfill} bind def\n");
fprintf(fd, "%%%%EndProlog\n");
fprintf(fd, "%%%%BeginSetup\n");
fprintf(fd, "<< /PageSize [%g %g] /Orientation 0 >> setpagedevice\n", pagex, pagey);
fprintf(fd, "%%%%Page: 1 1\n\n");
fprintf(fd, "%%%%BeginPageSetup\n");
fprintf(fd, "%%%%EndPageSetup\n");
scaley = scale = (pagey-2 * margin) / dy;
dbg(1, "scale=%g pagex=%g pagey=%g dx=%g dy=%g\n", scale, pagex, pagey, dx, dy);
if(dx * scale > (pagex - 2 * margin)) {
scale = (pagex - 2 * margin) / dx;
dbg(1, "scale=%g\n", scale);
}
fprintf(fd, "%g %g translate\n",
-scale * boundbox.x1 + margin, pagey - (scaley - scale) * dy - margin + scale * boundbox.y1);
fprintf(fd, "%g %g scale\n", scale, -scale);
fprintf(fd, "1 setlinejoin 1 setlinecap\n");
set_lw();
ps_drawgrid();
for(i=0;i<xctx->texts;i++)
{
textlayer = xctx->text[i].layer;
if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER;
my_snprintf(ps_font_family, S(ps_font_name), "Helvetica");
my_snprintf(ps_font_name, S(ps_font_name), "Helvetica");
textfont = xctx->text[i].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( xctx->text[i].flags & TEXT_BOLD) {
if( (xctx->text[i].flags & TEXT_ITALIC) || (xctx->text[i].flags & TEXT_OBLIQUE) ) {
my_snprintf(ps_font_family, S(ps_font_family), "%s-BoldOblique", ps_font_name);
} else {
my_snprintf(ps_font_family, S(ps_font_family), "%s-Bold", ps_font_name);
}
}
else if( xctx->text[i].flags & TEXT_ITALIC)
my_snprintf(ps_font_family, S(ps_font_family), "%s-Oblique", ps_font_name);
else if( xctx->text[i].flags & TEXT_OBLIQUE)
my_snprintf(ps_font_family, S(ps_font_family), "%s-Oblique", ps_font_name);
if(text_ps) {
ps_draw_string(textlayer, xctx->text[i].txt_ptr,
xctx->text[i].rot, xctx->text[i].flip, xctx->text[i].hcenter, xctx->text[i].vcenter,
xctx->text[i].x0,xctx->text[i].y0,
xctx->text[i].xscale, xctx->text[i].yscale);
} else {
old_ps_draw_string(textlayer, xctx->text[i].txt_ptr,
xctx->text[i].rot, xctx->text[i].flip, xctx->text[i].hcenter, xctx->text[i].vcenter,
xctx->text[i].x0,xctx->text[i].y0,
xctx->text[i].xscale, xctx->text[i].yscale);
}
}
for(c=0;c<cadlayers;c++)
{
set_ps_colors(c);
for(i=0;i<xctx->lines[c];i++)
ps_drawline(c, xctx->line[c][i].x1, xctx->line[c][i].y1,
xctx->line[c][i].x2, xctx->line[c][i].y2, xctx->line[c][i].dash);
for(i=0;i<xctx->rects[c];i++)
{
ps_filledrect(c, xctx->rect[c][i].x1, xctx->rect[c][i].y1,
xctx->rect[c][i].x2, xctx->rect[c][i].y2, xctx->rect[c][i].dash);
}
for(i=0;i<xctx->arcs[c];i++)
{
ps_drawarc(c, xctx->arc[c][i].fill, xctx->arc[c][i].x, xctx->arc[c][i].y,
xctx->arc[c][i].r, xctx->arc[c][i].a, xctx->arc[c][i].b, xctx->arc[c][i].dash);
}
for(i=0;i<xctx->polygons[c];i++) {
ps_drawpolygon(c, NOW, xctx->poly[c][i].x, xctx->poly[c][i].y, xctx->poly[c][i].points,
xctx->poly[c][i].fill, xctx->poly[c][i].dash);
}
for(i=0;i<xctx->instances;i++)
ps_draw_symbol(i,c,0,0,0.0,0.0);
}
set_ps_colors(WIRELAYER);
for(i=0;i<xctx->wires;i++)
{
ps_drawline(WIRELAYER, xctx->wire[i].x1,xctx->wire[i].y1,xctx->wire[i].x2,xctx->wire[i].y2, 0);
}
{
double x1, y1, x2, y2;
struct wireentry *wireptr;
int i;
struct iterator_ctx ctx;
update_conn_cues(0, 0);
/* draw connecting dots */
x1 = X_TO_XSCHEM(xctx->areax1);
y1 = Y_TO_XSCHEM(xctx->areay1);
x2 = X_TO_XSCHEM(xctx->areax2);
y2 = Y_TO_XSCHEM(xctx->areay2);
for(init_wire_iterator(&ctx, x1, y1, x2, y2); ( wireptr = wire_iterator_next(&ctx) ) ;) {
i = wireptr->n;
if( xctx->wire[i].end1 >1 ) { /* 20150331 draw_dots */
ps_drawarc(WIRELAYER, 1, xctx->wire[i].x1, xctx->wire[i].y1, cadhalfdotsize, 0, 360, 0);
}
if( xctx->wire[i].end2 >1 ) { /* 20150331 draw_dots */
ps_drawarc(WIRELAYER, 1, xctx->wire[i].x2, xctx->wire[i].y2, cadhalfdotsize, 0, 360, 0);
}
}
}
dbg(1, "ps_draw(): INT_WIDTH(lw)=%d plotfile=%s\n",INT_WIDTH(xctx->lw), plotfile);
fprintf(fd, "showpage\n\n");
fprintf(fd, "%%%%trailer\n");
fprintf(fd, "%%%%EOF\n");
fclose(fd);
draw_grid=old_grid;
my_free(879, &ps_colors);
create_ps(&psfile);
if(plotfile[0]) {
my_snprintf(tmp, S(tmp), "convert_to_pdf %s %s", psfile, plotfile);
} else {

View File

@ -860,6 +860,7 @@ extern int name_strcmp(char *s, char *d) ;
extern int search(const char *tok, const char *val, int sub, int sel);
extern int process_options(int argc, char **argv);
extern void calc_drawing_bbox(xRect *boundbox, int selected);
extern void create_ps(char **psfile);
extern void ps_draw(void);
extern void svg_draw(void);
extern void set_viewport_size(int w, int h, double lw);

View File

@ -186,8 +186,12 @@ proc convert_to_pdf {filename dest} {
global to_pdf
# puts "convert_to_pdf: $filename --> $dest"
if { [regexp -nocase {\.pdf$} $dest] } {
set pdffile [file rootname $filename].pdf]
if { ![catch "exec $to_pdf $filename $pdffile" msg] } {
set pdffile [file rootname $filename].pdf
set cmd "exec $to_pdf $filename $pdffile"
if {$::OS == "Windows"} {
set cmd "exec $to_pdf $pdffile $filename"
}
if { ![catch $cmd msg] } {
file rename -force $pdffile $dest
# ps2pdf succeeded, so remove original .ps file
if { ![xschem get debug_var] } {
@ -205,7 +209,11 @@ proc convert_to_pdf {filename dest} {
proc convert_to_png {filename dest} {
global to_png tcl_debug
# puts "---> $to_png $filename $destfile"
if { ![catch "exec $to_png $filename png:$dest" msg] } {
set cmd "exec $to_png $filename png:$dest"
if {$::OS == "Windows"} {
set cmd "exec $to_png $dest $filename"
}
if { ![catch $cmd msg] } {
# conversion succeeded, so remove original .xpm file
if { ![xschem get debug_var] } {
file delete $filename

View File

@ -149,11 +149,15 @@
#### command to translate xpm to png; (assumes command takes source
#### and dest file as arguments, example: gm convert plot.xpm plot.png)
#### default: {gm convert}
#### Windows ghostscript uses gswin64c
# set to_png {gswin64c -sDEVICE=png16m -o}
# set to_png {gm convert}
#### command to translate ps to pdf; (assumes command takes source
#### and dest file as arguments, example: ps2pdf plot.ps plot.pdf)
#### default: ps2pdf
#### Windows ghostscript uses gswin64c
# set to_pdf {gswin64c -sDEVICE=pdfwrite -o}
# set to_pdf ps2pdf
###########################################################################