kwave  18.07.70
TrackPixmap.h
Go to the documentation of this file.
1 /***************************************************************************
2  TrackPixmap.h - buffered pixmap for displaying a kwave track
3  -------------------
4  begin : Tue Mar 20 2001
5  copyright : (C) 2001 by Thomas Eschenbacher
6  email : Thomas.Eschenbacher@gmx.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef TRACK_PIXMAP_H
19 #define TRACK_PIXMAP_H
20 
21 #include "config.h"
22 
23 #include <math.h>
24 
25 #include <QtGlobal>
26 #include <QBitArray>
27 #include <QColor>
28 #include <QMutex>
29 #include <QObject>
30 #include <QPixmap>
31 #include <QVector>
32 
33 #include "libkwave/Sample.h"
34 #include "libkwave/SampleArray.h"
35 #include "libkwave/Utils.h"
36 
37 #include "libgui/Colors.h"
38 
63 namespace Kwave
64 {
65  class Track;
66 
67  class Q_DECL_EXPORT TrackPixmap: public QObject
68  {
69  Q_OBJECT
70 
71  public:
72 
74  explicit TrackPixmap(Kwave::Track &track);
75 
77  virtual ~TrackPixmap();
78 
84  virtual void resize(int width, int height);
85 
90  virtual int width() const { return m_pixmap.width(); }
91 
96  virtual int height() const { return m_pixmap.height(); }
97 
102  virtual const QPixmap &pixmap() const { return m_pixmap; }
103 
109  virtual void repaint();
110 
115  virtual void setVerticalZoom(double zoom);
116 
121  virtual bool isModified();
122 
124  virtual void setModified() { m_modified = true; }
125 
126  signals:
127 
129  void sigModified();
130 
131  public slots:
132 
139  void setOffset(sample_index_t offset);
140 
146  void setZoom(double zoom);
147 
148  private slots:
149 
158  void slotSamplesInserted(Kwave::Track *src, sample_index_t offset,
159  sample_index_t length);
160 
169  void slotSamplesDeleted(Kwave::Track *src, sample_index_t offset,
170  sample_index_t length);
171 
180  void slotSamplesModified(Kwave::Track *src, sample_index_t offset,
181  sample_index_t length);
182 
187  void selectionChanged();
188 
189  private:
190 
195  void resizeBuffer();
196 
201  void invalidateBuffer();
202 
210  bool validateBuffer();
211 
221  void drawOverview(QPainter &p, int middle, int height,
222  int first, int last);
223 
230  void calculateInterpolation();
231 
243  void drawInterpolatedSignal(QPainter &p, int width, int middle,
244  int height);
245 
257  void drawPolyLineSignal(QPainter &p, int width, int middle, int height);
258 
262  inline sample_index_t pixels2samples(int pixels) {
263  return static_cast<sample_index_t>(rint(
264  static_cast<double>(pixels) * m_zoom));
265  }
266 
270  inline int samples2pixels(sample_index_t samples) {
271  if (m_zoom <= 0) return 0;
272  return Kwave::toInt(rint(static_cast<double>(samples) / m_zoom));
273  }
274 
287  void convertOverlap(sample_index_t &offset, sample_index_t &length);
288 
289  private:
290 
292  QPixmap m_pixmap;
293 
298 
305 
310  double m_zoom;
311 
316 
322 
329 
334 
339 
342 
349  QBitArray m_valid;
350 
353 
358 
364  QVector<double> m_interpolation_alpha;
365 
368 
369  };
370 }
371 
372 #endif /* TRACK_PIXMAP_H */
373 
374 //***************************************************************************
375 //***************************************************************************
virtual int width() const
Definition: TrackPixmap.h:90
sample_index_t m_offset
Definition: TrackPixmap.h:304
Definition: App.h:33
virtual const QPixmap & pixmap() const
Definition: TrackPixmap.h:102
virtual void setModified()
Definition: TrackPixmap.h:124
virtual int height() const
Definition: TrackPixmap.h:96
quint64 sample_index_t
Definition: Sample.h:28
Kwave::SampleArray m_sample_buffer
Definition: TrackPixmap.h:328
Kwave::Colors::ColorSet m_colors
Definition: TrackPixmap.h:367
QVector< double > m_interpolation_alpha
Definition: TrackPixmap.h:364
Kwave::SampleArray m_min_buffer
Definition: TrackPixmap.h:333
int toInt(T x)
Definition: Utils.h:127
Kwave::Track & m_track
Definition: TrackPixmap.h:297
sample_index_t pixels2samples(int pixels)
Definition: TrackPixmap.h:262
int samples2pixels(sample_index_t samples)
Definition: TrackPixmap.h:270
Kwave::SampleArray m_max_buffer
Definition: TrackPixmap.h:338