#ifndef U_VTKOBJECTSCONTEXT_H #define U_VTKOBJECTSCONTEXT_H #include #include "Core/ObjectsContext.h" #include "uLibVtkInterface.h" class vtkAssembly; namespace uLib { namespace Vtk { /** * @brief ObjectsContext manages VTK representations (Prop3Ds) for a collection of uLib::Objects. */ class ObjectsContext : public Prop3D { public: uLibTypeMacro(ObjectsContext, Prop3D) ObjectsContext(uLib::ObjectsContext *context); virtual ~ObjectsContext(); /** @brief Synchronizes the VTK prop3ds with the core ObjectsContext. */ void Synchronize(); /** @brief Returns the Prop3D associated with a specific core object. */ Prop3D* GetProp3D(uLib::Object* obj); const std::map& GetProp3Ds() const { return m_Prop3Ds; } /** @brief Updates all managed prop3ds. */ virtual void Update() override; /** @brief Synchronizes all managed prop3ds back to their models. */ virtual void SyncFromVtk() override; virtual Object* GetContent() const override { return (Object*)m_Context; } public: virtual void Prop3DAdded(Prop3D* prop3d); virtual void Prop3DRemoved(Prop3D* prop3d); public: /** @brief Slot called when an object is added to the core context. */ void OnObjectAdded(uLib::Object* obj); /** @brief Slot called when an object is removed from the core context. */ void OnObjectRemoved(uLib::Object* obj); protected: /** @brief Factory method to create a Prop3D for a core object. */ Prop3D* CreateProp3D(uLib::Object* obj); private: uLib::ObjectsContext *m_Context; std::map m_Prop3Ds; vtkAssembly *m_Assembly; }; } // namespace Vtk } // namespace uLib #endif // U_VTKOBJECTSCONTEXT_H