Skip to content
Snippets Groups Projects
Commit 8e39e553 authored by David Dormagen's avatar David Dormagen
Browse files

annotations: allow hiding with Alt+H

parent 2a9bc223
No related branches found
No related tags found
No related merge requests found
Pipeline #23078 passed
......@@ -107,7 +107,12 @@ void ControllerAnnotations::keyPressEvent(QKeyEvent *event)
case Qt::Key::Key_E:
actionQueued = ActionQueued::CreateEllipse;
break;
case Qt::Key::Key_Delete:
case Qt::Key::Key_H:
model->toggleHideAnnotations();
handled = true;
break;
case Qt::Key::Key_Delete: // Fallthrough.
case Qt::Key::Key_Backspace:
// Remove existing selected annotation at current frame.
if (model->removeSelection())
{
......
......@@ -353,6 +353,8 @@ bool Annotations::tryStartDragging(QPoint cursor)
bool annotationFound = false;
for (auto &annotation : annotations)
{
if (annotation->isHidden())
continue;
auto handle = annotation->getHandleForPosition(cursor);
if (!handle) // Nothing found?
continue;
......@@ -372,6 +374,8 @@ bool Annotations::trySetText(QPoint cursor) {
selection.reset();
for (auto &annotation : annotations)
{
if (annotation->isHidden())
continue;
if (!(selection.handle = annotation->getHandleForPosition(cursor))) {
continue;
}
......@@ -442,3 +446,23 @@ bool Annotations::updateSelectionEndFrame()
selectedAnnotation->startFrame = selectedAnnotation->endFrame;
return true;
}
void Annotations::toggleHideAnnotations()
{
bool allWereHidden = true;
for (auto &annotation : annotations)
{
if (!annotation->isHidden())
{
allWereHidden = false;
annotation->setHidden(true);
}
}
if (allWereHidden)
{
for (auto &annotation : annotations)
annotation->setHidden(false);
}
}
\ No newline at end of file
......@@ -104,12 +104,18 @@ public:
{
origin.update(currentFrameID, trackedComponents);
}
// Visually disable annotations and interactions with them.
// This will not be serialized.
void setHidden(bool hidden=true) { this->hidden = hidden; }
bool isHidden() const { return hidden; }
protected:
bool isHandleAtPosition(const QPoint &handle, const QPoint &pos);
bool isHandleAtPosition(const TrackedPoint &handle, const QPoint &pos)
{
return isHandleAtPosition(*handle, pos);
}
private:
bool hidden { false };
};
/// A label marks a position.
......@@ -185,6 +191,8 @@ public:
size_t getCurrentFrame() const { return currentFrame; }
// Called when trajectories or displayed frames have changed.
void updateTrackedAnnotations(const QList<IModelTrackedComponent*> &trackedComponents);
// Used to hide existing annotations, or if all are hidden, unhide them.
void toggleHideAnnotations();
private:
size_t currentFrame{ 0 }; /**< The current frame is required by the view. */
......
......@@ -47,6 +47,8 @@ void AnnotationsView::paint(QPainter * painter, const QStyleOptionGraphicsItem *
const auto currentFrame = model->getCurrentFrame();
for (auto &annotation : model->annotations)
{
if (annotation->isHidden())
continue;
// Is the current frame in the annotation's range?
if ((currentFrame >= annotation->startFrame && currentFrame <= annotation->endFrame)
|| (currentFrame == annotation->startFrame && annotation->startFrame > annotation->endFrame))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment