PEG gfxdemos_framework--tjl:

Author: Tuomas J. Lukka
Author: Janne V. Kujala
Last-Modified:2002-12-19
Revision: 1.5
Status: Incomplete

The current gfx/demos directory is a mess. To see an effect, you have to read the source for the key bindings and hope the demo hasn't been broken by recent changes. It's time to organize.

Issues

Goals

Changes

Files, directories

Change the file/directory structure of the demos so that one file shall contain at most one scene object, and the name of that object will be Scene. The scene files should be importable as modules, independent of the gldemo.py wrapper. If several scenes move around a common theme, they should be placed in their own directory (python module).

RATIONALE: easiest for a demo browser to read. Files will be smaller. Directory structure helps organization.

The gldemo.py wrapper should then be changed to accept one or more file or directory names. The global window variable w should be moved to its own module.

Scene objects

Each Scene object shall have a docstring briefly explaining what the point of the demo is, and how the point is demonstrated by the demo. For example:

Demonstrate the ambiguity of box-line views.

would be a good way to start the docstring of a demo; OTOH,

Show a small graph filleted and unfilleted.

misses the point entirely. The reader, unfamiliar with the idea, does not understand why this is something she'd like to see. Demos not fulfilling this requirement shall be relegated to the directory gfx/demo/pointless.

Instead of the current key(self, k) mechanism where key presses are decoded in a sequence of if statements, each Scene class shall contain a table keys:

keys = KeyPresses(
    Toggle("fillets", 0, "filleting", "f"),
    SlideLog("zoom", 900.0, "Zoom factor", "<", ">"),
    Custom("setFlurbType", re.compile("[0-9]")),
    ...
)

where the Toggle and others come from gfx.util.demokeys.

The scene mechanism

def scene(self, vs):
    # ... put stuff into vs

shall remain the same.