CAD2006View.cpp
资源名称:CAD2006.rar [点击查看]
上传用户:ckg1000
上传日期:2013-01-26
资源大小:630k
文件大小:42k
源码类别:
CAD
开发平台:
Visual C++
- // CAD2006View.cpp : implementation of the CCAD2006View class
- //
- #include "stdafx.h"
- #include "CAD2006.h"
- #include "MainFrm.h"
- #include "CAD2006Doc.h"
- #include "CAD2006View.h"
- #include "shape.h"
- #include "Line1.h"
- #include "Trigon.h"
- #include "Polygon.h"
- #include "Circle.h"
- #include "Rect.h"
- #include "ellipse.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- extern enum SHAPE;
- static CString m_allshapepoint;
- CArray<CRect,CRect> m_rectarray;
- CArray<CRect,CRect> m_textarray;
- CString m_array; //1 line,2 linedown,3 rect,4 trigon,5 polygon,6 circle,7 ellipse
- CArray<CPoint,CPoint> m_linearray;
- CArray<CPoint,CPoint> m_linedownarray;
- CArray<CPoint,CPoint> m_circlearray;
- CArray<CPoint,CPoint> m_ellipsearray;
- CArray<CPoint,CPoint> m_rectanglearray;
- CArray<CPoint,CPoint> m_trigonarray;
- CArray<CPoint,CPoint> m_polygonarray;
- CArray<POINT *,POINT *> m_polygonarraypoint;
- int shapeindex = 0;
- enum SelectStatus{NoSelect,YesSelect} selectstatus; //选定状态
- enum MirrorStatus{NoMirror,YesMirror} mirrorstatus; //镜像状态
- static bool bln = true;
- static bool blnselecttrigon = true;
- static bool blnfirst = true; //打开
- CRect selectrect;
- int index;
- int count = 0;
- bool blnselect = true;
- bool blnfrist = true; //只初始化一次
- /////////////////////////////////////////////////////////////////////////////
- // CCAD2006View
- IMPLEMENT_DYNCREATE(CCAD2006View, CView)
- BEGIN_MESSAGE_MAP(CCAD2006View, CView)
- //{{AFX_MSG_MAP(CCAD2006View)
- ON_WM_MOUSEMOVE()
- ON_WM_SETCURSOR()
- ON_WM_LBUTTONDOWN()
- ON_WM_RBUTTONDOWN()
- ON_WM_KEYDOWN()
- ON_WM_LBUTTONUP()
- ON_COMMAND(ID_FILE_SAVE, OnFileSave)
- ON_WM_KILLFOCUS()
- ON_WM_MOUSEWHEEL()
- ON_WM_ERASEBKGND()
- ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
- //}}AFX_MSG_MAP
- // Standard printing commands
- ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CCAD2006View construction/destruction
- CCAD2006View::CCAD2006View()
- {
- // TODO: add construction code here
- this->m_openclose = close;
- this->m_state = first;
- }
- CCAD2006View::~CCAD2006View()
- {
- }
- BOOL CCAD2006View::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return CView::PreCreateWindow(cs);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CCAD2006View drawing
- void CCAD2006View::OnDraw(CDC* pDC)
- {
- CCAD2006Doc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // TODO: add draw code for native data herestatic HCURSOR hcur = NULL;
- /* if( !blnfirst )
- {
- this->ShowShape(m_allshapepoint);
- }*/
- /* RECT rect;
- ::AfxGetApp()->m_pMainWnd->GetClientRect(&rect);
- ::AfxGetApp()->GetMainWnd()->GetClientRect(&rect);
- ::AfxGetApp()->GetMainWnd()->InvalidateRect(&rect,false);*/
- }
- /////////////////////////////////////////////////////////////////////////////
- // CCAD2006View printing
- BOOL CCAD2006View::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // default preparation
- return DoPreparePrinting(pInfo);
- }
- void CCAD2006View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add extra initialization before printing
- }
- void CCAD2006View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
- /////////////////////////////////////////////////////////////////////////////
- // CCAD2006View diagnostics
- #ifdef _DEBUG
- void CCAD2006View::AssertValid() const
- {
- CView::AssertValid();
- }
- void CCAD2006View::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
- CCAD2006Doc* CCAD2006View::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCAD2006Doc)));
- return (CCAD2006Doc*)m_pDocument;
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CCAD2006View message handlers
- BOOL CCAD2006View::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
- {
- /*******************设置相应的鼠标光标******************************/
- CCAD2006Doc* pDoc = GetDocument();
- static HCURSOR hcur = NULL;
- switch( pDoc->m_shape ) //形状工具
- {
- case line:
- hcur = ::AfxGetApp()->LoadCursor(IDC_CURSOR_LINE);
- break;
- case linedown:
- hcur = ::AfxGetApp()->LoadCursor(IDC_CURSOR_LINE);
- break;
- case lineangle:
- hcur = ::AfxGetApp()->LoadCursor(IDC_CURSOR_LINE);
- break;
- case trigon:
- hcur = ::AfxGetApp()->LoadCursor(IDC_CURSOR_TRIGON);
- break;
- case circle:
- hcur = ::AfxGetApp()->LoadCursor(IDC_CURSOR_RECT);
- break;
- case ellipse:
- hcur = ::AfxGetApp()->LoadCursor(IDC_CURSOR_RECT);
- break;
- case circlemater:
- hcur = ::AfxGetApp()->LoadCursor(IDC_CURSOR_RECT);
- break;
- case rect:
- hcur = ::AfxGetApp()->LoadCursor(IDC_CURSOR_RECT);
- break;
- case polygon:
- hcur = ::AfxGetApp()->LoadCursor(IDC_CURSOR_RECT);
- break;
- case font:
- hcur = ::AfxGetApp()->LoadCursor(IDC_CURSOR_ARROW);
- break;
- }
- switch( pDoc->m_tool ) //图形工具
- {
- case arrow:
- hcur = ::AfxGetApp()->LoadCursor(IDC_CURSOR_ARROW);
- break;
- case draw:
- hcur = ::AfxGetApp()->LoadCursor(IDC_CURSOR_ARROW);
- break;
- case fill:
- hcur = ::AfxGetApp()->LoadCursor(IDC_CURSOR_ARROW);
- break;
- case move:
- hcur = ::AfxGetApp()->LoadCursor(IDC_CURSOR_ARROW);
- break;
- case zoom:
- hcur = ::AfxGetApp()->LoadCursor(IDC_CURSOR_ARROW);
- break;
- case msl:
- hcur = ::AfxGetApp()->LoadCursor(IDC_CURSOR_ARROW);
- break;
- case eddy:
- hcur = ::AfxGetApp()->LoadCursor(IDC_CURSOR_ROTATE);
- break;
- }
- ::SetCursor(hcur);
- return 0;
- }
- void CCAD2006View::OnMouseMove(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
- CCAD2006Doc* pDoc = GetDocument();
- CDC *pDC = GetDC();
- /*******************************************/
- /*****************镜像工具***********************/
- if( pDoc->m_tool == msl )
- {
- switch( pDoc->m_shape )
- {
- case rect:
- {
- if(mirrorstatus == YesMirror)
- {
- pDoc->m_shapetool->Mirror(pDC,point);
- }
- break;
- }
- case trigon:
- {
- if(mirrorstatus == YesMirror)
- {
- pDoc->m_shapetool->Mirror(pDC,point);
- }
- break;
- }
- case polygon:
- {
- if(mirrorstatus == YesMirror)
- {
- pDoc->m_shapetool->Mirror(pDC,point);
- }
- break;
- }
- case circle:
- {
- if(mirrorstatus == YesMirror)
- {
- pDoc->m_shapetool->Mirror(pDC,point);
- }
- break;
- }
- case line:
- {
- if(mirrorstatus == YesMirror)
- {
- pDoc->m_shapetool->Mirror(pDC,point);
- }
- break;
- }
- }
- }
- /*******************缩放工具********************/
- if( pDoc->m_tool == zoom )
- {
- switch( pDoc->m_shape )
- {
- case trigon:
- {
- if(selectstatus == YesSelect)
- {
- pDoc->m_shapetool->Update(pDC); //去小圈再动
- pDoc->m_shapetool->Zoom(pDC,point);
- }
- break;
- }
- case polygon:
- {
- if(selectstatus == YesSelect)
- {
- pDoc->m_shapetool->Update(pDC); //去小圈再动
- pDoc->m_shapetool->Zoom(pDC,point);
- }
- break;
- }
- case rect:
- {
- if(selectstatus == YesSelect)
- {
- pDoc->m_shapetool->Update(pDC); //去小圈再动
- pDoc->m_shapetool->Zoom(pDC,point);
- }
- break;
- }
- case circle:
- {
- if(selectstatus == YesSelect)
- {
- //pDoc->m_shapetool->Update(pDC); //去小圈再动
- pDoc->m_shapetool->Zoom(pDC,point);
- }
- break;
- }
- case ellipse:
- {
- if(selectstatus == YesSelect)
- {
- //pDoc->m_shapetool->Update(pDC); //去小圈再动
- pDoc->m_shapetool->Zoom(pDC,point);
- }
- break;
- }
- case line:
- {
- if(selectstatus == YesSelect)
- {
- //pDoc->m_shapetool->Update(pDC); //去小圈再动
- pDoc->m_shapetool->Zoom(pDC,point);
- }
- break;
- }
- }
- }
- /********************画图形****************************/
- if( this->m_openclose == open )
- {
- switch( pDoc->m_shape )
- {
- case rect:
- {
- pDoc->m_shapetool->Onmousemove(pDC,point);
- this->m_state = second;
- break;
- }
- case line:
- {
- pDoc->m_shapetool->Onmousemove(pDC,point);
- this->m_state = second;
- break;
- }
- case linedown:
- {
- pDoc->m_shapetool->Onmousemove(pDC,point);
- //this->m_state = second;
- break;
- }
- case trigon:
- {
- pDoc->m_shapetool->Onmousemove(pDC,point);
- //this->m_state = second;
- break;
- }
- case polygon:
- {
- pDoc->m_shapetool->Onmousemove(pDC,point);
- this->m_state = second;
- break;
- }
- case circle:
- {
- pDoc->m_shapetool->Onmousemove(pDC,point);
- this->m_state = second;
- break;
- }
- case ellipse:
- {
- pDoc->m_shapetool->Onmousemove(pDC,point);
- this->m_state = second;
- break;
- }
- }
- }
- /*******************图形移动***********************************/
- if( pDoc->m_tool == move )
- {
- switch( pDoc->m_shape )
- {
- case line:
- {
- if(selectstatus == YesSelect)
- {
- pDoc->m_shapetool->Update(pDC); //去小圈再动
- pDoc->m_shapetool->Move(pDC,point);
- }
- break;
- }
- case trigon:
- {
- if(selectstatus == YesSelect)
- {
- pDoc->m_shapetool->Update(pDC); //去小圈再动
- pDoc->m_shapetool->Move(pDC,point);
- }
- break;
- }
- case polygon:
- {
- if(selectstatus == YesSelect)
- {
- pDoc->m_shapetool->Update(pDC); //去小圈再动
- pDoc->m_shapetool->Move(pDC,point);
- }
- break;
- }
- case rect:
- {
- if(selectstatus == YesSelect)
- {
- pDoc->m_shapetool->Update(pDC); //去小圈再动
- pDoc->m_shapetool->Move(pDC,point);
- }
- break;
- }
- case circle :
- {
- if(selectstatus == YesSelect)
- {
- // pDoc->m_shapetool->Update(pDC);
- pDoc->m_shapetool->Move(pDC,point);
- }
- break;
- }
- case ellipse:
- {
- if(selectstatus == YesSelect)
- {
- // pDoc->m_shapetool->Update(pDC);
- pDoc->m_shapetool->Move(pDC,point);
- }
- break;
- }
- }
- }
- /************************字体移动***********************************/
- /* if( pDoc->m_tool == move && pDoc->m_shape == font && nFlags == MK_LBUTTON )
- {
- CPoint m_point;
- m_point.x = point.x ;
- m_point.y = point.y - 32;
- m_point.x = abs(m_point.x - m_fontselect.x);
- m_point.y = abs(m_point.y - m_fontselect.y);
- //pDoc->m_text.TextMove(pDC,point,index,selectrect);
- }*/
- /*********** 坐标计算 *********/
- CMainFrame *pWnd = (CMainFrame *)::AfxGetMainWnd();
- pWnd->m_wndStatusBar.SetPaneInfo(2,ID_SEPARATOR,SBPS_NORMAL,45);
- CString MouseInfo;
- MouseInfo.Format("%002d,%002d",point.x,point.y);
- pWnd->m_wndStatusBar.SetPaneText(2,MouseInfo);
- CView::OnMouseMove(nFlags, point);
- }
- void CCAD2006View::OnLButtonDown(UINT nFlags, CPoint point)
- {
- CCAD2006Doc* pDoc = GetDocument();
- CDC *pDC = GetDC();
- /********************旋转工具****************************/
- if( pDoc->m_tool == eddy )
- {
- switch( pDoc->m_shape )
- {
- case trigon:
- {
- if(selectstatus == YesSelect)
- {
- pDoc->m_shapetool->Rotate(pDC,point); //转30度
- this->m_openclose = close;
- }
- break;
- }
- case polygon:
- {
- if(selectstatus == YesSelect)
- {
- pDoc->m_shapetool->Rotate(pDC,point); //转30度
- this->m_openclose = close;
- }
- break;
- }
- case line:
- {
- if(selectstatus == YesSelect)
- {
- pDoc->m_shapetool->Rotate(pDC,point); //转30度
- this->m_openclose = close;
- }
- break;
- }
- }
- }
- /*****************镜像工具***********************/
- if( pDoc->m_tool == msl )
- {
- switch( pDoc->m_shape )
- {
- case rect:
- {
- if(selectstatus == YesSelect)
- {
- mirrorstatus = YesMirror;
- pDoc->m_shapetool->OnMirLBtnDn(pDC,point);
- }
- break;
- }
- case trigon:
- {
- if(selectstatus == YesSelect)
- {
- mirrorstatus = YesMirror;
- pDoc->m_shapetool->OnMirLBtnDn(pDC,point);
- }
- break;
- }
- case polygon:
- {
- if(selectstatus == YesSelect)
- {
- mirrorstatus = YesMirror;
- pDoc->m_shapetool->OnMirLBtnDn(pDC,point);
- }
- break;
- }
- case circle:
- {
- if(selectstatus == YesSelect)
- {
- mirrorstatus = YesMirror;
- pDoc->m_shapetool->OnMirLBtnDn(pDC,point);
- }
- break;
- }
- case line:
- {
- if(selectstatus == YesSelect)
- {
- mirrorstatus = YesMirror;
- pDoc->m_shapetool->OnMirLBtnDn(pDC,point);
- }
- break;
- }
- }
- }
- /**************************缩放工具***********************************/
- if( pDoc->m_tool == zoom )
- {
- if( this->ZoomTrigonSelect(point) )
- {
- blnselecttrigon = false;
- selectstatus = YesSelect;
- this->m_openclose = close;
- }
- else if( this->ZoomPolygonSelect(point) )
- {
- blnselecttrigon = false;
- this->m_openclose = close;
- selectstatus = YesSelect;
- }
- else if( this->RectSelect(point) )
- {
- blnselecttrigon = false;
- this->m_openclose = close;
- selectstatus = YesSelect;
- }
- else if( this->CircleSelect(point) )
- {
- blnselecttrigon = false;
- this->m_openclose = close;
- selectstatus = YesSelect;
- }
- else if( this->EllipseSelect(point) )
- {
- blnselecttrigon = false;
- this->m_openclose = close;
- selectstatus = YesSelect;
- }
- else if( this->ZoomLineSelect(point) )
- {
- blnselecttrigon = false;
- this->m_openclose = close;
- selectstatus = YesSelect;
- }
- }
- /*****************选中工具******************/
- if( pDoc->m_tool == select )
- {
- for( int i = 0; i < m_array.GetLength(); i++ )
- {
- switch( m_array.operator [](i) )
- {
- case '1':
- {
- if(this->LineSelect(point))
- {
- selectstatus = YesSelect;
- pDoc->m_shape = line;
- blnselecttrigon = false;
- blnselect = false; //删除
- }
- break;
- }
- case '2':
- {
- //(CLine *)pDoc->m_shapetool->Select(pDC,point);
- break;
- }
- case '3':
- {
- if(RectSelect(point))
- {
- selectstatus = YesSelect;
- pDoc->m_shape = rect;
- blnselecttrigon = false;
- blnselect = false; //删除
- }
- break;
- }
- case '4':
- {
- if(TrigonSelect(point))
- {
- selectstatus = YesSelect;
- pDoc->m_shape = trigon;
- blnselecttrigon = false;
- blnselect = false; //删除
- }
- break;
- }
- case '5':
- {
- if(this->PolygonSelect(point))
- {
- selectstatus = YesSelect;
- pDoc->m_shape = polygon;
- blnselecttrigon = false;
- blnselect = false; //删除
- }
- break;
- }
- case '6':
- {
- //(CCircle *)pDoc->m_shapetool->Select(pDC,point);
- if(this->CircleSelect(point))
- {
- pDoc->m_shape = circle;
- blnselecttrigon = false;
- selectstatus = YesSelect;
- blnselect = false; //删除
- }
- break;
- }
- case '7':
- {
- //(CCircle *)pDoc->m_shapetool->Select(pDC,point);
- if(this->EllipseSelect(point))
- {
- pDoc->m_shape = ellipse;
- blnselecttrigon = false;
- selectstatus = YesSelect;
- blnselect = false; //删除
- }
- break;
- }
- }
- }
- }
- /**********************画图工具绘画***************************/
- if( this->m_state == first && pDoc->m_tool != select && pDoc->m_tool != move &&
- pDoc->m_tool != zoom && pDoc->m_tool != msl && pDoc->m_tool != eddy )
- {
- switch( pDoc->m_shape )
- {
- case rect:
- {
- this->m_openclose = open;
- pDoc->m_shapetool = new CRectangle;
- pDoc->m_shapetool->OnLbuttondown(pDC,point);
- pDoc->m_shapearray.Add(((CObject*)pDoc->m_shapetool));
- m_rectanglearray.Add(pDoc->m_shapetool->GetPosBegin());
- m_array.Insert(m_array.GetLength(),"3");
- break;
- }
- case trigon:
- {
- this->m_openclose = open;
- if( blnfrist )
- {
- pDoc->m_shapetool = new CTrigon;
- pDoc->m_shapetool->OnLbuttondown(pDC,point);
- pDoc->m_shapearray.Add(((CObject*)pDoc->m_shapetool));
- m_trigonarray.Add(pDoc->m_shapetool->GetPosBegin());
- m_array.Insert(m_array.GetLength(),"4");
- count++;
- blnfrist = false;
- }
- else
- {
- if( count == 1 )
- {
- m_trigonarray.Add(pDoc->m_shapetool->GetPosCenter());
- }
- else
- {
- m_trigonarray.Add(pDoc->m_shapetool->GetPosEnd());
- }
- pDoc->m_shapetool->OnLbuttondown(pDC,point);
- count++;
- }
- break;
- }
- case line:
- {
- this->m_openclose = open;
- pDoc->m_shapetool = new CLine;
- pDoc->m_shapetool->OnLbuttondown(pDC,point);
- pDoc->m_shapearray.Add(((CObject*)pDoc->m_shapetool));
- m_linearray.Add(pDoc->m_shapetool->GetPosBegin());
- m_array.Insert(m_array.GetLength(),"1");
- break;
- }
- case linedown:
- {
- this->m_openclose = open;
- pDoc->m_shapetool = new CLine;
- pDoc->m_shapetool->OnLbuttondown(pDC,point);
- pDoc->m_shapearray.Add(((CObject*)pDoc->m_shapetool));
- m_linedownarray.Add(pDoc->m_shapetool->GetPosBegin());
- m_array.Insert(m_array.GetLength(),"2");
- break;
- }
- case polygon:
- {
- this->m_openclose = open;
- pDoc->m_shapetool = new CPolygon;
- pDoc->m_shapetool->OnLbuttondown(pDC,point);
- m_polygonarray.Add(pDoc->m_shapetool->GetPosBegin());
- m_array.Insert(m_array.GetLength(),"5");
- break;
- }
- case circle:
- {
- this->m_openclose = open;
- pDoc->m_shapetool = new CCircle;
- pDoc->m_shapetool->OnLbuttondown(pDC,point);
- m_circlearray.Add(pDoc->m_shapetool->GetPosBegin());
- m_array.Insert(m_array.GetLength(),"6");
- break;
- }
- case ellipse:
- {
- this->m_openclose = open;
- pDoc->m_shapetool = new CEllipse;
- pDoc->m_shapetool->OnLbuttondown(pDC,point);
- m_ellipsearray.Add(pDoc->m_shapetool->GetPosBegin());
- m_array.Insert(m_array.GetLength(),"7");
- break;
- }
- }
- }
- /*******************移动工具************************/
- if( pDoc->m_tool == move )
- {
- if( blnselecttrigon == false )
- {
- selectstatus = YesSelect;
- this->m_openclose = close;
- }
- else if(TrigonSelect(point))
- {
- blnselecttrigon = false;
- selectstatus = YesSelect;
- this->m_openclose = close;
- }
- else if( this->PolygonSelect(point) )
- {
- blnselecttrigon = false;
- this->m_openclose = close;
- selectstatus = YesSelect;
- }
- else if( this->RectSelect(point) )
- {
- blnselecttrigon = false;
- this->m_openclose = close;
- selectstatus = YesSelect;
- }
- else if( this->CircleSelect(point) )
- {
- blnselecttrigon = false;
- this->m_openclose = close;
- selectstatus = YesSelect;
- }
- else if( this->EllipseSelect(point) )
- {
- blnselecttrigon = false;
- this->m_openclose = close;
- selectstatus = YesSelect;
- }
- else if( this->LineSelect(point) )
- {
- blnselecttrigon = false;
- this->m_openclose = close;
- selectstatus = YesSelect;
- }
- }
- if( count == 3 ) //三角形
- {
- blnfrist = true;
- this->m_state = second;
- count = 0;
- }
- /*********************存储数据****************************/
- if( this->m_state == second )
- {
- switch( pDoc->m_shape )
- {
- case line:
- {
- m_linearray.Add(pDoc->m_shapetool->GetPosEnd());
- break;
- }
- case rect:
- {
- m_rectanglearray.Add(pDoc->m_shapetool->GetPosEnd());
- break;
- }
- case polygon:
- {
- m_polygonarray.Add(pDoc->m_shapetool->GetPosEnd());
- m_polygonarraypoint.Add(pDoc->m_shapetool->GetPosBorder());
- break;
- }
- case circle:
- {
- m_circlearray.Add(pDoc->m_shapetool->GetPosEnd());
- break;
- }
- case ellipse:
- {
- m_ellipsearray.Add(pDoc->m_shapetool->GetPosCenter());
- m_ellipsearray.Add(pDoc->m_shapetool->GetPosEnd());
- break;
- }
- }
- this->m_openclose = close;
- this->m_state = first;
- }
- /************************字体工具进行写字***********************************/
- if( pDoc->m_shape == font )
- {
- if( bln == true )
- {
- int m_num = m_rectarray.GetSize();
- if( m_num > 0 )
- {
- CRect rect = m_rectarray.operator [](m_num - 1);
- pDoc->m_text.LostTextFouce(pDC,rect);
- }
- CRect recttext(point.x+55,point.y+60,point.x+140,point.y+80);
- m_textarray.Add(recttext);
- CRect rectrect(point.x,point.y,point.x+90,point.y+22);
- m_rectarray.Add(rectrect);
- pDoc->m_text.draw(recttext);
- pDoc->m_text.SetTextFouce(pDC,rectrect);
- //pDoc->m_text.SetFouceRect(rectrect);
- //pDoc->m_text.SetFouceTextRect(rectrect);
- bln = false;
- }
- else
- {
- CRect rect = m_rectarray.operator [](m_rectarray.GetSize() - 1);
- pDoc->m_text.LostTextFouce(pDC,rect);
- bln = true;
- }
- }
- /*********************选中字体****************************/
- if( pDoc->m_tool == arrow )
- {
- if( m_rectarray.GetSize() > 0 )
- {
- CPoint m_point;
- m_point.x = point.x ;
- m_point.y = point.y ;
- for( int i = 0; i < m_rectarray.GetSize(); i++ )
- {
- CRect rect = m_rectarray.operator [](i);
- if( rect.PtInRect(m_point) )
- {
- CRect textrect = m_textarray.operator [](i);
- selectrect = rect;
- index = i;
- blnselect = false; //判断是否被选取
- pDoc->m_text.LostTextFouce(pDC,pDoc->m_text.GetFouceText());
- pDoc->m_text.SetTextFouce(pDC,rect);
- pDoc->m_text.SetFouceRect(rect); //存取选取的框架的大小
- //pDoc->m_text.SetFouceTextRect(textrect);
- //pDoc->m_shape = font;
- break;
- }
- else
- {
- if( !blnselect )
- {
- pDoc->m_text.LostTextFouce(pDC,pDoc->m_text.GetFouceText());
- }
- }
- }
- }
- }
- CView::OnLButtonDown(nFlags, point);
- }
- void CCAD2006View::OnRButtonDown(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
- CCAD2006Doc* pDoc = GetDocument();
- CDC *pDC = GetDC();
- this->m_openclose = close;
- pDoc->m_tool = select;
- pDoc->m_shape = shape;
- // pDoc->m_text.DeleteText(pDC,1,rect);
- CView::OnRButtonDown(nFlags, point);
- }
- void CCAD2006View::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
- {
- // TODO: Add your message handler code here and/or call default
- CCAD2006Doc* pDoc = GetDocument();
- CDC *pDC = GetDC();
- if( nChar == 46 && blnselect == false )
- {
- switch( pDoc->m_shape )
- {
- case rect:
- {
- // pDoc->m_shapetool = new CRectangle;
- pDoc->m_shapetool->Delete(pDC);
- m_rectanglearray.RemoveAt(shapeindex,1);
- m_rectanglearray.RemoveAt(shapeindex,1);
- blnselect = true;
- break;
- }
- case font:
- {
- //pDoc->m_shapetool = new CRectangle;
- pDoc->m_text.DeleteText(pDC,index,selectrect);
- m_rectarray.RemoveAt(index);
- m_textarray.RemoveAt(index);
- blnselect = true;
- break;
- }
- case trigon:
- {
- // pDoc->m_shapetool = new CTrigon;
- pDoc->m_shapetool->Delete(pDC);
- m_trigonarray.RemoveAt(shapeindex,1);
- m_trigonarray.RemoveAt(shapeindex,1);
- m_trigonarray.RemoveAt(shapeindex,1);
- blnselect = true;
- break;
- }
- case polygon:
- {
- // pDoc->m_shapetool = new CPolygon;
- pDoc->m_shapetool->Delete(pDC);
- m_polygonarray.RemoveAt(shapeindex,1);
- m_polygonarray.RemoveAt(shapeindex,1);
- m_polygonarraypoint.RemoveAt(shapeindex/2,1);
- blnselect = true;
- break;
- }
- case circle:
- {
- pDoc->m_shapetool->Delete(pDC);
- m_circlearray.RemoveAt(shapeindex,1);
- m_circlearray.RemoveAt(shapeindex,1);
- blnselect = true;
- break;
- }
- case ellipse:
- {
- pDoc->m_shapetool->Delete(pDC);
- m_ellipsearray.RemoveAt(shapeindex,1);
- m_ellipsearray.RemoveAt(shapeindex,1);
- blnselect = true;
- break;
- }
- case line:
- {
- pDoc->m_shapetool->Delete(pDC);
- m_linearray.RemoveAt(shapeindex,1);
- m_linearray.RemoveAt(shapeindex,1);
- blnselect = true;
- break;
- }
- }
- switch( pDoc->m_tool )
- {
- case arrow:
- {
- pDoc->m_text.DeleteText(pDC,index,selectrect);
- m_rectarray.RemoveAt(index);
- m_textarray.RemoveAt(index);
- blnselect = true;
- break;
- }
- }
- }
- if( nChar == VK_CONTROL || nChar == 90 )
- {
- int i = pDoc->m_shapearray.GetSize();
- if( i )
- {
- CShape* temp = (CShape*)pDoc->m_shapearray.operator [](i - 1);
- pDoc->m_shapearray.RemoveAt(i - 1);
- delete temp;
- CRect rect;
- this->GetClientRect(&rect);
- pDC->InvertRect(rect);
- pDoc->m_shape = shape;
- pDoc->m_tool = arrow;
- }
- }
- CView::OnKeyDown(nChar, nRepCnt, nFlags);
- }
- void CCAD2006View::OnLButtonUp(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
- CCAD2006Doc* pDoc = GetDocument();
- CDC *pDC = GetDC();
- /******************旋转工具***************************/
- if( pDoc->m_tool == eddy )
- {
- switch( pDoc->m_shape )
- {
- case trigon:
- {
- //selectstatus = NoSelect;
- pDoc->m_shapetool->Update(pDC); //去小圈再动
- m_trigonarray.operator [](shapeindex) = pDoc->m_shapetool->GetPosBegin();
- m_trigonarray.operator [](shapeindex + 1) = pDoc->m_shapetool->GetPosCenter();
- m_trigonarray.operator [](shapeindex + 2) = pDoc->m_shapetool->GetPosEnd();
- //pDoc->m_shapetool->Move(pDC,point);
- //delete pDoc->m_shapetool;
- blnselecttrigon = true;
- break;
- }
- case polygon:
- {
- //selectstatus = NoSelect;
- pDoc->m_shapetool->Update(pDC); //去小圈再动
- m_polygonarray.operator [](shapeindex) = pDoc->m_shapetool->GetPosBegin();
- m_polygonarray.operator [](shapeindex + 1) = pDoc->m_shapetool->GetPosEnd();
- m_polygonarraypoint.operator [](shapeindex/2) = pDoc->m_shapetool->GetPosBorder();
- //pDoc->m_shapetool->Move(pDC,point);
- //delete pDoc->m_shapetool;
- blnselecttrigon = true;
- break;
- }
- }
- }
- /*****************镜像工具***********************/
- if( pDoc->m_tool == msl )
- {
- switch( pDoc->m_shape )
- {
- case rect:
- {
- if(mirrorstatus == YesMirror)
- {
- mirrorstatus = NoMirror;
- pDoc->m_shapetool->Update(pDC);
- }
- break;
- }
- case trigon:
- {
- if(mirrorstatus == YesMirror)
- {
- mirrorstatus = NoMirror;
- m_trigonarray.Add(pDoc->m_shapetool->GetPosBegin());
- m_trigonarray.Add(pDoc->m_shapetool->GetPosCenter());
- m_trigonarray.Add(pDoc->m_shapetool->GetPosEnd());
- pDoc->m_shapetool->Update(pDC);
- }
- break;
- }
- case polygon:
- {
- if(mirrorstatus == YesMirror)
- {
- mirrorstatus = NoMirror;
- pDoc->m_shapetool->Update(pDC);
- }
- break;
- }
- case circle:
- {
- if(mirrorstatus == YesMirror)
- {
- m_circlearray.Add(pDoc->m_shapetool->GetPosBegin());
- m_circlearray.Add(pDoc->m_shapetool->GetPosEnd());
- mirrorstatus = NoMirror;
- pDoc->m_shapetool->Update(pDC);
- }
- break;
- }
- case line:
- {
- if(mirrorstatus == YesMirror)
- {
- m_linearray.Add(pDoc->m_shapetool->GetPosBegin());
- m_linearray.Add(pDoc->m_shapetool->GetPosEnd());
- mirrorstatus = NoMirror;
- pDoc->m_shapetool->Update(pDC);
- }
- break;
- }
- }
- }
- /******************拖动工具*******************/
- if( pDoc->m_tool == move && !blnselecttrigon )
- {
- switch( pDoc->m_shape )
- {
- case line:
- {
- selectstatus = NoSelect;
- pDoc->m_shapetool->Update(pDC); //去小圈再动
- m_linearray.operator [](shapeindex) = pDoc->m_shapetool->GetPosBegin();
- m_linearray.operator [](shapeindex + 1) = pDoc->m_shapetool->GetPosEnd();
- pDoc->m_shapetool->Move(pDC,point);
- blnselecttrigon = true;
- break;
- }
- case trigon:
- {
- selectstatus = NoSelect;
- pDoc->m_shapetool->Update(pDC); //去小圈再动
- m_trigonarray.operator [](shapeindex) = pDoc->m_shapetool->GetPosBegin();
- m_trigonarray.operator [](shapeindex + 1) = pDoc->m_shapetool->GetPosCenter();
- m_trigonarray.operator [](shapeindex + 2) = pDoc->m_shapetool->GetPosEnd();
- pDoc->m_shapetool->Move(pDC,point);
- //delete pDoc->m_shapetool;
- blnselecttrigon = true;
- break;
- }
- case polygon:
- {
- selectstatus = NoSelect;
- pDoc->m_shapetool->Update(pDC); //去小圈再动
- m_polygonarray.operator [](shapeindex) = pDoc->m_shapetool->GetPosBegin();
- m_polygonarray.operator [](shapeindex + 1) = pDoc->m_shapetool->GetPosEnd();
- m_polygonarraypoint.operator [](shapeindex/2) = pDoc->m_shapetool->GetPosBorder();
- pDoc->m_shapetool->Move(pDC,point);
- //delete pDoc->m_shapetool;
- blnselecttrigon = true;
- break;
- }
- case rect:
- {
- selectstatus = NoSelect;
- pDoc->m_shapetool->Update(pDC); //去小圈再动
- m_rectanglearray.operator [](shapeindex) = pDoc->m_shapetool->GetPosBegin();
- m_rectanglearray.operator [](shapeindex + 1) = pDoc->m_shapetool->GetPosEnd();
- //pDoc->m_shapetool->Move(pDC,point);
- //delete pDoc->m_shapetool;
- blnselecttrigon = true;
- break;
- }
- case circle:
- {
- selectstatus = NoSelect;
- //pDoc->m_shapetool->Update(pDC); //去小圈再动
- m_circlearray.operator [](shapeindex) = pDoc->m_shapetool->GetPosBegin();
- m_circlearray.operator [](shapeindex + 1) = pDoc->m_shapetool->GetPosEnd();
- //pDoc->m_shapetool->Move(pDC,point);
- //delete pDoc->m_shapetool;
- blnselecttrigon = true;
- break;
- }
- case ellipse:
- {
- selectstatus = NoSelect;
- //pDoc->m_shapetool->Update(pDC); //去小圈再动
- m_ellipsearray.operator [](shapeindex) = pDoc->m_shapetool->GetPosBegin();
- m_ellipsearray.operator [](shapeindex + 1) = pDoc->m_shapetool->GetPosCenter();
- m_ellipsearray.operator [](shapeindex + 2) = pDoc->m_shapetool->GetPosEnd();
- //pDoc->m_shapetool->Move(pDC,point);
- //delete pDoc->m_shapetool;
- blnselecttrigon = true;
- break;
- }
- }
- }
- /*********************缩放工具*************************/
- if( pDoc->m_tool == zoom && !blnselecttrigon )
- {
- switch( pDoc->m_shape )
- {
- case trigon:
- {
- selectstatus = NoSelect;
- pDoc->m_shapetool->Update(pDC); //去小圈再动
- m_trigonarray.operator [](shapeindex) = pDoc->m_shapetool->GetPosBegin();
- m_trigonarray.operator [](shapeindex + 1) = pDoc->m_shapetool->GetPosCenter();
- m_trigonarray.operator [](shapeindex + 2) = pDoc->m_shapetool->GetPosEnd();
- //delete pDoc->m_shapetool;
- blnselecttrigon = true;
- break;
- }
- case polygon:
- {
- selectstatus = NoSelect;
- pDoc->m_shapetool->Update(pDC); //去小圈再动
- m_polygonarray.operator [](shapeindex) = pDoc->m_shapetool->GetPosBegin();
- m_polygonarray.operator [](shapeindex + 1) = pDoc->m_shapetool->GetPosEnd();
- m_polygonarraypoint.operator [](shapeindex/2) = pDoc->m_shapetool->GetPosBorder();
- //delete pDoc->m_shapetool;
- blnselecttrigon = true;
- break;
- }
- case rect:
- {
- selectstatus = NoSelect;
- pDoc->m_shapetool->Update(pDC); //去小圈再动
- m_rectanglearray.operator [](shapeindex) = pDoc->m_shapetool->GetPosBegin();
- m_rectanglearray.operator [](shapeindex + 1) = pDoc->m_shapetool->GetPosEnd();
- //delete pDoc->m_shapetool;
- blnselecttrigon = true;
- break;
- }
- case circle:
- {
- selectstatus = NoSelect;
- // pDoc->m_shapetool->Update(pDC); //去小圈再动
- m_circlearray.operator [](shapeindex) = pDoc->m_shapetool->GetPosBegin();
- m_circlearray.operator [](shapeindex + 1) = pDoc->m_shapetool->GetPosEnd();
- //delete pDoc->m_shapetool;
- blnselecttrigon = true;
- break;
- }
- case ellipse:
- {
- selectstatus = NoSelect;
- // pDoc->m_shapetool->Update(pDC); //去小圈再动
- m_ellipsearray.operator [](shapeindex) = pDoc->m_shapetool->GetPosBegin();
- m_ellipsearray.operator [](shapeindex + 1) = pDoc->m_shapetool->GetPosCenter();
- m_ellipsearray.operator [](shapeindex + 2) = pDoc->m_shapetool->GetPosEnd();
- //delete pDoc->m_shapetool;
- blnselecttrigon = true;
- break;
- }
- case line:
- {
- selectstatus = NoSelect;
- // pDoc->m_shapetool->Update(pDC); //去小圈再动
- m_linearray.operator [](shapeindex) = pDoc->m_shapetool->GetPosBegin();
- m_linearray.operator [](shapeindex + 1) = pDoc->m_shapetool->GetPosEnd();
- //delete pDoc->m_shapetool;
- blnselecttrigon = true;
- break;
- }
- }
- }
- CView::OnLButtonUp(nFlags, point);
- }
- bool CCAD2006View::TrigonSelect(CPoint point)
- {
- CCAD2006Doc* pDoc = GetDocument();
- CDC *pDC = GetDC();
- pDoc->m_shapetool = new CTrigon;
- for( int j = 0; j < m_trigonarray.GetSize() ; j+=3 )
- {
- pDoc->m_shapetool->SetPosBegin(m_trigonarray.operator [](j));
- pDoc->m_shapetool->SetPosCenter(m_trigonarray.operator [](j+1));
- pDoc->m_shapetool->SetPosEnd(m_trigonarray.operator [](j+2));
- if(pDoc->m_shapetool->Select(pDC,point))
- {
- shapeindex = j;
- return true;
- }
- }
- delete pDoc->m_shapetool;
- return false;
- }
- bool CCAD2006View::LineSelect(CPoint point)
- {
- CCAD2006Doc* pDoc = GetDocument();
- CDC *pDC = GetDC();
- pDoc->m_shapetool = new CLine;
- for( int j = 0; j < m_linearray.GetSize() ; j+=2 )
- {
- pDoc->m_shapetool->SetPosBegin(m_linearray.operator [](j));
- pDoc->m_shapetool->SetPosEnd(m_linearray.operator [](j+1));
- if((CLine *)pDoc->m_shapetool->Select(pDC,point))
- {
- shapeindex = j;
- return true;
- }
- }
- delete pDoc->m_shapetool;
- return false;
- }
- bool CCAD2006View::CircleSelect(CPoint point)
- {
- CCAD2006Doc* pDoc = GetDocument();
- CDC *pDC = GetDC();
- pDoc->m_shapetool = new CCircle;
- for( int j = 0; j < m_circlearray.GetSize() ; j+=2 )
- {
- pDoc->m_shapetool->SetPosBegin(m_circlearray.operator [](j));
- pDoc->m_shapetool->SetPosEnd(m_circlearray.operator [](j+1));
- if((CCircle *)pDoc->m_shapetool->Select(pDC,point))
- {
- pDoc->m_shape = circle;
- shapeindex = j;
- return true;
- }
- }
- delete pDoc->m_shapetool;
- return false;
- }
- bool CCAD2006View::RectSelect(CPoint point)
- {
- CCAD2006Doc* pDoc = GetDocument();
- CDC *pDC = GetDC();
- pDoc->m_shapetool = new CRectangle;
- for( int j = 0; j < m_rectanglearray.GetSize() ; j+=2 )
- {
- pDoc->m_shapetool->SetPosBegin(m_rectanglearray.operator [](j));
- pDoc->m_shapetool->SetPosEnd(m_rectanglearray.operator [](j+1));
- if((CRectangle *)pDoc->m_shapetool->Select(pDC,point))
- {
- shapeindex = j;
- return true;
- }
- }
- delete pDoc->m_shapetool;
- return false;
- }
- bool CCAD2006View::PolygonSelect(CPoint point)
- {
- CCAD2006Doc* pDoc = GetDocument();
- CDC *pDC = GetDC();
- pDoc->m_shapetool = new CPolygon;
- for( int j = 0,i = 0; j < m_polygonarray.GetSize() ; j+=2,i++ )
- {
- pDoc->m_shapetool->SetPosBegin(m_polygonarray.operator [](j));
- pDoc->m_shapetool->SetPosEnd(m_polygonarray.operator [](j+1));
- pDoc->m_shapetool->SetPosBorder(m_polygonarraypoint.operator [](i));
- if((CPolygon *)pDoc->m_shapetool->Select(pDC,point))
- {
- shapeindex = j;
- return true;
- }
- }
- delete pDoc->m_shapetool;
- return false;
- }
- bool CCAD2006View::EllipseSelect(CPoint point)
- {
- CCAD2006Doc* pDoc = GetDocument();
- CDC *pDC = GetDC();
- pDoc->m_shapetool = new CEllipse;
- for( int j = 0; j < m_ellipsearray.GetSize() ; j+=3 )
- {
- pDoc->m_shapetool->SetPosBegin(m_ellipsearray.operator [](j));
- pDoc->m_shapetool->SetPosCenter(m_ellipsearray.operator [](j+1));
- pDoc->m_shapetool->SetPosEnd(m_ellipsearray.operator [](j+2));
- if((CEllipse *)pDoc->m_shapetool->Select(pDC,point))
- {
- pDoc->m_shape = ellipse;
- shapeindex = j;
- return true;
- }
- }
- delete pDoc->m_shapetool;
- return false;
- }
- bool CCAD2006View::ZoomTrigonSelect(CPoint point)
- {
- CCAD2006Doc* pDoc = GetDocument();
- CDC *pDC = GetDC();
- pDoc->m_shapetool = new CTrigon;
- for( int j = 0; j < m_trigonarray.GetSize() ; j+=3 )
- {
- pDoc->m_shapetool->SetPosBegin(m_trigonarray.operator [](j));
- pDoc->m_shapetool->SetPosCenter(m_trigonarray.operator [](j+1));
- pDoc->m_shapetool->SetPosEnd(m_trigonarray.operator [](j+2));
- if((CTrigon *)pDoc->m_shapetool->SelectOnePt(pDC,point))
- {
- shapeindex = j;
- return true;
- }
- }
- delete pDoc->m_shapetool;
- return false;
- }
- bool CCAD2006View::ZoomPolygonSelect(CPoint point)
- {
- CCAD2006Doc* pDoc = GetDocument();
- CDC *pDC = GetDC();
- pDoc->m_shapetool = new CPolygon;
- for( int j = 0,i = 0; j < m_polygonarray.GetSize() ; j+=2,i++ )
- {
- pDoc->m_shapetool->SetPosBegin(m_polygonarray.operator [](j));
- pDoc->m_shapetool->SetPosEnd(m_polygonarray.operator [](j+1));
- pDoc->m_shapetool->SetPosBorder(m_polygonarraypoint.operator [](i));
- if((CPolygon *)pDoc->m_shapetool->Select(pDC,point))
- {
- shapeindex = j;
- return true;
- }
- }
- delete pDoc->m_shapetool;
- return false;
- }
- bool CCAD2006View::ZoomLineSelect(CPoint point)
- {
- CCAD2006Doc* pDoc = GetDocument();
- CDC *pDC = GetDC();
- pDoc->m_shapetool = new CLine;
- for( int j = 0,i = 0; j < m_linearray.GetSize() ; j+=2,i++ )
- {
- pDoc->m_shapetool->SetPosBegin(m_linearray.operator [](j));
- pDoc->m_shapetool->SetPosEnd(m_linearray.operator [](j+1));
- if((CLine *)pDoc->m_shapetool->SelectOnePt(pDC,point))
- {
- shapeindex = j;
- return true;
- }
- }
- delete pDoc->m_shapetool;
- return false;
- }
- void CCAD2006View::OnFileSave()
- {
- // TODO: Add your command handler code here
- CFile m_file;
- CString m_str;
- CString m_temp;
- int j = m_linearray.GetSize();
- for( int i = 0; i < m_array.GetLength(); i++ )
- {
- switch( m_array.operator [](i) )
- {
- case '1':
- {
- static int m_line = 0;
- CPoint point1 = m_linearray.operator [](m_line);
- CPoint point2 = m_linearray.operator [](m_line + 1);
- m_temp.Format("*%c,%d,%d,%d,%d",m_array.operator [](i),
- point1.x,point1.y,point2.x,point2.y);
- m_str.Insert(m_str.GetLength(),m_temp);
- m_line += 2;
- break;
- }
- case '2':
- {
- /* static int m_linedown = 0;
- m_temp.Format("%s,%d,%d",m_array.operator [](i),
- m_linedownarray.operator [](m_linedown).x,m_linedownarray.operator [](m_linedown + 1).y)
- m_str.Insert(m_str.GetLength(),m_temp);
- m_linedown += 2;*/
- break;
- }
- case '3':
- {
- static int m_rect = 0;
- m_temp.Format("*%c,%d,%d,%d,%d",m_array.operator [](i),
- m_rectanglearray.operator [](m_rect).x,m_rectanglearray.operator [](m_rect).y,
- m_rectanglearray.operator [](m_rect + 1).x,m_rectanglearray.operator [](m_rect + 1).y);
- m_str.Insert(m_str.GetLength(),m_temp);
- m_rect += 2;
- break;
- }
- case '4':
- {
- static int m_trigon = 0;
- m_temp.Format("*%c,%d,%d,%d,%d,%d,%d",m_array.operator [](i),
- m_trigonarray.operator [](m_trigon).x,m_trigonarray.operator [](m_trigon).y,
- m_trigonarray.operator [](m_trigon + 1).x,m_trigonarray.operator [](m_trigon + 1).y,
- m_trigonarray.operator [](m_trigon + 2).x,m_trigonarray.operator [](m_trigon + 2).y);
- m_str.Insert(m_str.GetLength(),m_temp);
- m_trigon += 3;
- break;
- }
- case '5':
- {
- /* static int m_rect = 0;
- m_temp.Format("%s,%d,%d",m_array.operator [](i),
- m_polygonarray.operator [](m_rect).x,m_polygonarray.operator [](m_rect + 1).y)
- m_str.Insert(m_str.GetLength(),m_temp);
- m_rect += 2;*/
- break;
- }
- case '6':
- {
- static int m_circle = 0;
- m_temp.Format("*%c,%d,%d,%d,%d",m_array.operator [](i),
- m_circlearray.operator [](m_circle).x,m_circlearray.operator [](m_circle).y,
- m_circlearray.operator [](m_circle + 1).x,m_circlearray.operator [](m_circle + 1).y);
- m_str.Insert(m_str.GetLength(),m_temp);
- m_circle += 2;
- break;
- }
- case '7':
- {
- static int m_ellipse = 0;
- m_temp.Format("*%c,%d,%d,%d,%d",m_array.operator [](i),
- m_ellipsearray.operator [](m_ellipse).x,m_ellipsearray.operator [](m_ellipse).y,
- m_ellipsearray.operator [](m_ellipse + 1).x,m_ellipsearray.operator [](m_ellipse + 1).y);
- m_str.Insert(m_str.GetLength(),m_temp);
- m_ellipse += 2;
- break;
- }
- }
- }
- m_file.Open("CAD.txt",CFile::modeCreate | CFile::modeWrite);
- m_file.Write(m_str.operator LPCTSTR(),m_str.GetLength());
- }
- void CCAD2006View::OnFileOpen()
- {
- // TODO: Add your command handler code here
- CFileDialog m_dialog(true);
- m_dialog.m_ofn.lpstrFilter = "文本文件(*.txt) *.txt 所有类型(*.*) *.* ";
- CFile m_file;
- if(m_dialog.DoModal() == IDOK )
- {
- m_file.Open(m_dialog.GetFileName(),CFile::modeRead);
- m_file.Read((void *)m_allshapepoint.operator LPCTSTR(),m_file.GetLength());
- }
- ShowShape(m_allshapepoint);
- }
- void CCAD2006View::ShowShape(CString str)
- {
- CCAD2006Doc* pDoc = GetDocument();
- CDC *pDC = GetDC();
- CString m_tempshape;
- CString m_temp;
- CString m_point1,m_point2,m_point3,m_point4,m_point5,m_point6;
- int i = 1;
- int j ;
- m_array = "";
- while( 1 == 1 )
- {
- j = ::AfxExtractSubString(m_tempshape,str.operator LPCTSTR(),i,'*');
- AfxExtractSubString(m_temp,m_tempshape.operator LPCTSTR(),0,',');
- AfxExtractSubString(m_point1,m_tempshape.operator LPCTSTR(),1,',');
- AfxExtractSubString(m_point2,m_tempshape.operator LPCTSTR(),2,',');
- AfxExtractSubString(m_point3,m_tempshape.operator LPCTSTR(),3,',');
- AfxExtractSubString(m_point4,m_tempshape.operator LPCTSTR(),4,',');
- CPoint point1(atoi(m_point1.operator LPCTSTR()),atoi(m_point2.operator LPCTSTR()));
- CPoint point2(atoi(m_point3.operator LPCTSTR()),atoi(m_point4.operator LPCTSTR()));
- if( j == 0 )
- {
- break;
- }
- switch( m_temp.operator [](0) )
- {
- case '1':
- {
- pDC->MoveTo(point1.x,point1.y);
- pDC->LineTo(point2.x,point2.y);
- m_linearray.Add(point1);
- m_linearray.Add(point2);
- m_array.Insert(m_array.GetLength(),'1');
- break;
- }
- case '2':
- {
- break;
- }
- case '3':
- {
- pDC->Rectangle(point1.x,point1.y,point2.x,point2.y);
- m_rectanglearray.Add(point1);
- m_rectanglearray.Add(point2);
- m_array.Insert(m_array.GetLength(),'3');
- break;
- }
- case '4':
- {
- AfxExtractSubString(m_point5,m_tempshape.operator LPCTSTR(),5,',');
- AfxExtractSubString(m_point6,m_tempshape.operator LPCTSTR(),6,',');
- CPoint point3(atoi(m_point5.operator LPCTSTR()),atoi(m_point6.operator LPCTSTR()));
- pDC->MoveTo(point1);
- pDC->LineTo(point2);
- pDC->LineTo(point3);
- pDC->LineTo(point1);
- m_trigonarray.Add(point1);
- m_trigonarray.Add(point2);
- m_trigonarray.Add(point3);
- m_array.Insert(m_array.GetLength(),'4');
- break;
- }
- case '5':
- {
- break;
- }
- case '6':
- {
- pDC->Ellipse(point1.x - point2.x,point1.y - point2.x,point1.x + point2.x,point1.y + point2.x);
- m_circlearray.Add(point1);
- m_circlearray.Add(point2);
- m_array.Insert(m_array.GetLength(),'6');
- break;
- }
- case '7':
- {
- pDC->Ellipse(point2.x,point2.y,point1.x,point1.y);
- m_ellipsearray.Add(point1);
- m_ellipsearray.Add(point2);
- m_array.Insert(m_array.GetLength(),'7');
- break;
- }
- }
- i++;
- }
- }