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>
17 typedef boost::shared_ptr<GlSequence> GlSequenceRef;
19 //! Manage rendering a mussa sequence track
20 /*! The idea is this will keep track of the location of where the sequence
21 * is being rendered, and handle displaying annotations on that track
23 class GlSequence : public Sequence
26 GlSequence(const Sequence & s,
27 boost::shared_ptr<AnnotationColors> cm);
28 GlSequence(const GlSequence & s);
29 GlSequence(const GlSequence *);
30 //! Make a new GlSequence, using a copy of SeqSpan
31 GlSequence(const GlSequenceRef);
33 GlSequence &operator=(const GlSequence &s);
35 static DrawableRef default_drawable();
36 static DrawableRef copy_drawable(DrawableRef s);
38 //! search through sequence and add an annotation highlighting all the non AGCT characters
39 void add_annotations_for_defined_sequence(Drawable::draw_func_ptr draw=0);
40 /**!search through our annotations and set the draw function for a particular "type"
41 * this is really a temporary solution to configuring annotation display styles
43 void update_annotation_draw_function(
45 Drawable::draw_func_ptr draw,
48 //! set our starting x (horizontal) coordinate
50 //! get our starting x (horizontal) coordinate
52 //! set our current y (vertical) position
54 //! get our current y (vertical) position
56 //! get our current z (depth) position
58 //! how thick (high) the track we're drawing is
61 //! set our default draw color
62 void setColor(ColorRef &c );
63 //! return our draw color
64 const ColorRef color() const;
65 //! return our draw color
67 //! return our annotation color mapper
68 AnnotationColorsRef colorMapper() { return color_mapper; }
70 //! draw a from left to right +/- height/2
72 void draw_box(GLfloat world_left, GLfloat world_right,
73 GLfloat left, GLfloat right, GLfloat height,
75 GLint primitive=GL_QUADS);
77 /*! left and right are the edges of the current viewport
79 void draw(GLfloat left, GLfloat right) const;
81 //! get our right (horizontal) coordinate (size-x)
83 //! how long is our sequence track? (computed from the sequence)
86 //! return the left (lowest) base index that is fully visible
87 Sequence::size_type leftbase(GLfloat left) const;
88 //! return one past rightmost (highest ) base index that is fully visible
89 //! done mostly so all the iterator logic continues to work correctly.
90 Sequence::size_type rightbase(GLfloat right) const;
92 //! provide an iterator to the sequence starting at world coordinate left
93 Sequence::const_iterator region_begin(GLfloat left, GLfloat right) const;
94 //! provide an iterator to the sequence ending at world coordinate right
95 Sequence::const_iterator region_end(GLfloat left, GLfloat right) const;
97 //! return a subsequence as a GlSequence (instead of a Sequence subsequence)
98 GlSequence subseq(size_type start, size_type count) const;
100 //! Return the pixel width of the opengl viewport.
101 static int get_viewport_width_in_pixels();
102 //! how big is a pixel in world coordinats
103 static GLfloat pixelWidth(GLfloat, GLfloat);
104 //! how big is a pixel in world coordinats (specifying viewport size)
105 static GLfloat pixelWidth(GLfloat, GLfloat, int);
107 //! are we close enough that it would make sense to view the base pairs?
108 bool is_sequence_renderable(GLfloat left, GLfloat right) const;
109 //! are we close enough that it would make sense to view the base pairs?
110 /*! though we don't actually check to see if there's sequence in our
111 * view, just that there's enough pixels to render something if
113 * \param[in] left the left edge of the viewable region in world coordinates
114 * \param[in] right the right edge of the viewable region in world
116 * \param[in] pixel_width allow setting the current viewport pixel width
118 bool is_sequence_renderable(GLfloat, GLfloat, int) const;
120 friend bool operator==(const GlSequence &left, const GlSequence &right);
123 AnnotationColorsRef color_mapper;
124 const GLfloat char_pix_per_world_unit;
126 //! initalize a SeqSpanRef covering start, count
127 SeqSpanRef make_drawable_annotation(
128 Drawable::draw_func_ptr draw,
134 //! draw sequence as a bar
135 void draw_track(GLfloat, GLfloat) const;
136 void draw_annotations(GLfloat, GLfloat) const;
137 //! render a sequence as ATGC
138 /*! left and right are the current edges of the viewable world
140 void draw_sequence(GLfloat, GLfloat) const;
143 void draw_track(SeqSpanRef ref, float left, float right);
144 void draw_narrow_track(SeqSpanRef ref, float left, float right);