refactor: improve Object property management with duplicate prevention, memory cleanup, and updated VTK interface tests
This commit is contained in:
@@ -36,11 +36,11 @@ int main() {
|
||||
BEGIN_TESTING(vtk ContainerBox Test);
|
||||
|
||||
{
|
||||
ContainerBox box;
|
||||
box.Scale(Vector3f(1_m, 2_m, 1_m));
|
||||
box.SetPosition(Vector3f(0, 0, 0));
|
||||
ContainerBox* box = new ContainerBox();
|
||||
box->Scale(Vector3f(1_m, 2_m, 1_m));
|
||||
box->SetPosition(Vector3f(0, 0, 0));
|
||||
|
||||
Vtk::ContainerBox v_box(&box);
|
||||
Vtk::ContainerBox v_box(box);
|
||||
v_box.Update();
|
||||
|
||||
v_box.SetRepresentation(Vtk::Prop3D::Surface);
|
||||
|
||||
@@ -15,11 +15,11 @@ using namespace uLib;
|
||||
|
||||
int main() {
|
||||
std::cout << "Creating ContainerBox..." << std::endl;
|
||||
ContainerBox box(Vector3f(1.0, 1.0, 1.0)); // 1x1x1 unit box
|
||||
box.SetInstanceName("MyTestBox");
|
||||
ContainerBox* box = new ContainerBox(Vector3f(1.0, 1.0, 1.0)); // 1x1x1 unit box
|
||||
box->SetInstanceName("MyTestBox");
|
||||
|
||||
std::cout << "Creating VTK representation..." << std::endl;
|
||||
Vtk::ContainerBox v_box(&box);
|
||||
Vtk::ContainerBox v_box(box);
|
||||
v_box.SetRepresentation(Vtk::Prop3D::Wireframe);
|
||||
v_box.SetColor(1.0, 0.0, 0.0); // Red
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "Vtk/uLibVtkInterface.h"
|
||||
#include "Core/Property.h"
|
||||
#include "Math/Dense.h"
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
#include "testing-prototype.h"
|
||||
@@ -33,7 +34,7 @@ int main() {
|
||||
|
||||
// Verify specific properties exist
|
||||
Property<double>* opacityProp = nullptr;
|
||||
Property<double>* colorRProp = nullptr;
|
||||
Property<Vector3d>* colorProp = nullptr;
|
||||
|
||||
for (auto* prop : props) {
|
||||
std::cout << " - [" << prop->GetTypeName() << "] " << prop->GetName()
|
||||
@@ -42,13 +43,13 @@ int main() {
|
||||
if (prop->GetName() == "Opacity") {
|
||||
opacityProp = dynamic_cast<Property<double>*>(prop);
|
||||
}
|
||||
if (prop->GetName() == "ColorR") {
|
||||
colorRProp = dynamic_cast<Property<double>*>(prop);
|
||||
if (prop->GetName() == "Color") {
|
||||
colorProp = dynamic_cast<Property<Vector3d>*>(prop);
|
||||
}
|
||||
}
|
||||
|
||||
assert(opacityProp != nullptr && "Opacity property not registered!");
|
||||
assert(colorRProp != nullptr && "ColorR property not registered!");
|
||||
assert(colorProp != nullptr && "Color property not registered!");
|
||||
|
||||
// Test modification via uLib Property interface
|
||||
std::cout << "Modifying Opacity via property proxy (0.25)..." << std::endl;
|
||||
@@ -58,9 +59,9 @@ int main() {
|
||||
assert(opacityProp->Get() == 0.25);
|
||||
assert(opacityProp->GetValueAsString().find("0.25") != std::string::npos);
|
||||
|
||||
std::cout << "Modifying ColorR via property proxy (0.9)..." << std::endl;
|
||||
*colorRProp = 0.9;
|
||||
assert(colorRProp->Get() == 0.9);
|
||||
std::cout << "Modifying Color via property proxy (0.9, 0.1, 0.1)..." << std::endl;
|
||||
*colorProp = Vector3d(0.9, 0.1, 0.1);
|
||||
assert(colorProp->Get().x() == 0.9);
|
||||
|
||||
std::cout << "All Prop3D Property Registration Tests PASSED!" << std::endl;
|
||||
|
||||
|
||||
@@ -290,9 +290,6 @@ public:
|
||||
|
||||
Prop3D::Prop3D() : Object(), pd(new Prop3DData(this)) {
|
||||
ULIB_ACTIVATE_DISPLAY_PROPERTIES;
|
||||
for (auto* p : this->GetDisplayProperties()) {
|
||||
uLib::Object::connect(p, &uLib::Object::Updated, this, &Prop3D::Update);
|
||||
}
|
||||
}
|
||||
|
||||
Prop3D::~Prop3D()
|
||||
|
||||
Reference in New Issue
Block a user