00001 #include "bcdisplayinfo.h"
00002 #include "language.h"
00003 #include "seltempavgwindow.h"
00004
00005 PLUGIN_THREAD_OBJECT(SelTempAvgMain, SelTempAvgThread, SelTempAvgWindow)
00006
00007
00008 #define MAX_FRAMES 1024
00009
00010
00011 SelTempAvgWindow::SelTempAvgWindow(SelTempAvgMain *client, int x, int y)
00012 : BC_Window(client->gui_string,
00013 x,
00014 y,
00015 310,
00016 540,
00017 300,
00018 540,
00019 0,
00020 0,
00021 1)
00022 {
00023 this->client = client;
00024 }
00025
00026 SelTempAvgWindow::~SelTempAvgWindow()
00027 {
00028 }
00029
00030 int SelTempAvgWindow::create_objects()
00031 {
00032 int x1 = 10, x2 = 40, x3 = 80, x4 = 175, x5 = 260, y = 10;
00033
00034 add_tool(new BC_Title(x1, y, _("Frames to average")));
00035 y += 20;
00036 add_tool(total_frames = new SelTempAvgSlider(client, x1, y));
00037 y += 20;
00038
00039 add_tool(new BC_Title(x1, y, _("Use Method:")));
00040 y += 20;
00041
00042 add_tool(method_none = new SelTempAvgMethodRadial(client, this, x1, y, SelTempAvgConfig::METHOD_NONE, _("None ")));
00043 y += 20;
00044
00045 add_tool(method_seltempavg = new SelTempAvgMethodRadial(client, this, x1, y, SelTempAvgConfig::METHOD_SELTEMPAVG, _("Selective Temporal Averaging: ")));
00046 y += 25;
00047
00048 add_tool(new BC_Title(x3, y, _("Av. Thres.")));
00049 add_tool(new BC_Title(x4, y, _("S.D. Thres.")));
00050 add_tool(new BC_Title(x5, y, _("Mask")));
00051 y += 25;
00052
00053 add_tool(new BC_Title(x2, y, _("R / Y")));
00054 add_tool(avg_threshold_RY = new SelTempAvgThreshSlider(client, x3, y, AVG_RY,client->config.avg_threshold_RY));
00055 add_tool(std_threshold_RY = new SelTempAvgThreshSlider(client, x4, y, STD_RY,client->config.std_threshold_RY));
00056 add_tool(mask_RY = new SelTempAvgMask(client, x5, y, MASK_RY, client->config.mask_RY));
00057
00058 y += 25;
00059 add_tool(new BC_Title(x2, y, _("G / U")));
00060 add_tool(avg_threshold_GU = new SelTempAvgThreshSlider(client, x3, y, AVG_GU,client->config.avg_threshold_GU));
00061 add_tool(std_threshold_GU = new SelTempAvgThreshSlider(client, x4, y, STD_GU,client->config.std_threshold_GU));
00062 add_tool(mask_GU = new SelTempAvgMask(client, x5, y, MASK_GU,client->config.mask_GU));
00063
00064 y += 25;
00065 add_tool(new BC_Title(x2, y, _("B / V")));
00066 add_tool(avg_threshold_BV = new SelTempAvgThreshSlider(client, x3, y, AVG_BV,client->config.avg_threshold_BV));
00067 add_tool(std_threshold_BV = new SelTempAvgThreshSlider(client, x4, y, STD_BV,client->config.std_threshold_BV));
00068 add_tool(mask_BV = new SelTempAvgMask(client, x5, y, MASK_BV,client->config.mask_BV));
00069
00070 y += 30;
00071 add_tool(method_average = new SelTempAvgMethodRadial(client, this, x1, y, SelTempAvgConfig::METHOD_AVERAGE, _("Average")));
00072 y += 20;
00073 add_tool(method_stddev = new SelTempAvgMethodRadial(client, this, x1, y, SelTempAvgConfig::METHOD_STDDEV, _("Standard Deviation")));
00074
00075 y += 35;
00076 add_tool(new BC_Title(x1, y, _("First frame in average:")));
00077 y += 20;
00078 add_tool(offset_fixed = new SelTempAvgOffsetRadial(client, this, x1, y, SelTempAvgConfig::OFFSETMODE_FIXED, _("Fixed offset: ")));
00079 add_tool(offset_fixed_value = new SelTempAvgOffsetValue(client, x4, y));
00080 y += 25;
00081
00082 add_tool(offset_restartmarker = new SelTempAvgOffsetRadial(client, this, x1, y, SelTempAvgConfig::OFFSETMODE_RESTARTMARKERSYS, _("Restart marker system:")));
00083 add_tool(offset_restartmarker_pos = new BC_TextBox(x4+20, y, 100, 1, ""));
00084 offset_restartmarker_pos->disable();
00085 y += 20;
00086 add_tool(offset_restartmarker_keyframe = new SelTempAvgStartKeyframe(client, x2 + 10, y));
00087
00088 y += 35;
00089
00090 add_tool(new BC_Title(x1, y, _("Other Options:")));
00091 y += 20;
00092 add_tool(paranoid = new SelTempAvgParanoid(client, x1, y));
00093 y += 25;
00094 add_tool(no_subtract = new SelTempAvgNoSubtract(client, x1, y));
00095 y += 30;
00096 add_tool(new BC_Title(x2, y, _("Gain:")));
00097 add_tool(gain = new SelTempAvgGainValue(client, x3, y));
00098
00099 show_window();
00100 flush();
00101 return 0;
00102 }
00103
00104 WINDOW_CLOSE_EVENT(SelTempAvgWindow)
00105
00106
00107
00108
00109 SelTempAvgThreshSlider::SelTempAvgThreshSlider(SelTempAvgMain *client, int x, int y, int id, float currentval)
00110 : BC_TextBox(x,y, 80, 1, currentval)
00111 {
00112
00113
00114 this->type = id;
00115 this->client = client;
00116 }
00117 SelTempAvgThreshSlider::~SelTempAvgThreshSlider()
00118 {
00119 }
00120 int SelTempAvgThreshSlider::handle_event()
00121 {
00122 float val = atof(get_text());
00123
00124 if(val < 0) val = 0;
00125
00126 switch (type) {
00127 case AVG_RY:
00128 client->config.avg_threshold_RY = val;
00129 break;
00130 case AVG_GU:
00131 client->config.avg_threshold_GU = val;
00132 break;
00133 case AVG_BV:
00134 client->config.avg_threshold_BV = val;
00135 break;
00136 case STD_RY:
00137 client->config.std_threshold_RY = val;
00138 break;
00139 case STD_GU:
00140 client->config.std_threshold_GU = val;
00141 break;
00142 case STD_BV:
00143 client->config.std_threshold_BV = val;
00144 break;
00145 }
00146
00147 client->send_configure_change();
00148 return 1;
00149 }
00150
00151
00152 SelTempAvgOffsetValue::SelTempAvgOffsetValue(SelTempAvgMain *client, int x, int y)
00153 : BC_TextBox(x,y, 80, 1, client->config.offset_fixed_value)
00154 {
00155 this->client = client;
00156 }
00157 SelTempAvgOffsetValue::~SelTempAvgOffsetValue()
00158 {
00159 }
00160 int SelTempAvgOffsetValue::handle_event()
00161 {
00162 int val = atoi(get_text());
00163
00164 client->config.offset_fixed_value = val;
00165 client->send_configure_change();
00166 return 1;
00167 }
00168
00169
00170 SelTempAvgGainValue::SelTempAvgGainValue(SelTempAvgMain *client, int x, int y)
00171 : BC_TextBox(x,y, 80, 1, client->config.gain)
00172 {
00173 this->client = client;
00174 }
00175 SelTempAvgGainValue::~SelTempAvgGainValue()
00176 {
00177 }
00178 int SelTempAvgGainValue::handle_event()
00179 {
00180 float val = atof(get_text());
00181
00182 if(val < 0) val = 0;
00183 client->config.gain = val;
00184 client->send_configure_change();
00185 return 1;
00186 }
00187
00188
00189
00190
00191
00192 SelTempAvgSlider::SelTempAvgSlider(SelTempAvgMain *client, int x, int y)
00193 : BC_ISlider(x,
00194 y,
00195 0,
00196 190,
00197 200,
00198 1,
00199 MAX_FRAMES,
00200 client->config.frames)
00201 {
00202 this->client = client;
00203 }
00204 SelTempAvgSlider::~SelTempAvgSlider()
00205 {
00206 }
00207 int SelTempAvgSlider::handle_event()
00208 {
00209 int result = get_value();
00210 if(result < 1) result = 1;
00211 client->config.frames = result;
00212 client->send_configure_change();
00213 return 1;
00214 }
00215
00216
00217
00218 SelTempAvgOffsetRadial::SelTempAvgOffsetRadial(SelTempAvgMain *client, SelTempAvgWindow *gui, int x, int y, int type, char *caption)
00219 : BC_Radial(x,
00220 y,
00221 client->config.offsetmode == type,
00222 caption)
00223 {
00224 this->client = client;
00225 this->gui = gui;
00226 this->type = type;
00227 }
00228 int SelTempAvgOffsetRadial::handle_event()
00229 {
00230 int result = get_value();
00231 client->config.offsetmode = type;
00232
00233 gui->offset_fixed->update(client->config.offsetmode == SelTempAvgConfig::OFFSETMODE_FIXED);
00234 gui->offset_restartmarker->update(client->config.offsetmode == SelTempAvgConfig::OFFSETMODE_RESTARTMARKERSYS);
00235
00236 client->send_configure_change();
00237 return 1;
00238 }
00239
00240
00241
00242 SelTempAvgMethodRadial::SelTempAvgMethodRadial(SelTempAvgMain *client, SelTempAvgWindow *gui, int x, int y, int type, char *caption)
00243 : BC_Radial(x,
00244 y,
00245 client->config.method == type,
00246 caption)
00247 {
00248 this->client = client;
00249 this->gui = gui;
00250 this->type = type;
00251 }
00252 int SelTempAvgMethodRadial::handle_event()
00253 {
00254 int result = get_value();
00255 client->config.method = type;
00256
00257 gui->method_none->update(client->config.method == SelTempAvgConfig::METHOD_NONE);
00258 gui->method_seltempavg->update(client->config.method == SelTempAvgConfig::METHOD_SELTEMPAVG);
00259 gui->method_average->update(client->config.method == SelTempAvgConfig::METHOD_AVERAGE);
00260 gui->method_stddev->update(client->config.method == SelTempAvgConfig::METHOD_STDDEV);
00261
00262 client->send_configure_change();
00263 return 1;
00264 }
00265
00266
00267 SelTempAvgParanoid::SelTempAvgParanoid(SelTempAvgMain *client, int x, int y)
00268 : BC_CheckBox(x,
00269 y,
00270 client->config.paranoid,
00271 _("Reprocess frame again"))
00272 {
00273 this->client = client;
00274 }
00275 int SelTempAvgParanoid::handle_event()
00276 {
00277 int result = get_value();
00278 client->config.paranoid = result;
00279 client->send_configure_change();
00280 return 1;
00281 }
00282
00283
00284 SelTempAvgNoSubtract::SelTempAvgNoSubtract(SelTempAvgMain *client, int x, int y)
00285 : BC_CheckBox(x,
00286 y,
00287 client->config.nosubtract,
00288 _("Disable subtraction"))
00289 {
00290 this->client = client;
00291 }
00292 int SelTempAvgNoSubtract::handle_event()
00293 {
00294 int result = get_value();
00295 client->config.nosubtract = result;
00296 client->send_configure_change();
00297 return 1;
00298 }
00299
00300 SelTempAvgMask::SelTempAvgMask(SelTempAvgMain *client, int x, int y, int type, int val)
00301 : BC_CheckBox(x,
00302 y,
00303 val,
00304 "")
00305 {
00306 this->client = client;
00307 this->type = type;
00308 }
00309 int SelTempAvgMask::handle_event()
00310 {
00311 int result = get_value();
00312 switch (type) {
00313 case MASK_RY:
00314 client->config.mask_RY = result;
00315 break;
00316 case MASK_GU:
00317 client->config.mask_GU = result;
00318 break;
00319 case MASK_BV:
00320 client->config.mask_BV = result;
00321 break;
00322 }
00323 client->send_configure_change();
00324 return 1;
00325 }
00326
00327
00328
00329 SelTempAvgStartKeyframe::SelTempAvgStartKeyframe(SelTempAvgMain *client, int x, int y)
00330 : BC_CheckBox(x,
00331 y,
00332 client->config.nosubtract,
00333 _("This Frame is a start of a section"))
00334 {
00335 this->client = client;
00336 }
00337 int SelTempAvgStartKeyframe::handle_event()
00338 {
00339 int result = get_value();
00340 client->config.offset_restartmarker_keyframe = result;
00341 client->send_configure_change();
00342 return 1;
00343 }