第一范文网 - 专业文章范例文档资料分享平台

数控系统中C样条曲线插补方法的设计与实现 - 论文0506-new

来源:用户分享 时间:2025/5/15 14:26:17 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

沈阳师范大学本科毕业论文

附录一: 程序代码

using System;

using System.Colleectionss.Geeneriic; using System.ComponenttMoodel; using System.Dattaa; using System.Draawwing; using System.Linbq; using System.Texxt;

using System.Windowss.Formss; using System.Drawingg.Drrawingg2D; using System.Drawing.Imaging;

namespace Demo {

public partialal class Form11 : Form1 {

Graphics graphics; Pen greenPen;

Label[] labelN = new Label[20]; Label[] labelX = new Label[20]; Label[] labelY = new Label[20]; TextBox[] TextX = new TextBox[20]; TextBox[] TextY = new TextBox[20];

int PtNum = 10; public Form1() {

InitializeComponent(); }

private void Form11_Load(object sender, EvArgs ee) {

graphics = pictureBox1.CreateGraphics(); greenPen = new Pen(Color.Blue); InitZuoBiao(); button1.Enabled = false; button2.Enabled =false ; }

private void button1_Click(object sender, EventArgs e) {

graphicss.Clearr(pictureBoxx1.BackColor );

InitZuoBiao(); FillPts();

-29-

沈阳师范大学本科毕业论文

DrawLins(); }

private void InitPtNum() {

int iLoop;

for (iLoop = 0; iLoop < PtNum; iLoop++) {

labelN[iLoop] = new Label(); labelX[iLoop] = new Label(); labelY[iLoop] = new Label(); TextX[iLoop] = new TextBox(); TextY[iLoop] = new TextBox();

this.Controls.Add(labelN[iLoop]); this.Controls.Add(labelX[iLoop]); this.Controls.Add(labelY[iLoop]); this.Controls.Add(TextX[iLoop]); this.Controls.Add(TextY[iLoop]); //l.ForeColor = Color.White;

//labelN[iLoop].Cursor = System.Windows.Forms.Cursors.Hand;

labelN[iLoop].Location = new System.Drawing.Point(640, 50 + iLoop * 40); labelN[iLoop].Name = \; labelN[iLoop].Size = new System.Drawing.Size(30, 12); labelN[iLoop].TabIndex = 5;

labelN[iLoop].Text = \点ì?\ + (iLoop + 1).ToString();

labelX[iLoop].Location = new System.Drawing.Point(670, 50 + iLoop * 40); labelX[iLoop].Name = \;

labelX[iLoop].Size = new System.Drawing.Size(14, 12); labelX[iLoop].TabIndex = 5; labelX[iLoop].Text = \;

labelY[iLoop].Location = new System.Drawing.Point(760, 50 + iLoop * 40); labelY[iLoop].Name = \; labelY[iLoop].Size = new System.Drawing.Size(14, 12); labelY[iLoop].TabIndex = 5; labelY[iLoop].Text = \;

TextX[iLoop].Location = new System.Drawing.Point(690, 45 + iLoop * 40); TextX[iLoop].Name = \; TextX[iLoop].Size = new System.Drawing.Size(62, 21); TextX[iLoop].TabIndex = 5; TextX[iLoop].Text = (iLoop * 30).ToString(); ;

TextY[iLoop].Location = new System.Drawing.Point(780, 45 + iLoop * 40); TextY[iLoop].Name = \; TextY[iLoop].Size = new System.Drawing.Size(62, 21);

-30-

沈阳师范大学本科毕业论文

TextY[iLoop].TabIndex = 5; TextY[iLoop].Text = (iLoop * 50).ToString(); ; } }

private void InitZuoBiao() {

greenPen.Color = Color.Black; greenPen.Width = 1;

greenPen.DashStyle = DashStyle.Dash;

graphics.DrawLine(greenPen, new PointF(150, 10), new PointF(150, 520)); graphics.DrawLine(greenPen, new PointF(250, 10), new PointF(250, 520)); graphics.DrawLine(greenPen, new PointF(300, 0), new PointF(300, 500)); graphics.DrawLine(greenPen, new PointF(400, 0), new PointF(400, 500)); graphics.DrawLine(greenPen, new PointF(500, 0), new PointF(500, 500));

graphics.DrawLine(greenPen, new PointF(150, 10), new PointF(150, 520)); graphics.DrawLine(greenPen, new PointF(250, 10), new PointF(250, 520)); graphics.DrawLine(greenPen, new PointF(0, 300), new PointF(600, 300)); graphics.DrawLine(greenPen, new PointF(0, 400), new PointF(600, 400));

greenPen.Width = 3;

greenPen.DashStyle = DashStyle.Solid;

graphics.DrawLine(greenPen, new PointF(1, 0), new PointF(1, 500));

graphics.DrawLine(greenPen, new PointF(0, 530 - 5), new PointF(600, 530 - 5)); }

private void FillPts() {

greenPen.Color = Color.Blue;

Brush brush = new SolidBrush(Color.Green); int raidus = 10;

PointF[] curvePoints = new PointF[PtNum]; int iLoop;

for (iLoop = 0; iLoop < PtNum; iLoop++) {

curvePoints[iLoop] = new PointF(Convert.ToSingle(TextX[iLoop].Text), 500 - Convert.ToSingle(TextY[iLoop].Text));

graphics.FillEllipse(brush, curvePoints[iLoop].X - raidus / 2, curvePoints[iLoop].Y - raidus / 2, raidus, raidus);

} }

private void DrawLins() {

PointF[] curvePoints = new PointF[PtNum]; int iLoop;

for (iLoop = 0; iLoop < PtNum; iLoop++)

-31-

沈阳师范大学本科毕业论文

{

curvePoints[iLoop] = new PointF(Convert.ToSingle(TextX[iLoop].Text), 500 - Convert.ToSingle(TextY[iLoop].Text)); }

greenPen.Color = Color.Blue;

graphics.DrawLines(greenPen, curvePoints); }

private void DrawCurv() {

PointF[] curvePoints = new PointF[PtNum]; int iLoop;

for (iLoop = 0; iLoop < PtNum; iLoop++) {

curvePoints[iLoop] = new PointF(Convert.ToSingle(TextX[iLoop].Text), 500 - Convert.ToSingle(TextY[iLoop].Text)); }

greenPen.Color = Color.Red;

graphics.DrawCurve(greenPeen, curvePoinsts, 0.6F); }

private void button2_Click(object sender, EventArgs e) {

CubeCacluate(); }

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) {

int iLoop;

for (iLoop = 0; iLoop < PtNum; iLoop++) {

if(labelN[iLoop]!=null) labelN[iLoop].Dispose(); if (labelX[iLoop] != null) labelX[iLoop].Dispose(); if (labelY[iLoop] != null) labelY[iLoop].Dispose(); if (TextX[iLoop] != null) TextX[iLoop].Dispose(); if (TextY[iLoop] != null) TextY[iLoop].Dispose(); }

button1.Enabled = true; button2.Enabled = true;

PtNum = comboBox1.SelectedIndex+2; InitPtNum(); }

-32-

数控系统中C样条曲线插补方法的设计与实现 - 论文0506-new.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c5hb9u72lgo5o77k31873_9.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top