#include "alg/glseqbrowser.hpp"
#include "mussa_exceptions.hpp"
+#include <math.h>
#include <iostream>
#include <sstream>
#include <stdexcept>
}
}
+float GlSeqBrowser::get_pixel_width() const
+{
+ GLint viewport[4];
+ glGetIntegerv(GL_VIEWPORT, viewport);
+ GLint vp_width = viewport[3]; // grab the viewport width
+
+ return round((cur_ortho.right-cur_ortho.left)/vp_width);
+}
+
void GlSeqBrowser::setViewportCenter(float x)
{
update_viewport(x, zoom_level);
glEnable(GL_BLEND);
glDepthMask(GL_FALSE);
const float zdepth = -1.0;
+ const float min_segment_width = max((float)(1.0), get_pixel_width());
+
// each vector contains path_segment_maps of all the connections
// between this track and the next
path_segment_map_vector::const_iterator psmv_i;
+ track_container[path_index]->x();
float seq_end_x = s.end.x
+ track_container[path_index+1]->x();
- if (s.length <= 1) {
- // use lines for elements of length <=1.
+ if (s.length <= min_segment_width) {
+ // use lines for elements of length <=1 or < 1 pixel.
// and try to center the line
- const float offset = 0.5;
+ const float offset = s.length * 0.5;
glBegin(GL_LINES);
glVertex3f(seq_start_x+offset, s.start.y, -1);
glVertex3f(seq_end_x +offset, s.end.y, -1);
float left() const;
//! max world right coordinate
float right() const;
+ // return how wide is a pixel in world coordinates?
+ float get_pixel_width() const;
void setViewportCenter(float x);
//! return world coordinate of the left side of the viewport