kwave
18.07.70
|
#include <TrackPixmap.h>
Public Slots | |
void | setOffset (sample_index_t offset) |
void | setZoom (double zoom) |
Signals | |
void | sigModified () |
Public Member Functions | |
TrackPixmap (Kwave::Track &track) | |
virtual | ~TrackPixmap () |
virtual void | resize (int width, int height) |
virtual int | width () const |
virtual int | height () const |
virtual const QPixmap & | pixmap () const |
virtual void | repaint () |
virtual void | setVerticalZoom (double zoom) |
virtual bool | isModified () |
virtual void | setModified () |
Private Slots | |
void | slotSamplesInserted (Kwave::Track *src, sample_index_t offset, sample_index_t length) |
void | slotSamplesDeleted (Kwave::Track *src, sample_index_t offset, sample_index_t length) |
void | slotSamplesModified (Kwave::Track *src, sample_index_t offset, sample_index_t length) |
void | selectionChanged () |
Private Member Functions | |
void | resizeBuffer () |
void | invalidateBuffer () |
bool | validateBuffer () |
void | drawOverview (QPainter &p, int middle, int height, int first, int last) |
void | calculateInterpolation () |
void | drawInterpolatedSignal (QPainter &p, int width, int middle, int height) |
void | drawPolyLineSignal (QPainter &p, int width, int middle, int height) |
sample_index_t | pixels2samples (int pixels) |
int | samples2pixels (sample_index_t samples) |
void | convertOverlap (sample_index_t &offset, sample_index_t &length) |
Private Attributes | |
QPixmap | m_pixmap |
Kwave::Track & | m_track |
sample_index_t | m_offset |
double | m_zoom |
double | m_vertical_zoom |
bool | m_minmax_mode |
Kwave::SampleArray | m_sample_buffer |
Kwave::SampleArray | m_min_buffer |
Kwave::SampleArray | m_max_buffer |
bool | m_modified |
QBitArray | m_valid |
QMutex | m_lock_buffer |
int | m_interpolation_order |
QVector< double > | m_interpolation_alpha |
Kwave::Colors::ColorSet | m_colors |
Definition at line 67 of file TrackPixmap.h.
|
explicit |
Default constructor
Definition at line 50 of file TrackPixmap.cpp.
References Kwave::connect(), selectionChanged(), slotSamplesDeleted(), slotSamplesInserted(), and slotSamplesModified().
|
virtual |
Destructor
Definition at line 75 of file TrackPixmap.cpp.
References m_interpolation_alpha, and m_lock_buffer.
|
private |
Calculates the parameters for interpolation of the graphical display when zoomed in. Allocates (new) buffer for the filter coefficients of the low pass filter used for interpolation.
Definition at line 491 of file TrackPixmap.cpp.
References INTERPOLATION_PRECISION, m_interpolation_alpha, m_interpolation_order, m_zoom, and samples2pixels().
Referenced by drawInterpolatedSignal().
|
private |
Converts the offset and length of an overlapping region into buffer indices, depending on the current mode. If the given region does not overlap at all, the length of the area will be set to zero. The length will be truncated to the end of the current buffer(s).
offset | reference to the source sample index, will be converted into buffer index |
length | reference to the length in samples, will be converted to the number of buffer indices |
Definition at line 790 of file TrackPixmap.cpp.
References m_minmax_mode, m_offset, m_valid, and m_zoom.
Referenced by slotSamplesDeleted(), slotSamplesInserted(), and slotSamplesModified().
|
private |
Draws the signal and interpolates the pixels between the samples. The interpolation is done by using a simple FIR lowpass filter.
p | reference to a QPainter |
width | the width of the pixmap in pixels |
middle | the y position of the zero line in the drawing area [pixels] |
height | the height of the drawing are [pixels] |
Definition at line 548 of file TrackPixmap.cpp.
References calculateInterpolation(), height(), Kwave::Colors::ColorSet::interpolated, INTERPOLATION_PRECISION, m_colors, m_interpolation_alpha, m_interpolation_order, m_sample_buffer, m_valid, m_vertical_zoom, m_zoom, Kwave::Colors::ColorSet::sample, SAMPLE_MAX, samples2pixels(), Kwave::toInt(), and width().
Referenced by repaint().
|
private |
Draws the signal as an overview with multiple samples per pixel.
p | reference to a QPainter |
middle | the y position of the zero line [pixels] |
height | the height of the pixmap [pixels] |
first | the offset of the first pixel |
last | the offset of the last pixel |
Definition at line 457 of file TrackPixmap.cpp.
References height(), m_colors, m_max_buffer, m_min_buffer, m_minmax_mode, m_valid, m_vertical_zoom, Kwave::Colors::ColorSet::sample, SAMPLE_BITS, Kwave::SampleArray::size(), Kwave::toInt(), and width().
Referenced by repaint().
|
private |
Draws the signal and connects the pixels between the samples by using a simple poly-line. This gets used if the current zoom factor is not suitable for either an overview nor an interpolated signal display.
p | reference to a QPainter |
width | the width of the pixmap in pixels |
middle | the y position of the zero line in the drawing area [pixels] |
height | the height of the drawing are [pixels] |
Definition at line 645 of file TrackPixmap.cpp.
References height(), m_sample_buffer, m_vertical_zoom, m_zoom, SAMPLE_MAX, samples2pixels(), Kwave::SampleArray::size(), and Kwave::toInt().
Referenced by repaint().
|
inlinevirtual |
Get the height of the pixmap
Definition at line 96 of file TrackPixmap.h.
Referenced by drawInterpolatedSignal(), drawOverview(), drawPolyLineSignal(), Kwave::TrackView::paintEvent(), and repaint().
|
private |
Sets the current buffer to "invalid" state. Note: this does not include any resize!
Definition at line 267 of file TrackPixmap.cpp.
References m_modified, and m_valid.
Referenced by setOffset(), setZoom(), and validateBuffer().
|
virtual |
Returns "true" if the buffer has changed and the pixmap has to be re-painted.
Definition at line 443 of file TrackPixmap.cpp.
References m_lock_buffer, and m_modified.
Referenced by Kwave::TrackView::paintEvent(), and Kwave::TrackView::setZoomAndOffset().
|
inlineprivate |
Converts a pixel offset into a sample offset.
Definition at line 262 of file TrackPixmap.h.
Referenced by resizeBuffer(), and setOffset().
|
inlinevirtual |
Get the internal QPixmap object
Definition at line 102 of file TrackPixmap.h.
Referenced by Kwave::TrackView::paintEvent().
|
virtual |
Repaints the current pixmap. After the repaint the pixmap is no longer in status "modified". If it was not modified before, this is a no-op.
Definition at line 382 of file TrackPixmap.cpp.
References Kwave::Colors::ColorSet::background, Kwave::Colors::Disabled, drawInterpolatedSignal(), drawOverview(), drawPolyLineSignal(), height(), INTERPOLATION_ZOOM, Kwave::Track::length(), m_colors, m_lock_buffer, m_minmax_mode, m_modified, m_offset, m_pixmap, m_track, m_zoom, Kwave::Colors::Normal, samples2pixels(), Kwave::Track::selected(), validateBuffer(), width(), Kwave::Colors::ColorSet::zero, and Kwave::Colors::ColorSet::zero_unused.
Referenced by Kwave::TrackView::paintEvent(), and Kwave::TrackView::refresh().
|
virtual |
Resize the pixmap.
width | new width in pixels |
height | new height in pixels |
Definition at line 252 of file TrackPixmap.cpp.
References m_lock_buffer, m_modified, m_pixmap, and resizeBuffer().
Referenced by Kwave::TrackView::paintEvent().
|
private |
Resizes the current buffer and sets all new entries to invalid (if any).
Definition at line 192 of file TrackPixmap.cpp.
References m_max_buffer, m_min_buffer, m_minmax_mode, m_sample_buffer, m_valid, pixels2samples(), Kwave::SampleArray::resize(), Kwave::toInt(), and width().
Referenced by resize(), and setZoom().
|
inlineprivate |
Converts a sample offset into a pixel offset.
Definition at line 270 of file TrackPixmap.h.
References Kwave::toInt().
Referenced by calculateInterpolation(), drawInterpolatedSignal(), drawPolyLineSignal(), repaint(), and setOffset().
|
privateslot |
Sets the state of the pixmap to "modified" whenever the selection of the track has changed
Definition at line 450 of file TrackPixmap.cpp.
References m_lock_buffer, and m_modified.
Referenced by TrackPixmap().
|
inlinevirtual |
|
slot |
Sets a new sample offset and moves the signal display left or right. Only the new areas that were moved in will be redrawn.
offset | index of the first visible sample |
Definition at line 82 of file TrackPixmap.cpp.
References invalidateBuffer(), m_lock_buffer, m_max_buffer, m_min_buffer, m_minmax_mode, m_modified, m_offset, m_sample_buffer, m_valid, m_zoom, pixels2samples(), samples2pixels(), Kwave::SampleArray::size(), Kwave::toInt(), and Kwave::toUint().
Referenced by Kwave::TrackView::setZoomAndOffset().
|
virtual |
Sets a new vertical zoom factor.
zoom | new vertical zoom |
Definition at line 433 of file TrackPixmap.cpp.
References m_lock_buffer, m_modified, and m_vertical_zoom.
|
slot |
Sets a new zoom factor in samples per pixel. This normally affects the number of visible samples and a redraw of the current view.
Definition at line 218 of file TrackPixmap.cpp.
References invalidateBuffer(), m_lock_buffer, m_minmax_mode, m_modified, m_zoom, and resizeBuffer().
Referenced by Kwave::TrackView::setZoomAndOffset().
|
signal |
Emitted if the content of the pixmap was modified.
Referenced by slotSamplesDeleted(), slotSamplesInserted(), and slotSamplesModified().
|
privateslot |
Connected to the track's sigSamplesDeleted.
src | source track |
offset | position from which the data was removed |
length | number of samples deleted |
Definition at line 738 of file TrackPixmap.cpp.
References convertOverlap(), m_lock_buffer, m_modified, m_valid, sigModified(), and Kwave::toInt().
Referenced by TrackPixmap().
|
privateslot |
Connected to the track's sigSamplesInserted.
src | source track |
offset | position from which the data was inserted |
length | number of samples inserted |
Definition at line 712 of file TrackPixmap.cpp.
References convertOverlap(), m_lock_buffer, m_modified, m_valid, sigModified(), and Kwave::toInt().
Referenced by TrackPixmap().
|
privateslot |
Connected to the track's sigSamplesModified
src | source track |
offset | position from which the data was modified |
length | number of samples modified |
Definition at line 764 of file TrackPixmap.cpp.
References convertOverlap(), m_lock_buffer, m_modified, m_valid, sigModified(), and Kwave::toInt().
Referenced by TrackPixmap().
|
private |
Adapts the current mode and size of the buffers and fills all areas that do not contain valid data with fresh samples. In other words: it makes the buffer "valid" and consistent.
Definition at line 274 of file TrackPixmap.cpp.
References INTERPOLATION_ZOOM, invalidateBuffer(), Kwave::Track::length(), m_max_buffer, m_min_buffer, m_minmax_mode, m_offset, m_sample_buffer, m_track, m_valid, m_zoom, Kwave::SampleReader::minMax(), Kwave::Track::openReader(), Kwave::SampleReader::read(), Kwave::SampleReader::seek(), Kwave::SinglePassForward, Kwave::SampleArray::size(), and Kwave::toInt().
Referenced by repaint().
|
inlinevirtual |
Get the width of the pixmap
Definition at line 90 of file TrackPixmap.h.
Referenced by drawInterpolatedSignal(), drawOverview(), Kwave::TrackView::paintEvent(), repaint(), and resizeBuffer().
|
private |
set of colors for drawing
Definition at line 367 of file TrackPixmap.h.
Referenced by drawInterpolatedSignal(), drawOverview(), and repaint().
|
private |
Buffer for filter coefficients of the low pass used for interpolation.
Definition at line 364 of file TrackPixmap.h.
Referenced by calculateInterpolation(), drawInterpolatedSignal(), and ~TrackPixmap().
|
private |
order of the low pass filter used for interpolation
Definition at line 357 of file TrackPixmap.h.
Referenced by calculateInterpolation(), and drawInterpolatedSignal().
|
private |
Mutex for exclusive access to the buffers.
Definition at line 352 of file TrackPixmap.h.
Referenced by isModified(), repaint(), resize(), selectionChanged(), setOffset(), setVerticalZoom(), setZoom(), slotSamplesDeleted(), slotSamplesInserted(), slotSamplesModified(), and ~TrackPixmap().
|
private |
Array with maximum sample values, if in min/max mode.
Definition at line 338 of file TrackPixmap.h.
Referenced by drawOverview(), resizeBuffer(), setOffset(), and validateBuffer().
|
private |
Array with minimum sample values, if in min/max mode.
Definition at line 333 of file TrackPixmap.h.
Referenced by drawOverview(), resizeBuffer(), setOffset(), and validateBuffer().
|
private |
If true, we are in min/max mode. This means that m_sample_buffer is not used and m_minmax_buffer contains is used instead.
Definition at line 321 of file TrackPixmap.h.
Referenced by convertOverlap(), drawOverview(), repaint(), resizeBuffer(), setOffset(), setZoom(), and validateBuffer().
|
private |
Indicates that the buffer content was modified
Definition at line 341 of file TrackPixmap.h.
Referenced by invalidateBuffer(), isModified(), repaint(), resize(), selectionChanged(), setOffset(), setVerticalZoom(), setZoom(), slotSamplesDeleted(), slotSamplesInserted(), and slotSamplesModified().
|
private |
Index of the first sample. Needed for converting pixel positions into absolute sample numbers. This is always in units of samples, independent of the current mode!
Definition at line 304 of file TrackPixmap.h.
Referenced by convertOverlap(), repaint(), setOffset(), and validateBuffer().
|
private |
The QPixmap with the bitmap data
Definition at line 292 of file TrackPixmap.h.
|
private |
Array with samples needed for drawing when not in min/max mode. This might sometimes include one sample before or after the current view.
Definition at line 328 of file TrackPixmap.h.
Referenced by drawInterpolatedSignal(), drawPolyLineSignal(), resizeBuffer(), setOffset(), and validateBuffer().
|
private |
Reference to the track with our sample data.
Definition at line 297 of file TrackPixmap.h.
Referenced by repaint(), and validateBuffer().
|
private |
Array with one bit for each position in the internal buffers. If the bit corresponding to a certain buffer index is set to "1", the position contains valid data, if "0" the content of the buffer is invalid.
Definition at line 349 of file TrackPixmap.h.
Referenced by convertOverlap(), drawInterpolatedSignal(), drawOverview(), invalidateBuffer(), resizeBuffer(), setOffset(), slotSamplesDeleted(), slotSamplesInserted(), slotSamplesModified(), and validateBuffer().
|
private |
vertical zoom factor. Default is 1.0
Definition at line 315 of file TrackPixmap.h.
Referenced by drawInterpolatedSignal(), drawOverview(), drawPolyLineSignal(), and setVerticalZoom().
|
private |
Zoom factor in samples/pixel. Needed for converting sample indices into pixels and vice-versa.
Definition at line 310 of file TrackPixmap.h.
Referenced by calculateInterpolation(), convertOverlap(), drawInterpolatedSignal(), drawPolyLineSignal(), repaint(), setOffset(), setZoom(), and validateBuffer().