Exemplo n.º 1
0
        public ArcCmd(RunnableModule runnableModule, ArcCmdLine arcCmdLine, MeasureHeightCmd mhCmd) : base(runnableModule, arcCmdLine)
        {
            this.Valve = arcCmdLine.Valve;
            var structure = runnableModule.CommandsModule.program.ModuleStructure;

            if (!runnableModule.CommandsModule.IsReversePattern)
            {
                start  = structure.ToMachine(runnableModule, arcCmdLine.Start);
                middle = structure.ToMachine(runnableModule, arcCmdLine.Middle);
                end    = structure.ToMachine(runnableModule, arcCmdLine.End);
                center = structure.ToMachine(runnableModule, arcCmdLine.Center);
                Degree = arcCmdLine.Degree;
            }
            else
            {
                start  = structure.ToMachine(runnableModule, arcCmdLine.End);
                middle = structure.ToMachine(runnableModule, arcCmdLine.Middle);
                end    = structure.ToMachine(runnableModule, arcCmdLine.Start);
                center = structure.ToMachine(runnableModule, arcCmdLine.Center);
                Degree = -arcCmdLine.Degree;
            }

            LineStyle       = arcCmdLine.LineStyle;
            IsWeightControl = arcCmdLine.IsWeightControl;
            weight          = arcCmdLine.Weight;
            this.associatedMeasureheightCmd = mhCmd;
        }
Exemplo n.º 2
0
        public void TeachPoint(PointD point)
        {
            CmdLinePoint cmdLinePoint = this.model.GetSelectedPoint();

            if (cmdLinePoint == null)
            {
                return;
            }

            cmdLinePoint.Point.X = point.X;
            cmdLinePoint.Point.Y = point.Y;
            //如果是圆弧则要重新计算圆弧中心和弧度
            if (cmdLinePoint.CmdLineType == CmdLineType.圆弧或圆环)
            {
                ArcCmdLine arc = this.model.CmdLineList[cmdLinePoint.CmdLineNo] as ArcCmdLine;
                arc.Center = MathUtils.CalculateCircleCenter(arc.Start, arc.Middle, arc.End);
                //如果不是圆环,则要重新计算弧度
                if (arc.Degree != 360 && arc.Degree != -360)
                {
                    arc.Degree = MathUtils.CalculateDegree(arc.Start, arc.Middle, arc.End, arc.Center);
                }
            }
            this.model.NotifyObserversModelChanged();

            if (this.AutoTrack)
            {
                if (!this.NextTrack())
                {
                    MessageBox.Show("已到最后一个点");
                }
            }
            else
            {
                this.model.NotifyObserverSelectChanged();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Author: liyi
        /// Date:   2019/08/27
        /// Description:用于将界面参数更新至传入的轨迹数组
        /// </summary>
        /// <param name="cmdLines"></param>
        private void UpdateCmdLineParam(List <CmdLine> cmdLines)
        {
            if (cmdLines.Count <= 0)
            {
                return;
            }
            if (this.rdoIncrementWeight.Checked)
            {
                isConstantWeight = false;
            }
            else if (this.rdoConstantWeight.Checked)
            {
                isConstantWeight = true;
            }
            if (this.cbxRotate.SelectedIndex == -1)
            {
                this.cbxRotate.SelectedIndex = 0;
            }
            double rotateAngle = this.cbxRotate.SelectedIndex * 90;

            // 机械坐标 -> 系统坐标
            PointD referencePoint = this.pattern.SystemRel(new PointD(this.tbRefX.Value, this.tbRefY.Value));
            PointD offsetPoint    = this.pattern.SystemRel(new PointD(this.tbXOffset.Value, this.tbYOffset.Value));
            double offsetX        = offsetPoint.X; //this.tbXOffset.Value;
            double offsetY        = offsetPoint.Y; //this.tbYOffset.Value;

            foreach (CmdLine cmdLine in cmdLines)
            {
                //判断是否是胶量模式
                //1.胶量模式,全部启用胶量模式
                //2.非胶量模式,全部禁用胶量模式
                //3.都有的状态,只增加胶量值,不更改模式
                if (cmdLine is CircleCmdLine)
                {
                    CircleCmdLine circleCmdLine = cmdLine as CircleCmdLine;
                    circleCmdLine.Weight = GetNewValue(circleCmdLine.Weight, tbWeight.Value, isConstantWeight);
                    PointD temp = GetNewPosition(circleCmdLine.Start, referencePoint, offsetX, offsetY, rotateAngle);
                    circleCmdLine.Start.X = temp.X;
                    circleCmdLine.Start.Y = temp.Y;
                    temp = GetNewPosition(circleCmdLine.Start, referencePoint, offsetX, offsetY, rotateAngle);
                    circleCmdLine.End.X = temp.X;
                    circleCmdLine.End.Y = temp.Y;
                    temp = GetNewPosition(circleCmdLine.Middle, referencePoint, offsetX, offsetY, rotateAngle);
                    circleCmdLine.Middle.X = temp.X;
                    circleCmdLine.Middle.Y = temp.Y;
                    temp = GetNewPosition(circleCmdLine.Middle, referencePoint, offsetX, offsetY, rotateAngle);
                    circleCmdLine.Center.X = temp.X;
                    circleCmdLine.Center.Y = temp.Y;
                    if (this.cbxLineType.SelectedIndex != -1)
                    {
                        circleCmdLine.LineStyle = (LineStyle)this.cmdLineType;
                    }
                    if (this.cbIsWeightControl.CheckState != CheckState.Indeterminate)
                    {
                        circleCmdLine.IsWeightControl = this.cbIsWeightControl.Checked;
                    }
                }
                else if (cmdLine is ArcCmdLine)
                {
                    ArcCmdLine arcCmdLine = cmdLine as ArcCmdLine;
                    arcCmdLine.Weight = GetNewValue(arcCmdLine.Weight, tbWeight.Value, isConstantWeight);
                    PointD temp = GetNewPosition(arcCmdLine.Start, referencePoint, offsetX, offsetY, rotateAngle);
                    arcCmdLine.Start.X = temp.X;
                    arcCmdLine.Start.Y = temp.Y;
                    temp                = GetNewPosition(arcCmdLine.End, referencePoint, offsetX, offsetY, rotateAngle);
                    arcCmdLine.End.X    = temp.X;
                    arcCmdLine.End.Y    = temp.Y;
                    temp                = GetNewPosition(arcCmdLine.Middle, referencePoint, offsetX, offsetY, rotateAngle);
                    arcCmdLine.Middle.X = temp.X;
                    arcCmdLine.Middle.Y = temp.Y;
                    temp                = GetNewPosition(arcCmdLine.Center, referencePoint, offsetX, offsetY, rotateAngle);
                    arcCmdLine.Center.X = temp.X;
                    arcCmdLine.Center.Y = temp.Y;
                    if (this.cbxLineType.SelectedIndex != -1)
                    {
                        arcCmdLine.LineStyle = (LineStyle)this.cmdLineType;
                    }
                    if (this.cbIsWeightControl.CheckState != CheckState.Indeterminate)
                    {
                        arcCmdLine.IsWeightControl = this.cbIsWeightControl.Checked;
                    }
                }
                else if (cmdLine is DotCmdLine)
                {
                    DotCmdLine dotCmdLine = cmdLine as DotCmdLine;
                    dotCmdLine.Weight = GetNewValue(dotCmdLine.Weight, tbWeight.Value, isConstantWeight);
                    PointD temp = GetNewPosition(dotCmdLine.Position, referencePoint, offsetX, offsetY, rotateAngle);
                    dotCmdLine.Position.X = temp.X;
                    dotCmdLine.Position.Y = temp.Y;
                    if (this.cbxDotType.SelectedIndex != -1)
                    {
                        dotCmdLine.DotStyle = (DotStyle)this.cmdDotType;
                    }
                    if (this.cbIsWeightControl.CheckState != CheckState.Indeterminate)
                    {
                        dotCmdLine.IsWeightControl = this.cbIsWeightControl.Checked;
                    }
                }
                else if (cmdLine is SnakeLineCmdLine)
                {
                    SnakeLineCmdLine snakeLineCmdLine = cmdLine as SnakeLineCmdLine;
                    if (this.cbxLineType.SelectedIndex != -1)
                    {
                        snakeLineCmdLine.LineStyle = (LineStyle)this.cmdLineType;
                    }
                    if (this.cbIsWeightControl.CheckState != CheckState.Indeterminate)
                    {
                        snakeLineCmdLine.IsWeightControl = this.cbIsWeightControl.Checked;
                    }
                    PointD temp = new PointD();
                    foreach (LineCoordinate item in snakeLineCmdLine.LineCoordinateList)
                    {
                        temp         = GetNewPosition(item.Start, referencePoint, offsetX, offsetY, rotateAngle);
                        item.Start.X = temp.X;
                        item.Start.Y = temp.Y;
                        temp         = GetNewPosition(item.End, referencePoint, offsetX, offsetY, rotateAngle);
                        item.End.X   = temp.X;
                        item.End.Y   = temp.Y;
                    }
                }
                else if (cmdLine is LineCmdLine)
                {
                    LineCmdLine lineCmdLine = cmdLine as LineCmdLine;
                    if (this.cbxLineType.SelectedIndex != -1)
                    {
                        lineCmdLine.LineStyle = (LineStyle)this.cmdLineType;
                    }
                    for (int i = 0; i < lineCmdLine.LineCoordinateList.Count; i++)
                    {
                        lineCmdLine.LineCoordinateList[i].LineStyle = lineCmdLine.LineStyle;
                    }
                    if (this.cbIsWeightControl.CheckState != CheckState.Indeterminate)
                    {
                        lineCmdLine.IsWeightControl = this.cbIsWeightControl.Checked;
                    }
                    if (lineCmdLine.LineMethod == LineMethod.Single)
                    {
                        lineCmdLine.WholeWeight = GetNewValue(lineCmdLine.WholeWeight, tbWeight.Value, isConstantWeight);
                    }
                    else if (lineCmdLine.LineMethod == LineMethod.Multi)
                    {
                        lineCmdLine.WholeWeight = GetNewValue(lineCmdLine.WholeWeight, tbWeight.Value, isConstantWeight);
                    }
                    else if (lineCmdLine.LineMethod == LineMethod.Poly)
                    {
                        lineCmdLine.WholeWeight = GetNewValue(lineCmdLine.WholeWeight, tbWeight.Value, isConstantWeight);
                    }
                    PointD temp = new PointD();
                    foreach (LineCoordinate item in lineCmdLine.LineCoordinateList)
                    {
                        temp         = GetNewPosition(item.Start, referencePoint, offsetX, offsetY, rotateAngle);
                        item.Start.X = temp.X;
                        item.Start.Y = temp.Y;
                        temp         = GetNewPosition(item.End, referencePoint, offsetX, offsetY, rotateAngle);
                        item.End.X   = temp.X;
                        item.End.Y   = temp.Y;
                    }
                }
                else if (cmdLine is MultiTracesCmdLine)
                {
                    MultiTracesCmdLine multiTrace = cmdLine as MultiTracesCmdLine;
                    PointD             temp       = new PointD();
                    foreach (var item in multiTrace.Traces)
                    {
                        if (item is TraceLine)
                        {
                            temp         = GetNewPosition(item.Start, referencePoint, offsetX, offsetY, rotateAngle);
                            item.Start.X = temp.X;
                            item.Start.Y = temp.Y;
                            temp         = GetNewPosition(item.End, referencePoint, offsetX, offsetY, rotateAngle);
                            item.End.X   = temp.X;
                            item.End.Y   = temp.Y;
                        }
                        else if (item is TraceArc)
                        {
                            TraceArc traceArc = item as TraceArc;
                            temp             = GetNewPosition(traceArc.Start, referencePoint, offsetX, offsetY, rotateAngle);
                            traceArc.Start.X = temp.X;
                            traceArc.Start.Y = temp.Y;
                            temp             = GetNewPosition(traceArc.Mid, referencePoint, offsetX, offsetY, rotateAngle);
                            traceArc.Mid.X   = temp.X;
                            traceArc.Mid.Y   = temp.Y;
                            temp             = GetNewPosition(traceArc.End, referencePoint, offsetX, offsetY, rotateAngle);
                            traceArc.End.X   = temp.X;
                            traceArc.End.Y   = temp.Y;
                        }
                    }
                }
                else if (cmdLine is SymbolLinesCmdLine)
                {
                    SymbolLinesCmdLine symbolLinesCmdLine = cmdLine as SymbolLinesCmdLine;
                    PointD             temp = new PointD();
                    double             r    = this.symbolLine1.GetPrm();
                    foreach (var item in symbolLinesCmdLine.Symbols)
                    {
                        item.transitionR = r;
                        if (item.symbolType == SymbolType.Line)
                        {
                            temp = GetNewPosition(item.symbolPoints[0], referencePoint, offsetX, offsetY, rotateAngle);
                            item.symbolPoints[0].X = temp.X;
                            item.symbolPoints[0].Y = temp.Y;
                            temp = GetNewPosition(item.symbolPoints[1], referencePoint, offsetX, offsetY, rotateAngle);
                            item.symbolPoints[1].X = temp.X;
                            item.symbolPoints[1].Y = temp.Y;
                        }
                        else if (item.symbolType == SymbolType.Arc)
                        {
                            temp = GetNewPosition(item.symbolPoints[0], referencePoint, offsetX, offsetY, rotateAngle);
                            item.symbolPoints[0].X = temp.X;
                            item.symbolPoints[0].Y = temp.Y;
                            temp = GetNewPosition(item.symbolPoints[1], referencePoint, offsetX, offsetY, rotateAngle);
                            item.symbolPoints[1].X = temp.X;
                            item.symbolPoints[1].Y = temp.Y;
                            temp = GetNewPosition(item.symbolPoints[2], referencePoint, offsetX, offsetY, rotateAngle);
                            item.symbolPoints[2].X = temp.X;
                            item.symbolPoints[2].Y = temp.Y;
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 获取第一点轨迹和第一个线轨迹的参数类型
        /// </summary>
        private void GetSymbolParamType()
        {
            //只批量修改和选中的第一条轨迹相同类型的轨迹
            int index = 0;

            foreach (CmdLine cmdLine in this.updateCmdLines)
            {
                if (!lineParamGet)
                {
                    if (cmdLine is CircleCmdLine)
                    {
                        CircleCmdLine temp = cmdLine as CircleCmdLine;
                        this.cmdLineType = (int)temp.LineStyle;
                        if (index == 0)
                        {
                            this.weightControlType = temp.IsWeightControl;
                        }
                        lineParamGet = true;
                    }
                    else if (cmdLine is ArcCmdLine)
                    {
                        ArcCmdLine temp = cmdLine as ArcCmdLine;
                        this.cmdLineType = (int)temp.LineStyle;
                        if (index == 0)
                        {
                            this.weightControlType = temp.IsWeightControl;
                        }
                        lineParamGet = true;
                    }
                    else if (cmdLine is SnakeLineCmdLine)
                    {
                        SnakeLineCmdLine temp = cmdLine as SnakeLineCmdLine;
                        this.cmdLineType = (int)temp.LineStyle;
                        if (index == 0)
                        {
                            this.weightControlType = temp.IsWeightControl;
                        }
                        lineParamGet = true;
                    }
                    else if (cmdLine is LineCmdLine)
                    {
                        LineCmdLine temp = cmdLine as LineCmdLine;
                        this.cmdLineType = (int)temp.LineStyle;
                        if (index == 0)
                        {
                            this.weightControlType = temp.IsWeightControl;
                        }
                        lineParamGet = true;
                    }
                }

                if (!dotParamGet)
                {
                    if (cmdLine is DotCmdLine)
                    {
                        DotCmdLine temp = cmdLine as DotCmdLine;
                        this.cmdDotType = (int)temp.DotStyle;
                        if (index == 0)
                        {
                            this.weightControlType = temp.IsWeightControl;
                        }
                        dotParamGet = true;
                    }
                }
                index++;
                //第一个点和第一个线的参数都获取后,停止循环
                if (lineParamGet && dotParamGet)
                {
                    break;
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Author: liyi
        /// Date: 2019/08/20
        /// Description: 判断是否所有轨迹是否都是胶量模式、是否所有参数类型
        /// </summary>
        private void GetSameProperty()
        {
            foreach (CmdLine cmdLine in this.updateCmdLines)
            {
                if (this.cmdLineTypeIsSame)
                {
                    if (cmdLine is CircleCmdLine)
                    {
                        CircleCmdLine temp = cmdLine as CircleCmdLine;
                        if (temp.IsWeightControl != this.weightControlType)
                        {
                            this.WeightControlTypeIsSame = false;
                        }
                        if (this.cmdLineType != (int)temp.LineStyle)
                        {
                            this.cmdLineTypeIsSame = false;
                        }
                    }
                    else if (cmdLine is ArcCmdLine)
                    {
                        ArcCmdLine temp = cmdLine as ArcCmdLine;
                        if (temp.IsWeightControl != this.weightControlType)
                        {
                            this.WeightControlTypeIsSame = false;
                        }
                        if (this.cmdLineType != (int)temp.LineStyle)
                        {
                            this.cmdLineTypeIsSame = false;
                        }
                    }
                    else if (cmdLine is SnakeLineCmdLine)
                    {
                        SnakeLineCmdLine temp = cmdLine as SnakeLineCmdLine;
                        if (temp.IsWeightControl != this.weightControlType)
                        {
                            this.WeightControlTypeIsSame = false;
                        }
                        if (this.cmdLineType != (int)temp.LineStyle)
                        {
                            this.cmdDotTypeIsSame = false;
                        }
                    }
                    else if (cmdLine is LineCmdLine)
                    {
                        LineCmdLine temp = cmdLine as LineCmdLine;
                        if (temp.IsWeightControl != this.weightControlType)
                        {
                            this.WeightControlTypeIsSame = false;
                        }
                        if (this.cmdLineType != (int)temp.LineStyle)
                        {
                            this.cmdLineTypeIsSame = false;
                        }
                    }
                }
                if (this.cmdDotTypeIsSame)
                {
                    if (cmdLine is DotCmdLine)
                    {
                        DotCmdLine temp = cmdLine as DotCmdLine;
                        if (temp.IsWeightControl != this.weightControlType)
                        {
                            this.WeightControlTypeIsSame = false;
                        }
                        if (this.cmdDotType != (int)temp.DotStyle)
                        {
                            this.cmdDotTypeIsSame = false;
                        }
                    }
                }

                if ((!this.cmdDotTypeIsSame || !this.dotParamGet) && (!this.cmdLineTypeIsSame || !this.lineParamGet) && !this.WeightControlTypeIsSame)
                {
                    break;
                }
            }
        }
Exemplo n.º 6
0
        public EditArcForm1(Pattern pattern, ArcCmdLine arcCmdLine) : base(pattern.GetOriginPos())
        {
            InitializeComponent();
            this.pattern    = pattern;
            this.origin     = pattern.GetOriginPos();
            this.arcCmdLine = arcCmdLine;
            isCreating      = arcCmdLine == null;
            if (isCreating)
            {
                this.arcCmdLine = new ArcCmdLine();

                this.arcCmdLine.Start.X         = Properties.Settings.Default.ArcStartX;
                this.arcCmdLine.Start.Y         = Properties.Settings.Default.ArcStartY;
                this.arcCmdLine.Middle.X        = Properties.Settings.Default.ArcMidX;
                this.arcCmdLine.Middle.Y        = Properties.Settings.Default.ArcMidY;
                this.arcCmdLine.End.X           = Properties.Settings.Default.ArcEndX;
                this.arcCmdLine.End.Y           = Properties.Settings.Default.ArcEndY;
                this.arcCmdLine.Center.X        = Properties.Settings.Default.ArcCenterX;
                this.arcCmdLine.Center.Y        = Properties.Settings.Default.ArcCenterY;
                this.arcCmdLine.Degree          = Properties.Settings.Default.ArcDegree;
                this.arcCmdLine.LineStyle       = (LineStyle)Properties.Settings.Default.ArcLineStyle;
                this.arcCmdLine.IsWeightControl = Properties.Settings.Default.ArcIsWt;
                this.arcCmdLine.Weight          = Properties.Settings.Default.ArcWt;
                this.btnLastCmdLine.Visible     = false;
                this.btnNextCmdLine.Visible     = false;
            }
            start.X  = this.arcCmdLine.Start.X;
            start.Y  = this.arcCmdLine.Start.Y;
            middle.X = this.arcCmdLine.Middle.X;
            middle.Y = this.arcCmdLine.Middle.Y;
            end.X    = this.arcCmdLine.End.X;
            end.Y    = this.arcCmdLine.End.Y;
            center.X = this.arcCmdLine.Center.X;
            center.Y = this.arcCmdLine.Center.Y;
            degree   = this.arcCmdLine.Degree;
            //系统坐标->机械坐标
            PointD pS = this.pattern.MachineRel(start);
            PointD pM = this.pattern.MachineRel(middle);
            PointD pE = this.pattern.MachineRel(end);
            PointD pC = this.pattern.MachineRel(center);

            // 设置UI数据显示
            rbSME.Checked  = true; // default
            tbStartX.Text  = pS.X.ToString("0.000");
            tbStartY.Text  = pS.Y.ToString("0.000");
            tbMiddleX.Text = pM.X.ToString("0.000");
            tbMiddleY.Text = pM.Y.ToString("0.000");
            tbEndX.Text    = pE.X.ToString("0.000");
            tbEndY.Text    = pE.Y.ToString("0.000");
            tbCenterX.Text = pC.X.ToString("0.000");
            tbCenterY.Text = pC.Y.ToString("0.000");
            tbDegree.Text  = degree.ToString("0.000");
            for (int i = 0; i < FluidProgram.Current.ProgramSettings.LineParamList.Count; i++)
            {
                comboBoxLineType.Items.Add("Type " + (i + 1));
            }
            comboBoxLineType.SelectedIndex = (int)this.arcCmdLine.LineStyle;
            cbWeightControl.Checked        = this.arcCmdLine.IsWeightControl;
            tbWeight.Text = this.arcCmdLine.Weight.ToString("0.000");
            if (this.arcCmdLine != null)
            {
                this.arcCmdLineBackUp = (ArcCmdLine)this.arcCmdLine.Clone();
            }
            this.ReadLanguageResources();
        }
Exemplo n.º 7
0
        /// <summary>
        /// 将程序指令解析为绘图指令,添加到绘图workpiece或者pattern中
        /// </summary>
        /// <param name="cmdLine"></param>
        /// <param name="pattern"></param>
        private void Parse(CmdLine cmdLine, DrawPattern pattern)
        {
            if (cmdLine is ArcCmdLine)
            {
                ArcCmdLine arc            = cmdLine as ArcCmdLine;
                PointF     centerPosition = new PointF((float)arc.Center.X, (float)arc.Center.Y);
                PointF     startPosition  = new PointF((float)arc.Start.X, (float)arc.Start.Y);
                PointF     endPosition    = new PointF((float)arc.End.X, (float)arc.End.Y);
                float      degree         = (float)arc.Degree;
                ArcDrawCmd arcDrawCmd     = new ArcDrawCmd(centerPosition, startPosition, endPosition, degree, arc.Enabled);
                pattern.Add(arcDrawCmd);
            }
            //如果是DoPattern指令
            else if (cmdLine is DoCmdLine)
            {
                if (this._drawPatterns.Count <= 0)
                {
                    pattern.Add(null);
                }
                else if (pattern.GetType().Equals(typeof(DrawWorkPiece)))
                {
                    DoCmdLine doPattern = cmdLine as DoCmdLine;

                    //判断是paternList里的哪一个pattern
                    int index = 0;
                    for (int i = 0; i < fluidProgram.Patterns.Count; i++)
                    {
                        if (fluidProgram.Patterns[i].Name.Equals(doPattern.PatternName))
                        {
                            index = i;
                        }
                    }
                    PointF           origin           = new PointF((float)doPattern.Origin.X, (float)doPattern.Origin.Y);
                    DoPatternDrawCmd doPatternDrawCmd = new DoPatternDrawCmd(this._drawPatterns[index], origin, doPattern.Enabled);

                    pattern.Add(doPatternDrawCmd);
                }
                else
                {
                    pattern.Add(null);
                }
            }
            else if (cmdLine is StepAndRepeatCmdLine)
            {
                if (pattern.GetType().Equals(typeof(DrawWorkPiece)))
                {
                    StepAndRepeatCmdLine array = cmdLine as StepAndRepeatCmdLine;

                    //判断是paternList里的哪一个pattern
                    int index = 0;
                    for (int i = 0; i < fluidProgram.Patterns.Count; i++)
                    {
                        if (fluidProgram.Patterns[i].Name.Equals(array.PatternName))
                        {
                            index = i;
                        }
                    }
                    PointF[] points = new PointF[array.DoCmdLineList.Count];
                    for (int i = 0; i < array.DoCmdLineList.Count; i++)
                    {
                        points[i] = new PointF((float)array.DoCmdLineList[i].Origin.X, (float)array.DoCmdLineList[i].Origin.Y);
                    }

                    ArrayDrawCmd arrayDrawCmd = new ArrayDrawCmd(this._drawPatterns[index], points, array.Enabled);

                    pattern.Add(arrayDrawCmd);
                }
                else
                {
                    pattern.Add(null);
                }
            }
            else if (cmdLine is CircleCmdLine)
            {
                CircleCmdLine circle         = cmdLine as CircleCmdLine;
                PointF        centerPosition = new PointF((float)circle.Center.X, (float)circle.Center.Y);
                float         radius         = (float)Math.Sqrt(Math.Pow(Math.Abs(circle.Start.X - circle.Center.X), 2) + Math.Pow(Math.Abs(circle.Start.Y - circle.Center.Y), 2));
                CircleDrawCmd circleDrawCmd  = new CircleDrawCmd(centerPosition, radius, circle.Enabled);

                pattern.Add(circleDrawCmd);
            }
            else if (cmdLine is DoMultiPassCmdLine)
            {
                if (pattern.GetType().Equals(typeof(DrawWorkPiece)))
                {
                    DoMultiPassCmdLine doMultiPass = cmdLine as DoMultiPassCmdLine;

                    //判断是paternList里的哪一个pattern
                    int index = 0;
                    for (int i = 0; i < fluidProgram.Patterns.Count; i++)
                    {
                        if (fluidProgram.Patterns[i].Name.Equals(doMultiPass.PatternName))
                        {
                            index = i;
                        }
                    }

                    PointF             position       = new PointF((float)doMultiPass.Origin.X, (float)doMultiPass.Origin.Y);
                    DoMultiPassDrawCmd doMultiDrawCmd = new DoMultiPassDrawCmd(this._drawPatterns[index], position, doMultiPass.Enabled);

                    pattern.Add(doMultiDrawCmd);
                }
                else
                {
                    pattern.Add(null);
                }
            }
            else if (cmdLine is DotCmdLine)
            {
                DotCmdLine dot            = cmdLine as DotCmdLine;
                PointF     centerPosition = new PointF((float)dot.Position.X, (float)dot.Position.Y);
                DotDrawCmd dotDrawCmd     = new DotDrawCmd(centerPosition, dot.Enabled);

                pattern.Add(dotDrawCmd);
            }
            else if (cmdLine is MeasureHeightCmdLine)
            {
                MeasureHeightCmdLine height = cmdLine as MeasureHeightCmdLine;
                PointF        position      = new PointF((float)height.Position.X, (float)height.Position.Y);
                HeightDrawCmd heightDrawCmd = new HeightDrawCmd(position, height.Enabled);

                pattern.Add(heightDrawCmd);
            }
            ///包含line、lines和polyline
            else if (cmdLine is LineCmdLine)
            {
                LineCmdLine line       = cmdLine as LineCmdLine;
                int         jointCount = 0;
                if (line.LineCoordinateList.Count == 1)
                {
                    PointF      startPoint  = new PointF((float)line.LineCoordinateList[0].Start.X, (float)line.LineCoordinateList[0].Start.Y);
                    PointF      endPoint    = new PointF((float)line.LineCoordinateList[0].End.X, (float)line.LineCoordinateList[0].End.Y);
                    LineDrawCmd lineDrawCmd = new LineDrawCmd(startPoint, endPoint, true, line.Enabled);

                    pattern.Add(lineDrawCmd);
                }
                else if (line.LineCoordinateList.Count > 1)
                {
                    Line2Points[] lines = new Line2Points[line.LineCoordinateList.Count];

                    for (int i = 0; i < line.LineCoordinateList.Count; i++)
                    {
                        PointF startPoint = new PointF((float)line.LineCoordinateList[i].Start.X, (float)line.LineCoordinateList[i].Start.Y);
                        PointF endPoint   = new PointF((float)line.LineCoordinateList[i].End.X, (float)line.LineCoordinateList[i].End.Y);
                        lines[i] = new Line2Points(startPoint, endPoint);

                        //判断是不是polyline(如果所有相邻线段首尾点一致,则为polyline)
                        if (i > 0 && lines[i].StartPoint == lines[i - 1].EndPoint)
                        {
                            jointCount++;
                        }
                    }

                    //如果是polyline
                    if (jointCount == line.LineCoordinateList.Count - 1)
                    {
                        PointF[] points = new PointF[line.LineCoordinateList.Count + 1];
                        for (int i = 0; i < lines.Length + 1; i++)
                        {
                            if (i == 0)
                            {
                                points[i] = new PointF((float)lines[0].StartPoint.X, (float)lines[0].StartPoint.Y);
                            }
                            else
                            {
                                points[i] = new PointF((float)lines[i - 1].EndPoint.X, (float)lines[i - 1].EndPoint.Y);
                            }
                        }
                        PolyLineDrawCmd polyLineDrawCmd = new PolyLineDrawCmd(points, line.Enabled);
                        pattern.Add(polyLineDrawCmd);
                    }
                    //如果是lines
                    else
                    {
                        LinesDrawCmd linesDrawCmd = new LinesDrawCmd(lines, true, line.Enabled);
                        pattern.Add(linesDrawCmd);
                    }
                }
            }

            else if (cmdLine is MarkCmdLine)
            {
                MarkCmdLine mark        = cmdLine as MarkCmdLine;
                PointF      position    = new PointF((float)mark.PosInPattern.X, (float)mark.PosInPattern.Y);
                MarkDrawCmd markDrawCmd = new MarkDrawCmd(position, mark.Enabled, MarkType.NormalMark);

                pattern.Add(markDrawCmd);
            }

            else if (cmdLine is BadMarkCmdLine)
            {
                BadMarkCmdLine mark        = cmdLine as BadMarkCmdLine;
                PointF         position    = new PointF((float)mark.Position.X, (float)mark.Position.Y);
                MarkDrawCmd    markDrawCmd = new MarkDrawCmd(position, mark.Enabled, MarkType.BadMark);

                pattern.Add(markDrawCmd);
            }

            else if (cmdLine is NozzleCheckCmdLine)
            {
                NozzleCheckCmdLine mark        = cmdLine as NozzleCheckCmdLine;
                PointF             position    = new PointF((float)mark.Position.X, (float)mark.Position.Y);
                MarkDrawCmd        markDrawCmd = new MarkDrawCmd(position, mark.Enabled, MarkType.CheckDotMark);

                pattern.Add(markDrawCmd);
            }

            else if (cmdLine is SnakeLineCmdLine)
            {
                SnakeLineCmdLine snake = cmdLine as SnakeLineCmdLine;

                Line2Points[] lines = new Line2Points[snake.LineCoordinateList.Count];
                for (int i = 0; i < snake.LineCoordinateList.Count; i++)
                {
                    PointF startPoint = new PointF((float)snake.LineCoordinateList[i].Start.X, (float)snake.LineCoordinateList[i].Start.Y);
                    PointF endPoint   = new PointF((float)snake.LineCoordinateList[i].End.X, (float)snake.LineCoordinateList[i].End.Y);
                    lines[i] = new Line2Points(startPoint, endPoint);
                }

                SnakeLineDrawCmd snakeLineDrawCmd = new SnakeLineDrawCmd(lines, true, snake.Enabled);

                pattern.Add(snakeLineDrawCmd);
            }
            else if (cmdLine is SymbolLinesCmdLine)
            {
                SymbolLinesCmdLine symbolLines = cmdLine as SymbolLinesCmdLine;

                SymbolLinesDrawCmd symbolLinesDrawCmd = new SymbolLinesDrawCmd(symbolLines.Symbols, symbolLines.Enabled);

                pattern.Add(symbolLinesDrawCmd);
            }
            else if (cmdLine is MultiTracesCmdLine)
            {
                MultiTracesCmdLine tracesCmdLine = cmdLine as MultiTracesCmdLine;
                MultiTracesDrawCmd tracesDrawCmd = new MultiTracesDrawCmd(tracesCmdLine.Traces, tracesCmdLine.Enabled);
                pattern.Add(tracesDrawCmd);
            }

            //如果是别的逻辑指令,为了保证和程序指令一致性,添加一个null进去
            else
            {
                pattern.Add(null);
            }
        }