raisin::tcp_viewer::ViewerApp
class · #include <rayrai/TcpViewerApp.hpp>
The TCP viewer: split panes, server discovery, the control and inspector panels, tools, recording and replay, local simulation and the URDF/MJCF inspector.
The host owns the OpenGL context and an ImGui context with the OpenGL3 renderer backend; both must be current in every call. The viewer restyles and re-fonts that ImGui context and lays its panes out as top-level windows over the whole display, so a host that has its own ImGui UI gives the viewer a context of its own (ViewerWidget does).
Per frame: beginFrame(), the backends' NewFrame() and ImGui::NewFrame(), drawFrame(), ImGui::Render() and the draw-data render.
Constructors & destructor
ViewerApp
explicit ViewerApp(ViewerAppConfig config)ViewerApp(const ViewerApp &) = delete~ViewerApp
~ViewerApp()Calls shutdown() if the host did not.
Public member functions
operator=
ViewerApp &operator=(const ViewerApp &) = deleteinit
bool init()Creates the panes and loads the settings; false (with a message) if the GPU is unsupported. A viewer runs once: init() after shutdown() fails.
beginFrame
void beginFrame(const ImVec2 &framebufferSize, const ImVec2 &uiSize)Before ImGui::NewFrame(): applies the UI scale and rebuilds the font atlas when it changes. This and drawFrame() are fatal before a successful init() and after shutdown().
Parameters
| Parameter | Description |
|---|---|
framebufferSize | Display size in framebuffer pixels. |
uiSize | Display size in ImGui points (differs from the pixels on a HiDPI display). |
drawFrame
void drawFrame()Between ImGui::NewFrame() and ImGui::Render(): runs every pane and the split-pane chrome.
openFile
void openFile(const std::filesystem::path &path)Opens a world XML (simulated locally) or a URDF/MJCF (inspector), as a file drop does.
setKeyboardFocus
void setKeyboardFocus(bool focused)Whether the host gives the viewer the keyboard (default true). The camera keys (W, A, S, D, Space) and the B shortcut read SDL's keyboard state, which is shared by the whole process, so a host that shows the viewer next to other UI passes false while the keyboard belongs elsewhere.
quitRequested
bool quitRequested() constSet when the startup options ask to exit (after a screenshot, a timeout, a failed load).
exitCode
int exitCode() constshutdown
void shutdown()Saves the settings and releases GL and network resources (GL context current).