| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
#include <iostream> |
|---|
| 21 |
#include <FL/Fl.H> |
|---|
| 22 |
#include <FL/fl_draw.H> |
|---|
| 23 |
|
|---|
| 24 |
#include "_PairMapCanvas.hh" |
|---|
| 25 |
|
|---|
| 26 |
using namespace gui; |
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
void _PairMapCanvas::recompute() |
|---|
| 33 |
{ |
|---|
| 34 |
_top_scale = (float) _top_w / (float) (_top_end - _top_start); |
|---|
| 35 |
_bot_scale = (float) _bot_w / (float) (_bot_end - _bot_start); |
|---|
| 36 |
} |
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
void _PairMapCanvas::draw_feature(int top_pos, int bot_pos, |
|---|
| 43 |
unsigned int width, int orientation) |
|---|
| 44 |
{ |
|---|
| 45 |
for (unsigned int i = 0; i < width; i++) { |
|---|
| 46 |
top_pos++; |
|---|
| 47 |
bot_pos += orientation; |
|---|
| 48 |
|
|---|
| 49 |
draw_feature(top_pos, bot_pos); |
|---|
| 50 |
} |
|---|
| 51 |
#if 0 |
|---|
| 52 |
top_pos -= _top_start; |
|---|
| 53 |
if (top_pos < 0) top_pos = 0; |
|---|
| 54 |
bot_pos -= _bot_start; |
|---|
| 55 |
if (bot_pos < 0) bot_pos = 0; |
|---|
| 56 |
|
|---|
| 57 |
int top_pixel, bot_pixel; |
|---|
| 58 |
|
|---|
| 59 |
float top_pixel_width = _top_scale * width; |
|---|
| 60 |
float bot_pixel_width = _bot_scale * width; |
|---|
| 61 |
float max_pixel_width = top_pixel_width > bot_pixel_width ? top_pixel_width : |
|---|
| 62 |
bot_pixel_width; |
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
float top_step = top_pixel_width / max_pixel_width; |
|---|
| 66 |
float bot_step = bot_pixel_width / max_pixel_width; |
|---|
| 67 |
|
|---|
| 68 |
int top_pixel_start = (int) (_top_scale * top_pos + .5) + _top_x; |
|---|
| 69 |
int bot_pixel_start = (int) (_bot_scale * bot_pos + .5) + _bot_x; |
|---|
| 70 |
|
|---|
| 71 |
float top = 0; |
|---|
| 72 |
float bot = 0; |
|---|
| 73 |
while (top < max_pixel_width || bot < max_pixel_width) { |
|---|
| 74 |
top_pixel = (int) (top_pixel_start + top); |
|---|
| 75 |
bot_pixel = (int) (bot_pixel_start + bot * orientation); |
|---|
| 76 |
|
|---|
| 77 |
fl_line(top_pixel, _top_y, bot_pixel, _bot_y); |
|---|
| 78 |
|
|---|
| 79 |
top += top_step; |
|---|
| 80 |
bot += bot_step; |
|---|
| 81 |
} |
|---|
| 82 |
#endif |
|---|
| 83 |
} |
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
void _PairMapCanvas::draw_feature(int top_pos, int bot_pos) |
|---|
| 90 |
{ |
|---|
| 91 |
if (top_pos < _top_start || top_pos > _top_end || |
|---|
| 92 |
bot_pos < _bot_start || bot_pos > _bot_end) { |
|---|
| 93 |
return; |
|---|
| 94 |
} |
|---|
| 95 |
|
|---|
| 96 |
top_pos -= _top_start; |
|---|
| 97 |
bot_pos -= _bot_start; |
|---|
| 98 |
|
|---|
| 99 |
int top_pixel = (int) (_top_scale * top_pos + .5) + _top_x; |
|---|
| 100 |
int bot_pixel = (int) (_bot_scale * bot_pos + .5) + _bot_x; |
|---|
| 101 |
|
|---|
| 102 |
fl_line(top_pixel, _top_y, bot_pixel, _bot_y); |
|---|
| 103 |
} |
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
void _PairMapCanvas::set_top_canvas_coords(int x_start, int width, int y) |
|---|
| 111 |
{ |
|---|
| 112 |
_top_x = x_start; |
|---|
| 113 |
_top_w = width; |
|---|
| 114 |
_top_y = y; |
|---|
| 115 |
|
|---|
| 116 |
recompute(); |
|---|
| 117 |
} |
|---|
| 118 |
|
|---|
| 119 |
void _PairMapCanvas::set_bot_canvas_coords(int x_start, int width, int y) |
|---|
| 120 |
{ |
|---|
| 121 |
_bot_x = x_start; |
|---|
| 122 |
_bot_w = width; |
|---|
| 123 |
_bot_y = y; |
|---|
| 124 |
|
|---|
| 125 |
recompute(); |
|---|
| 126 |
} |
|---|
| 127 |
|
|---|
| 128 |
void _PairMapCanvas::push_clip() |
|---|
| 129 |
{ |
|---|
| 130 |
int min_x, max_width; |
|---|
| 131 |
if (_top_x < _bot_x) { |
|---|
| 132 |
min_x = _top_x; |
|---|
| 133 |
max_width = _top_w; |
|---|
| 134 |
} else { |
|---|
| 135 |
min_x = _bot_x; |
|---|
| 136 |
max_width = _bot_w; |
|---|
| 137 |
} |
|---|
| 138 |
fl_push_clip(min_x, _top_y, max_width, _bot_y - _top_y); |
|---|
| 139 |
} |
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
void _PairMapCanvas::set_top_sequence_coords(int start, int end) |
|---|
| 147 |
{ |
|---|
| 148 |
_top_start = start; |
|---|
| 149 |
_top_end = end; |
|---|
| 150 |
|
|---|
| 151 |
recompute(); |
|---|
| 152 |
} |
|---|
| 153 |
|
|---|
| 154 |
void _PairMapCanvas::set_bot_sequence_coords(int start, int end) |
|---|
| 155 |
{ |
|---|
| 156 |
_bot_start = start; |
|---|
| 157 |
_bot_end = end; |
|---|
| 158 |
|
|---|
| 159 |
recompute(); |
|---|
| 160 |
} |
|---|