hivemind 1.0.0
Loading...
Searching...
No Matches
keyframe_manager.cpp
Go to the documentation of this file.
2
3#include <iostream>
4
5namespace KeyframeManagement
6{
7
8 void
9 KeyframeManager::AddKeyframe(int agentId, float timeStamp, float x, float y,
10 float z)
11 {
12 Core::CartesianCoordinate position = { x, y, z };
13 Core::Keyframe newKeyframe = { agentId, timeStamp, position };
14 AddKeyframe(newKeyframe);
15 }
16
17 void
18 KeyframeManager::AddKeyframe(int agentId, float timeStamp,
20 {
21 Core::Keyframe newKeyframe = { agentId, timeStamp, position };
22 AddKeyframe(newKeyframe);
23 }
24
25 // This function iterate over each keyframe in the m_Keyframes vector and
26 // check if the timestamp and agent ID of the keyframe match the provided
27 // keyframe. If a match is found, update the position of the existing
28 // keyframe
29 void
31 {
32 bool exists = false;
33 for (Core::Keyframe& kf : m_Keyframes) {
34 if (keyframe.TimeStamp == kf.TimeStamp &&
35 keyframe.AgentId == kf.AgentId) {
36 kf.Position = keyframe.Position;
37 exists = true;
38 }
39 }
40 // If no existing keyframe with the same timestamp and agent ID is
41 // found, add the new keyframe
42 if (!exists) {
43 m_Keyframes.push_back(keyframe);
44 }
45
46 emit KeyframeAdded();
47 }
48
49 void
51 {
52 for (auto it = m_Keyframes.begin(); it != m_Keyframes.end(); ++it) {
53 if (it->AgentId == keyframe.AgentId &&
54 it->TimeStamp == keyframe.TimeStamp &&
55 it->Position.X == keyframe.Position.X &&
56 it->Position.Y == keyframe.Position.Y &&
57 it->Position.Z == keyframe.Position.Z) {
58 m_Keyframes.erase(it);
59 break;
60 }
61 }
62 }
63
64 void
66 {
67 std::cout << "DebugDump called. Number of keyframes: "
68 << m_Keyframes.size() << std::endl;
69 std::cout << "Keyframes:" << std::endl;
70 for (const Core::Keyframe& kf : m_Keyframes) {
71 std::cout << "AgentId: " << kf.AgentId
72 << " TimeStamp: " << kf.TimeStamp
73 << " X: " << kf.Position.X << " Y: " << kf.Position.Y
74 << " Z: " << kf.Position.Z << std::endl;
75 }
76 }
77
78} // namespace KeyframeManagement
void RemoveKeyframe(const Core::Keyframe &keyframe)
Removes a keyframe from the keyframe list.
void DebugDump(void) const
Dumps keyframe information to the console for debugging purposes.
std::vector< Core::Keyframe > m_Keyframes
void AddKeyframe(int agentId, float timeStamp, float x, float y, float z)
Adds a keyframe to the keyframe list using x, y, and z coordinates.
A structure that represents a cartesian coordinate.
Definition: types.h:12
A structure representing an agent's position in cartesian space at a given point in time.
Definition: types.h:69
CartesianCoordinate Position
Definition: types.h:78
int AgentId
Definition: types.h:76
float TimeStamp
Definition: types.h:77