a
This commit is contained in:
@@ -0,0 +1,399 @@
|
||||
// C2DSimulationDlg.cpp : 实现文件
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GeoMative.h"
|
||||
#include "crossHole/C2DSimulationDlg.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
extern CGeoMativeApp theApp;
|
||||
// C2DSimulationDlg 对话框
|
||||
|
||||
IMPLEMENT_DYNAMIC(C2DSimulationDlg, CDialog)
|
||||
|
||||
C2DSimulationDlg::C2DSimulationDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(C2DSimulationDlg::IDD, pParent)
|
||||
{
|
||||
m_bStopSimulation = TRUE;
|
||||
m_iTimeInterval = 1000;
|
||||
}
|
||||
|
||||
C2DSimulationDlg::~C2DSimulationDlg()
|
||||
{
|
||||
}
|
||||
|
||||
void C2DSimulationDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(C2DSimulationDlg, CDialog)
|
||||
ON_WM_PAINT()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
C2DSimulationDlg* C2DSimulationDlg::GetInstance()
|
||||
{
|
||||
static C2DSimulationDlg simulationBoardDlg;
|
||||
return &simulationBoardDlg;
|
||||
}
|
||||
|
||||
BOOL C2DSimulationDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
GetParent()->GetClientRect(&m_rcWnd);
|
||||
m_rcBrush.left = m_rcWnd.left + 50;
|
||||
m_rcBrush.right = m_rcWnd.right - 50;
|
||||
m_rcBrush.top = m_rcWnd.top + 50;
|
||||
m_rcBrush.bottom = m_rcWnd.bottom - 50;
|
||||
// TODO: 在此添加额外的初始化
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// 异常: OCX 属性页应返回 FALSE
|
||||
}
|
||||
|
||||
void C2DSimulationDlg::OnPaint()
|
||||
{
|
||||
CPaintDC dc(this); // device context for painting
|
||||
dc.FillSolidRect(m_rcWnd, RGB(255, 255, 255));
|
||||
|
||||
CPen pen;
|
||||
pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
|
||||
dc.SelectObject(pen);
|
||||
CString strlog;
|
||||
CBrush cBlackBrush, *pBrush, cRedBrush, cBlueBrush;
|
||||
cBlackBrush.CreateSolidBrush(RGB(0, 0, 0));
|
||||
cRedBrush.CreateSolidBrush(RGB(255, 0, 0));
|
||||
cBlueBrush.CreateSolidBrush(RGB(0, 0, 255));
|
||||
pBrush = dc.SelectObject(&cBlackBrush);
|
||||
//水平布线,判断是否需要绘制
|
||||
int iSurfaceCount = m_vecSurfacePoints.size();
|
||||
int iBoreholeCount = m_mapBoreholePoints.size();
|
||||
float* pBoreholeXValue = NULL;
|
||||
float fDrawBoradMaxLength = 0; //整个画板最大长度
|
||||
if (iBoreholeCount > 0)
|
||||
{
|
||||
pBoreholeXValue = new float[iBoreholeCount];
|
||||
std::map<STWellPoints, std::vector<STBoreHolePoints>>::iterator iter = m_mapBoreholePoints.begin();
|
||||
for (int i = 0; i<iBoreholeCount, iter != m_mapBoreholePoints.end(); i++, iter++)
|
||||
{
|
||||
pBoreholeXValue[i] = iter->first.fX;
|
||||
if (iter->second.at(iter->second.size() - 1).fZ < fDrawBoradMaxLength)
|
||||
{
|
||||
fDrawBoradMaxLength = iter->second.at(iter->second.size() - 1).fZ;
|
||||
}
|
||||
if (abs(fDrawBoradMaxLength) < iter->first.fX)
|
||||
{
|
||||
fDrawBoradMaxLength = iter->first.fX;
|
||||
}
|
||||
}
|
||||
if (pBoreholeXValue != NULL)
|
||||
{
|
||||
delete[] pBoreholeXValue;
|
||||
pBoreholeXValue = NULL;
|
||||
}
|
||||
}
|
||||
fDrawBoradMaxLength = abs(fDrawBoradMaxLength);
|
||||
if (iSurfaceCount > 0)
|
||||
{
|
||||
if (m_vecSurfacePoints[iSurfaceCount - 1].fX > fDrawBoradMaxLength)
|
||||
fDrawBoradMaxLength = m_vecSurfacePoints[iSurfaceCount - 1].fX;
|
||||
}
|
||||
|
||||
strlog.Format(_T("整个画板最大刻度fDrawBoradMaxLength=%f\n"), fDrawBoradMaxLength);
|
||||
OutputDebugString(strlog);
|
||||
|
||||
//如果要求X轴和Z轴的最小间距都是一样的,需要取实际长度中较小的一方来计算,防止绘制超过边界
|
||||
int iEachSmallSize = (m_rcBrush.right - m_rcBrush.left) / fDrawBoradMaxLength;
|
||||
if (m_rcBrush.bottom - m_rcBrush.top < m_rcBrush.right - m_rcBrush.left)
|
||||
{
|
||||
iEachSmallSize = (m_rcBrush.bottom - m_rcBrush.top) / fDrawBoradMaxLength;
|
||||
}
|
||||
|
||||
//绘制地表线
|
||||
CClientDC fdc(this);
|
||||
RECT rcText;
|
||||
CFont font;
|
||||
if (iSurfaceCount > 0)
|
||||
{
|
||||
int iPointX = m_rcBrush.left;
|
||||
int iPointY = m_rcBrush.top;
|
||||
//如果没有孔,在中间绘制
|
||||
if (iBoreholeCount <= 0)
|
||||
{
|
||||
iPointY = m_rcBrush.top + (m_rcBrush.bottom - m_rcBrush.top) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
//确定起点X坐标
|
||||
iPointX = m_rcBrush.left + iEachSmallSize*m_vecSurfacePoints[0].fX;
|
||||
}
|
||||
|
||||
//绘制一条总线
|
||||
dc.MoveTo(iPointX, iPointY);
|
||||
dc.LineTo(iPointX + iEachSmallSize*(m_vecSurfacePoints[iSurfaceCount - 1].fX - m_vecSurfacePoints[0].fX), iPointY);
|
||||
strlog.Format(_T("地表 起点x=%d,y=%d,终点x=%d,y=%d\n"), iPointX, iPointY, iPointX + iEachSmallSize*m_vecSurfacePoints[iSurfaceCount - 1].fX, iPointY);
|
||||
OutputDebugString(strlog);
|
||||
|
||||
iPointX = m_rcBrush.left;
|
||||
|
||||
//遍历集合的每一个元素
|
||||
for (int i = 0; i < iSurfaceCount; i++)
|
||||
{
|
||||
strlog.Format(_T("X轴绘制点m_vecSurfacePoints[%d].fX值为%f,fEachSmallSize=%d,m_vecSurfacePoints[i].fX=%d x1=%d,y1=%d,x2=%d,y2=%d\n"), i, m_vecSurfacePoints[i].fX, iEachSmallSize, m_vecSurfacePoints[i].fX, iPointX + m_vecSurfacePoints[i].fX*iEachSmallSize - 2, iPointY - 2, iPointX + m_vecSurfacePoints[i].fX*iEachSmallSize + 2, iPointY + 2);
|
||||
OutputDebugString(strlog);
|
||||
if (m_vecSurfacePoints[i].uiElecID == m_iA || m_vecSurfacePoints[i].uiElecID == m_iB)
|
||||
{
|
||||
pBrush = dc.SelectObject(&cRedBrush);
|
||||
dc.Ellipse(iPointX + m_vecSurfacePoints[i].fX*iEachSmallSize - 5, iPointY - 5, iPointX + m_vecSurfacePoints[i].fX*iEachSmallSize + 5, iPointY + 5);
|
||||
}
|
||||
else if (m_vecSurfacePoints[i].uiElecID == m_iM || m_vecSurfacePoints[i].uiElecID == m_iN)
|
||||
{
|
||||
pBrush = dc.SelectObject(&cBlueBrush);
|
||||
dc.Ellipse(iPointX + m_vecSurfacePoints[i].fX*iEachSmallSize - 5, iPointY - 5, iPointX + m_vecSurfacePoints[i].fX*iEachSmallSize + 5, iPointY + 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
pBrush = dc.SelectObject(&cBlackBrush);
|
||||
dc.Ellipse(iPointX + m_vecSurfacePoints[i].fX*iEachSmallSize - 2, iPointY - 2, iPointX + m_vecSurfacePoints[i].fX*iEachSmallSize + 2, iPointY + 2);
|
||||
}
|
||||
|
||||
|
||||
//标识电极编号,电极位置重复,后面的覆盖前面的
|
||||
strlog.Format(_T("%d"), m_vecSurfacePoints[i].uiElecID);
|
||||
rcText.left = iPointX + m_vecSurfacePoints[i].fX*iEachSmallSize - 3;
|
||||
rcText.top = iPointY - 20;
|
||||
rcText.right = rcText.left + 20;
|
||||
rcText.bottom = iPointY - 1;
|
||||
font.CreatePointFont(70, _T(""), &fdc);
|
||||
fdc.SelectObject(&font);
|
||||
fdc.DrawText(strlog, &rcText, DT_WORDBREAK | DT_BOTTOM);
|
||||
//dc.TextOutA(iPointX + m_vecSurfacePoints[i].fX*iEachSmallSize - 4, iPointY - 20, strlog);
|
||||
}
|
||||
}
|
||||
|
||||
//绘制孔线
|
||||
if (iBoreholeCount > 0)
|
||||
{
|
||||
int iPointY = m_rcBrush.top;
|
||||
int iPointX = m_rcBrush.left;
|
||||
int iDrawBoreholeWidth = 0;//实际绘制孔的宽度
|
||||
//没有地表线
|
||||
/*if (iSurfaceCount <= 0)
|
||||
{
|
||||
//只有一个孔,居中
|
||||
if (iBoreholeCount == 1)
|
||||
{
|
||||
iPointX = m_rcBrush.left + (m_rcBrush.right - m_rcBrush.left) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
//先计算所有孔绘制出来后需要的宽度,然后再从中心对称的方式求出X轴起点
|
||||
if (pBoreholeXValue != NULL)
|
||||
{
|
||||
iDrawBoreholeWidth = (pBoreholeXValue[iBoreholeCount - 1] - pBoreholeXValue[0])*iEachSmallSize;
|
||||
iPointX = m_rcBrush.left + (m_rcBrush.right - m_rcBrush.left) / 2 - iDrawBoreholeWidth / 2;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
int iCurOneBoreHoleCount = 0;
|
||||
int i = 0;
|
||||
//遍历每一孔
|
||||
std::map<STWellPoints, std::vector<STBoreHolePoints>>::iterator iter = m_mapBoreholePoints.begin();
|
||||
for (int iBoreholeIndex = 0; iBoreholeIndex < iBoreholeCount, iter != m_mapBoreholePoints.end(); iBoreholeIndex++, iter++)
|
||||
{
|
||||
iCurOneBoreHoleCount = iter->second.size();
|
||||
//绘制一个孔的主线
|
||||
/*if (iSurfaceCount <= 0)
|
||||
{
|
||||
if (iBoreholeIndex > 0)
|
||||
{
|
||||
iPointX = iPointX + (pBoreholeXValue[iBoreholeIndex] - pBoreholeXValue[iBoreholeIndex - 1])*iEachSmallSize;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//同一个孔的X值相等
|
||||
iPointX = m_rcBrush.left + iter->second.at(0).fX*iEachSmallSize;
|
||||
}*/
|
||||
iPointX = m_rcBrush.left + iter->second.at(0).fX*iEachSmallSize;
|
||||
|
||||
dc.MoveTo(iPointX, m_rcBrush.top);
|
||||
dc.LineTo(iPointX, m_rcBrush.top + iEachSmallSize*abs(iter->second.at(iCurOneBoreHoleCount - 1).fZ));
|
||||
strlog.Format(_T("第%d口井起点x=%d,y=%d,终点x=%d,y=%d\n"), iBoreholeIndex + 1, iPointX, m_rcBrush.top, iPointX, m_rcBrush.top + iEachSmallSize*abs(iter->second.at(iCurOneBoreHoleCount - 1).fZ));
|
||||
OutputDebugString(strlog);
|
||||
|
||||
//遍历集合的每一个元素
|
||||
for (i = 0; i < iCurOneBoreHoleCount; i++)
|
||||
{
|
||||
strlog.Format(_T("Z轴绘制点vecCurBoreHolePoint[%d].fZ值为%f,fEachSmallSize=%d,j=%d x1=%d,y1=%d,x2=%d,y2=%d\n"), i, iter->second[i].fZ, iEachSmallSize, abs(iter->second[i].fZ), iPointX - 2, iPointY + abs(iter->second[i].fZ)*iEachSmallSize - 2, iPointX + 2, iPointY + abs(iter->second[i].fZ)*iEachSmallSize + 2);
|
||||
OutputDebugString(strlog);
|
||||
|
||||
|
||||
if (iter->second[i].uiElecID == m_iA || iter->second[i].uiElecID == m_iB)
|
||||
{
|
||||
pBrush = dc.SelectObject(&cRedBrush);
|
||||
dc.Ellipse(iPointX - 5, iPointY + abs(iter->second[i].fZ)*iEachSmallSize - 5, iPointX + 5, iPointY + abs(iter->second[i].fZ)*iEachSmallSize + 5);
|
||||
}
|
||||
else if (iter->second[i].uiElecID == m_iM || iter->second[i].uiElecID == m_iN)
|
||||
{
|
||||
pBrush = dc.SelectObject(&cBlueBrush);
|
||||
dc.Ellipse(iPointX - 5, iPointY + abs(iter->second[i].fZ)*iEachSmallSize - 5, iPointX + 5, iPointY + abs(iter->second[i].fZ)*iEachSmallSize + 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
pBrush = dc.SelectObject(&cBlackBrush);
|
||||
dc.Ellipse(iPointX - 2, iPointY + abs(iter->second[i].fZ)*iEachSmallSize - 2, iPointX + 2, iPointY + abs(iter->second[i].fZ)*iEachSmallSize + 2);
|
||||
}
|
||||
|
||||
//标识电极编号,电极位置重复,后面的覆盖前面的
|
||||
strlog.Format(_T("%d"), iter->second[i].uiElecID);
|
||||
rcText.left = iPointX + 4;
|
||||
rcText.right = rcText.left + 20;
|
||||
rcText.top = iPointY + abs(iter->second[i].fZ)*iEachSmallSize - 8;
|
||||
rcText.bottom = rcText.top + 15;
|
||||
//dc.TextOutA(iPointX + 4, iPointY + abs(iter->second[i].fZ)*iEachSmallSize - 8, strlog);
|
||||
//dc.DrawText(strlog, &rcText, DT_WORDBREAK | DT_LEFT);
|
||||
font.CreatePointFont(70, _T(""), &fdc);
|
||||
fdc.SelectObject(&font);
|
||||
fdc.DrawText(strlog, &rcText, DT_WORDBREAK | DT_LEFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
dc.SelectObject(pBrush);
|
||||
// TODO: 在此处添加消息处理程序代码
|
||||
// 不为绘图消息调用 CDialog::OnPaint()
|
||||
}
|
||||
|
||||
|
||||
//将坐标点添加到井下集合
|
||||
void C2DSimulationDlg::AddBoreholePointToVector(std::map<STWellPoints, std::vector<STBoreHolePoints>> mapNewPoints)
|
||||
{
|
||||
m_mapBoreholePoints.clear();
|
||||
m_mapBoreholePoints = mapNewPoints;
|
||||
RedrawWindow();
|
||||
}
|
||||
|
||||
//将坐标点添加到地表集合
|
||||
void C2DSimulationDlg::AddSurfacePointsToVector(std::vector<STBoreHolePoints> vecNewPoints)
|
||||
{
|
||||
m_vecSurfacePoints.clear();
|
||||
|
||||
m_vecSurfacePoints = vecNewPoints;
|
||||
RedrawWindow();
|
||||
|
||||
}
|
||||
|
||||
//清空所有的线
|
||||
void C2DSimulationDlg::DeleteCoordinatesPoint()
|
||||
{
|
||||
m_mapBoreholePoints.clear();
|
||||
m_vecSurfacePoints.clear();
|
||||
RedrawWindow();
|
||||
}
|
||||
|
||||
void C2DSimulationDlg::SetTimeInterval(int iTimeInterval)
|
||||
{
|
||||
m_iTimeInterval = iTimeInterval;
|
||||
}
|
||||
|
||||
void C2DSimulationDlg::SetSingleChannelSimulationRunMethod(vector<STDatabaseABMNInfo> vecAllBoreholeABMNInfo)
|
||||
{
|
||||
m_vecAllBoreholeABMNInfo.clear();
|
||||
m_vecAllBoreholeABMNInfo = vecAllBoreholeABMNInfo;
|
||||
}
|
||||
|
||||
void C2DSimulationDlg::SetMultiChannelSimulationRunMethod(map<int, map<int, map<int, STDatabaseABMNInfo>>> mapPointsSortedByABMN)
|
||||
{
|
||||
m_mapPointsSortedByABMN.clear();
|
||||
m_mapPointsSortedByABMN = mapPointsSortedByABMN;
|
||||
}
|
||||
|
||||
//开始模拟
|
||||
BOOL C2DSimulationDlg::StartSimulation()
|
||||
{
|
||||
m_bStopSimulation = FALSE;
|
||||
HANDLE hThread = ::CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)SimulateScriptRunMethodThread, this, 0, 0);
|
||||
if (INVALID_HANDLE_VALUE == hThread)
|
||||
{
|
||||
CFileOperTools::GetInstance()->WriteComLog(_T("Create Thread failed to simulate script run method"));
|
||||
}
|
||||
CloseHandle(hThread);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//上传设备市场数据到云端
|
||||
UINT C2DSimulationDlg::SimulateScriptRunMethodThread(LPVOID lParam)
|
||||
{
|
||||
C2DSimulationDlg* pThis = (C2DSimulationDlg*)lParam;
|
||||
if (pThis == NULL)
|
||||
return 1;
|
||||
|
||||
//CString strLog;
|
||||
//theApp.m_ucIsMultiChannel 0:单通道;1:多通道
|
||||
if (EN_MULTI_CHANNEL == theApp.m_ucIsMultiChannel)
|
||||
{
|
||||
map<int, map<int, map<int, STDatabaseABMNInfo>>>::iterator iterA = pThis->m_mapPointsSortedByABMN.begin();
|
||||
map<int, map<int, STDatabaseABMNInfo>>::iterator iterB;
|
||||
map<int, STDatabaseABMNInfo>::iterator iterM;
|
||||
int iTSN = 0;
|
||||
for (; iterA != pThis->m_mapPointsSortedByABMN.end(); iterA++)
|
||||
{
|
||||
for (iterB = iterA->second.begin(); iterB != iterA->second.end(); iterB++)
|
||||
{
|
||||
for (iterM = iterB->second.begin(); iterM != iterB->second.end(); iterM++)
|
||||
{
|
||||
if (pThis->m_bStopSimulation)
|
||||
{
|
||||
break;
|
||||
}
|
||||
pThis->m_iA = iterM->second.uiAElecID;
|
||||
pThis->m_iB = iterM->second.uiBElecID;
|
||||
pThis->m_iM = iterM->second.uiMElecID;
|
||||
pThis->m_iN = iterM->second.uiNElecID;
|
||||
pThis->RedrawWindow();
|
||||
//strLog.Format(_T("******************************C2DSimulationDlg::SimulateScriptRunMethodThread a=%d,b=%d,m=%d,n=%d\n"), pThis->m_iA, pThis->m_iB, pThis->m_iM, pThis->m_iN);
|
||||
//OutputDebugString(strLog);
|
||||
Sleep(pThis->m_iTimeInterval);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (0 == theApp.m_ucIsMultiChannel)
|
||||
{
|
||||
int iPointCount = pThis->m_vecAllBoreholeABMNInfo.size();
|
||||
for (int i = 0; i < iPointCount; i++)
|
||||
{
|
||||
if (pThis->m_bStopSimulation)
|
||||
{
|
||||
break;
|
||||
}
|
||||
pThis->m_iA = pThis->m_vecAllBoreholeABMNInfo[i].uiAElecID;
|
||||
pThis->m_iB = pThis->m_vecAllBoreholeABMNInfo[i].uiBElecID;
|
||||
pThis->m_iM = pThis->m_vecAllBoreholeABMNInfo[i].uiMElecID;
|
||||
pThis->m_iN = pThis->m_vecAllBoreholeABMNInfo[i].uiNElecID;
|
||||
pThis->RedrawWindow();
|
||||
//strLog.Format(_T("******************************C2DSimulationDlg::SimulateScriptRunMethodThread a=%d,b=%d,m=%d,n=%d\n"), pThis->m_iA, pThis->m_iB, pThis->m_iM, pThis->m_iN);
|
||||
//OutputDebugString(strLog);
|
||||
Sleep(pThis->m_iTimeInterval);
|
||||
}
|
||||
}
|
||||
|
||||
::SendMessage(pThis->GetParent()->GetParent()->GetSafeHwnd(), WM_MSG_UPDATE_CROSSHOLEMAINWND_BTN, NULL, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//结束模拟
|
||||
BOOL C2DSimulationDlg::StopSimulation()
|
||||
{
|
||||
m_bStopSimulation = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//是否正在模拟中
|
||||
BOOL C2DSimulationDlg::IsSimulating()
|
||||
{
|
||||
return !m_bStopSimulation;
|
||||
}
|
||||
@@ -0,0 +1,539 @@
|
||||
// C3DSimulationDlg.cpp : 实现文件
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GeoMative.h"
|
||||
#include "crossHole/C3DSimulationDlg.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
#define DRAW_ARROW_LENGTH (5) //X/Y/Z方向示意图
|
||||
#define DRAW_BOARD_TO_SIDE_DISTANCE (50) //绘制电缆示意图画布到边框的距离
|
||||
#define DRAW_X_Y_Z_EXTESION_LINES_LEN (20) //绘制延长线长度
|
||||
#define SIMULATION_DRAW_CIRCLE_SIZE (5) //模拟状态选中时绘制电极大小
|
||||
#define NORMAL_DRAW_CIRCLE_SIZE (2) //正常绘制电极大小
|
||||
#define DRAW_FONT_SIZE (100) //字体大小
|
||||
|
||||
// C3DSimulationDlg 对话框
|
||||
extern CGeoMativeApp theApp;
|
||||
IMPLEMENT_DYNAMIC(C3DSimulationDlg, CDialog)
|
||||
|
||||
C3DSimulationDlg::C3DSimulationDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(C3DSimulationDlg::IDD, pParent)
|
||||
{
|
||||
m_bStopSimulation = TRUE;
|
||||
m_iTimeInterval = 1000;
|
||||
m_fMaxCableLength = 0.0;
|
||||
m_iEachSmallSize = 0;
|
||||
m_isNeedCalc = FALSE;
|
||||
m_pFont = NULL;
|
||||
}
|
||||
|
||||
C3DSimulationDlg::~C3DSimulationDlg()
|
||||
{
|
||||
if (m_pFont != NULL)
|
||||
{
|
||||
delete m_pFont;
|
||||
m_pFont = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void C3DSimulationDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(C3DSimulationDlg, CDialog)
|
||||
ON_WM_PAINT()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
C3DSimulationDlg* C3DSimulationDlg::GetInstance()
|
||||
{
|
||||
static C3DSimulationDlg simulationBoardDlg;
|
||||
return &simulationBoardDlg;
|
||||
}
|
||||
|
||||
BOOL C3DSimulationDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
// TODO: 在此添加额外的初始化
|
||||
GetParent()->GetClientRect(&m_rcWnd);
|
||||
m_rcBrush.left = m_rcWnd.left + DRAW_BOARD_TO_SIDE_DISTANCE;
|
||||
m_rcBrush.right = m_rcWnd.right - DRAW_BOARD_TO_SIDE_DISTANCE;
|
||||
m_rcBrush.top = m_rcWnd.top + DRAW_BOARD_TO_SIDE_DISTANCE;
|
||||
m_rcBrush.bottom = m_rcWnd.bottom - DRAW_BOARD_TO_SIDE_DISTANCE;
|
||||
m_pFont = new CFont();
|
||||
m_pFont->CreatePointFont(DRAW_FONT_SIZE, _T("楷体"));
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// 异常: OCX 属性页应返回 FALSE
|
||||
}
|
||||
|
||||
float C3DSimulationDlg::CalcMaxCableLength()
|
||||
{
|
||||
float fDrawBoradMaxLength = 0;
|
||||
STWellPoints* pstWellPoint = NULL;
|
||||
|
||||
int iSurfaceXCount = m_mapSurfaceXPoints.size();
|
||||
int iSurfaceYCount = m_mapSurfaceYPoints.size();
|
||||
int iBoreholeCount = m_mapBoreholePoints.size();
|
||||
map<int, std::vector<STBoreHolePoints>>::iterator iter;
|
||||
if (iBoreholeCount > 0)
|
||||
{
|
||||
float fTempDepth = 0.0;
|
||||
pstWellPoint = new STWellPoints[iBoreholeCount];
|
||||
map<STWellPoints, vector<STBoreHolePoints>>::iterator iter = m_mapBoreholePoints.begin();
|
||||
for (int i = 0; i < iBoreholeCount, iter != m_mapBoreholePoints.end(); i++, iter++)
|
||||
{
|
||||
pstWellPoint[i] = iter->first;
|
||||
//Z方向
|
||||
fTempDepth = abs(iter->second.at(iter->second.size() - 1).fZ) + sqrt(pow(iter->second.at(iter->second.size() - 1).fY, 2) / 2);
|
||||
if (fTempDepth > fDrawBoradMaxLength)
|
||||
{
|
||||
fDrawBoradMaxLength = fTempDepth;
|
||||
}
|
||||
|
||||
//X方向
|
||||
fTempDepth = iter->second.at(iter->second.size() - 1).fX + sqrt(pow(iter->second.at(iter->second.size() - 1).fY, 2) / 2);
|
||||
if (fTempDepth > fDrawBoradMaxLength)
|
||||
{
|
||||
fDrawBoradMaxLength = fTempDepth;
|
||||
}
|
||||
}
|
||||
|
||||
if (pstWellPoint != NULL)
|
||||
{
|
||||
delete[] pstWellPoint;
|
||||
pstWellPoint = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
fDrawBoradMaxLength = abs(fDrawBoradMaxLength);
|
||||
if (iSurfaceXCount > 0)
|
||||
{
|
||||
int iWellSize = 0;
|
||||
for (iter = m_mapSurfaceXPoints.begin(); iter != m_mapSurfaceXPoints.end(); iter++)
|
||||
{
|
||||
iWellSize = iter->second.size();
|
||||
if (iter->second[iWellSize - 1].fX > fDrawBoradMaxLength)
|
||||
fDrawBoradMaxLength = iter->second[iWellSize - 1].fX;
|
||||
}
|
||||
}
|
||||
|
||||
if (iSurfaceYCount > 0)
|
||||
{
|
||||
int iWellSize = 0;
|
||||
float fCurMaxXValue = 0.0;
|
||||
for (iter = m_mapSurfaceYPoints.begin(); iter != m_mapSurfaceYPoints.end(); iter++)
|
||||
{
|
||||
iWellSize = iter->second.size();
|
||||
fCurMaxXValue = iter->second[iWellSize - 1].fX + sqrt(pow(iter->second[iWellSize - 1].fY, 2) / 2);
|
||||
if (fCurMaxXValue > fDrawBoradMaxLength)
|
||||
fDrawBoradMaxLength = fCurMaxXValue;
|
||||
}
|
||||
}
|
||||
|
||||
return fDrawBoradMaxLength;
|
||||
}
|
||||
|
||||
void C3DSimulationDlg::OnPaint()
|
||||
{
|
||||
CPaintDC dc(this); // device context for painting
|
||||
dc.FillSolidRect(m_rcWnd, RGB(255, 255, 255));
|
||||
dc.SelectObject(m_pFont);
|
||||
CPen pen, penEx,penBlue;
|
||||
pen.CreatePen(PS_SOLID, 2, RGB(0, 0, 0));
|
||||
penEx.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
|
||||
penBlue.CreatePen(PS_SOLID, 2, RGB(81, 81, 255));
|
||||
dc.SelectObject(pen);
|
||||
|
||||
CString strlog;
|
||||
CBrush brush, blueBrush;
|
||||
brush.CreateSolidBrush(RGB(0, 0, 0));
|
||||
blueBrush.CreateSolidBrush(RGB(81, 81, 255));
|
||||
CBrush cBlackBrush, cRedBrush;
|
||||
cBlackBrush.CreateSolidBrush(RGB(0, 0, 0));
|
||||
cRedBrush.CreateSolidBrush(RGB(255, 0, 0));
|
||||
dc.SelectObject(&brush);
|
||||
|
||||
if (!m_isNeedCalc)
|
||||
{
|
||||
m_fMaxCableLength = CalcMaxCableLength();
|
||||
|
||||
m_iEachSmallSize = (m_rcBrush.right - m_rcBrush.left) / m_fMaxCableLength;
|
||||
if (m_rcBrush.bottom - m_rcBrush.top < m_rcBrush.right - m_rcBrush.left)
|
||||
{
|
||||
m_iEachSmallSize = (m_rcBrush.bottom - m_rcBrush.top) / m_fMaxCableLength - 1;
|
||||
}
|
||||
m_isNeedCalc = TRUE;
|
||||
}
|
||||
|
||||
//水平布线,判断是否需要绘制
|
||||
int iSurfaceXCount = m_mapSurfaceXPoints.size();
|
||||
int iSurfaceYCount = m_mapSurfaceYPoints.size();
|
||||
int iBoreholeCount = m_mapBoreholePoints.size();
|
||||
map<int, std::vector<STBoreHolePoints>>::iterator iter;
|
||||
strlog.Format(_T("最大电缆长度m_fMaxCableLength=%f,每个刻度对应的像素m_iEachSmallSize=%d\n"), m_fMaxCableLength, m_iEachSmallSize);
|
||||
OutputDebugString(strlog);
|
||||
|
||||
if (iBoreholeCount > 0 || iSurfaceXCount > 0 || iSurfaceYCount > 0)
|
||||
{
|
||||
dc.SelectObject(penEx);
|
||||
//X
|
||||
dc.MoveTo(m_rcBrush.left, m_rcBrush.top);
|
||||
dc.LineTo(m_rcBrush.left + m_iEachSmallSize*m_fMaxCableLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, m_rcBrush.top);
|
||||
//箭头
|
||||
dc.MoveTo(m_rcBrush.left + m_iEachSmallSize*m_fMaxCableLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, m_rcBrush.top);
|
||||
dc.LineTo(m_rcBrush.left + m_iEachSmallSize*m_fMaxCableLength + DRAW_X_Y_Z_EXTESION_LINES_LEN - DRAW_ARROW_LENGTH, m_rcBrush.top - DRAW_ARROW_LENGTH);
|
||||
dc.MoveTo(m_rcBrush.left + m_iEachSmallSize*m_fMaxCableLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, m_rcBrush.top);
|
||||
dc.LineTo(m_rcBrush.left + m_iEachSmallSize*m_fMaxCableLength + DRAW_X_Y_Z_EXTESION_LINES_LEN - DRAW_ARROW_LENGTH, m_rcBrush.top + DRAW_ARROW_LENGTH);
|
||||
dc.TextOutA(m_rcBrush.left + m_iEachSmallSize*m_fMaxCableLength + DRAW_X_Y_Z_EXTESION_LINES_LEN + 5, m_rcBrush.top - DRAW_ARROW_LENGTH / 2, _T("X"));
|
||||
//Y
|
||||
dc.MoveTo(m_rcBrush.left, m_rcBrush.top);
|
||||
dc.LineTo(m_rcBrush.left + sqrt(pow(m_iEachSmallSize*m_fMaxCableLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, 2) / 2), m_rcBrush.top + sqrt(pow(m_iEachSmallSize*m_fMaxCableLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, 2) / 2));
|
||||
dc.MoveTo(m_rcBrush.left + sqrt(pow(m_iEachSmallSize*m_fMaxCableLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, 2) / 2), m_rcBrush.top + sqrt(pow(m_iEachSmallSize*m_fMaxCableLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, 2) / 2));
|
||||
dc.LineTo(m_rcBrush.left + sqrt(pow(m_iEachSmallSize*m_fMaxCableLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, 2) / 2), m_rcBrush.top + sqrt(pow(m_iEachSmallSize*m_fMaxCableLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, 2) / 2) - DRAW_ARROW_LENGTH);
|
||||
dc.MoveTo(m_rcBrush.left + sqrt(pow(m_iEachSmallSize*m_fMaxCableLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, 2) / 2), m_rcBrush.top + sqrt(pow(m_iEachSmallSize*m_fMaxCableLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, 2) / 2));
|
||||
dc.LineTo(m_rcBrush.left + sqrt(pow(m_iEachSmallSize*m_fMaxCableLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, 2) / 2) - DRAW_ARROW_LENGTH, m_rcBrush.top + sqrt(pow(m_iEachSmallSize*m_fMaxCableLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, 2) / 2));
|
||||
dc.TextOutA(m_rcBrush.left + sqrt(pow(m_iEachSmallSize*m_fMaxCableLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, 2) / 2) + 5, m_rcBrush.top + sqrt(pow(m_iEachSmallSize*m_fMaxCableLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, 2) / 2) + 5, _T("Y"));
|
||||
|
||||
//Z
|
||||
dc.MoveTo(m_rcBrush.left, m_rcBrush.top);
|
||||
dc.LineTo(m_rcBrush.left, m_rcBrush.top + m_iEachSmallSize*m_fMaxCableLength + DRAW_X_Y_Z_EXTESION_LINES_LEN);
|
||||
dc.MoveTo(m_rcBrush.left, m_rcBrush.top + m_iEachSmallSize*m_fMaxCableLength + DRAW_X_Y_Z_EXTESION_LINES_LEN);
|
||||
dc.LineTo(m_rcBrush.left - DRAW_ARROW_LENGTH, m_rcBrush.top + m_iEachSmallSize*m_fMaxCableLength + DRAW_X_Y_Z_EXTESION_LINES_LEN - DRAW_ARROW_LENGTH);
|
||||
dc.MoveTo(m_rcBrush.left, m_rcBrush.top + m_iEachSmallSize*m_fMaxCableLength + DRAW_X_Y_Z_EXTESION_LINES_LEN);
|
||||
dc.LineTo(m_rcBrush.left + DRAW_ARROW_LENGTH, m_rcBrush.top + m_iEachSmallSize*m_fMaxCableLength + DRAW_X_Y_Z_EXTESION_LINES_LEN - DRAW_ARROW_LENGTH);
|
||||
dc.TextOutA(m_rcBrush.left - DRAW_ARROW_LENGTH / 2, m_rcBrush.top + m_iEachSmallSize*m_fMaxCableLength + DRAW_X_Y_Z_EXTESION_LINES_LEN + 5, _T("Z"));
|
||||
dc.SelectObject(pen);
|
||||
}
|
||||
|
||||
//X方向电缆示意图
|
||||
if (iSurfaceXCount > 0)
|
||||
{
|
||||
int i = 0;
|
||||
int iPointX = m_rcBrush.left;
|
||||
int iPointY = m_rcBrush.top;
|
||||
for (iter = m_mapSurfaceXPoints.begin(); iter != m_mapSurfaceXPoints.end(); iter++)
|
||||
{
|
||||
iSurfaceXCount = iter->second.size();
|
||||
//如果没有孔,在中间绘制
|
||||
if (iBoreholeCount <= 0 && iSurfaceYCount <= 0)
|
||||
{
|
||||
iPointY = m_rcBrush.top + (m_rcBrush.bottom - m_rcBrush.top) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
//确定起点X坐标
|
||||
iPointX = m_rcBrush.left + m_iEachSmallSize* iter->second[0].fX;
|
||||
}
|
||||
|
||||
//绘制一条总线
|
||||
dc.MoveTo(iPointX, iPointY);
|
||||
dc.LineTo(iPointX + m_iEachSmallSize*(iter->second[iSurfaceXCount - 1].fX - iter->second[0].fX), iPointY);
|
||||
strlog.Format(_T("地表 起点x=%d,y=%d,终点x=%d,y=%d\n"), iPointX, iPointY, iPointX + m_iEachSmallSize*iter->second[iSurfaceXCount - 1].fX, iPointY);
|
||||
OutputDebugString(strlog);
|
||||
|
||||
iPointX = m_rcBrush.left;
|
||||
|
||||
//遍历集合的每一个元素
|
||||
for (i = 0; i < iSurfaceXCount; i++)
|
||||
{
|
||||
strlog.Format(_T("X轴绘制点iterX->second[%d].fX值为%f,fEachSmallSize=%d,fEachSmallSize=%.2f,iterY->second[i].fY=%.2f x1=%.2f,y1=%.2f,x2=%.2f,y2=%.2f\n\n"), i, iter->second[i].fX, m_iEachSmallSize, iter->second[i].fX, iPointX + iter->second[i].fX*m_iEachSmallSize - 2, iPointY - 2, iPointX + iter->second[i].fX*m_iEachSmallSize + 2, iPointY + 2);
|
||||
OutputDebugString(strlog);
|
||||
//dc.Ellipse(iPointX + iterX->second[i].fX*m_iEachSmallSize - 2, iPointY - 2, iPointX + iterX->second[i].fX*m_iEachSmallSize + 2, iPointY + 2);
|
||||
if (iter->second[i].uiElecID == m_iA || iter->second[i].uiElecID == m_iB)
|
||||
{
|
||||
dc.SelectObject(&cRedBrush);
|
||||
dc.Ellipse(iPointX + iter->second[i].fX*m_iEachSmallSize - 5, iPointY - 5, iPointX + iter->second[i].fX*m_iEachSmallSize + 5, iPointY + 5);
|
||||
}
|
||||
else if (iter->second[i].uiElecID == m_iM || iter->second[i].uiElecID == m_iN)
|
||||
{
|
||||
dc.SelectObject(&blueBrush);
|
||||
dc.Ellipse(iPointX + iter->second[i].fX*m_iEachSmallSize - 5, iPointY - 5, iPointX + iter->second[i].fX*m_iEachSmallSize + 5, iPointY + 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
dc.SelectObject(&cBlackBrush);
|
||||
dc.Ellipse(iPointX + iter->second[i].fX*m_iEachSmallSize - 2, iPointY - 2, iPointX + iter->second[i].fX*m_iEachSmallSize + 2, iPointY + 2);
|
||||
}
|
||||
strlog.Format(_T("%d"), iter->second[i].uiElecID);
|
||||
dc.TextOutA(iPointX + iter->second[i].fX*m_iEachSmallSize -3, iPointY - 20, strlog);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Y方向电缆示意图
|
||||
if (iSurfaceYCount > 0)
|
||||
{
|
||||
int i = 0;
|
||||
float fYCellSize;
|
||||
int iPointX = m_rcBrush.left;
|
||||
int iPointY = m_rcBrush.top;
|
||||
for (iter = m_mapSurfaceYPoints.begin(); iter != m_mapSurfaceYPoints.end(); iter++)
|
||||
{
|
||||
iSurfaceYCount = iter->second.size();
|
||||
//确定起点X坐标
|
||||
iPointX = m_rcBrush.left + m_iEachSmallSize* iter->second[0].fX;
|
||||
|
||||
//绘制一条总线
|
||||
dc.MoveTo(iPointX, iPointY);
|
||||
fYCellSize = m_iEachSmallSize*iter->second[iSurfaceYCount - 1].fY;
|
||||
dc.LineTo(iPointX + sqrt(pow(fYCellSize, 2) / 2), iPointY + sqrt(pow(fYCellSize, 2) / 2));
|
||||
strlog.Format(_T("地表 起点x=%d,y=%d,终点x=%d,y=%d\n"), iPointX, iPointY, iPointX + fYCellSize, iPointY + fYCellSize);
|
||||
OutputDebugString(strlog);
|
||||
|
||||
//iPointX = m_rcBrush.left;
|
||||
iPointY = m_rcBrush.top;
|
||||
|
||||
//遍历集合的每一个元素
|
||||
for (i = 0; i < iSurfaceYCount; i++)
|
||||
{
|
||||
fYCellSize = sqrt(pow(iter->second[i].fY*m_iEachSmallSize, 2) / 2);
|
||||
strlog.Format(_T("Y轴绘制点iterY->second[%d].fX值为%f,ElecID=%d,fEachSmallSize=%.2f,iterY->second[i].fY=%.2f x1=%.2f,y1=%.2f,x2=%.2f,y2=%.2f\n"), i, iter->second[i].fX, iter->second[i].uiElecID, m_iEachSmallSize, iter->second[i].fY, \
|
||||
iPointX + iter->second[i].fY*m_iEachSmallSize - 2, iPointY + iter->second[i].fY*m_iEachSmallSize - 2, iPointX + iter->second[i].fY*m_iEachSmallSize + 2, iPointY + iter->second[i].fY*m_iEachSmallSize + 2);
|
||||
OutputDebugString(strlog);
|
||||
//dc.Ellipse(iPointX + fYCellSize - 2, iPointY + fYCellSize - 2, iPointX + fYCellSize + 2, iPointY + fYCellSize + 2);
|
||||
strlog.Format(_T("%d"), iter->second[i].uiElecID);
|
||||
if (iter->second[i].uiElecID == m_iA || iter->second[i].uiElecID == m_iB)
|
||||
{
|
||||
dc.SelectObject(&cRedBrush);
|
||||
dc.Ellipse(iPointX + fYCellSize - 5, iPointY + fYCellSize - 5, iPointX + fYCellSize + 5, iPointY + fYCellSize + 5);
|
||||
dc.TextOutA(iPointX + fYCellSize + 10, iPointY + fYCellSize - 7, strlog);
|
||||
}
|
||||
else if (iter->second[i].uiElecID == m_iM || iter->second[i].uiElecID == m_iN)
|
||||
{
|
||||
dc.SelectObject(&blueBrush);
|
||||
dc.Ellipse(iPointX + fYCellSize - 5, iPointY + fYCellSize - 5, iPointX + fYCellSize + 5, iPointY + fYCellSize + 5);
|
||||
dc.TextOutA(iPointX + fYCellSize + 10, iPointY + fYCellSize - 7, strlog);
|
||||
}
|
||||
else
|
||||
{
|
||||
dc.SelectObject(&cBlackBrush);
|
||||
dc.Ellipse(iPointX + fYCellSize - 2, iPointY + fYCellSize - 2, iPointX + fYCellSize + 2, iPointY + fYCellSize + 2);
|
||||
dc.TextOutA(iPointX + fYCellSize + 7, iPointY + fYCellSize - 7, strlog);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//井下电缆示意图
|
||||
dc.SelectObject(&blueBrush);
|
||||
dc.SelectObject(penBlue);
|
||||
if (iBoreholeCount > 0)
|
||||
{
|
||||
int iPointY = m_rcBrush.top;
|
||||
int iPointX = m_rcBrush.left;
|
||||
int iLastPointX = 0;
|
||||
int iDrawBoreholeWidth = 0;//实际绘制孔的宽度
|
||||
float fWellYPoint = 0.0;
|
||||
int iCurOneBoreHoleCount = 0;
|
||||
int i = 0;
|
||||
//遍历每一孔
|
||||
map<STWellPoints, vector<STBoreHolePoints>>::iterator iter = m_mapBoreholePoints.begin();
|
||||
for (int iBoreholeIndex = 0; iBoreholeIndex < iBoreholeCount, iter != m_mapBoreholePoints.end(); iBoreholeIndex++, iter++)
|
||||
{
|
||||
iCurOneBoreHoleCount = iter->second.size();
|
||||
//同一个孔的X值相等
|
||||
iLastPointX = iPointX = m_rcBrush.left + iter->second.at(0).fX*m_iEachSmallSize;
|
||||
fWellYPoint = m_iEachSmallSize*iter->second.at(0).fY;
|
||||
if (iter->second.at(0).fY > 0.000001)
|
||||
{
|
||||
iPointX += sqrt(pow(fWellYPoint, 2) / 2);
|
||||
}
|
||||
|
||||
//绘制井口坐标到X、Y的距离
|
||||
dc.MoveTo(iLastPointX, m_rcBrush.top);
|
||||
dc.LineTo(iPointX, m_rcBrush.top + sqrt(pow(fWellYPoint, 2) / 2));
|
||||
dc.MoveTo(m_rcBrush.left + sqrt(pow(fWellYPoint, 2) / 2), m_rcBrush.top + sqrt(pow(fWellYPoint, 2) / 2));
|
||||
dc.LineTo(iPointX, m_rcBrush.top + sqrt(pow(fWellYPoint, 2) / 2));
|
||||
|
||||
//绘制井主线
|
||||
dc.MoveTo(iPointX, m_rcBrush.top + sqrt(pow(fWellYPoint, 2) / 2));
|
||||
dc.LineTo(iPointX, m_rcBrush.top + m_iEachSmallSize*abs(iter->second.at(iCurOneBoreHoleCount - 1).fZ) + sqrt(pow(fWellYPoint, 2) / 2));
|
||||
strlog.Format(_T("第%d口井起点x=%f,y=%f,z=%f\n"), iBoreholeIndex + 1, iPointX, m_rcBrush.top + sqrt(pow(fWellYPoint, 2) / 2), m_rcBrush.top + m_iEachSmallSize*abs(iter->second.at(iCurOneBoreHoleCount - 1).fZ) + sqrt(pow(fWellYPoint, 2) / 2));
|
||||
OutputDebugString(strlog);
|
||||
|
||||
//遍历集合的每一个元素
|
||||
for (i = 0; i < iCurOneBoreHoleCount; i++)
|
||||
{
|
||||
strlog.Format(_T("Z轴绘制点vecCurBoreHolePoint[%d].fZ值为%f,fEachSmallSize=%.2f,iterY->second[i].fY=%.2f x1=%.2f,y1=%.2f,x2=%.2f,y2=%.2f\n"), i, iter->second[i].fZ, m_iEachSmallSize, abs(iter->second[i].fZ), iPointX - 2, iPointY + abs(iter->second[i].fZ)*m_iEachSmallSize - 2, iPointX + 2, iPointY + abs(iter->second[i].fZ)*m_iEachSmallSize + 2);
|
||||
OutputDebugString(strlog);
|
||||
//dc.Ellipse(iPointX - 2, iPointY + abs(iter->second[i].fZ)*m_iEachSmallSize - 2 + sqrt(pow(fWellYPoint, 2) / 2), iPointX + 2, iPointY + abs(iter->second[i].fZ)*m_iEachSmallSize + 2 + sqrt(pow(fWellYPoint, 2) / 2));
|
||||
strlog.Format(_T("%d"), iter->second[i].uiElecID);
|
||||
if (iter->second[i].uiElecID == m_iA || iter->second[i].uiElecID == m_iB)
|
||||
{
|
||||
dc.SelectObject(&cRedBrush);
|
||||
dc.Ellipse(iPointX - 5, iPointY + abs(iter->second[i].fZ)*m_iEachSmallSize - 5 + sqrt(pow(fWellYPoint, 2) / 2), iPointX + 5, iPointY + abs(iter->second[i].fZ)*m_iEachSmallSize + 5 + sqrt(pow(fWellYPoint, 2) / 2));
|
||||
dc.TextOutA(iPointX + 10, iPointY + abs(iter->second[i].fZ)*m_iEachSmallSize - 8 + sqrt(pow(fWellYPoint, 2) / 2), strlog);
|
||||
}
|
||||
else if (iter->second[i].uiElecID == m_iM || iter->second[i].uiElecID == m_iN)
|
||||
{
|
||||
dc.SelectObject(&blueBrush);
|
||||
dc.Ellipse(iPointX - 5, iPointY + abs(iter->second[i].fZ)*m_iEachSmallSize - 5 + sqrt(pow(fWellYPoint, 2) / 2), iPointX + 5, iPointY + abs(iter->second[i].fZ)*m_iEachSmallSize + 5 + sqrt(pow(fWellYPoint, 2) / 2));
|
||||
dc.TextOutA(iPointX + 10, iPointY + abs(iter->second[i].fZ)*m_iEachSmallSize - 8 + sqrt(pow(fWellYPoint, 2) / 2), strlog);
|
||||
}
|
||||
else
|
||||
{
|
||||
dc.SelectObject(&cBlackBrush);
|
||||
dc.Ellipse(iPointX - 2, iPointY + abs(iter->second[i].fZ)*m_iEachSmallSize - 2 + sqrt(pow(fWellYPoint, 2) / 2), iPointX + 2, iPointY + abs(iter->second[i].fZ)*m_iEachSmallSize + 2 + sqrt(pow(fWellYPoint, 2) / 2));
|
||||
dc.TextOutA(iPointX + 5, iPointY + abs(iter->second[i].fZ)*m_iEachSmallSize - 8 + sqrt(pow(fWellYPoint, 2) / 2), strlog);
|
||||
}
|
||||
//标识电极编号,电极位置重复,后面的覆盖前面的
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//将坐标点添加到井下集合
|
||||
void C3DSimulationDlg::AddBoreholePointToVector(map<STWellPoints, vector<STBoreHolePoints>> mapNewPoints)
|
||||
{
|
||||
m_mapBoreholePoints.clear();
|
||||
m_mapBoreholePoints = mapNewPoints;
|
||||
RedrawWindow();
|
||||
}
|
||||
|
||||
//将坐标点添加到地表集合
|
||||
void C3DSimulationDlg::AddSurfaceXPointsToVector(map<int, std::vector<STBoreHolePoints>> mapXNewPoints)
|
||||
{
|
||||
m_mapSurfaceXPoints.clear();
|
||||
m_mapSurfaceXPoints = mapXNewPoints;
|
||||
RedrawWindow();
|
||||
|
||||
}
|
||||
|
||||
//将坐标点添加到地表集合
|
||||
void C3DSimulationDlg::AddSurfaceYPointsToVector(map<int, std::vector<STBoreHolePoints>> mapYNewPoints)
|
||||
{
|
||||
m_mapSurfaceYPoints.clear();
|
||||
m_mapSurfaceYPoints = mapYNewPoints;
|
||||
RedrawWindow();
|
||||
}
|
||||
|
||||
//清空所有的线
|
||||
void C3DSimulationDlg::DeleteCoordinatesPoint()
|
||||
{
|
||||
m_mapBoreholePoints.clear();
|
||||
m_mapSurfaceXPoints.clear();
|
||||
m_mapSurfaceYPoints.clear();
|
||||
RedrawWindow();
|
||||
}
|
||||
|
||||
void C3DSimulationDlg::SetTimeInterval(int iTimeInterval)
|
||||
{
|
||||
m_iTimeInterval = iTimeInterval;
|
||||
}
|
||||
|
||||
void C3DSimulationDlg::SetSingleChannelSimulationRunMethod(vector<STDatabaseABMNInfo> vecAllBoreholeABMNInfo)
|
||||
{
|
||||
m_vecAllBoreholeABMNInfo.clear();
|
||||
m_vecAllBoreholeABMNInfo = vecAllBoreholeABMNInfo;
|
||||
}
|
||||
|
||||
void C3DSimulationDlg::SetMultiChannelSimulationRunMethod(map<int, map<int, map<int, STDatabaseABMNInfo>>> mapDatabaseABMNInfo)
|
||||
{
|
||||
m_mapPointsSortedByABMN.clear();
|
||||
m_mapPointsSortedByABMN = mapDatabaseABMNInfo;
|
||||
}
|
||||
|
||||
//开始模拟
|
||||
BOOL C3DSimulationDlg::StartSimulation()
|
||||
{
|
||||
m_bStopSimulation = FALSE;
|
||||
HANDLE hThread = ::CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)SimulateScriptRunMethodThread, this, 0, 0);
|
||||
if (INVALID_HANDLE_VALUE == hThread)
|
||||
{
|
||||
CFileOperTools::GetInstance()->WriteComLog(_T("Create Thread failed to simulate script run method"));
|
||||
}
|
||||
CloseHandle(hThread);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//上传设备市场数据到云端
|
||||
UINT C3DSimulationDlg::SimulateScriptRunMethodThread(LPVOID lParam)
|
||||
{
|
||||
C3DSimulationDlg* pThis = (C3DSimulationDlg*)lParam;
|
||||
if (pThis == NULL)
|
||||
return 1;
|
||||
|
||||
//CString strLog;
|
||||
//theApp.m_ucIsMultiChannel 0:单通道;1:多通道
|
||||
if (EN_MULTI_CHANNEL == theApp.m_ucIsMultiChannel)
|
||||
{
|
||||
map<int, map<int, map<int, STDatabaseABMNInfo>>>::iterator iterA = pThis->m_mapPointsSortedByABMN.begin();
|
||||
map<int, map<int, STDatabaseABMNInfo>>::iterator iterB;
|
||||
map<int, STDatabaseABMNInfo>::iterator iterM;
|
||||
int iTSN = 0;
|
||||
for (; iterA != pThis->m_mapPointsSortedByABMN.end(); iterA++)
|
||||
{
|
||||
for (iterB = iterA->second.begin(); iterB != iterA->second.end(); iterB++)
|
||||
{
|
||||
for (iterM = iterB->second.begin(); iterM != iterB->second.end(); iterM++)
|
||||
{
|
||||
if (pThis->m_bStopSimulation)
|
||||
{
|
||||
break;
|
||||
}
|
||||
pThis->m_iA = iterM->second.uiAElecID;
|
||||
pThis->m_iB = iterM->second.uiBElecID;
|
||||
pThis->m_iM = iterM->second.uiMElecID;
|
||||
pThis->m_iN = iterM->second.uiNElecID;
|
||||
pThis->RedrawWindow();
|
||||
//strLog.Format(_T("******************************C3DSimulationDlg::SimulateScriptRunMethodThread a=%d,b=%d,m=%d,n=%d\n"), pThis->m_iA, pThis->m_iB, pThis->m_iM, pThis->m_iN);
|
||||
//OutputDebugString(strLog);
|
||||
Sleep(pThis->m_iTimeInterval);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (0 == theApp.m_ucIsMultiChannel)
|
||||
{
|
||||
int iPointCount = pThis->m_vecAllBoreholeABMNInfo.size();
|
||||
for (int i = 0; i < iPointCount; i++)
|
||||
{
|
||||
if (pThis->m_bStopSimulation)
|
||||
{
|
||||
break;
|
||||
}
|
||||
pThis->m_iA = pThis->m_vecAllBoreholeABMNInfo[i].uiAElecID;
|
||||
pThis->m_iB = pThis->m_vecAllBoreholeABMNInfo[i].uiBElecID;
|
||||
pThis->m_iM = pThis->m_vecAllBoreholeABMNInfo[i].uiMElecID;
|
||||
pThis->m_iN = pThis->m_vecAllBoreholeABMNInfo[i].uiNElecID;
|
||||
pThis->RedrawWindow();
|
||||
Sleep(pThis->m_iTimeInterval);
|
||||
}
|
||||
}
|
||||
|
||||
CWnd* cWnd = pThis->GetParent();
|
||||
if (cWnd == NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
cWnd = cWnd->GetParent();
|
||||
if (cWnd == NULL)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
HWND hWnd = cWnd->GetSafeHwnd();
|
||||
if (hWnd == NULL)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
::SendMessage(hWnd, WM_MSG_UPDATE_CROSSHOLEMAINWND_BTN, NULL, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//结束模拟
|
||||
BOOL C3DSimulationDlg::StopSimulation()
|
||||
{
|
||||
m_bStopSimulation = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//是否正在模拟中
|
||||
BOOL C3DSimulationDlg::IsSimulating()
|
||||
{
|
||||
return !m_bStopSimulation;
|
||||
}
|
||||
@@ -0,0 +1,912 @@
|
||||
// CrossHoleConfigDlg.cpp : 实现文件
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GeoMative.h"
|
||||
#include "crossHole/CCrossHoleConfig2DMainDlg.h"
|
||||
#include "crossHole/C2DSimulationDlg.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
extern CGeoMativeApp theApp;
|
||||
// CCrossHoleConfig2DMainDlg 对话框
|
||||
|
||||
IMPLEMENT_DYNAMIC(CCrossHoleConfig2DMainDlg, CDialog)
|
||||
|
||||
CCrossHoleConfig2DMainDlg::CCrossHoleConfig2DMainDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CCrossHoleConfig2DMainDlg::IDD, pParent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CCrossHoleConfig2DMainDlg::~CCrossHoleConfig2DMainDlg()
|
||||
{
|
||||
m_mapDatabaseABMNInfo.clear();
|
||||
}
|
||||
|
||||
void CCrossHoleConfig2DMainDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
DDX_Control(pDX, IDC_TAB_AR_CHANGE, m_tabChange);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CCrossHoleConfig2DMainDlg, CDialog)
|
||||
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB_AR_CHANGE, &CCrossHoleConfig2DMainDlg::OnTcnSelchangeTabArChange)
|
||||
ON_BN_CLICKED(ID_BTN_LOAD_GEOMETRY, &CCrossHoleConfig2DMainDlg::OnBnClickedBtnLoadGeometry)
|
||||
ON_BN_CLICKED(ID_BTN_CREATE, &CCrossHoleConfig2DMainDlg::OnBnClickedBtnCreate)
|
||||
ON_BN_CLICKED(ID_BTN_START_SIMULATION, &CCrossHoleConfig2DMainDlg::OnBnClickedBtnStartSimulation)
|
||||
ON_BN_CLICKED(ID_BTN_STOP_SIMULATION, &CCrossHoleConfig2DMainDlg::OnBnClickedBtnStopSimulation)
|
||||
ON_BN_CLICKED(ID_BTN_CLOSE, &CCrossHoleConfig2DMainDlg::OnBnClickedBtnClose)
|
||||
ON_MESSAGE(WM_MSG_UPDATE_CROSSHOLEMAINWND_BTN, &CCrossHoleConfig2DMainDlg::OnMsgCrossHoleMainWndBtn)
|
||||
ON_WM_DESTROY()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
CCrossHoleConfig2DMainDlg* CCrossHoleConfig2DMainDlg::GetInstance()
|
||||
{
|
||||
static CCrossHoleConfig2DMainDlg crossHoleConfig;
|
||||
return &crossHoleConfig;
|
||||
}
|
||||
// CCrossHoleConfig2DMainDlg 消息处理程序
|
||||
BOOL CCrossHoleConfig2DMainDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
{
|
||||
SetDlgItemText(ID_BTN_LOAD_GEOMETRY, _T("加载坐标"));
|
||||
SetDlgItemText(ID_BTN_CREATE, _T("创建"));
|
||||
SetDlgItemText(ID_BTN_START_SIMULATION, _T("开始模拟"));
|
||||
SetDlgItemText(ID_BTN_STOP_SIMULATION, _T("停止模拟"));
|
||||
SetDlgItemText(ID_BTN_CLOSE, _T("关闭"));
|
||||
m_tabChange.InsertItem(0, _T("电极坐标"));
|
||||
m_tabChange.InsertItem(1, _T("井下"));
|
||||
m_tabChange.InsertItem(2, _T("地面"));
|
||||
m_tabChange.InsertItem(3, _T("参数"));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_tabChange.InsertItem(0, _T("Geometry"));
|
||||
m_tabChange.InsertItem(1, _T("BoreHole"));
|
||||
m_tabChange.InsertItem(2, _T("Surface"));
|
||||
m_tabChange.InsertItem(3, _T("Setting"));
|
||||
}
|
||||
|
||||
m_tabChange.SetCurSel(1);
|
||||
// TODO: 在此添加额外的初始化
|
||||
CRect rcDrawCtr;
|
||||
GetDlgItem(IDC_STATIC_DRAWING_BOARD)->GetClientRect(&rcDrawCtr);
|
||||
//m_DrawingBoardDlg.Create(IDD_DIALOG_DRAWING_BOARD, this);
|
||||
CCrosshole2dDrawingBoardDlg::GetInstance()->Create(IDD_DIALOG_DRAWING_BOARD, GetDlgItem(IDC_STATIC_DRAWING_BOARD));
|
||||
CCrosshole2dDrawingBoardDlg::GetInstance()->MoveWindow(&rcDrawCtr);
|
||||
CCrosshole2dDrawingBoardDlg::GetInstance()->ShowWindow(SW_SHOW);
|
||||
|
||||
C2DSimulationDlg::GetInstance()->Create(IDD_DIALOG_SIMULATION_BOARD, GetDlgItem(IDC_STATIC_DRAWING_BOARD));
|
||||
C2DSimulationDlg::GetInstance()->MoveWindow(&rcDrawCtr);
|
||||
C2DSimulationDlg::GetInstance()->ShowWindow(SW_HIDE);
|
||||
//CCrosshole2dDrawingBoardDlg::GetInstance()->Create(IDD_DIALOG_DRAWING_BOARD, this);
|
||||
//CCrosshole2dDrawingBoardDlg::GetInstance()->MoveWindow(&rcDrawCtr);
|
||||
|
||||
CRect rect;
|
||||
m_tabChange.GetClientRect(&rect);
|
||||
rect.top = rect.top + 25;
|
||||
rect.left = rect.left + 2;
|
||||
rect.right = rect.right - 2;
|
||||
rect.bottom = rect.bottom - 2;
|
||||
COption2DGeometryDlg::GetInstance()->Create(IDD_DIALOG_OPTION_2D_GEOMETRY, &m_tabChange);
|
||||
COption2DGeometryDlg::GetInstance()->MoveWindow(&rect);
|
||||
|
||||
COption2DBoreholeDlg::GetInstance()->Create(IDD_DIALOG_OPTION_2D_BOREHOLE, &m_tabChange);
|
||||
COption2DBoreholeDlg::GetInstance()->MoveWindow(&rect);
|
||||
|
||||
COption2DSurfaceDlg::GetInstance()->Create(IDD_DIALOG_OPTION_2D_SURFACE, &m_tabChange);
|
||||
COption2DSurfaceDlg::GetInstance()->MoveWindow(&rect);
|
||||
|
||||
COption2DSettingDlg::GetInstance()->Create(IDD_DIALOG_OPTION_2D_SETTING, &m_tabChange);
|
||||
COption2DSettingDlg::GetInstance()->MoveWindow(&rect);
|
||||
|
||||
COption2DGeometryDlg::GetInstance()->ShowWindow(SW_HIDE);
|
||||
COption2DBoreholeDlg::GetInstance()->ShowWindow(SW_SHOW);
|
||||
COption2DSurfaceDlg::GetInstance()->ShowWindow(SW_HIDE);
|
||||
COption2DSettingDlg::GetInstance()->ShowWindow(SW_HIDE);
|
||||
|
||||
GetDlgItem(ID_BTN_START_SIMULATION)->EnableWindow(FALSE);
|
||||
GetDlgItem(ID_BTN_STOP_SIMULATION)->EnableWindow(FALSE);
|
||||
|
||||
m_pConnection = theApp.m_pConnection;
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// 异常: OCX 属性页应返回 FALSE
|
||||
}
|
||||
|
||||
void CCrossHoleConfig2DMainDlg::OnTcnSelchangeTabArChange(NMHDR *pNMHDR, LRESULT *pResult)
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
int iSel = m_tabChange.GetCurSel();
|
||||
switch (iSel)
|
||||
{
|
||||
case EN_OPTION_GEOMETRY:
|
||||
{
|
||||
COption2DGeometryDlg::GetInstance()->ShowWindow(SW_SHOW);
|
||||
COption2DBoreholeDlg::GetInstance()->ShowWindow(SW_HIDE);
|
||||
COption2DSurfaceDlg::GetInstance()->ShowWindow(SW_HIDE);
|
||||
COption2DSettingDlg::GetInstance()->ShowWindow(SW_HIDE);
|
||||
}
|
||||
break;
|
||||
case EN_OPTION_BOREHOLE:
|
||||
{
|
||||
COption2DGeometryDlg::GetInstance()->ShowWindow(SW_HIDE);
|
||||
COption2DBoreholeDlg::GetInstance()->ShowWindow(SW_SHOW);
|
||||
COption2DSurfaceDlg::GetInstance()->ShowWindow(SW_HIDE);
|
||||
COption2DSettingDlg::GetInstance()->ShowWindow(SW_HIDE);
|
||||
}
|
||||
break;
|
||||
case EN_OPTION_SURFACE:
|
||||
{
|
||||
COption2DGeometryDlg::GetInstance()->ShowWindow(SW_HIDE);
|
||||
COption2DBoreholeDlg::GetInstance()->ShowWindow(SW_HIDE);
|
||||
COption2DSurfaceDlg::GetInstance()->ShowWindow(SW_SHOW);
|
||||
COption2DSettingDlg::GetInstance()->ShowWindow(SW_HIDE);
|
||||
}
|
||||
break;
|
||||
case EN_OPTION_SETTING:
|
||||
{
|
||||
COption2DGeometryDlg::GetInstance()->ShowWindow(SW_HIDE);
|
||||
COption2DBoreholeDlg::GetInstance()->ShowWindow(SW_HIDE);
|
||||
COption2DSurfaceDlg::GetInstance()->ShowWindow(SW_HIDE);
|
||||
COption2DSettingDlg::GetInstance()->ShowWindow(SW_SHOW);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
*pResult = 0;
|
||||
}
|
||||
|
||||
void CCrossHoleConfig2DMainDlg::ChangeTabPage(EN_TAB_PAGE pageType, std::vector<STBoreHolePoints> vecPoints, STBoreHoleParam stBoreholeParam)
|
||||
{
|
||||
if (vecPoints.size() <= 0)
|
||||
{
|
||||
ASSERT(vecPoints.size() > 0);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (pageType)
|
||||
{
|
||||
case EN_OPTION_GEOMETRY:
|
||||
break;
|
||||
case EN_OPTION_BOREHOLE:
|
||||
{
|
||||
COption2DGeometryDlg::GetInstance()->AddCoordinatesPoints(EN_BOREHOLE_TYPE, vecPoints);
|
||||
m_tabChange.SetCurSel(0);
|
||||
COption2DGeometryDlg::GetInstance()->ShowWindow(SW_SHOW);
|
||||
COption2DBoreholeDlg::GetInstance()->ShowWindow(SW_HIDE);
|
||||
}
|
||||
break;
|
||||
case EN_OPTION_SURFACE:
|
||||
{
|
||||
COption2DGeometryDlg::GetInstance()->AddCoordinatesPoints(EN_SURFACE_TYPE, vecPoints);
|
||||
m_tabChange.SetCurSel(0);
|
||||
COption2DGeometryDlg::GetInstance()->ShowWindow(SW_SHOW);
|
||||
COption2DSurfaceDlg::GetInstance()->ShowWindow(SW_HIDE);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
COption2DGeometryDlg::GetInstance()->AddElecCoordinatesInfo(stBoreholeParam);
|
||||
|
||||
}
|
||||
|
||||
void CCrossHoleConfig2DMainDlg::OnBnClickedBtnLoadGeometry()
|
||||
{
|
||||
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: 在此添加控件通知处理程序代码
|
||||
CFileDialog cfd(TRUE, _T(".geomative"), _T("*.geomative"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("geomative Files(*.geomative)|*.txt||"), NULL);
|
||||
if (IDOK == cfd.DoModal())
|
||||
{
|
||||
CString strRawContent;
|
||||
BOOL bRes = FALSE;
|
||||
CStdioFile csf;
|
||||
int i = 0;
|
||||
UINT32 uiID = 1;//ID
|
||||
UINT iExists = 0;
|
||||
char* pCurContent = NULL;
|
||||
STBoreHolePoints stPoints;
|
||||
std::map<STWellPoints, std::vector<STBoreHolePoints>> mapBoreholePoints;//保存从Geomative文件读取到的borehole所有的点
|
||||
std::vector<STBoreHolePoints> vecBoreholePoints;
|
||||
std::vector<STBoreHolePoints> vecNoSortBoreholePoints;
|
||||
std::vector<STBoreHolePoints> vecSurfacePoints;//保存从Geomative文件读取到的surface所有的点
|
||||
bRes = csf.Open(cfd.GetPathName(), CStdioFile::modeReadWrite);
|
||||
if (bRes)
|
||||
{
|
||||
while (csf.ReadString(strRawContent))
|
||||
{
|
||||
OutputDebugString(strRawContent+_T("\n"));
|
||||
|
||||
pCurContent = _tcstok(strRawContent.GetBuffer(), _T(","));
|
||||
stPoints.uiID = uiID;
|
||||
stPoints.uiElecID = atoi(pCurContent);
|
||||
i = 0;
|
||||
while ((pCurContent = _tcstok(NULL, _T(","))))
|
||||
{
|
||||
//x
|
||||
if (i == 0)
|
||||
{
|
||||
stPoints.fX = atof(pCurContent);
|
||||
}
|
||||
//y
|
||||
else
|
||||
{
|
||||
stPoints.fZ = atof(pCurContent);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
//地表
|
||||
if (stPoints.fZ >= -0.000001 && stPoints.fZ < 0.000001)
|
||||
{
|
||||
vecSurfacePoints.push_back(stPoints);
|
||||
}
|
||||
else
|
||||
{
|
||||
STWellPoints stWellPoint;
|
||||
stWellPoint.fX = stPoints.fX;
|
||||
stWellPoint.fY = stPoints.fY;
|
||||
iExists = mapBoreholePoints.count(stWellPoint);
|
||||
if (0 == iExists)
|
||||
{
|
||||
vecBoreholePoints.push_back(stPoints);
|
||||
mapBoreholePoints[stWellPoint] = vecBoreholePoints;
|
||||
vecBoreholePoints.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
mapBoreholePoints[stWellPoint].push_back(stPoints);
|
||||
}
|
||||
}
|
||||
vecNoSortBoreholePoints.push_back(stPoints);
|
||||
uiID++;
|
||||
}
|
||||
csf.Close();
|
||||
}
|
||||
|
||||
COption2DGeometryDlg::GetInstance()->DeleteCoordinatesPoint();
|
||||
//添加List列表
|
||||
COption2DGeometryDlg::GetInstance()->AddNoSortCoordinatesFromFile(vecNoSortBoreholePoints);
|
||||
|
||||
//从Geomative文件加载的坐标传给画板和模拟窗口
|
||||
CCrosshole2dDrawingBoardDlg::GetInstance()->DeleteCoordinatesPoint();
|
||||
C2DSimulationDlg::GetInstance()->DeleteCoordinatesPoint();
|
||||
if (mapBoreholePoints.size() > 0)
|
||||
{
|
||||
CCrosshole2dDrawingBoardDlg::GetInstance()->AddBoreholePointToVector(mapBoreholePoints);
|
||||
C2DSimulationDlg::GetInstance()->AddBoreholePointToVector(mapBoreholePoints);
|
||||
}
|
||||
if (vecSurfacePoints.size() > 0)
|
||||
{
|
||||
CCrosshole2dDrawingBoardDlg::GetInstance()->AddSurfacePointsToVector(vecSurfacePoints);
|
||||
C2DSimulationDlg::GetInstance()->AddSurfacePointsToVector(vecSurfacePoints);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<int> CCrossHoleConfig2DMainDlg::CalcLValue(std::vector<STBoreHolePoints> vecPointBH1, std::vector<STBoreHolePoints> vecPointBH2)
|
||||
{
|
||||
std::vector<int> vecLValue;
|
||||
UINT uiBH1 = 0, uiBH2 = 0;
|
||||
uiBH1 = vecPointBH1.size();
|
||||
uiBH2 = vecPointBH2.size();
|
||||
if (0 == uiBH1 || 0 == uiBH2)
|
||||
return vecLValue;
|
||||
|
||||
int iMinN = min(uiBH1, uiBH2);
|
||||
//向正无穷取整
|
||||
int iMaxL = iMinN / 3;
|
||||
if (0 != iMinN % 3)
|
||||
{
|
||||
iMaxL++;
|
||||
}
|
||||
|
||||
//向正无穷取整
|
||||
int iMinL = iMinN / 10;
|
||||
if (0 != iMinN % 10)
|
||||
{
|
||||
iMinL++;
|
||||
}
|
||||
|
||||
//向正无穷取整
|
||||
int iDL = iMinN / 15;
|
||||
if (0 != iMinN % 15)
|
||||
{
|
||||
iDL++;
|
||||
}
|
||||
|
||||
//向负无穷取整
|
||||
int iN = (iMaxL - iMinL) / iDL;
|
||||
|
||||
int iL = 0;
|
||||
OutputDebugString(_T("zm:CCrossHoleConfig2DMainDlg::GenerateTestPoints 生成L的取值:"));
|
||||
for (int i = 0; i <= iN; i++)
|
||||
{
|
||||
iL = iMinL + i*iDL;
|
||||
vecLValue.push_back(iL);
|
||||
OutputDebugString("" + iL);
|
||||
}
|
||||
OutputDebugString("\n\n");
|
||||
return vecLValue;
|
||||
}
|
||||
struct Points
|
||||
{
|
||||
UINT32 A;
|
||||
UINT32 B;
|
||||
UINT32 M;
|
||||
UINT32 N;
|
||||
Points()
|
||||
{
|
||||
memset(this, 0, sizeof(Points));
|
||||
}
|
||||
};
|
||||
|
||||
float CCrossHoleConfig2DMainDlg::GetUniSptXPos(int iA, int iB, int iM, int iN)
|
||||
{
|
||||
//16-39的区间为1维脚本和3维脚本,不支持
|
||||
//在这里只支持2维脚本
|
||||
// if (m_iAR > 16 && m_iAR < 39) //2D脚本装置类型
|
||||
// {
|
||||
// AfxMessageBox(_T("Universal script only supprot 2D script."));
|
||||
// return -1;
|
||||
// }
|
||||
int iMin = 100000, iMax = 0, iTotalVal = 0;
|
||||
int iDataArr[4] = { iA, iB, iM, iN };
|
||||
int iNegativeCnt = 0;//非正整数的个数
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (iDataArr[i] > 0)
|
||||
{
|
||||
if (iDataArr[i] > iMax)
|
||||
{
|
||||
iMax = iDataArr[i];
|
||||
}
|
||||
if (iDataArr[i] < iMin)
|
||||
{
|
||||
iMin = iDataArr[i];
|
||||
}
|
||||
iTotalVal += iDataArr[i];
|
||||
}
|
||||
else
|
||||
iNegativeCnt++;
|
||||
}
|
||||
//如果全部是正整数(四级装置),则此时iTotalVal表示的是四个数的总和,那么需要剪掉最大的和最小的
|
||||
if (0 == iNegativeCnt)
|
||||
return (iTotalVal - iMin - iMax)*1.0 / 2;
|
||||
|
||||
//如果此时是三级装置,那么此时只需要减掉最小值即可
|
||||
if (1 == iNegativeCnt)
|
||||
return (iTotalVal - iMin)*1.0 / 2;
|
||||
|
||||
//如果是二级装置,则不需进行再处理
|
||||
if (2 == iNegativeCnt)
|
||||
return iTotalVal*1.0 / 2;
|
||||
|
||||
CString strErr;
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
{
|
||||
strErr.Format(_T("GetUniSptXPos错误,负值%d"), iNegativeCnt);
|
||||
AfxMessageBox(strErr);
|
||||
}
|
||||
else
|
||||
{
|
||||
strErr.Format(_T("GetUniSptXPos error,number of negative is %d"), iNegativeCnt);
|
||||
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void CCrossHoleConfig2DMainDlg::TwoBoreholeGenerateScript(std::vector<STBoreHolePoints> vecPointBH1, std::vector<STBoreHolePoints> vecPointBH2)
|
||||
{
|
||||
//两个孔,组合
|
||||
CString strLog;
|
||||
std::vector<int> vecLValue = CalcLValue(vecPointBH1, vecPointBH2);
|
||||
std::vector<int>::iterator iter = vecLValue.begin();
|
||||
std::vector<STBoreHolePoints>::iterator iterBH1 = vecPointBH1.begin();
|
||||
std::vector<STBoreHolePoints>::iterator iterBH2 = vecPointBH2.begin();
|
||||
int iBH1Size = vecPointBH1.size();
|
||||
int iBH2Size = vecPointBH2.size();
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
double dK = 0.0;
|
||||
float fAM = 0.0;
|
||||
float fAM2 = 0.0;
|
||||
float fBM = 0.0;
|
||||
float fBM2 = 0.0;
|
||||
float fAN = 0.0;
|
||||
float fAN2 = 0.0;
|
||||
float fBN = 0.0;
|
||||
float fBN2 = 0.0;
|
||||
STDatabaseABMNInfo stDatabaseABMNInfo;
|
||||
map<int, STDatabaseABMNInfo> mapM;
|
||||
map<int, map<int, STDatabaseABMNInfo>> mapB;
|
||||
map<int, map<int, map<int, STDatabaseABMNInfo>>>::iterator iterFindA;
|
||||
map<int, map<int, STDatabaseABMNInfo>>::iterator iterFindB;
|
||||
map<int, STDatabaseABMNInfo>::iterator iterFindM;
|
||||
//L取值
|
||||
for (; iter != vecLValue.end(); iter++)
|
||||
{
|
||||
//遍历第一个孔的电极
|
||||
for (i = 0; i < iBH1Size - *iter; i++)
|
||||
{
|
||||
//遍历第二个孔的电极
|
||||
for (j = 0; j < iBH2Size - *iter; j++)
|
||||
{
|
||||
/*if (EN_SURFACE_TYPE == iterBH1->eType)
|
||||
{
|
||||
//直线
|
||||
fAM = (iterBH1 + i + *iter)->fX-(iterBH1 + i)->fX;
|
||||
fAM2 = fAM;//待确认,地表2AM
|
||||
fBN = (iterBH2 + j)->fZ - (iterBH2 + j + *iter)->fZ;
|
||||
fBN2 = -(iterBH2 + j)->fZ - (iterBH2 + j + *iter)->fZ;
|
||||
|
||||
//三角形
|
||||
fBM = sqrt(pow((iterBH2 + j)->fZ, 2) + pow((iterBH1 + i + *iter)->fX - iterBH2->fX, 2));
|
||||
fBM2 = sqrt(pow(-(iterBH2 + j)->fZ, 2) + pow((iterBH1 + i + *iter)->fX - iterBH2->fX, 2));
|
||||
fAN = sqrt(pow((iterBH2 + j + *iter)->fZ, 2) + pow((iterBH1 + i)->fX - iterBH2->fX, 2));
|
||||
fAN2 = sqrt(pow(-(iterBH2 + j + *iter)->fZ, 2) + pow((iterBH1 + i)->fX - iterBH2->fX, 2));
|
||||
}
|
||||
else*/
|
||||
//生成脚本时,地表的坐标时添加在最后的,所以只有第二个孔为地表的情况
|
||||
if (EN_SURFACE_TYPE == iterBH2->eType)
|
||||
{
|
||||
//直线
|
||||
fAM = (iterBH1 + i)->fZ - (iterBH1 + i + *iter)->fZ;
|
||||
fAM2 = -(iterBH1 + i)->fZ - (iterBH1 + i + *iter)->fZ;
|
||||
fBN = (iterBH2 + j + *iter)->fX-(iterBH2 + j)->fX;
|
||||
fBN2 = fBN;//待确认,地表2AM
|
||||
|
||||
//三角形
|
||||
fBM = sqrt(pow(iterBH1->fX-(iterBH2+j)->fX, 2) + pow((iterBH1 + i + *iter)->fZ, 2));
|
||||
fBM2 = sqrt(pow(iterBH1->fX - (iterBH2 + j)->fX, 2) + pow(-(iterBH1 + i + *iter)->fZ, 2));
|
||||
fAN = sqrt(pow((iterBH1 + i)->fZ, 2) + pow((iterBH2 + j+*iter)->fX - iterBH1->fX, 2));
|
||||
fAN2 = sqrt(pow(-(iterBH1 + i)->fZ, 2) + pow((iterBH2 + j + *iter)->fX - iterBH1->fX, 2));
|
||||
}
|
||||
else
|
||||
{
|
||||
//直线
|
||||
fAM = (iterBH1 + i)->fZ - (iterBH1 + i + *iter)->fZ;
|
||||
fAM2 = -(iterBH1 + i)->fZ - (iterBH1 + i + *iter)->fZ;
|
||||
fBN = (iterBH2 + j)->fZ - (iterBH2 + j + *iter)->fZ;
|
||||
fBN2 = -(iterBH2 + j)->fZ - (iterBH2 + j + *iter)->fZ;
|
||||
|
||||
//三角形
|
||||
fBM = sqrt(pow((iterBH2 + j)->fZ - (iterBH1 + i + *iter)->fZ, 2) + pow(iterBH2->fX - iterBH1->fX, 2));
|
||||
fBM2 = sqrt(pow(-(iterBH2 + j)->fZ - (iterBH1 + i + *iter)->fZ, 2) + pow(iterBH2->fX - iterBH1->fX, 2));
|
||||
fAN = sqrt(pow((iterBH1 + i)->fZ - (iterBH2 + j + *iter)->fZ, 2) + pow(iterBH2->fX - iterBH1->fX, 2));
|
||||
fAN2 = sqrt(pow(-(iterBH1 + i)->fZ - (iterBH2 + j + *iter)->fZ, 2) + pow(iterBH2->fX - iterBH1->fX, 2));
|
||||
}
|
||||
|
||||
|
||||
dK = 4 * 3.1415926/(1/fAM+1/fAM2-1/fBM-1/fBM2-1/fAN-1/fAN2+1/fBN+1/fBN2);
|
||||
stDatabaseABMNInfo.uiAElecID = (iterBH1 + i)->uiElecID;
|
||||
stDatabaseABMNInfo.uiNElecID = (iterBH2 + j + *iter)->uiElecID;
|
||||
stDatabaseABMNInfo.uiMElecID = (iterBH1 + i + *iter)->uiElecID;
|
||||
stDatabaseABMNInfo.uiBElecID = (iterBH2 + j)->uiElecID;
|
||||
stDatabaseABMNInfo.iTrace = 1;//默认为1
|
||||
stDatabaseABMNInfo.fK = dK;
|
||||
stDatabaseABMNInfo.fSptXPos = GetUniSptXPos(stDatabaseABMNInfo.uiAElecID, stDatabaseABMNInfo.uiBElecID, stDatabaseABMNInfo.uiMElecID, stDatabaseABMNInfo.uiNElecID);
|
||||
|
||||
m_vecAllBoreholeABMNInfo.push_back(stDatabaseABMNInfo);
|
||||
|
||||
iterFindA = m_mapDatabaseABMNInfo.find(stDatabaseABMNInfo.uiAElecID);
|
||||
mapB.clear();
|
||||
mapM.clear();
|
||||
if (iterFindA != m_mapDatabaseABMNInfo.end())
|
||||
{
|
||||
iterFindB = iterFindA->second.find(stDatabaseABMNInfo.uiBElecID);
|
||||
if (iterFindB != iterFindA->second.end())
|
||||
{
|
||||
iterFindM = iterFindB->second.find(stDatabaseABMNInfo.uiMElecID);
|
||||
if (iterFindM != iterFindB->second.end())
|
||||
{
|
||||
AfxMessageBox(_T("生成测点AB相同,存在M值相同\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
iterFindB->second.insert(make_pair(stDatabaseABMNInfo.uiMElecID, stDatabaseABMNInfo));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mapM[stDatabaseABMNInfo.uiMElecID] = stDatabaseABMNInfo;
|
||||
iterFindA->second.insert(make_pair(stDatabaseABMNInfo.uiBElecID, mapM));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mapM[stDatabaseABMNInfo.uiMElecID] = stDatabaseABMNInfo;
|
||||
mapB[stDatabaseABMNInfo.uiBElecID] = mapM;
|
||||
m_mapDatabaseABMNInfo[stDatabaseABMNInfo.uiAElecID] = mapB;
|
||||
}
|
||||
m_uiTPamount++;
|
||||
strLog.Format(_T("m_uiTPamount=%d,L=%d,A=%d(z=%f),B=%d(z=%f),M=%d(z=%f),N=%d(z=%f),k=%lf\n"),\
|
||||
m_uiTPamount, *iter, (iterBH1 + i)->uiElecID, (iterBH1 + i)->fZ, (iterBH2 + j)->uiElecID, (iterBH2 + j)->fZ, (iterBH1 + i + *iter)->uiElecID, (iterBH1 + i + *iter)->fZ, (iterBH2 + j + *iter)->uiElecID, (iterBH2 + j + *iter)->fZ, dK);
|
||||
OutputDebugString(strLog);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//写入数据库
|
||||
BOOL CCrossHoleConfig2DMainDlg::SaveTestPointToDB()
|
||||
{
|
||||
m_pConnection = theApp.m_pConnection;
|
||||
m_pConnection->BeginTrans();
|
||||
//将AMNB信息吸入数据库---------------begin------------------
|
||||
_RecordsetPtr pRecSCID = NULL;
|
||||
_CommandPtr pCmdIns = NULL;
|
||||
pCmdIns.CreateInstance(_uuidof(Command));
|
||||
pCmdIns->ActiveConnection = m_pConnection;
|
||||
|
||||
CString strSql, strCN, strCurTime;
|
||||
CGUCodeCreator guCodeCreator;
|
||||
strCN = guCodeCreator.GenerateGUIDCode();
|
||||
|
||||
m_uiEamount = COption2DGeometryDlg::GetInstance()->GetAllCoordinatesPointsCount();
|
||||
|
||||
//检查脚本是否已存在
|
||||
pRecSCID.CreateInstance(_uuidof(Recordset));
|
||||
strSql.Format(_T("select * from scon where Sname = '%s' and Stype=1"), m_strScriptName);
|
||||
pRecSCID->Open(strSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
if ((long)VAL_ZERO != pRecSCID->GetRecordCount())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("脚本已经存在."));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Script has been alreay exists"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
pRecSCID->Close();
|
||||
m_pConnection->RollbackTrans();
|
||||
return FALSE;
|
||||
}
|
||||
pRecSCID->Close();
|
||||
|
||||
//Stype暂定二维
|
||||
float fPoleDistance = COption2DGeometryDlg::GetInstance()->GetElectrodeDistance();
|
||||
CString strPoleDistance;
|
||||
strPoleDistance.Format(_T("%.2f"), COption2DGeometryDlg::GetInstance()->GetElectrodeDistance());
|
||||
/*CString strPoleDistance,strTemp;
|
||||
strPoleDistance.Empty();
|
||||
std::vector<STBoreHoleParam> vecAllElecCoordinatesInfo = COption2DGeometryDlg::GetInstance()->GetAllElecCoordinatesInfo();
|
||||
for (std::vector<STBoreHoleParam>::iterator iter = vecAllElecCoordinatesInfo.begin(); iter != vecAllElecCoordinatesInfo.end(); iter++)
|
||||
{
|
||||
//x,y,z,电极间距
|
||||
strTemp.Empty();
|
||||
strTemp.Format(_T("%.2f,%.2f,%.2f,%.2f;"), iter->fX, iter->fY, iter->fZ,iter->fElecSpacing);
|
||||
strPoleDistance += strTemp;
|
||||
}*/
|
||||
SYSTEMTIME st;
|
||||
GetLocalTime(&st);
|
||||
strCurTime.Format(_T("%4d-%2d-%2d"), st.wYear, st.wMonth, st.wDay);
|
||||
strSql.Format(_T("insert into scon(CN,Sname,Stype,Eamount,CHamount,TPamount,definer,DEdate,SCdesc,Rect,RectLoc,PoleDistance,PoleStep) "
|
||||
"values('%s','%s',%d,%d,%d,%d,'%s',#%s#,'%s','%s', '%s', '%s', '%s')"),
|
||||
strCN,
|
||||
m_strScriptName,
|
||||
1,//暂时只考虑2D,以后再考虑如何计算
|
||||
m_uiEamount,
|
||||
1,//目前二维都是得到的1,暂填
|
||||
m_uiTPamount,
|
||||
m_strOperator,//定义人暂时为空,是否需要支持
|
||||
strCurTime,
|
||||
m_strNote,//脚本描述
|
||||
"",//pCreate3DSptDlg->GetRect(),
|
||||
"",//pCreate3DSptDlg->GetPoleStart(),
|
||||
strPoleDistance,//pCreate3DSptDlg->GetPoleDistance(),
|
||||
"");//pCreate3DSptDlg->GetPoleStep());
|
||||
pCmdIns->CommandText = strSql.AllocSysString();
|
||||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||||
|
||||
//取得scon表中ID最大的ITEM
|
||||
DWORD dwSConID = 0;
|
||||
DWORD dwCHID = 0;
|
||||
pRecSCID.CreateInstance(_uuidof(Recordset));
|
||||
pRecSCID->Open(_T("select max(ID) as ID from scon"), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
if ((long)VAL_ZERO != pRecSCID->GetRecordCount())//返回1
|
||||
{
|
||||
dwSConID = (DWORD)pRecSCID->GetCollect(_T("ID")).ulVal;
|
||||
}
|
||||
pRecSCID->Close();
|
||||
|
||||
strSql.Format(_T("insert into channel(SCID,CHnumber,AR) values(%u,%d,%d) "),
|
||||
dwSConID,
|
||||
1,//pChannel->m_iChNumber
|
||||
AR_CROSS_HOLE_GEOMATIVE);
|
||||
pCmdIns->CommandText = strSql.AllocSysString();
|
||||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||||
|
||||
strSql.Format(_T("select ID from channel where SCID = %d"), dwSConID);
|
||||
pRecSCID->Open(strSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
if ((long)VAL_ZERO != pRecSCID->GetRecordCount())
|
||||
{
|
||||
dwCHID = (DWORD)pRecSCID->GetCollect(_T("ID")).ulVal;
|
||||
}
|
||||
pRecSCID->Close();
|
||||
|
||||
//多通道装置,排序
|
||||
if (EN_MULTI_CHANNEL == theApp.m_ucIsMultiChannel)
|
||||
{
|
||||
map<int, map<int, map<int, STDatabaseABMNInfo>>>::iterator iterA = m_mapDatabaseABMNInfo.begin();
|
||||
map<int, map<int, STDatabaseABMNInfo>>::iterator iterB;
|
||||
map<int, STDatabaseABMNInfo>::iterator iterM;
|
||||
int iTSN = 0;
|
||||
for (; iterA != m_mapDatabaseABMNInfo.end(); iterA++)
|
||||
{
|
||||
for (iterB = iterA->second.begin(); iterB != iterA->second.end(); iterB++)
|
||||
{
|
||||
for (iterM = iterB->second.begin(); iterM != iterB->second.end(); iterM++)
|
||||
{
|
||||
strSql.Format(_T("insert into script2d(CHID,TSN,C1,C2,P1,P2,K,N,Layer,XPos) values(%u,%d,%d,%d,%d,%d,%f,%d,%d,%f) "),
|
||||
dwCHID,
|
||||
iTSN + 1,
|
||||
iterM->second.uiAElecID,
|
||||
iterM->second.uiBElecID,
|
||||
iterM->second.uiMElecID,
|
||||
iterM->second.uiNElecID,
|
||||
iterM->second.fK,
|
||||
iterM->second.iTrace,
|
||||
iterM->second.iTrace,
|
||||
iterM->second.fSptXPos);
|
||||
OutputDebugString(strSql + _T("\n"));
|
||||
pCmdIns->CommandText = strSql.AllocSysString();
|
||||
try
|
||||
{
|
||||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
//hHook = SetWindowsHookEx(WH_CBT, (HOOKPROC)CBTHookProc, AfxGetInstanceHandle(), NULL);
|
||||
AfxMessageBox((LPCTSTR)e.Description());
|
||||
}
|
||||
iTSN++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (0 == theApp.m_ucIsMultiChannel)//单通道,不需要排序
|
||||
{
|
||||
int iTestPointNum = m_vecAllBoreholeABMNInfo.size();
|
||||
for (int i = 0; i < iTestPointNum; i++)
|
||||
{
|
||||
strSql.Format(_T("insert into script2d(CHID,TSN,C1,C2,P1,P2,K,N,Layer,XPos) values(%u,%d,%d,%d,%d,%d,%f,%d,%d,%f) "),
|
||||
dwCHID,
|
||||
i + 1,
|
||||
m_vecAllBoreholeABMNInfo[i].uiAElecID,
|
||||
m_vecAllBoreholeABMNInfo[i].uiBElecID,
|
||||
m_vecAllBoreholeABMNInfo[i].uiMElecID,
|
||||
m_vecAllBoreholeABMNInfo[i].uiNElecID,
|
||||
m_vecAllBoreholeABMNInfo[i].fK,
|
||||
m_vecAllBoreholeABMNInfo[i].iTrace,
|
||||
m_vecAllBoreholeABMNInfo[i].iLayer,
|
||||
m_vecAllBoreholeABMNInfo[i].fSptXPos);
|
||||
OutputDebugString(strSql + _T("\n"));
|
||||
pCmdIns->CommandText = strSql.AllocSysString();
|
||||
try
|
||||
{
|
||||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
//hHook = SetWindowsHookEx(WH_CBT, (HOOKPROC)CBTHookProc, AfxGetInstanceHandle(), NULL);
|
||||
AfxMessageBox((LPCTSTR)e.Description());
|
||||
}
|
||||
}
|
||||
}
|
||||
//将AMNB信息吸入数据库---------------end------------------
|
||||
|
||||
//将脚本电极坐标信息写入数据库---------begin--------------
|
||||
std::vector<STBoreHolePoints> vecAllCoordinates = COption2DGeometryDlg::GetInstance()->GetAllCoordinatesPoints();
|
||||
std::vector<STBoreHolePoints>::iterator iter = vecAllCoordinates.begin();
|
||||
for (int i=1; iter != vecAllCoordinates.end(); iter++,i++)
|
||||
{
|
||||
strSql.Format(_T("insert into TCoordinatesInfo(SSN,ScriptCN,ElectrodeID,X,Y,Z) values(%d,'%s',%d,%f,%f,%f)"), i,strCN, iter->uiElecID, iter->fX, iter->fY, iter->fZ);
|
||||
pCmdIns->CommandText = strSql.AllocSysString();
|
||||
try
|
||||
{
|
||||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
AfxMessageBox((LPCTSTR)e.Description());
|
||||
}
|
||||
}
|
||||
//将脚本电极坐标信息写入数据库---------end--------------
|
||||
|
||||
m_pConnection->CommitTrans();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CCrossHoleConfig2DMainDlg::OnBnClickedBtnCreate()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
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);
|
||||
|
||||
m_vecAllBoreholeABMNInfo.clear();
|
||||
int iMediumType = COption2DSettingDlg::GetInstance()->GetMediumType();
|
||||
if (iMediumType < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_strScriptName = COption2DSettingDlg::GetInstance()->GetScriptName();
|
||||
if (m_strScriptName.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("脚本名称不能为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Script name cannot be empty"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
m_strTimeInterval = COption2DSettingDlg::GetInstance()->GetTimeInterval();
|
||||
if (m_strTimeInterval.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("时间间隔不能为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Time interval cannot be empty"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
m_strOperator = COption2DSettingDlg::GetInstance()->GetOperator();
|
||||
m_strNote = COption2DSettingDlg::GetInstance()->GetNote();
|
||||
|
||||
m_uiTPamount = 0;
|
||||
m_mapDatabaseABMNInfo.clear();
|
||||
//先只生产脚本测点,其他的情况后面再加
|
||||
//获取孔的数目
|
||||
std::map<STWellPoints, std::vector<STBoreHolePoints>> mapBoreholePoint = COption2DGeometryDlg::GetInstance()->GetBoreholeCoordinates();
|
||||
int iBHNum = mapBoreholePoint.size();
|
||||
//获取地表的坐标
|
||||
std::vector<STBoreHolePoints> vecSurface = COption2DGeometryDlg::GetInstance()->GetSurfaceCoordinates();
|
||||
STWellPoints stWellPoint,stWellPoint1;
|
||||
if (vecSurface.size() > 0)
|
||||
{
|
||||
if (0 == iMediumType)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("跨孔装置不需要地表"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Cross-hole devices do not require a surface"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
iBHNum++;
|
||||
stWellPoint.fY = 0;
|
||||
stWellPoint.fX = iBHNum;
|
||||
mapBoreholePoint[stWellPoint] = vecSurface;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (1 == iMediumType)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("井地井装置需要地表"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Well to well equipment requires surface"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
CString strLog;
|
||||
strLog.Format(_T("zm:当前井数目:%d\n"), iBHNum);
|
||||
OutputDebugString(strLog);
|
||||
if (iBHNum > 0)
|
||||
{
|
||||
if (iBHNum == 1)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("跨孔必须两孔或以上"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Span holes must be two or more"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_uiTPamount = 0;
|
||||
//井 + 井
|
||||
map<STWellPoints, vector<STBoreHolePoints>>::iterator iterWell = mapBoreholePoint.begin();
|
||||
map<STWellPoints, vector<STBoreHolePoints>>::iterator iterWellEx = mapBoreholePoint.begin();
|
||||
for (iterWell = mapBoreholePoint.begin(); iterWell != mapBoreholePoint.end(); iterWell++)
|
||||
{
|
||||
iterWellEx = iterWell;
|
||||
iterWellEx++;
|
||||
for (; iterWellEx != mapBoreholePoint.end(); iterWellEx++)
|
||||
{
|
||||
TwoBoreholeGenerateScript(iterWell->second, iterWellEx->second);
|
||||
}
|
||||
}
|
||||
|
||||
//写入数据库
|
||||
BOOL bRes = SaveTestPointToDB();
|
||||
if (bRes)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("创建成功"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Create success"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
//关闭当前窗口?更新到脚本列表
|
||||
|
||||
::SendMessage(AfxGetApp()->GetMainWnd()->m_hWnd, WM_REFRESH, (WPARAM)OP_SPT_SYN, (LPARAM)VAL_ZERO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GetDlgItem(ID_BTN_START_SIMULATION)->EnableWindow(TRUE);
|
||||
}
|
||||
|
||||
void CCrossHoleConfig2DMainDlg::OnBnClickedBtnStartSimulation()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
CCrosshole2dDrawingBoardDlg::GetInstance()->ShowWindow(FALSE);
|
||||
C2DSimulationDlg::GetInstance()->ShowWindow(SW_SHOW);
|
||||
|
||||
if (!m_strTimeInterval.IsEmpty())
|
||||
{
|
||||
m_strTimeInterval = COption2DSettingDlg::GetInstance()->GetTimeInterval();
|
||||
}
|
||||
C2DSimulationDlg::GetInstance()->SetTimeInterval(atoi(m_strTimeInterval));
|
||||
C2DSimulationDlg::GetInstance()->SetSingleChannelSimulationRunMethod(m_vecAllBoreholeABMNInfo);
|
||||
C2DSimulationDlg::GetInstance()->SetMultiChannelSimulationRunMethod(m_mapDatabaseABMNInfo);
|
||||
C2DSimulationDlg::GetInstance()->StartSimulation();
|
||||
GetDlgItem(ID_BTN_START_SIMULATION)->EnableWindow(FALSE);
|
||||
GetDlgItem(ID_BTN_STOP_SIMULATION)->EnableWindow(TRUE);
|
||||
GetDlgItem(ID_BTN_CLOSE)->EnableWindow(FALSE);
|
||||
}
|
||||
|
||||
|
||||
void CCrossHoleConfig2DMainDlg::OnBnClickedBtnStopSimulation()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
C2DSimulationDlg::GetInstance()->StopSimulation();
|
||||
GetDlgItem(ID_BTN_START_SIMULATION)->EnableWindow(TRUE);
|
||||
GetDlgItem(ID_BTN_STOP_SIMULATION)->EnableWindow(FALSE);
|
||||
GetDlgItem(ID_BTN_CLOSE)->EnableWindow(TRUE);
|
||||
}
|
||||
|
||||
|
||||
void CCrossHoleConfig2DMainDlg::OnBnClickedBtnClose()
|
||||
{
|
||||
CDialog::OnOK();
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
}
|
||||
|
||||
LRESULT CCrossHoleConfig2DMainDlg::OnMsgCrossHoleMainWndBtn(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
OnBnClickedBtnStopSimulation();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CCrossHoleConfig2DMainDlg::OnDestroy()
|
||||
{
|
||||
OnBnClickedBtnStopSimulation();
|
||||
|
||||
//清空窗口信息
|
||||
COption2DGeometryDlg::GetInstance()->DeleteCoordinatesPoint();
|
||||
CCrosshole2dDrawingBoardDlg::GetInstance()->DeleteCoordinatesPoint();
|
||||
|
||||
CDialog::OnDestroy();
|
||||
// TODO: 在此处添加消息处理程序代码
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,260 @@
|
||||
// CCrosshole2dDrawingBoardDlg.cpp : 实现文件
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GeoMative.h"
|
||||
#include "crossHole/CCrosshole2dDrawingBoardDlg.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
|
||||
// CCrosshole2dDrawingBoardDlg 对话框
|
||||
|
||||
IMPLEMENT_DYNAMIC(CCrosshole2dDrawingBoardDlg, CDialog)
|
||||
|
||||
CCrosshole2dDrawingBoardDlg::CCrosshole2dDrawingBoardDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CCrosshole2dDrawingBoardDlg::IDD, pParent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CCrosshole2dDrawingBoardDlg::~CCrosshole2dDrawingBoardDlg()
|
||||
{
|
||||
}
|
||||
|
||||
void CCrosshole2dDrawingBoardDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CCrosshole2dDrawingBoardDlg, CDialog)
|
||||
ON_WM_PAINT()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
CCrosshole2dDrawingBoardDlg* CCrosshole2dDrawingBoardDlg::GetInstance()
|
||||
{
|
||||
static CCrosshole2dDrawingBoardDlg drawingBoardDlg;
|
||||
return &drawingBoardDlg;
|
||||
}
|
||||
|
||||
BOOL CCrosshole2dDrawingBoardDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
// TODO: 在此添加额外的初始化
|
||||
GetParent()->GetClientRect(&m_rcWnd);
|
||||
m_rcBrush.left = m_rcWnd.left + 50;
|
||||
m_rcBrush.right = m_rcWnd.right - 50;
|
||||
m_rcBrush.top = m_rcWnd.top + 50;
|
||||
m_rcBrush.bottom = m_rcWnd.bottom - 50;
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// 异常: OCX 属性页应返回 FALSE
|
||||
}
|
||||
|
||||
void CCrosshole2dDrawingBoardDlg::OnPaint()
|
||||
{
|
||||
CPaintDC dc(this); // device context for painting
|
||||
dc.FillSolidRect(m_rcWnd, RGB(255, 255, 255));
|
||||
|
||||
CPen pen;
|
||||
pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
|
||||
dc.SelectObject(pen);
|
||||
|
||||
CString strlog;
|
||||
CBrush brush, *pBrush;
|
||||
brush.CreateSolidBrush(RGB(0, 0, 0));
|
||||
pBrush = dc.SelectObject(&brush);
|
||||
//水平布线,判断是否需要绘制
|
||||
int iSurfaceCount = m_vecSurfacePoints.size();
|
||||
int iBoreholeCount = m_mapBoreholePoints.size();
|
||||
float* pBoreholeXValue = NULL;
|
||||
float fDrawBoradMaxLength = 0; //整个画板最大长度
|
||||
if (iBoreholeCount > 0)
|
||||
{
|
||||
pBoreholeXValue = new float[iBoreholeCount];
|
||||
std::map<STWellPoints, std::vector<STBoreHolePoints>>::iterator iter = m_mapBoreholePoints.begin();
|
||||
for (int i = 0; i<iBoreholeCount,iter != m_mapBoreholePoints.end(); i++,iter++)
|
||||
{
|
||||
pBoreholeXValue[i] = iter->first.fX;//iter->first;
|
||||
if (iter->second.at(iter->second.size() - 1).fZ < fDrawBoradMaxLength)
|
||||
{
|
||||
fDrawBoradMaxLength = iter->second.at(iter->second.size() - 1).fZ;
|
||||
}
|
||||
if (abs(fDrawBoradMaxLength) < iter->first.fX)
|
||||
{
|
||||
fDrawBoradMaxLength = iter->first.fX;
|
||||
}
|
||||
}
|
||||
|
||||
if (pBoreholeXValue != NULL)
|
||||
{
|
||||
delete[] pBoreholeXValue;
|
||||
pBoreholeXValue = NULL;
|
||||
}
|
||||
}
|
||||
fDrawBoradMaxLength = abs(fDrawBoradMaxLength);
|
||||
if (iSurfaceCount > 0)
|
||||
{
|
||||
if (m_vecSurfacePoints[iSurfaceCount - 1].fX > fDrawBoradMaxLength)
|
||||
fDrawBoradMaxLength = m_vecSurfacePoints[iSurfaceCount - 1].fX;
|
||||
}
|
||||
|
||||
strlog.Format(_T("整个画板最大刻度fDrawBoradMaxLength=%f\n"), fDrawBoradMaxLength);
|
||||
OutputDebugString(strlog);
|
||||
|
||||
//如果要求X轴和Z轴的最小间距都是一样的,需要取实际长度中较小的一方来计算,防止绘制超过边界
|
||||
int iEachSmallSize = (m_rcBrush.right - m_rcBrush.left) / fDrawBoradMaxLength;
|
||||
if (m_rcBrush.bottom - m_rcBrush.top < m_rcBrush.right - m_rcBrush.left)
|
||||
{
|
||||
iEachSmallSize = (m_rcBrush.bottom - m_rcBrush.top) / fDrawBoradMaxLength;
|
||||
}
|
||||
|
||||
CClientDC fdc(this);
|
||||
RECT rcText;
|
||||
CFont font;
|
||||
if (iSurfaceCount > 0)
|
||||
{
|
||||
int iPointX = m_rcBrush.left;
|
||||
int iPointY = m_rcBrush.top;
|
||||
//如果没有孔,在中间绘制
|
||||
if (iBoreholeCount <= 0)
|
||||
{
|
||||
iPointY = m_rcBrush.top + (m_rcBrush.bottom - m_rcBrush.top) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
//确定起点X坐标
|
||||
iPointX = m_rcBrush.left + iEachSmallSize*m_vecSurfacePoints[0].fX;
|
||||
}
|
||||
|
||||
//绘制一条总线
|
||||
dc.MoveTo(iPointX, iPointY);
|
||||
dc.LineTo(iPointX + iEachSmallSize*(m_vecSurfacePoints[iSurfaceCount - 1].fX - m_vecSurfacePoints[0].fX), iPointY);
|
||||
strlog.Format(_T("地表 起点x=%d,y=%d,终点x=%d,y=%d\n"), iPointX, iPointY, iPointX + iEachSmallSize*m_vecSurfacePoints[iSurfaceCount - 1].fX, iPointY);
|
||||
OutputDebugString(strlog);
|
||||
|
||||
iPointX = m_rcBrush.left;
|
||||
|
||||
//遍历集合的每一个元素
|
||||
for (int i = 0; i < iSurfaceCount; i++)
|
||||
{
|
||||
strlog.Format(_T("X轴绘制点m_vecSurfacePoints[%d].fX值为%f,fEachSmallSize=%d,m_vecSurfacePoints[i].fX=%d x1=%d,y1=%d,x2=%d,y2=%d\n"), i, m_vecSurfacePoints[i].fX, iEachSmallSize, m_vecSurfacePoints[i].fX, iPointX + m_vecSurfacePoints[i].fX*iEachSmallSize - 2, iPointY - 2, iPointX + m_vecSurfacePoints[i].fX*iEachSmallSize + 2, iPointY + 2);
|
||||
OutputDebugString(strlog);
|
||||
dc.Ellipse(iPointX + m_vecSurfacePoints[i].fX*iEachSmallSize - 2, iPointY - 2, iPointX + m_vecSurfacePoints[i].fX*iEachSmallSize + 2, iPointY + 2);
|
||||
|
||||
//标识电极编号,电极位置重复,后面的覆盖前面的
|
||||
strlog.Format(_T("%d"), m_vecSurfacePoints[i].uiElecID);
|
||||
rcText.left = iPointX + m_vecSurfacePoints[i].fX*iEachSmallSize - 3;
|
||||
rcText.top = iPointY - 20;
|
||||
rcText.right = rcText.left + 20;
|
||||
rcText.bottom = iPointY - 1;
|
||||
font.CreatePointFont(70, _T(""), &fdc);
|
||||
fdc.SelectObject(&font);
|
||||
fdc.DrawText(strlog, &rcText, DT_WORDBREAK | DT_BOTTOM);
|
||||
//dc.TextOutA(iPointX + m_vecSurfacePoints[i].fX*iEachSmallSize - 4, iPointY - 20, strlog);
|
||||
}
|
||||
}
|
||||
|
||||
//有孔
|
||||
if (iBoreholeCount > 0)
|
||||
{
|
||||
int iPointY = m_rcBrush.top;
|
||||
int iPointX = m_rcBrush.left;
|
||||
int iDrawBoreholeWidth = 0;//实际绘制孔的宽度
|
||||
//没有地表线
|
||||
/*if (iSurfaceCount <= 0)
|
||||
{
|
||||
//只有一个孔,居中
|
||||
if (iBoreholeCount == 1)
|
||||
{
|
||||
iPointX = m_rcBrush.left + (m_rcBrush.right - m_rcBrush.left) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
//先计算所有孔绘制出来后需要的宽度,然后再从中心对称的方式求出X轴起点
|
||||
if (pBoreholeXValue != NULL)
|
||||
{
|
||||
iDrawBoreholeWidth = (pBoreholeXValue[iBoreholeCount - 1] - pBoreholeXValue[0])*iEachSmallSize;
|
||||
iPointX = m_rcBrush.left + (m_rcBrush.right - m_rcBrush.left) / 2 - iDrawBoreholeWidth / 2;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
int iCurOneBoreHoleCount = 0;
|
||||
int i = 0;
|
||||
//遍历每一孔
|
||||
std::map<STWellPoints, std::vector<STBoreHolePoints>>::iterator iter = m_mapBoreholePoints.begin();
|
||||
for (int iBoreholeIndex = 0; iBoreholeIndex < iBoreholeCount,iter != m_mapBoreholePoints.end(); iBoreholeIndex++,iter++)
|
||||
{
|
||||
iCurOneBoreHoleCount = iter->second.size();
|
||||
//绘制一个孔的主线
|
||||
/*if (iSurfaceCount <= 0)
|
||||
{
|
||||
if (iBoreholeIndex > 0)
|
||||
{
|
||||
iPointX = iPointX + (pBoreholeXValue[iBoreholeIndex] - pBoreholeXValue[iBoreholeIndex - 1])*iEachSmallSize;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//同一个孔的X值相等
|
||||
iPointX = m_rcBrush.left + iter->second.at(0).fX*iEachSmallSize;
|
||||
}*/
|
||||
iPointX = m_rcBrush.left + iter->second.at(0).fX*iEachSmallSize;
|
||||
|
||||
dc.MoveTo(iPointX, m_rcBrush.top);
|
||||
dc.LineTo(iPointX, m_rcBrush.top + iEachSmallSize*abs(iter->second.at(iCurOneBoreHoleCount - 1).fZ));
|
||||
strlog.Format(_T("第%d口井起点x=%d,y=%d,终点x=%d,y=%d\n"), iBoreholeIndex + 1, iPointX, m_rcBrush.top, iPointX, m_rcBrush.top + iEachSmallSize*abs(iter->second.at(iCurOneBoreHoleCount - 1).fZ));
|
||||
OutputDebugString(strlog);
|
||||
|
||||
//遍历集合的每一个元素
|
||||
for (i = 0; i < iCurOneBoreHoleCount; i++)
|
||||
{
|
||||
strlog.Format(_T("Z轴绘制点vecCurBoreHolePoint[%d].fZ值为%f,fEachSmallSize=%d,j=%d x1=%d,y1=%d,x2=%d,y2=%d\n"), i, iter->second[i].fZ, iEachSmallSize, abs(iter->second[i].fZ), iPointX - 2, iPointY + abs(iter->second[i].fZ)*iEachSmallSize - 2, iPointX + 2, iPointY + abs(iter->second[i].fZ)*iEachSmallSize + 2);
|
||||
OutputDebugString(strlog);
|
||||
dc.Ellipse(iPointX - 2, iPointY + abs(iter->second[i].fZ)*iEachSmallSize - 2, iPointX + 2, iPointY + abs(iter->second[i].fZ)*iEachSmallSize + 2);
|
||||
|
||||
//标识电极编号,电极位置重复,后面的覆盖前面的
|
||||
strlog.Format(_T("%d"), iter->second[i].uiElecID);
|
||||
rcText.left = iPointX + 4;
|
||||
rcText.right = rcText.left + 20;
|
||||
rcText.top = iPointY + abs(iter->second[i].fZ)*iEachSmallSize - 8;
|
||||
rcText.bottom = rcText.top + 15;
|
||||
//dc.TextOutA(iPointX + 4, iPointY + abs(iter->second[i].fZ)*iEachSmallSize - 8, strlog);
|
||||
//dc.DrawText(strlog, &rcText, DT_WORDBREAK | DT_LEFT);
|
||||
font.CreatePointFont(70, _T(""), &fdc);
|
||||
fdc.SelectObject(&font);
|
||||
fdc.DrawText(strlog, &rcText, DT_WORDBREAK | DT_LEFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
dc.SelectObject(pBrush);
|
||||
// TODO: 在此处添加消息处理程序代码
|
||||
// 不为绘图消息调用 CDialog::OnPaint()
|
||||
}
|
||||
|
||||
//将坐标点添加到井下集合
|
||||
void CCrosshole2dDrawingBoardDlg::AddBoreholePointToVector(std::map<STWellPoints, std::vector<STBoreHolePoints>> mapNewPoints)
|
||||
{
|
||||
m_mapBoreholePoints.clear();
|
||||
m_mapBoreholePoints = mapNewPoints;
|
||||
RedrawWindow();
|
||||
}
|
||||
|
||||
//将坐标点添加到地表集合
|
||||
void CCrosshole2dDrawingBoardDlg::AddSurfacePointsToVector(std::vector<STBoreHolePoints> vecNewPoints)
|
||||
{
|
||||
m_vecSurfacePoints.clear();
|
||||
|
||||
m_vecSurfacePoints = vecNewPoints;
|
||||
RedrawWindow();
|
||||
|
||||
}
|
||||
|
||||
//清空所有的线
|
||||
void CCrosshole2dDrawingBoardDlg::DeleteCoordinatesPoint()
|
||||
{
|
||||
m_mapBoreholePoints.clear();
|
||||
m_vecSurfacePoints.clear();
|
||||
RedrawWindow();
|
||||
}
|
||||
@@ -0,0 +1,357 @@
|
||||
// CCrosshole3dDrawingBoardDlg.cpp : 实现文件
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GeoMative.h"
|
||||
#include "crossHole/CCrosshole3dDrawingBoardDlg.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
#define DRAW_ARROW_LENGTH (5)
|
||||
#define DRAW_BOARD_TO_SIDE_DISTANCE (50)
|
||||
#define DRAW_X_Y_Z_EXTESION_LINES_LEN (20) //绘制延长线长度
|
||||
#define DRAW_FONT_SIZE (100) //字体大小
|
||||
|
||||
// CCrosshole3dDrawingBoardDlg 对话框
|
||||
|
||||
IMPLEMENT_DYNAMIC(CCrosshole3dDrawingBoardDlg, CDialog)
|
||||
|
||||
CCrosshole3dDrawingBoardDlg::CCrosshole3dDrawingBoardDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CCrosshole3dDrawingBoardDlg::IDD, pParent)
|
||||
{
|
||||
m_pFont = NULL;
|
||||
}
|
||||
|
||||
CCrosshole3dDrawingBoardDlg::~CCrosshole3dDrawingBoardDlg()
|
||||
{
|
||||
if (m_pFont != NULL)
|
||||
{
|
||||
delete m_pFont;
|
||||
m_pFont = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CCrosshole3dDrawingBoardDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CCrosshole3dDrawingBoardDlg, CDialog)
|
||||
ON_WM_PAINT()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
CCrosshole3dDrawingBoardDlg* CCrosshole3dDrawingBoardDlg::GetInstance()
|
||||
{
|
||||
static CCrosshole3dDrawingBoardDlg drawingBoardDlg;
|
||||
return &drawingBoardDlg;
|
||||
}
|
||||
|
||||
BOOL CCrosshole3dDrawingBoardDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
GetParent()->GetClientRect(&m_rcWnd);
|
||||
m_rcBrush.left = m_rcWnd.left + DRAW_BOARD_TO_SIDE_DISTANCE;
|
||||
m_rcBrush.right = m_rcWnd.right - DRAW_BOARD_TO_SIDE_DISTANCE;
|
||||
m_rcBrush.top = m_rcWnd.top + DRAW_BOARD_TO_SIDE_DISTANCE;
|
||||
m_rcBrush.bottom = m_rcWnd.bottom - DRAW_BOARD_TO_SIDE_DISTANCE;
|
||||
// TODO: 在此添加额外的初始化
|
||||
|
||||
m_pFont = new CFont();
|
||||
m_pFont->CreatePointFont(DRAW_FONT_SIZE, _T("楷体"));
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// 异常: OCX 属性页应返回 FALSE
|
||||
}
|
||||
|
||||
float CCrosshole3dDrawingBoardDlg::CalcMaxCableLength()
|
||||
{
|
||||
float fDrawBoradMaxLength = 0;
|
||||
STWellPoints* pstWellPoint = NULL;
|
||||
|
||||
int iSurfaceXCount = m_mapSurfaceXPoints.size();
|
||||
int iSurfaceYCount = m_mapSurfaceYPoints.size();
|
||||
int iBoreholeCount = m_mapBoreholePoints.size();
|
||||
map<int, std::vector<STBoreHolePoints>>::iterator iter;
|
||||
if (iBoreholeCount > 0)
|
||||
{
|
||||
float fTempDepth = 0.0;
|
||||
pstWellPoint = new STWellPoints[iBoreholeCount];
|
||||
map<STWellPoints, vector<STBoreHolePoints>>::iterator iter = m_mapBoreholePoints.begin();
|
||||
for (int i = 0; i < iBoreholeCount, iter != m_mapBoreholePoints.end(); i++, iter++)
|
||||
{
|
||||
pstWellPoint[i] = iter->first;
|
||||
//Z方向
|
||||
fTempDepth = abs(iter->second.at(iter->second.size() - 1).fZ) + sqrt(pow(iter->second.at(iter->second.size() - 1).fY, 2) / 2);
|
||||
if (fTempDepth > fDrawBoradMaxLength)
|
||||
{
|
||||
fDrawBoradMaxLength = fTempDepth;
|
||||
}
|
||||
|
||||
//X方向
|
||||
fTempDepth = iter->second.at(iter->second.size() - 1).fX + sqrt(pow(iter->second.at(iter->second.size() - 1).fY, 2) / 2);
|
||||
if (fTempDepth > fDrawBoradMaxLength)
|
||||
{
|
||||
fDrawBoradMaxLength = fTempDepth;
|
||||
}
|
||||
}
|
||||
|
||||
if (pstWellPoint != NULL)
|
||||
{
|
||||
delete[] pstWellPoint;
|
||||
pstWellPoint = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
fDrawBoradMaxLength = abs(fDrawBoradMaxLength);
|
||||
if (iSurfaceXCount > 0)
|
||||
{
|
||||
int iWellSize = 0;
|
||||
for (iter = m_mapSurfaceXPoints.begin(); iter != m_mapSurfaceXPoints.end(); iter++)
|
||||
{
|
||||
iWellSize = iter->second.size();
|
||||
if (iter->second[iWellSize - 1].fX > fDrawBoradMaxLength)
|
||||
fDrawBoradMaxLength = iter->second[iWellSize - 1].fX;
|
||||
}
|
||||
}
|
||||
|
||||
if (iSurfaceYCount > 0)
|
||||
{
|
||||
int iWellSize = 0;
|
||||
float fCurMaxXValue = 0.0;
|
||||
for (iter = m_mapSurfaceYPoints.begin(); iter != m_mapSurfaceYPoints.end(); iter++)
|
||||
{
|
||||
iWellSize = iter->second.size();
|
||||
fCurMaxXValue = iter->second[iWellSize - 1].fX + sqrt(pow(iter->second[iWellSize - 1].fY, 2) / 2);
|
||||
if (fCurMaxXValue > fDrawBoradMaxLength)
|
||||
fDrawBoradMaxLength = fCurMaxXValue;
|
||||
}
|
||||
}
|
||||
|
||||
return fDrawBoradMaxLength;
|
||||
}
|
||||
|
||||
void CCrosshole3dDrawingBoardDlg::OnPaint()
|
||||
{
|
||||
CPaintDC dc(this); // device context for painting
|
||||
dc.FillSolidRect(m_rcWnd, RGB(255, 255, 255));
|
||||
dc.SelectObject(m_pFont);
|
||||
CPen pen,penEx,penBlue;
|
||||
pen.CreatePen(PS_SOLID, 2, RGB(0, 0, 0));
|
||||
penEx.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
|
||||
penBlue.CreatePen(PS_SOLID, 2, RGB(81,81,255));
|
||||
dc.SelectObject(pen);
|
||||
|
||||
CString strlog;
|
||||
CBrush brush,blueBrush;
|
||||
brush.CreateSolidBrush(RGB(0, 0, 0));
|
||||
blueBrush.CreateSolidBrush(RGB(81, 81, 255));
|
||||
dc.SelectObject(&brush);
|
||||
//水平布线,判断是否需要绘制
|
||||
int iSurfaceXCount = m_mapSurfaceXPoints.size();
|
||||
int iSurfaceYCount = m_mapSurfaceYPoints.size();
|
||||
int iBoreholeCount = m_mapBoreholePoints.size();
|
||||
map<int, std::vector<STBoreHolePoints>>::iterator iter;
|
||||
|
||||
float fDrawBoradMaxLength = CalcMaxCableLength();
|
||||
|
||||
//如果要求X轴和Z轴的最小间距都是一样的,需要取实际长度中较小的一方来计算,防止绘制超过边界
|
||||
int iEachSmallSize = (m_rcBrush.right - m_rcBrush.left) / fDrawBoradMaxLength;
|
||||
if (m_rcBrush.bottom - m_rcBrush.top < m_rcBrush.right - m_rcBrush.left)
|
||||
{
|
||||
iEachSmallSize = (m_rcBrush.bottom - m_rcBrush.top) / fDrawBoradMaxLength-1;
|
||||
}
|
||||
|
||||
//绘制带箭头维度体系
|
||||
if (iBoreholeCount > 0 || iSurfaceXCount > 0 || iSurfaceYCount > 0)
|
||||
{
|
||||
dc.SelectObject(penEx);
|
||||
//X
|
||||
dc.MoveTo(m_rcBrush.left, m_rcBrush.top);
|
||||
dc.LineTo(m_rcBrush.left + iEachSmallSize*fDrawBoradMaxLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, m_rcBrush.top);
|
||||
//箭头
|
||||
dc.MoveTo(m_rcBrush.left + iEachSmallSize*fDrawBoradMaxLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, m_rcBrush.top);
|
||||
dc.LineTo(m_rcBrush.left + iEachSmallSize*fDrawBoradMaxLength + DRAW_X_Y_Z_EXTESION_LINES_LEN - DRAW_ARROW_LENGTH, m_rcBrush.top - DRAW_ARROW_LENGTH);
|
||||
dc.MoveTo(m_rcBrush.left + iEachSmallSize*fDrawBoradMaxLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, m_rcBrush.top);
|
||||
dc.LineTo(m_rcBrush.left + iEachSmallSize*fDrawBoradMaxLength + DRAW_X_Y_Z_EXTESION_LINES_LEN - DRAW_ARROW_LENGTH, m_rcBrush.top + DRAW_ARROW_LENGTH);
|
||||
dc.TextOutA(m_rcBrush.left + iEachSmallSize*fDrawBoradMaxLength + DRAW_X_Y_Z_EXTESION_LINES_LEN + 5, m_rcBrush.top - DRAW_ARROW_LENGTH / 2, _T("X"));
|
||||
//Y
|
||||
dc.MoveTo(m_rcBrush.left, m_rcBrush.top);
|
||||
dc.LineTo(m_rcBrush.left + sqrt(pow(iEachSmallSize*fDrawBoradMaxLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, 2) / 2), m_rcBrush.top + sqrt(pow(iEachSmallSize*fDrawBoradMaxLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, 2) / 2));
|
||||
dc.MoveTo(m_rcBrush.left + sqrt(pow(iEachSmallSize*fDrawBoradMaxLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, 2) / 2), m_rcBrush.top + sqrt(pow(iEachSmallSize*fDrawBoradMaxLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, 2) / 2));
|
||||
dc.LineTo(m_rcBrush.left + sqrt(pow(iEachSmallSize*fDrawBoradMaxLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, 2) / 2), m_rcBrush.top + sqrt(pow(iEachSmallSize*fDrawBoradMaxLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, 2) / 2) - DRAW_ARROW_LENGTH);
|
||||
dc.MoveTo(m_rcBrush.left + sqrt(pow(iEachSmallSize*fDrawBoradMaxLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, 2) / 2), m_rcBrush.top + sqrt(pow(iEachSmallSize*fDrawBoradMaxLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, 2) / 2));
|
||||
dc.LineTo(m_rcBrush.left + sqrt(pow(iEachSmallSize*fDrawBoradMaxLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, 2) / 2) - DRAW_ARROW_LENGTH, m_rcBrush.top + sqrt(pow(iEachSmallSize*fDrawBoradMaxLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, 2) / 2));
|
||||
dc.TextOutA(m_rcBrush.left + sqrt(pow(iEachSmallSize*fDrawBoradMaxLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, 2) / 2) + 5, m_rcBrush.top + sqrt(pow(iEachSmallSize*fDrawBoradMaxLength + DRAW_X_Y_Z_EXTESION_LINES_LEN, 2) / 2) + 5, _T("Y"));
|
||||
|
||||
//Z
|
||||
dc.MoveTo(m_rcBrush.left, m_rcBrush.top);
|
||||
dc.LineTo(m_rcBrush.left, m_rcBrush.top + iEachSmallSize*fDrawBoradMaxLength + DRAW_X_Y_Z_EXTESION_LINES_LEN);
|
||||
dc.MoveTo(m_rcBrush.left, m_rcBrush.top + iEachSmallSize*fDrawBoradMaxLength + DRAW_X_Y_Z_EXTESION_LINES_LEN);
|
||||
dc.LineTo(m_rcBrush.left - DRAW_ARROW_LENGTH, m_rcBrush.top + iEachSmallSize*fDrawBoradMaxLength + DRAW_X_Y_Z_EXTESION_LINES_LEN - DRAW_ARROW_LENGTH);
|
||||
dc.MoveTo(m_rcBrush.left, m_rcBrush.top + iEachSmallSize*fDrawBoradMaxLength + DRAW_X_Y_Z_EXTESION_LINES_LEN);
|
||||
dc.LineTo(m_rcBrush.left + DRAW_ARROW_LENGTH, m_rcBrush.top + iEachSmallSize*fDrawBoradMaxLength + DRAW_X_Y_Z_EXTESION_LINES_LEN - DRAW_ARROW_LENGTH);
|
||||
dc.TextOutA(m_rcBrush.left - DRAW_ARROW_LENGTH / 2, m_rcBrush.top + iEachSmallSize*fDrawBoradMaxLength + DRAW_X_Y_Z_EXTESION_LINES_LEN + 5, _T("Z"));
|
||||
dc.SelectObject(pen);
|
||||
}
|
||||
|
||||
//X方向电缆示意图
|
||||
if (iSurfaceXCount > 0)
|
||||
{
|
||||
int i = 0;
|
||||
int iPointX = m_rcBrush.left;
|
||||
int iPointY = m_rcBrush.top;
|
||||
for (iter = m_mapSurfaceXPoints.begin(); iter != m_mapSurfaceXPoints.end(); iter++)
|
||||
{
|
||||
iSurfaceXCount = iter->second.size();
|
||||
//如果没有孔,在中间绘制
|
||||
if (iBoreholeCount <= 0 && iSurfaceYCount <=0)
|
||||
{
|
||||
iPointY = m_rcBrush.top + (m_rcBrush.bottom - m_rcBrush.top) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
//确定起点X坐标
|
||||
iPointX = m_rcBrush.left + iEachSmallSize* iter->second[0].fX;
|
||||
}
|
||||
|
||||
//绘制一条总线
|
||||
dc.MoveTo(iPointX, iPointY);
|
||||
dc.LineTo(iPointX + iEachSmallSize*(iter->second[iSurfaceXCount - 1].fX - iter->second[0].fX), iPointY);
|
||||
//strlog.Format(_T("地表 起点x=%d,y=%d,终点x=%d,y=%d\n"), iPointX, iPointY, iPointX + iEachSmallSize*iter->second[iSurfaceXCount - 1].fX, iPointY);
|
||||
//OutputDebugString(strlog);
|
||||
|
||||
iPointX = m_rcBrush.left;
|
||||
|
||||
//遍历集合的每一个元素
|
||||
for (i = 0; i < iSurfaceXCount; i++)
|
||||
{
|
||||
//strlog.Format(_T("X轴绘制点iter->second[%d].fX值为%f,fEachSmallSize=%d,fEachSmallSize=%.2f,iter->second[i].fY=%.2f x1=%.2f,y1=%.2f,x2=%.2f,y2=%.2f\n\n"), i, iter->second[i].fX, iEachSmallSize, iter->second[i].fX, iPointX + iter->second[i].fX*iEachSmallSize - 2, iPointY - 2, iPointX + iter->second[i].fX*iEachSmallSize + 2, iPointY + 2);
|
||||
//OutputDebugString(strlog);
|
||||
dc.Ellipse(iPointX + iter->second[i].fX*iEachSmallSize - 2, iPointY - 2, iPointX + iter->second[i].fX*iEachSmallSize + 2, iPointY + 2);
|
||||
|
||||
//标识电极编号,电极位置重复,后面的覆盖前面的
|
||||
strlog.Format(_T("%d"), iter->second[i].uiElecID);
|
||||
dc.TextOutA(iPointX + iter->second[i].fX*iEachSmallSize - 3, iPointY - 20, strlog);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Y方向电缆示意图
|
||||
if (iSurfaceYCount > 0)
|
||||
{
|
||||
int i = 0;
|
||||
float fYCellSize;
|
||||
int iPointX = m_rcBrush.left;
|
||||
int iPointY = m_rcBrush.top;
|
||||
for (iter = m_mapSurfaceYPoints.begin(); iter != m_mapSurfaceYPoints.end(); iter++)
|
||||
{
|
||||
iSurfaceYCount = iter->second.size();
|
||||
//确定起点X坐标
|
||||
iPointX = m_rcBrush.left + iEachSmallSize* iter->second[0].fX;
|
||||
|
||||
//绘制一条总线
|
||||
dc.MoveTo(iPointX, iPointY);
|
||||
fYCellSize = iEachSmallSize*iter->second[iSurfaceYCount - 1].fY;
|
||||
dc.LineTo(iPointX + sqrt(pow(fYCellSize, 2) / 2), iPointY + sqrt(pow(fYCellSize, 2) / 2));
|
||||
//strlog.Format(_T("地表 起点x=%d,y=%d,终点x=%d,y=%d\n"), iPointX, iPointY, iPointX + fYCellSize, iPointY + fYCellSize);
|
||||
//OutputDebugString(strlog);
|
||||
|
||||
//iPointX = m_rcBrush.left;
|
||||
iPointY = m_rcBrush.top;
|
||||
|
||||
//遍历集合的每一个元素
|
||||
for (i = 0; i < iSurfaceYCount; i++)
|
||||
{
|
||||
fYCellSize = sqrt(pow(iter->second[i].fY*iEachSmallSize, 2) / 2);
|
||||
dc.Ellipse(iPointX + fYCellSize - 2, iPointY + fYCellSize - 2, iPointX + fYCellSize + 2, iPointY + fYCellSize + 2);
|
||||
|
||||
//标识电极编号,电极位置重复,后面的覆盖前面的
|
||||
strlog.Format(_T("%d"), iter->second[i].uiElecID);
|
||||
dc.TextOutA(iPointX + fYCellSize + 7, iPointY + fYCellSize - 7, strlog);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//井下电缆示意图
|
||||
dc.SelectObject(&blueBrush);
|
||||
dc.SelectObject(penBlue);
|
||||
if (iBoreholeCount > 0)
|
||||
{
|
||||
int iPointY = m_rcBrush.top;
|
||||
int iPointX = m_rcBrush.left;
|
||||
int iLastPointX = 0;
|
||||
int iDrawBoreholeWidth = 0;//实际绘制孔的宽度
|
||||
float fWellYPoint = 0.0;
|
||||
int iCurOneBoreHoleCount = 0;
|
||||
int i = 0;
|
||||
//遍历每一孔
|
||||
map<STWellPoints, vector<STBoreHolePoints>>::iterator iter = m_mapBoreholePoints.begin();
|
||||
for (int iBoreholeIndex = 0; iBoreholeIndex < iBoreholeCount, iter != m_mapBoreholePoints.end(); iBoreholeIndex++, iter++)
|
||||
{
|
||||
iCurOneBoreHoleCount = iter->second.size();
|
||||
//同一个孔的X值相等
|
||||
iLastPointX = iPointX = m_rcBrush.left + iter->second.at(0).fX*iEachSmallSize;
|
||||
fWellYPoint = iEachSmallSize*iter->second.at(0).fY;
|
||||
if (iter->second.at(0).fY > 0.000001)
|
||||
{
|
||||
iPointX += sqrt(pow(fWellYPoint, 2) / 2);
|
||||
}
|
||||
|
||||
//绘制井口坐标到X、Y的距离
|
||||
dc.MoveTo(iLastPointX, m_rcBrush.top);
|
||||
dc.LineTo(iPointX, m_rcBrush.top + sqrt(pow(fWellYPoint, 2) / 2));
|
||||
dc.MoveTo(m_rcBrush.left + sqrt(pow(fWellYPoint, 2) / 2), m_rcBrush.top + sqrt(pow(fWellYPoint, 2) / 2));
|
||||
dc.LineTo(iPointX, m_rcBrush.top + sqrt(pow(fWellYPoint, 2) / 2));
|
||||
|
||||
//绘制井主线
|
||||
dc.MoveTo(iPointX, m_rcBrush.top + sqrt(pow(fWellYPoint, 2) / 2));
|
||||
dc.LineTo(iPointX, m_rcBrush.top + iEachSmallSize*abs(iter->second.at(iCurOneBoreHoleCount - 1).fZ) + sqrt(pow(fWellYPoint, 2) / 2));
|
||||
|
||||
//遍历集合的每一个元素
|
||||
for (i = 0; i < iCurOneBoreHoleCount; i++)
|
||||
{
|
||||
dc.Ellipse(iPointX - 2, iPointY + abs(iter->second[i].fZ)*iEachSmallSize - 2 + sqrt(pow(fWellYPoint, 2) / 2), iPointX + 2, iPointY + abs(iter->second[i].fZ)*iEachSmallSize + 2 + sqrt(pow(fWellYPoint, 2) / 2));
|
||||
|
||||
//标识电极编号,电极位置重复,后面的覆盖前面的
|
||||
strlog.Format(_T("%d"), iter->second[i].uiElecID);
|
||||
dc.TextOutA(iPointX + 5, iPointY + abs(iter->second[i].fZ)*iEachSmallSize - 8 + sqrt(pow(fWellYPoint, 2) / 2), strlog);
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: 在此处添加消息处理程序代码
|
||||
// 不为绘图消息调用 CDialog::OnPaint()
|
||||
}
|
||||
|
||||
//将坐标点添加到井下集合
|
||||
void CCrosshole3dDrawingBoardDlg::AddBoreholePointToVector(map<STWellPoints, vector<STBoreHolePoints>> mapNewPoints)
|
||||
{
|
||||
m_mapBoreholePoints.clear();
|
||||
m_mapBoreholePoints = mapNewPoints;
|
||||
RedrawWindow();
|
||||
}
|
||||
|
||||
//将坐标点添加到地表集合
|
||||
void CCrosshole3dDrawingBoardDlg::AddSurfaceXPointsToVector(map<int, std::vector<STBoreHolePoints>> mapXNewPoints)
|
||||
{
|
||||
m_mapSurfaceXPoints.clear();
|
||||
m_mapSurfaceXPoints = mapXNewPoints;
|
||||
RedrawWindow();
|
||||
|
||||
}
|
||||
|
||||
//将坐标点添加到地表集合
|
||||
void CCrosshole3dDrawingBoardDlg::AddSurfaceYPointsToVector(map<int, std::vector<STBoreHolePoints>> mapYNewPoints)
|
||||
{
|
||||
m_mapSurfaceYPoints.clear();
|
||||
m_mapSurfaceYPoints = mapYNewPoints;
|
||||
RedrawWindow();
|
||||
}
|
||||
|
||||
//清空所有的线
|
||||
void CCrosshole3dDrawingBoardDlg::DeleteCoordinatesPoint()
|
||||
{
|
||||
m_mapBoreholePoints.clear();
|
||||
m_mapSurfaceXPoints.clear();
|
||||
m_mapSurfaceYPoints.clear();
|
||||
RedrawWindow();
|
||||
}
|
||||
@@ -0,0 +1,269 @@
|
||||
// COption2DBoreholeDlg.cpp : 实现文件
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GeoMative.h"
|
||||
#include "crossHole/COption2DBoreholeDlg.h"
|
||||
#include "crossHole/CCrossHoleConfig2DMainDlg.h"
|
||||
#include "crossHole/C2DSimulationDlg.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
extern int g_iUILanguage;
|
||||
// COption2DBoreholeDlg 对话框
|
||||
|
||||
IMPLEMENT_DYNAMIC(COption2DBoreholeDlg, CDialog)
|
||||
|
||||
COption2DBoreholeDlg::COption2DBoreholeDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(COption2DBoreholeDlg::IDD, pParent)
|
||||
{
|
||||
}
|
||||
|
||||
COption2DBoreholeDlg::~COption2DBoreholeDlg()
|
||||
{
|
||||
}
|
||||
|
||||
void COption2DBoreholeDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
}
|
||||
|
||||
COption2DBoreholeDlg* COption2DBoreholeDlg::GetInstance()
|
||||
{
|
||||
static COption2DBoreholeDlg optionBoreholeDlg;
|
||||
return &optionBoreholeDlg;
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(COption2DBoreholeDlg, CDialog)
|
||||
ON_BN_CLICKED(ID_BTN_ADD_ONE_HOREHOLE, &COption2DBoreholeDlg::OnBnClickedBtnAddOneBorehole)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
BOOL COption2DBoreholeDlg::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_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 COption2DBoreholeDlg::OnBnClickedBtnAddOneBorehole()
|
||||
{
|
||||
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, 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_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.fZ = atof(strZ);
|
||||
stBoreholeParam.iElecNum = atoi(strNumOfElec);
|
||||
stBoreholeParam.fElecSpacing = atof(strElecSpacing);
|
||||
strLog.Format(_T("Add one borehole Parameter:addr=%d,x=%.2f,z=%.2f,ElecNum=%d,ElecSpacing=%.2f"),
|
||||
stBoreholeParam.iElecID, stBoreholeParam.fX, stBoreholeParam.fZ, stBoreholeParam.iElecNum, stBoreholeParam.fElecSpacing);
|
||||
CFileOperTools::GetInstance()->WriteComLog(strLog);
|
||||
|
||||
generatedCoordinates(stBoreholeParam);
|
||||
}
|
||||
|
||||
void COption2DBoreholeDlg::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;
|
||||
float fOldElectrodeDistance = 0.0;
|
||||
//遍历是否存在电极编号冲突
|
||||
if (uPointsTotal > 0)
|
||||
{
|
||||
//判断当前电极间距跟之前添加的电极间距是否相等
|
||||
fOldElectrodeDistance = COption2DGeometryDlg::GetInstance()->GetElectrodeDistance();
|
||||
strLog.Format(_T("原电极间距fOldElectrodeDistance=%f,新电极间距stBoreholeParam.fElecSpacing=%f\n"), fOldElectrodeDistance, stBoreholeParam.fElecSpacing);
|
||||
CFileOperTools::GetInstance()->WriteComLog(strLog);
|
||||
if (abs(fOldElectrodeDistance - stBoreholeParam.fElecSpacing) >= 0.000001)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("电极间距与之前测线的间距不匹配"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Electrode spacing does not match the spacing of the previous survey line"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
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("COption2DBoreholeDlg::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++;
|
||||
}
|
||||
}
|
||||
|
||||
//保存电极间距
|
||||
COption2DGeometryDlg::GetInstance()->SetElectrodeDistance(stBoreholeParam.fElecSpacing);
|
||||
|
||||
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.fZ = stBoreholeParam.fZ - iCurElec*stBoreholeParam.fElecSpacing;
|
||||
|
||||
iter = vecAllPoints.begin();
|
||||
for (; iter != vecAllPoints.end(); iter++)
|
||||
{
|
||||
if ((iter->fX == stPoints.fX) && (iter->fZ == stPoints.fZ))
|
||||
{
|
||||
iConflictCount++;
|
||||
strLog.Format(_T("COption2DBoreholeDlg::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_BOREHOLE_TYPE;
|
||||
stPoints.uiID = i;
|
||||
stPoints.uiElecID = iElecID;
|
||||
stPoints.fX = stBoreholeParam.fX;
|
||||
stPoints.fZ = stBoreholeParam.fZ - iCurElec*stBoreholeParam.fElecSpacing;
|
||||
|
||||
strLog.Format(_T("COption2DBoreholeDlg::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_BOREHOLE, vecNewCoordinatesPoints, stBoreholeParam);
|
||||
}
|
||||
@@ -0,0 +1,309 @@
|
||||
// COption2DGeometryDlg.cpp : 实现文件
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GeoMative.h"
|
||||
#include "crossHole/COption2DGeometryDlg.h"
|
||||
#include "crossHole/COption2DBoreholeDlg.h"
|
||||
#include "crossHole/COption2DSurfaceDlg.h"
|
||||
#include "crossHole/CCrosshole2dDrawingBoardDlg.h"
|
||||
#include "crossHole/C2DSimulationDlg.h"
|
||||
#include "FileOperTools.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
|
||||
// COption2DGeometryDlg 对话框
|
||||
|
||||
IMPLEMENT_DYNAMIC(COption2DGeometryDlg, CDialog)
|
||||
|
||||
COption2DGeometryDlg::COption2DGeometryDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(COption2DGeometryDlg::IDD, pParent)
|
||||
{
|
||||
}
|
||||
|
||||
COption2DGeometryDlg::~COption2DGeometryDlg()
|
||||
{
|
||||
}
|
||||
|
||||
void COption2DGeometryDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
DDX_Control(pDX, IDC_LIST_GEOMETRY, m_geometryList);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(COption2DGeometryDlg, CDialog)
|
||||
ON_BN_CLICKED(ID_BTN_SORT, &COption2DGeometryDlg::OnBnClickedBtnSort)
|
||||
ON_BN_CLICKED(ID_BTN_SAVE_GEOMETRY, &COption2DGeometryDlg::OnBnClickedSaveGeometry)
|
||||
ON_BN_CLICKED(ID_BTN_CLEAR_ALL, &COption2DGeometryDlg::OnBnClickedBtnClearAll)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
COption2DGeometryDlg* COption2DGeometryDlg::GetInstance()
|
||||
{
|
||||
static COption2DGeometryDlg optionGeometryDlg;
|
||||
return &optionGeometryDlg;
|
||||
}
|
||||
|
||||
BOOL COption2DGeometryDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
int iColIndex = 0;
|
||||
m_geometryList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP
|
||||
| LVS_EX_ONECLICKACTIVATE | LVS_EX_GRIDLINES);
|
||||
|
||||
m_geometryList.InsertColumn(iColIndex++, _T("ID"), LVCFMT_LEFT, 60);
|
||||
m_geometryList.InsertColumn(iColIndex++, _T("Addr"), LVCFMT_CENTER, 60);
|
||||
m_geometryList.InsertColumn(iColIndex++, _T("X(m)"), LVCFMT_CENTER, 60);
|
||||
m_geometryList.InsertColumn(iColIndex++, _T("Z(m)"), LVCFMT_CENTER, 60);
|
||||
m_geometryList.InsertColumn(iColIndex++, _T("Y(m)"), LVCFMT_CENTER, 60);
|
||||
// TODO: 在此添加额外的初始化
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
{
|
||||
SetDlgItemTextA(ID_BTN_SORT,_T("排序"));
|
||||
SetDlgItemTextA(ID_BTN_SAVE_GEOMETRY, _T("保存坐标"));
|
||||
SetDlgItemTextA(ID_BTN_CLEAR_ALL, _T("清空"));
|
||||
}
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// 异常: OCX 属性页应返回 FALSE
|
||||
}
|
||||
|
||||
void COption2DGeometryDlg::OnBnClickedBtnSort()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
}
|
||||
|
||||
void COption2DGeometryDlg::OnBnClickedSaveGeometry()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
CFileDialog cfd(FALSE, _T(".geomative"), _T("*.geomative"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("geomative Files(*.geomative)|*.txt||"), NULL);
|
||||
if (IDOK == cfd.DoModal())
|
||||
{
|
||||
CString strFilePath;
|
||||
strFilePath.Format(_T("%s"), cfd.GetPathName());
|
||||
|
||||
CFile cf;
|
||||
BOOL bRes = false;
|
||||
CString strRawContent;
|
||||
bRes = cf.Open(strFilePath, CFile::modeCreate|CFile::modeReadWrite);
|
||||
if (bRes)
|
||||
{
|
||||
int iItemCount = m_geometryList.GetItemCount();
|
||||
for (int i = 0; i < iItemCount; i++)
|
||||
{
|
||||
//Addr,x,z
|
||||
strRawContent.Format(_T("%s,%s,%s\r\n"), m_geometryList.GetItemText(i, 1), m_geometryList.GetItemText(i, 2), m_geometryList.GetItemText(i, 3));
|
||||
cf.Write(strRawContent, strRawContent.GetLength());
|
||||
}
|
||||
cf.Close();
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("保存文件成功"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Save file successfully"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// COption2DGeometryDlg 消息处理程序
|
||||
void COption2DGeometryDlg::OnBnClickedBtnClearAll()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
DeleteCoordinatesPoint();
|
||||
C2DSimulationDlg::GetInstance()->DeleteCoordinatesPoint();
|
||||
C2DSimulationDlg::GetInstance()->ShowWindow(SW_HIDE);
|
||||
CCrosshole2dDrawingBoardDlg::GetInstance()->DeleteCoordinatesPoint();
|
||||
CCrosshole2dDrawingBoardDlg::GetInstance()->ShowWindow(SW_SHOW);
|
||||
}
|
||||
|
||||
void COption2DGeometryDlg::AddCoordinatesPoints(EN_COORDINATES_TYPE eType, std::vector<STBoreHolePoints> vecNewPoints)
|
||||
{
|
||||
std::vector<STBoreHolePoints>::iterator iter = vecNewPoints.begin();
|
||||
for (; iter != vecNewPoints.end(); iter++)
|
||||
{
|
||||
m_vecNoSortAllPoints.push_back(*iter);
|
||||
}
|
||||
ShowCoordinatesPoints();
|
||||
|
||||
//添加到集合
|
||||
switch (eType)
|
||||
{
|
||||
case EN_BOREHOLE_TYPE:
|
||||
AddBoreholePointToVector(vecNewPoints);
|
||||
break;
|
||||
case EN_SURFACE_TYPE:
|
||||
AddSurfacePointsToVector(vecNewPoints);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void COption2DGeometryDlg::AddNoSortCoordinatesFromFile(std::vector<STBoreHolePoints> vecNewPoints)
|
||||
{
|
||||
m_vecNoSortAllPoints.clear();
|
||||
m_vecNoSortAllPoints = vecNewPoints;
|
||||
ShowCoordinatesPoints();
|
||||
}
|
||||
|
||||
void COption2DGeometryDlg::DeleteCoordinatesPoint()
|
||||
{
|
||||
m_geometryList.DeleteAllItems();
|
||||
m_vecNoSortAllPoints.clear();
|
||||
|
||||
//删除集合
|
||||
DeletePointsToVector();
|
||||
}
|
||||
|
||||
void COption2DGeometryDlg::ShowCoordinatesPoints()
|
||||
{
|
||||
m_geometryList.DeleteAllItems();
|
||||
|
||||
CString strText;
|
||||
int iColIndex = 0;
|
||||
vector<STBoreHolePoints>::iterator iter = m_vecNoSortAllPoints.begin();
|
||||
for (; iter != m_vecNoSortAllPoints.end(); iter++)
|
||||
{
|
||||
m_geometryList.InsertItem(iColIndex, _T(""));
|
||||
strText.Format(_T("%d"), iter->uiID);
|
||||
m_geometryList.SetItemText(iColIndex, 0, strText);
|
||||
|
||||
strText.Format(_T("%d"), iter->uiElecID);
|
||||
m_geometryList.SetItemText(iColIndex, 1, strText);
|
||||
|
||||
strText.Format(_T("%.2f"), iter->fX);//孔,X坐标固定
|
||||
m_geometryList.SetItemText(iColIndex, 2, strText);
|
||||
|
||||
strText.Format(_T("%.2f"), iter->fZ);
|
||||
m_geometryList.SetItemText(iColIndex, 3, strText);
|
||||
|
||||
strText.Format(_T("%.2f"), iter->fY);
|
||||
m_geometryList.SetItemText(iColIndex, 4, strText);
|
||||
iColIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
//地表
|
||||
void COption2DGeometryDlg::AddSurfacePointsToVector(std::vector<STBoreHolePoints> vecNewPoints)
|
||||
{
|
||||
std::vector<STBoreHolePoints>::iterator iter = vecNewPoints.begin();
|
||||
for (; iter != vecNewPoints.end(); iter++)
|
||||
{
|
||||
m_vecSurfaceCoordinates.push_back(*iter);
|
||||
}
|
||||
|
||||
//打印当前X轴坐标
|
||||
/*CString strLog;
|
||||
iter = m_vecSurfaceCoordinates.begin();
|
||||
OutputDebugString(_T("打印当前X轴坐标\n"));
|
||||
for (; iter != m_vecSurfaceCoordinates.end(); iter++)
|
||||
{
|
||||
strLog.Format(_T("x=%f\n"),iter->fX);
|
||||
OutputDebugString(strLog);
|
||||
}*/
|
||||
|
||||
|
||||
/*if (m_vecSurfaceCoordinates.size() <= 0)
|
||||
{
|
||||
m_vecSurfaceCoordinates = vecNewPoints;
|
||||
}
|
||||
else
|
||||
{
|
||||
//新加入的逐个比较
|
||||
int i = 0;
|
||||
BOOL bAppend = TRUE;
|
||||
std::vector<STBoreHolePoints>::iterator newIter = vecNewPoints.begin();
|
||||
for (; newIter != vecNewPoints.end(); newIter++)
|
||||
{
|
||||
bAppend = TRUE;
|
||||
for (i = 0; i < m_vecSurfaceCoordinates.size(); i++)
|
||||
{
|
||||
if (newIter->fX < m_vecSurfaceCoordinates[i].fX)
|
||||
{
|
||||
bAppend = FALSE;
|
||||
m_vecSurfaceCoordinates.insert(m_vecSurfaceCoordinates.begin() + i, *newIter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//集合中没有小于它的值
|
||||
if (bAppend)
|
||||
{
|
||||
m_vecSurfaceCoordinates.push_back(*newIter);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
//将数据传递给画板井下
|
||||
CCrosshole2dDrawingBoardDlg::GetInstance()->AddSurfacePointsToVector(m_vecSurfaceCoordinates);
|
||||
//将数据传给模拟井下
|
||||
C2DSimulationDlg::GetInstance()->AddSurfacePointsToVector(m_vecSurfaceCoordinates);
|
||||
}
|
||||
|
||||
//井下
|
||||
void COption2DGeometryDlg::AddBoreholePointToVector(std::vector<STBoreHolePoints> vecNewPoints) //将坐标点添加到集合
|
||||
{
|
||||
/*CString strLog;
|
||||
int iExists = 0;
|
||||
float fCurX = vecNewPoints.at(0).fX;
|
||||
iExists = m_mapBoreholeCoordinates.count(fCurX);
|
||||
if (0 == iExists)
|
||||
{
|
||||
m_mapBoreholeCoordinates[fCurX] = vecNewPoints;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<STBoreHolePoints> vecOldPoint;
|
||||
vecOldPoint = m_mapBoreholeCoordinates[fCurX];
|
||||
m_mapBoreholeCoordinates.erase(fCurX);
|
||||
std::vector<STBoreHolePoints>::iterator iter = vecNewPoints.begin();
|
||||
for (; iter != vecNewPoints.end(); iter++)
|
||||
{
|
||||
vecOldPoint.push_back(*iter);
|
||||
}
|
||||
m_mapBoreholeCoordinates[fCurX] = vecOldPoint;
|
||||
}
|
||||
|
||||
//将数据传递给画板井下
|
||||
CCrosshole2dDrawingBoardDlg::GetInstance()->AddBoreholePointToVector(m_mapBoreholeCoordinates);
|
||||
//将数据传给模拟窗口井下
|
||||
C2DSimulationDlg::GetInstance()->AddBoreholePointToVector(m_mapBoreholeCoordinates);*/
|
||||
|
||||
BOOL bExist = FALSE;
|
||||
STWellPoints stWellPoint;
|
||||
stWellPoint.fX = vecNewPoints.at(0).fX;
|
||||
stWellPoint.fY = vecNewPoints.at(0).fY;
|
||||
|
||||
map<STWellPoints, vector<STBoreHolePoints>>::iterator iter = m_mapBoreholeCoordinates.begin();
|
||||
for (; iter != m_mapBoreholeCoordinates.end(); iter++)
|
||||
{
|
||||
if (iter->first.fX == stWellPoint.fX && iter->first.fY == stWellPoint.fY)
|
||||
{
|
||||
bExist = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bExist)
|
||||
{
|
||||
std::vector<STBoreHolePoints>::iterator iterNew = vecNewPoints.begin();
|
||||
for (; iterNew != vecNewPoints.end(); iterNew++)
|
||||
{
|
||||
iter->second.push_back(*iterNew);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_mapBoreholeCoordinates[stWellPoint] = vecNewPoints;
|
||||
}
|
||||
|
||||
//CCrosshole2dDrawingBoardDlg::GetInstance()->AddBoreholePointToVector(m_mapBoreholeCoordinates);
|
||||
//将数据传递给画板井下
|
||||
CCrosshole2dDrawingBoardDlg::GetInstance()->AddBoreholePointToVector(m_mapBoreholeCoordinates);
|
||||
//将数据传给模拟窗口井下
|
||||
C2DSimulationDlg::GetInstance()->AddBoreholePointToVector(m_mapBoreholeCoordinates);
|
||||
}
|
||||
|
||||
void COption2DGeometryDlg::DeletePointsToVector() //删除集合的数据
|
||||
{
|
||||
m_mapBoreholeCoordinates.clear();
|
||||
m_vecSurfaceCoordinates.clear();
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
// COption2DSettingDlg.cpp : 实现文件
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GeoMative.h"
|
||||
#include "crossHole/COption2DSettingDlg.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
|
||||
// COption2DSettingDlg 对话框
|
||||
|
||||
IMPLEMENT_DYNAMIC(COption2DSettingDlg, CDialog)
|
||||
|
||||
COption2DSettingDlg::COption2DSettingDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(COption2DSettingDlg::IDD, pParent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
COption2DSettingDlg::~COption2DSettingDlg()
|
||||
{
|
||||
}
|
||||
|
||||
void COption2DSettingDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
DDX_Control(pDX, IDC_COMBO_MEDIUM_TYPE, m_comMediumType);
|
||||
DDX_Control(pDX, IDC_EDIT_SCRIPT_NAME, m_editScriptName);
|
||||
DDX_Control(pDX, IDC_EDIT_TIME_INTERVAL, m_editTimeInterval);
|
||||
DDX_Control(pDX, IDC_EDIT_OPERATOR, m_editOperator);
|
||||
DDX_Control(pDX, IDC_EDIT_NOTE, m_editNote);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(COption2DSettingDlg, CDialog)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
COption2DSettingDlg* COption2DSettingDlg::GetInstance()
|
||||
{
|
||||
static COption2DSettingDlg optionSettingDlg;
|
||||
return &optionSettingDlg;
|
||||
}
|
||||
|
||||
// COption2DSettingDlg 消息处理程序
|
||||
BOOL COption2DSettingDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
{
|
||||
m_comMediumType.AddString(_T("跨孔"));
|
||||
m_comMediumType.AddString(_T("井地井"));
|
||||
//m_comMediumType.AddString(_T("自定义"));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDlgItemText(IDC_STATIC_SCRIPT_NAME, _T("*Script Name"));
|
||||
SetDlgItemText(IDC_STATIC_MEDIUM_TYPE, _T("*Medium Type"));
|
||||
SetDlgItemText(IDC_STATIC_TIME_INTERVAL, _T("Time Interval"));
|
||||
SetDlgItemText(IDC_STATIC_OPERATOR, _T("Operator"));
|
||||
SetDlgItemText(IDC_STATIC_NOTE, _T("Note:"));
|
||||
|
||||
m_comMediumType.AddString(_T("Cross Hole"));
|
||||
m_comMediumType.AddString(_T("Bipole Hole"));
|
||||
//m_comMediumType.AddString(_T("Custom"));
|
||||
}
|
||||
m_comMediumType.SetItemData(0, AR_CROSS_HOLE_GEOMATIVE);
|
||||
m_comMediumType.SetItemData(1, AR_CROSS_HOLE_GEOMATIVE);
|
||||
//m_comMediumType.SetItemData(2, AR_CUSTOM_2D_TYPE);
|
||||
m_comMediumType.SetCurSel(-1);
|
||||
m_editTimeInterval.SetWindowTextA(_T("1000"));
|
||||
// TODO: 在此添加额外的初始化
|
||||
((CEdit*)GetDlgItem(IDC_EDIT_SCRIPT_NAME))->SetLimitText(20);
|
||||
((CEdit*)GetDlgItem(IDC_EDIT_OPERATOR))->SetLimitText(20);
|
||||
((CEdit*)GetDlgItem(IDC_EDIT_NOTE))->SetLimitText(50);
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// 异常: OCX 属性页应返回 FALSE
|
||||
}
|
||||
|
||||
int COption2DSettingDlg::GetMediumType() //获取选中的装置类型
|
||||
{
|
||||
int iCurSel = m_comMediumType.GetCurSel();
|
||||
if (-1 == iCurSel)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("请选择装置类型"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Please select medium type"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return 0;
|
||||
}
|
||||
return iCurSel;//m_comMediumType.GetItemData(iCurSel);
|
||||
}
|
||||
|
||||
CString COption2DSettingDlg::GetScriptName()
|
||||
{
|
||||
CString strScriptName;
|
||||
m_editScriptName.GetWindowTextA(strScriptName);
|
||||
return strScriptName;
|
||||
}
|
||||
|
||||
|
||||
CString COption2DSettingDlg::GetTimeInterval()
|
||||
{
|
||||
CString strTimeInterval;
|
||||
m_editTimeInterval.GetWindowTextA(strTimeInterval);
|
||||
return strTimeInterval;
|
||||
}
|
||||
|
||||
//获取操作员
|
||||
CString COption2DSettingDlg::GetOperator()
|
||||
{
|
||||
CString strOperator;
|
||||
m_editOperator.GetWindowTextA(strOperator);
|
||||
return strOperator;
|
||||
}
|
||||
|
||||
//获取备注
|
||||
CString COption2DSettingDlg::GetNote()
|
||||
{
|
||||
CString strNote;
|
||||
m_editNote.GetWindowTextA(strNote);
|
||||
return strNote;
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
// 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);
|
||||
}
|
||||
@@ -0,0 +1,273 @@
|
||||
// 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);
|
||||
}
|
||||
@@ -0,0 +1,396 @@
|
||||
// COption3DGeometryDlg.cpp : 实现文件
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GeoMative.h"
|
||||
#include "crossHole/COption3DGeometryDlg.h"
|
||||
#include "crossHole/COption3DBoreholeDlg.h"
|
||||
#include "crossHole/COption3DSurfaceDlg.h"
|
||||
#include "crossHole/CCrosshole3dDrawingBoardDlg.h"
|
||||
#include "crossHole/C3DSimulationDlg.h"
|
||||
#include "FileOperTools.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
|
||||
// COption3DGeometryDlg 对话框
|
||||
|
||||
IMPLEMENT_DYNAMIC(COption3DGeometryDlg, CDialog)
|
||||
|
||||
COption3DGeometryDlg::COption3DGeometryDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(COption3DGeometryDlg::IDD, pParent)
|
||||
{
|
||||
}
|
||||
|
||||
COption3DGeometryDlg::~COption3DGeometryDlg()
|
||||
{
|
||||
}
|
||||
|
||||
void COption3DGeometryDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
DDX_Control(pDX, IDC_LIST_GEOMETRY, m_geometryList);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(COption3DGeometryDlg, CDialog)
|
||||
ON_BN_CLICKED(ID_BTN_SORT, &COption3DGeometryDlg::OnBnClickedBtnSort)
|
||||
ON_BN_CLICKED(ID_BTN_SAVE_GEOMETRY, &COption3DGeometryDlg::OnBnClickedSaveGeometry)
|
||||
ON_BN_CLICKED(ID_BTN_CLEAR_ALL, &COption3DGeometryDlg::OnBnClickedBtnClearAll)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
COption3DGeometryDlg* COption3DGeometryDlg::GetInstance()
|
||||
{
|
||||
static COption3DGeometryDlg optionGeometryDlg;
|
||||
return &optionGeometryDlg;
|
||||
}
|
||||
|
||||
BOOL COption3DGeometryDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
int iColIndex = 0;
|
||||
m_geometryList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP
|
||||
| LVS_EX_ONECLICKACTIVATE | LVS_EX_GRIDLINES);
|
||||
|
||||
m_geometryList.InsertColumn(iColIndex++, _T("ID"), LVCFMT_LEFT, 60);
|
||||
m_geometryList.InsertColumn(iColIndex++, _T("Addr"), LVCFMT_CENTER, 60);
|
||||
m_geometryList.InsertColumn(iColIndex++, _T("X(m)"), LVCFMT_CENTER, 60);
|
||||
m_geometryList.InsertColumn(iColIndex++, _T("Y(m)"), LVCFMT_CENTER, 60);
|
||||
m_geometryList.InsertColumn(iColIndex++, _T("Z(m)"), LVCFMT_CENTER, 60);
|
||||
// TODO: 在此添加额外的初始化
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
{
|
||||
SetDlgItemTextA(ID_BTN_SORT,_T("排序"));
|
||||
SetDlgItemTextA(ID_BTN_SAVE_GEOMETRY, _T("保存坐标"));
|
||||
SetDlgItemTextA(ID_BTN_CLEAR_ALL, _T("清空"));
|
||||
}
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// 异常: OCX 属性页应返回 FALSE
|
||||
}
|
||||
|
||||
void COption3DGeometryDlg::OnBnClickedBtnSort()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
}
|
||||
|
||||
void COption3DGeometryDlg::OnBnClickedSaveGeometry()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
CFileDialog cfd(FALSE, _T(".geomative"), _T("*.geomative"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("geomative Files(*.geomative)|*.txt||"), NULL);
|
||||
if (IDOK == cfd.DoModal())
|
||||
{
|
||||
CString strFilePath;
|
||||
strFilePath.Format(_T("%s"), cfd.GetPathName());
|
||||
|
||||
CFile cf;
|
||||
BOOL bRes = false;
|
||||
CString strRawContent;
|
||||
bRes = cf.Open(strFilePath, CFile::modeCreate|CFile::modeReadWrite);
|
||||
if (bRes)
|
||||
{
|
||||
int iItemCount = m_geometryList.GetItemCount();
|
||||
for (int i = 0; i < iItemCount; i++)
|
||||
{
|
||||
//Addr,x,y,z
|
||||
strRawContent.Format(_T("%s,%s,%s,%s\r\n"), \
|
||||
m_geometryList.GetItemText(i, 1), \
|
||||
m_geometryList.GetItemText(i, 2), \
|
||||
m_geometryList.GetItemText(i, 3), \
|
||||
m_geometryList.GetItemText(i, 4));
|
||||
cf.Write(strRawContent, strRawContent.GetLength());
|
||||
}
|
||||
cf.Close();
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("保存文件成功"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Save file successfully"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// COption3DGeometryDlg 消息处理程序
|
||||
void COption3DGeometryDlg::OnBnClickedBtnClearAll()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
DeleteCoordinatesPoint();
|
||||
C3DSimulationDlg::GetInstance()->DeleteCoordinatesPoint();
|
||||
C3DSimulationDlg::GetInstance()->ShowWindow(SW_HIDE);
|
||||
CCrosshole3dDrawingBoardDlg::GetInstance()->DeleteCoordinatesPoint();
|
||||
CCrosshole3dDrawingBoardDlg::GetInstance()->ShowWindow(SW_SHOW);
|
||||
}
|
||||
|
||||
void COption3DGeometryDlg::AddCoordinatesPoints(EN_COORDINATES_TYPE eType, std::vector<STBoreHolePoints> vecNewPoints)
|
||||
{
|
||||
std::vector<STBoreHolePoints>::iterator iter = vecNewPoints.begin();
|
||||
for (; iter != vecNewPoints.end(); iter++)
|
||||
{
|
||||
m_vecNoSortAllPoints.push_back(*iter);
|
||||
}
|
||||
ShowCoordinatesPoints();
|
||||
|
||||
//添加到集合
|
||||
switch (eType)
|
||||
{
|
||||
case EN_BOREHOLE_TYPE:
|
||||
AddBoreholePointToVector(vecNewPoints);
|
||||
break;
|
||||
case EN_SURFACE_TYPE:
|
||||
AddSurfacePointsToVector(vecNewPoints);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void COption3DGeometryDlg::AddNoSortCoordinatesFromFile(std::vector<STBoreHolePoints> vecNewPoints)
|
||||
{
|
||||
m_vecNoSortAllPoints.clear();
|
||||
m_vecNoSortAllPoints = vecNewPoints;
|
||||
ShowCoordinatesPoints();
|
||||
}
|
||||
|
||||
void COption3DGeometryDlg::DeleteCoordinatesPoint()
|
||||
{
|
||||
m_geometryList.DeleteAllItems();
|
||||
m_vecNoSortAllPoints.clear();
|
||||
|
||||
//删除集合
|
||||
DeletePointsToVector();
|
||||
}
|
||||
|
||||
void COption3DGeometryDlg::ShowCoordinatesPoints()
|
||||
{
|
||||
m_geometryList.DeleteAllItems();
|
||||
|
||||
CString strText;
|
||||
int iColIndex = 0;
|
||||
vector<STBoreHolePoints>::iterator iter = m_vecNoSortAllPoints.begin();
|
||||
for (; iter != m_vecNoSortAllPoints.end(); iter++)
|
||||
{
|
||||
m_geometryList.InsertItem(iColIndex, _T(""));
|
||||
strText.Format(_T("%d"), iter->uiID);
|
||||
m_geometryList.SetItemText(iColIndex, 0, strText);
|
||||
|
||||
strText.Format(_T("%d"), iter->uiElecID);
|
||||
m_geometryList.SetItemText(iColIndex, 1, strText);
|
||||
|
||||
strText.Format(_T("%.2f"), iter->fX);//孔,X坐标固定
|
||||
m_geometryList.SetItemText(iColIndex, 2, strText);
|
||||
|
||||
strText.Format(_T("%.2f"), iter->fY);//孔,Y坐标
|
||||
m_geometryList.SetItemText(iColIndex, 3, strText);
|
||||
|
||||
strText.Format(_T("%.2f"), iter->fZ);//孔,Z坐标
|
||||
m_geometryList.SetItemText(iColIndex, 4, strText);
|
||||
|
||||
|
||||
iColIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
//地表
|
||||
void COption3DGeometryDlg::AddSurfacePointsToVector(std::vector<STBoreHolePoints> vecNewPoints)
|
||||
{
|
||||
/*std::vector<STBoreHolePoints>::iterator iter = vecNewPoints.begin();
|
||||
for (; iter != vecNewPoints.end(); iter++)
|
||||
{
|
||||
m_vecSurfaceCoordinates.push_back(*iter);
|
||||
}*/
|
||||
|
||||
EN_CABLE_DIRECTION_TYPE eCableDirection = COption3DSurfaceDlg::GetInstance()->GetCableDirectionType();
|
||||
switch (eCableDirection)
|
||||
{
|
||||
case EN_CABLE_DIRECTION_X:
|
||||
{
|
||||
CString strLog;
|
||||
int iExists = 0;
|
||||
//X方向的电缆,Y有几个值就有几条线
|
||||
float fCurY = vecNewPoints.at(0).fY;
|
||||
iExists = m_mapSurfaceXCoordinates.count(fCurY);
|
||||
if (0 == iExists)
|
||||
{
|
||||
m_mapSurfaceXCoordinates[fCurY] = vecNewPoints;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//打印日志
|
||||
/*strLog.Format(_T("之前不存在孔\n"));
|
||||
OutputDebugString(strLog);
|
||||
std::vector<STBoreHolePoints>::iterator iter = vecNewPoints.begin();
|
||||
for (; iter != vecNewPoints.end(); iter++)
|
||||
{
|
||||
strLog.Format(_T("x=%f,z=%f\n"), iter->fX,iter->fZ);
|
||||
OutputDebugString(strLog);
|
||||
}*/
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<STBoreHolePoints> vecOldPoint;
|
||||
vecOldPoint = m_mapSurfaceXCoordinates[fCurY];
|
||||
m_mapSurfaceXCoordinates.erase(fCurY);
|
||||
std::vector<STBoreHolePoints>::iterator iter = vecNewPoints.begin();
|
||||
for (; iter != vecNewPoints.end(); iter++)
|
||||
{
|
||||
vecOldPoint.push_back(*iter);
|
||||
}
|
||||
m_mapSurfaceXCoordinates[fCurY] = vecOldPoint;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//打印日志
|
||||
strLog.Format(_T("***************************X的测线\n"));
|
||||
OutputDebugString(strLog);
|
||||
iter = vecOldPoint.begin();
|
||||
for (; iter != vecOldPoint.end(); iter++)
|
||||
{
|
||||
strLog.Format(_T("x=%.2f,y=%.2f,z=%.2f\n"), iter->fX, iter->fY, iter->fZ);
|
||||
OutputDebugString(strLog);
|
||||
}
|
||||
}
|
||||
CCrosshole3dDrawingBoardDlg::GetInstance()->AddSurfaceXPointsToVector(m_mapSurfaceXCoordinates);
|
||||
C3DSimulationDlg::GetInstance()->AddSurfaceXPointsToVector(m_mapSurfaceXCoordinates);
|
||||
}
|
||||
break;
|
||||
case EN_CABLE_DIRECTION_Y:
|
||||
{
|
||||
CString strLog;
|
||||
int iExists = 0;
|
||||
//Y方向的电缆,X有几个值就有几条线
|
||||
float fCurX = vecNewPoints.at(0).fX;
|
||||
iExists = m_mapSurfaceYCoordinates.count(fCurX);
|
||||
if (0 == iExists)
|
||||
{
|
||||
m_mapSurfaceYCoordinates[fCurX] = vecNewPoints;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//打印日志
|
||||
/*strLog.Format(_T("之前不存在孔\n"));
|
||||
OutputDebugString(strLog);
|
||||
std::vector<STBoreHolePoints>::iterator iter = vecNewPoints.begin();
|
||||
for (; iter != vecNewPoints.end(); iter++)
|
||||
{
|
||||
strLog.Format(_T("x=%f,z=%f\n"), iter->fX,iter->fZ);
|
||||
OutputDebugString(strLog);
|
||||
}*/
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<STBoreHolePoints> vecOldPoint;
|
||||
vecOldPoint = m_mapSurfaceYCoordinates[fCurX];
|
||||
m_mapSurfaceYCoordinates.erase(fCurX);
|
||||
std::vector<STBoreHolePoints>::iterator iter = vecNewPoints.begin();
|
||||
for (; iter != vecNewPoints.end(); iter++)
|
||||
{
|
||||
vecOldPoint.push_back(*iter);
|
||||
}
|
||||
m_mapSurfaceYCoordinates[fCurX] = vecOldPoint;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//打印日志
|
||||
strLog.Format(_T("---------------------Y的测线\n"));
|
||||
OutputDebugString(strLog);
|
||||
iter = vecOldPoint.begin();
|
||||
for (; iter != vecOldPoint.end(); iter++)
|
||||
{
|
||||
strLog.Format(_T("x=%.2f,y=%.2f,z=%.2f\n"), iter->fX, iter->fY, iter->fZ);
|
||||
OutputDebugString(strLog);
|
||||
}
|
||||
}
|
||||
CCrosshole3dDrawingBoardDlg::GetInstance()->AddSurfaceYPointsToVector(m_mapSurfaceYCoordinates);
|
||||
C3DSimulationDlg::GetInstance()->AddSurfaceYPointsToVector(m_mapSurfaceYCoordinates);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//打印当前X轴坐标
|
||||
/*CString strLog;
|
||||
iter = m_vecSurfaceCoordinates.begin();
|
||||
OutputDebugString(_T("打印当前X轴坐标\n"));
|
||||
for (; iter != m_vecSurfaceCoordinates.end(); iter++)
|
||||
{
|
||||
strLog.Format(_T("x=%f\n"),iter->fX);
|
||||
OutputDebugString(strLog);
|
||||
}*/
|
||||
|
||||
|
||||
/*if (m_vecSurfaceCoordinates.size() <= 0)
|
||||
{
|
||||
m_vecSurfaceCoordinates = vecNewPoints;
|
||||
}
|
||||
else
|
||||
{
|
||||
//新加入的逐个比较
|
||||
int i = 0;
|
||||
BOOL bAppend = TRUE;
|
||||
std::vector<STBoreHolePoints>::iterator newIter = vecNewPoints.begin();
|
||||
for (; newIter != vecNewPoints.end(); newIter++)
|
||||
{
|
||||
bAppend = TRUE;
|
||||
for (i = 0; i < m_vecSurfaceCoordinates.size(); i++)
|
||||
{
|
||||
if (newIter->fX < m_vecSurfaceCoordinates[i].fX)
|
||||
{
|
||||
bAppend = FALSE;
|
||||
m_vecSurfaceCoordinates.insert(m_vecSurfaceCoordinates.begin() + i, *newIter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//集合中没有小于它的值
|
||||
if (bAppend)
|
||||
{
|
||||
m_vecSurfaceCoordinates.push_back(*newIter);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
//将数据传递给画板井下,暂时这么传递
|
||||
//CDrawingBoardDlg::GetInstance()->AddSurfacePointsToVector(m_mapSurfaceXCoordinates);
|
||||
//CDrawingBoardDlg::GetInstance()->AddSurfacePointsToVector(m_mapSurfaceYCoordinates);
|
||||
|
||||
//将数据传给模拟井下
|
||||
//C3DSimulationDlg::GetInstance()->AddSurfacePointsToVector(m_vecSurfaceCoordinates);
|
||||
}
|
||||
|
||||
//井下
|
||||
void COption3DGeometryDlg::AddBoreholePointToVector(std::vector<STBoreHolePoints> vecNewPoints) //将坐标点添加到集合
|
||||
{
|
||||
BOOL bExist = FALSE;
|
||||
STWellPoints stWellPoint;
|
||||
stWellPoint.fX = vecNewPoints.at(0).fX;
|
||||
stWellPoint.fY = vecNewPoints.at(0).fY;
|
||||
|
||||
map<STWellPoints, vector<STBoreHolePoints>>::iterator iter = m_mapBoreholeCoordinates.begin();
|
||||
for (; iter != m_mapBoreholeCoordinates.end(); iter++)
|
||||
{
|
||||
if (iter->first.fX == stWellPoint.fX && iter->first.fY == stWellPoint.fY)
|
||||
{
|
||||
bExist = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bExist)
|
||||
{
|
||||
std::vector<STBoreHolePoints>::iterator iterNew = vecNewPoints.begin();
|
||||
for (; iterNew != vecNewPoints.end(); iterNew++)
|
||||
{
|
||||
iter->second.push_back(*iterNew);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_mapBoreholeCoordinates[stWellPoint] = vecNewPoints;
|
||||
}
|
||||
|
||||
CCrosshole3dDrawingBoardDlg::GetInstance()->AddBoreholePointToVector(m_mapBoreholeCoordinates);
|
||||
C3DSimulationDlg::GetInstance()->AddBoreholePointToVector(m_mapBoreholeCoordinates);
|
||||
}
|
||||
|
||||
void COption3DGeometryDlg::DeletePointsToVector() //删除集合的数据
|
||||
{
|
||||
m_mapBoreholeCoordinates.clear();
|
||||
m_mapSurfaceXCoordinates.clear();
|
||||
m_mapSurfaceYCoordinates.clear();
|
||||
|
||||
m_vecAllElecCoordinatesInfo.clear();
|
||||
//m_vecSurfaceCoordinates.clear();
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
// COption3DSettingDlg.cpp : 实现文件
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GeoMative.h"
|
||||
#include "crossHole/COption3DSettingDlg.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
|
||||
// COption3DSettingDlg 对话框
|
||||
|
||||
IMPLEMENT_DYNAMIC(COption3DSettingDlg, CDialog)
|
||||
|
||||
COption3DSettingDlg::COption3DSettingDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(COption3DSettingDlg::IDD, pParent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
COption3DSettingDlg::~COption3DSettingDlg()
|
||||
{
|
||||
}
|
||||
|
||||
void COption3DSettingDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
DDX_Control(pDX, IDC_COMBO_MEDIUM_TYPE, m_comMediumType);
|
||||
DDX_Control(pDX, IDC_EDIT_SCRIPT_NAME, m_editScriptName);
|
||||
DDX_Control(pDX, IDC_EDIT_TIME_INTERVAL, m_editTimeInterval);
|
||||
DDX_Control(pDX, IDC_EDIT_OPERATOR, m_editOperator);
|
||||
DDX_Control(pDX, IDC_EDIT_NOTE, m_editNote);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(COption3DSettingDlg, CDialog)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
COption3DSettingDlg* COption3DSettingDlg::GetInstance()
|
||||
{
|
||||
static COption3DSettingDlg optionSettingDlg;
|
||||
return &optionSettingDlg;
|
||||
}
|
||||
|
||||
// COption3DSettingDlg 消息处理程序
|
||||
BOOL COption3DSettingDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
{
|
||||
m_comMediumType.AddString(_T("跨孔"));
|
||||
m_comMediumType.AddString(_T("井地井"));
|
||||
//m_comMediumType.AddString(_T("自定义"));
|
||||
m_comMediumType.AddString(_T("AM排列"));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDlgItemText(IDC_STATIC_SCRIPT_NAME, _T("*Script Name"));
|
||||
SetDlgItemText(IDC_STATIC_MEDIUM_TYPE, _T("*Medium Type"));
|
||||
SetDlgItemText(IDC_STATIC_TIME_INTERVAL, _T("Time Interval"));
|
||||
SetDlgItemText(IDC_STATIC_OPERATOR, _T("Operator"));
|
||||
SetDlgItemText(IDC_STATIC_NOTE, _T("Note:"));
|
||||
|
||||
m_comMediumType.AddString(_T("Cross Hole"));
|
||||
m_comMediumType.AddString(_T("Bipole Hole"));
|
||||
//m_comMediumType.AddString(_T("Custom"));
|
||||
m_comMediumType.AddString(_T("Pole-Pole AM"));
|
||||
}
|
||||
m_comMediumType.SetItemData(0, AR_CROSS_HOLE_GEOMATIVE);
|
||||
m_comMediumType.SetItemData(1, AR_CROSS_HOLE_GEOMATIVE);
|
||||
//m_comMediumType.SetItemData(2, AR_CUSTOM_2D_TYPE);
|
||||
m_comMediumType.SetItemData(2, AR_CROSS_HOLE_GEOMATIVE_AM);
|
||||
m_comMediumType.SetCurSel(-1);
|
||||
m_editTimeInterval.SetWindowTextA(_T("1000"));
|
||||
// TODO: 在此添加额外的初始化
|
||||
|
||||
((CEdit*)GetDlgItem(IDC_EDIT_SCRIPT_NAME))->SetLimitText(20);
|
||||
((CEdit*)GetDlgItem(IDC_EDIT_OPERATOR))->SetLimitText(20);
|
||||
((CEdit*)GetDlgItem(IDC_EDIT_NOTE))->SetLimitText(50);
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// 异常: OCX 属性页应返回 FALSE
|
||||
}
|
||||
|
||||
int COption3DSettingDlg::GetMediumType() //获取选中的装置类型
|
||||
{
|
||||
UpdateData(TRUE);
|
||||
int iCurSel = m_comMediumType.GetCurSel();
|
||||
if (-1 == iCurSel)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("请选择装置类型"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Please select medium type"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return 0;
|
||||
}
|
||||
return iCurSel;//m_comMediumType.GetItemData(iCurSel);
|
||||
}
|
||||
|
||||
CString COption3DSettingDlg::GetScriptName()
|
||||
{
|
||||
CString strScriptName;
|
||||
m_editScriptName.GetWindowTextA(strScriptName);
|
||||
return strScriptName;
|
||||
}
|
||||
|
||||
|
||||
CString COption3DSettingDlg::GetTimeInterval()
|
||||
{
|
||||
CString strTimeInterval;
|
||||
m_editTimeInterval.GetWindowTextA(strTimeInterval);
|
||||
return strTimeInterval;
|
||||
}
|
||||
|
||||
//获取操作员
|
||||
CString COption3DSettingDlg::GetOperator()
|
||||
{
|
||||
CString strOperator;
|
||||
m_editOperator.GetWindowTextA(strOperator);
|
||||
return strOperator;
|
||||
}
|
||||
|
||||
//获取备注
|
||||
CString COption3DSettingDlg::GetNote()
|
||||
{
|
||||
CString strNote;
|
||||
m_editNote.GetWindowTextA(strNote);
|
||||
return strNote;
|
||||
}
|
||||
@@ -0,0 +1,295 @@
|
||||
// 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);
|
||||
}
|
||||
Reference in New Issue
Block a user