Store Sequence sequence location in a shared_ptr class
[mussa.git] / alg / glsequence.hpp
index c20e1945b11414d0090e829c60d0abc2b87624ec..01b7e056da8ce8c53286f089cf5fce1c4746374d 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef _GL_SEQUENCE_H_
 #define _GL_SEQUENCE_H_
 
+#include <boost/shared_ptr.hpp>
+
 #include "alg/annotation_colors.hpp"
 #include "alg/sequence.hpp"
 #include "alg/color.hpp"
 /*! The idea is this will keep track of the location of where the sequence
  *  is being rendered, and handle displaying annotations on that track
  */
-class GlSequence
+class GlSequence : public Sequence
 {
 public: 
-  GlSequence(const Sequence & s, AnnotationColors &cm);
+  GlSequence(const Sequence & s,
+             boost::shared_ptr<AnnotationColors> cm);
   GlSequence(const GlSequence & s);
+  GlSequence(const GlSequence *);
   GlSequence &operator=(const GlSequence &s);
 
   //! draw a track 
@@ -27,12 +31,11 @@ public:
    */
   void draw(GLfloat left, GLfloat right) const;
 
-  const Sequence& sequence() const;
   //! set our starting x (horizontal) coordinate
   void setX(GLfloat);
   //! get our starting x (horizontal) coordinate
   GLfloat x() const;
-  //! get our right (horizontal) coordinate (length-x)
+  //! get our right (horizontal) coordinate (size-x)
   GLfloat right() const;
   //! set our current y (vertical) position
   void setY(GLfloat);
@@ -41,7 +44,7 @@ public:
   //! how thick (high) the track we're drawing is
   GLfloat height() const;
   //! how long is our sequence track? (computed from the sequence)
-  GLfloat length() const;
+  GLfloat size() const;
  
   //! return the left (lowest) base index that is fully visible
   Sequence::size_type leftbase(GLfloat left) const;
@@ -49,23 +52,22 @@ public:
   //! done mostly so all the iterator logic continues to work correctly.
   Sequence::size_type rightbase(GLfloat right) const;
 
-  //! return iterator to the start of the stored sequence
-  Sequence::const_iterator sequence_begin() const;
-  //! return iterator to the end of the stored sequence
-  Sequence::const_iterator sequence_end() const;
   //! provide an iterator to the sequence starting at world coordinate left
-  Sequence::const_iterator sequence_begin(GLfloat left, GLfloat right) const;
+  Sequence::const_iterator region_begin(GLfloat left, GLfloat right) const;
   //! provide an iterator to the sequence ending at world coordinate right
-  Sequence::const_iterator sequence_end(GLfloat left, GLfloat right) const;
+  Sequence::const_iterator region_end(GLfloat left, GLfloat right) const;
 
+  //! return a subsequence as a GlSequence (instead of a Sequence subsequence)
+  GlSequence subseq(size_type start, size_type count) const;
+  
   //! set track color 
-  void setColor(Color &);
-  Color color();
+  void setColor(boost::shared_ptr<Color> &);
+  boost::shared_ptr<Color> color();
 
   //! how big is a pixel in world coordinats
   GLfloat get_pixel_width(GLfloat, GLfloat) const;
   //! how big is a pixel in world coordinats (specifying viewport size)
-  GLfloat get_pixel_width(GLfloat, GLfloat, int) const;
+  GLfloat pixelWidth(GLfloat, GLfloat, int) const;
 
   //! are we close enough that it would make sense to view the base pairs?
   bool is_sequence_renderable(GLfloat left, GLfloat right) const;
@@ -83,13 +85,12 @@ public:
   friend bool operator==(const GlSequence &left, const GlSequence &right);
 
 protected:
-  const Sequence& seq;
   GLfloat seq_x;
   GLfloat seq_y;
   GLfloat seq_z;
   GLfloat seq_height;
-  AnnotationColors& color_mapper;
-  Color drawColor;
+  boost::shared_ptr<AnnotationColors> color_mapper;
+  boost::shared_ptr<Color> drawColor;
   const GLfloat char_pix_per_world_unit;
 
   //! Return the pixel width of the opengl viewport.