From fe3466390fd990f5de6b864d4cc0bddc85e7d0d3 Mon Sep 17 00:00:00 2001 From: Itay Carpis Date: Tue, 18 Jul 2017 13:02:12 +0300 Subject: [PATCH 1/4] Added an ability to determine the order of controls appearance in rs-config app Change-Id: I0acd71261961b78f8e005b7c7e055d41c796b9c1 --- .gitignore | 9 ++++--- common/model-views.cpp | 37 +++++++++++++++++++++++++++++ common/model-views.h | 4 ++++ src/ds5/ds5-active.cpp | 27 ++++++++++++++------- src/ds5/ds5-device.cpp | 1 - src/ds5/ds5-options.h | 2 +- src/option.h | 29 +++++++++++++++------- tools/realsense-ui/realsense-ui.cpp | 27 ++++++--------------- 8 files changed, 91 insertions(+), 45 deletions(-) diff --git a/.gitignore b/.gitignore index 6396ef7fdc..d1b7dd36d3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ bin/ lib/ +ubuntu-xenial/ + # CMake build/ @@ -33,10 +35,8 @@ local_ignore/ # QTCreator Project /.qmake.cache /.qmake.stash -*.pro.user -*.pro.user.* -*.qbs.user -*.qbs.user.* +*.user +*.user.* *.moc moc_*.cpp qrc_*.cpp @@ -45,7 +45,6 @@ Makefile* *-build-* librealsense-log.txt -*.vcxproj.user *.pyproj *.orig *.psess diff --git a/common/model-views.cpp b/common/model-views.cpp index 81c45a1dce..508f5f16af 100644 --- a/common/model-views.cpp +++ b/common/model-views.cpp @@ -707,6 +707,43 @@ namespace rs2 } } + void subdevice_model::draw_options(const std::vector& drawing_order, + bool update_read_only_options, std::string& error_message) + { + for (auto& opt : drawing_order) + { + draw_option(opt, update_read_only_options, error_message); + } + + for (auto i = 0; i < RS2_OPTION_COUNT; i++) + { + auto opt = static_cast(i); + if(std::find(drawing_order.begin(), drawing_order.end(), opt) == drawing_order.end()) + { + draw_option(opt, update_read_only_options, error_message); + } + } + } + + void subdevice_model::draw_option(rs2_option opt, bool update_read_only_options, + std::string& error_message) + { + auto&& metadata = options_metadata[opt]; + if (update_read_only_options) + { + metadata.update_supported(error_message); + if (metadata.supported && streaming) + { + metadata.update_read_only(error_message); + if (metadata.read_only) + { + metadata.update_all(error_message); + } + } + } + metadata.draw(error_message); + } + stream_model::stream_model() : texture ( std::unique_ptr(new texture_buffer())) {} diff --git a/common/model-views.h b/common/model-views.h index 2917cfaef4..39f3085a5d 100644 --- a/common/model-views.h +++ b/common/model-views.h @@ -226,6 +226,10 @@ namespace rs2 void stop(); void play(const std::vector& profiles); void update(std::string& error_message); + void draw_options(const std::vector& drawing_order, + bool update_read_only_options, std::string& error_message); + void draw_option(rs2_option opt, bool update_read_only_options, + std::string& error_message); bool is_paused() const; void pause(); diff --git a/src/ds5/ds5-active.cpp b/src/ds5/ds5-active.cpp index 91b0681877..7364a1e250 100644 --- a/src/ds5/ds5-active.cpp +++ b/src/ds5/ds5-active.cpp @@ -25,15 +25,24 @@ namespace librealsense { using namespace ds; - get_depth_sensor().register_option(RS2_OPTION_EMITTER_ENABLED, std::make_shared(get_depth_sensor())); - - get_depth_sensor().register_option(RS2_OPTION_LASER_POWER, - std::make_shared>(get_depth_sensor(), - depth_xu, - DS5_LASER_POWER, "Manual laser power in mw. applicable only when laser power mode is set to Manual")); - - get_depth_sensor().register_option(RS2_OPTION_PROJECTOR_TEMPERATURE, - std::make_shared(get_depth_sensor(), + auto& depth_ep = get_depth_sensor(); + auto emitter_enabled = std::make_shared(depth_ep); + depth_ep.register_option(RS2_OPTION_EMITTER_ENABLED, emitter_enabled); + + auto laser_power = std::make_shared>(depth_ep, + depth_xu, + DS5_LASER_POWER, + "Manual laser power in mw. applicable only when laser power mode is set to Manual"); + depth_ep.register_option(RS2_OPTION_LASER_POWER, laser_power); + + depth_ep.register_option(RS2_OPTION_LASER_POWER, + std::make_shared( + laser_power, + emitter_enabled, + std::vector{0.f, 2.f}, 1.f)); + + depth_ep.register_option(RS2_OPTION_PROJECTOR_TEMPERATURE, + std::make_shared(depth_ep, RS2_OPTION_PROJECTOR_TEMPERATURE)); } diff --git a/src/ds5/ds5-device.cpp b/src/ds5/ds5-device.cpp index d2bf4b11df..c32d7cd794 100644 --- a/src/ds5/ds5-device.cpp +++ b/src/ds5/ds5-device.cpp @@ -223,7 +223,6 @@ namespace librealsense std::make_shared( exposure_option, enable_auto_exposure)); - } if (_fw_version >= firmware_version("5.5.8.0")) diff --git a/src/ds5/ds5-options.h b/src/ds5/ds5-options.h index 3b7dbd6ddc..4c8450cf3f 100644 --- a/src/ds5/ds5-options.h +++ b/src/ds5/ds5-options.h @@ -32,7 +32,7 @@ namespace librealsense private: uvc_sensor& _ep; - rs2_option _option; + rs2_option _option; }; class motion_module_temperature_option : public readonly_option diff --git a/src/option.h b/src/option.h index d364e6f120..10c9db8727 100644 --- a/src/option.h +++ b/src/option.h @@ -226,7 +226,7 @@ namespace librealsense }; /** \brief auto_disabling_control class provided a control - * that disable auto exposure whan changing the auto disabling control value */ + * that disable auto-control when changing the auto disabling control value */ class auto_disabling_control : public option { public: @@ -243,12 +243,19 @@ namespace librealsense auto strong = _auto_exposure.lock(); assert(strong); - auto is_auto = strong->query(); + auto move_to_manual = false; + auto val = strong->query(); - if(strong && is_auto) + if (std::find(_move_to_manual_values.begin(), + _move_to_manual_values.end(), val) != _move_to_manual_values.end()) { - LOG_DEBUG("Move auto exposure to manual mode in order set value to gain controll"); - strong->set(0); + move_to_manual = true; + } + + if (strong && move_to_manual) + { + LOG_DEBUG("Move option to manual mode in order to set a value"); + strong->set(_manual_value); } _auto_disabling_control->set(value); } @@ -273,16 +280,20 @@ namespace librealsense return _auto_disabling_control->is_read_only(); } - explicit auto_disabling_control(std::shared_ptr