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