Scheme Editors
 
 
 

The alternate and original way of creating Alias editors utilizes a scheme interface. This technique is described next.

First scheme file

If the plug-in requires an option box, the first scheme file is used to define it. All Alias option boxes are written in Scheme, which is described below. For many examples of option box files, examine the .o.scm files that reside in subdirectories in the Alias install area.

Second scheme file

If the plug-in requires an option box and the option box requires default values for its variables, these default values are set in this file, which is invoked from plugin_init().

Creating symbols and strings in Scheme

To pass information around in scheme,we define symbols as place-holders for values, and strings as names for those values. This is done through two primitives, ui-symbol and ui-string. These functions add elements to symbol tables inside of Alias, unlike the define primitive which adds a symbol to Scheme’s symbol table. In places where the name of a symbol is desired (for example, the label for a menu item), a search is done of the string symbol table for a string with the same symbol name as the given symbol. If one is found, the associated string is used. If not, the actual symbol name is used instead. So, for example:

	(ui-symbol ’my_symbol 16)

The default value of the symbol will be 16. No ui-string is associated with this symbol. Therefore, the text “my_symbol” will appear whenever the name of this symbol is displayed.

	Example 2: 
	(ui-string ’my_symbol “Number of Cows”) 
	(ui-symbol ’my_symbol 16)

In this case a ui-string is defined with the same symbol name. When the name of the symbol “my_symbol” is required, a search is done for a ui-string with the same name. Here one is found, and the text “Number of Cows” will be used as the name of this symbol.

Creating an Option Box with Scheme

You create option boxes with a call to the ui-editor primitive. There are several arguments that apply to option boxes in general. The remaining arguments specify the widgets (editor tools) that make up the option box.

General option box attributes

The following attributes describe the general behavior of an option box.

Option box widgets

An option box can specify any number of ui-widgets, a set of editor tools like sliders, ticks, and buttons that can be used to set ui-symbols.

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.

Rebuilding Selectors

If a rebuild is desired when a change of value occurs we add the rebuild property.

	(ui-radio-widget ’variable  	
(list ’rebuild)  	
(ui-choice	’title_symbol_1		’VALUE1)  	
(ui-choice	’title_symbol_2		’VALUE2)  	
(ui-choice	’title_symbol_3		’VALUE3) 
)

Selectively Enabling Selectors

Sometimes the selector should be displayed only under certain conditions.

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) 
)

Changing Number of Columns

The default for radio widgets is two columns. To specify the number of columns use the columns property. The value range is 1, 2 or 3.

	(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) 
)

Making Assignments to Variables

When a choice is selected you may assign a value to another variable. For example in the primitives option box the number of caps is set when cylinders or cones are specified.

(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) 
)

These assignments may be made conditionally. If for example the number of caps for a cone should be set to one only if it was two then we could specify this as

	(ui-choice ’prim.type.cone				’MO_CONE  	
   (list ’assign (ui-eq ’mo_prim_caps 2) ’mo_prim_caps 1)
  	)

This way if it was set to zero then it wouldn’t change.

Additional Widgets

Note that if the ui-radio-widget has an “enabled” bit to it, the separator widget has to have the same.

A Complete List of Widgets

Selection Widgets

  • ui-radio-widget - radio choices
  • ui-popup-widget - choices on popup
  • ui-boolean-widget - on/off choice (shown as tick)

Numbers

  • ui-integer-widget
  • ui-double-widget
  • ui-distance-widget - double which displays in current linear unit
  • ui-angle-widget - double which displays in current angular unit

Triples

  • ui-wdltriple-widget - triple with 3 symbols
  • ui-wdltriple-linear-widget - triple with 3 symbols representing distance.
  • ui-triple-widget - triple using array (instead of 3 numbers).

Miscellaneous

  • ui-string-widget
  • ui-separator-widget - visual separator
  • ui-group-widget - group a section of widgets together under expand/compress

Widget Properties

  • ui-radio-widget
    • (list “rebuild”)
    • (list 'enabled (some condition))
    • (list 'columns 3)
  • ui-double-widget (and so on)
    • (list “rebuild”) - this widget gets a rebuild if another widget elsewhere in the option box is depending on its state.
    • (list 'enabled (some condition)) - condition for when the widget is shown.
    • (list 'precision “%f6.2”) - precision
    • (list 'range 0 360) - valid range
    • (list ’slider_range 0.0 500.0) - allows numbers outside of the range to be entered

Tooltips

(ui_function_tooltip_item
 	"FunctionName"
 	"ToolTip String")

See the supplied examples for uses of these widgets.