// ProfilePanel.cpp : implementation file
//

#include "stdafx.h"
#include "pixelwhippro.h"
#include "ProfilePanel.h"

extern CPixelWhipProApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CProfilePanel dialog


CProfilePanel::CProfilePanel(CWnd* pParent /*=NULL*/)
: CDynaPanel(CProfilePanel::IDD, pParent)
{
	//{{AFX_DATA_INIT(CProfilePanel)
	m_PrfPan = -1;
	//}}AFX_DATA_INIT
}


void CProfilePanel::DoDataExchange(CDataExchange* pDX)
{
	CDynaPanel::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CProfilePanel)
	DDX_CBIndex(pDX, IDC_PRF, m_PrfPan);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CProfilePanel, CDynaPanel)
//{{AFX_MSG_MAP(CProfilePanel)
ON_CBN_SELCHANGE(IDC_PRF, OnSelchangePrf)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CProfilePanel message handlers
void CProfilePanel::Set(void *dat)
{
	gosFX::Effect::Specification *espec=(gosFX::Effect::Specification *)dat;
	tspec=NULL;
	bspec=NULL;
	
	switch(espec->GetClassID())
	{
	case gosFX::TubeClassID:
		tspec=(gosFX::Tube__Specification *)dat;
		break;
		
	case gosFX::BeamClassID:
		bspec=(gosFX::Beam__Specification *)dat;
		break;
	}
	
	if(tspec)
		switch(tspec->m_profileType)
	{
	case	gosFX::Tube__Specification::e_Ribbon :			m_PrfPan=0; break;
	case	gosFX::Tube__Specification::e_VerticalRibbon :	m_PrfPan=1; break;
	case	gosFX::Tube__Specification::e_Triangle:			m_PrfPan=2; break; 
	case	gosFX::Tube__Specification::e_Square:			m_PrfPan=3; break;
	case	gosFX::Tube__Specification::e_Cross:			m_PrfPan=4; break;
	case	gosFX::Tube__Specification::e_Pentagon:			m_PrfPan=5; break;
	case	gosFX::Tube__Specification::e_Hexagon:			m_PrfPan=6; break;
	case	gosFX::Tube__Specification::e_AlignedRibbon:	m_PrfPan=7; break;
		
	}
	
	if(bspec)
		switch(bspec->m_profileType)
	{
	case	gosFX::Beam__Specification::e_Ribbon :			m_PrfPan=0; break;
	case	gosFX::Beam__Specification::e_VerticalRibbon :	m_PrfPan=1; break;
	case	gosFX::Beam__Specification::e_Triangle:			m_PrfPan=2; break; 
	case	gosFX::Beam__Specification::e_Square:			m_PrfPan=3; break;
	case	gosFX::Beam__Specification::e_Cross:			m_PrfPan=4; break;
	case	gosFX::Beam__Specification::e_Pentagon:			m_PrfPan=5; break;
	case	gosFX::Beam__Specification::e_Hexagon:			m_PrfPan=6; break;
	case	gosFX::Beam__Specification::e_AlignedRibbon:	m_PrfPan=7; break;
		
	}
	
	
}

void CProfilePanel::OnSelchangePrf() 
{
	UpdateData(TRUE);
	theApp.StopEffects();
	
	if(tspec)
	{
		switch(m_PrfPan)
		{
		case 0: tspec->m_profileType=gosFX::Tube__Specification::e_Ribbon ; break;
		case 1: tspec->m_profileType=gosFX::Tube__Specification::e_VerticalRibbon ; break;
		case 2: tspec->m_profileType=gosFX::Tube__Specification::e_Triangle; break; 
		case 3: tspec->m_profileType=gosFX::Tube__Specification::e_Square; break;
		case 4: tspec->m_profileType=gosFX::Tube__Specification::e_Cross; break;
		case 5: tspec->m_profileType=gosFX::Tube__Specification::e_Pentagon; break;
		case 6: tspec->m_profileType=gosFX::Tube__Specification::e_Hexagon; break;
		case 7: tspec->m_profileType=gosFX::Tube__Specification::e_AlignedRibbon; break;
			
		}
		tspec->BuildTemplate();
	}
	
	if(bspec)
	{
		switch(m_PrfPan)
		{
		case 0: bspec->m_profileType=gosFX::Beam__Specification::e_Ribbon ; break;
		case 1: bspec->m_profileType=gosFX::Beam__Specification::e_VerticalRibbon ; break;
		case 2: bspec->m_profileType=gosFX::Beam__Specification::e_Triangle; break; 
		case 3: bspec->m_profileType=gosFX::Beam__Specification::e_Square; break;
		case 4: bspec->m_profileType=gosFX::Beam__Specification::e_Cross; break;
		case 5: bspec->m_profileType=gosFX::Beam__Specification::e_Pentagon; break;
		case 6: bspec->m_profileType=gosFX::Beam__Specification::e_Hexagon; break;
		case 7: bspec->m_profileType=gosFX::Beam__Specification::e_AlignedRibbon; break;
			
		}
		bspec->BuildTemplate();
	}
	
	theApp.StartEffects();
	
}
