MiniCADView.cpp
上传用户:netltd
上传日期:2013-02-12
资源大小:7234k
文件大小:22k
- // MiniCADView.cpp : implementation of the CMiniCADView class
- //
- #include "stdafx.h"
- #include "MiniCADView.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)
- //}}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();
- pDoc = GetDocument();
- 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));
- pDoc->m_HandleCommand.m_OperateObject.LineStyle = pApp->CADInfo.LineStyle;
- pDoc->m_HandleCommand.m_OperateObject.PenColor = pApp->CADInfo.PenColor;
- 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_HandleCommand.GetView((CScrollView*)this);
- pDoc->m_HandleCommand.SetPageSize(size);
-
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////
- //改变视图背景颜色
- void CMiniCADView::OnEraseBkgnd (CDC* pDC)
- {
- // Create a cyan brush.
- CBrush Brush (RGB (200, 255, 255));
- CBrush* pOldBrush = pDC->SelectObject (&Brush);
- // Get the area that needs to be erased .
- CRect rcClip ;
- pDC->GetClipBox (&rcClip);
- //Paint the area.
- pDC-> PatBlt (rcClip.left , rcClip.top , rcClip.Width ( ) , rcClip.Height ( ) , PATCOPY );
- //Unselect brush out of device context .
- pDC->SelectObject (pOldBrush );
- }
- // CMiniCADView drawing
- void CMiniCADView::OnDraw(CDC* pDC)
- {
- 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);
- /*
- rect.left = 46;
- rect.top = 243;
- rect.right = 204;
- rect.bottom = 401;
- POINT sd = {100, 397};
- POINT ed = {190, 277};
- pDC->Arc(&rect, sd, ed);
- */
- //重画所有的图形对象
- pDoc->m_HandleCommand.Redraw(pDC);
- }
- //////////////////////////////////////////////////////////////////////////////////////////////
- void CMiniCADView::OnDrawSelect()
- {
- pDoc->m_HandleCommand.SetCommand(DRAW_SELECT);
- }
- void CMiniCADView::OnDrawLine()
- {
- //if(pDoc->m_OperateObject.UnselectObject())
- // Invalidate();
- pDoc->m_HandleCommand.SetCommand(DRAW_LINE);
- }
- void CMiniCADView::OnDrawRect()
- {
- //if(pDoc->m_OperateObject.UnselectObject())
- // Invalidate();
- pDoc->m_HandleCommand.SetCommand(DRAW_RECT);
- }
- void CMiniCADView::OnDrawCircle()
- {
- //if(pDoc->m_OperateObject.UnselectObject())
- // Invalidate();
- pDoc->m_HandleCommand.SetCommand(DRAW_CIRCLE);
- }
- void CMiniCADView::OnDrawArc()
- {
- // if(pDoc->m_OperateObject.UnselectObject())
- // Invalidate();
- pDoc->m_HandleCommand.SetCommand(DRAW_ARC);
-
- }
- void CMiniCADView::OnDrawMultiline()
- {
-
- }
- void CMiniCADView::OnDrawPolygon()
- {
-
- }
- void CMiniCADView::OnDrawEllipse()
- {
-
- }
- void CMiniCADView::OnDrawDot()
- {
-
- }
- void CMiniCADView::OnDrawCurve()
- {
-
- }
- void CMiniCADView::OnDrawDefineline()
- {
- }
- void CMiniCADView::OnDrawText()
- {
- // if(pDoc->m_OperateObject.UnselectObject())
- // Invalidate();
- pDoc->m_HandleCommand.SetCommand(DRAW_TEXT);
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////
- void CMiniCADView::OnUpdateDrawSelect(CCmdUI* pCmdUI)
- {
- pCmdUI->SetRadio(pDoc->m_HandleCommand.GetCommand() == DRAW_SELECT);
- pCmdUI->ContinueRouting();
- }
- void CMiniCADView::OnUpdateDrawLine(CCmdUI* pCmdUI)
- {
- pCmdUI->SetRadio(pDoc->m_HandleCommand.GetCommand() == DRAW_LINE);
- //继续传递当前命令
- pCmdUI->ContinueRouting();
- }
- void CMiniCADView::OnUpdateDrawRect(CCmdUI* pCmdUI)
- {
- pCmdUI->SetRadio(pDoc->m_HandleCommand.GetCommand() == DRAW_RECT);
- pCmdUI->ContinueRouting();
- }
- void CMiniCADView::OnUpdateDrawCircle(CCmdUI* pCmdUI)
- {
- pCmdUI->SetRadio(pDoc->m_HandleCommand.GetCommand() == DRAW_CIRCLE);
- pCmdUI->ContinueRouting();
- }
- void CMiniCADView::OnUpdateDrawArc(CCmdUI* pCmdUI)
- {
- pCmdUI->SetRadio(pDoc->m_HandleCommand.GetCommand() == DRAW_ARC);
- pCmdUI->ContinueRouting();
- }
- void CMiniCADView::OnUpdateDrawText(CCmdUI* pCmdUI)
- {
- pCmdUI->SetRadio(pDoc->m_HandleCommand.GetCommand() == DRAW_TEXT);
- pCmdUI->ContinueRouting();
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////
- //mouse message
- void CMiniCADView::OnLButtonDown(UINT nFlags, CPoint point)
- {
- CClientDC dc(this);
- OnPrepareDC(&dc);
- dc.DPtoLP(&point);
- pDoc->m_HandleCommand.LButtonDown(&dc, point);
- CScrollView::OnLButtonDown(nFlags, point);
- }
- void CMiniCADView::OnRButtonDown(UINT nFlags, CPoint point)
- {
- CClientDC dc(this);
- OnPrepareDC(&dc);
- dc.DPtoLP(&point);
- pDoc->m_HandleCommand.RButtonDown(&dc, point);
- CScrollView::OnRButtonDown(nFlags, point);
- }
- void CMiniCADView::OnMouseMove(UINT nFlags, CPoint point)
- {
- 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);
- pDoc->m_HandleCommand.MouseMove(&dc, point);
- CScrollView::OnMouseMove(nFlags, point);
- }
- void CMiniCADView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- CClientDC dc(this);
- OnPrepareDC(&dc);
-
- pDoc->m_HandleCommand.ScrollScreen(&dc);
- CScrollView::OnVScroll(nSBCode, nPos, pScrollBar);
- }
- void CMiniCADView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- CClientDC dc(this);
- OnPrepareDC(&dc);
- pDoc->m_HandleCommand.ScrollScreen(&dc);
- CScrollView::OnHScroll(nSBCode, nPos, pScrollBar);
- }
- void CMiniCADView::OnDestroy()
- {
- CScrollView::OnDestroy();
- }
- //屏幕放大
- void CMiniCADView::OnZoomout()
- {
- /*
- if(Proportion < 4)
- {
- Proportion += 0.25;
- pDoc->m_OperateObject.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_OperateObject.size.cx = size.cx;
- pDoc->m_OperateObject.size.cy = size.cy;
- CComboBox* psizeCombo = (CComboBox*)pMainWnd->m_MyOptionBar.GetDlgItem(IDC_FILESIZE);
- psizeCombo->SetCurSel((int)(Proportion / 0.25 - 1));
- Invalidate();
- }
- */
- }
- //屏幕缩小
- void CMiniCADView::OnZoomin()
- {
- // TODO: Add your command handler code here
- /* if(Proportion > 0.25)
- {
- Proportion -= 0.25;
- pDoc->m_OperateObject.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_OperateObject.size.cx = size.cx;
- pDoc->m_OperateObject.size.cy = size.cy;
- CComboBox* psizeCombo = (CComboBox*)pMainWnd->m_MyOptionBar.GetDlgItem(IDC_FILESIZE);
- psizeCombo->SetCurSel((int)(Proportion / 0.25 - 1));
- Invalidate();
- }
- */
- }
- //选择图纸尺寸
- void CMiniCADView::OnSelchangeFilesize()
- {
- /*
- int index;
- CComboBox* psizeCombo = (CComboBox*)pMainWnd->m_MyOptionBar.GetDlgItem(IDC_FILESIZE);
- index = psizeCombo->GetCurSel();
- Proportion = (index + 1) * (float)0.25;
- pDoc->m_OperateObject.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_OperateObject.size.cx = size.cx;
- pDoc->m_OperateObject.size.cy = size.cy;
- Invalidate();
- */
- }
- void CMiniCADView::OnSelchangeColor()
- {
- /* CComboBoxEx* ColorCombo = (CComboBoxEx*)pMainWnd->m_MyOptionBar.GetDlgItem(IDC_COLOR);
- switch(ColorCombo->GetCurSel())
- {
- case 0:
- pApp->CADInfo.PenColor = RGB(0, 0, 0);
- break;
- case 1:
- pApp->CADInfo.PenColor = RGB(255, 0, 0);
- break;
- case 2:
- pApp->CADInfo.PenColor = RGB(255, 255, 0);
- break;
- case 3:
- pApp->CADInfo.PenColor = RGB(0, 255, 0);
- break;
- case 4:
- pApp->CADInfo.PenColor = RGB(0, 255, 255);
- break;
- case 5:
- pApp->CADInfo.PenColor = RGB(0, 0, 255);
- break;
- case 6:
- pApp->CADInfo.PenColor = RGB( 255, 0, 255);
- break;
- }
- pDoc->m_OperateObject.PenColor = pApp->CADInfo.PenColor;
- */
- }
- void CMiniCADView::OnSelchangeLinestyle()
- {
- /* CComboBoxEx* LineStyleCombo = (CComboBoxEx*)pMainWnd->m_MyOptionBar.GetDlgItem(IDC_LINESTYLE);
- switch(LineStyleCombo->GetCurSel())
- {
- case 0:
- pApp->CADInfo.LineStyle = PS_SOLID;
- break;
- case 1:
- pApp->CADInfo.LineStyle = PS_DASH;
- break;
- case 2:
- pApp->CADInfo.LineStyle = PS_DOT;
- break;
- case 3:
- pApp->CADInfo.LineStyle = PS_DASHDOT;
- break;
- case 4:
- pApp->CADInfo.LineStyle = PS_DASHDOTDOT;
- break;
- }
- pDoc->m_OperateObject.LineStyle = pApp->CADInfo.LineStyle;
- */
- }
- void CMiniCADView::OnSize(UINT nType, int cx, int cy)
- {
- CScrollView::OnSize(nType, cx, cy);
-
- //当改变视图尺寸时取消当前的绘图命令
- //pApp->CADInfo.CurrentCommand = DRAW_SELECT;
- //pApp->CADInfo.LRepeatTimes = 0;
- }
- void CMiniCADView::OnViewRedraw()
- {
- //激活OnDraw()函数,重画当前视图
- Invalidate();
- }
- void CMiniCADView::OnEditUndo()
- {
- /* CCommandStruct* pCommand;
- CGraphObjectInfo* pLineInfo;
- CGraphObjectInfo* pRectInfo;
- CGraphObjectInfo* pCircleInfo;
- CGraphObjectInfo* pArcInfo;
- if(pDoc->m_HandleCommand.CommandPointer < 0)
- return;
- pCommand = (CCommandStruct*)pDoc->m_HandleCommand.GetCommandAt(pDoc->m_HandleCommand.CommandPointer);
- switch(pCommand->m_command)
- {
- case ID_DRAW_LINE:
- pLineInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_LineInfoArray.GetAt(pCommand->m_index[0]);
- pLineInfo->m_del = TRUE;
- break;
- case ID_DRAW_RECT:
- pRectInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_RectInfoArray.GetAt(pCommand->m_index[0]);
- pRectInfo->m_del = TRUE;
- break;
- case ID_DRAW_CIRCLE:
- pCircleInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_CircleInfoArray.GetAt(pCommand->m_index[0]);
- pCircleInfo->m_del = TRUE;
- break;
- case ID_DRAW_ARC:
- pArcInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_ArcInfoArray.GetAt(pCommand->m_index[0]);
- pArcInfo->m_del = TRUE;
- break;
- case ID_CHANGE_DELETE:
- for(int index =0; index < pCommand->m_num; index++)
- {
- switch(pCommand->m_object[index])
- {
- case OBJ_LINE:
- pLineInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_LineInfoArray.GetAt(pCommand->m_index[index]);
- pLineInfo->m_del = FALSE;
- break;
- case OBJ_RECT:
- pRectInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_RectInfoArray.GetAt(pCommand->m_index[index]);
- pRectInfo->m_del = FALSE;
- break;
- case OBJ_CIRCLE:
- pCircleInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_CircleInfoArray.GetAt(pCommand->m_index[index]);
- pCircleInfo->m_del = FALSE;
- break;
- case OBJ_ARC:
- pArcInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_ArcInfoArray.GetAt(pCommand->m_index[index]);
- pArcInfo->m_del = FALSE;
- break;
- }
- }
- break;
- }
-
- pDoc->m_HandleCommand.CommandPointer--;
- Invalidate();
- */
- }
- void CMiniCADView::OnUpdateEditUndo(CCmdUI* pCmdUI)
- {
- /* if(pDoc->m_HandleCommand.m_CommandArray.GetSize() > 0 &&
- pDoc->m_HandleCommand.CommandPointer > -1)
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- */
- }
- void CMiniCADView::OnEditRedo()
- {
- /* CCommandStruct* pCommand;
- CGraphObjectInfo* pLineInfo;
- CGraphObjectInfo* pRectInfo;
- CGraphObjectInfo* pCircleInfo;
- CGraphObjectInfo* pArcInfo;
- if(pDoc->m_HandleCommand.CommandPointer == pDoc->m_HandleCommand.m_CommandArray.GetUpperBound())
- return;
- else
- pDoc->m_HandleCommand.CommandPointer++;
- pCommand = (CCommandStruct*)pDoc->m_HandleCommand.GetCommandAt(pDoc->m_HandleCommand.CommandPointer);
- switch(pCommand->m_command)
- {
- case ID_DRAW_LINE:
- pLineInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_LineInfoArray.GetAt(pCommand->m_index[0]);
- pLineInfo->m_del = FALSE;
- break;
- case ID_DRAW_RECT:
- pRectInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_RectInfoArray.GetAt(pCommand->m_index[0]);
- pRectInfo->m_del = FALSE;
- break;
- case ID_DRAW_CIRCLE:
- pCircleInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_CircleInfoArray.GetAt(pCommand->m_index[0]);
- pCircleInfo->m_del = FALSE;
- break;
- case ID_DRAW_ARC:
- pArcInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_ArcInfoArray.GetAt(pCommand->m_index[0]);
- pArcInfo->m_del = FALSE;
- break;
- case ID_CHANGE_DELETE:
- for(int index =0; index < pCommand->m_num; index++)
- {
- switch(pCommand->m_object[index])
- {
- case OBJ_LINE:
- pLineInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_LineInfoArray.GetAt(pCommand->m_index[index]);
- pLineInfo->m_del = TRUE;
- break;
- case OBJ_RECT:
- pRectInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_RectInfoArray.GetAt(pCommand->m_index[index]);
- pRectInfo->m_del = TRUE;
- break;
- case OBJ_CIRCLE:
- pCircleInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_CircleInfoArray.GetAt(pCommand->m_index[index]);
- pCircleInfo->m_del = TRUE;
- break;
- case OBJ_ARC:
- pArcInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_ArcInfoArray.GetAt(pCommand->m_index[index]);
- pArcInfo->m_del = TRUE;
- break;
- }
- }
- break;
- }
- Invalidate();
- */
- }
- void CMiniCADView::OnUpdateEditRedo(CCmdUI* pCmdUI)
- {
- /*
- if(pDoc->m_HandleCommand.m_CommandArray.GetSize() > 0 &&
- pDoc->m_HandleCommand.CommandPointer < pDoc->m_HandleCommand.m_CommandArray.GetUpperBound())
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- */
- }
- void CMiniCADView::OnModifyDelete()
- {
- /*
- int* pObjectType;
- int* pObjetcIndex;
- int nIndex;
- int num;
- CGraphObjectInfo* pLineInfo;
- CGraphObjectInfo* pRectInfo;
- CGraphObjectInfo* pCircleInfo;
- CGraphObjectInfo* pArcInfo;
- CSelectedObjectInfo* pSelObjectInfo;
- CMiniCADDoc* pDoc = GetDocument();
- num = pDoc->m_OperateObject.m_SelObjInfoArray.GetSize();
- pObjectType = new int[num];
- pObjetcIndex = new int[num];
- for(nIndex = 0; nIndex < num; nIndex++)
- {
- pSelObjectInfo = (CSelectedObjectInfo*)pDoc->m_OperateObject.m_SelObjInfoArray.GetAt(nIndex);
- switch(pSelObjectInfo->m_type)
- {
- case OBJ_LINE:
- pLineInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_LineInfoArray.GetAt(pSelObjectInfo->m_index);
- pLineInfo->m_del = TRUE;
- pObjectType[nIndex] = OBJ_LINE;
- pObjetcIndex[nIndex] = pSelObjectInfo->m_index;
- break;
- case OBJ_RECT:
- pRectInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_RectInfoArray.GetAt(pSelObjectInfo->m_index);
- pRectInfo->m_del = TRUE;
- pObjectType[nIndex] = OBJ_RECT;
- pObjetcIndex[nIndex] = pSelObjectInfo->m_index;
- break;
- case OBJ_CIRCLE:
- pCircleInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_CircleInfoArray.GetAt(pSelObjectInfo->m_index);
- pCircleInfo->m_del = TRUE;
- pObjectType[nIndex] = OBJ_CIRCLE;
- pObjetcIndex[nIndex] = pSelObjectInfo->m_index;
- break;
- case OBJ_ARC:
- pArcInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_ArcInfoArray.GetAt(pSelObjectInfo->m_index);
- pArcInfo->m_del = TRUE;
- pObjectType[nIndex] = OBJ_ARC;
- pObjetcIndex[nIndex] = pSelObjectInfo->m_index;
- break;
- }
- }
- pDoc->m_HandleCommand.DelCommandFrom(pDoc->m_HandleCommand.CommandPointer + 1);
- pDoc->m_HandleCommand.AddCommand(ID_CHANGE_DELETE, num, pObjectType, pObjetcIndex);
- pDoc->m_HandleCommand.CommandPointer = pDoc->m_HandleCommand.m_CommandArray.GetUpperBound();
- pDoc->m_OperateObject.UnselectObject();
- Invalidate();
-
- delete pObjectType;
- delete pObjetcIndex;
- */
- }
- void CMiniCADView::OnUpdateChangeDelete(CCmdUI* pCmdUI)
- {
- /*
- CMiniCADDoc* pDoc = GetDocument();
- if(pDoc->m_OperateObject.m_SelObjInfoArray.GetSize() > 0)
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- */
- }
- void CMiniCADView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
- {
- // TODO: Add your specialized code here and/or call the base class
-
- 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()
- {
-
- }
- BOOL CMiniCADView::OnScroll(UINT nScrollCode, UINT nPos, BOOL bDoScroll)
- {
- // TODO: Add your specialized code here and/or call the base class
-
- return CScrollView::OnScroll(nScrollCode, nPos, bDoScroll);
- }