refactor: rename Vtk classes by removing the vtk prefix to follow project naming conventions
This commit is contained in:
@@ -4,35 +4,43 @@
|
||||
#include "Vtk/Math/vtkAssembly.h"
|
||||
#include "Vtk/Math/vtkVoxImage.h"
|
||||
|
||||
#include "HEP/Detectors/vtkDetectorChamber.h"
|
||||
#include "HEP/Geant/vtkBoxSolid.h"
|
||||
#include "Vtk/HEP/Detectors/vtkDetectorChamber.h"
|
||||
#include "Vtk/HEP/Geant/vtkBoxSolid.h"
|
||||
|
||||
#include <vtkAssembly.h>
|
||||
#include <vtkPropCollection.h>
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
|
||||
#include "Math/ContainerBox.h"
|
||||
#include "Math/Cylinder.h"
|
||||
#include "Math/Assembly.h"
|
||||
#include "Math/VoxImage.h"
|
||||
#include "HEP/Detectors/DetectorChamber.h"
|
||||
#include "HEP/Geant/Solid.h"
|
||||
|
||||
|
||||
namespace uLib {
|
||||
namespace Vtk {
|
||||
|
||||
vtkObjectsContext::vtkObjectsContext(uLib::ObjectsContext *context)
|
||||
ObjectsContext::ObjectsContext(uLib::ObjectsContext *context)
|
||||
: m_Context(context), m_Assembly(::vtkAssembly::New()) {
|
||||
this->SetProp(m_Assembly);
|
||||
if (m_Context) {
|
||||
Object::connect(m_Context, &uLib::ObjectsContext::ObjectAdded, this, &vtkObjectsContext::OnObjectAdded);
|
||||
Object::connect(m_Context, &uLib::ObjectsContext::ObjectRemoved, this, &vtkObjectsContext::OnObjectRemoved);
|
||||
Object::connect(m_Context, &uLib::ObjectsContext::ObjectAdded, this, &ObjectsContext::OnObjectAdded);
|
||||
Object::connect(m_Context, &uLib::ObjectsContext::ObjectRemoved, this, &ObjectsContext::OnObjectRemoved);
|
||||
this->Synchronize();
|
||||
}
|
||||
}
|
||||
|
||||
vtkObjectsContext::~vtkObjectsContext() {
|
||||
ObjectsContext::~ObjectsContext() {
|
||||
for (auto const& [obj, puppet] : m_Puppets) {
|
||||
delete puppet;
|
||||
}
|
||||
m_Assembly->Delete();
|
||||
}
|
||||
|
||||
void vtkObjectsContext::Synchronize() {
|
||||
void ObjectsContext::Synchronize() {
|
||||
if (!m_Context) return;
|
||||
|
||||
// 1. Identify objects to add and remove
|
||||
@@ -70,7 +78,7 @@ void vtkObjectsContext::Synchronize() {
|
||||
}
|
||||
}
|
||||
|
||||
void vtkObjectsContext::OnObjectAdded(uLib::Object* obj) {
|
||||
void ObjectsContext::OnObjectAdded(uLib::Object* obj) {
|
||||
if (!obj) return;
|
||||
if (m_Puppets.find(obj) == m_Puppets.end()) {
|
||||
Puppet* puppet = this->CreatePuppet(obj);
|
||||
@@ -83,7 +91,7 @@ void vtkObjectsContext::OnObjectAdded(uLib::Object* obj) {
|
||||
}
|
||||
}
|
||||
|
||||
void vtkObjectsContext::OnObjectRemoved(uLib::Object* obj) {
|
||||
void ObjectsContext::OnObjectRemoved(uLib::Object* obj) {
|
||||
if (!obj) return;
|
||||
auto it = m_Puppets.find(obj);
|
||||
if (it != m_Puppets.end()) {
|
||||
@@ -97,55 +105,55 @@ void vtkObjectsContext::OnObjectRemoved(uLib::Object* obj) {
|
||||
}
|
||||
}
|
||||
|
||||
Puppet* vtkObjectsContext::GetPuppet(uLib::Object* obj) {
|
||||
Puppet* ObjectsContext::GetPuppet(uLib::Object* obj) {
|
||||
auto it = m_Puppets.find(obj);
|
||||
if (it != m_Puppets.end()) return it->second;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void vtkObjectsContext::Update() {
|
||||
void ObjectsContext::Update() {
|
||||
for (auto const& [obj, puppet] : m_Puppets) {
|
||||
puppet->Update();
|
||||
}
|
||||
}
|
||||
|
||||
void vtkObjectsContext::SyncFromVtk() {
|
||||
void ObjectsContext::SyncFromVtk() {
|
||||
for (auto const& [obj, puppet] : m_Puppets) {
|
||||
puppet->SyncFromVtk();
|
||||
}
|
||||
}
|
||||
|
||||
Puppet* vtkObjectsContext::CreatePuppet(uLib::Object* obj) {
|
||||
Puppet* ObjectsContext::CreatePuppet(uLib::Object* obj) {
|
||||
if (!obj) return nullptr;
|
||||
|
||||
if (auto* vox = dynamic_cast<uLib::Abstract::VoxImage*>(obj)) {
|
||||
return new vtkVoxImage(*vox);
|
||||
return new VoxImage(*vox);
|
||||
} else if (auto* box = dynamic_cast<uLib::ContainerBox*>(obj)) {
|
||||
return new vtkContainerBox(box);
|
||||
return new ContainerBox(box);
|
||||
} else if (auto* chamber = dynamic_cast<uLib::DetectorChamber*>(obj)) {
|
||||
return new vtkDetectorChamber(chamber);
|
||||
return new DetectorChamber(chamber);
|
||||
} else if (auto* cylinder = dynamic_cast<uLib::Cylinder*>(obj)) {
|
||||
return new vtkCylinder(cylinder);
|
||||
return new Cylinder(cylinder);
|
||||
} else if (auto* assembly = dynamic_cast<uLib::Assembly*>(obj)) {
|
||||
return new Assembly(assembly);
|
||||
} else if (auto* box = dynamic_cast<uLib::Geant::BoxSolid*>(obj)) {
|
||||
return new vtkBoxSolid(box);
|
||||
return new BoxSolid(box);
|
||||
}
|
||||
|
||||
// Fallback if we don't know the exact class but it might be a context itself
|
||||
if (auto subCtx = dynamic_cast<uLib::ObjectsContext*>(obj)) {
|
||||
return new vtkObjectsContext(subCtx);
|
||||
return new ObjectsContext(subCtx);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void vtkObjectsContext::PuppetAdded(Puppet* puppet) {
|
||||
ULIB_SIGNAL_EMIT(vtkObjectsContext::PuppetAdded, puppet);
|
||||
void ObjectsContext::PuppetAdded(Puppet* puppet) {
|
||||
ULIB_SIGNAL_EMIT(ObjectsContext::PuppetAdded, puppet);
|
||||
}
|
||||
|
||||
void vtkObjectsContext::PuppetRemoved(Puppet* puppet) {
|
||||
ULIB_SIGNAL_EMIT(vtkObjectsContext::PuppetRemoved, puppet);
|
||||
void ObjectsContext::PuppetRemoved(Puppet* puppet) {
|
||||
ULIB_SIGNAL_EMIT(ObjectsContext::PuppetRemoved, puppet);
|
||||
}
|
||||
|
||||
} // namespace Vtk
|
||||
|
||||
Reference in New Issue
Block a user