| 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 __EDITWIN_H |
| 22 |
#define __EDITWIN_H |
| 23 |
|
| 24 |
|
| 25 |
#include <clxclient.h> |
| 26 |
#include "impdata.h" |
| 27 |
|
| 28 |
|
| 29 |
class Mark |
| 30 |
{ |
| 31 |
public: |
| 32 |
|
| 33 |
enum { OFF, ON, LL, RR }; |
| 34 |
|
| 35 |
int _flags; |
| 36 |
int _posit; |
| 37 |
unsigned long _color; |
| 38 |
X_ibutton *_butt; |
| 39 |
}; |
| 40 |
|
| 41 |
|
| 42 |
class Editwin : public X_window, public X_callback |
| 43 |
{ |
| 44 |
public: |
| 45 |
|
| 46 |
Editwin (X_window *parent, X_callback *callb, int xp, int yp, int xs, int ys); |
| 47 |
~Editwin (void); |
| 48 |
|
| 49 |
enum { LOGMODE = 1, POWMODE = 2, OVERLAY = 4 }; |
| 50 |
|
| 51 |
X_window *bbwin (void) { return _bbwin; } |
| 52 |
X_window *rbwin (void) { return _rbwin; } |
| 53 |
|
| 54 |
void set_data (Impdata *I, int mask, int opts, float t0, float t1); |
| 55 |
void set_mask (int mask); |
| 56 |
int get_mask (void) { return _mask; } |
| 57 |
void set_xrange (float t0, float t1); |
| 58 |
void set_xzoom (int); |
| 59 |
void set_yzoom (int); |
| 60 |
void set_offs (int); |
| 61 |
void set_ind0 (int); |
| 62 |
void set_gain (float); |
| 63 |
void unset_all (void); |
| 64 |
void logmode (bool); |
| 65 |
void overlay (bool); |
| 66 |
void update (void); |
| 67 |
void resize (int xs, int ys); |
| 68 |
void clear_marks (void); |
| 69 |
int get_currmark (void) const { return _cmark; } |
| 70 |
int get_markpos (int i) const { return _marks [i]._flags ? _marks [i]._posit : INT_MIN; } |
| 71 |
void addtext (X_window *W, int xp, int yp, int xs, int ys, const char *text, int align); |
| 72 |
|
| 73 |
private: |
| 74 |
|
| 75 |
enum { LSW = 36, RPM = 6, RWW = 37, TPM = 5, BSH = 22, BWH = 21 }; |
| 76 |
enum { NZOOM = 22, NYTAB = 12, MOVEX = 1, ZOOMX = 2, ZOOMY = 3 }; |
| 77 |
enum { NTRACE = 12, NMARK = 2 }; |
| 78 |
enum { B_XMI, B_XPL, B_LIN, B_LOG, B_YPL, B_YMI, B_MK0, B_MK1 }; |
| 79 |
|
| 80 |
virtual void handle_event (XEvent *); |
| 81 |
virtual void handle_callb (int k, X_window *W, XEvent *E ); |
| 82 |
|
| 83 |
void expose (XExposeEvent *); |
| 84 |
void bpress (XButtonEvent *); |
| 85 |
void motion (XPointerMovedEvent *); |
| 86 |
void brelse (XButtonEvent *); |
| 87 |
void set_xscale (void); |
| 88 |
void set_yscale (void); |
| 89 |
void plot_xscale (void); |
| 90 |
void plot_yscale (void); |
| 91 |
void xscroll (int dx); |
| 92 |
void redraw (void); |
| 93 |
void plot_grid (X_draw *D); |
| 94 |
void plot_data (X_draw *D); |
| 95 |
void check_marks (void); |
| 96 |
void show_mark (int i, int x); |
| 97 |
void move_mark (int x); |
| 98 |
void goto_mark (int i); |
| 99 |
int find_mark (int x, int y); |
| 100 |
void togg_mark (int i); |
| 101 |
void curr_mark (int i); |
| 102 |
void plot_mark (X_draw *D, int i); |
| 103 |
|
| 104 |
X_callback *_callb; |
| 105 |
int _xs; |
| 106 |
int _ys; |
| 107 |
int _xd; |
| 108 |
int _yd; |
| 109 |
int _x0; |
| 110 |
int _x1; |
| 111 |
bool _show; |
| 112 |
bool _wait; |
| 113 |
X_window *_plotw; |
| 114 |
X_window *_lswin; |
| 115 |
X_window *_bswin; |
| 116 |
X_window *_rbwin; |
| 117 |
X_window *_bbwin; |
| 118 |
X_tbutton *_blin; |
| 119 |
X_tbutton *_blog; |
| 120 |
X_ibutton *_bxmi; |
| 121 |
X_ibutton *_bxpl; |
| 122 |
X_ibutton *_bypl; |
| 123 |
X_ibutton *_bymi; |
| 124 |
X_textip *_tmark; |
| 125 |
XSegment *_segm; |
| 126 |
Impdata *_data; |
| 127 |
int _rate; |
| 128 |
int _fst0; |
| 129 |
int _offs; |
| 130 |
int _ind0; |
| 131 |
float _gain; |
| 132 |
int _zoom; |
| 133 |
int _zind; |
| 134 |
int _xi0; |
| 135 |
int _xmm; |
| 136 |
double _xun; |
| 137 |
double _xsc; |
| 138 |
int _mask; |
| 139 |
int _opts; |
| 140 |
int _yref; |
| 141 |
int _ydel; |
| 142 |
int _ypos [NTRACE]; |
| 143 |
int _slin; |
| 144 |
int _slog; |
| 145 |
int _xdrag; |
| 146 |
int _mdrag; |
| 147 |
int _cmark; |
| 148 |
Mark _marks [NMARK]; |
| 149 |
|
| 150 |
static int _ztab [NZOOM]; |
| 151 |
static int _ytab [NYTAB]; |
| 152 |
}; |
| 153 |
|
| 154 |
|
| 155 |
#endif |