SelectPointDlg.cpp
上传用户:kairuinn
上传日期:2009-02-07
资源大小:2922k
文件大小:5k
- // SelectPointDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "..//..//Solidgraph.h"
- #include "SelectPointDlg.h"
- #include ".selectpointdlg.h"
- // CSelectPointDlg dialog
- IMPLEMENT_DYNAMIC(CSelectPointDlg, CDialog)
- CSelectPointDlg::CSelectPointDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CSelectPointDlg::IDD, pParent)
- {
- m_enable_history = NULL;
- m_was_diasabled = false;
- }
- CSelectPointDlg::~CSelectPointDlg()
- {
- m_points.clear();
- if (m_enable_history)
- delete[] m_enable_history;
- }
- void CSelectPointDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_SELECT_POINT_LIST, m_list);
- }
- BEGIN_MESSAGE_MAP(CSelectPointDlg, CDialog)
- ON_WM_SIZE()
- ON_NOTIFY(LVN_GETDISPINFO, IDC_SELECT_POINT_LIST, OnLvnGetdispinfoSelectPointList)
- ON_NOTIFY(NM_CLICK, IDC_SELECT_POINT_LIST, OnNMClickSelectPointList)
- ON_WM_ERASEBKGND()
- ON_BN_CLICKED(IDC_SELECT_POINT_FINISH_BUTTON, OnBnClickedSelectPointFinishButton)
- END_MESSAGE_MAP()
- IBaseInterfaceOfGetDialogs::DLG_TYPE CSelectPointDlg::GetType()
- {
- return IBaseInterfaceOfGetDialogs::SELECT_POINT_DLG;
- }
- CWnd* CSelectPointDlg::GetWindow()
- {
- return this;
- }
- void CSelectPointDlg::EnableControls(bool enbl)
- {
- if (m_enable_history==NULL)
- m_enable_history = new bool[2];
- if (enbl)
- {
- GetDlgItem(IDC_SELECT_POINT_LIST)->EnableWindow(m_enable_history[0]);
- GetDlgItem(IDC_SELECT_POINT_FINISH_BUTTON)->EnableWindow(m_enable_history[1]);
- m_was_diasabled = false;
- }
- else
- {
- if (!m_was_diasabled)
- {
- m_enable_history[0] = GetDlgItem(IDC_SELECT_POINT_LIST)->IsWindowEnabled()!=0;
- m_enable_history[1] = GetDlgItem(IDC_SELECT_POINT_FINISH_BUTTON)->IsWindowEnabled()!=0;
- }
- GetDlgItem(IDC_SELECT_POINT_LIST)->EnableWindow(FALSE);
- GetDlgItem(IDC_SELECT_POINT_FINISH_BUTTON)->EnableWindow(FALSE);
- m_was_diasabled = true;
- }
- Invalidate();
- }
- void CSelectPointDlg::AddPoint(double xP,double yP,double zP)
- {
- PNTS tmpS;
- tmpS.pX = xP;
- tmpS.pY = yP;
- tmpS.pZ = zP;
-
- tmpS.pStr.Format("X=%f Y=%f Z=%f",xP,yP,zP);
- m_points.push_back(tmpS);
- m_list.SetItemCount(m_points.size());
- }
- void CSelectPointDlg::RemoveAllPoints()
- {
- m_list.DeleteAllItems();
- m_points.clear();
- m_list.SetItemCount(0);
- }
- void CSelectPointDlg::SetCurrentPoint(unsigned int ind)
- {
- if (ind>=m_points.size())
- return;
- m_list.SetItemState(ind, LVNI_SELECTED, LVNI_SELECTED);
- }
- unsigned int CSelectPointDlg::GetCurrentPoint()
- {
- POSITION pos = m_list.GetFirstSelectedItemPosition();
- return m_list.GetNextSelectedItem(pos);
- }
- // CSelectPointDlg message handlers
- void CSelectPointDlg::OnCancel()
- {
- // TODO: Add your specialized code here and/or call the base class
- //CDialog::OnCancel();
- }
- void CSelectPointDlg::OnOK()
- {
- // TODO: Add your specialized code here and/or call the base class
- //CDialog::OnOK();
- }
- BOOL CSelectPointDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- //m_list.SubclassDlgItem(IDC_SELECT_POINT_LIST, this);
- m_list.InsertColumn(0,"");
- CRect rct;
- m_list.GetWindowRect(rct);
- m_list.SetColumnWidth(0,rct.Width());
- // 朽琊屮噱