GLG Toolkit, C# Class Library  Version 4.6
Object Configuration

This group contains methods that may be used to edit and configure objects in the drawing at run time. More...

Detailed Description

This group contains methods that may be used to edit and configure objects in the drawing at run time.

Functions

bool ConstrainObject (GlgObject to_attribute)
 Constrains an attribute or a point of the object to an attribute or a point of another object. More...
 
bool DeleteTags (GlgTagType tag_type_mask)
 Deletes all data tags or all public properties inside the object the method is invoked on. More...
 
void ReleaseObject (GlgObject suspend_info)
 Releases the object that was suspended for editing. More...
 
static void SetCustomSetupHandler (GlgCustomSetupHandler handler)
 Installs a custom setup handler that will be invoked to perform custom processing of objects tagged using the CustomSetup flag in the GLG drawing. More...
 
GlgObject SuspendObject ()
 Suspends the object for editing after it has been drawn. More...
 

Function Documentation

◆ ConstrainObject()

bool ConstrainObject ( GlgObject  to_attribute)

Constrains an attribute or a point of the object to an attribute or a point of another object.

This method constrains an attribute or a point object stored in the object the method is invoked on. To obtain the object ID of the attribute or point object to be constrained, the GetResourceObject method must be used with a default resource name rather than a user-defined resource name as the last part of resource path. For example, "object1/FillColor" must be used to get the object ID of the FillColor attribute of my_object, and not "my_object/my_color".

For objects that have a fixed number of control points (Arc, Text, etc.), use the default attribute name ("PointN") to access an object's Nth control point. For objects with a variable number of points (e.g. polygons), use the GetElement or Iterate method to get its points and use them as the from_attribute.

Parameters
to_attributeThe attribute or the point to constrain to. This object may be queried by using either the default or a user-defined resource name.
Returns
Success or failure status.

The method constrains the attribute or the point the method is invoked on to the attribute or the point specified by to_attribute. If two attributes are constrained, changing the value of either attribute changes the values of both. For more information about constraining, see the Constraints section in the Structure of a GLG Drawing chapter of the GLG User's Guide and Builder Reference Manual.

If the object whose attribute is being constrained has already been drawn, an error message will be generated. You should either constrain object attributes before drawing the object or use the SuspendObject and ReleaseObject methods to temporarily suspend a drawn object for editing.

You cannot constrain any objects beside attribute objects (a control point is an attribute object as well). The objects being constrained must be of the same data subtype. That is, you cannot constrain a color attribute object (eref GlgDataType.G "G" type) to the line width attribute object (D "D" type) because they have different data types.

If any of the conditions above are not satisfied, the method fails and returns false. If constraining is successful, the method returns true.

Note that constraining an attribute object causes all the attributes of the attribute object to be identical to the attributes of the object to which it is constrained, including its name, transformation and value. If a transformation is added to an attribute object, it is automatically added to all the attribute objects that are constrained to this attribute object in order to maintain the constraints.

Similarly, if the object name is changed, it is automatically changed for all the objects that are constrained to the object. These changes are permanent and remain in effect even after the constraints are removed.

◆ DeleteTags()

bool DeleteTags ( GlgTagType  tag_type_mask)

Deletes all data tags or all public properties inside the object the method is invoked on.

Parameters
tag_type_maskDefines the type of tags to delete:
Returns
Success or failure status.

This method fails if the object has been set up and drawn. The SuspendObject and ReleaseObject methods may be used to temporarily suspend an object that has been drawn to perform any modifications that require a hierarchy reset.

◆ ReleaseObject()

void ReleaseObject ( GlgObject  suspend_info)

Releases the object that was suspended for editing.

Parameters
suspend_infoSuspension information returned by the previous call to SuspendObject.

This method releases previously suspended object and is intended to be used only in conjunction with the SuspendObject method.

◆ SetCustomSetupHandler()

static void SetCustomSetupHandler ( GlgCustomSetupHandler  handler)
static

Installs a custom setup handler that will be invoked to perform custom processing of objects tagged using the CustomSetup flag in the GLG drawing.

Parameters
handlerThe custom setup handler to be invoked.

A custom setup handler is invoked at different times during the lifetime of objects tagged using the CustomSetup flag. The handler's ProcessObject method is invoked for each tagged object with the object passed as a parameter. The handler can perform custom processing based on the information stored in the object.

Custom setup may be used to automate object data tags assignment on per-object basis or to attach Input and Trace callbacks to objects representing custom widgets that handle user interaction.

The DEMOS_C#/SCADAViewer/GlgViewer.cs and DEMOS_C#/SCADAViewer/HMIPageC.cs files in the GLG installation directory provide an elaborate example of an application framework that uses a custom setup handler to process special custom widgets.

See GlgCustomSetupHandler for more information.

◆ SuspendObject()

GlgObject SuspendObject ( )

Suspends the object for editing after it has been drawn.

Returns
An object which keeps suspension information. This information should be passed to the ReleaseObject method when the object is released.

Some operations, such as attaching a transformation to an object, constraining an object's attribute and some others, may be carried out only before the object has been drawn. If the object has been drawn and you still need to perform these operations, the SuspendObject method must be used to suspend the object for editing. If SuspendObject is not used, any attempt to perform these modifications will fail, producing an error message.

SuspendObject may be called only for the graphical objects, such as a viewport, group, polygon, text, etc.

The ReleaseObject method must be called after the editing operations have been completed. If an object is suspended, it is not allowed to call UpdateGlg until the object has been released.