📄 drawdoc.h
字号:
// DrawDoc.h : interface of the CDrawDoc class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_DrawDOC_H__0EFFC62E_8953_11D2_AE7B_444553540000__INCLUDED_)
#define AFX_DrawDOC_H__0EFFC62E_8953_11D2_AE7B_444553540000__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#define pi 3.1415926
#include "data1ret.h"
#include "data2set.h"
#include "linkdataset.h"
typedef struct //用来存储逆操作信息的结构
{
unsigned char Lb; //操作的类别
long l_Start; //在外部文件中的位置
int Index; //在删除和增加操作操作时是删除图形元素的数量
}UndoStruct;
typedef struct //用来存储层的信息的结构
{
char m_Name[21];//层的名称
BOOL b_Display; //是否显示1-显示0-隐藏
int reserved; //备用
}LayerStruct;
class CGraphPara //用来存储图形的基本参数的类
{
protected:
int n_ColorNumbAll; //总的颜色数
int n_LayerNumbAll; //总的图层数
int n_ColorNumb; //系统当前具有的颜色数
int n_LayerNumb; //系统当前具有的图层数
long* m_ColorList; //用来存储颜色列表
LayerStruct* m_LayerList;//用来存储层的列表
public:
CGraphPara()
{
n_ColorNumb=100; //最多具有100种颜色
n_LayerNumb=100; //最多具有100层
m_ColorList=new long[n_ColorNumb];
m_LayerList=new LayerStruct[n_LayerNumb];
n_ColorNumb=4; //目前有4种颜色
n_LayerNumb=1; //目前有一层
//以下初始化几种颜色和一个层
m_ColorList[0]=RGB(0,0,0);
m_ColorList[1]=RGB(255,0,0);
m_ColorList[2]=RGB(0,255,0);
m_ColorList[3]=RGB(0,0,255);
m_LayerList[0].b_Display=1;
strcpy(m_LayerList[0].m_Name,"Layer 0");
}
~CGraphPara()
{
delete m_LayerList;
delete m_ColorList;
}
public:
COLORREF GetColor(int n); //得到第n种颜色的实际颜色
BOOL GetDisplayStatue(int n); //得到第n层的显示状态
};
typedef struct
{
float x;
float y;
float z;
}PointStruct;
class CDraw:public CObject //基本图形类,用来存储图形的颜色、线型、层等信息
{
protected:
CDraw(){} //构造函数
short m_ColorPen; //笔色
short m_ColorBrush; //填充刷颜色
short m_LineWide; //线宽(像素)
short m_LineType; //线型(像素)
short m_Layer; //所处层
int m_id_only; //图形元素唯一的识别号
BOOL b_Delete; //是否处于删除状态
// DECLARE_SERIAL(CDraw); //串形化
public:
CDraw(short ColorPen,short ColorBrush,short LineWide,
short LineType,short Layer,int id_only,BOOL Delete)
//构造函数
{
m_ColorPen=ColorPen;
m_ColorBrush=ColorBrush;
m_LineWide=LineWide;
m_LineType=LineType;
m_Layer=Layer;
b_Delete=Delete;
m_id_only=id_only;
}
//计算点到直线的距离的函数
float PointLine(float xx,float yy,float x1,float y1,float x2,float y2);
//判断点是否在一个多边形区域中的函数
BOOL PointRgn(float x,float y,int Numble,PointStruct *PointList,float blc);
BOOL IsDelete(); //判断一个图形元素是否删除的函数
float CalDisp(float x1,float y1,float x2,float y2);//计算两点间的距离的函数
void Delete(BOOL Is); //删除或恢复删除图形元素的函数
//从一个文件中存储或读出图形坐标数据的函数
virtual void Save(CFile* file,BOOL Yn);
virtual void Serialize(CArchive& ar); //文档串形化函数
void toChar(char *p_Char);
char *toData(char *p_Char);
virtual void Draw(CDC *pDC,int m_DrawMode,int m_DrawMode1,short BackColor)=0;
int GetID();
// int ArcRgn(float x,float y,float r,float angl1,float angl2,int nPoint,PointStruct* Pointxy,int *nCross,PointStruct *Pointxy1);
float GetAngle(float x,float y,float xx,float yy);
// int ArcLine(float x,float y,float r,float *angl1,float *angl2,float *X1,float *Y1,float *X2,float *Y2);
// int CircleLine(float x,float y,float r,float *X1,float *Y1,float *X2,float *Y2);
// int PLineRgn(int nPoint1,PointStruct* Pointxy1,int nPoint2,PointStruct* Pointxy2,int *nCross,PointStruct* Pointxy3);
// int CircleCircle(CCircle* cir1,CCircle* cir2,float *angl1,float *angl2);
// int ArcCircle(CArc* arc1,CCircle* cir2,int *nCross,PointStruct* Pointxy1);
}
;
class CLine:public CDraw //直线类
{
protected:
DECLARE_SERIAL(CLine); //声明串形化
public:
float m_X1,m_X2,m_Y1,m_Y2; //直线的起点和终点
CLine(){} //不带任何参数的构造函数
//以下是有初始化参数的构造函数
CLine(short ColorPen,short ColorBrush,
short LineWide,short LineType,short Layer,int id_only,
BOOL Delete,float X1,float Y1,float X2,float Y2)
:CDraw(ColorPen,ColorBrush,LineWide,LineType,Layer,id_only,Delete)
{
m_X1=X1;
m_Y1=Y1;
m_X2=X2;
m_Y2=Y2;
}
//直线的绘制函数
virtual void Draw(CDC *pDC,int m_DrawMode,int m_DrawMode1,short BackColor);
//得到边界矩形的函数
void GetRect(float *minX,float *minY,float *maxX,float *maxY);
BOOL IsPoint(float x,float y,float jl); //判断是否被点选中的函数
virtual void Serialize(CArchive& ar); //串形化函数
//从剪裁板中读出或写入剪裁板的函数
void Save(CFile* file,BOOL Yn);
void toChar(char *p_Char);
char *toData(char *p_Char);
void Move(float x_Move,float y_Move);
int LineLine(CLine* line1,float *xxx1,float *yyy1,float *xxx2,float *yyy2);
};
class CCircle:public CDraw //圆及圆形区域类
{
protected:
DECLARE_SERIAL(CCircle);
public:
float m_CircleX,m_CircleY,m_CircleR; //圆心及半径
BOOL b_Fill; //是否填充 1-圆形区域 0-普通圆
CCircle() //不带任何参数的构造函数
{}
CCircle(short ColorPen,short ColorBrush,
short LineWide,short LineType,short Layer,int id_only,
BOOL Delete,float CircleX,float CircleY,float CircleR,BOOL Fill)
:CDraw(ColorPen,ColorBrush,LineWide,LineType,Layer,id_only,Delete)
{
m_CircleX=CircleX;
m_CircleY=CircleY;
m_CircleR=CircleR;
b_Fill=Fill;
}
virtual void Draw(CDC *pDC,int m_DrawMode,int m_DrawMode1,short BackColor);
void GetRect(float *minX,float *minY,float *maxX,float *maxY);
virtual IsPoint(float x,float y,float jl);
BOOL IsCircle();
virtual void Save(CFile* file,BOOL Yn);
virtual void Serialize(CArchive& ar);
void toChar(char *p_Char);
char *toData(char *p_Char);
void Move(float x_Move,float y_Move);
int CircleLine(CLine* line1,float *angle1,float *angle2,float *X1, float *Y1, float *X2, float *Y2);
int CircleCircle(CCircle* cir1,float *angl1,float *angl2);
};
class CArc:public CCircle //圆弧类
{
protected:
DECLARE_SERIAL(CArc);
public:
float m_Angle1,m_Angle2; //圆弧的起点和终点角度
CArc() //不带任何参数的构造函数
{}
CArc(short ColorPen,short ColorBrush,short LineWide
,short LineType,short Layer,int id_only,BOOL Delete,float CircleX
,float CircleY,float CircleR,BOOL Fill,float Angle1,float Angle2)
:CCircle(ColorPen,ColorBrush,LineWide,LineType,Layer,Delete,id_only,CircleX,
CircleY,CircleR,Fill)
{
m_Angle1=Angle1;
m_Angle2=Angle2;
}
virtual void Draw(CDC *pDC,int m_DrawMode,int m_DrawMode1,short BackColor);
void Init(short ColorPen,short ColorBrush,short LineWide,short LineType,short Layer,float CircleX,float CircleY,float CircleR,BOOL Fill,float Angle1,float Angle2);
void GetRect(float *minX,float *minY,float *maxX,float *maxY);
virtual BOOL IsPoint(float x,float y,float jl);
BOOL IsInArc(float angle);
void Save(CFile* file,BOOL Yn);
virtual void Serialize(CArchive& ar);
void toChar(char *p_Char);
char *toData(char *p_Char);
int ArcLine(CLine *line1, float *angle1, float *angle2, float *X1, float *Y1, float *X2, float *Y2);
int ArcCircle(CCircle* cir1,int *nCross,PointStruct* Pointxy1);
};
class CPline:public CDraw //连续直线或多边形区域类
{
protected:
int m_Numble; //连续直线或多边形区域的顶点数
BOOL b_Fill; //是否为连续直线
DECLARE_SERIAL(CPline); //声明串形化
;
public:
PointStruct* m_PointList; //存储顶点的数组指针
CPline() //不带任何参数的构造函数
{ m_Numble=0;}
CPline(short ColorPen,short ColorBrush,
short LineWide,short LineType,short Layer,int id_only,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -