Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

ngui.cpp

Go to the documentation of this file.
00001 
00002 // Name:        gui.cpp
00003 // Purpose:     Code for NeReK's Gui
00004 // Author:      Chad Rempp
00005 // Modified by: Chad Rempp
00006 // Created:     05-20-03
00007 // Copyright:   (c) 2003 Chad Rempp
00008 // Licence:     GNU Public License (hey it's what all my friends are doing)
00010 
00011 #include <wx/wxprec.h>
00012 #include <wx/glcanvas.h>
00013 #include <wx/wfstream.h>
00014 #include <wx/txtstrm.h>
00015 #include <wx/textctrl.h>
00016 #include <wx/textfile.h>
00017 #include "ngui/ngui.h"
00018 #include "nviz3d/nviz3d.h"
00019 #include "nkernel/nkern_net.h"
00020 #include "nkernel/nkern_neuron.h"
00021 #include "netio.h"
00022 
00023 #ifndef WX_PRECOMP
00024    #include <wx/wx.h>
00025 #endif
00026 
00027 IMPLEMENT_APP(NguiApp)
00028 
00030 // NguiApp Class Implementation
00032 
00034 bool NguiApp::OnInit()
00035 {
00036    NguiFrame *ngui_frame = new NguiFrame("NeReK Simulator",
00037        wxPoint (0,0), wxSize(450, 45), wxDEFAULT_FRAME_STYLE);
00038    ngui_frame->Show(TRUE);
00039    SetTopWindow(ngui_frame);
00040 
00041    return TRUE;
00042 }
00043 
00045 // NguiFrame Class Implementation
00047 
00049 NguiFrame::NguiFrame(const wxString &title, const wxPoint &pos, const wxSize &size, long style)
00050     : wxFrame((wxFrame *) NULL, -1, title, pos, size, style)
00051 {
00052     wxMenu *FileMenu     = new wxMenu;
00053     wxMenu *NetworkMenu  = new wxMenu;
00054     wxMenu *DebugMenu    = new wxMenu;
00055     wxMenu *HelpMenu     = new wxMenu;
00056     wxMenuBar *MenuBar   = new wxMenuBar;
00057 
00058     // create a menu bar
00059     FileMenu->AppendSeparator();
00060     FileMenu->Append(NguiFrame_Quit, "&Quit");
00061     NetworkMenu->Append(NguiFrame_NewNetwork, "&New Network");
00062     NetworkMenu->Append(NguiFrame_LoadNetwork, "&Load Network");
00063     NetworkMenu->Append(NguiFrame_SaveNetwork, "&Save Network");
00064     NetworkMenu->AppendSeparator();
00065     DebugMenu->Append(NguiFrame_OpenLog, "&Log");
00066     DebugMenu->AppendSeparator();
00067     HelpMenu->AppendSeparator();
00068     HelpMenu->Append(NguiFrame_About, "&About");
00069 
00070     // Add it to the menu bar
00071     MenuBar->Append(FileMenu, "&File");
00072     MenuBar->Append(NetworkMenu,"&Network");
00073     MenuBar->Append(DebugMenu, "&Debug");
00074     MenuBar->Append(HelpMenu, "&Help");
00075     SetMenuBar(MenuBar);
00076 
00077     // Create the status bar
00078     CreateStatusBar(2);
00079     SetStatusText("Welcome To NeReK");
00080 }
00081 
00083 void NguiFrame::OnAbout(wxCommandEvent &event)
00084 {
00085 //    size_t monitor_count = wxDisplay::GetCount();
00086     (void)wxMessageBox("NeReK Simulator\nAuthor: Chad Rempp\n",
00087                        "About NeReK Simulator");
00088 }
00089 
00091 void NguiFrame::OnLoadNetwork(wxCommandEvent &event)
00092 {
00093     wxFileDialog load_dialog(this, "Load Network File", "", "",
00094                         "Network Files (*.net)|*.net");
00095     //wxTextCtrl &txt_log = *GetTextCtrl();
00096     wxString tmp;
00097     if (load_dialog.ShowModal() == wxID_OK)
00098     {
00099         wxTextFile *network_file = new wxTextFile(load_dialog.GetPath().c_str());
00100         network_file->Open();
00101 
00102         ParseFile(network_file);
00103 
00104         //tmp = network_file->GetLine(1);
00105         //(*txt_log) << tmp;
00106     }
00107 }
00108 
00110 void NguiFrame::OnNewNetwork(wxCommandEvent &event)
00111 {
00112 }
00113 
00115 void NguiFrame::OnQuit(wxCommandEvent & WXUNUSED(event))
00116 {
00117     // Force the window to close
00118     Close(TRUE);
00119 }
00120 
00122 void NguiFrame::OnSaveNetwork(wxCommandEvent &event)
00123 {
00124 }
00125 
00127 void NguiFrame::OnOpenLog(wxCommandEvent &event)
00128 {
00129     dlg_log = new wxDialog(this, -1, "Debug Log", wxPoint(400,400),
00130                            wxSize(400,500));
00131     txt_log = new wxTextCtrl(dlg_log, -1, "", wxPoint(0,0), wxSize(400,500),
00132                              wxTE_MULTILINE | wxTE_READONLY);
00133 //    (*txt_log) << "Log Window";
00134     dlg_log->Show();
00135 }
00136 
00137 BEGIN_EVENT_TABLE(NguiFrame, wxFrame)
00138    EVT_MENU(NguiFrame_Quit, NguiFrame::OnQuit)
00139    EVT_MENU(NguiFrame_NewNetwork, NguiFrame::OnNewNetwork)
00140    EVT_MENU(NguiFrame_LoadNetwork, NguiFrame::OnLoadNetwork)
00141    EVT_MENU(NguiFrame_SaveNetwork, NguiFrame::OnSaveNetwork)
00142    EVT_MENU(NguiFrame_About, NguiFrame::OnAbout)
00143    EVT_MENU(NguiFrame_OpenLog, NguiFrame::OnOpenLog)
00144 END_EVENT_TABLE()
00145 
00147 // NetDialog Class Implementation
00149 
00151 NetDialog::NetDialog(wxWindow *parent, wxWindowID id, const wxString &title,
00152                      const wxPoint &position, const wxSize& size, long style) :
00153                      wxDialog(parent, id, title, position, size, style)
00154 {
00155     btn_newinput  = new wxButton(this, NetDialog_NEWINPUT_BTN, "New Input",
00156                                  wxPoint(10,10), wxSize(70,17));
00157     btn_delinput  = new wxButton(this, NetDialog_DELINPUT_BTN, "Delete Input",
00158                                  wxPoint(10,30), wxSize(70,17));
00159     btn_setwghts  = new wxButton(this, NetDialog_SETWGHTS_BTN, "Set Weights",
00160                                  wxPoint(10,50), wxSize(70,17));
00161     btn_train     = new wxButton(this, NetDialog_TRAIN_BTN, "Train",
00162                                  wxPoint(10,90), wxSize(70,17));
00163     btn_run       = new wxButton(this, NetDialog_RUN_BTN, "Run",
00164                                  wxPoint(10,110), wxSize(70,17));
00165     btn_setdesrd  = new wxButton(this, NetDialog_SETDESRD_BTN, "Set Desired",
00166                                  wxPoint(10,70), wxSize(70,17));
00167     btn_showdiag  = new wxButton(this, NetDialog_SHOWDIAG_BTN, "Show Diag",
00168                                  wxPoint(10,170), wxSize(70,17));
00169     btn_quit      = new wxButton(this, NetDialog_QUIT_BTN, "Quit",
00170                                  wxPoint(10,200), wxSize(70,17));
00171     txt_bias      = new wxTextCtrl(this, NetDialog_BIAS_TXT, "",
00172                                  wxPoint(90,150), wxSize(25,22));
00173     txt_squashval = new wxTextCtrl(this, NetDialog_SQUASHVAL_TXT, "",
00174                                  wxPoint(90,130), wxSize(25,22));
00175     stc_bias      = new wxStaticText(this, -1, "Bias Value", wxPoint(10,150));
00176     stc_squashval = new wxStaticText(this, -1, "Squash Value", wxPoint(10,130));
00177 }
00178 
00180 void NetDialog::OnNewInput(wxCommandEvent &event)
00181 {
00182 }
00183 
00185 void NetDialog::OnDelInput(wxCommandEvent &event)
00186 {
00187 }
00188 
00190 void NetDialog::OnSetWghts(wxCommandEvent &event)
00191 {
00192 }
00193 
00195 void NetDialog::OnSetDesrd(wxCommandEvent &event)
00196 {
00197 }
00198 
00200 void NetDialog::OnTrain(wxCommandEvent &event)
00201 {
00202 }
00203 
00205 void NetDialog::OnRun(wxCommandEvent &event)
00206 {
00207 }
00208 
00210 void NetDialog::OnShowDiag(wxCommandEvent &event)
00211 {
00212     NvizFrame *dlg_gldiagram = new NvizFrame(this, "Network Diagram",
00213                                wxPoint(50,50), wxSize(450,340));
00214     dlg_gldiagram->Show(TRUE);
00215 }
00216 
00218 void NetDialog::OnQuit(wxCommandEvent &event)
00219 {
00220     Close(TRUE);
00221 }
00222 
00223 BEGIN_EVENT_TABLE(NetDialog, wxDialog)
00224    EVT_BUTTON(NetDialog_NEWINPUT_BTN, NetDialog::OnNewInput)
00225    EVT_BUTTON(NetDialog_DELINPUT_BTN, NetDialog::OnDelInput)
00226    EVT_BUTTON(NetDialog_SETWGHTS_BTN, NetDialog::OnSetWghts)
00227    EVT_BUTTON(NetDialog_TRAIN_BTN, NetDialog::OnTrain)
00228    EVT_BUTTON(NetDialog_RUN_BTN, NetDialog::OnRun)
00229    EVT_BUTTON(NetDialog_SETDESRD_BTN, NetDialog::OnSetDesrd)
00230    EVT_BUTTON(NetDialog_SHOWDIAG_BTN, NetDialog::OnShowDiag)
00231    EVT_BUTTON(NetDialog_QUIT_BTN, NetDialog::OnQuit)
00232 END_EVENT_TABLE()
00233 
00234 

Generated on Mon Jun 23 23:09:51 2003 for NeReK Documentation by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002