From 20cbc5daf1cd1c08f9e3f1dcbaf6462585b045b3 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Mon, 25 Jun 2012 10:26:31 +0000 Subject: [PATCH] first pass at scatter diagram, works OK git-svn-id: https://svn.code.sf.net/p/freetel/code@577 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/fltk/fl_fdmdv.cxx | 121 ++++++++++++++++++++++++++++++++--- 1 file changed, 113 insertions(+), 8 deletions(-) diff --git a/codec2-dev/fltk/fl_fdmdv.cxx b/codec2-dev/fltk/fl_fdmdv.cxx index 12fa2fb2..bfd8c4a4 100644 --- a/codec2-dev/fltk/fl_fdmdv.cxx +++ b/codec2-dev/fltk/fl_fdmdv.cxx @@ -24,11 +24,15 @@ #define MIN_HZ 0 #define MAX_HZ 4000 #define WATERFALL_SECS_Y 5 // number of seconds respresented by y axis of waterfall -#define DT 0.1 // time between samples +#define DT 0.02 // time between samples #define FS 8000 -#define W 800 -#define W2 (W/2) +#define SCATTER_MEM (FDMDV_NSYM)*50 +#define SCATTER_X_MAX 3.0 +#define SCATTER_Y_MAX 3.0 + +#define W 1200 +#define W3 (W/3) #define H 600 #define H2 (H/2) #define SP 20 @@ -36,6 +40,7 @@ class Spectrum; class Waterfall; +class Scatter; char *fin_name = NULL; FILE *fin = NULL; @@ -44,6 +49,7 @@ Fl_Group *agroup; Fl_Window *window; Spectrum *aSpectrum; Waterfall *aWaterfall; +Scatter *aScatter; float av_mag[FDMDV_NSPEC]; // shared between a few classes @@ -269,6 +275,86 @@ public: }; +class Scatter: public Fl_Box { +protected: + int first; + COMP mem[SCATTER_MEM]; + COMP new_samples[FDMDV_NSYM]; + int prev_w, prev_h; + + void draw() { + float x_scale; + float y_scale; + int i, j, x1, y1; + + Fl_Box::draw(); + + /* detect resizing of window */ + + if ((h() != prev_h) || (w() != prev_w)) { + fl_color(FL_BLACK); + fl_rectf(x(),y(),w(),h()); + prev_h = h(); prev_w = w(); + } + + fl_push_clip(x(),y(),w(),h()); + + x_scale = w()/SCATTER_X_MAX; + y_scale = h()/SCATTER_Y_MAX; + + // erase last samples + + fl_color(FL_BLACK); + for(i=0; iadd_new_samples(stats.rx_symbols); + + // update plots every DT + if (Ts >= DT) { Ts -= DT; aSpectrum->redraw(); aWaterfall->redraw(); + aScatter->redraw(); } } usleep(20000); @@ -343,8 +447,9 @@ int main(int argc, char **argv) { window = new Fl_Window(W, SP+H2+SP+SP+H2+SP, "fl_fmdv"); window->size_range(100, 100); window->resizable(); - aSpectrum = new Spectrum(SP, SP, W-2*SP, H2); - aWaterfall = new Waterfall(SP, SP+H2+SP+SP, W-2*SP, H2); + aSpectrum = new Spectrum(SP, SP, 2*W3-2*SP, H2); + aWaterfall = new Waterfall(SP, SP+H2+SP+SP, 2*W3-2*SP, H2); + aScatter = new Scatter(2*W3, SP, W3, H2); fdmdv = fdmdv_create(); Fl::add_idle(idle); -- 2.25.1