kwave
18.07.70
|
#include <MainWidget.h>
Public Slots | |
virtual int | executeCommand (const QString &command) Q_DECL_OVERRIDE |
void | setOffset (sample_index_t new_offset) |
virtual void | scrollTo (sample_index_t pos) Q_DECL_OVERRIDE |
virtual void | setZoom (double new_zoom) Q_DECL_OVERRIDE |
void | zoomSelection () |
void | zoomAll () |
void | zoomNormal () |
void | zoomIn (int pos=-1) |
void | zoomOut (int pos=-1) |
Signals | |
void | sigZoomChanged (double zoom) |
void | sigCommand (const QString &command) |
void | sigVisibleRangeChanged (sample_index_t offset, sample_index_t visible, sample_index_t total) |
Public Member Functions | |
MainWidget (QWidget *parent, Kwave::FileContext &context, const QSize &preferred_size) | |
virtual bool | isOK () |
virtual | ~MainWidget () Q_DECL_OVERRIDE |
virtual double | zoom () const Q_DECL_OVERRIDE |
virtual int | visibleWidth () const Q_DECL_OVERRIDE |
virtual sample_index_t | visibleSamples () const Q_DECL_OVERRIDE |
virtual sample_index_t | visibleOffset () |
virtual QSize | sizeHint () const Q_DECL_OVERRIDE |
![]() | |
CommandHandler () | |
virtual | ~CommandHandler () |
virtual int | executeCommand (const QString &command)=0 |
![]() | |
Zoomable () | |
virtual | ~Zoomable () |
virtual void | setZoom (double factor)=0 |
virtual void | scrollTo (sample_index_t pos)=0 |
Protected Slots | |
void | updateViewRange () |
Protected Member Functions | |
virtual void | dragEnterEvent (QDragEnterEvent *event) Q_DECL_OVERRIDE |
virtual void | dropEvent (QDropEvent *event) Q_DECL_OVERRIDE |
virtual void | resizeEvent (QResizeEvent *event) Q_DECL_OVERRIDE |
virtual void | wheelEvent (QWheelEvent *event) Q_DECL_OVERRIDE |
virtual void | closeEvent (QCloseEvent *e) Q_DECL_OVERRIDE |
Private Slots | |
void | slotTrackInserted (unsigned int index, Kwave::Track *track) |
void | slotTrackDeleted (unsigned int index, Kwave::Track *track) |
void | refreshHorizontalScrollBar () |
void | horizontalScrollBarMoved (int newval) |
Private Member Functions | |
sample_index_t | ms2samples (double ms) |
sample_index_t | pixels2samples (unsigned int pixels) const |
int | samples2pixels (sample_index_t samples) const |
double | fullZoom () const |
void | fixZoomAndOffset (double zoom, sample_index_t offset) |
void | addLabel (sample_index_t pos, const QString &description) |
bool | labelProperties (Kwave::Label &label) |
int | loadLabels (const QString &filename) |
int | saveLabels (const QString &filename) |
Private Attributes | |
Kwave::FileContext & | m_context |
QVBoxLayout | m_upper_dock |
QVBoxLayout | m_lower_dock |
QScrollArea | m_scroll_area |
QScrollBar * | m_horizontal_scrollbar |
Kwave::SignalWidget | m_signal_widget |
Kwave::OverViewWidget * | m_overview |
sample_index_t | m_offset |
double | m_zoom |
QSize | m_preferred_size |
QTimer | m_delayed_update_timer |
The main widget is responsible for controlling the zoom on the time axis and the scrolling. For this purpose it has an optionally enabled vertical scroll bar at the right side and a horizontal scroll bar plus an overview widget at the lower side. The main view contains a viewport that contains a signal widget, which is fit in horizontally and has variable vertical size (scrolled via the vertical scroll bar if necessary). The
layout looks like this:
Definition at line 83 of file MainWidget.h.
Kwave::MainWidget::MainWidget | ( | QWidget * | parent, |
Kwave::FileContext & | context, | ||
const QSize & | preferred_size | ||
) |
Constructor.
parent | parent widget |
context | reference to the context of this instance |
preferred_size | preferred size of the widget, needed in MDI mode, otherwise ignored |
Definition at line 96 of file MainWidget.cpp.
References Kwave::connect(), horizontalScrollBarMoved(), m_context, m_delayed_update_timer, m_horizontal_scrollbar, m_lower_dock, m_overview, m_scroll_area, m_signal_widget, m_upper_dock, Kwave::SignalManager::metaData(), Kwave::OverViewWidget::metaDataChanged(), Kwave::SignalManager::playbackController(), Kwave::FileContext::pluginManager(), Kwave::PluginManager::registerViewManager(), setOffset(), sigCommand(), Kwave::FileContext::signalManager(), Kwave::OverViewWidget::sizeHint(), slotTrackDeleted(), slotTrackInserted(), and updateViewRange().
|
virtual |
Destructor.
Definition at line 230 of file MainWidget.cpp.
References m_context, Kwave::FileContext::pluginManager(), and Kwave::PluginManager::registerViewManager().
|
private |
add a new label
pos | position of the label [samples] |
description | optional label description |
Definition at line 887 of file MainWidget.cpp.
References Kwave::SignalManager::abortUndoTransaction(), Kwave::SignalManager::addLabel(), Kwave::SignalManager::deleteLabel(), Kwave::SignalManager::isModified(), Kwave::MetaData::isNull(), Kwave::SignalManager::labelIndex(), labelProperties(), m_context, Kwave::SignalManager::setModified(), and Kwave::FileContext::signalManager().
Referenced by executeCommand(), and sizeHint().
|
protectedvirtual |
Definition at line 347 of file MainWidget.cpp.
References Kwave::FileContext::closeFile(), and m_context.
Referenced by sizeHint().
|
protectedvirtual |
Definition at line 257 of file MainWidget.cpp.
References Kwave::FileDrag::canDecode().
Referenced by sizeHint().
|
protectedvirtual |
For dropping data into an empty signal
Definition at line 269 of file MainWidget.cpp.
References Kwave::Drag::canDecode(), DBG, Kwave::Drag::decode(), Kwave::SignalManager::isEmpty(), m_context, m_offset, pixels2samples(), Kwave::SignalManager::selectRange(), and Kwave::FileContext::signalManager().
Referenced by sizeHint().
|
virtualslot |
Execute a Kwave text command
command | a text command |
-ENOSYS | is returned if the command is unknown in this component |
Definition at line 389 of file MainWidget.cpp.
References addLabel(), Kwave::SignalManager::addLabel(), CASE_COMMAND, Kwave::SignalManager::executeCommand(), Kwave::Selection::first(), Kwave::Parser::hasParams(), Kwave::Parser::isDone(), labelProperties(), Kwave::Selection::last(), Kwave::Selection::length(), Kwave::SignalManager::length(), loadLabels(), m_context, m_offset, Kwave::SignalManager::metaData(), Kwave::Parser::nextParam(), saveLabels(), Kwave::SignalManager::selection(), Kwave::SignalManager::selectRange(), setOffset(), Kwave::FileContext::signalManager(), Kwave::Parser::toInt(), Kwave::Parser::toSampleIndex(), visibleSamples(), zoomAll(), zoomIn(), zoomNormal(), zoomOut(), and zoomSelection().
Referenced by sizeHint(), and wheelEvent().
|
private |
Fixes the zoom and the offset of the display so that no non-existing samples (index < 0 or index >= length) have to be displayed and the current display window of the signal fits into the screen.
zoom | new zoom value [samples/pixel] |
offset | new offset value [samples] |
Definition at line 707 of file MainWidget.cpp.
References fullZoom(), Kwave::SignalManager::length(), m_context, m_offset, m_zoom, MINIMUM_SAMPLES_PER_SCREEN, pixels2samples(), Kwave::FileContext::signalManager(), sigVisibleRangeChanged(), sigZoomChanged(), updateViewRange(), visibleSamples(), visibleWidth(), and zoom().
Referenced by setOffset(), setZoom(), sizeHint(), updateViewRange(), zoomIn(), and zoomOut().
|
private |
Returns the zoom value that will be used to fit the whole signal into the current window.
Definition at line 661 of file MainWidget.cpp.
References DEFAULT_DISPLAY_TIME, Kwave::FileInfo::get(), Kwave::INF_ESTIMATED_LENGTH, Kwave::SignalManager::isEmpty(), Kwave::SignalManager::length(), m_context, Kwave::SignalManager::metaData(), Kwave::SignalManager::rate(), Kwave::FileContext::signalManager(), and visibleWidth().
Referenced by fixZoomAndOffset(), sizeHint(), and zoomAll().
|
privateslot |
Connected to the horizontal scrollbar for scrolling left/right
Definition at line 580 of file MainWidget.cpp.
References Kwave::SignalManager::length(), m_context, setOffset(), and Kwave::FileContext::signalManager().
Referenced by MainWidget(), and sizeHint().
|
virtual |
Returns true if this instance was successfully initialized, or false if something went wrong during initialization.
Definition at line 224 of file MainWidget.cpp.
References m_horizontal_scrollbar, and m_overview.
|
private |
Opens a dialog for editing the properties of a label
label | a Label that should be edited |
Definition at line 1026 of file MainWidget.cpp.
References Kwave::SignalManager::abortUndoTransaction(), Kwave::SignalManager::deleteLabel(), Kwave::SignalManager::findLabel(), Kwave::MetaData::isNull(), Kwave::SignalManager::labelIndex(), Kwave::LabelPropertiesWidget::labelName(), Kwave::LabelPropertiesWidget::labelPosition(), Kwave::SignalManager::length(), m_context, Kwave::SignalManager::modifyLabel(), Kwave::Label::moveTo(), Kwave::Label::name(), Kwave::Label::pos(), Kwave::SignalManager::rate(), Kwave::Label::rename(), Kwave::LabelPropertiesWidget::saveSettings(), Kwave::LabelPropertiesWidget::setLabelIndex(), Kwave::LabelPropertiesWidget::setLabelName(), Kwave::LabelPropertiesWidget::setLabelPosition(), Kwave::FileContext::signalManager(), and Kwave::MessageBox::warningYesNoCancel().
Referenced by addLabel(), executeCommand(), and sizeHint().
|
private |
load labels from a file
filename | file name from which to load the labels, a file open dialog will be shown if zero length |
Definition at line 918 of file MainWidget.cpp.
References _, LABEL_LIST_EXT, LABEL_LIST_FILTER, Kwave::FileContext::loadBatch(), m_context, name, Kwave::FileDialog::OpenFile, Kwave::FileDialog::selectedUrl(), and Kwave::FileContext::signalManager().
Referenced by executeCommand(), and sizeHint().
|
private |
Converts a time in milliseconds to a number of samples, based on the current signal rate.
ms | time in milliseconds |
Definition at line 623 of file MainWidget.cpp.
References m_context, Kwave::SignalManager::rate(), and Kwave::FileContext::signalManager().
Referenced by sizeHint().
|
private |
Converts a sample index into a pixel offset using the current zoom value. Always rounds up or downwards. If the number of pixels or the current zoom is less than zero, the return value will be zero.
pixels | pixel offset |
Definition at line 634 of file MainWidget.cpp.
References m_zoom.
Referenced by dropEvent(), fixZoomAndOffset(), sizeHint(), and visibleSamples().
|
privateslot |
refresh the scale and position of the horizontal scrollbar
Definition at line 520 of file MainWidget.cpp.
References Kwave::SignalManager::isEmpty(), Kwave::SignalManager::length(), m_context, m_horizontal_scrollbar, m_offset, m_overview, Kwave::FileContext::signalManager(), Kwave::toInt(), and visibleSamples().
Referenced by sizeHint(), and updateViewRange().
|
protectedvirtual |
Called if the main widget has been resized and resizes/moves the signal widget and the channel controls
Definition at line 238 of file MainWidget.cpp.
References Kwave::FileContext::app(), Kwave::App::GUI_TAB, Kwave::App::guiType(), Kwave::FileContext::isActive(), m_context, m_delayed_update_timer, and updateViewRange().
Referenced by sizeHint().
|
private |
Converts a pixel offset into a sample index using the current zoom value. Always rounds op or downwards.
samples | number of samples to be converted |
Definition at line 642 of file MainWidget.cpp.
References m_zoom, and Kwave::toInt().
Referenced by scrollTo(), and sizeHint().
|
private |
save all labels to a file
filename | file name from which to load the labels, a file open dialog will be shown if zero length |
Definition at line 952 of file MainWidget.cpp.
References _, Kwave::Parser::escape(), Kwave::Logger::Info, LABEL_LIST_EXT, LABEL_LIST_FILTER, Kwave::Logger::log(), m_context, Kwave::SignalManager::metaData(), Kwave::Label::name(), name, Kwave::Label::pos(), Kwave::FileDialog::SaveFile, Kwave::FileDialog::selectedUrl(), Kwave::FileContext::signalManager(), Kwave::FileContext::signalName(), and Kwave::MessageBox::warningYesNo().
Referenced by executeCommand(), and sizeHint().
|
virtualslot |
Scrolls the display so that the given position gets visible, centered within the display if possible.
Definition at line 793 of file MainWidget.cpp.
References m_offset, samples2pixels(), setOffset(), and visibleSamples().
Referenced by sizeHint().
|
slot |
Sets the display offset [samples] and refreshes the screen.
new_offset | new value for the offset in samples, will be internally limited to [0...length-1] |
Definition at line 787 of file MainWidget.cpp.
References fixZoomAndOffset(), and m_zoom.
Referenced by executeCommand(), horizontalScrollBarMoved(), MainWidget(), scrollTo(), and sizeHint().
|
virtualslot |
sets a new zoom factor [samples/pixel], does not refresh the screen
new_zoom | new zoom value, will be internally limited to [length/width...1/width] (from full display to one visible sample only) |
Definition at line 781 of file MainWidget.cpp.
References fixZoomAndOffset(), and m_offset.
Referenced by sizeHint(), zoomAll(), zoomNormal(), and zoomSelection().
|
signal |
forward a sigCommand to the next layer
Referenced by MainWidget(), and sizeHint().
|
signal |
emitted when the visible range has changed
Referenced by fixZoomAndOffset(), and sizeHint().
|
signal |
Will be emitted if the zoom factor of the view has changed.
Referenced by fixZoomAndOffset(), and sizeHint().
|
inlinevirtual |
Returns the preferred size of the widget
Definition at line 123 of file MainWidget.h.
References addLabel(), closeEvent(), dragEnterEvent(), dropEvent(), executeCommand(), fixZoomAndOffset(), fullZoom(), horizontalScrollBarMoved(), labelProperties(), loadLabels(), m_preferred_size, ms2samples(), pixels2samples(), refreshHorizontalScrollBar(), resizeEvent(), samples2pixels(), saveLabels(), scrollTo(), setOffset(), setZoom(), sigCommand(), sigVisibleRangeChanged(), sigZoomChanged(), slotTrackDeleted(), slotTrackInserted(), updateViewRange(), wheelEvent(), zoom(), zoomAll(), zoomIn(), zoomNormal(), zoomOut(), and zoomSelection().
|
privateslot |
Called if a track has been deleted. Updates the display by resizing/re-positioning the signal views.
index | the index of the inserted track [0...tracks-1] |
track | pointer to the track object (ignored here) |
Definition at line 372 of file MainWidget.cpp.
References updateViewRange().
Referenced by MainWidget(), and sizeHint().
|
privateslot |
Called if a track has been added. Updates the display by resizing/re-positioning the signal views.
index | the index of the inserted track [0...tracks-1] |
track | pointer to the track object (ignored here) |
Definition at line 353 of file MainWidget.cpp.
References m_context, Kwave::FileContext::signalManager(), Kwave::SignalManager::tracks(), updateViewRange(), and zoomAll().
Referenced by MainWidget(), and sizeHint().
|
protectedslot |
updates all widgets that depend on the current view range
Definition at line 593 of file MainWidget.cpp.
References fixZoomAndOffset(), Kwave::SignalManager::isEmpty(), Kwave::SignalManager::length(), m_context, m_horizontal_scrollbar, m_offset, m_overview, m_signal_widget, m_zoom, refreshHorizontalScrollBar(), Kwave::OverViewWidget::setRange(), Kwave::SignalWidget::setZoomAndOffset(), Kwave::FileContext::signalManager(), and visibleSamples().
Referenced by fixZoomAndOffset(), MainWidget(), resizeEvent(), sizeHint(), slotTrackDeleted(), and slotTrackInserted().
|
inlinevirtual |
Returns the current start position of the visible area [samples]
Definition at line 120 of file MainWidget.h.
References m_offset.
|
virtual |
Returns the width of the current view in samples
Implements Kwave::Zoomable.
Definition at line 655 of file MainWidget.cpp.
References pixels2samples(), and visibleWidth().
Referenced by executeCommand(), fixZoomAndOffset(), refreshHorizontalScrollBar(), scrollTo(), updateViewRange(), zoomIn(), zoomNormal(), and zoomOut().
|
virtual |
Returns the width of the current view in pixels
Implements Kwave::Zoomable.
Definition at line 649 of file MainWidget.cpp.
References m_signal_widget, and Kwave::SignalWidget::visibleWidth().
Referenced by fixZoomAndOffset(), fullZoom(), visibleSamples(), zoomNormal(), and zoomSelection().
|
protectedvirtual |
slot for mouse wheel events, for scrolling/zooming
Definition at line 300 of file MainWidget.cpp.
References _, executeCommand(), m_overview, m_scroll_area, m_signal_widget, and Kwave::SignalWidget::mapToViewPort().
Referenced by sizeHint().
|
virtual |
Returns the current zoom factor [samples/pixel]
Implements Kwave::Zoomable.
Definition at line 383 of file MainWidget.cpp.
References m_zoom.
Referenced by fixZoomAndOffset(), and sizeHint().
|
slot |
Zooms the signal to be fully visible.
Definition at line 831 of file MainWidget.cpp.
References fullZoom(), and setZoom().
Referenced by executeCommand(), sizeHint(), and slotTrackInserted().
|
slot |
Zooms into the signal, the new display will show the signal zoomed at the position given as parameter (if >= 0) or centered if a position < 0 is given.
Definition at line 847 of file MainWidget.cpp.
References fixZoomAndOffset(), m_offset, m_zoom, Kwave::toInt(), and visibleSamples().
Referenced by executeCommand(), and sizeHint().
|
slot |
Zooms the signal to one-pixel-per-sample. Equivalent to setZoom(1.0).
Definition at line 837 of file MainWidget.cpp.
References m_offset, setZoom(), visibleSamples(), and visibleWidth().
Referenced by executeCommand(), and sizeHint().
|
slot |
Zooms out the signal, the new display will show the signal zoomed at the position given as parameter (if >= 0) or centered if a position < 0 is given.
Definition at line 867 of file MainWidget.cpp.
References fixZoomAndOffset(), m_offset, m_zoom, Kwave::toInt(), and visibleSamples().
Referenced by executeCommand(), and sizeHint().
|
slot |
Zooms into the selected range between the left and right marker.
Definition at line 814 of file MainWidget.cpp.
References Kwave::Selection::length(), m_context, m_offset, Kwave::Selection::offset(), Kwave::SignalManager::selection(), setZoom(), Kwave::FileContext::signalManager(), and visibleWidth().
Referenced by executeCommand(), and sizeHint().
|
private |
context of the Kwave application instance
Definition at line 338 of file MainWidget.h.
Referenced by addLabel(), closeEvent(), dropEvent(), executeCommand(), fixZoomAndOffset(), fullZoom(), horizontalScrollBarMoved(), labelProperties(), loadLabels(), MainWidget(), ms2samples(), refreshHorizontalScrollBar(), resizeEvent(), saveLabels(), slotTrackInserted(), updateViewRange(), zoomSelection(), and ~MainWidget().
|
private |
timer for delayed update
Definition at line 371 of file MainWidget.h.
Referenced by MainWidget(), and resizeEvent().
|
private |
horizontal scrollbar
Definition at line 350 of file MainWidget.h.
Referenced by isOK(), MainWidget(), refreshHorizontalScrollBar(), and updateViewRange().
|
private |
lower docking area, managed by the signal widget
Definition at line 344 of file MainWidget.h.
Referenced by MainWidget().
|
private |
Offset from which signal is being displayed. This is equal to the index of the first visible sample.
Definition at line 362 of file MainWidget.h.
Referenced by dropEvent(), executeCommand(), fixZoomAndOffset(), refreshHorizontalScrollBar(), scrollTo(), setZoom(), updateViewRange(), visibleOffset(), zoomIn(), zoomNormal(), zoomOut(), and zoomSelection().
|
private |
overview widget
Definition at line 356 of file MainWidget.h.
Referenced by isOK(), MainWidget(), refreshHorizontalScrollBar(), updateViewRange(), and wheelEvent().
|
private |
|
private |
container widget that contains the signal widget.
Definition at line 347 of file MainWidget.h.
Referenced by MainWidget(), and wheelEvent().
|
private |
the widget that shows the signal, scrolled within the view port
Definition at line 353 of file MainWidget.h.
Referenced by MainWidget(), updateViewRange(), visibleWidth(), and wheelEvent().
|
private |
upper docking area, managed by the signal widget
Definition at line 341 of file MainWidget.h.
Referenced by MainWidget().
|
private |
number of samples per pixel
Definition at line 365 of file MainWidget.h.
Referenced by fixZoomAndOffset(), pixels2samples(), samples2pixels(), setOffset(), updateViewRange(), zoom(), zoomIn(), and zoomOut().