Exemplo n.º 1
0
        private void ComputeDisplayParametersForThumbnail()
        {
            if (currentConstellation == "Error")
            {
                return;
            }
            IPlace  target    = Constellations.ConstellationCentroids[currentConstellation];
            Lineset boundries = Constellations.boundries[currentConstellation];

            Vector3[] points    = new Vector3[boundries.Points.Count];
            Vector3[] pointsOut = new Vector3[boundries.Points.Count];
            for (int i = 0; i < points.Length; i++)
            {
                points[i] = Coordinates.GeoTo3d(boundries.Points[i].Dec, boundries.Points[i].RA);
            }

            Matrix mat = Matrix.RotationY((float)(-(24 - (target.RA + 6)) / 12 * Math.PI));

            mat = Matrix.Multiply(mat, Matrix.RotationX((float)(target.Lat / 180f * Math.PI)));
            mat = Matrix.Multiply(mat, Matrix.Scaling(50, -50, 50));
            mat = Matrix.Multiply(mat, Matrix.Translation(48, 22, 0));
            // mat.Translate(58, 33,0);

            Vector3.TransformCoordinate(points, ref mat, pointsOut);

            lines = new PointF[points.Length + 1];

            int index = 0;

            foreach (Vector3 point in pointsOut)
            {
                lines[index++] = new PointF((float)point.X, (float)point.Y);
            }
            lines[index] = lines[0];
        }
Exemplo n.º 2
0
        public virtual bool Draw3D(RenderContext11 renderContext, bool showOnlySelected, float opacity, string focusConsteallation, bool reverse)
        {
            constToDraw = focusConsteallation;

            Lineset lsSelected = null;

            foreach (Lineset ls in this.lines)
            {
                bool enabled = boundry ? Settings.Active.ConstellationBoundariesFilter.IsSet(ls.Name) : Settings.Active.ConstellationFiguresFilter.IsSet(ls.Name);
                if (enabled)
                {
                    if (constToDraw == ls.Name && boundry)
                    {
                        lsSelected = ls;
                    }
                    else if (!showOnlySelected || !boundry)
                    {
                        DrawSingleConstellation(renderContext, ls, opacity, reverse, true);
                    }
                }
            }

            if (lsSelected != null)
            {
                DrawSingleConstellation(renderContext, lsSelected, opacity, reverse, true);
            }

            renderContext.setRasterizerState(TriangleCullMode.Off, true);

            return(true);
        }
        private void figureTree_AfterCheck(object sender, TreeViewEventArgs e)
        {
            if (!initialized)
            {
                return;
            }

            if (e.Node.Tag != null && e.Node.Tag is Linepoint)
            {
                Linepoint lp = (Linepoint)e.Node.Tag;

                lp.PointType = e.Node.Checked ? PointType.Line : PointType.Move;

                e.Node.Text = lp.ToString();

                TreeNode parent = figureTree.SelectedNode.Parent;
                if (parent != null)
                {
                    Lineset ls = (Lineset)parent.Tag;
                    Earth3d.MainWindow.constellationsFigures.ResetConstellation(ls.Name);
                }
            }
            else
            {
                if (e.Node.Checked)
                {
                    e.Node.Checked = false;
                }
            }
        }
        private void AddFigurePoint()
        {
            TreeNode parent = figureTree.SelectedNode.Parent;

            Lineset ls = (Lineset)parent.Tag;

            ls.Points.Remove((Linepoint)figureTree.SelectedNode.Tag);
            parent.Nodes.Remove(figureTree.SelectedNode);
            Earth3d.MainWindow.constellationsFigures.ResetConstellation(ls.Name);
        }
Exemplo n.º 5
0
        private void DrawSingleConstellation(RenderContext11 renderContext, Lineset ls, float opacity, bool reverse, bool drawAllSky)
        {
            if (!constellationVertexBuffers.ContainsKey(ls.Name))
            {
                int count = ls.Points.Count;

                SimpleLineList11 linelist = new SimpleLineList11();
                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 = RaDecTo3d(ls.Points[i].Dec, ls.Points[i].RA);
                    }
                    else
                    {
                        temp = RaDecTo3d(ls.Points[i].Dec, ls.Points[i].RA);
                        linelist.AddLine(currentPoint, temp);
                        currentPoint = temp;
                    }
                }

                if (boundry)
                {
                    temp = RaDecTo3d(ls.Points[0].Dec, ls.Points[0].RA);
                    linelist.AddLine(currentPoint, temp);
                }
            }

            Color col;

            if (boundry)
            {
                if (constToDraw != ls.Name)
                {
                    col = Properties.Settings.Default.ConstellationBoundryColor;
                }
                else
                {
                    col = Properties.Settings.Default.ConstellationSelectionColor;
                }
            }
            else
            {
                col = Properties.Settings.Default.ConstellationFigureColor;
            }

            constellationVertexBuffers[ls.Name].DrawLines(renderContext, opacity, col);
        }
        internal void AddFigurePoint(IPlace place)
        {
            TreeNode  parent;
            Linepoint pnt = new Linepoint(place.RA * 15 - 180, place.Dec, PointType.Line, place.Name != Language.GetLocalizedText(90, "No Object") ? place.Name : null);

            if (figureTree.SelectedNode.Tag is Linepoint)
            {
                parent = figureTree.SelectedNode.Parent;

                Lineset ls = (Lineset)parent.Tag;

                Linepoint lp = (Linepoint)figureTree.SelectedNode.Tag;

                int index = ls.Points.FindIndex(delegate(Linepoint target) { return(target == lp); }) + 1;

                ls.Points.Insert(index, pnt);

                TreeNode child;
                if (index >= parent.Nodes.Count)
                {
                    child = parent.Nodes.Add(pnt.ToString());
                }
                else
                {
                    child = parent.Nodes.Insert(index, pnt.ToString());
                }
                child.Tag               = pnt;
                child.Checked           = pnt.PointType != PointType.Move;
                figureTree.SelectedNode = child;
                Earth3d.MainWindow.constellationsFigures.ResetConstellation(ls.Name);
            }
            else
            {
                parent = figureTree.SelectedNode;
                Lineset ls = (Lineset)figureTree.SelectedNode.Tag;
                ls.Points.Add(pnt);
                TreeNode child = parent.Nodes.Add(pnt.ToString());
                child.Tag               = pnt;
                child.Checked           = pnt.PointType != PointType.Move;
                figureTree.SelectedNode = child;
                Earth3d.MainWindow.constellationsFigures.ResetConstellation(ls.Name);
            }
        }
        private void DeleteSelectedPoint()
        {
            if (figureTree.SelectedNode.Tag != null && figureTree.SelectedNode.Tag is Linepoint)
            {
                TreeNode parent = figureTree.SelectedNode.Parent;

                Lineset ls = (Lineset)parent.Tag;

                ls.Points.Remove((Linepoint)figureTree.SelectedNode.Tag);
                parent.Nodes.Remove(figureTree.SelectedNode);
                Earth3d.MainWindow.constellationsFigures.ResetConstellation(ls.Name);
            }
            else if (figureTree.SelectedNode.Tag != null && figureTree.SelectedNode.Tag is Lineset)
            {
                if (MessageBox.Show(Language.GetLocalizedText(169, "This will remove all points from the selected constellation.\nAre you sure you want to do this?"), Language.GetLocalizedText(170, "Confirm Delete all Constellation Points"), MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    Lineset ls = (Lineset)figureTree.SelectedNode.Tag;
                    ls.Points.Clear();
                    figureTree.SelectedNode.Nodes.Clear();
                    Earth3d.MainWindow.constellationsFigures.ResetConstellation(ls.Name);
                }
            }
        }
        private void figureTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (e.Node == null)
            {
                return;
            }

            figureTree.SelectedNode = e.Node;

            if (e.Button == MouseButtons.Right)
            {
                contextMenu = new ContextMenuStrip();
                ToolStripMenuItem deleteMenu = new ToolStripMenuItem(Language.GetLocalizedText(167, "Delete"));
                deleteMenu.Click += new EventHandler(deleteMenu_Click);
                contextMenu.Items.Add(deleteMenu);
                contextMenu.Show(Cursor.Position);
            }
            else if (e.Node.Tag is Lineset)
            {
                Lineset ls = (Lineset)figureTree.SelectedNode.Tag;

                Earth3d.MainWindow.GotoTarget(Constellations.ConstellationCentroids[ls.Name], false, false, true);
            }
        }
Exemplo n.º 9
0
        public Constellations(string name, string url, bool boundry, bool noInterpollation)
        {
            instances.Add(this);

            if (boundry && !noInterpollation)
            {
                boundries = new Dictionary <string, Lineset>();
            }
            this.noInterpollation = noInterpollation;
            this.boundry          = boundry;
            lines     = new List <Lineset>();
            this.name = name;
            this.url  = url;
            if (!Directory.Exists(Properties.Settings.Default.CahceDirectory))
            {
                Directory.CreateDirectory(Properties.Settings.Default.CahceDirectory);
            }

            if (boundry)
            {
                targetPath = Properties.Settings.Default.CahceDirectory + @"data\";
                extention  = ".wwtbnd";
            }
            else
            {
                targetPath = Properties.Settings.Default.CahceDirectory + @"data\figures\";
                extention  = ".wwtfig";
            }


            if (!Directory.Exists(targetPath))
            {
                Directory.CreateDirectory(targetPath);
            }

            if (!string.IsNullOrEmpty(url))
            {
                DataSetManager.DownloadFile(url, targetPath + name + extention, false, true);
            }

            Lineset lineSet = null;

            try
            {
                using (StreamReader sr = new StreamReader(targetPath + name + extention))
                {
                    string    line;
                    string    abrv;
                    string    abrvOld = "";
                    double    ra;
                    double    dec;
                    double    lastRa = 0;
                    PointType type   = PointType.Move;
                    while (sr.Peek() >= 0)
                    {
                        line = sr.ReadLine();

                        if (line.Substring(11, 2) == "- ")
                        {
                            line = line.Substring(0, 11) + " -" + line.Substring(13, (line.Length - 13));
                        }
                        if (line.Substring(11, 2) == "+ ")
                        {
                            line = line.Substring(0, 11) + " +" + line.Substring(13, (line.Length - 13));
                        }
                        dec = Convert.ToDouble(line.Substring(11, 10));
                        if (noInterpollation)
                        {
                            ra = Convert.ToDouble(line.Substring(0, 10));
                        }
                        else
                        {
                            ra = ((Convert.ToDouble(line.Substring(0, 10)) / 24.0 * 360) - 180);
                        }

                        abrv = line.Substring(23, 4).Trim();
                        if (!boundry)
                        {
                            if (line.Substring(28, 1).Trim() != "")
                            {
                                type = (PointType)Convert.ToInt32(line.Substring(28, 1));
                            }
                        }
                        else
                        {
                            if (this.noInterpollation && line.Substring(28, 1) != "O")
                            {
                                continue;
                            }
                        }

                        if (abrv != abrvOld)
                        {
                            type    = PointType.Start;
                            lineSet = new Lineset(abrv);
                            lines.Add(lineSet);
                            if (boundry && !noInterpollation)
                            {
                                boundries.Add(abrv, lineSet);
                            }
                            abrvOld = abrv;
                            lastRa  = 0;
                        }


                        if (this.noInterpollation)
                        {
                            if (Math.Abs(ra - lastRa) > 12)
                            {
                                ra = ra - (24 * Math.Sign(ra - lastRa));
                            }
                            lastRa = ra;
                        }
                        string starName = null;
                        if (line.Length > 30)
                        {
                            starName = line.Substring(30).Trim();
                        }

                        if (starName == null || starName != "Empty")
                        {
                            lineSet.Add(ra, dec, type, starName);
                        }
                        pointCount++;
                        type = PointType.Line;
                    }
                    sr.Close();
                }
            }
            catch
            {
            }
        }
Exemplo n.º 10
0
        private void DrawSingleConstellation(RenderContext11 renderContext, Lineset ls, float opacity, bool reverse, bool drawAllSky)
        {
            if (!constellationVertexBuffers.ContainsKey(ls.Name))
            {
                int count = ls.Points.Count;

                SimpleLineList11 linelist = new SimpleLineList11();
                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 = RaDecTo3d(ls.Points[i].Dec, ls.Points[i].RA);
                    }
                    else
                    {
                        temp = RaDecTo3d(ls.Points[i].Dec, ls.Points[i].RA);
                        linelist.AddLine(currentPoint, temp);
                        currentPoint = temp;
                    }
                }

                if (boundry)
                {
                    temp = RaDecTo3d(ls.Points[0].Dec, ls.Points[0].RA);
                    linelist.AddLine(currentPoint, temp);
                }
             }

            Color col;
            if (boundry)
            {
                if (constToDraw != ls.Name)
                {
                    col = Properties.Settings.Default.ConstellationBoundryColor;
                }
                else
                {
                    col = Properties.Settings.Default.ConstellationSelectionColor;
                }
            }
            else
            {
                col = Properties.Settings.Default.ConstellationFigureColor;
            }

            constellationVertexBuffers[ls.Name].DrawLines(renderContext, opacity , col);
        }
Exemplo n.º 11
0
        public Constellations(string name, string url, bool boundry, bool noInterpollation)
        {
            instances.Add(this);

            if (boundry && !noInterpollation)
            {
                boundries = new Dictionary<string, Lineset>();
            }
            this.noInterpollation = noInterpollation;
            this.boundry = boundry;
            lines = new List<Lineset>();
            this.name = name;
            this.url = url;
            if (!Directory.Exists(Properties.Settings.Default.CahceDirectory))
            {
                Directory.CreateDirectory(Properties.Settings.Default.CahceDirectory);
            }

            if (boundry)
            {

                targetPath = Properties.Settings.Default.CahceDirectory + @"data\";
                extention = ".wwtbnd";
            }
            else
            {
                targetPath = Properties.Settings.Default.CahceDirectory + @"data\figures\";
                extention = ".wwtfig";
            }

            if (!Directory.Exists(targetPath))
            {
                Directory.CreateDirectory(targetPath);
            }

            if (!string.IsNullOrEmpty(url))
            {
                DataSetManager.DownloadFile(url, targetPath + name + extention, false, true);
            }

            Lineset lineSet = null;

            try
            {
                using (StreamReader sr = new StreamReader(targetPath + name + extention))
                {
                    string line;
                    string abrv;
                    string abrvOld = "";
                    double ra;
                    double dec;
                    double lastRa = 0;
                    PointType type = PointType.Move;
                    while (sr.Peek() >= 0)
                    {
                        line = sr.ReadLine();

                        if (line.Substring(11, 2) == "- ")
                        {
                            line = line.Substring(0, 11) + " -" + line.Substring(13, (line.Length - 13));
                        }
                        if (line.Substring(11, 2) == "+ ")
                        {
                            line = line.Substring(0, 11) + " +" + line.Substring(13, (line.Length - 13));
                        }
                        dec = Convert.ToDouble(line.Substring(11, 10));
                        if (noInterpollation)
                        {
                            ra = Convert.ToDouble(line.Substring(0, 10));
                        }
                        else
                        {
                            ra = ((Convert.ToDouble(line.Substring(0, 10)) / 24.0 * 360) - 180);
                        }

                        abrv = line.Substring(23, 4).Trim();
                        if (!boundry)
                        {
                            if (line.Substring(28, 1).Trim() != "")
                            {
                                type = (PointType)Convert.ToInt32(line.Substring(28, 1));
                            }
                        }
                        else
                        {
                            if (this.noInterpollation && line.Substring(28, 1) != "O")
                            {
                                continue;
                            }
                        }

                        if (abrv != abrvOld)
                        {
                            type = PointType.Start;
                            lineSet = new Lineset(abrv);
                            lines.Add(lineSet);
                            if (boundry && !noInterpollation)
                            {
                                boundries.Add(abrv, lineSet);
                            }
                            abrvOld = abrv;
                            lastRa = 0;
                        }

                        if (this.noInterpollation)
                        {
                            if (Math.Abs(ra - lastRa) > 12)
                            {
                                ra = ra - (24 * Math.Sign(ra - lastRa));

                            }
                            lastRa = ra;

                        }
                        string starName = null;
                        if (line.Length > 30)
                        {
                            starName = line.Substring(30).Trim();
                        }

                        if (starName == null || starName != "Empty")
                        {
                            lineSet.Add(ra, dec, type, starName);
                        }
                        pointCount++;
                        type = PointType.Line;

                    }
                    sr.Close();
                }
            }
            catch
            {

            }
        }