Home |
Class PegChart HMI (Human-Machine Interface) Classes |
Class PegChartPegChart is the base class for all of the charts in the PEG library. PegChart is a virtual base class, therefore, it is not possible to instantiate an object of this type directly at run time. The main job of PegChart is to provide a basic framework for its derived children. It does this by keeping track of an extra style variable, over and above the one retained by PegThing. It also provides the algorithms for calculating the layout of the chart based on whether or not the chart will be drawing labels and tick marks. And, lastly, it provides drawing methods for the common elements of a chart (ie., X and Y tick marks, labels and grid lines). class PegChart : public PegThing { public: PegChart(const PegRect& rect, LONG lMinX = 0, LONG lMaxX = 0, LONG lMinY = 0, LONG lMaxY = 0, PEGUINT wMajorXScale = 0, PEGUINT wMajorYScale = 0); virtual void Draw(void); virtual PEGINT Message(const PegMessage& Mesg); virtual void ParentShift(int xOffset, int yOffset); virtual void RecalcLayout(BOOL bRedraw = TRUE); virtual void RecalcSize(const PegRect& NewRect, BOOL bRedraw = TRUE); virtual void MapDataToPoint(PegChartPoint * pPoint); virtual void MapPointToData(PegChartPoint * pPoint); LONG GetMinX(void) const; LONG GetMaxX(void) const; LONG GetMinY(void) const; LONG GetMaxY(void) const; PEGUINT GetMajorXScale(void) const; PEGUINT GetMajorYScale(void) const; PEGUINT GetTicSize(void) const; PEGUINT GetXLabelScale(void) const; PEGUINT GetYLabelScale(void) const; void SetMinX(LONG lData); void SetMaxX(LONG lData); void SetMinY(LONG lData); void SetMaxY(LONG lData); void SetMajorXScale(PEGUINT wScale); void SetMajorYScale(PEGUINT wScale); void SetTicSize(PEGUINT wSize); void SetXLabelScale(PEGUINT wScale); void SetYLabelScale(PEGUINT wScale); PEGUINT GetExStyle(void) const; void SetExStyle(PEGUINT wStyle); void SetYLabelWidth(PEGUINT wWidth); void SetXLabelHeight(PEGUINT wHeight); PegFont * GetFont(void) const; void SetFont(PegFont * pFont); PegRect GetChartRegion(void) const; }; Style FlagsCS_DRAWXGRID, CS_DRAWYGRID, CS_DRAWXTICS, CS_DRAWYTICS, CS_AUTOSIZE, CS_DRAWXLABELS, CS_DRAWYLABELS. ConstructorLike most PegThing derived objects, you pass it the rectangle you wish for it to occupy. If you have CS_AUTOSIZE turned on, you may just want to pass it the parent's mClient rectangle. The next four LONG values specify the minimum and maximum values for X and Y. The last two parameters are for setting the tick mark frequency for the X and Y axis, respectively. For instance, if your minimum Y value is -100 and your maximum Y value is 900, and you specify a Y scale of 100, if the CS_DRAWYTICS bit is set in the extended style flag, you will see tick marks on the Y axis starting at -100 and incrementing 100 all the way to 900. Therefore, there will be 11 tick marks drawn on the Y axis. If you were to also turn on the CS_DRAWYGRID bit, you would see a grid line at the same interval as the tick marks. Label scaling, or interval, is independant of the tick mark/grid line scaling. Therefore, it is possible to specify tick marks to appear at intervals of 100, while specifying labels to be drawn every 200. No matter the scaling, all drawing starts at the minimum value and works its way toward the maximum value until it meets or exceeds the maximum value. This holds true for both the X and Y axis. Method DrawPegChart overrides the Draw() function to draw the background color of the chart area, and, if specified, the optional tick marks, labels and grid lines. Method MessagePegChart overrides the Message method in order to provide appropriate layout recalculation when its parent is moved, or optionally, resized. Method RecalcLayoutCalculates the region used for drawing the actual chart (represented internally by mChartRegion). This method takes into account the drawing of tick marks and labels. This method is typically not called by objects outside of the chart classes. Method RecalcSizeResets the chart's size to the new rectangle, then calls RecalcLayout and passes through bRedraw. This method is typically not called by objects outside of the chart classes. Method MapDataToPointConverts the data points held in pPoint to screen coordinates based on the size of the mChartRegion of the chart, and the minimum and maximum allowable values for X and Y. It then puts the coordinates in the appropriate pPoint members. This method is typically not called by objects outside of the chart classes. Method MapPointToDataThis method does the opposite of MapDataToPoint. In that it takes screen coordinates and converts them to data points based on the same criteria as MapDataToPoint. This method is typically not called by objects outside of the chart classes. Method GetMinXReturns the minimum allowable value for X. Method GetMaxXReturns the maximum allowable value for X. Method GetMinYReturns the minimum allowable value for Y. Method GetMaxYReturns the maximum allowable value for Y. Method GetMajorXScaleReturns the interval for drawing tick marks and grid lines along the X axis. Method GetMajorYScaleReturns the interval for drawing tick marks and grid lines along the Y axis. Method GetTicSizeReturns the integral value used to determine the size of the tick marks. This value equates to number of pixels used for the length of a tick mark. Method GetXLabelScaleReturns the interval for drawing labels along the X axis. Method GetYLabelScaleReturns the interval for drawing labels along the Y axis. Method SetMinXSets the minimum value for X. Method SetMaxXSets the maximum value for X. Method SetMinYSets the minimum value for Y. Method SetMinYSets the minimum value for Y. Method SetMajorXScaleSets the interval for drawing tick marks and grid lines along the X axis. Method SetMajorYScaleSets the interval for drawing tick marks and grid lines along the Y axis. Method SetTicSizeSets the size, in pixels, of the tick marks. Method SetXLabelScaleSets the interval for drawing labels along the X axis. Method SetYLabelScaleSets the interval for drawing labels along the X axis. Method GetExStyleReturns the current value of mwExStyle. Method SetExStyleSets the current value of mwExStyle. These values may be bitwise OR'd together. Method GetFontReturns a pointer to the current font being used to draw axis labels. Method SetFontSets the font used for drawing axis labels. Method GetChartRegionReturns the rectangle that represents the area where the chart is actually being drawn. This rectangle's size and position is based on the position and size of its parent (if CS_AUTOSIZE is set), as well as any tick marks or labels that it may be drawing. In other words, this rectangle roughly corresponds to a typical mClient rectangle in a standard PegThing. Examples:PegChart is not directly instantiable. See PegLineChart, PegMultiLineChart, or PegStripChart for examples of appropriate usage.
|