コード例 #1
0
 public void clear()
 {
     GraphProcessing.RemoveLine(PARALELL1_NAME, form);
     GraphProcessing.RemoveLine(PARALELL2_NAME, form);
     if (zeroTwoCB.Checked)
     {
         GraphProcessing.RemoveLine(SIGMANZEROTWO, form);
     }
     else
     {
         GraphProcessing.RemoveLine(SIGMANZEROFIVE, form);
     }
 }
コード例 #2
0
        private void accept_Click(object sender, EventArgs e)
        {
            aproximateLinearCurve = null;
            GraphProcessing.RemoveLine(MNK_NAME, form);
            GraphProcessing.RemoveLine(MNK_NAME, form);
            GraphProcessing.RemoveLine(REG_NAME, form);

            GraphProcessing.UpdateGraph(form.ZGCInstance);
            if (form.SelectionCurveBegin != null && form.SelectionCurveEnd != null)
            {
                int index = form.ZGCInstance.GraphPane.CurveList.IndexOf(MNK_NAME);
                if (index >= 0)
                {
                    form.ZGCInstance.GraphPane.CurveList.RemoveAt(index);
                    DynamicToolStripButton tempBtn = null;
                    for (int i = 0; i < form.buttons.Count; i++)
                    {
                        string test = form.buttons[i].curve.Label.Text;
                        if (test == MNK_NAME)
                        {
                            tempBtn = form.buttons[i]; break;
                        }
                    }
                    form.CurvesDropDownButton.DropDownItems.Remove(tempBtn.button); //ошибка
                }


                PointPairList tempPointPair = (PointPairList)form.getCurve.Points;
                double        beginX        = tempPointPair.IndexOf(form.SelectionCurveBegin.Points[0]);
                double        endX          = tempPointPair.IndexOf(form.SelectionCurveEnd.Points[0]);
                int           begin         = (int)Math.Min(beginX, endX);
                int           end           = (int)Math.Max(beginX, endX);
                LineItem      temp          = new LineItem("tempCurve");
                temp.Tag = 5;

                if (form.getCurve != null)
                {
                    if (leastSquaresMode)
                    {
                        for (int i = begin; i < end; i++)
                        {
                            temp.AddPoint(form.getCurve.Points[i]);
                        }
                        begin = (int)form.getCurve.Points[begin].X;
                        end   = (int)form.getCurve.Points[end].X;

                        form.buttons.Add(GraphProcessing.CreateCurve(ref aproximateLinearCurve, form.CurvesDropDownButton, form.ZGCInstance, MNK_NAME, Color.Green, 2, SymbolType.Default, Color.Green));
                        aproximateLinearCurve.Tag = 2;
                        double[] data = MyMath.leastSquaresBuild(begin, end, temp, ref aproximateLinearCurve, form);
                        form.kCoef = data[0];
                        form.bCoef = data[1];
                        form.ZGCInstance.Refresh();
                        GraphProcessing.UpdateGraph(form.ZGCInstance);

                        form.AproximateLinearCurve = aproximateLinearCurve;
                    }
                    if (regularMode)
                    {
                        aproximateLinearCurve = null;
                        double x1 = form.getCurve.Points[begin].X;
                        double y1 = form.getCurve.Points[begin].Y;

                        double x2 = form.getCurve.Points[end].X;
                        double y2 = form.getCurve.Points[end].Y;

                        // y= y1+(x-x1) (y2 - y1) / (x2-x1) ; y = k*(x-x1) + y1 = kx - (kx1 + y1)

                        double coef = (y2 - y1) / (x2 - x1);

                        form.buttons.Add(GraphProcessing.CreateCurve(ref aproximateLinearCurve, form.CurvesDropDownButton, form.ZGCInstance, REG_NAME, Color.DarkCyan, 6, SymbolType.Circle, Color.DarkCyan));
                        for (int i = (int)form.getCurve.Points[(int)begin].X; i < form.getCurve.Points[(int)end].X; i++)
                        {
                            aproximateLinearCurve.AddPoint(new PointPair(i, coef * (i - x1) + y1));
                        }
                        form.AproximateLinearCurve = aproximateLinearCurve;
                        GraphProcessing.UpdateGraph(form.ZGCInstance);
                        LineItem curveTemp = form.getCurve;
                        curveTemp.Tag             = 5;
                        aproximateLinearCurve.Tag = 2;
                        //MyMath.buildLine(form.secondDerivativeCurve, ref curveTemp, form);
                        form.getCurve = curveTemp;

                        GraphProcessing.UpdateGraph(form.ZGCInstance);
                        //y = (x-x1)*(y2-y1)/(x2-x1) + y1
                    }
                    isUsed = true;
                }

                //if (form.processedCurve != null) { form.ZGCInstance.GraphPane.CurveList.Remove(form.processedCurve); form.processedCurve = null; }
                //if (form.processedCurve2 != null) {  form.ZGCInstance.GraphPane.CurveList.Remove(form.processedCurve2); form.processedCurve2 = null; }
            }
            else
            {
                MessageBox.Show("Выберите две точки на прямой который будут использованы для построения прямой");
            }
            info.Text = form.getCurve.Points.Count.ToString();
        }