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;
17  int green = 200;
18  QPen pen(QColor(red, green, 0, 255));
19  int count = m_scale.range();
20  int incr = 200 / count;
21  int rad = m_range;
22  QRect circ(m_area.x() + m_area.width() / 2, m_area.y() + m_area.height() / 2,
23  rad, rad);
24  painter->Begin(device);
25  for (int i = 0; i < count; i++, rad += m_range, red += incr, green -= incr)
26  {
27  double mag = qAbs((m_magnitudes[i] + m_magnitudes[i + count]) / 2.0);
28  if (mag > 1.0)
29  {
30  pen.setWidth((int)mag);
31  painter->DrawRoundRect(circ, rad, kNobrush, pen, 200);
32  }
33  circ.adjust(-m_range, -m_range, m_range, m_range);
34  pen.setColor(QColor(red, green, 0, 255));
35  }
36  painter->End();
37 }
38 
40 {
41  m_range = (static_cast<double>(m_area.height()) / 2.0)
42  / (m_scale.range() - 10);
43  m_scaleFactor = 10.0;
44  m_falloff = 1.0;
45 
46  LOG(VB_GENERAL, LOG_INFO, DESC +
47  QString("Initialised Circles with %1 circles.") .arg(m_scale.range()));
48  return true;
49 }
50 
52 {
53  public:
54  const QString &name(void) const override // VideoVisualFactory
55  {
56  static QString s_name("Circles");
57  return s_name;
58  }
59 
61  MythRender *render) const override // VideoVisualFactory
62  {
63  return new VideoVisualCircles(audio, render);
64  }
65 
66  bool SupportedRenderer(RenderType type) override // VideoVisualFactory
67  {
68  return (type == kRenderOpenGL);
69  }
bool InitialisePriv(void) override
#define DESC
Definition: videovisual.h:17
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:65
int range() const