⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smallcad203doc.cpp

📁 一个简单的画图程序 可以画点线面等
💻 CPP
字号:
// SmallCAD203Doc.cpp : implementation of the CSmallCAD203Doc class
//

#include "stdafx.h"
#include "SmallCAD203.h"
#include "GraphEllipse.h"
#include "GraphPoint.h"
#include "GraphRectangle.h"
#include "GraphTriangle.h"
#include "GraphLine.h"

#include "SmallCAD203Doc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSmallCAD203Doc

IMPLEMENT_DYNCREATE(CSmallCAD203Doc, CDocument)

BEGIN_MESSAGE_MAP(CSmallCAD203Doc, CDocument)
	//{{AFX_MSG_MAP(CSmallCAD203Doc)
		// 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()

/////////////////////////////////////////////////////////////////////////////
// CSmallCAD203Doc construction/destruction

CSmallCAD203Doc::CSmallCAD203Doc()
{
	// TODO: add one-time construction code here
	m_pCurrentFunction=NULL;
	m_currentScale=1;
	m_currentColor=0;
	m_nGraphNumber=0;

}

CSmallCAD203Doc::~CSmallCAD203Doc()
{
}

BOOL CSmallCAD203Doc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	// TODO: add reinitialization code here
	// (SDI documents will reuse this document)

	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CSmallCAD203Doc serialization

void CSmallCAD203Doc::Serialize(CArchive &ar)
{
	CGraph *p1;
	p1=this->my_list.head;

	if(ar.IsStoring())
	{
		while(p1!=NULL)
		{
			ar<<(p1->nflag);
			p1->Serialize(ar);
			p1=p1->next;
		}
		ar<<100;
	}
	else
	{
		my_list.head=NULL;
		int sharp;
		ar>>sharp;
		CGraph *p2;
		while(sharp!=100)
		{
			switch(sharp)

			{
			case 1: 
				p2=new CGraphEllipse;
				p2->Serialize(ar);
				this->my_list.InSert(p2);
				break;
			case 2:
				p2=new CGraphPoint;
				p2->Serialize(ar);
				this->my_list.InSert(p2);
				break;
			case 3:
				p2=new CGraphRectangle;
				p2->Serialize(ar);
				this->my_list.InSert(p2);
				break;
			case 4:
				p2=new CGraphTriangle;
				p2->Serialize(ar);
				this->my_list.InSert(p2);
				break;
			case 5:
				p2=new CGraphLine;
				p2->Serialize(ar);
				this->my_list.InSert(p2);
				break;
			default:
				break;
			}

			ar>>sharp;
		}


	}
}

/////////////////////////////////////////////////////////////////////////////
// CSmallCAD203Doc diagnostics

#ifdef _DEBUG
void CSmallCAD203Doc::AssertValid() const
{
	CDocument::AssertValid();
}

void CSmallCAD203Doc::Dump(CDumpContext& dc) const
{
	CDocument::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CSmallCAD203Doc commands

void CSmallCAD203Doc::SetCurrentFunction(CFunction *F)
{
	if(m_pCurrentFunction!=NULL)
		delete m_pCurrentFunction;
	m_pCurrentFunction=F;
}

CFunction* CSmallCAD203Doc::GetCurrentFunction()
{
	return m_pCurrentFunction;

}

void CSmallCAD203Doc::AddGraph(CGraph *g)
{
//	m_pGraphList[m_nGraphNumber++]=g;

}

//CGraph * CSmallCAD203Doc::GetGraph(int idx)
//{
	//	return m_pGraphList[idx];

//}

void CSmallCAD203Doc::SetCurrentColor(COLORREF color)
{	
	m_currentColor=color;

}

COLORREF CSmallCAD203Doc::GetCurrentColor()
{
	return m_currentColor;

}

void CSmallCAD203Doc::SetCurrentScale(int scale)
{
	m_currentScale=scale;

}

int CSmallCAD203Doc::GetCurrentScale()
{
	return m_currentScale;

}

//int CSmallCAD203Doc::GetGraphNumber()
//{
	//return m_nGraphNumber;

//}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -