Files
geomative/GeomativeStudio/cpp/Views/opcreatesptdlg.cpp
T
coco df489d5640 a
2026-07-03 16:05:30 +08:00

1899 lines
58 KiB
C++

// opcreatesptdlg.cpp : implementation file
//
#include "stdafx.h"
#include "geomative.h"
#include "opcreatesptdlg.h"
#include "Constant.h"
#include "DialCustomSptInput.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define WM_UPDATEFIELDS WM_APP + 1
extern BOOL DoEvent(HWND hWnd);
extern HHOOK hHook;
extern LRESULT __stdcall CBTHookProc(long nCode, WPARAM wParam, LPARAM lParam);
extern bool IsExistSpecialChar(const CString &strFileName);
extern bool bIsInteger(CString strTxt);
extern bool bIsFloat(CString strTxt);
extern int g_iUILanguage;
extern int g_UIOffset;
extern CGeoMativeApp theApp;
/////////////////////////////////////////////////////////////////////////////
// COpCreateSptDlg dialog
//COpCreateSptDlg::COpCreateSptDlg(CWnd* pParent /*=NULL*/)
// : CDialog(COpCreateSptDlg::IDD, pParent)
//{
// //{{AFX_DATA_INIT(COpCreateSptDlg)
// m_cbAR = -1;
// m_cbCHamount = -1;
// m_dtpDEdate = 0;
// m_edDefiner = _T("");
// m_Eamount = -1;
// m_edSCdesc = _T("");
// m_edSname = _T("");
// m_lbChnumber = _T("");
// //}}AFX_DATA_INIT
//}
COpCreateSptDlg::COpCreateSptDlg(CScript2D* pNewScript, CLinkList<CMedium*>* pMedLinkList, INT_PTR* pRet, CWnd* pParent /*=NULL*/)
: CDialog(COpCreateSptDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(COpCreateSptDlg)
m_edDeDate = CTime::GetCurrentTime();
m_iStartLayer = 0;
m_iEndLayer = 0;
m_strStartLayer = _T("");
m_strEndLayer = _T("");
//}}AFX_DATA_INIT
m_pRet = pRet;
m_pNewScript = pNewScript;
m_pOpCreateSptFrame = NULL;
m_pMedLinkList = pMedLinkList;
m_pOpCreateSptView = NULL;
// m_pOpCreateSptInfoView = NULL;
m_pOpCreateSptRecListView = NULL;
m_strStartLayer = _T("0");
m_strEndLayer = _T("0");
m_fDipoleSep = 1;
}
void COpCreateSptDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(COpCreateSptDlg)
DDX_Control(pDX, IDC_SPT_AR_RUN_METHOD, m_cmbArRunMethod);
DDX_Control(pDX, IDC_COMBO_MN_CTRL, m_cmbMNCtrl);
DDX_Control(pDX, IDC_TAB_OP_TP, m_tpTab);
DDX_DateTimeCtrl(pDX, IDC_SPT_DEDATE, m_edDeDate);
DDX_Text(pDX, IDC_EDIT_START_LAYER, m_strStartLayer);
DDX_Text(pDX, IDC_EDIT_END_LAYER, m_strEndLayer);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(COpCreateSptDlg, CDialog)
//{{AFX_MSG_MAP(COpCreateSptDlg)
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB_OP_TP, OnSelchangeTabOpTp)
ON_CBN_SELCHANGE(IDC_SPT_CHAMOUNT, OnSelchangeSptChamount)
ON_CBN_SELCHANGE(IDC_SPT_AR, OnSelchangeSptAr)
// ON_CBN_SELCHANGE(IDC_SPT_EAMOUNT, OnSelchangeSptEamount)
ON_BN_CLICKED(IDC_GEN, OnGen)
ON_WM_SIZE()
ON_BN_CLICKED(IDC_BUTTON_LAYER_FILTER, OnButtonLayerFilter)
ON_CBN_SELCHANGE(IDC_COMBO_MN_CTRL, OnSelchangeComboMnCtrl)
ON_MESSAGE(WM_UPDATEFIELDS, UpdateDisplay)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//BEGIN_EASYSIZE_MAP(COpCreateSptDlg)
//BASIC_INFO
//SYSIZE(IDC_STATIC_BASIC_INFOR,ES_BORDER,ES_BORDER,ES_BORDER,ES_KEEPSIZE,0)
//EASYSIZE(IDC_STATIC_SCRIPTNAME,ES_BORDER,ES_BORDER,ES_BORDER,ES_KEEPSIZE,0)
// EASYSIZE(IDC_STATIC_DATE,IDC_STATIC_SCRIPTNAME,IDC_STATIC_BASIC_INFOR,ES_KEEPSIZE,ES_KEEPSIZE,0)
// EASYSIZE(IDC_SPT_SNAME,ES_KEEPSIZE,IDC_STATIC_SCRIPTNAME,IDC_STATIC_BASIC_INFOR,ES_KEEPSIZE,0)
// EASYSIZE(IDC_SPT_DEDATE,IDC_SPT_SNAME,IDC_STATIC_DATE,ES_KEEPSIZE,ES_KEEPSIZE,0)
// EASYSIZE(IDC_STATIC_SPT_OPERATOR,ES_KEEPSIZE,IDC_SPT_SNAME,IDC_STATIC_BASIC_INFOR,ES_KEEPSIZE,0)
// EASYSIZE(IDC_STATIC_SPT_SEPRATE,IDC_STATIC_SPT_OPERATOR,IDC_SPT_DEDATE,ES_KEEPSIZE,ES_KEEPSIZE,0)
// EASYSIZE(IDC_SPT_DEFINER,ES_KEEPSIZE,IDC_STATIC_SPT_OPERATOR,IDC_STATIC_BASIC_INFOR,ES_KEEPSIZE,0)
// EASYSIZE(IDC_EDIT_SPT_SEPRATE,IDC_SPT_DEFINER,IDC_STATIC_SPT_SEPRATE,ES_KEEPSIZE,ES_KEEPSIZE,0)
// EASYSIZE(IDC_STATIC_SPT_REMARK,ES_KEEPSIZE,IDC_SPT_DEFINER,IDC_STATIC_BASIC_INFOR,ES_KEEPSIZE,0)
// EASYSIZE(IDC_SPT_SCDESC,ES_KEEPSIZE,IDC_STATIC_SPT_REMARK,IDC_STATIC_BASIC_INFOR,ES_KEEPSIZE,0)
//Channel_info
// EASYSIZE(IDC_STATIC_CHANNEL_INFO,IDC_STATIC_BASIC_INFOR,ES_BORDER,ES_KEEPSIZE,ES_KEEPSIZE,0)
// EASYSIZE(IDC_STATIC_SPT_ELECT_NUMBER,ES_KEEPSIZE,IDC_STATIC_CHANNEL_INFO,IDC_STATIC_CHANNEL_INFO,ES_KEEPSIZE,0)
// EASYSIZE(IDC_SPT_EAMOUNT,ES_KEEPSIZE,IDC_STATIC_SPT_ELECT_NUMBER,IDC_STATIC_CHANNEL_INFO,ES_KEEPSIZE,0)
// EASYSIZE(IDC_STATIC_SPT_CHANNEL_NUMBER,ES_KEEPSIZE,IDC_SPT_EAMOUNT,IDC_STATIC_CHANNEL_INFO,ES_KEEPSIZE,0)
// EASYSIZE(IDC_SPT_CHAMOUNT,ES_KEEPSIZE,IDC_STATIC_SPT_CHANNEL_NUMBER,IDC_STATIC_CHANNEL_INFO,ES_KEEPSIZE,0)
// EASYSIZE(IDC_STATIC_SPT_ARRAY,ES_KEEPSIZE,IDC_SPT_CHAMOUNT,IDC_STATIC_CHANNEL_INFO,ES_KEEPSIZE,0)
// EASYSIZE(IDC_SPT_AR,ES_KEEPSIZE,IDC_STATIC_SPT_ARRAY,IDC_STATIC_CHANNEL_INFO,ES_KEEPSIZE,0)
// EASYSIZE(IDC_STATIC_SPT_CHANL_INDEX,IDC_STATIC_SPT_ELECT_NUMBER,IDC_STATIC_CHANNEL_INFO,ES_KEEPSIZE,ES_KEEPSIZE,0)
// EASYSIZE(IDC_SPT_CHNUMBER,IDC_SPT_EAMOUNT,IDC_STATIC_SPT_CHANL_INDEX,ES_KEEPSIZE,ES_KEEPSIZE,0)
//Poing filter
// EASYSIZE(IDC_STATIC_POINTFILTER,IDC_STATIC_CHANNEL_INFO,ES_BORDER,ES_KEEPSIZE,ES_KEEPSIZE,0)
// EASYSIZE(IDC_TAB_OP_TP,ES_KEEPSIZE,IDC_STATIC_POINTFILTER,IDC_STATIC_POINTFILTER,ES_KEEPSIZE,0)
// EASYSIZE(IDC_STATIC_LAYER_FILTERINFO,ES_KEEPSIZE,IDC_TAB_OP_TP,IDC_STATIC_POINTFILTER,ES_KEEPSIZE,0)
// EASYSIZE(IDC_STATIC_LAYER_SHOW,ES_KEEPSIZE,IDC_STATIC_LAYER_FILTERINFO,IDC_STATIC_LAYER_FILTERINFO,ES_KEEPSIZE,0)
// EASYSIZE(IDC_EDIT_START_LAYER,IDC_STATIC_LAYER_SHOW,IDC_STATIC_LAYER_FILTERINFO,ES_KEEPSIZE,ES_KEEPSIZE,0)
// EASYSIZE(IDC_STATIC_LAYER_SEPRATE,IDC_EDIT_START_LAYER,IDC_STATIC_LAYER_FILTERINFO,ES_KEEPSIZE,ES_KEEPSIZE,0)
// EASYSIZE(IDC_EDIT_END_LAYER,IDC_STATIC_LAYER_SEPRATE,IDC_STATIC_LAYER_FILTERINFO,ES_KEEPSIZE,ES_KEEPSIZE,0)
// EASYSIZE(IDC_BUTTON_LAYER_FILTER,IDC_STATIC_LAYER_FILTERINFO,ES_KEEPSIZE,IDC_STATIC_LAYER_FILTERINFO,IDC_STATIC_LAYER_FILTERINFO,ES_HCENTER)
//Script frame
//SYSIZE(IDC_STATIC_FRAME,ES_BORDER,ES_KEEPSIZE,ES_KEEPSIZE,ES_BORDER,0)
//Button
// EASYSIZE(IDC_GEN,IDC_STATIC_POINTFILTER,ES_BORDER,ES_KEEPSIZE,ES_KEEPSIZE,0)
// EASYSIZE(IDOK,IDC_STATIC_POINTFILTER,IDC_GEN,ES_KEEPSIZE,ES_KEEPSIZE,0)
// EASYSIZE(IDCANCEL,IDC_STATIC_POINTFILTER,IDOK,ES_KEEPSIZE,ES_KEEPSIZE,0)
//END_EASYSIZE_MAP
/////////////////////////////////////////////////////////////////////////////
// COpCreateSptDlg message handlers
LRESULT COpCreateSptDlg::UpdateDisplay(WPARAM wParam, LPARAM lParam)
{
UpdateData((BOOL)wParam);
return 0;
}
BOOL COpCreateSptDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_bIsShowLayerFilter = false;
int iCAmount = (int)VAL_ZERO;
int iCHAmount = (int)VAL_ZERO;
m_fSptSeprate = 1;
m_pChannel = NULL;
m_vtListOrder.clear();
CString szLabel = _T("");
CTabCtrl* pTpTab = NULL;
CRect rect;
CRect recDlg;
// CComboBox* pCbEAmount = NULL;
CComboBox* pCbCHAmount = NULL;
CListBox* pLbChNumber = NULL;
((CEdit*)GetDlgItem(IDC_SPT_SNAME))->SetLimitText(20);
((CEdit*)GetDlgItem(IDC_SPT_DEFINER))->SetLimitText(20);
((CEdit*)GetDlgItem(IDC_SPT_SCDESC))->SetLimitText(50);
GetDlgItem(IDC_STATIC_SPT_SEPRATE)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_EDIT_SPT_SEPRATE)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_CHECK_STRONG_GRADIENT_SWITCH)->ShowWindow(SW_HIDE);
szLabel.Empty();
szLabel.LoadString(IDS_SPT_TP_SEL);
ASSERT(!szLabel.IsEmpty());
m_tpTab.InsertItem(TAB_INDEX_TP_SEL, szLabel);
szLabel.Empty();
szLabel.LoadString(IDS_SPT_TP_SORT);
ASSERT(!szLabel.IsEmpty());
m_tpTab.InsertItem(TAB_INDEX_TP_SORT, szLabel);
m_opSelSptTpDlg.Create(IDD_OP_SPT_TP_SEL, GetDlgItem(IDC_TAB_OP_TP));
m_opSortSptTpDlg.Create(IDD_OP_SPT_TP_SORT, GetDlgItem(IDC_TAB_OP_TP));
pTpTab = (CTabCtrl*)GetDlgItem(IDC_TAB_OP_TP);
if ((NULL != pTpTab) && (VAL_ZERO != m_opSelSptTpDlg.GetSafeHwnd()) && (VAL_ZERO != m_opSortSptTpDlg.GetSafeHwnd()))
{
CRect rect;
pTpTab->GetClientRect(&rect);
rect.top += 23;
rect.bottom -= 4;
rect.left += 4;
rect.right -= 4;
m_opSelSptTpDlg.MoveWindow(&rect);
m_opSortSptTpDlg.MoveWindow(&rect);
}
pTpTab = NULL;
m_opSelSptTpDlg.ShowWindow(true);
m_opSortSptTpDlg.ShowWindow(false);
this->ShowWindow(SW_MAXIMIZE);
CRect rcStaticWnd;
CWnd* pStaticWnd = GetDlgItem(IDC_STATIC_2D_SPT_BASIC_INFO);
if (pStaticWnd != NULL)
{
pStaticWnd->GetClientRect(&rcStaticWnd);
}
CRect rcClient;
GetClientRect(&rcClient);
CWnd *pStatic = GetDlgItem(IDC_STATIC_FRAME);
if (pStatic != NULL)
{
rcClient.top = rcStaticWnd.bottom +5;
rcClient.left += 10;
rcClient.right -= 10;
rcClient.bottom -= 20;
pStatic->MoveWindow(&rcClient);
}
m_pOpCreateSptFrame = (COpCreateSptFrame*)((CRuntimeClass*)RUNTIME_CLASS(COpCreateSptFrame))->CreateObject();
m_pOpCreateSptFrame->Create(NULL, NULL, WS_CHILD, rcClient, this);
//m_pOpCreateSptFrame->MoveWindow(&rect);
//m_pOpCreateSptFrame->ShowWindow(SW_SHOW);
// pCbEAmount = (CComboBox*)(GetDlgItem(IDC_SPT_EAMOUNT));
// pCbEAmount->ResetContent();
// for (iCAmount = (int)VAL_ONE; iCAmount <= CABLE_AMOUNT; iCAmount++)
// {
// szLabel.Empty();
// szLabel.Format(_T("%d"), iCAmount*ELECTRODE_AMOUNT_PERCABLE);
// pCbEAmount->AddString(szLabel);
// pCbEAmount->SetItemData(pCbEAmount->GetCount()-1, iCAmount*ELECTRODE_AMOUNT_PERCABLE);
// }
GetDlgItem(IDC_SPT_EAMOUNT)->SetWindowText(_T("0"));
pCbCHAmount = (CComboBox*)(GetDlgItem(IDC_SPT_CHAMOUNT));
pCbCHAmount->ResetContent();
for (iCHAmount = (int)VAL_ONE; iCHAmount <= CHANNEL_AMOUNT; iCHAmount++)
{
szLabel.Empty();
szLabel.Format(_T("%d"), iCHAmount);
pCbCHAmount->AddString(szLabel);
pCbCHAmount->SetItemData(pCbCHAmount->GetCount()-1, iCHAmount);
}
pCbCHAmount->SetCurSel((int)VAL_ZERO);
pLbChNumber = (CListBox*)(GetDlgItem(IDC_SPT_CHNUMBER));
OnSelchangeSptChamount();
pLbChNumber->SetCurSel((int)VAL_ZERO);
pCbCHAmount->EnableWindow(FALSE);
CChannel* pChannel = new CChannel;
pChannel->m_iChNumber = (int)VAL_ONE;
m_pNewScript->m_chaList.AddTail((void*)pChannel);
m_pOpCreateSptView = (COpCreateSptView*)(((COpCreateSptFrame*)(this->m_pOpCreateSptFrame))->m_pOpCreateSptView);
// m_pOpCreateSptInfoView = (COpCreateSptInfoView*)(((COpCreateSptFrame*)(this->m_pOpCreateSptFrame))->m_pOpCreateSptInfoView);
m_pOpCreateSptRecListView = (COpCreateSptRecListView*)(((COpCreateSptFrame*)(this->m_pOpCreateSptFrame))->m_pOpCreateSptRecListView);
m_pOpCreateSptFrame->MoveWindow(&rcClient);
m_pOpCreateSptFrame->ShowWindow(SW_SHOW);
//屏蔽点过滤
GetDlgItem(IDC_STATIC_PT_FILTER)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_TAB_OP_TP)->ShowWindow(SW_HIDE);
m_cmbMNCtrl.ResetContent();
m_cmbMNCtrl.AddString(_T("Fixed"));
m_cmbMNCtrl.AddString(_T("Auto"));
m_cmbMNCtrl.SetCurSel(0);
GetDlgItem(IDC_STATIC_MN_CTRL)->SetWindowText(_T("*MN Space Control:"));
GetDlgItem(IDC_STATIC_MN_SPACE)->SetWindowText(_T("*MN Space:"));
GetDlgItem(IDC_STATIC_MN_CTRL)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_COMBO_MN_CTRL)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATIC_MN_SPACE)->ShowWindow(SW_HIDE);
ShowLayerFilterInfo(FALSE);
InitUIByLanguage(g_iUILanguage);
//加入跑极方式
m_cmbArRunMethod.ResetContent();
if (LANG_ZHCN == g_iUILanguage)
{
m_cmbArRunMethod.AddString(_T("乱序"));
m_cmbArRunMethod.AddString(_T("按层"));
m_cmbArRunMethod.AddString(_T("按滚动"));
}
else
{
m_cmbArRunMethod.AddString(_T("Disorder"));
m_cmbArRunMethod.AddString(_T("By layer"));
m_cmbArRunMethod.AddString(_T("By rolling section"));
SetDlgItemText(IDC_CHECK_STRONG_GRADIENT_SWITCH, _T("reverse"));
}
m_cmbArRunMethod.SetCurSel(0);
GetDlgItem(IDC_STATIC_2D_SPT_CHANNEL_NUM)->SetWindowText(_T("Channel Index"));
GetDlgItem(IDC_SPT_CHAMOUNT)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATIC_2D_SPT_CHANNEL_INDEX)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_SPT_CHNUMBER)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_SPT_PARAM_A)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_SPT_PARAM_N)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATIC_2D_SPT_A)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATIC_2D_SPT_N)->ShowWindow(SW_HIDE);
if (EN_MULTI_CHANNEL == theApp.m_ucIsMultiChannel)
GetDlgItem(IDC_EDIT_SIG_CHANNEL)->SetWindowText(_T("Multi-Channel\r\nOnly"));
else
GetDlgItem(IDC_EDIT_SIG_CHANNEL)->SetWindowText(_T("Single-Channel\r\nOnly"));
GetDlgItem(IDC_STATIC_START_ELEC_NUMBER)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_EDIT_START_ELECTRODE_ID)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATIC_N_MIN)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_EDIT_N_MIN)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATIC_N_MAX)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_EDIT_N_MAX)->ShowWindow(SW_HIDE);
// INIT_EASYSIZE;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void COpCreateSptDlg::OnSelchangeTabOpTp(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
int iCurSel = VAL_MINUS_ONE;
iCurSel = m_tpTab.GetCurSel();
switch (iCurSel)
{
case TAB_INDEX_TP_SEL:
m_opSelSptTpDlg.ShowWindow(true);
m_opSelSptTpDlg.ShowWindow(false);
break;
case TAB_INDEX_TP_SORT:
m_opSelSptTpDlg.ShowWindow(false);
m_opSelSptTpDlg.ShowWindow(true);
break;
default:
break;
}
m_tpTab.SetFocus();
*pResult = VAL_ZERO;
}
void COpCreateSptDlg::OnOK()
{
// TODO: Add extra validation here
int iArrayCnt = m_pChannel->m_sptRecArray.GetSize();
bool bIsSelPt = false;
CSptRecord* pSptRecord = NULL;
for (int i = 0; i < iArrayCnt; i++)
{
pSptRecord = (CSptRecord*)m_pChannel->m_sptRecArray.GetAt(i);
if (pSptRecord->m_bIsSel)
{
bIsSelPt = true;
break;
}
}
if (!bIsSelPt)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("脚本的测点数不能为0"));
else
MessageBoxEx(NULL, _T("The number of point in the script can not be zero"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return;
}
CString szSName = _T("");
CString szCaption = _T("");
this->GetDlgItem(IDC_SPT_SNAME)->GetWindowText(szSName);
szSName.TrimLeft();
szSName.TrimRight();
if (_T("") == szSName)
{
szCaption.Empty();
szCaption.LoadString(IDS_OP_LC_SCON_INPUT_SNAME+g_UIOffset);
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
MessageBox(szCaption, NULL, MB_ICONWARNING);
this->GetDlgItem(IDC_SPT_SNAME)->SetFocus();
}
else
{
if (IsExistSpecialChar(szSName))
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("脚本名中含有特殊字符,请重新输入"));
else
MessageBoxEx(NULL, _T("There are some special charcter in script name,please rename it!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return;
}
AfxGetMainWnd()->EnableWindow();
if (!UpdateData(TRUE))
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("更新失败"));
else
MessageBoxEx(NULL, _T("Updatedata failed!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
}
*m_pRet = 1;
this->EndModalLoop(*m_pRet); //结束非模态对话框模态循环
}
// CDialog::OnOK();
}
void COpCreateSptDlg::OnCancel()
{
// TODO: Add extra cleanup here
if (m_pOpCreateSptRecListView->GetListCtrl().GetItemCount() > 0)
{
//All data in the list would be deleted if you close dialog without save!\r\n")
// _T("Do you want to continue to close dialog
int nRet = 0;
if (LANG_ZHCN == g_iUILanguage)
nRet = AfxMessageBox(_T("是否取消脚本创建?"), MB_YESNO | MB_ICONINFORMATION);
else
nRet = MessageBoxEx(NULL, _T("Do you want to cancel the script?"), STRING_MESSAGEBOXEX_TITLE, MB_YESNO | MB_ICONINFORMATION, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
if (IDYES != nRet)
{
return;
}
}
CListBox* pLbChNumber = (CListBox*)GetDlgItem(IDC_SPT_CHNUMBER);
POSITION pos = m_pNewScript->m_chaList.FindIndex(pLbChNumber->GetCurSel());
CChannel* pChannel = (CChannel*)m_pNewScript->m_chaList.GetAt(pos);
if (pChannel->m_sptRecArray.GetSize() == m_pOpCreateSptRecListView->GetListCtrl().GetItemCount())
{
pChannel->ClearSptRecList();
AfxGetMainWnd()->EnableWindow();
*m_pRet = 2;
this->EndModalLoop(*m_pRet); //结束非模态对话框模态循环
}
// CDialog::OnCancel();
}
BOOL COpCreateSptDlg::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);
}
void COpCreateSptDlg::OnSelchangeSptChamount()
{
// TODO: Add your control notification handler code here
CString szLabel = _T("");
CListBox* pLbChNumber = (CListBox*)GetDlgItem(IDC_SPT_CHNUMBER);
CComboBox* pCbChAmount = (CComboBox*)(GetDlgItem(IDC_SPT_CHAMOUNT));
int iChNumber = (int)VAL_ONE;
int iChAmount = pCbChAmount->GetItemData(pCbChAmount->GetCurSel());
// UpdateData(TRUE);
pLbChNumber->ResetContent();
while (iChNumber <= iChAmount)
{
szLabel.Empty();
szLabel.Format(_T("%d"), iChNumber);
pLbChNumber->AddString(szLabel);
pLbChNumber->SetItemData(pLbChNumber->GetCount()-1, iChNumber);
iChNumber++;
}
// UpdateData(FALSE);
pLbChNumber->EnableWindow(FALSE);
}
void COpCreateSptDlg::OnSelchangeSptAr()
{
// TODO: Add your control notification handler code here
CComboBox* pCbAR = (CComboBox*)GetDlgItem(IDC_SPT_AR);
int nCurl = pCbAR->GetCurSel();
GetDlgItem(IDC_STATIC_SPT_SEPRATE)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_EDIT_SPT_SEPRATE)->ShowWindow(SW_HIDE);
if ((int)VAL_MINUS_ONE == nCurl)
{
return;
}
int iAR = pCbAR->GetItemData(nCurl);
//加强梯度,是否逆向排序开关
if (AR_STRONG_GRADIENT == iAR)
{
GetDlgItem(IDC_CHECK_STRONG_GRADIENT_SWITCH)->ShowWindow(SW_SHOW);
}
else
{
GetDlgItem(IDC_CHECK_STRONG_GRADIENT_SWITCH)->ShowWindow(SW_HIDE);
}
if (AR_CROSS_HOLE_TYPE == iAR)
{
CString strTmp = _T("");
strTmp.Format(_T("%.2f"), m_fSptSeprate);
// GetDlgItem(IDC_STATIC_SPT_SEPRATE)->ShowWindow(SW_SHOW);
// GetDlgItem(IDC_EDIT_SPT_SEPRATE)->ShowWindow(SW_SHOW);
// GetDlgItem(IDC_EDIT_SPT_SEPRATE)->SetWindowText(strTmp);
m_cmbArRunMethod.SetCurSel(0);
m_cmbArRunMethod.EnableWindow(FALSE);
}
else if (AR_CUSTOM_2D_TYPE == iAR ||
AR_EDGE_GARDIENT == iAR ||
AR_BIPOLE_HOLE_SPT == iAR ||
AR_DOUBLE_SIZE_3P == iAR)
{
m_cmbArRunMethod.SetCurSel(0);
m_cmbArRunMethod.EnableWindow(FALSE);
}
else
{
m_cmbArRunMethod.EnableWindow(TRUE);
m_cmbArRunMethod.SetCurSel(0);
}
if (AR_SCHLUMBERGER == iAR)
{
GetDlgItem(IDC_STATIC_MN_CTRL)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_COMBO_MN_CTRL)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_EDIT_SPT_SEPRATE)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_STATIC_MN_SPACE)->ShowWindow(SW_SHOW);
if (0 == m_cmbMNCtrl.GetCurSel())
GetDlgItem(IDC_EDIT_SPT_SEPRATE)->SetWindowText("1");
else
GetDlgItem(IDC_EDIT_SPT_SEPRATE)->SetWindowText("6");
}
else
{
if (AR_BIPOLE_HOLE_SPT == iAR)
{
if (LANG_ZHCN == g_iUILanguage)
GetDlgItem(IDC_STATIC_SPT_SEPRATE)->SetWindowText(_T(" *表面电极数"));
else
GetDlgItem(IDC_STATIC_SPT_SEPRATE)->SetWindowText(_T("*Surface Electrode number"));
GetDlgItem(IDC_STATIC_SPT_SEPRATE)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_EDIT_SPT_SEPRATE)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_EDIT_SPT_SEPRATE)->SetWindowText(_T("0"));
}
else if (AR_DOUBLE_SIZE_3P == iAR)
{
if (LANG_ZHCN == g_iUILanguage)
GetDlgItem(IDC_STATIC_SPT_SEPRATE)->SetWindowText(_T(" *间隔系数"));
else
GetDlgItem(IDC_STATIC_SPT_SEPRATE)->SetWindowText(_T("*Interval Coffient"));
GetDlgItem(IDC_STATIC_SPT_SEPRATE)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_EDIT_SPT_SEPRATE)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_EDIT_SPT_SEPRATE)->SetWindowText(_T("1"));
}
else if (AR_DIP_DIP == iAR)
{
if (LANG_ZHCN == g_iUILanguage)
GetDlgItem(IDC_STATIC_SPT_SEPRATE)->SetWindowText(_T(" *偶极距离因子"));
else
GetDlgItem(IDC_STATIC_SPT_SEPRATE)->SetWindowText(_T(" *Spacing Units"));
GetDlgItem(IDC_STATIC_SPT_SEPRATE)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_EDIT_SPT_SEPRATE)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_EDIT_SPT_SEPRATE)->SetWindowText(_T("6"));
}
GetDlgItem(IDC_STATIC_MN_CTRL)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_COMBO_MN_CTRL)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATIC_MN_SPACE)->ShowWindow(SW_HIDE);
}
//进行单通道和多通道的提示显示
if((iAR >0 && iAR < 4) || 11 == iAR || 39 == iAR || AR_WENNER_SCH_BASIC == iAR)
{
if (EN_MULTI_CHANNEL == theApp.m_ucIsMultiChannel)
GetDlgItem(IDC_EDIT_SIG_CHANNEL)->SetWindowText(_T("Multi-Channel\r\nOnly"));
else
GetDlgItem(IDC_EDIT_SIG_CHANNEL)->SetWindowText(_T("Single-Channel\r\nOnly"));
m_cmbArRunMethod.EnableWindow(TRUE);
}
else
{
m_cmbArRunMethod.SetCurSel(0);
if (EN_MULTI_CHANNEL == theApp.m_ucIsMultiChannel)
{
GetDlgItem(IDC_EDIT_SIG_CHANNEL)->SetWindowText(_T("Multi-Channel\r\nOr\r\nSingle-Channel"));
m_cmbArRunMethod.EnableWindow(FALSE);
}
else
{
GetDlgItem(IDC_EDIT_SIG_CHANNEL)->SetWindowText(_T("Single-Channel\r\nOnly"));
if ((iAR > 3 && iAR < 7)||iAR == 9)
m_cmbArRunMethod.EnableWindow(TRUE);
}
}
//三极装置增加a、n参数输入
if (AR_POLE_DIPOLE_AMN == iAR || AR_DIPOLE_POLE_MNB == iAR)
{
GetDlgItem(IDC_SPT_PARAM_A)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_SPT_PARAM_N)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_SPT_PARAM_A)->SetWindowTextA(_T("8"));
GetDlgItem(IDC_SPT_PARAM_N)->SetWindowTextA(_T("10"));
GetDlgItem(IDC_STATIC_2D_SPT_A)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_STATIC_2D_SPT_N)->ShowWindow(SW_SHOW);
}
else
{
GetDlgItem(IDC_SPT_PARAM_A)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_SPT_PARAM_N)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATIC_2D_SPT_A)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATIC_2D_SPT_N)->ShowWindow(SW_HIDE);
}
if (AR_S3P_MEDIUM == iAR)
{
GetDlgItem(IDC_STATIC_START_ELEC_NUMBER)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_EDIT_START_ELECTRODE_ID)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_STATIC_N_MIN)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_EDIT_N_MIN)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_STATIC_N_MAX)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_EDIT_N_MAX)->ShowWindow(SW_SHOW);
}
else
{
GetDlgItem(IDC_STATIC_START_ELEC_NUMBER)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_EDIT_START_ELECTRODE_ID)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATIC_N_MIN)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_EDIT_N_MIN)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATIC_N_MAX)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_EDIT_N_MAX)->ShowWindow(SW_HIDE);
}
/*
CString szCaption = _T("");
CMedium* pMedium = NULL;
CSptRecord* pSptRecord = NULL;
CListBox* pLbChNumber = (CListBox*)GetDlgItem(IDC_SPT_CHNUMBER);
CComboBox* pCbEAmount = (CComboBox*)GetDlgItem(IDC_SPT_EAMOUNT);
CComboBox* pCbAR = (CComboBox*)GetDlgItem(IDC_SPT_AR);
DWORD dwMedHandle = (DWORD)VAL_ZERO;
BOOL bIsFin = TRUE;
int iAR = (int)VAL_ZERO;
int iChIndex = (int)VAL_ZERO;
int iChCount = (int)VAL_ZERO;
int iRecIndex = (int)VAL_ZERO;
POSITION posCh = NULL;
CString szEU = _T("");
float fEU = (float)VAL_ZERO;
if (m_edEU.GetWindowTextLength() == (int)VAL_ZERO)
{
szCaption.Empty();
szCaption.LoadString(IDS_OP_LC_SCON_INPUT_EU);
MessageBox(szCaption, NULL, MB_ICONERROR);
m_edEU.SetFocus();
return;
}
m_edEU.GetWindowText(szEU);
fEU = (float)atof(szEU);
if ((float)VAL_ZERO == fEU)
{
szCaption.Empty();
szCaption.LoadString(IDS_OP_LC_SCON_NOTZERO_EU);
MessageBox(szCaption, NULL, MB_ICONERROR);
m_edEU.SetFocus();
return;
}
if ((int)VAL_ZERO == m_pNewScript->m_iEAmount)
{
szCaption.Empty();
szCaption.LoadString(IDS_OP_LC_SCON_SEL_EAMOUNT);
MessageBox(szCaption, NULL, MB_ICONERROR);
pCbEAmount->SetFocus();
return;
}
this->m_pOpCreateSptView->m_bIsDraw = FALSE;
POSITION pos = m_pNewScript->m_chaList.FindIndex(pLbChNumber->GetCurSel());
CChannel* pChannel = (CChannel*)m_pNewScript->m_chaList.GetAt(pos);
if (NULL != pChannel)
{
// iEAmount = pCbEAmount->GetItemData(pCbEAmount->GetCurSel());
m_pOpCreateSptView->m_pNewChannel = pChannel;
m_pOpCreateSptView->m_iEAmount = m_pNewScript->m_iEAmount;
m_pOpCreateSptInfoView->m_pNewChannel = pChannel;
m_pOpCreateSptRecListView->m_pNewChannel = pChannel;
iAR = pCbAR->GetItemData(pCbAR->GetCurSel());
dwMedHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
pChannel->m_pMedium = m_pMedLinkList->Find(dwMedHandle);
pMedium = pChannel->m_pMedium;
pChannel->ClearSptRecList();
if (NULL != pMedium)
{
pMedium->GenerateSptRecElecVal(m_pNewScript->m_iEAmount, fEU, &(pChannel->m_iMaxLevel), &(pChannel->m_iPtAmount), &(pChannel->m_sptRecArray));
m_pOpCreateSptRecListView->GetListCtrl().DeleteAllItems();
while (iRecIndex < pChannel->m_sptRecArray.GetSize())
{
DoEvent(this->m_hWnd);
m_pOpCreateSptRecListView->GetListCtrl().InsertItem(iRecIndex, _T(""));
pSptRecord = (CSptRecord*)(pChannel->m_sptRecArray.GetAt(iRecIndex));
if (NULL != pSptRecord)
{
InsertSptRecToRecListView(pSptRecord);
}
iRecIndex++;
DoEvent(this->m_hWnd);
}
}
}
posCh = NULL;
iChIndex = (int)VAL_ZERO;
iChCount = m_pNewScript->m_chaList.GetCount();
while (iChIndex < iChCount)
{
posCh = m_pNewScript->m_chaList.FindIndex(iChIndex);
pChannel = (CChannel*)m_pNewScript->m_chaList.GetAt(posCh);
bIsFin = bIsFin && (pChannel->m_sptRecArray.GetSize() > (int)VAL_ZERO);
iChIndex ++;
}
if (TRUE == bIsFin)
{
this->GetDlgItem(IDOK)->EnableWindow();
}
else
{
this->GetDlgItem(IDOK)->EnableWindow(FALSE);
}
this->m_pOpCreateSptView->m_bIsDraw = TRUE;
this->m_pOpCreateSptView->m_iMul = 2;
this->m_pOpCreateSptView->Invalidate(FALSE);
this->m_pOpCreateSptView->SetFocus();
*/
}
void COpCreateSptDlg::InsertSptRecToRecListView(CSptRecord* pSptRecord)
{
CString szLabel = _T("");
int iRecIndex = (int)VAL_ZERO;
iRecIndex = pSptRecord->m_iTsn;
iRecIndex--;
m_pOpCreateSptRecListView->GetListCtrl().SetItemData(iRecIndex, (DWORD)pSptRecord);
szLabel.Empty();
szLabel.Format(_T("%d"), pSptRecord->m_iTsn);
m_pOpCreateSptRecListView->GetListCtrl().SetItemText(iRecIndex, 0, szLabel);
szLabel.Empty();
szLabel.Format(_T("%d"), pSptRecord->m_iC1);
m_pOpCreateSptRecListView->GetListCtrl().SetItemText(iRecIndex, 1, szLabel);
szLabel.Empty();
szLabel.Format(_T("%d"), pSptRecord->m_iC2);
m_pOpCreateSptRecListView->GetListCtrl().SetItemText(iRecIndex, 2, szLabel);
szLabel.Empty();
szLabel.Format(_T("%d"), pSptRecord->m_iP1);
m_pOpCreateSptRecListView->GetListCtrl().SetItemText(iRecIndex, 3, szLabel);
szLabel.Empty();
szLabel.Format(_T("%d"), pSptRecord->m_iP2);
m_pOpCreateSptRecListView->GetListCtrl().SetItemText(iRecIndex, 4, szLabel);
szLabel.Empty();
szLabel.Format(_T("%f"), pSptRecord->m_fK);
m_pOpCreateSptRecListView->GetListCtrl().SetItemText(iRecIndex, 5, szLabel);
szLabel.Empty();
szLabel.Format(_T("%d"), pSptRecord->m_iN);
m_pOpCreateSptRecListView->GetListCtrl().SetItemText(iRecIndex, 6, szLabel);
szLabel.Empty();
szLabel.Format(_T("%d"), pSptRecord->m_iLevel);
m_pOpCreateSptRecListView->GetListCtrl().SetItemText(iRecIndex, 7, szLabel);
m_pOpCreateSptRecListView->GetListCtrl().SetCheck(iRecIndex, pSptRecord->m_bIsSel);
}
/*
void COpCreateSptDlg::OnSelchangeSptEamount()
{
// TODO: Add your control notification handler code here
BOOL bIsFin = TRUE;
int iAR = (int)VAL_ZERO;
int iChIndex = (int)VAL_ZERO;
int iChCount = (int)VAL_ZERO;
int iRecIndex = (int)VAL_ZERO;
CString szCaption = _T("");
POSITION posCh = NULL;
DWORD dwMedHandle = (DWORD)VAL_ZERO;
CString szEU = _T("");
float fEU = (float)VAL_ZERO;
CMedium* pMedium = NULL;
CSptRecord* pSptRecord = NULL;
CComboBox* pCbAR = (CComboBox*)GetDlgItem(IDC_SPT_AR);
CListBox* pLbChNumber = (CListBox*)GetDlgItem(IDC_SPT_CHNUMBER);
CComboBox* pCbEAmount = (CComboBox*)GetDlgItem(IDC_SPT_EAMOUNT);
m_pNewScript->m_iEAmount = pCbEAmount->GetItemData(pCbEAmount->GetCurSel());
if (pCbAR->GetCurSel() != (int)VAL_MINUS_ONE)
{
if (m_edEU.GetWindowTextLength() == (int)VAL_ZERO)
{
szCaption.Empty();
szCaption.LoadString(IDS_OP_LC_SCON_INPUT_EU);
MessageBox(szCaption, NULL, MB_ICONERROR);
m_edEU.SetFocus();
return;
}
m_edEU.GetWindowText(szEU);
fEU = (float)atof(szEU);
if ((float)VAL_ZERO == fEU)
{
szCaption.Empty();
szCaption.LoadString(IDS_OP_LC_SCON_NOTZERO_EU);
MessageBox(szCaption, NULL, MB_ICONERROR);
m_edEU.SetFocus();
return;
}
this->m_pOpCreateSptView->m_bIsDraw = FALSE;
POSITION pos = m_pNewScript->m_chaList.FindIndex(pLbChNumber->GetCurSel());
CChannel* pChannel = (CChannel*)m_pNewScript->m_chaList.GetAt(pos);
if (NULL != pChannel)
{
// iEAmount = pCbEAmount->GetItemData(pCbEAmount->GetCurSel());
m_pOpCreateSptView->m_pNewChannel = pChannel;
m_pOpCreateSptView->m_iEAmount = m_pNewScript->m_iEAmount;
m_pOpCreateSptInfoView->m_pNewChannel = pChannel;
m_pOpCreateSptRecListView->m_pNewChannel = pChannel;
iAR = pCbAR->GetItemData(pCbAR->GetCurSel());
dwMedHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
pChannel->m_pMedium = m_pMedLinkList->Find(dwMedHandle);
pMedium = pChannel->m_pMedium;
pChannel->ClearSptRecList();
if (NULL != pMedium)
{
pMedium->GenerateSptRecElecVal(m_pNewScript->m_iEAmount, fEU, &(pChannel->m_iMaxLevel), &(pChannel->m_iPtAmount), &(pChannel->m_sptRecArray));
m_pOpCreateSptRecListView->GetListCtrl().DeleteAllItems();
while (iRecIndex < pChannel->m_sptRecArray.GetSize())
{
DoEvent(this->m_hWnd);
m_pOpCreateSptRecListView->GetListCtrl().InsertItem(iRecIndex, _T(""));
pSptRecord = (CSptRecord*)(pChannel->m_sptRecArray.GetAt(iRecIndex));
if (NULL != pSptRecord)
{
InsertSptRecToRecListView(pSptRecord);
}
iRecIndex++;
DoEvent(this->m_hWnd);
}
}
}
posCh = NULL;
iChIndex = (int)VAL_ZERO;
iChCount = m_pNewScript->m_chaList.GetCount();
while (iChIndex < iChCount)
{
posCh = m_pNewScript->m_chaList.FindIndex(iChIndex);
pChannel = (CChannel*)m_pNewScript->m_chaList.GetAt(posCh);
bIsFin = bIsFin && (pChannel->m_sptRecArray.GetSize() > (int)VAL_ZERO);
iChIndex ++;
}
if (TRUE == bIsFin)
{
this->GetDlgItem(IDOK)->EnableWindow();
}
else
{
this->GetDlgItem(IDOK)->EnableWindow(FALSE);
}
this->m_pOpCreateSptView->m_bIsDraw = TRUE;
this->m_pOpCreateSptView->m_iMul = 2;
this->m_pOpCreateSptView->Invalidate(FALSE);
this->m_pOpCreateSptView->SetFocus();
}
}*/
int COpCreateSptDlg::GetMinEAmountFromArType(int iArrType)
{
switch (iArrType)
{
case 1:
case 2:
case 3:
case 9:
case 11:
case 16:
case AR_WENNER_SCH_BASIC:
case 39:
case 41:
case 42:
case AR_S3P_MEDIUM:
return 4;
case 4:
case 5:
case 43:
return 3;
case 6:
return 2;
case 40:
return 0;
case AR_STRONG_GRADIENT:
return 20;
default :
return -1;
}
}
void COpCreateSptDlg::OnGen()
{
// TODO: Add your control notification handler code here
// if (!UpdateData(TRUE))
// {
// AfxMessageBox(_T("set param error!"));
// return;
// }
CProgressDlg ProgressDlg;
ProgressDlg.DoModal();
HANDLE hThread = ::CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)GenerateScriptTestThread, this, 0, 0);
if (INVALID_HANDLE_VALUE == hThread)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("生成脚本测点创建线程失败."));
else
MessageBoxEx(NULL, _T("Thread for generating script measure points creation failed."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
//CFileOperTools::GetInstance()->WriteComLog(_T("Create Thread failed to upload device market data to Cloud"));
}
CloseHandle(hThread);
}
UINT COpCreateSptDlg::GenerateScriptTestThread(LPVOID lParam)
{
COpCreateSptDlg* pThis = (COpCreateSptDlg*)lParam;
if (NULL == pThis)
{
return -1;
}
CString szCaption = _T("");
CListBox* pLbChNumber = (CListBox*)pThis->GetDlgItem(IDC_SPT_CHNUMBER);
// CComboBox* pCbEAmount = (CComboBox*)GetDlgItem(IDC_SPT_EAMOUNT);
CComboBox* pCbAR = (CComboBox*)pThis->GetDlgItem(IDC_SPT_AR);
DWORD dwMedHandle = (DWORD)VAL_ZERO;
BOOL bIsFin = TRUE;
int iAR = (int)VAL_ZERO;
// CString szEU = _T("");
// float fEU = (float)VAL_ZERO;
// if (m_edEU.GetWindowTextLength() == (int)VAL_ZERO)
// {
// szCaption.Empty();
// szCaption.LoadString(IDS_OP_LC_SCON_INPUT_EU);
// MessageBox(szCaption, NULL, MB_ICONWARNING);
// m_edEU.SetFocus();
// return;
// }
// m_edEU.GetWindowText(szEU);
// fEU = (float)atof(szEU);
// if ((float)VAL_ZERO == fEU)
// {
// szCaption.Empty();
// szCaption.LoadString(IDS_OP_LC_SCON_NOTZERO_EU);
// MessageBox(szCaption, NULL, MB_ICONWARNING);
// m_edEU.SetFocus();
// return;
// }
if ((int)VAL_MINUS_ONE == pCbAR->GetCurSel())
{
szCaption.Empty();
szCaption.LoadString(IDS_OP_LC_SCON_SEL_AR + g_UIOffset);
hHook = SetWindowsHookEx(WH_CBT, (HOOKPROC)CBTHookProc, AfxGetInstanceHandle(), NULL);
//MessageBox(szCaption, NULL, MB_ICONWARNING);
MessageBoxEx(NULL, szCaption, STRING_MESSAGEBOXEX_TITLE, MB_ICONWARNING, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
pCbAR->SetFocus();
return -1;
}
iAR = pCbAR->GetItemData(pCbAR->GetCurSel());
// if (AR_CUSTOM_2D_TYPE == iAR)
// {
// CreateCustomSpt();
// return;
//
// }
CString strCbEAmount = _T("");
pThis->GetDlgItem(IDC_SPT_EAMOUNT)->GetWindowText(strCbEAmount);
if (strCbEAmount.IsEmpty())
{
szCaption.Empty();
szCaption.LoadString(IDS_OP_LC_SCON_SEL_EAMOUNT + g_UIOffset);
hHook = SetWindowsHookEx(WH_CBT, (HOOKPROC)CBTHookProc, AfxGetInstanceHandle(), NULL);
//MessageBox(szCaption, NULL, MB_ICONWARNING);
MessageBoxEx(NULL, szCaption, STRING_MESSAGEBOXEX_TITLE, MB_ICONWARNING, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return -1;
}
else
{
//这里取得电极数
int iEAmount = atoi(strCbEAmount);
int iMinCbNum = pThis->GetMinEAmountFromArType(iAR);
if (iMinCbNum < 0)
{
szCaption.Empty();
if (LANG_ZHCN == g_iUILanguage)
{
szCaption.Format(_T("Unknow Array type, value = %d"), iAR);
AfxMessageBox(szCaption);
}
else
{
szCaption.Format(_T("未知装置类型 %d"), iAR);
MessageBoxEx(NULL, szCaption, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
}
return -1;
}
if (iEAmount < iMinCbNum || iEAmount > MAX_CB_AMOUNT)
{
szCaption.Empty();
if (LANG_ZHCN == g_iUILanguage)
{
szCaption.Format(_T("电极数的取值范围为%d到%d."), iMinCbNum, MAX_CB_AMOUNT);
AfxMessageBox(szCaption);
}
else
{
szCaption.Format(_T("Please input an postive integer from %d to %d on electrode number"), iMinCbNum, MAX_CB_AMOUNT);
MessageBoxEx(NULL, szCaption, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
}
return -1;
}
if (AR_CROSS_HOLE_TYPE == iAR)
{
if (iEAmount % 2 != 0)
{
szCaption.Empty();
if (LANG_ZHCN == g_iUILanguage)
{
szCaption = _T("跨孔偶级的电极数必须为偶数");
AfxMessageBox(szCaption);
}
else
{
szCaption = _T("The electrode number of Cross-Hole Dipole must be even number");
MessageBoxEx(NULL, szCaption, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
}
return -1;
}
}
pThis->m_pNewScript->m_iEAmount = iEAmount;
}
if ((int)VAL_MINUS_ONE == pThis->m_cmbArRunMethod.GetCurSel())
{
hHook = SetWindowsHookEx(WH_CBT, (HOOKPROC)CBTHookProc, AfxGetInstanceHandle(), NULL);
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("请选择跑极方式."));
else
MessageBoxEx(NULL, _T("Please select run method of electrode."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
pThis->m_cmbArRunMethod.SetFocus();
return -1;
}
int iSurfaceElectCnt = 0;
int iSepInterval = 0;
int iMNSpace = 0;
float fInterval = 0;
int iMaxDipoleA = 0;
int iMaxSepN = 0;
int iUpX = 0, iUpY = 0, iDownX = 0, iDownY = 0;
int iStartElectID = 0, iMinN = 0, iMaxN = 0;
int iIsolationLayers = 0; //Schlumberger装置Auto增加隔离层数控制
BYTE bStrongGradientSwitch = 0;
switch (iAR)
{
case AR_BIPOLE_HOLE_SPT:
{
CString strSurfaceElec = _T("");
pThis->GetDlgItem(IDC_EDIT_SPT_SEPRATE)->GetWindowText(strSurfaceElec);
if (!bIsInteger(strSurfaceElec))
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("地表电极数须为正数."));
else
MessageBoxEx(NULL, _T("Please input an postive integer on surface electrode number."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return -1;
}
iSurfaceElectCnt = atoi(strSurfaceElec);
if (iSurfaceElectCnt < 2 || iSurfaceElectCnt >= pThis->m_pNewScript->m_iEAmount)
{
strSurfaceElec.Empty();
if (LANG_ZHCN == g_iUILanguage)
{
strSurfaceElec.Format(_T("地表电极的取值范围为2到%d."), pThis->m_pNewScript->m_iEAmount - 1);
AfxMessageBox(strSurfaceElec);
}
else
{
strSurfaceElec.Format(_T("Please input an postive integer from 2 to %d on surface electrode number"), pThis->m_pNewScript->m_iEAmount - 1);
MessageBoxEx(NULL, strSurfaceElec, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
}
return -1;
}
}
break;
case AR_DOUBLE_SIZE_3P:
{
CString strSepInterval = _T("");
pThis->GetDlgItem(IDC_EDIT_SPT_SEPRATE)->GetWindowText(strSepInterval);
if (!bIsInteger(strSepInterval))
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("间隔系数的值须为正数."));
else
MessageBoxEx(NULL, _T("Please input an postive integer on interval coffient."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return -1;
}
iSepInterval = atoi(strSepInterval);
if (iSepInterval < 1 || iSepInterval > pThis->m_pNewScript->m_iEAmount - 2)
{
strSepInterval.Empty();
if (LANG_ZHCN == g_iUILanguage)
{
strSepInterval.Format(_T("间隔系数的取值范围为1到%d."), pThis->m_pNewScript->m_iEAmount - 2);
AfxMessageBox(strSepInterval);
}
else
{
strSepInterval.Format(_T("Please input an postive integer from 1 to %d on interval coffient"), pThis->m_pNewScript->m_iEAmount - 2);
MessageBoxEx(NULL, strSepInterval, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
}
return -1;
}
}
break;
case AR_SCHLUMBERGER:
{
if (0 == pThis->m_cmbMNCtrl.GetCurSel())
{
CString strTmp = _T("");
pThis->GetDlgItem(IDC_EDIT_SPT_SEPRATE)->GetWindowText(strTmp);
if (!bIsInteger(strTmp))
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("MN电极间距必须为正整数."));
else
MessageBoxEx(NULL, _T("Please input an postive integer on MN Space."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return -1;
}
iMNSpace = atoi(strTmp);
if ((3 + iMNSpace > pThis->m_pNewScript->m_iEAmount) || iMNSpace < 1)
{
if (LANG_ZHCN == g_iUILanguage)
{
strTmp.Format(_T("MN间距的取值范围为从1到%d."), pThis->m_pNewScript->m_iEAmount - 3);
AfxMessageBox(strTmp);
}
else
{
strTmp.Format(_T("Please input an postive integer from 1 to %d on MN Space."), pThis->m_pNewScript->m_iEAmount - 3);
MessageBoxEx(NULL, strTmp, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
}
return -1;
}
}
else if (1 == pThis->m_cmbMNCtrl.GetCurSel())//选中Auto
{
CString strTmp = _T("");
pThis->GetDlgItem(IDC_EDIT_SPT_SEPRATE)->GetWindowText(strTmp);
if (!bIsInteger(strTmp))
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("隔离层数必须为正整数."));
else
MessageBoxEx(NULL, _T("Isolation layers must be a positive integer."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return -1;
}
iIsolationLayers = atoi(strTmp);
if ((iIsolationLayers > pThis->m_pNewScript->m_iEAmount / 3) || iIsolationLayers < 1)
{
if (LANG_ZHCN == g_iUILanguage)
{
strTmp.Format(_T("隔离层数取值范围为从1到%d."), pThis->m_pNewScript->m_iEAmount / 3);
AfxMessageBox(strTmp);
}
else
{
strTmp.Format(_T("Please input an postive integer from 1 to %d on Isolation layers."), pThis->m_pNewScript->m_iEAmount / 3);
MessageBoxEx(NULL, strTmp, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
}
return -1;
}
}
}
break;
case AR_DIP_DIP:
{
CString strElecInterval = _T("");
pThis->GetDlgItem(IDC_EDIT_SPT_SEPRATE)->GetWindowText(strElecInterval);
if (strElecInterval.IsEmpty() || !bIsFloat(strElecInterval))
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("偶极间隔因子的值须为正数."));
else
MessageBoxEx(NULL, _T("Please input an postive value on spacing units."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return -1;
}
fInterval = atof(strElecInterval);
if (fInterval < 1 || fInterval > pThis->m_pNewScript->m_iEAmount - 3)
{
strElecInterval.Empty();
if (LANG_ZHCN == g_iUILanguage)
{
strElecInterval.Format(_T("偶极间隔因子的取值范围为1到%d."), pThis->m_pNewScript->m_iEAmount - 3);
AfxMessageBox(strElecInterval);
}
else
{
strElecInterval.Format(_T("Please input an postive value from 1 to %d on spacing units"), pThis->m_pNewScript->m_iEAmount - 3);
MessageBoxEx(NULL, strElecInterval, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
}
return -1;
}
pThis->GetDlgItem(IDC_EDIT_SPT_SEPRATE)->EnableWindow(FALSE);
}
break;
case AR_POLE_DIPOLE_AMN:
case AR_DIPOLE_POLE_MNB:
{
CString strIma, strImn;
pThis->GetDlgItem(IDC_SPT_PARAM_A)->GetWindowTextA(strIma);
pThis->GetDlgItem(IDC_SPT_PARAM_N)->GetWindowTextA(strImn);
if (strIma.IsEmpty())
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("请输入Max Dipole a值"));
else
MessageBoxEx(NULL, _T("Please enter Max Dipole a value."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return -1;
}
iMaxDipoleA = atoi(strIma);
if (strImn.IsEmpty())
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("请输入Max sep n值"));
else
MessageBoxEx(NULL, _T("Please enter Max sep n value."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return -1;
}
iMaxSepN = atoi(strImn);
}
break;
case AR_STRONG_GRADIENT:
{
bStrongGradientSwitch = ((CButton*)pThis->GetDlgItem(IDC_CHECK_STRONG_GRADIENT_SWITCH))->GetCheck();
}
break;
case AR_S3P_MEDIUM:
{
CString strStartElecID, strMinN, strMaxN;
pThis->GetDlgItemText(IDC_EDIT_START_ELECTRODE_ID, strStartElecID);
pThis->GetDlgItemText(IDC_EDIT_N_MIN, strMinN);
pThis->GetDlgItemText(IDC_EDIT_N_MAX, strMaxN);
if (strStartElecID.IsEmpty())
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("请输入起始电极号"));
else
MessageBoxEx(NULL, _T("Please enter start electrode ID."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return -1;
}
iStartElectID = atoi(strStartElecID);
if (strMinN.IsEmpty())
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("请输入最小n值"));
else
MessageBoxEx(NULL, _T("Please enter min n value."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return -1;
}
iMinN = atoi(strMinN);
if (strMaxN.IsEmpty())
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("请输入最大n值"));
else
MessageBoxEx(NULL, _T("Please enter max n value."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return -1;
}
iMaxN = atoi(strMaxN);
}
break;
default:
break;
}
// if (AR_CROSS_HOLE_TYPE == pCbAR->GetItemData(pCbAR->GetCurSel()))
// {
// CString strSep = _T("");
// GetDlgItem(IDC_EDIT_SPT_SEPRATE)->GetWindowText(strSep);
// if (strSep.IsEmpty())
// {
// AfxMessageBox(_T("Interval Coffient can't be empty"));
// return;
// }
//
// m_fSptSeprate = atof(strSep);
// }
int iChIndex = (int)VAL_ZERO;
int iChCount = (int)VAL_ZERO;
int iRecIndex = (int)VAL_ZERO;
pThis->m_pOpCreateSptView->m_bIsDraw = FALSE;//pLbChNumber->GetCurSel()一直位0
POSITION pos = pThis->m_pNewScript->m_chaList.FindIndex(pLbChNumber->GetCurSel());//pLbChNumber是listbox控件保存了通道索引
CChannel* pChannel = (CChannel*)pThis->m_pNewScript->m_chaList.GetAt(pos);
if (NULL != pChannel)
{
pThis->GetDlgItem(IDC_GEN)->EnableWindow(FALSE);
pThis->GetDlgItem(IDOK)->EnableWindow();
// iEAmount = pCbEAmount->GetItemData(pCbEAmount->GetCurSel());
pThis->m_pOpCreateSptView->m_pNewChannel = pChannel;
pThis->m_pOpCreateSptView->m_iEAmount = pThis->m_pNewScript->m_iEAmount;
// m_pOpCreateSptInfoView->m_pNewChannel = pChannel;
pThis->m_pOpCreateSptRecListView->m_pNewChannel = pChannel;
dwMedHandle = pThis->m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
//对装置类型的处理
pChannel->m_pMedium = pThis->m_pMedLinkList->Find(dwMedHandle);
pThis->m_pChannel = pChannel;
CMedium* pMedium = NULL;
pMedium = pChannel->m_pMedium;
pChannel->ClearSptRecList();
if (NULL != pMedium)
{
switch (iAR)
{
case AR_CROSS_HOLE_TYPE:
{
pMedium->SetParamVal(&pThis->m_fSptSeprate);
}
break;
case AR_SCHLUMBERGER:
{
int iMNInfo[3];
iMNInfo[0] = pThis->m_cmbMNCtrl.GetCurSel();
iMNInfo[1] = iMNSpace;
iMNInfo[2] = iIsolationLayers;
pMedium->SetParamVal(iMNInfo);
}
break;
case AR_BIPOLE_HOLE_SPT:
{
pMedium->SetParamVal(&iSurfaceElectCnt);
}
break;
case AR_DOUBLE_SIZE_3P:
{
pMedium->SetParamVal(&iSepInterval);
}
break;
case AR_DIP_DIP:
{
pMedium->SetParamVal(&fInterval);
pThis->m_fDipoleSep = fInterval;
}
break;
case AR_POLE_DIPOLE_AMN:
case AR_DIPOLE_POLE_MNB:
{
int iParam[2];
iParam[0] = iMaxDipoleA;
iParam[1] = iMaxSepN;
pMedium->SetParamVal(iParam);
}
break;
case AR_STRONG_GRADIENT:
{
pMedium->SetParamVal(&bStrongGradientSwitch);
}
break;
case AR_S3P_MEDIUM:
{
int iParam[3];
iParam[0] = iStartElectID;
iParam[1] = iMinN;
iParam[2] = iMaxN;
pMedium->SetParamVal(iParam);
}
break;
default:
break;
}
bool bRes = pMedium->GenerateSptRecElecVal(pThis->m_pNewScript->m_iEAmount, &(pChannel->m_iMaxLevel), &(pChannel->m_iPtAmount), &(pChannel->m_sptRecArray));
if (AR_CUSTOM_2D_TYPE == iAR && (bRes == false))
{
pThis->GetDlgItem(IDC_GEN)->EnableWindow(TRUE);
pThis->GetDlgItem(IDOK)->EnableWindow(FALSE);
return -1;
}
if ((iAR >0 && iAR < 4) || 11 == iAR || /*39 == iAR || 40 == iAR ||*/ EN_MULTI_CHANNEL != theApp.m_ucIsMultiChannel)
pMedium->ReSortPoint(&(pChannel->m_sptRecArray), pThis->m_cmbArRunMethod.GetCurSel());
else
{
//多通道脚本排序,A相同的一起测试
pMedium->SortMulChannelSpt(&(pChannel->m_sptRecArray));
}
/////////////////////////added by lsq 20161101////////////////////////////////
//添加产生通用脚本信息
if (false == pMedium->GeneralUniSptInfo(pChannel->m_iMaxLevel, &(pChannel->m_sptRecArray)))
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("获取通用脚本信息错误."));
else
MessageBoxEx(NULL, _T("Get universal script information error."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
}
//////////////////////////////////////////////////////////////////////////
CSptRecord* pSptRecord = NULL;
pThis->m_pOpCreateSptRecListView->GetListCtrl().DeleteAllItems();
while (iRecIndex < pChannel->m_sptRecArray.GetSize())
{
DoEvent(pThis->m_hWnd);
pThis->m_pOpCreateSptRecListView->GetListCtrl().InsertItem(iRecIndex, _T(""));
pSptRecord = (CSptRecord*)(pChannel->m_sptRecArray.GetAt(iRecIndex));
if (NULL != pSptRecord)
{
pThis->InsertSptRecToRecListView(pSptRecord);
}
iRecIndex++;
DoEvent(pThis->m_hWnd);
}
//只需要对HeaderCtrl进行调整,则整个列表的数据也会跟着调整
pThis->AdjustRecListColumnIndex(iAR);
//调整完成之后,需要进行进行重绘才行
pThis->m_pOpCreateSptRecListView->Invalidate();
//
}
// m_edEU.EnableWindow(FALSE);
pThis->GetDlgItem(IDC_SPT_EAMOUNT)->EnableWindow(FALSE);
pCbAR->EnableWindow(FALSE);
//add layer info
pThis->m_iStartLayer = 1;
pThis->m_iEndLayer = pChannel->m_iMaxLevel;
pThis->m_strStartLayer.Format(_T("%d"), pThis->m_iStartLayer);
pThis->m_strEndLayer.Format(_T("%d"), pThis->m_iEndLayer);
//pThis->UpdateData(FALSE);
pThis->SendMessage(WM_UPDATEFIELDS, FALSE);
pThis->ShowLayerFilterInfo(TRUE);
pThis->m_cmbArRunMethod.EnableWindow(FALSE);
}
POSITION posCh = NULL;
iChIndex = (int)VAL_ZERO;
iChCount = pThis->m_pNewScript->m_chaList.GetCount();
while (iChIndex < iChCount)
{
posCh = pThis->m_pNewScript->m_chaList.FindIndex(iChIndex);
pChannel = (CChannel*)pThis->m_pNewScript->m_chaList.GetAt(posCh);
// bIsFin = bIsFin && (pChannel->m_sptRecArray.GetSize() > (int)VAL_ZERO);
iChIndex++;
}
/*
if (TRUE == bIsFin)
{
this->GetDlgItem(IDC_GEN)->EnableWindow(FALSE);
this->GetDlgItem(IDOK)->EnableWindow();
}
else
{
this->GetDlgItem(IDC_GEN)->EnableWindow();
this->GetDlgItem(IDOK)->EnableWindow(FALSE);
}
*/
//如果是跨孔或者是边缘梯度的话,则不画脚本的剖面图
if (AR_CUSTOM_2D_TYPE == iAR || AR_CROSS_HOLE_TYPE == iAR || AR_EDGE_GARDIENT == iAR || AR_BIPOLE_HOLE_SPT == iAR || AR_DOUBLE_SIZE_3P == iAR || AR_STRONG_GRADIENT == iAR || AR_S3P_MEDIUM == iAR)
{
pThis->m_pOpCreateSptView->m_bIsDraw = FALSE;
}
else
pThis->m_pOpCreateSptView->m_bIsDraw = TRUE;
pThis->m_pOpCreateSptView->m_iMul = 2;
pThis->m_pOpCreateSptView->Invalidate(FALSE);
pThis->m_pOpCreateSptView->SetFocus();
// pThis->m_pOpCreateSptInfoView->m_bIsDraw = TRUE;
// pThis->m_pOpCreateSptInfoView->Invalidate(TRUE);
}
BOOL COpCreateSptDlg::DestroyWindow()
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::DestroyWindow();
}
void COpCreateSptDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
if (NULL != m_pOpCreateSptFrame)
{
CRect rcStaticWnd,rect;
CWnd* pStaticWnd = GetDlgItem(IDC_STATIC_2D_SPT_BASIC_INFO);
if (pStaticWnd != NULL)
{
pStaticWnd->GetClientRect(&rcStaticWnd);
}
CRect rcClient;
GetClientRect(&rcClient);
CWnd *pStatic = GetDlgItem(IDC_STATIC_FRAME);
if (pStatic != NULL)
{
rcClient.top = rcStaticWnd.bottom + 5;
rcClient.left += 10;
rcClient.right -= 10;
rcClient.bottom -= 20;
pStatic->MoveWindow(&rcClient);
}
m_pOpCreateSptFrame->MoveWindow(&rcClient);
m_pOpCreateSptFrame->ShowWindow(SW_SHOW);
// m_stSptInfo.GetClientRect(&rect);
//m_pOpCreateSptFrame->MoveWindow(&recDlg);
//m_pOpCreateSptFrame->ShowWindow(SW_SHOW);
}
// UPDATE_EASYSIZE;
}
BOOL COpCreateSptDlg::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);
}
//DEL void COpCreateSptDlg::SelctAllSptData()
//DEL {
//DEL
//DEL }
void COpCreateSptDlg::ShowLayerFilterInfo(BOOL bShow)
{
GetDlgItem(IDC_EDIT_START_LAYER)->EnableWindow(bShow);
GetDlgItem(IDC_EDIT_END_LAYER)->EnableWindow(bShow);
GetDlgItem(IDC_BUTTON_LAYER_FILTER)->EnableWindow(bShow);
}
void COpCreateSptDlg::OnButtonLayerFilter()
{
// TODO: Add your control notification handler code here
if (NULL == m_pChannel)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("获取通道信息失败!"));
else
MessageBoxEx(NULL, _T("Get channel info failed!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return;
}
if (!UpdateData(TRUE))
{
return;
}
if (!bIsInteger(m_strStartLayer))
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("开始层数值须为正数."));
else
MessageBoxEx(NULL, _T("Please input an integer on start layer!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return;
}
if (!bIsInteger(m_strEndLayer))
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("结束层数值须为正数."));
else
MessageBoxEx(NULL, _T("Please input an integer on end layer!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return;
}
m_iStartLayer = atoi(m_strStartLayer);
m_iEndLayer = atoi(m_strEndLayer);
if (m_iStartLayer < 1 || m_iEndLayer < 1)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("层数值错误."));
else
MessageBoxEx(NULL, _T("Layer Information error!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return;
}
if (m_iStartLayer > m_iEndLayer)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("层数乱序."));
else
MessageBoxEx(NULL, _T("The layer is disorder!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return;
}
if (m_iEndLayer > m_pChannel->m_iMaxLevel)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("层数超过最大值."));
else
MessageBoxEx(NULL, _T("The layer overflow!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return;
}
CSptRecord* pSptRec = NULL;
for (int i = 0; i < m_pChannel->m_sptRecArray.GetSize(); i++)
{
pSptRec = (CSptRecord*)(m_pChannel->m_sptRecArray.GetAt(i));
//如果满足层数条件,则将该点的状态设置为已选择
if ((pSptRec->m_iLevel >= m_iStartLayer) && (pSptRec->m_iLevel <= m_iEndLayer))
{
pSptRec->m_bIsSel = TRUE;
pSptRec->m_colorREF = RGB(0, 255, 0);
}
else
{
pSptRec->m_bIsSel = FALSE;
pSptRec->m_colorREF = RGB(150, 255, 255);
}
if (!SetSptRctItemStatus(pSptRec))
{
return;
}
}
m_pOpCreateSptView->Invalidate(FALSE);
m_pOpCreateSptView->SetFocus();
}
bool COpCreateSptDlg::SetSptRctItemStatus(CSptRecord* pSpt)
{
if (NULL == pSpt)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("在SetSptRctItemStatus中,pSpt不能为空"));
else
MessageBoxEx(NULL, _T("pSpt can't be null in SetSptRctItemStatus!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return false;
}
LVFINDINFO info;
info.flags = LVFI_PARTIAL | LVFI_PARAM;
info.lParam = (long)pSpt;
int iIndex = m_pOpCreateSptRecListView->GetListCtrl().FindItem(&info);
if (iIndex != (int)VAL_MINUS_ONE)
{
m_pOpCreateSptRecListView->GetListCtrl().SetCheck(iIndex, pSpt->m_bIsSel);
if (pSpt->m_bIsSel)
{
m_pOpCreateSptRecListView->GetListCtrl().SetHotItem(iIndex);
m_pOpCreateSptRecListView->GetListCtrl().EnsureVisible(iIndex, TRUE);
m_pOpCreateSptRecListView->GetListCtrl().SetItemState(iIndex, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
}
return true;
}
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("RectList中没有SptRecord"));
else
MessageBoxEx(NULL, _T("There is not SptRecord in RectList!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return false;
}
void COpCreateSptDlg::AdjustRecListColumnIndex(int iAR)
{
m_vtListOrder.clear();
switch (iAR)
{
case 1:
case 11:
case 4:
case 5:
case 6:
case AR_WENNER_SCH_BASIC:
case 39:
case 41://温钠-alpha,斯伦贝谢,温斯,二级和三极装置都为A\M\N\B
m_vtListOrder.push_back(1);
m_vtListOrder.push_back(3);
m_vtListOrder.push_back(4);
m_vtListOrder.push_back(2);
break;
case 2:
case 9://wenner-beta和偶极-偶极为B\A\M\N
m_vtListOrder.push_back(2);
m_vtListOrder.push_back(1);
m_vtListOrder.push_back(3);
m_vtListOrder.push_back(4);
break;
case 3: // Wennerγ装置为A\M\B\N
m_vtListOrder.push_back(1);
m_vtListOrder.push_back(3);
m_vtListOrder.push_back(2);
m_vtListOrder.push_back(4);
break;
case 42://井地井装置为B\N\A\M
m_vtListOrder.push_back(2);
m_vtListOrder.push_back(4);
m_vtListOrder.push_back(1);
m_vtListOrder.push_back(3);
break;
default:
m_vtListOrder.push_back(1);
m_vtListOrder.push_back(2);
m_vtListOrder.push_back(3);
m_vtListOrder.push_back(4);
break;
}
m_pOpCreateSptRecListView->ChangeListHeaderOrder(m_vtListOrder);
}
void COpCreateSptDlg::InitUIByLanguage(int iLanguage)
{
if (LANG_ZHCN == iLanguage)
{
SetWindowText(_T("2D脚本"));
GetDlgItem(IDC_STATIC_2D_SPT_BASIC_INFO)->SetWindowText(_T("基本信息"));
GetDlgItem(IDC_STATIC_2D_SPT_NAME)->SetWindowText(_T("*脚本名称"));
GetDlgItem(IDC_STATIC_2D_SPT_DATE)->SetWindowText(_T("日期"));
GetDlgItem(IDC_STATIC_2D_SPT_OPERATOR)->SetWindowText(_T("操作员"));
GetDlgItem(IDC_STATIC_2D_SPT_REMARK)->SetWindowText(_T("备注"));
GetDlgItem(IDC_STATIC_SPT_SEPRATE)->SetWindowText(_T(" *间隔系数"));
GetDlgItem(IDC_STATIC_MN_CTRL)->SetWindowText(_T("*MN间距控制:"));
GetDlgItem(IDC_STATIC_MN_SPACE)->SetWindowText(_T("*MN间距数:"));
GetDlgItem(IDC_STATIC_2D_SPT_CHANNEL)->SetWindowText(_T("通道"));
GetDlgItem(IDC_STATIC_2D_SPT_ELEC_NUMBER)->SetWindowText(_T("电极数"));
GetDlgItem(IDC_STATIC_2D_SPT_ARRAY)->SetWindowText(_T("排列"));
GetDlgItem(IDC_STATIC_2D_SPT_MOVE_PT)->SetWindowText(_T("跑极方式"));
GetDlgItem(IDC_STATIC_2D_SPT_CHANNEL_NUM)->SetWindowText(_T("通道"));
GetDlgItem(IDC_STATIC_2D_SPT_CHANNEL_INDEX)->SetWindowText(_T("通道序号"));
GetDlgItem(IDC_STATIC_LAYER_FILTERINFO)->SetWindowText(_T("选择层数"));
GetDlgItem(IDC_STATIC_LAYER_SHOW)->SetWindowText(_T("层数"));
GetDlgItem(IDC_BUTTON_LAYER_FILTER)->SetWindowText(_T("过滤"));
GetDlgItem(IDC_GEN)->SetWindowText(_T("创建"));
GetDlgItem(IDOK)->SetWindowText(_T("保存"));
GetDlgItem(IDCANCEL)->SetWindowText(_T("取消"));
}
}
void COpCreateSptDlg::OnSelchangeComboMnCtrl()
{
// TODO: Add your control notification handler code here
if (0 == m_cmbMNCtrl.GetCurSel())
{
if (LANG_ZHCN == g_iUILanguage)
GetDlgItem(IDC_STATIC_MN_SPACE)->SetWindowTextA(_T("*MN间距数:"));
else
GetDlgItem(IDC_STATIC_MN_SPACE)->SetWindowTextA(_T("*MN Space:"));
GetDlgItem(IDC_EDIT_SPT_SEPRATE)->SetWindowText("1");
}
else
{
if (LANG_ZHCN == g_iUILanguage)
GetDlgItem(IDC_STATIC_MN_SPACE)->SetWindowTextA(_T("隔离层数"));
else
GetDlgItem(IDC_STATIC_MN_SPACE)->SetWindowTextA(_T("Isolation layers"));
GetDlgItem(IDC_EDIT_SPT_SEPRATE)->SetWindowText("6");
}
}