Add ability to set param of stretch

This commit is contained in:
2020-05-16 22:38:38 +02:00
parent ab2a7c9f1a
commit 3fb3b2a760
6 changed files with 50 additions and 7 deletions
+30 -5
View File
@@ -1,6 +1,5 @@
#include "stretchpanel.h"
#include <QVBoxLayout>
#include <QComboBox>
StretchPanel::StretchPanel(QWidget *parent) : QWidget(parent)
{
@@ -9,19 +8,45 @@ StretchPanel::StretchPanel(QWidget *parent) : QWidget(parent)
m_lowSlider = new QSlider(Qt::Horizontal, this);
m_highSlider = new QSlider(Qt::Horizontal, this);
m_paramSlider = new QSlider(Qt::Horizontal, this);
m_lowSlider->setRange(0, UINT16_MAX);
m_highSlider->setRange(0, UINT16_MAX);
m_highSlider->setValue(UINT16_MAX);
m_paramSlider->setRange(0, UINT16_MAX);
QComboBox *stretchSelect = new QComboBox(this);
stretchSelect->addItems({tr("Linear"), tr("Square root"), tr("Power"), tr("Logarithm"), tr("Asinh")});
m_stretchSelect = new QComboBox(this);
m_stretchSelect->addItems({tr("Linear"), tr("Square root"), tr("Power"), tr("Logarithm"), tr("Asinh")});
layout->addWidget(m_lowSlider);
layout->addWidget(m_highSlider);
layout->addWidget(stretchSelect);
layout->addWidget(m_paramSlider);
layout->addWidget(m_stretchSelect);
connect(m_lowSlider, SIGNAL(valueChanged(int)), this, SIGNAL(lowChanged(int)));
connect(m_highSlider, SIGNAL(valueChanged(int)), this, SIGNAL(highChanged(int)));
connect(stretchSelect, SIGNAL(activated(int)), this, SIGNAL(stretchChanged(int)));
connect(m_paramSlider, SIGNAL(valueChanged(int)), this, SLOT(calculateParam()));
connect(m_stretchSelect, SIGNAL(activated(int)), this, SIGNAL(stretchChanged(int)));
connect(m_stretchSelect, SIGNAL(activated(int)), this, SLOT(calculateParam()));
}
void StretchPanel::calculateParam()
{
float val = m_paramSlider->value();
float param;
switch(m_stretchSelect->currentIndex())
{
case 2:
param = val*10/UINT16_MAX;
break;
case 3:
param = val;
break;
case 4:
param = 1.001-val/UINT16_MAX;
break;
default:
return;
}
emit paramChanged(param);
}