Debian Codegraph @

source/filtwin.h

raw
1 // ----------------------------------------------------------------------------
2 //
3 // Copyright (C) 2003-2013 Fons Adriaensen <[email protected]>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // ----------------------------------------------------------------------------
19
20
21 #ifndef __FILTWIN_H
22 #define __FILTWIN_H
23
24
25 #include <clxclient.h>
26 #include "impdata.h"
27
28
29 class Dots
30 {
31 public:
32
33 int v2y (float v)
34 {
35 return _y0 - (int)(v * (_y0 - _y1) + 0.5f);
36 }
37
38 float y2v (int y)
39 {
40 if (y > _y0) return 0.0f;
41 if (y < _y1) return 1.0f;
42 return (float)(_y0 - y) / (_y0 - _y1);
43 }
44
45 unsigned long _col;
46 int _n;
47 int _y0;
48 int _y1;
49 float _v [33];
50 };
51
52
53 class Filtwin : public X_window, public X_callback
54 {
55 public:
56
57 Filtwin (X_window *parent, X_callback *callb, int xp, int yp, int xs, int ys);
58 ~Filtwin (void);
59
60 void resize (int xs, int ys);
61 X_window *bbwin (void) { return _bbwin; }
62
63 private:
64
65 enum { LSW = 40, RSW = 40, TPM = 5, BSH = 22, BWH = 25 };
66
67 virtual void handle_event (XEvent *);
68 virtual void handle_callb (int k, X_window *W, XEvent *E );
69
70 void expose (XExposeEvent *);
71 void bpress (XButtonEvent *);
72 void motion (XPointerMovedEvent *);
73 void brelse (XButtonEvent *);
74 void set_xscale (void);
75 void set_yscale (void);
76 void plot_xscale (void);
77 void plot_lscale (void);
78 void plot_rscale (void);
79 void update (void);
80 void redraw (void);
81 void plot_grid (X_draw *D);
82 void plot_data (X_draw *D);
83 void plot_dots (X_draw *D, Dots *P);
84 void finddot (int x);
85 void movedot (int y);
86
87 X_callback *_callb;
88 int _xs;
89 int _ys;
90 int _xd;
91 int _yd;
92 bool _show;
93 bool _wait;
94 X_window *_plotw;
95 X_window *_lswin;
96 X_window *_rswin;
97 X_window *_bswin;
98 X_window *_bbwin;
99 int _xticks [33];
100 int _yticks [9];
101 float _xunit;
102 float _yunit;
103 Dots _dots1;
104 Dots _dots2;
105 Dots *_dots;
106 int _idot;
107
108 static const char *_xtexts [33];
109 };
110
111
112 #endif