Example #1
0
        private void listView1_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedIndices.Count > 0)
            {
                try
                {
                    VoRow  row = table.Rows[listView1.SelectedIndices[0]];
                    double ra  = Coordinates.ParseRA(row[raSource.SelectedIndex - 1].ToString(), true);
                    double dec = Coordinates.ParseDec(row[decSource.SelectedIndex - 1].ToString().ToString());
                    string id;

                    VoColumn col = table.GetColumnByUcd("meta.id");
                    if (col != null)
                    {
                        id = row[col.Name].ToString();
                    }
                    else
                    {
                        id = row[0].ToString();
                    }

                    TourPlace pl = new TourPlace(id, dec, ra, Classification.Star, Constellations.Containment.FindConstellationForPoint(ra, dec), ImageSetType.Sky, -1);
                    Earth3d.MainWindow.GotoTarget(pl, false, false, false);
                }
                catch
                {
                }
            }
        }
Example #2
0
        private void listView1_ItemMouseHover(object sender, ListViewItemMouseHoverEventArgs e)
        {
            if (listView1.SelectedIndices.Count > 0)
            {
                listView1.FullRowSelect = true;
                try
                {
                    VoRow row = table.Rows[e.Item.Index];

                    // double ra = Convert.ToDouble(row[GetRAColumn().Name]) / 15;
                    // double dec = Convert.ToDouble(row[GetDecColumn().Name]);
                    double ra  = Coordinates.ParseRA(row[raSource.SelectedIndex - 1].ToString(), true);
                    double dec = Coordinates.ParseDec(row[decSource.SelectedIndex - 1].ToString());
                    string id;

                    VoColumn col = table.GetColumnByUcd("meta.id");
                    if (col != null)
                    {
                        id = row[col.Name].ToString();
                    }
                    else
                    {
                        id = row[0].ToString();
                    }

                    TourPlace pl = new TourPlace(id, dec, ra, Classification.Star, Constellations.Containment.FindConstellationForPoint(ra, dec), ImageSetType.Sky, -1);
                    Earth3d.MainWindow.SetLabelText(pl, true);
                }
                catch
                {
                }
            }
        }
        private void AddSiapStcRow(string stcsColName, VoRow row, bool selected)
        {
            string stcs = row[stcsColName].ToString().Replace("  ", " ");
            Color  col  = Color.FromArgb(120, 255, 255, 255);

            if (selected)
            {
                col = Color.Yellow;
            }

            if (stcs.StartsWith("Polygon J2000"))
            {
                string[] parts = stcs.Split(new char[] { ' ' });

                int len   = parts.Length;
                int index = 0;
                while (index < len)
                {
                    if (parts[index] == "Polygon")
                    {
                        index += 2;
                        Vector3d lastPoint  = new Vector3d();
                        Vector3d firstPoint = new Vector3d();
                        bool     start      = true;
                        for (int i = index; i < len; i += 2)
                        {
                            if (parts[i] == "Polygon")
                            {
                                start = true;
                                break;
                            }
                            else
                            {
                                double Xcoord = Coordinates.ParseRA(parts[i], true) * 15 + 180;
                                double Ycoord = Coordinates.ParseDec(parts[i + 1]);


                                Vector3d pnt = Coordinates.GeoTo3dDouble(Ycoord, Xcoord);

                                if (!start)
                                {
                                    lineList2d.AddLine(lastPoint, pnt, col, new Dates());
                                }
                                else
                                {
                                    firstPoint = pnt;
                                    start      = false;
                                }
                                lastPoint = pnt;
                            }
                            index += 2;
                        }
                        if (len > 4)
                        {
                            lineList2d.AddLine(firstPoint, lastPoint, col, new Dates());
                        }
                    }
                }
            }
        }
Example #4
0
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listView1.SelectedIndices.Count > 0)
            {
                listView1.FullRowSelect = true;
                try
                {
                    VoRow row = table.Rows[listView1.SelectedIndices[0]];

                    table.SelectedRow = row;
                    layer.CleanUp();
                    double ra  = Coordinates.ParseRA(row[raSource.SelectedIndex - 1].ToString(), true);
                    double dec = Coordinates.ParseDec(row[decSource.SelectedIndex - 1].ToString());
                    string id;

                    VoColumn col = table.GetColumnByUcd("meta.id");
                    if (col != null)
                    {
                        id = row[col.Name].ToString();
                    }
                    else
                    {
                        id = row[0].ToString();
                    }

                    TourPlace pl = new TourPlace(id, dec, ra, Classification.Star, Constellations.Containment.FindConstellationForPoint(ra, dec), ImageSetType.Sky, -1);
                    Earth3d.MainWindow.SetLabelText(pl, true);

                    if (table.SampId != null)
                    {
                        Earth3d.MainWindow.sampConnection.TableHighlightRow("", table.SampId, listView1.SelectedIndices[0]);
                    }
                }
                catch
                {
                }
            }
        }
        protected override bool PrepVertexBuffer(float opacity)
        {
            VoColumn col = table.GetColumnByUcd("meta.id");

            if (col == null)
            {
                col = table.Column[0];
            }

            if (shapeFileVertex == null)
            {
                bool siapSet = IsSiapResultSet();

                if (lineList2d == null)
                {
                    lineList2d = new LineList();
                }
                lineList2d.Clear();

                VoColumn stcsCol = table.GetColumnByUcd("phys.area;obs.field");

                if (stcsCol == null && table.Columns.ContainsKey("regionSTCS"))
                {
                    stcsCol = table.Columns["regionSTCS"];
                }

                if (PlotType == PlotTypes.Gaussian)
                {
                    MarkerScale = MarkerScales.World;
                }
                else
                {
                    MarkerScale = MarkerScales.Screen;
                }

                List <TimeSeriesPointVertex> vertList = new List <TimeSeriesPointVertex>();
                List <UInt32>         indexList       = new List <UInt32>();
                TimeSeriesPointVertex lastItem        = new TimeSeriesPointVertex();
                positions.Clear();
                UInt32 currentIndex = 0;
                Color  color        = Color.FromArgb((int)(opacity * (float)Color.A), Color);

                pointScaleType = PointScaleTypes.StellarMagnitude;

                foreach (VoRow row in table.Rows)
                {
                    try
                    {
                        if (lngColumn > -1 && latColumn > -1)
                        {
                            double Xcoord = Coordinates.ParseRA(row[this.LngColumn].ToString(), true) * 15 + 180;
                            double Ycoord = Coordinates.ParseDec(row[this.LatColumn].ToString());
                            lastItem.Position = Coordinates.GeoTo3dDouble(Ycoord, Xcoord).Vector311;
                            positions.Add(lastItem.Position);
                            lastItem.Color = color;
                            if (sizeColumn > -1)
                            {
                                try
                                {
                                    if (MarkerScale == MarkerScales.Screen)
                                    {
                                        lastItem.PointSize = 20f;
                                    }
                                    else
                                    {
                                        switch (pointScaleType)
                                        {
                                        case PointScaleTypes.Linear:
                                            lastItem.PointSize = Convert.ToSingle(row[sizeColumn]);
                                            break;

                                        case PointScaleTypes.Log:
                                            lastItem.PointSize = (float)Math.Log(Convert.ToSingle(row[sizeColumn]));
                                            break;

                                        case PointScaleTypes.Power:
                                            lastItem.PointSize = (float)Math.Pow(2, Convert.ToSingle(row[sizeColumn]));
                                            break;

                                        case PointScaleTypes.StellarMagnitude:
                                        {
                                            double size = Convert.ToSingle(row[sizeColumn]);
                                            lastItem.PointSize = (float)(40 / Math.Pow(1.6, size)) * 10;
                                        }
                                        break;

                                        case PointScaleTypes.Constant:
                                            lastItem.PointSize = 1;
                                            break;

                                        default:
                                            break;
                                        }
                                    }
                                }
                                catch
                                {
                                    lastItem.PointSize = .01f;
                                }
                            }
                            else
                            {
                                if (MarkerScale == MarkerScales.Screen)
                                {
                                    lastItem.PointSize = 20;
                                }
                                else
                                {
                                    lastItem.PointSize = (float)Math.Pow(2, 1) * 100;
                                }
                            }


                            if (startDateColumn > -1)
                            {
                                DateTime dateTime = DateTime.Parse(row[startDateColumn].ToString());
                                lastItem.Tu = (float)SpaceTimeController.UtcToJulian(dateTime);
                                lastItem.Tv = 0;
                            }


                            vertList.Add(lastItem);
                            currentIndex++;
                        }


                        if (siapSet && stcsCol != null)
                        {
                            AddSiapStcRow(stcsCol.Name, row, row == table.SelectedRow);
                        }
                    }

                    catch
                    {
                    }
                    lines = false;
                }

                if (siapSet && stcsCol != null)
                {
                    AddSiapStcRow(stcsCol.Name, table.SelectedRow, true);
                }


                shapeVertexCount = vertList.Count;
                if (shapeVertexCount == 0)
                {
                    shapeVertexCount = 1;
                }
                shapeFileVertex = new TimeSeriesPointSpriteSet(RenderContext11.PrepDevice, vertList.ToArray());
            }
            return(true);
        }
Example #6
0
        private void GoToRADec_Click(object sender, EventArgs e)
        {
            int index = coordinateType.SelectedIndex;


            double ra       = 0;
            double dec      = 0;
            bool   raValid  = false;
            bool   decValid = false;

            switch (index)
            {
            case 0:     // Equitorial
            {
                ra       = Coordinates.ParseRA(raText.Text, false);
                dec      = Coordinates.ParseDec(decText.Text);
                raValid  = Coordinates.ValidateRA(raText.Text);
                decValid = Coordinates.ValidateDec(decText.Text);
            }
            break;

            case 2:     // Galactic
            {
                double l = Coordinates.Parse(raText.Text);
                double b = Coordinates.ParseDec(decText.Text);
                raValid  = Coordinates.Validate(raText.Text);
                decValid = Coordinates.ValidateDec(decText.Text);
                if (raValid && decValid)
                {
                    double[] result = Earth3d.GalactictoJ2000(l, b);
                    ra  = result[0] / 15;
                    dec = result[1];
                }
            }
            break;

            case 3:     // Ecliptic
            {
                double l = Coordinates.Parse(raText.Text);
                double b = Coordinates.ParseDec(decText.Text);
                raValid  = Coordinates.Validate(raText.Text);
                decValid = Coordinates.ValidateDec(decText.Text);
                if (raValid && decValid)
                {
                    AstroCalc.AstroRaDec radec = AstroCalc.AstroCalc.EclipticToJ2000(l, b, SpaceTimeController.JNow);
                    ra  = radec.RA;
                    dec = radec.Dec;
                }
            }
            break;

            case 4:     // Geo
            {
                ra       = -Coordinates.Parse(raText.Text) / 15;
                dec      = Coordinates.ParseDec(decText.Text);
                raValid  = Coordinates.Validate(raText.Text);
                decValid = Coordinates.ValidateDec(decText.Text);
            }
            break;

            case 1:     // alt/az
            {
                double az  = Coordinates.Parse(raText.Text);
                double alt = Coordinates.ParseDec(decText.Text);
                raValid  = Coordinates.Validate(raText.Text);
                decValid = Coordinates.ValidateDec(decText.Text);
                Coordinates radec = Coordinates.HorizonToEquitorial(Coordinates.FromLatLng(alt, az), SpaceTimeController.Location, SpaceTimeController.Now);
                ra  = radec.RA;
                dec = radec.Dec;
            }
            break;
            }
            if (raValid && decValid)
            {
                if (Earth3d.MainWindow.SolarSystemMode)
                {
                    Vector3d pnt = Coordinates.GeoTo3dDouble(dec, Coordinates.Parse(raText.Text));


                    pnt = Vector3d.TransformCoordinate(pnt, Planets.EarthMatrix);
                    pnt.Normalize();
                    Vector2d radec = Coordinates.CartesianToLatLng(pnt);

                    Earth3d.MainWindow.TargetLat  = radec.Y;
                    Earth3d.MainWindow.TargetLong = radec.X - 90;
                }
                else
                {
                    Earth3d.MainWindow.GotoTargetRADec(ra, dec, true, false);
                }
            }
        }