WaveRubber: Remove trailing whitespaces and fix formatting
This commit is contained in:
@@ -24,11 +24,12 @@
|
|||||||
const char *WaveRubber::kName = QT_TRANSLATE_NOOP("AnalyzerContainer", "WaveRubber");
|
const char *WaveRubber::kName = QT_TRANSLATE_NOOP("AnalyzerContainer", "WaveRubber");
|
||||||
|
|
||||||
WaveRubber::WaveRubber(QWidget *parent)
|
WaveRubber::WaveRubber(QWidget *parent)
|
||||||
: AnalyzerBase(parent, 9) {}
|
: AnalyzerBase(parent, 9) {}
|
||||||
|
|
||||||
void WaveRubber::resizeEvent(QResizeEvent *e) {
|
void WaveRubber::resizeEvent(QResizeEvent *e) {
|
||||||
|
|
||||||
Q_UNUSED(e)
|
Q_UNUSED(e)
|
||||||
|
|
||||||
canvas_ = QPixmap(size());
|
canvas_ = QPixmap(size());
|
||||||
canvas_.fill(palette().color(QPalette::AlternateBase));
|
canvas_.fill(palette().color(QPalette::AlternateBase));
|
||||||
|
|
||||||
@@ -49,12 +50,12 @@ void WaveRubber::analyze(QPainter &p, const Scope &s, bool new_frame) {
|
|||||||
|
|
||||||
// Set the pen color to the QT palette highlight color
|
// Set the pen color to the QT palette highlight color
|
||||||
canvas_painter.setPen(palette().color(QPalette::Highlight));
|
canvas_painter.setPen(palette().color(QPalette::Highlight));
|
||||||
// Get pointer to amplitude data
|
// Get pointer to amplitude data
|
||||||
const float *amplitude_data = s.data();
|
const float *amplitude_data = s.data();
|
||||||
|
|
||||||
int mid_y = height() / 4;
|
int mid_y = height() / 4;
|
||||||
int num_samples = s.size();
|
int num_samples = s.size();
|
||||||
|
|
||||||
float x_scale = static_cast<float>(width()) / num_samples;
|
float x_scale = static_cast<float>(width()) / num_samples;
|
||||||
float prev_y = mid_y;
|
float prev_y = mid_y;
|
||||||
|
|
||||||
@@ -68,13 +69,12 @@ void WaveRubber::analyze(QPainter &p, const Scope &s, bool new_frame) {
|
|||||||
// Blend blue and green with highlight color from QT palette based on amplitude
|
// Blend blue and green with highlight color from QT palette based on amplitude
|
||||||
QColor blended_color = QColor(rgb_value, highlight_color.green(), highlight_color.blue());
|
QColor blended_color = QColor(rgb_value, highlight_color.green(), highlight_color.blue());
|
||||||
canvas_painter.setPen(blended_color);
|
canvas_painter.setPen(blended_color);
|
||||||
|
|
||||||
int x = static_cast<int>(i * x_scale );
|
|
||||||
int y = static_cast<int>(mid_y - (s[i] * mid_y));
|
|
||||||
|
|
||||||
canvas_painter.drawLine(x, prev_y + mid_y, x + x_scale, y + mid_y); // Draw
|
int x = static_cast<int>(i * x_scale);
|
||||||
|
int y = static_cast<int>(mid_y - (s[i] * mid_y));
|
||||||
|
|
||||||
|
canvas_painter.drawLine(x, prev_y + mid_y, x + x_scale, y + mid_y); // Draw
|
||||||
prev_y = y;
|
prev_y = y;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas_painter.end();
|
canvas_painter.end();
|
||||||
@@ -90,4 +90,3 @@ void WaveRubber::transform(Scope &s) {
|
|||||||
void WaveRubber::demo(QPainter &p) {
|
void WaveRubber::demo(QPainter &p) {
|
||||||
analyze(p, Scope(fht_->size(), 0), new_frame_);
|
analyze(p, Scope(fht_->size(), 0), new_frame_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,8 @@
|
|||||||
#include "analyzerbase.h"
|
#include "analyzerbase.h"
|
||||||
|
|
||||||
class WaveRubber : public AnalyzerBase {
|
class WaveRubber : public AnalyzerBase {
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Q_INVOKABLE explicit WaveRubber(QWidget *parent);
|
Q_INVOKABLE explicit WaveRubber(QWidget *parent);
|
||||||
|
|
||||||
@@ -38,6 +38,4 @@ class WaveRubber : public AnalyzerBase {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QPixmap canvas_;
|
QPixmap canvas_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user