private void Check(object sender, EventArgs e)
        {
            ArgsTrend sel;

            try
            {
                sel = this.GetSelection();
            }
            catch
            {
                sel = null;
            }

            bool valid = sel != null;

            this._txtName.Watermark = sel != null ? sel.DefaultDisplayName : Texts.default_name;

            this._lnkError.Visible = false;

            if (sel != null)
            {
                StylisedPeak sPeak = new StylisedPeak(this._previewPeak);

                ConfigurationTrend temporary = new ConfigurationTrend()
                {
                    Args = sel
                };
                IntensityMatrix source = this._ecbSource.SelectedItem.Provide;

                if (this._previewPeak != null)
                {
                    try
                    {
                        sPeak.OverrideDefaultOptions = new StylisedPeakOptions(this._core)
                        {
                            SelectedTrend = temporary
                        };
                        this._chart1.Plot(sPeak);
                    }
                    catch (Exception ex)
                    {
                        this._lnkError.Visible       = true;
                        this._lnkError.Tag           = ex.ToString();
                        sPeak.OverrideDefaultOptions = null;
                        this._chart1.Plot(sPeak);
                    }
                }
            }

            this._btnOk.Enabled      = valid;
            this._tlpPreview.Visible = valid;
        }
Beispiel #2
0
        public StylisedPeakOptions(Core core)
        {
            CoreOptions visualOptions = core.Options;

            this.ShowRanges                      = visualOptions.ShowVariableRanges;
            this.ShowMinMax                      = visualOptions.ShowVariableMinMax;
            this.ViewGroups                      = visualOptions.ViewTypes;
            this.ViewBatches                     = core.Batches;
            this.ConditionsSideBySide            = visualOptions.ConditionsSideBySide;
            this.ShowPoints                      = visualOptions.ShowPoints;
            this.ShowTrend                       = visualOptions.ShowTrend;
            this.ShowAcqisition                  = visualOptions.ViewAcquisition;
            this.ShowVariableMean                = visualOptions.ShowVariableMean;
            this.DrawExperimentalGroupAxisLabels = visualOptions.DrawExperimentalGroupAxisLabels;
            this.SelectedTrend                   = visualOptions.SelectedTrend;
        }
Beispiel #3
0
        public void Plot(StylisedPeak stylisedPeak)
        {
            // Get observations
            Vector vector;

            if (stylisedPeak.ForceObservations != null)
            {
                vector = stylisedPeak.ForceObservations;
            }
            else
            {
                IntensityMatrix matrix = this._core.Options.SelectedMatrix;

                if (matrix == null)
                {
                    vector = null;
                }
                else
                {
                    vector = matrix.Find(stylisedPeak.Peak);
                }
            }

            Debug.WriteLine("PeakPlot: " + stylisedPeak);
            Dictionary <string, MCharting.Series> seriesNames = new Dictionary <string, MCharting.Series>();
            Peak peak = stylisedPeak?.Peak;

            // Clear plot
            MCharting.Plot plot = this.PrepareNewPlot(stylisedPeak != null && !stylisedPeak.IsPreview, peak, vector?.Source);

            try // <- CompletNewPlot
            {
                // Get selection
                this.SelectedPeak = peak;
                this.SetCaption("Plot of {0}.", peak);

                if (peak == null)
                {
                    return;
                }

                // Get options
                StylisedPeakOptions opts = stylisedPeak.OverrideDefaultOptions ?? new StylisedPeakOptions(this._core);

                // Get order data
                ObservationInfo[] obsOrder = this._core.Observations.ToArray();

                // Group legends
                IEnumerable <GroupInfoBase> order = opts.ShowAcqisition ? (IEnumerable <GroupInfoBase>)opts.ViewBatches : (IEnumerable <GroupInfoBase>)opts.ViewGroups;
                Dictionary <GroupInfoBase, MCharting.Series> groupLegends = this.DrawLegend(plot, order);

                if (vector == null)
                {
                    return;
                }

                // Show acquisition and batches?
                if (opts.ShowAcqisition)
                {
                    // --- RAW DATA (points) ---
                    MCharting.Series legendEntry = new MCharting.Series();
                    legendEntry.Name             = "Observations";
                    legendEntry.Style.DrawPoints = new SolidBrush(Color.Black);
                    plot.LegendEntries.Add(legendEntry);

                    this.AddToPlot(plot, peak, seriesNames, vector, "Raw data", opts, EPlot.ByBatch, groupLegends, legendEntry);

                    // --- TREND (thick line) ---
                    if (stylisedPeak.ForceTrend != null)
                    {
                        MCharting.Series legendEntry2 = new MCharting.Series();
                        legendEntry2.Name                  = "Trend";
                        legendEntry2.Style.DrawLines       = new Pen(Color.Black, this._core.Options.LineWidth);
                        legendEntry2.Style.DrawLines.Width = 4;
                        plot.LegendEntries.Add(legendEntry2);

                        this.AddToPlot(plot, peak, seriesNames, stylisedPeak.ForceTrend, "Trend data", opts, EPlot.ByBatch | EPlot.DrawLine | EPlot.DrawBold, groupLegends, legendEntry2);
                    }

                    this.DrawLabels(plot, opts.ConditionsSideBySide, order, opts.DrawExperimentalGroupAxisLabels);
                    return;
                }

                // Sort data
                ConfigurationTrend trend = opts.SelectedTrend;
                Vector             avg   = stylisedPeak.ForceTrend ?? trend.CreateTrend(this._core, vector);
                Vector             min   = MinSmoother.CreateTrend(this._core, vector);
                Vector             max   = MaxSmoother.CreateTrend(this._core, vector);

                // --- PLOT MEAN & SD (lines across)
                if (opts.ShowVariableMean)
                {
                    this.AddMeanAndSdLines(plot, opts, vector.Values, peak, groupLegends);
                }

                // --- RANGE (shaded area) ---
                if (opts.ShowRanges)
                {
                    this.AddUpperAndLowerShade(plot, opts, seriesNames, peak, min, max, groupLegends);
                }

                // --- RAW DATA (points) ---
                if (opts.ShowPoints && !stylisedPeak.IsPreview)
                {
                    MCharting.Series legendEntry = new MCharting.Series();
                    legendEntry.Name             = "Observations";
                    legendEntry.Style.DrawPoints = new SolidBrush(Color.Black);
                    plot.LegendEntries.Add(legendEntry);

                    this.AddToPlot(plot, peak, seriesNames, vector, "Raw data", opts, EPlot.None, groupLegends, legendEntry);
                }

                // --- RANGE (lines) ---
                if (opts.ShowMinMax)
                {
                    MCharting.Series legendEntry = new MCharting.Series();
                    legendEntry.Name            = "Range min/max";
                    legendEntry.Style.DrawLines = new Pen(Color.Gray, this._core.Options.LineWidth);
                    plot.LegendEntries.Add(legendEntry);

                    this.AddToPlot(plot, peak, seriesNames, min, "Min value", opts, EPlot.DrawLine, groupLegends, legendEntry);
                    this.AddToPlot(plot, peak, seriesNames, max, "Max value", opts, EPlot.DrawLine, groupLegends, legendEntry);
                }

                // --- TREND (thick line) ---
                if (opts.ShowTrend)
                {
                    MCharting.Series legendEntry = new MCharting.Series();
                    legendEntry.Name                  = "Trend";
                    legendEntry.Style.DrawLines       = new Pen(Color.Black, this._core.Options.LineWidth);
                    legendEntry.Style.DrawLines.Width = this._core.Options.LineWidth * 4;
                    plot.LegendEntries.Add(legendEntry);

                    this.AddToPlot(plot, peak, seriesNames, avg, "Trend data", opts, EPlot.DrawLine | EPlot.DrawBold, groupLegends, legendEntry);
                }

                // --- LABELS ---
                this.DrawLabels(plot, opts.ConditionsSideBySide, order, opts.DrawExperimentalGroupAxisLabels);
            }
            finally
            {
                this.CompleteNewPlot(plot);
            }
        }