Esempio n. 1
0
 public void SetCenter(double ra, double dec)
 {
     Annotation.BatchDirty = true;
     this.ra  = ra / 15;
     this.dec = dec;
     center   = Coordinates.RADecTo3d(this.ra, this.dec);
 }
        public static void DrawArtwork(RenderContext renderContext)
        {
            if (Artwork == null)
            {
                if (artFile == null)
                {
                    artFile = new Folder();
                    artFile.LoadFromUrl("http://www.worldwidetelescope.org/wwtweb/catalog.aspx?W=hevelius", OnArtReady);
                    //artFile.LoadFromUrl("http://www.worldwidetelescope.org/wwtweb/catalog.aspx?W=and", OnArtReady);
                }

                return;
            }
            maxSeperation = Math.Max(.50, Math.Cos((renderContext.FovAngle * 2) / 180.0 * Math.PI));


            foreach (Place place in Artwork)
            {
                //BlendState bs = PictureBlendStates[imageset.Name];
                //bs.TargetState = Settings.Active.ConstellationArtFilter.IsSet(imageset.Name);

                //if (bs.State)
                bool  reverse  = false;
                Place centroid = ConstellationCentroids[place.Constellation];
                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)
                    {
                        renderContext.DrawImageSet(place.StudyImageset, 100);
                    }
                }
            }
        }
        //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));
        }
Esempio n. 5
0
 public void AddPoint(double x, double y)
 {
     Annotation.BatchDirty = true;
     points.Add(Coordinates.RADecTo3d(x / 15, y));
 }
Esempio n. 6
0
 public void AddPoint(double x, double y)
 {
     points.Add(Coordinates.RADecTo3d(x / 15, y));
 }
Esempio n. 7
0
 public void SetCenter(double ra, double dec)
 {
     this.ra  = ra / 15;
     this.dec = dec;
     center   = Coordinates.RADecTo3d(this.ra, this.dec);
 }