16#include "../../../../HitTestResult.h"
20#include "../../../../RefreshCode.h"
21#include "../../../../TrackPanelMouseEvent.h"
23#include "../../../../prefs/SpectrogramSettings.h"
26(
const std::shared_ptr<WaveTrack> &pTrack,
const wxRect &rect,
int y)
27 : mpTrack{ pTrack } , mZoomStart(y), mZoomEnd(y), mRect(rect)
40#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
78 evt, pProject, pParent, pTrack.get(),
mRect,
92 const wxRect &rect,
unsigned iPass )
102 const wxRect &rect,
const wxRect &panelRect,
unsigned iPass )
114 const wxRect &rect,
int zoomStart,
int zoomEnd,
115 bool fixedMousePoint)
118 static const float ZOOMLIMIT = 0.001f;
120 int height = rect.height;
124 if (zoomEnd < zoomStart)
127 float min, max, minBand = 0;
128 const double rate = pTrack->
GetRate();
129 const float halfrate = rate / 2;
130 float maxFreq = 8000.0;
133 const bool spectrumLinear =
139 const int kSpectral = 100;
150 scale = (specSettings.GetScale(
min, max));
151 const auto fftLength = specSettings.GetFFTLength();
152 const float binSize = rate / fftLength;
158 const int minBins = 1;
159 minBand = minBins * binSize;
168 wxFAIL_MSG(
"Zooming Case not implemented by Audacity");
176 min = spectrumLinear ? 0.0f : 1.0f;
186 min = spectrumLinear ? 0.0f : 1.0f;
192 double xmin = 1 - (zoomEnd - ypos) / (
float)height;
193 double xmax = 1 - (zoomStart - ypos) / (
float)height;
194 const float middle = (xmin + xmax) / 2;
197 min = std::max(spectrumLinear ? 0.0f : 1.0f,
202 std::max(middleValue + minBand / 2,
210 const float p1 = (zoomStart - ypos) / (
float)height;
211 const float middle = 1.0f - p1;
214 if (fixedMousePoint) {
215 min = std::max(spectrumLinear ? 0.0f : 1.0f,
216 std::min(middleValue - minBand * middle,
220 std::max(middleValue + minBand * p1,
225 min = std::max(spectrumLinear ? 0.0f : 1.0f,
230 std::max(middleValue + minBand / 2,
239 const float p1 = (zoomStart - ypos) / (
float)height;
246 if (fixedMousePoint) {
261 zoomEnd = zoomStart = 0;
280 for (
int ii = 0, nn =
names.size(); ii < nn; ++ii) {
291 menu.Check(
id,
true);
307 MakeLabel(
XXO(
"Zoom to Fit"),
bVZoom,
XXO(
"Shift-Right-Click") ),
310 MakeLabel(
XXO(
"Zoom In"),
bVZoom,
XXO(
"Left-Click/Left-Drag") ),
313 MakeLabel(
XXO(
"Zoom Out"),
bVZoom,
XXO(
"Shift-Left-Click") ),
@ Internal
Indicates internal failure from Audacity.
XXO("&Cut/Copy/Paste Toolbar")
audacity::BasicSettings * gPrefs
IntSetting SpectrumMaxFreq
AppendItem("Reset", OnZoomResetID, XXO("Zoom Reset"), POPUP_MENU_FN(OnZoomReset))
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
float PositionToValue(float pp) const
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined */
void GetBounds(const WaveTrack &wt, float &min, float &max) const
void SetBounds(float min, float max)
static SpectrogramBounds & Get(WaveTrack &track)
Get either the global default settings, or the track's own if previously created.
static const EnumValueSymbols & GetScaleNames()
static SpectrogramSettings & Get(const WaveTrack &track)
Mutative access to attachment even if the track argument is const.
static SpectrogramSettings & Own(WaveTrack &track)
std::weak_ptr< WaveTrack > mpTrack
SpectrumVZoomHandle(const SpectrumVZoomHandle &)
Result Release(const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
bool HandlesRightClick() override
Whether the handle has any special right-button handling.
void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass) override
Result Drag(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
static void DoZoom(AudacityProject *pProject, WaveTrack *pTrack, WaveChannelViewConstants::ZoomActions ZoomKind, const wxRect &rect, int zoomStart, int zoomEnd, bool fixedMousePoint)
Result Click(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
std::shared_ptr< const Channel > FindChannel() const override
void Enter(bool forward, AudacityProject *) override
wxRect DrawingArea(TrackPanelDrawingContext &, const wxRect &rect, const wxRect &panelRect, unsigned iPass) override
~SpectrumVZoomHandle() override
Result Cancel(AudacityProject *pProject) override
HitTestPreview Preview(const TrackPanelMouseState &state, AudacityProject *pProject) override
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
static TrackList & Get(AudacityProject &project)
A Track that contains audio waveform data.
double GetRate() const override
virtual bool Read(const wxString &key, bool *value) const =0
Namespace containing an enum 'what to do on a refresh?'.
AUDACITY_DLL_API Result DoRelease(const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent, WaveTrack *pTrack, const wxRect &mRect, DoZoomFunction doZoom, PopupMenuTable &table, int zoomStart, int zoomEnd)
AUDACITY_DLL_API Result DoDrag(const TrackPanelMouseEvent &event, AudacityProject *pProject, int zoomStart, int &zoomEnd)
AUDACITY_DLL_API HitTestPreview HitPreview(const wxMouseState &state)
AUDACITY_DLL_API void DoDraw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass, int zoomStart, int zoomEnd)
AUDACITY_DLL_API wxRect DoDrawingArea(const wxRect &rect, const wxRect &panelRect, unsigned iPass)
AUDACITY_DLL_API bool IsDragZooming(int zoomStart, int zoomEnd)
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
AuthorizationHandler handler