예제 #1
0
        // 2005-03-08 Cursor Option Added.
        /*
        private bool FCursorMode = false ;
        [Category("Plotter")]
        [Description("The cursor mode of plotter.")]
        public bool CursorMode
        {
            get { return FCursorMode ; }
            set { if ( ! grid && ! ShowLegend ) FCursorMode = value; }
        }
        */
        protected override void OnPaint(PaintEventArgs e)
        {
            if(bIsColorMap == false)
            {
                int x0, y0, x1, y1, w0, h0, w1=0, h1=0;
                int i, j, x, y, n, d, d1;
                string s;

            //				try	// overall exception handling to avoid crashes
            //				{
                    // check properties
                    if (xRangeEnd <= xRangeStart) return;
                    if (yRangeEnd <= yRangeStart) return;
                    if ( FXAxisMode == XAxisModeType.Linear )   // linear.
                    {
                        if (xGrid <= 0) return;
                    }
                    else                // logarithmic
                    {
                        if (xRangeStart <= 0) return;
                    }

                    switch ( FYAxisMode )
                    {
                        case YAxisModeType.Linear :  // linear.
                            if (yGrid <= 0) return;
                            break;
                        case YAxisModeType.Log10 :   // logarithmic.
                            if (yRangeStart <= 0) return;
                            break;
                        case YAxisModeType.dB :
                            if (yRangeStart <= 0) return;     // dB Mode.
                            break;
                    }

                    // prepare the tools
                    Graphics g = e.Graphics;
                    e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
                    g.FillRectangle(new SolidBrush(colorBg), ClientRectangle);
                    Pen penDraw = new Pen(colorDraw, penWidth);
                    Pen penGrid = new Pen(colorGrid, 1);
                    Pen penAxis = new Pen(colorAxis, 1);
                    Pen penTitle = new Pen(titlecolor, 3);
                    Pen penLabel = new Pen(xlabelcolor, 2);
                    SolidBrush brushAxis = new SolidBrush(colorAxis);
                    SolidBrush brushTitle = new SolidBrush(titlecolor);
                    SolidBrush xBrushLabel = new SolidBrush(xlabelcolor);
                    SolidBrush yBrushLabel = new SolidBrush(ylabelcolor);

                    // calculate coordinates, width and hight inside
                    x0 = ClientRectangle.Left + borderLeft;
                    y0 = ClientRectangle.Top + borderTop;
                    w0 = ClientRectangle.Width - borderLeft - borderRight;
                    h0 = ClientRectangle.Height - borderTop - borderBottom;
                    x1 = ClientRectangle.Right - borderRight;
                    y1 = ClientRectangle.Bottom - borderBottom;

                    // draw title and label

                    s = title ;
                    SizeF tp = g.MeasureString(s, fontTitle);
                    //				g.DrawString(s, fontTitle, brushTitle, ClientRectangle.Left + w0/2-tp.Width/2, ClientRectangle.Top + 5);
                    // ���⸮�� ������ �κ�
                    g.DrawString(s, fontTitle, brushTitle, ((ClientRectangle.Left + ClientRectangle.Right) / 2) - (tp.Width / 2), ClientRectangle.Top + 5);
                    // �������

                    s = xlabel ;
                    tp = g.MeasureString(s, fontLabel);
                    g.DrawString(s, fontLabel, xBrushLabel, ((ClientRectangle.Left + ClientRectangle.Right) / 2) - (tp.Width / 2), ClientRectangle.Bottom - 20);

                    s = ylabel;
                    tp = g.MeasureString(s, fontLabel);
                    StringFormat drawFormat = new StringFormat();
                    //drawFormat.FormatFlags = StringFormatFlags.DirectionVertical;
                drawFormat.FormatFlags = StringFormatFlags.FitBlackBox;
                    //				g.DrawString(s, fontLabel, yBrushLabel, ClientRectangle.Left + 5, ClientRectangle.Top + tp.Width + 10, drawFormat);
                    // ���⸮�� ������ �κ�
                g.RotateTransform(-90,System.Drawing.Drawing2D.MatrixOrder.Append);
                g.DrawString(s, fontLabel, yBrushLabel, ((ClientRectangle.Top - ClientRectangle.Bottom) / 2) - (tp.Width / 2),ClientRectangle.Left + 10, drawFormat);
                //g.DrawString(s, fontLabel, yBrushLabel, ClientRectangle.Left - 200, ((ClientRectangle.Top + ClientRectangle.Bottom) / 2) - 180, drawFormat);
                //	g.DrawString(s, fontLabel, yBrushLabel, ClientRectangle.Left + 10, ((ClientRectangle.Top + ClientRectangle.Bottom) / 2) - (tp.Width / 2), drawFormat);
                g.RotateTransform(90,System.Drawing.Drawing2D.MatrixOrder.Append);
                // �������
                    drawFormat.Dispose();

                    // draw grid
                    switch ( FXAxisMode )
                    {
                        case XAxisModeType.Linear :  // linear.
                            if(IsOctave == false)
                            {
                                n = Convert.ToInt32(Math.Floor((xRangeEnd - xRangeStart) / xGrid));
                                if (n == 0) n = 1;
                                d = (int)(w0 * xGrid / (xRangeEnd - xRangeStart));
                                for (i = 0; i <= n; i++)
                                {
                                    x = x0 + i * d;

                                    // grid ����� ������ �׸��带 �׸���.

                                    if ( grid ) g.DrawLine(penGrid, x, y0, x, y1);

                                    // �����Ͱ� �ִٸ� ���� �׸��� ������ tick marker �� �׸���.

                                    //							if ( series.Count > 0 ) // �����ǰ� ( xData != null && yData != null)
                                    //							{
                                    g.DrawLine(penAxis, x, y1, x, y1-5);
                                    g.DrawLine(penAxis, x, y0, x, y0+5);
                                    //							}

                                    // Tick Label
                                    s = Convert.ToString(xRangeStart + xGrid * i);
                                    SizeF sf = g.MeasureString(s, fontAxis);
                                    g.DrawString(s, fontAxis, brushAxis, x - sf.Width / 2, y1 + sf.Height / 2);
                                }

                                w1 = d * n;
                            }
                            else
                            {
                                n = Convert.ToInt32(((DataSeries)this.series[0]).XData.Length);

                                float w0_Temp = w0;
                                float n_Temp = n;
                                float fTemp_d = w0_Temp / n_Temp ;
                                float xd = 0;
                                int count = Interval;
                                for (i = 0; i < n; i++)
                                {
                                    if(i == 0.0)
                                    {
                                        xd = fTemp_d / 2;
                                    }
                                    else
                                    {
                                        xd = fTemp_d + xd ;
                                    }

                                    x = (int)(x0 + xd);

                                    // grid ����� ������ �׸��带 �׸���.

                                    if ( grid ) g.DrawLine(penGrid, x, y0, x, y1);

                                    if(Interval > 0)
                                    {
                                        if(Interval == count)
                                        {
                                            // ���� �׸��� ������ tick marker �� �׸���.
                                            g.DrawLine(penAxis, x, y1, x, y1-5);
                                            g.DrawLine(penAxis, x, y0, x, y0+5);

                                            s = Convert.ToString(((DataSeries)series[0]).XData[(int)i]);
                                            SizeF sf = g.MeasureString(s, fontAxis);
                                            g.DrawString(s, fontAxis, brushAxis, x - sf.Width / 2, y1 + sf.Height / 2);

                                            count = 0;
                                        }
                                    }
                                    else
                                    {
                                        // ���� �׸��� ������ tick marker �� �׸���.
                                        g.DrawLine(penAxis, x, y1, x, y1-5);
                                        g.DrawLine(penAxis, x, y0, x, y0+5);

                                        s = Convert.ToString(((DataSeries)series[0]).XData[(int)i]);
                                        SizeF sf = g.MeasureString(s, fontAxis);
                                        g.DrawString(s, fontAxis, brushAxis, x - sf.Width / 2, y1 + sf.Height / 2);
                                    }

                                    count++;
                                }

                                w1 = (int)(fTemp_d * n);
                            }
                            break;

                        case XAxisModeType.Log10 :					// logarithmic
                            //if ( xRangeStart > 0 )
                            n = Convert.ToInt32(Math.Log10(xRangeEnd) - Math.Log10(xRangeStart));
                            //else
                            //n = Convert.ToInt32(Math.Log10(xRangeEnd));
                            if (n == 0) n = 1;
                            d = w0 / n;
                            for (i = 0; i <= n; i++)
                            {
                                x = x0 + i * d;
                                if (i < n)
                                {
                                    for (j = 1; j < 10 /* log base */ ; j++)
                                    {
                                        d1 = Convert.ToInt32(Math.Log10(j) * d);

                                        // grid ����� ������ �׸��带 �׸���.

                                        if ( grid ) g.DrawLine(penGrid, x + d1, y0, x + d1, y1);
                                    }
                                }

                                // �����Ͱ� �ִٸ� ���� �׸��� ������ tick marker �� �׸���.

                                //							if ( series.Count > 0 ) // �����ǰ� ( xData != null && yData != null)
                                //							{
                                g.DrawLine(penAxis, x, y1, x, y1-5);
                                g.DrawLine(penAxis, x, y0, x, y0+5);
                                //							}

                                if ( xRangeStart > 0 )
                                    s = Convert.ToString(Math.Pow(10, Math.Log10(xRangeStart) + i));
                                else
                                {
                                    if ( i == 0 ) s = "0";
                                    if ( i != 0 ) s = Convert.ToString(Math.Pow(10, 0 + i));
                                }
            //								int Temp_ss = (int)double.Parse(s);
            //								s = Temp_ss.ToString();
                                SizeF sf = g.MeasureString(s, fontAxis);
                                g.DrawString(s, fontAxis, brushAxis, x - sf.Width / 2, y1 + sf.Height / 2);
                            }

                            w1 = d * n;
                            break;
                    }

                    switch ( FYAxisMode )
                    {
                        case YAxisModeType.Linear :  // linear.

                            n = Convert.ToInt32(Math.Floor((yRangeEnd - yRangeStart) / yGrid));
                            if (n == 0) n = 1;
                            d = (int)(h0 * yGrid / (yRangeEnd - yRangeStart));
                            for (i = 0; i <= n; i++)
                            {
                                y = y1 - i * d;

                                // grid ����� ������ �׸��带 �׸���.

                                if ( grid ) g.DrawLine(penGrid, x0, y, x1, y);

                                // �����Ͱ� �ִٸ� ���� �׸��� ������ tick marker �� �׸���.

                                //							if ( series.Count > 0 ) // �����ǰ� ( xData != null && yData != null)
                                //							{
                                g.DrawLine(penAxis, x0, y, x0+5, y);
                                g.DrawLine(penAxis, x1, y, x1-5, y);
                                //							}

                                s = Convert.ToString(yRangeStart + yGrid * i);
                                SizeF sf = g.MeasureString(s, fontAxis);
                                g.DrawString(s, fontAxis, brushAxis, x0 - sf.Width - sf.Height / 4, y - sf.Height / 2);
                            }

                            h1 = d * n;
                            break;

                        case YAxisModeType.Log10 :   // logarithmic.

                            n = Convert.ToInt32(Math.Log10(yRangeEnd) - Math.Log10(yRangeStart));
                            if (n == 0) n = 1;
                            d = h0 / n;
                            for (i = 0; i <= n; i++)
                            {
                                y = y1 - i * d;
                                if (i < n)
                                {
                                    for (j = 1; j < 10 ; j++)
                                    {
                                        d1 = Convert.ToInt32(Math.Log10(j) * d);

                                        // grid ����� ������ �׸��带 �׸���.

                                        if (grid ) g.DrawLine(penGrid, x0, y - d1, x1, y - d1);
                                    }
                                }

                                // �����Ͱ� �ִٸ� ���� �׸��� ������ tick marker �� �׸���.

                                //							if ( series.Count > 0 ) // �����ǰ� ( xData != null && yData != null)
                                //							{
                                g.DrawLine(penAxis, x0, y, x0+5, y);
                                g.DrawLine(penAxis, x1, y, x1-5, y);
                                //							}

                                s = Convert.ToString(Math.Pow(10, Math.Log10(yRangeStart) + i));
            //								int Temp_ss = (int)double.Parse(s);
            //								s = Temp_ss.ToString();
                                SizeF sf = g.MeasureString(s, fontAxis);
                                g.DrawString(s, fontAxis, brushAxis, x0 - sf.Width - sf.Height / 4, y - sf.Height / 2);
                            }

                            h1 = d * n;
                            break;

                        case YAxisModeType.dB :  // dB Mode.

                            n = Convert.ToInt32((yRangeEnd - yRangeStart) / yGrid);
                            if (n == 0) n = 1;
                            d = h0 / n;
                            for (i = 0; i <= n; i++)
                            {
                                y = y1 - i * d;

                                // grid ����� ������ �׸��带 �׸���.

                                if ( grid ) g.DrawLine(penGrid, x0, y, x1, y);

                                // �����Ͱ� �ִٸ� ���� �׸��� ������ tick marker �� �׸���.

                                //							if ( series.Count > 0 ) // �����ǰ� ( xData != null && yData != null)
                                //							{
                                g.DrawLine(penAxis, x0, y, x0+5, y);
                                g.DrawLine(penAxis, x1, y, x1-5, y);
                                //							}

                                s = Convert.ToString(yRangeStart + (yRangeEnd - yRangeStart) * i / n);
            //								int Temp_ss = (int)double.Parse(s);
            //								s = Temp_ss.ToString();
                                SizeF sf = g.MeasureString(s, fontAxis);
                                g.DrawString(s, fontAxis, brushAxis, x0 - sf.Width - sf.Height / 4, y - sf.Height / 2);
                            }

                            h1 = d * n;
                            break;
                    }

                    // draw axis
                    g.DrawRectangle(penAxis, x0, y0, w0, h0);

                    // Correct internal width and height.
                    // This is necessary because equidistant grid lines may not fit into
                    // the axis rectangle without rounding errors
                    //h0 = h1;
                    //w0 = w1;

                    // draw data if available

                    if ( series.Count == 0 ) return;

                    for ( int ppp = 0 ; ppp < series.Count ; ++ ppp )
                    {
                        DataSeries tSeries = new DataSeries() ;
                        tSeries = (DataSeries)series[ppp];
                        if ( tSeries.XData.Length != tSeries.YData.Length ) return ;
                    }

                    // draw legend - ���� ��ġ �߿�.
                    // �� �� if �� ���ų� ���� ���� �Ϸ��� ���ǿ� && (xData != null && yData != null) �߰�.

                    if ( showlegend )
                    {
                        int lb_w = 0, lb_h = 0, ln_w = 0, ln_h = 0, lx0, ly0, max_CapW = 0;
                        // lb_w : legend box width.     lb_h : legend box height.
                        // ln_w : legend name width.    ln_w : legend name height.
                        // lx0  : legend box x position ly0 : legend box y position.
                        // max_CapW : ���� �� ������ ���� ���� .

                        DataSeries tSeries = new DataSeries();

                        float[] ln_hs = new float[series.Count]; // ������ ���ڵ� ������ �迭�̴�.

                        for ( int ppp = 0; ppp < series.Count ; ++ ppp )
                        {
                            tSeries = (DataSeries)series[ppp];

                            s = tSeries.Name ;  // ���� s  = legendname ;
                            tp = g.MeasureString(s, tSeries.Font); // ���� fontLegend);
                            ln_w = Convert.ToInt32(tp.Width);
                            ln_h += Convert.ToInt32(tp.Height);
                            ln_hs[ppp] = tp.Height ;
                            if( max_CapW < ln_w )
                            {
                                max_CapW = ln_w;
                            }
                            else
                            {
                                max_CapW = max_CapW ;
                            }

                            /* ������ �����尡 �ƴϸ� ���ݵ� ���Խ�Ų��. */
                            if ( ppp + 1 != series.Count ) ln_h += 2 ; // �ø������ �� ������ 2������.
                        }

                        ln_w = max_CapW;

                        lb_w = 30+2+ln_w+10*2;
                        lb_h = ln_h+3*2;
                        lx0 = 0;
                        ly0 = 0;
                        if(LegendPosition_ == LegendPosition_Enum.RIGHT_TOP)
                        {
                            lx0  = x0+w0-lb_w-4;
                            ly0 = y0+10;
                        }
                        else if(LegendPosition_ == LegendPosition_Enum.LEFT_TOP)
                        {
                            lx0  = x0 + 4;
                            ly0 = y0+10;
                        }

                        if(LegendPosition_ == LegendPosition_Enum.RIGHT_DOWN)
                        {
                            lx0  = x0+w0-lb_w-4;
                            ly0 = y1 - lb_h - 10;
                        }
                        else if(LegendPosition_ == LegendPosition_Enum.LEFT_DOWN)
                        {
                            lx0  = x0 + 4;
                            ly0 = y1 - lb_h - 10;
                        }

                        // ������ �ڽ��� �׸���.
                        g.DrawRectangle(penAxis, lx0, ly0, lb_w, lb_h);

                        PointF[] lp = new PointF[2];

                        float Lcyp = ly0+3;  // legend caption Y position.
                        // ���� �����带 �׷�����.

                        for ( int ppp = 0; ppp < series.Count ; ++ ppp )
                        {
                            tSeries = (DataSeries)series[ppp];
                            s = tSeries.Name ;
                            Pen tpen = new Pen(tSeries.Color);
                            lp[0].X = lx0+10; lp[1].X = lp[0].X+30;
                            lp[0].Y = Lcyp+ln_hs[ppp]/2;
                            lp[1].Y = lp[0].Y ;
                            g.DrawLine(tpen, lp[0], lp[1]);
                            g.DrawString(s, tSeries.Font, xBrushLabel, lp[1].X + 2, Lcyp);
                            Lcyp = Lcyp + ln_hs[ppp] + 2 ;
                        }
                    }

                    // first convert the data arrays into points inside the axis rectangle

                    DataSeries pSeries = new DataSeries();

                    for ( int ppp = 0 ; ppp < series.Count ; ++ ppp )
                    {
                        pSeries = (DataSeries)series[ppp];

                        Pen ppen = new Pen(pSeries.Color, pSeries.PenWidth);

                        Point[] pt = new Point[pSeries.XData.Length];
                        Point lastValidPt = new Point(x0, y1);

                        n = Convert.ToInt32(((DataSeries)this.series[0]).XData.Length);

                        float w0_Temp = w0;
                        float n_Temp = n;
                        float fTemp_d = w0_Temp / n_Temp ;
                        float xd = 0;

                        for (i = 0; i < pt.Length; i++)
                        {
            //							try	// catch invalid data points
            //							{
                                switch ( FXAxisMode )
                                {
                                    case XAxisModeType.Linear :  // linear.
                                        if(this.IsOctave == true)
                                        {
                                            if(i == 0)
                                            {
                                                xd = fTemp_d / 2;
                                            }
                                            else
                                            {
                                                xd = fTemp_d + xd ;
                                            }

                                            x = (int)(x0 + xd);

                                            pt[i].X = x;
                                        }
                                        else
                                        {
                                            pt[i].X = (int)(x0 + (pSeries.XData[i] - xRangeStart) / (xRangeEnd - xRangeStart) * w0);
                                        }
                                        break;
                                    case XAxisModeType.Log10 :   // logarithmic
                                        pt[i].X = (int)(x0 + (Math.Log10(pSeries.XData[i]) - Math.Log10(xRangeStart)) / (Math.Log10(xRangeEnd) - Math.Log10(xRangeStart)) * w0);
                                        break;
                                }

                                switch ( FYAxisMode )
                                {
                                    case YAxisModeType.Linear :  // linear.
                                        pt[i].Y = (int)(y1 - (pSeries.YData[i] - yRangeStart) / (yRangeEnd - yRangeStart) * h0);
                                        break;
                                    case YAxisModeType.Log10 :   // logarithmic
                                        pt[i].Y = (int)(y1 - (Math.Log10(pSeries.YData[i]) - Math.Log10(yRangeStart)) / (Math.Log10(yRangeEnd) - Math.Log10(yRangeStart)) * h0);
                                        break;

                                    case YAxisModeType.dB    :   // dB
                                        pt[i].Y = (int)(y1 - (pSeries.YData[i] - yRangeStart) / (yRangeEnd - yRangeStart) * h0);
                                        break;
                                }

                                lastValidPt = pt[i];
            //							}
            //							catch(System.Exception )
            //							{
                                pt[i] = lastValidPt;	// redraw last valid point on error
            //							}

                        }

                        // now draw the points
                        g.Clip = new Region(new Rectangle(new Point(x0, y0), new Size(w0, h0)));

                        for (i = 0; i < pt.Length; i++)
                        {
                            if ( ( pt[i].X >= x0 && pt[i].X <= x0 + w0 ) && ( pt[i].Y >= y0 && pt[i].Y <= y0 + h0 ) )  // �׷��� �������� �׸��� �׸���.
                            {
                                switch(drawMode)
                                {
                                    case DrawModeType.Dot:
                                        Debug.WriteLine("Dot");
                                        g.DrawEllipse(ppen, pt[i].X - penWidth / 2, pt[i].Y - penWidth / 2, penWidth, penWidth);
                                        break;

                                    case DrawModeType.Bar:
                                        Debug.WriteLine("Bar");
                                        g.DrawLine(ppen, new Point(pt[i].X, y1), pt[i]);
                                        break;

                                    default:
                                        // Draw mode �� dot�� bar�� ��� ������ ��ü�� �̻����̹Ƿ� Line Mode �ÿ��� Marker �� ǥ���Ѵ�.
                                        // �������� �����Ͱ� Continuous �DZ����� Marker�� �׸���.

                                    switch ( markerType )
                                    {
                                        case MarkerModeType.None :
                                            Debug.WriteLine("None");
                                            break;
                                        case MarkerModeType.Circle :
                                            Debug.WriteLine("Circle");
                                            g.DrawEllipse(ppen, pt[i].X - markerSize/2, pt[i].Y - markerSize/2, markerSize, markerSize);
                                            break;
                                        case MarkerModeType.Square :
                                            Debug.WriteLine("Square");
                                            g.DrawRectangle(ppen, pt[i].X - markerSize/2, pt[i].Y - markerSize/2, markerSize, markerSize);
                                            break;
                                        case MarkerModeType.Cross :
                                            Debug.WriteLine("Cross");
                                            g.DrawLine(ppen, pt[i].X - markerSize/2, pt[i].Y - markerSize/2, pt[i].X + markerSize/2, pt[i].Y + markerSize/2);
                                            g.DrawLine(ppen, pt[i].X + markerSize/2, pt[i].Y - markerSize/2, pt[i].X - markerSize/2, pt[i].Y + markerSize/2);
                                            break;
                                        case MarkerModeType.Plus :
                                            Debug.WriteLine("Plus");
                                            g.DrawLine(ppen, pt[i].X, pt[i].Y - markerSize/2, pt[i].X, pt[i].Y + markerSize/2);
                                            g.DrawLine(ppen, pt[i].X - markerSize/2, pt[i].Y, pt[i].X + markerSize/2, pt[i].Y);
                                            break;
                                        case MarkerModeType.Triangle :
                                            Debug.WriteLine("Triangle");
                                            g.DrawLine(ppen, pt[i].X, pt[i].Y - markerSize/2, pt[i].X - markerSize/2, pt[i].Y + markerSize/2);
                                            g.DrawLine(ppen, pt[i].X - markerSize/2, pt[i].Y + markerSize/2, pt[i].X + markerSize/2, pt[i].Y + markerSize/2);
                                            g.DrawLine(ppen, pt[i].X + markerSize/2, pt[i].Y + markerSize/2, pt[i].X, pt[i].Y - markerSize/2);
                                            break;
                                        case MarkerModeType.Diamond :
                                            Debug.WriteLine("Diamond");
                                            g.DrawLine(ppen, pt[i].X, pt[i].Y - markerSize/2, pt[i].X - markerSize/2, pt[i].Y);
                                            g.DrawLine(ppen, pt[i].X - markerSize/2, pt[i].Y, pt[i].X, pt[i].Y + markerSize/2);
                                            g.DrawLine(ppen, pt[i].X, pt[i].Y + markerSize/2, pt[i].X + markerSize/2, pt[i].Y);
                                            g.DrawLine(ppen, pt[i].X + markerSize/2, pt[i].Y, pt[i].X, pt[i].Y - markerSize/2);
                                            break;
                                        case MarkerModeType.Asterik :
                                            Debug.WriteLine("Asterik");
                                            g.DrawLine(ppen, pt[i].X, pt[i].Y - markerSize/2, pt[i].X, pt[i].Y + markerSize/2);
                                            g.DrawLine(ppen, pt[i].X - markerSize/2, pt[i].Y, pt[i].X + markerSize/2, pt[i].Y);
                                            g.DrawLine(ppen, pt[i].X - markerSize/2, pt[i].Y - markerSize/2, pt[i].X + markerSize/2, pt[i].Y + markerSize/2);
                                            g.DrawLine(ppen, pt[i].X + markerSize/2, pt[i].Y - markerSize/2, pt[i].X - markerSize/2, pt[i].Y + markerSize/2);
                                            break;
                                        case MarkerModeType.Right :
                                            Debug.WriteLine("Right");
                                            g.DrawLine(ppen, pt[i].X - markerSize/2, pt[i].Y - markerSize/2, pt[i].X - markerSize/2, pt[i].Y + markerSize/2);
                                            g.DrawLine(ppen, pt[i].X - markerSize/2, pt[i].Y + markerSize/2, pt[i].X + markerSize/2, pt[i].Y);
                                            g.DrawLine(ppen, pt[i].X + markerSize/2, pt[i].Y, pt[i].X - markerSize/2, pt[i].Y - markerSize/2);
                                            break;
                                        case MarkerModeType.Left :
                                            Debug.WriteLine("Left");
                                            g.DrawLine(ppen, pt[i].X + markerSize/2, pt[i].Y - markerSize/2, pt[i].X + markerSize/2, pt[i].Y + markerSize/2);
                                            g.DrawLine(ppen, pt[i].X + markerSize/2, pt[i].Y + markerSize/2, pt[i].X - markerSize/2, pt[i].Y);
                                            g.DrawLine(ppen, pt[i].X - markerSize/2, pt[i].Y, pt[i].X + markerSize/2, pt[i].Y - markerSize/2);
                                            break;
                                        case MarkerModeType.Down :
                                            Debug.WriteLine("Down");
                                            g.DrawLine(ppen, pt[i].X - markerSize/2, pt[i].Y - markerSize/2, pt[i].X + markerSize/2, pt[i].Y - markerSize/2);
                                            g.DrawLine(ppen, pt[i].X + markerSize/2, pt[i].Y - markerSize/2, pt[i].X, pt[i].Y + markerSize/2);
                                            g.DrawLine(ppen, pt[i].X, pt[i].Y + markerSize/2, pt[i].X - markerSize/2, pt[i].Y - markerSize/2);
                                            break;
                                    }

                                        // ���� ����̹Ƿ� ������ �̾� �ش�. ������ �ʿ� ������ �÷����� �и�.... =��=;;
                                        if (i > 0) g.DrawLine(ppen, pt[i - 1], pt[i]);

                                        /*
                                         * ��ģ �� ó��..... =��=;;
                                        if ( pt[i-1].X <= x0 )
                                        {
                                            g.DrawLine(ppen, pt[i - 1], pt[i]);
                                        }
                                        */
                                        break;
                                }

                            }
                        }
                        g.Flush();
                    }

            //				}
            //				catch( System.Exception )
            //				{ }
            }
            else // Color Map
            {
                ColorMapDraw();
            }
        }
예제 #2
0
        /// <summary>
        /// ��ȿ�� üũ
        /// </summary>
        /// <returns></returns>
        private bool Exception_Check()
        {
            bool bResult = true;

            // check properties
            if (xRangeEnd <= xRangeStart)
            {
                bResult = false;
            }

            if (yRangeEnd <= yRangeStart)
            {
                bResult = false;
            }

            if ( FXAxisMode == XAxisModeType.Linear )   // linear.
            {
                if (xGrid <= 0)
                {
                    bResult = false;
                }
            }
            else                // logarithmic
            {
                if (xRangeStart <= 0)
                {
                    bResult = false;
                }
            }

            switch ( FYAxisMode )
            {
                case YAxisModeType.Linear :  // linear.
                    if (yGrid <= 0)
                    {
                        bResult = false;
                    }
                    break;
                case YAxisModeType.Log10 :   // logarithmic.
                    if (yRangeStart <= 0)
                    {
                        bResult = false;
                    }
                    break;
                case YAxisModeType.dB :
                    if (yRangeStart <= 0)
                    {
                        bResult = false;
                    }
                    break;
            }

            // draw data if available

            if ( series.Count == 0 )
            {
                bResult = false;
            }

            for ( int ppp = 0 ; ppp < series.Count ; ++ ppp )
            {
                DataSeries tSeries = new DataSeries() ;
                tSeries = (DataSeries)series[ppp];
                if ( tSeries.XData.Length != tSeries.YData.Length )
                {
                    bResult = false;
                }
            }

            return bResult;
        }
예제 #3
0
        /// <summary>
        /// Legend �׸���
        /// </summary>
        /// <param name="g"></param>
        private void Legend_Draw(Graphics g)
        {
            // draw legend - ���� ��ġ �߿�.
            int x0 = ClientRectangle.Left + borderLeft;
            int y0 = ClientRectangle.Top + borderTop;
            int w0 = ClientRectangle.Width - borderLeft - borderRight;

            Pen penAxis = new Pen(colorAxis, 1);

            SolidBrush xBrushLabel = new SolidBrush(xlabelcolor);

            if ( showlegend )
            {
                int lb_w = 0, lb_h = 0, ln_w = 0, ln_h = 0, lx0, ly0, max_CapW = 0;
                // lb_w : legend box width.     lb_h : legend box height.
                // ln_w : legend name width.    ln_w : legend name height.
                // lx0  : legend box x position ly0 : legend box y position.
                // max_CapW : ���� �� ������ ���� ���� .

                DataSeries tSeries = new DataSeries();

                float[] ln_hs = new float[series.Count]; // ������ ���ڵ� ������ �迭�̴�.

                for ( int ppp = 0; ppp < series.Count ; ++ ppp )
                {
                    tSeries = (DataSeries)series[ppp];

                    string s = tSeries.Name ;  // ���� s  = legendname ;
                    SizeF tp = g.MeasureString(s, tSeries.Font); // ���� fontLegend);
                    ln_w = Convert.ToInt32(tp.Width);
                    ln_h += Convert.ToInt32(tp.Height);
                    ln_hs[ppp] = tp.Height ;
                    ln_w = ( max_CapW < ln_w ) ? ln_w : max_CapW ;
                    /* ������ �����尡 �ƴϸ� ���ݵ� ���Խ�Ų��. */
                    if ( ppp + 1 != series.Count ) ln_h += 2 ; // �ø������ �� ������ 2������.
                }

                lb_w = 30+2+ln_w+10*2; lb_h = ln_h+3*2;
                lx0  = x0+w0-lb_w-4;  ly0 = y0+10;
                // ������ �ڽ��� �׸���.
                g.DrawRectangle(penAxis, lx0, ly0, lb_w, lb_h);

                PointF[] lp = new PointF[2];

                float Lcyp = ly0+3;  // legend caption Y position.
                // ���� �����带 �׷�����.

                for ( int ppp = 0; ppp < series.Count ; ++ ppp )
                {
                    tSeries = (DataSeries)series[ppp];
                    string s = tSeries.Name ;
                    Pen tpen = new Pen(tSeries.Color);
                    lp[0].X = lx0+10; lp[1].X = lp[0].X+30;
                    lp[0].Y = Lcyp+ln_hs[ppp]/2;
                    lp[1].Y = lp[0].Y ;
                    g.DrawLine(tpen, lp[0], lp[1]);
                    g.DrawString(s, tSeries.Font, xBrushLabel, lp[1].X + 2, Lcyp);
                    Lcyp = Lcyp + ln_hs[ppp]/2 + 2 ;
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Data �׸���
        /// </summary>
        /// <param name="g"></param>
        private void Data_Draw(Graphics g)
        {
            float y1 = ClientRectangle.Bottom - borderBottom;
            float h0 = ClientRectangle.Height - borderTop - borderBottom;
            float x0 = ClientRectangle.Left + borderLeft;
            float w0 = ClientRectangle.Width - borderLeft - borderRight;
            float y0 = ClientRectangle.Top + borderTop;

            float d = h0 / Convert.ToInt32(this.series.Count);
            //float xd = w0 / Convert.ToInt32(((DataSeries)this.series[0]).XData.Length);
            float xd = (w0 - this.ColorBarGap) / Convert.ToInt32(((DataSeries)this.series[0]).XData.Length);

            Pen penAxis = new Pen(colorAxis, 1);

            // first convert the data arrays into points inside the axis rectangle
            DataSeries pSeries = new DataSeries();

            for ( int ppp = 0 ; ppp < series.Count ; ++ ppp )
            {
                pSeries = (DataSeries)series[ppp];

                Pen ppen = new Pen(pSeries.Color, pSeries.PenWidth);

                Point_Data [] pt = new Point_Data[pSeries.XData.Length];
                for (int iii = 0;iii<pSeries.XData.Length;iii++)
                {
                    pt[iii] = new Point_Data();
                }
                Point_Data lastValidPt = new Point_Data(x0, y1);

                Color [] dimColor = new Color[pt.Length];
                for(int jjj = 0 ; jjj < pt.Length ; jjj++)
                {
                    dimColor[jjj] = new Color();
                }

                for (int i = 0; i < pt.Length; i++)
                {
            //					try	// catch invalid data points
            //					{
                        switch ( FXAxisMode )
                        {
                            case XAxisModeType.Linear :  // linear.
                                //pt[i].x_Data = (double)(x0 + (pSeries.XData[i] - xRangeStart) / (xRangeEnd - xRangeStart) * w0);
                                pt[i].x_Data = x0 + (i + 1) * xd;
                                break;
                        }

                        switch ( FYAxisMode )
                        {
                            case YAxisModeType.Linear :  // linear.
                                // RGB ������ ���س���
                                pt[i].y_Data = y1 - (pSeries.YData[i] - yRangeStart) / (yRangeEnd - yRangeStart) * h0;
                                dimColor[i] = GetRGB(pSeries.YData[i]);
                                break;

                                #region Log10
            //							case YAxisModeType.Log10 :   // logarithmic
            //								pt[i].Y = Convert.ToInt32(y1 - (Math.Log10(pSeries.YData[i]) - Math.Log10(yRangeStart)) / (Math.Log10(yRangeEnd) - Math.Log10(yRangeStart)) * h0);
            //								break;
                                #endregion

                                #region DB
            //							case YAxisModeType.dB    :   // dB
            //								pt[i].Y = Convert.ToInt32(y1 - (pSeries.YData[i] - yRangeStart) / (yRangeEnd - yRangeStart) * h0);
            //								break;
                                #endregion
                        }

                        switch ( FZAxisMode )
                        {
                            case ZAxisModeType.Linear :  // linear.
                                pt[i].y_Data = y1 - (ppp + 1) * d;
                                break;
                        }

                        lastValidPt = pt[i];
            //					}
            //					catch(System.Exception )
            //					{
            ////					}
                }

                for (int i = 0; i < pt.Length; i++)
                {
                    float X1, XW, Y1, YH;
                    // Color Map �� ��ĭ ��ĭ �׸� �׸���.
                    SolidBrush brushColor = new SolidBrush(dimColor[i]);
            //					if(i == 0)
            //					{
            //						X1 = x0;
            //						XW = (float)(pt[1].x_Data/2 + pt[0].x_Data - x0);
            //					}
            //					else if(i == pt.Length-1)
            //					{
            //						X1 = (float)(pt[i].x_Data/2 + pt[i-1].x_Data/2);
            //						XW = x0 + w0;
            //					}
            //					else
            //					{
            //						X1 = (float)(pt[i].x_Data/2 + pt[i-1].x_Data/2);
            //						XW = (float)(pt[i+1].x_Data/2 - pt[i-1].x_Data/2);
            //					}
                    X1 = x0 + i * xd;
                    XW = xd;
                    Y1 = y1 - (ppp + 1) * d;
                    YH = d;

                    g.FillRectangle(brushColor,X1,Y1, XW, YH);
                    //g.DrawRectangle(brushColor,X1,Y1, XW, YH);
                }
            }
        }