From 769c7d4663bf80a74c31e28215cc69d7a6e5492d Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Thu, 9 Nov 2023 16:41:53 +0100 Subject: [PATCH] Add incremental_select tcl variable. It is normally set. If set show selected objects while dragging a selection rectangle. If unset show selection at end of drag operation. Fix possible endless loop whiel zooming on X axis if raw file has only one point (OP). Also if graph specifies custom plot switch to that raw file to get correct x range. --- src/actions.c | 6 ++++-- src/callback.c | 24 +++++++++++++++++++++--- src/xschem.tcl | 10 ++++++++-- src/xschemrc | 5 +++++ xschem_library/examples/cmos_example.sch | 8 ++++---- 5 files changed, 42 insertions(+), 11 deletions(-) diff --git a/src/actions.c b/src/actions.c index 15069dfe..1927cbb5 100644 --- a/src/actions.c +++ b/src/actions.c @@ -3459,6 +3459,7 @@ void fix_restore_rect(double x1, double y1, double x2, double y2) /* 20150927 select=1: select objects, select=0: unselect objects */ void select_rect(int what, int select) { + int incremental_select = tclgetboolvar("incremental_select"); dbg(1, "select_rect(): what=%d, mousex_save=%g mousey_save=%g, mousex_snap=%g mousey_snap=%g\n", what, xctx->mx_double_save, xctx->my_double_save, xctx->mousex_snap, xctx->mousey_snap); if(what & RUBBER) @@ -3475,10 +3476,11 @@ void select_rect(int what, int select) /* 20171026 update unselected objects while dragging */ rebuild_selected_array(); draw_selection(xctx->gc[SELLAYER], 0); - /* if(xctx->nl_sel) { */ + + if(incremental_select || !xctx->nl_sel) { if(xctx->nl_dir == 0) select_inside(xctx->nl_xx1, xctx->nl_yy1, xctx->nl_xx2, xctx->nl_yy2, xctx->nl_sel); else select_touch(xctx->nl_xx1, xctx->nl_yy1, xctx->nl_xx2, xctx->nl_yy2, xctx->nl_sel); - /* } */ + } xctx->nl_xx1=xctx->nl_xr;xctx->nl_xx2=xctx->nl_xr2;xctx->nl_yy1=xctx->nl_yr;xctx->nl_yy2=xctx->nl_yr2; RECTORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); drawtemprect(xctx->gc[SELLAYER],NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); diff --git a/src/callback.c b/src/callback.c index a04135bb..17d145a1 100644 --- a/src/callback.c +++ b/src/callback.c @@ -512,13 +512,28 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int /* parameters for absolute positioning by mouse drag in bottom graph area */ if( event == MotionNotify && (state & Button1Mask) && xctx->graph_bottom ) { - int idx = get_raw_index(find_nth(get_tok_value(r->prop_ptr, "sweep", 0), ", ", "\"", 0, 1)); - int dset = dataset == -1 ? 0 : dataset; + int idx; + int dset; double wwx1, wwx2, pp, delta, ccx, ddx; + + char *rawfile = NULL; + char *sim_type = NULL; + int switched = 0; + + my_strdup2(_ALLOC_ID_, &rawfile, get_tok_value(r->prop_ptr, "rawfile", 0)); + my_strdup2(_ALLOC_ID_, &sim_type, get_tok_value(r->prop_ptr, "sim_type", 0)); + switched = extra_rawfile(2, rawfile, sim_type); + my_free(_ALLOC_ID_, &rawfile); + my_free(_ALLOC_ID_, &sim_type); + + idx = get_raw_index(find_nth(get_tok_value(r->prop_ptr, "sweep", 0), ", ", "\"", 0, 1)); + dset = dataset == -1 ? 0 : dataset; + if(idx < 0 ) idx = 0; delta = gr->gw; wwx1 = get_raw_value(dset, idx, 0); wwx2 = get_raw_value(dset, idx, xctx->raw->npoints[dset] - 1); + if(wwx1 == wwx2) wwx2 += 1e-6; if(gr->logx) { wwx1 = mylog10(wwx1); wwx2 = mylog10(wwx2); @@ -528,6 +543,9 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int pp = (xctx->mousex_snap - ddx) / ccx; xx1 = pp - delta / 2.0; xx2 = pp + delta / 2.0; + + if(switched) extra_rawfile(5, NULL, NULL); /* switch back to previous raw file */ + } else if(button == Button3 && (xctx->ui_state & GRAPHPAN) && !xctx->graph_left && !xctx->graph_top) { /* parameters for zoom area by mouse drag */ @@ -547,7 +565,7 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int for(i=0; i< xctx->rects[GRIDLAYER]; ++i) { r = &xctx->rect[GRIDLAYER][i]; need_redraw = 0; - if( !(r->flags & 1) ) continue; + if( !(r->flags & 1) ) continue; /* 1: graph; 3: graph_unlocked */ gr->gx1 = gr->master_gx1; gr->gx2 = gr->master_gx2; gr->gw = gr->master_gw; diff --git a/src/xschem.tcl b/src/xschem.tcl index 89be388a..a7de202e 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -4954,8 +4954,8 @@ proc alert_ {txtlabel {position +200+300} {nowait {0}} {yesno 0}} { } else { wm geometry .alert "+$X+$Y" } - label .alert.l1 -font {Sans 12 bold} \ - -text " \n ${txtlabel} \n" -wraplength 700 + label .alert.l1 -font {Sans 10 bold} \ + -text " \n ${txtlabel} \n" -wraplength 750 if { $yesno} { set oktxt Yes } else { @@ -7714,6 +7714,12 @@ set_ne incr_hilight 1 set_ne enable_stretch 0 set_ne constrained_move 0 set_ne unselect_partial_sel_wires 0 + +# if set show selected elements while dragging the selection rectangle. +# once selected these can not be unselected by retracting the selection rectangle +# if not set show selected items at end of drag. +set_ne incremental_select 1 + set_ne draw_crosshair 0 set_ne draw_grid 1 set_ne big_grid_points 0 diff --git a/src/xschemrc b/src/xschemrc index f85015ce..e6384519 100644 --- a/src/xschemrc +++ b/src/xschemrc @@ -182,6 +182,11 @@ #### default: not enabled (0) # set unselect_partial_sel_wires 0 +#### if set show selected elements while dragging the selection rectangle. +#### once selected these can not be unselected by retracting the selection rectangle +#### if not set show selected items at end of drag. Default: enabled (1) +# set_ne incremental_select 0 + #### if set to 1 automatically join/trim wires while editing #### this may slow down on rally big designs. Can be disabled via menu #### default: 0 diff --git a/xschem_library/examples/cmos_example.sch b/xschem_library/examples/cmos_example.sch index b5075dfd..12788e99 100644 --- a/xschem_library/examples/cmos_example.sch +++ b/xschem_library/examples/cmos_example.sch @@ -94,8 +94,8 @@ y1=-53 y2=43 subdivy=1 -x1=0.295931 -x2=9.29594 +x1=0 +x2=9 divx=6 subdivx=8 @@ -118,8 +118,8 @@ y1=37 y2=180 divy=4 subdivy=1 -x1=0.295931 -x2=9.29594 +x1=0 +x2=9 divx=6 subdivx=8