+ track_container[path_index]->x();
float seq_end_x = s.end.x
+ track_container[path_index+1]->x();
- // add in length
- float seq_start_x_length = s.start.x
+ if (s.length <= 1) {
+ // use lines for elements of length <=1.
+ // and try to center the line
+ const float offset = 0.5;
+ glBegin(GL_LINES);
+ glVertex3f(seq_start_x+offset, s.start.y, -1);
+ glVertex3f(seq_end_x +offset, s.end.y, -1);
+ glEnd();
+ } else {
+ // otherwise use quads
+ // compute length
+ float seq_start_x_length = s.start.x
+ + s.length
+ + track_container[path_index]->x();
+ float seq_end_x_length = s.end.x
+ s.length
- + track_container[path_index]->x();
- float seq_end_x_length = s.end.x
- + s.length
- + track_container[path_index+1]->x();
- //glBegin(GL_LINES);
- // glVertex3f(seq_start_x, s.start.y, -1);
- // glVertex3f(seq_end_x , s.end.y, -1);
- //glEnd();
-
- glBegin(GL_QUADS);
- glVertex3f(seq_start_x, s.start.y, zdepth);
- glVertex3f(seq_end_x, s.end.y, zdepth);
- glVertex3f(seq_end_x_length, s.end.y, zdepth);
- glVertex3f(seq_start_x_length, s.start.y, zdepth);
- glEnd();
+ + track_container[path_index+1]->x();
+ glBegin(GL_QUADS);
+ glVertex3f(seq_start_x, s.start.y, zdepth);
+ glVertex3f(seq_end_x, s.end.y, zdepth);
+ glVertex3f(seq_end_x_length, s.end.y, zdepth);
+ glVertex3f(seq_start_x_length, s.start.y, zdepth);
+ glEnd();
+ }
// clear the names
glPopName(); glPopName(); glPopName();
}
}
+// this way of drawing characters, came from the red open gl book
const int PT = 1;
const int STROKE = 2;
const int END =3;
CP Xdata[] = {{ 0, 5, PT}, {5, -5,STROKE},{0,-5,PT},{5, 5, END}};
CP Ndata[] = {{ 0, -5, PT}, {0, 5, PT}, {5, -5, PT}, {5, 5, END}};
+//! the maximum width used for a charcter glyph
+const int max_glyph_width = 5;
+
static void drawLetter(CP *l, GLfloat z)
{
glBegin(GL_LINE_STRIP);
Sequence::const_iterator seq_itor = sequence_begin(left, right);
Sequence::const_iterator seq_end = sequence_end(left, right);
Sequence::size_type basepair = 0;
+ const float glyph_x_scale = 0.1;
+ const float glyph_margin = ((1.0 / glyph_x_scale) - max_glyph_width) / 4.0;
assert(seq_end - seq_itor >= 0);
while(seq_itor != seq_end)
{
assert ( basepair < seq->size() );
glPushMatrix();
- glTranslatef( seq_x+leftbase(left) + basepair, seq_y, 1.0 );
- glScalef(0.1, 1.0, 1.0);
+ glTranslatef( seq_x+leftbase(left) + basepair + glyph_margin, seq_y, 1.0 );
+ glScalef(glyph_x_scale, 1.0, 1.0);
switch (*seq_itor) {
case 'A': case 'a':
drawLetter(Adata, z);