2018-02-27 18:06:05 +01:00
|
|
|
// Maintainer: Max Howell <mac.howell@methylblue.com>, (C) 2003-5
|
|
|
|
// Copyright: See COPYING file that comes with this distribution
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef BLOCKANALYZER_H
|
|
|
|
#define BLOCKANALYZER_H
|
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <QtGlobal>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QString>
|
|
|
|
#include <QPixmap>
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QPalette>
|
|
|
|
#include <QtEvents>
|
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
#include "analyzerbase.h"
|
|
|
|
|
|
|
|
class QResizeEvent;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Max Howell
|
|
|
|
*/
|
|
|
|
|
|
|
|
class BlockAnalyzer : public Analyzer::Base {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
Q_INVOKABLE BlockAnalyzer(QWidget*);
|
|
|
|
~BlockAnalyzer();
|
|
|
|
|
|
|
|
static const uint HEIGHT;
|
|
|
|
static const uint WIDTH;
|
|
|
|
static const uint MIN_ROWS;
|
|
|
|
static const uint MIN_COLUMNS;
|
|
|
|
static const uint MAX_COLUMNS;
|
|
|
|
static const uint FADE_SIZE;
|
|
|
|
|
|
|
|
static const char *kName;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void transform(Analyzer::Scope&);
|
|
|
|
virtual void analyze(QPainter &p, const Analyzer::Scope&, bool new_frame);
|
|
|
|
virtual void resizeEvent(QResizeEvent*);
|
|
|
|
virtual void paletteChange(const QPalette&);
|
|
|
|
virtual void framerateChanged();
|
|
|
|
|
|
|
|
void drawBackground();
|
|
|
|
void determineStep();
|
|
|
|
|
|
|
|
private:
|
2018-09-30 15:32:21 +02:00
|
|
|
QPixmap *bar() { return &barpixmap_; }
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2018-09-30 15:32:21 +02:00
|
|
|
uint columns_, rows_; // number of rows and columns of blocks
|
|
|
|
uint y_; // y-offset from top of widget
|
|
|
|
QPixmap barpixmap_;
|
|
|
|
QPixmap topbarpixmap_;
|
|
|
|
QPixmap background_;
|
2018-02-27 18:06:05 +01:00
|
|
|
QPixmap canvas_;
|
2018-09-30 15:32:21 +02:00
|
|
|
Analyzer::Scope scope_; // so we don't create a vector every frame
|
|
|
|
std::vector<float> store_; // current bar heights
|
|
|
|
std::vector<float> yscale_;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
// FIXME why can't I namespace these? c++ issue?
|
2018-09-30 15:32:21 +02:00
|
|
|
std::vector<QPixmap> fade_bars_;
|
|
|
|
std::vector<uint> fade_pos_;
|
|
|
|
std::vector<int> fade_intensity_;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2018-09-30 15:32:21 +02:00
|
|
|
float step_; // rows to fall per frame
|
2018-02-27 18:06:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|