Пример #1
0
        public override void Render(IMapContext map)
        {
            var frames = settings.Get <List <FovFrame> >("FovFrames").Where(f => f.Enabled);

            foreach (var frame in frames)
            {
                if (frame is FinderFovFrame finderFrame)
                {
                    var  sizes = finderFrame.Sizes.OrderByDescending(s => s);
                    bool outer = true;
                    foreach (var size in sizes)
                    {
                        DrawFovCircle(map, size, finderFrame, isOuter: outer);

                        if (finderFrame.Crosslines)
                        {
                            float radius = size * 3600 / 4;
                            float diam   = map.GetDiskSize(radius);

                            // do not draw frame if its size exceeds screen bounds
                            if (diam < Math.Sqrt(map.Width * map.Width + map.Height * map.Height))
                            {
                                map.Graphics.DrawPlusCross(new Pen(frame.Color.GetColor(map.Schema, map.DayLightFactor)), new PointF(map.Width / 2, map.Height / 2), diam);
                            }
                        }

                        outer = false;
                    }
                }
                else if (frame is CircularFovFrame circularFrame)
                {
                    DrawFovCircle(map, circularFrame.Size, circularFrame, isOuter: true);
                }
                else if (frame is CameraFovFrame cameraFrame)
                {
                    float width  = map.GetDiskSize(cameraFrame.Width * 3600 / 2);
                    float height = map.GetDiskSize(cameraFrame.Height * 3600 / 2);

                    // do not draw frame if its size exceeds screen bounds
                    if (Math.Min(width, height) < Math.Sqrt(map.Width * map.Width + map.Height * map.Height))
                    {
                        var pCenter = new PointF(map.Width / 2, map.Height / 2);
                        if (cameraFrame.RotateOrigin == FovFrameRotateOrigin.Equatorial)
                        {
                            map.Rotate(pCenter, map.Center.ToEquatorial(map.GeoLocation, map.SiderealTime), cameraFrame.Rotation);
                        }
                        else if (cameraFrame.RotateOrigin == FovFrameRotateOrigin.Horizontal)
                        {
                            map.Rotate(pCenter, cameraFrame.Rotation);
                        }

                        if (frame.Shading > 0 && cameraFrame.Height >= map.ViewAngle / 2)
                        {
                            var rect = new GraphicsPath();
                            rect.AddRectangle(new RectangleF(-width / 2, -height / 2, width, height));

                            var shading = new Region(new RectangleF(0, 0, map.Width, map.Height));
                            shading.Exclude(rect);

                            int transparency = (int)(frame.Shading / 100f * 255);
                            var solidBrush   = new SolidBrush(Color.FromArgb(transparency, map.GetSkyColor()));
                            map.Graphics.FillRegion(solidBrush, shading);
                        }

                        map.Graphics.DrawRectangle(new Pen(frame.Color.GetColor(map.Schema, map.DayLightFactor)), -width / 2, -height / 2, width, height);
                        float labelWidth = map.Graphics.MeasureString(frame.Label, font).Width;
                        if (labelWidth <= width * 2)
                        {
                            map.Graphics.DrawString(frame.Label, font, new SolidBrush(frame.Color.GetColor(map.Schema, map.DayLightFactor)), new PointF(0, height / 2), format);
                        }

                        map.Graphics.ResetTransform();
                    }
                }
            }
        }
Пример #2
0
            public virtual void Draw(IMapContext map, ISettings settings, DeepSky ds)
            {
                PointF p = map.Project(ds.Horizontal);

                float sizeA = GetDiameter(map, ds.SizeA);
                float sizeB = GetDiameter(map, ds.SizeB);

                // elliptic object with known size
                if (sizeB > 0 && sizeB != sizeA)
                {
                    float diamA = GetDiameter(map, ds.SizeA);
                    if (diamA > 10)
                    {
                        float diamB = GetDiameter(map, ds.SizeB);
                        if (ds.Outline != null && settings.Get <bool>("DeepSkyOutlines"))
                        {
                            DrawOutline(map, ds.Outline);
                        }
                        else
                        {
                            map.Rotate(p, ds.Equatorial, ds.PA + 90);
                            DrawEllipticObject(map.Graphics, diamA, diamB);
                            map.Graphics.ResetTransform();
                        }
                        map.AddDrawnObject(ds);

                        if (map.ViewAngle <= Renderer.limitLabels && settings.Get <bool>("DeepSkyLabels"))
                        {
                            var font = settings.Get <Font>("DeepSkyLabelsFont");
                            map.DrawObjectCaption(font, Renderer.brushCaption, ds.DisplayName, p, Math.Min(diamA, diamB));
                        }
                    }
                }
                // round object
                else if (sizeA > 0)
                {
                    float diamA = GetDiameter(map, ds.SizeA);
                    if (diamA > 10)
                    {
                        if (ds.Outline != null && settings.Get <bool>("DeepSkyOutlines"))
                        {
                            DrawOutline(map, ds.Outline);
                        }
                        else
                        {
                            map.Rotate(p, ds.Equatorial, ds.PA + 90);
                            DrawRoundObject(map.Graphics, diamA);
                            map.Graphics.ResetTransform();
                        }
                        map.AddDrawnObject(ds);

                        if (map.ViewAngle <= Renderer.limitLabels && settings.Get <bool>("DeepSkyLabels"))
                        {
                            var font = settings.Get <Font>("DeepSkyLabelsFont");
                            map.DrawObjectCaption(font, Renderer.brushCaption, ds.DisplayName, p, diamA);
                        }
                    }
                }
                // point object
                else
                {
                    float size = map.GetPointSize(ds.Mag == null ? 15 : ds.Mag.Value);
                    if ((int)size > 0)
                    {
                        if (ds.Outline != null && settings.Get <bool>("DeepSkyOutlines"))
                        {
                            DrawOutline(map, ds.Outline);
                        }
                        else
                        {
                            map.Graphics.TranslateTransform(p.X, p.Y);
                            DrawPointObject(map.Graphics, size);
                            map.Graphics.ResetTransform();
                        }
                        map.AddDrawnObject(ds);

                        if (map.ViewAngle <= Renderer.limitLabels && settings.Get <bool>("DeepSkyLabels"))
                        {
                            var font = settings.Get <Font>("DeepSkyLabelsFont");
                            map.DrawObjectCaption(font, Renderer.brushCaption, ds.DisplayName, p, 0);
                        }
                    }
                }
            }