PtTrend

PtTrend — A graph for displaying real-time trends (in QNX 6).

Synopsis

class PtTrend PtBasic
{
    trend_data;        // array of arrays of integer  (Pt_ARG_TREND_DATA)    
    trend_flags;       // flag  (Pt_ARG_TREND_FLAGS)    
    trend_attributes;    // integer array  (Pt_ARG_TREND_ATTRIBUTES)    
    trend_color_list;    // color array  (Pt_ARG_TREND_COLOR_LIST)    
    trend_count;         // integer  (Pt_ARG_TREND_COUNT)    
    trend_grid_color;    // color  (Pt_ARG_TREND_GRID_COLOR)    
    trend_grid_x;        // short  (Pt_ARG_TREND_GRID_X)    
    trend_grid_y;        // short  (Pt_ARG_TREND_GRID_Y)    
    trend_inc;           // short  (Pt_ARG_TREND_INC)    
    trend_max;           // short  (Pt_ARG_TREND_MAX)    
    trend_min;           // short  (Pt_ARG_TREND_MIN)    
}
		

Base Classes

PtWidget <-- PtBasic <-- PtTrend

Description

This widget is a real-time trend display that can plot multiple trends and display them in a moving format, to show changes over time. The QNX 4 version of this widget is RtTrend.

[Note]

For detailed information, please refer to PtTrend in the Photon documentation.

Instance Variables

pttrend_data

An array of data arrays. Each data array corresponds to one trend line on the display.

pttrend_flags

Flags that specify grid characteristics and direction. If any of these flags is set incorrectly, the widget will not display any trends.

[Note]

The grid options are only supported by 8-bit graphics environments, and only on some graphics cards.

This instance variable may be a combination of zero or more of the following flags:

ConstantDescription
Pt_GRIDDraws a grid. This flag requires exactly one of Pt_GRID_IS_TRANSLUCENT, Pt_GRID_ABOVE_TRENDS, or Pt_TRENDS_ABOVE_GRID to be set as well.
Pt_GRID_IS_TRANSLUCENTMakes the grid that was set using Pt_GRID appear to be translucent.
Pt_GRID_ABOVE_TRENDSMakes the grid that was set using Pt_GRID appear to be superimposed over the trends.
Pt_GRID_FORCEForces drawing the grid, despite possible flickering effect due to poor hardware support.
Pt_PIXELThe grid is drawn using a pixel array instead of vector graphics.
Pt_TRENDS_ABOVE_GRIDMakes the grid that was set using Pt_GRID appear to be underneath the trends.
Pt_TREND_HORIZONTALCauses the trend to move horizontally. This flag requires exactly one of Pt_TREND_LEFT_TO_RIGHT or Pt_TREND_RIGHT_TO_LEFT.
Pt_TREND_VERTICALCauses the trend to move vertically. This flag requires exactly one of Pt_TREND_TOP_TO_BOTTOM or Pt_TREND_BOTTOM_TO_TOP.
Pt_LEFT_TO_RIGHTSets the direction for Pt_TREND_HORIZONTAL.
Pt_RIGHT_TO_LEFTSets the direction for Pt_TREND_HORIZONTAL.
Pt_TOP_TO_BOTTOMSets the direction for Pt_TREND_VERTICAL.
Pt_BOTTOM_TO_TOPSets the direction for Pt_TREND_VERTICAL.

trend_attributes

An array that indexes the trend_color_list. Index numbers are consecutive integers starting with 0, and each number points to an element of the trend_color_list. Default is nil.

trend_color_list

An array of colors to be used for plotting trend lines. Default array has a single number: [16711680], which equals 0xff0000 (red).

trend_count

An integer specifying the number of trends.

trend_grid_color

A number specifying the color of the grid to be used if the Pt_GRID flag is set in the pttrend_flags variable. Default is 0xc0c0c0 (grey).

trend_grid_x

A number specifying the number of vertical grid lines to be used if the Pt_GRID flag is set in the pttrend_flags variable. Default is 5.

trend_grid_y

A number specifying the number of horizontal grid lines to be used if the Pt_GRID flag is set in the rttrend_flags variable. Default is 5.

trend_inc

A number specifying the spacing of the plotted points along the moving axis. Default is 1.

trend_max

A number specifying the maximum value for the display. Default is 32,767.

trend_min

A number specifying the maximum value for the display. Default is -32,768.

Example

Here is a very simple example of an PtTrend widget. For more complex examples, see the Gamma demos cpumem and trend. This example, ex_Trend.g, is included in the product distribution.

#!/usr/cogent/bin/phgamma

/*
 * This example illustrates an RtTrend in QNX 4, or a PtTrend in QNX 6,
 * by creating and displaying a sine function.  
 */
require_lisp("PhotonWidgets.lsp");
require_lisp("PhabTemplate.lsp");
PtInit(nil);

wfile = PhabReadWidgetFile (string(_os_, "-WidgetFiles/wgt/trend.wgtw"));
window = PhabCreateWidgets(wfile, nil, nil);
win = PhabLookupWidget(window,#trend,nil);
tr = PhabLookupWidget(window,#Trend,nil);
ebut = PhabLookupWidget(window,#TrendExitButton,nil);
PtAttachCallback(ebut, Pt_CB_ACTIVATE, #exit_program(1));

Values := make_array (1);
valarray = make_array (1);

/*
 * Make a function to generate a trend.
 */

Sinex = 0;

function Sine (inc, max, min)
{
	local		temp = sin (Sinex), diff = (max - min) / 2;
	Sinex = Sinex + inc;
	temp * diff + min + diff;
}

Trend = list (Sine, 0.07, 550, 250);

/*
 * Make a function to evaluate the trend.
 */

function FillTrend ()
{
  valarray[0] = eval(Trend);
  Values[0] = valarray;
  if (_os_ == "QNX4")
    tr.rttrend_data = Values;
  else if (_os_ == "QNX6")
    tr.trend_data = Values;
}

/*
 * Set up the trend.
 */

tr.trend_max = 800;
tr.trend_min = 0;

/*
 * Start an update timer, and loop forever.
 */

every (.03, #FillTrend());

PtRealizeWidget(win);
PtMainLoop();