#ifndef U_VTKOBJECTSCONTEXT_H #define U_VTKOBJECTSCONTEXT_H #include #include "Core/ObjectsContext.h" #include "uLibVtkInterface.h" class vtkAssembly; namespace uLib { namespace Vtk { /** * @brief vtkObjectsContext manages VTK representations (Puppets) for a collection of uLib::Objects. */ class vtkObjectsContext : public Puppet { public: uLibTypeMacro(vtkObjectsContext, Puppet) vtkObjectsContext(uLib::ObjectsContext *context); virtual ~vtkObjectsContext(); /** @brief Synchronizes the VTK puppets with the core ObjectsContext. */ void Synchronize(); /** @brief Returns the puppet associated with a specific core object. */ Puppet* GetPuppet(uLib::Object* obj); const std::map& GetPuppets() const { return m_Puppets; } /** @brief Updates all managed puppets. */ virtual void Update() override; /** @brief Synchronizes all managed puppets back to their models. */ virtual void SyncFromVtk() override; public: virtual void PuppetAdded(Puppet* puppet); virtual void PuppetRemoved(Puppet* puppet); 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 puppet for a core object. */ Puppet* CreatePuppet(uLib::Object* obj); private: uLib::ObjectsContext *m_Context; std::map m_Puppets; vtkAssembly *m_Assembly; }; } // namespace Vtk } // namespace uLib #endif // U_VTKOBJECTSCONTEXT_H