Monado OpenXR Runtime
gui_scene_debug.c File Reference

A debugging scene. More...

#include "xrt/xrt_config_have.h"
#include "os/os_time.h"
#include "util/u_var.h"
#include "util/u_misc.h"
#include "util/u_sink.h"
#include "util/u_debug.h"
#include "util/u_native_images_debug.h"
#include "tracking/t_tracking.h"
#include "xrt/xrt_frame.h"
#include "xrt/xrt_prober.h"
#include "xrt/xrt_tracking.h"
#include "xrt/xrt_settings.h"
#include "xrt/xrt_frameserver.h"
#include "math/m_api.h"
#include "math/m_filter_fifo.h"
#include "gui_common.h"
#include "gui_imgui.h"
#include "gui_window_record.h"
#include "gui_widget_native_images.h"
#include "imgui_monado/cimgui_monado.h"
#include <float.h>
Include dependency graph for gui_scene_debug.c:

Data Structures

struct  debug_record
 A single record window, here only used to draw a single element in a object window, holds all the needed state. More...
 
struct  debug_scene
 A GUI scene for debugging Monado while it is running, it uses the variable tracking code in the util/u_var.h file to provide live updates state. More...
 
struct  draw_state
 One "frame" of draw state, what is passed to the variable tracking visitor functions, holds pointers to the program and live state such as visibility stack of gui headers. More...
 
struct  plot_state
 State for plotting m_ff_vec3_f32, assumes it's relative to now. More...
 
struct  curated_state
 Extra state for curated debug UI. More...
 

Macros

#define MAX_HEADER_NESTING   256
 How many nested gui headers can we show, overly large. More...
 
#define COLOR_FLAGS   (ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_PickerHueWheel)
 Shared flags for color gui elements. More...
 
#define PLOT_HELPER(elm)
 
#define CHECK_RAW(NAME, TYPE)
 
#define CHECK(NAME, FIELD)
 
#define DRAW(FIELD)
 

Enumerations

enum  search_type {
  SEARCH_INVALID , SEARCH_GUI_CONTROL , SEARCH_IPC_SERVER , SEARCH_SPACE_OVERSEER ,
  SEARCH_SLAM_TRACKER , SEARCH_READBACK , SEARCH_HAND_TRACKER , SEARCH_APP_TIMING ,
  SEARCH_COMPOSITOR , SEARCH_COMPOSITOR_TIMING
}
 Which window are we searching. More...
 

Functions

static void conv_rgb_f32_to_u8 (struct xrt_colour_rgb_f32 *from, struct xrt_colour_rgb_u8 *to)
 
static void conv_rgb_u8_to_f32 (struct xrt_colour_rgb_u8 *from, struct xrt_colour_rgb_f32 *to)
 
static void handle_draggable_vec3_f32 (const char *name, struct xrt_vec3 *v)
 
static void handle_draggable_quat (const char *name, struct xrt_quat *q)
 
static struct debug_recordensure_debug_record_created (void *ptr, struct draw_state *state)
 
static XRT_MAYBE_UNUSED void draw_sink_to_background (struct u_var_info *var, struct draw_state *state)
 
static XRT_MAYBE_UNUSED void draw_native_images_to_background (struct u_var_info *var, struct draw_state *state)
 
static void * plot_vec3_f32_x (void *ptr, int index, ImPlotPoint *point)
 
static void * plot_vec3_f32_y (void *ptr, int index, ImPlotPoint *point)
 
static void * plot_vec3_f32_z (void *ptr, int index, ImPlotPoint *point)
 
static void * plot_curve_point (void *ptr, int i, ImPlotPoint *point)
 
static float plot_f32_array_value (void *ptr, int i)
 
static void on_color_rgb_f32 (const char *name, void *ptr)
 
static void on_color_rgb_u8 (const char *name, void *ptr)
 
static void on_f32_arr (const char *name, void *ptr)
 
static void on_timing (const char *name, void *ptr)
 
static void on_pose (const char *name, void *ptr)
 
static void on_ff_vec3_var (struct u_var_info *info, struct gui_program *p)
 
static void on_sink_debug_var (const char *name, void *ptr, struct draw_state *state)
 
static void on_native_images_debug_var (const char *name, void *ptr, struct draw_state *state)
 
static void on_button_var (const char *name, void *ptr)
 
static void on_combo_var (const char *name, void *ptr)
 
static void on_histogram_f32_var (const char *name, void *ptr)
 
static void on_curve_var (const char *name, void *ptr)
 
static void on_curves_var (const char *name, void *ptr)
 
static void on_draggable_f32_var (const char *name, void *ptr)
 
static void on_draggable_u16_var (const char *name, void *ptr)
 
static void on_gui_header (const char *name, struct draw_state *state)
 
static void on_gui_header_begin (const char *name, struct draw_state *state)
 
static void on_gui_header_end (void)
 
static void on_root_enter (struct u_var_root_info *info, void *priv)
 
static void on_elem (struct u_var_info *info, void *priv)
 
static void on_root_exit (struct u_var_root_info *info, void *priv)
 
static void advanced_scene_render (struct debug_scene *ds, struct gui_program *p)
 
static void curated_on_root_enter (struct u_var_root_info *info, void *priv)
 
static void curated_on_elem (struct u_var_info *info, void *priv)
 
static void curated_on_root_exit (struct u_var_root_info *info, void *priv)
 
static void curated_render (struct debug_scene *ds, struct gui_program *p)
 
static void on_root_enter_sink (struct u_var_root_info *info, void *priv)
 
static void on_elem_sink_debug_remove (struct u_var_info *info, void *null_ptr)
 
static void on_root_exit_sink (struct u_var_root_info *info, void *priv)
 
static void scene_render (struct gui_scene *scene, struct gui_program *p)
 
static void scene_destroy (struct gui_scene *scene, struct gui_program *p)
 
void gui_scene_debug (struct gui_program *p)
 

Variables

static bool g_show_advanced_gui = false
 

Detailed Description

A debugging scene.

Author
Jakob Bornecrantz jakob.nosp@m.@col.nosp@m.labor.nosp@m.a.co.nosp@m.m

Macro Definition Documentation

◆ CHECK

#define CHECK (   NAME,
  FIELD 
)
Value:
if (strcmp(info->name, NAME) == 0) { \
cs->FIELD = info; \
}

◆ CHECK_RAW

#define CHECK_RAW (   NAME,
  TYPE 
)
Value:
if (strcmp(info->raw_name, NAME) == 0) { \
cs->search = TYPE; \
}

◆ COLOR_FLAGS

#define COLOR_FLAGS   (ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_PickerHueWheel)

Shared flags for color gui elements.

◆ DRAW

#define DRAW (   FIELD)
Value:
if (cs.FIELD != NULL) { \
on_elem(cs.FIELD, &cs.ds); \
}

◆ MAX_HEADER_NESTING

#define MAX_HEADER_NESTING   256

How many nested gui headers can we show, overly large.

◆ PLOT_HELPER

#define PLOT_HELPER (   elm)
Value:
static void *plot_vec3_f32_##elm(void *ptr, int index, ImPlotPoint *point) \
{ \
struct plot_state *state = (struct plot_state *)ptr; \
struct xrt_vec3 value; \
uint64_t timestamp; \
m_ff_vec3_f32_get(state->ff, index, &value, &timestamp); \
*point = (ImPlotPoint){time_ns_to_s(state->now - timestamp), value.elm}; \
return NULL; \
}
static double time_ns_to_s(time_duration_ns ns)
Convert nanoseconds duration to double seconds.
Definition: u_time.h:90
State for plotting m_ff_vec3_f32, assumes it's relative to now.
Definition: gui_scene_debug.c:118
A 3 element vector with single floats.
Definition: xrt_defines.h:271

Enumeration Type Documentation

◆ search_type

Which window are we searching.