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)
35#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
73 evt, pProject, pParent, pTrack.get(),
mRect,
87 const wxRect &rect,
unsigned iPass )
97 const wxRect &rect,
const wxRect &panelRect,
unsigned iPass )
109 const wxRect &rect,
int zoomStart,
int zoomEnd,
110 bool fixedMousePoint)
113 static const float ZOOMLIMIT = 0.001f;
115 int height = rect.height;
119 if (zoomEnd < zoomStart)
122 float min, max, minBand = 0;
123 const double rate = pTrack->
GetRate();
124 const float halfrate = rate / 2;
125 float maxFreq = 8000.0;
128 const bool spectrumLinear =
134 const int kSpectral = 100;
145 scale = (specSettings.GetScale(
min, max));
146 const auto fftLength = specSettings.GetFFTLength();
147 const float binSize = rate / fftLength;
153 const int minBins = 1;
154 minBand = minBins * binSize;
163 wxFAIL_MSG(
"Zooming Case not implemented by Audacity");
171 min = spectrumLinear ? 0.0f : 1.0f;
181 min = spectrumLinear ? 0.0f : 1.0f;
187 double xmin = 1 - (zoomEnd - ypos) / (
float)height;
188 double xmax = 1 - (zoomStart - ypos) / (
float)height;
189 const float middle = (xmin + xmax) / 2;
192 min = std::max(spectrumLinear ? 0.0f : 1.0f,
197 std::max(middleValue + minBand / 2,
205 const float p1 = (zoomStart - ypos) / (
float)height;
206 const float middle = 1.0f - p1;
209 if (fixedMousePoint) {
210 min = std::max(spectrumLinear ? 0.0f : 1.0f,
211 std::min(middleValue - minBand * middle,
215 std::max(middleValue + minBand * p1,
220 min = std::max(spectrumLinear ? 0.0f : 1.0f,
225 std::max(middleValue + minBand / 2,
234 const float p1 = (zoomStart - ypos) / (
float)height;
241 if (fixedMousePoint) {
257 zoomEnd = zoomStart = 0;
276 for (
int ii = 0, nn =
names.size(); ii < nn; ++ii) {
287 menu.Check(
id,
true);
303 MakeLabel(
XXO(
"Zoom to Fit"),
bVZoom,
XXO(
"Shift-Right-Click") ),
306 MakeLabel(
XXO(
"Zoom In"),
bVZoom,
XXO(
"Left-Click/Left-Drag") ),
309 MakeLabel(
XXO(
"Zoom Out"),
bVZoom,
XXO(
"Shift-Left-Click") ),
@ Internal
Indicates internal failure from Audacity.
XXO("&Cut/Copy/Paste Toolbar")
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)
static void DoZoom(AudacityProject *pProject, WaveTrack *pTrack, WaveTrackViewConstants::ZoomActions ZoomKind, const wxRect &rect, int zoomStart, int zoomEnd, bool fixedMousePoint)
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
Result Click(const TrackPanelMouseEvent &event, AudacityProject *pProject) 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)
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
A Track that contains audio waveform data.
double GetRate() const override
Namespace containing an enum 'what to do on a refresh?'.
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 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 wxRect DoDrawingArea(const wxRect &rect, const wxRect &panelRect, unsigned iPass)
AUDACITY_DLL_API bool IsDragZooming(int zoomStart, int zoomEnd)
AUDACITY_DLL_API Result DoDrag(const TrackPanelMouseEvent &event, AudacityProject *pProject, int zoomStart, int &zoomEnd)
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
AuthorizationHandler handler