diff --git a/XSchemWin/XSchemWix/doc.wxs b/XSchemWin/XSchemWix/doc.wxs index 24baaca9..08c970fc 100644 --- a/XSchemWin/XSchemWix/doc.wxs +++ b/XSchemWin/XSchemWix/doc.wxs @@ -270,6 +270,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -901,6 +946,21 @@ + + + + + + + + + + + + + + + diff --git a/XSchemWin/XSchemWix/heat_doc.wxs b/XSchemWin/XSchemWix/heat_doc.wxs index e46e69d9..60acb382 100644 --- a/XSchemWin/XSchemWix/heat_doc.wxs +++ b/XSchemWin/XSchemWix/heat_doc.wxs @@ -3,808 +3,853 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -901,6 +946,21 @@ + + + + + + + + + + + + + + + diff --git a/XSchemWin/config.h b/XSchemWin/config.h index 9eac9dd7..07290494 100644 --- a/XSchemWin/config.h +++ b/XSchemWin/config.h @@ -4,7 +4,8 @@ /*************************************************************/ /* Define to 1 if cairo is available and is to be used */ -/*#undef HAS_CAIRO */ +/* #define HAS_CAIRO 1 +#define CAIRO_WIN32_STATIC_BUILD 1 */ /* Define to 1 if Xlib's xcb is available */ /*#undef HAS_XCB */ diff --git a/src/draw.c b/src/draw.c index 5dea8182..14317052 100644 --- a/src/draw.c +++ b/src/draw.c @@ -78,34 +78,43 @@ void print_image() tclsetvar("draw_grid", "0"); xctx->draw_pixmap=1; draw(); - #ifdef __unix__ + #if HAS_CAIRO == 1 /* use cairo native support for png writing, no need to convert * XPM and handles Xrender extensions for transparent embedded images */ { cairo_surface_t *png_sfc; +#ifdef __unix__ png_sfc = cairo_xlib_surface_create(display, xctx->save_pixmap, visual, xctx->xrect[0].width, xctx->xrect[0].height); +#else + HWND hwnd = Tk_GetHWND(xctx->window); + HDC dc = GetDC(hwnd); + png_sfc = cairo_win32_surface_create(dc); +#endif + if(xctx->plotfile[0]) cairo_surface_write_to_png(png_sfc, xctx->plotfile); else cairo_surface_write_to_png(png_sfc, "plot.png"); } #else /* no cairo */ +#ifdef __unix__ XpmWriteFileFromPixmap(display, "plot.xpm", xctx->save_pixmap,0, NULL ); /* .gz ???? */ dbg(1, "print_image(): Window image saved\n"); if(xctx->plotfile[0]) { my_snprintf(cmd, S(cmd), "convert_to_png plot.xpm {%s}", xctx->plotfile); tcleval(cmd); } else tcleval( "convert_to_png plot.xpm plot.png"); - #endif - #else - char *psfile=NULL; +#else + char *psfile = NULL; create_ps(&psfile, 7); - if(xctx->plotfile[0]) { + if (xctx->plotfile[0]) { my_snprintf(cmd, S(cmd), "convert_to_png {%s} {%s}", psfile, xctx->plotfile); tcleval(cmd); - } else tcleval( "convert_to_png {%s} plot.png", psfile); + } + else tcleval("convert_to_png {%s} plot.png", psfile); +#endif #endif my_strncpy(xctx->plotfile,"", S(xctx->plotfile)); tclsetboolvar("draw_grid", save_draw_grid); @@ -113,8 +122,9 @@ void print_image() } #if HAS_CAIRO==1 -void set_cairo_color(int layer) +void set_cairo_color(int layer) { +#ifdef __unix__ cairo_set_source_rgb(xctx->cairo_ctx, (double)xctx->xcolor_array[layer].red/65535.0, (double)xctx->xcolor_array[layer].green/65535.0, @@ -123,6 +133,10 @@ void set_cairo_color(int layer) (double)xctx->xcolor_array[layer].red/65535.0, (double)xctx->xcolor_array[layer].green/65535.0, (double)xctx->xcolor_array[layer].blue/65535.0); +#else /* temporary until I get find_best_color to work on Windows */ + cairo_set_source_rgb(xctx->cairo_ctx, 1, 0, 0); + cairo_set_source_rgb(xctx->cairo_save_ctx, 1, 0, 0); +#endif } /* remember to call cairo_restore(xctx->cairo_ctx) when done !! */ diff --git a/src/save.c b/src/save.c index 955fa634..77384d5d 100644 --- a/src/save.c +++ b/src/save.c @@ -222,13 +222,16 @@ unsigned char *base64_decode(const char *data, const size_t input_length, size_t * data layout in memory arranged to maximize cache locality * when looking up data */ -static void read_binary_block(FILE *fd) +static void read_binary_block(FILE *fd, int sim_type) { int p, v; double *tmp; size_t size = 0; int offset = 0; + int mult = 0; + double val; + if(sim_type == 3) mult = 1; /* AC analysis, complex numbers twice the size */ for(p = 0 ; p < xctx->graph_datasets; p++) { size += xctx->graph_nvars * xctx->graph_npoints[p]; @@ -236,19 +239,24 @@ static void read_binary_block(FILE *fd) } /* read buffer */ - tmp = my_calloc(1405, xctx->graph_nvars, sizeof(double *)); + tmp = my_calloc(1405, xctx->graph_nvars, (sizeof(double *) << mult)); /* allocate storage for binary block */ if(!xctx->graph_values) xctx->graph_values = my_calloc(118, xctx->graph_nvars, sizeof(SPICE_DATA *)); for(p = 0 ; p < xctx->graph_nvars; p++) { - my_realloc(372, &xctx->graph_values[p], (size + xctx->graph_npoints[xctx->graph_datasets]) * sizeof(double)); + my_realloc(372, + &xctx->graph_values[p], (size + xctx->graph_npoints[xctx->graph_datasets]) * sizeof(SPICE_DATA)); } /* read binary block */ for(p = 0; p < xctx->graph_npoints[xctx->graph_datasets]; p++) { - if(fread(tmp, sizeof(double), xctx->graph_nvars, fd) != xctx->graph_nvars) { + if(fread(tmp, (sizeof(double) << mult), xctx->graph_nvars, fd) != xctx->graph_nvars) { dbg(0, "Warning: binary block is not of correct size\n"); } /* assign to xschem struct, memory aligned per variable, for cache locality */ - for(v = 0; v < xctx->graph_nvars; v++) { + if(mult) for(v = 0; v < xctx->graph_nvars; v++) { /*AC analysis: calculate magnitude */ + xctx->graph_values[v][offset + p] = + sqrt( tmp[v << mult] * tmp[v << mult] + tmp[(v << mult) + 1] * tmp[(v << mult) + 1]); + } + else for(v = 0; v < xctx->graph_nvars; v++) { xctx->graph_values[v][offset + p] = tmp[v]; } } @@ -292,7 +300,7 @@ static int read_dataset(FILE *fd) int npoints = xctx->graph_npoints[xctx->graph_datasets]; if(sim_type) { done_header = 1; - read_binary_block(fd); + read_binary_block(fd, sim_type); dbg(1, "read_dataset(): read binary block, nvars=%d npoints=%d\n", xctx->graph_nvars, npoints); xctx->graph_datasets++; exit_status = 1; @@ -310,6 +318,10 @@ static int read_dataset(FILE *fd) if(sim_type && sim_type != 2) sim_type = 0; else sim_type = 2; } + else if(!strncmp(line, "Plotname: AC Analysis", 21)) { + if(sim_type && sim_type != 3) sim_type = 0; + else sim_type = 3; + } else if(!strncmp(line, "Plotname:", 9)) { sim_type = 0; } diff --git a/src/xinit.c b/src/xinit.c index bc28bb05..0e368813 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -1532,8 +1532,15 @@ void resetcairo(int create, int clear, int force_or_resize) cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_FAST); cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_SLIGHT); /***** Create Cairo save buffer drawing area *****/ +#ifdef __unix__ xctx->cairo_save_sfc = cairo_xlib_surface_create(display, xctx->save_pixmap, visual, xctx->xrect[0].width, xctx->xrect[0].height); +#else + HWND hwnd = Tk_GetHWND(xctx->window); + HDC dc = GetDC(hwnd); + xctx->cairo_save_sfc = cairo_win32_surface_create(dc); + cairo_surface_set_device_scale(xctx->cairo_save_sfc, 1, 1); +#endif if(cairo_surface_status(xctx->cairo_save_sfc)!=CAIRO_STATUS_SUCCESS) { fprintf(errfp, "ERROR: invalid cairo xcb surface\n"); } @@ -1549,8 +1556,13 @@ void resetcairo(int create, int clear, int force_or_resize) cairo_set_line_join(xctx->cairo_save_ctx, CAIRO_LINE_JOIN_ROUND); cairo_set_line_cap(xctx->cairo_save_ctx, CAIRO_LINE_CAP_ROUND); /***** Create Cairo main drawing window structures *****/ +#ifdef __unix__ xctx->cairo_sfc = cairo_xlib_surface_create(display, xctx->window, visual, xctx->xrect[0].width, xctx->xrect[0].height); +#else + xctx->cairo_sfc = cairo_win32_surface_create(dc); + cairo_surface_set_device_scale(xctx->cairo_sfc, 1, 1); +#endif if(cairo_surface_status(xctx->cairo_sfc)!=CAIRO_STATUS_SUCCESS) { fprintf(errfp, "ERROR: invalid cairo surface\n"); } diff --git a/src/xschem.h b/src/xschem.h index ea81c7c1..1b018948 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -103,8 +103,12 @@ extern char win_temp_dir[PATH_MAX]; #if HAS_CAIRO==1 #include +#if __unix__ #include #include "cairo-xlib-xrender.h" +#else +#include +#endif #endif #include diff --git a/src/xschem.tcl b/src/xschem.tcl index 92f35ab6..5629f22e 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -4529,18 +4529,19 @@ proc delete_ctx {context} { } proc restore_ctx {context} { - # puts "restoring tcl context $context : semaphore=[xschem get semaphore]" global has_x - if {![info exists $has_x]} {return} + if {![info exists has_x]} {return} + # puts "restoring tcl context $context : semaphore=[xschem get semaphore]" set tctx::tctx $context array unset ::sim uplevel #0 { if { [ array exists $tctx::tctx ] } { # puts "restore_ctx $tctx::tctx" - # Cleanup these vars to avoid side effects from previous ctx + ## Cleanup these vars to avoid side effects from previous ctx unset -nocomplain gaw_fd foreach tctx::i $tctx::global_list { if { [info exists [subst $tctx::tctx]($tctx::i)] } { + # puts "restoring: $tctx::i" set $tctx::i [set [subst $tctx::tctx]($tctx::i)] } } @@ -4554,14 +4555,15 @@ proc restore_ctx {context} { } proc save_ctx {context} { - # puts "saving tcl context $context : semaphore=[xschem get semaphore]" global has_x - if {![info exists $has_x]} {return} + if {![info exists has_x]} {return} + # puts "saving tcl context $context : semaphore=[xschem get semaphore]" set tctx::tctx $context uplevel #0 { # puts "save_ctx $tctx::tctx" foreach tctx::i $tctx::global_list { if { [info exists $tctx::i] } { + # puts "saving: $tctx::i" set [subst $tctx::tctx]($tctx::i) [set $tctx::i] } }