#include <AlFunction.h>
class AlFunction
virtual ~AlFunction();
statusCode deleteObject();
virtual AlMomentaryFunction* asMomentaryFunctionPtr();
virtual AlContinuousFunction* asContinuousFunctionPtr();
const char *name();
class AlMomentaryFunction : public AlFunction
virtual AlMomentaryFunction* asMomentaryFunctionPtr();
statusCode create( const char *command, void (*action)( void ));
statusCode create( void (*action)(void) );
class AlContinuousFunction : public AlFunction
virtual AlContinuousFunction* asContinuousFunctionPtr();
statusCode create( void (*init)( void ),
AlMouseButtonFunction *down,
AlMouseButtonFunction *move,
AlMouseButtonFunction *up,
void (*cleanup)( void ),
boolean manipulatesPickList = FALSE );
statusCode create( const char *,
void (*init)( void ),
AlMouseButtonFunction *down,
AlMouseButtonFunction *move,
AlMouseButtonFunction *up,
void (*cleanup)( void ),
boolean manipulatesPickList = FALSE );
statusCode setPreInitFunction( void (*preInit)() );
statusCode setPostCleanupFunction( void (*postCleanup)() );
statusCode setPrompt( const char *staticPrompt, char *inputBuffer,
AlFilterType );
statusCode setPrompt( const char *(*outputStringFunc)(), char
*inputBuffer, AlFilterType );
statusCode setBehaviour( AlBehaviourType type );
statusCode setMouseCoordinateType( AlCoordinateType type);
AlBehaviourType behaviour() const;
static statusCode createGoButton( void (*pressed)( void ) );
static statusCode clearGoButton( boolean do_redraw );
static AlCoordinateType keyboardCoordinateMode();
static AlInputType translateInput( int event, int &button );
static int inputModifierMask(); // see kModifier_xxxx
statusCode finished();
The UI interacts with the plug-in through the use of callback functions. The plug-in supplies pointers to functions that are called whenever a menu button is pressed or the mouse moves. There are two classes of UI functions (the set of callbacks associated with a menu button): momentary functions and continuous functions.
A true momentary function just executes an operation and then returns to the previous function. Momentary functions are used for 'one shot' type operations. The function does not require any user input, and simply returns after it is done. An example of a momentary function is Xform->undo.
A continuous function is a set of 5 callback functions that correspond to the stages involved in a mouse interaction. They are the 'init' function, the mouse down function, the mouse move function, the mouse up function and the cleanup function.
The init function is called when you first switch to the UI function by clicking on the menu item. It does not take any arguments, and is intended for setting up any data required for the operation (e.g. reading option box values, making a list of picked items etc.).
The cleanup function is called when the user leaves this UI function by selecting another menu item. You will usually clean up the data structures that are set up in the init function.
The mouse down function is called when the user depresses the mouse button. The mouse move function is called each time the mouse is moved from its current position. Note that this function will be called immediately after the init function. A mouse 'session' will always contain one call to the down function, one or more calls to the move function followed by a call to the mouse up function.
The mouse up function is called when the mouse button is released. The mouse down/move/up functions are passed three arguments: the event information (a packed value containing information about the mouse buttons, keyboard keys etc) and the x/y position of the mouse when the event occurred (use AlContinousFunction::translateInput to extract the values). If a keyboard event is read, then use scanf() to process the values read from the command line. Otherwise, the mouse was clicked down on the screen. The button in question can be determined by examining the Modifier masks on the value returned by translateInput.
A continuous function performs the action, and that function stays current until you select another function. These types of functions can have mouse or keyboard input.
There are circumstances which require a momentary style function but we want to also provide mouse or keyboard input. For example 'set keyframe' requires keyboard input, so it should be continuous.
However, it can become cumbersome for the user to use. Consider the following sequence of events to set the keyframe while Xform->move is selected.
Instead of declaring the 'set keyframe' function using ..
AlMomentaryFunction::create( do_set_keyframe )
AlContinuousFunction::create( NULL, // init
down_set_keyframe, // reads the keyboard input
NULL,
up_set_keyframe,
NULL // cleanup )
AlContinuousFunction::setPrompt( "Enter frame: %f", frame_buff, kFilterNone )
AlContinousFunction::setBehaviour( kBehaviourMomentary );
Note: Due to the original design of the UI, there is no way to pass a user data pointer to the five functions without using globals.
sFailure - the function could not be removed
sObjectInvalid - this function is not valid
NOTE - to get an icon to load with your function, the name of the icon file must be the same as the function name with a '.S' or '.M' appended. If the return code sNameChangedToUniqueOne is returned, then your function name will be altered slightly, to prevent a collision. As a result, it is possible that it does not match your icon filename so the icon may not appear.
i.e. If you name your function 'fuzzyNavel', then the icon file should be called 'fuzzyNavel.S'
< action - the action function to attach the name to
sSuccess - the momentary function was created
sFailure - the momentary function could not be created
sNameChangedToUniqueOne - the given function name was changed to a unique name. Use name() to find out what.
sSuccess - the momentary function was created
sFailure - the momentary function could not be created
< down - the routine to be called when the mouse button is depressed
< move - the routine to be called when the mouse is moved with the
button depressed
< up - the routine to be called when the mouse button is released
< cleanup - the routine called when the interaction is completed
< manipulatesPickList - TRUE or FALSE
sFailure - the function could not be created
sNameChangedToUniqueOne - success but the name was altered
sSuccess
< init - the routine to be called when the function is invoked
< down - the routine to be called when the mouse button is depressed
< move - the routine to be called when the mouse is moved with the button depressed
< up - the routine to be called when the mouse button is released
< cleanup - the routine called when the interaction is completed
< manipulatesPickList - TRUE or FALSE
sFailure - the function could not be created
sNameChangedToUniqueOne - success but the name was altered
sSuccess
sFailure - couldn't be set
sSuccess - worked
sInvalidObject - the function wasn't created
sSuccess - worked
sFailure - couldn't be set
sSuccess - worked
sInvalidObject - the function wasn't created
sSuccess - the set call worked
sFailure - method failed
sInvalidObject - the continuous function was invalid
sSuccess - the set call worked
sFailure - method failed
sInvalidObject - the continuous function was invalid
char *outputStringFunc()
{
return "Enter coordinate: %f %f %f";
}
char inputBuffer[200]; /* accepts the 'coordinate' */
< inputBuffer - buffer to be used for input
< filter - the units filter for the input
sInvalidObject - the continuous function is invalid
sSuccess - the method worked
< inputBuffer - buffer to be used for input
< filter - the unit filter for the string
sInvalidObject - the continuous function is invalid
sSuccess - the method worked
char dataBuffer[200];
promptInfo( "Input offset %f", dataBuffer );
case kInputKeyboard
sscanf( dataBuffer, "%lf", &newOffset );
break;
kInputKeyboard - keyboard input was detected (see the above source example)
or a bitwise OR of the following values
kModifierButton1 - button 1 was depressed
kModifierButton2 - button 2 was depressed
kModifierButton3 - button 3 was depressed
kModifierButton4 - button 4 was depressed
kModifierButton5 - button 5 was depressed
kModifierButton1 - button 1 was depressed
kModifierButton2 - button 2 was depressed
kModifierButton3 - button 3 was depressed
kModifierButton4 - button 4 was depressed
kModifierButton5 - button 5 was depressed
kModifierControl - the control key was depressed
kModifierShift - the shift key was depressed
kModifierAlt - the alt key was depressed
sSuccess - a 'Go' button is now displayed