source: tags/svn.1.5.4/SL/ITEMS/species.cxx

Last change on this file was 7806, checked in by westram, 13 years ago

merge from dev [7720] [7721] [7722] [7723] [7724] [7725] [7726] [7747]

  • ItemSelector
    • is now const by default (org struct is called MutableItemSelector)
    • now passed/stored as reference
    • hide MutableItemSelectors using access functions (so only const ItemSelectors can be passed around)
  • BoundItemSel
    • color_mark_data was in fact a BoundItemSel
    • BoundItemSel is now const by default (org struct is called MutableBoundItemSel)
  • renames
    • DbScanner → GB_DbScanner
    • db_scanner_data → DbScanner
  • fixes
    • skip query if querying empty set (e.g. db w/o experiments)
    • assertion failure on multiple instances of field admin menu entries (genes + experiments)
    • gene-info shows selected gene when opened 1st time
    • error no longer exported in experiment create
    • deleting current item and then selecting a new one failed to remove callback on keydata
  • added TODOs for genes/experiment UI/ItemSelectors
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
Line 
1// ================================================================ //
2//                                                                  //
3//   File      : species.cxx                                        //
4//   Purpose   :                                                    //
5//                                                                  //
6//   Institute of Microbiology (Technical University Munich)        //
7//   http://www.arb-home.de/                                        //
8//                                                                  //
9// ================================================================ //
10
11#include "item_sel_list.h"
12
13#include <arbdbt.h>
14#include <aw_root.hxx>
15#include <aw_awars.hxx>
16
17
18static GBDATA *get_first_species_data(GBDATA *gb_main, AW_root *, QUERY_RANGE) {
19    return GBT_get_species_data(gb_main);
20}
21static GBDATA *get_next_species_data(GBDATA *, QUERY_RANGE) {
22    return 0; // there is only ONE species_data
23}
24
25static void select_species(GBDATA*,  AW_root *aw_root, const char *item_name) {
26    aw_root->awar(AWAR_SPECIES_NAME)->write_string(item_name);
27}
28
29static GBDATA* get_selected_species(GBDATA *gb_main, AW_root *aw_root) {
30    char   *species_name = aw_root->awar(AWAR_SPECIES_NAME)->read_string();
31    GBDATA *gb_species   = 0;
32    if (species_name[0]) {
33        gb_species = GBT_find_species(gb_main, species_name);
34    }
35    free(species_name);
36    return gb_species;
37}
38
39static char* get_species_id(GBDATA *, GBDATA *gb_species) {
40    GBDATA *gb_name = GB_entry(gb_species, "name");
41    if (!gb_name) return 0;     // species w/o name -> skip
42    return GB_read_as_string(gb_name);
43}
44
45static GBDATA *find_species_by_id(GBDATA *gb_main, const char *id) {
46    return GBT_find_species(gb_main, id); // id is 'name' field
47}
48
49static GBDATA *get_first_species(GBDATA *gb_species_data, QUERY_RANGE range) {
50    GBDATA *gb_first = NULL;
51    switch (range) {
52        case QUERY_ALL_ITEMS:    gb_first = GBT_first_species_rel_species_data(gb_species_data); break;
53        case QUERY_MARKED_ITEMS: gb_first = GBT_first_marked_species_rel_species_data(gb_species_data); break;
54        case QUERY_CURRENT_ITEM: gb_first = get_selected_species(GB_get_root(gb_species_data), AW_root::SINGLETON); break;
55    }
56    return gb_first;
57}
58static GBDATA *get_next_species(GBDATA *gb_prev, QUERY_RANGE range) {
59    GBDATA *gb_next = NULL;
60    switch (range) {
61        case QUERY_ALL_ITEMS:    gb_next = GBT_next_species(gb_prev); break;
62        case QUERY_MARKED_ITEMS: gb_next = GBT_next_marked_species(gb_prev); break;
63        case QUERY_CURRENT_ITEM: gb_next = NULL; break;
64    }
65    return gb_next;
66}
67
68static struct MutableItemSelector ITEM_species = {
69    QUERY_ITEM_SPECIES,
70    select_species,
71    get_species_id,
72    find_species_by_id,
73    (AW_CB)species_field_selection_list_update_cb,
74    12,
75    CHANGE_KEY_PATH,
76    "species",
77    "species",
78    "name",
79    get_first_species_data,
80    get_next_species_data,
81    get_first_species,
82    get_next_species,
83    get_selected_species,
84    0, 0,
85};
86
87static struct MutableItemSelector ITEM_organism = {
88    QUERY_ITEM_SPECIES,
89    select_species,
90    get_species_id,
91    find_species_by_id,
92    (AW_CB)species_field_selection_list_update_cb,
93    12,
94    CHANGE_KEY_PATH,
95    "organism",
96    "organism",
97    "name",
98    get_first_species_data,
99    get_next_species_data,
100    get_first_species,
101    get_next_species,
102    get_selected_species,
103    0, 0,
104};
105
106ItemSelector& SPECIES_get_selector() { return ITEM_species; }
107ItemSelector& ORGANISM_get_selector() { return ITEM_organism; }
108
109void popup_select_species_field_window(AW_window *aww, AW_CL cl_awar_name, AW_CL cl_gb_main) {
110    static AW_window_simple *aws = 0;
111
112    // everytime map selection awar to latest user awar:
113    AW_root    *aw_root   = aww->get_root();
114    const char *awar_name = (const char *)cl_awar_name;
115    aw_root->awar("tmp/viewkeys/key_text_select")->map(awar_name);
116
117    if (!aws) {
118        aws = new AW_window_simple;
119
120        aws->init(aw_root, "SELECT_SPECIES_FIELD", "Select species field");
121        aws->load_xfig("awt/nds_sel.fig");
122        aws->button_length(13);
123
124        aws->callback(AW_POPDOWN);
125        aws->at("close");
126        aws->create_button("CLOSE", "CLOSE", "C");
127
128        create_selection_list_on_itemfields((GBDATA *)cl_gb_main,
129                                            aws,
130                                            "tmp/viewkeys/key_text_select",
131                                            FIELD_FILTER_NDS,
132                                            "scandb", "rescandb", SPECIES_get_selector(), 20, 10);
133        aws->recalc_pos_atShow(AW_REPOS_TO_MOUSE);
134    }
135    aws->activate();
136}
137
Note: See TracBrowser for help on using the repository browser.