Example #1
0
 public ParameterIdentificationResidualHistogramPresenter(
     IParameterIdentificationSingleRunAnalysisView view,
     IParameterIdentificationResidualHistogramView histogramView,
     IPresentationSettingsTask presentationSettingsTask,
     IResidualDistibutionDataCreator residualDistibutionDataCreator,
     INormalDistributionDataCreator normalDistributionDataCreator,
     IApplicationSettings applicationSettings) : base(view)
 {
     _presentationSettingsTask       = presentationSettingsTask;
     _histogramView                  = histogramView;
     _residualDistibutionDataCreator = residualDistibutionDataCreator;
     _normalDistributionDataCreator  = normalDistributionDataCreator;
     _applicationSettings            = applicationSettings;
     _nameProperty         = ReflectionHelper.PropertyFor <ParameterIdentificationResidualHistogram, string>(x => x.Name).Name;
     view.ApplicationIcon  = ApplicationIcons.ResidualHistogramAnalysis;
     _distributionSettings = new DistributionSettings
     {
         AxisCountMode = AxisCountMode.Count,
         BarType       = BarType.SideBySide,
         XAxisTitle    = Captions.ParameterIdentification.Residuals,
         YAxisTitle    = Captions.ParameterIdentification.ResidualCount
     };
     _view.SetAnalysisView(histogramView);
     _histogramView.CopyToClipboardManager = this;
     view.HelpId = HelpId.Tool_PI_Analysis_HistogramResiduals;
 }
 public void Plot(DiscreteDistributionData dataToPlot, DistributionSettings settings)
 {
     ResetPlot();
     plot(dataToPlot, settings);
     AxisX.WholeRange.AutoSideMargins  = true;
     AxisX.WholeRange.SideMarginsValue = 0.5D;
 }
        private void plot <T>(DistributionData <T> dataToPlot, DistributionSettings settings)
        {
            DataSource       = dataToPlot.DataTable;
            SeriesDataMember = dataToPlot.GroupingName;
            InitializeColor();
            SeriesTemplate.ArgumentDataMember = dataToPlot.XAxisName;
            SeriesTemplate.ArgumentScaleType  = ScaleType.Auto;

            SeriesTemplate.ValueDataMembers.AddRange(dataToPlot.YAxisName);
            SeriesTemplate.ValueScaleType = ScaleType.Numerical;

            SeriesTemplate.LabelsVisibility = DefaultBoolean.False;
            SeriesTemplate.View             = barViewFrom(settings.BarType);

            Legend.Visibility = Series.Count > 1 ? DefaultBoolean.True : DefaultBoolean.False;

            _title.Visibility = DefaultBoolean.True;
            _title.Text       = settings.PlotCaption;

            updateDiagramFromSettings(settings);

            if (!dataToPlot.IsRangeSpecified)
            {
                AxisX.WholeRange.Auto = true;
            }

            AxisX.WholeRange.AutoSideMargins  = false;
            AxisX.WholeRange.SideMarginsValue = 0;
        }
Example #4
0
        protected override void Context()
        {
            _view = A.Fake <IAdvancedParameterDistributionView>();
            _representationInfoRepository      = A.Fake <IRepresentationInfoRepository>();
            _entityPathResolver                = A.Fake <IEntityPathResolver>();
            _parametersPresenter               = A.Fake <IPopulationParameterGroupsPresenter>();
            _popParameterDistributionPresenter = A.Fake <IPopulationDistributionPresenter>();
            _population             = A.Fake <Population>();
            _projectChangedNotifier = A.Fake <IProjectChangedNotifier>();

            _gender1 = A.Fake <Gender>().WithName("Gender1");
            _gender2 = A.Fake <Gender>().WithName("Gender2");
            A.CallTo(() => _population.AllGenders()).Returns(new[] { _gender1, _gender2 });
            A.CallTo(() => _representationInfoRepository.DisplayNameFor(_gender1)).Returns("Display1");
            A.CallTo(() => _representationInfoRepository.DisplayNameFor(_gender2)).Returns("Display2");


            _allParameters      = new List <IParameter>();
            _allParametersCache = new PathCacheForSpecs <IParameter>();
            A.CallTo(() => _population.AllVectorialParameters(_entityPathResolver)).Returns(_allParameters);
            A.CallTo(() => _population.AllParameters(_entityPathResolver)).Returns(_allParametersCache);
            A.CallTo(() => _popParameterDistributionPresenter.Plot(_population, A <IParameter> ._, A <DistributionSettings> ._, A <IDimension> ._, A <Unit> ._))
            .Invokes(x => _settings = x.GetArgument <DistributionSettings>(2));


            sut = new PopulationAdvancedParameterDistributionPresenter(_view, _parametersPresenter,
                                                                       _representationInfoRepository, _entityPathResolver, _popParameterDistributionPresenter, _projectChangedNotifier);
        }
Example #5
0
        protected override void Context()
        {
            base.Context();

            _gaussData        = new DataTable();
            _distributionData = A.Fake <ContinuousDistributionData>();

            A.CallTo(_normalDistributionDataCreator).WithReturnType <DataTable>().Returns(_gaussData);

            A.CallTo(() => _histogramView.BindTo(_gaussData, _distributionData, A <DistributionSettings> ._))
            .Invokes(x => _distributionSettings = x.GetArgument <DistributionSettings>(2));

            _badResult  = A.Fake <ParameterIdentificationRunResult>();
            _goodResult = A.Fake <ParameterIdentificationRunResult>();

            A.CallTo(() => _badResult.TotalError).Returns(5);
            A.CallTo(() => _goodResult.TotalError).Returns(1);

            _parameterIdentification.AddResult(_badResult);
            _parameterIdentification.AddResult(_goodResult);

            A.CallTo(() => _residualDataCreator.CreateFor(_goodResult.BestResult)).Returns(_distributionData);

            _residuals = new [] { 10d, 20d, 30d };
            A.CallTo(() => _goodResult.BestResult.AllResidualValues).Returns(_residuals);
        }
 private void updateDiagramFromSettings(DistributionSettings settings)
 {
     AxisX.Title.Text       = settings.XAxisTitle;
     AxisX.Title.Visibility = DefaultBoolean.True;
     AxisY.Title.Text       = settings.YAxisTitle;
     AxisY.Title.Visibility = DefaultBoolean.True;
 }
Example #7
0
        public DistributionSettingsBinding(ExpressionArgument owner, DistributionSettings instance, PropertyInfo propertyInfo)
        {
            _owner        = owner;
            _instance     = instance;
            _propertyInfo = propertyInfo;

            Name = TranslationSource.Instance[_propertyInfo.Name];
        }
Example #8
0
 public PreferencesWindowVM(IVersionProvider versionProvider, IWorkingDirProvider workingDirProvider, DistributionSettings distributionSettings)
 {
     _versionProvider     = versionProvider;
     _workingDirProvider  = workingDirProvider;
     DistributionSettings = distributionSettings;
     OpenWorkingDirCmd    = new Command(OnOpenWorkingDir, null, HandleError);
     OpenContributeCmd    = new Command(OnOpenContribute, null, HandleError);
     InitDefaults();
 }
Example #9
0
        public void Update(ExpressionArgument source, DistributionSettings settings)
        {
            Clear();

            var properties = settings.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public)
                             .Where(x => x.CanWrite && x.CanRead);

            foreach (var property in properties)
            {
                Add(new DistributionSettingsBinding(source, settings, property));
            }
        }
        public CommonDistributionSettingsForm(DistributionSettings settings)
        {
            InitializeComponent();

            Text           = Languages.GetText("DistributionSettings");
            btnOk.Text     = Languages.GetText("ButtonOk");
            btnCancel.Text = Languages.GetText("ButtonCancel");

            _labels    = new Label[] { lbParameter0, lbParameter1, lbParameter2, lbParameter3, lbParameter4 };
            _textBoxes = new TextBox[] { txtParameter0, txtParameter1, txtParameter2, txtParameter3, txtParameter4 };

            _settings = settings;
            OnSettingsSet(settings);
        }
            public SettingsMembers(Label nameHolder, TextBox valueHolder, DistributionSettings owner, PropertyInfo info)
            {
                var name = Languages.GetText(info.Name);

                nameHolder.Text  = name;
                valueHolder.Text = info.GetValue(owner, null)?.ToString();

                nameHolder.Visible  = true;
                valueHolder.Visible = true;

                NameHolder  = nameHolder;
                ValueHolder = valueHolder;
                Owner       = owner;
                Info        = info;
            }
        private void OnSettingsSet(DistributionSettings distributionSettings)
        {
            var properties = distributionSettings.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).Where(x => x.CanRead && x.CanWrite).ToArray();


            if (properties.Length > _labels.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(properties));
            }

            for (int i = 0; i < properties.Length; i++)
            {
                PropertyInfo property = properties[i];

                _members.Add(new SettingsMembers(_labels[i], _textBoxes[i], distributionSettings, property));
            }
        }
        public void Plot(ContinuousDistributionData distributionData, DistributionSettings settings)
        {
            ResetPlot();
            plot(distributionData, settings);

            if (!distributionData.IsRangeSpecified)
            {
                return;
            }

            var templateView = SeriesTemplate.View as BarSeriesView;

            if (templateView != null)
            {
                templateView.BarWidth = distributionData.BarWidth;
            }

            AxisX.WholeRange.SetMinMaxValues(distributionData.XMinValue, distributionData.XMaxValue);
        }
Example #14
0
        private void plotContinousData <TObject>(IPopulationDataCollector populationDataCollector, TObject objectToPlot, INumericValueField numericValueField,
                                                 Func <IPopulationDistributionPresenter, Action <IPopulationDataCollector, TObject, DistributionSettings, IDimension, Unit> > plotFunc)
            where TObject : class, IWithDimension

        {
            if (objectToPlot == null)
            {
                return;
            }

            var displayUnit = _displayUnitRetriever.PreferredUnitFor(objectToPlot);
            var dimension   = objectToPlot.Dimension;
            var settings    = new DistributionSettings();

            if (numericValueField != null)
            {
                displayUnit          = numericValueField.DisplayUnit;
                settings.PlotCaption = numericValueField.Name;
                dimension            = _dimensionRepository.MergedDimensionFor(new NumericFieldContext(numericValueField, populationDataCollector));
            }
            plotFunc(_populationDistributionPresenter)(populationDataCollector, objectToPlot, settings, dimension, displayUnit);
        }
Example #15
0
        public void BindTo(DataTable gaussData, ContinuousDistributionData distributionData, DistributionSettings settings)
        {
            chart.Series.Clear();
            var gaussSeries = createGaussSeriesFor(gaussData);

            //need to add it before creating the seconday axis. Need to be added BEFORE the distribution to be put in the front
            chart.Series.Add(gaussSeries);

            var secondaryAxis = getOrCreateSecondaryAxis();

            setGaussSeriesOptions(gaussSeries, secondaryAxis);

            chart.Plot(distributionData, settings);

            //need to add it once a again to actually see it
            chart.Series.Add(gaussSeries);
        }
Example #16
0
 public ParameterDistributionSettings()
 {
     Settings = new DistributionSettings();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ContinuousDistribution"/> class.
 /// by <paramref name="distributionSettings"/> and samples count.
 /// </summary>
 /// <param name="distributionSettings">Distribution settings.</param>
 /// <param name="samples">Samples count used in method <see cref="Discretize"/>.</param>
 public ContinuousDistribution(DistributionSettings distributionSettings, int samples)
     : this(distributionSettings?.GetUnivariateContinuoisDistribution(), samples)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ContinuousDistribution"/> class
 /// by <paramref name="distributionSettings"/>.
 /// </summary>
 /// <param name="distributionSettings">Distribution settings.</param>
 public ContinuousDistribution(DistributionSettings distributionSettings)
     : this(distributionSettings?.GetUnivariateContinuoisDistribution())
 {
 }
Example #19
0
        private ContinuousDistributionData generateContinuousDistributionData(double minimum, double maximum, int bins, int valueCount, DistributionSettings settings)
        {
            List <double> values = createValues(valueCount, minimum, maximum).ToList();

            var allIntervals = _binIntervalsCreator.CreateUniformIntervalsFor(values, bins);
            var data         = new ContinuousDistributionData(settings.AxisCountMode, allIntervals.Count);

            foreach (var interval in allIntervals)
            {
                var currentInterval = interval;

                double count = values.Count(x => currentInterval.Contains(x));

                data.AddData(currentInterval.MeanValue, count);
            }

            data.XMinData = values.Min();
            data.XMaxData = values.Max();

            return(data);
        }
Example #20
0
        public void Plot()
        {
            var distributionSettings = new DistributionSettings();

            _view.PlotPopulationData(generateContinuousDistributionData(Minimum, Maximum, Bins, ValueCount, distributionSettings), distributionSettings);
        }
 public ExpressionArgument(string arg, DistributionSettings settings)
     : this(arg, settings.GetType())
 {
     DistributionSettings = settings;
 }
Example #22
0
 public DistributionFunctionArgument(string arg, DistributionSettings settings)
 {
     Argument             = arg;
     _settingType         = settings.GetType();
     DistributionSettings = settings;
 }
 public void BindToPlotOptions(DistributionSettings settings)
 {
     _screenBinder.BindToSource(settings);
 }
Example #24
0
 public void PlotPopulationData(ContinuousDistributionData distributionData, DistributionSettings distributionSettings)
 {
     uxHistogramControl.Plot(distributionData, distributionSettings);
 }