Date:2011-04-14 00:08:23 (8 years 2 months ago)
Author:Werner Almesberger
Commit:f32f48ae2673b799878a831ba9e216b26177505a
Message:atrf-path: visualize the limits in GUI mode

- gui.c (avg2y, segment): moved mapping from measurement to y position
to separate function, to allow for sharing
- gui.c (LIMIT_RGBA, draw_limit, gui): draw the limits
Files: tools/atrf-path/gui.c (4 diffs)

Change Details

tools/atrf-path/gui.c
3333#define OK_RGBA 0x00ff00ff
3434#define OVER_RGBA 0xffff00ff
3535#define UNDER_RGBA 0xff0000ff
36#define LIMIT_RGBA 0xff0000ff
3637
3738#define CHAN_STEP 20 /* 4 pixels/MHz */
3839#define SIDE_STEP 2
...... 
4546#define STATUS_R 8
4647
4748
49static int avg2y(double avg)
50{
51    return YRES-(avg-Y_MIN)/(Y_MAX-Y_MIN)*YRES-1;
52}
53
54
4855static void segment(SDL_Surface *s, int *last_x, int *last_y, int x,
4956    const struct sample *res, int first)
5057{
51    int y = YRES-(res->avg-Y_MIN)/(Y_MAX-Y_MIN)*YRES-1;
58    int y = avg2y(res->avg);
5259
5360    if (!first) {
5461        aalineColor(s, *last_x, *last_y, x, y, FG_RGBA);
...... 
8390}
8491
8592
93static void draw_limit(SDL_Surface *s, const double *v)
94{
95    int x, y, i, last = 0;
96
97    x = CHAN_X_OFFSET;
98    for (i = 0; i != N_CHAN; i++) {
99        y = avg2y(*v);
100        if (i)
101            vlineColor(s, x-CHAN_STEP/2, last, y, LIMIT_RGBA);
102        hlineColor(s, x-CHAN_STEP/2, x+CHAN_STEP/2, y, LIMIT_RGBA);
103        last = y;
104        x += CHAN_STEP;
105        v++;
106    }
107}
108
109
86110static void indicate(SDL_Surface *s, int fail)
87111{
88112    static uint32_t last = 0;
...... 
179203
180204        clear(surf);
181205
206        draw_limit(surf, sweep->min);
207        draw_limit(surf, sweep->max);
182208        indicate(surf, fail);
183209        draw(surf, res, sweep->cont_tx);
184210

Archive Download the corresponding diff file



interactive