00001
00002
00003
00004 #include "stdafx.h"
00005 #include "EvolveTraffic.h"
00006
00007 #include "MainFrm.h"
00008 #include "EvolveTrafficDoc.h"
00009 #include "EvolveTrafficView.h"
00010
00011 #include <Mmsystem.h>
00012
00013 extern CConfigData g_ConfigData;
00014
00015 #ifdef _DEBUG
00016 #define new DEBUG_NEW
00017 #undef THIS_FILE
00018 static char THIS_FILE[] = __FILE__;
00019 #endif
00020
00022
00023
00024 BEGIN_MESSAGE_MAP(CEvolveTrafficApp, CWinApp)
00025
00026 ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
00027
00028
00029
00030
00031 ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
00032 ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
00033
00034 ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
00035 END_MESSAGE_MAP()
00036
00038
00039
00042 CEvolveTrafficApp::CEvolveTrafficApp()
00043 {
00044
00045
00046 }
00047
00049
00050
00051 CEvolveTrafficApp theApp;
00052
00054
00055
00056 BOOL CEvolveTrafficApp::InitInstance()
00057 {
00058 AfxEnableControlContainer();
00059
00060
00061
00062
00063
00064
00065 #ifdef _AFXDLL
00066 Enable3dControls();
00067 #else
00068 Enable3dControlsStatic();
00069 #endif
00070
00071
00072
00073
00074 SetRegistryKey(_T("Local AppWizard-Generated Applications"));
00075
00076 LoadStdProfileSettings();
00077
00078 if (!g_ConfigData.ReadData("EvolveTraffic.ini") )
00079 MessageBox(NULL,"Configuration file cannot be read", "EvolveTraffic", MB_OK|MB_ICONWARNING);
00080
00081
00082
00083
00084 CSingleDocTemplate* pDocTemplate;
00085 pDocTemplate = new CSingleDocTemplate(
00086 IDR_MAINFRAME,
00087 RUNTIME_CLASS(CEvolveTrafficDoc),
00088 RUNTIME_CLASS(CMainFrame),
00089 RUNTIME_CLASS(CEvolveTrafficView));
00090 AddDocTemplate(pDocTemplate);
00091
00092
00093 EnableShellOpen();
00094 RegisterShellFileTypes(TRUE);
00095
00096
00097 CCommandLineInfo cmdInfo;
00098 ParseCommandLine(cmdInfo);
00099
00100
00101 if (!ProcessShellCommand(cmdInfo))
00102 return FALSE;
00103
00104
00105 m_pMainWnd->ShowWindow(SW_SHOW);
00106 m_pMainWnd->UpdateWindow();
00107
00108
00109 m_pMainWnd->DragAcceptFiles();
00110
00111 m_bInSimulation = false;
00112
00113 return TRUE;
00114 }
00115
00116
00118
00119
00122 class CAboutDlg : public CDialog
00123 {
00124 public:
00125 CAboutDlg();
00126
00127
00128
00129 enum { IDD = IDD_ABOUTBOX };
00130 CString m_EditBox;
00131
00132
00133
00134
00135 protected:
00136 virtual void DoDataExchange(CDataExchange* pDX);
00137
00138
00139
00140 protected:
00141
00142
00143
00144 DECLARE_MESSAGE_MAP()
00145 };
00146
00147 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
00148 {
00149
00150 CString str;
00151 str += "Copyright (C) 2008:"; str += "\r\n";
00152 str += "- University College Dublin"; str += "\r\n";
00153 str += "- Laboratoire Central des Ponts et Chausées"; str += "\r\n";
00154 str += "- Dublin Institute of Technology"; str += "\r\n";
00155 str += "\r\n";
00156 str += "Written by:"; str += "\r\n";
00157 str += "Dr Colin Caprani (colin.caprani@ucd.ie)"; str += "\r\n";
00158 str += "Cillian Murphy"; str += "\r\n";
00159 str += "\r\n";
00160 str += "Supervised by:"; str += "\r\n";
00161 str += "Prof. Eugene OBrien (eugene.obrien@ucd.ie)";
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175 m_EditBox = str;
00176
00177 }
00178
00179 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
00180 {
00181 CDialog::DoDataExchange(pDX);
00182
00183 DDX_Text(pDX, IDC_EDIT1, m_EditBox);
00184
00185 }
00186
00187 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
00188
00189
00190
00191 END_MESSAGE_MAP()
00192
00193
00194 void CEvolveTrafficApp::OnAppAbout()
00195 {
00196 CAboutDlg aboutDlg;
00197 aboutDlg.DoModal();
00198 }
00199
00201
00202
00203
00204 BOOL CEvolveTrafficApp::OnIdle(LONG lCount)
00205 {
00206
00207
00208
00209
00210 CWinApp::OnIdle(lCount);
00211 if (lCount < 2)
00212 return TRUE;
00213
00214 CEvolveTrafficView* pView = (CEvolveTrafficView*)((CFrameWnd*)AfxGetMainWnd())->GetActiveView();
00215 ASSERT_VALID(pView);
00216
00217 if(m_bInSimulation)
00218 pView->doLoop( timeGetTime() );
00219
00220 return true;
00221 }
00222
00223
00225
00226
00227 void CEvolveTrafficApp::setInSimulation(bool InSim)
00228 {
00229 m_bInSimulation = InSim;
00230 }