2014-10-27 21:22:29 -04:00
|
|
|
#include "AppFrame.h"
|
|
|
|
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/wx.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !wxUSE_GLCANVAS
|
|
|
|
#error "OpenGL required: set wxUSE_GLCANVAS to 1 and rebuild the library"
|
|
|
|
#endif
|
|
|
|
|
2014-10-28 21:39:59 -04:00
|
|
|
#include <vector>
|
|
|
|
#include "SDRThread.h"
|
2014-10-27 21:22:29 -04:00
|
|
|
|
2014-10-28 21:39:59 -04:00
|
|
|
wxBEGIN_EVENT_TABLE(AppFrame, wxFrame)
|
|
|
|
//EVT_MENU(wxID_NEW, AppFrame::OnNewWindow)
|
2014-10-27 21:22:29 -04:00
|
|
|
EVT_MENU(wxID_CLOSE, AppFrame::OnClose)
|
2014-10-28 21:39:59 -04:00
|
|
|
EVT_THREAD(EVENT_SDR_INPUT, AppFrame::OnEventInput)
|
|
|
|
EVT_IDLE(AppFrame::OnIdle)
|
2014-10-27 21:22:29 -04:00
|
|
|
wxEND_EVENT_TABLE()
|
|
|
|
|
|
|
|
AppFrame::AppFrame() :
|
|
|
|
wxFrame(NULL, wxID_ANY, wxT("CubicSDR")) {
|
|
|
|
|
2014-10-28 22:59:17 -04:00
|
|
|
canvas = new TestGLCanvas(this, NULL);
|
2014-10-27 21:22:29 -04:00
|
|
|
|
2014-10-27 23:52:25 -04:00
|
|
|
// SetIcon(wxICON(sample));
|
2014-10-27 21:22:29 -04:00
|
|
|
|
2014-10-28 21:39:59 -04:00
|
|
|
// Make a menubar
|
2014-10-27 21:22:29 -04:00
|
|
|
wxMenu *menu = new wxMenu;
|
|
|
|
// menu->Append(wxID_NEW);
|
|
|
|
// menu->AppendSeparator();
|
|
|
|
menu->Append(wxID_CLOSE);
|
|
|
|
wxMenuBar *menuBar = new wxMenuBar;
|
|
|
|
menuBar->Append(menu, wxT("&File"));
|
|
|
|
|
|
|
|
SetMenuBar(menuBar);
|
|
|
|
|
|
|
|
CreateStatusBar();
|
2014-10-31 01:37:01 -04:00
|
|
|
SetClientSize(1280, 400);
|
|
|
|
Centre();
|
2014-10-27 21:22:29 -04:00
|
|
|
Show();
|
|
|
|
|
2014-11-04 17:25:04 -05:00
|
|
|
|
|
|
|
t_SDR = new SDRThread(appframe);
|
|
|
|
if (t_SDR->Run() != wxTHREAD_NO_ERROR) {
|
|
|
|
wxLogError
|
|
|
|
("Can't create the thread!");
|
|
|
|
delete t_SDR;
|
|
|
|
t_SDR = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
t_IQBuffer = new IQBufferThread(this);
|
|
|
|
if (t_IQBuffer->Run() != wxTHREAD_NO_ERROR) {
|
|
|
|
wxLogError
|
|
|
|
("Can't create the thread!");
|
|
|
|
delete t_IQBuffer;
|
|
|
|
t_IQBuffer = NULL;
|
|
|
|
}
|
|
|
|
|
2014-10-27 21:22:29 -04:00
|
|
|
// static const int attribs[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, 0 };
|
|
|
|
// wxLogStatus("Double-buffered display %s supported", wxGLCanvas::IsDisplaySupported(attribs) ? "is" : "not");
|
|
|
|
// ShowFullScreen(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppFrame::OnClose(wxCommandEvent& WXUNUSED(event)) {
|
2014-11-04 17:25:04 -05:00
|
|
|
|
|
|
|
{
|
|
|
|
wxCriticalSectionLocker enter(m_pThreadCS);
|
|
|
|
if (t_SDR) {
|
|
|
|
wxMessageOutputDebug().Printf("CubicSDR: deleting thread");
|
|
|
|
if (t_SDR->Delete() != wxTHREAD_NO_ERROR) {
|
|
|
|
wxLogError
|
|
|
|
("Can't delete the thread!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
wxCriticalSectionLocker enter(m_pThreadCS);
|
|
|
|
if (t_IQBuffer) {
|
|
|
|
wxMessageOutputDebug().Printf("CubicSDR: deleting thread");
|
|
|
|
if (t_IQBuffer->Delete() != wxTHREAD_NO_ERROR) {
|
|
|
|
wxLogError
|
|
|
|
("Can't delete the thread!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-10-27 21:22:29 -04:00
|
|
|
// true is to force the frame to close
|
|
|
|
Close(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event)) {
|
|
|
|
new AppFrame();
|
|
|
|
}
|
2014-10-28 21:39:59 -04:00
|
|
|
|
|
|
|
void AppFrame::OnEventInput(wxThreadEvent& event) {
|
2014-10-28 22:59:17 -04:00
|
|
|
std::vector<signed char> *new_buffer = event.GetPayload<std::vector<signed char> *>();
|
2014-10-28 21:39:59 -04:00
|
|
|
|
2014-10-28 22:59:17 -04:00
|
|
|
// std::cout << "Got IQ buffer, length: " << new_buffer->size() << std::endl;
|
|
|
|
|
|
|
|
canvas->setData(new_buffer);
|
2014-10-28 21:39:59 -04:00
|
|
|
|
|
|
|
delete new_buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppFrame::OnIdle(wxIdleEvent& event) {
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
}
|