Display Objects and Gadgets
Mathwright32 Display Objects are used for input and output, and to display and manipulate mathematical objects. Logically, these are associated with a page, and are implemented as classes with multiple instances, inheritance, data encapsulation, and methods for interaction with mathematical objects. Display Gadgets may be scripted, so that the script is run when the user interacts with them. Display Objects are not scripted.
These objects each have "names" through which they are identified in Mathscript. Mathwright32 PageManager is responsible for creating and destroying these objects, and for channeling instructions to and from them in a rational way. For a given type of object there can be only one object with that name (except for labels). Thus one writes commands or programs in Mathscript that manipulate the data in those objects in various ways. Presently we have implemented the following 13 classes of Display Objects.
Graph2D
Gadgets.
These scriptable objects display graphs of functions or curves defined by user
input, solutions of differential equations, filled polygons, pictures, sprites
that can
be translated, rotated, or transformed by any affine transformation under
program control, animations, and a variety of Logo objects such as points, lines,
polygons, polylines, and so on. These gadgets
may be scripted to respond to a mouse-click, or even to the motion of a mouse
over them.
Graph3D
Objects.
These display objects hold "scenes" that are populated by "actors".
The actors are parametric and implicit surfaces, space curves or "tubes,"
arbitrary geometry created with OpenGL, and imported 3D models from 3D Studio
or DirectX format. OpenGL
is a powerful rendering language that will display your scenes and allow the
user to interact with them in real time. Mathscript contains 57 primitive OpenGL
commands, 47 constants and principal state variables in interactive form. This
means that you (and your readers) may use OpenGL in essentially its original
form (its syntax blends seamlessly with Mathscript syntax) to experiment with
geometry and graphics interactively.
And
since Mathscript is so tightly integrated with OpenGL, it can in fact be an
excellent tool to learn and experiment with OpenGL itself. In its scripts, you
will see the results of your graphics instructions immediately, however, without
the need to compile them into C++. This is a great advantage for building simulations
that must be fine-tuned over many incremental cycles.
But
Mathscript is also a highly flexible language that allows you to create your
own commands, to build your own object hierarchies, and to create the mathematical
objects that will support your simulation. What distinguishes our 3D Graph Objects
from other 3D Graphics environments is the fact that the "actors" in the scenes
you create are dynamic. They may be moved individually either interactively
(at the command line) or under the control of scripts that you write. They may
be selected by the reader when she clicks on them, and may respond in appropriate
ways with the full Euclidean group of motions. Further, the reader may navigate
your scenes by flying through them in the first person, or by moving the entire
scene itself. This makes possible a large variety of realistic experiments and
simulations that it would be difficult to imagine supporting on a 2 dimensional
canvas.
MathEdit
Objects.
These are designed to display mathematical expressions in an intuitive form,
with raised exponents and true fractions to any order of nesting. In addition,
the MathEdit
windows serve as word processors, with a variety of uses. As an editor, it is
used by authors to provide colorful on-line explanations of the Microworld lessons.
These windows also display pictures and "snapshots" of any part of
any screen. Students use them to create and save their reports or notes. In
Mathwright32 Reader,
students
may create and save files for these objects, and recall them at any later time,
thereby customizing the text without actually changing it. MathEdit windows
also display matrices and can be used as an interface for the input of matrix
or of algebraic expressions.
DataTable
Objects.
For the input and output of tables of numeric,
string, or
function data, the data windows provide small "spreadsheet" environments.
The columns
of these
windows are
Mathscript vectors, and so they may be used in any calculation on vectors.
For example, they may produce scatter plots or bar charts in Graph2D windows
at the click of the mouse.
String columns may be used to build Lexicons, and so on. Also, these data tables
are Microsoft Access Active Data Objects, and so may be queried with SQL queries,
saved to disk and retrieved later.
TextBox
Objects.
These are the work horse objects of Mathwright32, used principally for multiline
text input and output. With the Enter command, they allow the user to
define programs, commands, and full scripts interactively.
TextLine
Gadgets.
These scriptable objects
are single-line
text fields. They are used mainly for input. Their scripts are run when the
user presses Enter at the end of the line. Text does not scroll.
Command
Line
Objects.
These multiline
text fields are
also mainly
for input. The
player may enter any of the predefined or user-defined commands of Mathscript
and the command is executed when the user presses Enter at the end of the line.
This is an excellent place to define functions and short commands, to set values
for variables, and so on.
Program
Listeners. These objects are associated with any scriptable gadget, or
with a page, or with the document itself. Use these to compose scripts, define
programs and commands, to test and debug scripts, or even to program in LISP.
The scripts created here may be saved to files, or may be saved with the object
to which they are attached.
Label Objects.
These provide
static text for the background page, such as instructions.
HotSpot
Gadgets. When a page has wallpaper (a .gif, .jpg, or bitmap background)
then it may have associated with it any number of invisible, non-overlapping
rectangles. When the mouse is moved over a hotspot, the cursor changes to a
"pointing finger". When the reader left-clicks the mouse on a hotspot,
the script for the hotspot is run.
Button
Gadgets.
These are
scripted gadgets that respond to the left mouse-click by running their scripts.
Slider
Gadgets. These are input gadgets
that allow the reader to input numbers in some interval, either in a continuous
or discrete fashion.
They may
also be scripted, so that any motion of their thumb causes the script to be
run.
CheckBox
Gadgets.
These are input and output gadgets for Boolean data (True or False). They may
also be scripted so that their activation causes an arbitrary script to be run.
See Also:
Selection of Display Objects and Gadgets