public override void Render(IMapContext map) { Graphics g = map.Graphics; bool isGround = settings.Get <bool>("Ground"); bool showNovae = settings.Get("Stars") && settings.Get <bool>("Novae"); if (!showNovae) { return; } var novae = calc.Novae.Where(m => Angle.Separation(map.Center, m.Horizontal) < map.ViewAngle); if (isGround) { novae = novae.Where(m => m.Horizontal.Altitude >= 0); } var font = SystemFonts.DefaultFont; var brush = new SolidBrush(map.Schema == ColorSchema.White ? Color.Black : Color.White); foreach (var star in novae) { float diam = map.GetPointSize(star.Mag); if ((int)diam > 0) { PointF p = map.Project(star.Horizontal); if (!map.IsOutOfScreen(p)) { if (map.Schema == ColorSchema.White) { g.FillEllipse(Brushes.White, p.X - diam / 2 - 1, p.Y - diam / 2 - 1, diam + 2, diam + 2); } g.FillEllipse(brush, p.X - diam / 2, p.Y - diam / 2, diam, diam); map.AddDrawnObject(star); } } } if (settings.Get <bool>("StarsLabels") && settings.Get <bool>("NovaeLabels") && map.ViewAngle <= limitAllNames) { brushStarNames = new SolidBrush(map.GetColor("ColorStarsLabels")); foreach (var nova in novae) { float diam = map.GetPointSize(nova.Mag); if ((int)diam > 0) { PointF p = map.Project(nova.Horizontal); if (!map.IsOutOfScreen(p)) { DrawStarName(map, p, nova, diam); } } } } }
private void DrawLabels(IMapContext map, Track track) { var brushLabel = new SolidBrush(track.Color); double trackStep = track.Step; double stepLabels = track.LabelsStep.TotalDays; double coeff = map.DiagonalCoefficient(); int each = (int)(stepLabels / trackStep); double jd = track.From; for (int i = 0; i < track.Points.Count; i++) { if (i % each == 0 || i == track.Points.Count - 1) { var tp = track.Points[i]; double ad = Angle.Separation(tp.Horizontal, map.Center); if (ad < map.ViewAngle * coeff) { PointF p = map.Project(tp.Horizontal); if (!map.IsOutOfScreen(p)) { map.Graphics.FillEllipse(brushLabel, p.X - 2, p.Y - 2, 4, 4); map.DrawObjectCaption(fontLabel, brushLabel, Formatters.DateTime.Format(new Date(jd, map.GeoLocation.UtcOffset)), p, 4); } } } jd += trackStep; } }
public override void Render(IMapContext map) { Graphics g = map.Graphics; bool isGround = settings.Get <bool>("Ground"); bool isLabels = settings.Get <bool>("StarsLabels"); Brush brushNames = new SolidBrush(map.GetColor("ColorStarsLabels")); if (map.MagLimit > 8 && settings.Get <bool>("Stars") && settings.Get <bool>("Tycho2")) { Brush brushStar = GetColor(map); PrecessionalElements pe = Precession.ElementsFK5(map.JulianDay, Date.EPOCH_J2000); var eq0 = map.Center.ToEquatorial(map.GeoLocation, map.SiderealTime); CrdsEquatorial eq = Precession.GetEquatorialCoordinates(eq0, pe); SkyContext context = new SkyContext(map.JulianDay, map.GeoLocation); tycho2.LockedStar = map.LockedObject as Tycho2Star; tycho2.SelectedStar = map.SelectedObject as Tycho2Star; var stars = tycho2.GetStars(context, eq, map.ViewAngle, m => MagFilter(map, m)); foreach (var star in stars) { if (!isGround || star.Horizontal.Altitude > 0) { PointF p = map.Project(star.Horizontal); if (!map.IsOutOfScreen(p)) { float size = map.GetPointSize(star.Magnitude); if (map.Schema == ColorSchema.White) { g.FillEllipse(Brushes.White, p.X - size / 2 - 1, p.Y - size / 2 - 1, size + 2, size + 2); } g.FillEllipse(brushStar, p.X - size / 2, p.Y - size / 2, size, size); if (isLabels && map.ViewAngle < 1 && size > 3) { map.DrawObjectCaption(fontNames, brushNames, star.ToString(), p, size); } map.AddDrawnObject(star); } } } } }
public override void Render(IMapContext map) { Graphics g = map.Graphics; bool isGround = settings.Get <bool>("Ground"); bool showMeteors = settings.Get("Meteors"); bool onlyActive = settings.Get("MeteorsOnlyActive"); bool showLabels = settings.Get("MeteorsLabels"); int activityClassLimit = 4; if (!showMeteors) { return; } var meteors = calc.GetCelestialObjects().Where(m => Angle.Separation(map.Center, m.Horizontal) < map.ViewAngle); if (isGround) { meteors = meteors.Where(m => m.Horizontal.Altitude >= 0); } if (onlyActive) { meteors = meteors.Where(m => m.IsActive); } meteors = meteors.Where(m => m.ActivityClass <= activityClassLimit); var color = map.GetColor("ColorMeteors"); var pen = new Pen(color); var brush = new SolidBrush(color); var font = settings.Get <Font>("MeteorsLabelsFont"); foreach (var meteor in meteors) { PointF p = map.Project(meteor.Horizontal); if (!map.IsOutOfScreen(p)) { g.DrawXCross(pen, p, 5); map.AddDrawnObject(meteor); if (showLabels) { map.DrawObjectCaption(font, brush, meteor.Name, p, 10); } } } }
public override void Render(IMapContext map) { double coeff = map.DiagonalCoefficient(); if (settings.Get <bool>("Ground")) { const int POINTS_COUNT = 64; PointF[] hor = new PointF[POINTS_COUNT]; double step = 2 * map.ViewAngle / (POINTS_COUNT - 1); SolidBrush brushGround = new SolidBrush(map.GetColor(colorGroundNight, colorGroundDay)); // Bottom part of ground shape for (int i = 0; i < POINTS_COUNT; i++) { var h = new CrdsHorizontal(map.Center.Azimuth - map.ViewAngle + step * i, 0); hor[i] = map.Project(h); } if (hor[0].X >= 0) { hor[0].X = -1; } if (hor[POINTS_COUNT - 1].X <= map.Width) { hor[POINTS_COUNT - 1].X = map.Width + 1; } if (hor.Any(h => !map.IsOutOfScreen(h))) { GraphicsPath gp = new GraphicsPath(); gp.AddCurve(hor); gp.AddLines(new PointF[] { new PointF(map.Width + 1, map.Height + 1), new PointF(-1, map.Height + 1) }); map.Graphics.FillPath(brushGround, gp); } else if (map.Center.Altitude <= 0) { map.Graphics.FillRectangle(brushGround, 0, 0, map.Width, map.Height); } // Top part of ground shape if (map.Center.Altitude > 0) { for (int i = 0; i < POINTS_COUNT; i++) { var h = new CrdsHorizontal(map.Center.Azimuth - map.ViewAngle - step * i, 0); hor[i] = map.Project(h); } if (hor.Count(h => !map.IsOutOfScreen(h)) > 2) { GraphicsPath gp = new GraphicsPath(); gp.AddCurve(hor); gp.AddLines(new PointF[] { new PointF(map.Width + 1, -1), new PointF(-1, -1), }); map.Graphics.FillPath(brushGround, gp); } } } if (map.Schema == ColorSchema.White || (!settings.Get <bool>("Ground") && settings.Get <bool>("HorizonLine"))) { const int POINTS_COUNT = 64; PointF[] hor = new PointF[POINTS_COUNT]; double step = 2 * map.ViewAngle / (POINTS_COUNT - 1); for (int i = 0; i < POINTS_COUNT; i++) { var h = new CrdsHorizontal(map.Center.Azimuth - map.ViewAngle + step * i, 0); hor[i] = map.Project(h); } if (hor[0].X >= 0) { hor[0].X = -1; } if (hor[POINTS_COUNT - 1].X <= map.Width) { hor[POINTS_COUNT - 1].X = map.Width + 1; } if (hor.Any(h => !map.IsOutOfScreen(h))) { Pen penHorizonLine = new Pen(map.GetColor("ColorHorizon"), 2); map.Graphics.DrawCurve(penHorizonLine, hor); } } if (settings.Get <bool>("LabelCardinalDirections")) { Brush brushCardinalLabels = new SolidBrush(map.GetColor("ColorCardinalDirections")); StringFormat format = new StringFormat() { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }; for (int i = 0; i < cardinalDirections.Length; i++) { var h = new CrdsHorizontal(i * 360 / cardinalDirections.Length, 0); if (Angle.Separation(h, map.Center) < map.ViewAngle * coeff) { PointF p = map.Project(h); p.Y += fontCardinalLabels[i % 2].Height; using (var gp = new GraphicsPath()) { map.Graphics.DrawString(Text.Get($"CardinalDirections.{cardinalDirections[i]}"), fontCardinalLabels[i % 2], brushCardinalLabels, p, format); } } } } }
public override void Render(IMapContext map) { Graphics g = map.Graphics; var allComets = cometsCalc.Comets; bool isGround = settings.Get("Ground"); bool useTextures = settings.Get("PlanetsTextures"); bool drawComets = settings.Get("Comets"); bool drawLabels = settings.Get("CometsLabels"); bool drawAll = settings.Get <bool>("CometsDrawAll"); decimal drawAllMagLimit = settings.Get <decimal>("CometsDrawAllMagLimit"); bool drawLabelMag = settings.Get <bool>("CometsLabelsMag"); Brush brushNames = new SolidBrush(map.GetColor("ColorCometsLabels")); var font = settings.Get <Font>("CometsLabelsFont"); if (drawComets) { var comets = allComets.Where(a => Angle.Separation(map.Center, a.Horizontal) < map.ViewAngle); foreach (var c in comets) { float diam = map.GetDiskSize(c.Semidiameter); float size = map.GetPointSize(c.Magnitude); // if "draw all" setting is enabled, draw comets brighter than limit if (drawAll && size < 1 && c.Magnitude <= (float)drawAllMagLimit) { size = 1; } string label = drawLabelMag ? $"{c.Name} {Formatters.Magnitude.Format(c.Magnitude)}" : c.Name; if (diam > 5) { double ad = Angle.Separation(c.Horizontal, map.Center); if ((!isGround || c.Horizontal.Altitude + c.Semidiameter / 3600 > 0) && ad < map.ViewAngle + c.Semidiameter / 3600) { PointF p = map.Project(c.Horizontal); PointF t = map.Project(c.TailHorizontal); double tail = map.DistanceBetweenPoints(p, t); if (diam > 5 || tail > 10) { using (var gpComet = new GraphicsPath()) { double rotation = Math.Atan2(t.Y - p.Y, t.X - p.X) + Math.PI / 2; gpComet.StartFigure(); // tail is long enough if (tail > diam) { gpComet.AddArc(p.X - diam / 2, p.Y - diam / 2, diam, diam, (float)Angle.ToDegrees(rotation), 180); gpComet.AddLines(new PointF[] { gpComet.PathPoints[gpComet.PathPoints.Length - 1], t, gpComet.PathPoints[0] }); } // draw coma only else { gpComet.AddEllipse(p.X - diam / 2, p.Y - diam / 2, diam, diam); } gpComet.CloseAllFigures(); using (var brushComet = new PathGradientBrush(gpComet)) { brushComet.CenterPoint = p; int alpha = 100; if (c.Magnitude >= map.MagLimit) { alpha -= (int)(100 * (c.Magnitude - map.MagLimit) / c.Magnitude); } brushComet.CenterColor = map.GetColor(Color.FromArgb(alpha, colorComet)); brushComet.SurroundColors = gpComet.PathPoints.Select(pp => Color.Transparent).ToArray(); g.FillPath(brushComet, gpComet); } } if (drawLabels) { map.DrawObjectCaption(font, brushNames, label, p, diam); } map.AddDrawnObject(c); } } } else if ((int)size > 0) { PointF p = map.Project(c.Horizontal); if (!map.IsOutOfScreen(p)) { g.FillEllipse(new SolidBrush(map.GetColor(Color.White)), p.X - size / 2, p.Y - size / 2, size, size); if (drawLabels) { map.DrawObjectCaption(font, brushNames, label, p, size); } map.AddDrawnObject(c); continue; } } } } }
private void DrawGrid(IMapContext map, Pen penGrid, CelestialGrid grid) { bool isAnyPoint = false; // Azimuths for (int j = 0; j < grid.Columns; j++) { var segments = grid.Column(j) .Select(p => Angle.Separation(grid.ToHorizontal(p, map), map.Center) < map.ViewAngle ? p : null) .Split(p => p == null, true); foreach (var segment in segments) { for (int k = 0; k < 2; k++) { if (segment.First().RowIndex > 1) { segment.Insert(0, grid[segment.First().RowIndex - 1, j]); } } for (int k = 0; k < 2; k++) { if (segment.Last().RowIndex < grid.Rows - 2) { segment.Add(grid[segment.Last().RowIndex + 1, j]); } } PointF[] refPoints = new PointF[2]; for (int k = 0; k < 2; k++) { var coord = grid.FromHorizontal(map.Center, map); coord.Longitude = segment[0].Longitude; coord.Latitude += -map.ViewAngle + k * (map.ViewAngle * 2); coord.Latitude = Math.Min(coord.Latitude, 80); coord.Latitude = Math.Max(coord.Latitude, -80); var refHorizontal = grid.ToHorizontal(coord, map); refPoints[k] = map.Project(refHorizontal); } DrawGroupOfPoints(map, penGrid, segment.Select(s => map.Project(grid.ToHorizontal(s, map))).ToArray(), refPoints); isAnyPoint = true; } } // Altitude circles for (int i = 0; i < grid.Rows; i++) { var segments = grid.Row(i) .Select(p => Angle.Separation(grid.ToHorizontal(p, map), map.Center) < map.ViewAngle ? p : null) .Split(p => p == null, true).ToList(); // segment that starts with point "0 degrees" var seg0 = segments.FirstOrDefault(s => s.First().ColumnIndex == 0); // segment that ends with point "345 degrees" var seg23 = segments.FirstOrDefault(s => s.Last().ColumnIndex == 23); // join segments into one if (seg0 != null && seg23 != null && seg0 != seg23) { segments.Remove(seg0); seg23.AddRange(seg0); } foreach (var segment in segments) { if (segment.Count == 24) { map.Graphics.DrawClosedCurve(penGrid, segment.Select(s => map.Project(grid.ToHorizontal(s, map))).ToArray()); } else { for (int k = 0; k < 2; k++) { int col = segment.First().ColumnIndex; if (col == 0) { segment.Insert(0, grid[i, 23]); } else { segment.Insert(0, grid[i, col - 1]); } } for (int k = 0; k < 2; k++) { int col = segment.Last().ColumnIndex; if (col < 23) { segment.Add(grid[i, col + 1]); } else if (col == 23) { segment.Add(grid[i, 0]); } } PointF[] refPoints = new PointF[2]; for (int k = 0; k < 2; k++) { var coord = grid.FromHorizontal(map.Center, map); coord.Longitude += -map.ViewAngle + k * (map.ViewAngle * 2); coord.Latitude = segment[0].Latitude; var refHorizontal = grid.ToHorizontal(coord, map); refPoints[k] = map.Project(refHorizontal); } if (!map.IsOutOfScreen(refPoints[0]) || !map.IsOutOfScreen(refPoints[1])) { refPoints = map.LineScreenIntersection(refPoints[0], refPoints[1]); } DrawGroupOfPoints(map, penGrid, segment.Select(s => map.Project(grid.ToHorizontal(s, map))).ToArray(), refPoints); } isAnyPoint = true; } } // Special case: there are no points visible // on the screen at the current position and zoom. // Then we select one point that is closest to screen senter. if (!isAnyPoint) { GridPoint closestPoint = grid.Points.OrderBy(p => Angle.Separation(grid.ToHorizontal(p, map), map.Center)).First(); { var segment = new List <GridPoint>(); segment.Add(closestPoint); int i = closestPoint.RowIndex; for (int k = 0; k < 2; k++) { int col = segment.First().ColumnIndex; if (col == 0) { segment.Insert(0, grid[i, 23]); } else { segment.Insert(0, grid[i, col - 1]); } } for (int k = 0; k < 2; k++) { int col = segment.Last().ColumnIndex; if (col < 23) { segment.Add(grid[i, col + 1]); } else if (col == 23) { segment.Add(grid[i, 0]); } } PointF[] refPoints = new PointF[2]; for (int k = 0; k < 2; k++) { var coord = grid.FromHorizontal(map.Center, map); coord.Longitude += -map.ViewAngle + k * (map.ViewAngle * 2); coord.Latitude = segment[0].Latitude; var refHorizontal = grid.ToHorizontal(coord, map); refPoints[k] = map.Project(refHorizontal); } if (!map.IsOutOfScreen(refPoints[0]) || !map.IsOutOfScreen(refPoints[1])) { refPoints = map.LineScreenIntersection(refPoints[0], refPoints[1]); } DrawGroupOfPoints(map, penGrid, segment.Select(s => map.Project(grid.ToHorizontal(s, map))).ToArray(), refPoints); } { var segment = new List <GridPoint>(); segment.Add(closestPoint); int j = closestPoint.ColumnIndex; for (int k = 0; k < 2; k++) { if (segment.First().RowIndex > 1) { segment.Insert(0, grid[segment.First().RowIndex - 1, j]); } } for (int k = 0; k < 2; k++) { if (segment.Last().RowIndex < grid.Rows - 2) { segment.Add(grid[segment.Last().RowIndex + 1, j]); } } PointF[] refPoints = new PointF[2]; for (int k = 0; k < 2; k++) { var coord = grid.FromHorizontal(map.Center, map); coord.Longitude = segment[0].Longitude; coord.Latitude += -map.ViewAngle + k * (map.ViewAngle * 2); coord.Latitude = Math.Min(coord.Latitude, 80); coord.Latitude = Math.Max(coord.Latitude, -80); var refHorizontal = grid.ToHorizontal(coord, map); refPoints[k] = map.Project(refHorizontal); } DrawGroupOfPoints(map, penGrid, segment.Select(s => map.Project(grid.ToHorizontal(s, map))).ToArray(), refPoints); } } }
public override void Render(IMapContext map) { Graphics g = map.Graphics; var allStars = starsCalc.Stars; bool isGround = settings.Get <bool>("Ground"); if (settings.Get <bool>("ConstLines")) { PointF p1, p2; CrdsHorizontal h1, h2; penConLine.Brush = new SolidBrush(map.GetColor("ColorConstLines")); foreach (var line in sky.ConstellationLines) { h1 = allStars.ElementAt(line.Item1).Horizontal; h2 = allStars.ElementAt(line.Item2).Horizontal; if ((!isGround || h1.Altitude > 0 || h2.Altitude > 0) && Angle.Separation(map.Center, h1) < 90 && Angle.Separation(map.Center, h2) < 90) { p1 = map.Project(h1); p2 = map.Project(h2); var points = map.SegmentScreenIntersection(p1, p2); if (points.Length == 2) { g.DrawLine(penConLine, points[0], points[1]); } } } } if (settings.Get <bool>("Stars") && !(map.Schema == ColorSchema.Day && map.DayLightFactor == 1)) { var stars = allStars.Where(s => s != null && Angle.Separation(map.Center, s.Horizontal) < map.ViewAngle); if (isGround) { stars = stars.Where(s => s.Horizontal.Altitude >= 0); } foreach (var star in stars) { float diam = map.GetPointSize(star.Mag); if ((int)diam > 0) { PointF p = map.Project(star.Horizontal); if (!map.IsOutOfScreen(p)) { if (map.Schema == ColorSchema.White) { g.FillEllipse(Brushes.White, p.X - diam / 2 - 1, p.Y - diam / 2 - 1, diam + 2, diam + 2); } g.FillEllipse(new SolidBrush(GetColor(map, star.Color)), p.X - diam / 2, p.Y - diam / 2, diam, diam); map.AddDrawnObject(star); } } } if (settings.Get <bool>("StarsLabels") && map.ViewAngle <= limitAllNames) { brushStarNames = new SolidBrush(map.GetColor("ColorStarsLabels")); foreach (var star in stars) { float diam = map.GetPointSize(star.Mag); if ((int)diam > 0) { PointF p = map.Project(star.Horizontal); if (!map.IsOutOfScreen(p)) { DrawStarName(map, p, star, diam); } } } } } }
public override void Render(IMapContext map) { if (settings.Get <bool>("Ground")) { const int POINTS_COUNT = 64; PointF[] hor = new PointF[POINTS_COUNT]; double step = 2 * map.ViewAngle / (POINTS_COUNT - 1); SolidBrush brushGround = new SolidBrush(map.GetColor(colorGroundNight, colorGroundDay)); // Bottom part of ground shape for (int i = 0; i < POINTS_COUNT; i++) { var h = new CrdsHorizontal(map.Center.Azimuth - map.ViewAngle + step * i, 0); hor[i] = map.Project(h); } if (hor.Any(h => !map.IsOutOfScreen(h))) { GraphicsPath gp = new GraphicsPath(); gp.AddCurve(hor); var pts = map.IsInverted ? new PointF[] { new PointF(map.Width + 1, -1), new PointF(-1, -1), } : new PointF[] { new PointF(map.Width + 1, map.Height + 1), new PointF(-1, map.Height + 1) }; if (hor.Last().X > map.Width / 2) { gp.AddLines(pts); } else { gp.AddLines(pts.Reverse().ToArray()); } map.Graphics.FillPath(brushGround, gp); } else if (map.Center.Altitude <= 0) { map.Graphics.FillRectangle(brushGround, 0, 0, map.Width, map.Height); } // Top part of ground shape if (map.Center.Altitude > 0) { for (int i = 0; i < POINTS_COUNT; i++) { var h = new CrdsHorizontal(map.Center.Azimuth - map.ViewAngle - step * i, 0); hor[i] = map.Project(h); } if (hor.Count(h => !map.IsOutOfScreen(h)) > 2) { GraphicsPath gp = new GraphicsPath(); gp.AddCurve(hor); gp.AddLines(new PointF[] { new PointF(map.Width + 1, -1), new PointF(-1, -1), }); map.Graphics.FillPath(brushGround, gp); } } } if (map.Schema == ColorSchema.White || (!settings.Get <bool>("Ground") && settings.Get <bool>("HorizonLine"))) { const int POINTS_COUNT = 64; PointF[] hor = new PointF[POINTS_COUNT]; double step = 2 * map.ViewAngle / (POINTS_COUNT - 1); for (int i = 0; i < POINTS_COUNT; i++) { var h = new CrdsHorizontal(map.Center.Azimuth - map.ViewAngle + step * i, 0); hor[i] = map.Project(h); } if (hor.Any(h => !map.IsOutOfScreen(h))) { Pen penHorizonLine = new Pen(map.GetColor("ColorHorizon"), 2); map.Graphics.DrawCurve(penHorizonLine, hor); } } if (settings.Get <bool>("LabelCardinalDirections")) { Brush brushCardinalLabels = new SolidBrush(map.GetColor("ColorCardinalDirections")); StringFormat format = new StringFormat() { LineAlignment = StringAlignment.Near, Alignment = StringAlignment.Center }; for (int i = 0; i < cardinalDirections.Length; i++) { var h = new CrdsHorizontal(i * 360 / cardinalDirections.Length, 0); if (Angle.Separation(h, map.Center) < map.ViewAngle) { PointF p = map.Project(h); var fontBase = settings.Get <Font>("CardinalDirectionsFont"); var font = new Font(fontBase.FontFamily, fontBase.Size * (i % 2 == 0 ? 1 : 0.75f), fontBase.Style); using (var gp = new GraphicsPath()) { map.Graphics.DrawString(Text.Get($"CardinalDirections.{cardinalDirections[i]}"), font, brushCardinalLabels, p, format); } } } } }
public override void Render(IMapContext map) { Graphics g = map.Graphics; var allAsteroids = asteroidsCalc.Asteroids; bool isGround = settings.Get <bool>("Ground"); double coeff = map.DiagonalCoefficient(); bool drawAsteroids = settings.Get <bool>("Asteroids"); bool drawLabels = settings.Get <bool>("AsteroidsLabels"); Brush brushNames = new SolidBrush(map.GetColor("ColorAsteroidsLabels")); if (drawAsteroids) { var asteroids = allAsteroids.Where(a => Angle.Separation(map.Center, a.Horizontal) < map.ViewAngle * coeff); foreach (var a in asteroids) { double ad = Angle.Separation(a.Horizontal, map.Center); if ((!isGround || a.Horizontal.Altitude + a.Semidiameter / 3600 > 0) && ad < coeff * map.ViewAngle + a.Semidiameter / 3600) { float diam = map.GetDiskSize(a.Semidiameter); // asteroid should be rendered as disk if ((int)diam > 0) { PointF p = map.Project(a.Horizontal); map.Graphics.FillEllipse(new SolidBrush(map.GetColor(colorAsteroid)), p.X - diam / 2, p.Y - diam / 2, diam, diam); DrawVolume(map, diam, 0); if (drawLabels) { map.DrawObjectCaption(fontNames, brushNames, a.Name, p, diam); } map.AddDrawnObject(a); continue; } // asteroid should be rendered as point float size = map.GetPointSize(a.Magnitude, maxDrawingSize: 3); if ((int)size > 0) { PointF p = map.Project(a.Horizontal); if (!map.IsOutOfScreen(p)) { g.FillEllipse(new SolidBrush(map.GetColor(Color.White)), p.X - size / 2, p.Y - size / 2, size, size); if (drawLabels) { map.DrawObjectCaption(fontNames, brushNames, a.Name, p, size); } map.AddDrawnObject(a); continue; } } } } } }
public override void Render(IMapContext map) { Graphics g = map.Graphics; var allAsteroids = asteroidsCalc.Asteroids; bool isGround = settings.Get <bool>("Ground"); bool drawAsteroids = settings.Get <bool>("Asteroids"); bool drawLabels = settings.Get <bool>("AsteroidsLabels"); bool drawAll = settings.Get <bool>("AsteroidsDrawAll"); decimal drawAllMagLimit = settings.Get <decimal>("AsteroidsDrawAllMagLimit"); bool drawLabelMag = settings.Get <bool>("AsteroidsLabelsMag"); Brush brushNames = new SolidBrush(map.GetColor("ColorAsteroidsLabels")); var font = settings.Get <Font>("AsteroidsLabelsFont"); if (drawAsteroids) { var asteroids = allAsteroids.Where(a => Angle.Separation(map.Center, a.Horizontal) < map.ViewAngle); foreach (var a in asteroids) { double ad = Angle.Separation(a.Horizontal, map.Center); if ((!isGround || a.Horizontal.Altitude + a.Semidiameter / 3600 > 0) && ad < map.ViewAngle + a.Semidiameter / 3600) { float diam = map.GetDiskSize(a.Semidiameter); float size = map.GetPointSize(a.Magnitude); // if "draw all" setting is enabled, draw asteroids brighter than limit if (drawAll && size < 1 && a.Magnitude <= (float)drawAllMagLimit) { size = 1; } string label = drawLabelMag ? $"{a.Name} {Formatters.Magnitude.Format(a.Magnitude)}" : a.Name; // asteroid should be rendered as disk if ((int)diam > 0 && diam > size) { PointF p = map.Project(a.Horizontal); map.Graphics.FillEllipse(new SolidBrush(map.GetColor(colorAsteroid)), p.X - diam / 2, p.Y - diam / 2, diam, diam); DrawVolume(map, diam, 0); if (drawLabels) { map.DrawObjectCaption(font, brushNames, label, p, diam); } map.AddDrawnObject(a); continue; } // asteroid should be rendered as point else if ((int)size > 0) { PointF p = map.Project(a.Horizontal); if (!map.IsOutOfScreen(p)) { g.FillEllipse(new SolidBrush(map.GetColor(Color.White)), p.X - size / 2, p.Y - size / 2, size, size); if (drawLabels) { map.DrawObjectCaption(font, brushNames, label, p, size); } map.AddDrawnObject(a); continue; } } } } } }