-#include <QHBoxLayout>
#include <QSlider>
#include <QString>
// This is completely and totally derived from the Qt example
// LCDRange.cpp
ThresholdWidget::ThresholdWidget(QWidget *parent, int min, int max)
- : QWidget(parent)
+ : QWidget(parent),
+ layout(new QHBoxLayout(this)),
+ basepair_spinner(new QSpinBox(this)),
+ window_size_label(new QLabel(this)),
+ percent_label(new QLabel(this))
{
- basepair_spinner.setWhatsThis("How many base pairs need to be conserved in the window size");
+ basepair_spinner->setWhatsThis("How many base pairs need to be conserved in the window size");
setRange(min, max);
- connect(&basepair_spinner, SIGNAL(valueChanged(int)),
+ connect(basepair_spinner, SIGNAL(valueChanged(int)),
this, SLOT(setBasepairThreshold(int)));
- basepair_spinner.setValue(min);
+ basepair_spinner->setValue(min);
updatePercentThreshold();
- QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(new QLabel("Threshold"));
- layout->addWidget(&basepair_spinner);
- layout->addWidget(&window_size_label);
- layout->addWidget(&percent_label);
+ layout->addWidget(basepair_spinner);
+ layout->addWidget(window_size_label);
+ layout->addWidget(percent_label);
setLayout(layout);
}
void ThresholdWidget::setRange(int min, int max)
{
- basepair_spinner.setRange(min, max);
+ basepair_spinner->setRange(min, max);
cur_bp_threshold = min;
- basepair_spinner.setValue(min);
+ basepair_spinner->setValue(min);
QString num;
num.setNum(max);
- window_size_label.setText("/"+num);
+ window_size_label->setText("/"+num);
updatePercentThreshold();
}
double ThresholdWidget::min_ratio() const
{
- double ratio=((double)basepair_spinner.minimum()/
- (double)basepair_spinner.maximum());
+ double ratio=((double)basepair_spinner->minimum()/
+ (double)basepair_spinner->maximum());
return ratio;
}
double ThresholdWidget::ratio() const
{
- return ((float)threshold())/((float)basepair_spinner.maximum());
+ return ((float)threshold())/((float)basepair_spinner->maximum());
}
void ThresholdWidget::setBasepairThreshold(int threshold)
{
cur_bp_threshold = threshold;
cur_percent_threshold = (int)(roundl(ratio() * 100));
- basepair_spinner.setValue(threshold);
+ basepair_spinner->setValue(threshold);
updatePercentThreshold();
emit thresholdChanged(threshold);
}
QString label;
label.setNum(min_percent);
label += "%";
- percent_label.setText(label);
+ percent_label->setText(label);
}
int ThresholdWidget::threshold() const