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