diff --git a/app/gcompose/src/ContextModel.cpp b/app/gcompose/src/ContextModel.cpp index 2fd469f..d88d6ec 100644 --- a/app/gcompose/src/ContextModel.cpp +++ b/app/gcompose/src/ContextModel.cpp @@ -140,7 +140,7 @@ QVariant ContextModel::data(const QModelIndex& index, int role) const { QVariant ContextModel::headerData(int section, Qt::Orientation orientation, int role) const { if (orientation == Qt::Horizontal && role == Qt::DisplayRole && section == 0) { - return "Object Type"; + return "Object Context"; } return QVariant(); } diff --git a/app/gcompose/src/ContextPanel.h b/app/gcompose/src/ContextPanel.h index f11857b..2447465 100644 --- a/app/gcompose/src/ContextPanel.h +++ b/app/gcompose/src/ContextPanel.h @@ -8,6 +8,8 @@ class QTreeView; class QVBoxLayout; class QLabel; class ContextModel; +class QSplitter; + namespace uLib { class Object; @@ -18,8 +20,6 @@ namespace uLib { } } -class QSplitter; - class ContextPanel : public QWidget { Q_OBJECT public: @@ -41,6 +41,7 @@ private: QTreeView* m_treeView; ContextModel* m_model; QSplitter* m_splitter; + uLib::Vtk::QViewport* m_vtkView; uLib::Vtk::vtkObjectsContext* m_vtkContext; uLib::ObjectsContext* m_context; diff --git a/src/Core/Archives.h b/src/Core/Archives.h index 1a71072..1d40396 100644 --- a/src/Core/Archives.h +++ b/src/Core/Archives.h @@ -198,20 +198,16 @@ public: return &bpos; } - template Archive &operator<<(T &t) { + template Archive &operator<<(const T &t) { // to get access you must redefine save_override by typing // "using save_override" in archive impl this->This()->save_override(t); return *this->This(); } - + // the & operator - template Archive &operator&(T &t) { -#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING - return *this->This() << const_cast(t); -#else + template Archive &operator&(const T &t) { return *this->This() << t; -#endif } // the == operator @@ -364,7 +360,6 @@ public: boost::serialization::hrp &t) { this->This()->load_start(t.name()); this->detail_common_iarchive::load_override(t.value()); - // t.stov(); this->This()->load_end(t.name()); } @@ -432,8 +427,7 @@ public: #endif ::boost::serialization::hrp &t) { this->This()->save_start(t.name()); - // t.vtos(); - // this->detail_common_oarchive::save_override(t.const_value()); + this->detail_common_oarchive::save_override(t.const_value()); this->This()->save_end(t.name()); } @@ -467,14 +461,10 @@ public: text_iarchive(std::istream &is, unsigned int flags = 0) : text_iarchive_impl(is, flags) {} - using basic_text_iarchive::load_override; + using base::load_override; void load_override(boost::archive::object_id_type &t) {} - // class_name_type can't be handled here as it depends upon the - // char type used by the stream. So require the derived implementation. - // derived in this case is xml_iarchive_impl or base .. - using base::load_override; void load_override(const char *str) { StringReader sr(basic_text_iprimitive::is); @@ -532,7 +522,7 @@ public: hrt_iarchive(std::istream &is, unsigned int flags = 0) : base(is, flags | boost::archive::no_header) {} - using basic_text_iarchive::load_override; + using base::load_override; // hide all archive props // void load_override(boost::archive::object_id_type &t) {} @@ -544,10 +534,6 @@ public: void load_override(boost::archive::class_name_type &t) {} void load_override(boost::archive::tracking_type &t) {} - // class_name_type can't be handled here as it depends upon the - // char type used by the stream. So require the derived implementation. - // derived in this case is xml_iarchive_impl or base .. - using base::load_override; void load_override(const char *str) { StringReader sr(basic_text_iprimitive::is); @@ -583,6 +569,13 @@ public: void save_override(const char *str) { basic_text_oprimitive::save(str); } + template + void save_override(const boost::serialization::hrp &t) { + *this << t.name() << ": "; + *this << t.const_value(); + *this << "\n"; + } + ~hrt_oarchive() {} }; @@ -611,7 +604,7 @@ public: // basic_text_oprimitive::save(str); } - template void save_override(T &t) { + template void save_override(const T &t) { base::save_override(boost::serialization::make_nvp(NULL, t)); } @@ -627,6 +620,10 @@ public: base::save_override(t); } + template void save_override(const boost::serialization::hrp &t) { + base::save_override(boost::serialization::make_nvp(t.name(), t.const_value())); + } + // specific overrides for attributes - not name value pairs so we // want to trap them before the above "fall through" // since we don't want to see these in the output - make them no-ops. diff --git a/src/Core/Debug.h b/src/Core/Debug.h index a495ba3..37e68aa 100644 --- a/src/Core/Debug.h +++ b/src/Core/Debug.h @@ -36,7 +36,7 @@ #include "SmartPointer.h" #include -#include + namespace uLib { diff --git a/src/Core/Object.cpp b/src/Core/Object.cpp index 0c302d3..c6eb47e 100644 --- a/src/Core/Object.cpp +++ b/src/Core/Object.cpp @@ -35,6 +35,9 @@ #include "boost/archive/polymorphic_xml_iarchive.hpp" #include "boost/archive/polymorphic_xml_oarchive.hpp" +#include +#include "Property.h" + namespace uLib { const char *Version::PackageName = PACKAGE_NAME; @@ -60,8 +63,43 @@ public: std::string m_InstanceName; Vector sigv; Vector slov; + std::vector m_Properties; }; +// Implementations of Property methods +void Object::RegisterProperty(PropertyBase* prop) { + if (prop) d->m_Properties.push_back(prop); +} + +const std::vector& Object::GetProperties() const { + return d->m_Properties; +} + +// In Object.h, the template serialize needs to be updated to call property serialization. +// However, since Object::serialize is a template in the header, we might need a helper here. + +template +void Object::serialize(ArchiveT &ar, const unsigned int version) { + ar & boost::serialization::make_nvp("InstanceName", d->m_InstanceName); + for (auto* prop : d->m_Properties) { + prop->serialize(ar, version); + } +} + +void Object::Updated() { ULIB_SIGNAL_EMIT(Object::Updated); } + +template +void Object::save_override(ArchiveT &ar, const unsigned int version) {} + +// Explicitly instantiate for all uLib archives +template void Object::serialize(Archive::xml_oarchive &, const unsigned int); +template void Object::serialize(Archive::xml_iarchive &, const unsigned int); +template void Object::serialize(Archive::text_oarchive &, const unsigned int); +template void Object::serialize(Archive::text_iarchive &, const unsigned int); +template void Object::serialize(Archive::hrt_oarchive &, const unsigned int); +template void Object::serialize(Archive::hrt_iarchive &, const unsigned int); +template void Object::serialize(Archive::log_archive &, const unsigned int); + //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// @@ -146,8 +184,6 @@ GenericMFPtr *Object::findSlotImpl(const char *name) const { return NULL; } -void Object::Updated() { ULIB_SIGNAL_EMIT(Object::Updated); } - const std::string& Object::GetInstanceName() const { return d->m_InstanceName; } diff --git a/src/Core/Object.h b/src/Core/Object.h index 97f199f..93d0bac 100644 --- a/src/Core/Object.h +++ b/src/Core/Object.h @@ -51,6 +51,8 @@ class polymorphic_oarchive; namespace uLib { +class PropertyBase; + class Version { public: static const char *PackageName; @@ -79,6 +81,12 @@ public: const std::string& GetInstanceName() const; void SetInstanceName(const std::string& name); + + //////////////////////////////////////////////////////////////////////////// + // PROPERTIES // + void RegisterProperty(PropertyBase* prop); + const std::vector& GetProperties() const; + //////////////////////////////////////////////////////////////////////////// // PARAMETERS // @@ -89,9 +97,9 @@ public: // SERIALIZATION // template - void serialize(ArchiveT &ar, const unsigned int version) {} + void serialize(ArchiveT &ar, const unsigned int version); template - void save_override(ArchiveT &ar, const unsigned int version) {} + void save_override(ArchiveT &ar, const unsigned int version); void SaveConfig(std::ostream &os, int version = 0); void LoadConfig(std::istream &is, int version = 0); diff --git a/src/Core/Property.h b/src/Core/Property.h new file mode 100644 index 0000000..66616f0 --- /dev/null +++ b/src/Core/Property.h @@ -0,0 +1,128 @@ +#ifndef U_CORE_PROPERTY_H +#define U_CORE_PROPERTY_H + +#include +#include +#include +#include +#include +#include "Core/Archives.h" +#include "Core/Signal.h" +#include "Core/Object.h" + +namespace uLib { + +/** + * @brief Base class for properties to allow runtime listing and identification. + */ +class PropertyBase : public Object { +public: + virtual ~PropertyBase() {} + virtual const std::string& GetName() const = 0; + virtual const char* GetTypeName() const = 0; + virtual std::string GetValueAsString() const = 0; + + // Signal support + signals: + virtual void Updated() override { ULIB_SIGNAL_EMIT(PropertyBase::Updated); } + + // Serialization support for different uLib archives + virtual void serialize(Archive::xml_oarchive & ar, const unsigned int version) = 0; + virtual void serialize(Archive::xml_iarchive & ar, const unsigned int version) = 0; + virtual void serialize(Archive::text_oarchive & ar, const unsigned int version) = 0; + virtual void serialize(Archive::text_iarchive & ar, const unsigned int version) = 0; + virtual void serialize(Archive::hrt_oarchive & ar, const unsigned int version) = 0; + virtual void serialize(Archive::hrt_iarchive & ar, const unsigned int version) = 0; + virtual void serialize(Archive::log_archive & ar, const unsigned int version) = 0; +}; + +/** + * @brief Template class for typed properties. + */ +template +class Property : public PropertyBase { +public: + Property(Object* owner, const std::string& name, const T& defaultValue = T()) + : m_owner(owner), m_name(name), m_value(defaultValue) { + if (m_owner) { + m_owner->RegisterProperty(this); + } + } + virtual ~Property() {} + + const std::string& GetName() const override { return m_name; } + const char* GetTypeName() const override { return typeid(T).name(); } + + std::string GetValueAsString() const override { + try { + return boost::lexical_cast(m_value); + } catch (const boost::bad_lexical_cast&) { + std::stringstream ss; + ss << m_value; + return ss.str(); + } + } + + // Accessors + const T& Get() const { return m_value; } + void Set(const T& value) { + if (m_value != value) { + m_value = value; + ULIB_SIGNAL_EMIT(Property::PropertyChanged); + } + } + + // Operators for seamless usage + operator const T&() const { return m_value; } + Property& operator=(const T& value) { + Set(value); + return *this; + } + + // Signals + signals: + virtual void PropertyChanged() { ULIB_SIGNAL_EMIT(Property::PropertyChanged); } + + // Serialization + template + void serialize_impl(ArchiveT & ar, const unsigned int version) { + ar & boost::serialization::make_nvp(m_name.c_str(), m_value); + } + + void serialize(Archive::xml_oarchive & ar, const unsigned int v) override { serialize_impl(ar, v); } + void serialize(Archive::xml_iarchive & ar, const unsigned int v) override { serialize_impl(ar, v); } + void serialize(Archive::text_oarchive & ar, const unsigned int v) override { serialize_impl(ar, v); } + void serialize(Archive::text_iarchive & ar, const unsigned int v) override { serialize_impl(ar, v); } + void serialize(Archive::hrt_oarchive & ar, const unsigned int v) override { serialize_impl(ar, v); } + void serialize(Archive::hrt_iarchive & ar, const unsigned int v) override { serialize_impl(ar, v); } + void serialize(Archive::log_archive & ar, const unsigned int v) override { serialize_impl(ar, v); } + +private: + std::string m_name; + T m_value; + Object* m_owner; +}; + +/** + * @brief Conveninent typedefs for common property types. + */ +typedef Property StringProperty; +typedef Property IntProperty; +typedef Property UIntProperty; +typedef Property LongProperty; +typedef Property ULongProperty; +typedef Property FloatProperty; +typedef Property DoubleProperty; +typedef Property BoolProperty; + +/** + * @brief Macro to simplify property declaration within a class. + * Usage: ULIB_PROPERTY(float, Width, 1.0f) + */ +#define ULIB_PROPERTY(type, name, defaultValue) \ + Property name = Property(this, #name, defaultValue); + + +} // namespace uLib + +#endif // U_CORE_PROPERTY_H diff --git a/src/Core/Serializable.h b/src/Core/Serializable.h index ea2c376..1a6fb7d 100644 --- a/src/Core/Serializable.h +++ b/src/Core/Serializable.h @@ -72,39 +72,33 @@ namespace serialization { template struct access2 {}; // NON FUNZIONA ... SISTEMARE !!!! // ------------------------------------------ -template class hrp : public wrapper_traits> { +template +class hrp : public boost::serialization::wrapper_traits> { const char *m_name; - T *m_value; - std::string *m_str; + T &m_value; public: - explicit hrp(const char *name_, T &t) - : m_str(new std::string), m_name(name_), m_value(&t) {} + explicit hrp(const char *name_, T &t) : m_name(name_), m_value(t) {} const char *name() const { return this->m_name; } + T &value() { return this->m_value; } + const T &const_value() const { return this->m_value; } + + BOOST_SERIALIZATION_SPLIT_MEMBER() template - void save(Archivex &ar, const unsigned int /* file_version */) const { - //// ar.operator<<(const_value()); - // std::stringstream ss; - // uLib::Archive::hrt_oarchive har(ss); - // har << make_nvp(m_name,*m_value); - // // (*m_str) = ss.str(); - //// ar.operator << (make_nvp(m_name, ss.str()); + void save(Archivex &ar, const unsigned int /* version */) const { + ar << boost::serialization::make_nvp(m_name, m_value); } + template - void load(Archivex &ar, const unsigned int /* file_version */) { - // ar.operator>>(value()); + void load(Archivex &ar, const unsigned int /* version */) { + ar >> boost::serialization::make_nvp(m_name, m_value); } - BOOST_SERIALIZATION_SPLIT_MEMBER() }; template -inline -#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING - const -#endif - hrp make_hrp(const char *name, T &t) { +inline hrp make_hrp(const char *name, T &t) { return hrp(name, t); } diff --git a/src/Core/Types.h b/src/Core/Types.h index 5c04028..d854eec 100644 --- a/src/Core/Types.h +++ b/src/Core/Types.h @@ -139,6 +139,7 @@ typedef id_t Id_t; typedef void *Pointer_t; typedef bool Bool_t; // Boolean (0=false, 1=true) (bool) + //--- bit manipulation --------------------------------------------------------- #ifndef BIT #define BIT(n) (1ULL << (n)) diff --git a/src/Core/testing/CMakeLists.txt b/src/Core/testing/CMakeLists.txt index 7d08dde..ea1cb5e 100644 --- a/src/Core/testing/CMakeLists.txt +++ b/src/Core/testing/CMakeLists.txt @@ -21,6 +21,8 @@ set( TESTS OptionsTest PingPongTest VectorMetaAllocatorTest + PropertyTypesTest + HRPTest ) set(LIBRARIES diff --git a/src/Core/testing/HRPTest.cpp b/src/Core/testing/HRPTest.cpp new file mode 100644 index 0000000..e142f59 --- /dev/null +++ b/src/Core/testing/HRPTest.cpp @@ -0,0 +1,49 @@ +#include +#include +#include "Core/Serializable.h" +#include "Core/Archives.h" + +using namespace uLib; + +struct SimpleObject { + int value; + std::string name; + + template + void serialize(Archive & ar, const unsigned int version) { + ar & HRP(value); + ar & HRP(name); + } +}; + +int main() { + SimpleObject obj; + obj.value = 42; + obj.name = "TestObject"; + + std::cout << "Testing HRP Serialization to Log..." << std::endl; + std::stringstream ss; + { + uLib::Archive::log_archive ar(ss); + ar << boost::serialization::make_nvp("Object", obj); + } + std::cout << ss.str() << std::endl; + + std::cout << "Testing HRP Serialization to HRT..." << std::endl; + ss.str(""); + { + uLib::Archive::hrt_oarchive ar(ss); + ar << obj; + } + std::cout << ss.str() << std::endl; + + std::cout << "Testing HRP Serialization to XML..." << std::endl; + ss.str(""); + { + uLib::Archive::xml_oarchive ar(ss); + ar << boost::serialization::make_nvp("Object", obj); + } + std::cout << ss.str() << std::endl; + + return 0; +} diff --git a/src/Core/testing/PropertySystemTest.cpp b/src/Core/testing/PropertySystemTest.cpp new file mode 100644 index 0000000..092f9f8 --- /dev/null +++ b/src/Core/testing/PropertySystemTest.cpp @@ -0,0 +1,64 @@ +#include +#include +#include "Core/Object.h" +#include "Core/Property.h" +#include + +using namespace uLib; + +class TestObject : public Object { +public: + TestObject() : Object(), + IntProp(this, "IntProp", 10), + StringProp(this, "StringProp", "Initial") + {} + + virtual const char* GetClassName() const override { return "TestObject"; } + + Property IntProp; + Property StringProp; +}; + +int main() { + TestObject obj; + + std::cout << "Testing Properties..." << std::endl; + + // 1. Check registration + const auto& props = obj.GetProperties(); + assert(props.size() == 2); + assert(props[0]->GetName() == "IntProp"); + assert(props[1]->GetName() == "StringProp"); + + // 2. Check value access and signals + bool signalCalled = false; + uLib::Object::connect(&obj.IntProp, &Property::PropertyChanged, [&signalCalled]() { + signalCalled = true; + }); + + assert(obj.IntProp.Get() == 10); + obj.IntProp = 20; + assert(obj.IntProp.Get() == 20); + assert(signalCalled == true); + + // 3. Check serialization + std::stringstream ss; + Object::SaveXml(ss, obj); + std::string xml = ss.str(); + std::cout << "Serialized XML: \n" << xml << std::endl; + + assert(xml.find("20") != std::string::npos); + assert(xml.find("Initial") != std::string::npos); + + // 4. Check deserialization + TestObject obj2; + std::stringstream ss2(xml); + Object::LoadXml(ss2, obj2); + + assert(obj2.IntProp.Get() == 20); + assert(obj2.StringProp.Get() == "Initial"); + + std::cout << "All Property Tests PASSED!" << std::endl; + + return 0; +} diff --git a/src/Core/testing/PropertyTypesTest.cpp b/src/Core/testing/PropertyTypesTest.cpp new file mode 100644 index 0000000..2eeca71 --- /dev/null +++ b/src/Core/testing/PropertyTypesTest.cpp @@ -0,0 +1,68 @@ +#include +#include +#include +#include "Core/Object.h" +#include "Core/Property.h" +#include "Math/Dense.h" + +using namespace uLib; + +class TestObject : public Object { +public: + TestObject() : Object() {} + + virtual const char* GetClassName() const override { return "TestObject"; } + + // Use new typedefs + StringProperty StringProp = StringProperty(this, "StringProp", "Initial"); + IntProperty IntProp = IntProperty(this, "IntProp", 42); + FloatProperty FloatProp = FloatProperty(this, "FloatProp", 3.14f); + BoolProperty BoolProp = BoolProperty(this, "BoolProp", true); + + // Use new macro + ULIB_PROPERTY(Matrix3f, MatrixProp, Matrix3f::Identity()) + + // Use new Dense typedefs + Vector3fProperty Vector3fProp = Vector3fProperty(this, "Vector3fProp", Vector3f(1.1f, 2.2f, 3.3f)); + Matrix4fProperty Matrix4fProp = Matrix4fProperty(this, "Matrix4fProp", Matrix4f::Identity()); +}; + +int main() { + TestObject obj; + + std::cout << "Testing Property Types..." << std::endl; + + // 1. Verify string representation + std::cout << "StringProp: " << obj.StringProp.GetValueAsString() << std::endl; + assert(obj.StringProp.GetValueAsString() == "Initial"); + + std::cout << "IntProp: " << obj.IntProp.GetValueAsString() << std::endl; + assert(obj.IntProp.GetValueAsString() == "42"); + + std::cout << "FloatProp: " << obj.FloatProp.GetValueAsString() << std::endl; + // boost::lexical_cast might have different precision, but for 3.14 it should be okay or we check find + assert(obj.FloatProp.GetValueAsString().find("3.14") != std::string::npos); + + std::cout << "BoolProp: " << obj.BoolProp.GetValueAsString() << std::endl; + // Bool might be "1" or "true" depending on lexical_cast/stringstream + assert(obj.BoolProp.GetValueAsString() == "1" || obj.BoolProp.GetValueAsString() == "true"); + + // 2. Verify Matrix/Vector string representation (uses operator<<) + std::cout << "MatrixProp: \n" << obj.MatrixProp.GetValueAsString() << std::endl; + assert(obj.MatrixProp.GetValueAsString().find("1 0 0") != std::string::npos); + + std::cout << "Vector3fProp: " << obj.Vector3fProp.GetValueAsString() << std::endl; + assert(obj.Vector3fProp.GetValueAsString().find("1.1 2.2 3.3") != std::string::npos); + + std::cout << "Matrix4fProp: \n" << obj.Matrix4fProp.GetValueAsString() << std::endl; + assert(obj.Matrix4fProp.GetValueAsString().find("1 0 0 0") != std::string::npos); + + // 3. Verify updates and signals + obj.IntProp = 100; + assert(obj.IntProp.Get() == 100); + assert(obj.IntProp.GetValueAsString() == "100"); + + std::cout << "All Property Type Tests PASSED!" << std::endl; + + return 0; +} diff --git a/src/Math/ContainerBox.h b/src/Math/ContainerBox.h index 30086c8..2255639 100644 --- a/src/Math/ContainerBox.h +++ b/src/Math/ContainerBox.h @@ -28,6 +28,7 @@ #include "Geometry.h" #include "Core/Object.h" +#include "Core/Property.h" #include "Math/Dense.h" #include "Math/Transform.h" #include @@ -48,6 +49,11 @@ class ContainerBox : public AffineTransform, public Object { typedef AffineTransform BaseClass; public: + //////////////////////////////////////////////////////////////////////////// + // PROPERTIES // + Property Width; + Property Height; + Property Depth; virtual const char * GetClassName() const { return "ContainerBox"; } @@ -56,14 +62,28 @@ public: * Initializes the local transformation with this instance as its parent. */ ContainerBox() - : m_LocalT(this) // BaseClass is Parent of m_LocalTransform - {} + : m_LocalT(this), // BaseClass is Parent of m_LocalTransform + Width(this, "Width", 1.0f), + Height(this, "Height", 1.0f), + Depth(this, "Depth", 1.0f) { + Object::connect(&Width, &Property::PropertyChanged, this, &ContainerBox::SyncSize); + Object::connect(&Height, &Property::PropertyChanged, this, &ContainerBox::SyncSize); + Object::connect(&Depth, &Property::PropertyChanged, this, &ContainerBox::SyncSize); + } /** * @brief Constructor with size. * @param size The size vector. */ - ContainerBox(const Vector3f &size) : m_LocalT(this) { this->SetSize(size); } + ContainerBox(const Vector3f &size) + : m_LocalT(this), + Width(this, "Width", size(0)), + Height(this, "Height", size(1)), + Depth(this, "Depth", size(2)) { + Object::connect(&Width, &Property::PropertyChanged, this, &ContainerBox::SyncSize); + Object::connect(&Height, &Property::PropertyChanged, this, &ContainerBox::SyncSize); + Object::connect(&Depth, &Property::PropertyChanged, this, &ContainerBox::SyncSize); + } /** * @brief Copy constructor. @@ -71,9 +91,14 @@ public: */ ContainerBox(const ContainerBox ©) : m_LocalT(this), // BaseClass is Parent of m_LocalTransform - AffineTransform(copy) { + AffineTransform(copy), + Width(this, "Width", copy.Width), + Height(this, "Height", copy.Height), + Depth(this, "Depth", copy.Depth) { + Object::connect(&Width, &Property::PropertyChanged, this, &ContainerBox::SyncSize); + Object::connect(&Height, &Property::PropertyChanged, this, &ContainerBox::SyncSize); + Object::connect(&Depth, &Property::PropertyChanged, this, &ContainerBox::SyncSize); this->SetOrigin(copy.GetOrigin()); - this->SetSize(copy.GetSize()); } /** @@ -94,6 +119,9 @@ public: * @param v The size vector (width, height, depth). */ void SetSize(const Vector3f &v) { + Width = v(0); + Height = v(1); + Depth = v(2); Vector3f pos = this->GetOrigin(); m_LocalT = AffineTransform(this); // regenerate local transform m_LocalT.Scale(v); @@ -186,6 +214,10 @@ signals: virtual void Updated() override { ULIB_SIGNAL_EMIT(ContainerBox::Updated); } private: + void SyncSize() { + this->SetSize(Vector3f(Width, Height, Depth)); + } + AffineTransform m_LocalT; }; diff --git a/src/Math/Dense.h b/src/Math/Dense.h index 5f08d36..6aec366 100644 --- a/src/Math/Dense.h +++ b/src/Math/Dense.h @@ -51,6 +51,8 @@ #include #include +#include "Core/Types.h" +#include "Core/Property.h" //// BOOST SERIALIZATION /////////////////////////////////////////////////////// @@ -107,7 +109,6 @@ std::ostream &operator<<(std::ostream &os, namespace uLib { typedef id_t Id_t; - typedef int Scalari; typedef unsigned int Scalarui; typedef long Scalarl; @@ -249,15 +250,53 @@ struct _HError3f { HVector3f position_error; HVector3f direction_error; }; -typedef struct _HError3f HError3f; + typedef struct _HError3f HError3f; + + inline std::ostream &operator<<(std::ostream &stream, const HError3f &err) { + stream << "HError3f(" << "ept[" << err.position_error.transpose() + << "] , edr[" << err.direction_error.transpose() << "]) "; + return stream; + } + +typedef Property ScalariProperty; +typedef Property ScalaruiProperty; +typedef Property ScalarlProperty; +typedef Property ScalarulProperty; +typedef Property ScalarfProperty; +typedef Property ScalardProperty; -inline std::ostream &operator<<(std::ostream &stream, const HError3f &err) { - stream << "HError3f(" << "ept[" << err.position_error.transpose() - << "] , edr[" << err.direction_error.transpose() << "]) "; - return stream; -} +typedef Property Vector1iProperty; +typedef Property Vector1fProperty; +typedef Property Vector1dProperty; -} // namespace uLib +typedef Property Vector2iProperty; +typedef Property Vector3iProperty; +typedef Property Vector4iProperty; + +typedef Property Vector2fProperty; +typedef Property Vector3fProperty; +typedef Property Vector4fProperty; + +typedef Property Vector2dProperty; +typedef Property Vector3dProperty; +typedef Property Vector4dProperty; + +typedef Property Matrix2iProperty; +typedef Property Matrix3iProperty; +typedef Property Matrix4iProperty; + +typedef Property Matrix2fProperty; +typedef Property Matrix3fProperty; +typedef Property Matrix4fProperty; + +typedef Property Matrix2dProperty; +typedef Property Matrix3dProperty; +typedef Property Matrix4dProperty; + +typedef Property HVector3fProperty; +typedef Property HPoint3fProperty; + + } // namespace uLib //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// diff --git a/src/Vtk/vtkViewport.cpp b/src/Vtk/vtkViewport.cpp index 05b3853..2af1185 100644 --- a/src/Vtk/vtkViewport.cpp +++ b/src/Vtk/vtkViewport.cpp @@ -55,7 +55,7 @@ void Viewport::SetupPipeline(vtkRenderWindowInteractor* iren) m_Annotation->GetTextProperty()->SetFontFamilyToArial(); m_Annotation->GetTextProperty()->SetOpacity(0.5); m_Annotation->SetMaximumFontSize(10); - m_Annotation->SetText(0, "uLib VTK Viewer - OpenCMT viewer."); + m_Annotation->SetText(0, "uLib VTK viewer."); m_Renderer->AddViewProp(m_Annotation); // right corner annotation