From 2e1ff97fa7f0d32c799a97614fd30ad91bf30fe1 Mon Sep 17 00:00:00 2001
From: "Kilic, Deniz" <d.kilic@fz-juelich.de>
Date: Mon, 4 Apr 2022 13:33:43 +0200
Subject: [PATCH 01/13] WIP

---
 CMakeLists.txt                  |  3 ++
 include/frameRange.h            | 11 +++++++
 include/manualTrackpointMover.h | 49 +++++++++++++++++++++++++++++
 include/personStorage.h         |  6 ++--
 include/petrack.h               |  6 ++++
 src/manualTrackpointMover.cpp   | 55 +++++++++++++++++++++++++++++++++
 src/personStorage.cpp           | 25 +++++++++++++--
 src/petrack.cpp                 | 26 +++++++++++++++-
 src/view.cpp                    | 21 +++++++++++++
 9 files changed, 196 insertions(+), 6 deletions(-)
 create mode 100644 include/frameRange.h
 create mode 100644 include/manualTrackpointMover.h
 create mode 100644 src/manualTrackpointMover.cpp

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 73fd37693..843bc7e81 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -377,6 +377,8 @@ target_sources(petrack_core PRIVATE
     include/moCapSelectionWidget.h
     include/personStorage.h
     include/autosave.h
+    include/manualTrackpointMover.h
+    include/frameRange.h
     )
 
 target_sources(petrack_core PRIVATE
@@ -437,6 +439,7 @@ target_sources(petrack_core PRIVATE
     src/moCapSelectionWidget.cpp
     src/personStorage.cpp
     src/autosave.cpp
+    src/manualTrackpointMover.cpp
     ui/about.ui
     ui/codeMarker.ui
     ui/colorMarker.ui
diff --git a/include/frameRange.h b/include/frameRange.h
new file mode 100644
index 000000000..5402ede60
--- /dev/null
+++ b/include/frameRange.h
@@ -0,0 +1,11 @@
+#ifndef FRAMERANGE_H
+#define FRAMERANGE_H
+
+struct FrameRange
+{
+    int before;
+    int after;
+    int current;
+};
+
+#endif // FRAMERANGE_H
diff --git a/include/manualTrackpointMover.h b/include/manualTrackpointMover.h
new file mode 100644
index 000000000..aafc2e508
--- /dev/null
+++ b/include/manualTrackpointMover.h
@@ -0,0 +1,49 @@
+/*
+ * PeTrack - Software for tracking pedestrians movement in videos
+ * Copyright (C) 2010-2022 Forschungszentrum Jülich GmbH,
+ * Maik Boltes, Juliane Adrian, Ricardo Martin Brualla, Arne Graf, Paul Häger, Daniel Hillebrand,
+ * Deniz Kilic, Paul Lieberenz, Daniel Salden, Tobias Schrödter, Ann Katrin Seemann
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef MANUALTRACKPOINTMOVER_H
+#define MANUALTRACKPOINTMOVER_H
+
+#include "frameRange.h"
+#include "personStorage.h"
+
+#include <QObject>
+
+
+class ManualTrackpointMover : public QObject
+{
+    Q_OBJECT
+
+public:
+    explicit ManualTrackpointMover(QObject *parent = nullptr) : QObject{parent} {}
+
+    void selectTrackPoint(
+        const QPointF       &pos,
+        const PersonStorage &person_store,
+        const QSet<int>     &peds,
+        const FrameRange    &range);
+    void moveTrackPoint(const QPointF &pos, PersonStorage &person_store); // need to manually specify redraw?
+    void setTrackPoint();
+
+private:
+    PersonFrame mSelectedPerson = PersonFrame{-1, -1};
+};
+
+#endif // MANUALTRACKPOINTMOVER_H
diff --git a/include/personStorage.h b/include/personStorage.h
index 2798fe197..2b1286a88 100644
--- a/include/personStorage.h
+++ b/include/personStorage.h
@@ -21,6 +21,7 @@
 #ifndef PERSONSTORAGE_H
 #define PERSONSTORAGE_H
 
+#include "frameRange.h"
 #include "tracker.h"
 
 #include <vector>
@@ -56,6 +57,7 @@ public:
     bool editTrackPersonComment(const Vec2F &p, int frame, const QSet<int> &onlyVisible);
     bool setTrackPersonHeight(const Vec2F &p, int frame, const QSet<int> &onlyVisible);
     bool resetTrackPersonHeight(const Vec2F &p, int frame, QSet<int> onlyVisible);
+    void moveTrackPoint(int personID, int frame, const Vec2F &newPosition);
 
     size_t                          nbPersons() const { return mPersons.size(); }
     const TrackPerson              &at(size_t i) const { return mPersons.at(i); }
@@ -82,8 +84,8 @@ public:
     int  largestFirstFrame() const;
     int  largestLastFrame() const;
     int  smallestFirstFrame() const;
-    std::vector<PersonFrame>
-         getProximalPersons(const QPointF &pos, int frame, QSet<int> selected, int before, int after) const;
+    [[nodiscard]] std::vector<PersonFrame>
+         getProximalPersons(const QPointF &pos, QSet<int> selected, const FrameRange &frameRange) const;
     void recalcHeight(float altitude);
 
     void clear() { mPersons.clear(); }
diff --git a/include/petrack.h b/include/petrack.h
index 59431550d..de557b6ce 100644
--- a/include/petrack.h
+++ b/include/petrack.h
@@ -39,6 +39,7 @@
 #include "brightContrastFilter.h"
 #include "coordItem.h"
 #include "extrCalibration.h"
+#include "manualTrackpointMover.h"
 #include "moCapController.h"
 #include "moCapPerson.h"
 #include "personStorage.h"
@@ -156,6 +157,9 @@ public slots:
     void deleteTrackPointAll(PersonStorage::Direction direction);
     void deleteTrackPointROI();
     void deleteTrackPointInsideROI();
+    void moveTrackPoint(QPointF pos);
+    void selectPersonForMoveTrackPoint(QPointF pos);
+    void releaseTrackPoint(QPointF pos);
     //    void showContextMenu(QPointF pos);
     void updateSourceInOutFrames();
     void skipToFrameWheel(int delta);
@@ -497,6 +501,8 @@ private:
     double        mHeadSize;
     double        mCmPerPixel;
 
+    ManualTrackpointMover mManualTrackPointMover;
+
     double mShowFPS;
 
     bool mAutoBackTrack;
diff --git a/src/manualTrackpointMover.cpp b/src/manualTrackpointMover.cpp
new file mode 100644
index 000000000..b595ec69b
--- /dev/null
+++ b/src/manualTrackpointMover.cpp
@@ -0,0 +1,55 @@
+/*
+ * PeTrack - Software for tracking pedestrians movement in videos
+ * Copyright (C) 2010-2022 Forschungszentrum Jülich GmbH,
+ * Maik Boltes, Juliane Adrian, Ricardo Martin Brualla, Arne Graf, Paul Häger, Daniel Hillebrand,
+ * Deniz Kilic, Paul Lieberenz, Daniel Salden, Tobias Schrödter, Ann Katrin Seemann
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include "manualTrackpointMover.h"
+
+#include "pMessageBox.h"
+
+void ManualTrackpointMover::selectTrackPoint(
+    const QPointF       &pos,
+    const PersonStorage &person_store,
+    const QSet<int>     &peds,
+    const FrameRange    &range)
+{
+    auto res = person_store.getProximalPersons(pos, peds, range);
+
+    if(res.size() == 1)
+    {
+        mSelectedPerson = res.front();
+    }
+    else if(res.size() > 1)
+    {
+        PWarning(
+            nullptr,
+            tr("Too many trajectories"),
+            tr("PeTrack can't determine which point you meant. Try selecting fewer trajectories first."));
+    }
+}
+
+void ManualTrackpointMover::moveTrackPoint(const QPointF &pos, PersonStorage &person_store)
+{
+    person_store.moveTrackPoint(mSelectedPerson.personID, mSelectedPerson.frame, Vec2F{pos});
+}
+
+void ManualTrackpointMover::setTrackPoint()
+{
+    // resetting is not neccessary
+    mSelectedPerson = {-1, -1};
+}
diff --git a/src/personStorage.cpp b/src/personStorage.cpp
index 8a7a091f5..f261a5c6f 100644
--- a/src/personStorage.cpp
+++ b/src/personStorage.cpp
@@ -404,6 +404,25 @@ bool PersonStorage::resetTrackPersonHeight(const Vec2F &point, int frame, QSet<i
     return false;
 }
 
+void PersonStorage::moveTrackPoint(int personID, int frame, const Vec2F &newPosition)
+{
+    mAutosave.trackPersonModified();
+    auto      &person = mPersons.at(personID);
+    TrackPoint newPoint;
+    newPoint = newPosition;
+    if(person.trackPointExist(frame))
+    {
+        int idx     = frame - person.firstFrame();
+        person[idx] = newPoint;
+    }
+    else
+    {
+        // only logging since this is a software bug, not a user bug; precondition of function not fulfilled
+        debout << "Warning: Trying to move nonexisting trackpoint of person " << personID << " at frame " << frame
+               << std::endl;
+    }
+}
+
 // used for calculation of 3D point for all points in frame
 // returns number of found points or -1 if no stereoContext available (also points without disp found are counted)
 int PersonStorage::calcPosition(int /*frame*/)
@@ -711,7 +730,7 @@ int PersonStorage::smallestFirstFrame() const
  * @return list of the id of all proximal persons with the frame at which they are nearest to pos
  */
 std::vector<PersonFrame>
-PersonStorage::getProximalPersons(const QPointF &pos, int frame, QSet<int> selected, int before, int after) const
+PersonStorage::getProximalPersons(const QPointF &pos, QSet<int> selected, const FrameRange &frameRange) const
 {
     std::vector<PersonFrame> result;
     for(int i = 0; i < static_cast<int>(mPersons.size()); ++i)
@@ -723,14 +742,14 @@ PersonStorage::getProximalPersons(const QPointF &pos, int frame, QSet<int> selec
 
         double minDist  = std::numeric_limits<double>::max();
         int    minFrame = -1;
-        for(int f = frame - before; f <= frame + after; ++f)
+        for(int f = frameRange.current - frameRange.before; f <= frameRange.current + frameRange.after; ++f)
         {
             if(!mPersons[i].trackPointExist(f))
             {
                 continue;
             }
             auto dist = mPersons[i].trackPointAt(f).distanceToPoint(pos);
-            if(dist < minDist && dist < (mMainWindow.getHeadSize(nullptr, i, frame) / 2.))
+            if(dist < minDist && dist < (mMainWindow.getHeadSize(nullptr, i, frameRange.current) / 2.))
             {
                 minDist  = dist;
                 minFrame = f;
diff --git a/src/petrack.cpp b/src/petrack.cpp
index 169a7e6aa..196679794 100644
--- a/src/petrack.cpp
+++ b/src/petrack.cpp
@@ -173,6 +173,9 @@ Petrack::Petrack() :
     connect(mView, &GraphicsView::mouseMiddleDoubleClick, this, &Petrack::deleteTrackPointAll);
     connect(mView, &GraphicsView::mouseShiftWheel, this, &Petrack::skipToFrameWheel);
     connect(mView, &GraphicsView::mouseAltDoubleClick, this, &Petrack::skipToFrameFromTrajectory);
+    connect(mView, &GraphicsView::mouseAltMoved, this, &Petrack::moveTrackPoint);
+    connect(mView, &GraphicsView::mousePressedAlt, this, &Petrack::selectPersonForMoveTrackPoint);
+    connect(mView, &GraphicsView::mouseAltReleased, this, &Petrack::releaseTrackPoint);
 
     mPlayerWidget = new Player(mAnimation, this);
 
@@ -4214,6 +4217,26 @@ void Petrack::deleteTrackPointInsideROI()
     updateControlWidget();
     mScene->update();
 }
+
+void Petrack::moveTrackPoint(QPointF pos)
+{
+    mManualTrackPointMover.moveTrackPoint(pos, mPersonStorage);
+}
+
+void Petrack::selectPersonForMoveTrackPoint(QPointF pos)
+{
+    FrameRange range;
+    range.before  = mControlWidget->trackShowBefore->value();
+    range.after   = mControlWidget->trackShowAfter->value();
+    range.current = mPlayerWidget->getPos();
+    mManualTrackPointMover.selectTrackPoint(pos, mPersonStorage, getPedestrianUserSelection(), range);
+}
+
+void Petrack::releaseTrackPoint(QPointF)
+{
+    mManualTrackPointMover.setTrackPoint();
+}
+
 void Petrack::updateSourceInOutFrames()
 {
     mPlayerWidget->setFrameInNum(mAnimation->getSourceInFrameNum());
@@ -4232,8 +4255,9 @@ void Petrack::skipToFrameFromTrajectory(QPointF pos)
     const auto before    = mControlWidget->trackShowBefore->value();
     const auto after     = mControlWidget->trackShowAfter->value();
     const auto currFrame = mPlayerWidget->getPos();
+    FrameRange frameRange{before, after, currFrame};
 
-    auto res = mPersonStorage.getProximalPersons(pos, currFrame, peds, before, after);
+    auto res = mPersonStorage.getProximalPersons(pos, peds, frameRange);
 
     if(res.size() == 1)
     {
diff --git a/src/view.cpp b/src/view.cpp
index 841c10e78..e1628179c 100644
--- a/src/view.cpp
+++ b/src/view.cpp
@@ -164,9 +164,30 @@ void GraphicsView::mousePressEvent(QMouseEvent *event)
     {
         emit colorSelected();
     }
+
+    if(event->modifiers().testFlag(Qt::AltModifier) && event->button() == Qt::LeftButton)
+    {
+        emit mousePressedAlt(event->pos());
+    }
     QGraphicsView::mousePressEvent(event);
 }
 
+void GraphicsView::mouseReleaseEvent(QMouseEvent *event)
+{
+    if(event->modifiers().testFlag(Qt::AltModifier))
+    {
+        emit mouseAltReleased(event->pos());
+    }
+}
+
+void GraphicsView::mouseMoveEvent(QMouseEvent *event)
+{
+    if(event->modifiers().testFlag(Qt::AltModifier))
+    {
+        emit mouseAltMoved(event->pos());
+    }
+}
+
 //---------------------------------------------------------------------
 
 
-- 
GitLab


From 371b75712fc76d25b25a3b15cda422152932292f Mon Sep 17 00:00:00 2001
From: "Kilic, Deniz" <d.kilic@fz-juelich.de>
Date: Mon, 4 Apr 2022 13:33:57 +0200
Subject: [PATCH 02/13] WIP

---
 include/view.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/view.h b/include/view.h
index 9dac4763c..71e62be25 100644
--- a/include/view.h
+++ b/include/view.h
@@ -49,6 +49,8 @@ public:
     void mouseDoubleClickEvent(QMouseEvent *event) override;
     void keyPressEvent(QKeyEvent *event) override;
     void mousePressEvent(QMouseEvent *event) override;
+    void mouseReleaseEvent(QMouseEvent *event) override;
+    void mouseMoveEvent(QMouseEvent *event) override;
 
 signals:
     void mouseDoubleClick();
@@ -59,6 +61,9 @@ signals:
     void mouseRightDoubleClick(QPointF pos, int direction);
     void mouseMiddleDoubleClick(PersonStorage::Direction direction);
     void mouseShiftWheel(int delta);
+    void mousePressedAlt(QPointF pos);
+    void mouseAltReleased(QPointF pos);
+    void mouseAltMoved(QPointF pos);
     void colorSelected();
     void setColorEvent();
 };
-- 
GitLab


From 959a85e642c6f7f67f0ddb4cbe9bbb58ece15917 Mon Sep 17 00:00:00 2001
From: "Kilic, Deniz" <d.kilic@fz-juelich.de>
Date: Mon, 4 Apr 2022 14:29:39 +0200
Subject: [PATCH 03/13] Fix scrolling and make moving functional

---
 src/manualTrackpointMover.cpp | 7 +++++--
 src/personStorage.cpp         | 1 -
 src/petrack.cpp               | 1 +
 src/view.cpp                  | 8 +++++---
 4 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/manualTrackpointMover.cpp b/src/manualTrackpointMover.cpp
index b595ec69b..a99ed8426 100644
--- a/src/manualTrackpointMover.cpp
+++ b/src/manualTrackpointMover.cpp
@@ -45,11 +45,14 @@ void ManualTrackpointMover::selectTrackPoint(
 
 void ManualTrackpointMover::moveTrackPoint(const QPointF &pos, PersonStorage &person_store)
 {
-    person_store.moveTrackPoint(mSelectedPerson.personID, mSelectedPerson.frame, Vec2F{pos});
+    if(mSelectedPerson.personID != -1 && mSelectedPerson.frame != -1)
+    {
+        person_store.moveTrackPoint(mSelectedPerson.personID, mSelectedPerson.frame, Vec2F{pos});
+    }
 }
 
 void ManualTrackpointMover::setTrackPoint()
 {
-    // resetting is not neccessary
     mSelectedPerson = {-1, -1};
+    // TODO: Call to autosave
 }
diff --git a/src/personStorage.cpp b/src/personStorage.cpp
index f261a5c6f..f3b45a586 100644
--- a/src/personStorage.cpp
+++ b/src/personStorage.cpp
@@ -406,7 +406,6 @@ bool PersonStorage::resetTrackPersonHeight(const Vec2F &point, int frame, QSet<i
 
 void PersonStorage::moveTrackPoint(int personID, int frame, const Vec2F &newPosition)
 {
-    mAutosave.trackPersonModified();
     auto      &person = mPersons.at(personID);
     TrackPoint newPoint;
     newPoint = newPosition;
diff --git a/src/petrack.cpp b/src/petrack.cpp
index 196679794..9ceebde68 100644
--- a/src/petrack.cpp
+++ b/src/petrack.cpp
@@ -4221,6 +4221,7 @@ void Petrack::deleteTrackPointInsideROI()
 void Petrack::moveTrackPoint(QPointF pos)
 {
     mManualTrackPointMover.moveTrackPoint(pos, mPersonStorage);
+    mView->update();
 }
 
 void Petrack::selectPersonForMoveTrackPoint(QPointF pos)
diff --git a/src/view.cpp b/src/view.cpp
index e1628179c..01153ca7b 100644
--- a/src/view.cpp
+++ b/src/view.cpp
@@ -167,7 +167,7 @@ void GraphicsView::mousePressEvent(QMouseEvent *event)
 
     if(event->modifiers().testFlag(Qt::AltModifier) && event->button() == Qt::LeftButton)
     {
-        emit mousePressedAlt(event->pos());
+        emit mousePressedAlt(mapToScene(event->pos()));
     }
     QGraphicsView::mousePressEvent(event);
 }
@@ -176,16 +176,18 @@ void GraphicsView::mouseReleaseEvent(QMouseEvent *event)
 {
     if(event->modifiers().testFlag(Qt::AltModifier))
     {
-        emit mouseAltReleased(event->pos());
+        emit mouseAltReleased(mapToScene(event->pos()));
     }
+    QGraphicsView::mouseReleaseEvent(event);
 }
 
 void GraphicsView::mouseMoveEvent(QMouseEvent *event)
 {
     if(event->modifiers().testFlag(Qt::AltModifier))
     {
-        emit mouseAltMoved(event->pos());
+        emit mouseAltMoved(mapToScene(event->pos()));
     }
+    QGraphicsView::mouseMoveEvent(event);
 }
 
 //---------------------------------------------------------------------
-- 
GitLab


From 21f4c9688924c7d181a4ef6b096466aa691a2674 Mon Sep 17 00:00:00 2001
From: "Kilic, Deniz" <d.kilic@fz-juelich.de>
Date: Mon, 4 Apr 2022 14:34:52 +0200
Subject: [PATCH 04/13] Call mAutosave.trackPersonModified()

---
 src/manualTrackpointMover.cpp | 1 -
 src/petrack.cpp               | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/manualTrackpointMover.cpp b/src/manualTrackpointMover.cpp
index a99ed8426..10c9f299f 100644
--- a/src/manualTrackpointMover.cpp
+++ b/src/manualTrackpointMover.cpp
@@ -54,5 +54,4 @@ void ManualTrackpointMover::moveTrackPoint(const QPointF &pos, PersonStorage &pe
 void ManualTrackpointMover::setTrackPoint()
 {
     mSelectedPerson = {-1, -1};
-    // TODO: Call to autosave
 }
diff --git a/src/petrack.cpp b/src/petrack.cpp
index 9ceebde68..18db748db 100644
--- a/src/petrack.cpp
+++ b/src/petrack.cpp
@@ -4236,6 +4236,7 @@ void Petrack::selectPersonForMoveTrackPoint(QPointF pos)
 void Petrack::releaseTrackPoint(QPointF)
 {
     mManualTrackPointMover.setTrackPoint();
+    mAutosave.trackPersonModified();
 }
 
 void Petrack::updateSourceInOutFrames()
-- 
GitLab


From 445304e6f14adb969f93d5449165d1e4701ae657 Mon Sep 17 00:00:00 2001
From: "Kilic, Deniz" <d.kilic@fz-juelich.de>
Date: Mon, 4 Apr 2022 14:38:18 +0200
Subject: [PATCH 05/13] Make method const

---
 include/manualTrackpointMover.h | 2 +-
 src/manualTrackpointMover.cpp   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/manualTrackpointMover.h b/include/manualTrackpointMover.h
index aafc2e508..ae6b632fd 100644
--- a/include/manualTrackpointMover.h
+++ b/include/manualTrackpointMover.h
@@ -39,7 +39,7 @@ public:
         const PersonStorage &person_store,
         const QSet<int>     &peds,
         const FrameRange    &range);
-    void moveTrackPoint(const QPointF &pos, PersonStorage &person_store); // need to manually specify redraw?
+    void moveTrackPoint(const QPointF &pos, PersonStorage &person_store) const;
     void setTrackPoint();
 
 private:
diff --git a/src/manualTrackpointMover.cpp b/src/manualTrackpointMover.cpp
index 10c9f299f..2261bf6aa 100644
--- a/src/manualTrackpointMover.cpp
+++ b/src/manualTrackpointMover.cpp
@@ -43,7 +43,7 @@ void ManualTrackpointMover::selectTrackPoint(
     }
 }
 
-void ManualTrackpointMover::moveTrackPoint(const QPointF &pos, PersonStorage &person_store)
+void ManualTrackpointMover::moveTrackPoint(const QPointF &pos, PersonStorage &person_store) const
 {
     if(mSelectedPerson.personID != -1 && mSelectedPerson.frame != -1)
     {
-- 
GitLab


From bcc2da4616b1f43200f196f88324692b1b237d57 Mon Sep 17 00:00:00 2001
From: "Kilic, Deniz" <d.kilic@fz-juelich.de>
Date: Mon, 4 Apr 2022 16:47:22 +0200
Subject: [PATCH 06/13] Misc - see next lines

- Draw grab cursor
- make ManualTrackpointMover not a QObject
- redraw scene properly
---
 include/manualTrackpointMover.h | 10 +++-------
 src/manualTrackpointMover.cpp   | 11 +++++++----
 src/personStorage.cpp           |  1 +
 src/petrack.cpp                 | 11 +++++++++--
 src/view.cpp                    |  5 ++++-
 5 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/include/manualTrackpointMover.h b/include/manualTrackpointMover.h
index ae6b632fd..3b50d7b71 100644
--- a/include/manualTrackpointMover.h
+++ b/include/manualTrackpointMover.h
@@ -24,17 +24,13 @@
 #include "frameRange.h"
 #include "personStorage.h"
 
-#include <QObject>
-
-
-class ManualTrackpointMover : public QObject
+class ManualTrackpointMover
 {
-    Q_OBJECT
 
 public:
-    explicit ManualTrackpointMover(QObject *parent = nullptr) : QObject{parent} {}
+    explicit ManualTrackpointMover() = default;
 
-    void selectTrackPoint(
+    bool selectTrackPoint(
         const QPointF       &pos,
         const PersonStorage &person_store,
         const QSet<int>     &peds,
diff --git a/src/manualTrackpointMover.cpp b/src/manualTrackpointMover.cpp
index 2261bf6aa..5c59dc92f 100644
--- a/src/manualTrackpointMover.cpp
+++ b/src/manualTrackpointMover.cpp
@@ -22,7 +22,7 @@
 
 #include "pMessageBox.h"
 
-void ManualTrackpointMover::selectTrackPoint(
+bool ManualTrackpointMover::selectTrackPoint(
     const QPointF       &pos,
     const PersonStorage &person_store,
     const QSet<int>     &peds,
@@ -30,7 +30,9 @@ void ManualTrackpointMover::selectTrackPoint(
 {
     auto res = person_store.getProximalPersons(pos, peds, range);
 
-    if(res.size() == 1)
+    bool successfull_selection = res.size() == 1;
+
+    if(successfull_selection)
     {
         mSelectedPerson = res.front();
     }
@@ -38,9 +40,10 @@ void ManualTrackpointMover::selectTrackPoint(
     {
         PWarning(
             nullptr,
-            tr("Too many trajectories"),
-            tr("PeTrack can't determine which point you meant. Try selecting fewer trajectories first."));
+            "Too many trajectories",
+            "PeTrack can't determine which point you meant. Try selecting fewer trajectories first.");
     }
+    return successfull_selection;
 }
 
 void ManualTrackpointMover::moveTrackPoint(const QPointF &pos, PersonStorage &person_store) const
diff --git a/src/personStorage.cpp b/src/personStorage.cpp
index f3b45a586..fa08541d8 100644
--- a/src/personStorage.cpp
+++ b/src/personStorage.cpp
@@ -409,6 +409,7 @@ void PersonStorage::moveTrackPoint(int personID, int frame, const Vec2F &newPosi
     auto      &person = mPersons.at(personID);
     TrackPoint newPoint;
     newPoint = newPosition;
+    newPoint.setQual(100);
     if(person.trackPointExist(frame))
     {
         int idx     = frame - person.firstFrame();
diff --git a/src/petrack.cpp b/src/petrack.cpp
index 18db748db..cb7dd029c 100644
--- a/src/petrack.cpp
+++ b/src/petrack.cpp
@@ -4221,7 +4221,7 @@ void Petrack::deleteTrackPointInsideROI()
 void Petrack::moveTrackPoint(QPointF pos)
 {
     mManualTrackPointMover.moveTrackPoint(pos, mPersonStorage);
-    mView->update();
+    mScene->update();
 }
 
 void Petrack::selectPersonForMoveTrackPoint(QPointF pos)
@@ -4230,13 +4230,20 @@ void Petrack::selectPersonForMoveTrackPoint(QPointF pos)
     range.before  = mControlWidget->trackShowBefore->value();
     range.after   = mControlWidget->trackShowAfter->value();
     range.current = mPlayerWidget->getPos();
-    mManualTrackPointMover.selectTrackPoint(pos, mPersonStorage, getPedestrianUserSelection(), range);
+    auto successfully_selected =
+        mManualTrackPointMover.selectTrackPoint(pos, mPersonStorage, getPedestrianUserSelection(), range);
+
+    if(successfully_selected)
+    {
+        setCursor(QCursor{Qt::CursorShape::DragMoveCursor});
+    }
 }
 
 void Petrack::releaseTrackPoint(QPointF)
 {
     mManualTrackPointMover.setTrackPoint();
     mAutosave.trackPersonModified();
+    setCursor(QCursor{});
 }
 
 void Petrack::updateSourceInOutFrames()
diff --git a/src/view.cpp b/src/view.cpp
index 01153ca7b..1b25feaaf 100644
--- a/src/view.cpp
+++ b/src/view.cpp
@@ -187,7 +187,10 @@ void GraphicsView::mouseMoveEvent(QMouseEvent *event)
     {
         emit mouseAltMoved(mapToScene(event->pos()));
     }
-    QGraphicsView::mouseMoveEvent(event);
+    else
+    {
+        QGraphicsView::mouseMoveEvent(event);
+    }
 }
 
 //---------------------------------------------------------------------
-- 
GitLab


From 2209771e7641447b8ff203640418660e9cb43005 Mon Sep 17 00:00:00 2001
From: "Kilic, Deniz" <d.kilic@fz-juelich.de>
Date: Wed, 6 Apr 2022 13:59:31 +0200
Subject: [PATCH 07/13] Add license header to frameRange.h

---
 include/frameRange.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/include/frameRange.h b/include/frameRange.h
index 5402ede60..0eb8cfcd9 100644
--- a/include/frameRange.h
+++ b/include/frameRange.h
@@ -1,3 +1,23 @@
+/*
+ * PeTrack - Software for tracking pedestrians movement in videos
+ * Copyright (C) 2010-2022 Forschungszentrum Jülich GmbH,
+ * Maik Boltes, Juliane Adrian, Ricardo Martin Brualla, Arne Graf, Paul Häger, Daniel Hillebrand,
+ * Deniz Kilic, Paul Lieberenz, Daniel Salden, Tobias Schrödter, Ann Katrin Seemann
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
 #ifndef FRAMERANGE_H
 #define FRAMERANGE_H
 
-- 
GitLab


From f55ef7870800d4f7300895221598e26968be6084 Mon Sep 17 00:00:00 2001
From: "Kilic, Deniz" <d.kilic@fz-juelich.de>
Date: Wed, 6 Apr 2022 14:05:16 +0200
Subject: [PATCH 08/13] Beautifying the code

---
 include/manualTrackpointMover.h | 2 --
 include/view.h                  | 2 +-
 src/manualTrackpointMover.cpp   | 6 +++---
 src/view.cpp                    | 2 +-
 4 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/include/manualTrackpointMover.h b/include/manualTrackpointMover.h
index 3b50d7b71..8440aa317 100644
--- a/include/manualTrackpointMover.h
+++ b/include/manualTrackpointMover.h
@@ -28,8 +28,6 @@ class ManualTrackpointMover
 {
 
 public:
-    explicit ManualTrackpointMover() = default;
-
     bool selectTrackPoint(
         const QPointF       &pos,
         const PersonStorage &person_store,
diff --git a/include/view.h b/include/view.h
index 71e62be25..228f6b7e9 100644
--- a/include/view.h
+++ b/include/view.h
@@ -61,7 +61,7 @@ signals:
     void mouseRightDoubleClick(QPointF pos, int direction);
     void mouseMiddleDoubleClick(PersonStorage::Direction direction);
     void mouseShiftWheel(int delta);
-    void mousePressedAlt(QPointF pos);
+    void mouseAltPressed(QPointF pos);
     void mouseAltReleased(QPointF pos);
     void mouseAltMoved(QPointF pos);
     void colorSelected();
diff --git a/src/manualTrackpointMover.cpp b/src/manualTrackpointMover.cpp
index 5c59dc92f..ab646d153 100644
--- a/src/manualTrackpointMover.cpp
+++ b/src/manualTrackpointMover.cpp
@@ -30,9 +30,9 @@ bool ManualTrackpointMover::selectTrackPoint(
 {
     auto res = person_store.getProximalPersons(pos, peds, range);
 
-    bool successfull_selection = res.size() == 1;
+    bool successful_selection = res.size() == 1;
 
-    if(successfull_selection)
+    if(successful_selection)
     {
         mSelectedPerson = res.front();
     }
@@ -43,7 +43,7 @@ bool ManualTrackpointMover::selectTrackPoint(
             "Too many trajectories",
             "PeTrack can't determine which point you meant. Try selecting fewer trajectories first.");
     }
-    return successfull_selection;
+    return successful_selection;
 }
 
 void ManualTrackpointMover::moveTrackPoint(const QPointF &pos, PersonStorage &person_store) const
diff --git a/src/view.cpp b/src/view.cpp
index 1b25feaaf..131d19009 100644
--- a/src/view.cpp
+++ b/src/view.cpp
@@ -167,7 +167,7 @@ void GraphicsView::mousePressEvent(QMouseEvent *event)
 
     if(event->modifiers().testFlag(Qt::AltModifier) && event->button() == Qt::LeftButton)
     {
-        emit mousePressedAlt(mapToScene(event->pos()));
+        emit mouseAltPressed(mapToScene(event->pos()));
     }
     QGraphicsView::mousePressEvent(event);
 }
-- 
GitLab


From ede3e0189a4fdc6add27d2363917bf789fcefe6c Mon Sep 17 00:00:00 2001
From: "Kilic, Deniz" <d.kilic@fz-juelich.de>
Date: Thu, 7 Apr 2022 09:20:43 +0200
Subject: [PATCH 09/13] Reformat

---
 include/manualTrackpointMover.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/manualTrackpointMover.h b/include/manualTrackpointMover.h
index 8440aa317..f1900e63a 100644
--- a/include/manualTrackpointMover.h
+++ b/include/manualTrackpointMover.h
@@ -26,7 +26,6 @@
 
 class ManualTrackpointMover
 {
-
 public:
     bool selectTrackPoint(
         const QPointF       &pos,
-- 
GitLab


From d81a080bd4745eaf0e273baec65e769b14e06d52 Mon Sep 17 00:00:00 2001
From: "Kilic, Deniz" <d.kilic@fz-juelich.de>
Date: Thu, 7 Apr 2022 09:22:59 +0200
Subject: [PATCH 10/13] Fix name change

---
 src/petrack.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/petrack.cpp b/src/petrack.cpp
index cb7dd029c..9350e93f6 100644
--- a/src/petrack.cpp
+++ b/src/petrack.cpp
@@ -174,7 +174,7 @@ Petrack::Petrack() :
     connect(mView, &GraphicsView::mouseShiftWheel, this, &Petrack::skipToFrameWheel);
     connect(mView, &GraphicsView::mouseAltDoubleClick, this, &Petrack::skipToFrameFromTrajectory);
     connect(mView, &GraphicsView::mouseAltMoved, this, &Petrack::moveTrackPoint);
-    connect(mView, &GraphicsView::mousePressedAlt, this, &Petrack::selectPersonForMoveTrackPoint);
+    connect(mView, &GraphicsView::mouseAltPressed, this, &Petrack::selectPersonForMoveTrackPoint);
     connect(mView, &GraphicsView::mouseAltReleased, this, &Petrack::releaseTrackPoint);
 
     mPlayerWidget = new Player(mAnimation, this);
-- 
GitLab


From dd2e7f262465bebdca5213c12ec36ea1145cec3e Mon Sep 17 00:00:00 2001
From: Deniz Kilic <d.kilic@fz-juelich.de>
Date: Fri, 22 Apr 2022 08:21:17 +0200
Subject: [PATCH 11/13] Changed behaviour for releasing

- Now releases the TrackPoint immeadiately when releasing alt
additionally to when releasing the mouse
---
 include/petrack.h |  2 +-
 include/view.h    |  2 ++
 src/petrack.cpp   |  4 +++-
 src/view.cpp      | 10 ++++++++++
 4 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/include/petrack.h b/include/petrack.h
index de557b6ce..f9278b2b8 100644
--- a/include/petrack.h
+++ b/include/petrack.h
@@ -159,7 +159,7 @@ public slots:
     void deleteTrackPointInsideROI();
     void moveTrackPoint(QPointF pos);
     void selectPersonForMoveTrackPoint(QPointF pos);
-    void releaseTrackPoint(QPointF pos);
+    void releaseTrackPoint();
     //    void showContextMenu(QPointF pos);
     void updateSourceInOutFrames();
     void skipToFrameWheel(int delta);
diff --git a/include/view.h b/include/view.h
index 228f6b7e9..115e81661 100644
--- a/include/view.h
+++ b/include/view.h
@@ -48,6 +48,7 @@ public:
     void wheelEvent(QWheelEvent *event) override;
     void mouseDoubleClickEvent(QMouseEvent *event) override;
     void keyPressEvent(QKeyEvent *event) override;
+    void keyReleaseEvent(QKeyEvent *event) override;
     void mousePressEvent(QMouseEvent *event) override;
     void mouseReleaseEvent(QMouseEvent *event) override;
     void mouseMoveEvent(QMouseEvent *event) override;
@@ -63,6 +64,7 @@ signals:
     void mouseShiftWheel(int delta);
     void mouseAltPressed(QPointF pos);
     void mouseAltReleased(QPointF pos);
+    void altReleased();
     void mouseAltMoved(QPointF pos);
     void colorSelected();
     void setColorEvent();
diff --git a/src/petrack.cpp b/src/petrack.cpp
index 9350e93f6..30c5f9123 100644
--- a/src/petrack.cpp
+++ b/src/petrack.cpp
@@ -175,8 +175,10 @@ Petrack::Petrack() :
     connect(mView, &GraphicsView::mouseAltDoubleClick, this, &Petrack::skipToFrameFromTrajectory);
     connect(mView, &GraphicsView::mouseAltMoved, this, &Petrack::moveTrackPoint);
     connect(mView, &GraphicsView::mouseAltPressed, this, &Petrack::selectPersonForMoveTrackPoint);
+    connect(mView, &GraphicsView::altReleased, this, &Petrack::releaseTrackPoint);
     connect(mView, &GraphicsView::mouseAltReleased, this, &Petrack::releaseTrackPoint);
 
+
     mPlayerWidget = new Player(mAnimation, this);
 
     QVBoxLayout *vLayout = new QVBoxLayout;
@@ -4239,7 +4241,7 @@ void Petrack::selectPersonForMoveTrackPoint(QPointF pos)
     }
 }
 
-void Petrack::releaseTrackPoint(QPointF)
+void Petrack::releaseTrackPoint()
 {
     mManualTrackPointMover.setTrackPoint();
     mAutosave.trackPersonModified();
diff --git a/src/view.cpp b/src/view.cpp
index 131d19009..43d94aa2f 100644
--- a/src/view.cpp
+++ b/src/view.cpp
@@ -154,6 +154,16 @@ void GraphicsView::keyPressEvent(QKeyEvent *event)
     }
 }
 
+void GraphicsView::keyReleaseEvent(QKeyEvent *event)
+{
+    switch(event->key())
+    {
+        case Qt::Key_Alt:
+            emit altReleased();
+            break;
+    }
+}
+
 void GraphicsView::mousePressEvent(QMouseEvent *event)
 {
     if(event->modifiers() & Qt::ShiftModifier)
-- 
GitLab


From 7e0ba5cc867e6702f7d8f40d2032beaf10939772 Mon Sep 17 00:00:00 2001
From: Deniz Kilic <d.kilic@fz-juelich.de>
Date: Fri, 29 Apr 2022 08:56:22 +0200
Subject: [PATCH 12/13] Reviewer comments -- mostly formatting

---
 include/frameRange.h            |  6 +++---
 include/manualTrackpointMover.h |  4 ++--
 src/manualTrackpointMover.cpp   | 14 +++++++-------
 src/petrack.cpp                 |  4 ++--
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/include/frameRange.h b/include/frameRange.h
index 0eb8cfcd9..b532d1d96 100644
--- a/include/frameRange.h
+++ b/include/frameRange.h
@@ -23,9 +23,9 @@
 
 struct FrameRange
 {
-    int before;
-    int after;
-    int current;
+    int before  = 0;
+    int after   = 0;
+    int current = 0;
 };
 
 #endif // FRAMERANGE_H
diff --git a/include/manualTrackpointMover.h b/include/manualTrackpointMover.h
index f1900e63a..b1df17693 100644
--- a/include/manualTrackpointMover.h
+++ b/include/manualTrackpointMover.h
@@ -29,10 +29,10 @@ class ManualTrackpointMover
 public:
     bool selectTrackPoint(
         const QPointF       &pos,
-        const PersonStorage &person_store,
+        const PersonStorage &personStore,
         const QSet<int>     &peds,
         const FrameRange    &range);
-    void moveTrackPoint(const QPointF &pos, PersonStorage &person_store) const;
+    void moveTrackPoint(const QPointF &pos, PersonStorage &personStore) const;
     void setTrackPoint();
 
 private:
diff --git a/src/manualTrackpointMover.cpp b/src/manualTrackpointMover.cpp
index ab646d153..52f76df9f 100644
--- a/src/manualTrackpointMover.cpp
+++ b/src/manualTrackpointMover.cpp
@@ -24,15 +24,15 @@
 
 bool ManualTrackpointMover::selectTrackPoint(
     const QPointF       &pos,
-    const PersonStorage &person_store,
+    const PersonStorage &personStore,
     const QSet<int>     &peds,
     const FrameRange    &range)
 {
-    auto res = person_store.getProximalPersons(pos, peds, range);
+    auto res = personStore.getProximalPersons(pos, peds, range);
 
-    bool successful_selection = res.size() == 1;
+    bool successfulSelection = res.size() == 1;
 
-    if(successful_selection)
+    if(successfulSelection)
     {
         mSelectedPerson = res.front();
     }
@@ -43,14 +43,14 @@ bool ManualTrackpointMover::selectTrackPoint(
             "Too many trajectories",
             "PeTrack can't determine which point you meant. Try selecting fewer trajectories first.");
     }
-    return successful_selection;
+    return successfulSelection;
 }
 
-void ManualTrackpointMover::moveTrackPoint(const QPointF &pos, PersonStorage &person_store) const
+void ManualTrackpointMover::moveTrackPoint(const QPointF &pos, PersonStorage &personStore) const
 {
     if(mSelectedPerson.personID != -1 && mSelectedPerson.frame != -1)
     {
-        person_store.moveTrackPoint(mSelectedPerson.personID, mSelectedPerson.frame, Vec2F{pos});
+        personStore.moveTrackPoint(mSelectedPerson.personID, mSelectedPerson.frame, Vec2F{pos});
     }
 }
 
diff --git a/src/petrack.cpp b/src/petrack.cpp
index 30c5f9123..30014e9c1 100644
--- a/src/petrack.cpp
+++ b/src/petrack.cpp
@@ -4232,10 +4232,10 @@ void Petrack::selectPersonForMoveTrackPoint(QPointF pos)
     range.before  = mControlWidget->trackShowBefore->value();
     range.after   = mControlWidget->trackShowAfter->value();
     range.current = mPlayerWidget->getPos();
-    auto successfully_selected =
+    auto successfullySelected =
         mManualTrackPointMover.selectTrackPoint(pos, mPersonStorage, getPedestrianUserSelection(), range);
 
-    if(successfully_selected)
+    if(successfullySelected)
     {
         setCursor(QCursor{Qt::CursorShape::DragMoveCursor});
     }
-- 
GitLab


From a9ce53fa652e543511875a6316ca06205181f92a Mon Sep 17 00:00:00 2001
From: "Kilic, Deniz" <d.kilic@fz-juelich.de>
Date: Wed, 1 Jun 2022 16:13:31 +0200
Subject: [PATCH 13/13] Add description of shortcuts in Key Bindings Window

---
 src/petrack.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/petrack.cpp b/src/petrack.cpp
index 30014e9c1..22cdc5b2f 100644
--- a/src/petrack.cpp
+++ b/src/petrack.cpp
@@ -1624,7 +1624,9 @@ void Petrack::keyBindings()
         "<dt><kbd>Alt + double-click middle mouse button</kbd></dt><dd>deletes the future part of all trajectories</dd>"
         "<dt><kbd>Shift + t</kbd></dt><dd>toggles tracking online calculation</dd>"
         "<dt><kbd>Shift + double-click left mouse button</kbd></dt><dd>inserts new or moves near trackpoint and "
-        "enables showing only the modified trajectory</dd></dl>"
+        "enables showing only the modified trajectory</dd>"
+        "<dt><kbd>Alt + double-click left mouse button</kbd></dt><dd>jumps to frame of trackpoint under cursor</dd>"
+        "<dt><kbd>Alt + holding left mouse button</kbd></dt><dd>moves trackpoint under cursor</dd></dl>"
         "<p>Further key bindings you will find next to the entries of the menus.</p>");
 
     PMessageBox *mb = new PMessageBox(this, tr("Key Bindings"), out, QIcon());
-- 
GitLab