CEllipse.cpp 15 KB

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