用C#解析DXF文件,读取里面的有用数据绘制在picturebox上,椭圆椭圆弧,圆弧旋转角度及相对位置处理不好 30
1个回答
展开全部
绘制圆弧(C#)
class ARC
{
public string LName;
public Double CenterX; //圆心坐标X
public Double CenterY; //圆心坐标Y
public Double Radiu; //半径
public Double SAngle; //起始角度
public Double EAngle; //结束角度
public string lwidth;
public void Move(double leftx, double lefty, double righty) //坐标转换,根据程序需求,自定义
{
PointF pos = GraphProperty.coordinatesTranslateF(CenterX, CenterY, leftx, lefty, righty); //自定义
CenterX = pos.X;
CenterY = pos.Y;
Radiu /= GraphProperty.ratio; //圆弧缩放,自定义
}
public void Draw(Graphics g) //绘制圆弧
{
if (SAngle == 0.0 && EAngle == 0.0) //如果是封闭的园
{
Rectangle re = new Rectangle((int)(CenterX - Radiu), (int)(CenterY - Radiu), (int)(2 * Radiu), (int)(2 * Radiu)); //指定圆弧所在的矩形
g.DrawArc(GraphProperty.p, re, 0, 360); // 绘制圆弧,SAngle是圆弧起始角度,EAngle是圆弧末端角度
}
else //如果是圆弧
{
Rectangle re = new Rectangle((int)(CenterX - Radiu), (int)(CenterY - Radiu), (int)(2 * Radiu), (int)(2 * Radiu));
g.DrawArc(GraphProperty.p, re, (float)(360 - EAngle), (float)((360 + EAngle - SAngle) % 360)); // 绘制圆弧,SAngle是圆弧起始角度,EAngle是圆弧末端角度
}
}
}
class ARC
{
public string LName;
public Double CenterX; //圆心坐标X
public Double CenterY; //圆心坐标Y
public Double Radiu; //半径
public Double SAngle; //起始角度
public Double EAngle; //结束角度
public string lwidth;
public void Move(double leftx, double lefty, double righty) //坐标转换,根据程序需求,自定义
{
PointF pos = GraphProperty.coordinatesTranslateF(CenterX, CenterY, leftx, lefty, righty); //自定义
CenterX = pos.X;
CenterY = pos.Y;
Radiu /= GraphProperty.ratio; //圆弧缩放,自定义
}
public void Draw(Graphics g) //绘制圆弧
{
if (SAngle == 0.0 && EAngle == 0.0) //如果是封闭的园
{
Rectangle re = new Rectangle((int)(CenterX - Radiu), (int)(CenterY - Radiu), (int)(2 * Radiu), (int)(2 * Radiu)); //指定圆弧所在的矩形
g.DrawArc(GraphProperty.p, re, 0, 360); // 绘制圆弧,SAngle是圆弧起始角度,EAngle是圆弧末端角度
}
else //如果是圆弧
{
Rectangle re = new Rectangle((int)(CenterX - Radiu), (int)(CenterY - Radiu), (int)(2 * Radiu), (int)(2 * Radiu));
g.DrawArc(GraphProperty.p, re, (float)(360 - EAngle), (float)((360 + EAngle - SAngle) % 360)); // 绘制圆弧,SAngle是圆弧起始角度,EAngle是圆弧末端角度
}
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询