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->get_plugin_track();
108 int trk_w = track ? track->track_w : plugin->get_edl()->session->output_w;
109 int trk_h = track ? track->track_h : plugin->get_edl()->session->output_h;
110 float drag_w = trk_w * plugin->config.scene_w / 100.;
111 float drag_h = trk_h * plugin->config.scene_h / 100.;
112 float ctr_x = trk_w * plugin->config.scene_x / 100.;
113 float ctr_y = trk_h * plugin->config.scene_y / 100.;
114 float drag_x = ctr_x - drag_w/2, drag_y = ctr_y - drag_h/2;
115 drag_scene = new FindObjDragScene(plugin, this, x1+title->get_w()+xs10, y+ys5,
116 drag_x, drag_y, drag_w, drag_h);
117 add_subwindow(drag_scene);
118 drag_scene->create_objects();
119 y += title->get_h() + ys15;
121 add_subwindow(scene_x = new FindObjScanFloat(plugin, this,
122 x1, y, &plugin->config.scene_x));
123 add_subwindow(scene_x_text = new FindObjScanFloatText(plugin, this,
124 x1 + scene_x->get_w() + xs10, y + ys10, &plugin->config.scene_x));
125 scene_x->center_text = scene_x_text;
126 scene_x_text->center = scene_x;
129 add_subwindow(title = new BC_Title(x1, y + ys10, _("Scene Y:")));
130 y += title->get_h() + ys15;
131 add_subwindow(scene_y = new FindObjScanFloat(plugin, this,
132 x1, y, &plugin->config.scene_y));
133 add_subwindow(scene_y_text = new FindObjScanFloatText(plugin, this,
134 x1 + scene_y->get_w() + xs10, y + ys10, &plugin->config.scene_y));
135 scene_y->center_text = scene_y_text;
136 scene_y_text->center = scene_y;
139 add_subwindow(new BC_Title(x1, y + ys10, _("Scene W:")));
140 y += title->get_h() + ys15;
141 add_subwindow(scene_w = new FindObjScanFloat(plugin, this,
142 x1, y, &plugin->config.scene_w));
143 add_subwindow(scene_w_text = new FindObjScanFloatText(plugin, this,
144 x1 + scene_w->get_w() + xs10, y + ys10, &plugin->config.scene_w));
145 scene_w->center_text = scene_w_text;
146 scene_w_text->center = scene_w;
149 add_subwindow(title = new BC_Title(x1, y + ys10, _("Scene H:")));
150 y += title->get_h() + ys15;
151 add_subwindow(scene_h = new FindObjScanFloat(plugin, this,
152 x1, y, &plugin->config.scene_h));
153 add_subwindow(scene_h_text = new FindObjScanFloatText(plugin, this,
154 x1 + scene_h->get_w() + xs10, y + ys10,
155 &plugin->config.scene_h));
156 scene_h->center_text = scene_h_text;
157 scene_h_text->center = scene_h;
160 add_subwindow(title = new BC_Title(x2, y + ys10, _("Object X:")));
161 drag_w = trk_w * plugin->config.object_w / 100.;
162 drag_h = trk_h * plugin->config.object_h / 100.;
163 ctr_x = trk_w * plugin->config.object_x / 100.,
164 ctr_y = trk_h * plugin->config.object_y / 100.;
165 drag_x = ctr_x - drag_w/2; drag_y = ctr_y - drag_h/2;
166 drag_object = new FindObjDragObject(plugin, this, x2+title->get_w()+xs10, y+ys5,
167 drag_x, drag_y, drag_w, drag_h);
168 add_subwindow(drag_object);
169 drag_object->create_objects();
170 y += title->get_h() + ys15;
172 add_subwindow(object_x = new FindObjScanFloat(plugin, this,
173 x2, y, &plugin->config.object_x));
174 add_subwindow(object_x_text = new FindObjScanFloatText(plugin, this,
175 x2 + object_x->get_w() + xs10, y + ys10, &plugin->config.object_x));
176 object_x->center_text = object_x_text;
177 object_x_text->center = object_x;
180 add_subwindow(title = new BC_Title(x2, y + ys10, _("Object Y:")));
181 y += title->get_h() + ys15;
182 add_subwindow(object_y = new FindObjScanFloat(plugin, this,
183 x2, y, &plugin->config.object_y));
184 add_subwindow(object_y_text = new FindObjScanFloatText(plugin, this,
185 x2 + object_y->get_w() + xs10, y + ys10, &plugin->config.object_y));
186 object_y->center_text = object_y_text;
187 object_y_text->center = object_y;
190 add_subwindow(new BC_Title(x2, y + ys10, _("Object W:")));
191 y += title->get_h() + ys15;
192 add_subwindow(object_w = new FindObjScanFloat(plugin, this,
193 x2, y, &plugin->config.object_w));
194 add_subwindow(object_w_text = new FindObjScanFloatText(plugin, this,
195 x2 + object_w->get_w() + xs10, y + ys10, &plugin->config.object_w));
196 object_w->center_text = object_w_text;
197 object_w_text->center = object_w;
200 add_subwindow(title = new BC_Title(x2, y + ys10, _("Object H:")));
201 y += title->get_h() + ys15;
202 add_subwindow(object_h = new FindObjScanFloat(plugin, this,
203 x2, y, &plugin->config.object_h));
204 add_subwindow(object_h_text = new FindObjScanFloatText(plugin, this,
205 x2 + object_h->get_w() + xs10, y + ys10,
206 &plugin->config.object_h));
207 object_h->center_text = object_h_text;
208 object_h_text->center = object_h;
211 add_subwindow(title = new BC_Title(x3, y + ys10, _("Replace X:")));
212 drag_w = trk_w * plugin->config.replace_w / 100.;
213 drag_h = trk_h * plugin->config.replace_h / 100.;
214 ctr_x = trk_w * plugin->config.replace_x / 100.,
215 ctr_y = trk_h * plugin->config.replace_y / 100.;
216 drag_x = ctr_x - drag_w/2; drag_y = ctr_y - drag_h/2;
217 drag_replace = new FindObjDragReplace(plugin, this, x3+title->get_w()+xs10, y+ys5,
218 drag_x, drag_y, drag_w, drag_h);
219 add_subwindow(drag_replace);
220 drag_replace->create_objects();
221 y += title->get_h() + ys15;
223 add_subwindow(replace_x = new FindObjScanFloat(plugin, this,
224 x3, y, &plugin->config.replace_x));
225 add_subwindow(replace_x_text = new FindObjScanFloatText(plugin, this,
226 x3 + replace_x->get_w() + xs10, y + ys10, &plugin->config.replace_x));
227 replace_x->center_text = replace_x_text;
228 replace_x_text->center = replace_x;
231 add_subwindow(title = new BC_Title(x3, y + ys10, _("Replace Y:")));
232 y += title->get_h() + ys15;
233 add_subwindow(replace_y = new FindObjScanFloat(plugin, this,
234 x3, y, &plugin->config.replace_y));
235 add_subwindow(replace_y_text = new FindObjScanFloatText(plugin, this,
236 x3 + replace_y->get_w() + xs10, y + ys10, &plugin->config.replace_y));
237 replace_y->center_text = replace_y_text;
238 replace_y_text->center = replace_y;
241 add_subwindow(new BC_Title(x3, y + ys10, _("Replace W:")));
242 y += title->get_h() + ys15;
243 add_subwindow(replace_w = new FindObjScanFloat(plugin, this,
244 x3, y, &plugin->config.replace_w));
245 add_subwindow(replace_w_text = new FindObjScanFloatText(plugin, this,
246 x3 + replace_w->get_w() + xs10, y + ys10, &plugin->config.replace_w));
247 replace_w->center_text = replace_w_text;
248 replace_w_text->center = replace_w;
251 add_subwindow(title = new BC_Title(x3, y + ys10, _("Replace H:")));
252 y += title->get_h() + ys15;
253 add_subwindow(replace_h = new FindObjScanFloat(plugin, this,
254 x3, y, &plugin->config.replace_h));
255 add_subwindow(replace_h_text = new FindObjScanFloatText(plugin, this,
256 x3 + replace_h->get_w() + xs10, y + ys10,
257 &plugin->config.replace_h));
258 replace_h->center_text = replace_h_text;
259 replace_h_text->center = replace_h;
261 y += ys40; int y2 = y;
262 add_subwindow(title = new BC_Title(x3, y + ys10, _("Replace DX:")));
263 y += title->get_h() + ys15;
264 add_subwindow(replace_dx = new FindObjScanFloat(plugin, this,
265 x3, y, &plugin->config.replace_dx, -100.f, 100.f));
266 add_subwindow(replace_dx_text = new FindObjScanFloatText(plugin, this,
267 x3 + replace_dx->get_w() + xs10, y + ys10, &plugin->config.replace_dx));
268 replace_dx->center_text = replace_dx_text;
269 replace_dx_text->center = replace_dx;
272 add_subwindow(title = new BC_Title(x3, y + ys10, _("Replace DY:")));
273 y += title->get_h() + ys15;
274 add_subwindow(replace_dy = new FindObjScanFloat(plugin, this,
275 x3, y, &plugin->config.replace_dy, -100.f, 100.f));
276 add_subwindow(replace_dy_text = new FindObjScanFloatText(plugin, this,
277 x3 + replace_dy->get_w() + xs10, y + ys10, &plugin->config.replace_dy));
278 replace_dy->center_text = replace_dy_text;
279 replace_dy_text->center = replace_dy;
282 add_subwindow(draw_keypoints = new FindObjDrawKeypoints(plugin, this, x, y));
283 y += draw_keypoints->get_h() + plugin->get_theme()->widget_border;
284 add_subwindow(draw_scene_border = new FindObjDrawSceneBorder(plugin, this, x, y));
285 y += draw_scene_border->get_h() + plugin->get_theme()->widget_border;
286 add_subwindow(draw_object_border = new FindObjDrawObjectBorder(plugin, this, x, y));
287 y += draw_object_border->get_h() + plugin->get_theme()->widget_border;
288 add_subwindow(draw_replace_border = new FindObjDrawReplaceBorder(plugin, this, x, y));
289 y += draw_object_border->get_h() + plugin->get_theme()->widget_border;
291 add_subwindow(title = new BC_Title(x, y + xs10, _("Object blend amount:")));
292 add_subwindow(blend = new FindObjBlend(plugin,
293 x + title->get_w() + plugin->get_theme()->widget_border, y,
294 &plugin->config.blend));
300 FindObjReset::FindObjReset(FindObjMain *plugin, FindObjWindow *gui, int x, int y)
301 : BC_GenericButton(x - BC_GenericButton::calculate_w(gui, _("Reset")), y, _("Reset"))
303 this->plugin = plugin;
307 int FindObjReset::handle_event()
309 plugin->config.reset();
310 gui->drag_scene->drag_deactivate();
311 gui->drag_object->drag_deactivate();
312 gui->drag_replace->drag_deactivate();
314 plugin->send_configure_change();
318 void FindObjWindow::update_drag()
320 Track *track = drag_scene->get_drag_track();
321 int trk_w = track->track_w, trk_h = track->track_h;
322 drag_scene->drag_w = trk_w * plugin->config.scene_w/100.;
323 drag_scene->drag_h = trk_h * plugin->config.scene_h/100.;
324 drag_scene->drag_x = trk_w * plugin->config.scene_x/100. - drag_scene->drag_w/2;
325 drag_scene->drag_y = trk_h * plugin->config.scene_y/100. - drag_scene->drag_h/2;
326 track = drag_object->get_drag_track();
327 trk_w = track->track_w, trk_h = track->track_h;
328 drag_object->drag_w = trk_w * plugin->config.object_w/100.;
329 drag_object->drag_h = trk_h * plugin->config.object_h/100.;
330 drag_object->drag_x = trk_w * plugin->config.object_x/100. - drag_object->drag_w/2;
331 drag_object->drag_y = trk_h * plugin->config.object_y/100. - drag_object->drag_h/2;
332 track = drag_replace->get_drag_track();
333 trk_w = track->track_w, trk_h = track->track_h;
334 drag_replace->drag_w = trk_w * plugin->config.replace_w/100.;
335 drag_replace->drag_h = trk_h * plugin->config.replace_h/100.;
336 drag_replace->drag_x = trk_w * plugin->config.replace_x/100. - drag_replace->drag_w/2;
337 drag_replace->drag_y = trk_h * plugin->config.replace_y/100. - drag_replace->drag_h/2;
340 void FindObjWindow::update_gui()
343 FindObjConfig &conf = plugin->config;
344 algorithm->update(conf.algorithm);
345 use_flann->update(conf.use_flann);
346 draw_match->update(conf.draw_match);
347 aspect->update(conf.aspect);
348 scale->update(conf.scale);
349 rotate->update(conf.rotate);
350 translate->update(conf.translate);
351 drag_object->update(conf.drag_object);
352 object_x->update(conf.object_x);
353 object_x_text->update((float)conf.object_x);
354 object_y->update(conf.object_y);
355 object_y_text->update((float)conf.object_y);
356 object_w->update(conf.object_w);
357 object_w_text->update((float)conf.object_w);
358 object_h->update(conf.object_h);
359 object_h_text->update((float)conf.object_h);
360 drag_scene->update(conf.drag_scene);
361 scene_x->update(conf.scene_x);
362 scene_x_text->update((float)conf.scene_x);
363 scene_y->update(conf.scene_y);
364 scene_y_text->update((float)conf.scene_y);
365 scene_w->update(conf.scene_w);
366 scene_w_text->update((float)conf.scene_w);
367 scene_h->update(conf.scene_h);
368 scene_h_text->update((float)conf.scene_h);
369 drag_replace->update(conf.drag_replace);
370 replace_x->update(conf.replace_x);
371 replace_x_text->update((float)conf.replace_x);
372 replace_y->update(conf.replace_y);
373 replace_y_text->update((float)conf.replace_y);
374 replace_w->update(conf.replace_w);
375 replace_w_text->update((float)conf.replace_w);
376 replace_h->update(conf.replace_h);
377 replace_h_text->update((float)conf.replace_h);
378 replace_dx->update(conf.replace_dx);
379 replace_dx_text->update((float)conf.replace_dx);
380 replace_dx->update(conf.replace_dx);
381 replace_dx_text->update((float)conf.replace_dx);
382 draw_keypoints->update(conf.draw_keypoints);
383 draw_scene_border->update(conf.draw_scene_border);
384 replace_object->update(conf.replace_object);
385 draw_object_border->update(conf.draw_object_border);
386 draw_replace_border->update(conf.draw_replace_border);
387 object_layer->update( (int64_t)conf.object_layer);
388 replace_layer->update( (int64_t)conf.replace_layer);
389 scene_layer->update( (int64_t)conf.scene_layer);
390 blend->update( (int64_t)conf.blend);
393 FindObjScanFloat::FindObjScanFloat(FindObjMain *plugin, FindObjWindow *gui,
394 int x, int y, float *value, float min, float max)
395 : BC_FPot(x, y, *value, min, max)
397 this->plugin = plugin;
400 this->center_text = 0;
404 int FindObjScanFloat::handle_event()
406 *value = get_value();
407 center_text->update(*value);
409 plugin->send_configure_change();
413 void FindObjScanFloat::update(float v)
415 BC_FPot::update(*value = v);
416 center_text->update(v);
417 plugin->send_configure_change();
421 FindObjScanFloatText::FindObjScanFloatText(FindObjMain *plugin, FindObjWindow *gui,
422 int x, int y, float *value)
423 : BC_TextBox(x, y, xS(75), 1, *value)
425 this->plugin = plugin;
432 int FindObjScanFloatText::handle_event()
434 *value = atof(get_text());
435 center->update(*value);
437 plugin->send_configure_change();
442 FindObjDrawSceneBorder::FindObjDrawSceneBorder(FindObjMain *plugin, FindObjWindow *gui,
444 : BC_CheckBox(x, y, plugin->config.draw_scene_border, _("Draw scene border"))
447 this->plugin = plugin;
450 int FindObjDrawSceneBorder::handle_event()
452 plugin->config.draw_scene_border = get_value();
453 plugin->send_configure_change();
457 FindObjDrawObjectBorder::FindObjDrawObjectBorder(FindObjMain *plugin, FindObjWindow *gui,
459 : BC_CheckBox(x, y, plugin->config.draw_object_border, _("Draw object border"))
462 this->plugin = plugin;
465 int FindObjDrawObjectBorder::handle_event()
467 plugin->config.draw_object_border = get_value();
468 plugin->send_configure_change();
472 FindObjDrawReplaceBorder::FindObjDrawReplaceBorder(FindObjMain *plugin, FindObjWindow *gui,
474 : BC_CheckBox(x, y, plugin->config.draw_replace_border, _("Draw replace border"))
477 this->plugin = plugin;
480 int FindObjDrawReplaceBorder::handle_event()
482 plugin->config.draw_replace_border = get_value();
483 plugin->send_configure_change();
488 FindObjDrawKeypoints::FindObjDrawKeypoints(FindObjMain *plugin, FindObjWindow *gui,
490 : BC_CheckBox(x, y, plugin->config.draw_keypoints, _("Draw keypoints"))
493 this->plugin = plugin;
496 int FindObjDrawKeypoints::handle_event()
498 plugin->config.draw_keypoints = get_value();
499 plugin->send_configure_change();
504 FindObjReplace::FindObjReplace(FindObjMain *plugin, FindObjWindow *gui,
506 : BC_CheckBox(x, y, plugin->config.replace_object, _("Replace object"))
509 this->plugin = plugin;
512 int FindObjReplace::handle_event()
514 plugin->config.replace_object = get_value();
515 plugin->send_configure_change();
520 FindObjDragScene::FindObjDragScene(FindObjMain *plugin, FindObjWindow *gui, int x, int y,
521 float drag_x, float drag_y, float drag_w, float drag_h)
522 : DragCheckBox(plugin->server->mwindow, x, y, _("Drag"), &plugin->config.drag_scene,
523 drag_x, drag_y, drag_w, drag_h)
525 this->plugin = plugin;
529 FindObjDragScene::~FindObjDragScene()
533 int FindObjDragScene::handle_event()
535 int ret = DragCheckBox::handle_event();
536 plugin->send_configure_change();
540 Track *FindObjDragScene::get_drag_track()
542 return plugin->get_plugin_track();
545 int64_t FindObjDragScene::get_drag_position()
547 return plugin->get_source_position();
550 void FindObjDragScene::update_gui()
553 Track *track = get_drag_track();
554 int trk_w = track ? track->track_w : plugin->get_edl()->session->output_w;
555 int trk_h = track ? track->track_h : plugin->get_edl()->session->output_h;
556 float ctr_x = drag_x + drag_w/2, ctr_y = drag_y + drag_h/2;
557 gui->scene_x->update( plugin->config.scene_x = 100. * ctr_x / trk_w );
558 gui->scene_y->update( plugin->config.scene_y = 100. * ctr_y / trk_h );
559 gui->scene_w->update( plugin->config.scene_w = 100. * drag_w / trk_w );
560 gui->scene_h->update( plugin->config.scene_h = 100. * drag_h / trk_h );
561 plugin->send_configure_change();
564 FindObjDragObject::FindObjDragObject(FindObjMain *plugin, FindObjWindow *gui, int x, int y,
565 float drag_x, float drag_y, float drag_w, float drag_h)
566 : DragCheckBox(plugin->server->mwindow, x, y, _("Drag"), &plugin->config.drag_object,
567 drag_x, drag_y, drag_w, drag_h)
569 this->plugin = plugin;
573 FindObjDragObject::~FindObjDragObject()
577 int FindObjDragObject::handle_event()
579 int ret = DragCheckBox::handle_event();
580 plugin->send_configure_change();
584 Track *FindObjDragObject::get_drag_track()
586 return plugin->get_plugin_track();
589 int64_t FindObjDragObject::get_drag_position()
591 return plugin->get_source_position();
594 void FindObjDragObject::update_gui()
597 Track *track = get_drag_track();
598 int trk_w = track ? track->track_w : plugin->get_edl()->session->output_w;
599 int trk_h = track ? track->track_h : plugin->get_edl()->session->output_h;
600 float ctr_x = drag_x + drag_w/2, ctr_y = drag_y + drag_h/2;
601 gui->object_x->update( plugin->config.object_x = 100. * ctr_x / trk_w );
602 gui->object_y->update( plugin->config.object_y = 100. * ctr_y / trk_h );
603 gui->object_w->update( plugin->config.object_w = 100. * drag_w / trk_w );
604 gui->object_h->update( plugin->config.object_h = 100. * drag_h / trk_h );
605 plugin->send_configure_change();
608 FindObjDragReplace::FindObjDragReplace(FindObjMain *plugin, FindObjWindow *gui, int x, int y,
609 float drag_x, float drag_y, float drag_w, float drag_h)
610 : DragCheckBox(plugin->server->mwindow, x, y, _("Drag"), &plugin->config.drag_replace,
611 drag_x, drag_y, drag_w, drag_h)
613 this->plugin = plugin;
617 FindObjDragReplace::~FindObjDragReplace()
621 int FindObjDragReplace::handle_event()
623 int ret = DragCheckBox::handle_event();
624 plugin->send_configure_change();
627 Track *FindObjDragReplace::get_drag_track()
629 return plugin->get_plugin_track();
632 int64_t FindObjDragReplace::get_drag_position()
634 return plugin->get_source_position();
637 void FindObjDragReplace::update_gui()
640 Track *track = get_drag_track();
641 int trk_w = track ? track->track_w : plugin->get_edl()->session->output_w;
642 int trk_h = track ? track->track_h : plugin->get_edl()->session->output_h;
643 float ctr_x = drag_x + drag_w/2, ctr_y = drag_y + drag_h/2;
644 gui->replace_x->update( plugin->config.replace_x = 100. * ctr_x / trk_w );
645 gui->replace_y->update( plugin->config.replace_y = 100. * ctr_y / trk_h );
646 gui->replace_w->update( plugin->config.replace_w = 100. * drag_w / trk_w );
647 gui->replace_h->update( plugin->config.replace_h = 100. * drag_h / trk_h );
648 plugin->send_configure_change();
653 FindObjAlgorithm::FindObjAlgorithm(FindObjMain *plugin, FindObjWindow *gui, int x, int y)
654 : BC_PopupMenu(x, y, calculate_w(gui), to_text(plugin->config.algorithm))
656 this->plugin = plugin;
660 int FindObjAlgorithm::handle_event()
662 plugin->config.algorithm = from_text(get_text());
663 plugin->send_configure_change();
667 void FindObjAlgorithm::create_objects()
669 add_item(new BC_MenuItem(to_text(NO_ALGORITHM)));
671 add_item(new BC_MenuItem(to_text(ALGORITHM_SIFT)));
674 add_item(new BC_MenuItem(to_text(ALGORITHM_SURF)));
677 add_item(new BC_MenuItem(to_text(ALGORITHM_ORB)));
680 add_item(new BC_MenuItem(to_text(ALGORITHM_AKAZE)));
683 add_item(new BC_MenuItem(to_text(ALGORITHM_BRISK)));
687 int FindObjAlgorithm::from_text(char *text)
690 if(!strcmp(text, _("SIFT"))) return ALGORITHM_SIFT;
693 if(!strcmp(text, _("SURF"))) return ALGORITHM_SURF;
696 if(!strcmp(text, _("ORB"))) return ALGORITHM_ORB;
699 if(!strcmp(text, _("AKAZE"))) return ALGORITHM_AKAZE;
702 if(!strcmp(text, _("BRISK"))) return ALGORITHM_BRISK;
707 void FindObjAlgorithm::update(int mode)
709 set_text(to_text(mode));
712 char* FindObjAlgorithm::to_text(int mode)
716 case ALGORITHM_SIFT: return _("SIFT");
719 case ALGORITHM_SURF: return _("SURF");
722 case ALGORITHM_ORB: return _("ORB");
725 case ALGORITHM_AKAZE: return _("AKAZE");
728 case ALGORITHM_BRISK: return _("BRISK");
731 return _("Don't Calculate");
734 int FindObjAlgorithm::calculate_w(FindObjWindow *gui)
737 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(NO_ALGORITHM)));
739 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_SIFT)));
742 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_SURF)));
745 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_ORB)));
748 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_AKAZE)));
751 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_BRISK)));
753 return result + xS(50);
757 FindObjUseFlann::FindObjUseFlann(FindObjMain *plugin, FindObjWindow *gui,
759 : BC_CheckBox(x, y, plugin->config.use_flann, _("Use FLANN"))
762 this->plugin = plugin;
765 int FindObjUseFlann::handle_event()
767 plugin->config.use_flann = get_value();
768 plugin->send_configure_change();
772 FindObjDrawMatch::FindObjDrawMatch(FindObjMain *plugin, FindObjWindow *gui,
774 : BC_CheckBox(x, y, plugin->config.draw_match, _("Draw match"))
777 this->plugin = plugin;
780 int FindObjDrawMatch::handle_event()
782 plugin->config.draw_match = get_value();
783 plugin->send_configure_change();
787 FindObjAspect::FindObjAspect(FindObjMain *plugin, FindObjWindow *gui,
789 : BC_CheckBox(x, y, plugin->config.aspect, _("Aspect"))
792 this->plugin = plugin;
795 int FindObjAspect::handle_event()
797 plugin->config.aspect = get_value();
798 plugin->send_configure_change();
802 FindObjScale::FindObjScale(FindObjMain *plugin, FindObjWindow *gui,
804 : BC_CheckBox(x, y, plugin->config.scale, _("Scale"))
807 this->plugin = plugin;
810 int FindObjScale::handle_event()
812 plugin->config.scale = get_value();
813 plugin->send_configure_change();
817 FindObjRotate::FindObjRotate(FindObjMain *plugin, FindObjWindow *gui,
819 : BC_CheckBox(x, y, plugin->config.rotate, _("Rotate"))
822 this->plugin = plugin;
825 int FindObjRotate::handle_event()
827 plugin->config.rotate = get_value();
828 plugin->send_configure_change();
832 FindObjTranslate::FindObjTranslate(FindObjMain *plugin, FindObjWindow *gui,
834 : BC_CheckBox(x, y, plugin->config.translate, _("Translate"))
837 this->plugin = plugin;
840 int FindObjTranslate::handle_event()
842 plugin->config.translate = get_value();
843 plugin->send_configure_change();
847 FindObjMode::FindObjMode(FindObjMain *plugin, FindObjWindow *gui, int x, int y)
848 : BC_PopupMenu(x, y, calculate_w(gui), to_text(plugin->config.mode))
850 this->plugin = plugin;
854 int FindObjMode::handle_event()
856 plugin->config.mode = from_text(get_text());
857 plugin->send_configure_change();
861 void FindObjMode::create_objects()
863 add_item(new BC_MenuItem(to_text(MODE_SQUARE)));
864 add_item(new BC_MenuItem(to_text(MODE_RHOMBUS)));
865 add_item(new BC_MenuItem(to_text(MODE_RECTANGLE)));
866 add_item(new BC_MenuItem(to_text(MODE_PARALLELOGRAM)));
867 add_item(new BC_MenuItem(to_text(MODE_QUADRILATERAL)));
869 int FindObjMode::from_text(char *text)
871 if(!strcmp(text, _("Square"))) return MODE_SQUARE;
872 if(!strcmp(text, _("Rhombus"))) return MODE_RHOMBUS;
873 if(!strcmp(text, _("Rectangle"))) return MODE_RECTANGLE;
874 if(!strcmp(text, _("Parallelogram"))) return MODE_PARALLELOGRAM;
875 if(!strcmp(text, _("Quadrilateral"))) return MODE_QUADRILATERAL;
879 void FindObjMode::update(int mode)
881 set_text(to_text(mode));
884 char* FindObjMode::to_text(int mode)
887 case MODE_SQUARE: return _("Square");
888 case MODE_RHOMBUS: return _("Rhombus");
889 case MODE_RECTANGLE: return _("Rectangle");
890 case MODE_PARALLELOGRAM: return _("Parallelogram");
891 case MODE_QUADRILATERAL: return _("Quadrilateral");
896 int FindObjMode::calculate_w(FindObjWindow *gui)
899 for( int mode=MODE_NONE; mode<MODE_MAX; ++mode )
900 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(mode)));
901 return result + xS(50);
905 FindObjLayer::FindObjLayer(FindObjMain *plugin, FindObjWindow *gui,
906 int x, int y, int *value)
907 : BC_TumbleTextBox(gui, *value, MIN_LAYER, MAX_LAYER, x, y, calculate_w(gui))
909 this->plugin = plugin;
914 int FindObjLayer::handle_event()
916 *value = atoi(get_text());
917 plugin->send_configure_change();
921 int FindObjLayer::calculate_w(FindObjWindow *gui)
924 result = gui->get_text_width(MEDIUMFONT, "000");
925 return result + xS(50);
929 FindObjBlend::FindObjBlend(FindObjMain *plugin,
939 this->plugin = plugin;
943 int FindObjBlend::handle_event()
945 *value = (int)get_value();
946 plugin->send_configure_change();