#include "stretchpanel.h" #include StretchPanel::StretchPanel(QWidget *parent) : QWidget(parent) { QVBoxLayout *layout = new QVBoxLayout(this); setLayout(layout); 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_lowSlider->setPageStep(512); m_highSlider->setRange(0, UINT16_MAX); m_highSlider->setPageStep(512); m_highSlider->setValue(UINT16_MAX); m_paramSlider->setRange(0, UINT16_MAX); m_paramSlider->setPageStep(512); 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(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(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*100/UINT16_MAX; break; case 3: param = val; break; case 4: val += 100; param = val/100.0f; break; default: return; } emit paramChanged(param); }