DataObject is a system of Xt intrinsic tools that provides for the retrieval, storage and manipulation of sets or groups of data. DataObject serves as the model component of the MVC architecture described earlier. As explained in the following pages, treating sets of data as individual objects not only makes the MVC architecture possible, but also provides the mechanism for a wide range of advanced data handling and graphical display features.
Similar to the the GraphicObject classes, the data classes are all derived from the Xt Object class. These classes can be manipulated using resources, functions, and callbacks, just like any standard Motif/Xt object or widget. The data objects must not be managed. Modification of the data can be accomplished using either standard Xt resource setting mechanisms or the convenience functions provided by INT.

Figure 4: Bar Chart View of Grouped DataSampled Objects
The following example (see file chart_1.c in directory examples) shows the complete programming code required to produce the bar chart display shown above.
#include <Xint/EditObject.h>
#include <Xint/Chart.h>
static String x_labels[] = {"Houston", "Dallas", "Austin", "San Antonio"};
static float d1992[] = { 00.0, 30.0, 20.0, 20.0};
static float d1993[] = { 10.0, 45.0, 32.0, 30.0};
static float d1994[] = { 15.0, 25.0, 27.0, 35.0};
main(argc, argv)
int argc;
char *argv[];
{
XtAppContext app_context;
Widget top_level;
Widget edit;
Object data_group;
Object chart;
XintGeometry chart_geometry;
top_level = XtAppInitialize(&app_context, "test",
(XrmOptionDescList)NULL, 0,
&argc, argv, NULL, NULL, 0);
/* Create an EditObject widget*/
edit = XtVaCreateManagedWidget("edit_object",
xintEditObjectWidgetClass,top_level,
XmNwidth, 600, XmNheight, 600,
XmNobjectEditMode, XintEDIT_ADJUST,
NULL);
/* Create Chart object */
chart_geometry.x1 = 0;
chart_geometry.y1 = 0;
chart_geometry.x2 = 100;
chart_geometry.y2 = 100;
chart = (Object) XtVaCreateWidget("BarPlot",
(WidgetClass)xintChartObjectClass,
edit,
XmNgeometry, &chart_geometry,
XmNchartType, XintCHART_TYPE_BAR,
XmNchartTitle, "Yearly Sales",
XmNshowLegend, True,
NULL);
/* Create a data group */
data_group = XintCreateDataGroup(edit, "Yearly Sales", NULL, 0);
XtVaCreateWidget("Cities", (WidgetClass)xintDataLabelObjectClass,
edit,
XmNlabelStrings, x_labels,
XmNlabelCount, sizeof(x_labels)/sizeof(String),
XmNlabelOrientation, XintLABEL_X,
XmNdataGroup, data_group, NULL);
XtVaCreateWidget("1992", (WidgetClass)xintDataSampledObjectClass,
edit,
XmNdataArray, d1992,
XmNcount, sizeof(d1992)/sizeof(float),
XmNdataType, XintDATA_TYPE_FLOAT,
XmNdataGroup, data_group, NULL);
XtVaCreateWidget("1993", (WidgetClass)xintDataSampledObjectClass,
edit,
XmNdataArray, d1993,
XmNcount, sizeof(d1993)/sizeof(float),
XmNdataType, XintDATA_TYPE_FLOAT,
XmNdataGroup, data_group, NULL);
XtVaCreateWidget("1994", (WidgetClass)xintDataSampledObjectClass,
edit,
XmNdataArray, d1994,
XmNcount, sizeof(d1994)/sizeof(float),
XmNdataType, XintDATA_TYPE_FLOAT,
XmNdataGroup, data_group, NULL);
/* Associate the data group with the chart object */
XintChartAssociateData(chart, data_group);
/* Loop forever */
XtRealizeWidget(top_level);
XtAppMainLoop(app_context);
}

Notice that you can have multiple instances of any data object type within the same group. The DataLabel object provides annotation for either the entire group or for individual objects. It accompanies the group to any destination view, and is inserted into the view in the appropriate context (for example, as column/row annotation in a table or as an axis label in a chart).
In addition, the data labelling follows the data from one view to the next. In a table, the labels might appear as horizontal and vertical titles. In a chart they appear as axis labels. When a user performs a drag-and-drop, the built-in widget mechanism automatically creates the appropriate groups and data objects to accomplish the task. The widget automatically maintains correct hierarchical relationships between data elements, and attaches the appropriate label to the new view.
| Constant | Description |
|---|---|
| XintUNDEFINED_DOUBLE | Missing value for double data format. |
| XintUNDEFINED_FLOAT | Missing value for float data format. |
| XintUNDEFINED_INTEGER | Missing value for integer data format. |
| XintUNDEFINED_LONG | Missing value for long data format. |
| XintUNDEFINED_SHORT | Missing value for short data format. |
void XintChartAssociateData (Object chart, Object data)
This function creates a view of the data object that is displayed by the chart object. See Reference pages for more information on this function.
A similar function is available to associate a data object with an EditTable widget:
Boolean XintEditTableAssociateData(Widget edit_table, Object data,
int col_start, int row_start,
Boolean link)
See the EditTable Reference pages for a complete description of this function.
float new_value;
...
XintDataSampledReplace (data_sampled, &new_value, 0, 1);
The end-user of an application may optionally modify data indirectly by interactively editing a tabular or graphical view of the data. Real-time editing features for replacing, extending or shifting the contents of a data object are also provided. Application programmers can be notified of editing operations using the callback XmNupdateCallback, which can be registered on each data object or at the data group level and may override any requested editing operation. Also, resource XmNeditable can be used to prevent a specific data object or data group from being modified through the editing of a graphical view.
Data groups can also be modified at any time by adding or destroying data objects. Again, if the data group is connected to a chart, the chart will automatically update itself to take into account the changes in the data.
If you need to update several data objects inside a data group that is connected to a chart, use function XintDataBatchUpdate to freeze the propagation of updates to the views and minimize flashing. The following code sample illustrates how to insert two new DataSampled objects to a data group data_group that is already connected to a chart.
/* Freeze propagation of updates for this data group */
XintDataBatchUpdate(data_group, True);
/* add the two new data_sampled objects */
XtVaCreateWidget ("new1", (WidgetClass) xintDataSampledObjectClass,
edit,
XmNdataArray, data1,
XmNcount, count1,
XmNdataGroup, data_group, NULL);
XtVaCreateWidget ("new2", (WidgetClass) xintDataSampledObjectClass,
edit,
XmNdataArray, data2,
XmNcount, count2,
XmNdataGroup, data_group, NULL);
/* allow updates */
XintDataBatchUpdate(data_group, False);
Data resource XmNlastViewDestroy can be used to cause a data object be destroyed automatically after it is no longer associated with a view (chart or table). If you are using a data group, you only need to set this resource on the data group; you don't need to set it for the data objects belonging to the data group.
Object data_group, data_series;
...
index = 0;
while ((data_series = XintDataGroupIterate (data_group,
xintDataSeriesObjectClass, index++)) != NULL) {
printf("series name = %s number = %d\n",
XtName((Widget) data_series), index);
}
If you specify NULL for the name of the object class, function XintDataGroupIterate iterates through all the data objects, whatever the type.