| 941 | } |
| 942 | |
| 943 | void FrequencyPlotDialog::Recalc() |
| 944 | { |
| 945 | if (!mData || mDataLen < mWindowSize) { |
| 946 | DrawPlot(); |
| 947 | return; |
| 948 | } |
| 949 | |
| 950 | SpectrumAnalyst::Algorithm alg = |
| 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 | } |
| 998 | |
| 999 | void FrequencyPlotDialog::OnExport(wxCommandEvent & WXUNUSED(event)) |
| 1000 | { |
nothing calls this directly
no test coverage detected