📄 2dcaddoc.cpp
字号:
// 2DCADDoc.cpp : implementation of the CMy2DCADDoc class
//
#include "stdafx.h"
#include "2DCAD.h"
#include "2DCADDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMy2DCADDoc
IMPLEMENT_DYNCREATE(CMy2DCADDoc, CDocument)
BEGIN_MESSAGE_MAP(CMy2DCADDoc, CDocument)
//{{AFX_MSG_MAP(CMy2DCADDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMy2DCADDoc construction/destruction
CMy2DCADDoc::CMy2DCADDoc()
{
// TODO: add one-time construction code here
m_nPointNum = 0; // 初始点数目为0
m_nLineNum = 0; // 初始线段数目为0
}
CMy2DCADDoc::~CMy2DCADDoc()
{
}
BOOL CMy2DCADDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
m_nPointNum = 0; // 初始点数目为0
m_nLineNum = 0; // 初始线段数目为0
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMy2DCADDoc serialization
void CMy2DCADDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
ar<<m_nPointNum; // 首先存入总的点数
for(int i=0;i<m_nPointNum;i++)
{ // 使用循环存入各个点的坐标值
ar<<m_Point[i][0]<<m_Point[i][1];
}
ar<<m_nLineNum; // 存入线段数目
for( i=0;i<m_nLineNum;i++)
{ // 使用循环存入各条线段端点的坐标值
ar<<m_Line[i][0]<<m_Line[i][1]
<<m_Line[i][2]<<m_Line[i][3];
}
}
else
{
// TODO: add loading code here
ar>>m_nPointNum; // 首先读出总的点数
for(int i=0;i<m_nPointNum;i++)
{ // 使用循环读出各个点的坐标值
ar>>m_Point[i][0]>>m_Point[i][1];
}
ar>>m_nLineNum; // 读出线段数目
for( i=0;i<m_nLineNum;i++)
{ // 使用循环读出各条线段端点的坐标值
ar>>m_Line[i][0]>>m_Line[i][1]
>>m_Line[i][2]>>m_Line[i][3];
}
}
}
/////////////////////////////////////////////////////////////////////////////
// CMy2DCADDoc diagnostics
#ifdef _DEBUG
void CMy2DCADDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CMy2DCADDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMy2DCADDoc commands
void CMy2DCADDoc::DeleteContents()
{
// TODO: Add your specialized code here and/or call the base class
m_nPointNum = 0; // 清除文档中的数据
m_nLineNum = 0; // 清除文档中的数据
CDocument::DeleteContents();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -