| 1 | // =============================================================== // |
|---|
| 2 | // // |
|---|
| 3 | // File : NT_extern.cxx // |
|---|
| 4 | // Purpose : // |
|---|
| 5 | // // |
|---|
| 6 | // Institute of Microbiology (Technical University Munich) // |
|---|
| 7 | // http://www.arb-home.de/ // |
|---|
| 8 | // // |
|---|
| 9 | // =============================================================== // |
|---|
| 10 | |
|---|
| 11 | #include "map_viewer.h" |
|---|
| 12 | #include "NT_local.h" |
|---|
| 13 | #include "ad_trees.h" |
|---|
| 14 | #include "NT_group_search.h" |
|---|
| 15 | |
|---|
| 16 | #include <seq_quality.h> |
|---|
| 17 | #include <multi_probe.hxx> |
|---|
| 18 | #include <st_window.hxx> |
|---|
| 19 | #include <GEN.hxx> |
|---|
| 20 | #include <EXP.hxx> |
|---|
| 21 | |
|---|
| 22 | #include <TreeCallbacks.hxx> |
|---|
| 23 | #include <AW_rename.hxx> |
|---|
| 24 | #include <probe_gui.hxx> |
|---|
| 25 | #include <primer_design.hxx> |
|---|
| 26 | #include <gde.hxx> |
|---|
| 27 | #include <awtc_submission.hxx> |
|---|
| 28 | |
|---|
| 29 | #include <macros.hxx> |
|---|
| 30 | #include <nds.h> |
|---|
| 31 | #include <db_query.h> |
|---|
| 32 | #include <dbui.h> |
|---|
| 33 | #include <refentries.h> |
|---|
| 34 | #include <insdel.h> |
|---|
| 35 | |
|---|
| 36 | #include <awti_export.hxx> |
|---|
| 37 | #include <awti_import.hxx> |
|---|
| 38 | |
|---|
| 39 | #include <awt.hxx> |
|---|
| 40 | #include <awt_input_mask.hxx> |
|---|
| 41 | #include <awt_sel_boxes.hxx> |
|---|
| 42 | #include <awt_www.hxx> |
|---|
| 43 | #include <awt_TreeAwars.hxx> |
|---|
| 44 | #include <awt_misc.hxx> |
|---|
| 45 | |
|---|
| 46 | #include <aw_color_groups.hxx> |
|---|
| 47 | #include <aw_advice.hxx> |
|---|
| 48 | #include <aw_preset.hxx> |
|---|
| 49 | #include <aw_awars.hxx> |
|---|
| 50 | #include <aw_global_awars.hxx> |
|---|
| 51 | #include <aw_file.hxx> |
|---|
| 52 | #include <aw_msg.hxx> |
|---|
| 53 | #include <arb_progress.h> |
|---|
| 54 | #include <aw_root.hxx> |
|---|
| 55 | #include <aw_question.hxx> |
|---|
| 56 | #include <aw_select.hxx> |
|---|
| 57 | #include <rootAsWin.h> |
|---|
| 58 | |
|---|
| 59 | #include <ad_cb.h> |
|---|
| 60 | |
|---|
| 61 | #include <arb_strbuf.h> |
|---|
| 62 | #include <arb_file.h> |
|---|
| 63 | #include <arb_version.h> |
|---|
| 64 | |
|---|
| 65 | #if defined(DEVEL_RALF) |
|---|
| 66 | # define TRACE_GROUP_SELECTION |
|---|
| 67 | #endif |
|---|
| 68 | |
|---|
| 69 | #define AWAR_EXPORT_NDS "tmp/export_nds" |
|---|
| 70 | #define AWAR_EXPORT_NDS_SEPARATOR AWAR_EXPORT_NDS "/separator" |
|---|
| 71 | #define AWAR_MARKED_SPECIES_COUNTER "tmp/disp_marked_species" |
|---|
| 72 | #define AWAR_NTREE_TITLE_MODE "tmp/title_mode" |
|---|
| 73 | |
|---|
| 74 | void create_probe_design_variables(AW_root *aw_root, AW_default def, AW_default global); |
|---|
| 75 | |
|---|
| 76 | void create_insertDeleteColumn_variables(AW_root *root, AW_default db1); |
|---|
| 77 | AW_window *create_insertDeleteColumn_window(AW_root *root); |
|---|
| 78 | AW_window *create_insertDeleteBySAI_window(AW_root *root, GBDATA *gb_main); |
|---|
| 79 | |
|---|
| 80 | AW_window *create_tree_window(AW_root *aw_root, AWT_graphic *awd); |
|---|
| 81 | |
|---|
| 82 | static void nt_changesecurity(AW_root *aw_root) { |
|---|
| 83 | int level = aw_root->awar(AWAR_SECURITY_LEVEL)->read_int(); |
|---|
| 84 | GB_push_transaction(GLOBAL.gb_main); |
|---|
| 85 | GB_change_my_security(GLOBAL.gb_main, level); // changes user security |
|---|
| 86 | GB_pop_transaction(GLOBAL.gb_main); |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | static void export_nds_cb(AW_window *aww, bool do_print) { |
|---|
| 90 | AW_root *aw_root = aww->get_root(); |
|---|
| 91 | char *name = aw_root->awar(AWAR_EXPORT_NDS"/file_name")->read_string(); |
|---|
| 92 | FILE *out = fopen(name, "w"); |
|---|
| 93 | |
|---|
| 94 | if (!out) { |
|---|
| 95 | aw_message("Error: Cannot open and write to file"); |
|---|
| 96 | } |
|---|
| 97 | else { |
|---|
| 98 | GB_transaction ta(GLOBAL.gb_main); |
|---|
| 99 | |
|---|
| 100 | make_node_text_init(GLOBAL.gb_main); |
|---|
| 101 | NDS_Type nds_type = (NDS_Type)aw_root->awar(AWAR_EXPORT_NDS_SEPARATOR)->read_int(); |
|---|
| 102 | char *tree_name = aw_root->awar(AWAR_TREE)->read_string(); |
|---|
| 103 | |
|---|
| 104 | for (GBDATA *gb_species = GBT_first_marked_species(GLOBAL.gb_main); |
|---|
| 105 | gb_species; |
|---|
| 106 | gb_species = GBT_next_marked_species(gb_species)) |
|---|
| 107 | { |
|---|
| 108 | const char *buf = make_node_text_nds(GLOBAL.gb_main, gb_species, nds_type, NULp, tree_name); |
|---|
| 109 | fprintf(out, "%s\n", buf); |
|---|
| 110 | } |
|---|
| 111 | AW_refresh_fileselection(aw_root, AWAR_EXPORT_NDS); |
|---|
| 112 | fclose(out); |
|---|
| 113 | if (do_print) { |
|---|
| 114 | GB_ERROR error = GB_textprint(name); |
|---|
| 115 | if (error) aw_message(error); |
|---|
| 116 | } |
|---|
| 117 | free(tree_name); |
|---|
| 118 | } |
|---|
| 119 | free(name); |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | static AW_window *create_nds_export_window(AW_root *root) { |
|---|
| 123 | AW_window_simple *aws = new AW_window_simple; |
|---|
| 124 | aws->init(root, "EXPORT_NDS_OF_MARKED", "EXPORT NDS OF MARKED SPECIES"); |
|---|
| 125 | aws->load_xfig("sel_box_nds.fig"); |
|---|
| 126 | |
|---|
| 127 | aws->callback(AW_POPDOWN); |
|---|
| 128 | aws->at("close"); |
|---|
| 129 | aws->create_button("CLOSE", "CLOSE", "C"); |
|---|
| 130 | |
|---|
| 131 | aws->callback(makeHelpCallback("arb_export_nds.hlp")); |
|---|
| 132 | aws->at("help"); |
|---|
| 133 | aws->create_button("HELP", "HELP", "H"); |
|---|
| 134 | |
|---|
| 135 | aws->at("save"); |
|---|
| 136 | aws->callback(makeWindowCallback(export_nds_cb, false)); |
|---|
| 137 | aws->create_button("SAVE", "SAVE", "S"); |
|---|
| 138 | |
|---|
| 139 | aws->at("print"); |
|---|
| 140 | aws->callback(makeWindowCallback(export_nds_cb, true)); |
|---|
| 141 | aws->create_button("PRINT", "PRINT", "P"); |
|---|
| 142 | |
|---|
| 143 | aws->at("toggle1"); |
|---|
| 144 | aws->label("Column output"); |
|---|
| 145 | aws->create_option_menu(AWAR_EXPORT_NDS_SEPARATOR, true); |
|---|
| 146 | aws->insert_default_option("Space padded", "S", NDS_OUTPUT_SPACE_PADDED); |
|---|
| 147 | aws->insert_option ("TAB separated", "T", NDS_OUTPUT_TAB_SEPARATED); |
|---|
| 148 | aws->insert_option ("Comma separated", "C", NDS_OUTPUT_COMMA_SEPARATED); |
|---|
| 149 | aws->update_option_menu(); |
|---|
| 150 | |
|---|
| 151 | AW_create_standard_fileselection(aws, AWAR_EXPORT_NDS); |
|---|
| 152 | |
|---|
| 153 | return aws; |
|---|
| 154 | } |
|---|
| 155 | |
|---|
| 156 | static void create_export_nds_awars(AW_root *awr, AW_default def) { |
|---|
| 157 | AW_create_fileselection_awars(awr, AWAR_EXPORT_NDS, "", ".nds", "export.nds"); |
|---|
| 158 | awr->awar_int(AWAR_EXPORT_NDS_SEPARATOR, NDS_OUTPUT_SPACE_PADDED, def); |
|---|
| 159 | } |
|---|
| 160 | |
|---|
| 161 | static void selectedSpeciesChanged_cb(AW_root *awr) { |
|---|
| 162 | const char *value = awr->awar(AWAR_SPECIES_NAME)->read_char_pntr(); |
|---|
| 163 | awr->awar(AWAR_INFO_BUTTON_TEXT)->write_string(value[0] ? value : "Species Info"); |
|---|
| 164 | if (value[0]) { |
|---|
| 165 | awr->awar(AWAR_GROUP)->write_pointer(NULp); // deselect group when species gets selected |
|---|
| 166 | #if defined(TRACE_GROUP_SELECTION) |
|---|
| 167 | fputs("clear AWAR_GROUP (because species selected)\n", stderr); |
|---|
| 168 | #endif |
|---|
| 169 | } |
|---|
| 170 | } |
|---|
| 171 | |
|---|
| 172 | static void expert_mode_changed_cb(AW_root *aw_root) { |
|---|
| 173 | aw_root->awar(AWAR_AWM_MASK)->write_int(aw_root->awar(AWAR_EXPERT)->read_int() ? AWM_ALL : AWM_BASIC); // publish expert-mode globally |
|---|
| 174 | } |
|---|
| 175 | |
|---|
| 176 | static void NT_toggle_expert_mode(AW_window *aww) { aww->get_root()->awar(AWAR_EXPERT)->toggle_toggle(); } |
|---|
| 177 | static void NT_toggle_focus_policy(AW_window *aww) { aww->get_root()->awar(AWAR_AW_FOCUS_FOLLOWS_MOUSE)->toggle_toggle(); } |
|---|
| 178 | |
|---|
| 179 | static void nt_create_all_awars(AW_root *awr) { |
|---|
| 180 | // creates awars for all modules reachable from ARB_NT main window |
|---|
| 181 | |
|---|
| 182 | awr->awar_string(AWAR_FOOTER, "", AW_ROOT_DEFAULT); |
|---|
| 183 | if (GB_read_clients(GLOBAL.gb_main)>=0) { |
|---|
| 184 | awr->awar_string(AWAR_TREE, "", GLOBAL.gb_main); |
|---|
| 185 | } |
|---|
| 186 | else { |
|---|
| 187 | awr->awar_string(AWAR_TREE, "", AW_ROOT_DEFAULT); |
|---|
| 188 | } |
|---|
| 189 | |
|---|
| 190 | awr->awar_string(AWAR_SPECIES_NAME, "", GLOBAL.gb_main); |
|---|
| 191 | awr->awar_string(AWAR_SAI_NAME, "", GLOBAL.gb_main); |
|---|
| 192 | awr->awar_string(AWAR_SAI_GLOBAL, "", GLOBAL.gb_main); |
|---|
| 193 | awr->awar_string(AWAR_MARKED_SPECIES_COUNTER, "unknown", GLOBAL.gb_main); |
|---|
| 194 | awr->awar_string(AWAR_INFO_BUTTON_TEXT, "Species Info", GLOBAL.gb_main); |
|---|
| 195 | awr->awar(AWAR_SPECIES_NAME)->add_callback(selectedSpeciesChanged_cb); |
|---|
| 196 | awr->awar_int(AWAR_NTREE_TITLE_MODE, 1); |
|---|
| 197 | |
|---|
| 198 | awr->awar_string(AWAR_SAI_COLOR_STR, "", GLOBAL.gb_main); // sai visualization in probe match |
|---|
| 199 | |
|---|
| 200 | GEN_create_awars(awr, AW_ROOT_DEFAULT, GLOBAL.gb_main); |
|---|
| 201 | EXP_create_awars(awr, AW_ROOT_DEFAULT, GLOBAL.gb_main); |
|---|
| 202 | #if defined(DEBUG) |
|---|
| 203 | AWT_create_db_browser_awars(awr, AW_ROOT_DEFAULT); |
|---|
| 204 | #endif // DEBUG |
|---|
| 205 | |
|---|
| 206 | AW_create_namesadmin_awars(awr, GLOBAL.gb_main); |
|---|
| 207 | |
|---|
| 208 | awr->awar_int(AWAR_SECURITY_LEVEL, 0, AW_ROOT_DEFAULT); |
|---|
| 209 | awr->awar(AWAR_SECURITY_LEVEL)->add_callback(nt_changesecurity); |
|---|
| 210 | #if defined(DEBUG) && 0 |
|---|
| 211 | awr->awar(AWAR_SECURITY_LEVEL)->write_int(6); // no security for debugging.. |
|---|
| 212 | #endif // DEBUG |
|---|
| 213 | |
|---|
| 214 | create_insertDeleteColumn_variables(awr, AW_ROOT_DEFAULT); |
|---|
| 215 | create_probe_design_variables(awr, AW_ROOT_DEFAULT, GLOBAL.gb_main); |
|---|
| 216 | create_primer_design_variables(awr, AW_ROOT_DEFAULT, GLOBAL.gb_main); |
|---|
| 217 | create_trees_var(awr, AW_ROOT_DEFAULT); |
|---|
| 218 | DBUI::create_dbui_awars(awr); |
|---|
| 219 | AP_create_consensus_var(awr, AW_ROOT_DEFAULT); |
|---|
| 220 | { |
|---|
| 221 | GB_ERROR gde_err = GDE_init(awr, AW_ROOT_DEFAULT, GLOBAL.gb_main, NULp, ARB_format_alignment, GDE_WINDOWTYPE_DEFAULT); |
|---|
| 222 | if (gde_err) GBK_terminatef("Fatal: %s", gde_err); |
|---|
| 223 | } |
|---|
| 224 | NT_create_transpro_variables(awr, AW_ROOT_DEFAULT); |
|---|
| 225 | NT_create_resort_awars(awr, AW_ROOT_DEFAULT); |
|---|
| 226 | NT_create_compare_taxonomy_awars(awr, AW_ROOT_DEFAULT); |
|---|
| 227 | NT_create_trackAliChanges_Awars(awr, GLOBAL.gb_main); |
|---|
| 228 | |
|---|
| 229 | NT_create_alignment_vars(awr, AW_ROOT_DEFAULT, GLOBAL.gb_main); |
|---|
| 230 | NT_create_extendeds_vars(awr, AW_ROOT_DEFAULT, GLOBAL.gb_main); |
|---|
| 231 | create_nds_vars(awr, AW_ROOT_DEFAULT, GLOBAL.gb_main, false); |
|---|
| 232 | create_export_nds_awars(awr, AW_ROOT_DEFAULT); |
|---|
| 233 | create_group_search_awars(awr, AW_ROOT_DEFAULT); |
|---|
| 234 | TREE_create_awars(awr, GLOBAL.gb_main); |
|---|
| 235 | |
|---|
| 236 | awr->awar_string(AWAR_ERROR_MESSAGES, "", GLOBAL.gb_main); |
|---|
| 237 | awr->awar_string(AWAR_DB_COMMENT, "<no description>", GLOBAL.gb_main); |
|---|
| 238 | |
|---|
| 239 | AWTC_create_submission_variables(awr, GLOBAL.gb_main); |
|---|
| 240 | NT_createConcatenationAwars(awr, AW_ROOT_DEFAULT, GLOBAL.gb_main); |
|---|
| 241 | NT_createValidNamesAwars(awr, AW_ROOT_DEFAULT); // lothar |
|---|
| 242 | SQ_create_awars(awr, AW_ROOT_DEFAULT); |
|---|
| 243 | RefEntries::create_refentries_awars(awr, AW_ROOT_DEFAULT); |
|---|
| 244 | |
|---|
| 245 | NT_create_multifurcate_tree_awars(awr, AW_ROOT_DEFAULT); |
|---|
| 246 | |
|---|
| 247 | GB_ERROR error = ARB_bind_global_awars(GLOBAL.gb_main); |
|---|
| 248 | if (!error) { |
|---|
| 249 | AW_awar *awar_expert = awr->awar(AWAR_EXPERT); |
|---|
| 250 | awar_expert->add_callback(expert_mode_changed_cb); |
|---|
| 251 | awar_expert->touch(); |
|---|
| 252 | |
|---|
| 253 | awt_create_aww_vars(awr, AW_ROOT_DEFAULT); |
|---|
| 254 | } |
|---|
| 255 | |
|---|
| 256 | if (error) aw_message(error); |
|---|
| 257 | } |
|---|
| 258 | |
|---|
| 259 | // -------------------------------------------------------------------------------- |
|---|
| 260 | |
|---|
| 261 | static bool nt_disconnect_from_db(AW_root *aw_root, GBDATA*& gb_main_ref) { |
|---|
| 262 | // ask user if DB was not saved |
|---|
| 263 | // returns true if user allows to quit |
|---|
| 264 | |
|---|
| 265 | // @@@ code here could as well be applied to both merge DBs |
|---|
| 266 | // - question about saving only with target DB! |
|---|
| 267 | |
|---|
| 268 | if (gb_main_ref) { |
|---|
| 269 | if (GB_read_clients(gb_main_ref)>=0) { |
|---|
| 270 | if (GB_read_clock(gb_main_ref) > GB_last_saved_clock(gb_main_ref)) { |
|---|
| 271 | long secs; |
|---|
| 272 | secs = GB_last_saved_time(gb_main_ref); |
|---|
| 273 | |
|---|
| 274 | #if defined(DEBUG) |
|---|
| 275 | secs = GB_time_of_day(); // simulate "just saved" |
|---|
| 276 | #endif // DEBUG |
|---|
| 277 | |
|---|
| 278 | const char *quit_buttons = "Quit ARB,Do NOT quit"; |
|---|
| 279 | if (secs) { |
|---|
| 280 | secs = GB_time_of_day() - secs; |
|---|
| 281 | if (secs>10) { |
|---|
| 282 | char *question = GBS_global_string_copy("You last saved your data %li:%li minutes ago\nSure to quit ?", secs/60, secs%60); |
|---|
| 283 | int dontQuit = aw_question("quit_arb", question, quit_buttons); |
|---|
| 284 | free(question); |
|---|
| 285 | if (dontQuit) { |
|---|
| 286 | return false; |
|---|
| 287 | } |
|---|
| 288 | } |
|---|
| 289 | } |
|---|
| 290 | else { |
|---|
| 291 | if (aw_question("quit_arb", "You never saved any data\nSure to quit ???", quit_buttons)) { |
|---|
| 292 | return false; |
|---|
| 293 | } |
|---|
| 294 | } |
|---|
| 295 | } |
|---|
| 296 | } |
|---|
| 297 | |
|---|
| 298 | GBCMS_shutdown(gb_main_ref); |
|---|
| 299 | |
|---|
| 300 | GBDATA *gb_main = gb_main_ref; |
|---|
| 301 | gb_main_ref = NULp; // avoid further usage |
|---|
| 302 | |
|---|
| 303 | nt_assert(aw_root); |
|---|
| 304 | #if defined(WARN_TODO) |
|---|
| 305 | #warning instead of directly calling the following functions, try to add them as GB_atclose_callback |
|---|
| 306 | #endif |
|---|
| 307 | aw_root->unlink_awars_from_DB(gb_main); |
|---|
| 308 | AWT_destroy_input_masks(); |
|---|
| 309 | #if defined(DEBUG) |
|---|
| 310 | AWT_browser_forget_db(gb_main); |
|---|
| 311 | #endif // DEBUG |
|---|
| 312 | |
|---|
| 313 | GB_close(gb_main); |
|---|
| 314 | } |
|---|
| 315 | return true; |
|---|
| 316 | } |
|---|
| 317 | |
|---|
| 318 | static void nt_run(const char *command) { |
|---|
| 319 | GB_ERROR error = GBK_system(command); |
|---|
| 320 | if (error) { |
|---|
| 321 | fprintf(stderr, "nt_run: Failed to run '%s' (Reason: %s)\n", command, error); |
|---|
| 322 | #if defined(DEBUG) |
|---|
| 323 | GBK_dump_backtrace(stderr, "nt_run-error"); |
|---|
| 324 | #endif |
|---|
| 325 | } |
|---|
| 326 | } |
|---|
| 327 | |
|---|
| 328 | void NT_start(const char *arb_ntree_args, bool restart_with_new_ARB_PID) { |
|---|
| 329 | char *command = GBS_global_string_copy("arb_launcher --async %s %s", restart_with_new_ARB_PID ? "arb" : "arb_ntree", arb_ntree_args); |
|---|
| 330 | nt_run(command); |
|---|
| 331 | free(command); |
|---|
| 332 | } |
|---|
| 333 | |
|---|
| 334 | __ATTR__NORETURN static void really_exit(int exitcode, bool kill_my_clients) { |
|---|
| 335 | if (kill_my_clients) { |
|---|
| 336 | nt_run("(arb_clean session; echo ARB done) &"); // kills all clients |
|---|
| 337 | } |
|---|
| 338 | exit(exitcode); |
|---|
| 339 | } |
|---|
| 340 | |
|---|
| 341 | void NT_exit(AW_window *aws, int exitcode) { |
|---|
| 342 | AW_root *aw_root = aws->get_root(); |
|---|
| 343 | AWTI_cleanup_importer(); |
|---|
| 344 | shutdown_macro_recording(aw_root); |
|---|
| 345 | bool is_server_and_has_clients = GLOBAL.gb_main && GB_read_clients(GLOBAL.gb_main)>0; |
|---|
| 346 | if (nt_disconnect_from_db(aw_root, GLOBAL.gb_main)) { |
|---|
| 347 | really_exit(exitcode, is_server_and_has_clients); |
|---|
| 348 | } |
|---|
| 349 | } |
|---|
| 350 | void NT_restart(AW_root *aw_root, const char *arb_ntree_args) { |
|---|
| 351 | // restarts arb_ntree (with new ARB_PID) |
|---|
| 352 | bool is_server_and_has_clients = GLOBAL.gb_main && GB_read_clients(GLOBAL.gb_main)>0; |
|---|
| 353 | if (nt_disconnect_from_db(aw_root, GLOBAL.gb_main)) { |
|---|
| 354 | NT_start(arb_ntree_args, true); |
|---|
| 355 | really_exit(EXIT_SUCCESS, is_server_and_has_clients); |
|---|
| 356 | } |
|---|
| 357 | } |
|---|
| 358 | |
|---|
| 359 | static void nt_start_2nd_arb(AW_window *aww, bool quit) { |
|---|
| 360 | // start 2nd arb with intro window |
|---|
| 361 | AW_root *aw_root = aww->get_root(); |
|---|
| 362 | char *dir4intro; |
|---|
| 363 | GB_split_full_path(aw_root->awar(AWAR_DB_PATH)->read_char_pntr(), &dir4intro, NULp, NULp, NULp); |
|---|
| 364 | if (!dir4intro) { |
|---|
| 365 | dir4intro = ARB_strdup("."); |
|---|
| 366 | } |
|---|
| 367 | |
|---|
| 368 | if (quit) { |
|---|
| 369 | NT_restart(aw_root, dir4intro); |
|---|
| 370 | } |
|---|
| 371 | else { |
|---|
| 372 | NT_start(dir4intro, true); |
|---|
| 373 | } |
|---|
| 374 | free(dir4intro); |
|---|
| 375 | } |
|---|
| 376 | |
|---|
| 377 | // -------------------------------------------------------------------------------- |
|---|
| 378 | |
|---|
| 379 | static void NT_save_quick_cb(AW_window *aww) { |
|---|
| 380 | AW_root *awr = aww->get_root(); |
|---|
| 381 | char *filename = awr->awar(AWAR_DB_PATH)->read_string(); |
|---|
| 382 | |
|---|
| 383 | awr->dont_save_awars_with_default_value(GLOBAL.gb_main); |
|---|
| 384 | |
|---|
| 385 | GB_ERROR error = GB_save_quick(GLOBAL.gb_main, filename); |
|---|
| 386 | free( filename); |
|---|
| 387 | if (error) aw_message(error); |
|---|
| 388 | else AW_refresh_fileselection(awr, AWAR_DBBASE); |
|---|
| 389 | } |
|---|
| 390 | |
|---|
| 391 | |
|---|
| 392 | static void NT_save_quick_as_cb(AW_window *aww) { |
|---|
| 393 | AW_root *awr = aww->get_root(); |
|---|
| 394 | char *filename = awr->awar(AWAR_DB_PATH)->read_string(); |
|---|
| 395 | GB_ERROR error = GB_save_quick_as(GLOBAL.gb_main, filename); |
|---|
| 396 | if (!error) AW_refresh_fileselection(awr, AWAR_DBBASE); |
|---|
| 397 | aww->hide_or_notify(error); |
|---|
| 398 | |
|---|
| 399 | free(filename); |
|---|
| 400 | } |
|---|
| 401 | |
|---|
| 402 | #define AWAR_DB_TYPE AWAR_DBBASE "/type" // created by AWT_insert_DBsaveType_selector |
|---|
| 403 | #define AWAR_DB_COMPRESSION AWAR_DBBASE "/compression" // created by AWT_insert_DBcompression_selector |
|---|
| 404 | #define AWAR_DB_OPTI_TREENAME AWAR_DBBASE "/optimize_tree_name" |
|---|
| 405 | |
|---|
| 406 | static void NT_save_as_cb(AW_window *aww) { |
|---|
| 407 | AW_root *awr = aww->get_root(); |
|---|
| 408 | char *filename = awr->awar(AWAR_DB_PATH)->read_string(); |
|---|
| 409 | const char *atype = awr->awar(AWAR_DB_TYPE)->read_char_pntr(); |
|---|
| 410 | const char *ctype = awr->awar(AWAR_DB_COMPRESSION)->read_char_pntr(); |
|---|
| 411 | char *savetype = GBS_global_string_copy("%s%s", atype, ctype); |
|---|
| 412 | |
|---|
| 413 | awr->dont_save_awars_with_default_value(GLOBAL.gb_main); |
|---|
| 414 | GB_ERROR error = GB_save(GLOBAL.gb_main, filename, savetype); |
|---|
| 415 | if (!error) AW_refresh_fileselection(awr, AWAR_DBBASE); |
|---|
| 416 | aww->hide_or_notify(error); |
|---|
| 417 | |
|---|
| 418 | free(savetype); |
|---|
| 419 | free(filename); |
|---|
| 420 | } |
|---|
| 421 | |
|---|
| 422 | static AW_window *NT_create_save_quick_as_window(AW_root *aw_root, const char *base_name) { |
|---|
| 423 | static AW_window_simple *aws = NULp; |
|---|
| 424 | if (!aws) { |
|---|
| 425 | aws = new AW_window_simple; |
|---|
| 426 | aws->init(aw_root, "SAVE_CHANGES_TO", "Quicksave changes as"); |
|---|
| 427 | aws->load_xfig("save_as.fig"); |
|---|
| 428 | |
|---|
| 429 | aws->at("close"); |
|---|
| 430 | aws->callback(AW_POPDOWN); |
|---|
| 431 | aws->create_button("CLOSE", "CLOSE", "C"); |
|---|
| 432 | |
|---|
| 433 | aws->callback(makeHelpCallback("save.hlp")); |
|---|
| 434 | aws->at("help"); |
|---|
| 435 | aws->create_button("HELP", "HELP", "H"); |
|---|
| 436 | |
|---|
| 437 | AW_create_standard_fileselection(aws, base_name); |
|---|
| 438 | |
|---|
| 439 | aws->at("comment"); |
|---|
| 440 | aws->create_text_field(AWAR_DB_COMMENT); |
|---|
| 441 | |
|---|
| 442 | aws->at("save"); |
|---|
| 443 | aws->callback(NT_save_quick_as_cb); |
|---|
| 444 | aws->create_button("SAVE", "SAVE", "S"); |
|---|
| 445 | } |
|---|
| 446 | return aws; |
|---|
| 447 | } |
|---|
| 448 | |
|---|
| 449 | static void NT_database_optimization(AW_window *aww) { |
|---|
| 450 | arb_progress progress("Optimizing database compression", 2L); |
|---|
| 451 | GB_topSecurityLevel unsecured(GLOBAL.gb_main); |
|---|
| 452 | |
|---|
| 453 | GB_ERROR error = GB_begin_transaction(GLOBAL.gb_main); |
|---|
| 454 | if (!error) { |
|---|
| 455 | ConstStrArray ali_names; |
|---|
| 456 | GBT_get_alignment_names(ali_names, GLOBAL.gb_main); |
|---|
| 457 | |
|---|
| 458 | arb_progress ali_progress("Optimizing sequence data", ali_names.size()); |
|---|
| 459 | ali_progress.allow_title_reuse(); |
|---|
| 460 | |
|---|
| 461 | error = GBT_check_data(GLOBAL.gb_main, NULp); |
|---|
| 462 | error = GB_end_transaction(GLOBAL.gb_main, error); |
|---|
| 463 | |
|---|
| 464 | if (!error) { |
|---|
| 465 | char *tree_name = aww->get_root()->awar(AWAR_DB_OPTI_TREENAME)->read_string(); |
|---|
| 466 | for (int i = 0; ali_names[i]; ++i) { |
|---|
| 467 | error = GBT_compress_sequence_tree2(GLOBAL.gb_main, tree_name, ali_names[i]); |
|---|
| 468 | ali_progress.inc_and_check_user_abort(error); |
|---|
| 469 | } |
|---|
| 470 | free(tree_name); |
|---|
| 471 | } |
|---|
| 472 | } |
|---|
| 473 | progress.inc_and_check_user_abort(error); |
|---|
| 474 | |
|---|
| 475 | if (!error) { |
|---|
| 476 | error = GB_optimize(GLOBAL.gb_main); |
|---|
| 477 | progress.inc_and_check_user_abort(error); |
|---|
| 478 | } |
|---|
| 479 | aww->hide_or_notify(error); |
|---|
| 480 | } |
|---|
| 481 | |
|---|
| 482 | static AW_window *NT_create_database_optimization_window(AW_root *aw_root) { |
|---|
| 483 | static AW_window_simple *aws = NULp; |
|---|
| 484 | if (aws) return aws; |
|---|
| 485 | GB_transaction ta(GLOBAL.gb_main); |
|---|
| 486 | |
|---|
| 487 | const char *largest_tree = GBT_name_of_largest_tree(GLOBAL.gb_main); |
|---|
| 488 | aw_root->awar_string(AWAR_DB_OPTI_TREENAME, largest_tree); |
|---|
| 489 | |
|---|
| 490 | aws = new AW_window_simple; |
|---|
| 491 | aws->init(aw_root, "OPTIMIZE_DATABASE", "Optimize database compression"); |
|---|
| 492 | aws->load_xfig("optimize.fig"); |
|---|
| 493 | |
|---|
| 494 | aws->at("trees"); |
|---|
| 495 | awt_create_TREE_selection_list(GLOBAL.gb_main, aws, AWAR_DB_OPTI_TREENAME, true); |
|---|
| 496 | |
|---|
| 497 | aws->at("close"); |
|---|
| 498 | aws->callback(AW_POPDOWN); |
|---|
| 499 | aws->create_button("CLOSE", "CLOSE", "C"); |
|---|
| 500 | |
|---|
| 501 | aws->callback(makeHelpCallback("optimize.hlp")); |
|---|
| 502 | aws->at("help"); |
|---|
| 503 | aws->create_button("HELP", "HELP", "H"); |
|---|
| 504 | |
|---|
| 505 | aws->at("go"); |
|---|
| 506 | aws->callback(NT_database_optimization); |
|---|
| 507 | aws->create_button("GO", "GO"); |
|---|
| 508 | return aws; |
|---|
| 509 | } |
|---|
| 510 | |
|---|
| 511 | static AW_window *NT_create_save_as(AW_root *aw_root, const char *base_name) { |
|---|
| 512 | static AW_window_simple *aws = NULp; |
|---|
| 513 | if (aws) return aws; |
|---|
| 514 | |
|---|
| 515 | aws = new AW_window_simple; |
|---|
| 516 | aws->init(aw_root, "SAVE_DB", "SAVE ARB DB"); |
|---|
| 517 | aws->load_xfig("save_as.fig"); |
|---|
| 518 | |
|---|
| 519 | aws->at("close"); |
|---|
| 520 | aws->callback(AW_POPDOWN); |
|---|
| 521 | aws->create_button("CLOSE", "CLOSE", "C"); |
|---|
| 522 | |
|---|
| 523 | aws->at("help"); |
|---|
| 524 | aws->callback(makeHelpCallback("save.hlp")); |
|---|
| 525 | aws->create_button("HELP", "HELP", "H"); |
|---|
| 526 | |
|---|
| 527 | AW_create_standard_fileselection(aws, base_name); |
|---|
| 528 | |
|---|
| 529 | aws->at("type"); |
|---|
| 530 | AWT_insert_DBsaveType_selector(aws, AWAR_DB_TYPE); |
|---|
| 531 | |
|---|
| 532 | aws->at("compression"); |
|---|
| 533 | AWT_insert_DBcompression_selector(aws, AWAR_DB_COMPRESSION); |
|---|
| 534 | |
|---|
| 535 | aws->at("optimize"); |
|---|
| 536 | aws->callback(NT_create_database_optimization_window); |
|---|
| 537 | aws->help_text("optimize.hlp"); |
|---|
| 538 | aws->create_autosize_button("OPTIMIZE", "Optimize database compression"); |
|---|
| 539 | |
|---|
| 540 | aws->at("save"); |
|---|
| 541 | aws->callback(NT_save_as_cb); |
|---|
| 542 | aws->create_button("SAVE", "SAVE", "S"); |
|---|
| 543 | |
|---|
| 544 | aws->at("comment"); |
|---|
| 545 | aws->create_text_field(AWAR_DB_COMMENT); |
|---|
| 546 | |
|---|
| 547 | return aws; |
|---|
| 548 | } |
|---|
| 549 | |
|---|
| 550 | static void NT_undo_cb(AW_window*, GB_UNDO_TYPE undo_type, TREE_canvas *ntw) { |
|---|
| 551 | GB_ERROR error = GB_undo(GLOBAL.gb_main, undo_type); |
|---|
| 552 | if (error) aw_message(error); |
|---|
| 553 | else { |
|---|
| 554 | GB_transaction ta(GLOBAL.gb_main); |
|---|
| 555 | AWT_auto_refresh allowed_on(ntw); |
|---|
| 556 | ntw->request_refresh(); |
|---|
| 557 | } |
|---|
| 558 | } |
|---|
| 559 | |
|---|
| 560 | enum streamSource { FROM_PIPE, FROM_FILE }; |
|---|
| 561 | static char *stream2str(streamSource source, const char *commandOrFile) { |
|---|
| 562 | char *output = NULp; |
|---|
| 563 | FILE *in = NULp; |
|---|
| 564 | |
|---|
| 565 | switch (source) { |
|---|
| 566 | case FROM_PIPE: in = popen(commandOrFile, "r"); break; |
|---|
| 567 | case FROM_FILE: in = fopen(commandOrFile, "rt"); break; |
|---|
| 568 | } |
|---|
| 569 | |
|---|
| 570 | if (in) { |
|---|
| 571 | GBS_strstruct *out = GBS_stropen(2000); |
|---|
| 572 | int c; |
|---|
| 573 | |
|---|
| 574 | while (EOF != (c = fgetc(in))) GBS_chrcat(out, c); |
|---|
| 575 | |
|---|
| 576 | switch (source) { |
|---|
| 577 | case FROM_PIPE: pclose(in); break; |
|---|
| 578 | case FROM_FILE: fclose(in); break; |
|---|
| 579 | } |
|---|
| 580 | |
|---|
| 581 | // skip trailing linefeeds |
|---|
| 582 | long offset = GBS_memoffset(out); |
|---|
| 583 | while (offset>0 && GBS_mempntr(out)[offset-1] == '\n') { |
|---|
| 584 | GBS_str_cut_tail(out, 1); |
|---|
| 585 | offset--; |
|---|
| 586 | } |
|---|
| 587 | |
|---|
| 588 | output = GBS_strclose(out); |
|---|
| 589 | } |
|---|
| 590 | return output; |
|---|
| 591 | } |
|---|
| 592 | |
|---|
| 593 | inline void removeTrailingNewlines(char *str) { |
|---|
| 594 | char *eos = strchr(str, 0)-1; |
|---|
| 595 | while (eos >= str && eos[0] == '\n') *eos-- = 0; |
|---|
| 596 | } |
|---|
| 597 | |
|---|
| 598 | inline void append_named_value(GBS_strstruct *out, const char *prefix, const char *value) { |
|---|
| 599 | GBS_strcat(out, GBS_global_string("%-*s: %s\n", 12, prefix, value)); |
|---|
| 600 | } |
|---|
| 601 | inline void append_command_output(GBS_strstruct *out, const char *prefix, const char *command) { |
|---|
| 602 | char *output = stream2str(FROM_PIPE, command); |
|---|
| 603 | if (output) { |
|---|
| 604 | removeTrailingNewlines(output); |
|---|
| 605 | if (strcmp(output, "unknown") != 0) append_named_value(out, prefix, output); |
|---|
| 606 | free(output); |
|---|
| 607 | } |
|---|
| 608 | } |
|---|
| 609 | |
|---|
| 610 | static void NT_infomode_cb(UNFIXED, TREE_canvas *canvas, AWT_COMMAND_MODE mode) { |
|---|
| 611 | DBUI::popup_species_info_window(canvas->awr, canvas->gb_main); |
|---|
| 612 | nt_mode_event(NULp, canvas, mode); |
|---|
| 613 | } |
|---|
| 614 | |
|---|
| 615 | static void NT_mark_duplicates(UNFIXED, TREE_canvas *ntw) { |
|---|
| 616 | AP_tree *tree_root = AWT_TREE(ntw)->get_root_node(); |
|---|
| 617 | if (tree_root) { |
|---|
| 618 | AWT_auto_refresh allowed_on(ntw); |
|---|
| 619 | GB_transaction ta(ntw->gb_main); |
|---|
| 620 | |
|---|
| 621 | NT_mark_all_cb(NULp, ntw, 0); // unmark all |
|---|
| 622 | tree_root->mark_duplicates(); |
|---|
| 623 | ntw->request_structure_update(); |
|---|
| 624 | } |
|---|
| 625 | } |
|---|
| 626 | |
|---|
| 627 | static void NT_justify_branch_lenghs(UNFIXED, TREE_canvas *ntw) { |
|---|
| 628 | GB_transaction ta(ntw->gb_main); |
|---|
| 629 | AP_tree *tree_root = AWT_TREE(ntw)->get_root_node(); |
|---|
| 630 | |
|---|
| 631 | if (tree_root) { |
|---|
| 632 | AWT_auto_refresh allowed_on(ntw); |
|---|
| 633 | tree_root->justify_branch_lenghs(ntw->gb_main); |
|---|
| 634 | ntw->request_save_and_zoom_reset(); |
|---|
| 635 | } |
|---|
| 636 | } |
|---|
| 637 | |
|---|
| 638 | #if defined(DEBUG) |
|---|
| 639 | static void NT_fix_database(AW_window *) { |
|---|
| 640 | GB_ERROR err = NULp; |
|---|
| 641 | err = GB_fix_database(GLOBAL.gb_main); |
|---|
| 642 | if (err) aw_message(err); |
|---|
| 643 | } |
|---|
| 644 | #endif |
|---|
| 645 | |
|---|
| 646 | static void relink_pseudo_species_to_organisms(GBDATA *&ref_gb_node, char *&ref_name, GB_HASH *organism_hash) { |
|---|
| 647 | if (ref_gb_node) { |
|---|
| 648 | if (GEN_is_pseudo_gene_species(ref_gb_node)) { |
|---|
| 649 | GBDATA *gb_organism = GEN_find_origin_organism(ref_gb_node, organism_hash); |
|---|
| 650 | |
|---|
| 651 | if (gb_organism) { |
|---|
| 652 | char *name = GBT_read_string(gb_organism, "name"); |
|---|
| 653 | |
|---|
| 654 | if (name) { |
|---|
| 655 | freeset(ref_name, name); |
|---|
| 656 | ref_gb_node = gb_organism; |
|---|
| 657 | } |
|---|
| 658 | } |
|---|
| 659 | } |
|---|
| 660 | } |
|---|
| 661 | } |
|---|
| 662 | |
|---|
| 663 | static void NT_pseudo_species_to_organism(AW_window *, TREE_canvas *ntw) { |
|---|
| 664 | GB_transaction ta(ntw->gb_main); |
|---|
| 665 | AP_tree *tree_root = AWT_TREE(ntw)->get_root_node(); |
|---|
| 666 | |
|---|
| 667 | if (tree_root) { |
|---|
| 668 | AWT_auto_refresh allowed_on(ntw); |
|---|
| 669 | |
|---|
| 670 | GB_HASH *organism_hash = GBT_create_organism_hash(ntw->gb_main); |
|---|
| 671 | tree_root->relink_tree(ntw->gb_main, relink_pseudo_species_to_organisms, organism_hash); |
|---|
| 672 | GBS_free_hash(organism_hash); |
|---|
| 673 | ntw->request_save(); |
|---|
| 674 | } |
|---|
| 675 | } |
|---|
| 676 | |
|---|
| 677 | |
|---|
| 678 | // ######################################### |
|---|
| 679 | // ######################################### |
|---|
| 680 | // ### ### |
|---|
| 681 | // ## user mask section ## |
|---|
| 682 | // ### ### |
|---|
| 683 | // ######################################### |
|---|
| 684 | // ######################################### |
|---|
| 685 | |
|---|
| 686 | struct nt_item_type_species_selector FINAL_TYPE : public awt_item_type_selector { |
|---|
| 687 | nt_item_type_species_selector() : awt_item_type_selector(AWT_IT_SPECIES) {} |
|---|
| 688 | ~nt_item_type_species_selector() OVERRIDE {} |
|---|
| 689 | |
|---|
| 690 | const char *get_self_awar() const OVERRIDE { |
|---|
| 691 | return AWAR_SPECIES_NAME; |
|---|
| 692 | } |
|---|
| 693 | size_t get_self_awar_content_length() const OVERRIDE { |
|---|
| 694 | return 12; // should be enough for "nnaammee.999" |
|---|
| 695 | } |
|---|
| 696 | GBDATA *current(AW_root *root, GBDATA *gb_main) const OVERRIDE { // give the current item |
|---|
| 697 | char *species_name = root->awar(get_self_awar())->read_string(); |
|---|
| 698 | GBDATA *gb_species = NULp; |
|---|
| 699 | |
|---|
| 700 | if (species_name[0]) { |
|---|
| 701 | GB_transaction ta(gb_main); |
|---|
| 702 | gb_species = GBT_find_species(gb_main, species_name); |
|---|
| 703 | } |
|---|
| 704 | |
|---|
| 705 | free(species_name); |
|---|
| 706 | return gb_species; |
|---|
| 707 | } |
|---|
| 708 | const char *getKeyPath() const OVERRIDE { // give the keypath for items |
|---|
| 709 | return CHANGE_KEY_PATH; |
|---|
| 710 | } |
|---|
| 711 | }; |
|---|
| 712 | |
|---|
| 713 | static nt_item_type_species_selector item_type_species; |
|---|
| 714 | |
|---|
| 715 | static void NT_open_mask_window(AW_window *aww, int id, GBDATA *gb_main) { |
|---|
| 716 | const awt_input_mask_descriptor *descriptor = AWT_look_input_mask(id); |
|---|
| 717 | nt_assert(descriptor); |
|---|
| 718 | if (descriptor) AWT_initialize_input_mask(aww->get_root(), gb_main, &item_type_species, descriptor->get_internal_maskname(), descriptor->is_local_mask()); |
|---|
| 719 | } |
|---|
| 720 | |
|---|
| 721 | static void NT_create_mask_submenu(AW_window_menu_modes *awm) { |
|---|
| 722 | AWT_create_mask_submenu(awm, AWT_IT_SPECIES, NT_open_mask_window, GLOBAL.gb_main); |
|---|
| 723 | } |
|---|
| 724 | static AW_window *create_colorize_species_window(AW_root *aw_root) { |
|---|
| 725 | return QUERY::create_colorize_items_window(aw_root, GLOBAL.gb_main, SPECIES_get_selector()); |
|---|
| 726 | } |
|---|
| 727 | |
|---|
| 728 | static void NT_update_marked_counter(GBDATA*, AW_window* aww) { |
|---|
| 729 | /*! Updates marked counter and issues redraw on tree if number of marked species changes. |
|---|
| 730 | * Called on any change of species_information container. |
|---|
| 731 | */ |
|---|
| 732 | long count = GBT_count_marked_species(GLOBAL.gb_main); |
|---|
| 733 | const char *buffer = count ? GBS_global_string("%li marked", count) : ""; |
|---|
| 734 | AW_awar *counter = aww->get_root()->awar(AWAR_MARKED_SPECIES_COUNTER); |
|---|
| 735 | char *oldval = counter->read_string(); |
|---|
| 736 | if (strcmp(oldval, buffer)) { |
|---|
| 737 | counter->write_string(buffer); |
|---|
| 738 | aww->get_root()->awar(AWAR_TREE_REFRESH)->touch(); |
|---|
| 739 | } |
|---|
| 740 | free(oldval); |
|---|
| 741 | } |
|---|
| 742 | |
|---|
| 743 | // -------------------------------------------------------------------------------------------------- |
|---|
| 744 | |
|---|
| 745 | static void NT_alltree_remove_leafs(AW_window *, GBT_TreeRemoveType mode, GBDATA *gb_main) { |
|---|
| 746 | GB_ERROR error = NULp; |
|---|
| 747 | GB_transaction ta(gb_main); |
|---|
| 748 | |
|---|
| 749 | ConstStrArray tree_names; |
|---|
| 750 | GBT_get_tree_names(tree_names, gb_main, false); |
|---|
| 751 | |
|---|
| 752 | if (!tree_names.empty()) { |
|---|
| 753 | long treeCount = tree_names.size(); |
|---|
| 754 | |
|---|
| 755 | const char *whats_removed = NULp; |
|---|
| 756 | switch (mode) { |
|---|
| 757 | case GBT_REMOVE_ZOMBIES: whats_removed = "zombies"; break; |
|---|
| 758 | case GBT_REMOVE_MARKED: whats_removed = "marked"; break; |
|---|
| 759 | default: nt_assert(0); break; |
|---|
| 760 | } |
|---|
| 761 | |
|---|
| 762 | const char *task = GBS_global_string("Deleting %s from %li trees", whats_removed, treeCount); |
|---|
| 763 | |
|---|
| 764 | arb_progress progress(task, treeCount); |
|---|
| 765 | GB_HASH *species_hash = GBT_create_species_hash(gb_main); |
|---|
| 766 | |
|---|
| 767 | int modified = 0; |
|---|
| 768 | |
|---|
| 769 | for (int t = 0; t<treeCount && !error; t++) { |
|---|
| 770 | progress.subtitle(tree_names[t]); |
|---|
| 771 | TreeNode *tree = GBT_read_tree(gb_main, tree_names[t], new SimpleRoot); |
|---|
| 772 | if (!tree) { |
|---|
| 773 | aw_message(GBS_global_string("Can't load tree '%s' - skipped", tree_names[t])); |
|---|
| 774 | } |
|---|
| 775 | else { |
|---|
| 776 | int removed = 0; |
|---|
| 777 | int groups_removed = 0; |
|---|
| 778 | |
|---|
| 779 | tree = GBT_remove_leafs(tree, mode, species_hash, &removed, &groups_removed); |
|---|
| 780 | |
|---|
| 781 | nt_assert(removed >= groups_removed); |
|---|
| 782 | |
|---|
| 783 | if (!tree) { |
|---|
| 784 | aw_message(GBS_global_string("'%s' would disappear. Please delete tree manually.", tree_names[t])); |
|---|
| 785 | } |
|---|
| 786 | else { |
|---|
| 787 | if (removed>0) { |
|---|
| 788 | error = GBT_write_tree(gb_main, tree_names[t], tree); |
|---|
| 789 | if (error) { |
|---|
| 790 | aw_message(GBS_global_string("Failed to write '%s' (Reason: %s)", tree_names[t], error)); |
|---|
| 791 | } |
|---|
| 792 | else { |
|---|
| 793 | if (groups_removed>0) { |
|---|
| 794 | aw_message(GBS_global_string("Removed %i species and %i groups from '%s'", removed, groups_removed, tree_names[t])); |
|---|
| 795 | } |
|---|
| 796 | else { |
|---|
| 797 | aw_message(GBS_global_string("Removed %i species from '%s'", removed, tree_names[t])); |
|---|
| 798 | } |
|---|
| 799 | modified++; |
|---|
| 800 | } |
|---|
| 801 | } |
|---|
| 802 | UNCOVERED(); |
|---|
| 803 | destroy(tree); |
|---|
| 804 | } |
|---|
| 805 | } |
|---|
| 806 | progress.inc_and_check_user_abort(error); |
|---|
| 807 | } |
|---|
| 808 | |
|---|
| 809 | if (modified) { |
|---|
| 810 | aw_message(GBS_global_string("Changed %i of %li trees.", modified, treeCount)); |
|---|
| 811 | } |
|---|
| 812 | else { |
|---|
| 813 | aw_message("No tree modified"); |
|---|
| 814 | } |
|---|
| 815 | |
|---|
| 816 | GBS_free_hash(species_hash); |
|---|
| 817 | } |
|---|
| 818 | |
|---|
| 819 | aw_message_if(ta.close(error)); |
|---|
| 820 | } |
|---|
| 821 | |
|---|
| 822 | TreeNode *NT_get_tree_root_of_canvas(TREE_canvas *ntw) { |
|---|
| 823 | AWT_graphic_tree *tree = AWT_TREE(ntw); |
|---|
| 824 | if (tree) { |
|---|
| 825 | AP_tree *root = tree->get_root_node(); |
|---|
| 826 | if (root) return root; |
|---|
| 827 | } |
|---|
| 828 | return NULp; |
|---|
| 829 | } |
|---|
| 830 | |
|---|
| 831 | // -------------------------------------------------------------------------------------------------- |
|---|
| 832 | |
|---|
| 833 | static ARB_ERROR mark_referred_species(GBDATA *gb_main, const DBItemSet& referred) { |
|---|
| 834 | GB_transaction ta(gb_main); |
|---|
| 835 | GBT_mark_all(gb_main, 0); |
|---|
| 836 | |
|---|
| 837 | DBItemSetIter end = referred.end(); |
|---|
| 838 | for (DBItemSetIter s = referred.begin(); s != end; ++s) { |
|---|
| 839 | GB_write_flag(*s, 1); |
|---|
| 840 | } |
|---|
| 841 | return ARB_ERROR(); |
|---|
| 842 | } |
|---|
| 843 | |
|---|
| 844 | static AW_window *create_mark_by_refentries_window(AW_root *awr, GBDATA *gbmain) { |
|---|
| 845 | static AW_window *aws = NULp; |
|---|
| 846 | if (!aws) { |
|---|
| 847 | static RefEntries::ReferringEntriesHandler reh(gbmain, SPECIES_get_selector()); |
|---|
| 848 | aws = RefEntries::create_refentries_window(awr, &reh, "markbyref", "Mark by reference", "markbyref.hlp", NULp, "Mark referenced", mark_referred_species); |
|---|
| 849 | } |
|---|
| 850 | return aws; |
|---|
| 851 | } |
|---|
| 852 | |
|---|
| 853 | // -------------------------------------------------------------------------------------------------- |
|---|
| 854 | |
|---|
| 855 | static void merge_from_to(AW_root *awr, const char *db_awar_name, bool merge_to) { |
|---|
| 856 | const char *db_name = awr->awar(db_awar_name)->read_char_pntr(); |
|---|
| 857 | char *quotedDB = GBK_singlequote(db_name); |
|---|
| 858 | |
|---|
| 859 | AWT_system_cb( |
|---|
| 860 | GBS_global_string( |
|---|
| 861 | merge_to |
|---|
| 862 | ? "arb_ntree : %s &" |
|---|
| 863 | : "arb_ntree %s : &", |
|---|
| 864 | quotedDB) |
|---|
| 865 | ); |
|---|
| 866 | |
|---|
| 867 | free(quotedDB); |
|---|
| 868 | } |
|---|
| 869 | |
|---|
| 870 | static void merge_from_cb(AW_window *aww, AW_CL cl_awarNamePtr) { merge_from_to(aww->get_root(), *(const char**)cl_awarNamePtr, false); } |
|---|
| 871 | static void merge_into_cb(AW_window *aww, AW_CL cl_awarNamePtr) { merge_from_to(aww->get_root(), *(const char**)cl_awarNamePtr, true); } |
|---|
| 872 | |
|---|
| 873 | static AW_window *NT_create_merge_from_window(AW_root *awr) { |
|---|
| 874 | static char *awar_name = NULp; // do not free, bound to callback |
|---|
| 875 | AW_window *aw_from = |
|---|
| 876 | awt_create_load_box(awr, "Merge data from", "other ARB database", |
|---|
| 877 | ".", ".arb", &awar_name, |
|---|
| 878 | makeWindowCallback(merge_from_cb, AW_CL(&awar_name))); |
|---|
| 879 | return aw_from; |
|---|
| 880 | } |
|---|
| 881 | static AW_window *NT_create_merge_to_window(AW_root *awr) { |
|---|
| 882 | static char *awar_name = NULp; // do not free, bound to callback |
|---|
| 883 | AW_window *aw_to = |
|---|
| 884 | awt_create_load_box(awr, "Merge data to", "other ARB database", |
|---|
| 885 | ".", ".arb", &awar_name, |
|---|
| 886 | makeWindowCallback(merge_into_cb, AW_CL(&awar_name)), |
|---|
| 887 | makeWindowCallback(AW_POPDOWN), NULp); |
|---|
| 888 | return aw_to; |
|---|
| 889 | } |
|---|
| 890 | |
|---|
| 891 | // -------------------------------------------------------------------------------------------------- |
|---|
| 892 | |
|---|
| 893 | static void update_main_window_title(AW_root* awr, AW_window_menu_modes* aww, int clone) { |
|---|
| 894 | const char* filename = awr->awar(AWAR_DB_NAME)->read_char_pntr(); |
|---|
| 895 | if (clone) { |
|---|
| 896 | aww->set_window_title(GBS_global_string("%s - ARB (%i)", filename, clone)); |
|---|
| 897 | } |
|---|
| 898 | else { |
|---|
| 899 | aww->set_window_title(GBS_global_string("%s - ARB", filename)); |
|---|
| 900 | } |
|---|
| 901 | } |
|---|
| 902 | |
|---|
| 903 | static void canvas_tree_awar_changed_cb(AW_awar *, bool, TREE_canvas *ntw) { |
|---|
| 904 | NT_reload_tree_event(AW_root::SINGLETON, ntw, true); |
|---|
| 905 | AW_root::SINGLETON->awar(AWAR_NTREE_MAIN_WINDOW_COUNT)->touch(); // refresh canvas selection lists |
|---|
| 906 | TREE_auto_jump_cb(NULp, ntw, AP_JUMP_REASON_TREE); |
|---|
| 907 | } |
|---|
| 908 | |
|---|
| 909 | class TREE_canvas_registry { |
|---|
| 910 | int count; |
|---|
| 911 | TREE_canvas *canvas[MAX_NT_WINDOWS]; |
|---|
| 912 | |
|---|
| 913 | static TREE_canvas_registry *SINGLETON; |
|---|
| 914 | |
|---|
| 915 | TREE_canvas_registry() : count(0) { |
|---|
| 916 | AW_root::SINGLETON->awar_int(AWAR_NTREE_MAIN_WINDOW_COUNT, 0, AW_ROOT_DEFAULT); |
|---|
| 917 | } |
|---|
| 918 | |
|---|
| 919 | public: |
|---|
| 920 | static TREE_canvas_registry& instance() { |
|---|
| 921 | if (!SINGLETON) SINGLETON = new TREE_canvas_registry; |
|---|
| 922 | return *SINGLETON; |
|---|
| 923 | } |
|---|
| 924 | |
|---|
| 925 | void register_canvas(TREE_canvas *ntw) { |
|---|
| 926 | nt_assert(count<MAX_NT_WINDOWS); |
|---|
| 927 | nt_assert(count == ntw->get_index()); // you have to register TREE_canvas'es in order of creation! |
|---|
| 928 | canvas[count++] = ntw; |
|---|
| 929 | ntw->awr->awar(AWAR_NTREE_MAIN_WINDOW_COUNT)->write_int(count); // trigger callbacks |
|---|
| 930 | } |
|---|
| 931 | |
|---|
| 932 | int get_count() const { return count; } |
|---|
| 933 | |
|---|
| 934 | TREE_canvas *get_canvas(int idx) const { |
|---|
| 935 | if (idx<0 || idx>=count) return NULp; |
|---|
| 936 | return canvas[idx]; |
|---|
| 937 | } |
|---|
| 938 | }; |
|---|
| 939 | |
|---|
| 940 | TREE_canvas_registry *TREE_canvas_registry::SINGLETON = NULp; |
|---|
| 941 | |
|---|
| 942 | TREE_canvas *NT_get_canvas_by_index(int idx) { |
|---|
| 943 | /*! return canvas with index 'idx' [0...MAX_NT_WINDOWS-1] */ |
|---|
| 944 | nt_assert(idx>=0 && idx<MAX_NT_WINDOWS); |
|---|
| 945 | return TREE_canvas_registry::instance().get_canvas(idx); |
|---|
| 946 | } |
|---|
| 947 | |
|---|
| 948 | #if defined(TRACE_GROUP_SELECTION) |
|---|
| 949 | static TREE_canvas *find_canvas_showing(AWT_graphic_tree *agt) { |
|---|
| 950 | // look for (registered) canvas showing given AWT_graphic_tree |
|---|
| 951 | // returns NULp if none found |
|---|
| 952 | const TREE_canvas_registry& reg = TREE_canvas_registry::instance(); |
|---|
| 953 | |
|---|
| 954 | int maxIdx = reg.get_count(); |
|---|
| 955 | for (int32_t i = 0; i<maxIdx; ++i) { |
|---|
| 956 | TREE_canvas *ntw = reg.get_canvas(i); |
|---|
| 957 | if (ntw->gfx == agt) return ntw; |
|---|
| 958 | } |
|---|
| 959 | return NULp; |
|---|
| 960 | } |
|---|
| 961 | #endif |
|---|
| 962 | |
|---|
| 963 | void NT_fill_canvas_selection_list(class AW_selection_list *sellst, TREE_canvas *to_skip) { |
|---|
| 964 | /*! insert canvases into selection list (using canvas-indices as values) |
|---|
| 965 | */ |
|---|
| 966 | const TREE_canvas_registry& reg = TREE_canvas_registry::instance(); |
|---|
| 967 | |
|---|
| 968 | int maxIdx = reg.get_count(); |
|---|
| 969 | for (int32_t i = 0; i<maxIdx; ++i) { |
|---|
| 970 | TREE_canvas *ntw = reg.get_canvas(i); |
|---|
| 971 | if (ntw && ntw != to_skip) { |
|---|
| 972 | nt_assert(ntw->get_awar_tree()); |
|---|
| 973 | const char *treename = ntw->get_awar_tree()->read_char_pntr(); |
|---|
| 974 | const char *description = i |
|---|
| 975 | ? GBS_global_string("ARB (%i): %s", i, treename) |
|---|
| 976 | : GBS_global_string("ARB main: %s", treename); |
|---|
| 977 | sellst->insert(description, i); |
|---|
| 978 | } |
|---|
| 979 | } |
|---|
| 980 | } |
|---|
| 981 | |
|---|
| 982 | // ---------------------------------- |
|---|
| 983 | // group-selection handlers |
|---|
| 984 | |
|---|
| 985 | void NT_deselect_group(AW_root *awr) { |
|---|
| 986 | awr->awar(AWAR_GROUP)->write_pointer(NULp); |
|---|
| 987 | } |
|---|
| 988 | |
|---|
| 989 | static bool track_group_selection_by_canvas = true; |
|---|
| 990 | |
|---|
| 991 | static void group_selected_by_canvas_cb(AWT_graphic_tree *gfx) { |
|---|
| 992 | const Group& group = gfx->get_selected_group(); |
|---|
| 993 | |
|---|
| 994 | #if defined(TRACE_GROUP_SELECTION) |
|---|
| 995 | fprintf(stderr, "[%s] ", track_group_selection_by_canvas ? "track" : "dont track"); |
|---|
| 996 | TREE_canvas *ntw = find_canvas_showing(gfx); |
|---|
| 997 | if (group.is_valid()) { |
|---|
| 998 | fprintf(stderr, "canvas %i selects group '%s'\n", ntw->get_index(), group.get_name()); |
|---|
| 999 | } |
|---|
| 1000 | else { |
|---|
| 1001 | fprintf(stderr, "canvas %i de-selects group\n", ntw->get_index()); |
|---|
| 1002 | } |
|---|
| 1003 | #endif |
|---|
| 1004 | |
|---|
| 1005 | if (track_group_selection_by_canvas) { |
|---|
| 1006 | // set group-awar: |
|---|
| 1007 | gfx->get_root()->awar(AWAR_GROUP)->write_pointer(group.get_group_data()); // writes NULp if !group.is_valid() |
|---|
| 1008 | } |
|---|
| 1009 | } |
|---|
| 1010 | |
|---|
| 1011 | static void group_awar_changed_cb(AW_root *awr) { |
|---|
| 1012 | AW_awar *awar_group = awr->awar(AWAR_GROUP); |
|---|
| 1013 | GBDATA *gb_wanted_group = awar_group->read_pointer(); |
|---|
| 1014 | |
|---|
| 1015 | GBDATA *gb_wanted_tree = NULp; |
|---|
| 1016 | { |
|---|
| 1017 | if (gb_wanted_group) { |
|---|
| 1018 | GB_transaction ta(gb_wanted_group); |
|---|
| 1019 | gb_wanted_tree = GB_get_father(gb_wanted_group); |
|---|
| 1020 | awr->awar(AWAR_SPECIES_NAME)->write_string(""); // deselect species when group gets selected |
|---|
| 1021 | #if defined(TRACE_GROUP_SELECTION) |
|---|
| 1022 | fputs("clear AWAR_SPECIES_NAME (because group selected)\n", stderr); |
|---|
| 1023 | #endif |
|---|
| 1024 | } |
|---|
| 1025 | #if defined(TRACE_GROUP_SELECTION) |
|---|
| 1026 | const char *group_name = NULp; |
|---|
| 1027 | if (gb_wanted_group) { |
|---|
| 1028 | GB_transaction ta(gb_wanted_group); |
|---|
| 1029 | GBDATA *gb_name = GB_entry(gb_wanted_group, "group_name"); |
|---|
| 1030 | if (gb_name) group_name = GB_read_char_pntr(gb_name); |
|---|
| 1031 | } |
|---|
| 1032 | fprintf(stderr, "group awar changed to %p", gb_wanted_group); |
|---|
| 1033 | if (group_name) fprintf(stderr, " (='%s')", group_name); |
|---|
| 1034 | fputc('\n', stderr); |
|---|
| 1035 | #endif |
|---|
| 1036 | } |
|---|
| 1037 | |
|---|
| 1038 | LocallyModify<bool> ignore_group_selection_by_canvas(track_group_selection_by_canvas, false); |
|---|
| 1039 | |
|---|
| 1040 | { |
|---|
| 1041 | const TREE_canvas_registry& reg = TREE_canvas_registry::instance(); |
|---|
| 1042 | |
|---|
| 1043 | int maxIdx = reg.get_count(); |
|---|
| 1044 | for (int32_t i = 0; i<maxIdx; ++i) { |
|---|
| 1045 | TREE_canvas *ntw = reg.get_canvas(i); |
|---|
| 1046 | AWT_graphic_tree *agt = AWT_TREE(ntw); |
|---|
| 1047 | const Group& curr_group = agt->get_selected_group(); |
|---|
| 1048 | |
|---|
| 1049 | GBDATA *gb_curr_tree = agt->get_tree_root()->get_gb_tree(); |
|---|
| 1050 | if (gb_curr_tree == gb_wanted_tree) { |
|---|
| 1051 | AWT_auto_refresh allowed_on(ntw); |
|---|
| 1052 | if (!curr_group.is_valid() || // no group selected |
|---|
| 1053 | curr_group.get_group_data() != gb_wanted_group) // wrong group selected |
|---|
| 1054 | { |
|---|
| 1055 | agt->select_group(gb_wanted_group); |
|---|
| 1056 | ntw->request_refresh(); |
|---|
| 1057 | } |
|---|
| 1058 | // perform auto-jump (also if group was already selected, otherwise group-traversal keys will not follow the selected group) |
|---|
| 1059 | TREE_auto_jump_cb(NULp, ntw, AP_JUMP_REASON_GROUP); |
|---|
| 1060 | } |
|---|
| 1061 | else { |
|---|
| 1062 | if (curr_group.is_valid()) { |
|---|
| 1063 | AWT_auto_refresh allowed_on(ntw); |
|---|
| 1064 | agt->deselect_group(); |
|---|
| 1065 | ntw->request_refresh(); |
|---|
| 1066 | } |
|---|
| 1067 | } |
|---|
| 1068 | } |
|---|
| 1069 | } |
|---|
| 1070 | } |
|---|
| 1071 | |
|---|
| 1072 | // ---------------------------- |
|---|
| 1073 | // create main window |
|---|
| 1074 | |
|---|
| 1075 | static AW_window *popup_new_main_window(AW_root *awr, int clone, TREE_canvas **result_ntw) { |
|---|
| 1076 | /*! create ARB_NTREE main window |
|---|
| 1077 | * @param awr application root |
|---|
| 1078 | * @param clone == 0 -> first window (full functionality); >0 -> additional tree views (restricted functionality) |
|---|
| 1079 | * @param result_ntw is set to the created TREE_canvas (passed pointer may be NULp if result is not needed) |
|---|
| 1080 | */ |
|---|
| 1081 | GB_push_transaction(GLOBAL.gb_main); |
|---|
| 1082 | |
|---|
| 1083 | char window_title[256]; |
|---|
| 1084 | const char *awar_tree = NULp; |
|---|
| 1085 | |
|---|
| 1086 | if (clone) { |
|---|
| 1087 | awar_tree = ARB_keep_string(GBS_global_string_copy(AWAR_TREE "_%i", clone)); |
|---|
| 1088 | sprintf(window_title, "ARB_NT_%i", clone); |
|---|
| 1089 | } |
|---|
| 1090 | else { |
|---|
| 1091 | awar_tree = AWAR_TREE; |
|---|
| 1092 | sprintf(window_title, "ARB_NT"); |
|---|
| 1093 | } |
|---|
| 1094 | AW_window_menu_modes *awm = new AW_window_menu_modes; |
|---|
| 1095 | awm->init(awr, window_title, window_title, 0, 0); |
|---|
| 1096 | |
|---|
| 1097 | awr->awar(AWAR_DB_NAME) |
|---|
| 1098 | ->add_callback(makeRootCallback(update_main_window_title, awm, clone)) |
|---|
| 1099 | ->update(); |
|---|
| 1100 | |
|---|
| 1101 | awm->button_length(5); |
|---|
| 1102 | |
|---|
| 1103 | if (!clone) AW_init_color_group_defaults("arb_ntree"); |
|---|
| 1104 | |
|---|
| 1105 | AWT_graphic_tree *tree = NT_generate_tree(awr, GLOBAL.gb_main, launch_MapViewer_cb); |
|---|
| 1106 | |
|---|
| 1107 | if (!clone) { // while creating initial window |
|---|
| 1108 | AWT_graphic_tree::install_group_changed_callback(makeGraphicTreeCallback(group_selected_by_canvas_cb)); |
|---|
| 1109 | awr->awar(AWAR_GROUP)->add_callback(group_awar_changed_cb); |
|---|
| 1110 | } |
|---|
| 1111 | |
|---|
| 1112 | TREE_canvas *ntw; |
|---|
| 1113 | { |
|---|
| 1114 | AW_awar *tree_awar = awr->awar_string(awar_tree); |
|---|
| 1115 | { |
|---|
| 1116 | AP_tree_display_style prev_style = tree->get_tree_style(); |
|---|
| 1117 | tree->set_tree_style(AP_LIST_SIMPLE, NULp); // avoid NDS warnings during startup |
|---|
| 1118 | |
|---|
| 1119 | ntw = new TREE_canvas(GLOBAL.gb_main, awm, "ARB_NT", tree, tree_awar); |
|---|
| 1120 | tree->set_tree_style(prev_style, ntw); |
|---|
| 1121 | ntw->set_mode(AWT_MODE_SELECT); |
|---|
| 1122 | } |
|---|
| 1123 | |
|---|
| 1124 | if (result_ntw) *result_ntw = ntw; |
|---|
| 1125 | |
|---|
| 1126 | { |
|---|
| 1127 | const char *tree_name = tree_awar->read_char_pntr(); |
|---|
| 1128 | const char *existing_tree_name = GBT_existing_tree(GLOBAL.gb_main, tree_name); |
|---|
| 1129 | |
|---|
| 1130 | if (existing_tree_name) { |
|---|
| 1131 | tree_awar->write_string(existing_tree_name); |
|---|
| 1132 | NT_reload_tree_event(awr, ntw, true); // load first tree |
|---|
| 1133 | } |
|---|
| 1134 | else { |
|---|
| 1135 | AW_advice("Your database contains no tree.", AW_ADVICE_TOGGLE_AND_HELP, NULp, "no_tree.hlp"); |
|---|
| 1136 | tree->set_tree_style(AP_LIST_NDS, ntw); // no tree -> show NDS list |
|---|
| 1137 | } |
|---|
| 1138 | |
|---|
| 1139 | TREE_canvas_registry::instance().register_canvas(ntw); |
|---|
| 1140 | AWT_registerTreeAwarCallback(tree_awar, makeTreeAwarCallback(canvas_tree_awar_changed_cb, ntw), false); |
|---|
| 1141 | } |
|---|
| 1142 | } |
|---|
| 1143 | |
|---|
| 1144 | TREE_install_update_callbacks(ntw); |
|---|
| 1145 | |
|---|
| 1146 | bool is_genome_db = GEN_is_genome_db(GLOBAL.gb_main, 0); // is this a genome database ? (default = 0 = not a genom db) |
|---|
| 1147 | |
|---|
| 1148 | WindowCallback popupinfo_wcb = RootAsWindowCallback::simple(DBUI::popup_species_info_window, GLOBAL.gb_main); |
|---|
| 1149 | |
|---|
| 1150 | // -------------- |
|---|
| 1151 | // File |
|---|
| 1152 | |
|---|
| 1153 | #if defined(DEBUG) |
|---|
| 1154 | AWT_create_debug_menu(awm); |
|---|
| 1155 | #endif // DEBUG |
|---|
| 1156 | |
|---|
| 1157 | bool allow_new_window = (ntw->get_index()+1) < MAX_NT_WINDOWS; |
|---|
| 1158 | |
|---|
| 1159 | if (clone) { |
|---|
| 1160 | awm->create_menu("File", "F", AWM_ALL); |
|---|
| 1161 | if (allow_new_window) { |
|---|
| 1162 | awm->insert_menu_topic(awm->local_id("new_window"), "New window (same database)", "N", "newwindow.hlp", AWM_ALL, makeCreateWindowCallback(popup_new_main_window, clone+1, (TREE_canvas**)NULp)); |
|---|
| 1163 | } |
|---|
| 1164 | awm->insert_menu_topic("close", "Close", "C", NULp, AWM_ALL, AW_POPDOWN); |
|---|
| 1165 | } |
|---|
| 1166 | else { |
|---|
| 1167 | #if defined(DEBUG) |
|---|
| 1168 | // add more to debug-menu |
|---|
| 1169 | awm->sep______________(); |
|---|
| 1170 | awm->insert_menu_topic("fix_db", "Fix database", "F", NULp, AWM_ALL, NT_fix_database); |
|---|
| 1171 | awm->insert_menu_topic("debug_arbdb", "Print debug information", "d", NULp, AWM_ALL, makeWindowCallback(GB_print_debug_information, GLOBAL.gb_main)); |
|---|
| 1172 | awm->insert_menu_topic("test_compr", "Test compression", "T", NULp, AWM_ALL, makeWindowCallback(GBT_compression_test, GLOBAL.gb_main)); |
|---|
| 1173 | #endif // DEBUG |
|---|
| 1174 | |
|---|
| 1175 | awm->create_menu("File", "F", AWM_ALL); |
|---|
| 1176 | { |
|---|
| 1177 | // keep the following entries in sync with ../EDIT4/ED4_root.cxx@common_save_menu_entries |
|---|
| 1178 | awm->insert_menu_topic("save_changes", "Quicksave changes", "s", "save.hlp", AWM_ALL, NT_save_quick_cb); |
|---|
| 1179 | awm->insert_menu_topic("save_all_as", "Save whole database as ...", "w", "save.hlp", AWM_ALL, makeCreateWindowCallback(NT_create_save_as, AWAR_DBBASE)); |
|---|
| 1180 | if (allow_new_window) { |
|---|
| 1181 | awm->sep______________(); |
|---|
| 1182 | awm->insert_menu_topic("new_window", "New window (same database)", "N", "newwindow.hlp", AWM_ALL, makeCreateWindowCallback(popup_new_main_window, clone+1, (TREE_canvas**)NULp)); |
|---|
| 1183 | } |
|---|
| 1184 | awm->sep______________(); |
|---|
| 1185 | awm->insert_menu_topic("optimize_db", "Optimize database compression", "O", "optimize.hlp", AWM_ALL, NT_create_database_optimization_window); |
|---|
| 1186 | awm->sep______________(); |
|---|
| 1187 | |
|---|
| 1188 | awm->insert_sub_menu("Import", "I"); |
|---|
| 1189 | { |
|---|
| 1190 | awm->insert_menu_topic("merge_from", "Merge from other ARB database", "d", "arb_merge_into.hlp", AWM_ALL, NT_create_merge_from_window); |
|---|
| 1191 | awm->insert_menu_topic("import_seq", "Import from external format", "I", "arb_import.hlp", AWM_ALL, makeWindowCallback(NT_import_sequences, ntw)); |
|---|
| 1192 | GDE_load_menu(awm, AWM_EXP, "Import"); |
|---|
| 1193 | } |
|---|
| 1194 | awm->close_sub_menu(); |
|---|
| 1195 | |
|---|
| 1196 | awm->insert_sub_menu("Export", "E"); |
|---|
| 1197 | { |
|---|
| 1198 | awm->insert_menu_topic("export_to_ARB", "Merge to (new) ARB database", "A", "arb_merge_outof.hlp", AWM_ALL, NT_create_merge_to_window); |
|---|
| 1199 | awm->insert_menu_topic("export_seqs", "Export to external format", "f", "arb_export.hlp", AWM_ALL, makeCreateWindowCallback(create_AWTC_export_window, GLOBAL.gb_main)); |
|---|
| 1200 | GDE_load_menu(awm, AWM_ALL, "Export"); |
|---|
| 1201 | awm->insert_menu_topic("export_nds", "Export fields (to calc-sheet using NDS)", "N", "arb_export_nds.hlp", AWM_ALL, create_nds_export_window); |
|---|
| 1202 | } |
|---|
| 1203 | awm->close_sub_menu(); |
|---|
| 1204 | awm->sep______________(); |
|---|
| 1205 | |
|---|
| 1206 | insert_macro_menu_entry(awm, false); |
|---|
| 1207 | |
|---|
| 1208 | awm->insert_sub_menu("VersionInfo/Bugreport/MailingList", "V"); |
|---|
| 1209 | { |
|---|
| 1210 | awm->insert_menu_topic("version_info", "Version info (" ARB_VERSION_DETAILED ")", "V", "version.hlp", AWM_ALL, makeHelpCallback ("version.hlp")); |
|---|
| 1211 | awm->insert_menu_topic("bug_report", "Report bug", "b", NULp, AWM_ALL, makeWindowCallback(AWT_openURL, "http://bugs.arb-home.de/wiki/BugReport")); |
|---|
| 1212 | awm->insert_menu_topic("mailing_list", "Mailing list", "M", NULp, AWM_ALL, makeWindowCallback(AWT_openURL, "http://bugs.arb-home.de/wiki/ArbMailingList")); |
|---|
| 1213 | } |
|---|
| 1214 | awm->close_sub_menu(); |
|---|
| 1215 | awm->sep______________(); |
|---|
| 1216 | |
|---|
| 1217 | awm->insert_menu_topic("new_arb", "Start second database", "d", "quit.hlp", AWM_ALL, makeWindowCallback(nt_start_2nd_arb, false)); |
|---|
| 1218 | awm->insert_menu_topic("restart_arb", "Quit + load other database", "l", "quit.hlp", AWM_ALL, makeWindowCallback(nt_start_2nd_arb, true)); |
|---|
| 1219 | awm->insert_menu_topic("quit", "Quit", "Q", "quit.hlp", AWM_ALL, makeWindowCallback(NT_exit, EXIT_SUCCESS)); |
|---|
| 1220 | } |
|---|
| 1221 | |
|---|
| 1222 | // ----------------- |
|---|
| 1223 | // Species |
|---|
| 1224 | |
|---|
| 1225 | awm->create_menu("Species", "c", AWM_ALL); |
|---|
| 1226 | { |
|---|
| 1227 | awm->insert_menu_topic("species_search", "Search and query", "q", "sp_search.hlp", AWM_ALL, makeCreateWindowCallback(DBUI::create_species_query_window, GLOBAL.gb_main)); |
|---|
| 1228 | awm->insert_menu_topic("species_info", "Species information", "i", "sp_info.hlp", AWM_ALL, popupinfo_wcb); |
|---|
| 1229 | |
|---|
| 1230 | awm->sep______________(); |
|---|
| 1231 | |
|---|
| 1232 | NT_insert_mark_submenus(awm, ntw, 1); |
|---|
| 1233 | awm->insert_menu_topic("mark_by_ref", "Mark by reference..", "r", "markbyref.hlp", AWM_EXP, makeCreateWindowCallback(create_mark_by_refentries_window, GLOBAL.gb_main)); |
|---|
| 1234 | awm->insert_menu_topic("species_colors", "Colors ...", "l", "colorize.hlp", AWM_ALL, create_colorize_species_window); |
|---|
| 1235 | awm->insert_menu_topic("selection_admin", "Selections ...", "o", "species_configs.hlp", AWM_ALL, makeWindowCallback(NT_popup_configuration_admin, ntw)); |
|---|
| 1236 | |
|---|
| 1237 | awm->sep______________(); |
|---|
| 1238 | |
|---|
| 1239 | awm->insert_sub_menu("Database fields admin", "f"); |
|---|
| 1240 | DBUI::insert_field_admin_menuitems(awm, GLOBAL.gb_main); |
|---|
| 1241 | awm->close_sub_menu(); |
|---|
| 1242 | NT_create_mask_submenu(awm); |
|---|
| 1243 | |
|---|
| 1244 | awm->sep______________(); |
|---|
| 1245 | |
|---|
| 1246 | awm->insert_menu_topic("del_marked", "Delete Marked Species", "D", "sp_del_mrkd.hlp", AWM_ALL, makeWindowCallback(NT_delete_mark_all_cb, ntw)); |
|---|
| 1247 | |
|---|
| 1248 | awm->insert_sub_menu("Sort Species", "s"); |
|---|
| 1249 | { |
|---|
| 1250 | awm->insert_menu_topic("$sort_by_field", "According to Database Entries", "D", "sp_sort_fld.hlp", AWM_ALL, NT_create_resort_window); |
|---|
| 1251 | awm->insert_menu_topic("$sort_by_tree", "According to Phylogeny", "P", "sp_sort_phyl.hlp", AWM_ALL, makeWindowCallback(NT_resort_data_by_phylogeny, ntw)); |
|---|
| 1252 | } |
|---|
| 1253 | awm->close_sub_menu(); |
|---|
| 1254 | |
|---|
| 1255 | awm->insert_sub_menu("Merge Species", "g", AWM_EXP); |
|---|
| 1256 | { |
|---|
| 1257 | awm->insert_menu_topic("merge_species", "Create merged species from similar species", "m", "merge_species.hlp", AWM_EXP, NT_createMergeSimilarSpeciesWindow); |
|---|
| 1258 | awm->insert_menu_topic("join_marked", "Join Marked Species", "J", "species_join.hlp", AWM_EXP, NT_create_species_join_window); |
|---|
| 1259 | } |
|---|
| 1260 | awm->close_sub_menu(); |
|---|
| 1261 | |
|---|
| 1262 | awm->sep______________(); |
|---|
| 1263 | |
|---|
| 1264 | awm->insert_menu_topic("species_submission", "Submit Species", "b", "submission.hlp", AWM_EXP, makeCreateWindowCallback(AWTC_create_submission_window, GLOBAL.gb_main)); |
|---|
| 1265 | |
|---|
| 1266 | awm->sep______________(); |
|---|
| 1267 | |
|---|
| 1268 | awm->insert_menu_topic("new_names", "Synchronize IDs", "e", "rename.hlp", AWM_ALL, makeCreateWindowCallback(AWTC_create_rename_window, GLOBAL.gb_main)); |
|---|
| 1269 | |
|---|
| 1270 | awm->insert_sub_menu("Valid Names ...", "V", AWM_EXP); |
|---|
| 1271 | { |
|---|
| 1272 | awm->insert_menu_topic("imp_names", "Import names from file", "I", "vn_import.hlp", AWM_EXP, NT_importValidNames); |
|---|
| 1273 | awm->insert_menu_topic("del_names", "Delete names from DB", "D", "vn_delete.hlp", AWM_EXP, NT_deleteValidNames); |
|---|
| 1274 | awm->insert_menu_topic("sug_names", "Suggest valid names", "v", "vn_suggest.hlp", AWM_EXP, NT_suggestValidNames); |
|---|
| 1275 | awm->insert_menu_topic("search_names", "Search manually", "m", "vn_search.hlp", AWM_EXP, NT_create_searchManuallyNames_window); |
|---|
| 1276 | } |
|---|
| 1277 | awm->close_sub_menu(); |
|---|
| 1278 | } |
|---|
| 1279 | |
|---|
| 1280 | // ---------------------------- |
|---|
| 1281 | // Genes + Experiment |
|---|
| 1282 | |
|---|
| 1283 | if (is_genome_db) GEN_create_genes_submenu(awm, GLOBAL.gb_main, true); |
|---|
| 1284 | |
|---|
| 1285 | // ------------------ |
|---|
| 1286 | // Sequence |
|---|
| 1287 | |
|---|
| 1288 | awm->create_menu("Sequence", "S", AWM_ALL); |
|---|
| 1289 | { |
|---|
| 1290 | awm->insert_menu_topic("seq_admin", "Sequence/Alignment Admin", "A", "ad_align.hlp", AWM_ALL, makeCreateWindowCallback(NT_create_alignment_admin_window, (AW_window*)NULp)); |
|---|
| 1291 | awm->insert_sub_menu("Insert/delete", "I"); |
|---|
| 1292 | { |
|---|
| 1293 | awm->insert_menu_topic("ins_del_col", ".. column", "c", "insdel.hlp", AWM_ALL, create_insertDeleteColumn_window); |
|---|
| 1294 | awm->insert_menu_topic("ins_del_sai", ".. using SAI", "S", "insdel_sai.hlp", AWM_ALL, makeCreateWindowCallback(create_insertDeleteBySAI_window, GLOBAL.gb_main)); |
|---|
| 1295 | } |
|---|
| 1296 | awm->close_sub_menu(); |
|---|
| 1297 | awm->sep______________(); |
|---|
| 1298 | |
|---|
| 1299 | awm->insert_sub_menu("Edit Sequences", "E"); |
|---|
| 1300 | { |
|---|
| 1301 | awm->insert_menu_topic("new_arb_edit4", "Using marked species and tree", "m", "arb_edit4.hlp", AWM_ALL, makeWindowCallback(NT_start_editor_on_tree, 0, ntw)); |
|---|
| 1302 | awm->insert_menu_topic("new2_arb_edit4", "... plus relatives", "r", "arb_edit4.hlp", AWM_ALL, makeWindowCallback(NT_start_editor_on_tree, -1, ntw)); |
|---|
| 1303 | awm->insert_menu_topic("old_arb_edit4", "Using earlier configuration", "c", "arb_edit4.hlp", AWM_ALL, NT_create_startEditorOnOldConfiguration_window); |
|---|
| 1304 | } |
|---|
| 1305 | awm->close_sub_menu(); |
|---|
| 1306 | |
|---|
| 1307 | awm->sep______________(); |
|---|
| 1308 | |
|---|
| 1309 | awm->insert_sub_menu("Align Sequences", "S"); |
|---|
| 1310 | { |
|---|
| 1311 | awm->insert_menu_topic("realign_dna", "Realign DNA according to aligned protein", "R", "realign_dna.hlp", AWM_ALL, NT_create_realign_dna_window); |
|---|
| 1312 | GDE_load_menu(awm, AWM_ALL, "Align"); |
|---|
| 1313 | } |
|---|
| 1314 | awm->close_sub_menu(); |
|---|
| 1315 | awm->insert_menu_topic("seq_concat", "Concatenate Sequences/Alignments", "C", "concatenate.hlp", AWM_ALL, NT_createConcatenationWindow); |
|---|
| 1316 | awm->insert_menu_topic("track_changes", "Track alignment changes", "k", "track_ali_changes.hlp", AWM_EXP, NT_create_trackAliChanges_window); |
|---|
| 1317 | awm->sep______________(); |
|---|
| 1318 | |
|---|
| 1319 | awm->insert_menu_topic("dna_2_pro", "Perform translation", "t", "translate_dna_2_pro.hlp", AWM_ALL, NT_create_dna_2_pro_window); |
|---|
| 1320 | awm->insert_menu_topic("arb_dist", "Distance Matrix + ARB NJ", "D", "dist.hlp", AWM_ALL, makeWindowCallback(AWT_system_cb, "arb_dist &")); |
|---|
| 1321 | awm->sep______________(); |
|---|
| 1322 | |
|---|
| 1323 | awm->insert_menu_topic("seq_quality", "Check Sequence Quality", "Q", "seq_quality.hlp", AWM_EXP, makeCreateWindowCallback(SQ_create_seq_quality_window, GLOBAL.gb_main)); |
|---|
| 1324 | awm->insert_menu_topic("chimera_check", "Chimera Check", "m", "chimera_check.hlp", AWM_EXP, makeCreateWindowCallback(STAT_create_chimera_check_window, GLOBAL.gb_main)); |
|---|
| 1325 | |
|---|
| 1326 | awm->sep______________(); |
|---|
| 1327 | |
|---|
| 1328 | GDE_load_menu(awm, AWM_ALL, "Print"); |
|---|
| 1329 | } |
|---|
| 1330 | |
|---|
| 1331 | // ------------- |
|---|
| 1332 | // SAI |
|---|
| 1333 | |
|---|
| 1334 | awm->create_menu("SAI", "A", AWM_ALL); |
|---|
| 1335 | { |
|---|
| 1336 | awm->insert_menu_topic("sai_admin", "Manage SAIs", "S", "ad_extended.hlp", AWM_ALL, NT_create_extendeds_window); |
|---|
| 1337 | awm->insert_sub_menu("Create SAI using ...", "C"); |
|---|
| 1338 | { |
|---|
| 1339 | awm->insert_menu_topic("sai_max_freq", "Max. Frequency", "M", "max_freq.hlp", AWM_EXP, AP_create_max_freq_window); |
|---|
| 1340 | awm->insert_menu_topic("sai_consensus", "Consensus", "C", "consensus.hlp", AWM_ALL, AP_create_con_expert_window); |
|---|
| 1341 | awm->insert_menu_topic("pos_var_pars", "Positional variability + Column statistic (parsimony method)", "a", "pos_var_pars.hlp", AWM_ALL, AP_create_pos_var_pars_window); |
|---|
| 1342 | awm->insert_menu_topic("arb_phyl", "Filter by base frequency", "F", "phylo.hlp", AWM_ALL, makeWindowCallback(AWT_system_cb, "arb_phylo &")); |
|---|
| 1343 | awm->insert_menu_topic("sai_pfold", "Protein secondary structure (field \"sec_struct\")", "P", "pfold.hlp", AWM_EXP, NT_create_sai_from_pfold); |
|---|
| 1344 | |
|---|
| 1345 | GDE_load_menu(awm, AWM_EXP, "SAI"); |
|---|
| 1346 | } |
|---|
| 1347 | awm->close_sub_menu(); |
|---|
| 1348 | |
|---|
| 1349 | awm->insert_sub_menu("Other functions", "O"); |
|---|
| 1350 | { |
|---|
| 1351 | awm->insert_menu_topic("count_different_chars", "Count different chars/column", "C", "count_chars.hlp", AWM_EXP, makeWindowCallback(NT_count_different_chars, GLOBAL.gb_main)); |
|---|
| 1352 | awm->insert_menu_topic("corr_mutat_analysis", "Compute clusters of correlated positions", "m", "", AWM_ALL, makeWindowCallback(AWT_system_in_console_cb, "arb_rnacma", XCMD_ASYNC_WAIT_ON_ERROR)); |
|---|
| 1353 | awm->insert_menu_topic("export_pos_var", "Export Column Statistic (GNUPLOT format)", "E", "csp_2_gnuplot.hlp", AWM_ALL, NT_create_colstat_2_gnuplot_window); |
|---|
| 1354 | } |
|---|
| 1355 | awm->close_sub_menu(); |
|---|
| 1356 | } |
|---|
| 1357 | |
|---|
| 1358 | // ---------------- |
|---|
| 1359 | // Probes |
|---|
| 1360 | |
|---|
| 1361 | awm->create_menu("Probes", "P", AWM_ALL); |
|---|
| 1362 | { |
|---|
| 1363 | awm->insert_menu_topic("probe_design", "Design Probes", "D", "probedesign.hlp", AWM_ALL, makeCreateWindowCallback(create_probe_design_window, GLOBAL.gb_main)); |
|---|
| 1364 | awm->insert_menu_topic("probe_multi", "Calculate Multi-Probes", "u", "multiprobe.hlp", AWM_ALL, makeCreateWindowCallback(create_multiprobe_window, ntw)); |
|---|
| 1365 | awm->insert_menu_topic("probe_match", "Match Probes", "M", "probematch.hlp", AWM_ALL, makeCreateWindowCallback(create_probe_match_window, GLOBAL.gb_main)); |
|---|
| 1366 | awm->sep______________(); |
|---|
| 1367 | awm->insert_menu_topic("probe_match_sp", "Match Probes with Specificity", "f", "probespec.hlp", AWM_ALL, makeCreateWindowCallback(create_probe_match_with_specificity_window, ntw)); |
|---|
| 1368 | awm->sep______________(); |
|---|
| 1369 | awm->insert_menu_topic("primer_design_new", "Design Primers", "P", "primer_new.hlp", AWM_EXP, makeCreateWindowCallback(create_primer_design_window, GLOBAL.gb_main)); |
|---|
| 1370 | awm->insert_menu_topic("primer_design", "Design Sequencing Primers", "S", "primer.hlp", AWM_EXP, makeWindowCallback(AWT_system_in_console_cb, "arb_primer", XCMD_ASYNC_WAITKEY)); |
|---|
| 1371 | awm->sep______________(); |
|---|
| 1372 | awm->insert_menu_topic("pt_server_admin", "PT_SERVER Admin", "A", "probeadmin.hlp", AWM_ALL, makeCreateWindowCallback(create_probe_admin_window, GLOBAL.gb_main)); |
|---|
| 1373 | } |
|---|
| 1374 | |
|---|
| 1375 | } |
|---|
| 1376 | |
|---|
| 1377 | // -------------- |
|---|
| 1378 | // Tree |
|---|
| 1379 | |
|---|
| 1380 | awm->create_menu("Tree", "T", AWM_ALL); |
|---|
| 1381 | { |
|---|
| 1382 | if (!clone) { |
|---|
| 1383 | awm->insert_sub_menu("Add Species to Existing Tree", "A"); |
|---|
| 1384 | { |
|---|
| 1385 | awm->insert_menu_topic("arb_pars_quick", "ARB Parsimony (Quick add marked)", "Q", "pars.hlp", AWM_ALL, makeWindowCallback(AWT_system_cb, "arb_pars -add_marked -quit &")); |
|---|
| 1386 | awm->insert_menu_topic("arb_pars", "ARB Parsimony interactive", "i", "pars.hlp", AWM_ALL, makeWindowCallback(AWT_system_cb, "arb_pars &")); |
|---|
| 1387 | GDE_load_menu(awm, AWM_EXP, "Incremental phylogeny"); |
|---|
| 1388 | } |
|---|
| 1389 | awm->close_sub_menu(); |
|---|
| 1390 | } |
|---|
| 1391 | |
|---|
| 1392 | awm->insert_sub_menu("Remove Species from Tree", "R"); |
|---|
| 1393 | { |
|---|
| 1394 | awm->insert_menu_topic(awm->local_id("tree_remove_deleted"), "Remove zombies", "z", "trm_del.hlp", AWM_ALL, makeWindowCallback(NT_remove_leafs, ntw, AWT_REMOVE_ZOMBIES)); |
|---|
| 1395 | awm->insert_menu_topic(awm->local_id("tree_remove_marked"), "Remove marked", "m", "trm_mrkd.hlp", AWM_ALL, makeWindowCallback(NT_remove_leafs, ntw, AWT_REMOVE_MARKED)); |
|---|
| 1396 | awm->insert_menu_topic(awm->local_id("tree_keep_marked"), "Keep marked", "K", "tkeep_mrkd.hlp", AWM_ALL, makeWindowCallback(NT_remove_leafs, ntw, AWT_KEEP_MARKED)); |
|---|
| 1397 | awm->sep______________(); |
|---|
| 1398 | awm->insert_menu_topic("all_tree_remove_deleted", "Remove zombies from ALL trees", "A", "trm_del.hlp", AWM_ALL, makeWindowCallback(NT_alltree_remove_leafs, GBT_REMOVE_ZOMBIES, GLOBAL.gb_main)); |
|---|
| 1399 | awm->insert_menu_topic("all_tree_remove_marked", "Remove marked from ALL trees", "L", "trm_mrkd.hlp", AWM_ALL, makeWindowCallback(NT_alltree_remove_leafs, GBT_REMOVE_MARKED, GLOBAL.gb_main)); |
|---|
| 1400 | } |
|---|
| 1401 | awm->close_sub_menu(); |
|---|
| 1402 | |
|---|
| 1403 | if (!clone) { |
|---|
| 1404 | awm->insert_sub_menu("Build tree from sequence data", "B"); |
|---|
| 1405 | { |
|---|
| 1406 | awm->insert_sub_menu("Distance matrix methods", "D"); |
|---|
| 1407 | awm->insert_menu_topic("arb_dist", "Distance Matrix + ARB NJ", "J", "dist.hlp", AWM_ALL, makeWindowCallback(AWT_system_cb, "arb_dist &")); |
|---|
| 1408 | GDE_load_menu(awm, AWM_ALL, "Phylogeny Distance Matrix"); |
|---|
| 1409 | awm->close_sub_menu(); |
|---|
| 1410 | |
|---|
| 1411 | awm->insert_sub_menu("Maximum Parsimony methods", "P"); |
|---|
| 1412 | GDE_load_menu(awm, AWM_ALL, "Phylogeny max. parsimony"); |
|---|
| 1413 | awm->close_sub_menu(); |
|---|
| 1414 | |
|---|
| 1415 | awm->insert_sub_menu("Maximum Likelihood methods", "L"); |
|---|
| 1416 | GDE_load_menu(awm, AWM_EXP, "Phylogeny max. Likelihood EXP"); |
|---|
| 1417 | GDE_load_menu(awm, AWM_ALL, "Phylogeny max. Likelihood"); |
|---|
| 1418 | awm->close_sub_menu(); |
|---|
| 1419 | |
|---|
| 1420 | awm->insert_sub_menu("Other methods", "O", AWM_EXP); |
|---|
| 1421 | GDE_load_menu(awm, AWM_EXP, "Phylogeny (Other)"); |
|---|
| 1422 | awm->close_sub_menu(); |
|---|
| 1423 | } |
|---|
| 1424 | awm->close_sub_menu(); |
|---|
| 1425 | } |
|---|
| 1426 | |
|---|
| 1427 | awm->insert_menu_topic(awm->local_id("consense_tree"), "Build consensus tree", "c", "consense_tree.hlp", AWM_ALL, NT_create_consense_window); |
|---|
| 1428 | |
|---|
| 1429 | awm->sep______________(); |
|---|
| 1430 | |
|---|
| 1431 | awm->insert_sub_menu("Reset zoom", "z"); |
|---|
| 1432 | { |
|---|
| 1433 | awm->insert_menu_topic(awm->local_id("reset_logical_zoom"), "Logical zoom", "L", "rst_log_zoom.hlp", AWM_ALL, makeWindowCallback(NT_reset_lzoom_cb, ntw)); |
|---|
| 1434 | awm->insert_menu_topic(awm->local_id("reset_physical_zoom"), "Physical zoom", "P", "rst_phys_zoom.hlp", AWM_ALL, makeWindowCallback(NT_reset_pzoom_cb, ntw)); |
|---|
| 1435 | } |
|---|
| 1436 | awm->close_sub_menu(); |
|---|
| 1437 | |
|---|
| 1438 | awm->sep______________(); |
|---|
| 1439 | |
|---|
| 1440 | // taxonomic groups |
|---|
| 1441 | NT_insert_collapse_submenu(awm, ntw); |
|---|
| 1442 | if (!clone) { |
|---|
| 1443 | awm->insert_menu_topic("group_search", "Search groups...", "g", "group_search.hlp", AWM_ALL, makeWindowCallback (popup_group_search_window, GLOBAL.gb_main)); |
|---|
| 1444 | awm->insert_menu_topic("compare_taxonomy", "Compare taxonomy...", "x", "compare_taxonomy.hlp", AWM_ALL, makeCreateWindowCallback(NT_create_compare_taxonomy_window, ntw)); |
|---|
| 1445 | awm->insert_menu_topic("move_groups", "Move groups...", "n", "move_groups.hlp", AWM_ALL, makeCreateWindowCallback(NT_create_moveGroupInfo_window)); |
|---|
| 1446 | } |
|---|
| 1447 | |
|---|
| 1448 | awm->sep______________(); |
|---|
| 1449 | |
|---|
| 1450 | if (!clone) { |
|---|
| 1451 | awm->insert_menu_topic("compare_topology", "Compare topology...", "p", "compare_topo.hlp", AWM_ALL, makeCreateWindowCallback(NT_create_compareTopologies_window)); |
|---|
| 1452 | } |
|---|
| 1453 | |
|---|
| 1454 | awm->insert_sub_menu("Modify branches", "M"); |
|---|
| 1455 | { |
|---|
| 1456 | awm->insert_menu_topic(awm->local_id("tree_remove_remark"), "Remove bootstraps", "b", "trm_boot.hlp", AWM_ALL, makeWindowCallback(NT_remove_bootstrap, ntw)); |
|---|
| 1457 | awm->sep______________(); |
|---|
| 1458 | awm->insert_menu_topic(awm->local_id("tree_reset_lengths"), "Reset branchlengths", "R", "tbl_reset.hlp", AWM_ALL, makeWindowCallback(NT_reset_branchlengths, ntw)); |
|---|
| 1459 | awm->insert_menu_topic(awm->local_id("justify_branch_lengths"), "Justify branchlengths", "J", "tbl_justify.hlp", AWM_ALL, makeWindowCallback(NT_justify_branch_lenghs, ntw)); |
|---|
| 1460 | awm->insert_menu_topic(awm->local_id("tree_scale_lengths"), "Scale Branchlengths", "S", "tbl_scale.hlp", AWM_ALL, makeWindowCallback(NT_scale_tree, ntw)); |
|---|
| 1461 | awm->sep______________(); |
|---|
| 1462 | awm->insert_menu_topic(awm->local_id("tree_multifurcate"), "Multifurcate...", "M", "multifurcate.hlp", AWM_ALL, makeCreateWindowCallback(NT_create_multifurcate_tree_window, ntw)); |
|---|
| 1463 | awm->sep______________(); |
|---|
| 1464 | awm->insert_menu_topic(awm->local_id("tree_boot2len"), "Bootstraps -> Branchlengths", "l", "tbl_boot2len.hlp", AWM_ALL, makeWindowCallback(NT_move_boot_branch, ntw, 0)); |
|---|
| 1465 | awm->insert_menu_topic(awm->local_id("tree_len2boot"), "Bootstraps <- Branchlengths", "o", "tbl_boot2len.hlp", AWM_ALL, makeWindowCallback(NT_move_boot_branch, ntw, 1)); |
|---|
| 1466 | |
|---|
| 1467 | } |
|---|
| 1468 | awm->close_sub_menu(); |
|---|
| 1469 | awm->insert_sub_menu("Beautify tree", "e"); |
|---|
| 1470 | { |
|---|
| 1471 | awm->insert_menu_topic(awm->local_id("beautifyt_tree"), "#beautifyt.xpm", "", "resorttree.hlp", AWM_ALL, makeWindowCallback(NT_resort_tree_cb, ntw, BIG_BRANCHES_TO_TOP)); |
|---|
| 1472 | awm->insert_menu_topic(awm->local_id("beautifyc_tree"), "#beautifyc.xpm", "", "resorttree.hlp", AWM_ALL, makeWindowCallback(NT_resort_tree_cb, ntw, BIG_BRANCHES_TO_EDGE)); |
|---|
| 1473 | awm->insert_menu_topic(awm->local_id("beautifyb_tree"), "#beautifyb.xpm", "", "resorttree.hlp", AWM_ALL, makeWindowCallback(NT_resort_tree_cb, ntw, BIG_BRANCHES_TO_BOTTOM)); |
|---|
| 1474 | awm->insert_menu_topic(awm->local_id("beautifyr_tree"), "Radial tree (1)", "1", "resorttree.hlp", AWM_ALL, makeWindowCallback(NT_resort_tree_cb, ntw, BIG_BRANCHES_TO_CENTER)); |
|---|
| 1475 | awm->insert_menu_topic(awm->local_id("beautifyr2_tree"), "Radial tree (2)", "2", "resorttree.hlp", AWM_ALL, makeWindowCallback(NT_resort_tree_cb, ntw, BIG_BRANCHES_ALTERNATING)); |
|---|
| 1476 | awm->sep______________(); |
|---|
| 1477 | awm->insert_menu_topic(awm->local_id("sort_by_other"), "By other tree", "o", "resortbyother.hlp", AWM_ALL, makeCreateWindowCallback(NT_create_sort_tree_by_other_tree_window, ntw)); |
|---|
| 1478 | } |
|---|
| 1479 | awm->close_sub_menu(); |
|---|
| 1480 | |
|---|
| 1481 | awm->insert_menu_topic(awm->local_id("branch_analysis"), "Branch analysis", "h", "branch_analysis.hlp", AWM_ALL, makeCreateWindowCallback(NT_create_branch_analysis_window, ntw)); |
|---|
| 1482 | awm->insert_menu_topic(awm->local_id("mark_duplicates"), "Mark duplicates", "u", "mark_duplicates.hlp", AWM_ALL, makeWindowCallback(NT_mark_duplicates, ntw)); |
|---|
| 1483 | |
|---|
| 1484 | awm->sep______________(); |
|---|
| 1485 | |
|---|
| 1486 | awm->insert_menu_topic(awm->local_id("shade"), "Tree shading...", "s", "tree_shading.hlp", AWM_ALL, makeWindowCallback (NT_configure_treeShader)); |
|---|
| 1487 | awm->insert_menu_topic(awm->local_id("syncscroll"), "Sync tree scrolling..", "o", "syncscroll.hlp", AWM_ALL, makeCreateWindowCallback(NT_create_syncScroll_window, ntw)); |
|---|
| 1488 | |
|---|
| 1489 | awm->sep______________(); |
|---|
| 1490 | |
|---|
| 1491 | awm->insert_menu_topic(awm->local_id("tree_select"), "Select Tree", "T", NULp, AWM_ALL, makeCreateWindowCallback(NT_create_select_tree_window, awar_tree)); |
|---|
| 1492 | awm->insert_menu_topic(awm->local_id("tree_select_latest"), "Select Last Tree", "L", NULp, AWM_ALL, makeWindowCallback(NT_select_bottom_tree, awar_tree)); |
|---|
| 1493 | |
|---|
| 1494 | if (!clone) { |
|---|
| 1495 | awm->sep______________(); |
|---|
| 1496 | awm->insert_menu_topic("tree_admin", "Tree admin", "i", "treeadm.hlp", AWM_ALL, popup_tree_admin_window); |
|---|
| 1497 | awm->insert_menu_topic("nds", "NDS (Node display setup)", "N", "props_nds.hlp", AWM_ALL, makeCreateWindowCallback(AWT_create_nds_window, GLOBAL.gb_main)); |
|---|
| 1498 | } |
|---|
| 1499 | |
|---|
| 1500 | awm->sep______________(); |
|---|
| 1501 | awm->insert_menu_topic("transversion", "Transversion analysis", "y", "trans_anal.hlp", AWM_EXP, makeHelpCallback("trans_anal.hlp")); |
|---|
| 1502 | |
|---|
| 1503 | if (!clone) { |
|---|
| 1504 | awm->sep______________(); |
|---|
| 1505 | awm->insert_menu_topic("print_tree", "Print tree", "P", "tree2prt.hlp", AWM_ALL, makeWindowCallback(AWT_popup_print_window, static_cast<AWT_canvas*>(ntw))); |
|---|
| 1506 | awm->insert_menu_topic("tree_2_xfig", "Export tree to XFIG", "F", "tree2file.hlp", AWM_ALL, makeWindowCallback(AWT_popup_tree_export_window, static_cast<AWT_canvas*>(ntw))); |
|---|
| 1507 | } |
|---|
| 1508 | |
|---|
| 1509 | if (is_genome_db) { |
|---|
| 1510 | awm->sep______________(); |
|---|
| 1511 | awm->insert_sub_menu("Other..", "O", AWM_EXP); |
|---|
| 1512 | { |
|---|
| 1513 | awm->insert_menu_topic(awm->local_id("tree_pseudo_species_to_organism"), "Relink tree to organisms", "o", "tree_pseudo.hlp", AWM_EXP, makeWindowCallback(NT_pseudo_species_to_organism, ntw)); |
|---|
| 1514 | } |
|---|
| 1515 | awm->close_sub_menu(); |
|---|
| 1516 | } |
|---|
| 1517 | } |
|---|
| 1518 | |
|---|
| 1519 | if (!clone) { |
|---|
| 1520 | // --------------- |
|---|
| 1521 | // Tools |
|---|
| 1522 | |
|---|
| 1523 | awm->create_menu("Tools", "o", AWM_ALL); |
|---|
| 1524 | { |
|---|
| 1525 | awm->insert_menu_topic("names_admin", "Name server admin (IDs)", "s", "namesadmin.hlp", AWM_ALL, makeCreateWindowCallback(AW_create_namesadmin_window, GLOBAL.gb_main)); |
|---|
| 1526 | awm->insert_sub_menu("DB admin", "D", AWM_EXP); |
|---|
| 1527 | { |
|---|
| 1528 | awm->insert_menu_topic("db_admin", "Re-repair DB", "R", "rerepair.hlp", AWM_EXP, makeWindowCallback(NT_rerepair_DB, GLOBAL.gb_main)); |
|---|
| 1529 | } |
|---|
| 1530 | awm->close_sub_menu(); |
|---|
| 1531 | awm->insert_sub_menu("Network", "N", AWM_EXP); |
|---|
| 1532 | { |
|---|
| 1533 | GDE_load_menu(awm, AWM_EXP, "Network"); |
|---|
| 1534 | } |
|---|
| 1535 | awm->close_sub_menu(); |
|---|
| 1536 | awm->sep______________(); |
|---|
| 1537 | |
|---|
| 1538 | awm->insert_sub_menu("GDE specials", "G", AWM_EXP); |
|---|
| 1539 | { |
|---|
| 1540 | GDE_load_menu(awm, AWM_EXP, NULp); |
|---|
| 1541 | } |
|---|
| 1542 | awm->close_sub_menu(); |
|---|
| 1543 | |
|---|
| 1544 | awm->sep______________(); |
|---|
| 1545 | awm->insert_menu_topic("xterm", "Start XTERM", "X", "xterm.hlp", AWM_ALL, AWT_console); |
|---|
| 1546 | awm->insert_menu_topic("viewlog", "View ARB log", "l", "console.hlp", AWM_ALL, makeWindowCallback(AWT_system_in_console_cb, "arb_show_log.pl run", XCMD_ASYNC_WAIT_ON_ERROR)); // ../SH/arb_show_log.pl |
|---|
| 1547 | awm->insert_menu_topic("viewserv", "View server log", "V", "console.hlp", AWM_ALL, makeWindowCallback(AWT_system_in_console_cb, "arb_show_log.pl server", XCMD_ASYNC_WAIT_ON_ERROR)); |
|---|
| 1548 | awm->sep______________(); |
|---|
| 1549 | GDE_load_menu(awm, AWM_EXP, "User"); |
|---|
| 1550 | } |
|---|
| 1551 | // -------------------- |
|---|
| 1552 | // Properties |
|---|
| 1553 | |
|---|
| 1554 | awm->create_menu("Properties", "r", AWM_ALL); |
|---|
| 1555 | { |
|---|
| 1556 | awm->insert_menu_topic("props_menu", "Frame settings ...", "F", "props_frame.hlp", AWM_ALL, AW_preset_window); |
|---|
| 1557 | awm->insert_menu_topic(awm->local_id("props_tree2"), "Tree options", "o", "nt_tree_settings.hlp", AWM_ALL, TREE_create_settings_window); |
|---|
| 1558 | awm->insert_menu_topic("props_tree", "Tree colors & fonts", "c", "color_props.hlp", AWM_ALL, makeCreateWindowCallback(AW_create_gc_window, ntw->gc_manager)); |
|---|
| 1559 | awm->insert_menu_topic("props_www", "Search world wide web (WWW)", "b", "props_www.hlp", AWM_ALL, makeCreateWindowCallback(AWT_create_www_window, GLOBAL.gb_main)); |
|---|
| 1560 | awm->sep______________(); |
|---|
| 1561 | awm->insert_menu_topic("!toggle_expert", "Toggle expert mode", "x", NULp, AWM_ALL, NT_toggle_expert_mode); |
|---|
| 1562 | awm->insert_menu_topic("!toggle_focus", "Toggle focus follows mouse", "m", NULp, AWM_ALL, NT_toggle_focus_policy); |
|---|
| 1563 | awm->sep______________(); |
|---|
| 1564 | AW_insert_common_property_menu_entries(awm); |
|---|
| 1565 | awm->sep______________(); |
|---|
| 1566 | awm->insert_menu_topic("save_props", "Save properties (ntree.arb)", "S", "savedef.hlp", AWM_ALL, AW_save_properties); |
|---|
| 1567 | } |
|---|
| 1568 | } |
|---|
| 1569 | |
|---|
| 1570 | awm->insert_help_topic("ARB_NT help", "N", "arb_ntree.hlp", AWM_ALL, makeHelpCallback("arb_ntree.hlp")); |
|---|
| 1571 | |
|---|
| 1572 | // ---------------------- |
|---|
| 1573 | // mode buttons |
|---|
| 1574 | // |
|---|
| 1575 | // keep them synchronized as far as possible with those in ARB_PARSIMONY |
|---|
| 1576 | // see ../PARSIMONY/PARS_main.cxx@keepModesSynchronized |
|---|
| 1577 | |
|---|
| 1578 | awm->create_mode("mode_select.xpm", "mode_select.hlp", AWM_ALL, makeWindowCallback(nt_mode_event, ntw, AWT_MODE_SELECT)); |
|---|
| 1579 | awm->create_mode("mode_mark.xpm", "mode_mark.hlp", AWM_ALL, makeWindowCallback(nt_mode_event, ntw, AWT_MODE_MARK)); |
|---|
| 1580 | awm->create_mode("mode_group.xpm", "mode_group.hlp", AWM_ALL, makeWindowCallback(nt_mode_event, ntw, AWT_MODE_GROUP)); |
|---|
| 1581 | awm->create_mode("mode_zoom.xpm", "mode_pzoom.hlp", AWM_ALL, makeWindowCallback(nt_mode_event, ntw, AWT_MODE_ZOOM)); |
|---|
| 1582 | awm->create_mode("mode_lzoom.xpm", "mode_lzoom.hlp", AWM_ALL, makeWindowCallback(nt_mode_event, ntw, AWT_MODE_LZOOM)); |
|---|
| 1583 | |
|---|
| 1584 | awm->create_mode("mode_info.xpm", "mode_info.hlp", AWM_ALL, makeWindowCallback(NT_infomode_cb, ntw, AWT_MODE_INFO)); |
|---|
| 1585 | awm->create_mode("mode_www.xpm", "mode_www.hlp", AWM_ALL, makeWindowCallback(nt_mode_event, ntw, AWT_MODE_WWW)); |
|---|
| 1586 | |
|---|
| 1587 | // topology-modification-modes |
|---|
| 1588 | awm->create_mode("mode_setroot.xpm", "mode_setroot.hlp", AWM_ALL, makeWindowCallback(nt_mode_event, ntw, AWT_MODE_SETROOT)); |
|---|
| 1589 | awm->create_mode("mode_swap.xpm", "mode_swap.hlp", AWM_ALL, makeWindowCallback(nt_mode_event, ntw, AWT_MODE_SWAP)); |
|---|
| 1590 | awm->create_mode("mode_move.xpm", "mode_move.hlp", AWM_ALL, makeWindowCallback(nt_mode_event, ntw, AWT_MODE_MOVE)); |
|---|
| 1591 | awm->create_mode("mode_length.xpm", "mode_length.hlp", AWM_ALL, makeWindowCallback(nt_mode_event, ntw, AWT_MODE_LENGTH)); |
|---|
| 1592 | awm->create_mode("mode_multifurc.xpm", "mode_length.hlp", AWM_ALL, makeWindowCallback(nt_mode_event, ntw, AWT_MODE_MULTIFURC)); |
|---|
| 1593 | |
|---|
| 1594 | // layout-modes |
|---|
| 1595 | awm->create_mode("mode_line.xpm", "mode_width.hlp", AWM_ALL, makeWindowCallback(nt_mode_event, ntw, AWT_MODE_LINE)); |
|---|
| 1596 | awm->create_mode("mode_rotate.xpm", "mode_rotate.hlp", AWM_ALL, makeWindowCallback(nt_mode_event, ntw, AWT_MODE_ROTATE)); |
|---|
| 1597 | awm->create_mode("mode_spread.xpm", "mode_spread.hlp", AWM_ALL, makeWindowCallback(nt_mode_event, ntw, AWT_MODE_SPREAD)); |
|---|
| 1598 | |
|---|
| 1599 | awm->set_info_area_height(250); |
|---|
| 1600 | awm->at(5, 2); |
|---|
| 1601 | awm->auto_space(-2, -2); |
|---|
| 1602 | awm->shadow_width(1); |
|---|
| 1603 | |
|---|
| 1604 | // ------------------------- |
|---|
| 1605 | // create top area |
|---|
| 1606 | |
|---|
| 1607 | int first_liney; |
|---|
| 1608 | int leftx; |
|---|
| 1609 | awm->get_at_position(&leftx, &first_liney); |
|---|
| 1610 | |
|---|
| 1611 | // --------------------- |
|---|
| 1612 | // quit + help |
|---|
| 1613 | |
|---|
| 1614 | awm->button_length(0); |
|---|
| 1615 | |
|---|
| 1616 | if (clone) { |
|---|
| 1617 | awm->callback(AW_POPDOWN); |
|---|
| 1618 | awm->create_button("CLOSE", "#close.xpm"); |
|---|
| 1619 | } |
|---|
| 1620 | else { |
|---|
| 1621 | awm->callback(makeWindowCallback(NT_exit, EXIT_SUCCESS)); |
|---|
| 1622 | awm->help_text("quit.hlp"); |
|---|
| 1623 | awm->create_button("QUIT", "#quit.xpm"); |
|---|
| 1624 | } |
|---|
| 1625 | |
|---|
| 1626 | int db_pathx = awm->get_at_xposition(); |
|---|
| 1627 | |
|---|
| 1628 | // now fetch the yposition for the 2nd button line |
|---|
| 1629 | awm->at_newline(); |
|---|
| 1630 | int second_liney = awm->get_at_yposition(); |
|---|
| 1631 | |
|---|
| 1632 | awm->callback(AW_help_entry_pressed); |
|---|
| 1633 | awm->help_text("arb_ntree.hlp"); |
|---|
| 1634 | awm->create_button("?", "#help.xpm"); |
|---|
| 1635 | |
|---|
| 1636 | // -------------------------- |
|---|
| 1637 | // save + undo/redo |
|---|
| 1638 | |
|---|
| 1639 | awm->callback(NT_save_quick_cb); |
|---|
| 1640 | awm->help_text("save.hlp"); |
|---|
| 1641 | awm->create_button("SAVE", "#save.xpm"); |
|---|
| 1642 | |
|---|
| 1643 | awm->callback(makeCreateWindowCallback(NT_create_save_as, AWAR_DBBASE)); |
|---|
| 1644 | awm->help_text("save.hlp"); |
|---|
| 1645 | awm->create_button("SAVE_AS", "#saveAs.xpm"); |
|---|
| 1646 | |
|---|
| 1647 | // undo/redo: |
|---|
| 1648 | awm->callback(makeWindowCallback(NT_undo_cb, GB_UNDO_UNDO, ntw)); |
|---|
| 1649 | awm->help_text("undo.hlp"); |
|---|
| 1650 | awm->create_button("UNDO", "#undo.xpm"); |
|---|
| 1651 | |
|---|
| 1652 | awm->callback(makeWindowCallback(NT_undo_cb, GB_UNDO_REDO, ntw)); |
|---|
| 1653 | awm->help_text("undo.hlp"); |
|---|
| 1654 | awm->create_button("REDO", "#redo.xpm"); |
|---|
| 1655 | |
|---|
| 1656 | int db_pathx2 = awm->get_at_xposition(); |
|---|
| 1657 | |
|---|
| 1658 | // fetch position for mode help-line: |
|---|
| 1659 | awm->at_newline(); |
|---|
| 1660 | int third_liney = awm->get_at_yposition(); |
|---|
| 1661 | |
|---|
| 1662 | awm->at(db_pathx, first_liney); |
|---|
| 1663 | // size of DB-name button is determined by buttons below: |
|---|
| 1664 | awm->at_attach_to(false, false, db_pathx2-db_pathx-1, second_liney-first_liney+1); |
|---|
| 1665 | awm->callback(makeCreateWindowCallback(NT_create_save_quick_as_window, AWAR_DBBASE)); |
|---|
| 1666 | awm->help_text("save.hlp"); |
|---|
| 1667 | awm->create_button("QUICK_SAVE_AS", AWAR_DB_NAME); |
|---|
| 1668 | |
|---|
| 1669 | // ----------------------------- |
|---|
| 1670 | // tree + tree display |
|---|
| 1671 | |
|---|
| 1672 | #define TREE_BUTTON_OVERSIZE 6 |
|---|
| 1673 | |
|---|
| 1674 | int db_treex = awm->get_at_xposition(); |
|---|
| 1675 | int second_uppery = second_liney-TREE_BUTTON_OVERSIZE; |
|---|
| 1676 | |
|---|
| 1677 | awm->at(db_treex, second_uppery); |
|---|
| 1678 | awm->button_length(0); |
|---|
| 1679 | |
|---|
| 1680 | awm->callback(makeWindowCallback(NT_set_tree_style, ntw, AP_TREE_RADIAL)); |
|---|
| 1681 | awm->help_text("tr_type_radial.hlp"); |
|---|
| 1682 | awm->create_button("RADIAL_TREE_TYPE", "#radial.xpm"); |
|---|
| 1683 | |
|---|
| 1684 | awm->callback(makeWindowCallback(NT_set_tree_style, ntw, AP_TREE_NORMAL)); |
|---|
| 1685 | awm->help_text("tr_type_list.hlp"); |
|---|
| 1686 | awm->create_button("LIST_TREE_TYPE", "#dendro.xpm"); |
|---|
| 1687 | |
|---|
| 1688 | awm->callback(makeWindowCallback(NT_set_tree_style, ntw, AP_TREE_IRS)); |
|---|
| 1689 | awm->help_text("tr_type_irs.hlp"); |
|---|
| 1690 | awm->create_button("FOLDED_LIST_TREE_TYPE", "#dendroIrs.xpm"); |
|---|
| 1691 | |
|---|
| 1692 | awm->callback(makeWindowCallback(NT_set_tree_style, ntw, AP_LIST_NDS)); |
|---|
| 1693 | awm->help_text("tr_type_nds.hlp"); |
|---|
| 1694 | awm->create_button("NO_TREE_TYPE", "#listdisp.xpm"); |
|---|
| 1695 | |
|---|
| 1696 | int db_treex2 = awm->get_at_xposition(); |
|---|
| 1697 | |
|---|
| 1698 | awm->at(db_treex, first_liney); |
|---|
| 1699 | // size of tree-name button is determined by buttons below: |
|---|
| 1700 | awm->at_attach_to(false, false, db_treex2-db_treex-1, second_uppery-first_liney+1); |
|---|
| 1701 | awm->callback(makeCreateWindowCallback(NT_create_select_tree_window, awar_tree)); |
|---|
| 1702 | awm->help_text("nt_tree_select.hlp"); |
|---|
| 1703 | awm->create_button("SELECT_A_TREE", awar_tree); |
|---|
| 1704 | |
|---|
| 1705 | // --------------------------------------------------------------- |
|---|
| 1706 | // protection, alignment + editor (and maybe Genome Map) |
|---|
| 1707 | |
|---|
| 1708 | int db_alignx = awm->get_at_xposition(); |
|---|
| 1709 | |
|---|
| 1710 | // editor and genemap buttons have to be 44x24 sized |
|---|
| 1711 | #define EDIT_XSIZE 50 |
|---|
| 1712 | #define EDIT_YSIZE 30 // same as 'save as' buttons |
|---|
| 1713 | |
|---|
| 1714 | // first draw protection: |
|---|
| 1715 | int protectx = db_alignx + 2*EDIT_XSIZE; |
|---|
| 1716 | |
|---|
| 1717 | awm->at(protectx+2, first_liney+1); |
|---|
| 1718 | awm->button_length(0); |
|---|
| 1719 | awm->create_button(NULp, "#protect.xpm"); |
|---|
| 1720 | |
|---|
| 1721 | awm->at(protectx, second_liney+2); |
|---|
| 1722 | awm->create_option_menu(AWAR_SECURITY_LEVEL, true); |
|---|
| 1723 | awm->insert_option ("0", NULp, 0); |
|---|
| 1724 | awm->insert_option ("1", NULp, 1); |
|---|
| 1725 | awm->insert_option ("2", NULp, 2); |
|---|
| 1726 | awm->insert_option ("3", NULp, 3); |
|---|
| 1727 | awm->insert_option ("4", NULp, 4); |
|---|
| 1728 | awm->insert_option ("5", NULp, 5); |
|---|
| 1729 | awm->insert_default_option("6", NULp, 6); |
|---|
| 1730 | awm->update_option_menu(); |
|---|
| 1731 | |
|---|
| 1732 | int db_searchx = awm->get_at_xposition() - 7; |
|---|
| 1733 | |
|---|
| 1734 | // draw ali/editor buttons AFTER protect menu (to get rid of it's label) |
|---|
| 1735 | awm->at(db_alignx, second_liney); |
|---|
| 1736 | |
|---|
| 1737 | awm->at_attach_to(false, false, ((2-is_genome_db)*EDIT_XSIZE), EDIT_YSIZE); |
|---|
| 1738 | awm->callback(makeWindowCallback(NT_start_editor_on_tree, 0, ntw)); |
|---|
| 1739 | awm->help_text("arb_edit4.hlp"); |
|---|
| 1740 | if (is_genome_db) awm->create_button("EDIT_SEQUENCES", "#editor_small.xpm"); |
|---|
| 1741 | else awm->create_button("EDIT_SEQUENCES", "#editor.xpm"); |
|---|
| 1742 | |
|---|
| 1743 | if (is_genome_db) { |
|---|
| 1744 | awm->at_attach_to(false, false, EDIT_XSIZE, EDIT_YSIZE); |
|---|
| 1745 | awm->callback(makeCreateWindowCallback(GEN_create_first_map, GLOBAL.gb_main)); // initial gene map |
|---|
| 1746 | awm->help_text("gene_map.hlp"); |
|---|
| 1747 | awm->create_button("OPEN_GENE_MAP", "#gen_map.xpm"); |
|---|
| 1748 | } |
|---|
| 1749 | |
|---|
| 1750 | int db_alignx2 = awm->get_at_xposition(); |
|---|
| 1751 | |
|---|
| 1752 | awm->at(db_alignx, first_liney); |
|---|
| 1753 | awm->at_attach_to(false, false, db_alignx2-db_alignx-1, second_liney-first_liney+1); |
|---|
| 1754 | awm->callback(NT_create_select_alignment_window); |
|---|
| 1755 | awm->help_text("nt_align_select.hlp"); |
|---|
| 1756 | awm->create_button("SELECT_AN_ALIGNMENT", AWAR_DEFAULT_ALIGNMENT); |
|---|
| 1757 | |
|---|
| 1758 | // ------------------------------- |
|---|
| 1759 | // create mode-help line |
|---|
| 1760 | |
|---|
| 1761 | awm->at(leftx, third_liney); |
|---|
| 1762 | awm->button_length(AWAR_FOOTER_MAX_LEN); |
|---|
| 1763 | awm->create_button(NULp, AWAR_FOOTER); |
|---|
| 1764 | |
|---|
| 1765 | awm->at_newline(); |
|---|
| 1766 | int bottomy = awm->get_at_yposition(); |
|---|
| 1767 | |
|---|
| 1768 | // --------------------------------------- |
|---|
| 1769 | // Info / marked / Search / Jump |
|---|
| 1770 | |
|---|
| 1771 | awm->button_length(7); |
|---|
| 1772 | |
|---|
| 1773 | awm->at(db_searchx, first_liney); |
|---|
| 1774 | awm->callback(makeCreateWindowCallback(DBUI::create_species_query_window, GLOBAL.gb_main)); |
|---|
| 1775 | awm->help_text("sp_search.hlp"); |
|---|
| 1776 | awm->create_button("SEARCH", "Search"); |
|---|
| 1777 | |
|---|
| 1778 | awm->at(db_searchx, second_uppery); |
|---|
| 1779 | awm->callback(makeWindowCallback(NT_jump_cb, ntw, AP_JUMP_BY_BUTTON)); |
|---|
| 1780 | awm->help_text("tr_jump.hlp"); |
|---|
| 1781 | awm->create_button("JUMP", "Jump"); |
|---|
| 1782 | |
|---|
| 1783 | int db_infox = awm->get_at_xposition(); |
|---|
| 1784 | |
|---|
| 1785 | awm->at(db_infox, first_liney); |
|---|
| 1786 | awm->button_length(13); |
|---|
| 1787 | awm->callback(popupinfo_wcb); |
|---|
| 1788 | awm->help_text("sp_search.hlp"); |
|---|
| 1789 | awm->create_button("INFO", AWAR_INFO_BUTTON_TEXT); |
|---|
| 1790 | |
|---|
| 1791 | awm->at(db_infox, second_uppery); |
|---|
| 1792 | awm->button_length(13); |
|---|
| 1793 | awm->help_text("species_configs.hlp"); |
|---|
| 1794 | awm->callback(makeWindowCallback(NT_popup_configuration_admin, ntw)); |
|---|
| 1795 | awm->create_button("selection_admin2", AWAR_MARKED_SPECIES_COUNTER); |
|---|
| 1796 | { |
|---|
| 1797 | GBDATA *gb_species_data = GBT_get_species_data(GLOBAL.gb_main); |
|---|
| 1798 | GB_add_callback(gb_species_data, GB_CB_CHANGED, makeDatabaseCallback(NT_update_marked_counter, static_cast<AW_window*>(awm))); |
|---|
| 1799 | NT_update_marked_counter(NULp, awm); |
|---|
| 1800 | } |
|---|
| 1801 | |
|---|
| 1802 | // set height of top area: |
|---|
| 1803 | awm->set_info_area_height(bottomy+2); |
|---|
| 1804 | awm->set_bottom_area_height(0); |
|---|
| 1805 | |
|---|
| 1806 | NT_activate_configMarkers_display(ntw); |
|---|
| 1807 | |
|---|
| 1808 | // ------------------------------------ |
|---|
| 1809 | // Autostarts for development |
|---|
| 1810 | |
|---|
| 1811 | #if defined(DEVEL_RALF) |
|---|
| 1812 | // if (is_genome_db) GEN_map_first(awr)->show(); |
|---|
| 1813 | #endif // DEVEL_RALF |
|---|
| 1814 | |
|---|
| 1815 | GB_pop_transaction(GLOBAL.gb_main); |
|---|
| 1816 | |
|---|
| 1817 | #if defined(DEBUG) |
|---|
| 1818 | AWT_check_action_ids(awr, is_genome_db ? "_genome" : ""); |
|---|
| 1819 | #endif |
|---|
| 1820 | |
|---|
| 1821 | return awm; |
|---|
| 1822 | } |
|---|
| 1823 | |
|---|
| 1824 | TREE_canvas *NT_create_main_window(AW_root *aw_root) { |
|---|
| 1825 | GB_ERROR error = GB_request_undo_type(GLOBAL.gb_main, GB_UNDO_NONE); |
|---|
| 1826 | if (error) aw_message(error); |
|---|
| 1827 | |
|---|
| 1828 | nt_create_all_awars(aw_root); |
|---|
| 1829 | |
|---|
| 1830 | TREE_canvas *ntw = NULp; |
|---|
| 1831 | AW_window *aww = popup_new_main_window(aw_root, 0, &ntw); |
|---|
| 1832 | NT_install_treeShader(ntw, GLOBAL.gb_main); |
|---|
| 1833 | aww->show(); |
|---|
| 1834 | |
|---|
| 1835 | error = GB_request_undo_type(GLOBAL.gb_main, GB_UNDO_UNDO); |
|---|
| 1836 | if (error) aw_message(error); |
|---|
| 1837 | |
|---|
| 1838 | return ntw; |
|---|
| 1839 | } |
|---|