
By default this path is
.:$ALIAS_LOCATION/ODS/OpenAlias/plugins:$ALIAS_LOCATION/Conductors/ghostwriter
which causes $ALIAS_WORKENV (or the directory Alias was launched from if $ALIAS_WORKENV is not set) to be searched first, followed by the example plug-ins. Lastly, the Conductors directory is searched. Any number of directories can be listed with each searched in turn until a plug-in is found. Note that this default path is one of many that are searched for plug-ins as described in the "How OpenAlias Finds Files" section.
The Messages popup allows the selection of Full(verbose) or Brief messages. In Full or verbose message mode, detailed information will be written to the errlog file if there is an error during the loading or unloading of plug-ins.

The Plug-in Manager window consists of 3 columns and a Browser button on the bottom. The columns list the plug-ins that are currently in the OpenAlias search paths and their load and auto-load status. A plug-in can be loaded by clicking on its associated Load/Unload check box. A check mark indicates that the plug-in has been loaded into Alias. Clicking on the check box of an already loaded plug-in will unload it. A plug-in can be made auto-loaded(loaded when Alias starts) by clicking on its associated check box. If any of the operations on plug-ins for this window fail, information will be sent to the Alias prompt-line and the errlog.
The Plug-in Browse button allows a user to select an arbitrary plug-in to be loaded.

Once selected, the plug-in is inserted into the Plug-in Manager list and is loaded. Auto-loading could be applied to this plug-in at this point. Plug-ins which are manually inserted by the Browse option take precedence over other plug-ins which may have the same name that are found in the search process.
The Plug-in Manager window searches the OpenAlias plug-in search paths every time it is opened. It is therefore sufficient, to close and open the window to have a new plug-in shown in the list.
The Plug-in Manager window writes out the auto-load list when it is closed.
When locating plug-ins, icons, scheme files, etc., Alias will start searching at the beginning of the search list and continue until the first occurrence of the desired file is found. If the file is found, the first occurrence is used and the remaining instances are ignored.
extern "C" int plugin_init( const char* pluginDirPath )
The developer uses this function to initialize the OpenAlias universe, and uses instances of the AlFunctionHandle class and AlMomentaryFunction or AlContinuousFunction classes (declared in the file scope to be available to the plugin_exit() function as well) to define the interface between Alias and the plug-in. On successful completion this function should return zero. If a non-zero value is returned from the plugin_init function, OpenAlias will assume that some error condition was encountered in initialization and will automatically unload the plug-in.
Note: we suggest doing the bare minimum in the plugin_init function. Allocate any user data that the plug-in will need but do not allocate any OpenAlias classes.
extern "C" int plugin_exit( void )
Static destructors will be called when a plug-in is unloaded manually. We suggest not performing operations within the static destructors of your classes. Note that plug_init() will still be called when Alias exits so any saving of data can be performed within that call.
summer% Alias -d dbx
debugging: /usr/aw/alias/bin/.Alias
dbx version 6.2 Mar 9 1996 15:23:28
Executable /usr/aw/alias/bin/.Alias
(dbx)
The environment variable AW_DEBUGGING must be set in order to use a debugger on the Alias
binary. In Alias V8.0, the Alias script automatically sets this variable when it is invoked with the -d flag.
Please read the API release notes for more information.
(ui-symbol 'my_symbol 16)
Example 2:
(ui-string 'my_symbol "Number of Cows")
(ui-symbol 'my_symbol 16)
Example: (list 'title "View Frame Options")
Example: (list 'symbols 'nothing.intval 'nothing.doubval 'nothing.boolean )
Example:
Scheme file:
(ui-editor 'control.options
(list 'symbols 'control.pos_x)
(list 'init_option_function "control.init_func" )
(list 'title "Control Options")
(ui-double-widget 'control.pos_x
(list 'range -10.0 10.0)
(list 'precision "%f4.6")
)
)
)
Scheme init file:
(ui-symbol 'control.pos_x 0.0)
(ui-string 'control.pos_x "X")
Plug-in:
static void option_box_init_func( void )
{
AlSetDouble( "control.pos_x", 45 );
}
AlMomentaryFunction function;
AlFunctionHandle handle;
extern "C"
int plugin_init( const char* dirName )
{
AlUniverse::initialize();
function.create( "control.init_func", option_box_init_func );
// other code goes here
}
Note: Allocating memory in the init_option_function will result in memory leaks if the
Exit button is selected. There is no corresponding exit_option_function where allocated
memory can be released.
This function follows the same programming principles as the example in the previous bullet
except that 3 functions will be needed.
Radio and popup widgets are collectively called selector widgets. The order of the elements of the widget is unimportant with the exceptions that the variable is the first item and the choices will appear in the order specified. The following apply to both popup widgets and radio widgets. The columns property only applies to ui-radio-widget. It is ignored if specified in a popup widget.
; Define the label strings.
(ui-string 'title_symbol_1 "First Choice")
(ui-string 'title_symbol_2 "Second Choice")
(ui-string 'title_symbol_3 "Third Choice")
(ui-radio-widget 'variable
(ui-choice 'title_symbol_1 'VALUE1)
(ui-choice 'title_symbol_2 'VALUE2)
(ui-choice 'title_symbol_3 'VALUE3)
)
(ui-popup-widget 'variable
(ui-choice 'title_symbol_1 'VALUE1)
(ui-choice 'title_symbol_2 'VALUE2)
(ui-choice 'title_symbol_3 'VALUE3)
)
(ui-string 'ao_set_device_offset "Offset")
(list 'symbols 'ao_set_device_offset )
(ui-double-widget 'ao_set_device_offset
list 'precision "%f6.3")
(list 'slider_range 1 10)
)
(list 'symbols 'nothing.boolean )
(ui-tick-widget 'nothing.boolean)
Left:
(list 'symbols 'mo_bevel_front_cap)
(ui-tick-left-widget 'mo_bevel_front_cap)
Right:
(list 'symbols 'mo_bevel_front_cap)
(ui-tick-right-widget 'mo_bevel_back_cap)
If there is a whole group with a tick-left at the end,use the regular ui-tick-widget for
the last one,otherwise there will be a hole on the right.
(ui-radio-widget 'variable
(list 'rebuild)
(ui-choice 'title_symbol_1 'VALUE1)
(ui-choice 'title_symbol_2 'VALUE2)
(ui-choice 'title_symbol_3 'VALUE3)
)
The enabled property is used to specify this condition. The expression is built from the relational primitives ui-eq (equal), ui-ne (not equal), ui-lt (less than), ui-le (less than or equal), ui-gt (greater than), ui-ge (greater than or equal). The relational primitives can be combined using the logical primitives ui-and, ui-or, and ui-not.
(ui-radio-widget 'variable
(list 'enabled (ui-eq 'other_variable 'SOME_VALUE))
(list 'rebuild)
(ui-choice 'title_symbol_1 'VALUE1)
(ui-choice 'title_symbol_2 'VALUE2)
(ui-choice 'title_symbol_3 'VALUE3)
)
(ui-radio-widget 'variable
(list 'columns 3)
(list 'enabled (ui-eq 'other_variable 'SOME_VALUE))
(list 'rebuild)
(ui-choice 'title_symbol_1 'VALUE1)
(ui-choice 'title_symbol_2 'VALUE2)
(ui-choice 'title_symbol_3 'VALUE3)
)
(ui-radio-widget 'mo_prim_type
(list 'rebuild #t)
(ui-choice 'prim.type.cube 'MO_CUBE)
(ui-choice 'prim.type.plane 'MO_PLANE)
(ui-choice 'prim.type.circle 'MO_CIRCLE)
(ui-choice 'prim.type.cylinder 'MO_CYLINDER
(list 'assign 'mo_prim_caps 2)
)
(ui-choice 'prim.type.cone 'MO_CONE
(list 'assign 'mo_prim_caps 1)
)
(ui-choice 'prim.type.sphere 'MO_SPHERE)
)
(ui-choice 'prim.type.cone 'MO_CONE
(list 'assign (ui-eq 'mo_prim_caps 2) 'mo_prim_caps 1)
)
(ui-separator-widget)
tree_init.scm:
(ui-symbol 'seed 0)
(ui-string 'seed "Seed")
(ui-symbol 'max_branch 15)
(ui-string 'max_branch "Max Branch Limit");
(ui-symbol 'bend 0.2)
(ui-string 'bend "Bend")
(ui-symbol 'fork_angle 30.0)
(ui-string 'fork_angle "Fork Angle (deg)")
(ui-symbol 'branch_frequency 50.0)
(ui-string 'branch_frequency "Branch Frequency %")
(ui-symbol 'gravity -0.1)
(ui-string 'gravity "Gravity")
(ui-symbol 'branch_length 5.0)
(ui-string 'branch_length "Grow Length")
(ui-symbol 'trunk_taper 95.0 )
(ui-string 'trunk_taper "Trunk Taper %")
(ui-symbol 'min_branch_size 0.025 )
(ui-string 'min_branch_size "Minimum Branch Size")
(ui-symbol 'twist 45.0 )
(ui-string 'twist "Twist Angle (deg)")
(ui-symbol 'leaf.choice 0)
(ui-string 'leaf.choice "Type of Leaves")
(ui-string 'leaf_none "None")
(ui-string 'leaf_oak "Oak")
(ui-string 'leaf_maple "Maple")
(ui-string 'leaf_pine "Pine")
tree.scm:
(ui-editor 'tree.options
(list 'title "Fractal Tree Options")
(list 'symbols 'seed 'bend 'fork_angle 'branch_frequency 'gravity
'branch_length 'trunk_taper 'min_branch_size 'twist
'leaf.choice 'max_branch )
(ui-integer-widget 'seed
(list 'range 0 65535)
)
(ui-integer-widget 'max_branch
(list 'range 1 100)
)
(ui-double-widget 'bend
(list 'precision "%f6.4")
(list 'range -1.0 1.0)
)
(ui-double-widget 'fork_angle
(list 'precision "%f6.1")
(list 'range 0.0 90.0)
)
(ui-double-widget 'branch_frequency
(list 'precision "%f6.1")
(list 'range 0.0 100.0)
)
(ui-double-widget 'gravity
(list 'precision "%f6.4")
(list 'range -1.0 1.0)
)
(ui-double-widget 'branch_length
(list 'precision "%f6.4")
(list 'range 0.0 10.0)
)
(ui-double-widget 'trunk_taper
(list 'precision "%f6.1")
(list 'range 0.0 100.0)
)
(ui-double-widget 'min_branch_size
(list 'precision "%f6.4")
(list 'range 0.0001 1.0)
)
(ui-double-widget 'twist
(list 'precision "%f6.4")
(list 'range 0.0 90.0)
)
(list 'title "Leaf Options")
(ui-radio-widget 'leaf.choice
(ui-choice 'leaf_none 0)
(ui-choice 'leaf_oak 1)
(ui-choice 'leaf_maple 2)
(ui-choice 'leaf_pine 3)
)
)
The simplest way to define a momentary function is through the AlMomentaryFunction class. Calling one of the create methods on an instance of that class will generate a new momentary function in Alias.
One can also define a momentary function in Scheme using the ui-function-define-momentary primitive. This primitive takes two arguments - the name of the momentary function to define, and a piece of executable Scheme code. This can be the name of another function or a lambda closure. Once the momentary function is defined, it can be referenced like any other and added to menus. For instance, to create a menu item that invokes the unix command `xcalc', one could add the following to Alias.scm:
(ui-function-define-momentary "InvokeXcalc"
(lambda () (unix-system "xcalc &")))
(ui-string "xcalc.str" "Invoke xcalc")
(ui-function "invoke_xcalc"
(list 'command "InvokeXCalc")
(list 'label_string 'xcalc.str)
)
(ui-menu-add-entry "al_goto" 'invoke_xcalc)
In addition, a continuous function is allowed to define pre-init and post-cleanup functions. The reason for these is that there are two ways to enter and leave the context of a continuous function. The function can be preempted temporarily by selecting some momentary function, or terminated more permanently by switching contexts to some other continuous function (or quitting Alias, of course). The pre-init and post-cleanup functions allow you to define actions that get invoked when Alias truly changes contexts and does not merely preempt your continuous function.
To actually define the menu item which will invoke that AlFunction, use the AlFunctionHandle class, which provides a C++ interface to Scheme.
The file AlFunctionHandle.h must be included by the plug-in to use AlFunctionHandle. AlFunction.h must be included to use either AlMomentaryFunction or AlContinuousFunction.
In the plugin_init() function of the plug-in the various methods of the AlFunctionHandle are used to define the menu item (or menu items) that will be added to OpenAlias, and the AlFunction classes are used to register the functions which make up the functionality of the plug-in. In the case of using Scheme instead of AlFunctionHandle, plugin_init() would at some point invoke a Scheme file that performs the necessary UI initialization.
statusCode AlFunctionHandle::create( const char * name, const char * command );
statusCode AlFunctionHandle::create( const char * name, AlFunction *func );
These methods are used to create the function handle and set some of its attributes. (It is also possible to use the constructor to create the function handle.)
Arguments:
statusCode AlFunctionHandle::setAttributeString( const char * str );
This method sets the string which will appear on the attribute line below the prompt line when the plug-in is selected from the menu.
Arguments:
statusCode AlFunctionHandle::setOptionBox( const char * schemeFileName, const char *
editorName, const char* dirPrefix );
This method sets the option box for the plug-in. If the plug-in has no option box, this method need not be used. This method wil fail if the scheme file described by the name and prefix does not exist.
Arguments:
statusCode AlFunctionHandle::setIconPath( const char * iconPath );
This method sets the pathname to load the icon images from. If the path is not set, then the icon image will be loaded from the standard bitmap locations ($ALIAS_BITMAP_LOCATION or $ALIAS_LOCATION/bitmaps). Currently the icon path must contain two directories: `small' and `medium'. Each directory contains an image of the icon to be displayed. The small image must have the suffix `.S', and the medium sized image must have the suffix `.M'.
For example, if the function name is `myFunc', then the directory would be setup as:
..../small/myFunc.S
..../medium/myFunc.M
statusCode AlFunctionHandle::addToMenu( const char * menuname );
statusCode AlFunctionHandle::appendToMenu(const char * menuname);
These methods add the plug-in to the menu. addToMenu() adds the plug-in to the bottom of the menu, while appendToMenu() will add it to the top of the menu.
Arguments:
Menu Identifier |
|
|---|---|
![]() ![]() _![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() _![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() _![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() _![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() _![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() _![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() _![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() _![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() _![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() _![]() ![]() ![]() ![]() ![]() _![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() _![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() _![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() _![]() ![]() µ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() µ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() _![]() µ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() µ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
µ _![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
µ _![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
µ _![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
µ _![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
µ _![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
µ _![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
µ _![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
µ _![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() ![]() ![]() ![]()
|
µ _![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
µ _![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() µ![]() ![]() ![]() ![]() ![]()
|
µ _![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
µ _![]() ![]() ![]() ![]() ![]() ![]() _µ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
µ _![]() ![]() ![]() µ![]()
|
![]() ![]() ![]() ![]() µ![]()
|
![]() ![]() _![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() _![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() (![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() )
|
AlFunctionHandle::removeFromMenu
Prototype:statusCode AlFunctionHandle::removeFromMenu();
Description:
statusCode AlFunctionHandle::deleteObject();
This method deletes the function handle from the menu and completely invalidates it.
Return codes:
AlFunctionHandle& AlFunctionHandle::operator =( const AlFunctionHandle& f )
This defines the assignment operator for the AlFunctionHandle class.
Arguments:
int AlFunctionHandle::operator !() const
This method allows us to check the validity of a function handle.
ex.
if ( functionhandle ) ...
;; This file simply gives the defaults for the Scheme variables
;; used in the option box.
(ui-symbol "frame" 0)
(ui-string "frame" "Frame")
;; This file defines the option box
(ui-editor "frame.options"
(list 'symbols 'frame )
(list 'title "View Frame Options")
(ui-integer-widget "frame"
(list 'range 0 65535)
)
)
#include <AlUniverse.h>
#include <AlViewFrame.h>
#include <AlPickList.h>
#include <AlObject.h>
#include <AlLiveData.h>
#include <AlFunction.h>
#include <AlFunctionHandle.h>
#include <AlIterator.h>
#include <strings.h>
extern char * makeAltPath(const char *dirName, const char *suffix);
// A simple iterator used to pass the frame number
// along when viewing an object.
class viewIterator: public AlIterator
{
public:
viewIterator( double frame = 0.0 )
: frameNum( frame ) {};
virtual ~viewIterator() {};
virtual int func( AlObject* );
private:
double frameNum;
};
// The iterator's one and only method. Does a viewframe
// on the passed in object using the frame number in the
// iterator object.
int viewIterator::func( AlObject* obj )
{
if ( obj == NULL )
return 0;
AlAnimatable* animitem;
AlCurve* curve;
AlSurface* surface;
AlObjectType type = obj->type();
if( animitem = obj->asAnimatablePtr() )
AlViewFrame::viewFrame( animitem, frameNum, AlViewFrame::kObjectAndBelow );
else if( curve = obj->asCurvePtr() )
AlViewFrame::viewFrame( curve, frameNum );
else if( surface = obj->asSurfacePtr() )
AlViewFrame::viewFrame( surface, frameNum );
else
AlPrintf( kPrompt, "Sorry, %s is not a viewable object", obj->name() );
; // a non viewable object
return 0;
}
// The actual plugin function.
void my_view()
{
int frameNum;
// Get the frame number from the option box.
if( sSuccess == AlGetInteger( "frame", frameNum ) )
{
// Print the number to the promptline.
AlPrintf( kPrompt, "Viewing frame %d.", frameNum );
// Instantiate an iterator and apply it to all picked
// objects.
int rc;
viewIterator* view = new viewIterator( frameNum );
if ( sSuccess != AlPickList::applyIteratorToItems( view, rc ) )
AlPrintf( kPrompt, "Iterator failed." );
if ( rc != 0 )
AlPrintf( kPrompt, "Return code is %d.", rc );
AlPrintf( kPrompt, "Viewing complete." );
}
}
// This handle may have to be global if you wish to remove the
// plugin from the menu using the h.destroy() method in the
// 'momentary_exit' function.
// The menu entry is automatically removed when Alias exits.
//
AlFunctionHandle h;
AlMomentaryFunction hFunc;
extern "C"
int plugin_init( const char *dirName )
//
// This routine initializes the plugins and attaches it to the menu.
// It returns 0 if there is no initialization error.
//
{
char *dirScm;
// Initialize the universe. This must be done by all
// plugins. If the universe is not initialized the plugin
// will fail.
AlUniverse::initialize( );
dirScm = makeAltPath(dirName,"scm");
// Invoke the scheme file which sets defaults for the scheme
// variables.
AlInvokeSchemeFile( "frame_init.scm", dirScm );
// Allocate a function handle. The first argument is the label on
// the menu and the second is the function to invoke when the
// menu item is selected.
hFunc.create( my_view );
h.create( "View Frame", &hFunc );
// Define the attribute string for the attribute line below
// the prompt line.
h.setAttributeString( "viewframe" );
// Read in the option box. The first argument is the
// option box in $ALIAS_WORKENV, and
// the second argument is the name of the option box given
// in the scheme file. The third argument is a directory
// path(possibly NULL) where to look for the scheme file.
// If a call to this method is omitted, there will be no option box.
if ( sSuccess != h.setOptionBox( "frame.scm", "frame.options", dirScm) ) {
AlPrintf(
kPrompt,
"Frame plug-in unable to find .scm file for option box"
);
return (1);
}
// Indicate which menu to add the plugin to. addToMenu()
// adds the plugin to the bottom of the menu, while
// appendToMenu() will add it to the top of the menu.
h.addToMenu( "mp_objtools" );
h.setIconPath( makeAltPath( dirName, NULL ) );
// Return a success code.
// Returning a non zero indicates an error.
// An error value ( a non-zero ) will be printed on the prompt
// line in Alias.
AlPrintf( kPrompt, "Frame attached to Palette 'Object Edit'");
return 0;
}
extern "C"
int plugin_exit( void )
{
// Remove the plugin from the menu and free the FunctionHandle.
// Note that h.destroy() implicitly calls h.removeFromMenu()
h.deleteObject();
hFunc.deleteObject();
return 0;
}
// cont.plugin
//
// This file implements a simple continuous function plugin, a plugin
// that gets events from Alias and can interact with the user. It can
// be used as a skeleton from which to construct other, more complicated
// continuous functions if desired.
//
#include <AlLiveData.h>
#include <AlFunction.h>
#include <AlFunctionHandle.h>
#include <AlUniverse.h>
#include <AlDagNode.h>
#include <AlPickList.h>
#include <AlPickable.h>
#include <AlWindow.h>
char inbuf[ 256 ];
char text_buf[ 100 ];
const char * my_prompt = "Enter some text: %s";
extern char * makeAltPath(const char *dirName, const char *suffix);
void go_button_pressed( void )
{
AlPrintf( kStdout, "Go button pressed!\n" );
AlContinuousFunction::createGoButton( go_button_pressed );
}
static void init_func( void ) {
AlPrintf( kStdout, "Now entering continuous plugin.\n" );
AlContinuousFunction::createGoButton( go_button_pressed );
}
static void down_func( int input, Screencoord x, Screencoord y )
{
int button;
double dx=-1, dy=-1, dz=-1, ex=-1, ey=-1, ez=-1;
AlWindow * w;
switch( AlContinuousFunction::translateInput( input, button ) ) {
case kInputButton:
w = AlUniverse::currentWindow();
w->mapToWorldSpace( x, y, dx, dy, dz, ex, ey, ez );
AlPrintf( kStdout, "Mousedown at %d,%d [%lf,%lf,%lf %lf,%lf,%lf]. Button %d.\n",
x,y, dx,dy,dz, ex,ey,ez, button );
delete w;
break;
}
}
static void move_func( int input, Screencoord x, Screencoord y )
{
int button;
double dx=-1, dy=-1, dz=-1, ex=-1, ey=-1, ez=-1;
AlWindow * w;
switch( AlContinuousFunction::translateInput( input, button ) ) {
case kInputButton:
w = AlUniverse::currentWindow();
w->mapToWorldSpace( x, y, dx, dy, dz, ex, ey, ez );
AlPrintf( kStdout, "Mousemove at %d,%d [%lf,%lf,%lf %lf,%lf,%lf]. Button %d.\n",
x,y, dx,dy,dz, ex,ey,ez, button );
delete w;
break;
case kInputKeyboard:
sscanf( inbuf, "%s", text_buf );
AlPrintf( kStdout, "Text input: %s [%s]\n", text_buf, inbuf );
break;
}
}
static void up_func( int input, Screencoord x, Screencoord y )
{
int button;
double dx=-1, dy=-1, dz=-1, ex=-1, ey=-1, ez=-1;
AlWindow * w;
switch( AlContinuousFunction::translateInput( input, button ) ) {
case kInputButton:
w = AlUniverse::currentWindow();
w->mapToWorldSpace( x, y, dx, dy, dz, ex, ey, ez );
AlPrintf( kStdout, "Mouseup at %d,%d [%lf,%lf,%lf %lf,%lf,%lf]. Button %d.\n",
x,y, dx,dy,dz, ex,ey,ez, button );
delete w;
break;
}
}
static void cleanup_func() {
AlPrintf( kStdout, "Now leaving continuous plugin.\n" );
AlContinuousFunction::clearGoButton( TRUE );
}
AlFunctionHandle h;
AlContinuousFunction hFunc;
extern "C"
int plugin_init( void )
{
AlUniverse::initialize();
hFunc.create( "Continuous", init_func, down_func, move_func,
up_func, cleanup_func, TRUE );
hFunc.setPrompt( my_prompt, inbuf, kFilterNone );
h.create( "Cont Test", &hFunc );
h.setAttributeString( "cont" );
h.setIconPath( makeAltPath( dirName, NULL ) );
h.addToMenu( "mp_objtools" );
AlPrintf( kPrompt, "Continuous example installed on Palette 'Object Edit.");
return 0;
}
extern "C"
int plugin_exit( void )
{
h.removeFromMenu();
h.deleteObject();
hFunc.deleteObject();
return 0;
}
As mentioned earlier, command history plug-ins are not attached to a menu, but rather they are invoked when geometry changes.
See the documentation on AlCommand, AlUserCommand, and AlNotifyDagNode, as well as the examples constrainCV.c++ and polyhist.c++.
It is important to note that when modifying geometry the doUpdates() method of the geometry should be called with FALSE, and never called with TRUE. This is necessary since the command is being called from within the message system, and updates generate messages. If updates are performed during a command then unnecessary messages will be generated, and it is possible that a loop could be created where the command is responding to a message it generated.
-I$(ALIAS_LOCATION)/ODS/Common/examples