1 /********************************************************************** 2 3 Audacity: A Digital Audio Editor 4 5 FreqWindow.h 6 7 Dominic Mazzoni 8 9 **********************************************************************/ 10 11 #ifndef __AUDACITY_FREQ_WINDOW__ 12 #define __AUDACITY_FREQ_WINDOW__ 13 14 #include <vector> 15 #include <wx/font.h> // member variable 16 #include <wx/statusbr.h> // to inherit 17 #include "Prefs.h" 18 #include "SampleFormat.h" 19 #include "SpectrumAnalyst.h" 20 #include "widgets/wxPanelWrapper.h" // to inherit 21 22 class wxMemoryDC; 23 class wxScrollBar; 24 class wxSlider; 25 class wxTextCtrl; 26 class wxButton; 27 class wxCheckBox; 28 class wxChoice; 29 30 class AudacityProject; 31 class FrequencyPlotDialog; 32 class FreqGauge; 33 class RulerPanel; 34 35 DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_FREQWINDOW_RECALC, -1); 36 37 class FreqPlot final : public wxWindow 38 { 39 public: 40 FreqPlot(wxWindow *parent, wxWindowID winid); 41 42 // We don't need or want to accept focus. 43 bool AcceptsFocus() const; 44 45 private: 46 void OnPaint(wxPaintEvent & event); 47 void OnErase(wxEraseEvent & event); 48 void OnMouseEvent(wxMouseEvent & event); 49 50 private: 51 FrequencyPlotDialog *freqWindow; 52 53 DECLARE_EVENT_TABLE() 54 }; 55 56 class FrequencyPlotDialog final : public wxDialogWrapper, 57 public PrefsListener 58 { 59 public: 60 FrequencyPlotDialog(wxWindow *parent, wxWindowID id, 61 AudacityProject &project, 62 const TranslatableString & title, const wxPoint & pos); 63 virtual ~ FrequencyPlotDialog(); 64 65 bool Show( bool show = true ) override; 66 67 private: 68 void Populate(); 69 70 void GetAudio(); 71 72 void PlotMouseEvent(wxMouseEvent & event); 73 void PlotPaint(wxPaintEvent & event); 74 75 void OnCloseWindow(wxCloseEvent & event); 76 void OnCloseButton(wxCommandEvent & event); 77 void OnGetURL(wxCommandEvent & event); 78 void OnSize(wxSizeEvent & event); 79 void OnPanScroller(wxScrollEvent & event); 80 void OnZoomSlider(wxCommandEvent & event); 81 void OnAlgChoice(wxCommandEvent & event); 82 void OnSizeChoice(wxCommandEvent & event); 83 void OnFuncChoice(wxCommandEvent & event); 84 void OnAxisChoice(wxCommandEvent & event); 85 void OnExport(wxCommandEvent & event); 86 void OnReplot(wxCommandEvent & event); 87 void OnGridOnOff(wxCommandEvent & event); 88 void OnRecalc(wxCommandEvent & event); 89 90 void SendRecalcEvent(); 91 void Recalc(); 92 void DrawPlot(); 93 void DrawBackground(wxMemoryDC & dc); 94 95 // PrefsListener implementation 96 void UpdatePrefs() override; 97 98 private: 99 bool mDrawGrid; 100 int mSize; 101 SpectrumAnalyst::Algorithm mAlg; 102 int mFunc; 103 int mAxis; 104 int dBRange; 105 AudacityProject *mProject; 106 107 #ifdef __WXMSW__ 108 static const int fontSize = 8; 109 #else 110 static const int fontSize = 10; 111 #endif 112 113 RulerPanel *vRuler; 114 RulerPanel *hRuler; 115 FreqPlot *mFreqPlot; 116 FreqGauge *mProgress; 117 118 wxRect mPlotRect; 119 120 wxFont mFreqFont; 121 122 std::unique_ptr<wxCursor> mArrowCursor; 123 std::unique_ptr<wxCursor> mCrossCursor; 124 125 wxButton *mCloseButton; 126 wxButton *mExportButton; 127 wxButton *mReplotButton; 128 wxCheckBox *mGridOnOff; 129 wxChoice *mAlgChoice; 130 wxChoice *mSizeChoice; 131 wxChoice *mFuncChoice; 132 wxChoice *mAxisChoice; 133 wxScrollBar *mPanScroller; 134 wxSlider *mZoomSlider; 135 wxTextCtrl *mCursorText; 136 wxTextCtrl *mPeakText; 137 138 139 double mRate; 140 size_t mDataLen; 141 Floats mData; 142 size_t mWindowSize; 143 144 bool mLogAxis; 145 float mYMin; 146 float mYMax; 147 float mYStep; 148 149 std::unique_ptr<wxBitmap> mBitmap; 150 151 int mMouseX; 152 int mMouseY; 153 154 std::unique_ptr<SpectrumAnalyst> mAnalyst; 155 156 DECLARE_EVENT_TABLE() 157 158 friend class FreqPlot; 159 }; 160 161 #endif 162