Skip to content
Snippets Groups Projects
Commit 495215ac authored by Nicolas Pope's avatar Nicolas Pope
Browse files

GUI to use actual available channels in frame

parent 043ba798
Branches
No related tags found
1 merge request!316Resolves #343 GUI and Frame Refactor
Pipeline #28074 failed
......@@ -63,7 +63,7 @@ void Camera::_initiate(ftl::data::Frame &frame) {
}
});
panel->setAvailableChannels({Channel::Colour, Channel::Right, Channel::Depth});
panel->setAvailableChannels(frame.available());
setChannel(channel);
screen->setView(view);
......@@ -101,6 +101,7 @@ void Camera::activate(ftl::data::FrameID id) {
);
// For first data, extract useful things and create view
// Must be done in GUI thread, hence use of cv.
std::unique_lock<std::mutex> lk(m);
cv.wait_for(lk, 1s, [this](){ return has_seen_frame_; });
_initiate(std::atomic_load(&current_fs_)->frames[frame_idx]);
......
......
......@@ -164,7 +164,7 @@ class Frame {
inline const std::unordered_map<ftl::codecs::Channel, ChangeType> &changed() const { return changed_; }
std::unordered_set<ftl::codecs::Channel> channels();
std::unordered_set<ftl::codecs::Channel> channels() const;
template <typename T>
bool isType(ftl::codecs::Channel c) const;
......
......
......@@ -7,6 +7,7 @@ using ftl::data::Session;
using ftl::data::ChannelConfig;
using ftl::data::StorageMode;
using ftl::data::FrameStatus;
using ftl::codecs::Channel;
#define LOGURU_REPLACE_GLOG 1
#include <loguru.hpp>
......@@ -97,6 +98,19 @@ bool ftl::data::Frame::availableAll(const std::unordered_set<ftl::codecs::Channe
return result;
}
std::unordered_set<ftl::codecs::Channel> ftl::data::Frame::available() const {
std::unordered_set<ftl::codecs::Channel> result = channels();
uint64_t m = 1;
// TODO: NAIVE, use ffs or ctz.
for (int i=0; i<32; ++i) {
if (m & available_) result.emplace(static_cast<Channel>(i));
m <<= 1;
}
return result;
}
void ftl::data::Frame::remove(ftl::codecs::Channel c) {
const auto &i = data_.find(c);
if (i != data_.end()) {
......@@ -377,7 +391,7 @@ Frame Frame::make_standalone() {
return f;
}
std::unordered_set<ftl::codecs::Channel> Frame::channels() {
std::unordered_set<ftl::codecs::Channel> Frame::channels() const {
std::unordered_set<ftl::codecs::Channel> res{};
for (const auto& [k, v] : data_) {
std::ignore = v;
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment