75a757a59c43baefa422c3f14b5244ed9af40399
[mussa.git] / mussa_gui_conn.cc
1 #include "mussa_gui_conn.hh"
2
3
4
5 void
6 ConnView::setup(string name, int sq_num, int win_len,
7                 vector<Sequence> *some_seqs,
8                 Nway_Paths *some_paths)
9 {
10   int i;
11   Sequence a_seq;
12
13   ana_name = name;
14   seq_num = sq_num;
15   window = win_len;
16   S = some_seqs;
17   P = some_paths;
18
19   for(i = 0; i < seq_num; ++i)
20   {
21     a_seq = (*S)[i];
22     seq_lens.push_back(a_seq.len());
23   }
24
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);
28 }
29
30
31 void
32 ConnView::scale_paths()
33 {
34   vector<int> a_path;
35   list<vector<int> >::iterator pathz_i;
36   int i2;
37
38
39   scaled_pathz.clear();
40
41   for(pathz_i = P->pathz.begin(); pathz_i != P->pathz.end(); ++pathz_i)
42   {
43     a_path = *pathz_i;
44     for(i2 = 0; i2 < seq_num; i2++)
45       a_path[i2] = (int) (a_path[i2] / x_scale_factor);
46     scaled_pathz.push_back(a_path);
47   }
48 }
49
50
51
52
53 void
54 ConnView::draw()
55 {
56   list<vector<int> >::iterator i;
57   int i2, y_loc, x_loc;
58   vector<int> a_path;
59
60   fl_color(FL_RED);
61   fl_line_style(FL_SOLID, 1, NULL);
62
63   for(i = scaled_pathz.begin(); i != scaled_pathz.end(); ++i)
64   {
65     a_path = *i;
66     y_loc = 10;
67     for(i2 = seq_num - 1; i2 > 0; i2--)
68     {
69       // RC case handling
70       // ugh, and xor...only want blue if one of the nodes is rc
71       if ( ((a_path[i2] < 0) || (a_path[i2-1] < 0)) &&
72            !((a_path[i2] < 0) && (a_path[i2-1] < 0)) )
73         fl_color(FL_BLUE);
74
75       fl_line((int)abs(a_path[i2]),y_loc,(int)abs(a_path[i2-1]),y_loc + y_seq_incre);
76       y_loc += y_seq_incre;
77       fl_color(FL_RED);
78     }
79   }
80
81   fl_color(FL_BLACK);
82   fl_line_style(FL_SOLID, 3, NULL);
83   y_loc = 10;
84   for(i2 = seq_num - 1; i2 >= 0; i2--)
85   {
86     x_loc = (int)(seq_lens[i2] / x_scale_factor);
87     fl_line(0,y_loc,x_loc,y_loc);
88     y_loc += y_seq_incre;
89   }
90 }
91
92 void
93 ConnView::spawnSeq()
94 {
95   int seq_box_x;
96
97   Fl_Window *seq_window = new Fl_Window(x_max, y_max, "Mussa Sequence");
98   Fl_Scroll *scroll_seq = new Fl_Scroll(0, 0, x_max, y_max);
99
100   seq_box_x = 32000; 
101     //seq_lens[0]*14;
102   SeqView *seq_box = new SeqView(0, 0, seq_box_x, y_max-20);
103   seq_box->setup(ana_name, seq_num, window, S, P, seq_lens);
104
105   seq_window->end();
106   seq_window->show();
107 }