CUnit.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. #include "stdafx.h"
  2. #include"CUnit.h"
  3. #include "EastDrawView.h"
  4. IMPLEMENT_SERIAL(CUnit,CObject,1)
  5. CUnit::CUnit()
  6. {
  7. Initial();
  8. }
  9. CUnit::CUnit(CUnit&unit)
  10. {
  11. m_FirstPoint=unit.m_FirstPoint;
  12. m_SecondPoint=unit.m_SecondPoint;
  13. m_PenColor=unit.m_PenColor;
  14. m_PenWidth=unit.m_PenWidth;
  15. m_PenStyle=unit.m_PenStyle;
  16. }
  17. CUnit CUnit::operator =(CUnit&unit)
  18. {
  19. m_FirstPoint=unit.m_FirstPoint;
  20. m_SecondPoint=unit.m_SecondPoint;
  21. m_PenColor=unit.m_PenColor;
  22. m_PenWidth=unit.m_PenWidth;
  23. m_PenStyle=unit.m_PenStyle;
  24. return *this;
  25. }
  26. void CUnit::Initial()
  27. {
  28. m_BkMode=TRANSPARENT;
  29. m_Rgn=NULL;
  30. m_FirstPoint=0;
  31. m_SecondPoint=0;
  32. m_PenColor=RGB(0,0,0);
  33. m_BrushColor=RGB(0,0,0);
  34. m_BackgroundColor=RGB(255,255,255);
  35. m_PenWidth=1;
  36. m_PenStyle=PS_SOLID;
  37. m_DrawingMode=R2_COPYPEN;
  38. m_HaveLBUp=false;
  39. m_HaveFindFirst=false;
  40. m_DrawStatus=Draw_Status;
  41. }
  42. void CUnit::Serialize(CArchive &ar)
  43. {
  44. if(ar.IsStoring())
  45. {
  46. ar<<m_PenColor<<m_PenStyle<<m_PenWidth<<m_DrawingMode<<m_BkMode<<m_BackgroundColor;
  47. ar<<m_FirstPoint<<m_SecondPoint;
  48. }
  49. else
  50. {
  51. ar>>m_PenColor>>m_PenStyle>>m_PenWidth>>m_DrawingMode>>m_BkMode>>m_BackgroundColor;
  52. ar>>m_FirstPoint>>m_SecondPoint;
  53. }
  54. }
  55. CRgn* CUnit::GetRgn()
  56. {
  57. if(m_Rgn==NULL)
  58. {
  59. m_Rgn=new CRgn;
  60. CPoint point[2];
  61. point[0]=m_FirstPoint;
  62. point[1]=m_SecondPoint;
  63. m_Rgn->CreatePolygonRgn(point,2,ALTERNATE);
  64. }
  65. return m_Rgn;
  66. }
  67. BOOL CUnit::IsInRgn(CPoint point)
  68. {
  69. this->GetRgn();
  70. return (m_Rgn->PtInRegion(point));
  71. }
  72. int CUnit::IsOnMarginPoint(CPoint point)
  73. {
  74. return 0;
  75. }
  76. void CUnit::Circumrotate(CPoint first,CPoint second)
  77. {
  78. }
  79. void CUnit::OnLButtonDown(CDC*pDC,CEastDrawView*pView,CPoint point)
  80. {
  81. }
  82. void CUnit::DrawMask(CDC*pDC,CPoint first,CPoint second)
  83. {
  84. }
  85. void CUnit::DrawMask(CDC *pDC, CPoint point)
  86. {
  87. }
  88. void CUnit::DrawEnd(CDC*pDC,CPoint point)
  89. {
  90. }
  91. void CUnit::ExchangeDraw(CDC *pDC, CPoint point)
  92. {
  93. }
  94. int CUnit::ComputRadious(CPoint centerPoint, CPoint movingPoint)
  95. {
  96. return 0;
  97. }
  98. void CUnit::ellipseMidpoint(CDC*pDC,int xCenter, int yCenter, int Rx, int Ry)
  99. {
  100. }
  101. float CUnit::ComputSloap(CPoint firstPoint, CPoint secondPoint)
  102. {
  103. return 0;
  104. }
  105. int CUnit::ComputRadiusY(CPoint firstPoint,CPoint secondPoint)
  106. {
  107. return 0;
  108. }
  109. int CUnit::ComputRadiusX(CPoint firstPoint,CPoint secondPoint)
  110. {
  111. return 0;
  112. }
  113. void CUnit::ShowMovingLine(CDC*pDC,CPoint firstPoint, CPoint secondPoint)
  114. {
  115. CPen m_pen;
  116. m_pen.CreatePen(PS_SOLID,1,RGB(0,0,255));
  117. CPen *OldPen=pDC->SelectObject(&m_pen);
  118. int oldDrawingMode=pDC->SetROP2(R2_NOTXORPEN);
  119. int oldBkMode=pDC->SetBkMode(OPAQUE);
  120. pDC->MoveTo(firstPoint);
  121. pDC->LineTo(secondPoint.x,secondPoint.y);
  122. pDC->SelectObject(OldPen);
  123. pDC->SetROP2(oldDrawingMode);
  124. pDC->SetBkMode(oldBkMode);
  125. }
  126. void CUnit::ShowSelectPoint(CDC*pDC)
  127. {
  128. }
  129. void CUnit::DrawOldReferencePoint(CDC *pDC, CPoint point)
  130. {
  131. CBrush brush;
  132. brush.CreateSolidBrush(RGB(250,0,250));
  133. CPen m_pen;
  134. m_pen.CreatePen(PS_SOLID,1,RGB(0,0,255));
  135. CPen *OldPen=pDC->SelectObject(&m_pen);
  136. int oldBkMode=pDC->SetBkMode(OPAQUE);
  137. CBrush *OldBrush=pDC->SelectObject(&brush);
  138. int oldDrawingMode=pDC->SetROP2(R2_NOTXORPEN);
  139. CRect rect;
  140. rect.SetRect(point,point);
  141. rect.InflateRect(3,3);
  142. pDC->Rectangle(rect);
  143. pDC->SelectObject(OldPen);
  144. pDC->SelectObject(OldBrush);
  145. pDC->SetROP2(oldDrawingMode);
  146. pDC->SetBkMode(oldBkMode);
  147. }
  148. CRect CUnit::GetBoundingRect()
  149. {
  150. return 0;
  151. }
  152. double CUnit::ComputeSloap1(CPoint firstpoint, CPoint secondpoint)
  153. {
  154. return 0;
  155. }
  156. double CUnit::ComputeSloap2(CPoint firstpoint, CPoint secondpoint)
  157. {
  158. return 0;
  159. }
  160. void CUnit::DrawActive(CDC *pDC,CPoint point)
  161. {
  162. }
  163. void CUnit::DrawActiveStepOne(CDC *pDC,CPoint movingPoint)
  164. {
  165. }
  166. void CUnit::DrawStaticStepOne(CDC *pDC,CPoint movingPoint)
  167. {
  168. }
  169. CPoint CUnit::ComputeIntersectionPointFirst(CPoint point)
  170. {
  171. return 0;
  172. }
  173. CPoint CUnit::ComputeIntersectionPointSecond(CPoint point)
  174. {
  175. return 0;
  176. }
  177. void CUnit::OnMouseMove(CDC*pDC,CEastDrawView*pView,CPoint point)
  178. {
  179. }
  180. void CUnit::OnLButtonDblClk(CDC *pDC,CEastDrawView *pView, CPoint point)
  181. {
  182. }
  183. void CUnit::SetFont(ENUMLOGFONT *lpelf)
  184. {
  185. }
  186. void CUnit::ChangeFont(ENUMLOGFONT *lpelf)
  187. {
  188. }
  189. void CUnit::ChangeFontSize(ENUMLOGFONT *lpelf)
  190. {
  191. }
  192. void CUnit::OnContextMenu(CWnd *pWnd, CPoint point)
  193. {
  194. }
  195. void CUnit::OnMenuitemOk(CDC *pDC, CEastDrawView *pView)
  196. {
  197. }
  198. void CUnit::OnMENUITEMSize()
  199. {
  200. }
  201. void CUnit::OnMenuitemCirCu(CDC *pDC, CEastDrawView *pView)
  202. {
  203. }
  204. void CUnit::SetBrushOrg(CDC *pDC,CBrush*brush)
  205. {
  206. if(pDC!=NULL&&brush!=NULL)
  207. {
  208. if(pDC->m_hDC!=NULL&&brush->m_hObject!=NULL)
  209. {
  210. CPoint pointB(0,0);
  211. pDC->LPtoDP(&pointB);
  212. pointB.x%=8;
  213. pointB.y%=8;
  214. brush->UnrealizeObject();
  215. pDC->SetBrushOrg(pointB);
  216. }
  217. }
  218. }