a
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user