initial commit
[goodguy/history.git] / cinelerra-5.0 / 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 "cicolors.h"
24 #include "language.h"
25 #include "mainsession.h"
26 #include "mutex.h"
27 #include "preferences.h"
28 #include "recordmonitor.h"
29 #include "recordscopes.h"
30
31 RecordScopeThread::RecordScopeThread(MWindow *mwindow, RecordMonitor *record_monitor)
32  : BC_DialogThread()
33 {
34         this->mwindow = mwindow;
35         this->record_monitor = record_monitor;
36         scope_gui = 0;
37         gui_lock = new Mutex("RecordScopeThread::gui_lock");
38 }
39
40 RecordScopeThread::~RecordScopeThread()
41 {
42         delete gui_lock;
43 }
44
45 void RecordScopeThread::handle_done_event(int result)
46 {
47         gui_lock->lock("RecordScopeThread::handle_done_event");
48         scope_gui = 0;
49         gui_lock->unlock();
50         
51         record_monitor->window->lock_window("RecordScopeThread::handle_done_event");
52         record_monitor->window->scope_toggle->update(0);
53         record_monitor->window->unlock_window();
54 }
55
56 BC_Window* RecordScopeThread::new_gui()
57 {
58         RecordScopeGUI *gui = new RecordScopeGUI(mwindow, record_monitor);
59         gui->create_objects();
60         scope_gui = gui;
61         return gui;
62 }
63
64 void RecordScopeThread::process(VFrame *output_frame)
65 {
66         if(record_monitor->scope_thread)
67         {
68                 record_monitor->scope_thread->gui_lock->lock("RecordScopeThread::process");
69                 if(record_monitor->scope_thread->scope_gui)
70                 {
71                         RecordScopeGUI *gui = record_monitor->scope_thread->scope_gui;
72                         gui->process(output_frame);
73                 }
74
75
76
77                 record_monitor->scope_thread->gui_lock->unlock();
78         }
79 }
80
81
82
83
84
85
86
87
88
89 RecordScopeGUI::RecordScopeGUI(MWindow *mwindow, 
90         RecordMonitor *record_monitor)
91  : ScopeGUI(mwindow->theme, 
92         mwindow->session->scope_x, 
93         mwindow->session->scope_y, 
94         mwindow->session->scope_w, 
95         mwindow->session->scope_h,
96         mwindow->preferences->processors)
97 {
98         this->mwindow = mwindow;
99         this->record_monitor = record_monitor;
100 }
101
102 RecordScopeGUI::~RecordScopeGUI()
103 {
104 }
105
106 void RecordScopeGUI::create_objects()
107 {
108         use_hist = mwindow->session->use_hist;
109         use_wave = mwindow->session->use_wave;
110         use_vector = mwindow->session->use_vector;
111         use_hist_parade = mwindow->session->use_hist_parade;
112         use_wave_parade = mwindow->session->use_wave_parade;
113         ScopeGUI::create_objects();
114 }
115
116
117 void RecordScopeGUI::toggle_event()
118 {
119         mwindow->session->use_hist = use_hist;
120         mwindow->session->use_wave = use_wave;
121         mwindow->session->use_vector = use_vector;
122         mwindow->session->use_hist_parade = use_hist_parade;
123         mwindow->session->use_wave_parade = use_wave_parade;
124 }
125
126 int RecordScopeGUI::translation_event()
127 {
128         ScopeGUI::translation_event();
129         mwindow->session->scope_x = get_x();
130         mwindow->session->scope_y = get_y();
131         return 0;
132 }
133
134 int RecordScopeGUI::resize_event(int w, int h)
135 {
136         ScopeGUI::resize_event(w, h);
137         mwindow->session->scope_w = w;
138         mwindow->session->scope_h = h;
139         return 0;
140 }
141
142
143
144
145
146 ScopeEnable::ScopeEnable(MWindow *mwindow, RecordMonitor *record_monitor, int x, int y)
147  : BC_Toggle(x, 
148         y, 
149         mwindow->theme ? mwindow->theme->get_image_set("scope_toggle") : 0,
150         mwindow->session->record_scope)
151 {
152         this->record_monitor = record_monitor;
153         this->mwindow = mwindow;
154         set_tooltip(_("View scope"));
155 }
156
157 ScopeEnable::~ScopeEnable()
158 {
159 }
160
161
162 int ScopeEnable::handle_event()
163 {
164         unlock_window();
165         mwindow->session->record_scope = get_value();
166
167         if(mwindow->session->record_scope)
168         {
169                 record_monitor->scope_thread->start();
170         }
171         else
172         {
173                 record_monitor->scope_thread->close_window();
174         }
175
176         lock_window("ScopeEnable::handle_event");
177         return 1;
178 }
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194