store default colors
authorDiane Trout <diane@caltech.edu>
Sat, 14 Apr 2007 00:06:10 +0000 (00:06 +0000)
committerDiane Trout <diane@caltech.edu>
Sat, 14 Apr 2007 00:06:10 +0000 (00:06 +0000)
to cut down on the problem of repeating myself, provide a place to store
a default gene and track color.

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

index c3f5cb19a8f4199e7debd2892fd40615d63c1465..37fc0c0e31696ebedfe04f79561d5b48627589eb 100644 (file)
@@ -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
index 2e5bb756b03979448291da6c56982439a3281549..5362b21b1ce96824865d734a6ae39fd7eb116c4a 100644 (file)
@@ -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(), 
index 6f16a199e8c747cd89146316883a934ce8d51d42..af1e14c569e3b9dc0359005bfc2d3c8b6e5370e3 100644 (file)
@@ -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; }