0.4.1
Loading...
Searching...
No Matches
FlowAnimation.cpp
Go to the documentation of this file.
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
15namespace
16{
17
18/// Queue to store animations till the draw threads pushes them onto the library
19std::vector<std::pair<ax::NodeEditor::LinkId, ax::NodeEditor::FlowDirection>> flowAnimationQueue;
20/// Mutex to lock the animation queue
21std::mutex flowAnimationQueueMutex;
22
23} // namespace
24
25void 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
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}
Handles Flow animations.
void Add(ax::NodeEditor::LinkId id, ax::NodeEditor::FlowDirection direction=ax::NodeEditor::FlowDirection::Forward)
Thread safe flow animaton of links.
void ProcessQueue()
Triggers the queued flow animations.