refactor: rename Puppet class to Prop3D across the codebase

This commit is contained in:
AndreaRigoni
2026-04-08 15:47:33 +00:00
parent 77f00a2b8a
commit f7ba4b1a17
63 changed files with 412 additions and 413 deletions

View File

@@ -80,15 +80,15 @@ namespace Vtk {
// PIMPL -------------------------------------------------------------------- //
class PuppetData {
class Prop3DData {
public:
PuppetData(Puppet* owner) :
m_Puppet(owner),
Prop3DData(Prop3D* owner) :
m_Prop3D(owner),
m_Renderers(vtkSmartPointer<vtkRendererCollection>::New()),
m_Prop(nullptr),
m_ShowBoundingBox(false),
m_ShowScaleMeasures(false),
m_Representation(Puppet::Surface),
m_Representation(Prop3D::Surface),
m_Opacity(1.0),
m_Selectable(true),
m_Selected(false),
@@ -98,12 +98,12 @@ public:
m_Color = Vector3d(-1, -1, -1);
}
~PuppetData() {
~Prop3DData() {
// No manual Delete needed for smart pointers
}
Puppet *m_Puppet;
Prop3D *m_Prop3D;
// members //
vtkSmartPointer<vtkRendererCollection> m_Renderers;
vtkSmartPointer<vtkProp3D> m_Prop;
@@ -136,11 +136,11 @@ public:
vtkActor *actor = vtkActor::SafeDownCast(p);
if (actor) {
if (m_Representation != -1 && m_Representation != Puppet::Volume) {
if (m_Representation == Puppet::SurfaceWithEdges) {
if (m_Representation != -1 && m_Representation != Prop3D::Volume) {
if (m_Representation == Prop3D::SurfaceWithEdges) {
actor->GetProperty()->SetRepresentation(VTK_SURFACE);
actor->GetProperty()->SetEdgeVisibility(1);
} else if (m_Representation != Puppet::Outline && m_Representation != Puppet::Slice) {
} else if (m_Representation != Prop3D::Outline && m_Representation != Prop3D::Slice) {
actor->GetProperty()->SetRepresentation(m_Representation);
actor->GetProperty()->SetEdgeVisibility(0);
}
@@ -248,8 +248,8 @@ public:
}
// Update highlight matrix from the model world matrix
if (m_Puppet) {
if (auto* content = m_Puppet->GetContent()) {
if (m_Prop3D) {
if (auto* content = m_Prop3D->GetContent()) {
if (auto* tr = dynamic_cast<uLib::TRS*>(content)) {
vtkNew<vtkMatrix4x4> vwm;
Matrix4fToVtk(tr->GetWorldMatrix(), vwm);
@@ -288,24 +288,24 @@ public:
Puppet::Puppet() : Object(), pd(new PuppetData(this)) {
Prop3D::Prop3D() : Object(), pd(new Prop3DData(this)) {
ULIB_ACTIVATE_DISPLAY_PROPERTIES;
for (auto* p : this->GetDisplayProperties()) {
uLib::Object::connect(p, &uLib::PropertyBase::Updated, this, &Puppet::Update);
uLib::Object::connect(p, &uLib::PropertyBase::Updated, this, &Prop3D::Update);
}
}
Puppet::~Puppet()
Prop3D::~Prop3D()
{
delete pd;
}
vtkProp *Puppet::GetProp()
vtkProp *Prop3D::GetProp()
{
return pd->m_Prop;
}
vtkProp3D *Puppet::GetProxyProp()
vtkProp3D *Prop3D::GetProxyProp()
{
// The handler should manipulate the highlight actor if it exists
if (pd->m_HighlightActor) {
@@ -314,7 +314,7 @@ vtkProp3D *Puppet::GetProxyProp()
return vtkProp3D::SafeDownCast(this->GetProp());
}
void Puppet::SetProp(vtkProp *prop)
void Prop3D::SetProp(vtkProp *prop)
{
if(prop) {
prop->SetPickable(pd->m_Selectable);
@@ -339,23 +339,23 @@ void Puppet::SetProp(vtkProp *prop)
}
}
void Puppet::RemoveProp(vtkProp *prop)
void Prop3D::RemoveProp(vtkProp *prop)
{
// TODO
}
void Puppet::ApplyAppearance(vtkProp* prop)
void Prop3D::ApplyAppearance(vtkProp* prop)
{
pd->ApplyAppearance(prop);
}
void Puppet::ApplyTransform(vtkProp3D* p3d)
void Prop3D::ApplyTransform(vtkProp3D* p3d)
{
pd->ApplyTransform(p3d);
}
vtkPropCollection *Puppet::GetParts()
vtkPropCollection *Prop3D::GetParts()
{
if (auto* asm_p = vtkAssembly::SafeDownCast(pd->m_Prop)) {
return asm_p->GetParts();
@@ -363,7 +363,7 @@ vtkPropCollection *Puppet::GetParts()
return nullptr;
}
vtkPropCollection *Puppet::GetProps()
vtkPropCollection *Prop3D::GetProps()
{
if (auto* asm_p = vtkAssembly::SafeDownCast(pd->m_Prop)) {
return asm_p->GetParts();
@@ -371,7 +371,7 @@ vtkPropCollection *Puppet::GetProps()
return nullptr;
}
void Puppet::ConnectRenderer(vtkRenderer *renderer)
void Prop3D::ConnectRenderer(vtkRenderer *renderer)
{
if(renderer) {
this->GetRenderers()->AddItem(renderer);
@@ -391,7 +391,7 @@ void Puppet::ConnectRenderer(vtkRenderer *renderer)
}
}
void Puppet::DisconnectRenderer(vtkRenderer *renderer)
void Prop3D::DisconnectRenderer(vtkRenderer *renderer)
{
if(renderer) {
if(vtkProp* prop = this->GetProp())
@@ -404,22 +404,22 @@ void Puppet::DisconnectRenderer(vtkRenderer *renderer)
}
}
void Puppet::AddToViewer(Viewport &viewer)
void Prop3D::AddToViewer(Viewport &viewer)
{
viewer.AddPuppet(*this);
viewer.AddProp3D(*this);
}
void Puppet::RemoveFromViewer(Viewport &viewer)
void Prop3D::RemoveFromViewer(Viewport &viewer)
{
viewer.RemovePuppet(*this);
viewer.RemoveProp3D(*this);
}
vtkRendererCollection *Puppet::GetRenderers() const
vtkRendererCollection *Prop3D::GetRenderers() const
{
return pd->m_Renderers;
}
void Puppet::PrintSelf(std::ostream &o) const
void Prop3D::PrintSelf(std::ostream &o) const
{
o << "Props Assembly: \n";
if (pd->m_Prop)
@@ -429,7 +429,7 @@ void Puppet::PrintSelf(std::ostream &o) const
pd->m_Renderers->PrintSelf(o,vtkIndent(1));
}
void Puppet::ShowBoundingBox(bool show)
void Prop3D::ShowBoundingBox(bool show)
{
if (pd->m_ShowBoundingBox == show) return;
pd->m_ShowBoundingBox = show;
@@ -465,7 +465,7 @@ void Puppet::ShowBoundingBox(bool show)
}
}
void Puppet::ShowScaleMeasures(bool show)
void Prop3D::ShowScaleMeasures(bool show)
{
if (pd->m_ShowScaleMeasures == show) return;
pd->m_ShowScaleMeasures = show;
@@ -499,13 +499,13 @@ void Puppet::ShowScaleMeasures(bool show)
}
}
void Puppet::SetRepresentation(Representation mode)
void Prop3D::SetRepresentation(Representation mode)
{
pd->m_Representation = static_cast<int>(mode);
pd->ApplyAppearance(pd->m_Prop);
}
void Puppet::SetRepresentation(const char *mode)
void Prop3D::SetRepresentation(const char *mode)
{
std::string s(mode);
if (s == "points") SetRepresentation(Points);
@@ -517,7 +517,7 @@ void Puppet::SetRepresentation(const char *mode)
else if (s == "slice") SetRepresentation(Slice);
}
void Puppet::SetColor(double r, double g, double b)
void Prop3D::SetColor(double r, double g, double b)
{
pd->m_Color[0] = r;
pd->m_Color[1] = g;
@@ -525,7 +525,7 @@ void Puppet::SetColor(double r, double g, double b)
pd->ApplyAppearance(pd->m_Prop);
}
void Puppet::SetOpacity(double alpha)
void Prop3D::SetOpacity(double alpha)
{
pd->m_Opacity = alpha;
pd->ApplyAppearance(pd->m_Prop);
@@ -537,18 +537,18 @@ void Puppet::SetOpacity(double alpha)
void Puppet::SetSelectable(bool selectable)
void Prop3D::SetSelectable(bool selectable)
{
pd->m_Selectable = selectable;
pd->ApplyAppearance(pd->m_Prop);
}
bool Puppet::IsSelectable() const
bool Prop3D::IsSelectable() const
{
return pd->m_Selectable;
}
void Puppet::SetSelected(bool selected)
void Prop3D::SetSelected(bool selected)
{
if (!pd->m_Selectable) return;
if (pd->m_Selected == selected) return;
@@ -556,12 +556,12 @@ void Puppet::SetSelected(bool selected)
pd->UpdateHighlight();
}
bool Puppet::IsSelected() const
bool Prop3D::IsSelected() const
{
return pd->m_Selected;
}
void Puppet::ApplyPuppetTransform(vtkProp3D* prop)
void Prop3D::ApplyProp3DTransform(vtkProp3D* prop)
{
if (!prop) return;
if (auto* content = this->GetContent()) {
@@ -574,7 +574,7 @@ void Puppet::ApplyPuppetTransform(vtkProp3D* prop)
}
}
void Puppet::SyncFromVtk()
void Prop3D::SyncFromVtk()
{
if (auto* content = this->GetContent()) {
if (auto* tr = dynamic_cast<uLib::TRS*>(content)) {
@@ -588,11 +588,11 @@ void Puppet::SyncFromVtk()
}
}
void Puppet::Update()
void Prop3D::Update()
{
// Apply content transform via virtual GetProp() / ApplyPuppetTransform(),
// Apply content transform via virtual GetProp() / ApplyProp3DTransform(),
// so all derived classes benefit without duplicating the matrix code.
this->ApplyPuppetTransform(vtkProp3D::SafeDownCast(this->GetProp()));
this->ApplyProp3DTransform(vtkProp3D::SafeDownCast(this->GetProp()));
// Use virtual GetProp() for appearance so overriders (e.g. VoxImage)
// that never call SetProp() are handled correctly.
@@ -626,8 +626,7 @@ void Puppet::Update()
}
void Puppet::ConnectInteractor(vtkRenderWindowInteractor *interactor)
void Prop3D::ConnectInteractor(vtkRenderWindowInteractor *interactor)
{
}
@@ -639,7 +638,7 @@ void Puppet::ConnectInteractor(vtkRenderWindowInteractor *interactor)
struct TransformProxy {
PuppetData* pd;
Prop3DData* pd;
template<class Archive>
void serialize(Archive & ar, const unsigned int version) {
ar & boost::serialization::make_nvp("Transform", pd->m_Transform);
@@ -647,7 +646,7 @@ struct TransformProxy {
};
struct AppearanceProxy {
PuppetData* pd;
Prop3DData* pd;
template<class Archive>
void serialize(Archive & ar, const unsigned int version) {
ar & boost::serialization::make_hrp("Color", pd->m_Color, "color");
@@ -662,7 +661,7 @@ struct AppearanceProxy {
}
};
void Puppet::serialize_display(Archive::display_properties_archive & ar, const unsigned int version) {
void Prop3D::serialize_display(Archive::display_properties_archive & ar, const unsigned int version) {
AppearanceProxy appearance{pd};
ar & boost::serialization::make_nvp("Appearance", appearance);