add vtk Properties
This commit is contained in:
@@ -3,6 +3,7 @@ set( TESTS
|
||||
vtkViewerTest
|
||||
vtkContainerBoxTest
|
||||
vtkHandlerWidget
|
||||
PuppetPropertyTest
|
||||
# vtkVoxImageTest
|
||||
# vtkTriangleMeshTest
|
||||
)
|
||||
|
||||
68
src/Vtk/testing/PuppetPropertyTest.cpp
Normal file
68
src/Vtk/testing/PuppetPropertyTest.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
|
||||
All rights reserved
|
||||
|
||||
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
#include "Vtk/uLibVtkInterface.h"
|
||||
#include "Core/Property.h"
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
#include "testing-prototype.h"
|
||||
|
||||
using namespace uLib;
|
||||
using namespace Vtk;
|
||||
|
||||
int main() {
|
||||
BEGIN_TESTING(Puppet Property Registration Test);
|
||||
|
||||
std::cout << "Creating Puppet object..." << std::endl;
|
||||
Puppet p;
|
||||
|
||||
// At this point, the Puppet constructor has called ULIB_ACTIVATE_PROPERTIES.
|
||||
// This should have discovered the members used in Puppet::serialize()
|
||||
// and registered them as uLib properties.
|
||||
|
||||
const auto& props = p.GetProperties();
|
||||
std::cout << "Total registered properties: " << props.size() << std::endl;
|
||||
|
||||
// Verify specific properties exist
|
||||
Property<double>* opacityProp = nullptr;
|
||||
Property<double>* colorRProp = nullptr;
|
||||
|
||||
for (auto* prop : props) {
|
||||
std::cout << " - [" << prop->GetTypeName() << "] " << prop->GetName()
|
||||
<< " = " << prop->GetValueAsString() << std::endl;
|
||||
|
||||
if (prop->GetName() == "Opacity") {
|
||||
opacityProp = dynamic_cast<Property<double>*>(prop);
|
||||
}
|
||||
if (prop->GetName() == "ColorR") {
|
||||
colorRProp = dynamic_cast<Property<double>*>(prop);
|
||||
}
|
||||
}
|
||||
|
||||
assert(opacityProp != nullptr && "Opacity property not registered!");
|
||||
assert(colorRProp != nullptr && "ColorR property not registered!");
|
||||
|
||||
// Test modification via uLib Property interface
|
||||
std::cout << "Modifying Opacity via property proxy (0.25)..." << std::endl;
|
||||
*opacityProp = 0.25;
|
||||
|
||||
// Verify the proxy correctly updated the underlying data
|
||||
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 << "All Puppet Property Registration Tests PASSED!" << std::endl;
|
||||
|
||||
END_TESTING;
|
||||
}
|
||||
Reference in New Issue
Block a user