KwikPeg Manuals
Home
PegStripChart
Examples
Examples
Index
Index


Members
Styles
Signals
(none)
Overview Derived from class PegChart

The PegStripChart class provides a simple, dynamic, two dimensional plot of one or more data variables as a function of another variable (often time). Y values are plotted left to right along the X axis as data samples become available. Each data point is joined to the data point to its left (if any) by a straight line. Two presentation styles are supported: scrolled and paged.

The scrolled strip chart operates as follows. When a data point is finally added to the right edge of the chart, the previously plotted data points start to shift horizontally to the left. The oldest (leftmost) data sample is lost as each new data sample is added at the right edge of the chart.

The paged strip chart operates as follows. When a data point is finally added to the right edge of the chart, the color of all previously plotted data points is changed to the aged color indicating that the data is valid, but old. New data points are once again added from left to right in the active color replacing the oldest (leftmost) data points. An optional vertical line called a leader is drawn to indicate the current drawing position for new data. The leader acts as a boundary between new data to its left and aged data to its right. The strip chart has a single leader.

The strip chart is drawn as a collection of one or more trace lines. These trace lines can overlap. All trace lines operate in the same way: either all are scrolled or all are paged.

Each trace line is identified by a line ID, a number ranging from 1 to 255. One strip chart can contain at most 255 traces lines. Line IDs are assigned as you add trace lines to the strip chart. If a trace line is removed from the strip chart, its line ID may be reused to identify a subsequent line added to the chart.

For each trace line, a PegStripChartLine structure is maintained by the PegStripChart class. These private structures are used to identify the trace lines and control their display. The pointer to such a trace line structure is called a line handle. Your application will have access to these handles as you add, insert or remove the trace lines which form your strip chart.

For each trace line, the PegStripChart class maintains an array of data points which make up the trace line. You can add data points (samples) to the array. However, once in the array, the data points become private to the class and unaccessible to your application.

To use the PegStripChart class or its derivatives, your KwikPeg configuration must have the following option enabled:
  Drawing: Charts



 See Also

PegLineChart

PegMultiLineChart



 Styles

The PegStripChart class supports the following extended style flags:

CS_AUTOSIZE  If this flag is set, the chart will always take up the entire mClient region of its parent. When the parent is resized or moved, the PegChart object also resizes itself appropriately.
CS_DRAWXGRID  Draw grid lines along the X axis in the chart region.
CS_DRAWYGRID  Draw grid lines along the Y axis in the chart region.
CS_DRAWXTICS  Draw tick marks along the X axis at the specified intervals.
CS_DRAWYTICS  Draw tick marks along the Y axis at the specified intervals.
CS_DRAWXLABELS  Draw incremental value labels along the X axis below the chart. The label values are based on the minimum and maximum possible values of X.
CS_DRAWYLABELS  Draw incremental value labels along the Y axis to the left of the chart. The label values are based on the minimum and maximum possible values of Y.
CS_DUALYLABELS  Draw Y axis value labels along both the left and right edges of the chart. This style flag is ignored if the CS_DRAWYLABELS style flag is not also set.
CS_DUALYTICS  Draw Y axis tick marks along both the left and right edges of the chart. This style flag is ignored if the CS_DRAWYTICS style flag is not also set.
CS_DRAWLINEFILL  Fill the area between the trace lines and the (x,y=0) axis with the currently specified fill color.
CS_XAXISONZEROY  Draw the X axis along the Y=0 axis instead of below the chart. This style flag is ignored if the CS_DRAWXTICS style flag is not also set.
CS_DRAWXAXIS  Draw a horizontal baseline at value Y=0 across the chart region. Tick marks and labels are not drawn on the line. This style flag is ignored if style flag CS_XAXISONZEROY is set.
CS_PAGED  This style flag and CS_SCROLLED are mutually exclusive. Draw data horizontally from left to right and page the data horizontally. New data is drawn at the leader marker which advances to the right. When the leader reaches the right boundary of the chart region, the leader wraps to the left boundary of the chart region. At that instant, existing data becomes old and is drawn in an aged data color specified via the AddLine() member function. New data continues to be drawn in the active data color at the leader position as it advances from left to right. The behavior of the strip chart mimics that of a heart beat monitor.
CS_SCROLLED  This style flag and CS_PAGED are mutually exclusive. Data is drawn from the left to the right across the chart region. When the right boundary of the chart region is reached, data starts to scroll. Old data is shifted to the left. The oldest data is lost as it shifts past the left boundary of the chart region. New data continues to be added at the right. The behavior of the strip chart mimics that of a seismograph.
CS_DRAWAGED  For a paged strip chart, the aged data is only drawn if this style flag is set. If this flag is not set, the strip chart is cleared of aged data every time the trace reaches the right boundary of the chart. This style flag is ignored unless the CS_PAGED style flag is set.
CS_DRAWLEADER  The vertical leader line which marks the current position at which data is being added to a paged strip chart is only drawn if this style flag is set. This style flag is ignored unless the CS_PAGED style flag is set.

Top of page


 Members

Constructors:

PegStripChart(const PegRect &Rect,
  WORD wSamples,
  LONG lMinY, LONG lMaxY,
  WORD wXMajorScale = 0,
  WORD wYMajorScale = 0)

This constructor creates a strip chart in the rectangle specified by parameter Rect. If style flag CS_AUTOSIZE is to be used (see function SetExStyle()), you may want to draw the chart in the parent's mClient rectangle.

Parameter wSamples specifies the number of data points (samples) which are to be drawn at equidistant intervals across the width of the chart region. This parameter defines the size of the data point array which will be allocated for each trace line added to the strip chart.

Parameters lMinY and lMaxY specify the minimum and maximum Y (vertical) values. Data points which lie outside this range, although not rejected, will not be viewable in the chart rectangle.

Parameters wXMajorScale and wYMajorScale define the intervals along the X and Y axes respectively at which major tick marks will be drawn. Of course, tick marks are only drawn if the object's CS_DRAWXTICS or CS_DRAWYTICS extended style flag is set.

For example, if the minimum Y value is -100, the maximum Y value is 900, the Y scale is 100 and the CS_DRAWYTICS extended style flag is set, then tick marks will be drawn on the Y axis at intervals of 100 starting at -100 and ending at 900. Consequently, there will be 11 tick marks drawn on the Y axis. If the CS_DRAWYGRID extended style flag is also set, horizontal grid lines will also be drawn at the same tick mark intervals.

The interval at which axis label values are drawn is independent of the tick mark/grid line scaling interval. Hence, tick marks might appear at intervals of 100 with the axis values labeled at intervals of 200.

Another style flag, CS_XAXISONZEROY, is provided for strip charts to force the X axis to be drawn at the Y=0 position rather than at the usual minimum Y position.

Style flag CS_DRAWXAXIS is also provided for strip charts to force a baseline to be drawn at the Y=0 position. This style flag is ignored if style flag CS_XAXISONZEROY is used to force the X axis to be drawn at the Y=0 location.

For strip charts, the relationship between the wSamples and wXScale parameters is important. Parameter wSamples indicates the number of data samples which will be presented across the width of the chart. Parameter wXScale indicates the intervals at which tick marks will be drawn along the X axis. It is up to your application to ensure that the data points are presented sequentially so that the resulting presentation is meaningful.

 

Public Functions:

BOOL AddData(UCHAR ucID,
  LONG lRawData,
  BOOL bRedraw = TRUE)

This function adds the new data point (sample) value lRawData to the trace line with line ID ucID. The function returns TRUE if the the data point value was added successfully, else FALSE.

When adding data to a multitrace strip chart, it is important that you add one new data point value for each trace line so that every trace has a data point value for each sample point along the X axis.

UCHAR AddLine(
  COLORVAL tLineColor, COLORVAL tAgedColor,
  COLORVAL tFillColor = 0)

This function adds a new trace line to the strip chart. Parameter tLineColor indicates the active color to be used to draw the trace as new data points are added to it. Parameter tAgedColor indicates the aged color to be used to redraw the old trace data for a paged strip chart presentation.

Parameter tFillColor indicates the color to be used to fill the region between the trace line and the X axis. This color is only used if extended style flag CS_DRAWLINEFILL is set.

The function returns the line ID assigned to the new trace line. The function returns the value 0 if a new trace line cannot be added.

void Draw(void)

The PegStripChart class overrides the Draw() function to draw each of the trace lines which make up the strip chart.

COLORVAL GetLineAgedColor(UCHAR ucID)
COLORVAL GetLineColor(UCHAR ucID)
COLORVAL GetLineFillColor(UCHAR ucID)

These functions return each of the colors being used to draw the trace line with line ID ucID. The aged color is only meaningful for a paged strip chart. The fill color is only meaningful if extended style flag CS_DRAWLINEFILL is set.

COLORVAL GetLineLeaderColor(UCHAR ucID)

This function returns the color being used to draw the leader for the trace line with line ID ucID. Since trace leaders are only drawn for paged strip charts, the color returned by this function is only meaningful if extended style flag CS_PAGED is set.

SIGNED IndexToPointX(WORD wIndex)

This function converts a data array index to an X axis screen location measured in pixels. The index is used by the strip chart to identify samples within the data value array maintained for each trace line. The conversion accounts for the width of the chart region and the number of samples displayed along the X axis. This function is used privately by this chart class.

SIGNED Message(const PegMessage &Mesg)

The PegStripChart class overrides the Message() function to recalculate the chart location or layout when its parent is moved or resized.

virtual void RecalcSize(
  const PegRect &NewRect,
  BOOL bRedraw = TRUE)

The PegStripChart class overrides the RecalcSize() function to adjust the strip chart's location and size as specified by the rectangle NewRect. This function is used privately to redraw the strip chart if it is moved or resized. The function uses the Resize() function to update the screen coordinates of all the data points associated with each trace line. If the bRedraw flag is TRUE, the chart is redrawn.

BOOL RemoveLine(UCHAR ucID)

This function removes the trace line with line ID ucID from the strip chart. If the trace line is successfully removed, the value TRUE is returned, else FALSE. Once a trace line has been removed from the chart, its line ID becomes free. The line ID may subsequently be reused for a new line.

virtual void Resize(PegRect NewRect)

The PegStripChart class overrides the Resize() function to adjust the strip chart's location and size as specified by the rectangle NewRect. The function calls the PegChart base class RecalcLayout() function but inhibits redrawing of the chart. This function is used privately by this chart class.

void SetLineAgedColor(UCHAR ucID,
  COLORVAL tColor)
void SetLineColor(UCHAR ucID,
  COLORVAL tColor)
void SetLineFillColor(UCHAR ucID,
  COLORVAL tColor)

These functions set each of the colors to be used to draw the trace line with line ID ucID. The aged color is only meaningful for a paged strip chart. The fill color is only meaningful if extended style flag CS_DRAWLINEFILL is set.

void SetLineLeaderColor(UCHAR ucID, COLORVAL tColor)

This function sets the color to be used to draw the leader for the trace line with line ID ucID. If a leader color is not defined, the trace line color will be used. Trace leaders are only drawn for paged strip charts. Hence, this function has no effect unless extended style flag CS_PAGED is set.

SIGNED ValToPointY(LONG lVal)

This function converts a data value to a Y axis screen location measured in pixels. The conversion accounts for the height of the chart region and the range of sample values allowed along the Y axis. This function is used privately by this chart class.


Top of page


 Examples

The following code fragment illustrates the use of a PegStripChart object to generate the paged strip chart pictured below. The code needed to dynamically add data points to the strip chart is not shown.

    PegRect Rect;
    Rect.Set(40, 40, 590, 240);

    PegStripChart *pChart =
        new PegStripChart(Rect, 240, -100, 120, 0, 20);

    UCHAR mucID = pChart->AddLine(
        LIGHTGREEN, DARKGRAY);

    Add(pChart);

 




Top of page
KwikPeg Manuals
Home
Index
Index

 
Copyright © 2000-2003