define an analysis should keep settings
[mussa.git] / qui / ThresholdWidget.cpp
1 #include <QHBoxLayout>
2 #include <QSlider>
3
4 #include "qui/ThresholdWidget.hpp"
5
6 // This is completely and totally derived from the Qt example
7 // LCDRange.cpp
8 ThresholdWidget::ThresholdWidget(QWidget *parent, int min, int max) 
9   : QWidget(parent)
10 {
11   basepair_spinner.setRange(min, max);
12
13   connect(&basepair_spinner, SIGNAL(valueChanged(int)), 
14           this, SIGNAL(thresholdChanged(int)));
15
16   basepair_spinner.setValue(min);
17
18   QHBoxLayout *layout = new QHBoxLayout;
19   layout->addWidget(&basepair_spinner);
20   setLayout(layout);
21 }
22 /*
23 void ThresholdWidget::setMinimumThreshold(int min)
24 {
25   basepair_spinner->setMinimum(min);
26 }
27
28 int ThresholdWidget::getMinimumThreshold()
29 {
30   return basepair_spinner->minimum();
31 }
32
33 void ThresholdWidget::setMaximumThreshold(int max)
34 {
35   basepair_spinner->setMaximum(max);
36 }
37
38 int ThresholdWidget::getMaximumThreshold()
39 {
40   return basepair_spinner->maximum();
41 }
42 */
43 void ThresholdWidget::setRange(int min, int max)
44 {
45   basepair_spinner.setRange(min, max);
46 }
47
48 float ThresholdWidget::percent() const
49 {
50   return ((float)threshold())/((float)basepair_spinner.maximum()); 
51 }
52
53 void ThresholdWidget::setThreshold(int threshold)
54 {
55   if (basepair_spinner.value() != threshold)
56   {
57     basepair_spinner.setValue(threshold);
58     emit thresholdChanged(threshold);
59   }
60 }
61
62 int ThresholdWidget::threshold() const
63 {
64   return basepair_spinner.value();
65 }
66
67