kwave  18.07.70
Kwave::LogoWidget Class Reference

#include <LogoWidget.h>

Inheritance diagram for Kwave::LogoWidget:
Inheritance graph
Collaboration diagram for Kwave::LogoWidget:
Collaboration graph

Public Slots

void doAnim ()
 

Public Member Functions

 LogoWidget (QWidget *parent)
 
virtual ~LogoWidget () Q_DECL_OVERRIDE
 

Protected Member Functions

virtual void paintEvent (QPaintEvent *) Q_DECL_OVERRIDE
 

Private Attributes

int m_width
 
int m_height
 
bool m_repaint
 
double m_deg [MAXSIN]
 
QImage * m_image
 
QPixmap m_logo
 
QTimer * m_timer
 
double m_color_h
 

Detailed Description

Definition at line 35 of file LogoWidget.h.

Constructor & Destructor Documentation

◆ LogoWidget()

Kwave::LogoWidget::LogoWidget ( QWidget *  parent)
explicit

Constructor

Definition at line 39 of file LogoWidget.cpp.

References Kwave::connect(), doAnim(), m_deg, m_timer, and MAXSIN.

40  :QWidget(parent), m_width(-1), m_height(-1), m_repaint(false),
41  m_image(Q_NULLPTR), m_logo(xpm_aboutlogo), m_timer(Q_NULLPTR),
42  m_color_h(0.0)
43 {
44  for (int i = 0; i < MAXSIN; m_deg[i++] = 0) {}
45 
46  m_timer = new QTimer(this);
47  Q_ASSERT(m_timer);
48  if (!m_timer) return;
49  connect(m_timer, SIGNAL(timeout()), this, SLOT(doAnim()));
50 
51  // gives 40ms refresh ;-)...
52  m_timer->setInterval(40);
53  m_timer->start();
54 
55  QPalette pal = palette();
56  pal.setColor(QPalette::Window, Qt::black);
57  setPalette(pal);
58 }
QTimer * m_timer
Definition: LogoWidget.h:76
bool connect(Kwave::StreamObject &source, const char *output, Kwave::StreamObject &sink, const char *input)
Definition: Connect.cpp:48
QImage * m_image
Definition: LogoWidget.h:70
#define MAXSIN
Definition: LogoWidget.h:31
double m_deg[MAXSIN]
Definition: LogoWidget.h:67
Here is the call graph for this function:

◆ ~LogoWidget()

Kwave::LogoWidget::~LogoWidget ( )
virtual

Destructor

Definition at line 79 of file LogoWidget.cpp.

References m_image, and m_timer.

80 {
81  if (m_timer) delete m_timer;
82  if (m_image) delete m_image;
83 }
QTimer * m_timer
Definition: LogoWidget.h:76
QImage * m_image
Definition: LogoWidget.h:70

Member Function Documentation

◆ doAnim

void Kwave::LogoWidget::doAnim ( )
slot

animates the next step of the logo

Definition at line 61 of file LogoWidget.cpp.

References m_deg, m_repaint, and MAXSIN.

Referenced by LogoWidget().

62 {
63  double mul = 0.04131211 + m_deg[MAXSIN-1] / 75;
64 
65  for (int i = 0; i < MAXSIN; i++) {
66  m_deg[i] += mul;
67  if (m_deg[i] > 2 * M_PI) m_deg[i] = 0;
68  mul = ((mul * 521)/437);
69  mul -= floor(mul); // gives again a number between 0 and 1
70  mul /= 17;
71  mul += m_deg[i] / 100; //so that chaos may be ...
72  }
73 
74  m_repaint = true;
75  repaint();
76 }
#define MAXSIN
Definition: LogoWidget.h:31
double m_deg[MAXSIN]
Definition: LogoWidget.h:67
Here is the caller graph for this function:

◆ paintEvent()

void Kwave::LogoWidget::paintEvent ( QPaintEvent *  )
protectedvirtual

repaints

Definition at line 86 of file LogoWidget.cpp.

References COLOR_INCREMENT, m_color_h, m_deg, m_height, m_image, m_logo, m_repaint, m_width, MAXSIN, rect(), and Kwave::toInt().

87 {
88  // if image has to be resized ...
89  if ((rect().height() != m_height) || (rect().width() != m_width)) {
90  m_height = rect().height();
91  m_width = rect().width();
92 
93  if (m_image) delete m_image;
94  m_image = new QImage(size(), QImage::Format_ARGB32_Premultiplied);
95  m_repaint = true;
96  }
97 
98  if ((m_repaint) && (m_image)) {
99  QPainter p;
100  QPolygon si(20 + 3);
101 
102  p.begin(m_image);
103 
104  // erase everything to black
105  p.setPen(Qt::black);
106  p.setBrush(Qt::black);
107  p.drawRect(0, 0, m_width, m_height);
108 
109  // blit logo bitmap
110  int ampx = (m_logo.width() - m_width ) / 2;
111  int ampy = (m_logo.height() - m_height) / 2;
112  p.setCompositionMode(QPainter::CompositionMode_Source);
113  p.drawPixmap(
114  -ampx + Kwave::toInt(sin(m_deg[0]) * ampx),
115  -ampy + Kwave::toInt(sin(m_deg[1]) * ampy),
116  m_logo);
117 
118  // draw the sine waves with XOR
119  p.setCompositionMode(QPainter::CompositionMode_Exclusion);
120  p.setBrush(QColor::fromHsvF(m_color_h, 1.0, 1.0));
121  m_color_h += COLOR_INCREMENT; // this gives the nice color change :-)
122  if (m_color_h > 1.0) m_color_h -= 1.0;
123 
124  double amp = sin(m_deg[MAXSIN - 1] * 3);
125  for (int j = 0; j < MAXSIN; j++) {
126  for (int i = 0; i < 21; i++) {
127  si.setPoint(i, (j * m_width / MAXSIN) +
128  Kwave::toInt(amp * sin(M_PI * i / 10 + m_deg[j])
129  * m_width / 2),
130  m_height * i / 20);
131  }
132  si.setPoint(21, m_width / 2, m_height);
133  si.setPoint(22, m_width / 2, 0);
134 
135  p.drawPolygon(si);
136  amp = sin(m_deg[j] * 3);
137  }
138 
139  p.end();
140  m_repaint = false;
141  }
142 
143  // blit the result to the display
144  if (m_image) {
145  QPainter p(this);
146  p.drawImage(0, 0, *m_image);
147  p.end();
148  }
149 
150 }
QImage * m_image
Definition: LogoWidget.h:70
int toInt(T x)
Definition: Utils.h:127
#define COLOR_INCREMENT
Definition: LogoWidget.cpp:36
#define MAXSIN
Definition: LogoWidget.h:31
double m_deg[MAXSIN]
Definition: LogoWidget.h:67
static double rect(double param)
Definition: Functions.cpp:29
Here is the call graph for this function:

Member Data Documentation

◆ m_color_h

double Kwave::LogoWidget::m_color_h
private

"H" channel of the sine wave color

Definition at line 79 of file LogoWidget.h.

Referenced by paintEvent().

◆ m_deg

double Kwave::LogoWidget::m_deg[MAXSIN]
private

phase of sinus for animation

Definition at line 67 of file LogoWidget.h.

Referenced by doAnim(), LogoWidget(), and paintEvent().

◆ m_height

int Kwave::LogoWidget::m_height
private

height of the widget

Definition at line 61 of file LogoWidget.h.

Referenced by paintEvent().

◆ m_image

QImage* Kwave::LogoWidget::m_image
private

QImage for drawing

Definition at line 70 of file LogoWidget.h.

Referenced by paintEvent(), and ~LogoWidget().

◆ m_logo

QPixmap Kwave::LogoWidget::m_logo
private

image with the logo

Definition at line 73 of file LogoWidget.h.

Referenced by paintEvent().

◆ m_repaint

bool Kwave::LogoWidget::m_repaint
private

set to true for repaint

Definition at line 64 of file LogoWidget.h.

Referenced by doAnim(), and paintEvent().

◆ m_timer

QTimer* Kwave::LogoWidget::m_timer
private

timer for refresh

Definition at line 76 of file LogoWidget.h.

Referenced by LogoWidget(), and ~LogoWidget().

◆ m_width

int Kwave::LogoWidget::m_width
private

width of the widget

Definition at line 58 of file LogoWidget.h.

Referenced by paintEvent().


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