source: branches/port5/AWT/awt_dtree.hxx

Last change on this file was 5968, checked in by westram, 15 years ago
  • new flag -w to aisc_mkpt (add include wrapper)
  • uniform style for several include wrappers
  • removed duplicated includes
  • removed useless nt_concatenate.hxx
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.6 KB
Line 
1// =========================================================== //
2//                                                             //
3//   File      : awt_dtree.hxx                                 //
4//   Purpose   :                                               //
5//                                                             //
6//   Institute of Microbiology (Technical University Munich)   //
7//   http://www.arb-home.de/                                   //
8//                                                             //
9// =========================================================== //
10
11#ifndef AWT_DTREE_HXX
12#define AWT_DTREE_HXX
13
14
15#define AWAR_DTREE_BASELINEWIDTH   "awt/dtree/baselinewidth"
16#define AWAR_DTREE_VERICAL_DIST    "awt/dtree/verticaldist"
17#define AWAR_DTREE_AUTO_JUMP       "awt/dtree/autojump"
18#define AWAR_DTREE_SHOW_CIRCLE     "awt/dtree/show_circle"
19#define AWAR_DTREE_CIRCLE_ZOOM     "awt/dtree/circle_zoom"
20#define AWAR_DTREE_CIRCLE_MAX_SIZE "awt/dtree/max_size"
21#define AWAR_DTREE_USE_ELLIPSE     "awt/dtree/ellipse"
22#define AWAR_DTREE_GREY_LEVEL      "awt/dtree/greylevel"
23
24#define AWAR_DTREE_REFRESH       AWAR_TREE_REFRESH // touch this awar to refresh the tree display
25
26void awt_create_dtree_awars(AW_root *aw_root,AW_default def);
27
28#define NT_BOX_WIDTH       3.5  /* pixel/2 ! */
29#define NT_ROOT_WIDTH      4.5  /* pixel/2 ! */
30#define NT_SELECTED_WIDTH  5.5
31
32#define PH_CLICK_SPREAD   0.10
33
34#define AWT_TREE(ntw) ((AWT_graphic_tree *)ntw->tree_disp)
35
36
37typedef enum {
38    AP_TREE_NORMAL, // normal tree display (dendogram)
39    AP_TREE_RADIAL, // radial tree display
40    AP_TREE_IRS, // like AP_TREE_NORMAL, with folding line
41    AP_LIST_NDS,
42    AP_LIST_SIMPLE // simple display only showing name (used at startup to avoid NDS error messages)
43} AP_tree_sort;
44
45inline bool sort_is_list_style(AP_tree_sort sort) { return sort == AP_LIST_NDS || sort == AP_LIST_SIMPLE; }
46inline bool sort_is_tree_style(AP_tree_sort sort) { return !sort_is_list_style(sort); }
47
48
49class AWT_graphic_tree_group_state;
50
51struct AWT_scaled_font_limits {
52    double ascent;
53    double descent;
54    double height;
55    double width;
56
57    void init(const AW_font_limits& font_limits, double factor) {
58        ascent  = font_limits.ascent*factor;
59        descent = font_limits.descent*factor;
60        height  = font_limits.height*factor;
61        width   = font_limits.width*factor;
62    }
63};
64
65
66class AWT_graphic_tree : public AWT_graphic {
67    char  *species_name;
68    int    baselinewidth;
69    int    show_circle;
70    int    use_ellipse;
71    float  circle_zoom_factor;
72    float  circle_max_size;
73
74    int zombies; // # of zombies during last load()
75    int duplicates; // # of duplicates during last load()
76
77    int draw_slot(int x_offset, GB_BOOL draw_at_tips); // return max_x
78    int paint_irs_sub_tree(AP_tree *node, int x_offset, int type); // returns y pos
79
80    void unload();
81
82    // variables - tree compatibility
83
84    AP_tree * tree_proto;
85    double    y_pos;
86    double    list_tree_ruler_y;
87    double    irs_tree_ruler_scale_factor;
88
89    AWT_scaled_font_limits scaled_font;
90    double                 scaled_branch_distance; // vertical distance between branches (may be extra-scaled in options)
91
92    AW_pos          grey_level;
93    double          rot_orientation;
94    double          rot_spread;
95    AW_clicked_text rot_ct;
96
97    AW_device *disp_device; // device for  rekursiv Funktions
98
99    AW_bitset line_filter,vert_line_filter, text_filter,mark_filter;
100    AW_bitset ruler_filter, root_filter;
101    int       treemodus;
102    bool      nds_show_all;
103
104    void scale_text_koordinaten(AW_device *device, int gc, double& x,double& y,double orientation,int flag );
105
106    // functions to compute displayinformation
107
108    double show_dendrogram(AP_tree *at, double x_father, double x_son);
109
110    void show_radial_tree(AP_tree *at,
111                          double   x_center,
112                          double   y_center,
113                          double   tree_sprad,
114                          double   tree_orientation,
115                          double   x_root,
116                          double   y_root,
117                          int      linewidth);
118
119    void show_nds_list(GBDATA * gb_main, bool use_nds);
120    void show_irs_tree(AP_tree *at,AW_device *device, int height);
121
122    void NT_scalebox(int gc, double x, double y, double width);
123    void NT_emptybox(int gc, double x, double y, double width);
124    void NT_rotbox(int gc, double x, double y, double width);
125   
126    const char *show_ruler(AW_device *device, int gc);
127    void        rot_show_triangle( AW_device *device);
128
129protected:
130
131    AW_clicked_line  old_rot_cl;
132    AW_clicked_line  rot_cl;
133    AP_tree         *rot_at;
134
135    void rot_show_line( AW_device *device );
136   
137public:
138
139    // *********** read only variables !!!
140    AW_root      *aw_root;
141    AP_tree_sort  tree_sort;
142    AP_tree *     tree_root;
143    AP_tree *     tree_root_display;
144    AP_tree_root *tree_static;
145    GBDATA       *gb_main;
146    char         *tree_name;
147
148    AP_FLOAT x_cursor,y_cursor;
149    // *********** public section
150    AWT_graphic_tree(AW_root *aw_root, GBDATA *gb_main);
151    virtual ~AWT_graphic_tree(void);
152
153    void init(AP_tree * tree_prot);
154    virtual AW_gc_manager init_devices(AW_window *,AW_device *,AWT_canvas *ntw,AW_CL);
155
156    virtual void show(AW_device *device);
157
158    virtual void info(AW_device *device, AW_pos x, AW_pos y,
159                      AW_clicked_line *cl, AW_clicked_text *ct);
160
161    virtual void command(AW_device *device, AWT_COMMAND_MODE cmd, int button, AW_key_mod key_modifier, AW_key_code key_code, char key_char, AW_event_type type,
162                         AW_pos x, AW_pos y,
163                         AW_clicked_line *cl, AW_clicked_text *ct);
164
165    void key_command(AWT_COMMAND_MODE cmd, AW_key_mod key_modifier, char key_char,
166                     AW_pos           x, AW_pos y, AW_clicked_line *cl, AW_clicked_text *ct);
167
168    void mark_species_in_tree(AP_tree *at, int mark);
169    void mark_species_in_tree_that(AP_tree *at, int mark, int (*condition)(GBDATA*, void*), void *cd);
170
171    void mark_species_in_rest_of_tree(AP_tree *at, int mark);
172    void mark_species_in_rest_of_tree_that(AP_tree *at, int mark, int (*condition)(GBDATA*, void*), void *cd);
173
174    bool tree_has_marks(AP_tree *at);
175    bool rest_tree_has_marks(AP_tree *at);
176
177    void detect_group_state(AP_tree *at, AWT_graphic_tree_group_state *state, AP_tree *skip_this_son);
178
179    int       group_tree(struct AP_tree *at, int mode, int color_group);
180    int       group_rest_tree(AP_tree *at, int mode, int color_group);
181    int       resort_tree(int mode, struct AP_tree *at = 0 );
182    GB_ERROR  create_group(AP_tree * at) __ATTR__USERESULT;
183    void      toggle_group(AP_tree * at);
184    void      jump(AP_tree *at, const char *name);
185    AP_tree  *search(AP_tree *root, const char *name);
186    GB_ERROR  load(GBDATA *gb_main, const char *name,AW_CL link_to_database, AW_CL insert_delete_cbs) __ATTR__USERESULT;
187    GB_ERROR  save(GBDATA *gb_main, const char *name,AW_CL cd1, AW_CL cd2) __ATTR__USERESULT;
188    int       check_update(GBDATA *gb_main); // reload tree if needed
189    void      update(GBDATA *gb_main);
190    void      set_tree_type(AP_tree_sort type);
191
192    double get_irs_tree_ruler_scale_factor() const { return irs_tree_ruler_scale_factor; }
193    void get_zombies_and_duplicates(int& zomb, int& dups) const { zomb = zombies; dups = duplicates; }
194};
195
196AWT_graphic_tree *NT_generate_tree( AW_root *root,GBDATA *gb_main );
197bool              AWT_show_remark_branch(AW_device *device, const char *remark_branch, bool is_leaf, AW_pos x, AW_pos y, AW_pos alignment, AW_bitset filteri, AW_CL cd1, AW_CL cd2);
198
199
200#else
201#error awt_dtree.hxx included twice
202#endif // AWT_DTREE_HXX
Note: See TracBrowser for help on using the repository browser.