add a toolbar with toggle motifs and the base pair threshold
authorDiane Trout <diane@caltech.edu>
Sat, 25 Feb 2006 05:31:41 +0000 (05:31 +0000)
committerDiane Trout <diane@caltech.edu>
Sat, 25 Feb 2006 05:31:41 +0000 (05:31 +0000)
mussagl.pro
qui/PathWindow.cxx
qui/PathWindow.h
qui/ThresholdWidget.cxx [new file with mode: 0644]
qui/ThresholdWidget.h [new file with mode: 0644]

index 6f8c36190145033ed4cbba150f54d67a84160185..453719b56da1e85d0eae804e5be17d68641d9e4b 100644 (file)
@@ -14,6 +14,7 @@ INCLUDEPATH += . alg qui
 HEADERS += mussa_exceptions.hh \
            qui/PathWindow.h \
            qui/PathScene.h \
+          qui/ThresholdWidget.h \
            alg/flp.hh \
            alg/mussa_class.hh \
            alg/nway_paths.hh \
@@ -21,6 +22,7 @@ HEADERS += mussa_exceptions.hh \
 SOURCES += mussagl.cxx \
            qui/PathWindow.cxx \
            qui/PathScene.cxx \
+          qui/ThresholdWidget.cxx \
            alg/flp.cxx \
            alg/flp_seqcomp.cxx \
            alg/mussa_class.cxx \
index 0313496789d4a878512a7201ce3cad14365a8619..a3a3a0776b881c11fc49cc9962a49973c9b95c3e 100644 (file)
@@ -7,8 +7,10 @@
 #include <QMessageBox>
 #include <QStatusBar>
 #include <QString>
+#include <QToolBar>
 
 #include "qui/PathScene.h"
+#include "qui/ThresholdWidget.h"
 
 PathWindow::PathWindow(QWidget *) :
   closeAction(0) // initialize one of the pointers to null as a saftey flag
@@ -17,7 +19,16 @@ PathWindow::PathWindow(QWidget *) :
   setupMainMenu();
 
   scene = new PathScene(10000, 10, this);
-  this->setCentralWidget(scene);
+  setCentralWidget(scene);
+
+  mussaViewTB = new QToolBar("Path Views");
+  mussaViewTB->addAction(toggleMotifsAction);
+
+  ThresholdWidget *threshold = new ThresholdWidget;
+  connect(threshold, SIGNAL(currentThresholdChanged(int)),
+          scene, SLOT(setClipPlane(int)));
+  mussaViewTB->addWidget(threshold);
+  addToolBar(mussaViewTB);
 
   statusBar()->showMessage("Welcome to mussa", 2000);
 }
index c25e035b8a1aae3abd1509b83744e65b092c0c57..4677708a0c09a5090f6a48516daa6a2c7fdebbec 100644 (file)
@@ -42,6 +42,7 @@ public slots:
 protected:
   // display our wonderful mussa output
   PathScene *scene;
+  QToolBar *mussaViewTB;
   
   QAction *aboutAction;
   QAction *closeAction;
diff --git a/qui/ThresholdWidget.cxx b/qui/ThresholdWidget.cxx
new file mode 100644 (file)
index 0000000..21a47d6
--- /dev/null
@@ -0,0 +1,75 @@
+#include "qui/ThresholdWidget.h"
+
+#include <QHBoxLayout>
+#include <QLCDNumber>
+#include <QSlider>
+
+// This is completely and totally derived from the Qt example
+// LCDRange.cpp
+ThresholdWidget::ThresholdWidget(QWidget *parent, int min, int max) 
+  : QWidget(parent)
+{
+  QLCDNumber *lcd = new QLCDNumber(threshold_max_display_digits);
+  lcd->setSegmentStyle(QLCDNumber::Filled);
+
+  slider = new QSlider(Qt::Horizontal);
+  slider->setRange(min, max);
+
+  connect(slider, SIGNAL(valueChanged(int)), lcd, SLOT(display(int)));
+  connect(slider, SIGNAL(valueChanged(int)), 
+          this, SIGNAL(thresholdChanged(int)));
+
+  slider->setValue(min);
+  lcd->display(min);
+
+  QHBoxLayout *layout = new QHBoxLayout;
+  layout->addWidget(slider);
+  layout->addWidget(lcd);
+  setLayout(layout);
+}
+/*
+void ThresholdWidget::setMinimumThreshold(int min)
+{
+  slider->setMinimum(min);
+}
+
+int ThresholdWidget::getMinimumThreshold()
+{
+  return slider->minimum();
+}
+
+void ThresholdWidget::setMaximumThreshold(int max)
+{
+  slider->setMaximum(max);
+}
+
+int ThresholdWidget::getMaximumThreshold()
+{
+  return slider->maximum();
+}
+*/
+void ThresholdWidget::setRange(int min, int max)
+{
+  slider->setRange(min, max);
+}
+
+float ThresholdWidget::percent() const
+{
+  return ((float)threshold())/((float)slider->maximum()); 
+}
+
+void ThresholdWidget::setThreshold(int threshold)
+{
+  if (slider->value() != threshold)
+  {
+    slider->setValue(threshold);
+    emit thresholdChanged(threshold);
+  }
+}
+
+int ThresholdWidget::threshold() const
+{
+  return slider->value();
+}
+
+
diff --git a/qui/ThresholdWidget.h b/qui/ThresholdWidget.h
new file mode 100644 (file)
index 0000000..320858f
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef _THRESHOLD_WIDGET_H_ 
+#define _THRESHOLD_WIDGET_H_
+
+#include <QWidget>
+
+class QSlider;
+
+class ThresholdWidget : public QWidget
+{
+  Q_OBJECT 
+
+public: 
+  ThresholdWidget(QWidget *parent = 0, int min=21, int max=30);
+
+  //! return what percent of our maximum threshold we are.
+  float percent() const;
+  //! return our current threshold
+  int threshold() const;
+
+public slots:
+  void setThreshold(int threshold);
+  void setRange(int min, int max);
+
+signals:
+  void thresholdChanged(int new_threshold);
+
+protected:
+  QSlider *slider;
+
+};
+const int threshold_max_display_digits = 2;
+
+#endif