The GLG Toolkit is used to create sophisticated real-time animated drawings. The design of a GLG drawing allows developers to edit drawings simply and quickly, without re-programming, and allows many simple tasks to be controlled within the drawing itself, without programming at all. For example, GLG allows a developer to create a graphical input widget to accept input from a user, and to link that input to some drawing feature, without programming a single line of code.
The ease with which you can create new and elaborate drawings and the speed with which you can adapt existing drawings to new uses make GLG ideal for custom data display projects. Also, the flexible structure of the product makes it adaptable to many different real-time display applications. This allows the application programmer to concentrate on the data collection and management aspects of such an application, instead of the display.
GLG consists of several separate components:
The GLG Graphics Builder, used to create and edit GLG drawings.
A set of GLG containers (GLG Bean, GLG Wrapper Widget, GLG ActiveX Control, etc.) for embedding GLG drawings into different programming environments.
The set of functions (also called the Application Program Interface, or API) used to incorporate a GLG drawing into a user's application and update the drawing with real-time data.
The extended set of functions (referred to as an Extended API) used to create GLG objects programmatically or perform complex manipulations on GLG objects.
A library of ready-to-use GLG Widgets including graphs, meters, dials, avionics gauges, process control symbols and other widgets that can be used alone or incorporated into other drawings.
Programming tools and utilities, including a data generator for prototyping animated drawings, a file format converter, and a tool for creating memory images of finished GLG drawings.
Central to each of these components is the GLG drawing. Broadly speaking, the GLG Graphics Builder is for creating and modifying these drawings, and the API is for including and controlling the drawings from a user's program. (There is also an "extended" API for creating and modifying a drawing from within a program.) The widget set is a library of GLG drawings, and the tools are aids for creating and editing these drawings. Rather than relying on the sophistication of the editor or the API, however, it is the organization and internal structure of these drawings that gives GLG its power. Because of this, it is important for you to be familiar with the general structure of a GLG drawing before trying to use the Builder or the API. Fortunately, though the GLG approach presents a rich set of possibilities to the user, the structure is not a complex one.
The organizing philosophy of the GLG system might be described as a process of relentless abstraction. Wherever possible, GLG uses the same data structure to describe similar objects. For example, a point in space uses three numbers to specify its position: its X, Y, and Z coordinates. Similarly, a color is described as a collection of three numbers: the red, green, and blue values. In GLG, these two kinds of data are represented using the same data structure. Similarly, a straight line segment and a complex polygon appear similar within GLG. After all, a line is simply a two-point polygon
In addition to keeping the size of a GLG application small, this object-oriented approach provides a tremendous amount of flexibility. An operation defined on a polygon, for example, may equally well be applied to only one of its vertex points, or to a neighboring object, or to the properties of any other object, including a color. On the other hand, with this flexibility comes some complications. The approach can create some unexpected side effects (linking colors to positions in space is just one example), and one of the important consequences is that there are usually several different ways to solve the same problem.
The following sections describe the components of the GLG Toolkit in greater depth.
The GLG Graphics Builder is used to create, modify, and test GLG drawings. It is the most sophisticated graphics animation editor available in its class, and lets you create elaborately structured animated drawings, and to test them with intricate animation data--generated or real. Since all aspects of the object's appearance and dynamics are encapsulated as data, most of the object dynamics and behavior may be defined and prototyped in the Builder without any programming. Elaborate constraints between objects' attributes may be created to define complex object behavior, and timer transformations may be used to animate objects without programming.
The Builder's data generator may be used to animate objects in the drawing with simulated data in the prototype mode, and the Builder's resource browser presents the user with resource interface to the drawing - the same interface the application will use at run time. The GIS Zooming Mode of the Builder assists in the setup and prototyping of the integrated GIS mapping object.
OpenGL (Open Graphics Library) is a standard specification defining a cross-language cross-platform API for writing applications that produce 2D and 3D computer graphics. OpenGL is often used by 3D games and advanced graphical applications as an interface to the hardware accelerated graphics provided by modern graphics cards.
Starting with the GLG version 2.10, the OpenGL renderer is available on both Unix/Linux and Windows for all programming environments supported by the Toolkit . While the Java2D OpenGL renderer is always used for the Java version of the Toolkit, the C/C++ and ActiveX versions have a choice between the OpenGL renderer or a native windowing system (GDI) renderer, where GDI stands for Graphical Device Interface.
The OpenGL renderer uses hardware acceleration and enables such rendering features as antialiasing, true transparency and alpha-blending, native linear color gradients and other features. The native windowing system renderer may be used as an alternative in cases when an application needs a greater consistency for rendering individual pixels regardless of the installed graphics cards. It may also be used as a fallback if the OpenGL renderer is not available.
The OpenGL renderer is used by the Toolkit in a transparent way, and the user does not need to know the low-level details of OpenGL graphics in order to benefit from the OpenGL's hardware acceleration and an extended set of rendering features. The same application executable may switch between using the OpenGL or native windowing renderer at run time, without any changes to the application code. The OpenGL renderer is supported in a cross-platform way on both Unix/Linux and Windows environments.
When the Toolkit is installed on Windows, two groups of icon shortcuts are provided for starting the demos and the Builder: one for the OpenGL rendering mode and another for the GDI mode. For Unix/Linux installations, symbolic links are provided for starting the demos and the Builder in either OpenGL or GDI rendering mode.
The OpenGL renderer is enabled on per-viewport basis by setting viewport's OpenGLHint flag to ON .
At run time, the OpenGL renderer may be enabled or disabled by using the
-glg-enable-opengl
or
-glg-disable-opengl
command-line options.
It may also be enabled or disabled globally, by setting the GLG_OPENGL_MODE environment variable to True or False , or programmatically, by setting the value of the GlgOpenGLMode global configuration resource to 1 or 0. The global configuration resource takes precedent over the command-line options, while the command-line options take precedent over the environment variable settings.
To use hardware acceleration, a graphics card that supports OpenGL must be present and appropriate drivers must be installed. If the graphics card and/or drivers with the OpenGL support are not installed, a software OpenGL renderer will be used if available. On Unix/Linux systems, the libGL and libGLU libraries must be installed. The libraries are dynamically loaded at run time if they are available, so that the executable may be used even if the libraries are absent.
To check the status of the OpenGL renderer in the GlgBuilder, select the Options / Display OpenGL Info option from the main menu.
In both the Builder and the application, the -verbose command-line option may be used to display extended OpenGL diagnostic informations. On Unix/Linux, the information will be printed to the terminal. On both Windows and Unix/Linux, the information will also be logged into the GLG log file named glg_error.log. The verbose mode can also be activated globally by setting the GLG_VERBOSE environment variable to True .
Once a drawing is created, the GLG Toolkit offers a variety of ways to use that drawing in a program. Many of these methods are portable across window environments, allowing applications to be easily ported from X Windows to Microsoft Windows and back again.
The first step in using a GLG drawing from your application is to display the drawing on the screen. Again, depending on the application and graphical environment in which it will operate, you can choose one of several different display facilities:
You use the wrapper widget for applications that will operate in the X Windows environment. The GLG Toolkit supplies a version of this widget that uses Motif, and another that uses the Xt interface directly. You can use Motif if you want access to the Motif widgets, or if it's important for your application to use that graphical standard. The Xt version of the wrapper widget can also display and animate GLG drawings.
This interface allows you to display and animate a GLG drawing in the Microsoft Windows environment.
The functions of the GLG Generic API can be used to display and animate a GLG drawing in an entirely platform-independent way. A program using only functions from this API can work equally well in the Microsoft Windows and X Windows environments.
This collection of Microsoft Windows properties and methods also allows you to control GLG drawings within the Microsoft Windows environment, but it allows any program adhering to the OLE (Object Linking and Embedding) standard to operate the drawing. This means that a GLG drawing could be operated from a spreadsheet, database application, or word processor, as the occasion demands. Not just for displaying drawings, the ActiveX interface includes methods with which a GLG drawing may be animated, too.
Once a drawing is displayed, it may be animated by querying and setting drawing resources, in a manner comparable to the control of the X Windows environment itself. You can do this with two sets of functions supplied for the purpose:
The GLG Standard API includes functions to set and query drawing resources, as well as to update and reset the whole drawing. These functions, along with a small assortment of convenience functions, are platform-independent, and work equally well under the Microsoft Windows and X Windows environments, and they can be used from both local and remote processes.
It is possible to control a GLG drawing from another process than the one that rendered it. A GLG drawing can be equipped with an internal server that can respond to remote procedure calls. By using the GLG Communications API, the remote procedure can actually use the same functions of the Standard API to animate a GLG drawing.
It is often necessary to modify a GLG drawing from within an application program. It may even be useful to be able to create such a drawing from scratch from within a program. For these purposes, the GLG Toolkit includes an Extended API , containing functions to create and modify objects, and to build and change the object hierarchy that connects them with each other. As a side note, these are the functions with which the GLG Graphics Builder is written.
Many application requirements can be satisfied with one of the drawings provided in the GLG Widget Library. These drawings include both graphs, which can be animated simply by attaching them to a data source, and controls, which can be used to accept direct user input to control drawing features. Over 200 widgets are included in this collection, with several variations available of most of the graph and control types. Custom widgets are also available.
The GLG Toolkit includes several programming tools useful to application programmers. These include a test data generator, a file format converter, and a code generator for including a GLG drawing directly within an application's code. The GLG Graphics Builder and file converter may also be used as scripting tools, for editing drawings using a script in batch mode, or to create new drawings using a script.