Esempio n. 1
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public Stochfit(string[] args)
        {
            InitializeComponent();

            //Set properties that persist
            Properties.Settings.Default.UseSLDSingleSession = UseSLDToolStripMenuItem.Checked = Properties.Settings.Default.UseSLD;
            forceRQ4GraphingToolStripMenuItem.Checked       = Properties.Settings.Default.ForceRQ4;
            SaveReminderCTB.Checked = Properties.Settings.Default.DisableSavePrompt;

            InfoStruct = new ModelSettings();
            //Object for thread synchronization
            lockobj = new Object();
            //Class instances that make controlling the graph easier
            reflgraphobject = new Graphing(string.Empty);
            rhographobject  = new Graphing(string.Empty);
            modelreflname   = "Model Independent Reflectivity";
            rhomodelname    = "rhomodel";

            FileNameTB.ReadOnly = true;
            //Set default values here for internationalization reasons
            Rholipid.Text    = (9.38).ToString();
            SubSLDTB.Text    = (9.38).ToString();
            SurfAbs.Text     = ((double)1.0e-14).ToString();
            SubAbs.Text      = ((double)2.0e-8).ToString();
            layerlength.Text = ((double)25.0).ToString();
            SupSLDTB.Text    = ((double)0).ToString();
            wavelength.Text  = (1.24).ToString();
            SupAbsTB.Text    = ((double)0).ToString();
            QErrTB.Text      = ((double)0).ToString();
            ParamTempTB.Text = (0.03).ToString();


            ImpNormCB_CheckedChanged(null, null);
            UseAbsCB_CheckedChanged(null, null);

            //Setup the graphs
            reflgraphobject.CreateGraph(ReflGraph, "Model Independent Reflectivity Fit", "Q", "Intensity", AxisType.Log);
            rhographobject.CreateGraph(RhoGraph, "Model Independent Electron Density Fit", "Z",
                                       "Normalized Electron Density", AxisType.Linear);


            if (args.Length > 0)
            {
                m_bloadfromcommandline = true;
                origreflfilename       = args[0];
                LoadDataFile(args[0]);
                IterationsTB.Text = args[1];
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Graphs and fits an Electron Density Profile against a user defined Electron Density Profile
        /// </summary>
        /// <param name="Z">Array of thickness data points</param>
        /// <param name="ERho">Electron density of the profile to be fit</param>
        /// <param name="roughness">The overall smoothing parameter found by the model independent fit</param>
        /// <param name="SupOffset">The offset in Z for the first box</param>
        /// <param name="subsld">The subphase SLD</param>
        /// <param name="supsld">The superphase SLD</param>
        public Rhomodeling(double[] Z, double[] ERho, double roughness, string SupOffset, string subsld, string supsld)
        {
            InitializeComponent();
            RhoCalc = new RhoFit(Z, ERho);

            BoxSigmaArray  = new List <TextBox>(6);
            BoxLengthArray = new List <TextBox>(6);
            BoxRhoArray    = new List <TextBox>(6);

            this.Text = "Profile Modeling";

            //Setup variables
            if (roughness == 0)
            {
                roughness = 3.0;
            }

            RhoCalc.GetSubRoughness = roughness;
            SubRough.Text           = roughness.ToString();
            Zoffset.Text            = SupOffset.ToString();

            SubphaseSLD.Text = subsld;
            SupSLDTB.Text    = supsld;

            //Set default array values
            if (Properties.Settings.Default.UseSLDSingleSession == false)
            {
                Rho2.Text = Rho1.Text = (1.1).ToString();
            }
            else
            {
                Rho2.Text = Rho1.Text = (1.3 * double.Parse(subsld)).ToString();
            }

            Sigma2.Text   = Sigma1.Text = (3.25).ToString();
            LLength1.Text = LLength2.Text = (15.1).ToString();


            //Initialize the arrays
            MakeArrays();

            if (Z == null)
            {
                Report_btn.Enabled = UndoFit.Enabled = LevenbergFit.Enabled = false;
            }

            //Setup the Graph
            m_gRhoGraphing        = new Graphing(string.Empty);
            m_gRhoGraphing.SubSLD = double.Parse(subsld);
            m_gRhoGraphing.UseSLD = Properties.Settings.Default.UseSLDSingleSession;

            if (Properties.Settings.Default.UseSLDSingleSession == false)
            {
                m_gRhoGraphing.CreateGraph(RhoGraph, "Electron Density Profile", "Z", "Normalized Electron Density", AxisType.Linear);
                RhoLabel.Text = "Normalized Rho";
            }
            else
            {
                m_gRhoGraphing.CreateGraph(RhoGraph, "SLD Profile", "Z", "SLD", AxisType.Linear);
                RhoLabel.Text = "SLD";
            }

            m_gRhoGraphing.SetGraphType(false, false);

            if (Z != null)
            {
                m_gRhoGraphing.LoadfromArray("Model Independent Fit", Z, ERho, System.Drawing.Color.Black, SymbolType.None, 0, true, string.Empty);
            }

            ChangeRoughnessArray();
            GreyFields();

            //Subscribe to the event that notifies us to update the frontend
            RhoCalc.Update += new BoxReflFitBase.UpdateProfileHandler(UpdateProfile);

            //Create the electron density graph
            MakeED();
        }
        public ConstrainedReflmodeling(RhoFit RhoCalc)
        {
            InitializeComponent();

            ReflCalc  = new ReflFit(RhoCalc as BoxReflFitBase);
            m_bUseSLD = Properties.Settings.Default.UseSLDSingleSession;

            SigmaArray      = new List <TextBox>(6);
            LengthArray     = new List <TextBox>(6);
            RhoArray        = new List <TextBox>(6);
            HoldSigmaArray  = new List <CheckBox>(6);
            HoldLengthArray = new List <CheckBox>(6);
            HoldRhoArray    = new List <CheckBox>(6);

            if (m_bUseSLD)
            {
                tabControl1.TabPages[1].Text = "SLD";
                RhoLabel.Text = "SLD";
            }
            else
            {
                tabControl1.TabPages[1].Text = "Electron Density";
            }

            WavelengthTB.Text = ((double)(1.24)).ToString();

            //Initialize the arrays
            MakeArrays();

            //Copy over the values
            BoxCount.Text     = RhoCalc.BoxCount.ToString();
            SubRough.Text     = RhoCalc.GetSubRoughness.ToString();
            SubphaseSLD.Text  = RhoCalc.SubphaseSLD.ToString();
            SupSLDTB.Text     = RhoCalc.SuperphaseSLD.ToString();
            Holdsigma.Checked = RhoCalc.IsOneSigma;


            //Setup the Graph
            ReflGraphing = new Graphing(string.Empty);
            ReflGraphing.SetGraphType(Properties.Settings.Default.ForceRQ4, DBFCB.Checked);
            ReflGraphing.SubSLD = SubphaseSLD.ToDouble();
            ReflGraphing.SupSLD = SupSLDTB.ToDouble();
            ReflGraphing.CreateGraph(RhoGraph, "Reflectivity", "Q/Qc", "Intensity / Fresnel", AxisType.Log);
            ReflGraphing.LoadDatawithErrorstoGraph("Reflectivity Data", System.Drawing.Color.Black, SymbolType.Circle, 5, ReflData.Instance.GetQData, ReflData.Instance.GetReflData);

            //Set up ED Graph
            RhoGraphing        = new Graphing(string.Empty);
            RhoGraphing.SubSLD = SubphaseSLD.ToDouble();
            RhoGraphing.UseSLD = m_bUseSLD;
            RhoGraphing.SetGraphType(false, false);

            if (m_bUseSLD == false)
            {
                RhoGraphing.CreateGraph(EDzedGraphControl1, "Electron Density Profile", "Z", "Normalized Electron Density", AxisType.Linear);
            }
            else
            {
                RhoGraphing.CreateGraph(EDzedGraphControl1, "SLD Profile", "Z", "SLD", AxisType.Linear);
            }


            RhoGraphing.Pane.XAxis.Scale.Min = 0;
            RhoGraphing.Pane.XAxis.Scale.Max = ReflCalc.Z[ReflCalc.Z.Length - 1];

            loadingCircle2.Visible           = loadingCircle1.Visible = false;
            loadingCircle2.NumberSpoke       = loadingCircle1.NumberSpoke = 25;
            loadingCircle2.InnerCircleRadius = loadingCircle1.InnerCircleRadius = 60;
            loadingCircle2.OuterCircleRadius = loadingCircle1.OuterCircleRadius = 120;
            loadingCircle2.RotationSpeed     = loadingCircle1.RotationSpeed = 150;
            loadingCircle2.SpokeThickness    = loadingCircle1.SpokeThickness = 3;

            //Initialize constrain form
            ConstrForm = new Constraints(6);
            GreyFields();

            //Setup the callback if the graph updates the bounds
            ReflGraphing.ChangedBounds += new Graphing.ChangedEventHandler(PointChanged);

            //Setup the callback to update the frontend with new information
            ReflCalc.Update += new BoxReflFitBase.UpdateProfileHandler(ReflCalc_Update);
            ReflCalc_Update(null, null);
            MakeReflectivity();
        }