Skip to content

Commit

Permalink
Added gui_stats method and stats section to gui
Browse files Browse the repository at this point in the history
  • Loading branch information
ramenguy99 committed Nov 24, 2023
1 parent 93c62bb commit 8412c2d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
13 changes: 13 additions & 0 deletions aitviewer/renderables/meshes.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,19 @@ def gui(self, imgui):
if imgui.button("Show Normals ##show_normals{}".format(self.unique_name)):
self._show_normals()

@hooked
def gui_stats(self, imgui):
for k, v in {
"Vertices": self.vertices.shape[1],
"Faces": self.faces.shape[0],
"Vertex colors": "yes" if self._vertex_colors is not None else "no",
"UVs": "yes" if self.uv_coords is not None else "no",
"Face normals": "yes" if self._face_normals is not None else "no",
"Face colors": "yes" if self._face_colors is not None else "no",
"Texture": "yes" if self.has_texture else "no",
}.items():
imgui.text(f"{k}: {v}")

def gui_context_menu(self, imgui, x: int, y: int):
_, self.flat_shading = imgui.menu_item("Flat shading", "F", selected=self.flat_shading, enabled=True)
_, self.draw_edges = imgui.menu_item("Draw edges", "E", selected=self.draw_edges, enabled=True)
Expand Down
9 changes: 9 additions & 0 deletions aitviewer/scene/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,15 @@ def gui(self, imgui):
"""
pass

def gui_stats(self, imgui):
"""
Render GUI for stats about the node, rendered at the bottom of the scene hierarchy.
Should be implemented with @hooked decorator to print stats from parent classes.
:param imgui: imgui context.
See https://pyimgui.readthedocs.io/en/latest/reference/imgui.core.html for available elements to render
"""
imgui.text(f"Frames: {self.n_frames}")

def gui_modes(self, imgui):
"""Render GUI with toolbar (tools) for this particular node"""

Expand Down
9 changes: 9 additions & 0 deletions aitviewer/scene/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,15 @@ def gui_selected(self, imgui):
imgui.spacing()
imgui.spacing()

imgui.spacing()
imgui.spacing()
imgui.spacing()
imgui.same_line(spacing=8)
imgui.begin_group()
if imgui.collapsing_header("Stats")[0]:
s.gui_stats(imgui)
imgui.end_group()

def gui(self, imgui):
imgui.text(f"FPS: {self.fps:.1f}")
# Background color
Expand Down

0 comments on commit 8412c2d

Please sign in to comment.