refactor: migrate vtk classes to use ObjectWrapper for model management and update registration logic

This commit is contained in:
AndreaRigoni
2026-04-09 10:38:45 +00:00
parent 64a87e97e3
commit db76513e79
27 changed files with 479 additions and 349 deletions

View File

@@ -66,9 +66,10 @@ struct ContainerBoxData {
ContainerBox::ContainerBox(ContainerBox::Content *content)
: d(new ContainerBoxData()), m_Content(content) {
: d(new ContainerBoxData()), ObjectWrapper(content) {
this->InstallPipe();
d->m_UpdateSignal = Object::connect(m_Content, &uLib::Object::Updated, this, &ContainerBox::Update);
d->m_UpdateSignal =
Object::connect(this->m_model.get(), &uLib::Object::Updated, this, &ContainerBox::Update);
}
ContainerBox::~ContainerBox() {
@@ -83,13 +84,13 @@ vtkPolyData *ContainerBox::GetPolyData() const {
void ContainerBox::Update() {
RecursiveMutex::ScopedLock lock(this->m_UpdateMutex);
if (!m_Content) return;
if (!this->m_model) return;
vtkProp3D* prop = vtkProp3D::SafeDownCast(this->GetProp());
if (prop) {
// Apply the full volume matrix (TRS * m_LocalT)
vtkNew<vtkMatrix4x4> m;
Matrix4fToVtk(m_Content->GetMatrix(), m);
Matrix4fToVtk(this->m_model->GetMatrix(), m);
prop->SetUserMatrix(m);
prop->Modified();
}
@@ -104,7 +105,7 @@ void ContainerBox::Update() {
void ContainerBox::SyncFromVtk() {
RecursiveMutex::ScopedLock lock(this->m_UpdateMutex);
if (!m_Content) return;
if (!this->m_model) return;
vtkProp3D* root = this->GetProxyProp();
if (!root) return;
@@ -114,11 +115,11 @@ void ContainerBox::SyncFromVtk() {
Matrix4f vtkWorld = VtkToMatrix4f(rootMat);
// Synchronize TRS property members from the updated local matrix
m_Content->FromMatrix(vtkWorld);
this->m_model->FromMatrix(vtkWorld);
// Since we modified the model, notify observers, but block the loop back to VTK
// ConnectionBlock blocker(d->m_UpdateSignal);
m_Content->Updated();
this->m_model->Updated();
}
@@ -126,9 +127,9 @@ void ContainerBox::SyncFromVtk() {
void ContainerBox::InstallPipe() {
if (!m_Content)
if (!this->m_model)
return;
Content *c = m_Content;
Content *c = this->m_model;
// CUBE
vtkSmartPointer<vtkCubeSource> cube = vtkSmartPointer<vtkCubeSource>::New();