64 , m_decayedPeakLevel(0.0)
66 , m_peakHoldLevel(0.0)
68 , m_redrawTimer(new QTimer(this))
69 , m_avgColor(0xff, 0x8b, 0x00, 128)
70 , m_peakColor(Qt::red)
71 , m_decayedPeakColor(0x97, 0x54, 0x00, 128)
72 , m_backgroundPixmap(0)
74 setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
98 const qreal smooth = pow(qreal(0.9), static_cast<qreal>(numSamples) /
m_avgSmoothing);
136 QPainter painter(
this);
149 m_avgSmoothing = smoothingFactor < 1 ? 1 : smoothingFactor > 256 ? 256 : smoothingFactor;
180 barTop.setBottom(0.5 * rect().height() - 2);
182 barTop.setLeft(0.75* rect().width());
183 painter.fillRect(barTop, Qt::red);
188 painter.setPen(Qt::white);
189 painter.setFont(font());
196 for (
int i = 0;
i < scaleTickList.count();
i++)
210 painter.drawText(QPointF(tick.
textPos - (tick.
textSize/2) - 4, bar.height()/2 - 3), tick.
text);
213 painter.drawLine(
shiftx(tick.
pos, bar.width()), 0,
shiftx(scaleTickList[
i].pos, bar.width()), bar.height());
217 painter.drawLine(tick.
pos, bar.height()/2 - 2, scaleTickList[
i].pos, bar.height()/2);
230 bar.setTop(0.5 * rect().height() + 2);
231 bar.setBottom(rect().height() - 1);
233 bar.setRight(rect().right() - (1.0 - 0.75*
m_peakHoldLevel) * rect().width());
234 bar.setLeft(bar.right() - 2);
237 bar.setBottom(0.75*rect().height());
239 bar.setRight(rect().right() - (1.0 - 0.75*
m_avgLevel) * rect().width());
243 bar.setTop(0.75 * rect().height() + 1);
244 bar.setBottom(rect().height() - 1);
250 painter->setPen(QColor(0,0,0));
251 painter->drawLine(0, 0, rect().width() - 2, 0);
252 painter->drawLine(0, rect().height() - 1, 0, 0);
253 painter->setPen(QColor(80,80,80));
254 painter->drawLine(1, rect().height() - 1, rect().width() - 1, rect().height() - 1);
255 painter->drawLine(rect().width() - 1, rect().height() - 1, rect().width() - 1, 0);
261 QColor(0xff, 0x8b, 0x00, 128),
262 QColor(0x8c, 0xff, 0x00, 128),
263 QColor(0x8c, 0xff, 0x00, 128),
264 QColor(0x8c, 0xbf, 0xff, 128),
268 QColor(0x97, 0x54, 0x00, 128),
269 QColor(0x53, 0x96, 0x00, 128),
270 QColor(0x00, 0x96, 0x53, 128),
271 QColor(0x00, 0x94, 0x94, 128),
283 m_colorTheme(ColorGold)
315 painter.setPen(Qt::white);
316 painter.setFont(font());
322 for (
int i = 0;
i < scaleTickList.count();
i++)
336 painter.drawText(QPointF(tick.
textPos - (tick.
textSize/2) - 4, bar.height()/2 - 3), tick.
text);
339 painter.drawLine(
shiftx(tick.
pos, bar.width()), 0,
shiftx(scaleTickList[
i].pos,bar.width()), bar.height());
343 painter.drawLine(tick.
pos, bar.height()/2 - 2, scaleTickList[
i].pos, bar.height()/2);
356 bar.setTop(0.5 * rect().height() + 2);
357 bar.setBottom(0.75*rect().height());
359 bar.setRight(rect().right() - (1.0 -
m_avgLevel) * rect().width());
363 bar.setTop(0.75 * rect().height() + 1);
364 bar.setBottom(rect().height() - 1);
369 bar.setTop(0.5 * rect().height() + 2);
370 bar.setBottom(rect().height() - 1);
372 bar.setRight(rect().right() - (1.0 -
m_peakHoldLevel) * rect().width());
373 bar.setLeft(bar.right() - 2);
377 painter->setPen(QColor(0,0,0));
378 painter->drawLine(0, 0, rect().width() - 2, 0);
379 painter->drawLine(0, rect().height() - 1, 0, 0);
380 painter->setPen(QColor(80,80,80));
381 painter->drawLine(1, rect().height() - 1, rect().width() - 1, rect().height() - 1);
382 painter->drawLine(rect().width() - 1, rect().height() - 1, rect().width() - 1, 0);
LevelMeter(QWidget *parent=0)
QPixmap * m_backgroundPixmap
void redrawTimerExpired()
static const QColor m_peakColor[4]
virtual ~LevelMeterSignalDB()
virtual void render(QPainter *painter)=0
LevelMeterSignalDB(QWidget *parent=0)
void setAverageSmoothing(uint32_t smoothingFactor)
ScaleEngine m_scaleEngine
QTime m_peakHoldLevelChanged
void resizeEvent(QResizeEvent *event)
void setFont(const QFont &font)
int shiftx(int val, int width)
static const QColor m_decayedPeakColor[4]
const TickList & getTickList()
const qreal PeakDecayRate
void levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples)
LevelMeterVU(QWidget *parent=0)
void setRange(Unit::Physical physicalUnit, float rangeMin, float rangeMax)
const int PeakHoldLevelDuration
virtual void render(QPainter *painter)
static const QColor m_avgColor[4]
QColor m_decayedPeakColor
void setOrientation(Qt::Orientation orientation)
void setRange(int min, int max)
T max(const T &x, const T &y)
virtual void render(QPainter *painter)
void paintEvent(QPaintEvent *event)
T min(const T &x, const T &y)