ホーム » Xcode » CPoint と CGPoint

2013年6月
 1
2345678
9101112131415
16171819202122
23242526272829
30  

カテゴリー

アーカイブ

ブログ統計情報

  • 77,344 アクセス



CPoint と CGPoint

以前作成した MemoryStatus クラスを利用して,Win , iOS で書いてみた.
MemoryStatus の配列として,MemoryStatusAry を作成.
また,float の配列をそれぞれの点配列に変換する ::GraphGetPoint を用意.


Win
  void CMemSSDView::OnPaint()
  {
    CPaintDC dc(this);
    CRect rect ;
    GetClientRect(rect) ;
    {
      std::vector<float> grphF = MemSA.GetGraph(MemoryStatusAry::WinPhysF) ;
      std::vector<float> grphT = MemSA.GetGraph(MemoryStatusAry::WinPhysT) ;
      std::vector<float> grphP = MemSA.GetGraph(MemoryStatusAry::WinPageF) ;
      std::vector<CPoint> pntsF = ::GraphGetPoint(grphF,rect) ;
      std::vector<CPoint> pntsT = ::GraphGetPoint(grphT,rect) ;
      std::vector<CPoint> pntsP = ::GraphGetPoint(grphP,rect) ;
      {
        CPen penGreen(PS_SOLID,1,RGB(0,192,0)) ;
        CPen* oldPen = dc.SelectObject(&penGreen) ;
        dc.Polyline(&pntsF[0],pntsF.size()) ;
        CPen penRed(PS_SOLID,1,RGB(192,0,0)) ;
        oldPen = dc.SelectObject(&penRed) ;
        dc.Polyline(&pntsT[0],pntsT.size()) ;
        CPen penBlue(PS_SOLID,1,RGB(0,0,192)) ;
        oldPen = dc.SelectObject(&penBlue) ;
        dc.Polyline(&pntsP[0],pntsP.size()) ;
        dc.SelectObject(oldPen) ;
        }
      }
    }


iOS
  - (void)drawRect:(CGRect)rect
  {
    _context = UIGraphicsGetCurrentContext() ;
    {
      std::vector<float> grphP = MemSA.GetGraph(MemoryStatusAry::MacPFree) ;
      std::vector<float> grphA = MemSA.GetGraph(MemoryStatusAry::MacInact) ;
      std::vector<float> grphW = MemSA.GetGraph(MemoryStatusAry::MacWired) ;
      std::vector<CGPoint> pntsP = ::GraphGetPoint(grphP,rect) ;
      std::vector<CGPoint> pntsA = ::GraphGetPoint(grphA,rect) ;
      std::vector<CGPoint> pntsW = ::GraphGetPoint(grphW,rect) ;
      {
        [self setColor_r:0 g:192 b:0] ;
        CGContextAddLines (_context,&pntsP[0],pntsP.size()) ;
        CGContextStrokePath (_context) ;
        [self setColor_r:0 g:0 b:192] ;
        CGContextAddLines (_context,&pntsA[0],pntsA.size()) ;
        CGContextStrokePath (_context) ;
        [self setColor_r:192 g:0 b:0] ;
        CGContextAddLines (_context,&pntsW[0],pntsW.size()) ;
        CGContextStrokePath (_context) ;
        }
      }
    }

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

コメントする

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

%d人のブロガーが「いいね」をつけました。