You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ovvizCVisualizationContext.hpp 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #pragma once
  2. #include <map>
  3. #include <memory>
  4. #include <openvibe/plugins/ovIPluginObjectDesc.h>
  5. #include <visualization-toolkit/ovviz_all.h>
  6. #include <gtk/gtk.h>
  7. #include "ovvizIVisualizationManager.h"
  8. #include "ovvizIVisualizationContext.h"
  9. #define OVP_ClassId_Plugin_VisualizationCtx OpenViBE::CIdentifier(0x05A7171D, 0x78E4FE3C)
  10. #define OVP_ClassId_Plugin_VisualizationCtxDesc OpenViBE::CIdentifier(0x35A11438, 0x764F72E8)
  11. namespace OpenViBE {
  12. namespace VisualizationToolkit {
  13. /**
  14. * @brief The CVisualizationContext class is a singleton used for passing visualization related information between the application
  15. * and visualization plugins.
  16. */
  17. class CVisualizationContext final : public IVisualizationContext
  18. {
  19. public:
  20. /**
  21. * The release function is neutralized. The object is only allocated once in the descriptor as a unique_ptr
  22. * and will be released at its destruction.
  23. */
  24. void release() override { }
  25. bool setManager(IVisualizationManager* visualizationManager) override
  26. {
  27. m_VisualizationManager = visualizationManager;
  28. return true;
  29. }
  30. bool setWidget(Toolkit::TBoxAlgorithm<Plugins::IBoxAlgorithm>& box, GtkWidget* widget) override;
  31. bool setToolbar(Toolkit::TBoxAlgorithm<Plugins::IBoxAlgorithm>& box, GtkWidget* toolbarWidget) override;
  32. bool isDerivedFromClass(const CIdentifier& classIdentifier) const override
  33. {
  34. return ((classIdentifier == OVP_ClassId_Plugin_VisualizationCtx) || IVisualizationContext::isDerivedFromClass(classIdentifier));
  35. }
  36. CIdentifier getClassIdentifier() const override { return OVP_ClassId_Plugin_VisualizationCtx; }
  37. CVisualizationContext() = default;
  38. private:
  39. IVisualizationManager* m_VisualizationManager = nullptr;
  40. };
  41. class CVisualizationContextDesc final : public Plugins::IPluginObjectDesc
  42. {
  43. public:
  44. CVisualizationContextDesc() : m_visualizationCtx(new CVisualizationContext()) {}
  45. void release() override { }
  46. CString getName() const override { return CString("Visualization Context"); }
  47. CString getAuthorName() const override { return CString("Jozef Legény"); }
  48. CString getAuthorCompanyName() const override { return CString("Mensia Technologies"); }
  49. CString getShortDescription() const override { return CString(""); }
  50. CString getDetailedDescription() const override { return CString(""); }
  51. CString getCategory() const override { return CString(""); }
  52. CString getVersion() const override { return CString("1.0"); }
  53. CIdentifier getCreatedClass() const override { return OVP_ClassId_Plugin_VisualizationCtx; }
  54. /**
  55. * The create function usage is different from standard plugins. As we need to be able to pass data between
  56. * the application and the plugins, we need a permanent object that can be accessed by both. We achieve this
  57. * by saving the object within the plugin descriptor and returning the pointer to the same object to all
  58. * plugins.
  59. *
  60. * @return The singleton visualizationContext object
  61. */
  62. Plugins::IPluginObject* create() override { return m_visualizationCtx.get(); }
  63. bool isDerivedFromClass(const CIdentifier& classIdentifier) const override
  64. {
  65. return ((classIdentifier == OVP_ClassId_Plugin_VisualizationCtxDesc) || IPluginObjectDesc::isDerivedFromClass(classIdentifier));
  66. }
  67. CIdentifier getClassIdentifier() const override { return OVP_ClassId_Plugin_VisualizationCtxDesc; }
  68. private:
  69. std::unique_ptr<CVisualizationContext> m_visualizationCtx;
  70. };
  71. } // namespace VisualizationToolkit
  72. } // namespace OpenViBE