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, 500, 700, 500, 700, 0)
39 this->plugin = plugin;
42 FindObjWindow::~FindObjWindow()
46 void FindObjWindow::create_objects()
48 int x = 10, y = 10, x1 = x, x2 = get_w()*1/3, x3 = get_w()*2/3;
49 plugin->load_configuration();
52 add_subwindow(title = new BC_Title(x1, y, _("Mode:")));
53 add_subwindow(mode = new FindObjMode(plugin, this,
55 add_subwindow(reset = new FindObjReset(plugin, this, get_w()-15, y));
56 mode->create_objects();
57 y += mode->get_h() + 10;
59 add_subwindow(title = new BC_Title(x1, y, _("Algorithm:")));
60 add_subwindow(algorithm = new FindObjAlgorithm(plugin, this,
62 algorithm->create_objects();
63 y += algorithm->get_h() + plugin->get_theme()->widget_border;
64 add_subwindow(use_flann = new FindObjUseFlann(plugin, this, x, y));
65 y += use_flann->get_h() + 10;
68 add_subwindow(replace_object = new FindObjReplace(plugin, this,x3, y));
69 y += replace_object->get_h() + 10;
70 add_subwindow(draw_match = new FindObjDrawMatch(plugin, this, x3, y));
71 y += draw_match->get_h() + 10;
72 add_subwindow(aspect = new FindObjAspect(plugin, this, x3, y));
73 y += aspect->get_h() + 10;
74 add_subwindow(scale = new FindObjScale(plugin, this, x3, y));
75 y += scale->get_h() + 10;
76 add_subwindow(rotate = new FindObjRotate(plugin, this, x3, y));
77 y += rotate->get_h() + 10;
78 add_subwindow(translate = new FindObjTranslate(plugin, this, x3, y));
80 int x0 = x + 200; y = y1 + 10;
81 add_subwindow(title = new BC_Title(x, y, _("Output/scene layer:")));
82 scene_layer = new FindObjLayer(plugin, this, x0, y,
83 &plugin->config.scene_layer);
84 scene_layer->create_objects();
85 y += scene_layer->get_h() + plugin->get_theme()->widget_border;
87 add_subwindow(title = new BC_Title(x, y, _("Object layer:")));
88 object_layer = new FindObjLayer(plugin, this, x0, y,
89 &plugin->config.object_layer);
90 object_layer->create_objects();
91 y += object_layer->get_h() + plugin->get_theme()->widget_border;
93 add_subwindow(title = new BC_Title(x, y, _("Replacement object layer:")));
94 replace_layer = new FindObjLayer(plugin, this, x0, y,
95 &plugin->config.replace_layer);
96 replace_layer->create_objects();
97 y += replace_layer->get_h() + plugin->get_theme()->widget_border + 10;
100 add_subwindow(title = new BC_Title(x+15, y, _("Units: 0 to 100 percent")));
104 add_subwindow(title = new BC_Title(x1, y + 10, _("Scene X:")));
105 Track *track = plugin->server->plugin->track;
106 int trk_w = track->track_w, trk_h = track->track_h;
107 float drag_w = trk_w * plugin->config.scene_w / 100.;
108 float drag_h = trk_h * plugin->config.scene_h / 100.;
109 float ctr_x = trk_w * plugin->config.scene_x / 100.;
110 float ctr_y = trk_h * plugin->config.scene_y / 100.;
111 float drag_x = ctr_x - drag_w/2, drag_y = ctr_y - drag_h/2;
112 drag_scene = new FindObjDragScene(plugin, this, x1+title->get_w()+10, y+5,
113 drag_x, drag_y, drag_w, drag_h);
114 add_subwindow(drag_scene);
115 drag_scene->create_objects();
116 y += title->get_h() + 15;
118 add_subwindow(scene_x = new FindObjScanFloat(plugin, this,
119 x1, y, &plugin->config.scene_x));
120 add_subwindow(scene_x_text = new FindObjScanFloatText(plugin, this,
121 x1 + scene_x->get_w() + 10, y + 10, &plugin->config.scene_x));
122 scene_x->center_text = scene_x_text;
123 scene_x_text->center = scene_x;
126 add_subwindow(title = new BC_Title(x1, y + 10, _("Scene Y:")));
127 y += title->get_h() + 15;
128 add_subwindow(scene_y = new FindObjScanFloat(plugin, this,
129 x1, y, &plugin->config.scene_y));
130 add_subwindow(scene_y_text = new FindObjScanFloatText(plugin, this,
131 x1 + scene_y->get_w() + 10, y + 10, &plugin->config.scene_y));
132 scene_y->center_text = scene_y_text;
133 scene_y_text->center = scene_y;
136 add_subwindow(new BC_Title(x1, y + 10, _("Scene W:")));
137 y += title->get_h() + 15;
138 add_subwindow(scene_w = new FindObjScanFloat(plugin, this,
139 x1, y, &plugin->config.scene_w));
140 add_subwindow(scene_w_text = new FindObjScanFloatText(plugin, this,
141 x1 + scene_w->get_w() + 10, y + 10, &plugin->config.scene_w));
142 scene_w->center_text = scene_w_text;
143 scene_w_text->center = scene_w;
146 add_subwindow(title = new BC_Title(x1, y + 10, _("Scene H:")));
147 y += title->get_h() + 15;
148 add_subwindow(scene_h = new FindObjScanFloat(plugin, this,
149 x1, y, &plugin->config.scene_h));
150 add_subwindow(scene_h_text = new FindObjScanFloatText(plugin, this,
151 x1 + scene_h->get_w() + 10, y + 10,
152 &plugin->config.scene_h));
153 scene_h->center_text = scene_h_text;
154 scene_h_text->center = scene_h;
157 add_subwindow(title = new BC_Title(x2, y + 10, _("Object X:")));
158 drag_w = trk_w * plugin->config.object_w / 100.;
159 drag_h = trk_h * plugin->config.object_h / 100.;
160 ctr_x = trk_w * plugin->config.object_x / 100.,
161 ctr_y = trk_h * plugin->config.object_y / 100.;
162 drag_x = ctr_x - drag_w/2; drag_y = ctr_y - drag_h/2;
163 drag_object = new FindObjDragObject(plugin, this, x2+title->get_w()+10, y+5,
164 drag_x, drag_y, drag_w, drag_h);
165 add_subwindow(drag_object);
166 drag_object->create_objects();
167 y += title->get_h() + 15;
169 add_subwindow(object_x = new FindObjScanFloat(plugin, this,
170 x2, y, &plugin->config.object_x));
171 add_subwindow(object_x_text = new FindObjScanFloatText(plugin, this,
172 x2 + object_x->get_w() + 10, y + 10, &plugin->config.object_x));
173 object_x->center_text = object_x_text;
174 object_x_text->center = object_x;
177 add_subwindow(title = new BC_Title(x2, y + 10, _("Object Y:")));
178 y += title->get_h() + 15;
179 add_subwindow(object_y = new FindObjScanFloat(plugin, this,
180 x2, y, &plugin->config.object_y));
181 add_subwindow(object_y_text = new FindObjScanFloatText(plugin, this,
182 x2 + object_y->get_w() + 10, y + 10, &plugin->config.object_y));
183 object_y->center_text = object_y_text;
184 object_y_text->center = object_y;
187 add_subwindow(new BC_Title(x2, y + 10, _("Object W:")));
188 y += title->get_h() + 15;
189 add_subwindow(object_w = new FindObjScanFloat(plugin, this,
190 x2, y, &plugin->config.object_w));
191 add_subwindow(object_w_text = new FindObjScanFloatText(plugin, this,
192 x2 + object_w->get_w() + 10, y + 10, &plugin->config.object_w));
193 object_w->center_text = object_w_text;
194 object_w_text->center = object_w;
197 add_subwindow(title = new BC_Title(x2, y + 10, _("Object H:")));
198 y += title->get_h() + 15;
199 add_subwindow(object_h = new FindObjScanFloat(plugin, this,
200 x2, y, &plugin->config.object_h));
201 add_subwindow(object_h_text = new FindObjScanFloatText(plugin, this,
202 x2 + object_h->get_w() + 10, y + 10,
203 &plugin->config.object_h));
204 object_h->center_text = object_h_text;
205 object_h_text->center = object_h;
208 add_subwindow(title = new BC_Title(x3, y + 10, _("Replace X:")));
209 drag_w = trk_w * plugin->config.replace_w / 100.;
210 drag_h = trk_h * plugin->config.replace_h / 100.;
211 ctr_x = trk_w * plugin->config.replace_x / 100.,
212 ctr_y = trk_h * plugin->config.replace_y / 100.;
213 drag_x = ctr_x - drag_w/2; drag_y = ctr_y - drag_h/2;
214 drag_replace = new FindObjDragReplace(plugin, this, x3+title->get_w()+10, y+5,
215 drag_x, drag_y, drag_w, drag_h);
216 add_subwindow(drag_replace);
217 drag_replace->create_objects();
218 y += title->get_h() + 15;
220 add_subwindow(replace_x = new FindObjScanFloat(plugin, this,
221 x3, y, &plugin->config.replace_x));
222 add_subwindow(replace_x_text = new FindObjScanFloatText(plugin, this,
223 x3 + replace_x->get_w() + 10, y + 10, &plugin->config.replace_x));
224 replace_x->center_text = replace_x_text;
225 replace_x_text->center = replace_x;
228 add_subwindow(title = new BC_Title(x3, y + 10, _("Replace Y:")));
229 y += title->get_h() + 15;
230 add_subwindow(replace_y = new FindObjScanFloat(plugin, this,
231 x3, y, &plugin->config.replace_y));
232 add_subwindow(replace_y_text = new FindObjScanFloatText(plugin, this,
233 x3 + replace_y->get_w() + 10, y + 10, &plugin->config.replace_y));
234 replace_y->center_text = replace_y_text;
235 replace_y_text->center = replace_y;
238 add_subwindow(new BC_Title(x3, y + 10, _("Replace W:")));
239 y += title->get_h() + 15;
240 add_subwindow(replace_w = new FindObjScanFloat(plugin, this,
241 x3, y, &plugin->config.replace_w));
242 add_subwindow(replace_w_text = new FindObjScanFloatText(plugin, this,
243 x3 + replace_w->get_w() + 10, y + 10, &plugin->config.replace_w));
244 replace_w->center_text = replace_w_text;
245 replace_w_text->center = replace_w;
248 add_subwindow(title = new BC_Title(x3, y + 10, _("Replace H:")));
249 y += title->get_h() + 15;
250 add_subwindow(replace_h = new FindObjScanFloat(plugin, this,
251 x3, y, &plugin->config.replace_h));
252 add_subwindow(replace_h_text = new FindObjScanFloatText(plugin, this,
253 x3 + replace_h->get_w() + 10, y + 10,
254 &plugin->config.replace_h));
255 replace_h->center_text = replace_h_text;
256 replace_h_text->center = replace_h;
259 add_subwindow(title = new BC_Title(x3, y + 10, _("Replace DX:")));
260 y += title->get_h() + 15;
261 add_subwindow(replace_dx = new FindObjScanFloat(plugin, this,
262 x3, y, &plugin->config.replace_dx, -100.f, 100.f));
263 add_subwindow(replace_dx_text = new FindObjScanFloatText(plugin, this,
264 x3 + replace_dx->get_w() + 10, y + 10, &plugin->config.replace_dx));
265 replace_dx->center_text = replace_dx_text;
266 replace_dx_text->center = replace_dx;
269 add_subwindow(title = new BC_Title(x3, y + 10, _("Replace DY:")));
270 y += title->get_h() + 15;
271 add_subwindow(replace_dy = new FindObjScanFloat(plugin, this,
272 x3, y, &plugin->config.replace_dy, -100.f, 100.f));
273 add_subwindow(replace_dy_text = new FindObjScanFloatText(plugin, this,
274 x3 + replace_dy->get_w() + 10, y + 10, &plugin->config.replace_dy));
275 replace_dy->center_text = replace_dy_text;
276 replace_dy_text->center = replace_dy;
279 add_subwindow(draw_keypoints = new FindObjDrawKeypoints(plugin, this, x, y));
280 y += draw_keypoints->get_h() + plugin->get_theme()->widget_border;
281 add_subwindow(draw_scene_border = new FindObjDrawSceneBorder(plugin, this, x, y));
282 y += draw_scene_border->get_h() + plugin->get_theme()->widget_border;
283 add_subwindow(draw_object_border = new FindObjDrawObjectBorder(plugin, this, x, y));
284 y += draw_object_border->get_h() + plugin->get_theme()->widget_border;
285 add_subwindow(draw_replace_border = new FindObjDrawReplaceBorder(plugin, this, x, y));
286 y += draw_object_border->get_h() + plugin->get_theme()->widget_border;
288 add_subwindow(title = new BC_Title(x, y + 10, _("Object blend amount:")));
289 add_subwindow(blend = new FindObjBlend(plugin,
290 x + title->get_w() + plugin->get_theme()->widget_border, y,
291 &plugin->config.blend));
297 FindObjReset::FindObjReset(FindObjMain *plugin, FindObjWindow *gui, int x, int y)
298 : BC_GenericButton(x - BC_GenericButton::calculate_w(gui, _("Reset")), y, _("Reset"))
300 this->plugin = plugin;
304 int FindObjReset::handle_event()
306 plugin->config.reset();
307 gui->drag_scene->drag_deactivate();
308 gui->drag_object->drag_deactivate();
309 gui->drag_replace->drag_deactivate();
311 plugin->send_configure_change();
315 void FindObjWindow::update_drag()
317 Track *track = drag_scene->get_drag_track();
318 int trk_w = track->track_w, trk_h = track->track_h;
319 drag_scene->drag_w = trk_w * plugin->config.scene_w/100.;
320 drag_scene->drag_h = trk_h * plugin->config.scene_h/100.;
321 drag_scene->drag_x = trk_w * plugin->config.scene_x/100. - drag_scene->drag_w/2;
322 drag_scene->drag_y = trk_h * plugin->config.scene_y/100. - drag_scene->drag_h/2;
323 track = drag_object->get_drag_track();
324 trk_w = track->track_w, trk_h = track->track_h;
325 drag_object->drag_w = trk_w * plugin->config.object_w/100.;
326 drag_object->drag_h = trk_h * plugin->config.object_h/100.;
327 drag_object->drag_x = trk_w * plugin->config.object_x/100. - drag_object->drag_w/2;
328 drag_object->drag_y = trk_h * plugin->config.object_y/100. - drag_object->drag_h/2;
329 track = drag_replace->get_drag_track();
330 trk_w = track->track_w, trk_h = track->track_h;
331 drag_replace->drag_w = trk_w * plugin->config.replace_w/100.;
332 drag_replace->drag_h = trk_h * plugin->config.replace_h/100.;
333 drag_replace->drag_x = trk_w * plugin->config.replace_x/100. - drag_replace->drag_w/2;
334 drag_replace->drag_y = trk_h * plugin->config.replace_y/100. - drag_replace->drag_h/2;
337 void FindObjWindow::update_gui()
340 FindObjConfig &conf = plugin->config;
341 algorithm->update(conf.algorithm);
342 use_flann->update(conf.use_flann);
343 draw_match->update(conf.draw_match);
344 aspect->update(conf.aspect);
345 scale->update(conf.scale);
346 rotate->update(conf.rotate);
347 translate->update(conf.translate);
348 drag_object->update(conf.drag_object);
349 object_x->update(conf.object_x);
350 object_x_text->update((float)conf.object_x);
351 object_y->update(conf.object_y);
352 object_y_text->update((float)conf.object_y);
353 object_w->update(conf.object_w);
354 object_w_text->update((float)conf.object_w);
355 object_h->update(conf.object_h);
356 object_h_text->update((float)conf.object_h);
357 drag_scene->update(conf.drag_scene);
358 scene_x->update(conf.scene_x);
359 scene_x_text->update((float)conf.scene_x);
360 scene_y->update(conf.scene_y);
361 scene_y_text->update((float)conf.scene_y);
362 scene_w->update(conf.scene_w);
363 scene_w_text->update((float)conf.scene_w);
364 scene_h->update(conf.scene_h);
365 scene_h_text->update((float)conf.scene_h);
366 drag_replace->update(conf.drag_replace);
367 replace_x->update(conf.replace_x);
368 replace_x_text->update((float)conf.replace_x);
369 replace_y->update(conf.replace_y);
370 replace_y_text->update((float)conf.replace_y);
371 replace_w->update(conf.replace_w);
372 replace_w_text->update((float)conf.replace_w);
373 replace_h->update(conf.replace_h);
374 replace_h_text->update((float)conf.replace_h);
375 replace_dx->update(conf.replace_dx);
376 replace_dx_text->update((float)conf.replace_dx);
377 replace_dx->update(conf.replace_dx);
378 replace_dx_text->update((float)conf.replace_dx);
379 draw_keypoints->update(conf.draw_keypoints);
380 draw_scene_border->update(conf.draw_scene_border);
381 replace_object->update(conf.replace_object);
382 draw_object_border->update(conf.draw_object_border);
383 draw_replace_border->update(conf.draw_replace_border);
384 object_layer->update( (int64_t)conf.object_layer);
385 replace_layer->update( (int64_t)conf.replace_layer);
386 scene_layer->update( (int64_t)conf.scene_layer);
387 blend->update( (int64_t)conf.blend);
390 FindObjScanFloat::FindObjScanFloat(FindObjMain *plugin, FindObjWindow *gui,
391 int x, int y, float *value, float min, float max)
392 : BC_FPot(x, y, *value, min, max)
394 this->plugin = plugin;
397 this->center_text = 0;
401 int FindObjScanFloat::handle_event()
403 *value = get_value();
404 center_text->update(*value);
406 plugin->send_configure_change();
410 void FindObjScanFloat::update(float v)
412 BC_FPot::update(*value = v);
413 center_text->update(v);
414 plugin->send_configure_change();
418 FindObjScanFloatText::FindObjScanFloatText(FindObjMain *plugin, FindObjWindow *gui,
419 int x, int y, float *value)
420 : BC_TextBox(x, y, 75, 1, *value)
422 this->plugin = plugin;
429 int FindObjScanFloatText::handle_event()
431 *value = atof(get_text());
432 center->update(*value);
434 plugin->send_configure_change();
439 FindObjDrawSceneBorder::FindObjDrawSceneBorder(FindObjMain *plugin, FindObjWindow *gui,
441 : BC_CheckBox(x, y, plugin->config.draw_scene_border, _("Draw scene border"))
444 this->plugin = plugin;
447 int FindObjDrawSceneBorder::handle_event()
449 plugin->config.draw_scene_border = get_value();
450 plugin->send_configure_change();
454 FindObjDrawObjectBorder::FindObjDrawObjectBorder(FindObjMain *plugin, FindObjWindow *gui,
456 : BC_CheckBox(x, y, plugin->config.draw_object_border, _("Draw object border"))
459 this->plugin = plugin;
462 int FindObjDrawObjectBorder::handle_event()
464 plugin->config.draw_object_border = get_value();
465 plugin->send_configure_change();
469 FindObjDrawReplaceBorder::FindObjDrawReplaceBorder(FindObjMain *plugin, FindObjWindow *gui,
471 : BC_CheckBox(x, y, plugin->config.draw_replace_border, _("Draw replace border"))
474 this->plugin = plugin;
477 int FindObjDrawReplaceBorder::handle_event()
479 plugin->config.draw_replace_border = get_value();
480 plugin->send_configure_change();
485 FindObjDrawKeypoints::FindObjDrawKeypoints(FindObjMain *plugin, FindObjWindow *gui,
487 : BC_CheckBox(x, y, plugin->config.draw_keypoints, _("Draw keypoints"))
490 this->plugin = plugin;
493 int FindObjDrawKeypoints::handle_event()
495 plugin->config.draw_keypoints = get_value();
496 plugin->send_configure_change();
501 FindObjReplace::FindObjReplace(FindObjMain *plugin, FindObjWindow *gui,
503 : BC_CheckBox(x, y, plugin->config.replace_object, _("Replace object"))
506 this->plugin = plugin;
509 int FindObjReplace::handle_event()
511 plugin->config.replace_object = get_value();
512 plugin->send_configure_change();
517 FindObjDragScene::FindObjDragScene(FindObjMain *plugin, FindObjWindow *gui, int x, int y,
518 float drag_x, float drag_y, float drag_w, float drag_h)
519 : DragCheckBox(plugin->server->mwindow, x, y, _("Drag"), &plugin->config.drag_scene,
520 drag_x, drag_y, drag_w, drag_h)
522 this->plugin = plugin;
526 FindObjDragScene::~FindObjDragScene()
530 int FindObjDragScene::handle_event()
532 int ret = DragCheckBox::handle_event();
533 plugin->send_configure_change();
536 Track *FindObjDragScene::get_drag_track()
538 return !plugin->server->plugin ? 0 :
539 plugin->server->plugin->track;
541 int64_t FindObjDragScene::get_drag_position()
543 return plugin->get_source_position();
545 void FindObjDragScene::update_gui()
548 Track *track = get_drag_track();
549 int trk_w = track ? track->track_w : plugin->get_edl()->session->output_w;
550 int trk_h = track ? track->track_h : plugin->get_edl()->session->output_h;
551 float ctr_x = drag_x + drag_w/2, ctr_y = drag_y + drag_h/2;
552 gui->scene_x->update( plugin->config.scene_x = 100. * ctr_x / trk_w );
553 gui->scene_y->update( plugin->config.scene_y = 100. * ctr_y / trk_h );
554 gui->scene_w->update( plugin->config.scene_w = 100. * drag_w / trk_w );
555 gui->scene_h->update( plugin->config.scene_h = 100. * drag_h / trk_h );
556 plugin->send_configure_change();
559 FindObjDragObject::FindObjDragObject(FindObjMain *plugin, FindObjWindow *gui, int x, int y,
560 float drag_x, float drag_y, float drag_w, float drag_h)
561 : DragCheckBox(plugin->server->mwindow, x, y, _("Drag"), &plugin->config.drag_object,
562 drag_x, drag_y, drag_w, drag_h)
564 this->plugin = plugin;
568 FindObjDragObject::~FindObjDragObject()
572 int FindObjDragObject::handle_event()
574 int ret = DragCheckBox::handle_event();
575 plugin->send_configure_change();
578 Track *FindObjDragObject::get_drag_track()
580 return !plugin->server->plugin ? 0 :
581 plugin->server->plugin->track;
583 int64_t FindObjDragObject::get_drag_position()
585 return plugin->get_source_position();
587 void FindObjDragObject::update_gui()
590 Track *track = get_drag_track();
591 int trk_w = track ? track->track_w : plugin->get_edl()->session->output_w;
592 int trk_h = track ? track->track_h : plugin->get_edl()->session->output_h;
593 float ctr_x = drag_x + drag_w/2, ctr_y = drag_y + drag_h/2;
594 gui->object_x->update( plugin->config.object_x = 100. * ctr_x / trk_w );
595 gui->object_y->update( plugin->config.object_y = 100. * ctr_y / trk_h );
596 gui->object_w->update( plugin->config.object_w = 100. * drag_w / trk_w );
597 gui->object_h->update( plugin->config.object_h = 100. * drag_h / trk_h );
598 plugin->send_configure_change();
601 FindObjDragReplace::FindObjDragReplace(FindObjMain *plugin, FindObjWindow *gui, int x, int y,
602 float drag_x, float drag_y, float drag_w, float drag_h)
603 : DragCheckBox(plugin->server->mwindow, x, y, _("Drag"), &plugin->config.drag_replace,
604 drag_x, drag_y, drag_w, drag_h)
606 this->plugin = plugin;
610 FindObjDragReplace::~FindObjDragReplace()
614 int FindObjDragReplace::handle_event()
616 int ret = DragCheckBox::handle_event();
617 plugin->send_configure_change();
620 Track *FindObjDragReplace::get_drag_track()
622 return !plugin->server->plugin ? 0 :
623 plugin->server->plugin->track;
625 int64_t FindObjDragReplace::get_drag_position()
627 return plugin->get_source_position();
629 void FindObjDragReplace::update_gui()
632 Track *track = get_drag_track();
633 int trk_w = track ? track->track_w : plugin->get_edl()->session->output_w;
634 int trk_h = track ? track->track_h : plugin->get_edl()->session->output_h;
635 float ctr_x = drag_x + drag_w/2, ctr_y = drag_y + drag_h/2;
636 gui->replace_x->update( plugin->config.replace_x = 100. * ctr_x / trk_w );
637 gui->replace_y->update( plugin->config.replace_y = 100. * ctr_y / trk_h );
638 gui->replace_w->update( plugin->config.replace_w = 100. * drag_w / trk_w );
639 gui->replace_h->update( plugin->config.replace_h = 100. * drag_h / trk_h );
640 plugin->send_configure_change();
645 FindObjAlgorithm::FindObjAlgorithm(FindObjMain *plugin, FindObjWindow *gui, int x, int y)
646 : BC_PopupMenu(x, y, calculate_w(gui), to_text(plugin->config.algorithm))
648 this->plugin = plugin;
652 int FindObjAlgorithm::handle_event()
654 plugin->config.algorithm = from_text(get_text());
655 plugin->send_configure_change();
659 void FindObjAlgorithm::create_objects()
661 add_item(new BC_MenuItem(to_text(NO_ALGORITHM)));
663 add_item(new BC_MenuItem(to_text(ALGORITHM_SIFT)));
666 add_item(new BC_MenuItem(to_text(ALGORITHM_SURF)));
669 add_item(new BC_MenuItem(to_text(ALGORITHM_ORB)));
672 add_item(new BC_MenuItem(to_text(ALGORITHM_AKAZE)));
675 add_item(new BC_MenuItem(to_text(ALGORITHM_BRISK)));
679 int FindObjAlgorithm::from_text(char *text)
682 if(!strcmp(text, _("SIFT"))) return ALGORITHM_SIFT;
685 if(!strcmp(text, _("SURF"))) return ALGORITHM_SURF;
688 if(!strcmp(text, _("ORB"))) return ALGORITHM_ORB;
691 if(!strcmp(text, _("AKAZE"))) return ALGORITHM_AKAZE;
694 if(!strcmp(text, _("BRISK"))) return ALGORITHM_BRISK;
699 void FindObjAlgorithm::update(int mode)
701 set_text(to_text(mode));
704 char* FindObjAlgorithm::to_text(int mode)
708 case ALGORITHM_SIFT: return _("SIFT");
711 case ALGORITHM_SURF: return _("SURF");
714 case ALGORITHM_ORB: return _("ORB");
717 case ALGORITHM_AKAZE: return _("AKAZE");
720 case ALGORITHM_BRISK: return _("BRISK");
723 return _("Don't Calculate");
726 int FindObjAlgorithm::calculate_w(FindObjWindow *gui)
729 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(NO_ALGORITHM)));
731 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_SIFT)));
734 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_SURF)));
737 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_ORB)));
740 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_AKAZE)));
743 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_BRISK)));
749 FindObjUseFlann::FindObjUseFlann(FindObjMain *plugin, FindObjWindow *gui,
751 : BC_CheckBox(x, y, plugin->config.use_flann, _("Use FLANN"))
754 this->plugin = plugin;
757 int FindObjUseFlann::handle_event()
759 plugin->config.use_flann = get_value();
760 plugin->send_configure_change();
764 FindObjDrawMatch::FindObjDrawMatch(FindObjMain *plugin, FindObjWindow *gui,
766 : BC_CheckBox(x, y, plugin->config.draw_match, _("Draw match"))
769 this->plugin = plugin;
772 int FindObjDrawMatch::handle_event()
774 plugin->config.draw_match = get_value();
775 plugin->send_configure_change();
779 FindObjAspect::FindObjAspect(FindObjMain *plugin, FindObjWindow *gui,
781 : BC_CheckBox(x, y, plugin->config.aspect, _("Aspect"))
784 this->plugin = plugin;
787 int FindObjAspect::handle_event()
789 plugin->config.aspect = get_value();
790 plugin->send_configure_change();
794 FindObjScale::FindObjScale(FindObjMain *plugin, FindObjWindow *gui,
796 : BC_CheckBox(x, y, plugin->config.scale, _("Scale"))
799 this->plugin = plugin;
802 int FindObjScale::handle_event()
804 plugin->config.scale = get_value();
805 plugin->send_configure_change();
809 FindObjRotate::FindObjRotate(FindObjMain *plugin, FindObjWindow *gui,
811 : BC_CheckBox(x, y, plugin->config.rotate, _("Rotate"))
814 this->plugin = plugin;
817 int FindObjRotate::handle_event()
819 plugin->config.rotate = get_value();
820 plugin->send_configure_change();
824 FindObjTranslate::FindObjTranslate(FindObjMain *plugin, FindObjWindow *gui,
826 : BC_CheckBox(x, y, plugin->config.translate, _("Translate"))
829 this->plugin = plugin;
832 int FindObjTranslate::handle_event()
834 plugin->config.translate = get_value();
835 plugin->send_configure_change();
839 FindObjMode::FindObjMode(FindObjMain *plugin, FindObjWindow *gui, int x, int y)
840 : BC_PopupMenu(x, y, calculate_w(gui), to_text(plugin->config.mode))
842 this->plugin = plugin;
846 int FindObjMode::handle_event()
848 plugin->config.mode = from_text(get_text());
849 plugin->send_configure_change();
853 void FindObjMode::create_objects()
855 add_item(new BC_MenuItem(to_text(MODE_SQUARE)));
856 add_item(new BC_MenuItem(to_text(MODE_RHOMBUS)));
857 add_item(new BC_MenuItem(to_text(MODE_RECTANGLE)));
858 add_item(new BC_MenuItem(to_text(MODE_PARALLELOGRAM)));
859 add_item(new BC_MenuItem(to_text(MODE_QUADRILATERAL)));
861 int FindObjMode::from_text(char *text)
863 if(!strcmp(text, _("Square"))) return MODE_SQUARE;
864 if(!strcmp(text, _("Rhombus"))) return MODE_RHOMBUS;
865 if(!strcmp(text, _("Rectangle"))) return MODE_RECTANGLE;
866 if(!strcmp(text, _("Parallelogram"))) return MODE_PARALLELOGRAM;
867 if(!strcmp(text, _("Quadrilateral"))) return MODE_QUADRILATERAL;
871 void FindObjMode::update(int mode)
873 set_text(to_text(mode));
876 char* FindObjMode::to_text(int mode)
879 case MODE_SQUARE: return _("Square");
880 case MODE_RHOMBUS: return _("Rhombus");
881 case MODE_RECTANGLE: return _("Rectangle");
882 case MODE_PARALLELOGRAM: return _("Parallelogram");
883 case MODE_QUADRILATERAL: return _("Quadrilateral");
888 int FindObjMode::calculate_w(FindObjWindow *gui)
891 for( int mode=MODE_NONE; mode<MODE_MAX; ++mode )
892 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(mode)));
897 FindObjLayer::FindObjLayer(FindObjMain *plugin, FindObjWindow *gui,
898 int x, int y, int *value)
899 : BC_TumbleTextBox(gui, *value, MIN_LAYER, MAX_LAYER, x, y, calculate_w(gui))
901 this->plugin = plugin;
906 int FindObjLayer::handle_event()
908 *value = atoi(get_text());
909 plugin->send_configure_change();
913 int FindObjLayer::calculate_w(FindObjWindow *gui)
916 result = gui->get_text_width(MEDIUMFONT, "000");
921 FindObjBlend::FindObjBlend(FindObjMain *plugin,
931 this->plugin = plugin;
935 int FindObjBlend::handle_event()
937 *value = (int)get_value();
938 plugin->send_configure_change();