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

	Program:		Range Imaging Toolkit (RITK)
	Module:			ritkVisualizationWidget3D.h
	Version:		$Revision: 1821 $
	Date:			$Date: 2011-10-02 15:41:17 +0200 (Sun, 02 Oct 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 VISUALIZATIONWIDGET3D_H__
#define VISUALIZATIONWIDGET3D_H__

#include "ritkVTK.h"

#include <QWidget>
#include <QMutex>
#include "ui_ritkVisualizationWidget3D.h"

#include "ritkActorPipeline.h"

#include <itkImageToVTKImageFilter.h>
#include <vtkSmartPointer.h>
#include <vtkCamera.h>
#include <vtkImageActor.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkDelaunay2D.h>
#include <vtkCellArray.h>
#include <vtkInteractorStyleImage.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkstd/vector>


Q_DECLARE_METATYPE(vtkSmartPointer<ritk::ActorPipeline>)

namespace ritk
{

/**	@ingroup	ritkVTK
 *	@class		VisualizationWidget3D
 *	@author		Jakob Wasza
 *	@brief		A visualization widget
 *
 *	@details
 *	A widget used to visualize 3D data.
 *	@todo	Needs a detailed documentation on how actors/props are managed asap. Also document thread safety.
 */
class RITKVTK_EXPORT VisualizationWidget3D : public QWidget, public Ui_VisualizationWidget3D
{
	Q_OBJECT

public:
	/// Constructor
	VisualizationWidget3D(QWidget *parent=0);
	/// Destructor
	~VisualizationWidget3D();
	
	/// Get the vtk render window
	vtkRenderWindow* GetRenderWindow();

	/// Fullscreen mode
	void SetFullScreenMode(bool b);

public slots:
	/// UpdateGUI. Note that this method has to be called from the main thread context
	void UpdateGUI();
	/// Add an actor 
	void AddActor(vtkSmartPointer<vtkActor> Actor);	
	/// Remove an actor 
	void RemoveActor(vtkSmartPointer<vtkActor> Actor);
	/// Add a 3D prop
	void AddProp3D(vtkSmartPointer<vtkProp3D> Prop3D);	
	/// Remove a prop
	void RemoveProp3D(vtkSmartPointer<vtkProp3D> Prop3D);
	/// Add a prop
	void AddProp(vtkSmartPointer<vtkProp> Prop);
	/// Remove a prop
	void RemoveProp(vtkSmartPointer<vtkProp> Prop);
	/// Set stereo status (on/off)
	void SetStereo(bool Status);

protected slots:
	/// Close the fullscreen mode
	void CloseFullScreen();
	/// Open the fullscreen mode
	void OpenFullScreen();


protected:
	/// The renderer
	vtkSmartPointer<vtkRenderer> m_Renderer;
	/// The render window
	vtkSmartPointer<vtkRenderWindow> m_RenderWindow;

	/// VTK camera
	vtkSmartPointer<vtkCamera> m_Camera;
	/// Flag that indicates whether the camera has been initialized
	bool m_CameraInitFlag;

	/// The current 3D props
	std::vector<vtkSmartPointer<vtkProp3D> > m_Prop3Ds;

	/// The stereo status
	bool m_StereoStatus;
};

} // end namespace ritk

#endif // VISUALIZATIONWIDGET3D_H__
