📄 mineview.cpp
字号:
// MineView.cpp : implementation of the CMineView class
//
#include "stdafx.h"
#include "Mine.h"
#include "MineDoc.h"
#include "MineView.h"
#include "ReadData.h"
#include "math.h"
#include "DB.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern _ConnectionPtr g_pConnection;
extern CNode *g_pNodeHead;
extern CEdge *g_pEdgeHead;
extern CPolygon *g_pPolygonHead;
extern int g_nNodeNum;
extern int g_nEdgeNum;
extern int g_nPolygonNum;
extern float g_fXMin;
extern float g_fXMax;
extern float g_fYMin;
extern float g_fYMax;
extern float g_fZMin;
extern float g_fZMax;
extern float g_fXTranslation;
extern float g_fYTranslation;
extern float g_fZTranslation;
extern float g_fXZoom;
extern float g_fYZoom;
extern float g_fZZoom;
extern float g_fSize;
extern float size;//冗差控制
extern bool g_bCreateTin;
extern bool g_bCreateTinBody;
extern int g_nCurrentLayer;
extern int g_nMaxLayer;
extern bool g_bInit;
/////////////////////////////////////////////////////////////////////////////
// CMineView
IMPLEMENT_DYNCREATE(CMineView, CView)
BEGIN_MESSAGE_MAP(CMineView, CView)
//{{AFX_MSG_MAP(CMineView)
ON_COMMAND(ID_SHOWDB, OnShowdb)
ON_COMMAND(ID_SHOWTIN, OnShowtin)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_COMMAND(ID_CDLINE, OnInsertCDLine)
ON_WM_MOUSEMOVE()
ON_COMMAND(ID_SHOWCDTIN, OnShowcdtin)
ON_COMMAND(ID_SHOWCLINFORM, OnShowCLInform)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMineView construction/destruction
CMineView::CMineView()
{
// TODO: add construction code here
m_bDraw = FALSE;
m_ptOrigin=0;
m_nDrawType=0;
bCreateTin = false;//形成Tin网控制变量
bCreateTinBody = false;//形成体控制变量
bDisplayTin = false;//TIN网显示控制变量
bDisplayTinBody = false;//TIN网成体显示控制变量
}
CMineView::~CMineView()
{
}
BOOL CMineView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
//设置窗口类型
cs.style |=WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMineView drawing
void CMineView::OnDraw(CDC* pDC)
{
CMineDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
DrawPoint();
}
/////////////////////////////////////////////////////////////////////////////
// CMineView printing
BOOL CMineView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CMineView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CMineView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CMineView diagnostics
#ifdef _DEBUG
void CMineView::AssertValid() const
{
CView::AssertValid();
}
void CMineView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CMineDoc* CMineView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMineDoc)));
return (CMineDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMineView message handlers
void CMineView::OnShowdb()
{
// TODO: Add your command handler code here
if (m_nDrawType==0)
{
CReadData readdata;
readdata.ReadAdoData();
}
m_nDrawType=1;
Invalidate();
}
void CMineView::OnShowtin()
{
// TODO: Add your command handler code here
if (m_nDrawType==1)
{
if (!g_bCreateTin)
{
tin.CreateTin();
ShowTin();
g_bCreateTin = true;
}
}
m_nDrawType=2;
}
void CMineView::DrawPoint()
{
CClientDC dc(this);
CNode *node;
node=g_pNodeHead->next ;
//float x,y;
CString Str_Pname;
CPen pen(1,1,RGB(0,0,255));
CPen* pOldPen ;
pOldPen = dc.SelectObject(&pen);
while(node!=g_pNodeHead)
{
Str_Pname.Format("%d",node->m_nNodeID );
dc.Ellipse((int)node->x-2,(int)node->y-2,(int)node->x+2,(int)node->y+2);
// dc.TextOut((int)node->x+1,(int)node->y+1,Str_Pname);
node=node->next ;
}
dc.SelectObject(pOldPen);
}
//DEL void CMineView::OnOpendbAccess()
//DEL {
//DEL
//DEL CDB db;//数据库变量
//DEL
//DEL db.ConnectDataBase(1,"DB\\地面点.MDB");
//DEL //读取数据
//DEL CReadData readdata;
//DEL readdata.ReadAdoData()
//DEL }
void CMineView::ShowTin()
{
CClientDC dc(this);
CPen pen(PS_SOLID,1,RGB(0,0,255));
CPen* pOldPen ;
pOldPen = dc.SelectObject(&pen);
CPolygon *pf;
pf=g_pPolygonHead->next;int i=0;
while(pf!=g_pPolygonHead)
{
dc.MoveTo((int)pf->m_pConsistNodes[0]->x,(int)pf->m_pConsistNodes[0]->y );
dc.LineTo((int)pf->m_pConsistNodes[1]->x,(int)pf->m_pConsistNodes[1]->y );
dc.MoveTo((int)pf->m_pConsistNodes[1]->x,(int)pf->m_pConsistNodes[1]->y);
dc.LineTo((int)pf->m_pConsistNodes[2]->x,(int)pf->m_pConsistNodes[2]->y );
dc.MoveTo((int)pf->m_pConsistNodes[2]->x,(int)pf->m_pConsistNodes[2]->y );
dc.LineTo((int)pf->m_pConsistNodes[0]->x,(int)pf->m_pConsistNodes[0]->y );
pf=pf->next ;
i++;
}
dc.SelectObject(pOldPen);
}
void CMineView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if (m_nDrawType==2)
{
m_ptOrigin=point;
m_ptEnd=point;
m_bDraw = TRUE;
}
m_nDrawType=2;
CView::OnLButtonDown(nFlags, point);
}
#include "InformDlg.h"
void CMineView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if (m_nDrawType==2)
{
if (m_ptOrigin.x>g_fXMax||m_ptOrigin.x<g_fXMin||m_ptOrigin.y>g_fYMax||m_ptOrigin.y<g_fYMin||m_ptEnd.x>g_fXMax||m_ptEnd.x<g_fXMin||m_ptEnd.y>g_fYMax||m_ptEnd.y<g_fYMin)
{
AfxMessageBox("操作非法,约束线端点超出了TIN网!");
return;
}
else
{
CPen pen(PS_SOLID,2,RGB(255,0,0));
CClientDC dc(this);
CPen* pOldPen = dc.SelectObject(&pen);
dc.MoveTo(m_ptOrigin);
dc.LineTo(point);
m_ptEnd=point;
dc.SelectObject(pOldPen);
CEntity entity;
CNode *node1,*node2;
node1=entity.InitNode();
node1->x=(float)m_ptEnd.x;
node1->y=(float)m_ptEnd.y;
node2=entity.InitNode();
node2->x=(float)m_ptOrigin.x;
node2->y=(float)m_ptOrigin.y;
node1->m_CDNode=true;
node2->m_CDNode=true;
dc.Ellipse((int)node1->x-2,(int)node1->y-2,(int)node1->x+2,(int)node1->y+2);
dc.Ellipse((int)node2->x-2,(int)node2->y-2,(int)node2->x+2,(int)node2->y+2);
m_bDraw = FALSE;
}
}
m_nDrawType=3;
CView::OnLButtonUp(nFlags, point);
}
void CMineView::OnInsertCDLine()
{
// TODO: Add your command handler code here
// m_nDrawType=3;
}
void CMineView::DrawCDLine()
{
// CClientDC dc(this);
//
// CString Str_Pname;
//
// CPen pen(1,1,RGB(255,0,0));
// CPen* pOldPen ;
// pOldPen = dc.SelectObject(&pen);
// //Str_Pname.Format("%d",node->m_nNodeID );
// // dc.Ellipse((int)node->x-2,(int)node->y-2,(int)node->x+2,(int)node->y+2);
// // dc.TextOut((int)node->x+1,(int)node->y+1,Str_Pname);
// dc.MoveTo(m_ptOrigin);
// dc.LineTo(m_ptEnd);
// dc.SelectObject(pOldPen);
}
void CMineView::OnMouseMove(UINT nFlags, CPoint point)
{
CView::OnMouseMove(nFlags, point);
}
void CMineView::OnShowcdtin()
{
// TODO: Add your command handler code here
if (m_nDrawType==3)
{
CClientDC dc(this);
tin.CreateCDTin();
CNode *node;
node=g_pNodeHead->next;
while (node->m_CDNode)
{
dc.Ellipse((int)node->x-2,(int)node->y-2,(int)node->x+2,(int)node->y+2);
node=node->next;
}
// ShowTin();
}
m_nDrawType=4;
}
#include "InformDlg.h"
void CMineView::OnShowCLInform()
{
// TODO: Add your command handler code here
CInformDlg dlg;
if (m_nDrawType==4)
{
dlg.DoModal();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -