|
GLG Toolkit, C / C++ API Library
Version 4.5
|
This group contains functions for querying objects, their properties and relations to other objects. More...
This group contains functions for querying objects, their properties and relations to other objects.
Functions | |
| GlgObject | GlgCreatePointArray (GlgObject object, GlgControlPointType type) |
| ADVANCED: Creates and returns an array containing all control points of an object. More... | |
| GlgObject | GlgCreateResourceList (GlgObject object, GlgBoolean list_named_res, GlgBoolean list_def_attr, GlgBoolean list_aliases) |
| Returns a list of an object's resources. More... | |
| GlgBoolean | GlgFindObjects (GlgObject object, GlgFindObjectsData *data) |
| Finds either one or all parents or children of the specified object that match the supplied search criteria. More... | |
| GlgObject | GlgGetAction (GlgObject object, GlgActionType action_type, GlgTriggerType trigger_type, GlgLong button, GlgArmedStateType armed_state, GlgDoubleClickStateType double_click_state, char *action, char *subaction, GlgBoolean enabled_only) |
| Returns the first found action with the matching parameters attached to the object. More... | |
| GlgObject | GlgGetAlarmObject (GlgObject object, char *alarm_label, GlgBoolean single_alarm, GlgLong reserved) |
| Returns an alarm object with a specified alarm label, or a list of alarms matching the specified alarm label pattern. More... | |
| GlgCube * | GlgGetBoxPtr (GlgObject object) |
| Returns an object's bounding box extent in screen coordinates. More... | |
| GlgObject | GlgGetObjectViewport (GlgObject object, GlgBoolean heavy_weight, GlgBoolean self) |
| Returns parent viewport of a drawable GLG object. More... | |
| GlgObject | GlgGetParent (GlgObject object, GlgLong *num_parents) |
| ADVANCED: Returns an object's parent object, if one exists, or an array of all parents for constrained data objects. More... | |
| GlgObject | GlgGetParentViewport (GlgObject object, GlgBoolean heavy_weight) |
| Returns parent viewport of a drawable GLG object. More... | |
| GlgObject | GlgGetResourceObject (GlgObject parent, char *resource_name) |
| Retrieves an object ID of a resource object. More... | |
| GlgObject | GlgGetTagObject (GlgObject object, char *search_string, GlgBoolean by_name, GlgBoolean unique_tags, GlgBoolean single_tag, GlgTagType tag_type_mask) |
| Retrieves a tag object with a specified tag name, data tag source, or export tag category, or retrieves a list of tags matching the specified tag name, tag source or category pattern. More... | |
| GlgBoolean | GlgHasTag (GlgObject object, char *tag_name, GlgTagType tag_type_mask) |
| Checks if a data or export tag with a specified tag name exists. More... | |
| GlgBoolean | GlgIsDrawable (GlgObject object) |
| Checks if an object is drawable. More... | |
| GlgObject | GlgQueryTags (GlgObject object, GlgTagType tag_type_mask) |
| Returns a group of all tags of the requested tag type defined in the object. More... | |
| void | GlgTraverseObjects (GlgObject object, GlgBoolean(*func)(GlgObject object, void *data), void *data) |
| Traverses the object hierarchy of the object and invokes the supplied function on the object itself and all its subobjects, including object attributes. More... | |
| void | GlgTraverseObjectsExt (GlgObject object, GlgBoolean(*enter_func)(GlgObject object, void *data), GlgBoolean(*exit_func)(GlgObject object, void *data), void *data) |
| Traverses the object hierarchy of the object and invokes the supplied functions on the object itself and all its subobjects, including object attributes. More... | |
| GlgObject GlgCreatePointArray | ( | GlgObject | object, |
| GlgControlPointType | type | ||
| ) |
ADVANCED: Creates and returns an array containing all control points of an object.
| object | The object to query. |
| type | The type of points to be returned:
|
| GlgObject GlgCreateResourceList | ( | GlgObject | object, |
| GlgBoolean | list_named_res, | ||
| GlgBoolean | list_def_attr, | ||
| GlgBoolean | list_aliases | ||
| ) |
Returns a list of an object's resources.
| object | The object whose resources will be listed. |
| list_named_res | Include named resources if True. |
| list_def_attr | Include default attributes if True. The resource objects referred to by the default resource names are not actually included in the list. Instead a dummy scalar data object (type D) is included whose name is the same as the default attribute. |
| list_aliases | Include aliases if True. The resource objects referred to by the aliases are not included in the list. Instead a dummy scalar data object (type D) is included whose name is the same as the alias. |
The list_named_res, list_def_attr and list_aliases parameters let you choose whether the returned array should include named resources, default attributes, aliases or any combination of the above.
The returned array has one entry for each resource. The entries are not sorted and are listed in the order of the occurrence inside their category. The named resources (if any) are listed first, then default resources and finally the aliases.
For named resources, the entries are the object IDs of the resource objects themselves. For default resources and aliases, the entries are dummy scalar data objects named after the default attributes or aliases. For both types of entries, the name of the entry object is the name of the resource listed.
The following code fragment shows how to print the list of an object's resources:
The function returns resource list on only one level of the resource hierarchy. To see the resource lists of the returned resources, invoke GlgCreateResourceList recursively using one of the following techniques:
| GlgBoolean GlgFindObjects | ( | GlgObject | object, |
| GlgFindObjectsData * | data | ||
| ) |
Finds either one or all parents or children of the specified object that match the supplied search criteria.
| object | The object whose parents or children to search. |
| data | The structure that specifies search criteria and returns search results. For forward compatibility with future releases the structure has to be cleared by writing zeros before assigning values to its fields. This can be done using the GlgInitStruct macro: GlgFindObjectsData find_data;
GlgInitStruct( &find_data, sizeof( find_data ) );
#define GlgInitStruct(ptr, size) Initializes structure with 0s. Definition: GlgApi.h:2710 A structure used to pass information to the GlgFindObjects function, and to return the search results... Definition: GlgApi.h:3571 |
If one or more matches were found, the the found_object field of GlgFindObjectsData structure will contain the search result:
The dont_add_matches field of GlgFindObjectsData structure may be set to True to prevent adding matching objects to the found_object field when the custom_match function processes objects in-place, as shown in the DEMOS/SCADAViewer/HMIPageC.c file in the GLG installation directory.
See GlgFindObjectsData for more information.
| GlgObject GlgGetAction | ( | GlgObject | object, |
| GlgActionType | action_type, | ||
| GlgTriggerType | trigger_type, | ||
| GlgLong | button, | ||
| GlgArmedStateType | armed_state, | ||
| GlgDoubleClickStateType | double_click_state, | ||
| char * | action, | ||
| char * | subaction, | ||
| GlgBoolean | enabled_only | ||
| ) |
Returns the first found action with the matching parameters attached to the object.
| object | The object whose actions to query. |
| action_type | An action type. If zero (0), actions of any type will be considered. |
| trigger_type | A trigger type. If zero (0), actions with any trigger type will be considered. |
| button | A mouse button. If zero (0), actions that are activated by any mouse button will be considered. |
| armed_state | The setting of the action's ProcessArmed attribute, see GlgArmedStateType. |
| double_click_state | The setting of an action's DoubleClick attribute, see GlgDoubleClickStateType. |
| action | The input action string for action objects with GLG_INPUT_TRIGGER trigger. If NULL, action objects with any input action string will be considered. |
| subaction | Specifies input subaction string for action objects with GLG_INPUT_TRIGGER trigger. If NULL, action objects with any input subaction string will be considered. |
| enabled_only | If True, only actions enabled by the settings of their Enabled attribute will be considered. |
| GlgObject GlgGetAlarmObject | ( | GlgObject | object, |
| char * | alarm_label, | ||
| GlgBoolean | single_alarm, | ||
| GlgLong | reserved | ||
| ) |
Returns an alarm object with a specified alarm label, or a list of alarms matching the specified alarm label pattern.
| object | Specifies a GLG object whose alarms to query. |
| alarm_label | A string or a pattern for the search (may include ? and wildcards). |
| single_alarm | Defines a single alarm (True) or multiple alarm (False) mode. |
| reserved | Reserved for future use, must be 0. |
The GlgGetElement and GlgGetSize functions may be used to handle the returned group object.
Returns an object's bounding box extent in screen coordinates.
| object | The object whose bounds are to be returned. |
The returned pointer points to internal structures which are valid only while the object exists and should not be modified.
The object box may be converted to world coordinates by using the sequence of the GlgGetDrawingMatrix, GlgCreateInversedMatrix and GlgTransformPoint functions.
| GlgObject GlgGetObjectViewport | ( | GlgObject | object, |
| GlgBoolean | heavy_weight, | ||
| GlgBoolean | self | ||
| ) |
Returns parent viewport of a drawable GLG object.
| object | A drawable GLG object. |
| heavy_weight | Controls the type of a parent viewport to be returned.
|
| self |
|
The object's hierarchy must be set up to use this function, otherwise an error message is generated and NULL is returned.
ADVANCED: Returns an object's parent object, if one exists, or an array of all parents for constrained data objects.
| object | The object whose parents are to be returned. |
| num_parents | A pointer used to return the number of parents attached to the object. If it is NULL, an error message will be generated if the object has more than one parent. |
For constrained data objects, there may be more than one parent object. In this case, the function returns an array of parent object IDs and sets num_parents, which may be used to check whether a data object is constrained.
The returned object ID is a pointer to an internal data structure and it should not be dereferenced with GlgDropObject. To keep it from being destroyed when the parent object is destroyed, you can reference it with GlgReferenceObject (and dereference later).
If the returned value is an array of parents, it points to an internal object which should not be modified and is destroyed when the object's hierarchy is reset. To keep it around, create a copy using GLG_SHALLOW_CLONE, which prevents array's elements from being modified by the GLG internals.
This function must be called after the hierarchy is created.
| GlgObject GlgGetParentViewport | ( | GlgObject | object, |
| GlgBoolean | heavy_weight | ||
| ) |
Returns parent viewport of a drawable GLG object.
| object | A drawable GLG object. |
| heavy_weight | Controls the type of a parent viewport to be returned.
|
The object's hierarchy must be set up to use this function, otherwise an error message is generated and NULL is returned.
Retrieves an object ID of a resource object.
| parent | The parent object whose resources are queried. |
| resource_name | A string that specifies a resource path to access the resource object inside the parent. It may use object names or default attribute names. |
This function finds and returns a named resource of the parent object or an object ID its attribute. It cannot be used to access attributes that are not objects, such as an object's Name.
If the resource is not found, the function returns NULL. No error message is generated in this case, so this function can be used to query if a resource exists.
The returned object ID is not referenced and is valid only immediately after the function call. Reference the returned object using GlgReferenceObject if the resource ID has to be stored for later use to make sure the object is not destroyed.
| GlgObject GlgGetTagObject | ( | GlgObject | object, |
| char * | search_string, | ||
| GlgBoolean | by_name, | ||
| GlgBoolean | unique_tags, | ||
| GlgBoolean | single_tag, | ||
| GlgTagType | tag_type_mask | ||
| ) |
Retrieves a tag object with a specified tag name, data tag source, or export tag category, or retrieves a list of tags matching the specified tag name, tag source or category pattern.
| object | The object whose tags to query. |
| search_string | A string or a pattern for the search (may include the ? and * wildcards). |
| by_name | If True, the search is performed by matching the tag names, otherwise the search is done by matching the tag sources for data tags or matching the tag categories for export tags. |
| unique_tags | Controls if only one tag is included in case there are multiple data tags with the same TagName or TagSource (is ignored in the single tag mode and when searching for export tags):
|
| single_tag | Defines the single tag (True) or multiple tag (False) mode. In the single tag mode, the first found tag object of the highest priority matching the search criteria will be returned. Input tags are prioritized over output tags, and enabled tags over disabled tags. |
| tag_type_mask | Defines the type of tags to query: data tags or export tags. For export tags, tag type constants may be combined with bitwise OR to query multiple subtypes of export tags. |
The GlgGetElement and GlgGetSize functions may be used to handle the returned group object in the multiple tag mode.
| GlgBoolean GlgHasTag | ( | GlgObject | object, |
| char * | tag_name, | ||
| GlgTagType | tag_type_mask | ||
| ) |
Checks if a data or export tag with a specified tag name exists.
| object | Specifies a GLG object whose tag to query. |
| tag_name | Specifies the TagName to query. |
| tag_type_mask | Defines the type of tags to query: For export tags, tag type constants may be combined with bitwise OR to query multiple subtypes of export tags. |
| GlgBoolean GlgIsDrawable | ( | GlgObject | object | ) |
Checks if an object is drawable.
| object | The object. |
Drawable objects can be placed directly in a drawing area, have control points and a bounding box, have the Visibility attribute and can contain custom properties, actions and aliases.
For a Chart object, the Chart itself is drawable, but its Plot objects are not.
| GlgObject GlgQueryTags | ( | GlgObject | object, |
| GlgTagType | tag_type_mask | ||
| ) |
Returns a group of all tags of the requested tag type defined in the object.
| object | Specifies a GLG object whose tags to query. |
| tag_type_mask | Defines the type of tags to query: For export tags, tag type constants may be combined with bitwise OR to query multiple subtypes of export tags. |
Each element of the returned group is an attribute object that has a tag attached. The GlgGetElement and GlgGetSize functions may be used to handle the returned group object.
| void GlgTraverseObjects | ( | GlgObject | object, |
| GlgBoolean(*)(GlgObject object, void *data) | func, | ||
| void * | data | ||
| ) |
Traverses the object hierarchy of the object and invokes the supplied function on the object itself and all its subobjects, including object attributes.
See also GlgTraverseObjectsExt.
| object | The object to traverse. |
| func | A custom traversal function that will be invoked for each traversed object. The function is invoked before traversing the object's subobjects. The function's return result is used to modify the traversal: if the function returns False for a subobject, traversal of objects inside the subobject will not be performed. |
| data | Custom data that will be passed to the traversal function. If a pointer to a structure is passed, the structure's fields may be used to pass data to the function, as well as to store data to track the state of the traversal process. |
| void GlgTraverseObjectsExt | ( | GlgObject | object, |
| GlgBoolean(*)(GlgObject object, void *data) | enter_func, | ||
| GlgBoolean(*)(GlgObject object, void *data) | exit_func, | ||
| void * | data | ||
| ) |
Traverses the object hierarchy of the object and invokes the supplied functions on the object itself and all its subobjects, including object attributes.
One function is invoked when entering an object and another when exiting it.
| object | The object to traverse. |
| enter_func | A custom traversal function that will be invoked for each traversed object to perform a custom action before traversing its subobjects. The function's return result is used to modify the traversal: if the function returns False for a subobject, traversal of objects inside the subobject will not be performed. |
| exit_func | An optional function that will be invoked for each traversed object to perform a custom action after traversing its subobjects. The function should return True. If NULL is supplied as the value of the exit_func parameter, the exit function is not used and GlgTraverseObjectsExt behaves the same way as GlgTraverseObjects. |
| data | Custom data that will be passed to the traversal functions. If a pointer to a structure is passed, the structure's fields may be used to pass data to the function, as well as to store data to track the state of the traversal process. |