source: branches/species/NTREE/NT_cb.cxx

Last change on this file was 19613, checked in by westram, 2 months ago
  • reintegrates 'lib' into 'trunk'
    • replace dynamic library AWT by several static libraries: APP, ARB_SPEC, MASKS, CANVAS, MAPKEY, GUI_TK
    • now also check wrong library dependencies for untested units (only4me)
  • adds: log:branches/lib@19578:19612
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.1 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : NT_cb.cxx                                         //
4//   Purpose   :                                                   //
5//                                                                 //
6//   Institute of Microbiology (Technical University Munich)       //
7//   http://www.arb-home.de/                                       //
8//                                                                 //
9// =============================================================== //
10
11#include "NT_local.h"
12#include "ad_trees.h"
13
14#include <TreeDisplay.hxx>
15
16#include <sel_boxes.hxx>
17#include <aw_awars.hxx>
18#include <aw_root.hxx>
19#include <aw_question.hxx>
20#include <aw_msg.hxx>
21
22#include <map>
23#include <AliAdmin.h>
24
25// AISC_MKPT_PROMOTE:#ifndef ARBDB_BASE_H
26// AISC_MKPT_PROMOTE:#include <arbdb_base.h>
27// AISC_MKPT_PROMOTE:#endif
28// AISC_MKPT_PROMOTE:class TREE_canvas;
29
30void NT_delete_mark_all_cb(AW_window*, TREE_canvas *ntw) {
31    if (aw_ask_sure("delete_marked_species",
32                    "Are you sure to delete species ??\n"
33                    "This will destroy primary data !!!"))
34    {
35        {
36            GB_ERROR       error = NULp;
37            GB_transaction ta(ntw->gb_main);
38
39            GBDATA *gb_species, *gb_next;
40            for (gb_species = GBT_first_marked_species(ntw->gb_main);
41                 gb_species && !error;
42                 gb_species = gb_next)
43            {
44                gb_next = GBT_next_marked_species(gb_species);
45                error   = GB_delete(gb_species);
46            }
47
48            if (error) {
49                error = ta.close(error);
50                aw_message(error);
51            }
52        }
53        AWT_auto_refresh allowed_on(ntw);
54        ntw->request_refresh();
55    }
56}
57
58
59AW_window *NT_create_select_tree_window(AW_root *awr, const char *awar_tree) {
60    static std::map<std::string,AW_window*> tree_select_windows;
61    if (tree_select_windows.find(awar_tree) == tree_select_windows.end()) {
62        AW_window_simple *aws = new AW_window_simple;
63
64        const char *id = strrchr(awar_tree, '/');
65        nt_assert(id);
66        id++; // use name-part of awar_tree as id (results in 'SELECT_tree_name', 'SELECT_tree_name_1', ...)
67
68        aws->init(awr, GBS_global_string("SELECT_%s", id), "SELECT A TREE");
69        aws->load_xfig("select_simple.fig");
70
71        aws->at("selection");
72        awr->awar(awar_tree)->add_callback(makeRootCallback(awt_auto_popdown_cb, aws));
73        awt_create_TREE_selection_list(GLOBAL.gb_main, aws, awar_tree);
74
75        aws->auto_space(5, 5);
76        aws->button_length(6);
77
78        aws->at("button");
79        aws->callback(AW_POPDOWN);
80        aws->create_button("CLOSE", "CLOSE", "C");
81
82        aws->callback(popup_tree_admin_window);
83        aws->help_text("treeadm.hlp");
84        aws->create_button("MODIFY", "ADMIN", "A");
85
86        tree_select_windows[awar_tree] = aws;
87    }
88    return tree_select_windows[awar_tree];
89}
90
91void NT_select_bottom_tree(AW_window *aww, const char *awar_tree) {
92    GB_transaction ta(GLOBAL.gb_main);
93    const char *ltree = GBT_name_of_bottom_tree(GLOBAL.gb_main);
94    if (ltree) aww->get_root()->awar(awar_tree)->write_string(ltree);
95}
96
97void NT_create_alignment_vars(AW_root *aw_root, AW_default aw_def, GBDATA *gb_main) {
98    // map awar containing selected alignment with db-entry (both contain same value; historical)
99    // - allows access via AWAR_DEFAULT_ALIGNMENT and GBT_get_default_alignment
100
101    AW_awar        *awar_def_ali = aw_root->awar_string(AWAR_DEFAULT_ALIGNMENT, "", aw_def);
102    GB_transaction  ta(gb_main);
103    GBDATA         *gb_use       = GB_search(gb_main, GB_DEFAULT_ALIGNMENT, GB_STRING);
104
105    awar_def_ali->map(gb_use);
106}
107
108AW_window *NT_create_alignment_admin_window(AW_root *root, AW_window *aw_popmedown) {
109    // if 'aw_popmedown' points to a window, that window is popped down
110    if (aw_popmedown) aw_popmedown->hide();
111
112    static AliAdmin *ntreeAliAdmin    = NULp;
113    if (!ntreeAliAdmin) ntreeAliAdmin = new AliAdmin(MAIN_ADMIN, GLOBAL.gb_main, AWAR_DEFAULT_ALIGNMENT, "tmp/presets/");
114
115    return ALI_create_admin_window(root, ntreeAliAdmin);
116}
117
118AW_window *NT_create_select_alignment_window(AW_root *awr) {
119    static AW_window_simple *aws = NULp;
120    if (!aws) {
121        aws = new AW_window_simple;
122
123        aws->init(awr, "SELECT_ALIGNMENT", "SELECT AN ALIGNMENT");
124        aws->load_xfig("select_simple.fig");
125
126        aws->at("selection");
127        awr->awar(AWAR_DEFAULT_ALIGNMENT)->add_callback(makeRootCallback(awt_auto_popdown_cb, aws));
128        awt_create_ALI_selection_list(GLOBAL.gb_main, aws, AWAR_DEFAULT_ALIGNMENT, "*=");
129
130        aws->auto_space(5, 5);
131        aws->button_length(6);
132
133        aws->at("button");
134        aws->callback(AW_POPDOWN);
135        aws->create_button("CLOSE", "CLOSE", "C");
136
137        aws->callback(makeCreateWindowCallback(NT_create_alignment_admin_window, static_cast<AW_window*>(aws)));
138        aws->help_text("ad_align.hlp");
139        aws->create_button("MODIFY", "ADMIN", "A");
140
141        aws->window_fit();
142    }
143    return aws;
144}
145
Note: See TracBrowser for help on using the repository browser.