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);
29 //! max world left coordinate
31 //! max world right coordinate
34 void setViewportCenter(float x);
35 float viewportLeft() const;
36 float viewportCenter() const;
37 float viewportRight() const;
38 float viewportHeight() const;
39 float viewportWidth() const;
41 void setZoom(int zoom_level);
44 void setColorMapper(AnnotationColors& cm);
45 AnnotationColors& colorMapper();
47 //! clear our tracks and connections
50 //! add a sequence to the back of our track container
51 void push_sequence(const Sequence &s);
52 //! add a glsequence to the back of our track container
53 void push_sequence(GlSequence &s);
54 //! return our track container
55 const std::vector<GlSequence>& sequences() const;
57 //! clear all the line segments between all the sequences
60 void link(const std::vector<int>& path, const std::vector<bool>& isRC, int length);
62 //! Provide a logical name for a type discriminator for our glName stack
63 enum FeatureType { MussaTrack, MussaSegment };
65 //! a useful point class
66 template<class T> struct point {
70 point(T x_, T y_):x(x_), y(y_) {}
73 //! a useful rectangle, where 0,0 is in the lower left
74 template<class T> struct rect {
81 rect(T t, T l, T b, T r) : top(t), left(l), bottom(b), right(r) {}
82 T width() { return right - left; }
83 T height() { return top - bottom; }
91 std::set<int> path_ids;
93 Segment() : start(0.0, 0.0), end(0.0, 0.0) {}
94 Segment(float x1, float y1, float x2, float y2, bool isRC)
95 : start(x1, y1), end(x2, y2), reversed(isRC) {}
98 //! data structure holding our line segments
99 /*! the vector is of size track_container.size()-1
100 * it's indexed by the pair x1, x2 (the two x coordinates between
103 typedef std::pair<int, int> segment_key;
104 typedef std::map<segment_key, Segment> pair_segment_map;
105 typedef std::vector<pair_segment_map> path_segment_map_vector;
106 path_segment_map_vector path_segments;
108 //! recalculate the viewable world
109 /*! depending on the size of our canvas, our zoom level and
110 * how far we've been offset
112 void update_viewport(float center, int new_zoom);
114 //! determine where all the tracks should be placed
115 void update_layout();
117 //! convert opengl selections into the list of paths we should highlight
118 void processSelection(GLuint hits, GLuint buffer[], GLuint bufsize);
120 //! master scene drawing function
121 /*! draw is broken out for the opengl selection code
124 //! draw glsequence tracks
125 void draw_tracks() const;
126 //! draw line segments between tracks
127 void draw_segments() const;
128 //! draw selection box
129 void draw_selection() const;
131 //! number of pixels to reserve around the edges of our canvas
133 //! the maximum dimensions that our scene is taking up (world coord)
134 rect<float> max_ortho;
135 //! the current viewable region (world coord)
136 rect<float> cur_ortho;
137 //! how many pixels our viewport is (screen coord)
138 point<int> viewport_size;
139 //! the center of our current viewport (world coord) (used for scrollbar)
140 float viewport_center;
142 AnnotationColors color_mapper;
143 //! container of all the GlSequences loaded into our scene
144 std::vector<GlSequence> track_container;
145 //! counter for each path added to us via connect
149 //! where to draw our box
150 rect<float> selectedRegion;
151 //! true if we have a selection
153 //! indicate which paths are selected
154 std::set<int> selectedPaths;
155 //! which track is selected (it only makes sense to have one track selected).
156 std::set<int> selectedTracks;