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 bool MagFilter(IMapContext map, float mag) { if (mag > map.MagLimit) { return(false); } if ((int)map.GetPointSize(mag) == 0) { return(false); } return(true); }
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 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 { float rotation = map.GetRotationTowardsNorth(ds.Equatorial) + 90 - ds.PA; map.Graphics.TranslateTransform(p.X, p.Y); map.Graphics.RotateTransform(rotation); 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 { float rotation = map.GetRotationTowardsNorth(ds.Equatorial) + 90 - ds.PA; map.Graphics.TranslateTransform(p.X, p.Y); map.Graphics.RotateTransform(rotation); 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); } } } }
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 RenderJupiterMoons(IMapContext map, Planet jupiter, IEnumerable <JupiterMoon> moons) { bool isGround = settings.Get <bool>("Ground"); bool useTextures = settings.Get <bool>("UseTextures"); double coeff = map.DiagonalCoefficient(); foreach (var moon in moons) { double ad = Angle.Separation(moon.Horizontal, map.Center); if ((!isGround || moon.Horizontal.Altitude + moon.Semidiameter / 3600 > 0) && ad < coeff * map.ViewAngle + moon.Semidiameter / 3600) { PointF p = map.Project(moon.Horizontal); PointF pJupiter = map.Project(jupiter.Horizontal); float size = map.GetPointSize(moon.Magnitude, 2); float diam = map.GetDiskSize(moon.Semidiameter); // diameter is to small to render moon disk, // but point size caclulated from magnitude is enough to be drawn if (size > diam && (int)size > 0) { // do not draw moon point if eclipsed if (!moon.IsEclipsedByJupiter) { // satellite is distant enough from the Jupiter // but too small to be drawn as disk if (map.DistanceBetweenPoints(p, pJupiter) >= 5) { map.Graphics.TranslateTransform(p.X, p.Y); map.Graphics.FillEllipse(new SolidBrush(map.GetColor(Color.Wheat)), -size / 2, -size / 2, size, size); map.Graphics.ResetTransform(); map.DrawObjectCaption(fontLabel, brushLabel, moon.Name, p, 2); map.AddDrawnObject(moon); } } } // moon should be rendered as disk else if (diam >= size && (int)diam > 0) { float rotation = map.GetRotationTowardsNorth(jupiter.Equatorial) + 360 - (float)jupiter.Appearance.P; map.Graphics.TranslateTransform(p.X, p.Y); map.Graphics.RotateTransform(rotation); if (useTextures) { Image texture = imagesCache.RequestImage($"5-{moon.Number}", new PlanetTextureToken($"5-{moon.Number}", moon.CM, jupiter.Appearance.D), PlanetTextureProvider, map.Redraw); if (texture != null) { map.DrawImage(texture, -diam / 2 * 1.01f, -diam / 2 * 1.01f, diam * 1.01f, diam * 1.01f); DrawVolume(map, diam, 0); } else { map.Graphics.FillEllipse(new SolidBrush(map.GetColor(Color.Wheat)), -diam / 2, -diam / 2, diam, diam); } } else { map.Graphics.FillEllipse(new SolidBrush(map.GetColor(Color.Wheat)), -diam / 2, -diam / 2, diam, diam); if (diam > 2) { map.Graphics.DrawEllipse(new Pen(map.GetSkyColor()), -diam / 2, -diam / 2, diam, diam); } } map.Graphics.ResetTransform(); // render another moon shadows on the moon RenderJupiterMoonShadow(map, moon, moon.RectangularS); // render Jupiter shadow on the moon if (moon.IsEclipsedByJupiter) { RenderJupiterShadow(map, moon); } map.DrawObjectCaption(fontLabel, brushLabel, moon.Name, p, diam); map.AddDrawnObject(moon); } } } }
private void RenderPlanet(IMapContext map, Planet planet) { if (!settings.Get <bool>("Planets")) { return; } if (planet.Number == Planet.JUPITER) { // render moons behind Jupiter var moons = planetsCalc.JupiterMoons.Where(m => m.Rectangular.Z >= 0).OrderByDescending(m => m.Rectangular.Z); RenderJupiterMoons(map, planet, moons); } Graphics g = map.Graphics; double ad = Angle.Separation(planet.Horizontal, map.Center); bool isGround = settings.Get <bool>("Ground"); bool useTextures = settings.Get <bool>("UseTextures"); double coeff = map.DiagonalCoefficient(); if ((!isGround || planet.Horizontal.Altitude + planet.Semidiameter / 3600 > 0) && ad < coeff * map.ViewAngle + planet.Semidiameter / 3600) { float size = map.GetPointSize(planet.Magnitude, maxDrawingSize: 7); float diam = map.GetDiskSize(planet.Semidiameter); // diameter is to small to render as planet disk, // but point size caclulated from magnitude is enough to be drawn if (size > diam && (int)size > 0) { PointF p = map.Project(planet.Horizontal); g.FillEllipse(GetPlanetColor(map, planet.Number), p.X - size / 2, p.Y - size / 2, size, size); map.DrawObjectCaption(fontLabel, brushLabel, planet.Name, p, size); map.AddDrawnObject(planet); } // planet should be rendered as disk else if (diam >= size && (int)diam > 0) { PointF p = map.Project(planet.Horizontal); float rotation = map.GetRotationTowardsNorth(planet.Equatorial) + 360 - (float)planet.Appearance.P; g.TranslateTransform(p.X, p.Y); g.RotateTransform(rotation); DrawRotationAxis(g, diam); if (planet.Number == Planet.SATURN) { var rings = planetsCalc.SaturnRings; double maxSize = Math.Max(map.Width, map.Height); // scale value to convert visible size of ring to screen pixels double scale = 1.0 / 3600 / map.ViewAngle * maxSize / 4; // draw rings by halfs arcs, first half is farther one for (int half = 0; half < 2; half++) { // draw planets textures if (useTextures) { float a = (float)(rings.GetRingSize(0, RingEdge.Outer, RingAxis.Major) * scale); float b = (float)(rings.GetRingSize(0, RingEdge.Outer, RingAxis.Minor) * scale); // half of source image: 0 = top, 1 = bottom int h = (half + (rings.B > 0 ? 0 : 1)) % 2; Image textureRings = imagesCache.RequestImage("Rings", true, t => Image.FromFile("Data\\Rings.png", true), map.Redraw); if (textureRings != null) { map.DrawImage(textureRings, // destination rectangle new RectangleF(-a, -b + h * b, a * 2, b), // source rectangle new RectangleF(0, h * textureRings.Height / 2f, textureRings.Width, textureRings.Height / 2f)); } else { DrawRingsUntextured(g, rings, half, scale); } } // do not use textures else { DrawRingsUntextured(g, rings, half, scale); } // draw planet disk after first half of rings if (half == 0) { DrawPlanetGlobe(map, planet, diam); } } } else { DrawPlanetGlobe(map, planet, diam); } g.ResetTransform(); if (planet.Number <= Planet.MARS) { float phase = (float)planet.Phase * Math.Sign(planet.Elongation); GraphicsPath shadow = GetPhaseShadow(phase, diam + 1, planet.Flattening); // rotation of phase image rotation = map.GetRotationTowardsEclipticPole(planet.Ecliptical); g.TranslateTransform(p.X, p.Y); g.RotateTransform(rotation); g.FillPath(GetShadowBrush(map), shadow); g.ResetTransform(); } map.DrawObjectCaption(fontLabel, brushLabel, planet.Name, p, diam); map.AddDrawnObject(planet); if (planet.Number == Planet.JUPITER) { // render shadows on Jupiter RenderJupiterMoonShadow(map, planet); } } } // render moons over Jupiter if (planet.Number == Planet.JUPITER) { var moons = planetsCalc.JupiterMoons.Where(m => m.Rectangular.Z < 0).OrderByDescending(m => m.Rectangular.Z); RenderJupiterMoons(map, planet, moons); } }
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) { 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; } } } } } }