295 lines
9.3 KiB
C++
295 lines
9.3 KiB
C++
// COption3DSurfaceDlg.cpp : 实现文件
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "GeoMative.h"
|
|
#include "crossHole/COption3DSurfaceDlg.h"
|
|
#include "crossHole/CCrossHoleConfig3DMainDlg.h"
|
|
#include "crossHole/C3DSimulationDlg.h"
|
|
#include "afxdialogex.h"
|
|
|
|
|
|
// COption3DSurfaceDlg 对话框
|
|
|
|
IMPLEMENT_DYNAMIC(COption3DSurfaceDlg, CDialog)
|
|
|
|
COption3DSurfaceDlg::COption3DSurfaceDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(COption3DSurfaceDlg::IDD, pParent)
|
|
{
|
|
|
|
}
|
|
|
|
COption3DSurfaceDlg::~COption3DSurfaceDlg()
|
|
{
|
|
}
|
|
|
|
|
|
void COption3DSurfaceDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
DDX_Control(pDX, IDC_COMBO_CABLE_DIRECTION, m_comCableDirection);
|
|
}
|
|
|
|
COption3DSurfaceDlg* COption3DSurfaceDlg::GetInstance()
|
|
{
|
|
static COption3DSurfaceDlg optionSurfaceDlg;
|
|
return &optionSurfaceDlg;
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(COption3DSurfaceDlg, CDialog)
|
|
ON_BN_CLICKED(ID_BTN_ADD_ONE_SURFACE, &COption3DSurfaceDlg::OnBnClickedBtnAddOneSurface)
|
|
END_MESSAGE_MAP()
|
|
|
|
BOOL COption3DSurfaceDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
// TODO: 在此添加额外的初始化
|
|
SetDlgItemText(IDC_EDIT_ADDR, _T("1"));
|
|
SetDlgItemText(IDC_EDIT_X, _T("0"));
|
|
SetDlgItemText(IDC_EDIT_Y, _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("添加"));
|
|
SetDlgItemText(IDC_STATIC_CABLE_DIRECTION, _T("电缆方向"));
|
|
}
|
|
|
|
m_comCableDirection.AddString(_T("X"));
|
|
m_comCableDirection.AddString(_T("Y"));
|
|
m_comCableDirection.SetItemData(0, EN_CABLE_DIRECTION_X);
|
|
m_comCableDirection.SetItemData(1, EN_CABLE_DIRECTION_Y);
|
|
m_comCableDirection.SetCurSel(0);
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// 异常: OCX 属性页应返回 FALSE
|
|
}
|
|
|
|
// COption3DSurfaceDlg 消息处理程序
|
|
void COption3DSurfaceDlg::OnBnClickedBtnAddOneSurface()
|
|
{
|
|
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, 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_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;
|
|
}
|
|
|
|
int iCurSel = m_comCableDirection.GetCurSel();
|
|
if (-1 == iCurSel)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("请选择电缆方向"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Please select cable direction"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return;
|
|
}
|
|
|
|
m_eCableDirection = (EN_CABLE_DIRECTION_TYPE)m_comCableDirection.GetItemData(m_comCableDirection.GetCurSel());
|
|
|
|
STBoreHoleParam stBoreholeParam;
|
|
stBoreholeParam.iElecID = atoi(strAddr);
|
|
stBoreholeParam.fX = atof(strX);
|
|
stBoreholeParam.fY = atof(strY);
|
|
stBoreholeParam.iElecNum = atoi(strNumOfElec);
|
|
stBoreholeParam.fElecSpacing = atof(strElecSpacing);
|
|
strLog.Format(_T("Add one surface Parameter:addr=%d,x=%.2f,y=%.2f,ElecNum=%d,ElecSpacing=%.2f"),
|
|
stBoreholeParam.iElecID, stBoreholeParam.fX, stBoreholeParam.fY, stBoreholeParam.iElecNum, stBoreholeParam.fElecSpacing);
|
|
CFileOperTools::GetInstance()->WriteComLog(strLog);
|
|
generatedCoordinates(stBoreholeParam);
|
|
}
|
|
|
|
void COption3DSurfaceDlg::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 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("COption3DSurfaceDlg::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;
|
|
|
|
switch (m_eCableDirection)
|
|
{
|
|
case EN_CABLE_DIRECTION_X:
|
|
{
|
|
stPoints.fX = stBoreholeParam.fX + iCurElec*stBoreholeParam.fElecSpacing;
|
|
stPoints.fY = stBoreholeParam.fY;
|
|
}
|
|
break;
|
|
case EN_CABLE_DIRECTION_Y:
|
|
{
|
|
stPoints.fX = stBoreholeParam.fX;
|
|
stPoints.fY = stBoreholeParam.fY + iCurElec*stBoreholeParam.fElecSpacing;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
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("COption3DSurfaceDlg::generatedCoordinates Coordinate Conflict %d %d %.2f %.2f %.2f\n"), i, iElecID, stBoreholeParam.fX, stBoreholeParam.fY, 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;
|
|
switch (m_eCableDirection)
|
|
{
|
|
case EN_CABLE_DIRECTION_X:
|
|
{
|
|
stPoints.fX = stBoreholeParam.fX + iCurElec*stBoreholeParam.fElecSpacing;
|
|
stPoints.fY = stBoreholeParam.fY;
|
|
}
|
|
break;
|
|
case EN_CABLE_DIRECTION_Y:
|
|
{
|
|
stPoints.fX = stBoreholeParam.fX;
|
|
stPoints.fY = stBoreholeParam.fY + iCurElec*stBoreholeParam.fElecSpacing;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
strLog.Format(_T("COption3DSurfaceDlg::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_SURFACE, vecNewCoordinatesPoints, stBoreholeParam);
|
|
} |