// LCDRange.cpp
ThresholdWidget::ThresholdWidget(QWidget *parent, int min, int max)
: QWidget(parent),
- layout(new QHBoxLayout(this)),
- basepair_spinner(new QSpinBox(this)),
- window_size_label(new QLabel(this)),
- percent_label(new QLabel(this))
+ layout(0),
+ cur_bp_threshold(0),
+ basepair_spinner(0),
+ window_size_label(0),
+ percent_label(0)
{
+ setupWidgets();
basepair_spinner->setWhatsThis("How many base pairs need to be conserved in the window size");
setRange(min, max);
setLayout(layout);
}
+void ThresholdWidget::setupWidgets()
+{
+ layout = new QHBoxLayout(this);
+ basepair_spinner = new QSpinBox(this);
+ window_size_label = new QLabel(this);
+ percent_label = new QLabel(this);
+}
+
void ThresholdWidget::setRange(int min, int max)
{
basepair_spinner->setRange(min, max);
- cur_bp_threshold = min;
- basepair_spinner->setValue(min);
+ if (cur_bp_threshold < min || cur_bp_threshold > max)
+ {
+ cur_bp_threshold = min;
+ basepair_spinner->setValue(min);
+ }
QString num;
num.setNum(max);
updatePercentThreshold();
}
+bool ThresholdWidget::isReadOnly() const
+{
+ return basepair_spinner->isReadOnly();
+}
+
+void ThresholdWidget::setReadOnly(bool read_only)
+{
+ basepair_spinner->setReadOnly(read_only);
+}
+
double ThresholdWidget::min_ratio() const
{
double ratio=((double)basepair_spinner->minimum()/
{
return cur_bp_threshold;
}
+
+void ThresholdWidget::reset(int min, int max, int threshold)
+{
+
+ cur_bp_threshold = threshold;
+ cur_percent_threshold = (int)(roundl(ratio() * 100));
+ setRange(min, max);
+ basepair_spinner->setValue(threshold);
+ updatePercentThreshold();
+
+}