Exemplo n.º 1
0
        //在mrk.sequence[]中指定的那些channel中,搜索Y值最大的点
        //绘制PEAK点文本和PEAK图形
        private static void DrawPeak( int mrkCount,
                                      int mrkOrder,
                                      Graphics g, 
                                      Channels chnls, 
                                      ChannelMark mrk,
                                      AixsVisibleArea ava, 
                                      ChannelPictureArea cpa, 
                                      Font mrkFont)
        {
            SizeF szf;
            Channel chnl;           
            string label = "";
            PointF p2 = new PointF(float.MinValue, float.MinValue);
            PointF srcPoint = p2;
            
            //在mrk.sequence指定的channel搜索PEAK点
            int k = -1;
            for (int i = 0; i < mrk.sequence.Length; i++) 
            {
                chnl = chnls.ChannelOf(mrk.sequence[i]);
                if (chnl != null) {
                    p2 = SearchPeak(chnl);

                    if (p2.Y > srcPoint.Y) {
                        k = i;
                        srcPoint = p2;
                    }
                }
            }
            
            //找到PEAK点
            if ((mrk.showMarkShape) && (srcPoint.X > float.MinValue)) 
            {
                //对srcPoint的X坐标执行世界变换
                int x = (int)(cpa.rec.X + (srcPoint.X - ava.xBegin) * cpa.rec.Width / (ava.xEnd - ava.xBegin));

                MarkInfo[] mi = new MarkInfo[1];
                mi[0].fPoint = srcPoint;
                mi[0].iChannel = (k + 1);
                mi[0].iOrder = mrkOrder;

                //构造并绘制PEAK文本
                if (GenPeakText != null) {                   
                    label = GenPeakText(mi);
                    szf   = g.MeasureString(label, mrkFont);
                    g.DrawString(label,
                                 mrkFont,
                                 new LinearGradientBrush(new RectangleF(0, 0, szf.Width, szf.Height), mrk.markColor, mrk.markColor, 0.0),
                                 new Point(cpa.rec.X, (int)(cpa.rec.Y + mrkCount * szf.Height + MARKMARGIN)));
                }

                Point[] p;
                RectangleF recf;
              
                p = new Point[7];
                recf = MakeMarkPolygon(p, x, cpa);

                //绘制PEAK形状
                g.DrawPolygon(new Pen(mrk.markColor), p);

                //绘制PEAK形状内的文本
                szf = g.MeasureString(mrkOrder.ToString(), mrkFont);

                g.DrawString(mrkOrder.ToString(),
                             mrkFont,
                             new LinearGradientBrush(recf, mrk.markColor, mrk.markColor, 0.0),
                             new PointF(recf.X + (recf.Width - szf.Width) / 2, recf.Y + (recf.Height - szf.Height) / 2)
                             );
            }
        }
Exemplo n.º 2
0
        //在mrk.sequence[]中指定的那些channel中,搜索MARK点
        //把找到的点,合并成一个文本,作为该MARK点文本
        //绘制MARK点文本和MARK图形
        private static void DrawMark( int mrkCount,
                                      int mrkOrder,
                                      Graphics g, 
                                      Channels chnls, 
                                      ChannelMark mrk,
                                      AixsVisibleArea ava, 
                                      ChannelPictureArea cpa, 
                                      Font mrkFont)
        {
            int i, j;         
            SizeF szf;
            Channel chnl;
            
            string label = "";
            bool bExists = false;
            PointF srcPoint = new PointF(float.MinValue, float.MinValue);

            //用于绘制MARK线时,定位坐标
            PointF gphPoint = srcPoint;

            //计算MARK点的世界坐标,即mrk.value,由外部传入      
           
            MarkInfo[] mi = new MarkInfo[mrk.sequence.Length];
            //在指定的channel中构造MARK文本
            for (i = 0; i < mrk.sequence.Length; i++) 
            {
                mi[i].iChannel = -1;
                mi[i].iOrder = mrkOrder;

                j = mrk.sequence[i];

                chnl = chnls.ChannelOf(j);
                if (chnl == null)
                    continue;

                srcPoint = Search2(chnl, ava, cpa, mrk.searchType, mrk.value);
              
                if (srcPoint.X > float.MinValue) 
                {
                    if (!bExists) {
                        bExists = true;
                        gphPoint = srcPoint;
                    }
                }

                mi[i].fPoint = srcPoint;
                mi[i].iChannel = (j + 1);
            }
            
            //若找到MARK点
            if ((mrk.showMarkShape) && (gphPoint.X > float.MinValue))
            {
                //使用找的MARK,绘制其文本
                if (GenMarkText != null)
                {
                    label = GenMarkText(mi);
                    szf = g.MeasureString(label, mrkFont);
                    g.DrawString(label,
                                 mrkFont,
                                 new LinearGradientBrush(new RectangleF(0, 0, szf.Width, szf.Height), mrk.markColor, mrk.markColor, 0.0),
                                 new Point(cpa.rec.X, (int)(cpa.rec.Y + mrkCount * szf.Height + MARKMARGIN)));

                }

                //使用找的MARK,构造形状
                Point[] p;
                RectangleF recf;

                //使用找到点的X坐标值来计算MARK点页面坐标在X轴方向的值,不使用mrk.value
                float x = (int)(cpa.rec.X + 
                                (gphPoint.X - ava.xBegin) * cpa.rec.Width / (ava.xEnd - ava.xBegin));              

                if (mrk.markShape == MarkShape.markPloygon) {
                    p = new Point[7];
                    recf = MakeMarkPolygon(p, (int)x, cpa);

                } else {
                    p = new Point[3];
                    int y = (int)(cpa.rec.Y + cpa.rec.Height -
                                  (gphPoint.Y - ava.yBegin) * cpa.rec.Height / (ava.yEnd - ava.yBegin));

                    recf = MakeMarkTriangle(p, new Point((int)x, y), cpa);
                }

                //绘制MARK形状
                g.DrawPolygon(new Pen(mrk.markColor), p);

                //绘制MARK形状内的文本
                szf = g.MeasureString(mrkOrder.ToString(), mrkFont);
                g.DrawString(mrkOrder.ToString(),
                             mrkFont,
                             new LinearGradientBrush(recf, mrk.markColor, mrk.markColor, 0.0),
                             new PointF(recf.X + (recf.Width - szf.Width) / 2, recf.Y + (recf.Height - szf.Height) / 2)
                             );
            }
        }
Exemplo n.º 3
0
 public string PimPeakText(MarkInfo[] mi)
 {
     return "99.6@ABC";
 }