8 #include "alg/annotation_colors.hpp"
9 #include "alg/sequence.hpp"
10 #include "alg/glsequence.hpp"
12 //! Manage rendering a collection of glSequences
17 GlSeqBrowser(const GlSeqBrowser&);
19 //! setup the opengl canvas
21 //! called when our screen canvas is resized
22 void resizeGL(int width, int height);
26 //! select a region (using canvas coordinates)
27 void GlSeqBrowser::selectRegion(int top, int left, int bottom, int right);
32 //! max world left coordinate
34 //! max world right coordinate
37 void setViewportCenter(float x);
38 //! return world coordinate of the left side of the viewport
39 float viewportLeft() const;
40 //! return world coordinate of the center of the viewport
41 float viewportCenter() const;
42 //! return world coordinate of the right side of the viewport
43 float viewportRight() const;
44 //! return height of the viewport in world coordinates
45 float viewportHeight() const;
46 //! return width of the viewport in world coordinates
47 float viewportWidth() const;
49 //! zoom out far enough to show the full size of the sequence
51 //! zoom in to a reasonable sequence view
52 double zoomToSequence();
53 //! set the current zoom level in (base pairs / pix )
54 /*! its a double as zoom levels of [0.01, 1.0] make nice sequence views
56 void setZoom(double zoom_level);
57 //! returns the current zoom level as basepairs per pixel
60 void setColorMapper(AnnotationColors& cm);
61 AnnotationColors& colorMapper();
63 //! clear our tracks and connections
66 //! add a sequence to the back of our track container
67 void push_sequence(const Sequence &s);
68 //! add a glsequence to the back of our track container
69 void push_sequence(GlSequence &s);
70 //! return our track container
71 const std::vector<GlSequence>& sequences() const;
73 //! clear all the line segments between all the sequences
76 void link(const std::vector<int>& path, const std::vector<bool>& isRC, int length);
77 //! returns the index of pathids based on order added by link
78 const std::set<int>& selectedPaths() const;
79 //! center the provided path in the current viewport
80 void centerOnPath(const std::vector<int>&);
82 //! Provide a logical name for a type discriminator for our glName stack
83 enum FeatureType { MussaTrack, MussaSegment };
85 //! a useful point class
86 template<class T> struct point {
90 point(T x_, T y_):x(x_), y(y_) {}
93 //! a useful rectangle, where 0,0 is in the lower left
94 template<class T> struct rect {
101 rect(T t, T l, T b, T r) : top(t), left(l), bottom(b), right(r) {}
102 T width() { return right - left; }
103 T height() { return top - bottom; }
111 std::set<int> path_ids;
113 Segment() : start(0.0, 0.0), end(0.0, 0.0) {}
114 Segment(float x1, float y1, float x2, float y2, bool isRC)
115 : start(x1, y1), end(x2, y2), reversed(isRC) {}
118 //! data structure holding our line segments
119 /*! the vector is of size track_container.size()-1
120 * it's indexed by the pair x1, x2 (the two x coordinates between
123 typedef std::pair<int, int> segment_key;
124 typedef std::map<segment_key, Segment> pair_segment_map;
125 typedef std::vector<pair_segment_map> path_segment_map_vector;
126 path_segment_map_vector path_segments;
128 //! recalculate the viewable world
129 /*! depending on the size of our canvas, our zoom level and
130 * how far we've been offset
132 void update_viewport(float center, double new_zoom);
134 //! determine where all the tracks should be placed
135 void update_layout();
137 //! convert opengl selections into the list of paths we should highlight
138 void processSelection(GLuint hits, GLuint buffer[], GLuint bufsize);
140 //! master scene drawing function
141 /*! draw is broken out for the opengl selection code
144 //! draw glsequence tracks
145 void draw_tracks() const;
146 //! draw line segments between tracks
147 void draw_segments() const;
148 //! draw selection box
149 void draw_selection() const;
151 //! number of pixels to reserve around the edges of our canvas
152 const int border_width;
153 //! the current viewable region (world coord)
154 rect<float> cur_ortho;
155 //! how many pixels our viewport is (screen coord)
156 point<int> viewport_size;
157 //! the center of our current viewport (world coord) (used for scrollbar)
158 float viewport_center;
160 AnnotationColors color_mapper;
161 //! container of all the GlSequences loaded into our scene
162 std::vector<GlSequence> track_container;
163 //! counter for each path added to us via connect
167 //! where to draw our box
168 rect<float> selectedRegion;
169 //! true if we have a selection
171 //! indicate which paths are selected
172 std::set<int> selected_paths;
173 //! which track is selected (it only makes sense to have one track selected).
174 std::set<int> selected_tracks;