00001
00002
00004
00005 #if !defined(AFX_EVOLVETRAFFICVIEW_H__A8EBCCBD_29B8_4AA3_BF81_C9D991006520__INCLUDED_)
00006 #define AFX_EVOLVETRAFFICVIEW_H__A8EBCCBD_29B8_4AA3_BF81_C9D991006520__INCLUDED_
00007
00008 #if _MSC_VER > 1000
00009 #pragma once
00010 #endif // _MSC_VER > 1000
00011
00012 #include "MiscCtrls/ProgressBar.h"
00013 #include "MiscCtrls/ZoomView.h"
00014 #include "MiscCtrls/MessageTip.h"
00015
00018 class CEvolveTrafficView : public CScrollView
00019 {
00020 protected:
00021 CEvolveTrafficView();
00022 DECLARE_DYNCREATE(CEvolveTrafficView)
00023
00024
00025 public:
00026 CEvolveTrafficDoc* GetDocument();
00027
00028
00029 public:
00030
00031
00032
00033
00034 public:
00035 virtual void OnDraw(CDC* pDC);
00036 virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
00037 virtual void OnPrepareDC(CDC* pDC, CPrintInfo* pInfo = NULL);
00038 protected:
00039 virtual void OnInitialUpdate();
00040 virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
00041 virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
00042 virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
00043
00044
00045
00046 public:
00047 void UpdateProgressBar();
00048 void doLoop(int curTime);
00049 void setMaxTimeWarp();
00050 virtual ~CEvolveTrafficView();
00051 #ifdef _DEBUG
00052 virtual void AssertValid() const;
00053 virtual void Dump(CDumpContext& dc) const;
00054 #endif
00055
00056 protected:
00057
00058
00059 protected:
00060
00061 afx_msg void OnConfigSim();
00062 afx_msg void OnRunVisible();
00063 afx_msg void OnSize(UINT nType, int cx, int cy);
00064 afx_msg void OnConfigTraf();
00065 afx_msg void OnToolsPrefs();
00066 afx_msg void OnToolsPause();
00067 afx_msg void OnToolsZoomin();
00068 afx_msg void OnToolsZoomout();
00069 afx_msg void OnToolsSpeedup();
00070 afx_msg void OnToolsSlowdown();
00071 afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
00072 afx_msg void OnRunInvisible();
00073 afx_msg void OnConfigFeatures();
00074 afx_msg void OnConfigMetrics();
00075 afx_msg void OnUpdateToolsPause(CCmdUI* pCmdUI);
00076 afx_msg void OnUpdateToolsSpeedup(CCmdUI* pCmdUI);
00077 afx_msg void OnUpdateToolsSlowdown(CCmdUI* pCmdUI);
00078 afx_msg void OnToolsStop();
00079 afx_msg void OnUpdateToolsStop(CCmdUI* pCmdUI);
00080 afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
00081 afx_msg void OnFileSaveImage();
00082
00083 DECLARE_MESSAGE_MAP()
00084 private:
00085 bool m_bShowLegend;
00086 bool m_bShowVelocity;
00087 Vehicle* FindVehicle(int iLane, int location);
00088 BOOL WriteWindowToDIB( LPTSTR szFile, CWnd *pWnd );
00089
00090 int m_BtmEdge;
00091 int m_TopEdge;
00092 int m_nLanesOnBtm;
00093 int m_nLanesOnTop;
00094 bool m_DriveOnRight;
00095 double m_ExaggerateWidths;
00096 void SetZoomScale(double newScale);
00097 void ValidateTimeWarp();
00098 CSize m_DrawArea;
00099
00100 void doSimStart();
00101 int m_LastPercentComplete;
00102
00103 int Round(double val) {return int(val + 0.5);};
00104
00105 void doSimFinished(bool bCompleted);
00106 void UpdateDrawRegion();
00107 void SettingUpdateRedraw();
00108
00109 void initRoad();
00110 void DrawRoad(CMemDC *pDC);
00111 void DrawRuler(CMemDC *pDC);
00112 void DrawTimer(CMemDC *pDC);
00113 void DrawVehicle(CMemDC *pDC, Vehicle* veh);
00114 void DrawVehicleAt(CMemDC *pDC, WORD VEH_ID, CRect VehRect);
00115 void DrawDetectors(CMemDC *pDC);
00116 void DrawLaneChangeDetectors(CMemDC *pDC, bool DirPos);
00117 void DrawLegend(CMemDC *pDC);
00118 void DrawLegendElement(CMemDC *pDC, int LineLength, int LineToText,
00119 int xpos, int ypos, CString str, COLORREF COL);
00120 void DrawSingleSegment(CMemDC *pDC, COLORREF COL, WORD HATCH,
00121 WORD FeatType, int val, CRect rect, int yTextOffset);
00122 void DrawRoadSegments(CMemDC *pDC);
00123 void DrawSingleDetector(CMemDC *pDC, COLORREF COL, int Loc, bool DirPos);
00124 void DrawLegendSegment(CMemDC *pDC, COLORREF COL, WORD HATCH,
00125 WORD FeatType, CString str, int value, int LineToText, int xpos, int ypos);
00126 void DrawLegendVehicle(CMemDC *pDC, WORD VehType, CString str, int LineToText, int xpos, int ypos);
00127
00128 double m_MaxTimeWarp;
00129 int m_SimTimeStep;
00130 int m_PauseTime;
00131 int m_StartRealTime;
00132 int m_CurentRealTime;
00133 double m_CurentSimTime;
00134 BOOL m_bPause;
00135 int m_TimerSpeed;
00136 int m_PercentComplete;
00137
00138 CRect m_ClientRect;
00139 int m_YCoordTop;
00140 RECT m_RoadRect;
00141 bool m_bInSimulation;
00142
00143 double m_Scale;
00144 double m_TimeWarp;
00145 double m_VehicleLengthScale;
00146 double m_VehicleWidth;
00147 double m_TickLength;
00148 int m_TickStep;
00149 double m_LaneWidth;
00150 double m_Border_Top;
00151 double m_Border_Btm;
00152 double m_Border_Lhs;
00153 double m_Border_Rhs;
00154
00155 int m_NoDirections;
00156 int m_NoLanes;
00157 int m_NoLanesDirPos;
00158 int m_NoLanesDirNeg;
00159 int m_RoadLength;
00160 int m_NoTicks;
00161 int m_RoadWidth;
00162
00163 M2D m_VehiclePositions;
00164
00165 CEvolveTrafficDoc* m_pDoc;
00166 CProgressBar* m_pProgBar;
00167 CMessageTip m_DataTip;
00168
00169 double MIN_VIEW_SCALE;
00170 double DATATIP_DELAY;
00171
00172 COLORREF CLR_BACKGRND;
00173 COLORREF CLR_DET_COMPOSITION;
00174 COLORREF CLR_DET_FLOWDENSITY;
00175 COLORREF CLR_DET_HEADWAY;
00176 COLORREF CLR_DET_OUTPUT;
00177 COLORREF CLR_FEAT_GRADIENT;
00178 COLORREF CLR_FEAT_SPEEDLIMIT;
00179 COLORREF CLR_LEGEND_TEXT;
00180 COLORREF CLR_ROAD_LINES;
00181 COLORREF CLR_ROAD_SURFACE;
00182 COLORREF CLR_RULER_LINES;
00183 COLORREF CLR_RULER_TEXT;
00184
00185 COLORREF VEH_COLOR_CAR;
00186 COLORREF VEH_COLOR_SMALLTRUCK;
00187 COLORREF VEH_COLOR_LARGETRUCK;
00188 COLORREF VEH_COLOR_CRANE;
00189 COLORREF VEH_COLOR_LOWLOADER;
00190 };
00191
00192 #ifndef _DEBUG // debug version in EvolveTrafficView.cpp
00193 inline CEvolveTrafficDoc* CEvolveTrafficView::GetDocument()
00194 { return (CEvolveTrafficDoc*)m_pDocument; }
00195 #endif
00196
00198
00199
00200
00201
00202 #endif // !defined(AFX_EVOLVETRAFFICVIEW_H__A8EBCCBD_29B8_4AA3_BF81_C9D991006520__INCLUDED_)