refactor: Enhance VTK puppet lifecycle management by explicitly handling puppet removal and synchronizing puppets across all viewports, and remove default scene objects from startup.
This commit is contained in:
@@ -86,7 +86,7 @@ void ContextPanel::setContext(uLib::ObjectsContext* context) {
|
||||
delete m_vtkContext;
|
||||
}
|
||||
m_vtkContext = new uLib::Vtk::vtkObjectsContext(context);
|
||||
m_vtkView->AddPuppet(*m_vtkContext);
|
||||
// m_vtkView->AddPuppet(*m_vtkContext); // redundant: child puppets are added individually
|
||||
|
||||
// Render viewport and add child puppets when context is updated
|
||||
if (context) {
|
||||
@@ -98,6 +98,13 @@ void ContextPanel::setContext(uLib::ObjectsContext* context) {
|
||||
}
|
||||
});
|
||||
|
||||
uLib::Object::connect(m_vtkContext, &uLib::Vtk::vtkObjectsContext::PuppetRemoved, [this](uLib::Vtk::Puppet* p) {
|
||||
if (this->m_vtkView && p) {
|
||||
this->m_vtkView->RemovePuppet(*p);
|
||||
this->m_vtkView->Render();
|
||||
}
|
||||
});
|
||||
|
||||
// Add any puppets that were created during m_vtkContext's construction
|
||||
for (auto* obj : context->GetObjects()) {
|
||||
if (auto* p = m_vtkContext->GetPuppet(obj)) {
|
||||
|
||||
Reference in New Issue
Block a user