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

绘图程序

开发平台:

C/C++

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