better glyph offset computation
authorDiane Trout <diane@caltech.edu>
Thu, 12 Oct 2006 21:51:19 +0000 (21:51 +0000)
committerDiane Trout <diane@caltech.edu>
Thu, 12 Oct 2006 21:51:19 +0000 (21:51 +0000)
my first attempt at computing an offset to better center the
AGCTN ended up putting the links under the wrong basepair.

Not only does this patch put the segment under the right basepair
it also makes the glyphs a little bit wider.

alg/glsequence.cpp

index 3a9df4d3e0e4669445197d5044c8ab9698a2bcd8..6cb1b578fc211c59bcd39c68f721b816116c27fc 100644 (file)
@@ -284,7 +284,7 @@ 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;
+const int max_glyph_width = 5; // unit ( glyph_coord )
 
 static void drawLetter(CP *l, GLfloat z)
 {
@@ -321,8 +321,11 @@ 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;  
+  const float bp_per_world = 1.0; //( world coord )
+  const float glyph_x_scale = 0.125; // unit = ( world coord / glyph coord )
+  // compute how much space there should be to either size of a letter
+  const float glyph_margin = (bp_per_world - glyph_x_scale * max_glyph_width) 
+                           / 2.0;  
 
   assert(seq_end - seq_itor >= 0);
   while(seq_itor != seq_end)