diff --git a/applications/gui/src/camera.cpp b/applications/gui/src/camera.cpp index debb8e73d5cf6f1f1bc1d685bb7298350014614c..b9812d95e94b5e2af57850e44cc753fcb58575f0 100644 --- a/applications/gui/src/camera.cpp +++ b/applications/gui/src/camera.cpp @@ -493,6 +493,16 @@ const GLTexture &ftl::gui::Camera::captureFrame() { return texture1_; } +void ftl::gui::Camera::snapshot() { + UNIQUE_LOCK(mutex_, lk); + char timestamp[18]; + std::time_t t = std::time(NULL); + std::strftime(timestamp, sizeof(timestamp), "%F-%H%M%S", std::localtime(&t)); + cv::Mat image; + cv::flip(im1_, image, 0); + cv::imwrite(std::string(timestamp) + ".png", image); +} + nlohmann::json ftl::gui::Camera::getMetaData() { return nlohmann::json(); } diff --git a/applications/gui/src/camera.hpp b/applications/gui/src/camera.hpp index 24dcbacfdc51d20166ffc49175f268140e4dcdf3..cc874305c36daa9918ce3360f07f2da64a71b6e9 100644 --- a/applications/gui/src/camera.hpp +++ b/applications/gui/src/camera.hpp @@ -51,6 +51,8 @@ class Camera { bool thumbnail(cv::Mat &thumb); + void snapshot(); + nlohmann::json getMetaData(); StatisticsImage *stats_ = nullptr; diff --git a/applications/gui/src/config_window.cpp b/applications/gui/src/config_window.cpp index d75772f09e84e391e8d6eedd342fe819c1349c68..6112fe82292cd4470b626e9a5242038049600366 100644 --- a/applications/gui/src/config_window.cpp +++ b/applications/gui/src/config_window.cpp @@ -6,6 +6,7 @@ #include <nanogui/button.h> #include <nanogui/entypo.h> #include <nanogui/formhelper.h> +#include <nanogui/vscrollpanel.h> #include <vector> #include <string> @@ -27,8 +28,13 @@ ConfigWindow::ConfigWindow(nanogui::Widget *parent, ftl::ctrl::Master *ctrl) new Label(this, "Select Configurable","sans-bold"); + auto vscroll = new VScrollPanel(this); + vscroll->setFixedHeight(300); + Widget *buttons = new Widget(vscroll); + buttons->setLayout(new BoxLayout(Orientation::Vertical, Alignment::Fill)); + for (auto c : configurables_) { - auto itembutton = new Button(this, c); + auto itembutton = new Button(buttons, c); itembutton->setCallback([this,c]() { LOG(INFO) << "Change configurable: " << c; _buildForm(c); diff --git a/applications/gui/src/media_panel.cpp b/applications/gui/src/media_panel.cpp index 407fb917222c078c76d34a58d00ac93f2deb7228..639b1c50de9b0ee74f71f673323097e07f09c2fc 100644 --- a/applications/gui/src/media_panel.cpp +++ b/applications/gui/src/media_panel.cpp @@ -34,9 +34,22 @@ MediaPanel::MediaPanel(ftl::gui::Screen *screen) : nanogui::Window(screen, ""), if (cam) cam->showPoseWindow(); }); - button = new Button(this, "", ENTYPO_ICON_CONTROLLER_RECORD); - button->setFlags(Button::ToggleButton); - button->setChangeCallback([this,button](bool state) { + auto recordbutton = new PopupButton(this, "", ENTYPO_ICON_CONTROLLER_RECORD); + recordbutton->setTooltip("Record"); + recordbutton->setSide(Popup::Side::Right); + recordbutton->setChevronIcon(0); + auto recordpopup = recordbutton->popup(); + recordpopup->setLayout(new GroupLayout()); + recordpopup->setTheme(screen->toolbuttheme); + recordpopup->setAnchorHeight(150); + auto itembutton = new Button(recordpopup, "Snapshot"); + itembutton->setCallback([this](){ + screen_->activeCamera()->snapshot(); + }); + itembutton = new Button(recordpopup, "2D video recording"); + itembutton = new Button(recordpopup, "Depth video recording"); + itembutton->setFlags(Button::ToggleButton); + itembutton->setChangeCallback([this,recordbutton](bool state) { auto tag = screen_->activeCamera()->source()->get<std::string>("uri"); if (tag) { auto tagvalue = tag.value(); @@ -45,14 +58,16 @@ MediaPanel::MediaPanel(ftl::gui::Screen *screen) : nanogui::Window(screen, ""), ftl::Configurable *configurable = configurables[0]; if (state){ configurable->set("record", true); - button->setTextColor(nanogui::Color(1.0f,0.1f,0.1f,1.0f)); + recordbutton->setTextColor(nanogui::Color(1.0f,0.1f,0.1f,1.0f)); } else { - button->setTextColor(nanogui::Color(1.0f,1.0f,1.0f,1.0f)); + recordbutton->setTextColor(nanogui::Color(1.0f,1.0f,1.0f,1.0f)); configurable->set("record", false); } } } }); + itembutton = new Button(recordpopup, "3D scene recording"); + itembutton = new Button(recordpopup, "Detailed recording options"); button = new Button(this, "", ENTYPO_ICON_CONTROLLER_STOP); button->setCallback([this]() { diff --git a/applications/gui/src/screen.cpp b/applications/gui/src/screen.cpp index 474952f0c8e5df041962a3333d5a1c0ea0a677be..eb3650f3f460437cc5d33120e1b7f00dbfced3cf 100644 --- a/applications/gui/src/screen.cpp +++ b/applications/gui/src/screen.cpp @@ -213,18 +213,18 @@ ftl::gui::Screen::Screen(ftl::Configurable *proot, ftl::net::Universe *pnet, ftl popup->setVisible(false); }); - popbutton = new PopupButton(innertool, "", ENTYPO_ICON_COG); - popbutton->setIconExtraScale(1.5f); - popbutton->setTheme(toolbuttheme); - popbutton->setTooltip("Settings"); - popbutton->setFixedSize(Vector2i(40,40)); - popbutton->setSide(Popup::Side::Right); - popbutton->setChevronIcon(0); - // popbutton->setPosition(Vector2i(5,height()-50)); - popup = popbutton->popup(); - popup->setLayout(new GroupLayout()); - popup->setTheme(toolbuttheme); + itembutton = new Button(innertool, "", ENTYPO_ICON_COG); + itembutton->setIconExtraScale(1.5f); + itembutton->setTheme(toolbuttheme); + itembutton->setTooltip("Settings"); + itembutton->setFixedSize(Vector2i(40,40)); + + itembutton->setCallback([this]() { + auto config_window = new ConfigWindow(this, ctrl_); + config_window->setTheme(windowtheme); + }); + /* //net_->onConnect([this,popup](ftl::net::Peer *p) { { LOG(INFO) << "NET CONNECT"; @@ -247,6 +247,7 @@ ftl::gui::Screen::Screen(ftl::Configurable *proot, ftl::net::Universe *pnet, ftl auto config_window = new ConfigWindow(this, ctrl_); config_window->setTheme(windowtheme); }); + */ //configwindow_ = new ConfigWindow(parent, ctrl_); cwindow_ = new ftl::gui::ControlWindow(this, controller);