Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Objective Chart User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

18.5 Compound Component Classes

In addition to the compound component classes (SRGCompoundComponent, SRGCompoundDisplay, and SRGAxisManager), this section introduces three other new component classes — SRGTickMarks, SRGGridLines, and SRGDataWatcher. These classes may be used standalone (SRGDataWatcher) or within the internals of SRGraphDisplay (SRGTickMarks). Because they are integral parts of SRGAxisManager, they are presented here.

The hierarchy of these compound component and related classes is shown in Figure 138.

Figure 138: Compound component hierarchy

18.5.1 SRGTickMarks

The SRGTickMarks class controls chart tick marks for many axis types. Two types of tick marks, major and minor, are provided. Major ticks are placed at positions corresponding to the labels on an axis. Minor ticks may be linearly interspersed between major ticks in a set ratio.

Major and minor ticks have individual settings for width, color, and length. The length of the minor tick is specified as a multiple (usually less than 1) of the length of the major tick. Furthermore, the side of the axis line upon which tick marks are drawn may be selected. This allows tick marks to be placed inside the rectangle of the axis.

18.5.1.1 Using Tick Marks

The SRGTickMarks class is used internally by the standard SRGraphDisplay. The major tick marks are drawn at the list of tick-mark positions passed via the SetptrTickPositionList() function. This list of positions is usually generated by the CreateLabels() function of one of the axis scale classes. Tick marks are drawn perpendicular to the line connecting the first and last points in the list.

To set up a typical SRGTickMarks object:

18.5.2 SRGGridLines

Similar in usage to the SRGTickMarks class, this class provides a flexible method of adding grid lines to a chart. Major and minor grid lines with individually controlled styles are available to complement the tick-mark system. Color, line thickness, and line style (dots and dashes, etc.) are individually selectable for both major and minor grid lines.

18.5.2.1 Using Grid Lines

Within Objective Chart, the SRGGridLines class is used exclusively as a sub-component of compound displays. The major grid lines are drawn at the list of tick-mark positions passed via the SetptrTickPositionList() function.

Member functions provide full flexibility for selecting the appearance of the major and minor grid lines. Their parameters are simply passed on to the CPen::CreatePen() or CreatePenIndirect() functions.

18.5.2.2 Specifying Grid Line Appearance

To select a color, style, and line width, use standard CreatePen() parameters.

Or, set the style to PS_USER_STYLE and create a list of DWORD styles:

Or, create a LOGPEN structure for CreatePenIndirect():

To set the number of minor grid lines between each major grid line, call SetMinorGridRatio(n); n=0 for no minor grid lines.

18.5.2.3 Customizing Grid Lines

If you create a custom chart type or custom axis type, override DrawHGridLine() and/or DrawVGridLine() to add your new type. If your custom axis requires nonstandard grid lines, override DrawCustomHGrid() and/or DrawCustomVGrid().

18.5.3 SRGDataWatcher

This specialized class monitors the data values in a chart and triggers events when the data exceed preset limits.

Data watchers can be used with standard displays as well as compound displays. The operation and use of data watchers are described in detail in Chapter 21, "Data Surveillance."

When used in conjunction with a compound display, the SRGDataWatcher is registered with and managed by an SRGAxisManager object. Then the data watcher uses information from the display component of the same axis manager.

A data watcher can draw a line (or lines) on the display indicating the limit level(s). Because SRGDataWatcher is derived from SRGGridLines, the appearance of its line(s) can be modified in the same way.

To set up a typical data watcher with a compound display:


For the conditions that require only one limit, use SetHighLimit().

18.5.4 SRGCompoundComponent

This component class is able to hold and maintain its own component list. Components on this list are drawn in order in much the same way that the components on the main SRGraph component list are. A compound component may itself be used as a sub-component thereby allowing complex, nested display objects to be created.

18.5.5 SRGCompoundDisplay

This display class is especially designed to allow fast development of custom charts. The class constructor creates four sub-components of the type SRGAxisManager and adds them to its component list. The SRGAxisManager objects, in turn, hold labels, tick marks, grid lines, data watchers, and displays. The compound display can be used to create ad hoc custom charts. To create a chart you only need to instantiate the relevant classes and add them to the compound display's axis managers. The axis managers then draw the sub-components in the correct places and with appropriate scales.

Charts with two y-axes or two x-axes can specify the relationship between the axis scales. Functions are provided to lock the numerical ratios of the axes together. A virtual function – CalcXRelationship() or CalcYRelationship() – can be overridden to establish more complex relationships.


A compound display can draw up to four axes along the edges of a rectangular frame. It is not compatible with graph types that use pseudo-3D or circular axes.

18.5.6 SRGAxisManager

This sub-component of the compound display manages one side of the chart rectangle used by the SRGCompoundDisplay object. Its constructor initially creates a list of six sub-components that draw nothing. These may be replaced as needed by label blocks, tick marks, grid lines, data watchers, displays, and axis titles to create a portion of a custom chart. Figure 139 shows the sub-components of SRGAxisManager.

Figure 139: SRGAxisManager sub-components

The axis manager coordinates the positions of labels, tick marks, and grid lines through a common list of CPoint objects.


The axis manager accesses these various sub-components by their position in the list. Therefore, the supplied RegisterXXX() and UnregisterXXX() functions should always be used to add or remove sub-components. Do not access the sub-component list directly.



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.