#include <ViewProxy.h>

Inheritance diagram for ViewProxy:
Inheritance graph
Collaboration diagram for ViewProxy:
Collaboration graph

Public Member Functions

 ViewProxy (View *view, int scaleFactor)
 Create a standard ViewProxy for the given view, mapping using the given scale factor. More...
 
 ViewProxy (View *view, int scaleFactor, ModelId alignment)
 Create a re-aligning ViewProxy for the given view, mapping using the given scale factor. More...
 
int getId () const override
 Retrieve the id of this object. More...
 
sv_frame_t getStartFrame () const override
 Retrieve the first visible sample frame on the widget. More...
 
sv_frame_t getCentreFrame () const override
 Return the centre frame of the visible widget. More...
 
sv_frame_t getEndFrame () const override
 Retrieve the last visible sample frame on the widget. More...
 
int getXForFrame (sv_frame_t frame) const override
 Return the pixel x-coordinate corresponding to a given sample frame (which may be negative). More...
 
sv_frame_t getFrameForX (int x) const override
 Return the closest frame to the given pixel x-coordinate. More...
 
int getXForViewX (int viewx) const override
 Return the closest pixel x-coordinate corresponding to a given view x-coordinate. More...
 
int getViewXForX (int x) const override
 Return the closest view x-coordinate corresponding to a given pixel x-coordinate. More...
 
sv_frame_t getModelsStartFrame () const override
 
sv_frame_t getModelsEndFrame () const override
 
double getYForFrequency (double frequency, double minFreq, double maxFreq, bool logarithmic) const override
 Return the (maybe fractional) pixel y-coordinate corresponding to a given frequency, if the frequency range is as specified. More...
 
double getFrequencyForY (double y, double minFreq, double maxFreq, bool logarithmic) const override
 Return the closest frequency to the given (maybe fractional) pixel y-coordinate, if the frequency range is as specified. More...
 
int getTextLabelYCoord (const Layer *layer, QPainter &paint) const override
 Return a y-coordinate at which text labels for individual items in a layer may be drawn, so as not to overlap with those of other layers. More...
 
bool getVisibleExtentsForUnit (QString unit, double &min, double &max, bool &log) const override
 Return the visible vertical extents for the given unit, if any. More...
 
ZoomLevel getZoomLevel () const override
 Return the zoom level, i.e. More...
 
QRect getPaintRect () const override
 To be called from a layer, to obtain the extent of the surface that the layer is currently painting to. More...
 
QSize getPaintSize () const override
 
int getPaintWidth () const override
 
int getPaintHeight () const override
 
bool hasLightBackground () const override
 
QColor getForeground () const override
 
QColor getBackground () const override
 
ViewManagergetViewManager () const override
 
bool shouldIlluminateLocalFeatures (const Layer *layer, QPoint &point) const override
 
bool shouldShowFeatureLabels () const override
 
void drawMeasurementRect (QPainter &p, const Layer *layer, QRect rect, bool focus) const override
 
void updatePaintRect (QRect r) override
 
double scaleSize (double size) const override
 Scale up a size in pixels for a hi-dpi display without pixel doubling. More...
 
int scalePixelSize (int size) const override
 Integer version of scaleSize. More...
 
double scalePenWidth (double width) const override
 Scale up pen width for a hi-dpi display without pixel doubling. More...
 
QPen scalePen (QPen pen) const override
 Apply scalePenWidth to a pen. More...
 
ViewgetView () override
 
const ViewgetView () const override
 

Static Protected Member Functions

static int getNextId ()
 

Private Member Functions

sv_frame_t alignToReference (sv_frame_t frame) const
 
sv_frame_t alignFromReference (sv_frame_t frame) const
 

Private Attributes

Viewm_view
 
int m_scaleFactor
 
ModelId m_alignment
 

Detailed Description

Definition at line 22 of file ViewProxy.h.

Constructor & Destructor Documentation

ViewProxy::ViewProxy ( View view,
int  scaleFactor 
)
inline

Create a standard ViewProxy for the given view, mapping using the given scale factor.

The scale factor is generally used with pixel-doubled "retina" Mac displays and is usually 1 elsewhere.

Definition at line 30 of file ViewProxy.h.

ViewProxy::ViewProxy ( View view,
int  scaleFactor,
ModelId  alignment 
)
inline

Create a re-aligning ViewProxy for the given view, mapping using the given scale factor.

The scale factor is generally used with pixel-doubled "retina" Mac displays and is usually 1 elsewhere.

Coordinates are mapped through the given alignment model, such that frame values passed from the caller are mapped "from reference" by that alignment before being used by the view or converted to pixel coordinates, and returned values are mapped back "to reference" before being passed back to the caller.

This form of proxy may be created specially for rendering a single layer which comes from a different alignment to that of the rest of the containing view.

Definition at line 49 of file ViewProxy.h.

Member Function Documentation

int ViewProxy::getId ( ) const
inlineoverridevirtual

Retrieve the id of this object.

Implements LayerGeometryProvider.

Definition at line 52 of file ViewProxy.h.

References View::getId(), and m_view.

sv_frame_t ViewProxy::getStartFrame ( ) const
inlineoverridevirtual

Retrieve the first visible sample frame on the widget.

This is a calculated value based on the centre-frame, widget width and zoom level. The result may be negative.

Implements LayerGeometryProvider.

Definition at line 55 of file ViewProxy.h.

References alignToReference(), View::getStartFrame(), and m_view.

sv_frame_t ViewProxy::getCentreFrame ( ) const
inlineoverridevirtual

Return the centre frame of the visible widget.

This is an exact value that does not depend on the zoom block size. Other frame values (start, end) are calculated from this based on the zoom and other factors.

Implements LayerGeometryProvider.

Definition at line 58 of file ViewProxy.h.

References alignToReference(), View::getCentreFrame(), and m_view.

sv_frame_t ViewProxy::getEndFrame ( ) const
inlineoverridevirtual

Retrieve the last visible sample frame on the widget.

This is a calculated value based on the centre-frame, widget width and zoom level.

Implements LayerGeometryProvider.

Definition at line 61 of file ViewProxy.h.

References alignToReference(), View::getEndFrame(), and m_view.

int ViewProxy::getXForFrame ( sv_frame_t  frame) const
inlineoverridevirtual

Return the pixel x-coordinate corresponding to a given sample frame (which may be negative).

!! not actually correct, if frame lies between view's pixels

Implements LayerGeometryProvider.

Definition at line 64 of file ViewProxy.h.

References alignFromReference(), View::getXForFrame(), m_scaleFactor, and m_view.

sv_frame_t ViewProxy::getFrameForX ( int  x) const
inlineoverridevirtual

Return the closest frame to the given pixel x-coordinate.

Implements LayerGeometryProvider.

Definition at line 68 of file ViewProxy.h.

References alignToReference(), View::getFrameForX(), m_scaleFactor, and m_view.

int ViewProxy::getXForViewX ( int  viewx) const
inlineoverridevirtual

Return the closest pixel x-coordinate corresponding to a given view x-coordinate.

Implements LayerGeometryProvider.

Definition at line 75 of file ViewProxy.h.

References m_scaleFactor.

int ViewProxy::getViewXForX ( int  x) const
inlineoverridevirtual

Return the closest view x-coordinate corresponding to a given pixel x-coordinate.

Implements LayerGeometryProvider.

Definition at line 78 of file ViewProxy.h.

References m_scaleFactor.

sv_frame_t ViewProxy::getModelsStartFrame ( ) const
inlineoverridevirtual

Implements LayerGeometryProvider.

Definition at line 81 of file ViewProxy.h.

References alignToReference(), View::getModelsStartFrame(), and m_view.

sv_frame_t ViewProxy::getModelsEndFrame ( ) const
inlineoverridevirtual

Implements LayerGeometryProvider.

Definition at line 84 of file ViewProxy.h.

References alignToReference(), View::getModelsEndFrame(), and m_view.

double ViewProxy::getYForFrequency ( double  frequency,
double  minFreq,
double  maxFreq,
bool  logarithmic 
) const
inlineoverridevirtual

Return the (maybe fractional) pixel y-coordinate corresponding to a given frequency, if the frequency range is as specified.

This does not imply any policy about layer frequency ranges, but it might be useful for layers to match theirs up if desired.

Not thread-safe in logarithmic mode. Call only from GUI thread.

Implements LayerGeometryProvider.

Definition at line 87 of file ViewProxy.h.

References View::getYForFrequency(), m_scaleFactor, and m_view.

double ViewProxy::getFrequencyForY ( double  y,
double  minFreq,
double  maxFreq,
bool  logarithmic 
) const
inlineoverridevirtual

Return the closest frequency to the given (maybe fractional) pixel y-coordinate, if the frequency range is as specified.

Not thread-safe in logarithmic mode. Call only from GUI thread.

Implements LayerGeometryProvider.

Definition at line 93 of file ViewProxy.h.

References View::getFrequencyForY(), m_scaleFactor, and m_view.

int ViewProxy::getTextLabelYCoord ( const Layer layer,
QPainter &   
) const
inlineoverridevirtual

Return a y-coordinate at which text labels for individual items in a layer may be drawn, so as not to overlap with those of other layers.

The returned coordinate will be near the top of the visible widget, but adjusted downward depending on how many other visible layers return true from their implementation of Layer::needsTextLabelHeight().

Implements LayerGeometryProvider.

Definition at line 98 of file ViewProxy.h.

References View::getTextLabelYCoord(), m_scaleFactor, and m_view.

bool ViewProxy::getVisibleExtentsForUnit ( QString  unit,
double &  min,
double &  max,
bool &  log 
) const
inlineoverridevirtual

Return the visible vertical extents for the given unit, if any.

That is:

  • if at least one non-dormant layer uses the same unit and returns some values from its getDisplayExtents() method, return the extents from the topmost of those
  • otherwise, if at least one non-dormant layer uses the same unit, return the union of the value extents of all of those
  • otherwise return false

Implements LayerGeometryProvider.

Definition at line 101 of file ViewProxy.h.

References View::getVisibleExtentsForUnit(), and m_view.

ZoomLevel ViewProxy::getZoomLevel ( ) const
inlineoverridevirtual

Return the zoom level, i.e.

the number of frames per pixel or pixels per frame

Implements LayerGeometryProvider.

Definition at line 105 of file ViewProxy.h.

References View::getZoomLevel(), m_scaleFactor, and m_view.

QRect ViewProxy::getPaintRect ( ) const
inlineoverridevirtual

To be called from a layer, to obtain the extent of the surface that the layer is currently painting to.

This may be the extent of the view (if 1x display scaling is in effect) or of a larger cached pixmap (if greater display scaling is in effect).

Implements LayerGeometryProvider.

Definition at line 117 of file ViewProxy.h.

References View::getPaintRect(), m_scaleFactor, and m_view.

Referenced by getPaintHeight(), getPaintSize(), and getPaintWidth().

QSize ViewProxy::getPaintSize ( ) const
inlineoverridevirtual

Reimplemented from LayerGeometryProvider.

Definition at line 124 of file ViewProxy.h.

References getPaintRect().

int ViewProxy::getPaintWidth ( ) const
inlineoverridevirtual

Reimplemented from LayerGeometryProvider.

Definition at line 127 of file ViewProxy.h.

References getPaintRect().

int ViewProxy::getPaintHeight ( ) const
inlineoverridevirtual

Reimplemented from LayerGeometryProvider.

Definition at line 130 of file ViewProxy.h.

References getPaintRect().

bool ViewProxy::hasLightBackground ( ) const
inlineoverridevirtual

Implements LayerGeometryProvider.

Definition at line 133 of file ViewProxy.h.

References View::hasLightBackground(), and m_view.

QColor ViewProxy::getForeground ( ) const
inlineoverridevirtual

Implements LayerGeometryProvider.

Definition at line 136 of file ViewProxy.h.

References View::getForeground(), and m_view.

QColor ViewProxy::getBackground ( ) const
inlineoverridevirtual

Implements LayerGeometryProvider.

Definition at line 139 of file ViewProxy.h.

References View::getBackground(), and m_view.

ViewManager* ViewProxy::getViewManager ( ) const
inlineoverridevirtual

Implements LayerGeometryProvider.

Definition at line 142 of file ViewProxy.h.

References View::getViewManager(), and m_view.

bool ViewProxy::shouldIlluminateLocalFeatures ( const Layer layer,
QPoint &  point 
) const
inlineoverridevirtual

Implements LayerGeometryProvider.

Definition at line 146 of file ViewProxy.h.

References m_scaleFactor, m_view, and View::shouldIlluminateLocalFeatures().

bool ViewProxy::shouldShowFeatureLabels ( ) const
inlineoverridevirtual

Implements LayerGeometryProvider.

Definition at line 154 of file ViewProxy.h.

References m_view, and View::shouldShowFeatureLabels().

void ViewProxy::drawMeasurementRect ( QPainter &  p,
const Layer layer,
QRect  rect,
bool  focus 
) const
inlineoverridevirtual

Implements LayerGeometryProvider.

Definition at line 158 of file ViewProxy.h.

References View::drawMeasurementRect(), and m_view.

void ViewProxy::updatePaintRect ( QRect  r)
inlineoverridevirtual

Implements LayerGeometryProvider.

Definition at line 163 of file ViewProxy.h.

References m_scaleFactor, and m_view.

double ViewProxy::scaleSize ( double  size) const
inlineoverridevirtual

Scale up a size in pixels for a hi-dpi display without pixel doubling.

This is like ViewManager::scalePixelSize, but taking and returning floating-point values rather than integer pixels. It is also a little more conservative - it never shrinks the size, it can only increase or leave it unchanged.

Implements LayerGeometryProvider.

Definition at line 177 of file ViewProxy.h.

References m_scaleFactor, m_view, and View::scaleSize().

int ViewProxy::scalePixelSize ( int  size) const
inlineoverridevirtual

Integer version of scaleSize.

Implements LayerGeometryProvider.

Definition at line 184 of file ViewProxy.h.

References m_scaleFactor, m_view, and View::scalePixelSize().

double ViewProxy::scalePenWidth ( double  width) const
inlineoverridevirtual

Scale up pen width for a hi-dpi display without pixel doubling.

This is like scaleSize except that it also scales the zero-width case.

Implements LayerGeometryProvider.

Definition at line 193 of file ViewProxy.h.

References m_scaleFactor, m_view, and View::scalePenWidth().

Referenced by scalePen().

QPen ViewProxy::scalePen ( QPen  pen) const
inlineoverridevirtual

Apply scalePenWidth to a pen.

Implements LayerGeometryProvider.

Definition at line 204 of file ViewProxy.h.

References scalePenWidth().

View* ViewProxy::getView ( )
inlineoverridevirtual

Implements LayerGeometryProvider.

Definition at line 208 of file ViewProxy.h.

References m_view.

const View* ViewProxy::getView ( ) const
inlineoverridevirtual

Implements LayerGeometryProvider.

Definition at line 209 of file ViewProxy.h.

References m_view.

sv_frame_t ViewProxy::alignToReference ( sv_frame_t  frame) const
inlineprivate
sv_frame_t ViewProxy::alignFromReference ( sv_frame_t  frame) const
inlineprivate

Definition at line 224 of file ViewProxy.h.

Referenced by getXForFrame().

static int LayerGeometryProvider::getNextId ( )
inlinestaticprotectedinherited

Definition at line 48 of file LayerGeometryProvider.h.

Member Data Documentation

ModelId ViewProxy::m_alignment
private

Definition at line 214 of file ViewProxy.h.


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