SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
LevelMeterSignalDB Class Reference

#include <levelmeter.h>

+ Inheritance diagram for LevelMeterSignalDB:
+ Collaboration diagram for LevelMeterSignalDB:

Public Types

enum  ColorTheme { ColorGold, ColorGreenYellow, ColorGreenAndBlue, ColorCyanAndBlue }
 

Public Member Functions

 LevelMeterSignalDB (QWidget *parent=0)
 
virtual ~LevelMeterSignalDB ()
 
void setColorTheme (ColorTheme colorTheme)
 
void setRange (int min, int max)
 
- Public Member Functions inherited from LevelMeter
 LevelMeter (QWidget *parent=0)
 
virtual ~LevelMeter ()
 
void paintEvent (QPaintEvent *event)
 
void resizeEvent (QResizeEvent *event)
 
void setAverageSmoothing (uint32_t smoothingFactor)
 

Static Public Attributes

static const QColor m_avgColor [4]
 
static const QColor m_decayedPeakColor [4]
 
static const QColor m_peakColor [4]
 

Protected Member Functions

virtual void render (QPainter *painter)
 
virtual void resized ()
 
- Protected Member Functions inherited from LevelMeter
int shiftx (int val, int width)
 

Protected Attributes

ColorTheme m_colorTheme
 
- Protected Attributes inherited from LevelMeter
qreal m_avgLevel
 
qreal m_peakLevel
 
qreal m_decayedPeakLevel
 
QTime m_peakLevelChanged
 
qreal m_peakDecayRate
 
qreal m_peakHoldLevel
 
QTime m_peakHoldLevelChanged
 
uint32_t m_avgSmoothing
 
QTimer * m_redrawTimer
 
QColor m_avgColor
 
QColor m_peakColor
 
QColor m_decayedPeakColor
 
ScaleEngine m_scaleEngine
 
QPixmap * m_backgroundPixmap
 

Additional Inherited Members

- Public Slots inherited from LevelMeter
void reset ()
 
void levelChanged (qreal rmsLevel, qreal peakLevel, int numSamples)
 
- Protected Slots inherited from LevelMeter
void redrawTimerExpired ()
 

Detailed Description

Definition at line 158 of file levelmeter.h.

Member Enumeration Documentation

◆ ColorTheme

Enumerator
ColorGold 
ColorGreenYellow 
ColorGreenAndBlue 
ColorCyanAndBlue 

Definition at line 161 of file levelmeter.h.

Constructor & Destructor Documentation

◆ LevelMeterSignalDB()

LevelMeterSignalDB::LevelMeterSignalDB ( QWidget *  parent = 0)

Definition at line 281 of file levelmeter.cpp.

References Unit::Decibel, LevelMeter::m_scaleEngine, resized(), ScaleEngine::setFont(), ScaleEngine::setOrientation(), and ScaleEngine::setRange().

281  :
282  LevelMeter(parent),
284 {
285  m_scaleEngine.setFont(font());
286  m_scaleEngine.setOrientation(Qt::Horizontal);
288 
289  resized();
290 }
LevelMeter(QWidget *parent=0)
Definition: levelmeter.cpp:60
virtual void resized()
Definition: levelmeter.cpp:301
ScaleEngine m_scaleEngine
Definition: levelmeter.h:135
ColorTheme m_colorTheme
Definition: levelmeter.h:183
void setFont(const QFont &font)
void setRange(Unit::Physical physicalUnit, float rangeMin, float rangeMax)
void setOrientation(Qt::Orientation orientation)
+ Here is the call graph for this function:

◆ ~LevelMeterSignalDB()

LevelMeterSignalDB::~LevelMeterSignalDB ( )
virtual

Definition at line 292 of file levelmeter.cpp.

293 {
294 }

Member Function Documentation

◆ render()

void LevelMeterSignalDB::render ( QPainter *  painter)
protectedvirtual

Implements LevelMeter.

Definition at line 348 of file levelmeter.cpp.

References m_avgColor, LevelMeter::m_avgLevel, LevelMeter::m_backgroundPixmap, m_colorTheme, m_decayedPeakColor, LevelMeter::m_decayedPeakLevel, m_peakColor, and LevelMeter::m_peakHoldLevel.

349 {
350  painter->drawPixmap(rect(), *m_backgroundPixmap);
351 
352  QRect bar = rect();
353 
354  // Bottom moving gauge
355 
356  bar.setTop(0.5 * rect().height() + 2);
357  bar.setBottom(0.75*rect().height());
358 
359  bar.setRight(rect().right() - (1.0 - m_avgLevel) * rect().width());
360  bar.setLeft(1);
361  painter->fillRect(bar, m_avgColor[m_colorTheme]);
362 
363  bar.setTop(0.75 * rect().height() + 1);
364  bar.setBottom(rect().height() - 1);
365 
366  bar.setRight(rect().right() - (1.0 - m_decayedPeakLevel) * rect().width());
367  painter->fillRect(bar, m_decayedPeakColor[m_colorTheme]);
368 
369  bar.setTop(0.5 * rect().height() + 2);
370  bar.setBottom(rect().height() - 1);
371 
372  bar.setRight(rect().right() - (1.0 - m_peakHoldLevel) * rect().width());
373  bar.setLeft(bar.right() - 2);
374  painter->fillRect(bar, m_peakColor[m_colorTheme]);
375 
376  // borders
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);
383 }
qreal m_avgLevel
Definition: levelmeter.h:87
QPixmap * m_backgroundPixmap
Definition: levelmeter.h:136
static const QColor m_peakColor[4]
Definition: levelmeter.h:177
qreal m_peakHoldLevel
Definition: levelmeter.h:117
ColorTheme m_colorTheme
Definition: levelmeter.h:183
static const QColor m_decayedPeakColor[4]
Definition: levelmeter.h:176
static const QColor m_avgColor[4]
Definition: levelmeter.h:175
qreal m_decayedPeakLevel
Definition: levelmeter.h:100

◆ resized()

void LevelMeterSignalDB::resized ( )
protectedvirtual

Implements LevelMeter.

Definition at line 301 of file levelmeter.cpp.

References ScaleEngine::getTickList(), i, LevelMeter::m_backgroundPixmap, LevelMeter::m_scaleEngine, ScaleEngine::Tick::major, ScaleEngine::Tick::pos, ScaleEngine::setSize(), LevelMeter::shiftx(), ScaleEngine::Tick::text, ScaleEngine::Tick::textPos, and ScaleEngine::Tick::textSize.

Referenced by LevelMeterSignalDB().

302 {
303  if (m_backgroundPixmap)
304  {
305  delete m_backgroundPixmap;
306  }
307 
308  m_backgroundPixmap = new QPixmap(rect().width(), rect().height());
309  m_backgroundPixmap->fill(QColor(42, 42, 42, 255));
310 
311  QPainter painter(m_backgroundPixmap);
312  QRect bar = m_backgroundPixmap->rect();
313 
314  // 100% full height white line
315  painter.setPen(Qt::white);
316  painter.setFont(font());
317 
318  m_scaleEngine.setSize(bar.width());
319  const ScaleEngine::TickList& scaleTickList = m_scaleEngine.getTickList();
320 
321 
322  for (int i = 0; i < scaleTickList.count(); i++)
323  {
324 // qDebug() << "LevelMeterVU::resized: tick #" << i
325 // << " major: " << scaleTickList[i].major
326 // << " pos: " << scaleTickList[i].pos
327 // << " text: " << scaleTickList[i].text
328 // << " textPos: " << scaleTickList[i].textPos
329 // << " textSize: " << scaleTickList[i].textSize;
330  const ScaleEngine::Tick tick = scaleTickList[i];
331 
332  if(tick.major)
333  {
334  if ((tick.textSize > 0) && (tick.textPos > 0))
335  {
336  painter.drawText(QPointF(tick.textPos - (tick.textSize/2) - 4, bar.height()/2 - 3), tick.text);
337  }
338 
339  painter.drawLine(shiftx(tick.pos, bar.width()), 0, shiftx(scaleTickList[i].pos,bar.width()), bar.height());
340  }
341  else
342  {
343  painter.drawLine(tick.pos, bar.height()/2 - 2, scaleTickList[i].pos, bar.height()/2);
344  }
345  }
346 }
void setSize(float size)
QPixmap * m_backgroundPixmap
Definition: levelmeter.h:136
ScaleEngine m_scaleEngine
Definition: levelmeter.h:135
int32_t i
Definition: decimators.h:244
int shiftx(int val, int width)
Definition: levelmeter.h:142
const TickList & getTickList()
QList< Tick > TickList
Definition: scaleengine.h:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setColorTheme()

void LevelMeterSignalDB::setColorTheme ( ColorTheme  colorTheme)
inline

Definition at line 172 of file levelmeter.h.

References leansdr::max(), and leansdr::min().

172 { m_colorTheme = colorTheme; }
ColorTheme m_colorTheme
Definition: levelmeter.h:183
+ Here is the call graph for this function:

◆ setRange()

void LevelMeterSignalDB::setRange ( int  min,
int  max 
)

Definition at line 296 of file levelmeter.cpp.

References Unit::Decibel, LevelMeter::m_scaleEngine, and ScaleEngine::setRange().

297 {
299 }
ScaleEngine m_scaleEngine
Definition: levelmeter.h:135
void setRange(Unit::Physical physicalUnit, float rangeMin, float rangeMax)
T max(const T &x, const T &y)
Definition: framework.h:446
T min(const T &x, const T &y)
Definition: framework.h:440
+ Here is the call graph for this function:

Member Data Documentation

◆ m_avgColor

const QColor LevelMeterSignalDB::m_avgColor
static
Initial value:
= {
QColor(0xff, 0x8b, 0x00, 128),
QColor(0x8c, 0xff, 0x00, 128),
QColor(0x8c, 0xff, 0x00, 128),
QColor(0x8c, 0xbf, 0xff, 128),
}

Definition at line 175 of file levelmeter.h.

Referenced by LevelMeterVU::render(), and render().

◆ m_colorTheme

ColorTheme LevelMeterSignalDB::m_colorTheme
protected

Definition at line 183 of file levelmeter.h.

Referenced by render().

◆ m_decayedPeakColor

const QColor LevelMeterSignalDB::m_decayedPeakColor
static
Initial value:
= {
QColor(0x97, 0x54, 0x00, 128),
QColor(0x53, 0x96, 0x00, 128),
QColor(0x00, 0x96, 0x53, 128),
QColor(0x00, 0x94, 0x94, 128),
}

Definition at line 176 of file levelmeter.h.

Referenced by LevelMeterVU::render(), and render().

◆ m_peakColor

const QColor LevelMeterSignalDB::m_peakColor
static
Initial value:
= {
Qt::red,
Qt::green,
Qt::green,
Qt::cyan
}

Definition at line 177 of file levelmeter.h.

Referenced by LevelMeterVU::render(), and render().


The documentation for this class was generated from the following files: