From: drowe67 Date: Fri, 23 Nov 2012 23:04:43 +0000 (+0000) Subject: automatic scaling of scatter diagram, quite nice to watch X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=fb3d9657e9c33ac7198f2f679eb848622d37a234;p=freetel-svn-tracking.git automatic scaling of scatter diagram, quite nice to watch git-svn-id: https://svn.code.sf.net/p/freetel/code@1055 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/fdmdv2/src/fdmdv2_defines.h b/fdmdv2/src/fdmdv2_defines.h index 616d3855..6883f7d7 100644 --- a/fdmdv2/src/fdmdv2_defines.h +++ b/fdmdv2/src/fdmdv2_defines.h @@ -44,8 +44,6 @@ // (symbols/frame)/(graphics update period) = symbols/s sent to scatter memory // memory (symbols) = secs of memory * symbols/sec #define SCATTER_MEM_SYMS ((int)(SCATTER_MEM_SECS*(FDMDV_NSYM/DT))) -#define SCATTER_X_MAX 4.0 -#define SCATTER_Y_MAX 4.0 // Waveform plotting constants diff --git a/fdmdv2/src/fdmdv2_plot_scatter.cpp b/fdmdv2/src/fdmdv2_plot_scatter.cpp index c194365f..d41b2790 100644 --- a/fdmdv2/src/fdmdv2_plot_scatter.cpp +++ b/fdmdv2/src/fdmdv2_plot_scatter.cpp @@ -45,6 +45,8 @@ PlotScatter::PlotScatter(wxFrame* parent) : PlotPanel(parent) m_mem[i].real = 0.0; m_mem[i].imag = 0.0; } + + m_filter_max_xy = 0.1; } //---------------------------------------------------------------- @@ -70,9 +72,7 @@ void PlotScatter::draw(wxAutoBufferedPaintDC& dc) dc.SetBrush(ltGraphBkgBrush); dc.SetPen(wxPen(BLACK_COLOR, 0)); dc.DrawRectangle(m_rPlot); - x_scale = (float)m_rGrid.GetWidth()/SCATTER_X_MAX; - y_scale = (float)m_rGrid.GetHeight()/SCATTER_Y_MAX; - + wxPen pen; pen.SetColour(LIGHT_GREEN_COLOR); pen.SetWidth(1); @@ -92,6 +92,26 @@ void PlotScatter::draw(wxAutoBufferedPaintDC& dc) m_mem[i] = m_new_samples[j]; } + // automatically scale + + float max_xy = 1E-12; + float real,imag; + for(i=0; i< SCATTER_MEM_SYMS; i++) { + real = fabs(m_mem[i].real); + imag = fabs(m_mem[i].imag); + if (real > max_xy) + max_xy = real; + if (imag > max_xy) + max_xy = imag; + } + m_filter_max_xy = BETA*m_filter_max_xy + (1 - BETA)*2.5*max_xy; + if (m_filter_max_xy < 0.1) + m_filter_max_xy = 0.1; + //printf("max_xy: %f m_filter_max_xy: %f\n", max_xy, m_filter_max_xy); + + x_scale = (float)m_rGrid.GetWidth()/m_filter_max_xy; + y_scale = (float)m_rGrid.GetHeight()/m_filter_max_xy; + // draw all samples for(i = 0; i < SCATTER_MEM_SYMS; i++) diff --git a/fdmdv2/src/fdmdv2_plot_scatter.h b/fdmdv2/src/fdmdv2_plot_scatter.h index 86bc54b6..f33d3afe 100644 --- a/fdmdv2/src/fdmdv2_plot_scatter.h +++ b/fdmdv2/src/fdmdv2_plot_scatter.h @@ -45,6 +45,9 @@ class PlotScatter : public PlotPanel void OnShow(wxShowEvent& event); DECLARE_EVENT_TABLE() + + private: + float m_filter_max_xy; }; #endif //__FDMDV2_PLOT_SCATTER__