GlSeqBrowser::GlSeqBrowser(const GlSeqBrowser& gt)
: border_width(gt.border_width),
- max_ortho(gt.max_ortho),
cur_ortho(gt.cur_ortho),
viewport_size(gt.viewport_size),
viewport_center(gt.viewport_center),
return cur_ortho.right - cur_ortho.left;
}
+int GlSeqBrowser::zoomOut()
+{
+
+ if (right() - left() > 0) {
+ cur_ortho.left = left();
+ cur_ortho.right = right();
+ zoom_level = (int)(( (right() - left()) / viewport_size.x) * 100);
+ return zoom_level;
+ } else {
+ // made up number representing 50 bp / pixel
+ return 5000;
+ }
+}
+
void GlSeqBrowser::setZoom(int new_zoom)
{
update_viewport(viewport_center, new_zoom);
}
void
-GlSeqBrowser::link(const vector<int>& path, const vector<bool>& rc, int length)
+GlSeqBrowser::link(const vector<int>& path, const vector<bool>& rc, int )
{
if (path.size() < 2) {
// should i throw an error instead?
void GlSeqBrowser::update_viewport(float center, int new_zoom)
{
- float max_width = max_ortho.width();
- // division by zero is a major bummer
+ // limit how close we can get
if (new_zoom < 1) {
new_zoom = 1;
}
- float new_max_width = max_width / new_zoom;
- cur_ortho.left = center-new_max_width;
- cur_ortho.right = center+new_max_width;
+ float new_width = (((float)new_zoom / 100.0) * (float)viewport_size.x);
+ cur_ortho.left = center-new_width/2.0;
+ cur_ortho.right = center+new_width/2.0;
}
void GlSeqBrowser::update_layout()
// nothing to do as we're empty
return;
}
- max_ortho.right = max_base_pairs + border_width;
- max_ortho.left = -border_width;
- max_ortho.top = viewport_size.x;
- max_ortho.bottom = 0;
- cur_ortho = max_ortho;
+ cur_ortho.right = max_base_pairs + border_width;
+ cur_ortho.left = -border_width;
+ cur_ortho.top = viewport_size.x;
+ cur_ortho.bottom = 0;
viewport_center = (cur_ortho.width()/2) + cur_ortho.left;
+ zoomOut();
}
void GlSeqBrowser::draw() const
float viewportHeight() const;
float viewportWidth() const;
+ //! zoom out far enough to show the full size of the sequence
+ int zoomOut();
+ //! 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
+ */
void setZoom(int zoom_level);
+ //! returns the current zoom level
int zoom() const;
void setColorMapper(AnnotationColors& cm);
//! number of pixels to reserve around the edges of our canvas
const int border_width;
- //! the maximum dimensions that our scene is taking up (world coord)
- rect<float> max_ortho;
//! the current viewable region (world coord)
rect<float> cur_ortho;
//! how many pixels our viewport is (screen coord)
zoomBox.setToolTip(tr("Zoom"));
zoomBox.setWhatsThis(tr("Zoom magnification factor"));
- zoomBox.setRange(2,1000);
+ zoomBox.setRange(1,10000000);
mussaViewTB.addWidget(&zoomBox);
connect(&zoomBox, SIGNAL(valueChanged(int)),
&browser, SLOT(setZoom(int)));
const vector<Sequence>& seqs = analysis->sequences();
browser.setSequences(seqs, analysis->colorMapper());
updateLinks();
+ browser.zoomOut();
+ cout << "browser zoom " << browser.zoom() << endl;
+ zoomBox.setValue(browser.zoom());
}
void MussaWindow::updateLinks()