ARB
NT_cb.cxx
Go to the documentation of this file.
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 
32  if (aw_ask_sure("delete_marked_species",
33  "Are you sure to delete species ??\n"
34  "This will destroy primary data !!!"))
35  {
36  {
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));
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) {
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 
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 
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 
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));
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 
const char * GB_ERROR
Definition: arb_core.h:25
GBDATA * GBT_first_marked_species(GBDATA *gb_main)
Definition: aditem.cxx:113
AW_window * ALI_create_admin_window(AW_root *root, AliAdmin *admin)
Definition: AdminGui.cxx:162
#define GB_DEFAULT_ALIGNMENT
Definition: arbdb.h:30
void request_refresh()
Definition: awt_canvas.hxx:362
const char * GBT_name_of_bottom_tree(GBDATA *gb_main)
Definition: adtree.cxx:1107
#define AWAR_DEFAULT_ALIGNMENT
Definition: aw_awar_defs.hxx:8
const char * GBS_global_string(const char *templat,...)
Definition: arb_msg.cxx:203
AW_DB_selection * awt_create_TREE_selection_list(GBDATA *gb_main, AW_window *aws, const char *varname)
void AW_POPDOWN(AW_window *window)
Definition: AW_window.cxx:52
void NT_create_alignment_vars(AW_root *aw_root, AW_default aw_def, GBDATA *gb_main)
Definition: NT_cb.cxx:98
void NT_delete_mark_all_cb(AW_window *, TREE_canvas *ntw)
Definition: NT_cb.cxx:31
AW_awar * add_callback(const RootCallback &cb)
Definition: AW_awar.cxx:231
GB_ERROR GB_delete(GBDATA *&source)
Definition: arbdb.cxx:1916
AW_window * NT_create_select_alignment_window(AW_root *awr)
Definition: NT_cb.cxx:119
void awt_auto_popdown_cb(AW_root *, AW_window_simple *aw_popup)
void popup_tree_admin_window(AW_window *awp)
Definition: ad_trees.cxx:795
AW_window * NT_create_select_tree_window(AW_root *awr, const char *awar_tree)
Definition: NT_cb.cxx:60
AW_window * NT_create_alignment_admin_window(AW_root *root, AW_window *aw_popmedown)
Definition: NT_cb.cxx:109
static void error(const char *msg)
Definition: mkptypes.cxx:96
GBDATA * GBT_next_marked_species(GBDATA *gb_species)
Definition: aditem.cxx:116
AW_awar * awar(const char *awar)
Definition: AW_root.cxx:554
#define nt_assert(cond)
Definition: NT_local.h:27
AW_DB_selection * awt_create_ALI_selection_list(GBDATA *gb_main, AW_window *aws, const char *varname, const char *ali_type_match)
bool aw_ask_sure(const char *unique_id, const char *msg)
GB_ERROR close(GB_ERROR error)
Definition: arbdbpp.cxx:35
AW_awar * map(const char *awarn)
Definition: AW_awar.cxx:521
void aw_message(const char *msg)
Definition: AW_status.cxx:1142
void hide()
Definition: AW_window.cxx:1835
AW_root * get_root()
Definition: aw_window.hxx:359
#define NULp
Definition: cxxforward.h:116
GBDATA * gb_main
Definition: NT_local.h:37
void NT_select_bottom_tree(AW_window *aww, const char *awar_tree)
Definition: NT_cb.cxx:92
GB_ERROR write_string(const char *aw_string)
GB_transaction ta(gb_var)
GBDATA * gb_main
Definition: adname.cxx:32
AW_awar * awar_string(const char *var_name, const char *default_value="", AW_default default_file=AW_ROOT_DEFAULT)
Definition: AW_root.cxx:570
GBDATA * GB_search(GBDATA *gbd, const char *fieldpath, GB_TYPES create)
Definition: adquery.cxx:531
NT_global GLOBAL
Definition: NT_main.cxx:46
GBDATA * gb_main
Definition: awt_canvas.hxx:336