Fix some errors in src/analyzers introduced while fixing cpplint.py errors

This commit is contained in:
Krzysztof Sobiecki 2014-11-29 21:05:59 +01:00
parent 63b0c10125
commit 1cbe135a8d
7 changed files with 23 additions and 22 deletions

View File

@ -25,6 +25,7 @@
#include "analyzerbase.h"
#include <cmath>
#include <cstdint>
#include <QEvent>
#include <QPainter>
@ -184,13 +185,13 @@ void Analyzer::interpolate(const Scope& inVec, Scope& outVec) {
for (uint i = 0; i < outVec.size(); ++i, pos += step) {
const double error = pos - std::floor(pos);
const unsigned int64 offset = static_cast<unsigned int64>(pos);
const uint64_t offset = static_cast<uint64_t>(pos);
unsigned int64 indexLeft = offset + 0;
uint64_t indexLeft = offset + 0;
if (indexLeft >= inVec.size()) indexLeft = inVec.size() - 1;
unsigned int64 indexRight = offset + 1;
uint64_t indexRight = offset + 1;
if (indexRight >= inVec.size()) indexRight = inVec.size() - 1;

View File

@ -87,7 +87,7 @@ void BarAnalyzer::init() {
for (int x = 0, r = rgb.red(), g = rgb.green(), b = rgb.blue(), r2 = 255 - r; x < height();
++x) {
for (int y = x; y > 0; --y) {
const double fraction = static_cast<double>y / height();
const double fraction = static_cast<double>(y) / height();
// p.setPen( QColor( r + (int)(r2 * fraction), g, b - (int)(255 *
// fraction) ) );
@ -137,8 +137,8 @@ void BarAnalyzer::analyze(QPainter& p, const Scope& s, bool new_frame) {
MAX_DOWN)
y2 = barVector[i] + MAX_DOWN;
if (static_cast<int>y2 > roofVector[i]) {
roofVector[i] = static_cast<int>y2;
if (static_cast<int>(y2) > roofVector[i]) {
roofVector[i] = static_cast<int>(y2);
roofVelocityVector[i] = 1;
}

View File

@ -172,7 +172,7 @@ void BlockAnalyzer::analyze(QPainter& p, const Analyzer::Scope& s,
// this is opposite to what you'd think, higher than y
// means the bar is lower than y (physically)
if (static_cast<float>y > m_store[x])
if (static_cast<float>(y) > m_store[x])
y = static_cast<int>(m_store[x] += m_step);
else
m_store[x] = y;
@ -339,7 +339,7 @@ void BlockAnalyzer::paletteChange(const QPalette&) {
bar()->fill(bg);
QPainter p(bar());
for (int y = 0; static_cast<uint>y < m_rows; ++y)
for (int y = 0; static_cast<uint>(y) < m_rows; ++y)
// graduate the fg color
p.fillRect(0, y * (HEIGHT + 1), WIDTH, HEIGHT,
QColor(r + static_cast<int>(dr * y), g + static_cast<int>(dg * y),
@ -363,7 +363,7 @@ void BlockAnalyzer::paletteChange(const QPalette&) {
for (uint y = 0; y < FADE_SIZE; ++y) {
m_fade_bars[y].fill(palette().color(QPalette::Background));
QPainter f(&m_fade_bars[y]);
for (int z = 0; static_cast<uint>z < m_rows; ++z) {
for (int z = 0; static_cast<uint>(z) < m_rows; ++z) {
const double Y = 1.0 - (log10(FADE_SIZE - y) / log10(FADE_SIZE));
f.fillRect(0, z * (HEIGHT + 1), WIDTH, HEIGHT,
QColor(r + static_cast<int>(dr * Y), g + static_cast<int>(dg * Y), b + static_cast<int>(db * Y)));

View File

@ -44,11 +44,11 @@ BoomAnalyzer::BoomAnalyzer(QWidget* parent)
barPixmap(COLUMN_WIDTH, 50) {}
void BoomAnalyzer::changeK_barHeight(int newValue) {
K_barHeight = static_cast<double>newValue / 1000;
K_barHeight = static_cast<double>(newValue) / 1000;
}
void BoomAnalyzer::changeF_peakSpeed(int newValue) {
F_peakSpeed = static_cast<double>newValue / 1000;
F_peakSpeed = static_cast<double>(newValue) / 1000;
}
void BoomAnalyzer::resizeEvent(QResizeEvent*) { init(); }
@ -65,7 +65,7 @@ void BoomAnalyzer::init() {
QPainter p(&barPixmap);
for (uint y = 0; y < HEIGHT; ++y) {
const double F = static_cast<double>y * h;
const double F = static_cast<double>(y) * h;
p.setPen(QColor(qMax(0, 255 - static_cast<int>(229.0 * F)),
qMax(0, 255 - static_cast<int>(229.0 * F)),

View File

@ -77,7 +77,7 @@ void GLAnalyzer2::resizeGL(int w, int h) {
glOrtho(-10.0f, 10.0f, -10.0f, 10.0f, -5.0f, 5.0f);
// Get the aspect ratio of the screen to draw 'cicular' particles
float ratio = static_cast<float>w / static_cast<float>h, eqPixH = 60, eqPixW = 80;
float ratio = static_cast<float>(w) / static_cast<float>(h), eqPixH = 60, eqPixW = 80;
if (ratio >= (4.0 / 3.0)) {
unitX = 10.0 / (eqPixH * ratio);
unitY = 10.0 / eqPixH;
@ -89,7 +89,7 @@ void GLAnalyzer2::resizeGL(int w, int h) {
// Get current timestamp.
timeval tv;
gettimeofday(&tv, nullptr);
show.timeStamp = static_cast<double>tv.tv_sec + static_cast<double>tv.tv_usec / 1000000.0;
show.timeStamp = static_cast<double>(tv.tv_sec) + static_cast<double>(tv.tv_usec) / 1000000.0;
}
void GLAnalyzer2::paused() { analyze(Scope()); }
@ -109,13 +109,13 @@ void GLAnalyzer2::analyze(const Scope& s) {
for (int i = 0; i < bands; i++) {
float value = s[i];
currentEnergy += value;
currentMeanBand += static_cast<float>i * value;
currentMeanBand += static_cast<float>(i) * value;
if (value > maxValue) maxValue = value;
}
frame.silence = currentEnergy < 0.001;
if (!frame.silence) {
frame.meanBand = 100.0 * currentMeanBand / (currentEnergy * bands);
currentEnergy = 100.0 * currentEnergy / static_cast<float>bands;
currentEnergy = 100.0 * currentEnergy / static_cast<float>(bands);
frame.dEnergy = currentEnergy - frame.energy;
frame.energy = currentEnergy;
// printf( "%d [%f :: %f ]\t%f \n", bands, frame.energy,
@ -133,7 +133,7 @@ void GLAnalyzer2::paintGL() {
// Compute the dT since the last call to paintGL and update timings
timeval tv;
gettimeofday(&tv, nullptr);
double currentTime = static_cast<double>tv.tv_sec + static_cast<double>tv.tv_usec / 1000000.0;
double currentTime = static_cast<double>(tv.tv_sec) + static_cast<double>(tv.tv_usec) / 1000000.0;
show.dT = currentTime - show.timeStamp;
show.timeStamp = currentTime;

View File

@ -163,7 +163,7 @@ void GLAnalyzer3::resizeGL(int w, int h) {
glFrustum(-0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 4.5f);
// Get the aspect ratio of the screen to draw 'circular' particles
float ratio = static_cast<float>w / static_cast<float>h;
float ratio = static_cast<float>(w) / static_cast<float>(h);
if (ratio >= 1.0) {
unitX = 0.34 / ratio;
unitY = 0.34;
@ -175,7 +175,7 @@ void GLAnalyzer3::resizeGL(int w, int h) {
// Get current timestamp.
timeval tv;
gettimeofday(&tv, nullptr);
show.timeStamp = static_cast<double>tv.tv_sec + static_cast<double>tv.tv_usec / 1000000.0;
show.timeStamp = static_cast<double>(tv.tv_sec) + static_cast<double>(tv.tv_usec) / 1000000.0;
}
void GLAnalyzer3::paused() { analyze(Scope()); }
@ -184,7 +184,7 @@ void GLAnalyzer3::analyze(const Scope& s) {
// compute the dTime since the last call
timeval tv;
gettimeofday(&tv, nullptr);
double currentTime = static_cast<double>tv.tv_sec + static_cast<double>tv.tv_usec / 1000000.0;
double currentTime = static_cast<double>(tv.tv_sec) + static_cast<double>(tv.tv_usec) / 1000000.0;
show.dT = currentTime - show.timeStamp;
show.timeStamp = currentTime;
@ -198,7 +198,7 @@ void GLAnalyzer3::analyze(const Scope& s) {
currentEnergy += value;
if (value > maxValue) maxValue = value;
}
currentEnergy *= 100.0 / static_cast<float>bands;
currentEnergy *= 100.0 / static_cast<float>(bands);
// emulate a peak detector: currentEnergy -> peakEnergy (3tau = 30 seconds)
show.peakEnergy = 1.0 + (show.peakEnergy - 1.0) * exp(-show.dT / 10.0);
if (currentEnergy > show.peakEnergy) show.peakEnergy = currentEnergy;

View File

@ -87,7 +87,7 @@ void TurbineAnalyzer::analyze(QPainter& p, const Scope& scope, bool new_frame) {
canvas_painter.setPen(palette().color(QPalette::Highlight));
if (bar_height[i] > 0)
canvas_painter.drawRect(x, y, COLUMN_WIDTH - 1,
static_cast<int>bar_height[i] * 2 - 1);
static_cast<int>(bar_height[i]) * 2 - 1);
const uint x2 = x + COLUMN_WIDTH - 1;
canvas_painter.setPen(palette().color(QPalette::Base));