diff --git a/applications/gui2/src/views/thumbnails.cpp b/applications/gui2/src/views/thumbnails.cpp index 78b1b86f120e86baf3b6392696aab3e9f8a8e0e2..7250e176341d7888d3256e2010cdec4aaab6a7a3 100644 --- a/applications/gui2/src/views/thumbnails.cpp +++ b/applications/gui2/src/views/thumbnails.cpp @@ -133,18 +133,21 @@ Thumbnails::~Thumbnails() { } bool Thumbnails::mouseButtonEvent(const nanogui::Vector2i &p, int button, bool down, int modifiers) { - if (button == 1) { - if (!down) { - context_menu_->setPosition(p - mPos); - context_menu_->setVisible(true); - return true; + bool r = View::mouseButtonEvent(p, button, down, modifiers); + + if (!r) { + if (button == 1) { + if (!down) { + context_menu_->setPosition(p - mPos); + context_menu_->setVisible(true); + return true; + } + } else { + context_menu_->setVisible(false); } - } else { - context_menu_->setVisible(false); } - bool r = View::mouseButtonEvent(p, button, down, modifiers); - return r; + return true; } void Thumbnails::updateThumbnails() { diff --git a/components/codecs/src/channels.cpp b/components/codecs/src/channels.cpp index 54d1181c09a71e17c97a2c7ab158fdebbe89ca95..cc30c51683d4947507dc9bec81bbca3159dcef95 100644 --- a/components/codecs/src/channels.cpp +++ b/components/codecs/src/channels.cpp @@ -1,110 +1,74 @@ #include <ftl/codecs/channels.hpp> - +#include <unordered_map> #include <opencv2/opencv.hpp> +using ftl::codecs::Channel; + struct ChannelInfo { const char *name; int type; }; -static ChannelInfo info[] = { - "Colour", CV_8UC4, // 0 - "Depth", CV_32F, // 1 - "Right", CV_8UC4, // 2 - "DepthRight", CV_32F, // 3 - "Deviation", CV_32F, // 4 - "Normals", CV_16FC4, // 5 - "Weights", CV_16SC1, // 6 - "Confidence", CV_32F, // 7 - "EnergyVector", CV_32FC4, // 8 - "Flow", CV_32F, // 9 - "Energy", CV_32F, // 10 - "Mask", CV_8U, // 11 - "Density", CV_32F, // 12 - "Support1", CV_8UC4, // 13 - "Support2", CV_8UC4, // 14 - "Segmentation", CV_32S, // 15 - - "ColourNormals", 0, // 16 - "ColourHighRes", CV_8UC4, // 17 - "Disparity", CV_32F, // 18 - "Smoothing", 0, // 19 - "Colour2HighRes", CV_8UC4, // 20 - "Overlay", 0, // 21 - "GroundTruth", CV_32F, // 22 - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, +static const std::unordered_map<Channel,ChannelInfo> info = { + {Channel::Colour, {"Left", CV_8UC4}}, + {Channel::Depth, {"Depth", CV_32F}}, + {Channel::Right, {"Right", CV_8UC4}}, + {Channel::Depth2, {"Depth Right", CV_32F}}, + {Channel::Deviation, {"Deviation", CV_32F}}, + {Channel::Normals, {"Normals", CV_32FC4}}, + {Channel::Weights, {"Weights", CV_32F}}, + {Channel::Confidence, {"Confidence", CV_32F}}, + {Channel::EnergyVector, {"Energy Vector", CV_32FC4}}, + {Channel::Flow, {"Flow", CV_32F}}, + {Channel::Energy, {"Energy", CV_32F}}, + {Channel::Mask, {"Mask", CV_8U}}, + {Channel::Density, {"Density", CV_32F}}, + {Channel::Support1, {"Support1", CV_8UC4}}, + {Channel::Support2, {"Support2", CV_8UC4}}, + {Channel::Segmentation, {"Segmentation", CV_8U}}, + {Channel::Normals2, {"Normals Right", CV_32FC4}}, + {Channel::ColourHighRes, {"Left High-res", CV_8UC4}}, + {Channel::Disparity, {"Disparity", CV_16S}}, + {Channel::Smoothing, {"Smoothing", CV_32F}}, + {Channel::Colour2HighRes, {"Right High-res", CV_8UC4}}, + {Channel::Overlay, {"Overlay", CV_8UC4}}, + {Channel::GroundTruth, {"Ground Truth", CV_32F}}, - "AudioLeft", 0, - "AudioRight", 0, + {Channel::AudioMono, {"Audio (Mono)", -1}}, + {Channel::AudioStereo, {"Audio (Stereo)", -1}}, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - "NoName", 0, - - "Configuration", 0, - "Calibration", 0, - "Pose", 0, - "Calibration2", 0, - "Index", 0, - "Control", 0, - "Settings3", 0, - "MetaData", 0, - "Capabilities", 0, - "CalibrationData", 0 -}; + {Channel::Configuration, {"Configuration", -1}}, + {Channel::Calibration, {"Calibration", -1}}, + {Channel::Pose, {"Pose", -1}}, + {Channel::Calibration2, {"Calibration High-res", -1}}, + {Channel::MetaData, {"Meta Data", -1}}, + {Channel::Capabilities, {"Capabilities", -1}}, + {Channel::CalibrationData, {"Calibration Data", -1}}, + {Channel::Thumbnail, {"Thumbnail", -1}}, -static ChannelInfo info_data[] = { - "Data", 0, - "Faces", 0, - "Transforms", 0, - "Shapes3D", 0, - "Messages", 0, - "Touch", 0 + {Channel::Data, {"Generic Data", -1}}, + {Channel::Faces, {"Faces", -1}}, + {Channel::Shapes3D, {"Shapes 3D", -1}}, + {Channel::Messages, {"Messages", -1}}, + {Channel::Touch, {"Touch", -1}} }; std::string ftl::codecs::name(Channel c) { - // FIXME: This function is dangerous if (c == Channel::None) return "None"; - else if (int(c) >= 2048) return info_data[(int)c - 2048].name; - else return info[(int)c].name; + auto i = info.find(c); + if (i != info.end()) { + return i->second.name; + } else { + return "Unknown"; + } } int ftl::codecs::type(Channel c) { if (c == Channel::None) return 0; - else return info[(int)c].type; + auto i = info.find(c); + if (i != info.end()) { + return i->second.type; + } else { + return -1; + } } diff --git a/components/common/cpp/include/ftl/configurable.hpp b/components/common/cpp/include/ftl/configurable.hpp index f08f5a72ac31e836972a327fbc1e47eb11a6b1f6..b2a66943d35e7cba6a86d6842e037d0068d15feb 100644 --- a/components/common/cpp/include/ftl/configurable.hpp +++ b/components/common/cpp/include/ftl/configurable.hpp @@ -150,7 +150,9 @@ class Configurable { std::string restore_; std::string defaults_; std::unordered_set<std::string> save_allowed_; - std::map<std::string, std::list<std::function<void()>>> observers_; + + typedef std::list<std::function<void()>> ObserverList; + std::unordered_map<std::string,ObserverList> observers_; void _trigger(const std::string &name); };