vtkProperties
This commit is contained in:
@@ -28,7 +28,9 @@
|
||||
|
||||
#include <iomanip>
|
||||
#include <ostream>
|
||||
#include <vector>
|
||||
#include "Core/Object.h"
|
||||
#include "Core/Property.h"
|
||||
|
||||
// vtk classes forward declaration //
|
||||
class vtkProp;
|
||||
@@ -38,6 +40,10 @@ class vtkRenderer;
|
||||
class vtkRendererCollection;
|
||||
class vtkRenderWindowInteractor;
|
||||
|
||||
namespace uLib {
|
||||
namespace Archive { class display_properties_archive; }
|
||||
namespace Vtk { class Puppet; class Viewer; }
|
||||
}
|
||||
|
||||
namespace uLib {
|
||||
namespace Vtk {
|
||||
@@ -46,37 +52,21 @@ class Puppet : public uLib::Object {
|
||||
uLibTypeMacro(Puppet, uLib::Object)
|
||||
public:
|
||||
Puppet();
|
||||
~Puppet();
|
||||
virtual ~Puppet();
|
||||
|
||||
virtual vtkProp *GetProp();
|
||||
|
||||
virtual vtkPropCollection *GetParts();
|
||||
|
||||
virtual vtkPropCollection *GetProps();
|
||||
|
||||
void ConnectRenderer(vtkRenderer *renderer);
|
||||
|
||||
void DisconnectRenderer(vtkRenderer *renderer);
|
||||
|
||||
void ConnectViewer(class Viewer *viewer);
|
||||
void ConnectViewer(Viewer *viewer);
|
||||
|
||||
void DisonnectViewer(class Viewer *viewer);
|
||||
|
||||
vtkRendererCollection *GetRenderers() const;
|
||||
|
||||
enum Representation {
|
||||
Points,
|
||||
Wireframe,
|
||||
Surface
|
||||
};
|
||||
|
||||
virtual void PrintSelf(std::ostream &o) const;
|
||||
|
||||
void ShowBoundingBox(bool show = true);
|
||||
|
||||
void ShowScaleMeasures(bool show = true);
|
||||
|
||||
void SetRepresentation(Representation mode);
|
||||
|
||||
void SetRepresentation(const char *mode);
|
||||
void DisonnectViewer(Viewer *viewer);
|
||||
|
||||
void SetColor(double r, double g, double b);
|
||||
|
||||
@@ -90,21 +80,39 @@ public:
|
||||
|
||||
virtual void Update();
|
||||
|
||||
enum Representation { Points, Wireframe, Surface };
|
||||
void SetRepresentation(Representation mode);
|
||||
void SetRepresentation(const char *mode);
|
||||
|
||||
virtual void PrintSelf(std::ostream &o) const;
|
||||
|
||||
void ShowBoundingBox(bool show);
|
||||
void ShowScaleMeasures(bool show);
|
||||
|
||||
vtkRendererCollection *GetRenderers() const;
|
||||
|
||||
virtual void serialize(Archive::xml_oarchive & ar, const unsigned int version) override;
|
||||
virtual void serialize(Archive::xml_iarchive & ar, const unsigned int version) override;
|
||||
virtual void serialize(Archive::text_oarchive & ar, const unsigned int version) override;
|
||||
virtual void serialize(Archive::text_iarchive & ar, const unsigned int version) override;
|
||||
virtual void serialize(Archive::hrt_oarchive & ar, const unsigned int version) override;
|
||||
virtual void serialize(Archive::hrt_iarchive & ar, const unsigned int version) override;
|
||||
virtual void serialize(Archive::log_archive & ar, const unsigned int version) override;
|
||||
|
||||
const std::vector<uLib::PropertyBase*>& GetDisplayProperties() const { return m_DisplayProperties; }
|
||||
void RegisterDisplayProperty(uLib::PropertyBase* prop) { m_DisplayProperties.push_back(prop); }
|
||||
|
||||
virtual void serialize_display(uLib::Archive::display_properties_archive & ar, const unsigned int version = 0);
|
||||
|
||||
virtual void ConnectInteractor(class vtkRenderWindowInteractor *interactor);
|
||||
|
||||
// Serialization and Reflection
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int version);
|
||||
void save_override(Archive::xml_oarchive & ar, const unsigned int version);
|
||||
void save_override(Archive::hrt_oarchive & ar, const unsigned int version);
|
||||
void save_override(Archive::log_archive & ar, const unsigned int version);
|
||||
void save_override(Archive::text_oarchive & ar, const unsigned int version);
|
||||
|
||||
protected:
|
||||
void SetProp(vtkProp *prop);
|
||||
|
||||
void RemoveProp(vtkProp *prop);
|
||||
|
||||
std::vector<uLib::PropertyBase*> m_DisplayProperties;
|
||||
|
||||
private:
|
||||
Puppet(const Puppet&) = delete;
|
||||
Puppet& operator=(const Puppet&) = delete;
|
||||
@@ -113,11 +121,60 @@ private:
|
||||
class PuppetData *d;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Vtk
|
||||
} // namespace uLib
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
namespace uLib {
|
||||
namespace Archive {
|
||||
|
||||
/**
|
||||
* @brief Specialized archive for registering display-only properties in Puppets.
|
||||
*/
|
||||
class display_properties_archive : public boost::archive::detail::common_oarchive<display_properties_archive> {
|
||||
public:
|
||||
display_properties_archive(Vtk::Puppet* puppet) :
|
||||
boost::archive::detail::common_oarchive<display_properties_archive>(boost::archive::no_header),
|
||||
m_Puppet(puppet) {}
|
||||
|
||||
template<class T>
|
||||
void save_override(const boost::serialization::hrp<T> &t) {
|
||||
if (m_Puppet) {
|
||||
m_Puppet->RegisterDisplayProperty(
|
||||
new uLib::Property<T>(m_Puppet, t.name(), &const_cast<boost::serialization::hrp<T>&>(t).value())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
template<class T> void save_override(const boost::serialization::nvp<T> &t) {
|
||||
boost::archive::detail::common_oarchive<display_properties_archive>::save_override(t.const_value());
|
||||
}
|
||||
|
||||
template<class T> void save_override(const T &t) {}
|
||||
|
||||
void save_override(const boost::archive::object_id_type & t) {}
|
||||
void save_override(const boost::archive::object_reference_type & t) {}
|
||||
void save_override(const boost::archive::version_type & t) {}
|
||||
void save_override(const boost::archive::class_id_type & t) {}
|
||||
void save_override(const boost::archive::class_id_optional_type & t) {}
|
||||
void save_override(const boost::archive::class_id_reference_type & t) {}
|
||||
void save_override(const boost::archive::class_name_type & t) {}
|
||||
void save_override(const boost::archive::tracking_type & t) {}
|
||||
|
||||
private:
|
||||
Vtk::Puppet* m_Puppet;
|
||||
};
|
||||
|
||||
} // namespace Archive
|
||||
|
||||
// This macro MUST be defined after both Puppet and display_properties_archive are fully defined.
|
||||
#define ULIB_ACTIVATE_DISPLAY_PROPERTIES \
|
||||
{ \
|
||||
uLib::Archive::display_properties_archive dar(this); \
|
||||
this->serialize_display(dar, 0); \
|
||||
}
|
||||
|
||||
} // namespace uLib
|
||||
|
||||
#endif // ULIBVTKINTERFACE_H
|
||||
|
||||
Reference in New Issue
Block a user