graph_union.cpp

来自「VS2005 MFC 实现的画图程序」· C++ 代码 · 共 97 行

CPP
97
字号
#include"stdafx.h"
#include"GDraw.h"
#include"Graph_Union.h"



IMPLEMENT_SERIAL(Graph_Union,CObject,1)
void Graph_Union::operator =(Graph_Union &gu)
{
	type=gu.type ;
	count=gu.count ;
	color=gu.color ;
	fill_color=gu.fill_color;
	wide=gu.wide ;
	shape=gu.shape ;
	if(!pp)
		delete []pp;
	if(!count)
		pp=new CPoint[count];
	else
		pp=NULL;
	for(int i=0;i<gu.count ;i++)
		pp[i]=gu.pp [i];
		
}

Graph_Union::Graph_Union(const Graph_Union &gu) 
{
	type=gu.type ;
	count=gu.count ;
	color=gu.color ;
	fill_color=gu.fill_color ;
	wide=gu.wide ;
	shape=gu.shape ;
	if(count)
		pp=new CPoint[count];
	else
		pp=NULL;
	for(int i=0;i<gu.count ;i++)
		pp[i]=gu.pp [i];

}

Graph_Union::Graph_Union() 
{
	count=0;
	pp=NULL;
}
Graph_Union::Graph_Union(int t,int c,int w=1,int s=0,CPoint *ptr=NULL,COLORREF col=RGB(255,255,255),COLORREF f_col=RGB(0,0,0))
:type(t),count(c),wide(w),shape(s),color(col),fill_color(f_col)
{
	if(count)
	{
		pp=new CPoint [count];
		for(int i=0;i<count;i++)
			pp[i]=ptr[i];
	}
	else
		pp=NULL;

}
Graph_Union::~Graph_Union() 
{
	if(pp!=NULL)
		delete []pp;
}


void Graph_Union::Serialize(CArchive &ar)
{

/*	CObject::Serialize(ar);
	if(ar.IsStoring())
	{
    
		 ar<<type;   //the type of graphics:0 line; 1 circle; 2 ellipse; and so on;
		 ar<<count;   //the counter of points
		 ar<<color;
		 ar<<shape;
		 ar<<wide;
		 ar<<pp->x;
		 ar<<pp->y;
          
	}
	else
	{
	 ar>>type;   //the type of graphics:0 line; 1 circle; 2 ellipse; and so on;
	 ar>>count;   //the counter of points
     ar>>color;
	 ar>>shape;
	 ar>>wide;
	 ar>>pp->x;
	 ar>>pp->y;
	}
	*/
}

⌨️ 快捷键说明

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