From 38ff46069443359fcbf774d5c28dca78bbe53c47 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Mon, 15 Jan 2024 15:53:49 +0100 Subject: [PATCH] added `xschem fill_reset` command to reset fill patterns defined via tcl array pixdata(n) --- doc/xschem_man/developer_info.html | 7 ++- src/scheduler.c | 19 +++++- src/xinit.c | 34 +++++++++-- src/xschem.h | 1 + src/xschem.tcl | 93 ++++++++++++++++++++++++++++++ src/xschemrc | 19 ++++++ 6 files changed, 164 insertions(+), 9 deletions(-) diff --git a/doc/xschem_man/developer_info.html b/doc/xschem_man/developer_info.html index b117c242..2d9ff461 100644 --- a/doc/xschem_man/developer_info.html +++ b/doc/xschem_man/developer_info.html @@ -546,8 +546,6 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns" - - @@ -683,6 +681,9 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns" xschem expandlabel {2*A[3:0]} --> A[3],A[2],A[1],A[0],A[3],A[2],A[1],A[0] 8 last field is the number of bits since [ and ] are TCL special characters argument must be quoted with { and } +
  • fill_reset [nodraw]
  • +   After setting tcl array pixdata(n) reset fill patterns on all layers
    +   If 'nodraw' is given do not redraw window.
  • fill_type n fill_type [nodraw]
  •     Set fill type for layer 'n', fill_type may be 'solid' or 'stipple' or 'empty'
        If 'nodraw' is given do not redraw window.
    @@ -1489,6 +1490,8 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns" + + diff --git a/src/scheduler.c b/src/scheduler.c index fe3e498a..186b2981 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -908,11 +908,28 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg else { cmd_found = 0;} break; case 'f': /*----------------------------------------------*/ + /* fill_reset [nodraw] + * After setting tcl array pixdata(n) reset fill patterns on all layers + * If 'nodraw' is given do not redraw window. + */ + if(!strcmp(argv[1], "fill_reset")) + { + int dr = 1; + if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;} + init_pixdata(); + free_gc(); + create_gc(); + enable_layers(); + build_colors(0.0, 0.0); + resetwin(1, 0, 1, 0, 0); /* recreate pixmap. resetwin(create_pixmap, clear_pixmap, force, w, h) */ + if(argc > 2 && !strcmp(argv[2], "nodraw")) dr = 0; + if(dr) draw(); + } /* fill_type n fill_type [nodraw] * Set fill type for layer 'n', fill_type may be 'solid' or 'stipple' or 'empty' * If 'nodraw' is given do not redraw window. */ - if(!strcmp(argv[1], "fill_type")) + else if(!strcmp(argv[1], "fill_type")) { int dr = 1; if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;} diff --git a/src/xinit.c b/src/xinit.c index 795c0759..821481ed 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -325,17 +325,39 @@ static void init_color_array(double dim, double dim_bg) } } -static void init_pixdata()/* populate xctx->fill_type array that is used in create_gc() to set fill styles */ +void init_pixdata()/* populate xctx->fill_type array that is used in create_gc() to set fill styles */ { int i,j, full, empty; + const char *tclpixdata; + const char *tclword; + int found_data; + for(i=0;i> 1), NULL); + tclword = tclresult(); + if(tclword[0]) { + unsigned int word; + unsigned char byte; + sscanf(tclword, "%x", &word); + if(j%2) byte = word & 0xff; + else byte = (word >> 8) & 0xff; + dbg(1, "byte=%02x\n", byte); + found_data = 1; + pixdata[i][j] = byte; + } + } + if(!found_data) { + if(i