Skip to content

Commit

Permalink
Merge pull request IntelRealSense#1549 from aangerma/development
Browse files Browse the repository at this point in the history
Fixed bug DSO-8817 - enable loading json file in DQT.
  • Loading branch information
dorodnic authored Apr 16, 2018
2 parents 428b80e + b196dd7 commit 19006f8
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 12 deletions.
28 changes: 20 additions & 8 deletions common/model-views.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4949,7 +4949,9 @@ namespace rs2
ux_window& window,
std::string& error_message,
viewer_model& viewer,
bool update_read_only_options)
bool update_read_only_options,
bool load_json_if_streaming,
json_loading_func json_loading)
{
const float panel_height = 40.f;
auto panel_pos = ImGui::GetCursorPos();
Expand Down Expand Up @@ -5152,26 +5154,33 @@ namespace rs2
std::string upload_button_name = to_string() << textual_icons::upload << "##" << id;
ImGui::PushStyleColor(ImGuiCol_Text, light_grey);
ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, light_grey);
if (ImGui::ButtonEx(upload_button_name.c_str(), icons_size, is_streaming ? ImGuiButtonFlags_Disabled : buttons_flags))

if (ImGui::ButtonEx(upload_button_name.c_str(), icons_size, (is_streaming && !load_json_if_streaming) ? ImGuiButtonFlags_Disabled : buttons_flags))
{
if (is_advanced_mode_enabled)
{
auto ret = file_dialog_open(open_file, "JavaScript Object Notation (JSON)\0*.json\0", NULL, NULL);
if (ret)
json_loading([&]()
{
error_message = safe_call([&]() { load_json(ret); });
}
auto ret = file_dialog_open(open_file, "JavaScript Object Notation (JSON)\0*.json\0", NULL, NULL);
if (ret)
{
error_message = safe_call([&]() { load_json(ret); });
}
});
}
else
{
require_advanced_mode_enable_prompt = true;
}
}

if (ImGui::IsItemHovered())
{
std::string tooltip = to_string() << "Load pre-configured settings" << (is_streaming ? " (Disabled while streaming)" : "");
std::string tooltip = to_string() << "Load pre-configured settings" << (is_streaming && !load_json_if_streaming ? " (Disabled while streaming)" : "");
ImGui::SetTooltip("%s", tooltip.c_str());
}

ImGui::SameLine();

////////////////////////////////////////
Expand Down Expand Up @@ -5220,7 +5229,10 @@ namespace rs2
device_model*& device_to_remove,
viewer_model& viewer, float windows_width,
bool update_read_only_options,
std::vector<std::function<void()>>& draw_later, bool draw_device_outline)
std::vector<std::function<void()>>& draw_later,
bool load_json_if_streaming,
json_loading_func json_loading,
bool draw_device_outline)
{
////////////////////////////////////////
// draw device header
Expand Down Expand Up @@ -5333,7 +5345,7 @@ namespace rs2
const float horizontal_space_before_device_control = 3.0f;
auto advanced_mode_pos = ImVec2{ pos.x + horizontal_space_before_device_control, pos.y + vertical_space_before_advanced_mode_control };
ImGui::SetCursorPos(advanced_mode_pos);
const float advanced_mode_panel_height = draw_preset_panel(panel_width, window, error_message, viewer, update_read_only_options);
const float advanced_mode_panel_height = draw_preset_panel(panel_width, window, error_message, viewer, update_read_only_options, load_json_if_streaming, json_loading);
ImGui::SetCursorPos({ advanced_mode_pos.x, advanced_mode_pos.y + advanced_mode_panel_height });
}

Expand Down
11 changes: 9 additions & 2 deletions common/model-views.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ namespace rs2
class device_model
{
public:
typedef std::function<void(std::function<void()> load)> json_loading_func;

void reset();
explicit device_model(device& dev, std::string& error_message, viewer_model& viewer);
void start_recording(const std::string& path, std::string& error_message);
Expand All @@ -462,7 +464,10 @@ namespace rs2
device_model*& device_to_remove,
viewer_model& viewer, float windows_width,
bool update_read_only_options,
std::vector<std::function<void()>>& draw_later, bool draw_device_outline = true);
std::vector<std::function<void()>>& draw_later,
bool load_json_if_streaming = false,
json_loading_func json_loading = [](std::function<void()> load) {load(); },
bool draw_device_outline = true);
void handle_harware_events(const std::string& serialized_data);

std::vector<std::shared_ptr<subdevice_model>> subdevices;
Expand Down Expand Up @@ -503,7 +508,9 @@ namespace rs2
ux_window& window,
std::string& error_message,
viewer_model& viewer,
bool update_read_only_options);
bool update_read_only_options,
bool load_json_if_streaming,
json_loading_func json_loading);
bool prompt_toggle_advanced_mode(bool enable_advanced_mode, const std::string& message_text,
std::vector<std::string>& restarting_device_info,
viewer_model& view,
Expand Down
26 changes: 24 additions & 2 deletions tools/depth-quality/depth-quality-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,13 +475,35 @@ namespace rs2
device_model* device_to_remove = nullptr;
std::vector<std::function<void()>> draw_later;
auto windows_width = ImGui::GetContentRegionMax().x;

auto json_loaded = false;
_device_model->draw_controls(_viewer_model.panel_width, _viewer_model.panel_y,
win,
_error_message, device_to_remove, _viewer_model, windows_width,
_update_readonly_options_timer,
draw_later, false);
draw_later, true,
[&](std::function<void()>func)
{
auto profile =_pipe.get_active_profile();
_pipe.stop();
func();

auto streams = profile.get_streams();
config cfg;

for (auto&& s : streams)
{
cfg.enable_stream(s.stream_type(), s.stream_index(), s.format(), s.fps());
}
_pipe.start(cfg);

json_loaded = true;
},
false);

if (json_loaded)
{
update_configuration();
}
ImGui::SetContentRegionWidth(windows_width);
auto pos = ImGui::GetCursorScreenPos();

Expand Down

0 comments on commit 19006f8

Please sign in to comment.