DataSampled Object Class


Overview

The DataSampled object class is used to manipulate a one-dimensional array of values. For instance, a DataSampled object may appear as a row or column of data in a table, a series of bars in a bar chart, a plotted line in a graph and so forth. The type of data contained in a DataSampled Object can be float, short, integer, long, or double.

When the one-dimensional array is viewed in a two-dimensional context such as a chart, the second dimension (or implied direction) is generated from a start and an increment which are specified using resource XmNrange.


Example

The following example shows programming code used to define a typical DataSampled object.

   static int population[] = {142000, 256000, 320000, 340000}
   Object population_data;
   XintRange range;
   ...
   range.start = 1990;
   range.increment =1;
   population_growth = (Object) XtVaCreateWidget("population"),
                                    (WidgetClass) xintDataSampledObjectClass,
                                    parent,
                                    XmNdataArray, population,
                                    XmNdataType, XintDATA_TYPE_INTEGER,
                                    XmNsampledRange, &range,
                                    XmNdataGroup, data_group,
                                    NULL);


Inherited Resources and Behavior

The DataSampled object class does not inherit behavior and resources from any other object class.
The following resources can be defined for the DataSampled object class:
NameTypeDefaultAccess
XmNcopyDataBooleanTrueCSG
XmNcountint0CSG
XmNdataArrayXtPointerNULLCSG
XmNdataGroupObjectNULLCSG
XmNdataTypeintXintDATA_TYPE_FLOATCSG
XmNeditableBooleanTrueCSG
XmNlastViewDestroyBooleanTrueCSG
XmNsampledRangeXintRange *NULLCSG
XmNupdateCallbackXtCallbackListNULLCSG


XmNcopyData

If True, this resource will allocate memory to store a copy of the data, then free the memory allocation when the object is destroyed. If False, the widget does not create a copy of the data or manage memory for this purpose.

XmNcount

Specifies the number of elements in the sampled data array named by XmNdataArray.

XmNdataArray

Specifies the name of a pre-defined array containing the actual data. The array size is expressed through the resource XmNcount and the data type is specified by XmNdataType, both discussed later in this section. The default value of this resource is NULL.

XmNdataGroup

Specifies the object ID of the data group to which this sampled array belongs. This resource must be specified if the sampled data object is to be placed inside a group.

XmNdataType

Specifies the data type for the array named by XmNdataArray. You can specify one of the following constants for the value of this resource:

Resource ValueDescription
XintDATA_TYPE_FLOATData type is float (default).
XintDATA_TYPE_SHORTData type is short.
XintDATA_TYPE_INTEGERData type is integer.
XintDATA_TYPE_LONGData type is long.
XintDATA_TYPE_DOUBLEData type is double.


XmNeditable

Specifies whether or not this data series can be edited when displayed in a view.

XmNlastViewDestroy

Specifies whether or not to automatically destroy this data object when there are no more views connected to the data. If this data object is inserted into a DataGroup, you only need to set this resource for the DataGroup object.

XmNsampledRange

Specifies the start and increment used to generate the implied direction. This is particularly useful for axis scaling in a chart view. If this resource is not specified, the start is assumed to be 0 and the increment 1.

This resource is specified as a pointer to a data structure of type XintRange, which takes the following form:

   typedef struct {
                   float start;
                   float increment;
   } XintRange;

where:

MemberDescription
startMinimum value.
incrementIncrement.


XmNupdateCallback

This resource allows you to attach a callback to the object, as described in the following section.

Callback

The callback XmNupdateCallback provides notification of changes in sampled data objects. As for any widget, you can register callbacks using the Xt function XtAddCallback. The callback structure takes the following form:

   typedef struct {
                   int reason;
                   XEvent *event;
                   Object object;
                   int start;
                   int count;
                   float minimum;
                   float maximum;
   } XintDataSampledUpdateCallbackStruct;

This callback is specific to the DataSampled object and must be registered for each separate data object in a group. If you prefer to monitor updates at the group level, you should register callback XmNupdateCallback only for the DataGroup object and use the XintDataGroupUpdateCallbackStruct discussed earlier in this manual.

The DataSampled update callback contains information that indicates why and how the object was modified. The following ordered table lists the members of XintDataSampledUpdateCallbackStruct in their required sequence:

Data TypeMemberDescription
intreasonIndicates why the callback was invoked (see table below).
XEvent *eventStandard member of a Motif callback structure; not used in this context (will always be NULL).
ObjectobjectID of the updated object.
intstartStarting index of the data updated (starts at 0).
intcountNumber of items updated.
floatminimumNew minimum value of the object.
floatmaximumNew maximum value of the object.

The callback structure includes information explaining the reason why a particular update occurred.

ReasonDescription
XintCR_DATA_UPDATE
XintCR_DATA_BATCH
Entire data array has been changed, no more information is available.
XintCR_DATA_REPLACEData was replaced in the object. (as specified by start and count).
XintCR_DATA_EXTENDData was added to the object (count values were added).
XintCR_DATA_SHIFTData was shifted in the object (count values were shifted).


Functions

The following functions are defined for creating, updating or retrieving information regarding a particular sampled data object.

Function NameDescription
XintCreateDataSampledCreates a DataSampled object.
XintDataSampledDataExtendExtends the data in a sampled array.
XintDataSampledGetDataArrayReturns part of the data array and converts it to float.
XintDataSampledGetSampledArrayReturns the sampled values.
XintDataSampledDataReplaceReplaces a range of values in a sampled array.
XintDataSampledDataShiftShifts the data in a sampled array.


XintCreateDataSampled

This function creates a data sampled object and defines all the resources for it.

     Object XintCreateDataSampled (...)

WidgetparentParent of new data sampled object.
char *nameName of new data sampled.
ArgListarglistList of resource settings for the new data object.
CardinalargcountNumber of resources set by arglist.


XintDataSampledDataExtend

This function adds more data to the end of a sampled array. The function returns False if there is a bad argument, if the function cannot be performed, or if CopyData is false.

     Boolean XintDataSampledDataExtend (...)

ObjectobjectObject ID of the sampled array to be extended.
XtPointerarrayArray of data values to be added to the original sampled array. The data type for this array should be the same as the type specified by XmNdataType.
intcountNumber of values being added.


XintDataSampledGetDataArray

This function returns any part of a specified data array as an array of float values. If the data is not already stored as float, it converts the data type to float. You will need to free the returned array after it is no longer needed.

     float *XintDataSampledGetDataArray (...)

ObjectobjectObject ID of the sampled array containing the desired data.
intstartIndex of first value to be returned (starts at 0).
intcountTotal number of values to be returned.


XintDataSampledGetSampledArray

Since a sampled data object contains only a single array of data values, the data along the implied direction is generated from the XmNsampledRange resource. This function lets you retrieve any part of the synthetic array by specifying the index of the first value and the total number of values (count) to be retrieved. Count cannot be more than the total number of values available, otherwise this function returns NULL. You will need to free the returned array after it is no longer needed.

     float *XintDataSampledGetSampledArray (...)

ObjectobjectID of the sampled array.
intstartIndex of first value to be retrieved.
intcountNumber of values to be retrieved.


XintDataSampledDataReplace

This function replaces a range of values in a sampled array. The function returns False if there is a bad argument or the function cannot be performed.

     Boolean XintDataSampledDataReplace (...)

ObjectobjectObject ID of the sampled array that requires values replaced.
XtPointerarrayArray of new values to be used to replace existing values. The data type for this array should be the same as the type specified by XmNdataType.
intstartIndex of first value to be replaced (starts at 0).
intcountNumber of values being replaced.


XintDataSampledDataShift

This function shifts the data in the sampled array by discarding a certain number of values (count) at the beginning of the array and adding an equal number of values to the end of the array. The values to be added must be specified in a separate array.

     Boolean XintDataSampledDataShift (...)

ObjectobjectObject ID of the array to be shifted
XtPointerarrayAn array of values to be appended to the end of the current array in the DataSampled object. The data type for this array should be the same as the type specified by XmNdataType.
intcountNumber of values to be discarded at the front of the array and appended to the end of the array.


Macros

Macro XintIsDataSampled returns True if the specified object is a DataSampled object.

     Boolean XintIsDataSampled (Object object)