Home |
Class PegLineChart HMI (Human-Machine Interface) Classes |
Class PegLineChartPegLineChart is a simple abstract down from PegChart and supports the displaying of a single line on a given scale. class PegLineChart : public PegChart { public: PegLineChart(const PegRect& Rect, LONG lMinX, LONG lMaxX, LONG lMinY, LONG lMaxY, PEGUINT wXScale, PEGUINT wYScale); virtual void Draw(void); virtual PEGINT Message(const PegMessage& Mesg); virtual void RecalcSize(const PegRect& NewSize, BOOL bRedraw = TRUE); void RecalcLine(); void ResetLine(); PegChartPoint * AddPoint(LONG lX, LONG lY); PegChartPoint * InsertPoint(PegChartPoint * pPreviousPoint, LONG lX, LONG lY); PegChartPoint * RemovePoint(PegChartPoint * pPoint); PegChartPoint * GetFirstPoint(void) const; COLORVAL GetLineColor(void) const; COLORVAL SetLineColor(COLORVAL cColor); }; Style FlagsPegLineChart supports the same styles as PegChart. ConstructorThe constructor is identical to the base class PegChart. Method DrawPegLineChart overrides the Draw() function to draw the line segments that make up the line. Method MessagePegLineChart overrides the Message method in order to provide appropriate layout recalculation when its parent is moved, or optionally, resized. Method RecalcSizeThis method is overridden in order to ensure that the line data is up to date. In other words, if the chart is moved or resized, the screen coordinates associated with a given data point will change. In order to keep up with these changes, this method calls the RecalcLine method to update the screen coordinates of all the data points associated with the line. Method RecalcLineForces a recalculation of the screen coordinates for every point on the line. Method ResetLineRemoves all of the points associated with the line. Method AddPointAdds a point to the end of the line segment and returns a pointer to the point. Method InsertPointInserts a point after the point pointed to by pPoint and returns a pointer to the point. Method RemovePointRemoves the point pointed to by pPoint. It returns a pointer to the point proceeding the deleted point, or NULL if there is none. Method GetFirstPointReturns the first point of the line segment. Method GetLineColorReturns the COLORVAL used for determining the color of the line. Method SetLineColorSets the COLORVAL used for determining the color the line. ExamplesThe following code snippet produces the PegLineChart pictured below. PegLineChart * pLineChart = new PegLineChart(Rect, 0, 1000, 0, 1000, 100, 100); pLineChart->SetXLabelScale(200); pLineChart->SetExStyle(CS_DRAWXTICS | CS_DRAWYTICS | CS_DRAWXGRID | CS_DRAWYGRID | CS_AUTOSIZE | CS_DRAWYLABELS | CS_DRAWXLABELS); pLineChart->AddPoint(100, 100); pLineChart->AddPoint(200, 200); pLineChart->AddPoint(300, 300); PegChartPoint * pPoint = pLineChart->AddPoint(400, 400); pLineChart->AddPoint(500, 500); pLineChart->AddPoint(600, 600); pLineChart->AddPoint(700, 800); pLineChart->InsertPoint(pPoint, 450, 0);
|