ARB
ED4_no_class.cxx
Go to the documentation of this file.
1 // =============================================================== //
2 // //
3 // File : ED4_no_class.cxx //
4 // Purpose : //
5 // //
6 // Institute of Microbiology (Technical University Munich) //
7 // http://www.arb-home.de/ //
8 // //
9 // =============================================================== //
10 
11 #include <ed4_extern.hxx>
12 
13 #include "ed4_awars.hxx"
14 #include "ed4_class.hxx"
15 #include "ed4_edit_string.hxx"
16 #include "ed4_nds.hxx"
17 #include "ed4_list.hxx"
18 #include "ed4_seq_colors.hxx"
19 #include "ed4_flags.hxx"
20 
21 #include <iupac.h>
22 #include <consensus_config.h>
23 #include <item_sel_list.h>
24 #include <macros.hxx>
25 
26 #include <awt.hxx>
27 #include <awt_config_manager.hxx>
28 #include <awt_misc.hxx>
29 #include <awt_sel_boxes.hxx>
30 
31 #include <aw_awars.hxx>
32 #include <AW_helix.hxx>
33 #include <aw_msg.hxx>
34 #include <AW_rename.hxx>
35 #include <aw_root.hxx>
36 
37 #include <ad_config.h>
38 
39 #include <arb_defs.h>
40 #include <arb_global_defs.h>
41 #include <arb_progress.h>
42 
43 #include <cctype>
44 #include <limits.h>
45 
46 #include <vector>
47 
48 using namespace std;
49 
50 struct group_folding {
51  int max_depth; // maximum group level (root-group has level 0)
52  int max_visible; // max visible group level (even if folded)
53  int max_unfolded; // max visible unfolded group level
54 
56  max_depth(0),
57  max_visible(0),
58  max_unfolded(0)
59  {}
60 };
61 
63  if (base->is_group_manager()) {
64  int group_level = base->calc_group_depth()+1;
65  folding->max_depth = std::max(folding->max_depth, group_level);
66 
67  bool is_folded = base->has_property(PROP_IS_FOLDED);
68  if (group_level>folding->max_visible || (group_level>folding->max_unfolded && !is_folded)) { // may change other maxima?
69  bool is_visible = !base->is_hidden();
70  if (is_visible) {
71  folding->max_visible = std::max(folding->max_visible, group_level);
72  if (!is_folded) {
73  folding->max_unfolded = std::max(folding->max_unfolded, group_level);
74  }
75  }
76  }
77  }
78  return NULp;
79 }
80 
82  if (ED4_ROOT->main_manager) {
83  ED4_ROOT->main_manager->route_down_hierarchy(makeED4_route_cb(update_group_folding, &folding)).expect_no_error();
84  }
85 }
86 
89 
90  AW_device *device = ED4_ROOT->first_window->get_device(); // any device
91 
92  const AW_font_group& font_group = ED4_ROOT->font_group;
93  const AW_font_limits& seq_font_limits = font_group.get_limits(ED4_G_SEQUENCES);
94  const AW_font_limits& seq_equal_limits = device->get_font_limits(ED4_G_SEQUENCES, '=');
95  const AW_font_limits& info_font_limits = font_group.get_limits(ED4_G_STANDARD);
96 
97  int info_char_width = info_font_limits.width;
98  int seq_term_descent;
99 
100  if (ED4_ROOT->helix->is_enabled() || ED4_ROOT->protstruct) { // display helix ?
102  seq_equal_limits.ascent // the ascent of '='
103  + ED4_ROOT->helix_add_spacing; // xtra user-defined spacing
104 
105  seq_term_descent = ED4_ROOT->helix_spacing;
106  }
107  else {
108  ED4_ROOT->helix_spacing = 0;
109  seq_term_descent = seq_font_limits.descent;
110  }
111 
112  // for wanted_seq_term_height ignore descent, because it additionally allocates 'ED4_ROOT->helix_spacing' space:
113  int wanted_seq_term_height = seq_font_limits.ascent + seq_term_descent + ED4_ROOT->terminal_add_spacing;
114  int wanted_seq_info_height = info_font_limits.get_height() + ED4_ROOT->terminal_add_spacing;
115 
116  TERMINAL_HEIGHT = (wanted_seq_term_height>wanted_seq_info_height) ? wanted_seq_term_height : wanted_seq_info_height;
117 
118  {
120  calculate_group_folding(folding);
121 
122  int maxbrackets = folding.max_unfolded;
123  int maxchars = ED4_get_NDS_width();
124 
125 #if defined(DEBUG)
126  fprintf(stderr, "maxbrackets=%i\n", maxbrackets);
127 #endif
128 
129  MAXNAME_WIDTH =
130  (maxchars+1+1)*info_char_width + // width defined in NDS window (+ 1 char for marked-box; + 1 extra char to avoid truncation)
131  maxbrackets*BRACKET_WIDTH; // brackets defined in NDS window
132  }
133 
134  {
136  int headerlen = flags.get_header_length();
137 
138  if (headerlen) {
140  FLAG_WIDTH = flags.get_pixel_width();
141  }
142  else {
143  FLAG_WIDTH = 0;
144  }
145  }
146 
147  MAXINFO_WIDTH =
149  info_char_width*ED4_ROOT->aw_root->awar(ED4_AWAR_NDS_INFO_WIDTH)->read_int() +
150  1; // + 1 extra char to avoid truncation
151 
152  INFO_TERM_TEXT_YOFFSET = info_font_limits.ascent - 1;
153  SEQ_TERM_TEXT_YOFFSET = seq_font_limits.ascent - 1;
154 
156 
157 #if defined(DEBUG) && 0
158  printf("seq_term_descent = %i\n", seq_term_descent);
159  printf("TERMINAL_HEIGHT = %i\n", TERMINAL_HEIGHT);
160  printf("MAXNAME_WIDTH = %i\n", MAXNAME_WIDTH);
161  printf("FLAG_WIDTH = %i\n", FLAG_WIDTH);
162  printf("MAXINFO_WIDTH = %i\n", MAXINFO_WIDTH);
163  printf("INFO_TERM_TEXT_YOFFSET= %i\n", INFO_TERM_TEXT_YOFFSET);
164  printf(" SEQ_TERM_TEXT_YOFFSET= %i\n", SEQ_TERM_TEXT_YOFFSET);
165 #endif // DEBUG
166 }
167 
168 bool ED4_flag_header_terminal::set_dynamic_size() {
169  return extension.set_size_does_change(WIDTH, FLAG_WIDTH);
170 }
171 bool ED4_flag_terminal::set_dynamic_size() {
172  return extension.set_size_does_change(WIDTH, FLAG_WIDTH);
173 }
174 bool ED4_species_name_terminal::set_dynamic_size() {
175  return extension.set_size_does_change(WIDTH, MAXNAME_WIDTH - BRACKET_WIDTH * calc_group_depth());
176 }
177 bool ED4_sequence_info_terminal::set_dynamic_size() {
178  return extension.set_size_does_change(WIDTH, MAXINFO_WIDTH);
179 }
180 bool ED4_line_terminal::set_dynamic_size() {
181  // dynamically adapt to ref_terminals
182 
183  AW_pos overall_width =
185  MAXNAME_WIDTH +
186  ED4_ROOT->ref_terminals.sequence_info()->extension.size[WIDTH] +
188 
189  return extension.set_size_does_change(WIDTH, overall_width);
190 }
191 bool ED4_spacer_terminal::set_dynamic_size() {
192  if (!has_property(PROP_DYNA_RESIZE)) return false; // some spacer terminals never change their size (eg. bottom-spacer)
193 
194  AW_pos new_height = SPACER_HEIGHT;
195 
196  if (parent->is_device_manager()) {
197  if (this == ED4_ROOT->main_manager->get_top_middle_spacer_terminal()) {
198  ED4_terminal *top_middle_line_terminal = ED4_ROOT->main_manager->get_top_middle_line_terminal();
199 
200  // top-middle spacer + top-middle line >= font-size (otherwise scrolling relicts!)
201  new_height = TERMINAL_HEIGHT - top_middle_line_terminal->extension.size[HEIGHT];
202  }
203  else {
204  new_height = 1; // use minimal height for other top-group spacers
205  }
206  }
207  else {
208  ED4_manager *grandpa = parent->parent;
209  e4_assert(grandpa);
210 
211  if (grandpa->is_group_manager()) {
212  ED4_group_manager *group_man = grandpa->to_group_manager();
213  if (group_man->has_property(PROP_IS_FOLDED)) {
214  if (!AW_root::SINGLETON->awar(ED4_AWAR_CONSENSUS_SHOW)->read_int()) {
215  new_height = SPACER_NOCONS_HEIGHT;
216  }
217  }
218  }
219  }
220 
221  return extension.set_size_does_change(HEIGHT, new_height);
222 }
223 
225  base->resize_dynamic();
226  return NULp; // doesn't fail
227 }
228 
229 void ED4_resize_all_extensions() { // @@@ pass flag to force resize-request? (eg. for initial-call?)
231 
232  // @@@ below calculations have to be done at startup as well (are they done somewhere else or not done?)
233 
237 
239  while (1) {
241 
242  ED4_ROOT->main_manager->route_down_hierarchy(makeED4_route_cb(update_extension_size)).expect_no_error();
243 
244  ED4_ROOT->resize_all_requesting_childs(); // Note: may change mapping
245 
247  if (new_screenwidth == screenwidth) { // mapping did not change
248  break;
249  }
250  screenwidth = new_screenwidth;
251  }
252 }
253 
254 static ARB_ERROR call_edit(ED4_base *object, ED4_work_info *work_info) {
255  // called after editing consensus to edit single sequences
256  GB_ERROR error = NULp;
257 
258  if (object->is_species_seq_terminal()) {
259  int expected_prop = PROP_CURSOR_ALLOWED|PROP_ALIGNMENT_DATA;
260 
261  if ((object->dynamic_prop & expected_prop) == expected_prop) {
262  ED4_work_info new_work_info;
263 
264  new_work_info.event = work_info->event;
265  new_work_info.char_position = work_info->char_position;
266  new_work_info.out_seq_position = work_info->out_seq_position;
267  new_work_info.refresh_needed = false;
268  new_work_info.cursor_jump = ED4_JUMP_KEEP_VISIBLE;
269  new_work_info.out_string = NULp;
270  new_work_info.mode = work_info->mode;
271  new_work_info.rightward = work_info->rightward;
272  new_work_info.cannot_handle = false;
273  new_work_info.is_sequence = work_info->is_sequence;
274  new_work_info.working_terminal = object->to_terminal();
275 
276  if (object->get_species_pointer()) {
277  new_work_info.gb_data = object->get_species_pointer();
278  new_work_info.string = NULp;
279  }
280  else {
281  new_work_info.gb_data = NULp;
282  new_work_info.string = object->id; // @@@ looks obsolete (see [8402] for previous code)
283  e4_assert(0); // assume we never come here
284  }
285 
286  new_work_info.repeat_count = 1;
287 
289  error = ED4_ROOT->edit_string->edit(&new_work_info);
290 
291  e4_assert(error || !new_work_info.out_string);
292 
293  if (new_work_info.refresh_needed) {
294  object->request_refresh();
295  if (object->is_sequence_terminal()) {
296  ED4_sequence_terminal *seq_term = object->to_sequence_terminal();
297  seq_term->results().searchAgain();
298  }
299  }
300 
301  if (move_cursor) {
303  move_cursor = 0;
304  }
305  }
306  }
307  return error;
308 }
309 
310 static void executeKeystroke(AW_event *event, int repeatCount) {
311  e4_assert(repeatCount>0);
312 
313  if (event->keycode!=AW_KEY_NONE) {
314  ED4_cursor *cursor = &current_cursor();
315  if (cursor->owner_of_cursor && !cursor->owner_of_cursor->flag.hidden) {
317  if (event->keycode == AW_KEY_UP || event->keycode == AW_KEY_DOWN ||
318  ((event->keymodifier & AW_KEYMODE_CONTROL) &&
319  (event->keycode == AW_KEY_HOME || event->keycode == AW_KEY_END)))
320  {
321  GB_transaction ta(gb_main);
322  while (repeatCount--) {
323  cursor->move_cursor(event);
324  }
325  }
326  else {
327  ED4_work_info *work_info = new ED4_work_info;
328 
329  work_info->cannot_handle = false;
330  work_info->event = *event;
331  work_info->char_position = cursor->get_screen_pos();
332  work_info->out_seq_position = cursor->get_sequence_pos();
333  work_info->refresh_needed = false;
334  work_info->cursor_jump = ED4_JUMP_KEEP_VISIBLE;
335  work_info->out_string = NULp; // nur falls new malloc
336  work_info->repeat_count = repeatCount;
337 
338  ED4_terminal *terminal = cursor->owner_of_cursor;
339  e4_assert(terminal->is_text_terminal());
340 
341  work_info->working_terminal = terminal;
342 
343  if (terminal->is_sequence_terminal()) {
344  work_info->mode = awar_edit_mode;
345  work_info->rightward = awar_edit_rightward;
346  work_info->is_sequence = 1;
347  }
348  else {
349  work_info->rightward = true;
350  work_info->is_sequence = 0;
351 
352  if (terminal->is_pure_text_terminal()) {
353  work_info->mode = awar_edit_mode;
354  }
355  else if (terminal->is_columnStat_terminal()) {
356  work_info->mode = AD_NOWRITE;
357  }
358  else {
359  e4_assert(0);
360  }
361  }
362 
363  work_info->string = NULp;
364  work_info->gb_data = NULp;
365 
366  if (terminal->get_species_pointer()) {
367  work_info->gb_data = terminal->get_species_pointer();
368  }
369  else if (terminal->is_columnStat_terminal()) {
370  work_info->gb_data = terminal->to_columnStat_terminal()->corresponding_sequence_terminal()->get_species_pointer();
371  }
372  else {
373  e4_assert(terminal->is_consensus_terminal());
374  ED4_consensus_sequence_terminal *cterm = terminal->to_consensus_sequence_terminal();
375  work_info->string = cterm->temp_cons_seq;
376  }
377 
378  ED4_Edit_String *edit_string = new ED4_Edit_String;
379  ARB_ERROR error = NULp;
380 
381  GB_push_transaction(gb_main);
382 
383  if (terminal->is_consensus_terminal()) {
384  ED4_consensus_sequence_terminal *cterm = terminal->to_consensus_sequence_terminal();
385  ED4_group_manager *group_manager = terminal->get_parent(LEV_GROUP)->to_group_manager();
386 
387  e4_assert(!cterm->temp_cons_seq);
388  work_info->string = cterm->temp_cons_seq = group_manager->build_consensus_string();
389 
390  error = edit_string->edit(work_info);
391 
393 
394  work_info->string = NULp;
395 
396  if (work_info->cannot_handle) {
397  e4_assert(!error); // see ED4_Edit_String::edit()
398  move_cursor = 1;
399  if (!ED4_ROOT->edit_string) {
401  }
402  error = group_manager->route_down_hierarchy(makeED4_route_cb(call_edit, work_info));
403  group_manager->rebuild_consensi(group_manager, ED4_U_UP_DOWN);
404  }
405 
406  freenull(cterm->temp_cons_seq);
407  }
408  else {
409  error = edit_string->edit(work_info);
410  cursor->jump_sequence_pos(work_info->out_seq_position, work_info->cursor_jump);
411  }
412 
413  edit_string->finish_edit();
414 
415  if (error) work_info->refresh_needed = true;
416 
417  GB_end_transaction_show_error(gb_main, error, aw_message);
418 
419  if (work_info->refresh_needed) {
420  GB_transaction ta(gb_main);
421 
422  terminal->request_refresh();
423  if (terminal->is_sequence_terminal()) {
424  ED4_sequence_terminal *seq_term = terminal->to_sequence_terminal();
425  seq_term->results().searchAgain();
426  }
427  }
428 
429  delete edit_string;
430  delete work_info;
431  }
432  }
433  }
434 }
435 
436 void ED4_remote_event(AW_event *faked_event) { // keystrokes forwarded from SECEDIT
437  ED4_MostRecentWinContext context;
438  executeKeystroke(faked_event, 1);
439 }
440 
441 static int get_max_slider_xpos() {
442  const AW_screen_area& rect = current_device()->get_area_size();
443 
444  AW_pos x, y;
446  horizontal_link->calc_world_coords(&x, &y);
447 
448  AW_pos max_xpos = horizontal_link->extension.size[WIDTH] // overall width of virtual scrolling area
449  - (rect.r - x); // minus width of visible scroll-area (== relative width of horizontal scrollbar)
450 
451  if (max_xpos<0) max_xpos = 0; // happens when window-content is smaller than window (e.g. if (folded) alignment is narrow)
452  return int(max_xpos+0.5);
453 }
454 
455 static int get_max_slider_ypos() {
456  const AW_screen_area& rect = current_device()->get_area_size();
457 
458  AW_pos x, y;
460  vertical_link->calc_world_coords(&x, &y);
461 
462  AW_pos max_ypos = vertical_link->extension.size[HEIGHT] // overall height of virtual scrolling area
463  - (rect.b - y); // minus height of visible scroll-area (== relative height of vertical scrollbar)
464 
465  if (max_ypos<0) max_ypos = 0; // happens when window-content is smaller than window (e.g. if ARB_EDIT4 is not filled)
466  return int(max_ypos+0.5);
467 }
468 
469 static void ed4_scroll(AW_window *aww, int xdiff, int ydiff) {
470  int new_xpos = aww->slider_pos_horizontal + (xdiff*ED4_ROOT->aw_root->awar(ED4_AWAR_SCROLL_SPEED_X)->read_int())/10;
471  int new_ypos = aww->slider_pos_vertical + (ydiff*ED4_ROOT->aw_root->awar(ED4_AWAR_SCROLL_SPEED_Y)->read_int())/10;
472 
473  if (xdiff<0) { // scroll left
474  if (new_xpos<0) new_xpos = 0;
475  }
476  else if (xdiff>0) { // scroll right
477  int max_xpos = get_max_slider_xpos();
478  if (max_xpos<0) max_xpos = 0;
479  if (new_xpos>max_xpos) new_xpos = max_xpos;
480  }
481 
482  if (ydiff<0) { // scroll up
483  if (new_ypos<0) new_ypos = 0;
484  }
485  else if (ydiff>0) { // scroll down
486  int max_ypos = get_max_slider_ypos();
487  if (max_ypos<0) max_ypos = 0;
488  if (new_ypos>max_ypos) new_ypos = max_ypos;
489  }
490 
491  if (new_xpos!=aww->slider_pos_horizontal) {
492  aww->set_horizontal_scrollbar_position(new_xpos);
494  }
495 
496  if (new_ypos!=aww->slider_pos_vertical) {
497  aww->set_vertical_scrollbar_position(new_ypos);
499  }
500 }
501 
503  AW_event event;
504  static AW_event lastEvent;
505  static int repeatCount;
506 
507  ED4_LocalWinContext uses(aww);
508 
509  aww->get_event(&event);
510 
511 
512 #if defined(DEBUG) && 0
513  printf("event.type=%i event.keycode=%i event.character='%c' event.keymodifier=%i\n", event.type, event.keycode, event.character, event.keymodifier);
514 #endif
515 
516  switch (event.type) {
517  case AW_Keyboard_Press: {
518  if (repeatCount==0) { // first key event?
519  lastEvent = event;
520  repeatCount = 1;
521  }
522  else {
523  if (lastEvent.keycode==event.keycode &&
524  lastEvent.character==event.character &&
525  lastEvent.keymodifier==event.keymodifier) { // same key as last?
526  repeatCount++;
527  }
528  else { // other key => execute now
529  executeKeystroke(&lastEvent, repeatCount);
530  lastEvent = event;
531  repeatCount = 1;
532  }
533  }
534 
535  if (repeatCount) {
536 #if defined(DARWIN) || 1
537  // sth goes wrong with OSX -> always execute keystroke
538  // Xfree 4.3 has problems as well, so repeat counting is disabled completely
539  executeKeystroke(&lastEvent, repeatCount);
540  repeatCount = 0;
541 #else
542  AW_ProcessEventType nextEventType = ED4_ROOT->aw_root->peek_key_event(aww);
543 
544  if (nextEventType!=KEY_RELEASED) { // no key waiting => execute now
545  executeKeystroke(&lastEvent, repeatCount);
546  repeatCount = 0;
547  }
548 #endif
549  }
550  break;
551  }
552  case AW_Keyboard_Release: {
553  AW_ProcessEventType nextEventType = ED4_ROOT->aw_root->peek_key_event(aww);
554 
555  if (nextEventType!=KEY_PRESSED && repeatCount) { // no key follows => execute keystrokes (if any)
556  executeKeystroke(&lastEvent, repeatCount);
557  repeatCount = 0;
558  }
559 
560  break;
561  }
562  default: {
563  if (event.button == AW_WHEEL_UP || event.button == AW_WHEEL_DOWN) {
564  if (event.type == AW_Mouse_Press) {
565  bool horizontal = event.keymodifier & AW_KEYMODE_ALT;
566  int direction = event.button == AW_WHEEL_UP ? -1 : 1;
567 
568  int dx = horizontal ? direction*ED4_ROOT->font_group.get_max_width() : 0;
569  int dy = horizontal ? 0 : direction*ED4_ROOT->font_group.get_max_height();
570 
571  ed4_scroll(aww, dx, dy);
572  }
573  return;
574  }
575 
576  if (event.button == AW_BUTTON_MIDDLE) {
577  if (event.type == AW_Mouse_Press) {
579  ED4_ROOT->scroll_picture.old_y = event.y;
580  ED4_ROOT->scroll_picture.old_x = event.x;
581  return;
582  }
583  if (event.type == AW_Mouse_Release) {
585  return;
586  }
587  }
588 
589 #if defined(DEBUG) && 0
590  if (event.button==AW_BUTTON_LEFT) {
591  printf("[ED4_input_cb] type=%i x=%i y=%i ", (int)event.type, (int)event.x, (int)event.y);
592  }
593 #endif
594 
595  AW_pos win_x = event.x;
596  AW_pos win_y = event.y;
597  current_ed4w()->win_to_world_coords(&(win_x), &(win_y));
598  event.x = (int) win_x;
599  event.y = (int) win_y;
600 
601 #if defined(DEBUG) && 0
602  if (event.button==AW_BUTTON_LEFT) {
603  printf("-> x=%i y=%i\n", (int)event.type, (int)event.x, (int)event.y);
604  }
605 #endif
606 
608  ED4_ROOT->main_manager->event_sent_by_parent(&event, aww);
609  break;
610  }
611  }
612 
614 }
615 
617  ED4_LocalWinContext uses(aww);
618 
620  {
622 
623  int old_slider_pos = win->slider_pos_vertical;
624 
625  { // correct slider_pos if necessary
626  int max_slider_ypos = get_max_slider_ypos();
627 
628  if (aww->slider_pos_vertical>max_slider_ypos) aww->set_vertical_scrollbar_position(max_slider_ypos);
630  }
631 
632  int slider_diff = aww->slider_pos_vertical - old_slider_pos;
633 
634  win->coords.window_upper_clip_point += slider_diff;
635  win->coords.window_lower_clip_point += slider_diff;
636 
637  win->scroll_rectangle(0, -slider_diff);
639  }
640  win->update_window_coords();
641 }
642 
644  ED4_LocalWinContext uses(aww);
645 
647  {
649 
650  int old_slider_pos = win->slider_pos_horizontal;
651 
652  { // correct slider_pos if necessary
653  int max_slider_xpos = get_max_slider_xpos();
654 
655  if (aww->slider_pos_horizontal>max_slider_xpos) aww->set_horizontal_scrollbar_position(max_slider_xpos);
657  }
658 
659  int slider_diff = aww->slider_pos_horizontal - old_slider_pos;
660 
661  win->coords.window_left_clip_point += slider_diff;
662  win->coords.window_right_clip_point += slider_diff;
663 
664  win->scroll_rectangle(-slider_diff, 0);
666  }
667  win->update_window_coords();
668 }
669 
671  ED4_LocalWinContext uses(aww);
672 
674  {
676 
677 
678  int old_hslider_pos = win->slider_pos_horizontal;
679  int old_vslider_pos = win->slider_pos_vertical;
680 
681  {
682  // correct slider_pos if necessary
683  int max_slider_xpos = get_max_slider_xpos();
684  int max_slider_ypos = get_max_slider_ypos();
685 
686  if (aww->slider_pos_horizontal>max_slider_xpos) aww->set_horizontal_scrollbar_position(max_slider_xpos);
688 
689  if (aww->slider_pos_vertical>max_slider_ypos) aww->set_vertical_scrollbar_position(max_slider_ypos);
691  }
692 
693  int slider_hdiff = aww->slider_pos_horizontal - old_hslider_pos;
694  int slider_vdiff = aww->slider_pos_vertical - old_vslider_pos;
695 
696  ED4_coords *coords = &win->coords;
697  coords->window_left_clip_point += slider_hdiff;
698  coords->window_right_clip_point += slider_hdiff;
699  coords->window_upper_clip_point += slider_vdiff;
700  coords->window_lower_clip_point += slider_vdiff;
701 
702  win->scroll_rectangle(-slider_hdiff, -slider_vdiff);
703 
706  }
707  win->update_window_coords();
708 }
709 
711  AW_event event;
712 
713  ED4_LocalWinContext uses(aww);
714 
715  aww->get_event(&event);
716 
717  if (event.type == AW_Mouse_Drag && event.button == AW_BUTTON_MIDDLE) {
719  int xdiff = ED4_ROOT->scroll_picture.old_x - event.x;
720  int ydiff = ED4_ROOT->scroll_picture.old_y - event.y;
721 
722  ed4_scroll(aww, xdiff, ydiff);
723 
724  ED4_ROOT->scroll_picture.old_x = event.x;
725  ED4_ROOT->scroll_picture.old_y = event.y;
726  }
727  }
728  else {
729 
730 #if defined(DEBUG) && 0
731  if (event.button==AW_BUTTON_LEFT) {
732  printf("[ED4_motion_cb] type=%i x=%i y=%i ", (int)event.type, (int)event.x, (int)event.y);
733  }
734 #endif
735 
736  AW_pos win_x = event.x;
737  AW_pos win_y = event.y;
738  current_ed4w()->win_to_world_coords(&win_x, &win_y);
739  event.x = (int) win_x;
740  event.y = (int) win_y;
741 
742 #if defined(DEBUG) && 0
743  if (event.button==AW_BUTTON_LEFT) {
744  printf("-> x=%i y=%i\n", (int)event.type, (int)event.x, (int)event.y);
745  }
746 #endif
747 
749  ED4_ROOT->main_manager->event_sent_by_parent(&event, aww);
750  }
751 }
752 
754  AW_awar *awar = awr->awar(AWAR_SET_CURSOR_POSITION);
755  long pos = awar->read_int();
756 
757  if (pos != -1) {
758  ED4_MostRecentWinContext context;
759  ED4_cursor *cursor = &current_cursor();
760  cursor->jump_sequence_pos(pos, ED4_JUMP_CENTERED);
761  awar->write_int(-1);
762  }
763 }
764 
765 void ED4_jump_to_cursor_position(AW_window *aww, const char *awar_name, PositionType posType) {
766  ED4_LocalWinContext uses(aww);
767  ED4_cursor *cursor = &current_cursor();
768  GB_ERROR error = NULp;
769 
770  long pos = aww->get_root()->awar(awar_name)->read_int();
771 
772  if (pos>0) pos = bio2info(pos);
773  else if (pos<0) { // jump negative (count from back)
774  int last_pos = -1; // [1..]
775 
776  switch (posType) {
777  case ED4_POS_SEQUENCE: {
778  last_pos = MAXSEQUENCECHARACTERLENGTH;
779  break;
780  }
781  case ED4_POS_ECOLI: {
782  BI_ecoli_ref *ecoli = ED4_ROOT->ecoli_ref;
783  if (ecoli->gotData()) {
784  last_pos = ecoli->abs_2_rel(INT_MAX);
785  }
786  else {
787  last_pos = 0; // doesnt matter (error below)
788  }
789  break;
790  }
791  case ED4_POS_BASE: {
792  last_pos = cursor->sequence2base_position(INT_MAX);
793  break;
794  }
795  }
796 
797  e4_assert(last_pos != -1);
798  pos = bio2info(last_pos+1+pos);
799  }
800 
801  switch (posType) {
802  case ED4_POS_SEQUENCE: {
803  e4_assert(strcmp(awar_name, current_ed4w()->awar_path_for_cursor)==0);
804  break;
805  }
806  case ED4_POS_ECOLI: {
807  e4_assert(strcmp(awar_name, current_ed4w()->awar_path_for_Ecoli)==0);
808 
809  BI_ecoli_ref *ecoli = ED4_ROOT->ecoli_ref;
810  if (ecoli->gotData()) pos = ecoli->rel_2_abs(pos);
811  else error = "No ecoli reference";
812  break;
813  }
814  case ED4_POS_BASE: {
815  e4_assert(strcmp(awar_name, current_ed4w()->awar_path_for_basePos)==0);
816  pos = cursor->base2sequence_position(pos);
817  break;
818  }
819  }
820 
821  // now position is absolute [0..N-1]
822 
823  // limit to screen
824  {
825  ED4_remap *remap = ED4_ROOT->root_group_man->remap();
826  long max = remap->screen_to_sequence(remap->get_max_screen_pos());
827 
828  if (pos > max) pos = max;
829  else if (pos<0) pos = 0;
830  }
831 
832  if (error) {
833  aw_message(error);
834  }
835  else {
836  cursor->jump_sequence_pos(pos, ED4_JUMP_CENTERED);
837  }
838 }
839 
840 void ED4_set_helixnr(AW_window *aww, const char *awar_name) {
841  ED4_LocalWinContext uses(aww);
842  ED4_cursor *cursor = &current_cursor();
843 
844  if (cursor->owner_of_cursor) {
845  AW_root *root = aww->get_root();
846  char *helix_nr = root->awar(awar_name)->read_string();
847  BI_helix *helix = ED4_ROOT->helix;
848 
849  if (helix->has_entries()) {
850  long pos = helix->first_position(helix_nr);
851 
852  if (pos == -1) {
853  aw_message(GBS_global_string("No helix '%s' found", helix_nr));
854  }
855  else {
856  cursor->jump_sequence_pos(pos, ED4_JUMP_CENTERED);
857  }
858  }
859  else {
860  aw_message("Got no helix information");
861  }
862  free(helix_nr);
863  }
864 }
865 
866 void ED4_set_iupac(AW_window *aww, const char *awar_name) {
867  ED4_LocalWinContext uses(aww);
868  ED4_cursor *cursor = &current_cursor();
869 
870  if (cursor->owner_of_cursor) {
871  if (cursor->in_consensus_terminal()) {
872  aw_message("You cannot change the consensus");
873  }
874  else {
875  int len;
876  char *seq = cursor->owner_of_cursor->resolve_pointer_to_string_copy(&len);
877  int seq_pos = cursor->get_sequence_pos();
878 
879  e4_assert(seq);
880 
881  if (seq_pos<len) {
882  char *iupac = ED4_ROOT->aw_root->awar(awar_name)->read_string();
883  char new_char = iupac::encode(iupac, ED4_ROOT->alignment_type);
884 
885  seq[seq_pos] = new_char;
886  cursor->owner_of_cursor->write_sequence(seq, len);
887 
888  free(iupac);
889  }
890 
891  free(seq);
892  }
893  }
894 }
895 
896 void ED4_exit() {
897  // @@@ most of the code here could be placed in ED4_ROOT-dtor
898 
901 
903 
904  while (ed4w) {
905  ed4w->aww->hide();
906  ed4w->cursor.prepare_shutdown(); // removes any callbacks
907  ed4w = ed4w->next;
908  }
909 
910  while (ED4_ROOT->first_window) {
912  }
913 
915  delete ED4_ROOT;
916 
917 #if defined(DEBUG)
918  AWT_browser_forget_db(gb_main);
919 #endif // DEBUG
920  GB_close(gb_main);
921 
922  ::exit(EXIT_SUCCESS);
923 }
924 
926  ED4_LocalWinContext uses(aww); // @@@ dont use context here
927 
928  if (ED4_ROOT->first_window == current_ed4w()) { // quit button has been pressed in first window
929  ED4_exit();
930  }
931  // case : in another window close has been pressed
932  current_aww()->hide();
933  current_ed4w()->is_hidden = true;
934 }
935 
936 static int timer_calls = 0;
937 static int timer_calls_triggered = 0;
938 
939 static unsigned ED4_timer(AW_root *) {
940  timer_calls++;
941 
942 #if defined(TRACE_REFRESH)
943  fprintf(stderr, "ED4_timer\n"); fflush(stderr);
944 #endif
946 
947  // get all changes from server
948  GB_begin_transaction(gb_main);
949  GB_tell_server_dont_wait(gb_main);
950  GB_commit_transaction(gb_main);
951 
953 
954  if (timer_calls == timer_calls_triggered) {
955  timer_calls_triggered++;
956  return 2000; // trigger callback after 2s
957  }
958  return 0; // do not trigger callback
959 }
960 
962 #if defined(TRACE_REFRESH)
963  fprintf(stderr, "ED4_trigger_instant_refresh\n"); fflush(stderr);
964 #endif
965  timer_calls_triggered++;
966  ED4_ROOT->aw_root->add_timed_callback(1, makeTimedCallback(ED4_timer)); // trigger instant callback
967 }
969  ED4_ROOT->main_manager->request_refresh();
970 }
974 }
975 
978  ED4_ROOT->main_manager->request_resize();
980 }
981 
982 #define SIGNIFICANT_FIELD_CHARS 30 // length used to compare field contents (in createGroupFromSelected)
983 
984 static void createGroupFromSelected(GB_CSTR group_name, GB_CSTR field_name, GB_CSTR field_content) {
985  // creates a new group named group_name
986  // if field_name==0 -> all selected species & subgroups are moved to this new group
987  // if field_name!=0 -> all selected species containing field_content in field field_name are moved to this new group
988 
990  ED4_multi_species_manager *group_content_manager;
991  ED4_group_manager *new_group_manager = ED4_build_group_manager_start(top_multi_species_manager, group_name, 1, false, ED4_ROOT->ref_terminals, group_content_manager);
992  ED4_build_group_manager_end(group_content_manager);
993 
994  group_content_manager->update_requested_by_child();
995 
996  ED4_counter++;
998 
999  bool lookingForNoContent = !field_content || field_content[0]==0;
1000 
1002  while (list_elem) {
1003  ED4_base *object = list_elem->elem()->object;
1004  object = object->get_parent(LEV_SPECIES);
1005 
1006  bool move_object = true;
1007  if (object->is_consensus_manager()) {
1008  object = object->get_parent(LEV_GROUP);
1009  if (field_name) move_object = false; // don't move groups if moving by field_name
1010  }
1011  else {
1012  e4_assert(object->is_species_manager());
1013  if (field_name) {
1014  GBDATA *gb_species = object->get_species_pointer();
1015  GBDATA *gb_field = GB_search(gb_species, field_name, GB_FIND);
1016 
1017  move_object = lookingForNoContent;
1018  if (gb_field) { // field was found
1019  char *found_content = GB_read_as_string(gb_field);
1020  if (found_content) {
1021  move_object = strncmp(found_content, field_content, SIGNIFICANT_FIELD_CHARS)==0;
1022  free(found_content);
1023  }
1024  }
1025  }
1026  }
1027 
1028  if (move_object) {
1029  ED4_base *base = object->get_parent(LEV_MULTI_SPECIES);
1030  if (base && base->is_multi_species_manager()) {
1031  ED4_multi_species_manager *old_multi = base->to_multi_species_manager();
1032  old_multi->invalidate_species_counters();
1033  }
1034 
1035  object->parent->remove_member(object);
1036  group_content_manager->append_member(object);
1037 
1038  object->parent = group_content_manager;
1039  object->set_width();
1040  }
1041 
1042  list_elem = list_elem->next();
1043  }
1044 
1045  new_group_manager->create_consensus(new_group_manager, NULp);
1046  group_content_manager->invalidate_species_counters();
1047 
1048  new_group_manager->fold();
1049 
1050  group_content_manager->resize_requested_by_child();
1051 }
1052 
1053 static void group_species(bool use_field, AW_window *use_as_main_window) {
1054  GB_ERROR error = NULp;
1056  GB_push_transaction(gb_main);
1057 
1058  ED4_LocalWinContext uses(use_as_main_window);
1059 
1060  if (!use_field) {
1061  char *group_name = aw_input("Enter name for new group:");
1062 
1063  if (group_name) {
1064  if (strlen(group_name)>GB_GROUP_NAME_MAX) {
1065  group_name[GB_GROUP_NAME_MAX] = 0;
1066  aw_message("Truncated overlong group name");
1067  }
1068  createGroupFromSelected(group_name, NULp, NULp);
1069  free(group_name);
1070  }
1071  }
1072  else {
1073  char *field_name = ED4_ROOT->aw_root->awar(AWAR_FIELD_CHOSEN)->read_string();
1074  char *doneContents = ARB_strdup(";");
1075  size_t doneLen = 1;
1076 
1077  bool tryAgain = true;
1078  bool foundField = false;
1079  bool foundSpecies = false;
1080 
1081  if (strcmp(field_name, NO_FIELD_SELECTED) == 0) {
1082  error = "Please select a field to use for grouping.";
1083  }
1084 
1085  while (tryAgain && !error) {
1086  tryAgain = false;
1088  while (list_elem && !error) {
1089  ED4_base *object = list_elem->elem()->object;
1090  object = object->get_parent(LEV_SPECIES);
1091  if (!object->is_consensus_manager()) {
1092  GBDATA *gb_species = object->get_species_pointer();
1093  GBDATA *gb_field = NULp;
1094 
1095  if (gb_species) {
1096  foundSpecies = true;
1097  gb_field = GB_search(gb_species, field_name, GB_FIND);
1098  }
1099 
1100  error = GB_incur_error_if(!gb_field);
1101  if (!error) {
1102  e4_assert(gb_field);
1103  char *field_content = GB_read_as_string(gb_field);
1104  if (field_content) {
1105  size_t field_content_len = strlen(field_content);
1106 
1107  foundField = true;
1108  if (field_content_len>SIGNIFICANT_FIELD_CHARS) {
1109  field_content[SIGNIFICANT_FIELD_CHARS] = 0;
1110  field_content_len = SIGNIFICANT_FIELD_CHARS;
1111  }
1112 
1113  char with_semi[SIGNIFICANT_FIELD_CHARS+2+1];
1114  sprintf(with_semi, ";%s;", field_content);
1115 
1116  if (!strstr(doneContents, with_semi)) { // field_content was not used yet
1117  createGroupFromSelected(field_content, field_name, field_content);
1118  tryAgain = true;
1119 
1120  int newlen = doneLen + field_content_len + 1;
1121  char *newDone = ARB_alloc<char>(newlen+1);
1122 
1123  GBS_global_string_to_buffer(newDone, newlen+1, "%s%s;", doneContents, field_content);
1124  freeset(doneContents, newDone);
1125  doneLen = newlen;
1126  }
1127  free(field_content);
1128  }
1129  else {
1130  error = "Incompatible field type";
1131  }
1132  }
1133  }
1134  list_elem = list_elem->next();
1135  }
1136  }
1137 
1138  if (!error) {
1139  if (!foundSpecies) error = "Please select some species in order to insert them into new groups";
1140  else if (!foundField) error = GBS_global_string("Field not found: '%s'%s", field_name, error ? GBS_global_string(" (Reason: %s)", error) : "");
1141  }
1142 
1143  free(doneContents);
1144  free(field_name);
1145  }
1146 
1147  GB_end_transaction_show_error(gb_main, error, aw_message);
1148 }
1149 
1150 static void group_species_by_field_content(AW_window*, AW_window *use_as_main_window, AW_window *window_to_hide) {
1151  group_species(true, use_as_main_window);
1152  window_to_hide->hide();
1153 }
1154 
1155 static AW_window *create_group_species_by_field_window(AW_root *aw_root, AW_window *use_as_main_window) {
1156  AW_window_simple *aws = new AW_window_simple;
1157 
1158  aws->init(aw_root, "CREATE_GROUP_USING_FIELD_CONTENT", "Create groups using field");
1159  aws->auto_space(10, 10);
1160 
1161  aws->button_length(10);
1162  aws->at_newline();
1163 
1164  aws->callback(AW_POPDOWN);
1165  aws->create_button("CLOSE", "CLOSE", "C");
1166 
1167  aws->callback(makeHelpCallback("group_by_field.hlp"));
1168  aws->create_button("HELP", "HELP", "H");
1169 
1170  aws->at_newline();
1171  aws->label("Use content of field");
1173 
1174  aws->at_newline();
1175  aws->callback(makeWindowCallback(group_species_by_field_content, use_as_main_window, static_cast<AW_window*>(aws)));
1176  aws->create_autosize_button("USE_FIELD", "Group selected species by content", "");
1177 
1178  return aws;
1179 }
1180 
1181 void group_species_cb(AW_window *aww, bool use_fields) {
1182  if (!use_fields) {
1183  group_species(false, aww);
1184  }
1185  else {
1186  static AW_window *ask_field_window;
1187 
1188  if (!ask_field_window) ask_field_window = create_group_species_by_field_window(ED4_ROOT->aw_root, aww);
1189  ask_field_window->activate();
1190  }
1191 }
1192 
1193 static GB_ERROR ED4_load_new_config(char *name) {
1194  GB_ERROR error;
1195  GBT_config cfg(ED4_ROOT->get_gb_main(), name, error);
1196  if (cfg.exists()) {
1197  ED4_ROOT->main_manager->clear_whole_background();
1198 
1200 
1202 
1203  if (ED4_ROOT->selected_objects->size() > 0) {
1205  }
1206 
1208 
1212 
1214 
1215  for (ED4_window *window = ED4_ROOT->first_window; window; window=window->next) {
1216  window->cursor.init();
1217  window->aww->set_horizontal_scrollbar_position (0);
1218  window->aww->set_vertical_scrollbar_position (0);
1219  }
1220 
1225 
1226  delete ED4_ROOT->main_manager;
1228  delete ED4_ROOT->ecoli_ref;
1229 
1231  ED4_ROOT->create_hierarchy(cfg.get_definition(GBT_config::MIDDLE_AREA), cfg.get_definition(GBT_config::TOP_AREA));
1232  }
1233 
1234  return error;
1235 }
1236 
1238  if (!root->awar(AWAR_EDIT_MODE)->read_int()) return AD_ALIGN;
1239  return root->awar(AWAR_INSERT_MODE)->read_int() ? AD_INSERT : AD_REPLACE;
1240 }
1241 
1243  ED4_EDITMODE mode = ED4_get_edit_mode(root);
1244  const char *awar_name = NULp;
1245 
1246  switch (mode) {
1247  case AD_ALIGN:
1248  awar_name = AWAR_EDIT_SECURITY_LEVEL_ALIGN;
1249  break;
1250  default:
1251  awar_name = AWAR_EDIT_SECURITY_LEVEL_CHANGE;
1252  }
1253 
1255 
1256  long level = ED4_ROOT->aw_root->awar(awar_name)->read_int();
1257  GB_change_my_security(ED4_ROOT->get_gb_main(), level); // change user security in EDIT4
1258 }
1259 
1262  ed4_changesecurity(root);
1263 }
1264 
1266  if (object->is_consensus_manager()) {
1267  ED4_species_manager *spec_man = object->to_species_manager();
1268  spec_man->do_callbacks();
1269 
1270  ED4_base *sequence_data_terminal = spec_man->search_spec_child_rek(LEV_SEQUENCE_STRING);
1271  sequence_data_terminal->request_refresh();
1272  }
1273  return NULp; // needed by route_down_hierarchy
1274 }
1275 
1277  ED4_LocalWinContext uses(aww);
1278 
1279  AW_device *device;
1280  ED4_window *new_window = NULp;
1281 
1282  if (ED4_ROOT->generate_window(&device, &new_window) != ED4_R_BREAK) {
1283  ED4_LocalWinContext now_uses(new_window);
1284 
1289 
1290  new_window->aww->show();
1291  new_window->update_scrolled_rectangle();
1292  }
1293 }
1294 
1295 
1296 
1298  aww->hide();
1299 
1300  GB_ERROR error;
1301  {
1302  char *name = aww->get_root()->awar(AWAR_EDIT_CONFIGURATION)->read_string();
1303  error = ED4_load_new_config(name);
1304  free(name);
1305  }
1306 
1307  if (error) {
1308  aw_message(error);
1309  aww->show(); // show old window
1310  }
1311 }
1312 
1313 struct cursorpos {
1316  int seq;
1317 
1319  : cursor(&win->cursor),
1320  screen_rel(cursor->get_screen_relative_pos()),
1321  seq(cursor->get_sequence_pos())
1322  {}
1323 };
1324 
1325 
1328  int percent = awr->awar(ED4_AWAR_COMPRESS_SEQUENCE_PERCENT)->read_int();
1330 
1331  if (ED4_ROOT->root_group_man) {
1332  vector<cursorpos> pos;
1333 
1334  for (ED4_window *win = ED4_ROOT->first_window; win; win = win->next) {
1335  pos.push_back(cursorpos(win));
1336  }
1337 
1338  ED4_ROOT->root_group_man->remap()->set_mode(mode, percent);
1340 
1341  for (vector<cursorpos>::iterator i = pos.begin(); i != pos.end(); ++i) {
1342  ED4_cursor *cursor = i->cursor;
1343  ED4_window *win = cursor->window();
1344 
1345  win->update_scrolled_rectangle(); // @@@ needed ?
1346 
1347  cursor->jump_sequence_pos(i->seq, ED4_JUMP_KEEP_POSITION);
1348  cursor->set_screen_relative_pos(i->screen_rel);
1349  }
1350 
1352  }
1353 }
1354 
1355 void ED4_compression_toggle_changed_cb(AW_root *root, bool hideChanged) {
1356  int gaps = root->awar(ED4_AWAR_COMPRESS_SEQUENCE_GAPS)->read_int();
1357  int hide = root->awar(ED4_AWAR_COMPRESS_SEQUENCE_HIDE)->read_int();
1358 
1359  ED4_remap_mode mode = ED4_remap_mode(root->awar(ED4_AWAR_COMPRESS_SEQUENCE_TYPE)->read_int()); // @@@ mode is overwritten below
1360 
1361  if (hideChanged) {
1362  // ED4_AWAR_COMPRESS_SEQUENCE_HIDE changed
1363  if (hide!=0 && gaps!=2) {
1365  return;
1366  }
1367  }
1368  else {
1369  // ED4_AWAR_COMPRESS_SEQUENCE_GAPS changed
1370  if (gaps!=2 && hide!=0) {
1372  return;
1373  }
1374  }
1375 
1376  mode = ED4_RM_NONE;
1377  switch (gaps) {
1378  case 0: mode = ED4_RM_NONE; break;
1379  case 1: mode = ED4_RM_DYNAMIC_GAPS; break;
1380  case 2: {
1381  switch (hide) {
1382  case 0: mode = ED4_RM_MAX_ALIGN; break;
1383  case 1: mode = ED4_RM_SHOW_ABOVE; break;
1384  default: e4_assert(0); break;
1385  }
1386  break;
1387  }
1388  default: e4_assert(0); break;
1389  }
1390 
1391  root->awar(ED4_AWAR_COMPRESS_SEQUENCE_TYPE)->write_int(int(mode));
1392 }
1393 
1395  { ED4_AWAR_COMPRESS_SEQUENCE_GAPS, "compressgaps" },
1396  { ED4_AWAR_COMPRESS_SEQUENCE_HIDE, "hidenucs" },
1397  { ED4_AWAR_COMPRESS_SEQUENCE_PERCENT, "hidepercent" },
1398  { AWAR_EDIT_HELIX_SPACING, "helixspacing" },
1399  { AWAR_EDIT_TERMINAL_SPACING, "terminalspacing" },
1400  { ED4_AWAR_SCROLL_SPEED_X, "scrollspeedx" },
1401  { ED4_AWAR_SCROLL_SPEED_Y, "scrollspeedy" },
1402  { ED4_AWAR_SCROLL_MARGIN, "scrollmargin" },
1403  { ED4_AWAR_GAP_CHARS, "gapchars" },
1404  { ED4_AWAR_DIGITS_AS_REPEAT, "digitsasrepeat" },
1405  { ED4_AWAR_FAST_CURSOR_JUMP, "fastcursorjump" },
1406  { ED4_AWAR_ANNOUNCE_CHECKSUM_CHANGES, "announcechecksumchanges" },
1407 
1408  { NULp, NULp }
1409 };
1410 
1412  AW_window_simple *aws = new AW_window_simple;
1413 
1414  aws->init(root, "EDIT4_PROPS", "EDIT4 Options");
1415  aws->load_xfig("edit4/options.fig");
1416 
1417  aws->auto_space(5, 5);
1418 
1419  const int SCALEDCOLUMNS = 4;
1420  const int SCALERLEN = 200;
1421 
1422  aws->callback(AW_POPDOWN);
1423  aws->at("close");
1424  aws->create_button("CLOSE", "CLOSE", "C");
1425 
1426  aws->callback(makeHelpCallback("e4_options.hlp"));
1427  aws->at("help");
1428  aws->create_button("HELP", "HELP", "H");
1429 
1430  // -----------------------------------
1431  // Online Sequence Compression
1432 
1433  aws->at("gaps");
1434  aws->create_toggle_field(ED4_AWAR_COMPRESS_SEQUENCE_GAPS);
1435  aws->insert_default_toggle("Show all gaps", "A", 0);
1436  aws->insert_toggle("Show some gaps", "S", 1);
1437  aws->insert_toggle("Hide all gaps", "H", 2);
1438  aws->update_toggle_field();
1439 
1440  aws->at("hide");
1441  aws->create_toggle_field(ED4_AWAR_COMPRESS_SEQUENCE_HIDE);
1442  aws->insert_default_toggle("Hide no Nucleotides", "0", 0);
1443  aws->insert_toggle("Hide columns with less than...", "1", 1);
1444  aws->update_toggle_field();
1445 
1446  aws->at("percent");
1447  aws->create_input_field_with_scaler(ED4_AWAR_COMPRESS_SEQUENCE_PERCENT, SCALEDCOLUMNS, SCALERLEN, AW_SCALER_LINEAR);
1448 
1449  // --------------
1450  // Layout
1451 
1452  aws->at("seq_helix"); aws->create_input_field_with_scaler(AWAR_EDIT_HELIX_SPACING, SCALEDCOLUMNS, SCALERLEN, AW_SCALER_EXP_CENTER);
1453  aws->at("seq_seq"); aws->create_input_field_with_scaler(AWAR_EDIT_TERMINAL_SPACING, SCALEDCOLUMNS, SCALERLEN, AW_SCALER_EXP_CENTER);
1454 
1455  // --------------------
1456  // Scroll-Speed
1457 
1458  aws->at("scroll_x");
1459  aws->create_input_field(ED4_AWAR_SCROLL_SPEED_X);
1460 
1461  aws->at("scroll_y");
1462  aws->create_input_field(ED4_AWAR_SCROLL_SPEED_Y);
1463 
1464  aws->at("margin");
1465  aws->create_input_field(ED4_AWAR_SCROLL_MARGIN);
1466 
1467  // ---------------
1468  // Editing
1469 
1470  aws->at("gapchars");
1471  aws->create_input_field(ED4_AWAR_GAP_CHARS);
1472 
1473  aws->at("repeat");
1474  aws->create_toggle(ED4_AWAR_DIGITS_AS_REPEAT);
1475 
1476  aws->at("fast");
1477  aws->create_toggle(ED4_AWAR_FAST_CURSOR_JUMP);
1478 
1479  aws->at("checksum");
1480  aws->create_toggle(ED4_AWAR_ANNOUNCE_CHECKSUM_CHANGES);
1481 
1482  aws->at("config");
1483  AWT_insert_config_manager(aws, AW_ROOT_DEFAULT, "options", editor_options_config_mapping);
1484 
1485  return aws;
1486 }
1487 
1495 
1496  { NULp, NULp }
1497 };
1498 
1500  // keep in sync with ../NTREE/AP_consensus.cxx@AP_create_con_expert_window
1501 
1502  static AW_window_simple *aws = NULp;
1503 
1504  if (!aws) {
1505  aws = new AW_window_simple;
1506 
1507  aws->init(root, "EDIT4_CONSENSUS_DEFm", "EDIT4 Consensus Definition");
1508  aws->load_xfig("edit4/consensus.fig");
1509 
1510  aws->auto_space(5, 5);
1511 
1512  const int SCALEDCOLUMNS = 3;
1513  const int SCALERSIZE = 150;
1514 
1515  // top part of window:
1516  aws->button_length(9);
1517 
1518  aws->callback(AW_POPDOWN);
1519  aws->at("close");
1520  aws->create_button("CLOSE", "CLOSE", "C");
1521 
1522  aws->callback(makeHelpCallback("e4_consensus.hlp"));
1523  aws->at("help");
1524  aws->create_button("HELP", "HELP", "H");
1525 
1526  // center part of window (same as in NTREE):
1527  aws->at("countgaps");
1528  aws->create_toggle_field(ED4_AWAR_CONSENSUS_COUNTGAPS);
1529  aws->insert_toggle("on", "1", 1);
1530  aws->insert_default_toggle("off", "0", 0);
1531  aws->update_toggle_field();
1532 
1533  aws->at("gapbound");
1534  aws->create_input_field_with_scaler(ED4_AWAR_CONSENSUS_GAPBOUND, SCALEDCOLUMNS, SCALERSIZE, AW_SCALER_LINEAR);
1535 
1536  aws->at("group");
1537  aws->create_toggle_field(ED4_AWAR_CONSENSUS_GROUP);
1538  aws->insert_toggle("on", "1", 1);
1539  aws->insert_default_toggle("off", "0", 0);
1540  aws->update_toggle_field();
1541 
1542  aws->at("considbound");
1543  aws->create_input_field_with_scaler(ED4_AWAR_CONSENSUS_CONSIDBOUND, SCALEDCOLUMNS, SCALERSIZE, AW_SCALER_LINEAR);
1544 
1545  aws->at("showgroups");
1546  aws->callback(AWT_create_IUPAC_info_window);
1547  aws->create_autosize_button("SHOW_IUPAC", "Show IUPAC groups", "S");
1548 
1549  aws->at("upper");
1550  aws->create_input_field_with_scaler(ED4_AWAR_CONSENSUS_UPPER, SCALEDCOLUMNS, SCALERSIZE, AW_SCALER_LINEAR);
1551 
1552  aws->at("lower");
1553  aws->create_input_field_with_scaler(ED4_AWAR_CONSENSUS_LOWER, SCALEDCOLUMNS, SCALERSIZE, AW_SCALER_LINEAR);
1554 
1555  // bottom part of window:
1556  aws->at("show");
1557  aws->label("Display consensus?");
1558  aws->create_toggle(ED4_AWAR_CONSENSUS_SHOW);
1559 
1560  aws->at("config");
1561  AWT_insert_config_manager(aws, AW_ROOT_DEFAULT, CONSENSUS_CONFIG_ID, consensus_config_mapping);
1562  }
1563 
1564  return aws;
1565 }
1566 
1567 static void consensus_upper_lower_changed_cb(AW_root *awr, bool upper_changed) {
1568  AW_awar *awar_lower = awr->awar(ED4_AWAR_CONSENSUS_LOWER);
1569  AW_awar *awar_upper = awr->awar(ED4_AWAR_CONSENSUS_UPPER);
1570 
1571  int lower = awar_lower->read_int();
1572  int upper = awar_upper->read_int();
1573 
1574  if (upper<lower) {
1575  if (upper_changed) awar_lower->write_int(upper);
1576  else awar_upper->write_int(lower);
1577  }
1579 }
1580 
1583 
1588  aw_root->awar_int(ED4_AWAR_CONSENSUS_UPPER, 95)->set_minmax(0, 100)->add_callback(makeRootCallback(consensus_upper_lower_changed_cb, true));
1589  aw_root->awar_int(ED4_AWAR_CONSENSUS_LOWER, 70)->set_minmax(0, 100)->add_callback(makeRootCallback(consensus_upper_lower_changed_cb, false));
1590 
1591  AW_awar *cons_show = aw_root->awar_int(ED4_AWAR_CONSENSUS_SHOW, 1);
1592 
1593  cons_show->write_int(1);
1595 }
1596 
1599 }
1600 
1602  static AW_window_simple *aws = NULp;
1603  if (!aws) {
1604  aws = new AW_window_simple;
1605  aws->init(awr, "LOAD_CONFIGURATION", "Load existing configuration");
1606  aws->load_xfig("edit4/load_config.fig");
1607 
1608  aws->at("close");
1609  aws->callback(AW_POPDOWN);
1610  aws->create_button("CLOSE", "CLOSE", "C");
1611 
1612  aws->at("help");
1613  aws->callback(makeHelpCallback("species_configs_saveload.hlp"));
1614  aws->create_button("HELP", "HELP");
1615 
1616  aws->at("confs");
1618 
1619  aws->at("go");
1620  aws->callback(ED4_start_editor_on_configuration);
1621  aws->create_button("LOAD", "LOAD");
1622 
1623  aws->window_fit();
1624  }
1625  return aws;
1626 }
1627 
1628 void ED4_saveConfiguration(AW_window *aww, bool hide_aww) {
1629  if (hide_aww) aww->hide();
1630 
1631  char *name = aww->get_root()->awar(AWAR_EDIT_CONFIGURATION)->read_string();
1633  free(name);
1634 }
1635 
1637  static AW_window_simple *aws = NULp;
1638  if (!aws) {
1639  aws = new AW_window_simple;
1640  aws->init(awr, "SAVE_CONFIGURATION", "Save current configuration as");
1641  aws->load_xfig("edit4/save_config.fig");
1642 
1643  aws->at("close");
1644  aws->callback(AW_POPDOWN);
1645  aws->create_button("CLOSE", "CLOSE");
1646 
1647  aws->at("help");
1648  aws->callback(makeHelpCallback("species_configs_saveload.hlp"));
1649  aws->create_button("HELP", "HELP");
1650 
1651  aws->at("save");
1652  aws->create_input_field(AWAR_EDIT_CONFIGURATION);
1653 
1654  aws->at("confs");
1656 
1657  aws->at("go");
1658  aws->callback(makeWindowCallback(ED4_saveConfiguration, true));
1659  aws->create_button("SAVE", "SAVE");
1660  }
1661  return aws;
1662 }
1663 
1664 static char *filter_loadable_SAIs(GBDATA *gb_sai) {
1665  GBDATA *gb_ali = GB_search(gb_sai, ED4_ROOT->alignment_name, GB_FIND);
1666  if (gb_ali) {
1667  GBDATA *gb_data = GB_search(gb_ali, "data", GB_FIND);
1668  if (gb_data) {
1669  const char *sai_name = GBT_get_name(gb_sai);
1670  if (sai_name && !ED4_find_SAI_name_terminal(sai_name)) { // if not loaded yet
1671  return ARB_strdup(sai_name);
1672  }
1673  }
1674  }
1675  return NULp;
1676 }
1677 
1679  static AW_window_simple *aws = NULp;
1680  if (!aws) {
1681  aws = new AW_window_simple;
1682  aws->init(awr, "LOAD_SAI", "Load additional SAI");
1683  aws->load_xfig("edit4/load_sai.fig");
1684 
1685  aws->at("close");
1686  aws->callback(AW_POPDOWN);
1687  aws->create_button("CLOSE", "CLOSE");
1688 
1689  aws->at("help");
1690  aws->callback(makeHelpCallback("e4_get_species.hlp"));
1691  aws->create_button("HELP", "HELP");
1692 
1693  aws->at("sai");
1694  awt_create_SAI_selection_list(ED4_ROOT->get_gb_main(), aws, AWAR_SAI_NAME, false, makeSaiSelectionlistFilterCallback(filter_loadable_SAIs));
1696 
1697  aws->at("go");
1698  aws->callback(ED4_get_and_jump_to_selected_SAI);
1699  aws->create_button("LOAD", "LOAD");
1700  }
1701  return aws;
1702 }
1703 
1705  GB_ERROR error = NULp;
1706 
1707  int len;
1708  char *consensus = group_man->build_consensus_string(&len);
1709 
1713 
1714  for (int p=0; p<len; p++) {
1715  switch (consensus[p]) {
1716  case '=': consensus[p] = equal_to[0]; break;
1717  case '.': consensus[p] = point_to[0]; break;
1718  default: {
1719  if (allUpper) {
1720  consensus[p] = toupper(consensus[p]);
1721  }
1722  break;
1723  }
1724  }
1725  }
1726 
1727  if (ED4_ROOT->aw_root->awar(ED4_AWAR_CREATE_FROM_CONS_CREATE_POINTS)) { // points at start & end of sequence?
1728  for (int p=0; p<len; p++) {
1729  if (!ED4_is_gap_character(consensus[p])) break;
1730  consensus[p] = '.';
1731  }
1732  for (int p=len-1; p>=0; p--) {
1733  if (!ED4_is_gap_character(consensus[p])) break;
1734  consensus[p] = '.';
1735  }
1736  }
1737 
1739  GBDATA *gb_ali = GB_search(gb_species, ali, GB_DB);
1740  if (gb_ali) {
1741  GBDATA *gb_data = GB_search(gb_ali, "data", GB_STRING);
1742  error = GB_write_pntr(gb_data, consensus, len+1, len);
1743  }
1744  else {
1745  error = GB_export_errorf("Can't find alignment '%s'", ali);
1746  }
1747  free(consensus);
1748  return error;
1749 }
1750 
1751 // --------------------------------------------------------------------------------
1752 
1756 
1758 };
1759 
1761  GB_ERROR error = NULp;
1762 
1763  if (base->is_species_name_terminal()) {
1764  ED4_species_name_terminal *name_term = base->to_species_name_terminal();
1765 
1766  if (!name_term->inside_consensus_manager()) {
1767  char *species_name = name_term->resolve_pointer_to_string_copy();
1768  GBDATA *gb_species = GBT_find_species_rel_species_data(gb_species_data, species_name);
1769 
1770  if (gb_species) {
1772 
1773  sml->species = gb_species;
1774  sml->species_name = ARB_strdup(species_name);
1775  sml->next = *smlp;
1776  *smlp = sml;
1777  }
1778  else {
1779  error = GB_append_exportedError(GBS_global_string("can't find species '%s'", species_name));
1780  }
1781 
1782  free(species_name);
1783  }
1784  }
1785  return error;
1786 }
1788  int length = 0;
1789 
1790  while (sml) {
1791  length++;
1792  sml = sml->next;
1793  }
1794 
1795  return length;
1796 }
1798  while (sml) {
1799  free(sml->species_name);
1800  freeset(sml, sml->next);
1801  }
1802 }
1803 
1804 // --------------------------------------------------------------------------------
1805 
1806 inline bool nameIsUnique(const char *short_name, GBDATA *gb_species_data) {
1807  return !GBT_find_species_rel_species_data(gb_species_data, short_name);
1808 }
1809 
1810 
1811 static void create_new_species(AW_window *, SpeciesCreationMode creation_mode) {
1812  char *new_species_full_name = ED4_ROOT->aw_root->awar(ED4_AWAR_SPECIES_TO_CREATE)->read_string(); // this contains the full_name now!
1813  ARB_ERROR error = NULp;
1814 
1815  e4_assert(creation_mode>=0 && creation_mode<=2);
1816 
1817  if (!new_species_full_name || new_species_full_name[0]==0) {
1818  error = "Please enter a full_name for the new species";
1819  }
1820  else {
1821  ED4_MostRecentWinContext context;
1822 
1824  error = GB_begin_transaction(gb_main);
1825 
1827  char *new_species_name = NULp;
1828  char *acc = NULp;
1829  char *addid = NULp;
1830 
1831  enum e_dataSource { MERGE_FIELDS, COPY_FIELDS } dataSource = (enum e_dataSource)ED4_ROOT->aw_root ->awar(ED4_AWAR_CREATE_FROM_CONS_DATA_SOURCE)->read_int();
1832  enum { NOWHERE, ON_SPECIES, ON_CONSENSUS } where_we_are = NOWHERE;
1833  ED4_terminal *cursor_terminal = NULp;
1834 
1835  if (!error) {
1836  if (creation_mode==CREATE_FROM_CONSENSUS || creation_mode==COPY_SPECIES) {
1837  ED4_cursor *cursor = &current_cursor();
1838 
1839  if (cursor->owner_of_cursor) {
1840  cursor_terminal = cursor->owner_of_cursor;
1841  where_we_are = cursor_terminal->is_consensus_terminal() ? ON_CONSENSUS : ON_SPECIES;
1842  }
1843  }
1844 
1845  if (creation_mode==COPY_SPECIES || (creation_mode==CREATE_FROM_CONSENSUS && dataSource==COPY_FIELDS)) {
1846  if (where_we_are==ON_SPECIES) {
1847  ED4_species_name_terminal *spec_name = cursor_terminal->to_sequence_terminal()->corresponding_species_name_terminal();
1848  const char *source_name = spec_name->resolve_pointer_to_char_pntr();
1849  GBDATA *gb_source = GBT_find_species_rel_species_data(gb_species_data, source_name);
1850 
1851  if (!gb_source) error = GBS_global_string("No such species: '%s'", source_name);
1852  else {
1853  GBDATA *gb_acc = GB_search(gb_source, "acc", GB_FIND);
1854  if (gb_acc) acc = GB_read_string(gb_acc); // if has accession
1855 
1856  const char *add_field = AW_get_nameserver_addid(gb_main);
1857  GBDATA *gb_addid = add_field[0] ? GB_search(gb_source, add_field, GB_FIND) : NULp;
1858  if (gb_addid) addid = GB_read_as_string(gb_addid);
1859  }
1860  }
1861  else {
1862  error = "Please place cursor on a species";
1863  }
1864  }
1865  }
1866 
1867  if (!error) {
1868  UniqueNameDetector *existingNames = NULp;
1869 
1870  if (creation_mode==0) {
1871  error = "It's no good idea to create the short-name for a new species using the nameserver! (has no acc yet)";
1872  }
1873  else {
1874  error = AWTC_generate_one_name(gb_main, new_species_full_name, acc, addid, new_species_name);
1875  if (!error) { // name was created
1876  if (!nameIsUnique(new_species_name, gb_species_data)) {
1877  if (!existingNames) existingNames = new UniqueNameDetector(gb_species_data);
1878  freeset(new_species_name, AWTC_makeUniqueShortName(new_species_name, *existingNames));
1879  if (!new_species_name) error = GB_await_error();
1880  }
1881  }
1882  }
1883 
1884  if (error) { // try to make a random name
1885  const char *msg = GBS_global_string("%s\nGenerating a random name instead.", error.deliver());
1886  aw_message(msg);
1887  error = NULp;
1888 
1889  if (!existingNames) existingNames = new UniqueNameDetector(gb_species_data);
1890  new_species_name = AWTC_generate_random_name(*existingNames);
1891 
1892  if (!new_species_name) {
1893  error = GBS_global_string("Failed to create a new name for '%s'", new_species_full_name);
1894  }
1895  }
1896 
1897  if (existingNames) delete existingNames;
1898  }
1899 
1900  if (!error) {
1901  if (!error) {
1902  if (creation_mode==CREATE_NEW_SPECIES) {
1903  GBDATA *gb_created_species = GBT_find_or_create_species(gb_main, new_species_name, true);
1904  if (!gb_created_species) {
1905  error = GBS_global_string("Failed to create new species '%s'", new_species_name);
1906  }
1907  else {
1908  GB_CSTR ali = GBT_get_default_alignment(gb_main);
1909  GBDATA *gb_ali = GB_search(gb_created_species, ali, GB_DB);
1910 
1911  if (gb_ali) error = GBT_write_string(gb_ali, "data", ".......");
1912  else error = GBS_global_string("Can't create alignment '%s' (Reason: %s)", ali, GB_await_error());
1913  }
1914  if (!error) error = GBT_write_string(gb_created_species, "full_name", new_species_full_name);
1915  }
1916  else if (creation_mode==CREATE_FROM_CONSENSUS && dataSource==MERGE_FIELDS) {
1917  // create from consensus (merge fields from all species in container)
1918  if (where_we_are==NOWHERE) {
1919  error = "Please place cursor on any sequence/consensus of group";
1920  }
1921  else {
1922  ED4_group_manager *group_man = cursor_terminal->get_parent(LEV_GROUP)->to_group_manager();
1923  SpeciesMergeList *sml = NULp; // list of species in group
1924 
1925  error = group_man->route_down_hierarchy(makeED4_route_cb(add_species_to_merge_list, &sml, gb_species_data));
1926  if (!error && !sml) {
1927  error = "Please choose a none empty group!";
1928  }
1929 
1930  GBDATA *gb_new_species = NULp;
1931  if (!error) {
1932  GBDATA *gb_source = sml->species;
1933  gb_new_species = GB_create_container(gb_species_data, "species");
1934  error = GB_copy_dropProtectMarksAndTempstate(gb_new_species, gb_source); // copy first found species to create a new species
1935  }
1936  if (!error) error = GBT_write_string(gb_new_species, "name", new_species_name); // insert new 'name'
1937  if (!error) error = GBT_write_string(gb_new_species, "full_name", new_species_full_name); // insert new 'full_name'
1938  if (!error) error = createDataFromConsensus(gb_new_species, group_man); // insert consensus as 'data'
1939 
1940  if (!error) {
1941  char *doneFields = ARB_strdup(";name;full_name;"); // all fields which are already merged
1942  int doneLen = strlen(doneFields);
1943  SpeciesMergeList *sl = sml;
1944  int sl_length = SpeciesMergeListLength(sml);
1945  int *fieldStat = new int[sl_length]; // 0 = not used yet ; -1 = don't has field ; 1..n = field content, same number means same content
1946 
1947  arb_progress progress("Merging fields", long(sl_length));
1948 
1949  while (sl && !error) { // with all species do..
1950  char *newFields = GB_get_subfields(sl->species);
1951  char *fieldStart = newFields; // points to ; before next field
1952 
1953  while (fieldStart[1] && !error) { // with all subfields of the species do..
1954  char *fieldEnd = strchr(fieldStart+1, ';');
1955 
1956  e4_assert(fieldEnd);
1957  char behind = fieldEnd[1];
1958  fieldEnd[1] = 0;
1959 
1960  if (!strstr(doneFields, fieldStart)) { // field is not merged yet
1961  char *fieldName = fieldStart+1;
1962  int fieldLen = int(fieldEnd-fieldName);
1963 
1964  e4_assert(fieldEnd[0]==';');
1965  fieldEnd[0] = 0;
1966 
1967  GBDATA *gb_field = GB_search(sl->species, fieldName, GB_FIND);
1968  e4_assert(gb_field); // field has to exist, cause it was found before
1969 
1970  GB_TYPES type = GB_read_type(gb_field);
1971  if (type==GB_STRING) { // we only merge string fields
1972  int i;
1973  int doneSpecies = 0;
1974  int nextStat = 1;
1975 
1976  for (i=0; i<sl_length; i++) { // clear field status
1977  fieldStat[i] = 0;
1978  }
1979 
1980  while (doneSpecies<sl_length) { // since all species in list were handled
1981  SpeciesMergeList *sl2 = sml;
1982  i = 0;
1983 
1984  while (sl2) {
1985  if (fieldStat[i]==0) {
1986  gb_field = GB_search(sl2->species, fieldName, GB_FIND);
1987  if (gb_field) {
1988  char *content = GB_read_as_string(gb_field);
1989  SpeciesMergeList *sl3 = sl2->next;
1990 
1991  fieldStat[i] = nextStat;
1992  doneSpecies++;
1993  int j = i+1;
1994  while (sl3) {
1995  if (fieldStat[j]==0) {
1996  gb_field = GB_search(sl3->species, fieldName, GB_FIND);
1997  if (gb_field) {
1998  char *content2 = GB_read_as_string(gb_field);
1999 
2000  if (strcmp(content, content2)==0) { // if contents are the same, they get the same status
2001  fieldStat[j] = nextStat;
2002  doneSpecies++;
2003  }
2004  free(content2);
2005  }
2006  else {
2007  fieldStat[j] = -1;
2008  doneSpecies++;
2009  }
2010  }
2011  sl3 = sl3->next;
2012  j++;
2013  }
2014 
2015  free(content);
2016  nextStat++;
2017  }
2018  else {
2019  fieldStat[i] = -1; // field does not exist here
2020  doneSpecies++;
2021  }
2022  }
2023  sl2 = sl2->next;
2024  i++;
2025  }
2026  }
2027 
2028  e4_assert(nextStat!=1); // this would mean that none of the species contained the field
2029 
2030  {
2031  char *new_content = NULp;
2032  int new_content_len = 0;
2033 
2034  if (nextStat==2) { // all species contain same field content or do not have the field
2035  SpeciesMergeList *sl2 = sml;
2036 
2037  while (sl2) {
2038  gb_field = GB_search(sl2->species, fieldName, GB_FIND);
2039  if (gb_field) {
2040  new_content = GB_read_as_string(gb_field);
2041  new_content_len = strlen(new_content); // @@@ new_content_len never used
2042  break;
2043  }
2044  sl2 = sl2->next;
2045  }
2046  }
2047  else { // different field contents
2048  int currStat;
2049  for (currStat=1; currStat<nextStat; currStat++) {
2050  int names_len = 1; // open bracket
2051  SpeciesMergeList *sl2 = sml;
2052  i = 0;
2053  char *content = NULp;
2054 
2055  while (sl2) {
2056  if (fieldStat[i]==currStat) {
2057  names_len += strlen(sl2->species_name)+1;
2058  if (!content) {
2059  gb_field = GB_search(sl2->species, fieldName, GB_FIND);
2060  e4_assert(gb_field);
2061  content = GB_read_as_string(gb_field);
2062  }
2063  }
2064  sl2 = sl2->next;
2065  i++;
2066  }
2067 
2068  e4_assert(content);
2069  int add_len = names_len+1+strlen(content);
2070  char *whole = ARB_alloc<char>(new_content_len+1+add_len+1);
2071  e4_assert(whole);
2072  char *add = new_content ? whole+sprintf(whole, "%s ", new_content) : whole;
2073  sl2 = sml;
2074  i = 0;
2075  int first = 1;
2076  while (sl2) {
2077  if (fieldStat[i]==currStat) {
2078  add += sprintf(add, "%c%s", first ? '{' : ';', sl2->species_name);
2079  first = 0;
2080  }
2081  sl2 = sl2->next;
2082  i++;
2083  }
2084  add += sprintf(add, "} %s", content);
2085 
2086  free(content);
2087 
2088  freeset(new_content, whole);
2089  new_content_len = strlen(new_content);
2090  }
2091  }
2092 
2093  if (new_content) {
2094  error = GBT_write_string(gb_new_species, fieldName, new_content);
2095  free(new_content);
2096  }
2097  }
2098  }
2099 
2100  // mark field as done:
2101  char *new_doneFields = ARB_alloc<char>(doneLen+fieldLen+1+1);
2102  sprintf(new_doneFields, "%s%s;", doneFields, fieldName);
2103  doneLen += fieldLen+1;
2104  freeset(doneFields, new_doneFields);
2105 
2106  fieldEnd[0] = ';';
2107  }
2108 
2109  fieldEnd[1] = behind;
2110  fieldStart = fieldEnd;
2111  }
2112  free(newFields);
2113  sl = sl->next;
2114  progress.inc_and_check_user_abort(error);
2115  }
2116  free(doneFields);
2117  delete [] fieldStat;
2118  }
2119  freeSpeciesMergeList(sml); sml = NULp;
2120  }
2121  }
2122  else { // copy species or create from consensus (copy fields from one species)
2123  e4_assert(where_we_are==ON_SPECIES);
2124 
2125  ED4_species_name_terminal *spec_name = cursor_terminal->to_sequence_terminal()->corresponding_species_name_terminal();
2126  const char *source_name = spec_name->resolve_pointer_to_char_pntr();
2127  GBDATA *gb_source = GBT_find_species_rel_species_data(gb_species_data, source_name);
2128 
2129  if (gb_source) {
2130  GBDATA *gb_new_species = GB_create_container(gb_species_data, "species");
2131  error = GB_copy_dropProtectMarksAndTempstate(gb_new_species, gb_source);
2132  if (!error) error = GBT_write_string(gb_new_species, "name", new_species_name);
2133  if (!error) error = GBT_write_string(gb_new_species, "full_name", new_species_full_name); // insert new 'full_name'
2134  if (!error && creation_mode==CREATE_FROM_CONSENSUS) {
2135  ED4_group_manager *group_man = cursor_terminal->get_parent(LEV_GROUP)->to_group_manager();
2136  error = createDataFromConsensus(gb_new_species, group_man);
2137  }
2138  }
2139  else {
2140  error = GBS_global_string("Can't find species '%s'", source_name);
2141  }
2142  }
2143  }
2144 
2145  error = GB_end_transaction(gb_main, error);
2146  if (!error) ED4_get_and_jump_to_species(new_species_name);
2147  }
2148  else {
2149  GB_abort_transaction(gb_main);
2150  }
2151 
2152  free(addid);
2153  free(acc);
2154  free(new_species_name);
2155  }
2156 
2157  aw_message_if(error);
2158  free(new_species_full_name);
2159 }
2160 
2162  e4_assert(valid(creation_mode));
2163 
2164  AW_window_simple *aws = new AW_window_simple;
2165  switch (creation_mode) {
2166  case CREATE_NEW_SPECIES: aws->init(root, "create_species", "Create species"); break;
2167  case CREATE_FROM_CONSENSUS: aws->init(root, "create_species_from_consensus", "Create species from consensus"); break;
2168  case COPY_SPECIES: aws->init(root, "copy_species", "Copy current species"); break;
2169  }
2170 
2171  if (creation_mode==CREATE_FROM_CONSENSUS) {
2172  aws->load_xfig("edit4/create_seq_fc.fig");
2173  }
2174  else {
2175  aws->load_xfig("edit4/create_seq.fig");
2176  }
2177 
2178  aws->callback(AW_POPDOWN);
2179  aws->at("close");
2180  aws->create_button("CLOSE", "CLOSE", "C");
2181 
2182  aws->at("label");
2183  aws->create_autosize_button(NULp, "Please enter the FULL_NAME\nof the new species");
2184 
2185  aws->at("input");
2186  aws->create_input_field(ED4_AWAR_SPECIES_TO_CREATE, 30);
2187 
2188  aws->at("ok");
2189  aws->callback(makeWindowCallback(create_new_species, creation_mode));
2190  aws->create_button("GO", "GO", "g");
2191 
2192  if (creation_mode==CREATE_FROM_CONSENSUS) {
2193  aws->at("replace_equal");
2194  aws->label("Replace '=' by ");
2195  aws->create_input_field(ED4_AWAR_CREATE_FROM_CONS_REPL_EQUAL, 1);
2196 
2197  aws->at("replace_point");
2198  aws->label("Replace '.' by ");
2199  aws->create_input_field(ED4_AWAR_CREATE_FROM_CONS_REPL_POINT, 1);
2200 
2201  aws->at("replace_start_end");
2202  aws->label("Create ... at ends of sequence?");
2203  aws->create_toggle(ED4_AWAR_CREATE_FROM_CONS_CREATE_POINTS);
2204 
2205  aws->at("upper");
2206  aws->label("Convert all chars to upper?");
2207  aws->create_toggle(ED4_AWAR_CREATE_FROM_CONS_ALL_UPPER);
2208 
2209  aws->at("data");
2210  aws->label("Other fields");
2211  aws->create_option_menu(ED4_AWAR_CREATE_FROM_CONS_DATA_SOURCE, true);
2212  aws->insert_default_option("Merge from all in group", "", 0);
2213  aws->insert_option("Copy from current species", "", 1);
2214  aws->update_option_menu();
2215  }
2216 
2217  return aws;
2218 }
2219 
GB_ERROR GB_begin_transaction(GBDATA *gbd)
Definition: arbdb.cxx:2516
static AWT_config_mapping_def editor_options_config_mapping[]
ED4_species_name_terminal * ED4_find_SAI_name_terminal(const char *sai_name)
Definition: ED4_root.cxx:894
GB_ERROR GB_copy_dropProtectMarksAndTempstate(GBDATA *dest, GBDATA *source)
Definition: arbdb.cxx:2144
#define ED4_AWAR_SCROLL_SPEED_Y
Definition: ed4_awars.hxx:32
const char * GB_ERROR
Definition: arb_core.h:25
void ED4_jump_to_cursor_position(AW_window *aww, const char *awar_name, PositionType posType)
int is_pure_text_terminal() const
Definition: ed4_class.hxx:1091
ED4_returncode generate_window(AW_device **device, ED4_window **new_window)
Definition: ED4_root.cxx:1318
AW_device * get_device() const
Definition: ed4_class.hxx:772
ED4_selected_list * selected_objects
Definition: ed4_class.hxx:1438
GB_TYPES type
bool is_species_seq_terminal() const
Definition: ed4_class.hxx:1857
AW_device * current_device()
Definition: ed4_class.hxx:1402
GB_ERROR GB_commit_transaction(GBDATA *gbd)
Definition: arbdb.cxx:2539
const char * resolve_pointer_to_char_pntr(int *str_len=NULp) const FINAL_OVERRIDE
AW_helix * helix
Definition: ed4_class.hxx:1451
ED4_EDITMODE
Definition: ed4_defs.hxx:30
int screen_to_sequence(int screen_pos) const
void resize_requested_by_child()
Definition: ed4_class.hxx:2199
void ED4_request_full_instant_refresh()
#define ED4_AWAR_ANNOUNCE_CHECKSUM_CHANGES
Definition: ed4_awars.hxx:36
ED4_returncode set_width()
Definition: ED4_base.cxx:719
ED4_returncode move_cursor(AW_event *event)
ED4_terminal * working_terminal
Definition: ed4_defs.hxx:318
virtual bool is_hidden() const =0
long char_position
Definition: ed4_defs.hxx:300
AW_font_group font_group
Definition: ed4_class.hxx:1472
AW_pos size[2]
Definition: ed4_defs.hxx:261
int rel_2_abs(int rel) const
Definition: BI_basepos.hxx:87
#define AWAR_EDIT_SECURITY_LEVEL
Definition: ed4_defs.hxx:93
#define ED4_AWAR_CONSENSUS_GROUP
Definition: ed4_awars.hxx:47
short get_height() const
const AW_screen_area & get_area_size() const
Definition: AW_device.cxx:57
ED4_EDITMODE mode
Definition: ed4_defs.hxx:304
#define ED4_AWAR_COMPRESS_SEQUENCE_GAPS
Definition: ed4_awars.hxx:23
static char * y[maxsp+1]
ED4_window * window() const
Definition: ed4_class.hxx:700
int is_text_terminal() const
Definition: ed4_class.hxx:1083
char * AWTC_generate_random_name(UniqueNameDetector &existingNames)
Definition: AW_rename.cxx:664
#define ED4_AWAR_CREATE_FROM_CONS_REPL_EQUAL
Definition: ed4_awars.hxx:55
ED4_area_manager * top_area_man
Definition: ed4_class.hxx:1435
GB_ERROR GB_append_exportedError(GB_ERROR error)
Definition: arb_msg.cxx:399
virtual char * resolve_pointer_to_string_copy(int *str_len=NULp) const
Definition: ED4_base.cxx:230
void load_xfig(const char *file, bool resize=true)
Definition: AW_window.cxx:717
GB_ERROR GB_tell_server_dont_wait(GBDATA *gbd)
Definition: adcomm.cxx:1867
int MAXNAME_WIDTH
Definition: ED4_main.cxx:56
SpeciesCreationMode
Definition: ed4_class.hxx:2247
void ED4_saveConfiguration(AW_window *aww, bool hide_aww)
GBDATA * get_species_pointer() const
Definition: ed4_class.hxx:953
const char * GBS_global_string_to_buffer(char *buffer, size_t bufsize, const char *templat,...)
Definition: arb_msg.cxx:177
void update_window_coords()
Definition: ED4_window.cxx:52
static const int MIDDLE_AREA
Definition: ad_config.h:46
void ED4_remote_set_cursor_cb(AW_root *awr)
void ED4_set_iupac(AW_window *aww, const char *awar_name)
#define ED4_AWAR_FAST_CURSOR_JUMP
Definition: ed4_awars.hxx:28
ED4_SearchResults & results() const
Definition: ed4_class.hxx:2010
char * out_string
Definition: ed4_defs.hxx:314
void resize_dynamic()
Definition: ed4_class.hxx:967
#define CONSENSUS_CONFIG_COUNTGAPS
int is_columnStat_terminal() const
Definition: ed4_class.hxx:1092
GB_ERROR GB_end_transaction(GBDATA *gbd, GB_ERROR error)
Definition: arbdb.cxx:2549
ED4_area_manager * middle_area_man
Definition: ed4_class.hxx:1434
bool is_enabled() const
Definition: AW_helix.hxx:34
void add(int v)
Definition: ClustalV.cxx:461
void ED4_reloadConfiguration(AW_window *aww)
void ED4_compression_toggle_changed_cb(AW_root *root, bool hideChanged)
bool refresh_needed
Definition: ed4_defs.hxx:310
#define ED4_AWAR_CONSENSUS_COUNTGAPS
Definition: ed4_awars.hxx:45
Definition: iupac.cxx:21
void ED4_set_helixnr(AW_window *aww, const char *awar_name)
GB_ERROR GB_write_pntr(GBDATA *gbd, const char *s, size_t bytes_size, size_t stored_size)
Definition: arbdb.cxx:1342
GB_ERROR AWTC_generate_one_name(GBDATA *gb_main, const char *full_name, const char *acc, const char *addid, char *&new_name)
Definition: AW_rename.cxx:317
#define ED4_AWAR_SCROLL_SPEED_X
Definition: ed4_awars.hxx:31
ED4_returncode deselect_all()
Definition: ED4_root.cxx:316
char * ARB_strdup(const char *str)
Definition: arb_string.h:27
void AWT_insert_config_manager(AW_window *aww, AW_default default_file_, const char *id, const StoreConfigCallback &store_cb, const RestoreConfigCallback &load_or_reset_cb, const char *macro_id, const AWT_predefined_config *predef)
char * GB_read_as_string(GBDATA *gbd)
Definition: arbdb.cxx:1054
void GB_end_transaction_show_error(GBDATA *gbd, GB_ERROR error, void(*error_handler)(GB_ERROR))
Definition: arbdb.cxx:2572
#define BRACKET_WIDTH
Definition: ed4_defs.hxx:78
long read_int() const
Definition: AW_awar.cxx:187
#define AWAR_EDIT_SECURITY_LEVEL_ALIGN
Definition: ed4_defs.hxx:94
#define AWAR_INSERT_MODE
Definition: ed4_defs.hxx:92
EDB_root_bact * database
Definition: ed4_class.hxx:1437
void win_to_world_coords(AW_pos *xPtr, AW_pos *yPtr) const
Definition: ed4_class.hxx:366
int slider_pos_horizontal
Definition: ed4_class.hxx:712
AW_awar * set_minmax(float min, float max)
Definition: AW_awar.cxx:532
#define ED4_AWAR_COMPRESS_SEQUENCE_TYPE
Definition: ed4_awars.hxx:22
int base2sequence_position(int base_pos) const
Definition: ed4_class.hxx:673
static const int TOP_AREA
Definition: ad_config.h:45
long first_position(const char *helixNr) const
Definition: BI_helix.cxx:373
const char * GBS_global_string(const char *templat,...)
Definition: arb_msg.cxx:204
static void calculate_group_folding(group_folding &folding)
static void touch_world_cache()
Definition: ed4_class.hxx:1013
ED4_root * ED4_ROOT
Definition: ED4_main.cxx:48
#define AWAR_EDIT_SECURITY_LEVEL_CHANGE
Definition: ed4_defs.hxx:95
int is_species_manager() const
Definition: ed4_class.hxx:1114
STL namespace.
GB_ERROR edit(ED4_work_info *info) __ATTR__USERESULT
void AW_POPDOWN(AW_window *window)
Definition: AW_window.cxx:52
static ARB_ERROR update_extension_size(ED4_base *base)
void ed4_change_edit_mode(AW_root *root)
void ED4_scrollbar_change_cb(AW_window *aww)
void update_scrolled_rectangle()
Definition: ED4_window.cxx:144
size_t get_max_screen_pos() const
Definition: ed4_class.hxx:1739
void ED4_quit_editor(AW_window *aww)
AW_DB_selection * awt_create_CONFIG_selection_list(GBDATA *gb_main, AW_window *aws, const char *varname, bool fallback2default)
void add_timed_callback(int ms, const TimedCallback &tcb)
Definition: AW_root.cxx:538
#define CONSENSUS_CONFIG_GROUP
#define SIGNIFICANT_FIELD_CHARS
#define TREE_TERMINAL_WIDTH
Definition: ed4_defs.hxx:82
#define ED4_AWAR_CONSENSUS_GAPBOUND
Definition: ed4_awars.hxx:46
#define SPACER_HEIGHT
Definition: ed4_defs.hxx:79
ED4_group_manager * ED4_build_group_manager_start(ED4_manager *group_parent, GB_CSTR group_name, int group_depth, bool is_folded, ED4_reference_terminals &refterms, ED4_multi_species_manager *&multi_species_manager)
Definition: ED4_base.cxx:233
ED4_terminal * owner_of_cursor
Definition: ed4_class.hxx:649
#define EXIT_SUCCESS
Definition: arb_a2ps.c:154
int slider_pos_horizontal
current position of the vertical slider
Definition: aw_window.hxx:339
void create_consensus(ED4_abstract_group_manager *upper_group_manager, arb_progress *progress)
Definition: ED4_base.cxx:569
AW_window * ED4_create_consensus_definition_window(AW_root *root)
static void group_species_by_field_content(AW_window *, AW_window *use_as_main_window, AW_window *window_to_hide)
int get_width(int gc) const
ED4_manager * parent
Definition: ed4_class.hxx:921
static SpeciesFlags & mutable_instance()
Definition: ed4_flags.hxx:95
ED4_reference_terminals ref_terminals
Definition: ed4_class.hxx:1441
char * protstruct
Definition: ed4_class.hxx:1455
#define ED4_AWAR_CONSENSUS_SHOW
Definition: ed4_awars.hxx:51
static void create_new_species(AW_window *, SpeciesCreationMode creation_mode)
GB_ERROR GB_push_transaction(GBDATA *gbd)
Definition: arbdb.cxx:2482
void activate()
Definition: aw_window.hxx:354
FILE * seq
Definition: rns.c:46
ED4_coords coords
Definition: ed4_class.hxx:716
int get_screen_pos() const
Definition: ed4_class.hxx:668
int get_header_length() const
Definition: ed4_flags.hxx:107
char character
Definition: aw_window.hxx:91
long ED4_counter
Definition: ED4_main.cxx:60
#define e4_assert(bed)
Definition: ed4_class.hxx:11
#define NO_FIELD_SELECTED
const int WIDTH
char * AWTC_makeUniqueShortName(const char *prefix, UniqueNameDetector &existingNames)
Definition: AW_rename.cxx:633
int sequence2base_position(int seq_pos) const
Definition: ed4_class.hxx:674
int is_multi_species_manager() const
Definition: ed4_class.hxx:1106
GB_ERROR GB_incur_error_if(bool error_may_occur)
Definition: arb_msg.h:56
AW_awar * add_callback(const RootCallback &cb)
Definition: AW_awar.cxx:234
void create_itemfield_selection_button(AW_window *aws, const FieldSelDef &selDef, const char *at)
bool cannot_handle
Definition: ed4_defs.hxx:307
bool has_property(ED4_properties prop) const
Definition: ed4_class.hxx:982
static void createGroupFromSelected(GB_CSTR group_name, GB_CSTR field_name, GB_CSTR field_content)
const char * AW_get_nameserver_addid(GBDATA *gb_main)
Definition: AW_rename.cxx:39
const AW_font_limits & get_font_limits(int gc, char c) const
Definition: AW_device.cxx:399
#define CONSENSUS_CONFIG_GAPBOUND
void GB_change_my_security(GBDATA *gbd, int level)
Definition: arbdb.cxx:1625
bool is_consensus_manager() const
Definition: ed4_class.hxx:1842
ED4_scroll_picture scroll_picture
Definition: ed4_class.hxx:1443
#define ED4_AWAR_CREATE_FROM_CONS_ALL_UPPER
Definition: ed4_awars.hxx:58
char * build_consensus_string(PosRange range) const
Definition: ed4_class.hxx:1660
#define CONSENSUS_CONFIG_ID
uchar flags
Definition: probe_tree.h:38
AW_window * ED4_create_loadSAI_window(AW_root *awr)
GB_ERROR GB_await_error()
Definition: arb_msg.cxx:353
long helix_add_spacing
Definition: ed4_class.hxx:1453
static AW_root * SINGLETON
Definition: aw_root.hxx:102
void show()
Definition: AW_window.cxx:1658
void recalc_font_group()
Definition: ED4_root.cxx:529
double AW_pos
Definition: aw_base.hxx:29
GBDATA * GB_create_container(GBDATA *father, const char *key)
Definition: arbdb.cxx:1827
static int timer_calls
const AW_font_limits & get_limits(int gc) const
WindowCallback makeHelpCallback(const char *helpfile)
Definition: aw_window.hxx:106
void prepare_shutdown()
Definition: ed4_class.hxx:678
static unsigned ED4_timer(AW_root *)
#define ED4_AWAR_CREATE_FROM_CONS_DATA_SOURCE
Definition: ed4_awars.hxx:59
int abs_2_rel(int abs) const
Definition: BI_basepos.hxx:76
void append_member(ED4_base *new_member)
Definition: arbdb.h:78
fflush(stdout)
GB_TYPES GB_read_type(GBDATA *gbd)
Definition: arbdb.cxx:1641
int SEQ_TERM_TEXT_YOFFSET
Definition: ED4_main.cxx:53
void ED4_build_group_manager_end(ED4_multi_species_manager *multi_species_manager)
Definition: ED4_base.cxx:316
GB_ERROR deliver() const
Definition: arb_error.h:114
int helix_spacing
Definition: ed4_class.hxx:1452
char * string
Definition: ed4_defs.hxx:299
ED4_window * next
Definition: ed4_class.hxx:711
#define ED4_AWAR_SPECIES_TO_CREATE
Definition: ed4_awars.hxx:206
void ED4_request_relayout()
T * elem() const
Definition: ed4_list.hxx:25
void save_current_config(char *confname)
#define CONSENSUS_CONFIG_CONSIDBOUND
long window_upper_clip_point
Definition: ed4_defs.hxx:349
AW_window * AWT_create_IUPAC_info_window(AW_root *aw_root)
Definition: AWT_misc.cxx:21
void get_event(AW_event *eventi) const
Definition: AW_window.cxx:540
bool is_sequence
Definition: ed4_defs.hxx:306
void ED4_new_editor_window(AW_window *aww)
long window_lower_clip_point
Definition: ed4_defs.hxx:349
GBDATA * get_gb_main() const
Definition: ed4_class.hxx:1426
GBDATA * gb_species_data
Definition: adname.cxx:34
#define ED4_AWAR_NDS_INFO_WIDTH
Definition: ed4_awars.hxx:73
#define ED4_AWAR_CONSENSUS_LOWER
Definition: ed4_awars.hxx:50
LoadableSaiState loadable_SAIs
Definition: ed4_class.hxx:1468
void ED4_calc_terminal_extentions()
virtual void request_refresh(int clear=1)=0
char * alignment_name
Definition: ed4_class.hxx:1445
ED4_returncode rebuild_consensi(ED4_base *start_species, ED4_update_flag update_flag)
static AW_window * create_group_species_by_field_window(AW_root *aw_root, AW_window *use_as_main_window)
static int get_max_slider_xpos()
#define AWAR_FIELD_CHOSEN
Definition: ed4_defs.hxx:104
#define AWAR_EDIT_HELIX_SPACING
Definition: ed4_defs.hxx:107
#define NOWHERE
Definition: align.cxx:31
void ED4_motion_cb(AW_window *aww)
bool in_consensus_terminal() const
Definition: ed4_class.hxx:1860
char * GB_get_subfields(GBDATA *gbd)
Definition: arbdb.cxx:2217
#define ED4_AWAR_CONSENSUS_CONSIDBOUND
Definition: ed4_awars.hxx:48
ED4_window * first_window
Definition: ed4_class.hxx:1432
AW_event event
Definition: ed4_defs.hxx:297
int size() const
Definition: ed4_list.hxx:47
long out_seq_position
Definition: ed4_defs.hxx:312
static void error(const char *msg)
Definition: mkptypes.cxx:96
GB_ERROR GB_abort_transaction(GBDATA *gbd)
Definition: arbdb.cxx:2527
#define CONSENSUS_CONFIG_UPPER
ED4_cursor cursor
Definition: ed4_class.hxx:727
int get_max_width() const
void reset_all_for_new_config()
Definition: ED4_window.cxx:20
AW_window * current_aww()
Definition: ed4_class.hxx:1404
static ARB_ERROR add_species_to_merge_list(ED4_base *base, SpeciesMergeList **smlp, GBDATA *gb_species_data)
int FLAG_WIDTH
Definition: ED4_main.cxx:58
#define ED4_AWAR_DIGITS_AS_REPEAT
Definition: ed4_awars.hxx:27
void ED4_remote_event(AW_event *faked_event)
SpeciesMergeList * next
PositionType
Definition: ed4_class.hxx:108
#define ED4_AWAR_COMPRESS_SEQUENCE_PERCENT
Definition: ed4_awars.hxx:25
ED4_root_group_manager * root_group_man
Definition: ed4_class.hxx:1436
int shown_sequence_to_screen(int sequence_pos) const
Definition: ed4_class.hxx:1719
#define ED4_AWAR_CONSENSUS_UPPER
Definition: ed4_awars.hxx:49
void set_screen_relative_pos(int scroll_to_relpos)
Definition: ED4_cursor.cxx:913
static void consensus_upper_lower_changed_cb(AW_root *awr, bool upper_changed)
#define CHARACTEROFFSET
Definition: ed4_defs.hxx:110
ARB_ERROR route_down_hierarchy(const ED4_route_cb &cb) FINAL_OVERRIDE
Definition: ED4_base.cxx:392
void ED4_consensus_definition_changed(AW_root *)
#define AWAR_SET_CURSOR_POSITION
ED4_main_manager * main_manager
Definition: ed4_class.hxx:1433
#define AWAR_SAI_NAME
void group_species_cb(AW_window *aww, bool use_fields)
void calc_world_coords(AW_pos *x, AW_pos *y) const
Definition: ed4_class.hxx:988
GBDATA * GBT_find_species_rel_species_data(GBDATA *gb_species_data, const char *name)
Definition: aditem.cxx:133
char * read_string() const
Definition: AW_awar.cxx:201
static int timer_calls_triggered
void set_mode(ED4_remap_mode Mode, int above_percent)
Definition: ed4_class.hxx:1744
CONSTEXPR_INLINE bool valid(SpeciesCreationMode m)
Definition: ed4_class.hxx:2254
AW_awar * awar(const char *awar)
Definition: AW_root.cxx:554
void ED4_consensus_display_changed(AW_root *root)
void delete_window(ED4_window *window)
Definition: ED4_window.cxx:349
int ED4_get_NDS_width()
Definition: ED4_nds.cxx:38
AW_key_code keycode
Definition: aw_window.hxx:90
AW_key_mod keymodifier
Definition: aw_window.hxx:83
Definition: arbdb.h:86
ED4_scroll_links scroll_links
Definition: ed4_class.hxx:1439
ED4_list_elem * next() const
Definition: ed4_list.hxx:24
GB_alignment_type alignment_type
Definition: ed4_class.hxx:1446
bool nameIsUnique(const char *short_name, GBDATA *gb_species_data)
ED4_extension extension
Definition: ed4_class.hxx:929
void ED4_compression_changed_cb(AW_root *awr)
void unlink_awars_from_DB(GBDATA *gb_main)
Definition: AW_root.cxx:635
int calc_group_depth()
Definition: ED4_base.cxx:424
static int SpeciesMergeListLength(SpeciesMergeList *sml)
int TERMINAL_HEIGHT
Definition: ED4_main.cxx:50
static void ED4_start_editor_on_configuration(AW_window *aww)
static ARB_ERROR update_group_folding(ED4_base *base, group_folding *folding)
ED4_multi_species_manager * get_multi_species_manager() const
Definition: ed4_class.hxx:1594
ED4_sequence_info_terminal * sequence_info()
Definition: ed4_class.hxx:1364
bool is_consensus_terminal() const
Definition: ed4_class.hxx:1855
void ED4_trigger_instant_refresh()
ASSERTING_CONSTEXPR_INLINE int bio2info(int biopos)
Definition: arb_defs.h:26
GB_ERROR GB_export_errorf(const char *templat,...)
Definition: arb_msg.cxx:264
AW_event_type type
Definition: aw_window.hxx:81
void resize_all_requesting_childs()
Definition: ED4_root.cxx:454
AW_window * ED4_create_saveConfigurationAs_window(AW_root *awr)
ED4_cursor & current_cursor()
Definition: ed4_class.hxx:1405
AW_awar * awar_int(const char *var_name, long default_value=0, AW_default default_file=AW_ROOT_DEFAULT)
Definition: AW_root.cxx:580
#define AWAR_EDIT_MODE
Definition: ed4_defs.hxx:91
#define ED4_AWAR_CREATE_FROM_CONS_CREATE_POINTS
Definition: ed4_awars.hxx:57
void auto_space(int xspace, int yspace)
Definition: AW_at.cxx:259
#define ED4_AWAR_CREATE_FROM_CONS_REPL_POINT
Definition: ed4_awars.hxx:56
bool has_entries() const
Definition: BI_helix.hxx:89
static GB_ERROR ED4_load_new_config(char *name)
int MAXSEQUENCECHARACTERLENGTH
Definition: ED4_main.cxx:55
void remove_all_callbacks()
void ED4_init_notFoundMessage()
Definition: ED4_cursor.cxx:566
#define GB_GROUP_NAME_MAX
Definition: arbdbt.h:16
static void freeSpeciesMergeList(SpeciesMergeList *sml)
long terminal_add_spacing
Definition: ed4_class.hxx:1454
void ED4_create_consensus_awars(AW_root *aw_root)
void ED4_vertical_change_cb(AW_window *aww)
GB_ERROR GBT_write_string(GBDATA *gb_container, const char *fieldpath, const char *content)
Definition: adtools.cxx:451
GBDATA * gb_data
Definition: ed4_defs.hxx:298
#define ED4_AWAR_SCROLL_MARGIN
Definition: ed4_awars.hxx:33
AW_MouseButton button
Definition: aw_window.hxx:86
#define ED4_AWAR_COMPRESS_SEQUENCE_HIDE
Definition: ed4_awars.hxx:24
ED4_CursorJumpType cursor_jump
Definition: ed4_defs.hxx:309
long awar_edit_rightward
Definition: ED4_main.cxx:67
AW_awar * map(const char *awarn)
Definition: AW_awar.cxx:523
static ED4_EDITMODE ED4_get_edit_mode(AW_root *root)
void jump_sequence_pos(int sequence_pos, ED4_CursorJumpType jump_type)
char * GB_read_string(GBDATA *gbd)
Definition: arbdb.cxx:903
GB_ERROR write_sequence(const char *seq, int seq_len)
static void ed4_scroll(AW_window *aww, int xdiff, int ydiff)
void calculate_header_dimensions(AW_device *device, int gc)
Definition: ED4_flags.cxx:153
BI_ecoli_ref * ecoli_ref
Definition: ed4_class.hxx:1444
ED4_window * current_ed4w()
Definition: ed4_class.hxx:1403
bool move_cursor
Definition: ED4_main.cxx:68
AW_window * ED4_create_editor_options_window(AW_root *root)
AW_root * aw_root
Definition: ed4_class.hxx:1429
void set_horizontal_scrollbar_position(int position)
Definition: AW_window.cxx:995
void ED4_horizontal_change_cb(AW_window *aww)
ItemSelector & SPECIES_get_selector()
Definition: species.cxx:139
int slider_pos_vertical
Definition: ed4_class.hxx:713
void ED4_get_and_jump_to_species(GB_CSTR species_name)
Definition: ED4_cursor.cxx:653
ED4_list_elem< T > * head() const
Definition: ed4_list.hxx:45
ED4_sequence_terminal * sequence()
Definition: ed4_class.hxx:1363
#define AWAR_EDIT_TERMINAL_SPACING
Definition: ed4_defs.hxx:108
unsigned int hidden
Definition: ed4_class.hxx:932
static void executeKeystroke(AW_event *event, int repeatCount)
void update_requested_by_child()
long window_right_clip_point
Definition: ed4_defs.hxx:349
bool ED4_is_gap_character(char chr)
ED4_returncode set_scrolled_rectangle(ED4_base *x_link, ED4_base *y_link, ED4_base *width_link, ED4_base *height_link)
Definition: ED4_window.cxx:183
void request_refresh(int clear=1) FINAL_OVERRIDE
void aw_message(const char *msg)
Definition: AW_status.cxx:932
ED4_returncode scroll_rectangle(int dx, int dy)
Definition: ED4_window.cxx:291
void hide()
Definition: AW_window.cxx:1807
void ED4_exit()
char encode(const char bases[], GB_alignment_type aliType)
Definition: iupac.cxx:192
AW_root * get_root()
Definition: aw_window.hxx:348
#define SPACER_NOCONS_HEIGHT
Definition: ed4_defs.hxx:80
void ED4_resize_all_extensions()
ED4_returncode refresh_all_windows(bool redraw)
Definition: ED4_root.cxx:168
long max_seq_terminal_length
Definition: ED4_main.cxx:65
AW_window_simple * win
GBDATA * GBT_find_or_create_species(GBDATA *gb_main, const char *name, bool markCreated)
Definition: aditem.cxx:61
void shutdown_macro_recording(AW_root *aw_root)
Definition: trackers.cxx:470
#define NULp
Definition: cxxforward.h:97
static ARB_ERROR call_edit(ED4_base *object, ED4_work_info *work_info)
const ED4_remap * remap() const
Definition: ed4_class.hxx:1788
static void group_species(bool use_field, AW_window *use_as_main_window)
void ED4_request_full_refresh()
#define ED4_AWAR_GAP_CHARS
Definition: ed4_awars.hxx:35
int is_sequence_terminal() const
Definition: ed4_class.hxx:1088
char * GBT_get_default_alignment(GBDATA *gb_main)
Definition: adali.cxx:675
const char * GBT_get_name(GBDATA *gb_item)
Definition: aditem.cxx:450
bool gotData() const
Definition: BI_basepos.hxx:74
bool is_hidden
Definition: ed4_class.hxx:726
void set_vertical_scrollbar_position(int position)
Definition: AW_window.cxx:986
AW_DB_selection * awt_create_SAI_selection_list(GBDATA *gb_main, AW_window *aws, const char *varname, bool fallback2default, const SaiSelectionlistFilterCallback &fcb)
char * resolve_pointer_to_string_copy(int *str_len=NULp) const FINAL_OVERRIDE
GB_TYPES
Definition: arbdb.h:62
AW_ProcessEventType peek_key_event(AW_window *)
Definition: AW_root.cxx:54
int get_sequence_pos() const
Definition: ED4_cursor.cxx:393
AW_window_menu_modes * aww
Definition: ed4_class.hxx:710
GB_transaction ta(gb_var)
ED4_returncode create_hierarchy(const char *area_string_middle, const char *area_string_top)
Definition: ED4_root.cxx:550
int INFO_TERM_TEXT_YOFFSET
Definition: ED4_main.cxx:52
GBDATA * gb_main
Definition: adname.cxx:33
RefPtr< ED4_cursor > cursor
long window_left_clip_point
Definition: ed4_defs.hxx:349
cursorpos(ED4_window *win)
ED4_Edit_String * edit_string
Definition: ed4_class.hxx:1458
GBDATA * GB_search(GBDATA *gbd, const char *fieldpath, GB_TYPES create)
Definition: adquery.cxx:531
AW_window * ED4_create_new_seq_window(AW_root *root, SpeciesCreationMode creation_mode)
char * aw_input(const char *title, const char *prompt, const char *default_input)
Definition: AW_modal.cxx:251
size_t length
int get_pixel_width() const
Definition: ed4_flags.hxx:113
int get_max_height() const
int MAXINFO_WIDTH
Definition: ED4_main.cxx:57
ED4_manager * get_parent(ED4_level lev) const
Definition: ed4_class.hxx:1828
int slider_pos_vertical
window id
Definition: aw_window.hxx:338
ED4_EDITMODE awar_edit_mode
Definition: ED4_main.cxx:66
struct ED4_base::@7 flag
ARB_ERROR rebuild_consensus(ED4_base *object)
void ED4_input_cb(AW_window *aww)
#define HEIGHT
Definition: ed4_defs.hxx:75
ED4_remap_mode
Definition: ed4_class.hxx:1678
#define CONSENSUS_CONFIG_LOWER
static char * filter_loadable_SAIs(GBDATA *gb_sai)
#define AWAR_EDIT_CONFIGURATION
Definition: ed4_defs.hxx:96
int is_group_manager() const
Definition: ed4_class.hxx:1110
ED4_properties dynamic_prop
Definition: ed4_class.hxx:924
#define AW_ROOT_DEFAULT
Definition: aw_base.hxx:106
AW_window * ED4_create_loadConfiguration_window(AW_root *awr)
GB_ERROR write_int(long aw_int)
void ED4_get_and_jump_to_selected_SAI(AW_window *aww)
Definition: ED4_cursor.cxx:630
void ed4_changesecurity(AW_root *root)
void inc_and_check_user_abort(GB_ERROR &error)
Definition: arb_progress.h:274
int is_species_name_terminal() const
Definition: ed4_class.hxx:1085
void aw_message_if(GB_ERROR error)
Definition: aw_msg.hxx:21
CONSTEXPR long FIELD_FILTER_STRING_READABLE
Definition: item_sel_list.h:47
void GB_close(GBDATA *gbd)
Definition: arbdb.cxx:649
static GB_ERROR createDataFromConsensus(GBDATA *gb_species, ED4_group_manager *group_man)
static int folding
Definition: arb_a2ps.c:263
static int get_max_slider_ypos()
AW_ProcessEventType
Definition: aw_root.hxx:49
static AWT_config_mapping_def consensus_config_mapping[]
GBDATA * GBT_get_species_data(GBDATA *gb_main)
Definition: aditem.cxx:105
#define max(a, b)
Definition: f2c.h:154