MythTV  master
videovisualcircles.cpp
Go to the documentation of this file.
1 // Qt
2 #include <QPen>
3 
4 // MythTV
5 #include "videovisualcircles.h"
6 
7 #ifdef USING_VULKAN
9 #endif
10 
12  : VideoVisualSpectrum(Audio, Render)
13 {
14  m_numSamples = 32;
15 }
16 
17 void VideoVisualCircles::DrawPriv(MythPainter* Painter, QPaintDevice* Device)
18 {
19  if (!Painter)
20  return;
21 
22  static const QBrush kNobrush(Qt::NoBrush);
23  int red = 0;
24  int green = 200;
25  QPen pen(QColor(red, green, 0, 255));
26  int count = m_scale.range();
27  int incr = 200 / count;
28  int rad = static_cast<int>(m_range);
29  QRect circ(m_area.x() + m_area.width() / 2, m_area.y() + m_area.height() / 2,
30  rad, rad);
31  Painter->Begin(Device);
32  for (int i = 0; i < count; i++, rad += m_range, red += incr, green -= incr)
33  {
34  double mag = qAbs((m_magnitudes[i] + m_magnitudes[i + count]) / 2.0);
35  if (mag > 1.0)
36  {
37  pen.setWidth(static_cast<int>(mag));
38  Painter->DrawRoundRect(circ, rad, kNobrush, pen, 200);
39  }
40  circ.adjust(static_cast<int>(-m_range), static_cast<int>(-m_range),
41  static_cast<int>(m_range), static_cast<int>(m_range));
42  pen.setColor(QColor(red, green, 0, 255));
43  }
44  Painter->End();
45 }
46 
48 {
49  m_range = (static_cast<double>(m_area.height()) / 2.0) / (m_scale.range() - 10);
50  m_scaleFactor = 10.0;
51  m_falloff = 1.0;
52 
53  LOG(VB_GENERAL, LOG_INFO, DESC +
54  QString("Initialised Circles with %1 circles.") .arg(m_scale.range()));
55  return true;
56 }
57 
59 {
60  public:
61  const QString &name() const override
62  {
63  static QString s_name(CIRCLES_NAME);
64  return s_name;
65  }
66 
67  VideoVisual* Create(AudioPlayer* Audio, MythRender* Render) const override
68  {
69 #ifdef USING_VULKAN
70  auto * vulkan = dynamic_cast<MythRenderVulkan*>(Render);
71  if (vulkan)
72  return new MythVisualCirclesVulkan(Audio, vulkan);
73 #endif
74  return new VideoVisualCircles(Audio, Render);
75  }
76 
77  bool SupportedRenderer(RenderType Type) override;
78 
80 
82 {
83  return ((Type == kRenderOpenGL) || (Type == kRenderVulkan));
84 }
VideoVisualCirclesFactory::SupportedRenderer
bool SupportedRenderer(RenderType Type) override
Definition: videovisualcircles.cpp:81
VideoVisualSpectrum::m_scale
LogScale m_scale
Definition: videovisualspectrum.h:27
VideoVisualCircles::DrawPriv
void DrawPriv(MythPainter *Painter, QPaintDevice *Device) override
Definition: videovisualcircles.cpp:17
AudioPlayer
Definition: audioplayer.h:28
VideoVisualCirclesFactory
VideoVisualCirclesFactory VideoVisualCirclesFactory
MythVisualCirclesVulkan
Definition: mythvisualcirclesvulkan.h:18
kRenderOpenGL
@ kRenderOpenGL
Definition: mythrender_base.h:19
VideoVisualSpectrum::m_magnitudes
QVector< double > m_magnitudes
Definition: videovisualspectrum.h:25
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
VideoVisualCircles
Definition: videovisualcircles.h:8
Device
A device containing images (ie. USB stick, CD, storage group etc)
Definition: imagemanager.cpp:33
VideoVisualCirclesFactory
Definition: videovisualcircles.cpp:58
kRenderVulkan
@ kRenderVulkan
Definition: mythrender_base.h:20
VideoVisualSpectrum
Definition: videovisualspectrum.h:9
videovisualcircles.h
VideoVisualCircles::VideoVisualCircles
VideoVisualCircles(AudioPlayer *Audio, MythRender *Render)
Definition: videovisualcircles.cpp:11
VideoVisualCirclesFactory::name
const QString & name() const override
Definition: videovisualcircles.cpp:61
DESC
#define DESC
Definition: videovisual.h:19
VideoVisualSpectrum::m_range
double m_range
Definition: videovisualspectrum.h:26
LogScale::range
int range() const
Definition: videovisualdefs.h:20
VideoVisualFactory
Definition: videovisual.h:77
VideoVisualSpectrum::m_falloff
double m_falloff
Definition: videovisualspectrum.h:29
CIRCLES_NAME
#define CIRCLES_NAME
Definition: videovisualcircles.h:6
RenderType
RenderType
Definition: mythrender_base.h:15
MythPainter::End
virtual void End()
Definition: mythpainter.h:53
VideoVisualCircles::InitialisePriv
bool InitialisePriv() override
Definition: videovisualcircles.cpp:47
VideoVisualSpectrum::m_numSamples
int m_numSamples
Definition: videovisualspectrum.h:24
VideoVisualCirclesFactory::Create
VideoVisual * Create(AudioPlayer *Audio, MythRender *Render) const override
Definition: videovisualcircles.cpp:67
MythRender
Definition: mythrender_base.h:23
MythPainter
Definition: mythpainter.h:32
VideoVisual
Definition: videovisual.h:42
MythRenderVulkan
Definition: mythrendervulkan.h:54
VideoVisualSpectrum::m_scaleFactor
double m_scaleFactor
Definition: videovisualspectrum.h:28
VideoVisual::m_area
QRect m_area
Definition: videovisual.h:71
mythvisualcirclesvulkan.h
MythPainter::Begin
virtual void Begin(QPaintDevice *)
Definition: mythpainter.h:52
MythPainter::DrawRoundRect
virtual void DrawRoundRect(QRect area, int cornerRadius, const QBrush &fillBrush, const QPen &linePen, int alpha)
Definition: mythpainter.cpp:168