CEllipse.cpp
上传用户:qiye66671
上传日期:2009-12-10
资源大小:182k
文件大小:15k
源码类别:

绘图程序

开发平台:

C/C++

  1. #include "stdafx.h"
  2. #include"CEllipse.h"
  3. #include"EastDrawView.h"
  4. IMPLEMENT_SERIAL(CEllipse,CUnit,1)
  5. void CEllipse::DrawStatic(CDC*pDC)
  6. {  
  7.   CPen m_pen;
  8.   CBrush m_brush;
  9.   int oldDrawingMode=pDC->SetROP2(this->m_DrawingMode);
  10.   m_pen.CreatePen(m_PenStyle,m_PenWidth,m_PenColor);
  11.   CPen* pen=(CPen*)pDC->SelectObject(&m_pen);
  12.   LOGBRUSH brushlog;
  13.   brushlog.lbColor=m_BrushColor;
  14.   brushlog.lbHatch=m_BrushHatch;
  15.   brushlog.lbStyle=m_BrushStyle;
  16.   m_brush.CreateBrushIndirect(&brushlog);
  17.   SetBrushOrg(pDC,&m_brush);
  18.   CBrush*brush=(CBrush*)pDC->SelectObject(&m_brush);
  19.  
  20.  int OldBkMode=pDC->SetBkMode(m_BkMode);
  21.  COLORREF OldColor=pDC->SetBkColor(m_BackgroundColor);
  22.  
  23.  ellipseMidpoint(pDC,m_CenterPoint.x,m_CenterPoint.y,this->m_Xr,this->m_Yr);
  24.  pDC->SelectObject(brush);
  25.  pDC->SelectObject(pen);
  26.  pDC->SetBkMode(OldBkMode);
  27.  pDC->SetBkColor(OldColor);
  28.  pDC->SetROP2(oldDrawingMode);
  29. }
  30. void CEllipse::Serialize(CArchive &ar)
  31. {
  32. CUnit::Serialize(ar);
  33.     if(ar.IsStoring())
  34. {
  35.   ar<<m_BrushStyle<<m_BkMode<<m_BrushHatch<<m_BrushColor;
  36.   ar<<m_Sin<<m_Cos;
  37.   ar<<m_Xr<<m_Yr;
  38.   ar<<m_CenterPoint;
  39. }
  40. else
  41. {
  42.   ar>>m_BrushStyle>>m_BkMode>>m_BrushHatch>>m_BrushColor;
  43.   ar>>m_Sin>>m_Cos;
  44.   ar>>m_Xr>>m_Yr;
  45.   ar>>m_CenterPoint;
  46. }
  47. }
  48. BOOL CEllipse::IsInRgn(CPoint point)
  49. {
  50.     
  51. double vh[3][3]={m_Cos,-m_Sin,m_CenterPoint.x*(1-m_Cos)+m_CenterPoint.y*m_Sin,
  52.                m_Sin, m_Cos,m_CenterPoint.y*(1-m_Cos)-m_CenterPoint.x*m_Sin,
  53.    0,0,1
  54.                   };       
  55.   
  56.      
  57.        
  58.   double xy[3];
  59.   CPoint point1=CPoint(m_CenterPoint.x-m_Xr,m_CenterPoint.y+m_Yr);
  60.   CPoint point2=CPoint(m_CenterPoint.x+m_Xr,m_CenterPoint.y+m_Yr);
  61.   CPoint point3=CPoint(m_CenterPoint.x+m_Xr,m_CenterPoint.y-m_Yr);
  62.   CPoint point4=CPoint(m_CenterPoint.x-m_Xr,m_CenterPoint.y-m_Yr);
  63.   CPoint point11=CPoint(m_CenterPoint.x-m_Xr/1.2,m_CenterPoint.y+m_Yr/1.2);
  64.   CPoint point22=CPoint(m_CenterPoint.x+m_Xr/1.2,m_CenterPoint.y+m_Yr/1.2);
  65.   CPoint point33=CPoint(m_CenterPoint.x+m_Xr/1.2,m_CenterPoint.y-m_Yr/1.2);
  66.   CPoint point44=CPoint(m_CenterPoint.x-m_Xr/1.2,m_CenterPoint.y-m_Yr/1.2);
  67.    
  68.   CPoint pointList1[]={point1,point2,point3,point4};
  69.   CPoint pointList2[]={point11,point22,point33,point44};
  70.   
  71.   for(int i=0;i<4;i++)
  72.   {
  73.   xy[0]=pointList1[i].x;
  74.   xy[1]=pointList1[i].y;
  75.   xy[2]=1;
  76.   pointList1[i].x=vh[0][0]*xy[0]+vh[0][1]*xy[1]+vh[0][2]*xy[2];
  77.   pointList1[i].y=vh[1][0]*xy[0]+vh[1][1]*xy[1]+vh[1][2]*xy[2];
  78.   
  79.   xy[0]=pointList2[i].x;
  80.   xy[1]=pointList2[i].y;
  81.   xy[2]=1;
  82.   pointList2[i].x=vh[0][0]*xy[0]+vh[0][1]*xy[1]+vh[0][2]*xy[2];
  83.   pointList2[i].y=vh[1][0]*xy[0]+vh[1][1]*xy[1]+vh[1][2]*xy[2];
  84.   }
  85.   CRgn rgn1;
  86.   rgn1.CreatePolygonRgn(pointList1,4,ALTERNATE);
  87.   CRgn rgn2;
  88.   rgn2.CreatePolygonRgn(pointList2,4,ALTERNATE);
  89.   if(rgn1.PtInRegion(point)&&!rgn2.PtInRegion(point))
  90.   return true;
  91.   
  92.   return false;
  93. }
  94. int CEllipse::IsOnMarginPoint(CPoint point)
  95. {
  96.       CRect rect;
  97.   for(int i=0;i<5;i++)
  98.   {
  99.   rect=CRect(this->m_MarginPoint[i],this->m_MarginPoint[i]);
  100.   rect.InflateRect(4,4);
  101.       if(rect.PtInRect(point))
  102.   {   
  103.   m_FoundPoint=this->m_MarginPoint[i];
  104.   return i+1;
  105.   }
  106.    }
  107. return 0;
  108.  }
  109. void CEllipse::ellipseMidpoint(CDC*pDC,int xCenter, int yCenter, int Rx, int Ry)
  110. {
  111. int Rx2=Rx*Rx;
  112. int Ry2=Ry*Ry;
  113. int twoRx2=2*Rx2;
  114. int twoRy2=2*Ry2;
  115. int p;
  116. int x=0;
  117. int y=Ry;
  118. int px=0;
  119. int py=twoRx2*y;
  120. ellipsePlotPoints(pDC,xCenter,yCenter,x,y);
  121. p=ROUND(Ry2-(Rx2*Ry)+(0.25*Rx2));
  122. while(px<py)
  123. {
  124. x++;
  125. px+=twoRy2;
  126. if(p<0)
  127. p+=Ry2+px;
  128. else
  129. {
  130. y--;
  131. py-=twoRx2;
  132. p+=Ry2+px-py;
  133. }
  134. ellipsePlotPoints(pDC,xCenter,yCenter,x,y);
  135. }
  136. p=ROUND(Ry2*(x+0.5)*(x+0.5)+Rx2*(y-1)*(y-1)-Rx2*Ry2);
  137. while(y>0)
  138. {
  139. y--;
  140. py-=twoRx2;
  141. if(p>0)
  142. p+=Rx2-py;
  143. else
  144. {
  145. x++;
  146. px+=twoRy2;
  147. p+=Rx2-py+px;
  148. }
  149. ellipsePlotPoints(pDC,xCenter,yCenter,x,y);
  150. }
  151. }
  152. void CEllipse::ellipsePlotPoints(CDC*pDC,int xCenter, int yCenter, int x, int y)
  153. {
  154.  /* CPen m_pen;
  155.   CBrush m_brush;
  156.   int oldDrawingMode=pDC->SetROP2(this->m_DrawingMode);
  157.   m_pen.CreatePen(m_PenStyle,m_PenWidth,m_PenColor);
  158.   CPen* pen=(CPen*)pDC->SelectObject(&m_pen);
  159.   LOGBRUSH brushlog;
  160.   brushlog.lbColor=m_BrushColor;
  161.   brushlog.lbHatch=m_BrushHatch;
  162.   brushlog.lbStyle=m_BrushStyle;
  163.   m_brush.CreateBrushIndirect(&brushlog);
  164.  
  165.   CBrush*brush=(CBrush*)pDC->SelectObject(&m_brush);
  166.  
  167.  int OldBkMode=pDC->SetBkMode(m_BkMode);
  168.  COLORREF OldColor=pDC->SetBkColor(m_BackgroundColor);
  169. */
  170. PdcSetPixel(pDC,xCenter+x,yCenter+y,m_PenColor);
  171. PdcSetPixel(pDC,xCenter-x,yCenter+y,m_PenColor);
  172. PdcSetPixel(pDC,xCenter+x,yCenter-y,m_PenColor);
  173. PdcSetPixel(pDC,xCenter-x,yCenter-y,m_PenColor);
  174. /*
  175.  pDC->SelectObject(brush);
  176.  pDC->SelectObject(pen);
  177.  pDC->SetBkMode(OldBkMode);
  178.  pDC->SetBkColor(OldColor);
  179.  pDC->SetROP2(oldDrawingMode);
  180.  */
  181. }
  182. float CEllipse::ComputSloap(CPoint firstPoint, CPoint secondPoint)
  183. {
  184.     m_SecondPoint=secondPoint;
  185. double sloap;
  186. if(firstPoint.x==secondPoint.x)
  187. {
  188.   sloap=9999999999999.0;
  189. }
  190. else
  191. {
  192. sloap=double((firstPoint.y-secondPoint.y))/double((firstPoint.x-secondPoint.x));
  193. }
  194.    
  195.   if(sloap<0)
  196.    {
  197.    m_Cos=fabs(sloap/sqrt(sloap*sloap+1.0));
  198.    m_Sin=1.0/sqrt(sloap*sloap+1.0);
  199.    }
  200.    else
  201.    {
  202.    m_Cos=fabs(sloap/sqrt(sloap*sloap+1.0));
  203.    m_Sin=-1.0/sqrt(sloap*sloap+1.0);
  204.    }
  205.   
  206.    return 0;
  207. }
  208. void CEllipse::PdcSetPixel(CDC *pDC, int xCenter, int yCenter, COLORREF m_PenColor)
  209. {
  210.       //xCenter+x,yCenter+y
  211.   
  212. double vh[3][3]={m_Cos,-m_Sin,m_CenterPoint.x*(1-m_Cos)+m_CenterPoint.y*m_Sin,
  213.                m_Sin, m_Cos,m_CenterPoint.y*(1-m_Cos)-m_CenterPoint.x*m_Sin,
  214.    0,0,1
  215.                   };       
  216.   
  217.       double xy[3]={xCenter,yCenter,1};
  218.   double x[3]={0,0,0};
  219.  
  220.   x[0]=vh[0][0]*xy[0]+vh[0][1]*xy[1]+vh[0][2]*xy[2];
  221.   x[1]=vh[1][0]*xy[0]+vh[1][1]*xy[1]+vh[1][2]*xy[2];
  222.    if(x[0]-int(x[0])>=0.5)
  223.   x[0]+=1;
  224.   if(x[1]-int(x[1])>=0.5)
  225.   x[1]+=1;
  226.   
  227.     for(int i=0;i<this->m_PenWidth;i++)
  228.   pDC->SetPixel(x[0]+i,x[1]-i,m_PenColor);
  229.   
  230.  
  231.    
  232.   //pDC->LineTo(x[0],x[1]);
  233.   // pDC->LineTo(x[0]+1,x[1]-1);
  234.   
  235.   
  236. }
  237. int CEllipse::ComputRadiusX(CPoint firstPoint,CPoint secondPoint)
  238. {
  239.  m_Xr=sqrt((firstPoint.x-secondPoint.x)*(firstPoint.x-secondPoint.x)+(firstPoint.y-secondPoint.y)*(firstPoint.y-secondPoint.y));
  240.  return 0;
  241. }
  242. int CEllipse::ComputRadiusY(CPoint firstPoint,CPoint secondPoint)
  243. {
  244.   m_Yr=sqrt((firstPoint.x-secondPoint.x)*(firstPoint.x-secondPoint.x)+(firstPoint.y-secondPoint.y)*(firstPoint.y-secondPoint.y));
  245.   return 0;
  246. }
  247. void CEllipse::ShowMovingLine(CDC*pDC,CPoint firstPoint, CPoint secondPoint)
  248. {
  249. CPen m_pen;
  250. m_pen.CreatePen(PS_SOLID,1,RGB(0,0,255));
  251. CPen *OldPen=pDC->SelectObject(&m_pen);
  252. pDC->MoveTo(firstPoint);
  253. pDC->LineTo(secondPoint);
  254. pDC->SelectObject(OldPen);
  255. }
  256. void CEllipse::ComputeOffSet()
  257. {
  258. double vh[3][3]={m_Cos,-m_Sin,m_CenterPoint.x*(1-m_Cos)+m_CenterPoint.y*m_Sin,
  259.                m_Sin, m_Cos,m_CenterPoint.y*(1-m_Cos)-m_CenterPoint.x*m_Sin,
  260.    0,0,1
  261.             };       
  262.   
  263.       double xy1[3]={m_CenterPoint.x,m_CenterPoint.y,1};
  264.   m_OffSetX=vh[0][0]*xy1[0]+vh[0][1]*xy1[1]+vh[0][2]*xy1[2];
  265.   m_OffSetY=vh[1][0]*xy1[0]+vh[1][1]*xy1[1]+vh[1][2]*xy1[2];
  266.   
  267. }
  268. void CEllipse::ShowSelectPoint(CDC *pDC)
  269. {
  270.  double vh[3][3]={m_Cos,-m_Sin,m_CenterPoint.x*(1-m_Cos)+m_CenterPoint.y*m_Sin,
  271.                m_Sin, m_Cos,m_CenterPoint.y*(1-m_Cos)-m_CenterPoint.x*m_Sin,
  272.    0,0,1
  273.                   };       
  274.   
  275.       double xy1[3]={-m_Xr+this->m_CenterPoint.x,this->m_CenterPoint.y,1};
  276.   this->m_MarginPoint[0].x=vh[0][0]*xy1[0]+vh[0][1]*xy1[1]+vh[0][2]*xy1[2];
  277.   this->m_MarginPoint[0].y=vh[1][0]*xy1[0]+vh[1][1]*xy1[1]+vh[1][2]*xy1[2];
  278.       
  279.   double xy2[3]={this->m_CenterPoint.x,this->m_CenterPoint.y-m_Yr,1};
  280.       this->m_MarginPoint[1].x=vh[0][0]*xy2[0]+vh[0][1]*xy2[1]+vh[0][2]*xy2[2];
  281.   this->m_MarginPoint[1].y=vh[1][0]*xy2[0]+vh[1][1]*xy2[1]+vh[1][2]*xy2[2]; 
  282.   double xy3[3]={this->m_CenterPoint.x+m_Xr,this->m_CenterPoint.y,1};
  283.   this->m_MarginPoint[2].x=vh[0][0]*xy3[0]+vh[0][1]*xy3[1]+vh[0][2]*xy3[2];
  284.   this->m_MarginPoint[2].y=vh[1][0]*xy3[0]+vh[1][1]*xy3[1]+vh[1][2]*xy3[2];
  285.    
  286.   double xy4[3]={this->m_CenterPoint.x,m_Yr+this->m_CenterPoint.y,1};
  287.       this->m_MarginPoint[3].x=vh[0][0]*xy4[0]+vh[0][1]*xy4[1]+vh[0][2]*xy4[2];
  288.   this->m_MarginPoint[3].y=vh[1][0]*xy4[0]+vh[1][1]*xy4[1]+vh[1][2]*xy4[2];
  289.   double xy5[3]={this->m_CenterPoint.x,this->m_CenterPoint.y,1};
  290.       this->m_MarginPoint[4].x=vh[0][0]*xy5[0]+vh[0][1]*xy5[1]+vh[0][2]*xy5[2];
  291.   this->m_MarginPoint[4].y=vh[1][0]*xy5[0]+vh[1][1]*xy5[1]+vh[1][2]*xy5[2];
  292. CBrush brush;
  293. brush.CreateSolidBrush(RGB(0,0,255));
  294. CPen m_pen;
  295. m_pen.CreatePen(PS_SOLID,1,RGB(0,0,255));
  296. CPen *OldPen=pDC->SelectObject(&m_pen);
  297. int oldBkMode=pDC->SetBkMode(OPAQUE); 
  298. CBrush *OldBrush=pDC->SelectObject(&brush);
  299. int oldDrawingMode=pDC->SetROP2(R2_NOTXORPEN);
  300.  CRect rect;
  301.  for(int i=0;i<4;i++)
  302.  {
  303.   rect.SetRect(this->m_MarginPoint[i],this->m_MarginPoint[i]);
  304.   rect.InflateRect(3,3);
  305.   pDC->Rectangle(rect);
  306.  }
  307.  pDC->SelectObject(OldBrush);
  308.  brush.DeleteObject();
  309.  brush.CreateSolidBrush(RGB(255,0,0));
  310.  pDC->SelectObject(&brush);
  311.   rect.SetRect(this->m_MarginPoint[4],this->m_MarginPoint[4]);
  312.   rect.InflateRect(3,3);
  313.   pDC->Rectangle(rect);
  314. pDC->SelectObject(OldPen);
  315. pDC->SetBkMode(oldBkMode); 
  316. pDC->SelectObject(OldBrush);
  317. pDC->SetROP2(oldDrawingMode);
  318. }
  319. CRect CEllipse::GetBoundingRect()
  320. {
  321. double vh[3][3]={m_Cos,-m_Sin,m_CenterPoint.x*(1-m_Cos)+m_CenterPoint.y*m_Sin,
  322.                m_Sin, m_Cos,m_CenterPoint.y*(1-m_Cos)-m_CenterPoint.x*m_Sin,
  323.    0,0,1
  324.                   };       
  325.   
  326.       double xy1[3]={-m_Xr+this->m_CenterPoint.x,this->m_CenterPoint.y-m_Yr,1};
  327.   int left=vh[0][0]*xy1[0]+vh[0][1]*xy1[1]+vh[0][2]*xy1[2];
  328.   int top=vh[1][0]*xy1[0]+vh[1][1]*xy1[1]+vh[1][2]*xy1[2];
  329.       
  330.   double xy2[3]={this->m_CenterPoint.x+m_Xr,this->m_CenterPoint.y-m_Yr,1};
  331.       int left2=vh[0][0]*xy2[0]+vh[0][1]*xy2[1]+vh[0][2]*xy2[2];
  332.   int top2=vh[1][0]*xy2[0]+vh[1][1]*xy2[1]+vh[1][2]*xy2[2]; 
  333.   double xy3[3]={this->m_CenterPoint.x+m_Xr,this->m_CenterPoint.y+m_Yr,1};
  334.   int right=vh[0][0]*xy3[0]+vh[0][1]*xy3[1]+vh[0][2]*xy3[2];
  335.   int bottom=vh[1][0]*xy3[0]+vh[1][1]*xy3[1]+vh[1][2]*xy3[2];
  336.    
  337.   double xy4[3]={this->m_CenterPoint.x-m_Xr,m_Yr+this->m_CenterPoint.y,1};
  338.       int right2=vh[0][0]*xy4[0]+vh[0][1]*xy4[1]+vh[0][2]*xy4[2];
  339.   int bottom2=vh[1][0]*xy4[0]+vh[1][1]*xy4[1]+vh[1][2]*xy4[2];
  340.      
  341.  int miny=min(min(top,top2),min(bottom,bottom2));
  342.  int minx=min(min(right,right2),min(left,left2));
  343.  int maxy=max(max(top,top2),max(bottom,bottom2));
  344.  int maxx=max(max(right,right2),max(left,left2));
  345.   m_BoundingRect.left=minx;
  346.   m_BoundingRect.top=miny;
  347.   m_BoundingRect.right=maxx;
  348.   m_BoundingRect.bottom=maxy;
  349.   
  350.   return this->m_BoundingRect;
  351.   
  352. }
  353. void CEllipse::DrawActive(CDC *pDC,CPoint point)
  354. {
  355.   CPen m_pen;
  356.   CBrush m_brush;
  357.  
  358.   m_pen.CreatePen(m_PenStyle,m_PenWidth,m_PenColor);
  359.   CPen* pen=(CPen*)pDC->SelectObject(&m_pen);
  360.   LOGBRUSH brushlog;
  361.   brushlog.lbColor=m_BrushColor;
  362.   brushlog.lbHatch=m_BrushHatch;
  363.   brushlog.lbStyle=m_BrushStyle;
  364.   m_brush.CreateBrushIndirect(&brushlog);
  365.   SetBrushOrg(pDC,&m_brush);
  366.   CBrush*brush=(CBrush*)pDC->SelectObject(&m_brush);
  367.  
  368.  int OldBkMode=pDC->SetBkMode(m_BkMode);
  369.  COLORREF OldColor=pDC->SetBkColor(m_BackgroundColor);
  370.  
  371.  ellipseMidpoint(pDC,m_CenterPoint.x,m_CenterPoint.y,this->m_Xr,this->m_Yr);
  372.  pDC->SelectObject(brush);
  373.  pDC->SelectObject(pen);
  374.  pDC->SetBkMode(OldBkMode);
  375.  pDC->SetBkColor(OldColor);
  376.  
  377. }
  378. void CEllipse::OnLButtonDown(CDC *pDC, CEastDrawView *pView, CPoint point)
  379. {
  380.    if(m_HaveFindFirst)
  381. {
  382.     pView->L_iPointCount=IsOnMarginPoint(point);
  383. if(pView->L_iPointCount!=0)
  384. {
  385. pView->m_bHaveFindSecond=true;
  386.         pView->m_CurrentDrawTool=Ellipse_Tool;
  387.         pView->m_CurrentDrawStatus=Change_Status;
  388.   
  389. switch(pView->L_iPointCount)
  390. {
  391.    case 1:
  392.    pView->m_FirstPoint=m_SecondPoint;
  393.    pView->m_SecondPoint=m_FirstPoint;
  394.    break;
  395.    case 2:
  396.    pView->m_FirstPoint=m_FirstPoint;
  397.    pView->m_SecondPoint=m_SecondPoint;
  398.    break;
  399.    
  400.    case 3:
  401.    pView->m_FirstPoint=m_FirstPoint;
  402.    pView->m_SecondPoint=m_SecondPoint;
  403.    break;
  404.    case 4:
  405.    pView->m_FirstPoint=m_SecondPoint;
  406.    pView->m_SecondPoint=m_FirstPoint;
  407.    break;
  408.    case 5:
  409.    pView->m_FirstPoint=m_FirstPoint;
  410.    pView->m_SecondPoint=m_SecondPoint;
  411.        pView->m_CurrentDrawTool=Ellipse_Tool;
  412.        pView->m_CurrentDrawStatus=Drag_Status;
  413.   break;
  414. }
  415.  }//******if(L_iPointCount!=0)
  416. }//**********if(L_pEllipse->m_HaveFindFirst)
  417.   
  418.      if(!pView->m_bHaveFindSecond&&IsInRgn(point))
  419.  {
  420.    if(!m_HaveFindFirst)
  421.    {
  422.     m_HaveFindFirst=true;
  423. pView->m_bHaveFindFirst=true;
  424.     ShowSelectPoint(pDC);
  425.    }
  426.    else
  427.    {
  428.     m_HaveFindFirst=false;
  429. pView->m_bHaveFindFirst=true;
  430. ShowSelectPoint(pDC);
  431.    }
  432.  }
  433.  
  434.    if(pView->m_bHaveFindSecond)
  435. {   
  436.         pView->m_pCurrentUnit=this;
  437. m_DrawingMode=pDC->GetROP2();
  438.         DrawStatic(pDC);
  439. DrawOldReferencePoint(pDC,m_FoundPoint);
  440.     ShowSelectPoint(pDC);
  441.     }
  442.   
  443. }
  444.  void CEllipse::OnMouseMove(CDC *pDC, CEastDrawView *pView, CPoint point)
  445. {
  446.     if(pView->m_CurrentDrawStatus==Drag_Status)
  447. {
  448.        if(!m_IsCirCu)
  449.    m_CenterPoint.Offset((pView->m_SecondPoint.x-pView->m_FirstPoint.x),(pView->m_SecondPoint.y-pView->m_FirstPoint.y)); 
  450.    if(m_IsCirCu)
  451.    ComputSloap(m_CenterPoint,point);
  452. }
  453. else
  454.   {
  455.       //pDC->SetROP2(R2_NOTXORPEN);
  456.  if(pView->m_LBDownTimes==2&&pView->m_CurrentDrawStatus!=Change_Status)
  457.   {
  458.  
  459.   ShowMovingLine(pDC,m_CenterPoint,point);
  460.   ellipseMidpoint(pDC,m_CenterPoint.x,m_CenterPoint.y,m_Xr,m_Yr);
  461.       ComputRadiusX(m_CenterPoint,point);
  462.   //m_DrawingMode=pDC->GetROP2();
  463.   pView->m_SecondPoint=point;
  464.   ellipseMidpoint(pDC,m_CenterPoint.x,m_CenterPoint.y,m_Xr,m_Yr);
  465.   ShowMovingLine(pDC,m_CenterPoint,point);
  466.  }
  467.  if(pView->m_CurrentDrawStatus==Change_Status)
  468.  {
  469.  
  470.  ellipseMidpoint(pDC,m_CenterPoint.x,m_CenterPoint.y,m_Xr,m_Yr);
  471.  
  472.     ShowMovingLine(pDC,m_CenterPoint,pView->m_SecondPoint);
  473.       pView->m_SecondPoint=point;
  474.   if(pView->L_iPointCount==1||pView->L_iPointCount==3)
  475.   ComputRadiusX(m_CenterPoint,point);
  476.   if(pView->L_iPointCount==2||pView->L_iPointCount==4)
  477.           ComputRadiusY(m_CenterPoint,point);
  478.   
  479.   //m_DrawingMode=pDC->GetROP2();
  480.   ShowMovingLine(pDC,m_CenterPoint,point);
  481.   
  482.   
  483.       ellipseMidpoint(pDC,m_CenterPoint.x,m_CenterPoint.y,m_Xr,m_Yr);
  484.   }
  485.  
  486.  if(pView->m_LBDownTimes==1&&pView->m_CurrentDrawStatus!=Change_Status)
  487.  {
  488.           
  489.   ShowMovingLine(pDC,pView->m_FirstPoint,pView->m_SecondPoint);
  490.   pView->m_SecondPoint=point;
  491.   ShowMovingLine(pDC,pView->m_FirstPoint,point);
  492.  }
  493.   }
  494. }
  495. void CEllipse::OnMenuitemCirCu(CDC *pDC, CEastDrawView *pView)
  496. {
  497.   m_IsCirCu=!m_IsCirCu;
  498. }
  499. CEllipse::CEllipse()
  500. {
  501. CUnit::Initial();
  502. m_IsCirCu=false;
  503. }
  504. void CEllipse::OnContextMenu(CWnd *pWnd, CPoint point)
  505. {
  506. CEastDrawView*pView=(CEastDrawView*)pWnd;
  507. if(pView->m_CurrentDrawStatus==Drag_Status)
  508. {
  509. CMenu menuTextEdit;
  510. menuTextEdit.LoadMenu(IDR_MENU_Canvas_Edit);
  511. menuTextEdit.CheckMenuItem(ID_CirCu,m_IsCirCu?MF_CHECKED:MF_UNCHECKED);
  512. menuTextEdit.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN,point.x,point.y,pWnd);
  513. }
  514. }