#include <Colour3DPlotRenderer.h>

Collaboration diagram for Colour3DPlotRenderer:
Collaboration graph

Classes

struct  Parameters
 
struct  RenderResult
 
struct  Sources
 

Public Member Functions

 Colour3DPlotRenderer (Sources sources, Parameters parameters)
 
RenderResult render (const LayerGeometryProvider *v, QPainter &paint, QRect rect)
 Render the requested area using the given painter, obtaining geometry (e.g. More...
 
RenderResult renderTimeConstrained (const LayerGeometryProvider *v, QPainter &paint, QRect rect)
 Render the requested area using the given painter, obtaining geometry (e.g. More...
 
QRect getLargestUncachedRect (const LayerGeometryProvider *v)
 Return the area of the largest rectangle within the entire area of the cache that is unavailable in the cache. More...
 
bool geometryChanged (const LayerGeometryProvider *v)
 Return true if the provider's geometry differs from the cache, or if we are not using a cache. More...
 
bool willRenderOpaque (const LayerGeometryProvider *v)
 Return true if the rendering will be opaque. More...
 
QColor getColour (double value) const
 Return the colour corresponding to the given value. More...
 
QRect findSimilarRegionExtents (QPoint point) const
 Return the enclosing rectangle for the region of similar colour to the given point within the cache. More...
 

Private Types

enum  RenderType { DrawBufferPixelResolution, DrawBufferBinResolution, DirectTranslucent }
 

Private Member Functions

RenderResult render (const LayerGeometryProvider *v, QPainter &paint, QRect rect, bool timeConstrained)
 
MagnitudeRange renderDirectTranslucent (const LayerGeometryProvider *v, QPainter &paint, QRect rect)
 
void renderToCachePixelResolution (const LayerGeometryProvider *v, int x0, int repaintWidth, bool rightToLeft, bool timeConstrained)
 
void renderToCacheBinResolution (const LayerGeometryProvider *v, int x0, int repaintWidth)
 
int renderDrawBuffer (int w, int h, const std::vector< int > &binforx, const std::vector< double > &binfory, int peakCacheIndex, bool rightToLeft, bool timeConstrained)
 
int renderDrawBufferPeakFrequencies (const LayerGeometryProvider *v, int w, int h, const std::vector< int > &binforx, const std::vector< double > &binfory, bool rightToLeft, bool timeConstrained)
 
void recreateDrawBuffer (int w, int h)
 
void clearDrawBuffer (int w, int h)
 
RenderType decideRenderType (const LayerGeometryProvider *) const
 
QImage scaleDrawBufferImage (QImage source, int targetWidth, int targetHeight) const
 
ColumnOp::Column getColumn (int sx, int minbin, int nbins, std::shared_ptr< DenseThreeDimensionalModel > source) const
 
ColumnOp::Column getColumnRaw (int sx, int minbin, int nbins, std::shared_ptr< DenseThreeDimensionalModel > source) const
 
void getPreferredPeakCache (const LayerGeometryProvider *, int &peakCacheIndex, int &binsPerPeak) const
 
void updateTimings (const RenderTimer &timer, int xPixelCount)
 

Private Attributes

Sources m_sources
 
Parameters m_params
 
QImage m_drawBuffer
 
std::vector< MagnitudeRange > m_magRanges
 
ScrollableImageCache m_cache
 
ScrollableMagRangeCache m_magCache
 
double m_secondsPerXPixel
 
bool m_secondsPerXPixelValid
 

Detailed Description

Definition at line 49 of file Colour3DPlotRenderer.h.

Member Enumeration Documentation

Enumerator
DrawBufferPixelResolution 
DrawBufferBinResolution 
DirectTranslucent 

Definition at line 315 of file Colour3DPlotRenderer.h.

Constructor & Destructor Documentation

Colour3DPlotRenderer::Colour3DPlotRenderer ( Sources  sources,
Parameters  parameters 
)
inline

Definition at line 119 of file Colour3DPlotRenderer.h.

Member Function Documentation

Colour3DPlotRenderer::RenderResult Colour3DPlotRenderer::render ( const LayerGeometryProvider v,
QPainter &  paint,
QRect  rect 
)

Render the requested area using the given painter, obtaining geometry (e.g.

start frame) from the given LayerGeometryProvider.

The whole of the supplied rect will be rendered and the returned QRect will be equal to the supplied QRect. (See renderTimeConstrained for an alternative that may render only part of the rect in cases where obtaining source data is slow and retaining responsiveness is important.)

Note that Colour3DPlotRenderer retains internal cache state related to the size and position of the supplied LayerGeometryProvider. Although it is valid to call render() successively on the same Colour3DPlotRenderer with different LayerGeometryProviders, it will be much faster to use a dedicated Colour3DPlotRenderer for each LayerGeometryProvider.

If the model to render from is not ready, this will throw a std::logic_error exception. The model must be ready and the layer requesting the render must not be dormant in its view, so that the LayerGeometryProvider returns valid results; it is the caller's responsibility to ensure these.

Definition at line 44 of file Colour3DPlotRenderer.cpp.

Referenced by Colour3DPlotLayer::paintWithRenderer(), and SpectrogramLayer::paintWithRenderer().

Colour3DPlotRenderer::RenderResult Colour3DPlotRenderer::renderTimeConstrained ( const LayerGeometryProvider v,
QPainter &  paint,
QRect  rect 
)

Render the requested area using the given painter, obtaining geometry (e.g.

start frame) from the stored LayerGeometryProvider.

As much of the rect will be rendered as can be managed given internal time constraints (using a RenderTimer object internally). The returned QRect (the rendered field in the RenderResult struct) will contain the area that was rendered. Note that we always render the full requested height, it's only width that is time-constrained.

Note that Colour3DPlotRenderer retains internal cache state related to the size and position of the supplied LayerGeometryProvider. Although it is valid to call render() successively on the same Colour3DPlotRenderer with different LayerGeometryProviders, it will be much faster to use a dedicated Colour3DPlotRenderer for each LayerGeometryProvider.

If the model to render from is not ready, this will throw a std::logic_error exception. The model must be ready and the layer requesting the render must not be dormant in its view, so that the LayerGeometryProvider returns valid results; it is the caller's responsibility to ensure these.

Definition at line 50 of file Colour3DPlotRenderer.cpp.

Referenced by Colour3DPlotLayer::paintWithRenderer(), and SpectrogramLayer::paintWithRenderer().

QRect Colour3DPlotRenderer::getLargestUncachedRect ( const LayerGeometryProvider v)

Return the area of the largest rectangle within the entire area of the cache that is unavailable in the cache.

This is only valid in relation to a preceding render() call which is presumed to have set the area, start frame, and zoom level for the cache. It could be used to establish a suitable region for a subsequent paint request (because if an area is not in the cache, it cannot have been rendered since the cache was cleared).

Returns an empty QRect if the cache is entirely valid.

Definition at line 57 of file Colour3DPlotRenderer.cpp.

Referenced by Colour3DPlotLayer::paintWithRenderer(), and SpectrogramLayer::paintWithRenderer().

bool Colour3DPlotRenderer::geometryChanged ( const LayerGeometryProvider v)

Return true if the provider's geometry differs from the cache, or if we are not using a cache.

i.e. if the cache will be regenerated for the next render, or the next render performed from scratch.

Definition at line 79 of file Colour3DPlotRenderer.cpp.

References LayerGeometryProvider::getPaintSize(), LayerGeometryProvider::getStartFrame(), and LayerGeometryProvider::getZoomLevel().

Referenced by Colour3DPlotLayer::paintWithRenderer(), and SpectrogramLayer::paintWithRenderer().

bool Colour3DPlotRenderer::willRenderOpaque ( const LayerGeometryProvider v)
inline

Return true if the rendering will be opaque.

This may be used by the calling layer to determine whether it can scroll directly without regard to any other layers beneath.

Definition at line 228 of file Colour3DPlotRenderer.h.

QColor Colour3DPlotRenderer::getColour ( double  value) const
inline

Return the colour corresponding to the given value.

See also
ColourScale::getPixel
ColourScale::getColour

Definition at line 237 of file Colour3DPlotRenderer.h.

QRect Colour3DPlotRenderer::findSimilarRegionExtents ( QPoint  point) const

Return the enclosing rectangle for the region of similar colour to the given point within the cache.

Return an empty QRect if this is not possible.

See also
ImageRegionFinder

Definition at line 1429 of file Colour3DPlotRenderer.cpp.

References ImageRegionFinder::findRegionExtents().

Referenced by SpectrogramLayer::measureDoubleClick().

void Colour3DPlotRenderer::renderToCachePixelResolution ( const LayerGeometryProvider v,
int  x0,
int  repaintWidth,
bool  rightToLeft,
bool  timeConstrained 
)
private
void Colour3DPlotRenderer::renderToCacheBinResolution ( const LayerGeometryProvider v,
int  x0,
int  repaintWidth 
)
private
int Colour3DPlotRenderer::renderDrawBuffer ( int  w,
int  h,
const std::vector< int > &  binforx,
const std::vector< double > &  binfory,
int  peakCacheIndex,
bool  rightToLeft,
bool  timeConstrained 
)
private
int Colour3DPlotRenderer::renderDrawBufferPeakFrequencies ( const LayerGeometryProvider v,
int  w,
int  h,
const std::vector< int > &  binforx,
const std::vector< double > &  binfory,
bool  rightToLeft,
bool  timeConstrained 
)
private
void Colour3DPlotRenderer::recreateDrawBuffer ( int  w,
int  h 
)
private

Definition at line 1402 of file Colour3DPlotRenderer.cpp.

void Colour3DPlotRenderer::clearDrawBuffer ( int  w,
int  h 
)
private

Definition at line 1418 of file Colour3DPlotRenderer.cpp.

QImage Colour3DPlotRenderer::scaleDrawBufferImage ( QImage  source,
int  targetWidth,
int  targetHeight 
) const
private

Definition at line 760 of file Colour3DPlotRenderer.cpp.

ColumnOp::Column Colour3DPlotRenderer::getColumn ( int  sx,
int  minbin,
int  nbins,
std::shared_ptr< DenseThreeDimensionalModel >  source 
) const
private

Definition at line 406 of file Colour3DPlotRenderer.cpp.

References Phase.

ColumnOp::Column Colour3DPlotRenderer::getColumnRaw ( int  sx,
int  minbin,
int  nbins,
std::shared_ptr< DenseThreeDimensionalModel >  source 
) const
private

Definition at line 442 of file Colour3DPlotRenderer.cpp.

References Phase.

void Colour3DPlotRenderer::getPreferredPeakCache ( const LayerGeometryProvider v,
int &  peakCacheIndex,
int &  binsPerPeak 
) const
private
void Colour3DPlotRenderer::updateTimings ( const RenderTimer timer,
int  xPixelCount 
)
private

Definition at line 1379 of file Colour3DPlotRenderer.cpp.

References RenderTimer::secondsPerItem().

Member Data Documentation

Sources Colour3DPlotRenderer::m_sources
private

Definition at line 249 of file Colour3DPlotRenderer.h.

Parameters Colour3DPlotRenderer::m_params
private

Definition at line 250 of file Colour3DPlotRenderer.h.

QImage Colour3DPlotRenderer::m_drawBuffer
private

Definition at line 256 of file Colour3DPlotRenderer.h.

std::vector<MagnitudeRange> Colour3DPlotRenderer::m_magRanges
private

Definition at line 262 of file Colour3DPlotRenderer.h.

ScrollableImageCache Colour3DPlotRenderer::m_cache
private

Definition at line 271 of file Colour3DPlotRenderer.h.

ScrollableMagRangeCache Colour3DPlotRenderer::m_magCache
private

Definition at line 280 of file Colour3DPlotRenderer.h.

double Colour3DPlotRenderer::m_secondsPerXPixel
private

Definition at line 282 of file Colour3DPlotRenderer.h.

bool Colour3DPlotRenderer::m_secondsPerXPixelValid
private

Definition at line 283 of file Colour3DPlotRenderer.h.


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