1 | // =============================================================== // |
---|
2 | // // |
---|
3 | // File : sec_db.hxx // |
---|
4 | // Purpose : DB interface // |
---|
5 | // // |
---|
6 | // Coded by Ralf Westram (coder@reallysoft.de) in August 2007 // |
---|
7 | // Institute of Microbiology (Technical University Munich) // |
---|
8 | // http://www.arb-home.de/ // |
---|
9 | // // |
---|
10 | // =============================================================== // |
---|
11 | |
---|
12 | #ifndef SEC_DB_HXX |
---|
13 | #define SEC_DB_HXX |
---|
14 | |
---|
15 | #ifndef BI_BASEPOS_HXX |
---|
16 | #include <BI_basepos.hxx> |
---|
17 | #endif |
---|
18 | |
---|
19 | #ifndef SEC_DEFS_HXX |
---|
20 | #include "SEC_defs.hxx" |
---|
21 | #endif |
---|
22 | #ifndef SECEDIT_EXTERN_HXX |
---|
23 | #include "secedit_extern.hxx" |
---|
24 | #endif |
---|
25 | |
---|
26 | |
---|
27 | // -------------------------------------------------------------------------------- |
---|
28 | |
---|
29 | #define AWAR_SECEDIT_BASELINEWIDTH "secedit/baselinewidth" |
---|
30 | #define AWAR_SECEDIT_SAVEDIR "tmp/secedit/savedir" |
---|
31 | |
---|
32 | #define AWAR_SECEDIT_DIST_BETW_STRANDS "secedit/layout/dist_betw_strands" |
---|
33 | #define AWAR_SECEDIT_SKELETON_THICKNESS "secedit/layout/skelton_thickness" |
---|
34 | #define AWAR_SECEDIT_BOND_THICKNESS "secedit/layout/bond_thickness" |
---|
35 | #define AWAR_SECEDIT_SHOW_DEBUG "secedit/layout/show_debug_info" |
---|
36 | #define AWAR_SECEDIT_SHOW_HELIX_NRS "secedit/layout/show_helix_numbers" |
---|
37 | #define AWAR_SECEDIT_SHOW_ECOLI_POS "secedit/layout/show_ecoli_pos" |
---|
38 | #define AWAR_SECEDIT_SHOW_STR_SKELETON "secedit/layout/show_structure_skeleton" |
---|
39 | #define AWAR_SECEDIT_HIDE_BASES "secedit/layout/hide_bases" |
---|
40 | #define AWAR_SECEDIT_SHOW_BONDS "secedit/layout/show_bonds" |
---|
41 | #define AWAR_SECEDIT_SHOW_CURPOS "secedit/layout/show_cursor_pos" |
---|
42 | #define AWAR_SECEDIT_DISPLAY_SAI "secedit/layout/display_sai" |
---|
43 | #define AWAR_SECEDIT_DISPLAY_SEARCH "secedit/layout/display_search" |
---|
44 | #define AWAR_SECEDIT_DISPPOS_BINDING "secedit/layout/disppos_binding" |
---|
45 | #define AWAR_SECEDIT_DISPPOS_ECOLI "secedit/layout/disppos_ecoli" |
---|
46 | |
---|
47 | #define AWAR_SECEDIT_BOND_SYMBOLS_EDIT4 "secedit/layout/bonds/edit4" |
---|
48 | #define AWAR_SECEDIT_BOND_SYMBOLS_TRANS "secedit/layout/bonds/translated" |
---|
49 | |
---|
50 | // -------------------------------------------------------------------------------- |
---|
51 | |
---|
52 | struct SEC_dbcb; |
---|
53 | class SEC_db_interface; |
---|
54 | |
---|
55 | class SEC_seq_data : virtual Noncopyable { // represents a sequence (or SAI) |
---|
56 | GBDATA *gb_name; |
---|
57 | GBDATA *gb_data; |
---|
58 | const SEC_dbcb *change_cb; |
---|
59 | size_t len; |
---|
60 | char *Data; |
---|
61 | |
---|
62 | public: |
---|
63 | SEC_seq_data(GBDATA *gb_item, const char *aliname, const SEC_dbcb *reload_item); |
---|
64 | ~SEC_seq_data(); |
---|
65 | |
---|
66 | bool valid() const { return Data; } |
---|
67 | size_t length() const { sec_assert(valid()); return len; } |
---|
68 | char data(size_t abspos) const { |
---|
69 | sec_assert(abspos<length()); |
---|
70 | return Data[abspos]; |
---|
71 | } |
---|
72 | |
---|
73 | const char *sequence() const { sec_assert(valid()); return Data; } |
---|
74 | }; |
---|
75 | |
---|
76 | class BI_helix; |
---|
77 | class BI_ecoli_ref; |
---|
78 | class SEC_graphic; |
---|
79 | class AWT_canvas; |
---|
80 | class AW_root; |
---|
81 | class ED4_sequence_terminal; |
---|
82 | class SEC_bond_def; |
---|
83 | class SEC_root; |
---|
84 | class SEC_structure_toggler; |
---|
85 | |
---|
86 | class SEC_db_interface : virtual Noncopyable { |
---|
87 | SEC_seq_data *sequence; // 0 = no sequence selected |
---|
88 | ED4_plugin_host& Host; |
---|
89 | |
---|
90 | bool displayEcoliPositions; // whether to display ecoli positions |
---|
91 | SEC_seq_data *ecoli_seq; // 0 = no ecoli found or not used |
---|
92 | BI_ecoli_ref *Ecoli; |
---|
93 | |
---|
94 | SEC_bond_def *bonddef; |
---|
95 | |
---|
96 | bool displayBindingHelixPositions; // whether to display all binding helix positions |
---|
97 | SEC_seq_data *helix_nr; |
---|
98 | SEC_seq_data *helix_pos; |
---|
99 | BI_helix *Helix; |
---|
100 | |
---|
101 | mutable SEC_structure_toggler *toggler; |
---|
102 | |
---|
103 | SEC_graphic *gfx; |
---|
104 | AWT_canvas *scr; |
---|
105 | GBDATA *gb_main; |
---|
106 | AW_root *aw_root; |
---|
107 | |
---|
108 | char *aliname; |
---|
109 | size_t ali_length; |
---|
110 | |
---|
111 | bool *displayPos; // contains true for displayed positions |
---|
112 | size_t shown; // how many positions are shown |
---|
113 | |
---|
114 | SEC_dbcb *sequence_cb; |
---|
115 | SEC_dbcb *ecoli_cb; |
---|
116 | SEC_dbcb *helix_cb; |
---|
117 | SEC_dbcb *updatepos_cb; |
---|
118 | SEC_dbcb *relayout_cb; |
---|
119 | SEC_dbcb *refresh_cb; |
---|
120 | SEC_dbcb *cursorpos_cb; |
---|
121 | SEC_dbcb *alilen_changed_cb; |
---|
122 | |
---|
123 | void reload_sequence(const SEC_dbcb *cb); |
---|
124 | void reload_ecoli(const SEC_dbcb *cb); |
---|
125 | void reload_helix(const SEC_dbcb *cb); |
---|
126 | void update_positions(const SEC_dbcb *cb); |
---|
127 | void relayout(const SEC_dbcb *cb); |
---|
128 | void refresh(const SEC_dbcb *cb); |
---|
129 | void cursor_changed(const SEC_dbcb *cb); |
---|
130 | void alilen_changed(const SEC_dbcb *cb); |
---|
131 | |
---|
132 | void bind_awars(const char **awars, SEC_dbcb *cb); |
---|
133 | |
---|
134 | public: |
---|
135 | SEC_db_interface(SEC_graphic *Gfx, AWT_canvas *Scr, ED4_plugin_host& host_); |
---|
136 | ~SEC_db_interface(); |
---|
137 | |
---|
138 | void update_shown_positions(); |
---|
139 | |
---|
140 | bool canDisplay() const { return Helix && sequence; } |
---|
141 | size_t length() const { return ali_length; } |
---|
142 | |
---|
143 | bool shallDisplayPosition(size_t abspos) const { |
---|
144 | sec_assert(abspos<length()); |
---|
145 | return displayPos[abspos]; |
---|
146 | } |
---|
147 | char baseAt(size_t abspos) const { |
---|
148 | sec_assert(abspos<length()); |
---|
149 | return sequence->data(abspos); |
---|
150 | } |
---|
151 | |
---|
152 | AW_root *awroot() const { return aw_root; } |
---|
153 | GBDATA *gbmain() const { return gb_main; } |
---|
154 | SEC_graphic *graphic() const { return gfx; } |
---|
155 | SEC_root *secroot() const; |
---|
156 | AWT_canvas *canvas() const { return scr; } |
---|
157 | |
---|
158 | BI_helix *helix() const { return Helix; } // used to fold secondary structure |
---|
159 | const AW_helix *edit4_helix() const { return Host.get_helix(); } // used to determine symbols displayed under sequence in EDIT4 |
---|
160 | |
---|
161 | BI_ecoli_ref *ecoli() const { return Ecoli; } |
---|
162 | SEC_bond_def *bonds() const { return bonddef; } |
---|
163 | SEC_structure_toggler *structure() const { return toggler; } |
---|
164 | const ED4_plugin_host& host() const { return Host; } |
---|
165 | |
---|
166 | void init_toggler() const; |
---|
167 | }; |
---|
168 | |
---|
169 | |
---|
170 | |
---|
171 | #else |
---|
172 | #error sec_db.hxx included twice |
---|
173 | #endif // SEC_DB_HXX |
---|