示例#1
0
 internal void NewObjectSelected(SelectedObject objInfo)
 {
     if (m_Operation != null)
         m_Operation.NewObjectSelected(objInfo);
 }
 public override void OnNewFrame(int currentFrameIndex, bool isLastFrame)
 {
     m_SelectedObject = null;
 }
        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);
                    }
                }
            }
        }
示例#4
0
        internal void PresentSelectedObject(SelectedObject objInfo)
        {
            SwitchToStandardControls();
            pnlSwitchControl.Visible = m_AllMeasurements.Count > 0;
            m_JustAfterNewFit = false;

            pnlObject.Visible = true;
            pnlAstrometry.Visible = false;
            pnlMeasurements.Visible = false;
            pnlObject.Top = 0;
            pnlObject.Left = 0;

            pnlObject.Visible = objInfo != null;
            btnFramesAstrometry.Visible = false;

            if (objInfo != null)
            {
                if (objInfo.FittedStar != null)
                {
                    if (TangraConfig.Settings.StarCatalogue.Catalog == TangraConfig.StarCatalog.PPMXL)
                        lblObjectName.Text = objInfo.FittedStar.StarNo.ToString(); // PPMXL numbers are too large so to save space don't add the catalog name
                    else
                        lblObjectName.Text = string.Format("{0} {1}", TangraConfig.Settings.StarCatalogue.Catalog, objInfo.FittedStar.StarNo);
                    lblX.Text = objInfo.FittedStar.x.ToString("0.0");
                    lblY.Text = objInfo.FittedStar.y.ToString("0.0");

                    if (AstrometryContext.Current.CurrentPhotometricFit != null)
                    {
                        bool isSaturated;
                        double I = AstrometryContext.Current.CurrentPhotometricFit.GetIntencity(objInfo.Pixel, out isSaturated);

                        double colorJKIndex = double.NaN;

                        IStar matchedStar = m_CatalogueStars.FirstOrDefault(s => s.StarNo == objInfo.FittedStar.StarNo);
                        if (matchedStar != null)
                            colorJKIndex = matchedStar.MagJ - matchedStar.MagK;
                        else
                            colorJKIndex = ColourIndexTables.GetJKFromVR(m_MeasurementContext.AssumedTargetVRColour);

                        double mag = AstrometryContext.Current.CurrentPhotometricFit.GetMagnitudeForIntencity(I, colorJKIndex);
                        if (double.IsNaN(mag))
                            lblIntensity.Text = string.Format("{0}", I.ToString("0"));
                        else
                            lblIntensity.Text = string.Format("{0} (m = {1})", I.ToString("0"), mag.ToString("0.0"));
                        lblMagFitTitle.Visible = true;
                        lblIntensity.Visible = true;
                        lblIntensity.ForeColor = isSaturated ? Color.Red : SystemColors.ControlText;
                    }
                    else
                    {
                        lblIntensity.Visible = false;
                        lblMagFitTitle.Visible = false;
                    }

                    lblMag.Text = string.Format("m = {0}", objInfo.FittedStar.Mag.ToString("0.0"));
                    lblResRaTitle.Text = "Residual RA =";
                    lblResDeTitle.Text = "Residual DE =";
                    lblResRA.Text = string.Format("{0}\"", objInfo.FittedStar.FitInfo.ResidualRAArcSec.ToString("0.00"));
                    lblResDE.Text = string.Format("{0}\"", objInfo.FittedStar.FitInfo.ResidualDEArcSec.ToString("0.00"));
                }
                else
                {
                    lblX.Text = objInfo.Pixel.XDouble.ToString("0.0");
                    lblY.Text = objInfo.Pixel.YDouble.ToString("0.0");

                    if (objInfo.IdentifiedObject != null)
                    {
                        lblObjectName.Text = objInfo.IdentifiedObject.ObjectName;
                        lblMag.Text = string.Format("m = {0}", objInfo.IdentifiedObject.Mag.ToString("0.0"));
                    }
                    else
                    {
                        lblObjectName.Text = "Unknown Object";
                        lblMag.Text = "";
                    }

                    lblResRaTitle.Text = "Std.Dev RA =";
                    lblResDeTitle.Text = "Std.Dev DE =";

                    lblResRA.Text = string.Format("{0}\"", objInfo.Solution.StdDevRAArcSec.ToString("0.00"));
                    lblResDE.Text = string.Format("{0}\"", objInfo.Solution.StdDevDEArcSec.ToString("0.00"));
                }

                lblRA.Text = AstroConvert.ToStringValue(objInfo.RADeg / 15.0, "HH MM SS.TT");
                lblDE.Text = AstroConvert.ToStringValue(objInfo.DEDeg, "+DD MM SS.T");

                var cosDE = Math.Cos(objInfo.DEDeg * Math.PI / 180);
                var stdDevSol = Math.Sqrt(objInfo.Solution.StdDevDEArcSec * objInfo.Solution.StdDevDEArcSec + objInfo.Solution.StdDevRAArcSec * objInfo.Solution.StdDevRAArcSec * cosDE * cosDE);
                lblErrSol.Text = string.Format("{0:0.00}\"", stdDevSol / Math.Sqrt(objInfo.Solution.FitInfo.NumberOfStarsUsedInSolution()));

                btnFramesAstrometry.Visible = !m_AstrometricState.ObjectToMeasureSelected;
                if (!m_AstrometricState.ObjectToMeasureSelected)
                {
                    m_UserObject.RADeg = objInfo.RADeg;
                    m_UserObject.DEDeg = objInfo.DEDeg;
                    m_UserObject.X0 = (float)objInfo.Pixel.XDouble;
                    m_UserObject.Y0 = (float)objInfo.Pixel.YDouble;
                }

                if (objInfo.Gaussian != null)
                {
                    pbPSFFit.Visible = true;

                    using (Graphics g = Graphics.FromImage(pbPSFFit.Image))
                    {
                        objInfo.Gaussian.DrawGraph(g, m_FullRect, m_VideoController.VideoBitPix, m_VideoController.VideoAav16NormVal);
                        g.Save();
                    }

                    pbPSFFit.Invalidate();

                    double certaintyRounded = Math.Round(objInfo.Gaussian.Certainty * 100) / 100.0;
                    lblMax.Text = certaintyRounded < 0 ? "N/A" : (certaintyRounded).ToString("0.00");
                    lblFWHM.Text = objInfo.Gaussian.FWHM.ToString("0.00");
                    lblSNR.Text = objInfo.Gaussian.GetSNR().ToString("0.00");
                    pnlPSFInfo.Visible = true;
                    lblErrPos.Text = string.Format("{0:0.00}\"", objInfo.Solution.GetDistanceInArcSec(objInfo.Gaussian.FWHM) / (2.355 * objInfo.Gaussian.GetSNR()));
                }
                else
                {
                    pbPSFFit.Visible = false;
                    pnlPSFInfo.Visible = false;
                    lblErrPos.Text = "N/A";
                }

                if (AstrometryContext.Current.CurrentPhotometricFit != null && objInfo.Pixel != null)
                {
                    bool isSaturated;
                    double I = AstrometryContext.Current.CurrentPhotometricFit.GetIntencity(objInfo.Pixel, out isSaturated);

                    double colorJKIndex = double.NaN;

                    IStar matchedStar = objInfo.FittedStar != null
                        ? m_CatalogueStars.FirstOrDefault(s => s.StarNo == objInfo.FittedStar.StarNo)
                        : null;

                    if (matchedStar != null)
                        colorJKIndex = matchedStar.MagJ - matchedStar.MagK;
                    else
                    {
                        colorJKIndex = ColourIndexTables.GetJKFromVR(m_MeasurementContext != null
                            ? m_MeasurementContext.AssumedTargetVRColour
                            : TangraConfig.Settings.Astrometry.AssumedTargetVRColour);
                    }

                    double mag = AstrometryContext.Current.CurrentPhotometricFit.GetMagnitudeForIntencity(I, colorJKIndex);

                    if (double.IsNaN(mag))
                        lblIntensity.Text = string.Format("{0}", I.ToString("0"));
                    else
                        lblIntensity.Text = string.Format("{0} (m = {1})", I.ToString("0"), mag.ToString("0.0"));
                    lblIntensity.ForeColor = isSaturated ? Color.Red : SystemColors.ControlText;

                    lblIntensity.Visible = true;
                    lblMagFitTitle.Visible = true;
                }
                else
                    lblIntensity.Text = "";
            }
        }