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