Skip to content

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 ​

cpp
explicit ViewerApp(ViewerAppConfig config)
cpp
ViewerApp(const ViewerApp &) = delete

~ViewerApp ​

cpp
~ViewerApp()

Calls shutdown() if the host did not.

Public member functions ​

operator= ​

cpp
ViewerApp &operator=(const ViewerApp &) = delete

init ​

cpp
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 ​

cpp
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

ParameterDescription
framebufferSizeDisplay size in framebuffer pixels.
uiSizeDisplay size in ImGui points (differs from the pixels on a HiDPI display).

drawFrame ​

cpp
void drawFrame()

Between ImGui::NewFrame() and ImGui::Render(): runs every pane and the split-pane chrome.

openFile ​

cpp
void openFile(const std::filesystem::path &path)

Opens a world XML (simulated locally) or a URDF/MJCF (inspector), as a file drop does.

setKeyboardFocus ​

cpp
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 ​

cpp
bool quitRequested() const

Set when the startup options ask to exit (after a screenshot, a timeout, a failed load).

exitCode ​

cpp
int exitCode() const

shutdown ​

cpp
void shutdown()

Saves the settings and releases GL and network resources (GL context current).

RaiSim — physics for robotics and AI.