refactor: migrate vtk classes to use ObjectWrapper for model management and update registration logic
This commit is contained in:
@@ -38,9 +38,9 @@ namespace uLib {
|
||||
namespace Vtk {
|
||||
|
||||
Cylinder::Cylinder(Cylinder::Content *content)
|
||||
: m_Content(content), m_Actor(nullptr), m_VtkAsm(nullptr) {
|
||||
: ObjectWrapper(content), m_Actor(nullptr), m_VtkAsm(nullptr) {
|
||||
this->InstallPipe();
|
||||
m_UpdateSignal = Object::connect(m_Content, &uLib::Object::Updated, this, &Cylinder::Update);
|
||||
m_UpdateSignal = Object::connect(this->m_model.get(), &uLib::Object::Updated, this, &Cylinder::Update);
|
||||
}
|
||||
|
||||
Cylinder::~Cylinder() {
|
||||
@@ -49,14 +49,14 @@ Cylinder::~Cylinder() {
|
||||
}
|
||||
|
||||
void Cylinder::Update() {
|
||||
if (!m_Content)
|
||||
if (!this->m_model)
|
||||
return;
|
||||
|
||||
vtkProp3D* root = vtkProp3D::SafeDownCast(this->GetProp());
|
||||
if (root) {
|
||||
// 1. Placement handled specifically from content (use TRS GetMatrix, not World)
|
||||
vtkNew<vtkMatrix4x4> m;
|
||||
Matrix4fToVtk(m_Content->GetMatrix(), m);
|
||||
Matrix4fToVtk(this->m_model->GetMatrix(), m);
|
||||
root->SetUserMatrix(m);
|
||||
|
||||
// 2. Shape-local properties (Radius, Height, Axis alignment) go to the internal actor
|
||||
@@ -68,10 +68,10 @@ void Cylinder::Update() {
|
||||
|
||||
// Initial source is centered Y-cylinder (Radial XZ [-1,1], Height Y [-0.5, 0.5])
|
||||
// Apply Radius and Height scaling
|
||||
alignment->Scale(m_Content->GetRadius(), m_Content->GetHeight(), m_Content->GetRadius());
|
||||
alignment->Scale(this->m_model->GetRadius(), this->m_model->GetHeight(), this->m_model->GetRadius());
|
||||
|
||||
// Apply Axis alignment
|
||||
int axis = m_Content->GetAxis();
|
||||
int axis = this->m_model->GetAxis();
|
||||
if (axis == 0) alignment->RotateZ(-90); // Y -> X
|
||||
else if (axis == 1) ; // Y -> Y (identity)
|
||||
else if (axis == 2) alignment->RotateX(90); // Y -> Z
|
||||
@@ -86,7 +86,7 @@ void Cylinder::Update() {
|
||||
}
|
||||
|
||||
void Cylinder::SyncFromVtk() {
|
||||
if (!m_Content) return;
|
||||
if (!this->m_model) return;
|
||||
|
||||
vtkProp3D* root = this->GetProxyProp();
|
||||
if (!root) return;
|
||||
@@ -96,12 +96,12 @@ void Cylinder::SyncFromVtk() {
|
||||
Matrix4f vtkWorld = VtkToMatrix4f(rootMat);
|
||||
|
||||
// Directly sync model from the world matrix
|
||||
m_Content->FromMatrix(vtkWorld);
|
||||
m_Content->Updated();
|
||||
this->m_model->FromMatrix(vtkWorld);
|
||||
this->m_model->Updated();
|
||||
}
|
||||
|
||||
void Cylinder::InstallPipe() {
|
||||
if (!m_Content)
|
||||
if (!this->m_model)
|
||||
return;
|
||||
|
||||
m_VtkAsm = ::vtkAssembly::New();
|
||||
|
||||
Reference in New Issue
Block a user