Line |
Branch |
Exec |
Source |
1 |
|
|
// This file is part of INSTINCT, the INS Toolkit for Integrated |
2 |
|
|
// Navigation Concepts and Training by the Institute of Navigation of |
3 |
|
|
// the University of Stuttgart, Germany. |
4 |
|
|
// |
5 |
|
|
// This Source Code Form is subject to the terms of the Mozilla Public |
6 |
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this |
7 |
|
|
// file, You can obtain one at https://mozilla.org/MPL/2.0/. |
8 |
|
|
|
9 |
|
|
#include "FlowAnimation.hpp" |
10 |
|
|
|
11 |
|
|
#include <vector> |
12 |
|
|
#include <mutex> |
13 |
|
|
#include <algorithm> |
14 |
|
|
|
15 |
|
|
namespace |
16 |
|
|
{ |
17 |
|
|
|
18 |
|
|
/// Queue to store animations till the draw threads pushes them onto the library |
19 |
|
|
std::vector<std::pair<ax::NodeEditor::LinkId, ax::NodeEditor::FlowDirection>> flowAnimationQueue; |
20 |
|
|
/// Mutex to lock the animation queue |
21 |
|
|
std::mutex flowAnimationQueueMutex; |
22 |
|
|
|
23 |
|
|
} // namespace |
24 |
|
|
|
25 |
|
✗ |
void NAV::FlowAnimation::Add(ax::NodeEditor::LinkId id, ax::NodeEditor::FlowDirection direction) |
26 |
|
|
{ |
27 |
|
✗ |
const std::scoped_lock<std::mutex> lock(flowAnimationQueueMutex); |
28 |
|
✗ |
if (std::ranges::find(flowAnimationQueue, std::make_pair(id, direction)) == flowAnimationQueue.end()) |
29 |
|
|
{ |
30 |
|
✗ |
flowAnimationQueue.emplace_back(id, direction); |
31 |
|
|
} |
32 |
|
✗ |
} |
33 |
|
|
|
34 |
|
✗ |
void NAV::FlowAnimation::ProcessQueue() |
35 |
|
|
{ |
36 |
|
✗ |
const std::scoped_lock<std::mutex> lock(flowAnimationQueueMutex); |
37 |
|
✗ |
for (const auto& [linkId, direction] : flowAnimationQueue) |
38 |
|
|
{ |
39 |
|
✗ |
ax::NodeEditor::Flow(linkId, direction); |
40 |
|
|
} |
41 |
|
|
|
42 |
|
✗ |
flowAnimationQueue.clear(); |
43 |
|
✗ |
} |
44 |
|
|
|