4 * Copyright (C) 1997-2012 Adam Williams <broadcast at earthling dot net>
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.
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.
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
22 #include "bcdisplayinfo.h"
24 #include "dragcheckbox.h"
26 #include "edlsession.h"
29 #include "findobjwindow.h"
31 #include "pluginserver.h"
36 FindObjWindow::FindObjWindow(FindObjMain *plugin)
37 : PluginClientWindow(plugin, xS(500), yS(700), xS(500), yS(700), 0)
39 this->plugin = plugin;
42 FindObjWindow::~FindObjWindow()
46 void FindObjWindow::create_objects()
48 int xs10 = xS(10), xs15 = xS(15), xs100 = xS(100), xs200 = xS(200);
49 int ys5 = yS(5), ys10 = yS(10), ys15 = yS(15), ys40 = yS(40);
50 int x = xs10, y = ys10, x1 = x, x2 = get_w()*1/3, x3 = get_w()*2/3;
51 plugin->load_configuration();
54 add_subwindow(title = new BC_Title(x1, y, _("Mode:")));
55 add_subwindow(mode = new FindObjMode(plugin, this,
57 add_subwindow(reset = new FindObjReset(plugin, this, get_w()-xs15, y));
58 mode->create_objects();
59 y += mode->get_h() + ys10;
61 add_subwindow(title = new BC_Title(x1, y, _("Algorithm:")));
62 add_subwindow(algorithm = new FindObjAlgorithm(plugin, this,
64 algorithm->create_objects();
65 y += algorithm->get_h() + plugin->get_theme()->widget_border;
66 add_subwindow(use_flann = new FindObjUseFlann(plugin, this, x, y));
67 y += use_flann->get_h() + ys10;
70 add_subwindow(replace_object = new FindObjReplace(plugin, this,x3, y));
71 y += replace_object->get_h() + ys10;
72 add_subwindow(draw_match = new FindObjDrawMatch(plugin, this, x3, y));
73 y += draw_match->get_h() + ys10;
74 add_subwindow(aspect = new FindObjAspect(plugin, this, x3, y));
75 y += aspect->get_h() + ys10;
76 add_subwindow(scale = new FindObjScale(plugin, this, x3, y));
77 y += scale->get_h() + ys10;
78 add_subwindow(rotate = new FindObjRotate(plugin, this, x3, y));
79 y += rotate->get_h() + ys10;
80 add_subwindow(translate = new FindObjTranslate(plugin, this, x3, y));
82 int x0 = x + xs200; y = y1 + ys10;
83 add_subwindow(title = new BC_Title(x, y, _("Output/scene layer:")));
84 scene_layer = new FindObjLayer(plugin, this, x0, y,
85 &plugin->config.scene_layer);
86 scene_layer->create_objects();
87 y += scene_layer->get_h() + plugin->get_theme()->widget_border;
89 add_subwindow(title = new BC_Title(x, y, _("Object layer:")));
90 object_layer = new FindObjLayer(plugin, this, x0, y,
91 &plugin->config.object_layer);
92 object_layer->create_objects();
93 y += object_layer->get_h() + plugin->get_theme()->widget_border;
95 add_subwindow(title = new BC_Title(x, y, _("Replacement object layer:")));
96 replace_layer = new FindObjLayer(plugin, this, x0, y,
97 &plugin->config.replace_layer);
98 replace_layer->create_objects();
99 y += replace_layer->get_h() + plugin->get_theme()->widget_border + ys10;
102 add_subwindow(title = new BC_Title(x+xs15, y, _("Units: 0 to 100 percent")));
106 add_subwindow(title = new BC_Title(x1, y + ys10, _("Scene X:")));
107 Track *track = plugin->server->plugin->track;
108 int trk_w = track->track_w, trk_h = track->track_h;
109 float drag_w = trk_w * plugin->config.scene_w / 100.;
110 float drag_h = trk_h * plugin->config.scene_h / 100.;
111 float ctr_x = trk_w * plugin->config.scene_x / 100.;
112 float ctr_y = trk_h * plugin->config.scene_y / 100.;
113 float drag_x = ctr_x - drag_w/2, drag_y = ctr_y - drag_h/2;
114 drag_scene = new FindObjDragScene(plugin, this, x1+title->get_w()+xs10, y+ys5,
115 drag_x, drag_y, drag_w, drag_h);
116 add_subwindow(drag_scene);
117 drag_scene->create_objects();
118 y += title->get_h() + ys15;
120 add_subwindow(scene_x = new FindObjScanFloat(plugin, this,
121 x1, y, &plugin->config.scene_x));
122 add_subwindow(scene_x_text = new FindObjScanFloatText(plugin, this,
123 x1 + scene_x->get_w() + xs10, y + ys10, &plugin->config.scene_x));
124 scene_x->center_text = scene_x_text;
125 scene_x_text->center = scene_x;
128 add_subwindow(title = new BC_Title(x1, y + ys10, _("Scene Y:")));
129 y += title->get_h() + ys15;
130 add_subwindow(scene_y = new FindObjScanFloat(plugin, this,
131 x1, y, &plugin->config.scene_y));
132 add_subwindow(scene_y_text = new FindObjScanFloatText(plugin, this,
133 x1 + scene_y->get_w() + xs10, y + ys10, &plugin->config.scene_y));
134 scene_y->center_text = scene_y_text;
135 scene_y_text->center = scene_y;
138 add_subwindow(new BC_Title(x1, y + ys10, _("Scene W:")));
139 y += title->get_h() + ys15;
140 add_subwindow(scene_w = new FindObjScanFloat(plugin, this,
141 x1, y, &plugin->config.scene_w));
142 add_subwindow(scene_w_text = new FindObjScanFloatText(plugin, this,
143 x1 + scene_w->get_w() + xs10, y + ys10, &plugin->config.scene_w));
144 scene_w->center_text = scene_w_text;
145 scene_w_text->center = scene_w;
148 add_subwindow(title = new BC_Title(x1, y + ys10, _("Scene H:")));
149 y += title->get_h() + ys15;
150 add_subwindow(scene_h = new FindObjScanFloat(plugin, this,
151 x1, y, &plugin->config.scene_h));
152 add_subwindow(scene_h_text = new FindObjScanFloatText(plugin, this,
153 x1 + scene_h->get_w() + xs10, y + ys10,
154 &plugin->config.scene_h));
155 scene_h->center_text = scene_h_text;
156 scene_h_text->center = scene_h;
159 add_subwindow(title = new BC_Title(x2, y + ys10, _("Object X:")));
160 drag_w = trk_w * plugin->config.object_w / 100.;
161 drag_h = trk_h * plugin->config.object_h / 100.;
162 ctr_x = trk_w * plugin->config.object_x / 100.,
163 ctr_y = trk_h * plugin->config.object_y / 100.;
164 drag_x = ctr_x - drag_w/2; drag_y = ctr_y - drag_h/2;
165 drag_object = new FindObjDragObject(plugin, this, x2+title->get_w()+xs10, y+ys5,
166 drag_x, drag_y, drag_w, drag_h);
167 add_subwindow(drag_object);
168 drag_object->create_objects();
169 y += title->get_h() + ys15;
171 add_subwindow(object_x = new FindObjScanFloat(plugin, this,
172 x2, y, &plugin->config.object_x));
173 add_subwindow(object_x_text = new FindObjScanFloatText(plugin, this,
174 x2 + object_x->get_w() + xs10, y + ys10, &plugin->config.object_x));
175 object_x->center_text = object_x_text;
176 object_x_text->center = object_x;
179 add_subwindow(title = new BC_Title(x2, y + ys10, _("Object Y:")));
180 y += title->get_h() + ys15;
181 add_subwindow(object_y = new FindObjScanFloat(plugin, this,
182 x2, y, &plugin->config.object_y));
183 add_subwindow(object_y_text = new FindObjScanFloatText(plugin, this,
184 x2 + object_y->get_w() + xs10, y + ys10, &plugin->config.object_y));
185 object_y->center_text = object_y_text;
186 object_y_text->center = object_y;
189 add_subwindow(new BC_Title(x2, y + ys10, _("Object W:")));
190 y += title->get_h() + ys15;
191 add_subwindow(object_w = new FindObjScanFloat(plugin, this,
192 x2, y, &plugin->config.object_w));
193 add_subwindow(object_w_text = new FindObjScanFloatText(plugin, this,
194 x2 + object_w->get_w() + xs10, y + ys10, &plugin->config.object_w));
195 object_w->center_text = object_w_text;
196 object_w_text->center = object_w;
199 add_subwindow(title = new BC_Title(x2, y + ys10, _("Object H:")));
200 y += title->get_h() + ys15;
201 add_subwindow(object_h = new FindObjScanFloat(plugin, this,
202 x2, y, &plugin->config.object_h));
203 add_subwindow(object_h_text = new FindObjScanFloatText(plugin, this,
204 x2 + object_h->get_w() + xs10, y + ys10,
205 &plugin->config.object_h));
206 object_h->center_text = object_h_text;
207 object_h_text->center = object_h;
210 add_subwindow(title = new BC_Title(x3, y + ys10, _("Replace X:")));
211 drag_w = trk_w * plugin->config.replace_w / 100.;
212 drag_h = trk_h * plugin->config.replace_h / 100.;
213 ctr_x = trk_w * plugin->config.replace_x / 100.,
214 ctr_y = trk_h * plugin->config.replace_y / 100.;
215 drag_x = ctr_x - drag_w/2; drag_y = ctr_y - drag_h/2;
216 drag_replace = new FindObjDragReplace(plugin, this, x3+title->get_w()+xs10, y+ys5,
217 drag_x, drag_y, drag_w, drag_h);
218 add_subwindow(drag_replace);
219 drag_replace->create_objects();
220 y += title->get_h() + ys15;
222 add_subwindow(replace_x = new FindObjScanFloat(plugin, this,
223 x3, y, &plugin->config.replace_x));
224 add_subwindow(replace_x_text = new FindObjScanFloatText(plugin, this,
225 x3 + replace_x->get_w() + xs10, y + ys10, &plugin->config.replace_x));
226 replace_x->center_text = replace_x_text;
227 replace_x_text->center = replace_x;
230 add_subwindow(title = new BC_Title(x3, y + ys10, _("Replace Y:")));
231 y += title->get_h() + ys15;
232 add_subwindow(replace_y = new FindObjScanFloat(plugin, this,
233 x3, y, &plugin->config.replace_y));
234 add_subwindow(replace_y_text = new FindObjScanFloatText(plugin, this,
235 x3 + replace_y->get_w() + xs10, y + ys10, &plugin->config.replace_y));
236 replace_y->center_text = replace_y_text;
237 replace_y_text->center = replace_y;
240 add_subwindow(new BC_Title(x3, y + ys10, _("Replace W:")));
241 y += title->get_h() + ys15;
242 add_subwindow(replace_w = new FindObjScanFloat(plugin, this,
243 x3, y, &plugin->config.replace_w));
244 add_subwindow(replace_w_text = new FindObjScanFloatText(plugin, this,
245 x3 + replace_w->get_w() + xs10, y + ys10, &plugin->config.replace_w));
246 replace_w->center_text = replace_w_text;
247 replace_w_text->center = replace_w;
250 add_subwindow(title = new BC_Title(x3, y + ys10, _("Replace H:")));
251 y += title->get_h() + ys15;
252 add_subwindow(replace_h = new FindObjScanFloat(plugin, this,
253 x3, y, &plugin->config.replace_h));
254 add_subwindow(replace_h_text = new FindObjScanFloatText(plugin, this,
255 x3 + replace_h->get_w() + xs10, y + ys10,
256 &plugin->config.replace_h));
257 replace_h->center_text = replace_h_text;
258 replace_h_text->center = replace_h;
260 y += ys40; int y2 = y;
261 add_subwindow(title = new BC_Title(x3, y + ys10, _("Replace DX:")));
262 y += title->get_h() + ys15;
263 add_subwindow(replace_dx = new FindObjScanFloat(plugin, this,
264 x3, y, &plugin->config.replace_dx, -100.f, 100.f));
265 add_subwindow(replace_dx_text = new FindObjScanFloatText(plugin, this,
266 x3 + replace_dx->get_w() + xs10, y + ys10, &plugin->config.replace_dx));
267 replace_dx->center_text = replace_dx_text;
268 replace_dx_text->center = replace_dx;
271 add_subwindow(title = new BC_Title(x3, y + ys10, _("Replace DY:")));
272 y += title->get_h() + ys15;
273 add_subwindow(replace_dy = new FindObjScanFloat(plugin, this,
274 x3, y, &plugin->config.replace_dy, -100.f, 100.f));
275 add_subwindow(replace_dy_text = new FindObjScanFloatText(plugin, this,
276 x3 + replace_dy->get_w() + xs10, y + ys10, &plugin->config.replace_dy));
277 replace_dy->center_text = replace_dy_text;
278 replace_dy_text->center = replace_dy;
281 add_subwindow(draw_keypoints = new FindObjDrawKeypoints(plugin, this, x, y));
282 y += draw_keypoints->get_h() + plugin->get_theme()->widget_border;
283 add_subwindow(draw_scene_border = new FindObjDrawSceneBorder(plugin, this, x, y));
284 y += draw_scene_border->get_h() + plugin->get_theme()->widget_border;
285 add_subwindow(draw_object_border = new FindObjDrawObjectBorder(plugin, this, x, y));
286 y += draw_object_border->get_h() + plugin->get_theme()->widget_border;
287 add_subwindow(draw_replace_border = new FindObjDrawReplaceBorder(plugin, this, x, y));
288 y += draw_object_border->get_h() + plugin->get_theme()->widget_border;
290 add_subwindow(title = new BC_Title(x, y + xs10, _("Object blend amount:")));
291 add_subwindow(blend = new FindObjBlend(plugin,
292 x + title->get_w() + plugin->get_theme()->widget_border, y,
293 &plugin->config.blend));
299 FindObjReset::FindObjReset(FindObjMain *plugin, FindObjWindow *gui, int x, int y)
300 : BC_GenericButton(x - BC_GenericButton::calculate_w(gui, _("Reset")), y, _("Reset"))
302 this->plugin = plugin;
306 int FindObjReset::handle_event()
308 plugin->config.reset();
309 gui->drag_scene->drag_deactivate();
310 gui->drag_object->drag_deactivate();
311 gui->drag_replace->drag_deactivate();
313 plugin->send_configure_change();
317 void FindObjWindow::update_drag()
319 Track *track = drag_scene->get_drag_track();
320 int trk_w = track->track_w, trk_h = track->track_h;
321 drag_scene->drag_w = trk_w * plugin->config.scene_w/100.;
322 drag_scene->drag_h = trk_h * plugin->config.scene_h/100.;
323 drag_scene->drag_x = trk_w * plugin->config.scene_x/100. - drag_scene->drag_w/2;
324 drag_scene->drag_y = trk_h * plugin->config.scene_y/100. - drag_scene->drag_h/2;
325 track = drag_object->get_drag_track();
326 trk_w = track->track_w, trk_h = track->track_h;
327 drag_object->drag_w = trk_w * plugin->config.object_w/100.;
328 drag_object->drag_h = trk_h * plugin->config.object_h/100.;
329 drag_object->drag_x = trk_w * plugin->config.object_x/100. - drag_object->drag_w/2;
330 drag_object->drag_y = trk_h * plugin->config.object_y/100. - drag_object->drag_h/2;
331 track = drag_replace->get_drag_track();
332 trk_w = track->track_w, trk_h = track->track_h;
333 drag_replace->drag_w = trk_w * plugin->config.replace_w/100.;
334 drag_replace->drag_h = trk_h * plugin->config.replace_h/100.;
335 drag_replace->drag_x = trk_w * plugin->config.replace_x/100. - drag_replace->drag_w/2;
336 drag_replace->drag_y = trk_h * plugin->config.replace_y/100. - drag_replace->drag_h/2;
339 void FindObjWindow::update_gui()
342 FindObjConfig &conf = plugin->config;
343 algorithm->update(conf.algorithm);
344 use_flann->update(conf.use_flann);
345 draw_match->update(conf.draw_match);
346 aspect->update(conf.aspect);
347 scale->update(conf.scale);
348 rotate->update(conf.rotate);
349 translate->update(conf.translate);
350 drag_object->update(conf.drag_object);
351 object_x->update(conf.object_x);
352 object_x_text->update((float)conf.object_x);
353 object_y->update(conf.object_y);
354 object_y_text->update((float)conf.object_y);
355 object_w->update(conf.object_w);
356 object_w_text->update((float)conf.object_w);
357 object_h->update(conf.object_h);
358 object_h_text->update((float)conf.object_h);
359 drag_scene->update(conf.drag_scene);
360 scene_x->update(conf.scene_x);
361 scene_x_text->update((float)conf.scene_x);
362 scene_y->update(conf.scene_y);
363 scene_y_text->update((float)conf.scene_y);
364 scene_w->update(conf.scene_w);
365 scene_w_text->update((float)conf.scene_w);
366 scene_h->update(conf.scene_h);
367 scene_h_text->update((float)conf.scene_h);
368 drag_replace->update(conf.drag_replace);
369 replace_x->update(conf.replace_x);
370 replace_x_text->update((float)conf.replace_x);
371 replace_y->update(conf.replace_y);
372 replace_y_text->update((float)conf.replace_y);
373 replace_w->update(conf.replace_w);
374 replace_w_text->update((float)conf.replace_w);
375 replace_h->update(conf.replace_h);
376 replace_h_text->update((float)conf.replace_h);
377 replace_dx->update(conf.replace_dx);
378 replace_dx_text->update((float)conf.replace_dx);
379 replace_dx->update(conf.replace_dx);
380 replace_dx_text->update((float)conf.replace_dx);
381 draw_keypoints->update(conf.draw_keypoints);
382 draw_scene_border->update(conf.draw_scene_border);
383 replace_object->update(conf.replace_object);
384 draw_object_border->update(conf.draw_object_border);
385 draw_replace_border->update(conf.draw_replace_border);
386 object_layer->update( (int64_t)conf.object_layer);
387 replace_layer->update( (int64_t)conf.replace_layer);
388 scene_layer->update( (int64_t)conf.scene_layer);
389 blend->update( (int64_t)conf.blend);
392 FindObjScanFloat::FindObjScanFloat(FindObjMain *plugin, FindObjWindow *gui,
393 int x, int y, float *value, float min, float max)
394 : BC_FPot(x, y, *value, min, max)
396 this->plugin = plugin;
399 this->center_text = 0;
403 int FindObjScanFloat::handle_event()
405 *value = get_value();
406 center_text->update(*value);
408 plugin->send_configure_change();
412 void FindObjScanFloat::update(float v)
414 BC_FPot::update(*value = v);
415 center_text->update(v);
416 plugin->send_configure_change();
420 FindObjScanFloatText::FindObjScanFloatText(FindObjMain *plugin, FindObjWindow *gui,
421 int x, int y, float *value)
422 : BC_TextBox(x, y, xS(75), 1, *value)
424 this->plugin = plugin;
431 int FindObjScanFloatText::handle_event()
433 *value = atof(get_text());
434 center->update(*value);
436 plugin->send_configure_change();
441 FindObjDrawSceneBorder::FindObjDrawSceneBorder(FindObjMain *plugin, FindObjWindow *gui,
443 : BC_CheckBox(x, y, plugin->config.draw_scene_border, _("Draw scene border"))
446 this->plugin = plugin;
449 int FindObjDrawSceneBorder::handle_event()
451 plugin->config.draw_scene_border = get_value();
452 plugin->send_configure_change();
456 FindObjDrawObjectBorder::FindObjDrawObjectBorder(FindObjMain *plugin, FindObjWindow *gui,
458 : BC_CheckBox(x, y, plugin->config.draw_object_border, _("Draw object border"))
461 this->plugin = plugin;
464 int FindObjDrawObjectBorder::handle_event()
466 plugin->config.draw_object_border = get_value();
467 plugin->send_configure_change();
471 FindObjDrawReplaceBorder::FindObjDrawReplaceBorder(FindObjMain *plugin, FindObjWindow *gui,
473 : BC_CheckBox(x, y, plugin->config.draw_replace_border, _("Draw replace border"))
476 this->plugin = plugin;
479 int FindObjDrawReplaceBorder::handle_event()
481 plugin->config.draw_replace_border = get_value();
482 plugin->send_configure_change();
487 FindObjDrawKeypoints::FindObjDrawKeypoints(FindObjMain *plugin, FindObjWindow *gui,
489 : BC_CheckBox(x, y, plugin->config.draw_keypoints, _("Draw keypoints"))
492 this->plugin = plugin;
495 int FindObjDrawKeypoints::handle_event()
497 plugin->config.draw_keypoints = get_value();
498 plugin->send_configure_change();
503 FindObjReplace::FindObjReplace(FindObjMain *plugin, FindObjWindow *gui,
505 : BC_CheckBox(x, y, plugin->config.replace_object, _("Replace object"))
508 this->plugin = plugin;
511 int FindObjReplace::handle_event()
513 plugin->config.replace_object = get_value();
514 plugin->send_configure_change();
519 FindObjDragScene::FindObjDragScene(FindObjMain *plugin, FindObjWindow *gui, int x, int y,
520 float drag_x, float drag_y, float drag_w, float drag_h)
521 : DragCheckBox(plugin->server->mwindow, x, y, _("Drag"), &plugin->config.drag_scene,
522 drag_x, drag_y, drag_w, drag_h)
524 this->plugin = plugin;
528 FindObjDragScene::~FindObjDragScene()
532 int FindObjDragScene::handle_event()
534 int ret = DragCheckBox::handle_event();
535 plugin->send_configure_change();
538 Track *FindObjDragScene::get_drag_track()
540 return !plugin->server->plugin ? 0 :
541 plugin->server->plugin->track;
543 int64_t FindObjDragScene::get_drag_position()
545 return plugin->get_source_position();
547 void FindObjDragScene::update_gui()
550 Track *track = get_drag_track();
551 int trk_w = track ? track->track_w : plugin->get_edl()->session->output_w;
552 int trk_h = track ? track->track_h : plugin->get_edl()->session->output_h;
553 float ctr_x = drag_x + drag_w/2, ctr_y = drag_y + drag_h/2;
554 gui->scene_x->update( plugin->config.scene_x = 100. * ctr_x / trk_w );
555 gui->scene_y->update( plugin->config.scene_y = 100. * ctr_y / trk_h );
556 gui->scene_w->update( plugin->config.scene_w = 100. * drag_w / trk_w );
557 gui->scene_h->update( plugin->config.scene_h = 100. * drag_h / trk_h );
558 plugin->send_configure_change();
561 FindObjDragObject::FindObjDragObject(FindObjMain *plugin, FindObjWindow *gui, int x, int y,
562 float drag_x, float drag_y, float drag_w, float drag_h)
563 : DragCheckBox(plugin->server->mwindow, x, y, _("Drag"), &plugin->config.drag_object,
564 drag_x, drag_y, drag_w, drag_h)
566 this->plugin = plugin;
570 FindObjDragObject::~FindObjDragObject()
574 int FindObjDragObject::handle_event()
576 int ret = DragCheckBox::handle_event();
577 plugin->send_configure_change();
580 Track *FindObjDragObject::get_drag_track()
582 return !plugin->server->plugin ? 0 :
583 plugin->server->plugin->track;
585 int64_t FindObjDragObject::get_drag_position()
587 return plugin->get_source_position();
589 void FindObjDragObject::update_gui()
592 Track *track = get_drag_track();
593 int trk_w = track ? track->track_w : plugin->get_edl()->session->output_w;
594 int trk_h = track ? track->track_h : plugin->get_edl()->session->output_h;
595 float ctr_x = drag_x + drag_w/2, ctr_y = drag_y + drag_h/2;
596 gui->object_x->update( plugin->config.object_x = 100. * ctr_x / trk_w );
597 gui->object_y->update( plugin->config.object_y = 100. * ctr_y / trk_h );
598 gui->object_w->update( plugin->config.object_w = 100. * drag_w / trk_w );
599 gui->object_h->update( plugin->config.object_h = 100. * drag_h / trk_h );
600 plugin->send_configure_change();
603 FindObjDragReplace::FindObjDragReplace(FindObjMain *plugin, FindObjWindow *gui, int x, int y,
604 float drag_x, float drag_y, float drag_w, float drag_h)
605 : DragCheckBox(plugin->server->mwindow, x, y, _("Drag"), &plugin->config.drag_replace,
606 drag_x, drag_y, drag_w, drag_h)
608 this->plugin = plugin;
612 FindObjDragReplace::~FindObjDragReplace()
616 int FindObjDragReplace::handle_event()
618 int ret = DragCheckBox::handle_event();
619 plugin->send_configure_change();
622 Track *FindObjDragReplace::get_drag_track()
624 return !plugin->server->plugin ? 0 :
625 plugin->server->plugin->track;
627 int64_t FindObjDragReplace::get_drag_position()
629 return plugin->get_source_position();
631 void FindObjDragReplace::update_gui()
634 Track *track = get_drag_track();
635 int trk_w = track ? track->track_w : plugin->get_edl()->session->output_w;
636 int trk_h = track ? track->track_h : plugin->get_edl()->session->output_h;
637 float ctr_x = drag_x + drag_w/2, ctr_y = drag_y + drag_h/2;
638 gui->replace_x->update( plugin->config.replace_x = 100. * ctr_x / trk_w );
639 gui->replace_y->update( plugin->config.replace_y = 100. * ctr_y / trk_h );
640 gui->replace_w->update( plugin->config.replace_w = 100. * drag_w / trk_w );
641 gui->replace_h->update( plugin->config.replace_h = 100. * drag_h / trk_h );
642 plugin->send_configure_change();
647 FindObjAlgorithm::FindObjAlgorithm(FindObjMain *plugin, FindObjWindow *gui, int x, int y)
648 : BC_PopupMenu(x, y, calculate_w(gui), to_text(plugin->config.algorithm))
650 this->plugin = plugin;
654 int FindObjAlgorithm::handle_event()
656 plugin->config.algorithm = from_text(get_text());
657 plugin->send_configure_change();
661 void FindObjAlgorithm::create_objects()
663 add_item(new BC_MenuItem(to_text(NO_ALGORITHM)));
665 add_item(new BC_MenuItem(to_text(ALGORITHM_SIFT)));
668 add_item(new BC_MenuItem(to_text(ALGORITHM_SURF)));
671 add_item(new BC_MenuItem(to_text(ALGORITHM_ORB)));
674 add_item(new BC_MenuItem(to_text(ALGORITHM_AKAZE)));
677 add_item(new BC_MenuItem(to_text(ALGORITHM_BRISK)));
681 int FindObjAlgorithm::from_text(char *text)
684 if(!strcmp(text, _("SIFT"))) return ALGORITHM_SIFT;
687 if(!strcmp(text, _("SURF"))) return ALGORITHM_SURF;
690 if(!strcmp(text, _("ORB"))) return ALGORITHM_ORB;
693 if(!strcmp(text, _("AKAZE"))) return ALGORITHM_AKAZE;
696 if(!strcmp(text, _("BRISK"))) return ALGORITHM_BRISK;
701 void FindObjAlgorithm::update(int mode)
703 set_text(to_text(mode));
706 char* FindObjAlgorithm::to_text(int mode)
710 case ALGORITHM_SIFT: return _("SIFT");
713 case ALGORITHM_SURF: return _("SURF");
716 case ALGORITHM_ORB: return _("ORB");
719 case ALGORITHM_AKAZE: return _("AKAZE");
722 case ALGORITHM_BRISK: return _("BRISK");
725 return _("Don't Calculate");
728 int FindObjAlgorithm::calculate_w(FindObjWindow *gui)
731 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(NO_ALGORITHM)));
733 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_SIFT)));
736 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_SURF)));
739 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_ORB)));
742 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_AKAZE)));
745 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_BRISK)));
747 return result + xS(50);
751 FindObjUseFlann::FindObjUseFlann(FindObjMain *plugin, FindObjWindow *gui,
753 : BC_CheckBox(x, y, plugin->config.use_flann, _("Use FLANN"))
756 this->plugin = plugin;
759 int FindObjUseFlann::handle_event()
761 plugin->config.use_flann = get_value();
762 plugin->send_configure_change();
766 FindObjDrawMatch::FindObjDrawMatch(FindObjMain *plugin, FindObjWindow *gui,
768 : BC_CheckBox(x, y, plugin->config.draw_match, _("Draw match"))
771 this->plugin = plugin;
774 int FindObjDrawMatch::handle_event()
776 plugin->config.draw_match = get_value();
777 plugin->send_configure_change();
781 FindObjAspect::FindObjAspect(FindObjMain *plugin, FindObjWindow *gui,
783 : BC_CheckBox(x, y, plugin->config.aspect, _("Aspect"))
786 this->plugin = plugin;
789 int FindObjAspect::handle_event()
791 plugin->config.aspect = get_value();
792 plugin->send_configure_change();
796 FindObjScale::FindObjScale(FindObjMain *plugin, FindObjWindow *gui,
798 : BC_CheckBox(x, y, plugin->config.scale, _("Scale"))
801 this->plugin = plugin;
804 int FindObjScale::handle_event()
806 plugin->config.scale = get_value();
807 plugin->send_configure_change();
811 FindObjRotate::FindObjRotate(FindObjMain *plugin, FindObjWindow *gui,
813 : BC_CheckBox(x, y, plugin->config.rotate, _("Rotate"))
816 this->plugin = plugin;
819 int FindObjRotate::handle_event()
821 plugin->config.rotate = get_value();
822 plugin->send_configure_change();
826 FindObjTranslate::FindObjTranslate(FindObjMain *plugin, FindObjWindow *gui,
828 : BC_CheckBox(x, y, plugin->config.translate, _("Translate"))
831 this->plugin = plugin;
834 int FindObjTranslate::handle_event()
836 plugin->config.translate = get_value();
837 plugin->send_configure_change();
841 FindObjMode::FindObjMode(FindObjMain *plugin, FindObjWindow *gui, int x, int y)
842 : BC_PopupMenu(x, y, calculate_w(gui), to_text(plugin->config.mode))
844 this->plugin = plugin;
848 int FindObjMode::handle_event()
850 plugin->config.mode = from_text(get_text());
851 plugin->send_configure_change();
855 void FindObjMode::create_objects()
857 add_item(new BC_MenuItem(to_text(MODE_SQUARE)));
858 add_item(new BC_MenuItem(to_text(MODE_RHOMBUS)));
859 add_item(new BC_MenuItem(to_text(MODE_RECTANGLE)));
860 add_item(new BC_MenuItem(to_text(MODE_PARALLELOGRAM)));
861 add_item(new BC_MenuItem(to_text(MODE_QUADRILATERAL)));
863 int FindObjMode::from_text(char *text)
865 if(!strcmp(text, _("Square"))) return MODE_SQUARE;
866 if(!strcmp(text, _("Rhombus"))) return MODE_RHOMBUS;
867 if(!strcmp(text, _("Rectangle"))) return MODE_RECTANGLE;
868 if(!strcmp(text, _("Parallelogram"))) return MODE_PARALLELOGRAM;
869 if(!strcmp(text, _("Quadrilateral"))) return MODE_QUADRILATERAL;
873 void FindObjMode::update(int mode)
875 set_text(to_text(mode));
878 char* FindObjMode::to_text(int mode)
881 case MODE_SQUARE: return _("Square");
882 case MODE_RHOMBUS: return _("Rhombus");
883 case MODE_RECTANGLE: return _("Rectangle");
884 case MODE_PARALLELOGRAM: return _("Parallelogram");
885 case MODE_QUADRILATERAL: return _("Quadrilateral");
890 int FindObjMode::calculate_w(FindObjWindow *gui)
893 for( int mode=MODE_NONE; mode<MODE_MAX; ++mode )
894 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(mode)));
895 return result + xS(50);
899 FindObjLayer::FindObjLayer(FindObjMain *plugin, FindObjWindow *gui,
900 int x, int y, int *value)
901 : BC_TumbleTextBox(gui, *value, MIN_LAYER, MAX_LAYER, x, y, calculate_w(gui))
903 this->plugin = plugin;
908 int FindObjLayer::handle_event()
910 *value = atoi(get_text());
911 plugin->send_configure_change();
915 int FindObjLayer::calculate_w(FindObjWindow *gui)
918 result = gui->get_text_width(MEDIUMFONT, "000");
919 return result + xS(50);
923 FindObjBlend::FindObjBlend(FindObjMain *plugin,
933 this->plugin = plugin;
937 int FindObjBlend::handle_event()
939 *value = (int)get_value();
940 plugin->send_configure_change();