From: wittend99 Date: Fri, 23 Nov 2012 16:01:05 +0000 (+0000) Subject: git-svn-id: https://svn.code.sf.net/p/freetel/code@1050 01035d8c-6547-0410-b346-abe4f... X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=eb56ae4bb99eade7176f47738e7af8302b100efa;p=freetel-svn-tracking.git git-svn-id: https://svn.code.sf.net/p/freetel/code@1050 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/fdmdv2/src/fdmdv2_plot_waterfall_linux.cpp b/fdmdv2/src/fdmdv2_plot_waterfall_linux.cpp index 08ecc4c4..da8135c0 100644 --- a/fdmdv2/src/fdmdv2_plot_waterfall_linux.cpp +++ b/fdmdv2/src/fdmdv2_plot_waterfall_linux.cpp @@ -7,14 +7,14 @@ // License: // // This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License version 2.1, +// it under the terms of the GNU General Public License version 2.1, // as published by the Free Software Foundation. This program is // distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public // License for more details. // -// You should have received a copy of the GNU Lesser General Public License +// You should have received a copy of the GNU General Public License // along with this program; if not, see . // //========================================================================== @@ -64,8 +64,8 @@ PlotWaterfall::PlotWaterfall(wxFrame* parent): PlotPanel(parent) // When the window size gets set we can work outthe size of the window // we plot in and allocate a bit map of the correct size - -void PlotWaterfall::OnSize(wxSizeEvent& event) { +void PlotWaterfall::OnSize(wxSizeEvent& event) +{ // resize bit map delete m_pBmp; @@ -165,10 +165,10 @@ void PlotWaterfall::draw(wxAutoBufferedPaintDC& dc) m_rGrid = m_rCtrl; m_rGrid = m_rGrid.Deflate(PLOT_BORDER + (XLEFT_OFFSET/2), (PLOT_BORDER + (YBOTTOM_OFFSET/2))); - if (m_pBmp == NULL) { - // we want a bit map the size of m_rGrid - - m_pBmp = new wxBitmap(m_rGrid.GetWidth(), m_rGrid.GetHeight(), 24); + if (m_pBmp == NULL) + { + // we want a bit map the size of m_rGrid + m_pBmp = new wxBitmap(m_rGrid.GetWidth(), m_rGrid.GetHeight(), 24); } dc.Clear(); @@ -177,28 +177,26 @@ void PlotWaterfall::draw(wxAutoBufferedPaintDC& dc) { m_newdata = false; plotPixelData(); - dc.DrawBitmap(*m_pBmp, PLOT_BORDER + XLEFT_OFFSET, PLOT_BORDER); + dc.DrawBitmap(*m_pBmp, PLOT_BORDER + XLEFT_OFFSET, PLOT_BORDER); } - else { - - // no data to plot so just erase to black. Blue looks nicer - // but is same colour as low amplitude signal - - // Bug on Linux: When Stop is pressed this code doesn't erase - // the lower 25% of the Waterfall Window - - m_rPlot = wxRect(PLOT_BORDER + XLEFT_OFFSET, PLOT_BORDER, m_rGrid.GetWidth(), m_rGrid.GetHeight()); - wxBrush ltGraphBkgBrush = wxBrush(BLACK_COLOR); - dc.SetBrush(ltGraphBkgBrush); - dc.SetPen(wxPen(BLACK_COLOR, 0)); - dc.DrawRectangle(m_rPlot); + else + { + + // no data to plot so just erase to black. Blue looks nicer + // but is same colour as low amplitude signal + + // Bug on Linux: When Stop is pressed this code doesn't erase + // the lower 25% of the Waterfall Window + + m_rPlot = wxRect(PLOT_BORDER + XLEFT_OFFSET, PLOT_BORDER, m_rGrid.GetWidth(), m_rGrid.GetHeight()); + wxBrush ltGraphBkgBrush = wxBrush(BLACK_COLOR); + dc.SetBrush(ltGraphBkgBrush); + dc.SetPen(wxPen(BLACK_COLOR, 0)); + dc.DrawRectangle(m_rPlot); } - drawGraticule(dc); - } - //------------------------------------------------------------------------- // drawGraticule() //------------------------------------------------------------------------- @@ -221,21 +219,19 @@ void PlotWaterfall::drawGraticule(wxAutoBufferedPaintDC& dc) // upper LH coords of plot area are (PLOT_BORDER + XLEFT_OFFSET, PLOT_BORDER) // lower RH coords of plot area are (PLOT_BORDER + XLEFT_OFFSET + m_rGrid.GetWidth(), // PLOT_BORDER + m_rGrid.GetHeight()) - // Vertical gridlines - dc.SetPen(m_penShortDash); - for(f=STEP_F_HZ; f 255) intensity = 255; - if (intensity < 0) intensity = 0; - //printf("%d %f %d \n", index, g_avmag[index], intensity); - - p.Red() = m_heatmap_lut[intensity] & 0xff; - p.Green() = (m_heatmap_lut[intensity] >> 8) & 0xff; - p.Blue() = (m_heatmap_lut[intensity] >> 16) & 0xff; - ++p; + index = px * spec_index_per_px; + assert(index < FDMDV_NSPEC); + + intensity = intensity_per_dB * (g_avmag[index] - MIN_MAG_DB); + if(intensity > 255) intensity = 255; + if (intensity < 0) intensity = 0; + //printf("%d %f %d \n", index, g_avmag[index], intensity); + + p.Red() = m_heatmap_lut[intensity] & 0xff; + p.Green() = (m_heatmap_lut[intensity] >> 8) & 0xff; + p.Blue() = (m_heatmap_lut[intensity] >> 16) & 0xff; + ++p; } - - p = rowStart; - p.OffsetY(data, 1); + p = rowStart; + p.OffsetY(data, 1); } } @@ -372,7 +366,8 @@ void PlotWaterfall::OnMouseDown(wxMouseEvent& event) pt.y -= PLOT_BORDER; // valid click if inside of plot - if ((pt.x >= 0) && (pt.x <= m_rGrid.GetWidth()) && (pt.y >=0) && (pt.y < m_rGrid.GetHeight())) { + if ((pt.x >= 0) && (pt.x <= m_rGrid.GetWidth()) && (pt.y >=0) && (pt.y < m_rGrid.GetHeight())) + { float freq_hz_to_px = (float)m_rGrid.GetWidth()/(MAX_F_HZ-MIN_F_HZ); float clickFreq = (float)pt.x/freq_hz_to_px;