selected_paths.clear();
selected_tracks.clear();
- std::cout << "hits = " << hits << std::endl;
ptr = (GLuint *) buffer;
if (hits > 0)
selectedMode = true;
return cur_ortho.right - cur_ortho.left;
}
-int GlSeqBrowser::zoomOut()
+double GlSeqBrowser::zoomOut()
{
if (right() - left() > 0) {
cur_ortho.left = left();
cur_ortho.right = right();
- zoom_level = (int)(( (right() - left()) / viewport_size.x) * 100);
+ zoom_level = (right() - left()) / (double)viewport_size.x;
return zoom_level;
} else {
// made up number representing 50 bp / pixel
- return 5000;
+ return 50.0;
}
}
-int GlSeqBrowser::zoomToSequence()
+
+double GlSeqBrowser::zoomToSequence()
{
// (experimentally determined zoom level)
- const int friendly_zoom = 7;
+ const double friendly_zoom = 0.10;
setZoom(friendly_zoom);
return friendly_zoom;
}
-void GlSeqBrowser::setZoom(int new_zoom)
+
+void GlSeqBrowser::setZoom(double new_zoom)
{
update_viewport(viewport_center, new_zoom);
zoom_level = new_zoom;
}
-int GlSeqBrowser::zoom() const
+double GlSeqBrowser::zoom() const
{
return zoom_level;
}
}
}
-void GlSeqBrowser::update_viewport(float center, int new_zoom)
+void GlSeqBrowser::update_viewport(float center, double new_zoom)
{
// limit how close we can get
- if (new_zoom < 1) {
- new_zoom = 1;
+ if (new_zoom < 0.01) {
+ new_zoom = 0.01;
}
- float new_width = (((float)new_zoom / 100.0) * (float)viewport_size.x);
+ double new_width = (new_zoom * (float)viewport_size.x);
cur_ortho.left = center-new_width/2.0;
cur_ortho.right = center+new_width/2.0;
}
float viewportWidth() const;
//! zoom out far enough to show the full size of the sequence
- int zoomOut();
+ double zoomOut();
//! zoom in to a reasonable sequence view
- int zoomToSequence();
- //! set the current zoom level in (base pairs / pix ) * 100
- /*! a zoomlevel of 1 is .01 base pairs per pixel or a rather exploded
- * 100 pixels per base pair
+ double zoomToSequence();
+ //! set the current zoom level in (base pairs / pix )
+ /*! its a double as zoom levels of [0.01, 1.0] make nice sequence views
*/
- void setZoom(int zoom_level);
+ void setZoom(double zoom_level);
//! returns the current zoom level
- int zoom() const;
+ double zoom() const;
void setColorMapper(AnnotationColors& cm);
AnnotationColors& colorMapper();
/*! depending on the size of our canvas, our zoom level and
* how far we've been offset
*/
- void update_viewport(float center, int new_zoom);
+ void update_viewport(float center, double new_zoom);
//! determine where all the tracks should be placed
void update_layout();
point<int> viewport_size;
//! the center of our current viewport (world coord) (used for scrollbar)
float viewport_center;
- int zoom_level;
+ double zoom_level;
AnnotationColors color_mapper;
//! container of all the GlSequences loaded into our scene
std::vector<GlSequence> track_container;
qui/MussaWindow.hpp \
qui/MussaAlignedWindow.hpp \
qui/ThresholdWidget.hpp \
+ qui/ZoomWidget.hpp \
qui/ImageScaler.hpp \
qui/ImageSaveDialog.hpp \
qui/IntAction.hpp \
qui/MussaWindow.cpp \
qui/MussaAlignedWindow.cpp \
qui/ThresholdWidget.cpp \
+ qui/ZoomWidget.cpp \
qui/ImageScaler.cpp \
qui/ImageSaveDialog.cpp \
qui/IntAction.cpp \
motif_editor(0),
browser(this),
mussaViewTB("Path Views"),
- zoomBox(),
+ zoom(),
threshold(),
- zoomLabel(),
closeAction(0) // initialize one of the pointers to null as a saftey flag
{
setupActions();
connect(this, SIGNAL(changedAnnotations()), &browser, SLOT(update()));
mussaViewTB.addAction(toggleMotifsAction);
+ mussaViewTB.addWidget(&zoom);
- zoomLabel.setPixmap(QIcon(":/icons/viewmag.png").pixmap(16, 16));
- zoomLabel.setToolTip(tr("Zoom"));
- zoomLabel.setWhatsThis(tr("Zoom magnification factor"));
- mussaViewTB.addWidget(&zoomLabel);
-
- zoomBox.setToolTip(tr("Zoom"));
- zoomBox.setWhatsThis(tr("Zoom magnification factor"));
- zoomBox.setRange(1,10000000);
- mussaViewTB.addWidget(&zoomBox);
- connect(&zoomBox, SIGNAL(valueChanged(int)),
- &browser, SLOT(setZoom(int)));
+ connect(&zoom, SIGNAL(valueChanged(double)),
+ &browser, SLOT(setZoom(double)));
// threshold range is set in updateAnalysis
updateLinks();
browser.zoomOut();
cout << "browser zoom " << browser.zoom() << endl;
- zoomBox.setValue(browser.zoom());
+ zoom.setValue(browser.zoom());
}
void MussaWindow::updateAnnotations()
#include "qui/mussa_setup_dialog/MussaSetupDialog.hpp"
#include "qui/seqbrowser/SequenceBrowserWidget.hpp"
#include "qui/ThresholdWidget.hpp"
+#include "qui/ZoomWidget.hpp"
+
class QAction;
class QLabel;
// display our wonderful mussa output
SequenceBrowserWidget browser;
QToolBar mussaViewTB;
- QSpinBox zoomBox;
+ ZoomWidget zoom;
ThresholdWidget threshold;
- QLabel zoomLabel;
-
QAction *aboutAction;
QAction *closeAction;
--- /dev/null
+#include <QHBoxLayout>
+#include <QIcon>
+#include <QLabel>
+
+#include "qui/ZoomWidget.hpp"
+#include <iostream>
+using namespace std;
+
+ZoomWidget::ZoomWidget(QWidget *parent)
+ : QWidget(parent),
+ max_zoom_size(10000)
+{
+ zoom.setRange(0.01, max_zoom_size);
+ zoom.setSingleStep(0.1);
+ connect(&zoom, SIGNAL(valueChanged(double)), this, SLOT(setValue(double)));
+
+ QLabel *zoomLabel = new QLabel();
+ zoomLabel->setPixmap(QIcon(":/icons/viewmag.png").pixmap(16, 16));
+ QHBoxLayout *layout = new QHBoxLayout;
+ layout->addWidget(zoomLabel);
+ layout->addWidget(&zoom);
+ setLayout(layout);
+
+ setToolTip(tr("Zoom"));
+ setWhatsThis(tr("Zoom magnification factor (base pairs per pixel)"));
+}
+
+void ZoomWidget::setValue(double value)
+{
+ if (cur_value != value)
+ {
+ cur_value = value;
+ zoom.setValue(cur_value);
+ emit valueChanged(cur_value);
+ }
+}
+
+void ZoomWidget::setRange(double min, double max)
+{
+ zoom.setRange(min, max);
+}
+
+void ZoomWidget::setSingleStep(double val)
+{
+ zoom.setSingleStep(val);
+}
+
+double ZoomWidget::singleStep() const
+{
+ return zoom.singleStep();
+}
+
+double ZoomWidget::minimum() const
+{
+ return zoom.minimum();
+}
+
+double ZoomWidget::maximum() const
+{
+ return zoom.maximum();
+}
+
--- /dev/null
+#ifndef _ZOOMWIDGET_H_
+#define _ZOOMWIDGET_H_
+
+#include <QDoubleSpinBox>
+#include <QWidget>
+
+class ZoomWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ ZoomWidget(QWidget *parent = 0);
+ //! set the range
+ void setRange(double min, double max);
+ double minimum() const;
+ double maximum() const;
+ //! set value used when incrementing the spinner
+ void setSingleStep(double val);
+ //! get the value used to incrementing the spinner
+ double singleStep() const;
+
+public slots:
+ void setValue(double);
+
+signals:
+ //! the current number of base pairs needed for a window of conservation
+ void valueChanged(double);
+
+protected:
+ QDoubleSpinBox zoom;
+
+ double cur_value;
+ const double max_zoom_size;
+ };
+#endif
}
}
-void SequenceBrowser::setZoom(int new_zoom)
+void SequenceBrowser::setZoom(double new_zoom)
{
if (new_zoom != GlSeqBrowser::zoom()) {
GlSeqBrowser::setZoom(new_zoom);
//! set the center of the current viewport
void setViewportCenter(float x);
//! set our magnification level
- void setZoom(int);
+ void setZoom(double);
signals:
//! emited when someone adds to our list of tracks
cout << "Result: " << result << "\n";
}
-int SequenceBrowserWidget::zoom()
+double SequenceBrowserWidget::zoom()
{
return scrollable_browser.browser().zoom();
}
-void SequenceBrowserWidget::zoomOut()
+double SequenceBrowserWidget::zoomOut()
{
- scrollable_browser.browser().zoomOut();
+ double zoom_level = scrollable_browser.browser().zoomOut();
scrollable_browser.updateScrollBar();
+ return zoom_level;
}
-void SequenceBrowserWidget::zoomToSequence()
+double SequenceBrowserWidget::zoomToSequence()
{
- scrollable_browser.browser().zoomToSequence();
+ double zoom_level = scrollable_browser.browser().zoomToSequence();
scrollable_browser.updateScrollBar();
+ return zoom_level;
}
-void SequenceBrowserWidget::setZoom(int z)
+void SequenceBrowserWidget::setZoom(double z)
{
scrollable_browser.browser().setZoom(z);
}
SequenceBrowserWidget(QWidget *parent=0);
//! return current zoom size
- int zoom();
+ double zoom();
//! reset all of our stored data back to the empty state
void clear();
public slots:
//! set the zoom level of our browser
- void setZoom(int);
+ void setZoom(double);
//! zoom to fit the whole scene on the screen
- void zoomOut();
+ double zoomOut();
//! zoom to sequence
- void zoomToSequence();
+ double zoomToSequence();
void updatePosition();
//! ask the user where to save an image of the current browser view