📄 dlgline.cpp
字号:
// DlgLine.cpp : implementation file
//
#include "stdafx.h"
#include "NeuralNetwork.h"
#include "DlgLine.h"
#include "MainFrm.h"
#include "NeuralNetworkView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgLine dialog
CDlgLine::CDlgLine(CWnd* pParent /*=NULL*/)
: CDialog(CDlgLine::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgLine)
m_nWeight = 0.0f;
//}}AFX_DATA_INIT
}
void CDlgLine::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgLine)
DDX_Text(pDX, IDC_EDIT_WEIGHT, m_nWeight);
DDV_MinMaxFloat(pDX, m_nWeight, -100.f, 100.f);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgLine, CDialog)
//{{AFX_MSG_MAP(CDlgLine)
ON_WM_VSCROLL()
ON_EN_CHANGE(IDC_EDIT_WEIGHT, OnChangeEditWeight)
ON_BN_CLICKED(IDCANCEL, OnDelete)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgLine message handlers
BOOL CDlgLine::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CString strText;
CSliderCtrl* pSlide= (CSliderCtrl*) GetDlgItem(IDC_TRACKBAR);
pSlide->SetRange(-100.0f, 100.0f);
pSlide->SetPos(m_nWeight);
strText.Format("%f", pSlide->GetPos());
SetDlgItemText(IDC_EDIT_WEIGHT, strText);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgLine::OnOK()
{
// TODO: Add extra validation here
CString neuralWeight;
CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();
CNeuralNetworkDoc* pDoc = (CNeuralNetworkDoc*) pMainFrame->GetActiveDocument();
GetDlgItemText(IDC_EDIT_WEIGHT,neuralWeight);
m_nWeight=atof(neuralWeight);
pDoc->neuralNetwork.setCurrentWeight(m_nWeight);
CDialog::OnOK();
}
void CDlgLine::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
CSliderCtrl* pSlide = (CSliderCtrl*) pScrollBar;
CString strText;
strText.Format("%d", pSlide->GetPos());
SetDlgItemText(IDC_EDIT_WEIGHT, strText);
CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}
void CDlgLine::OnChangeEditWeight()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
CString strText;
CSliderCtrl* pSlide= (CSliderCtrl*) GetDlgItem(IDC_TRACKBAR);
GetDlgItemText(IDC_EDIT_WEIGHT, strText);
//CString转换为float
m_nWeight=atof(strText);
//重新设置slider位置
pSlide->SetPos(m_nWeight);
}
void CDlgLine::setCDC(CDC *newDC)
{
pDC=newDC;
}
void CDlgLine::setRect(CRect newRect)
{
rect=newRect;
}
void CDlgLine::OnDelete()
{
// TODO: Add your control notification handler code here
CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();
CNeuralNetworkDoc* pDoc = (CNeuralNetworkDoc*) pMainFrame->GetActiveDocument();
//=========删除当前突触=========
pDoc->neuralNetwork.deleteLine(pDC,rect);
CDialog::OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -