source: tags/arb_5.1/EDIT4/EDB_root_bact.cxx

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