www.pudn.com > 3DEDITOR.rar > DLGIMPORT.CPP


// DlgImport.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "3DEditor.h" 
#include "DlgImport.h" 
#include "ImpExp3ds.h" 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// DlgImport dialog 
 
 
DlgImport::DlgImport(CWnd* pParent /*=NULL*/) 
	: CDialog(DlgImport::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(DlgImport) 
	//}}AFX_DATA_INIT 
} 
 
 
void DlgImport::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(DlgImport) 
	DDX_Control(pDX, IDC_N_VERTS, m_n_verts); 
	DDX_Control(pDX, IDC_N_OBJECTS, m_n_objects); 
	DDX_Control(pDX, IDC_N_FACES, m_n_faces); 
	DDX_Control(pDX, IDC_LIST, m_list); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(DlgImport, CDialog) 
	//{{AFX_MSG_MAP(DlgImport) 
	ON_BN_CLICKED(IDC_ALL, OnAll) 
	ON_BN_CLICKED(IDC_NONE, OnNone) 
	ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST, OnItemchangedList) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// DlgImport message handlers 
 
class import3ds_names : private import3ds 
{ 
public: 
	DlgImport *dlgi; 
	char str[256]; 
	void object3d(char *name, int nv, int nf, int ntc,float *local_axis) 
	{ 
		sprintf(str,"%s",name); 
		dlgi->m_list.InsertItem(0,str); 
 
		LV_FINDINFO pFindInfo; 
		pFindInfo.flags=LVFI_STRING; 
		pFindInfo.psz=str; 
		int indx=dlgi->m_list.FindItem( &pFindInfo ); 
 
		sprintf(str,"%i",nv); 
		dlgi->m_list.SetItem(indx,1,LVIF_TEXT,str,0,0,0,0); 
		sprintf(str,"%i",nf); 
		dlgi->m_list.SetItem(indx,2,LVIF_TEXT,str,0,0,0,0); 
 
		dlgi->nvI+=nv; 
		dlgi->nfI+=nf; 
		dlgi->noI++; 
	} 
 
	import3ds_names(DlgImport *d, char *file) 
	{ 
		dlgi=d; 
		dlgi->nvI=0; 
		dlgi->nfI=0; 
		dlgi->noI=0; 
		if (dlgi) 
			import(file,1); 
	} 
}; 
 
void DlgImport::OnAll()  
{ 
	// TODO: Add your control notification handler code here 
	int i,j=m_list.GetItemCount(); 
	for( i=0;iEnableWindow(m_list.GetSelectedCount()); 
	m_list.SetFocus();	 
} 
 
void DlgImport::OnNone()  
{ 
	// TODO: Add your control notification handler code here 
	int i,j=m_list.GetItemCount(); 
	for( i=0;iobj0; 
	 
	int nf=0; 
	int e; 
 
	while(o) 
	{ 
		for(e=0;enelem;e++) 
			nf+=(o->elem[e].ncoef-o->elem[e].cur_ncoef-1)*2+o->elem[e].nrf; 
		o=o->next; 
	} 
 
	CString s; 
 
	m_n_faces.GetWindowText(s); 
 
	doc->ncamlib_ant=doc->ncamlib; 
	doc->nlights_ant=doc->nlights; 
	doc->nmatlib_ant=doc->nmatlib; 
	doc->nobj_ant=doc->nobj; 
 
	BeginWaitCursor();	 
	doc->import(filename,&m_list); 
	EndWaitCursor();		 
	CDialog::OnOK(); 
} 
 
void DlgImport::OnItemchangedList(NMHDR* pNMHDR, LRESULT* pResult)  
{ 
	NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; 
	// TODO: Add your control notification handler code here 
	int sel=m_list.GetSelectedCount(); 
	 
	GetDlgItem(IDOK)->EnableWindow(sel); 
	char str[256]; 
	if (sel==0) 
		{ 
		sprintf(str,"%i",noI); 
		m_n_objects.SetWindowText(str); 
		sprintf(str,"%i",nvI); 
		m_n_verts.SetWindowText(str); 
		sprintf(str,"%i",nfI); 
		m_n_faces.SetWindowText(str); 
		} 
	else 
	{ 
	int i,j=m_list.GetItemCount(); 
	int totf=0,totv=0,toto=0; 
 
	for( i=0;iEnableWindow(0);	 
	return TRUE;  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
}