source: branches/port5/SECEDIT/SEC_db.hxx

Last change on this file was 5675, checked in by westram, 16 years ago
  • removed automatic timestamps (the best they were good for, were vc-conflicts)
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.3 KB
Line 
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 _CPP_CSTDIO
16#include <cstdio>
17#endif
18
19#ifndef ARBDB_H
20#include <arbdb.h>
21#endif
22#ifndef ARBTOOLS_H
23#include <arbtools.h>
24#endif
25#ifndef BI_HELIX_HXX
26#include <BI_helix.hxx>
27#endif
28
29#ifndef SEC_DEFS_HXX
30#include "SEC_defs.hxx"
31#endif
32
33// --------------------------------------------------------------------------------
34
35#define AWAR_SECEDIT_BASELINEWIDTH "secedit/baselinewidth"
36#define AWAR_SECEDIT_SAVEDIR       "secedit/savedir"
37
38#define AWAR_SECEDIT_DIST_BETW_STRANDS  "secedit/layout/dist_betw_strands"
39#define AWAR_SECEDIT_SKELETON_THICKNESS "secedit/layout/skelton_thickness"
40#define AWAR_SECEDIT_BOND_THICKNESS     "secedit/layout/bond_thickness"
41#define AWAR_SECEDIT_SHOW_DEBUG         "secedit/layout/show_debug_info"
42#define AWAR_SECEDIT_SHOW_HELIX_NRS     "secedit/layout/show_helix_numbers"
43#define AWAR_SECEDIT_SHOW_ECOLI_POS     "secedit/layout/show_ecoli_pos"
44#define AWAR_SECEDIT_SHOW_STR_SKELETON  "secedit/layout/show_structure_skeleton"
45#define AWAR_SECEDIT_HIDE_BASES         "secedit/layout/hide_bases"
46#define AWAR_SECEDIT_SHOW_BONDS         "secedit/layout/show_bonds"
47#define AWAR_SECEDIT_SHOW_CURPOS        "secedit/layout/show_cursor_pos"
48#define AWAR_SECEDIT_DISPLAY_SAI        "secedit/layout/display_sai"
49#define AWAR_SECEDIT_DISPLAY_SEARCH     "secedit/layout/display_search"
50#define AWAR_SECEDIT_DISPPOS_BINDING    "secedit/layout/disppos_binding"
51#define AWAR_SECEDIT_DISPPOS_ECOLI      "secedit/layout/disppos_ecoli"
52
53#define AWAR_SECEDIT_STRONG_PAIRS   "secedit/layout/pairs/strong"       // Bonds
54#define AWAR_SECEDIT_NORMAL_PAIRS   "secedit/layout/pairs/normal"
55#define AWAR_SECEDIT_WEAK_PAIRS     "secedit/layout/pairs/weak"
56#define AWAR_SECEDIT_NO_PAIRS       "secedit/layout/pairs/no"
57#define AWAR_SECEDIT_USER_PAIRS     "secedit/layout/pairs/user"
58
59#define AWAR_SECEDIT_STRONG_PAIR_CHAR   "secedit/layout/pairs/strong_char"
60#define AWAR_SECEDIT_NORMAL_PAIR_CHAR   "secedit/layout/pairs/normal_char"
61#define AWAR_SECEDIT_WEAK_PAIR_CHAR     "secedit/layout/pairs/weak_char"
62#define AWAR_SECEDIT_NO_PAIR_CHAR       "secedit/layout/pairs/no_char"
63#define AWAR_SECEDIT_USER_PAIR_CHAR     "secedit/layout/pairs/user_char"
64
65// --------------------------------------------------------------------------------
66
67struct SEC_dbcb;
68class  SEC_db_interface;
69
70class SEC_seq_data { // represents a sequence (or SAI)
71    GBDATA         *gb_name;
72    GBDATA         *gb_data;
73    const SEC_dbcb *change_cb;
74    size_t          len;
75    char           *Data;
76
77public:
78    SEC_seq_data(GBDATA *gb_item, const char *aliname, const SEC_dbcb *reload_item);
79    ~SEC_seq_data();
80
81    bool valid() const { return Data; }
82    size_t length() const { sec_assert(valid()); return len; }
83    char data(size_t abspos) const {
84        sec_assert(abspos<length());
85        return Data[abspos];
86    }
87
88    const char *sequence() const { sec_assert(valid()); return Data; }
89};
90
91class BI_helix;
92class BI_ecoli_ref;
93class SEC_graphic;
94class AWT_canvas;
95class AW_root;
96class ED4_sequence_terminal;
97class SEC_bond_def;
98class SEC_root;
99class SEC_structure_toggler;
100
101class SEC_db_interface : Noncopyable {
102    SEC_seq_data                *sequence; // 0 = no sequence selected
103    const ED4_sequence_terminal *seqTerminal;
104
105    bool          displayEcoliPositions; // whether to display ecoli positions
106    SEC_seq_data *ecoli_seq;        // 0 = no ecoli found or not used
107    BI_ecoli_ref *Ecoli;
108
109    SEC_bond_def *bonddef;
110
111    bool          displayBindingHelixPositions; // whether to display all binding helix positions
112    SEC_seq_data *helix_nr;
113    SEC_seq_data *helix_pos;
114    BI_helix     *Helix;
115
116    mutable SEC_structure_toggler *toggler;
117
118    SEC_graphic *gfx;
119    AWT_canvas  *ntw;
120    GBDATA      *gb_main;
121    AW_root     *aw_root;
122
123    char   *aliname;
124    size_t  ali_length;
125
126    bool *displayPos;           // contains true for displayed positions
127    size_t shown; // how many positions are shown
128
129    SEC_dbcb *sequence_cb;
130    SEC_dbcb *ecoli_cb;
131    SEC_dbcb *helix_cb;
132    SEC_dbcb *updatepos_cb;
133    SEC_dbcb *relayout_cb;
134    SEC_dbcb *refresh_cb;
135    SEC_dbcb *cursorpos_cb;
136    SEC_dbcb *alilen_changed_cb;
137
138    bool perform_refresh; // perform canvas refresh in callbacks ?
139
140    void reload_sequence(const SEC_dbcb *cb);
141    void reload_ecoli(const SEC_dbcb *cb);
142    void reload_helix(const SEC_dbcb *cb);
143    void update_positions(const SEC_dbcb *cb);
144    void relayout(const SEC_dbcb *cb);
145    void refresh(const SEC_dbcb *cb);
146    void cursor_changed(const SEC_dbcb *cb);
147    void alilen_changed(const SEC_dbcb *cb);
148
149    void bind_awars(const char **awars, SEC_dbcb *cb);
150   
151public:
152    SEC_db_interface(SEC_graphic *Gfx, AWT_canvas *Ntw);
153    ~SEC_db_interface();
154
155    void update_shown_positions();
156
157    bool canDisplay() const { return Helix && sequence; }
158    size_t length() const { return ali_length; }
159
160    bool shallDisplayPosition(size_t abspos) const {
161        sec_assert(abspos<length());
162        return displayPos[abspos];
163    }
164    char baseAt(size_t abspos) const {
165        sec_assert(abspos<length());
166        return sequence->data(abspos);
167    }
168
169    AW_root *awroot() const { return aw_root; }
170    GBDATA *gbmain() const { return gb_main; }
171    SEC_graphic *graphic() const { return gfx; }
172    SEC_root *secroot() const;
173    AWT_canvas *canvas() const { return ntw; }
174    BI_helix *helix() const { return Helix; }
175    BI_ecoli_ref *ecoli() const { return Ecoli; }
176    const ED4_sequence_terminal *get_seqTerminal() const { return seqTerminal; }
177    SEC_bond_def *bonds() const { return bonddef; }
178    SEC_structure_toggler *structure() const { return toggler; }
179
180    void init_toggler() const;
181};
182
183
184
185#else
186#error sec_db.hxx included twice
187#endif // SEC_DB_HXX
Note: See TracBrowser for help on using the repository browser.