source: branches/stable/SECEDIT/SEC_db.hxx

Last change on this file was 15665, checked in by westram, 7 years ago
  • reintegrates 'refactor' into 'trunk'
    • refactored AWT_graphic
      • now have explicit states with different permissions
        1. update model + request view/DB updates (AWT_auto_refresh)
          • always preceeded by DB→model up-to-date-check
          • automatically updates the view on destruction
        2. update (DB and view) from model
        3. neither
    • benefits
      • saves several view-updates
      • unproblematic nesting of functions requesting view-updates
      • will allow
        • delayed view-updates and
        • easier modification of update logic
    • fixes a bunch of update-issues (found on the way)
  • adds: log:branches/refactor@15613:15615,15627:15637,15639:15664
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.2 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 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_STRONG_PAIRS   "secedit/layout/pairs/strong"       // Bonds
48#define AWAR_SECEDIT_NORMAL_PAIRS   "secedit/layout/pairs/normal"
49#define AWAR_SECEDIT_WEAK_PAIRS     "secedit/layout/pairs/weak"
50#define AWAR_SECEDIT_NO_PAIRS       "secedit/layout/pairs/no"
51#define AWAR_SECEDIT_USER_PAIRS     "secedit/layout/pairs/user"
52
53#define AWAR_SECEDIT_STRONG_PAIR_CHAR   "secedit/layout/pairs/strong_char"
54#define AWAR_SECEDIT_NORMAL_PAIR_CHAR   "secedit/layout/pairs/normal_char"
55#define AWAR_SECEDIT_WEAK_PAIR_CHAR     "secedit/layout/pairs/weak_char"
56#define AWAR_SECEDIT_NO_PAIR_CHAR       "secedit/layout/pairs/no_char"
57#define AWAR_SECEDIT_USER_PAIR_CHAR     "secedit/layout/pairs/user_char"
58
59// --------------------------------------------------------------------------------
60
61struct SEC_dbcb;
62class  SEC_db_interface;
63
64class SEC_seq_data : virtual Noncopyable { // represents a sequence (or SAI)
65    GBDATA         *gb_name;
66    GBDATA         *gb_data;
67    const SEC_dbcb *change_cb;
68    size_t          len;
69    char           *Data;
70
71public:
72    SEC_seq_data(GBDATA *gb_item, const char *aliname, const SEC_dbcb *reload_item);
73    ~SEC_seq_data();
74
75    bool valid() const { return Data; }
76    size_t length() const { sec_assert(valid()); return len; }
77    char data(size_t abspos) const {
78        sec_assert(abspos<length());
79        return Data[abspos];
80    }
81
82    const char *sequence() const { sec_assert(valid()); return Data; }
83};
84
85class BI_helix;
86class BI_ecoli_ref;
87class SEC_graphic;
88class AWT_canvas;
89class AW_root;
90class ED4_sequence_terminal;
91class SEC_bond_def;
92class SEC_root;
93class SEC_structure_toggler;
94
95class SEC_db_interface : virtual Noncopyable {
96    SEC_seq_data          *sequence;       // 0 = no sequence selected
97    ED4_plugin_host&  Host;
98
99    bool          displayEcoliPositions; // whether to display ecoli positions
100    SEC_seq_data *ecoli_seq;        // 0 = no ecoli found or not used
101    BI_ecoli_ref *Ecoli;
102
103    SEC_bond_def *bonddef;
104
105    bool          displayBindingHelixPositions; // whether to display all binding helix positions
106    SEC_seq_data *helix_nr;
107    SEC_seq_data *helix_pos;
108    BI_helix     *Helix;
109
110    mutable SEC_structure_toggler *toggler;
111
112    SEC_graphic *gfx;
113    AWT_canvas  *scr;
114    GBDATA      *gb_main;
115    AW_root     *aw_root;
116
117    char   *aliname;
118    size_t  ali_length;
119
120    bool *displayPos;           // contains true for displayed positions
121    size_t shown; // how many positions are shown
122
123    SEC_dbcb *sequence_cb;
124    SEC_dbcb *ecoli_cb;
125    SEC_dbcb *helix_cb;
126    SEC_dbcb *updatepos_cb;
127    SEC_dbcb *relayout_cb;
128    SEC_dbcb *refresh_cb;
129    SEC_dbcb *cursorpos_cb;
130    SEC_dbcb *alilen_changed_cb;
131
132    void reload_sequence(const SEC_dbcb *cb);
133    void reload_ecoli(const SEC_dbcb *cb);
134    void reload_helix(const SEC_dbcb *cb);
135    void update_positions(const SEC_dbcb *cb);
136    void relayout(const SEC_dbcb *cb);
137    void refresh(const SEC_dbcb *cb);
138    void cursor_changed(const SEC_dbcb *cb);
139    void alilen_changed(const SEC_dbcb *cb);
140
141    void bind_awars(const char **awars, SEC_dbcb *cb);
142
143public:
144    SEC_db_interface(SEC_graphic *Gfx, AWT_canvas *Scr, ED4_plugin_host& host_);
145    ~SEC_db_interface();
146
147    void update_shown_positions();
148
149    bool canDisplay() const { return Helix && sequence; }
150    size_t length() const { return ali_length; }
151
152    bool shallDisplayPosition(size_t abspos) const {
153        sec_assert(abspos<length());
154        return displayPos[abspos];
155    }
156    char baseAt(size_t abspos) const {
157        sec_assert(abspos<length());
158        return sequence->data(abspos);
159    }
160
161    AW_root *awroot() const { return aw_root; }
162    GBDATA *gbmain() const { return gb_main; }
163    SEC_graphic *graphic() const { return gfx; }
164    SEC_root *secroot() const;
165    AWT_canvas *canvas() const { return scr; }
166    BI_helix *helix() const { return Helix; }
167    BI_ecoli_ref *ecoli() const { return Ecoli; }
168    SEC_bond_def *bonds() const { return bonddef; }
169    SEC_structure_toggler *structure() const { return toggler; }
170    const ED4_plugin_host& host() const { return Host; }
171
172    void init_toggler() const;
173};
174
175
176
177#else
178#error sec_db.hxx included twice
179#endif // SEC_DB_HXX
Note: See TracBrowser for help on using the repository browser.