source: tags/arb-6.0.6/DIST/di_view_matrix.hxx

Last change on this file was 11283, checked in by westram, 10 years ago
  • fixed some issues related to [11278]
    • added missing help
    • disable for non-experts
    • some logical fixes
      • do timer callback only (once) after need_recalc was set
      • checking 'auto calc' now instantly performs the calculation (if needed)
      • happens even automatically after ARB_DIST startup (if saved with properties)
      • if 'matrix autocalc' is checked, but neither 'tree autocalc' is checked nor matrix windows is shown (or would auto-popup) ⇒ only forget matrix
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : di_view_matrix.hxx                                //
4//                                                                 //
5//   Institute of Microbiology (Technical University Munich)       //
6//   http://www.arb-home.de/                                       //
7//                                                                 //
8// =============================================================== //
9
10#ifndef DI_VIEW_MATRIX_HXX
11#define DI_VIEW_MATRIX_HXX
12
13#ifndef AW_WINDOW_HXX
14#include <aw_window.hxx>
15#endif
16#ifndef DI_MATR_HXX
17#include "di_matr.hxx"
18#endif
19
20enum DI_gc {
21    DI_G_STANDARD,
22    DI_G_NAMES,
23    DI_G_RULER,
24    DI_G_RULER_DISPLAY,
25    DI_G_BELOW_DIST,
26    DI_G_ABOVE_DIST,
27    DI_G_LAST                   // must be last
28};
29
30class  AW_device;
31struct AW_event;
32class  DI_MATRIX;
33
34class MatrixDisplay {
35    int screen_width;             // dimensions of main screen
36    int screen_height;
37
38    int cell_width;               // width and height of one cell
39    int cell_height;
40    int cell_padd;                // space between cells
41
42    bool leadZero;                // show leading zero
43    int  digits;                  // digits after '.'
44    char format_string[50];       // for digits
45
46    int horiz_page_start;         // number of first element in this page
47    int vert_page_start;
48
49    int vert_last_view_start;     // last value of scrollbars
50    int horiz_last_view_start;
51
52    int total_cells_horiz;
53    int total_cells_vert;
54
55    int horiz_page_size;          // page size in cells (how many cells per page,
56    int vert_page_size;           // vertical and horizontal)
57
58    int off_dx;                   // offset values for scrollable area
59    int off_dy;
60
61    double min_view_dist;         // m[i][j]<min_view_dist -> ascii ; else small slider
62    double max_view_dist;         // m[i][j]>max_view_dist -> ascii ; else small slider
63
64    void set_scrollbar_steps(long width, long hight, long xinc, long yinc);
65    void scroll_to(int sxpos, int sypos);
66
67public:
68    enum UpdateFlag { // bits
69        NEED_NOTHING = 0,
70        NEED_CLEAR   = 1,
71        NEED_RESIZE  = 2,
72        NEED_SETUP   = 4,
73    };
74private:
75    UpdateFlag beforeUpdate;
76
77    void setup();
78    void adapt_to_canvas_size();                                 // call after resize main window
79    void draw();
80
81    enum LastAutoPop { UNKNOWN, UP, DOWN };
82    LastAutoPop lastautopop;
83
84    bool autopop(bool show) {
85        // handle automatic hide/show of matrix view
86        // - avoid popup if was not auto-hidden
87        if (!awm) return false;
88        if (!show) {
89            if (awm->is_shown()) {
90                awm->hide(); lastautopop = DOWN;
91            }
92        }
93        else if (!awm->is_shown() && lastautopop == DOWN) {
94            awm->show(); lastautopop = UP;
95        }
96        return awm->is_shown();
97    }
98
99public:
100    AW_window *awm;
101    AW_device *device;          // device to draw in
102
103    MatrixDisplay()
104        : screen_width(0),
105          screen_height(0),
106          cell_width(0),
107          cell_height(0),
108          cell_padd(0),
109          leadZero(false),
110          digits(0),
111          horiz_page_start(0),
112          vert_page_start(0),
113          vert_last_view_start(0),
114          horiz_last_view_start(0),
115          total_cells_horiz(0),
116          total_cells_vert(0),
117          horiz_page_size(0),
118          vert_page_size(0),
119          off_dx(0),
120          off_dy(0),
121          min_view_dist(0.0),
122          max_view_dist(0.0),
123          beforeUpdate(NEED_SETUP),
124          lastautopop(UNKNOWN),
125          awm(NULL),
126          device(NULL)
127    {}
128
129    DI_MATRIX *get_matrix() { return GLOBAL_MATRIX.get(); }
130
131    bool willShow() {
132        if (!awm) return false;
133        return awm->is_shown() || lastautopop == DOWN;
134    }
135
136    void monitor_vertical_scroll_cb(AW_window *);   // vertical and horizontal
137    void monitor_horizontal_scroll_cb(AW_window *); // scrollbar movements
138
139    void mark(UpdateFlag needed) { beforeUpdate = UpdateFlag(beforeUpdate|needed); }
140
141    void update_display() {
142        if (beforeUpdate&NEED_SETUP) setup();
143        if (beforeUpdate&NEED_RESIZE) adapt_to_canvas_size();
144        draw();
145        beforeUpdate = NEED_NOTHING;
146    }
147
148    // ******************** real public section *******************
149    void set_slider_min(double d) { min_view_dist = d; };
150    void set_slider_max(double d) { max_view_dist = d; };
151
152    void handle_move(AW_event& event);
153    void scroll_cells(int cells_x, int cells_y);
154};
155
156struct save_matrix_params;
157AW_window *DI_create_view_matrix_window(AW_root *awr, MatrixDisplay *disp, save_matrix_params *sparam);
158
159
160#else
161#error di_view_matrix.hxx included twice
162#endif // DI_VIEW_MATRIX_HXX
Note: See TracBrowser for help on using the repository browser.