예제 #1
0
        public bool LoadCalibration(TangraConfig.PersistedConfiguration configuration)
        {
            float        maxVal    = m_MasterSpectra.Points.Max(x => x.RawValue);
            SpectraPoint peakPoint = m_MasterSpectra.Points.SingleOrDefault(x => Math.Abs(maxVal - x.RawValue) < 0.00001);

            if (peakPoint != null)
            {
                switch (configuration.Order)
                {
                case 1:
                    m_WavelengthCalibration = new LinearWavelengthCalibration(configuration.A, peakPoint.PixelNo, configuration.RMS);
                    return(true);

                case 2:
                    m_WavelengthCalibration = new QuadraticWavelengthCalibration(configuration.A, configuration.B, peakPoint.PixelNo, configuration.RMS);
                    return(true);

                case 3:
                    m_WavelengthCalibration = new CubicWavelengthCalibration(configuration.A, configuration.B, configuration.C, peakPoint.PixelNo, configuration.RMS);
                    return(true);
                }
            }

            return(false);
        }
예제 #2
0
        public frmChooseConfiguration(int width, int height, int bitPix)
            : this()
        {
            m_Width = width;
            m_Height = height;

            m_SelectedConfiguration = null;
            LoadConfigurations();
        }
예제 #3
0
        public frmChooseConfiguration(int width, int height, int bitPix)
            : this()
        {
            m_Width  = width;
            m_Height = height;

            m_SelectedConfiguration = null;
            LoadConfigurations();
        }
예제 #4
0
        private void btnNewConfig_Click(object sender, EventArgs e)
        {
            var frm = new frmEditWavelengthConfigName(null, m_Width, m_Height);

            if (frm.ShowDialog(this) == DialogResult.OK)
            {
                m_SelectedConfiguration = frm.Config;
                LoadConfigurations();
            }
        }
예제 #5
0
        internal void DisplaySpectra(MasterSpectra masterSpectra, TangraConfig.PersistedConfiguration configuration, TangraConfig.SpectraViewDisplaySettings displaySettings, string fileName = null)
        {
            EnsureViewSpectraForm(displaySettings);

            m_CurrentSpectra    = masterSpectra;
            m_Configuration     = configuration;
            m_SpectraCalibrator = new SpectraCalibrator(masterSpectra);

            m_ViewSpectraForm.SetMasterSpectra(masterSpectra, fileName);
            m_ViewSpectraForm.StartPosition = FormStartPosition.CenterParent;
            m_ViewSpectraForm.Show(m_MainFormView);
        }
예제 #6
0
        private void cbxSavedConfigurations_SelectedIndexChanged(object sender, EventArgs e)
        {
            pnlCalibrated.Visible    = false;
            pnlNotCalibrated.Visible = false;

            var selectedConfig = cbxSavedConfigurations.SelectedItem as TangraConfig.PersistedConfiguration;

            if (selectedConfig != null)
            {
                m_SelectedConfiguration = selectedConfig;
                if (selectedConfig.IsCalibrated)
                {
                    lblDispersion.Text = string.Format("{0} A/pix", selectedConfig.Dispersion.ToString("0.00"));
                    if (float.IsNaN(selectedConfig.RMS))
                    {
                        lblRMS.Text = "N/A";
                    }
                    else
                    {
                        lblRMS.Text = string.Format("{0} pix", selectedConfig.RMS.ToString("0.00"));
                    }

                    switch (selectedConfig.Order)
                    {
                    case 2:
                        lblCalibratedCaption.Text = "2-nd Order Polynomial Calibration";
                        break;

                    case 3:
                        lblCalibratedCaption.Text = "3-rd Order Polynomial Calibration";
                        break;

                    default:
                        lblCalibratedCaption.Text = "1-st Order Polynomial Calibration";
                        break;
                    }

                    pnlCalibrated.Visible    = true;
                    pnlNotCalibrated.Visible = false;
                    pnlNotCalibrated.SendToBack();
                }
                else
                {
                    pnlNotCalibrated.Visible = true;
                    pnlCalibrated.Visible    = false;
                    pnlCalibrated.SendToBack();
                }
            }
        }
예제 #7
0
        public frmEditWavelengthConfigName(
            TangraConfig.PersistedConfiguration config,
            int frameWidth,
            int frameHeight)
        {
            InitializeComponent();

            m_FrameWidth  = frameWidth;
            m_FrameHeight = frameHeight;

            if (config == null)
            {
                config = new TangraConfig.PersistedConfiguration {
                    Width = frameWidth, Height = frameHeight
                };
                tbxConfigName.Enabled = true;
                m_New  = true;
                Height = 260;
                pnlSolvedWavelengthConf.Visible = false;
                cbxEditConfig.Visible           = false;
            }
            else
            {
                tbxConfigName.Enabled = false;
                m_OriginalName        = config.Name;
                Height = 324;
                pnlSolvedWavelengthConf.Visible = true;
                cbxEditConfig.Visible           = true;

                tbxSolvedA.Text = config.A.ToString();
                tbxSolvedB.Text = config.B.ToString();
                if (config.Order > 1)
                {
                    tbxSolvedC.Text = config.C.ToString();
                    if (config.Order > 2)
                    {
                        tbxSolvedD.Text = config.D.ToString();
                    }
                }
                nudConfigOrder.SetNUDValue(config.Order);
            }

            m_Config           = config;
            tbxConfigName.Text = config.Name;
        }
예제 #8
0
        private void btnDelConfig_Click(object sender, EventArgs e)
        {
            var selectedConfig = cbxSavedConfigurations.SelectedItem as TangraConfig.PersistedConfiguration;

            if (selectedConfig != null)
            {
                if (MessageBox.Show(this,
                    string.Format("Are you sure you want to delete '{0}'", selectedConfig.Name),
                    "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    TangraConfig.Settings.Spectroscopy.PersistedConfigurations.RemoveAll(x => x.Name == selectedConfig.Name);
                    TangraConfig.Settings.Save();

                    m_SelectedConfiguration = null;
                    LoadConfigurations();
                }
            }
        }
예제 #9
0
        private void btnDelConfig_Click(object sender, EventArgs e)
        {
            var selectedConfig = cbxSavedConfigurations.SelectedItem as TangraConfig.PersistedConfiguration;

            if (selectedConfig != null)
            {
                if (MessageBox.Show(this,
                                    string.Format("Are you sure you want to delete '{0}'", selectedConfig.Name),
                                    "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    TangraConfig.Settings.Spectroscopy.PersistedConfigurations.RemoveAll(x => x.Name == selectedConfig.Name);
                    TangraConfig.Settings.Save();

                    m_SelectedConfiguration = null;
                    LoadConfigurations();
                }
            }
        }
예제 #10
0
        public frmEditWavelengthConfigName(
			TangraConfig.PersistedConfiguration config,
			int frameWidth,
			int frameHeight)
        {
            InitializeComponent();

            m_FrameWidth = frameWidth;
            m_FrameHeight = frameHeight;

            if (config == null)
            {
                config = new TangraConfig.PersistedConfiguration { Width = frameWidth, Height = frameHeight };
                tbxConfigName.Enabled = true;
                m_New = true;
                Height = 260;
                pnlSolvedWavelengthConf.Visible = false;
                cbxEditConfig.Visible = false;
            }
            else
            {
                tbxConfigName.Enabled = false;
                m_OriginalName = config.Name;
                Height = 324;
                pnlSolvedWavelengthConf.Visible = true;
                cbxEditConfig.Visible = true;

                tbxSolvedA.Text = config.A.ToString();
                tbxSolvedB.Text = config.B.ToString();
                if (config.Order > 1)
                {
                    tbxSolvedC.Text = config.C.ToString();
                    if (config.Order > 2)
                        tbxSolvedD.Text = config.D.ToString();
                }
                nudConfigOrder.SetNUDValue(config.Order);
            }

            m_Config = config;
            tbxConfigName.Text = config.Name;
        }
예제 #11
0
        internal void SaveCalibratedConfiguration()
        {
            if (m_Configuration != null && !m_Configuration.IsCalibrated)
            {
                SpectraCalibration calibration = GetSpectraCalibration();
                TangraConfig.PersistedConfiguration persistedConfiguration = TangraConfig.Settings.Spectroscopy.PersistedConfigurations.SingleOrDefault(x => x.Name == m_Configuration.Name);
                if (persistedConfiguration != null)
                {
                    persistedConfiguration.A            = calibration.A;
                    persistedConfiguration.B            = calibration.B;
                    persistedConfiguration.C            = calibration.C;
                    persistedConfiguration.D            = calibration.D;
                    persistedConfiguration.RMS          = calibration.RMS;
                    persistedConfiguration.Order        = calibration.PolynomialOrder;
                    persistedConfiguration.Dispersion   = calibration.Dispersion;
                    persistedConfiguration.IsCalibrated = true;

                    TangraConfig.Settings.Save();
                }
            }
        }
예제 #12
0
 public VideoSpectroscopyOperation(SpectroscopyController spectroscopyController, TangraConfig.PersistedConfiguration configuration, bool debugMode)
 {
     m_Configuration = configuration;
     m_SpectroscopyController = spectroscopyController;
     PixelValueCoefficient = 1;
 }
예제 #13
0
 public VideoSpectroscopyOperation(SpectroscopyController spectroscopyController, TangraConfig.PersistedConfiguration configuration, bool debugMode)
 {
     m_Configuration          = configuration;
     m_SpectroscopyController = spectroscopyController;
     PixelValueCoefficient    = 1;
 }
예제 #14
0
 private void btnNewConfig_Click(object sender, EventArgs e)
 {
     var frm = new frmEditWavelengthConfigName(null, m_Width, m_Height);
     if (frm.ShowDialog(this) == DialogResult.OK)
     {
         m_SelectedConfiguration = frm.Config;
         LoadConfigurations();
     }
 }
예제 #15
0
        private void cbxSavedConfigurations_SelectedIndexChanged(object sender, EventArgs e)
        {
            pnlCalibrated.Visible = false;
            pnlNotCalibrated.Visible = false;

            var selectedConfig = cbxSavedConfigurations.SelectedItem as TangraConfig.PersistedConfiguration;
            if (selectedConfig != null)
            {
                m_SelectedConfiguration = selectedConfig;
                if (selectedConfig.IsCalibrated)
                {
                    lblDispersion.Text = string.Format("{0} A/pix", selectedConfig.Dispersion.ToString("0.00"));
                    if (float.IsNaN(selectedConfig.RMS))
                        lblRMS.Text = "N/A";
                    else
                        lblRMS.Text = string.Format("{0} pix", selectedConfig.RMS.ToString("0.00"));

                    switch (selectedConfig.Order)
                    {
                        case 2:
                            lblCalibratedCaption.Text = "2-nd Order Polynomial Calibration";
                            break;

                        case 3:
                            lblCalibratedCaption.Text = "3-rd Order Polynomial Calibration";
                            break;

                        default:
                            lblCalibratedCaption.Text = "1-st Order Polynomial Calibration";
                            break;
                    }

                    pnlCalibrated.Visible = true;
                    pnlNotCalibrated.Visible = false;
                    pnlNotCalibrated.SendToBack();
                }
                else
                {
                    pnlNotCalibrated.Visible = true;
                    pnlCalibrated.Visible = false;
                    pnlCalibrated.SendToBack();
                }
            }
        }
예제 #16
0
        internal void DisplaySpectra(MasterSpectra masterSpectra, TangraConfig.PersistedConfiguration configuration, TangraConfig.SpectraViewDisplaySettings displaySettings, string fileName = null)
        {
            EnsureViewSpectraForm(displaySettings);

            m_CurrentSpectra = masterSpectra;
            m_Configuration = configuration;
            m_SpectraCalibrator = new SpectraCalibrator(masterSpectra);

            m_ViewSpectraForm.SetMasterSpectra(masterSpectra, fileName);
            m_ViewSpectraForm.StartPosition = FormStartPosition.CenterParent;
            m_ViewSpectraForm.Show(m_MainFormView);
        }