⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gui.cpp

📁 函数逼近
💻 CPP
字号:
/*
 * 
 *	 Copyright 2004-2006 Ghassan OREIBY
 *   
 * 	 This file is part of Neurality.
 *
 *   Neurality is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   Neurality is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *   along with Neurality; if not, write to the Free Software
 *   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * 
 */


// GUI.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "GUI.h"
#include "MainFrm.h"
#include "NewDialog.h"
#include "LearnOptionsDlg.h"
//#include "../NeuralDLL/NeuralNetwork.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif



// CGUIApp

BEGIN_MESSAGE_MAP(CGUIApp, CWinApp)
	ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
//	ON_COMMAND(ID_FILE_NEW, OnFileNew)
//	ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
//	ON_COMMAND(ID_LEARNING_OPTIONS, OnLearningOptions)
//	ON_COMMAND(ID_LEARNING_START, OnLearningStart)
END_MESSAGE_MAP()


// CGUIApp construction

CGUIApp::CGUIApp()
//: m_Net(NULL)
//, m_HiddenLayer(NULL)
//, m_nTotalHidden(0)
//, bNetworkExist(false)
//, m_nItrShow(1000)
//, m_nItrSave(10000)
//, m_bShowCurve(FALSE)
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}


// The one and only CGUIApp object

CGUIApp theApp;

// CGUIApp initialization

BOOL CGUIApp::InitInstance()
{
	// InitCommonControls() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	InitCommonControls();

	CWinApp::InitInstance();

	// Initialize OLE libraries
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_OLE_INIT_FAILED);
		return FALSE;
	}
	AfxEnableControlContainer();
	// Standard initialization
	// If you are not using these features and wish to reduce the size
	// of your final executable, you should remove from the following
	// the specific initialization routines you do not need
	// Change the registry key under which our settings are stored
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));
	// To create the main window, this code creates a new frame window
	// object and then sets it as the application's main window object
	CMainFrame* pFrame = new CMainFrame;
	m_pMainWnd = pFrame;
	// create and load the frame with its resources
	pFrame->LoadFrame(IDR_MAINFRAME,
		WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL,
		NULL);
    
	CMenu* pMenu = m_pMainWnd->GetMenu();
	CMenu* pSubMenu = pMenu->GetSubMenu(0);
	pSubMenu->EnableMenuItem(ID_FILE_NEW, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);

	 //If there is a menu and it has items, we'll
	 //delete the first one.
	if (pMenu != NULL && pMenu->GetMenuItemCount() > 0)
	{
		//pMenu->DeleteMenu(0, MF_BYPOSITION);
		//pMenu->GetSubMenu(0)->EnableMenuItem(0, MF_BYPOSITION | MF_GRAYED);
		//pMenu->EnableMenuItem(ID_FILE_OPEN, MF_BYCOMMAND | MF_GRAYED);
		 //force a redraw of the menu bar
		pFrame->DrawMenuBar();
	}

	//LoadStdProfileSettings(4);
	// The one and only window has been initialized, so show and update it
	pFrame->ShowWindow(SW_SHOW);
	pFrame->UpdateWindow();
	// call DragAcceptFiles only if there's a suffix
	//  In an SDI app, this should occur after ProcessShellCommand

	return TRUE;
}


// CGUIApp message handlers



// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	enum { IDD = IDD_ABOUTBOX };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

// Implementation
protected:
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()

// App command to run the dialog
void CGUIApp::OnAppAbout()
{
	CAboutDlg aboutDlg;
	aboutDlg.DoModal();
}


// CGUIApp message handlers


//void CGUIApp::OnFileNew()
//{
//	CNewDialog NewDlg;
//
//	if (NewDlg.DoModal() == IDCANCEL) return;
//	m_nTotalHidden = NewDlg.m_nTotalHidden;
//	m_HiddenLayer = new CLayer*[m_nTotalHidden];
//	for (int i = 0; i < NewDlg.m_nTotalHidden; i++)
//		m_HiddenLayer[i] = new CLayer(NewDlg.m_nHiddenArray[i]);
//	m_Net = new CNetwork(m_HiddenLayer, m_nTotalHidden, NewDlg.m_nInputNo, NewDlg.m_nOuputNo,
//		NewDlg.m_fInputMin, NewDlg.m_fInputMax, NewDlg.m_fOutputMin, NewDlg.m_fOutputMax);
//	MessageBox(NULL, TEXT("Neural Network created Successfully"), TEXT("Success"), NULL);
//   
//}

CGUIApp::~CGUIApp(void)
{
	//if (m_Net) delete m_Net;
	//if (m_HiddenLayer) 
	//{
	//	for (int i = 0; i < m_nTotalHidden; i++)
	//		delete m_HiddenLayer[i];
	//	delete[] m_HiddenLayer;
	//}
}

//void CGUIApp::OnFileOpen()
//{
//	static char BASED_CODE szFilter[] = "Neural Network Files (*.nnf)|*.nnf|All Files (*.*)|*.*||";
//	CFileDialog	OpenDlg(TRUE, NULL, NULL, OFN_EXPLORER | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter);
//	char	str[256];
//
//	if (OpenDlg.DoModal() == IDCANCEL) return;
//	sprintf(str, "%s", OpenDlg.GetPathName().GetString());
//	if (m_Net) delete m_Net;
//	m_Net = new CNetwork(str);
//	if (m_Net->GetState())	
//		MessageBox(NULL, OpenDlg.GetPathName(), TEXT("Success!"), MB_OK);
//	else 
//	{
//		MessageBox(NULL, TEXT("Couldnt open the File."), NULL, MB_ICONERROR);
//		delete m_Net;
//		m_Net = NULL;
//	}
//}

//void CGUIApp::OnLearningOptions()
//{
//	CLearnOptionsDlg	LearnDlg;
//	
//	LearnDlg.DoModal();
//	LearnDlg.AdjustNetworkLearning();
//	m_nItrSave = LearnDlg.GetItrSave();
//	m_nItrShow = LearnDlg.GetItrShow();
//	m_bShowCurve = LearnDlg.GetShowCurveState();
//}

//void CGUIApp::OnLearningStart()
//{
//	// TODO: Add your command handler code here
//	real	inp[SAMPLES][1], outp[SAMPLES][1];
//	real	in[SAMPLES], out[SAMPLES];
//	
//    for (int i=0; i < SAMPLES; i++)
//	{
//		inp[i][0] = i * 0.35f / SAMPLES;// * 0.35f / 25 + 0.15f;
//		outp[i][0] = sinf( 2.0f * PI * inp[i][0] * 5.0f) + sinf( 2.0f * PI * inp[i][0] * 10.0f);
//	}
//
//	LINEARIZE_ARRAY(inp, SAMPLES, 1, in);
//	LINEARIZE_ARRAY(outp, SAMPLES, 1, out);
//
//	this->m_pMainWnd->m_wnd
//
//
//
//	//m_Net->Learn(SAMPLES , in, out, 0.0001f, 100, 50000, ClientDC);
//}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -