CPreferencesDlg Class Reference

A class for the User Preferences Dialog. More...

#include <PreferencesDlg.h>

List of all members.

Public Types

enum  { IDD = IDD_PREFERENCES }

Public Member Functions

 CPreferencesDlg (CWnd *pParent=NULL)

Public Attributes

double m_Scale
double m_ExaggerateWidths
double m_TimeWarp
double m_LaneWidth
double m_VehicleWidth
double m_VehicleLengthScale
double m_ShowVelocity
double m_ShowLegend
double m_TickLength
double m_TickStep
double m_Border_Top
double m_Border_Btm
double m_Border_Lhs
double m_Border_Rhs
CGridCtrl m_Grid

Protected Member Functions

virtual void DoDataExchange (CDataExchange *pDX)
virtual void OnOK ()

Private Member Functions

BOOL OnInitDialog ()
void SetGridHeadings ()
void SetCells ()
void LoadSettingsIntoGrid ()
void OnGridEndEdit (NMHDR *pNotifyStruct, LRESULT *pResult)
double * MapRowToValue (int row)

Private Attributes

int m_nFixCols
int m_nFixRows
CStringArray m_sRowHeads
CStringArray m_sColHeads
int m_nCols
int m_nRows
double MIN_VIEW_SCALE


Detailed Description

A class for the User Preferences Dialog.

Definition at line 17 of file PreferencesDlg.h.


Member Enumeration Documentation

anonymous enum

Enumerator:
IDD 

Definition at line 25 of file PreferencesDlg.h.

00025 { IDD = IDD_PREFERENCES };


Constructor & Destructor Documentation

CPreferencesDlg::CPreferencesDlg ( CWnd *  pParent = NULL  ) 

Definition at line 23 of file PreferencesDlg.cpp.

References FIXED_COLUMNS, FIXED_ROWS, m_nCols, m_nFixCols, m_nFixRows, m_nRows, m_sColHeads, m_sRowHeads, CConfigData::View_Config::MIN_VIEW_SCALE, MIN_VIEW_SCALE, and CConfigData::View.

00024         : CDialog(CPreferencesDlg::IDD, pParent)
00025 {
00026         MIN_VIEW_SCALE = g_ConfigData.View.MIN_VIEW_SCALE;
00027 
00028         m_sRowHeads.Add("Overall scale (meters/pixel)");
00029         m_sRowHeads.Add("Widths Scale");
00030         m_sRowHeads.Add("Time warp factor");
00031         m_sRowHeads.Add("Lane width (m)");
00032         m_sRowHeads.Add("Vehicle width (m)");
00033         m_sRowHeads.Add("Vehicle Length Scale");
00034         m_sRowHeads.Add("Show Velocities");
00035         m_sRowHeads.Add("Show Legend");
00036         m_sRowHeads.Add("Tick Length (m)");
00037         m_sRowHeads.Add("Tick Interval (m)");
00038         m_sRowHeads.Add("Border Top (m)");
00039         m_sRowHeads.Add("Border Bottom (m)");
00040         m_sRowHeads.Add("Border Left (m)");
00041         m_sRowHeads.Add("Border Right (m)");
00042 
00043         m_sColHeads.Add("Setting");
00044         m_sColHeads.Add("Value");
00045         
00046         m_nFixRows = FIXED_ROWS;        // MAGIC NUMBER - row and column headers
00047         m_nFixCols = FIXED_COLUMNS;
00048         
00049         m_nCols = 1 + m_nFixCols;       // MAGIC NUMBER - obviously 1 extra column
00050         m_nRows = m_sRowHeads.GetSize() + m_nFixRows;
00051 
00052         //{{AFX_DATA_INIT(CPreferencesDlg)
00053                 // NOTE: the ClassWizard will add member initialization here
00054         //}}AFX_DATA_INIT
00055 }


Member Function Documentation

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

Definition at line 58 of file PreferencesDlg.cpp.

References IDC_GRID, and m_Grid.

00059 {
00060         CDialog::DoDataExchange(pDX);
00061         //{{AFX_DATA_MAP(CPreferencesDlg)
00062         DDX_Control(pDX, IDC_GRID, m_Grid);             // associate the grid window with a C++ object
00063         //}}AFX_DATA_MAP
00064 }

void CPreferencesDlg::OnOK (  )  [protected, virtual]

Definition at line 77 of file PreferencesDlg.cpp.

References m_ExaggerateWidths, m_LaneWidth, m_Scale, m_TimeWarp, m_VehicleWidth, and MIN_VIEW_SCALE.

00078 {
00079         CDialog::OnOK();
00080         if(m_Scale < MIN_VIEW_SCALE)
00081         {
00082                 MessageBox("View scale cannot be less than minimum - default minimum set", "EvolveTraffic", MB_OK | MB_ICONWARNING);
00083                 m_Scale = MIN_VIEW_SCALE;
00084         }
00085         if(m_ExaggerateWidths < 1.0)
00086         {
00087                 MessageBox("Widths scale cannot be less than 1.0 - default set", "EvolveTraffic", MB_OK | MB_ICONWARNING);
00088                 m_ExaggerateWidths = 1.0;
00089         }
00090         if(m_TimeWarp < 1.0)
00091         {
00092                 MessageBox("Widths scale cannot be less than 1.0 - default set", "EvolveTraffic", MB_OK | MB_ICONWARNING);
00093                 m_ExaggerateWidths = 1.0;
00094         }
00095         if(m_VehicleWidth > m_LaneWidth)
00096         {
00097                 MessageBox("Vehicle width should be less than lane width - default of 80% of lane width set", "EvolveTraffic",  MB_OK | MB_ICONWARNING);
00098                 m_VehicleWidth = 0.8 * m_LaneWidth;     // MAGIC NUMBER - no harm having a magic number here
00099         }
00100 }

BOOL CPreferencesDlg::OnInitDialog (  )  [private]

Definition at line 102 of file PreferencesDlg.cpp.

References LoadSettingsIntoGrid(), m_Grid, m_nCols, m_nFixCols, m_nFixRows, m_nRows, SetCells(), and SetGridHeadings().

00103 {
00104         CDialog::OnInitDialog();
00105 
00106         TRY {
00107                 m_Grid.SetRowCount(m_nRows);
00108                 m_Grid.SetColumnCount(m_nCols);
00109                 m_Grid.SetFixedRowCount(m_nFixRows);
00110                 m_Grid.SetFixedColumnCount(m_nFixCols);
00111         }
00112         CATCH (CMemoryException, e)
00113         {
00114                 e->ReportError();
00115                 return FALSE;
00116         }
00117         END_CATCH
00118         
00119         SetGridHeadings();
00120         SetCells();
00121         m_Grid.ExpandToFit();   
00122         
00123         LoadSettingsIntoGrid();
00124 
00125         return TRUE;  // return TRUE  unless you set the focus to a control
00126 }

Here is the call graph for this function:

void CPreferencesDlg::SetGridHeadings (  )  [private]

Definition at line 128 of file PreferencesDlg.cpp.

References m_Grid, m_nFixCols, m_sColHeads, and m_sRowHeads.

Referenced by OnInitDialog().

00129 {
00130         int row = 0;
00131         int col = 0;
00132 
00133         // Set fixed column text
00134         m_Grid.SetItemText(row,m_nFixCols-1,m_sColHeads.GetAt(0));
00135         m_Grid.SetItemText(row,m_nFixCols,m_sColHeads.GetAt(1));
00136 
00137         // Set fixed row text
00138         col = 0;
00139         for (row = 1; row < m_Grid.GetRowCount(); row++)
00140                 m_Grid.SetItemText(row,col,m_sRowHeads.GetAt(row-1));
00141 }

void CPreferencesDlg::SetCells (  )  [private]

Definition at line 143 of file PreferencesDlg.cpp.

References m_Grid, and m_nRows.

Referenced by OnInitDialog().

00144 {
00145         for (int row = 1; row < m_nRows; row++)
00146         {
00147                 int col = 1;
00148                 m_Grid.SetCellType(row,col, RUNTIME_CLASS(CGridCellNumeric));
00149                 m_Grid.GetCell(row,col)->SetFormat(DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_NOPREFIX|DT_END_ELLIPSIS);
00150                 CGridCellNumeric *pCell = (CGridCellNumeric*)m_Grid.GetCell(row,col);
00151                 pCell->SetFlags(CGridCellNumeric::Real);        // no negative numbers
00152         }
00153 }

void CPreferencesDlg::LoadSettingsIntoGrid (  )  [private]

Definition at line 155 of file PreferencesDlg.cpp.

References m_Grid, m_nRows, and MapRowToValue().

Referenced by OnInitDialog().

00156 {
00157         int col = 1;
00158         for (int row = 1; row < m_nRows; row++)
00159         {
00160                 CGridCellNumeric* pCell = (CGridCellNumeric *)(m_Grid.GetCell(row,col));
00161                 pCell->SetNumber( *(MapRowToValue(row)) );
00162         }
00163 }

Here is the call graph for this function:

void CPreferencesDlg::OnGridEndEdit ( NMHDR *  pNotifyStruct,
LRESULT *  pResult 
) [private]

Definition at line 165 of file PreferencesDlg.cpp.

References m_Grid, and MapRowToValue().

00166 {
00167         // if change is ok, then *pResult 0, else *pResult -1
00168         
00169         // pItem is the cell that has just been edited
00170     NM_GRIDVIEW* pItem = (NM_GRIDVIEW*) pNotifyStruct;
00171     
00172     int row = pItem->iRow;
00173         int col = pItem->iColumn;
00174 
00175         double val = ((CGridCellNumeric *)(m_Grid.GetCell(row,col)))->GetNumber();
00176         *(MapRowToValue(row)) = val;
00177 
00178         *pResult = 0;
00179 }

Here is the call graph for this function:

double * CPreferencesDlg::MapRowToValue ( int  row  )  [private]

Definition at line 181 of file PreferencesDlg.cpp.

References m_Border_Btm, m_Border_Lhs, m_Border_Rhs, m_Border_Top, m_ExaggerateWidths, m_LaneWidth, m_nFixRows, m_Scale, m_ShowLegend, m_ShowVelocity, m_TickLength, m_TickStep, m_TimeWarp, m_VehicleLengthScale, and m_VehicleWidth.

Referenced by LoadSettingsIntoGrid(), and OnGridEndEdit().

00182 {
00183         // This functions assumes the variable order as per m_sRowHeads
00184 
00185         row = row - m_nFixRows; // keeps independence of m_nFixRows
00186         switch(row)
00187         {
00188                 case 0:
00189                         return &m_Scale;
00190                 case 1:
00191                         return &m_ExaggerateWidths;
00192                 case 2:
00193                         return &m_TimeWarp;
00194                 case 3:
00195                         return &m_LaneWidth;
00196                 case 4:
00197                         return &m_VehicleWidth;
00198                 case 5:
00199                         return &m_VehicleLengthScale;
00200                 case 6:
00201                         return &m_ShowVelocity;
00202                 case 7:
00203                         return &m_ShowLegend;
00204                 case 8:
00205                         return &m_TickLength;
00206                 case 9:
00207                         return &m_TickStep;
00208                 case 10:
00209                         return &m_Border_Top;
00210                 case 11:
00211                         return &m_Border_Btm;
00212                 case 12:
00213                         return &m_Border_Lhs;
00214                 case 13:
00215                         return &m_Border_Rhs;
00216                 default:
00217                         return &m_Border_Top;
00218         }
00219 }


Member Data Documentation

Definition at line 26 of file PreferencesDlg.h.

Referenced by MapRowToValue(), OnOK(), and CEvolveTrafficView::OnToolsPrefs().

Definition at line 27 of file PreferencesDlg.h.

Referenced by MapRowToValue(), OnOK(), and CEvolveTrafficView::OnToolsPrefs().

Definition at line 28 of file PreferencesDlg.h.

Referenced by MapRowToValue(), OnOK(), and CEvolveTrafficView::OnToolsPrefs().

Definition at line 29 of file PreferencesDlg.h.

Referenced by MapRowToValue(), OnOK(), and CEvolveTrafficView::OnToolsPrefs().

Definition at line 30 of file PreferencesDlg.h.

Referenced by MapRowToValue(), OnOK(), and CEvolveTrafficView::OnToolsPrefs().

Definition at line 31 of file PreferencesDlg.h.

Referenced by MapRowToValue(), and CEvolveTrafficView::OnToolsPrefs().

Definition at line 32 of file PreferencesDlg.h.

Referenced by MapRowToValue(), and CEvolveTrafficView::OnToolsPrefs().

Definition at line 33 of file PreferencesDlg.h.

Referenced by MapRowToValue(), and CEvolveTrafficView::OnToolsPrefs().

Definition at line 34 of file PreferencesDlg.h.

Referenced by MapRowToValue(), and CEvolveTrafficView::OnToolsPrefs().

Definition at line 35 of file PreferencesDlg.h.

Referenced by MapRowToValue(), and CEvolveTrafficView::OnToolsPrefs().

Definition at line 36 of file PreferencesDlg.h.

Referenced by MapRowToValue(), and CEvolveTrafficView::OnToolsPrefs().

Definition at line 37 of file PreferencesDlg.h.

Referenced by MapRowToValue(), and CEvolveTrafficView::OnToolsPrefs().

Definition at line 38 of file PreferencesDlg.h.

Referenced by MapRowToValue(), and CEvolveTrafficView::OnToolsPrefs().

Definition at line 39 of file PreferencesDlg.h.

Referenced by MapRowToValue(), and CEvolveTrafficView::OnToolsPrefs().

Definition at line 59 of file PreferencesDlg.h.

Referenced by CPreferencesDlg(), OnInitDialog(), and SetGridHeadings().

Definition at line 60 of file PreferencesDlg.h.

Referenced by CPreferencesDlg(), MapRowToValue(), and OnInitDialog().

CStringArray CPreferencesDlg::m_sRowHeads [private]

Definition at line 61 of file PreferencesDlg.h.

Referenced by CPreferencesDlg(), and SetGridHeadings().

CStringArray CPreferencesDlg::m_sColHeads [private]

Definition at line 62 of file PreferencesDlg.h.

Referenced by CPreferencesDlg(), and SetGridHeadings().

int CPreferencesDlg::m_nCols [private]

Definition at line 63 of file PreferencesDlg.h.

Referenced by CPreferencesDlg(), and OnInitDialog().

int CPreferencesDlg::m_nRows [private]

Definition at line 64 of file PreferencesDlg.h.

Referenced by CPreferencesDlg(), LoadSettingsIntoGrid(), OnInitDialog(), and SetCells().

Definition at line 73 of file PreferencesDlg.h.

Referenced by CPreferencesDlg(), and OnOK().


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