| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
#ifndef MAPPING_VIEW_HH |
|---|
| 25 |
#define MAPPING_VIEW_HH |
|---|
| 26 |
|
|---|
| 27 |
#include <FL/Fl.H> |
|---|
| 28 |
#include <FL/Fl_Window.H> |
|---|
| 29 |
#include <FL/Fl_Box.H> |
|---|
| 30 |
#include <FL/fl_draw.H> |
|---|
| 31 |
|
|---|
| 32 |
#include <vector> |
|---|
| 33 |
#include <map> |
|---|
| 34 |
#include <assert.h> |
|---|
| 35 |
|
|---|
| 36 |
#include "SequenceView.hh" |
|---|
| 37 |
#include "MappingContainer.hh" |
|---|
| 38 |
#include "_Canvas.hh" |
|---|
| 39 |
|
|---|
| 40 |
namespace gui { |
|---|
| 41 |
class MappingView : public Fl_Group { |
|---|
| 42 |
protected: |
|---|
| 43 |
const int top_len, bot_len; |
|---|
| 44 |
SequenceView* top_seq, * bot_seq; |
|---|
| 45 |
|
|---|
| 46 |
_Canvas* canvas; |
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
std::vector<MappingContainer*> _maps; |
|---|
| 50 |
|
|---|
| 51 |
MappingView(int a, int b, int c, int d, int top, int bot) |
|---|
| 52 |
: Fl_Group(a, b, c, d), top_len(top), bot_len(bot), |
|---|
| 53 |
top_seq(NULL), bot_seq(NULL) { }; |
|---|
| 54 |
public: |
|---|
| 55 |
|
|---|
| 56 |
void add_map(MappingContainer* m) { |
|---|
| 57 |
_maps.push_back(m); |
|---|
| 58 |
|
|---|
| 59 |
MappingContainerChanged_ * listener; |
|---|
| 60 |
listener = new MappingContainerChanged_Redrawer(this); |
|---|
| 61 |
|
|---|
| 62 |
m->add_change_listener(listener); |
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
virtual void zoom_top(int start, int end) { |
|---|
| 67 |
canvas->set_top_sequence_coords(start, end); |
|---|
| 68 |
redraw(); |
|---|
| 69 |
} |
|---|
| 70 |
|
|---|
| 71 |
virtual void zoom_bot(int start, int end) { |
|---|
| 72 |
canvas->set_bot_sequence_coords(start, end); |
|---|
| 73 |
redraw(); |
|---|
| 74 |
} |
|---|
| 75 |
|
|---|
| 76 |
virtual void select_top(unsigned int start, unsigned int end) { }; |
|---|
| 77 |
virtual void select_bot(unsigned int start, unsigned int end) { }; |
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
SequenceView * get_top_seq_view() const { return top_seq; } |
|---|
| 81 |
SequenceView * get_bot_seq_view() const { return bot_seq; } |
|---|
| 82 |
const _Canvas * get_canvas() const { return canvas; } |
|---|
| 83 |
}; |
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
class SequenceViewListener_MappingAdapter : |
|---|
| 91 |
public SequenceViewListener_ { |
|---|
| 92 |
private: |
|---|
| 93 |
MappingView* view; |
|---|
| 94 |
int position; |
|---|
| 95 |
public: |
|---|
| 96 |
const static int TOP = 0; |
|---|
| 97 |
const static int BOT = 1; |
|---|
| 98 |
|
|---|
| 99 |
SequenceViewListener_MappingAdapter(MappingView* v, int p) : |
|---|
| 100 |
SequenceViewListener_(), view(v), position(p) { |
|---|
| 101 |
assert(position == TOP || position == BOT); |
|---|
| 102 |
} |
|---|
| 103 |
|
|---|
| 104 |
void notify(SequenceViewCoordinates& coords) { |
|---|
| 105 |
if (position == TOP) { |
|---|
| 106 |
view->zoom_top(coords.start, coords.end); |
|---|
| 107 |
} else { |
|---|
| 108 |
view->zoom_bot(coords.start, coords.end); |
|---|
| 109 |
} |
|---|
| 110 |
} |
|---|
| 111 |
|
|---|
| 112 |
void set_selection(unsigned int start, unsigned int end) { |
|---|
| 113 |
if (position == TOP) { |
|---|
| 114 |
view->select_top(start, end); |
|---|
| 115 |
} else { |
|---|
| 116 |
view->select_bot(start, end); |
|---|
| 117 |
} |
|---|
| 118 |
} |
|---|
| 119 |
}; |
|---|
| 120 |
} |
|---|
| 121 |
|
|---|
| 122 |
#endif |
|---|
| 123 |
|
|---|