From 75543a242a4aaad87dfa509701965fc2d1afe226 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Wed, 20 Jun 2012 06:32:42 +0000 Subject: [PATCH] resizing waterfall doesn't deg fault any more git-svn-id: https://svn.code.sf.net/p/freetel/code@573 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/fltk/fl_fdmdv.cxx | 50 +++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/codec2-dev/fltk/fl_fdmdv.cxx b/codec2-dev/fltk/fl_fdmdv.cxx index 5af89b14..de88d244 100644 --- a/codec2-dev/fltk/fl_fdmdv.cxx +++ b/codec2-dev/fltk/fl_fdmdv.cxx @@ -109,7 +109,7 @@ protected: } public: - Spectrum(int x, int y, int h, int w): Fl_Box(x,y,h,w, "Spectrum") + Spectrum(int x, int y, int w, int h): Fl_Box(x, y, w, h, "Spectrum") { align(FL_ALIGN_TOP); labelsize(10); @@ -118,14 +118,6 @@ public: }; -// question: how to map block sizes to pixels? -// need to handle: FDMDV_NSPEC across x, even when FDMDV_NSPEC < w(), -// could use axis as min of w(), FDMDV_NSPEC? -// set height of blocks based on update rate, number of seconds to display? -// do we take a snapshot every x mseconds of plot average? -// maybe just take a first pass -// draw graticule or axis - /* Notes: @@ -141,14 +133,31 @@ public: class Waterfall: public Fl_Box { protected: - uchar *pixel_buf; + int prev_w, prev_h; + unsigned *pixel_buf; + + void new_pixel_buf(int w, int h) { + int buf_sz, i; + + prev_w = w; prev_h = h; + buf_sz = h*w; + pixel_buf = new unsigned[buf_sz]; + for(i=0; i %d %d\n", w(), h(), prev_w, prev_h); + delete pixel_buf; + new_pixel_buf(w(), h()); + } Fl_Box::draw(); @@ -163,7 +172,7 @@ protected: // shift previous bit map - bytes_in_row_of_blocks = dy*w()*sizeof(uchar); + bytes_in_row_of_blocks = dy*w()*sizeof(unsigned); for(b=0; b