📄 neuralnetworkview.cpp
字号:
// NeuralNetworkView.cpp : implementation of the CNeuralNetworkView class
//
#include "stdafx.h"
#include "NeuralNetwork.h"
#include "NeuralNetworkDoc.h"
#include "NeuralNetworkView.h"
#include "DlgNeuron.h"
#include "DlgLine.h"
#include "DlgTrain.h"
#include "DlgTest.h"
#include <stdlib.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
using namespace std; //for vector
/////////////////////////////////////////////////////////////////////////////
// CNeuralNetworkView
IMPLEMENT_DYNCREATE(CNeuralNetworkView, CView)
BEGIN_MESSAGE_MAP(CNeuralNetworkView, CView)
//{{AFX_MSG_MAP(CNeuralNetworkView)
ON_WM_ERASEBKGND()
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_COMMAND(ID_NEURON_INSERT, OnNeuronInsert)
ON_COMMAND(ID_NEURON_TRAIN, OnNeuronTrain)
ON_WM_RBUTTONDOWN()
ON_COMMAND(ID_NEURON_TEST, OnNeuronTest)
ON_COMMAND(ID_APP_HELP, OnAppHelp)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CNeuralNetworkView construction/destruction
CNeuralNetworkView::CNeuralNetworkView()//:m_rect(0,0,100,100)//,m_vNeuron(0)
{
// TODO: add construction code here
}
CNeuralNetworkView::~CNeuralNetworkView()
{
}
BOOL CNeuralNetworkView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CNeuralNetworkView drawing
void CNeuralNetworkView::OnDraw(CDC* pDC)
{
// TODO: add draw code for native data here
CRect rect;
GetClientRect(&rect);
CNeuralNetworkDoc* pDoc=GetDocument();
pDoc->neuralNetwork.neuralRedraw(pDC,rect);
CString test;
}
/////////////////////////////////////////////////////////////////////////////
// CNeuralNetworkView diagnostics
#ifdef _DEBUG
void CNeuralNetworkView::AssertValid() const
{
CView::AssertValid();
}
void CNeuralNetworkView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CNeuralNetworkDoc* CNeuralNetworkView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CNeuralNetworkDoc)));
return (CNeuralNetworkDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CNeuralNetworkView message handlers
BOOL CNeuralNetworkView::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
CBitmap bitmap;
bitmap.LoadBitmap(IDB_BMP_BACK);
CDC dcCompatible;
dcCompatible.CreateCompatibleDC(pDC);
dcCompatible.SelectObject(&bitmap);
CRect rect;
GetClientRect(&rect);
pDC->BitBlt(0,0,rect.Width(),rect.Height(),&dcCompatible,0,0,SRCCOPY);
return TRUE;
return CView::OnEraseBkgnd(pDC);
}
void CNeuralNetworkView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CDC *pDC=GetDC();
CNeuralNetworkDoc* pDoc=GetDocument();
pDoc->neuralNetwork.neuronMove(pDC,point);
CView::OnMouseMove(nFlags, point);
}
void CNeuralNetworkView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CDC *pDC=GetDC();
CNeuralNetworkDoc* pDoc=GetDocument();
pDoc->neuralNetwork.neuronSelected(pDC,point);
CView::OnLButtonDown(nFlags, point);
}
void CNeuralNetworkView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CDC *pDC=GetDC();
CNeuralNetworkDoc* pDoc=GetDocument();
CRect rect;
GetClientRect(&rect);
pDoc->neuralNetwork.neuronReleased(pDC,point,rect);
CView::OnLButtonUp(nFlags, point);
}
void CNeuralNetworkView::OnNeuronInsert()
{
// TODO: Add your command handler code here
CDC *pDC=GetDC();
CNeuralNetworkDoc* pDoc=GetDocument();
pDoc->neuralNetwork.drawNeuron(pDC);
}
void CNeuralNetworkView::OnNeuronTrain()
{
// TODO: Add your command handler code here
CDlgTrain dlgTrain;
dlgTrain.DoModal();
}
void CNeuralNetworkView::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CDC *pDC=GetDC();
CRect rect;
GetClientRect(&rect);
CNeuralNetworkDoc* pDoc=GetDocument();
pDoc->neuralNetwork.neuronRSelected(point,pDC,rect);
CView::OnRButtonDown(nFlags, point);
}
void CNeuralNetworkView::OnNeuronTest()
{
// TODO: Add your command handler code here
CDlgTest dlgTest;
dlgTest.DoModal();
}
void CNeuralNetworkView::OnAppHelp()
{
// TODO: Add your command handler code here
ShellExecute(NULL, "open", "NeuralNetwork.chm", NULL, NULL, SW_SHOWNORMAL);//SW_SHOWNORMAL
// HtmlHelp(this,"NeuralNetwork.chm" , HH_DISPLAY_TOPIC, 0);//(LPCSTR)strHelp
//AfxMessageBox("");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -