Procedure constructor

You begin writing a procedure mode by deriving a new class from AFXProcedure.

In the body of the AFXProcedure constructor you must call the base class constructor and pass in the owner, which is the module or toolset GUI to which this procedure belongs. Optionally, you can pass in a value for the type of procedure. The default value for the type is NORMAL. The type defines what happens when a new procedure is activated while another procedure is currently executing.

The type of a procedure can be either NORMAL or SUBPROCEDURE. When a normal procedure is activated, it cancels any procedure that is currently executing. When a subprocedure is activated, it suspends a normal procedure or cancels another subprocedure. If a procedure is suspended, it resumes upon the completion of the subprocedure.

View procedures (for example, pan, rotate, and zoom) are special types of procedures that cannot be suspended. View procedures are always cancelled when another procedure is activated, and they always suspend any currently executing procedure when they are activated.

By default, procedures are identified by the infrastructure using their class name. If you need to have multiple instances of a procedure executing at the same time, you will need to distinguish their names to the infrastructure by calling the setModeName method.

After you have derived a new class from AFXProcedure, you define the commands and keywords needed for the mode. The keywords are stored as members of the mode so that they can be accessed by steps. If you set registerQuery=True in the AFXGuiCommand constructor, the mode will query the kernel object specified by the command when it is activated and automatically set the values of the command's keywords. For more information, see Keeping the GUI and commands up-to-date. If there is no kernel object associated with your command (for example, when creating a new object), you can set the keyword values by specifying a default value in their constructor.

If you have a default object that you want to use to reestablish default values for a dialog box, you can use the mode’s registerDefaultsObject method to register an object whose values will be queried when the user presses the Defaults button in the dialog box. For more information, see Defaults objects.

By default, dialog boxes are posted as modeless. You can post a dialog box as modal by calling self.setModal(True). In most cases you set the modality only once in the mode; however, you can change the modality as often as needed by calling the setModal method in the getFirstDialog or getNextDialog methods. For more information, see Modal versus modeless.