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

	Program:		Range Imaging Toolkit (RITK)
	Module:			ritkOpenGLRGBAVolumeCudaRayCastEntity.h
	Version:		$Revision: 2908 $
	Date:			$Date: 2012-04-03 22:28:42 +0200 (Di, 03 Apr 2012) $

	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 RITKOPENGLRGBAVOLUMECUDARAYCASTENTITY_H__
#define RITKOPENGLRGBAVOLUMECUDARAYCASTENTITY_H__

#if defined(WIN32)
	#include <windows.h>
	// Due to explicit template instantiation
	#pragma warning(disable : 4661)
#endif

#include <GL/glu.h>

#include "ritkCuda.h"
#include "ritkVisualization.h"
#include "ritkOpenGLVolumeRayCastEntity.h"
#include "ritkOpenGLFloatVolumeRayCastControlUnit.h"
#include "ritkCudaRayCaster.h"

#include <itkRGBAPixel.h>



namespace ritk
{

/**	@ingroup	Cuda
 *	@class		OpenGLRGBAVolumeCudaRayCastEntity
 *	@author		Jakob Wasza
 *	@brief		RGBA volume ray casting
 *
 *	@details
 */
class CUDA_EXPORT OpenGLRGBAVolumeCudaRayCastEntity : public OpenGLVolumeRayCastEntity<itk::Image<itk::RGBAPixel<float>,3>, itk::Image<itk::RGBAPixel<float>,2> >
{
	Q_OBJECT

public:
	/**	@name	Standard ITK typedefs */
	//@{
	typedef OpenGLRGBAVolumeCudaRayCastEntity																		Self;
	typedef OpenGLVolumeRayCastEntity<itk::Image<itk::RGBAPixel<float>,3>, itk::Image<itk::RGBAPixel<float>,2> >	Superclass;
	typedef itk::SmartPointer<Self>																					Pointer;
	typedef itk::SmartPointer<const Self>																			ConstPointer;
	//@}

	/**	@name	Volume and image typedefs */
	//@{
	typedef Superclass::VolumeType					RGBVolumeType;
	typedef RGBVolumeType::Pointer					RGBVolumePointer;
	typedef RGBVolumeType::ConstPointer				VolumeConstPointer;
	typedef Superclass::OutputImageType				RGBProjectionImageType;
	typedef RGBProjectionImageType::Pointer			RGBProjectionImagePointer;
	typedef RGBProjectionImageType::ConstPointer	RGBProjectionImageConstPointer;
	//@}

	/**	@name	The ray caster */
	//@{
	typedef Superclass::RayCasterType			RayCasterType;
	typedef Superclass::RayCasterPointer		RayCasterPointer;
	//@}

	/// RTTI
	itkTypeMacro(OpenGLRGBAVolumeCudaRayCastEntity, OpenGLVolumeRayCastEntity);

	/// Object creation
	itkNewMacro(Self);

	/// Rendering
	virtual void PostProcessAndRender();

	/// The controlunit of this entity.
	virtual QDockWidget* GetControlUnit() const;

protected:
	/// Constructor
	OpenGLRGBAVolumeCudaRayCastEntity();
	/// Destructor
	virtual ~OpenGLRGBAVolumeCudaRayCastEntity();

	/**	@name The Cuda ray caster */
	//@{
	typedef CudaRayCaster<RGBVolumeType, RGBProjectionImageType>	CudaRayCasterType;
	//@}

	/// Initialize all OpenGL related members
	virtual void InitGL();
	/// Release all OpenGL related members
	virtual void CloseGL();


protected slots:
	/// Set whether to render the bounding box
	void RenderBoundingBox(bool);

protected:
	/// Flag to indicate initialization
	bool m_InitFlag;

	/// The control unit
	OpenGLFloatVolumeRayCastControlUnit *m_ControlUnit;

	/// The texture
	GLuint m_Texture;

private:
	/// purposely not implemented
	OpenGLRGBAVolumeCudaRayCastEntity(Self&); 
	/// purposely not implemented
	void operator=(const Self&); 
};

} // ritk

#endif // RITKOPENGLRGBAVOLUMECUDARAYCASTENTITY_H__
