示例#1
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            if (this.listBoxPoints.SelectedIndex < 0)
            {
                return;
            }
            PointTrace pointTrace = pointsCache[this.listBoxPoints.SelectedIndex];

            if (pointTrace.PointType != TracePointType.End)
            {
                return;
            }

            int index = this.listBoxPoints.SelectedIndex;

            PointTrace pointPrev = pointsCache[this.listBoxPoints.SelectedIndex - 1];
            PointD     newPoint  = (Machine.Instance.Robot.PosXY - origin).ToPoint();
            TraceBase  trace     = this.tracesCache[pointTrace.TraceIndex];

            TraceBase tracePrev;

            if (pointTrace.TraceIndex == 0)
            {
                tracePrev = null;
            }
            else
            {
                tracePrev = this.tracesCache[pointTrace.TraceIndex - 1];
            }

            if (this.rbLine.Checked)
            {
                trace.Start = newPoint.Clone() as PointD;
                TraceLine line;
                if (tracePrev == null)
                {
                    line           = new TraceLine(pointPrev.Point.Clone() as PointD, newPoint.Clone() as PointD);
                    line.LineStyle = trace.LineStyle;
                }
                else
                {
                    line           = new TraceLine(tracePrev.End.Clone() as PointD, newPoint.Clone() as PointD);
                    line.LineStyle = trace.LineStyle;
                }
                this.tracesCache.Insert(pointTrace.TraceIndex, line);
            }
            else
            {
                TraceArc arc = new TraceArc(trace.Start, newPoint, trace.End);
                arc.LineStyle = trace.LineStyle;
                this.tracesCache[pointTrace.TraceIndex] = arc;
            }
            this.updatePointsCache();
            this.LoadLines2ListBox();
            this.LoadPoints2ListBox();

            this.listBoxPoints.SelectedIndex = index + 1;
        }
示例#2
0
        private void btnReTeach_Click(object sender, EventArgs e)
        {
            if (this.listBoxPoints.SelectedIndex < 0 || this.listBoxPoints.Items.Count == 0)
            {
                return;
            }

            int index = this.listBoxPoints.SelectedIndex;

            PointTrace selectedPointTrace = this.pointsCache[this.listBoxPoints.SelectedIndex];
            PointD     p = pattern.SystemRel(Machine.Instance.Robot.PosX - origin.X, Machine.Instance.Robot.PosY - origin.Y);

            switch (selectedPointTrace.PointType)
            {
            case TracePointType.Start:
                selectedPointTrace.Trace.Start.X = p.X;
                selectedPointTrace.Trace.Start.Y = p.Y;
                break;

            case TracePointType.Mid:
                (selectedPointTrace.Trace as TraceArc).Mid.X = p.X;
                (selectedPointTrace.Trace as TraceArc).Mid.Y = p.Y;
                break;

            case TracePointType.End:
                selectedPointTrace.Trace.End.X = p.X;
                selectedPointTrace.Trace.End.Y = p.Y;
                if (selectedPointTrace.TraceIndex < this.tracesCache.Count - 1)
                {
                    this.tracesCache[selectedPointTrace.TraceIndex + 1].Start.X = p.X;
                    this.tracesCache[selectedPointTrace.TraceIndex + 1].Start.Y = p.Y;
                }
                break;
            }
            this.LoadLines2ListBox();
            this.LoadPoints2ListBox();

            this.SetListSelected(index);
        }
示例#3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (this.listBoxPoints.SelectedIndex < 0)
            {
                return;
            }
            PointTrace pointTrace = pointsCache[this.listBoxPoints.SelectedIndex];
            TraceBase  trace      = this.tracesCache[pointTrace.TraceIndex];
            TraceBase  traceNext  = null;
            TraceBase  traceNew   = null;

            if (pointTrace.PointType == TracePointType.End)
            {
                // 删除连接点,则同时删除2条相邻轨迹,用一条直线轨迹替代
                if (this.tracesCache.Count - 1 >= pointTrace.TraceIndex + 1)
                {
                    traceNext          = this.tracesCache[pointTrace.TraceIndex + 1];
                    traceNew           = new TraceLine(trace.Start, traceNext.End);
                    traceNew.LineStyle = trace.LineStyle;
                }
                this.tracesCache.Remove(trace);
                if (traceNext != null)
                {
                    this.tracesCache.Remove(traceNext);
                    this.tracesCache.Insert(pointTrace.TraceIndex, traceNew);
                }
            }
            else if (pointTrace.PointType == TracePointType.Mid)
            {
                traceNew           = new TraceLine(trace.Start, trace.End);
                traceNew.LineStyle = trace.LineStyle;
                this.tracesCache.Remove(trace);
                this.tracesCache.Insert(pointTrace.TraceIndex, traceNew);
            }
            this.updatePointsCache();
            this.LoadLines2ListBox();
            this.LoadPoints2ListBox();
        }