Created base class for sample sources
This commit is contained in:
1 parent
4dd39e1ba3
commit
c86e85920b
14 files changed
+302
-227
No files matched your search
+7
-52
@@ -5,17 +5,11 @@
|
||||
#include <QLine>
|
||||
|
||||
OsciWidget::OsciWidget(QWidget *parent) :
|
||||
QOpenGLWidget(parent)
|
||||
QOpenGLWidget{parent}
|
||||
{
|
||||
restartTimer();
|
||||
resizePixmap();
|
||||
}
|
||||
|
||||
int OsciWidget::framerate() const
|
||||
{
|
||||
return m_framerate;
|
||||
}
|
||||
|
||||
int OsciWidget::blend() const
|
||||
{
|
||||
return m_blend;
|
||||
@@ -31,18 +25,6 @@ float OsciWidget::glow() const
|
||||
return m_glow;
|
||||
}
|
||||
|
||||
void OsciWidget::setFramerate(int framerate)
|
||||
{
|
||||
if (framerate == m_framerate)
|
||||
return;
|
||||
|
||||
qDebug() << framerate;
|
||||
|
||||
m_framerate = framerate;
|
||||
|
||||
restartTimer();
|
||||
}
|
||||
|
||||
void OsciWidget::setBlend(int blend)
|
||||
{
|
||||
if (blend == m_blend)
|
||||
@@ -110,7 +92,13 @@ void OsciWidget::renderSamples(const SamplePair *begin, const SamplePair *end)
|
||||
m_lastPoint = p;
|
||||
}
|
||||
|
||||
painter.resetTransform();
|
||||
painter.setCompositionMode(QPainter::CompositionMode_Multiply);
|
||||
painter.fillRect(m_pixmap.rect(), QColor(m_blend,m_blend,m_blend));
|
||||
|
||||
painter.end();
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
void OsciWidget::paintEvent(QPaintEvent *event)
|
||||
@@ -121,22 +109,6 @@ void OsciWidget::paintEvent(QPaintEvent *event)
|
||||
painter.begin(this);
|
||||
painter.drawPixmap(0, 0, m_pixmap);
|
||||
painter.end();
|
||||
// Fade pixmap by multiplying all pixels by m_blend
|
||||
|
||||
painter.begin(&m_pixmap);
|
||||
painter.setCompositionMode(QPainter::CompositionMode_Multiply);
|
||||
painter.fillRect(m_pixmap.rect(), QColor(m_blend,m_blend,m_blend));
|
||||
painter.end();
|
||||
}
|
||||
|
||||
void OsciWidget::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
if (event->timerId() == m_timerId)
|
||||
{
|
||||
repaint();
|
||||
}
|
||||
else
|
||||
QWidget::timerEvent(event);
|
||||
}
|
||||
|
||||
void OsciWidget::resizeEvent(QResizeEvent *event)
|
||||
@@ -146,23 +118,6 @@ void OsciWidget::resizeEvent(QResizeEvent *event)
|
||||
resizePixmap();
|
||||
}
|
||||
|
||||
void OsciWidget::stop()
|
||||
{
|
||||
if (m_timerId != -1)
|
||||
killTimer(m_timerId);
|
||||
}
|
||||
|
||||
void OsciWidget::start()
|
||||
{
|
||||
m_timerId = startTimer(1000/m_framerate);
|
||||
}
|
||||
|
||||
void OsciWidget::restartTimer()
|
||||
{
|
||||
stop();
|
||||
start();
|
||||
}
|
||||
|
||||
void OsciWidget::resizePixmap()
|
||||
{
|
||||
m_pixmap = QPixmap(size());
|
||||
|
||||
Reference in new issue
Block a user