Exemple #1
0
        private void btnEditConfiguration_Click(object sender, EventArgs e)
        {
            TangraConfig.ScopeRecorderConfiguration entry = cbxSavedConfigurations.SelectedItem as TangraConfig.ScopeRecorderConfiguration;
            VideoCamera camera    = cbxSavedCameras.SelectedItem as VideoCamera;
            Rectangle   plateRect = new Rectangle(0, 0, TangraContext.Current.FrameWidth, TangraContext.Current.FrameHeight);

            TangraConfig.PersistedPlateConstants pltConst = TangraConfig.Settings.PlateSolve.GetPlateConstants(camera, entry, plateRect);

            if (entry != null && camera != null)
            {
                frmEditConfigName frmNewConfig = new frmEditConfigName(entry, camera, FrameWidth, FrameHeight, pltConst);
                if (frmNewConfig.ShowDialog(this) == DialogResult.OK)
                {
                    m_SelectedScopeRecorder = frmNewConfig.Config.Title;

                    if (frmNewConfig.UpdatePlateConstants && frmNewConfig.PltConst != null)
                    {
                        pltConst = frmNewConfig.PltConst;

                        TangraConfig.Settings.PlateSolve.SetPlateConstants(camera, entry, plateRect, pltConst);
                    }

                    ReloadScopeRecorders();
                    CheckSolvedPlateConstants(camera, entry);
                }
            }
        }
Exemple #2
0
        private void UpdateCurrentConfigValues()
        {
            VideoCamera camera = cbxSavedCameras.SelectedItem as VideoCamera;

            TangraConfig.ScopeRecorderConfiguration config = cbxSavedConfigurations.SelectedItem as TangraConfig.ScopeRecorderConfiguration;

            if (camera != null && config != null && !m_Setting)
            {
                Rectangle rawFrame = config.RawFrameSizes[camera.Model];
                if (rawFrame == Rectangle.Empty)
                {
                    config.RawFrameSizes[camera.Model] = new Rectangle(0, 0, FrameWidth, FrameHeight);
                }

#if ASTROMETRY_DEBUG
                Trace.Assert(config.RawFrameSizes[camera.Model].Width == FrameWidth);
                Trace.Assert(config.RawFrameSizes[camera.Model].Height == FrameHeight);
#endif

                m_LimitingMagnitudeChanged = config.LimitingMagnitudes[camera.Model] != (double)nudLimitMagnitude.Value;
                config.LimitingMagnitudes[camera.Model] = (double)nudLimitMagnitude.Value;
                config.FlipVertically   = cbxFlipVertically.Checked;
                config.FlipHorizontally = cbxFlipHorizontally.Checked;

                TangraConfig.Settings.Save();
            }
        }
Exemple #3
0
        private void btnNewConfig_Click(object sender, EventArgs e)
        {
            if (cbxSavedCameras.SelectedItem != null)
            {
                VideoCamera       camera       = cbxSavedCameras.SelectedItem as VideoCamera;
                frmEditConfigName frmNewConfig = new frmEditConfigName(null, camera, FrameWidth, FrameHeight, null);

                if (frmNewConfig.ShowDialog(this) == DialogResult.OK)
                {
                    m_SelectedScopeRecorder = frmNewConfig.Config.Title;
                    TangraConfig.ScopeRecorderConfiguration entry = TangraConfig.Settings.PlateSolve.ScopeRecorders.FirstOrDefault(r => r.Title == m_SelectedScopeRecorder);

                    if (frmNewConfig.PltConst != null)
                    {
                        Rectangle plateRect = new Rectangle(0, 0, TangraContext.Current.FrameWidth, TangraContext.Current.FrameHeight);

                        TangraConfig.PersistedPlateConstants pltConst = new TangraConfig.PersistedPlateConstants();

                        pltConst.EffectiveFocalLength = frmNewConfig.PltConst.EffectiveFocalLength;
                        pltConst.EffectivePixelWidth  = frmNewConfig.PltConst.EffectivePixelWidth;
                        pltConst.EffectivePixelHeight = frmNewConfig.PltConst.EffectivePixelHeight;

                        TangraConfig.Settings.PlateSolve.SetPlateConstants(camera, entry, plateRect, pltConst);
                        TangraConfig.Settings.Save();
                    }

                    ReloadScopeRecorders();
                    CheckSolvedPlateConstants(camera, entry);
                }
            }
            else
            {
                cbxSavedCameras.Focus();
            }
        }
Exemple #4
0
        private void btnDelConfig_Click(object sender, EventArgs e)
        {
            TangraConfig.ScopeRecorderConfiguration entry = cbxSavedConfigurations.SelectedItem as TangraConfig.ScopeRecorderConfiguration;

            if (entry != null)
            {
                if (MessageBox.Show(this,
                                    string.Format("Are you sure you want to delete '{0}' and all calibrations of this configuration?", entry.Title),
                                    "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    TangraConfig.Settings.PlateSolve.SolvedPlateConstants.RemoveAll(c => c.ScopeRecoderConfig == entry.Title);
                    TangraConfig.Settings.PlateSolve.ScopeRecorders.Remove(entry);

                    if (TangraConfig.Settings.PlateSolve.SelectedScopeRecorder == entry.Title)
                    {
                        TangraConfig.Settings.PlateSolve.SelectedScopeRecorder = null;
                    }

                    TangraConfig.Settings.Save();

                    m_SelectedScopeRecorder = null;
                    ReloadScopeRecorders();
                    UpdateEnabledDisabledState();
                }
            }
        }
Exemple #5
0
        public frmEditConfigName(
            TangraConfig.ScopeRecorderConfiguration config,
            VideoCamera camera,
            int frameWidth,
            int frameHeight,
            TangraConfig.PersistedPlateConstants pltConst)
        {
            InitializeComponent();

            m_FrameWidth  = frameWidth;
            m_FrameHeight = frameHeight;

            if (config == null)
            {
                config = new TangraConfig.ScopeRecorderConfiguration(camera.Model, frameWidth, frameHeight);
                tbxConfigName.Enabled = true;
                m_New  = true;
                Height = 260;
                pnlSolvedPlateConf.Visible = false;
                cbxEditConfig.Visible      = false;
                pnlOSDAreaConf.Visible     = false;
                cbxEditOSDArea.Visible     = false;
            }
            else
            {
                tbxConfigName.Enabled = false;
                Height = 396;
                pnlSolvedPlateConf.Visible = true;
                cbxEditConfig.Visible      = true;
                if (pltConst != null)
                {
                    tbxSolvedCellX.Text       = pltConst.EffectivePixelWidth.ToString();
                    tbxSolvedCellY.Text       = pltConst.EffectivePixelHeight.ToString();
                    tbxSolvedFocalLength.Text = pltConst.EffectiveFocalLength.ToString();
                }
            }

            cbxAreaType.SelectedIndex = config.IsInclusionArea ? 1 : 0;
            if (config.IsInclusionArea)
            {
                SetOSDDimentions(config.InclusionArea);
            }
            else
            {
                SetOSDDimentions(config.OSDExclusionArea);
            }

            m_Config           = config;
            m_Camera           = camera;
            tbxConfigName.Text = config.Title;
            m_PltConst         = pltConst;
        }
Exemple #6
0
        private void CheckSolvedPlateConstants(VideoCamera camera, TangraConfig.ScopeRecorderConfiguration config)
        {
            TangraConfig.PersistedPlateConstants pltCopnst =
                TangraConfig.Settings.PlateSolve.GetPlateConstants(
                    camera,
                    config,
                    new Rectangle(0, 0, TangraContext.Current.FrameWidth, TangraContext.Current.FrameHeight));

            if (pltCopnst == null)
            {
                gbxSolved.Visible    = false;
                pnlNotSolved.Visible = true;

                cbxSolveConstantsNow.Checked = true;
                cbxSolveConstantsNow.Visible = true;
            }
            else
            {
                gbxSolved.Visible = true;

                cbxSolveConstantsNow.Checked = false;
                pnlNotSolved.Visible         = false;

                tbxSolvedCellX.Text       = pltCopnst.EffectivePixelWidth.ToString("0.000");
                tbxSolvedCellY.Text       = pltCopnst.EffectivePixelHeight.ToString("0.000");
                tbxSolvedFocalLength.Text = pltCopnst.EffectiveFocalLength.ToString("0.0");

                Rectangle rect = config.IsInclusionArea ? config.InclusionArea : config.OSDExclusionArea;
                lblConfigAreaInfo.Text = string.Format("{0} Area [({1},{2})-({3},{4})]", config.IsInclusionArea ? "Inclusion" : "Exclusion", rect.Left, rect.Top, rect.Right, rect.Bottom);
            }

            pnlEditableConfigSettings.Visible = true;

            toolTip.SetToolTip(lblLimitingMagnitude, string.Format("  The limiting magnitude when {0}\r\nis used with this configuration", camera.Model));
            toolTip.SetToolTip(nudLimitMagnitude, string.Format("  The limiting magnitude when {0}\r\nis used with this configuration", camera.Model));

            m_Setting = true;
            try
            {
                nudLimitMagnitude.Value    = (decimal)config.LimitingMagnitudes[camera.Model];
                m_LimitingMagnitudeChanged = false;

                cbxFlipVertically.Checked   = config.FlipVertically;
                cbxFlipHorizontally.Checked = config.FlipHorizontally;
            }
            finally
            {
                m_Setting = false;
            }
        }
Exemple #7
0
        public frmEditConfigName(
			TangraConfig.ScopeRecorderConfiguration config,
			VideoCamera camera,
			int frameWidth,
			int frameHeight,
			TangraConfig.PersistedPlateConstants pltConst)
        {
            InitializeComponent();

            m_FrameWidth = frameWidth;
            m_FrameHeight = frameHeight;

            if (config == null)
            {
                config = new TangraConfig.ScopeRecorderConfiguration(camera.Model, frameWidth, frameHeight);
                tbxConfigName.Enabled = true;
                m_New = true;
                Height = 260;
                pnlSolvedPlateConf.Visible = false;
                cbxEditConfig.Visible = false;
                pnlOSDAreaConf.Visible = false;
                cbxEditOSDArea.Visible = false;
            }
            else
            {
                tbxConfigName.Enabled = false;
                Height = 396;
                pnlSolvedPlateConf.Visible = true;
                cbxEditConfig.Visible = true;
                if (pltConst != null)
                {
                    tbxSolvedCellX.Text = pltConst.EffectivePixelWidth.ToString();
                    tbxSolvedCellY.Text = pltConst.EffectivePixelHeight.ToString();
                    tbxSolvedFocalLength.Text = pltConst.EffectiveFocalLength.ToString();
                }
            }

            cbxAreaType.SelectedIndex = config.IsInclusionArea ? 1 : 0;
            if (config.IsInclusionArea)
                SetOSDDimentions(config.InclusionArea);
            else
                SetOSDDimentions(config.OSDExclusionArea);

            m_Config = config;
            m_Camera = camera;
            tbxConfigName.Text = config.Title;
            m_PltConst = pltConst;
        }
Exemple #8
0
        private void UpdateEnabledDisabledState()
        {
            VideoCamera camera = cbxSavedCameras.SelectedItem as VideoCamera;

            TangraConfig.ScopeRecorderConfiguration config = cbxSavedConfigurations.SelectedItem as TangraConfig.ScopeRecorderConfiguration;

            if (OnUpdateEnabledDisabledState != null)
            {
                OnUpdateEnabledDisabledState.Invoke(camera != null && config != null);
            }

            if (camera != null && config != null)
            {
                CheckSolvedPlateConstants(camera, config);
            }
            else
            {
                gbxSolved.Visible = false;
                pnlEditableConfigSettings.Visible = false;
                pnlNotSolved.Visible = false;
            }
        }
Exemple #9
0
        internal ChooseConfigurationResult VerifyCameraSettings()
        {
            VideoCamera camera = cbxSavedCameras.SelectedItem as VideoCamera;

            TangraConfig.ScopeRecorderConfiguration config = cbxSavedConfigurations.SelectedItem as TangraConfig.ScopeRecorderConfiguration;

            if (camera != null && config != null)
            {
                if (cbxRecalibrate.Checked)
                {
                    return(new ChooseConfigurationResult()
                    {
                        SolvePlateConstantsNow = true,
                        SelectedCameraModel = camera.Model,
                        SelectedConfigName = config.Title,
                        Recalibrate = true
                    });
                }

                Rectangle rawFrame = config.RawFrameSizes[camera.Model];
                if (rawFrame == Rectangle.Empty)
                {
                    rawFrame = new Rectangle(0, 0, FrameWidth, FrameHeight);
                    config.RawFrameSizes[camera.Model] = rawFrame;
                }

                m_LimitingMagnitudeChanged |= config.LimitingMagnitudes[camera.Model] != (double)nudLimitMagnitude.Value;
                config.LimitingMagnitudes[camera.Model] = (double)nudLimitMagnitude.Value;
                if (m_LimitingMagnitudeChanged && config.LimitingMagnitudes[camera.Model] < 13)
                {
                    MessageBox.Show("Your limitting magnitude may result in too few stars being used for a fit. Unless your field of view is a degree or more it is recommended to use at least limitting magnitude of 13.\r\n\r\nThe limiting magnitude has the meaning of 'What is the faintest star you can record with this equipment using the maximum useful exposure'. For non integrating video cameras it is recommended to use one magnitude fainter than what you have determined experimentally to be your limiting magnitude.", "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    m_LimitingMagnitudeChanged = false;
                }

                config.FlipVertically   = cbxFlipVertically.Checked;
                config.FlipHorizontally = cbxFlipHorizontally.Checked;

                TangraConfig.Settings.Save();

                if (rawFrame.Height != FrameHeight ||
                    rawFrame.Width != FrameWidth)
                {
                    MessageBox.Show(
                        "The opened video frame size is incompatible with the selected configuration. May be " +
                        "the recording equipment is different? Please create a new configuration.",
                        "Wrong Configuration", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    cbxSavedConfigurations.Focus();
                    return(null);
                }
                else if (rawFrame == Rectangle.Empty)
                {
                    // This is an existing configuration with no parameters for this frame size, so create one
                    config.RawFrameSizes[camera.Model] = new Rectangle(0, 0, FrameWidth, FrameHeight);
                }

                var rv = new ChooseConfigurationResult()
                {
                    IsNew = config.IsNew,
                    SolvePlateConstantsNow = cbxSolveConstantsNow.Checked,
                    SelectedCameraModel    = camera.Model,
                    SelectedConfigName     = config.Title
                };

                return(rv);
            }

            return(null);
        }