ScrollableMagRangeCache Class Reference

A cached set of magnitude range records for a view that scrolls horizontally, such as a spectrogram. More...

#include <ScrollableMagRangeCache.h>

Public Member Functions

 ScrollableMagRangeCache ()
 
void invalidate ()
 
int getWidth () const
 
void resize (int newWidth)
 Set the width of the cache in columns. More...
 
ZoomLevel getZoomLevel () const
 
void setZoomLevel (ZoomLevel zoom)
 Set the zoom level. More...
 
sv_frame_t getStartFrame () const
 
void setStartFrame (sv_frame_t frame)
 Set the start frame. More...
 
bool isColumnSet (int column) const
 
bool areColumnsSet (int x, int count) const
 
MagnitudeRange getRange (int column) const
 Get the magnitude range for a single column. More...
 
MagnitudeRange getRange (int x, int count) const
 Get the magnitude range for a range of columns. More...
 
void scrollTo (const LayerGeometryProvider *v, sv_frame_t newStartFrame)
 Set the new start frame for the cache, according to the geometry of the supplied LayerGeometryProvider, if possible also moving along any existing valid data within the cache so that it continues to be valid for the new start frame. More...
 
void sampleColumn (int column, const MagnitudeRange &r)
 Update a column in the cache, by column index. More...
 

Private Attributes

std::vector< MagnitudeRange > m_ranges
 
sv_frame_t m_startFrame
 
ZoomLevel m_zoomLevel
 

Detailed Description

A cached set of magnitude range records for a view that scrolls horizontally, such as a spectrogram.

The cache object holds a magnitude range per column of the view, can report width (likely the same as the underlying view, but it's the caller's responsibility to set the size appropriately), can scroll the set of ranges, and can report and update which columns have had a range specified.

The only way to update the valid area in a cache is to update the magnitude range for a column using the sampleColumn call.

Definition at line 35 of file ScrollableMagRangeCache.h.

Constructor & Destructor Documentation

ScrollableMagRangeCache::ScrollableMagRangeCache ( )
inline

Definition at line 38 of file ScrollableMagRangeCache.h.

Member Function Documentation

void ScrollableMagRangeCache::invalidate ( )
inline

Definition at line 42 of file ScrollableMagRangeCache.h.

References m_ranges.

Referenced by setStartFrame(), and setZoomLevel().

int ScrollableMagRangeCache::getWidth ( ) const
inline

Definition at line 46 of file ScrollableMagRangeCache.h.

References m_ranges.

Referenced by resize().

void ScrollableMagRangeCache::resize ( int  newWidth)
inline

Set the width of the cache in columns.

If the new size differs from the current size, the cache is invalidated.

Definition at line 54 of file ScrollableMagRangeCache.h.

References getWidth(), and m_ranges.

ZoomLevel ScrollableMagRangeCache::getZoomLevel ( ) const
inline

Definition at line 60 of file ScrollableMagRangeCache.h.

References m_zoomLevel.

void ScrollableMagRangeCache::setZoomLevel ( ZoomLevel  zoom)
inline

Set the zoom level.

If the new zoom level differs from the current one, the cache is invalidated. (Determining whether to invalidate the cache here is the only thing the zoom level is used for.)

Definition at line 70 of file ScrollableMagRangeCache.h.

References invalidate(), and m_zoomLevel.

sv_frame_t ScrollableMagRangeCache::getStartFrame ( ) const
inline

Definition at line 78 of file ScrollableMagRangeCache.h.

References m_startFrame.

void ScrollableMagRangeCache::setStartFrame ( sv_frame_t  frame)
inline

Set the start frame.

If the new start frame differs from the current one, the cache is invalidated. To scroll, i.e. to set the start frame while retaining cache validity where possible, use scrollTo() instead.

Definition at line 88 of file ScrollableMagRangeCache.h.

References invalidate(), and m_startFrame.

bool ScrollableMagRangeCache::isColumnSet ( int  column) const
inline

Definition at line 95 of file ScrollableMagRangeCache.h.

References m_ranges.

Referenced by areColumnsSet().

bool ScrollableMagRangeCache::areColumnsSet ( int  x,
int  count 
) const
inline

Definition at line 99 of file ScrollableMagRangeCache.h.

References isColumnSet().

MagnitudeRange ScrollableMagRangeCache::getRange ( int  column) const
inline

Get the magnitude range for a single column.

Definition at line 109 of file ScrollableMagRangeCache.h.

References m_ranges, sampleColumn(), and scrollTo().

MagnitudeRange ScrollableMagRangeCache::getRange ( int  x,
int  count 
) const

Get the magnitude range for a range of columns.

Definition at line 99 of file ScrollableMagRangeCache.cpp.

void ScrollableMagRangeCache::scrollTo ( const LayerGeometryProvider v,
sv_frame_t  newStartFrame 
)

Set the new start frame for the cache, according to the geometry of the supplied LayerGeometryProvider, if possible also moving along any existing valid data within the cache so that it continues to be valid for the new start frame.

Definition at line 26 of file ScrollableMagRangeCache.cpp.

References LayerGeometryProvider::getXForFrame().

Referenced by getRange().

void ScrollableMagRangeCache::sampleColumn ( int  column,
const MagnitudeRange &  r 
)

Update a column in the cache, by column index.

(Column zero is the first column in the cache, it has nothing to do with any underlying model that the cache may be used with.)

Definition at line 121 of file ScrollableMagRangeCache.cpp.

Referenced by getRange().

Member Data Documentation

std::vector<MagnitudeRange> ScrollableMagRangeCache::m_ranges
private

Definition at line 134 of file ScrollableMagRangeCache.h.

Referenced by getRange(), getWidth(), invalidate(), isColumnSet(), and resize().

sv_frame_t ScrollableMagRangeCache::m_startFrame
private

Definition at line 135 of file ScrollableMagRangeCache.h.

Referenced by getStartFrame(), and setStartFrame().

ZoomLevel ScrollableMagRangeCache::m_zoomLevel
private

Definition at line 136 of file ScrollableMagRangeCache.h.

Referenced by getZoomLevel(), and setZoomLevel().


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