The morph module allows you to implement an object that can dynamically switch between different overlapping implementations. This module is one way that you can implement a dynamic network, where modules are created and deleted automatically. With this approach, you do not have to write any code to explicitly delete or create modules, or make or break connections. You do have to invest some work to define the types properly to get the right behavior.

Input ports

morph_obj

Points to the object into which objects are to be merged.

morph_type

An index into the morph_types array to select which object should be merged into the value of morph_obj. As this value changes, the old object is unmerged from the value of morph_obj and the new object is merged.

morph_types

Defines a library of objects between which to morph. The objects in this library are merged into the morph_obj as the morph_type parameter changes.

Usage

The morph module uses the merge and unmerge facilities of the Object Manager to switch between types. As you change the morph_type parameters, the morph object is deinstanced, the old type is unmerged, the new type is merged and the morph object is reinstanced. The unmerge operation removes any subobjects or values that are not defined in the base type of the morph object.

To use this object, you first define a morph object. This is the object that you should connect to the morph_obj parameter and should contain all of the parameters and subobjects that you want preserved as you switch between types. Then you define two or more morph types that will be merged into the morph object based on the setting of the morph_type parameter. These objects may be derived from the template of the morph object, but this is not necessary.

This example shows how you can use the morph object to create a UI object that switches configuration based on the setting of the morph_type parameter. This example could have been implemented by switching the visibility of the widgets as well. The advantage of using the morph object is that only the widgets that are in use are instanced at any given time. For larger examples, this can improve the performance of the system as it takes some time to instance UI objects even if they are not visible.

This second example shows how the morph object can be used to create a dynamic visualization network. The first morph type implements an isosurface module, the second morph type implements combination of slice plane and isoline. The threshold value and component parameters are shared between the two different modules.