Exemple #1
0
        /// <summary>
        ///   Forces a update of the scatter plot.
        /// </summary>
        ///
        public void UpdateGraph()
        {
            zedGraphControl.GraphPane.Title.Text       = scatterplot.Title;
            zedGraphControl.GraphPane.XAxis.Title.Text = scatterplot.XAxisTitle;
            zedGraphControl.GraphPane.YAxis.Title.Text = scatterplot.YAxisTitle;

            classes.Clear();

            if (scatterplot.Classes != null)
            {
                if (scatterplot.Classes.Count == 0)
                {
                    zedGraphControl.GraphPane.Legend.IsVisible = false;

                    // Create space for unlabelled data
                    PointPairList list = new PointPairList(scatterplot.XAxis, scatterplot.YAxis);

                    LineItem item = new LineItem(String.Empty, list, Color.Black, SymbolType.Default);

                    item.Line.IsVisible          = false;
                    item.Symbol.Border.IsVisible = false;
                    item.Symbol.Fill             = new Fill(Color.Black);

                    classes.Add(item);
                }
                else
                {
                    zedGraphControl.GraphPane.Legend.IsVisible = true;
                    var colors = new ColorSequenceCollection(scatterplot.Classes.Count);

                    // Create a curve item for each of the labels
                    for (int i = 0; i < scatterplot.Classes.Count; i++)
                    {
                        // retrieve the x,y pairs for the label
                        double[]      x    = scatterplot.Classes[i].XAxis;
                        double[]      y    = scatterplot.Classes[i].YAxis;
                        PointPairList list = new PointPairList(x, y);

                        LineItem item = new LineItem(scatterplot.Classes[i].Label.ToString(),
                                                     list, colors[i], SymbolType.Default);

                        item.Line.IsVisible          = false;
                        item.Symbol.Border.IsVisible = false;
                        item.Symbol.Fill             = new Fill(colors[i]);

                        classes.Add(item);
                    }
                }

                zedGraphControl.AxisChange();
                zedGraphControl.Invalidate();

                zedGraphControl.ZoomPane(zedGraphControl.GraphPane, 1.1, PointF.Empty, false);
            }
        }
Exemple #2
0
        private static DataBarBox show(string title, string[] labels, double[][] series)
        {
            DataBarBox form       = null;
            Thread     formThread = null;

            if (title == null)
            {
                title = "Bar chart";
            }

            double[] x = Matrix.Indices(0, labels.Length).ToDouble();

            AutoResetEvent stopWaitHandle = new AutoResetEvent(false);

            formThread = new Thread(() =>
            {
                BestCS.Controls.Tools.ConfigureWindowsFormsApplication();

                // Show control in a form
                form            = new DataBarBox();
                form.Text       = title;
                form.formThread = formThread;

                var sequence = new ColorSequenceCollection(series.Length);

                for (int i = 0; i < series.Length; i++)
                {
                    form.series.Add(new BarItem(i.ToString(), x,
                                                series[i], sequence.GetColor(i)));
                }

                form.zedGraphControl.GraphPane.Title.Text             = title;
                form.zedGraphControl.GraphPane.XAxis.Type             = AxisType.Text;
                form.zedGraphControl.GraphPane.XAxis.Scale.TextLabels = labels;
                form.zedGraphControl.GraphPane.XAxis.Scale.MajorStep  = 1;
                form.zedGraphControl.GraphPane.AxisChange();

                stopWaitHandle.Set();

                Application.Run(form);
            });

            formThread.SetApartmentState(ApartmentState.STA);

            formThread.Start();

            stopWaitHandle.WaitOne();

            return(form);
        }
Exemple #3
0
        /// <summary>
        ///   Constructs a new instance of the ScatterplotView.
        /// </summary>
        ///
        public ComponentView()
        {
            InitializeComponent();

            zedGraphControl.GraphPane.Title.Text            = "Components";
            zedGraphControl.GraphPane.Title.FontSpec.Size   = 24f;
            zedGraphControl.GraphPane.Title.FontSpec.Family = "Tahoma";

            zedGraphControl.GraphPane.XAxis.Title.Text = "Components";
            zedGraphControl.GraphPane.YAxis.Title.Text = "Percentage";

            zedGraphControl.BorderStyle = System.Windows.Forms.BorderStyle.None;
            zedGraphControl.GraphPane.Border.IsVisible = false;
            zedGraphControl.GraphPane.Border.Color     = Color.White;
            zedGraphControl.GraphPane.Border.Width     = 0;
            zedGraphControl.GraphPane.Fill             = new Fill(Color.White);
            zedGraphControl.GraphPane.Chart.Fill       = new Fill(Color.GhostWhite);

            zedGraphControl.GraphPane.Legend.IsVisible           = false;
            zedGraphControl.GraphPane.Legend.Position            = LegendPos.Right;
            zedGraphControl.GraphPane.Legend.IsShowLegendSymbols = false;

            zedGraphControl.GraphPane.XAxis.Scale.MinAuto = true;
            zedGraphControl.GraphPane.XAxis.Scale.MaxAuto = true;
            zedGraphControl.GraphPane.YAxis.Scale.MinAuto = true;
            zedGraphControl.GraphPane.YAxis.Scale.MaxAuto = true;
            zedGraphControl.GraphPane.XAxis.Scale.MagAuto = true;
            zedGraphControl.GraphPane.YAxis.Scale.MagAuto = true;


            zedGraphControl.GraphPane.Chart.Fill.Type  = FillType.None;
            zedGraphControl.GraphPane.Legend.IsVisible = false;

            zedGraphControl.GraphPane.Title.FontSpec.Size   = 24f;
            zedGraphControl.GraphPane.Title.FontSpec.Family = "Tahoma";

            colors = new ColorSequenceCollection();
        }
Exemple #4
0
        private static WavechartBox show(String title, bool hold, params Tuple <Signal, int>[] series)
        {
            WavechartBox form       = null;
            Thread       formThread = null;

            AutoResetEvent stopWaitHandle = new AutoResetEvent(false);

            formThread = new Thread(() =>
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                // Show control in a form
                form            = new WavechartBox();
                form.Text       = title;
                form.formThread = formThread;

                if (!String.IsNullOrEmpty(title))
                {
                    form.zedGraphControl.GraphPane.Title.IsVisible = true;
                    form.zedGraphControl.GraphPane.Title.Text      = title;
                }

                var sequence = new ColorSequenceCollection(series.Length);

                for (int i = 0; i < series.Length; i++)
                {
                    var signal  = series[i].Item1;
                    int channel = series[i].Item2;

                    ComplexSignal complex = signal as ComplexSignal;

                    if (complex != null && complex.Status != ComplexSignalStatus.Normal)
                    {
                        double[] spectrum    = BestCS.Audio.Tools.GetPowerSpectrum(complex.GetChannel(channel));
                        double[] frequencies = BestCS.Audio.Tools.GetFrequencyVector(signal.Length, signal.SampleRate);

                        form.series.Add(new LineItem(i.ToString(), frequencies,
                                                     spectrum, sequence.GetColor(i), SymbolType.None));

                        form.zedGraphControl.GraphPane.XAxis.Title.Text = "Frequency";
                        form.zedGraphControl.GraphPane.YAxis.Title.Text = "Power";
                    }
                    else
                    {
                        double[] values;
                        if (signal.Channels == 1)
                        {
                            values = signal.ToDouble();
                        }
                        else
                        {
                            ExtractChannel extract = new ExtractChannel(channel);
                            values = extract.Apply(signal).ToDouble();
                        }

                        form.series.Add(new LineItem(i.ToString(), Matrix.Indices(0, signal.Length).ToDouble(),
                                                     values, sequence.GetColor(i), SymbolType.None));

                        form.zedGraphControl.GraphPane.XAxis.Title.Text = "Time";
                        form.zedGraphControl.GraphPane.YAxis.Title.Text = "Amplitude";
                    }
                }

                form.zedGraphControl.GraphPane.AxisChange();

                stopWaitHandle.Set();

                Application.Run(form);
            });

            formThread.SetApartmentState(ApartmentState.STA);

            formThread.Start();

            stopWaitHandle.WaitOne();

            if (!hold)
            {
                formThread.Join();
            }

            return(form);
        }
Exemple #5
0
        private static DataSeriesBox show(String title, double[] x, double[][] series,
                                          bool time = false)
        {
            DataSeriesBox form       = null;
            Thread        formThread = null;

            if (title == null)
            {
                title = "Time series";
            }

            x = (double[])x.Clone();
            var idx = Matrix.Indices(0, x.Length);

            Array.Sort(x, idx);

            for (int i = 0; i < series.Length; i++)
            {
                series[i] = series[i].Submatrix(idx);
            }

            AutoResetEvent stopWaitHandle = new AutoResetEvent(false);

            formThread = new Thread(() =>
            {
                BestCS.Controls.Tools.ConfigureWindowsFormsApplication();

                // Show control in a form
                form            = new DataSeriesBox();
                form.Text       = title;
                form.formThread = formThread;

                var pane = form.zedGraphControl.GraphPane;

                if (time)
                {
                    pane.XAxis.Type            = AxisType.Date;
                    pane.XAxis.Scale.MajorUnit = DateUnit.Hour;
                    pane.XAxis.Scale.Format    = "T";
                }

                var sequence = new ColorSequenceCollection(series.Length);

                for (int i = 0; i < series.Length; i++)
                {
                    if (x == null)
                    {
                        x = Matrix.Indices(0, series[i].Length).ToDouble();
                    }

                    var lineItem = new LineItem(i.ToString(), x,
                                                series[i], sequence.GetColor(i), SymbolType.None);

                    form.series.Add(lineItem);
                }

                pane.Title.Text = title;
                pane.AxisChange();

                stopWaitHandle.Set();

                Application.Run(form);
            });

            formThread.SetApartmentState(ApartmentState.STA);

            formThread.Start();

            stopWaitHandle.WaitOne();

            return(form);
        }