📄 matchview.cpp
字号:
// MatchView.cpp : implementation of the CMatchView class
//
#include "stdafx.h"
#include "Match.h"
#include "MatchDoc.h"
#include "MatchView.h"
#include "PathSec.h"
#include "MainFrm.h"
#include "RightView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMatchView
IMPLEMENT_DYNCREATE(CMatchView, CView)
BEGIN_MESSAGE_MAP(CMatchView, CView)
//{{AFX_MSG_MAP(CMatchView)
ON_WM_SIZE()
ON_WM_KEYDOWN()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CMatchView construction/destruction
CMatchView::CMatchView()
{
// TODO: add construction code here
m_bDown = false;
}
CMatchView::~CMatchView()
{
}
BOOL CMatchView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMatchView drawing
void CMatchView::OnDraw(CDC* pDC)
{
CMatchDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
if ( pDoc->m_hDIB1 != NULL)
{
Draw(pDC, pDoc->m_hDIB1);
}
}
/////////////////////////////////////////////////////////////////////////////
// CMatchView printing
BOOL CMatchView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CMatchView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CMatchView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CMatchView diagnostics
#ifdef _DEBUG
void CMatchView::AssertValid() const
{
CView::AssertValid();
}
void CMatchView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CMatchDoc* CMatchView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMatchDoc)));
return (CMatchDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMatchView message handlers
void CMatchView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
}
void CMatchView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
CView::OnKeyDown(nChar, nRepCnt, nFlags);
}
void CMatchView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CMatchDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if ( pDoc->m_bSec )
{
m_bDown = true;
m_pt = point;
}
CView::OnLButtonDown(nFlags, point);
}
void CMatchView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CMatchDoc* pDoc = GetDocument();
CDC *pDC = GetDC();
CMainFrame *pFrm = (CMainFrame *)AfxGetApp()->GetMainWnd();
CRightView *pView = (CRightView *)(pFrm->m_wndSplitter).GetPane(0, 1);
if (m_bDown)
{
cx = abs(point.x - m_pt.x);
cy = abs(point.y - m_pt.y);
m_point.x = ( point.x > m_pt.x ) ? m_pt.x : point.x;
m_point.y = ( point.y > m_pt.y ) ? point.y: m_pt.y ;
m_bDown = false;
CPen* pPenRed = new CPen;
pPenRed->CreatePen(PS_SOLID,1,RGB(255,0,0));
CPen *oldpen = pDC->SelectObject(pPenRed);
pDC->MoveTo(m_pt);
pDC->LineTo(m_pt.x, point.y);
pDC->LineTo(point);
pDC->LineTo(point.x, m_pt.y);
pDC->LineTo(m_pt);
pDC->SelectObject(oldpen);
delete pPenRed;
int x = 0, y = 0;
double result = 0.0;
pView->Start(x, y, result);
pView->DrawCross(x, pDoc->m_nHeight2 - y);
CString str1,str2,str3,str4;
str1.Format("x = %d", x);
str2.Format("y = %d", y);
str3.Format(" 相关系数 = %lf", result);
str4 = str1 + " "+ str2 + str3;
MessageBox(str4);
}
CView::OnLButtonUp(nFlags, point);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -