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, 700, 500, 700, 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, _("Mode:")));
51 add_subwindow(mode = new FindObjMode(plugin, this,
53 add_subwindow(reset = new FindObjReset(plugin, this, get_w()-15, y));
54 mode->create_objects();
55 y += mode->get_h() + 10;
57 add_subwindow(title = new BC_Title(x1, y, _("Algorithm:")));
58 add_subwindow(algorithm = new FindObjAlgorithm(plugin, this,
60 algorithm->create_objects();
61 y += algorithm->get_h() + plugin->get_theme()->widget_border;
62 add_subwindow(use_flann = new FindObjUseFlann(plugin, this, x, y));
63 y += use_flann->get_h() + 10;
66 add_subwindow(replace_object = new FindObjReplace(plugin, this,x3, y));
67 y += replace_object->get_h() + 10;
68 add_subwindow(draw_match = new FindObjDrawMatch(plugin, this, x3, y));
69 y += draw_match->get_h() + 10;
70 add_subwindow(aspect = new FindObjAspect(plugin, this, x3, y));
71 y += aspect->get_h() + 10;
72 add_subwindow(scale = new FindObjScale(plugin, this, x3, y));
73 y += scale->get_h() + 10;
74 add_subwindow(rotate = new FindObjRotate(plugin, this, x3, y));
75 y += rotate->get_h() + 10;
76 add_subwindow(translate = new FindObjTranslate(plugin, this, x3, y));
78 int x0 = x + 200; y = y1 + 10;
79 add_subwindow(title = new BC_Title(x, y, _("Output/scene layer:")));
80 scene_layer = new FindObjLayer(plugin, this, x0, y,
81 &plugin->config.scene_layer);
82 scene_layer->create_objects();
83 y += scene_layer->get_h() + plugin->get_theme()->widget_border;
85 add_subwindow(title = new BC_Title(x, y, _("Object layer:")));
86 object_layer = new FindObjLayer(plugin, this, x0, y,
87 &plugin->config.object_layer);
88 object_layer->create_objects();
89 y += object_layer->get_h() + plugin->get_theme()->widget_border;
91 add_subwindow(title = new BC_Title(x, y, _("Replacement object layer:")));
92 replace_layer = new FindObjLayer(plugin, this, x0, y,
93 &plugin->config.replace_layer);
94 replace_layer->create_objects();
95 y += replace_layer->get_h() + plugin->get_theme()->widget_border + 10;
98 add_subwindow(title = new BC_Title(x+15, y, _("Units: 0 to 100 percent")));
102 add_subwindow(title = new BC_Title(x1, y + 10, _("Scene X:")));
103 Track *track = plugin->server->plugin->track;
104 int trk_w = track->track_w, trk_h = track->track_h;
105 float drag_w = trk_w * plugin->config.scene_w / 100.;
106 float drag_h = trk_h * plugin->config.scene_h / 100.;
107 float ctr_x = trk_w * plugin->config.scene_x / 100.;
108 float ctr_y = trk_h * plugin->config.scene_y / 100.;
109 float drag_x = ctr_x - drag_w/2, drag_y = ctr_y - drag_h/2;
110 drag_scene = new FindObjDragScene(plugin, this, x1+title->get_w()+10, y+5,
111 drag_x, drag_y, drag_w, drag_h);
112 add_subwindow(drag_scene);
113 drag_scene->create_objects();
114 y += title->get_h() + 15;
116 add_subwindow(scene_x = new FindObjScanFloat(plugin, this,
117 x1, y, &plugin->config.scene_x));
118 add_subwindow(scene_x_text = new FindObjScanFloatText(plugin, this,
119 x1 + scene_x->get_w() + 10, y + 10, &plugin->config.scene_x));
120 scene_x->center_text = scene_x_text;
121 scene_x_text->center = scene_x;
124 add_subwindow(title = new BC_Title(x1, y + 10, _("Scene Y:")));
125 y += title->get_h() + 15;
126 add_subwindow(scene_y = new FindObjScanFloat(plugin, this,
127 x1, y, &plugin->config.scene_y));
128 add_subwindow(scene_y_text = new FindObjScanFloatText(plugin, this,
129 x1 + scene_y->get_w() + 10, y + 10, &plugin->config.scene_y));
130 scene_y->center_text = scene_y_text;
131 scene_y_text->center = scene_y;
134 add_subwindow(new BC_Title(x1, y + 10, _("Scene W:")));
135 y += title->get_h() + 15;
136 add_subwindow(scene_w = new FindObjScanFloat(plugin, this,
137 x1, y, &plugin->config.scene_w));
138 add_subwindow(scene_w_text = new FindObjScanFloatText(plugin, this,
139 x1 + scene_w->get_w() + 10, y + 10, &plugin->config.scene_w));
140 scene_w->center_text = scene_w_text;
141 scene_w_text->center = scene_w;
144 add_subwindow(title = new BC_Title(x1, y + 10, _("Scene H:")));
145 y += title->get_h() + 15;
146 add_subwindow(scene_h = new FindObjScanFloat(plugin, this,
147 x1, y, &plugin->config.scene_h));
148 add_subwindow(scene_h_text = new FindObjScanFloatText(plugin, this,
149 x1 + scene_h->get_w() + 10, y + 10,
150 &plugin->config.scene_h));
151 scene_h->center_text = scene_h_text;
152 scene_h_text->center = scene_h;
155 add_subwindow(title = new BC_Title(x2, y + 10, _("Object X:")));
156 drag_w = trk_w * plugin->config.object_w / 100.;
157 drag_h = trk_h * plugin->config.object_h / 100.;
158 ctr_x = trk_w * plugin->config.object_x / 100.,
159 ctr_y = trk_h * plugin->config.object_y / 100.;
160 drag_x = ctr_x - drag_w/2; drag_y = ctr_y - drag_h/2;
161 drag_object = new FindObjDragObject(plugin, this, x2+title->get_w()+10, y+5,
162 drag_x, drag_y, drag_w, drag_h);
163 add_subwindow(drag_object);
164 drag_object->create_objects();
165 y += title->get_h() + 15;
167 add_subwindow(object_x = new FindObjScanFloat(plugin, this,
168 x2, y, &plugin->config.object_x));
169 add_subwindow(object_x_text = new FindObjScanFloatText(plugin, this,
170 x2 + object_x->get_w() + 10, y + 10, &plugin->config.object_x));
171 object_x->center_text = object_x_text;
172 object_x_text->center = object_x;
175 add_subwindow(title = new BC_Title(x2, y + 10, _("Object Y:")));
176 y += title->get_h() + 15;
177 add_subwindow(object_y = new FindObjScanFloat(plugin, this,
178 x2, y, &plugin->config.object_y));
179 add_subwindow(object_y_text = new FindObjScanFloatText(plugin, this,
180 x2 + object_y->get_w() + 10, y + 10, &plugin->config.object_y));
181 object_y->center_text = object_y_text;
182 object_y_text->center = object_y;
185 add_subwindow(new BC_Title(x2, y + 10, _("Object W:")));
186 y += title->get_h() + 15;
187 add_subwindow(object_w = new FindObjScanFloat(plugin, this,
188 x2, y, &plugin->config.object_w));
189 add_subwindow(object_w_text = new FindObjScanFloatText(plugin, this,
190 x2 + object_w->get_w() + 10, y + 10, &plugin->config.object_w));
191 object_w->center_text = object_w_text;
192 object_w_text->center = object_w;
195 add_subwindow(title = new BC_Title(x2, y + 10, _("Object H:")));
196 y += title->get_h() + 15;
197 add_subwindow(object_h = new FindObjScanFloat(plugin, this,
198 x2, y, &plugin->config.object_h));
199 add_subwindow(object_h_text = new FindObjScanFloatText(plugin, this,
200 x2 + object_h->get_w() + 10, y + 10,
201 &plugin->config.object_h));
202 object_h->center_text = object_h_text;
203 object_h_text->center = object_h;
206 add_subwindow(title = new BC_Title(x3, y + 10, _("Replace X:")));
207 drag_w = trk_w * plugin->config.replace_w / 100.;
208 drag_h = trk_h * plugin->config.replace_h / 100.;
209 ctr_x = trk_w * plugin->config.replace_x / 100.,
210 ctr_y = trk_h * plugin->config.replace_y / 100.;
211 drag_x = ctr_x - drag_w/2; drag_y = ctr_y - drag_h/2;
212 drag_replace = new FindObjDragReplace(plugin, this, x3+title->get_w()+10, y+5,
213 drag_x, drag_y, drag_w, drag_h);
214 add_subwindow(drag_replace);
215 drag_replace->create_objects();
216 y += title->get_h() + 15;
218 add_subwindow(replace_x = new FindObjScanFloat(plugin, this,
219 x3, y, &plugin->config.replace_x));
220 add_subwindow(replace_x_text = new FindObjScanFloatText(plugin, this,
221 x3 + replace_x->get_w() + 10, y + 10, &plugin->config.replace_x));
222 replace_x->center_text = replace_x_text;
223 replace_x_text->center = replace_x;
226 add_subwindow(title = new BC_Title(x3, y + 10, _("Replace Y:")));
227 y += title->get_h() + 15;
228 add_subwindow(replace_y = new FindObjScanFloat(plugin, this,
229 x3, y, &plugin->config.replace_y));
230 add_subwindow(replace_y_text = new FindObjScanFloatText(plugin, this,
231 x3 + replace_y->get_w() + 10, y + 10, &plugin->config.replace_y));
232 replace_y->center_text = replace_y_text;
233 replace_y_text->center = replace_y;
236 add_subwindow(new BC_Title(x3, y + 10, _("Replace W:")));
237 y += title->get_h() + 15;
238 add_subwindow(replace_w = new FindObjScanFloat(plugin, this,
239 x3, y, &plugin->config.replace_w));
240 add_subwindow(replace_w_text = new FindObjScanFloatText(plugin, this,
241 x3 + replace_w->get_w() + 10, y + 10, &plugin->config.replace_w));
242 replace_w->center_text = replace_w_text;
243 replace_w_text->center = replace_w;
246 add_subwindow(title = new BC_Title(x3, y + 10, _("Replace H:")));
247 y += title->get_h() + 15;
248 add_subwindow(replace_h = new FindObjScanFloat(plugin, this,
249 x3, y, &plugin->config.replace_h));
250 add_subwindow(replace_h_text = new FindObjScanFloatText(plugin, this,
251 x3 + replace_h->get_w() + 10, y + 10,
252 &plugin->config.replace_h));
253 replace_h->center_text = replace_h_text;
254 replace_h_text->center = replace_h;
257 add_subwindow(title = new BC_Title(x3, y + 10, _("Replace DX:")));
258 y += title->get_h() + 15;
259 add_subwindow(replace_dx = new FindObjScanFloat(plugin, this,
260 x3, y, &plugin->config.replace_dx, -100.f, 100.f));
261 add_subwindow(replace_dx_text = new FindObjScanFloatText(plugin, this,
262 x3 + replace_dx->get_w() + 10, y + 10, &plugin->config.replace_dx));
263 replace_dx->center_text = replace_dx_text;
264 replace_dx_text->center = replace_dx;
267 add_subwindow(title = new BC_Title(x3, y + 10, _("Replace DY:")));
268 y += title->get_h() + 15;
269 add_subwindow(replace_dy = new FindObjScanFloat(plugin, this,
270 x3, y, &plugin->config.replace_dy, -100.f, 100.f));
271 add_subwindow(replace_dy_text = new FindObjScanFloatText(plugin, this,
272 x3 + replace_dy->get_w() + 10, y + 10, &plugin->config.replace_dy));
273 replace_dy->center_text = replace_dy_text;
274 replace_dy_text->center = replace_dy;
277 add_subwindow(draw_keypoints = new FindObjDrawKeypoints(plugin, this, x, y));
278 y += draw_keypoints->get_h() + plugin->get_theme()->widget_border;
279 add_subwindow(draw_scene_border = new FindObjDrawSceneBorder(plugin, this, x, y));
280 y += draw_scene_border->get_h() + plugin->get_theme()->widget_border;
281 add_subwindow(draw_object_border = new FindObjDrawObjectBorder(plugin, this, x, y));
282 y += draw_object_border->get_h() + plugin->get_theme()->widget_border;
283 add_subwindow(draw_replace_border = new FindObjDrawReplaceBorder(plugin, this, x, y));
284 y += draw_object_border->get_h() + plugin->get_theme()->widget_border;
286 add_subwindow(title = new BC_Title(x, y + 10, _("Object blend amount:")));
287 add_subwindow(blend = new FindObjBlend(plugin,
288 x + title->get_w() + plugin->get_theme()->widget_border, y,
289 &plugin->config.blend));
295 FindObjReset::FindObjReset(FindObjMain *plugin, FindObjWindow *gui, int x, int y)
296 : BC_GenericButton(x - BC_GenericButton::calculate_w(gui, _("Reset")), y, _("Reset"))
298 this->plugin = plugin;
302 int FindObjReset::handle_event()
304 plugin->config.reset();
305 gui->drag_scene->drag_deactivate();
306 gui->drag_object->drag_deactivate();
307 gui->drag_replace->drag_deactivate();
309 plugin->send_configure_change();
313 void FindObjWindow::update_drag()
315 Track *track = drag_scene->get_drag_track();
316 int trk_w = track->track_w, trk_h = track->track_h;
317 drag_scene->drag_w = trk_w * plugin->config.scene_w/100.;
318 drag_scene->drag_h = trk_h * plugin->config.scene_h/100.;
319 drag_scene->drag_x = trk_w * plugin->config.scene_x/100. - drag_scene->drag_w/2;
320 drag_scene->drag_y = trk_h * plugin->config.scene_y/100. - drag_scene->drag_h/2;
321 track = drag_object->get_drag_track();
322 trk_w = track->track_w, trk_h = track->track_h;
323 drag_object->drag_w = trk_w * plugin->config.object_w/100.;
324 drag_object->drag_h = trk_h * plugin->config.object_h/100.;
325 drag_object->drag_x = trk_w * plugin->config.object_x/100. - drag_object->drag_w/2;
326 drag_object->drag_y = trk_h * plugin->config.object_y/100. - drag_object->drag_h/2;
327 track = drag_replace->get_drag_track();
328 trk_w = track->track_w, trk_h = track->track_h;
329 drag_replace->drag_w = trk_w * plugin->config.replace_w/100.;
330 drag_replace->drag_h = trk_h * plugin->config.replace_h/100.;
331 drag_replace->drag_x = trk_w * plugin->config.replace_x/100. - drag_replace->drag_w/2;
332 drag_replace->drag_y = trk_h * plugin->config.replace_y/100. - drag_replace->drag_h/2;
335 void FindObjWindow::update_gui()
338 FindObjConfig &conf = plugin->config;
339 algorithm->update(conf.algorithm);
340 use_flann->update(conf.use_flann);
341 draw_match->update(conf.draw_match);
342 aspect->update(conf.aspect);
343 scale->update(conf.scale);
344 rotate->update(conf.rotate);
345 translate->update(conf.translate);
346 drag_object->update(conf.drag_object);
347 object_x->update(conf.object_x);
348 object_x_text->update((float)conf.object_x);
349 object_y->update(conf.object_y);
350 object_y_text->update((float)conf.object_y);
351 object_w->update(conf.object_w);
352 object_w_text->update((float)conf.object_w);
353 object_h->update(conf.object_h);
354 object_h_text->update((float)conf.object_h);
355 drag_scene->update(conf.drag_scene);
356 scene_x->update(conf.scene_x);
357 scene_x_text->update((float)conf.scene_x);
358 scene_y->update(conf.scene_y);
359 scene_y_text->update((float)conf.scene_y);
360 scene_w->update(conf.scene_w);
361 scene_w_text->update((float)conf.scene_w);
362 scene_h->update(conf.scene_h);
363 scene_h_text->update((float)conf.scene_h);
364 drag_replace->update(conf.drag_replace);
365 replace_x->update(conf.replace_x);
366 replace_x_text->update((float)conf.replace_x);
367 replace_y->update(conf.replace_y);
368 replace_y_text->update((float)conf.replace_y);
369 replace_w->update(conf.replace_w);
370 replace_w_text->update((float)conf.replace_w);
371 replace_h->update(conf.replace_h);
372 replace_h_text->update((float)conf.replace_h);
373 replace_dx->update(conf.replace_dx);
374 replace_dx_text->update((float)conf.replace_dx);
375 replace_dx->update(conf.replace_dx);
376 replace_dx_text->update((float)conf.replace_dx);
377 draw_keypoints->update(conf.draw_keypoints);
378 draw_scene_border->update(conf.draw_scene_border);
379 replace_object->update(conf.replace_object);
380 draw_object_border->update(conf.draw_object_border);
381 draw_replace_border->update(conf.draw_replace_border);
382 object_layer->update( (int64_t)conf.object_layer);
383 replace_layer->update( (int64_t)conf.replace_layer);
384 scene_layer->update( (int64_t)conf.scene_layer);
385 blend->update( (int64_t)conf.blend);
388 FindObjScanFloat::FindObjScanFloat(FindObjMain *plugin, FindObjWindow *gui,
389 int x, int y, float *value, float min, float max)
390 : BC_FPot(x, y, *value, min, max)
392 this->plugin = plugin;
395 this->center_text = 0;
399 int FindObjScanFloat::handle_event()
401 *value = get_value();
402 center_text->update(*value);
404 plugin->send_configure_change();
408 void FindObjScanFloat::update(float v)
410 BC_FPot::update(*value = v);
411 center_text->update(v);
412 plugin->send_configure_change();
416 FindObjScanFloatText::FindObjScanFloatText(FindObjMain *plugin, FindObjWindow *gui,
417 int x, int y, float *value)
418 : BC_TextBox(x, y, 75, 1, *value)
420 this->plugin = plugin;
427 int FindObjScanFloatText::handle_event()
429 *value = atof(get_text());
430 center->update(*value);
432 plugin->send_configure_change();
437 FindObjDrawSceneBorder::FindObjDrawSceneBorder(FindObjMain *plugin, FindObjWindow *gui,
439 : BC_CheckBox(x, y, plugin->config.draw_scene_border, _("Draw scene border"))
442 this->plugin = plugin;
445 int FindObjDrawSceneBorder::handle_event()
447 plugin->config.draw_scene_border = get_value();
448 plugin->send_configure_change();
452 FindObjDrawObjectBorder::FindObjDrawObjectBorder(FindObjMain *plugin, FindObjWindow *gui,
454 : BC_CheckBox(x, y, plugin->config.draw_object_border, _("Draw object border"))
457 this->plugin = plugin;
460 int FindObjDrawObjectBorder::handle_event()
462 plugin->config.draw_object_border = get_value();
463 plugin->send_configure_change();
467 FindObjDrawReplaceBorder::FindObjDrawReplaceBorder(FindObjMain *plugin, FindObjWindow *gui,
469 : BC_CheckBox(x, y, plugin->config.draw_replace_border, _("Draw replace border"))
472 this->plugin = plugin;
475 int FindObjDrawReplaceBorder::handle_event()
477 plugin->config.draw_replace_border = get_value();
478 plugin->send_configure_change();
483 FindObjDrawKeypoints::FindObjDrawKeypoints(FindObjMain *plugin, FindObjWindow *gui,
485 : BC_CheckBox(x, y, plugin->config.draw_keypoints, _("Draw keypoints"))
488 this->plugin = plugin;
491 int FindObjDrawKeypoints::handle_event()
493 plugin->config.draw_keypoints = get_value();
494 plugin->send_configure_change();
499 FindObjReplace::FindObjReplace(FindObjMain *plugin, FindObjWindow *gui,
501 : BC_CheckBox(x, y, plugin->config.replace_object, _("Replace object"))
504 this->plugin = plugin;
507 int FindObjReplace::handle_event()
509 plugin->config.replace_object = get_value();
510 plugin->send_configure_change();
515 FindObjDragScene::FindObjDragScene(FindObjMain *plugin, FindObjWindow *gui, int x, int y,
516 float drag_x, float drag_y, float drag_w, float drag_h)
517 : DragCheckBox(plugin->server->mwindow, x, y, _("Drag"), &plugin->config.drag_scene,
518 drag_x, drag_y, drag_w, drag_h)
520 this->plugin = plugin;
524 FindObjDragScene::~FindObjDragScene()
528 int FindObjDragScene::handle_event()
530 int ret = DragCheckBox::handle_event();
531 plugin->send_configure_change();
534 Track *FindObjDragScene::get_drag_track()
536 return plugin->server->plugin->track;
538 int64_t FindObjDragScene::get_drag_position()
540 return plugin->get_source_position();
542 void FindObjDragScene::update_gui()
545 Track *track = get_drag_track();
546 int trk_w = track->track_w, trk_h = track->track_h;
547 float ctr_x = drag_x + drag_w/2, ctr_y = drag_y + drag_h/2;
548 gui->scene_x->update( plugin->config.scene_x = 100. * ctr_x / trk_w );
549 gui->scene_y->update( plugin->config.scene_y = 100. * ctr_y / trk_h );
550 gui->scene_w->update( plugin->config.scene_w = 100. * drag_w / trk_w );
551 gui->scene_h->update( plugin->config.scene_h = 100. * drag_h / trk_h );
552 plugin->send_configure_change();
555 FindObjDragObject::FindObjDragObject(FindObjMain *plugin, FindObjWindow *gui, int x, int y,
556 float drag_x, float drag_y, float drag_w, float drag_h)
557 : DragCheckBox(plugin->server->mwindow, x, y, _("Drag"), &plugin->config.drag_object,
558 drag_x, drag_y, drag_w, drag_h)
560 this->plugin = plugin;
564 FindObjDragObject::~FindObjDragObject()
568 int FindObjDragObject::handle_event()
570 int ret = DragCheckBox::handle_event();
571 plugin->send_configure_change();
574 Track *FindObjDragObject::get_drag_track()
576 return plugin->server->plugin->track;
578 int64_t FindObjDragObject::get_drag_position()
580 return plugin->get_source_position();
582 void FindObjDragObject::update_gui()
585 Track *track = get_drag_track();
586 int trk_w = track->track_w, trk_h = track->track_h;
587 float ctr_x = drag_x + drag_w/2, ctr_y = drag_y + drag_h/2;
588 gui->object_x->update( plugin->config.object_x = 100. * ctr_x / trk_w );
589 gui->object_y->update( plugin->config.object_y = 100. * ctr_y / trk_h );
590 gui->object_w->update( plugin->config.object_w = 100. * drag_w / trk_w );
591 gui->object_h->update( plugin->config.object_h = 100. * drag_h / trk_h );
592 plugin->send_configure_change();
595 FindObjDragReplace::FindObjDragReplace(FindObjMain *plugin, FindObjWindow *gui, int x, int y,
596 float drag_x, float drag_y, float drag_w, float drag_h)
597 : DragCheckBox(plugin->server->mwindow, x, y, _("Drag"), &plugin->config.drag_replace,
598 drag_x, drag_y, drag_w, drag_h)
600 this->plugin = plugin;
604 FindObjDragReplace::~FindObjDragReplace()
608 int FindObjDragReplace::handle_event()
610 int ret = DragCheckBox::handle_event();
611 plugin->send_configure_change();
614 Track *FindObjDragReplace::get_drag_track()
616 return plugin->server->plugin->track;
618 int64_t FindObjDragReplace::get_drag_position()
620 return plugin->get_source_position();
622 void FindObjDragReplace::update_gui()
625 Track *track = get_drag_track();
626 int trk_w = track->track_w, trk_h = track->track_h;
627 float ctr_x = drag_x + drag_w/2, ctr_y = drag_y + drag_h/2;
628 gui->replace_x->update( plugin->config.replace_x = 100. * ctr_x / trk_w );
629 gui->replace_y->update( plugin->config.replace_y = 100. * ctr_y / trk_h );
630 gui->replace_w->update( plugin->config.replace_w = 100. * drag_w / trk_w );
631 gui->replace_h->update( plugin->config.replace_h = 100. * drag_h / trk_h );
632 plugin->send_configure_change();
637 FindObjAlgorithm::FindObjAlgorithm(FindObjMain *plugin, FindObjWindow *gui, int x, int y)
638 : BC_PopupMenu(x, y, calculate_w(gui), to_text(plugin->config.algorithm))
640 this->plugin = plugin;
644 int FindObjAlgorithm::handle_event()
646 plugin->config.algorithm = from_text(get_text());
647 plugin->send_configure_change();
651 void FindObjAlgorithm::create_objects()
653 add_item(new BC_MenuItem(to_text(NO_ALGORITHM)));
655 add_item(new BC_MenuItem(to_text(ALGORITHM_SIFT)));
658 add_item(new BC_MenuItem(to_text(ALGORITHM_SURF)));
661 add_item(new BC_MenuItem(to_text(ALGORITHM_ORB)));
664 add_item(new BC_MenuItem(to_text(ALGORITHM_AKAZE)));
667 add_item(new BC_MenuItem(to_text(ALGORITHM_BRISK)));
671 int FindObjAlgorithm::from_text(char *text)
674 if(!strcmp(text, _("SIFT"))) return ALGORITHM_SIFT;
677 if(!strcmp(text, _("SURF"))) return ALGORITHM_SURF;
680 if(!strcmp(text, _("ORB"))) return ALGORITHM_ORB;
683 if(!strcmp(text, _("AKAZE"))) return ALGORITHM_AKAZE;
686 if(!strcmp(text, _("BRISK"))) return ALGORITHM_BRISK;
691 void FindObjAlgorithm::update(int mode)
693 set_text(to_text(mode));
696 char* FindObjAlgorithm::to_text(int mode)
700 case ALGORITHM_SIFT: return _("SIFT");
703 case ALGORITHM_SURF: return _("SURF");
706 case ALGORITHM_ORB: return _("ORB");
709 case ALGORITHM_AKAZE: return _("AKAZE");
712 case ALGORITHM_BRISK: return _("BRISK");
715 return _("Don't Calculate");
718 int FindObjAlgorithm::calculate_w(FindObjWindow *gui)
721 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(NO_ALGORITHM)));
723 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_SIFT)));
726 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_SURF)));
729 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_ORB)));
732 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_AKAZE)));
735 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_BRISK)));
741 FindObjUseFlann::FindObjUseFlann(FindObjMain *plugin, FindObjWindow *gui,
743 : BC_CheckBox(x, y, plugin->config.use_flann, _("Use FLANN"))
746 this->plugin = plugin;
749 int FindObjUseFlann::handle_event()
751 plugin->config.use_flann = get_value();
752 plugin->send_configure_change();
756 FindObjDrawMatch::FindObjDrawMatch(FindObjMain *plugin, FindObjWindow *gui,
758 : BC_CheckBox(x, y, plugin->config.draw_match, _("Draw match"))
761 this->plugin = plugin;
764 int FindObjDrawMatch::handle_event()
766 plugin->config.draw_match = get_value();
767 plugin->send_configure_change();
771 FindObjAspect::FindObjAspect(FindObjMain *plugin, FindObjWindow *gui,
773 : BC_CheckBox(x, y, plugin->config.aspect, _("Aspect"))
776 this->plugin = plugin;
779 int FindObjAspect::handle_event()
781 plugin->config.aspect = get_value();
782 plugin->send_configure_change();
786 FindObjScale::FindObjScale(FindObjMain *plugin, FindObjWindow *gui,
788 : BC_CheckBox(x, y, plugin->config.scale, _("Scale"))
791 this->plugin = plugin;
794 int FindObjScale::handle_event()
796 plugin->config.scale = get_value();
797 plugin->send_configure_change();
801 FindObjRotate::FindObjRotate(FindObjMain *plugin, FindObjWindow *gui,
803 : BC_CheckBox(x, y, plugin->config.rotate, _("Rotate"))
806 this->plugin = plugin;
809 int FindObjRotate::handle_event()
811 plugin->config.rotate = get_value();
812 plugin->send_configure_change();
816 FindObjTranslate::FindObjTranslate(FindObjMain *plugin, FindObjWindow *gui,
818 : BC_CheckBox(x, y, plugin->config.translate, _("Translate"))
821 this->plugin = plugin;
824 int FindObjTranslate::handle_event()
826 plugin->config.translate = get_value();
827 plugin->send_configure_change();
831 FindObjMode::FindObjMode(FindObjMain *plugin, FindObjWindow *gui, int x, int y)
832 : BC_PopupMenu(x, y, calculate_w(gui), to_text(plugin->config.mode))
834 this->plugin = plugin;
838 int FindObjMode::handle_event()
840 plugin->config.mode = from_text(get_text());
841 plugin->send_configure_change();
845 void FindObjMode::create_objects()
847 add_item(new BC_MenuItem(to_text(MODE_SQUARE)));
848 add_item(new BC_MenuItem(to_text(MODE_RHOMBUS)));
849 add_item(new BC_MenuItem(to_text(MODE_RECTANGLE)));
850 add_item(new BC_MenuItem(to_text(MODE_PARALLELOGRAM)));
851 add_item(new BC_MenuItem(to_text(MODE_QUADRILATERAL)));
853 int FindObjMode::from_text(char *text)
855 if(!strcmp(text, _("Square"))) return MODE_SQUARE;
856 if(!strcmp(text, _("Rhombus"))) return MODE_RHOMBUS;
857 if(!strcmp(text, _("Rectangle"))) return MODE_RECTANGLE;
858 if(!strcmp(text, _("Parallelogram"))) return MODE_PARALLELOGRAM;
859 if(!strcmp(text, _("Quadrilateral"))) return MODE_QUADRILATERAL;
863 void FindObjMode::update(int mode)
865 set_text(to_text(mode));
868 char* FindObjMode::to_text(int mode)
871 case MODE_SQUARE: return _("Square");
872 case MODE_RHOMBUS: return _("Rhombus");
873 case MODE_RECTANGLE: return _("Rectangle");
874 case MODE_PARALLELOGRAM: return _("Parallelogram");
875 case MODE_QUADRILATERAL: return _("Quadrilateral");
880 int FindObjMode::calculate_w(FindObjWindow *gui)
883 for( int mode=MODE_NONE; mode<MODE_MAX; ++mode )
884 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(mode)));
889 FindObjLayer::FindObjLayer(FindObjMain *plugin, FindObjWindow *gui,
890 int x, int y, int *value)
891 : BC_TumbleTextBox(gui, *value, MIN_LAYER, MAX_LAYER, x, y, calculate_w(gui))
893 this->plugin = plugin;
898 int FindObjLayer::handle_event()
900 *value = atoi(get_text());
901 plugin->send_configure_change();
905 int FindObjLayer::calculate_w(FindObjWindow *gui)
908 result = gui->get_text_width(MEDIUMFONT, "000");
913 FindObjBlend::FindObjBlend(FindObjMain *plugin,
923 this->plugin = plugin;
927 int FindObjBlend::handle_event()
929 *value = (int)get_value();
930 plugin->send_configure_change();