Merge pull request #460 from cjcliffe/develop

Develop
This commit is contained in:
Charles J. Cliffe
2016-11-03 20:37:05 -04:00
committed by GitHub
16 changed files with 393 additions and 84 deletions
+50
View File
@@ -0,0 +1,50 @@
#include "ImagePanel.h"
BEGIN_EVENT_TABLE(ImagePanel, wxPanel)
EVT_PAINT(ImagePanel::paintEvent)
END_EVENT_TABLE()
ImagePanel::ImagePanel(wxPanel * parent, wxString file, wxBitmapType format) :
wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE) {
image.LoadFile(file, format);
}
void ImagePanel::paintEvent(wxPaintEvent & evt) {
wxPaintDC dc(this);
render(dc);
}
void ImagePanel::paintNow() {
wxClientDC dc(this);
render(dc);
}
void ImagePanel::render(wxDC& dc) {
double imagew = image.GetWidth();
double imageh = image.GetHeight();
wxSize destSize = dc.GetSize();
double destw = destSize.GetWidth();
double desth = destSize.GetHeight();
double sf = 1.0, wf, hf;
wf = destw / imagew;
hf = desth / imageh;
sf = (wf < hf)?wf:hf;
double resulth = imageh * sf;
double resultw = imagew * sf;
dc.SetUserScale(sf, sf);
dc.DrawBitmap( image, (destw/2 - resultw/2)/sf, (desth/2 - resulth/2)/sf, false );
}
+16
View File
@@ -0,0 +1,16 @@
#include <wx/wx.h>
#include <wx/sizer.h>
class ImagePanel : public wxPanel {
wxBitmap image;
public:
ImagePanel(wxPanel* parent, wxString file, wxBitmapType format);
void paintEvent(wxPaintEvent & evt);
void paintNow();
void render(wxDC& dc);
DECLARE_EVENT_TABLE()
};
+11 -1
View File
@@ -174,6 +174,14 @@ bool SpectrumCanvas::getShowDb() {
return spectrumPanel.getShowDb();
}
void SpectrumCanvas::setUseDBOfs(bool showDb) {
spectrumPanel.setUseDBOffset(showDb);
}
bool SpectrumCanvas::getUseDBOfs() {
return spectrumPanel.getUseDBOffset();
}
void SpectrumCanvas::setView(long long center_freq_in, int bandwidth_in) {
bwChange += bandwidth_in-bandwidth;
#define BW_RESET_TH 400000
@@ -293,7 +301,9 @@ void SpectrumCanvas::OnMouseRightReleased(wxMouseEvent& event) {
wxGetApp().getSpectrumProcessor()->setPeakHold(wxGetApp().getSpectrumProcessor()->getPeakHold());
//make the peak hold act on the current dmod also, like a zoomed-in version.
wxGetApp().getDemodSpectrumProcessor()->setPeakHold(wxGetApp().getSpectrumProcessor()->getPeakHold());
if (wxGetApp().getDemodSpectrumProcessor()) {
wxGetApp().getDemodSpectrumProcessor()->setPeakHold(wxGetApp().getSpectrumProcessor()->getPeakHold());
}
}
mouseTracker.OnMouseRightReleased(event);
}
+3
View File
@@ -22,6 +22,9 @@ public:
void setShowDb(bool showDb);
bool getShowDb();
void setUseDBOfs(bool showDb);
bool getUseDBOfs();
void setView(long long center_freq_in, int bandwidth_in);
void disableView();