CEvolveTrafficView Class Reference

A class for user interaction and drawing functions. More...

#include <EvolveTrafficView.h>

Collaboration diagram for CEvolveTrafficView:

Collaboration graph
[legend]

List of all members.

Public Member Functions

CEvolveTrafficDocGetDocument ()
virtual void OnDraw (CDC *pDC)
virtual BOOL PreCreateWindow (CREATESTRUCT &cs)
virtual void OnPrepareDC (CDC *pDC, CPrintInfo *pInfo=NULL)
void UpdateProgressBar ()
void doLoop (int curTime)
void setMaxTimeWarp ()
virtual ~CEvolveTrafficView ()

Protected Member Functions

 CEvolveTrafficView ()
virtual void OnInitialUpdate ()
virtual BOOL OnPreparePrinting (CPrintInfo *pInfo)
virtual void OnBeginPrinting (CDC *pDC, CPrintInfo *pInfo)
virtual void OnEndPrinting (CDC *pDC, CPrintInfo *pInfo)
afx_msg void OnConfigSim ()
afx_msg void OnRunVisible ()
afx_msg void OnSize (UINT nType, int cx, int cy)
afx_msg void OnConfigTraf ()
afx_msg void OnToolsPrefs ()
afx_msg void OnToolsPause ()
afx_msg void OnToolsZoomin ()
afx_msg void OnToolsZoomout ()
afx_msg void OnToolsSpeedup ()
afx_msg void OnToolsSlowdown ()
afx_msg void OnKeyDown (UINT nChar, UINT nRepCnt, UINT nFlags)
afx_msg void OnRunInvisible ()
afx_msg void OnConfigFeatures ()
afx_msg void OnConfigMetrics ()
afx_msg void OnUpdateToolsPause (CCmdUI *pCmdUI)
afx_msg void OnUpdateToolsSpeedup (CCmdUI *pCmdUI)
afx_msg void OnUpdateToolsSlowdown (CCmdUI *pCmdUI)
afx_msg void OnToolsStop ()
afx_msg void OnUpdateToolsStop (CCmdUI *pCmdUI)
afx_msg void OnLButtonDown (UINT nFlags, CPoint point)
afx_msg void OnFileSaveImage ()

Private Member Functions

VehicleFindVehicle (int iLane, int location)
BOOL WriteWindowToDIB (LPTSTR szFile, CWnd *pWnd)
void SetZoomScale (double newScale)
void ValidateTimeWarp ()
void doSimStart ()
int Round (double val)
void doSimFinished (bool bCompleted)
void UpdateDrawRegion ()
void SettingUpdateRedraw ()
void initRoad ()
void DrawRoad (CMemDC *pDC)
void DrawRuler (CMemDC *pDC)
void DrawTimer (CMemDC *pDC)
void DrawVehicle (CMemDC *pDC, Vehicle *veh)
void DrawVehicleAt (CMemDC *pDC, WORD VEH_ID, CRect VehRect)
void DrawDetectors (CMemDC *pDC)
void DrawLaneChangeDetectors (CMemDC *pDC, bool DirPos)
void DrawLegend (CMemDC *pDC)
void DrawLegendElement (CMemDC *pDC, int LineLength, int LineToText, int xpos, int ypos, CString str, COLORREF COL)
void DrawSingleSegment (CMemDC *pDC, COLORREF COL, WORD HATCH, WORD FeatType, int val, CRect rect, int yTextOffset)
void DrawRoadSegments (CMemDC *pDC)
void DrawSingleDetector (CMemDC *pDC, COLORREF COL, int Loc, bool DirPos)
void DrawLegendSegment (CMemDC *pDC, COLORREF COL, WORD HATCH, WORD FeatType, CString str, int value, int LineToText, int xpos, int ypos)
void DrawLegendVehicle (CMemDC *pDC, WORD VehType, CString str, int LineToText, int xpos, int ypos)

Private Attributes

bool m_bShowLegend
bool m_bShowVelocity
int m_BtmEdge
int m_TopEdge
int m_nLanesOnBtm
int m_nLanesOnTop
bool m_DriveOnRight
double m_ExaggerateWidths
CSize m_DrawArea
int m_LastPercentComplete
double m_MaxTimeWarp
int m_SimTimeStep
int m_PauseTime
int m_StartRealTime
int m_CurentRealTime
double m_CurentSimTime
BOOL m_bPause
int m_TimerSpeed
int m_PercentComplete
CRect m_ClientRect
int m_YCoordTop
RECT m_RoadRect
bool m_bInSimulation
double m_Scale
double m_TimeWarp
double m_VehicleLengthScale
double m_VehicleWidth
double m_TickLength
int m_TickStep
double m_LaneWidth
double m_Border_Top
double m_Border_Btm
double m_Border_Lhs
double m_Border_Rhs
int m_NoDirections
int m_NoLanes
int m_NoLanesDirPos
int m_NoLanesDirNeg
int m_RoadLength
int m_NoTicks
int m_RoadWidth
M2D m_VehiclePositions
CEvolveTrafficDocm_pDoc
CProgressBar * m_pProgBar
CMessageTip m_DataTip
double MIN_VIEW_SCALE
double DATATIP_DELAY
COLORREF CLR_BACKGRND
COLORREF CLR_DET_COMPOSITION
COLORREF CLR_DET_FLOWDENSITY
COLORREF CLR_DET_HEADWAY
COLORREF CLR_DET_OUTPUT
COLORREF CLR_FEAT_GRADIENT
COLORREF CLR_FEAT_SPEEDLIMIT
COLORREF CLR_LEGEND_TEXT
COLORREF CLR_ROAD_LINES
COLORREF CLR_ROAD_SURFACE
COLORREF CLR_RULER_LINES
COLORREF CLR_RULER_TEXT
COLORREF VEH_COLOR_CAR
COLORREF VEH_COLOR_SMALLTRUCK
COLORREF VEH_COLOR_LARGETRUCK
COLORREF VEH_COLOR_CRANE
COLORREF VEH_COLOR_LOWLOADER


Detailed Description

A class for user interaction and drawing functions.

Definition at line 18 of file EvolveTrafficView.h.


Constructor & Destructor Documentation

CEvolveTrafficView::CEvolveTrafficView (  )  [protected]

Definition at line 67 of file EvolveTrafficView.cpp.

References CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_BACKGRND, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_DET_COMPOSITION, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_DET_FLOWDENSITY, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_DET_HEADWAY, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_DET_OUTPUT, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_FEAT_GRADIENT, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_FEAT_SPEEDLIMIT, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_LEGEND_TEXT, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_ROAD_LINES, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_ROAD_SURFACE, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_RULER_LINES, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_RULER_TEXT, CConfigData::View_Config::Colours, CConfigData::View_Config::DATATIP_DELAY, DRAW_FRAMES_PER_SEC, CConfigData::View_Config::View_Colours::DrawElements, CConfigData::View_Config::MIN_VIEW_SCALE, CConfigData::View_Config::View_Colours::Col_Vehicles::VEH_COLOR_CAR, CConfigData::View_Config::View_Colours::Col_Vehicles::VEH_COLOR_CRANE, CConfigData::View_Config::View_Colours::Col_Vehicles::VEH_COLOR_LARGETRUCK, CConfigData::View_Config::View_Colours::Col_Vehicles::VEH_COLOR_LOWLOADER, CConfigData::View_Config::View_Colours::Col_Vehicles::VEH_COLOR_SMALLTRUCK, CConfigData::View_Config::View_Colours::Vehicles, and CConfigData::View.

00068 {
00069         // Configuration Settings
00070         MIN_VIEW_SCALE          = g_ConfigData.View.MIN_VIEW_SCALE;
00071         DATATIP_DELAY           = g_ConfigData.View.DATATIP_DELAY;
00072 
00073         CLR_BACKGRND            = g_ConfigData.View.Colours.DrawElements.CLR_BACKGRND;
00074         CLR_DET_COMPOSITION = g_ConfigData.View.Colours.DrawElements.CLR_DET_COMPOSITION;
00075         CLR_DET_FLOWDENSITY = g_ConfigData.View.Colours.DrawElements.CLR_DET_FLOWDENSITY;
00076         CLR_DET_HEADWAY         = g_ConfigData.View.Colours.DrawElements.CLR_DET_HEADWAY;
00077         CLR_DET_OUTPUT          = g_ConfigData.View.Colours.DrawElements.CLR_DET_OUTPUT;
00078         CLR_FEAT_GRADIENT       = g_ConfigData.View.Colours.DrawElements.CLR_FEAT_GRADIENT;
00079         CLR_FEAT_SPEEDLIMIT     = g_ConfigData.View.Colours.DrawElements.CLR_FEAT_SPEEDLIMIT;
00080         CLR_LEGEND_TEXT         = g_ConfigData.View.Colours.DrawElements.CLR_LEGEND_TEXT;
00081         CLR_ROAD_LINES          = g_ConfigData.View.Colours.DrawElements.CLR_ROAD_LINES;
00082         CLR_ROAD_SURFACE        = g_ConfigData.View.Colours.DrawElements.CLR_ROAD_SURFACE;
00083         CLR_RULER_LINES         = g_ConfigData.View.Colours.DrawElements.CLR_RULER_LINES;
00084         CLR_RULER_TEXT          = g_ConfigData.View.Colours.DrawElements.CLR_RULER_TEXT;
00085 
00086         VEH_COLOR_CAR                   = g_ConfigData.View.Colours.Vehicles.VEH_COLOR_CAR;
00087         VEH_COLOR_SMALLTRUCK    = g_ConfigData.View.Colours.Vehicles.VEH_COLOR_SMALLTRUCK;
00088         VEH_COLOR_LARGETRUCK    = g_ConfigData.View.Colours.Vehicles.VEH_COLOR_LARGETRUCK;
00089         VEH_COLOR_CRANE                 = g_ConfigData.View.Colours.Vehicles.VEH_COLOR_CRANE;
00090         VEH_COLOR_LOWLOADER             = g_ConfigData.View.Colours.Vehicles.VEH_COLOR_LOWLOADER;
00091 
00092         // Initial view scale
00093         m_Scale = 1.0;
00094         m_ExaggerateWidths       = 10.0;
00095         
00096         m_Border_Top                    = 20;
00097         m_Border_Btm                    = 40;
00098         m_Border_Lhs                    = 20;
00099         m_Border_Rhs                    = 100;
00100         m_TickStep                              = 500;
00101         m_VehicleLengthScale    = 2.0;  // so they look ok - results in overlaps??
00102         m_bShowVelocity                 = true;
00103         m_bShowLegend                   = true;
00104         m_TickLength                    = 1.0 * m_ExaggerateWidths;
00105         m_LaneWidth                             = 4.0 * m_ExaggerateWidths;
00106         m_VehicleWidth                  = 3.0 * m_ExaggerateWidths;             // less than lane width! 
00107         
00108         m_bInSimulation = false;        // has a simulation begun
00109         m_bPause = false;                       // is the simulation to progress one step
00110         m_TimeWarp = 1;                         // multiplier of real time that the simulation runs
00111         // the timer speed is constant since the refresh rate is constant
00112         m_TimerSpeed = Round(1000/DRAW_FRAMES_PER_SEC); // in int ms
00113         m_CurentRealTime = 0;           // actual time since simulation started
00114         m_CurentSimTime = 0;            // sim time since sim started
00115         m_PauseTime = 0;                        // the time the sim was paused at
00116         m_MaxTimeWarp = 1000;           // a high number - will be reduced as sim progresses
00117 
00118         m_LastPercentComplete = 0;
00119         m_PercentComplete = 0;
00120 
00121         m_YCoordTop = 0;        // legacy - need to remove
00122 }

CEvolveTrafficView::~CEvolveTrafficView (  )  [virtual]

Definition at line 124 of file EvolveTrafficView.cpp.

00125 {
00126 
00127 }


Member Function Documentation

CEvolveTrafficDoc * CEvolveTrafficView::GetDocument (  )  [inline]

Definition at line 193 of file EvolveTrafficView.h.

Referenced by OnInitialUpdate().

00194    { return (CEvolveTrafficDoc*)m_pDocument; }

void CEvolveTrafficView::OnDraw ( CDC *  pDC  )  [virtual]

Definition at line 287 of file EvolveTrafficView.cpp.

References DrawLegend(), DrawRoad(), DrawRuler(), DrawTimer(), DrawVehicle(), m_bInSimulation, m_bShowLegend, and m_VehiclePositions.

00288 {
00289         CMemDC pDC(dc);
00290 
00291         DrawRoad(pDC);
00292         DrawRuler(pDC);
00293         
00294         if(m_bShowLegend)
00295                 DrawLegend(pDC);
00296         
00297         if(m_bInSimulation)             // we're in a simulation
00298         {
00299                 // draw the vehicles where they are
00300                 for (int i = 0; i < m_VehiclePositions.size(); i++)                     // Total number of lanes
00301                 {
00302                         for (int j = 0; j < m_VehiclePositions[i].size(); j++)  // No vehicles in each lane
00303                                         DrawVehicle(pDC, m_VehiclePositions[i][j]);
00304                 }
00305         }
00306 
00307         DrawTimer(pDC); // always draw & last so it's on top
00308 
00309 }

Here is the call graph for this function:

BOOL CEvolveTrafficView::PreCreateWindow ( CREATESTRUCT &  cs  )  [virtual]

Definition at line 129 of file EvolveTrafficView.cpp.

00130 {
00131         // TODO: Modify the Window class or styles here by modifying
00132         //  the CREATESTRUCT cs
00133 
00134         return CScrollView::PreCreateWindow(cs);
00135 }

void CEvolveTrafficView::OnPrepareDC ( CDC *  pDC,
CPrintInfo *  pInfo = NULL 
) [virtual]

Definition at line 159 of file EvolveTrafficView.cpp.

References m_Border_Lhs, m_ClientRect, m_DrawArea, and m_Scale.

Referenced by OnLButtonDown().

00160 {
00161         CScrollView::OnPrepareDC(pDC, pInfo);
00162 
00163         pDC->SetMapMode(MM_ANISOTROPIC);        // for scaling
00164         pDC->SetWindowExt(m_DrawArea);          // in logical units
00165 
00166         int xExtent = m_Scale * m_DrawArea.cx;
00167         int yExtent = m_Scale * m_DrawArea.cy;
00168         pDC->SetViewportExt(xExtent, yExtent);
00169 
00170         // keep the road divider in the centre of screen
00171         // by moving the viewport origin
00172         GetClientRect(&m_ClientRect);   // the height of the window
00173         CPoint viewOrg;
00174         viewOrg.y = m_ClientRect.Height()/2;    // - yExtent/2;
00175         viewOrg.x = m_Border_Lhs*m_Scale;
00176         
00177         viewOrg -= GetDeviceScrollPosition();   // so scrolling accounted for
00178         pDC->SetViewportOrg(viewOrg);
00179 }

void CEvolveTrafficView::OnInitialUpdate (  )  [protected, virtual]

Definition at line 140 of file EvolveTrafficView.cpp.

References DATATIP_DELAY, GetDocument(), initRoad(), m_DataTip, m_DrawArea, m_pDoc, and Round().

00141 {
00142         m_DrawArea.cx = 5000;
00143         m_DrawArea.cy = 100;
00144         
00145         CScrollView::OnInitialUpdate();
00146         
00147         m_pDoc = GetDocument();
00148         ASSERT_VALID(m_pDoc);
00149 
00150         initRoad();
00151         if(m_DataTip.m_hWnd == NULL)
00152         {
00153                 m_DataTip.Create(this);
00154                 m_DataTip.SetDisplayTime( Round(DATATIP_DELAY*1000) );
00155         }
00156 
00157 }

Here is the call graph for this function:

BOOL CEvolveTrafficView::OnPreparePrinting ( CPrintInfo *  pInfo  )  [protected, virtual]

Definition at line 314 of file EvolveTrafficView.cpp.

00315 {
00316         // default preparation
00317         return DoPreparePrinting(pInfo);
00318 }

void CEvolveTrafficView::OnBeginPrinting ( CDC *  pDC,
CPrintInfo *  pInfo 
) [protected, virtual]

Definition at line 320 of file EvolveTrafficView.cpp.

00321 {
00322         // TODO: add extra initialization before printing
00323 }

void CEvolveTrafficView::OnEndPrinting ( CDC *  pDC,
CPrintInfo *  pInfo 
) [protected, virtual]

Definition at line 325 of file EvolveTrafficView.cpp.

00326 {
00327         // TODO: add cleanup after printing
00328 }

void CEvolveTrafficView::UpdateProgressBar (  ) 

Definition at line 272 of file EvolveTrafficView.cpp.

References Sim::getPercentComplete(), m_LastPercentComplete, m_pDoc, m_PercentComplete, m_pProgBar, and CEvolveTrafficDoc::m_Sim.

Referenced by doLoop(), and OnRunInvisible().

00273 {
00274         m_PercentComplete = m_pDoc->m_Sim.getPercentComplete();
00275 
00276         if(m_PercentComplete > m_LastPercentComplete)
00277         {
00278                 CString str;
00279                 str.Format("%d%% complete", m_PercentComplete);
00280                 m_pProgBar->SetText(str);
00281                 m_pProgBar->StepIt();
00282                 m_LastPercentComplete = m_PercentComplete;
00283                 Invalidate(FALSE);      // called so that during invisible the bar is still seen
00284         }
00285 }

Here is the call graph for this function:

void CEvolveTrafficView::doLoop ( int  curTime  ) 

Definition at line 242 of file EvolveTrafficView.cpp.

References Sim::doOneTimeStep(), doSimFinished(), m_bInSimulation, m_bPause, m_pDoc, CEvolveTrafficDoc::m_Sim, m_SimTimeStep, m_StartRealTime, m_TimerSpeed, m_TimeWarp, m_VehiclePositions, Round(), and UpdateProgressBar().

Referenced by CEvolveTrafficApp::OnIdle().

00243 {
00244         int StepTime = Round( (double)m_SimTimeStep/m_TimeWarp );
00245         static int TimeNextSimStep = m_StartRealTime + StepTime;
00246         static int TimeNextDraw = m_StartRealTime + m_TimerSpeed;
00247         
00248         if(m_bInSimulation && !m_bPause)        // simulating & not paused
00249         {
00250                 if(curTime > TimeNextSimStep)   // ready for next simstep
00251                 {
00252                         // note m_bInSimulation will become false if it's the end of the simulation
00253                         m_VehiclePositions = m_pDoc->m_Sim.doOneTimeStep(&m_bInSimulation);
00254                         UpdateProgressBar();
00255 
00256                         if(!m_bInSimulation) // we were in a simulation and now we're not - ie it's just finished
00257                                 doSimFinished(true);    // true means completed
00258 
00259                         while(TimeNextSimStep < curTime)
00260                                 TimeNextSimStep += StepTime;
00261                 }
00262         }
00263         
00264         if(curTime > TimeNextDraw)                      // ready for next frame?
00265         {
00266                 InvalidateRect(NULL,FALSE);             // draw it
00267                 while(TimeNextDraw < curTime)
00268                         TimeNextDraw += m_TimerSpeed;
00269         }
00270 }

Here is the call graph for this function:

void CEvolveTrafficView::setMaxTimeWarp (  ) 

Definition at line 428 of file EvolveTrafficView.cpp.

References m_MaxTimeWarp, and m_TimeWarp.

00429 {
00430         m_MaxTimeWarp = m_TimeWarp;
00431 }

void CEvolveTrafficView::OnConfigSim (  )  [protected]

Definition at line 594 of file EvolveTrafficView.cpp.

References CEvolveTrafficDoc::getAllowLaneChanging(), CEvolveTrafficDoc::getDriveOnRight(), CEvolveTrafficDoc::getFileIn(), CEvolveTrafficDoc::getFileOut(), CEvolveTrafficDoc::getFileType(), CEvolveTrafficDoc::getLocOutputDetectorDirNeg(), CEvolveTrafficDoc::getLocOutputDetectorDirPos(), CEvolveTrafficDoc::getMetricsDir(), CEvolveTrafficDoc::getNoLanesDirNeg(), CEvolveTrafficDoc::getNoLanesDirPos(), CEvolveTrafficDoc::getRoadLength(), CEvolveTrafficDoc::getSimTimeStep(), CEvolveTrafficDoc::getTrafFileNoLanesDirNeg(), CEvolveTrafficDoc::getTrafFileNoLanesDirPos(), CSimConfigDlg::m_AllowLaneChanging, CSimConfigDlg::m_DriveOnRight, CSimConfigDlg::m_FileIn, CSimConfigDlg::m_FileOut, CSimConfigDlg::m_FileType, CSimConfigDlg::m_LocOutputDetectorDirNeg, CSimConfigDlg::m_LocOutputDetectorDirPos, CSimConfigDlg::m_MetricsDir, CSimConfigDlg::m_NoLanesDirNeg, CSimConfigDlg::m_NoLanesDirPos, m_pDoc, CSimConfigDlg::m_RoadLength, CSimConfigDlg::m_SimTimeStep, CSimConfigDlg::m_TrafFileNoLanesDirNeg, CSimConfigDlg::m_TrafFileNoLanesDirPos, CEvolveTrafficDoc::setAllowLaneChanging(), CEvolveTrafficDoc::setDriveOnRight(), CEvolveTrafficDoc::setFileIn(), CEvolveTrafficDoc::setFileOut(), CEvolveTrafficDoc::setFileType(), CEvolveTrafficDoc::setLocOutputDetectorDirNeg(), CEvolveTrafficDoc::setLocOutputDetectorDirPos(), CEvolveTrafficDoc::setMetricsDir(), CEvolveTrafficDoc::setNoLanesDirNeg(), CEvolveTrafficDoc::setNoLanesDirPos(), CEvolveTrafficDoc::setRoadLength(), CEvolveTrafficDoc::setSimTimeStep(), SettingUpdateRedraw(), CEvolveTrafficDoc::setTrafFileNoLanesDirNeg(), CEvolveTrafficDoc::setTrafFileNoLanesDirPos(), and CEvolveTrafficDoc::UpdateDerivedMembers().

00595 {
00596         CSimConfigDlg SimDlg;
00597 
00598         SimDlg.m_FileIn                 = m_pDoc->getFileIn();
00599         SimDlg.m_FileOut                = m_pDoc->getFileOut();
00600         SimDlg.m_MetricsDir             = m_pDoc->getMetricsDir();
00601         SimDlg.m_FileType               = m_pDoc->getFileType();
00602         SimDlg.m_RoadLength             = m_pDoc->getRoadLength();
00603         SimDlg.m_DriveOnRight   = m_pDoc->getDriveOnRight();
00604         SimDlg.m_NoLanesDirPos  = m_pDoc->getNoLanesDirPos();
00605         SimDlg.m_NoLanesDirNeg  = m_pDoc->getNoLanesDirNeg();
00606         SimDlg.m_SimTimeStep    = (int)(m_pDoc->getSimTimeStep() * 1000);       // seconds to milliseconds
00607         
00608         SimDlg.m_AllowLaneChanging                      = m_pDoc->getAllowLaneChanging();
00609         SimDlg.m_TrafFileNoLanesDirPos          = m_pDoc->getTrafFileNoLanesDirPos();
00610         SimDlg.m_TrafFileNoLanesDirNeg          = m_pDoc->getTrafFileNoLanesDirNeg();
00611         SimDlg.m_LocOutputDetectorDirPos        = m_pDoc->getLocOutputDetectorDirPos();
00612         SimDlg.m_LocOutputDetectorDirNeg        = m_pDoc->getLocOutputDetectorDirNeg();
00613 
00614         if(SimDlg.DoModal() == IDOK)
00615         {
00616                 m_pDoc->setFileIn(                      SimDlg.m_FileIn         );
00617                 m_pDoc->setFileOut(                     SimDlg.m_FileOut        );
00618                 m_pDoc->setMetricsDir(          SimDlg.m_MetricsDir     );
00619                 m_pDoc->setFileType(            SimDlg.m_FileType       );
00620                 m_pDoc->setRoadLength(          SimDlg.m_RoadLength     );
00621                 m_pDoc->setDriveOnRight(        SimDlg.m_DriveOnRight );
00622                 m_pDoc->setNoLanesDirPos(       SimDlg.m_NoLanesDirPos);
00623                 m_pDoc->setNoLanesDirNeg(       SimDlg.m_NoLanesDirNeg);
00624                 m_pDoc->setSimTimeStep(         (double)SimDlg.m_SimTimeStep / 1000 );  // milliseconds to seconds
00625                 
00626                 m_pDoc->setAllowLaneChanging(           SimDlg.m_AllowLaneChanging );
00627                 m_pDoc->setTrafFileNoLanesDirPos(       SimDlg.m_TrafFileNoLanesDirPos );
00628                 m_pDoc->setTrafFileNoLanesDirNeg(       SimDlg.m_TrafFileNoLanesDirNeg );
00629                 m_pDoc->setLocOutputDetectorDirPos( SimDlg.m_LocOutputDetectorDirPos );
00630                 m_pDoc->setLocOutputDetectorDirNeg( SimDlg.m_LocOutputDetectorDirNeg );
00631 
00632                 m_pDoc->UpdateDerivedMembers(true);     // call setMod flag
00633                 
00634                 SettingUpdateRedraw();
00635         };
00636 }

Here is the call graph for this function:

void CEvolveTrafficView::OnRunVisible (  )  [protected]

Definition at line 354 of file EvolveTrafficView.cpp.

References doSimStart(), m_bInSimulation, m_bPause, and OnToolsPause().

00355 {
00356         if( !m_bInSimulation )
00357                 doSimStart();
00358         else
00359         {
00360                 if(m_bPause)            // give this button start stop behaviour as well
00361                         OnToolsPause();
00362                 else
00363                         MessageBox("Simulation already running", "EvolveTraffic", MB_OK|MB_ICONWARNING);
00364         }
00365 }

Here is the call graph for this function:

void CEvolveTrafficView::OnSize ( UINT  nType,
int  cx,
int  cy 
) [protected]

Definition at line 433 of file EvolveTrafficView.cpp.

00434 {
00435         CScrollView::OnSize(nType, cx, cy);
00436 }

void CEvolveTrafficView::OnConfigTraf (  )  [protected]

Definition at line 638 of file EvolveTrafficView.cpp.

References CEvolveTrafficDoc::getIDMParams_Car(), CEvolveTrafficDoc::getIDMParams_Crane(), CEvolveTrafficDoc::getIDMParams_LargeTruck(), CEvolveTrafficDoc::getIDMParams_Lowloader(), CEvolveTrafficDoc::getIDMParams_SmallTruck(), CTrafficConfigDlg::m_IDMParams_Car, CTrafficConfigDlg::m_IDMParams_Crane, CTrafficConfigDlg::m_IDMParams_LargeTruck, CTrafficConfigDlg::m_IDMParams_Lowloader, CTrafficConfigDlg::m_IDMParams_SmallTruck, m_pDoc, CEvolveTrafficDoc::setIDMParams_Car(), CEvolveTrafficDoc::setIDMParams_Crane(), CEvolveTrafficDoc::setIDMParams_LargeTruck(), CEvolveTrafficDoc::setIDMParams_Lowloader(), and CEvolveTrafficDoc::setIDMParams_SmallTruck().

00639 {
00640         CTrafficConfigDlg TrafDlg;
00641 
00642         TrafDlg.m_IDMParams_Car                 = m_pDoc->getIDMParams_Car();
00643         TrafDlg.m_IDMParams_SmallTruck  = m_pDoc->getIDMParams_SmallTruck();
00644         TrafDlg.m_IDMParams_LargeTruck  = m_pDoc->getIDMParams_LargeTruck();
00645         TrafDlg.m_IDMParams_Crane               = m_pDoc->getIDMParams_Crane();
00646         TrafDlg.m_IDMParams_Lowloader   = m_pDoc->getIDMParams_Lowloader();
00647 
00648         if(TrafDlg.DoModal() == IDOK)
00649         {
00650                 m_pDoc->setIDMParams_Car                (TrafDlg.m_IDMParams_Car);
00651                 m_pDoc->setIDMParams_SmallTruck (TrafDlg.m_IDMParams_SmallTruck);
00652                 m_pDoc->setIDMParams_LargeTruck (TrafDlg.m_IDMParams_LargeTruck);
00653                 m_pDoc->setIDMParams_Crane              (TrafDlg.m_IDMParams_Crane);
00654                 m_pDoc->setIDMParams_Lowloader  (TrafDlg.m_IDMParams_Lowloader);
00655 
00656                 Invalidate();
00657         }       
00658 }

Here is the call graph for this function:

void CEvolveTrafficView::OnToolsPrefs (  )  [protected]

Definition at line 660 of file EvolveTrafficView.cpp.

References m_Border_Btm, CPreferencesDlg::m_Border_Btm, m_Border_Lhs, CPreferencesDlg::m_Border_Lhs, m_Border_Rhs, CPreferencesDlg::m_Border_Rhs, m_Border_Top, CPreferencesDlg::m_Border_Top, m_bShowLegend, m_bShowVelocity, m_ExaggerateWidths, CPreferencesDlg::m_ExaggerateWidths, m_LaneWidth, CPreferencesDlg::m_LaneWidth, m_Scale, CPreferencesDlg::m_Scale, CPreferencesDlg::m_ShowLegend, CPreferencesDlg::m_ShowVelocity, m_TickLength, CPreferencesDlg::m_TickLength, m_TickStep, CPreferencesDlg::m_TickStep, m_TimeWarp, CPreferencesDlg::m_TimeWarp, m_VehicleLengthScale, CPreferencesDlg::m_VehicleLengthScale, m_VehicleWidth, CPreferencesDlg::m_VehicleWidth, and SettingUpdateRedraw().

00661 {
00662         CPreferencesDlg PrefsDlg;
00663 
00664         PrefsDlg.m_Scale                                = m_Scale;
00665         PrefsDlg.m_ExaggerateWidths             = m_ExaggerateWidths;
00666         PrefsDlg.m_TimeWarp                             = m_TimeWarp;
00667         PrefsDlg.m_TickStep                             = m_TickStep;
00668         
00669         PrefsDlg.m_LaneWidth                    = m_LaneWidth   / m_ExaggerateWidths;
00670         PrefsDlg.m_VehicleWidth                 = m_VehicleWidth/ m_ExaggerateWidths;
00671         PrefsDlg.m_TickLength                   = m_TickLength  / m_ExaggerateWidths;
00672         
00673         PrefsDlg.m_VehicleLengthScale   = m_VehicleLengthScale;
00674         PrefsDlg.m_ShowVelocity                 = m_bShowVelocity ? 1 : 0;
00675         PrefsDlg.m_ShowLegend                   = m_bShowLegend ? 1 : 0;
00676         PrefsDlg.m_Border_Top                   = m_Border_Top;
00677         PrefsDlg.m_Border_Btm                   = m_Border_Btm;
00678         PrefsDlg.m_Border_Lhs                   = m_Border_Lhs;
00679         PrefsDlg.m_Border_Rhs                   = m_Border_Rhs;
00680 
00681         if(PrefsDlg.DoModal() == IDOK)
00682         {
00683                 m_Scale                                 =       PrefsDlg.m_Scale;
00684                 m_ExaggerateWidths              =       PrefsDlg.m_ExaggerateWidths;
00685                 m_TimeWarp                              =       PrefsDlg.m_TimeWarp;
00686                 m_TickStep                              =       PrefsDlg.m_TickStep;
00687                 
00688                 m_LaneWidth                             =       PrefsDlg.m_LaneWidth    * m_ExaggerateWidths;
00689                 m_VehicleWidth                  =       PrefsDlg.m_VehicleWidth * m_ExaggerateWidths;
00690                 m_TickLength                    =       PrefsDlg.m_TickLength   * m_ExaggerateWidths;
00691 
00692                 m_VehicleLengthScale    =       PrefsDlg.m_VehicleLengthScale;
00693                 m_bShowVelocity                 =       PrefsDlg.m_ShowVelocity == 0 ? false : true;
00694                 m_bShowLegend                   =       PrefsDlg.m_ShowLegend == 0 ? false : true;
00695                 m_Border_Top                    =       PrefsDlg.m_Border_Top;
00696                 m_Border_Btm                    =       PrefsDlg.m_Border_Btm;
00697                 m_Border_Lhs                    =       PrefsDlg.m_Border_Lhs;
00698                 m_Border_Rhs                    =       PrefsDlg.m_Border_Rhs;
00699 
00700                 SettingUpdateRedraw();
00701         }
00702 }

Here is the call graph for this function:

void CEvolveTrafficView::OnToolsPause (  )  [protected]

Definition at line 438 of file EvolveTrafficView.cpp.

References m_bPause, m_PauseTime, and m_StartRealTime.

Referenced by OnRunVisible().

00439 {
00440         if(m_bPause)    // currently paused - about to not be
00441         {
00442                 m_PauseTime = timeGetTime() - m_PauseTime;      // calc total pause time
00443                 m_StartRealTime += m_PauseTime;                                 // so time just carries on
00444         }
00445         else                    // not paused - but about to be
00446                 m_PauseTime = timeGetTime();                            // save initial pause time
00447 
00448         m_bPause = !m_bPause;           // so pause/start behaviour
00449 
00450 }

void CEvolveTrafficView::OnToolsZoomin (  )  [protected]

Definition at line 517 of file EvolveTrafficView.cpp.

References m_Scale, and SetZoomScale().

00518 {
00519         SetZoomScale(m_Scale + 0.2);    // MAGIC NUMBER - should it be an option?
00520 }

Here is the call graph for this function:

void CEvolveTrafficView::OnToolsZoomout (  )  [protected]

Definition at line 522 of file EvolveTrafficView.cpp.

References m_Scale, and SetZoomScale().

00523 {
00524         SetZoomScale(m_Scale - 0.2);    // MAGIC NUMBER - should it be an option?
00525 }

Here is the call graph for this function:

void CEvolveTrafficView::OnToolsSpeedup (  )  [protected]

Definition at line 527 of file EvolveTrafficView.cpp.

References m_TimeWarp, and ValidateTimeWarp().

00528 {
00529         m_TimeWarp += 1.0;                              // MAGIC NUMBER - should it be an option?
00530 
00531         ValidateTimeWarp();
00532 }

Here is the call graph for this function:

void CEvolveTrafficView::OnToolsSlowdown (  )  [protected]

Definition at line 534 of file EvolveTrafficView.cpp.

References m_TimeWarp, and ValidateTimeWarp().

00535 {
00536         m_TimeWarp -= 1.0;                              // MAGIC NUMBER - should it be an option?
00537 
00538         ValidateTimeWarp();
00539 }

Here is the call graph for this function:

void CEvolveTrafficView::OnKeyDown ( UINT  nChar,
UINT  nRepCnt,
UINT  nFlags 
) [protected]

Definition at line 541 of file EvolveTrafficView.cpp.

References m_RoadLength, and Round().

00542 {
00543         CScrollView::OnKeyDown(nChar, nRepCnt, nFlags);
00544 
00545         POINT curPoint = GetScrollPosition();
00546         int deltaX = Round(m_RoadLength/10);    // MAGIC NUMBER - scroll 1/10 of road
00547 
00548         switch(nChar)
00549         {
00550                 case VK_RIGHT:
00551                         curPoint.x += deltaX;   
00552                         break;
00553                 case VK_LEFT:
00554                         curPoint.x -= deltaX;
00555                         break;
00556                 case VK_HOME:
00557                         curPoint.x = 0;
00558                         break;
00559                 case VK_END:
00560                         CSize temp = GetTotalSize();
00561                         curPoint.x = temp.cx;
00562                         break;
00563         }
00564         ScrollToPosition(curPoint);
00565         Invalidate(FALSE);
00566 }

Here is the call graph for this function:

void CEvolveTrafficView::OnRunInvisible (  )  [protected]

Definition at line 367 of file EvolveTrafficView.cpp.

References Sim::doOneTimeStep(), doSimFinished(), doSimStart(), Sim::getCurrentSimTime(), m_bInSimulation, m_CurentRealTime, m_CurentSimTime, m_pDoc, CEvolveTrafficDoc::m_Sim, m_StartRealTime, and UpdateProgressBar().

00368 {
00369         if( !m_bInSimulation )
00370         {
00371                 int result = MessageBox("Running EvolveTraffic in this mode means:\n"
00372                                                                 "- only the progress bar is updated;\n"
00373                                                                 "- the program will appear to be unresponsive until the simulation is complete.\n"
00374                                                                 "Are you sure that you want to proceed in this mode?",
00375                                                                 "EvolveTraffic", MB_YESNO|MB_ICONWARNING);
00376 
00377                 if(result == IDYES)     // we're cleared to go
00378                 {
00379                         doSimStart();
00380                         bool bInSim = true;             // local inSim - we want class-wide InSim to persist longer than this loop
00381                         while(bInSim)
00382                         {
00383                                 m_pDoc->m_Sim.doOneTimeStep(&bInSim);   // bInSim becomes false when sim is over
00384                                 UpdateProgressBar();
00385                         }
00386                         m_CurentSimTime = m_pDoc->m_Sim.getCurrentSimTime();
00387                         m_CurentRealTime = timeGetTime() - m_StartRealTime;     // no need for PauseTime since no pause
00388                         doSimFinished(true);    // no need to check if it's finished - true means completed
00389                 }
00390         }
00391         else
00392                 MessageBox("Simulation already running", "EvolveTraffic", MB_OK|MB_ICONWARNING);
00393         
00394 }

Here is the call graph for this function:

void CEvolveTrafficView::OnConfigFeatures (  )  [protected]

Definition at line 704 of file EvolveTrafficView.cpp.

References CEvolveTrafficDoc::getRoadFeatures(), m_pDoc, m_RoadLength, CRoadFeaturesDlg::m_RoadLength, CRoadFeaturesDlg::m_vRoadFeatures, and CEvolveTrafficDoc::setRoadFeatures().

00705 {
00706         CRoadFeaturesDlg FeaturesDlg;
00707 
00708         FeaturesDlg.m_RoadLength = m_RoadLength;        // for validation purposes only
00709         FeaturesDlg.m_vRoadFeatures.Copy( *(m_pDoc->getRoadFeatures()) );
00710 
00711         if( FeaturesDlg.DoModal() == IDOK )
00712                 m_pDoc->setRoadFeatures( &(FeaturesDlg.m_vRoadFeatures) );
00713 
00714         Invalidate();
00715 }

Here is the call graph for this function:

void CEvolveTrafficView::OnConfigMetrics (  )  [protected]

Definition at line 717 of file EvolveTrafficView.cpp.

References CEvolveTrafficDoc::getStatDetectors(), m_pDoc, m_RoadLength, CStatDetectorDlg::m_RoadLength, CStatDetectorDlg::m_vStatDetectors, and CEvolveTrafficDoc::setStatDetectors().

00718 {
00719         CStatDetectorDlg StatDetDlg;
00720         
00721         StatDetDlg.m_RoadLength = m_RoadLength; // for validation purposes only
00722         StatDetDlg.m_vStatDetectors.Copy( *(m_pDoc->getStatDetectors()) );
00723 
00724         if( StatDetDlg.DoModal() == IDOK )
00725                 m_pDoc->setStatDetectors( &(StatDetDlg.m_vStatDetectors) );
00726 
00727         Invalidate();   
00728 }

Here is the call graph for this function:

void CEvolveTrafficView::OnUpdateToolsPause ( CCmdUI *  pCmdUI  )  [protected]

Definition at line 465 of file EvolveTrafficView.cpp.

References m_bInSimulation, and m_bPause.

00466 {
00467         if(m_bInSimulation)
00468         {
00469                 pCmdUI->Enable(true);
00470                 if(m_bPause)
00471                         pCmdUI->SetText("&Resume\tF9");
00472                 else
00473                         pCmdUI->SetText("&Pause\tF9");
00474         }
00475         else
00476                 pCmdUI->Enable(false);
00477         
00478 }

void CEvolveTrafficView::OnUpdateToolsSpeedup ( CCmdUI *  pCmdUI  )  [protected]

Definition at line 480 of file EvolveTrafficView.cpp.

References m_bInSimulation.

00481 {
00482         if(m_bInSimulation)
00483                 pCmdUI->Enable(true);
00484         else
00485                 pCmdUI->Enable(false);  
00486 }

void CEvolveTrafficView::OnUpdateToolsSlowdown ( CCmdUI *  pCmdUI  )  [protected]

Definition at line 488 of file EvolveTrafficView.cpp.

References m_bInSimulation.

00489 {
00490         if(m_bInSimulation)
00491                 pCmdUI->Enable(true);
00492         else
00493                 pCmdUI->Enable(false);  
00494 }

void CEvolveTrafficView::OnToolsStop (  )  [protected]

Definition at line 452 of file EvolveTrafficView.cpp.

References doSimFinished().

00453 {
00454         doSimFinished(false);   // false means not compelted, but stopped midway through
00455 }

Here is the call graph for this function:

void CEvolveTrafficView::OnUpdateToolsStop ( CCmdUI *  pCmdUI  )  [protected]

Definition at line 457 of file EvolveTrafficView.cpp.

References m_bInSimulation.

00458 {
00459         if(m_bInSimulation)
00460                 pCmdUI->Enable(true);
00461         else
00462                 pCmdUI->Enable(false);  
00463 }

void CEvolveTrafficView::OnLButtonDown ( UINT  nFlags,
CPoint  point 
) [protected]

Definition at line 734 of file EvolveTrafficView.cpp.

References FindVehicle(), Vehicle::getDataString(), m_Border_Lhs, m_bPause, m_BtmEdge, m_DataTip, m_DriveOnRight, m_LaneWidth, m_NoLanes, m_TopEdge, and OnPrepareDC().

00735 {
00736         if(m_bPause)    // only if paused
00737         {
00738                 // Get road coords
00739                 CClientDC aDC(this);
00740                 OnPrepareDC(&aDC);
00741                 CPoint ptRoad = point;
00742                 aDC.DPtoLP(&ptRoad);
00743                 ptRoad.x -= m_Border_Lhs;
00744 
00745                 if(ptRoad.y < m_BtmEdge && ptRoad.y > m_TopEdge) // only if within road
00746                 {
00747                         // Get lane
00748                         int iLane = 1;
00749                         int TopOfLane = m_BtmEdge;
00750 
00751                         while(ptRoad.y < TopOfLane)
00752                         {
00753                                 TopOfLane = m_BtmEdge - iLane*m_LaneWidth;
00754                                 iLane++;
00755                         }
00756                         // so it was in the previous lane, but zero based array, i.e.
00757                         iLane -= 2;
00758                         if(!m_DriveOnRight)
00759                                 iLane = m_NoLanes - iLane -1;
00760 
00761                         // Find vehicle at pos x in lane iLane
00762                         Vehicle* pVeh = FindVehicle(iLane, ptRoad.x);
00763                         
00764                         if(pVeh != NULL)        // assemble datastring and display
00765                         {
00766                                 CRect rect(point.x,point.y,point.x+100, point.y+100);   // notice point in screen coords
00767                                 m_DataTip.Show(rect,pVeh->getDataString());
00768                         }
00769                 }
00770         }
00771         
00772         CScrollView::OnLButtonDown(nFlags, point);
00773 }

Here is the call graph for this function:

void CEvolveTrafficView::OnFileSaveImage (  )  [protected]

Definition at line 572 of file EvolveTrafficView.cpp.

References CWindowToBMP::Write().

00573 {
00574         CFileDialog FileDlg(
00575                 FALSE,                  // TRUE if File Open, FALSE if File Save As
00576                 _T("*.bmp"),    // the default file extension
00577                 NULL,                   // the initial filename that appears
00578                 OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,//flags for customizing the appearance
00579                 "Bitmap files (*.bmp) |*.bmp||",        // file filters
00580                 this); // pointer to FileCialog's parent object
00581 
00582         if(FileDlg.DoModal() == IDOK)
00583         {
00584                 CString file = FileDlg.GetPathName();
00585                 UpdateWindow();         // to get rid of dialog
00586                 CWindowToBMP convert;
00587                 if( convert.Write(file, this) )
00588                         MessageBox("Image saved.","EvolveTraffic", MB_OK|MB_ICONINFORMATION);
00589                 else
00590                         MessageBox("Image saving failed.","EvolveTraffic", MB_OK|MB_ICONWARNING);
00591         }       
00592 }

Here is the call graph for this function:

Vehicle * CEvolveTrafficView::FindVehicle ( int  iLane,
int  location 
) [private]

Definition at line 775 of file EvolveTrafficView.cpp.

References Vehicle::getDirection(), Vehicle::getLength(), Vehicle::getRoadPos(), m_VehicleLengthScale, and m_VehiclePositions.

Referenced by OnLButtonDown().

00776 {
00777         Vehicle* pVeh = NULL;
00778         std::vector<Vehicle*> vLaneVehs = m_VehiclePositions.at(iLane);
00779         
00780         for(int i = 0; i < vLaneVehs.size(); i++)
00781         {
00782                 pVeh = vLaneVehs.at(i);
00783                 int front = pVeh->getRoadPos();
00784                 int length = pVeh->getLength() * m_VehicleLengthScale;
00785 
00786                 bool bOnVehicle = false;
00787                 if(pVeh->getDirection())
00788                 {
00789                         if( location < front && location > front - length )
00790                                 bOnVehicle = true;
00791                 }
00792                 else
00793                 {
00794                         if( location > front && location < front + length )
00795                                 bOnVehicle = true;
00796                 }
00797 
00798                 if( bOnVehicle )
00799                         return pVeh;
00800         }
00801 
00802         return NULL;
00803 }

Here is the call graph for this function:

BOOL CEvolveTrafficView::WriteWindowToDIB ( LPTSTR  szFile,
CWnd *  pWnd 
) [private]

void CEvolveTrafficView::SetZoomScale ( double  newScale  )  [private]

Definition at line 181 of file EvolveTrafficView.cpp.

References m_ClientRect, m_DrawArea, m_Scale, MIN_VIEW_SCALE, and Round().

Referenced by OnToolsZoomin(), and OnToolsZoomout().

00182 {
00183         if(newScale > MIN_VIEW_SCALE)
00184         {
00185                 double oldZoomFactor = m_Scale;
00186                 
00187                 CPoint centerScrollPosition = GetScrollPosition();
00188                 CRect ClientRect(0,0,0,0);
00189                 centerScrollPosition.x += m_ClientRect.right/2;
00190                 centerScrollPosition.y += m_ClientRect.bottom/2;
00191 
00192                 m_Scale = newScale;
00193                 
00194                 CSize displaySize;
00195                 displaySize.cx = Round(m_DrawArea.cx * m_Scale);
00196                 displaySize.cy = Round(m_DrawArea.cy * m_Scale);
00197                 SetScrollSizes(MM_TEXT,displaySize);
00198                 
00199                 int newXScrollPosition = Round((centerScrollPosition.x / oldZoomFactor) * m_Scale);
00200                 int newYScrollPosition = Round((centerScrollPosition.y / oldZoomFactor) * m_Scale);
00201 
00202                 newXScrollPosition -= m_ClientRect.right/2;
00203                 newYScrollPosition -= m_ClientRect.bottom/2;
00204                 ScrollToPosition(CPoint(newXScrollPosition,newYScrollPosition));
00205         }
00206         else
00207         {
00208                 CString str; str.Format("You cannot zoom out any further - minimum view scale is 0.1.", MIN_VIEW_SCALE);
00209                 MessageBox(str, "EvolveTraffic", MB_OK|MB_ICONWARNING);
00210         }
00211 
00212         Invalidate(FALSE);
00213 }

Here is the call graph for this function:

void CEvolveTrafficView::ValidateTimeWarp (  )  [private]

Definition at line 502 of file EvolveTrafficView.cpp.

References m_MaxTimeWarp, and m_TimeWarp.

Referenced by OnToolsSlowdown(), and OnToolsSpeedup().

00503 {
00504         if(m_TimeWarp > m_MaxTimeWarp)
00505         {
00506                 m_TimeWarp = m_MaxTimeWarp;
00507                 CString str;    str.Format("Maximum time warp reached (%.2f) for this simulation.",m_TimeWarp);
00508                 MessageBox(str,"EvolveTraffic",MB_OK|MB_ICONINFORMATION);
00509         }
00510         if(m_TimeWarp < 0.5)    // set half speed as minimum
00511         {
00512                 m_TimeWarp = 1.0;
00513                 MessageBox("Half of real-time speed is the minimum time warp.","EvolveTraffic",MB_OK|MB_ICONINFORMATION);
00514         }
00515 }

void CEvolveTrafficView::doSimStart (  )  [private]

Definition at line 396 of file EvolveTrafficView.cpp.

References CEvolveTrafficDoc::initSim(), m_bInSimulation, m_CurentSimTime, m_pDoc, m_pProgBar, and m_StartRealTime.

Referenced by OnRunInvisible(), and OnRunVisible().

00397 {
00398         bool statusOK = m_pDoc->initSim();
00399         if(statusOK)
00400         {
00401                 ((CEvolveTrafficApp*)AfxGetApp())->setInSimulation(true);
00402                 m_StartRealTime = timeGetTime();
00403                 m_bInSimulation = true;                         // this means the doLoop() becomes active
00404                 m_CurentSimTime = 0.0;
00405                 m_pProgBar = new CProgressBar;
00406                 m_pProgBar->Create("Percent Complete 0%");
00407                 Invalidate();   // refresh screen before starting
00408         }
00409 }

Here is the call graph for this function:

int CEvolveTrafficView::Round ( double  val  )  [inline, private]

Definition at line 103 of file EvolveTrafficView.h.

Referenced by doLoop(), DrawLegend(), DrawRoadSegments(), DrawTimer(), initRoad(), OnInitialUpdate(), OnKeyDown(), and SetZoomScale().

00103 {return int(val + 0.5);};

void CEvolveTrafficView::doSimFinished ( bool  bCompleted  )  [private]

Definition at line 411 of file EvolveTrafficView.cpp.

References Sim::clear(), m_bInSimulation, m_LastPercentComplete, m_pDoc, m_pProgBar, CEvolveTrafficDoc::m_Sim, and m_VehiclePositions.

Referenced by doLoop(), OnRunInvisible(), and OnToolsStop().

00412 {
00413         Invalidate();                                                                                           // draw last screen
00414         m_bInSimulation = false;                                                                        // tell overall class we're done
00415         ((CEvolveTrafficApp*)AfxGetApp())->setInSimulation(false);      // tell the sim loop to stop
00416         m_pProgBar->Clear();                                                                            // clear and
00417         delete m_pProgBar;                                                                                      // delete the current progress bar
00418         m_pDoc->m_Sim.clear();                                                                          // clear the simulation
00419         m_LastPercentComplete = 0;                                                                      // reset the percent complete
00420         m_VehiclePositions.clear();                                                                     // clear vehicles
00421 
00422         if(bCompleted)
00423                 MessageBox("The simulation has finished.","EvolveTraffic",MB_OK|MB_ICONINFORMATION);
00424 }

Here is the call graph for this function:

void CEvolveTrafficView::UpdateDrawRegion (  )  [private]

void CEvolveTrafficView::SettingUpdateRedraw (  )  [private]

Definition at line 496 of file EvolveTrafficView.cpp.

References initRoad().

Referenced by OnConfigSim(), and OnToolsPrefs().

00497 {
00498         initRoad();             // re-do the road properties
00499         Invalidate();   // draw it
00500 }

Here is the call graph for this function:

void CEvolveTrafficView::initRoad (  )  [private]

Definition at line 215 of file EvolveTrafficView.cpp.

References CEvolveTrafficDoc::getDriveOnRight(), CEvolveTrafficDoc::getNoDirections(), CEvolveTrafficDoc::getNoLanes(), CEvolveTrafficDoc::getNoLanesDirNeg(), CEvolveTrafficDoc::getNoLanesDirPos(), CEvolveTrafficDoc::getRoadLength(), CEvolveTrafficDoc::getSimTimeStep(), m_Border_Btm, m_Border_Lhs, m_Border_Rhs, m_Border_Top, m_BtmEdge, m_DrawArea, m_DriveOnRight, m_LaneWidth, m_nLanesOnBtm, m_nLanesOnTop, m_NoDirections, m_NoLanes, m_NoLanesDirNeg, m_NoLanesDirPos, m_NoTicks, m_pDoc, m_RoadLength, m_RoadWidth, m_Scale, m_SimTimeStep, m_TickStep, m_TopEdge, and Round().

Referenced by OnInitialUpdate(), and SettingUpdateRedraw().

00216 {
00217         m_DriveOnRight  = m_pDoc->getDriveOnRight();
00218         m_RoadLength    = m_pDoc->getRoadLength();
00219         m_NoLanes               = m_pDoc->getNoLanes();
00220         m_NoLanesDirPos = m_pDoc->getNoLanesDirPos();
00221         m_NoLanesDirNeg = m_pDoc->getNoLanesDirNeg();
00222         m_NoDirections  = m_pDoc->getNoDirections();
00223         m_RoadWidth             = m_NoLanes * m_LaneWidth;
00224         m_NoTicks               = (int)(m_RoadLength/m_TickStep)+1;
00225 
00226         m_nLanesOnTop   = m_DriveOnRight ? m_NoLanesDirNeg : m_NoLanesDirPos;
00227         m_nLanesOnBtm   = m_DriveOnRight ? m_NoLanesDirPos : m_NoLanesDirNeg;
00228         m_TopEdge               = -m_nLanesOnTop*m_LaneWidth;
00229         m_BtmEdge               = m_nLanesOnBtm*m_LaneWidth;
00230 
00231         m_SimTimeStep = Round(1000 * m_pDoc->getSimTimeStep()); // constant sim time step
00232 
00233         m_DrawArea.cy =  m_Border_Top + m_Border_Btm + m_RoadWidth;
00234         m_DrawArea.cx =  m_Border_Lhs + m_Border_Rhs + m_RoadLength;
00235 
00236         CSize scrolls;
00237         scrolls.cx = m_DrawArea.cx*m_Scale;     // when scale is not 1.0
00238         scrolls.cy = m_DrawArea.cy*m_Scale;
00239         CScrollView::SetScrollSizes(MM_TEXT, scrolls);
00240 }

Here is the call graph for this function:

void CEvolveTrafficView::DrawRoad ( CMemDC pDC  )  [private]

Definition at line 809 of file EvolveTrafficView.cpp.

References CLR_ROAD_LINES, CLR_ROAD_SURFACE, DrawDetectors(), DrawRoadSegments(), m_Border_Lhs, m_BtmEdge, m_LaneWidth, m_NoDirections, m_NoLanes, m_RoadLength, m_RoadWidth, and m_TopEdge.

Referenced by OnDraw().

00810 {
00811         // Prepare brushes
00812         CPen BlackPen(PS_SOLID, 0, CLR_ROAD_LINES);
00813         CPen BlackDashPen(PS_DASH, 0, CLR_ROAD_LINES);
00814 
00815         // fill the road surface
00816         pDC->FillSolidRect(m_Border_Lhs,m_TopEdge,m_RoadLength,m_RoadWidth, CLR_ROAD_SURFACE);
00817         // draw road segements
00818         DrawRoadSegments(pDC);
00819         
00820         pDC->SelectObject(&BlackPen);
00821         // Top edge of the road
00822         pDC->MoveTo(m_Border_Lhs,m_TopEdge);    
00823         pDC->LineTo(m_Border_Lhs+m_RoadLength,m_TopEdge);
00824         // bottom edge of the road
00825         pDC->MoveTo(m_Border_Lhs,m_BtmEdge);    
00826         pDC->LineTo(m_Border_Lhs+m_RoadLength,m_BtmEdge);
00827         // for each lane
00828         pDC->SelectObject(&BlackDashPen);
00829         int LaneEdge =  m_BtmEdge;
00830         for (int i = 0; i < m_NoLanes-1; i++)
00831         {       // from bottom working the way up
00832                 LaneEdge -= m_LaneWidth;
00833                 pDC->MoveTo(m_Border_Lhs,LaneEdge);     
00834                 pDC->LineTo(m_Border_Lhs+m_RoadLength,LaneEdge);
00835         }
00836         // Divide carraigeway
00837         pDC->SelectObject(&BlackPen);
00838         if(m_NoDirections == 2)
00839         {
00840                 pDC->MoveTo(m_Border_Lhs,0);    
00841                 pDC->LineTo(m_Border_Lhs+m_RoadLength,0);
00842         }
00843 
00844         DrawDetectors(pDC);
00845 }

Here is the call graph for this function:

void CEvolveTrafficView::DrawRuler ( CMemDC pDC  )  [private]

Definition at line 1175 of file EvolveTrafficView.cpp.

References CLR_BACKGRND, CLR_RULER_LINES, CLR_RULER_TEXT, m_Border_Lhs, m_BtmEdge, m_NoTicks, m_TickLength, and m_TickStep.

Referenced by OnDraw().

01176 {
01177         int ypos = m_BtmEdge;
01178 
01179         //int ypos =    m_YCoordTop; //m_ClientRect.Height()/2 + m_RoadWidth/2;
01180         CPen RulerLinesPen(PS_SOLID, 0, CLR_RULER_LINES);
01181         pDC->SelectObject(&RulerLinesPen);
01182         pDC->SetTextColor(CLR_RULER_TEXT);
01183         pDC->SetBkColor(CLR_BACKGRND);
01184 
01185         for(int i = 0; i < m_NoTicks; i++)
01186         {
01187                 int xpos = m_Border_Lhs+i*m_TickStep;
01188                 pDC->MoveTo(xpos,ypos);
01189                 pDC->LineTo(xpos,ypos+m_TickLength);
01190                 CString str; str.Format("%d m",i*m_TickStep);
01191                 pDC->TextOut(xpos+5,ypos+10,str);
01192         }
01193 }

void CEvolveTrafficView::DrawTimer ( CMemDC pDC  )  [private]

Definition at line 902 of file EvolveTrafficView.cpp.

References CLR_BACKGRND, CLR_LEGEND_TEXT, Sim::getCurrentSimTime(), HOURS_PER_DAY, m_bInSimulation, m_Border_Lhs, m_Border_Top, m_bPause, m_ClientRect, m_CurentRealTime, m_CurentSimTime, m_pDoc, m_Scale, CEvolveTrafficDoc::m_Sim, m_StartRealTime, MINS_PER_HOUR, Round(), SECS_PER_HOUR, and SECS_PER_MIN.

Referenced by OnDraw().

00903 {
00904         pDC->SetTextColor(CLR_LEGEND_TEXT);
00905         pDC->SetBkColor(CLR_BACKGRND);
00906         
00907         // Draw the simulation time
00908         int ypos = Round(-(m_ClientRect.Height()/2)/m_Scale)+m_Border_Top;      // this keeps the timer position scale invariant
00909         int xpos = m_Border_Lhs;
00910         
00911         if(m_bInSimulation)
00912                 m_CurentSimTime = m_pDoc->m_Sim.getCurrentSimTime();
00913 
00914         double temp = m_CurentSimTime;                                                  int day = (int)(temp/(HOURS_PER_DAY * SECS_PER_HOUR));          
00915         temp = temp - day * HOURS_PER_DAY * SECS_PER_HOUR;              int hr  = (int)(temp/(SECS_PER_HOUR));
00916         temp = temp - hr * SECS_PER_HOUR;                                               int min = (int)(temp/(MINS_PER_HOUR));
00917         temp = temp - min * SECS_PER_MIN;                                               double sec      = temp;
00918 
00919         CString SimStr; SimStr.Format("Sim. Time - Day: %d - %d:%02d:%05.2f",day,hr,min,sec);
00920         CSize strSimSize = pDC->GetTextExtent(SimStr);  // so text is always inside the window
00921         pDC->TextOut(xpos,ypos,SimStr); // change + to - if drawn on bottom
00922 
00923         // draw the real elapsed time
00924         if(m_bInSimulation && !m_bPause)        // only update if we're simulating and not paused
00925                 m_CurentRealTime = timeGetTime() - m_StartRealTime;
00926 
00927         temp = (double)m_CurentRealTime/1000;                                   day     = (int)(temp/(HOURS_PER_DAY * SECS_PER_HOUR));
00928         temp = temp - day * HOURS_PER_DAY * SECS_PER_HOUR;              hr      = (int)(temp/(SECS_PER_HOUR));
00929         temp = temp - hr * SECS_PER_HOUR;                                               min     = (int)(temp/(MINS_PER_HOUR));
00930         temp = temp - min * SECS_PER_MIN;                                               sec     = temp;
00931 
00932         CString RealStr; RealStr.Format("Real Time - Day: %d - %d:%02d:%05.2f",day,hr,min,sec);
00933         CSize strRealSize = pDC->GetTextExtent(RealStr);        // so text is always inside the window
00934         pDC->TextOut(xpos,ypos + strRealSize.cy*1.2 ,RealStr);  // 20% sapce between strings | change + to - if drawn on bottom 
00935 
00936 }

Here is the call graph for this function:

void CEvolveTrafficView::DrawVehicle ( CMemDC pDC,
Vehicle veh 
) [private]

Definition at line 847 of file EvolveTrafficView.cpp.

References DrawVehicleAt(), Vehicle::getDirection(), Vehicle::getID(), Vehicle::getLane(), Vehicle::getLength(), Vehicle::getRoadPos(), Vehicle::getVelocity(), m_Border_Lhs, m_bShowVelocity, m_BtmEdge, m_DriveOnRight, m_LaneWidth, M_PER_S_TO_KM_PER_H, m_TopEdge, m_VehicleLengthScale, and m_VehicleWidth.

Referenced by OnDraw().

00848 {
00849         bool DirPointsRight = pVeh->getDirection();     
00850         int lane = pVeh->getLane();
00851         int x = pVeh->getRoadPos() + m_Border_Lhs;      // front of vehicle road position to screen position
00852         int y = 0;                                                                      // just to initialize it
00853 
00854         y = m_DriveOnRight ? m_BtmEdge - (lane-0.5)*m_LaneWidth : m_TopEdge + (lane-0.5)*m_LaneWidth;
00855         // and subtract half the vehicle width to get the y pos of the top edge
00856         y = y - m_VehicleWidth/2;
00857 
00858         // So DirNeg vehicles' position corresponds with the front of the vehicle
00859         int DirectionFactor = DirPointsRight == true ? -1 : +1;
00860         int cx = DirectionFactor * m_VehicleLengthScale * pVeh->getLength();
00861         CRect VehRect(x,y,x+cx,y+m_VehicleWidth);
00862         
00863         DrawVehicleAt(pDC, pVeh->getID(), VehRect);
00864 
00865         // draw the velocity on the vehicle
00866         double velocity = pVeh->getVelocity()*M_PER_S_TO_KM_PER_H;
00867 
00868         if(m_bShowVelocity)
00869         {
00870                 CString SpeedStr; SpeedStr.Format("%3.1f", velocity);
00871                 CSize strSize = pDC->GetTextExtent(SpeedStr);
00872                 x = x + cx/2 - strSize.cx/2;
00873                 y = y + m_VehicleWidth/2 - strSize.cy/2;
00874                 pDC->TextOut(x,y,SpeedStr);
00875         }
00876 }

Here is the call graph for this function:

void CEvolveTrafficView::DrawVehicleAt ( CMemDC pDC,
WORD  VEH_ID,
CRect  VehRect 
) [private]

Definition at line 878 of file EvolveTrafficView.cpp.

References VEH_COLOR_CAR, VEH_COLOR_CRANE, VEH_COLOR_LARGETRUCK, VEH_COLOR_LOWLOADER, VEH_COLOR_SMALLTRUCK, VEH_ID_CAR, VEH_ID_CRANE, VEH_ID_LARGETRUCK, VEH_ID_LOWLOADER, and VEH_ID_SMALLTRUCK.

Referenced by DrawLegendVehicle(), and DrawVehicle().

00879 {
00880         switch(VEH_ID)
00881         {
00882                 case VEH_ID_CAR:
00883                         pDC->FillSolidRect(VehRect, VEH_COLOR_CAR);
00884                         break;
00885                 case VEH_ID_SMALLTRUCK:
00886                         pDC->FillSolidRect(VehRect, VEH_COLOR_SMALLTRUCK);
00887                         break;
00888                 case VEH_ID_LARGETRUCK:
00889                         pDC->FillSolidRect(VehRect, VEH_COLOR_LARGETRUCK);
00890                         break;
00891                 case VEH_ID_CRANE:
00892                         pDC->FillSolidRect(VehRect, VEH_COLOR_CRANE);
00893                         break;
00894                 case VEH_ID_LOWLOADER:
00895                         pDC->FillSolidRect(VehRect, VEH_COLOR_LOWLOADER);
00896                         break;
00897                 default:
00898                         pDC->FillSolidRect(VehRect, VEH_COLOR_CAR);     // car
00899         }
00900 }

void CEvolveTrafficView::DrawDetectors ( CMemDC pDC  )  [private]

Definition at line 1102 of file EvolveTrafficView.cpp.

References CLR_DET_COMPOSITION, CLR_DET_FLOWDENSITY, CLR_DET_HEADWAY, CLR_DET_OUTPUT, DrawLaneChangeDetectors(), DrawSingleDetector(), CStatDetector::getDetectorType(), CStatDetector::getDirPos(), CStatDetector::getLocation(), CEvolveTrafficDoc::getLocOutputDetectorDirNeg(), CEvolveTrafficDoc::getLocOutputDetectorDirPos(), CEvolveTrafficDoc::getStatDetectors(), m_pDoc, METRICS_TYPE_COMPOSITION, METRICS_TYPE_FLOWDENSITY, METRICS_TYPE_HEADWAY, and METRICS_TYPE_LANE_CHANGE.

Referenced by DrawRoad().

01103 {
01104         // Output Detectors
01105         double LocDetDirPos = m_pDoc->getLocOutputDetectorDirPos();
01106         double LocDetDirNeg = m_pDoc->getLocOutputDetectorDirNeg();
01107         DrawSingleDetector(pDC, CLR_DET_OUTPUT, LocDetDirPos, true);
01108         DrawSingleDetector(pDC, CLR_DET_OUTPUT, LocDetDirNeg, false);
01109 
01110         // Metrics Detectors
01111         CObArray vSD;   vSD.Copy( *(m_pDoc->getStatDetectors()) );
01112         for(int i = 0; i < vSD.GetSize(); i++)
01113         {
01114                 CStatDetector* pSD = reinterpret_cast<CStatDetector*>(vSD.GetAt(i));
01115                 WORD SDtype = pSD->getDetectorType();
01116                 bool bDraw = true;
01117                 COLORREF COL;
01118                 switch(SDtype)
01119                 {
01120                         case METRICS_TYPE_FLOWDENSITY:  
01121                                 COL = CLR_DET_FLOWDENSITY;
01122                                 break;
01123                         case METRICS_TYPE_HEADWAY:              
01124                                 COL = CLR_DET_HEADWAY;
01125                                 break;
01126                         case METRICS_TYPE_COMPOSITION:  
01127                                 COL = CLR_DET_COMPOSITION;
01128                                 break;
01129                         case METRICS_TYPE_LANE_CHANGE:  // nothing to draw!
01130                                 DrawLaneChangeDetectors(pDC, pSD->getDirPos());
01131                                 bDraw = false;
01132                                 break;
01133                         default:                                                
01134                                 COL = CLR_DET_FLOWDENSITY;
01135                 }
01136                 if(bDraw)
01137                         DrawSingleDetector(pDC, COL, pSD->getLocation(), pSD->getDirPos());
01138         }
01139 }

Here is the call graph for this function:

void CEvolveTrafficView::DrawLaneChangeDetectors ( CMemDC pDC,
bool  DirPos 
) [private]

Definition at line 1141 of file EvolveTrafficView.cpp.

References m_Border_Lhs, m_DriveOnRight, m_LaneWidth, m_NoLanesDirNeg, and m_NoLanesDirPos.

Referenced by DrawDetectors().

01142 {
01143         CString str = "LC";
01144         CSize strSize = pDC->GetTextExtent(str);
01145         
01146         int DriveSide = m_DriveOnRight ? +1 : -1;
01147         int DirFactor = DirPos ? +1 : -1;
01148         int nLanes = DirPos ? m_NoLanesDirPos : m_NoLanesDirNeg;
01149 
01150         int xScrnLoc = m_Border_Lhs - strSize.cx - 2;
01151         int ypos = DirFactor* DriveSide * nLanes * m_LaneWidth /2;
01152 
01153         pDC->TextOut(xScrnLoc,ypos-strSize.cy/2,str);
01154 }

void CEvolveTrafficView::DrawLegend ( CMemDC pDC  )  [private]

Definition at line 938 of file EvolveTrafficView.cpp.

References CLR_BACKGRND, CLR_DET_COMPOSITION, CLR_DET_FLOWDENSITY, CLR_DET_HEADWAY, CLR_DET_OUTPUT, CLR_FEAT_GRADIENT, CLR_FEAT_SPEEDLIMIT, CLR_LEGEND_TEXT, DrawLegendElement(), DrawLegendSegment(), DrawLegendVehicle(), FEAT_GRADIENT, FEAT_SPEEDLIMIT, m_Border_Lhs, m_Border_Top, m_ClientRect, m_Scale, Round(), VEH_ID_CAR, VEH_ID_CRANE, VEH_ID_LARGETRUCK, VEH_ID_LOWLOADER, and VEH_ID_SMALLTRUCK.

Referenced by OnDraw().

00939 {
00940         pDC->SetTextColor(CLR_LEGEND_TEXT);
00941         pDC->SetBkColor(CLR_BACKGRND);
00942         
00943         CString strTime = "Real Time - Day: 00 - 00:00:00.00";
00944         CSize timeSize = pDC->GetTextExtent(strTime);
00945 
00946         // initial positions
00947         int ypos = Round(-(m_ClientRect.Height()/2)/m_Scale) + m_Border_Top;    // this keeps the timer position scale invariant
00948         int xpos = m_Border_Lhs + timeSize.cx + m_Border_Lhs;                                   // to avoid a clash with the timer
00949         int ygap = 20/m_Scale;
00950         int LineLength = m_Border_Lhs/m_Scale;  // why not!
00951         int LineToText = 20/m_Scale;
00952         
00953         DrawLegendVehicle(pDC, VEH_ID_CAR,                      "Car",                  LineToText, xpos, ypos);                        ypos += ygap;
00954         DrawLegendVehicle(pDC, VEH_ID_SMALLTRUCK,       "Small Truck",  LineToText, xpos, ypos);                        ypos += ygap;
00955         DrawLegendVehicle(pDC, VEH_ID_LARGETRUCK,       "Large Truck",  LineToText, xpos, ypos);                        ypos += ygap;
00956         DrawLegendVehicle(pDC, VEH_ID_CRANE,            "Crane",                LineToText, xpos, ypos);                        ypos += ygap;
00957         DrawLegendVehicle(pDC, VEH_ID_LOWLOADER,        "Low-loader",   LineToText, xpos, ypos);                        ypos += ygap;
00958 
00959         ypos -= 5*ygap; //reset ypos
00960         CSize strSize = pDC->GetTextExtent("Large Truck");
00961         xpos += LineLength+LineToText+strSize.cx+2*m_Border_Lhs;
00962         
00963         DrawLegendElement(pDC, LineLength, LineToText, xpos, ypos, "Output Detector", CLR_DET_OUTPUT);                          ypos += ygap;
00964         DrawLegendElement(pDC, LineLength, LineToText, xpos, ypos, "Flow-Density Detector", CLR_DET_FLOWDENSITY);       ypos += ygap;
00965         DrawLegendElement(pDC, LineLength, LineToText, xpos, ypos, "Headway Detector", CLR_DET_HEADWAY);                        ypos += ygap;
00966         DrawLegendElement(pDC, LineLength, LineToText, xpos, ypos, "Composition Detector", CLR_DET_COMPOSITION);        ypos += ygap;
00967 
00968         pDC->TextOut(xpos,ypos,"LC");
00969         pDC->TextOut(xpos+LineLength+LineToText,ypos,"Lane Change Detector");
00970 
00971         ypos -= 4*ygap; //reset ypos
00972         strSize = pDC->GetTextExtent("Lane Change Detector");
00973         xpos += LineLength+LineToText+strSize.cx+2*m_Border_Lhs;
00974 
00975         DrawLegendSegment(pDC, CLR_FEAT_SPEEDLIMIT, HS_DIAGCROSS, FEAT_SPEEDLIMIT, 
00976                 "Speed limit section", 50, LineToText, xpos, ypos);
00977         ypos += 2*ygap+5;
00978         DrawLegendSegment(pDC, CLR_FEAT_GRADIENT, HS_VERTICAL, FEAT_GRADIENT, 
00979                 "Gradient section", 5, LineToText, xpos, ypos);
00980 
00981 }

Here is the call graph for this function:

void CEvolveTrafficView::DrawLegendElement ( CMemDC pDC,
int  LineLength,
int  LineToText,
int  xpos,
int  ypos,
CString  str,
COLORREF  COL 
) [private]

Definition at line 1008 of file EvolveTrafficView.cpp.

Referenced by DrawLegend().

01010 {               
01011         CPen DetPen;
01012         
01013         DetPen.CreatePen(PS_SOLID, 3, COL);
01014         pDC->SelectObject(&DetPen);
01015         CSize strSize = pDC->GetTextExtent(str);
01016         pDC->TextOut(xpos+LineLength+LineToText,ypos,str);
01017         ypos += strSize.cy/2;
01018         pDC->MoveTo(xpos,ypos); 
01019         pDC->LineTo(xpos+LineLength,ypos);
01020 }

void CEvolveTrafficView::DrawSingleSegment ( CMemDC pDC,
COLORREF  COL,
WORD  HATCH,
WORD  FeatType,
int  val,
CRect  rect,
int  yTextOffset 
) [private]

Definition at line 1062 of file EvolveTrafficView.cpp.

References FEAT_GRADIENT, and FEAT_SPEEDLIMIT.

Referenced by DrawLegendSegment(), and DrawRoadSegments().

01064 {
01065         int x1 = rect.left;
01066         int x2 = rect.right;
01067         int y1 = rect.top;
01068         int y2 = rect.bottom;
01069 
01070         CPen SegEdgePen(PS_SOLID, 1, COL);
01071         CPen* pOldPen = pDC->SelectObject(&SegEdgePen);         // store previous pen
01072         CBrush SegBrush(HATCH,COL);
01073         CRect SegRect(x1,y1,x2,y2);
01074         CBrush* pOldBrush = pDC->SelectObject(&SegBrush);       // select drawing object and store previous one
01075         pDC->SetBkMode(TRANSPARENT);    // set background mode
01076         pDC->Rectangle(SegRect);                // draw a rectangle which will be patterned //FillRect(SegRect,&SegBrush);
01077         pDC->SelectObject(pOldBrush);   // reset previous objects
01078         
01079         CPen SegEndsPen(PS_SOLID, 3, COL);      // MAGIC NUMBER - seg pen width - keep same as detector pen width
01080         pDC->SelectObject(&SegEndsPen);
01081         pDC->MoveTo(x1,y1);     pDC->LineTo(x1,y2);
01082         pDC->MoveTo(x2,y1);     pDC->LineTo(x2,y2);
01083         
01084         pDC->SelectObject(pOldPen);                     // now reselect old pen
01085         
01086         CString str; 
01087         switch(FeatType)
01088         {
01089                 case FEAT_SPEEDLIMIT:
01090                         str.Format("%d km/h",val);
01091                         break;
01092                 case FEAT_GRADIENT:
01093                         str.Format("%d%%",val);
01094                         break;
01095                 default:
01096                         str.Format("%d km/h",val);
01097         }
01098         CSize strSize = pDC->GetTextExtent(str);
01099         pDC->TextOut((x1+x2)/2-strSize.cx/2,(y1+y2)/2-strSize.cy/2+yTextOffset,str);
01100 }

void CEvolveTrafficView::DrawRoadSegments ( CMemDC pDC  )  [private]

Definition at line 1022 of file EvolveTrafficView.cpp.

References CLR_FEAT_GRADIENT, CLR_FEAT_SPEEDLIMIT, DrawSingleSegment(), FEAT_GRADIENT, FEAT_SPEEDLIMIT, CRoadFeature::getDirPos(), CRoadFeature::getEnd(), CEvolveTrafficDoc::getRoadFeatures(), CRoadFeature::getStart(), CRoadFeature::getType(), CRoadFeature::getValue(), m_Border_Lhs, m_DriveOnRight, m_LaneWidth, m_NoLanesDirNeg, m_NoLanesDirPos, m_pDoc, M_PER_S_TO_KM_PER_H, and Round().

Referenced by DrawRoad().

01023 {
01024         CObArray vSeg;  vSeg.Copy( *(m_pDoc->getRoadFeatures()) );
01025         for(int i = 0; i < vSeg.GetSize(); i++)
01026         {
01027                 CRoadFeature* pFeat = reinterpret_cast<CRoadFeature*>(vSeg.GetAt(i));
01028                 WORD FeatType = pFeat->getType();
01029                 int FeatValue = 0;
01030                 COLORREF COL;
01031                 WORD HATCH;
01032                 switch(FeatType)
01033                 {
01034                         case FEAT_SPEEDLIMIT:
01035                                 COL = CLR_FEAT_SPEEDLIMIT;
01036                                 HATCH = HS_DIAGCROSS;
01037                                 FeatValue = Round(pFeat->getValue()*M_PER_S_TO_KM_PER_H);
01038                                 break;
01039                         case FEAT_GRADIENT:
01040                                 COL = CLR_FEAT_GRADIENT;
01041                                 HATCH = HS_VERTICAL;
01042                                 FeatValue = Round(pFeat->getValue());
01043                                 break;
01044                         default:
01045                                 COL = CLR_FEAT_SPEEDLIMIT;
01046                 }
01047 
01048                 bool DirPos = pFeat->getDirPos();
01049                 int DriveSide = m_DriveOnRight ? +1 : -1;
01050                 int DirFactor = DirPos ? +1 : -1;
01051                 int nLanes = DirPos ? m_NoLanesDirPos : m_NoLanesDirNeg;
01052                 
01053                 int x1 = pFeat->getStart() + m_Border_Lhs;
01054                 int x2 = pFeat->getEnd() + m_Border_Lhs;
01055                 int y1 = 0;
01056                 int y2 = DirFactor * DriveSide * nLanes * m_LaneWidth;
01057                 CRect segRect(x1,y1,x2,y2);
01058                 DrawSingleSegment(pDC, COL, HATCH, FeatType, FeatValue, segRect,m_LaneWidth/2);
01059         }
01060 }

Here is the call graph for this function:

void CEvolveTrafficView::DrawSingleDetector ( CMemDC pDC,
COLORREF  COL,
int  Loc,
bool  DirPos 
) [private]

Definition at line 1156 of file EvolveTrafficView.cpp.

References m_Border_Lhs, m_DriveOnRight, m_LaneWidth, m_NoLanesDirNeg, and m_NoLanesDirPos.

Referenced by DrawDetectors().

01157 {
01158         // Draw detectors
01159         CPen DetectorPen(PS_SOLID, 3, COL);     // MAGIC NUMBER - detector pen width
01160         pDC->SelectObject(&DetectorPen);
01161 
01162         int ScrnLoc = Loc + m_Border_Lhs;
01163 
01164         int DriveSide = m_DriveOnRight ? +1 : -1;
01165         int DirFactor = DirPos ? +1 : -1;
01166         int nLanes = DirPos ? m_NoLanesDirPos : m_NoLanesDirNeg;
01167 
01168         int ypos = 0;//DirFactor*DriveSide*m_RoadWidth/2;// + m_ClientRect.Height()/2;  // bottom/top of road
01169         pDC->MoveTo(ScrnLoc,ypos);                                                                                              // start at bottom/top
01170         //ypos = ypos - DirFactor* DriveSide * nLanes * m_LaneWidth;                            // distance to top/bottom
01171         ypos = DirFactor* DriveSide * nLanes * m_LaneWidth;
01172         pDC->LineTo(ScrnLoc,ypos);                                                                                              // draw line
01173 }

void CEvolveTrafficView::DrawLegendSegment ( CMemDC pDC,
COLORREF  COL,
WORD  HATCH,
WORD  FeatType,
CString  str,
int  value,
int  LineToText,
int  xpos,
int  ypos 
) [private]

Definition at line 995 of file EvolveTrafficView.cpp.

References DrawSingleSegment(), and m_Scale.

Referenced by DrawLegend().

00997 {
00998         int rectWidth = 80/m_Scale;
00999         int rectHeight = 30/m_Scale;
01000         
01001         CRect segRect(xpos,ypos,xpos+rectWidth, ypos+rectHeight);
01002         DrawSingleSegment(pDC, COL, HATCH, FeatType, value, segRect, 0);
01003         
01004         CSize strSize = pDC->GetTextExtent(str);
01005         pDC->TextOut(xpos+rectWidth+LineToText, ypos+rectHeight/2-strSize.cy/2,str);
01006 }

Here is the call graph for this function:

void CEvolveTrafficView::DrawLegendVehicle ( CMemDC pDC,
WORD  VehType,
CString  str,
int  LineToText,
int  xpos,
int  ypos 
) [private]

Definition at line 983 of file EvolveTrafficView.cpp.

References DrawVehicleAt(), and m_Scale.

Referenced by DrawLegend().

00984 {       
00985         int rectWidth = 20/m_Scale;
00986         int rectHeight = 10/m_Scale;
00987         
00988         CSize strSize = pDC->GetTextExtent(str);
00989         pDC->TextOut(xpos+rectWidth+LineToText, ypos,str);      
00990         ypos += strSize.cy/2 - rectHeight/2;
00991         CRect VehRect(xpos,ypos,xpos+rectWidth, ypos+rectHeight);
00992         DrawVehicleAt(pDC, VehType, VehRect);
00993 }

Here is the call graph for this function:


Member Data Documentation

Definition at line 85 of file EvolveTrafficView.h.

Referenced by OnDraw(), and OnToolsPrefs().

Definition at line 86 of file EvolveTrafficView.h.

Referenced by DrawVehicle(), and OnToolsPrefs().

Definition at line 90 of file EvolveTrafficView.h.

Referenced by DrawRoad(), DrawRuler(), DrawVehicle(), initRoad(), and OnLButtonDown().

Definition at line 91 of file EvolveTrafficView.h.

Referenced by DrawRoad(), DrawVehicle(), initRoad(), and OnLButtonDown().

Definition at line 92 of file EvolveTrafficView.h.

Referenced by initRoad().

Definition at line 93 of file EvolveTrafficView.h.

Referenced by initRoad().

Definition at line 95 of file EvolveTrafficView.h.

Referenced by OnToolsPrefs().

Definition at line 98 of file EvolveTrafficView.h.

Referenced by initRoad(), OnInitialUpdate(), OnPrepareDC(), and SetZoomScale().

Definition at line 101 of file EvolveTrafficView.h.

Referenced by doSimFinished(), and UpdateProgressBar().

Definition at line 128 of file EvolveTrafficView.h.

Referenced by setMaxTimeWarp(), and ValidateTimeWarp().

Definition at line 129 of file EvolveTrafficView.h.

Referenced by doLoop(), and initRoad().

Definition at line 130 of file EvolveTrafficView.h.

Referenced by OnToolsPause().

Definition at line 131 of file EvolveTrafficView.h.

Referenced by doLoop(), doSimStart(), DrawTimer(), OnRunInvisible(), and OnToolsPause().

Definition at line 132 of file EvolveTrafficView.h.

Referenced by DrawTimer(), and OnRunInvisible().

Definition at line 133 of file EvolveTrafficView.h.

Referenced by doSimStart(), DrawTimer(), and OnRunInvisible().

Definition at line 135 of file EvolveTrafficView.h.

Referenced by doLoop().

Definition at line 136 of file EvolveTrafficView.h.

Referenced by UpdateProgressBar().

Definition at line 138 of file EvolveTrafficView.h.

Referenced by DrawLegend(), DrawTimer(), OnPrepareDC(), and SetZoomScale().

Definition at line 139 of file EvolveTrafficView.h.

Definition at line 140 of file EvolveTrafficView.h.

double CEvolveTrafficView::m_Scale [private]

Definition at line 145 of file EvolveTrafficView.h.

Referenced by DrawVehicle(), FindVehicle(), and OnToolsPrefs().

Definition at line 146 of file EvolveTrafficView.h.

Referenced by DrawVehicle(), and OnToolsPrefs().

Definition at line 147 of file EvolveTrafficView.h.

Referenced by DrawRuler(), and OnToolsPrefs().

Definition at line 148 of file EvolveTrafficView.h.

Referenced by DrawRuler(), initRoad(), and OnToolsPrefs().

Definition at line 150 of file EvolveTrafficView.h.

Referenced by DrawLegend(), DrawTimer(), initRoad(), and OnToolsPrefs().

Definition at line 151 of file EvolveTrafficView.h.

Referenced by initRoad(), and OnToolsPrefs().

Definition at line 153 of file EvolveTrafficView.h.

Referenced by initRoad(), and OnToolsPrefs().

Definition at line 155 of file EvolveTrafficView.h.

Referenced by DrawRoad(), and initRoad().

Definition at line 156 of file EvolveTrafficView.h.

Referenced by DrawRoad(), initRoad(), and OnLButtonDown().

Definition at line 159 of file EvolveTrafficView.h.

Referenced by DrawRoad(), initRoad(), OnConfigFeatures(), OnConfigMetrics(), and OnKeyDown().

Definition at line 160 of file EvolveTrafficView.h.

Referenced by DrawRuler(), and initRoad().

Definition at line 161 of file EvolveTrafficView.h.

Referenced by DrawRoad(), and initRoad().

Definition at line 163 of file EvolveTrafficView.h.

Referenced by doLoop(), doSimFinished(), FindVehicle(), and OnDraw().

CProgressBar* CEvolveTrafficView::m_pProgBar [private]

Definition at line 166 of file EvolveTrafficView.h.

Referenced by doSimFinished(), doSimStart(), and UpdateProgressBar().

CMessageTip CEvolveTrafficView::m_DataTip [private]

Definition at line 167 of file EvolveTrafficView.h.

Referenced by OnInitialUpdate(), and OnLButtonDown().

Definition at line 169 of file EvolveTrafficView.h.

Referenced by SetZoomScale().

Definition at line 170 of file EvolveTrafficView.h.

Referenced by OnInitialUpdate().

Definition at line 172 of file EvolveTrafficView.h.

Referenced by DrawLegend(), DrawRuler(), and DrawTimer().

Definition at line 173 of file EvolveTrafficView.h.

Referenced by DrawDetectors(), and DrawLegend().

Definition at line 174 of file EvolveTrafficView.h.

Referenced by DrawDetectors(), and DrawLegend().

Definition at line 175 of file EvolveTrafficView.h.

Referenced by DrawDetectors(), and DrawLegend().

Definition at line 176 of file EvolveTrafficView.h.

Referenced by DrawDetectors(), and DrawLegend().

Definition at line 177 of file EvolveTrafficView.h.

Referenced by DrawLegend(), and DrawRoadSegments().

Definition at line 178 of file EvolveTrafficView.h.

Referenced by DrawLegend(), and DrawRoadSegments().

Definition at line 179 of file EvolveTrafficView.h.

Referenced by DrawLegend(), and DrawTimer().

Definition at line 180 of file EvolveTrafficView.h.

Referenced by DrawRoad().

Definition at line 181 of file EvolveTrafficView.h.

Referenced by DrawRoad().

Definition at line 182 of file EvolveTrafficView.h.

Referenced by DrawRuler().

Definition at line 183 of file EvolveTrafficView.h.

Referenced by DrawRuler().

Definition at line 185 of file EvolveTrafficView.h.

Referenced by DrawVehicleAt().

Definition at line 186 of file EvolveTrafficView.h.

Referenced by DrawVehicleAt().

Definition at line 187 of file EvolveTrafficView.h.

Referenced by DrawVehicleAt().

Definition at line 188 of file EvolveTrafficView.h.

Referenced by DrawVehicleAt().

Definition at line 189 of file EvolveTrafficView.h.

Referenced by DrawVehicleAt().


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

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