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