示例#1
0
void CPage_Node_LaneTurn::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	CRect PlotRect;
	GetClientRect(PlotRect);
	m_PlotRect = PlotRect;

		m_PlotRect.top += 35;
		m_PlotRect.bottom -= 35;
		m_PlotRect.left += 450;
		m_PlotRect.right -= 50;

	DrawMovements(&dc,m_PlotRect);
}
void CPage_Node_Movement::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	CRect PlotRect;
	GetClientRect(PlotRect);
	m_PlotRect = PlotRect;

	m_PlotRect.top += 55;
	m_PlotRect.bottom -= 290;
	m_PlotRect.left += 50;
	m_PlotRect.right -= 50;

	int GreenTimeDiagramHeight = 25;

	DrawMovements(&dc,m_PlotRect,false);


}
void CPage_Node_Phase::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	CRect PlotRect;
	GetClientRect(PlotRect);
	m_PlotRect = PlotRect;

	m_PlotRect.top += 35;
	m_PlotRect.bottom -= 250;
	m_PlotRect.left += 50;
	m_PlotRect.right -= 50;

	int GreenTimeDiagramHeight = 25;
	if(m_bMultiPhaseDisplay == false)
		DrawMovements(&dc,m_PlotRect,false);

	if(m_bMultiPhaseDisplay == true)
	{
		int number_of_rectangles = 8;

		int width = m_PlotRect.Width ()/4;
		int height = (m_PlotRect.Height  ()- 2*GreenTimeDiagramHeight)/2;

		CRect OriginalPlotRect = m_PlotRect;
		CRect GreenTimePlotRect = m_PlotRect;

		GreenTimePlotRect.left  +=5;
		GreenTimePlotRect.right   -=5;

		GreenTimePlotRect.top = m_PlotRect.bottom - 2*GreenTimeDiagramHeight;
		GreenTimePlotRect.bottom  = m_PlotRect.bottom - 1*GreenTimeDiagramHeight;

		CRect GreenTimePlotRect2 = GreenTimePlotRect;


		GreenTimePlotRect2.top = GreenTimePlotRect.bottom +5;
		GreenTimePlotRect2.bottom  = GreenTimePlotRect2.top+ GreenTimeDiagramHeight;


		CBrush  RedBrush(RGB(255,0,0)); 

		dc.SelectObject(&RedBrush);

		dc.Rectangle (GreenTimePlotRect);

		if(m_RingTypeComboBox.GetCurSel () ==1)  //dual ring
		{
			dc.Rectangle (GreenTimePlotRect2);
		}

		for(int p = 1; p <= number_of_rectangles; p++)
		{
			int column = (p-1)%4 ;
			//		int column = p-1;
			int row  = 0;

			if(p>=5)
				row  = 1;

			CRect PhaseRect;

			PhaseRect.left = OriginalPlotRect.left + column* width;
			PhaseRect.right  = OriginalPlotRect.left + (column+1)* width;

			PhaseRect.top = OriginalPlotRect.top + row* height;
			PhaseRect.bottom   = OriginalPlotRect.top + (row+1)* height;

			m_SelectedPhaseNumber = p;


			// update m_PlotRect for drawing links
			m_PlotRect = PhaseRect;


			BOOL bMovementIncluded = false;
			DTANode* pNode  = m_pDoc->m_NodeNoMap [m_CurrentNodeID];


			for (unsigned int i=0;i< pNode->m_MovementDataMap["ALLDAY"].m_MovementVector .size();i++)
			{

				DTANodeMovement movement = pNode->m_MovementDataMap["ALLDAY"].m_MovementVector[i];

				bMovementIncluded = m_pDoc->IfMovementIncludedInPhase(m_CurrentNodeNumber ,  m_pDoc->m_TimingPlanVector[ m_SelectedTimingPlanNo].timing_plan_name,m_SelectedPhaseNumber, movement.in_link_from_node_id,movement.out_link_to_node_id );

				if(bMovementIncluded)
					break;
			}
			// draw phase diagram when there is movement
			if(bMovementIncluded)

			{
				DrawMovements(&dc,PhaseRect, true);
				int row = 5;
				float GreenStartTime = atof(m_PhasingGrid.GetItemText(row,p));

				row = 6;
				float PhaseEndTime = atof(m_PhasingGrid.GetItemText(row,p));

				if(PhaseEndTime <= GreenStartTime +1)  //skip empty movement
					continue;

				row = 3;
				float Yellow = atof(m_PhasingGrid.GetItemText(row,p));

				row =4;
				float AllRed = atof(m_PhasingGrid.GetItemText(row,p));


				if(m_RingTypeComboBox.GetCurSel () ==0)  //single ring
					DrawPhaseGreenTimeBand(&dc,GreenTimePlotRect,m_CycleLength,GreenStartTime,PhaseEndTime, Yellow, AllRed);
				else
				{
					if(p<=4)
						DrawPhaseGreenTimeBand(&dc,GreenTimePlotRect,m_CycleLength,GreenStartTime,PhaseEndTime, Yellow, AllRed);
					else
						DrawPhaseGreenTimeBand(&dc,GreenTimePlotRect2,m_CycleLength,GreenStartTime,PhaseEndTime, Yellow, AllRed);

				}
			}

		}

		m_SelectedPhaseNumber= 0;

	}

}