aboutsummaryrefslogtreecommitdiff
path: root/src/ui.cc
diff options
context:
space:
mode:
authorYour Name <you@example.com>2021-08-17 16:29:44 -0400
committerYour Name <you@example.com>2021-08-17 16:29:44 -0400
commite4ec24000b7ed45490eaa988c94546f480114933 (patch)
treeed8a9bb992c2ffc3e49fdec2abd478d1c07f90e2 /src/ui.cc
parentab5e941dcaedcf2cc896eed1ea257c59780fdb59 (diff)
downloadannotator-e4ec24000b7ed45490eaa988c94546f480114933.tar.gz
annotator-e4ec24000b7ed45490eaa988c94546f480114933.tar.bz2
annotator-e4ec24000b7ed45490eaa988c94546f480114933.zip
Finished rectangle annotation code
Diffstat (limited to 'src/ui.cc')
-rw-r--r--src/ui.cc22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/ui.cc b/src/ui.cc
index 9b24815..3940955 100644
--- a/src/ui.cc
+++ b/src/ui.cc
@@ -36,20 +36,24 @@ namespace frontend {
case 32: // Space pauses
data->play = ! data->play;
break;
- case 65361: // Left seeks backward 1 frame
+ case 104:
+ case 65361: // Left seeks backward 1 frame (or h)
data->pb->seekFrame(data->pb->getFrame() - 1);
break;
- case 65362: // Up seeks backward 1 second
+ case 100:
+ case 65362: // Up seeks backward 1 second (or d)
if(data->pb->getTime() < 1) {
data->pb->seekTime(data->pb->getTime() * -1);
} else {
data->pb->seekTime(data->pb->getTime() - 1);
}
break;
- case 65363: // Right seeks forward 1 frame
+ case 116:
+ case 65363: // Right seeks forward 1 frame (or t)
data->pb->seekFrame(data->pb->getFrame() + 1);
break;
- case 65364: // Down seeks forward 1 second
+ case 110:
+ case 65364: // Down seeks forward 1 second (or n)
data->pb->seekTime(data->pb->getTime() + 1);
break;
case 117: // u undoes
@@ -74,9 +78,9 @@ namespace frontend {
}
backend::label* getCurrentRectLabel(ui_impl *data) {
- auto labs = data->llr->getEditableLabels();
+ auto &labs = data->llr->getEditableLabels();
for(auto rit = labs.rbegin(); rit != labs.rend(); rit++) {
- if(rit->location.nonzero()) {
+ if(rit->location.nonzero() && rit->time <= data->pb->getTime()) {
return &(*rit);
}
}
@@ -106,8 +110,8 @@ namespace frontend {
data->llr->applyLabel(name, time);
lab = &data->llr->getEditableLabels().back();
}
- lab->location.x1 = x;
- lab->location.y1 = y;
+ lab->location.x1 = lab->location.x2 = x;
+ lab->location.y1 = lab->location.y2 = y;
} else if(event == cv::EVENT_LBUTTONUP) {
// Mouse is no longer down
mouseDown = false;
@@ -115,7 +119,7 @@ namespace frontend {
// If the mouse is down, update x2 and y2 of current window
if(mouseDown) {
auto lab = getCurrentRectLabel(data); // It will be valid! TODO: Will it?
- std::cout << "Updating location from " << lab->location.x2 << ", " << lab->location.y2 << " to " << x << ", " << y << "\n";
+ //std::cout << "Updating location from " << lab->location.x2 << ", " << lab->location.y2 << " to " << x << ", " << y << "\n";
lab->location.x2 = x;
lab->location.y2 = y;
}