📄 newproject.cpp
字号:
// NewProject.cpp : implementation file
//
#include "stdafx.h"
#include "bpnlayerexe.h"
#include "NewProject.h"
#include "BpNlayerEXEDoc.h"
#include "resualtTextView.h"
#include "SelectErrorType.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CNewProject dialog
CNewProject::CNewProject(CWnd* pParent /*=NULL*/)
: CDialog(CNewProject::IDD, pParent)
{
//{{AFX_DATA_INIT(CNewProject)
m_iLayerNum = 1;
m_iLayerTh = 1;
m_iNeuNum = 1;
m_dStudyRate = 0.0;
m_dMomentum = 0.0;
//}}AFX_DATA_INIT
}
BOOL CNewProject::OnInitDialog()
{
((CComboBox *)GetDlgItem(IDC_COMBO1))->AddString("Sigm");
((CComboBox *)GetDlgItem(IDC_COMBO1))->AddString("Tanh");
((CComboBox *)GetDlgItem(IDC_COMBO1))->AddString("Gaus");
((CComboBox *)GetDlgItem(IDC_COMBO1))->SetCurSel(0);
UpdateData(FALSE);
return TRUE;
}
void CNewProject::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CNewProject)
DDX_Text(pDX, IDC_EDIT1, m_iLayerNum);
DDV_MinMaxUInt(pDX, m_iLayerNum, 1, 100);
DDX_Text(pDX, IDC_EDIT2, m_iLayerTh);
DDV_MinMaxUInt(pDX, m_iLayerTh, 0, 100);
DDX_Text(pDX, IDC_EDIT3, m_iNeuNum);
DDV_MinMaxUInt(pDX, m_iNeuNum, 0, 100);
DDX_Text(pDX, IDC_EDIT4, m_dStudyRate);
DDV_MinMaxDouble(pDX, m_dStudyRate, 0., 100.);
DDX_Text(pDX, IDC_EDIT5, m_dMomentum);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CNewProject, CDialog)
//{{AFX_MSG_MAP(CNewProject)
ON_BN_CLICKED(IDC_BTN_LAYOK, OnBtnLayok)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CNewProject message handlers
void CNewProject::OnBtnLayok()
{
// TODO: Add your control notification handler code here
//CBpNlayerEXEDoc *pDoc=(CBpNlayerEXEDoc *)(((CBpNlayerEXEView *)GetParent())->GetDocument());//error
CBpNlayerEXEDoc* pDoc=CBpNlayerEXEDoc::GetDoc();
UpdateData();
pDoc->m_iLayerNum=m_iLayerNum;
pDoc->m_piLayerCapture=new int[m_iLayerNum];
for (int i=0;i<m_iLayerNum;i++)
{
*(pDoc->m_piLayerCapture+i)=0;
}
//GetDlgItem(IDC_EDIT1)->SetWindowText("haha");
GetDlgItem(IDC_EDIT1)->EnableWindow(FALSE);
GetDlgItem(IDC_BTN_LAYOK)->EnableWindow(FALSE);
GetDlgItem(IDC_EDIT2)->EnableWindow(TRUE);
GetDlgItem(IDC_EDIT3)->EnableWindow(TRUE);
GetDlgItem(IDC_BUTTON2)->EnableWindow(TRUE);
GetDlgItem(IDC_BUTTON3)->EnableWindow(TRUE);
GetDlgItem(IDC_COMBO1)->EnableWindow(TRUE);
}
void CNewProject::OnButton2()
{
// TODO: Add your control notification handler code here
CBpNlayerEXEDoc* pDoc=CBpNlayerEXEDoc::GetDoc();
UpdateData();
if (m_iLayerTh>m_iLayerNum||m_iLayerTh<1)
{
MessageBox("输入层数不合要求");
}
else
{
*(pDoc->m_piLayerCapture+m_iLayerTh-1)=m_iNeuNum;
CString str;
int inttemp=0;
inttemp=m_iLayerTh+1;
if (inttemp>m_iLayerNum)
{
inttemp=1;
}
str.Format("%d",inttemp);
SetDlgItemText(IDC_EDIT2,str);
}
}
void CNewProject::OnButton3()
{
// TODO: Add your control notification handler code here
CBpNlayerEXEDoc* pDoc=CBpNlayerEXEDoc::GetDoc();
UpdateData();
switch(((CComboBox*)GetDlgItem(IDC_COMBO1))->GetCurSel())
{
case 0:
pDoc->m_FunctionType=NEURON_SIGM;
break;
case 1:
pDoc->m_FunctionType=NEURON_TANH;
break;
case 2:
pDoc->m_FunctionType=NEURON_GAUS;
break;
default:
break;
}
GetDlgItem(IDC_EDIT4)->EnableWindow(TRUE);
GetDlgItem(IDC_BUTTON1)->EnableWindow(TRUE);
}
void CNewProject::OnButton4()
{
// TODO: Add your control notification handler code here
CBpNlayerEXEDoc* pDoc=CBpNlayerEXEDoc::GetDoc();
pDoc->m_pBPNet=new CBPNLayer;
pDoc->m_pBPNet->SetBPNet(pDoc->m_iLayerNum,pDoc->m_piLayerCapture,pDoc->m_FunctionType
,pDoc->m_dStudyRate,pDoc->m_dMomentum);
POSITION pos = pDoc->GetFirstViewPosition();
CView *pView1,*pView2,*pView3;
while (pos != NULL)
{
pView1=pDoc->GetNextView(pos);
if (pView1->IsKindOf(RUNTIME_CLASS(resualtTextView)))
{
pView2=pView1;
}
if (pView1->IsKindOf(RUNTIME_CLASS(textshowView)))
{
pView3=pView1;
}
}
pDoc->m_pResualtView=(resualtTextView*)pView2;
pDoc->m_pTextShowView=(textshowView*)pView3;
((resualtTextView*)pView2)->m_pdOrigin=new double[*(pDoc->m_piLayerCapture+pDoc->m_iLayerNum-1)];
((textshowView*)pView3)->SetTreeView();
EndDialog(0);
pDoc->SetDatabase();
SelectErrorType dlg;
if (IDOK==dlg.DoModal())
{
pDoc->m_bAbsError=TRUE;
}
else
pDoc->m_bAbsError=FALSE;
/* POSITION pos = GetFirstViewPosition();
while (pos != NULL)
{
CView* pView = GetNextView(pos);
pView->Invalidate();
} */
}
void CNewProject::OnButton1()
{
// TODO: Add your control notification handler code here
UpdateData();
CBpNlayerEXEDoc* pDoc=CBpNlayerEXEDoc::GetDoc();
pDoc->m_dStudyRate=m_dStudyRate;
GetDlgItem(IDC_BUTTON5)->EnableWindow(TRUE);
GetDlgItem(IDC_EDIT5)->EnableWindow(TRUE);
}
void CNewProject::OnButton5()
{
// TODO: Add your control notification handler code here
UpdateData();
CBpNlayerEXEDoc * pDoc=CBpNlayerEXEDoc::GetDoc();
pDoc->m_dMomentum=m_dMomentum;
GetDlgItem(IDC_BUTTON4)->EnableWindow(TRUE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -