Ejemplo n.º 1
0
        private bool CheckInputAndLoadStars()
        {
            if (!TangraContext.Current.HasImageLoaded)
            {
                MessageBox.Show(this, "There is no loaded frame/image", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
            }

            m_RAHours = double.NaN;
            m_DEDeg   = double.NaN;

            Context.ObsCode = tbxObsCode.Text;

            if (rbKnownCenter.Checked)
            {
                try
                {
                    m_RAHours = AstroConvert.ToRightAcsension(cbxRA.Text);
                }
                catch
                {
                    MessageBox.Show(this, "Enter a valid RA value", "Validation Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    cbxRA.Focus();
                    cbxRA.Select();
                    return(false);
                }

                try
                {
                    m_DEDeg = AstroConvert.ToDeclination(cbxDE.Text);
                }
                catch
                {
                    MessageBox.Show(this, "Enter a valid DE value", "Validation Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    cbxDE.Focus();
                    cbxDE.Select();
                    return(false);
                }

                cbxRA.Persist();
                cbxDE.Persist();
            }
            else if (rbKnownObject.Checked)
            {
                // Connect to MPC to find the object coordinates
                MPEph2.MPEphEntry position = null;
                Cursor  = Cursors.WaitCursor;
                Enabled = false;
                try
                {
                    if (!TangraConfig.Settings.HasSiteCoordinatesOrCOD && string.IsNullOrEmpty(tbxObsCode.Text))
                    {
                        m_VideoController.ShowTangraSettingsDialog(false, true);

                        if (!TangraConfig.Settings.HasSiteCoordinatesOrCOD)
                        {
                            return(false);
                        }
                    }


                    Refresh();

                    frmIdentifyObjects frm;

                    if (TangraConfig.Settings.Astrometry.UseMPCCode || !string.IsNullOrEmpty(tbxObsCode.Text))
                    {
                        Context.ObsCode = tbxObsCode.Text;
                        frm             = new frmIdentifyObjects(cbxObject.Text, Context.UtcTime, Context.ObsCode);
                    }
                    else
                    {
                        frm = new frmIdentifyObjects(
                            cbxObject.Text, Context.UtcTime,
                            TangraConfig.Settings.Generic.Longitude,
                            TangraConfig.Settings.Generic.Latitude);
                    }


                    if (m_VideoController.ShowDialog(frm) == DialogResult.OK)
                    {
                        position = frm.Position;
                    }
                }
                finally
                {
                    Enabled = true;
                    Cursor  = Cursors.Default;
                }

                if (position == null)
                {
                    MessageBox.Show(
                        this,
                        string.Format(string.Format("Could not retrieve the position of '{0}' from MPC. Is your internet connection active? Is the designation correct?", cbxObject.Text)),
                        "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    cbxObject.Focus();
                    cbxObject.Select();
                    return(false);
                }
                else
                {
                    m_RAHours = position.RAHours;
                    m_DEDeg   = position.DEDeg;

                    cbxObject.Persist();

                    Context.FoundObject = position;
                }
            }

            Context.RADeg   = m_RAHours * 15;
            Context.DEDeg   = m_DEDeg;
            Context.ErrFoVs = (double)nudError.Value;

            Context.Method = RecognitionMethod.KnownCenter;

            Context.LimitMagn = (double)nudFaintestMag.Value;

            float epoch = Context.UtcTime.Year + Context.UtcTime.DayOfYear / 365.25f;


            if (TangraConfig.Settings.TraceLevels.PlateSolving.TraceInfo())
            {
                Trace.WriteLine(string.Format("Loading stars in region ({0}, {1})",
                                              AstroConvert.ToStringValue(Context.RADeg / 15, "REC"),
                                              AstroConvert.ToStringValue(Context.DEDeg, "DEC")));
            }

            var facade = new StarCatalogueFacade(TangraConfig.Settings.StarCatalogue);

            m_CatalogueStars = facade.GetStarsInRegion(
                Context.RADeg,
                Context.DEDeg,
                (Context.ErrFoVs + 1.0) * m_Image.GetMaxFOVInArcSec() / 3600.0,
                Context.LimitMagn,
                epoch);

            Context.CatalogueStars      = m_CatalogueStars;
            Context.StarCatalogueFacade = facade;

            Context.DetermineAutoLimitMagnitude = rbAutomaticLimitMagnitude.Checked;
            Context.AutoLimitMagnitude          = double.NaN;

            return(true);
        }
Ejemplo n.º 2
0
        private bool CheckInputAndLoadStars()
        {
            if (!TangraContext.Current.HasImageLoaded)
            {
                MessageBox.Show(this, "There is no loaded frame/image", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
            }

            m_RAHours = double.NaN;
            m_DEDeg = double.NaN;

            Context.ObsCode = TangraConfig.Settings.Astrometry.MPCObservatoryCode;

            if (rbKnownCenter.Checked)
            {
                try
                {
                    m_RAHours = AstroConvert.ToRightAcsension(cbxRA.Text);
                }
                catch
                {
                    MessageBox.Show(this, "Enter a valid RA value", "Validation Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    cbxRA.Focus();
                    cbxRA.Select();
                    return false;
                }

                try
                {
                    m_DEDeg = AstroConvert.ToDeclination(cbxDE.Text);
                }
                catch
                {
                    MessageBox.Show(this, "Enter a valid DE value", "Validation Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    cbxDE.Focus();
                    cbxDE.Select();
                    return false;
                }

                cbxRA.Persist();
                cbxDE.Persist();
            }
            else if (rbKnownObject.Checked)
            {
                // Connect to MPC to find the object coordinates
                MPEph2.MPEphEntry position = null;
                Cursor = Cursors.WaitCursor;
                Enabled = false;
                try
                {
                    if (!TangraConfig.Settings.HasSiteCoordinatesOrCOD)
                    {
                        m_VideoController.ShowTangraSettingsDialog(false, true);

                        if (!TangraConfig.Settings.HasSiteCoordinatesOrCOD)
                            return false;
                    }

                    Refresh();

                    frmIdentifyObjects frm;

                    if (TangraConfig.Settings.Astrometry.UseMPCCode)
                    {
                        Context.ObsCode = TangraConfig.Settings.Astrometry.MPCObservatoryCode;
                        frm = new frmIdentifyObjects(
                            cbxObject.Text, Context.UtcTime,
                            TangraConfig.Settings.Astrometry.MPCObservatoryCode);
                    }
                    else
                    {
                        frm = new frmIdentifyObjects(
                            cbxObject.Text, Context.UtcTime,
                            TangraConfig.Settings.Generic.Longitude,
                            TangraConfig.Settings.Generic.Latitude);
                    }

                    if (m_VideoController.ShowDialog(frm) == DialogResult.OK)
                    {
                        position = frm.Position;
                    }

                }
                finally
                {
                    Enabled = true;
                    Cursor = Cursors.Default;
                }

                if (position == null)
                {
                    MessageBox.Show(
                         this,
                         string.Format(string.Format("Could not retrieve the position of '{0}' from MPC. Is your internet connection active? Is the designation correct?", cbxObject.Text)),
                         "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    cbxObject.Focus();
                    cbxObject.Select();
                    return false;
                }
                else
                {
                    m_RAHours = position.RAHours;
                    m_DEDeg = position.DEDeg;

                    cbxObject.Persist();

                    Context.FoundObject = position;
                }
            }

            Context.RADeg = m_RAHours * 15;
            Context.DEDeg = m_DEDeg;
            Context.ErrFoVs = (double)nudError.Value;

            Context.Method = RecognitionMethod.KnownCenter;

            Context.LimitMagn = (double)nudFaintestMag.Value;

            float epoch = Context.UtcTime.Year + Context.UtcTime.DayOfYear / 365.25f;

            if (TangraConfig.Settings.TraceLevels.PlateSolving.TraceInfo())
                Trace.WriteLine(string.Format("Loading stars in region ({0}, {1})",
                                              AstroConvert.ToStringValue(Context.RADeg / 15, "REC"),
                                              AstroConvert.ToStringValue(Context.DEDeg, "DEC")));

            var facade = new StarCatalogueFacade(TangraConfig.Settings.StarCatalogue);
            m_CatalogueStars = facade.GetStarsInRegion(
                Context.RADeg,
                Context.DEDeg,
                (Context.ErrFoVs + 1.0) * m_Image.GetMaxFOVInArcSec() / 3600.0,
                Context.LimitMagn,
                epoch);

            Context.CatalogueStars = m_CatalogueStars;
            Context.StarCatalogueFacade = facade;

            Context.DetermineAutoLimitMagnitude = rbAutomaticLimitMagnitude.Checked;
            Context.AutoLimitMagnitude = double.NaN;

            return true;
        }