Reputation: 1
I would to make a class that holds a history of objects (in my case graphs) each graph can get a list of (label, geometry) tuples from the get_geometries method I would like to always display the most recent graph as well as have the display be interactive (look around with the mouse)
What I have right now is the following
class Graph_Manager:
def __init__(self):
self.graph_history = []
self.last_displayed_labels = []
self.app = o3d.visualization.gui.Application.instance
self.app.initialize()
self.vis = o3d.visualization.O3DVisualizer(title="Scene Graph Visualizer", width=1000, height=1000)
self.app.add_window(self.vis)
self.app.run_in_thread(self.update_display)
def update_display(self):
while True:
print(f"update display looped")
if len(self.graph_history) == 0:
geo = get_geometries(None) # Get geometries for the initial graph
else:
geo = get_geometries(self.graph_history[-1]) # Get geometries for the latest graph
#print(f"{geo=}")
# Clear previous geometry and add new geometries to the visualizer
#print(f"{dir(self.vis)=}")
for old_geometry in self.last_displayed_labels:
#print(f"removing {old_geometry}")
self.vis.remove_geometry(old_geometry)
self.last_displayed_labels = []
for label, geometry in geo:
self.vis.add_geometry(label, geometry)
self.last_displayed_labels.append(label)
self.vis.post_redraw()
#self.app.post_to_main_thread(self.vis, self.vis.post_redraw)
#self.app.run_one_tick()
self.app.post_to_main_thread(self.vis, self.app.run_one_tick)
time.sleep(0.05)
def add_graph(self, graph):
self.graph_history.append(graph)
This currently just shows a black screen, I believe because of the main thread requirements, Any help is appreciated. O3DVisualizer Application
Upvotes: 0
Views: 37