From 16ee7264600da01db691667bfb684d88b869ee37 Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Sat, 14 Apr 2007 00:06:10 +0000 Subject: [PATCH] store default colors to cut down on the problem of repeating myself, provide a place to store a default gene and track color. --- alg/glseqbrowser.cpp | 2 +- alg/glsequence.cpp | 24 +++++++++++++++++++++--- alg/glsequence.hpp | 5 +++++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/alg/glseqbrowser.cpp b/alg/glseqbrowser.cpp index c3f5cb1..37fc0c0 100644 --- a/alg/glseqbrowser.cpp +++ b/alg/glseqbrowser.cpp @@ -354,7 +354,7 @@ void GlSeqBrowser::push_sequence(GlSequence gs) void GlSeqBrowser::push_sequence(GlSequenceRef gs) { - ColorRef default_color(new Color(0.0, 0.8, 0.0)); + ColorRef default_color(GlSequence::default_gene_color()); GlSequenceRef new_gs(new GlSequence(gs)); new_gs->update_annotation_draw_function("gene", draw_narrow_track, default_color); // mark where the sequence is diff --git a/alg/glsequence.cpp b/alg/glsequence.cpp index 2e5bb75..5362b21 100644 --- a/alg/glsequence.cpp +++ b/alg/glsequence.cpp @@ -264,6 +264,24 @@ const ColorRef GlSequence::color() const 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]; @@ -355,7 +373,7 @@ 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); } @@ -498,7 +516,7 @@ void draw_narrow_track(SeqSpanRef s, float left, float right) 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; @@ -514,7 +532,7 @@ void draw_track(SeqSpanRef s, float left, float right) 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() ); GlSequence::draw_box(left, right, x+s->start(), x+s->stop(), diff --git a/alg/glsequence.hpp b/alg/glsequence.hpp index 6f16a19..af1e14c 100644 --- a/alg/glsequence.hpp +++ b/alg/glsequence.hpp @@ -64,6 +64,11 @@ public: const ColorRef color() const; //! return our draw color ColorRef color(); + //! return default gene color + static ColorRef default_gene_color(); + //! return default track color + static ColorRef default_track_color(); + //! return our annotation color mapper AnnotationColorsRef colorMapper() { return color_mapper; } -- 2.30.2