//|||||||||||||||||||||||||||||||||||||||||||||||

#ifndef VIEW_GESTURE_STATE_HPP
#define VIEW_GESTURE_STATE_HPP

//|||||||||||||||||||||||||||||||||||||||||||||||

#include "AppState.hpp"
#include "GestureDef.h"

using namespace Ogre;

//|||||||||||||||||||||||||||||||||||||||||||||||

class ViewGestureState : public AppState
{
public:	
    ViewGestureState();

	DECLARE_APPSTATE_CLASS(ViewGestureState)
	
	void enter();
	void createScene();
	void exit();
	bool pause();
	void resume();

	bool keyPressed(const OIS::KeyEvent &keyEventRef);
	bool keyReleased(const OIS::KeyEvent &keyEventRef);

	bool mouseMoved(const OIS::MouseEvent &evt);
	bool mousePressed(const OIS::MouseEvent &evt, OIS::MouseButtonID id);
	bool mouseReleased(const OIS::MouseEvent &evt, OIS::MouseButtonID id);

	void buttonHit(OgreBites::Button* button);

	void update(double timeSinceLastFrame);
	void updateDetailsPanel(void);
	void buildGUI(void);

private:
	// variables related to GUI
	bool m_bQuit;
	bool m_bDrawScalar;	
	OgreBites::ParamsPanel *m_pDetailsPanel;
	OgreBites::SdkTrayManager *m_pTrayMgr;

	// variables related to ViewGestureState
	SceneNode* mCamNode;
	SceneNode* m_pController;		
	Timer* m_pLogTimer;
	Database* m_pDatabase;

	int mCurrTrial;
	int mCurrGestureIdx;
	int mCurrTesterIdx;	
	size_t mFrameIdx;
	String mCurrGestureName;
	GestureDef::TesterInfo mCurrTesterInfo;
	std::vector<GestureDef::TesterInfo> mTestersList;
	Ogre::MaterialPtr materialR, materialG, materialB;
	GestureDef::Gesture mGesture, mGestureToPlay;

	// functions related to display
	void createMaterialRGB();
	SceneNode* createController(void);
	
	void drawScalarAtNode(SceneNode* node);
	void destroyScalarAtNode(SceneNode* node);	
	
	// functions related to gestures
	void playGesture(const GestureDef::Gesture& gesture);
	void gotoNextGesture(void);
	void gotoPrevGesture(void);
	void gotoNextTester(void);
	void gotoPrevTester(void);
	void gotoNextTrial(void);
	void gotoPrevTrial(void);

	// functions related to control/OpMode	
	Vector3 getSamplePos(GestureDef::XYZ xyz);
	Quaternion getSampleOri(GestureDef::ORI ori);
};

//|||||||||||||||||||||||||||||||||||||||||||||||

#endif

//|||||||||||||||||||||||||||||||||||||||||||||||