Added debug controls for afterglow and lightspeed again
This commit is contained in:
@@ -2,11 +2,10 @@
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
// Qt includes
|
||||
#include <QButtonGroup>
|
||||
#include <QMessageBox>
|
||||
#include <QStringBuilder>
|
||||
#include <QRadioButton>
|
||||
#include <QLabel>
|
||||
#include <QWidgetAction>
|
||||
#include <QFormLayout>
|
||||
#include <QSpinBox>
|
||||
#include <QDebug>
|
||||
|
||||
// local includes
|
||||
@@ -43,13 +42,13 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
// setting up menu File
|
||||
connect(m_ui->actionStart, &QAction::triggered, this, &MainWindow::start);
|
||||
connect(m_ui->actionStop, &QAction::triggered, this, &MainWindow::stop);
|
||||
m_ui->action_Quit->setShortcut(QKeySequence::Quit);
|
||||
m_ui->actionQuit->setShortcut(QKeySequence::Quit);
|
||||
|
||||
// setting up menu Devices
|
||||
for (const auto &device : m_audioDevices)
|
||||
{
|
||||
auto name = device.deviceName();
|
||||
const auto action = m_ui->menu_Device->addAction(name);
|
||||
const auto action = m_ui->menuDevice->addAction(name);
|
||||
action->setCheckable(true);
|
||||
m_deviceGroup.addAction(action);
|
||||
|
||||
@@ -61,7 +60,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
// setting up menu Samplerates
|
||||
for (const auto samplerate : samplerates)
|
||||
{
|
||||
auto action = m_ui->menu_Samplerate->addAction(tr("%0").arg(samplerate));
|
||||
auto action = m_ui->menuSamplerate->addAction(tr("%0").arg(samplerate));
|
||||
action->setCheckable(true);
|
||||
m_samplerateGroup.addAction(action);
|
||||
}
|
||||
@@ -71,7 +70,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
// setting up menu Refreshrates
|
||||
for (const auto refreshrate : refreshrates)
|
||||
{
|
||||
auto action = m_ui->menu_Refreshrate->addAction(tr("%0FPS").arg(refreshrate));
|
||||
auto action = m_ui->menuRefreshrate->addAction(tr("%0FPS").arg(refreshrate));
|
||||
action->setCheckable(true);
|
||||
m_refreshrateGroup.addAction(action);
|
||||
}
|
||||
@@ -87,7 +86,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
// setting up menu Zoom
|
||||
for (const auto zoomlevel : zoomlevels)
|
||||
{
|
||||
auto action = m_ui->menu_Zoom->addAction(tr("%0%").arg(zoomlevel));
|
||||
auto action = m_ui->menuZoom->addAction(tr("%0%").arg(zoomlevel));
|
||||
action->setCheckable(true);
|
||||
m_zoomlevelsGroup.addAction(action);
|
||||
}
|
||||
@@ -100,6 +99,29 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
connect(&m_zoomlevelsGroup, &QActionGroup::triggered, this, &MainWindow::zoomChanged);
|
||||
|
||||
//setting up menu Debug
|
||||
{
|
||||
auto widgetAction = new QWidgetAction(this);
|
||||
auto widget = new QWidget;
|
||||
auto layout = new QFormLayout(widget);
|
||||
{
|
||||
auto input = new QSpinBox;
|
||||
input->setRange(0, 255);
|
||||
input->setValue(m_ui->widget->afterglow());
|
||||
connect(input, qOverload<int>(&QSpinBox::valueChanged), m_ui->widget, &OsciWidget::setAfterglow);
|
||||
layout->addRow(tr("Afterglow:"), input);
|
||||
}
|
||||
{
|
||||
auto input = new QSpinBox;
|
||||
input->setRange(0, 255);
|
||||
input->setValue(m_ui->widget->lightspeed());
|
||||
connect(input, qOverload<int>(&QSpinBox::valueChanged), m_ui->widget, &OsciWidget::setLightspeed);
|
||||
layout->addRow(tr("Lightspeed:"), input);
|
||||
}
|
||||
widgetAction->setDefaultWidget(widget);
|
||||
m_ui->menuDebug->addAction(widgetAction);
|
||||
}
|
||||
|
||||
// autostart
|
||||
if (m_audioDevices.isEmpty())
|
||||
{
|
||||
|
@@ -23,43 +23,49 @@
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu_File">
|
||||
<widget class="QMenu" name="menuFile">
|
||||
<property name="title">
|
||||
<string>&File</string>
|
||||
</property>
|
||||
<addaction name="actionStart"/>
|
||||
<addaction name="actionStop"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="action_Quit"/>
|
||||
<addaction name="actionQuit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_Device">
|
||||
<widget class="QMenu" name="menuDevice">
|
||||
<property name="title">
|
||||
<string>&Device</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_Samplerate">
|
||||
<widget class="QMenu" name="menuSamplerate">
|
||||
<property name="title">
|
||||
<string>&Samplerate</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_Refreshrate">
|
||||
<widget class="QMenu" name="menuRefreshrate">
|
||||
<property name="title">
|
||||
<string>&Refreshrate</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_Zoom">
|
||||
<widget class="QMenu" name="menuZoom">
|
||||
<property name="title">
|
||||
<string>&Zoom</string>
|
||||
</property>
|
||||
</widget>
|
||||
<addaction name="menu_File"/>
|
||||
<addaction name="menu_Device"/>
|
||||
<addaction name="menu_Samplerate"/>
|
||||
<addaction name="menu_Refreshrate"/>
|
||||
<addaction name="menu_Zoom"/>
|
||||
<widget class="QMenu" name="menuDebug">
|
||||
<property name="title">
|
||||
<string>Debug</string>
|
||||
</property>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuDevice"/>
|
||||
<addaction name="menuSamplerate"/>
|
||||
<addaction name="menuRefreshrate"/>
|
||||
<addaction name="menuZoom"/>
|
||||
<addaction name="menuDebug"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<action name="action_Quit">
|
||||
<action name="actionQuit">
|
||||
<property name="text">
|
||||
<string>&Quit</string>
|
||||
</property>
|
||||
@@ -86,7 +92,7 @@
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>action_Quit</sender>
|
||||
<sender>actionQuit</sender>
|
||||
<signal>triggered()</signal>
|
||||
<receiver>MainWindow</receiver>
|
||||
<slot>close()</slot>
|
||||
|
@@ -14,6 +14,11 @@ OsciWidget::OsciWidget(QWidget *parent) :
|
||||
m_statsTimer.start();
|
||||
}
|
||||
|
||||
int OsciWidget::lightspeed() const
|
||||
{
|
||||
return std::cbrt(m_lightspeed) * 20.f;
|
||||
}
|
||||
|
||||
void OsciWidget::setFps(int fps)
|
||||
{
|
||||
killTimer(m_redrawTimerId);
|
||||
@@ -23,6 +28,12 @@ void OsciWidget::setFps(int fps)
|
||||
m_redrawTimerId = startTimer(1000/m_fps);
|
||||
}
|
||||
|
||||
void OsciWidget::setLightspeed(int lightspeed) {
|
||||
const auto temp = (float(lightspeed)/20.f);
|
||||
m_lightspeed = temp*temp*temp;
|
||||
qDebug() << m_lightspeed;
|
||||
}
|
||||
|
||||
void OsciWidget::renderSamples(const SamplePair *begin, const SamplePair *end)
|
||||
{
|
||||
m_callbacksCounter++;
|
||||
@@ -52,7 +63,7 @@ void OsciWidget::paintEvent(QPaintEvent *event)
|
||||
// darkening last frame
|
||||
painter.setCompositionMode(QPainter::CompositionMode_Multiply);
|
||||
painter.setPen({});
|
||||
painter.setBrush(QColor(150,150,150 ));
|
||||
painter.setBrush(QColor(m_afterglow, m_afterglow, m_afterglow));
|
||||
painter.drawRect(m_pixmap.rect());
|
||||
|
||||
// drawing new lines ontop
|
||||
@@ -80,7 +91,7 @@ void OsciWidget::paintEvent(QPaintEvent *event)
|
||||
|
||||
const QLineF line(m_lastPoint, p);
|
||||
|
||||
painter.setOpacity(std::min(1.0, 1. / ((line.length() * 75) + 1)));
|
||||
painter.setOpacity(std::min(1.0, 1. / ((line.length() * m_lightspeed) + 1)));
|
||||
|
||||
painter.drawLine(pointToCoordinates(m_lastPoint), pointToCoordinates(p));
|
||||
|
||||
|
18
osciwidget.h
18
osciwidget.h
@@ -21,6 +21,8 @@ public:
|
||||
|
||||
float factor() const { return m_factor; }
|
||||
int fps() const { return m_fps; }
|
||||
int afterglow() const { return m_afterglow; }
|
||||
int lightspeed() const;
|
||||
|
||||
signals:
|
||||
void statusUpdate(const QString &status);
|
||||
@@ -28,6 +30,8 @@ signals:
|
||||
public slots:
|
||||
void setFactor(float factor) { m_factor = factor; }
|
||||
void setFps(int fps);
|
||||
void setAfterglow(int afterglow) { m_afterglow = afterglow; }
|
||||
void setLightspeed(int lightspeed);
|
||||
|
||||
void renderSamples(const SamplePair *begin, const SamplePair *end);
|
||||
|
||||
@@ -36,17 +40,17 @@ protected:
|
||||
void timerEvent(QTimerEvent *event) override;
|
||||
|
||||
private:
|
||||
float m_factor{2.f};
|
||||
|
||||
int m_redrawTimerId;
|
||||
QPointF m_lastPoint;
|
||||
|
||||
float m_factor{2.f};
|
||||
int m_fps{15}, m_afterglow{175};
|
||||
float m_lightspeed{35.f};
|
||||
|
||||
std::vector<SamplePair> m_buffer;
|
||||
|
||||
int m_frameCounter{0}, m_callbacksCounter{0};
|
||||
QElapsedTimer m_statsTimer;
|
||||
|
||||
int m_fps{15};
|
||||
int m_redrawTimerId;
|
||||
|
||||
std::vector<SamplePair> m_buffer;
|
||||
|
||||
QPixmap m_pixmap;
|
||||
};
|
||||
|
Reference in New Issue
Block a user