123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294 |
- #include "stdafx.h"
- #include"CUnit.h"
- #include "EastDrawView.h"
- IMPLEMENT_SERIAL(CUnit,CObject,1)
- CUnit::CUnit()
- {
- Initial();
- }
- CUnit::CUnit(CUnit&unit)
- {
- m_FirstPoint=unit.m_FirstPoint;
- m_SecondPoint=unit.m_SecondPoint;
- m_PenColor=unit.m_PenColor;
- m_PenWidth=unit.m_PenWidth;
- m_PenStyle=unit.m_PenStyle;
-
- }
- CUnit CUnit::operator =(CUnit&unit)
- {
- m_FirstPoint=unit.m_FirstPoint;
- m_SecondPoint=unit.m_SecondPoint;
- m_PenColor=unit.m_PenColor;
- m_PenWidth=unit.m_PenWidth;
- m_PenStyle=unit.m_PenStyle;
-
-
- return *this;
- }
- void CUnit::Initial()
- {
- m_BkMode=TRANSPARENT;
- m_Rgn=NULL;
- m_FirstPoint=0;
- m_SecondPoint=0;
- m_PenColor=RGB(0,0,0);
- m_BrushColor=RGB(0,0,0);
- m_BackgroundColor=RGB(255,255,255);
- m_PenWidth=1;
- m_PenStyle=PS_SOLID;
-
- m_DrawingMode=R2_COPYPEN;
- m_HaveLBUp=false;
- m_HaveFindFirst=false;
- m_DrawStatus=Draw_Status;
- }
- void CUnit::Serialize(CArchive &ar)
- {
- if(ar.IsStoring())
- {
- ar<<m_PenColor<<m_PenStyle<<m_PenWidth<<m_DrawingMode<<m_BkMode<<m_BackgroundColor;
- ar<<m_FirstPoint<<m_SecondPoint;
- }
- else
- {
- ar>>m_PenColor>>m_PenStyle>>m_PenWidth>>m_DrawingMode>>m_BkMode>>m_BackgroundColor;
- ar>>m_FirstPoint>>m_SecondPoint;
- }
- }
- CRgn* CUnit::GetRgn()
- {
- if(m_Rgn==NULL)
- {
- m_Rgn=new CRgn;
- CPoint point[2];
- point[0]=m_FirstPoint;
- point[1]=m_SecondPoint;
- m_Rgn->CreatePolygonRgn(point,2,ALTERNATE);
- }
- return m_Rgn;
- }
- BOOL CUnit::IsInRgn(CPoint point)
- {
- this->GetRgn();
- return (m_Rgn->PtInRegion(point));
-
- }
- int CUnit::IsOnMarginPoint(CPoint point)
- {
- return 0;
- }
- void CUnit::Circumrotate(CPoint first,CPoint second)
- {
- }
- void CUnit::OnLButtonDown(CDC*pDC,CEastDrawView*pView,CPoint point)
- {
- }
- void CUnit::DrawMask(CDC*pDC,CPoint first,CPoint second)
- {
- }
- void CUnit::DrawMask(CDC *pDC, CPoint point)
- {
- }
- void CUnit::DrawEnd(CDC*pDC,CPoint point)
- {
- }
- void CUnit::ExchangeDraw(CDC *pDC, CPoint point)
- {
- }
- int CUnit::ComputRadious(CPoint centerPoint, CPoint movingPoint)
- {
- return 0;
- }
- void CUnit::ellipseMidpoint(CDC*pDC,int xCenter, int yCenter, int Rx, int Ry)
- {
- }
- float CUnit::ComputSloap(CPoint firstPoint, CPoint secondPoint)
- {
- return 0;
- }
- int CUnit::ComputRadiusY(CPoint firstPoint,CPoint secondPoint)
- {
- return 0;
- }
- int CUnit::ComputRadiusX(CPoint firstPoint,CPoint secondPoint)
- {
- return 0;
- }
- void CUnit::ShowMovingLine(CDC*pDC,CPoint firstPoint, CPoint secondPoint)
- {
- CPen m_pen;
- m_pen.CreatePen(PS_SOLID,1,RGB(0,0,255));
- CPen *OldPen=pDC->SelectObject(&m_pen);
- int oldDrawingMode=pDC->SetROP2(R2_NOTXORPEN);
- int oldBkMode=pDC->SetBkMode(OPAQUE);
- pDC->MoveTo(firstPoint);
- pDC->LineTo(secondPoint.x,secondPoint.y);
- pDC->SelectObject(OldPen);
- pDC->SetROP2(oldDrawingMode);
- pDC->SetBkMode(oldBkMode);
- }
- void CUnit::ShowSelectPoint(CDC*pDC)
- {
- }
- void CUnit::DrawOldReferencePoint(CDC *pDC, CPoint point)
- {
- CBrush brush;
- brush.CreateSolidBrush(RGB(250,0,250));
- CPen m_pen;
- m_pen.CreatePen(PS_SOLID,1,RGB(0,0,255));
- CPen *OldPen=pDC->SelectObject(&m_pen);
- int oldBkMode=pDC->SetBkMode(OPAQUE);
- CBrush *OldBrush=pDC->SelectObject(&brush);
- int oldDrawingMode=pDC->SetROP2(R2_NOTXORPEN);
- CRect rect;
- rect.SetRect(point,point);
- rect.InflateRect(3,3);
- pDC->Rectangle(rect);
- pDC->SelectObject(OldPen);
- pDC->SelectObject(OldBrush);
- pDC->SetROP2(oldDrawingMode);
- pDC->SetBkMode(oldBkMode);
- }
- CRect CUnit::GetBoundingRect()
- {
- return 0;
- }
- double CUnit::ComputeSloap1(CPoint firstpoint, CPoint secondpoint)
- {
- return 0;
- }
- double CUnit::ComputeSloap2(CPoint firstpoint, CPoint secondpoint)
- {
- return 0;
- }
- void CUnit::DrawActive(CDC *pDC,CPoint point)
- {
- }
- void CUnit::DrawActiveStepOne(CDC *pDC,CPoint movingPoint)
- {
- }
- void CUnit::DrawStaticStepOne(CDC *pDC,CPoint movingPoint)
- {
- }
- CPoint CUnit::ComputeIntersectionPointFirst(CPoint point)
- {
- return 0;
- }
- CPoint CUnit::ComputeIntersectionPointSecond(CPoint point)
- {
- return 0;
- }
- void CUnit::OnMouseMove(CDC*pDC,CEastDrawView*pView,CPoint point)
- {
- }
- void CUnit::OnLButtonDblClk(CDC *pDC,CEastDrawView *pView, CPoint point)
- {
- }
- void CUnit::SetFont(ENUMLOGFONT *lpelf)
- {
- }
- void CUnit::ChangeFont(ENUMLOGFONT *lpelf)
- {
- }
- void CUnit::ChangeFontSize(ENUMLOGFONT *lpelf)
- {
- }
- void CUnit::OnContextMenu(CWnd *pWnd, CPoint point)
- {
- }
- void CUnit::OnMenuitemOk(CDC *pDC, CEastDrawView *pView)
- {
- }
- void CUnit::OnMENUITEMSize()
- {
- }
- void CUnit::OnMenuitemCirCu(CDC *pDC, CEastDrawView *pView)
- {
- }
- void CUnit::SetBrushOrg(CDC *pDC,CBrush*brush)
- {
- if(pDC!=NULL&&brush!=NULL)
- {
- if(pDC->m_hDC!=NULL&&brush->m_hObject!=NULL)
- {
- CPoint pointB(0,0);
- pDC->LPtoDP(&pointB);
- pointB.x%=8;
- pointB.y%=8;
- brush->UnrealizeObject();
-
- pDC->SetBrushOrg(pointB);
- }
- }
- }
|