git-svn-id: https://svn.code.sf.net/p/freetel/code@645 01035d8c-6547-0410-b346-abe4f9...
authorwittend99 <wittend99@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 29 Aug 2012 03:50:53 +0000 (03:50 +0000)
committerwittend99 <wittend99@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 29 Aug 2012 03:50:53 +0000 (03:50 +0000)
21 files changed:
fdmdv2/build/Debug/fdmdv2.exe
fdmdv2/build/Release/fdmdv2.exe
fdmdv2/build/fdmdv2.mk
fdmdv2/build/fdmdv2.txt
fdmdv2/build/fdmdv2.workspace
fdmdv2/build/fdmdv2_wsp.mk
fdmdv2/src/fdmdv2_defines.h [new file with mode: 0644]
fdmdv2/src/fdmdv2_main.cpp
fdmdv2/src/fdmdv2_main.h
fdmdv2/src/fdmdv2_plot.cpp
fdmdv2/src/fdmdv2_plot.h
fdmdv2/src/fdmdv2_plot_scalar.cpp [new file with mode: 0644]
fdmdv2/src/fdmdv2_plot_scalar.h [new file with mode: 0644]
fdmdv2/src/fdmdv2_plot_scatter.cpp
fdmdv2/src/fdmdv2_plot_scatter.h
fdmdv2/src/fdmdv2_plot_spectrum.cpp
fdmdv2/src/fdmdv2_plot_spectrum.h
fdmdv2/src/fdmdv2_plot_waterfall.cpp
fdmdv2/src/fdmdv2_plot_waterfall.h
fdmdv2/src/fdmdv2_scalar.cpp [deleted file]
fdmdv2/src/fdmdv2_scalar.h [deleted file]

index 789f00a375d6bb8027eefafc07a990bc5b93b6ff..7163699e4a3ee0d7ac8eb981b34b2fc788331ca7 100644 (file)
Binary files a/fdmdv2/build/Debug/fdmdv2.exe and b/fdmdv2/build/Debug/fdmdv2.exe differ
index c4be3ae8a97ad6a54783bcdfbea39fb76f3c84fc..adb293405bc18b6b2f0735094b80b24a7fb4d7fe 100644 (file)
Binary files a/fdmdv2/build/Release/fdmdv2.exe and b/fdmdv2/build/Release/fdmdv2.exe differ
index 0eb5eff861a93105e5926e9c2fde5b780addb159..4027dc43b642ef3a7323c8ae27957a981fb2a867 100644 (file)
@@ -2,10 +2,10 @@
 ## Auto Generated makefile by CodeLite IDE\r
 ## any manual changes will be erased      \r
 ##\r
-## Release\r
+## Debug\r
 ProjectName            :=fdmdv2\r
-ConfigurationName      :=Release\r
-IntermediateDirectory  :=./Release\r
+ConfigurationName      :=Debug\r
+IntermediateDirectory  :=./Debug\r
 OutDir                 := $(IntermediateDirectory)\r
 WorkspacePath          := "C:\bin\Projects\Radio\fdmdv2\build"\r
 ProjectPath            := "C:\bin\Projects\Radio\fdmdv2\build"\r
@@ -13,7 +13,7 @@ CurrentFileName        :=
 CurrentFilePath        :=\r
 CurrentFileFullPath    :=\r
 User                   :=OFA-Staff\r
-Date                   :=8/27/2012\r
+Date                   :=8/28/2012\r
 CodeLitePath           :="C:\bin\CodeLite"\r
 LinkerName             :=g++\r
 ArchiveTool            :=ar rcus\r
@@ -38,9 +38,9 @@ PreprocessOnlySwitch   :=-E
 ObjectsFileList        :="C:\bin\Projects\Radio\fdmdv2\build\fdmdv2.txt"\r
 PCHCompileFlags        :=\r
 MakeDirCommand         :=makedir\r
-CmpOptions             := -O2 -Wall $(shell wx-config --cxxflags --unicode=yes --debug=no) $(Preprocessors)\r
-C_CmpOptions           := -O2 -Wall $(shell wx-config --cxxflags --unicode=yes --debug=no) $(Preprocessors)\r
-LinkOptions            :=  -mwindows -s $(shell wx-config --debug=no --libs --unicode=yes)\r
+CmpOptions             := -g -O0 -Wall $(shell wx-config --cxxflags --unicode=yes --debug=yes)  -DSVN_REVISION=\"631\"  $(Preprocessors)\r
+C_CmpOptions           := -g -O0 -Wall $(shell wx-config --cxxflags --unicode=yes --debug=yes)  -DSVN_REVISION=\"631\"  $(Preprocessors)\r
+LinkOptions            :=  -mwindows $(shell wx-config --debug=yes --libs --unicode=yes)\r
 IncludePath            :=  $(IncludeSwitch). $(IncludeSwitch)/bin/MinGW/msys/1.0/local/include $(IncludeSwitch)../../codec2-dev/src $(IncludeSwitch)../3rdparty/portaudio/include $(IncludeSwitch)../3rdparty/portaudio/bindings/cpp/include $(IncludeSwitch)../3rdparty/libsndfile/include $(IncludeSwitch)../3rdparty/libsamplerate-0.1.8/src \r
 IncludePCH             := \r
 RcIncludePath          := \r
@@ -72,7 +72,7 @@ $(OutputFile): $(IntermediateDirectory)/.d $(Objects)
        $(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(LibPath) $(Libs) $(LinkOptions)\r
 \r
 $(IntermediateDirectory)/.d:\r
-       @$(MakeDirCommand) "./Release"\r
+       @$(MakeDirCommand) "./Debug"\r
 \r
 PreBuild:\r
 \r
@@ -231,6 +231,6 @@ clean:
        $(RM) $(IntermediateDirectory)/src_fdmdv2_plot_scalar$(PreprocessSuffix)\r
        $(RM) $(OutputFile)\r
        $(RM) $(OutputFile).exe\r
-       $(RM) "C:\bin\Projects\Radio\fdmdv2\build\.build-release\fdmdv2"\r
+       $(RM) "C:\bin\Projects\Radio\fdmdv2\build\.build-debug\fdmdv2"\r
 \r
 \r
index b569c15b798141ee488fb46ef8d8b8361ace21f9..21368bcd97b991574117f2a16b47de0695121fb9 100644 (file)
@@ -1 +1 @@
-./Release/src_dlg_about.o ./Release/src_dlg_audio.o ./Release/src_dlg_comports.o ./Release/src_dlg_options.o ./Release/src_fdmdv2_main.o ./Release/src_fdmdv2_plot.o ./Release/src_topFrame.o ./Release/src_fdmdv2_plot_scatter.o ./Release/src_fdmdv2_plot_waterfall.o ./Release/src_fdmdv2_plot_spectrum.o ./Release/src_fdmdv2_pa_wrapper.o ./Release/src_fdmdv2_process_audio.o ./Release/src_fdmdv2_plot_scalar.o  \r
+./Debug/src_dlg_about.o ./Debug/src_dlg_audio.o ./Debug/src_dlg_comports.o ./Debug/src_dlg_options.o ./Debug/src_fdmdv2_main.o ./Debug/src_fdmdv2_plot.o ./Debug/src_topFrame.o ./Debug/src_fdmdv2_plot_scatter.o ./Debug/src_fdmdv2_plot_waterfall.o ./Debug/src_fdmdv2_plot_spectrum.o ./Debug/src_fdmdv2_pa_wrapper.o ./Debug/src_fdmdv2_process_audio.o ./Debug/src_fdmdv2_plot_scalar.o  \r
index e70810b801e060539f670db61ee629a8c121aefb..5fb58e851396f4345a11f46ddc7cf4880585ee5b 100644 (file)
@@ -2,10 +2,10 @@
 <CodeLite_Workspace Name="fdmdv2" Database="./fdmdv2.tags">
   <Project Name="fdmdv2" Path="fdmdv2.project" Active="Yes"/>
   <BuildMatrix>
-    <WorkspaceConfiguration Name="Debug" Selected="no">
+    <WorkspaceConfiguration Name="Debug" Selected="yes">
       <Project Name="fdmdv2" ConfigName="Debug"/>
     </WorkspaceConfiguration>
-    <WorkspaceConfiguration Name="Release" Selected="yes">
+    <WorkspaceConfiguration Name="Release" Selected="no">
       <Project Name="fdmdv2" ConfigName="Release"/>
     </WorkspaceConfiguration>
   </BuildMatrix>
index 359a9f63279ae4b50622056b8e386244b86f8f85..dd8060fabdc87d30d9341dff1da066b246e31109 100644 (file)
@@ -1,8 +1,8 @@
 .PHONY: clean All
 
 All:
-       @echo ----------Building project:[ fdmdv2 - Release ]----------
+       @echo ----------Building project:[ fdmdv2 - Debug ]----------
        @"mingw32-make.exe"  -j 2 -f "fdmdv2.mk"
 clean:
-       @echo ----------Cleaning project:[ fdmdv2 - Release ]----------
+       @echo ----------Cleaning project:[ fdmdv2 - Debug ]----------
        @"mingw32-make.exe"  -j 2 -f "fdmdv2.mk" clean
diff --git a/fdmdv2/src/fdmdv2_defines.h b/fdmdv2/src/fdmdv2_defines.h
new file mode 100644 (file)
index 0000000..39c2365
--- /dev/null
@@ -0,0 +1,89 @@
+//==========================================================================\r
+// Name:            fdmdv2_defines.h\r
+// Purpose:         Definitions used by plots derived from fdmdv2_plot class.\r
+// Created:         August 27, 2012
+// Initial author:  David Witten\r
+// Derived from:    code written by David Rowe\r
+// License:\r
+//\r
+//  Copyright (C) 2012 David Witten
+//
+//  All rights reserved.
+//
+//  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,
+//  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
+//  along with this program; if not, see <http://www.gnu.org/licenses/>.
+//
+//==========================================================================\r
+#ifndef __FDMDV2_DEFINES__
+#define __FDMDV2_DEFINES__
+
+/* FFT points */
+#define FDMDV_NSPEC         512
+\r
+#define MIN_DB              -40.0
+#define MAX_DB              0.0
+#define BETA                0.1     // constant for time averageing spectrum data
+#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.02    // time between samples
+#define FS                  8000    // FDMDV modem sample rate
+
+#define FDMDV_BITS_PER_FRAME          28  /* 20ms frames, 1400 bit/s                                        */
+#define FDMDV_NOM_SAMPLES_PER_FRAME  160  /* modulator output samples/frame and nominal demod samples/frame */
+                                          /* at 8000 Hz sample rate                                         */
+#define FDMDV_MAX_SAMPLES_PER_FRAME  200  /* max demod samples/frame, use this to allocate storage          */
+#define FDMDV_SCALE                 1000  /* suggested scaling for 16 bit shorts                            */
+#define FDMDV_NSYM                    15
+
+#define MIN_DB              -40.0
+#define MAX_DB              0.0
+#define BETA                0.1  // constant for time averageing spectrum data
+#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.02 // time between samples
+#define FS                  8000    // FDMDV modem sample rate
+
+#define SCATTER_MEM         (FDMDV_NSYM)*50
+#define SCATTER_X_MAX       3.0
+#define SCATTER_Y_MAX       3.0
+
+// main window params
+#define W                   1200
+#define W3                  (W/3)
+#define H                   600
+#define H2                  (H/2)
+#define SP                  20
+
+// sound card
+#define SAMPLE_RATE         48000                          // 48 kHz sampling rate rec. as we can trust accuracy of sound card
+#define N8                  FDMDV_NOM_SAMPLES_PER_FRAME    // processing buffer size at 8 kHz
+#define MEM8                (FDMDV_OS_TAPS/FDMDV_OS)
+#define N48                 (N8*FDMDV_OS)                  // processing buffer size at 48 kHz
+#define NUM_CHANNELS        2                              // I think most sound cards prefer stereo we will convert to mono
+
+#define BITS_PER_CODEC_FRAME (2*FDMDV_BITS_PER_FRAME)
+#define BYTES_PER_CODEC_FRAME (BITS_PER_CODEC_FRAME/8)
+
+/* 8 to 48 kHz sample rate conversion */
+#define FDMDV_OS                 6         /* oversampling rate           */
+#define FDMDV_OS_TAPS           48         /* number of OS filter taps    */
+
+enum
+{
+    ID_ROTATE_LEFT = wxID_HIGHEST + 1,
+    ID_ROTATE_RIGHT,
+    ID_RESIZE,
+    ID_PAINT_BG
+};\r
+
+#endif  //__FDMDV2_DEFINES__
index 59a52e693e31cf1725fcc2a3e6c583ac1bbb0284..5aaeb07510b332e5132ade4d401e3e8e3962be8d 100644 (file)
@@ -64,11 +64,17 @@ bool MainApp::OnInit()
     // Create the main application window\r
     MainFrame *frame = new MainFrame(NULL);\r
 \r
-    frame->m_panelSpectrum = new PlotSpectrum((wxFrame*) frame->m_auiNbookCtrl );\r
-    frame->m_auiNbookCtrl->AddPage(frame->m_panelSpectrum, _("Spectrum"), true, wxNullBitmap );\r
+    frame->m_panelDefaultA = new PlotPanel((wxFrame*) frame->m_auiNbookCtrl );\r
+    frame->m_auiNbookCtrl->AddPage(frame->m_panelDefaultA, _("Spectrum"), true, wxNullBitmap );\r
 \r
-    frame->m_panelWaterfall = new PlotWaterfall((wxFrame*) frame->m_auiNbookCtrl );\r
-    frame->m_auiNbookCtrl->AddPage(frame->m_panelWaterfall, _("Waterfall"), true, wxNullBitmap );\r
+    frame->m_panelDefaultB = new PlotPanel((wxFrame*) frame->m_auiNbookCtrl );\r
+    frame->m_auiNbookCtrl->AddPage(frame->m_panelDefaultB, _("Waterfall"), true, wxNullBitmap );\r
+\r
+//    frame->m_panelSpectrum = new PlotSpectrum((wxFrame*) frame->m_auiNbookCtrl );\r
+//    frame->m_auiNbookCtrl->AddPage(frame->m_panelSpectrum, _("Spectrum"), true, wxNullBitmap );\r
+\r
+//    frame->m_panelWaterfall = new PlotWaterfall((wxFrame*) frame->m_auiNbookCtrl );\r
+//    frame->m_auiNbookCtrl->AddPage(frame->m_panelWaterfall, _("Waterfall"), true, wxNullBitmap );\r
 \r
 //    frame->m_panelScatter = new PlotScatter((wxFrame*) frame->m_auiNbookCtrl );\r
 //    frame->m_auiNbookCtrl->AddPage(frame->m_panelWaterfall, _("Scatter"), true, wxNullBitmap );\r
index 516a4defc4bf1f09769b3cc1006e141acc10ffab..c372752ac8f584f71c97fd1c1cd8cebcfa02ed0a 100644 (file)
@@ -70,7 +70,8 @@ class MainFrame : public TopFrame
     public:
         MainFrame(wxWindow *parent);
         virtual ~MainFrame();
-        PlotPanel*      m_panelDefault;\r
+        PlotPanel*      m_panelDefaultA;\r
+        PlotPanel*      m_panelDefaultB;\r
         PlotSpectrum*   m_panelSpectrum;\r
         PlotWaterfall*  m_panelWaterfall;\r
         PlotScatter*    m_panelScatter;\r
index 55810aedb75f3e49ff85f1990e66dfe30ec31b7e..a54fc4851bccd837456336dfcedd2fd99cceac51 100644 (file)
 #include "fdmdv2_main.h"\r
 #include "fdmdv2_plot.h"\r
 \r
-#define wxUSE_FILEDLG   1\r
-#define wxUSE_LIBPNG    1\r
-#define wxUSE_LIBJPEG   1\r
-#define wxUSE_GIF       1\r
-#define wxUSE_PCX       1\r
-#define wxUSE_LIBTIFF   1\r
-\r
 BEGIN_EVENT_TABLE(PlotPanel, wxPanel)\r
     EVT_PAINT           (PlotPanel::OnPaint)\r
     EVT_MOTION          (PlotPanel::OnMouseMove)\r
@@ -27,7 +20,6 @@ BEGIN_EVENT_TABLE(PlotPanel, wxPanel)
     EVT_MOUSEWHEEL      (PlotPanel::OnMouseWheelMoved)\r
     EVT_SIZE            (PlotPanel::OnSize)\r
     EVT_SHOW            (PlotPanel::OnShow)\r
-//    EVT_ERASE_BACKGROUND(PlotPanel::OnErase)\r
 END_EVENT_TABLE()\r
 \r
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\r
@@ -42,12 +34,12 @@ PlotPanel::PlotPanel(wxFrame* parent) : wxPanel(parent)
     m_mouseDown         = false;\r
     m_penShortDash      = wxPen(wxColor(0xA0, 0xA0, 0xA0), 1, wxPENSTYLE_SHORT_DASH);\r
     m_penDotDash        = wxPen(wxColor(0xD0, 0xD0, 0xD0), 1, wxPENSTYLE_DOT_DASH);\r
-    m_gridLeftOffset    = 10;\r
-    m_gridRightOffset   = 10;\r
-    m_gridTopOffset     = 10;\r
-    m_gridBottomOffset  = 10;\r
+//    m_gridLeftOffset    = 20;\r
+//    m_gridRightOffset   = 5;\r
+//    m_gridTopOffset     = 5;\r
+//    m_gridBottomOffset  = 10;\r
+    SetBackgroundStyle(wxBG_STYLE_PAINT);\r
     SetLabelSize(10.0);\r
-    paintNow();\r
 }\r
 \r
 //-------------------------------------------------------------------------\r
@@ -67,11 +59,11 @@ void PlotPanel::SetLabelSize(double size)
 }\r
 \r
 //-------------------------------------------------------------------------\r
-// OnActivate()\r
+// OnShow()\r
 //-------------------------------------------------------------------------\r
 void PlotPanel::OnShow(wxShowEvent& event)\r
 {\r
-    paintNow();\r
+    this->Refresh();\r
 }\r
 \r
 //-------------------------------------------------------------------------\r
@@ -89,7 +81,7 @@ void PlotPanel::OnSize(wxSizeEvent& event)
 {\r
     if(m_bitmap)\r
     {\r
-        paintNow();\r
+        this->Refresh();\r
     }\r
 }\r
 \r
@@ -147,41 +139,35 @@ double PlotPanel::GetZoomFactor(double zf)
     return m_zoomFactor;\r
 }\r
 \r
-#define PLOT_BORDER         10\r
-#define XLEFT_OFFSET        0\r
-#define YBOTTOM_OFFSET      25\r
-#define GRID_INCREMENT      50\r
-#define GREY_COLOR          wxColor(0x80, 0x80, 0x80)\r
-#define BLACK_COLOR         wxColor(0x00, 0x00, 0x00)\r
-\r
 //-------------------------------------------------------------------------\r
-// render() Temporary. Subclass for each view, overide this as needed.\r
+// drawGraticule()\r
 //-------------------------------------------------------------------------\r
-void PlotPanel::render(wxDC&  dc)\r
+void PlotPanel::drawGraticule(wxAutoBufferedPaintDC&  dc)\r
 {\r
+    int p;\r
+    char buf[15];\r
+    wxString s;\r
+\r
     m_rectCtrl  = GetClientRect();\r
     m_rectGrid  = m_rectCtrl;\r
 \r
-    m_rectGrid.Deflate(PLOT_BORDER, (PLOT_BORDER + (YBOTTOM_OFFSET/2)));\r
-    m_rectGrid.Offset(PLOT_BORDER, PLOT_BORDER);\r
+    m_rectGrid.Deflate(PLOT_BORDER + (XLEFT_OFFSET/2), (PLOT_BORDER + (YBOTTOM_OFFSET/2)));\r
+    //m_rectGrid.Offset(PLOT_BORDER + (XLEFT_OFFSET), PLOT_BORDER);\r
+    m_rectGrid.Offset(PLOT_BORDER + XLEFT_OFFSET, PLOT_BORDER);\r
 \r
     int h = m_rectGrid.GetHeight();\r
     int w = m_rectGrid.GetWidth();\r
 \r
-    int p;\r
-    char buf[15];\r
-    wxString s;\r
-\r
     dc.Clear();\r
 \r
     // Draw a filled rectangle with aborder\r
     dc.SetBrush(*wxBLUE_BRUSH);\r
     dc.SetPen(wxPen(BLACK_COLOR, 2));\r
-    dc.DrawRectangle(PLOT_BORDER, PLOT_BORDER, w, h);\r
+    dc.DrawRectangle(PLOT_BORDER + XLEFT_OFFSET, PLOT_BORDER, w, h);\r
 \r
     // Vertical gridlines\r
     dc.SetPen(m_penShortDash);\r
-    for(p = (PLOT_BORDER + GRID_INCREMENT); p < w; p += GRID_INCREMENT)\r
+    for(p = (PLOT_BORDER + XLEFT_OFFSET + GRID_INCREMENT); p < w; p += GRID_INCREMENT)\r
     {\r
         dc.DrawLine(p, (h + PLOT_BORDER), p, PLOT_BORDER);\r
     }\r
@@ -189,17 +175,25 @@ void PlotPanel::render(wxDC&  dc)
     dc.SetPen(m_penDotDash);\r
     for(p = (h - GRID_INCREMENT); p > PLOT_BORDER; p -= GRID_INCREMENT)\r
     {\r
-        dc.DrawLine(PLOT_BORDER, (p + PLOT_BORDER), (w + PLOT_BORDER), (p + PLOT_BORDER));\r
+        dc.DrawLine(PLOT_BORDER + XLEFT_OFFSET, (p + PLOT_BORDER), (w + PLOT_BORDER + XLEFT_OFFSET), (p + PLOT_BORDER));\r
     }\r
     // Label the X-Axis\r
     dc.SetPen(wxPen(GREY_COLOR, 1));\r
     for(p = GRID_INCREMENT; p < (w - YBOTTOM_OFFSET); p += GRID_INCREMENT)\r
     {\r
         sprintf(buf, "%1.1f Hz",(double)(p / 10));\r
-        dc.DrawText(buf, p - PLOT_BORDER, h + YBOTTOM_OFFSET/2);\r
+        dc.DrawText(buf, p - PLOT_BORDER + XLEFT_OFFSET, h + YBOTTOM_OFFSET/2);\r
     }\r
 }\r
 \r
+//-------------------------------------------------------------------------\r
+// draw()\r
+//-------------------------------------------------------------------------\r
+void PlotPanel::draw(wxAutoBufferedPaintDC&  dc)\r
+{\r
+    drawGraticule(dc);\r
+}\r
+\r
 //-------------------------------------------------------------------------\r
 // paintEvent()\r
 //\r
@@ -209,8 +203,8 @@ void PlotPanel::render(wxDC&  dc)
 //-------------------------------------------------------------------------\r
 void PlotPanel::OnPaint(wxPaintEvent & evt)\r
 {\r
-    wxPaintDC dc(this);\r
-    render(dc);\r
+    wxAutoBufferedPaintDC dc(this);\r
+    draw(dc);\r
 }\r
 \r
 //-------------------------------------------------------------------------\r
@@ -227,12 +221,9 @@ void PlotPanel::OnPaint(wxPaintEvent & evt)
 // paint events and calling Refresh() when a refresh is needed\r
 // will do the job.\r
 //-------------------------------------------------------------------------\r
-void PlotPanel::paintNow()\r
-{\r
-    wxClientDC dc(this);\r
-    render(dc);\r
-}\r
-\r
-// general purpose way of plotting scalar values that are\r
-// updated once per frame\r
-\r
+//void PlotPanel::paintNow()\r
+//{\r
+//    wxClientDC dc(this);\r
+//    draw(dc);\r
+//    draw();\r
+//}\r
index d7d5ded4e36b4d92b4b86e63748c9423c422c1ff..f5108739429a908d8d79a5a29ea4b03d14ef688b 100644 (file)
 //#include "fdmdv.h"\r
 #include <wx/rawbmp.h>\r
 #include <wx/image.h>\r
+#include <wx/dcbuffer.h>\r
+\r
+#define wxUSE_FILEDLG       1\r
+#define wxUSE_LIBPNG        1\r
+#define wxUSE_LIBJPEG       1\r
+#define wxUSE_GIF           1\r
+#define wxUSE_PCX           1\r
+#define wxUSE_LIBTIFF       1\r
+\r
+#define PLOT_BORDER         2\r
+#define XLEFT_OFFSET        20\r
+#define YBOTTOM_OFFSET      25\r
+#define GRID_INCREMENT      50\r
+#define GREY_COLOR          wxColor(0x80, 0x80, 0x80)\r
+#define BLACK_COLOR         wxColor(0x00, 0x00, 0x00)\r
+#define BLUE_COLOR          wxColor(0x00, 0x00, 0xFF)\r
+#define GREEN_COLOR         wxColor(0xFF, 0x00, 0xFF)\r
+#define RED_COLOR           wxColor(0xFF, 0x00, 0x00)\r
+#define YELLOW_COLOR        wxColor(0x00, 0xFF, 0x00)\r
+\r
 \r
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\r
 // Class PlotPanel\r
@@ -21,54 +41,55 @@ class PlotPanel : public wxPanel
 {\r
     public:\r
         PlotPanel(wxFrame* parent);\r
-        void paintEvent(wxPaintEvent & evt);\r
-        void paintNow();\r
-        void render(wxDC& dc);\r
-        wxPen m_penShortDash;\r
-        wxPen m_penDotDash;\r
-        wxRect m_rectCtrl;\r
-        wxRect m_rectGrid;\r
-        wxRect m_rectPlot;\r
-        int m_gridLeftOffset;\r
-        int m_gridRightOffset;\r
-        int m_gridTopOffset;\r
-        int m_gridBottomOffset;\r
-        double m_label_size;\r
-        wxBitmap            *m_bmp;\r
+        void            paintEvent(wxPaintEvent & evt);\r
+        void            draw(wxAutoBufferedPaintDC& dc);\r
+        void            drawGraticule(wxAutoBufferedPaintDC& dc);\r
+        wxPen           m_penShortDash;\r
+        wxPen           m_penDotDash;\r
+        wxRect          m_rectCtrl;\r
+        wxRect          m_rectGrid;\r
+        wxRect          m_rectPlot;\r
+//        int             m_gridLeftOffset;\r
+//        int             m_gridRightOffset;\r
+//        int             m_gridTopOffset;\r
+//        int             m_gridBottomOffset;\r
+        double          m_label_size;\r
+        wxSize          m_Bufsz;\r
+        wxBitmap        *m_bmp;\r
+        wxImagePixelData *m_pBmp;\r
         //wxNativePixelData   *m_pBmp;\r
         //wxAlphaPixelData    *m_pBmp;\r
-        wxImagePixelData    *m_pBmp;\r
 \r
         // some useful events\r
-        void OnMouseMove(wxMouseEvent& event);\r
-        void OnMouseDown(wxMouseEvent& event);\r
-        void OnMouseUp(wxMouseEvent& event);\r
-        void OnMouseWheelMoved(wxMouseEvent& event);\r
-        void OnPaint(wxPaintEvent& event);
-        void OnClose( wxCloseEvent& event ){ event.Skip(); }
-        void OnSize( wxSizeEvent& event );\r
-        void OnErase(wxEraseEvent& event);\r
-        double SetZoomFactor(double zf);\r
-        double GetZoomFactor(double zf);\r
+        void    OnMouseMove(wxMouseEvent& event);\r
+        void    OnMouseDown(wxMouseEvent& event);\r
+        void    OnMouseUp(wxMouseEvent& event);\r
+        void    OnMouseWheelMoved(wxMouseEvent& event);\r
+        void    OnClose(wxCloseEvent& event ){ event.Skip(); }
+        void    OnSize( wxSizeEvent& event );\r
+        void    OnErase(wxEraseEvent& event);\r
+        void    OnPaint(wxPaintEvent& event);
+        double  SetZoomFactor(double zf);\r
+        double  GetZoomFactor(double zf);\r
         //void OnUpdateUI( wxUpdateUIEvent& event ){ event.Skip(); }\r
-        void OnShow(wxShowEvent& event);\r
-        double GetLabelSize();\r
-        void SetLabelSize(double size);\r
+        void    OnShow(wxShowEvent& event);\r
+        double  GetLabelSize();\r
+        void    SetLabelSize(double size);\r
 
     protected:\r
-        int  m_x;
-        int  m_y;
-        int  m_w;
-        int  m_h;
-        int  m_prev_w;
-        int  m_prev_h;
-        int  m_prev_x;
-        int  m_prev_y;
-        bool m_bitmap;\r
-        bool m_clip;\r
-        bool m_rubberBand;\r
-        bool m_mouseDown;\r
-        double m_zoomFactor;\r
+        int     m_x;
+        int     m_y;
+        int     m_w;
+        int     m_h;
+        int     m_prev_w;
+        int     m_prev_h;
+        int     m_prev_x;
+        int     m_prev_y;
+        bool    m_bitmap;\r
+        bool    m_clip;\r
+        bool    m_rubberBand;\r
+        bool    m_mouseDown;\r
+        double  m_zoomFactor;\r
     DECLARE_EVENT_TABLE()\r
 };\r
 #endif //__FDMDV2_PLOT__\r
diff --git a/fdmdv2/src/fdmdv2_plot_scalar.cpp b/fdmdv2/src/fdmdv2_plot_scalar.cpp
new file mode 100644 (file)
index 0000000..3ccfb42
--- /dev/null
@@ -0,0 +1,222 @@
+//==========================================================================\r
+// Name:            fdmdv2_plot_scalar.cpp\r
+// Purpose:         Implements a waterfall plot derivative of fdmdv2_plot.\r
+// Created:         June 22, 2012
+// Initial author:  David Witten\r
+// Derived from:    code written by David Rowe\r
+// License:\r
+//\r
+//  Copyright (C) 2012 David Witten
+//
+//  All rights reserved.
+//
+//  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,
+//  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
+//  along with this program; if not, see <http://www.gnu.org/licenses/>.
+//
+//==========================================================================\r
+#include <string.h>\r
+#include "wx/wx.h"\r
+#include "fdmdv2_main.h"\r
+#include "fdmdv2_plot_scalar.h"\r
+
+BEGIN_EVENT_TABLE(PlotScalar, PlotPanel)\r
+    EVT_PAINT           (PlotScalar::OnPaint)\r
+    EVT_MOTION          (PlotScalar::OnMouseMove)\r
+    EVT_LEFT_DOWN       (PlotScalar::OnMouseDown)\r
+    EVT_LEFT_UP         (PlotScalar::OnMouseUp)\r
+    EVT_MOUSEWHEEL      (PlotScalar::OnMouseWheelMoved)\r
+    EVT_SIZE            (PlotScalar::OnSize)\r
+    EVT_SHOW            (PlotScalar::OnShow)\r
+//    EVT_ERASE_BACKGROUND(PlotScalar::OnErase)\r
+END_EVENT_TABLE()\r
+\r
+//----------------------------------------------------------------\r
+//\r
+//----------------------------------------------------------------\r
+//PlotScalar::PlotScalar(wxFrame* parent, int x, int y, int w, int h, int x_max_, int y_max_, const char name[]): PlotPanel(parent)\r
+PlotScalar::PlotScalar(wxFrame* parent, int x_max_, int y_max_): PlotPanel(parent)\r
+{
+    int i;\r
+\r
+    //align(FL_ALIGN_TOP);\r
+    //labelsize(10);\r
+\r
+    m_x_max = x_max_;\r
+    m_y_max = y_max_;\r
+    m_mem = new float[m_x_max];\r
+\r
+    for(i = 0; i < m_x_max; i++)\r
+    {\r
+        m_mem[i] = 0.0;\r
+    }\r
+    m_prev_w = 0;\r
+    m_prev_h = 0;\r
+    m_prev_x = 0;\r
+    m_prev_y = 0;\r
+    m_index = 0;\r
+}\r
+\r
+//----------------------------------------------------------------\r
+//\r
+//----------------------------------------------------------------\r
+PlotScalar::~PlotScalar()\r
+{\r
+    delete m_mem;\r
+}\r
+\r
+//----------------------------------------------------------------\r
+//\r
+//----------------------------------------------------------------\r
+void PlotScalar::add_new_sample(float sample)\r
+{\r
+    m_new_sample = sample;\r
+}\r
+\r
+//----------------------------------------------------------------\r
+//\r
+//----------------------------------------------------------------\r
+int PlotScalar::clip(int y1)\r
+{\r
+    if(y1 > (m_h/2 - 10))
+    {\r
+        y1 = m_h/2 - 10;\r
+    }\r
+    if(y1 < -(m_h/2 - 10))\r
+    {
+        y1 = -(m_h/2 - 10);
+    }\r
+    return y1;\r
+}\r
+\r
+//----------------------------------------------------------------\r
+//\r
+//----------------------------------------------------------------\r
+void PlotScalar::draw(wxAutoBufferedPaintDC&  dc)\r
+{\r
+    float x_scale;\r
+    float y_scale;\r
+    int   i;
+    int   x1;
+    int   y1;
+    int   x2;
+    int   y2;\r
+    char  label[100];\r
+\r
+//    PlotPanel::draw();\r
+\r
+    /* detect resizing of window */\r
+    if((m_h != m_prev_h) || (m_w != m_prev_w) || (m_x != m_prev_x) || (m_y != m_prev_y))\r
+    {\r
+        //fl_color(FL_BLACK);\r
+        //fl_rectf(m_x, m_y, m_w, m_h);\r
+        m_prev_h = m_h;\r
+        m_prev_w = m_w;\r
+        m_prev_x = m_x;\r
+        m_prev_y = m_y;\r
+    }\r
+\r
+    //fl_push_clip(m_x, m_y, m_w, m_h);\r
+    x_scale = (float)m_x_max;\r
+    y_scale = (float)m_h /(2.0 * m_y_max);\r
+\r
+    // erase last sample\r
+    //fl_color(FL_BLACK);\r
+    x1 = x_scale * m_index + m_x;\r
+    y1 = y_scale * m_mem[m_index];\r
+    y1 = clip(y1);\r
+    y1 = m_y + m_h/2 - y1;\r
+    //fl_point(x1, y1);\r
+\r
+    // draw new sample\r
+    //fl_color(FL_GREEN);\r
+    x1 = x_scale * m_index + m_x;\r
+    y1 = y_scale * m_new_sample;\r
+    y1 = clip(y1);\r
+    y1 = m_y + m_h/2 - y1;\r
+//    fl_point(x1, y1);\r
+    m_mem[m_index] = m_new_sample;\r
+    m_index++;\r
+    if(m_index >=  m_x_max)\r
+    {\r
+        m_index = 0;\r
+    }\r
+\r
+    // y axis graticule\r
+    m_step = 10;\r
+    while((2.0 * m_y_max/m_step) > 10)\r
+    {\r
+        m_step *= 2.0;\r
+    }\r
+    while((2.0 * m_y_max/m_step) < 4)\r
+    {\r
+        m_step /= 2.0;\r
+    }\r
+   // fl_color(FL_DARK_GREEN);\r
+   // fl_line_style(FL_DOT);\r
+    for(i =- m_y_max; i < m_y_max; i += m_step)\r
+    {\r
+        x1 = m_x;\r
+        y1 = m_y + m_h/2 - i * y_scale;\r
+        x2 = m_x + m_w;\r
+        y2 = y1;\r
+        //fl_line(x1, y1, x2, y2);\r
+    }\r
+\r
+    // y axis graticule labels\r
+   // fl_color(FL_GREEN);\r
+   // fl_line_style(FL_SOLID);\r
+    for(i =- m_y_max; i < m_y_max; i += m_step)\r
+    {\r
+        x1 = m_x;\r
+        y1 = m_y + m_h/2 - i * y_scale;\r
+        sprintf(label, "%d", i);\r
+        //fl_draw(label, x1, y1);\r
+    }\r
+    //fl_pop_clip();\r
+}
+\r
+// // update average of each spectrum point\r
+// void new_data(float mag_dB[])\r
+// {\r
+//     int i;\r
+//\r
+//     for(i=0; i<FDMDV_NSPEC; i++)
+//     {\r
+//         av_mag[i] = (1.0 - BETA)*av_mag[i] + BETA*mag_dB[i];
+//     }\r
+// }
+\r
+//----------------------------------------------------------------\r
+// OnPaint()\r
+//----------------------------------------------------------------\r
+void PlotScalar::OnPaint(wxPaintEvent& event)\r
+{\r
+    wxAutoBufferedPaintDC dc(this);\r
+    draw(dc);\r
+}\r
+\r
+//----------------------------------------------------------------\r
+// OnSize()\r
+//----------------------------------------------------------------\r
+void PlotScalar::OnSize(wxSizeEvent& event)\r
+{\r
+//    wxAutoBufferedPaintDC dc(this);\r
+//    draw(dc);\r
+}\r
+\r
+//----------------------------------------------------------------\r
+// OnShow()\r
+//----------------------------------------------------------------\r
+void PlotScalar::OnShow(wxShowEvent& event)\r
+{\r
+//    wxAutoBufferedPaintDC dc(this);\r
+ //   draw(dc);\r
+}\r
diff --git a/fdmdv2/src/fdmdv2_plot_scalar.h b/fdmdv2/src/fdmdv2_plot_scalar.h
new file mode 100644 (file)
index 0000000..d9d0515
--- /dev/null
@@ -0,0 +1,73 @@
+//==========================================================================\r
+// Name:            fdmdv2_plot_scalar.h\r
+// Purpose:         Defines a scalar plot derivative of fdmdv2_plot.\r
+// Created:         June 22, 2012
+// Initial author:  David Witten\r
+// Derived from:    code written by David Rowe\r
+// License:\r
+//\r
+//  Copyright (C) 2012 David Witten
+//
+//  All rights reserved.
+//
+//  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,
+//  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
+//  along with this program; if not, see <http://www.gnu.org/licenses/>.
+//
+//==========================================================================\r
+#ifndef __FDMDV2_PLOT_SCALAR__
+#define __FDMDV2_PLOT_SCALAR__
+\r
+#include "fdmdv2_plot.h"\r
+#include "fdmdv2_defines.h"\r
+\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\r
+// Class PlotScalar\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\r
+class PlotScalar: public PlotPanel\r
+{\r
+    public:\r
+\r
+        //PlotScalar(wxFrame* parent, int x, int y, int w, int h, int x_max_, int y_max_, const char name[]);\r
+        PlotScalar(wxFrame* parent, int x_max_, int y_max_);\r
+        ~PlotScalar();\r
+        void add_new_sample(float sample);\r
+\r
+    protected:\r
+\r
+        int    m_x_max;\r
+        int    m_y_max;\r
+        float  *m_mem;              /* array of x_max samples */\r
+        float  m_new_sample;\r
+        int    m_index;\r
+        int    m_step;\r
+\r
+        int clip(int y1);\r
+        void draw(wxAutoBufferedPaintDC&  dc);\r
+        void OnPaint(wxPaintEvent& event);\r
+        void OnSize(wxSizeEvent& event);\r
+        void OnShow(wxShowEvent& event);\r
+\r
+        DECLARE_EVENT_TABLE()\r
+};\r
+\r
+//// update average of each spectrum point\r
+//void new_data(float mag_dB[])\r
+//{\r
+//    int i;\r
+//\r
+//    for(i=0; i<FDMDV_NSPEC; i++)\r
+//    {\r
+//        av_mag[i] = (1.0 - BETA)*av_mag[i] + BETA*mag_dB[i];\r
+//    }\r
+//}\r
+\r
+#endif // __FDMDV2_PLOT_SCALAR__
+\r
index 8c5b9c2eb94de9c734b2537c09a45279bcc0e26e..3a8637a5d2faf6ca00af2fedc13cd67cc6b56809 100644 (file)
@@ -37,9 +37,9 @@ BEGIN_EVENT_TABLE(PlotScatter, PlotPanel)
 //    EVT_ERASE_BACKGROUND(PlotScatter::OnErase)\r
 END_EVENT_TABLE()\r
 \r
-//----------------------------------------------------------------\r
-//\r
-//----------------------------------------------------------------\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\r
+// PlotScatter\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\r
 PlotScatter::PlotScatter(wxFrame* parent) : PlotPanel(parent)\r
 {\r
     int i;\r
@@ -47,7 +47,7 @@ PlotScatter::PlotScatter(wxFrame* parent) : PlotPanel(parent)
     //align(FL_ALIGN_TOP);
     //labelsize(10);
 
-    for(i=0; i<SCATTER_MEM; i++)
+    for(i=0; i < SCATTER_MEM; i++)
     {
         m_mem[i].real = 0.0;
         m_mem[i].imag = 0.0;
@@ -59,9 +59,9 @@ PlotScatter::PlotScatter(wxFrame* parent) : PlotPanel(parent)
 }
 
 //----------------------------------------------------------------\r
-//\r
+// draw()\r
 //----------------------------------------------------------------\r
-void PlotScatter::draw()
+void PlotScatter::draw(wxAutoBufferedPaintDC&  dc)
 {
     float x_scale;
     float y_scale;
@@ -118,14 +118,41 @@ void PlotScatter::draw()
 }
 
 //----------------------------------------------------------------\r
-//\r
+// add_new_samples()\r
 //----------------------------------------------------------------\r
 void PlotScatter::add_new_samples(COMP samples[])
 {
     int i;
 
-    for(i=0; i<FDMDV_NSYM; i++)
+    for(i = 0; i < FDMDV_NSYM; i++)
     {
         m_new_samples[i] = samples[i];
     }
-}
+}\r
+\r
+//----------------------------------------------------------------\r
+// OnPaint()\r
+//----------------------------------------------------------------\r
+void PlotScatter::OnPaint(wxPaintEvent& event)\r
+{\r
+    wxAutoBufferedPaintDC dc(this);\r
+    draw(dc);\r
+}\r
+\r
+//----------------------------------------------------------------\r
+// OnSize()\r
+//----------------------------------------------------------------\r
+void PlotScatter::OnSize(wxSizeEvent& event)\r
+{\r
+//    wxAutoBufferedPaintDC dc(this);\r
+//    draw(dc);\r
+}\r
+\r
+//----------------------------------------------------------------\r
+// OnShow()\r
+//----------------------------------------------------------------\r
+void PlotScatter::OnShow(wxShowEvent& event)\r
+{\r
+//    paintNow();\r
+}\r
+
index f60e5a0e2a194d6c7be4d9a2402f978c06a23570..15095fb47d8ab49562800d8c07d6155a2c322643 100644 (file)
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\r
 class PlotScatter : public PlotPanel
 {
-public:
-   PlotScatter(wxFrame* parent);\r
-    ~PlotScatter(){};
+    public:
+       PlotScatter(wxFrame* parent);\r
+        ~PlotScatter(){};
 
-protected:
-    COMP m_mem[SCATTER_MEM];
-    COMP m_new_samples[FDMDV_NSYM];
+    protected:
+        COMP m_mem[SCATTER_MEM];
+        COMP m_new_samples[FDMDV_NSYM];
 
-    void draw();
-    void add_new_samples(COMP samples[]);
-    DECLARE_EVENT_TABLE()\r
+        void draw(wxAutoBufferedPaintDC&  dc);
+        void add_new_samples(COMP samples[]);\r
+        void OnPaint(wxPaintEvent& event);\r
+        void OnSize(wxSizeEvent& event);\r
+        void OnShow(wxShowEvent& event);\r
+
+        DECLARE_EVENT_TABLE()\r
 };\r
 
 #endif //__FDMDV2_PLOT_SCATTER__
index c6ef9881fa04cd75d9caa233aadf872cbbb97ec3..cbc9bd3bdd71f2f8c3bde0b5d9de90f82a0f38f8 100644 (file)
 #include "fdmdv2_plot_spectrum.h"\r
 \r
 BEGIN_EVENT_TABLE(PlotSpectrum, PlotPanel)\r
-    EVT_PAINT           (PlotSpectrum::OnPaint)\r
     EVT_MOTION          (PlotSpectrum::OnMouseMove)\r
     EVT_LEFT_DOWN       (PlotSpectrum::OnMouseDown)\r
     EVT_LEFT_UP         (PlotSpectrum::OnMouseUp)\r
     EVT_MOUSEWHEEL      (PlotSpectrum::OnMouseWheelMoved)\r
+    EVT_PAINT           (PlotSpectrum::OnPaint)\r
     EVT_SIZE            (PlotSpectrum::OnSize)\r
     EVT_SHOW            (PlotSpectrum::OnShow)\r
 //    EVT_ERASE_BACKGROUND(PlotSpectrum::OnErase)\r
@@ -42,36 +42,15 @@ END_EVENT_TABLE()
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\r
 // Class PlotSpectrum\r
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\r
-//PlotSpectrum::PlotSpectrum(wxFrame* parent, int x, int y, int w, int h): PlotPanel(parent)\r
 PlotSpectrum::PlotSpectrum(wxFrame* parent): PlotPanel(parent)\r
 {\r
-//    align(FL_ALIGN_TOP);\r
-//    labelsize(10);\r
+    SetLabelSize(10.0);\r
 }\r
 \r
 //----------------------------------------------------------------\r
-//\r
+// draw()\r
 //----------------------------------------------------------------\r
-int PlotSpectrum::handle(int event)\r
-{
-/*\r
-    //  detect a left mouse down if inside the spectrum window
-    if((event == FL_NO_EVENT) && (Fl::event_button() == 1))
-    {
-        if((Fl::event_x() > x()) && (Fl::event_x() < (x() + w())) && (Fl::event_y() > y()) && (Fl::event_y() < (y() + h())))
-        {
-            // show zoomed spectrum window
-            zoomSpectrumWindow->show();
-        }
-    }
-*/
-    return 0;
-}
-
-//----------------------------------------------------------------\r
-//\r
-//----------------------------------------------------------------\r
-void PlotSpectrum::draw()
+void PlotSpectrum::draw(wxAutoBufferedPaintDC&  dc)
 {
     float x_px_per_point = 0.0;
     float y_px_per_dB = 0.0;
@@ -82,7 +61,8 @@ void PlotSpectrum::draw()
     int   y2;
     float mag1, mag2;
     char  label[20];
-    float px_per_hz;
+    float px_per_hz;\r
+\r
 /*
     Fl_Box::draw();
     fl_color(FL_BLACK);
@@ -93,12 +73,16 @@ void PlotSpectrum::draw()
     fl_push_clip(x(),y(),w(),h());
     //printf("%d %d\n", w(), h());
 */
+    dc.SetBrush(*wxBLUE_BRUSH);\r
+    dc.SetPen(wxPen(YELLOW_COLOR, 2));\r
+    dc.DrawRectangle(PLOT_BORDER, PLOT_BORDER, m_w, m_h);\r
+\r
     x_px_per_point = (float)m_w / FDMDV_NSPEC;
     y_px_per_dB = (float)m_h / (MAX_DB - MIN_DB);
 
     // plot spectrum
 
-    for(i=0; i<FDMDV_NSPEC-1; i++)
+    for(i = 0; i < FDMDV_NSPEC - 1; i++)
     {
 //        mag1 = av_mag[i];
 //        mag2 = av_mag[i+1];
@@ -140,3 +124,30 @@ void PlotSpectrum::draw()
     }
 //    fl_pop_clip();
 }
+\r
+//----------------------------------------------------------------\r
+// OnPaint()\r
+//----------------------------------------------------------------\r
+void PlotSpectrum::OnPaint(wxPaintEvent& event)\r
+{\r
+    wxAutoBufferedPaintDC dc(this);\r
+    draw(dc);\r
+}\r
+\r
+//----------------------------------------------------------------\r
+// OnSize()\r
+//----------------------------------------------------------------\r
+void PlotSpectrum::OnSize(wxSizeEvent& event)\r
+{\r
+//    wxAutoBufferedPaintDC dc(this);\r
+//    draw(dc);\r
+}\r
+\r
+//----------------------------------------------------------------\r
+// OnShow()\r
+//----------------------------------------------------------------\r
+void PlotSpectrum::OnShow(wxShowEvent& event)\r
+{\r
+//    wxAutoBufferedPaintDC dc(this);\r
+//   draw(dc);\r
+}\r
index 4f8472b135a1e441f30047ee5e61398740766fe9..4d933ef7b67d6d0bb6076f02578fdcb70be652cf 100644 (file)
@@ -38,8 +38,11 @@ class PlotSpectrum : public PlotPanel
         PlotSpectrum(wxFrame* parent);
         ~PlotSpectrum() {};
     protected:
-        int handle(int event);\r
-        void draw();
+        void draw(wxAutoBufferedPaintDC&  dc);\r
+        void OnPaint(wxPaintEvent& event);\r
+        void OnSize(wxSizeEvent& event);\r
+        void OnShow(wxShowEvent& event);\r
+
         DECLARE_EVENT_TABLE()\r
 };
 
index ab9c672f071088b9ad305f14d1ce286748a2e927..bbac7e71661ff83222267d98f8714a78aec64cd5 100644 (file)
@@ -52,8 +52,6 @@ END_EVENT_TABLE()
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\r
 // Class WaterfallPlot\r
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\r
-//PlotWaterfall::PlotWaterfall(int x, int y, int w, int h): Fl_Box(x, y, w, h, "PlotWaterfall")
-//PlotWaterfall::PlotWaterfall(wxFrame* parent, int x, int y, int w, int h, const char name[]): PlotPanel(parent)\r
 PlotWaterfall::PlotWaterfall(wxFrame* parent): PlotPanel(parent)\r
 {
     int   i;
@@ -64,9 +62,7 @@ PlotWaterfall::PlotWaterfall(wxFrame* parent): PlotPanel(parent)
     }
     greyscale = 0;
     SetLabelSize(10.0);\r
-//    wxSize sz = GetClientSize();
-    wxSize sz = GetMaxClientSize();
-    new_pixel_buf(sz.GetWidth(), sz.GetHeight());
+    m_Bufsz = GetMaxClientSize();
 };
 
 //----------------------------------------------------------------\r
@@ -74,27 +70,39 @@ PlotWaterfall::PlotWaterfall(wxFrame* parent): PlotPanel(parent)
 //----------------------------------------------------------------\r
 PlotWaterfall::~PlotWaterfall()
 {
-    delete pixel_buf;
+    if(m_bmp->IsOk())\r
+    {\r
+        delete m_bmp;\r
+    }
 }
 \r
+/*\r
 //----------------------------------------------------------------\r
 // new_pixel_buf()\r
 //----------------------------------------------------------------\r
 void PlotWaterfall::new_pixel_buf(int w, int h)
 {
-    int buf_sz;\r
-    int i;
-
-    prev_w = w;\r
-    prev_h = h;
-    buf_sz = h * w;\r
-\r
-    // pixel_buf = new unsigned[buf_sz];
-    //for(i = 0; i < buf_sz; i++)
-    //{
-    //    pixel_buf[i] = 0;
-    //}\r
+//    int i;\r
+\r
+    m_prev_w = w;\r
+    m_prev_h = h;
+\r
+//    wxMemoryDC m_memDC = new wxMemoryDC();
 
+    if(m_bmp->IsOk())\r
+    {\r
+        delete m_bmp;\r
+        //m_Bufsz = h * w;\r
+\r
+        //m_img = new wxImage(sz, pdata, alpha,false);\r
+        m_bmp = new wxBitmap(w, h, wxBITMAP_SCREEN_DEPTH);\r
+        //m_pBmp = m_bmp->GetBitmapData();\r
+    }
+//    pixel_buf = new unsigned[buf_sz];
+//    for(i = 0; i < buf_sz; i++)
+//    {
+//        pixel_buf[i] = 0;
+//    }\r
 }
 
 //----------------------------------------------------------------\r
@@ -103,7 +111,6 @@ void PlotWaterfall::new_pixel_buf(int w, int h)
 int PlotWaterfall::handle(int event)
 {
     //  detect a left mouse down if inside the window
-/*
     if ((event == FL_NO_EVENT) && (Fl::event_button() == 1))
     {
         if ((Fl::event_x() > x()) && (Fl::event_x() < (x() + w())) && (Fl::event_y() > y()) && (Fl::event_y() < (y() + h())))
@@ -112,9 +119,9 @@ int PlotWaterfall::handle(int event)
             zoomWaterfallWindow->show();
         }
     }
-*/\r
     return 0;
 }
+*/\r
 
 //----------------------------------------------------------------\r
 // heatmap()\r
@@ -155,7 +162,7 @@ unsigned PlotWaterfall::heatmap(float val, float min, float max)
 //----------------------------------------------------------------\r
 // draw()\r
 //----------------------------------------------------------------\r
-void PlotWaterfall::draw()
+void PlotWaterfall::draw(wxAutoBufferedPaintDC&  dc)
 {
     float       spec_index_per_px;\r
     float       intensity_per_dB;
@@ -172,12 +179,35 @@ void PlotWaterfall::draw()
     unsigned    *pdest;\r
     unsigned    *psrc;
 
+    m_rectCtrl  = GetClientRect();\r
+    m_rectGrid  = m_rectCtrl;\r
+\r
+    m_rectGrid.Deflate(PLOT_BORDER, (PLOT_BORDER + (YBOTTOM_OFFSET/2)));\r
+    m_rectGrid.Offset(PLOT_BORDER, PLOT_BORDER);\r
+\r
+    int m_h = m_rectGrid.GetHeight();\r
+    int m_w = m_rectGrid.GetWidth();\r
+\r
     /* detect resizing of window */
+/*\r
     if ((m_h != m_prev_h) || (m_w != m_prev_w))
     {
-        delete pixel_buf;
+        //delete m_pBmp;
         new_pixel_buf(m_w, m_h);
-    }
+    }\r
+*/\r
+    //int p;\r
+    //char buf[15];\r
+    wxString s;\r
+\r
+    dc.Clear();\r
+//    PlotPanel::draw(dc);
+\r
+    // Draw a filled rectangle with aborder\r
+    dc.SetBrush(*wxBLUE_BRUSH);\r
+    dc.SetPen(wxPen(GREEN_COLOR, 2));\r
+    dc.DrawRectangle(PLOT_BORDER, PLOT_BORDER, m_w, m_h);\r
+\r
 //    Fl_Box::draw();
     // determine dy, the height of one "block"
     px_per_sec = (float)m_h / WATERFALL_SECS_Y;
@@ -212,7 +242,7 @@ void PlotWaterfall::draw()
         {
             for(py = 0; py < dy; py++)
             {
-                last_row[px + py * m_w] = intensity<<8;
+                last_row[px + py * m_w] = intensity << 8;
             }
         }
         else
@@ -224,7 +254,49 @@ void PlotWaterfall::draw()
         }
     }
     // update bit map
-    //fl_draw_image((unsigned char*)pixel_buf, m_x, m_y, m_w, m_h, 4, 0);
+    //fl_draw_image((unsigned char*)pixel_buf, m_x, m_y, m_w, m_h, 4, 0);\r
+    //dc.DrawLines(4, m_pBmp, 0, 0 );
 }
 
-
+//----------------------------------------------------------------\r
+// paintNow()\r
+//----------------------------------------------------------------\r
+void PlotWaterfall::paintNow()\r
+{\r
+//    wxClientDC dc(this);\r
+//    draw(dc);\r
+//    draw();\r
+}\r
+\r
+//----------------------------------------------------------------\r
+// paintEvent()\r
+//\r
+// Called by the system of by wxWidgets when the panel needs\r
+// to be redrawn. You can also trigger this call by calling\r
+// Refresh()/Update().\r
+//----------------------------------------------------------------\r
+void PlotWaterfall::OnPaint(wxPaintEvent & evt)\r
+{\r
+    wxAutoBufferedPaintDC dc(this);\r
+    draw(dc);\r
+}\r
+\r
+//----------------------------------------------------------------\r
+// OnSize()\r
+//----------------------------------------------------------------\r
+void PlotWaterfall::OnSize(wxSizeEvent& event)\r
+{\r
+    if(m_bitmap)\r
+    {\r
+        this->Refresh();\r
+    }\r
+}\r
+\r
+//----------------------------------------------------------------\r
+// OnShow()\r
+//----------------------------------------------------------------\r
+void PlotWaterfall::OnShow(wxShowEvent& event)\r
+{\r
+//    wxAutoBufferedPaintDC dc(this);\r
+//    draw();\r
+}\r
index 5d629e413cfd7e23cfba67f63dbd0f02d2db0026..ee56df2419b06c0c300e67192efc0736c9b0d2a6 100644 (file)
 class PlotWaterfall : public PlotPanel\r
 {\r
 public:
-    //PlotWaterfall(int x, int y, int w, int h);\r
-    //PlotWaterfall(wxFrame* parent, int x, int y, int w, int h, const char name[]);\r
     PlotWaterfall(wxFrame* parent);\r
     ~PlotWaterfall();\r
 
 protected:
-    int         prev_w;\r
-    int         prev_h;
     unsigned    *pixel_buf;
     unsigned    heatmap_lut[256];
     int         greyscale;
 \r
-    void    new_pixel_buf(int w, int h);
-    int     handle(int event);
-    unsigned heatmap(float val, float min, float max);
-    void    draw();\r
-
+    unsigned    heatmap(float val, float min, float max);
+    void        draw(wxAutoBufferedPaintDC&  dc);\r
+\r
+    void        OnPaint(wxPaintEvent & evt);\r
+    void        OnSize(wxSizeEvent& event);\r
+    void        OnShow(wxShowEvent& event);\r
+    void        paintNow();
     DECLARE_EVENT_TABLE()\r
 };\r
 \r
diff --git a/fdmdv2/src/fdmdv2_scalar.cpp b/fdmdv2/src/fdmdv2_scalar.cpp
deleted file mode 100644 (file)
index e0ed6cf..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-//==========================================================================\r
-// Name:            fdmdv2_plot_waterfall.cpp\r
-// Purpose:         Implements a waterfall plot derivative of fdmdv2_plot.\r
-// Created:         June 22, 2012
-// Initial author:  David Witten\r
-// Derived from:    code written by David Rowe\r
-// License:\r
-//\r
-//  Copyright (C) 2012 David Witten
-//
-//  All rights reserved.
-//
-//  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,
-//  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
-//  along with this program; if not, see <http://www.gnu.org/licenses/>.
-//
-//==========================================================================\r
-#include <string.h>\r
-#include "wx/wx.h"\r
-#include "fdmdv2_main.h"\r
-#include "fdmdv2_plot.h"\r
-#include "fdmdv2_scalar.h"
-\r
-Scalar::Scalar(wxFrame* parent, int x, int y, int w, int h, int x_max_, int y_max_, const char name[]): DrawPanel(parent)\r
-{
-    int i;\r
-\r
-    //align(FL_ALIGN_TOP);\r
-    //labelsize(10);\r
-\r
-    m_x_max = x_max_;\r
-    m_y_max = y_max_;\r
-    m_mem = new float[m_x_max];\r
-\r
-    for(i = 0; i < m_x_max; i++)\r
-    {\r
-        m_mem[i] = 0.0;\r
-    }\r
-    m_prev_w = 0;\r
-    m_prev_h = 0;\r
-    m_prev_x = 0;\r
-    m_prev_y = 0;\r
-    m_index = 0;\r
-}\r
-\r
-Scalar::~Scalar()\r
-{\r
-    delete m_mem;\r
-}\r
-\r
-void Scalar::add_new_sample(float sample)\r
-{\r
-    m_new_sample = sample;\r
-}\r
-\r
-int Scalar::clip(int y1)\r
-{\r
-    if(y1 > (m_h/2 - 10))
-    {\r
-        y1 = m_h/2 - 10;\r
-    }\r
-    if(y1 < -(m_h/2 - 10))\r
-    {
-        y1 = -(m_h/2 - 10);
-    }\r
-    return y1;\r
-}\r
-\r
-void Scalar::draw()\r
-{\r
-    float x_scale;\r
-    float y_scale;\r
-    int   i;
-    int   x1;
-    int   y1;
-    int   x2;
-    int   y2;\r
-    char  label[100];\r
-\r
-//    DrawPanel::draw();\r
-\r
-    /* detect resizing of window */\r
-    if((m_h != m_prev_h) || (m_w != m_prev_w) || (m_x != m_prev_x) || (m_y != m_prev_y))\r
-    {\r
-        //fl_color(FL_BLACK);\r
-        //fl_rectf(m_x, m_y, m_w, m_h);\r
-        m_prev_h = m_h;\r
-        m_prev_w = m_w;\r
-        m_prev_x = m_x;\r
-        m_prev_y = m_y;\r
-    }\r
-\r
-    //fl_push_clip(m_x, m_y, m_w, m_h);\r
-    x_scale = (float)m_x_max;\r
-    y_scale = (float)m_h /(2.0 * m_y_max);\r
-\r
-    // erase last sample\r
-    //fl_color(FL_BLACK);\r
-    x1 = x_scale * m_index + m_x;\r
-    y1 = y_scale * m_mem[m_index];\r
-    y1 = clip(y1);\r
-    y1 = m_y + m_h/2 - y1;\r
-    //fl_point(x1, y1);\r
-\r
-    // draw new sample\r
-    //fl_color(FL_GREEN);\r
-    x1 = x_scale * m_index + m_x;\r
-    y1 = y_scale * m_new_sample;\r
-    y1 = clip(y1);\r
-    y1 = m_y + m_h/2 - y1;\r
-//    fl_point(x1, y1);\r
-    m_mem[m_index] = m_new_sample;\r
-    m_index++;\r
-    if(m_index >=  m_x_max)\r
-    {\r
-        m_index = 0;\r
-    }\r
-\r
-    // y axis graticule\r
-    m_step = 10;\r
-    while((2.0 * m_y_max/m_step) > 10)\r
-    {\r
-        m_step *= 2.0;\r
-    }\r
-    while((2.0 * m_y_max/m_step) < 4)\r
-    {\r
-        m_step /= 2.0;\r
-    }\r
-   // fl_color(FL_DARK_GREEN);\r
-   // fl_line_style(FL_DOT);\r
-    for(i =- m_y_max; i < m_y_max; i += m_step)\r
-    {\r
-        x1 = m_x;\r
-        y1 = m_y + m_h/2 - i * y_scale;\r
-        x2 = m_x + m_w;\r
-        y2 = y1;\r
-        //fl_line(x1, y1, x2, y2);\r
-    }\r
-\r
-    // y axis graticule labels\r
-   // fl_color(FL_GREEN);\r
-   // fl_line_style(FL_SOLID);\r
-    for(i =- m_y_max; i < m_y_max; i += m_step)\r
-    {\r
-        x1 = m_x;\r
-        y1 = m_y + m_h/2 - i * y_scale;\r
-        sprintf(label, "%d", i);\r
-        //fl_draw(label, x1, y1);\r
-    }\r
-    //fl_pop_clip();\r
-}
-\r
-// // update average of each spectrum point\r
-// void new_data(float mag_dB[])\r
-// {\r
-//     int i;\r
-//\r
-//     for(i=0; i<FDMDV_NSPEC; i++)
-//     {\r
-//         av_mag[i] = (1.0 - BETA)*av_mag[i] + BETA*mag_dB[i];
-//     }\r
-// }
diff --git a/fdmdv2/src/fdmdv2_scalar.h b/fdmdv2/src/fdmdv2_scalar.h
deleted file mode 100644 (file)
index 5422520..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-//==========================================================================\r
-// Name:            fdmdv2_scalar.h\r
-// Purpose:         Defines a scalar plot derivative of fdmdv2_plot.\r
-// Created:         June 22, 2012
-// Initial author:  David Witten\r
-// Derived from:    code written by David Rowe\r
-// License:\r
-//\r
-//  Copyright (C) 2012 David Witten
-//
-//  All rights reserved.
-//
-//  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,
-//  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
-//  along with this program; if not, see <http://www.gnu.org/licenses/>.
-//
-//==========================================================================\r
-#ifndef __FDMDV2_PLOT_SCALAR__
-#define __FDMDV2_PLOT_SCALAR__
-
-\r
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\r
-// Class Scalar\r
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\r
-class Scalar: public DrawPanel\r
-{\r
-public:\r
-\r
-    Scalar(wxFrame* parent, int x, int y, int w, int h, int x_max_, int y_max_, const char name[]);\r
-    ~Scalar();\r
-    void add_new_sample(float sample);\r
-\r
-protected:\r
-\r
-    int    m_x_max;\r
-    int    m_y_max;\r
-    float  *m_mem;              /* array of x_max samples */\r
-    float  m_new_sample;\r
-    int    m_index;\r
-    int    m_step;\r
-\r
-    int clip(int y1);\r
-    void draw();\r
-};\r
-\r
-//// update average of each spectrum point\r
-//void new_data(float mag_dB[])\r
-//{\r
-//    int i;\r
-//\r
-//    for(i=0; i<FDMDV_NSPEC; i++)\r
-//    {\r
-//        av_mag[i] = (1.0 - BETA)*av_mag[i] + BETA*mag_dB[i];\r
-//    }\r
-//}\r
-\r
-#endif // __FDMDV2_PLOT_SCALAR__
-\r