Home |
Class PegMultiLineChart HMI (Human-Machine Interface) Classes |
Class PegMultiLineChartPegMultiLineChart supports the drawing of discrete lines which use the same x and y scaling. class PegMultiLineChart : public PegChart { public: PegMultiLineChart(const PegRect& Rect, LONG lMinX, LONG lMaxX, LONG lMinY, LONG lMaxY, PEGUINT wXScale = 0, PEGUINT wYScale = 0); virtual void Draw(void); virtual PEGINT Message(const PegMessage& Mesg); virtual void RecalcSize(const PegRect& NewSize, BOOL bRedraw = TRUE); void DrawNewLineData(PegChartLine * pLine, PegChartPoint * pNew, PegChartPoint * pPrevious = NULL); void RecalcLine(UCHAR ucID, BOOL bRedraw = TRUE); void ResetLine(UCHAR ucID, BOOL bRedraw = TRUE); void ResetAllLines(BOOL bRedraw = TRUE); UCHAR AddLine(COLORVAL tColor); BOOL RemoveLine(UCHAR ucID); PegChartPoint * AddPoint(UCHAR ucID, LONG lX, LONG lY, BOOL bRedraw = TRUE); PegChartPoint * InsertPoint(UCHAR ucID, PegChartPoint * pPreviousPoint, LONG lX, LONG lY, BOOL bRedraw = TRUE); PegChartLine * GetFirstLine(void) const; PegChartLine * GetLineFromID(UCHAR ucID); }; Style FlagsPegMultiLineChart supports the same styles as PegChart. ConstructorThe constructor is identical to the base class PegChart. Method DrawPegMultiLineChart overrides the Draw() function to draw the individual lines. Method MessagePegMultiLineChart overrides the Message method in order to provide appropriate layout recalculation when i's 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 given line. Method ResetLineRemoves all of the points associated with the given line. Method ResetAllLinesCalls ResetLine(UCHAR) for each line in the chart. Method AddPointAdds a point to the end of the line segment identified by ucID and returns a pointer to the point. Method InsertPointInserts a point after the point pointed to by pPoint for the given line segment. It returns a pointer to the newly created point. Method GetFirstLineReturns the first line segment, or NULL if there are no lines in the chart. Method GetLineFromIDReturns a pointer to the line segment that has the ID ucID, or NULL if it could not find it. Method AddLineAdds a new line to the chart. tColor is used to draw the line in the specified color. The return value is the ID of the new line. It is possible to add a maximum of 256 lines to a single chart. Method RemoveLineRemoves a line from the chart. It returns a boolean describing its success. When a line is removed from the chart, its ID is not reused. ExamplesThe following code snippet produces the PegMultiLineChart pictured below. PegMultiLineChart * pLineChart = new PegMultiLineChart(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); UCHAR LineID = pLineChart->AddLine(LIGHTGREEN); pLineChart->AddPoint(LineID, 100, 100); pLineChart->AddPoint(LineID, 200, 200); pLineChart->AddPoint(LineID, 300, 300); PegChartPoint * pPoint = pLineChart->AddPoint(LineID, 400, 400); pLineChart->AddPoint(LineID, 500, 500); pLineChart->AddPoint(LineID, 600, 600); pLineChart->AddPoint(LineID, 700, 800); pLineChart->InsertPoint(LineID, pPoint, 450, 0); UCHAR LineID2 = pLineChart->AddLine(CYAN); pLineChart->AddPoint(LineID2, 0, 0); pLineChart->AddPoint(LineID2, 100, 500); pLineChart->AddPoint(LineID2, 900, 0);
|