Skip to content

Commit a27dbfa

Browse files
authored
Merge pull request #21 from jonahpearl/hotkeys
Add hotkeys for keypoint suppression and skipping
2 parents 4099ad8 + 09e5ce0 commit a27dbfa

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

gui/editor/editorwidget.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ EditorWidget::EditorWidget(QWidget *parent) : QWidget(parent) {
166166
connect(this, &EditorWidget::frameChanged, keypointWidget, &KeypointWidget::frameChangedSlot);
167167
connect(this, &EditorWidget::frameChanged, reprojectionWidget, &ReprojectionWidget::calculateReprojectionSlot);
168168
connect(this, &EditorWidget::frameChanged, datasetControlWidget, &DatasetControlWidget::frameChangedSlot);
169+
connect(this, &EditorWidget::cmdRPressed, keypointWidget, &KeypointWidget::toggleCurrentKeypointSlot);
170+
connect(this, &EditorWidget::cmdEPressed, keypointWidget, &KeypointWidget::advanceCurrentKeypointSlot);
169171

170172
//<-> Relayed Signals
171173
connect(datasetControlWidget, &DatasetControlWidget::datasetLoaded, this, &EditorWidget::newSegmentLoaded);
@@ -456,4 +458,10 @@ void EditorWidget::keyPressEvent(QKeyEvent *e)
456458
else if (key == 16777248) {
457459
keypointWidget->toggleHideAll();
458460
}
461+
else if ((key == Qt::Key_R) && (e->modifiers() & Qt::ControlModifier)){
462+
emit cmdRPressed(); // will suppress currently selected keypoint
463+
}
464+
else if ((key == Qt::Key_E) && (e->modifiers() & Qt::ControlModifier)){
465+
emit cmdEPressed(); // will skip currently selected keypoint
466+
}
459467
}

gui/editor/editorwidget.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ class EditorWidget : public QWidget {
5454
void errorThresholdChanged(float val);
5555
void boneLengthErrorThresholdChanged(float val);
5656
void brightnessChanged(int brightnessFactor);
57+
void cmdRPressed(); // toggle keypoint suppression
58+
void cmdEPressed(); // skip keypoint without any action
5759

5860
public slots:
5961
void splitterMovedSlot(int pos, int index);

gui/editor/keypointwidget.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ void KeypointWidget::init() {
7373
connect(bodyPartsListWidget, &KeypointListWidget::removeKeypoint, this, &KeypointWidget::removeKeypointSlot);
7474
connect(bodyPartsListWidget, &KeypointListWidget::suppressKeypoint, this, &KeypointWidget::suppressKeypointSlot);
7575
connect(bodyPartsListWidget, &KeypointListWidget::unsuppressKeypoint, this, &KeypointWidget::unsuppressKeypointSlot);
76+
connect(bodyPartsListWidget, &KeypointListWidget::advanceCurrentKeypoint, this, &KeypointWidget::advanceCurrentKeypointSlot);
7677

7778
for (const auto& bp : Dataset::dataset->bodypartsList()) {
7879
QListWidgetItem * bpItem = new QListWidgetItem();
@@ -167,6 +168,36 @@ void KeypointWidget::suppressKeypointSlot(int row) {
167168
}
168169

169170

171+
// we have to do this back and forth dance because the keypointListWidget handles
172+
// suppression (or not) of keypoints. maybe a way to do it all from here, rather than having a method?
173+
// but the method seems generically useful. The downside is then we have to come back and
174+
// update the viewer in a separate slot, so we're sure to not update the current row before the toggle occurs.
175+
void KeypointWidget::toggleCurrentKeypointSlot() {
176+
177+
// figure out which keypointList is currently active
178+
KeypointListWidget* keypointList = keypointListMap[m_currentEntity];
179+
180+
// call the toggleCurrentKeypointSuppression method of this keypointList
181+
// maybe this should be a signal + slot
182+
keypointList->toggleCurrentKeypointSuppression();
183+
}
184+
185+
void KeypointWidget::advanceCurrentKeypointSlot(){
186+
// figure out which keypointList is currently active
187+
KeypointListWidget* keypointList = keypointListMap[m_currentEntity];
188+
189+
// advance the row to the next keypoint, if possible
190+
if (keypointList->currentRow() < keypointList->count()-1) {
191+
keypointList->setCurrentRow(keypointList->currentRow()+1);
192+
193+
// update the viewer accordingly
194+
QColor color = colorMap->getColor(keypointList->currentRow(), keypointList->count());
195+
m_currentBodypart = keypointList->item(keypointList->currentRow())->text();
196+
emit currentBodypartChanged(m_currentBodypart, color);
197+
emit updateViewer();
198+
}
199+
}
200+
170201
void KeypointWidget::unsuppressKeypointSlot(int row) {
171202
QListWidget* keypointList = keypointListMap[m_currentEntity];
172203
keypointList->item(row)->setIcon(QIcon::fromTheme("no_check"));

gui/editor/keypointwidget.hpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,29 @@ class KeypointListWidget : public QListWidget {
4040
void clearSupressed() {
4141
m_suppressedList.clear();
4242
}
43+
// bool isSuppressed(int row) {
44+
// return m_suppressedList.contains(row);
45+
// }
46+
47+
void toggleCurrentKeypointSuppression(){
48+
int current = this->currentRow();
49+
bool isSuppressed = m_suppressedList.contains(current);
50+
if (isSuppressed) {
51+
m_suppressedList.removeAll(current);
52+
emit unsuppressKeypoint(current);
53+
}
54+
else {
55+
m_suppressedList.append(current);
56+
emit suppressKeypoint(current);
57+
}
58+
emit advanceCurrentKeypoint();
59+
}
4360

4461
signals:
4562
void removeKeypoint(int row);
4663
void suppressKeypoint(int row);
4764
void unsuppressKeypoint(int row);
65+
void advanceCurrentKeypoint();
4866

4967
private:
5068
QList<int> m_suppressedList = {};
@@ -131,6 +149,8 @@ class KeypointWidget : public QWidget {
131149
void unsuppressKeypointSlot(int row);
132150
void frameChangedSlot(int currentImgSetIndex, int currentFrameIndex);
133151
void setKeypointsFromDatasetSlot();
152+
void toggleCurrentKeypointSlot();
153+
void advanceCurrentKeypointSlot();
134154

135155
private:
136156
ColorMap *colorMap;

0 commit comments

Comments
 (0)