Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helper functions for formatted values on metadata #12550

Merged
merged 2 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion common/stream-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ namespace rs2
std::string desc;
if( descriptions.find( val ) != descriptions.end() )
desc = descriptions[val];
stream_details.push_back( { name, rsutils::string::from( kvp.second ), desc } );
stream_details.push_back( { name, format_value(val, kvp.second), desc } );
}
}

Expand Down Expand Up @@ -1041,6 +1041,23 @@ namespace rs2
ImGui::EndChild();
}

std::string stream_model::format_value(rs2_frame_metadata_value& md_val, rs2_metadata_type& attribute_val) const
{
if (should_show_in_hex(md_val))
return rsutils::string::from() << "0x" << std::hex << attribute_val; // return value as hex
return rsutils::string::from() << attribute_val;
}

bool stream_model::should_show_in_hex(rs2_frame_metadata_value& md_val) const
{
// place in the SET metadata types you wish to display in HEX format
static std::unordered_set< int > show_in_hex;

if (show_in_hex.find(md_val) != show_in_hex.end())
return true;
return false;
}

void stream_model::show_stream_footer(ImFont* font, const rect &stream_rect, const mouse_info& mouse, const std::map<int, stream_model> &streams, viewer_model& viewer)
{
auto non_visual_stream = (profile.stream_type() == RS2_STREAM_GYRO)
Expand Down
2 changes: 2 additions & 0 deletions common/stream-model.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ namespace rs2
std::unique_ptr< reflectivity > _reflectivity;
rsutils::number::stabilized_value<float> _stabilized_reflectivity;

std::string format_value(rs2_frame_metadata_value& md_val, rs2_metadata_type& attribute_val) const;
bool should_show_in_hex(rs2_frame_metadata_value& md_val) const;
};


Expand Down
Loading