## 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
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
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
$(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(LibPath) $(Libs) $(LinkOptions)\r
\r
$(IntermediateDirectory)/.d:\r
- @$(MakeDirCommand) "./Release"\r
+ @$(MakeDirCommand) "./Debug"\r
\r
PreBuild:\r
\r
$(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
-./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
<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>
.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
--- /dev/null
+//==========================================================================\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__
// 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
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
#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
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
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
}\r
\r
//-------------------------------------------------------------------------\r
-// OnActivate()\r
+// OnShow()\r
//-------------------------------------------------------------------------\r
void PlotPanel::OnShow(wxShowEvent& event)\r
{\r
- paintNow();\r
+ this->Refresh();\r
}\r
\r
//-------------------------------------------------------------------------\r
{\r
if(m_bitmap)\r
{\r
- paintNow();\r
+ this->Refresh();\r
}\r
}\r
\r
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
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
//-------------------------------------------------------------------------\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
// 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
//#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
{\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
--- /dev/null
+//==========================================================================\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
--- /dev/null
+//==========================================================================\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
// 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
//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;
}
//----------------------------------------------------------------\r
-//\r
+// draw()\r
//----------------------------------------------------------------\r
-void PlotScatter::draw()
+void PlotScatter::draw(wxAutoBufferedPaintDC& dc)
{
float x_scale;
float y_scale;
}
//----------------------------------------------------------------\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
+
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\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__
#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
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\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;
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);
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];
}
// 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
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
};
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\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;
}
greyscale = 0;
SetLabelSize(10.0);\r
-// wxSize sz = GetClientSize();
- wxSize sz = GetMaxClientSize();
- new_pixel_buf(sz.GetWidth(), sz.GetHeight());
+ m_Bufsz = GetMaxClientSize();
};
//----------------------------------------------------------------\r
//----------------------------------------------------------------\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
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())))
zoomWaterfallWindow->show();
}
}
-*/\r
return 0;
}
+*/\r
//----------------------------------------------------------------\r
// heatmap()\r
//----------------------------------------------------------------\r
// draw()\r
//----------------------------------------------------------------\r
-void PlotWaterfall::draw()
+void PlotWaterfall::draw(wxAutoBufferedPaintDC& dc)
{
float spec_index_per_px;\r
float intensity_per_dB;
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;
{
for(py = 0; py < dy; py++)
{
- last_row[px + py * m_w] = intensity<<8;
+ last_row[px + py * m_w] = intensity << 8;
}
}
else
}
}
// 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
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
+++ /dev/null
-//==========================================================================\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
-// }
+++ /dev/null
-//==========================================================================\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