refactor: extend Object property system and implement recursive property discovery in Vtk::Puppet archive
This commit is contained in:
@@ -560,28 +560,55 @@ bool Puppet::IsSelected() const
|
||||
return pd->m_Selected;
|
||||
}
|
||||
|
||||
void Puppet::ApplyPuppetTransform(vtkProp3D* prop)
|
||||
{
|
||||
if (!prop) return;
|
||||
if (auto* content = this->GetContent()) {
|
||||
if (auto* tr = dynamic_cast<uLib::TRS*>(content)) {
|
||||
vtkNew<vtkMatrix4x4> m;
|
||||
Matrix4fToVtk(tr->GetMatrix(), m);
|
||||
prop->SetUserMatrix(m);
|
||||
prop->Modified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Puppet::SyncFromVtk()
|
||||
{
|
||||
if (auto* content = this->GetContent()) {
|
||||
if (auto* tr = dynamic_cast<uLib::TRS*>(content)) {
|
||||
if (auto* proxy = this->GetProxyProp()) {
|
||||
if (vtkMatrix4x4* mat = proxy->GetUserMatrix()) {
|
||||
tr->FromMatrix(VtkToMatrix4f(mat));
|
||||
content->Updated();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Puppet::Update()
|
||||
{
|
||||
// Derived classes should have updated the transform if they override Update()
|
||||
// or we can apply base transform if it's default:
|
||||
// pd->ApplyTransform(pd->m_Prop);
|
||||
// Apply content transform via virtual GetProp() / ApplyPuppetTransform(),
|
||||
// so all derived classes benefit without duplicating the matrix code.
|
||||
this->ApplyPuppetTransform(vtkProp3D::SafeDownCast(this->GetProp()));
|
||||
|
||||
pd->ApplyAppearance(pd->m_Prop);
|
||||
// Use virtual GetProp() for appearance so overriders (e.g. vtkVoxImage)
|
||||
// that never call SetProp() are handled correctly.
|
||||
pd->ApplyAppearance(this->GetProp());
|
||||
|
||||
if (pd->m_Selected) {
|
||||
pd->UpdateHighlight();
|
||||
}
|
||||
|
||||
if (pd->m_Prop) {
|
||||
if (pd->m_ShowBoundingBox) {
|
||||
double* bounds = pd->m_Prop->GetBounds();
|
||||
|
||||
if (auto* prop = this->GetProp()) {
|
||||
if (pd->m_ShowBoundingBox && pd->m_OutlineSource) {
|
||||
double* bounds = prop->GetBounds();
|
||||
pd->m_OutlineSource->SetBounds(bounds);
|
||||
pd->m_OutlineSource->Update();
|
||||
}
|
||||
|
||||
if (pd->m_ShowScaleMeasures) {
|
||||
double* bounds = pd->m_Prop->GetBounds();
|
||||
pd->m_CubeAxesActor->SetBounds(bounds);
|
||||
if (pd->m_ShowScaleMeasures && pd->m_CubeAxesActor) {
|
||||
pd->m_CubeAxesActor->SetBounds(prop->GetBounds());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -598,6 +625,7 @@ void Puppet::Update()
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Puppet::ConnectInteractor(vtkRenderWindowInteractor *interactor)
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user