233 lines
7.5 KiB
C++
233 lines
7.5 KiB
C++
// COption2DSurfaceDlg.cpp : 实现文件
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "GeoMative.h"
|
|
#include "crossHole/COption2DSurfaceDlg.h"
|
|
#include "crossHole/CCrossHoleConfig2DMainDlg.h"
|
|
#include "crossHole/C2DSimulationDlg.h"
|
|
#include "afxdialogex.h"
|
|
|
|
|
|
// COption2DSurfaceDlg 对话框
|
|
|
|
IMPLEMENT_DYNAMIC(COption2DSurfaceDlg, CDialog)
|
|
|
|
COption2DSurfaceDlg::COption2DSurfaceDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(COption2DSurfaceDlg::IDD, pParent)
|
|
{
|
|
|
|
}
|
|
|
|
COption2DSurfaceDlg::~COption2DSurfaceDlg()
|
|
{
|
|
}
|
|
|
|
|
|
void COption2DSurfaceDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
}
|
|
|
|
COption2DSurfaceDlg* COption2DSurfaceDlg::GetInstance()
|
|
{
|
|
static COption2DSurfaceDlg optionSurfaceDlg;
|
|
return &optionSurfaceDlg;
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(COption2DSurfaceDlg, CDialog)
|
|
ON_BN_CLICKED(ID_BTN_ADD_ONE_SURFACE, &COption2DSurfaceDlg::OnBnClickedBtnAddOneSurface)
|
|
END_MESSAGE_MAP()
|
|
|
|
BOOL COption2DSurfaceDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
// TODO: 在此添加额外的初始化
|
|
SetDlgItemText(IDC_EDIT_ADDR, _T("1"));
|
|
SetDlgItemText(IDC_EDIT_X, _T("0"));
|
|
SetDlgItemText(IDC_EDIT_NUMBER_OF_ELECTRODES, _T("10"));
|
|
SetDlgItemText(IDC_EDIT_ELECTRODE_SPACING, _T("1.0"));
|
|
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
SetDlgItemText(IDC_STATIC_TOP_ELECTRODE, _T("第一个电极"));
|
|
SetDlgItemText(IDC_STATIC_ADDR, _T("电极编号"));
|
|
SetDlgItemText(IDC_STATIC_NUMBER_OF_ELECTRODES, _T("电极数目"));
|
|
SetDlgItemText(IDC_STATIC_ELECTRODE_SPACING, _T("电极间距"));
|
|
SetDlgItemText(ID_BTN_ADD_ONE_SURFACE, _T("添加"));
|
|
}
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// 异常: OCX 属性页应返回 FALSE
|
|
}
|
|
|
|
// COption2DSurfaceDlg 消息处理程序
|
|
void COption2DSurfaceDlg::OnBnClickedBtnAddOneSurface()
|
|
{
|
|
if (C2DSimulationDlg::GetInstance()->IsSimulating())
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("正在模拟跑极不能操作"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Running is being simulated and cannot be operated"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return;
|
|
}
|
|
C2DSimulationDlg::GetInstance()->ShowWindow(SW_HIDE);
|
|
CCrosshole2dDrawingBoardDlg::GetInstance()->ShowWindow(SW_SHOW);
|
|
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
CString strAddr, strX, strNumOfElec, strElecSpacing, strLog;
|
|
GetDlgItemText(IDC_EDIT_ADDR, strAddr);
|
|
if (strAddr.IsEmpty())
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("请输入电极编号"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Please enter the electrode number"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return;
|
|
}
|
|
|
|
GetDlgItemText(IDC_EDIT_X, strX);
|
|
if (strX.IsEmpty())
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("请输入X值"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Please enter X value"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return;
|
|
}
|
|
|
|
GetDlgItemText(IDC_EDIT_NUMBER_OF_ELECTRODES, strNumOfElec);
|
|
if (strNumOfElec.IsEmpty())
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("请输入电极数目"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Please enter the number of electrodes"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return;
|
|
}
|
|
|
|
GetDlgItemText(IDC_EDIT_ELECTRODE_SPACING, strElecSpacing);
|
|
if (strElecSpacing.IsEmpty())
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("请输入电极间距"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Please input the electrode spacing"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return;
|
|
}
|
|
|
|
STBoreHoleParam stBoreholeParam;
|
|
stBoreholeParam.iElecID = atoi(strAddr);
|
|
stBoreholeParam.fX = atof(strX);
|
|
stBoreholeParam.iElecNum = atoi(strNumOfElec);
|
|
stBoreholeParam.fElecSpacing = atof(strElecSpacing);
|
|
strLog.Format(_T("Add one surface Parameter:addr=%d,x=%.2f,ElecNum=%d,ElecSpacing=%.2f"),
|
|
stBoreholeParam.iElecID, stBoreholeParam.fX, stBoreholeParam.iElecNum, stBoreholeParam.fElecSpacing);
|
|
CFileOperTools::GetInstance()->WriteComLog(strLog);
|
|
|
|
generatedCoordinates(stBoreholeParam);
|
|
}
|
|
|
|
void COption2DSurfaceDlg::generatedCoordinates(STBoreHoleParam stBoreholeParam)
|
|
{
|
|
std::vector<STBoreHolePoints> vecAllPoints = COption2DGeometryDlg::GetInstance()->GetAllCoordinatesPoints();
|
|
UINT32 uPointsTotal = vecAllPoints.size();
|
|
//跨孔目前只考虑Z的变化
|
|
CString strLog;
|
|
int i = 0;
|
|
strLog.Format(_T("ID Addr X Z iItemCount=%d"), uPointsTotal);
|
|
CFileOperTools::GetInstance()->WriteComLog(strLog);
|
|
BOOL bRes = FALSE;
|
|
int iElecID = stBoreholeParam.iElecID;
|
|
//遍历是否存在电极编号冲突
|
|
if (uPointsTotal > 0)
|
|
{
|
|
vector<STBoreHolePoints>::iterator iter;
|
|
for (i = uPointsTotal + 1; i <= uPointsTotal + stBoreholeParam.iElecNum; i++)
|
|
{
|
|
//查找是否已存在电极编号
|
|
bRes = FALSE;
|
|
for (iter = vecAllPoints.begin(); iter != vecAllPoints.end(); iter++)
|
|
{
|
|
if (iter->uiElecID == iElecID)
|
|
{
|
|
bRes = TRUE;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (bRes)
|
|
{
|
|
strLog.Format(_T("COption2DSurfaceDlg::generatedCoordinates ElecNum=%d Conflict"), iElecID);
|
|
CFileOperTools::GetInstance()->WriteComLog(strLog);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("电极编号冲突,不允许添加"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Electrode number conflict, do not allow to add"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return;
|
|
}
|
|
iElecID++;
|
|
}
|
|
}
|
|
|
|
int iCurElec = 0;//电极下标
|
|
STBoreHolePoints stPoints;
|
|
int iConflictCount = 0;
|
|
std::vector<STBoreHolePoints>::iterator iter;
|
|
for (i = uPointsTotal + 1, iElecID = stBoreholeParam.iElecID; i <= uPointsTotal + stBoreholeParam.iElecNum; i++, iCurElec++)
|
|
{
|
|
stPoints.uiID = i;
|
|
stPoints.uiElecID = iElecID;
|
|
stPoints.fX = stBoreholeParam.fX + iCurElec*stBoreholeParam.fElecSpacing;
|
|
|
|
iter = vecAllPoints.begin();
|
|
for (; iter != vecAllPoints.end(); iter++)
|
|
{
|
|
if ((iter->fX == stPoints.fX) && (iter->fZ == stPoints.fZ))
|
|
{
|
|
iConflictCount++;
|
|
strLog.Format(_T("COption2DSurfaceDlg::generatedCoordinates Coordinate Conflict %d %d %.2f %.2f\n"), i, iElecID, stBoreholeParam.fX, stBoreholeParam.fZ - iCurElec*stBoreholeParam.fElecSpacing);
|
|
CFileOperTools::GetInstance()->WriteComLog(strLog);
|
|
break;
|
|
}
|
|
}
|
|
iElecID++;
|
|
}
|
|
|
|
//点取消,所有的点都不添加
|
|
if (iConflictCount > 0)
|
|
{
|
|
int nRet = 0;
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strLog.Format(_T("有%d个点冲突,是否添加?"), iConflictCount);
|
|
nRet = AfxMessageBox(strLog, MB_OKCANCEL);
|
|
}
|
|
else
|
|
{
|
|
strLog.Format(_T("There are %d point conflicts, do you want to add?"), iConflictCount);
|
|
nRet = MessageBoxEx(NULL, strLog, STRING_MESSAGEBOXEX_TITLE, MB_OKCANCEL, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
|
|
if (IDOK != nRet)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
|
|
std::vector<STBoreHolePoints> vecNewCoordinatesPoints;
|
|
for (i = uPointsTotal + 1, iCurElec = 0, iElecID = stBoreholeParam.iElecID; i <= uPointsTotal + stBoreholeParam.iElecNum; i++, iCurElec++)
|
|
{
|
|
stPoints.eType = EN_SURFACE_TYPE;
|
|
stPoints.uiID = i;
|
|
stPoints.uiElecID = iElecID;
|
|
stPoints.fX = stBoreholeParam.fX + iCurElec*stBoreholeParam.fElecSpacing;
|
|
|
|
strLog.Format(_T("COption2DSurfaceDlg::generatedCoordinates add %d %d %.2f %.2f\n"), i, iElecID, stBoreholeParam.fX, stBoreholeParam.fZ - iCurElec*stBoreholeParam.fElecSpacing);
|
|
CFileOperTools::GetInstance()->WriteComLog(strLog);
|
|
vecNewCoordinatesPoints.push_back(stPoints);
|
|
iElecID++;
|
|
}
|
|
CCrossHoleConfig2DMainDlg::GetInstance()->ChangeTabPage(EN_OPTION_SURFACE, vecNewCoordinatesPoints, stBoreholeParam);
|
|
} |