SelectPointDlg.cpp
Upload User: kairuinn
Upload Date: 2009-02-07
Package Size: 2922k
Code Size: 5k
Category:

Graph program

Development Platform:

Visual C++

  1. // SelectPointDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "..//..//Solidgraph.h"
  5. #include "SelectPointDlg.h"
  6. #include ".selectpointdlg.h"
  7. // CSelectPointDlg dialog
  8. IMPLEMENT_DYNAMIC(CSelectPointDlg, CDialog)
  9. CSelectPointDlg::CSelectPointDlg(CWnd* pParent /*=NULL*/)
  10. : CDialog(CSelectPointDlg::IDD, pParent)
  11. {
  12. m_enable_history = NULL;
  13. m_was_diasabled = false;
  14. }
  15. CSelectPointDlg::~CSelectPointDlg()
  16. {
  17. m_points.clear();
  18. if (m_enable_history)
  19. delete[] m_enable_history;
  20. }
  21. void CSelectPointDlg::DoDataExchange(CDataExchange* pDX)
  22. {
  23. CDialog::DoDataExchange(pDX);
  24. DDX_Control(pDX, IDC_SELECT_POINT_LIST, m_list);
  25. }
  26. BEGIN_MESSAGE_MAP(CSelectPointDlg, CDialog)
  27. ON_WM_SIZE()
  28. ON_NOTIFY(LVN_GETDISPINFO, IDC_SELECT_POINT_LIST, OnLvnGetdispinfoSelectPointList)
  29. ON_NOTIFY(NM_CLICK, IDC_SELECT_POINT_LIST, OnNMClickSelectPointList)
  30. ON_WM_ERASEBKGND()
  31. ON_BN_CLICKED(IDC_SELECT_POINT_FINISH_BUTTON, OnBnClickedSelectPointFinishButton)
  32. END_MESSAGE_MAP()
  33. IBaseInterfaceOfGetDialogs::DLG_TYPE CSelectPointDlg::GetType()
  34. {
  35. return IBaseInterfaceOfGetDialogs::SELECT_POINT_DLG;
  36. }
  37. CWnd*   CSelectPointDlg::GetWindow()
  38. {
  39. return this;
  40. }
  41. void    CSelectPointDlg::EnableControls(bool enbl)
  42. {
  43. if (m_enable_history==NULL)
  44. m_enable_history = new bool[2];
  45. if (enbl)
  46. {
  47. GetDlgItem(IDC_SELECT_POINT_LIST)->EnableWindow(m_enable_history[0]);
  48. GetDlgItem(IDC_SELECT_POINT_FINISH_BUTTON)->EnableWindow(m_enable_history[1]);
  49. m_was_diasabled = false;
  50. }
  51. else
  52. {
  53. if (!m_was_diasabled)
  54. {
  55. m_enable_history[0] = GetDlgItem(IDC_SELECT_POINT_LIST)->IsWindowEnabled()!=0;
  56. m_enable_history[1] = GetDlgItem(IDC_SELECT_POINT_FINISH_BUTTON)->IsWindowEnabled()!=0;
  57. }
  58. GetDlgItem(IDC_SELECT_POINT_LIST)->EnableWindow(FALSE);
  59. GetDlgItem(IDC_SELECT_POINT_FINISH_BUTTON)->EnableWindow(FALSE);
  60. m_was_diasabled = true;
  61. }
  62. Invalidate();
  63. }
  64. void   CSelectPointDlg::AddPoint(double xP,double yP,double zP)
  65. {
  66. PNTS tmpS;
  67. tmpS.pX = xP;
  68. tmpS.pY = yP;
  69. tmpS.pZ = zP;
  70. tmpS.pStr.Format("X=%f  Y=%f  Z=%f",xP,yP,zP);
  71. m_points.push_back(tmpS);
  72. m_list.SetItemCount(m_points.size());
  73. }
  74. void   CSelectPointDlg::RemoveAllPoints()
  75. {
  76. m_list.DeleteAllItems();
  77. m_points.clear();
  78. m_list.SetItemCount(0);
  79. }
  80. void   CSelectPointDlg::SetCurrentPoint(unsigned int ind)
  81. {
  82. if (ind>=m_points.size())
  83. return;
  84. m_list.SetItemState(ind, LVNI_SELECTED, LVNI_SELECTED);
  85. }
  86. unsigned int  CSelectPointDlg::GetCurrentPoint()
  87. {
  88. POSITION pos = m_list.GetFirstSelectedItemPosition();
  89. return m_list.GetNextSelectedItem(pos);
  90. }
  91. // CSelectPointDlg message handlers
  92. void CSelectPointDlg::OnCancel()
  93. {
  94. // TODO: Add your specialized code here and/or call the base class
  95. //CDialog::OnCancel();
  96. }
  97. void CSelectPointDlg::OnOK()
  98. {
  99. // TODO: Add your specialized code here and/or call the base class
  100. //CDialog::OnOK();
  101. }
  102. BOOL CSelectPointDlg::OnInitDialog()
  103. {
  104. CDialog::OnInitDialog();
  105. //m_list.SubclassDlgItem(IDC_SELECT_POINT_LIST, this);
  106. m_list.InsertColumn(0,"");
  107. CRect rct;
  108. m_list.GetWindowRect(rct);
  109. m_list.SetColumnWidth(0,rct.Width());
  110. // 朽琊屮噱