7 #include "alg/annotation_colors.hpp"
8 #include "alg/sequence.hpp"
9 #include "alg/glsequence.hpp"
11 //! Manage rendering a collection of glSequences
16 GlTracks(const GlTracks&);
18 //! setup the opengl canvas
20 //! called when our screen canvas is resized
21 void resizeGL(int width, int height);
25 //! max world left coordinate
27 //! max world right coordinate
30 void setViewportCenter(float x);
31 float viewportLeft() const;
32 float viewportCenter() const;
33 float viewportRight() const;
34 float viewportHeight() const;
35 float viewportWidth() const;
37 void setZoom(int zoom_level);
40 void setColorMapper(AnnotationColors& cm);
41 AnnotationColors& colorMapper();
43 //! clear our tracks and connections
46 //! add a sequence to the back of our track container
47 void push_sequence(const Sequence &s);
48 //! add a glsequence to the back of our track container
49 void push_sequence(GlSequence &s);
50 //! return our track container
51 const std::vector<GlSequence>& tracks() const;
53 //! clear all the line segments between all the sequences
56 void link(std::vector<int> path, std::vector<bool> isRC, int length);
58 //! a useful point class
59 template<class T> struct point {
63 point(T x_, T y_):x(x_), y(y_) {}
66 //! a useful rectangle, where 0,0 is in the lower left
67 template<class T> struct rect {
73 rect(T t, T l, T b, T r) : top(t), left(l), bottom(b), right(r) {}
74 T width() { return right - left; }
75 T height() { return top - bottom; }
83 std::list<int> path_ids;
85 Segment() : start(0.0, 0.0), end(0.0, 0.0) {}
86 Segment(float x1, float y1, float x2, float y2, bool isRC)
87 : start(x1, y1), end(x2, y2), reversed(isRC) {}
90 //! data structure holding our line segments
91 /*! the vector is of size track_container.size()-1
92 * it's indexed by the pair x1, x2 (the two x coordinates between
95 typedef std::pair<int, int> segment_key;
96 typedef std::map<segment_key, Segment> pair_segment_map;
97 typedef std::vector<pair_segment_map> path_segment_map_vector;
98 path_segment_map_vector path_segments;
100 //! recalculate the viewable world
101 /*! depending on the size of our canvas, our zoom level and
102 * how far we've been offset
104 void update_viewport(float center, int new_zoom);
106 //! determine where all the tracks should be placed
107 void update_layout();
109 //! master scene drawing function
110 /*! draw is broken out for the opengl selection code
113 //! draw glsequence tracks
114 void draw_tracks() const;
115 //! draw line segments between tracks
116 void draw_segments() const;
117 //! draw selection box
118 void draw_selection() const;
120 //! number of pixels to reserve around the edges of our canvas
122 //! the maximum dimensions that our scene is taking up (world coord)
123 rect<float> max_ortho;
124 //! the current viewable region (world coord)
125 rect<float> cur_ortho;
126 //! how many pixels our viewport is (screen coord)
127 point<int> viewport_size;
128 //! the center of our current viewport (world coord) (used for scrollbar)
129 float viewport_center;
131 AnnotationColors color_mapper;
132 //! container of all the GlSequences loaded into our scene
133 std::vector<GlSequence> track_container;
134 //! counter for each path added to us via connect