dont draw sequence box when we can see sequence text
[mussa.git] / alg / glsequence.cpp
index 1a97c70443918bc27273a8071f030d8b8f49a507..9f861bbac7bf016b404f6e16865590f1e6af2c1b 100644 (file)
@@ -7,36 +7,33 @@
 using namespace std;
 
 static const float default_height = 12.0;
+static const float char_pix_per_world_unit = 2.5;
 
 GlSequence::GlSequence(const Sequence &s, 
                        boost::shared_ptr<AnnotationColors> cm) 
   : Sequence(s),
-    color_mapper(cm),
-    char_pix_per_world_unit(2.5)
+    color_mapper(cm)
 {
   seq->setDrawable(default_drawable());
 }
 
 GlSequence::GlSequence(const GlSequence &s)
   : Sequence(s),
-    color_mapper(s.color_mapper),
-    char_pix_per_world_unit(s.char_pix_per_world_unit)
+    color_mapper(s.color_mapper)
 {
   seq->setDrawable(copy_drawable(s.seq->drawable()));
 }
 
 GlSequence::GlSequence(const GlSequence *s)
   : Sequence(s),
-    color_mapper(s->color_mapper),
-    char_pix_per_world_unit(s->char_pix_per_world_unit)
+    color_mapper(s->color_mapper)
 {
   seq->setDrawable(copy_drawable(s->seq->drawable()));
 }
 
 GlSequence::GlSequence(const GlSequenceRef s)
   : Sequence( (SequenceRef)s ),
-    color_mapper(s->color_mapper),
-    char_pix_per_world_unit(s->char_pix_per_world_unit)
+    color_mapper(s->color_mapper)
 {
   seq->setDrawable(copy_drawable(s->seq->drawable()));
 }
@@ -47,7 +44,6 @@ GlSequence &GlSequence::operator=(const GlSequence & s)
     Sequence::operator=(s);
     seq->setDrawable(copy_drawable(s.seq->drawable()));
     color_mapper = s.color_mapper;
-    assert(char_pix_per_world_unit == s.char_pix_per_world_unit);
   }
   return *this;
 }
@@ -300,14 +296,14 @@ GlSequence::pixelWidth(GLfloat left, GLfloat right, int vp_width)
   return round((right-left)/vp_width);
 }
 
-bool GlSequence::is_sequence_renderable(GLfloat left, GLfloat right) const
+bool GlSequence::is_sequence_renderable(GLfloat left, GLfloat right)
 {
   return is_sequence_renderable(left, right, get_viewport_width_in_pixels());
 }
 
 bool GlSequence::is_sequence_renderable(GLfloat left, 
                                         GLfloat right, 
-                                        int viewport_width) const
+                                        int viewport_width)
 {
   GLfloat world_width = right - left;
   GLfloat pixels_needed = (char_pix_per_world_unit * world_width);
@@ -527,17 +523,20 @@ void draw_narrow_track(SeqSpanRef s, float left, float right)
                        hsmall, y, z+10);
 }
 
-void draw_track(SeqSpanRef s, float left, float right)
+void draw_summarized_track(SeqSpanRef s, float left, float right)
 {
-  SeqSpanRef parent(s->parent());
-  DrawableRef parent_draw(parent->drawable());
-  float x( (parent_draw) ? parent_draw->x() : 0);
-  float y( (parent_draw) ? parent_draw->y() : 0);
-  float z( (parent_draw) ? parent_draw->z() : 10 );
-  float height( (parent_draw) ? parent_draw->height() : default_height ); 
-  Color c( (s->drawable()) ? s->drawable()->color() : *GlSequence::default_track_color() );
+  // if we can see the sequence text (AGCTN), don't draw the black boxes
+  if (not GlSequence::is_sequence_renderable(left, right)) { 
+    SeqSpanRef parent(s->parent());
+    DrawableRef parent_draw(parent->drawable());
+    float x( (parent_draw) ? parent_draw->x() : 0);
+    float y( (parent_draw) ? parent_draw->y() : 0);
+    float z( (parent_draw) ? parent_draw->z() : 10 );
+    float height( (parent_draw) ? parent_draw->height() : default_height ); 
+    Color c( (s->drawable()) ? s->drawable()->color() : *GlSequence::default_track_color() );
 
-  glColor3fv( c.get() );
-  GlSequence::draw_box(left, right, x+s->start(), x+s->stop(), 
-                       height, y, z+10);
+    glColor3fv( c.get() );
+    GlSequence::draw_box(left, right, x+s->start(), x+s->stop(), 
+                         height, y, z+10);
+  }
 }