ARB
ED4_root.cxx
Go to the documentation of this file.
1 // =============================================================== //
2 // //
3 // File : ED4_root.cxx //
4 // Purpose : //
5 // //
6 // Institute of Microbiology (Technical University Munich) //
7 // http://www.arb-home.de/ //
8 // //
9 // =============================================================== //
10 
11 #include "ed4_class.hxx"
12 #include "ed4_awars.hxx"
13 #include "ed4_tools.hxx"
14 #include "ed4_block.hxx"
15 #include "ed4_dots.hxx"
16 #include "ed4_nds.hxx"
17 #include "ed4_list.hxx"
18 #include "ed4_plugins.hxx"
19 #include "ed4_visualizeSAI.hxx"
20 #include "ed4_naligner.hxx"
21 #include "ed4_ProteinViewer.hxx"
23 #include "graph_aligner_gui.hxx"
24 #include "ed4_colStat.hxx"
25 #include "ed4_seq_colors.hxx"
26 #include "ed4_flags.hxx"
27 
28 #include <ed4_extern.hxx>
29 #include <fast_aligner.hxx>
30 
31 #include <AW_helix.hxx>
32 #include <gde.hxx>
33 #include <awt.hxx>
34 #include <awt_map_key.hxx>
35 
36 #include <aw_awars.hxx>
37 #include <aw_preset.hxx>
38 #include <aw_msg.hxx>
39 #include <arb_progress.h>
40 #include <aw_root.hxx>
41 #include <aw_question.hxx>
42 #include <aw_advice.hxx>
43 #include <rootAsWin.h>
44 #include "../WINDOW/aw_status.hxx" // @@@ hack - obsolete when EDIT4 status works like elsewhere
45 
46 #include <arb_version.h>
47 #include <arb_file.h>
48 #include <arb_defs.h>
49 
50 #include <arbdbt.h>
51 #include <ad_cb.h>
52 #include <macros.hxx>
53 #include <st_window.hxx>
54 
55 #include <cctype>
56 #include <map>
57 
59 
61 #if defined(DEBUG)
62  if (dimension<0.0) {
63  // e4_assert(0); // crashes gdb when called from scrollbar callback - so instead only dump backtrace
64  const char *msg = GBS_global_string("illegal dimension %f\n", dimension);
65  GBK_dump_backtrace(stderr, msg);
66  }
67 #endif
68 }
69 
70 void ED4_WinContext::warn_missing_context() const {
71  e4_assert(0);
72  GBK_dump_backtrace(stderr, "Missing context");
73  aw_message("Missing context - please send information from console to devel@arb-home.de");
74 }
75 
77  if (lev == LEV_NONE || (base->spec.level&lev) != 0) {
78  if (base->is_terminal()) base->request_refresh();
79  }
80  return NULp;
81 }
82 
84  main_manager->route_down_hierarchy(makeED4_route_cb(request_terminal_refresh, LEV_NONE)).expect_no_error();
85 }
86 
88  main_manager->route_down_hierarchy(makeED4_route_cb(request_terminal_refresh, lev)).expect_no_error();
89 }
90 
91 
92 static ARB_ERROR request_sequence_refresh(ED4_base *base, bool consensi) {
94  if (base->spec.level & LEV_SPECIES) {
95  if (base->is_consensus_manager() == consensi) {
96  error = base->to_manager()->route_down_hierarchy(makeED4_route_cb(request_terminal_refresh, LEV_SEQUENCE_STRING));
97  }
98  }
99  return error;
100 }
101 
102 // if you want to refresh consensi AND sequences you may use request_refresh_for_specific_terminals(LEV_SEQUENCE_STRING)
104  main_manager->route_down_hierarchy(makeED4_route_cb(request_sequence_refresh, true)).expect_no_error();
105 }
107  if (main_manager) {
108  main_manager->route_down_hierarchy(makeED4_route_cb(request_sequence_refresh, false)).expect_no_error();
109  }
110 }
111 
112 void ED4_root::refresh_window_simple(bool redraw) {
113  // if 'redraw' -> update everything (ignoring refresh flag)
114  bool refresh_all = false;
115  if (redraw) {
116 #if defined(TRACE_REFRESH)
117  fprintf(stderr, "- clear display (refresh_window_simple(redraw=true) called)\n"); fflush(stderr);
118 #endif
119  main_manager->update_info.set_clear_at_refresh(1);
120  refresh_all = true;
121  }
122 
123  main_manager->Show(refresh_all, false);
124  if (redraw) main_manager->update_info.set_clear_at_refresh(0);
125 }
126 
127 void ED4_root::handle_update_requests(bool& redraw) {
128  if (main_manager->update_info.delete_requested) {
129 #if defined(TRACE_REFRESH)
130  fprintf(stderr, "- handling requested deletes\n"); fflush(stderr);
131 #endif
132  main_manager->delete_requested_children();
133  redraw = true;
134  }
135 
136  if (main_manager->update_info.update_requested) {
137 #if defined(TRACE_REFRESH)
138  fprintf(stderr, "- handling requested updates\n"); fflush(stderr);
139 #endif
140  main_manager->update_requested_children();
141  redraw = true; // @@@ needed ?
142  }
143 
144  while (main_manager->update_info.resize) {
145 #if defined(TRACE_REFRESH)
146  fprintf(stderr, "- handling requested resizes\n"); fflush(stderr);
147 #endif
148  main_manager->resize_requested_children();
149  redraw = true;
150  }
151 
152  // make sure all update request have been handled:
153  e4_assert(!main_manager->update_info.delete_requested);
154  e4_assert(!main_manager->update_info.update_requested);
155  e4_assert(!main_manager->update_info.resize);
156 }
157 
158 void ED4_root::special_window_refresh(bool handle_updates) {
159  // this function should only be used for window specific updates (e.g. cursor placement/deletion)
161 
162  bool redraw = true;
163  if (handle_updates) handle_update_requests(redraw);
164  refresh_window_simple(redraw);
165  // do NOT clear_refresh_requests here!! this is no full refresh!
166 }
167 
169  // if 'redraw' -> update everything (ignoring refresh flag)
171 
172  handle_update_requests(redraw);
173 
174  ED4_window *window = first_window;
175  while (window) {
176  ED4_LocalWinContext uses(window);
177  refresh_window_simple(redraw);
178  window = window->next;
179  }
180 
181  if (main_manager->update_info.refresh) main_manager->clear_refresh();
182 
183  if (loadable_SAIs == LSAI_OUTDATED) {
184  GB_touch(GBT_get_SAI_data(GLOBAL_gb_main)); // touch SAI data to force update of SAI selection list
186  }
187 
188  return ED4_R_OK;
189 }
190 
191 // --------------------------------------------------------------------------------
192 
193 #ifdef UNIT_TESTS
194 #ifndef TEST_UNIT_H
195 #include <test_unit.h>
196 #endif
197 
198 static arb_test::match_expectation correct_win2world_calculation(ED4_foldable& foldable, int xwin_org, int ywin_org, int xwrld_expd, int ywrld_expd) {
199  using namespace arb_test;
200  match_expectation precondition(all().of(that(xwrld_expd).is_more_or_equal(xwin_org),
201  that(ywrld_expd).is_more_or_equal(ywin_org)));
202 
203  AW_pos xwrld_calc = xwin_org;
204  AW_pos ywrld_calc = ywin_org;
205  foldable.win_to_world_coords(&xwrld_calc, &ywrld_calc);
206 
207  match_expectation win_2_world_conversion(all().of(that(xwrld_calc).is_equal_to(xwrld_expd),
208  that(ywrld_calc).is_equal_to(ywrld_expd)));
209 
210  AW_pos xwin_back = xwrld_calc;
211  AW_pos ywin_back = ywrld_calc;
212  foldable.world_to_win_coords(&xwin_back, &ywin_back);
213 
214  match_expectation world_back2_win_conversion(all().of(that(xwin_back).is_equal_to(xwin_org),
215  that(ywin_back).is_equal_to(ywin_org)));
216 
217  return all().of(precondition, win_2_world_conversion, world_back2_win_conversion);
218 }
219 
220 static arb_test::match_expectation correct_world2win_calculation(ED4_foldable& foldable, int xwrld_org, int ywrld_org, int xwin_expd, int ywin_expd) {
221  using namespace arb_test;
222  match_expectation precondition(all().of(that(xwrld_org).is_more_or_equal(xwin_expd),
223  that(ywrld_org).is_more_or_equal(ywin_expd)));
224 
225 
226  AW_pos xwin_calc = xwrld_org;
227  AW_pos ywin_calc = ywrld_org;
228  foldable.world_to_win_coords(&xwin_calc, &ywin_calc);
229 
230  match_expectation world_2_win_conversion(all().of(that(xwin_calc).is_equal_to(xwin_expd),
231  that(ywin_calc).is_equal_to(ywin_expd)));
232 
233  return all().of(precondition, world_2_win_conversion);
234 }
235 
236 #define TEST_EXPECT_WIN_UNFOLDED(xwi,ywi) TEST_EXPECTATION(correct_win2world_calculation(foldable, xwi, ywi, xwi, ywi))
237 #define TEST_EXPECT_WIN_WORLD_FOLDING(xwi,ywi,fx,fy) TEST_EXPECTATION(correct_win2world_calculation(foldable, xwi, ywi, (xwi)+(fx), (ywi)+(fy)))
238 #define TEST_EXPECT_WORLD_WIN_FOLDING(xwo,ywo,xwi,ywi) TEST_EXPECTATION(correct_world2win_calculation(foldable, xwo, ywo, xwi, ywi))
239 
240 #define TEST_EXPECT_WIN_WORLD_FOLDING__BROKEN(xwi,ywi,fx,fy) TEST_EXPECTATION__BROKEN(correct_win2world_calculation(foldable, xwi, ywi, (xwi)+(fx), (ywi)+(fy)))
241 #define TEST_EXPECT_WIN_WORLD_FOLDING__BROKENIF(when,xwi,ywi,fx,fy) TEST_EXPECTATION__BROKENIF(when, correct_win2world_calculation(foldable, xwi, ywi, (xwi)+(fx), (ywi)+(fy)))
242 
243 void TEST_win_2_world() {
244  ED4_foldable foldable;
245 
246  const int X1 = 200;
247  const int X2 = 300;
248  const int Y1 = 100;
249  const int Y2 = 200;
250 
251  ED4_folding_line *hor100 = foldable.insert_folding_line(Y1, 0, PROP_HORIZONTAL);
252  ED4_folding_line *ver200 = foldable.insert_folding_line(X1, 0, PROP_VERTICAL);
253  ED4_folding_line *hor200 = foldable.insert_folding_line(Y2, 0, PROP_HORIZONTAL);
254  ED4_folding_line *ver300 = foldable.insert_folding_line(X2, 0, PROP_VERTICAL);
255 
256  // nothing folded yet
257 
258  const int x01 = X1/2;
259  const int x12 = (X1+X2)/2;
260  const int x23 = X2+x01;
261 
262  const int y01 = Y1/2;
263  const int y12 = (Y1+Y2)/2;
264  const int y23 = Y2+y01;
265 
266  TEST_EXPECT_WIN_UNFOLDED(x01, y01);
267  TEST_EXPECT_WIN_UNFOLDED(x12, y01);
268  TEST_EXPECT_WIN_UNFOLDED(x23, y01);
269 
270  TEST_EXPECT_WIN_UNFOLDED(x01, y12);
271  TEST_EXPECT_WIN_UNFOLDED(x12, y12);
272  TEST_EXPECT_WIN_UNFOLDED(x23, y12);
273 
274  TEST_EXPECT_WIN_UNFOLDED(x01, y23);
275  TEST_EXPECT_WIN_UNFOLDED(x12, y23);
276  TEST_EXPECT_WIN_UNFOLDED(x23, y23);
277 
278  for (int FACTOR = 1; FACTOR <= 100; FACTOR += 7) {
279  TEST_ANNOTATE(GBS_global_string("FACTOR=%i", FACTOR));
280  int H1 = FACTOR* 10;
281  int H2 = FACTOR* 40;
282  int V1 = FACTOR* 20;
283  int V2 = FACTOR* 80;
284 
285  hor100->set_dimension(H1);
286  hor200->set_dimension(H2);
287  ver200->set_dimension(V1);
288  ver300->set_dimension(V2);
289 
290  TEST_EXPECT_WIN_UNFOLDED (x01, y01); // always in unfolded range
291  TEST_EXPECT_WIN_WORLD_FOLDING(x12, y01, V1, 0);
292  TEST_EXPECT_WIN_WORLD_FOLDING(x23, y01, V1+V2, 0);
293 
294  TEST_EXPECT_WIN_WORLD_FOLDING(x01, y12, 0, H1);
295  TEST_EXPECT_WIN_WORLD_FOLDING(x12, y12, V1, H1);
296  TEST_EXPECT_WIN_WORLD_FOLDING(x23, y12, V1+V2, H1);
297 
298  TEST_EXPECT_WIN_WORLD_FOLDING(x01, y23, 0, H1+H2);
299  TEST_EXPECT_WIN_WORLD_FOLDING(x12, y23, V1, H1+H2);
300  TEST_EXPECT_WIN_WORLD_FOLDING(x23, y23, V1+V2, H1+H2);
301 
302  // test "folded" world positions.
303  // they result in win positions lower than folding line!
304  TEST_EXPECT_WORLD_WIN_FOLDING(X1-1, Y1-1, X1-1, Y1-1); // left of/above folded range
305  TEST_EXPECT_WORLD_WIN_FOLDING(X1, Y1, X1-V1, Y1-H1); // left/upper end of folded range
306  TEST_EXPECT_WORLD_WIN_FOLDING(X1+5, Y1+5, X1+5-V1, Y1+5-H1); // in folded range
307  TEST_EXPECT_WORLD_WIN_FOLDING(X1+V1, Y1+H1, X1, Y1); // right/lower end of folded range
308  TEST_EXPECT_WORLD_WIN_FOLDING(X1+V1+1, Y1+H1+1, X1+1, Y1+1); // right of/below folded range
309  }
310 }
311 
312 #endif // UNIT_TESTS
313 
314 // --------------------------------------------------------------------------------
315 
318  main_multi_man->deselect_all_species_and_SAI();
319 
320  main_multi_man = top_area_man->get_multi_species_manager();
321  main_multi_man->deselect_all_species_and_SAI();
322 
324 
325  return ED4_R_OK;
326 }
327 
328 void ED4_root::remove_from_selected(ED4_species_name_terminal *name_term) { // @@@ change param to ED4_species_manager ?
329  if (name_term) {
330  if ((selected_objects->has_elem(name_term->selection_info))) {
331  selected_objects->remove_elem(name_term->selection_info);
332 
333  delete name_term->selection_info;
334  name_term->selection_info = NULp;
335  name_term->containing_species_manager()->set_selected(false);
336  name_term->dragged = false; // @@@ caller shall do this
337 
338 #ifdef DEBUG
339  GBDATA *gbd = name_term->get_species_pointer();
340 
341  if (gbd) {
342  GB_transaction ta(gbd);
343  printf("removed term '%s'\n", GB_read_char_pntr(gbd));
344  }
345  else {
346  ED4_species_manager *spec_man = name_term->get_parent(LEV_SPECIES)->to_species_manager();
347 
348  if (spec_man->is_consensus_manager()) {
349  printf("removed consensus '%s'\n", name_term->id);
350  }
351  else {
352  printf("removed unknown term '%s'\n", name_term->id ? name_term->id : "NULp");
353  }
354  }
355 #endif
356 
357  name_term->request_refresh();
358  ED4_sequence_terminal *seq_term = name_term->corresponding_sequence_terminal();
359  if (seq_term) seq_term->request_refresh();
360 
361  // ProtView: Refresh corresponding orf terminals
362  if (alignment_type == GB_AT_DNA) {
364  }
365 
366  ED4_multi_species_manager *multi_man = name_term->get_parent(LEV_MULTI_SPECIES)->to_multi_species_manager();
367  multi_man->invalidate_species_counters();
368  }
369  }
370 }
371 
373  for (ED4_window *win = first_window; win; win = win->next) {
374  if (win->aww == aww) {
375  most_recently_used_window = win;
376  }
377  }
378 }
379 
380 ED4_returncode ED4_root::add_to_selected(ED4_species_name_terminal *name_term) { // @@@ change param to ED4_species_manager ?
381  if (!name_term || !name_term->has_property(PROP_SELECTABLE)) { // check if object exists and may be selected
382  return ED4_R_IMPOSSIBLE;
383  }
384 
385  if (!(selected_objects->has_elem(name_term->selection_info))) { // object is really new to our list => calculate current extension and append it
387  name_term->selection_info = sel_info;
388 
389  if (name_term->has_property(PROP_IS_HANDLE)) { // object is a handle for an object up in the hierarchy => search it
390  ED4_level mlevel = name_term->spec.handled_level;
391  ED4_base *tmp_object = name_term;
392 
393  while (tmp_object && !(tmp_object->spec.level & mlevel)) {
394  tmp_object = tmp_object->parent;
395  }
396 
397  if (!tmp_object) return ED4_R_WARNING; // no target level found
398 
399  sel_info->actual_width = tmp_object->extension.size[WIDTH];
400  sel_info->actual_height = tmp_object->extension.size[HEIGHT];
401  }
402  else { // selected object is no handle => take it directly
403  sel_info->actual_width = name_term->extension.size[WIDTH];
404  sel_info->actual_height = name_term->extension.size[HEIGHT];
405  }
406 
407  sel_info->drag_old_x = 0;
408  sel_info->drag_old_y = 0;
409  sel_info->drag_off_x = 0;
410  sel_info->drag_off_y = 0;
411  sel_info->old_event_y = 0;
412 
413  sel_info->object = name_term;
414 
415  selected_objects->prepend_elem(sel_info);
416 
417  name_term->containing_species_manager()->set_selected(true);
418 
419 #ifdef DEBUG
420  GBDATA *gbd = name_term->get_species_pointer();
421 
422  if (gbd) {
423  printf("added term '%s'\n", GB_read_char_pntr(gbd));
424  }
425  else {
426  ED4_species_manager *spec_man = name_term->get_parent(LEV_SPECIES)->to_species_manager();
427  if (spec_man->is_consensus_manager()) {
428  printf("added consensus '%s'\n", name_term->id);
429  }
430  else {
431  printf("added unknown term '%s'\n", name_term->id ? name_term->id : "NULp");
432  }
433  }
434 #endif
435 
436  name_term->request_refresh();
437  ED4_sequence_terminal *seq_term = name_term->corresponding_sequence_terminal();
438  if (seq_term) seq_term->request_refresh();
439 
440  // ProtView: Refresh corresponding orf terminals
441  if (alignment_type == GB_AT_DNA) {
443  }
444 
445  ED4_multi_species_manager *multi_man = name_term->get_parent(LEV_MULTI_SPECIES)->to_multi_species_manager();
446  multi_man->invalidate_species_counters();
447 
448  return ED4_R_OK;
449  }
450 
451  return ED4_R_IMPOSSIBLE;
452 }
453 
455  while (main_manager->update_info.resize) {
456  main_manager->resize_requested_children();
457  }
458 }
459 
460 static ARB_ERROR change_char_table_length(ED4_base *base, int new_length) {
461  if (base->is_abstract_group_manager()) {
462  ED4_abstract_group_manager *group_man = base->to_abstract_group_manager();
463  group_man->table().change_table_length(new_length);
464  }
465  return NULp;
466 }
467 
468 void ED4_alignment_length_changed(GBDATA *gb_alignment_len, GB_CB_TYPE IF_ASSERTION_USED(gbtype)) { // callback from database
469  e4_assert(gbtype==GB_CB_CHANGED);
470  int new_length = GB_read_int(gb_alignment_len);
471 
472 #if defined(DEBUG) && 1
473  printf("alignment_length_changed from %i to %i\n", MAXSEQUENCECHARACTERLENGTH, new_length);
474 #endif
475 
476  if (MAXSEQUENCECHARACTERLENGTH!=new_length) { // otherwise we already did this (i.e. we were called by changed_by_database)
477  bool was_increased = new_length>MAXSEQUENCECHARACTERLENGTH;
478 
479  MAXSEQUENCECHARACTERLENGTH = new_length;
480 
481  {
482  const char *err = ED4_ROOT->helix->init(GLOBAL_gb_main); // reload helix
483  aw_message_if(err);
484  }
485  {
486  const char *err = ED4_ROOT->ecoli_ref->init(GLOBAL_gb_main); // reload ecoli
487  aw_message_if(err);
488  }
489 
490  if (ED4_ROOT->alignment_type == GB_AT_AA) {
491  // TODO: is this needed here?
492  const char *err = ED4_pfold_set_SAI(&ED4_ROOT->protstruct, GLOBAL_gb_main, ED4_ROOT->alignment_name, &ED4_ROOT->protstruct_len); // reload protstruct
493  aw_message_if(err);
494  }
495 
496  if (was_increased) {
497  ED4_ROOT->main_manager->route_down_hierarchy(makeED4_route_cb(change_char_table_length, new_length)).expect_no_error();
499  }
500  }
501 }
502 
505 
509  return GBS_global_string("You have to select a valid alignment before you can start ARB_EDIT4\n(%s)", GB_await_error());
510  }
511 
513  if (!gb_alignment) {
514  return GBS_global_string("You can't edit without an existing alignment\n(%s)", GB_await_error());
515  }
516 
517  GBDATA *gb_alignment_len = GB_search(gb_alignment, "alignment_len", GB_FIND);
518  int alignment_length = GB_read_int(gb_alignment_len);
519  MAXSEQUENCECHARACTERLENGTH = alignment_length;
520 
521  GB_add_callback(gb_alignment_len, GB_CB_CHANGED, makeDatabaseCallback(ED4_alignment_length_changed));
522 
524 
525  return NULp;
526 }
527 
529  int font_GC[] = {
533  };
534 
536  for (unsigned i = 0; i<ARRAY_ELEMS(font_GC); ++i) {
537  ED4_MostRecentWinContext context;
538  font_group.registerFont(current_device(), font_GC[i]);
539  }
540 }
541 
543  if (base->is_multi_species_manager()) {
544  base->to_multi_species_manager()->update_requested_by_child();
545  }
546  return NULp;
547 }
548 
549 ED4_returncode ED4_root::create_hierarchy(const char *area_string_middle, const char *area_string_top) {
550  // creates internal hierarchy of editor
551 
552  long total_no_of_groups = 0;
553  long total_no_of_species = 0;
554  {
555  // count species and related info (e.g. helix) displayed in the top region (a == 0)
556  // count no of species and sais including groups in middle region (a == 1)
557 
558  const char *area_string[2] = { area_string_top, area_string_middle };
559  for (int a = 0; a<2; ++a) {
560  long group_count;
561  long species_count;
562  database->calc_no_of_all(area_string[a], &group_count, &species_count);
563 
564  total_no_of_groups += group_count;
565  total_no_of_species += species_count;
566  }
567  }
568 
569  SmartPtr<arb_progress> startup_progress = new arb_progress("EDIT4 startup");
570 
572 
573  ecoli_ref = new BI_ecoli_ref;
575 
576  // [former position of ali-init-code]
577 
578  main_manager = new ED4_main_manager("Main_Manager", 0, 0, NULp); // build a test hierarchy
579  root_group_man = new ED4_root_group_manager("Root_Group_Manager", 0, 0, main_manager);
580 
581  main_manager->append_member(root_group_man);
582 
583  ED4_device_manager *device_manager = new ED4_device_manager("Device_Manager", 0, 0, root_group_man);
584  root_group_man->append_member(device_manager);
585 
586  {
587  int col_stat_term_height = 50; // @@@ Hoehe des ColumnStatistics Terminals ausrechnen
588 
590  new ED4_sequence_info_terminal("Reference_Sequence_Info_Terminal", MAXINFO_WIDTH, TERMINAL_HEIGHT, NULp),
591  new ED4_sequence_terminal ("Reference_Sequence_Terminal", 300, TERMINAL_HEIGHT, NULp, false),
592  new ED4_sequence_info_terminal("Reference_ColumnStatistics_Info_Terminal", MAXINFO_WIDTH, col_stat_term_height, NULp),
593  new ED4_columnStat_terminal ("Reference_ColumnStatistics_Terminal", 300, col_stat_term_height, NULp)
594  );
595  }
596 
597  {
598  arb_progress species_progress("Loading species", total_no_of_species);
599 
600  // ********** Top Area beginning **********
601 
602  ED4_multi_species_manager *top_multi_species_manager;
603  ED4_spacer_terminal *top_spacer_terminal;
604  ED4_spacer_terminal *top_mid_spacer_terminal;
605  ED4_spacer_terminal *top_multi_spacer_terminal_beg;
606  ED4_line_terminal *top_mid_line_terminal;
607  {
608  ED4_area_manager *top_area_manager = new ED4_area_manager("Top_Area_Manager", 0, 0, device_manager);
609  device_manager->append_member(top_area_manager);
610  top_area_man = top_area_manager;
611 
612  top_spacer_terminal = new ED4_spacer_terminal("Top_Spacer", false, 100, 10, top_area_manager);
613  top_area_manager->append_member(top_spacer_terminal);
614 
615  top_multi_species_manager = new ED4_multi_species_manager("Top_MultiSpecies_Manager", 0, 0, top_area_manager);
616  top_area_manager->append_member(top_multi_species_manager);
617 
618  top_multi_spacer_terminal_beg = new ED4_spacer_terminal("Top_Left_Spacer", false, 0, 3, top_multi_species_manager);
619  top_multi_species_manager->append_member(top_multi_spacer_terminal_beg);
620 
622 
623  int index = 0;
624  database->scan_string(top_multi_species_manager, ref_terminals, area_string_top, &index, species_progress);
626 
627  const int TOP_MID_LINE_HEIGHT = 3;
628  int TOP_MID_SPACER_HEIGHT = font_group.get_max_height()-TOP_MID_LINE_HEIGHT;
629 
630  top_mid_line_terminal = new ED4_line_terminal("Top_Mid_Line_Terminal", 0, TOP_MID_LINE_HEIGHT, device_manager); // width will be set below
631  device_manager->append_member(top_mid_line_terminal);
632 
633  top_mid_spacer_terminal = new ED4_spacer_terminal("Top_Middle_Spacer", true, 880, TOP_MID_SPACER_HEIGHT, device_manager);
634  device_manager->append_member(top_mid_spacer_terminal);
635 
636  // needed to avoid text-clipping problems:
637  main_manager->set_top_middle_spacer_terminal(top_mid_spacer_terminal);
638  main_manager->set_top_middle_line_terminal(top_mid_line_terminal);
639  }
640 
641  // ********** Middle Area beginning **********
642 
643  ED4_area_manager *middle_area_manager;
644  ED4_tree_terminal *tree_terminal;
645  ED4_multi_species_manager *mid_multi_species_manager;
646  ED4_spacer_terminal *mid_multi_spacer_terminal_beg;
647  ED4_line_terminal *mid_bot_line_terminal;
648  ED4_spacer_terminal *total_bottom_spacer;
649  {
650  middle_area_manager = new ED4_area_manager("Middle_Area_Manager", 0, 0, device_manager);
651  device_manager->append_member(middle_area_manager);
652  middle_area_man = middle_area_manager;
653 
654  tree_terminal = new ED4_tree_terminal("Tree", 2, 0, middle_area_manager);
655  middle_area_manager->append_member(tree_terminal);
656 
657  mid_multi_species_manager = new ED4_multi_species_manager("Middle_MultiSpecies_Manager", 0, 0, middle_area_manager);
658  middle_area_manager->append_member(mid_multi_species_manager);
659 
660  mid_multi_spacer_terminal_beg = new ED4_spacer_terminal("Mid_Multi_Spacer_Terminal_Beg", false, 0, 3, mid_multi_species_manager);
661  mid_multi_species_manager->append_member(mid_multi_spacer_terminal_beg);
662 
663  scroll_links.link_for_ver_slider = middle_area_manager;
664 
665  {
667  int index = 0;
668  database->scan_string(mid_multi_species_manager, ref_terminals, area_string_middle, &index, species_progress);
669  }
670 
671  {
672  ED4_spacer_terminal *mid_bot_spacer_terminal = new ED4_spacer_terminal("Middle_Bot_Spacer_Terminal", false, 880, 10, device_manager);
673  device_manager->append_member(mid_bot_spacer_terminal);
674  }
675 
676  mid_bot_line_terminal = new ED4_line_terminal("Mid_Bot_Line_Terminal", 0, 3, device_manager); // width will be set below
677  device_manager->append_member(mid_bot_line_terminal);
678 
679  total_bottom_spacer = new ED4_spacer_terminal("Total_Bottom_Spacer_terminal", false, 0, 10000, device_manager);
680  total_bottom_spacer->clr_property(PROP_DYNA_RESIZE);
681  device_manager->append_member(total_bottom_spacer);
682  }
683 
685  const long ext_width = long(scroll_links.link_for_hor_slider->extension.size[WIDTH]);
686  const long spacer_width = ext_width + MAXNAME_WIDTH + SEQUENCE_INFO_WIDTH;
687  const long line_width = spacer_width + TREE_TERMINAL_WIDTH;
688 
689  top_multi_spacer_terminal_beg->extension.size[WIDTH] = spacer_width;
690  mid_multi_spacer_terminal_beg->extension.size[WIDTH] = spacer_width;
691  total_bottom_spacer->extension.size[WIDTH] = spacer_width;
692 
693  top_mid_line_terminal->extension.size[WIDTH] = line_width;
694  mid_bot_line_terminal->extension.size[WIDTH] = line_width;
695 
696  }
697 
698  tree_terminal->set_links(NULp, mid_multi_species_manager); // set links
699  top_spacer_terminal->set_links(tree_terminal, top_multi_species_manager);
700  top_mid_spacer_terminal->set_links(middle_area_manager, NULp);
701  total_bottom_spacer->set_links(mid_bot_line_terminal, NULp);
702 
703  species_progress.done();
704  }
705 
708 
709  main_manager->route_down_hierarchy(makeED4_route_cb(force_group_update)).expect_no_error();
710 
711  if (!scroll_links.link_for_hor_slider) { // happens when no species AND no SAI has data
712  startup_progress->done();
713  startup_progress.setNull(); // make progress disappear (otherwise prompter below is often behind progress window)
715 
716  aw_popup_ok(GBS_global_string("No species/SAI contains data in '%s'\nARB_EDIT4 will terminate", alignment_name));
717  ED4_exit();
718  }
719 
720  // build consensi
721  {
722  arb_progress consensi_progress("Initializing consensi", total_no_of_species+total_no_of_groups+1); // 1 is root_group_man
723 
724  root_group_man->create_consensus(root_group_man, &consensi_progress);
726  consensi_progress.done(); // if there is a "top"-group, progress increment is one to low
727  }
728 
731 
732  // calc size and display:
733 
735 
737 
738  {
741  ED4_base *width_link = x_link;
742  ED4_base *height_link = y_link;
743 
745  while (win) {
746  win->set_scrolled_rectangle(x_link, y_link, width_link, height_link);
747  win->aww->show();
749  win = win->next;
750  }
751  }
752 
755 
756 #if defined(DEBUG) && 0
757  // dump created hierarchy:
758  puts("---------------------------------------- [main_manager dump start]");
759  main_manager->dump(1);
760  puts("---------------------------------------- [main_manager dump end]");
761 #endif
762 
763  return ED4_R_OK;
764 }
765 
767  // returns win-coordinates of area (defined by folding lines) which contains position x/y
768  int x1, x2, y1, y2;
769  const AW_screen_area& area_rect = current_device()->get_area_size();
770 
771  x1 = area_rect.l;
772  for (const ED4_folding_line *flv=current_ed4w()->get_vertical_folding(); ; flv = flv->get_next()) {
773  if (flv) {
774  x2 = int(flv->get_pos()); // @@@ use AW_INT ?
775  }
776  else {
777  x2 = area_rect.r;
778  if (x1==x2) {
779  break;
780  }
781  }
782 
783  y1 = area_rect.t;
784  for (const ED4_folding_line *flh=current_ed4w()->get_horizontal_folding(); ; flh = flh->get_next()) {
785  if (flh) {
786  y2 = int(flh->get_pos()); // @@@ use AW_INT ?
787  }
788  else {
789  y2 = area_rect.b;
790  if (y1==y2) {
791  break;
792  }
793  }
794 
795  if (x1<=x && x<=x2 && y1<=y && y<=y2) {
796  rect->t = y1;
797  rect->b = y2;
798  rect->l = x1;
799  rect->r = x2;
800  return ED4_R_OK;
801  }
802  y1 = y2;
803  if (!flh) break;
804  }
805  x1 = x2;
806  if (!flv) break;
807  }
808  return ED4_R_IMPOSSIBLE; // no area contains x/y :-(
809 }
810 
812  destination->slider_pos_horizontal = source->slider_pos_horizontal;
813  destination->slider_pos_vertical = source->slider_pos_vertical;
814  destination->coords = source->coords;
815 }
816 
817 
818 static void reload_helix_cb() {
819  const char *err = ED4_ROOT->helix->init(GLOBAL_gb_main);
820  if (err) aw_message(err);
822 }
823 
824 
825 static void reload_ecoli_cb() {
826  const char *err = ED4_ROOT->ecoli_ref->init(GLOBAL_gb_main);
827  if (err) aw_message(err);
829 }
830 
831 // ---------------------------------------
832 // recursion through all species
833 
834 DECLARE_CBTYPE_FVV_AND_BUILDERS(ED4_Species_Callback, ARB_ERROR, GBDATA *); // generates makeED4_Species_Callback
835 
836 static ARB_ERROR do_sth_with_species(ED4_base *base, const ED4_Species_Callback *cb) {
837  ARB_ERROR error = NULp;
838 
839  if (base->is_species_manager()) {
840  ED4_species_manager *species_manager = base->to_species_manager();
841  ED4_species_name_terminal *species_name_terminal = species_manager->search_spec_child_rek(LEV_SPECIES_NAME)->to_species_name_terminal();
842 
843  if (species_name_terminal->get_species_pointer()) {
844  char *species_name = GB_read_as_string(species_name_terminal->get_species_pointer());
845 
846  e4_assert(species_name);
847  GBDATA *species = GBT_find_species(GLOBAL_gb_main, species_name);
848 
849  error = species
850  ? (*cb)(species)
851  : GB_append_exportedError(GBS_global_string("can't find species '%s'", species_name));
852 
853  free(species_name);
854  }
855  }
856 
857  return error;
858 }
859 
860 
861 static ARB_ERROR ED4_with_all_loaded_species(const ED4_Species_Callback& cb) {
862  return ED4_ROOT->root_group_man->route_down_hierarchy(makeED4_route_cb(do_sth_with_species, &cb));
863 }
864 
865 static bool is_named(ED4_base *base, const char *wanted_name) {
866  ED4_species_name_terminal *name_term = base->to_species_name_terminal();
867  GBDATA *gbd = name_term->get_species_pointer();
868  if (gbd) {
869  const char *name = GB_read_char_pntr(gbd);
870  e4_assert(name);
871 
872  return strcmp(name, wanted_name) == 0;
873  }
874  return false;
875 }
876 
877 static bool is_species_named(ED4_base *base, const char *species_name) {
878  return base->inside_species_seq_manager() && is_named(base, species_name);
879 }
880 
881 static bool is_SAI_named(ED4_base *base, const char *sai_name) {
882  return base->inside_SAI_manager() && is_named(base, sai_name);
883 }
884 
885 ED4_species_name_terminal *ED4_find_species_or_SAI_name_terminal(const char *species_name) {
886  ED4_base *base = ED4_ROOT->root_group_man->find_first_that(LEV_SPECIES_NAME, makeED4_basePredicate(is_species_named, species_name));
887  return base ? base->to_species_name_terminal() : NULp;
888 }
889 ED4_species_name_terminal *ED4_find_species_name_terminal(const char *species_name) {
890  ED4_base *base = ED4_ROOT->root_group_man->find_first_that(LEV_SPECIES_NAME, makeED4_basePredicate(is_species_named, species_name));
891  return base ? base->to_species_name_terminal() : NULp;
892 }
893 ED4_species_name_terminal *ED4_find_SAI_name_terminal(const char *sai_name) {
894  ED4_base *base = ED4_ROOT->root_group_man->find_first_that(LEV_SPECIES_NAME, makeED4_basePredicate(is_SAI_named, sai_name));
895  return base ? base->to_species_name_terminal() : NULp;
896 }
897 
898 static char *get_group_consensus(const char *species_name, PosRange range) {
899  ED4_species_name_terminal *name_term = ED4_find_species_name_terminal(species_name);
900  char *consensus = NULp;
901 
902  if (name_term) {
903  ED4_abstract_group_manager *group_man = name_term->get_parent(ED4_level(LEV_GROUP|LEV_ROOTGROUP))->to_abstract_group_manager();
904  if (group_man) {
905  consensus = group_man->build_consensus_string(range);
906  }
907  }
908 
909  return consensus;
910 }
911 
912 static bool get_selected_range(PosRange& range) {
914  if (listElem) {
915  ED4_sequence_terminal *seqTerm = listElem->elem()->object->corresponding_sequence_terminal();
916  return ED4_get_selected_range(seqTerm, range);
917  }
918  return false;
919 }
920 
922 
924  if (!curr_aligner_elem) return NULp;
925 
926  ED4_species_manager *specMan = curr_aligner_elem->elem()->object->containing_species_manager();
927  curr_aligner_elem = curr_aligner_elem->next();
928  return specMan->get_species_pointer();
929 }
930 
931 static GBDATA *get_first_selected_species(int *total_no_of_selected_species) {
932  int selected = ED4_ROOT->selected_objects->size();
933 
934  if (total_no_of_selected_species) {
935  *total_no_of_selected_species = selected;
936  }
937 
938  if (selected) {
939  curr_aligner_elem = ED4_ROOT->selected_objects->head();
940  }
941  else {
942  curr_aligner_elem = NULp;
943  }
944 
945  return get_next_selected_species();
946 }
947 
949  return FastAligner_delete_temp_entries(species, alignment_name);
950 }
951 
954  if (!error) error = ED4_with_all_loaded_species(makeED4_Species_Callback(ED4_delete_temp_entries, ED4_ROOT->alignment_name));
956 }
957 
958 static void toggle_helix_for_SAI(AW_window *aww) {
959  ED4_LocalWinContext uses(aww);
960  ED4_cursor *cursor = &current_cursor();
961 
962  if (cursor->in_SAI_terminal()) {
963  ED4_sequence_terminal *sai_term = cursor->owner_of_cursor->to_sequence_terminal();
964  ED4_sequence_info_terminal *sai_info_term = sai_term->parent->search_spec_child_rek(LEV_SEQUENCE_INFO)->to_sequence_info_terminal();
965 
966  GBDATA *gb_sai_data = sai_info_term->data();
967  GB_transaction ta(gb_sai_data);
968 
969  GBDATA *gb_sai = GB_get_grandfather(gb_sai_data);
970  GBDATA *gb_disp_sec = GB_searchOrCreate_int(gb_sai, "showsec", 0);
971 
972  bool show_sec = 1-bool(GB_read_int(gb_disp_sec));
973  GB_ERROR error = GB_write_int(gb_disp_sec, show_sec);
974  if (!error) {
975  sai_term->set_secstruct_display(show_sec);
976  sai_term->request_refresh();
977  }
978  if (error) aw_message(error);
979  }
980  else {
981  aw_message("Please select an SAI");
982  }
983 }
984 
985 static void title_mode_changed(AW_root *aw_root, AW_window *aww) {
986  int title_mode = aw_root->awar(AWAR_EDIT_TITLE_MODE)->read_int();
987 
988  if (title_mode==0) {
989  aww->set_info_area_height(57);
990  }
991  else {
992  aww->set_info_area_height(170);
993  }
994 }
995 
996 static void ED4_undo_redo(AW_window *aww, GB_UNDO_TYPE undo_type) {
997  ED4_LocalWinContext uses(aww);
998  GB_ERROR error = GB_undo(GLOBAL_gb_main, undo_type);
999 
1000  if (error) {
1001  aw_message(error);
1002  }
1003  else {
1006  ED4_cursor *cursor = &current_cursor();
1007  if (cursor->owner_of_cursor) cursor->owner_of_cursor->request_refresh();
1008  }
1009 }
1010 
1012  AW_window_simple *aws = new AW_window_simple;
1013 
1014  aws->init(root, "ZOOM_ERR_MSG", "Errors and warnings");
1015  aws->load_xfig("edit4/message.fig");
1016 
1017  aws->callback(AW_POPDOWN);
1018  aws->at("hide");
1019  aws->create_button("HIDE", "HIDE");
1020 
1021  aws->callback(aw_clear_message_cb);
1022  aws->at("clear");
1023  aws->create_button("CLEAR", "CLEAR");
1024 
1025  aws->at("errortext");
1026  aws->create_text_field(AWAR_ERROR_MESSAGES);
1027 
1028  return aws;
1029 }
1030 
1031 
1032 static char *cat(char *toBuf, const char *s1, const char *s2) {
1033  char *buf = toBuf;
1034 
1035  while ((*buf++=*s1++)!=0) ;
1036  buf--;
1037  while ((*buf++=*s2++)!=0) ;
1038 
1039  return toBuf;
1040 }
1041 
1043  const char *label_prefix, const char *macro_prefix,
1044  const char *pattern_awar_name, const char *show_awar_name,
1045  int short_form, ED4_SearchPositionType type, ED4_window *ed4w)
1046 {
1047  char buf[200];
1048 
1049  if (!short_form) {
1050  awmm->at(cat(buf, label_prefix, "search"));
1051  awmm->create_input_field(pattern_awar_name, 30);
1052  }
1053 
1054  awmm->at(cat(buf, label_prefix, "n"));
1055  awmm->help_text("e4_search.hlp");
1056  awmm->callback(makeWindowCallback(ED4_search_cb, ED4_encodeSearchDescriptor(+1, type), ed4w));
1057  awmm->create_button(cat(buf, macro_prefix, "_SEARCH_NEXT"), "#edit/next.xpm");
1058 
1059  awmm->at(cat(buf, label_prefix, "l"));
1060  awmm->help_text("e4_search.hlp");
1061  awmm->callback(makeWindowCallback(ED4_search_cb, ED4_encodeSearchDescriptor(-1, type), ed4w));
1062  awmm->create_button(cat(buf, macro_prefix, "_SEARCH_LAST"), "#edit/last.xpm");
1063 
1064  awmm->at(cat(buf, label_prefix, "d"));
1065  awmm->help_text("e4_search.hlp");
1066  awmm->callback(makeWindowCallback(ED4_popup_search_window, type));
1067  awmm->create_button(cat(buf, macro_prefix, "_SEARCH_DETAIL"), "#edit/detail.xpm");
1068 
1069  awmm->at(cat(buf, label_prefix, "s"));
1070  awmm->create_toggle(show_awar_name);
1071 }
1072 
1073 static void ED4_set_protection(AW_window *aww, int wanted_protection) {
1074  ED4_LocalWinContext uses(aww);
1075  ED4_cursor *cursor = &current_cursor();
1076  GB_ERROR error = NULp;
1077 
1078  if (cursor->owner_of_cursor) {
1079  ED4_sequence_terminal *seq_term = cursor->owner_of_cursor->to_sequence_terminal();
1080  ED4_sequence_info_terminal *seq_info_term = seq_term->parent->search_spec_child_rek(LEV_SEQUENCE_INFO)->to_sequence_info_terminal();
1081  GBDATA *gbd = seq_info_term->data();
1082 
1083  GB_transaction ta(gbd);
1084  GB_topSecurityLevel unsecured(gbd);
1085 
1086  error = GB_write_security_write(gbd, wanted_protection);
1087  error = ta.close(error);
1088  }
1089  else {
1090  error = "No species selected";
1091  }
1092 
1093  if (error) aw_message(error);
1094 }
1095 
1096 enum MenuSelectType { // @@@ rename -> MenuHighlightType
1107 };
1108 
1109 static void ED4_menu_highlight(AW_window *aww, MenuSelectType select) { // @@@ rename select -> hilight
1112 
1113  e4_assert(middle_multi_man);
1114 
1115  switch (select) {
1116  case ED4_MS_NONE: {
1119  }
1120  break;
1121  }
1122  case ED4_MS_ALL: {
1123  middle_multi_man->select_all(true); // only species
1125  break;
1126  }
1127  case ED4_MS_INVERT: {
1128  middle_multi_man->invert_selection_of_all_species();
1130  break;
1131  }
1132  case ED4_MS_SELECT_MARKED: {
1133  middle_multi_man->marked_species_select(true);
1135  break;
1136  }
1137  case ED4_MS_DESELECT_MARKED: {
1138  middle_multi_man->marked_species_select(false);
1140  break;
1141  }
1142  case ED4_MS_UNMARK_ALL: {
1144  break;
1145  }
1146  case ED4_MS_MARK_SELECTED: {
1147  middle_multi_man->selected_species_mark(true);
1149  break;
1150  }
1151  case ED4_MS_UNMARK_SELECTED: {
1152  middle_multi_man->selected_species_mark(false);
1154  break;
1155  }
1156  case ED4_MS_INVERT_GROUP: {
1158  int done = 0;
1159 
1160  if (cursor->owner_of_cursor) {
1161  ED4_multi_species_manager *multi_man = cursor->owner_of_cursor->get_parent(LEV_MULTI_SPECIES)->to_multi_species_manager();
1162 
1163  multi_man->invert_selection_of_all_species();
1165  done = 1;
1166  }
1167 
1168  if (!done) {
1169  aw_message("Place cursor into group");
1170  }
1171  break;
1172  }
1173  case ED4_MS_TOGGLE_BLOCKTYPE: {
1175  break;
1176  }
1177  default: {
1178  e4_assert(0);
1179  break;
1180  }
1181  }
1182 
1184 }
1185 
1188 }
1189 
1190 static void modes_cb(AW_window*, ED4_species_mode smode) {
1191  ED4_ROOT->species_mode = smode;
1192  for (ED4_window *win = ED4_ROOT->first_window; win; win = win->next) {
1193  win->aww->select_mode(smode);
1194  }
1195  if (smode == ED4_SM_INFO) {
1196  AWT_trigger_remote_action(NULp, GLOBAL_gb_main, "ARB_NT:species_info");
1197  }
1198 }
1199 
1201  if (ED4_ROOT->species_mode == ED4_SM_KILL) {
1203  }
1204 }
1205 
1206 static char *get_helix_string(GBDATA *gb_main, const char *alignment_name) {
1207  GB_transaction ta(gb_main);
1208 
1209  char *helix_string = NULp;
1210  char *helix_name = GBT_get_default_helix(gb_main);
1211  GBDATA *gb_helix_con = GBT_find_SAI(gb_main, helix_name);
1212  if (gb_helix_con) {
1213  GBDATA *gb_helix = GBT_find_sequence(gb_helix_con, alignment_name);
1214  if (gb_helix) helix_string = GB_read_string(gb_helix);
1215  }
1216  free(helix_name);
1217 
1218  return helix_string;
1219 }
1220 
1222  static SmartPtr<AlignDataAccess> aliDataAccess;
1223 
1224  if (aliDataAccess.isNull()) {
1225  aliDataAccess = new AlignDataAccess(GLOBAL_gb_main,
1227  true, ED4_trigger_instant_refresh, // perform refresh
1228  get_group_consensus, // aligner fetches consensus of group of species via this function
1229  get_selected_range, // aligner fetches column range of selection via this function
1230  get_first_selected_species, // aligner fetches first and..
1231  get_next_selected_species, // .. following selected species via these functions
1232  get_helix_string); // used by island_hopping (if configured to use sec-structure)
1233  }
1234 
1235  return aliDataAccess.content();
1236 }
1237 
1239 #if defined(DEBUG)
1240  static const AlignDataAccess *last_data_access = NULp;
1241 
1242  e4_assert(!last_data_access || (last_data_access == data_access)); // there shall be only one AlignDataAccess
1243  last_data_access = data_access;
1244 #endif
1245 
1246  static AW_window *aws = NULp;
1247  if (!aws) aws = FastAligner_create_window(awr, data_access);
1248  return aws;
1249 }
1250 
1251 static void ED4_save_properties(AW_window *aw, int mode) {
1253 }
1254 
1256  typedef std::map<AW_gc_manager*, AW_window*> gcwin;
1257  static gcwin win;
1258 
1259  gcwin::iterator found = win.find(gcman);
1260 
1261  AW_window *aww = NULp;
1262  if (found == win.end()) {
1263  aww = AW_create_gc_window(awp->get_root(), gcman);
1264  win[gcman] = aww;
1265  }
1266  else {
1267  aww = win[gcman];
1268  }
1269  aww->activate();
1270 }
1271 
1272 static void gc_change_cb(GcChange whatChanged) {
1273  if (whatChanged == GC_FONT_CHANGED) {
1275  }
1277 }
1278 
1280  {
1281  ED4_window *ed4w = first_window;
1282 
1283  while (ed4w) { // before creating a window look for a hidden window
1284  if (ed4w->is_hidden) {
1285  ed4w->aww->show();
1286  ed4w->is_hidden = false;
1287  return ED4_R_BREAK;
1288  }
1289  ed4w = ed4w->next;
1290  }
1291  }
1292 
1293  if (ED4_window::no_of_windows == MAXWINDOWS) { // no more than 5 windows allowed
1294  aw_message(GBS_global_string("Restricted to %i windows", MAXWINDOWS));
1295  return ED4_R_BREAK;
1296  }
1297 
1299  {
1300  int winNum = ED4_window::no_of_windows+1;
1301  char *winName = winNum>1 ? GBS_global_string_copy("ARB_EDIT4_%i", winNum) : ARB_strdup("ARB_EDIT4");
1302  char *winTitle = GBS_global_string_copy("ARB_EDIT4 *%d* [%s]", winNum, alignment_name);
1303 
1304  awmm->init(aw_root, winName, winTitle, 800, 450);
1305 
1306  free(winTitle);
1307  free(winName);
1308  }
1309 
1310  *device = awmm->get_device(AW_MIDDLE_AREA); // points to Middle Area device
1311  *new_window = ED4_window::insert_window(awmm); // append to window list
1312 
1314  bool clone = ED4_window::no_of_windows>1;
1315  if (!clone) { // this is the first window
1316  AW_init_color_group_defaults("arb_edit4");
1317  }
1318  else { // additional edit windows
1319  copy_window_struct(first_window, *new_window);
1320  }
1321 
1322  ED4_LocalWinContext uses(*new_window);
1323 
1324  // each window has its own gc-manager
1325  gc_manager = AW_manage_GC(awmm,
1326  "ARB_EDIT4", // but all gc-managers use the same colors
1327  *device,
1328  ED4_G_DRAG,
1330  makeGcChangedCallback(gc_change_cb), // callback triggering refresh on gc-change
1331 
1332  "#f8f8f8",
1333  "STANDARD$black", // standard color showing species/group info (name, ...)
1334  "FlagInfo$#DDD",
1335  "#SEQUENCES (0)$#505050", // default color for sequences (color 0)
1336 
1337  "+-HELIX (1)$#8E0000", "+-COLOR 2$#0000dd", "-COLOR 3$#00AA55",
1338  "+-COLOR 4$#80f", "+-COLOR 5$#c0a020", "-COLOR 6$grey",
1339  "+-COLOR 7$#ff0000", "+-COLOR 8$#44aaff", "-COLOR 9$#ffaa00",
1340 
1341  "+-CURSOR$#FF0080", "+-MARKED$#f4f8e0", "-SELECTED$#FFFF80",
1342 
1343  "+-RANGE 0$#FFFFFF", "+-RANGE 1$#F0F0F0", "-RANGE 2$#E0E0E0",
1344  "+-RANGE 3$#D8D8D8", "+-RANGE 4$#D0D0D0", "-RANGE 5$#C8C8C8",
1345  "+-RANGE 6$#C0C0C0", "+-RANGE 7$#B8B8B8", "-RANGE 8$#B0B0B0",
1346  "-RANGE 9$#A0A0A0",
1347 
1348  // colors used to Paint search patterns
1349  // (do not change the names of these gcs)
1350  "+-User1$#B8E2F8", "+-User2$#B8E2F8", "-Probe$#B8E2F8", // see also SEC_graphic::init_devices
1351  "+-Primer(l)$#A9FE54", "+-Primer(r)$#A9FE54", "-Primer(g)$#A9FE54",
1352  "+-Sig(l)$#DBB0FF", "+-Sig(r)$#DBB0FF", "-Sig(g)$#DBB0FF",
1353 
1354  "+-MISMATCHES$#FF9AFF", "+-Flag$#7c7ce3", "-FlagFill$#aacef1",
1355 
1356  "&color_groups", // use color groups
1357 
1358  NULp);
1359 
1360  // since the gc-managers of all EDIT4-windows point to the same window properties,
1361  // changing fonts and colors is always done on first gc-manager
1362  static AW_gc_manager *first_gc_manager = NULp;
1363  if (!first_gc_manager) first_gc_manager = gc_manager;
1364 
1365  // --------------
1366  // File
1367 
1368 #if defined(DEBUG)
1369  AWT_create_debug_menu(awmm);
1370 #endif // DEBUG
1371 
1372  awmm->create_menu("File", "F", AWM_ALL);
1373 
1374  awmm->insert_menu_topic("new_win", "New Editor Window", "N", NULp, AWM_ALL, ED4_new_editor_window);
1375  awmm->sep______________();
1376  awmm->insert_menu_topic("save_config", "Save configuration", "S", "species_configs_saveload.hlp", AWM_ALL, makeWindowCallback(ED4_saveConfiguration, false));
1377  awmm->insert_menu_topic(awmm->local_id("save_config_as"), "Save configuration as ...", "a", "species_configs_saveload.hlp", AWM_ALL, ED4_create_saveConfigurationAs_window);
1378  awmm->insert_menu_topic(awmm->local_id("load_config"), "Load configuration ...", "L", "species_configs_saveload.hlp", AWM_ALL, ED4_create_loadConfiguration_window);
1379  awmm->insert_menu_topic("reload_config", "Reload configuration", "R", "species_configs_saveload.hlp", AWM_ALL, ED4_reloadConfiguration);
1380  insert_macro_menu_entry(awmm, true);
1381  awmm->sep______________();
1382  // keep the following entries in sync with ../NTREE/NT_extern.cxx@common_save_menu_entries
1383  awmm->insert_menu_topic("save_changes", "Quicksave changes", "c", "save.hlp", AWM_ALL, makeWindowCallback(AWT_trigger_remote_action, GLOBAL_gb_main, "ARB_NT:save_changes"));
1384  awmm->insert_menu_topic("save_all_as", "Save whole database as ...", "w", "save.hlp", AWM_ALL, makeWindowCallback(AWT_trigger_remote_action, GLOBAL_gb_main, "ARB_NT:save_all_as"));
1385 #if defined(DEBUG)
1386  awmm->sep______________();
1387  awmm->insert_menu_topic("deb1", "[DEBUG] remote: invalid app", "D", NULp, AWM_ALL, makeWindowCallback(AWT_trigger_remote_action, GLOBAL_gb_main, "ARB_NTREE:aljdlaisjdlad"));
1388  awmm->insert_menu_topic("deb2", "[DEBUG] remote: invalid cmd", "E", NULp, AWM_ALL, makeWindowCallback(AWT_trigger_remote_action, GLOBAL_gb_main, "ARB_NT:aljdlaisjdlad"));
1389 #endif
1390  awmm->sep______________();
1391  GDE_load_menu(awmm, AWM_ALL, "Print");
1392  awmm->sep______________();
1393 
1394  if (clone) awmm->insert_menu_topic("close", "CLOSE", "C", NULp, AWM_ALL, ED4_quit_editor);
1395  else awmm->insert_menu_topic("quit", "QUIT", "Q", NULp, AWM_ALL, ED4_quit_editor);
1396 
1397  // ----------------
1398  // Create
1399 
1400  awmm->create_menu("Create", "C", AWM_ALL);
1401  awmm->insert_menu_topic(awmm->local_id("create_species"), "Create new species", "n", NULp, AWM_ALL, makeCreateWindowCallback(ED4_create_new_seq_window, CREATE_NEW_SPECIES));
1402  awmm->insert_menu_topic(awmm->local_id("create_species_from_consensus"), "Create new species from consensus", "u", NULp, AWM_ALL, makeCreateWindowCallback(ED4_create_new_seq_window, CREATE_FROM_CONSENSUS));
1403  awmm->insert_menu_topic(awmm->local_id("copy_species"), "Copy current species", "C", NULp, AWM_ALL, makeCreateWindowCallback(ED4_create_new_seq_window, COPY_SPECIES));
1404  awmm->sep______________();
1405  awmm->insert_menu_topic("create_group", "Create new Group (from selected)", "G", NULp, AWM_ALL, makeWindowCallback(group_species_cb, false));
1406  awmm->insert_menu_topic("create_groups_by_field", "Create new groups using Field", "F", NULp, AWM_ALL, makeWindowCallback(group_species_cb, true));
1407 
1408  // --------------
1409  // Edit
1410 
1411  awmm->create_menu("Edit", "E", AWM_ALL);
1412  awmm->insert_menu_topic("refresh", "Refresh [Ctrl-L]", "f", NULp, AWM_ALL, makeWindowCallback(ED4_request_full_refresh));
1413  awmm->insert_menu_topic("load_current", "Load current species [GET]", "G", "e4_get_species.hlp", AWM_ALL, makeWindowCallback(ED4_get_and_jump_to_current));
1414  awmm->insert_menu_topic("load_marked", "Load marked species", "m", "e4_get_species.hlp", AWM_ALL, makeWindowCallback(ED4_get_marked_from_menu));
1415  awmm->insert_menu_topic(awmm->local_id("load_SAI"), "Load SAI ...", "L", "e4_get_species.hlp", AWM_ALL, ED4_create_loadSAI_window);
1416  awmm->sep______________();
1417  awmm->insert_menu_topic("refresh_ecoli", "Reload Ecoli sequence", "E", "ecoliref.hlp", AWM_ALL, makeWindowCallback(reload_ecoli_cb));
1418  awmm->insert_menu_topic("refresh_helix", "Reload Helix", "H", "helix.hlp", AWM_ALL, makeWindowCallback(reload_helix_cb));
1419  awmm->insert_menu_topic("helix_jump_opposite", "Jump helix opposite [Ctrl-J]", "J", NULp, AWM_ALL, ED4_helix_jump_opposite);
1420  awmm->sep______________();
1421 
1422  awmm->insert_sub_menu("Set protection of current ", "p");
1423  {
1424  char macro[] = "to_0",
1425  topic[] = ".. to 0",
1426  hotkey[] = "0";
1427 
1428  for (char i='0'; i<='6'; i++) {
1429  macro[3] = topic[6] = hotkey[0] = i;
1430  awmm->insert_menu_topic(macro, topic, hotkey, "security.hlp", AWM_ALL, makeWindowCallback(ED4_set_protection, i-'0'));
1431  }
1432  }
1433  awmm->close_sub_menu();
1434 
1435  awmm->sep______________();
1436  awmm->insert_menu_topic(awmm->local_id("fast_aligner"), INTEGRATED_ALIGNERS_TITLE, "I", "faligner.hlp", AWM_ALL, makeCreateWindowCallback(ED4_create_faligner_window, ED4_get_aligner_data_access()));
1437  awmm->insert_menu_topic("fast_align_set_ref", "Set aligner reference [Ctrl-R]", "R", "faligner.hlp", AWM_ALL, RootAsWindowCallback::simple(FastAligner_set_reference_species));
1438  awmm->insert_menu_topic(awmm->local_id("align_sequence"), "Old aligner from ARB_EDIT [broken]", "O", "ne_align_seq.hlp", AWM_DISABLED, create_naligner_window);
1439  awmm->insert_menu_topic("sina", "SINA (SILVA Incremental Aligner)", "S", "sina_main.hlp", sina_mask(aw_root), makeWindowCallback(show_sina_window, ED4_get_aligner_data_access()));
1440  awmm->insert_menu_topic("del_ali_tmp", "Remove all aligner Entries", "v", NULp, AWM_ALL, makeWindowCallback(ED4_remove_faligner_entries));
1441  awmm->sep______________();
1442  awmm->insert_menu_topic("missing_bases", "Dot potentially missing bases", "D", "missbase.hlp", AWM_EXP, ED4_popup_dot_missing_bases_window);
1443 
1444  if (alignment_type == GB_AT_RNA) { // if the database contains valid alignment of rRNA sequences
1445  awmm->sep______________();
1446  awmm->insert_menu_topic("sec_edit", "Edit secondary structure", "c", "arb_secedit.hlp", AWM_ALL, makeWindowCallback(ED4_start_plugin, GLOBAL_gb_main, "SECEDIT"));
1447 #if defined(ARB_OPENGL)
1448  awmm->insert_menu_topic("rna3d", "View 3D molecule", "3", "rna3d_general.hlp", AWM_ALL, makeWindowCallback(ED4_start_plugin, GLOBAL_gb_main, "RNA3D"));
1449 #endif // ARB_OPENGL
1450 #if defined(DEBUG)
1451  awmm->insert_menu_topic("noplugin", "DEBUG: call unknown plugin", "u", NULp, AWM_ALL, makeWindowCallback(ED4_start_plugin, GLOBAL_gb_main, "testplugin"));
1452 #endif // DEBUG
1453  }
1454 
1455  // --------------
1456  // View
1457 
1458  awmm->create_menu("View", "V", AWM_ALL);
1459  awmm->insert_sub_menu("Search", "S");
1460  {
1461  int s;
1462  const char *hotkeys = "12Poiclrg";
1463  char hotkey[] = "_";
1464 
1465  e4_assert(strlen(hotkeys) == SEARCH_PATTERNS);
1466 
1467  for (s=0; s<SEARCH_PATTERNS; s++) {
1469  const char *id = ED4_SearchPositionTypeId[type];
1470  int len = strlen(id);
1471  char *macro_name = GB_give_buffer(2*(len+8));
1472  char *menu_entry_name = macro_name+(len+8);
1473 
1474 #ifndef NDEBUG
1475  memset(macro_name, 0, 2*(len+8)); // to avoid memchk-warning
1476 #endif
1477  sprintf(macro_name, "%s_SEARCH", id);
1478  char *p = macro_name;
1479  while (1) {
1480  char c = *p++;
1481  if (!c) break;
1482  p[-1] = toupper(c);
1483  }
1484  sprintf(menu_entry_name, "%s Search", id);
1485 
1486  hotkey[0] = hotkeys[s];
1487  awmm->insert_menu_topic(awmm->local_id(macro_name), menu_entry_name, hotkey, "e4_search.hlp", AWM_ALL, makeWindowCallback(ED4_popup_search_window, type));
1488  }
1489  }
1490  awmm->close_sub_menu();
1491  awmm->sep______________();
1492  awmm->insert_sub_menu("Cursor position ", "p");
1493  awmm->insert_menu_topic("store_curpos", "Store cursor position", "S", NULp, AWM_ALL, ED4_store_curpos);
1494  awmm->insert_menu_topic("restore_curpos", "Restore cursor position ", "R", NULp, AWM_ALL, ED4_restore_curpos);
1495  awmm->insert_menu_topic("clear_curpos", "Clear stored positions", "C", NULp, AWM_ALL, makeWindowCallback(ED4_clear_stored_curpos));
1496  awmm->close_sub_menu();
1497 
1498  awmm->sep______________();
1499  awmm->insert_menu_topic("change_cursor", "Change cursor type", "t", NULp, AWM_ALL, ED4_change_cursor);
1500  awmm->insert_menu_topic(awmm->local_id("view_diff"), "View differences ...", "V", "viewdiff.hlp", AWM_ALL, ED4_create_viewDifferences_window);
1501  awmm->sep______________();
1502  awmm->insert_menu_topic("enable_col_stat", "Activate column statistics", "A", "st_ml.hlp", AWM_EXP, ED4_activate_col_stat);
1503  awmm->insert_menu_topic("disable_col_stat", "Disable column statistics", "i", "st_ml.hlp", AWM_EXP, ED4_disable_col_stat);
1504  awmm->insert_menu_topic("detail_col_stat", "Toggle detailed Col.-Stat.", "C", "st_ml.hlp", AWM_EXP, ED4_toggle_detailed_column_stats);
1505  awmm->insert_menu_topic("dcs_threshold", "Set threshold for D.c.s.", "f", "st_ml.hlp", AWM_EXP, makeWindowCallback(ED4_set_col_stat_threshold));
1506  awmm->sep______________();
1507  awmm->insert_menu_topic(awmm->local_id("visualize_SAI"), "Visualize SAIs", "z", "visualizeSAI.hlp", AWM_ALL, ED4_createVisualizeSAI_window);
1508  awmm->insert_menu_topic("toggle_saisec", "Toggle secondary info for SAI", "o", "toggle_secinfo.hlp", AWM_ALL, toggle_helix_for_SAI);
1509 
1510  // Enable ProteinViewer only for DNA sequence type
1511  if (alignment_type == GB_AT_DNA) {
1512  awmm->insert_menu_topic(awmm->local_id("Protein_Viewer"), "Protein Viewer", "w", "proteinViewer.hlp", AWM_ALL, ED4_CreateProteinViewer_window);
1513  }
1514 
1515  // ---------------
1516  // Block
1517 
1518  awmm->create_menu("Block", "B", AWM_ALL);
1519 
1520  awmm->insert_menu_topic("select_marked", "Highlight marked species", "e", "e4_block.hlp", AWM_ALL, makeWindowCallback(ED4_menu_highlight, ED4_MS_SELECT_MARKED));
1521  awmm->insert_menu_topic("deselect_marked", "De-highlight marked species", "k", "e4_block.hlp", AWM_ALL, makeWindowCallback(ED4_menu_highlight, ED4_MS_DESELECT_MARKED));
1522  awmm->insert_menu_topic("select_all", "Highlight all species", "s", "e4_block.hlp", AWM_ALL, makeWindowCallback(ED4_menu_highlight, ED4_MS_ALL));
1523  awmm->insert_menu_topic("deselect_all", "De-highlight all species", "D", "e4_block.hlp", AWM_ALL, makeWindowCallback(ED4_menu_highlight, ED4_MS_NONE));
1524  awmm->sep______________();
1525  awmm->insert_menu_topic("mark_selected", "Mark highlighted species", "M", "e4_block.hlp", AWM_ALL, makeWindowCallback(ED4_menu_highlight, ED4_MS_MARK_SELECTED));
1526  awmm->insert_menu_topic("unmark_selected", "Unmark highlighted species", "n", "e4_block.hlp", AWM_ALL, makeWindowCallback(ED4_menu_highlight, ED4_MS_UNMARK_SELECTED));
1527  awmm->insert_menu_topic("unmark_all", "Unmark all species", "U", "e4_block.hlp", AWM_ALL, makeWindowCallback(ED4_menu_highlight, ED4_MS_UNMARK_ALL));
1528  awmm->sep______________();
1529  awmm->insert_menu_topic("invert_all", "Invert highlighted species", "I", "e4_block.hlp", AWM_ALL, makeWindowCallback(ED4_menu_highlight, ED4_MS_INVERT));
1530  awmm->insert_menu_topic("invert_group", "Invert group", "g", "e4_block.hlp", AWM_ALL, makeWindowCallback(ED4_menu_highlight, ED4_MS_INVERT_GROUP));
1531  awmm->sep______________();
1532  awmm->insert_menu_topic("lowcase", "Change to lower case ", "w", "e4_block.hlp", AWM_ALL, makeWindowCallback(ED4_menu_perform_block_operation, ED4_BO_LOWER_CASE));
1533  awmm->insert_menu_topic("upcase", "Change to upper case", "p", "e4_block.hlp", AWM_ALL, makeWindowCallback(ED4_menu_perform_block_operation, ED4_BO_UPPER_CASE));
1534  awmm->sep______________();
1535  awmm->insert_menu_topic("reverse", "Reverse highlighted ", "v", "e4_block.hlp", AWM_ALL, makeWindowCallback(ED4_menu_perform_block_operation, ED4_BO_REVERSE));
1536  awmm->insert_menu_topic("complement", "Complement highlighted ", "o", "e4_block.hlp", AWM_ALL, makeWindowCallback(ED4_menu_perform_block_operation, ED4_BO_COMPLEMENT));
1537  awmm->insert_menu_topic("reverse_complement", "Reverse complement", "t", "e4_block.hlp", AWM_ALL, makeWindowCallback(ED4_menu_perform_block_operation, ED4_BO_REVERSE_COMPLEMENT));
1538  awmm->sep______________();
1539  awmm->insert_menu_topic("unalignBlockLeft", "Unalign block left", "a", "e4_block.hlp", AWM_ALL, makeWindowCallback(ED4_menu_perform_block_operation, ED4_BO_UNALIGN_LEFT));
1540  awmm->insert_menu_topic("unalignBlockCenter", "Unalign block center", "c", "e4_block.hlp", AWM_ALL, makeWindowCallback(ED4_menu_perform_block_operation, ED4_BO_UNALIGN_CENTER));
1541  awmm->insert_menu_topic("unalignBlockRight", "Unalign block right", "b", "e4_block.hlp", AWM_ALL, makeWindowCallback(ED4_menu_perform_block_operation, ED4_BO_UNALIGN_RIGHT));
1542  awmm->sep______________();
1543  awmm->insert_menu_topic(awmm->local_id("replace"), "Search & Replace ", "h", "e4_replace.hlp", AWM_ALL, ED4_create_replace_window);
1544  awmm->insert_menu_topic(awmm->local_id("setsai"), "Modify SAI ", "y", "e4_modsai.hlp", AWM_ALL, ED4_create_modsai_window);
1545  awmm->sep______________();
1546  awmm->insert_menu_topic("toggle_block_type", "Exchange: Line<->Column", "x", "e4_block.hlp", AWM_ALL, makeWindowCallback(ED4_menu_highlight, ED4_MS_TOGGLE_BLOCKTYPE));
1547  awmm->insert_menu_topic("shift_left", "Shift block left ", "l", "e4_block.hlp", AWM_ALL, makeWindowCallback(ED4_menu_perform_block_operation, ED4_BO_SHIFT_LEFT));
1548  awmm->insert_menu_topic("shift_right", "Shift block right", "r", "e4_block.hlp", AWM_ALL, makeWindowCallback(ED4_menu_perform_block_operation, ED4_BO_SHIFT_RIGHT));
1549 
1550  // --------------------
1551  // Properties
1552 
1553  awmm->create_menu("Properties", "P", AWM_ALL);
1554 
1555  awmm->insert_menu_topic(awmm->local_id("props_frame"), "Frame settings ...", "g", NULp, AWM_ALL, AW_preset_window);
1556  awmm->insert_menu_topic(awmm->local_id("props_options"), "Editor Options ", "O", "e4_options.hlp", AWM_ALL, ED4_create_editor_options_window);
1557  awmm->insert_menu_topic(awmm->local_id("props_consensus"), "Consensus Definition ", "u", "e4_consensus.hlp", AWM_ALL, ED4_create_consensus_definition_window);
1558  awmm->sep______________();
1559 
1560  awmm->insert_menu_topic("props_data", "Change Colors & Fonts ", "C", NULp, AWM_ALL, makeWindowCallback (ED4_popup_gc_window, first_gc_manager));
1561  awmm->insert_menu_topic(awmm->local_id("props_seq_colors"), "Sequence color mapping", "S", "sequence_colors.hlp", AWM_ALL, makeCreateWindowCallback(ED4_create_seq_colors_window, sequence_colors));
1562 
1563  awmm->sep______________();
1564 
1565  awmm->insert_menu_topic(awmm->local_id("props_nds"), "Select visible info (NDS) ", "D", "ed4_nds.hlp", AWM_ALL, ED4_create_nds_window);
1566  awmm->insert_menu_topic(awmm->local_id("props_flags"), "Select species flags", "f", "ed4_flags.hlp", AWM_ALL, makeCreateWindowCallback(ED4_configure_species_flags, GLOBAL_gb_main));
1567  {
1568  static WindowCallback reqRelCb = makeWindowCallback(ED4_request_relayout);
1569  if (alignment_type == GB_AT_AA) awmm->insert_menu_topic(awmm->local_id("props_pfold"), "Protein Match Settings ", "P", "pfold_props.hlp", AWM_ALL, makeCreateWindowCallback(ED4_pfold_create_props_window, &reqRelCb));
1570  else awmm->insert_menu_topic(awmm->local_id("props_helix_sym"), "Helix Settings ", "H", "helixsym.hlp", AWM_ALL, makeCreateWindowCallback(create_helix_props_window, &reqRelCb));
1571  }
1572  awmm->insert_menu_topic(awmm->local_id("props_key_map"), "Key Mappings ", "K", "nekey_map.hlp", AWM_ALL, create_key_map_window);
1573 
1574  awmm->sep______________();
1576  awmm->sep______________();
1577  awmm->insert_sub_menu("Save properties ...", "a");
1578  {
1579  static const char * const tag[] = { "save_alispecific_props", "save_alitype_props", "save_props" };
1580  static const char * const entry_type[] = { "alignment specific ", "ali-type specific ", "" };
1581 
1582  // check what is the default mode
1583  int default_mode = -1;
1584  for (int mode = 0; mode <= 2; ++mode) {
1585  if (strcmp(GB_path_in_arbprop(ED4_propertyName(mode)), db_name) == 0) {
1586  default_mode = mode;
1587  break;
1588  }
1589  }
1590  if (default_mode == -1) default_mode = 2; // no properties yet -> use 'edit4.arb'
1591 
1592  const char *entry = GBS_global_string("Save loaded Properties (%s)", ED4_propertyName(default_mode));
1593  awmm->insert_menu_topic("save_loaded_props", entry, "l", "e4_defaults.hlp", AWM_ALL, makeWindowCallback(ED4_save_properties, default_mode));
1594  awmm->sep______________();
1595 
1596  for (int mode = 2; mode >= 0; --mode) {
1597  char hotkey[] = "x";
1598  hotkey[0] = "Pta"[mode];
1599  entry = GBS_global_string("Save %sProperties (%s)", entry_type[mode], ED4_propertyName(mode));
1600  awmm->insert_menu_topic(tag[mode], entry, hotkey, "e4_defaults.hlp", AWM_ALL, makeWindowCallback(ED4_save_properties, mode));
1601  }
1602  }
1603  awmm->close_sub_menu();
1604 
1605  awmm->insert_help_topic("ARB_EDIT4 help", "E", "e4.hlp", AWM_ALL, makeHelpCallback("e4.hlp"));
1606 
1607  // ----------------------------------------------------------------------------------------------------
1608 
1609  aw_root->awar_int(AWAR_EDIT_TITLE_MODE)->add_callback(makeRootCallback(title_mode_changed, static_cast<AW_window*>(awmm)));
1610  awmm->set_bottom_area_height(0); // No bottom area
1611 
1612  awmm->auto_space(5, -2);
1613  awmm->shadow_width(3);
1614 
1615  int db_pathx, db_pathy;
1616  awmm->get_at_position(&db_pathx, &db_pathy);
1617 
1618  awmm->shadow_width(1);
1619  awmm->load_xfig("edit4/editmenu.fig", false);
1620 
1621  // --------------------------
1622  // help /quit /fold
1623 
1624  awmm->button_length(0);
1625 
1626  awmm->at("quit");
1627  awmm->callback(ED4_quit_editor);
1628  awmm->help_text("quit.hlp");
1629 
1630  if (clone) awmm->create_button("CLOSE", "#close.xpm");
1631  else awmm->create_button("QUIT", "#quit.xpm");
1632 
1633  awmm->at("help");
1635  awmm->help_text("e4.hlp");
1636  awmm->create_button("HELP", "#help.xpm");
1637 
1638  awmm->at("fold");
1639  awmm->help_text("e4.hlp");
1640  awmm->create_toggle(AWAR_EDIT_TITLE_MODE, "#more.xpm", "#less.xpm");
1641 
1642  // -------------------
1643  // positions
1644 
1645  awmm->button_length(0);
1646 
1647  awmm->at("posTxt"); awmm->create_button(NULp, "Position");
1648 
1649  awmm->button_length(6+1);
1650 
1651  awmm->at("ecoliTxt"); awmm->create_button(NULp, ED4_AWAR_NDS_ECOLI_NAME, NULp, "+");
1652 
1653  awmm->button_length(0);
1654 
1655  awmm->at("baseTxt"); awmm->create_button(NULp, "Base");
1656  awmm->at("iupacTxt"); awmm->create_button(NULp, "IUPAC");
1657  awmm->at("helixnrTxt"); awmm->create_button(NULp, "Helix#");
1658 
1659  awmm->at("pos");
1660  awmm->callback(makeWindowCallback(ED4_jump_to_cursor_position, current_ed4w()->awar_path_for_cursor, ED4_POS_SEQUENCE)); // @@@ used as INPUTFIELD_CB (see #559)
1661  awmm->create_input_field(current_ed4w()->awar_path_for_cursor, 7);
1662 
1663  awmm->at("ecoli");
1664  awmm->callback(makeWindowCallback(ED4_jump_to_cursor_position, current_ed4w()->awar_path_for_Ecoli, ED4_POS_ECOLI)); // @@@ used as INPUTFIELD_CB (see #559)
1665  awmm->create_input_field(current_ed4w()->awar_path_for_Ecoli, 6);
1666 
1667  awmm->at("base");
1668  awmm->callback(makeWindowCallback(ED4_jump_to_cursor_position, current_ed4w()->awar_path_for_basePos, ED4_POS_BASE)); // @@@ used as INPUTFIELD_CB (see #559)
1669  awmm->create_input_field(current_ed4w()->awar_path_for_basePos, 6);
1670 
1671  awmm->at("iupac");
1672  awmm->callback(makeWindowCallback(ED4_set_iupac, current_ed4w()->awar_path_for_IUPAC)); // @@@ used as INPUTFIELD_CB (see #559)
1673  awmm->create_input_field(current_ed4w()->awar_path_for_IUPAC, 4);
1674 
1675  awmm->at("helixnr");
1676  awmm->callback(makeWindowCallback(ED4_set_helixnr, current_ed4w()->awar_path_for_helixNr)); // @@@ used as INPUTFIELD_CB (see #559)
1677  awmm->create_input_field(current_ed4w()->awar_path_for_helixNr, 5);
1678 
1679  // ----------------------------
1680  // jump/get/undo/redo
1681 
1682  awmm->button_length(4);
1683 
1684  awmm->at("jump");
1686  awmm->help_text("e4_get_species.hlp");
1687  awmm->create_button("JUMP", "Jump");
1688 
1689  awmm->at("get");
1690  awmm->callback(makeWindowCallback(ED4_get_and_jump_to_current));
1691  awmm->help_text("e4_get_species.hlp");
1692  awmm->create_button("GET", "Get");
1693 
1694  awmm->button_length(0);
1695 
1696  awmm->at("undo");
1697  awmm->callback(makeWindowCallback(ED4_undo_redo, GB_UNDO_UNDO));
1698  awmm->help_text("undo.hlp");
1699  awmm->create_button("UNDO", "#undo.xpm");
1700 
1701  awmm->at("redo");
1702  awmm->callback(makeWindowCallback(ED4_undo_redo, GB_UNDO_REDO));
1703  awmm->help_text("undo.hlp");
1704  awmm->create_button("REDO", "#redo.xpm");
1705 
1706  // --------------------------
1707  // aligner / SAIviz
1708 
1709  awmm->button_length(7);
1710 
1711  awmm->at("aligner");
1712  awmm->callback(makeCreateWindowCallback(ED4_create_faligner_window, ED4_get_aligner_data_access()));
1713  awmm->help_text("faligner.hlp");
1714  awmm->create_button("ALIGNER", "Aligner");
1715 
1716  awmm->at("saiviz");
1718  awmm->help_text("visualizeSAI.hlp");
1719  awmm->create_button("SAIVIZ", "SAIviz");
1720 
1721  // -------------------------------------------
1722  // align/insert/protection/direction
1723 
1724  awmm->button_length(0);
1725 
1726  awmm->at("protect");
1728  awmm->insert_option ("0", NULp, 0);
1729  awmm->insert_option ("1", NULp, 1);
1730  awmm->insert_option ("2", NULp, 2);
1731  awmm->insert_option ("3", NULp, 3);
1732  awmm->insert_option ("4", NULp, 4);
1733  awmm->insert_option ("5", NULp, 5);
1734  awmm->insert_default_option("6", NULp, 6);
1735  awmm->update_option_menu();
1736 
1737  // draw protection icon AFTER protection!!
1738  awmm->at("pico");
1739  awmm->create_button(NULp, "#protect.xpm");
1740 
1741  // draw align/edit-button AFTER protection!!
1742  awmm->at("edit");
1743  awmm->create_toggle(AWAR_EDIT_MODE, "#edit/align.xpm", "#edit/editseq.xpm", 7);
1744 
1745  awmm->at("insert");
1746  awmm->create_text_toggle(AWAR_INSERT_MODE, "Replace", "Insert", 7);
1747 
1748  awmm->at("direct");
1749  awmm->create_toggle(AWAR_EDIT_RIGHTWARD, "#edit/3to5.xpm", "#edit/5to3.xpm", 7);
1750 
1751  // -------------------------
1752  // secedit / rna3d
1753 
1754  int xoffset = 0;
1755 
1756  if (alignment_type == GB_AT_RNA) { // if the database contains valid alignment of rRNA sequences
1757  // add buttons for RNA3D and SECEDIT plugins
1758 
1759  awmm->button_length(0);
1760 
1761  awmm->at("secedit");
1762  awmm->callback(makeWindowCallback(ED4_start_plugin, GLOBAL_gb_main, "SECEDIT"));
1763  awmm->help_text("arb_secedit.hlp");
1764  awmm->create_button("SECEDIT", "#edit/secedit.xpm");
1765 
1766 #if defined(ARB_OPENGL)
1767  awmm->at("rna3d");
1768  awmm->callback(makeWindowCallback(ED4_start_plugin, GLOBAL_gb_main, "RNA3D"));
1769  awmm->help_text("rna3d_general.hlp");
1770  awmm->create_button("RNA3D", "#edit/rna3d.xpm");
1771 #endif // ARB_OPENGL
1772  }
1773  else {
1774  awmm->at("secedit");
1775  int xsecedit = awmm->get_at_xposition();
1776  awmm->at("zoom");
1777  int xzoom = awmm->get_at_xposition();
1778  xoffset = xsecedit-xzoom; // shift message stuff to the left by xoffset
1779  }
1780 
1781  {
1782  int x, y;
1783 
1784  awmm->at("zoom");
1785  if (xoffset) { awmm->get_at_position(&x, &y); awmm->at(x+xoffset, y); }
1787  awmm->create_button("ZOOM", "#edit/zoom.xpm");
1788 
1789  awmm->at("clear");
1790  if (xoffset) { awmm->get_at_position(&x, &y); awmm->at(x+xoffset, y); }
1792  awmm->create_button("CLEAR", "#edit/clear.xpm");
1793 
1794  awmm->at("errortext");
1795  if (xoffset) { awmm->get_at_position(&x, &y); awmm->at(x+xoffset, y); }
1796  aw_root->awar_string(AWAR_ERROR_MESSAGES, "This is ARB Edit4 [Build " ARB_VERSION "]");
1799  }
1800 
1801  // ---------------------
1802  // 'more' area
1803 
1804  awmm->at("cons");
1805  awmm->create_toggle(ED4_AWAR_CONSENSUS_SHOW, "#edit/nocons.xpm", "#edit/cons.xpm");
1806 
1807  awmm->at("num");
1808  awmm->create_toggle(ED4_AWAR_DIGITS_AS_REPEAT, "#edit/norepeat.xpm", "#edit/repeat.xpm");
1809 
1810  awmm->at("key");
1811  awmm->create_toggle("key_mapping/enable", "#edit/nokeymap.xpm", "#edit/keymap.xpm");
1812 
1813  // search
1814 
1815  awmm->button_length(0);
1816 #define INSERT_SEARCH_FIELDS(Short, label_prefix, prefix) \
1817  insert_search_fields(awmm, \
1818  #label_prefix, \
1819  #prefix, \
1820  ED4_AWAR_##prefix##_SEARCH_PATTERN, \
1821  ED4_AWAR_##prefix##_SEARCH_SHOW, \
1822  Short, \
1823  ED4_##prefix##_PATTERN, \
1824  current_ed4w() \
1825  )
1826 
1827  INSERT_SEARCH_FIELDS(0, u1, USER1);
1828  INSERT_SEARCH_FIELDS(0, u2, USER2);
1829  INSERT_SEARCH_FIELDS(0, pro, PROBE);
1830  INSERT_SEARCH_FIELDS(1, pri1, PRIMER1);
1831  INSERT_SEARCH_FIELDS(1, pri2, PRIMER2);
1832  INSERT_SEARCH_FIELDS(1, pri3, PRIMER3);
1833  INSERT_SEARCH_FIELDS(1, sig1, SIG1);
1834  INSERT_SEARCH_FIELDS(1, sig2, SIG2);
1835  INSERT_SEARCH_FIELDS(1, sig3, SIG3);
1836 
1837 #undef INSERT_SEARCH_FIELDS
1838 
1839  awmm->at("alast");
1841  awmm->create_button("ALL_SEARCH_LAST", "#edit/last.xpm");
1842 
1843  awmm->at("anext");
1845  awmm->create_button("ALL_SEARCH_NEXT", "#edit/next.xpm");
1846 
1847  title_mode_changed(aw_root, awmm);
1848 
1849  // Buttons at left window border
1850 
1851  awmm->create_mode("edit/arrow.xpm", "e4_mode.hlp", AWM_ALL, makeWindowCallback(modes_cb, ED4_SM_MOVE));
1852  awmm->create_mode("edit/kill.xpm", "e4_mode.hlp", AWM_ALL, makeWindowCallback(modes_cb, ED4_SM_KILL));
1853  awmm->create_mode("edit/mark.xpm", "e4_mode.hlp", AWM_ALL, makeWindowCallback(modes_cb, ED4_SM_MARK));
1854  awmm->create_mode("mode_info.xpm", "e4_mode.hlp", AWM_ALL, makeWindowCallback(modes_cb, ED4_SM_INFO));
1855 
1857 
1858 #if defined(DEBUG)
1859  AWT_check_action_ids(awmm->get_root(), "");
1860 #endif
1861 
1862  announce_useraction_in(awmm);
1863 
1864  return ED4_R_OK;
1865 }
1866 
1868  // Note: other windows are generated by generate_window
1869  AW_device *device = NULp;
1870  ED4_window *new_window = NULp;
1871 
1872  generate_window(&device, &new_window);
1873 
1874  ED4_LocalWinContext uses(new_window);
1875 
1876  ED4_calc_terminal_extentions(); // (Note: done again later, but otherwise variables are used uninitialized);
1877 
1878  DRAW = 1;
1879  move_cursor = 0;
1881 
1883 
1884  return new_window->aww;
1885 }
1886 
1888  // 'click_x' is the x-offset into the terminal in pixels
1889  // returns the x-offset into the terminal in base positions (clipped to max. allowed position)
1890 
1891  int length_of_char = font_group.get_width(ED4_G_SEQUENCES);
1892  ED4_index scr_pos = int((click_x-CHARACTEROFFSET) / length_of_char);
1893  int max_scrpos = root_group_man->remap()->get_max_screen_pos();
1894 
1895  if (scr_pos>max_scrpos) scr_pos = max_scrpos;
1896 
1897  return scr_pos;
1898 }
1899 
1900 static char *detectProperties() {
1901  char *propname = NULp;
1902 
1903  // check if edit4_?na.arb / edit4_ali_???.arb exist in $ARB_PROP
1904  for (int mode = 0; !propname && mode <= 1; ++mode) {
1905  const char *fullprop = GB_path_in_arbprop(ED4_propertyName(mode));
1906  if (GB_is_regularfile(fullprop)) {
1907  freedup(propname, fullprop);
1908  }
1909  }
1910 
1911  // if not, use 'mode 2', i.e. "edit4.arb"
1912  // (no full path, we want to load default from arb_defaults)
1913  if (!propname) propname = ARB_strdup(ED4_propertyName(2));
1914 
1915  return propname;
1916 }
1917 
1918 ED4_root::ED4_root(int* argc, char*** argv)
1919  : most_recently_used_window(NULp),
1920  cons_param(NULp),
1921  db_name(detectProperties()),
1922  aw_root(AWT_create_root(db_name, "ARB_EDIT4", need_macro_ability(), argc, argv)),
1923  props_db(AW_ROOT_DEFAULT),
1924  first_window(NULp),
1925  main_manager(NULp),
1926  middle_area_man(NULp),
1927  top_area_man(NULp),
1928  root_group_man(NULp),
1929  database(NULp),
1930  selected_objects(new ED4_selected_list),
1931  folding_action(false),
1932  species_mode(ED4_SM_MOVE),
1933  ecoli_ref(NULp),
1935  alignment_type(GB_AT_UNKNOWN),
1936  reference(NULp),
1937  sequence_colors(NULp),
1938  gc_manager(NULp),
1939  st_ml(NULp),
1940  helix(NULp),
1941  helix_spacing(0),
1942  helix_add_spacing(0),
1943  terminal_add_spacing(0),
1944  protstruct(NULp),
1945  protstruct_len(0),
1946  edk(NULp),
1947  edit_string(NULp),
1948  column_stat_activated(false),
1949  column_stat_initialized(false),
1950  visualizeSAI(false),
1951  visualizeSAI_allSpecies(false),
1952  loadable_SAIs(LSAI_UNUSED),
1953  temp_gc(0)
1954 {}
1955 
1956 
1958  delete aw_root;
1959  delete first_window;
1960  delete reference; // needs to be deleted before main_manager (to ensure reference callbacks are removed)
1961  delete main_manager; // also deletes middle_area_man + top_area_man
1962  delete database;
1963  delete ecoli_ref;
1964  delete selected_objects;
1965  delete helix;
1966  delete sequence_colors;
1967  delete edk;
1969 
1970  free(protstruct);
1971  free(db_name);
1972  free(alignment_name);
1973 }
GB_ERROR GB_begin_transaction(GBDATA *gbd)
Definition: arbdb.cxx:2492
bool inside_SAI_manager() const
Definition: ed4_class.hxx:1847
void insert_option(AW_label choice_label, const char *mnemonic, const char *var_value, const char *name_of_color=NULp)
static ARB_ERROR change_char_table_length(ED4_base *base, int new_length)
Definition: ED4_root.cxx:460
static bool have_context()
Definition: ed4_class.hxx:1398
void ED4_set_iupac(AW_window *aww, const char *awar_name)
ED4_species_mode
Definition: ed4_class.hxx:1345
void get_at_position(int *x, int *y) const
Definition: AW_at.cxx:291
void FastAligner_create_variables(AW_root *root, AW_default db1)
static ARB_ERROR force_group_update(ED4_base *base)
Definition: ED4_root.cxx:542
static void reload_ecoli_cb()
Definition: ED4_root.cxx:825
ED4_returncode generate_window(AW_device **device, ED4_window **new_window)
Definition: ED4_root.cxx:1279
ED4_selected_list * selected_objects
Definition: ed4_class.hxx:1433
void ED4_get_marked_from_menu(AW_window *)
Definition: ED4_cursor.cxx:681
GB_TYPES type
void group_species_cb(AW_window *aww, bool use_fields)
AW_device * current_device()
Definition: ed4_class.hxx:1402
GB_ERROR GB_commit_transaction(GBDATA *gbd)
Definition: arbdb.cxx:2515
static void reload_helix_cb()
Definition: ED4_root.cxx:818
char * db_name
Definition: ed4_class.hxx:1423
AW_helix * helix
Definition: ed4_class.hxx:1446
void ED4_jump_to_cursor_position(AW_window *aww, const char *awar_name, PositionType posType)
void button_length(int length)
Definition: AW_at.cxx:283
group_matcher all()
Definition: test_unit.h:1000
GB_CSTR GB_path_in_arbprop(const char *relative_path)
Definition: adsocket.cxx:1109
void special_window_refresh(bool handle_updates)
Definition: ED4_root.cxx:158
int get_at_xposition() const
Definition: AW_at.cxx:296
AW_font_group font_group
Definition: ed4_class.hxx:1467
static ED4_selected_elem * curr_aligner_elem
Definition: ED4_root.cxx:921
AW_pos size[2]
Definition: ed4_defs.hxx:262
#define AWAR_EDIT_SECURITY_LEVEL
Definition: ed4_defs.hxx:94
AW_device * get_device(AW_area area)
Definition: AW_window.cxx:534
long GB_read_int(GBDATA *gbd)
Definition: arbdb.cxx:699
#define AWAR_EDIT_TITLE_MODE
Definition: ed4_defs.hxx:107
const AW_screen_area & get_area_size() const
Definition: AW_device.cxx:57
static char * y[maxsp+1]
static ARB_ERROR ED4_delete_temp_entries(GBDATA *species, GB_CSTR alignment_name)
Definition: ED4_root.cxx:948
AW_window * ED4_pfold_create_props_window(AW_root *awr, const WindowCallback *refreshCallback)
Creates the "Protein Match Settings" window.
#define MAXWINDOWS
Definition: ed4_defs.hxx:90
ED4_area_manager * top_area_man
Definition: ed4_class.hxx:1430
void ED4_activate_col_stat(AW_window *aww)
Definition: ED4_colStat.cxx:99
bool DRAW
Definition: ED4_main.cxx:70
void insert_menu_topic(const char *id, const char *name, const char *mnemonic, const char *help_text_, AW_active mask, const WindowCallback &wcb)
Definition: AW_window.cxx:592
AW_window * create_key_map_window(AW_root *root)
Definition: AWT_map_key.cxx:77
void set_dimension(AW_pos dim)
Definition: ed4_class.hxx:315
GB_ERROR GB_append_exportedError(GB_ERROR error)
Definition: arb_msg.cxx:399
AW_window * ED4_create_modsai_window(AW_root *root)
Definition: ED4_block.cxx:974
void load_xfig(const char *file, bool resize=true)
Definition: AW_window.cxx:717
int MAXNAME_WIDTH
Definition: ED4_main.cxx:57
void aw_set_local_message()
Definition: AW_status.cxx:927
GB_ERROR GB_add_callback(GBDATA *gbd, GB_CB_TYPE type, const DatabaseCallback &dbcb)
Definition: ad_cb.cxx:356
AW_root * AWT_create_root(const char *properties, const char *program, UserActionTracker *user_tracker, int *argc, char ***argv)
void request_refresh_for_all_terminals()
Definition: ED4_root.cxx:83
void update_window_coords()
Definition: ED4_window.cxx:52
virtual ARB_ERROR route_down_hierarchy(const ED4_route_cb &cb)
Definition: ED4_base.cxx:385
static bool is_named(ED4_base *base, const char *wanted_name)
Definition: ED4_root.cxx:865
AW_pos drag_off_y
Definition: ed4_defs.hxx:248
static void ED4_menu_highlight(AW_window *aww, MenuSelectType select)
Definition: ED4_root.cxx:1109
ED4_species_name_terminal * object
Definition: ed4_defs.hxx:253
void at(int x, int y)
Definition: AW_at.cxx:93
long
Definition: AW_awar.cxx:154
ED4_area_manager * middle_area_man
Definition: ed4_class.hxx:1429
GBDATA * GBT_get_alignment(GBDATA *gb_main, const char *aliname)
Definition: adali.cxx:684
void ED4_setBlocktype(ED4_blocktype bt)
Definition: ED4_block.cxx:360
BaseFrequencies & table()
Definition: ed4_class.hxx:1648
const char * init(GBDATA *gb_main)
Definition: BI_helix.cxx:299
void ED4_request_relayout()
AW_pos actual_width
Definition: ed4_defs.hxx:250
void ED4_search_cb(UNFIXED, int searchDescriptor, ED4_window *ed4w)
#define INTEGRATED_ALIGNERS_TITLE
ED4_returncode get_area_rectangle(AW_screen_area *rect, AW_pos x, AW_pos y)
Definition: ED4_root.cxx:766
ED4_returncode deselect_all()
Definition: ED4_root.cxx:316
char * ARB_strdup(const char *str)
Definition: arb_string.h:27
void create_toggle(const char *awar_name)
Definition: AW_button.cxx:842
void warn_illegal_dimension()
Definition: ED4_root.cxx:60
void change_table_length(int new_length)
Definition: chartable.cxx:1126
void set_secstruct_display(bool show)
Definition: ed4_class.hxx:2003
void GB_end_transaction_show_error(GBDATA *gbd, GB_ERROR error, void(*error_handler)(GB_ERROR))
Definition: arbdb.cxx:2548
char * GB_read_as_string(GBDATA *gbd)
Definition: arbdb.cxx:1030
long read_int() const
Definition: AW_awar.cxx:187
void remove_from_selected(ED4_species_name_terminal *object)
Definition: ED4_root.cxx:328
#define AWAR_INSERT_MODE
Definition: ed4_defs.hxx:93
static bool is_SAI_named(ED4_base *base, const char *sai_name)
Definition: ED4_root.cxx:881
EDB_root_bact * database
Definition: ed4_class.hxx:1432
void win_to_world_coords(AW_pos *xPtr, AW_pos *yPtr) const
Definition: ed4_class.hxx:366
static GBDATA * get_next_selected_species()
Definition: ED4_root.cxx:923
int slider_pos_horizontal
Definition: ed4_class.hxx:712
ST_ML * st_ml
ED4_level level
Definition: ed4_class.hxx:230
ED4_reference * reference
Definition: ed4_class.hxx:1442
static bool get_selected_range(PosRange &range)
Definition: ED4_root.cxx:912
ed_key * edk
Definition: ed4_class.hxx:1452
const char * GBS_global_string(const char *templat,...)
Definition: arb_msg.cxx:204
void PV_CallBackFunction(AW_root *root)
void marked_species_select(bool select)
ED4_root * ED4_ROOT
Definition: ED4_main.cxx:48
int is_species_manager() const
Definition: ed4_class.hxx:1114
void ED4_trigger_instant_refresh()
static char * alignment_name
void AW_POPDOWN(AW_window *window)
Definition: AW_window.cxx:52
void scan_string(ED4_multi_species_manager *parent, ED4_reference_terminals &refterms, const char *str, int *index, arb_progress &progress)
void AW_insert_common_property_menu_entries(AW_window_menu_modes *awmm)
Definition: AW_preset.cxx:1445
#define ARB_VERSION
Definition: arb_build.h:1
void unregisterAll()
ED4_window * get_matching_ed4w(AW_window *aww)
Definition: ED4_window.cxx:107
void update_scrolled_rectangle()
Definition: ED4_window.cxx:144
size_t get_max_screen_pos() const
Definition: ed4_class.hxx:1734
void ED4_clear_stored_curpos()
AW_window * ED4_configure_species_flags(AW_root *root, GBDATA *gb_main)
Definition: ED4_flags.cxx:213
bool isNull() const
test if SmartPtr is NULp
Definition: smartptr.h:248
#define TREE_TERMINAL_WIDTH
Definition: ed4_defs.hxx:83
ED4_terminal * owner_of_cursor
Definition: ed4_class.hxx:649
void create_consensus(ED4_abstract_group_manager *upper_group_manager, arb_progress *progress)
Definition: ED4_base.cxx:567
void ED4_change_cursor(AW_window *aww)
static ED4_window * insert_window(AW_window_menu_modes *new_aww)
Definition: ED4_window.cxx:395
void ED4_disable_col_stat(AW_window *)
ED4_folding_line * insert_folding_line(AW_pos pos, AW_pos dimension, ED4_properties prop)
Definition: ED4_window.cxx:97
int get_width(int gc) const
ED4_manager * parent
Definition: ed4_class.hxx:921
AW_gc_manager * gc_manager
Definition: ed4_class.hxx:1444
AW_gc_manager * AW_manage_GC(AW_window *aww, const char *gc_base_name, AW_device *device, int base_drag, AW_GCM_AREA area, const GcChangedCallback &changecb, const char *default_background_color,...)
Definition: AW_preset.cxx:969
bool in_SAI_terminal() const
Definition: ed4_class.hxx:1856
void ED4_request_full_instant_refresh()
const ED4_folding_line * get_horizontal_folding()
Definition: ed4_class.hxx:356
void ED4_request_full_refresh()
ED4_reference_terminals ref_terminals
Definition: ed4_class.hxx:1436
#define ARRAY_ELEMS(array)
Definition: arb_defs.h:19
char * protstruct
Definition: ed4_class.hxx:1450
AW_window * ED4_create_viewDifferences_window(AW_root *awr)
GBDATA * GB_get_grandfather(GBDATA *gbd)
Definition: arbdb.cxx:1702
void setNull()
set SmartPtr to NULp
Definition: smartptr.h:251
void update_option_menu()
#define ED4_AWAR_CONSENSUS_SHOW
Definition: ed4_awars.hxx:51
GB_ERROR GB_push_transaction(GBDATA *gbd)
Definition: arbdb.cxx:2458
void activate()
Definition: aw_window.hxx:354
void AW_init_color_group_defaults(const char *for_program)
Definition: AW_preset.cxx:1113
ED4_base * find_first_that(ED4_level level, const ED4_basePredicate &fulfills_predicate)
Definition: ED4_base.cxx:400
AW_window * ED4_create_new_seq_window(AW_root *root, SpeciesCreationMode creation_mode)
#define cb(action)
ED4_coords coords
Definition: ed4_class.hxx:716
#define AWAR_EDIT_RIGHTWARD
Definition: ed4_extern.hxx:76
static void gc_change_cb(GcChange whatChanged)
Definition: ED4_root.cxx:1272
#define e4_assert(bed)
Definition: ed4_class.hxx:11
const int WIDTH
void ED4_quit_editor(AW_window *aww)
GBDATA * GLOBAL_gb_main
Definition: DI_main.cxx:27
int is_multi_species_manager() const
Definition: ed4_class.hxx:1106
AW_awar * add_callback(const RootCallback &cb)
Definition: AW_awar.cxx:234
const ED4_objspec & spec
Definition: ed4_class.hxx:919
void ED4_correctBlocktypeAfterSelection()
Definition: ED4_block.cxx:362
void init(ED4_sequence_info_terminal *, ED4_sequence_terminal *, ED4_sequence_info_terminal *, ED4_columnStat_terminal *)
static ARB_ERROR do_sth_with_species(ED4_base *base, const ED4_Species_Callback *cb)
Definition: ED4_root.cxx:836
void world_to_win_coords(AW_pos *xPtr, AW_pos *yPtr) const
Definition: ed4_class.hxx:359
void request_refresh_for_specific_terminals(ED4_level lev)
Definition: ED4_root.cxx:87
GB_UNDO_TYPE
Definition: arbdb.h:107
bool is_consensus_manager() const
Definition: ed4_class.hxx:1837
void ED4_jump_to_current_species(AW_window *)
Definition: ED4_cursor.cxx:518
void ED4_new_editor_window(AW_window *aww)
GBDATA * GBT_find_SAI(GBDATA *gb_main, const char *name)
Definition: aditem.cxx:172
static void insert_search_fields(AW_window_menu_modes *awmm, const char *label_prefix, const char *macro_prefix, const char *pattern_awar_name, const char *show_awar_name, int short_form, ED4_SearchPositionType type, ED4_window *ed4w)
Definition: ED4_root.cxx:1042
void ED4_popup_search_window(AW_window *aww, ED4_SearchPositionType type)
GcChange
Definition: aw_base.hxx:94
char * build_consensus_string(PosRange range) const
Definition: ed4_class.hxx:1655
ED4_level
Definition: ed4_defs.hxx:120
#define SEQUENCE_INFO_WIDTH
Definition: ed4_defs.hxx:82
ED4_species_name_terminal * ED4_find_species_name_terminal(const char *species_name)
Definition: ED4_root.cxx:889
int create_mode(const char *pixmap, const char *help_text_, AW_active mask, const WindowCallback &cb)
Definition: AW_window.cxx:2958
GB_ERROR GB_await_error()
Definition: arb_msg.cxx:353
void show()
Definition: AW_window.cxx:1658
void recalc_font_group()
Definition: ED4_root.cxx:528
#define ED4_AWAR_NDS_ECOLI_NAME
Definition: ed4_awars.hxx:74
void ED4_toggle_detailed_column_stats(AW_window *aww)
double AW_pos
Definition: aw_base.hxx:29
void GDE_load_menu(AW_window *awm, AW_active, const char *menulabel)
Definition: GDE.cxx:433
void aw_clear_message_cb(AW_window *aww)
Definition: AW_status.cxx:747
WindowCallback makeHelpCallback(const char *helpfile)
Definition: aw_window.hxx:106
const char * ED4_propertyName(int mode)
Definition: ED4_main.cxx:403
ED4_species_name_terminal * ED4_find_species_or_SAI_name_terminal(const char *species_name)
Definition: ED4_root.cxx:885
static ARB_ERROR request_terminal_refresh(ED4_base *base, ED4_level lev)
Definition: ED4_root.cxx:76
void append_member(ED4_base *new_member)
fflush(stdout)
void calc_no_of_all(const char *string_to_scan, long *group, long *species)
static char * get_group_consensus(const char *species_name, PosRange range)
Definition: ED4_root.cxx:898
AW_window * ED4_create_saveConfigurationAs_window(AW_root *awr)
void FastAligner_set_reference_species(AW_root *root)
bool inside_species_seq_manager() const
Definition: ed4_class.hxx:1848
int is_abstract_group_manager() const
Definition: ed4_class.hxx:1112
ED4_window * next
Definition: ed4_class.hxx:711
ED4_returncode
Definition: ed4_defs.hxx:161
AW_window * ED4_CreateProteinViewer_window(AW_root *aw_root)
GB_ERROR ED4_pfold_set_SAI(char **protstruct, GBDATA *gb_main, const char *alignment_name, long *protstruct_len)
Sets the reference protein secondary structure SAI.
T * elem() const
Definition: ed4_list.hxx:25
void show_sina_window(UNFIXED, const AlignDataAccess *alignData)
AW_window * ED4_create_loadConfiguration_window(AW_root *awr)
void aw_popup_ok(const char *msg)
ED4_returncode add_to_selected(ED4_species_name_terminal *object)
Definition: ED4_root.cxx:380
static void ED4_undo_redo(AW_window *aww, GB_UNDO_TYPE undo_type)
Definition: ED4_root.cxx:996
Generic smart pointer.
Definition: smartptr.h:149
LoadableSaiState loadable_SAIs
Definition: ed4_class.hxx:1463
void ED4_toggle_block_type()
Definition: ED4_block.cxx:361
virtual void request_refresh(int clear=1)=0
ED4_root(int *argc, char ***argv)
Definition: ED4_root.cxx:1918
char * alignment_name
Definition: ed4_class.hxx:1440
GB_BUFFER GB_give_buffer(size_t size)
Definition: arbdb.cxx:304
#define false
Definition: ureadseq.h:13
void create_menu(const char *name, const char *mnemonic, AW_active mask=AWM_ALL)
Definition: AW_window.cxx:469
ED4_window * first_window
Definition: ed4_class.hxx:1427
AW_window * AW_create_gc_window(AW_root *aw_root, AW_gc_manager *gcman)
Definition: AW_preset.cxx:1373
void help_text(const char *id)
Definition: AW_window.cxx:113
static char const * macro_name
Definition: mkptypes.cxx:81
static ARB_ERROR ED4_with_all_loaded_species(const ED4_Species_Callback &cb)
Definition: ED4_root.cxx:861
int size() const
Definition: ed4_list.hxx:47
static void error(const char *msg)
Definition: mkptypes.cxx:96
void init(AW_root *root, const char *wid, const char *windowname, int width, int height)
Definition: AW_window.cxx:2374
void STAT_destroy_ST_ML(ST_ML *&st_ml)
Definition: ST_window.cxx:113
ED4_cursor cursor
Definition: ed4_class.hxx:727
AW_window * AW_preset_window(AW_root *root)
Definition: AW_preset.cxx:1920
void mark_compile_needed_force()
AW_window * ED4_create_seq_colors_window(AW_root *awr, ED4_seq_colors *sc)
GBDATA * GB_searchOrCreate_int(GBDATA *gb_container, const char *fieldpath, long default_value)
Definition: adquery.cxx:569
#define ED4_AWAR_DIGITS_AS_REPEAT
Definition: ed4_awars.hxx:27
void insert_help_topic(const char *labeli, const char *mnemonic, const char *helpText, AW_active mask, const WindowCallback &cb)
Definition: AW_window.cxx:566
#define that(thing)
Definition: test_unit.h:1032
void ED4_no_dangerous_modes()
Definition: ED4_root.cxx:1200
ED4_root_group_manager * root_group_man
Definition: ed4_class.hxx:1431
void announce_useraction_in(AW_window *aww)
Definition: ED4_root.cxx:372
bool ED4_get_selected_range(ED4_terminal *term, PosRange &range)
Definition: ED4_block.cxx:351
#define CHARACTEROFFSET
Definition: ed4_defs.hxx:111
GB_alignment_type GBT_get_alignment_type(GBDATA *gb_main, const char *aliname)
Definition: adali.cxx:740
ARB_ERROR route_down_hierarchy(const ED4_route_cb &cb) FINAL_OVERRIDE
Definition: ED4_base.cxx:390
void init(const char *seq, int size)
Definition: BI_basepos.hxx:109
ED4_main_manager * main_manager
Definition: ed4_class.hxx:1428
ED4_species_name_terminal * ED4_find_SAI_name_terminal(const char *sai_name)
Definition: ED4_root.cxx:893
const T * content() const
convert SmartPtr to plain old pointer (also works if isNull())
Definition: smartptr.h:263
static void ED4_menu_perform_block_operation(AW_window *, ED4_blockoperation_type type)
Definition: ED4_root.cxx:1186
UserActionTracker * need_macro_ability()
Definition: trackers.cxx:450
GB_ERROR GB_write_security_write(GBDATA *gbd, unsigned long level)
Definition: arbdb.cxx:1558
static WindowCallback simple(void(*root_cb)(AW_root *, T), T t)
Definition: rootAsWin.h:47
static char * detectProperties()
Definition: ED4_root.cxx:1900
static void modes_cb(AW_window *, ED4_species_mode smode)
Definition: ED4_root.cxx:1190
AW_awar * awar(const char *awar)
Definition: AW_root.cxx:554
GB_ERROR GB_pop_transaction(GBDATA *gbd)
Definition: arbdb.cxx:2488
void ED4_get_and_jump_to_current(AW_window *)
Definition: ED4_cursor.cxx:670
void insert_sub_menu(const char *name, const char *mnemonic, AW_active mask=AWM_ALL)
Definition: AW_window.cxx:642
void ED4_exit() __ATTR__NORETURN
#define INSERT_SEARCH_FIELDS(Short, label_prefix, prefix)
Definition: arbdb.h:86
ED4_scroll_links scroll_links
Definition: ed4_class.hxx:1434
AW_option_menu_struct * create_option_menu(const char *awar_name, bool fallback2default)
AW_pos drag_old_y
Definition: ed4_defs.hxx:249
GBDATA * GBT_find_sequence(GBDATA *gb_species, const char *aliname)
Definition: adali.cxx:670
AW_window * create_naligner_window(AW_root *root)
ED4_list_elem * next() const
Definition: ed4_list.hxx:24
AW_window * ED4_create_loadSAI_window(AW_root *awr)
GB_alignment_type alignment_type
Definition: ed4_class.hxx:1441
static char * cat(char *toBuf, const char *s1, const char *s2)
Definition: ED4_root.cxx:1032
static AW_window * ED4_zoom_message_window(AW_root *root)
Definition: ED4_root.cxx:1011
GB_ERROR GB_write_int(GBDATA *gbd, long i)
Definition: arbdb.cxx:1220
ED4_extension extension
Definition: ed4_class.hxx:929
#define is_equal_to(val)
Definition: test_unit.h:1014
AW_window * ED4_create_nds_window(AW_root *root)
Definition: ED4_nds.cxx:111
void selected_species_mark(bool mark)
ED4_blocktype ED4_getBlocktype()
Definition: ED4_block.cxx:359
void insert_default_option(AW_label choice_label, const char *mnemonic, const char *var_value, const char *name_of_color=NULp)
int TERMINAL_HEIGHT
Definition: ED4_main.cxx:51
GB_ERROR GB_undo(GBDATA *gb_main, GB_UNDO_TYPE type) __ATTR__USERESULT
Definition: adindex.cxx:752
void ED4_calc_terminal_extentions()
ED4_multi_species_manager * get_multi_species_manager() const
Definition: ed4_class.hxx:1589
#define AWAR_EDITOR_ALIGNMENT
void copy_window_struct(ED4_window *source, ED4_window *destination)
Definition: ED4_root.cxx:811
void set_info_area_height(int height)
Definition: AW_window.cxx:793
Definition: ed4_defs.hxx:247
void create_input_field(const char *awar_name, int columns=0)
Definition: AW_button.cxx:855
void ED4_popup_dot_missing_bases_window(AW_window *editor_window)
Definition: ED4_dots.cxx:233
AW_active sina_mask(AW_root *root)
ED4_base * search_spec_child_rek(ED4_level level)
Definition: ED4_base.cxx:432
void resize_all_requesting_childs()
Definition: ED4_root.cxx:454
void AWT_trigger_remote_action(UNFIXED, GBDATA *gb_main, const char *remote_action_spec)
void set_bottom_area_height(int height)
Definition: AW_window.cxx:798
ED4_cursor & current_cursor()
Definition: ed4_class.hxx:1405
AW_awar * awar_int(const char *var_name, long default_value=0, AW_default default_file=AW_ROOT_DEFAULT)
Definition: AW_root.cxx:580
long protstruct_len
Definition: ed4_class.hxx:1451
#define AWAR_EDIT_MODE
Definition: ed4_defs.hxx:92
void auto_space(int xspace, int yspace)
Definition: AW_at.cxx:259
#define IF_ASSERTION_USED(x)
Definition: arb_assert.h:308
int MAXSEQUENCECHARACTERLENGTH
Definition: ED4_main.cxx:56
void ED4_init_notFoundMessage()
Definition: ED4_cursor.cxx:564
GB_ERROR close(GB_ERROR error)
Definition: arbdbpp.cxx:32
void AW_help_entry_pressed(AW_window *aww)
Definition: AW_root.cxx:37
AW_pos drag_old_x
Definition: ed4_defs.hxx:249
static ARB_ERROR request_sequence_refresh(ED4_base *base, bool consensi)
Definition: ED4_root.cxx:92
void ED4_restore_curpos(AW_window *aww)
#define AWAR_ERROR_MESSAGES
AW_pos drag_off_x
Definition: ed4_defs.hxx:248
static void title_mode_changed(AW_root *aw_root, AW_window *aww)
Definition: ED4_root.cxx:985
void ED4_store_curpos(AW_window *aww)
bool has_elem(const T *elem) const
Definition: ed4_list.hxx:98
AW_window * FastAligner_create_window(AW_root *root, const AlignDataAccess *data_access)
void GB_touch(GBDATA *gbd)
Definition: arbdb.cxx:2766
const ED4_folding_line * get_next() const
Definition: ed4_class.hxx:311
void ED4_popup_gc_window(AW_window *awp, AW_gc_manager *gcman)
Definition: ED4_root.cxx:1255
int ED4_encodeSearchDescriptor(int direction, ED4_SearchPositionType pattern)
Definition: ed4_search.hxx:50
ARB_ERROR FastAligner_delete_temp_entries(GBDATA *gb_species, const char *alignment)
static char * get_helix_string(GBDATA *gb_main, const char *alignment_name)
Definition: ED4_root.cxx:1206
char * GB_read_string(GBDATA *gbd)
Definition: arbdb.cxx:879
void GBK_dump_backtrace(FILE *out, const char *message)
Definition: arb_msg.cxx:428
ED4_window * current_ed4w()
Definition: ed4_class.hxx:1403
BI_ecoli_ref * ecoli_ref
Definition: ed4_class.hxx:1439
ED4_seq_colors * sequence_colors
Definition: ed4_class.hxx:1443
void registerFont(AW_device *device_, int gc, const char *chars=NULp)
bool move_cursor
Definition: ED4_main.cxx:69
DECLARE_CBTYPE_FVV_AND_BUILDERS(ED4_Species_Callback, ARB_ERROR, GBDATA *)
AW_root * aw_root
Definition: ed4_class.hxx:1424
int slider_pos_vertical
Definition: ed4_class.hxx:713
void close_sub_menu()
Definition: AW_window.cxx:483
void ED4_resize_all_extensions()
static bool is_species_named(ED4_base *base, const char *species_name)
Definition: ED4_root.cxx:877
ED4_list_elem< T > * head() const
Definition: ed4_list.hxx:45
static void ED4_set_protection(AW_window *aww, int wanted_protection)
Definition: ED4_root.cxx:1073
bool ok() const
Definition: chartable.cxx:1148
void ED4_reloadConfiguration(AW_window *aww)
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
void select_all(bool only_species)
void ED4_set_helixnr(AW_window *aww, const char *awar_name)
ED4_index pixel2pos(AW_pos click_x)
Definition: ED4_root.cxx:1887
void AW_save_specific_properties(AW_window *aw, const char *filename)
Definition: AW_preset.cxx:1448
void insert_macro_menu_entry(AW_window *awm, bool prepend_separator)
Definition: macro_gui.cxx:171
AW_window * ED4_createVisualizeSAI_window(AW_root *aw_root)
AW_root * get_root()
Definition: aw_window.hxx:348
static void ED4_remove_faligner_entries()
Definition: ED4_root.cxx:952
AW_window * create_helix_props_window(AW_root *awr, const WindowCallback *refreshCallback)
Definition: AW_helix.cxx:186
char * GBT_get_default_helix(GBDATA *)
Definition: adtools.cxx:64
ED4_returncode refresh_all_windows(bool redraw)
Definition: ED4_root.cxx:168
long max_seq_terminal_length
Definition: ED4_main.cxx:66
AW_window_simple * win
#define NULp
Definition: cxxforward.h:97
AW_window * create_first_window()
Definition: ED4_root.cxx:1867
bool GB_is_regularfile(const char *path)
Definition: arb_file.cxx:76
static void ED4_save_properties(AW_window *aw, int mode)
Definition: ED4_root.cxx:1251
void create_text_toggle(const char *var_name, const char *noText, const char *yesText, int buttonWidth=0)
Definition: AW_button.cxx:831
GBDATA * GBT_find_species(GBDATA *gb_main, const char *name)
Definition: aditem.cxx:136
const ED4_remap * remap() const
Definition: ed4_class.hxx:1783
ED4_blockoperation_type
Definition: ed4_block.hxx:22
static GBDATA * get_first_selected_species(int *total_no_of_selected_species)
Definition: ED4_root.cxx:931
AW_default props_db
Definition: ed4_class.hxx:1425
void request_refresh_for_sequence_terminals()
Definition: ED4_root.cxx:106
static AW_window * ED4_create_faligner_window(AW_root *awr, const AlignDataAccess *data_access)
Definition: ED4_root.cxx:1238
void ED4_saveConfiguration(AW_window *aww, bool hide_aww)
char * GBT_get_default_alignment(GBDATA *gb_main)
Definition: adali.cxx:675
void sep______________()
Definition: AW_window.cxx:750
bool is_hidden
Definition: ed4_class.hxx:726
ED4_species_mode species_mode
Definition: ed4_class.hxx:1437
static int no_of_windows
Definition: ed4_class.hxx:718
const char * local_id(const char *id) const
Definition: AW_window.cxx:744
void remove_elem(const T *elem)
Definition: ed4_list.hxx:75
void GBT_mark_all(GBDATA *gb_main, int flag)
Definition: aditem.cxx:291
void ED4_start_plugin(AW_window *aw, GBDATA *gb_main, const char *pluginname)
#define is_more_or_equal(val)
Definition: test_unit.h:1024
AW_window_menu_modes * aww
Definition: ed4_class.hxx:710
GB_transaction ta(gb_var)
void callback(const WindowCallback &cb)
Definition: AW_window.cxx:130
ED4_returncode create_hierarchy(const char *area_string_middle, const char *area_string_top)
Definition: ED4_root.cxx:549
const AlignDataAccess * ED4_get_aligner_data_access()
Definition: ED4_root.cxx:1221
GB_CSTR GB_read_char_pntr(GBDATA *gbd)
Definition: arbdb.cxx:874
GBDATA * gb_main
Definition: adname.cxx:33
MenuSelectType
Definition: ED4_root.cxx:1096
AW_awar * awar_string(const char *var_name, const char *default_value="", AW_default default_file=AW_ROOT_DEFAULT)
Definition: AW_root.cxx:570
void prepend_elem(T *elem)
Definition: ed4_list.hxx:62
ED4_SearchPositionType
Definition: ed4_search.hxx:34
void request_refresh_for_consensus_terminals()
Definition: ED4_root.cxx:103
GBDATA * GBT_get_SAI_data(GBDATA *gb_main)
Definition: aditem.cxx:152
int is_terminal() const
Definition: ed4_class.hxx:1081
GBDATA * GB_search(GBDATA *gbd, const char *fieldpath, GB_TYPES create)
Definition: adquery.cxx:531
ARB_ERROR init_alignment()
Definition: ED4_root.cxx:503
void shadow_width(int shadow_thickness)
Definition: AW_window.cxx:1075
GB_CB_TYPE
Definition: arbdb_base.h:46
int get_max_height() const
int MAXINFO_WIDTH
Definition: ED4_main.cxx:58
AW_window * ED4_create_consensus_definition_window(AW_root *root)
ED4_manager * get_parent(ED4_level lev) const
Definition: ed4_class.hxx:1823
void ED4_helix_jump_opposite(AW_window *aww)
static void toggle_helix_for_SAI(AW_window *aww)
Definition: ED4_root.cxx:958
AW_window * ED4_create_replace_window(AW_root *root)
Definition: ED4_block.cxx:685
AW_window * ED4_create_editor_options_window(AW_root *root)
#define HEIGHT
Definition: ed4_defs.hxx:76
static ED4_WinContext current_context
Definition: ed4_class.hxx:1388
void ED4_alignment_length_changed(GBDATA *gb_alignment_len, GB_CB_TYPE gbtype)
Definition: ED4_root.cxx:468
#define AW_ROOT_DEFAULT
Definition: aw_base.hxx:106
int old_event_y
Definition: ed4_defs.hxx:251
AW_pos actual_height
Definition: ed4_defs.hxx:250
void ED4_set_col_stat_threshold()
const char * ED4_SearchPositionTypeId[SEARCH_PATTERNS+1]
Definition: ED4_search.cxx:35
long ED4_index
Definition: ed4_defs.hxx:115
void ED4_perform_block_operation(ED4_blockoperation_type operationType)
Definition: ED4_block.cxx:882
ST_ML * st_ml
Definition: ed4_class.hxx:1445
void create_text_field(const char *awar_name, int columns=20, int rows=4)
Definition: AW_button.cxx:985
void aw_message_if(GB_ERROR error)
Definition: aw_msg.hxx:21
char * GBS_global_string_copy(const char *templat,...)
Definition: arb_msg.cxx:195
Adds support for protein structure prediction, comparison of two protein secondary structures and of ...
void create_button(const char *macro_name, AW_label label, const char *mnemonic=NULp, const char *color=NULp)
Definition: AW_button.cxx:446
void ED4_finish_and_show_notFoundMessage()
Definition: ED4_cursor.cxx:569
GB_write_int const char s
Definition: AW_awar.cxx:156