source: tags/arb-6.0/EDIT4/EDB_root_bact.cxx

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