示例#1
0
        private List <RobotPoint> insertCenterPoing(List <RobotPoint> _plist)
        {
            List <RobotPoint> result = new List <RobotPoint>();
            int len = _plist.Count;

            for (int i = 0; i < len; i++)
            {
                if (i == 0)
                {
                    result.Add(_plist[i]);
                    continue;
                }
                PointF pointf1 = new PointF(_plist[i - 1].bx, _plist[i - 1].by);
                PointF pointf2 = new PointF(_plist[i].bx, _plist[i].by);
                PointF pointf3 = new PointF();

                getCenterPoint(ref pointf1, ref pointf2, ref pointf3);

                float twidth = (_plist[i - 1].bWidth + _plist[i].bWidth) / 2;

                RobotPoint Point_t = new RobotPoint()
                {
                    bx         = pointf3.X,
                    by         = pointf3.Y,
                    bPenStatus = _plist[i].bPenStatus,
                    bWidth     = twidth,
                    bIndex     = -100,
                    isOptimize = true,
                };
                result.Add(Point_t);
                result.Add(_plist[i]);
            }
            return(result);
        }
示例#2
0
        // 接收到优化后的数据点数据
        public void recvOptimizeData(int nPenStatus, float x, float y, float fPenWidth)
        {
            RobotPoint nowPoint = new RobotPoint()
            {
                bx         = x,
                by         = y,
                bPenStatus = nPenStatus,
                bWidth     = fPenWidth,
                bIndex     = plist.Count() + 1,
                isOptimize = true,
            };

            if (fPenSize < 0)
            {
                return;
            }
            PointF pointf = new PointF(x, y);

            if (!pointIsInvalid(nPenStatus, ref pointf))
            {
                return;
            }

            if (fPenWidth == 0)  // 笔离开到板子
            {
                if (nFlags == 1)
                {
                    plist.Add(nowPoint);
                    if (DrawingCallbackBrushstroke_Evt != null)
                    {
                        DrawingCallbackBrushstroke_Evt(plist);
                        plist.Clear();
                    }

                    //if (Math.Abs(nowPoint.bWidth - lastPoint.bWidth) > 0.1)
                    //{
                    //    int t = (int)((nowPoint.bWidth - lastPoint.bWidth) / 0.1);

                    //    List<RobotPoint> _CheckList = new List<RobotPoint>();
                    //    _CheckList.Add(lastPoint);
                    //    _CheckList.Add(nowPoint);

                    //    for (int i = 0; i < t - 1; i++)
                    //    {
                    //        _CheckList = insertCenterPoing(_CheckList);
                    //    }
                    //    _CheckList.Remove(_CheckList[0]);
                    //    foreach (var item in _CheckList)
                    //    {
                    //        PointF fC = new PointF(item.bx, item.by);

                    //        compressPoint(ref fC);
                    //        onTrackDrawBezier(ref fC, item.bWidth);
                    //    }
                    //    onEndDrawBezier();
                    //}
                    //else
                    //{
                    //    onEndDrawBezier();
                    //}


                    //else
                    onEndDrawBezier();
                    lastPoint = new RobotPoint();
                    nFlags    = 0;
                }
            }
            else
            {
                plist.Add(nowPoint);
                if (nFlags == 0)
                {
                    nFlags = 1;
                    compressPoint(ref pointf);
                    onBeginDrawBezier(ref pointf, fPenWidth);
                }
                else
                {
                    //if (Math.Abs(nowPoint.bWidth - lastPoint.bWidth) > 0.1)
                    //{
                    //    int t = (int)((nowPoint.bWidth - lastPoint.bWidth) / 0.1);

                    //    List<RobotPoint> _CheckList = new List<RobotPoint>();
                    //    _CheckList.Add(lastPoint);
                    //    _CheckList.Add(nowPoint);

                    //    for (int i = 0; i < t - 1; i++)
                    //    {
                    //        _CheckList = insertCenterPoing(_CheckList);
                    //    }
                    //    _CheckList.Remove(_CheckList[0]);
                    //    foreach (var item in _CheckList)
                    //    {
                    //        PointF fC = new PointF(item.bx, item.by);

                    //        compressPoint(ref fC);
                    //        onTrackDrawBezier(ref fC, item.bWidth);
                    //    }
                    //}
                    //else
                    //{
                    //    compressPoint(ref pointf);
                    //    onTrackDrawBezier(ref pointf, fPenWidth);
                    //}
                    compressPoint(ref pointf);
                    onTrackDrawBezier(ref pointf, fPenWidth);
                }
            }
            lastPoint = nowPoint;
        }