From 12a93c9fe6c85ecc0697ca63517d2eaaf872b684 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Mon, 21 Feb 2022 20:19:56 +0100 Subject: [PATCH] Update to plotting of event nodes: Distance is now 1.5, scaling and cutouts are possible (with some lack of precision). Still missing: y axis labeling (no numbers, but node names). --- src/frontend/plotting/plotit.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/frontend/plotting/plotit.c b/src/frontend/plotting/plotit.c index 6b919f841..44b9e9551 100644 --- a/src/frontend/plotting/plotit.c +++ b/src/frontend/plotting/plotit.c @@ -852,13 +852,13 @@ bool plotit(wordlist *wl, const char *hcopy, const char *devname) } } - /* Add n * 1.1 to digital event node based vectors */ + /* Add n * spacing (e.g. 1.3) to digital event node based vectors */ if (digitop) { - double spacing = 1.0999999; /* numerical precision: stay below (rounded) ymax */ + double spacing = 1.5; double nn = 0.; int ii = 0; for (d = vecs; d; d = d->v_link2) { - if (d->v_scale && eq(d->v_scale->v_name, "step") && (d->v_scale->v_type == SV_TIME) && (d->v_type == SV_VOLTAGE)) { + if (d->v_scale && eq(d->v_scale->v_name, "step") && (d->v_scale->v_type == SV_TIME) && (d->v_type == SV_VOLTAGE) && (d->v_length > 1)) { for (ii = 0; ii < d->v_length; ii++) { d->v_realdata[ii] += nn; } @@ -868,10 +868,20 @@ bool plotit(wordlist *wl, const char *hcopy, const char *devname) if (!ydelta) ydelta = TMALLOC(double, 1); *ydelta = spacing; - if (!ylim) + if (!ylim) { ylim = TMALLOC(double, 2); - ylim[0] = 0; - ylim[1] = nn; + ylim[0] = 0; + ylim[1] = nn; + } + else { + if (ylim[0] < 1.5) + /* catch the bottom line */ + ylim[0] = 0; + else + /* If we redraw, set again multiples of 'spacing' */ + ylim[0] = ((int)(ylim[0] / spacing) + 1) * spacing; + ylim[1] = ((int)(ylim[1] / spacing) + 1) * spacing; + } } /* If there are higher dimensional vectors, transform them into a