source: tags/arb-6.0-rc1/GENOM/EXP_main.cxx

Last change on this file was 11464, checked in by westram, 11 years ago
  • un-dummy-fied transaction (renames only)
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.0 KB
Line 
1//  ==================================================================== //
2//                                                                       //
3//    File      : EXP_main.cxx                                           //
4//    Purpose   :                                                        //
5//                                                                       //
6//                                                                       //
7//  Coded by Ralf Westram (coder@reallysoft.de) in September 2001        //
8//  Copyright Department of Microbiology (Technical University Munich)   //
9//                                                                       //
10//  Visit our web site at: http://www.arb-home.de/                       //
11//                                                                       //
12//                                                                       //
13//  ==================================================================== //
14
15#include "EXP_local.hxx"
16
17#include <awt.hxx>
18#include <awt_input_mask.hxx>
19#include <aw_awars.hxx>
20#include <aw_window.hxx>
21#include <aw_root.hxx>
22#include <arbdbt.h>
23#include <db_query.h>
24#include <rootAsWin.h>
25
26using namespace std;
27
28static void EXP_species_name_changed_cb(AW_root * /* awr */) {
29}
30
31static void EXP_update_combined_cb(AW_root *awr) {
32    char       *organism   = awr->awar(AWAR_ORGANISM_NAME)->read_string();
33    char       *experiment = awr->awar(AWAR_EXPERIMENT_NAME)->read_string();
34    const char *combined   = GBS_global_string("%s/%s", organism, experiment);
35    awr->awar(AWAR_COMBINED_EXPERIMENT_NAME)->write_string(combined);
36    free(experiment);
37    free(organism);
38}
39
40void EXP_create_awars(AW_root *aw_root, AW_default /* aw_def */, GBDATA *gb_main) {
41    aw_root->awar_string(AWAR_EXPERIMENT_NAME,          "", gb_main)->add_callback((AW_RCB0)EXP_update_combined_cb);
42    aw_root->awar_string(AWAR_PROTEOM_NAME,             "", gb_main);
43    aw_root->awar_string(AWAR_PROTEIN_NAME,             "", gb_main);
44    aw_root->awar_string(AWAR_ORGANISM_NAME,            "", gb_main)->add_callback((AW_RCB0)EXP_update_combined_cb);
45    aw_root->awar_string(AWAR_COMBINED_EXPERIMENT_NAME, "", gb_main);
46    aw_root->awar_string(AWAR_SPECIES_NAME,             "", gb_main)->add_callback((AW_RCB0)EXP_species_name_changed_cb);
47    aw_root->awar_string(AWAR_EXPERIMENT_DEST,          "", gb_main);
48}
49
50// ---------------------------------------
51//      EXP_item_type_species_selector
52
53struct EXP_item_type_species_selector : public awt_item_type_selector {
54    EXP_item_type_species_selector() : awt_item_type_selector(AWT_IT_EXPERIMENT) {}
55    virtual ~EXP_item_type_species_selector() OVERRIDE {}
56
57    virtual const char *get_self_awar() const OVERRIDE {
58        return AWAR_COMBINED_EXPERIMENT_NAME;
59    }
60    virtual size_t get_self_awar_content_length() const OVERRIDE {
61        return 12 + 1 + 40; // species-name+'/'+experiment_name
62    }
63    virtual void add_awar_callbacks(AW_root *root, void (*f)(AW_root*, AW_CL), AW_CL cl_mask) const OVERRIDE { // add callbacks to awars
64        root->awar(get_self_awar())->add_callback(f, cl_mask);
65    }
66    virtual void remove_awar_callbacks(AW_root *root, void (*f)(AW_root*, AW_CL), AW_CL cl_mask) const OVERRIDE { // add callbacks to awars
67        root->awar(get_self_awar())->remove_callback(f, cl_mask);
68    }
69    virtual GBDATA *current(AW_root *root, GBDATA *gb_main) const OVERRIDE { // give the current item
70        char   *species_name    = root->awar(AWAR_ORGANISM_NAME)->read_string();
71        char   *experiment_name = root->awar(AWAR_EXPERIMENT_NAME)->read_string();
72        GBDATA *gb_experiment   = 0;
73
74        if (species_name[0] && experiment_name[0]) {
75            GB_transaction ta(gb_main);
76            GBDATA *gb_species = GBT_find_species(gb_main, species_name);
77            if (gb_species) {
78                gb_experiment = EXP_find_experiment(gb_species, experiment_name);
79            }
80        }
81
82        free(experiment_name);
83        free(species_name);
84
85        return gb_experiment;
86    }
87    virtual const char *getKeyPath() const OVERRIDE { // give the keypath for items
88        return CHANGE_KEY_PATH_EXPERIMENTS;
89    }
90};
91
92static EXP_item_type_species_selector item_type_experiment;
93
94static void EXP_open_mask_window(AW_window *aww, AW_CL cl_id, AW_CL cl_gb_main) {
95    int                              id         = int(cl_id);
96    const awt_input_mask_descriptor *descriptor = AWT_look_input_mask(id);
97    exp_assert(descriptor);
98    if (descriptor) {
99        GBDATA *gb_main = (GBDATA*)cl_gb_main;
100        AWT_initialize_input_mask(aww->get_root(), gb_main, &item_type_experiment, descriptor->get_internal_maskname(), descriptor->is_local_mask());
101    }
102}
103
104static void EXP_create_mask_submenu(AW_window_menu_modes *awm, GBDATA *gb_main) {
105    AWT_create_mask_submenu(awm, AWT_IT_EXPERIMENT, EXP_open_mask_window, (AW_CL)gb_main);
106}
107
108static AW_window *create_colorize_experiments_window(AW_root *aw_root, AW_CL cl_gb_main) {
109    GBDATA *gb_main = (GBDATA*)cl_gb_main;
110    return QUERY::create_colorize_items_window(aw_root, gb_main, EXP_get_selector());
111}
112
113void EXP_create_experiments_submenu(AW_window_menu_modes *awm, GBDATA *gb_main, bool submenu) {
114    const char *title  = "Experiment";
115    const char *hotkey = "x";
116
117    if (submenu) awm->insert_sub_menu(title, hotkey);
118    else awm->create_menu(title, hotkey, AWM_ALL);
119
120    {
121        awm->insert_menu_topic("experiment_info",   "Experiment information", "i", "experiment_info.hlp",   AWM_ALL, RootAsWindowCallback::simple(EXP_popup_experiment_window, gb_main));
122        awm->insert_menu_topic("experiment_search", "Search and query",       "q", "experiment_search.hlp", AWM_ALL, AW_POPUP, (AW_CL)EXP_create_experiment_query_window, (AW_CL)gb_main);
123
124        EXP_create_mask_submenu(awm, gb_main);
125
126        awm->sep______________();
127        awm->insert_menu_topic("experiment_colors",     "Colors ...",           "C",    "mark_colors.hlp", AWM_ALL, AW_POPUP,  (AW_CL)create_colorize_experiments_window, (AW_CL)gb_main);
128    }
129    if (submenu) awm->close_sub_menu();
130}
131
Note: See TracBrowser for help on using the repository browser.