MiniCADView.cpp
上传用户:netltd
上传日期:2013-02-12
资源大小:7234k
文件大小:22k
源码类别:

绘图程序

开发平台:

Visual C++

  1. // MiniCADView.cpp : implementation of the CMiniCADView class
  2. //
  3. #include "stdafx.h"
  4. #include "MiniCADView.h"
  5. #ifdef _DEBUG
  6. #define new DEBUG_NEW
  7. #undef THIS_FILE
  8. static char THIS_FILE[] = __FILE__;
  9. #endif
  10. /////////////////////////////////////////////////////////////////////////////
  11. // CMiniCADView
  12. IMPLEMENT_DYNCREATE(CMiniCADView, CScrollView)
  13. BEGIN_MESSAGE_MAP(CMiniCADView, CScrollView)
  14. //{{AFX_MSG_MAP(CMiniCADView)
  15. ON_COMMAND(ID_DRAW_CIRCLE, OnDrawCircle)
  16. ON_COMMAND(ID_DRAW_LINE, OnDrawLine)
  17. ON_WM_LBUTTONDOWN()
  18. ON_WM_RBUTTONDOWN()
  19. ON_WM_MOUSEMOVE()
  20. ON_WM_VSCROLL()
  21. ON_WM_DESTROY()
  22. ON_WM_HSCROLL()
  23. ON_COMMAND(ID_VIEW_ZOOMOUT, OnZoomout)
  24. ON_COMMAND(ID_VIEW_ZOOMIN, OnZoomin)
  25. ON_CBN_SELCHANGE(IDC_COLOR, OnSelchangeColor)
  26. ON_CBN_SELCHANGE(IDC_LINESTYLE, OnSelchangeLinestyle)
  27. ON_COMMAND(ID_DRAW_RECT, OnDrawRect)
  28. ON_WM_SIZE()
  29. ON_COMMAND(ID_VIEW_REDRAW, OnViewRedraw)
  30. ON_COMMAND(ID_DRAW_SELECT, OnDrawSelect)
  31. ON_COMMAND(ID_EDIT_UNDO, OnEditUndo)
  32. ON_COMMAND(ID_EDIT_REDO, OnEditRedo)
  33. ON_COMMAND(ID_DRAW_ARC, OnDrawArc)
  34. ON_COMMAND(ID_DRAW_TEXT, OnDrawText)
  35. ON_UPDATE_COMMAND_UI(ID_DRAW_SELECT, OnUpdateDrawSelect)
  36. ON_UPDATE_COMMAND_UI(ID_DRAW_LINE, OnUpdateDrawLine)
  37. ON_UPDATE_COMMAND_UI(ID_DRAW_RECT, OnUpdateDrawRect)
  38. ON_UPDATE_COMMAND_UI(ID_DRAW_CIRCLE, OnUpdateDrawCircle)
  39. ON_UPDATE_COMMAND_UI(ID_DRAW_ARC, OnUpdateDrawArc)
  40. ON_UPDATE_COMMAND_UI(ID_DRAW_TEXT, OnUpdateDrawText)
  41. ON_UPDATE_COMMAND_UI(ID_EDIT_REDO, OnUpdateEditRedo)
  42. ON_UPDATE_COMMAND_UI(ID_EDIT_UNDO, OnUpdateEditUndo)
  43. ON_UPDATE_COMMAND_UI(ID_CHANGE_DELETE, OnUpdateChangeDelete)
  44.     ON_WM_ERASEBKGND()
  45. ON_CBN_SELCHANGE(IDC_FILESIZE, OnSelchangeFilesize)
  46. ON_COMMAND(ID_DRAW_MULTILINE, OnDrawMultiline)
  47. ON_COMMAND(ID_DRAW_POLYGON, OnDrawPolygon)
  48. ON_COMMAND(ID_DRAW_ELLIPSE, OnDrawEllipse)
  49. ON_COMMAND(ID_MODIFY_DELETE, OnModifyDelete)
  50. ON_COMMAND(ID_MODIFY_COPY, OnModifyCopy)
  51. ON_COMMAND(ID_MODIFY_CUT, OnModifyCut)
  52. ON_COMMAND(ID_MODIFY_CUTTOANGLE, OnModifyCuttoangle)
  53. ON_COMMAND(ID_MODIFY_LENGTHENTO, OnModifyLengthento)
  54. ON_COMMAND(ID_MODIFY_JOIN, OnModifyJoin)
  55. ON_COMMAND(ID_MODIFY_MIRROR, OnModifyMirror)
  56. ON_COMMAND(ID_MODIFY_VERTICAL, OnModifyVertical)
  57. ON_COMMAND(ID_DRAW_DOT, OnDrawDot)
  58. ON_COMMAND(ID_DRAW_CURVE, OnDrawCurve)
  59. ON_COMMAND(ID_MODIFY_MOVE, OnModifyMove)
  60. ON_COMMAND(ID_MODIFY_ROTATE, OnModifyRotate)
  61. ON_COMMAND(ID_DRAW_DEFINELINE, OnDrawDefineline)
  62. ON_COMMAND(ID_MODIFY_EXCURSION, OnModifyExcursion)
  63. ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
  64. ON_COMMAND(ID_EDIT_CUT, OnEditCut)
  65. ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
  66. //}}AFX_MSG_MAP
  67. // Standard printing commands
  68. ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
  69. ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
  70. ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
  71. END_MESSAGE_MAP()
  72. /////////////////////////////////////////////////////////////////////////////
  73. // CMiniCADView construction/destruction
  74. CMiniCADView::CMiniCADView()
  75. {
  76. pApp = (CMiniCADApp*)AfxGetApp();
  77. pMainWnd = (CMainFrame*)pApp->m_pMainWnd;
  78. }
  79. CMiniCADView::~CMiniCADView()
  80. {
  81. }
  82. BOOL CMiniCADView::PreCreateWindow(CREATESTRUCT& cs)
  83. {
  84. cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW, 0 ,(HBRUSH)::GetStockObject(WHITE_BRUSH), 0);
  85. return CView::PreCreateWindow(cs);
  86. }
  87. /////////////////////////////////////////////////////////////////////////////
  88. // CMiniCADView printing
  89. BOOL CMiniCADView::OnPreparePrinting(CPrintInfo* pInfo)
  90. {
  91. // default preparation
  92. return DoPreparePrinting(pInfo);
  93. }
  94. void CMiniCADView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  95. {
  96. }
  97. void CMiniCADView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  98. {
  99. }
  100. /////////////////////////////////////////////////////////////////////////////
  101. // CMiniCADView diagnostics
  102. #ifdef _DEBUG
  103. void CMiniCADView::AssertValid() const
  104. {
  105. CView::AssertValid();
  106. }
  107. void CMiniCADView::Dump(CDumpContext& dc) const
  108. {
  109. CView::Dump(dc);
  110. }
  111. CMiniCADDoc* CMiniCADView::GetDocument() // non-debug version is inline
  112. {
  113. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMiniCADDoc)));
  114. return (CMiniCADDoc*)m_pDocument;
  115. }
  116. #endif //_DEBUG
  117. /////////////////////////////////////////////////////////////////////////////
  118. // CMiniCADView message handlers
  119. void CMiniCADView::OnInitialUpdate() 
  120. {
  121. CScrollView::OnInitialUpdate();
  122. pDoc = GetDocument();
  123. CClientDC dc(this);
  124.     
  125. //在MDI子框架上显示标题,标题为图纸名
  126. CChildFrame* pChildWnd = (CChildFrame*)pMainWnd->MDIGetActive();
  127. pChildWnd->SetWindowText(pDoc->FileInfo.Name);
  128.     
  129. //初始化颜色复选框
  130. CComboBoxEx* ColorCombo = (CComboBoxEx*)pMainWnd->m_MyOptionBar.GetDlgItem(IDC_COLOR);
  131. ColorCombo->EnableWindow(TRUE);
  132.     ColorCombo->SetCurSel(0);
  133. //初始化线形复选框
  134. CComboBoxEx* LineStyleCombo = (CComboBoxEx*)pMainWnd->m_MyOptionBar.GetDlgItem(IDC_LINESTYLE);
  135. LineStyleCombo->EnableWindow(TRUE);
  136. LineStyleCombo->SetCurSel(0);
  137. //初始化图纸尺寸复选框
  138. CComboBox* psizeCombo = (CComboBox*)pMainWnd->m_MyOptionBar.GetDlgItem(IDC_FILESIZE);
  139. psizeCombo->EnableWindow(TRUE);
  140. psizeCombo->SetCurSel(3);
  141.     //初始化绘图工具条 、光标
  142. SetCursor(AfxGetApp()->LoadCursor(IDC_SELECTCUR));
  143.     pDoc->m_HandleCommand.m_OperateObject.LineStyle = pApp->CADInfo.LineStyle;
  144. pDoc->m_HandleCommand.m_OperateObject.PenColor = pApp->CADInfo.PenColor;
  145.     Proportion = 1.0;
  146. //根据图纸尺寸设置滚动条滚动区域(既客户区)
  147. size.cx = pDoc->FileInfo.size.cx + EXTRA_WIDTH * 2; 
  148.     size.cy = pDoc->FileInfo.size.cy + EXTRA_HIGTH * 2;
  149. SetScrollSizes(MM_TEXT, size);
  150. pDoc->m_HandleCommand.GetView((CScrollView*)this);
  151. pDoc->m_HandleCommand.SetPageSize(size);
  152. }
  153. ////////////////////////////////////////////////////////////////////////////////////////////////
  154. //改变视图背景颜色
  155. void CMiniCADView::OnEraseBkgnd (CDC* pDC)
  156. {
  157. // Create a cyan brush.
  158.     CBrush Brush (RGB (200, 255, 255));
  159.     CBrush* pOldBrush = pDC->SelectObject (&Brush);
  160.     // Get the area that needs to be erased .
  161.     CRect rcClip ;
  162.     pDC->GetClipBox (&rcClip);
  163.     //Paint the area.
  164.     pDC-> PatBlt (rcClip.left , rcClip.top , rcClip.Width ( ) , rcClip.Height ( ) , PATCOPY );
  165.     //Unselect brush out of device context .
  166.     pDC->SelectObject (pOldBrush );
  167. }
  168. // CMiniCADView drawing
  169. void CMiniCADView::OnDraw(CDC* pDC)
  170. {
  171. CBrush brush;
  172. RECT rect;
  173. RECT shadow;
  174. rect.left = EXTRA_WIDTH;
  175. rect.top = EXTRA_HIGTH;
  176. rect.right = rect.left + (long)(pDoc->FileInfo.size.cx * Proportion) + 1;
  177. rect.bottom = rect.top + (long)(pDoc->FileInfo.size.cy * Proportion) + 1;
  178. brush.CreateSolidBrush(RGB(192, 192, 192));
  179.     shadow.left = rect.left + 3;
  180. shadow.top = rect.bottom;
  181. shadow.right = rect.right + 3;
  182. shadow.bottom = shadow.top + 3;
  183.     pDC->FillRect(&shadow, &brush);
  184. shadow.left = rect.right;
  185. shadow.top = rect.top + 3;
  186. shadow.right = shadow.left + 3;
  187. shadow.bottom = rect.bottom + 3;
  188.     pDC->FillRect(&shadow, &brush);
  189. pDC->Rectangle(&rect);
  190. /*
  191. rect.left = 46;
  192. rect.top = 243;
  193. rect.right = 204;
  194. rect.bottom = 401;
  195. POINT sd = {100, 397};
  196. POINT ed = {190, 277};
  197. pDC->Arc(&rect, sd, ed);
  198. */    
  199.     //重画所有的图形对象
  200. pDoc->m_HandleCommand.Redraw(pDC);
  201. }
  202. //////////////////////////////////////////////////////////////////////////////////////////////
  203. void CMiniCADView::OnDrawSelect() 
  204. {
  205. pDoc->m_HandleCommand.SetCommand(DRAW_SELECT);
  206. }
  207. void CMiniCADView::OnDrawLine() 
  208. {
  209. //if(pDoc->m_OperateObject.UnselectObject())
  210. // Invalidate();
  211.     pDoc->m_HandleCommand.SetCommand(DRAW_LINE);
  212. }
  213. void CMiniCADView::OnDrawRect() 
  214. {
  215. //if(pDoc->m_OperateObject.UnselectObject())
  216. // Invalidate();
  217. pDoc->m_HandleCommand.SetCommand(DRAW_RECT);
  218. }
  219. void CMiniCADView::OnDrawCircle() 
  220. {
  221. //if(pDoc->m_OperateObject.UnselectObject())
  222. // Invalidate();
  223. pDoc->m_HandleCommand.SetCommand(DRAW_CIRCLE);
  224. }
  225. void CMiniCADView::OnDrawArc() 
  226. {
  227. // if(pDoc->m_OperateObject.UnselectObject())
  228. // Invalidate();
  229. pDoc->m_HandleCommand.SetCommand(DRAW_ARC);
  230. }
  231. void CMiniCADView::OnDrawMultiline() 
  232. {
  233. }
  234. void CMiniCADView::OnDrawPolygon() 
  235. {
  236. }
  237. void CMiniCADView::OnDrawEllipse() 
  238. {
  239. }
  240. void CMiniCADView::OnDrawDot() 
  241. {
  242. }
  243. void CMiniCADView::OnDrawCurve() 
  244. {
  245. }
  246. void CMiniCADView::OnDrawDefineline() 
  247. {
  248. }
  249. void CMiniCADView::OnDrawText() 
  250. {
  251. // if(pDoc->m_OperateObject.UnselectObject())
  252. // Invalidate();
  253. pDoc->m_HandleCommand.SetCommand(DRAW_TEXT);
  254. }
  255. ///////////////////////////////////////////////////////////////////////////////////////////////
  256. void CMiniCADView::OnUpdateDrawSelect(CCmdUI* pCmdUI) 
  257. {
  258. pCmdUI->SetRadio(pDoc->m_HandleCommand.GetCommand() == DRAW_SELECT);
  259. pCmdUI->ContinueRouting();
  260. }
  261. void CMiniCADView::OnUpdateDrawLine(CCmdUI* pCmdUI) 
  262. {
  263. pCmdUI->SetRadio(pDoc->m_HandleCommand.GetCommand() == DRAW_LINE);
  264. //继续传递当前命令
  265. pCmdUI->ContinueRouting();
  266. }
  267. void CMiniCADView::OnUpdateDrawRect(CCmdUI* pCmdUI) 
  268. {
  269. pCmdUI->SetRadio(pDoc->m_HandleCommand.GetCommand() == DRAW_RECT);
  270. pCmdUI->ContinueRouting();
  271. }
  272. void CMiniCADView::OnUpdateDrawCircle(CCmdUI* pCmdUI) 
  273. {
  274. pCmdUI->SetRadio(pDoc->m_HandleCommand.GetCommand() == DRAW_CIRCLE);
  275. pCmdUI->ContinueRouting();
  276. }
  277. void CMiniCADView::OnUpdateDrawArc(CCmdUI* pCmdUI) 
  278. {
  279. pCmdUI->SetRadio(pDoc->m_HandleCommand.GetCommand() == DRAW_ARC);
  280. pCmdUI->ContinueRouting();
  281. }
  282. void CMiniCADView::OnUpdateDrawText(CCmdUI* pCmdUI) 
  283. {
  284. pCmdUI->SetRadio(pDoc->m_HandleCommand.GetCommand() == DRAW_TEXT);
  285. pCmdUI->ContinueRouting();
  286. }
  287. ///////////////////////////////////////////////////////////////////////////////////////////////
  288. //mouse message
  289. void CMiniCADView::OnLButtonDown(UINT nFlags, CPoint point) 
  290. {
  291. CClientDC dc(this);
  292. OnPrepareDC(&dc);
  293. dc.DPtoLP(&point);
  294. pDoc->m_HandleCommand.LButtonDown(&dc, point);
  295. CScrollView::OnLButtonDown(nFlags, point);
  296. }
  297. void CMiniCADView::OnRButtonDown(UINT nFlags, CPoint point) 
  298. {
  299. CClientDC dc(this);
  300. OnPrepareDC(&dc);
  301. dc.DPtoLP(&point);
  302. pDoc->m_HandleCommand.RButtonDown(&dc, point);
  303. CScrollView::OnRButtonDown(nFlags, point);
  304. }
  305. void CMiniCADView::OnMouseMove(UINT nFlags, CPoint point) 
  306. {
  307. char x[32];
  308. char y[32];
  309. int count;
  310. CClientDC dc(this);
  311.     OnPrepareDC(&dc);
  312. dc.DPtoLP(&point);
  313. count = sprintf(x, "%s", "X = ");
  314. sprintf(x + count, "%f", (float)(point.x - EXTRA_WIDTH) / Proportion);
  315. pMainWnd->m_wndStatusBar.SetPaneText(1, x, TRUE);
  316. count = sprintf(y, "%s", "Y = ");
  317. sprintf(y + count, "%f", (float)(size.cy - point.y - EXTRA_HIGTH) / Proportion);
  318. pMainWnd->m_wndStatusBar.SetPaneText(2, y, TRUE);
  319. pDoc->m_HandleCommand.MouseMove(&dc, point);
  320. CScrollView::OnMouseMove(nFlags, point);
  321. }
  322. void CMiniCADView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
  323. {
  324. CClientDC dc(this);
  325. OnPrepareDC(&dc);
  326.     pDoc->m_HandleCommand.ScrollScreen(&dc);
  327.     CScrollView::OnVScroll(nSBCode, nPos, pScrollBar);
  328. }
  329. void CMiniCADView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
  330. {
  331. CClientDC dc(this);
  332. OnPrepareDC(&dc);
  333. pDoc->m_HandleCommand.ScrollScreen(&dc);
  334. CScrollView::OnHScroll(nSBCode, nPos, pScrollBar);
  335. }
  336. void CMiniCADView::OnDestroy() 
  337. {
  338. CScrollView::OnDestroy();
  339. }
  340. //屏幕放大
  341. void CMiniCADView::OnZoomout() 
  342. {
  343. /*
  344. if(Proportion < 4)
  345. {
  346. Proportion += 0.25;
  347.         pDoc->m_OperateObject.Proportion = Proportion;
  348. //根据图纸尺寸设置滚动条滚动区域(既客户区)
  349. size.cx = (long)(pDoc->FileInfo.size.cx * Proportion) + EXTRA_WIDTH * 2; 
  350. size.cy = (long)(pDoc->FileInfo.size.cy * Proportion) + EXTRA_HIGTH * 2;
  351. SetScrollSizes(MM_TEXT, size);
  352. pDoc->m_OperateObject.size.cx = size.cx;
  353. pDoc->m_OperateObject.size.cy = size.cy;
  354. CComboBox* psizeCombo = (CComboBox*)pMainWnd->m_MyOptionBar.GetDlgItem(IDC_FILESIZE);
  355.     psizeCombo->SetCurSel((int)(Proportion / 0.25 - 1));
  356. Invalidate();
  357. }
  358. */
  359. }
  360. //屏幕缩小
  361. void CMiniCADView::OnZoomin() 
  362. {
  363. // TODO: Add your command handler code here
  364. /* if(Proportion > 0.25)
  365. {
  366. Proportion -= 0.25;
  367.         pDoc->m_OperateObject.Proportion = Proportion;
  368. //根据图纸尺寸设置滚动条滚动区域(既客户区)
  369. size.cx = (long)(pDoc->FileInfo.size.cx * Proportion) + EXTRA_WIDTH * 2; 
  370. size.cy = (long)(pDoc->FileInfo.size.cy * Proportion) + EXTRA_HIGTH * 2;
  371. SetScrollSizes(MM_TEXT, size);
  372. pDoc->m_OperateObject.size.cx = size.cx;
  373. pDoc->m_OperateObject.size.cy = size.cy;
  374. CComboBox* psizeCombo = (CComboBox*)pMainWnd->m_MyOptionBar.GetDlgItem(IDC_FILESIZE);
  375.     psizeCombo->SetCurSel((int)(Proportion / 0.25 - 1));
  376. Invalidate();
  377. }
  378. */
  379. }
  380. //选择图纸尺寸
  381. void CMiniCADView::OnSelchangeFilesize() 
  382. {
  383. /*
  384. int index;
  385. CComboBox* psizeCombo = (CComboBox*)pMainWnd->m_MyOptionBar.GetDlgItem(IDC_FILESIZE);
  386. index = psizeCombo->GetCurSel();
  387.     Proportion = (index + 1) * (float)0.25;
  388. pDoc->m_OperateObject.Proportion = Proportion;
  389. //根据图纸尺寸设置滚动条滚动区域(既客户区)
  390. size.cx = (long)(pDoc->FileInfo.size.cx * Proportion) + EXTRA_WIDTH * 2; 
  391. size.cy = (long)(pDoc->FileInfo.size.cy * Proportion) + EXTRA_HIGTH * 2;
  392. SetScrollSizes(MM_TEXT, size);
  393. pDoc->m_OperateObject.size.cx = size.cx;
  394. pDoc->m_OperateObject.size.cy = size.cy;
  395. Invalidate();
  396. */
  397. }
  398. void CMiniCADView::OnSelchangeColor() 
  399. {
  400. /* CComboBoxEx* ColorCombo = (CComboBoxEx*)pMainWnd->m_MyOptionBar.GetDlgItem(IDC_COLOR);
  401. switch(ColorCombo->GetCurSel())
  402. {
  403. case 0:
  404. pApp->CADInfo.PenColor = RGB(0, 0, 0);
  405. break;
  406. case 1:
  407. pApp->CADInfo.PenColor = RGB(255, 0, 0);
  408. break;
  409. case 2:
  410. pApp->CADInfo.PenColor = RGB(255, 255, 0);
  411. break;
  412. case 3:
  413. pApp->CADInfo.PenColor = RGB(0, 255, 0);
  414. break;
  415. case 4:
  416. pApp->CADInfo.PenColor = RGB(0, 255, 255);
  417. break;
  418. case 5:
  419. pApp->CADInfo.PenColor = RGB(0, 0, 255);
  420. break;
  421. case 6:
  422. pApp->CADInfo.PenColor = RGB( 255, 0, 255);
  423. break;
  424. }
  425.     pDoc->m_OperateObject.PenColor = pApp->CADInfo.PenColor;
  426. */
  427. }
  428. void CMiniCADView::OnSelchangeLinestyle() 
  429. {
  430. /* CComboBoxEx* LineStyleCombo = (CComboBoxEx*)pMainWnd->m_MyOptionBar.GetDlgItem(IDC_LINESTYLE);
  431. switch(LineStyleCombo->GetCurSel())
  432. {
  433. case 0:
  434. pApp->CADInfo.LineStyle = PS_SOLID;
  435. break;
  436. case 1:
  437. pApp->CADInfo.LineStyle = PS_DASH;
  438. break;
  439. case 2:
  440. pApp->CADInfo.LineStyle = PS_DOT;
  441. break;
  442. case 3:
  443. pApp->CADInfo.LineStyle = PS_DASHDOT;
  444. break;
  445. case 4:
  446. pApp->CADInfo.LineStyle = PS_DASHDOTDOT;
  447. break;
  448. }
  449.     pDoc->m_OperateObject.LineStyle = pApp->CADInfo.LineStyle;
  450. */
  451. }
  452. void CMiniCADView::OnSize(UINT nType, int cx, int cy) 
  453. {
  454. CScrollView::OnSize(nType, cx, cy);
  455. //当改变视图尺寸时取消当前的绘图命令
  456. //pApp->CADInfo.CurrentCommand = DRAW_SELECT;
  457. //pApp->CADInfo.LRepeatTimes = 0;
  458. }
  459. void CMiniCADView::OnViewRedraw() 
  460. {
  461. //激活OnDraw()函数,重画当前视图
  462. Invalidate();
  463. }
  464. void CMiniCADView::OnEditUndo() 
  465. {
  466. /* CCommandStruct* pCommand;
  467. CGraphObjectInfo* pLineInfo;
  468. CGraphObjectInfo* pRectInfo;
  469. CGraphObjectInfo* pCircleInfo;
  470. CGraphObjectInfo* pArcInfo;
  471. if(pDoc->m_HandleCommand.CommandPointer < 0)
  472. return;
  473. pCommand = (CCommandStruct*)pDoc->m_HandleCommand.GetCommandAt(pDoc->m_HandleCommand.CommandPointer);
  474.     switch(pCommand->m_command)
  475. {
  476. case ID_DRAW_LINE:
  477. pLineInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_LineInfoArray.GetAt(pCommand->m_index[0]);
  478.         pLineInfo->m_del = TRUE;
  479. break;
  480. case ID_DRAW_RECT:
  481. pRectInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_RectInfoArray.GetAt(pCommand->m_index[0]);
  482.         pRectInfo->m_del = TRUE;
  483. break;
  484. case ID_DRAW_CIRCLE:
  485. pCircleInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_CircleInfoArray.GetAt(pCommand->m_index[0]);
  486.         pCircleInfo->m_del = TRUE;
  487. break;
  488. case ID_DRAW_ARC:
  489. pArcInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_ArcInfoArray.GetAt(pCommand->m_index[0]);
  490.         pArcInfo->m_del = TRUE;
  491. break;
  492. case ID_CHANGE_DELETE:
  493. for(int index =0; index < pCommand->m_num; index++)
  494. {
  495. switch(pCommand->m_object[index])
  496. {
  497. case OBJ_LINE:
  498. pLineInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_LineInfoArray.GetAt(pCommand->m_index[index]);
  499. pLineInfo->m_del = FALSE;
  500. break;
  501. case OBJ_RECT:
  502. pRectInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_RectInfoArray.GetAt(pCommand->m_index[index]);
  503. pRectInfo->m_del = FALSE;
  504. break;
  505. case OBJ_CIRCLE:
  506. pCircleInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_CircleInfoArray.GetAt(pCommand->m_index[index]);
  507. pCircleInfo->m_del = FALSE;
  508. break;
  509. case OBJ_ARC:
  510. pArcInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_ArcInfoArray.GetAt(pCommand->m_index[index]);
  511. pArcInfo->m_del = FALSE;
  512. break;
  513. }
  514. }
  515. break;
  516. }
  517.      
  518. pDoc->m_HandleCommand.CommandPointer--;
  519. Invalidate();
  520. */
  521. }
  522. void CMiniCADView::OnUpdateEditUndo(CCmdUI* pCmdUI) 
  523. {
  524. /* if(pDoc->m_HandleCommand.m_CommandArray.GetSize() > 0 &&
  525.    pDoc->m_HandleCommand.CommandPointer > -1)
  526. pCmdUI->Enable(TRUE);
  527. else
  528. pCmdUI->Enable(FALSE);
  529. */
  530. }
  531. void CMiniCADView::OnEditRedo() 
  532. {
  533. /* CCommandStruct* pCommand;
  534. CGraphObjectInfo* pLineInfo;
  535. CGraphObjectInfo* pRectInfo;
  536. CGraphObjectInfo* pCircleInfo;
  537. CGraphObjectInfo* pArcInfo;
  538. if(pDoc->m_HandleCommand.CommandPointer == pDoc->m_HandleCommand.m_CommandArray.GetUpperBound())
  539. return;
  540. else
  541. pDoc->m_HandleCommand.CommandPointer++;
  542. pCommand = (CCommandStruct*)pDoc->m_HandleCommand.GetCommandAt(pDoc->m_HandleCommand.CommandPointer);
  543.     switch(pCommand->m_command)
  544. {
  545. case ID_DRAW_LINE:
  546. pLineInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_LineInfoArray.GetAt(pCommand->m_index[0]);
  547.         pLineInfo->m_del = FALSE;
  548. break;
  549. case ID_DRAW_RECT:
  550. pRectInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_RectInfoArray.GetAt(pCommand->m_index[0]);
  551.         pRectInfo->m_del = FALSE;
  552. break;
  553. case ID_DRAW_CIRCLE:
  554. pCircleInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_CircleInfoArray.GetAt(pCommand->m_index[0]);
  555.         pCircleInfo->m_del = FALSE;
  556. break;
  557. case ID_DRAW_ARC:
  558. pArcInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_ArcInfoArray.GetAt(pCommand->m_index[0]);
  559.         pArcInfo->m_del = FALSE;
  560. break;
  561. case ID_CHANGE_DELETE:
  562. for(int index =0; index < pCommand->m_num; index++)
  563. {
  564. switch(pCommand->m_object[index])
  565. {
  566. case OBJ_LINE:
  567. pLineInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_LineInfoArray.GetAt(pCommand->m_index[index]);
  568. pLineInfo->m_del = TRUE;
  569. break;
  570. case OBJ_RECT:
  571. pRectInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_RectInfoArray.GetAt(pCommand->m_index[index]);
  572. pRectInfo->m_del = TRUE;
  573. break;
  574. case OBJ_CIRCLE:
  575. pCircleInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_CircleInfoArray.GetAt(pCommand->m_index[index]);
  576. pCircleInfo->m_del = TRUE;
  577. break;
  578. case OBJ_ARC:
  579. pArcInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_ArcInfoArray.GetAt(pCommand->m_index[index]);
  580. pArcInfo->m_del = TRUE;
  581. break;
  582. }
  583. }
  584. break;
  585. }
  586. Invalidate();
  587. */
  588. }
  589. void CMiniCADView::OnUpdateEditRedo(CCmdUI* pCmdUI) 
  590. {
  591. /*
  592. if(pDoc->m_HandleCommand.m_CommandArray.GetSize() > 0 &&
  593.    pDoc->m_HandleCommand.CommandPointer < pDoc->m_HandleCommand.m_CommandArray.GetUpperBound())
  594. pCmdUI->Enable(TRUE);
  595. else
  596. pCmdUI->Enable(FALSE);
  597. */
  598. }
  599. void CMiniCADView::OnModifyDelete() 
  600. {
  601. /*
  602. int* pObjectType;
  603. int* pObjetcIndex;
  604. int nIndex;
  605. int num;
  606. CGraphObjectInfo* pLineInfo;
  607. CGraphObjectInfo* pRectInfo;
  608. CGraphObjectInfo* pCircleInfo;
  609. CGraphObjectInfo* pArcInfo;
  610. CSelectedObjectInfo* pSelObjectInfo;
  611. CMiniCADDoc* pDoc = GetDocument();
  612. num = pDoc->m_OperateObject.m_SelObjInfoArray.GetSize();
  613. pObjectType = new int[num];
  614. pObjetcIndex = new int[num];
  615. for(nIndex = 0; nIndex < num; nIndex++)
  616. {
  617. pSelObjectInfo = (CSelectedObjectInfo*)pDoc->m_OperateObject.m_SelObjInfoArray.GetAt(nIndex);
  618. switch(pSelObjectInfo->m_type)
  619. {
  620. case OBJ_LINE:
  621. pLineInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_LineInfoArray.GetAt(pSelObjectInfo->m_index);
  622. pLineInfo->m_del = TRUE;
  623. pObjectType[nIndex] = OBJ_LINE;
  624. pObjetcIndex[nIndex] = pSelObjectInfo->m_index;
  625. break;
  626. case OBJ_RECT:
  627. pRectInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_RectInfoArray.GetAt(pSelObjectInfo->m_index);
  628. pRectInfo->m_del = TRUE;
  629. pObjectType[nIndex] = OBJ_RECT;
  630. pObjetcIndex[nIndex] = pSelObjectInfo->m_index;
  631. break;
  632. case OBJ_CIRCLE:
  633. pCircleInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_CircleInfoArray.GetAt(pSelObjectInfo->m_index);
  634. pCircleInfo->m_del = TRUE;
  635. pObjectType[nIndex] = OBJ_CIRCLE;
  636. pObjetcIndex[nIndex] = pSelObjectInfo->m_index;
  637. break;
  638. case OBJ_ARC:
  639. pArcInfo = (CGraphObjectInfo*)pDoc->m_OperateObject.m_ArcInfoArray.GetAt(pSelObjectInfo->m_index);
  640. pArcInfo->m_del = TRUE;
  641. pObjectType[nIndex] = OBJ_ARC;
  642. pObjetcIndex[nIndex] = pSelObjectInfo->m_index;
  643. break;
  644. }
  645. }
  646. pDoc->m_HandleCommand.DelCommandFrom(pDoc->m_HandleCommand.CommandPointer + 1);
  647. pDoc->m_HandleCommand.AddCommand(ID_CHANGE_DELETE, num, pObjectType, pObjetcIndex);
  648. pDoc->m_HandleCommand.CommandPointer = pDoc->m_HandleCommand.m_CommandArray.GetUpperBound();
  649.     pDoc->m_OperateObject.UnselectObject();
  650. Invalidate();
  651. delete pObjectType;
  652. delete pObjetcIndex;
  653. */
  654. }
  655. void CMiniCADView::OnUpdateChangeDelete(CCmdUI* pCmdUI) 
  656. {
  657. /*
  658. CMiniCADDoc* pDoc = GetDocument();
  659. if(pDoc->m_OperateObject.m_SelObjInfoArray.GetSize() > 0)
  660. pCmdUI->Enable(TRUE);
  661. else
  662. pCmdUI->Enable(FALSE);
  663. */
  664. }
  665. void CMiniCADView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo) 
  666. {
  667. // TODO: Add your specialized code here and/or call the base class
  668. CScrollView::OnPrepareDC(pDC, pInfo);
  669. }
  670. void CMiniCADView::OnModifyCopy() 
  671. {
  672. }
  673. void CMiniCADView::OnModifyCut() 
  674. {
  675. }
  676. void CMiniCADView::OnModifyCuttoangle() 
  677. {
  678. }
  679. void CMiniCADView::OnModifyLengthento() 
  680. {
  681. }
  682. void CMiniCADView::OnModifyJoin() 
  683. {
  684. }
  685. void CMiniCADView::OnModifyMirror() 
  686. {
  687. }
  688. void CMiniCADView::OnModifyVertical() 
  689. {
  690. }
  691. void CMiniCADView::OnModifyMove() 
  692. {
  693. }
  694. void CMiniCADView::OnModifyRotate() 
  695. {
  696.   
  697. }
  698. void CMiniCADView::OnModifyExcursion() 
  699. {
  700. }
  701. void CMiniCADView::OnEditCopy() 
  702. {
  703. }
  704. void CMiniCADView::OnEditCut() 
  705. {
  706. }
  707. void CMiniCADView::OnEditPaste() 
  708. {
  709. }
  710. BOOL CMiniCADView::OnScroll(UINT nScrollCode, UINT nPos, BOOL bDoScroll) 
  711. {
  712. // TODO: Add your specialized code here and/or call the base class
  713. return CScrollView::OnScroll(nScrollCode, nPos, bDoScroll);
  714. }