dont draw sequence box when we can see sequence text
authorDiane Trout <diane@caltech.edu>
Sat, 21 Apr 2007 01:17:40 +0000 (01:17 +0000)
committerDiane Trout <diane@caltech.edu>
Sat, 21 Apr 2007 01:17:40 +0000 (01:17 +0000)
my new draw_track code didn't test to see if the sequence text was visible
thus hiding the text. This fixes that, though at the cost of adding
more logic in the process of rendering the display.

alg/glseqbrowser.cpp
alg/glsequence.cpp
alg/glsequence.hpp

index ca9f160883fb4aadccf87707ae9a98b12711dc2c..afcf6a97fc72d86df432e88978bb20a86c4f64cf 100644 (file)
@@ -365,7 +365,7 @@ void GlSeqBrowser::push_sequence(GlSequenceRef gs)
   GlSequenceRef new_gs(new GlSequence(gs));
   new_gs->update_annotation_draw_function("gene", draw_narrow_track, default_color);
   // mark where the sequence is
   GlSequenceRef new_gs(new GlSequence(gs));
   new_gs->update_annotation_draw_function("gene", draw_narrow_track, default_color);
   // mark where the sequence is
-  new_gs->add_annotations_for_defined_sequence(draw_track);
+  new_gs->add_annotations_for_defined_sequence(draw_summarized_track);
   
   clear_links();
   track_container.push_back(new_gs);
   
   clear_links();
   track_container.push_back(new_gs);
index 1a97c70443918bc27273a8071f030d8b8f49a507..9f861bbac7bf016b404f6e16865590f1e6af2c1b 100644 (file)
@@ -7,36 +7,33 @@
 using namespace std;
 
 static const float default_height = 12.0;
 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),
 
 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),
 {
   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),
 {
   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 ),
 {
   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()));
 }
 {
   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;
     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;
 }
   }
   return *this;
 }
@@ -300,14 +296,14 @@ GlSequence::pixelWidth(GLfloat left, GLfloat right, int vp_width)
   return round((right-left)/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, 
 {
   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);
 {
   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);
 }
 
                        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);
+  }
 }
 }
index af1e14c569e3b9dc0359005bfc2d3c8b6e5370e3..a2b5704a66024f0e6b61f7749d6126b4e9e8fffe 100644 (file)
@@ -110,7 +110,7 @@ public:
   static GLfloat pixelWidth(GLfloat, GLfloat, int);
 
   //! are we close enough that it would make sense to view the base pairs?
   static GLfloat pixelWidth(GLfloat, GLfloat, int);
 
   //! are we close enough that it would make sense to view the base pairs?
-  bool is_sequence_renderable(GLfloat left, GLfloat right) const;
+  static bool is_sequence_renderable(GLfloat left, GLfloat right);
   //! are we close enough that it would make sense to view the base pairs?
   /*! though we don't actually check to see if there's sequence in our
    *  view, just that there's enough pixels to render something if 
   //! are we close enough that it would make sense to view the base pairs?
   /*! though we don't actually check to see if there's sequence in our
    *  view, just that there's enough pixels to render something if 
@@ -120,13 +120,12 @@ public:
    *             coordinates
    *  \param[in] pixel_width allow setting the current viewport pixel width
    */
    *             coordinates
    *  \param[in] pixel_width allow setting the current viewport pixel width
    */
-  bool is_sequence_renderable(GLfloat, GLfloat, int) const;
+  static bool is_sequence_renderable(GLfloat, GLfloat, int);
 
   friend bool operator==(const GlSequence &left, const GlSequence &right);
 
 protected:
   AnnotationColorsRef color_mapper;
 
   friend bool operator==(const GlSequence &left, const GlSequence &right);
 
 protected:
   AnnotationColorsRef color_mapper;
-  const GLfloat char_pix_per_world_unit;
 
   //! initalize a SeqSpanRef covering start, count
   SeqSpanRef make_drawable_annotation(
 
   //! initalize a SeqSpanRef covering start, count
   SeqSpanRef make_drawable_annotation(
@@ -145,6 +144,8 @@ protected:
   void draw_sequence(GLfloat, GLfloat) const;
 };
 
   void draw_sequence(GLfloat, GLfloat) const;
 };
 
-void draw_track(SeqSpanRef ref, float left, float right);
+//! draw sequence track when we're far enough out not to see the AGCTs. 
+void draw_summarized_track(SeqSpanRef ref, float left, float right);
+//! draw a 1/4 width centered track 
 void draw_narrow_track(SeqSpanRef ref, float left, float right);
 #endif
 void draw_narrow_track(SeqSpanRef ref, float left, float right);
 #endif