//一定是从输出端向输入端画线
if(startput==Output_1)
{
x0=startpoint.x;
y0=startpoint.y;
x1=currentpoint.x;
y1=currentpoint.y;
}
else
{
x1=startpoint.x;
y1=startpoint.y;
x0=currentpoint.x; y0=currentpoint.y;
}
delta_x=5;
//动态生成数组对象
CArray<CPoint,CPoint>* pPointArray=new CArray<CPoint,CPoint>;
//根据点的位置分为三种情况:2个点,4个点,5个点
if(x0<x1)
{
if(y0==y1)
{
//两个点情况
pPointArray->Add (CPoint(x0,y0));
pPointArray->Add (CPoint(x1,y1));
}
else
{
//4个点情况
pPointArray->Add (CPoint(x0,y0));
pPointArray->Add (CPoint(x0+delta_x,y0));
pPointArray->Add (CPoint(x0+delta_x,y1));
pPointArray->Add (CPoint(x1,y1));
}
}
else if(x0==x1)
{
//两个点情况
pPointArray->Add (CPoint(x0,y0));
pPointArray->Add (CPoint(x1,y1));
}
else //x0>x1
{
//5个点情况
if(y0<y1)
{
delta_y=20;
}
else
{
delta_y=-20;
}
pPointArray->Add (CPoint(x0,y0));
pPointArray->Add (CPoint(x0,y0+delta_y));
pPointArray->Add (CPoint(x1-delta_x,y0+delta_y));
pPointArray->Add (CPoint(x1-delta_x,y1));
pPointArray->Add (CPoint(x1,y1));
}
//加入当前数组对象地址到MyPointList
MyPointList.AddTail (pPointArray);
//用数组中的点画线
DrawLinkLine(pPointArray);}
首先保证从输出端向输入端画线,这样可以统一画线操作。
上一页 [1] [2] [3] [4] [5] [6] [7] [8] 下一页