1 #ifndef _GL_SEQUENCE_H_
2 #define _GL_SEQUENCE_H_
4 #include "alg/annotation_colors.hpp"
5 #include "alg/sequence.hpp"
6 #include "alg/color.hpp"
8 //! Manage rendering a mussa sequence track
9 /*! The idea is this will keep track of the location of where the sequence
10 * is being rendered, and handle displaying annotations on that track
15 GlSequence(const Sequence & s, AnnotationColors &cm);
16 GlSequence(const GlSequence & s);
17 GlSequence &operator=(const GlSequence &s);
20 /*! left and right are the edges of the current viewport
22 void draw(GLfloat left, GLfloat right) const;
24 const Sequence& sequence() const;
25 //! set our starting x (horizontal) coordinate
27 //! get our starting x (horizontal) coordinate
29 //! get our right (horizontal) coordinate (length-x)
30 GLfloat right() const;
31 //! set our current y (vertical) position
33 //! get our current y (vertical) position
35 //! how thick (high) the track we're drawing is
36 GLfloat height() const;
37 //! how long is our sequence track? (computed from the sequence)
38 GLfloat length() const;
40 //! return the left (lowest) base index that is fully visible
41 Sequence::size_type GlSequence::leftbase(GLfloat left) const;
42 //! return one past rightmost (highest ) base index that is fully visible
43 /*! done mostly so all the iterator logic continues to work correctly.
45 Sequence::size_type GlSequence::rightbase(GLfloat right) const;
47 //! return iterator to the start of the stored sequence
48 Sequence::const_iterator sequence_begin() const;
49 //! return iterator to the end of the stored sequence
50 Sequence::const_iterator sequence_end() const;
51 //! provide an iterator to the sequence starting at world coordinate left
52 Sequence::const_iterator sequence_begin(GLfloat left, GLfloat right) const;
53 //! provide an iterator to the sequence ending at world coordinate right
54 Sequence::const_iterator sequence_end(GLfloat left, GLfloat right) const;
57 void setColor(Color &);
60 //! are we close enough that it would make sense to view the base pairs?
61 /*! though we don't actually check to see if there's sequence in our
62 * view, just that there's enough pixels to render something if
64 * \param[in] left the left edge of the viewable region in world coordinates
65 * \param[in] right the right edge of the viewable region in world
67 * \param[in] pixel_width allow setting the current viewport pixel width
69 bool is_sequence_renderable(GLfloat left,
71 int pixel_width=-1) const;
73 friend bool operator==(const GlSequence &left, const GlSequence &right);
81 AnnotationColors& color_mapper;
83 const GLfloat char_pix_per_world_unit;
85 //! Return the pixel width of the opengl viewport.
86 static int get_viewport_pixel_width();
87 //! draw a from left to right +/- height/2
88 void draw_box(GLfloat left, GLfloat right, GLfloat height, GLfloat z) const;
89 //! draw sequence as a bar
90 void draw_track(GLfloat, GLfloat) const;
91 void draw_annotations(GLfloat, GLfloat) const;
92 //! render a sequence as ATGC
93 /*! left and right are the current edges of the viewable world
95 void draw_sequence(GLfloat, GLfloat) const;