// STMEditorDoc.cpp : implementation of the CSTMEditorDoc class
//
#include "stdafx.h"
#include "STMEditor.h"
#include "STMEditorDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "math.h"
/////////////////////////////////////////////////////////////////////////////
// CSTMEditorDoc
#include "MapPropDlg.h"
IMPLEMENT_DYNCREATE(CSTMEditorDoc, CDocument)
BEGIN_MESSAGE_MAP(CSTMEditorDoc, CDocument)
//{{AFX_MSG_MAP(CSTMEditorDoc)
ON_COMMAND(ID_MAP_PROP, OnMapProp)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSTMEditorDoc construction/destruction
CSTMEditorDoc::CSTMEditorDoc()
{
m_selTool=ST_BROWSE;
m_arrSel.SetSize(0,10);
}
CSTMEditorDoc::~CSTMEditorDoc()
{
ClearDataBuffer();
}
BOOL CSTMEditorDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
ClearDataBuffer();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CSTMEditorDoc serialization
void CSTMEditorDoc::Serialize(CArchive& ar)
{
CString filename=ar.GetFile()->GetFilePath();
CString path=filename.Left(filename.ReverseFind('\\')+1);
CString workpath=path+ar.GetFile()->GetFileTitle()+"(set)";
CString crossfilename=workpath+"\\cross.dat";
CString pathfilename=workpath+"\\path.dat";
CString bsfilename=workpath+"\\busstation.dat";
CString trfilename=workpath+"\\traffic.dat";
CString streetfilename=workpath+"\\street.dat";
CString addressfilename=workpath+"\\address.dat";
int i;
if (ar.IsStoring())
{
// TODO: add storing code here
ar.WriteString(m_Name);
ar.WriteString("\r\n");
ar.WriteString(m_Author);
ar.WriteString("\r\n");
ar.WriteString(m_Memory);
ar.WriteString("\r\n");
CString tmp;
tmp.Format("%d\r\n%d\r\n%d\r\n",m_Width,m_Height,m_Scale);
ar.WriteString(tmp);
CreateDirectory(workpath,NULL);
if(!m_bkfilename.IsEmpty())
{
CString title=m_bkfilename.Right(m_bkfilename.GetLength()-m_bkfilename.ReverseFind('\\'));
CString bkfilename=workpath+title;
CopyFile(m_bkfilename,bkfilename,TRUE);
ar.WriteString(bkfilename);
ar.WriteString("\r\n");
}
//save cross data
CFile crossfile;
crossfile.Open(crossfilename,CFile::modeCreate|CFile::modeWrite|CFile::typeBinary);
int crosses=m_arrCross.GetSize();
crossfile.Write(&crosses,sizeof(int));
CROSSINFO ci;
int namelen;
for( i=0;i<m_arrCross.GetSize();i++)
{
ci=m_arrCross.GetAt(i);
namelen=strlen(ci.name);
crossfile.Write(&ci.pos,sizeof(POINT));
crossfile.Write(&namelen,sizeof(int));
crossfile.Write(ci.name,strlen(ci.name));
}
crossfile.Close();
//save path data
CFile pathfile;
pathfile.Open(pathfilename,CFile::modeCreate|CFile::modeWrite|CFile::typeBinary);
int pathes=m_arrPath.GetSize();
pathfile.Write(&pathes,sizeof(int));
PATHINFO pi;
for( i=0;i<m_arrPath.GetSize();i++)
{
pi=m_arrPath.GetAt(i);
pathfile.Write(&pi,sizeof(PATHINFO));
}
pathfile.Close();
//save bus station data
CFile bsfile;
bsfile.Open(bsfilename,CFile::modeCreate|CFile::modeWrite|CFile::typeBinary);
int bses=m_arrBS.GetSize();
bsfile.Write(&bses,sizeof(int));
BSINFO bsi;
for( i=0;i<m_arrBS.GetSize();i++)
{
bsi=m_arrBS.GetAt(i);
bsfile.Write(&bsi,sizeof(BSINFO));
}
bsfile.Close();
//save traffic route data
CFile trfile;
trfile.Open(trfilename,CFile::modeCreate|CFile::modeWrite|CFile::typeBinary);
int trafficroutes=m_arrTR.GetSize();
trfile.Write(&trafficroutes,sizeof(int));
TRAFFICROUTEINFO tri;
int test=sizeof(ELEINFO);
for( i=0;i<m_arrTR.GetSize();i++)
{
tri=m_arrTR.GetAt(i);
trfile.Write(tri.name,10);
trfile.Write(&tri.type,sizeof(BYTE));
trfile.Write(&tri.nStations,sizeof(int));
trfile.Write(tri.pEI,sizeof(ELEINFO)*tri.nStations);
}
trfile.Close();
//save street data
CFile streetfile;
streetfile.Open(streetfilename,CFile::modeCreate|CFile::modeWrite|CFile::typeBinary);
int streets=m_arrStreet.GetSize();
streetfile.Write(&streets,sizeof(int));
STREETINFO si;
for(i=0;i<streets;i++)
{
si=m_arrStreet.GetAt(i);
streetfile.Write(si.name,50);
streetfile.Write(&si.nPathes,sizeof(int));
streetfile.Write(si.pPathID,sizeof(int)*si.nPathes);
}
streetfile.Close();
//save address data
CFile addressfile;
addressfile.Open(addressfilename,CFile::modeCreate|CFile::modeWrite|CFile::typeBinary);
int addresses=m_arrAddress.GetSize();
addressfile.Write(&addresses,sizeof(int));
ADDRESSINFO ai;
for(i=0;i<addresses;i++)
{
ai=m_arrAddress.GetAt(i);
addressfile.Write(&ai,sizeof(ADDRESSINFO));
}
addressfile.Close();
}
else
{
// TODO: add loading code here
ClearDataBuffer();
ar.ReadString(m_Name);
ar.ReadString(m_Author);
ar.ReadString(m_Memory);
CString tmp;
ar.ReadString(tmp);
m_Width=atoi(tmp.GetBuffer(tmp.GetLength()));
tmp.ReleaseBuffer();
ar.ReadString(tmp);
m_Height=atoi(tmp.GetBuffer(tmp.GetLength()));
tmp.ReleaseBuffer();
ar.ReadString(tmp);
m_Scale=atoi(tmp.GetBuffer(tmp.GetLength()));
tmp.ReleaseBuffer();
ar.ReadString(m_bkfilename);
m_Picture.Load(m_bkfilename);
//read cross data
CFile crossfile;
if(crossfile.Open(crossfilename,CFile::modeRead|CFile::typeBinary))
{
int crosses;
crossfile.Read(&crosses,sizeof(int));
m_arrCross.SetSize(crosses,10);
CROSSINFO ci;
int namelen=0;
for( i=0;i<crosses;i++)
{
crossfile.Read(&ci.pos,sizeof(POINT));
crossfile.Read(&namelen,sizeof(int));
crossfile.Read(ci.name,namelen);
ci.name[namelen]=0;
m_arrCross.SetAt(i,ci);
}
crossfile.Close();
}
//read path data
CFile pathfile;
if(pathfile.Open(pathfilename,CFile::modeRead|CFile::typeBinary))
{
int pathes;
pathfile.Read(&pathes,sizeof(int));
m_arrPath.SetSize(pathes,10);
PATHINFO pi;
for( i=0;i<pathes;i++)
{
pathfile.Read(&pi,sizeof(PATHINFO));
m_arrPath.SetAt(i,pi);
}
pathfile.Close();
}
//read bus station data
CFile bsfile;
if(bsfile.Open(bsfilename,CFile::modeRead|CFile::typeBinary))
{
int bses;
bsfile.Read(&bses,sizeof(int));
m_arrBS.SetSize(bses,10);
BSINFO bsi;
for( i=0;i<bses;i++)
{
bsfile.Read(&bsi,sizeof(BSINFO));
m_arrBS.SetAt(i,bsi);
}
bsfile.Close();
}
//read traffic route data
CFile trfile;
if(trfile.Open(trfilename,CFile::modeRead|CFile::typeBinary))
{
int trafficroutes;
trfile.Read(&trafficroutes,sizeof(int));
m_arrTR.SetSize(trafficroutes,10);
TRAFFICROUTEINFO tri;
for( i=0;i<trafficroutes;i++)
{
trfile.Read(tri.name,10);//get traffic route name
trfile.Read(&tri.type,sizeof(BYTE));
trfile.Read(&tri.nStations,sizeof(int));//get traffic route number
tri.pEI=new ELEINFO[tri.nStations];
trfile.Read(tri.pEI,sizeof(ELEINFO)*tri.nStations);
m_arrTR.SetAt(i,tri);
}
trfile.Close();
}
//read street data
CFile streetfile;
if(streetfile.Open(streetfilename,CFile::modeRead|CFile::typeBinary))
{
int streets;
streetfile.Read(&streets,sizeof(int));
m_arrStreet.SetSize(streets,10);
STREETINFO si;
for( i=0;i<streets;i++)
{
streetfile.Read(si.name,50);//get traffic route name
streetfile.Read(&si.nPathes,sizeof(int));//get traffic route number
si.pPathID =new int[si.nPathes];
streetfile.Read(si.pPathID,sizeof(int)*si.nPathes);
m_arrStreet.SetAt(i,si);
}
streetfile.Close();
}
CFile addressfile;
if(addressfile.Open(addressfilename,CFile::modeRead|CFile::typeBinary))
{
int addresses;
a
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
vc交通电子地图.rar (91个子文件)
200641210166931
vc交通电子地图
stmeditor
STMStreetEventHandle.h 821B
BSNameInputDlg.h 1KB
StdAfx.cpp 211B
STMNewFileDlg.cpp 2KB
BSNameInputDlg.cpp 1KB
STMEditorDoc.h 6KB
StreetNameInputDlg.h 1KB
STMEditorView.cpp 12KB
STMEditor.aps 60KB
ResizableDlgBar.cpp 3KB
STMEditor.cpp 4KB
STMEditorView.h 3KB
STMEditor.dsp 7KB
TRNameInputDlg.cpp 1KB
MainFrm.h 2KB
STMStreetEventHandle.cpp 2KB
STMBSEventHandle.h 1006B
AddNameInputDlg.h 1KB
CrossNameInputDlg.h 1KB
Picture.h 2KB
STMEditor.rc 19KB
Debug
BSNameInputDlg.obj 13KB
STMEditor.obj 24KB
vc60.pdb 420KB
STMPathEventHandle.obj 20KB
STMEditor.pdb 737KB
STMEditor.pch 6.07MB
TRNameInputDlg.obj 13KB
vc60.idb 281KB
AddNameInputDlg.obj 13KB
StreetNameInputDlg.obj 13KB
STMCrossEventHandle.obj 26KB
STMBSEventHandle.obj 23KB
STMEditorView.obj 60KB
STMAddressEventHandle.obj 22KB
Picture.obj 25KB
STMStreetEventHandle.obj 26KB
STMTREventHandle.obj 26KB
STMEditor.exe 248KB
STMEditor.res 17KB
MainFrm.obj 23KB
STMObjBrowseDlg.obj 51KB
CrossNameInputDlg.obj 13KB
StdAfx.obj 110KB
STMEditorDoc.obj 224KB
STMEditor.ilk 618KB
MapPropDlg.obj 24KB
AddNameInputDlg.cpp 1KB
StdAfx.h 1KB
STMObjBrowseDlg.cpp 14KB
STMTREventHandle.h 837B
STMAddressEventHandle.cpp 5KB
STMEditor.ncb 129KB
MainFrm.cpp 3KB
STMCrossEventHandle.h 1KB
Picture.cpp 5KB
CrossNameInputDlg.cpp 1KB
Resource.h 3KB
STMTREventHandle.cpp 2KB
STMEditor.plg 1KB
MapPropDlg.h 1KB
TRNameInputDlg.h 1KB
STMEditor.dsw 541B
STMObjBrowseDlg.h 2KB
STMEditorDoc.cpp 35KB
STMEditor.h 1KB
res
STMEditor.ico 1KB
locstreet.cur 326B
function.bmp 4KB
loccross.cur 326B
locadd.cur 326B
STMEditor.rc2 401B
BROWSE.cur 326B
locbs.cur 326B
STMEditorDoc.ico 1KB
Toolbar.bmp 1KB
loctr.cur 326B
cursor1.cur 326B
cur00001.cur 326B
STMPathEventHandle.h 1KB
STMEditor.opt 54KB
STMBSEventHandle.cpp 5KB
STMEditor.clw 7KB
STMNewFileDlg.h 1KB
ResizableDlgBar.h 1KB
MapPropDlg.cpp 3KB
StreetNameInputDlg.cpp 1KB
STMAddressEventHandle.h 990B
STMCrossEventHandle.cpp 6KB
STMPathEventHandle.cpp 6KB
使用说明.htm 855B
共 91 条
- 1
资源评论
- dk12012-10-26是vc的代码,比较老了,还可以参考一下啊。
innphysu
- 粉丝: 1
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功