Next: , Previous: The Visualisation, Up: GUI

7.5 The GO Factory

Files: gui/main.h, gui/creatego.c, gui/view.c

The GO Factory is a mechanism similar to a finite automaton which creates new graphic objects. Each state has a desired input, such as a hanger, an anchor, a property value etc. You set the starting state of an operation and then, after getting the input values from the user, proceed to the next states until the object is created. Then the GO Factory returns back to the starting state and the user can create another GO in the same way; or you set a different starting state.

The creation process can be cancelled at any time when needed; for example, when the GUI needs to respond to another user action not related to GO Factory (in that case, it has to cancel the GO Factory operation to prevent errors, which is explained in the further description).

Every state can also have a function which is called before proceeding to the next state. This function can create and link GOs, store a GO pointer in the tmp_go variable, and can access the input values obtained so far and perform some actions if needed. The GO Factory can create a special hanger for the mouse cursor on which some object anchors can be hung temporarily. It also enables the user to undo some partial actions by the “Step back” command which uses the undo history.