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()));
}
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 size()+x();
}
-GLfloat GlSequence::size() const
+Sequence::size_type GlSequence::size() const
{
return Sequence::size();
}
return seq->drawable()->color();
}
+ColorRef GlSequence::default_gene_color()
+{
+ static ColorRef default_color;
+ if (not default_color) {
+ default_color.reset(new Color(0.0, 0.8, 0.0));
+ }
+ return default_color;
+}
+
+ColorRef GlSequence::default_track_color()
+{
+ static ColorRef default_color;
+ if (not default_color) {
+ default_color.reset(new Color(0.0, 0.0, 0.0));
+ }
+ return default_color;
+}
+
int GlSequence::get_viewport_width_in_pixels()
{
GLint viewport[4];
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);
void GlSequence::draw_track(GLfloat left, GLfloat right) const
{
- glColor3fv(color()->get());
// draw main sequence track
+ glColor3fv(color()->get());
draw_box(left, right, x(), x()+Sequence::size(), height(), y(), 0.0, GL_LINE_LOOP);
+
+ glColor3f(0.8, 0.8, 0.8);
+ draw_box(left, right, x(), x()+Sequence::size(), height(), y(), 0.0);
}
void GlSequence::draw_annotations(GLfloat left, GLfloat right) const
assert((*annot_itor)->parent() == seq);
drawable->drawFunction()((*annot_itor), left, right);
} else {
- glColor3f(0.0, 0.8, 0.0);
+ glColor3fv(default_gene_color()->get());
draw_box(left, right, x()+(*annot_itor)->start(), x()+(*annot_itor)->stop(),
height(), y(), annotation_z);
}
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() : Color(0.0, 0.0, 0.0) );
+ Color c( (s->drawable()) ? s->drawable()->color() : *GlSequence::default_track_color() );
glColor3fv(c.get());
float hsmall = height * 0.25;
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() : Color(0.0, 0.0, 0.0) );
+ // 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);
-}
\ No newline at end of file
+ glColor3fv( c.get() );
+ GlSequence::draw_box(left, right, x+s->start(), x+s->stop(),
+ height, y, z+10);
+ }
+}