1. <abbr id="v9zmj"></abbr>

        人妻一本久道久久综合鬼色,色噜噜在线视频免费观看,亚洲护士一区二区三区,亚洲国产精品久久久久秋霞 ,久久精品久久黄色片看看,国产成人精品久久性色av,成人3D动漫一区二区三区,亚洲综合成人av在线
           您現(xiàn)在的位置: 南方財(cái)富網(wǎng) >> 股票知識(shí) >> K線圖 >> 正文
        南方財(cái)富搜索

        DrawOneKLine如何畫(huà)單根K線

        2010-9-2 9:13:06   來(lái)源:不詳   佚名
            

        //函數(shù)實(shí)現(xiàn)畫(huà)單根K線的功能,坐標(biāo)為普通坐標(biāo),而非對(duì)數(shù)坐標(biāo)

        void CStockGraph::DrawOneKLine(CDC * pDC, int nIndexPos, int nIndexKD, CKData * pKData, double dMin, double dMax, BOOL bGreyed )
        {
         DECLARE_COLOR_DEFINATION

         // Check Valid

         //判斷當(dāng)前位置的序列號(hào)是否有效,指的是顯示窗口,在當(dāng)前的m_nIndexStart 和 m_nIndexEnd之間
         ASSERT( pDC && nIndexPos >= m_nIndexStart && nIndexPos <= m_nIndexEnd && nIndexPos >= 0 );
         if( !(pDC && nIndexPos >= m_nIndexStart && nIndexPos <= m_nIndexEnd && nIndexPos >= 0) )
          return;

         //判斷當(dāng)前位置的序列號(hào)是否有效,序列號(hào)是否是小于零或大于當(dāng)前序列的長(zhǎng)度
         if( !pKData || nIndexKD < 0 || nIndexKD >= pKData->GetSize() )
          return;
         if( dMax-dMin < 1e-4 )
          return;

         // Get Region

         //關(guān)于GetOneKLineRect請(qǐng)參看下面關(guān)于這個(gè)函數(shù)的分析

         //這里需要注意的一個(gè)問(wèn)題就是rectK, rcEntity,是有不同的含義的,rectK是指顯示的K線矩形區(qū)域,實(shí)際的畫(huà)K線的區(qū)域是rcEntity,指的是畫(huà)K線實(shí)體的區(qū)域
         CRect rectK, rcEntity;
         long xMedium = 0;
         if( !GetOneKLineRect( nIndexPos, &rectK, &rcEntity.left, &rcEntity.right, &xMedium ) )//參數(shù)xMedium 為K線實(shí)體的中間位置,對(duì)應(yīng)畫(huà)K線的圖形
          return;

         int xStart = rectK.left;
         int xEnd = rectK.right;
         ASSERT( xEnd <= m_rectKLineCenter.right );
         if( xEnd > m_rectKLineCenter.right )
          return;

         KDATA kd = pKData->ElementAt(nIndexKD);

        //根據(jù)當(dāng)前最低價(jià)格/最高價(jià)格/收盤(pán)價(jià)格/開(kāi)盤(pán)價(jià)格的計(jì)算出K線實(shí)體在當(dāng)前顯示區(qū)域中坐標(biāo).(等比例的計(jì)算)

         // Set rcEntity's top and bottom, set yLow, yHigh
         int yLow = int( m_rectKLineCenter.bottom - m_rectKLineCenter.Height() * (kd.m_fLow - dMin) / (dMax-dMin) );
         int yHigh = int( m_rectKLineCenter.bottom - m_rectKLineCenter.Height() * (kd.m_fHigh - dMin) / (dMax-dMin) );
         int yOpen = int( m_rectKLineCenter.bottom - m_rectKLineCenter.Height() * (kd.m_fOpen - dMin) / (dMax-dMin) );
         int yClose = int( m_rectKLineCenter.bottom - m_rectKLineCenter.Height() * (kd.m_fClose - dMin) / (dMax-dMin) );

         //計(jì)算出實(shí)體區(qū)域的上下坐標(biāo),左右坐標(biāo)已經(jīng)根據(jù)序列位置計(jì)算出來(lái)了,到這個(gè)地方,已經(jīng)計(jì)算出了要畫(huà)K線的試題區(qū)域的具體坐標(biāo)了.

         rcEntity.top = min( yOpen, yClose );
         rcEntity.bottom = max( yOpen, yClose ) + 1;

         

         //上面已經(jīng)計(jì)算出了要畫(huà)的K線的坐標(biāo)了,下面就開(kāi)始畫(huà)K線了

         if( CStockGraph::klineCandle == m_nCurKLineMode )
         {
          // Draw Entity

          //畫(huà)實(shí)體區(qū)域了
          COLORREF clr = clrRise;
          if( kd.m_fClose < kd.m_fOpen )
           clr = clrFallEntity;
          if( kd.m_date > m_dwLatestDate )
           clr = clrNewKLine;
          if( bGreyed )
           clr = clrDJ;
          pDC->SetBkColor( clrBK );
          if( kd.m_fClose < kd.m_fOpen )
           pDC->FillSolidRect( &rcEntity, clr );
          else
           pDC->Draw3dRect( &rcEntity, clr, clr );
         
          // Draw Line

          //畫(huà)K線上的最高和最低價(jià)格的線
          CPen pen( PS_SOLID, 1, clr );
          CPen *pOldPen = pDC->SelectObject( &pen );
          pDC->MoveTo( xMedium, yHigh );
          pDC->LineTo( xMedium, rcEntity.top );
          pDC->MoveTo( xMedium, rcEntity.bottom );
          pDC->LineTo( xMedium, yLow );

          pDC->SelectObject( pOldPen );
         }
         else if( CStockGraph::klineAmerica == m_nCurKLineMode )
         {
          // Draw Entity
          COLORREF clr = clrRise;
          if( kd.m_date > m_dwLatestDate )
           clr = clrNewKLine;
          if( bGreyed )
           clr = clrDJ;
          pDC->SetBkColor( clrBK );
         
          // Draw Line
          CPen pen( PS_SOLID, 1, clr );
          CPen *pOldPen = pDC->SelectObject( &pen );
          pDC->MoveTo( xStart, yHigh );
          pDC->LineTo( xStart, yLow );
          pDC->MoveTo( xStart, yClose );
          pDC->LineTo( xEnd, yClose );

          pDC->SelectObject( pOldPen );
         }
         else if( CStockGraph::klineTower == m_nCurKLineMode )
         {
         
          // Draw Entity
          COLORREF clr = clrRise;
          if( kd.m_fClose < kd.m_fOpen )
           clr = clrFallEntity;
          if( kd.m_date > m_dwLatestDate )
           clr = clrNewKLine;
          if( bGreyed )
           clr = clrDJ;
          pDC->SetBkColor( clrBK );
          if( kd.m_fClose < kd.m_fOpen )
           pDC->FillSolidRect( &rcEntity, clr );
          else
           pDC->Draw3dRect( &rcEntity, clr, clr );

          if( nIndexKD > 0 )
          {
           KDATA kdLast = pKData->ElementAt(nIndexKD-1);
           int yOpenLast = int( m_rectKLineCenter.bottom - m_rectKLineCenter.Height() * (kdLast.m_fOpen - dMin) / (dMax-dMin) );
           int yCloseLast = int( m_rectKLineCenter.bottom - m_rectKLineCenter.Height() * (kdLast.m_fClose - dMin) / (dMax-dMin) );
           if( kdLast.m_fClose > kdLast.m_fOpen && kd.m_fClose < kd.m_fOpen )
           {
            rcEntity.bottom = min(yOpenLast,rcEntity.bottom);
            if( rcEntity.bottom > rcEntity.top )
            {
             pDC->FillSolidRect( &rcEntity, clrBK );
             clr = clrRise;
             if( kd.m_date > m_dwLatestDate )
              clr = clrNewKLine;
             if( bGreyed )
              clr = clrDJ;
             pDC->Draw3dRect( &rcEntity, clr, clr );
            }
           }
           else if( kdLast.m_fClose < kdLast.m_fOpen && kd.m_fClose > kd.m_fOpen )
           {
            rcEntity.top = max(yOpenLast,rcEntity.top);
            if( rcEntity.bottom > rcEntity.top )
            {
             clr = clrFallEntity;
             if( kd.m_date > m_dwLatestDate )
              clr = clrNewKLine;
             if( bGreyed )
              clr = clrDJ;
             pDC->FillSolidRect( &rcEntity, clr );
            }
           }
          }
         }
        }

         

        //函數(shù)GetOneKLineRect的分析,得到當(dāng)前序列位置處要畫(huà)K線的區(qū)域

        BOOL CStockGraph::GetOneKLineRect( int nIndex, LPRECT lpRect, long *pxEntityLeft, long *pxEntityRight, long *pxMedium )
        {

         //判斷當(dāng)前的序列位置是在當(dāng)前顯示的窗口區(qū)域中
         if( nIndex == -1 || nIndex < m_nIndexStart || nIndex > m_nIndexEnd )
          return FALSE;

         //初始化畫(huà)K線的位置的矩形區(qū)域

         CRect rectK = m_rectCenter;

         //計(jì)算出K線位置的左右寬度的坐標(biāo),上下的坐標(biāo)沒(méi)有給出,只是初始化為m_rectCenter中的參數(shù)

         //左邊的起誓位置為,從K線顯示區(qū)域的左邊開(kāi)始m_rectKLineCenter.left,加上已經(jīng)顯示了nIndex-m_nIndexStart點(diǎn)的距離就是當(dāng)前序列處的坐標(biāo)
         rectK.left = m_rectKLineCenter.left + (nIndex-m_nIndexStart) * m_nThickness;

        //右邊的坐標(biāo)最簡(jiǎn)單,就是左邊左邊加上寬度就可以了.
         rectK.right = rectK.left + m_nThickness;

         if( rectK.Width() <= 0 || rectK.Height() <= 0 )
          return FALSE;

        //傳出參數(shù)lpRect
         if( lpRect )
          *lpRect = rectK;

         int xStart = rectK.left;

         CRect rcEntity;

         //根據(jù)當(dāng)前的K線的寬度計(jì)算出序列的右邊的坐標(biāo)點(diǎn),并傳出參數(shù)
         switch( m_nThickness )
         {
         case 1:
         case 2:
          rcEntity.left = xStart;
          rcEntity.right = xStart + 1;
          break;
         case 4:
         case 5:
          rcEntity.left = xStart;
          rcEntity.right = xStart + 3;
          break;
         case 6:
         case 7:
          rcEntity.left = xStart;
          rcEntity.right = xStart + 5;
          break;
         case 9:
         case 10:
          rcEntity.left = xStart;
          rcEntity.right = xStart + 7;
          break;
         case 13:
         case 15:
          rcEntity.left = xStart;
          rcEntity.right = xStart + 11;
          break;
         default:
          ASSERT( FALSE );
          rcEntity.left = xStart;
          rcEntity.right = xStart + 3;
          return FALSE;
         }
         if( pxEntityLeft )
          *pxEntityLeft = rcEntity.left;
         if( pxEntityRight )
          *pxEntityRight = rcEntity.right;
         if( pxMedium )
          *pxMedium = rcEntity.left + rcEntity.Width() / 2;

         return TRUE;
        }

        (責(zé)任編輯:張?jiān)墸?/td>
            南方財(cái)富網(wǎng)聲明:股市資訊來(lái)源于合作媒體及機(jī)構(gòu),屬作者個(gè)人觀點(diǎn),僅供投資者參考,并不構(gòu)成投資建議。投資者據(jù)此操作,風(fēng)險(xiǎn)自擔(dān)。
        商務(wù)進(jìn)行時(shí)
        每日必讀
        學(xué)院24小時(shí)排行
        證券導(dǎo)讀
        熱圖推薦

        關(guān)于南方財(cái)富網(wǎng)版權(quán)聲明誠(chéng)聘英才廣告服務(wù)網(wǎng)站地圖友情鏈接
        特此聲明:廣告商的言論與行為均與南方財(cái)富網(wǎng)無(wú)關(guān)
        www.605668.cn
        南方財(cái)富網(wǎng) © 版權(quán)所有 閩ICP備09035581號(hào)
        主站蜘蛛池模板: 亚洲AV熟妇在线观看| 久久99精品国产99久久6尤物| 日韩丝袜欧美人妻制服| 纯肉高h啪动漫| 国产高清乱码又大又圆| 人妻一本久道久久综合鬼色| 国产午夜福利视频在线| 午夜射精日本三级| 日韩人妻系列无码专区| 久久av无码精品人妻出轨| 亚洲国产亚洲国产路线久久| 精品一区二区不卡免费| 67194熟妇在线直接进入| 中文字幕乱妇无码AV在线| 国产蜜臀av在线一区在线| 忘忧草在线社区www中国中文| 亚洲AV福利天堂在线观看| 骚虎视频在线观看| 人妻激情一区二区三区四区| 欧美日韩精品一区二区视频| 国产日产欧产精品精品| 男女激情一区二区三区| 亚洲的天堂在线中文字幕| 久久99国产精品尤物| 免费看欧美全黄成人片| 中文字幕无线码中文字幕免费| 久久99久国产麻精品66| 国产免费播放一区二区三区| 精品国产午夜理论片不卡| 国产精品国产三级国产专业| 99久久亚洲综合精品成人网| 色窝窝免费播放视频在线| 亚洲AV无码精品色午夜果冻| 国产日韩av二区三区| 高级艳妇交换俱乐部小说| 国产精品激情av在线播放 | 日韩有码精品中文字幕| 老少配老妇老熟女中文普通话| 久久99精品国产麻豆婷婷| 成人av天堂网在线观看| 日本一区二区三区黄色网|