// ShapeCloudPanel.cpp : implementation file
//

#include "stdafx.h"
#include "pixelwhippro.h"
#include "ShapeCloudPanel.h"

extern CPixelWhipProApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CShapeCloudPanel dialog


CShapeCloudPanel::CShapeCloudPanel(CWnd* pParent /*=NULL*/)
	: CDynaPanel(CShapeCloudPanel::IDD, pParent)
{
	//{{AFX_DATA_INIT(CShapeCloudPanel)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CShapeCloudPanel::DoDataExchange(CDataExchange* pDX)
{
	CDynaPanel::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CShapeCloudPanel)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CShapeCloudPanel, CDynaPanel)
	//{{AFX_MSG_MAP(CShapeCloudPanel)
	ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CShapeCloudPanel message handlers

void CShapeCloudPanel::Set(void *dat)
{

	ShapeSpec=(gosFX::ShapeCloud__Specification *)dat;
}

void CShapeCloudPanel::OnBrowse() 
{
	CString doc_path=theApp.DocPath.Left(theApp.DocPath.ReverseFind('\\')),shape_path;
//	if(doc_path.GetLength()==0) 	GetCurrentDirectory(doc_path);
	SetCurrentDirectory(doc_path);
	
	CFileDialog dlg1(TRUE,"mlr",NULL,OFN_NOCHANGEDIR,"MLR Geometry(*.mlr)|*.mlr||",this);
	if(dlg1.DoModal()==IDOK)
	{
	shape_path=dlg1.GetPathName();
		if(doc_path.GetLength()>shape_path.GetLength() ||
			shape_path.Left(doc_path.GetLength()).CompareNoCase(doc_path)
			)
		{	
			MessageBox("Shape Path Error");
		}
		else
		{
			shape_path=shape_path.Mid(doc_path.GetLength()+1);
			
			ShapeSpec->SetShape(MString(shape_path));
			MidLevelRenderer::MLRTexturePool::Instance->LoadImages();	
		}
		
	}
		
}
