From 709adb67d249056f6864402c17f421a9b31f6119 Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Sat, 21 Apr 2007 01:17:40 +0000 Subject: [PATCH] dont draw sequence box when we can see sequence text 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 | 2 +- alg/glsequence.cpp | 43 +++++++++++++++++++++---------------------- alg/glsequence.hpp | 9 +++++---- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/alg/glseqbrowser.cpp b/alg/glseqbrowser.cpp index ca9f160..afcf6a9 100644 --- a/alg/glseqbrowser.cpp +++ b/alg/glseqbrowser.cpp @@ -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 - 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); diff --git a/alg/glsequence.cpp b/alg/glsequence.cpp index 1a97c70..9f861bb 100644 --- a/alg/glsequence.cpp +++ b/alg/glsequence.cpp @@ -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 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); + } } diff --git a/alg/glsequence.hpp b/alg/glsequence.hpp index af1e14c..a2b5704 100644 --- a/alg/glsequence.hpp +++ b/alg/glsequence.hpp @@ -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? - 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 @@ -120,13 +120,12 @@ public: * 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; - const GLfloat char_pix_per_world_unit; //! initalize a SeqSpanRef covering start, count SeqSpanRef make_drawable_annotation( @@ -145,6 +144,8 @@ protected: 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 -- 2.30.2