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, const 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 
288  {
289  ED4_Edit_String editString;
290  error = editString.edit(&new_work_info);
291  }
292 
293  e4_assert(error || !new_work_info.out_string);
294 
295  if (new_work_info.refresh_needed) {
296  object->request_refresh();
297  if (object->is_sequence_terminal()) {
298  ED4_sequence_terminal *seq_term = object->to_sequence_terminal();
299  seq_term->results().searchAgain();
300  }
301  }
302 
303  if (move_cursor) {
305  move_cursor = 0;
306  }
307  }
308  }
309  return error;
310 }
311 
312 static int get_max_slider_xpos() {
313  const AW_screen_area& rect = current_device()->get_area_size();
314 
315  AW_pos x, y;
317  horizontal_link->calc_world_coords(&x, &y);
318 
319  AW_pos max_xpos = horizontal_link->extension.size[WIDTH] // overall width of virtual scrolling area
320  - (rect.r - x); // minus width of visible scroll-area (== relative width of horizontal scrollbar)
321 
322  if (max_xpos<0) max_xpos = 0; // happens when window-content is smaller than window (e.g. if (folded) alignment is narrow)
323  return int(max_xpos+0.5);
324 }
325 
326 static int get_max_slider_ypos() {
327  const AW_screen_area& rect = current_device()->get_area_size();
328 
329  AW_pos x, y;
331  vertical_link->calc_world_coords(&x, &y);
332 
333  AW_pos max_ypos = vertical_link->extension.size[HEIGHT] // overall height of virtual scrolling area
334  - (rect.b - y); // minus height of visible scroll-area (== relative height of vertical scrollbar)
335 
336  if (max_ypos<0) max_ypos = 0; // happens when window-content is smaller than window (e.g. if ARB_EDIT4 is not filled)
337  return int(max_ypos+0.5);
338 }
339 
340 static void ed4_scroll(AW_window *aww, int xdiff, int ydiff, bool use_scroll_speed) {
341  if (use_scroll_speed) {
342  xdiff = xdiff * ED4_ROOT->aw_root->awar(ED4_AWAR_SCROLL_SPEED_X)->read_int() / 10;
343  ydiff = ydiff * ED4_ROOT->aw_root->awar(ED4_AWAR_SCROLL_SPEED_Y)->read_int() / 10;
344  }
345 
346  int new_xpos = aww->slider_pos_horizontal + xdiff;
347  int new_ypos = aww->slider_pos_vertical + ydiff;
348 
349  if (xdiff<0) { // scroll left
350  if (new_xpos<0) new_xpos = 0;
351  }
352  else if (xdiff>0) { // scroll right
353  int max_xpos = get_max_slider_xpos();
354  if (max_xpos<0) max_xpos = 0;
355  if (new_xpos>max_xpos) new_xpos = max_xpos;
356  }
357 
358  if (ydiff<0) { // scroll up
359  if (new_ypos<0) new_ypos = 0;
360  }
361  else if (ydiff>0) { // scroll down
362  int max_ypos = get_max_slider_ypos();
363  if (max_ypos<0) max_ypos = 0;
364  if (new_ypos>max_ypos) new_ypos = max_ypos;
365  }
366 
367  if (new_xpos!=aww->slider_pos_horizontal) {
368  aww->set_horizontal_scrollbar_position(new_xpos);
370  }
371 
372  if (new_ypos!=aww->slider_pos_vertical) {
373  aww->set_vertical_scrollbar_position(new_ypos);
375  }
376 }
377 
378 static void scrollHalfPage(bool backwards, bool horizontal) {
379  ED4_window *e4w = current_ed4w();
380  AW::Rectangle scrolledArea = e4w->scrolled_rect.get_window_rect();
381 
382  double fdist = horizontal ? scrolledArea.width() : scrolledArea.height();
383  int dist = int(fdist/2 + 0.5);
384 
385  if (backwards) dist = -dist;
386 
387  ed4_scroll(e4w->aww, horizontal ? dist : 0, horizontal ? 0 : dist, false);
388 }
389 
390 static void executeKeystroke(AW_event *event, int repeatCount) {
391  e4_assert(repeatCount>0);
392 
393  if (event->keycode == AW_KEY_PGUP || event->keycode == AW_KEY_PGDN) {
395  }
396  else if (event->keycode!=AW_KEY_NONE) {
397  ED4_cursor *cursor = &current_cursor();
398  if (cursor->owner_of_cursor && !cursor->owner_of_cursor->flag.hidden) {
400  if (event->keycode == AW_KEY_UP || event->keycode == AW_KEY_DOWN ||
401  ((event->keymodifier & AW_KEYMODE_CONTROL) &&
402  (event->keycode == AW_KEY_HOME || event->keycode == AW_KEY_END)))
403  {
404  GB_transaction ta(gb_main);
405  while (repeatCount--) {
406  cursor->move_cursor(event);
407  }
408  }
409  else {
410  // @@@ move into separate function?
411 
412  ED4_work_info work_info;
413 
414  work_info.cannot_handle = false;
415  work_info.event = *event;
416  work_info.char_position = cursor->get_screen_pos();
417  work_info.out_seq_position = cursor->get_sequence_pos();
418  work_info.refresh_needed = false;
420  work_info.out_string = NULp; // nur falls new malloc
421  work_info.repeat_count = repeatCount;
422 
423  ED4_terminal *terminal = cursor->owner_of_cursor;
424  e4_assert(terminal->is_text_terminal());
425 
426  work_info.working_terminal = terminal;
427 
428  if (terminal->is_sequence_terminal()) {
429  work_info.mode = awar_edit_mode;
430  work_info.rightward = awar_edit_rightward;
431  work_info.is_sequence = 1;
432  }
433  else {
434  work_info.rightward = true;
435  work_info.is_sequence = 0;
436 
437  if (terminal->is_pure_text_terminal()) {
438  work_info.mode = awar_edit_mode;
439  }
440  else if (terminal->is_columnStat_terminal()) {
441  work_info.mode = AD_NOWRITE;
442  }
443  else {
444  e4_assert(0);
445  }
446  }
447 
448  work_info.string = NULp;
449  work_info.gb_data = NULp;
450 
451  if (terminal->get_species_pointer()) {
452  work_info.gb_data = terminal->get_species_pointer();
453  }
454  else if (terminal->is_columnStat_terminal()) {
455  work_info.gb_data = terminal->to_columnStat_terminal()->corresponding_sequence_terminal()->get_species_pointer();
456  }
457  else {
458  e4_assert(terminal->is_consensus_terminal());
459  ED4_consensus_sequence_terminal *cterm = terminal->to_consensus_sequence_terminal();
460  work_info.string = cterm->temp_cons_seq;
461  }
462 
463  ED4_Edit_String editString;
464  ARB_ERROR error = NULp;
465 
466  GB_push_transaction(gb_main);
467 
468  if (terminal->is_consensus_terminal()) {
469  ED4_consensus_sequence_terminal *cterm = terminal->to_consensus_sequence_terminal();
470  ED4_group_manager *group_manager = terminal->get_parent(LEV_GROUP)->to_group_manager();
471 
472  e4_assert(!cterm->temp_cons_seq);
473  work_info.string = cterm->temp_cons_seq = group_manager->build_consensus_string();
474 
475  error = editString.edit(&work_info);
476 
478 
479  work_info.string = NULp;
480 
481  if (work_info.cannot_handle) {
482  e4_assert(!error); // see ED4_Edit_String::edit()
483  move_cursor = 1;
484  error = group_manager->route_down_hierarchy(makeED4_route_cb(call_edit, &work_info));
485  group_manager->rebuild_consensi(group_manager, ED4_U_UP_DOWN);
486  }
487 
488  freenull(cterm->temp_cons_seq);
489  }
490  else {
491  error = editString.edit(&work_info);
492  cursor->jump_sequence_pos(work_info.out_seq_position, work_info.cursor_jump);
493  }
494 
495  editString.finish_edit();
496 
497  if (error) work_info.refresh_needed = true;
498 
499  GB_end_transaction_show_error(gb_main, error, aw_message);
500 
501  if (work_info.refresh_needed) {
502  GB_transaction ta(gb_main);
503 
504  terminal->request_refresh();
505  if (terminal->is_sequence_terminal()) {
506  ED4_sequence_terminal *seq_term = terminal->to_sequence_terminal();
507  seq_term->results().searchAgain();
508  }
509  }
510  }
511  }
512  }
513 }
514 
515 void ED4_remote_event(AW_event *faked_event) { // keystrokes forwarded from SECEDIT
516  ED4_MostRecentWinContext context;
517  executeKeystroke(faked_event, 1);
518 }
519 
521  AW_event event;
522  static AW_event lastEvent;
523  static int repeatCount;
524 
525  ED4_LocalWinContext uses(aww);
526 
527  aww->get_event(&event);
528 
529 
530 #if defined(DEBUG) && 0
531  printf("event.type=%i event.keycode=%i event.character='%c' event.keymodifier=%i\n", event.type, event.keycode, event.character, event.keymodifier);
532 #endif
533 
534  switch (event.type) {
535  case AW_Keyboard_Press: {
536  if (repeatCount==0) { // first key event?
537  lastEvent = event;
538  repeatCount = 1;
539  }
540  else {
541  if (lastEvent.keycode==event.keycode &&
542  lastEvent.character==event.character &&
543  lastEvent.keymodifier==event.keymodifier) { // same key as last?
544  repeatCount++;
545  }
546  else { // other key => execute now
547  executeKeystroke(&lastEvent, repeatCount);
548  lastEvent = event;
549  repeatCount = 1;
550  }
551  }
552 
553  if (repeatCount) {
554 #if defined(DARWIN) || 1
555  // sth goes wrong with OSX -> always execute keystroke
556  // Xfree 4.3 has problems as well, so repeat counting is disabled completely
557  executeKeystroke(&lastEvent, repeatCount);
558  repeatCount = 0;
559 #else
560  AW_ProcessEventType nextEventType = ED4_ROOT->aw_root->peek_key_event(aww);
561 
562  if (nextEventType!=KEY_RELEASED) { // no key waiting => execute now
563  executeKeystroke(&lastEvent, repeatCount);
564  repeatCount = 0;
565  }
566 #endif
567  }
568  break;
569  }
570  case AW_Keyboard_Release: {
571  AW_ProcessEventType nextEventType = ED4_ROOT->aw_root->peek_key_event(aww);
572 
573  if (nextEventType!=KEY_PRESSED && repeatCount) { // no key follows => execute keystrokes (if any)
574  executeKeystroke(&lastEvent, repeatCount);
575  repeatCount = 0;
576  }
577 
578  break;
579  }
580  default: {
581  if (event.button == AW_WHEEL_UP || event.button == AW_WHEEL_DOWN) {
582  if (event.type == AW_Mouse_Press) {
583  bool horizontal = event.keymodifier & AW_KEYMODE_ALT;
584  int direction = event.button == AW_WHEEL_UP ? -1 : 1;
585 
586  int dx = horizontal ? direction*ED4_ROOT->font_group.get_max_width() : 0;
587  int dy = horizontal ? 0 : direction*ED4_ROOT->font_group.get_max_height();
588 
589  ed4_scroll(aww, dx, dy, true);
590  }
591  return;
592  }
593 
594  if (event.button == AW_BUTTON_MIDDLE) {
595  if (event.type == AW_Mouse_Press) {
597  ED4_ROOT->scroll_picture.old_y = event.y;
598  ED4_ROOT->scroll_picture.old_x = event.x;
599  return;
600  }
601  if (event.type == AW_Mouse_Release) {
603  return;
604  }
605  }
606 
607 #if defined(DEBUG) && 0
608  if (event.button==AW_BUTTON_LEFT) {
609  printf("[ED4_input_cb] type=%i x=%i y=%i ", (int)event.type, (int)event.x, (int)event.y);
610  }
611 #endif
612 
613  AW_pos win_x = event.x;
614  AW_pos win_y = event.y;
615  current_ed4w()->win_to_world_coords(&(win_x), &(win_y));
616  event.x = (int) win_x;
617  event.y = (int) win_y;
618 
619 #if defined(DEBUG) && 0
620  if (event.button==AW_BUTTON_LEFT) {
621  printf("-> x=%i y=%i\n", (int)event.type, (int)event.x, (int)event.y);
622  }
623 #endif
624 
626  ED4_ROOT->main_manager->event_sent_by_parent(&event, aww);
627  break;
628  }
629  }
630 
632 }
633 
635  ED4_LocalWinContext uses(aww);
636 
638  {
640 
641  int old_slider_pos = win->slider_pos_vertical;
642 
643  { // correct slider_pos if necessary
644  int max_slider_ypos = get_max_slider_ypos();
645 
646  if (aww->slider_pos_vertical>max_slider_ypos) aww->set_vertical_scrollbar_position(max_slider_ypos);
648  }
649 
650  int slider_diff = aww->slider_pos_vertical - old_slider_pos;
651 
652  win->coords.window_upper_clip_point += slider_diff;
653  win->coords.window_lower_clip_point += slider_diff;
654 
655  win->scroll_rectangle(0, -slider_diff);
657  }
658  win->update_window_coords();
659 }
660 
662  ED4_LocalWinContext uses(aww);
663 
665  {
667 
668  int old_slider_pos = win->slider_pos_horizontal;
669 
670  { // correct slider_pos if necessary
671  int max_slider_xpos = get_max_slider_xpos();
672 
673  if (aww->slider_pos_horizontal>max_slider_xpos) aww->set_horizontal_scrollbar_position(max_slider_xpos);
675  }
676 
677  int slider_diff = aww->slider_pos_horizontal - old_slider_pos;
678 
679  win->coords.window_left_clip_point += slider_diff;
680  win->coords.window_right_clip_point += slider_diff;
681 
682  win->scroll_rectangle(-slider_diff, 0);
684  }
685  win->update_window_coords();
686 }
687 
689  ED4_LocalWinContext uses(aww);
690 
692  {
694 
695 
696  int old_hslider_pos = win->slider_pos_horizontal;
697  int old_vslider_pos = win->slider_pos_vertical;
698 
699  {
700  // correct slider_pos if necessary
701  int max_slider_xpos = get_max_slider_xpos();
702  int max_slider_ypos = get_max_slider_ypos();
703 
704  if (aww->slider_pos_horizontal>max_slider_xpos) aww->set_horizontal_scrollbar_position(max_slider_xpos);
706 
707  if (aww->slider_pos_vertical>max_slider_ypos) aww->set_vertical_scrollbar_position(max_slider_ypos);
709  }
710 
711  int slider_hdiff = aww->slider_pos_horizontal - old_hslider_pos;
712  int slider_vdiff = aww->slider_pos_vertical - old_vslider_pos;
713 
714  ED4_coords *coords = &win->coords;
715  coords->window_left_clip_point += slider_hdiff;
716  coords->window_right_clip_point += slider_hdiff;
717  coords->window_upper_clip_point += slider_vdiff;
718  coords->window_lower_clip_point += slider_vdiff;
719 
720  win->scroll_rectangle(-slider_hdiff, -slider_vdiff);
721 
724  }
725  win->update_window_coords();
726 }
727 
729  AW_event event;
730 
731  ED4_LocalWinContext uses(aww);
732 
733  aww->get_event(&event);
734 
735  if (event.type == AW_Mouse_Drag && event.button == AW_BUTTON_MIDDLE) {
737  int xdiff = ED4_ROOT->scroll_picture.old_x - event.x;
738  int ydiff = ED4_ROOT->scroll_picture.old_y - event.y;
739 
740  ed4_scroll(aww, xdiff, ydiff, true);
741 
742  ED4_ROOT->scroll_picture.old_x = event.x;
743  ED4_ROOT->scroll_picture.old_y = event.y;
744  }
745  }
746  else {
747 
748 #if defined(DEBUG) && 0
749  if (event.button==AW_BUTTON_LEFT) {
750  printf("[ED4_motion_cb] type=%i x=%i y=%i ", (int)event.type, (int)event.x, (int)event.y);
751  }
752 #endif
753 
754  AW_pos win_x = event.x;
755  AW_pos win_y = event.y;
756  current_ed4w()->win_to_world_coords(&win_x, &win_y);
757  event.x = (int) win_x;
758  event.y = (int) win_y;
759 
760 #if defined(DEBUG) && 0
761  if (event.button==AW_BUTTON_LEFT) {
762  printf("-> x=%i y=%i\n", (int)event.type, (int)event.x, (int)event.y);
763  }
764 #endif
765 
767  ED4_ROOT->main_manager->event_sent_by_parent(&event, aww);
768  }
769 }
770 
772  AW_awar *awar = awr->awar(AWAR_SET_CURSOR_POSITION);
773  long pos = awar->read_int();
774 
775  if (pos != -1) {
776  ED4_MostRecentWinContext context;
777  ED4_cursor *cursor = &current_cursor();
778  cursor->jump_sequence_pos(pos, ED4_JUMP_CENTERED);
779  awar->write_int(-1);
780  }
781 }
782 
783 void ED4_jump_to_cursor_position(AW_window *aww, const char *awar_name, PositionType posType) {
784  ED4_LocalWinContext uses(aww);
785  ED4_cursor *cursor = &current_cursor();
786  GB_ERROR error = NULp;
787 
788  long pos = aww->get_root()->awar(awar_name)->read_int();
789 
790  if (pos>0) pos = bio2info(pos);
791  else if (pos<0) { // jump negative (count from back)
792  int last_pos = -1; // [1..]
793 
794  switch (posType) {
795  case ED4_POS_SEQUENCE: {
796  last_pos = MAXSEQUENCECHARACTERLENGTH;
797  break;
798  }
799  case ED4_POS_ECOLI: {
800  BI_ecoli_ref *ecoli = ED4_ROOT->ecoli_ref;
801  if (ecoli->gotData()) {
802  last_pos = ecoli->abs_2_rel(INT_MAX);
803  }
804  else {
805  last_pos = 0; // doesnt matter (error below)
806  }
807  break;
808  }
809  case ED4_POS_BASE: {
810  last_pos = cursor->sequence2base_position(INT_MAX);
811  break;
812  }
813  }
814 
815  e4_assert(last_pos != -1);
816  pos = bio2info(last_pos+1+pos);
817  }
818 
819  switch (posType) {
820  case ED4_POS_SEQUENCE: {
821  e4_assert(strcmp(awar_name, current_ed4w()->awar_path_for_cursor)==0);
822  break;
823  }
824  case ED4_POS_ECOLI: {
825  e4_assert(strcmp(awar_name, current_ed4w()->awar_path_for_Ecoli)==0);
826 
827  BI_ecoli_ref *ecoli = ED4_ROOT->ecoli_ref;
828  if (ecoli->gotData()) pos = ecoli->rel_2_abs(pos);
829  else error = "No ecoli reference";
830  break;
831  }
832  case ED4_POS_BASE: {
833  e4_assert(strcmp(awar_name, current_ed4w()->awar_path_for_basePos)==0);
834  pos = cursor->base2sequence_position(pos);
835  break;
836  }
837  }
838 
839  // now position is absolute [0..N-1]
840 
841  // limit to screen
842  {
843  ED4_remap *remap = ED4_ROOT->root_group_man->remap();
844  long max = remap->screen_to_sequence(remap->get_max_screen_pos());
845 
846  if (pos > max) pos = max;
847  else if (pos<0) pos = 0;
848  }
849 
850  if (error) {
851  aw_message(error);
852  }
853  else {
854  cursor->jump_sequence_pos(pos, ED4_JUMP_CENTERED);
855  }
856 }
857 
858 void ED4_set_helixnr(AW_window *aww, const char *awar_name) {
859  ED4_LocalWinContext uses(aww);
860  ED4_cursor *cursor = &current_cursor();
861 
862  if (cursor->owner_of_cursor) {
863  AW_root *root = aww->get_root();
864  char *helix_nr = root->awar(awar_name)->read_string();
865  BI_helix *helix = ED4_ROOT->helix;
866 
867  if (helix->has_entries()) {
868  long pos = helix->first_position(helix_nr);
869 
870  if (pos == -1) {
871  aw_message(GBS_global_string("No helix '%s' found", helix_nr));
872  }
873  else {
874  cursor->jump_sequence_pos(pos, ED4_JUMP_CENTERED);
875  }
876  }
877  else {
878  aw_message("Got no helix information");
879  }
880  free(helix_nr);
881  }
882 }
883 
884 void ED4_set_iupac(AW_window *aww, const char *awar_name) {
885  ED4_LocalWinContext uses(aww);
886  ED4_cursor *cursor = &current_cursor();
887 
888  if (cursor->owner_of_cursor) {
889  if (cursor->in_consensus_terminal()) {
890  aw_message("You cannot change the consensus");
891  }
892  else {
893  int len;
894  char *seq = cursor->owner_of_cursor->resolve_pointer_to_string_copy(&len);
895  int seq_pos = cursor->get_sequence_pos();
896 
897  e4_assert(seq);
898 
899  if (seq_pos<len) {
900  char *iupac = ED4_ROOT->aw_root->awar(awar_name)->read_string();
901  char new_char = iupac::encode(iupac, ED4_ROOT->alignment_type);
902 
903  seq[seq_pos] = new_char;
904  cursor->owner_of_cursor->write_sequence(seq, len);
905 
906  free(iupac);
907  }
908 
909  free(seq);
910  }
911  }
912 }
913 
914 void ED4_exit() {
915  // @@@ most of the code here could be placed in ED4_ROOT-dtor
916 
919 
921 
922  while (ed4w) {
923  ed4w->aww->hide();
924  ed4w->cursor.prepare_shutdown(); // removes any callbacks
925  ed4w = ed4w->next;
926  }
927 
928  while (ED4_ROOT->first_window) {
930  }
931 
933  delete ED4_ROOT;
934 
935 #if defined(DEBUG)
936  AWT_browser_forget_db(gb_main);
937 #endif // DEBUG
938  GB_close(gb_main);
939 
940  ::exit(EXIT_SUCCESS);
941 }
942 
944  ED4_LocalWinContext uses(aww); // @@@ dont use context here
945 
946  if (ED4_ROOT->first_window == current_ed4w()) { // quit button has been pressed in first window
947  ED4_exit();
948  }
949  // case : in another window close has been pressed
950  current_aww()->hide();
951  current_ed4w()->is_hidden = true;
952 }
953 
954 static int timer_calls = 0;
955 static int timer_calls_triggered = 0;
956 
957 static unsigned ED4_timer(AW_root *) {
958  timer_calls++;
959 
960 #if defined(TRACE_REFRESH)
961  fprintf(stderr, "ED4_timer\n"); fflush(stderr);
962 #endif
964 
965  // get all changes from server
966  GB_begin_transaction(gb_main);
967  GB_tell_server_dont_wait(gb_main);
968  GB_commit_transaction(gb_main);
969 
971 
972  if (timer_calls == timer_calls_triggered) {
973  timer_calls_triggered++;
974  return 2000; // trigger callback after 2s
975  }
976  return 0; // do not trigger callback
977 }
978 
980 #if defined(TRACE_REFRESH)
981  fprintf(stderr, "ED4_trigger_instant_refresh\n"); fflush(stderr);
982 #endif
983  timer_calls_triggered++;
984  ED4_ROOT->aw_root->add_timed_callback(1, makeTimedCallback(ED4_timer)); // trigger instant callback
985 }
987  ED4_ROOT->main_manager->request_refresh();
988 }
992 }
993 
996  ED4_ROOT->main_manager->request_resize();
998 }
999 
1000 #define SIGNIFICANT_FIELD_CHARS 30 // length used to compare field contents (in createGroupFromSelected)
1001 
1002 static void createGroupFromSelected(GB_CSTR group_name, GB_CSTR field_name, GB_CSTR field_content) {
1003  // creates a new group named group_name
1004  // if field_name==0 -> all selected species & subgroups are moved to this new group
1005  // if field_name!=0 -> all selected species containing field_content in field field_name are moved to this new group
1006 
1008  ED4_multi_species_manager *group_content_manager;
1009  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);
1010  ED4_build_group_manager_end(group_content_manager);
1011 
1012  group_content_manager->update_requested_by_child();
1013 
1014  ED4_counter++;
1016 
1017  bool lookingForNoContent = !field_content || field_content[0]==0;
1018 
1020  while (list_elem) {
1021  ED4_base *object = list_elem->elem()->object;
1022  object = object->get_parent(LEV_SPECIES);
1023 
1024  bool move_object = true;
1025  if (object->is_consensus_manager()) {
1026  object = object->get_parent(LEV_GROUP);
1027  if (field_name) move_object = false; // don't move groups if moving by field_name
1028  }
1029  else {
1030  e4_assert(object->is_species_manager());
1031  if (field_name) {
1032  GBDATA *gb_species = object->get_species_pointer();
1033  GBDATA *gb_field = GB_search(gb_species, field_name, GB_FIND);
1034 
1035  move_object = lookingForNoContent;
1036  if (gb_field) { // field was found
1037  char *found_content = GB_read_as_string(gb_field);
1038  if (found_content) {
1039  move_object = strncmp(found_content, field_content, SIGNIFICANT_FIELD_CHARS)==0;
1040  free(found_content);
1041  }
1042  }
1043  }
1044  }
1045 
1046  if (move_object) {
1047  ED4_base *base = object->get_parent(LEV_MULTI_SPECIES);
1048  if (base && base->is_multi_species_manager()) {
1049  ED4_multi_species_manager *old_multi = base->to_multi_species_manager();
1050  old_multi->invalidate_species_counters();
1051  }
1052 
1053  object->parent->remove_member(object);
1054  group_content_manager->append_member(object);
1055 
1056  object->parent = group_content_manager;
1057  object->set_width();
1058  }
1059 
1060  list_elem = list_elem->next();
1061  }
1062 
1063  new_group_manager->create_consensus(new_group_manager, NULp);
1064  group_content_manager->invalidate_species_counters();
1065 
1066  new_group_manager->fold();
1067 
1068  group_content_manager->resize_requested_by_child();
1069 }
1070 
1071 static void group_species(bool use_field, AW_window *use_as_main_window) {
1072  GB_ERROR error = NULp;
1074  GB_push_transaction(gb_main);
1075 
1076  ED4_LocalWinContext uses(use_as_main_window);
1077 
1078  if (!use_field) {
1079  char *group_name = aw_input("Enter name for new group:");
1080 
1081  if (group_name) {
1082  if (strlen(group_name)>GB_GROUP_NAME_MAX) {
1083  group_name[GB_GROUP_NAME_MAX] = 0;
1084  aw_message("Truncated overlong group name");
1085  }
1086  createGroupFromSelected(group_name, NULp, NULp);
1087  free(group_name);
1088  }
1089  }
1090  else {
1091  char *field_name = ED4_ROOT->aw_root->awar(AWAR_FIELD_CHOSEN)->read_string();
1092  char *doneContents = ARB_strdup(";");
1093  size_t doneLen = 1;
1094 
1095  bool tryAgain = true;
1096  bool foundField = false;
1097  bool foundSpecies = false;
1098 
1099  if (strcmp(field_name, NO_FIELD_SELECTED) == 0) {
1100  error = "Please select a field to use for grouping.";
1101  }
1102 
1103  while (tryAgain && !error) {
1104  tryAgain = false;
1106  while (list_elem && !error) {
1107  ED4_base *object = list_elem->elem()->object;
1108  object = object->get_parent(LEV_SPECIES);
1109  if (!object->is_consensus_manager()) {
1110  GBDATA *gb_species = object->get_species_pointer();
1111  GBDATA *gb_field = NULp;
1112 
1113  if (gb_species) {
1114  foundSpecies = true;
1115  gb_field = GB_search(gb_species, field_name, GB_FIND);
1116  }
1117 
1118  error = GB_incur_error_if(!gb_field);
1119  if (!error) {
1120  e4_assert(gb_field);
1121  char *field_content = GB_read_as_string(gb_field);
1122  if (field_content) {
1123  size_t field_content_len = strlen(field_content);
1124 
1125  foundField = true;
1126  if (field_content_len>SIGNIFICANT_FIELD_CHARS) {
1127  field_content[SIGNIFICANT_FIELD_CHARS] = 0;
1128  field_content_len = SIGNIFICANT_FIELD_CHARS;
1129  }
1130 
1131  char with_semi[SIGNIFICANT_FIELD_CHARS+2+1];
1132  sprintf(with_semi, ";%s;", field_content);
1133 
1134  if (!strstr(doneContents, with_semi)) { // field_content was not used yet
1135  createGroupFromSelected(field_content, field_name, field_content);
1136  tryAgain = true;
1137 
1138  int newlen = doneLen + field_content_len + 1;
1139  char *newDone = ARB_alloc<char>(newlen+1);
1140 
1141  GBS_global_string_to_buffer(newDone, newlen+1, "%s%s;", doneContents, field_content);
1142  freeset(doneContents, newDone);
1143  doneLen = newlen;
1144  }
1145  free(field_content);
1146  }
1147  else {
1148  error = "Incompatible field type";
1149  }
1150  }
1151  }
1152  list_elem = list_elem->next();
1153  }
1154  }
1155 
1156  if (!error) {
1157  if (!foundSpecies) error = "Please select some species in order to insert them into new groups";
1158  else if (!foundField) error = GBS_global_string("Field not found: '%s'%s", field_name, error ? GBS_global_string(" (Reason: %s)", error) : "");
1159  }
1160 
1161  free(doneContents);
1162  free(field_name);
1163  }
1164 
1165  GB_end_transaction_show_error(gb_main, error, aw_message);
1166 }
1167 
1168 static void group_species_by_field_content(AW_window*, AW_window *use_as_main_window, AW_window *window_to_hide) {
1169  group_species(true, use_as_main_window);
1170  window_to_hide->hide();
1171 }
1172 
1173 static AW_window *create_group_species_by_field_window(AW_root *aw_root, AW_window *use_as_main_window) {
1174  AW_window_simple *aws = new AW_window_simple;
1175 
1176  aws->init(aw_root, "CREATE_GROUP_USING_FIELD_CONTENT", "Create groups using field");
1177  aws->auto_space(10, 10);
1178 
1179  aws->button_length(10);
1180  aws->at_newline();
1181 
1182  aws->callback(AW_POPDOWN);
1183  aws->create_button("CLOSE", "CLOSE", "C");
1184 
1185  aws->callback(makeHelpCallback("group_by_field.hlp"));
1186  aws->create_button("HELP", "HELP", "H");
1187 
1188  aws->at_newline();
1189  aws->label("Use content of field");
1191 
1192  aws->at_newline();
1193  aws->callback(makeWindowCallback(group_species_by_field_content, use_as_main_window, static_cast<AW_window*>(aws)));
1194  aws->create_autosize_button("USE_FIELD", "Group selected species by content", "");
1195 
1196  return aws;
1197 }
1198 
1199 void group_species_cb(AW_window *aww, bool use_fields) {
1200  if (!use_fields) {
1201  group_species(false, aww);
1202  }
1203  else {
1204  static AW_window *ask_field_window;
1205 
1206  if (!ask_field_window) ask_field_window = create_group_species_by_field_window(ED4_ROOT->aw_root, aww);
1207  ask_field_window->activate();
1208  }
1209 }
1210 
1211 static GB_ERROR ED4_load_new_config(char *name) {
1212  GB_ERROR error;
1213  GBT_config cfg(ED4_ROOT->get_gb_main(), name, error);
1214  if (cfg.exists()) {
1215  ED4_ROOT->main_manager->clear_whole_background();
1216 
1218 
1220 
1221  if (ED4_ROOT->selected_objects->size() > 0) {
1223  }
1224 
1226 
1230 
1232 
1233  for (ED4_window *window = ED4_ROOT->first_window; window; window=window->next) {
1234  window->cursor.init();
1235  window->aww->set_horizontal_scrollbar_position (0);
1236  window->aww->set_vertical_scrollbar_position (0);
1237  }
1238 
1243 
1244  delete ED4_ROOT->main_manager;
1246  delete ED4_ROOT->ecoli_ref;
1247 
1249  ED4_ROOT->create_hierarchy(cfg.get_definition(GBT_config::MIDDLE_AREA), cfg.get_definition(GBT_config::TOP_AREA));
1250  }
1251 
1252  return error;
1253 }
1254 
1256  if (!root->awar(AWAR_EDIT_MODE)->read_int()) return AD_ALIGN;
1257  return root->awar(AWAR_INSERT_MODE)->read_int() ? AD_INSERT : AD_REPLACE;
1258 }
1259 
1261  ED4_EDITMODE mode = ED4_get_edit_mode(root);
1262  const char *awar_name = NULp;
1263 
1264  switch (mode) {
1265  case AD_ALIGN:
1266  awar_name = AWAR_EDIT_SECURITY_LEVEL_ALIGN;
1267  break;
1268  default:
1269  awar_name = AWAR_EDIT_SECURITY_LEVEL_CHANGE;
1270  }
1271 
1273 
1274  long level = ED4_ROOT->aw_root->awar(awar_name)->read_int();
1275  GB_change_my_security(ED4_ROOT->get_gb_main(), level); // change user security in EDIT4
1276 }
1277 
1280  ed4_changesecurity(root);
1281 }
1282 
1284  if (object->is_consensus_manager()) {
1285  ED4_species_manager *spec_man = object->to_species_manager();
1286  spec_man->do_callbacks();
1287 
1288  ED4_base *sequence_data_terminal = spec_man->search_spec_child_rek(LEV_SEQUENCE_STRING);
1289  sequence_data_terminal->request_refresh();
1290  }
1291  return NULp; // needed by route_down_hierarchy
1292 }
1293 
1295  ED4_LocalWinContext uses(aww);
1296 
1297  AW_device *device;
1298  ED4_window *new_window = NULp;
1299 
1300  if (ED4_ROOT->generate_window(&device, &new_window) != ED4_R_BREAK) {
1301  ED4_LocalWinContext now_uses(new_window);
1302 
1307 
1308  new_window->aww->show();
1309  new_window->update_scrolled_rectangle();
1310  }
1311 }
1312 
1313 
1314 
1316  aww->hide();
1317 
1318  GB_ERROR error;
1319  {
1320  char *name = aww->get_root()->awar(AWAR_EDIT_CONFIGURATION)->read_string();
1321  error = ED4_load_new_config(name);
1322  free(name);
1323  }
1324 
1325  if (error) {
1326  aw_message(error);
1327  aww->show(); // show old window
1328  }
1329 }
1330 
1331 struct cursorpos {
1334  int seq;
1335 
1337  : cursor(&win->cursor),
1338  screen_rel(cursor->get_screen_relative_pos()),
1339  seq(cursor->get_sequence_pos())
1340  {}
1341 };
1342 
1343 
1346  int percent = awr->awar(ED4_AWAR_COMPRESS_SEQUENCE_PERCENT)->read_int();
1348 
1349  if (ED4_ROOT->root_group_man) {
1350  vector<cursorpos> pos;
1351 
1352  for (ED4_window *win = ED4_ROOT->first_window; win; win = win->next) {
1353  pos.push_back(cursorpos(win));
1354  }
1355 
1356  ED4_ROOT->root_group_man->remap()->set_mode(mode, percent);
1358 
1359  for (vector<cursorpos>::iterator i = pos.begin(); i != pos.end(); ++i) {
1360  ED4_cursor *cursor = i->cursor;
1361  ED4_window *win = cursor->window();
1362 
1363  win->update_scrolled_rectangle(); // @@@ needed ?
1364 
1365  cursor->jump_sequence_pos(i->seq, ED4_JUMP_KEEP_POSITION);
1366  cursor->set_screen_relative_pos(i->screen_rel);
1367  }
1368 
1370  }
1371 }
1372 
1373 void ED4_compression_toggle_changed_cb(AW_root *root, bool hideChanged) {
1374  int gaps = root->awar(ED4_AWAR_COMPRESS_SEQUENCE_GAPS)->read_int();
1375  int hide = root->awar(ED4_AWAR_COMPRESS_SEQUENCE_HIDE)->read_int();
1376 
1377  ED4_remap_mode mode = ED4_remap_mode(root->awar(ED4_AWAR_COMPRESS_SEQUENCE_TYPE)->read_int()); // @@@ mode is overwritten below
1378 
1379  if (hideChanged) {
1380  // ED4_AWAR_COMPRESS_SEQUENCE_HIDE changed
1381  if (hide!=0 && gaps!=2) {
1383  return;
1384  }
1385  }
1386  else {
1387  // ED4_AWAR_COMPRESS_SEQUENCE_GAPS changed
1388  if (gaps!=2 && hide!=0) {
1390  return;
1391  }
1392  }
1393 
1394  mode = ED4_RM_NONE;
1395  switch (gaps) {
1396  case 0: mode = ED4_RM_NONE; break;
1397  case 1: mode = ED4_RM_DYNAMIC_GAPS; break;
1398  case 2: {
1399  switch (hide) {
1400  case 0: mode = ED4_RM_MAX_ALIGN; break;
1401  case 1: mode = ED4_RM_SHOW_ABOVE; break;
1402  default: e4_assert(0); break;
1403  }
1404  break;
1405  }
1406  default: e4_assert(0); break;
1407  }
1408 
1409  root->awar(ED4_AWAR_COMPRESS_SEQUENCE_TYPE)->write_int(int(mode));
1410 }
1411 
1413  { ED4_AWAR_COMPRESS_SEQUENCE_GAPS, "compressgaps" },
1414  { ED4_AWAR_COMPRESS_SEQUENCE_HIDE, "hidenucs" },
1415  { ED4_AWAR_COMPRESS_SEQUENCE_PERCENT, "hidepercent" },
1416  { AWAR_EDIT_HELIX_SPACING, "helixspacing" },
1417  { AWAR_EDIT_TERMINAL_SPACING, "terminalspacing" },
1418  { ED4_AWAR_SCROLL_SPEED_X, "scrollspeedx" },
1419  { ED4_AWAR_SCROLL_SPEED_Y, "scrollspeedy" },
1420  { ED4_AWAR_SCROLL_MARGIN, "scrollmargin" },
1421  { ED4_AWAR_GAP_CHARS, "gapchars" },
1422  { ED4_AWAR_DIGITS_AS_REPEAT, "digitsasrepeat" },
1423  { ED4_AWAR_FAST_CURSOR_JUMP, "fastcursorjump" },
1424  { ED4_AWAR_ANNOUNCE_CHECKSUM_CHANGES, "announcechecksumchanges" },
1425 
1426  { NULp, NULp }
1427 };
1428 
1430  AW_window_simple *aws = new AW_window_simple;
1431 
1432  aws->init(root, "EDIT4_PROPS", "EDIT4 Options");
1433  aws->load_xfig("edit4/options.fig");
1434 
1435  aws->auto_space(5, 5);
1436 
1437  const int SCALEDCOLUMNS = 4;
1438  const int SCALERLEN = 200;
1439 
1440  aws->callback(AW_POPDOWN);
1441  aws->at("close");
1442  aws->create_button("CLOSE", "CLOSE", "C");
1443 
1444  aws->callback(makeHelpCallback("e4_options.hlp"));
1445  aws->at("help");
1446  aws->create_button("HELP", "HELP", "H");
1447 
1448  // -----------------------------------
1449  // Online Sequence Compression
1450 
1451  aws->at("gaps");
1452  aws->create_toggle_field(ED4_AWAR_COMPRESS_SEQUENCE_GAPS);
1453  aws->insert_default_toggle("Show all gaps", "A", 0);
1454  aws->insert_toggle("Show some gaps", "S", 1);
1455  aws->insert_toggle("Hide all gaps", "H", 2);
1456  aws->update_toggle_field();
1457 
1458  aws->at("hide");
1459  aws->create_toggle_field(ED4_AWAR_COMPRESS_SEQUENCE_HIDE);
1460  aws->insert_default_toggle("Hide no Nucleotides", "0", 0);
1461  aws->insert_toggle("Hide columns with less than...", "1", 1);
1462  aws->update_toggle_field();
1463 
1464  aws->at("percent");
1465  aws->create_input_field_with_scaler(ED4_AWAR_COMPRESS_SEQUENCE_PERCENT, SCALEDCOLUMNS, SCALERLEN, AW_SCALER_LINEAR);
1466 
1467  // --------------
1468  // Layout
1469 
1470  aws->at("seq_helix"); aws->create_input_field_with_scaler(AWAR_EDIT_HELIX_SPACING, SCALEDCOLUMNS, SCALERLEN, AW_SCALER_EXP_CENTER);
1471  aws->at("seq_seq"); aws->create_input_field_with_scaler(AWAR_EDIT_TERMINAL_SPACING, SCALEDCOLUMNS, SCALERLEN, AW_SCALER_EXP_CENTER);
1472 
1473  // --------------------
1474  // Scroll-Speed
1475 
1476  aws->at("scroll_x");
1477  aws->create_input_field(ED4_AWAR_SCROLL_SPEED_X);
1478 
1479  aws->at("scroll_y");
1480  aws->create_input_field(ED4_AWAR_SCROLL_SPEED_Y);
1481 
1482  aws->at("margin");
1483  aws->create_input_field(ED4_AWAR_SCROLL_MARGIN);
1484 
1485  // ---------------
1486  // Editing
1487 
1488  aws->at("gapchars");
1489  aws->create_input_field(ED4_AWAR_GAP_CHARS);
1490 
1491  aws->at("repeat");
1492  aws->create_toggle(ED4_AWAR_DIGITS_AS_REPEAT);
1493 
1494  aws->at("fast");
1495  aws->create_toggle(ED4_AWAR_FAST_CURSOR_JUMP);
1496 
1497  aws->at("checksum");
1498  aws->create_toggle(ED4_AWAR_ANNOUNCE_CHECKSUM_CHANGES);
1499 
1500  aws->at("config");
1501  AWT_insert_config_manager(aws, AW_ROOT_DEFAULT, "options", editor_options_config_mapping);
1502 
1503  return aws;
1504 }
1505 
1513 
1514  { NULp, NULp }
1515 };
1516 
1518  // keep in sync with ../NTREE/AP_consensus.cxx@AP_create_con_expert_window
1519 
1520  static AW_window_simple *aws = NULp;
1521 
1522  if (!aws) {
1523  aws = new AW_window_simple;
1524 
1525  aws->init(root, "EDIT4_CONSENSUS_DEFm", "EDIT4 Consensus Definition");
1526  aws->load_xfig("edit4/consensus.fig");
1527 
1528  aws->auto_space(5, 5);
1529 
1530  const int SCALEDCOLUMNS = 3;
1531  const int SCALERSIZE = 150;
1532 
1533  // top part of window:
1534  aws->button_length(9);
1535 
1536  aws->callback(AW_POPDOWN);
1537  aws->at("close");
1538  aws->create_button("CLOSE", "CLOSE", "C");
1539 
1540  aws->callback(makeHelpCallback("e4_consensus.hlp"));
1541  aws->at("help");
1542  aws->create_button("HELP", "HELP", "H");
1543 
1544  // center part of window (same as in NTREE):
1545  aws->at("countgaps");
1546  aws->create_toggle_field(ED4_AWAR_CONSENSUS_COUNTGAPS);
1547  aws->insert_toggle("on", "1", 1);
1548  aws->insert_default_toggle("off", "0", 0);
1549  aws->update_toggle_field();
1550 
1551  aws->at("gapbound");
1552  aws->create_input_field_with_scaler(ED4_AWAR_CONSENSUS_GAPBOUND, SCALEDCOLUMNS, SCALERSIZE, AW_SCALER_LINEAR);
1553 
1554  aws->at("group");
1555  aws->create_toggle_field(ED4_AWAR_CONSENSUS_GROUP);
1556  aws->insert_toggle("on", "1", 1);
1557  aws->insert_default_toggle("off", "0", 0);
1558  aws->update_toggle_field();
1559 
1560  aws->at("considbound");
1561  aws->create_input_field_with_scaler(ED4_AWAR_CONSENSUS_CONSIDBOUND, SCALEDCOLUMNS, SCALERSIZE, AW_SCALER_LINEAR);
1562 
1563  aws->at("showgroups");
1564  aws->callback(AWT_create_IUPAC_info_window);
1565  aws->create_autosize_button("SHOW_IUPAC", "Show IUPAC groups", "S");
1566 
1567  aws->at("upper");
1568  aws->create_input_field_with_scaler(ED4_AWAR_CONSENSUS_UPPER, SCALEDCOLUMNS, SCALERSIZE, AW_SCALER_LINEAR);
1569 
1570  aws->at("lower");
1571  aws->create_input_field_with_scaler(ED4_AWAR_CONSENSUS_LOWER, SCALEDCOLUMNS, SCALERSIZE, AW_SCALER_LINEAR);
1572 
1573  // bottom part of window:
1574  aws->at("show");
1575  aws->label("Display consensus?");
1576  aws->create_toggle(ED4_AWAR_CONSENSUS_SHOW);
1577 
1578  aws->at("config");
1579  AWT_insert_config_manager(aws, AW_ROOT_DEFAULT, CONSENSUS_CONFIG_ID, consensus_config_mapping);
1580  }
1581 
1582  return aws;
1583 }
1584 
1585 static void consensus_upper_lower_changed_cb(AW_root *awr, bool upper_changed) {
1586  AW_awar *awar_lower = awr->awar(ED4_AWAR_CONSENSUS_LOWER);
1587  AW_awar *awar_upper = awr->awar(ED4_AWAR_CONSENSUS_UPPER);
1588 
1589  int lower = awar_lower->read_int();
1590  int upper = awar_upper->read_int();
1591 
1592  if (upper<lower) {
1593  if (upper_changed) awar_lower->write_int(upper);
1594  else awar_upper->write_int(lower);
1595  }
1597 }
1598 
1601 
1606  aw_root->awar_int(ED4_AWAR_CONSENSUS_UPPER, 95)->set_minmax(0, 100)->add_callback(makeRootCallback(consensus_upper_lower_changed_cb, true));
1607  aw_root->awar_int(ED4_AWAR_CONSENSUS_LOWER, 70)->set_minmax(0, 100)->add_callback(makeRootCallback(consensus_upper_lower_changed_cb, false));
1608 
1609  AW_awar *cons_show = aw_root->awar_int(ED4_AWAR_CONSENSUS_SHOW, 1);
1610 
1611  cons_show->write_int(1);
1613 }
1614 
1617 }
1618 
1620  static AW_window_simple *aws = NULp;
1621  if (!aws) {
1622  aws = new AW_window_simple;
1623  aws->init(awr, "LOAD_CONFIGURATION", "Load existing configuration");
1624  aws->load_xfig("edit4/load_config.fig");
1625 
1626  aws->at("close");
1627  aws->callback(AW_POPDOWN);
1628  aws->create_button("CLOSE", "CLOSE", "C");
1629 
1630  aws->at("help");
1631  aws->callback(makeHelpCallback("species_configs_saveload.hlp"));
1632  aws->create_button("HELP", "HELP");
1633 
1634  aws->at("confs");
1636 
1637  aws->at("go");
1638  aws->callback(ED4_start_editor_on_configuration);
1639  aws->create_button("LOAD", "LOAD");
1640 
1641  aws->window_fit();
1642  }
1643  return aws;
1644 }
1645 
1646 void ED4_saveConfiguration(AW_window *aww, bool hide_aww) {
1647  if (hide_aww) aww->hide();
1648 
1649  char *name = aww->get_root()->awar(AWAR_EDIT_CONFIGURATION)->read_string();
1651  free(name);
1652 }
1653 
1655  static AW_window_simple *aws = NULp;
1656  if (!aws) {
1657  aws = new AW_window_simple;
1658  aws->init(awr, "SAVE_CONFIGURATION", "Save current configuration as");
1659  aws->load_xfig("edit4/save_config.fig");
1660 
1661  aws->at("close");
1662  aws->callback(AW_POPDOWN);
1663  aws->create_button("CLOSE", "CLOSE");
1664 
1665  aws->at("help");
1666  aws->callback(makeHelpCallback("species_configs_saveload.hlp"));
1667  aws->create_button("HELP", "HELP");
1668 
1669  aws->at("save");
1670  aws->create_input_field(AWAR_EDIT_CONFIGURATION);
1671 
1672  aws->at("confs");
1674 
1675  aws->at("go");
1676  aws->callback(makeWindowCallback(ED4_saveConfiguration, true));
1677  aws->create_button("SAVE", "SAVE");
1678  }
1679  return aws;
1680 }
1681 
1682 static char *filter_loadable_SAIs(GBDATA *gb_sai) {
1683  GBDATA *gb_ali = GB_search(gb_sai, ED4_ROOT->alignment_name, GB_FIND);
1684  if (gb_ali) {
1685  GBDATA *gb_data = GB_search(gb_ali, "data", GB_FIND);
1686  if (gb_data) {
1687  const char *sai_name = GBT_get_name(gb_sai);
1688  if (sai_name && !ED4_find_SAI_name_terminal(sai_name)) { // if not loaded yet
1689  return ARB_strdup(sai_name);
1690  }
1691  }
1692  }
1693  return NULp;
1694 }
1695 
1697  static AW_window_simple *aws = NULp;
1698  if (!aws) {
1699  aws = new AW_window_simple;
1700  aws->init(awr, "LOAD_SAI", "Load additional SAI");
1701  aws->load_xfig("edit4/load_sai.fig");
1702 
1703  aws->at("close");
1704  aws->callback(AW_POPDOWN);
1705  aws->create_button("CLOSE", "CLOSE");
1706 
1707  aws->at("help");
1708  aws->callback(makeHelpCallback("e4_get_species.hlp"));
1709  aws->create_button("HELP", "HELP");
1710 
1711  aws->at("sai");
1712  awt_create_SAI_selection_list(ED4_ROOT->get_gb_main(), aws, AWAR_SAI_NAME, false, makeSaiSelectionlistFilterCallback(filter_loadable_SAIs));
1714 
1715  aws->at("go");
1716  aws->callback(ED4_get_and_jump_to_selected_SAI);
1717  aws->create_button("LOAD", "LOAD");
1718  }
1719  return aws;
1720 }
1721 
1723  GB_ERROR error = NULp;
1724 
1725  int len;
1726  char *consensus = group_man->build_consensus_string(&len);
1727 
1731 
1732  for (int p=0; p<len; p++) {
1733  switch (consensus[p]) {
1734  case '=': consensus[p] = equal_to[0]; break;
1735  case '.': consensus[p] = point_to[0]; break;
1736  default: {
1737  if (allUpper) {
1738  consensus[p] = toupper(consensus[p]);
1739  }
1740  break;
1741  }
1742  }
1743  }
1744 
1745  if (ED4_ROOT->aw_root->awar(ED4_AWAR_CREATE_FROM_CONS_CREATE_POINTS)) { // points at start & end of sequence?
1746  for (int p=0; p<len; p++) {
1747  if (!ED4_is_gap_character(consensus[p])) break;
1748  consensus[p] = '.';
1749  }
1750  for (int p=len-1; p>=0; p--) {
1751  if (!ED4_is_gap_character(consensus[p])) break;
1752  consensus[p] = '.';
1753  }
1754  }
1755 
1757  GBDATA *gb_ali = GB_search(gb_species, ali, GB_DB);
1758  if (gb_ali) {
1759  GBDATA *gb_data = GB_search(gb_ali, "data", GB_STRING);
1760  error = GB_write_pntr(gb_data, consensus, len+1, len);
1761  }
1762  else {
1763  error = GB_export_errorf("Can't find alignment '%s'", ali);
1764  }
1765  free(consensus);
1766  return error;
1767 }
1768 
1769 // --------------------------------------------------------------------------------
1770 
1774 
1776 };
1777 
1779  GB_ERROR error = NULp;
1780 
1781  if (base->is_species_name_terminal()) {
1782  ED4_species_name_terminal *name_term = base->to_species_name_terminal();
1783 
1784  if (!name_term->inside_consensus_manager()) {
1785  char *species_name = name_term->resolve_pointer_to_string_copy();
1786  GBDATA *gb_species = GBT_find_species_rel_species_data(gb_species_data, species_name);
1787 
1788  if (gb_species) {
1790 
1791  sml->species = gb_species;
1792  sml->species_name = ARB_strdup(species_name);
1793  sml->next = *smlp;
1794  *smlp = sml;
1795  }
1796  else {
1797  error = GB_append_exportedError(GBS_global_string("can't find species '%s'", species_name));
1798  }
1799 
1800  free(species_name);
1801  }
1802  }
1803  return error;
1804 }
1806  int length = 0;
1807 
1808  while (sml) {
1809  length++;
1810  sml = sml->next;
1811  }
1812 
1813  return length;
1814 }
1816  while (sml) {
1817  free(sml->species_name);
1818  freeset(sml, sml->next);
1819  }
1820 }
1821 
1822 // --------------------------------------------------------------------------------
1823 
1824 inline bool nameIsUnique(const char *short_name, GBDATA *gb_species_data) {
1825  return !GBT_find_species_rel_species_data(gb_species_data, short_name);
1826 }
1827 
1828 
1829 static void create_new_species(AW_window *, SpeciesCreationMode creation_mode) {
1830  char *new_species_full_name = ED4_ROOT->aw_root->awar(ED4_AWAR_SPECIES_TO_CREATE)->read_string(); // this contains the full_name now!
1831  ARB_ERROR error = NULp;
1832 
1833  e4_assert(creation_mode>=0 && creation_mode<=2);
1834 
1835  if (!new_species_full_name || new_species_full_name[0]==0) {
1836  error = "Please enter a full_name for the new species";
1837  }
1838  else {
1839  ED4_MostRecentWinContext context;
1840 
1842  error = GB_begin_transaction(gb_main);
1843 
1845  char *new_species_name = NULp;
1846  char *acc = NULp;
1847  char *addid = NULp;
1848 
1849  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();
1850  enum { NOWHERE, ON_SPECIES, ON_CONSENSUS } where_we_are = NOWHERE;
1851  ED4_terminal *cursor_terminal = NULp;
1852 
1853  if (!error) {
1854  if (creation_mode==CREATE_FROM_CONSENSUS || creation_mode==COPY_SPECIES) {
1855  ED4_cursor *cursor = &current_cursor();
1856 
1857  if (cursor->owner_of_cursor) {
1858  cursor_terminal = cursor->owner_of_cursor;
1859  where_we_are = cursor_terminal->is_consensus_terminal() ? ON_CONSENSUS : ON_SPECIES;
1860  }
1861  }
1862 
1863  if (creation_mode==COPY_SPECIES || (creation_mode==CREATE_FROM_CONSENSUS && dataSource==COPY_FIELDS)) {
1864  if (where_we_are==ON_SPECIES) {
1865  ED4_species_name_terminal *spec_name = cursor_terminal->to_sequence_terminal()->corresponding_species_name_terminal();
1866  const char *source_name = spec_name->resolve_pointer_to_char_pntr();
1867  GBDATA *gb_source = GBT_find_species_rel_species_data(gb_species_data, source_name);
1868 
1869  if (!gb_source) error = GBS_global_string("No such species: '%s'", source_name);
1870  else {
1871  GBDATA *gb_acc = GB_search(gb_source, "acc", GB_FIND);
1872  if (gb_acc) acc = GB_read_string(gb_acc); // if has accession
1873 
1874  const char *add_field = AW_get_nameserver_addid(gb_main);
1875  GBDATA *gb_addid = add_field[0] ? GB_search(gb_source, add_field, GB_FIND) : NULp;
1876  if (gb_addid) addid = GB_read_as_string(gb_addid);
1877  }
1878  }
1879  else {
1880  error = "Please place cursor on a species";
1881  }
1882  }
1883  }
1884 
1885  if (!error) {
1886  UniqueNameDetector *existingNames = NULp;
1887 
1888  if (creation_mode==0) {
1889  error = "It's no good idea to create the short-name for a new species using the nameserver! (has no acc yet)";
1890  }
1891  else {
1892  error = AWTC_generate_one_name(gb_main, new_species_full_name, acc, addid, new_species_name);
1893  if (!error) { // name was created
1894  if (!nameIsUnique(new_species_name, gb_species_data)) {
1895  if (!existingNames) existingNames = new UniqueNameDetector(gb_species_data);
1896  freeset(new_species_name, AWTC_makeUniqueShortName(new_species_name, *existingNames));
1897  if (!new_species_name) error = GB_await_error();
1898  }
1899  }
1900  }
1901 
1902  if (error) { // try to make a random name
1903  const char *msg = GBS_global_string("%s\nGenerating a random name instead.", error.deliver());
1904  aw_message(msg);
1905  error = NULp;
1906 
1907  if (!existingNames) existingNames = new UniqueNameDetector(gb_species_data);
1908  new_species_name = AWTC_generate_random_name(*existingNames);
1909 
1910  if (!new_species_name) {
1911  error = GBS_global_string("Failed to create a new name for '%s'", new_species_full_name);
1912  }
1913  }
1914 
1915  if (existingNames) delete existingNames;
1916  }
1917 
1918  if (!error) {
1919  if (!error) {
1920  if (creation_mode==CREATE_NEW_SPECIES) {
1921  GBDATA *gb_created_species = GBT_find_or_create_species(gb_main, new_species_name, true);
1922  if (!gb_created_species) {
1923  error = GBS_global_string("Failed to create new species '%s'", new_species_name);
1924  }
1925  else {
1926  GB_CSTR ali = GBT_get_default_alignment(gb_main);
1927  GBDATA *gb_ali = GB_search(gb_created_species, ali, GB_DB);
1928 
1929  if (gb_ali) error = GBT_write_string(gb_ali, "data", ".......");
1930  else error = GBS_global_string("Can't create alignment '%s' (Reason: %s)", ali, GB_await_error());
1931  }
1932  if (!error) error = GBT_write_string(gb_created_species, "full_name", new_species_full_name);
1933  }
1934  else if (creation_mode==CREATE_FROM_CONSENSUS && dataSource==MERGE_FIELDS) {
1935  // create from consensus (merge fields from all species in container)
1936  if (where_we_are==NOWHERE) {
1937  error = "Please place cursor on any sequence/consensus of group";
1938  }
1939  else {
1940  ED4_group_manager *group_man = cursor_terminal->get_parent(LEV_GROUP)->to_group_manager();
1941  SpeciesMergeList *sml = NULp; // list of species in group
1942 
1943  error = group_man->route_down_hierarchy(makeED4_route_cb(add_species_to_merge_list, &sml, gb_species_data));
1944  if (!error && !sml) {
1945  error = "Please choose a none empty group!";
1946  }
1947 
1948  GBDATA *gb_new_species = NULp;
1949  if (!error) {
1950  GBDATA *gb_source = sml->species;
1951  gb_new_species = GB_create_container(gb_species_data, "species");
1952  error = GB_copy_dropProtectMarksAndTempstate(gb_new_species, gb_source); // copy first found species to create a new species
1953  }
1954  if (!error) error = GBT_write_string(gb_new_species, "name", new_species_name); // insert new 'name'
1955  if (!error) error = GBT_write_string(gb_new_species, "full_name", new_species_full_name); // insert new 'full_name'
1956  if (!error) error = createDataFromConsensus(gb_new_species, group_man); // insert consensus as 'data'
1957 
1958  if (!error) {
1959  char *doneFields = ARB_strdup(";name;full_name;"); // all fields which are already merged
1960  int doneLen = strlen(doneFields);
1961  SpeciesMergeList *sl = sml;
1962  int sl_length = SpeciesMergeListLength(sml);
1963  int *fieldStat = new int[sl_length]; // 0 = not used yet ; -1 = don't has field ; 1..n = field content, same number means same content
1964 
1965  arb_progress progress("Merging fields", long(sl_length));
1966 
1967  while (sl && !error) { // with all species do..
1968  char *newFields = GB_get_subfields(sl->species);
1969  char *fieldStart = newFields; // points to ; before next field
1970 
1971  while (fieldStart[1] && !error) { // with all subfields of the species do..
1972  char *fieldEnd = strchr(fieldStart+1, ';');
1973 
1974  e4_assert(fieldEnd);
1975  char behind = fieldEnd[1];
1976  fieldEnd[1] = 0;
1977 
1978  if (!strstr(doneFields, fieldStart)) { // field is not merged yet
1979  char *fieldName = fieldStart+1;
1980  int fieldLen = int(fieldEnd-fieldName);
1981 
1982  e4_assert(fieldEnd[0]==';');
1983  fieldEnd[0] = 0;
1984 
1985  GBDATA *gb_field = GB_search(sl->species, fieldName, GB_FIND);
1986  e4_assert(gb_field); // field has to exist, cause it was found before
1987 
1988  GB_TYPES type = GB_read_type(gb_field);
1989  if (type==GB_STRING) { // we only merge string fields
1990  int i;
1991  int doneSpecies = 0;
1992  int nextStat = 1;
1993 
1994  for (i=0; i<sl_length; i++) { // clear field status
1995  fieldStat[i] = 0;
1996  }
1997 
1998  while (doneSpecies<sl_length) { // since all species in list were handled
1999  SpeciesMergeList *sl2 = sml;
2000  i = 0;
2001 
2002  while (sl2) {
2003  if (fieldStat[i]==0) {
2004  gb_field = GB_search(sl2->species, fieldName, GB_FIND);
2005  if (gb_field) {
2006  char *content = GB_read_as_string(gb_field);
2007  SpeciesMergeList *sl3 = sl2->next;
2008 
2009  fieldStat[i] = nextStat;
2010  doneSpecies++;
2011  int j = i+1;
2012  while (sl3) {
2013  if (fieldStat[j]==0) {
2014  gb_field = GB_search(sl3->species, fieldName, GB_FIND);
2015  if (gb_field) {
2016  char *content2 = GB_read_as_string(gb_field);
2017 
2018  if (strcmp(content, content2)==0) { // if contents are the same, they get the same status
2019  fieldStat[j] = nextStat;
2020  doneSpecies++;
2021  }
2022  free(content2);
2023  }
2024  else {
2025  fieldStat[j] = -1;
2026  doneSpecies++;
2027  }
2028  }
2029  sl3 = sl3->next;
2030  j++;
2031  }
2032 
2033  free(content);
2034  nextStat++;
2035  }
2036  else {
2037  fieldStat[i] = -1; // field does not exist here
2038  doneSpecies++;
2039  }
2040  }
2041  sl2 = sl2->next;
2042  i++;
2043  }
2044  }
2045 
2046  e4_assert(nextStat!=1); // this would mean that none of the species contained the field
2047 
2048  {
2049  char *new_content = NULp;
2050  int new_content_len = 0;
2051 
2052  if (nextStat==2) { // all species contain same field content or do not have the field
2053  SpeciesMergeList *sl2 = sml;
2054 
2055  while (sl2) {
2056  gb_field = GB_search(sl2->species, fieldName, GB_FIND);
2057  if (gb_field) {
2058  new_content = GB_read_as_string(gb_field);
2059  new_content_len = strlen(new_content); // @@@ new_content_len never used
2060  break;
2061  }
2062  sl2 = sl2->next;
2063  }
2064  }
2065  else { // different field contents
2066  int currStat;
2067  for (currStat=1; currStat<nextStat; currStat++) {
2068  int names_len = 1; // open bracket
2069  SpeciesMergeList *sl2 = sml;
2070  i = 0;
2071  char *content = NULp;
2072 
2073  while (sl2) {
2074  if (fieldStat[i]==currStat) {
2075  names_len += strlen(sl2->species_name)+1;
2076  if (!content) {
2077  gb_field = GB_search(sl2->species, fieldName, GB_FIND);
2078  e4_assert(gb_field);
2079  content = GB_read_as_string(gb_field);
2080  }
2081  }
2082  sl2 = sl2->next;
2083  i++;
2084  }
2085 
2086  e4_assert(content);
2087  int add_len = names_len+1+strlen(content);
2088  char *whole = ARB_alloc<char>(new_content_len+1+add_len+1);
2089  e4_assert(whole);
2090  char *add = new_content ? whole+sprintf(whole, "%s ", new_content) : whole;
2091  sl2 = sml;
2092  i = 0;
2093  int first = 1;
2094  while (sl2) {
2095  if (fieldStat[i]==currStat) {
2096  add += sprintf(add, "%c%s", first ? '{' : ';', sl2->species_name);
2097  first = 0;
2098  }
2099  sl2 = sl2->next;
2100  i++;
2101  }
2102  add += sprintf(add, "} %s", content);
2103 
2104  free(content);
2105 
2106  freeset(new_content, whole);
2107  new_content_len = strlen(new_content);
2108  }
2109  }
2110 
2111  if (new_content) {
2112  error = GBT_write_string(gb_new_species, fieldName, new_content);
2113  free(new_content);
2114  }
2115  }
2116  }
2117 
2118  // mark field as done:
2119  char *new_doneFields = ARB_alloc<char>(doneLen+fieldLen+1+1);
2120  sprintf(new_doneFields, "%s%s;", doneFields, fieldName);
2121  doneLen += fieldLen+1;
2122  freeset(doneFields, new_doneFields);
2123 
2124  fieldEnd[0] = ';';
2125  }
2126 
2127  fieldEnd[1] = behind;
2128  fieldStart = fieldEnd;
2129  }
2130  free(newFields);
2131  sl = sl->next;
2132  progress.inc_and_check_user_abort(error);
2133  }
2134  free(doneFields);
2135  delete [] fieldStat;
2136  }
2137  freeSpeciesMergeList(sml); sml = NULp;
2138  }
2139  }
2140  else { // copy species or create from consensus (copy fields from one species)
2141  e4_assert(where_we_are==ON_SPECIES);
2142 
2143  ED4_species_name_terminal *spec_name = cursor_terminal->to_sequence_terminal()->corresponding_species_name_terminal();
2144  const char *source_name = spec_name->resolve_pointer_to_char_pntr();
2145  GBDATA *gb_source = GBT_find_species_rel_species_data(gb_species_data, source_name);
2146 
2147  if (gb_source) {
2148  GBDATA *gb_new_species = GB_create_container(gb_species_data, "species");
2149  error = GB_copy_dropProtectMarksAndTempstate(gb_new_species, gb_source);
2150  if (!error) error = GBT_write_string(gb_new_species, "name", new_species_name);
2151  if (!error) error = GBT_write_string(gb_new_species, "full_name", new_species_full_name); // insert new 'full_name'
2152  if (!error && creation_mode==CREATE_FROM_CONSENSUS) {
2153  ED4_group_manager *group_man = cursor_terminal->get_parent(LEV_GROUP)->to_group_manager();
2154  error = createDataFromConsensus(gb_new_species, group_man);
2155  }
2156  }
2157  else {
2158  error = GBS_global_string("Can't find species '%s'", source_name);
2159  }
2160  }
2161  }
2162 
2163  error = GB_end_transaction(gb_main, error);
2164  if (!error) ED4_get_and_jump_to_species(new_species_name);
2165  }
2166  else {
2167  GB_abort_transaction(gb_main);
2168  }
2169 
2170  free(addid);
2171  free(acc);
2172  free(new_species_name);
2173  }
2174 
2175  aw_message_if(error);
2176  free(new_species_full_name);
2177 }
2178 
2180  e4_assert(valid(creation_mode));
2181 
2182  AW_window_simple *aws = new AW_window_simple;
2183  switch (creation_mode) {
2184  case CREATE_NEW_SPECIES: aws->init(root, "create_species", "Create species"); break;
2185  case CREATE_FROM_CONSENSUS: aws->init(root, "create_species_from_consensus", "Create species from consensus"); break;
2186  case COPY_SPECIES: aws->init(root, "copy_species", "Copy current species"); break;
2187  }
2188 
2189  if (creation_mode==CREATE_FROM_CONSENSUS) {
2190  aws->load_xfig("edit4/create_seq_fc.fig");
2191  }
2192  else {
2193  aws->load_xfig("edit4/create_seq.fig");
2194  }
2195 
2196  aws->callback(AW_POPDOWN);
2197  aws->at("close");
2198  aws->create_button("CLOSE", "CLOSE", "C");
2199 
2200  aws->at("label");
2201  aws->create_autosize_button(NULp, "Please enter the FULL_NAME\nof the new species");
2202 
2203  aws->at("input");
2204  aws->create_input_field(ED4_AWAR_SPECIES_TO_CREATE, 30);
2205 
2206  aws->at("ok");
2207  aws->callback(makeWindowCallback(create_new_species, creation_mode));
2208  aws->create_button("GO", "GO", "g");
2209 
2210  if (creation_mode==CREATE_FROM_CONSENSUS) {
2211  aws->at("replace_equal");
2212  aws->label("Replace '=' by ");
2213  aws->create_input_field(ED4_AWAR_CREATE_FROM_CONS_REPL_EQUAL, 1);
2214 
2215  aws->at("replace_point");
2216  aws->label("Replace '.' by ");
2217  aws->create_input_field(ED4_AWAR_CREATE_FROM_CONS_REPL_POINT, 1);
2218 
2219  aws->at("replace_start_end");
2220  aws->label("Create ... at ends of sequence?");
2221  aws->create_toggle(ED4_AWAR_CREATE_FROM_CONS_CREATE_POINTS);
2222 
2223  aws->at("upper");
2224  aws->label("Convert all chars to upper?");
2225  aws->create_toggle(ED4_AWAR_CREATE_FROM_CONS_ALL_UPPER);
2226 
2227  aws->at("data");
2228  aws->label("Other fields");
2229  aws->create_option_menu(ED4_AWAR_CREATE_FROM_CONS_DATA_SOURCE, true);
2230  aws->insert_default_option("Merge from all in group", "", 0);
2231  aws->insert_option("Copy from current species", "", 1);
2232  aws->update_option_menu();
2233  }
2234 
2235  return aws;
2236 }
2237 
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:895
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:1085
ED4_returncode generate_window(AW_device **device, ED4_window **new_window)
Definition: ED4_root.cxx:1319
AW_device * get_device() const
Definition: ed4_class.hxx:766
ED4_selected_list * selected_objects
Definition: ed4_class.hxx:1431
GB_TYPES type
bool is_species_seq_terminal() const
Definition: ed4_class.hxx:1849
AW_device * current_device()
Definition: ed4_class.hxx:1396
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:1444
ED4_EDITMODE
Definition: ed4_defs.hxx:30
int screen_to_sequence(int screen_pos) const
void resize_requested_by_child()
Definition: ed4_class.hxx:2191
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
virtual bool is_hidden() const =0
AW_font_group font_group
Definition: ed4_class.hxx:1464
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
#define ED4_AWAR_COMPRESS_SEQUENCE_GAPS
Definition: ed4_awars.hxx:23
static char * y[maxsp+1]
ED4_window * window() const
Definition: ed4_class.hxx:694
int is_text_terminal() const
Definition: ed4_class.hxx:1077
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:1429
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:2239
void ED4_saveConfiguration(AW_window *aww, bool hide_aww)
ED4_scrolled_rectangle scrolled_rect
Definition: ed4_class.hxx:708
GBDATA * get_species_pointer() const
Definition: ed4_class.hxx:947
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
double width() const
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:2002
void resize_dynamic()
Definition: ed4_class.hxx:961
#define CONSENSUS_CONFIG_COUNTGAPS
int is_columnStat_terminal() const
Definition: ed4_class.hxx:1086
GB_ERROR GB_end_transaction(GBDATA *gbd, GB_ERROR error)
Definition: arbdb.cxx:2549
static ARB_ERROR call_edit(ED4_base *object, const ED4_work_info *work_info)
ED4_area_manager * middle_area_man
Definition: ed4_class.hxx:1428
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)
#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
void win_to_world_coords(AW_pos *xPtr, AW_pos *yPtr) const
Definition: ed4_class.hxx:360
int slider_pos_horizontal
Definition: ed4_class.hxx:706
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:667
static const int TOP_AREA
Definition: ad_config.h:45
long first_position(const char *helixNr) const
Definition: BI_helix.cxx:375
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:1007
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:1108
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:1731
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:643
#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:915
static void ed4_scroll(AW_window *aww, int xdiff, int ydiff, bool use_scroll_speed)
static SpeciesFlags & mutable_instance()
Definition: ed4_flags.hxx:95
ED4_reference_terminals ref_terminals
Definition: ed4_class.hxx:1434
char * protstruct
Definition: ed4_class.hxx:1448
#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:710
int get_screen_pos() const
Definition: ed4_class.hxx:662
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:668
int is_multi_species_manager() const
Definition: ed4_class.hxx:1100
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 has_property(ED4_properties prop) const
Definition: ed4_class.hxx:976
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
void save_current_config(char *confname)
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:1834
ED4_scroll_picture scroll_picture
Definition: ed4_class.hxx:1436
#define ED4_AWAR_CREATE_FROM_CONS_ALL_UPPER
Definition: ed4_awars.hxx:58
char * build_consensus_string(PosRange range) const
Definition: ed4_class.hxx:1652
#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:1446
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:672
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:1445
ED4_window * next
Definition: ed4_class.hxx:705
#define ED4_AWAR_SPECIES_TO_CREATE
Definition: ed4_awars.hxx:206
void ED4_request_relayout()
T * elem() const
Definition: ed4_list.hxx:25
#define CONSENSUS_CONFIG_CONSIDBOUND
long window_upper_clip_point
Definition: ed4_defs.hxx:323
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
void ED4_new_editor_window(AW_window *aww)
long window_lower_clip_point
Definition: ed4_defs.hxx:323
GBDATA * get_gb_main() const
Definition: ed4_class.hxx:1420
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:1460
void ED4_calc_terminal_extentions()
virtual void request_refresh(int clear=1)=0
char * alignment_name
Definition: ed4_class.hxx:1438
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
double height() const
#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:1852
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:1426
int size() const
Definition: ed4_list.hxx:47
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:721
int get_max_width() const
void reset_all_for_new_config()
Definition: ED4_window.cxx:20
AW_window * current_aww()
Definition: ed4_class.hxx:1398
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:1430
int shown_sequence_to_screen(int sequence_pos) const
Definition: ed4_class.hxx:1711
#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:1427
#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:982
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:1736
CONSTEXPR_INLINE bool valid(SpeciesCreationMode m)
Definition: ed4_class.hxx:2246
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:1432
ED4_list_elem * next() const
Definition: ed4_list.hxx:24
GB_alignment_type alignment_type
Definition: ed4_class.hxx:1439
bool nameIsUnique(const char *short_name, GBDATA *gb_species_data)
ED4_extension extension
Definition: ed4_class.hxx:923
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:1586
ED4_sequence_info_terminal * sequence_info()
Definition: ed4_class.hxx:1358
bool is_consensus_terminal() const
Definition: ed4_class.hxx:1847
AW::Rectangle get_window_rect() const
Definition: ed4_class.hxx:480
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:1399
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:1447
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
#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
static void scrollHalfPage(bool backwards, bool horizontal)
ED4_CursorJumpType cursor_jump
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)
void calculate_header_dimensions(AW_device *device, int gc)
Definition: ED4_flags.cxx:153
BI_ecoli_ref * ecoli_ref
Definition: ed4_class.hxx:1437
ED4_window * current_ed4w()
Definition: ed4_class.hxx:1397
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:1423
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:707
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:1357
#define AWAR_EDIT_TERMINAL_SPACING
Definition: ed4_defs.hxx:108
unsigned int hidden
Definition: ed4_class.hxx:926
static void executeKeystroke(AW_event *event, int repeatCount)
void update_requested_by_child()
long window_right_clip_point
Definition: ed4_defs.hxx:323
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
const ED4_remap * remap() const
Definition: ed4_class.hxx:1780
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:1082
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:720
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:704
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:323
cursorpos(ED4_window *win)
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:1820
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:1670
#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:1104
ED4_properties dynamic_prop
Definition: ed4_class.hxx:918
#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:1079
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