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"
27 #include "findobjwindow.h"
29 #include "pluginserver.h"
34 FindObjWindow::FindObjWindow(FindObjMain *plugin)
35 : PluginClientWindow(plugin, 500, 660, 500, 660, 0)
37 this->plugin = plugin;
40 FindObjWindow::~FindObjWindow()
44 void FindObjWindow::create_objects()
46 int x = 10, y = 10, x1 = x, x2 = get_w()*1/3, x3 = get_w()*2/3;
47 plugin->load_configuration();
50 add_subwindow(title = new BC_Title(x1, y, _("Algorithm:")));
51 add_subwindow(algorithm = new FindObjAlgorithm(plugin, this,
52 x1 + title->get_w() + 10, y));
53 algorithm->create_objects();
54 add_subwindow(reset = new FindObjReset(plugin, this, get_w() - 15, y));
55 y += algorithm->get_h() + plugin->get_theme()->widget_border;
57 add_subwindow(use_flann = new FindObjUseFlann(plugin, this, x, y));
58 y += use_flann->get_h() + plugin->get_theme()->widget_border + 20;
61 add_subwindow(title = new BC_Title(x, y, _("Output/scene layer:")));
62 scene_layer = new FindObjLayer(plugin, this, x0, y,
63 &plugin->config.scene_layer);
64 scene_layer->create_objects();
65 y += scene_layer->get_h() + plugin->get_theme()->widget_border;
67 add_subwindow(title = new BC_Title(x, y, _("Object layer:")));
68 object_layer = new FindObjLayer(plugin, this, x0, y,
69 &plugin->config.object_layer);
70 object_layer->create_objects();
71 y += object_layer->get_h() + plugin->get_theme()->widget_border;
73 add_subwindow(title = new BC_Title(x, y, _("Replacement object layer:")));
74 replace_layer = new FindObjLayer(plugin, this, x0, y,
75 &plugin->config.replace_layer);
76 replace_layer->create_objects();
77 y += replace_layer->get_h() + plugin->get_theme()->widget_border + 10;
79 add_subwindow(title = new BC_Title(x+15, y, _("Units: 0 to 100 percent")));
83 add_subwindow(title = new BC_Title(x1, y + 10, _("Scene X:")));
84 Track *track = plugin->server->plugin->track;
85 int trk_w = track->track_w, trk_h = track->track_h;
86 float drag_w = trk_w * plugin->config.scene_w / 100.;
87 float drag_h = trk_h * plugin->config.scene_h / 100.;
88 float ctr_x = trk_w * plugin->config.scene_x / 100.;
89 float ctr_y = trk_h * plugin->config.scene_y / 100.;
90 float drag_x = ctr_x - drag_w/2, drag_y = ctr_y - drag_h/2;
91 drag_scene = new FindObjDragScene(plugin, this, x1+title->get_w()+10, y+5,
92 drag_x, drag_y, drag_w, drag_h);
93 add_subwindow(drag_scene);
94 drag_scene->create_objects();
95 y += title->get_h() + 15;
97 add_subwindow(scene_x = new FindObjScanFloat(plugin, this,
98 x1, y, &plugin->config.scene_x));
99 add_subwindow(scene_x_text = new FindObjScanFloatText(plugin, this,
100 x1 + scene_x->get_w() + 10, y + 10, &plugin->config.scene_x));
101 scene_x->center_text = scene_x_text;
102 scene_x_text->center = scene_x;
105 add_subwindow(title = new BC_Title(x1, y + 10, _("Scene Y:")));
106 y += title->get_h() + 15;
107 add_subwindow(scene_y = new FindObjScanFloat(plugin, this,
108 x1, y, &plugin->config.scene_y));
109 add_subwindow(scene_y_text = new FindObjScanFloatText(plugin, this,
110 x1 + scene_y->get_w() + 10, y + 10, &plugin->config.scene_y));
111 scene_y->center_text = scene_y_text;
112 scene_y_text->center = scene_y;
115 add_subwindow(new BC_Title(x1, y + 10, _("Scene W:")));
116 y += title->get_h() + 15;
117 add_subwindow(scene_w = new FindObjScanFloat(plugin, this,
118 x1, y, &plugin->config.scene_w));
119 add_subwindow(scene_w_text = new FindObjScanFloatText(plugin, this,
120 x1 + scene_w->get_w() + 10, y + 10, &plugin->config.scene_w));
121 scene_w->center_text = scene_w_text;
122 scene_w_text->center = scene_w;
125 add_subwindow(title = new BC_Title(x1, y + 10, _("Scene H:")));
126 y += title->get_h() + 15;
127 add_subwindow(scene_h = new FindObjScanFloat(plugin, this,
128 x1, y, &plugin->config.scene_h));
129 add_subwindow(scene_h_text = new FindObjScanFloatText(plugin, this,
130 x1 + scene_h->get_w() + 10, y + 10,
131 &plugin->config.scene_h));
132 scene_h->center_text = scene_h_text;
133 scene_h_text->center = scene_h;
136 add_subwindow(title = new BC_Title(x2, y + 10, _("Object X:")));
137 drag_w = trk_w * plugin->config.object_w / 100.;
138 drag_h = trk_h * plugin->config.object_h / 100.;
139 ctr_x = trk_w * plugin->config.object_x / 100.,
140 ctr_y = trk_h * plugin->config.object_y / 100.;
141 drag_x = ctr_x - drag_w/2; drag_y = ctr_y - drag_h/2;
142 drag_object = new FindObjDragObject(plugin, this, x2+title->get_w()+10, y+5,
143 drag_x, drag_y, drag_w, drag_h);
144 add_subwindow(drag_object);
145 drag_object->create_objects();
146 y += title->get_h() + 15;
148 add_subwindow(object_x = new FindObjScanFloat(plugin, this,
149 x2, y, &plugin->config.object_x));
150 add_subwindow(object_x_text = new FindObjScanFloatText(plugin, this,
151 x2 + object_x->get_w() + 10, y + 10, &plugin->config.object_x));
152 object_x->center_text = object_x_text;
153 object_x_text->center = object_x;
156 add_subwindow(title = new BC_Title(x2, y + 10, _("Object Y:")));
157 y += title->get_h() + 15;
158 add_subwindow(object_y = new FindObjScanFloat(plugin, this,
159 x2, y, &plugin->config.object_y));
160 add_subwindow(object_y_text = new FindObjScanFloatText(plugin, this,
161 x2 + object_y->get_w() + 10, y + 10, &plugin->config.object_y));
162 object_y->center_text = object_y_text;
163 object_y_text->center = object_y;
166 add_subwindow(new BC_Title(x2, y + 10, _("Object W:")));
167 y += title->get_h() + 15;
168 add_subwindow(object_w = new FindObjScanFloat(plugin, this,
169 x2, y, &plugin->config.object_w));
170 add_subwindow(object_w_text = new FindObjScanFloatText(plugin, this,
171 x2 + object_w->get_w() + 10, y + 10, &plugin->config.object_w));
172 object_w->center_text = object_w_text;
173 object_w_text->center = object_w;
176 add_subwindow(title = new BC_Title(x2, y + 10, _("Object H:")));
177 y += title->get_h() + 15;
178 add_subwindow(object_h = new FindObjScanFloat(plugin, this,
179 x2, y, &plugin->config.object_h));
180 add_subwindow(object_h_text = new FindObjScanFloatText(plugin, this,
181 x2 + object_h->get_w() + 10, y + 10,
182 &plugin->config.object_h));
183 object_h->center_text = object_h_text;
184 object_h_text->center = object_h;
187 add_subwindow(replace_object = new FindObjReplace(plugin, this,
188 x3, y - title->get_h() - 15));
190 add_subwindow(title = new BC_Title(x3, y + 10, _("Replace X:")));
191 drag_w = trk_w * plugin->config.replace_w / 100.;
192 drag_h = trk_h * plugin->config.replace_h / 100.;
193 ctr_x = trk_w * plugin->config.replace_x / 100.,
194 ctr_y = trk_h * plugin->config.replace_y / 100.;
195 drag_x = ctr_x - drag_w/2; drag_y = ctr_y - drag_h/2;
196 drag_replace = new FindObjDragReplace(plugin, this, x3+title->get_w()+10, y+5,
197 drag_x, drag_y, drag_w, drag_h);
198 add_subwindow(drag_replace);
199 drag_replace->create_objects();
200 y += title->get_h() + 15;
202 add_subwindow(replace_x = new FindObjScanFloat(plugin, this,
203 x3, y, &plugin->config.replace_x));
204 add_subwindow(replace_x_text = new FindObjScanFloatText(plugin, this,
205 x3 + replace_x->get_w() + 10, y + 10, &plugin->config.replace_x));
206 replace_x->center_text = replace_x_text;
207 replace_x_text->center = replace_x;
210 add_subwindow(title = new BC_Title(x3, y + 10, _("Replace Y:")));
211 y += title->get_h() + 15;
212 add_subwindow(replace_y = new FindObjScanFloat(plugin, this,
213 x3, y, &plugin->config.replace_y));
214 add_subwindow(replace_y_text = new FindObjScanFloatText(plugin, this,
215 x3 + replace_y->get_w() + 10, y + 10, &plugin->config.replace_y));
216 replace_y->center_text = replace_y_text;
217 replace_y_text->center = replace_y;
220 add_subwindow(new BC_Title(x3, y + 10, _("Replace W:")));
221 y += title->get_h() + 15;
222 add_subwindow(replace_w = new FindObjScanFloat(plugin, this,
223 x3, y, &plugin->config.replace_w));
224 add_subwindow(replace_w_text = new FindObjScanFloatText(plugin, this,
225 x3 + replace_w->get_w() + 10, y + 10, &plugin->config.replace_w));
226 replace_w->center_text = replace_w_text;
227 replace_w_text->center = replace_w;
230 add_subwindow(title = new BC_Title(x3, y + 10, _("Replace H:")));
231 y += title->get_h() + 15;
232 add_subwindow(replace_h = new FindObjScanFloat(plugin, this,
233 x3, y, &plugin->config.replace_h));
234 add_subwindow(replace_h_text = new FindObjScanFloatText(plugin, this,
235 x3 + replace_h->get_w() + 10, y + 10,
236 &plugin->config.replace_h));
237 replace_h->center_text = replace_h_text;
238 replace_h_text->center = replace_h;
241 add_subwindow(title = new BC_Title(x3, y + 10, _("Replace DX:")));
242 y += title->get_h() + 15;
243 add_subwindow(replace_dx = new FindObjScanFloat(plugin, this,
244 x3, y, &plugin->config.replace_dx, -100.f, 100.f));
245 add_subwindow(replace_dx_text = new FindObjScanFloatText(plugin, this,
246 x3 + replace_dx->get_w() + 10, y + 10, &plugin->config.replace_dx));
247 replace_dx->center_text = replace_dx_text;
248 replace_dx_text->center = replace_dx;
251 add_subwindow(title = new BC_Title(x3, y + 10, _("Replace DY:")));
252 y += title->get_h() + 15;
253 add_subwindow(replace_dy = new FindObjScanFloat(plugin, this,
254 x3, y, &plugin->config.replace_dy, -100.f, 100.f));
255 add_subwindow(replace_dy_text = new FindObjScanFloatText(plugin, this,
256 x3 + replace_dy->get_w() + 10, y + 10, &plugin->config.replace_dy));
257 replace_dy->center_text = replace_dy_text;
258 replace_dy_text->center = replace_dy;
261 add_subwindow(draw_keypoints = new FindObjDrawKeypoints(plugin, this, x, y));
262 y += draw_keypoints->get_h() + plugin->get_theme()->widget_border;
263 add_subwindow(draw_scene_border = new FindObjDrawSceneBorder(plugin, this, x, y));
264 y += draw_scene_border->get_h() + plugin->get_theme()->widget_border;
265 add_subwindow(draw_object_border = new FindObjDrawObjectBorder(plugin, this, x, y));
266 y += draw_object_border->get_h() + plugin->get_theme()->widget_border;
267 add_subwindow(draw_replace_border = new FindObjDrawReplaceBorder(plugin, this, x, y));
268 y += draw_object_border->get_h() + plugin->get_theme()->widget_border;
270 add_subwindow(title = new BC_Title(x, y + 10, _("Object blend amount:")));
271 add_subwindow(blend = new FindObjBlend(plugin,
272 x + title->get_w() + plugin->get_theme()->widget_border, y,
273 &plugin->config.blend));
279 FindObjReset::FindObjReset(FindObjMain *plugin, FindObjWindow *gui, int x, int y)
280 : BC_GenericButton(x - BC_GenericButton::calculate_w(gui, _("Reset")), y, _("Reset"))
282 this->plugin = plugin;
286 int FindObjReset::handle_event()
288 plugin->config.reset();
289 gui->drag_scene->drag_deactivate();
290 gui->drag_object->drag_deactivate();
291 gui->drag_replace->drag_deactivate();
293 plugin->send_configure_change();
297 void FindObjWindow::update_drag()
299 Track *track = drag_scene->get_drag_track();
300 int trk_w = track->track_w, trk_h = track->track_h;
301 drag_scene->drag_w = trk_w * plugin->config.scene_w/100.;
302 drag_scene->drag_h = trk_h * plugin->config.scene_h/100.;
303 drag_scene->drag_x = trk_w * plugin->config.scene_x/100. - drag_scene->drag_w/2;
304 drag_scene->drag_y = trk_h * plugin->config.scene_y/100. - drag_scene->drag_h/2;
305 track = drag_object->get_drag_track();
306 trk_w = track->track_w, trk_h = track->track_h;
307 drag_object->drag_w = trk_w * plugin->config.object_w/100.;
308 drag_object->drag_h = trk_h * plugin->config.object_h/100.;
309 drag_object->drag_x = trk_w * plugin->config.object_x/100. - drag_object->drag_w/2;
310 drag_object->drag_y = trk_h * plugin->config.object_y/100. - drag_object->drag_h/2;
311 track = drag_replace->get_drag_track();
312 trk_w = track->track_w, trk_h = track->track_h;
313 drag_replace->drag_w = trk_w * plugin->config.replace_w/100.;
314 drag_replace->drag_h = trk_h * plugin->config.replace_h/100.;
315 drag_replace->drag_x = trk_w * plugin->config.replace_x/100. - drag_replace->drag_w/2;
316 drag_replace->drag_y = trk_h * plugin->config.replace_y/100. - drag_replace->drag_h/2;
319 void FindObjWindow::update_gui()
322 FindObjConfig &conf = plugin->config;
323 algorithm->update(conf.algorithm);
324 use_flann->update(conf.use_flann);
325 drag_object->update(conf.drag_object);
326 object_x->update(conf.object_x);
327 object_x_text->update((float)conf.object_x);
328 object_y->update(conf.object_y);
329 object_y_text->update((float)conf.object_y);
330 object_w->update(conf.object_w);
331 object_w_text->update((float)conf.object_w);
332 object_h->update(conf.object_h);
333 object_h_text->update((float)conf.object_h);
334 drag_scene->update(conf.drag_scene);
335 scene_x->update(conf.scene_x);
336 scene_x_text->update((float)conf.scene_x);
337 scene_y->update(conf.scene_y);
338 scene_y_text->update((float)conf.scene_y);
339 scene_w->update(conf.scene_w);
340 scene_w_text->update((float)conf.scene_w);
341 scene_h->update(conf.scene_h);
342 scene_h_text->update((float)conf.scene_h);
343 drag_replace->update(conf.drag_replace);
344 replace_x->update(conf.replace_x);
345 replace_x_text->update((float)conf.replace_x);
346 replace_y->update(conf.replace_y);
347 replace_y_text->update((float)conf.replace_y);
348 replace_w->update(conf.replace_w);
349 replace_w_text->update((float)conf.replace_w);
350 replace_h->update(conf.replace_h);
351 replace_h_text->update((float)conf.replace_h);
352 replace_dx->update(conf.replace_dx);
353 replace_dx_text->update((float)conf.replace_dx);
354 replace_dx->update(conf.replace_dx);
355 replace_dx_text->update((float)conf.replace_dx);
356 draw_keypoints->update(conf.draw_keypoints);
357 draw_scene_border->update(conf.draw_scene_border);
358 replace_object->update(conf.replace_object);
359 draw_object_border->update(conf.draw_object_border);
360 draw_replace_border->update(conf.draw_replace_border);
361 object_layer->update( (int64_t)conf.object_layer);
362 replace_layer->update( (int64_t)conf.replace_layer);
363 scene_layer->update( (int64_t)conf.scene_layer);
364 blend->update( (int64_t)conf.blend);
367 FindObjScanFloat::FindObjScanFloat(FindObjMain *plugin, FindObjWindow *gui,
368 int x, int y, float *value, float min, float max)
369 : BC_FPot(x, y, *value, min, max)
371 this->plugin = plugin;
374 this->center_text = 0;
378 int FindObjScanFloat::handle_event()
380 *value = get_value();
381 center_text->update(*value);
383 plugin->send_configure_change();
387 void FindObjScanFloat::update(float v)
389 BC_FPot::update(*value = v);
390 center_text->update(v);
391 plugin->send_configure_change();
395 FindObjScanFloatText::FindObjScanFloatText(FindObjMain *plugin, FindObjWindow *gui,
396 int x, int y, float *value)
397 : BC_TextBox(x, y, 75, 1, *value)
399 this->plugin = plugin;
406 int FindObjScanFloatText::handle_event()
408 *value = atof(get_text());
409 center->update(*value);
411 plugin->send_configure_change();
416 FindObjDrawSceneBorder::FindObjDrawSceneBorder(FindObjMain *plugin, FindObjWindow *gui,
418 : BC_CheckBox(x, y, plugin->config.draw_scene_border, _("Draw scene border"))
421 this->plugin = plugin;
424 int FindObjDrawSceneBorder::handle_event()
426 plugin->config.draw_scene_border = get_value();
427 plugin->send_configure_change();
431 FindObjDrawObjectBorder::FindObjDrawObjectBorder(FindObjMain *plugin, FindObjWindow *gui,
433 : BC_CheckBox(x, y, plugin->config.draw_object_border, _("Draw object border"))
436 this->plugin = plugin;
439 int FindObjDrawObjectBorder::handle_event()
441 plugin->config.draw_object_border = get_value();
442 plugin->send_configure_change();
446 FindObjDrawReplaceBorder::FindObjDrawReplaceBorder(FindObjMain *plugin, FindObjWindow *gui,
448 : BC_CheckBox(x, y, plugin->config.draw_replace_border, _("Draw replace border"))
451 this->plugin = plugin;
454 int FindObjDrawReplaceBorder::handle_event()
456 plugin->config.draw_replace_border = get_value();
457 plugin->send_configure_change();
462 FindObjDrawKeypoints::FindObjDrawKeypoints(FindObjMain *plugin, FindObjWindow *gui,
464 : BC_CheckBox(x, y, plugin->config.draw_keypoints, _("Draw keypoints"))
467 this->plugin = plugin;
470 int FindObjDrawKeypoints::handle_event()
472 plugin->config.draw_keypoints = get_value();
473 plugin->send_configure_change();
478 FindObjReplace::FindObjReplace(FindObjMain *plugin, FindObjWindow *gui,
480 : BC_CheckBox(x, y, plugin->config.replace_object, _("Replace object"))
483 this->plugin = plugin;
486 int FindObjReplace::handle_event()
488 plugin->config.replace_object = get_value();
489 plugin->send_configure_change();
494 FindObjDragScene::FindObjDragScene(FindObjMain *plugin, FindObjWindow *gui, int x, int y,
495 float drag_x, float drag_y, float drag_w, float drag_h)
496 : DragCheckBox(plugin->server->mwindow, x, y, _("Drag"), &plugin->config.drag_scene,
497 drag_x, drag_y, drag_w, drag_h)
499 this->plugin = plugin;
503 FindObjDragScene::~FindObjDragScene()
507 int FindObjDragScene::handle_event()
509 int ret = DragCheckBox::handle_event();
510 plugin->send_configure_change();
513 Track *FindObjDragScene::get_drag_track()
515 return plugin->server->plugin->track;
517 int64_t FindObjDragScene::get_drag_position()
519 return plugin->get_source_position();
521 void FindObjDragScene::update_gui()
523 Track *track = get_drag_track();
524 int trk_w = track->track_w, trk_h = track->track_h;
525 float ctr_x = drag_x + drag_w/2, ctr_y = drag_y + drag_h/2;
526 gui->scene_x->update( plugin->config.scene_x = 100. * ctr_x / trk_w );
527 gui->scene_y->update( plugin->config.scene_y = 100. * ctr_y / trk_h );
528 gui->scene_w->update( plugin->config.scene_w = 100. * drag_w / trk_w );
529 gui->scene_h->update( plugin->config.scene_h = 100. * drag_h / trk_h );
530 plugin->send_configure_change();
533 FindObjDragObject::FindObjDragObject(FindObjMain *plugin, FindObjWindow *gui, int x, int y,
534 float drag_x, float drag_y, float drag_w, float drag_h)
535 : DragCheckBox(plugin->server->mwindow, x, y, _("Drag"), &plugin->config.drag_object,
536 drag_x, drag_y, drag_w, drag_h)
538 this->plugin = plugin;
542 FindObjDragObject::~FindObjDragObject()
546 int FindObjDragObject::handle_event()
548 int ret = DragCheckBox::handle_event();
549 plugin->send_configure_change();
552 Track *FindObjDragObject::get_drag_track()
554 return plugin->server->plugin->track;
556 int64_t FindObjDragObject::get_drag_position()
558 return plugin->get_source_position();
560 void FindObjDragObject::update_gui()
562 Track *track = get_drag_track();
563 int trk_w = track->track_w, trk_h = track->track_h;
564 float ctr_x = drag_x + drag_w/2, ctr_y = drag_y + drag_h/2;
565 gui->object_x->update( plugin->config.object_x = 100. * ctr_x / trk_w );
566 gui->object_y->update( plugin->config.object_y = 100. * ctr_y / trk_h );
567 gui->object_w->update( plugin->config.object_w = 100. * drag_w / trk_w );
568 gui->object_h->update( plugin->config.object_h = 100. * drag_h / trk_h );
569 plugin->send_configure_change();
572 FindObjDragReplace::FindObjDragReplace(FindObjMain *plugin, FindObjWindow *gui, int x, int y,
573 float drag_x, float drag_y, float drag_w, float drag_h)
574 : DragCheckBox(plugin->server->mwindow, x, y, _("Drag"), &plugin->config.drag_replace,
575 drag_x, drag_y, drag_w, drag_h)
577 this->plugin = plugin;
581 FindObjDragReplace::~FindObjDragReplace()
585 int FindObjDragReplace::handle_event()
587 int ret = DragCheckBox::handle_event();
588 plugin->send_configure_change();
591 Track *FindObjDragReplace::get_drag_track()
593 return plugin->server->plugin->track;
595 int64_t FindObjDragReplace::get_drag_position()
597 return plugin->get_source_position();
599 void FindObjDragReplace::update_gui()
601 Track *track = get_drag_track();
602 int trk_w = track->track_w, trk_h = track->track_h;
603 float ctr_x = drag_x + drag_w/2, ctr_y = drag_y + drag_h/2;
604 gui->replace_x->update( plugin->config.replace_x = 100. * ctr_x / trk_w );
605 gui->replace_y->update( plugin->config.replace_y = 100. * ctr_y / trk_h );
606 gui->replace_w->update( plugin->config.replace_w = 100. * drag_w / trk_w );
607 gui->replace_h->update( plugin->config.replace_h = 100. * drag_h / trk_h );
608 plugin->send_configure_change();
613 FindObjAlgorithm::FindObjAlgorithm(FindObjMain *plugin, FindObjWindow *gui, int x, int y)
614 : BC_PopupMenu(x, y, calculate_w(gui), to_text(plugin->config.algorithm))
616 this->plugin = plugin;
620 int FindObjAlgorithm::handle_event()
622 plugin->config.algorithm = from_text(get_text());
623 plugin->send_configure_change();
627 void FindObjAlgorithm::create_objects()
629 add_item(new BC_MenuItem(to_text(NO_ALGORITHM)));
631 add_item(new BC_MenuItem(to_text(ALGORITHM_SIFT)));
634 add_item(new BC_MenuItem(to_text(ALGORITHM_SURF)));
637 add_item(new BC_MenuItem(to_text(ALGORITHM_ORB)));
640 add_item(new BC_MenuItem(to_text(ALGORITHM_AKAZE)));
643 add_item(new BC_MenuItem(to_text(ALGORITHM_BRISK)));
647 int FindObjAlgorithm::from_text(char *text)
650 if(!strcmp(text, _("SIFT"))) return ALGORITHM_SIFT;
653 if(!strcmp(text, _("SURF"))) return ALGORITHM_SURF;
656 if(!strcmp(text, _("ORB"))) return ALGORITHM_ORB;
659 if(!strcmp(text, _("AKAZE"))) return ALGORITHM_AKAZE;
662 if(!strcmp(text, _("BRISK"))) return ALGORITHM_BRISK;
667 void FindObjAlgorithm::update(int mode)
669 set_text(to_text(mode));
672 char* FindObjAlgorithm::to_text(int mode)
676 case ALGORITHM_SIFT: return _("SIFT");
679 case ALGORITHM_SURF: return _("SURF");
682 case ALGORITHM_ORB: return _("ORB");
685 case ALGORITHM_AKAZE: return _("AKAZE");
688 case ALGORITHM_BRISK: return _("BRISK");
691 return _("Don't Calculate");
694 int FindObjAlgorithm::calculate_w(FindObjWindow *gui)
697 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(NO_ALGORITHM)));
699 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_SIFT)));
702 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_SURF)));
705 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_ORB)));
708 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_AKAZE)));
711 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_BRISK)));
717 FindObjUseFlann::FindObjUseFlann(FindObjMain *plugin, FindObjWindow *gui,
719 : BC_CheckBox(x, y, plugin->config.use_flann, _("Use FLANN"))
722 this->plugin = plugin;
725 int FindObjUseFlann::handle_event()
727 plugin->config.use_flann = get_value();
728 plugin->send_configure_change();
733 FindObjLayer::FindObjLayer(FindObjMain *plugin, FindObjWindow *gui,
734 int x, int y, int *value)
735 : BC_TumbleTextBox(gui, *value, MIN_LAYER, MAX_LAYER, x, y, calculate_w(gui))
737 this->plugin = plugin;
742 int FindObjLayer::handle_event()
744 *value = atoi(get_text());
745 plugin->send_configure_change();
749 int FindObjLayer::calculate_w(FindObjWindow *gui)
752 result = gui->get_text_width(MEDIUMFONT, "000");
757 FindObjBlend::FindObjBlend(FindObjMain *plugin,
767 this->plugin = plugin;
771 int FindObjBlend::handle_event()
773 *value = (int)get_value();
774 plugin->send_configure_change();