source: branches/port5/EDIT4/EDB_root_bact.cxx

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