Add ability to set param of stretch
This commit is contained in:
+30
-5
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user