273 lines
8.9 KiB
C++
273 lines
8.9 KiB
C++
// COption3DBoreholeDlg.cpp : 实现文件
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "GeoMative.h"
|
|
#include "crossHole/COption3DBoreholeDlg.h"
|
|
#include "crossHole/CCrossHoleConfig3DMainDlg.h"
|
|
#include "crossHole/C3DSimulationDlg.h"
|
|
#include "afxdialogex.h"
|
|
|
|
extern int g_iUILanguage;
|
|
// COption3DBoreholeDlg 对话框
|
|
|
|
IMPLEMENT_DYNAMIC(COption3DBoreholeDlg, CDialog)
|
|
|
|
COption3DBoreholeDlg::COption3DBoreholeDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(COption3DBoreholeDlg::IDD, pParent)
|
|
{
|
|
m_fWellMaxDepth = 0.0;
|
|
}
|
|
|
|
COption3DBoreholeDlg::~COption3DBoreholeDlg()
|
|
{
|
|
}
|
|
|
|
void COption3DBoreholeDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
}
|
|
|
|
COption3DBoreholeDlg* COption3DBoreholeDlg::GetInstance()
|
|
{
|
|
static COption3DBoreholeDlg optionBoreholeDlg;
|
|
return &optionBoreholeDlg;
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(COption3DBoreholeDlg, CDialog)
|
|
ON_BN_CLICKED(ID_BTN_ADD_ONE_HOREHOLE, &COption3DBoreholeDlg::OnBnClickedBtnAddOneBorehole)
|
|
END_MESSAGE_MAP()
|
|
|
|
BOOL COption3DBoreholeDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
SetDlgItemText(IDC_STATIC_ADD_ONE_BOREHOLE, _T("添加一口井"));
|
|
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_HOREHOLE, _T("添加"));
|
|
}
|
|
SetDlgItemText(IDC_EDIT_ADDR, _T("1"));
|
|
SetDlgItemText(IDC_EDIT_X, _T("0"));
|
|
SetDlgItemText(IDC_EDIT_Y, _T("0"));
|
|
SetDlgItemText(IDC_EDIT_Z, _T("-1"));
|
|
SetDlgItemText(IDC_EDIT_NUMBER_OF_ELECTRODES, _T("10"));
|
|
SetDlgItemText(IDC_EDIT_ELECTRODE_SPACING, _T("1.0"));
|
|
// TODO: 在此添加额外的初始化
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// 异常: OCX 属性页应返回 FALSE
|
|
}
|
|
|
|
void COption3DBoreholeDlg::OnBnClickedBtnAddOneBorehole()
|
|
{
|
|
if (C3DSimulationDlg::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;
|
|
}
|
|
C3DSimulationDlg::GetInstance()->ShowWindow(SW_HIDE);
|
|
CCrosshole3dDrawingBoardDlg::GetInstance()->ShowWindow(SW_SHOW);
|
|
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
CString strAddr, strX, strY, strZ, 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_Y, strY);
|
|
if (strY.IsEmpty())
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("请输入Y值"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Please enter Y value"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return;
|
|
}
|
|
|
|
GetDlgItemText(IDC_EDIT_Z, strZ);
|
|
if (strZ.IsEmpty())
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("请输入Z值"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Please enter Z value"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return;
|
|
}
|
|
if (atof(strZ) >= 0)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("Z值必须小于0"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Z has to be less than 0"), 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.fY = atof(strY);
|
|
stBoreholeParam.fZ = atof(strZ);
|
|
stBoreholeParam.iElecNum = atoi(strNumOfElec);
|
|
stBoreholeParam.fElecSpacing = atof(strElecSpacing);
|
|
strLog.Format(_T("Add one borehole Parameter:addr=%d,x=%.2f,y=%.2f,z=%.2f,ElecNum=%d,ElecSpacing=%.2f"),
|
|
stBoreholeParam.iElecID, stBoreholeParam.fX, stBoreholeParam.fY, stBoreholeParam.fZ, stBoreholeParam.iElecNum, stBoreholeParam.fElecSpacing);
|
|
CFileOperTools::GetInstance()->WriteComLog(strLog);
|
|
|
|
generatedCoordinates(stBoreholeParam);
|
|
}
|
|
|
|
void COption3DBoreholeDlg::generatedCoordinates(STBoreHoleParam stBoreholeParam)
|
|
{
|
|
std::vector<STBoreHolePoints> vecAllPoints = COption3DGeometryDlg::GetInstance()->GetAllCoordinatesPoints();
|
|
UINT32 uPointsTotal = vecAllPoints.size();
|
|
//跨孔目前只考虑Z的变化
|
|
CString strLog;
|
|
int i = 0;
|
|
strLog.Format(_T("ID Addr X Y 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("COption3DBoreholeDlg::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;
|
|
stPoints.fY = stBoreholeParam.fY;
|
|
stPoints.fZ = stBoreholeParam.fZ - iCurElec*stBoreholeParam.fElecSpacing;
|
|
|
|
iter = vecAllPoints.begin();
|
|
for (; iter != vecAllPoints.end(); iter++)
|
|
{
|
|
if ((iter->fX == stPoints.fX) && (iter->fY == stPoints.fY)&& (iter->fZ == stPoints.fZ))
|
|
{
|
|
iConflictCount++;
|
|
strLog.Format(_T("COption3DBoreholeDlg::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;
|
|
}
|
|
}
|
|
|
|
float fWellDepth = stBoreholeParam.fZ + (-(stBoreholeParam.iElecNum - 1)*stBoreholeParam.fElecSpacing);
|
|
if (m_fWellMaxDepth > fWellDepth)
|
|
{
|
|
m_fWellMaxDepth = fWellDepth;
|
|
}
|
|
|
|
std::vector<STBoreHolePoints> vecNewCoordinatesPoints;
|
|
for (i = uPointsTotal + 1, iCurElec = 0, iElecID = stBoreholeParam.iElecID; i <= uPointsTotal + stBoreholeParam.iElecNum; i++, iCurElec++)
|
|
{
|
|
stPoints.eType = EN_BOREHOLE_TYPE;
|
|
stPoints.uiID = i;
|
|
stPoints.uiElecID = iElecID;
|
|
stPoints.fX = stBoreholeParam.fX;
|
|
stPoints.fY = stBoreholeParam.fY;
|
|
stPoints.fZ = stBoreholeParam.fZ - iCurElec*stBoreholeParam.fElecSpacing;
|
|
|
|
strLog.Format(_T("COption3DBoreholeDlg::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++;
|
|
}
|
|
CCrossHoleConfig3DMainDlg::GetInstance()->ChangeTabPage(EN_OPTION_BOREHOLE, vecNewCoordinatesPoints, stBoreholeParam);
|
|
} |