add BC_SCALE env var for hi def monitors, cleanup theme data
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / denoiseseltempavg / seltempavgwindow.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #include "bcdisplayinfo.h"
23 #include "language.h"
24 #include "seltempavgwindow.h"
25
26
27
28 #define MAX_FRAMES 1024
29
30
31 SelTempAvgWindow::SelTempAvgWindow(SelTempAvgMain *client)
32  : PluginClientWindow(client,
33         xS(310),
34         yS(540),
35         xS(300),
36         yS(540),
37         0)
38 {
39         this->client = client;
40 }
41
42 SelTempAvgWindow::~SelTempAvgWindow()
43 {
44 }
45
46 void SelTempAvgWindow::create_objects()
47 {
48         int x1 = 10, x2 = 40, x3 = 80, x4 = 175, x5 = 260, y = 10;
49
50         add_tool(new BC_Title(x1, y, _("Frames to average")));
51         y += 20;
52         add_tool(total_frames = new SelTempAvgSlider(client, x1, y));
53         y += 20;
54
55         add_tool(new BC_Title(x1, y, _("Use Method:")));
56         y += 20;
57
58         add_tool(method_none = new SelTempAvgMethodRadial(client, this, x1, y, SelTempAvgConfig::METHOD_NONE, _("None ")));
59         y += 20;
60
61         add_tool(method_seltempavg = new SelTempAvgMethodRadial(client, this, x1, y, SelTempAvgConfig::METHOD_SELTEMPAVG, _("Selective Temporal Averaging: ")));
62         y += 25;
63
64         add_tool(new BC_Title(x3, y, _("Av. Thres.")));
65         add_tool(new BC_Title(x4, y, _("S.D. Thres.")));
66         add_tool(new BC_Title(x5, y, _("Mask")));
67         y += 25;
68
69         add_tool(new BC_Title(x2, y, _("R / Y")));
70         add_tool(avg_threshold_RY = new SelTempAvgThreshSlider(client, x3, y, AVG_RY,client->config.avg_threshold_RY));
71         add_tool(std_threshold_RY = new SelTempAvgThreshSlider(client, x4, y, STD_RY,client->config.std_threshold_RY));
72         add_tool(mask_RY = new SelTempAvgMask(client, x5, y, MASK_RY, client->config.mask_RY));
73
74         y += 25;
75         add_tool(new BC_Title(x2, y, _("G / U")));
76         add_tool(avg_threshold_GU = new SelTempAvgThreshSlider(client, x3, y, AVG_GU,client->config.avg_threshold_GU));
77         add_tool(std_threshold_GU = new SelTempAvgThreshSlider(client, x4, y, STD_GU,client->config.std_threshold_GU));
78         add_tool(mask_GU = new SelTempAvgMask(client, x5, y, MASK_GU,client->config.mask_GU));
79
80         y += 25;
81         add_tool(new BC_Title(x2, y, _("B / V")));
82         add_tool(avg_threshold_BV = new SelTempAvgThreshSlider(client, x3, y, AVG_BV,client->config.avg_threshold_BV));
83         add_tool(std_threshold_BV = new SelTempAvgThreshSlider(client, x4, y, STD_BV,client->config.std_threshold_BV));
84         add_tool(mask_BV = new SelTempAvgMask(client, x5, y, MASK_BV,client->config.mask_BV));
85
86         y += 30;
87         add_tool(method_average = new SelTempAvgMethodRadial(client, this, x1, y, SelTempAvgConfig::METHOD_AVERAGE, _("Average")));
88         y += 20;
89         add_tool(method_stddev = new SelTempAvgMethodRadial(client, this, x1, y, SelTempAvgConfig::METHOD_STDDEV, _("Standard Deviation")));
90
91         y += 35;
92         add_tool(new BC_Title(x1, y, _("First frame in average:")));
93         y += 20;
94         add_tool(offset_fixed = new SelTempAvgOffsetRadial(client, this, x1, y, SelTempAvgConfig::OFFSETMODE_FIXED, _("Fixed offset: ")));
95         add_tool(offset_fixed_value = new SelTempAvgOffsetValue(client, x4, y));
96         y += 25;
97
98         add_tool(offset_restartmarker = new SelTempAvgOffsetRadial(client, this, x1, y, SelTempAvgConfig::OFFSETMODE_RESTARTMARKERSYS, _("Restart marker system:")));
99         add_tool(offset_restartmarker_pos = new BC_TextBox(x4+20, y, 100, 1, ""));
100         offset_restartmarker_pos->disable();
101         y += 20;
102         add_tool(offset_restartmarker_keyframe = new SelTempAvgStartKeyframe(client, x2 + 10, y));
103
104         y += 35;
105
106         add_tool(new BC_Title(x1, y, _("Other Options:")));
107         y += 20;
108         add_tool(paranoid = new SelTempAvgParanoid(client, x1, y));
109         y += 25;
110         add_tool(no_subtract = new SelTempAvgNoSubtract(client, x1, y));
111         y += 30;
112         add_tool(new BC_Title(x2, y, _("Gain:")));
113         add_tool(gain = new SelTempAvgGainValue(client, x3, y));
114
115         show_window();
116         flush();
117 }
118
119
120
121
122
123 SelTempAvgThreshSlider::SelTempAvgThreshSlider(SelTempAvgMain *client, int x, int y, int id, float currentval)
124   : BC_TextBox(x,y, 80, 1, currentval)
125 {
126   //    float val;
127   //    int   ival;
128         this->type = id;
129         this->client = client;
130 }
131 SelTempAvgThreshSlider::~SelTempAvgThreshSlider()
132 {
133 }
134 int SelTempAvgThreshSlider::handle_event()
135 {
136         float val = atof(get_text());
137
138         if(val < 0) val = 0;
139
140         switch (type) {
141         case AVG_RY:
142                 client->config.avg_threshold_RY = val;
143                 break;
144         case AVG_GU:
145                 client->config.avg_threshold_GU = val;
146                 break;
147         case AVG_BV:
148                 client->config.avg_threshold_BV = val;
149                 break;
150         case STD_RY:
151                 client->config.std_threshold_RY = val;
152                 break;
153         case STD_GU:
154                 client->config.std_threshold_GU = val;
155                 break;
156         case STD_BV:
157                 client->config.std_threshold_BV = val;
158                 break;
159         }
160
161         client->send_configure_change();
162         return 1;
163 }
164
165
166 SelTempAvgOffsetValue::SelTempAvgOffsetValue(SelTempAvgMain *client, int x, int y)
167   : BC_TextBox(x,y, 80, 1, client->config.offset_fixed_value)
168 {
169         this->client = client;
170 }
171 SelTempAvgOffsetValue::~SelTempAvgOffsetValue()
172 {
173 }
174 int SelTempAvgOffsetValue::handle_event()
175 {
176         int val = atoi(get_text());
177
178         client->config.offset_fixed_value = val;
179         client->send_configure_change();
180         return 1;
181 }
182
183
184 SelTempAvgGainValue::SelTempAvgGainValue(SelTempAvgMain *client, int x, int y)
185   : BC_TextBox(x,y, 80, 1, client->config.gain)
186 {
187         this->client = client;
188 }
189 SelTempAvgGainValue::~SelTempAvgGainValue()
190 {
191 }
192 int SelTempAvgGainValue::handle_event()
193 {
194         float val = atof(get_text());
195
196         if(val < 0) val = 0;
197         client->config.gain = val;
198         client->send_configure_change();
199         return 1;
200 }
201
202
203
204
205
206 SelTempAvgSlider::SelTempAvgSlider(SelTempAvgMain *client, int x, int y)
207  : BC_ISlider(x, y, 0, 190, 200, 1, MAX_FRAMES, client->config.frames)
208 {
209         this->client = client;
210 }
211 SelTempAvgSlider::~SelTempAvgSlider()
212 {
213 }
214 int SelTempAvgSlider::handle_event()
215 {
216         int result = get_value();
217         if(result < 1) result = 1;
218         client->config.frames = result;
219         client->send_configure_change();
220         return 1;
221 }
222
223
224
225 SelTempAvgOffsetRadial::SelTempAvgOffsetRadial(SelTempAvgMain *client, SelTempAvgWindow *gui, int x, int y, int type, char *caption)
226  : BC_Radial(x, y, client->config.offsetmode == type, caption)
227 {
228         this->client = client;
229         this->gui = gui;
230         this->type = type;
231 }
232 int SelTempAvgOffsetRadial::handle_event()
233 {
234         int result = get_value();
235         client->config.offsetmode = result;
236
237         gui->offset_fixed->update(client->config.offsetmode == SelTempAvgConfig::OFFSETMODE_FIXED);
238         gui->offset_restartmarker->update(client->config.offsetmode == SelTempAvgConfig::OFFSETMODE_RESTARTMARKERSYS);
239
240         client->send_configure_change();
241         return 1;
242 }
243
244
245
246 SelTempAvgMethodRadial::SelTempAvgMethodRadial(SelTempAvgMain *client,
247         SelTempAvgWindow *gui, int x, int y, int type, char *caption)
248  : BC_Radial(x,
249         y,
250         client->config.method == type,
251         caption)
252 {
253         this->client = client;
254         this->gui = gui;
255         this->type = type;
256 }
257 int SelTempAvgMethodRadial::handle_event()
258 {
259         int result = get_value();
260         client->config.method = result;
261
262         gui->method_none->update(client->config.method       == SelTempAvgConfig::METHOD_NONE);
263         gui->method_seltempavg->update(client->config.method == SelTempAvgConfig::METHOD_SELTEMPAVG);
264         gui->method_average->update(client->config.method    == SelTempAvgConfig::METHOD_AVERAGE);
265         gui->method_stddev->update(client->config.method     == SelTempAvgConfig::METHOD_STDDEV);
266
267         client->send_configure_change();
268         return 1;
269 }
270
271
272 SelTempAvgParanoid::SelTempAvgParanoid(SelTempAvgMain *client, int x, int y)
273  : BC_CheckBox(x, y, client->config.paranoid, _("Reprocess frame again"))
274 {
275         this->client = client;
276 }
277 int SelTempAvgParanoid::handle_event()
278 {
279         int result = get_value();
280         client->config.paranoid = result;
281         client->send_configure_change();
282         return 1;
283 }
284
285
286 SelTempAvgNoSubtract::SelTempAvgNoSubtract(SelTempAvgMain *client, int x, int y)
287  : BC_CheckBox(x, y, client->config.nosubtract, _("Disable subtraction"))
288 {
289         this->client = client;
290 }
291 int SelTempAvgNoSubtract::handle_event()
292 {
293         int result = get_value();
294         client->config.nosubtract = result;
295         client->send_configure_change();
296         return 1;
297 }
298
299 SelTempAvgMask::SelTempAvgMask(SelTempAvgMain *client, int x, int y, int type, int val)
300  : BC_CheckBox(x, y, val, "")
301 {
302         this->client = client;
303         this->type = type;
304 }
305 int SelTempAvgMask::handle_event()
306 {
307         int result = get_value();
308         switch (type) {
309         case MASK_RY:
310                 client->config.mask_RY = result;
311                 break;
312         case MASK_GU:
313                 client->config.mask_GU = result;
314                 break;
315         case MASK_BV:
316                 client->config.mask_BV = result;
317                 break;
318         }
319         client->send_configure_change();
320         return 1;
321 }
322
323
324
325 SelTempAvgStartKeyframe::SelTempAvgStartKeyframe(SelTempAvgMain *client, int x, int y)
326  : BC_CheckBox(x, y, client->config.nosubtract, _("This Frame is a start of a section"))
327 {
328         this->client = client;
329 }
330 int SelTempAvgStartKeyframe::handle_event()
331 {
332         int result = get_value();
333         client->config.offset_restartmarker_keyframe = result;
334         client->send_configure_change();
335         return 1;
336 }