www.pudn.com > DEM_TDS.rar > DEMDoc.cpp, change:2007-06-20,size:2311b


// DEMDoc.cpp : implementation of the CDEMDoc class 
// 
 
#include "stdafx.h" 
#include "DEM.h" 
#include "MainFrm.h" 
#include "DEMDoc.h" 
#include "DEMView.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CDEMDoc 
 
IMPLEMENT_DYNCREATE(CDEMDoc, CDocument) 
 
BEGIN_MESSAGE_MAP(CDEMDoc, CDocument) 
	//{{AFX_MSG_MAP(CDEMDoc) 
	ON_COMMAND(ID_FILE_OPEN, OnFileOpen) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CDEMDoc construction/destruction 
 
CDEMDoc::CDEMDoc() 
{ 
	// TODO: add one-time construction code here 
 
} 
 
CDEMDoc::~CDEMDoc() 
{ 
 
} 
 
BOOL CDEMDoc::OnNewDocument() 
{ 
	if (!CDocument::OnNewDocument()) 
		return FALSE; 
 
	// TODO: add reinitialization code here 
	// (SDI documents will reuse this document) 
 return TRUE; 
} 
 
 
///////////////////////////////////////////////////////////////////////////// 
// CDEMDoc serialization 
 
void CDEMDoc::Serialize(CArchive& ar) 
{ 
	if (ar.IsStoring()) 
	{ 
		// TODO: add storing code here 
	} 
	else 
	{ 
		// TODO: add loading code here 
	} 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CDEMDoc diagnostics 
 
#ifdef _DEBUG 
void CDEMDoc::AssertValid() const 
{ 
	CDocument::AssertValid(); 
} 
 
void CDEMDoc::Dump(CDumpContext& dc) const 
{ 
	CDocument::Dump(dc); 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CDEMDoc commands 
 
bool CDEMDoc::OnFileOpen()  
{ 
	// TODO: Add your command handler code here 
	CMainFrame *pMainFrm=(CMainFrame *)AfxGetMainWnd(); 
	CMDIChildWnd *pChild = pMainFrm->MDIGetActive(); 
	CDEMView *pView=(CDEMView*)pChild->GetActiveView(); 
 
	CFileDialog dfxFileDig(true,NULL,NULL,OFN_READONLY|OFN_HIDEREADONLY, 
	"DEM Files(*.DEM)|*.DEM|All Files(*.*)|*.*|"); 
	if(dfxFileDig.DoModal()==IDCANCEL)return false; 
	CString fileName=dfxFileDig.GetPathName(); 
	dfxFileDig.DestroyWindow(); 
	if(fileName.Find(".DEM")==-1)fileName+=".DEM"; 
	ifstream is(fileName); 
 
	demdata.DeleteDEM(); 
 
	maploadok=demdata.ReadDEMdata(is); 
 
	if(maploadok)pView->MapOpen(&demdata); 
	return true; 
}