kwave  18.07.70
Kwave::TrackView Class Reference

#include <TrackView.h>

Inheritance diagram for Kwave::TrackView:
Inheritance graph
Collaboration diagram for Kwave::TrackView:
Collaboration graph

Public Slots

virtual void showCursor (sample_index_t pos=SAMPLE_INDEX_MAX) Q_DECL_OVERRIDE
 
- Public Slots inherited from Kwave::SignalView
virtual void setTrack (int track)
 
virtual void showCursor (sample_index_t pos=SAMPLE_INDEX_MAX)
 

Public Member Functions

 TrackView (QWidget *parent, QWidget *controls, Kwave::SignalManager *signal_manager, Kwave::Track *track)
 
virtual ~TrackView () Q_DECL_OVERRIDE
 
virtual void refresh () Q_DECL_OVERRIDE
 
virtual void setZoomAndOffset (double zoom, sample_index_t offset) Q_DECL_OVERRIDE
 
virtual void setVerticalZoom (double zoom) Q_DECL_OVERRIDE
 
virtual void resizeEvent (QResizeEvent *event) Q_DECL_OVERRIDE
 
virtual void paintEvent (QPaintEvent *) Q_DECL_OVERRIDE
 
virtual bool canHandleSelection () const Q_DECL_OVERRIDE
 
virtual QSharedPointer< Kwave::ViewItemfindItem (const QPoint &pos) Q_DECL_OVERRIDE
 
virtual void handleContextMenu (const QPoint &pos, QMenu *menu) Q_DECL_OVERRIDE
 
- Public Member Functions inherited from Kwave::SignalView
 SignalView (QWidget *parent, QWidget *controls, Kwave::SignalManager *signal_manager, Location preferred_location, int track=-1)
 
virtual ~SignalView () Q_DECL_OVERRIDE
 
Location preferredLocation () const
 
Kwave::SignalManagersignalManager () 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 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 addSibling (QWidget *widget)
 

Private Slots

void refreshSignalLayer ()
 
void refreshSelectionLayer ()
 
void refreshMarkersLayer ()
 
void refreshAllLayers ()
 
void contextMenuLabelNew ()
 

Private Attributes

Kwave::TrackPixmap m_pixmap
 
int m_last_width
 
int m_last_height
 
QImage m_image
 
QImage m_img_signal
 
QImage m_img_selection
 
QImage m_img_markers
 
bool m_img_signal_needs_refresh
 
bool m_img_selection_needs_refresh
 
bool m_img_markers_needs_refresh
 
sample_index_t m_mouse_click_position
 
sample_index_t m_cursor_pos
 

Additional Inherited Members

- Public Types inherited from Kwave::SignalView
enum  Location {
  UpperDockTop, UpperDockBottom, Top, AboveTrackTop,
  AboveTrackBottom, BelowTrackTop, BelowTrackBottom, Bottom,
  LowerDockTop, LowerDockBottom
}
 
- Signals inherited from Kwave::SignalView
void contentSizeChanged ()
 
void sigCursorChanged (sample_index_t pos)
 
void sigNeedRepaint (Kwave::SignalView *view)
 
void sigCommand (const QString &command)
 
- Protected Types inherited from Kwave::SignalView
enum  SelectionPosEnum { None = 0x0000, LeftBorder = 0x0001, RightBorder = 0x0002, Selection = 0x8000 }
 
- Protected Slots inherited from Kwave::SignalView
virtual void showPosition (const QString &text, sample_index_t pos, const QPoint &mouse)
 
virtual void hidePosition ()
 
- Protected Member Functions inherited from Kwave::SignalView
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 inherited from Kwave::SignalView
QWidget * m_controls
 
Kwave::SignalManagerm_signal_manager
 
Location m_preferred_location
 
int m_track_index
 
sample_index_t m_offset
 
double m_zoom
 

Detailed Description

Definition at line 44 of file TrackView.h.

Constructor & Destructor Documentation

◆ TrackView()

Kwave::TrackView::TrackView ( QWidget *  parent,
QWidget *  controls,
Kwave::SignalManager signal_manager,
Kwave::Track track 
)

Constructor

Parameters
parentpointer to the parent widget
controlscontainer widget for associated controls
signal_managerthe signal manager
trackthe track object this view is bound to

Definition at line 47 of file TrackView.cpp.

References _, Kwave::MultiStateWidget::addPixmap(), Kwave::connect(), m_pixmap, MINIMUM_HEIGHT, Kwave::SignalManager::playbackController(), refreshMarkersLayer(), refreshSelectionLayer(), refreshSignalLayer(), Kwave::Track::selected(), Kwave::SignalManager::selection(), showCursor(), and Kwave::MultiStateWidget::switchState().

50  :Kwave::SignalView(parent, controls, signal_manager,
52  m_pixmap(*track),
53  m_last_width(-1),
54  m_last_height(-1),
55  m_image(),
56  m_img_signal(),
58  m_img_markers(),
64 {
65  setMinimumSize(400, MINIMUM_HEIGHT);
66 
67  // trigger a repaint request when the signal has been modified
68  connect(&m_pixmap, SIGNAL(sigModified()),
69  this, SLOT(refreshSignalLayer()));
70 
71  if (controls) {
72  // add the channel controls, for "enabled" / "disabled"
73 
74  QVBoxLayout *layout = new QVBoxLayout(controls);
75  Q_ASSERT(layout);
76  if (!layout) return;
77 
79  new(std::nothrow) Kwave::MultiStateWidget(Q_NULLPTR, 0);
80  Q_ASSERT(msw);
81  if (!msw) {
82  delete layout;
83  return;
84  }
85 
86  // add a bitmap for off (0 and on (1)
87  msw->addPixmap(_("light_off.xpm"));
88  msw->addPixmap(_("light_on.xpm"));
89 
90  // connect widget <-> track
91  connect(
92  msw, SIGNAL(clicked(int)),
93  track, SLOT(toggleSelection())
94  );
95  connect(
96  track, SIGNAL(sigSelectionChanged(bool)),
97  msw, SLOT(switchState(bool))
98  );
99 
100  msw->setMinimumSize(20, 20);
101  msw->switchState(track->selected());
102  layout->addWidget(msw);
103  }
104 
105  // get informed about meta data changes
106  connect(signal_manager, SIGNAL(
107  sigMetaDataChanged(Kwave::MetaDataList)),
108  this, SLOT(refreshMarkersLayer()),
109  Qt::QueuedConnection);
110 
111  // get informed about selection changes
112  connect(&(signal_manager->selection()),
113  SIGNAL(changed(sample_index_t,sample_index_t)),
114  this,
115  SLOT(refreshSelectionLayer()));
116 
117  // update the playback position
118  connect(&(signal_manager->playbackController()),
119  SIGNAL(sigPlaybackPos(sample_index_t)),
120  this,
121  SLOT(showCursor(sample_index_t)));
122  connect(&(signal_manager->playbackController()),
123  SIGNAL(sigPlaybackStopped()),
124  this,
125  SLOT(showCursor()));
126 
127  // update when the track selection changed
128  connect(track, SIGNAL(sigSelectionChanged(bool)),
129  this, SLOT(refreshSignalLayer()));
130 }
QImage m_img_selection
Definition: TrackView.h:155
bool selected() const
Definition: Track.h:137
bool m_img_signal_needs_refresh
Definition: TrackView.h:161
bool m_img_markers_needs_refresh
Definition: TrackView.h:167
sample_index_t m_mouse_click_position
Definition: TrackView.h:170
#define MINIMUM_HEIGHT
Definition: TrackView.cpp:44
QImage m_img_signal
Definition: TrackView.h:152
Kwave::Selection & selection()
quint64 sample_index_t
Definition: Sample.h:28
Kwave::PlaybackController & playbackController()
void addPixmap(const QString &filename)
bool connect(Kwave::StreamObject &source, const char *output, Kwave::StreamObject &sink, const char *input)
Definition: Connect.cpp:48
Kwave::TrackPixmap m_pixmap
Definition: TrackView.h:140
void refreshSignalLayer()
Definition: TrackView.cpp:307
void refreshSelectionLayer()
Definition: TrackView.cpp:314
void refreshMarkersLayer()
Definition: TrackView.cpp:321
QImage m_img_markers
Definition: TrackView.h:158
virtual void showCursor(sample_index_t pos=SAMPLE_INDEX_MAX) Q_DECL_OVERRIDE
Definition: TrackView.cpp:520
#define _(m)
Definition: memcpy.c:66
bool m_img_selection_needs_refresh
Definition: TrackView.h:164
sample_index_t m_cursor_pos
Definition: TrackView.h:173
#define SAMPLE_INDEX_MAX
Definition: Sample.h:31
Here is the call graph for this function:

◆ ~TrackView()

Kwave::TrackView::~TrackView ( )
virtual

Destructor

Definition at line 133 of file TrackView.cpp.

134 {
135 }

Member Function Documentation

◆ canHandleSelection()

virtual bool Kwave::TrackView::canHandleSelection ( ) const
inlinevirtual

Should be overwritten by subclasses that can display the currently selected range and allow the user to change the selection by mouse.

Returns
true if mouse selection is handled

Reimplemented from Kwave::SignalView.

Definition at line 90 of file TrackView.h.

References SAMPLE_INDEX_MAX.

90 { return true; }

◆ contextMenuLabelNew

void Kwave::TrackView::contextMenuLabelNew ( )
privateslot

context menu: "label / new"

Definition at line 287 of file TrackView.cpp.

References _, m_mouse_click_position, and Kwave::SignalView::sigCommand().

Referenced by handleContextMenu().

288 {
289  emit sigCommand(_("label:add(%1)").arg(m_mouse_click_position));
290 }
void sigCommand(const QString &command)
sample_index_t m_mouse_click_position
Definition: TrackView.h:170
#define _(m)
Definition: memcpy.c:66
Here is the caller graph for this function:

◆ findItem()

QSharedPointer< Kwave::ViewItem > Kwave::TrackView::findItem ( const QPoint &  pos)
virtual

Tries to find the nearest item that is visible in this view at a given position

Parameters
posposition to look at, relative to view [pixels]
Returns
the nearest ViewObject in range or a null pointer if nothing found

Reimplemented from Kwave::SignalView.

Definition at line 174 of file TrackView.cpp.

References Kwave::Selection::first(), Kwave::MetaData::isNull(), Kwave::Selection::last(), Kwave::Selection::length(), Kwave::SignalView::m_offset, Kwave::SignalView::m_signal_manager, Kwave::SignalView::m_zoom, Kwave::SignalManager::metaData(), Kwave::SignalView::offset(), Kwave::SignalView::pixels2samples(), Kwave::Label::pos(), Kwave::SignalManager::selection(), and Kwave::SignalView::selectionTolerance().

175 {
176  QSharedPointer<Kwave::ViewItem> item =
177  QSharedPointer<Kwave::ViewItem>(Q_NULLPTR);
178  Q_ASSERT(m_signal_manager);
179  if (!m_signal_manager) return item;
180 
181  const double offset = m_offset + pixels2samples(pos.x()); // [samples]
182  const double tolerance = m_zoom * selectionTolerance(); // [samples]
183  const double fine_pos = static_cast<double>(m_offset) +
184  (static_cast<double>(pos.x()) * m_zoom);
185 
186  // we support the following items (with this priority):
187  // 1. a label, which can be moved
188  // 2. the border of a selection (left or right), which can be moved
189  // 3. the body of a selection, which can be dragged
190 
191  // find the nearest label
192  Kwave::Label nearest_label;
193  unsigned int nearest_label_index = 0;
194  double d_label = tolerance;
195  {
196  unsigned int index = 0;
197  foreach (const Kwave::Label &label,
199  {
200  double d = qAbs(static_cast<double>(label.pos()) - fine_pos);
201  if (d < qMin(d_label, tolerance)) {
202  d_label = d;
203  nearest_label = label;
204  nearest_label_index = index;
205  }
206  index++;
207  }
208  }
209 
210  // get information about the current selection
211  double selection_first = static_cast<double>(
213  double selection_last = static_cast<double>(
215  bool selection_is_empty = (m_signal_manager->selection().length() == 0);
216  const double d_selection_left = qAbs(selection_first - fine_pos);
217  const double d_selection_right = qAbs(selection_last - fine_pos);
218 
219  // special case: label is near selection left and cursor is left
220  // of selection -> take the label
221  // (or vice versa at the right border)
222  bool prefer_the_label =
223  ((d_selection_left < tolerance) && (fine_pos < selection_first)) ||
224  ((d_selection_right < tolerance) && (fine_pos > selection_last));
225  bool selection_is_nearer =
226  (d_selection_left <= d_label) || (d_selection_right <= d_label);
227  if (selection_is_nearer && !prefer_the_label) {
228  // one of the selection borders is nearer
229  d_label = d_selection_left + d_selection_right;
230  }
231 
232  if ( (d_label <= qMin(d_selection_left, d_selection_right)) &&
233  !nearest_label.isNull() ) {
234  // found a label
235  return QSharedPointer<Kwave::ViewItem>(new(std::nothrow)
237  nearest_label_index, nearest_label));
238  }
239 
240  if ( (d_selection_left < qMin(tolerance, d_selection_right)) ||
241  ((d_selection_left < tolerance) && selection_is_empty) )
242  {
243  // found selection border (left) or empty selection
244  return QSharedPointer<Kwave::ViewItem>(new(std::nothrow)
246  *this, *m_signal_manager,
248  }
249 
250  if (d_selection_right < qMin(tolerance, d_selection_left)) {
251  // found selection border (right)
252  return QSharedPointer<Kwave::ViewItem>(new(std::nothrow)
254  *this, *m_signal_manager,
256  }
257 
258  if ((offset >= selection_first) && (offset <= selection_last)) {
259  // found selection body
260  return QSharedPointer<Kwave::ViewItem>(new(std::nothrow)
262  }
263 
264  // nothing found
265  return QSharedPointer<Kwave::ViewItem>(Q_NULLPTR);
266 }
sample_index_t m_offset
Definition: SignalView.h:348
sample_index_t first() const
Definition: Selection.h:71
virtual int selectionTolerance() const
Definition: SignalView.cpp:542
sample_index_t last() const
Definition: Selection.h:76
Kwave::MetaDataList & metaData()
Kwave::Selection & selection()
virtual sample_index_t pos() const
Definition: Label.cpp:56
sample_index_t offset() const
Definition: SignalView.h:110
sample_index_t length() const
Definition: Selection.h:66
virtual bool isNull() const
Definition: MetaData.cpp:69
sample_index_t pixels2samples(int pixels) const
Definition: SignalView.cpp:155
Kwave::SignalManager * m_signal_manager
Definition: SignalView.h:336
Here is the call graph for this function:

◆ handleContextMenu()

void Kwave::TrackView::handleContextMenu ( const QPoint &  pos,
QMenu *  menu 
)
virtual

Called when the context menu has been activated over this view

Parameters
posa position in pixel within this widget
menupointer to the context menu

Reimplemented from Kwave::SignalView.

Definition at line 269 of file TrackView.cpp.

References _, contextMenuLabelNew(), m_mouse_click_position, Kwave::SignalView::m_offset, and Kwave::SignalView::pixels2samples().

270 {
271  QMenu *submenu_label = menu->addMenu(i18n("Label"));
272  Q_ASSERT(submenu_label);
273  if (!submenu_label) return;
274 
275  // add label
276  QAction *action_label_new = submenu_label->addAction(
277  QIcon::fromTheme(_("list-add")),
278  i18n("New"), this, SLOT(contextMenuLabelNew()));
279  Q_ASSERT(action_label_new);
280  if (!action_label_new) return;
281 
282  // store the menu position
284 }
sample_index_t m_offset
Definition: SignalView.h:348
sample_index_t m_mouse_click_position
Definition: TrackView.h:170
void contextMenuLabelNew()
Definition: TrackView.cpp:287
sample_index_t pixels2samples(int pixels) const
Definition: SignalView.cpp:155
#define _(m)
Definition: memcpy.c:66
Here is the call graph for this function:

◆ paintEvent()

void Kwave::TrackView::paintEvent ( QPaintEvent *  )
virtual

slot for repainting the widget or portions of it

Definition at line 337 of file TrackView.cpp.

References Kwave::Selection::first(), Kwave::TrackPixmap::height(), Kwave::TrackPixmap::isModified(), Kwave::Selection::last(), Kwave::SignalView::lastVisible(), m_cursor_pos, m_image, m_img_markers, m_img_markers_needs_refresh, m_img_selection, m_img_selection_needs_refresh, m_img_signal, m_img_signal_needs_refresh, m_last_height, m_last_width, Kwave::SignalView::m_offset, m_pixmap, Kwave::SignalView::m_signal_manager, Kwave::SignalManager::metaData(), Kwave::SignalView::pixels2samples(), Kwave::TrackPixmap::pixmap(), Kwave::Label::pos(), Kwave::TrackPixmap::repaint(), Kwave::TrackPixmap::resize(), SAMPLE_INDEX_MAX, Kwave::SignalView::samples2pixels(), Kwave::SignalManager::selection(), and Kwave::TrackPixmap::width().

338 {
339  Q_ASSERT(m_signal_manager);
340  if (!m_signal_manager) return;
341 
342 // qDebug("TrackView::paintEvent()");
343 // #define DEBUG_REPAINT_TIMES
344 #ifdef DEBUG_REPAINT_TIMES
345  QTime time;
346  time.start();
347 #endif /* DEBUG_REPAINT_TIMES */
348 
349  QPainter p;
350  const int width = QWidget::width();
351  const int height = QWidget::height();
352 
353 // qDebug("TrackView::paintEvent(): width=%d, height=%d", width, height);
354 
355  // --- detect size changes and refresh the whole image ---
356  if ((width > m_last_width) || (height != m_last_height)) {
357 // qDebug("TrackView::paintEvent(): window size changed from "
358 // "%dx%d to %dx%d", m_last_width, m_last_height, width, height);
359 
360  // create new images for the layers
361  const QImage::Format format = QImage::Format_ARGB32_Premultiplied;
362  m_img_signal = QImage(width, height, format);
363  m_img_selection = QImage(width, height, format);
364  m_img_markers = QImage(width, height, format);
365 
366  // create a new target image
367  m_image = QImage(width, height, format);
368 
369  // mark all images as "need refresh"
373 
374  // remember the last width
375  m_last_width = width;
376  m_last_height = height;
377  }
378 
379  // --- repaint of the signal layer ---
381 // qDebug("TrackView::paintEvent(): - redraw of signal layer -");
382 
383  p.begin(&m_img_signal);
384 
385  // fix the width and height of the track pixmap
386  if ((m_pixmap.width() < width) || (m_pixmap.height() != height))
387  m_pixmap.resize(width, height);
388 
389  // refresh the pixmap
390  if (m_pixmap.isModified())
391  m_pixmap.repaint();
392 
393  p.setCompositionMode(QPainter::CompositionMode_Source);
394  p.drawPixmap(0, 0, m_pixmap.pixmap());
395  p.end();
396 
398  }
399 
400  // --- repaint of the markers layer ---
402 // qDebug("TrackView::paintEvent(): - redraw of markers layer -");
403 
404  p.begin(&m_img_markers);
405  p.fillRect(0, 0, width, height, Qt::black);
406 
407  int last_marker = -1;
408  const sample_index_t last_visible = lastVisible();
409  foreach (const Kwave::Label &label,
411  {
412  sample_index_t pos = label.pos();
413  if (pos < m_offset) continue; // outside left
414  if (pos > last_visible) break; // far outside right, done
415  int x = samples2pixels(pos - m_offset);
416  if (x >= width) break; // outside right, done
417 
418  // position must differ from the last one, otherwise we
419  // would wipe out the last one with XOR mode
420  if (x == last_marker) continue;
421 
422  p.setPen(Qt::cyan);
423  p.setCompositionMode(QPainter::CompositionMode_Exclusion);
424  p.drawLine(x, 0, x, height);
425 
426  last_marker = x;
427  }
428 
429  p.end();
430 
432  }
433 
434  // --- repaint of the selection layer ---
436 // qDebug("TrackView::paintEvent(): - redraw of selection layer -");
437 
438  p.begin(&m_img_selection);
439  p.fillRect(0, 0, width, height, Qt::black);
440 
443  const sample_index_t visible = pixels2samples(width);
444 
445  if ((right > 0) && (right >= m_offset)) {
446 
447  // shift and clip the selection, relative to m_offset
448  left = (left > m_offset) ? (left - m_offset) : 0;
449  if (left <= visible) {
450  right -= m_offset;
451  if (right > visible) right = visible + 1;
452 
453  // transform to pixel coordinates
454  int l = samples2pixels(left);
455  int r = samples2pixels(right);
456 
457  // clip to the widget's size
458  if (r >= width) r = width - 1;
459  if (l > r) l = r;
460 
461  p.setPen(Qt::yellow);
462  if (l == r) {
463  p.drawLine(l, 0, l, height);
464  } else {
465  p.setBrush(Qt::yellow);
466  p.drawRect(l, 0, r - l + 1, height);
467  }
468  }
469  }
470  p.end();
471 
473  }
474 
475  // bitBlt all layers together
476  p.begin(&m_image);
477  p.fillRect(0, 0, width, height, Qt::black);
478 
479  // paint the signal layer (copy mode)
480  p.setCompositionMode(QPainter::CompositionMode_Source);
481  p.drawImage(0, 0, m_img_signal);
482 
483  // paint the selection layer (XOR mode)
484  p.setCompositionMode(QPainter::CompositionMode_Exclusion);
485  p.drawImage(0, 0, m_img_selection);
486 
487  // paint the markers/labels layer (XOR mode)
488  p.setCompositionMode(QPainter::CompositionMode_Exclusion);
489  p.drawImage(0, 0, m_img_markers);
490 
491  // --- show the cursor position ---
492  do
493  {
494  if (m_cursor_pos == SAMPLE_INDEX_MAX) break;
495  if (m_cursor_pos < m_offset) break;
496  const sample_index_t visible = pixels2samples(width);
497  if (m_cursor_pos >= m_offset + visible) break;
498 
500  if (x >= width) break;
501 
502  p.setPen(Qt::yellow);
503  p.setCompositionMode(QPainter::CompositionMode_Exclusion);
504  p.drawLine(x, 0, x, height);
505  } while (0);
506 
507  p.end();
508 
509  // draw the result
510  p.begin(this);
511  p.drawImage(0, 0, m_image);
512  p.end();
513 
514 #ifdef DEBUG_REPAINT_TIMES
515  qDebug("TrackView::paintEvent() -- done, t=%d ms --", time.elapsed());
516 #endif /* DEBUG_REPAINT_TIMES */
517 }
sample_index_t lastVisible() const
Definition: SignalView.h:130
QImage m_img_selection
Definition: TrackView.h:155
bool m_img_signal_needs_refresh
Definition: TrackView.h:161
bool m_img_markers_needs_refresh
Definition: TrackView.h:167
sample_index_t m_offset
Definition: SignalView.h:348
sample_index_t first() const
Definition: Selection.h:71
virtual int width() const
Definition: TrackPixmap.h:90
virtual const QPixmap & pixmap() const
Definition: TrackPixmap.h:102
sample_index_t last() const
Definition: Selection.h:76
QImage m_img_signal
Definition: TrackView.h:152
Kwave::MetaDataList & metaData()
virtual void repaint()
Kwave::Selection & selection()
virtual sample_index_t pos() const
Definition: Label.cpp:56
virtual int height() const
Definition: TrackPixmap.h:96
quint64 sample_index_t
Definition: Sample.h:28
virtual void resize(int width, int height)
Kwave::TrackPixmap m_pixmap
Definition: TrackView.h:140
QImage m_img_markers
Definition: TrackView.h:158
sample_index_t pixels2samples(int pixels) const
Definition: SignalView.cpp:155
Kwave::SignalManager * m_signal_manager
Definition: SignalView.h:336
virtual bool isModified()
bool m_img_selection_needs_refresh
Definition: TrackView.h:164
sample_index_t m_cursor_pos
Definition: TrackView.h:173
#define SAMPLE_INDEX_MAX
Definition: Sample.h:31
int samples2pixels(sample_index_t samples) const
Definition: SignalView.cpp:149
Here is the call graph for this function:

◆ refresh()

void Kwave::TrackView::refresh ( )
virtual

refreshes the bitmap that displays the signal

Reimplemented from Kwave::SignalView.

Definition at line 138 of file TrackView.cpp.

References m_pixmap, and Kwave::TrackPixmap::repaint().

139 {
140 // qDebug("Kwave::TrackView[%d]::refresh()", track());
141  m_pixmap.repaint();
142  repaint();
143 }
virtual void repaint()
Kwave::TrackPixmap m_pixmap
Definition: TrackView.h:140
Here is the call graph for this function:

◆ refreshAllLayers

void Kwave::TrackView::refreshAllLayers ( )
privateslot

requests a refresh of all layers

Definition at line 328 of file TrackView.cpp.

References m_img_markers_needs_refresh, m_img_selection_needs_refresh, m_img_signal_needs_refresh, and Kwave::SignalView::sigNeedRepaint().

Referenced by resizeEvent(), and setZoomAndOffset().

329 {
333  emit sigNeedRepaint(this);
334 }
bool m_img_signal_needs_refresh
Definition: TrackView.h:161
bool m_img_markers_needs_refresh
Definition: TrackView.h:167
bool m_img_selection_needs_refresh
Definition: TrackView.h:164
void sigNeedRepaint(Kwave::SignalView *view)
Here is the caller graph for this function:

◆ refreshMarkersLayer

void Kwave::TrackView::refreshMarkersLayer ( )
privateslot

requests a refresh of the markers layer

Definition at line 321 of file TrackView.cpp.

References m_img_markers_needs_refresh, and Kwave::SignalView::sigNeedRepaint().

Referenced by TrackView().

322 {
324  emit sigNeedRepaint(this);
325 }
bool m_img_markers_needs_refresh
Definition: TrackView.h:167
void sigNeedRepaint(Kwave::SignalView *view)
Here is the caller graph for this function:

◆ refreshSelectionLayer

void Kwave::TrackView::refreshSelectionLayer ( )
privateslot

requests a refresh of the selection layer

Definition at line 314 of file TrackView.cpp.

References m_img_selection_needs_refresh, and Kwave::SignalView::sigNeedRepaint().

Referenced by TrackView().

315 {
317  emit sigNeedRepaint(this);
318 }
bool m_img_selection_needs_refresh
Definition: TrackView.h:164
void sigNeedRepaint(Kwave::SignalView *view)
Here is the caller graph for this function:

◆ refreshSignalLayer

void Kwave::TrackView::refreshSignalLayer ( )
privateslot

requests a refresh of the signal layer

Definition at line 307 of file TrackView.cpp.

References m_img_signal_needs_refresh, and Kwave::SignalView::sigNeedRepaint().

Referenced by TrackView().

308 {
310  emit sigNeedRepaint(this);
311 }
bool m_img_signal_needs_refresh
Definition: TrackView.h:161
void sigNeedRepaint(Kwave::SignalView *view)
Here is the caller graph for this function:

◆ resizeEvent()

void Kwave::TrackView::resizeEvent ( QResizeEvent *  event)
virtual

called when the widget has been resized

Definition at line 293 of file TrackView.cpp.

References m_last_height, m_last_width, and refreshAllLayers().

294 {
295  Kwave::SignalView::resizeEvent(event);
296  if (!event) return;
297 
298  // request a repaint on all size changes, but not on horizontal shrink
299  if ((event->size().width() > m_last_width) ||
300  (event->size().height() != m_last_height))
301  {
303  }
304 }
void refreshAllLayers()
Definition: TrackView.cpp:328
Here is the call graph for this function:

◆ setVerticalZoom()

void Kwave::TrackView::setVerticalZoom ( double  zoom)
virtual

sets new vertical zoom factor

Parameters
zoomvertical zoom factor

Reimplemented from Kwave::SignalView.

Definition at line 158 of file TrackView.cpp.

References Kwave::SignalView::contentSizeChanged(), MINIMUM_HEIGHT, Kwave::SignalView::setVerticalZoom(), Kwave::toInt(), and Kwave::SignalView::verticalZoom().

159 {
160  const int old_height = this->height();
161  const double old_zoom = verticalZoom();
162 
163  if (old_height > MINIMUM_HEIGHT * old_zoom) {
164  // stretched mode
165  zoom *= double(old_height) / (old_zoom * double(MINIMUM_HEIGHT));
166  }
167 
169  setMinimumHeight(Kwave::toInt(MINIMUM_HEIGHT * zoom));
170  emit contentSizeChanged();
171 }
#define MINIMUM_HEIGHT
Definition: TrackView.cpp:44
void contentSizeChanged()
virtual void setVerticalZoom(double zoom)
Definition: SignalView.cpp:137
int toInt(T x)
Definition: Utils.h:127
double verticalZoom() const
Definition: SignalView.h:120
double zoom() const
Definition: SignalView.h:115
Here is the call graph for this function:

◆ setZoomAndOffset()

void Kwave::TrackView::setZoomAndOffset ( double  zoom,
sample_index_t  offset 
)
virtual

sets new zoom factor and offset

Parameters
zoomthe new zoom factor in pixels/sample
offsetthe index of the first visible sample

Reimplemented from Kwave::SignalView.

Definition at line 146 of file TrackView.cpp.

References Kwave::TrackPixmap::isModified(), m_pixmap, refreshAllLayers(), Kwave::TrackPixmap::setOffset(), Kwave::TrackPixmap::setZoom(), and Kwave::SignalView::setZoomAndOffset().

147 {
148  Q_ASSERT(zoom >= 0.0);
152  if (m_pixmap.isModified()) {
154  }
155 }
void refreshAllLayers()
Definition: TrackView.cpp:328
sample_index_t offset() const
Definition: SignalView.h:110
void setOffset(sample_index_t offset)
Definition: TrackPixmap.cpp:82
Kwave::TrackPixmap m_pixmap
Definition: TrackView.h:140
virtual bool isModified()
double zoom() const
Definition: SignalView.h:115
void setZoom(double zoom)
virtual void setZoomAndOffset(double zoom, sample_index_t offset)
Definition: SignalView.cpp:119
Here is the call graph for this function:

◆ showCursor

void Kwave::TrackView::showCursor ( sample_index_t  pos = SAMPLE_INDEX_MAX)
virtualslot

requests a repaint, as soon as the repaint timer elapsed

Parameters
poscurrent position of the cursor

Definition at line 520 of file TrackView.cpp.

References m_cursor_pos, and Kwave::SignalView::sigNeedRepaint().

Referenced by TrackView().

521 {
522  m_cursor_pos = pos;
523  emit sigNeedRepaint(this);
524 }
sample_index_t m_cursor_pos
Definition: TrackView.h:173
void sigNeedRepaint(Kwave::SignalView *view)
Here is the caller graph for this function:

Member Data Documentation

◆ m_cursor_pos

sample_index_t Kwave::TrackView::m_cursor_pos
private

last known position of the playback pointer

Definition at line 173 of file TrackView.h.

Referenced by paintEvent(), and showCursor().

◆ m_image

QImage Kwave::TrackView::m_image
private

QImage used for composition

Definition at line 149 of file TrackView.h.

Referenced by paintEvent().

◆ m_img_markers

QImage Kwave::TrackView::m_img_markers
private

QImage used for the markers/labels layer

Definition at line 158 of file TrackView.h.

Referenced by paintEvent().

◆ m_img_markers_needs_refresh

bool Kwave::TrackView::m_img_markers_needs_refresh
private

if true, the markers layer needs to be refreshed

Definition at line 167 of file TrackView.h.

Referenced by paintEvent(), refreshAllLayers(), and refreshMarkersLayer().

◆ m_img_selection

QImage Kwave::TrackView::m_img_selection
private

QImage used for the selection layer

Definition at line 155 of file TrackView.h.

Referenced by paintEvent().

◆ m_img_selection_needs_refresh

bool Kwave::TrackView::m_img_selection_needs_refresh
private

if true, the selection layer needs to be refreshed

Definition at line 164 of file TrackView.h.

Referenced by paintEvent(), refreshAllLayers(), and refreshSelectionLayer().

◆ m_img_signal

QImage Kwave::TrackView::m_img_signal
private

QImage used for the signal layer

Definition at line 152 of file TrackView.h.

Referenced by paintEvent().

◆ m_img_signal_needs_refresh

bool Kwave::TrackView::m_img_signal_needs_refresh
private

if true, the signal layer needs to be refreshed

Definition at line 161 of file TrackView.h.

Referenced by paintEvent(), refreshAllLayers(), and refreshSignalLayer().

◆ m_last_height

int Kwave::TrackView::m_last_height
private

last/previous height of the widget, for detecting size changes

Definition at line 146 of file TrackView.h.

Referenced by paintEvent(), and resizeEvent().

◆ m_last_width

int Kwave::TrackView::m_last_width
private

last/previous width of the widget, for detecting size changes

Definition at line 143 of file TrackView.h.

Referenced by paintEvent(), and resizeEvent().

◆ m_mouse_click_position

sample_index_t Kwave::TrackView::m_mouse_click_position
private

position of the last mouse click in samples

Definition at line 170 of file TrackView.h.

Referenced by contextMenuLabelNew(), and handleContextMenu().

◆ m_pixmap

Kwave::TrackPixmap Kwave::TrackView::m_pixmap
private

the track pixmap

Definition at line 140 of file TrackView.h.

Referenced by paintEvent(), refresh(), setZoomAndOffset(), and TrackView().


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