MiniCADView.cpp
上传用户:netltd
上传日期:2013-02-12
资源大小:7234k
文件大小:20k
- // MiniCADView.cpp : implementation of the CMiniCADView class
- //
- #include "stdafx.h"
- #include "MiniCADView.h"
- #include "DrawingAttribute.h"
- #include "SelectParameterDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMiniCADView
- IMPLEMENT_DYNCREATE(CMiniCADView, CScrollView)
- BEGIN_MESSAGE_MAP(CMiniCADView, CScrollView)
- //{{AFX_MSG_MAP(CMiniCADView)
- ON_COMMAND(ID_DRAW_CIRCLE, OnDrawCircle)
- ON_COMMAND(ID_DRAW_LINE, OnDrawLine)
- ON_WM_LBUTTONDOWN()
- ON_WM_RBUTTONDOWN()
- ON_WM_MOUSEMOVE()
- ON_WM_VSCROLL()
- ON_WM_DESTROY()
- ON_WM_HSCROLL()
- ON_COMMAND(ID_VIEW_ZOOMOUT, OnZoomout)
- ON_COMMAND(ID_VIEW_ZOOMIN, OnZoomin)
- ON_CBN_SELCHANGE(IDC_COLOR, OnSelchangeColor)
- ON_CBN_SELCHANGE(IDC_LINESTYLE, OnSelchangeLinestyle)
- ON_COMMAND(ID_DRAW_RECT, OnDrawRect)
- ON_WM_SIZE()
- ON_COMMAND(ID_VIEW_REDRAW, OnViewRedraw)
- ON_COMMAND(ID_DRAW_SELECT, OnDrawSelect)
- ON_COMMAND(ID_EDIT_UNDO, OnEditUndo)
- ON_COMMAND(ID_EDIT_REDO, OnEditRedo)
- ON_COMMAND(ID_DRAW_ARC, OnDrawArc)
- ON_COMMAND(ID_DRAW_TEXT, OnDrawText)
- ON_UPDATE_COMMAND_UI(ID_DRAW_SELECT, OnUpdateDrawSelect)
- ON_UPDATE_COMMAND_UI(ID_DRAW_LINE, OnUpdateDrawLine)
- ON_UPDATE_COMMAND_UI(ID_DRAW_RECT, OnUpdateDrawRect)
- ON_UPDATE_COMMAND_UI(ID_DRAW_CIRCLE, OnUpdateDrawCircle)
- ON_UPDATE_COMMAND_UI(ID_DRAW_ARC, OnUpdateDrawArc)
- ON_UPDATE_COMMAND_UI(ID_DRAW_TEXT, OnUpdateDrawText)
- ON_UPDATE_COMMAND_UI(ID_EDIT_REDO, OnUpdateEditRedo)
- ON_UPDATE_COMMAND_UI(ID_EDIT_UNDO, OnUpdateEditUndo)
- ON_UPDATE_COMMAND_UI(ID_CHANGE_DELETE, OnUpdateChangeDelete)
- ON_WM_ERASEBKGND()
- ON_CBN_SELCHANGE(IDC_FILESIZE, OnSelchangeFilesize)
- ON_COMMAND(ID_DRAW_MULTILINE, OnDrawMultiline)
- ON_COMMAND(ID_DRAW_POLYGON, OnDrawPolygon)
- ON_COMMAND(ID_DRAW_ELLIPSE, OnDrawEllipse)
- ON_COMMAND(ID_MODIFY_DELETE, OnModifyDelete)
- ON_COMMAND(ID_MODIFY_COPY, OnModifyCopy)
- ON_COMMAND(ID_MODIFY_CUT, OnModifyCut)
- ON_COMMAND(ID_MODIFY_CUTTOANGLE, OnModifyCuttoangle)
- ON_COMMAND(ID_MODIFY_LENGTHENTO, OnModifyLengthento)
- ON_COMMAND(ID_MODIFY_JOIN, OnModifyJoin)
- ON_COMMAND(ID_MODIFY_MIRROR, OnModifyMirror)
- ON_COMMAND(ID_MODIFY_VERTICAL, OnModifyVertical)
- ON_COMMAND(ID_DRAW_DOT, OnDrawDot)
- ON_COMMAND(ID_DRAW_CURVE, OnDrawCurve)
- ON_COMMAND(ID_MODIFY_MOVE, OnModifyMove)
- ON_COMMAND(ID_MODIFY_ROTATE, OnModifyRotate)
- ON_COMMAND(ID_DRAW_DEFINELINE, OnDrawDefineline)
- ON_COMMAND(ID_MODIFY_EXCURSION, OnModifyExcursion)
- ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
- ON_COMMAND(ID_EDIT_CUT, OnEditCut)
- ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
- ON_COMMAND(ID_FORMAT_DRAWINGATTRIBUTE, OnFormatDrawingAttribute)
- ON_COMMAND(ID_TOOL_SELECT, OnToolSelect)
- //}}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()
- /////////////////////////////////////////////////////////////////////////////
- // CMiniCADView construction/destruction
- CMiniCADView::CMiniCADView()
- {
- pApp = (CMiniCADApp*)AfxGetApp();
- pMainWnd = (CMainFrame*)pApp->m_pMainWnd;
- }
-
- CMiniCADView::~CMiniCADView()
- {
- }
- BOOL CMiniCADView::PreCreateWindow(CREATESTRUCT& cs)
- {
- cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW, 0 ,(HBRUSH)::GetStockObject(WHITE_BRUSH), 0);
- return CView::PreCreateWindow(cs);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMiniCADView printing
- BOOL CMiniCADView::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // default preparation
- return DoPreparePrinting(pInfo);
- }
- void CMiniCADView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
-
- }
- void CMiniCADView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMiniCADView diagnostics
- #ifdef _DEBUG
- void CMiniCADView::AssertValid() const
- {
- CView::AssertValid();
- }
- void CMiniCADView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
- CMiniCADDoc* CMiniCADView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMiniCADDoc)));
- return (CMiniCADDoc*)m_pDocument;
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMiniCADView message handlers
- void CMiniCADView::OnInitialUpdate()
- {
- CScrollView::OnInitialUpdate();
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- CClientDC dc(this);
-
- //在MDI子框架上显示标题,标题为图纸名
- CChildFrame* pChildWnd = (CChildFrame*)pMainWnd->MDIGetActive();
- pChildWnd->SetWindowText(pDoc->FileInfo.Name);
-
- //初始化颜色复选框
- CComboBoxEx* ColorCombo = (CComboBoxEx*)pMainWnd->m_MyOptionBar.GetDlgItem(IDC_COLOR);
- ColorCombo->EnableWindow(TRUE);
- ColorCombo->SetCurSel(0);
- //初始化线形复选框
- CComboBoxEx* LineStyleCombo = (CComboBoxEx*)pMainWnd->m_MyOptionBar.GetDlgItem(IDC_LINESTYLE);
- LineStyleCombo->EnableWindow(TRUE);
- LineStyleCombo->SetCurSel(0);
- //初始化图纸尺寸复选框
- CComboBox* psizeCombo = (CComboBox*)pMainWnd->m_MyOptionBar.GetDlgItem(IDC_FILESIZE);
- psizeCombo->EnableWindow(TRUE);
- psizeCombo->SetCurSel(3);
- //初始化绘图工具条 、光标
- SetCursor(AfxGetApp()->LoadCursor(IDC_SELECTCUR));
-
- Proportion = 1.0;
- //根据图纸尺寸设置滚动条滚动区域(既客户区)
- size.cx = pDoc->FileInfo.size.cx + EXTRA_WIDTH * 2;
- size.cy = pDoc->FileInfo.size.cy + EXTRA_HIGTH * 2;
- SetScrollSizes(MM_TEXT, size);
- pDoc->m_ManageGraphObject.PageSize.cx = size.cx;
- pDoc->m_ManageGraphObject.PageSize.cy = size.cy;
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////
- //改变视图背景颜色
- void CMiniCADView::OnEraseBkgnd (CDC* pDC)
- {
- CBrush Brush (RGB (200, 255, 255));
- CBrush* pOldBrush = pDC->SelectObject (&Brush);
- CRect rcClip ;
- pDC->GetClipBox (&rcClip);
- pDC-> PatBlt (rcClip.left , rcClip.top , rcClip.Width ( ) , rcClip.Height ( ) , PATCOPY );
- pDC->SelectObject (pOldBrush );
- }
- // CMiniCADView drawing
- void CMiniCADView::OnDraw(CDC* pDC)
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- CBrush brush;
- RECT rect;
- RECT shadow;
- rect.left = EXTRA_WIDTH;
- rect.top = EXTRA_HIGTH;
- rect.right = rect.left + (long)(pDoc->FileInfo.size.cx * Proportion) + 1;
- rect.bottom = rect.top + (long)(pDoc->FileInfo.size.cy * Proportion) + 1;
- brush.CreateSolidBrush(RGB(192, 192, 192));
- shadow.left = rect.left + 3;
- shadow.top = rect.bottom;
- shadow.right = rect.right + 3;
- shadow.bottom = shadow.top + 3;
- pDC->FillRect(&shadow, &brush);
- shadow.left = rect.right;
- shadow.top = rect.top + 3;
- shadow.right = shadow.left + 3;
- shadow.bottom = rect.bottom + 3;
- pDC->FillRect(&shadow, &brush);
- pDC->Rectangle(&rect);
- //重画所有的图形对象
- pDoc->m_ManageGraphObject.RedrawAllObject(pDC);
- }
- //////////////////////////////////////////////////////////////////////////////////////////////
- void CMiniCADView::OnDrawSelect()
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- pDoc->CurrentCommand = DRAW_SELECT;
- }
- void CMiniCADView::OnDrawLine()
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- if(pDoc->m_ManageGraphObject.UnselectObject())
- Invalidate();
- pDoc->CurrentCommand = DRAW_LINE;
- }
- void CMiniCADView::OnDrawRect()
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- if(pDoc->m_ManageGraphObject.UnselectObject())
- Invalidate();
- pDoc->CurrentCommand = DRAW_RECT;
- }
- void CMiniCADView::OnDrawCircle()
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- if(pDoc->m_ManageGraphObject.UnselectObject())
- Invalidate();
- pDoc->CurrentCommand = DRAW_CIRCLE;
- }
- void CMiniCADView::OnDrawArc()
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- if(pDoc->m_ManageGraphObject.UnselectObject())
- Invalidate();
- pDoc->CurrentCommand = DRAW_ARC;
- }
- void CMiniCADView::OnDrawMultiline()
- {
-
- }
- void CMiniCADView::OnDrawPolygon()
- {
-
- }
- void CMiniCADView::OnDrawEllipse()
- {
-
- }
- void CMiniCADView::OnDrawDot()
- {
-
- }
- void CMiniCADView::OnDrawCurve()
- {
-
- }
- void CMiniCADView::OnDrawDefineline()
- {
- }
- void CMiniCADView::OnDrawText()
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- if(pDoc->m_ManageGraphObject.UnselectObject())
- Invalidate();
- pDoc->CurrentCommand = DRAW_TEXT;
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////
- void CMiniCADView::OnUpdateDrawLine(CCmdUI* pCmdUI)
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- pCmdUI->SetRadio(pDoc->CurrentCommand == DRAW_LINE);
- //继续传递当前命令
- pCmdUI->ContinueRouting();
- }
- void CMiniCADView::OnUpdateDrawRect(CCmdUI* pCmdUI)
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- pCmdUI->SetRadio(pDoc->CurrentCommand == DRAW_RECT);
- pCmdUI->ContinueRouting();
- }
- void CMiniCADView::OnUpdateDrawCircle(CCmdUI* pCmdUI)
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- pCmdUI->SetRadio(pDoc->CurrentCommand == DRAW_CIRCLE);
- pCmdUI->ContinueRouting();
- }
- void CMiniCADView::OnUpdateDrawArc(CCmdUI* pCmdUI)
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- pCmdUI->SetRadio(pDoc->CurrentCommand == DRAW_ARC);
- pCmdUI->ContinueRouting();
- }
- void CMiniCADView::OnUpdateDrawText(CCmdUI* pCmdUI)
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- pCmdUI->SetRadio(pDoc->CurrentCommand == DRAW_TEXT);
- pCmdUI->ContinueRouting();
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////
- //mouse message
- void CMiniCADView::OnLButtonDown(UINT nFlags, CPoint point)
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- CClientDC dc(this);
- OnPrepareDC(&dc);
- dc.DPtoLP(&point);
- if(pDoc->CurrentCommand > DRAW_MIN && pDoc->CurrentCommand < DRAW_MAX)
- {
- pDoc->m_ManageGraphObject.GetDC(&dc);
- pDoc->m_ManageGraphObject.OnLButtonDown(pDoc->CurrentCommand, point);
- }
-
-
- CScrollView::OnLButtonDown(nFlags, point);
- }
- void CMiniCADView::OnRButtonDown(UINT nFlags, CPoint point)
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- CClientDC dc(this);
- OnPrepareDC(&dc);
- dc.DPtoLP(&point);
- if(pDoc->CurrentCommand > DRAW_MIN && pDoc->CurrentCommand < DRAW_MAX)
- {
- pDoc->m_ManageGraphObject.GetDC(&dc);
- pDoc->CurrentCommand = pDoc->m_ManageGraphObject.OnRButtonDown(pDoc->CurrentCommand, point);
- }
- CScrollView::OnRButtonDown(nFlags, point);
- }
- void CMiniCADView::OnMouseMove(UINT nFlags, CPoint point)
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- char x[32];
- char y[32];
- int count;
-
- CClientDC dc(this);
- OnPrepareDC(&dc);
- dc.DPtoLP(&point);
- /*在状态栏中显示坐标*/
- count = sprintf(x, "%s", "X = ");
- sprintf(x + count, "%f", (float)(point.x - EXTRA_WIDTH) / Proportion);
- pMainWnd->m_wndStatusBar.SetPaneText(1, x, TRUE);
- count = sprintf(y, "%s", "Y = ");
- sprintf(y + count, "%f", (float)(size.cy - point.y - EXTRA_HIGTH) / Proportion);
- pMainWnd->m_wndStatusBar.SetPaneText(2, y, TRUE);
- /*在状态栏中显示坐标*/
- if(pDoc->CurrentCommand > DRAW_MIN && pDoc->CurrentCommand < DRAW_MAX)
- {
- pDoc->m_ManageGraphObject.GetDC(&dc);
- pDoc->m_ManageGraphObject.OnMouseMove(pDoc->CurrentCommand, point);
- }
- CScrollView::OnMouseMove(nFlags, point);
- }
- void CMiniCADView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- CClientDC dc(this);
- OnPrepareDC(&dc);
-
- if(pDoc->CurrentCommand > DRAW_MIN && pDoc->CurrentCommand < DRAW_MAX)
- {
- pDoc->m_ManageGraphObject.GetDC(&dc);
- pDoc->m_ManageGraphObject.OnScroll(pDoc->CurrentCommand);
- }
-
- CScrollView::OnVScroll(nSBCode, nPos, pScrollBar);
- }
- void CMiniCADView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- CClientDC dc(this);
- OnPrepareDC(&dc);
- if(pDoc->CurrentCommand > DRAW_MIN && pDoc->CurrentCommand < DRAW_MAX)
- {
- pDoc->m_ManageGraphObject.GetDC(&dc);
- pDoc->m_ManageGraphObject.OnScroll(pDoc->CurrentCommand);
- }
-
- CScrollView::OnHScroll(nSBCode, nPos, pScrollBar);
- }
- void CMiniCADView::OnDestroy()
- {
- CScrollView::OnDestroy();
-
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- pDoc->CurrentCommand = DRAW_SELECT;
- }
- //屏幕放大
- void CMiniCADView::OnZoomout()
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- if(Proportion < 4)
- {
- Proportion += 0.25;
- pDoc->m_ManageGraphObject.Proportion = Proportion;
- //根据图纸尺寸设置滚动条滚动区域(既客户区)
- size.cx = (long)(pDoc->FileInfo.size.cx * Proportion) + EXTRA_WIDTH * 2;
- size.cy = (long)(pDoc->FileInfo.size.cy * Proportion) + EXTRA_HIGTH * 2;
- SetScrollSizes(MM_TEXT, size);
- pDoc->m_ManageGraphObject.PageSize.cx = size.cx;
- pDoc->m_ManageGraphObject.PageSize.cy = size.cy;
- CComboBox* psizeCombo = (CComboBox*)pMainWnd->m_MyOptionBar.GetDlgItem(IDC_FILESIZE);
- psizeCombo->SetCurSel((int)(Proportion / 0.25 - 1));
- Invalidate();
- }
-
- }
- //屏幕缩小
- void CMiniCADView::OnZoomin()
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- if(Proportion > 0.25)
- {
- Proportion -= 0.25;
- pDoc->m_ManageGraphObject.Proportion = Proportion;
- //根据图纸尺寸设置滚动条滚动区域(既客户区)
- size.cx = (long)(pDoc->FileInfo.size.cx * Proportion) + EXTRA_WIDTH * 2;
- size.cy = (long)(pDoc->FileInfo.size.cy * Proportion) + EXTRA_HIGTH * 2;
- SetScrollSizes(MM_TEXT, size);
- pDoc->m_ManageGraphObject.PageSize.cx = size.cx;
- pDoc->m_ManageGraphObject.PageSize.cy = size.cy;
- CComboBox* psizeCombo = (CComboBox*)pMainWnd->m_MyOptionBar.GetDlgItem(IDC_FILESIZE);
- psizeCombo->SetCurSel((int)(Proportion / 0.25 - 1));
- Invalidate();
- }
- }
- //选择图纸尺寸
- void CMiniCADView::OnSelchangeFilesize()
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- int index;
- CComboBox* psizeCombo = (CComboBox*)pMainWnd->m_MyOptionBar.GetDlgItem(IDC_FILESIZE);
- index = psizeCombo->GetCurSel();
- Proportion = (index + 1) * (float)0.25;
- pDoc->m_ManageGraphObject.Proportion = Proportion;
-
- //根据图纸尺寸设置滚动条滚动区域(既客户区)
- size.cx = (long)(pDoc->FileInfo.size.cx * Proportion) + EXTRA_WIDTH * 2;
- size.cy = (long)(pDoc->FileInfo.size.cy * Proportion) + EXTRA_HIGTH * 2;
- SetScrollSizes(MM_TEXT, size);
- pDoc->m_ManageGraphObject.PageSize.cx = size.cx;
- pDoc->m_ManageGraphObject.PageSize.cy = size.cy;
- Invalidate();
- }
- void CMiniCADView::OnSelchangeColor()
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- CComboBoxEx* ColorCombo = (CComboBoxEx*)pMainWnd->m_MyOptionBar.GetDlgItem(IDC_COLOR);
- switch(ColorCombo->GetCurSel())
- {
- case 0:
- pDoc->PenColor = RGB(0, 0, 0);
- break;
- case 1:
- pDoc->PenColor = RGB(255, 0, 0);
- break;
- case 2:
- pDoc->PenColor = RGB(255, 255, 0);
- break;
- case 3:
- pDoc->PenColor = RGB(0, 255, 0);
- break;
- case 4:
- pDoc->PenColor = RGB(0, 255, 255);
- break;
- case 5:
- pDoc->PenColor = RGB(0, 0, 255);
- break;
- case 6:
- pDoc->PenColor = RGB( 255, 0, 255);
- break;
- }
- pDoc->m_ManageGraphObject.SetPenColor(pDoc->PenColor);
- }
- void CMiniCADView::OnSelchangeLinestyle()
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- CComboBoxEx* LineStyleCombo = (CComboBoxEx*)pMainWnd->m_MyOptionBar.GetDlgItem(IDC_LINESTYLE);
- switch(LineStyleCombo->GetCurSel())
- {
- case 0:
- pDoc->LineStyle = PS_SOLID;
- break;
- case 1:
- pDoc->LineStyle = PS_DASH;
- break;
- case 2:
- pDoc->LineStyle = PS_DOT;
- break;
- case 3:
- pDoc->LineStyle = PS_DASHDOT;
- break;
- case 4:
- pDoc->LineStyle = PS_DASHDOTDOT;
- break;
- }
- pDoc->m_ManageGraphObject.SetLineStyle(pDoc->LineStyle);
- }
- void CMiniCADView::OnSize(UINT nType, int cx, int cy)
- {
- CScrollView::OnSize(nType, cx, cy);
-
- /* //当改变视图尺寸时取消当前的绘图命令
- pDoc->CurrentCommand = DRAW_SELECT;
- pDoc->LRepeatTimes = 0;
- */
- }
- void CMiniCADView::OnViewRedraw()
- {
- //激活OnDraw()函数,重画当前视图
- Invalidate();
- }
- void CMiniCADView::OnEditUndo()
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- pDoc->m_ManageGraphObject.OnUndo();
- Invalidate();
- }
- void CMiniCADView::OnUpdateEditUndo(CCmdUI* pCmdUI)
- {
- CMiniCADDoc* pDoc = GetDocument();
- if(pDoc->m_CommandStack.CanUndo())
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- }
- void CMiniCADView::OnEditRedo()
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- pDoc->m_ManageGraphObject.OnRedo();
- Invalidate();
- }
- void CMiniCADView::OnUpdateEditRedo(CCmdUI* pCmdUI)
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- if(pDoc->m_CommandStack.CanRedo())
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- }
- void CMiniCADView::OnUpdateDrawSelect(CCmdUI* pCmdUI)
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- pCmdUI->SetRadio(pDoc->CurrentCommand == DRAW_SELECT);
- pCmdUI->ContinueRouting();
- }
- void CMiniCADView::OnModifyDelete()
- {
- int* pObjectType;
- int* pObjetcIndex;
- int nIndex;
- int num;
- CGraphObjectInfo* pLineInfo;
- CGraphObjectInfo* pRectInfo;
- CGraphObjectInfo* pCircleInfo;
- CGraphObjectInfo* pArcInfo;
- CSelectedObjectInfo* pSelObjectInfo;
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- num = pDoc->m_ManageGraphObject.m_SelObjInfoArray.GetSize();
- pObjectType = new int[num];
- pObjetcIndex = new int[num];
- for(nIndex = 0; nIndex < num; nIndex++)
- {
- pSelObjectInfo = (CSelectedObjectInfo*)pDoc->m_ManageGraphObject.m_SelObjInfoArray.GetAt(nIndex);
- switch(pSelObjectInfo->m_type)
- {
- case OBJECT_LINE:
- pLineInfo = (CGraphObjectInfo*)pDoc->m_ManageGraphObject.m_LineInfoArray.GetAt(pSelObjectInfo->m_index);
- pLineInfo->m_del = TRUE;
- pObjectType[nIndex] = OBJECT_LINE;
- pObjetcIndex[nIndex] = pSelObjectInfo->m_index;
- break;
- case OBJECT_RECT:
- pRectInfo = (CGraphObjectInfo*)pDoc->m_ManageGraphObject.m_RectInfoArray.GetAt(pSelObjectInfo->m_index);
- pRectInfo->m_del = TRUE;
- pObjectType[nIndex] = OBJECT_RECT;
- pObjetcIndex[nIndex] = pSelObjectInfo->m_index;
- break;
- case OBJECT_CIRCLE:
- pCircleInfo = (CGraphObjectInfo*)pDoc->m_ManageGraphObject.m_CircleInfoArray.GetAt(pSelObjectInfo->m_index);
- pCircleInfo->m_del = TRUE;
- pObjectType[nIndex] = OBJECT_CIRCLE;
- pObjetcIndex[nIndex] = pSelObjectInfo->m_index;
- break;
- case OBJECT_ARC:
- pArcInfo = (CGraphObjectInfo*)pDoc->m_ManageGraphObject.m_ArcInfoArray.GetAt(pSelObjectInfo->m_index);
- pArcInfo->m_del = TRUE;
- pObjectType[nIndex] = OBJECT_ARC;
- pObjetcIndex[nIndex] = pSelObjectInfo->m_index;
- break;
- }
- }
- pDoc->m_CommandStack.PushCommand(ID_CHANGE_DELETE, num, pObjectType, pObjetcIndex);
- pDoc->m_ManageGraphObject.UnselectObject();
- Invalidate();
-
- delete pObjectType;
- delete pObjetcIndex;
- }
- void CMiniCADView::OnUpdateChangeDelete(CCmdUI* pCmdUI)
- {
- CMiniCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- if(pDoc->m_ManageGraphObject.m_SelObjInfoArray.GetSize() > 0)
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- }
- void CMiniCADView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
- {
-
- CScrollView::OnPrepareDC(pDC, pInfo);
- }
- void CMiniCADView::OnModifyCopy()
- {
-
- }
- void CMiniCADView::OnModifyCut()
- {
-
-
- }
- void CMiniCADView::OnModifyCuttoangle()
- {
-
-
- }
- void CMiniCADView::OnModifyLengthento()
- {
-
- }
- void CMiniCADView::OnModifyJoin()
- {
- }
- void CMiniCADView::OnModifyMirror()
- {
-
- }
- void CMiniCADView::OnModifyVertical()
- {
-
- }
- void CMiniCADView::OnModifyMove()
- {
-
- }
- void CMiniCADView::OnModifyRotate()
- {
-
- }
- void CMiniCADView::OnModifyExcursion()
- {
-
- }
- void CMiniCADView::OnEditCopy()
- {
-
-
- }
- void CMiniCADView::OnEditCut()
- {
-
- }
- void CMiniCADView::OnEditPaste()
- {
-
- }
- void CMiniCADView::OnFormatDrawingAttribute()
- {
- CDrawingAttributeDlg dlg;
- dlg.DoModal();
- }
- void CMiniCADView::OnToolSelect()
- {
- CSelectParameterDlg dlg;
- dlg.DoModal();
- }