MythTV  master
videovisualcircles.cpp
Go to the documentation of this file.
1 #include <QPen>
2 #include "videovisualcircles.h"
3 
5  : VideoVisualSpectrum(audio, render)
6 {
7  m_numSamples = 32;
8 }
9 
10 void VideoVisualCircles::DrawPriv(MythPainter *painter, QPaintDevice* device)
11 {
12  if (!painter)
13  return;
14 
15  static const QBrush kNobrush(Qt::NoBrush);
16  int red = 0, green = 200;
17  QPen pen(QColor(red, green, 0, 255));
18  int count = m_scale.range();
19  int incr = 200 / count;
20  int rad = m_range;
21  QRect circ(m_area.x() + m_area.width() / 2, m_area.y() + m_area.height() / 2,
22  rad, rad);
23  painter->Begin(device);
24  for (int i = 0; i < count; i++, rad += m_range, red += incr, green -= incr)
25  {
26  double mag = qAbs((m_magnitudes[i] + m_magnitudes[i + count]) / 2.0);
27  if (mag > 1.0)
28  {
29  pen.setWidth((int)mag);
30  painter->DrawRoundRect(circ, rad, kNobrush, pen, 200);
31  }
32  circ.adjust(-m_range, -m_range, m_range, m_range);
33  pen.setColor(QColor(red, green, 0, 255));
34  }
35  painter->End();
36 }
37 
39 {
40  m_range = (static_cast<double>(m_area.height()) / 2.0)
41  / (m_scale.range() - 10);
42  m_scaleFactor = 10.0;
43  m_falloff = 1.0;
44 
45  LOG(VB_GENERAL, LOG_INFO, DESC +
46  QString("Initialised Circles with %1 circles.") .arg(m_scale.range()));
47  return true;
48 }
49 
51 {
52  public:
53  const QString &name(void) const override // VideoVisualFactory
54  {
55  static QString s_name("Circles");
56  return s_name;
57  }
58 
60  MythRender *render) const override // VideoVisualFactory
61  {
62  return new VideoVisualCircles(audio, render);
63  }
64 
65  bool SupportedRenderer(RenderType type) override // VideoVisualFactory
66  {
67  return (type == kRenderOpenGL);
68  }
bool InitialisePriv(void) override
#define DESC
Definition: videovisual.h:16
void DrawPriv(MythPainter *painter, QPaintDevice *device) override
VideoVisual * Create(AudioPlayer *audio, MythRender *render) const override
virtual void DrawRoundRect(const QRect &area, int cornerRadius, const QBrush &fillBrush, const QPen &linePen, int alpha)
virtual void End()
Definition: mythpainter.h:51
const QString & name(void) const override
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
bool SupportedRenderer(RenderType type) override
QVector< double > m_magnitudes
VideoVisualCirclesFactory VideoVisualCirclesFactory
VideoVisualCircles(AudioPlayer *audio, MythRender *render)
RenderType
virtual void Begin(QPaintDevice *parent)
Definition: mythpainter.h:50
QRect m_area
Definition: videovisual.h:64
int range() const