source: tags/ms_r16q2/EDIT4/EDB_root_bact.cxx

Last change on this file was 14425, checked in by westram, 8 years ago
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 28.6 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : EDB_root_bact.cxx                                 //
4//   Purpose   :                                                   //
5//                                                                 //
6//   Institute of Microbiology (Technical University Munich)       //
7//   http://www.arb-home.de/                                       //
8//                                                                 //
9// =============================================================== //
10
11#include <ed4_extern.hxx>
12#include "ed4_class.hxx"
13
14#include <aw_msg.hxx>
15#include <arb_progress.h>
16#include <arbdbt.h>
17#include <arb_strbuf.h>
18#include <ad_config.h>
19
20#define NAME_BUFFERSIZE 100
21
22void EDB_root_bact::calc_no_of_all(const char *string_to_scan, long *group, long *species) {
23    *group = 0;
24    *species = 0;
25
26    if (string_to_scan) {
27        long i = 0;
28        while (string_to_scan[i]) {
29            if (string_to_scan[i] == 1) {
30                if (string_to_scan[i+1] == 'L' || string_to_scan[i+1] == 'S') {
31                    (*species)++;
32                    i++;
33                }
34                else if (string_to_scan[i+1] == 'F' || string_to_scan[i+1] == 'G') {
35                    (*group)++;
36                    i++;
37                }
38            }
39            i++;
40        }
41    }
42}
43
44ED4_returncode EDB_root_bact::fill_data(ED4_multi_species_manager  *multi_species_manager,
45                                        ED4_sequence_info_terminal *ref_sequence_info_terminal,
46                                        ED4_sequence_terminal      *ref_sequence_terminal,
47                                        char                       *str,
48                                        ED4_index                  *y,
49                                        ED4_index                   curr_local_position,
50                                        ED4_index                  *length_of_terminals,
51                                        int                         group_depth,
52                                        ED4_datamode                datamode)
53{
54    GBDATA *gb_datamode = NULL;
55    switch (datamode) {
56        case ED4_D_EXTENDED: gb_datamode = GBT_find_SAI(GLOBAL_gb_main, str); break;
57        case ED4_D_SPECIES:  gb_datamode = GBT_find_species(GLOBAL_gb_main, str); break;
58    }
59
60    if (!gb_datamode) { // didn't find this species
61        not_found_counter++;
62        if (not_found_counter <= MAX_SHOWN_MISSING_SPECIES) {
63            char dummy[150];
64            sprintf(dummy, "%zu. %s\n", not_found_counter, str);
65            e4_assert(not_found_message);
66            GBS_strcat(not_found_message, dummy);
67        }
68        return ED4_R_BREAK;
69    }
70
71    // check whether sequence has data in desired alignment
72    bool has_alignment = 0 != GB_entry(gb_datamode, ED4_ROOT->alignment_name);
73    if (!has_alignment) {
74        if (datamode == ED4_D_SPECIES) { // only warn about species w/o data (SAIs are skipped silently)
75            not_found_counter++;
76            if (not_found_counter <= MAX_SHOWN_MISSING_SPECIES) {
77                char dummy[150];
78                sprintf(dummy, "%zu. %s (no data in alignment)\n", not_found_counter, str);
79                GBS_strcat(not_found_message, dummy);
80            }
81        }
82        return ED4_R_BREAK;
83    }
84
85    const ED4_index  terminal_height      = TERMINALHEIGHT;
86    ED4_index        local_count_position = curr_local_position;
87    ED4_species_type spec_type            = (datamode == ED4_D_EXTENDED) ? ED4_SP_SAI : ED4_SP_SPECIES;
88
89
90    {
91        char namebuffer[NAME_BUFFERSIZE];
92        int count_two = 0;
93
94        sprintf(namebuffer, "Species_Manager.%ld.%d", ED4_counter, count_two);
95        ED4_species_manager *species_manager = new ED4_species_manager(spec_type, namebuffer, 0, local_count_position, 0, 0, multi_species_manager);
96
97        species_manager->set_property(ED4_P_MOVABLE);
98        if (spec_type == ED4_SP_SAI) {
99            ED4_abstract_group_manager *group_man = species_manager->get_parent(ED4_level(ED4_L_GROUP|ED4_L_ROOTGROUP))->to_abstract_group_manager();
100            group_man->table().ignore_me(); // ignore SAI tables (does not work - instead ignore SAIs when calculating consensus)
101        }
102        species_manager->set_species_pointer(gb_datamode);
103        multi_species_manager->children->append_member(species_manager);
104
105        sprintf(namebuffer, "MultiName_Manager.%ld.%d", ED4_counter, count_two);
106        ED4_multi_name_manager *multi_name_manager = new ED4_multi_name_manager(namebuffer, 0, 0, 0, 0, species_manager);
107        species_manager->children->append_member(multi_name_manager);
108
109        sprintf(namebuffer, "MultiSeq_Manager.%ld.%d", ED4_counter, count_two++);
110        ED4_multi_sequence_manager *multi_sequence_manager = new ED4_multi_sequence_manager(namebuffer, MAXSPECIESWIDTH-(group_depth*BRACKETWIDTH), 0, 0, 0, species_manager);
111        species_manager->children->append_member(multi_sequence_manager);
112       
113        sprintf(namebuffer, "Name_Manager%ld.%d", ED4_counter, count_two++);                          // hier fehlt noch y
114        ED4_name_manager *name_manager = new ED4_name_manager(namebuffer, 0, 0*terminal_height, 0, 0, multi_name_manager);            // hier fehlt noch y
115        name_manager->set_property(ED4_P_MOVABLE);                            // only Speciesname should be movable !!!!
116        multi_name_manager->children->append_member(name_manager);
117
118        {
119            sprintf(namebuffer, "Species_Name_Term%ld.%d", ED4_counter, count_two++);
120            ED4_species_name_terminal *species_name_terminal = new ED4_species_name_terminal(namebuffer, 0, 0, MAXSPECIESWIDTH-(group_depth*BRACKETWIDTH), terminal_height, name_manager);
121            species_name_terminal->set_property((ED4_properties) (ED4_P_SELECTABLE | ED4_P_DRAGABLE | ED4_P_IS_HANDLE));
122            species_name_terminal->set_links(NULL, ref_sequence_terminal);
123            species_name_terminal->set_species_pointer(GB_entry(gb_datamode, "name"));
124            name_manager->children->append_member(species_name_terminal);
125        }
126
127        {
128            ED4_index name_coords = terminal_height;
129            ED4_index seq_coords  = 0;
130
131            search_sequence_data_rek(multi_sequence_manager, ref_sequence_info_terminal, ref_sequence_terminal, gb_datamode,
132                                     count_two, &seq_coords, &max_seq_terminal_length, ED4_A_DEFAULT, datamode == ED4_D_EXTENDED);
133
134            local_count_position += std::max(name_coords, seq_coords);
135        }
136    }
137
138    if (!(multi_species_manager->flag.hidden)) {
139        *length_of_terminals = local_count_position-curr_local_position;
140        *y += *length_of_terminals; // needed for global coordinates of manager
141    }
142
143    return ED4_R_OK;
144}
145
146ED4_returncode EDB_root_bact::search_sequence_data_rek(ED4_multi_sequence_manager *multi_sequence_manager,
147                                                       ED4_sequence_info_terminal *ref_sequence_info_terminal,
148                                                       ED4_sequence_terminal      *ref_sequence_terminal,
149                                                       GBDATA                     *gb_datamode,
150                                                       int                         count_too,
151                                                       ED4_index                  *seq_coords,
152                                                       ED4_index                  *max_sequence_terminal_length,
153                                                       ED4_alignment               alignment_flag,
154                                                       bool                        isSAI)
155{
156    AW_device *device;
157    int        j          = 0;
158    int        pixel_length;
159    GBDATA    *gb_ali_xxx = NULL;
160    GBDATA    *gb_alignment;
161    long       string_length;
162    char       namebuffer[NAME_BUFFERSIZE];
163
164    device = ED4_ROOT->first_window->get_device();
165
166    if (alignment_flag == ED4_A_DEFAULT) {
167        gb_ali_xxx = GB_entry(gb_datamode, ED4_ROOT->alignment_name);
168    }
169    else if (alignment_flag == ED4_A_CONTAINER) {
170        gb_ali_xxx = gb_datamode;
171    }
172    if (!gb_ali_xxx) return ED4_R_OK;
173
174    j=0;
175    for (gb_alignment = GB_child(gb_ali_xxx); gb_alignment; gb_alignment = GB_nextChild(gb_alignment)) {
176        GB_TYPES type = GB_read_type(gb_alignment);
177
178        if (type == GB_INTS || type == GB_FLOATS) {
179            continue;
180        }
181
182        if (type == GB_DB) {  // we have to unpack container
183            search_sequence_data_rek(multi_sequence_manager, ref_sequence_info_terminal, ref_sequence_terminal,
184                                     gb_alignment, count_too, seq_coords, max_sequence_terminal_length, ED4_A_CONTAINER, isSAI);
185        }
186        else { // otherwise we enter the data
187            char *key_string = GB_read_key(gb_alignment);
188            if (key_string[0] != '_') { // don't show sequences starting with an underscore
189                sprintf(namebuffer, "Sequence_Manager.%ld.%d", ED4_counter, count_too++);
190                ED4_sequence_manager *seq_manager = new ED4_sequence_manager(namebuffer, 0, j*TERMINALHEIGHT, 0, 0, multi_sequence_manager);
191                seq_manager->set_property(ED4_P_MOVABLE);
192                multi_sequence_manager->children->append_member(seq_manager);
193
194                ED4_sequence_info_terminal *sequence_info_terminal =
195                    new ED4_sequence_info_terminal(key_string, 0, 0, SEQUENCEINFOSIZE, TERMINALHEIGHT, seq_manager);
196                sequence_info_terminal->set_property((ED4_properties) (ED4_P_SELECTABLE | ED4_P_DRAGABLE | ED4_P_IS_HANDLE));
197                sequence_info_terminal->set_links(ref_sequence_info_terminal, ref_sequence_info_terminal);
198                sequence_info_terminal->set_species_pointer(gb_alignment);
199                seq_manager->children->append_member(sequence_info_terminal);
200
201                ED4_text_terminal *text_terminal = 0;
202
203                bool is_data    = false;
204                bool is_data2   = false;
205                bool is_bits    = false;
206                bool is_quality = false;
207
208                if      (strcmp(key_string, "data")    == 0) is_data    = true; // SAI or species
209                else if (strcmp(key_string, "data2")   == 0) is_data2   = true; // used by SAIs with two entries (e.g. first and second digit of 2-digit-numbers)
210                else if (strcmp(key_string, "bits")    == 0) is_bits    = true; // used by binary SAIs (e.g. MARKERLINE)
211                else if (strcmp(key_string, "quality") == 0) is_quality = true; // used by "quality" entry written by chimera check; see ../STAT/ST_quality.cxx@chimera_check_quality_string
212
213                bool is_aligned = is_data || is_data2 || is_bits || is_quality;
214
215                if (is_aligned) {
216                    bool shall_display_secinfo = is_data;
217
218                    if (isSAI) {
219                        GBDATA *gb_sai        = GB_get_grandfather(gb_alignment);
220                        GBDATA *gb_disp_sec   = GB_searchOrCreate_int(gb_sai, "showsec", 0);
221                        shall_display_secinfo = GB_read_int(gb_disp_sec);
222                    }
223
224                    sprintf(namebuffer, "Sequence_Term%ld.%d", ED4_counter, count_too++);
225                    ED4_sequence_terminal *seq_term = new ED4_sequence_terminal(namebuffer, SEQUENCEINFOSIZE, 0, 0, TERMINALHEIGHT, seq_manager, shall_display_secinfo);
226                    seq_term->species_name          = seq_term->get_name_of_species();
227
228                    if (is_data) seq_term->set_property(ED4_P_CONSENSUS_RELEVANT);
229                    seq_term->set_property(ED4_P_ALIGNMENT_DATA);
230
231                    text_terminal = seq_term;
232                }
233                else {
234                    sprintf(namebuffer, "PureText_Term%ld.%d", ED4_counter, count_too++);
235                    text_terminal = new ED4_pure_text_terminal(namebuffer, SEQUENCEINFOSIZE, 0, 0, TERMINALHEIGHT, seq_manager);
236                }
237
238                text_terminal->set_property(ED4_P_CURSOR_ALLOWED);
239                text_terminal->set_links(ref_sequence_terminal, ref_sequence_terminal);
240                seq_manager->children->append_member(text_terminal);
241#if defined(DEBUG)
242                // ensure only 1 terminal is consensus-relevant!
243                if (is_data) {
244                    seq_manager->get_consensus_relevant_terminal(); // does an error otherwise!
245                }
246#endif // DEBUG
247                text_terminal->set_species_pointer(gb_alignment);
248
249                if (gb_alignment) {
250                    string_length = GB_read_count(gb_alignment);
251                }
252                else {
253                    string_length = 100;
254                }
255
256                pixel_length = device->get_string_size(ED4_G_SEQUENCES, NULL, string_length) + 100;
257
258                *max_sequence_terminal_length = std::max(*max_sequence_terminal_length, long(pixel_length));
259                text_terminal->extension.size[WIDTH] = pixel_length;
260
261                if (MAXSEQUENCECHARACTERLENGTH < string_length) {
262                    MAXSEQUENCECHARACTERLENGTH = string_length;
263                    ref_sequence_terminal->extension.size[WIDTH] = pixel_length;
264                }
265
266                if (!ED4_ROOT->scroll_links.link_for_hor_slider) {
267                    ED4_ROOT->scroll_links.link_for_hor_slider = text_terminal;
268                }
269                else if (*max_sequence_terminal_length > ED4_ROOT->scroll_links.link_for_hor_slider->extension.size[WIDTH]) {
270                    ED4_ROOT->scroll_links.link_for_hor_slider = text_terminal;
271                }
272
273                *seq_coords += TERMINALHEIGHT;
274                j++;
275            }
276            free(key_string);
277        }
278    }
279
280    return ED4_R_OK;
281}
282
283
284char* EDB_root_bact::make_string()
285{
286    const char *sep_name     = "\1"; // Trennzeichen
287    char*       configstring = new char[500];
288
289    strcpy(configstring, sep_name);
290
291    strcat(configstring, "FGruppe1lang");
292    strcat(configstring, sep_name);
293    strcat(configstring, "SHELIX_PAIRS");
294    strcat(configstring, sep_name);
295    strcat(configstring, "SHELIX_LINE");
296    strcat(configstring, sep_name);
297    strcat(configstring, "E");
298    strcat(configstring, sep_name);
299    strcat(configstring, "GFltDorot");  // Speciesmark L
300    strcat(configstring, sep_name);
301    strcat(configstring, "LCasElega");
302    strcat(configstring, sep_name);
303    strcat(configstring, "E");
304    strcat(configstring, sep_name);
305    strcat(configstring, "LBaeFrag3");
306    strcat(configstring, sep_name);
307    strcat(configstring, "LFlaFerr2");
308    strcat(configstring, sep_name);
309    strcat(configstring, "LCytLyti3");
310    strcat(configstring, "\0");
311
312    return configstring;
313}
314
315char* EDB_root_bact::make_top_bot_string()          // is only called when started manually
316{
317    char* configstring;
318    configstring = new char[400];
319    sprintf(configstring, "%cFSAI's%cSHELIX_PAIRS%cSHELIX_LINE%cSALI_ERR%cSALI_CON%cSALI_INT%cSALI_BIND%cSantibiot%cSmodnuc%cSelong%cStRNA%cSALI_BOR%cSALI_PRE_I%cSALI_PRE%cSALI_INSERTS%cSinseuca2%cSregaps%cSallr5%cSbacr5%cSarcr5%cSeucr5%cSgplr5%cSinsEuca%cSprimer1%cSprimer2%cSbetar5%cSprimer3%cE", 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
320
321    strcat(configstring, "\0");
322
323    return configstring;
324}
325
326
327ED4_returncode  EDB_root_bact::fill_species(ED4_multi_species_manager  *multi_species_manager,
328                                            ED4_sequence_info_terminal *ref_sequence_info_terminal,
329                                            ED4_sequence_terminal      *ref_sequence_terminal,
330                                            const char                 *str,
331                                            int                        *index,
332                                            ED4_index                  *y,
333                                            ED4_index                   curr_local_position,
334                                            ED4_index                  *length_of_terminals, // height of terminals is meant
335                                            int                         group_depth,
336                                            arb_progress               *progress)
337{
338#define SHIPSIZE 1024
339
340    int  lauf = 0;
341    bool word = 0;
342
343    ED4_index height_of_created_terminals = 0;
344
345    ED4_datamode datamode  = ED4_D_SPECIES;
346    ED4_returncode retCode = ED4_R_OK;
347
348    char      *ship                 = (char*)GB_calloc(SHIPSIZE, sizeof(*ship));
349    ED4_index  local_count_position = curr_local_position;
350
351    do {
352        if (word == 0) { // word is needed for jump over separator
353            if (str[(*index)+1] == 'L') {
354                datamode = ED4_D_SPECIES;
355            }
356            else if (str[(*index)+1] == 'S') {
357                datamode = ED4_D_EXTENDED;
358            }
359            else {
360
361                const char *entry = str+*index+1;
362                char        tag   = entry[0];
363                const char *sep   = strchr(entry, 1);
364
365                if (sep) {
366                    int   len     = sep-entry+1;
367                    char *content = (char*)GB_calloc(len+1, 1);
368                    memcpy(content, entry+1, len);
369
370                    char *message = GBS_global_string_copy("Unknown or misplaced tag-id '%c' (with content '%s'). Error in configuration-data!\nTrying to continue..", tag, content);
371                    fprintf(stderr, "ARB_EDIT4: %s\n", message);
372                    aw_message(message);
373
374                    free(message);
375                    free(content);
376                    retCode = ED4_R_WARNING;
377
378                    (*index) += sep-entry+1; // set index to next separator
379                    continue;
380                }
381                else {
382                    fprintf(stderr, "Error reading configuration: Unexpected end of data (at '%s')\n", str+*index);
383
384                    e4_assert(0);
385                    retCode = ED4_R_ERROR;
386                    break;
387                }
388                e4_assert(0); // never reached!
389            }
390
391            (*index) += 2;
392        }
393
394        if (str[*index] != 1) {
395            ship[lauf++] = str[*index];
396            word = 1;
397            (*index)++;
398        }
399
400        if (str[*index] == 1 || str[*index] == '\0') {
401            ship[lauf] = '\0'; // speciesname-generation is finished
402            lauf = 0;
403
404            if (progress) {
405                progress->inc();
406                if (progress->aborted()) ED4_exit();
407            }
408
409            fill_data(multi_species_manager, ref_sequence_info_terminal, ref_sequence_terminal, ship /* species name */,
410                      y, local_count_position, &height_of_created_terminals, group_depth, datamode);
411
412            ED4_counter++;
413            local_count_position += height_of_created_terminals;
414            *length_of_terminals += height_of_created_terminals;
415            word = 0;
416        }
417    } while (!((str[(*index)] == 1) && (str[(*index)+1] == 'G' || str[(*index)+1]=='E' || str[(*index)+1]=='F'))
418             && (str[*index] != '\0'));
419
420    free(ship);
421    return retCode;
422#undef SHIPSIZE
423}
424
425ED4_index EDB_root_bact::scan_string(ED4_multi_species_manager  *parent,
426                                     ED4_sequence_info_terminal *ref_sequence_info_terminal,
427                                     ED4_sequence_terminal      *ref_sequence_terminal,
428                                     const char                 *str,
429                                     int                        *index,
430                                     ED4_index                  *y,
431                                     arb_progress&               progress)
432{
433    ED4_multi_species_manager *multi_species_manager = NULL;
434    ED4_bracket_terminal      *bracket_terminal      = NULL;
435    ED4_spacer_terminal       *group_spacer_terminal = NULL;
436    char                       namebuffer[NAME_BUFFERSIZE];
437    char                       groupname[GB_GROUP_NAME_MAX];
438    ED4_index                  y_old                 = 0;
439    ED4_index                  lauf                  = 0;
440    ED4_index                  local_count_position  = 0;
441    ED4_index                  length_of_terminals   = 0;
442    static int                 group_depth           = 0;
443
444    if (!parent->parent->is_area_manager()) {       // add 25 if group is not child of; not the first time!
445        local_count_position = TERMINALHEIGHT + SPACERHEIGHT;   // a folded group
446    }
447
448    while (str[(*index)] != '\0' && str[(*index)+1] != 'E') { // E =
449        if (str[(*index)+1] == 'L' || str[(*index)+1] == 'S') {   // L = species, S = SAI
450            length_of_terminals = 0;
451
452            fill_species(parent, ref_sequence_info_terminal, ref_sequence_terminal, str, index,
453                         y, local_count_position, &length_of_terminals, group_depth, &progress);
454
455            local_count_position += length_of_terminals;
456            ED4_counter ++;     // counter is only needed to generate
457        }
458
459        if (str[(*index)] && (str[(*index)+1] == 'G' || str[(*index)+1] == 'F')) { // Group or folded group
460            group_depth++;
461            bool is_folded = str[(*index)+1]=='F';
462
463            for (*index += 2, lauf = 0; str[*index] != 1; (*index)++) {  // Jump over 'G' and Blank to get Groupname
464                groupname[lauf++] = str[*index];
465            }
466            groupname[lauf] = '\0';
467
468            create_group_header(parent, ref_sequence_info_terminal, ref_sequence_terminal, &multi_species_manager, &bracket_terminal,
469                                y, groupname, group_depth, is_folded, local_count_position);
470
471            y_old = local_count_position;
472            ED4_counter++;
473
474            local_count_position += scan_string(multi_species_manager, ref_sequence_info_terminal, ref_sequence_terminal, str, index, y, progress);
475            sprintf(namebuffer, "Group_Spacer_Terminal_End.%ld", ED4_counter);
476
477            local_count_position += SPACERHEIGHT;
478
479            bracket_terminal->extension.size[HEIGHT] = local_count_position - y_old;
480            group_spacer_terminal = new ED4_spacer_terminal(namebuffer, false, 0, local_count_position - y_old + SPACERHEIGHT, 10, SPACERHEIGHT, multi_species_manager);
481            bracket_terminal->set_links(NULL, multi_species_manager);
482
483            (*y) += SPACERHEIGHT;
484
485            multi_species_manager->children->append_member(group_spacer_terminal);
486
487            if (is_folded) multi_species_manager->hide_children();
488        }
489    }
490
491    if (str[(*index)] && str[(*index)+1] == 'E') {
492        (*index)+=2;
493        group_depth--;
494    }
495
496    return local_count_position;
497}
498
499ED4_returncode EDB_root_bact::create_group_header(ED4_multi_species_manager   *parent,
500                                                  ED4_sequence_info_terminal  *ref_sequence_info_terminal,
501                                                  ED4_sequence_terminal       *ref_sequence_terminal,
502                                                  ED4_multi_species_manager  **multi_species_manager,
503                                                  ED4_bracket_terminal       **bracket_terminal,
504                                                  ED4_index                   *y,
505                                                  char                        *groupname,
506                                                  int                          group_depth,
507                                                  bool                         is_folded,
508                                                  ED4_index                    local_count_position)
509{
510    const int height_terminal = TERMINALHEIGHT;
511    const int height_spacer   = SPACERHEIGHT;
512
513    char namebuffer[NAME_BUFFERSIZE];
514
515    sprintf(namebuffer, "Group_Manager.%ld", ED4_counter);                              // create new group manager
516    ED4_group_manager *group_manager = new ED4_group_manager(namebuffer, 0, local_count_position, 0, 0, parent);
517    parent->children->append_member(group_manager);
518
519    sprintf(namebuffer, "Bracket_Terminal.%ld", ED4_counter);
520    *bracket_terminal = new ED4_bracket_terminal(namebuffer, 0, 0, BRACKETWIDTH, 0, group_manager);
521    group_manager->children->append_member(*bracket_terminal);
522
523    sprintf(namebuffer, "MultiSpecies_Manager.%ld", ED4_counter);                           // create new multi_species_manager
524    *multi_species_manager = new ED4_multi_species_manager(namebuffer, BRACKETWIDTH, 0, 0, 0, group_manager);   // Objekt Gruppen name_terminal noch
525    group_manager->children->append_member(*multi_species_manager);                     // auszeichnen
526
527    if (is_folded) { // only set FOLDED-flag if group is folded
528        group_manager->set_property((ED4_properties) (ED4_P_IS_FOLDED | ED4_P_MOVABLE));
529        (*multi_species_manager)->set_property((ED4_properties) (ED4_P_IS_FOLDED | ED4_P_IS_HANDLE));
530        (*bracket_terminal)->set_property((ED4_properties) (ED4_P_IS_FOLDED | ED4_P_IS_HANDLE));
531    }
532    else {
533        group_manager->set_property(ED4_P_MOVABLE);
534        (*multi_species_manager)->set_property(ED4_P_IS_HANDLE);
535        (*bracket_terminal)->set_property(ED4_P_IS_HANDLE);
536    }
537
538    {
539        sprintf(namebuffer, "Group_Spacer_Terminal_Beg.%ld", ED4_counter);                      // Spacer at beginning of group
540        ED4_spacer_terminal *group_spacer_terminal = new ED4_spacer_terminal(namebuffer, false, 0, 0, 10, height_spacer, *multi_species_manager); // For better Overview
541        (*multi_species_manager)->children->append_member(group_spacer_terminal);
542    }
543
544    {
545        sprintf(namebuffer, "Consensus_Manager.%ld", ED4_counter);                             // Create competence terminal
546        ED4_species_manager *species_manager = new ED4_species_manager(ED4_SP_CONSENSUS, namebuffer, 0, height_spacer, 0, 0, *multi_species_manager);
547        species_manager->set_property(ED4_P_MOVABLE);
548        (*multi_species_manager)->children->append_member(species_manager);
549
550        ED4_species_name_terminal *species_name_terminal = new ED4_species_name_terminal(groupname, 0, 0, MAXSPECIESWIDTH-(group_depth*BRACKETWIDTH),   height_terminal, species_manager);
551        species_name_terminal->set_property((ED4_properties) (ED4_P_SELECTABLE | ED4_P_DRAGABLE | ED4_P_IS_HANDLE));      // only some terminals
552        species_name_terminal->set_links(NULL, ref_sequence_terminal);
553        species_manager->children->append_member(species_name_terminal);                                                  // properties
554
555        {
556            sprintf(namebuffer, "Consensus_Seq_Manager.%ld", ED4_counter);
557            ED4_sequence_manager *sequence_manager = new ED4_sequence_manager(namebuffer, MAXSPECIESWIDTH-(group_depth*BRACKETWIDTH), 0, 0, 0, species_manager);
558            sequence_manager->set_property(ED4_P_MOVABLE);
559            species_manager->children->append_member(sequence_manager);
560
561            ED4_sequence_info_terminal *sequence_info_terminal = new ED4_sequence_info_terminal("CONS", 0, 0, SEQUENCEINFOSIZE, height_terminal, sequence_manager);  // Info fuer Gruppe
562            sequence_info_terminal->set_links(ref_sequence_info_terminal, ref_sequence_info_terminal);
563            sequence_info_terminal->set_property((ED4_properties) (ED4_P_SELECTABLE | ED4_P_DRAGABLE | ED4_P_IS_HANDLE));
564            sequence_manager->children->append_member(sequence_info_terminal);
565
566            {
567                AW_device *device       = ED4_ROOT->first_window->get_device();
568                int        pixel_length = device->get_string_size(ED4_G_SEQUENCES, "whatever",   0);
569
570                sprintf(namebuffer, "Consensus_Seq_Terminal.%ld", ED4_counter);
571                ED4_sequence_terminal *sequence_terminal = new ED4_consensus_sequence_terminal(namebuffer, SEQUENCEINFOSIZE, 0, pixel_length + 10, height_terminal, sequence_manager);
572
573                sequence_terminal->set_property(ED4_P_CURSOR_ALLOWED);
574                sequence_terminal->set_links(ref_sequence_terminal, ref_sequence_terminal);
575                sequence_manager->children->append_member(sequence_terminal);
576            }
577        }
578    }
579
580    (*y) += height_terminal + height_spacer;
581
582    return ED4_R_OK;
583}
584
585void EDB_root_bact::save_current_config(char *confname) { // and save it in database
586    GB_ERROR   error;
587    GBT_config cfg(GLOBAL_gb_main, confname, error);
588    error = NULL; // ignore not-found error
589
590    int                 counter        = 0;
591    ED4_device_manager *device_manager = ED4_ROOT->get_device_manager();
592    ED4_members        *children       = device_manager->children;
593
594    for (int i=0; i<children->members(); i++) {
595        ED4_base *area = children->member(i);
596        if (area->is_area_manager()) {
597            GBS_strstruct area_config(10000);
598            area->generate_configuration_string(area_config);
599            cfg.set_definition(counter++, area_config.release());
600        }
601    }
602
603    // add/update comment
604    {
605        char *newComment = GBS_log_dated_action_to(cfg.get_comment(), "saved from ARB_EDIT4");
606        cfg.set_comment(newComment);
607        free(newComment);
608    }
609
610    error = cfg.save(GLOBAL_gb_main, confname, true);
611    aw_message_if(error);
612}
613
Note: See TracBrowser for help on using the repository browser.