public PlotPanel(PersistentSettings settings, UnitManager unitManager) {
      this.settings = settings;
      this.unitManager = unitManager;

      this.model = CreatePlotModel();

      this.plot = new Plot();
      this.plot.Dock = DockStyle.Fill;
      this.plot.Model = model;
      this.plot.BackColor = Color.White;
      this.plot.ContextMenu = CreateMenu();

      UpdateAxesPosition();

      this.SuspendLayout();
      this.Controls.Add(plot);
      this.ResumeLayout(true);
    }
Exemplo n.º 2
0
        private void MakeIOSignalsGraphics(List <List <string> > ioSignals, List <DateTime> dateTimes)
        {
            this.Invoke((MethodInvoker) delegate
            {
                int rowCount = _checkedIOIndexes.Count;
                if (rowCount == 0)
                {
                    rowCount = 1;
                }
                //plots
                var tlpIOplots             = new TableLayoutPanel();
                tlpIOplots.Dock            = DockStyle.Fill;
                tlpIOplots.CellBorderStyle = TableLayoutPanelCellBorderStyle.Outset;
                tlpIOplots.ColumnCount     = 1;
                tlpIOplots.RowCount        = rowCount;
                for (int i = 0; i < rowCount; i++)
                {
                    tlpIOplots.RowStyles.Add(new RowStyle());
                }
                float rowHight = 100 / rowCount;
                TableLayoutRowStyleCollection styles = tlpIOplots.RowStyles;
                foreach (RowStyle style in styles)
                {
                    style.SizeType = SizeType.Percent;
                    style.Height   = rowHight;
                }
                panelIOplots.Controls.Clear();
                panelIOplots.Controls.Add(tlpIOplots);
                _ioSeries[0] = new LineSeries {
                    StrokeThickness = 1, Color = OxyColors.Blue, MarkerType = MarkerType.Circle, MarkerStroke = OxyColors.Blue, MarkerFill = OxyColors.Blue, MarkerSize = 2
                };
                _ioSeries[1] = new LineSeries {
                    StrokeThickness = 1, Color = OxyColors.Magenta, MarkerType = MarkerType.Circle, MarkerStroke = OxyColors.Magenta, MarkerFill = OxyColors.Magenta, MarkerSize = 2
                };
                _ioSeries[2] = new LineSeries {
                    StrokeThickness = 1, Color = OxyColors.Green, MarkerType = MarkerType.Circle, MarkerStroke = OxyColors.Green, MarkerFill = OxyColors.Green, MarkerSize = 2
                };
                _ioSeries[3] = new LineSeries {
                    StrokeThickness = 1, Color = OxyColors.IndianRed, MarkerType = MarkerType.Circle, MarkerStroke = OxyColors.IndianRed, MarkerFill = OxyColors.IndianRed, MarkerSize = 2
                };
                _ioSeries[4] = new LineSeries {
                    StrokeThickness = 1, Color = OxyColors.DarkOrange, MarkerType = MarkerType.Circle, MarkerStroke = OxyColors.DarkOrange, MarkerFill = OxyColors.DarkOrange, MarkerSize = 2
                };
                _ioSeries[5] = new LineSeries {
                    StrokeThickness = 1, Color = OxyColors.Yellow, MarkerType = MarkerType.Circle, MarkerStroke = OxyColors.Yellow, MarkerFill = OxyColors.Yellow, MarkerSize = 2
                };
                _ioSeries[6] = new LineSeries {
                    StrokeThickness = 1, Color = OxyColors.Red, MarkerType = MarkerType.Circle, MarkerStroke = OxyColors.Red, MarkerFill = OxyColors.Red, MarkerSize = 2
                };
                _ioSeries[7] = new LineSeries {
                    StrokeThickness = 1, Color = OxyColors.LimeGreen, MarkerType = MarkerType.Circle, MarkerStroke = OxyColors.LimeGreen, MarkerFill = OxyColors.LimeGreen, MarkerSize = 2
                };
                _ioSeries[8] = new LineSeries {
                    StrokeThickness = 1, Color = OxyColors.DeepSkyBlue, MarkerType = MarkerType.Circle, MarkerStroke = OxyColors.DeepSkyBlue, MarkerFill = OxyColors.DeepSkyBlue, MarkerSize = 2
                };
                _ioSeries[9] = new LineSeries {
                    StrokeThickness = 1, Color = OxyColors.BlueViolet, MarkerType = MarkerType.Circle, MarkerStroke = OxyColors.BlueViolet, MarkerFill = OxyColors.BlueViolet, MarkerSize = 2
                };
                for (int i = 0; i < _checkedIOIndexes.Count; i++)
                {
                    xAxis[i] = new DateTimeAxis(AxisPosition.Bottom, dateTimes[0], dateTimes[dateTimes.Count - 1], null, null, DateTimeIntervalType.Auto)
                    {
                        MajorGridlineStyle = LineStyle.Solid,
                        MinorGridlineStyle = LineStyle.Dot,
                        //Title = "Дата",
                        StringFormat  = "dd-MM-yyyy HH:mm:ss",
                        FontSize      = 10,
                        IsZoomEnabled = true,
                        MajorStep     = 1.0 / 24 / 60 / 2,
                        MinorStep     = 1.0 / 24 / 60 / 12,
                        Minimum       = DateTimeAxis.ToDouble(dateTimes[0]),
                        Maximum       = DateTimeAxis.ToDouble(dateTimes[dateTimes.Count - 1])
                    };
                    yAxis[i] = new LinearAxis(AxisPosition.Left, 0)
                    {
                        MajorGridlineStyle = LineStyle.Solid,
                        MinorGridlineStyle = LineStyle.Dot,
                        Title        = "value",
                        StringFormat = "00#",
                        Minimum      = -0.2,
                        Maximum      = 1.2
                    };
                    plotIOSignals[i] = new OxyPlot.WindowsForms.Plot {
                        Model = new PlotModel(), Dock = DockStyle.Fill
                    };
                    plotIOSignals[i].Model.PlotType = PlotType.XY;
                    plotIOSignals[i].Model.Axes.Clear();
                    plotIOSignals[i].Model.Axes.Add(xAxis[i]);
                    plotIOSignals[i].Model.Axes.Add(yAxis[i]);
                    //annotations
                    lineAnnotationsIO[i] = new LineAnnotation {
                        Type = LineAnnotationType.Vertical, Color = OxyColors.Brown, Layer = AnnotationLayer.BelowSeries
                    };
                    lineAnnotationsIO[i].X = lineAnnotationVertical.X;

                    /* lineAnnotationsIO[i].MouseDown += (s, e) =>
                     * {
                     *   if (e.ChangedButton != OxyMouseButton.Left)
                     *   {
                     *       return;
                     *   }
                     *   if (_isMarkersActive == 1)
                     *   {
                     *       lineAnnotationsIO[i].StrokeThickness *= 3;
                     *       plotIOSignals[i].Model.InvalidatePlot(false);
                     *       e.Handled = true;
                     *   }
                     * };
                     * lineAnnotationsIO[i].MouseMove += (s, e) =>
                     * {
                     *   if (_isMarkersActive == 1)
                     *   {
                     *       lineAnnotationsIO[i].X = lineAnnotationsIO[i].InverseTransform(e.Position).X;
                     *       plotIOSignals[i].Model.InvalidatePlot(false);
                     *       e.Handled = true;
                     *   }
                     * };
                     * lineAnnotationsIO[i].MouseUp += (s, e) =>
                     * {
                     *   if (_isMarkersActive == 1)
                     *   {
                     *       lineAnnotationsIO[i].StrokeThickness /= 3;
                     *       plotIOSignals[i].Model.InvalidatePlot(false);
                     *       e.Handled = true;
                     *   }
                     * }; */
                    plotIOSignals[i].Model.Annotations.Add(lineAnnotationsIO[i]);
                }
                for (int i = 0; i < _ioSeries.Count(); i++)
                {
                    _ioSeries[i].Points.Clear();
                }
                for (int i = 0; i < _checkedIOIndexes.Count; i++)
                {
                    plotIOSignals[i].Model.Series.Clear();
                }
                for (int i = 0; i < _checkedIOIndexes.Count; i++)
                {
                    for (int j = 0; j < dateTimes.Count; j++)
                    {
                        if (ioSignals[_checkedIOIndexes[i]][j] != "нет данных")
                        {
                            _ioSeries[i].Points.Add(new DataPoint(DateTimeAxis.ToDouble(dateTimes[j]), Convert.ToDouble(ioSignals[_checkedIOIndexes[i]][j])));
                        }
                    }
                }
                for (int i = 0; i < _checkedIOIndexes.Count; i++)
                {
                    plotIOSignals[i].Model.Series.Add(_ioSeries[i]);
                    plotIOSignals[i].InvalidatePlot(true);
                    tlpIOplots.Controls.Add(plotIOSignals[i], 0, i);
                }
            });
        }
Exemplo n.º 3
0
        private void MakeAnalogSignalsGraphic(List <List <List <string> > > analogSignals, List <DateTime> dateTimes)
        {
            this.Invoke((MethodInvoker) delegate
            {
                plotAnalogSignals = new OxyPlot.WindowsForms.Plot {
                    Model = new PlotModel(), Dock = DockStyle.Fill
                };
                panel1.Controls.Clear();
                plotAnalogSignals.Model.PlotType = PlotType.XY;
                int oc = comboBoxOC.SelectedIndex;

                //Legend
                //Axis
                plotAnalogSignals.Model.Axes.Clear();
                var xAxis = new DateTimeAxis(AxisPosition.Bottom, dateTimes[0], dateTimes[dateTimes.Count - 1], null, null, DateTimeIntervalType.Auto)
                {
                    MajorGridlineStyle = LineStyle.Solid,
                    MinorGridlineStyle = LineStyle.Dot,
                    //Title = "Дата",
                    StringFormat  = "dd-MM-yyyy HH:mm:ss",
                    FontSize      = 10,
                    IsZoomEnabled = true,
                    MajorStep     = 1.0 / 24 / 60 / 2,
                    MinorStep     = 1.0 / 24 / 60 / 12,
                    Minimum       = DateTimeAxis.ToDouble(dateTimes[0]),
                    Maximum       = DateTimeAxis.ToDouble(dateTimes[dateTimes.Count - 1])
                };
                plotAnalogSignals.Model.Axes.Add(xAxis);
                var yAxis = new LinearAxis(AxisPosition.Left, 0)
                {
                    MajorGridlineStyle = LineStyle.Solid,
                    MinorGridlineStyle = LineStyle.Dot,
                    Title   = "%",
                    Minimum = -100,
                    Maximum = 100
                };
                plotAnalogSignals.Model.Axes.Add(yAxis);
                plotAnalogSignals.Model.Axes[0].AxisChanged += new EventHandler <AxisChangedEventArgs>(xAxis_AxisChanged);
                //annotations
                lineAnnotationVertical = new LineAnnotation {
                    Type = LineAnnotationType.Vertical, Color = OxyColors.Brown, Layer = AnnotationLayer.BelowSeries
                };
                lineAnnotationVertical.X          = DateTimeAxis.ToDouble(dateTimes[1]);
                lineAnnotationVertical.MouseDown += (s, e) =>
                {
                    if (e.ChangedButton != OxyMouseButton.Left)
                    {
                        return;
                    }
                    if (_isMarkersActive == 1)
                    {
                        lineAnnotationVertical.StrokeThickness *= 3;
                        plotAnalogSignals.Model.InvalidatePlot(false);
                        e.Handled = true;
                        if (_plotsSynchronized == 1)
                        {
                            for (int i = 0; i < _checkedIOIndexes.Count; i++)
                            {
                                lineAnnotationsIO[i].StrokeThickness *= 3;
                                plotIOSignals[i].Model.InvalidatePlot(false);
                            }
                        }
                    }
                };
                lineAnnotationVertical.MouseMove += (s, e) =>
                {
                    if (_isMarkersActive == 1)
                    {
                        lineAnnotationVertical.X = lineAnnotationVertical.InverseTransform(e.Position).X;
                        plotAnalogSignals.Model.InvalidatePlot(false);
                        e.Handled = true;
                        if (_plotsSynchronized == 1)
                        {
                            for (int i = 0; i < _checkedIOIndexes.Count; i++)
                            {
                                lineAnnotationsIO[i].X = lineAnnotationVertical.X;
                                plotIOSignals[i].Model.InvalidatePlot(false);
                            }
                        }
                    }
                };
                lineAnnotationVertical.MouseUp += (s, e) =>
                {
                    if (_isMarkersActive == 1)
                    {
                        lineAnnotationVertical.StrokeThickness /= 3;
                        plotAnalogSignals.Model.InvalidatePlot(false);
                        e.Handled = true;
                        if (_plotsSynchronized == 1)
                        {
                            for (int i = 0; i < _checkedIOIndexes.Count; i++)
                            {
                                lineAnnotationsIO[i].StrokeThickness /= 3;
                                plotIOSignals[i].Model.InvalidatePlot(false);
                            }
                        }
                    }
                };
                lineAnnotationHorizontal = new LineAnnotation {
                    Type = LineAnnotationType.Horizontal, Color = OxyColors.Brown, Layer = AnnotationLayer.BelowSeries
                };
                lineAnnotationHorizontal.Y          = 90;
                lineAnnotationHorizontal.MouseDown += (s, e) =>
                {
                    if (e.ChangedButton != OxyMouseButton.Left)
                    {
                        return;
                    }
                    if (_isMarkersActive == 1)
                    {
                        lineAnnotationHorizontal.StrokeThickness *= 3;
                        plotAnalogSignals.Model.InvalidatePlot(false);
                        e.Handled = true;
                    }
                };
                lineAnnotationHorizontal.MouseMove += (s, e) =>
                {
                    if (_isMarkersActive == 1)
                    {
                        lineAnnotationHorizontal.Y = lineAnnotationHorizontal.InverseTransform(e.Position).Y;
                        plotAnalogSignals.Model.InvalidatePlot(false);
                        e.Handled = true;
                    }
                };
                lineAnnotationHorizontal.MouseUp += (s, e) =>
                {
                    if (_isMarkersActive == 1)
                    {
                        lineAnnotationHorizontal.StrokeThickness /= 3;
                        plotAnalogSignals.Model.InvalidatePlot(false);
                        e.Handled = true;
                    }
                };
                plotAnalogSignals.Model.Annotations.Add(lineAnnotationVertical);
                plotAnalogSignals.Model.Annotations.Add(lineAnnotationHorizontal);
                // Create Line series
                var s1 = new LineSeries {
                    StrokeThickness = 1, Color = OxyColors.Blue, MarkerType = MarkerType.Circle, MarkerStroke = OxyColors.Blue, MarkerFill = OxyColors.Blue, MarkerSize = 2
                };
                var s2 = new LineSeries {
                    StrokeThickness = 1, Color = OxyColors.Magenta, MarkerType = MarkerType.Circle, MarkerStroke = OxyColors.Magenta, MarkerFill = OxyColors.Magenta, MarkerSize = 2
                };
                var s3 = new LineSeries {
                    StrokeThickness = 1, Color = OxyColors.Green, MarkerType = MarkerType.Circle, MarkerStroke = OxyColors.Green, MarkerFill = OxyColors.Green, MarkerSize = 2
                };
                var s4 = new LineSeries {
                    StrokeThickness = 1, Color = OxyColors.IndianRed, MarkerType = MarkerType.Circle, MarkerStroke = OxyColors.IndianRed, MarkerFill = OxyColors.IndianRed, MarkerSize = 2
                };
                var s5 = new LineSeries {
                    StrokeThickness = 1, Color = OxyColors.DarkOrange, MarkerType = MarkerType.Circle, MarkerStroke = OxyColors.DarkOrange, MarkerFill = OxyColors.DarkOrange, MarkerSize = 2
                };
                var s6 = new LineSeries {
                    StrokeThickness = 1, Color = OxyColors.Yellow, MarkerType = MarkerType.Circle, MarkerStroke = OxyColors.Yellow, MarkerFill = OxyColors.Yellow, MarkerSize = 2
                };
                var s7 = new LineSeries {
                    StrokeThickness = 1, Color = OxyColors.Red, MarkerType = MarkerType.Circle, MarkerStroke = OxyColors.Red, MarkerFill = OxyColors.Red, MarkerSize = 2
                };
                for (int i = 0; i < dateTimes.Count; i++)
                {
                    s1.Points.Add(new DataPoint(DateTimeAxis.ToDouble(dateTimes[i]), Convert.ToDouble(analogSignals[oc][0][i]) / ((_mineConfig.MainViewConfig.Distance.Value + 10) / 100)));
                    s2.Points.Add(new DataPoint(DateTimeAxis.ToDouble(dateTimes[i]), Convert.ToDouble(analogSignals[oc][1][i]) / ((_mineConfig.MainViewConfig.Distance.Value + 10) / 100)));
                    s3.Points.Add(new DataPoint(DateTimeAxis.ToDouble(dateTimes[i]), Convert.ToDouble(analogSignals[oc][2][i]) / (_mineConfig.MainViewConfig.MaxSpeed.Value / 100)));
                    s4.Points.Add(new DataPoint(DateTimeAxis.ToDouble(dateTimes[i]), Convert.ToDouble(analogSignals[oc][3][i]) / (_maxSpeedUp / 100)));
                    s5.Points.Add(new DataPoint(DateTimeAxis.ToDouble(dateTimes[i]), Convert.ToDouble(analogSignals[oc][4][i]) / (_mineConfig.MainViewConfig.MaxTokAnchor.Value / 100)));
                    s6.Points.Add(new DataPoint(DateTimeAxis.ToDouble(dateTimes[i]), Convert.ToDouble(analogSignals[oc][5][i]) / (_mineConfig.MainViewConfig.MaxTokExcitation.Value / 100)));
                    s7.Points.Add(new DataPoint(DateTimeAxis.ToDouble(dateTimes[i]), Convert.ToDouble(analogSignals[oc][6][i]) / (_mineConfig.MainViewConfig.MaxSpeed.Value / 100)));
                }
                //Series
                plotAnalogSignals.Model.Series.Add(s1);
                plotAnalogSignals.Model.Series.Add(s2);
                plotAnalogSignals.Model.Series.Add(s3);
                plotAnalogSignals.Model.Series.Add(s4);
                plotAnalogSignals.Model.Series.Add(s5);
                plotAnalogSignals.Model.Series.Add(s6);
                plotAnalogSignals.Model.Series.Add(s7);
                int j = 0;
                foreach (ListViewItem item in listViewAnalogSignals.Items)
                {
                    plotAnalogSignals.Model.Series[j].IsVisible = listViewAnalogSignals.CheckedItems.Contains(item);
                    j++;
                }
                plotAnalogSignals.InvalidatePlot(true);
                panel1.Controls.Add(plotAnalogSignals);
            });
        }
Exemplo n.º 4
0
        private void test_Load(object sender, EventArgs e)
        {
            testvar.Add(new RelationalDouble(7.9));

            Plot plot = new Plot();
            plot.Model = new OxyPlot.PlotModel();
            plot.Dock = DockStyle.Fill;
            Controls.Add(plot);

            plot.Model.PlotType = OxyPlot.PlotType.XY;

            var DS = new OxyPlot.Series.LineSeries();

            /*Plot plot = new Plot();
            plot.Model = new OxyPlot.PlotModel();
            plot.Dock = DockStyle.Fill;
            this.Controls.Add(plot);

            plot.Model.PlotType = OxyPlot.PlotType.XY;

            var DS = new OxyPlot.Series.LineSeries();
            var US = new OxyPlot.Series.LineSeries();
            var piolt = new OxyPlot.Series.StemSeries();
            US.Color = OxyPlot.OxyColors.Green;
            DS.Color = OxyPlot.OxyColors.Blue;
            piolt.Color = OxyPlot.OxyColors.OrangeRed;

            string[] tmp = "0,0,0,0,5,9,10,10,10,10,11,10,10,10,10,9,9,9,9,9,8,8,8,9,9,8,9,9,8,8,8,8,8,8,8,8,8,9,9,9,8,9,8,8,8,9,8,9,9,9,8,9,9,8,9,8,8,8,8,8,8,8,8,8,13,14,14,14,14,14,14,14,15,13,14,14,14,14,14,14,14,14,14,14,13,11,0,2,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,6,6,7,6,6,6,6,6,6,6,6,5,4,6,6,2,6,6,4,4,6,5,5,5,5,5,5,5,5,5,5,5,4,5,5,5,4,4,5,5,4,1,7,12,12,13,12,13,13,12,13,12,12,13,12,12,13,12,12,12,12,12,10,12,12,12,12,12,12,12,12,12,12,12,10,12,12,12,12,12,12,12,12,12,12,10,12,12,12,12,12,12,12,12,12,12,11,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0".Split(',');
            int i = 0;
            int c = 0;
            string profile = "8b";

            foreach (var item in tmp)
            {
                if (profile == "8b" && i < 2048)
                {
                    if (c < 87 || c > 147)
                    {
                        DS.Points.Add(new OxyPlot.DataPoint((double)i, Convert.ToDouble(item)));
                        US.Points.Add(new OxyPlot.DataPoint((double)i, 0));
                    }
                    else
                    {
                        DS.Points.Add(new OxyPlot.DataPoint((double)i, 0));
                        US.Points.Add(new OxyPlot.DataPoint((double)i, Convert.ToDouble(item)));
                    }
                    if (c == 74)
                    {
                        piolt.Points.Add(new OxyPlot.DataPoint((double)i, 16));
                    }
                    i += 8;
                    c++;
                }
            }

            plot.Model.Series.Add(DS);
            plot.Model.Series.Add(US);
            plot.Model.Series.Add(piolt);

            */
        }