public void Draw(RenderContext renderContext, bool showOnlySelected, string focusConsteallation, bool clearExisting) { maxSeperation = Math.Max(.6, Math.Cos((renderContext.FovAngle * 2) / 180.0 * Math.PI)); drawCount = 0; Lineset lsSelected = null; if (lines == null || ConstellationCentroids == null) { return; } constToDraw = focusConsteallation; foreach (Lineset ls in this.lines) { if (constToDraw == ls.Name && boundry) { lsSelected = ls; } else if (!showOnlySelected || !boundry) { DrawSingleConstellation(renderContext, ls, 1f); } } if (lsSelected != null) { DrawSingleConstellation(renderContext, lsSelected, 1f); } }
private void LoadConstellationData(string data) { if (boundry && !noInterpollation) { boundries = new Dictionary <string, Lineset>(); } lines = new List <Lineset>(); Lineset lineSet = null; try { string[] rows = data.Split("\r\n"); string abrv; string abrvOld = ""; double ra; double dec; double lastRa = 0; PointType type = PointType.Move; foreach (string row in rows) { string line = row; if (line.Substr(11, 2) == "- ") { line = line.Substr(0, 11) + " -" + line.Substr(13, (line.Length - 13)); } if (line.Substr(11, 2) == "+ ") { line = line.Substr(0, 11) + " +" + line.Substr(13, (line.Length - 13)); } dec = double.Parse(line.Substr(11, 10)); if (noInterpollation) { ra = double.Parse(line.Substr(0, 10)); } else { ra = double.Parse(line.Substr(0, 10)); } abrv = line.Substr(23, 4).Trim(); if (!boundry) { if (line.Substr(28, 1).Trim() != "") { type = (PointType)int.Parse(line.Substr(28, 1)); } } else { if (this.noInterpollation && line.Substr(28, 1) != "O") { continue; } } // if (abrv != abrvOld || type == PointType.Move) if (abrv != abrvOld) { type = PointType.Start; lineSet = new Lineset(abrv); lines.Add(lineSet); if (boundry && !noInterpollation) { boundries[abrv] = lineSet; } abrvOld = abrv; lastRa = 0; } if (this.noInterpollation) { if (Math.Abs(ra - lastRa) > 12) { ra = ra - (24 * ((ra - lastRa) < 0 ? -1 : 1)); } lastRa = ra; //console.WriteLine(String.Format("{0}, ra:{1}",abrv,ra)); } string starName = null; if (line.Length > 30) { starName = line.Substr(30).Trim(); } if (starName == null || starName != "Empty") { lineSet.Add(ra, dec, type, starName); } pointCount++; type = PointType.Line; } } catch { int i = 0; } WWTControl.RenderNeeded = true; }
//protected Vector3d RaDecTo3d(double lat, double lng) //{ // return Vector3d.Create((Math.Cos(lng * RC) * Math.Cos(lat * RC) * radius), (Math.Sin(lat * RC) * radius), (Math.Sin(lng * RC) * Math.Cos(lat * RC) * radius)); //} private void DrawSingleConstellationOld(RenderContext renderContext, Lineset ls) { bool reverse = false; // todo get this working Place centroid = ConstellationCentroids[ls.Name]; if (centroid != null) { Vector3d pos = Coordinates.RADecTo3d(reverse ? -centroid.RA - 6 : centroid.RA, reverse ? centroid.Dec : centroid.Dec); if (Vector3d.Dot(renderContext.ViewPoint, pos) < maxSeperation) { return; } } drawCount++; string col; if (boundry) { if (constToDraw != ls.Name) { col = Settings.GlobalSettings.ConstellationBoundryColor; } else { col = Settings.GlobalSettings.ConstellationSelectionColor; } } else { col = Settings.GlobalSettings.ConstellationFigureColor; } if (renderContext.gl == null) { CanvasContext2D ctx = renderContext.Device; int count = ls.Points.Count; Vector3d lastPoint = new Vector3d(); ctx.Save(); bool linePending = false; ctx.BeginPath(); ctx.StrokeStyle = col; ctx.LineWidth = 2; ctx.Alpha = .25; for (int i = 0; i < count; i++) { if (ls.Points[i].PointType == PointType.Move || i == 0) { if (linePending) { ctx.Stroke(); } lastPoint = renderContext.WVP.Transform(Coordinates.RADecTo3d(ls.Points[i].RA, ls.Points[i].Dec)); ctx.MoveTo(lastPoint.X, lastPoint.Y); } else { Vector3d newPoint = renderContext.WVP.Transform(Coordinates.RADecTo3d(ls.Points[i].RA, ls.Points[i].Dec)); // if (lastPoint.Z > 0 && newPoint.Z > 0) { ctx.LineTo(newPoint.X, newPoint.Y); linePending = true; } } } if (boundry) { ctx.ClosePath(); } ctx.Stroke(); ctx.Restore(); } else { //todo add webgl method of drawing } }
private void DrawSingleConstellation(RenderContext renderContext, Lineset ls, float opacity) { bool reverse = false; Place centroid = ConstellationCentroids[ls.Name]; if (centroid != null) { Vector3d pos = Coordinates.RADecTo3d(reverse ? -centroid.RA - 6 : centroid.RA, reverse ? centroid.Dec : centroid.Dec); if (Vector3d.Dot(renderContext.ViewPoint, pos) < maxSeperation) { return; } } if (!constellationVertexBuffers.ContainsKey(ls.Name)) { int count = ls.Points.Count; SimpleLineList linelist = new SimpleLineList(); linelist.DepthBuffered = false; constellationVertexBuffers[ls.Name] = linelist; Vector3d currentPoint = new Vector3d(); Vector3d temp; for (int i = 0; i < count; i++) { if (ls.Points[i].PointType == PointType.Move || i == 0) { currentPoint = Coordinates.RADecTo3d(ls.Points[i].RA, ls.Points[i].Dec); } else { temp = Coordinates.RADecTo3d(ls.Points[i].RA, ls.Points[i].Dec); linelist.AddLine(currentPoint, temp); currentPoint = temp; } } if (boundry) { temp = Coordinates.RADecTo3d(ls.Points[0].RA, ls.Points[0].Dec); linelist.AddLine(currentPoint, temp); } } string col = "red"; if (boundry) { if (constToDraw != ls.Name) { col = Settings.GlobalSettings.ConstellationBoundryColor; } else { col = Settings.GlobalSettings.ConstellationSelectionColor; } } else { col = Settings.GlobalSettings.ConstellationFigureColor; } constellationVertexBuffers[ls.Name].DrawLines(renderContext, opacity, Color.Load(col)); }
private void LoadConstellationData(string data) { if (boundry && !noInterpollation) { boundries = new Dictionary<string, Lineset>(); } lines = new List<Lineset>(); Lineset lineSet = null; try { string[] rows = data.Split("\r\n"); string abrv; string abrvOld = ""; double ra; double dec; double lastRa = 0; PointType type = PointType.Move; foreach(string row in rows) { string line = row; if (line.Substr(11, 2) == "- ") { line = line.Substr(0, 11) + " -" + line.Substr(13, (line.Length - 13)); } if (line.Substr(11, 2) == "+ ") { line = line.Substr(0, 11) + " +" + line.Substr(13, (line.Length - 13)); } dec = double.Parse(line.Substr(11, 10)); if (noInterpollation) { ra = double.Parse(line.Substr(0, 10)); } else { ra = double.Parse(line.Substr(0, 10)); } abrv = line.Substr(23, 4).Trim(); if (!boundry) { if (line.Substr(28, 1).Trim() != "") { type = (PointType)int.Parse(line.Substr(28, 1)); } } else { if (this.noInterpollation && line.Substr(28, 1) != "O") { continue; } } // if (abrv != abrvOld || type == PointType.Move) if (abrv != abrvOld) { type = PointType.Start; lineSet = new Lineset(abrv); lines.Add(lineSet); if (boundry && !noInterpollation) { boundries[abrv] = lineSet; } abrvOld = abrv; lastRa = 0; } if (this.noInterpollation) { if (Math.Abs(ra - lastRa) > 12) { ra = ra - (24 * ((ra - lastRa) < 0 ? -1 : 1)); } lastRa = ra; //console.WriteLine(String.Format("{0}, ra:{1}",abrv,ra)); } string starName = null; if (line.Length > 30) { starName = line.Substr(30).Trim(); } if (starName == null || starName != "Empty") { lineSet.Add(ra, dec, type, starName); } pointCount++; type = PointType.Line; } } catch { int i = 0; } WWTControl.RenderNeeded = true; }