fix display of cylinder
This commit is contained in:
@@ -55,17 +55,12 @@ void vtkCylinder::contentUpdate() {
|
|||||||
vtkProp3D* root = vtkProp3D::SafeDownCast(this->GetProp());
|
vtkProp3D* root = vtkProp3D::SafeDownCast(this->GetProp());
|
||||||
if (!root) return;
|
if (!root) return;
|
||||||
|
|
||||||
// 1. Placement (Position/Rotation/Model-level Scale) goes to the root prop
|
// 1. Placement handled by base Puppet class via Sync / Update logic
|
||||||
vtkMatrix4x4* vmat = root->GetUserMatrix();
|
// Update internal pd->m_Transform from content
|
||||||
if (!vmat) {
|
Puppet::Update();
|
||||||
vtkNew<vtkMatrix4x4> mat;
|
|
||||||
root->SetUserMatrix(mat);
|
|
||||||
vmat = mat;
|
|
||||||
}
|
|
||||||
Matrix4f transform = m_Content->GetMatrix();
|
|
||||||
Matrix4fToVtk(transform, vmat);
|
|
||||||
|
|
||||||
// 2. Shape-local properties (Radius, Height, Axis alignment) go to the internal actor
|
// 2. Shape-local properties (Radius, Height, Axis alignment) go to the internal actor
|
||||||
|
// These are relative to the root assembly
|
||||||
vtkTransform* alignment = vtkTransform::SafeDownCast(m_Actor->GetUserTransform());
|
vtkTransform* alignment = vtkTransform::SafeDownCast(m_Actor->GetUserTransform());
|
||||||
if (alignment) {
|
if (alignment) {
|
||||||
alignment->Identity();
|
alignment->Identity();
|
||||||
@@ -83,23 +78,29 @@ void vtkCylinder::contentUpdate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
root->Modified();
|
root->Modified();
|
||||||
Puppet::Update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void vtkCylinder::Update() {
|
void vtkCylinder::Update() {
|
||||||
|
this->contentUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void vtkCylinder::SyncFromVtk() {
|
||||||
if (!m_Content) return;
|
if (!m_Content) return;
|
||||||
|
|
||||||
vtkProp3D* root = vtkProp3D::SafeDownCast(this->GetProp());
|
|
||||||
if (!root) return;
|
|
||||||
|
|
||||||
vtkMatrix4x4* vmat = root->GetUserMatrix();
|
|
||||||
if (!vmat) return;
|
|
||||||
|
|
||||||
// Pull the placement matrix directly from VTK
|
vtkProp3D* assembly = vtkProp3D::SafeDownCast(this->GetProp());
|
||||||
Matrix4f transform = VtkToMatrix4f(vmat);
|
if (!assembly) return;
|
||||||
m_Content->SetMatrix(transform);
|
|
||||||
|
|
||||||
m_Content->Updated();
|
double pos[3], ori[3], scale[3];
|
||||||
|
assembly->GetPosition(pos);
|
||||||
|
assembly->GetOrientation(ori);
|
||||||
|
assembly->GetScale(scale);
|
||||||
|
|
||||||
|
m_Content->SetPosition(Vector3f(pos[0], pos[1], pos[2]));
|
||||||
|
// Convert VTK degrees to model radians
|
||||||
|
m_Content->SetOrientation(Vector3f(ori[0], ori[1], ori[2]) * CLHEP::degree);
|
||||||
|
m_Content->SetScale(Vector3f(scale[0], scale[1], scale[2]));
|
||||||
|
|
||||||
|
m_Content->Updated(); // Notify change
|
||||||
}
|
}
|
||||||
|
|
||||||
void vtkCylinder::InstallPipe() {
|
void vtkCylinder::InstallPipe() {
|
||||||
|
|||||||
@@ -52,7 +52,10 @@ public:
|
|||||||
virtual void contentUpdate();
|
virtual void contentUpdate();
|
||||||
|
|
||||||
/** Synchronizes the uLib model matrix with the VTK actor (e.g., after UI manipulation) */
|
/** Synchronizes the uLib model matrix with the VTK actor (e.g., after UI manipulation) */
|
||||||
virtual void Update();
|
virtual void Update() override;
|
||||||
|
|
||||||
|
/** Synchronizes the uLib model matrix with the VTK actor specifically for gizmo interactions */
|
||||||
|
virtual void SyncFromVtk() override;
|
||||||
|
|
||||||
virtual uLib::Object* GetContent() const override { return (uLib::Object*)m_Content; }
|
virtual uLib::Object* GetContent() const override { return (uLib::Object*)m_Content; }
|
||||||
|
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ public:
|
|||||||
TRS m_Transform;
|
TRS m_Transform;
|
||||||
|
|
||||||
void ApplyAppearance(vtkProp *p) {
|
void ApplyAppearance(vtkProp *p) {
|
||||||
|
if (!p) return;
|
||||||
p->SetVisibility(m_Visibility);
|
p->SetVisibility(m_Visibility);
|
||||||
p->SetPickable(m_Selectable);
|
p->SetPickable(m_Selectable);
|
||||||
p->SetDragable(m_Dragable);
|
p->SetDragable(m_Dragable);
|
||||||
@@ -143,6 +144,13 @@ public:
|
|||||||
if (m_Opacity != -1.0) {
|
if (m_Opacity != -1.0) {
|
||||||
actor->GetProperty()->SetOpacity(m_Opacity);
|
actor->GetProperty()->SetOpacity(m_Opacity);
|
||||||
}
|
}
|
||||||
|
} else if (vtkAssembly *asm_p = vtkAssembly::SafeDownCast(p)) {
|
||||||
|
// Recursively apply to parts of the assembly
|
||||||
|
vtkProp3DCollection *parts = asm_p->GetParts();
|
||||||
|
parts->InitTraversal();
|
||||||
|
for (int i = 0; i < parts->GetNumberOfItems(); ++i) {
|
||||||
|
this->ApplyAppearance(parts->GetNextProp3D());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user