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 Member Functions | Protected Member Functions | List of all members
LevelMeterVU Class Reference

#include <levelmeter.h>

+ Inheritance diagram for LevelMeterVU:
+ Collaboration diagram for LevelMeterVU:

Public Member Functions

 LevelMeterVU (QWidget *parent=0)
 
virtual ~LevelMeterVU ()
 
- 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)
 

Protected Member Functions

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

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 ()
 
- 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
 

Detailed Description

Definition at line 148 of file levelmeter.h.

Constructor & Destructor Documentation

◆ LevelMeterVU()

LevelMeterVU::LevelMeterVU ( QWidget *  parent = 0)

Definition at line 154 of file levelmeter.cpp.

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

154  :
155  LevelMeter(parent)
156 {
157  m_scaleEngine.setFont(font());
158  m_scaleEngine.setOrientation(Qt::Horizontal);
160 
161  resized();
162 }
LevelMeter(QWidget *parent=0)
Definition: levelmeter.cpp:60
virtual void resized()
Definition: levelmeter.cpp:168
ScaleEngine m_scaleEngine
Definition: levelmeter.h:135
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:

◆ ~LevelMeterVU()

LevelMeterVU::~LevelMeterVU ( )
virtual

Definition at line 164 of file levelmeter.cpp.

165 {
166 }

Member Function Documentation

◆ render()

void LevelMeterVU::render ( QPainter *  painter)
protectedvirtual

Implements LevelMeter.

Definition at line 222 of file levelmeter.cpp.

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

223 {
224  painter->drawPixmap(rect(), *m_backgroundPixmap);
225 
226  QRect bar = rect();
227 
228  // Bottom moving gauge
229 
230  bar.setTop(0.5 * rect().height() + 2);
231  bar.setBottom(rect().height() - 1);
232 
233  bar.setRight(rect().right() - (1.0 - 0.75*m_peakHoldLevel) * rect().width());
234  bar.setLeft(bar.right() - 2);
235  painter->fillRect(bar, m_peakColor);
236 
237  bar.setBottom(0.75*rect().height());
238 
239  bar.setRight(rect().right() - (1.0 - 0.75*m_avgLevel) * rect().width());
240  bar.setLeft(1);
241  painter->fillRect(bar, m_avgColor);
242 
243  bar.setTop(0.75 * rect().height() + 1);
244  bar.setBottom(rect().height() - 1);
245 
246  bar.setRight(rect().right() - (1.0 - 0.75*m_decayedPeakLevel) * rect().width());
247  painter->fillRect(bar, m_decayedPeakColor);
248 
249  // borders
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);
256 }
qreal m_avgLevel
Definition: levelmeter.h:87
QPixmap * m_backgroundPixmap
Definition: levelmeter.h:136
qreal m_peakHoldLevel
Definition: levelmeter.h:117
QColor m_avgColor
Definition: levelmeter.h:131
QColor m_peakColor
Definition: levelmeter.h:132
QColor m_decayedPeakColor
Definition: levelmeter.h:133
qreal m_decayedPeakLevel
Definition: levelmeter.h:100

◆ resized()

void LevelMeterVU::resized ( )
protectedvirtual

Implements LevelMeter.

Definition at line 168 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 LevelMeterVU().

169 {
170  if (m_backgroundPixmap)
171  {
172  delete m_backgroundPixmap;
173  }
174 
175  m_backgroundPixmap = new QPixmap(rect().width(), rect().height());
176  m_backgroundPixmap->fill(QColor(42, 42, 42, 255));
177 
178  QPainter painter(m_backgroundPixmap);
179  QRect barTop = m_backgroundPixmap->rect();
180  barTop.setBottom(0.5 * rect().height() - 2);
181  barTop.setTop(2);
182  barTop.setLeft(0.75* rect().width());
183  painter.fillRect(barTop, Qt::red);
184 
185  QRect bar = m_backgroundPixmap->rect();
186 
187  // 100% full height white line
188  painter.setPen(Qt::white);
189  painter.setFont(font());
190 // painter.drawLine(0.75*bar.width(), 0, 0.75*bar.width(), bar.height());
191 
192  m_scaleEngine.setSize(0.75*bar.width());
193  const ScaleEngine::TickList& scaleTickList = m_scaleEngine.getTickList();
194 
195 
196  for (int i = 0; i < scaleTickList.count(); i++)
197  {
198 // qDebug() << "LevelMeterVU::resized: tick #" << i
199 // << " major: " << scaleTickList[i].major
200 // << " pos: " << scaleTickList[i].pos
201 // << " text: " << scaleTickList[i].text
202 // << " textPos: " << scaleTickList[i].textPos
203 // << " textSize: " << scaleTickList[i].textSize;
204  const ScaleEngine::Tick tick = scaleTickList[i];
205 
206  if(tick.major)
207  {
208  if ((tick.textSize > 0) && (tick.textPos > 0))
209  {
210  painter.drawText(QPointF(tick.textPos - (tick.textSize/2) - 4, bar.height()/2 - 3), tick.text);
211  }
212 
213  painter.drawLine(shiftx(tick.pos, bar.width()), 0, shiftx(scaleTickList[i].pos, bar.width()), bar.height());
214  }
215  else
216  {
217  painter.drawLine(tick.pos, bar.height()/2 - 2, scaleTickList[i].pos, bar.height()/2);
218  }
219  }
220 }
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:

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