| 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 <awt_canvas.hxx> |
|---|
| 17 | #include <awt_sel_boxes.hxx> |
|---|
| 18 | #include <aw_awars.hxx> |
|---|
| 19 | #include <aw_root.hxx> |
|---|
| 20 | #include <aw_question.hxx> |
|---|
| 21 | #include <aw_msg.hxx> |
|---|
| 22 | |
|---|
| 23 | #include <map> |
|---|
| 24 | #include <AliAdmin.h> |
|---|
| 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:class TREE_canvas; |
|---|
| 30 | |
|---|
| 31 | void NT_delete_mark_all_cb(AW_window*, TREE_canvas *ntw) { |
|---|
| 32 | if (aw_ask_sure("delete_marked_species", |
|---|
| 33 | "Are you sure to delete species ??\n" |
|---|
| 34 | "This will destroy primary data !!!")) |
|---|
| 35 | { |
|---|
| 36 | { |
|---|
| 37 | GB_ERROR error = NULp; |
|---|
| 38 | GB_transaction ta(ntw->gb_main); |
|---|
| 39 | |
|---|
| 40 | GBDATA *gb_species, *gb_next; |
|---|
| 41 | for (gb_species = GBT_first_marked_species(ntw->gb_main); |
|---|
| 42 | gb_species && !error; |
|---|
| 43 | gb_species = gb_next) |
|---|
| 44 | { |
|---|
| 45 | gb_next = GBT_next_marked_species(gb_species); |
|---|
| 46 | error = GB_delete(gb_species); |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | if (error) { |
|---|
| 50 | error = ta.close(error); |
|---|
| 51 | aw_message(error); |
|---|
| 52 | } |
|---|
| 53 | } |
|---|
| 54 | AWT_auto_refresh allowed_on(ntw); |
|---|
| 55 | ntw->request_refresh(); |
|---|
| 56 | } |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | AW_window *NT_create_select_tree_window(AW_root *awr, const char *awar_tree) { |
|---|
| 61 | static std::map<std::string,AW_window*> tree_select_windows; |
|---|
| 62 | if (tree_select_windows.find(awar_tree) == tree_select_windows.end()) { |
|---|
| 63 | AW_window_simple *aws = new AW_window_simple; |
|---|
| 64 | |
|---|
| 65 | const char *id = strrchr(awar_tree, '/'); |
|---|
| 66 | nt_assert(id); |
|---|
| 67 | id++; // use name-part of awar_tree as id (results in 'SELECT_tree_name', 'SELECT_tree_name_1', ...) |
|---|
| 68 | |
|---|
| 69 | aws->init(awr, GBS_global_string("SELECT_%s", id), "SELECT A TREE"); |
|---|
| 70 | aws->load_xfig("select_simple.fig"); |
|---|
| 71 | |
|---|
| 72 | aws->at("selection"); |
|---|
| 73 | awr->awar(awar_tree)->add_callback(makeRootCallback(awt_auto_popdown_cb, aws)); |
|---|
| 74 | awt_create_TREE_selection_list(GLOBAL.gb_main, aws, awar_tree); |
|---|
| 75 | |
|---|
| 76 | aws->auto_space(5, 5); |
|---|
| 77 | aws->button_length(6); |
|---|
| 78 | |
|---|
| 79 | aws->at("button"); |
|---|
| 80 | aws->callback(AW_POPDOWN); |
|---|
| 81 | aws->create_button("CLOSE", "CLOSE", "C"); |
|---|
| 82 | |
|---|
| 83 | aws->callback(popup_tree_admin_window); |
|---|
| 84 | aws->help_text("treeadm.hlp"); |
|---|
| 85 | aws->create_button("MODIFY", "ADMIN", "A"); |
|---|
| 86 | |
|---|
| 87 | tree_select_windows[awar_tree] = aws; |
|---|
| 88 | } |
|---|
| 89 | return tree_select_windows[awar_tree]; |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | void NT_select_bottom_tree(AW_window *aww, const char *awar_tree) { |
|---|
| 93 | GB_transaction ta(GLOBAL.gb_main); |
|---|
| 94 | const char *ltree = GBT_name_of_bottom_tree(GLOBAL.gb_main); |
|---|
| 95 | if (ltree) aww->get_root()->awar(awar_tree)->write_string(ltree); |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | void NT_create_alignment_vars(AW_root *aw_root, AW_default aw_def, GBDATA *gb_main) { |
|---|
| 99 | // map awar containing selected alignment with db-entry (both contain same value; historical) |
|---|
| 100 | // - allows access via AWAR_DEFAULT_ALIGNMENT and GBT_get_default_alignment |
|---|
| 101 | |
|---|
| 102 | AW_awar *awar_def_ali = aw_root->awar_string(AWAR_DEFAULT_ALIGNMENT, "", aw_def); |
|---|
| 103 | GB_transaction ta(gb_main); |
|---|
| 104 | GBDATA *gb_use = GB_search(gb_main, GB_DEFAULT_ALIGNMENT, GB_STRING); |
|---|
| 105 | |
|---|
| 106 | awar_def_ali->map(gb_use); |
|---|
| 107 | } |
|---|
| 108 | |
|---|
| 109 | AW_window *NT_create_alignment_admin_window(AW_root *root, AW_window *aw_popmedown) { |
|---|
| 110 | // if 'aw_popmedown' points to a window, that window is popped down |
|---|
| 111 | if (aw_popmedown) aw_popmedown->hide(); |
|---|
| 112 | |
|---|
| 113 | static AliAdmin *ntreeAliAdmin = NULp; |
|---|
| 114 | if (!ntreeAliAdmin) ntreeAliAdmin = new AliAdmin(MAIN_ADMIN, GLOBAL.gb_main, AWAR_DEFAULT_ALIGNMENT, "tmp/presets/"); |
|---|
| 115 | |
|---|
| 116 | return ALI_create_admin_window(root, ntreeAliAdmin); |
|---|
| 117 | } |
|---|
| 118 | |
|---|
| 119 | AW_window *NT_create_select_alignment_window(AW_root *awr) { |
|---|
| 120 | static AW_window_simple *aws = NULp; |
|---|
| 121 | if (!aws) { |
|---|
| 122 | aws = new AW_window_simple; |
|---|
| 123 | |
|---|
| 124 | aws->init(awr, "SELECT_ALIGNMENT", "SELECT AN ALIGNMENT"); |
|---|
| 125 | aws->load_xfig("select_simple.fig"); |
|---|
| 126 | |
|---|
| 127 | aws->at("selection"); |
|---|
| 128 | awr->awar(AWAR_DEFAULT_ALIGNMENT)->add_callback(makeRootCallback(awt_auto_popdown_cb, aws)); |
|---|
| 129 | awt_create_ALI_selection_list(GLOBAL.gb_main, aws, AWAR_DEFAULT_ALIGNMENT, "*="); |
|---|
| 130 | |
|---|
| 131 | aws->auto_space(5, 5); |
|---|
| 132 | aws->button_length(6); |
|---|
| 133 | |
|---|
| 134 | aws->at("button"); |
|---|
| 135 | aws->callback(AW_POPDOWN); |
|---|
| 136 | aws->create_button("CLOSE", "CLOSE", "C"); |
|---|
| 137 | |
|---|
| 138 | aws->callback(makeCreateWindowCallback(NT_create_alignment_admin_window, static_cast<AW_window*>(aws))); |
|---|
| 139 | aws->help_text("ad_align.hlp"); |
|---|
| 140 | aws->create_button("MODIFY", "ADMIN", "A"); |
|---|
| 141 | |
|---|
| 142 | aws->window_fit(); |
|---|
| 143 | } |
|---|
| 144 | return aws; |
|---|
| 145 | } |
|---|
| 146 | |
|---|