Exemplo n.º 1
0
        /// <summary>
        /// 根据分段函数来计算,怕了吧~
        /// </summary>
        /// <param name="value"></param>
        private void CalXY(float value)
        {
            double y     = 0;
            int    count = Program.SysConfig.LaserConfig.HolePulsePoints.Count;
            var    x     = value;

            if (x == Program.SysConfig.LaserConfig.HolePulsePoints[0].X)
            {
                y = Program.SysConfig.LaserConfig.HolePulsePoints[0].Y;
            }
            else if (x == Program.SysConfig.LaserConfig.HolePulsePoints[count - 1].X)
            {
                y = Program.SysConfig.LaserConfig.HolePulsePoints[count - 1].Y;
            }
            else if (x > Program.SysConfig.LaserConfig.HolePulsePoints[0].X && x < Program.SysConfig.LaserConfig.HolePulsePoints[count - 1].X)
            {
                for (int i = 0; i < Program.SysConfig.LaserConfig.HolePulsePoints.Count; i++)
                {
                    if (x > Program.SysConfig.LaserConfig.HolePulsePoints[i].X && x < Program.SysConfig.LaserConfig.HolePulsePoints[i + 1].X)
                    {
                        double k = (Program.SysConfig.LaserConfig.HolePulsePoints[i + 1].Y - Program.SysConfig.LaserConfig.HolePulsePoints[i].Y) / (Program.SysConfig.LaserConfig.HolePulsePoints[i + 1].X - Program.SysConfig.LaserConfig.HolePulsePoints[i].X);
                        y = k * (value - Program.SysConfig.LaserConfig.HolePulsePoints[i].X) + Program.SysConfig.LaserConfig.HolePulsePoints[i].Y;
                        break;
                    }
                }
            }
            CurrentPoint = new HolePulsePoint(x, (float)y);
        }
Exemplo n.º 2
0
        private void UpdownClickHandler(bool isUp)
        {
            bool exist = CheckPoint(CurrentPoint);
            var  value = isUp ? CurrentPoint.Y + 0.2f : CurrentPoint.Y - 0.2f;

            //if (value < 0) return;
            if (!CheckPointValidate(new HolePulsePoint(CurrentPoint.X, value), exist))
            {
                return;
            }
            SaveDeleteButtonVisiable(true);
            CurrentPoint = new HolePulsePoint(CurrentPoint.X, value);
            if (exist)
            {
                UpdatePoint(CurrentPoint);
            }
            else
            {
                AddPoint(CurrentPoint);
            }
            if (this.graphicsProperties != null)
            {
                Program.SysConfig.LaserConfig.UpdatePulseWidth(CurrentPoint.Y);
            }
        }
Exemplo n.º 3
0
 private void AddPoint(HolePulsePoint point)
 {
     if (holePulsePoints != null)
     {
         holePulsePoints.Add(point);
         CalPiecewiseFunction();
     }
 }
Exemplo n.º 4
0
 private void AddPoint(HolePulsePoint point)
 {
     if (Program.SysConfig.LaserConfig.HolePulsePoints != null)
     {
         Program.SysConfig.LaserConfig.HolePulsePoints.Add(point);
         CalPiecewiseFunction();
     }
 }
Exemplo n.º 5
0
        private double CalSlopeFunction(HolePulsePoint p1, HolePulsePoint p2, double value)
        {
            double k      = 0;
            double deltaX = p2.X - p1.X;
            double deltaY = p2.Y - p1.Y;

            k = deltaY / deltaX;
            //var x = value;
            return(k * (value - p2.X) + p2.Y);
        }
Exemplo n.º 6
0
 private void CalXY(float value)
 {
     for (int i = 0; i < holePulsePoints.Count - 1; i++)
     {
         var    x = value;
         double k = (holePulsePoints[i + 1].Y - holePulsePoints[i].Y) / (holePulsePoints[i + 1].X - holePulsePoints[i].X);
         var    y = k * (value - holePulsePoints[i].X) + holePulsePoints[i].Y;
         CurrentPoint = new HolePulsePoint(x, (float)y);
     }
 }
Exemplo n.º 7
0
        private double CalSlopeFunction(HolePulsePoint p1, HolePulsePoint p2, int value)
        {
            double k = 0;

            k = (p2.Y - p1.Y) / (p2.X - p1.X);
            int startX = (int)(p1.X * 1000);
            int endX   = (int)(p2.X * 1000);
            var x      = value / 1000d;

            return(k * (x - p2.X) + p2.Y);
        }
Exemplo n.º 8
0
 private void UpdatePoint(HolePulsePoint point)
 {
     if (Program.SysConfig.LaserConfig.HolePulsePoints != null && Program.SysConfig.LaserConfig.HolePulsePoints.Count > 0)
     {
         for (int i = 0; i < Program.SysConfig.LaserConfig.HolePulsePoints.Count; i++)
         {
             if (Program.SysConfig.LaserConfig.HolePulsePoints[i].X == point.X)
             {
                 Program.SysConfig.LaserConfig.HolePulsePoints[i].Y = point.Y;
             }
         }
         CalPiecewiseFunction();
     }
 }
Exemplo n.º 9
0
 private void RemovePoint(HolePulsePoint point)
 {
     if (Program.SysConfig.LaserConfig.HolePulsePoints != null)
     {
         for (int i = 0; i < Program.SysConfig.LaserConfig.HolePulsePoints.Count; i++)
         {
             if (Program.SysConfig.LaserConfig.HolePulsePoints[i].X == point.X)
             {
                 Program.SysConfig.LaserConfig.HolePulsePoints.Remove(Program.SysConfig.LaserConfig.HolePulsePoints[i]);
             }
         }
         CalPiecewiseFunction();
     }
 }
Exemplo n.º 10
0
 private void UpdatePoint(HolePulsePoint point)
 {
     if (holePulsePoints != null && holePulsePoints.Count > 0)
     {
         for (int i = 0; i < holePulsePoints.Count; i++)
         {
             if (holePulsePoints[i].X == point.X)
             {
                 holePulsePoints[i].Y = point.Y;
             }
         }
         CalPiecewiseFunction();
     }
 }
Exemplo n.º 11
0
 private void RemovePoint(HolePulsePoint point)
 {
     if (holePulsePoints != null)
     {
         for (int i = 0; i < holePulsePoints.Count; i++)
         {
             if (holePulsePoints[i].X == point.X)
             {
                 holePulsePoints.Remove(holePulsePoints[i]);
             }
         }
         CalPiecewiseFunction();
     }
 }
Exemplo n.º 12
0
        private bool CheckPoint(HolePulsePoint point)
        {
            bool exist = false;

            if (holePulsePoints != null && holePulsePoints.Count > 0)
            {
                for (int i = 0; i < holePulsePoints.Count; i++)
                {
                    if (holePulsePoints[i].X == point.X)
                    {
                        exist = true;
                    }
                }
            }
            return(exist);
        }
Exemplo n.º 13
0
 private void UpdownClickHandler(bool isUp)
 {
     SaveDeleteButtonVisiable(true);
     CurrentPoint = new HolePulsePoint(CurrentPoint.X, isUp ? CurrentPoint.Y + 0.2f : CurrentPoint.Y - 0.2f);
     if (CheckPoint(CurrentPoint))
     {
         UpdatePoint(CurrentPoint);
     }
     else
     {
         AddPoint(CurrentPoint);
     }
     if (this.graphicsProperties != null)
     {
         SysConfig.GetSysConfig().LaserConfig.UpdatePulseWidth(CurrentPoint.Y);
     }
 }
Exemplo n.º 14
0
        /// <summary>
        /// 验证微调点的有效性
        /// </summary>
        /// <param name="point"></param>
        /// <param name="exist"></param>
        /// <returns></returns>
        private bool CheckPointValidate(HolePulsePoint point, bool exist)
        {
            bool validate = false;

            if (exist)
            {
                if (Program.SysConfig.LaserConfig.HolePulsePoints != null && Program.SysConfig.LaserConfig.HolePulsePoints.Count > 0)
                {
                    int index = Program.SysConfig.LaserConfig.HolePulsePoints.FindIndex(p => p.X == point.X);
                    if (index == Program.SysConfig.LaserConfig.HolePulsePoints.Count - 1)
                    {
                        if (point.Y < Program.SysConfig.LaserConfig.HolePulsePoints[index].Y)
                        {
                            validate = true;
                        }
                    }
                    else if (index > 0 && index < Program.SysConfig.LaserConfig.HolePulsePoints.Count - 1)
                    {
                        if (point.Y > Program.SysConfig.LaserConfig.HolePulsePoints[index - 1].Y && point.Y < Program.SysConfig.LaserConfig.HolePulsePoints[index + 1].Y)
                        {
                            validate = true;
                        }
                    }
                    else
                    {
                        validate = point.Y > 0.01 && point.Y < 33;
                    }
                }
            }
            else
            {
                if (Program.SysConfig.LaserConfig.HolePulsePoints != null && Program.SysConfig.LaserConfig.HolePulsePoints.Count > 0)
                {
                    for (int i = 0; i < Program.SysConfig.LaserConfig.HolePulsePoints.Count; i++)
                    {
                        if (point.X > Program.SysConfig.LaserConfig.HolePulsePoints[i].X && point.X < Program.SysConfig.LaserConfig.HolePulsePoints[i + 1].X)
                        {
                            validate = point.Y > Program.SysConfig.LaserConfig.HolePulsePoints[i].Y && point.Y < Program.SysConfig.LaserConfig.HolePulsePoints[i + 1].Y;
                        }
                    }
                }
            }
            return(validate);
        }
Exemplo n.º 15
0
        private bool CheckPoint(HolePulsePoint point)
        {
            bool exist = false;

            if (point != null)
            {
                if (Program.SysConfig.LaserConfig.HolePulsePoints != null && Program.SysConfig.LaserConfig.HolePulsePoints.Count > 0)
                {
                    for (int i = 0; i < Program.SysConfig.LaserConfig.HolePulsePoints.Count; i++)
                    {
                        if (Program.SysConfig.LaserConfig.HolePulsePoints[i].X == point.X)
                        {
                            exist = true;
                        }
                    }
                }
            }
            return(exist);
        }
Exemplo n.º 16
0
 private void chart1_MouseUp(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left && findPoint)
     {
         var dataPoints = this.chart1.Series[0].Points;
         if (dataPoints != null && dataPoints.Count > 0)
         {
             for (int i = 0; i < dataPoints.Count; i++)
             {
                 if (Math.Abs(valueToFindX - dataPoints[i].XValue) < 0.01)
                 {
                     dataPoints[i].MarkerStyle = MarkerStyle.Circle;
                     dataPoints[i].MarkerColor = Color.Red;
                     dataPoints[i].MarkerSize  = 10;
                     CurrentPoint = new HolePulsePoint((float)dataPoints[i].XValue, (float)dataPoints[i].YValues[0]);
                     int index = Program.SysConfig.LaserConfig.HolePulsePoints.FindIndex(p => p.X == CurrentPoint.X);
                     if (index != 0 && index != Program.SysConfig.LaserConfig.HolePulsePoints.Count - 1)
                     {
                         SaveDeleteButtonVisiable(true);
                     }
                     this.sliderPulse.Update = false;
                     this.sliderPulse.SetValue(CurrentPoint.X);
                     if (this.graphicsProperties != null)
                     {
                         Program.SysConfig.LaserConfig.UpdatePulseWidth(CurrentPoint.Y);
                     }
                     UpdateSliderValueHandler?.Invoke(CurrentPoint.X);
                     this.sliderPulse.Update = true;
                 }
                 else
                 {
                     dataPoints[i].MarkerSize  = 10;
                     dataPoints[i].MarkerColor = Color.DarkGreen;
                 }
             }
             this.chart1.Invalidate();
         }
     }
 }
Exemplo n.º 17
0
 private void CalSlopeFunction(HolePulsePoint p1, HolePulsePoint p2)
 {
     this.chart1.Series[0].Points.AddXY(p1.X, p1.Y);
     this.chart1.Series[0].Points.AddXY(p2.X, p2.Y);
 }