diff --git a/applications/gui2/src/modules/camera.cpp b/applications/gui2/src/modules/camera.cpp index eb8d9ea31aaa867b3c7179077aeee9c75c46bd98..5eb1a71e6c254760481e51f757b5c4887e8ca461 100644 --- a/applications/gui2/src/modules/camera.cpp +++ b/applications/gui2/src/modules/camera.cpp @@ -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(¤t_fs_)->frames[frame_idx]); diff --git a/components/structures/include/ftl/data/new_frame.hpp b/components/structures/include/ftl/data/new_frame.hpp index 59f9b5781045a8a0ae3530c914109dae083b1e39..71a21283cb24e9c266be0fc4dc0618ad036a6b98 100644 --- a/components/structures/include/ftl/data/new_frame.hpp +++ b/components/structures/include/ftl/data/new_frame.hpp @@ -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; diff --git a/components/structures/src/new_frame.cpp b/components/structures/src/new_frame.cpp index 7872f2d823d907b409ab88fd3a1d5b5f584fff80..b9ccbc6ce6e6324cc09582e525e14eff193cf4e0 100644 --- a/components/structures/src/new_frame.cpp +++ b/components/structures/src/new_frame.cpp @@ -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;