From c06034e33e04055f6ec8a0ce3f8d8e2717875ac5 Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Sun, 18 Sep 2022 11:06:48 +0200 Subject: [PATCH] performance optimization in live cursor b backannotation --- src/callback.c | 37 ++++++++++++++++++++----------------- src/draw.c | 12 +++++++----- src/xschemrc | 4 ++-- 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/src/callback.c b/src/callback.c index d11460d3..305439e6 100644 --- a/src/callback.c +++ b/src/callback.c @@ -219,11 +219,8 @@ static void backannotate_at_cursor_b_pos(xRect *r) tclvareval("set ngspice::ngspice_data(n\\ vars) ", my_itoa( xctx->graph_nvars), NULL); tclvareval("set ngspice::ngspice_data(n\\ points) 1", NULL); - - draw(); - - /* draw only probes. does not work as multiple texts will be overlayed */ + /* need to draw a background under texts */ #if 0 save = xctx->draw_window; xctx->draw_window = 1; @@ -252,14 +249,6 @@ static void backannotate_at_cursor_b_pos(xRect *r) } xctx->draw_window = save; #endif - - - - - - - - } } @@ -278,7 +267,7 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int { Graph_ctx *gr; const char *val; - int i, need_all_redraw = 0, need_redraw = 0, dataset = 0; + int i, redraw_all_at_end = 0, need_all_redraw = 0, need_redraw = 0, dataset = 0; double xx1, xx2, yy1, yy2; double delta_threshold = 0.25; double zoom_m = 0.5; @@ -347,6 +336,7 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int /* backannotate node values at cursor b position */ else if(key == 'a' && state == Mod1Mask && (xctx->graph_flags & 4)) { backannotate_at_cursor_b_pos(r); + redraw_all_at_end = 1; } /* x cursor1 toggle */ else if((key == 'a' && state == 0) ) { @@ -357,10 +347,17 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int /* x cursor2 toggle */ else if((key == 'b') ) { xctx->graph_flags ^= 4; - need_all_redraw = 1; if(xctx->graph_flags & 4) { xctx->graph_cursor2_x = G_X(xctx->mousex); - if(tclgetboolvar("live_cursor2_backannotate")) backannotate_at_cursor_b_pos(r); + if(tclgetboolvar("live_cursor2_backannotate")) { + backannotate_at_cursor_b_pos(r); + redraw_all_at_end = 1; + } else { + need_all_redraw = 1; + } + + } else { + need_all_redraw = 1; } } /* measurement tooltip */ @@ -508,7 +505,10 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int } /* move cursor2 */ else if(event == MotionNotify && (state & Button1Mask) && (xctx->graph_flags & 32 )) { - if(tclgetboolvar("live_cursor2_backannotate")) backannotate_at_cursor_b_pos(r); + if(tclgetboolvar("live_cursor2_backannotate")) { + backannotate_at_cursor_b_pos(r); + redraw_all_at_end = 1; + } else need_redraw = 1; } else /* drag waves with mouse */ @@ -960,7 +960,10 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int } } /* for(i=0; i< xctx->rects[GRIDLAYER]; i++ */ - + if(redraw_all_at_end ==1) { + draw(); + redraw_all_at_end = 0; + } if(clear_graphpan_at_end) xctx->ui_state &= ~GRAPHPAN; /* update saved mouse position after processing all graphs */ if(save_mouse_at_end && diff --git a/src/draw.c b/src/draw.c index 8d42de28..22d63374 100644 --- a/src/draw.c +++ b/src/draw.c @@ -2672,11 +2672,13 @@ void draw_graph(int i, const int flags, Graph_ctx *gr) if(RECT_OUTSIDE( gr->sx1, gr->sy1, gr->sx2, gr->sy2, xctx->areax1, xctx->areay1, xctx->areax2, xctx->areay2)) return; - /* - * dbg(0, "draw_graph(): window: %d %d %d %d\n", xctx->areax1, xctx->areay1, xctx->areax2, xctx->areay2); - * dbg(0, "draw_graph(): graph: %g %g %g %g\n", gr->sx1, gr->sy1, gr->sx2, gr->sy2); - * dbg(0, "draw_graph(): i = %d, flags = %d\n", i, flags); - */ + + #if 0 + dbg(0, "draw_graph(): window: %d %d %d %d\n", xctx->areax1, xctx->areay1, xctx->areax2, xctx->areay2); + dbg(0, "draw_graph(): graph: %g %g %g %g\n", gr->sx1, gr->sy1, gr->sx2, gr->sy2); + dbg(0, "draw_graph(): i = %d, flags = %d\n", i, flags); + #endif + /* draw stuff */ if(flags & 8) { #if !defined(__unix__) && defined(HAS_CAIRO) diff --git a/src/xschemrc b/src/xschemrc index d837fb3e..b9757e7a 100644 --- a/src/xschemrc +++ b/src/xschemrc @@ -374,8 +374,8 @@ # set hide_empty_graphs 0 ########################################################################### -#### SHOW HIDDEN TEXTS +#### LIVE BACKANNOTATION OF DATA AT CURSOR 2 (B) POSITION ########################################################################### ## if enabled will backannotate values in schematic at cursor 'b' position -## in graph. Default: not enabled (0) +## in graph. Default: not enabled (0) # set live_cursor2_backannotate 1