1 #ifndef _GL_SEQUENCE_H_
2 #define _GL_SEQUENCE_H_
4 #include <boost/shared_ptr.hpp>
6 #include "alg/annotation_colors.hpp"
7 #include "alg/sequence.hpp"
8 #include "alg/color.hpp"
9 // isn't it lovely how the header file can live in different places?
11 #include <OpenGL/gl.h>
16 //! Manage rendering a mussa sequence track
17 /*! The idea is this will keep track of the location of where the sequence
18 * is being rendered, and handle displaying annotations on that track
23 GlSequence(boost::shared_ptr<Sequence> s,
24 boost::shared_ptr<AnnotationColors> cm);
25 GlSequence(const GlSequence & s);
26 GlSequence &operator=(const GlSequence &s);
29 /*! left and right are the edges of the current viewport
31 void draw(GLfloat left, GLfloat right) const;
33 boost::shared_ptr<Sequence> sequence();
34 //! set our starting x (horizontal) coordinate
36 //! get our starting x (horizontal) coordinate
38 //! get our right (horizontal) coordinate (size-x)
39 GLfloat right() const;
40 //! set our current y (vertical) position
42 //! get our current y (vertical) position
44 //! how thick (high) the track we're drawing is
45 GLfloat height() const;
46 //! how long is our sequence track? (computed from the sequence)
49 //! return the left (lowest) base index that is fully visible
50 Sequence::size_type leftbase(GLfloat left) const;
51 //! return one past rightmost (highest ) base index that is fully visible
52 //! done mostly so all the iterator logic continues to work correctly.
53 Sequence::size_type rightbase(GLfloat right) const;
55 //! return iterator to the start of the stored sequence
56 Sequence::const_iterator sequence_begin() const;
57 //! return iterator to the end of the stored sequence
58 Sequence::const_iterator sequence_end() const;
59 //! provide an iterator to the sequence starting at world coordinate left
60 Sequence::const_iterator sequence_begin(GLfloat left, GLfloat right) const;
61 //! provide an iterator to the sequence ending at world coordinate right
62 Sequence::const_iterator sequence_end(GLfloat left, GLfloat right) const;
65 void setColor(Color &);
68 //! how big is a pixel in world coordinats
69 GLfloat get_pixel_width(GLfloat, GLfloat) const;
70 //! how big is a pixel in world coordinats (specifying viewport size)
71 GLfloat get_pixel_width(GLfloat, GLfloat, int) const;
73 //! are we close enough that it would make sense to view the base pairs?
74 bool is_sequence_renderable(GLfloat left, GLfloat right) const;
75 //! are we close enough that it would make sense to view the base pairs?
76 /*! though we don't actually check to see if there's sequence in our
77 * view, just that there's enough pixels to render something if
79 * \param[in] left the left edge of the viewable region in world coordinates
80 * \param[in] right the right edge of the viewable region in world
82 * \param[in] pixel_width allow setting the current viewport pixel width
84 bool is_sequence_renderable(GLfloat, GLfloat, int) const;
86 friend bool operator==(const GlSequence &left, const GlSequence &right);
89 boost::shared_ptr<Sequence> seq;
94 boost::shared_ptr<AnnotationColors> color_mapper;
96 const GLfloat char_pix_per_world_unit;
98 //! Return the pixel width of the opengl viewport.
99 static int get_viewport_width_in_pixels();
100 //! draw a from left to right +/- height/2
101 void draw_box(GLfloat world_left, GLfloat world_right, GLfloat left, GLfloat right, GLfloat height, GLfloat z) const;
102 //! draw sequence as a bar
103 void draw_track(GLfloat, GLfloat) const;
104 void draw_annotations(GLfloat, GLfloat) const;
105 //! render a sequence as ATGC
106 /*! left and right are the current edges of the viewable world
108 void draw_sequence(GLfloat, GLfloat) const;