length 1 segments should be drawn as lines
[mussa.git] / alg / glsequence.cpp
index 60e14e959772dfd6e06ddbd4ed1a36498ee2f358..678b1000d2c9940bc5c0bfa520a7519e0e2f6fdb 100644 (file)
@@ -251,6 +251,7 @@ void GlSequence::draw_annotations(GLfloat left, GLfloat right) const
 
 }
 
+// this way of drawing characters, came from the red open gl book
 const int PT = 1;
 const int STROKE = 2;
 const int END =3;
@@ -283,6 +284,9 @@ CP Cdata[] = {
 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);
@@ -318,14 +322,16 @@ void GlSequence::draw_sequence(GLfloat left, GLfloat right) const
   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);