#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
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);
}
--- /dev/null
+#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();
+}
+
+
--- /dev/null
+#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