Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

QwavWaveView Class Reference

Widget that displays waveform data graphically. More...

#include <qwavwaveview.h>

Inheritance diagram for QwavWaveView:

Inheritance graph
[legend]
Collaboration diagram for QwavWaveView:

Collaboration graph
[legend]
List of all members.

Public Slots

Customization
void setBgColor (const QColor &c)
const QColor & bgColor (void) const
void setPeakColor (const QColor &c)
const QColor & peakColor (void) const
void setAvgColor (const QColor &c)
const QColor & avgColor (void) const
Samples and pixels
void setSamplesVisible (const long &newVal)
void setZoomFac (double zoomFac)
void setZoomYFac (double zoomYFac)
void setFirstSample (ulong sample)
void setChannel (uint channel=1)
uint channel (void) const
void scrollBy (int pixel)
void displayHelp (void)

Signals

void selBeginChanged (long sample)
void selEndChanged (long sample)
void zoomFacChanged (double fac)
void positionChanged (ulong sample)
void firstSampleChanged (ulong sample)

Public Methods

const QwavWaveViewInterface::State & state (void) const
Constructor & Destructor
 QwavWaveView (QwavWaveDataInterface *waveData, QWidget *parent, const char *name, int wflags=WDestructiveClose) throw (InvalidNrOfChannels, FileOpenError)
 QwavWaveView (const string &file, QWidget *parent, const char *name) throw (InvalidNrOfChannels, FileOpenError, FileReadError)
virtual ~QwavWaveView ()
Layer
int addLayer (QwavViewLayer *layer)
QwavViewLayergetLayer (const string &name)
QwavViewLayergetLayer (uint index)
uint getNrOfLayers (void) const
QPixmap * getBackbuf (void)
Samples and pixels
int sample2Pixel (long sample) const
long pixel2Sample (int pixel) const
bool isSampleVisible (long sample) const
const int nrOfPixels (void) const
double zoomFac (void) const
double zoomYFac (void) const
double maxZoomFac (void) const
const ulong firstSample (void) const
const long lastSample (void) const
const long samplesVisible (void) const
void setPeakInterpolator (QwavPeakInterpolator *s)
QwavPeakInterpolatorpeakInterpolator () const
Position
void setPosition (const ulong sample)
const ulong & position () const
QwavSelection
uint addSelection (const QwavSelection &s)
uint getNrOfSelections (void) const
const QwavSelectiongetSelection (uint index=0) const
QwavSelectiongetSelection (uint index=0)
int isSelectionBegin (int pixel)
int isSelectionEnd (int pixel)
int activeSelection (void) const
void clearSelections (void)

Protected Methods

virtual void paintEvent (QPaintEvent *e)
virtual void resizeEvent (QResizeEvent *e)
virtual void mousePressEvent (QMouseEvent *e)
virtual void mouseMoveEvent (QMouseEvent *e)
virtual void mouseReleaseEvent (QMouseEvent *e)
virtual void mouseDoubleClickEvent (QMouseEvent *e)
virtual void wheelEvent (QWheelEvent *e)
virtual void keyPressEvent (QKeyEvent *e)
virtual void keyReleaseEvent (QKeyEvent *e)
void setState (State s)
virtual void initLayers ()

Friends

class QwavStereoWaveView

Detailed Description

Widget that displays waveform data graphically.

Author:
Peter Eschler

nrOfSamples() is the number of samples per channel (stereo sounds are not supported for now, mono only)

nrOfPixels() is the number of available pixels, which simply is the width() of this wave view widget.

samplesVisible() is used to set the number of samples to be visible in the view (which is nrOfPixels() wide).

zoomFac() is the quotient samplesVisible/nrOfPixels and thus depends on samplesVisible()

firstSample() specifies the first visible sample. It can be set by setFirstSample() and is used to implement scrolling.

Layers

A QwavWaveView consists of several layers. The layers are used to paint things like the background, some helper lines and of course the waveform data itself.

A QwavWaveView automatically contains some standard layers (otherwise nothing would be painted). The five standard layers are:

These layers can be accessed by their name via getLayer(). The name is simply the classname of the layer (e.g. "QwavPeakDataLayer"). Alternatively a layer can be accessed via it's index using getLayer() and the index obtained by calling addLayer().


Constructor & Destructor Documentation

Qwav_BEGIN_NAMESPACE QwavWaveView::QwavWaveView QwavWaveDataInterface   wd,
QWidget *    parent,
const char *    name,
int    wflags = WDestructiveClose
throw (InvalidNrOfChannels, FileOpenError)
 

Constructs a new view on a waveform.

This constructor gets it's data from the given pDoc. If the sounddata has more than one channel an InvalidNrOfChannels exception is thrown.

Parameters:
pDoc  the document to view (Document/View pattern)
parent  the parent widget
name  optional name for the widget
wflags  widget flags

QwavWaveView::QwavWaveView const string &    file,
QWidget *    parent,
const char *    name
throw (InvalidNrOfChannels, FileOpenError, FileReadError)
 

Constructs a QwavWaveView displaying the mono sound in file.

If file is not a mono sound an InvalidNrOfChannels exception is thrown.

QwavWaveView::~QwavWaveView   [virtual]
 

Destructor.


Member Function Documentation

int QwavWaveView::activeSelection void    const [inline, virtual]
 

Returns the index of the active selection or -1 of no active selection. The returned index can be just with getQwavSelection() to obtain the active selection.

Returns:
index to the active selection

Implements QwavWaveViewInterface.

int QwavWaveView::addLayer QwavViewLayer   layer [virtual]
 

Adds a layer to this view.

If there is no layer of layer's type present, layer is added and it's index returned.

If a layer with the same type as layer is already present (the type is determined by layer->getName()), layer is not added and -1 is returned.

Parameters:
layer  the layer to add
Returns:
index of the added layer, or -1 if layer was not added
See also:
getLayer

Implements QwavWaveViewInterface.

uint QwavWaveView::addSelection const QwavSelection   s [virtual]
 

Adds the selection s to the selection vector. For now only single selection is implemented. The selection s is added as a deep copy.

Parameters:
s  the selection to add
Returns:
the index of s in the selection vector

Implements QwavWaveViewInterface.

const QColor & QwavWaveView::avgColor void    const [virtual, slot]
 

Returns the average color of this view.

Returns:
the actual average color
See also:
setAvgColor

Implements QwavWaveViewInterface.

const QColor & QwavWaveView::bgColor void    const [virtual, slot]
 

Returns the background color of this view.

Returns:
the actual background color
See also:
setBgColor

Implements QwavWaveViewInterface.

void QwavWaveView::clearSelections void    [virtual]
 

Clears the selection vector and repaints the view.

Implements QwavWaveViewInterface.

const ulong QwavWaveView::firstSample void    const [inline, virtual]
 

Returns the first visible sample in this view.

Returns:
the first visible sample [0,nrOfSamples()]

Implements QwavWaveViewInterface.

void QwavWaveView::firstSampleChanged ulong    sample [virtual, signal]
 

Is emitted when the first visible sample has changed.

Implements QwavWaveViewInterface.

QPixmap * QwavWaveView::getBackbuf void    [inline, virtual]
 

Returns a pointer to the backbuffer pixmap.

The pixmap is used by the view layers of this QwavWaveView to paint onto.

Returns:
the backbuffer pixmap

Implements QwavWaveViewInterface.

QwavViewLayer * QwavWaveView::getLayer uint    index [inline, virtual]
 

Returns the view layer with the specified index.

Parameters:
index  index of the layer
Returns:
the QwavViewLayer with that index, or 0 if no layer with that index

Implements QwavWaveViewInterface.

QwavViewLayer * QwavWaveView::getLayer const string &    name [virtual]
 

Returns a pointer to the layer name if present, otherwise 0 is returned.

Parameters:
name  the name of the layer
Returns:
pointer to the layer

Implements QwavWaveViewInterface.

uint QwavWaveView::getNrOfLayers void    const [inline, virtual]
 

Returns the number of layers currently used.

Returns:
the number of layers

Implements QwavWaveViewInterface.

uint QwavWaveView::getNrOfSelections void    const [inline, virtual]
 

Returns the number of selections.

Returns:
the number of selections

Implements QwavWaveViewInterface.

QwavSelection & QwavWaveView::getSelection uint    index = 0 [virtual]
 

Returns a reference to the selection with the given index. If no selection with index exists, Selection::NullSelection is returned.

Parameters:
index  the selection to get
Returns:
the selection at index, or Selection::NullSelection

Implements QwavWaveViewInterface.

const QwavSelection & QwavWaveView::getSelection uint    index = 0 const [virtual]
 

Returns a reference to the selection with the given index. If no selection with index exists, Selection::NullSelection is returned.

Parameters:
index  the selection to get
Returns:
the selection at index, or Selection::NullSelection

Implements QwavWaveViewInterface.

bool QwavWaveView::isSampleVisible long    sample const [inline, virtual]
 

Checks if sample is visible in this view. If sample is visible true is returned, otherwise false.

Parameters:
sample  the sample to check
Returns:
true if true
false if not

Implements QwavWaveViewInterface.

int QwavWaveView::isSelectionBegin int    pixel [inline, virtual]
 

If pixel is the begin of an available selection, the index of that selection is returned. If pixel is not the begin of any selection -1 is returned.

Parameters:
pixel  the pixel to test
Returns:
index of the selection or -1

Implements QwavWaveViewInterface.

int QwavWaveView::isSelectionEnd int    pixel [inline, virtual]
 

If pixel is the end of an available selection, the index of that selection is returned. If pixel is not the end of any selection -1 is returned.

Parameters:
pixel  the pixel to test
Returns:
index of the selection or -1

Implements QwavWaveViewInterface.

const long QwavWaveView::lastSample void    const [inline, virtual]
 

Returns the first visible sample in this view.

Returns:
the first visible sample [0,nrOfSamples()]

Implements QwavWaveViewInterface.

double QwavWaveView::maxZoomFac void    const [inline, virtual]
 

Returns the maximum zoom factor.

Parameters:
the  maximum zoom factor

Implements QwavWaveViewInterface.

const int QwavWaveView::nrOfPixels void    const [inline, virtual]
 

Returns the number of pixels available. The number of pixel is equal to the width of this widget.

Returns:
the numer of pixels available

Implements QwavWaveViewInterface.

void QwavWaveView::paintEvent QPaintEvent *    pe [protected, virtual]
 

No descriptions

const QColor & QwavWaveView::peakColor void    const [virtual, slot]
 

Returns the peak color of this view.

Returns:
the actual peak color
See also:
setPeakColor

Implements QwavWaveViewInterface.

QwavPeakInterpolator * QwavWaveView::peakInterpolator   const [inline, virtual]
 

Returns the peak interpolator used.

Returns:
the QwavPeakInterpolator used

Implements QwavWaveViewInterface.

long QwavWaveView::pixel2Sample int    pixel const [inline, virtual]
 

Returns the sample of the given pixel.

Parameters:
pixel  the pixel to get the sample for
Returns:
the sample of pixel

Implements QwavWaveViewInterface.

const ulong & QwavWaveView::position   const [virtual]
 

Returns the current position of the position marker.

Returns:
the current position

Implements QwavWaveViewInterface.

void QwavWaveView::positionChanged ulong    sample [virtual, signal]
 

Is emitted when the current position has changed.

Implements QwavWaveViewInterface.

int QwavWaveView::sample2Pixel long    sample const [inline, virtual]
 

Returns the pixel position of the given sample. If sample is not visible in this view -1 is returned.

Parameters:
sample  the sample
Returns:
the pixel position or -1 if sample is not visible
See also:
pixel2Sample

Implements QwavWaveViewInterface.

const long QwavWaveView::samplesVisible void    const [inline, virtual]
 

Returns the number of samples visible in this view.

Returns:
the number of visible samples

Implements QwavWaveViewInterface.

void QwavWaveView::selBeginChanged long    sample [virtual, signal]
 

Is emitted when the selection begin has changed.

Implements QwavWaveViewInterface.

void QwavWaveView::selEndChanged long    sample [virtual, signal]
 

Is emitted when the selection end has changed.

Implements QwavWaveViewInterface.

void QwavWaveView::setAvgColor const QColor &    c [virtual, slot]
 

Sets the average color of this view to the color c.

Parameters:
c  the new average color
See also:
averageColor

Implements QwavWaveViewInterface.

void QwavWaveView::setBgColor const QColor &    c [virtual, slot]
 

Sets the background color of this view to the color c.

Parameters:
c  the new background color
See also:
bgColor

Implements QwavWaveViewInterface.

void QwavWaveView::setFirstSample ulong    sample [virtual, slot]
 

\copydoc QwavWaveViewInterface::setFirstSample()

This implementation first checks if sample is different to the current first sample.

Implements QwavWaveViewInterface.

void QwavWaveView::setPeakColor const QColor &    c [virtual, slot]
 

Sets the peak color of this view to the color c.

Parameters:
c  the new peak color
See also:
peakColor

Implements QwavWaveViewInterface.

void QwavWaveView::setPosition const ulong    sample [virtual]
 

Sets the position of the position marker to sample.

Parameters:
sample  the new position

Implements QwavWaveViewInterface.

void QwavWaveView::setSamplesVisible const long &    nSamples [virtual, slot]
 

Sets the number of pixels visible in this view.

Implements QwavWaveViewInterface.

void QwavWaveView::setZoomFac double    zoomFac [virtual, slot]
 

Sets the zoom factor of this view.

Parameters:
zoomFac  the zoom factor to set

Implements QwavWaveViewInterface.

void QwavWaveView::setZoomYFac double    zoomYFac [inline, virtual, slot]
 

Sets the vertical zoom factor of this view.

Parameters:
zoomYFac  the vertical zoom factor

Implements QwavWaveViewInterface.

const QwavWaveViewInterface::State & QwavWaveView::state void    const [inline, virtual]
 

Returns the state of this view.

Returns:
the state
See also:
State

Implements QwavWaveViewInterface.

double QwavWaveView::zoomFac void    const [inline, virtual]
 

Returns the zoom factor of this view. The zoom factor is the quotient
visibleSamples() / width()

The zoom factor is measured in samples per pixel. It tells how much samples are visualised by one pixel. Thus if zoom is 1.0 you get a 1:1 visualization (one sample=one pixel).

To zoom out from the waveform use zoom values greater than 1. The maximum value for zoom is limited to the double of the number of samples.

See also:
samplesVisible
Returns:
the zoom factor

Implements QwavWaveViewInterface.

void QwavWaveView::zoomFacChanged double    fac [virtual, signal]
 

Is emitted when the zoom factor has changed.

Implements QwavWaveViewInterface.

double QwavWaveView::zoomYFac void    const [inline, virtual]
 

Return the vertical zoom factor of this view.

Returns:
the vertical zoom factor

Implements QwavWaveViewInterface.


The documentation for this class was generated from the following files:
Generated on Mon Jan 20 00:24:57 2003 for Qwav by doxygen1.2.16