GLG Toolkit FAQs

GLG Widgets FAQs:
Online Demos

Widget Catalog:
Documentation and Tutorials

Glg Widgets


General Widget Questions

What is a GLG Widget?

Where are widget drawings located in the GLG directory?

What do I do with the widget's .g file?

How do I use a widget in my application?

Are there programming examples of using GLG Widgets?

How do I load a widget in the Graphics Builder?

How do I modify a widget?

How do I browse widget's resources?

Can I edit objects in the widget's drawing directly?

Can I add new objects to a widget or delete the ones I do not need?

How do I animate a widget?

How do I create a new widget from scratch?

I need to display several widgets. Do I need a separate Applet / Bean / Servlet / ActiveX container for each widget?

How do I create a dashboard containing several widgets?

Chart and Graph Widgets, General Questions


How do I use a chart or a graph widget in my application?

How do I prototype a chart or a graph in the Graphics Builder?

Can I use the Graphics Builder to generate a printout of a chart or a graph with real data?

Real-Time Charts

What is the difference between the Real-Time Charts and the Graph Widgets

How do I edit properties of the Real-Time Chart widget

2D and 3D Graphs


What is a GLG graph widget?

What are common resources of a GLG graph?

How do I modify graph's resources and geometry?


How do I change the number of data samples displayed in the graph?

How do I change the number of labels and minor ticks?

How do I set the range of the graph?

How do I set the initial value for the graphs samples?

How do I set the initial value for the graph's scrolling time labels?

How do I supply data to a graph?

How do I supply custom labels?

How do I add custom annotations to the graph?

How do I change the size of the graph's Data Area?

How do I change the number of lines in a multi-line graph?

How do I assign line and marker colors in a multi-line graph?

I have 10 lines, but I can see only 7 line color attributes in a multi-line graph. How do I add more color attributes to the list?


Dials and Meters FAQ

What is a GLG dial widget?

What are common resources of a dial widget?

How do I edit a dial's resources?

How do I prototype a dial in the Graphics Builder?

How do I use a dial in my application?


How do I handle the dial's input?

I want to use a dial to display a value. How do I disable the dial's input?

How do I add more than one needle to a dial?


General Widget Questions

What is a GLG Widget?
The conventional definition of a widget is a graphical interface element which is usually defined as a reusable piece of code. With this approach, extending a widget's functionality requires adding new code to the widget's source code. To port each widget to a new platform, its source code has to ported.

GLG Widgets use a different model where each widget is a GLG drawing (".g" file) containing a collection of GLG graphical objects that implement the widget's graphical appearance and run-time behavior.

To change the widget, the drawing may be edited with the GLG Graphics Builder, and new widget drawings may be created and saved.

At run-time, a widget drawing is loaded and handled by a GLG object engine in a form of a C/C++ library, Java class library or ActiveX control.

Since the GLG Widgets have no source code associated with them, their functionality is completely defined by each widget's drawing. Widgets' drawings are cross-platform and may be used by GLG applications on various platforms and programming environments (C/C++, Java, etc.) with no porting required.
Where are widget drawings located in the GLG directory?
The widgets' drawings are located in the widgets directory of the GLG installation.

For the Community Edition of the Toolkit, the widgets are located in the DEMOS/widgets directory. The Community Edition of the GLG Widgets should not be used with the commercial version of the Toolkit.
What do I do with the widget's .g file?
A widget's drawing is deployed in an application using one of the GLG containers provided in the GLG libraries: Java bean or applet, Java servlet, ActiveX control, X/Qt/Gtk Widget, and so on, as described in the next section.

A widget's drawing (".g" file) may be loaded into the GLG Graphics Builder to customize its appearance or browse the widget's resources, as described in the How do I edit a widget section.
How do I use a widget in my application?
At run time, an application uses an appropriate widget container provided by the Toolkit to load and display the widget:
Each of the widget containers contains a property that specifies the widget drawing file to be loaded into it. For example, the GLG Java Bean has a DrawingFile and DrawingURL properties for supplying a drawing as either a file or URL. Both the X / Motif Widget and ActiveX Control contain a DrawingFile property as well.

After loading the widget drawing, the application uses the widget container's methods to set widget's resources and supply dynamic data. For example, in the Java environment, the application will call the GLG Bean's SetResource methods to dynamically change widget resources.

The application may also use the Input callback to handle widget input. For example, in the Java environment the callback is implemented as the Input listener of the GLG Bean.

Most of the widgets are contained in a viewport (window object) named $Widget. These widget drawings may be loaded into an application as is. The Toolkit also provides non-rectangular viewport-less versions of the dial widgets, which are supposed to be used in dashboards. The viewportless widgets must be added to a dashboard drawing, and the dashboard's drawing is then loaded into an application.

Refer to the programming examples listed in the next section for samples of the source code.

Refer to the GLG Programming Reference Manual for more information on using GLG Widgets in C/C++  and .NET applications.

Refer to the GLG Programming Tutorial for Java for more information on using GLG Widgets in Java
applications.
Are there programming examples of using GLG Widgets?
Simple examples of using GLG widgets is provided in the following directories:

The demos located in the DEMOS directory contain the source code of GLG C/C++ and Java demos, which are more elaborate.

Refer to the GLG Programming Reference Manual for more information on using GLG Widgets in C/C++  and .NET applications.

Refer to the GLG Programming Tutorial for Java for more information on using GLG Widgets in Java
applications.
How do I load a widget in the Graphics Builder?
The most convenient way of loading a new widget into the Graphics Builder is using its Widget Palettes. To pop up a widget palette in the Builder, click on Palettes in the main menu, then select a desired palette type - graphs, dials, etc.

To replace the current drawing with the widget's drawing, press and hold the Control key, then click on the widget icon in the palette and click on OK to load the widget drawing. This is the preferred way of loading a single widget into the Builder for editing.

After editing, save the modified widget into a file in your project directory. The modified drawing can be loaded in the Graphics Builder using the File, Open menu options.

To load a widget from a palette into the current drawing, simply click on the widget icon with the mouse. To add several widgets, click several times and position each widget in the drawing. This way is used to add several widgets to a drawing to create dashboards.
How do I modify a widget?
The widget can be modified by loading its drawing in the Graphics Builder, which allows you to edit the drawing and save the customized version of it.

The widget's drawing can be edited via resources or by direct editing of the drawing, as described in the following sections.
How do I browse widget's resources?
To browse resources of a widget, load the widget into the Graphics Builder, then click on the widget with the mouse to select it.

The name of the selected widget will be displayed in the Name: field below the drawing area. For widgets contained in a viewport, it will display $Widget. For widgets without a rectangular viewport container, the $Drawing name will be displayed.

Click on the Resources button in the toolbar to bring the Resource Browser. Use tooltips to identify toolbar buttons. The Resource Browser may also be activated via the Object, Resources.

The Resource Browser will show resources of the selected widget. Selecting a resource such as FillColor activates a dialog with menus and palettes for editing the resource's value.

Some resources, such as DataGroup of the bar graph, have the ">>" symbols appended at the end, indicating that they contain more resources inside. Double-click on such resources to display resources inside them. To go back, double-click on the ".." entry at the beginning of the resource list.

The Resources Browser  displays resources of the selected object. Selecting a different object show its resources. If no object is selected, the Resource Browser lists resources of the whole drawing.
and one of the resources will be $Widget (or $Drawing for widgets without a viewport). Double-clicking on this resource will show resources inside the widget.
Can I edit objects in the widget's drawing directly?
Yes, the widget drawing may be edited as any other GLG drawing. The widget is usually contained in a viewport object named $Widget which provides the widget with its own window.

To edit objects inside the widget viewport, select the widget with the mouse and click on the Hierarchy Down button on the lower left side of the drawing area, or Traverse, Hierarchy Down options of the main menu. This will bring you "down" into the viewport, so that you can edit objects inside it.

When you get inside of the viewport, you can select and edit objects in it. To edit an object's attributes, click on the object to select it, then adjust its geometry by clicking and dragging its control and resize points. To edit point coordinates, Shift-click on the control point by pressing and holding the Shift key, then clicking on the point with the mouse. The following  picture shows object control points:


The Properties toolbar button activates the Object Properties dialog for editing object attributes. Use the Ellipsis button next to a property to display palettes and dialogs for editing the property.

The Edit Toolbox toolbar button activates the Edit Toolbox for editing object colors and other attributes. The Layout Toolbox toolbar button activates the Layout Toolbox with options for aligning groups of objects. A group may be created by dragging a rectangle with the mouse or Ctrl-clicking on objects in the drawing. Every Ctrl-click adds or deletes an object from the temporary editing group.

Use the Hierarchy Up button to go back to the top level of the drawing.

If the widget does not have a viewport, the Hierarchy Down button can still be used in the same way to get access to objects inside the widget's group or container object that holds all widget's objects together.
Can I add new objects to a widget or delete the ones I do not need?
Yes, you can. Select the widget and go down into its viewport as described in the previous section to get access to objects inside of the widget's viewport. Use the Object Palette on the upper left side of the drawing area to draw new objects.

To delete objects, select the object to be deleted and press the Cut toolbar button.
How do I animate a widget?
The Run mode of the Graphics Builder is used to prototype the widget's run time behavior. The Run mode is started by clicking on the Start toolbar button, then entering a run command and pressing OK.


For graphs, the Run mode is used to animate graphs with changing data. To load a graph widget with a run command to animate it, Ctrl-click on the widget icon in the widgets palette. Click on the Start toolbar button and press OK to accept the default run command. The graph will be animated with simulated data defined by the run command. Click on the Stop button to stop.


Dials
, sliders and other input widgets may be animated without a run command by moving them with the mouse. Click on Start , erase the run command and press OK, then click and drag the dial or slider with the mouse. Click on Stop to stop. Only widgets contained in a viewport can accept mouse input, viewportless versions of the dials are used only for the output and can not be dragged with the mouse.

Refer to the Data Generation Utility section in the GLG Programming Tools and Utilities chapter of the GLG Programming Reference Manual for more information on the run command options.
How do I create a new widget from scratch?
Since widgets are GLG drawings, new widgets may be created by creating and saving new drawings using the GLG Graphics Builder.

A GLG widget must be contained in a viewport named $Widget. The viewport object encapsulated a native window and provides the widget with a drawing surface. At run time, the $Widget viewport is loaded and displayed in a GLG container such as Java bean, applet or servlet, X/Qt/Gtk Widget or ActiveX control.

To create a new widget, select File, New Widget from the main menu. This creates a new $Widget viewport that will contain the widget's drawing,
and brings you down into it, so you can start creating objects. Constraints, Dynamics and Input Handlers may be used to define the widget's run time behavior and wire complex relationships between objects in the widget's drawing.

To create a new dial widget, it may be easier to start with an existing dial widget as a template and modify it. For example, to create a dial with two needles, use a dial widget with one needle and add the second needle by copying the needle or creating a new needle from scratch and attaching rotation dynamics to it. In either case, the dial's rotation axis with ticks and labels, as well as the interaction handler setup are reused.

Refer to the GLG Builder and Animation Tutorial viewport 
for more information on creating dynamic drawings.

Refer to the Input Objects chapter of the
GLG User's Guide and Builder Reference Manual for more information on input handlers.
I need to display several widgets. Do I need a separate Applet / Bean / Servlet / ActiveX container for each widget?
Instead of using a several containers, one for each widget, you can create a composite drawing containing several widgets (a dashboard) and use a single container to display it. Not only it results in more efficient use of resources, but also the layout of the widgets in the dashboard may be interactively edited using the Graphics Builder.
How do I create a dashboard containing several widgets?
To create a dashboard, first create a new drawing using File, New Widget. This will create a viewport named $Widget and will go down into it. Click on Palettes in the main menu and select a desired palette type, such as graphs or dials.

Click on a widget icon in the palette with the mouse to insert the widget into the drawing. Position the widget and bring its Properties Dialog, then change the widget Name from $Widget to a unique custom name, such as Widget1.

Repeat the previous steps to add several widgets to the drawing, positioning and naming each one Widget2, Widget3, and so on.

When finished, use the Hierarchy Up button to go to the top level to see the finished dashboard and save the drawing.

Use the Resource Browser to browser widget's resources. When the top $Widget viewport is selected, the Resource Browser will show the Widget1, Widget2, ... resources. Double-clicking on each entry will show resources inside it. When browsing resources, the resource paths of selected resources are displayed at the top of the Resource Browser. These paths are used in an application to access resources of each widget at run-time using the GLG's GetResource and SetResource methods.

Chart and Graph Widgets, General Questions

How do I use a chart or a graph widget in my application?
A chart or a graph widget is deployed in an application using one of the programming containers provided in the GLG libraries, as described in the How do I use a widget in my application section of the FAQ.
How do I prototype a chart or a graph in the Graphics Builder?
The Run mode of the GLG Graphics Builder may be used to prototype chart's and graph's run-time behavior using either simulated or real data as described in the How do I animate a widget section of the FAQ.

The widget's drawings provide default run commands for animating them in the Run mode. Open one of the chart or graph palettes using the Palettes menu, then Ctrl-click on a chart or a graph to load it's whole drawing in the Builder. Click on the Start toolbar button and press Enter to accept the default run command. Click on the Stop button to stop prototyping.

The following is a sample of a default run command for a bar graph:

$datagen -sleep 0.1
       d 0 1 $Widget/DataGroup/EntryPoint
       -period 1000 -incr s 0 1000 $Widget/XLabelGroup/EntryPoint

It uses the Builder's data generator to animate the $Widget/DataGroup/EntryPoint resource of the double (d) type with random data in the range from 0 to 1. It also supplies label strings (s type) into the $Widget/XLabelGroup/EntryPoint, converting incremental label numbers to strings. The "-period 1000 -incr  s 0 1000" option informs the data generator to make 1000 iterations, starting from 0 and ending at 1000, before going back to 0. The -sleep 0.1 option slows down the refresh rate to about 10 updates per second.
Can I use the Graphics Builder to generate a printout of a graph with real data?
Yes you can. The -script option of the Graphics Builder's run command may be used to supply the data from a script. For example, the following run command may be used with a packed bar graph to generate a Nitrogen Lab Graph displayed below:

    $datagen -script nitrogen_lab_graph_data

The nitrogen_lab_graph_data file contains a script that fills the graph with data and sets its titles and labels. Click here to see the content of the script file.

Generated Graph Printout for a Project

If there is a large number of graph values, they may be provided in a separate file. For example, the following two command may be used to configure the graph using the nitrogen_lab_graph_data2 script and then fill it with data from the nitrogen_lab_graph_values file:

    $datagen -script nitrogen_lab_graph_data2
    $datagen -datafile nitrogen_lab_graph_values d 0 1 $Widget/DataGroup/EntryPoint

The nitrogen_lab_graph_data2 script used by the first command to configure the graph is the same as nitrogen_lab_graph_data, but  without the values for the graph's datasamples, which will be supplied by a separate file.

The second command uses the nitrogen_lab_graph_values file that supplies values for the graph's datasamples. Click here to see the content of the data file.

When finished, the image of the graph may be saved using the File, Save Image option of the main menu, or printed using the File, Print option.

To save or print only the content of the graph, move the focus inside the graph by clicking on the Set Focus button on the lower left of the drawing area, then click on the graph to move the focus into it. Select Options, Draw Grid, No grid from the main menu to disable the grid, then use Options, Show Axis to toggle the axis display off if necessary. After saving or printing, unset the focus by clicking on the Main Focus button.

Real Time Charts

What is the difference between the Real-Time Charts and the Graph Widgets
The Real-Time Charts are optimized to render charts with large number of data points and fast update rates, and use an integrated Chart object for fast rendering with support for integrated zooming and scrolling, chart tooltips, cursor feedback and point selection.

The 2D and 3D Graph widgets provide a collection of graph widgets with a variety of graph types, such as bar, pie, polar and other graphs, and with support for gradient and 3D shading. While the Real-Time Charts are implemented using a single Chart object, the 2D and 3D graphs (including their axes and legends) are constructed using a collection of individual graphical objects, such as polygons, text, series and other objects. This allows for a greater flexibility in modifying their appearance by editing their drawings.
How do I edit properties of the Real-Time Chart widget
The behavior and appearance of a real-time chart is controlled by the properties of the Chart object contained in the real-time chart widget's viewport. These properties can be edited in the Graphics Builder via resources using the Resource Browser, or by direct editing of the Chart object and modifying its properties.

To get access to the Chart's properties,
select the widget with the mouse and click on the Hierarchy Down button, then select the Chart object and click on the Properties toolbar button, as described in the direct editing section.

Refer to the Real-Time Charts chapter on page 18 of the GLG Widget Reference Manual (HTML or PDF) for more information.

2D and 3D Graphs

What is a GLG graph widget?
Like any other GLG widget, a GLG graph is a GLG drawing representing a bar, line or some other graph. The objects in the drawing are wired up using the GLG dynamics, history and constraints mechanism to behave like a scrolling graph when filled with data. The resources defined in the drawing are used by an application at run-time to configure the graph and supply graph data.

The drawings of all GLG graphs are constructed using similar elements to represent graph components such as axes, ticks, labels and data. A typical graph has a data area, axes, grids, titles, minor and major ticks, major tick labels for each axis, a data group containing graph data samples and other elements as shown in the picture below. Click on the picture to see a bigger image.

Elements of a GLG Graph
What are common resources of a GLG graph?
All GLG graphs have similar resource hierarchies, which slightly differ depending on the graph type.

The following lists resources of a bar graph. Most of these resources are present in all graphs regardless of their type:

A line graph has a slightly different resource hierarchy for its DataGroup:

A multi-line graph has a different DataGroup hierarchy as well:

The top level DataGroupOne/EntryPoint resource of a multi-line graph may be used to push values into all lines of the graph. The entry points of each line (the DataGroupOne/DataGroupN/EntryPoint resources, where N is the index of a line) may be used to push datasamples into each line separately.

You can use the Resource Browser to interactively browse a graph's resources.
Refer to the GLG Widgets Reference Manual for more information on graph's resources and their usage.
How do I modify graph's resources and geometry?
Any graph widget may be loaded in the GLG Graphics Builder and edited as described in the How do I modify a widget section of the FAQ.

The Resource Browser may be used to browse and modify a graph's resources. Elements of a graph may be also be edited directly to position graph's titles, change geometry of the graph's DataArea or add custom annotations.

How do I change the number of data samples displayed in the graph?
For single-series graphs, such as a bar or line graphs, the DataGroup/Factor resource defines the number of the graph's datasamples.

For multi-series graphs, such as a multi-line graph, the
DataGroupOne/DataGroup/Factor resource defines the initial number of datasamples in each line. The number of datasamples in each of the graph's line may also be changed individually, by setting the DataGroupOne/DataGroupN/Factor resource of each line after the hierarchy setup.

You can use the Resource Browser to interactively browse the graph's resources.
How do I change the number of labels and minor ticks?
The number of labels and ticks on the X axis may be changed using the following resources:
For the Y grid:
You can use the Resource Browser to interactively browse the graph's resources.
How do I set the range of the graph?
For single-series bar graphs, the following resources define the graph's range:
For single-series line graphs, the resource are slightly different:
For multi-line graphs, the resources are:
You can use the Resource Browser to interactively browse the graph's resources.
How do I set the initial value for the graphs samples?
The Value resource of the DataSample template defines the initial value of the graph's datasamples before the data are filled in. The following resources may be used to set it depending on the graph type:
The resource must be set before the hierarchy setup at run time, or set in the graph's drawing.

You can use the Resource Browser to interactively browse the graph's resources.


How do I set the initial value for the graph's scrolling time labels?

The initial value of the scrolling labels is set using the label's String resource. For graphs that scroll horizontally along the X axis, the XLabelGroup/XLabel/String resource may be used.


The resource must be set before the hierarchy setup at run time, or set in the graph's drawing.
How do I supply data to a graph?
A graph provides entry points for supplying scrolling graph data and labels. For example, in a single-series graph such as a bar or line graph, the following resources may be used to supply data and scrolling time labels to the graph:

    DataGroup/EntryPoint         - graph data entry point
    XLabelGroup/EntryPoint     - label entry point

For multi-line graphs, the DataGroupOne/EntryPoint may be used to supply data to all lines of the graph at once. Individual entry points, such as DataGroupOne/DataGroupN/EntryPoint, where N is a line index, may be used to supply data to each line separately.
How do I supply custom labels?
Custom labels for the scrolling time axis are supplied though the XLabelGroup/XLabel/EntryPoint resource for graphs with the horizontal time axis, as described in the previous section.

The labels for the value axis are generated automatically based on the range of the graph. The number of digits after the decimal point may be specified using the label's Format resource, which defines a C-style format. To overwrite automatic labeling and supply custom values, the Format resource may be set to a string which does not contain the "%" format symbol.

For example, the format string "%.0lf" will display automatic labels with no digits after the decimal point. Setting  the YLabelGroup/YLabel0/Format resource to the "3.75" string will cause the string to be displayed in the first Y label. The Global flag of the YLabelGroup/YLabel/Format resource must be set to LOCAL in the drawing to set the Format resource of each label to a different value.

Refer to the GLG Widgets Reference Manual for more information.
How do I add custom annotations to the graph?
Since the graph widget is a GLG drawing, you can add new objects to it as described in the Can I add new objects inside a widget or delete the ones I do not need section of the FAQ.

Text objects may be added to annotate the graph or its axis. A label may be added to each of the graph's datasamples by adding a text object to the datasample's template to display the sample's value.
How do I change the size of the graph's Data Area?
The size and position of the DataArea or any other element of the graph may be changed by editing it using the mouse as described in the Can I edit objects in the widget's drawing directly section of the FAQ.

After traversing the hierarchy down into the graph widget, click on the DataArea to select it and adjust its size and position by dragging the DataArea or its control points with the mouse.

When selecting the DataArea, notice the its name appearing in the selected Name: indicator at the bottom of the Builder's drawing area. Since the graph contains many objects on top of the DataArea, the mouse click may select one of this object instead of the DataArea.

If you have problems selecting the DataArea, press and hold the Shift key while clicking on it. This will bring the Object Selection dialog if several objects are potentially selected by the click, so that you can scroll through all selected objects to select the DataArea. If the Object Properties dialog is active, the arrows to scroll through all selections will become active in the upper left corner of the Object Properties dialog, instead of activating the Object Selection dialog.
How do I change the number of lines in a multi-line graph?
The number of lines is controlled by the graph's DataGroupOne/Factor resource.
How do I assign line and marker colors in a multi-line graph?
The DataGroupOne/DataGroup/Polygon resource is a line template, and it has Color0, Color1, ... resources that define the color of each line. To change a color, select the color resource in the Resource Browser, then select a new color from a color palette.

The DataGroupOne/DataGroup/Marker resource defines a template for line markers. It also has Color0, Color1, ... resources that define the marker color for each line, which may be changed using the
Resource Browser.
I have 10 lines, but I can see only 7 line color attributes in a multi-line graph. How do I add more color attributes to the list?
The line colors are defined in a color list transformation attached to the EdgeColor of the line polygon object. By default, the color list contains seven colors. The number of colors in the list may be increased by editing the color list transformation.

To increase the number of line colors:
  1. Select the graph's $Widget viewport and click on the Hierarchy Down button to traverse the hierarchy down into it.
  2. Select the line series named DataGroupOne (a line with markers) at the bottom of the DataArea, and traverse the hierarchy down into it.
  3. You'll see the DataGroup object, which is a polyline object with markers used as a line template. Click on the polyline to select it.
  4. Click on the Properties toolbar button to display its Properties dialog.
  5. Click on the Ellipsis button next to the Polygon attribute and notice the "X" mark on the left of the EdgeColor attribute that indicates it has a transformation attached to it.
  6. Click on the Ellipsis button next to the EdgeColor to display the Attribute Object dialog for the edge color, then click on the Dynamics: Edit button to edit the color list transformation attached to it.
  7. Click on the List of Values button to display the list of colors. Select the last color in the list, then click on the Add button several times to add a required number of colors.
  8. Select each of the added color entries,  name it ColorN, where N is a sequential item index: Color8, Color9, and so on. Set the Global flag of each color entry to GLOBAL.
  9. Save the modified graph.
The marker colors are defined by a color list transformation attached to the FillColor attribute of the marker template. To increase the number of marker colors, follow the following steps:
  1. Perform the steps 1-3 listed above to select the DataGroup object used as a line template.
  2. Click on the Hierarchy Down button to traverse the hierarchy down into the DataGroup.
  3. Click on the marker template (marker object) to select it, then click on the Properties toolbar button to display the marker's Properties dialog. Notice the "X" mark on the left of the FillColor attribute which indicates it has a transformation attached to it.
  4. Click on the Ellipsis button next to the FillColor to display the Attribute Object dialog for the fill color, then click on the Dynamics: Edit button to edit the color list transformation attached to it.
  5. Perform the steps 7-9 listed above to add colors to the color list transformation.

Dials and Meters FAQ

What is a GLG dial widget?
Like any other GLG widget, a GLG dial is a GLG drawing representing a dial with one or more rotating needles, a rotational axis with ticks and labels, and an optional label displaying the dial's current value.
The objects in the dial's drawing are wired up using the GLG dynamics and constraints to implement a dial widget.

Two versions of dials are provided:

The resources defined in the dial drawing are used by an application at run-time to supply the dial value, labels, colors and other attributes.
What are common resources of a dial widget?
All dial widgets have the following resources:
You can use the Resource Browser to interactively browse a dial's resources.

Refer to the Input Widgets, Dials and Meters chapter of the GLG Widgets Reference Manual for detailed description of all dial widget's resources.
How do I edit a dial's resources?
Any dial widget may be loaded in the GLG Graphics Builder and edited as described in the How do I modify a widget section of the FAQ.

The Resource Browser may be used to browse and modify a dial's resources. Elements of a dial may be also be edited directly to change geometry of the dial's needle, position the dial's unit and value labels, or add custom annotations.

While the rotational axis resource may also be edited directly, it is a complex object with elaborate constraints. For a novice user of the Graphics Builder it might be easier to edit it via resources.
How do I prototype a dial in the Graphics Builder?
The Run mode of the GLG Graphics Builder may be used to prototype graphs run-time behavior using either simulated or real data as described in the How do I animate a widget section of the FAQ.

The dial widgets may be prototyped with no run command by using the mouse in the Run mode to move the dial's needle. Click on the Start toolbar button, erase the run command in the Animation Command dialog and press OK. Click and drag the mouse inside the dial to move its needle.
Click on the Stop button to stop prototyping.

The following run command may be used to animate a dial that has a [0; 50] range:

$datagen -sleep 0.01 -sin d 0 30 $Widget/Value


It uses the Builder's data generator to animate the
$Widget/Value resource of the double (d) type with a simulated sinusoidal data in the range from 0 to 50, which should match the Low and High resources of the dial. The -sleep 0.01 option slows down the refresh rate to about 100 updates per second.
How do I use a dial in my application?
A dial widget is deployed in an application using one of the programming containers provided in the GLG libraries, as described in the How do I use a widget in my application section of the FAQ.
How do I handle the dial's input?
When a dial widget is deployed in an application at run-time, the application's Input callback is invoked every time the dial is moved with the mouse. A message object provided as one of the parameters of the Input callback provides information about the dial (there may be several dials in the drawing), its value and the user action.

Refer to the GLG Programming Reference Manual for more information on handling user interaction in C/C++ applications, or to the GLG Programming Tutorial for Java for Java applications.

Refer to demos and examples for samples of source code that handle user interaction.
I want to use a dial to display a value. How do I disable the dial's input?
You can disable the dial's input handling by setting the HandlerDisabled property of the dial's viewport to YES. Select the dial and click on the Properties toolbar button to edit the dial's properties.

Alternatively, you can remove the dial's interaction handler by erasing the GlgKnob value of the dial's Handler property.
How do I add more than one needle to a dial?
The easiest way to add an additional needle to the dial is by copying and pasting a copy of the existing needle:
  1. Select the dial's $Widget viewport and click on the Hierarchy Down button to traverse the hierarchy down into it.
  2. Click on the needle to select it. The ActiveElement name will be displayed in the selected Name field at the bottom of the drawing area.
  3. Click on the Copy toolbar button, then paste using the Paste button. The new copy of the needle will be selected.
  4. Click on the Properties toolbar button to edit properties of the new needle and change its name to ActiveElement2.
  5. Save the drawing.
Select the dial's $Widget viewport and click on the Resources toolbar button to bring the Resource Browser: it will show an ActiveElement2 entry which is the second needle.  Double-click on it to display the Value, Low and High resources inside it. These resources will control the second needle. For example, ActiveElement2/Value may be used to supply the value for the second needle.

The Low and High resources of the second needle may be constrained to the Low and High of the first needle is so desired. Follow the steps below to constrain the Low resource:
  1. Select the ActiveElement2/Low resource in the resource browser.
  2. Click on the Constrain All button in the Resource Object dialog, then click on the Use Resource button.
  3. Navigate to the Low resource of the first needle ($Widget/ActiveElement/Low) and press Select at the bottom of the Resource Browser.
Repeat the steps 1-3 for the ActiveElement2/High resource, to constraint it to ActiveElement/High.

You can paste any number of needles following the steps above.

To eliminate the need to constrain the Low and High resources for each needle, set their Global flag to GLOBAL before copying the needle and use the Options, Paste Clone Type in the main menu to set it to Strong Clone. This will make the Low and High resources to be constrained automatically when the Copy and Paste operations are performed.