kwave
18.07.70
|
#include <SignalView.h>
Classes | |
class | PositionWidget |
Public Types | |
enum | Location { UpperDockTop, UpperDockBottom, Top, AboveTrackTop, AboveTrackBottom, BelowTrackTop, BelowTrackBottom, Bottom, LowerDockTop, LowerDockBottom } |
Public Slots | |
virtual void | setTrack (int track) |
virtual void | setZoomAndOffset (double zoom, sample_index_t offset) |
virtual void | setVerticalZoom (double zoom) |
virtual void | showCursor (sample_index_t pos=SAMPLE_INDEX_MAX) |
Signals | |
void | contentSizeChanged () |
void | sigCursorChanged (sample_index_t pos) |
void | sigNeedRepaint (Kwave::SignalView *view) |
void | sigCommand (const QString &command) |
Public Member Functions | |
SignalView (QWidget *parent, QWidget *controls, Kwave::SignalManager *signal_manager, Location preferred_location, int track=-1) | |
virtual | ~SignalView () Q_DECL_OVERRIDE |
virtual void | refresh () |
Location | preferredLocation () const |
Kwave::SignalManager * | signalManager () const |
int | track () const |
sample_index_t | offset () const |
double | zoom () const |
double | verticalZoom () const |
sample_index_t | firstVisible () const |
sample_index_t | lastVisible () const |
int | samples2pixels (sample_index_t samples) const |
sample_index_t | pixels2samples (int pixels) const |
double | samples2ms (sample_index_t samples) |
virtual bool | canHandleSelection () const |
virtual QSharedPointer< Kwave::ViewItem > | findItem (const QPoint &pos) |
virtual void | mouseMoveEvent (QMouseEvent *e) Q_DECL_OVERRIDE |
virtual void | mousePressEvent (QMouseEvent *e) Q_DECL_OVERRIDE |
virtual void | mouseReleaseEvent (QMouseEvent *e) Q_DECL_OVERRIDE |
virtual void | leaveEvent (QEvent *e) Q_DECL_OVERRIDE |
virtual void | keyPressEvent (QKeyEvent *e) Q_DECL_OVERRIDE |
virtual int | selectionTolerance () const |
virtual void | handleContextMenu (const QPoint &pos, QMenu *menu) |
virtual void | addSibling (QWidget *widget) |
Protected Types | |
enum | SelectionPosEnum { None = 0x0000, LeftBorder = 0x0001, RightBorder = 0x0002, Selection = 0x8000 } |
Protected Slots | |
virtual void | showPosition (const QString &text, sample_index_t pos, const QPoint &mouse) |
virtual void | hidePosition () |
Protected Member Functions | |
virtual void | dragEnterEvent (QDragEnterEvent *event) Q_DECL_OVERRIDE |
virtual void | dragLeaveEvent (QDragLeaveEvent *event) Q_DECL_OVERRIDE |
virtual void | dropEvent (QDropEvent *event) Q_DECL_OVERRIDE |
virtual void | dragMoveEvent (QDragMoveEvent *event) Q_DECL_OVERRIDE |
SelectionPos | selectionPosition (int x) |
bool | isInSelection (int x) |
void | findNewItem (const QPoint &mouse_pos, bool active) |
Protected Attributes | |
QWidget * | m_controls |
Kwave::SignalManager * | m_signal_manager |
Location | m_preferred_location |
int | m_track_index |
sample_index_t | m_offset |
double | m_zoom |
Private Types | |
enum | { MouseNormal = 0, MouseMoveItem, MouseDragItem } |
Private Attributes | |
double | m_vertical_zoom |
enum Kwave::SignalView:: { ... } | m_mouse_mode |
Kwave::MouseMark | m_mouse_selection |
int | m_mouse_down_x |
PositionWidget | m_position_widget |
QTimer | m_position_widget_timer |
QList< QPointer< QWidget > > | m_siblings |
QSharedPointer< Kwave::ViewItem > | m_selected_item |
Definition at line 50 of file SignalView.h.
|
private |
mode of the mouse cursor
Enumerator | |
---|---|
MouseNormal | over the signal [default] |
MouseMoveItem | while moving an item |
MouseDragItem | while dragging an item |
Definition at line 413 of file SignalView.h.
preferred location of the SignalView
Definition at line 56 of file SignalView.h.
|
protected |
Relationship between a screen position and the current selection.
Enumerator | |
---|---|
None | not near a border |
LeftBorder | close to start of selection |
RightBorder | close to end of selection |
Selection | within the selection |
Definition at line 295 of file SignalView.h.
Kwave::SignalView::SignalView | ( | QWidget * | parent, |
QWidget * | controls, | ||
Kwave::SignalManager * | signal_manager, | ||
Location | preferred_location, | ||
int | track = -1 |
||
) |
Constructor
parent | pointer to the parent widget |
controls | container widget for associated controls |
signal_manager | the signal manager |
preferred_location | the location where to insert the view |
track | (optional) index of the associated track or -1 if not related to a specific track (default) |
Definition at line 52 of file SignalView.cpp.
References Kwave::connect(), m_position_widget, and m_position_widget_timer.
|
virtual |
Destructor
Definition at line 82 of file SignalView.cpp.
References hidePosition(), m_mouse_mode, m_selected_item, m_siblings, and MouseNormal.
|
virtual |
Adds a widget to the list of associated widgets
widget | a QWidget that is associated to this view |
Definition at line 107 of file SignalView.cpp.
References m_siblings.
Referenced by Kwave::SignalWidget::insertRow().
|
inlinevirtual |
Should be overwritten by subclasses that can display the currently selected range and allow the user to change the selection by mouse.
Reimplemented in Kwave::TrackView.
Definition at line 164 of file SignalView.h.
References SAMPLE_INDEX_MAX.
Referenced by mousePressEvent(), mouseReleaseEvent(), and selectionPosition().
|
signal |
emitted whenever the size of the content has changed
Referenced by Kwave::TrackView::setVerticalZoom().
|
protectedvirtual |
Definition at line 555 of file SignalView.cpp.
References Kwave::FileDrag::canDecode(), SAMPLE_INDEX_MAX, and sigCursorChanged().
|
protectedvirtual |
Definition at line 568 of file SignalView.cpp.
References m_mouse_mode, MouseNormal, SAMPLE_INDEX_MAX, and sigCursorChanged().
|
protectedvirtual |
Definition at line 634 of file SignalView.cpp.
References Kwave::FileDrag::canDecode(), Kwave::Drag::canDecode(), Kwave::Selection::first(), isInSelection(), Kwave::Selection::last(), m_offset, m_signal_manager, pixels2samples(), rect(), SAMPLE_INDEX_MAX, samples2pixels(), Kwave::SignalManager::selection(), and sigCursorChanged().
|
protectedvirtual |
Definition at line 577 of file SignalView.cpp.
References _, Kwave::Drag::canDecode(), Kwave::CodecManager::canDecode(), DBG, Kwave::Drag::decode(), Kwave::Parser::escape(), m_mouse_mode, m_offset, m_signal_manager, Kwave::CodecManager::mimeTypeOf(), MouseNormal, pixels2samples(), SAMPLE_INDEX_MAX, Kwave::SignalManager::selectRange(), sigCommand(), and sigCursorChanged().
|
virtual |
Tries to find the nearest item that is visible in this view at a given position
pos | position to look at, relative to view [pixels] |
Reimplemented in Kwave::TrackView.
Definition at line 215 of file SignalView.cpp.
Referenced by findNewItem().
|
protected |
Tries to find the nearest item that is visible in this view at a given position and show or hide the corresponding tool tip.
mouse_pos | position to look at, relative to view [pixels] |
active | if true an operation (move or drag&drop) is active, otherwise it is only a hover over an item |
Definition at line 287 of file SignalView.cpp.
References Kwave::ViewItem::CanDragAndDrop, Kwave::ViewItem::CanGrabAndMove, findItem(), hidePosition(), m_mouse_mode, m_offset, m_selected_item, MouseMoveItem, MouseNormal, pixels2samples(), and showPosition().
Referenced by mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().
|
inline |
|
virtual |
Called when the context menu has been activated over this view
pos | a position in pixel within this widget |
menu | pointer to the context menu |
Reimplemented in Kwave::TrackView.
Definition at line 548 of file SignalView.cpp.
|
inlineprotectedvirtualslot |
Hide the current position marker
Definition at line 272 of file SignalView.h.
Referenced by findNewItem(), keyPressEvent(), leaveEvent(), mouseMoveEvent(), setZoomAndOffset(), and ~SignalView().
|
protected |
Checks if a pixel position is within the left and right border of a selection. The tolerance is 2% of the currently visible area.
x | pixel position to be tested |
Definition at line 209 of file SignalView.cpp.
References selectionPosition().
Referenced by dragMoveEvent().
|
virtual |
handles key press events (e.g. the Escape key)
Definition at line 527 of file SignalView.cpp.
References hidePosition(), m_mouse_mode, m_selected_item, and MouseNormal.
|
inline |
returns the index of the last visible sample
Definition at line 130 of file SignalView.h.
Referenced by Kwave::TrackView::paintEvent().
|
virtual |
slot when the mouse leaves the widget
Definition at line 518 of file SignalView.cpp.
References hidePosition(), m_mouse_mode, and MouseNormal.
|
virtual |
slot for mouse moves, used for selection and drag&drop
Definition at line 318 of file SignalView.cpp.
References Kwave::ViewItem::CanDragAndDrop, Kwave::ViewItem::CanGrabAndMove, findNewItem(), hidePosition(), Kwave::SignalManager::length(), m_mouse_down_x, m_mouse_mode, m_offset, m_selected_item, m_signal_manager, MouseDragItem, MouseMoveItem, MouseNormal, pixels2samples(), and showPosition().
|
virtual |
slot for mouse press, used for selection and drag&drop
Definition at line 391 of file SignalView.cpp.
References Kwave::ViewItem::CanDragAndDrop, canHandleSelection(), findNewItem(), Kwave::Selection::first(), Kwave::MouseMark::grep(), Kwave::Selection::last(), Kwave::MouseMark::left(), Kwave::MouseMark::length(), Kwave::SignalManager::length(), m_mouse_down_x, m_mouse_mode, m_mouse_selection, m_offset, m_selected_item, m_signal_manager, MouseMoveItem, pixels2samples(), Kwave::SignalManager::playbackController(), Kwave::PlaybackController::running(), Kwave::SignalManager::selection(), Kwave::SignalManager::selectRange(), and Kwave::MouseMark::set().
|
virtual |
slot for mouse release, used for selection and drag&drop
Definition at line 465 of file SignalView.cpp.
References Kwave::ViewItem::CanGrabAndMove, canHandleSelection(), findNewItem(), Kwave::SignalManager::length(), m_mouse_mode, m_mouse_selection, m_offset, m_selected_item, m_signal_manager, MouseDragItem, MouseMoveItem, pixels2samples(), Kwave::SignalManager::playbackController(), Kwave::PlaybackController::running(), Kwave::SignalManager::selectRange(), and Kwave::MouseMark::set().
|
inline |
returns the current start position
Definition at line 110 of file SignalView.h.
Referenced by Kwave::TrackView::findItem(), Kwave::SelectionBorderItem::moveTo(), Kwave::LabelItem::moveTo(), and setZoomAndOffset().
sample_index_t Kwave::SignalView::pixels2samples | ( | int | pixels | ) | const |
Converts a number of pixels into a number of samples, based on the current zoom factor
pixels | number of pixels (should be positive) |
Definition at line 155 of file SignalView.cpp.
References m_zoom.
Referenced by dragMoveEvent(), dropEvent(), Kwave::TrackView::findItem(), findNewItem(), Kwave::TrackView::handleContextMenu(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), Kwave::SelectionBorderItem::moveTo(), Kwave::LabelItem::moveTo(), and Kwave::TrackView::paintEvent().
|
inline |
returns the preferred location
Definition at line 95 of file SignalView.h.
Referenced by Kwave::SignalWidget::insertView().
|
virtual |
refresh the content of the view. The default implementation calls repaint(). Can be overwritten to trigger more complex refresh scenarios.
Reimplemented in Kwave::TrackView.
Definition at line 101 of file SignalView.cpp.
Referenced by Kwave::SignalWidget::repaintTimerElapsed().
double Kwave::SignalView::samples2ms | ( | sample_index_t | samples | ) |
Converts a number of samples to a time in milliseconds, based on the current signal rate.
samples | number of samples |
Definition at line 162 of file SignalView.cpp.
References m_signal_manager, and Kwave::SignalManager::rate().
Referenced by Kwave::SelectionBorderItem::toolTip(), and Kwave::LabelItem::toolTip().
int Kwave::SignalView::samples2pixels | ( | sample_index_t | samples | ) | const |
converts a number of samples into a number of pixels, based on the current zoom factor
samples | a small number of samples (must be positive) |
Definition at line 149 of file SignalView.cpp.
References m_zoom, and Kwave::toInt().
Referenced by dragMoveEvent(), Kwave::TrackView::paintEvent(), and showPosition().
|
protected |
Determines the relationship between a screen position and the current selection.
x | screen position |
Definition at line 173 of file SignalView.cpp.
References canHandleSelection(), Kwave::Selection::first(), Kwave::Selection::last(), LeftBorder, m_offset, m_signal_manager, m_zoom, None, RightBorder, Kwave::SignalManager::selection(), Selection, and selectionTolerance().
Referenced by isInSelection(), and showPosition().
|
virtual |
tolerance in pixel for snapping to a label or selection border
Definition at line 542 of file SignalView.cpp.
Referenced by Kwave::TrackView::findItem(), and selectionPosition().
|
virtualslot |
changes the association to a track
track | the new track index, or -1 if not associated |
Definition at line 113 of file SignalView.cpp.
References m_track_index.
Referenced by Kwave::SignalWidget::slotTrackDeleted(), and Kwave::SignalWidget::slotTrackInserted().
|
virtualslot |
sets new vertical zoom factor
zoom | vertical zoom factor |
Reimplemented in Kwave::TrackView.
Definition at line 137 of file SignalView.cpp.
References m_vertical_zoom, and zoom().
Referenced by Kwave::SignalWidget::insertView(), and Kwave::TrackView::setVerticalZoom().
|
virtualslot |
sets new zoom factor and offset
zoom | the new zoom factor in pixels/sample |
offset | the index of the first visible sample |
Reimplemented in Kwave::TrackView.
Definition at line 119 of file SignalView.cpp.
References hidePosition(), m_offset, m_zoom, offset(), and zoom().
Referenced by Kwave::SignalWidget::insertView(), and Kwave::TrackView::setZoomAndOffset().
|
virtualslot |
shows the cursor at a given position
pos | current position of the cursor |
Definition at line 143 of file SignalView.cpp.
|
protectedvirtualslot |
Shows the current cursor position as a tooltip
text | description of the position |
pos | marker position [samples] |
mouse | the coordinates of the mouse cursor, relative to this widget [pixel] |
Definition at line 222 of file SignalView.cpp.
References LeftBorder, m_offset, m_position_widget, m_position_widget_timer, POSITION_WIDGET_TIME, RightBorder, samples2pixels(), selectionPosition(), and Kwave::SignalView::PositionWidget::setText().
Referenced by findNewItem(), and mouseMoveEvent().
|
signal |
forward a sigCommand to the next layer
Referenced by Kwave::TrackView::contextMenuLabelNew(), and dropEvent().
|
signal |
emitted to request update of the cursor
Referenced by dragEnterEvent(), dragLeaveEvent(), dragMoveEvent(), and dropEvent().
|
inline |
returns the associated signal manager
Definition at line 100 of file SignalView.h.
Referenced by Kwave::SelectionItem::startDragging().
|
signal |
Can be emitted to signal that this view needs to be repainted, probably after synchronizing with other views and additionally throttled to reduce GUI load
view | pointer to the view that needs to be repainted |
Referenced by Kwave::TrackView::refreshAllLayers(), Kwave::TrackView::refreshMarkersLayer(), Kwave::TrackView::refreshSelectionLayer(), Kwave::TrackView::refreshSignalLayer(), and Kwave::TrackView::showCursor().
|
inline |
returns the index of the associated track (or -1)
Definition at line 105 of file SignalView.h.
Referenced by Kwave::SignalWidget::insertView(), and Kwave::SignalWidget::slotTrackDeleted().
|
inline |
returns the current vertical zoom factor
Definition at line 120 of file SignalView.h.
Referenced by Kwave::TrackView::setVerticalZoom().
|
inline |
returns the current zoom [pixels/sample]
Definition at line 115 of file SignalView.h.
Referenced by setVerticalZoom(), and setZoomAndOffset().
|
protected |
widget for displaying associated controls
Definition at line 333 of file SignalView.h.
|
private |
x position where the user clicked the last time, needed for finding out where to start a drag&drop operation [pixel]
Definition at line 426 of file SignalView.h.
Referenced by mouseMoveEvent(), and mousePressEvent().
enum { ... } Kwave::SignalView::m_mouse_mode |
mode of the mouse cursor
Referenced by dragLeaveEvent(), dropEvent(), findNewItem(), keyPressEvent(), leaveEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), and ~SignalView().
|
private |
selection handler
Definition at line 420 of file SignalView.h.
Referenced by mousePressEvent(), and mouseReleaseEvent().
|
protected |
Offset from which signal is being displayed. This is equal to the index of the first visible sample.
Definition at line 348 of file SignalView.h.
Referenced by dragMoveEvent(), dropEvent(), Kwave::TrackView::findItem(), findNewItem(), Kwave::TrackView::handleContextMenu(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), Kwave::TrackView::paintEvent(), selectionPosition(), setZoomAndOffset(), and showPosition().
|
private |
small widget for showing the mouse cursor position
Definition at line 429 of file SignalView.h.
Referenced by showPosition(), and SignalView().
|
private |
timer for automatic hiding
Definition at line 432 of file SignalView.h.
Referenced by showPosition(), and SignalView().
|
protected |
the preferred location, as per construction
Definition at line 339 of file SignalView.h.
|
private |
currently selected view item or null
Definition at line 438 of file SignalView.h.
Referenced by findNewItem(), keyPressEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), and ~SignalView().
|
private |
list of associated widgets, e.g. controls etc
Definition at line 435 of file SignalView.h.
Referenced by addSibling(), and ~SignalView().
|
protected |
the signal manager
Definition at line 336 of file SignalView.h.
Referenced by dragMoveEvent(), dropEvent(), Kwave::TrackView::findItem(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), Kwave::TrackView::paintEvent(), samples2ms(), and selectionPosition().
|
protected |
index of the associated track or -1 if no relation to a track
Definition at line 342 of file SignalView.h.
Referenced by setTrack().
|
private |
zoom factor for vertical size
Definition at line 410 of file SignalView.h.
Referenced by setVerticalZoom().
|
protected |
number of samples per pixel
Definition at line 351 of file SignalView.h.
Referenced by Kwave::TrackView::findItem(), pixels2samples(), samples2pixels(), selectionPosition(), and setZoomAndOffset().