예제 #1
0
 /// <summary>
 /// Render all objects to the specified <see cref="Graphics"/> device
 /// by calling the Draw method of each <see cref="ArrowItem"/> object in
 /// the collection.  This method is normally only called by the Draw method
 /// of the parent <see cref="AldysPane"/> object.
 /// </summary>
 /// <param name="g">
 /// A graphic device object to be drawn into.  This is normally e.Graphics from the
 /// PaintEventArgs argument to the Paint() method.
 /// </param>
 /// <param name="pane">
 /// A reference to the <see cref="AldysPane"/> object that is the parent or
 /// owner of this object.
 /// </param>
 /// <param name="scaleFactor">
 /// The scaling factor to be used for rendering objects.  This is calculated and
 /// passed down by the parent <see cref="AldysPane"/> object using the
 /// <see cref="AldysPane.CalcScaleFactor"/> method, and is used to proportionally adjust
 /// font sizes, etc. according to the actual size of the graph.
 /// </param>
 public void Draw(Graphics g, AldysPane pane, double scaleFactor)
 {
     foreach (ArrowItem item in this)
     {
         item.Draw(g, pane, scaleFactor);
     }
 }
예제 #2
0
 /// <summary>
 /// See if the <see cref="X"/> or <see cref="Y"/> data arrays are missing
 /// for this <see cref="CurveItem"/>.  If so, provide a suitable default
 /// array using ordinal values.
 /// </summary>
 /// <param name="pane">
 /// A reference to the <see cref="AldysPane"/> object that is the parent or
 /// owner of this object.
 /// </param>
 public void DataCheck(AldysPane pane)
 {
     // See if a default X array is required
     if (this.X == null)
     {
         // if a Y array is available, just make the same number of elements
         if (this.Y != null)
         {
             this.X = MakeDefaultArray(this.Y.Count);
         }
         else
         {
             this.X = pane.XAxis.MakeDefaultArray();
         }
     }
     // see if a default Y array is required
     if (this.Y == null)
     {
         // if an X array is available, just make the same number of elements
         if (this.X != null)
         {
             this.Y = MakeDefaultArray(this.X.Count);
         }
         //				else if ( this.isY2Axis )
         //					this.Y = pane.Y2Axis.MakeDefaultArray();
         else
         {
             this.Y = pane.YAxis.MakeDefaultArray();
         }
     }
 }
예제 #3
0
        /// <summary>
        /// Render text to the specified <see cref="Graphics"/> device
        /// by calling the Draw method of each <see cref="TextItem"/> object in
        /// the collection.  This method is normally only called by the Draw method
        /// of the parent <see cref="AldysPane"/> object.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="AldysPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="AldysPane"/> object using the
        /// <see cref="AldysPane.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public void Draw(Graphics g, AldysPane pane, double scaleFactor)
        {
            foreach (TextItem item in this)
            {
                //----- Added by Sachin Dokhale
                item.WidthX = (float)(item.FontSpec.GetWidth(g, item.Text, scaleFactor));                  // * ((float)item.Text.Length);
                //item.HeightY  = (item.fontSpec.GetHeight);	//* (flot) text.Length ;
                //item.WidthX  = (item.FontSpec.GetWidth(g, scaleFactor));	// * item.Text.Length);
                //-----

                //The following condition is added by deepak b on 07.04.06
                if (item.X < pane.XAxis.Min || item.X > pane.XAxis.Max || item.Y < pane.YAxis.Min || item.Y > pane.YAxis.Max)
                {
                    if (Convert.ToDouble(item.X) < (pane.XAxis.Min))
                    {
                        item.X = (float)pane.XAxis.Min;
                    }

                    if (Convert.ToDouble(item.X) > (pane.XAxis.Max))
                    {
                        item.X = (float)pane.XAxis.Max;
                    }
                    if (Convert.ToDouble(item.Y) < (pane.YAxis.Min))
                    {
                        item.Y = (float)pane.YAxis.Min;
                    }

                    if (Convert.ToDouble(item.Y) > (pane.YAxis.Max))
                    {
                        item.Y = (float)pane.YAxis.Max;
                    }

                    item.Draw(g, pane, scaleFactor);
                }
                else
                {
                    //Added By Pankaj Bamb on 04 Sup 07
                    if (item.X <= pane.XAxis.Min + item.Text.Length / 2)
                    {
                        item.AlignH = FontAlignH.Left;
                    }
                    else if (item.X >= pane.XAxis.Max - item.Text.Length / 2)
                    {
                        item.AlignH = FontAlignH.Right;
                    }
                    else
                    {
                        item.AlignH = FontAlignH.Center;
                    }
                    //Ended by pankaj Bamb
                    item.Draw(g, pane, scaleFactor);
                }
            }
            //item.Draw( g, pane, scaleFactor );
        }
예제 #4
0
        /// <summary>
        /// Render all the <see cref="CurveItem"/> objects in the list to the
        /// specified <see cref="Graphics"/>
        /// device by calling the <see cref="CurveItem.Draw"/> member function of
        /// each <see cref="CurveItem"/> object.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="AldysPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="AldysPane"/> object using the
        /// <see cref="AldysPane.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public void Draw(Graphics g, AldysPane pane, double scaleFactor)
        {
            // Loop for each curve
            foreach (CurveItem curve in this)
            {
                // Render the curve
                //curve.Draw( g, pane, scaleFactor );

                if (curve.IsHighPeakLine)
                {
                    this.isResizing = false;
                }

                curve.Draw(g, pane, scaleFactor);
            }
        }
예제 #5
0
//		public AldysPane()
//		{
//			//
//			// TODO: Add constructor logic here
//			//
//		}
        /// <summary>
        /// The Copy Constructor
        /// </summary>
        /// <param name="rhs">The GraphPane object from which to copy</param>
        public AldysPane(AldysPane rhs)
        {
            statusflag = rhs.statusflag;
            bPeakEdit  = rhs.bPeakEdit;
            cursor     = Cursors.NoMove2D;
            this.peakX = rhs.peakX;
            this.peakY = rhs.peakY;

            //Added By Mangesh S. on 25-Nov-2006
            this.peakInfoX = rhs.peakInfoX;
            this.peakInfoY = rhs.peakInfoY;
            //Added By Mangesh S. on 25-Nov-2006

            paneRect  = rhs.PaneRect;
            axisRect  = rhs.AxisRect;
            xAxis     = new XAxis(rhs.XAxis);
            yAxis     = new YAxis(rhs.YAxis);
            legend    = new Legend(rhs.Legend);
            curveList = new CurveList(rhs.CurveList);
            textList  = new TextList(rhs.TextList);
            arrowList = new ArrowList(rhs.ArrowList);

            this.title       = rhs.Title;
            this.isShowTitle = rhs.IsShowTitle;
            this.fontSpec    = new FontSpecs(rhs.fontSpec);

            this.isIgnoreInitial = rhs.IsIgnoreInitial;

            this.isPaneFramed      = rhs.IsPaneFramed;
            this.paneFrameColor    = rhs.PaneFrameColor;
            this.paneFramePenWidth = rhs.PaneFramePenWidth;
            this.paneBackColor     = rhs.PaneBackColor;

            this.isAxisFramed      = rhs.IsAxisFramed;
            this.axisFrameColor    = rhs.AxisFrameColor;
            this.axisFramePenWidth = rhs.AxisFramePenWidth;
            this.axisBackColor     = rhs.AxisBackColor;

            this.baseDimension    = rhs.BaseDimension;
            this.paneGap          = rhs.PaneGap;
            this.objAldysGraphTmp = rhs.objAldysGraphTmp;
            this.ShowCurveLabels  = rhs.ShowCurveLabels;
        }
예제 #6
0
        public void InsertCurvePixels(AldysPane pane, ArrayList peakx, ArrayList peaky)
        {
            // Transform the current point from user scale units to
            // screen coordinates
            float fX, fY;

            fX = 0;
            fY = 0;
            for (int i = 0; i < this.NPts; i++)
            {
                fX = pane.XAxis.Transform(((double)this.X[i]));
                fY = pane.YAxis.Transform(((double)this.Y[i]));
                if (pane.axisRect.Contains(fX, fY))
                {
                    peakx.Add((double)fX);
                    peaky.Add((double)fY);
                }
            }
        }
예제 #7
0
        /// <summary>
        /// Render this <see cref="TextItem"/> object to the specified <see cref="Graphics"/> device
        /// This method is normally only called by the Draw method
        /// of the parent <see cref="TextList"/> collection object.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="AldysPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="AldysPane"/> object using the
        /// <see cref="AldysPane.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public void Draw(Graphics g, AldysPane pane, double scaleFactor)
        {
            // transform the x,y location from the user-defined
            // coordinate frame to the screen pixel location
            PointF pix = pane.GeneralTransform(new PointF(this.x, this.y),
                                               this.coordinateFrame);

            // Draw the text on the screen, including any frame and background
            // fill elements
            if ((pix.X + this.WidthX) >= pane.paneRect.Width)
            {
                pix.X = pane.paneRect.Width - (this.WidthX + 5);
            }

            if (pix.X > -10000 && pix.X < 100000 && pix.Y > -100000 && pix.Y < 100000)
            {
                this.FontSpec.Draw(g, this.text, pix.X, pix.Y,
                                   this.alignH, this.alignV, scaleFactor);
            }
        }
예제 #8
0
 public void DrawManyEx(Graphics g, AldysPane pane, float[] x, float[] y, double scaleFactor, ArrayList xY)
 {
     // Only draw if the symbol is visible
     if (this.isVisible)
     {
         SolidBrush brush = new SolidBrush(this.color);
         Pen        pen   = new Pen(this.color, this.penWidth);
         int        nPts  = x.Length - 1;
         for (int i = 0; i < nPts; i++)
         {
             if (x[i] != System.Single.MaxValue &&
                 y[i] != System.Single.MaxValue)
             {
                 // Fill or draw the symbol as required
                 if ((((double)xY[i]) >= pane.YAxis.UpperAlarmLineY) && pane.YAxis.UpperAlarmLine)
                 {
                     pen.Color = pane.YAxis.UpperAlarmLineColor;
                 }
                 else if ((((double)xY[i]) <= pane.YAxis.LowerAlarmLineY) && pane.YAxis.LowerAlarmLine)
                 {
                     //pen.Color = pane.YAxis.LowerAlarmLineColor;
                     pen.Color = this.color;
                 }
                 else
                 {
                     pen.Color = this.color;
                 }
                 if (this.isFilled)
                 {
                     FillPoint(g, x[i], y[i], scaleFactor, pen, brush);
                 }
                 else
                 {
                     DrawPoint(g, x[i], y[i], scaleFactor, pen);
                 }
             }
         }
     }
 }
예제 #9
0
        /// <summary>
        /// Render this object to the specified <see cref="Graphics"/> device
        /// This method is normally only called by the Draw method
        /// of the parent <see cref="ArrowList"/> collection object.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="AldysPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="AldysPane"/> object using the
        /// <see cref="AldysPane.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public void Draw(Graphics g, AldysPane pane, double scaleFactor)
        {
            // Convert the arrow coordinates from the user coordinate system
            // to the screen coordinate system
            PointF pix1 = pane.GeneralTransform(new PointF(this.x1, this.y1),
                                                this.coordinateFrame);
            PointF pix2 = pane.GeneralTransform(new PointF(this.x2, this.y2),
                                                this.coordinateFrame);

            if (pix1.X > -10000 && pix1.X < 100000 && pix1.Y > -100000 && pix1.Y < 100000 &&
                pix2.X > -10000 && pix2.X < 100000 && pix2.Y > -100000 && pix2.Y < 100000)
            {
                // get a scaled size for the arrowhead
                float scaledSize = (float)(this.size * scaleFactor);

                // calculate the length and the angle of the arrow "vector"
                double dy     = pix2.Y - pix1.Y;
                double dx     = pix2.X - pix1.X;
                float  angle  = (float)Math.Atan2(dy, dx) * 180.0F / (float)Math.PI;
                float  length = (float)Math.Sqrt(dx * dx + dy * dy);

                // Save the old transform matrix
                Matrix transform = g.Transform;
                // Move the coordinate system so it is located at the starting point
                // of this arrow
                g.TranslateTransform(pix1.X, pix1.Y);
                // Rotate the coordinate system according to the angle of this arrow
                // about the starting point
                g.RotateTransform(angle);

                // get a pen according to this arrow properties
                Pen pen = new Pen(this.color, this.penWidth);

                // Draw the line segment for this arrow
                g.DrawLine(pen, 0, 0, length, 0);

                // Only show the arrowhead if required
                if (this.isArrowHead)
                {
                    SolidBrush brush = new SolidBrush(this.color);

                    // Create a polygon representing the arrowhead based on the scaled
                    // size
                    PointF[] polyPt = new PointF[4];
                    float    hsize  = scaledSize / 3.0F;
                    polyPt[0].X = length;
                    polyPt[0].Y = 0;
                    polyPt[1].X = length - size;
                    polyPt[1].Y = hsize;
                    polyPt[2].X = length - size;
                    polyPt[2].Y = -hsize;
                    polyPt[3]   = polyPt[0];

                    // render the arrowhead
                    g.FillPolygon(brush, polyPt);
                }

                // Restore the transform matrix back to its original state
                g.Transform = transform;
            }
        }
예제 #10
0
        /// <summary>
        /// Calculate the <see cref="Legend"/> rectangle (see cref="Rect"/>),
        /// taking into account the number of required legend
        /// entries, and the legend drawing preferences.  Adjust the size of the
        /// <see cref="AldysPane.AxisRect"/> for the parent <see cref="AldysPane"/> to accomodate the
        /// space required by the legend.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="AldysPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="AldysPane"/> object using the
        /// <see cref="AldysPane.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        /// <param name="axisRect">
        /// The rectangle that contains the area bounded by the axes, in pixel units.
        /// <seealso cref="AldysPane.AxisRect">AxisRect</seealso>
        /// </param>
        /// <param name="hStack">The number of columns (horizontal stacking) to be used
        /// for drawing the legend</param>
        /// <param name="legendWidth">The width of each column in the legend (pixels)</param>
        public void CalcRect(Graphics g, AldysPane pane, double scaleFactor,
                             ref RectangleF axisRect, out int hStack,
                             out float legendWidth)
        {
            // Start with an empty rectangle
            this.rect   = Rectangle.Empty;
            hStack      = 1;
            legendWidth = 1;

            // If the legend is invisible, don't do anything
            if (!this.isVisible)
            {
                return;
            }

            int   nCurve         = 0;
            float charHeight     = this.FontSpec.GetHeight(scaleFactor),
                  halfCharHeight = charHeight / 2.0F,
                  charWidth      = this.FontSpec.GetWidth(g, scaleFactor),
                  gap            = pane.ScaledGap(scaleFactor),
                  maxWidth       = 0,
                  tmpWidth;

            // Loop through each curve in the curve list
            // Find the maximum width of the legend labels
            foreach (CurveItem curve in pane.CurveList)
            {
                // Calculate the width of the label save the max width
                if (curve.Label.ToString() == "")
                {
                    continue;
                }
                tmpWidth = this.FontSpec.GetWidth(g, curve.Label, scaleFactor);

                if (tmpWidth > maxWidth)
                {
                    maxWidth = tmpWidth;
                }

                nCurve++;
            }

            float widthAvail;

            // Is this legend horizontally stacked?
            if (this.isHStack)
            {
                // Determine the available space for horizontal stacking
                switch (this.location)
                {
                // Never stack if the legend is to the right or left
                case LegendLoc.Right:
                case LegendLoc.Left:
                    widthAvail = 0;
                    break;

                // for the top & bottom, the axis frame width is available
                case LegendLoc.Top:
                case LegendLoc.Bottom:
                    widthAvail = pane.AxisRect.Width;
                    break;

                // for inside the axis area, use 1/2 of the axis frame width
                case LegendLoc.InsideTopRight:
                case LegendLoc.InsideTopLeft:
                case LegendLoc.InsideBotRight:
                case LegendLoc.InsideBotLeft:
                    widthAvail = pane.AxisRect.Width / 2;
                    break;

                // shouldn't ever happen
                default:
                    widthAvail = 0;
                    break;
                }

                // width of one legend entry
                legendWidth = 3 * charHeight + maxWidth;

                // Calculate the number of columns in the legend
                // Normally, the legend is:
                //     available width / ( max width of any entry + space for line&symbol )
                if (maxWidth > 0)
                {
                    hStack = (int)((widthAvail - halfCharHeight) / legendWidth);
                }

                // You can never have more columns than legend entries
                if (hStack > nCurve)
                {
                    hStack = nCurve;
                }

                // a saftey check
                if (hStack == 0)
                {
                    hStack = 1;
                }
            }
            else
            {
                legendWidth = 3.5F * charHeight + maxWidth;
            }

            // legend is:
            //   item:     space  line  space  text   space
            //   width:     wid  4*wid   wid  maxWid   wid
            // The symbol is centered on the line
            //
            // legend begins 3 * wid to the right of the plot rect
            //
            // The height of the legend is the actual height of the lines of text
            //   (nCurve * hite) plus wid on top and wid on the bottom

            // total legend width
            float totLegWidth = hStack * legendWidth;

            // The total legend height
            float legHeight = (float)Math.Ceiling((double)nCurve / (double)hStack)
                              * charHeight;

            // Now calculate the legend rect based on the above determined parameters
            // Also, adjust the plotArea and axisRect to reflect the space for the legend
            if (nCurve > 0)
            {
                // The switch statement assigns the left and top edges, and adjusts the axisRect
                // as required.  The right and bottom edges are calculated at the bottom of the switch.
                switch (this.location)
                {
                case LegendLoc.Right:
                    this.rect.X = pane.PaneRect.Right - totLegWidth - gap;
                    this.rect.Y = axisRect.Top;

                    axisRect.Width -= totLegWidth + halfCharHeight;
                    break;

                case LegendLoc.Top:
                    this.rect.X = axisRect.Left;
                    this.rect.Y = axisRect.Top;

                    axisRect.Y      += legHeight + halfCharHeight;
                    axisRect.Height -= legHeight + halfCharHeight;
                    break;

                case LegendLoc.Bottom:
                    this.rect.X = axisRect.Left;
                    this.rect.Y = pane.PaneRect.Bottom - legHeight - gap;

                    axisRect.Height -= legHeight + halfCharHeight;
                    break;

                case LegendLoc.Left:
                    this.rect.X = pane.PaneRect.Left + gap;
                    this.rect.Y = axisRect.Top;

                    axisRect.X     += totLegWidth + halfCharHeight;
                    axisRect.Width -= totLegWidth + halfCharHeight;
                    break;

                case LegendLoc.InsideTopRight:
                    this.rect.X = axisRect.Right - totLegWidth;
                    this.rect.Y = axisRect.Top;
                    break;

                case LegendLoc.InsideTopLeft:
                    this.rect.X = axisRect.Left;
                    this.rect.Y = axisRect.Top;
                    break;

                case LegendLoc.InsideBotRight:
                    this.rect.X = axisRect.Right - totLegWidth;
                    this.rect.Y = axisRect.Bottom - legHeight;
                    break;

                case LegendLoc.InsideBotLeft:
                    this.rect.X = axisRect.Left;
                    this.rect.Y = axisRect.Bottom - legHeight;
                    break;
                }

                // Calculate the Right and Bottom edges of the rect
                this.rect.Width  = totLegWidth;
                this.rect.Height = legHeight;
            }
        }
예제 #11
0
        /// <summary>
        /// Render the <see cref="Legend"/> to the specified <see cref="Graphics"/> device
        /// This method is normally only called by the Draw method
        /// of the parent <see cref="AldysPane"/> object.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="AldysPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="AldysPane"/> object using the
        /// <see cref="AldysPane.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        /// <param name="hStack">The number of columns (horizontal stacking) to be used
        /// for drawing the legend</param>
        /// <param name="legendWidth">The width of each column in the legend</param>
        public void Draw(Graphics g, AldysPane pane, double scaleFactor,
                         int hStack, float legendWidth)
        {
            // if the legend is not visible, do nothing
            if (!this.isVisible)
            {
                return;
            }

            // Fill the background with the specified color if required
            if (this.isFilled)
            {
                SolidBrush brush = new SolidBrush(this.fillColor);
                g.FillRectangle(brush, this.rect);
            }

            // Set up some scaled dimensions for calculating sizes and locations
            float charHeight     = this.FontSpec.GetHeight(scaleFactor),
                  halfCharHeight = charHeight / 2.0F;
            float charWidth      = this.FontSpec.GetWidth(g, scaleFactor);
            float gap            = pane.ScaledGap(scaleFactor);

            int   iEntry = 0;
            float x, y;

            // Get a brush for the legend label text
            SolidBrush brushB = new SolidBrush(Color.Black);

            // Loop for each curve in the CurveList collection
            foreach (CurveItem curve in pane.CurveList)
            {
                // Calculate the x,y (TopLeft) location of the current
                // curve legend label
                // assuming:
                //  charHeight/2 for the left margin, plus legendWidth for each
                //    horizontal column
                //  charHeight is the line spacing, with no extra margin above
                if (curve.Label.ToString() != "")
                {
                    x = this.rect.Left + halfCharHeight +
                        (iEntry % hStack) * legendWidth;
                    y = this.rect.Top + (int)(iEntry / hStack) * charHeight;
                    // Draw the legend label for the current curve
                    this.FontSpec.Draw(g, curve.Label, x + 2.5F * charHeight, y,
                                       FontAlignH.Left, FontAlignV.Top, scaleFactor);

                    // Draw a sample curve to the left of the label text
                    curve.Line.Draw(g, x, y + charHeight / 2,
                                    x + 2 * charHeight, y + halfCharHeight);
                    // Draw a sample symbol to the left of the label text
                    curve.Symbol.Draw(g, x + charHeight, y + halfCharHeight,
                                      scaleFactor);

                    // maintain a curve count for positioning
                    iEntry++;
                }
            }


            // Draw a frame around the legend if required
            if (iEntry > 0 && this.isFramed)
            {
                Pen pen = new Pen(this.frameColor, this.frameWidth);
                g.DrawRectangle(pen, Rectangle.Round(this.rect));
            }
        }
예제 #12
0
        /// <summary>
        /// Go through each <see cref="CurveItem"/> object in the collection,
        /// calling the <see cref="CurveItem.GetRange"/> member to
        /// determine the minimum and maximum values in the
        /// <see cref="CurveItem.X"/> and <see cref="CurveItem.Y"/> data arrays.  In the event that no
        /// data are available, a default range of min=0.0 and max=1.0 are returned.
        /// If any <see cref="CurveItem"/> in the list has a missing
        /// <see cref="CurveItem.X"/> or <see cref="CurveItem.Y"/> data array, and suitable
        /// default array will be created with ordinal values.
        /// </summary>
        /// <param name="xMinVal">The minimun X value in the data range for all curves
        /// in this collection</param>
        /// <param name="xMaxVal">The maximun X value in the data range for all curves
        /// in this collection</param>
        /// <param name="yMinVal">The minimun Y (left Y axis) value in the data range
        /// for all curves in this collection</param>
        /// <param name="yMaxVal">The maximun Y (left Y axis) value in the data range
        /// for all curves in this collection</param>
        /// <param name="y2MinVal">The minimun Y2 (right Y axis) value in the data range
        /// for all curves in this collection</param>
        /// <param name="y2MaxVal">The maximun Y2 (right Y axis) value in the data range
        /// for all curves in this collection</param>
        /// <param name="bIgnoreInitial">ignoreInitial is a boolean value that
        /// affects the data range that is considered for the automatic scale
        /// ranging (see <see cref="AldysPane.IsIgnoreInitial"/>).  If true, then initial
        /// data points where the Y value is zero are not included when
        /// automatically determining the scale <see cref="Axis.Min"/>,
        /// <see cref="Axis.Max"/>, and <see cref="Axis.Step"/> size.  All data after
        /// the first non-zero Y value are included.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="AldysPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        public void GetRange(out double xMinVal, out double xMaxVal,
                             out double yMinVal, out double yMaxVal,
                             out double y2MinVal, out double y2MaxVal,
                             bool bIgnoreInitial, AldysPane pane)
        {
            double tXMinVal,
                   tXMaxVal,
                   tYMinVal,
                   tYMaxVal;

            // initialize the values to outrageous ones to start
            xMinVal = yMinVal = y2MinVal = tXMinVal = tYMinVal = 1e20;
            xMaxVal = yMaxVal = y2MaxVal = tXMaxVal = tYMaxVal = -1e20;

            // Loop over each curve in the collection
            foreach (CurveItem curve in this)
            {
                // Generate default arrays of ordinal values if any data arrays are missing
                curve.DataCheck(pane);

                // Call the GetRange() member function for the current
                // curve to get the min and max values
                curve.GetRange(ref tXMinVal, ref tXMaxVal,
                               ref tYMinVal, ref tYMaxVal, bIgnoreInitial);

                // If the min and/or max values from the current curve
                // are the absolute min and/or max, then save the values
                // Also, differentiate between Y and Y2 values
                if (curve.IsY2Axis)
                {
                    if (tYMinVal < y2MinVal)
                    {
                        y2MinVal = tYMinVal;
                    }
                    if (tYMaxVal > y2MaxVal)
                    {
                        y2MaxVal = tYMaxVal;
                    }
                }
                else
                {
                    if (tYMinVal < yMinVal)
                    {
                        yMinVal = tYMinVal;
                    }
                    if (tYMaxVal > yMaxVal)
                    {
                        yMaxVal = tYMaxVal;
                    }
                }

                if (tXMinVal < xMinVal)
                {
                    xMinVal = tXMinVal;
                }
                if (tXMaxVal > xMaxVal)
                {
                    xMaxVal = tXMaxVal;
                }
            }

            // Define suitable default ranges in the event that
            // no data were available
            if (xMinVal >= 1e20 || xMaxVal <= -1e20)
            {
                xMinVal = 0;
                xMaxVal = 1;
            }

            if (yMinVal >= 1e20 || yMaxVal <= -1e20)
            {
                yMinVal = 0;
                yMaxVal = 1;
            }

            if (y2MinVal >= 1e20 || y2MaxVal <= -1e20)
            {
                y2MinVal = 0;
                y2MaxVal = 1;
            }
        }
예제 #13
0
        /// <summary>
        /// Do all rendering associated with this <see cref="CurveItem"/> to the specified
        /// <see cref="Graphics"/> device.  This method is normally only
        /// called by the Draw method of the parent <see cref="AldysGraph.CurveList"/>
        /// collection object.  This version is optimized for speed and should be much
        /// faster than the regular Draw() routine.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="AldysGraph.AldysPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="ZedGraph.AldysPane"/> object using the
        /// <see cref="AldysPane.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public void Draw(Graphics g, AldysPane pane, double scaleFactor)
        {
            int nPts = this.NPts - 1;

            float[] tmpX;
            float[] tmpY;
            int     i = 0;

            if ((this.isHighPeakLine == false) && (this.AddPointFlg == false) || (this.AddPointFlg == true && pane.CurveList.isResizing))
            {
                tmpX = new float[nPts];
                tmpY = new float[nPts];

                // Loop over each point in the curve
                for (i = 0; i < nPts; i++)
                {
                    if (((double)this.X[i]) == System.Double.MaxValue ||
                        ((double)this.Y[i]) == System.Double.MaxValue ||
                        (pane.XAxis.IsLog && ((double)this.X[i]) <= 0.0) ||
                        //( this.isY2Axis && pane.Y2Axis.IsLog && this.Y[i] <= 0.0 ) ||
                        (!this.isY2Axis && pane.YAxis.IsLog && ((double)this.Y[i]) <= 0.0))
                    {
                        tmpX[i] = float.MaxValue;
                        tmpY[i] = float.MaxValue;
                    }
                    else
                    {
                        // Transform the current point from user scale units to
                        // screen coordinates
                        tmpX[i] = pane.XAxis.Transform(((double)this.X[i]));
                        tmpY[i] = pane.YAxis.Transform(((double)this.Y[i]));

                        if (tmpX[i] < -100000 || tmpX[i] > 100000 ||
                            tmpY[i] < -100000 || tmpY[i] > 100000)
                        {
                            tmpX[i] = System.Single.MaxValue;
                            tmpY[i] = System.Single.MaxValue;
                        }
                    }
                }

                this.Line.ColorList = this.CL;
                this.Line.DrawManyEx(g, pane, tmpX, tmpY, this.Y);
                //pane.CurveList.isResizing = false;

                if ((this.SYM.Count > 0) && (this.CL.Count > 0))
                {
                    this.Symbol.DrawMany(g, tmpX, tmpY, scaleFactor, this.CL, this.SYM);
                }
                else
                {
                    this.Symbol.DrawManyEx(g, pane, tmpX, tmpY, scaleFactor, this.Y);
                }

                if (this.mblnIsScatteredPointsCurve)
                {
                    //Plot the scattered points
                    for (i = 0; i < this.ScatteredPoints.Count; i++)
                    {
                        //---Draw the single point
                        Point objPoint   = (Point)ScatteredPoints[i];
                        float fX         = pane.XAxis.Transform((double)objPoint.X);
                        float fY         = pane.YAxis.Transform((double)objPoint.Y);
                        Color curveColor = this.Symbol.Color;
                        this.Symbol.Color = objPoint.PointColor;
                        this.Symbol.Size  = objPoint.PointRadius;
                        this.Symbol.Draw(g, fX, fY, scaleFactor);
                        this.Symbol.Color = curveColor;
                    }
                }
            }
            else
            {
                if (nPts == 1 || nPts == 0)
                {
                    //---in future to draw single point in curve
                    //---Added By Mangesh S. on 26-Nov-2006
                    //if (this.mblnIsScatteredPointsCurve){
                    //---Loop over each point in the curve
                    //for ( i=0; i < this.NPts ; i++ )
                    //{
                    //	//---Draw the single point
                    //	float fX = pane.XAxis.Transform( ((double)this.X[i]));
                    //	float fY = pane.YAxis.Transform( ((double)this.Y[i]));
                    //	this.Symbol.Draw(g,fX,fY,scaleFactor);
                    //}
                    //}
                    return;
                }

                tmpX = new float[2];
                tmpY = new float[2];
                int j;

                //Draw only for last two points
                for (i = this.NPts - 2, j = 0; i < this.NPts; i++, j++)
                {
                    if (((double)this.X[i]) == System.Double.MaxValue ||
                        ((double)this.Y[i]) == System.Double.MaxValue ||
                        (pane.XAxis.IsLog && ((double)this.X[i]) <= 0.0) ||
                        (!this.isY2Axis && pane.YAxis.IsLog && ((double)this.Y[i]) <= 0.0))
                    {
                        tmpX[j] = System.Single.MaxValue;
                        tmpY[j] = System.Single.MaxValue;
                    }
                    else
                    {
                        // Transform the current point from user scale units to
                        // screen coordinates
                        tmpX[j] = pane.XAxis.Transform(((double)this.X[i]));
                        tmpY[j] = pane.YAxis.Transform(((double)this.Y[i]));

                        if (tmpX[j] < -100000 || tmpX[j] > 100000 ||
                            tmpY[j] < -100000 || tmpY[j] > 100000)
                        {
                            tmpX[j] = System.Single.MaxValue;
                            tmpY[j] = System.Single.MaxValue;
                        }
                    }
                }

                this.Line.DrawManyEx(g, pane, tmpX, tmpY, this.Y);
                this.Symbol.DrawMany(g, tmpX, tmpY, scaleFactor);
            }
        }
예제 #14
0
        public void DrawManyEx(Graphics g, AldysPane pane, float[] x, float[] y, ArrayList xY)
        {
            if (this.isVisible)
            {
                Pen pen = new Pen(this.color, this.width);
                pen.DashStyle = this.Style;
                int   nSeg = x.Length - 1;
                int   iPlus = 0;
                float xTmp, yTmp;
                xTmp = yTmp = 0;
                float slope, constant;
                slope = constant = 0;

                for (int i = 0; i < nSeg; i++)
                {
                    iPlus++;
                    if (x[i] != System.Single.MaxValue &&
                        x[iPlus] != System.Single.MaxValue &&
                        y[i] != System.Single.MaxValue &&
                        y[iPlus] != System.Single.MaxValue)
                    {
                        if (this.StepType == StepType.NonStep)
                        {
                            if ((((double)xY[i]) >= pane.YAxis.UpperAlarmLineY) && (((double)xY[iPlus]) >= pane.YAxis.UpperAlarmLineY) && pane.YAxis.UpperAlarmLine)
                            {
                                pen.Color = pane.YAxis.UpperAlarmLineColor;
                                CurveStatus cStatus = new CurveStatus(1);
                                pane.GetStatusEvent(cStatus);
                                g.DrawLine(pen, x[i], y[i], x[iPlus], y[iPlus]);
                            }
                            else if ((((double)xY[i]) < pane.YAxis.UpperAlarmLineY) && (((double)xY[iPlus]) > pane.YAxis.UpperAlarmLineY) && pane.YAxis.UpperAlarmLine)
                            {
                                //find the slope of the line
                                if (x[i] - x[iPlus] != 0)
                                {
                                    slope    = (y[iPlus] - y[i]) / (x[iPlus] - x[i]);
                                    constant = y[i] - (((y[iPlus] - y[i]) / (x[iPlus] - x[i])) * x[i]);
                                }
                                //find the new point
                                yTmp      = pane.YAxis.Transform(pane.YAxis.UpperAlarmLineY);
                                xTmp      = (yTmp - constant) / slope;
                                pen.Color = this.color;
                                g.DrawLine(pen, x[i], y[i], xTmp, yTmp);
                                pen.Color = pane.YAxis.UpperAlarmLineColor;
                                CurveStatus cStatus = new CurveStatus(1);
                                pane.GetStatusEvent(cStatus);
                                g.DrawLine(pen, xTmp, yTmp, x[iPlus], y[iPlus]);
                            }
                            else if ((((double)xY[i]) > pane.YAxis.UpperAlarmLineY) && (((double)xY[iPlus]) < pane.YAxis.UpperAlarmLineY) && pane.YAxis.UpperAlarmLine)
                            {
                                //find the slope of the line
                                if (x[i] - x[iPlus] != 0)
                                {
                                    slope    = (y[iPlus] - y[i]) / (x[iPlus] - x[i]);
                                    constant = y[i] - (((y[iPlus] - y[i]) / (x[iPlus] - x[i])) * x[i]);
                                }
                                //find the new point
                                yTmp      = pane.YAxis.Transform(pane.YAxis.UpperAlarmLineY);
                                xTmp      = (yTmp - constant) / slope;
                                pen.Color = pane.YAxis.UpperAlarmLineColor;
                                CurveStatus cStatus = new CurveStatus(1);
                                pane.GetStatusEvent(cStatus);
                                g.DrawLine(pen, x[i], y[i], xTmp, yTmp);
                                pen.Color = this.color;
                                g.DrawLine(pen, xTmp, yTmp, x[iPlus], y[iPlus]);
                            }

                            else if ((((double)xY[i]) <= pane.YAxis.LowerAlarmLineY) && (((double)xY[iPlus]) <= pane.YAxis.LowerAlarmLineY) && pane.YAxis.LowerAlarmLine)
                            {
                                pen.Color = this.color;
                                //Sachin Ashtankar
                                //pen.Color = pane.YAxis.LowerAlarmLineColor;
                                CurveStatus cStatus = new CurveStatus(-1);
                                pane.GetStatusEvent(cStatus);
                                g.DrawLine(pen, x[i], y[i], x[iPlus], y[iPlus]);
                            }
                            else if ((((double)xY[i]) > pane.YAxis.LowerAlarmLineY) && (((double)xY[iPlus]) < pane.YAxis.LowerAlarmLineY) && pane.YAxis.LowerAlarmLine)
                            {
                                //find the slope of the line

                                if (x[i] - x[iPlus] != 0)
                                {
                                    slope    = (y[iPlus] - y[i]) / (x[iPlus] - x[i]);
                                    constant = y[i] - (((y[iPlus] - y[i]) / (x[iPlus] - x[i])) * x[i]);
                                }
                                //find the new point
                                yTmp = pane.YAxis.Transform(pane.YAxis.LowerAlarmLineY);
                                xTmp = (yTmp - constant) / slope;

                                pen.Color = this.color;
                                g.DrawLine(pen, x[i], y[i], xTmp, yTmp);
                                pen.Color = pane.YAxis.LowerAlarmLineColor;
                                CurveStatus cStatus = new CurveStatus(1);
                                pane.GetStatusEvent(cStatus);
                                g.DrawLine(pen, xTmp, yTmp, x[iPlus], y[iPlus]);
                            }
                            else if ((((double)xY[i]) < pane.YAxis.LowerAlarmLineY) && (((double)xY[iPlus]) > pane.YAxis.LowerAlarmLineY) && pane.YAxis.LowerAlarmLine)
                            {
                                //find the slope of the line

                                if (x[i] - x[iPlus] != 0)
                                {
                                    slope    = (y[iPlus] - y[i]) / (x[iPlus] - x[i]);
                                    constant = y[i] - (((y[iPlus] - y[i]) / (x[iPlus] - x[i])) * x[i]);
                                }
                                //find the new point
                                yTmp      = pane.YAxis.Transform(pane.YAxis.LowerAlarmLineY);
                                xTmp      = (yTmp - constant) / slope;
                                pen.Color = this.color;
                                g.DrawLine(pen, xTmp, yTmp, x[iPlus], y[iPlus]);
                                pen.Color = pane.YAxis.LowerAlarmLineColor;
                                CurveStatus cStatus = new CurveStatus(1);
                                pane.GetStatusEvent(cStatus);
                                g.DrawLine(pen, x[i], y[i], xTmp, yTmp);
                            }
                            else
                            {
                                if (this.CL.Count > 0)
                                {
                                    pen.Color = (Color)this.CL[i];                             //this.color;
                                }
                                else
                                {
                                    pen.Color = this.color;
                                }

                                CurveStatus cStatus = new CurveStatus(0);
                                pane.GetStatusEvent(cStatus);
                                g.DrawLine(pen, x[i], y[i], x[iPlus], y[iPlus]);
                            }

                            //g.DrawLine( pen, xTmp, y[i], x[iPlus], y[iPlus] );
                        }

                        else if (this.StepType == StepType.ForwardStep)
                        {
                            g.DrawLine(pen, x[i], y[i], x[iPlus], y[i]);
                            g.DrawLine(pen, x[iPlus], y[i], x[iPlus], y[iPlus]);
                        }
                        else if (this.StepType == StepType.RearwardStep)
                        {
                            g.DrawLine(pen, x[i], y[i], x[i], y[iPlus]);
                            g.DrawLine(pen, x[i], y[iPlus], x[iPlus], y[iPlus]);
                        }
                    }
                }
            }
        }