507 lines
13 KiB
C++
507 lines
13 KiB
C++
// optd2dto3ddlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "geomative.h"
|
|
#include "optd2dto3ddlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COpTd2DTo3DDlg dialog
|
|
extern HHOOK hHook;
|
|
extern LRESULT __stdcall CBTHookProc(long nCode, WPARAM wParam, LPARAM lParam);
|
|
|
|
COpTd2DTo3DDlg::COpTd2DTo3DDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(COpTd2DTo3DDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(COpTd2DTo3DDlg)
|
|
//}}AFX_DATA_INIT
|
|
m_pTdManager = NULL;
|
|
this->m_dwTzHandle = (DWORD)VAL_ZERO;
|
|
}
|
|
|
|
COpTd2DTo3DDlg::COpTd2DTo3DDlg(CTdManager* pTdManager, DWORD dwTzHandle, CWnd* pParent)
|
|
: CDialog(COpTd2DTo3DDlg::IDD, pParent)
|
|
{
|
|
m_pTdManager = pTdManager;
|
|
this->m_dwTzHandle = (DWORD)dwTzHandle;
|
|
}
|
|
|
|
void COpTd2DTo3DDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(COpTd2DTo3DDlg)
|
|
DDX_Control(pDX, IDC_TD_ROWSPACE, m_edRowSpace);
|
|
DDX_Control(pDX, IDC_TD_MEDIUM, m_cbMedium);
|
|
DDX_Control(pDX, IDC_TD_POLECOUNT, m_edPoleCount);
|
|
DDX_Control(pDX, IDC_TD_POLESPACE, m_edPoleSpace);
|
|
DDX_Control(pDX, IDC_TD_TITLE, m_edTitle);
|
|
DDX_Control(pDX, IDC_2D_TD_LIST, m_tdList);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(COpTd2DTo3DDlg, CDialog)
|
|
//{{AFX_MSG_MAP(COpTd2DTo3DDlg)
|
|
ON_BN_CLICKED(IDC_QUERY, OnQuery)
|
|
ON_BN_CLICKED(IDC_BTN_UP, OnBtnUp)
|
|
ON_BN_CLICKED(IDC_BTN_DOWN, OnBtnDown)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COpTd2DTo3DDlg message handlers
|
|
|
|
BOOL COpTd2DTo3DDlg::Create(UINT nID, CWnd* pParentWnd)
|
|
{
|
|
// TODO: Add your specialized code here and/or call the base class
|
|
pParentWnd->EnableWindow(FALSE);
|
|
return CDialog::Create(IDD, pParentWnd);
|
|
}
|
|
|
|
BOOL COpTd2DTo3DDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
// TODO: Add extra initialization here
|
|
CString strColTitle;
|
|
int iColIndex = (int)VAL_ZERO;
|
|
|
|
m_edPoleCount.SetLimitText(3);
|
|
m_edPoleCount.SetWindowText(_T("0"));
|
|
|
|
m_edTitle.SetLimitText(30);
|
|
|
|
m_edPoleSpace.SetIntLimitLen(3);
|
|
m_edPoleSpace.SetDecLimitLen(1);
|
|
m_edPoleSpace.SetWindowText(_T("0"));
|
|
|
|
m_edRowSpace.SetIntLimitLen(3);
|
|
m_edRowSpace.SetDecLimitLen(1);
|
|
m_edRowSpace.SetWindowText(_T("0"));
|
|
|
|
m_tdList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP
|
|
| LVS_EX_ONECLICKACTIVATE | LVS_EX_GRIDLINES | LVS_EX_CHECKBOXES);
|
|
|
|
iColIndex = (int)VAL_ZERO;
|
|
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_TDNAME);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 150);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_TLOCATION);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_DESN);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_SCCN);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_SNAME);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_STYPE);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_TTYPE);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_TMODE);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_EAMOUNT);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_TPAMOUNT);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_CHAMOUNT);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_N);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_TRWAVE);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_TRFREQUENCY);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_IFREQUENCY);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_SAFREQUENCY);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_CLAYOUT);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_ESPACE);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_EDISTANCE);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_WEATHER);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_WDIR);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_TEMPERATURE);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_HEIGHT);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_HUMIDITY);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_CDATE);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_CTIME);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_TDATE);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_TTIME);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_RDIRECTION);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_CRTIME);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_PM);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_OP);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_QA);
|
|
m_tdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
void COpTd2DTo3DDlg::OnOK()
|
|
{
|
|
// TODO: Add extra validation here
|
|
CString szValue = _T("");
|
|
CString szCaption = _T("");
|
|
int iRowSpace = (int)VAL_ZERO;
|
|
|
|
int iItemIndex = (int)VAL_ZERO;
|
|
int iCableCount = (int)VAL_ZERO;
|
|
|
|
szValue.Empty();
|
|
this->m_edRowSpace.GetWindowText(szValue);
|
|
iRowSpace = atoi(szValue);
|
|
|
|
if ((int)VAL_ZERO == iRowSpace)
|
|
{
|
|
szCaption.Empty();
|
|
szCaption.LoadString(IDS_CAPTION_0006);
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
MessageBox(szCaption);
|
|
return;
|
|
}
|
|
|
|
szValue.Empty();
|
|
this->m_edTitle.GetWindowText(szValue);
|
|
|
|
if (TRUE == szValue.IsEmpty())
|
|
{
|
|
szCaption.Empty();
|
|
szCaption.LoadString(IDS_CAPTION_0007);
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
MessageBox(szCaption);
|
|
return;
|
|
}
|
|
|
|
iItemIndex = (int)VAL_ZERO;
|
|
iCableCount = (int)VAL_ZERO;
|
|
|
|
while (iItemIndex < this->m_tdList.GetItemCount())
|
|
{
|
|
|
|
if (this->m_tdList.GetCheck(iItemIndex) == TRUE)
|
|
{
|
|
iCableCount ++;
|
|
}
|
|
iItemIndex ++;
|
|
}
|
|
|
|
if (iCableCount < 3)
|
|
{
|
|
szCaption.Empty();
|
|
szCaption.LoadString(IDS_CAPTION_0008);
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
MessageBox(szCaption);
|
|
return;
|
|
}
|
|
|
|
AfxGetMainWnd()->EnableWindow();
|
|
EndModalLoop(RET_OK);
|
|
|
|
CDialog::OnOK();
|
|
}
|
|
|
|
void COpTd2DTo3DDlg::OnCancel()
|
|
{
|
|
// TODO: Add extra cleanup here
|
|
AfxGetMainWnd()->EnableWindow();
|
|
EndModalLoop(RET_CANCEL);
|
|
|
|
CDialog::OnCancel();
|
|
}
|
|
|
|
void COpTd2DTo3DDlg::OnQuery()
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
int iAR = (int)VAL_ZERO;
|
|
int iEAmount = (int)VAL_ZERO;
|
|
float fEDistance = (float)VAL_ZERO;
|
|
CString szCaption = _T("");
|
|
|
|
CString szValue = _T("");
|
|
|
|
szValue.Empty();
|
|
this->m_edPoleCount.GetWindowText(szValue);
|
|
iEAmount = atoi(szValue);
|
|
|
|
if ((int)VAL_ZERO == iEAmount)
|
|
{
|
|
szCaption.Empty();
|
|
szCaption.LoadString(IDS_CAPTION_0004);
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
MessageBox(szCaption);
|
|
return;
|
|
}
|
|
|
|
szValue.Empty();
|
|
this->m_edPoleSpace.GetWindowText(szValue);
|
|
fEDistance = (float)atof(szValue);
|
|
|
|
if ((float)VAL_ZERO == fEDistance)
|
|
{
|
|
szCaption.Empty();
|
|
szCaption.LoadString(IDS_CAPTION_0003);
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
MessageBox(szCaption);
|
|
return;
|
|
}
|
|
|
|
if ((int)VAL_MINUS_ONE == this->m_cbMedium.GetCurSel())
|
|
{
|
|
szCaption.Empty();
|
|
szCaption.LoadString(IDS_CAPTION_0005);
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
MessageBox(szCaption);
|
|
return;
|
|
}
|
|
|
|
iAR = (int)this->m_cbMedium.GetItemData(this->m_cbMedium.GetCurSel());
|
|
|
|
m_pTdManager->ShowTd2DListByTz(m_dwTzHandle, iEAmount, fEDistance, iAR, this->m_tdList);
|
|
|
|
this->m_edPoleCount.EnableWindow(FALSE);
|
|
this->m_edPoleSpace.EnableWindow(FALSE);
|
|
this->m_cbMedium.EnableWindow(FALSE);
|
|
|
|
this->m_edTitle.EnableWindow(TRUE);
|
|
this->m_edRowSpace.EnableWindow(TRUE);
|
|
|
|
this->GetDlgItem(IDOK)->EnableWindow(TRUE);
|
|
|
|
this->GetDlgItem(IDC_BTN_UP)->EnableWindow(TRUE);
|
|
this->GetDlgItem(IDC_BTN_DOWN)->EnableWindow(TRUE);
|
|
}
|
|
|
|
void COpTd2DTo3DDlg::OnBtnUp()
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
int iIndex = (int)VAL_ZERO;
|
|
int iSubIndex = (int)VAL_ZERO;
|
|
|
|
int iColCount = (int)VAL_ZERO;
|
|
|
|
BOOL bIsSel = TRUE;
|
|
|
|
POSITION pos = NULL;
|
|
|
|
pos = NULL;
|
|
pos = this->m_tdList.GetFirstSelectedItemPosition();
|
|
|
|
if (NULL != pos)
|
|
{
|
|
iIndex = this->m_tdList.GetNextSelectedItem(pos);
|
|
|
|
|
|
if (iIndex > (int)VAL_ZERO)
|
|
{
|
|
bIsSel = this->m_tdList.GetCheck(iIndex);
|
|
|
|
iColCount = this->m_tdList.GetHeaderCtrl()->GetItemCount();
|
|
|
|
this->m_tdList.InsertItem(iIndex - 1, this->m_tdList.GetItemText(iIndex, 0));
|
|
|
|
iSubIndex = (int)VAL_ONE;
|
|
while (iSubIndex < iColCount)
|
|
{
|
|
this->m_tdList.SetItemText(iIndex - 1, iSubIndex, this->m_tdList.GetItemText(iIndex + 1, iSubIndex));
|
|
iSubIndex ++;
|
|
}
|
|
|
|
this->m_tdList.SetItemData(iIndex - 1, this->m_tdList.GetItemData(iIndex + 1));
|
|
this->m_tdList.DeleteItem(iIndex + 1);
|
|
|
|
this->m_tdList.SetItemState(iIndex - 1, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
|
|
this->m_tdList.SetCheck(iIndex - 1, bIsSel);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
MessageBox(_T("Please select testing data record!"));
|
|
return;
|
|
}
|
|
}
|
|
|
|
void COpTd2DTo3DDlg::OnBtnDown()
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
int iIndex = (int)VAL_ZERO;
|
|
int iSubIndex = (int)VAL_ZERO;
|
|
|
|
int iColCount = (int)VAL_ZERO;
|
|
BOOL bIsSel = TRUE;
|
|
|
|
POSITION pos = NULL;
|
|
CPoint ptMove;
|
|
|
|
pos = NULL;
|
|
pos = this->m_tdList.GetFirstSelectedItemPosition();
|
|
|
|
if (NULL != pos)
|
|
{
|
|
iIndex = this->m_tdList.GetNextSelectedItem(pos);
|
|
|
|
if (iIndex < (this->m_tdList.GetItemCount() - 1))
|
|
{
|
|
bIsSel = this->m_tdList.GetCheck(iIndex);
|
|
iColCount = this->m_tdList.GetHeaderCtrl()->GetItemCount();
|
|
|
|
this->m_tdList.InsertItem(iIndex + 2, this->m_tdList.GetItemText(iIndex, 0));
|
|
|
|
iSubIndex = (int)VAL_ONE;
|
|
while (iSubIndex < iColCount)
|
|
{
|
|
this->m_tdList.SetItemText(iIndex + 2, iSubIndex, this->m_tdList.GetItemText(iIndex, iSubIndex));
|
|
iSubIndex ++;
|
|
}
|
|
|
|
this->m_tdList.SetItemData(iIndex + 2, this->m_tdList.GetItemData(iIndex + 1));
|
|
this->m_tdList.DeleteItem(iIndex);
|
|
|
|
this->m_tdList.SetItemState(iIndex + 1, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
|
|
this->m_tdList.SetCheck(iIndex + 1, bIsSel);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
MessageBox(_T("Please select testing data record!"));
|
|
return;
|
|
}
|
|
}
|
|
|
|
BOOL COpTd2DTo3DDlg::PreTranslateMessage(MSG* pMsg)
|
|
{
|
|
// TODO: Add your specialized code here and/or call the base class
|
|
if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_RETURN)
|
|
{
|
|
return TRUE;
|
|
}
|
|
|
|
if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_ESCAPE)
|
|
{
|
|
return TRUE;
|
|
}
|
|
return CDialog::PreTranslateMessage(pMsg);
|
|
}
|