Ejemplo n.º 1
0
        public override void MouseClick(ObjectClickEventArgs e)
        {
            if (e.MouseEventArgs.Button == MouseButtons.Right && m_AstrometricState.ManualStarIdentificationMode)
            {
                m_AstrometryController.SetManuallyIdentifyStarState(false);
            }

            if (e.Pixel != null)
            {
                if ((m_AstrometricState.MeasuringState == AstrometryInFramesState.Ready || m_AstrometricState.MatchResult != PerformMatchResult.FitSucceessfull) &&
                    m_AstrometricState.ManualStarIdentificationMode &&
                    AstrometryContext.Current.FieldSolveContext.CatalogueStars != null &&
                    AstrometryContext.Current.FieldSolveContext.CatalogueStars.Count > 3)
                {
                    var          frmIdentifyCalibrationStar = new frmIdentifyCalibrationStar(AstrometryContext.Current.FieldSolveContext.CatalogueStars, m_AstrometricState.ManuallyIdentifiedStars, false);
                    DialogResult res = m_VideoController.ShowDialog(frmIdentifyCalibrationStar);
                    if (res == DialogResult.Abort)
                    {
                        m_AstrometricState.ManuallyIdentifiedStars.Clear();
                        m_AstrometryController.SetManuallyIdentifyStarState(false);
                    }
                    else if (res == DialogResult.OK && frmIdentifyCalibrationStar.SelectedStar != null)
                    {
                        var frmQuestion = new frmIdentifiedStarAction(m_AstrometricState);
                        if (m_VideoController.ShowDialog(frmQuestion) == DialogResult.OK)
                        {
                            m_AstrometricState.ManuallyIdentifiedStars.Add(e.Gausian, frmIdentifyCalibrationStar.SelectedStar);
                            m_AstrometryController.TriggerPlateReSolve();
                            m_AstrometryController.SetManuallyIdentifyStarState(false);
                        }
                        else
                        {
                            m_AstrometricState.ManuallyIdentifiedStars.Add(e.Gausian, frmIdentifyCalibrationStar.SelectedStar);
                            m_VideoController.RedrawCurrentFrame(false, true, false);
                        }
                    }
                }
                else if (m_AstrometricState.MeasuringState != AstrometryInFramesState.RunningMeasurements)
                {
                    AstrometricState astrometryTracker = AstrometryContext.Current.AstrometricState;
                    if (astrometryTracker != null &&
                        astrometryTracker.AstrometricFit != null)
                    {
                        var objInfo = new SelectedObject()
                        {
                            X0 = e.Pixel.XDouble, Y0 = e.Pixel.YDouble
                        };
                        astrometryTracker.AstrometricFit.GetRADEFromImageCoords(e.Pixel.XDouble, e.Pixel.YDouble, out objInfo.RADeg, out objInfo.DEDeg);
                        objInfo.FittedStar = astrometryTracker.AstrometricFit.FitInfo.GetFittedStar(e.Pixel);
                        objInfo.Solution   = astrometryTracker.AstrometricFit;
                        objInfo.Pixel      = e.Pixel;
                        objInfo.Gaussian   = e.Gausian;
                        if (m_AstrometricState.IdentifiedObjects != null)
                        {
                            objInfo.IdentifiedObject = m_AstrometricState.GetIdentifiedObjectAt(objInfo.RADeg, objInfo.DEDeg);
                        }
                        else
                        {
                            objInfo.IdentifiedObject = null;
                        }


                        // We don't want to reload the current frame as this will result in trying another Astrometric Fit
                        // So we send a message to the Astrometry component about the newly selected object
                        m_AstrometryController.NewObjectSelected(objInfo);

                        m_SelectedObject = objInfo;
                        m_VideoController.RedrawCurrentFrame(false, true, false);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public override void MouseDown(Point location)
        {
            if (m_SelectedCalibrationStar != null)
            {
                frmIdentifyCalibrationStar frmIdentifyCalibrationStar = new frmIdentifyCalibrationStar(m_CatalogueStars, m_UserStarIdentification);
                DialogResult res = m_VideoController.ShowDialog(frmIdentifyCalibrationStar);
                if (res == DialogResult.Abort)
                {
                    m_UserStarIdentification.Clear();
                }
                else if (res == DialogResult.OK &&
                         frmIdentifyCalibrationStar.SelectedStar != null)
                {
                    m_UserStarIdentification.Add(m_SelectedCalibrationStar, frmIdentifyCalibrationStar.SelectedStar);
                    if (m_UserStarIdentification.Keys.Count > 0 &&
                        m_UserStarIdentification.Keys.Count < 3)
                    {
                        m_VideoController.ShowMessageBox(
                            string.Format("Identify another {0} star(s) to attempt calibration", 3 - m_UserStarIdentification.Keys.Count),
                            "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    if (m_UserStarIdentification.Keys.Count > 2)
                    {
                        List <PSFFit> keysList = m_UserStarIdentification.Keys.ToList();
                        IStar         star1    = m_UserStarIdentification[keysList[0]];
                        IStar         star2    = m_UserStarIdentification[keysList[1]];
                        IStar         star3    = m_UserStarIdentification[keysList[2]];
                        double        ArcSec1  = 1 / 3600.0;
                        bool          badRA    = false;
                        bool          badDE    = false;
                        if (Math.Abs(star1.RADeg - star2.RADeg) < ArcSec1 || Math.Abs(star1.RADeg - star3.RADeg) < ArcSec1 || Math.Abs(star2.RADeg - star3.RADeg) < ArcSec1)
                        {
                            badRA = true;
                        }

                        if (Math.Abs(star1.DEDeg - star2.DEDeg) < ArcSec1 || Math.Abs(star1.DEDeg - star3.DEDeg) < ArcSec1 || Math.Abs(star2.DEDeg - star3.DEDeg) < ArcSec1)
                        {
                            badDE = true;
                        }

                        if (badRA)
                        {
                            m_VideoController.ShowMessageBox(
                                "Two of the stars have almost identical Right Ascension. Please try again with different stars.",
                                "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error);

                            m_UserStarIdentification.Clear();
                        }
                        else if (badDE)
                        {
                            m_VideoController.ShowMessageBox(
                                "Two of the stars have almost identical Declination. Please try again with different stars.",
                                "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error);

                            m_UserStarIdentification.Clear();
                        }
                        else
                        {
                            ThreeStarAstrometry threeStarSolution = ThreeStarAstrometry.SolveByThreeStars(m_Image, m_UserStarIdentification, m_Tolerance);
                            if (threeStarSolution != null)
                            {
                                m_SolvedPlate = threeStarSolution;

                                m_PlatesolveController.UpdateFocalLength((int)Math.Round(threeStarSolution.Image.EffectiveFocalLength));
                                m_RADegCenter = threeStarSolution.RA0Deg;
                                m_DEDegCenter = threeStarSolution.DE0Deg;
                                m_Image.EffectiveFocalLength = threeStarSolution.Image.EffectiveFocalLength;

                                m_UserStarIdentification.Clear();

                                m_AstrometryController.RunCalibrationWithCurrentPreliminaryFit();
                            }
                            else
                            {
                                m_VideoController.ShowMessageBox(
                                    "Cannot complete calibration. Please try again with higher initial fit tolerance and/or with different stars. Be sure that the stars are well separated.",
                                    "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error);

                                m_UserStarIdentification.Remove(m_UserStarIdentification.Keys.ToList()[2]);
                            }
                        }
                    }
                }

                DrawCatalogStarsFit();
            }
            else
            {
                m_StarPoint = new Point(location.X, location.Y);
                m_Panning   = true;
                m_VideoController.SetPictureBoxCursor(CustomCursors.PanEnabledCursor);
            }
        }
Ejemplo n.º 3
0
        public override void MouseClick(ObjectClickEventArgs e)
        {
            if (e.MouseEventArgs.Button == MouseButtons.Right && m_AstrometricState.ManualStarIdentificationMode)
            {
                m_AstrometryController.SetManuallyIdentifyStarState(false);
            }

            if (e.Pixel != null)
            {
                if ((m_AstrometricState.MeasuringState == AstrometryInFramesState.Ready || m_AstrometricState.MatchResult != PerformMatchResult.FitSucceessfull)
                    && m_AstrometricState.ManualStarIdentificationMode
                    && AstrometryContext.Current.FieldSolveContext.CatalogueStars != null
                    && AstrometryContext.Current.FieldSolveContext.CatalogueStars.Count > 3)
                {

                    var frmIdentifyCalibrationStar = new frmIdentifyCalibrationStar(AstrometryContext.Current.FieldSolveContext.CatalogueStars, m_AstrometricState.ManuallyIdentifiedStars, false);
                    DialogResult res = m_VideoController.ShowDialog(frmIdentifyCalibrationStar);
                    if (res == DialogResult.Abort)
                    {
                        m_AstrometricState.ManuallyIdentifiedStars.Clear();
                        m_AstrometryController.SetManuallyIdentifyStarState(false);
                    }
                    else if (res == DialogResult.OK && frmIdentifyCalibrationStar.SelectedStar != null)
                    {
                        var frmQuestion = new frmIdentifiedStarAction(m_AstrometricState);
                        if (m_VideoController.ShowDialog(frmQuestion) == DialogResult.OK)
                        {
                            m_AstrometricState.ManuallyIdentifiedStars.Add(e.Gausian, frmIdentifyCalibrationStar.SelectedStar);
                            m_AstrometryController.TriggerPlateReSolve();
                            m_AstrometryController.SetManuallyIdentifyStarState(false);
                        }
                        else
                        {
                            m_AstrometricState.ManuallyIdentifiedStars.Add(e.Gausian, frmIdentifyCalibrationStar.SelectedStar);
                            m_VideoController.RedrawCurrentFrame(false);
                        }
                    }
                }
                else if (m_AstrometricState.MeasuringState != AstrometryInFramesState.RunningMeasurements)
                {
                    AstrometricState astrometryTracker = AstrometryContext.Current.AstrometricState;
                    if (astrometryTracker != null &&
                        astrometryTracker.AstrometricFit != null)
                    {
                        var objInfo = new SelectedObject() { X0 = e.Pixel.XDouble, Y0 = e.Pixel.YDouble };
                        astrometryTracker.AstrometricFit.GetRADEFromImageCoords(e.Pixel.XDouble, e.Pixel.YDouble, out objInfo.RADeg, out objInfo.DEDeg);
                        objInfo.FittedStar = astrometryTracker.AstrometricFit.FitInfo.GetFittedStar(e.Pixel);
                        objInfo.Solution = astrometryTracker.AstrometricFit;
                        objInfo.Pixel = e.Pixel;
                        objInfo.Gaussian = e.Gausian;
                        if (m_AstrometricState.IdentifiedObjects != null)
                            objInfo.IdentifiedObject = m_AstrometricState.GetIdentifiedObjectAt(objInfo.RADeg, objInfo.DEDeg);
                        else
                            objInfo.IdentifiedObject = null;

                        // We don't want to reload the current frame as this will result in trying another Astrometric Fit
                        // So we send a message to the Astrometry component about the newly selected object
                        m_AstrometryController.NewObjectSelected(objInfo);

                        m_SelectedObject = objInfo;
                        m_VideoController.RedrawCurrentFrame(false);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public override void MouseDown(Point location)
        {
            if (m_SelectedCalibrationStar != null)
            {
                frmIdentifyCalibrationStar frmIdentifyCalibrationStar = new frmIdentifyCalibrationStar(m_CatalogueStars, m_UserStarIdentification);
                DialogResult res = m_VideoController.ShowDialog(frmIdentifyCalibrationStar);
                if (res == DialogResult.Abort)
                {
                    m_UserStarIdentification.Clear();
                }
                else if (res == DialogResult.OK &&
                    frmIdentifyCalibrationStar.SelectedStar != null)
                {
                    m_UserStarIdentification.Add(m_SelectedCalibrationStar, frmIdentifyCalibrationStar.SelectedStar);
                    if (m_UserStarIdentification.Keys.Count > 0 &&
                        m_UserStarIdentification.Keys.Count < 3)
                    {
                        m_VideoController.ShowMessageBox(
                            string.Format("Identify another {0} star(s) to attempt calibration", 3 - m_UserStarIdentification.Keys.Count),
                            "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    if (m_UserStarIdentification.Keys.Count > 2)
                    {
                        List<PSFFit> keysList = m_UserStarIdentification.Keys.ToList();
                        IStar star1 = m_UserStarIdentification[keysList[0]];
                        IStar star2 = m_UserStarIdentification[keysList[1]];
                        IStar star3 = m_UserStarIdentification[keysList[2]];
                        double ArcSec1 = 1 / 3600.0;
                        bool badRA = false;
                        bool badDE = false;
                        if (Math.Abs(star1.RADeg - star2.RADeg) < ArcSec1 || Math.Abs(star1.RADeg - star3.RADeg) < ArcSec1 || Math.Abs(star2.RADeg - star3.RADeg) < ArcSec1)
                        {
                            badRA = true;
                        }

                        if (Math.Abs(star1.DEDeg - star2.DEDeg) < ArcSec1 || Math.Abs(star1.DEDeg - star3.DEDeg) < ArcSec1 || Math.Abs(star2.DEDeg - star3.DEDeg) < ArcSec1)
                        {
                            badDE = true;
                        }

                        if (badRA)
                        {
                            m_VideoController.ShowMessageBox(
                                "Two of the stars have almost identical Right Ascension. Please try again with different stars.",
                                "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error);

                            m_UserStarIdentification.Clear();
                        }
                        else if (badDE)
                        {
                            m_VideoController.ShowMessageBox(
                                "Two of the stars have almost identical Declination. Please try again with different stars.",
                                "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error);

                            m_UserStarIdentification.Clear();
                        }
                        else
                        {
                            ThreeStarAstrometry threeStarSolution = ThreeStarAstrometry.SolveByThreeStars(m_Image, m_UserStarIdentification, m_Tolerance);
                            if (threeStarSolution != null)
                            {
                                m_SolvedPlate = threeStarSolution;

                                m_PlatesolveController.UpdateFocalLength((int)Math.Round(threeStarSolution.Image.EffectiveFocalLength));
                                m_RADegCenter = threeStarSolution.RA0Deg;
                                m_DEDegCenter = threeStarSolution.DE0Deg;
                                m_Image.EffectiveFocalLength = threeStarSolution.Image.EffectiveFocalLength;

                                m_UserStarIdentification.Clear();

                                m_AstrometryController.RunCalibrationWithCurrentPreliminaryFit();
                            }
                            else
                            {
                                m_VideoController.ShowMessageBox(
                                    "Cannot complete calibration. Please try again with higher initial fit tolerance and/or with different stars. Be sure that the stars are well separated.",
                                    "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error);

                                m_UserStarIdentification.Remove(m_UserStarIdentification.Keys.ToList()[2]);
                            }
                        }
                    }
                }

                DrawCatalogStarsFit();
            }
            else
            {
                m_StarPoint = new Point(location.X, location.Y);
                m_Panning = true;
                m_VideoController.SetPictureBoxCursor(CustomCursors.PanEnabledCursor);
            }
        }