Next: , Previous: State definitions, Up: The GO Factory

7.5.2 Transitions between states

In the following image you can see an example of transitions between GO Factory states. The starting state above is set by a user action (clicking the appropriate toolbar icon). Then the editor waits for input of the current state (in this case, a hanger), and when the input is ready, it performs some actions using the input obtained and in case of success it moves to the next state. If an error occurs, which is usually a transaction fail, the GO Factory refuses the input, the current state remains unchanged, the editor outputs an error message and waits for another input from the user. After a success in the last state, the GO Factory returns to the starting state again. Additionally, in any state except for the starting one the user can move back or cancel the whole creation at once.

The green arrows show state transitions in case of success, the red ones are for errors and the black ones show the possible steps back.

Transition diagram for states creating an ellipse (by two foci and a point).

The creation process is also called an operation. The basic operation actions are these:

     void factory_op_start( struct go_group * group,
                            struct of_state * state, char * desc );
     void factory_op_break( void );
     void factory_op_step( void );
     void factory_op_step_back( void );

The current state is accessible as factory.state. Here the editor can find out what input to get from the user (according to the type, subtype etc). When the input is ready, it fills the factory.state->value state value and calls the factory_op_step function. Then the GO Factory does the following:

The factory_op_step_back function undoes the effect of the previous state (including the cleanup) and returns the GO Factory to the previous state.

The factory_op_break function undoes all actions from the starting state and moves to the starting state again. This function should be called before any other editing action beyond the control of GO Factory, especially those that create undo history items. The reason is described in the following subsection.