videoscope tweaks, add scope overlay grid (andrea), hw probe fix for sw fallback
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / recordscopes.C
1 /*
2  * CINELERRA
3  * Copyright (C) 1997-2011 Adam Williams <broadcast at earthling dot net>
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 2 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, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  *
19  */
20
21
22
23 #include "bctheme.h"
24 #include "bccolors.h"
25 #include "language.h"
26 #include "mainsession.h"
27 #include "mutex.h"
28 #include "preferences.h"
29 #include "recordmonitor.h"
30 #include "recordscopes.h"
31 #include "theme.h"
32
33 RecordScopeThread::RecordScopeThread(MWindow *mwindow, RecordMonitor *record_monitor)
34  : BC_DialogThread()
35 {
36         this->mwindow = mwindow;
37         this->record_monitor = record_monitor;
38         scope_gui = 0;
39         gui_lock = new Mutex("RecordScopeThread::gui_lock");
40 }
41
42 RecordScopeThread::~RecordScopeThread()
43 {
44         close_window();
45         delete gui_lock;
46 }
47
48 void RecordScopeThread::handle_close_event(int result)
49 {
50         scope_gui = 0;
51 }
52 void RecordScopeThread::handle_done_event(int result)
53 {
54         gui_lock->lock("RecordScopeThread::handle_done_event");
55         scope_gui = 0;
56         gui_lock->unlock();
57
58         record_monitor->window->lock_window("RecordScopeThread::handle_done_event");
59         record_monitor->window->scope_toggle->update(0);
60         record_monitor->window->unlock_window();
61 }
62
63 BC_Window* RecordScopeThread::new_gui()
64 {
65         RecordScopeGUI *gui = new RecordScopeGUI(mwindow, record_monitor);
66         gui->create_objects();
67         scope_gui = gui;
68         return gui;
69 }
70
71 void RecordScopeThread::process(VFrame *output_frame)
72 {
73         if(record_monitor->scope_thread)
74         {
75                 record_monitor->scope_thread->gui_lock->lock("RecordScopeThread::process");
76                 if(record_monitor->scope_thread->scope_gui)
77                 {
78                         RecordScopeGUI *gui = record_monitor->scope_thread->scope_gui;
79                         gui->process(output_frame);
80                 }
81
82
83
84                 record_monitor->scope_thread->gui_lock->unlock();
85         }
86 }
87
88
89
90
91
92
93
94
95
96 RecordScopeGUI::RecordScopeGUI(MWindow *mwindow,
97         RecordMonitor *record_monitor)
98  : ScopeGUI(mwindow->theme,
99         mwindow->session->scope_x,
100         mwindow->session->scope_y,
101         mwindow->session->scope_w,
102         mwindow->session->scope_h,
103         mwindow->preferences->processors)
104 {
105         this->mwindow = mwindow;
106         this->record_monitor = record_monitor;
107 }
108
109 RecordScopeGUI::~RecordScopeGUI()
110 {
111 }
112
113 void RecordScopeGUI::create_objects()
114 {
115         use_hist = mwindow->session->use_hist;
116         use_wave = mwindow->session->use_wave;
117         use_vector = mwindow->session->use_vector;
118         use_hist_parade = mwindow->session->use_hist_parade;
119         use_wave_parade = mwindow->session->use_wave_parade;
120         use_wave_gain = mwindow->session->use_wave_gain;
121         use_vect_gain = mwindow->session->use_vect_gain;
122         use_smooth = mwindow->session->use_smooth;
123         use_graticule = mwindow->session->use_graticule;
124         ScopeGUI::create_objects();
125 }
126
127
128 void RecordScopeGUI::toggle_event()
129 {
130         mwindow->session->use_hist = use_hist;
131         mwindow->session->use_wave = use_wave;
132         mwindow->session->use_vector = use_vector;
133         mwindow->session->use_hist_parade = use_hist_parade;
134         mwindow->session->use_wave_parade = use_wave_parade;
135         mwindow->session->use_wave_gain = use_wave_gain;
136         mwindow->session->use_vect_gain = use_vect_gain;
137         mwindow->session->use_smooth = use_smooth;
138         mwindow->session->use_graticule = use_graticule;
139 }
140
141 int RecordScopeGUI::translation_event()
142 {
143         ScopeGUI::translation_event();
144         mwindow->session->scope_x = get_x();
145         mwindow->session->scope_y = get_y();
146         return 0;
147 }
148
149 int RecordScopeGUI::resize_event(int w, int h)
150 {
151         ScopeGUI::resize_event(w, h);
152         mwindow->session->scope_w = w;
153         mwindow->session->scope_h = h;
154         return 0;
155 }
156
157
158
159
160
161 ScopeEnable::ScopeEnable(MWindow *mwindow, RecordMonitor *record_monitor, int x, int y)
162  : BC_Toggle(x,
163         y,
164         mwindow->theme ? mwindow->theme->get_image_set("scope_toggle") : 0,
165         mwindow->session->record_scope)
166 {
167         this->record_monitor = record_monitor;
168         this->mwindow = mwindow;
169         set_tooltip(_("View scope"));
170 }
171
172 ScopeEnable::~ScopeEnable()
173 {
174 }
175
176
177 int ScopeEnable::handle_event()
178 {
179         unlock_window();
180         mwindow->session->record_scope = get_value();
181
182         if(mwindow->session->record_scope)
183         {
184                 record_monitor->scope_thread->start();
185         }
186         else
187         {
188                 record_monitor->scope_thread->close_window();
189         }
190
191         lock_window("ScopeEnable::handle_event");
192         return 1;
193 }
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209