1 #include "mussa_gui_conn.hh"
6 ConnView::setup(string name, int sq_num, int win_len,
7 vector<Sequence> *some_seqs,
8 Nway_Paths *some_paths)
19 for(i = 0; i < seq_num; ++i)
22 seq_lens.push_back(a_seq.len());
25 x_scale_factor = (float) seq_lens[0] / x_max;
26 cout << "scale factor is " << x_scale_factor << endl;
27 y_seq_incre = (y_max-20) / (seq_num - 1);
37 ConnView::scale_paths()
40 list<vector<int> >::iterator pathz_i;
46 for(pathz_i = P->refined_pathz.begin(); pathz_i != P->refined_pathz.end(); ++pathz_i)
49 for(i2 = 0; i2 <= seq_num; i2++)
50 a_path[i2] = (int) (a_path[i2] / x_scale_factor);
51 scaled_pathz.push_back(a_path);
61 list<vector<int> >::iterator i;
62 int i2, i3, y_loc, x_loc, x_start, x_end;
64 list<annot>::iterator annot_i;
67 int path_start, path_end;
68 list<bool>::iterator highlight_i;
71 // clear drawing area and set background to white
73 fl_rectf(x(), y(), w(), h());
75 // determine which paths to highlight
77 for(i = scaled_pathz.begin(); i != scaled_pathz.end(); ++i)
80 // determine if path falls within the selected region and mark it for
82 path_start = abs(a_path[1]);
83 path_end = path_start + a_path[0];
84 if ( ( (path_start >= drag_start) && (path_end <= drag_end) ) ||
85 ( (path_start < drag_start) && (path_end > drag_end) ) ||
86 ( (path_start < drag_start) && (path_end > drag_start) ) ||
87 ( (path_start < drag_end) && (path_end > drag_end) ) )
88 highlight.push_back(true);
90 highlight.push_back(false);
93 fl_line_style(FL_SOLID, 1, NULL);
94 // draw non-highlight paths (ie not in the selection box)
95 highlight_i = highlight.begin();
96 for(i = scaled_pathz.begin(); i != scaled_pathz.end(); ++i)
101 // get window size to determine line width
102 window_size = a_path[0];
103 // make sure width is at least 1 - might be zero to my slack rounding
104 if (window_size == 0)
108 for(i2 = seq_num; i2 > 1; i2--)
111 // ugh, an xor...only want blue if one of the nodes is rc
112 if ( ((a_path[i2] < 0) || (a_path[i2-1] < 0)) &&
113 !((a_path[i2] < 0) && (a_path[i2-1] < 0)) )
116 fl_color(FL_MAGENTA);
118 fl_polygon((int)abs(a_path[i2]), y_loc + 3,
119 (int)abs(a_path[i2])+window_size, y_loc + 3,
120 (int)abs(a_path[i2-1])+window_size, y_loc + y_seq_incre - 3,
121 (int)abs(a_path[i2-1]), y_loc + y_seq_incre - 3);
123 y_loc += y_seq_incre;
128 // draw highlighted paths (ie in or partially in selection)
129 // drawing these separately and after other paths so they are on top
130 highlight_i = highlight.begin();
131 for(i = scaled_pathz.begin(); i != scaled_pathz.end(); ++i)
136 // get window size to determine line width
137 window_size = a_path[0];
138 // make sure width is at least 1 - might be zero to my slack rounding
139 if (window_size == 0)
143 for(i2 = seq_num; i2 > 1; i2--)
146 // ugh, an xor...only want blue if one of the nodes is rc
147 if ( ((a_path[i2] < 0) || (a_path[i2-1] < 0)) &&
148 !((a_path[i2] < 0) && (a_path[i2-1] < 0)) )
153 fl_polygon((int)abs(a_path[i2]), y_loc + 3,
154 (int)abs(a_path[i2])+window_size, y_loc + 3,
155 (int)abs(a_path[i2-1])+window_size, y_loc + y_seq_incre - 3,
156 (int)abs(a_path[i2-1]), y_loc + y_seq_incre - 3);
158 y_loc += y_seq_incre;
163 // draw sequence representation lines
165 fl_line_style(FL_SOLID, 3, NULL);
167 for(i2 = seq_num - 1; i2 >= 0; i2--)
169 x_loc = (int)(seq_lens[i2] / x_scale_factor);
170 fl_line(0,y_loc,x_loc,y_loc);
171 y_loc += y_seq_incre;
176 fl_line_style(FL_SOLID, 9, NULL);
178 for(i2 = seq_num - 1; i2 >= 0; i2--)
180 for(annot_i = (*S)[i2].annots.begin(); annot_i != (*S)[i2].annots.end(); ++annot_i)
182 x_start = (int)(annot_i->start / x_scale_factor);
183 x_end = (int)(annot_i->end / x_scale_factor);
184 fl_line(x_start,y_loc,x_end,y_loc);
186 y_loc += y_seq_incre;
189 // draw selection box
193 fl_line_style(FL_SOLID, 2, NULL);
194 fl_rect(drag_start, y_loc - y_seq_incre-8, drag_end-drag_start, 16);
201 ConnView::handle(int e)
208 if (Fl::event_button3())
217 drag_start = Fl::event_x() -x();
223 fl_line_style(FL_SOLID, 1, NULL);
224 fl_overlay_rect(drag_start, y_seq_incre*(seq_num-1), Fl::event_x()-drag_start, 16);
230 drag_end = Fl::event_x() - x();
238 return_value = Fl_Widget::handle(e);
248 list<vector<int> > selected_paths;
249 list<vector<int> >::iterator pathz_i;
250 int i2, i3, y_loc, x_loc, x_start, x_end;
252 list<bool>::iterator highlight_i;
254 // make new list of connections that are highlighted
255 selected_paths.clear();
256 highlight_i = highlight.begin();
257 for(pathz_i = P->refined_pathz.begin(); pathz_i != P->refined_pathz.end(); ++pathz_i)
262 selected_paths.push_back(a_path);
274 Fl_Window *seq_window = new Fl_Window(x_max, y_max, "Mussa Sequence");
277 SeqView *seq_box = new SeqView(0, 0, x_max, y_max);
278 seq_box->setup(ana_name, seq_num, S, selected_paths, seq_lens);
279 seq_box->debug_draw();