bf1afb3a2ef5fdec116493ef96cfdd4ee8c0235f
[mussa.git] / mussa_gui_seq.cc
1 #include "mussa_gui_seq.hh"
2
3
4 void
5 SeqView::setup(string name, int sq_num, int win_len, 
6                vector<Sequence> *some_seqs,
7                Nway_Paths *some_paths, vector<int> some_lens)
8 {
9   ana_name = name;
10   seq_num = sq_num;
11   base_window_len = win_len;
12   S = some_seqs;
13   P = some_paths;
14   seq_lens = some_lens;
15
16   y_seq_incre = (y_max-10) / (seq_num - 1);
17
18   fl_font(FL_COURIER, 14);
19   cout << fl_width('A') << endl;
20 }
21
22
23 void
24 SeqView::draw()
25 {
26   int seq_i;
27   Sequence a_seq;
28   int i, y_loc;
29   vector<int> a_path;
30   list<vector<int> >::iterator pathz_i;
31   int i2;
32   int x_start, y_start, x_end, y_end;
33   double ch_width;
34   int window_length, win_i;
35   int rc_1 = 0; 
36   int rc_2 = 0;
37
38
39   window_length = base_window_len;
40   fl_font(FL_COURIER, 14);
41   fl_color(FL_BLACK);
42   //blatantly stolen from FR2
43   ch_width = fl_width('A');     // monospaced: all characters are same width
44
45   y_loc = 10;
46   for(seq_i = seq_num-1; seq_i >= 0; --seq_i)
47   {
48     //a_seq = a_seq;
49     fl_draw((*S)[seq_i].c_seq(), 0+x(), y_loc+y()); 
50     y_loc += y_seq_incre;
51   }
52
53   fl_color(FL_RED);
54   fl_line_style(FL_SOLID, 1, NULL);
55   //fl_line(x(),10+y(),20+x(),y_max/2 + y());
56
57       //fl_color(FL_RED);
58
59
60   for(pathz_i = P->pathz.begin(); pathz_i != P->pathz.end(); ++pathz_i)
61   {
62     a_path = *pathz_i;
63     y_loc = 0;
64     for(i2 = seq_num - 1; i2 > 0; i2--)
65     {
66       // RC case handling
67
68       // ugh, and xor...only want black if one of the nodes is rc
69       if ( ((a_path[i2] < 0) || (a_path[i2-1] < 0)) &&
70            !((a_path[i2] < 0) && (a_path[i2-1] < 0)) )
71         fl_color(FL_BLUE);
72
73       // no matter the case, any RC node needs an offset
74       if (a_path[i2] < 0)
75         rc_1 = window_length;        
76       if (a_path[i2-1] < 0)
77         rc_2 = window_length;        
78       // normal case
79       for(win_i = 0; win_i < window_length; win_i++)
80         fl_line(abs((int)((a_path[i2]-rc_1+win_i+x()+0.5)*ch_width)),
81                 y_loc + 10+y(),
82                 abs((int)((a_path[i2-1]-rc_2+win_i+x()+0.5)*ch_width)),
83                 y_loc+y_seq_incre+y());
84       y_loc += y_seq_incre;
85       //if ((a_path[i2] < 0) || (a_path[i2-1] < 0))
86       //{
87         fl_color(FL_RED);
88         rc_1 = 0;
89         rc_2 = 0;
90         //}
91     }
92   }
93 }
94 /*
95       x_start = (int) ();
96       y_start = ;
97       x_end = (int) ();
98       y_end = ;
99       x_start,y_start,x_end,y_end
100 */
101
102
103 /*
104       if ((a_path[i2] >= 0) && (a_path[i2-1] >= 0))
105       {
106       }
107       else if ((a_path[i2] < 0) && (a_path[i2-1] < 0)) 
108       {
109         for(win_i = 0; win_i < window_length; win_i++)
110           fl_line(abs((int)((a_path[i2]+window_length+win_i+x())*ch_width)),
111                   y_loc + 10+y(),
112                   abs((int)((a_path[i2-1]+window_length+win_i+x())*ch_width)),
113                   y_loc+y_seq_incre+y());
114         
115       }
116       else 
117       {
118         fl_color(FL_BLACK);
119         for(win_i = 0; win_i < window_length; win_i++)
120           fl_line(abs((int)((a_path[i2]+window_length+win_i+x())*ch_width)),
121                   y_loc + 10+y(),
122                   abs((int)((a_path[i2-1]+win_i+x())*ch_width)),
123                   y_loc+y_seq_incre+y());
124         fl_color(FL_RED);
125       }
126       else //
127       {
128         fl_color(FL_BLACK);
129         for(win_i = 0; win_i < window_length; win_i++)
130           fl_line(abs((int)((a_path[i2]+win_i+x())*ch_width)),
131                   y_loc + 10+y(),
132                   abs((int)((a_path[i2-1]+window_length+win_i+x())*ch_width)),
133                   y_loc+y_seq_incre+y());
134         fl_color(FL_RED);
135       }
136 */