connect(&basepair_spinner, SIGNAL(valueChanged(int)),
this, SLOT(setBasepairThreshold(int)));
- connect(&percent_spinner, SIGNAL(valueChanged(int)),
- this, SLOT(setPercentThreshold(int)));
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_spinner);
- layout->addWidget(new QLabel("%"));
+ layout->addWidget(&percent_label);
setLayout(layout);
}
QString num;
num.setNum(max);
window_size_label.setText("/"+num);
- int min_percent =(int)fmaxl(0.0, roundl(min_ratio()*100));
- cur_percent_threshold = min_percent;
- percent_spinner.setRange( min_percent, 100);
- if (min_percent != 0.0) {
- percent_spinner.setSingleStep((int)(roundl(1.0/(double)(max)*100.0)));
- }
- percent_spinner.setValue(min_percent);
+ updatePercentThreshold();
}
double ThresholdWidget::min_ratio() const
cur_bp_threshold = threshold;
cur_percent_threshold = (int)(roundl(ratio() * 100));
basepair_spinner.setValue(threshold);
- percent_spinner.setValue(cur_percent_threshold);
+ updatePercentThreshold();
emit thresholdChanged(threshold);
}
}
-void ThresholdWidget::setPercentThreshold(int percent_threshold)
+void ThresholdWidget::updatePercentThreshold()
{
- if (cur_percent_threshold != percent_threshold)
- {
- cur_percent_threshold = percent_threshold;
- long t=lround(basepair_spinner.maximum()*((float)percent_threshold/100.0));
- cur_bp_threshold = (int)t;
- percent_spinner.setValue(percent_threshold);
- basepair_spinner.setValue(cur_bp_threshold);
- emit thresholdChanged(cur_bp_threshold);
- }
+ std::cout << "update percent" << std::endl;
+ int min_percent = (int)fmaxl(0.0, roundl(ratio()*100));
+ QString label;
+ label.setNum(min_percent);
+ label += "%";
+ percent_label.setText(label);
}
int ThresholdWidget::threshold() const