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