From 40d23e1b0d86347c0f4f0bb634d24323fa8b4660 Mon Sep 17 00:00:00 2001 From: Mathias Buhr Date: Sun, 23 Apr 2017 21:35:23 +0200 Subject: [PATCH] Fix broken waveforms --- src/avtk/waveform.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/avtk/waveform.h b/src/avtk/waveform.h index 47688bc..498fa73 100644 --- a/src/avtk/waveform.h +++ b/src/avtk/waveform.h @@ -45,7 +45,6 @@ public: h = _h; highlight = false; - newWaveform = false; waveformCr = 0; waveformSurf = 0; @@ -66,12 +65,11 @@ public: bool highlight; int x, y, w, h; - cairo_t* waveformCr; - cairo_surface_t* waveformSurf; + cairo_t* waveformCr = nullptr; + cairo_surface_t* waveformSurf = nullptr; - bool newWaveform; + bool newWaveform = false; - long dataSize; std::vector data; void setData( const std::vector& newdata ) @@ -80,7 +78,6 @@ public: data = newdata; newWaveform = true; - damage(FL_DAMAGE_ALL); } @@ -133,7 +130,7 @@ public: cairo_set_dash ( waveformCr, dashes, 0, 0.0); - if ( !data.empty() ) { + if ( data.empty() ) { // draw X cairo_move_to( cr, 0 , 0 ); cairo_line_to( cr, 0 + w, 0 + h ); @@ -156,7 +153,7 @@ public: float currentSample = 0.f; // find how many samples per pixel - int samplesPerPix = int(dataSize / float(w)); + const auto samplesPerPix = int(data.size() / float(w)); //cout << "width = " << w << " sampsPerPx " << samplesPerPix << endl; // loop over each pixel value we need @@ -237,12 +234,10 @@ public: // FIXME: needs to be resampled, not clipped at end // delete old data, and resize it - data.resize(w); newWaveform = true; - redraw(); }