/*======================================================================================

	Program:		Range Imaging Toolkit (RITK)
	Module:			ritkVisualizationUnit.h
	Version:		$Revision: 1748 $
	Date:			$Date: 2011-09-23 15:47:56 +0200 (Fr, 23 Sep 2011) $

	Copyright (c) 2010-2011
	Pattern Recognition Lab, 
    University Erlangen-Nuremberg, Germany
    All rights reserved.

	This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
	See RITKCopyright.txt for more information.

	http://www5.informatik.uni-erlangen.de/research/software/ritk

========================================================================================*/

#ifndef VISUALIZATIONUNIT_H__
#define VISUALIZATIONUNIT_H__

#include "ritkVisualization.h"

#include <QMutex>

#include "ritkOpenGLEntity.h"
#include "ritkOpenGLCamera.h"

#include "ritkOpenGLVisualizationWidget.h"

namespace ritk
{


	/**	@ingroup	Visualization
	*	@class		VisualizationUnit
	*	@author		Sven Haase
	*	@brief		A visualization unit for a visualization wdiget and its control widget
	*
	*	@details
	*/
	class VISUALIZATION_EXPORT VisualizationUnit : public QMainWindow
	{
		Q_OBJECT

	public:
		/// Constructor
		VisualizationUnit(QWidget* parent = 0, Qt::WindowFlags flags = 0);
		/// Destructor
		~VisualizationUnit();

		/**	@name	Camera */
		//@{
		typedef OpenGLCamera				CameraType;
		typedef CameraType::Pointer			CameraPointer;
		typedef CameraType::ConstPointer	CameraConstPointer;
		void SetCamera(CameraPointer Camera);
		CameraPointer GetCamera();
		CameraConstPointer GetCamera() const;
		//@}

		/**	Add/remove entities */
		//@{
		bool AddEntity(OpenGLEntity *e);
		bool RemoveEntity(OpenGLEntity *e);
		//@}


	protected:

		/**	@name	Keyboard events */
		//@{
		void keyPressEvent(QKeyEvent *e);
		//@}

		/// Show control widget
		bool m_ShowControls;

		/// Managed entities
		std::list<OpenGLEntity*> m_Entities;

		/// The widget for visualization
		OpenGLVisualizationWidget* m_VisualizationWidget;

		/// Mutex used to synchronize rendering and data update
		QMutex m_Mutex;
	};

} // end namespace ritk

#endif // VISUALIZATIONUNIT_H__