Skip to content

Commit 3210b6e

Browse files
committed
[multibody] Expose Visualizer::toggleGui() for synchronous visualizer
1 parent d2c5c0a commit 3210b6e

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

bindings/python/src/expose-visualizer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ void exposeVisualizer() {
3030
eigenpy::OptionalConverter<ConstVectorRef, std::optional>::registration();
3131
eigenpy::OptionalConverter<Vector3, std::optional>::registration();
3232
eigenpy::OptionalConverter<float, std::optional>::registration();
33+
eigenpy::OptionalConverter<bool, std::optional>::registration();
3334
eigenpy::detail::NoneToPython<std::nullopt_t>::registration();
3435

3536
bp::class_<Visualizer::Config>("VisualizerConfig", bp::no_init)
@@ -50,6 +51,10 @@ void exposeVisualizer() {
5051
.def_readonly("renderer", &Visualizer::renderer)
5152
.def_readwrite("worldSceneBounds", &Visualizer::worldSceneBounds)
5253
.def("resetCamera", &Visualizer::resetCamera, ("self"_a))
54+
.def("toggleGui", &Visualizer::toggleGui,
55+
("self"_a, "value"_a = std::nullopt),
56+
"Toggle the GUI on and off. Passing no value will toggle. Passing a "
57+
"value will override.")
5358
.DEF_PROP_PROXY(device)
5459
.def(
5560
"takeScreenshot",

src/candlewick/multibody/Visualizer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ class Visualizer final : public BaseVisualizer {
132132

133133
void processEvents();
134134

135+
void toggleGui(std::optional<bool> value = std::nullopt) noexcept {
136+
m_showGui = value.value_or(!m_showGui);
137+
}
138+
135139
[[nodiscard]] bool shouldExit() const noexcept { return m_shouldExit; }
136140

137141
void takeScreenshot(std::string_view filename);

0 commit comments

Comments
 (0)