Update mussa to build on ubuntu 10.04 with qt 4.6.2 +boost 1.40.0.1
[mussa.git] / qui / ZoomWidget.cpp
1 #include <QHBoxLayout>
2 #include <QIcon>
3 #include <QLabel>
4
5 #include "qui/ZoomWidget.hpp"
6 #include <iostream>
7 using namespace std;
8
9 ZoomWidget::ZoomWidget(QWidget *parent)
10   : QWidget(parent),
11     zoom(0),
12     max_zoom_size(10000)
13 {
14   zoom = new QDoubleSpinBox(this);
15   zoom->setRange(0.01, max_zoom_size);
16   zoom->setSingleStep(0.1);
17   connect(zoom, SIGNAL(valueChanged(double)), this, SLOT(setValue(double)));
18
19   QLabel *zoomLabel = new QLabel();
20   zoomLabel->setPixmap(QIcon(":/icons/viewmag.png").pixmap(16, 16));
21   QHBoxLayout *layout = new QHBoxLayout;
22   layout->addWidget(zoomLabel);
23   layout->addWidget(zoom);
24   layout->addWidget(new QLabel("bp/pix", this));
25   setLayout(layout);
26
27   setToolTip(tr("Zoom"));
28   setWhatsThis(tr("Zoom magnification factor (base pairs per pixel)"));
29 }
30
31 void ZoomWidget::setValue(double value)
32 {
33   if (cur_value != value)
34   {
35     cur_value = value;
36     zoom->setValue(cur_value);
37     emit valueChanged(cur_value);
38   }
39 }
40
41 void ZoomWidget::setRange(double min, double max)
42 {
43   zoom->setRange(min, max);
44 }
45
46 void ZoomWidget::setSingleStep(double val)
47 {
48   zoom->setSingleStep(val);
49 }
50
51 double ZoomWidget::singleStep() const
52 {
53   return zoom->singleStep();
54 }
55
56 double ZoomWidget::minimum() const
57 {
58   return zoom->minimum();
59 }
60
61 double ZoomWidget::maximum() const
62 {
63   return zoom->maximum();
64 }
65