2727#include < opencv2/imgproc.hpp>
2828#include < string>
2929
30+ #include " input/Copy.hpp"
3031#include " input/Image.hpp"
3132#include " input/List.hpp"
3233#include " input/Slice.hpp"
@@ -121,16 +122,6 @@ void LiveWindow::goToLabel(const std::string &label)
121122 }
122123}
123124
124- const std::map<std::string, std::size_t > &LiveWindow::getLabels () const
125- {
126- return _labels;
127- }
128-
129- const std::map<std::size_t , std::string> &LiveWindow::getLabelsByVal () const
130- {
131- return _labelsByVal;
132- }
133-
134125void LiveWindow::removeLabel (const std::string &label)
135126{
136127 _labelsByVal.erase (_labels[label]);
@@ -203,15 +194,13 @@ const std::shared_ptr<_IInput> &LiveWindow::getInput(std::string &&input)
203194
204195void LiveWindow::firstFrame ()
205196{
206- _index = 0 ;
207- _currentLabel = _labelsByVal[0 ];
197+ goToLabel (_labelsByVal[0 ]);
208198 std::cout << std::format (" Current Label set to '{}' at frame '0'." , _currentLabel) << std::endl;
209199}
210200
211201void LiveWindow::lastFrame ()
212202{
213- _index = _frames.size () - 1 ;
214- _currentLabel = std::prev (_labelsByVal.end ())->second ;
203+ goToLabel (std::prev (_labelsByVal.end ())->second );
215204 std::cout << std::format (" Current Label set to '{}' at frame '{}'." , _currentLabel, _index) << std::endl;
216205}
217206
@@ -233,19 +222,20 @@ void LiveWindow::previousLabel()
233222 goToLabel (_currentLabel);
234223 std::cout << std::format (" Timeline set to the start of the current label '{}', at frame '{}'." , _currentLabel, _index) << std::endl;
235224 } else {
236- goToLabel (std::prev (_labels .find (_currentLabel))->first );
225+ goToLabel (std::prev (_labelsByVal .find (_labels[ _currentLabel] ))->second );
237226 std::cout << std::format (" Timeline set to the previous label '{}', at frame '{}'." , _currentLabel, _index) << std::endl;
238227 }
239228}
240229
241230void LiveWindow::nextLabel ()
242231{
243- auto upperBound = getLabelsByVal (). upper_bound (_labels[_currentLabel]);
232+ auto next = std::next (_labelsByVal. find (_labels[_currentLabel]) );
244233
245- if (upperBound == getLabelsByVal ().end ()) {
246- std::cout << std::format (" The Timeline is currently at the last label, '{}'" , _currentLabel) << std::endl;
234+ if (next == _labelsByVal.end ()) {
235+ _index = _frames.size () - 1 ;
236+ std::cout << std::format (" Timeline set to last index, '{}'" , _index) << std::endl;
247237 } else {
248- goToLabel (upperBound ->second );
238+ goToLabel (next ->second );
249239 std::cout << std::format (" Timeline set to the next label '{}', at frame '{}'." , _currentLabel, _index) << std::endl;
250240 }
251241}
@@ -356,7 +346,7 @@ std::shared_ptr<_IInput> LiveWindow::repeat(const json::array_t &args)
356346
357347std::shared_ptr<_IInput> LiveWindow::copy (const json::array_t &args)
358348{
359- return std::make_unique<List >(executeInst (args[0 ]));
349+ return std::make_unique<Copy >(executeInst (args[0 ]));
360350}
361351
362352std::shared_ptr<_IInput> LiveWindow::concat (const json::array_t &args)
0 commit comments