1 | #ifndef ED4_CLASS_HXX |
---|
2 | #define ED4_CLASS_HXX |
---|
3 | |
---|
4 | #ifndef AW_FONT_GROUP_HXX |
---|
5 | #include <aw_font_group.hxx> |
---|
6 | #endif |
---|
7 | #ifndef POS_RANGE_H |
---|
8 | #include <pos_range.h> |
---|
9 | #endif |
---|
10 | |
---|
11 | #define e4_assert(bed) arb_assert(bed) |
---|
12 | |
---|
13 | #define concat(a,b) a##b |
---|
14 | |
---|
15 | #ifdef DEBUG |
---|
16 | # define IMPLEMENT_DUMP // comment out this line to skip compilation of the dump() methods |
---|
17 | #endif |
---|
18 | |
---|
19 | #ifndef ARB_ERROR_H |
---|
20 | #include <arb_error.h> |
---|
21 | #endif |
---|
22 | #ifndef ED4_DEFS_HXX |
---|
23 | #include "ed4_defs.hxx" |
---|
24 | #endif |
---|
25 | #ifndef ED4_SEARCH_HXX |
---|
26 | #include "ed4_search.hxx" |
---|
27 | #endif |
---|
28 | #ifndef _GLIBCXX_LIST |
---|
29 | #include <list> |
---|
30 | #endif |
---|
31 | #ifndef ATTRIBUTES_H |
---|
32 | #include <attributes.h> |
---|
33 | #endif |
---|
34 | #ifndef BI_BASEPOS_HXX |
---|
35 | #include <BI_basepos.hxx> |
---|
36 | #endif |
---|
37 | #ifndef DOWNCAST_H |
---|
38 | #include <downcast.h> |
---|
39 | #endif |
---|
40 | #ifndef CHARTABLE_H |
---|
41 | #include "chartable.h" |
---|
42 | #endif |
---|
43 | |
---|
44 | #if defined(IMPLEMENT_DUMP) // ------------------------------ |
---|
45 | |
---|
46 | #if 0 |
---|
47 | #define WARN(msg) void dummy_to_produce_a_warning(int msg) {} |
---|
48 | #else |
---|
49 | #define WARN(msg) |
---|
50 | #endif |
---|
51 | |
---|
52 | #define EMPTY_FUNCTION(name) void name() const {} |
---|
53 | #define EMPTY_FUNCTION_VERBOSE(name) void name(int je_mappelle_##name) const {} |
---|
54 | |
---|
55 | #define DERIVABLEFROM(base) concat(prohibited_leafclass_derivation,base) |
---|
56 | |
---|
57 | #define COMMON_FOR_BASES() \ |
---|
58 | virtual void dump(size_t indent) const = 0; \ |
---|
59 | |
---|
60 | #define COMMON_FOR_DERIVABLE(self) \ |
---|
61 | void dump_base(size_t indent) const; \ |
---|
62 | EMPTY_FUNCTION(DERIVABLEFROM(self)); \ |
---|
63 | |
---|
64 | #define COMMON_FOR_DERIVED(mybase) \ |
---|
65 | void dump_my_base(size_t indent) const { mybase::dump_base(indent); } \ |
---|
66 | virtual const char *baseclassname() const { return #mybase; } \ |
---|
67 | |
---|
68 | #define COMMON_FOR_INSTANCIABLE(mybase) \ |
---|
69 | void dump(size_t indent) const OVERRIDE; \ |
---|
70 | |
---|
71 | #define DECLARE_DUMP_FOR_ROOTCLASS(self) \ |
---|
72 | COMMON_FOR_BASES(); \ |
---|
73 | COMMON_FOR_DERIVABLE(self); \ |
---|
74 | |
---|
75 | #define DECLARE_DUMP_FOR_BASECLASS(self,mybase) \ |
---|
76 | COMMON_FOR_BASES(); \ |
---|
77 | COMMON_FOR_DERIVABLE(self); \ |
---|
78 | COMMON_FOR_DERIVED(mybase); \ |
---|
79 | |
---|
80 | #define DECLARE_DUMP_FOR_MIDCLASS(self,mybase) \ |
---|
81 | WARN(midclass_is_unwanted); \ |
---|
82 | COMMON_FOR_DERIVABLE(self); \ |
---|
83 | COMMON_FOR_DERIVED(mybase); \ |
---|
84 | COMMON_FOR_INSTANCIABLE(mybase); \ |
---|
85 | |
---|
86 | #define DECLARE_DUMP_FOR_LEAFCLASS(mybase) \ |
---|
87 | virtual void leaf() { DERIVABLEFROM(mybase)(); } \ |
---|
88 | COMMON_FOR_DERIVED(mybase); \ |
---|
89 | COMMON_FOR_INSTANCIABLE(mybase); \ |
---|
90 | |
---|
91 | #else |
---|
92 | #define DECLARE_DUMP_FOR_ROOTCLASS(self) |
---|
93 | #define DECLARE_DUMP_FOR_BASECLASS(self,mybase) |
---|
94 | #define DECLARE_DUMP_FOR_MIDCLASS(self,mybase) |
---|
95 | #define DECLARE_DUMP_FOR_LEAFCLASS(mybase) |
---|
96 | |
---|
97 | #endif // IMPLEMENT_DUMP ------------------------------ |
---|
98 | |
---|
99 | |
---|
100 | |
---|
101 | // #define LIMIT_TOP_AREA_SPACE // if defined, top area is size-limited |
---|
102 | #ifdef LIMIT_TOP_AREA_SPACE |
---|
103 | #define MAX_TOP_AREA_SIZE 10 // size limit for top-area |
---|
104 | #endif |
---|
105 | |
---|
106 | #define ed4_beep() do { fputc(char(7), stdout); fflush(stdout); } while (0) |
---|
107 | |
---|
108 | enum PositionType { |
---|
109 | ED4_POS_SEQUENCE, |
---|
110 | ED4_POS_ECOLI, |
---|
111 | ED4_POS_BASE, |
---|
112 | }; |
---|
113 | |
---|
114 | // **************************************** |
---|
115 | // needed prototypes, definitions below |
---|
116 | // **************************************** |
---|
117 | |
---|
118 | class ED4_area_manager; |
---|
119 | class ED4_abstract_group_manager; |
---|
120 | class ED4_base; |
---|
121 | class ED4_bracket_terminal; |
---|
122 | class BaseFrequencies; |
---|
123 | class ED4_columnStat_terminal; |
---|
124 | class ED4_consensus_sequence_terminal; |
---|
125 | class ED4_cursor; |
---|
126 | class ED4_device_manager; |
---|
127 | class ED4_folding_line; |
---|
128 | class ED4_group_manager; |
---|
129 | class ED4_line_terminal; |
---|
130 | class ED4_main_manager; |
---|
131 | class ED4_manager; |
---|
132 | class ED4_multi_name_manager; |
---|
133 | class ED4_multi_sequence_manager; |
---|
134 | class ED4_multi_species_manager; |
---|
135 | class ED4_name_manager; |
---|
136 | class ED4_pure_text_terminal; |
---|
137 | class ED4_reference_terminals; |
---|
138 | class ED4_remap; |
---|
139 | class ED4_root; |
---|
140 | class ED4_root_group_manager; |
---|
141 | class ED4_sequence_info_terminal; |
---|
142 | class ED4_sequence_manager; |
---|
143 | class ED4_sequence_terminal; |
---|
144 | class ED4_orf_terminal; |
---|
145 | class ED4_spacer_terminal; |
---|
146 | class ED4_species_manager; |
---|
147 | class ED4_species_name_terminal; |
---|
148 | class ED4_species_pointer; |
---|
149 | class ED4_terminal; |
---|
150 | class ED4_text_terminal; |
---|
151 | class ED4_tree_terminal; |
---|
152 | class ED4_flag_header_terminal; |
---|
153 | class ED4_flag_terminal; |
---|
154 | class ED4_window; |
---|
155 | |
---|
156 | class AP_tree; |
---|
157 | class ED4_reference; |
---|
158 | class ED4_seq_colors; |
---|
159 | class BI_ecoli_ref; |
---|
160 | class AW_helix; |
---|
161 | class arb_progress; |
---|
162 | class ST_ML; |
---|
163 | class ed_key; |
---|
164 | class ConsensusBuildParams; |
---|
165 | |
---|
166 | template <class T> class ED4_list; // derived from Noncopyable |
---|
167 | template <class T> class ED4_list_elem; // derived from Noncopyable |
---|
168 | |
---|
169 | typedef ED4_list<ED4_base> ED4_base_list; |
---|
170 | typedef ED4_list_elem<ED4_base> ED4_base_list_elem; |
---|
171 | |
---|
172 | typedef ED4_list<ED4_selection_entry> ED4_selected_list; |
---|
173 | typedef ED4_list_elem<ED4_selection_entry> ED4_selected_elem; |
---|
174 | |
---|
175 | |
---|
176 | namespace EDB_root_bact { |
---|
177 | void calc_no_of_all(const char *string_to_scan, // group gets the number of groups in string_to_scan, |
---|
178 | long *group, // species gets the number of species in string_to_scan |
---|
179 | long *species); |
---|
180 | |
---|
181 | ED4_returncode fill_species(ED4_multi_species_manager *multi_species_manager, |
---|
182 | ED4_reference_terminals& refterms, |
---|
183 | const char *str, |
---|
184 | int *index, |
---|
185 | int group_depth, |
---|
186 | arb_progress *progress); |
---|
187 | |
---|
188 | ED4_returncode fill_data(ED4_multi_species_manager *multi_species_manager, |
---|
189 | ED4_reference_terminals& refterms, |
---|
190 | char *str, |
---|
191 | int group_depth, |
---|
192 | ED4_datamode datamode); // flag only needed for loading a new configuration |
---|
193 | |
---|
194 | ED4_returncode search_sequence_data_rek(ED4_multi_sequence_manager *multi_sequence_manager, |
---|
195 | ED4_reference_terminals& refterms, |
---|
196 | GBDATA *gb_ali_xxx, // alignment-container (or any subcontainer of) |
---|
197 | int count_too, |
---|
198 | ED4_index *max_sequence_terminal_length, |
---|
199 | bool isSAI); |
---|
200 | |
---|
201 | void scan_string(ED4_multi_species_manager *parent, |
---|
202 | ED4_reference_terminals& refterms, |
---|
203 | const char *str, |
---|
204 | int *index, |
---|
205 | arb_progress& progress); |
---|
206 | |
---|
207 | void save_current_config(char *confname); |
---|
208 | }; |
---|
209 | |
---|
210 | #define SPECIFIED_OBJECT_TYPES 23 |
---|
211 | |
---|
212 | class ED4_objspec : public Noncopyable { |
---|
213 | static bool object_specs_initialized; |
---|
214 | static bool descendants_uptodate; |
---|
215 | |
---|
216 | mutable ED4_level used_children; // in any object of this type |
---|
217 | mutable ED4_level possible_descendants; // below any object of this type (depends on used_children) |
---|
218 | mutable ED4_level allowed_descendants; // below any object of this type (depends on allowed_children) |
---|
219 | |
---|
220 | void calc_descendants() const; |
---|
221 | |
---|
222 | public: |
---|
223 | ED4_properties static_prop; |
---|
224 | ED4_level level; |
---|
225 | ED4_level allowed_children; |
---|
226 | ED4_level handled_level; |
---|
227 | ED4_level restriction_level; |
---|
228 | |
---|
229 | ED4_objspec(ED4_properties static_prop_, ED4_level level_, ED4_level allowed_children_, ED4_level handled_level_, ED4_level restriction_level_); |
---|
230 | |
---|
231 | #if defined(IMPLEMENT_DUMP) |
---|
232 | void dump(size_t indent) const; |
---|
233 | #endif // IMPLEMENT_DUMP |
---|
234 | |
---|
235 | static void init_object_specs(); |
---|
236 | |
---|
237 | bool is_manager() const { return static_prop & PROP_IS_MANAGER; } |
---|
238 | bool is_terminal() const { return static_prop & PROP_IS_TERMINAL; } |
---|
239 | |
---|
240 | bool allowed_to_contain(ED4_level child_level) const { |
---|
241 | // e4_assert(object_specs_initialized); // @@@ cant check here.. but where |
---|
242 | e4_assert(is_manager()); // terminals can't contain anything - your test is senseless |
---|
243 | return allowed_children & child_level; |
---|
244 | } |
---|
245 | |
---|
246 | void announce_added(ED4_level child_level) const { |
---|
247 | e4_assert(allowed_to_contain(child_level)); |
---|
248 | used_children = ED4_level(used_children|child_level); |
---|
249 | descendants_uptodate = false; |
---|
250 | } |
---|
251 | |
---|
252 | static void recalc_descendants(); |
---|
253 | |
---|
254 | ED4_level get_possible_descendants() const { |
---|
255 | e4_assert(is_manager()); |
---|
256 | if (!descendants_uptodate) recalc_descendants(); |
---|
257 | return possible_descendants; |
---|
258 | } |
---|
259 | ED4_level get_allowed_descendants() const { // (allowed = possible + those allowed to add, but not added anywhere) |
---|
260 | e4_assert(is_manager()); |
---|
261 | if (!descendants_uptodate) recalc_descendants(); |
---|
262 | return allowed_descendants; |
---|
263 | } |
---|
264 | }; |
---|
265 | |
---|
266 | class ED4_folding_line : virtual Noncopyable { |
---|
267 | AW_pos dimension; // amount of pixel folded away |
---|
268 | AW_pos pos; // window position of folding line (x or y, only owner knows which coordinate is folded) |
---|
269 | ED4_folding_line *next; |
---|
270 | |
---|
271 | ED4_folding_line *insert(ED4_folding_line *fl) { |
---|
272 | e4_assert(!fl->next); |
---|
273 | if (pos <= fl->pos) { // insert behind |
---|
274 | next = next ? next->insert(fl) : fl; |
---|
275 | return this; |
---|
276 | } |
---|
277 | |
---|
278 | fl->next = this; |
---|
279 | return fl; |
---|
280 | } |
---|
281 | |
---|
282 | public: |
---|
283 | |
---|
284 | ED4_folding_line(AW_pos world, AW_pos dim) : dimension(dim), next(NULp) { set_pos(world-dimension); } |
---|
285 | |
---|
286 | ~ED4_folding_line() { delete next; } |
---|
287 | |
---|
288 | void insertAs(ED4_folding_line*& ptr) { |
---|
289 | ED4_folding_line *other = ptr; |
---|
290 | e4_assert(knownNonNull(this)); |
---|
291 | ptr = other ? other->insert(this) : this; |
---|
292 | } |
---|
293 | |
---|
294 | ED4_folding_line *delete_member(ED4_folding_line *fl) { |
---|
295 | ED4_folding_line *result = this; |
---|
296 | if (this == fl) { |
---|
297 | result = next; |
---|
298 | next = NULp; |
---|
299 | delete this; |
---|
300 | } |
---|
301 | return result; |
---|
302 | } |
---|
303 | |
---|
304 | AW_pos get_dimension() const { return dimension; } |
---|
305 | const ED4_folding_line *get_next() const { return next; } |
---|
306 | |
---|
307 | void warn_illegal_dimension(); |
---|
308 | |
---|
309 | void set_dimension(AW_pos dim) { dimension = dim; warn_illegal_dimension(); } |
---|
310 | void add_to_dimension(AW_pos offset) { dimension += offset; warn_illegal_dimension(); } |
---|
311 | |
---|
312 | void set_pos(AW_pos p) { pos = p; } |
---|
313 | AW_pos get_pos() const { return pos; } |
---|
314 | |
---|
315 | AW_pos win2world(AW_pos win) const { |
---|
316 | if (win<pos) return win; |
---|
317 | return (next ? next->win2world(win) : win)+dimension; |
---|
318 | } |
---|
319 | AW_pos world2win(AW_pos world) const { |
---|
320 | if (world<pos) return world; |
---|
321 | world -= dimension; |
---|
322 | if (!next) return world; |
---|
323 | return next->world2win(world); |
---|
324 | } |
---|
325 | }; |
---|
326 | |
---|
327 | struct ED4_scroll_links { |
---|
328 | ED4_base *link_for_hor_slider; |
---|
329 | ED4_base *link_for_ver_slider; |
---|
330 | |
---|
331 | ED4_scroll_links() : link_for_hor_slider(NULp), link_for_ver_slider(NULp) {} |
---|
332 | }; |
---|
333 | |
---|
334 | class ED4_foldable : virtual Noncopyable { |
---|
335 | ED4_folding_line *horizontal_fl; |
---|
336 | ED4_folding_line *vertical_fl; |
---|
337 | protected: |
---|
338 | void reset() { |
---|
339 | delete horizontal_fl; |
---|
340 | delete vertical_fl; |
---|
341 | horizontal_fl = NULp; |
---|
342 | vertical_fl = NULp; |
---|
343 | } |
---|
344 | bool is_reset() const { return !horizontal_fl && !vertical_fl; } |
---|
345 | public: |
---|
346 | |
---|
347 | ED4_foldable() : horizontal_fl(NULp), vertical_fl(NULp) {} |
---|
348 | ~ED4_foldable() { reset(); } |
---|
349 | |
---|
350 | const ED4_folding_line *get_horizontal_folding() { return horizontal_fl; } |
---|
351 | const ED4_folding_line *get_vertical_folding() { return vertical_fl; } |
---|
352 | |
---|
353 | void world_to_win_coords(AW_pos *xPtr, AW_pos *yPtr) const { // @@@ old style |
---|
354 | // Calculates transformation from world to window coordinates in a given window. |
---|
355 | // world-coordinates inside folded range result in window coordinates lower than folding line position. |
---|
356 | e4_assert(!is_reset()); |
---|
357 | *xPtr = vertical_fl->world2win(*xPtr); |
---|
358 | *yPtr = horizontal_fl->world2win(*yPtr); |
---|
359 | } |
---|
360 | void win_to_world_coords(AW_pos *xPtr, AW_pos *yPtr) const { // @@@ old style |
---|
361 | // calculates transformation from window to world coordinates in a given window |
---|
362 | e4_assert(!is_reset()); |
---|
363 | *xPtr = vertical_fl->win2world(*xPtr); |
---|
364 | *yPtr = horizontal_fl->win2world(*yPtr); |
---|
365 | } |
---|
366 | |
---|
367 | AW::Position world_to_win_coords(const AW::Position& pos) const { |
---|
368 | e4_assert(!is_reset()); |
---|
369 | return AW::Position(vertical_fl->world2win(pos.xpos()), |
---|
370 | horizontal_fl->world2win(pos.ypos())); |
---|
371 | } |
---|
372 | AW::Position win_to_world_coords(const AW::Position& pos) const { |
---|
373 | e4_assert(!is_reset()); |
---|
374 | return AW::Position(vertical_fl->win2world(pos.xpos()), |
---|
375 | horizontal_fl->win2world(pos.ypos())); |
---|
376 | } |
---|
377 | |
---|
378 | ED4_folding_line *insert_folding_line(AW_pos pos, AW_pos dimension, ED4_properties prop); |
---|
379 | void delete_folding_line(ED4_folding_line *fl, ED4_properties prop); |
---|
380 | }; |
---|
381 | |
---|
382 | |
---|
383 | class ED4_scrolled_rectangle : virtual Noncopyable { |
---|
384 | ED4_folding_line *scroll_bottom; |
---|
385 | ED4_folding_line *scroll_right; |
---|
386 | ED4_folding_line *scroll_top; |
---|
387 | ED4_folding_line *scroll_left; |
---|
388 | |
---|
389 | ED4_base *x_link; |
---|
390 | ED4_base *y_link; |
---|
391 | ED4_base *width_link; |
---|
392 | ED4_base *height_link; |
---|
393 | |
---|
394 | AW::Rectangle world; |
---|
395 | |
---|
396 | bool folding_dimensions_calculated; // flag to ensure calc_bottomRight_folding_dimensions is called before get_window_rect |
---|
397 | |
---|
398 | void init_links() { |
---|
399 | x_link = NULp; |
---|
400 | y_link = NULp; |
---|
401 | width_link = NULp; |
---|
402 | height_link = NULp; |
---|
403 | } |
---|
404 | |
---|
405 | void init_folding_lines() { |
---|
406 | scroll_top = NULp; |
---|
407 | scroll_bottom = NULp; |
---|
408 | scroll_left = NULp; |
---|
409 | scroll_right = NULp; |
---|
410 | |
---|
411 | folding_dimensions_calculated = false; |
---|
412 | } |
---|
413 | void init_pos_size() { world = AW::Rectangle(AW::Origin, AW::ZeroVector); } |
---|
414 | |
---|
415 | void init() { |
---|
416 | init_folding_lines(); |
---|
417 | init_pos_size(); |
---|
418 | init_links(); |
---|
419 | } |
---|
420 | |
---|
421 | void update_folding_line_positions() { |
---|
422 | scroll_top->set_pos(world.top()); |
---|
423 | scroll_left->set_pos(world.left()); |
---|
424 | } |
---|
425 | |
---|
426 | public: |
---|
427 | |
---|
428 | ED4_scrolled_rectangle() { init(); } |
---|
429 | |
---|
430 | AW_pos bottom() const { return world.bottom(); } |
---|
431 | AW_pos right() const { return world.right(); } |
---|
432 | |
---|
433 | void reset(ED4_foldable& owner) { |
---|
434 | destroy_folding_lines(owner); |
---|
435 | init_pos_size(); |
---|
436 | } |
---|
437 | |
---|
438 | AW_pos top_dim() const { return scroll_top->get_dimension(); } |
---|
439 | AW_pos left_dim() const { return scroll_left->get_dimension(); } |
---|
440 | |
---|
441 | bool exists() const { return scroll_top && scroll_bottom && scroll_left && scroll_right; } |
---|
442 | bool is_linked() const { |
---|
443 | if (x_link) { |
---|
444 | e4_assert(y_link); |
---|
445 | e4_assert(width_link); |
---|
446 | e4_assert(height_link); |
---|
447 | return true; |
---|
448 | } |
---|
449 | e4_assert(!y_link); |
---|
450 | e4_assert(!width_link); |
---|
451 | e4_assert(!height_link); |
---|
452 | return false; |
---|
453 | } |
---|
454 | void link(ED4_base *x, ED4_base *y, ED4_base *w, ED4_base *h) { |
---|
455 | e4_assert(x && y && w && h); |
---|
456 | |
---|
457 | x_link = x; |
---|
458 | y_link = y; |
---|
459 | width_link = w; |
---|
460 | height_link = h; |
---|
461 | } |
---|
462 | |
---|
463 | void replace_x_width_link_to(ED4_base *old_link, ED4_base *new_link) { |
---|
464 | if (x_link == old_link) x_link = new_link; |
---|
465 | if (width_link == old_link) width_link = new_link; |
---|
466 | } |
---|
467 | |
---|
468 | void add_to_top_left_dimension(int dx, int dy) { |
---|
469 | scroll_left->add_to_dimension(dx); |
---|
470 | scroll_top->add_to_dimension(dy); |
---|
471 | } |
---|
472 | |
---|
473 | void scroll(int dx, int dy) { |
---|
474 | scroll_left->add_to_dimension(-dx); |
---|
475 | scroll_top->add_to_dimension(-dy); |
---|
476 | scroll_right->add_to_dimension(dx); |
---|
477 | scroll_bottom->add_to_dimension(dy); |
---|
478 | } |
---|
479 | |
---|
480 | AW::Rectangle get_window_rect() const { |
---|
481 | e4_assert(folding_dimensions_calculated); |
---|
482 | return AW::Rectangle(scroll_left->get_pos(), scroll_top->get_pos(), |
---|
483 | scroll_right->get_pos(), scroll_bottom->get_pos()); |
---|
484 | } |
---|
485 | |
---|
486 | AW::Rectangle get_world_rect() const; |
---|
487 | |
---|
488 | void set_rect(const AW::Rectangle& rect) { world = rect; } |
---|
489 | void set_rect_and_update_folding_line_positions(const AW::Rectangle& rect) { |
---|
490 | set_rect(rect); |
---|
491 | update_folding_line_positions(); |
---|
492 | } |
---|
493 | |
---|
494 | void calc_bottomRight_folding_dimensions(int area_width, int area_height) { |
---|
495 | area_width -= SLIDER_OFFSET; |
---|
496 | area_height -= SLIDER_OFFSET; |
---|
497 | |
---|
498 | AW_pos dim; |
---|
499 | if (bottom() > area_height) { // our world doesn't fit vertically in our window |
---|
500 | dim = bottom()-area_height; // calc dimension of both horizontal folding lines |
---|
501 | scroll_top->set_dimension(std::min(dim, scroll_top->get_dimension())); |
---|
502 | scroll_bottom->set_dimension(std::max(0, int(dim - scroll_top->get_dimension()))); |
---|
503 | } |
---|
504 | else { |
---|
505 | dim = 0; |
---|
506 | scroll_bottom->set_dimension(0); |
---|
507 | scroll_top->set_dimension(0); |
---|
508 | } |
---|
509 | |
---|
510 | e4_assert(dim == (scroll_top->get_dimension()+scroll_bottom->get_dimension())); |
---|
511 | scroll_bottom->set_pos(world.bottom()-dim+SLIDER_OFFSET); |
---|
512 | |
---|
513 | if (right()>area_width) { // our world doesn't fit horizontally in our window |
---|
514 | dim = right()-area_width; // calc dimension of both vertical folding lines |
---|
515 | scroll_left->set_dimension(std::min(dim, scroll_left->get_dimension())); |
---|
516 | scroll_right->set_dimension(std::max(0, int(dim - scroll_left->get_dimension()))); |
---|
517 | } |
---|
518 | else { |
---|
519 | dim = 0; |
---|
520 | scroll_right->set_dimension(0); |
---|
521 | scroll_left->set_dimension(0); |
---|
522 | } |
---|
523 | |
---|
524 | e4_assert(dim == (scroll_left->get_dimension()+scroll_right->get_dimension())); |
---|
525 | scroll_right->set_pos(world.right()-dim+SLIDER_OFFSET); |
---|
526 | |
---|
527 | folding_dimensions_calculated = true; |
---|
528 | } |
---|
529 | |
---|
530 | void create_folding_lines(ED4_foldable& owner, const AW::Rectangle& rect, int area_width, int area_height) { |
---|
531 | scroll_top = owner.insert_folding_line(rect.top(), 0, PROP_HORIZONTAL); |
---|
532 | scroll_left = owner.insert_folding_line(rect.left(), 0, PROP_VERTICAL); |
---|
533 | |
---|
534 | AW_pos dim = 0; |
---|
535 | if (rect.bottom() > area_height) dim = rect.bottom() - area_height; |
---|
536 | scroll_bottom = owner.insert_folding_line(rect.bottom(), dim, PROP_HORIZONTAL); |
---|
537 | |
---|
538 | dim = 0; |
---|
539 | if (rect.right() > area_width) dim = rect.right() - area_width; |
---|
540 | scroll_right = owner.insert_folding_line(rect.right(), dim, PROP_VERTICAL); |
---|
541 | } |
---|
542 | |
---|
543 | void destroy_folding_lines(ED4_foldable& owner) { |
---|
544 | if (scroll_top) owner.delete_folding_line(scroll_top, PROP_HORIZONTAL); |
---|
545 | if (scroll_bottom) owner.delete_folding_line(scroll_bottom, PROP_HORIZONTAL); |
---|
546 | if (scroll_left) owner.delete_folding_line(scroll_left, PROP_VERTICAL); |
---|
547 | if (scroll_right) owner.delete_folding_line(scroll_right, PROP_VERTICAL); |
---|
548 | |
---|
549 | init_folding_lines(); |
---|
550 | } |
---|
551 | }; |
---|
552 | |
---|
553 | class ED4_base_position : private BasePosition { // derived from a Noncopyable |
---|
554 | const ED4_terminal *calced4term; // if calced4term => callback is bound to its species manager |
---|
555 | bool needUpdate; |
---|
556 | |
---|
557 | void calc4term(const ED4_terminal *term); |
---|
558 | void set_term(const ED4_terminal *term) { |
---|
559 | if (calced4term != term || needUpdate) { |
---|
560 | calc4term(term); |
---|
561 | } |
---|
562 | } |
---|
563 | void remove_changed_cb(); |
---|
564 | |
---|
565 | public: |
---|
566 | |
---|
567 | ED4_base_position() |
---|
568 | : calced4term(NULp), |
---|
569 | needUpdate(true) |
---|
570 | {} |
---|
571 | |
---|
572 | ~ED4_base_position() { |
---|
573 | remove_changed_cb(); |
---|
574 | } |
---|
575 | |
---|
576 | void invalidate() { |
---|
577 | needUpdate = true; |
---|
578 | } |
---|
579 | |
---|
580 | void announce_deletion(const ED4_terminal *term) { |
---|
581 | if (term == calced4term) { |
---|
582 | invalidate(); |
---|
583 | remove_changed_cb(); |
---|
584 | } |
---|
585 | e4_assert(calced4term != term); |
---|
586 | } |
---|
587 | void prepare_shutdown() { |
---|
588 | if (calced4term) announce_deletion(calced4term); |
---|
589 | } |
---|
590 | |
---|
591 | int get_base_position(const ED4_terminal *base, int sequence_position); |
---|
592 | int get_sequence_position(const ED4_terminal *base, int base_position); |
---|
593 | |
---|
594 | int get_base_count(const ED4_terminal *term) { set_term(term); return base_count(); } |
---|
595 | int get_abs_len(const ED4_terminal *term) { set_term(term); return abs_count(); } |
---|
596 | }; |
---|
597 | |
---|
598 | class ED4_CursorShape; |
---|
599 | |
---|
600 | |
---|
601 | enum ED4_CursorType { |
---|
602 | ED4_RIGHT_ORIENTED_CURSOR, |
---|
603 | ED4_RIGHT_ORIENTED_CURSOR_THIN, |
---|
604 | ED4_TRADITIONAL_CURSOR, |
---|
605 | ED4_TRADITIONAL_CURSOR_BOTTOM, |
---|
606 | ED4_TRADITIONAL_CURSOR_CONNECTED, |
---|
607 | ED4_FUCKING_BIG_CURSOR, |
---|
608 | |
---|
609 | ED4_CURSOR_TYPES |
---|
610 | |
---|
611 | }; |
---|
612 | |
---|
613 | struct ED4_TerminalPredicate { |
---|
614 | virtual ~ED4_TerminalPredicate() {} |
---|
615 | virtual bool fulfilled_by(const ED4_terminal *) const = 0; |
---|
616 | }; |
---|
617 | |
---|
618 | class ED4_WinContextFree { // denies usage of the following functions in classes derived from this |
---|
619 | AW_device *current_device(); |
---|
620 | ED4_window *current_ed4w(); |
---|
621 | AW_window *current_aww(); |
---|
622 | ED4_cursor& current_cursor(); |
---|
623 | public: |
---|
624 | void avoid_warning() {} |
---|
625 | }; |
---|
626 | |
---|
627 | class ED4_cursor : virtual Noncopyable, virtual ED4_WinContextFree { |
---|
628 | ED4_window *win; |
---|
629 | ED4_index cursor_abs_x; // absolute (to terminal) x-position of cursor (absolute world coordinate of edit window) |
---|
630 | int screen_position; // number of displayed characters leading the cursor |
---|
631 | mutable ED4_base_position base_position; // # of bases left of cursor |
---|
632 | ED4_CursorType ctype; |
---|
633 | ED4_CursorShape *cursor_shape; |
---|
634 | |
---|
635 | ED4_returncode draw_cursor(AW_pos x, AW_pos y); |
---|
636 | ED4_returncode delete_cursor(AW_pos del_mark, ED4_base *target_terminal); |
---|
637 | |
---|
638 | void updateAwars(bool new_term_selected); |
---|
639 | |
---|
640 | public: |
---|
641 | |
---|
642 | bool allowed_to_draw; // needed for cursor handling |
---|
643 | ED4_terminal *owner_of_cursor; |
---|
644 | |
---|
645 | bool is_partly_visible() const; |
---|
646 | bool is_completely_visible() const; |
---|
647 | |
---|
648 | bool is_hidden_inside_group() const; |
---|
649 | |
---|
650 | void changeType(ED4_CursorType typ); |
---|
651 | ED4_CursorType getType() const { return ctype; } |
---|
652 | |
---|
653 | void redraw() { changeType(getType()); } |
---|
654 | |
---|
655 | ED4_returncode HideCursor(); // deletes cursor and does refresh |
---|
656 | ED4_returncode move_cursor(AW_event *event); |
---|
657 | ED4_returncode show_clicked_cursor(AW_pos click_xpos, ED4_terminal *target_terminal); |
---|
658 | ED4_returncode show_cursor_at(ED4_terminal *target_terminal, ED4_index what_pos); |
---|
659 | ED4_returncode ShowCursor(ED4_index offset_x, ED4_cursor_move move, int move_pos = 1); |
---|
660 | |
---|
661 | int get_sequence_pos() const; |
---|
662 | int get_screen_pos() const { return screen_position; } |
---|
663 | |
---|
664 | long get_abs_x() const { return cursor_abs_x; } |
---|
665 | void set_abs_x(); |
---|
666 | |
---|
667 | int base2sequence_position(int base_pos) const { return base_position.get_sequence_position(owner_of_cursor, base_pos); } |
---|
668 | int sequence2base_position(int seq_pos) const { return base_position.get_base_position(owner_of_cursor, seq_pos); } |
---|
669 | |
---|
670 | int get_base_position() const { return sequence2base_position(get_sequence_pos()); } |
---|
671 | |
---|
672 | void prepare_shutdown() { base_position.prepare_shutdown(); } |
---|
673 | |
---|
674 | void jump_screen_pos(int screen_pos, ED4_CursorJumpType jump_type); |
---|
675 | void jump_sequence_pos(int sequence_pos, ED4_CursorJumpType jump_type); |
---|
676 | void jump_base_pos(int base_pos, ED4_CursorJumpType jump_type); |
---|
677 | |
---|
678 | int get_screen_relative_pos() const; |
---|
679 | void set_screen_relative_pos(int scroll_to_relpos); |
---|
680 | |
---|
681 | void set_to_terminal(ED4_terminal *terminal, int seq_pos, ED4_CursorJumpType jump_type); |
---|
682 | |
---|
683 | inline bool in_species_seq_terminal() const; |
---|
684 | inline bool in_consensus_terminal() const; |
---|
685 | inline bool in_SAI_terminal() const; |
---|
686 | |
---|
687 | void announce_deletion(ED4_terminal *object) { |
---|
688 | base_position.announce_deletion(object); |
---|
689 | if (object == owner_of_cursor) owner_of_cursor = NULp; // no need to delete the cursor (deletion triggers full redraw) |
---|
690 | } |
---|
691 | |
---|
692 | void init(); |
---|
693 | |
---|
694 | ED4_window *window() const { return win; } |
---|
695 | |
---|
696 | ED4_cursor(ED4_window *win); |
---|
697 | ~ED4_cursor(); |
---|
698 | }; |
---|
699 | |
---|
700 | class ED4_window : public ED4_foldable, virtual ED4_WinContextFree { // derived from Noncopyable |
---|
701 | void set_scrollbar_indents(); |
---|
702 | |
---|
703 | public: |
---|
704 | AW_window_menu_modes *aww; // Points to Window |
---|
705 | ED4_window *next; |
---|
706 | int slider_pos_horizontal; |
---|
707 | int slider_pos_vertical; |
---|
708 | ED4_scrolled_rectangle scrolled_rect; |
---|
709 | int id; // unique id in window-list |
---|
710 | ED4_coords coords; |
---|
711 | |
---|
712 | static int no_of_windows; |
---|
713 | |
---|
714 | char awar_path_for_cursor[50]; // position in current sequence, range = [1;len] |
---|
715 | char awar_path_for_Ecoli[50]; // position relative to ecoli |
---|
716 | char awar_path_for_basePos[50]; // base position in current sequence (# of bases left to cursor) |
---|
717 | char awar_path_for_IUPAC[50]; // IUPAC decoder content for current position |
---|
718 | char awar_path_for_helixNr[50]; // # of helix (or 0) for current position |
---|
719 | |
---|
720 | bool is_hidden; |
---|
721 | ED4_cursor cursor; |
---|
722 | |
---|
723 | // ED4_window controlling functions |
---|
724 | static ED4_window *insert_window(AW_window_menu_modes *new_aww); // append to window list |
---|
725 | |
---|
726 | void delete_window(ED4_window *window); // delete from window list |
---|
727 | void reset_all_for_new_config(); // reset structures for loading new config |
---|
728 | ED4_window *get_matching_ed4w(AW_window *aww); |
---|
729 | |
---|
730 | void announce_deletion(ED4_terminal *object) { cursor.announce_deletion(object); } |
---|
731 | |
---|
732 | // functions concerned the scrolled area |
---|
733 | void update_scrolled_rectangle(); |
---|
734 | ED4_returncode scroll_rectangle(int dx, int dy); |
---|
735 | ED4_returncode set_scrolled_rectangle(ED4_base *x_link, ED4_base *y_link, ED4_base *width_link, ED4_base *height_link); |
---|
736 | |
---|
737 | bool scrollbars_and_scrolledRect_inSync() const { |
---|
738 | // Scrolling in EDIT4 window uses redundant data |
---|
739 | // - dimension of folding lines |
---|
740 | // - slider positions in AW_window and ED4_window |
---|
741 | // This function checks whether they are in sync. |
---|
742 | |
---|
743 | bool inSync = |
---|
744 | (scrolled_rect.top_dim() == aww->slider_pos_vertical) && |
---|
745 | (scrolled_rect.left_dim() == aww->slider_pos_horizontal); |
---|
746 | |
---|
747 | #if defined(DEBUG) |
---|
748 | if (!inSync) { |
---|
749 | fputs("scrollbars not in sync with scrolled_rect:\n", stderr); |
---|
750 | fprintf(stderr, " aww->slider_pos_vertical =%i scrolled_rect->top_dim() =%f\n", aww->slider_pos_vertical, scrolled_rect.top_dim()); |
---|
751 | fprintf(stderr, " aww->slider_pos_horizontal=%i scrolled_rect->left_dim()=%f\n", aww->slider_pos_horizontal, scrolled_rect.left_dim()); |
---|
752 | } |
---|
753 | #endif |
---|
754 | |
---|
755 | return inSync; |
---|
756 | } |
---|
757 | |
---|
758 | void check_valid_scrollbar_values() { e4_assert(scrollbars_and_scrolledRect_inSync()); } |
---|
759 | |
---|
760 | bool shows_xpos(int x) const { return x >= coords.window_left_clip_point && x <= coords.window_right_clip_point; } |
---|
761 | bool partly_shows(int x1, int y1, int x2, int y2) const; |
---|
762 | bool completely_shows(int x1, int y1, int x2, int y2) const; |
---|
763 | |
---|
764 | void update_window_coords(); |
---|
765 | |
---|
766 | AW_device *get_device() const { return aww->get_device(AW_MIDDLE_AREA); } |
---|
767 | |
---|
768 | ED4_window(AW_window_menu_modes *window); |
---|
769 | ~ED4_window(); |
---|
770 | }; |
---|
771 | |
---|
772 | class ED4_container : virtual Noncopyable { |
---|
773 | // contains children of a manager |
---|
774 | |
---|
775 | ED4_base **memberList; |
---|
776 | ED4_index no_of_members; // How much members are in the list |
---|
777 | ED4_index size_of_list; // allocated size |
---|
778 | |
---|
779 | void correct_insert_position(ED4_index& index); |
---|
780 | void resize(ED4_index needed_size); |
---|
781 | |
---|
782 | void shift_list(ED4_index start_index, int length); |
---|
783 | |
---|
784 | protected: |
---|
785 | |
---|
786 | bool valid_index(ED4_index idx) const { return idx >= 0 && idx<size_of_list; } |
---|
787 | bool existing_index(ED4_index idx) const { return idx >= 0 && idx<no_of_members; } |
---|
788 | |
---|
789 | public: |
---|
790 | |
---|
791 | ED4_manager *owner() { return DOWNCAST(ED4_manager*, this); } |
---|
792 | const ED4_manager *owner() const { return const_cast<ED4_container*>(this)->owner(); } |
---|
793 | |
---|
794 | ED4_base* member(ED4_index i) const { e4_assert(i>=0 && i<size_of_list); return memberList[i]; } |
---|
795 | |
---|
796 | ED4_index members() const { return no_of_members; } |
---|
797 | bool empty() const { return !members(); } |
---|
798 | void clear(); |
---|
799 | |
---|
800 | void insert_member(ED4_base *new_member); // only used to move members with mouse |
---|
801 | void append_member(ED4_base *new_member); |
---|
802 | |
---|
803 | // an array is chosen instead of a linked list, because destructorhandling is more comfortable in various destructors (manager-destructors) |
---|
804 | |
---|
805 | ED4_returncode remove_member(ED4_base *member); |
---|
806 | ED4_index search_member(ED4_extension *location, ED4_properties prop); // search member |
---|
807 | |
---|
808 | ED4_returncode search_target_species(ED4_extension *location, ED4_properties prop, ED4_base **found_member, ED4_level return_level); |
---|
809 | |
---|
810 | ED4_returncode move_member(ED4_index old_pos, ED4_index new_pos); |
---|
811 | |
---|
812 | #if defined(IMPLEMENT_DUMP) |
---|
813 | void dump_container(size_t indent) const; |
---|
814 | #endif // IMPLEMENT_DUMP |
---|
815 | |
---|
816 | #if defined(ASSERTION_USED) |
---|
817 | bool members_ok() const; |
---|
818 | #endif // ASSERTION_USED |
---|
819 | |
---|
820 | ED4_container(); |
---|
821 | virtual ~ED4_container(); |
---|
822 | }; |
---|
823 | |
---|
824 | // ---------------------------- |
---|
825 | // ED4_species_pointer |
---|
826 | |
---|
827 | class ED4_species_pointer : virtual Noncopyable { |
---|
828 | // @@@ shall be renamed into ED4_gbdata_pointer to reflect general usage |
---|
829 | |
---|
830 | GBDATA *species_pointer; // points to database |
---|
831 | |
---|
832 | void addCallback(ED4_base *base); |
---|
833 | void removeCallback(ED4_base *base); |
---|
834 | |
---|
835 | public: |
---|
836 | |
---|
837 | ED4_species_pointer(); |
---|
838 | ~ED4_species_pointer(); |
---|
839 | |
---|
840 | GBDATA *Get() const { return species_pointer; } |
---|
841 | void Set(GBDATA *gbd, ED4_base *base); |
---|
842 | void notify_deleted() { |
---|
843 | species_pointer=NULp; |
---|
844 | } |
---|
845 | }; |
---|
846 | |
---|
847 | // ------------------------ |
---|
848 | // callback types |
---|
849 | |
---|
850 | template <class BASE, class BASECB> |
---|
851 | class ED4_cb_list { |
---|
852 | std::list<BASECB> callbacks; |
---|
853 | public: |
---|
854 | #if defined(ASSERTION_USED) |
---|
855 | ED4_cb_list() {} |
---|
856 | ~ED4_cb_list() { |
---|
857 | e4_assert(empty()); // calling ED4_root::remove_all_callbacks() did not remove all callbacks! |
---|
858 | } |
---|
859 | #endif |
---|
860 | void add_cb(BASECB cb) { callbacks.push_back(cb); } |
---|
861 | void remove_cb(BASECB cb) { callbacks.remove(cb); } |
---|
862 | |
---|
863 | void call(BASE *b) { |
---|
864 | for (typename std::list<BASECB>::iterator cb = callbacks.begin(); cb != callbacks.end();) { |
---|
865 | typename std::list<BASECB>::iterator curr = cb; |
---|
866 | ++cb; |
---|
867 | (*curr)(b); // Note: may be removed while called |
---|
868 | } |
---|
869 | } |
---|
870 | void clear() { callbacks.clear(); } |
---|
871 | bool empty() const { return callbacks.empty(); } |
---|
872 | }; |
---|
873 | |
---|
874 | // declare callback types used in ED4_cb_list: |
---|
875 | DECLARE_CBTYPE_FVV_AND_BUILDERS(ED4_managerCallback, void, ED4_manager*); // generates makeED4_managerCallback |
---|
876 | DECLARE_CBTYPE_FVV_AND_BUILDERS(ED4_species_managerCallback, void, ED4_species_manager*); // generates makeED4_species_managerCallback |
---|
877 | |
---|
878 | // ----------------- |
---|
879 | // ED4_base |
---|
880 | |
---|
881 | class ED4_base; |
---|
882 | |
---|
883 | DECLARE_CBTYPE_FVV_AND_BUILDERS(ED4_route_cb, ARB_ERROR, ED4_base*); // generates makeED4_route_cb |
---|
884 | |
---|
885 | enum ED4_species_type { |
---|
886 | ED4_SP_NONE, |
---|
887 | ED4_SP_SPECIES, |
---|
888 | ED4_SP_SAI, |
---|
889 | ED4_SP_CONSENSUS, |
---|
890 | }; |
---|
891 | |
---|
892 | class ED4_base : virtual Noncopyable { |
---|
893 | // base object |
---|
894 | |
---|
895 | ED4_species_pointer my_species_pointer; |
---|
896 | |
---|
897 | // cache world coordinates: |
---|
898 | |
---|
899 | static int currTimestamp; |
---|
900 | mutable AW::Position lastPos; |
---|
901 | mutable int timestamp; |
---|
902 | |
---|
903 | ED4_base_list *linked_objects; // linked list of objects which are depending from this object |
---|
904 | |
---|
905 | virtual bool set_dynamic_size() { |
---|
906 | // default behavior: keep size |
---|
907 | // (overload to implement dynamic sizing; also set static_prop!) |
---|
908 | e4_assert(!(spec.static_prop & PROP_DYNA_RESIZE)); // forgot to overload set_dynamic_size? |
---|
909 | return false; // = "nothing changed" |
---|
910 | } |
---|
911 | |
---|
912 | public: |
---|
913 | const ED4_objspec& spec; // contains information about Objectproperties |
---|
914 | |
---|
915 | ED4_manager *parent; // Points to parent |
---|
916 | |
---|
917 | |
---|
918 | ED4_properties dynamic_prop; // contains info about what i am, what i can do, what i should do |
---|
919 | char *id; // globally unique name in hierarchy |
---|
920 | ED4_index index; // defines the order of child objects |
---|
921 | ED4_base *width_link; // concerning the hierarchy |
---|
922 | ED4_base *height_link; // concerning the hierarchy |
---|
923 | ED4_extension extension; // contains relative info about graphical properties |
---|
924 | ED4_update_info update_info; // info about things to be done for the object, i.e. refresh; flag structure |
---|
925 | struct { |
---|
926 | unsigned int hidden : 1; // flag whether object is hidden or not |
---|
927 | } flag; |
---|
928 | |
---|
929 | void draw_bb(int color); |
---|
930 | |
---|
931 | DECLARE_DUMP_FOR_ROOTCLASS(ED4_base); |
---|
932 | |
---|
933 | // function for species_pointer |
---|
934 | // |
---|
935 | // Notes: |
---|
936 | // |
---|
937 | // * design is broken @@@ |
---|
938 | // - my_species_pointer should be member of those derived classes, where it's used |
---|
939 | // - accessor functions should tell what we get (eg. ED4_species_name_terminal::get_name_entry() or similar) |
---|
940 | // |
---|
941 | // * current uses of my_species_pointer (grepped for 'set_species_pointer' to detect): |
---|
942 | // - ED4_species_manager [holds pointer to] species/SAI container |
---|
943 | // - ED4_species_name_terminal [holds pointer to] the 'name' entry of species/SAI |
---|
944 | // - ED4_sequence_info_terminal [holds pointer to] the displayed sub-entry of the alignment-container of species/SAI (multiple may exist per species) |
---|
945 | // - ED4_text_terminal [holds pointer to] same as ED4_sequence_info_terminal (Caution: not true for all text terminals!) |
---|
946 | |
---|
947 | GBDATA *get_species_pointer() const { return my_species_pointer.Get(); } |
---|
948 | void set_species_pointer(GBDATA *gbd) { my_species_pointer.Set(gbd, this); } |
---|
949 | bool has_callback() const { return get_species_pointer(); } |
---|
950 | |
---|
951 | // callbacks |
---|
952 | |
---|
953 | virtual void changed_by_database(); |
---|
954 | virtual void deleted_from_database(); |
---|
955 | |
---|
956 | // functions concerned with graphic output |
---|
957 | int adjust_clipping_rectangle(); |
---|
958 | virtual void Show(bool refresh_all, bool is_cleared) = 0; |
---|
959 | |
---|
960 | virtual bool calc_bounding_box() = 0; |
---|
961 | void resize_dynamic() { |
---|
962 | if (set_dynamic_size()) { |
---|
963 | e4_assert(has_property(PROP_DYNA_RESIZE)); // object dynamically changed size (but isn't allowed to!) |
---|
964 | request_resize(); |
---|
965 | } |
---|
966 | } |
---|
967 | |
---|
968 | ED4_returncode clear_background(int color=0); |
---|
969 | |
---|
970 | void set_links(ED4_base *width_ref, ED4_base *height_ref); |
---|
971 | void set_both_links(ED4_base *ref) { set_links(ref, ref); } |
---|
972 | |
---|
973 | // functions concerned with special initialization |
---|
974 | void set_property(ED4_properties prop) { dynamic_prop = (ED4_properties) (dynamic_prop | prop); } |
---|
975 | void clr_property(ED4_properties prop) { dynamic_prop = (ED4_properties) (dynamic_prop & ~prop); } |
---|
976 | bool has_property(ED4_properties prop) const { return dynamic_prop & prop; } |
---|
977 | |
---|
978 | // functions concerned with coordinate transformation |
---|
979 | |
---|
980 | void calc_rel_coords(AW_pos *x, AW_pos *y); |
---|
981 | |
---|
982 | void calc_world_coords(AW_pos *x, AW_pos *y) const { |
---|
983 | update_world_coords_cache(); |
---|
984 | *x = lastPos.xpos(); |
---|
985 | *y = lastPos.ypos(); |
---|
986 | } |
---|
987 | const AW::Position& calc_world_coords() const { |
---|
988 | update_world_coords_cache(); |
---|
989 | return lastPos; |
---|
990 | } |
---|
991 | |
---|
992 | void update_world_coords_cache() const { |
---|
993 | bool cache_up_to_date = timestamp == currTimestamp; |
---|
994 | if (!cache_up_to_date) { |
---|
995 | if (parent) { |
---|
996 | ED4_base *pab = (ED4_base*)parent; |
---|
997 | lastPos = pab->calc_world_coords(); |
---|
998 | } |
---|
999 | else { |
---|
1000 | lastPos = AW::Origin; |
---|
1001 | } |
---|
1002 | lastPos.move(extension.get_parent_offset()); |
---|
1003 | timestamp = currTimestamp; |
---|
1004 | } |
---|
1005 | } |
---|
1006 | |
---|
1007 | static void touch_world_cache() { |
---|
1008 | currTimestamp++; |
---|
1009 | } |
---|
1010 | |
---|
1011 | AW::Rectangle get_win_area(ED4_window *ed4w) const { |
---|
1012 | AW::Position pos = ed4w->world_to_win_coords(calc_world_coords()); |
---|
1013 | return AW::Rectangle(pos, extension.get_size()-AW::Vector(1, 1)); |
---|
1014 | } |
---|
1015 | |
---|
1016 | // functions which refer to the object as a child, i.e. travelling down the hierarchy |
---|
1017 | virtual void request_refresh(int clear=1) = 0; |
---|
1018 | |
---|
1019 | inline void request_resize(); |
---|
1020 | void request_resize_of_linked(); |
---|
1021 | void resize_requested_by_link(ED4_base *link); |
---|
1022 | virtual void resize_requested_children() = 0; |
---|
1023 | |
---|
1024 | virtual void delete_requested_children() = 0; |
---|
1025 | virtual void Delete() = 0; |
---|
1026 | |
---|
1027 | inline void set_update(); |
---|
1028 | virtual void update_requested_children() = 0; |
---|
1029 | |
---|
1030 | virtual ED4_returncode event_sent_by_parent(AW_event *event, AW_window *aww) = 0; |
---|
1031 | |
---|
1032 | virtual ARB_ERROR route_down_hierarchy(const ED4_route_cb& cb); |
---|
1033 | |
---|
1034 | int calc_group_depth(); |
---|
1035 | |
---|
1036 | // general purpose functions |
---|
1037 | virtual ED4_base *search_ID(const char *id) = 0; |
---|
1038 | |
---|
1039 | void check_all(); |
---|
1040 | short in_border(AW_pos abs_x, AW_pos abs_y, ED4_movemode mode); |
---|
1041 | ED4_returncode set_width(); |
---|
1042 | |
---|
1043 | |
---|
1044 | ED4_AREA_LEVEL get_area_level(ED4_multi_species_manager **multi_species_manager=NULp) const; // returns area we belong to and the next multi species manager of the area |
---|
1045 | |
---|
1046 | inline ED4_manager *get_parent(ED4_level lev) const; |
---|
1047 | void unlink_from_parent(); |
---|
1048 | bool has_parent(ED4_manager *Parent); |
---|
1049 | bool is_child_of(ED4_manager *Parent) { return has_parent(Parent); } |
---|
1050 | |
---|
1051 | virtual char *resolve_pointer_to_string_copy(int *str_len = NULp) const; |
---|
1052 | virtual const char *resolve_pointer_to_char_pntr(int *str_len = NULp) const; |
---|
1053 | |
---|
1054 | ED4_group_manager *is_in_folded_group() const; |
---|
1055 | virtual bool is_hidden() const = 0; |
---|
1056 | |
---|
1057 | char *get_name_of_species(); // go from terminal to name of species |
---|
1058 | |
---|
1059 | // functions which refer to the selected object(s), i.e. across the hierarchy |
---|
1060 | |
---|
1061 | ED4_terminal *get_next_terminal(); |
---|
1062 | ED4_terminal *get_prev_terminal(); |
---|
1063 | |
---|
1064 | void generate_configuration_string(GBS_strstruct& buffer); |
---|
1065 | |
---|
1066 | virtual void remove_callbacks() = 0; |
---|
1067 | |
---|
1068 | const ED4_terminal *get_consensus_relevant_terminal() const; |
---|
1069 | |
---|
1070 | ED4_base(const ED4_objspec& spec_, GB_CSTR id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
1071 | virtual ~ED4_base(); |
---|
1072 | |
---|
1073 | // use the following functions to test which derived class we have |
---|
1074 | |
---|
1075 | int is_terminal() const { e4_assert(knownNonNull(this)); return spec.static_prop & PROP_IS_TERMINAL; } |
---|
1076 | |
---|
1077 | int is_text_terminal() const { e4_assert(knownNonNull(this)); return spec.level & (LEV_SPECIES_NAME|LEV_SEQUENCE_INFO|LEV_SEQUENCE_STRING|LEV_PURE_TEXT|LEV_COL_STAT); } |
---|
1078 | |
---|
1079 | int is_species_name_terminal() const { e4_assert(knownNonNull(this)); return spec.level & LEV_SPECIES_NAME; } |
---|
1080 | |
---|
1081 | int is_sequence_info_terminal() const { e4_assert(knownNonNull(this)); return spec.level & LEV_SEQUENCE_INFO; } |
---|
1082 | int is_sequence_terminal() const { e4_assert(knownNonNull(this)); return spec.level & LEV_SEQUENCE_STRING; } |
---|
1083 | int is_orf_terminal() const { e4_assert(knownNonNull(this)); return spec.level & LEV_ORF; } |
---|
1084 | |
---|
1085 | int is_pure_text_terminal() const { e4_assert(knownNonNull(this)); return spec.level & LEV_PURE_TEXT; } |
---|
1086 | int is_columnStat_terminal() const { e4_assert(knownNonNull(this)); return spec.level & LEV_COL_STAT; } |
---|
1087 | |
---|
1088 | int is_bracket_terminal() const { e4_assert(knownNonNull(this)); return spec.level & LEV_BRACKET; } |
---|
1089 | int is_spacer_terminal() const { e4_assert(knownNonNull(this)); return spec.level & LEV_SPACER; } |
---|
1090 | int is_line_terminal() const { e4_assert(knownNonNull(this)); return spec.level & LEV_LINE; } |
---|
1091 | |
---|
1092 | int is_flag_header_terminal() const { e4_assert(knownNonNull(this)); return spec.level & LEV_FLAG_HEADER; } |
---|
1093 | int is_flag_terminal() const { e4_assert(knownNonNull(this)); return spec.level & LEV_FLAG; } |
---|
1094 | |
---|
1095 | int is_manager() const { e4_assert(knownNonNull(this)); return spec.static_prop & PROP_IS_MANAGER; } |
---|
1096 | |
---|
1097 | int is_sequence_manager() const { e4_assert(knownNonNull(this)); return spec.level & LEV_SEQUENCE; } |
---|
1098 | int is_multi_name_manager() const { e4_assert(knownNonNull(this)); return spec.level & LEV_MULTI_NAME; } |
---|
1099 | int is_name_manager() const { e4_assert(knownNonNull(this)); return spec.level & LEV_NAME_MANAGER; } |
---|
1100 | int is_multi_species_manager() const { e4_assert(knownNonNull(this)); return spec.level & LEV_MULTI_SPECIES; } |
---|
1101 | int is_multi_sequence_manager() const { e4_assert(knownNonNull(this)); return spec.level & LEV_MULTI_SEQUENCE; } |
---|
1102 | int is_device_manager() const { e4_assert(knownNonNull(this)); return spec.level & LEV_DEVICE; } |
---|
1103 | |
---|
1104 | int is_group_manager() const { e4_assert(knownNonNull(this)); return spec.level & LEV_GROUP; } |
---|
1105 | int is_root_group_manager() const { e4_assert(knownNonNull(this)); return spec.level & LEV_ROOTGROUP; } |
---|
1106 | int is_abstract_group_manager() const { e4_assert(knownNonNull(this)); return spec.level & (LEV_GROUP|LEV_ROOTGROUP); } |
---|
1107 | |
---|
1108 | int is_species_manager() const { e4_assert(knownNonNull(this)); return spec.level & LEV_SPECIES; } |
---|
1109 | int is_area_manager() const { e4_assert(knownNonNull(this)); return spec.level & LEV_AREA; } |
---|
1110 | |
---|
1111 | // use the following functions to cast ED4_base to derived classes: |
---|
1112 | |
---|
1113 | #define E4B_DECL_CASTOP_helper(Class,toName) \ |
---|
1114 | inline const Class *toName() const; \ |
---|
1115 | inline Class *toName(); |
---|
1116 | |
---|
1117 | #define E4B_AVOID_CAST__helper(Class,toName,isName) \ |
---|
1118 | const Class *toName() const; \ |
---|
1119 | Class *toName(); \ |
---|
1120 | int isName() const; |
---|
1121 | |
---|
1122 | #define E4B_IMPL_CASTOP_helper(Class,toName,isName) \ |
---|
1123 | const Class *ED4_base::toName() const { \ |
---|
1124 | e4_assert(isName()); \ |
---|
1125 | return DOWNCAST(const Class*, this); \ |
---|
1126 | } \ |
---|
1127 | Class *ED4_base::toName() { \ |
---|
1128 | return const_cast<Class*>(const_cast<const ED4_base*>(this)->toName()); \ |
---|
1129 | } |
---|
1130 | |
---|
1131 | #define E4B_DECL_CASTOP(name) E4B_DECL_CASTOP_helper(concat(ED4_,name), concat(to_,name)) |
---|
1132 | #define E4B_AVOID_UNNEEDED_CASTS(name) E4B_AVOID_CAST__helper(concat(ED4_,name), concat(to_,name), concat(is_,name)) |
---|
1133 | #define E4B_IMPL_CASTOP(name) E4B_IMPL_CASTOP_helper(concat(ED4_,name), concat(to_,name), concat(is_,name)) |
---|
1134 | |
---|
1135 | E4B_DECL_CASTOP(area_manager); // to_area_manager |
---|
1136 | E4B_DECL_CASTOP(abstract_group_manager); // to_abstract_group_manager |
---|
1137 | E4B_DECL_CASTOP(bracket_terminal); // to_bracket_terminal |
---|
1138 | E4B_DECL_CASTOP(columnStat_terminal); // to_columnStat_terminal |
---|
1139 | E4B_DECL_CASTOP(consensus_sequence_terminal); // to_consensus_sequence_terminal |
---|
1140 | E4B_DECL_CASTOP(device_manager); // to_device_manager |
---|
1141 | E4B_DECL_CASTOP(group_manager); // to_group_manager |
---|
1142 | E4B_DECL_CASTOP(line_terminal); // to_line_terminal |
---|
1143 | E4B_DECL_CASTOP(manager); // to_manager |
---|
1144 | E4B_DECL_CASTOP(multi_name_manager); // to_multi_name_manager |
---|
1145 | E4B_DECL_CASTOP(multi_sequence_manager); // to_multi_sequence_manager |
---|
1146 | E4B_DECL_CASTOP(multi_species_manager); // to_multi_species_manager |
---|
1147 | E4B_DECL_CASTOP(name_manager); // to_name_manager |
---|
1148 | E4B_DECL_CASTOP(orf_terminal); // to_orf_terminal |
---|
1149 | E4B_DECL_CASTOP(pure_text_terminal); // to_pure_text_terminal |
---|
1150 | E4B_DECL_CASTOP(root_group_manager); // to_root_group_manager |
---|
1151 | E4B_DECL_CASTOP(sequence_info_terminal); // to_sequence_info_terminal |
---|
1152 | E4B_DECL_CASTOP(sequence_manager); // to_sequence_manager |
---|
1153 | E4B_DECL_CASTOP(sequence_terminal); // to_sequence_terminal |
---|
1154 | E4B_DECL_CASTOP(spacer_terminal); // to_spacer_terminal |
---|
1155 | E4B_DECL_CASTOP(species_manager); // to_species_manager |
---|
1156 | E4B_DECL_CASTOP(species_name_terminal); // to_species_name_terminal |
---|
1157 | E4B_DECL_CASTOP(terminal); // to_terminal |
---|
1158 | E4B_DECL_CASTOP(text_terminal); // to_text_terminal |
---|
1159 | E4B_DECL_CASTOP(flag_header_terminal); // to_flag_header_terminal |
---|
1160 | E4B_DECL_CASTOP(flag_terminal); // to_flag_terminal |
---|
1161 | |
---|
1162 | // simple access to containing managers |
---|
1163 | inline ED4_species_manager *containing_species_manager() const; |
---|
1164 | |
---|
1165 | // discriminate between different sequence managers: |
---|
1166 | |
---|
1167 | inline bool is_consensus_manager() const; |
---|
1168 | inline bool is_SAI_manager() const; |
---|
1169 | inline bool is_species_seq_manager() const; |
---|
1170 | |
---|
1171 | inline ED4_species_type get_species_type() const; // works for all items (recursively) contained in ED4_species_manager |
---|
1172 | |
---|
1173 | inline bool inside_consensus_manager() const; |
---|
1174 | inline bool inside_SAI_manager() const; |
---|
1175 | inline bool inside_species_seq_manager() const; |
---|
1176 | |
---|
1177 | inline bool is_consensus_terminal() const; |
---|
1178 | inline bool is_SAI_terminal() const; |
---|
1179 | inline bool is_species_seq_terminal() const; |
---|
1180 | |
---|
1181 | inline bool is_consensus_sequence_terminal() const { // alias for CASTOP |
---|
1182 | return is_consensus_terminal(); |
---|
1183 | } |
---|
1184 | }; |
---|
1185 | MARK_NONFINAL_FUNCTION(ED4_base,bool,set_dynamic_size,(),false); |
---|
1186 | |
---|
1187 | DECLARE_CBTYPE_FVV_AND_BUILDERS(ED4_basePredicate, bool, ED4_base*); // generates makeED4_basePredicate |
---|
1188 | |
---|
1189 | class ED4_manager : public ED4_base, public ED4_container { // derived from a Noncopyable |
---|
1190 | ED4_cb_list<ED4_manager, ED4_managerCallback> delete_cbs; |
---|
1191 | public: |
---|
1192 | |
---|
1193 | E4B_AVOID_UNNEEDED_CASTS(manager); |
---|
1194 | DECLARE_DUMP_FOR_BASECLASS(ED4_manager, ED4_base); |
---|
1195 | |
---|
1196 | void add_delete_callback(const ED4_managerCallback& cb) { delete_cbs.add_cb(cb); } |
---|
1197 | void remove_delete_callback(const ED4_managerCallback& cb) { delete_cbs.remove_cb(cb); } |
---|
1198 | |
---|
1199 | int refresh_flag_ok(); |
---|
1200 | |
---|
1201 | void changed_by_database() OVERRIDE; |
---|
1202 | void deleted_from_database() OVERRIDE; |
---|
1203 | |
---|
1204 | // functions concerned with graphics |
---|
1205 | void Show(bool refresh_all, bool is_cleared) OVERRIDE; |
---|
1206 | bool calc_bounding_box() FINAL_OVERRIDE; |
---|
1207 | |
---|
1208 | ED4_returncode distribute_children(); |
---|
1209 | |
---|
1210 | // top-down functions, means travelling down the hierarchy |
---|
1211 | ED4_returncode event_sent_by_parent(AW_event *event, AW_window *aww) FINAL_OVERRIDE; |
---|
1212 | |
---|
1213 | void request_refresh(int clear=1) FINAL_OVERRIDE; |
---|
1214 | ED4_returncode clear_refresh(); |
---|
1215 | |
---|
1216 | void resize_requested_children() OVERRIDE; |
---|
1217 | |
---|
1218 | void update_requested_children() OVERRIDE; |
---|
1219 | |
---|
1220 | void delete_requested_children() OVERRIDE; |
---|
1221 | void Delete() FINAL_OVERRIDE; |
---|
1222 | |
---|
1223 | ED4_returncode move_requested_by_parent(ED4_move_info *mi); |
---|
1224 | |
---|
1225 | void create_consensus(ED4_abstract_group_manager *upper_group_manager, arb_progress *progress); |
---|
1226 | |
---|
1227 | ARB_ERROR route_down_hierarchy(const ED4_route_cb& cb) FINAL_OVERRIDE; |
---|
1228 | |
---|
1229 | ED4_base *find_first_that(ED4_level level, const ED4_basePredicate& fulfills_predicate); |
---|
1230 | |
---|
1231 | // bottom-up functions |
---|
1232 | ED4_returncode move_requested_by_child(ED4_move_info *moveinfo); |
---|
1233 | inline void resize_requested_by_child(); |
---|
1234 | ED4_returncode refresh_requested_by_child(); |
---|
1235 | void delete_requested_by_child(); |
---|
1236 | void update_requested_by_child(); |
---|
1237 | |
---|
1238 | ED4_base *get_defined_level(ED4_level lev) const; |
---|
1239 | |
---|
1240 | // functions referring the consensus |
---|
1241 | |
---|
1242 | void update_consensus(ED4_manager *old_parent, ED4_manager *new_parent, ED4_base *sequence); |
---|
1243 | ED4_returncode rebuild_consensi(ED4_base *start_species, ED4_update_flag update_flag); |
---|
1244 | |
---|
1245 | ED4_returncode check_in_bases(ED4_base *added_base); |
---|
1246 | ED4_returncode check_out_bases(ED4_base *subbed_base); |
---|
1247 | |
---|
1248 | ED4_returncode update_bases(const ED4_base *old_base, const ED4_base *new_base, PosRange range = PosRange::whole()); |
---|
1249 | ED4_returncode update_bases(const char *old_seq, int old_len, const char *new_seq, int new_len, PosRange range = PosRange::whole()); |
---|
1250 | ED4_returncode update_bases(const char *old_seq, int old_len, const ED4_base *new_base, PosRange range = PosRange::whole()); |
---|
1251 | ED4_returncode update_bases(const BaseFrequencies *old_table, const BaseFrequencies *new_table, PosRange range = PosRange::whole()); |
---|
1252 | |
---|
1253 | ED4_returncode update_bases_and_rebuild_consensi(const char *old_seq, int old_len, ED4_base *species, ED4_update_flag update_flag, PosRange range = PosRange::whole()); |
---|
1254 | |
---|
1255 | // handle moves across the hierarchy |
---|
1256 | ED4_returncode handle_move(ED4_move_info *moveinfo); |
---|
1257 | |
---|
1258 | ED4_base *get_competent_child(AW_pos x, AW_pos y, ED4_properties relevant_prop); |
---|
1259 | ED4_base *get_competent_clicked_child(AW_pos x, AW_pos y, ED4_properties relevant_prop); |
---|
1260 | ED4_base *search_spec_child_rek(ED4_level level); // recursive search for level |
---|
1261 | |
---|
1262 | // general purpose functions |
---|
1263 | ED4_base *search_ID(const char *id) FINAL_OVERRIDE; |
---|
1264 | void remove_callbacks() OVERRIDE; |
---|
1265 | |
---|
1266 | ED4_terminal *get_first_terminal(int start_index=0) const; |
---|
1267 | ED4_terminal *get_last_terminal(int start_index=-1) const; |
---|
1268 | |
---|
1269 | void hide_children(); |
---|
1270 | void unhide_children(); |
---|
1271 | |
---|
1272 | bool is_hidden() const FINAL_OVERRIDE { |
---|
1273 | if (flag.hidden) return true; |
---|
1274 | if (!parent) return false; |
---|
1275 | return parent->is_hidden(); |
---|
1276 | } |
---|
1277 | |
---|
1278 | ED4_manager(const ED4_objspec& spec_, const char *id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
1279 | ~ED4_manager() OVERRIDE; |
---|
1280 | }; |
---|
1281 | MARK_NONFINAL_METHOD(ED4_manager,update_requested_children,()); |
---|
1282 | MARK_NONFINAL_METHOD(ED4_manager,delete_requested_children,()); |
---|
1283 | |
---|
1284 | class ED4_terminal : public ED4_base { // derived from a Noncopyable |
---|
1285 | E4B_AVOID_UNNEEDED_CASTS(terminal); |
---|
1286 | |
---|
1287 | public: |
---|
1288 | |
---|
1289 | struct { unsigned int deleted : 1; } tflag; // @@@ go bool |
---|
1290 | |
---|
1291 | long curr_timestamp; |
---|
1292 | |
---|
1293 | DECLARE_DUMP_FOR_BASECLASS(ED4_terminal,ED4_base); |
---|
1294 | |
---|
1295 | // callbacks |
---|
1296 | |
---|
1297 | void changed_by_database() OVERRIDE; |
---|
1298 | void deleted_from_database() OVERRIDE; |
---|
1299 | |
---|
1300 | // functions concerning graphic output |
---|
1301 | void Show(bool refresh_all, bool is_cleared) OVERRIDE; |
---|
1302 | virtual void draw() = 0; |
---|
1303 | |
---|
1304 | bool calc_bounding_box() FINAL_OVERRIDE; |
---|
1305 | |
---|
1306 | ED4_returncode draw_drag_box(AW_pos x, AW_pos y, GB_CSTR text = NULp, int cursor_y=-1); |
---|
1307 | |
---|
1308 | // functions which concern the object as a child |
---|
1309 | void request_refresh(int clear=1) FINAL_OVERRIDE; |
---|
1310 | |
---|
1311 | void resize_requested_children() OVERRIDE; |
---|
1312 | |
---|
1313 | void update_requested_children() OVERRIDE; |
---|
1314 | void delete_requested_children() OVERRIDE; |
---|
1315 | void Delete() OVERRIDE; |
---|
1316 | |
---|
1317 | ED4_returncode event_sent_by_parent(AW_event *event, AW_window *aww) OVERRIDE; |
---|
1318 | |
---|
1319 | ED4_returncode kill_object(); |
---|
1320 | |
---|
1321 | // general purpose functions |
---|
1322 | ED4_base *search_ID(const char *id) OVERRIDE; |
---|
1323 | char *resolve_pointer_to_string_copy(int *str_len = NULp) const FINAL_OVERRIDE; |
---|
1324 | const char *resolve_pointer_to_char_pntr(int *str_len = NULp) const FINAL_OVERRIDE; |
---|
1325 | void remove_callbacks() FINAL_OVERRIDE; |
---|
1326 | |
---|
1327 | GB_ERROR write_sequence(const char *seq, int seq_len); |
---|
1328 | |
---|
1329 | void scroll_into_view(ED4_window *ed4w); |
---|
1330 | inline bool setCursorTo(ED4_cursor *cursor, int seq_pos, bool unfoldGroups, ED4_CursorJumpType jump_type); |
---|
1331 | |
---|
1332 | bool is_hidden() const FINAL_OVERRIDE { return parent && parent->is_hidden(); } |
---|
1333 | |
---|
1334 | ED4_terminal(const ED4_objspec& spec_, GB_CSTR id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
1335 | ~ED4_terminal() OVERRIDE; |
---|
1336 | }; |
---|
1337 | MARK_NONFINAL_METHOD(ED4_terminal,Show,(bool,bool)); |
---|
1338 | |
---|
1339 | enum ED4_species_mode { |
---|
1340 | ED4_SM_MOVE, |
---|
1341 | ED4_SM_KILL, |
---|
1342 | ED4_SM_MARK, |
---|
1343 | ED4_SM_INFO // same functionality as AWT_MODE_INFO |
---|
1344 | }; |
---|
1345 | |
---|
1346 | class ED4_reference_terminals : virtual Noncopyable { |
---|
1347 | ED4_sequence_info_terminal *ref_sequence_info; |
---|
1348 | ED4_sequence_terminal *ref_sequence; |
---|
1349 | ED4_sequence_info_terminal *ref_column_stat_info; |
---|
1350 | ED4_columnStat_terminal *ref_column_stat; |
---|
1351 | |
---|
1352 | void null() { ref_sequence_info = NULp; ref_sequence = NULp; ref_column_stat = NULp; ref_column_stat_info = NULp; } |
---|
1353 | public: |
---|
1354 | void clear(); |
---|
1355 | void init(ED4_sequence_info_terminal *, ED4_sequence_terminal *, ED4_sequence_info_terminal *, ED4_columnStat_terminal *); |
---|
1356 | |
---|
1357 | ED4_sequence_terminal *sequence() { return ref_sequence; } |
---|
1358 | ED4_sequence_info_terminal *sequence_info() { return ref_sequence_info; } |
---|
1359 | ED4_columnStat_terminal *column_stat() { return ref_column_stat; } |
---|
1360 | ED4_sequence_info_terminal *column_stat_info() { return ref_column_stat_info; } |
---|
1361 | |
---|
1362 | ED4_reference_terminals() { null(); } |
---|
1363 | ~ED4_reference_terminals() { clear(); } |
---|
1364 | }; |
---|
1365 | |
---|
1366 | class ED4_WinContext { |
---|
1367 | ED4_window *ed4w; |
---|
1368 | AW_device *device; |
---|
1369 | |
---|
1370 | bool is_set() const { return ed4w; } |
---|
1371 | void init(ED4_window *ew) { |
---|
1372 | e4_assert(ew); |
---|
1373 | ed4w = ew; |
---|
1374 | device = ed4w->get_device(); |
---|
1375 | } |
---|
1376 | |
---|
1377 | void warn_missing_context() const; |
---|
1378 | void expect_context() const { if (!is_set()) warn_missing_context(); } |
---|
1379 | |
---|
1380 | protected: |
---|
1381 | ED4_WinContext() : ed4w(NULp), device(NULp) {} |
---|
1382 | static ED4_WinContext current_context; |
---|
1383 | |
---|
1384 | public: |
---|
1385 | inline ED4_WinContext(AW_window *aww_); |
---|
1386 | ED4_WinContext(ED4_window *ed4w_) { init(ed4w_); } |
---|
1387 | |
---|
1388 | AW_device *get_device() const { expect_context(); return device; } |
---|
1389 | ED4_window *get_ed4w() const { expect_context(); return ed4w; } |
---|
1390 | |
---|
1391 | static const ED4_WinContext& get_current_context() { return current_context; } |
---|
1392 | static bool have_context() { return current_context.is_set(); } |
---|
1393 | }; |
---|
1394 | |
---|
1395 | // accessors for current context (see also ED4_WinContextFree) |
---|
1396 | inline AW_device *current_device() { return ED4_WinContext::get_current_context().get_device(); } |
---|
1397 | inline ED4_window *current_ed4w() { return ED4_WinContext::get_current_context().get_ed4w(); } |
---|
1398 | inline AW_window *current_aww() { return current_ed4w()->aww; } |
---|
1399 | inline ED4_cursor& current_cursor() { return current_ed4w()->cursor; } |
---|
1400 | |
---|
1401 | enum LoadableSaiState { |
---|
1402 | LSAI_UNUSED, |
---|
1403 | LSAI_UPTODATE, |
---|
1404 | LSAI_OUTDATED, |
---|
1405 | }; |
---|
1406 | |
---|
1407 | class ED4_root : virtual Noncopyable { |
---|
1408 | void ED4_ROOT() const { e4_assert(0); } // avoid ED4_root-members use global ED4_ROOT |
---|
1409 | |
---|
1410 | void refresh_window_simple(bool redraw); |
---|
1411 | void handle_update_requests(bool& redraw); |
---|
1412 | |
---|
1413 | ED4_window *most_recently_used_window; |
---|
1414 | ConsensusBuildParams *cons_param; |
---|
1415 | |
---|
1416 | GBDATA *gb_main; |
---|
1417 | |
---|
1418 | public: |
---|
1419 | |
---|
1420 | GBDATA *get_gb_main() const { return gb_main; } |
---|
1421 | |
---|
1422 | char *db_name; // name of Default Properties database (complete path) |
---|
1423 | AW_root *aw_root; // Points to 'AW-Window-Controller' |
---|
1424 | AW_default props_db; // Default Properties database |
---|
1425 | |
---|
1426 | ED4_window *first_window; // Points to List of Main Windows of ED4 |
---|
1427 | ED4_main_manager *main_manager; // Points to Main manager of ED4 |
---|
1428 | ED4_area_manager *middle_area_man; // Points to middle area |
---|
1429 | ED4_area_manager *top_area_man; |
---|
1430 | ED4_root_group_manager *root_group_man; |
---|
1431 | ED4_selected_list *selected_objects; |
---|
1432 | ED4_scroll_links scroll_links; |
---|
1433 | bool folding_action; // flag tells whether action was folding action or not |
---|
1434 | ED4_reference_terminals ref_terminals; |
---|
1435 | ED4_species_mode species_mode; |
---|
1436 | ED4_scroll_picture scroll_picture; |
---|
1437 | BI_ecoli_ref *ecoli_ref; |
---|
1438 | char *alignment_name; |
---|
1439 | GB_alignment_type alignment_type; |
---|
1440 | ED4_reference *reference; |
---|
1441 | ED4_seq_colors *sequence_colors; |
---|
1442 | AW_gc_manager *gc_manager; |
---|
1443 | ST_ML *st_ml; |
---|
1444 | AW_helix *helix; |
---|
1445 | int helix_spacing; |
---|
1446 | long helix_add_spacing; |
---|
1447 | long terminal_add_spacing; |
---|
1448 | char *protstruct; // protein structure summary |
---|
1449 | long protstruct_len; // protein structure summary |
---|
1450 | ed_key *edk; |
---|
1451 | |
---|
1452 | bool column_stat_activated; |
---|
1453 | bool column_stat_initialized; |
---|
1454 | bool visualizeSAI; |
---|
1455 | bool visualizeSAI_allSpecies; |
---|
1456 | |
---|
1457 | const ConsensusBuildParams& get_consensus_params(); |
---|
1458 | void reset_consensus_params(); |
---|
1459 | |
---|
1460 | LoadableSaiState loadable_SAIs; // maintain proper refresh of list of loadable SAIs |
---|
1461 | void loadable_SAIs_may_have_changed() { if (loadable_SAIs == LSAI_UPTODATE) loadable_SAIs = LSAI_OUTDATED; } |
---|
1462 | |
---|
1463 | int temp_gc; |
---|
1464 | AW_font_group font_group; |
---|
1465 | |
---|
1466 | void announce_useraction_in(AW_window *aww); |
---|
1467 | ED4_window *get_most_recently_used_window() const { |
---|
1468 | e4_assert(most_recently_used_window); |
---|
1469 | return most_recently_used_window; |
---|
1470 | } |
---|
1471 | |
---|
1472 | inline ED4_device_manager *get_device_manager(); |
---|
1473 | |
---|
1474 | // Initializing functions |
---|
1475 | ED4_returncode create_hierarchy(const char *area_string_middle, const char *area_string_top); |
---|
1476 | ARB_ERROR init_alignment(); |
---|
1477 | void recalc_font_group(); |
---|
1478 | |
---|
1479 | AW_window *create_first_window(); |
---|
1480 | ED4_returncode generate_window(AW_device **device, ED4_window **new_window); |
---|
1481 | void copy_window_struct(ED4_window *source, ED4_window *destination); |
---|
1482 | |
---|
1483 | // functions concerned with global refresh and resize |
---|
1484 | void resize_all_requesting_childs(); |
---|
1485 | |
---|
1486 | void special_window_refresh(bool handle_updates); |
---|
1487 | ED4_returncode refresh_all_windows(bool redraw); |
---|
1488 | |
---|
1489 | void request_refresh_for_all_terminals(); |
---|
1490 | void request_refresh_for_specific_terminals(ED4_level lev); |
---|
1491 | void request_refresh_for_consensus_terminals(); |
---|
1492 | void request_refresh_for_sequence_terminals(); |
---|
1493 | |
---|
1494 | inline void announce_deletion(ED4_base *object); // before deleting an object, use this to announce |
---|
1495 | |
---|
1496 | // functions concerned with list of selected objects |
---|
1497 | ED4_returncode add_to_selected(ED4_species_name_terminal *object); |
---|
1498 | void remove_from_selected(ED4_species_name_terminal *object); |
---|
1499 | ED4_returncode deselect_all(); |
---|
1500 | |
---|
1501 | ED4_returncode get_area_rectangle(AW_screen_area *rect, AW_pos x, AW_pos y); |
---|
1502 | |
---|
1503 | ED4_index pixel2pos(AW_pos click_x); |
---|
1504 | |
---|
1505 | void remove_all_callbacks(); |
---|
1506 | |
---|
1507 | ED4_root(GBDATA *gb_main_); |
---|
1508 | ~ED4_root(); |
---|
1509 | }; |
---|
1510 | |
---|
1511 | ED4_WinContext::ED4_WinContext(AW_window *aww_) { init(ED4_ROOT->first_window->get_matching_ed4w(aww_)); } |
---|
1512 | |
---|
1513 | struct ED4_LocalWinContext : private ED4_WinContext { |
---|
1514 | ED4_LocalWinContext(AW_window *aww) : ED4_WinContext(current_context) { current_context = ED4_WinContext(aww); } |
---|
1515 | ED4_LocalWinContext(ED4_window *ew) : ED4_WinContext(current_context) { current_context = ED4_WinContext(ew); } |
---|
1516 | ~ED4_LocalWinContext() { current_context = *this; } |
---|
1517 | }; |
---|
1518 | |
---|
1519 | class ED4_MostRecentWinContext : virtual Noncopyable { |
---|
1520 | ED4_LocalWinContext *most_recent; |
---|
1521 | public: |
---|
1522 | ED4_MostRecentWinContext() : most_recent(NULp) { |
---|
1523 | if (!ED4_WinContext::have_context()) { |
---|
1524 | most_recent = new ED4_LocalWinContext(ED4_ROOT->get_most_recently_used_window()); |
---|
1525 | } |
---|
1526 | } |
---|
1527 | ~ED4_MostRecentWinContext() { |
---|
1528 | delete most_recent; |
---|
1529 | } |
---|
1530 | }; |
---|
1531 | |
---|
1532 | inline void ED4_root::announce_deletion(ED4_base *object) { |
---|
1533 | if (object->is_terminal()) { |
---|
1534 | ED4_terminal *term = object->to_terminal(); |
---|
1535 | for (ED4_window *win = first_window; win; win = win->next) { |
---|
1536 | ED4_LocalWinContext uses(win); |
---|
1537 | win->announce_deletion(term); |
---|
1538 | } |
---|
1539 | } |
---|
1540 | } |
---|
1541 | |
---|
1542 | // ------------------------ |
---|
1543 | // manager classes |
---|
1544 | // |
---|
1545 | // All manager classes only differ in their static properties. |
---|
1546 | // This kind of construction was chosen for using a minimum of RAM |
---|
1547 | |
---|
1548 | class ED4_main_manager FINAL_TYPE : public ED4_manager { // derived from a Noncopyable |
---|
1549 | // first in hierarchy |
---|
1550 | |
---|
1551 | E4B_AVOID_UNNEEDED_CASTS(main_manager); |
---|
1552 | |
---|
1553 | // these terminals are redrawn after refresh (with increase clipping area) |
---|
1554 | // to revert text from middle area drawn into top area: |
---|
1555 | ED4_terminal *top_middle_line; |
---|
1556 | ED4_terminal *top_middle_spacer; |
---|
1557 | |
---|
1558 | public: |
---|
1559 | ED4_main_manager(const char *id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
1560 | |
---|
1561 | void set_top_middle_spacer_terminal(ED4_terminal *top_middle_spacer_) { top_middle_spacer = top_middle_spacer_; } |
---|
1562 | void set_top_middle_line_terminal(ED4_terminal *top_middle_line_) { top_middle_line = top_middle_line_; } |
---|
1563 | |
---|
1564 | ED4_terminal *get_top_middle_spacer_terminal() const { return top_middle_spacer; } |
---|
1565 | ED4_terminal *get_top_middle_line_terminal() const { return top_middle_line; } |
---|
1566 | |
---|
1567 | DECLARE_DUMP_FOR_LEAFCLASS(ED4_manager); |
---|
1568 | |
---|
1569 | void Show(bool refresh_all, bool is_cleared) OVERRIDE; |
---|
1570 | void resize_requested_children() OVERRIDE; |
---|
1571 | |
---|
1572 | void clear_whole_background(); |
---|
1573 | }; |
---|
1574 | |
---|
1575 | struct ED4_device_manager : public ED4_manager { |
---|
1576 | E4B_AVOID_UNNEEDED_CASTS(device_manager); |
---|
1577 | ED4_device_manager (const char *id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
1578 | DECLARE_DUMP_FOR_LEAFCLASS(ED4_manager); |
---|
1579 | }; |
---|
1580 | |
---|
1581 | struct ED4_area_manager : public ED4_manager { |
---|
1582 | E4B_AVOID_UNNEEDED_CASTS(area_manager); |
---|
1583 | ED4_area_manager(const char *id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
1584 | DECLARE_DUMP_FOR_LEAFCLASS(ED4_manager); |
---|
1585 | |
---|
1586 | ED4_multi_species_manager *get_multi_species_manager() const { |
---|
1587 | return get_defined_level(LEV_MULTI_SPECIES)->to_multi_species_manager(); |
---|
1588 | } |
---|
1589 | }; |
---|
1590 | |
---|
1591 | class ED4_multi_species_manager : public ED4_manager { |
---|
1592 | E4B_AVOID_UNNEEDED_CASTS(multi_species_manager); |
---|
1593 | |
---|
1594 | int species; // # of species (-1 == unknown) |
---|
1595 | int selected_species; // # of selected species (-1 == unknown) |
---|
1596 | |
---|
1597 | void set_species_counters(int no_of_species, int no_of_selected); |
---|
1598 | #ifdef DEBUG |
---|
1599 | void count_species(int *speciesPtr, int *selectedPtr) const; |
---|
1600 | #endif |
---|
1601 | void update_species_counters(); |
---|
1602 | |
---|
1603 | public: |
---|
1604 | ED4_multi_species_manager(const char *id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
1605 | |
---|
1606 | DECLARE_DUMP_FOR_LEAFCLASS(ED4_manager); |
---|
1607 | |
---|
1608 | void update_requested_children() OVERRIDE; |
---|
1609 | void delete_requested_children() OVERRIDE; |
---|
1610 | |
---|
1611 | int count_visible_children(); // is called by a multi_species_manager |
---|
1612 | |
---|
1613 | ED4_species_manager *get_consensus_manager() const; // returns the consensus-manager or NULp |
---|
1614 | ED4_species_name_terminal *get_consensus_name_terminal() const; // returns the consensus-name-terminal or NULp |
---|
1615 | |
---|
1616 | // functions concerned with selection |
---|
1617 | int get_no_of_selected_species(); |
---|
1618 | int get_no_of_species(); |
---|
1619 | |
---|
1620 | void update_group_id(); |
---|
1621 | |
---|
1622 | void invalidate_species_counters(); |
---|
1623 | int has_valid_counters() const { return species != -1 && selected_species!=-1; } |
---|
1624 | bool all_are_selected() const { e4_assert(has_valid_counters()); return species == selected_species; } |
---|
1625 | |
---|
1626 | void select_all(bool only_species); |
---|
1627 | void deselect_all_species_and_SAI(); |
---|
1628 | void invert_selection_of_all_species(); |
---|
1629 | void marked_species_select(bool select); |
---|
1630 | void selected_species_mark(bool mark); |
---|
1631 | |
---|
1632 | void toggle_selected_species(); |
---|
1633 | }; |
---|
1634 | |
---|
1635 | class ED4_abstract_group_manager : public ED4_manager { |
---|
1636 | E4B_AVOID_UNNEEDED_CASTS(abstract_group_manager); |
---|
1637 | protected: |
---|
1638 | BaseFrequencies my_table; // table concerning Consensusfunction |
---|
1639 | |
---|
1640 | public: |
---|
1641 | ED4_abstract_group_manager(const ED4_objspec& spec_, const char *id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
1642 | |
---|
1643 | DECLARE_DUMP_FOR_BASECLASS(ED4_abstract_group_manager, ED4_manager); |
---|
1644 | |
---|
1645 | BaseFrequencies& table() { return my_table; } |
---|
1646 | const BaseFrequencies& table() const { return my_table; } |
---|
1647 | |
---|
1648 | ED4_multi_species_manager *get_multi_species_manager() const { |
---|
1649 | return get_defined_level(LEV_MULTI_SPECIES)->to_multi_species_manager(); |
---|
1650 | } |
---|
1651 | |
---|
1652 | char *build_consensus_string(PosRange range) const { return table().build_consensus_string(range, ED4_ROOT->get_consensus_params()); } |
---|
1653 | char *build_consensus_string(int *cons_length = NULp) const { |
---|
1654 | if (cons_length) *cons_length = table().size(); |
---|
1655 | return table().build_consensus_string(ED4_ROOT->get_consensus_params()); |
---|
1656 | } |
---|
1657 | }; |
---|
1658 | |
---|
1659 | struct ED4_group_manager : public ED4_abstract_group_manager { |
---|
1660 | E4B_AVOID_UNNEEDED_CASTS(group_manager); |
---|
1661 | ED4_group_manager(const char *id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
1662 | DECLARE_DUMP_FOR_LEAFCLASS(ED4_abstract_group_manager); |
---|
1663 | void reinit_char_table(); |
---|
1664 | |
---|
1665 | void fold(); |
---|
1666 | void unfold(); |
---|
1667 | void toggle_folding(); |
---|
1668 | }; |
---|
1669 | |
---|
1670 | enum ED4_remap_mode { |
---|
1671 | ED4_RM_NONE, // no remapping (normal mode = 'show all gaps') |
---|
1672 | ED4_RM_SHOW_ABOVE, // Show all positions, where xxx% of all edited sequences have any base |
---|
1673 | ED4_RM_MAX_ALIGN, // ------------------------- any edited sequence has a base |
---|
1674 | ED4_RM_MAX_EDIT, // like ED4_RM_MAX_ALIGN, but bases are pushed OVER remapped gaps (not INTO) |
---|
1675 | ED4_RM_DYNAMIC_GAPS, // gaps shown as spaces (more gaps => more spaces) |
---|
1676 | |
---|
1677 | ED4_RM_MODES |
---|
1678 | |
---|
1679 | }; |
---|
1680 | |
---|
1681 | class ED4_remap : virtual Noncopyable { |
---|
1682 | |
---|
1683 | ED4_remap_mode mode; |
---|
1684 | int show_above_percent; // used only for ED4_RM_SHOW_ABOVE |
---|
1685 | |
---|
1686 | size_t sequence_table_len; // allocated size of sequence_to_screen_tab |
---|
1687 | size_t screen_table_len; // allocated size of screen_to_sequence_tab |
---|
1688 | |
---|
1689 | size_t sequence_len; // size of recently compiled part of sequence_to_screen_tab |
---|
1690 | size_t screen_len; // size of recently compiled part of screen_to_sequence_tab |
---|
1691 | |
---|
1692 | int *screen_to_sequence_tab; |
---|
1693 | int *sequence_to_screen_tab; // <0 means position is not mapped (last displayed sequence position); 0 may be mapped or not; see is_shown() below |
---|
1694 | |
---|
1695 | bool update_needed; // remapping should be recompiled |
---|
1696 | |
---|
1697 | inline void set_sequence_to_screen(int pos, int newVal, bool& mapping_changed); |
---|
1698 | |
---|
1699 | public: |
---|
1700 | |
---|
1701 | ED4_remap(); |
---|
1702 | ~ED4_remap(); |
---|
1703 | |
---|
1704 | int screen_to_sequence(int screen_pos) const; |
---|
1705 | |
---|
1706 | int sequence_to_screen_PLAIN(int sequence_pos) const { |
---|
1707 | e4_assert(sequence_pos>=0 && size_t(sequence_pos)<=sequence_len); |
---|
1708 | return sequence_to_screen_tab[sequence_pos]; |
---|
1709 | } |
---|
1710 | int shown_sequence_to_screen(int sequence_pos) const { |
---|
1711 | // as well works for sequence_pos == MAXSEQUENCECHARACTERLENGTH |
---|
1712 | int screen_pos = sequence_to_screen_PLAIN(sequence_pos); |
---|
1713 | e4_assert(screen_pos >= 0); // sequence_pos expected to be visible (i.e. not folded away) |
---|
1714 | return screen_pos; |
---|
1715 | } |
---|
1716 | |
---|
1717 | int clipped_sequence_to_screen_PLAIN(int sequence_pos) const; |
---|
1718 | int sequence_to_screen(int sequence_pos) const; |
---|
1719 | |
---|
1720 | PosRange sequence_to_screen(PosRange range) const { |
---|
1721 | e4_assert(!range.is_empty()); |
---|
1722 | return PosRange(sequence_to_screen(range.start()), sequence_to_screen(range.end())); |
---|
1723 | } |
---|
1724 | PosRange screen_to_sequence(PosRange range) const { |
---|
1725 | e4_assert(!range.is_empty()); |
---|
1726 | if (range.is_unlimited()) return PosRange::from(screen_to_sequence(range.start())); |
---|
1727 | return PosRange(screen_to_sequence(range.start()), screen_to_sequence(range.end())); |
---|
1728 | } |
---|
1729 | |
---|
1730 | size_t get_max_screen_pos() const { return screen_len-1; } |
---|
1731 | |
---|
1732 | void adjacent_screen_positions(int seq_pos, int& screen_pos_left, int& screen_pos_right); |
---|
1733 | |
---|
1734 | ED4_remap_mode get_mode() const { return mode; } |
---|
1735 | void set_mode(ED4_remap_mode Mode, int above_percent) { |
---|
1736 | if (Mode<0 || Mode>=ED4_RM_MODES) { |
---|
1737 | Mode = ED4_RM_NONE; |
---|
1738 | } |
---|
1739 | if (mode!=Mode) { |
---|
1740 | mode = Mode; |
---|
1741 | update_needed = true; |
---|
1742 | } |
---|
1743 | |
---|
1744 | if (show_above_percent!=above_percent) { |
---|
1745 | show_above_percent = above_percent; |
---|
1746 | if (mode==ED4_RM_SHOW_ABOVE) { |
---|
1747 | update_needed = true; |
---|
1748 | } |
---|
1749 | } |
---|
1750 | } |
---|
1751 | |
---|
1752 | void mark_compile_needed(); // recompile if mode != none |
---|
1753 | void mark_compile_needed_force(); // always recompile |
---|
1754 | bool compile_needed() const { return update_needed; } |
---|
1755 | |
---|
1756 | bool compile(ED4_root_group_manager *gm); // returns true if mapping did change |
---|
1757 | |
---|
1758 | bool is_shown(int seq_pos) const { |
---|
1759 | int scr_pos = sequence_to_screen_PLAIN(seq_pos); |
---|
1760 | if (scr_pos<0) return false; |
---|
1761 | if (scr_pos>0) return true; |
---|
1762 | |
---|
1763 | int seq_pos2 = screen_to_sequence_tab[0]; |
---|
1764 | return seq_pos == seq_pos2; |
---|
1765 | } |
---|
1766 | |
---|
1767 | ExplicitRange clip_screen_range(PosRange screen_range) const { return ExplicitRange(screen_range, screen_len-1); } |
---|
1768 | }; |
---|
1769 | |
---|
1770 | class ED4_root_group_manager : public ED4_abstract_group_manager { |
---|
1771 | E4B_AVOID_UNNEEDED_CASTS(root_group_manager); |
---|
1772 | ED4_remap my_remap; |
---|
1773 | public: |
---|
1774 | ED4_root_group_manager(const char *id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
1775 | |
---|
1776 | bool update_remap(); // 'true' if mapping has changed |
---|
1777 | |
---|
1778 | const ED4_remap *remap() const { return &my_remap; } |
---|
1779 | ED4_remap *remap() { return &my_remap; } |
---|
1780 | |
---|
1781 | void Show(bool refresh_all, bool is_cleared) OVERRIDE; |
---|
1782 | void resize_requested_children() OVERRIDE; |
---|
1783 | |
---|
1784 | DECLARE_DUMP_FOR_LEAFCLASS(ED4_abstract_group_manager); |
---|
1785 | }; |
---|
1786 | |
---|
1787 | class ED4_species_manager FINAL_TYPE : public ED4_manager { |
---|
1788 | E4B_AVOID_UNNEEDED_CASTS(species_manager); |
---|
1789 | |
---|
1790 | ED4_cb_list<ED4_species_manager, ED4_species_managerCallback> changed_cbs; // called when sequence changes |
---|
1791 | |
---|
1792 | ED4_species_type type; |
---|
1793 | bool selected; |
---|
1794 | |
---|
1795 | public: |
---|
1796 | ED4_species_manager(ED4_species_type type_, const char *id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
1797 | ~ED4_species_manager() OVERRIDE; |
---|
1798 | |
---|
1799 | DECLARE_DUMP_FOR_LEAFCLASS(ED4_manager); |
---|
1800 | |
---|
1801 | ED4_species_type get_type() const { return type; } |
---|
1802 | |
---|
1803 | bool is_selected() const { return selected; } |
---|
1804 | void set_selected(bool select) { |
---|
1805 | // e4_assert(type != ED4_SP_CONSENSUS); // it's not allowed to select a consensus // @@@ happens atm when moving a group |
---|
1806 | selected = select; |
---|
1807 | } |
---|
1808 | |
---|
1809 | bool setCursorTo(ED4_cursor *cursor, int seq_pos, bool unfold_groups, ED4_CursorJumpType jump_type); |
---|
1810 | |
---|
1811 | void add_sequence_changed_cb(const ED4_species_managerCallback& cb) { changed_cbs.add_cb(cb); } |
---|
1812 | void remove_sequence_changed_cb(const ED4_species_managerCallback& cb) { changed_cbs.remove_cb(cb); } |
---|
1813 | void do_callbacks() { changed_cbs.call(this); } |
---|
1814 | |
---|
1815 | ED4_species_name_terminal *get_name_terminal() const { return member(0)->to_species_name_terminal(); } |
---|
1816 | }; |
---|
1817 | |
---|
1818 | inline ED4_manager *ED4_base::get_parent(ED4_level lev) const { |
---|
1819 | ED4_manager *temp_parent = parent; |
---|
1820 | while (temp_parent && !(temp_parent->spec.level & lev)) { |
---|
1821 | temp_parent = temp_parent->parent; |
---|
1822 | } |
---|
1823 | return temp_parent; |
---|
1824 | } |
---|
1825 | |
---|
1826 | |
---|
1827 | inline ED4_species_manager *ED4_base::containing_species_manager() const { |
---|
1828 | ED4_base *sman = get_parent(LEV_SPECIES); |
---|
1829 | return sman ? sman->to_species_manager() : NULp; |
---|
1830 | } |
---|
1831 | |
---|
1832 | inline bool ED4_base::is_consensus_manager() const { return is_species_manager() && to_species_manager()->get_type() == ED4_SP_CONSENSUS; } |
---|
1833 | inline bool ED4_base::is_SAI_manager() const { return is_species_manager() && to_species_manager()->get_type() == ED4_SP_SAI; } |
---|
1834 | inline bool ED4_base::is_species_seq_manager() const { return is_species_manager() && to_species_manager()->get_type() == ED4_SP_SPECIES; } |
---|
1835 | |
---|
1836 | inline ED4_species_type ED4_base::get_species_type() const { |
---|
1837 | ED4_species_manager *sman = containing_species_manager(); |
---|
1838 | return sman ? sman->get_type() : ED4_SP_NONE; |
---|
1839 | } |
---|
1840 | |
---|
1841 | inline bool ED4_base::inside_consensus_manager() const { return get_species_type() == ED4_SP_CONSENSUS; } |
---|
1842 | inline bool ED4_base::inside_SAI_manager() const { return get_species_type() == ED4_SP_SAI; } |
---|
1843 | inline bool ED4_base::inside_species_seq_manager() const { return get_species_type() == ED4_SP_SPECIES; } |
---|
1844 | |
---|
1845 | inline bool ED4_base::is_consensus_terminal() const { return is_sequence_terminal() && inside_consensus_manager(); } |
---|
1846 | inline bool ED4_base::is_SAI_terminal() const { return is_sequence_terminal() && inside_SAI_manager(); } |
---|
1847 | inline bool ED4_base::is_species_seq_terminal() const { return is_sequence_terminal() && inside_species_seq_manager(); } |
---|
1848 | |
---|
1849 | inline bool ED4_cursor::in_species_seq_terminal() const { return owner_of_cursor && owner_of_cursor->is_species_seq_terminal(); } |
---|
1850 | inline bool ED4_cursor::in_consensus_terminal() const { return owner_of_cursor && owner_of_cursor->is_consensus_terminal(); } |
---|
1851 | inline bool ED4_cursor::in_SAI_terminal() const { return owner_of_cursor && owner_of_cursor->is_SAI_terminal(); } |
---|
1852 | |
---|
1853 | |
---|
1854 | struct ED4_multi_sequence_manager : public ED4_manager { |
---|
1855 | E4B_AVOID_UNNEEDED_CASTS(multi_sequence_manager); |
---|
1856 | ED4_multi_sequence_manager(const char *id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
1857 | DECLARE_DUMP_FOR_LEAFCLASS(ED4_manager); |
---|
1858 | }; |
---|
1859 | |
---|
1860 | struct ED4_sequence_manager : public ED4_manager { |
---|
1861 | E4B_AVOID_UNNEEDED_CASTS(sequence_manager); |
---|
1862 | ED4_sequence_manager(const char *id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
1863 | DECLARE_DUMP_FOR_LEAFCLASS(ED4_manager); |
---|
1864 | }; |
---|
1865 | |
---|
1866 | struct ED4_multi_name_manager : public ED4_manager { |
---|
1867 | E4B_AVOID_UNNEEDED_CASTS(multi_name_manager); |
---|
1868 | // member of ED4_species_manager (contains ED4_name_manager for name and info) |
---|
1869 | ED4_multi_name_manager(const char *id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
1870 | DECLARE_DUMP_FOR_LEAFCLASS(ED4_manager); |
---|
1871 | }; |
---|
1872 | |
---|
1873 | |
---|
1874 | struct ED4_name_manager : public ED4_manager { |
---|
1875 | E4B_AVOID_UNNEEDED_CASTS(name_manager); |
---|
1876 | // member of ED4_multi_name_manager (contains speciesname or other info concerning the species) |
---|
1877 | ED4_name_manager(const char *id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
1878 | DECLARE_DUMP_FOR_LEAFCLASS(ED4_manager); |
---|
1879 | }; |
---|
1880 | |
---|
1881 | |
---|
1882 | // ------------------------- |
---|
1883 | // terminal classes |
---|
1884 | |
---|
1885 | |
---|
1886 | struct ED4_tree_terminal FINAL_TYPE : public ED4_terminal { |
---|
1887 | E4B_AVOID_UNNEEDED_CASTS(tree_terminal); |
---|
1888 | |
---|
1889 | void draw() OVERRIDE; |
---|
1890 | |
---|
1891 | ED4_tree_terminal(const char *id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
1892 | |
---|
1893 | DECLARE_DUMP_FOR_LEAFCLASS(ED4_terminal); |
---|
1894 | }; |
---|
1895 | |
---|
1896 | struct ED4_bracket_terminal : public ED4_terminal { |
---|
1897 | E4B_AVOID_UNNEEDED_CASTS(bracket_terminal); |
---|
1898 | |
---|
1899 | void draw() OVERRIDE; |
---|
1900 | |
---|
1901 | void toggle_folding(); |
---|
1902 | |
---|
1903 | ED4_bracket_terminal(const char *id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
1904 | |
---|
1905 | DECLARE_DUMP_FOR_LEAFCLASS(ED4_terminal); |
---|
1906 | }; |
---|
1907 | |
---|
1908 | struct ED4_text_terminal : public ED4_terminal { |
---|
1909 | E4B_AVOID_UNNEEDED_CASTS(text_terminal); |
---|
1910 | |
---|
1911 | // functions concerning graphic output |
---|
1912 | void draw() OVERRIDE; |
---|
1913 | |
---|
1914 | virtual int get_length() const = 0; |
---|
1915 | void deleted_from_database() OVERRIDE; |
---|
1916 | |
---|
1917 | ED4_text_terminal(const ED4_objspec& spec_, GB_CSTR id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
1918 | ~ED4_text_terminal() OVERRIDE {} |
---|
1919 | |
---|
1920 | DECLARE_DUMP_FOR_BASECLASS(ED4_text_terminal, ED4_terminal); |
---|
1921 | }; |
---|
1922 | |
---|
1923 | class ED4_abstract_sequence_terminal : public ED4_text_terminal { // derived from a Noncopyable |
---|
1924 | |
---|
1925 | PosRange pixel2index(PosRange pixel_range); |
---|
1926 | |
---|
1927 | E4B_AVOID_UNNEEDED_CASTS(abstract_sequence_terminal); |
---|
1928 | public: |
---|
1929 | char *species_name; // @@@ wrong place (may be member of ED4_sequence_manager) |
---|
1930 | |
---|
1931 | |
---|
1932 | ED4_abstract_sequence_terminal(const ED4_objspec& spec_, const char *id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
1933 | ~ED4_abstract_sequence_terminal() OVERRIDE; |
---|
1934 | |
---|
1935 | virtual GB_alignment_type GetAliType() = 0; |
---|
1936 | int get_length() const OVERRIDE { int len; resolve_pointer_to_char_pntr(&len); return len; } |
---|
1937 | |
---|
1938 | ED4_species_name_terminal *corresponding_species_name_terminal() const { |
---|
1939 | return get_parent(LEV_SPECIES)->search_spec_child_rek(LEV_SPECIES_NAME)->to_species_name_terminal(); |
---|
1940 | } |
---|
1941 | PosRange calc_interval_displayed_in_rectangle(AW_screen_area *area_rect); |
---|
1942 | PosRange calc_update_interval(); |
---|
1943 | |
---|
1944 | DECLARE_DUMP_FOR_BASECLASS(ED4_abstract_sequence_terminal, ED4_text_terminal); |
---|
1945 | }; |
---|
1946 | |
---|
1947 | class ED4_orf_terminal : public ED4_abstract_sequence_terminal { // derived from a Noncopyable |
---|
1948 | // NOTE: ED4_orf_terminal is a separate terminal class used to display Open Reading Frames (ORFs) |
---|
1949 | // for the corresponding gene (DNA) sequence. It is used in ProteinViewer Module and should not be |
---|
1950 | // used for drawing aminoacid sequence alone as in protein alignment. Aminoacid sequences are |
---|
1951 | // handled by the standard "ED4_sequence_terminal" class. |
---|
1952 | |
---|
1953 | char *aaSequence; |
---|
1954 | size_t aaSeqLen; |
---|
1955 | char *aaColor; |
---|
1956 | int aaStartPos; |
---|
1957 | int aaStrandType; |
---|
1958 | |
---|
1959 | void draw() OVERRIDE; |
---|
1960 | E4B_AVOID_UNNEEDED_CASTS(orf_terminal); |
---|
1961 | public: |
---|
1962 | ED4_orf_terminal(const char *id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
1963 | ~ED4_orf_terminal() OVERRIDE; |
---|
1964 | |
---|
1965 | GB_alignment_type GetAliType() OVERRIDE { return GB_AT_AA; } |
---|
1966 | |
---|
1967 | void SET_aaSeqFlags (int startPos, int strandType) { aaStartPos = startPos; aaStrandType = strandType; } |
---|
1968 | void SET_aaSequence(const char *aaSeq) { freedup(aaSequence, aaSeq); aaSeqLen = strlen(aaSequence); } |
---|
1969 | void SET_aaColor(const char *aaSeq) { freedup(aaColor, aaSeq); } |
---|
1970 | |
---|
1971 | int GET_aaStartPos () { return aaStartPos; } |
---|
1972 | int GET_aaStrandType () { return aaStrandType; } |
---|
1973 | |
---|
1974 | DECLARE_DUMP_FOR_LEAFCLASS(ED4_abstract_sequence_terminal); |
---|
1975 | }; |
---|
1976 | |
---|
1977 | class ED4_sequence_terminal : public ED4_abstract_sequence_terminal { // derived from a Noncopyable |
---|
1978 | mutable ED4_SearchResults searchResults; |
---|
1979 | bool shall_display_secstruct_info; // helix or protstruct |
---|
1980 | |
---|
1981 | void draw() OVERRIDE; |
---|
1982 | |
---|
1983 | E4B_AVOID_UNNEEDED_CASTS(sequence_terminal); |
---|
1984 | |
---|
1985 | public: |
---|
1986 | |
---|
1987 | AP_tree *st_ml_node; |
---|
1988 | |
---|
1989 | ED4_sequence_terminal(const char *id, AW_pos width, AW_pos height, ED4_manager *parent, bool shall_display_secstruct_info_); |
---|
1990 | |
---|
1991 | GB_alignment_type GetAliType() FINAL_OVERRIDE { return ED4_ROOT->alignment_type; } |
---|
1992 | |
---|
1993 | void deleted_from_database() OVERRIDE; |
---|
1994 | int get_length() const OVERRIDE { return ED4_abstract_sequence_terminal::get_length(); } |
---|
1995 | |
---|
1996 | virtual char *get_sequence_copy(int *str_len = NULp) const { return resolve_pointer_to_string_copy(str_len); } |
---|
1997 | |
---|
1998 | void set_secstruct_display(bool show) { shall_display_secstruct_info = show; } |
---|
1999 | |
---|
2000 | ED4_SearchResults& results() const { return searchResults; } |
---|
2001 | |
---|
2002 | ED4_columnStat_terminal *corresponding_columnStat_terminal() const { |
---|
2003 | ED4_base *col_term = get_parent(LEV_MULTI_SEQUENCE)->search_spec_child_rek(LEV_COL_STAT); |
---|
2004 | return col_term ? col_term->to_columnStat_terminal() : NULp; |
---|
2005 | } |
---|
2006 | |
---|
2007 | DECLARE_DUMP_FOR_MIDCLASS(ED4_sequence_terminal,ED4_abstract_sequence_terminal); |
---|
2008 | PREPARE_MARK_NONFINAL_CLASS(ED4_sequence_terminal); |
---|
2009 | }; |
---|
2010 | MARK_NONFINAL_CLASS(ED4_sequence_terminal); |
---|
2011 | MARK_NONFINAL_FUNCTION(ED4_sequence_terminal,int,get_length,()const,0); |
---|
2012 | MARK_NONFINAL_FUNCTION(ED4_sequence_terminal,char*,get_sequence_copy,(int*)const,NULp); |
---|
2013 | |
---|
2014 | class ED4_columnStat_terminal FINAL_TYPE : public ED4_text_terminal { // derived from a Noncopyable |
---|
2015 | char *likelihood[4]; // likelihood-array for each base (ACGU) [length of array = alignment_length] |
---|
2016 | int latest_update; |
---|
2017 | |
---|
2018 | static double threshold; |
---|
2019 | |
---|
2020 | int update_likelihood(); |
---|
2021 | |
---|
2022 | E4B_AVOID_UNNEEDED_CASTS(columnStat_terminal); |
---|
2023 | |
---|
2024 | public: |
---|
2025 | // functions concerning graphic output |
---|
2026 | void draw() OVERRIDE; |
---|
2027 | int get_length() const OVERRIDE { return corresponding_sequence_terminal()->get_length(); } |
---|
2028 | |
---|
2029 | static int threshold_is_set(); |
---|
2030 | static void set_threshold(double aThreshold); |
---|
2031 | static double get_threshold() { return threshold; } |
---|
2032 | |
---|
2033 | ED4_sequence_terminal *corresponding_sequence_terminal() const { return get_parent(LEV_MULTI_SEQUENCE)->search_spec_child_rek(LEV_SEQUENCE_STRING)->to_sequence_terminal(); } |
---|
2034 | |
---|
2035 | ED4_columnStat_terminal(GB_CSTR id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
2036 | ~ED4_columnStat_terminal() OVERRIDE; |
---|
2037 | |
---|
2038 | DECLARE_DUMP_FOR_LEAFCLASS(ED4_text_terminal); |
---|
2039 | }; |
---|
2040 | |
---|
2041 | class ED4_species_name_terminal FINAL_TYPE : public ED4_text_terminal { // derived from a Noncopyable |
---|
2042 | E4B_AVOID_UNNEEDED_CASTS(species_name_terminal); |
---|
2043 | bool set_dynamic_size() OVERRIDE; |
---|
2044 | |
---|
2045 | public: |
---|
2046 | ED4_species_name_terminal(GB_CSTR id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
2047 | ~ED4_species_name_terminal() OVERRIDE { delete selection_info; } |
---|
2048 | |
---|
2049 | |
---|
2050 | ED4_selection_entry *selection_info; // Info about i.e. Position |
---|
2051 | bool dragged; |
---|
2052 | |
---|
2053 | GB_CSTR get_displayed_text() const; |
---|
2054 | int get_length() const OVERRIDE { return strlen(get_displayed_text()); } |
---|
2055 | |
---|
2056 | ED4_sequence_terminal *corresponding_sequence_terminal() const { |
---|
2057 | ED4_base *seq_term = get_parent(LEV_SPECIES)->search_spec_child_rek(LEV_SEQUENCE_STRING); |
---|
2058 | return seq_term ? seq_term->to_sequence_terminal() : NULp; |
---|
2059 | } |
---|
2060 | |
---|
2061 | DECLARE_DUMP_FOR_LEAFCLASS(ED4_text_terminal); |
---|
2062 | }; |
---|
2063 | |
---|
2064 | class ED4_flag_header_terminal FINAL_TYPE : public ED4_text_terminal { // derived from a Noncopyable |
---|
2065 | // displays header of flags |
---|
2066 | |
---|
2067 | E4B_AVOID_UNNEEDED_CASTS(flag_header_terminal); |
---|
2068 | bool set_dynamic_size() OVERRIDE; |
---|
2069 | |
---|
2070 | public: |
---|
2071 | ED4_flag_header_terminal(GB_CSTR id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
2072 | |
---|
2073 | GB_CSTR get_displayed_text() const; |
---|
2074 | int get_length() const OVERRIDE; |
---|
2075 | |
---|
2076 | DECLARE_DUMP_FOR_LEAFCLASS(ED4_text_terminal); |
---|
2077 | }; |
---|
2078 | |
---|
2079 | class ED4_sequence_info_terminal FINAL_TYPE : public ED4_text_terminal { |
---|
2080 | E4B_AVOID_UNNEEDED_CASTS(sequence_info_terminal); |
---|
2081 | bool set_dynamic_size() OVERRIDE; |
---|
2082 | |
---|
2083 | public: |
---|
2084 | ED4_sequence_info_terminal(const char *id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
2085 | |
---|
2086 | ED4_species_name_terminal *corresponding_species_name_terminal() const { |
---|
2087 | return get_parent(LEV_SPECIES)->search_spec_child_rek(LEV_SPECIES_NAME)->to_species_name_terminal(); |
---|
2088 | } |
---|
2089 | |
---|
2090 | void draw() OVERRIDE; |
---|
2091 | |
---|
2092 | GBDATA *data() { return get_species_pointer(); } // DB-entry ("ali_xxx/data") |
---|
2093 | const GBDATA *data() const { return get_species_pointer(); } |
---|
2094 | |
---|
2095 | int get_length() const OVERRIDE { return 1+strlen(id); } |
---|
2096 | |
---|
2097 | DECLARE_DUMP_FOR_LEAFCLASS(ED4_text_terminal); |
---|
2098 | }; |
---|
2099 | |
---|
2100 | struct ED4_pure_text_terminal FINAL_TYPE : public ED4_text_terminal { |
---|
2101 | E4B_AVOID_UNNEEDED_CASTS(pure_text_terminal); |
---|
2102 | |
---|
2103 | ED4_pure_text_terminal(const char *id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
2104 | |
---|
2105 | int get_length() const OVERRIDE { int len; resolve_pointer_to_char_pntr(&len); return len; } |
---|
2106 | |
---|
2107 | DECLARE_DUMP_FOR_LEAFCLASS(ED4_text_terminal); |
---|
2108 | }; |
---|
2109 | |
---|
2110 | class ED4_consensus_sequence_terminal : public ED4_sequence_terminal { // derived from a Noncopyable |
---|
2111 | E4B_AVOID_UNNEEDED_CASTS(consensus_sequence_terminal); |
---|
2112 | |
---|
2113 | void draw() OVERRIDE; |
---|
2114 | const ED4_abstract_group_manager *get_group_manager() const { return get_parent(LEV_GROUP)->to_group_manager(); } |
---|
2115 | const BaseFrequencies& get_char_table() const { return get_group_manager()->table(); } |
---|
2116 | |
---|
2117 | public: |
---|
2118 | char *temp_cons_seq; // used for editing consensus (normally NULp) |
---|
2119 | |
---|
2120 | ED4_consensus_sequence_terminal(const char *id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
2121 | #if defined(ASSERTION_USED) |
---|
2122 | virtual ~ED4_consensus_sequence_terminal() { e4_assert(!temp_cons_seq); } |
---|
2123 | #endif |
---|
2124 | |
---|
2125 | int get_length() const OVERRIDE; |
---|
2126 | char *get_sequence_copy(int *str_len = NULp) const FINAL_OVERRIDE { return get_group_manager()->build_consensus_string(str_len); } |
---|
2127 | |
---|
2128 | DECLARE_DUMP_FOR_LEAFCLASS(ED4_sequence_terminal); |
---|
2129 | }; |
---|
2130 | |
---|
2131 | class ED4_spacer_terminal FINAL_TYPE : public ED4_terminal { |
---|
2132 | E4B_AVOID_UNNEEDED_CASTS(spacer_terminal); |
---|
2133 | bool shallDraw; // true -> spacer is really drawn (otherwise it's only a placeholder) |
---|
2134 | |
---|
2135 | bool set_dynamic_size() OVERRIDE; |
---|
2136 | |
---|
2137 | public: |
---|
2138 | void Show(bool refresh_all, bool is_cleared) OVERRIDE; |
---|
2139 | void draw() OVERRIDE; |
---|
2140 | |
---|
2141 | ED4_spacer_terminal(const char *id, bool shallDraw_, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
2142 | |
---|
2143 | DECLARE_DUMP_FOR_LEAFCLASS(ED4_terminal); |
---|
2144 | }; |
---|
2145 | |
---|
2146 | class ED4_line_terminal : public ED4_terminal { |
---|
2147 | E4B_AVOID_UNNEEDED_CASTS(line_terminal); |
---|
2148 | bool set_dynamic_size() OVERRIDE; |
---|
2149 | |
---|
2150 | public: |
---|
2151 | void draw() OVERRIDE; |
---|
2152 | |
---|
2153 | ED4_line_terminal(const char *id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
2154 | |
---|
2155 | DECLARE_DUMP_FOR_LEAFCLASS(ED4_terminal); |
---|
2156 | }; |
---|
2157 | |
---|
2158 | class ED4_flag_terminal FINAL_TYPE : public ED4_terminal { |
---|
2159 | E4B_AVOID_UNNEEDED_CASTS(flag_terminal); |
---|
2160 | bool set_dynamic_size() OVERRIDE; |
---|
2161 | |
---|
2162 | public: |
---|
2163 | void draw() OVERRIDE; |
---|
2164 | |
---|
2165 | ED4_flag_terminal(const char *id, AW_pos width, AW_pos height, ED4_manager *parent); |
---|
2166 | |
---|
2167 | GBDATA *get_species() const { return get_parent(LEV_SPECIES)->get_species_pointer(); } |
---|
2168 | void handle_left_click(const AW::Position& click); |
---|
2169 | |
---|
2170 | DECLARE_DUMP_FOR_LEAFCLASS(ED4_terminal); |
---|
2171 | }; |
---|
2172 | |
---|
2173 | |
---|
2174 | // ---------------------------------------------- |
---|
2175 | // inlines which need complete classdefs |
---|
2176 | |
---|
2177 | inline void ED4_base::set_update() { // @@@ rename into request_update |
---|
2178 | if (!update_info.update_requested) { |
---|
2179 | update_info.update_requested = 1; |
---|
2180 | if (parent) parent->update_requested_by_child(); |
---|
2181 | } |
---|
2182 | } |
---|
2183 | |
---|
2184 | inline void ED4_base::request_resize() { |
---|
2185 | update_info.set_resize(1); |
---|
2186 | if (parent) parent->resize_requested_by_child(); |
---|
2187 | } |
---|
2188 | |
---|
2189 | void ED4_manager::resize_requested_by_child() { |
---|
2190 | if (!update_info.resize) request_resize(); |
---|
2191 | } |
---|
2192 | |
---|
2193 | inline bool ED4_terminal::setCursorTo(ED4_cursor *cursor, int seq_pos, bool unfoldGroups, ED4_CursorJumpType jump_type) { |
---|
2194 | ED4_species_manager *sm = get_parent(LEV_SPECIES)->to_species_manager(); |
---|
2195 | return sm->setCursorTo(cursor, seq_pos, unfoldGroups, jump_type); |
---|
2196 | } |
---|
2197 | |
---|
2198 | E4B_IMPL_CASTOP(area_manager); // to_area_manager |
---|
2199 | E4B_IMPL_CASTOP(abstract_group_manager); // to_abstract_group_manager |
---|
2200 | E4B_IMPL_CASTOP(bracket_terminal); // to_bracket_terminal |
---|
2201 | E4B_IMPL_CASTOP(columnStat_terminal); // to_columnStat_terminal |
---|
2202 | E4B_IMPL_CASTOP(consensus_sequence_terminal); // to_consensus_sequence_terminal |
---|
2203 | E4B_IMPL_CASTOP(device_manager); // to_device_manager |
---|
2204 | E4B_IMPL_CASTOP(group_manager); // to_group_manager |
---|
2205 | E4B_IMPL_CASTOP(line_terminal); // to_line_terminal |
---|
2206 | E4B_IMPL_CASTOP(manager); // to_manager |
---|
2207 | E4B_IMPL_CASTOP(multi_name_manager); // to_multi_name_manager |
---|
2208 | E4B_IMPL_CASTOP(multi_sequence_manager); // to_multi_sequence_manager |
---|
2209 | E4B_IMPL_CASTOP(multi_species_manager); // to_multi_species_manager |
---|
2210 | E4B_IMPL_CASTOP(name_manager); // to_name_manager |
---|
2211 | E4B_IMPL_CASTOP(orf_terminal); // to_orf_terminal |
---|
2212 | E4B_IMPL_CASTOP(pure_text_terminal); // to_pure_text_terminal |
---|
2213 | E4B_IMPL_CASTOP(root_group_manager); // to_root_group_manager |
---|
2214 | E4B_IMPL_CASTOP(sequence_info_terminal); // to_sequence_info_terminal |
---|
2215 | E4B_IMPL_CASTOP(sequence_manager); // to_sequence_manager |
---|
2216 | E4B_IMPL_CASTOP(sequence_terminal); // to_sequence_terminal |
---|
2217 | E4B_IMPL_CASTOP(spacer_terminal); // to_spacer_terminal |
---|
2218 | E4B_IMPL_CASTOP(species_manager); // to_species_manager |
---|
2219 | E4B_IMPL_CASTOP(species_name_terminal); // to_species_name_terminal |
---|
2220 | E4B_IMPL_CASTOP(terminal); // to_terminal |
---|
2221 | E4B_IMPL_CASTOP(text_terminal); // to_text_terminal |
---|
2222 | E4B_IMPL_CASTOP(flag_header_terminal); // to_flag_header_terminal |
---|
2223 | E4B_IMPL_CASTOP(flag_terminal); // to_flag_terminal |
---|
2224 | |
---|
2225 | inline ED4_device_manager *ED4_root::get_device_manager() { |
---|
2226 | return main_manager->search_spec_child_rek(LEV_DEVICE)->to_device_manager(); |
---|
2227 | } |
---|
2228 | |
---|
2229 | |
---|
2230 | inline ED4_species_name_terminal *ED4_multi_species_manager::get_consensus_name_terminal() const { |
---|
2231 | ED4_species_manager *consensus_man = get_consensus_manager(); |
---|
2232 | return consensus_man ? consensus_man->get_name_terminal() : NULp; |
---|
2233 | } |
---|
2234 | |
---|
2235 | // ---------------------------------------- |
---|
2236 | |
---|
2237 | enum SpeciesCreationMode { |
---|
2238 | CREATE_NEW_SPECIES, |
---|
2239 | CREATE_FROM_CONSENSUS, // create new species from group consensus (of surrounding group) |
---|
2240 | COPY_SPECIES, // copy current species |
---|
2241 | }; |
---|
2242 | |
---|
2243 | #if defined(ASSERTION_USED) |
---|
2244 | CONSTEXPR_INLINE bool valid(SpeciesCreationMode m) { return m>=CREATE_NEW_SPECIES && m<=COPY_SPECIES; } |
---|
2245 | #endif |
---|
2246 | |
---|
2247 | extern ST_ML *st_ml; |
---|
2248 | struct AlignDataAccess; |
---|
2249 | |
---|
2250 | // ------------------------------------------------- |
---|
2251 | // factory functions (hierarchy builders): |
---|
2252 | |
---|
2253 | ED4_group_manager *ED4_build_group_manager_start(ED4_manager *group_parent, |
---|
2254 | GB_CSTR group_name, |
---|
2255 | int group_depth, |
---|
2256 | bool is_folded, |
---|
2257 | ED4_reference_terminals& refterms, |
---|
2258 | ED4_multi_species_manager*& multi_species_manager); |
---|
2259 | |
---|
2260 | void ED4_build_group_manager_end(ED4_multi_species_manager *multi_species_manager); |
---|
2261 | |
---|
2262 | // ------------------------------------- |
---|
2263 | // hierarchy access functions: |
---|
2264 | |
---|
2265 | ED4_species_name_terminal *ED4_find_species_name_terminal(const char *species_name); |
---|
2266 | ED4_species_name_terminal *ED4_find_SAI_name_terminal(const char *sai_name); |
---|
2267 | ED4_species_name_terminal *ED4_find_species_or_SAI_name_terminal(const char *species_name); |
---|
2268 | |
---|
2269 | ED4_multi_species_manager *ED4_find_MoreSequences_manager(); |
---|
2270 | |
---|
2271 | // -------------------------- |
---|
2272 | // other functions: |
---|
2273 | |
---|
2274 | void ED4_new_editor_window(AW_window *aww); |
---|
2275 | void ED4_with_all_edit_windows(void (*cb)(ED4_window *)); |
---|
2276 | |
---|
2277 | void ED4_resize_all_extensions(); |
---|
2278 | void ED4_calc_terminal_extentions(); |
---|
2279 | |
---|
2280 | void ED4_input_cb(AW_window *aww); |
---|
2281 | void ED4_remote_event(AW_event *faked_event); |
---|
2282 | void ED4_motion_cb(AW_window *aww); |
---|
2283 | void ED4_vertical_change_cb(AW_window *aww); |
---|
2284 | void ED4_horizontal_change_cb(AW_window *aww); |
---|
2285 | void ED4_scrollbar_change_cb(AW_window *aww); |
---|
2286 | void ED4_trigger_instant_refresh(); |
---|
2287 | void ED4_request_relayout(); |
---|
2288 | void ED4_request_full_refresh(); |
---|
2289 | void ED4_request_full_instant_refresh(); |
---|
2290 | |
---|
2291 | void ED4_store_curpos(AW_window *aww); |
---|
2292 | void ED4_restore_curpos(AW_window *aww); |
---|
2293 | void ED4_clear_stored_curpos(); |
---|
2294 | void ED4_helix_jump_opposite(AW_window *aww); |
---|
2295 | void ED4_jump_to_cursor_position(AW_window *aww, const char *awar_name, PositionType posType); |
---|
2296 | void ED4_remote_set_cursor_cb(AW_root *awr); |
---|
2297 | void ED4_change_cursor(AW_window *aww); |
---|
2298 | |
---|
2299 | void ED4_set_iupac(AW_window *aww, const char *awar_name); |
---|
2300 | void ED4_set_helixnr(AW_window *aww, const char *awar_name); |
---|
2301 | void ed4_changesecurity(AW_root *root); |
---|
2302 | void ed4_change_edit_mode(AW_root *root); |
---|
2303 | |
---|
2304 | void ED4_jump_to_current_species(AW_window *); |
---|
2305 | void ED4_get_and_jump_to_current(AW_window *); |
---|
2306 | void ED4_get_and_jump_to_species(GB_CSTR species_name); |
---|
2307 | |
---|
2308 | void ED4_get_marked_from_menu(AW_window *); |
---|
2309 | void ED4_selected_species_changed_cb(AW_root *aw_root); |
---|
2310 | |
---|
2311 | AW_window *ED4_create_loadSAI_window(AW_root *awr); |
---|
2312 | void ED4_get_and_jump_to_selected_SAI(AW_window *aww); |
---|
2313 | void ED4_selected_SAI_changed_cb(AW_root *aw_root); |
---|
2314 | |
---|
2315 | void ED4_init_notFoundMessage(); |
---|
2316 | void ED4_finish_and_show_notFoundMessage(); |
---|
2317 | |
---|
2318 | const AlignDataAccess *ED4_get_aligner_data_access(); |
---|
2319 | |
---|
2320 | void ED4_popup_gc_window(AW_window *awp, AW_gc_manager *gcman); |
---|
2321 | void ED4_no_dangerous_modes(); |
---|
2322 | |
---|
2323 | void group_species_cb(AW_window *aww, bool use_fields); |
---|
2324 | AW_window *ED4_create_group_species_by_field_window(AW_root *aw_root); |
---|
2325 | |
---|
2326 | AW_window *ED4_create_loadConfiguration_window(AW_root *awr); |
---|
2327 | void ED4_reloadConfiguration(AW_window *aww); |
---|
2328 | void ED4_saveConfiguration(AW_window *aww, bool hide_aww); |
---|
2329 | AW_window *ED4_create_saveConfigurationAs_window(AW_root *awr); |
---|
2330 | |
---|
2331 | ARB_ERROR rebuild_consensus(ED4_base *object); |
---|
2332 | |
---|
2333 | void ED4_create_consensus_awars(AW_root *aw_root); |
---|
2334 | AW_window *ED4_create_consensus_definition_window(AW_root *root); |
---|
2335 | void ED4_consensus_definition_changed(AW_root*); |
---|
2336 | void ED4_consensus_display_changed(AW_root *root); |
---|
2337 | |
---|
2338 | AW_window *ED4_create_editor_options_window(AW_root *root); |
---|
2339 | void ED4_compression_toggle_changed_cb(AW_root *root, bool hideChanged); |
---|
2340 | void ED4_compression_changed_cb(AW_root *awr); |
---|
2341 | void ED4_alignment_length_changed(GBDATA *gb_alignment_len, GB_CB_TYPE gbtype); |
---|
2342 | |
---|
2343 | AW_window *ED4_create_new_seq_window(AW_root *root, SpeciesCreationMode creation_mode); |
---|
2344 | |
---|
2345 | void ED4_quit_editor(AW_window *aww); |
---|
2346 | void ED4_exit() __ATTR__NORETURN; |
---|
2347 | |
---|
2348 | |
---|
2349 | #else |
---|
2350 | #error ed4_class included twice |
---|
2351 | #endif |
---|