Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
FrequencyPlotDialog Class Referencefinal

Displays a spectrum plot of the waveform. Has options for selecting parameters of the plot. More...

#include <FreqWindow.h>

Inheritance diagram for FrequencyPlotDialog:
[legend]
Collaboration diagram for FrequencyPlotDialog:
[legend]

Public Member Functions

 FrequencyPlotDialog (wxWindow *parent, wxWindowID id, AudacityProject &project, const TranslatableString &title, const wxPoint &pos)
 
virtual ~FrequencyPlotDialog ()
 
bool Show (bool show=true) override
 
- Public Member Functions inherited from PlotSpectrumBase
 PlotSpectrumBase (AudacityProject &project)
 
- Public Member Functions inherited from wxDialogWrapper
 wxDialogWrapper ()
 
 wxDialogWrapper (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
bool Create (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
void SetTitle (const TranslatableString &title)
 
void SetLabel (const TranslatableString &title)
 
void SetName (const TranslatableString &title)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxDialog >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 
- Public Member Functions inherited from PrefsListener
 PrefsListener ()
 
virtual ~PrefsListener ()
 
virtual void UpdatePrefs ()=0
 

Private Member Functions

void Populate ()
 
void PlotMouseEvent (wxMouseEvent &event)
 
void PlotPaint (wxPaintEvent &event)
 
void OnCloseWindow (wxCloseEvent &event)
 
void OnCloseButton (wxCommandEvent &event)
 
void OnGetURL (wxCommandEvent &event)
 
void OnSize (wxSizeEvent &event)
 
void OnPanScroller (wxScrollEvent &event)
 
void OnZoomSlider (wxCommandEvent &event)
 
void OnAlgChoice (wxCommandEvent &event)
 
void OnSizeChoice (wxCommandEvent &event)
 
void OnFuncChoice (wxCommandEvent &event)
 
void OnAxisChoice (wxCommandEvent &event)
 
void OnExport (wxCommandEvent &event)
 
void OnReplot (wxCommandEvent &event)
 
void OnGridOnOff (wxCommandEvent &event)
 
void OnRecalc (wxCommandEvent &event)
 
void SendRecalcEvent ()
 
void Recalc ()
 
void DrawPlot ()
 
void DrawBackground (wxMemoryDC &dc)
 
void UpdatePrefs () override
 

Private Attributes

RulerPanelvRuler
 
RulerPanelhRuler
 
FreqPlotmFreqPlot
 
FreqGaugemProgress
 
wxRect mPlotRect
 
wxFont mFreqFont
 
std::unique_ptr< wxCursor > mArrowCursor
 
std::unique_ptr< wxCursor > mCrossCursor
 
wxButton * mCloseButton
 
wxButton * mExportButton
 
wxButton * mReplotButton
 
wxCheckBox * mGridOnOff
 
wxChoice * mAlgChoice
 
wxChoice * mSizeChoice
 
wxChoice * mFuncChoice
 
wxChoice * mAxisChoice
 
wxScrollBar * mPanScroller
 
wxSlider * mZoomSlider
 
wxTextCtrl * mCursorText
 
wxTextCtrl * mPeakText
 
bool mLogAxis
 
float mYMin
 
float mYMax
 
float mYStep
 
std::unique_ptr< wxBitmap > mBitmap
 
int mMouseX
 
int mMouseY
 

Static Private Attributes

static const int fontSize = 8
 

Friends

class FreqPlot
 

Additional Inherited Members

- Static Public Member Functions inherited from PrefsListener
static void Broadcast (int id=0)
 Call this static function to notify all PrefsListener objects. More...
 
- Protected Member Functions inherited from PlotSpectrumBase
bool GetAudio ()
 
- Protected Member Functions inherited from PrefsListener
virtual void UpdateSelectedPrefs (int id)
 
- Protected Attributes inherited from PlotSpectrumBase
AudacityProjectmProject
 
std::unique_ptr< SpectrumAnalystmAnalyst
 
bool mDrawGrid
 
int mSize
 
SpectrumAnalyst::Algorithm mAlg
 
int mFunc
 
int mAxis
 
int dBRange
 
double mRate
 
size_t mDataLen
 
ArrayOf< float > mData
 
size_t mWindowSize
 

Detailed Description

Displays a spectrum plot of the waveform. Has options for selecting parameters of the plot.

Has a feature that finds peaks and reports their value as you move the mouse around.

Definition at line 54 of file FreqWindow.h.

Constructor & Destructor Documentation

◆ FrequencyPlotDialog()

FrequencyPlotDialog::FrequencyPlotDialog ( wxWindow *  parent,
wxWindowID  id,
AudacityProject project,
const TranslatableString title,
const wxPoint &  pos 
)

Definition at line 187 of file FreqWindow.cpp.

192 parent, id, title, pos, wxDefaultSize,
193 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX)
194{
195 SetName();
196
197 mMouseX = 0;
198 mMouseY = 0;
199
200 Populate();
201}
static const auto title
const auto project

References project.

◆ ~FrequencyPlotDialog()

FrequencyPlotDialog::~FrequencyPlotDialog ( )
virtual

Definition at line 203 of file FreqWindow.cpp.

204{
205}

Member Function Documentation

◆ DrawBackground()

void FrequencyPlotDialog::DrawBackground ( wxMemoryDC &  dc)
private

Definition at line 581 of file FreqWindow.cpp.

582{
583 Layout();
584
585 mBitmap.reset();
586
587 mPlotRect = mFreqPlot->GetClientRect();
588
589 mBitmap = std::make_unique<wxBitmap>(mPlotRect.width, mPlotRect.height,24);
590
591 dc.SelectObject(*mBitmap);
592
593 dc.SetBackground(wxBrush(wxColour(254, 254, 254)));// DONT-THEME Mask colour.
594 dc.Clear();
595
596 dc.SetPen(*wxBLACK_PEN);
597 dc.SetBrush(*wxWHITE_BRUSH);
598 dc.DrawRectangle(mPlotRect);
599
600 dc.SetFont(mFreqFont);
601}
std::unique_ptr< wxBitmap > mBitmap
Definition: FreqWindow.h:133
FreqPlot * mFreqPlot
Definition: FreqWindow.h:105

References mBitmap, mFreqFont, mFreqPlot, and mPlotRect.

Referenced by DrawPlot().

Here is the caller graph for this function:

◆ DrawPlot()

void FrequencyPlotDialog::DrawPlot ( )
private

Definition at line 603 of file FreqWindow.cpp.

604{
605 if (!mData || mDataLen < mWindowSize || mAnalyst->GetProcessedSize() == 0) {
606 wxMemoryDC memDC;
607
610
612 hRuler->ruler.SetRange(0, 1);
613
614 DrawBackground(memDC);
615
616 if (mDataLen < mWindowSize) {
617 wxString msg = _("Not enough data selected.");
618 wxSize sz = memDC.GetTextExtent(msg);
619 memDC.DrawText(msg,
620 (mPlotRect.GetWidth() - sz.GetWidth()) / 2,
621 (mPlotRect.GetHeight() - sz.GetHeight()) / 2);
622 }
623
624 memDC.SelectObject(wxNullBitmap);
625
626 mFreqPlot->Refresh();
627
628 Refresh();
629
630 return;
631 }
632
633 float yRange = mYMax - mYMin;
634 float yTotal = yRange * ((float) mZoomSlider->GetValue() / 100.0f);
635
636 int sTotal = yTotal * 100;
637 int sRange = yRange * 100;
638 int sPos = mPanScroller->GetThumbPosition() + ((mPanScroller->GetThumbSize() - sTotal) / 2);
639 mPanScroller->SetScrollbar(sPos, sTotal, sRange, sTotal);
640
641 float yMax = mYMax - ((float)sPos / 100);
642 float yMin = yMax - yTotal;
643
644 // Set up y axis ruler
645
647 vRuler->ruler.SetUnits(XO("dB"));
649 } else {
650 vRuler->ruler.SetUnits({});
652 }
653 int w1, w2, h;
654 vRuler->ruler.GetMaxSize(&w1, &h);
655 vRuler->ruler.SetRange(yMax, yMin); // Note inversion for vertical.
656 vRuler->ruler.GetMaxSize(&w2, &h);
657 if( w1 != w2 ) // Reduces flicker
658 {
659 vRuler->SetMinSize(wxSize(w2,h));
660 Layout();
661 }
662 vRuler->Refresh(false);
663
664 wxMemoryDC memDC;
665 DrawBackground(memDC);
666
667 // Get the plot dimensions
668 //
669 // Must be done after setting the vertical ruler above since the
670 // the width could change.
671 wxRect r = mPlotRect;
672
673 // Set up x axis ruler
674
675 int width = r.width - 2;
676
677 float xMin, xMax, xRatio, xStep;
678
680 xMin = mRate / mWindowSize;
681 xMax = mRate / 2;
682 xRatio = xMax / xMin;
683 if (mLogAxis)
684 {
685 xStep = pow(2.0f, (log(xRatio) / log(2.0f)) / width);
687 }
688 else
689 {
690 xStep = (xMax - xMin) / width;
692 }
693 hRuler->ruler.SetUnits(XO("Hz"));
694 } else {
695 xMin = 0;
696 xMax = mAnalyst->GetProcessedSize() / mRate;
697 xStep = (xMax - xMin) / width;
699 /* i18n-hint: short form of 'seconds'.*/
700 hRuler->ruler.SetUnits(XO("s"));
701 }
702 hRuler->ruler.SetRange(xMin, xMax-xStep);
703 hRuler->Refresh(false);
704
705 // Draw the plot
707 memDC.SetPen(wxPen(theTheme.Colour( clrHzPlot ), 1, wxPENSTYLE_SOLID));
708 else
709 memDC.SetPen(wxPen(theTheme.Colour( clrWavelengthPlot), 1, wxPENSTYLE_SOLID));
710
711 float xPos = xMin;
712
713 for (int i = 0; i < width; i++) {
714 float y;
715
716 if (mLogAxis)
717 y = mAnalyst->GetProcessedValue(xPos, xPos * xStep);
718 else
719 y = mAnalyst->GetProcessedValue(xPos, xPos + xStep);
720
721 float ynorm = (y - yMin) / yTotal;
722
723 int lineheight = (int)(ynorm * (r.height - 1));
724
725 if (lineheight > r.height - 2)
726 lineheight = r.height - 2;
727
728 if (ynorm > 0.0)
729 AColor::Line(memDC, r.x + 1 + i, r.y + r.height - 1 - lineheight,
730 r.x + 1 + i, r.y + r.height - 1);
731
732 if (mLogAxis)
733 xPos *= xStep;
734 else
735 xPos += xStep;
736 }
737
738 // Outline the graph
739 memDC.SetPen(*wxBLACK_PEN);
740 memDC.SetBrush(*wxTRANSPARENT_BRUSH);
741 memDC.DrawRectangle(r);
742
743 if(mDrawGrid)
744 {
745 hRuler->ruler.DrawGrid(memDC, r.height, true, true, 1, 1);
746 vRuler->ruler.DrawGrid(memDC, r.width, true, true, 1, 1);
747 }
748
749 memDC.SelectObject( wxNullBitmap );
750
751 mFreqPlot->Refresh();
752}
XO("Cut/Copy/Paste")
#define _(s)
Definition: Internat.h:73
THEME_API Theme theTheme
Definition: Theme.cpp:82
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:194
RulerPanel * hRuler
Definition: FreqWindow.h:104
wxSlider * mZoomSlider
Definition: FreqWindow.h:124
RulerPanel * vRuler
Definition: FreqWindow.h:103
void DrawBackground(wxMemoryDC &dc)
Definition: FreqWindow.cpp:581
wxScrollBar * mPanScroller
Definition: FreqWindow.h:123
static const LinearDBFormat & Instance()
static const LinearUpdater & Instance()
static const LogarithmicUpdater & Instance()
std::unique_ptr< SpectrumAnalyst > mAnalyst
SpectrumAnalyst::Algorithm mAlg
ArrayOf< float > mData
static const RealFormat & LinearInstance()
Definition: RealFormat.cpp:14
void DrawGrid(wxDC &dc, int length, bool minor=true, bool major=true, int xOffset=0, int yOffset=0) const
Definition: Ruler.cpp:530
void SetUpdater(const RulerUpdater *pUpdater)
Definition: Ruler.cpp:112
void SetFormat(const RulerFormat *pFormat)
Definition: Ruler.cpp:104
void GetMaxSize(wxCoord *width, wxCoord *height)
Definition: Ruler.cpp:612
void SetUnits(const TranslatableString &units)
Definition: Ruler.cpp:120
void SetRange(double min, double max)
Definition: Ruler.cpp:152
Ruler ruler
Definition: RulerPanel.h:79
wxColour & Colour(int iIndex)

References _, ThemeBase::Colour(), PlotSpectrumBase::dBRange, DrawBackground(), Ruler::DrawGrid(), Ruler::GetMaxSize(), hRuler, LinearDBFormat::Instance(), LinearUpdater::Instance(), LogarithmicUpdater::Instance(), AColor::Line(), RealFormat::LinearInstance(), PlotSpectrumBase::mAlg, PlotSpectrumBase::mAnalyst, PlotSpectrumBase::mData, PlotSpectrumBase::mDataLen, PlotSpectrumBase::mDrawGrid, mFreqPlot, mLogAxis, mPanScroller, mPlotRect, PlotSpectrumBase::mRate, PlotSpectrumBase::mWindowSize, mYMax, mYMin, mZoomSlider, RulerPanel::ruler, Ruler::SetFormat(), Ruler::SetRange(), Ruler::SetUnits(), Ruler::SetUpdater(), SpectrumAnalyst::Spectrum, theTheme, vRuler, and XO().

Referenced by OnAxisChoice(), OnGridOnOff(), OnPanScroller(), OnSize(), OnZoomSlider(), and Recalc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnAlgChoice()

void FrequencyPlotDialog::OnAlgChoice ( wxCommandEvent &  event)
private

Definition at line 780 of file FreqWindow.cpp.

781{
782 mAlg = SpectrumAnalyst::Algorithm(mAlgChoice->GetSelection());
783
784 // Log-frequency axis works for spectrum plots only.
786 mAxisChoice->Enable(true);
787 mLogAxis = mAxisChoice->GetSelection() ? true : false;
788 }
789 else {
790 mAxisChoice->Disable();
791 mLogAxis = false;
792 }
793
795}
wxChoice * mAlgChoice
Definition: FreqWindow.h:119
wxChoice * mAxisChoice
Definition: FreqWindow.h:122

References PlotSpectrumBase::mAlg, mAlgChoice, mAxisChoice, mLogAxis, SendRecalcEvent(), and SpectrumAnalyst::Spectrum.

Here is the call graph for this function:

◆ OnAxisChoice()

void FrequencyPlotDialog::OnAxisChoice ( wxCommandEvent &  event)
private

Definition at line 811 of file FreqWindow.cpp.

812{
813 mLogAxis = mAxisChoice->GetSelection() ? true : false;
814 DrawPlot();
815}

References DrawPlot(), mAxisChoice, and mLogAxis.

Here is the call graph for this function:

◆ OnCloseButton()

void FrequencyPlotDialog::OnCloseButton ( wxCommandEvent &  event)
private

Definition at line 925 of file FreqWindow.cpp.

926{
927 gPrefs->Write(wxT("/FrequencyPlotDialog/DrawGrid"), mDrawGrid);
928 gPrefs->Write(wxT("/FrequencyPlotDialog/SizeChoice"), mSizeChoice->GetSelection());
929 gPrefs->Write(wxT("/FrequencyPlotDialog/AlgChoice"), mAlgChoice->GetSelection());
930 gPrefs->Write(wxT("/FrequencyPlotDialog/FuncChoice"), mFuncChoice->GetSelection());
931 gPrefs->Write(wxT("/FrequencyPlotDialog/AxisChoice"), mAxisChoice->GetSelection());
932 gPrefs->Flush();
933 mData.reset();
934 Show(false);
935}
wxT("CloseDown"))
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
wxChoice * mSizeChoice
Definition: FreqWindow.h:120
wxChoice * mFuncChoice
Definition: FreqWindow.h:121
bool Show(bool show=true) override
Definition: FreqWindow.cpp:545
virtual bool Flush() noexcept=0
virtual bool Write(const wxString &key, bool value)=0

References audacity::BasicSettings::Flush(), gPrefs, mAlgChoice, mAxisChoice, PlotSpectrumBase::mData, PlotSpectrumBase::mDrawGrid, mFuncChoice, mSizeChoice, Show(), audacity::BasicSettings::Write(), and wxT().

Here is the call graph for this function:

◆ OnCloseWindow()

void FrequencyPlotDialog::OnCloseWindow ( wxCloseEvent &  event)
private

Definition at line 920 of file FreqWindow.cpp.

921{
922 Show(false);
923}

References Show().

Here is the call graph for this function:

◆ OnExport()

void FrequencyPlotDialog::OnExport ( wxCommandEvent &  event)
private

Definition at line 999 of file FreqWindow.cpp.

1000{
1001 wxString fName = _("spectrum.txt");
1002
1003 fName = SelectFile(FileNames::Operation::Export,
1004 XO("Export Spectral Data As:"),
1005 wxEmptyString,
1006 fName,
1007 wxT("txt"),
1009 wxFD_SAVE | wxRESIZE_BORDER,
1010 this);
1011
1012 if (fName.empty())
1013 return;
1014
1015 wxFFileOutputStream ffStream{ fName };
1016 if (!ffStream.IsOk()) {
1017 AudacityMessageBox( XO("Couldn't write to file: %s").Format( fName ) );
1018 return;
1019 }
1020
1021 wxTextOutputStream ss(ffStream);
1022
1023 const int processedSize = mAnalyst->GetProcessedSize();
1024 const float *const processed = mAnalyst->GetProcessed();
1025 if (mAlgChoice->GetSelection() == 0) {
1026 ss
1027 << XO("Frequency (Hz)\tLevel (dB)") << '\n';
1028 for (int i = 1; i < processedSize; i++)
1029 ss
1030 << wxString::Format(wxT("%f\t%f\n"),
1031 i * mRate / mWindowSize, processed[i] );
1032 }
1033 else {
1034 ss
1035 << XO("Lag (seconds)\tFrequency (Hz)\tLevel") << '\n';
1036 for (int i = 1; i < processedSize; i++)
1037 ss
1038 << wxString::Format(wxT("%f\t%f\t%f\n"),
1039 i / mRate, mRate / i, processed[i] );
1040 }
1041}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
FilePath SelectFile(FileNames::Operation op, const TranslatableString &message, const FilePath &default_path, const FilePath &default_filename, const FileExtension &default_extension, const FileTypes &fileTypes, int flags, wxWindow *parent)
Definition: SelectFile.cpp:17
FILES_API const FileType AllFiles
Definition: FileNames.h:70
FILES_API const FileType TextFiles
Definition: FileNames.h:73
Abstract base class used in importing a file.

References _, FileNames::AllFiles, AudacityMessageBox(), mAlgChoice, PlotSpectrumBase::mAnalyst, PlotSpectrumBase::mRate, PlotSpectrumBase::mWindowSize, SelectFile(), FileNames::TextFiles, wxT(), and XO().

Here is the call graph for this function:

◆ OnFuncChoice()

void FrequencyPlotDialog::OnFuncChoice ( wxCommandEvent &  event)
private

Definition at line 806 of file FreqWindow.cpp.

807{
809}

References SendRecalcEvent().

Here is the call graph for this function:

◆ OnGetURL()

void FrequencyPlotDialog::OnGetURL ( wxCommandEvent &  event)
private

Definition at line 538 of file FreqWindow.cpp.

539{
540 // Original help page is back on-line (March 2016), but the manual should be more reliable.
541 // http://www.eramp.com/WCAG_2_audio_contrast_tool_help.htm
542 HelpSystem::ShowHelp(this, L"Plot_Spectrum");
543}
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:231

References HelpSystem::ShowHelp().

Here is the call graph for this function:

◆ OnGridOnOff()

void FrequencyPlotDialog::OnGridOnOff ( wxCommandEvent &  event)
private

Definition at line 1052 of file FreqWindow.cpp.

1053{
1054 mDrawGrid = mGridOnOff->IsChecked();
1055
1056 DrawPlot();
1057}
wxCheckBox * mGridOnOff
Definition: FreqWindow.h:118

References DrawPlot(), PlotSpectrumBase::mDrawGrid, and mGridOnOff.

Here is the call graph for this function:

◆ OnPanScroller()

void FrequencyPlotDialog::OnPanScroller ( wxScrollEvent &  event)
private

Definition at line 770 of file FreqWindow.cpp.

771{
772 DrawPlot();
773}

References DrawPlot().

Here is the call graph for this function:

◆ OnRecalc()

void FrequencyPlotDialog::OnRecalc ( wxCommandEvent &  event)
private

Definition at line 1059 of file FreqWindow.cpp.

1060{
1061 Recalc();
1062}

References Recalc().

Here is the call graph for this function:

◆ OnReplot()

void FrequencyPlotDialog::OnReplot ( wxCommandEvent &  event)
private

Definition at line 1043 of file FreqWindow.cpp.

1044{
1046 if(dBRange < 90.)
1047 dBRange = 90.;
1048 GetAudio();
1050}
IntSetting DecibelScaleCutoff
Negation of this value is the lowest dB level that should be shown in dB scales.
Definition: Decibels.cpp:12
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:207

References PlotSpectrumBase::dBRange, DecibelScaleCutoff, PlotSpectrumBase::GetAudio(), Setting< T >::Read(), and SendRecalcEvent().

Here is the call graph for this function:

◆ OnSize()

void FrequencyPlotDialog::OnSize ( wxSizeEvent &  event)
private

Definition at line 572 of file FreqWindow.cpp.

573{
574 Layout();
575
576 DrawPlot();
577
578 Refresh(true);
579}

References DrawPlot().

Here is the call graph for this function:

◆ OnSizeChoice()

void FrequencyPlotDialog::OnSizeChoice ( wxCommandEvent &  event)
private

Definition at line 797 of file FreqWindow.cpp.

798{
799 long windowSize = 0;
800 mSizeChoice->GetStringSelection().ToLong(&windowSize);
801 mWindowSize = windowSize;
802
804}

References mSizeChoice, PlotSpectrumBase::mWindowSize, and SendRecalcEvent().

Here is the call graph for this function:

◆ OnZoomSlider()

void FrequencyPlotDialog::OnZoomSlider ( wxCommandEvent &  event)
private

Definition at line 775 of file FreqWindow.cpp.

776{
777 DrawPlot();
778}

References DrawPlot().

Here is the call graph for this function:

◆ PlotMouseEvent()

void FrequencyPlotDialog::PlotMouseEvent ( wxMouseEvent &  event)
private

Definition at line 755 of file FreqWindow.cpp.

756{
757 if (event.Moving() && (event.m_x != mMouseX || event.m_y != mMouseY)) {
758 mMouseX = event.m_x;
759 mMouseY = event.m_y;
760
761 if (mPlotRect.Contains(mMouseX, mMouseY))
762 mFreqPlot->SetCursor(*mCrossCursor);
763 else
764 mFreqPlot->SetCursor(*mArrowCursor);
765
766 mFreqPlot->Refresh(false);
767 }
768}
std::unique_ptr< wxCursor > mArrowCursor
Definition: FreqWindow.h:112
std::unique_ptr< wxCursor > mCrossCursor
Definition: FreqWindow.h:113

References mArrowCursor, mCrossCursor, mFreqPlot, mMouseX, mMouseY, and mPlotRect.

Referenced by FreqPlot::OnMouseEvent().

Here is the caller graph for this function:

◆ PlotPaint()

void FrequencyPlotDialog::PlotPaint ( wxPaintEvent &  event)
private

Definition at line 817 of file FreqWindow.cpp.

818{
819 wxPaintDC dc( (wxWindow *) event.GetEventObject() );
820
821 dc.DrawBitmap( *mBitmap, 0, 0, true );
822 // Fix for Bug 1226 "Plot Spectrum freezes... if insufficient samples selected"
823 if (!mData || mDataLen < mWindowSize)
824 return;
825
826 dc.SetFont(mFreqFont);
827
828 wxRect r = mPlotRect;
829
830 int width = r.width - 2;
831
832 float xMin, xMax, xRatio, xStep;
833
835 xMin = mRate / mWindowSize;
836 xMax = mRate / 2;
837 xRatio = xMax / xMin;
838 if (mLogAxis)
839 xStep = pow(2.0f, (log(xRatio) / log(2.0f)) / width);
840 else
841 xStep = (xMax - xMin) / width;
842 } else {
843 xMin = 0;
844 xMax = mAnalyst->GetProcessedSize() / mRate;
845 xStep = (xMax - xMin) / width;
846 }
847
848 float xPos = xMin;
849
850 // Find the peak nearest the cursor and plot it
851 if ( r.Contains(mMouseX, mMouseY) && (mMouseX!=0) && (mMouseX!=r.width-1) ) {
852 if (mLogAxis)
853 xPos = xMin * pow(xStep, mMouseX - (r.x + 1));
854 else
855 xPos = xMin + xStep * (mMouseX - (r.x + 1));
856
857 float bestValue = 0;
858 float bestpeak = mAnalyst->FindPeak(xPos, &bestValue);
859
860 int px;
861 if (mLogAxis)
862 px = (int)(log(bestpeak / xMin) / log(xStep));
863 else
864 px = (int)((bestpeak - xMin) * width / (xMax - xMin));
865
866 dc.SetPen(wxPen(wxColour(255, 32, 32), 1, wxPENSTYLE_SOLID));
867 AColor::Line(dc, r.x + 1 + px, r.y, r.x + 1 + px, r.y + r.height);
868
869 // print out info about the cursor location
870
871 float value;
872
873 if (mLogAxis) {
874 xPos = xMin * pow(xStep, mMouseX - (r.x + 1));
875 value = mAnalyst->GetProcessedValue(xPos, xPos * xStep);
876 } else {
877 xPos = xMin + xStep * (mMouseX - (r.x + 1));
878 value = mAnalyst->GetProcessedValue(xPos, xPos + xStep);
879 }
880
881 TranslatableString cursor;
883
885 auto xp = PitchName_Absolute(FreqToMIDInote(xPos));
886 auto pp = PitchName_Absolute(FreqToMIDInote(bestpeak));
887 /* i18n-hint: The %d's are replaced by numbers, the %s by musical notes, e.g. A#*/
888 cursor = XO("%d Hz (%s) = %d dB")
889 .Format( (int)(xPos + 0.5), xp, (int)(value + 0.5));
890 /* i18n-hint: The %d's are replaced by numbers, the %s by musical notes, e.g. A#*/
891 peak = XO("%d Hz (%s) = %.1f dB")
892 .Format( (int)(bestpeak + 0.5), pp, bestValue );
893 } else if (xPos > 0.0 && bestpeak > 0.0) {
894 auto xp = PitchName_Absolute(FreqToMIDInote(1.0 / xPos));
895 auto pp = PitchName_Absolute(FreqToMIDInote(1.0 / bestpeak));
896 /* i18n-hint: The %d's are replaced by numbers, the %s by musical notes, e.g. A#
897 * the %.4f are numbers, and 'sec' should be an abbreviation for seconds */
898 cursor = XO("%.4f sec (%d Hz) (%s) = %f")
899 .Format( xPos, (int)(1.0 / xPos + 0.5), xp, value );
900 /* i18n-hint: The %d's are replaced by numbers, the %s by musical notes, e.g. A#
901 * the %.4f are numbers, and 'sec' should be an abbreviation for seconds */
902 peak = XO("%.4f sec (%d Hz) (%s) = %.3f")
903 .Format( bestpeak, (int)(1.0 / bestpeak + 0.5), pp, bestValue );
904 }
905 mCursorText->SetValue( cursor.Translation() );
906 mPeakText->SetValue( peak.Translation() );
907 }
908 else {
909 mCursorText->SetValue(wxT(""));
910 mPeakText->SetValue(wxT(""));
911 }
912
913
914 // Outline the graph
915 dc.SetPen(*wxBLACK_PEN);
916 dc.SetBrush(*wxTRANSPARENT_BRUSH);
917 dc.DrawRectangle(r);
918}
TranslatableString PitchName_Absolute(const double dMIDInote, const PitchNameChoice choice)
Definition: PitchName.cpp:148
double FreqToMIDInote(const double freq)
Definition: PitchName.cpp:23
wxTextCtrl * mCursorText
Definition: FreqWindow.h:125
wxTextCtrl * mPeakText
Definition: FreqWindow.h:126
Holds a msgid for the translation catalog; may also bind format arguments.
wxString Translation() const

References FreqToMIDInote(), AColor::Line(), PlotSpectrumBase::mAlg, PlotSpectrumBase::mAnalyst, mBitmap, mCursorText, PlotSpectrumBase::mData, PlotSpectrumBase::mDataLen, mFreqFont, mLogAxis, mMouseX, mMouseY, mPeakText, mPlotRect, PlotSpectrumBase::mRate, PlotSpectrumBase::mWindowSize, PitchName_Absolute(), SpectrumAnalyst::Spectrum, TranslatableString::Translation(), wxT(), and XO().

Referenced by FreqPlot::OnPaint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Populate()

void FrequencyPlotDialog::Populate ( )
private

Definition at line 207 of file FreqWindow.cpp.

208{
210
211 TranslatableStrings algChoices{
212 XO("Spectrum") ,
213 XO("Standard Autocorrelation") ,
214 XO("Cuberoot Autocorrelation") ,
215 XO("Enhanced Autocorrelation") ,
216 /* i18n-hint: This is a technical term, derived from the word
217 * "spectrum". Do not translate it unless you are sure you
218 * know the correct technical word in your language. */
219 XO("Cepstrum") ,
220 };
221
222 TranslatableStrings sizeChoices{
223 Verbatim( "128" ) ,
224 Verbatim( "256" ) ,
225 Verbatim( "512" ) ,
226 Verbatim( "1024" ) ,
227 Verbatim( "2048" ) ,
228 Verbatim( "4096" ) ,
229 Verbatim( "8192" ) ,
230 Verbatim( "16384" ) ,
231 Verbatim( "32768" ) ,
232 Verbatim( "65536" ) ,
233 Verbatim( "131072" ) ,
234 };
235
236 TranslatableStrings funcChoices;
237 for (int i = 0, cnt = NumWindowFuncs(); i < cnt; i++)
238 {
239 funcChoices.push_back(
240 /* i18n-hint: This refers to a "window function",
241 * such as Hann or Rectangular, used in the
242 * Frequency analyze dialog box. */
243 XO("%s window").Format( WindowFuncName(i) ) );
244 }
245
246 TranslatableStrings axisChoices{
247 XO("Linear frequency") ,
248 XO("Log frequency") ,
249 };
250
251 mFreqFont = wxFont(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
252 mArrowCursor = std::make_unique<wxCursor>(wxCURSOR_ARROW);
253 mCrossCursor = std::make_unique<wxCursor>(wxCURSOR_CROSS);
254
255 long size;
256 // reinterpret one of the verbatim strings above as a number
257 sizeChoices[mSize].MSGID().GET().ToLong(&size);
259
261 if(dBRange < 90.)
262 dBRange = 90.;
263
264 ShuttleGui S(this, eIsCreating);
265
266 S.SetBorder(0);
267
268 S.AddSpace(5);
269
270 S.SetSizerProportion(1);
271 S.StartMultiColumn(3, wxEXPAND);
272 {
273 S.SetStretchyCol(1);
274 S.SetStretchyRow(0);
275
276 // -------------------------------------------------------------------
277 // ROW 1: Freq response panel and sliders for vertical scale
278 // -------------------------------------------------------------------
279
280 S.StartVerticalLay(2);
281 {
283 S.GetParent(), wxID_ANY, wxVERTICAL,
284 wxSize{ 100, 100 }, // Ruler can't handle small sizes
285 RulerPanel::Range{ 0.0, -dBRange },
287 XO("dB"),
289 .LabelEdges(true)
290 .TickColour( theTheme.Colour( clrGraphLabels ) )
291 );
292
293 S.AddSpace(wxDefaultCoord, 1);
294 S.Prop(1)
295 .Position(wxALIGN_RIGHT | wxALIGN_TOP)
296 .AddWindow(vRuler);
297 S.AddSpace(wxDefaultCoord, 1);
298 }
299 S.EndVerticalLay();
300
301 mFreqPlot = safenew FreqPlot(S.GetParent(), wxID_ANY);
302 S.Prop(1)
303 .Position(wxEXPAND)
304 .MinSize( { wxDefaultCoord, FREQ_WINDOW_HEIGHT } )
305 .AddWindow(mFreqPlot);
306
307 S.StartHorizontalLay(wxEXPAND, 0);
308 {
309 S.StartVerticalLay();
310 {
311 mPanScroller = safenew wxScrollBar(S.GetParent(), FreqPanScrollerID,
312 wxDefaultPosition, wxDefaultSize, wxSB_VERTICAL);
313#if wxUSE_ACCESSIBILITY
314 // so that name can be set on a standard control
316#endif
317 S.Prop(1);
318 S
319 .Name(XO("Scroll"))
320 .Position( wxALIGN_LEFT | wxTOP)
321 .AddWindow(mPanScroller);
322 }
323 S.EndVerticalLay();
324
325 S.StartVerticalLay();
326 {
327 wxStaticBitmap *zi = safenew wxStaticBitmap(S.GetParent(), wxID_ANY, wxBitmap(ZoomIn));
328 S.Position(wxALIGN_CENTER)
329 .AddWindow(zi);
330
331 S.AddSpace(5);
332
333 mZoomSlider = safenew wxSliderWrapper(S.GetParent(), FreqZoomSliderID, 100, 1, 100,
334 wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL);
335 S.Prop(1);
336 S
337 .Name(XO("Zoom"))
338 .Position(wxALIGN_CENTER_HORIZONTAL)
339 .AddWindow(mZoomSlider);
340#if wxUSE_ACCESSIBILITY
341 // so that name can be set on a standard control
343#endif
344
345 S.AddSpace(5);
346
347 wxStaticBitmap *zo = safenew wxStaticBitmap(S.GetParent(), wxID_ANY, wxBitmap(ZoomOut));
348 S.Position(wxALIGN_CENTER)
349 .AddWindow(zo);
350 }
351 S.EndVerticalLay();
352
353 S.AddSpace(5, wxDefaultCoord);
354 }
355 S.EndHorizontalLay();
356
357 // -------------------------------------------------------------------
358 // ROW 2: Frequency ruler
359 // -------------------------------------------------------------------
360
361 S.AddSpace(1);
362
363 S.StartHorizontalLay(wxEXPAND, 0);
364 {
366 S.GetParent(), wxID_ANY, wxHORIZONTAL,
367 wxSize{ 100, 100 }, // Ruler can't handle small sizes
368 RulerPanel::Range{ 10, 20000 },
370 XO("Hz"),
372 .Log(true)
373 .Flip(true)
374 .LabelEdges(true)
375 .TickColour( theTheme.Colour( clrGraphLabels ) )
376 );
377
378 S.AddSpace(1, wxDefaultCoord);
379 S.Prop(1)
380 .Position(wxALIGN_LEFT | wxALIGN_TOP)
381 .AddWindow(hRuler);
382 S.AddSpace(1, wxDefaultCoord);
383 }
384 S.EndHorizontalLay();
385
386 S.AddSpace(1);
387
388 // -------------------------------------------------------------------
389 // ROW 3: Spacer
390 // -------------------------------------------------------------------
391
392 S.AddSpace(5);
393 S.AddSpace(5);
394 S.AddSpace(5);
395
396 // -------------------------------------------------------------------
397 // ROW 4: Info
398 // -------------------------------------------------------------------
399
400 S.AddSpace(1);
401
402 S.StartHorizontalLay(wxEXPAND);
403 {
404 S.SetSizerProportion(1);
405 S.StartMultiColumn(6);
406 S.SetStretchyCol(1);
407 S.SetStretchyCol(3);
408 {
409 S.AddPrompt(XXO("Cursor:"));
410
411 mCursorText = S.Style(wxTE_READONLY)
412 .AddTextBox( {}, wxT(""), 10);
413
414 S.AddPrompt(XXO("Peak:"));
415
416 mPeakText = S.Style(wxTE_READONLY)
417 .AddTextBox( {}, wxT(""), 10);
418 S.AddSpace(5);
419
420 mGridOnOff = S.Id(GridOnOffID).AddCheckBox(XXO("&Grids"), mDrawGrid);
421 }
422 S.EndMultiColumn();
423 }
424 S.EndHorizontalLay();
425
426 S.AddSpace(1);
427 }
428 S.EndMultiColumn();
429
430 // -------------------------------------------------------------------
431 // ROW 5: Spacer
432 // -------------------------------------------------------------------
433
434 S.AddSpace(5);
435
436 S.SetBorder(2);
437 S.SetSizerProportion(0);
438 S.StartMultiColumn(9, wxALIGN_CENTER);
439 {
440 // ----------------------------------------------------------------
441 // ROW 6: Algorithm, Size, Export, Replot
442 // ----------------------------------------------------------------
443
444 S.AddSpace(5);
445
446 mAlgChoice = S.Id(FreqAlgChoiceID).Focus()
447 .MinSize( { wxDefaultCoord, wxDefaultCoord } )
448 .AddChoice(XXO("&Algorithm:"), algChoices, mAlg);
449
450 S.AddSpace(5);
451
453 .MinSize( { wxDefaultCoord, wxDefaultCoord } )
454 .AddChoice(XXO("&Size:"), sizeChoices, mSize);
455
456 S.AddSpace(5);
457
458 mExportButton = S.Id(FreqExportButtonID).AddButton(XXO("&Export..."));
459
460 S.AddSpace(5);
461
462 // ----------------------------------------------------------------
463 // ROW 7: Function, Axis, Grids, Close
464 // ----------------------------------------------------------------
465
466 S.AddSpace(5);
467
469 .MinSize( { wxDefaultCoord, wxDefaultCoord } )
470 .AddChoice(XXO("&Function:"), funcChoices, mFunc);
471 mFuncChoice->MoveAfterInTabOrder(mSizeChoice);
472
473 S.AddSpace(5);
474
476 .MinSize( { wxDefaultCoord, wxDefaultCoord } )
477 .AddChoice(XXO("&Axis:"), axisChoices, mAxis);
478 mAxisChoice->MoveAfterInTabOrder(mFuncChoice);
479
480 S.AddSpace(5);
481
482 mReplotButton = S.Id(ReplotButtonID).AddButton(XXO("&Replot..."));
483
484 S.AddSpace(5);
485
486 //mCloseButton = S.Id(wxID_CANCEL).AddButton(XO("&Close"));
487
488 //S.AddSpace(5);
489 }
490 S.EndMultiColumn();
491 S.AddStandardButtons( eHelpButton | eCloseButton );
492
493 // -------------------------------------------------------------------
494 // ROW 8: Spacer
495 // -------------------------------------------------------------------
496
497 S.AddSpace(5);
498
499 mProgress = safenew FreqGauge(S.GetParent(), wxID_ANY); //, wxST_SIZEGRIP);
500 S.Position(wxEXPAND)
501 .AddWindow(mProgress);
502
503 // Log-frequency axis works for spectrum plots only.
505 {
506 mAxis = 0;
507 mAxisChoice->Disable();
508 }
509 mLogAxis = mAxis != 0;
510
511 mCloseButton = static_cast<wxButton*>(FindWindowById( wxID_CANCEL ));
512 mCloseButton->SetDefault();
513
514 Layout();
515 Fit();
516 // Bug 1607:
517 Center();
518
519 SetMinSize(GetSize());
520
521#if defined(__WXGTK__)
522 // This should be rechecked with wx3.
523 //
524 // The scrollbar (focus some reason) doesn't allow tabbing past it
525 // because it can't receive focus. So, convince it otherwise.
526 //
527 // Unfortunately, this still doesn't let you adjust the scrollbar
528 // from the keyboard. Near as I can tell, wxWGTK is capturing the
529 // keyboard input, so the GTK widget doesn't see it, preventing
530 // the normal scroll events from being generated.
531 //
532 // I guess the only way round it would be to handle key actions
533 // ourselves, but we'll leave that for a future date.
534// gtk_widget_set_can_focus(mPanScroller->m_widget, true);
535#endif
536}
int NumWindowFuncs()
Definition: FFT.cpp:327
const TranslatableString WindowFuncName(int whichFunction)
Definition: FFT.cpp:332
#define FrequencyAnalysisTitle
Definition: FreqWindow.cpp:95
static const char * ZoomOut[]
Definition: FreqWindow.cpp:143
#define FREQ_WINDOW_HEIGHT
Definition: FreqWindow.cpp:116
@ FreqAxisChoiceID
Definition: FreqWindow.cpp:108
@ FreqFuncChoiceID
Definition: FreqWindow.cpp:107
@ FreqPanScrollerID
Definition: FreqWindow.cpp:103
@ FreqExportButtonID
Definition: FreqWindow.cpp:104
@ ReplotButtonID
Definition: FreqWindow.cpp:109
@ FreqAlgChoiceID
Definition: FreqWindow.cpp:105
@ FreqSizeChoiceID
Definition: FreqWindow.cpp:106
@ FreqZoomSliderID
Definition: FreqWindow.cpp:102
@ GridOnOffID
Definition: FreqWindow.cpp:110
static const char * ZoomIn[]
Definition: FreqWindow.cpp:118
XXO("&Cut/Copy/Paste Toolbar")
#define safenew
Definition: MemoryX.h:10
@ eIsCreating
Definition: ShuttleGui.h:37
@ eCloseButton
Definition: ShuttleGui.h:619
@ eHelpButton
Definition: ShuttleGui.h:613
#define S(N)
Definition: ToChars.cpp:64
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
std::vector< TranslatableString > TranslatableStrings
friend class FreqPlot
Definition: FreqWindow.h:140
wxButton * mExportButton
Definition: FreqWindow.h:116
wxButton * mReplotButton
Definition: FreqWindow.h:117
static const int fontSize
Definition: FreqWindow.h:98
FreqGauge * mProgress
Definition: FreqWindow.h:106
wxButton * mCloseButton
Definition: FreqWindow.h:115
RulerPanel class allows you to work with a Ruler like any other wxWindow.
Definition: RulerPanel.h:19
std::pair< double, double > Range
Definition: RulerPanel.h:23
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
void SetTitle(const TranslatableString &title)
Options & LabelEdges(bool l)
Definition: RulerPanel.h:41
Options & Log(bool l)
Definition: RulerPanel.h:35

References ThemeBase::Colour(), PlotSpectrumBase::dBRange, DecibelScaleCutoff, eCloseButton, eHelpButton, eIsCreating, fontSize, FREQ_WINDOW_HEIGHT, FreqAlgChoiceID, FreqAxisChoiceID, FreqExportButtonID, FreqFuncChoiceID, FreqPanScrollerID, FreqPlot, FreqSizeChoiceID, FrequencyAnalysisTitle, FreqZoomSliderID, GridOnOffID, hRuler, LinearDBFormat::Instance(), RulerPanel::Options::LabelEdges(), RealFormat::LinearInstance(), RulerPanel::Options::Log(), PlotSpectrumBase::mAlg, mAlgChoice, mArrowCursor, PlotSpectrumBase::mAxis, mAxisChoice, mCloseButton, mCrossCursor, mCursorText, PlotSpectrumBase::mDrawGrid, mExportButton, mFreqFont, mFreqPlot, PlotSpectrumBase::mFunc, mFuncChoice, mGridOnOff, mLogAxis, mPanScroller, mPeakText, mProgress, mReplotButton, PlotSpectrumBase::mSize, mSizeChoice, PlotSpectrumBase::mWindowSize, mZoomSlider, NumWindowFuncs(), Setting< T >::Read(), ReplotButtonID, S, safenew, wxDialogWrapper::SetTitle(), size, SpectrumAnalyst::Spectrum, theTheme, Verbatim(), vRuler, WindowFuncName(), wxT(), XO(), XXO(), ZoomIn, and ZoomOut.

Referenced by UpdatePrefs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Recalc()

void FrequencyPlotDialog::Recalc ( )
private

Definition at line 943 of file FreqWindow.cpp.

944{
945 if (!mData || mDataLen < mWindowSize) {
946 DrawPlot();
947 return;
948 }
949
951 SpectrumAnalyst::Algorithm(mAlgChoice->GetSelection());
952 int windowFunc = mFuncChoice->GetSelection();
953
954 wxWindow *hadFocus = FindFocus();
955 // In wxMac, the skipped window MUST be a top level window. I'd originally made it
956 // just the mProgress window with the idea of preventing user interaction with the
957 // controls while the plot was being recalculated. This doesn't appear to be necessary
958 // so just use the top level window instead.
959 {
960 std::optional<wxWindowDisabler> blocker;
961 if (IsShown())
962 blocker.emplace(this);
963 wxYieldIfNeeded();
964
965 auto first = true;
966 auto progress = [&](long long num, long long den) {
967 if (first) {
968 mProgress->SetRange(den);
969 first = false;
970 }
971 mProgress->SetValue(num);
972 };
973
974 mAnalyst->Calculate(alg, windowFunc, mWindowSize, mRate,
975 mData.get(), mDataLen,
976 &mYMin, &mYMax, std::move(progress));
977
978 mProgress->Reset();
979 }
980 if (hadFocus) {
981 hadFocus->SetFocus();
982 }
983
984 if (alg == SpectrumAnalyst::Spectrum) {
985 if(mYMin < -dBRange)
986 mYMin = -dBRange;
987 if(mYMax <= -dBRange)
988 mYMax = -dBRange + 10.; // it's all out of range, but show a scale.
989 else
990 mYMax += .5;
991 }
992
993 // Prime the scrollbar
994 mPanScroller->SetScrollbar(0, (mYMax - mYMin) * 100, (mYMax - mYMin) * 100, 1);
995
996 DrawPlot();
997}
void SetRange(int range, int bar=12, int gap=3)
Definition: FreqGauge.cpp:27
void Reset()
Definition: FreqGauge.cpp:64
void SetValue(int value)
Definition: FreqGauge.cpp:44
std::unique_ptr< WindowPlacement > FindFocus()
Find the window that is accepting keyboard input, if any.
Definition: BasicUI.h:383

References PlotSpectrumBase::dBRange, DrawPlot(), BasicUI::FindFocus(), mAlgChoice, PlotSpectrumBase::mAnalyst, PlotSpectrumBase::mData, PlotSpectrumBase::mDataLen, mFuncChoice, mPanScroller, mProgress, PlotSpectrumBase::mRate, PlotSpectrumBase::mWindowSize, mYMax, mYMin, FreqGauge::Reset(), FreqGauge::SetRange(), FreqGauge::SetValue(), and SpectrumAnalyst::Spectrum.

Referenced by OnRecalc(), and Show().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SendRecalcEvent()

void FrequencyPlotDialog::SendRecalcEvent ( )
private

Definition at line 937 of file FreqWindow.cpp.

938{
939 wxCommandEvent e(EVT_FREQWINDOW_RECALC, wxID_ANY);
940 GetEventHandler()->AddPendingEvent(e);
941}

Referenced by OnAlgChoice(), OnFuncChoice(), OnReplot(), and OnSizeChoice().

Here is the caller graph for this function:

◆ Show()

bool FrequencyPlotDialog::Show ( bool  show = true)
override

Definition at line 545 of file FreqWindow.cpp.

546{
547 if (!show)
548 {
549 mFreqPlot->SetCursor(*mArrowCursor);
550 }
551
552 bool shown = IsShown();
553
554 if (show && !shown)
555 {
557 if(dBRange < 90.)
558 dBRange = 90.;
559 if (!GetAudio())
560 return false;
561 // Don't send an event. We need the recalc right away.
562 // so that mAnalyst is valid when we paint.
563 //SendRecalcEvent();
564 Recalc();
565 }
566
567 bool res = wxDialogWrapper::Show(show);
568
569 return res;
570}
IMPORT_EXPORT_API ExportResult Show(ExportTask exportTask)

References PlotSpectrumBase::dBRange, DecibelScaleCutoff, PlotSpectrumBase::GetAudio(), mArrowCursor, mFreqPlot, Setting< T >::Read(), Recalc(), and ExportProgressUI::Show().

Referenced by OnCloseButton(), OnCloseWindow(), anonymous_namespace{FreqWindow.cpp}::OnPlotSpectrum(), and UpdatePrefs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdatePrefs()

void FrequencyPlotDialog::UpdatePrefs ( )
overrideprivatevirtual

Implements PrefsListener.

Definition at line 1064 of file FreqWindow.cpp.

1065{
1066 bool shown = IsShown();
1067 if (shown) {
1068 Show(false);
1069 }
1070
1071 auto zoomSlider = mZoomSlider->GetValue();
1072 auto drawGrid = mGridOnOff->GetValue();
1073 auto sizeChoice = mSizeChoice->GetStringSelection();
1074 auto algChoice = mAlgChoice->GetSelection();
1075 auto funcChoice = mFuncChoice->GetSelection();
1076 auto axisChoice = mAxisChoice->GetSelection();
1077
1078 SetSizer(nullptr);
1079 DestroyChildren();
1080
1081 Populate();
1082
1083 mZoomSlider->SetValue(zoomSlider);
1084
1085 mDrawGrid = drawGrid;
1086 mGridOnOff->SetValue(drawGrid);
1087
1088 long windowSize = 0;
1089 sizeChoice.ToLong(&windowSize);
1090 mWindowSize = windowSize;
1091 mSizeChoice->SetStringSelection(sizeChoice);
1092
1093 mAlg = static_cast<SpectrumAnalyst::Algorithm>(algChoice);
1094 mAlgChoice->SetSelection(algChoice);
1095
1096 mFunc = funcChoice;
1097 mFuncChoice->SetSelection(funcChoice);
1098
1099 mAxis = axisChoice;
1100 mAxisChoice->SetSelection(axisChoice);
1101
1102 if (shown) {
1103 Show(true);
1104 }
1105}

References PlotSpectrumBase::mAlg, mAlgChoice, PlotSpectrumBase::mAxis, mAxisChoice, PlotSpectrumBase::mDrawGrid, PlotSpectrumBase::mFunc, mFuncChoice, mGridOnOff, mSizeChoice, PlotSpectrumBase::mWindowSize, mZoomSlider, Populate(), and Show().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ FreqPlot

friend class FreqPlot
friend

Definition at line 140 of file FreqWindow.h.

Referenced by Populate().

Member Data Documentation

◆ fontSize

const int FrequencyPlotDialog::fontSize = 8
staticprivate

Definition at line 98 of file FreqWindow.h.

Referenced by Populate().

◆ hRuler

RulerPanel* FrequencyPlotDialog::hRuler
private

Definition at line 104 of file FreqWindow.h.

Referenced by DrawPlot(), and Populate().

◆ mAlgChoice

wxChoice* FrequencyPlotDialog::mAlgChoice
private

Definition at line 119 of file FreqWindow.h.

Referenced by OnAlgChoice(), OnCloseButton(), OnExport(), Populate(), Recalc(), and UpdatePrefs().

◆ mArrowCursor

std::unique_ptr<wxCursor> FrequencyPlotDialog::mArrowCursor
private

Definition at line 112 of file FreqWindow.h.

Referenced by PlotMouseEvent(), Populate(), and Show().

◆ mAxisChoice

wxChoice* FrequencyPlotDialog::mAxisChoice
private

Definition at line 122 of file FreqWindow.h.

Referenced by OnAlgChoice(), OnAxisChoice(), OnCloseButton(), Populate(), and UpdatePrefs().

◆ mBitmap

std::unique_ptr<wxBitmap> FrequencyPlotDialog::mBitmap
private

Definition at line 133 of file FreqWindow.h.

Referenced by DrawBackground(), and PlotPaint().

◆ mCloseButton

wxButton* FrequencyPlotDialog::mCloseButton
private

Definition at line 115 of file FreqWindow.h.

Referenced by Populate().

◆ mCrossCursor

std::unique_ptr<wxCursor> FrequencyPlotDialog::mCrossCursor
private

Definition at line 113 of file FreqWindow.h.

Referenced by PlotMouseEvent(), and Populate().

◆ mCursorText

wxTextCtrl* FrequencyPlotDialog::mCursorText
private

Definition at line 125 of file FreqWindow.h.

Referenced by PlotPaint(), and Populate().

◆ mExportButton

wxButton* FrequencyPlotDialog::mExportButton
private

Definition at line 116 of file FreqWindow.h.

Referenced by Populate().

◆ mFreqFont

wxFont FrequencyPlotDialog::mFreqFont
private

Definition at line 110 of file FreqWindow.h.

Referenced by DrawBackground(), PlotPaint(), and Populate().

◆ mFreqPlot

FreqPlot* FrequencyPlotDialog::mFreqPlot
private

Definition at line 105 of file FreqWindow.h.

Referenced by DrawBackground(), DrawPlot(), PlotMouseEvent(), Populate(), and Show().

◆ mFuncChoice

wxChoice* FrequencyPlotDialog::mFuncChoice
private

Definition at line 121 of file FreqWindow.h.

Referenced by OnCloseButton(), Populate(), Recalc(), and UpdatePrefs().

◆ mGridOnOff

wxCheckBox* FrequencyPlotDialog::mGridOnOff
private

Definition at line 118 of file FreqWindow.h.

Referenced by OnGridOnOff(), Populate(), and UpdatePrefs().

◆ mLogAxis

bool FrequencyPlotDialog::mLogAxis
private

Definition at line 128 of file FreqWindow.h.

Referenced by DrawPlot(), OnAlgChoice(), OnAxisChoice(), PlotPaint(), and Populate().

◆ mMouseX

int FrequencyPlotDialog::mMouseX
private

Definition at line 135 of file FreqWindow.h.

Referenced by PlotMouseEvent(), and PlotPaint().

◆ mMouseY

int FrequencyPlotDialog::mMouseY
private

Definition at line 136 of file FreqWindow.h.

Referenced by PlotMouseEvent(), and PlotPaint().

◆ mPanScroller

wxScrollBar* FrequencyPlotDialog::mPanScroller
private

Definition at line 123 of file FreqWindow.h.

Referenced by DrawPlot(), Populate(), and Recalc().

◆ mPeakText

wxTextCtrl* FrequencyPlotDialog::mPeakText
private

Definition at line 126 of file FreqWindow.h.

Referenced by PlotPaint(), and Populate().

◆ mPlotRect

wxRect FrequencyPlotDialog::mPlotRect
private

Definition at line 108 of file FreqWindow.h.

Referenced by DrawBackground(), DrawPlot(), PlotMouseEvent(), and PlotPaint().

◆ mProgress

FreqGauge* FrequencyPlotDialog::mProgress
private

Definition at line 106 of file FreqWindow.h.

Referenced by Populate(), and Recalc().

◆ mReplotButton

wxButton* FrequencyPlotDialog::mReplotButton
private

Definition at line 117 of file FreqWindow.h.

Referenced by Populate().

◆ mSizeChoice

wxChoice* FrequencyPlotDialog::mSizeChoice
private

Definition at line 120 of file FreqWindow.h.

Referenced by OnCloseButton(), OnSizeChoice(), Populate(), and UpdatePrefs().

◆ mYMax

float FrequencyPlotDialog::mYMax
private

Definition at line 130 of file FreqWindow.h.

Referenced by DrawPlot(), and Recalc().

◆ mYMin

float FrequencyPlotDialog::mYMin
private

Definition at line 129 of file FreqWindow.h.

Referenced by DrawPlot(), and Recalc().

◆ mYStep

float FrequencyPlotDialog::mYStep
private

Definition at line 131 of file FreqWindow.h.

◆ mZoomSlider

wxSlider* FrequencyPlotDialog::mZoomSlider
private

Definition at line 124 of file FreqWindow.h.

Referenced by DrawPlot(), Populate(), and UpdatePrefs().

◆ vRuler

RulerPanel* FrequencyPlotDialog::vRuler
private

Definition at line 103 of file FreqWindow.h.

Referenced by DrawPlot(), and Populate().


The documentation for this class was generated from the following files: