source: branches/profile/NTREE/NT_cb.cxx

Last change on this file was 12757, checked in by westram, 10 years ago
  • unify selectionlist creator names
  • awt_create_selection_list_on_pt_servers
    • remove param 'popup', instead split into two function (button and list) as done for SAIs
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.6 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 <awt_canvas.hxx>
15#include <awt_sel_boxes.hxx>
16#include <aw_awars.hxx>
17#include <aw_root.hxx>
18#include <aw_question.hxx>
19#include <aw_msg.hxx>
20#include <arbdbt.h>
21
22#include <map>
23#include <AliAdmin.h>
24
25
26// AISC_MKPT_PROMOTE:#ifndef ARBDB_BASE_H
27// AISC_MKPT_PROMOTE:#include <arbdb_base.h>
28// AISC_MKPT_PROMOTE:#endif
29// AISC_MKPT_PROMOTE:#ifndef AW_BASE_HXX
30// AISC_MKPT_PROMOTE:#include <aw_base.hxx>
31// AISC_MKPT_PROMOTE:#endif
32// AISC_MKPT_PROMOTE:class AWT_canvas;
33
34#define AWT_TREE(ntw)  DOWNCAST(AWT_graphic_tree *, (ntw)->tree_disp)
35
36void NT_delete_mark_all_cb(void *, AWT_canvas *ntw) {
37    if (aw_ask_sure("delete_marked_species",
38                    "Are you sure to delete species ??\n"
39                    "This will destroy primary data !!!"))
40    {
41        {
42            GB_ERROR       error = 0;
43            GB_transaction ta(ntw->gb_main);
44
45            GBDATA *gb_species, *gb_next;
46            for (gb_species = GBT_first_marked_species(ntw->gb_main);
47                 gb_species && !error;
48                 gb_species = gb_next)
49            {
50                gb_next = GBT_next_marked_species(gb_species);
51                error   = GB_delete(gb_species);
52            }
53
54            if (error) {
55                error = ta.close(error);
56                aw_message(error);
57            }
58        }
59        ntw->refresh();
60    }
61}
62
63
64AW_window *NT_create_select_tree_window(AW_root *awr, const char *awar_tree) {
65    static std::map<std::string,AW_window*> tree_select_windows;
66    if (tree_select_windows.find(awar_tree) == tree_select_windows.end()) {
67        AW_window_simple *aws = new AW_window_simple;
68
69        const char *id = strrchr(awar_tree, '/');
70        nt_assert(id);
71        id++; // use name-part of awar_tree as id (results in 'SELECT_tree_name', 'SELECT_tree_name_1', ...)
72
73        aws->init(awr, GBS_global_string("SELECT_%s", id), "SELECT A TREE");
74        aws->load_xfig("select_simple.fig");
75
76        aws->at("selection");
77        awt_create_TREE_selection_list(GLOBAL.gb_main, aws, awar_tree, true);
78
79        aws->auto_space(5, 5);
80        aws->button_length(6);
81
82        aws->at("button");
83        aws->callback(AW_POPDOWN);
84        aws->create_button("CLOSE", "CLOSE", "C");
85
86        aws->callback(popup_tree_admin_window);
87        aws->help_text("treeadm.hlp");
88        aws->create_button("MODIFY", "ADMIN", "A");
89
90        tree_select_windows[awar_tree] = aws;
91    }
92    return tree_select_windows[awar_tree];
93}
94
95void NT_select_bottom_tree(AW_window *aww, const char *awar_tree) {
96    GB_transaction ta(GLOBAL.gb_main);
97    const char *ltree = GBT_name_of_bottom_tree(GLOBAL.gb_main);
98    if (ltree) aww->get_root()->awar(awar_tree)->write_string(ltree);
99}
100
101void NT_create_alignment_vars(AW_root *aw_root, AW_default aw_def, GBDATA *gb_main) {
102    // map awar containing selected alignment with db-entry (both contain same value; historical)
103    // - allows access via AWAR_DEFAULT_ALIGNMENT and GBT_get_default_alignment
104
105    AW_awar        *awar_def_ali = aw_root->awar_string(AWAR_DEFAULT_ALIGNMENT, "", aw_def);
106    GB_transaction  ta(gb_main);
107    GBDATA         *gb_use       = GB_search(gb_main, GB_DEFAULT_ALIGNMENT, GB_STRING);
108
109    awar_def_ali->map(gb_use);
110}
111
112AW_window *NT_create_alignment_admin_window(AW_root *root, AW_window *aw_popmedown) {
113    // if 'aw_popmedown' points to a window, that window is popped down
114    if (aw_popmedown) aw_popmedown->hide();
115
116    static AliAdmin *ntreeAliAdmin    = NULL;
117    if (!ntreeAliAdmin) ntreeAliAdmin = new AliAdmin(MAIN_ADMIN, GLOBAL.gb_main, AWAR_DEFAULT_ALIGNMENT, "tmp/presets/");
118
119    return ALI_create_admin_window(root, ntreeAliAdmin);
120}
121
122AW_window *NT_create_select_alignment_window(AW_root *awr)
123{
124    static AW_window_simple *aws = 0;
125    if (!aws) {
126        aws = new AW_window_simple;
127
128        aws->init(awr, "SELECT_ALIGNMENT", "SELECT AN ALIGNMENT");
129        aws->load_xfig("select_simple.fig");
130
131        aws->at("selection");
132        aws->callback((AW_CB0)AW_POPDOWN);
133        awt_create_ALI_selection_list(GLOBAL.gb_main, (AW_window *)aws, AWAR_DEFAULT_ALIGNMENT, "*=");
134
135        aws->auto_space(5, 5);
136        aws->button_length(6);
137
138        aws->at("button");
139        aws->callback(AW_POPDOWN);
140        aws->create_button("CLOSE", "CLOSE", "C");
141
142        aws->callback(makeCreateWindowCallback(NT_create_alignment_admin_window, static_cast<AW_window*>(aws)));
143        aws->help_text("ad_align.hlp");
144        aws->create_button("MODIFY", "ADMIN", "A");
145
146        aws->window_fit();
147    }
148    return aws;
149}
150
151void NT_system_cb(AW_window *aww, AW_CL cl_command, AW_CL cl_auto_help_file) {
152    AW_system(aww, (const char *)cl_command, (const char *)cl_auto_help_file);
153}
154
155void NT_system_in_xterm_cb(AW_window *aww, AW_CL cl_command, AW_CL cl_auto_help_file) {
156    char *command = (char *)cl_command;
157    const char *autohelpfile = (const char *)cl_auto_help_file;
158    if (autohelpfile) AW_help_popup(aww, autohelpfile);
159
160    GB_ERROR error = GB_xcmd(command, true, true);
161    if (error) aw_message(error);
162}
Note: See TracBrowser for help on using the repository browser.