ovassvepCApplication.h 2.71 KB
Newer Older
Jussi Lindgren's avatar
Jussi Lindgren committed
1 2 3 4 5
#ifndef __OpenViBEApplication_CApplication_H__
#define __OpenViBEApplication_CApplication_H__

#include "ovassvep_defines.h"

Jozef Legeny's avatar
Jozef Legeny committed
6
#include <openvibe/ov_all.h>
Jussi Lindgren's avatar
Jussi Lindgren committed
7
#include <toolkit/ovtk_all.h>
Jussi Lindgren's avatar
Jussi Lindgren committed
8 9 10 11

#include <Ogre.h>
#include <vector>
#include <CEGUI.h>
12
#if (CEGUI_VERSION_MAJOR > 0) || (CEGUI_VERSION_MINOR >= 8)
13 14
#include <CEGUI/RendererModules/Ogre/Renderer.h>
#else
Jussi Lindgren's avatar
Jussi Lindgren committed
15
#include <RendererModules/Ogre/CEGUIOgreRenderer.h>
16
#endif
Jussi Lindgren's avatar
Jussi Lindgren committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127

#include "ovassvepICommand.h"
#include "ovassvepCBasicPainter.h"

namespace OpenViBESSVEP
{
	class CApplication : public Ogre::FrameListener, public Ogre::WindowEventListener
	{
		public:
			CApplication();
			virtual ~CApplication();

			void addCommand(ICommand* pCommand);
			virtual bool setup(OpenViBE::Kernel::IKernelContext* poKernelContext);
			void go();

			virtual void startExperiment();
			virtual void stopExperiment();
			virtual void startFlickering() {}
			virtual void stopFlickering() {}

			Ogre::RenderWindow* getWindow()
			{
				return m_poWindow;
			}

			Ogre::SceneManager* getSceneManager()
			{
				return m_poSceneManager;
			}

			Ogre::SceneNode* getSceneNode()
			{
				return m_poSceneNode;
			}

			CBasicPainter* getPainter()
			{
				return m_poPainter;
			}

			void exit()
			{
				m_bContinueRendering = false;
			}

			OpenViBE::Kernel::ILogManager& getLogManager()
			{
				return (*m_poLogManager);
			}

			OpenViBE::Kernel::IConfigurationManager* getConfigurationManager()
			{
				return &(m_poKernelContext->getConfigurationManager());
			}

			std::vector<std::pair<OpenViBE::uint32, OpenViBE::uint32> >* getFrequencies()
			{
				return &m_oFrequencies;
			}

			void resizeViewport();


		protected:
			OpenViBE::Kernel::IKernelContext* m_poKernelContext;
			OpenViBE::Kernel::ILogManager* m_poLogManager;

			OpenViBE::float64 m_f64ScreenRefreshRate;
			CBasicPainter* m_poPainter;

			bool m_bContinueRendering;
			OpenViBE::uint32 m_ui32CurrentFrame;

			Ogre::Root* m_poRoot;
			Ogre::SceneManager* m_poSceneManager;
			Ogre::Camera* m_poCamera;
			Ogre::RenderWindow* m_poWindow;
			Ogre::Viewport* m_poViewport;
			Ogre::SceneNode* m_poSceneNode;

			CEGUI::OgreRenderer* m_roGUIRenderer;
			CEGUI::WindowManager* m_poGUIWindowManager;
			CEGUI::Window* m_poSheet;

			std::vector<std::pair<OpenViBE::uint32, OpenViBE::uint32> > m_oFrequencies;

			std::vector<ICommand*> m_oCommands;

			virtual void processFrame(OpenViBE::uint32 ui32CurrentFrame);

			bool frameRenderingQueued(const Ogre::FrameEvent &evt);
			bool frameStarted(const Ogre::FrameEvent &evt);

			bool configure();
			void setupResources();


		private:
			void initCEGUI(const char *logFileName);
			Ogre::uint32 m_ui32WindowWidth;
			Ogre::uint32 m_ui32WindowHeight;


	};



}

#endif // __OpenViBEApplication_CApplication_H__