1 // osziview.cc
2 //
3 //    oszi - widget for gtk--
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 Version 2 as
7 //    published by the Free Software Foundation;
8 //
9 //    This program is distributed in the hope that it will be useful,
10 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //    GNU General Public License for more details.
13 //
14 //    You should have received a copy of the GNU General Public License
15 //    along with this program; if not, write to the Free Software
16 //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 //
18 //
19 
20 #include <gtkmm/drawingarea.h>
21 
22 
23 class OsziView : public Gtk::DrawingArea
24 {
25 // Q_OBJECT
26 public:
27 
28     OsziView();
29     ~OsziView();
30 
get_freq(void)31     double  get_freq      (void) const { return freq; }
32     void    setSampleData (const unsigned char *s, int num_samples);
33     void    setSampleData (const short *s, int num_samples);
34     void    setSampleFreq (double f);
35     void    setTrigFact   (double fact);
36     void    setAdaptive   (int active);
37     double  getTrigFact   ();
38     void    invalidate    ();
39     void    invalidate_sample ();
40 
41 protected:
42 
43     bool    on_expose_event(GdkEventExpose* p0);
44     void    on_realize();
45 //    void    draw_default_impl();
46 //    void    draw_impl(GdkRectangle* p0);
47 
48 private:
49 
50     enum SampFmt { U8, S16_LE };
51 
52     short int *      samp;
53     GByteArray *     samp_byte_array;
54     int              sampnr;
55     double           sampfreq;
56     int              wscr, hscr, xscr, yscr;
57     double           trigfact;
58     Glib::RefPtr<Gdk::GC> i_GC;
59     Gdk::Color       i_col_bg;
60     Gdk::Color       i_col_trig;
61     Gdk::Color       i_col_mark;
62     Gdk::Color       i_col_data;
63     Gdk::Color       i_col_scale;
64     Gdk::Color       i_col_ticks;
65     Gdk::Color       i_col_zero;
66     enum SampFmt     i_sampfmt;
67     int              i_minsamp;
68     int              i_maxsamp;
69     int              i_divisor;
70     int              i_adaptive_scale;
71     int              startpoint;
72     int              endpoint;
73     int              trigger_a;
74     int              trigger_b;
75     double           freq;
76 
77     void    paint_sample  ();
78     void    paint_marks   ();
79     void    paint_scale   ();
80 
81     void  calc_minmax(void);
82     void  calc_freq(void);
83     void  recalc(void);
84     void  copy_sample_data(const void *ptr, int data_size);
85 };
86