Update mussa to build on ubuntu 10.04 with qt 4.6.2 +boost 1.40.0.1
[mussa.git] / qui / ThresholdWidget.cpp
index c1ca76c2ffae3474bbdf5666c8a7eccda372ea5f..20fdbebaac9bf02bfc9fced140b1b87002b852d7 100644 (file)
@@ -9,11 +9,13 @@
 // 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);
@@ -31,11 +33,22 @@ ThresholdWidget::ThresholdWidget(QWidget *parent, int min, int 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);
@@ -43,6 +56,16 @@ void ThresholdWidget::setRange(int min, int 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()/
@@ -81,3 +104,14 @@ int ThresholdWidget::threshold() const
 {
   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();
+  
+}