CSimConfigDlg Class Reference

A class for the Simulation Configurations Dialog. More...

#include <SimConfigDlg.h>

List of all members.

Public Types

enum  { IDD = IDD_SIMCONFIG }

Public Member Functions

 CSimConfigDlg (CWnd *pParent=NULL)
virtual void OnValidate (UINT &nID, CString &strMessage)

Public Attributes

CString m_FileIn
CString m_FileOut
CString m_MetricsDir
int m_RoadLength
int m_NoLanesDirPos
int m_NoLanesDirNeg
int m_FileType
int m_SimTimeStep
int m_TrafFileNoLanesDirPos
int m_TrafFileNoLanesDirNeg
bool m_DriveOnRight
int m_LocOutputDetectorDirPos
int m_LocOutputDetectorDirNeg
BOOL m_AllowLaneChanging
int m_intDriveSide

Protected Member Functions

virtual void DoDataExchange (CDataExchange *pDX)
BOOL OnInitDialog ()
afx_msg void OnBtnFileInPick ()
afx_msg void OnBtnFileOutPick ()
afx_msg void OnRadCastor ()
afx_msg void OnRadSaft ()
afx_msg void OnSelchangeCmbDriveside ()
afx_msg void OnBtnMetricsout ()


Detailed Description

A class for the Simulation Configurations Dialog.

Definition at line 18 of file SimConfigDlg.h.


Member Enumeration Documentation

anonymous enum

Enumerator:
IDD 

Definition at line 26 of file SimConfigDlg.h.

00026 { IDD = IDD_SIMCONFIG };


Constructor & Destructor Documentation

CSimConfigDlg::CSimConfigDlg ( CWnd *  pParent = NULL  ) 

Definition at line 18 of file SimConfigDlg.cpp.

References CASTOR, m_AllowLaneChanging, m_DriveOnRight, m_FileIn, m_FileOut, m_FileType, m_intDriveSide, m_LocOutputDetectorDirNeg, m_LocOutputDetectorDirPos, m_MetricsDir, m_NoLanesDirNeg, m_NoLanesDirPos, m_RoadLength, m_SimTimeStep, m_TrafFileNoLanesDirNeg, and m_TrafFileNoLanesDirPos.

00019         : CDialogExt(CSimConfigDlg::IDD, pParent)
00020 {
00021         //{{AFX_DATA_INIT(CSimConfigDlg)
00022         m_FileIn = _T("");
00023         m_RoadLength = 5000;
00024         m_NoLanesDirPos = 1;
00025         m_NoLanesDirNeg = 1;
00026         m_FileType = CASTOR;
00027         m_SimTimeStep = 100;
00028         m_TrafFileNoLanesDirPos = -1;
00029         m_TrafFileNoLanesDirNeg = -1;
00030         m_FileOut = _T("");
00031         m_DriveOnRight = true;
00032         m_LocOutputDetectorDirPos = 0;
00033         m_LocOutputDetectorDirNeg = 0;
00034         m_AllowLaneChanging = true;
00035         m_intDriveSide = -1;
00036         m_MetricsDir = _T("");
00037         //}}AFX_DATA_INIT
00038 }


Member Function Documentation

void CSimConfigDlg::OnValidate ( UINT &  nID,
CString &  strMessage 
) [virtual]

Definition at line 78 of file SimConfigDlg.cpp.

References IDC_CMB_LANESDIRNEG, IDC_CMB_LANESDIRPOS, IDC_CMB_TRAFFILE_LANESDIR1, IDC_CMB_TRAFFILE_LANESDIR2, IDC_EDT_DIRNEGDETECTOR, IDC_EDT_DIRPOSDETECTOR, IDC_EDT_FILE_IN, IDC_EDT_FILE_OUT, m_LocOutputDetectorDirNeg, m_LocOutputDetectorDirPos, m_NoLanesDirNeg, m_NoLanesDirPos, m_RoadLength, m_TrafFileNoLanesDirNeg, and m_TrafFileNoLanesDirPos.

00079 {
00080         UpdateData();
00081 
00082         CString strFileIn, strFileOut, strNoLanesDirPos, strNoLanesDirNeg;
00083         CString strSimTimeStep, strTrafFileNoLanesDirPos, strTrafFileNoLanesDirNeg;
00084         CString strDriveSide, strLocOutputDetectorDirPos, strLocOutputDetectorDirNeg;
00085 
00086         GetDlgItemText(IDC_EDT_FILE_IN, strFileIn);
00087         GetDlgItemText(IDC_EDT_FILE_OUT, strFileOut);
00088         GetDlgItemText(IDC_CMB_LANESDIRPOS, strNoLanesDirPos);
00089         GetDlgItemText(IDC_CMB_LANESDIRNEG, strNoLanesDirNeg);
00090         GetDlgItemText(IDC_CMB_TRAFFILE_LANESDIR1, strTrafFileNoLanesDirPos);
00091         GetDlgItemText(IDC_CMB_TRAFFILE_LANESDIR2, strTrafFileNoLanesDirNeg);
00092 
00093         if(strFileIn.IsEmpty())
00094         {
00095                 strMessage = "Please select a file.";
00096                 nID = IDC_EDT_FILE_IN;
00097                 return;
00098         }
00099 
00100         if(strFileOut.IsEmpty())
00101         {
00102                 strMessage = "Please specify a filename.";
00103                 nID = IDC_EDT_FILE_OUT;
00104                 return;
00105         }
00106 
00107         if(strNoLanesDirPos.IsEmpty())
00108         {
00109                 strMessage = "Please specify the number of lanes.";
00110                 nID = IDC_CMB_LANESDIRPOS;
00111                 return;
00112         }
00113 
00114         if(strNoLanesDirNeg.IsEmpty())
00115         {
00116                 strMessage = "Please specify the number of lanes.";
00117                 nID = IDC_CMB_LANESDIRNEG;
00118                 return;
00119         }
00120 
00121         if(strTrafFileNoLanesDirPos.IsEmpty())
00122         {
00123                 strMessage = "Please specify the number of lanes.";
00124                 nID = IDC_CMB_TRAFFILE_LANESDIR1;
00125                 return;
00126         }
00127 
00128         if(strTrafFileNoLanesDirNeg.IsEmpty())
00129         {
00130                 strMessage = "Please specify the number of lanes.";
00131                 nID = IDC_CMB_TRAFFILE_LANESDIR2;
00132                 return;
00133         }
00134 
00135         if(m_TrafFileNoLanesDirPos == 0 && m_TrafFileNoLanesDirNeg == 0)
00136         {
00137                 strMessage = "There cannot be zero lanes in both directions";
00138                 nID = IDC_CMB_TRAFFILE_LANESDIR1;
00139                 return;
00140         }
00141 
00142         if(m_TrafFileNoLanesDirPos > m_NoLanesDirPos)
00143         {
00144                 strMessage = "The number of simulation lanes must not \nbe less than that of the traffic file.";
00145                 nID = IDC_CMB_LANESDIRPOS;
00146                 return;
00147         }
00148 
00149         if(m_TrafFileNoLanesDirNeg > m_NoLanesDirNeg)
00150         {
00151                 strMessage = "The number of simulation lanes must not \nbe less than that of the traffic file.";
00152                 nID = IDC_CMB_LANESDIRNEG;
00153                 return;
00154         }
00155 
00156         if(m_LocOutputDetectorDirPos > m_RoadLength)    // don't need to check < 0 since only positive nos allowed in edit ctrl
00157         {
00158                 strMessage = "The output dector must be located on the road \n- please check the road length";
00159                 nID = IDC_EDT_DIRPOSDETECTOR;
00160                 return;
00161         }
00162 
00163         if(m_LocOutputDetectorDirNeg > m_RoadLength)
00164         {
00165                 strMessage = "The output dector must be located on the road \n- please check the road length";
00166                 nID = IDC_EDT_DIRNEGDETECTOR;
00167                 return;
00168         }
00169 
00170         if(m_TrafFileNoLanesDirPos == 0 && m_NoLanesDirPos > 0)
00171         {
00172                 strMessage = "For this direction, there will be no vehicles \nsince there are no lanes in the traffic file";
00173                 nID = IDC_CMB_LANESDIRPOS;
00174                 return;
00175         }
00176 
00177         if(m_TrafFileNoLanesDirNeg == 0 && m_NoLanesDirNeg > 0)
00178         {
00179                 strMessage = "For this direction, there will be no vehicles \nsince there are no lanes in the traffic file";
00180                 nID = IDC_CMB_LANESDIRNEG;
00181                 return;
00182         }
00183 }

void CSimConfigDlg::DoDataExchange ( CDataExchange *  pDX  )  [protected, virtual]

Definition at line 41 of file SimConfigDlg.cpp.

References IDC_CHECK_LANECHNG, IDC_CMB_DRIVESIDE, IDC_CMB_LANESDIRNEG, IDC_CMB_LANESDIRPOS, IDC_CMB_TRAFFILE_LANESDIR1, IDC_CMB_TRAFFILE_LANESDIR2, IDC_EDT_DIRNEGDETECTOR, IDC_EDT_DIRPOSDETECTOR, IDC_EDT_FILE_IN, IDC_EDT_FILE_OUT, IDC_EDT_METRICSOUT, IDC_EDT_ROADLENGTH, IDC_EDT_SIMTIMESTEP, m_AllowLaneChanging, m_FileIn, m_FileOut, m_intDriveSide, m_LocOutputDetectorDirNeg, m_LocOutputDetectorDirPos, m_MetricsDir, m_NoLanesDirNeg, m_NoLanesDirPos, m_RoadLength, m_SimTimeStep, m_TrafFileNoLanesDirNeg, and m_TrafFileNoLanesDirPos.

00042 {
00043         CDialogExt::DoDataExchange(pDX);
00044         //{{AFX_DATA_MAP(CSimConfigDlg)
00045         DDX_Text(pDX, IDC_EDT_FILE_IN, m_FileIn);
00046         DDX_Text(pDX, IDC_EDT_ROADLENGTH, m_RoadLength);
00047         DDV_MinMaxInt(pDX, m_RoadLength, 500, 100000);
00048         DDX_CBIndex(pDX, IDC_CMB_LANESDIRPOS, m_NoLanesDirPos);
00049         DDX_CBIndex(pDX, IDC_CMB_LANESDIRNEG, m_NoLanesDirNeg);
00050         DDX_Text(pDX, IDC_EDT_SIMTIMESTEP, m_SimTimeStep);
00051         DDV_MinMaxInt(pDX, m_SimTimeStep, 10, 2000);
00052         DDX_CBIndex(pDX, IDC_CMB_TRAFFILE_LANESDIR1, m_TrafFileNoLanesDirPos);
00053         DDX_CBIndex(pDX, IDC_CMB_TRAFFILE_LANESDIR2, m_TrafFileNoLanesDirNeg);
00054         DDX_Text(pDX, IDC_EDT_FILE_OUT, m_FileOut);
00055         DDX_Text(pDX, IDC_EDT_DIRPOSDETECTOR, m_LocOutputDetectorDirPos);
00056         DDX_Text(pDX, IDC_EDT_DIRNEGDETECTOR, m_LocOutputDetectorDirNeg);
00057         DDX_Check(pDX, IDC_CHECK_LANECHNG, m_AllowLaneChanging);
00058         DDX_CBIndex(pDX, IDC_CMB_DRIVESIDE, m_intDriveSide);
00059         DDX_Text(pDX, IDC_EDT_METRICSOUT, m_MetricsDir);
00060         //}}AFX_DATA_MAP
00061 }

BOOL CSimConfigDlg::OnInitDialog (  )  [protected]

Definition at line 185 of file SimConfigDlg.cpp.

References CASTOR, IDC_CMB_DRIVESIDE, IDC_RAD_CASTOR, IDC_RAD_SAFT, m_DriveOnRight, m_FileType, m_intDriveSide, and SAFT.

00186 {
00187         CDialogExt::OnInitDialog();
00188 
00189         switch (m_FileType)
00190         {
00191                 case SAFT:
00192                         CheckDlgButton(IDC_RAD_SAFT,1);
00193                         break;
00194                 case CASTOR:
00195                         CheckDlgButton(IDC_RAD_CASTOR,1);
00196                         break;
00197                 default:
00198                         CheckDlgButton(IDC_RAD_CASTOR,1);
00199         }
00200         
00201         m_intDriveSide = 1;     // default to "Right"
00202         if(!m_DriveOnRight)
00203                 m_intDriveSide = 0;     // but "Left" if needs be
00204         CComboBox * pCmb = (CComboBox*)GetDlgItem(IDC_CMB_DRIVESIDE);
00205         pCmb->SetCurSel(m_intDriveSide);
00206 
00207         return TRUE;
00208 }

void CSimConfigDlg::OnBtnFileInPick (  )  [protected]

Definition at line 210 of file SimConfigDlg.cpp.

References m_FileIn.

00211 {
00212         // szFilters is a text string that includes two file name filters:
00213         // "*.my" for "MyType Files" and "*.*' for "All Files."
00214         //char CChildFrame::szFilters[] = ;
00215 
00216         CFileDialog FileDlg(
00217                 TRUE,   // TRUE if File Open, FALSE if File Save As
00218                 NULL,   // the default file extension
00219                 NULL,   // the initial filename that appears
00220                 OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY,//flags for customizing the appearance
00221                 "All Files (*.*)|*.*||",        // file filters
00222                 this); // pointer to FileCialog's parent object
00223         
00224    if(FileDlg.DoModal() == IDOK)
00225    {
00226       m_FileIn = FileDlg.GetPathName();
00227           UpdateData(FALSE); // The FALSE switches the direction of the DDX
00228    }
00229 }

void CSimConfigDlg::OnBtnFileOutPick (  )  [protected]

Definition at line 231 of file SimConfigDlg.cpp.

References m_FileOut.

00232 {
00233         CFileDialog FileDlg(
00234                 FALSE,                  // TRUE if File Open, FALSE if File Save As
00235                 _T("*.txt"),    // the default file extension
00236                 NULL,                   // the initial filename that appears
00237                 OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,//flags for customizing the appearance
00238                 "text files (*.txt) |*.txt|All Files (*.*)|*.*||",      // file filters
00239                 this); // pointer to FileCialog's parent object
00240         
00241    if(FileDlg.DoModal() == IDOK)
00242    {
00243       m_FileOut = FileDlg.GetPathName();
00244           UpdateData(FALSE); // The FALSE switches the direction of the DDX
00245    }
00246 }

void CSimConfigDlg::OnRadCastor (  )  [protected]

Definition at line 277 of file SimConfigDlg.cpp.

References CASTOR, and m_FileType.

00278 {
00279         m_FileType = CASTOR;
00280 }

void CSimConfigDlg::OnRadSaft (  )  [protected]

Definition at line 282 of file SimConfigDlg.cpp.

References m_FileType, and SAFT.

00283 {
00284         m_FileType = SAFT;
00285 }

void CSimConfigDlg::OnSelchangeCmbDriveside (  )  [protected]

Definition at line 287 of file SimConfigDlg.cpp.

References IDC_CMB_DRIVESIDE, and m_DriveOnRight.

00288 {
00289         CString str;
00290         GetDlgItemText(IDC_CMB_DRIVESIDE, str);
00291         
00292         if(str == "Left")
00293                 m_DriveOnRight = false;
00294         else
00295                 m_DriveOnRight = true;  
00296 }

void CSimConfigDlg::OnBtnMetricsout (  )  [protected]

Definition at line 248 of file SimConfigDlg.cpp.

References m_MetricsDir.

00249 {
00250     BROWSEINFO bi = { 0 };
00251     bi.lpszTitle = _T("Pick a Directory");
00252     LPITEMIDLIST pidl = SHBrowseForFolder ( &bi );
00253     if ( pidl != 0 )
00254     {
00255         // get the name of the folder
00256         TCHAR path[MAX_PATH];
00257         if ( SHGetPathFromIDList ( pidl, path ) )
00258         {
00259             //TRACE("Selected Folder: %s\n", path );
00260                         m_MetricsDir = path;
00261                         m_MetricsDir += "\\";
00262                         UpdateData(FALSE);
00263         }
00264                 else
00265                         MessageBox("Error in selecting folder - please type the name","EvolveTraffic",MB_OK | MB_ICONWARNING);
00266 
00267         // free memory used
00268         IMalloc * imalloc = 0;
00269         if ( SUCCEEDED( SHGetMalloc ( &imalloc )) )
00270         {
00271             imalloc->Free ( pidl );
00272             imalloc->Release ( );
00273         }
00274     }
00275 }


Member Data Documentation

Definition at line 34 of file SimConfigDlg.h.

Referenced by CSimConfigDlg(), DoDataExchange(), and CEvolveTrafficView::OnConfigSim().

Definition at line 40 of file SimConfigDlg.h.

Referenced by CSimConfigDlg(), DoDataExchange(), and CEvolveTrafficView::OnConfigSim().

Definition at line 41 of file SimConfigDlg.h.

Referenced by CSimConfigDlg(), DoDataExchange(), and OnInitDialog().


The documentation for this class was generated from the following files:

Generated on Wed Aug 20 00:48:46 2008 for EvolveTraffic by  doxygen 1.5.6