075302c2981767cd19c2ede569c9f867bcf8dcad
[mussa.git] / mussa_gui_seq.cc
1 #include "mussa_gui_seq.hh"
2 #include <sstream>
3
4
5 void
6 set_align_cb(Fl_Widget* widg, void* the_data)
7 {
8   menu_align_data_bundle * blah = (menu_align_data_bundle *) the_data;
9   SeqWindow* T= blah->swm_ptr;
10   T->real_set_align_cb(blah->which_align);
11 }
12
13
14 void
15 SeqWindow::real_set_align_cb(int which_align)
16 {
17   vector<int> a_path;
18   int window_length;
19
20
21   a_path = *P.begin();
22   window_length = a_path[0];
23   cout << window_length << endl;
24
25   cout << "fum1\n";    
26   seq_box->align_offsets(which_align);
27   seq_box->redraw();
28 }
29
30
31 void
32 show_align_cb(Fl_Widget* widg, void* the_data)
33 {
34   menu_align_data_bundle * blah = (menu_align_data_bundle *) the_data;
35   SeqWindow* T= blah->swm_ptr;
36   T->real_show_align_cb(blah->which_align);
37 }
38
39
40 void
41 SeqWindow::real_show_align_cb(int which_align)
42 {
43   vector<int> a_path;
44   int window_length;
45
46
47   cout << "fumish\n";    
48   seq_box->toggle_align(which_align);
49   seq_box->redraw();
50 }
51
52
53 void
54 toggle_bars_cb(Fl_Button* o, void* v)
55 {
56   SeqWindow* T=(SeqWindow*)v;
57   T->real_toggle_bars_cb();
58 }
59
60
61 void
62 SeqWindow::real_toggle_bars_cb()
63 {
64   seq_box->toggle_bars();
65 }
66
67
68 void
69 toggle_motifs_cb(Fl_Button* o, void* v)
70 {
71   SeqWindow* T=(SeqWindow*)v;
72   T->real_toggle_motifs_cb();
73 }
74
75
76 void
77 SeqWindow::real_toggle_motifs_cb()
78 {
79   seq_box->toggle_motifs();
80 }
81
82
83 // main code, window creation
84
85 SeqWindow::SeqWindow(int w, int h, const char* title, int sq_num,
86                      vector<Sequence> *some_seqs, 
87                      list<vector<int> > some_paths, 
88                      vector<int> some_lens,
89                      vector<motif> *some_motifs):
90   Fl_Double_Window(w,h,title)
91 {
92   menu_align_data_bundle * some_menu_data;
93   vector<int> a_path;
94   int window_length, align_number;
95   int i;
96   ostringstream align_id_ostr;
97   string align_id_string;
98   list<vector<int> >::iterator align_iter;
99
100
101
102   // most of this stuff is here just to pass to SeqView object
103   // some is needed to setup the window menus
104   seq_num = sq_num;
105   S = some_seqs;
106   P = some_paths;
107   seq_lens = some_lens;
108   the_motifs = some_motifs;
109
110
111   begin();
112   color(FL_WHITE);
113   resizable(this);
114
115   // make the menu that allows alignment selection
116   choose_align_menu = new Fl_Menu_Button(5, 2, 180, 30, "Choose Alignment");
117   choose_align_menu->color(FL_WHITE,FL_BLUE);
118   choose_align_menu->box(FL_BORDER_BOX);
119   choose_align_menu->clear();
120   
121   // make the menu that allows alignment selection
122   show_align_menu = new Fl_Menu_Button(190, 2, 180, 30, "Show Alignment");
123   show_align_menu->color(FL_WHITE,FL_BLUE);
124   show_align_menu->box(FL_BORDER_BOX);
125   show_align_menu->clear();
126
127
128   // adds menu items for each path
129   align_iter = P.begin();
130   align_number = 0;
131   while(align_iter != P.end())
132   {
133     some_menu_data = new menu_align_data_bundle;
134     some_menu_data->swm_ptr = this;
135     some_menu_data->which_align = align_number;
136     align_id_ostr << (*align_iter)[0] << ": ";
137     for(i = 1; i <= seq_num; i++)
138       align_id_ostr << (*align_iter)[i] << ", ";
139     align_id_string = align_id_ostr.str();
140     choose_align_menu->add((const char*)align_id_string.c_str(), 0, 
141                            (Fl_Callback *) set_align_cb, 
142                            (void*) some_menu_data);
143     show_align_menu->add((const char*)align_id_string.c_str(), 0, 
144                          (Fl_Callback *) show_align_cb, 
145                          (void*) some_menu_data, FL_MENU_TOGGLE|FL_MENU_VALUE);
146
147     align_id_ostr.str("");
148     ++align_number;
149     ++align_iter;
150   }
151
152   /*
153   show_align_menu->add("f&ee"); 
154   show_align_menu->add("f&ie"); 
155   show_align_menu->add("f&oe"); 
156   show_align_menu->add("f&um"); 
157   */
158
159   Fl_Button *test_but = new Fl_Button(375, 2, 150, 30, "Toggle Motifs");
160   test_but->color(FL_WHITE,FL_BLUE);
161   test_but->box(FL_BORDER_BOX);
162   test_but->callback((Fl_Callback*) toggle_motifs_cb, this);
163
164   toggle_bars = new Fl_Button(530, 2, 150, 30, "Toggle 10bp bars");
165   toggle_bars->color(FL_WHITE,FL_BLUE);
166   toggle_bars->box(FL_BORDER_BOX);
167   toggle_bars->callback((Fl_Callback*) toggle_bars_cb, this);
168  
169
170   // make the view of the sequence
171   seq_box = new SeqView(0, 34, w, h-34);
172   seq_box->setup(ana_name, seq_num, S, P, seq_lens, the_motifs);
173   //real_set_align_cb(2);
174
175   end();
176   Fl::visual(FL_DOUBLE|FL_INDEX);
177   show();
178 }
179
180
181
182 /*
183   some_menu_data = new menu_align_data_bundle;
184   some_menu_data->swm_ptr = this;
185   some_menu_data->which_align = 2;
186   choose_align_menu->add("f&ie", FL_ALT+'i', (Fl_Callback *) set_align_cb,
187                   (void*) some_menu_data);
188
189   some_menu_data = new menu_align_data_bundle;
190   some_menu_data->swm_ptr = this;
191   some_menu_data->which_align = 3;
192   choose_align_menu->add("f&oe", FL_ALT+'o', (Fl_Callback *) set_align_cb,
193                   (void*) some_menu_data);
194
195   some_menu_data = new menu_align_data_bundle;
196   some_menu_data->swm_ptr = this;
197   some_menu_data->which_align = 4;
198   choose_align_menu->add("f&um", FL_ALT+'u', (Fl_Callback *) set_align_cb,
199                   (void*) some_menu_data);
200 */
201
202
203
204