Fl_OpDesk
Fl_OpDesk documentation
opdesk-test-app.png
Fl_OpDesk example program

Description

Fl_OpDesk can be used for just about anything that fits the paradigm of 'connecting boxes together', such as making electronic circuit simulators, modular music tools (ie. connecting an 'oscillator' to an 'amplifier'), industrial control, programmable assembly lines, etc. The 'boxes' on the 'desk' can represent anything, and what happens when the user connects them is all up to you.

In 'widget' terminology, this is a 'node graph' or 'node tree' widget, where the user can interactive connect 'operation boxes' (Fl_OpBox) together to form interconnections (Fl_OpConnect) between 'input' and 'output' buttons on each box (Fl_OpButton) all of which is laid out on a 'desk' (Fl_OpDesk).

The purpose of this widget is to allow users to make modular 'layouts' that can be visual constructions similar to the real world technique of connecting black boxes together to form working systems.

Implementation Synopsis

Each box has a row of 'inputs' (on the left) and 'outputs' (on the right). Each input and output is an instance of an Fl_OpButton. Multiple boxes can be created inside the 'Fl_OpDesk', which is an FLTK 'group' widget that manages all the boxs' positions on the desk, and their interconnections. Scrollbars appear if the boxes go off the edges of the screen.

The idea is you derive one or more classes from Fl_OpBox to define what each box does. You derive classes from Fl_OpButton to define what each possible 'input' and 'output' button does. Each box makes instances of these buttons to define the box's inputs and outputs. You define which buttons can be connected to which other buttons. You define callbacks that are triggered when the user makes connections, so you can warn them if they try to do disallowed things, like connecting outputs to outputs. You can also derive from Fl_OpDesk to take over control of how the desk works, and implement functions like 'Load' and 'Save', and what these do. You can make methods that walk the tree asking each box what's in it, and what it's connected to such as generate code that the connections represent and pass them to a compiler or script interpreter (the 'test-app' example shows all this), or have it run a simulation or control hardware.

Is there a real world analogy?

A real world analogy would be connecting up a home stereo system. For instance, and Fl_OpBox might represent the FM Tuner, Tape Deck, Equalizer, Amplifier, Speakers. Each wire connecting the boxes would be an 'Fl_OpConnect'. The input/output jacks would each be an instance of an 'Fl_OpButton'. The entire system would be laid out on a desk, which would be the 'Fl_OpDesk'.

What are some example applications?

Fl_OpDesk is good at representing just about any kind of modular system.

An example might be a Buchla modular sound system, which lets one connect modular devices like oscillators, sequencers, sound effects boxes, mixers, keyboards, ramp generators, amplifiers, etc. Like the home stereo system above, only more types of black boxes.

Another example would be configuring the layout of an industrial electro-mechanical assembly line's relays/switches/sensors/motors. Or a residential lighting control / irrigation system. Or a digital phone switch to manage adding/removing extensions, voice mail features, paging systems, etc.

light-control.png
Lighting control

It could also be used as a graphic layout to demonstrate how to build simple programs, where each box represents a function, and the connections represent variables.

Another example could be modules for generating simple realtime graphics; for instance separate 'sine' and 'cosine' generator boxes that feed into the X/Y inputs of an oscilloscope to draw a circle, or by changing the input frequencies, a 'spirograph'. Or perhaps a 3-D oscilloscope so that 3 dimensional patterns can be represented with simple input patterns. This could be nice for educational purposes to simulate an oscilloscope.

oscilloscope.png
Oscilloscope simulator

The example program included with this widget shows a full on application of how to use Fl_OpDesk to generate simple perl scripts. Perhaps other examples will be included.

External Dependencies

This widget assumes you have FLTK 1.x and the std C++ library (eg. std::string, std::vector, etc)

The Fl_OpDesk project was designed so as to either be merged into the FLTK 1.x library, or to be installed as a subdirectory of your own project as a separate lib. (The latter is recommended. )

Where do I start?

For examples on how to use the Fl_OpDesk class, see 'test-OpDesk.cxx' for a simple (but non-practical) use of it. For an actual practical 'working' application, see the test-app/ directory, which shows a fully working application that lets users generate Perl scripts visually, and save + load the OpDesk layouts.