#include "__PLUGIN_NAME__Plugin.h"
#include "ritkDebugManager.h"
#include "ritkManager.h"


__PLUGIN_NAME__Plugin::__PLUGIN_NAME__Plugin()
{
	// Create the widget
	m_Widget = new __PLUGIN_NAME__Widget();
	connect(this, SIGNAL(UpdateGUI()), m_Widget, SLOT(UpdateGUI()));
}

__PLUGIN_NAME__Plugin::~__PLUGIN_NAME__Plugin()
{
	delete m_Widget;
}


//----------------------------------------------------------------------------
QString
__PLUGIN_NAME__Plugin::GetName()
{
	return tr("__PLUGIN_NAME__Plugin");
}


//----------------------------------------------------------------------------
QWidget*
__PLUGIN_NAME__Plugin::GetPluginGUI()
{
	return m_Widget;
}


//----------------------------------------------------------------------------
void
__PLUGIN_NAME__Plugin::ProcessEvent(ritk::Event::Pointer EventP)
{
	// New frame event
	if ( EventP->type() == ritk::NewFrameEvent::EventType )
	{
		// Cast the event
		ritk::NewFrameEvent::Pointer NewFrameEventP = qSharedPointerDynamicCast<ritk::NewFrameEvent,ritk::Event>(EventP);
		if ( !NewFrameEventP )
		{
			LOG_DEB("Event mismatch detected: Type=" << EventP->type());
			return;
		}
		ritk::NewFrameEvent::RImageConstPointer CurrentFrameP = NewFrameEventP->RImage;

		// Here comes your code. Access range data with CurrentFrame.
		// ...

		emit UpdateGUI();
	}
	else
	{
		LOG_DEB("Unknown event");
	}
}
