ObjGetUserDataΒΆ

ObjGetUserData returns a data-object, set with ObjSetUserData.

obj = ObjGetUserData(handle)
obj = ObjGetUserData(handle, ssObjectName)

Return Value

obj is an object created with obj_create. If an error occurs or the object does not contain an object, obj is 0.

Parameters

handle

handle identifies the object.

ssObjectName

ssObjectName is a name of a data object. If the name does not exist, the function returns the value 0. If the parameter is not specified, the function returns an object that contains all data objects.

Comment

With ObjSetUserData(hObj, obj) a data-object can be added to an UniPlot-object for example a dataset, diagram or drawing object.

To ensure that the data is saved in the IPW-document you must invoke ObjSaveUserData(hObj) every time you modify the data object.

Example

Example for using a data-object:

// The following function is a user defined function that will be invoked
// if the mouse cursor is a data point of a 2D dataset and the dataset
// contains a data-object with the name datatooltip.
// The function has two parameters: hData is the dataset handle and iPoint
// is the point index
def MyTooltip_callback(hData, iPoint)
{
    otip = ObjGetUserData(hData, "datatooltip");
    if (otip != 0) {
        if (otip.has_key(iPoint)) {
            return otip[iPoint];
        }
    }
    return "";
}

// Create a dataset:
h = plot([1:10], rand(1,10));
hData = h[3];

// Create an object and add some text for a number of points:
o = [.];
o[1] = "Info: P1";
o[2] = "Info: P2";
o[3] = "Info: P3";
o[10] = ["Title", "Info: P10"];
// Add the object o under the name datatooltip to the dataset
// Specify the callback function. In this version a callback function
// is only invoked for the object name datatooltip.
ObjSetUserData(hData, "datatooltip", o, "MyTooltip_callback");
// Make sure to invoke ObjSaveUserData:
ObjSaveUserData(hData);

History

Version Description
5.12.0 New

id-279857