示例#1
0
        private void RedrawWithLines()
        {
            if (_bgWithLines != null)
            {
                _bgWithLines.Dispose();
            }
            _bgWithLines = _bg.Clone() as Bitmap;
            _rline1      = RGPoint.ParabolaDirect(_a, _b, _rmin, _rmax, _rstep).ToList();
            _line1       = _rline1.Select(rg => rg.Value.CDirect).ToList();

            /*
             * _criticalLine = RGPoint.CriticalLineDirect(_rmin, _rmax, _rstep, _a, _b).ToList();
             */
            if (DrawTransformedLine)
            {
                _rline2 = new List <RGPoint>();
                foreach (var rp1 in _rline1)
                {
                    var r  = rp1.Value.R;
                    var r1 = RgSettings.Lambda * ((_a - _b - 1 + RgSettings.NMinus1) / (1 - RgSettings.NMinus1)) *
                             ((r - _a1) / (r - _b1));
                    var g1  = (r1 - _a11) / (r1 - _b11) * Math.Pow(r1 + RgSettings.Lambda, 2);
                    var rp2 = new RGPoint {
                        R = r1, G = g1
                    };
                    _rline2.Add(rp2);
                }
                _line2 = _rline2.Select(rg => rg.CDirect).ToList();
            }
            else
            {
                _rline2 = new List <RGPoint>();
                _line2  = new List <CPoint>();
            }


            if (_bgWithLines != null)
            {
                var gr = Graphics.FromImage(_bgWithLines);

                for (var i = 0; i < _rline1.Count - 1; i++)
                {
                    var rpt1 = _rline1[i];
                    var rpt2 = _rline1[i + 1];
                    var c1   = rpt1.Value.CDirect;
                    var c2   = rpt2.Value.CDirect;
                    var pen  = new Pen(rpt1.Color);
                    RG.DrawLine(X, Y, _xpxsz, _ypxsz, _sz, pen, c1, c2, gr, CProjection.UpC1C2);
                }

                if (DrawTransformedLine)
                {
                    for (var i = 0; i < _line2.Count - 1; i++)
                    {
                        var c1 = _line2[i];
                        var c2 = _line2[i + 1];
                        RG.DrawLine(X, Y, _xpxsz, _ypxsz, _sz, Config.WhitePen, c1, c2, gr, CProjection.UpC1C2);
                    }
                }

                /*
                 * for (var i = 0; i < _criticalLine.Count - 1; i++)
                 * {
                 *  var pt1 = _criticalLine[i];
                 *  var pt2 = _criticalLine[i];
                 *  RG.DrawLine(X, Y, _xpxsz, _ypxsz, _sz, Config.FuchsiaPen, pt1, pt2, gr, CProjection.UpC1C2);
                 * }
                 * */

                gr.Save();
            }
            ChangePictureBoxPicture(_bgWithLines);
            pictureBox.Update();
        }
示例#2
0
        private void RedrawWithLines()
        {
            if (_bgWithLines != null)
            {
                _bgWithLines.Dispose();
            }
            _bgWithLines = _bg.Clone() as Bitmap;
            _rline1      = RGPoint.ParabolaReversed(_a, _b, _rmin, _rmax, _rstep).ToList();
            _line1       = _rline1.Select(rg => rg.CReversed).ToList();

            _rline2 = new List <RGPoint>();
            foreach (var rp1 in _rline1)
            {
                var r   = rp1.R;
                var r1  = RgSettings.Lambda * ((_a - _b + (RgSettings.N - 1) * Math.Pow(RgSettings.Lambda, -1)) / (1 - RgSettings.N)) * ((r - _a1) / (r - _b1));
                var g1  = (r1 - _a11) / (r1 - _b11) * Math.Pow(r1 + 1, 2);
                var rp2 = new RGPoint {
                    R = r1, G = g1
                };
                _rline2.Add(rp2);
            }
            _line2 = _rline2.Select(rg => rg.CReversed).ToList();

            var nearestToB = _rline1.OrderBy(rp => Math.Abs(rp.R - _b)).FirstOrDefault();
            var nearestToL = _rline1.OrderBy(rp => Math.Abs(rp.R - -Math.Pow(RgSettings.Lambda, -1))).FirstOrDefault();

            var cNearestToB = nearestToB != null ? nearestToB.CReversed : null;
            var cNearesToL  = nearestToL != null ? nearestToL.CReversed : null;

            if (_bgWithLines != null)
            {
                var gr = Graphics.FromImage(_bgWithLines);

                var pen1 = new Pen(Config.Black);
                for (var i = 0; i < _line1.Count - 1; i++)
                {
                    var c1 = _line1[i];
                    var c2 = _line1[i + 1];
                    RG.DrawLine(X, Y, _xpxsz, _ypxsz, _sz, pen1, c1, c2, gr, CProjection.UpC0C1);
                }

                var pen2 = new Pen(Config.White);
                for (var i = 0; i < _line2.Count - 1; i++)
                {
                    var c1 = _line2[i];
                    var c2 = _line2[i + 1];
                    RG.DrawLine(X, Y, _xpxsz, _ypxsz, _sz, pen2, c1, c2, gr, CProjection.UpC0C1);
                }

                if (cNearestToB != null)
                {
                    RG.FillPoint(X, Y, _xpxsz, _ypxsz, _sz, Config.Red, cNearestToB, gr, CProjection.UpC0C1);
                }
                if (cNearesToL != null)
                {
                    RG.FillPoint(X, Y, _xpxsz, _ypxsz, _sz, Config.Yellow, cNearesToL, gr, CProjection.UpC0C1);
                }
                gr.Save();
            }
            ChangePictureBoxPicture(_bgWithLines);
            pictureBox.Update();
        }