Ejemplo n.º 1
0
        /// <summary>
        /// !!! Нарисовать графические объекты
        /// </summary>
        /// <param name="pane"></param>
        private void DrawObjects(GraphPane pane)
        {
            // Создадим текстовый объект, координаты которого задаются
            // не в координатах графика, а в координатах относительно графика
            TextObj text = new TextObj("Этот текст всегда находится в углу",
                                       0.0, 1,                  // Координаты текстового объекта
                                       CoordType.ChartFraction, // Координаты задаются относительно графика
                                       AlignH.Left,             // Координата по X задает положение левой границы объекта
                                       AlignV.Bottom);          // Координата по Y задает положение нижней границы объекта

            // Добавим текст в список графических объектов
            pane.GraphObjList.Add(text);

            // Нарисуем перекрестие, которое всегда будет посередине графика

            // Создадим горизонтальную линию
            LineObj cross_hor = new LineObj(Color.Black, 0.48, 0.5, 0.52, 0.5);

            // Ее координаты рассчитываются относительно графика
            cross_hor.Location.CoordinateFrame = CoordType.ChartFraction;
            // Координаты задают центральную точку и по горизонтали, и по вертикали
            cross_hor.Location.AlignH = AlignH.Center;
            cross_hor.Location.AlignV = AlignV.Center;

            // Аналогично создаем вертикальную линию перекрестия
            LineObj cross_ver = new LineObj(Color.Black, 0.5, 0.48, 0.5, 0.52);

            cross_ver.Location.CoordinateFrame = CoordType.ChartFraction;
            cross_ver.Location.AlignH          = AlignH.Center;
            cross_ver.Location.AlignV          = AlignV.Center;

            // Добавим линиии перекрестия в список графических объектов
            pane.GraphObjList.Add(cross_hor);
            pane.GraphObjList.Add(cross_ver);
        }
Ejemplo n.º 2
0
        //private static double FindMax(double[][] ia, int limit1, int limit2)
        //{
        //    double iMax = ia[0][0];
        //    for (int i = 0; i < limit1; i++)
        //        for (int j = 0; j < limit2; j++)
        //        {
        //            if (ia[i][j] > iMax)
        //                iMax = ia[i][j];
        //        }
        //    return iMax;
        //}

        //private static double FindMin(double[][] ia, int limit1, int limit2)
        //{
        //    double iMin = ia[0][0];
        //    for (int i = 0; i < limit1; i++)
        //        for (int j = 0; j < limit2; j++)
        //        {
        //            if (ia[i][j] < iMin)
        //                iMin = ia[i][j];
        //        }
        //    return iMin;
        //}

        private void occHeight_TextChanged(object sender, EventArgs e)
        {
            double convlength = 1;

            try
            {
                double heighttemp = Double.Parse(occHeight.Text);
                if (heighttemp < 0)
                {
                    System.ApplicationException ex = new System.ApplicationException("Height of occupied zone must be positive!");
                    throw ex;
                }
                else
                {
                    if (globalcontrol.units == 1)
                    {
                        convlength = 3.28084;
                    }
                    globalcontrol.occheight  = Double.Parse(occHeight.Text) / convlength;
                    this.occHeight.BackColor = Color.White;
                }
            }
            catch (Exception)
            {
                this.occHeight.BackColor = Color.PaleVioletRed;
            }
            this.mySPane.CurveList.Clear();
            this.mySPane.GraphObjList.Clear();
            this.threshHoldY = globalcontrol.occheight * convlength;
            LineObj threshHoldLine = new LineObj(Color.Red, mySPane.XAxis.Scale.Min, threshHoldY, mySPane.XAxis.Scale.Max, threshHoldY);

            this.mySPane.GraphObjList.Add(threshHoldLine);
            this.refreshPlot();
        }
Ejemplo n.º 3
0
        //----Двигаем точки
        private bool zGraph_MouseDownEvent(ZedGraphControl control, MouseEventArgs e)
        {
            if (Control.ModifierKeys == Keys.Shift)
            {
                PointF mousePt = new PointF(e.X, e.Y);

                if (pane.FindNearestPoint(mousePt, out dragCurve, out dragIndex) &&
                    dragCurve.Points is PointPairList &&
                    dragCurve.YAxisIndex == 0 && dragCurve.Label.Text == "Curve3")
                {
                    startPt   = mousePt;
                    startPair = dragCurve.Points[dragIndex];

                    isDragPoint = true;

                    pane.ReverseTransform(mousePt, out startX, out startY);

                    hLine            = new LineObj(pane.XAxis.Scale.Min, startPair.Y, pane.XAxis.Scale.Max, startPair.Y);
                    hLine.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;
                    vLine            = new LineObj(startPair.X, pane.YAxis.Scale.Min, startPair.X, pane.YAxis.Scale.Max);
                    vLine.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;
                    pane.GraphObjList.Add(hLine);
                    pane.GraphObjList.Add(vLine);

                    control.Refresh();
                }
            }

            return(false);
        }
        public void ReZoomLineObjs()
        {
            this.zedGraphControl1.GraphPane.GraphObjList.Remove(upperLimitLine);
            if (this.zedGraphControl1.GraphPane.YAxis.Scale.Max >= Convert.ToDouble(upperLimitDiameter))
            {
                upperLimitLine            = new LineObj(System.Drawing.Color.FromArgb(255, 0, 0), this.zedGraphControl1.GraphPane.XAxis.Scale.Min, Convert.ToDouble(upperLimitDiameter), this.zedGraphControl1.GraphPane.XAxis.Scale.Max, Convert.ToDouble(upperLimitDiameter));
                upperLimitLine.Line.Width = 2.0F;
                this.zedGraphControl1.GraphPane.GraphObjList.Add(upperLimitLine);
            }

            this.zedGraphControl1.GraphPane.GraphObjList.Remove(lowerLimitLine);
            if (this.zedGraphControl1.GraphPane.YAxis.Scale.Min <= Convert.ToDouble(lowerLimitDiameter))
            {
                lowerLimitLine            = new LineObj(System.Drawing.Color.FromArgb(255, 0, 0), this.zedGraphControl1.GraphPane.XAxis.Scale.Min, Convert.ToDouble(lowerLimitDiameter), this.zedGraphControl1.GraphPane.XAxis.Scale.Max, Convert.ToDouble(lowerLimitDiameter));
                lowerLimitLine.Line.Width = 2.0F;
                this.zedGraphControl1.GraphPane.GraphObjList.Add(lowerLimitLine);
            }

            this.zedGraphControl1.GraphPane.GraphObjList.Remove(nominalLine);
            if (this.zedGraphControl1.GraphPane.YAxis.Scale.Min <= Convert.ToDouble(nominalDiameter) && this.zedGraphControl1.GraphPane.YAxis.Scale.Max >= Convert.ToDouble(nominalDiameter))
            {
                nominalLine            = new LineObj(System.Drawing.Color.FromArgb(64, 191, 67), this.zedGraphControl1.GraphPane.XAxis.Scale.Min, Convert.ToDouble(nominalDiameter), this.zedGraphControl1.GraphPane.XAxis.Scale.Max, Convert.ToDouble(nominalDiameter));
                nominalLine.Line.Width = 2.0F;
                this.zedGraphControl1.GraphPane.GraphObjList.Add(nominalLine);
            }
        }
Ejemplo n.º 5
0
        public void SetThreshold(double?value)
        {
            if (value.HasValue)
            {
                if (m_Threshold == null)
                {
                    m_Threshold = new LineObj(Color.Red, 0, value.Value, 1, value.Value)
                    {
                        Location             = { CoordinateFrame = CoordType.XChartFractionYScale },
                        IsClippedToChartRect = true
                    };
                    GraphObjList.Add(m_Threshold);
                }
                else
                {
                    m_Threshold.Location.Y = value.Value;
                }
            }
            else
            {
                GraphObjList.Remove(m_Threshold);
                m_Threshold = null;
            }

            m_Parent.UpdateGraph();
        }
Ejemplo n.º 6
0
        public static void AddLabel(this GraphPane pane, double x, int n)
        {
            var    yScale = pane.YAxis.Scale;
            double yMin   = yScale.Min;
            double yMax   = yScale.Max;

            var line = new LineObj(x, yMin, x, yMax)
            {
                IsClippedToChartRect = true
            };

            //line.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;
            line.Line.Color = Color.DarkGreen;
            pane.GraphObjList.Add(line);

            if (n > 0)
            {
                var text = new TextObj(n.ToString(), x, yMax - 0.02 * (yMax - yMin))
                {
                    IsClippedToChartRect = true
                };
                text.FontSpec.Border.IsVisible = true;
                pane.GraphObjList.Add(text);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Begin tracking our value
        /// </summary>
        public void BeginTracking()
        {
            BaseValue = 0;
            foreach (MM_Element Elem in Elements)
            {
                float CurVal = FieldToCheck != null ? (float)FieldToCheck.GetValue(Elem) : (float)PropertyToCheck.GetValue(Elem);
                if (!float.IsNaN(CurVal))
                {
                    BaseValue += CurVal;
                }
            }


            lblBaseValue.Text       = BaseValue.ToString(NumberFormat);
            lblDeltaValue.Text      = (0).ToString(NumberFormat);
            lblDeltaValue.ForeColor = Color.White;

            //Set our master panel
            GraphPane myMaster = zgGraph.GraphPane;

            myMaster.CurveList.Clear();
            myMaster.Title.IsVisible          = false;
            myMaster.Title.FontSpec.FontColor = Color.White;
            myMaster.Legend.Fill = myMaster.Fill = new Fill(Color.Black);
            myMaster.Legend.FontSpec.FontColor      = Color.White;
            myMaster.Legend.FontSpec.Fill           = new Fill(Color.Black);
            myMaster.Legend.IsVisible               = true;
            myMaster.Legend.Position                = LegendPos.TopCenter;
            myMaster.XAxis.Title.FontSpec.FontColor = Color.White;
            myMaster.YAxis.Title.FontSpec.FontColor = Color.White;
            myMaster.XAxis.MajorTic.Color           = Color.White;
            myMaster.XAxis.MinorTic.Color           = Color.White;
            myMaster.YAxis.MajorTic.Color           = Color.White;
            myMaster.YAxis.MinorTic.Color           = Color.White;
            myMaster.XAxis.MajorGrid.Color          = Color.White;
            myMaster.YAxis.MajorGrid.Color          = Color.White;
            myMaster.Chart.Fill                     = new Fill(Color.Black);
            myMaster.Chart.Border.Color             = Color.DarkGray;
            myMaster.XAxis.Scale.FontSpec.FontColor = Color.White;
            myMaster.YAxis.Scale.FontSpec.FontColor = Color.White;
            this.BorderStyle      = System.Windows.Forms.BorderStyle.None;
            lblOperator.TextAlign = ContentAlignment.MiddleCenter;
            zgGraph.GraphPane.Legend.IsVisible = false;
            zgGraph.GraphPane.XAxis.Title.Text = "Date/Time";
            zgGraph.GraphPane.XAxis.Type       = AxisType.Date;
            zgGraph.GraphPane.XAxis.IsVisible  = false;
            zgGraph.GraphPane.YAxis.IsVisible  = false;
            zgGraph.IsShowPointValues          = true;
            TrackingCurve = myMaster.AddCurve(Title, new PointPairList(), Color.White);
            TrackingCurve.AddPoint(ZedGraph.XDate.DateTimeToXLDate(LastTime = Data_Integration.CurrentTime), BaseValue);

            LastValueChange = DateTime.Now;
            zgGraph.AxisChange();

            ThresholdLine = new LineObj(Color.Green, zgGraph.GraphPane.XAxis.Scale.Min, BaseValue, zgGraph.GraphPane.XAxis.Scale.Max, BaseValue);
            zgGraph.GraphPane.GraphObjList.Add(ThresholdLine);

            zgGraph.Invalidate();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Handle the timer update
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tmrUpdate_Tick(object sender, EventArgs e)
        {
            //If our simulator is paused, don't add points
            if (Data_Integration.SimulatorStatus != MacomberMapCommunications.Messages.EMS.MM_Simulation_Time.enumSimulationStatus.Running || Data_Integration.CurrentTime == LastTime)
            {
                return;
            }

            LastTime = Data_Integration.CurrentTime;
            float NewValue = 0;

            foreach (MM_Element Elem in Elements)
            {
                float CurVal = FieldToCheck != null ? (float)FieldToCheck.GetValue(Elem) : (float)PropertyToCheck.GetValue(Elem);
                if (!float.IsNaN(CurVal))
                {
                    NewValue += CurVal;
                }
            }

            TrackingCurve.AddPoint(ZedGraph.XDate.DateTimeToXLDate(LastTime), NewValue);
            zgGraph.AxisChange();

            if (chkMax.Checked)
            {
                zgGraph.GraphPane.YAxis.Scale.Max = (double)nudMax.Value;
            }
            else
            {
                nudMax.Value = (decimal)zgGraph.GraphPane.YAxis.Scale.Max;
            }
            if (chkMin.Checked)
            {
                zgGraph.GraphPane.YAxis.Scale.Min = (double)nudMin.Value;
            }
            else
            {
                nudMin.Value = (decimal)zgGraph.GraphPane.YAxis.Scale.Min;
            }

            ThresholdLine = new LineObj(Color.Green, zgGraph.GraphPane.XAxis.Scale.Min, BaseValue, zgGraph.GraphPane.XAxis.Scale.Max, BaseValue);
            zgGraph.GraphPane.GraphObjList.Add(ThresholdLine);

            //    .X2 = zgGraph.GraphPane.XAxis.Scale.Max;
            zgGraph.Invalidate();


            String NewText = (NewValue - BaseValue).ToString(NumberFormat);

            if (lblDeltaValue.Text != NewText)
            {
                lblDeltaValue.Text = NewText;
                LastValueChange    = DateTime.Now;
            }

            int Sec = Math.Min(255, (int)(DateTime.Now - LastValueChange).TotalSeconds * 6);

            lblDeltaValue.ForeColor = lblBaseValue.ForeColor = lblOperator.ForeColor = Color.FromArgb(Sec, 255, Sec);
        }
Ejemplo n.º 9
0
        private void AddMarker(ZedGraphControl gc, DateTime date, Color color, GraphMarkerType markerType)
        {
            var     ymax = gc.GraphPane.YAxis.Scale.Max;
            LineObj line = new LineObj(color, (double)new XDate(date), (double)0, (double)new XDate(date), ymax);

            line.Tag    = markerType;
            line.ZOrder = ZOrder.E_BehindCurves;
            gc.GraphPane.GraphObjList.Add(line);
        }
Ejemplo n.º 10
0
        public ZedGraphCrossHair(ZedGraphControl zed)
        {
            _xHairOld = new LineObj();
            _yHairOld = new LineObj();
            _zed      = zed;

            zed.MouseMove  += OnMouseMove;
            zed.MouseLeave += OnMouseLeave;
        }
Ejemplo n.º 11
0
        private void ShowHideGrahps()
        {
            var breathGraphPane = graphBreath.GraphPane;

            breathGraphPane.CurveList.Clear();
            breathGraphPane.Title.Text       = "Breath";
            breathGraphPane.XAxis.Title.Text = "t (сек)";
            breathGraphPane.YAxis.Title.Text = "мОм";

            var breathAutocorrelGraphPane = graphAutocorrelation.GraphPane;

            breathAutocorrelGraphPane.CurveList.Clear();
            breathAutocorrelGraphPane.Title.Text       = "Autocorrelation";
            breathAutocorrelGraphPane.XAxis.Title.Text = "t (сек)";
            breathAutocorrelGraphPane.YAxis.Title.Text = "мОм";

            breathGraphPane.GraphObjList.Clear();
            breathAutocorrelGraphPane.GraphObjList.Clear();

            double  x;
            LineObj line;

            if (cbBreath1.Checked && Breath1MaxIndiciesOfMax != null)
            {
                breathGraphPane.AddCurve("breath 1", Breath1PointPairList, System.Drawing.Color.OrangeRed, SymbolType.None);
                breathAutocorrelGraphPane.AddCurve("breath 1", Breath1AutocorrelPointPairList, System.Drawing.Color.OrangeRed, SymbolType.None);

                x    = Breath1MaxIndiciesOfMax[1] * TimeDelta;
                line = new LineObj(System.Drawing.Color.OrangeRed, x, Breath1Data.Min(), x, Breath1Data.Max());
                line.Location.CoordinateFrame = CoordType.AxisXYScale;
                breathGraphPane.GraphObjList.Add(line);

                line = new LineObj(System.Drawing.Color.OrangeRed, x, Breath1Autocorrel.Min(), x, Breath1Autocorrel.Max());
                line.Location.CoordinateFrame = CoordType.AxisXYScale;
                breathAutocorrelGraphPane.GraphObjList.Add(line);
            }
            if (cbBreath2.Checked && Breath2MaxIndiciesOfMax != null)
            {
                breathGraphPane.AddCurve("breath 2", Breath2PointPairList, System.Drawing.Color.SteelBlue, SymbolType.None);
                breathAutocorrelGraphPane.AddCurve("breath 2", Breath2AutocorrelPointPairList, System.Drawing.Color.SteelBlue, SymbolType.None);

                x    = Breath2MaxIndiciesOfMax[1] * TimeDelta;
                line = new LineObj(System.Drawing.Color.SteelBlue, x, Breath2Data.Min(), x, Breath2Data.Max());
                line.Location.CoordinateFrame = CoordType.AxisXYScale;
                breathGraphPane.GraphObjList.Add(line);

                line = new LineObj(System.Drawing.Color.SteelBlue, x, Breath2Autocorrel.Min(), x, Breath2Autocorrel.Max());
                line.Location.CoordinateFrame = CoordType.AxisXYScale;
                breathAutocorrelGraphPane.GraphObjList.Add(line);
            }

            graphBreath.AxisChange();
            graphBreath.Refresh();
            graphAutocorrelation.AxisChange();
            graphAutocorrelation.Refresh();
        }
Ejemplo n.º 12
0
        public void addEndVertex(Vector3 endVertex, Color vertexColor, int vertexWidth)
        {
            tmpLineInfo.Id        = lineObjId++;
            tmpLineInfo.EndVertex = endVertex;
            tmpLineInfo.LineColor = vertexColor;
            tmpLineInfo.LineWidth = vertexWidth;

            lineObjList.Add(tmpLineInfo);
            tmpLineInfo = null;
        }
Ejemplo n.º 13
0
 public void removeCrosshair()
 {
     if (xLine == null)
     {
         return;
     }
     GraphObjList.Remove(xLine);
     GraphObjList.Remove(yLine);
     xLine = null;
     yLine = null;
 }
Ejemplo n.º 14
0
        private void graphSession_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (session == null || !session.IsLoaded)
            {
                return;
            }

            int x, y;

            GetGraphPointFromMousePos(e.X, e.Y, graphSession, out x, out y);

            double E = session.Detector.GetEnergy(x);

            if (E == 0.0)
            {
                log.Warn("Unable to get energy for detector " + session.Detector.Serialnumber);
                return;
            }

            GraphPane pane = graphSession.GraphPane;

            pane.GraphObjList.Clear();

            LineObj line1 = new LineObj(Color.Black, (double)x - tbarNuclides.Value, pane.YAxis.Scale.Min, (double)x - tbarNuclides.Value, pane.YAxis.Scale.Max);

            makeGraphObjectType(ref line1.Tag, GraphObjectType.EnergyTolerance);
            line1.Line.Style = System.Drawing.Drawing2D.DashStyle.Dot;
            pane.GraphObjList.Add(line1);

            LineObj line2 = new LineObj(Color.Black, (double)x + tbarNuclides.Value, pane.YAxis.Scale.Min, (double)x + tbarNuclides.Value, pane.YAxis.Scale.Max);

            makeGraphObjectType(ref line2.Tag, GraphObjectType.EnergyTolerance);
            line2.Line.Style = System.Drawing.Drawing2D.DashStyle.Dot;
            pane.GraphObjList.Add(line2);

            graphSession.RestoreScale(pane);
            graphSession.AxisChange();
            graphSession.Refresh();

            // List nuclides
            lbNuclides.Items.Clear();
            foreach (NuclideInfo ni in NuclideLibrary)
            {
                foreach (NuclideEnergy ne in ni.Energies)
                {
                    if (ne.Energy > E - (double)tbarNuclides.Value && ne.Energy < E + (double)tbarNuclides.Value)
                    {
                        lbNuclides.Items.Add(ni);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 15
0
        private void SetMappedItem(string itemID)
        {
            if (m_MappedItem == itemID)
            {
                return;
            }

            GraphObjList.Clear();

            CurveItem item = GetCurve(m_MappedItem);

            if (item != null)
            {
                item.IsVisible = true;
            }

            m_MappedItem = itemID;

            item = CurveList[itemID];

            if (item != null)
            {
                item.IsVisible = false;
                List <GraphObj> objects = new List <GraphObj>();

                for (int index = 0; index < item.Points.Count; index++)
                {
                    PointPair point = item[index];

                    LineObj line = new LineObj(Color.Gray, point.X, 0, point.X, 1);
                    line.Tag = point.Y;
                    line.Location.CoordinateFrame = CoordType.XScaleYChartFraction;
                    line.ZOrder = ZOrder.E_BehindCurves;


                    TextObj text = new TextObj(point.Y.ToString(), point.X, 1);
                    text.Location.CoordinateFrame  = CoordType.XScaleYChartFraction;
                    text.IsClippedToChartRect      = false;
                    text.FontSpec.Border.IsVisible = false;
                    text.Location.AlignV           = AlignV.Bottom;
                    text.Location.AlignH           = AlignH.Right;
                    text.FontSpec.Angle            = -90;
                    text.FontSpec.Fill.IsVisible   = false;
                    objects.Add(line);
                    objects.Add(text);
                }

                GraphObjList.AddRange(objects);
            }

            m_HasChanged = true;
            m_Parent.UpdateGraph();
        }
Ejemplo n.º 16
0
        private void CreateThreshold()
        {
            GraphPane graphPane = graph.PaneList[0];
            double    num       = 0.0;
            LineObj   lineObj   = new LineObj(Color.Green, 0.0, num, 1.0, num);

            lineObj.Location.CoordinateFrame = CoordType.XChartFractionYScale;
            lineObj.IsVisible = true;
            graphPane.GraphObjList.Add((GraphObj)lineObj);
            graphPane.AxisChange();
            graph.Invalidate();
        }
Ejemplo n.º 17
0
        private void CreateThreshold()
        {
            GraphPane pane = this.graph.PaneList[0];
            double    num  = 0.0;
            LineObj   item = new LineObj(Color.Green, 0.0, num, 1.0, num);

            item.Location.CoordinateFrame = CoordType.XChartFractionYScale;
            item.IsVisible = true;
            pane.GraphObjList.Add(item);
            pane.AxisChange();
            this.graph.Invalidate();
        }
Ejemplo n.º 18
0
        public LineObj CrateVerticalLine()
        {
            LineObj threshHoldLine = new LineObj(
                Color.Red,
                control.GraphPane.XAxis.Scale.Min,
                0,
                control.GraphPane.XAxis.Scale.Min,
                1);

            threshHoldLine.Location.CoordinateFrame = CoordType.XScaleYChartFraction;
            control.GraphPane.GraphObjList.Add(threshHoldLine);
            return(threshHoldLine);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Generates a grid for a graph.
        /// </summary>
        /// <param name="zgc">A <see cref="ZedGraphControl"/> used to get a graph pane.</param>
        public void CreateGrid(ZedGraphControl zgc)
        {
            GraphPane myPane = zgc.GraphPane;

            myPane.XAxis.Scale.Min = -20;
            myPane.XAxis.Scale.Max = 20;
            myPane.YAxis.Scale.Min = -20.0;
            myPane.YAxis.Scale.Max = 20.0;

            myPane.Title.IsVisible       = false;
            myPane.Legend.IsVisible      = false;
            myPane.XAxis.Title.IsVisible = false;
            myPane.YAxis.Title.IsVisible = false;

            for (int i = -19; i < 20; i++)
            {
                LineObj thresholdLineX = new LineObj(Color.Black,
                                                     -20,
                                                     i * 1.230769230769231,
                                                     20,
                                                     i * 1.230769230769231);

                LineObj thresholdLineY = new LineObj(Color.Black, i, -20, i, 20);

                if (Math.Abs(i) % 5 == 0.0)
                {
                    thresholdLineX.Line.Width = 2f;
                    thresholdLineY.Line.Width = 2f;
                }
                else
                {
                    thresholdLineX.Line.Width = 0.5f;
                    thresholdLineY.Line.Width = 0.5f;
                }

                if (Math.Abs(i) == 0.0)
                {
                    thresholdLineX.Line.Color = allAvailableColors[0];
                    thresholdLineY.Line.Color = allAvailableColors[0];
                    thresholdLineX.Line.Width = 2f;
                    thresholdLineY.Line.Width = 2f;
                }

                if (!(i * 1.230769230769231 < -20 || i * 1.230769230769231 > 20))
                {
                    myPane.GraphObjList.Add(thresholdLineX);
                }

                myPane.GraphObjList.Add(thresholdLineY);
            }
        }
Ejemplo n.º 20
0
        private void SetThresholdLine(GraphPane pane, double x0, double x1, double threshold)
        {
            var thresholdLine = pane.GraphObjList.FirstOrDefault();

            if (thresholdLine == null)
            {
                thresholdLine = new LineObj(Color.Red, x0, threshold, x1, threshold);
                pane.GraphObjList.Add(thresholdLine);
            }
            else
            {
                thresholdLine.Location.Y = threshold;
            }
        }
Ejemplo n.º 21
0
        private void lbNuclides_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (session == null || !session.IsLoaded)
            {
                return;
            }

            // Remove current nuclide lines from graph
            GraphPane pane = graphSession.GraphPane;

            pane.GraphObjList.RemoveAll(o => isGraphObjectType(o.Tag, GraphObjectType.Energy));

            if (lbNuclides.SelectedItems.Count > 0)
            {
                double offset_y = 0d;

                // Display lines for currently selected nuclide
                NuclideInfo ni = (NuclideInfo)lbNuclides.SelectedItems[0];
                foreach (NuclideEnergy ne in ni.Energies)
                {
                    int ch = GetChannelFromEnergy(session.Detector, ne.Energy, 0, (int)session.NumChannels);
                    if (ch == -1)
                    {
                        // If no channel is found, or energy is outside current spectrum, continue to next energy
                        log.Warn("No channel found for energy: " + ni.Name + " " + ne.Energy.ToString());
                        continue;
                    }

                    // Add energy line
                    LineObj line = new LineObj(Color.ForestGreen, (double)ch, pane.YAxis.Scale.Min, (double)ch, pane.YAxis.Scale.Max);
                    makeGraphObjectType(ref line.Tag, GraphObjectType.Energy);
                    pane.GraphObjList.Add(line);

                    // Add probability text
                    TextObj label = new TextObj(ne.Probability.ToString() + " %", (double)ch, pane.YAxis.Scale.Max - offset_y, CoordType.AxisXY2Scale, AlignH.Left, AlignV.Top);
                    makeGraphObjectType(ref label.Tag, GraphObjectType.Energy);
                    label.FontSpec.Border.IsVisible = false;
                    label.FontSpec.Size             = 9f;
                    label.FontSpec.Fill.Color       = SystemColors.ButtonFace;
                    label.ZOrder = ZOrder.D_BehindAxis;
                    pane.GraphObjList.Add(label);
                    offset_y += pane.YAxis.Scale.Max / 25d;
                }
            }

            // Update graph
            graphSession.RestoreScale(pane);
            graphSession.AxisChange();
            graphSession.Refresh();
        }
Ejemplo n.º 22
0
        private void AddPeakRawTimes(GraphPane graphPane, ICollection <GraphObj> annotations,
                                     ScaledRetentionTime startTime, ScaledRetentionTime endTime, ChromatogramInfo info)
        {
            var hasTimes = info.RawTimes != null && info.RawTimes.Any(); // has measured points

            var scaledHeight = graphPane.YAxis.Scale.Max / 20;           // 5% of graph pane height
            var rawtimes     = new List <double>();

            if (hasTimes)
            {
                rawtimes.AddRange(GetRawTimes(startTime, endTime, info));
                if (rawtimes.Count == 0)
                {
                    return;
                }
                foreach (var time in rawtimes)
                {
                    LineObj stick = new LineObj(time, scaledHeight, time, 0)
                    {
                        IsClippedToChartRect = true,
                        Location             = { CoordinateFrame = CoordType.AxisXYScale },
                        ZOrder = ZOrder.A_InFront,
                        Line   = { Width = 1, Style = DashStyle.Dash, Color = ColorSelected },
                        Tag    = new GraphObjTag(this, GraphObjType.raw_time, new ScaledRetentionTime(time)),
                    };
                    annotations.Add(stick);
                }
            }

            var     countTxt   = hasTimes ? " " + rawtimes.Count : " ?";                  // Not L10N
            var     isBold     = !hasTimes;                                               // Question mark if no times exist is visually clearer if bold
            TextObj pointCount = new TextObj(countTxt, endTime.DisplayTime, scaledHeight) // Not L10N
            {
                FontSpec = new FontSpec(FontSpec.Family, FontSpec.Size, ColorSelected, isBold, false, false)
                {
                    Border = new Border {
                        IsVisible = false
                    },
                    Fill = new Fill()
                },
                Location =
                {
                    AlignH = AlignH.Left,
                    AlignV = AlignV.Bottom
                }
            };

            annotations.Add(pointCount);
        }
Ejemplo n.º 23
0
        private LineObj DrawLine(double y, double xMax, string Identifier)
        {
            if (Identifier.Equals(TA_Settings.High_Low.ToString()))
            {
                LineObj threshHoldLine = new LineObj(
                    Color.Plum,
                    1,
                    y,
                    xMax,
                    y);

                return(threshHoldLine);
            }
            return(null);
        }
Ejemplo n.º 24
0
        public override void AddAnnotations(MSGraphPane graphPane, Graphics g, MSPointList pointList, GraphObjList annotations)
        {
            // ReSharper disable UseObjectOrCollectionInitializer
            foreach (var rmi in SpectrumInfo.PeaksMatched)
            {
                if (!IsVisibleIon(rmi))
                {
                    continue;
                }

                IonType type = IsVisibleIon(rmi.IonType, rmi.Ordinal, rmi.Charge) ?
                               rmi.IonType : rmi.IonType2;

                Color color;
                switch (type)
                {
                default: color = COLOR_NONE; break;

                case IonType.a: color = COLOR_A; break;

                case IonType.x: color = COLOR_X; break;

                case IonType.b: color = COLOR_B; break;

                case IonType.y: color = COLOR_Y; break;

                case IonType.c: color = COLOR_C; break;

                case IonType.z: color = COLOR_Z; break;

                // FUTURE: Add custom ions when LibraryRankedSpectrumInfo can support them
                case IonType.precursor: color = COLOR_PRECURSOR; break;
                }

                if (IsMatch(rmi.PredictedMz))
                {
                    color = COLOR_SELECTED;
                }

                double mz    = rmi.ObservedMz;
                var    stick = new LineObj(color, mz, rmi.Intensity, mz, 0);
                stick.IsClippedToChartRect     = true;
                stick.Location.CoordinateFrame = CoordType.AxisXYScale;
                stick.Line.Width = LineWidth + 1;
                annotations.Add(stick);
            }
            //ReSharper restore UseObjectOrCollectionInitializer
        }
Ejemplo n.º 25
0
        public override void AddAnnotations(MSGraphPane graphPane, Graphics g, MSPointList pointList, GraphObjList annotations)
        {
            // ReSharper disable UseObjectOrCollectionInitializer
            foreach (var rmi in SpectrumInfo.PeaksMatched)
            {
                if (!IsVisibleIon(rmi))
                {
                    continue;
                }

                var matchedIon = rmi.MatchedIons.First(IsVisibleIon);

                Color color;
                switch (matchedIon.IonType)
                {
                default: color = COLOR_NONE; break;

                case IonType.a: color = COLOR_A; break;

                case IonType.x: color = COLOR_X; break;

                case IonType.b: color = COLOR_B; break;

                case IonType.y: color = COLOR_Y; break;

                case IonType.c: color = COLOR_C; break;

                case IonType.z: color = COLOR_Z; break;

                case IonType.custom: color = (rmi.Rank > 0) ? COLOR_OTHER_IONS : COLOR_NONE; break;     // Small molecule fragments - only color if ranked

                case IonType.precursor: color = COLOR_PRECURSOR; break;
                }

                if (rmi.MatchedIons.Any(mfi => IsMatch(mfi.PredictedMz)))
                {
                    color = COLOR_SELECTED;
                }

                double mz    = rmi.ObservedMz;
                var    stick = new LineObj(color, mz, rmi.Intensity, mz, 0);
                stick.IsClippedToChartRect     = true;
                stick.Location.CoordinateFrame = CoordType.AxisXYScale;
                stick.Line.Width = LineWidth + 1;
                annotations.Add(stick);
            }
            //ReSharper restore UseObjectOrCollectionInitializer
        }
Ejemplo n.º 26
0
        private void OnMouseMove(object sender, MouseEventArgs e)
        {
            double x, y;

            var pane = _zed.GraphPane;

            //
            // Пересчитываем пиксели в координаты на графике
            // у ZedGraph есть несколько перегруженных методов ReverseTransform.
            pane.ReverseTransform(e.Location, out x, out y);

            if (x < pane.XAxis.Scale.Min ||
                x > pane.XAxis.Scale.Max ||
                y < pane.YAxis.Scale.Min ||
                y > pane.YAxis.Scale.Max
                )//out of the bounds
            {
                OnMouseLeave(null, null);
            }
            else
            {
                if (_crossHairX != null && _crossHairY != null)
                {
                    pane.GraphObjList.Remove(_xHairOld);
                    pane.GraphObjList.Remove(_yHairOld);
                }

                LineObj xHair = new LineObj(pane.XAxis.Scale.Min, y, pane.XAxis.Scale.Max, y);
                xHair.Line.Style   = DashStyle.Custom;
                xHair.Line.DashOff = 5.0f;      // длина пропуска между пунктирами
                xHair.Line.DashOn  = 10.0f;     // длина пунктира
                LineObj yHair = new LineObj(x, pane.YAxis.Scale.Min, x, pane.YAxis.Scale.Max);
                yHair.Line.Style   = DashStyle.Custom;
                yHair.Line.DashOff = 5.0f;
                yHair.Line.DashOn  = 10.0f;

                pane.GraphObjList.Add(xHair);
                _xHairOld = xHair;

                pane.GraphObjList.Add(yHair);
                _yHairOld = yHair;

                _crossHairY = y;
                _crossHairX = x;

                _zed.Refresh();
            }
        }
Ejemplo n.º 27
0
        public void addEquity(Simulator simulator)
        {
            Bomb.when(Objects.hasContent(equity), () => "equity has content already: " + Objects.toShortString(equity));
            equity.AddRange(simulator.equity(symbol));
            var points = new PointPairList();

            Objects.eachIt(simulator.equity(symbol), (i, value) => points.Add(i + 1, value));
            var curve = AddCurve("equity", points, Color.Red);

            curve.Symbol.IsVisible  = false;
            curve.IsOverrideOrdinal = true;
            var zero = new LineObj(Color.Gray, 1, 0, bars.count(), 0)
            {
                Line = { Style = DashStyle.Dash }, Location = { CoordinateFrame = CoordType.AxisXYScale }
            };

            GraphObjList.Add(zero);
            AxisChange();
            var graphable = new EquityGraphable("equity", simulator.equity(symbol), simulator.dates(symbol));

            graphables.Add(graphable);

            var needsNewPoint = false;

            bars.pushedDown += () => needsNewPoint = true;
            bars.valueSet   += bar => {
                var value           = simulator.pnl(symbol);
                var todaysMarketPnl = Objects.sum(Objects.convert(simulator.positions(symbol), position => position.pnl(bars[1].close, bars[0].close)));
                value += todaysMarketPnl;
                graphable.add(bar.time, value);
                QControl.runOnGuiThread(dispatchTo, () => {
                    var lastPoint = curve[curve.Points.Count - 1];
                    if (needsNewPoint)
                    {
                        curve.AddPoint(lastPoint.X + 1, value);
                        equity.Add(value);
                    }
                    else
                    {
                        lastPoint.Y = value;
                        equity[equity.Count - 1] = value;
                    }
                    BarSpudGraph.addEquityTo(Objects.first(parentTyped.dataTable().Rows), value);
                    needsNewPoint = false;
                    parentTyped.Invalidate();
                });
            };
        }
Ejemplo n.º 28
0
        public void ShowBreaks(Color c, double[] b)
        {
            for (int i = 0; i < b.Length; i++)
            {
                LineObj BreakLine = new LineObj(
                    b[i],
                    mZedGraphControl.GraphPane.YAxis.Scale.Min,
                    b[i],
                    mZedGraphControl.GraphPane.YAxis.Scale.Max);
                BreakLine.Line.Style = System.Drawing.Drawing2D.DashStyle.Dot;
                BreakLine.ZOrder     = ZOrder.A_InFront;

                mZedGraphControl.GraphPane.GraphObjList.Add(BreakLine);
            }

            mZedGraphControl.AxisChange();
            mZedGraphControl.Refresh();
        }
        /// <summary>
        /// Update vertical line the marks current import time for progressively loaded files.
        /// </summary>
        private void UpdateProgressLine(double time)
        {
            // Remove old progressive loading indicators.
            if (_unfinishedBox != null)
            {
                _graphPane.GraphObjList.Remove(_unfinishedBox);
                _graphPane.GraphObjList.Remove(_unfinishedLine);
                _unfinishedBox = null;
            }

            // If we're still loading, create a white rectangle which blocks the fill background, indicating data yet to be loaded.
            if (time < _status.Transitions.MaxRetentionTime)
            {
                _graphPane.Chart.Fill = new Fill(_backgroundGradientColor1, _backgroundGradientColor2, 45.0f);
                _unfinishedBox        = new BoxObj(
                    time,
                    _graphPane.YAxis.Scale.Max,
                    _graphPane.XAxis.Scale.Max - time,
                    _graphPane.YAxis.Scale.Max - _graphPane.YAxis.Scale.Min,
                    Color.White, Color.White)
                {
                    Location = { CoordinateFrame = CoordType.AxisXYScale },
                    ZOrder   = ZOrder.F_BehindGrid
                };
                _graphPane.GraphObjList.Add(_unfinishedBox);

                // Place a vertical line after the last loaded data.
                _unfinishedLine = new LineObj(
                    _unfinishedLineColor,
                    time,
                    _graphPane.YAxis.Scale.Max,
                    time,
                    _graphPane.YAxis.Scale.Min)
                {
                    Location = { CoordinateFrame = CoordType.AxisXYScale },
                    Line     = { Width = PROGRESS_LINE_WIDTH },
                    ZOrder   = ZOrder.D_BehindAxis
                };
                _graphPane.GraphObjList.Add(_unfinishedLine);
            }
        }
Ejemplo n.º 30
0
        private void AddUnfinishedLine(GraphPane graphPane, float?currentTime)
        {
            if (IsCanceled)
            {
                graphPane.GraphObjList.Add(_canceledBox);
                graphPane.GraphObjList.Add(_canceledText);
            }
            else if (graphPane.YAxis.Scale.Max > graphPane.YAxis.Scale.Min &&
                     currentTime.HasValue && currentTime.Value < graphPane.XAxis.Scale.Max * 0.95)
            {
                var unfinishedBox = new BoxObj(
                    currentTime.Value,
                    graphPane.YAxis.Scale.Max,
                    graphPane.XAxis.Scale.Max - currentTime.Value,
                    graphPane.YAxis.Scale.Max - graphPane.YAxis.Scale.Min,
                    Color.White, Color.White)
                {
                    Location = { CoordinateFrame = CoordType.AxisXYScale },
                    ZOrder   = ZOrder.F_BehindGrid
                };

                var unfinishedLine = new LineObj(
                    _unfinishedLineColor,
                    currentTime.Value,
                    graphPane.YAxis.Scale.Max,
                    currentTime.Value,
                    graphPane.YAxis.Scale.Min)
                {
                    Location = { CoordinateFrame = CoordType.AxisXYScale },
                    Line     = { Width = PROGRESS_LINE_WIDTH },
                    ZOrder   = ZOrder.D_BehindAxis
                };

                graphPane.GraphObjList.Add(unfinishedBox);
                graphPane.GraphObjList.Add(unfinishedLine);
            }
            else
            {
                graphPane.GraphObjList.Clear();
            }
        }