23 namespace visualization {
25 using namespace visualizer;
28 py::class_<O3DVisualizerSelections::SelectedIndex> selected_index(
30 "Information about a point or vertex that was selected");
35 s <<
"{ index: " << idx.
index <<
", order: " << idx.
order
36 <<
", point: (" << idx.
point.x() <<
", " << idx.
point.y()
37 <<
", " << idx.
point.z() <<
") }";
40 .def_readonly(
"index",
42 "The index of this point in the point/vertex "
44 .def_readonly(
"order",
46 "A monotonically increasing value that can be "
47 "used to determine in what order the points "
49 .def_readonly(
"point",
51 "The (x, y, z) value of this point");
53 py::class_<O3DVisualizer, UnownedPointer<O3DVisualizer>,
gui::Window>
54 o3dvis(m,
"O3DVisualizer",
"Visualization object used by draw()");
56 py::native_enum<O3DVisualizer::Shader>(o3dvis,
"Shader",
"enum.Enum",
57 "Scene-level rendering options.")
59 "Pixel colors from standard lighting model")
61 "Normals will be ignored (useful for point clouds)")
63 "Pixel colors correspond to surface normal")
65 "Pixel colors correspond to depth buffer value")
69 py::native_enum<O3DVisualizer::TickResult>(
70 o3dvis,
"TickResult",
"enum.Enum",
71 "Return value from animation tick callback.")
73 "Signals that no change happened and no redraw is required")
75 "Signals that a redraw is required")
79 py::class_<O3DVisualizer::DrawObject> drawobj(
81 "Information about an object that is drawn. Do not modify this, it "
82 "can lead to unexpected results.");
84 "The name of the object")
85 .def_property_readonly(
89 return py::cast(o.geometry);
91 return py::cast(o.tgeometry);
94 "The geometry. Modifying this will not "
95 "result in any visible change. Use "
96 "remove_geometry() and then add_geometry()"
97 "to change the geometry")
99 "The group that the object belongs to")
101 "The object's timestamp")
103 "True if the object is checked in the list. "
104 "If the object's group is unchecked or an "
105 "animation is playing, the object's "
106 "visiblity may not correspond with this "
109 o3dvis.def(py::init<const std::string, int, int>(),
110 "title"_a =
"CloudViewer",
"width"_a = 1024,
"height"_a = 768,
111 "Creates a O3DVisualizer object")
115 "Window rect in OS coords, not device pixels")
118 "Returns the title of the window")
120 "Sets the width and height of window to its preferred size")
123 "The size of the window in device pixels, including "
124 "menubar (except on macOS)")
125 .def_property_readonly(
127 "Returns the frame in device pixels, relative "
128 " to the window, which is available for widgets "
130 .def_property_readonly(
132 "Returns the scaling factor between OS pixels "
133 "and device pixels (read-only)")
135 "True if window is visible (read-only)")
136 .def_property_readonly(
138 "Window's unique ID when WebRTCWindowSystem is use."
139 "Returns 'window_undefined' otherwise.")
141 "Tells the window to redraw")
145 "Closes the window and destroys it, unless an on_close "
146 "callback cancels the close.")
150 w.
ShowDialog(TakeOwnership<gui::Dialog>(dlg));
152 "Displays the dialog",
"dlg"_a)
154 "Closes the current dialog")
156 "Displays a simple dialog with a title and message and okay "
158 "title"_a,
"message"_a)
160 "Sets a callback that will be called when the window is "
161 "closed. The callback is given no arguments and should return "
162 "True to continue closing the window or False to cancel the "
166 "Shows or hides the menu in the window, except on macOS since "
167 "the menubar is not in the window and all applications must "
172 "Adds a button to the custom actions section of the UI and a "
173 "corresponding menu item in the \"Actions\" menu. The "
174 "callback will be given one parameter, the O3DVisualizer "
175 "instance, and does not return any value.",
176 "name"_a,
"callback"_a)
178 py::overload_cast<
const std::string&,
179 std::shared_ptr<ccHObject>,
181 const std::string&,
double,
bool>(
183 "name"_a,
"geometry"_a,
"material"_a =
nullptr,
"group"_a =
"",
184 "time"_a = 0.0,
"is_visible"_a =
true,
185 "Adds a geometry. 'name' must be unique.")
187 py::overload_cast<
const std::string&,
188 std::shared_ptr<t::geometry::Geometry>,
190 const std::string&,
double,
bool>(
192 "name"_a,
"geometry"_a,
"material"_a =
nullptr,
"group"_a =
"",
193 "time"_a = 0.0,
"is_visible"_a =
true,
194 "Adds a Tensor-based geometry. 'name' must be unique.")
198 std::shared_ptr<rendering::TriangleMeshModel>,
201 "name"_a,
"model"_a,
"material"_a =
nullptr,
"group"_a =
"",
202 "time"_a = 0.0,
"is_visible"_a =
true,
203 "Adds a TriangleMeshModel. 'name' must be unique. 'material' "
207 [](py::object dv,
const py::dict& d) {
209 std::string group =
"";
211 bool is_visible =
true;
213 std::string
name = py::cast<std::string>(d[
"name"]);
214 if (d.contains(
"material")) {
215 material = py::cast<rendering::MaterialRecord*>(
218 if (d.contains(
"group")) {
219 group = py::cast<std::string>(d[
"group"]);
221 if (d.contains(
"time")) {
222 time = py::cast<double>(d[
"time"]);
224 if (d.contains(
"is_visible")) {
225 is_visible = py::cast<bool>(d[
"is_visible"]);
227 py::object g = d[
"geometry"];
232 dv.attr(
"add_geometry")(
name, g, material, group, time,
235 "Adds a geometry from a dictionary. The dictionary has the "
236 "following elements:\n"
237 "name: unique name of the object (required)\n"
238 "geometry: the geometry or t.geometry object (required)\n"
239 "material: a visualization.rendering.Material object "
241 "group: a string declaring the group it is a member of "
243 "time: a time value\n",
246 "Removes the geometry with the name.",
"name"_a)
248 "Updates the attributes of the named geometry specified by "
249 "update_flags with tpoint_cloud. Note: Currently this "
250 "function only works with T Geometry Point Clouds.",
251 "name"_a,
"tpoint_cloud"_a,
"update_flags"_a)
253 "Checks or unchecks the named geometry in the list. Note that "
254 "even if show_geometry(name, True) is called, the object may "
255 "not actually be visible if its group is unchecked, or if an "
256 "animation is in progress.",
259 "Returns the DrawObject corresponding to the name. This "
260 "should be treated as read-only. Modify visibility with "
261 "show_geometry(), and other values by removing the object and "
262 "re-adding it with the new values",
265 "Returns the MaterialRecord corresponding to the name. The "
266 "returned material is a copy, therefore modifying it directly "
267 "will not change the visualization.",
269 .def(
"modify_geometry_material",
271 "Updates the named geometry to use the new provided material.",
272 "name"_a,
"material"_a)
274 "Displays text anchored at the 3D coordinate specified",
277 "Clears all 3D text")
279 py::overload_cast<
float,
const Eigen::Vector3f&,
280 const Eigen::Vector3f&,
281 const Eigen::Vector3f&>(
283 "Sets the camera view so that the camera is located at 'eye', "
284 "pointing towards 'center', and oriented so that the up "
286 "field_of_view"_a,
"center"_a,
"eye"_a,
"up"_a)
289 const Eigen::Matrix4d&>(
291 "Sets the camera view",
"intrinsic"_a,
"extrinsic_matrix"_a)
293 py::overload_cast<
const Eigen::Matrix3d&,
294 const Eigen::Matrix4d&,
int,
int>(
296 "Sets the camera view",
"intrinsic_matrix"_a,
297 "extrinsic_matrix"_a,
"intrinsic_width_px"_a,
298 "intrinsic_height_px"_a)
299 .def(
"reset_camera_to_default",
301 "Sets camera to default position")
303 "Returns the selection sets, as [{'obj_name', "
306 "Sets a callback that will be called every frame of the "
307 "animation. The callback will be called as callback(o3dvis, "
311 "Sets a callback that will be called every frame of the "
312 "animation. The callback will be called as callback(o3dvis, "
313 "time_since_last_tick, "
314 "total_elapsed_since_animation_started). Note that this is a "
315 "low-level callback. If you need to change the current "
316 "timestamp being shown you will need to update the "
317 "o3dvis.current_time property in the callback. The callback "
318 "must return either O3DVisualizer.TickResult.IGNORE if no "
319 "redraw is required or O3DVisualizer.TickResult.REDRAW if a "
320 "redraw is required.",
323 "Exports a PNG or JPEG image of what is currently displayed "
324 "to the given path.",
327 "address"_a,
"timeout"_a,
328 "Starts the RPC interface.\n"
329 "address: str with the address to listen on.\n"
330 "timeout: int timeout in milliseconds for sending the reply.")
332 "Stops the RPC interface.")
334 "Sets the background color and, optionally, the background "
335 "image. Passing None for the background image will clear any "
336 "image already there.",
337 "bg_color"_a,
"bg_image"_a)
339 "Sets the IBL and its matching skybox. If ibl_name_ibl.ktx is "
340 "found in the default resource directory then it is used. "
341 "Otherwise, ibl_name is assumed to be a path to the ibl KTX "
345 "Sets the intensity of the current IBL",
"intensity"_a)
347 "Enables/disables raw mode for simplified lighting "
351 "Show/Hide the skybox",
"show"_a)
353 "Expand/Collapse verts(panels) within the settings panel",
358 return dv.GetUIState().show_settings;
361 "Gets/sets if settings panel is visible")
365 return dv.GetUIState().mouse_mode;
368 "Gets/sets the control mode being used for the mouse")
372 return dv.GetUIState().scene_shader;
375 "Gets/sets the shading model for the scene")
379 return dv.GetUIState().show_axes;
385 return dv.GetUIState().show_ground;
388 "Gets/sets if ground plane is visible")
392 return dv.GetUIState().ground_plane;
395 "Sets the plane for ground plane, XZ, XY, or YZ")
399 return dv.GetUIState().point_size;
402 "Gets/sets size of points (in units of pixels)")
406 return dv.GetUIState().line_width;
409 "Gets/sets width of lines (in units of pixels)")
410 .def_property_readonly(
412 "Returns the rendering.CloudViewerScene object "
413 "for low-level manipulation")
419 return dv.GetCurrentTime();
422 "Gets/sets the current time. If setting, only the "
423 "objects belonging to the current time-step will "
425 .def_property(
"animation_time_step",
428 "Gets/sets the time step for animations. Default is "
430 .def_property(
"animation_frame_delay",
433 "Gets/sets the length of time a frame is visible.")
434 .def_property(
"animation_duration",
437 "Gets/sets the duration (in seconds) of the "
438 "animation. This is automatically computed to be the "
439 "difference between the minimum and maximum time "
440 "values, but this is useful if no time values have "
441 "been specified (that is, all objects are at the "
445 "Gets/sets the status of the animation. Changing "
446 "value will start or stop the animating.");
Contains the pinhole camera intrinsic parameters.
std::string GetWebRTCUID() const
void SetSize(const Size &size)
Sets the size of the window in pixels. Includes menubar on Linux.
const char * GetTitle() const
Rect GetContentRect() const
void SetTitle(const char *title)
void SetOSFrame(const Rect &r)
void ShowDialog(std::shared_ptr< Dialog > dlg)
void CloseDialog()
Closes the dialog.
void ShowMessageBox(const char *title, const char *message)
float GetScaling() const
Returns the scaling factor from OS pixels to device pixels.
void SetOnClose(std::function< bool()> callback)
void SetPointSize(int point_size)
void SetAnimationDuration(double sec)
double GetAnimationDuration() const
void StartRPCInterface(const std::string &address, int timeout)
Starts the RPC interface. See io/rpc/ZMQReceiver for the parameters.
void SetMouseMode(gui::SceneWidget::Controls mode)
void SetOnAnimationTick(std::function< TickResult(O3DVisualizer &, double, double)> cb)
void ShowSettings(bool show)
void SetGroundPlane(rendering::Scene::GroundPlane plane)
void ExportCurrentImage(const std::string &path)
void SetBackground(const Eigen::Vector4f &bg_color, std::shared_ptr< geometry::Image > bg_image=nullptr)
DrawObject GetGeometry(const std::string &name) const
Returns Visualizer's internal DrawObject for the named geometry.
void SetOnAnimationFrame(std::function< void(O3DVisualizer &, double)> cb)
double GetAnimationTimeStep() const
rendering::MaterialRecord GetGeometryMaterial(const std::string &name) const
void SetPanelOpen(const std::string &name, bool open)
void ShowGeometry(const std::string &name, bool show)
Show/hide the named geometry.
void SetupCamera(float fov, const Eigen::Vector3f ¢er, const Eigen::Vector3f &eye, const Eigen::Vector3f &up)
bool GetIsAnimating() const
void SetAnimating(bool is_animating)
void SetAnimationFrameDelay(double secs)
rendering::CloudViewerScene * GetScene() const
void RemoveGeometry(const std::string &name)
Removes the named geometry from the Visualizer.
void ShowGround(bool show)
void SetLineWidth(int line_width)
void SetIBL(const std::string &path)
void UpdateGeometry(const std::string &name, std::shared_ptr< t::geometry::Geometry > tgeom, uint32_t update_flags)
std::vector< O3DVisualizerSelections::SelectionSet > GetSelectionSets() const
void SetIBLIntensity(float intensity)
void ShowSkybox(bool show)
void EnableBasicMode(bool enable)
void Add3DLabel(const Eigen::Vector3f &pos, const char *text)
double GetAnimationFrameDelay() const
void AddAction(const std::string &name, std::function< void(O3DVisualizer &)> callback)
void SetShader(Shader shader)
void SetCurrentTime(double t)
void ResetCameraToDefault()
void ModifyGeometryMaterial(const std::string &name, const rendering::MaterialRecord *material)
void SetAnimationTimeStep(double time_step)
void AddGeometry(const std::string &name, std::shared_ptr< ccHObject > geom, const rendering::MaterialRecord *material=nullptr, const std::string &group="", double time=0.0, bool is_visible=true)
void pybind_o3dvisualizer(py::module &m)
Generic file read and write utility for python interface.
size_t order
the index of the point within the object
std::shared_ptr< ccHObject > geometry