Audacity  3.0.3
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | List of all members
ZoomInfo Class Reference

#include <ZoomInfo.h>

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

Classes

struct  Interval
 

Public Types

enum  FisheyeState { HIDDEN, PINNED, NUM_STATES }
 
typedef std::vector< IntervalIntervals
 

Public Member Functions

 ZoomInfo (double start, double pixelsPerSecond)
 
 ~ZoomInfo ()
 
 ZoomInfo (const ZoomInfo &) PROHIBITED
 
ZoomInfooperator= (const ZoomInfo &) PROHIBITED
 
void UpdatePrefs () override
 
double PositionToTime (wxInt64 position, wxInt64 origin=0, bool ignoreFisheye=false) const
 
wxInt64 TimeToPosition (double time, wxInt64 origin=0, bool ignoreFisheye=false) const
 STM: Converts a project time to screen x position. More...
 
double TimeRangeToPixelWidth (double timeRange) const
 
double OffsetTimeByPixels (double time, wxInt64 offset, bool ignoreFisheye=false) const
 
int GetWidth () const
 
void SetWidth (int width)
 
int GetVRulerWidth () const
 
void SetVRulerWidth (int width)
 
int GetVRulerOffset () const
 
int GetLeftOffset () const
 
int GetTracksUsableWidth () const
 
double GetScreenEndTime () const
 
bool ZoomInAvailable () const
 
bool ZoomOutAvailable () const
 
void SetZoom (double pixelsPerSecond)
 
double GetZoom () const
 
void ZoomBy (double multiplier)
 
void FindIntervals (double rate, Intervals &results, wxInt64 width, wxInt64 origin=0) const
 
FisheyeState GetFisheyeState () const
 
bool InFisheye (wxInt64, wxInt64 WXUNUSED(origin=0)) const
 
wxInt64 GetFisheyeLeftBoundary (wxInt64 WXUNUSED(origin=0)) const
 
wxInt64 GetFisheyeRightBoundary (wxInt64 WXUNUSED(origin=0)) const
 
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()
 

Static Public Member Functions

static double GetDefaultZoom ()
 
static double GetMaxZoom ()
 
static double GetMinZoom ()
 

Public Attributes

int vpos
 
double h
 
float dBr
 
int mWidth { 0 }
 
int mVRulerWidth { 36 }
 

Protected Attributes

double zoom
 

Additional Inherited Members

- Protected Member Functions inherited from PrefsListener
virtual void UpdateSelectedPrefs (int id)
 
 PrefsListener ()
 
virtual ~PrefsListener ()
 
- Static Protected Member Functions inherited from PrefsListener
static void Broadcast (int id=0)
 Call this static function to notify all PrefsListener objects. More...
 

Detailed Description

Definition at line 42 of file ZoomInfo.h.

Member Typedef Documentation

◆ Intervals

typedef std::vector<Interval> ZoomInfo::Intervals

Definition at line 146 of file ZoomInfo.h.

Member Enumeration Documentation

◆ FisheyeState

Enumerator
HIDDEN 
PINNED 
NUM_STATES 

Definition at line 158 of file ZoomInfo.h.

158  {
159  HIDDEN,
160  PINNED,
161 
162  NUM_STATES,
163  };

Constructor & Destructor Documentation

◆ ZoomInfo() [1/2]

ZoomInfo::ZoomInfo ( double  start,
double  pixelsPerSecond 
)

Definition at line 19 of file ZoomInfo.cpp.

20  : vpos(0)
21  , h(start)
22  , zoom(pixelsPerSecond)
23 {
24  UpdatePrefs();
25 }

References UpdatePrefs().

Here is the call graph for this function:

◆ ~ZoomInfo()

ZoomInfo::~ZoomInfo ( )

Definition at line 27 of file ZoomInfo.cpp.

28 {
29 }

◆ ZoomInfo() [2/2]

ZoomInfo::ZoomInfo ( const ZoomInfo )

Member Function Documentation

◆ FindIntervals()

void ZoomInfo::FindIntervals ( double  rate,
Intervals results,
wxInt64  width,
wxInt64  origin = 0 
) const

Definition at line 107 of file ZoomInfo.cpp.

109 {
110  results.clear();
111  results.reserve(2);
112 
113  const wxInt64 rightmost(origin + (0.5 + width));
114  wxASSERT(origin <= rightmost);
115  {
116  results.push_back(Interval(origin, zoom, false));
117  }
118 
119  if (origin < rightmost)
120  results.push_back(Interval(rightmost, 0, false));
121  wxASSERT(!results.empty() && results[0].position == origin);
122 }

References zoom.

Referenced by anonymous_namespace{WaveformView.cpp}::FindWavePortions(), and anonymous_namespace{SampleHandle.cpp}::SampleResolutionTest().

Here is the caller graph for this function:

◆ GetDefaultZoom()

static double ZoomInfo::GetDefaultZoom ( )
inlinestatic

Definition at line 123 of file ZoomInfo.h.

124  { return 44100.0 / 512.0; }

Referenced by anonymous_namespace{ViewMenus.cpp}::GetZoomOfPreset(), ViewActions::Handler::OnZoomNormal(), ZoomHandle::Release(), and TrackPanel::UpdateViewIfNoTracks().

Here is the caller graph for this function:

◆ GetFisheyeLeftBoundary()

wxInt64 ZoomInfo::GetFisheyeLeftBoundary ( wxInt64   WXUNUSEDorigin=0) const
inline

Definition at line 174 of file ZoomInfo.h.

175  {return 0;} // stub

◆ GetFisheyeRightBoundary()

wxInt64 ZoomInfo::GetFisheyeRightBoundary ( wxInt64   WXUNUSEDorigin=0) const
inline

Definition at line 177 of file ZoomInfo.h.

178  {return 0;} // stub

◆ GetFisheyeState()

FisheyeState ZoomInfo::GetFisheyeState ( ) const
inline

Definition at line 164 of file ZoomInfo.h.

165  { return HIDDEN; } // stub

◆ GetLeftOffset()

int ZoomInfo::GetLeftOffset ( ) const
inline

Definition at line 103 of file ZoomInfo.h.

104  { return GetVRulerOffset() + GetVRulerWidth() + 1; }

Referenced by LabelTrackView::DialogForLabelName(), TrackPanel::GetMostRecentXPos(), and TrackPanel::UpdateVRulerSize().

Here is the caller graph for this function:

◆ GetMaxZoom()

double ZoomInfo::GetMaxZoom ( )
static

Definition at line 81 of file ZoomInfo.cpp.

81 { return gMaxZoom;};

References anonymous_namespace{ZoomInfo.cpp}::gMaxZoom.

Referenced by anonymous_namespace{ViewMenus.cpp}::GetZoomOfPreset().

Here is the caller graph for this function:

◆ GetMinZoom()

double ZoomInfo::GetMinZoom ( )
static

Definition at line 82 of file ZoomInfo.cpp.

82 { return gMinZoom;};

References anonymous_namespace{ZoomInfo.cpp}::gMinZoom.

◆ GetScreenEndTime()

double ZoomInfo::GetScreenEndTime ( ) const
inline

Definition at line 114 of file ZoomInfo.h.

115  {
116  auto width = GetTracksUsableWidth();
117  return PositionToTime(width, 0, true);
118  }

Referenced by TrackPanel::HandlePageDownKey(), and TrackPanel::HandlePageUpKey().

Here is the caller graph for this function:

◆ GetTracksUsableWidth()

int ZoomInfo::GetTracksUsableWidth ( ) const
inline

Definition at line 106 of file ZoomInfo.h.

107  {
108  return
109  std::max( 0, GetWidth() - ( GetLeftOffset() + kRightMargin ) );
110  }

References kRightMargin.

◆ GetVRulerOffset()

int ZoomInfo::GetVRulerOffset ( ) const
inline

Definition at line 100 of file ZoomInfo.h.

100 { return kTrackInfoWidth + kLeftMargin; }

References kLeftMargin, and kTrackInfoWidth.

Referenced by TrackPanel::UpdateTrackVRuler().

Here is the caller graph for this function:

◆ GetVRulerWidth()

int ZoomInfo::GetVRulerWidth ( ) const
inline

Definition at line 98 of file ZoomInfo.h.

98 { return mVRulerWidth; }

Referenced by TrackPanel::UpdateTrackVRuler(), and TrackPanel::UpdateVRulerSize().

Here is the caller graph for this function:

◆ GetWidth()

int ZoomInfo::GetWidth ( ) const
inline

Definition at line 95 of file ZoomInfo.h.

95 { return mWidth; }

◆ GetZoom()

double ZoomInfo::GetZoom ( ) const

Definition at line 80 of file ZoomInfo.cpp.

80 { return zoom;};

References zoom.

◆ InFisheye()

bool ZoomInfo::InFisheye ( wxInt64  ,
wxInt64   WXUNUSEDorigin=0 
) const
inline

Definition at line 169 of file ZoomInfo.h.

170  {return false;} // stub

◆ OffsetTimeByPixels()

double ZoomInfo::OffsetTimeByPixels ( double  time,
wxInt64  offset,
bool  ignoreFisheye = false 
) const
inline

Definition at line 90 of file ZoomInfo.h.

91  {
92  return PositionToTime(offset + TimeToPosition(time, ignoreFisheye), ignoreFisheye);
93  }

◆ operator=()

ZoomInfo& ZoomInfo::operator= ( const ZoomInfo )

◆ PositionToTime()

double ZoomInfo::PositionToTime ( wxInt64  position,
wxInt64  origin = 0,
bool  ignoreFisheye = false 
) const

Converts a position (mouse X coordinate) to project time, in seconds. Needs the left edge of the track as an additional parameter.

Definition at line 39 of file ZoomInfo.cpp.

43 {
44  return h + (position - origin) / zoom;
45 }

References h, and zoom.

Referenced by SelectHandle::AdjustSelection(), anonymous_namespace{SelectHandle.cpp}::ChooseBoundary(), ClipParameters::ClipParameters(), CommonTrackPanelCell::DoContextMenu(), TimeShiftHandle::DoSlideVertical(), anonymous_namespace{TimeShiftHandle.cpp}::FindDesiredSlideAmount(), SampleHandle::FindSampleEditingLevel(), TrackPanel::GetMostRecentXPos(), Envelope::GetValues(), LabelGlyphHandle::HandleGlyphDragRelease(), EnvelopeEditor::HandleMouseButtonDown(), anonymous_namespace{SampleHandle.cpp}::IsSampleEditingPossible(), EnvelopeEditor::MoveDragPoint(), AdornedRulerPanel::Pos2Time(), and anonymous_namespace{BrushHandle.cpp}::PositionToLongSample().

Here is the caller graph for this function:

◆ SetVRulerWidth()

void ZoomInfo::SetVRulerWidth ( int  width)
inline

Definition at line 99 of file ZoomInfo.h.

99 { mVRulerWidth = width; }

Referenced by TrackPanel::UpdateVRulerSize().

Here is the caller graph for this function:

◆ SetWidth()

void ZoomInfo::SetWidth ( int  width)
inline

Definition at line 96 of file ZoomInfo.h.

96 { mWidth = width; }

Referenced by TrackPanel::OnSize().

Here is the caller graph for this function:

◆ SetZoom()

void ZoomInfo::SetZoom ( double  pixelsPerSecond)

Definition at line 84 of file ZoomInfo.cpp.

85 {
86  zoom = std::max(gMinZoom, std::min(gMaxZoom, pixelsPerSecond));
87 // DA: Avoids stuck in snap-to
88 #ifdef EXPERIMENTAL_DA
89  // Disable snapping if user zooms in a long way.
90  // Helps stop users be trapped in snap-to.
91  // The level chosen is in sample viewing range with samples
92  // still quite close together.
93  if( zoom > (gMaxZoom * 0.06 ))
94  {
95  AudacityProject * project = GetActiveProject();
96  if( project )
97  project->OnSnapToOff();
98  }
99 #endif
100 }

References GetActiveProject(), anonymous_namespace{ZoomInfo.cpp}::gMaxZoom, anonymous_namespace{ZoomInfo.cpp}::gMinZoom, min(), and zoom.

Referenced by TrackPanel::UpdateViewIfNoTracks(), and ZoomBy().

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

◆ TimeRangeToPixelWidth()

double ZoomInfo::TimeRangeToPixelWidth ( double  timeRange) const

Definition at line 65 of file ZoomInfo.cpp.

66 {
67  return timeRange * zoom;
68 }

References zoom.

◆ TimeToPosition()

wxInt64 ZoomInfo::TimeToPosition ( double  time,
wxInt64  origin = 0,
bool  ignoreFisheye = false 
) const

STM: Converts a project time to screen x position.

Definition at line 49 of file ZoomInfo.cpp.

53 {
54  double t = 0.5 + zoom * (projectTime - h) + origin ;
55  if( t < wxINT64_MIN )
56  return wxINT64_MIN;
57  if( t > wxINT64_MAX )
58  return wxINT64_MAX;
59  t = floor( t );
60  return t;
61 }

References h, and zoom.

Referenced by anonymous_namespace{SelectHandle.cpp}::ChooseTimeBoundary(), ClipParameters::ClipParameters(), LabelTrackView::ComputeLayout(), LabelTrackView::DialogForLabelName(), anonymous_namespace{TimeShiftHandle.cpp}::FindDesiredSlideAmount(), ClipParameters::GetClipRect(), LabelGlyphHandle::HandleGlyphClick(), EnvelopeEditor::HandleMouseButtonDown(), anonymous_namespace{CutlineHandle.cpp}::IsOverCutline(), SnapManager::PixelDiff(), anonymous_namespace{SampleHandle.cpp}::SampleResolutionTest(), SnapManager::Snap(), and AdornedRulerPanel::Time2Pos().

Here is the caller graph for this function:

◆ UpdatePrefs()

void ZoomInfo::UpdatePrefs ( )
overridevirtual

Implements PrefsListener.

Definition at line 31 of file ZoomInfo.cpp.

32 {
34 }

References dBr, DecibelScaleCutoff, and Setting< T >::Read().

Referenced by ViewInfo::UpdatePrefs(), and ZoomInfo().

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

◆ ZoomBy()

void ZoomInfo::ZoomBy ( double  multiplier)

Definition at line 102 of file ZoomInfo.cpp.

103 {
104  SetZoom(zoom * multiplier);
105 }

References SetZoom(), and zoom.

Here is the call graph for this function:

◆ ZoomInAvailable()

bool ZoomInfo::ZoomInAvailable ( ) const

Definition at line 70 of file ZoomInfo.cpp.

71 {
72  return zoom < gMaxZoom;
73 }

References anonymous_namespace{ZoomInfo.cpp}::gMaxZoom, and zoom.

Referenced by ZoomInAvailableFlag().

Here is the caller graph for this function:

◆ ZoomOutAvailable()

bool ZoomInfo::ZoomOutAvailable ( ) const

Definition at line 75 of file ZoomInfo.cpp.

76 {
77  return zoom > gMinZoom;
78 }

References anonymous_namespace{ZoomInfo.cpp}::gMinZoom, and zoom.

Referenced by ZoomOutAvailableFlag().

Here is the caller graph for this function:

Member Data Documentation

◆ dBr

float ZoomInfo::dBr

Definition at line 66 of file ZoomInfo.h.

Referenced by UpdatePrefs().

◆ h

double ZoomInfo::h

◆ mVRulerWidth

int ZoomInfo::mVRulerWidth { 36 }

Definition at line 181 of file ZoomInfo.h.

◆ mWidth

int ZoomInfo::mWidth { 0 }

Definition at line 180 of file ZoomInfo.h.

◆ vpos

int ZoomInfo::vpos

◆ zoom

double ZoomInfo::zoom
protected

The documentation for this class was generated from the following files:
ZoomInfo::vpos
int vpos
Definition: ZoomInfo.h:58
anonymous_namespace{ZoomInfo.cpp}::gMaxZoom
static const double gMaxZoom
Definition: ZoomInfo.cpp:15
ZoomInfo::GetVRulerOffset
int GetVRulerOffset() const
Definition: ZoomInfo.h:100
ZoomInfo::UpdatePrefs
void UpdatePrefs() override
Definition: ZoomInfo.cpp:31
ZoomInfo::GetWidth
int GetWidth() const
Definition: ZoomInfo.h:95
GetActiveProject
AUDACITY_DLL_API std::weak_ptr< AudacityProject > GetActiveProject()
Definition: ActiveProject.cpp:24
ZoomInfo::GetVRulerWidth
int GetVRulerWidth() const
Definition: ZoomInfo.h:98
ZoomInfo::TimeToPosition
wxInt64 TimeToPosition(double time, wxInt64 origin=0, bool ignoreFisheye=false) const
STM: Converts a project time to screen x position.
Definition: ZoomInfo.cpp:49
Setting::Read
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:128
ZoomInfo::GetLeftOffset
int GetLeftOffset() const
Definition: ZoomInfo.h:103
anonymous_namespace{ZoomInfo.cpp}::gMinZoom
static const double gMinZoom
Definition: ZoomInfo.cpp:16
ZoomInfo::mWidth
int mWidth
Definition: ZoomInfo.h:180
ZoomInfo::SetZoom
void SetZoom(double pixelsPerSecond)
Definition: ZoomInfo.cpp:84
ZoomInfo::NUM_STATES
@ NUM_STATES
Definition: ZoomInfo.h:162
ZoomInfo::PINNED
@ PINNED
Definition: ZoomInfo.h:160
ZoomInfo::HIDDEN
@ HIDDEN
Definition: ZoomInfo.h:159
DecibelScaleCutoff
IntSetting DecibelScaleCutoff
Negation of this value is the lowest dB level that should be shown in dB scales.
Definition: Decibels.cpp:12
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
ZoomInfo::mVRulerWidth
int mVRulerWidth
Definition: ZoomInfo.h:181
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
kRightMargin
@ kRightMargin
Definition: ZoomInfo.h:34
ZoomInfo::GetTracksUsableWidth
int GetTracksUsableWidth() const
Definition: ZoomInfo.h:106
ZoomInfo::zoom
double zoom
Definition: ZoomInfo.h:63
kTrackInfoWidth
@ kTrackInfoWidth
Definition: ZoomInfo.h:36
ZoomInfo::dBr
float dBr
Definition: ZoomInfo.h:66
ZoomInfo::h
double h
Definition: ZoomInfo.h:60
kLeftMargin
@ kLeftMargin
Definition: ZoomInfo.h:33
ZoomInfo::PositionToTime
double PositionToTime(wxInt64 position, wxInt64 origin=0, bool ignoreFisheye=false) const
Definition: ZoomInfo.cpp:39