| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
#include <iostream> |
|---|
| 17 |
#include "AlignmentCloseupView.hh" |
|---|
| 18 |
#include "SequenceZoomCoordinator.hh" |
|---|
| 19 |
#include "FeatureInfoDisplayWindow.hh" |
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
class _HighlightedFeatureList : public gui::SimpleMappingContainer { |
|---|
| 25 |
protected: |
|---|
| 26 |
gui::FeaturesContainer * _orig_c; |
|---|
| 27 |
public: |
|---|
| 28 |
_HighlightedFeatureList(gui::FeaturesContainer* c) :_orig_c(c) { |
|---|
| 29 |
select_feature(NULL); |
|---|
| 30 |
} |
|---|
| 31 |
|
|---|
| 32 |
void select_feature(const gui::Feature * f) { |
|---|
| 33 |
delete _c; |
|---|
| 34 |
gui::FeatureList * new_l = new gui::FeatureList(); |
|---|
| 35 |
if (f) { new_l->add_feature(f->copy_me()); } |
|---|
| 36 |
_c = new gui::SimpleFeaturesContainer(new_l); |
|---|
| 37 |
|
|---|
| 38 |
notify_changed(); |
|---|
| 39 |
} |
|---|
| 40 |
}; |
|---|
| 41 |
|
|---|
| 42 |
static void feature_select_cb(const gui::Feature * f, void * passthru) |
|---|
| 43 |
{ |
|---|
| 44 |
AlignmentCloseupView * aln_obj; |
|---|
| 45 |
aln_obj = (AlignmentCloseupView *) passthru; |
|---|
| 46 |
|
|---|
| 47 |
aln_obj->change_viewed_feature(f); |
|---|
| 48 |
} |
|---|
| 49 |
|
|---|
| 50 |
static void feature_info_cb(Fl_Widget * w, void * passthru) |
|---|
| 51 |
{ |
|---|
| 52 |
gui::Feature * f = (gui::Feature*) passthru; |
|---|
| 53 |
if (f && f->has_info()) { |
|---|
| 54 |
FeatureInfoDisplayWindow * disp = new FeatureInfoDisplayWindow(300, 400, |
|---|
| 55 |
f); |
|---|
| 56 |
disp->show(); |
|---|
| 57 |
} |
|---|
| 58 |
} |
|---|
| 59 |
|
|---|
| 60 |
static void del_window_cb(Fl_Widget * w, void * p) |
|---|
| 61 |
{ |
|---|
| 62 |
Fl_Window * window = (Fl_Window *) w; |
|---|
| 63 |
|
|---|
| 64 |
w->hide(); |
|---|
| 65 |
delete window; |
|---|
| 66 |
} |
|---|
| 67 |
|
|---|
| 68 |
AlignmentCloseupView::AlignmentCloseupView(const gui::SimpleMappingContainer * map, |
|---|
| 69 |
const gui::MappingView * view, |
|---|
| 70 |
unsigned int w, unsigned int h) : |
|---|
| 71 |
Fl_Double_Window(w, h) |
|---|
| 72 |
{ |
|---|
| 73 |
callback(del_window_cb); |
|---|
| 74 |
|
|---|
| 75 |
gui::SequenceView * old_top_view = view->get_top_seq_view(); |
|---|
| 76 |
gui::SequenceView * old_bot_view = view->get_bot_seq_view(); |
|---|
| 77 |
|
|---|
| 78 |
std::string top_name = old_top_view->sequence_name(); |
|---|
| 79 |
std::string top_seq = old_top_view->sequence_text(); |
|---|
| 80 |
std::string bot_name = old_top_view->sequence_name(); |
|---|
| 81 |
std::string bot_seq = old_bot_view->sequence_text(); |
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
tiling = new Fl_Pack(0, 0, w, h); |
|---|
| 85 |
add(tiling); |
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
line_view_a = new gui::HorizontalSequenceView(0, 100, w, top_seq.length()); |
|---|
| 89 |
line_view_a->sequence_text(top_seq); |
|---|
| 90 |
|
|---|
| 91 |
line_view_b = new gui::ClickableFeaturesSequenceView(0, 0, w, top_seq.length(), map->get_features_container()); |
|---|
| 92 |
line_view_b->sequence_text(top_seq); |
|---|
| 93 |
line_view_b->show_sequence_line(false); |
|---|
| 94 |
line_view_b->select_feature_handler(feature_select_cb, this); |
|---|
| 95 |
|
|---|
| 96 |
gui::SequenceZoomCoordinator* top_coord = new gui::SequenceZoomCoordinator(); |
|---|
| 97 |
gui::SequenceZoomCoordinator* bot_coord = new gui::SequenceZoomCoordinator(); |
|---|
| 98 |
line_view_a->zoom_coordinator(top_coord); |
|---|
| 99 |
line_view_b->zoom_coordinator(top_coord); |
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
gui::SimpleMappingContainer * new_map = map->copy_me(); |
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
new_view = new gui::PairwiseMappingView(0, 200, w, 250, |
|---|
| 106 |
top_name, top_seq, |
|---|
| 107 |
bot_name, bot_seq); |
|---|
| 108 |
|
|---|
| 109 |
new_view->get_top_seq_view()->zoom_coordinator(top_coord); |
|---|
| 110 |
new_view->get_bot_seq_view()->zoom_coordinator(bot_coord); |
|---|
| 111 |
|
|---|
| 112 |
new_view->add_map(new_map); |
|---|
| 113 |
|
|---|
| 114 |
hilite = new _HighlightedFeatureList(map->get_features_container()); |
|---|
| 115 |
hilite->color(FL_RED); |
|---|
| 116 |
new_view->add_map(hilite); |
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
aln_label = new gui::TextLabel(0, 0, w - 120, 40, "Alignment:"); |
|---|
| 124 |
aln_label->align(FL_ALIGN_LEFT); |
|---|
| 125 |
aln_label->color(FL_WHITE); |
|---|
| 126 |
aln_label->bold(true); |
|---|
| 127 |
aln_label->box(FL_THIN_DOWN_FRAME); |
|---|
| 128 |
|
|---|
| 129 |
aln_info_pack = new Fl_Pack(0, 0, w, 40); |
|---|
| 130 |
aln_info_pack->type(Fl_Pack::HORIZONTAL); |
|---|
| 131 |
aln_info_pack->add(aln_label); |
|---|
| 132 |
|
|---|
| 133 |
view_info = new Fl_Button(w - 120, 0, 120, 40); |
|---|
| 134 |
view_info->label("View feature info"); |
|---|
| 135 |
view_info->callback(feature_info_cb); |
|---|
| 136 |
aln_info_pack->add(view_info); |
|---|
| 137 |
|
|---|
| 138 |
aln_view = new gui::AlignedSequencePairWidget(0, 0, w, h); |
|---|
| 139 |
|
|---|
| 140 |
tiling->add(line_view_a); |
|---|
| 141 |
tiling->add(line_view_b); |
|---|
| 142 |
tiling->add(new_view); |
|---|
| 143 |
tiling->add(aln_info_pack); |
|---|
| 144 |
tiling->add(aln_view); |
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 |
|
|---|
| 150 |
unsigned int top_sel_start = old_top_view->start_sel_base(); |
|---|
| 151 |
unsigned int top_sel_end = old_top_view->end_sel_base(); |
|---|
| 152 |
|
|---|
| 153 |
unsigned int bot_sel_start = old_bot_view->start_sel_base(); |
|---|
| 154 |
unsigned int bot_sel_end = old_bot_view->end_sel_base(); |
|---|
| 155 |
|
|---|
| 156 |
line_view_a->set_visible_bases(top_sel_start, top_sel_end); |
|---|
| 157 |
line_view_b->set_visible_bases(top_sel_start, top_sel_end); |
|---|
| 158 |
new_view->get_top_seq_view()->set_visible_bases(top_sel_start, |
|---|
| 159 |
top_sel_end); |
|---|
| 160 |
|
|---|
| 161 |
new_view->get_bot_seq_view()->set_visible_bases(bot_sel_start, bot_sel_end); |
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
|
|---|
| 167 |
const gui::FeatureList * l = map->get_features_container()->getFeatureList(); |
|---|
| 168 |
const gui::Feature * f = NULL; |
|---|
| 169 |
for (unsigned int i = 0; i < l->n_features(); i++) { |
|---|
| 170 |
f = l->get(i); |
|---|
| 171 |
if (f->has_alignment() && |
|---|
| 172 |
f->end > top_sel_start && |
|---|
| 173 |
f->start < top_sel_end) { |
|---|
| 174 |
break; |
|---|
| 175 |
} |
|---|
| 176 |
} |
|---|
| 177 |
|
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 |
if (f) { |
|---|
| 181 |
line_view_b->select_feature(f); |
|---|
| 182 |
} |
|---|
| 183 |
|
|---|
| 184 |
|
|---|
| 185 |
|
|---|
| 186 |
|
|---|
| 187 |
|
|---|
| 188 |
resizable(this); |
|---|
| 189 |
end(); |
|---|
| 190 |
} |
|---|
| 191 |
|
|---|
| 192 |
AlignmentCloseupView::~AlignmentCloseupView() |
|---|
| 193 |
{ |
|---|
| 194 |
|
|---|
| 195 |
|
|---|
| 196 |
|
|---|
| 197 |
|
|---|
| 198 |
|
|---|
| 199 |
|
|---|
| 200 |
|
|---|
| 201 |
} |
|---|
| 202 |
|
|---|
| 203 |
void AlignmentCloseupView::change_viewed_feature(const gui::Feature * f) |
|---|
| 204 |
{ |
|---|
| 205 |
aln_view->change_feature(f); |
|---|
| 206 |
((_HighlightedFeatureList *) hilite)->select_feature(f); |
|---|
| 207 |
|
|---|
| 208 |
gui::Feature * new_f = f->copy_me(); |
|---|
| 209 |
gui::Feature * old_f = (gui::Feature *) view_info->user_data(); |
|---|
| 210 |
if (old_f) { delete old_f; } |
|---|
| 211 |
|
|---|
| 212 |
if (f->has_info()) { |
|---|
| 213 |
view_info->label("View info..."); |
|---|
| 214 |
view_info->user_data(new_f); |
|---|
| 215 |
} else { |
|---|
| 216 |
view_info->label("no info"); |
|---|
| 217 |
view_info->user_data(NULL); |
|---|
| 218 |
} |
|---|
| 219 |
redraw(); |
|---|
| 220 |
} |
|---|