4 * Copyright (C) 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"
26 #include "edlsession.h"
29 #include "motionscan.h"
30 #include "motionwindow.h"
32 #include "pluginserver.h"
34 MotionWindow::MotionWindow(MotionMain *plugin)
35 : PluginClientWindow(plugin, xS(800), yS(750), xS(800), yS(750), 0)
37 this->plugin = plugin;
40 MotionWindow::~MotionWindow()
44 void MotionWindow::create_objects()
46 int xs10 = xS(10), xs20 = xS(20), xs50 = xS(50), xs120 = xS(120);
47 int ys10 = yS(10), ys20 = yS(20), ys50 = yS(50), ys30 = yS(30), ys40 = yS(40);
48 int x = xs10, y = ys10;
52 add_subwindow(global = new MotionGlobal(plugin, this, x, y));
53 add_subwindow(rotate = new MotionRotate(plugin, this, x2, y));
56 add_subwindow(title = new BC_Title(x, y,
57 _("Translation search radius:\n(W/H Percent of image)")));
58 add_subwindow(global_range_w = new GlobalRange(plugin,
59 x + title->get_w() + xs10, y,
60 &plugin->config.global_range_w));
61 add_subwindow(global_range_h = new GlobalRange(plugin,
62 x + title->get_w() + xs10 + global_range_w->get_w(), y,
63 &plugin->config.global_range_h));
65 add_subwindow(title = new BC_Title(x2, y,
66 _("Rotation search radius:\n(Degrees)")));
67 add_subwindow(rotation_range = new RotationRange(plugin,
68 x2 + title->get_w() + xs10, y));
71 add_subwindow(title = new BC_Title(x, y,
72 _("Translation block size:\n(W/H Percent of image)")));
73 add_subwindow(global_block_w =
74 new BlockSize(plugin, x + title->get_w() + xs10, y,
75 &plugin->config.global_block_w));
76 add_subwindow(global_block_h =
77 new BlockSize(plugin, x + title->get_w() + xs10 +
78 global_block_w->get_w(), y,
79 &plugin->config.global_block_h));
81 // add_subwindow(title = new BC_Title(x2,
83 // _("Rotation block size:\n(W/H Percent of image)")));
84 // add_subwindow(rotation_block_w = new BlockSize(plugin,
85 // x2 + title->get_w() + xs10,
87 // &plugin->config.rotation_block_w));
88 // add_subwindow(rotation_block_h = new BlockSize(plugin,
89 // x2 + title->get_w() + xs10 + rotation_block_w->get_w(),
91 // &plugin->config.rotation_block_h));
94 add_subwindow(title = new BC_Title(x, y, _("Translation search steps:")));
95 add_subwindow(global_search_positions =
96 new GlobalSearchPositions(plugin, x + title->get_w() + xs10, y, xs120));
97 global_search_positions->create_objects();
99 add_subwindow(title = new BC_Title(x2, y, _("Rotation search steps:")));
100 add_subwindow(rotation_search_positions =
101 new RotationSearchPositions(plugin, x2 + title->get_w() + xs10, y, xs120));
102 rotation_search_positions->create_objects();
105 add_subwindow(title = new BC_Title(x, y, _("Translation direction:")));
106 add_subwindow(track_direction = new TrackDirection(plugin,
108 x + title->get_w() + xs10,
110 track_direction->create_objects();
113 add_subwindow(title = new BC_Title(x, y + ys10, _("Block X:")));
114 add_subwindow(block_x =
115 new MotionBlockX(plugin, this, x + title->get_w() + xs10, y));
116 add_subwindow(block_x_text =
117 new MotionBlockXText(plugin, this,
118 x + title->get_w() + xs10 + block_x->get_w() + xs10, y + ys10));
120 add_subwindow(title = new BC_Title(x2, y + ys10, _("Rotation center:")));
121 add_subwindow(rotation_center =
122 new RotationCenter(plugin, x2 + title->get_w() + xs10, y));
125 add_subwindow(title = new BC_Title(x, y + ys10, _("Block Y:")));
126 add_subwindow(block_y =
127 new MotionBlockY(plugin, this, x + title->get_w() + xs10, y));
128 add_subwindow(block_y_text =
129 new MotionBlockYText(plugin, this,
130 x + title->get_w() + xs10 + block_y->get_w() + xs10, y + ys10));
133 add_subwindow(title = new BC_Title(x, y + ys10, _("Maximum absolute offset:")));
134 add_subwindow(magnitude = new MotionMagnitude(plugin,
135 x + title->get_w() + xs10,
138 add_subwindow(title = new BC_Title(x2, y + ys10, _("Maximum angle offset:")));
139 add_subwindow(rotate_magnitude =
140 new MotionRMagnitude(plugin, x2 + title->get_w() + xs10, y));
143 add_subwindow(title = new BC_Title(x, y + ys10, _("Motion settling speed:")));
144 add_subwindow(return_speed =
145 new MotionReturnSpeed(plugin, x + title->get_w() + xs10, y));
147 add_subwindow(title = new BC_Title(x2, y + ys10, _("Rotation settling speed:")));
148 add_subwindow(rotate_return_speed =
149 new MotionRReturnSpeed(plugin, x2 + title->get_w() + xs10, y));
152 add_subwindow(title = new BC_Title(x, y, _("Motion noise level:\n(% of max diff.)")));
153 add_subwindow(noise_level =
154 new MotionNoiseLevel(plugin, this, x + title->get_w() + xs10, y));
155 add_subwindow(noise_level_text =
156 new MotionNoiseLevelText(plugin, this,
157 x + title->get_w() + xs10 + noise_level->get_w() + xs10, y + ys10));
159 add_subwindow(title = new BC_Title(x2, y, _("Rotation noise level:\n(% of max diff.)")));
160 add_subwindow(noise_rotation =
161 new MotionNoiseRotation(plugin, this, x2 + title->get_w() + xs10, y));
162 add_subwindow(noise_rotation_text =
163 new MotionNoiseRotationText(plugin, this,
164 x2 + title->get_w() + xs10 + noise_rotation->get_w() + xs10, y + ys10));
167 add_subwindow(vectors = new MotionDrawVectors(plugin, this, x, y));
168 add_subwindow(twopass = new MotionTwopass(plugin, this, x2, y));
171 add_subwindow(track_single =
172 new TrackSingleFrame(plugin, this, x, y));
174 add_subwindow(title = new BC_Title(x2, y, _("Frame number:")));
175 add_subwindow(track_frame_number =
176 new TrackFrameNumber(plugin, this, x2 + title->get_w() + xs10, y));
177 add_subwindow(frame_current =
178 new MotionFrameCurrent(plugin, this, x2 + title->get_w() + track_frame_number->get_w() + xs20, y));
179 if(plugin->config.tracking_object != MotionScan::TRACK_SINGLE)
181 track_frame_number->disable();
182 frame_current->disable();
186 add_subwindow(track_previous =
187 new TrackPreviousFrame(plugin, this, x, y));
190 add_subwindow(previous_same =
191 new PreviousFrameSameBlock(plugin, this, x, y));
193 add_subwindow(addtrackedframeoffset =
194 new AddTrackedFrameOffset(plugin, this, x2, y));
197 add_subwindow(title = new BC_Title(x, y, _("Tracking file:")));
198 add_subwindow(tracking_file = new MotionTrackingFile(plugin,
199 plugin->config.tracking_file, this, x+title->get_w() + xs10, y));
201 add_subwindow(reset_tracking =
202 new MotionResetTracking(plugin, this, x2, y));
205 add_subwindow(title = new BC_Title(x, y, _("Master layer:")));
206 add_subwindow(master_layer = new MasterLayer(plugin,
207 this, x + title->get_w() + xs10, y));
208 master_layer->create_objects();
210 add_subwindow(clear_tracking =
211 new MotionClearTracking(plugin, this, x2, y - ys10));
214 add_subwindow(title = new BC_Title(x, y, _("Action:")));
215 add_subwindow(action_type = new ActionType(plugin,
216 this, x + title->get_w() + xs10, y));
217 action_type->create_objects();
219 int pef = client->server->mwindow->edl->session->video_every_frame;
220 add_subwindow(pef_title = new BC_Title(x2+xs50, y,
221 !pef ? _("For best results\n"
222 " Set: Play every frame\n"
223 " Preferences-> Playback-> Video Out") :
224 _("Currently using: Play every frame"), MEDIUMFONT,
225 !pef ? RED : GREEN));
228 add_subwindow(title = new BC_Title(x, y, _("Calculation:")));
229 add_subwindow(tracking_type = new TrackingType(plugin,
230 this, x + title->get_w() + xs10, y));
231 tracking_type->create_objects();
236 void MotionWindow::update_mode()
238 global_range_w->update(plugin->config.global_range_w,
239 MIN_RADIUS, MAX_RADIUS);
240 global_range_h->update(plugin->config.global_range_h,
241 MIN_RADIUS, MAX_RADIUS);
242 rotation_range->update(plugin->config.rotation_range,
243 MIN_ROTATION, MAX_ROTATION);
244 vectors->update(plugin->config.draw_vectors);
245 twopass->update(plugin->config.twopass);
246 tracking_file->update(plugin->config.tracking_file);
247 global->update(plugin->config.global);
248 rotate->update(plugin->config.rotate);
249 addtrackedframeoffset->update(plugin->config.addtrackedframeoffset);
252 MotionTrackingFile::MotionTrackingFile(MotionMain *plugin,
253 const char *filename, MotionWindow *gui, int x, int y)
254 : BC_TextBox(x, y, gui->get_w()/2-x-xS(10), 1, filename)
256 this->plugin = plugin;
260 int MotionTrackingFile::handle_event()
262 strncpy(plugin->config.tracking_file, get_text(), sizeof(plugin->config.tracking_file));
263 plugin->reset_cache_file();
264 plugin->send_configure_change();
268 MotionResetTracking::MotionResetTracking(MotionMain *plugin, MotionWindow *gui, int x, int y)
269 : BC_GenericButton(x, y, _("Generate tracking file name"))
271 this->plugin = plugin;
275 int MotionResetTracking::handle_event()
277 // First of all, ensure closing current tracking file
278 plugin->reset_cache_file();
280 // Generate new tracking filename based on the asset filename
281 const char *sp = TRACKING_FILE;
282 char *cp = plugin->config.tracking_file, *ep = cp+sizeof(plugin->config.tracking_file)-1;
283 while( cp < ep && *sp != 0 ) *cp++ = *sp++;
284 if( cp < ep-1 && (sp=plugin->get_source_path()) ) {
286 const char *bp = strrchr(sp,'/');
288 while( cp < ep && *sp != 0 ) {
289 *cp++ = (*sp>='a' && *sp<='z') ||
290 (*sp>='A' && *sp<='Z') ||
291 (*sp>='0' && *sp<='9') ? *sp : '_';
297 gui->tracking_file->update(plugin->config.tracking_file);
298 plugin->reset_cache_file();
300 // Revert tracking type to not using tracking file
301 if( plugin->config.tracking_type == MotionScan::LOAD ||
302 plugin->config.tracking_type == MotionScan::SAVE )
304 plugin->config.tracking_type = MotionScan::NO_CALCULATE;
305 gui->tracking_type->set_text(TrackingType::to_text(plugin->config.tracking_type));
308 plugin->send_configure_change();
312 MotionClearTracking::MotionClearTracking(MotionMain *plugin, MotionWindow *gui, int x, int y)
313 : BC_GenericButton(x, y, _("Clear tracking file contents"))
315 this->plugin = plugin;
319 int MotionClearTracking::handle_event()
321 char save_file[BCTEXTLEN];
323 // First of all, ensure closing current tracking file
324 plugin->reset_cache_file();
326 // Suffix .bak not allowed: reserved for intermediate tracking file copy
327 snprintf(save_file, sizeof(save_file), "%s.old", plugin->config.tracking_file);
328 ::rename(plugin->config.tracking_file, save_file);
331 ::remove(plugin->config.tracking_file);
332 plugin->reset_cache_file();
337 MotionFrameCurrent::MotionFrameCurrent(MotionMain *plugin, MotionWindow *gui, int x, int y)
338 : BC_GenericButton(x, y, _("Get current"))
340 this->plugin = plugin;
344 int MotionFrameCurrent::handle_event()
346 plugin->config.track_frame = plugin->get_source_position();
347 gui->track_frame_number->update(plugin->config.track_frame);
348 plugin->send_configure_change();
353 GlobalRange::GlobalRange(MotionMain *plugin,
354 int x, int y, int *value)
355 : BC_IPot(x, y, (int64_t)*value,
356 (int64_t)MIN_RADIUS, (int64_t)MAX_RADIUS)
358 this->plugin = plugin;
363 int GlobalRange::handle_event()
365 *value = (int)get_value();
366 plugin->send_configure_change();
373 RotationRange::RotationRange(MotionMain *plugin, int x, int y)
374 : BC_IPot(x, y, (int64_t)plugin->config.rotation_range,
375 (int64_t)MIN_ROTATION, (int64_t)MAX_ROTATION)
377 this->plugin = plugin;
381 int RotationRange::handle_event()
383 plugin->config.rotation_range = (int)get_value();
384 plugin->send_configure_change();
389 RotationCenter::RotationCenter(MotionMain *plugin, int x, int y)
390 : BC_IPot(x, y, (int64_t)plugin->config.rotation_center,
391 (int64_t)-MAX_ROTATION, (int64_t)MAX_ROTATION)
393 this->plugin = plugin;
397 int RotationCenter::handle_event()
399 plugin->config.rotation_center = (int)get_value();
400 plugin->send_configure_change();
405 BlockSize::BlockSize(MotionMain *plugin,
415 this->plugin = plugin;
420 int BlockSize::handle_event()
422 *value = (int)get_value();
423 plugin->send_configure_change();
428 GlobalSearchPositions::GlobalSearchPositions(MotionMain *plugin,
430 : BC_PopupMenu(x, y, w, "", 1)
432 this->plugin = plugin;
434 void GlobalSearchPositions::create_objects()
436 add_item(new BC_MenuItem("16"));
437 add_item(new BC_MenuItem("32"));
438 add_item(new BC_MenuItem("64"));
439 add_item(new BC_MenuItem("128"));
440 add_item(new BC_MenuItem("256"));
441 add_item(new BC_MenuItem("512"));
442 add_item(new BC_MenuItem("1024"));
443 add_item(new BC_MenuItem("2048"));
444 add_item(new BC_MenuItem("4096"));
445 add_item(new BC_MenuItem("8192"));
446 add_item(new BC_MenuItem("16384"));
447 add_item(new BC_MenuItem("32768"));
448 add_item(new BC_MenuItem("65536"));
449 add_item(new BC_MenuItem("131072"));
450 char string[BCTEXTLEN];
451 sprintf(string, "%d", plugin->config.global_positions);
455 int GlobalSearchPositions::handle_event()
457 plugin->config.global_positions = atoi(get_text());
458 plugin->send_configure_change();
463 RotationSearchPositions::RotationSearchPositions(MotionMain *plugin,
465 : BC_PopupMenu(x, y, w, "", 1)
467 this->plugin = plugin;
469 void RotationSearchPositions::create_objects()
471 add_item(new BC_MenuItem("4"));
472 add_item(new BC_MenuItem("8"));
473 add_item(new BC_MenuItem("16"));
474 add_item(new BC_MenuItem("32"));
475 char string[BCTEXTLEN];
476 sprintf(string, "%d", plugin->config.rotate_positions);
480 int RotationSearchPositions::handle_event()
482 plugin->config.rotate_positions = atoi(get_text());
483 plugin->send_configure_change();
488 MotionMagnitude::MotionMagnitude(MotionMain *plugin, int x, int y)
490 (int64_t)plugin->config.magnitude, (int64_t)0, (int64_t)100)
492 this->plugin = plugin;
495 int MotionMagnitude::handle_event()
497 plugin->config.magnitude = (int)get_value();
498 plugin->send_configure_change();
503 MotionReturnSpeed::MotionReturnSpeed(MotionMain *plugin, int x, int y)
505 (int64_t)plugin->config.return_speed, (int64_t)0, (int64_t)100)
507 this->plugin = plugin;
510 int MotionReturnSpeed::handle_event()
512 plugin->config.return_speed = (int)get_value();
513 plugin->send_configure_change();
519 AddTrackedFrameOffset::AddTrackedFrameOffset(MotionMain *plugin,
520 MotionWindow *gui, int x, int y)
521 : BC_CheckBox(x, y, plugin->config.addtrackedframeoffset,
522 _("Add (loaded) offset from tracked frame"))
524 this->plugin = plugin;
528 int AddTrackedFrameOffset::handle_event()
530 plugin->config.addtrackedframeoffset = get_value();
531 plugin->send_configure_change();
536 MotionRMagnitude::MotionRMagnitude(MotionMain *plugin, int x, int y)
538 (int64_t)plugin->config.rotate_magnitude, (int64_t)0, (int64_t)90)
540 this->plugin = plugin;
543 int MotionRMagnitude::handle_event()
545 plugin->config.rotate_magnitude = (int)get_value();
546 plugin->send_configure_change();
552 MotionRReturnSpeed::MotionRReturnSpeed(MotionMain *plugin, int x, int y)
554 (int64_t)plugin->config.rotate_return_speed, (int64_t)0, (int64_t)100)
556 this->plugin = plugin;
559 int MotionRReturnSpeed::handle_event()
561 plugin->config.rotate_return_speed = (int)get_value();
562 plugin->send_configure_change();
567 MotionGlobal::MotionGlobal(MotionMain *plugin,
568 MotionWindow *gui, int x, int y)
569 : BC_CheckBox(x, y, plugin->config.global, _("Track translation"))
571 this->plugin = plugin;
575 int MotionGlobal::handle_event()
577 plugin->config.global = get_value();
578 plugin->send_configure_change();
582 MotionRotate::MotionRotate(MotionMain *plugin,
583 MotionWindow *gui, int x, int y)
584 : BC_CheckBox(x, y, plugin->config.rotate, _("Track rotation"))
586 this->plugin = plugin;
590 int MotionRotate::handle_event()
592 plugin->config.rotate = get_value();
593 plugin->send_configure_change();
597 MotionTwopass::MotionTwopass(MotionMain *plugin,
598 MotionWindow *gui, int x, int y)
599 : BC_CheckBox(x, y, plugin->config.twopass, _("Two pass tracking"))
601 this->plugin = plugin;
605 int MotionTwopass::handle_event()
607 plugin->config.twopass = get_value();
608 plugin->send_configure_change();
613 MotionBlockX::MotionBlockX(MotionMain *plugin,
614 MotionWindow *gui, int x, int y)
615 : BC_FPot(x, y, plugin->config.block_x, (float)0, (float)100)
617 this->plugin = plugin;
621 int MotionBlockX::handle_event()
623 plugin->config.block_x = get_value();
624 gui->block_x_text->update((float)plugin->config.block_x);
625 plugin->send_configure_change();
630 MotionBlockY::MotionBlockY(MotionMain *plugin,
636 (float)plugin->config.block_y,
640 this->plugin = plugin;
644 int MotionBlockY::handle_event()
646 plugin->config.block_y = get_value();
647 gui->block_y_text->update((float)plugin->config.block_y);
648 plugin->send_configure_change();
652 MotionBlockXText::MotionBlockXText(MotionMain *plugin,
653 MotionWindow *gui, int x, int y)
654 : BC_TextBox(x, y, xS(75), 1, (float)plugin->config.block_x)
656 this->plugin = plugin;
661 int MotionBlockXText::handle_event()
663 plugin->config.block_x = atof(get_text());
664 gui->block_x->update(plugin->config.block_x);
665 plugin->send_configure_change();
672 MotionBlockYText::MotionBlockYText(MotionMain *plugin,
673 MotionWindow *gui, int x, int y)
674 : BC_TextBox(x, y, xS(75), 1, (float)plugin->config.block_y)
676 this->plugin = plugin;
681 int MotionBlockYText::handle_event()
683 plugin->config.block_y = atof(get_text());
684 gui->block_y->update(plugin->config.block_y);
685 plugin->send_configure_change();
690 MotionNoiseLevel::MotionNoiseLevel(MotionMain *plugin,
691 MotionWindow *gui, int x, int y)
692 : BC_FPot(x, y, plugin->config.noise_level, (float)0, (float)100)
694 this->plugin = plugin;
698 int MotionNoiseLevel::handle_event()
700 float level = plugin->config.noise_level;
702 if (level < 0) level = 0;
703 if (level > 100) level = 100;
704 plugin->config.noise_level = level;
705 gui->noise_level_text->update((float)plugin->config.noise_level);
706 plugin->send_configure_change();
710 MotionNoiseLevelText::MotionNoiseLevelText(MotionMain *plugin,
711 MotionWindow *gui, int x, int y)
712 : BC_TextBox(x, y, xS(75), 1, (float)plugin->config.noise_level)
714 this->plugin = plugin;
719 int MotionNoiseLevelText::handle_event()
721 float level = plugin->config.noise_level;
722 level = atof(get_text());
723 if (level < 0) level = 0;
724 if (level > 100) level = 100;
725 plugin->config.noise_level = level;
726 gui->noise_level->update(plugin->config.noise_level);
727 plugin->send_configure_change();
731 MotionNoiseRotation::MotionNoiseRotation(MotionMain *plugin,
732 MotionWindow *gui, int x, int y)
733 : BC_FPot(x, y, plugin->config.noise_rotation, (float)0, (float)100)
735 this->plugin = plugin;
739 int MotionNoiseRotation::handle_event()
741 float level = plugin->config.noise_rotation;
743 if (level < 0) level = 0;
744 if (level > 100) level = 100;
745 plugin->config.noise_rotation = level;
746 gui->noise_rotation_text->update((float)plugin->config.noise_rotation);
747 plugin->send_configure_change();
751 MotionNoiseRotationText::MotionNoiseRotationText(MotionMain *plugin,
752 MotionWindow *gui, int x, int y)
753 : BC_TextBox(x, y, xS(75), 1, (float)plugin->config.noise_rotation)
755 this->plugin = plugin;
760 int MotionNoiseRotationText::handle_event()
762 float level = plugin->config.noise_rotation;
763 level = atof(get_text());
764 if (level < 0) level = 0;
765 if (level > 100) level = 100;
766 plugin->config.noise_rotation = level;
767 gui->noise_rotation->update(plugin->config.noise_rotation);
768 plugin->send_configure_change();
773 MotionDrawVectors::MotionDrawVectors(MotionMain *plugin,
774 MotionWindow *gui, int x, int y)
777 plugin->config.draw_vectors,
781 this->plugin = plugin;
784 int MotionDrawVectors::handle_event()
786 plugin->config.draw_vectors = get_value();
787 plugin->send_configure_change();
792 TrackSingleFrame::TrackSingleFrame(MotionMain *plugin,
798 plugin->config.tracking_object == MotionScan::TRACK_SINGLE,
799 _("Track single frame"))
801 this->plugin = plugin;
805 int TrackSingleFrame::handle_event()
807 plugin->config.tracking_object = MotionScan::TRACK_SINGLE;
808 gui->track_previous->update(0);
809 gui->previous_same->update(0);
810 gui->track_frame_number->enable();
811 gui->frame_current->enable();
812 plugin->send_configure_change();
816 TrackFrameNumber::TrackFrameNumber(MotionMain *plugin,
820 : BC_TextBox(x, y, xS(100), 1, plugin->config.track_frame)
822 this->plugin = plugin;
826 int TrackFrameNumber::handle_event()
828 plugin->config.track_frame = atol(get_text());
829 plugin->send_configure_change();
834 TrackPreviousFrame::TrackPreviousFrame(MotionMain *plugin,
840 plugin->config.tracking_object == MotionScan::TRACK_PREVIOUS,
841 _("Track previous frame"))
843 this->plugin = plugin;
846 int TrackPreviousFrame::handle_event()
848 plugin->config.tracking_object = MotionScan::TRACK_PREVIOUS;
849 gui->track_single->update(0);
850 gui->previous_same->update(0);
851 gui->track_frame_number->disable();
852 gui->frame_current->disable();
853 plugin->send_configure_change();
858 PreviousFrameSameBlock::PreviousFrameSameBlock(MotionMain *plugin,
864 plugin->config.tracking_object == MotionScan::PREVIOUS_SAME_BLOCK,
865 _("Previous frame same block"))
867 this->plugin = plugin;
870 int PreviousFrameSameBlock::handle_event()
872 plugin->config.tracking_object = MotionScan::PREVIOUS_SAME_BLOCK;
873 gui->track_single->update(0);
874 gui->track_previous->update(0);
875 gui->track_frame_number->disable();
876 gui->frame_current->disable();
877 plugin->send_configure_change();
882 MasterLayer::MasterLayer(MotionMain *plugin, MotionWindow *gui, int x, int y)
886 to_text(plugin->config.bottom_is_master))
888 this->plugin = plugin;
892 int MasterLayer::handle_event()
894 plugin->config.bottom_is_master = from_text(get_text());
895 plugin->send_configure_change();
899 void MasterLayer::create_objects()
901 add_item(new BC_MenuItem(to_text(0)));
902 add_item(new BC_MenuItem(to_text(1)));
905 int MasterLayer::from_text(char *text)
907 if(!strcmp(text, _("Top"))) return 0;
911 char* MasterLayer::to_text(int mode)
913 return mode ? _("Bottom") : _("Top");
916 int MasterLayer::calculate_w(MotionWindow *gui)
919 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(0)));
920 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(1)));
921 return result + xS(80);
925 ActionType::ActionType(MotionMain *plugin, MotionWindow *gui, int x, int y)
929 to_text(plugin->config.action_type))
931 this->plugin = plugin;
935 int ActionType::handle_event()
937 plugin->config.action_type = from_text(get_text());
938 plugin->send_configure_change();
942 void ActionType::create_objects()
944 add_item(new BC_MenuItem(to_text(MotionScan::TRACK)));
945 add_item(new BC_MenuItem(to_text(MotionScan::TRACK_PIXEL)));
946 add_item(new BC_MenuItem(to_text(MotionScan::STABILIZE)));
947 add_item(new BC_MenuItem(to_text(MotionScan::STABILIZE_PIXEL)));
948 add_item(new BC_MenuItem(to_text(MotionScan::NOTHING)));
951 int ActionType::from_text(char *text)
953 if(!strcmp(text, _("Track Subpixel"))) return MotionScan::TRACK;
954 if(!strcmp(text, _("Track Pixel"))) return MotionScan::TRACK_PIXEL;
955 if(!strcmp(text, _("Stabilize Subpixel"))) return MotionScan::STABILIZE;
956 if(!strcmp(text, _("Stabilize Pixel"))) return MotionScan::STABILIZE_PIXEL;
957 //if(!strcmp(text, _("Do Nothing"))) return MotionScan::NOTHING;
958 return MotionScan::NOTHING;
961 char* ActionType::to_text(int mode)
965 case MotionScan::TRACK:
966 return _("Track Subpixel");
967 case MotionScan::TRACK_PIXEL:
968 return _("Track Pixel");
969 case MotionScan::STABILIZE:
970 return _("Stabilize Subpixel");
971 case MotionScan::STABILIZE_PIXEL:
972 return _("Stabilize Pixel");
974 case MotionScan::NOTHING:
975 return _("Do Nothing");
979 int ActionType::calculate_w(MotionWindow *gui)
982 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(MotionScan::TRACK)));
983 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(MotionScan::TRACK_PIXEL)));
984 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(MotionScan::STABILIZE)));
985 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(MotionScan::STABILIZE_PIXEL)));
986 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(MotionScan::NOTHING)));
987 return result + xS(80);
991 TrackingType::TrackingType(MotionMain *plugin, MotionWindow *gui, int x, int y)
995 to_text(plugin->config.tracking_type))
997 this->plugin = plugin;
1001 int TrackingType::handle_event()
1003 plugin->config.tracking_type = from_text(get_text());
1004 plugin->send_configure_change();
1008 void TrackingType::create_objects()
1010 add_item(new BC_MenuItem(to_text(MotionScan::SAVE)));
1011 add_item(new BC_MenuItem(to_text(MotionScan::LOAD)));
1012 add_item(new BC_MenuItem(to_text(MotionScan::CALCULATE)));
1013 add_item(new BC_MenuItem(to_text(MotionScan::NO_CALCULATE)));
1016 int TrackingType::from_text(char *text)
1018 if(!strcmp(text, _("Save coords to tracking file"))) return MotionScan::SAVE;
1019 if(!strcmp(text, _("Load coords from tracking file"))) return MotionScan::LOAD;
1020 if(!strcmp(text, _("Recalculate"))) return MotionScan::CALCULATE;
1021 //if(!strcmp(text, _("Don't Calculate"))) return MotionScan::NO_CALCULATE;
1022 return MotionScan::NO_CALCULATE;
1025 char* TrackingType::to_text(int mode)
1029 case MotionScan::SAVE: return _("Save coords to tracking file");
1030 case MotionScan::LOAD: return _("Load coords from tracking file");
1031 case MotionScan::CALCULATE: return _("Recalculate");
1033 case MotionScan::NO_CALCULATE: return _("Don't Calculate");
1037 int TrackingType::calculate_w(MotionWindow *gui)
1040 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(MotionScan::NO_CALCULATE)));
1041 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(MotionScan::CALCULATE)));
1042 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(MotionScan::SAVE)));
1043 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(MotionScan::LOAD)));
1044 return result + xS(80);
1048 TrackDirection::TrackDirection(MotionMain *plugin, MotionWindow *gui, int x, int y)
1052 to_text(plugin->config.horizontal_only, plugin->config.vertical_only))
1054 this->plugin = plugin;
1058 int TrackDirection::handle_event()
1060 from_text(&plugin->config.horizontal_only, &plugin->config.vertical_only, get_text());
1061 plugin->send_configure_change();
1065 void TrackDirection::create_objects()
1067 add_item(new BC_MenuItem(to_text(1, 0)));
1068 add_item(new BC_MenuItem(to_text(0, 1)));
1069 add_item(new BC_MenuItem(to_text(0, 0)));
1072 void TrackDirection::from_text(int *horizontal_only, int *vertical_only, char *text)
1074 *horizontal_only = 0;
1076 if(!strcmp(text, to_text(1, 0))) *horizontal_only = 1;
1077 if(!strcmp(text, to_text(0, 1))) *vertical_only = 1;
1080 char* TrackDirection::to_text(int horizontal_only, int vertical_only)
1082 if(horizontal_only) return _("Horizontal only");
1083 if(vertical_only) return _("Vertical only");
1087 int TrackDirection::calculate_w(MotionWindow *gui)
1090 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(1, 0)));
1091 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(0, 1)));
1092 result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(0, 0)));
1093 return result + xS(80);