source: tags/old_import_filter/NTREE/NT_edconf.cxx

Last change on this file was 10117, checked in by westram, 11 years ago
  • fix include-chaos in NTREE
    • all headers named
      • .h (some had .hxx)
      • as .cxx file
    • removed obsolete header (NT_dbrepair.hxx, nt_join.hxx)
  • removed some more definitions of nt_assert
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 24.5 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : NT_edconf.cxx                                     //
4//   Purpose   :                                                   //
5//                                                                 //
6//   Institute of Microbiology (Technical University Munich)       //
7//   http://www.arb-home.de/                                       //
8//                                                                 //
9// =============================================================== //
10
11#include "NT_cb.h"
12#include "NT_local.h"
13
14#include <awt_sel_boxes.hxx>
15#include <aw_awars.hxx>
16#include <aw_window.hxx>
17#include <aw_root.hxx>
18#include <aw_msg.hxx>
19#include <ad_config.h>
20#include <arbdbt.h>
21#include <arb_strbuf.h>
22
23static void init_config_awars(AW_root *root) {
24    root->awar_string(AWAR_CONFIGURATION, "default_configuration", GLOBAL.gb_main);
25}
26
27// -----------------------------
28//      class Store_species
29
30class Store_species : virtual Noncopyable {
31    // stores an amount of species:
32    GBT_TREE *node;
33    Store_species *next;
34public:
35    Store_species(GBT_TREE *aNode) {
36        node = aNode;
37        next = 0;
38    }
39    ~Store_species();
40
41    Store_species* add(Store_species *list) {
42        nt_assert(next==0);
43        next = list;
44        return this;
45    }
46
47    Store_species* remove() {
48        Store_species *follower = next;
49        next = 0;
50        return follower;
51    }
52
53    GBT_TREE *getNode() const { return node; }
54
55    void call(void (*aPizza)(GBT_TREE*)) const;
56};
57
58Store_species::~Store_species() {
59    delete next;
60}
61
62void Store_species::call(void (*aPizza)(GBT_TREE*)) const {
63    aPizza(node);
64    if (next) next->call(aPizza);
65}
66
67static void unmark_species(GBT_TREE *node) {
68    nt_assert(node);
69    nt_assert(node->gb_node);
70    nt_assert(GB_read_flag(node->gb_node)!=0);
71    GB_write_flag(node->gb_node, 0);
72}
73
74static void mark_species(GBT_TREE *node, Store_species **extra_marked_species) {
75    nt_assert(node);
76    nt_assert(node->gb_node);
77    nt_assert(GB_read_flag(node->gb_node)==0);
78    GB_write_flag(node->gb_node, 1);
79
80    *extra_marked_species = (new Store_species(node))->add(*extra_marked_species);
81}
82
83
84
85static GBT_TREE *rightmost_leaf(GBT_TREE *node) {
86    nt_assert(node);
87    while (!node->is_leaf) {
88        node = node->rightson;
89        nt_assert(node);
90    }
91    return node;
92}
93
94static GBT_TREE *left_neighbour_leaf(GBT_TREE *node) {
95    if (node) {
96        GBT_TREE *father = node->father;
97        while (father) {
98            if (father->rightson==node) {
99                node = rightmost_leaf(father->leftson);
100                nt_assert(node->is_leaf);
101                if (!node->gb_node) { // Zombie
102                    node = left_neighbour_leaf(node);
103                }
104                return node;
105            }
106            node = father;
107            father = node->father;
108        }
109    }
110    return 0;
111}
112
113static int nt_build_conf_string_rek(GB_HASH *used, GBT_TREE *tree, GBS_strstruct *memfile,
114                             Store_species **extra_marked_species, int use_species_aside,
115                             int *auto_mark, int marked_at_left, int *marked_at_right)
116{
117    /*! Builds a configuration string from a tree.
118     *
119     * @param used                      all species inserted by this function are stored here
120     * @param tree                      used for group information
121     * @param memfile                   generated configuration string is stored here
122     * @param extra_marked_species      all extra marked species are inserted here
123     * @param use_species_aside         number of species to mark left and right of marked species
124     * @param auto_mark                 number species to extra-mark (if not already marked)
125     * @param marked_at_left            number of species which were marked (looking to left)
126     * @param marked_at_right           number of species which are marked (when returning from recursion)
127     *
128     * @return the number of marked species
129     *
130     * --------------------------------------------------
131     * Format of configuration string : [Part]+ \0
132     *
133     * Part : '\A' ( Group | Species | Sai )
134     *
135     * Group : ( OpenedGroup | ClosedGroup )
136     * OpenedGroup : 'G' GroupDef
137     * ClosedGroup : 'F' GroupDef
138     * GroupDef : 'groupname' [PART]* EndGroup
139     * EndGroup : '\AE'
140     *
141     * SPECIES : 'L' 'speciesname'
142     * SAI : 'S' 'sainame'
143     *
144     * \0 : ASCII 0 (eos)
145     * \A : ASCII 1
146     */
147
148    if (!tree) return 0;
149    if (tree->is_leaf) {
150        if (!tree->gb_node) {
151            *marked_at_right = marked_at_left;
152            return 0;   // Zombie
153        }
154
155        if (!GB_read_flag(tree->gb_node)) { // unmarked species
156            if (*auto_mark) {
157                (*auto_mark)--;
158                mark_species(tree, extra_marked_species);
159            }
160            else {
161                *marked_at_right = 0;
162                return 0;
163            }
164        }
165        else { // marked species
166            if (marked_at_left<use_species_aside) {
167                // on the left side there are not as many marked species as needed!
168
169                nt_assert(marked_at_left>=0);
170
171                GBT_TREE *leaf_at_left = tree;
172                int       step_over    = marked_at_left+1; // step over myself
173                int       then_mark    = use_species_aside-marked_at_left;
174
175                while (step_over--) { // step over self and over any adjacent, marked species
176                    leaf_at_left = left_neighbour_leaf(leaf_at_left);
177                }
178
179                Store_species *marked_back = 0;
180                while (leaf_at_left && then_mark--) { // then additionally mark some species
181                    if (GB_read_flag(leaf_at_left->gb_node) == 0) { // if they are not marked yet
182                        mark_species(leaf_at_left, extra_marked_species);
183                        marked_back = (new Store_species(leaf_at_left))->add(marked_back);
184                    }
185                    leaf_at_left = left_neighbour_leaf(leaf_at_left);
186                }
187
188                while (marked_back) {
189                    GBS_chrcat(memfile, 1);             // Separated by 1
190                    GBS_strcat(memfile, "L");
191                    GBS_strcat(memfile, marked_back->getNode()->name);
192                    GBS_write_hash(used, marked_back->getNode()->name, 1);      // Mark species
193
194                    Store_species *rest = marked_back->remove();
195                    delete marked_back;
196                    marked_back = rest;
197                }
198
199                marked_at_left = use_species_aside;
200            }
201            // now use_species_aside species to left are marked!
202            *auto_mark = use_species_aside;
203        }
204
205        GBS_chrcat(memfile, 1);             // Separated by 1
206        GBS_strcat(memfile, "L");
207        GBS_strcat(memfile, tree->name);
208        GBS_write_hash(used, tree->name, 1);    // Mark species
209
210        *marked_at_right = marked_at_left+1;
211        return 1;
212    }
213
214    long oldpos = GBS_memoffset(memfile);
215    if (tree->gb_node && tree->name) {      // but we are a group
216        GBDATA *gb_grouped = GB_entry(tree->gb_node, "grouped");
217        GBS_chrcat(memfile, 1);             // Separated by 1
218        if (gb_grouped && GB_read_byte(gb_grouped)) {
219            GBS_strcat(memfile, "F");
220        }
221        else {
222            GBS_strcat(memfile, "G");
223        }
224
225        GBS_strcat(memfile, tree->name);
226    }
227
228    int right_of_leftson;
229    long nspecies = nt_build_conf_string_rek(used, tree->leftson, memfile, extra_marked_species, use_species_aside, auto_mark, marked_at_left, &right_of_leftson);
230    nspecies += nt_build_conf_string_rek(used, tree->rightson, memfile, extra_marked_species, use_species_aside, auto_mark, right_of_leftson, marked_at_right);
231
232    if (tree->gb_node && tree->name) {      // but we are a group
233        GBS_chrcat(memfile, 1);         // Separated by 1
234        GBS_chrcat(memfile, 'E');        // Group end indicated by 'E'
235    }
236
237    if (!nspecies) {
238        long newpos = GBS_memoffset(memfile);
239        GBS_str_cut_tail(memfile, newpos-oldpos);   // delete group info
240    }
241    return nspecies;
242}
243
244struct SAI_string_builder {
245    GBS_strstruct *sai_middle;
246    const char    *last_group_name;
247};
248
249static long nt_build_sai_string_by_hash(const char *key, long val, void *cd_sai_builder) {
250    SAI_string_builder *sai_builder = (SAI_string_builder*)cd_sai_builder;
251
252    const char *sep = strchr(key, 1);
253    if (!sep) return val;                           // what's wrong
254
255    GBS_strstruct *sai_middle      = sai_builder->sai_middle;
256    const char    *last_group_name = sai_builder->last_group_name;
257
258    if (!last_group_name || strncmp(key, last_group_name, sep-key)) { // new group
259        if (last_group_name) {
260            GBS_chrcat(sai_middle, 1);              // Separated by 1
261            GBS_chrcat(sai_middle, 'E');             // End of old group
262        }
263        GBS_chrcat(sai_middle, 1);                  // Separated by 1
264        GBS_strcat(sai_middle, "FSAI:");
265        GBS_strncat(sai_middle, key, sep-key);
266        sai_builder->last_group_name = key;
267    }
268    GBS_chrcat(sai_middle, 1);                      // Separated by 1
269    GBS_strcat(sai_middle, "S");
270    GBS_strcat(sai_middle, sep+1);
271    return val;
272}
273
274
275static void nt_build_sai_string(GBS_strstruct *topfile, GBS_strstruct *middlefile) {
276    //! collect all Sais, place some SAI in top area, rest in middle
277
278    GBDATA *gb_sai_data = GBT_get_SAI_data(GLOBAL.gb_main);
279    if (gb_sai_data) {
280        GB_HASH *hash = GBS_create_hash(GB_number_of_subentries(gb_sai_data), GB_IGNORE_CASE);
281
282        for (GBDATA *gb_sai = GBT_first_SAI_rel_SAI_data(gb_sai_data); gb_sai; gb_sai = GBT_next_SAI(gb_sai)) {
283            GBDATA *gb_name = GB_search(gb_sai, "name", GB_FIND);
284            if (gb_name) {
285                char *name = GB_read_string(gb_name);
286
287                if (strcmp(name,  "HELIX") == 0  || strcmp(name,  "HELIX_NR") == 0 || strcmp(name,  "ECOLI") == 0) {
288                    GBS_chrcat(topfile, 1);             // Separated by 1
289                    GBS_strcat(topfile, "S");
290                    GBS_strcat(topfile, name);
291                }
292                else {
293                    GBDATA *gb_gn = GB_search(gb_sai, "sai_group", GB_FIND);
294                    char   *gn;
295
296                    if (gb_gn)  gn = GB_read_string(gb_gn);
297                    else        gn = strdup("SAI's");
298
299                    char *cn = new char[strlen(gn) + strlen(name) + 2];
300                    sprintf(cn, "%s%c%s", gn, 1, name);
301                    GBS_write_hash(hash, cn, 1);
302                    delete [] cn;
303                    free(gn);
304                }
305                free(name);
306            }
307        }
308
309        // open surrounding SAI-group:
310        GBS_chrcat(middlefile, 1);
311        GBS_strcat(middlefile, "GSAI-Maingroup");
312
313        SAI_string_builder sai_builder = { middlefile, 0 };
314        GBS_hash_do_sorted_loop(hash, nt_build_sai_string_by_hash, GBS_HCF_sortedByKey, &sai_builder);
315        if (sai_builder.last_group_name) {
316            GBS_chrcat(middlefile, 1);              // Separated by 1
317            GBS_chrcat(middlefile, 'E');             // End of old group
318        }
319
320        // close surrounding SAI-group:
321        GBS_chrcat(middlefile, 1);
322        GBS_chrcat(middlefile, 'E');
323
324        GBS_free_hash(hash);
325    }
326}
327
328static void nt_build_conf_marked(GB_HASH *used, GBS_strstruct *file) {
329    GBS_chrcat(file, 1);            // Separated by 1
330    GBS_strcat(file, "FMore Sequences");
331    GBDATA *gb_species;
332    for (gb_species = GBT_first_marked_species(GLOBAL.gb_main);
333         gb_species;
334         gb_species = GBT_next_marked_species(gb_species)) {
335        char *name = GBT_read_string(gb_species, "name");
336        if (GBS_read_hash(used, name)) {
337            free(name);
338            continue;
339        }
340        GBS_chrcat(file, 1);
341        GBS_strcat(file, "L");
342        GBS_strcat(file, name);
343        free(name);
344    }
345
346    GBS_chrcat(file, 1); // Separated by 1
347    GBS_chrcat(file, 'E');   // Group end indicated by 'E'
348}
349
350enum extractType {
351    CONF_EXTRACT,
352    CONF_MARK,
353    CONF_UNMARK,
354    CONF_INVERT,
355    CONF_COMBINE // logical AND
356};
357
358static void nt_extract_configuration(AW_window *aww, AW_CL cl_extractType) {
359    GB_transaction  dummy2(GLOBAL.gb_main);         // open close transaction
360    AW_root        *aw_root = aww->get_root();
361    char           *cn      = aw_root->awar(AWAR_CONFIGURATION)->read_string();
362   
363    GBDATA *gb_configuration = GBT_find_configuration(GLOBAL.gb_main, cn);
364    if (!gb_configuration) {
365        aw_message(GBS_global_string("Configuration '%s' not found in the database", cn));
366    }
367    else {
368        GBDATA *gb_middle_area  = GB_search(gb_configuration, "middle_area", GB_STRING);
369        char   *md              = 0;
370        size_t  unknown_species = 0;
371        bool    refresh         = false;
372
373        if (gb_middle_area) {
374            extractType ext_type = extractType(cl_extractType);
375
376            GB_HASH *was_marked = NULL;             // only used for CONF_COMBINE
377
378            switch (ext_type) {
379                case CONF_EXTRACT:
380                    GBT_mark_all(GLOBAL.gb_main, 0); // unmark all for extract
381                    refresh = true;
382                    break;
383                case CONF_COMBINE: {
384                    // store all marked species in hash and unmark them
385                    was_marked = GBS_create_hash(GBT_get_species_count(GLOBAL.gb_main), GB_IGNORE_CASE);
386                    for (GBDATA *gbd = GBT_first_marked_species(GLOBAL.gb_main); gbd; gbd = GBT_next_marked_species(gbd)) {
387                        int marked = GB_read_flag(gbd);
388                        if (marked) {
389                            GBS_write_hash(was_marked, GBT_read_name(gbd), 1);
390                            GB_write_flag(gbd, 0);
391                        }
392                    }
393
394                    refresh = refresh || GBS_hash_count_elems(was_marked);
395                    break;
396                }
397                default:
398                    break;
399            }
400
401            md = GB_read_string(gb_middle_area);
402            if (md) {
403                char *p;
404                char tokens[2];
405                tokens[0] = 1;
406                tokens[1] = 0;
407                for (p = strtok(md, tokens); p; p = strtok(NULL, tokens)) {
408                    if (p[0] == 'L') {
409                        const char *species_name = p+1;
410                        GBDATA     *gb_species   = GBT_find_species(GLOBAL.gb_main, species_name);
411
412                        if (gb_species) {
413                            int oldmark = GB_read_flag(gb_species);
414                            int newmark = oldmark;
415                            switch (ext_type) {
416                                case CONF_EXTRACT:
417                                case CONF_MARK:     newmark = 1; break;
418                                case CONF_UNMARK:   newmark = 0; break;
419                                case CONF_INVERT:   newmark = !oldmark; break;
420                                case CONF_COMBINE: {
421                                    nt_assert(!oldmark); // should have been unmarked above
422                                    newmark = GBS_read_hash(was_marked, species_name); // mark if was_marked
423                                    break;
424                                }
425                                default: nt_assert(0); break;
426                            }
427                            if (newmark != oldmark) {
428                                GB_write_flag(gb_species, newmark);
429                                refresh = true;
430                            }
431                        }
432                        else {
433                            unknown_species++;
434                        }
435                    }
436                }
437            }
438
439            if (was_marked) GBS_free_hash(was_marked);
440        }
441
442        if (unknown_species>0) {
443            aw_message(GBS_global_string("configuration '%s' contains %zu unknown species", cn, unknown_species));
444        }
445
446        if (refresh) aw_root->awar(AWAR_TREE_REFRESH)->touch();
447
448        free(md);
449    }
450    free(cn);
451}
452
453static void nt_delete_configuration(AW_window *aww) {
454    GB_transaction transaction_var(GLOBAL.gb_main);
455    char *cn = aww->get_root()->awar(AWAR_CONFIGURATION)->read_string();
456    GBDATA *gb_configuration = GBT_find_configuration(GLOBAL.gb_main, cn);
457    if (gb_configuration) {
458        GB_ERROR error = GB_delete(gb_configuration);
459        if (error) aw_message(error);
460    }
461    free(cn);
462}
463
464
465static GB_ERROR nt_create_configuration(AW_window *, GBT_TREE *tree, const char *conf_name, int use_species_aside) {
466    char     *to_free = NULL;
467    GB_ERROR  error   = NULL;
468
469    if (!conf_name) {
470        char *existing_configs = awt_create_string_on_configurations(GLOBAL.gb_main);
471        conf_name              = to_free = aw_string_selection2awar("CREATE CONFIGURATION", "Enter name of configuration:", AWAR_CONFIGURATION, existing_configs, 0, 0);
472        free(existing_configs);
473    }
474
475    if (!conf_name) error = "no config name";
476    else {
477        if (use_species_aside==-1) {
478            static int last_used_species_aside = 3;
479            {
480                const char *val                    = GBS_global_string("%i", last_used_species_aside);
481                char       *use_species            = aw_input("How many extra species to view aside marked:", val);
482                if (use_species) use_species_aside = atoi(use_species);
483                free(use_species);
484            }
485
486            if (use_species_aside<1) error = "illegal number of 'species aside'";
487            else last_used_species_aside = use_species_aside; // remember for next time
488        }
489
490        if (!error) {
491            GB_transaction  ta(GLOBAL.gb_main); // open close transaction
492            GB_HASH        *used    = GBS_create_hash(GBT_get_species_count(GLOBAL.gb_main), GB_MIND_CASE);
493            GBS_strstruct  *topfile = GBS_stropen(1000);
494            GBS_strstruct  *topmid  = GBS_stropen(10000);
495            {
496                GBS_strstruct *middlefile = GBS_stropen(10000);
497                nt_build_sai_string(topfile, topmid);
498
499                if (use_species_aside) {
500                    Store_species *extra_marked_species = 0;
501                    int            auto_mark            = 0;
502                    int            marked_at_right;
503                   
504                    nt_build_conf_string_rek(used, tree, middlefile, &extra_marked_species, use_species_aside, &auto_mark, use_species_aside, &marked_at_right);
505                    if (extra_marked_species) {
506                        extra_marked_species->call(unmark_species);
507                        delete extra_marked_species;
508                    }
509                }
510                else {
511                    int dummy_1=0, dummy_2;
512                    nt_build_conf_string_rek(used, tree, middlefile, 0, 0, &dummy_1, 0, &dummy_2);
513                }
514                nt_build_conf_marked(used, topmid);
515                char *mid = GBS_strclose(middlefile);
516                GBS_strcat(topmid, mid);
517                free(mid);
518            }
519
520            {
521                char   *middle    = GBS_strclose(topmid);
522                char   *top       = GBS_strclose(topfile);
523                GBDATA *gb_config = GBT_create_configuration(GLOBAL.gb_main, conf_name);
524
525                if (!gb_config) error = GB_await_error();
526                else {
527                    error             = GBT_write_string(gb_config, "top_area", top);
528                    if (!error) error = GBT_write_string(gb_config, "middle_area", middle);
529                }
530
531                free(middle);
532                free(top);
533            }
534            GBS_free_hash(used);
535        }
536    }
537   
538    free(to_free);
539    return error;
540}
541
542static void nt_store_configuration(AW_window *, AW_CL cl_ntw) {
543    GB_ERROR err = nt_create_configuration(0, nt_get_tree_root_of_canvas((AWT_canvas*)cl_ntw), 0, 0);
544    aw_message_if(err);
545}
546
547static void nt_rename_configuration(AW_window *aww) {
548    AW_awar  *awar_curr_cfg = aww->get_root()->awar(AWAR_CONFIGURATION);
549    char     *old_name      = awar_curr_cfg->read_string();
550    GB_ERROR  err           = 0;
551
552    GB_transaction dummy(GLOBAL.gb_main);
553
554    char *new_name = aw_input("Rename selection", "Enter the new name of the selection", old_name);
555    if (new_name) {
556        GBDATA *gb_existing_cfg  = GBT_find_configuration(GLOBAL.gb_main, new_name);
557        if (gb_existing_cfg) err = GBS_global_string("There is already a selection named '%s'", new_name);
558        else {
559            GBDATA *gb_old_cfg = GBT_find_configuration(GLOBAL.gb_main, old_name);
560            if (gb_old_cfg) {
561                GBDATA *gb_name = GB_entry(gb_old_cfg, "name");
562                if (gb_name) {
563                    err = GB_write_string(gb_name, new_name);
564                    if (!err) awar_curr_cfg->write_string(new_name);
565                }
566                else err = "Selection has no name";
567            }
568            else err = "Can't find that selection";
569        }
570        free(new_name);
571    }
572
573    if (err) aw_message(err);
574    free(old_name);
575}
576
577static AW_window *create_configuration_admin_window(AW_root *root, AWT_canvas *ntw) {
578    static AW_window_simple *existing_aws[MAX_NT_WINDOWS] = { MAX_NT_WINDOWS_NULLINIT };
579
580    int ntw_id = NT_get_canvas_id(ntw);
581    if (!existing_aws[ntw_id]) {
582        init_config_awars(root);
583
584        AW_window_simple *aws = new AW_window_simple;
585        aws->init(root, "SPECIES_SELECTIONS", "Species Selections");
586        aws->load_xfig("nt_selection.fig");
587
588        aws->at("close");
589        aws->callback((AW_CB0)AW_POPDOWN);
590        aws->create_button("CLOSE", "CLOSE", "C");
591
592        aws->at("help");
593        aws->callback(AW_POPUP_HELP, (AW_CL)"configuration.hlp");
594        aws->create_button("HELP", "HELP", "H");
595
596        aws->at("list");
597        awt_create_selection_list_on_configurations(GLOBAL.gb_main, aws, AWAR_CONFIGURATION);
598
599        aws->at("store");
600        aws->callback(nt_store_configuration, (AW_CL)ntw);
601        aws->create_button(GBS_global_string("STORE_%i", ntw_id), "STORE", "S");
602
603        aws->at("extract");
604        aws->callback(nt_extract_configuration, CONF_EXTRACT);
605        aws->create_button("EXTRACT", "EXTRACT", "E");
606
607        aws->at("mark");
608        aws->callback(nt_extract_configuration, CONF_MARK);
609        aws->create_button("MARK", "MARK", "M");
610
611        aws->at("unmark");
612        aws->callback(nt_extract_configuration, CONF_UNMARK);
613        aws->create_button("UNMARK", "UNMARK", "U");
614
615        aws->at("invert");
616        aws->callback(nt_extract_configuration, CONF_INVERT);
617        aws->create_button("INVERT", "INVERT", "I");
618
619        aws->at("combine");
620        aws->callback(nt_extract_configuration, CONF_COMBINE);
621        aws->create_button("COMBINE", "COMBINE", "C");
622
623        aws->at("delete");
624        aws->callback(nt_delete_configuration);
625        aws->create_button("DELETE", "DELETE", "D");
626
627        aws->at("rename");
628        aws->callback(nt_rename_configuration);
629        aws->create_button("RENAME", "RENAME", "R");
630
631        existing_aws[ntw_id] = aws;
632    }
633    return existing_aws[ntw_id];
634}
635
636void NT_popup_configuration_admin(AW_window *aw_main, AW_CL cl_ntw, AW_CL) {
637    AW_window *aww = create_configuration_admin_window(aw_main->get_root(), (AWT_canvas*)cl_ntw);
638    aww->activate();
639}
640
641// -----------------------------------------
642//      various ways to start the editor
643
644#define CONFNAME "default_configuration"
645
646static void nt_start_editor_on_configuration(AW_window *aww) {
647    aww->hide();
648
649    const char *cn  = aww->get_root()->awar(AWAR_CONFIGURATION)->read_char_pntr();
650    const char *com = GBS_global_string("arb_edit4 -c '%s' &", cn);
651
652    aw_message_if(GBK_system(com));
653}
654
655AW_window *NT_start_editor_on_old_configuration(AW_root *awr) {
656    static AW_window_simple *aws = 0;
657    if (aws) return (AW_window *)aws;
658    awr->awar_string(AWAR_CONFIGURATION, "default_configuration", GLOBAL.gb_main);
659    aws = new AW_window_simple;
660    aws->init(awr, "SELECT_CONFIGURATION", "SELECT A CONFIGURATION");
661    aws->at(10, 10);
662    aws->auto_space(0, 0);
663    awt_create_selection_list_on_configurations(GLOBAL.gb_main, (AW_window *)aws, AWAR_CONFIGURATION);
664    aws->at_newline();
665
666    aws->callback((AW_CB0)nt_start_editor_on_configuration);
667    aws->create_button("START", "START");
668
669    aws->callback(AW_POPDOWN);
670    aws->create_button("CLOSE", "CLOSE", "C");
671
672    aws->window_fit();
673    return (AW_window *)aws;
674}
675
676void NT_start_editor_on_tree(AW_window *, AW_CL cl_use_species_aside, AW_CL cl_ntw) {
677    GB_ERROR error = nt_create_configuration(0, nt_get_tree_root_of_canvas((AWT_canvas*)cl_ntw), CONFNAME, (int)cl_use_species_aside);
678    if (!error) error = GBK_system("arb_edit4 -c " CONFNAME " &");
679    aw_message_if(error);
680}
681
682
Note: See TracBrowser for help on using the repository browser.