/*
 * $Id: handlermodule.h,v 1.10 2008-09-11 20:39:01 kybav1 Exp $
 *
 * Description  : One line description of file.
 * Author       : Vaclav Kyba <mail/Jabber: vaseo1@gmail.com>  <ICQ: 98576293>
 *
 * Purpose      :
 *     Long description of what the file is for.
 */


#ifndef __MANIP_MODULE_H__
#define __MANIP_MODULE_H__

//#include <wx/event.h>

#include "VrutApi.h"
#include "scenemodule.h"
//#include "common.h"


namespace VRUT
{
	///Module processing mouse and key input and manipulating object - abstract
	class VRUT_CORE_API ManipulatorModule : public SceneModule
	{
	protected:
		///ID of node to manipulate (from scene with ID \c SceneModule::sceneID)
		NODE_ID nodeID;
		///\c nodeID parameter identifier
		Parameter::ParameterIdentifier nodeIDParamID;

		///Process event - \c Module overload
		virtual void processEvent(Event *evt)
		{
			SceneModule::processEvent(evt);
			switch (evt->type)
			{
			case Event::EVT_PARAM_SET:
				{
					if (((EventParamSet*)evt)->paramIdentifier==sceneIDParamID)
						RegisterNodeIDGUI();
					else if (((EventParamSet*)evt)->paramIdentifier==nodeIDParamID)
						UPDATE_PARAM_FROM_EVENT_ID(nodeIDParamID, nodeID, evt);
					break;
				}
			default:
				break;
			}
		}
		///Process next event - \c Module overload
		///NOTE: careful when setting \c eventTimeout too high
		virtual void processNextEvent()
		{
			SceneModule::processNextEvent();
		}

	public:
		///Class constructor
		ManipulatorModule(const MODULE_ID & _id, const wxString & _name, unsigned _type, Kernel * _kernel, SceneNode::TypeMask filterNodeType = SceneNode::ALL_SCENE_TYPES_MASK)
				: SceneModule(_id, _name, (_type | MODULE_TYPE_MANIPULATOR), _kernel), nodeID(NODE_ID_NONE)
		{
			REGISTER_LISTENER(Event::EVT_INPUT_KEY);
			REGISTER_LISTENER(Event::EVT_INPUT_MOUSE);
			RegisterNodeIDGUI();
		}
		///Class destructor
		virtual ~ManipulatorModule()
		{
		}

		void RegisterNodeIDGUI()
		{
			// Similar to RenderModule::RegisterCameraGUI
			REGISTER_PARAM_GUI_NODEID(nodeIDParamID, wxT("nodeID"), nodeID, sceneID, SceneNode::CreateClassMask<Camera>(), wxT("Manipulated node ID."));
		}
	};
}

#endif
