rfm2  22.0
A python-based rewrite of RenderMan for Maya
 All Classes Namespaces Files Functions Variables Pages
rfm2.ui.prefs Namespace Reference

Functions

def execute_callback
 
def qt_ui
 
def widget
 
def get_pref
 
def get_pref_by_name
 
def set_pref
 
def set_pref_by_name
 
def remove_pref
 
def remove_all_prefs
 
def register_pref_item
 
def get_module_prefs
 
def clear_module_prefs
 
def pref_window
 
def set_defaults
 
def hold_current_state
 
def update_ui
 
def create_frame
 
def create
 
def resize_tab_layout_to_fit
 
def register_prefs_ui
 
def unregister_ui
 

Variables

dictionary _PREFS_ = {}
 
string _TABNAME_ = 'rfmPrefsTab'
 
string _FRAMENAME_ = 'rfmPrefsFrame'
 
 _ACCEPTED_ = False
 
string kQtUI = 'qt_ui'
 
string PAGE_SEP = '|'
 

Detailed Description

The preferences module is in charge of:
  - Registering a preference tab in Maya's preference dialog.
  - Drawing and managing the preference UI.
  - Pulling preferences from rfm2 modules.
  - Provide preference registration and lookup API.

* Registering a RenderMan preference
    Modules (or any other python program) can register preferences to be
    displayed in the RenderMan section of Maya's preference window.
    All you need to do is call rfm2.ui.prefs.register_pref_item(). See that
    function's documentation for details.

* Preferences Registration
    At startup, get_module_prefs() is called by rfm2.renderer.register().
    get_module_prefs() walks the rfm2 module and call register_prefs() for each
    module. If that function doesn't exist for a given module, we simply catch
    the error and move on.
    It is also possible for any external script to register their own tab/pref
    by calling rfm2.ui.prefs.register_pref_item().

    RegisterPrefs() is implemented in rfm2.utils.file_dialog and rfm2.render.
    RegisterPrefs() can register one or more prefs.
    It can be as simple as :

    - creating a dictionnary to describe the pref
        pref = {'name': 'rfmRenderIprDestination', 'type': 'string',
                'default': 'Maya Render View', 'label': 'Render to:',
                'page': 'Render/IPR', 'widget': 'popup',
                'options': 'Maya Render View|Pixar It'}

    - initialize a rfm2.utils.node_desc.NodeDescParamJSON object with it.
        pdesc = rfm2.utils.node_desc.NodeDescParamJSON(pref)

    - pass it as the second argument to rfm2.ui.prefs.register_pref_item().
        rfm2.ui.prefs.register_pref_item(prefGroup,
                   node_desc.NodeDescParamJSON(pref))

* Supported widgets
  - int: mapper, checkBox, default
  - float: default
  - string: popup, fileInput, default

* Useful API calls
    register_pref_item(): register a single RenderMan pref.
    get_pref_by_name(): get a pref's value by name.
    set_pref_by_name(): prefs are usually set in the preference dialog, but it is
 sometimes useful to store a specific value from another UI.

Function Documentation

def rfm2.ui.prefs.clear_module_prefs ( )
Clears our internal pref storage.

+ Here is the caller graph for this function:

def rfm2.ui.prefs.create ( )
Called by Maya: The callback function to create the tab.

+ Here is the call graph for this function:

def rfm2.ui.prefs.create_frame ( )
Called by Maya: The callback function to create the frame layout of the
tab.
def rfm2.ui.prefs.execute_callback (   pdesc,
  name 
)
Safely execute a Qt callback for custom Qt widgets

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def rfm2.ui.prefs.get_module_prefs ( )
Recursively walk through the rfm2 module to harvest preferences.

We call register_prefs() on every module to give them an opportinity to
contribute preference items. If there is no register_prefs() function, we
silently swallow the error and move on to the next module.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def rfm2.ui.prefs.get_pref (   pdesc,
  hold = False 
)
Return a pref's value, based on the pdesc object.

Args:
- pdesc (NodeDescParamJSON): full pref description.

Kwargs:
- hold:  get the value of the holding primvar instead.

Returns:
- any type

+ Here is the caller graph for this function:

def rfm2.ui.prefs.get_pref_by_name (   pref_name)
Return a pref's value based on its name.

Args:
- pref_name (str): the name of the optionVar.

Returns:
- any type

Raises:
- ValueError: if this is not a registered pref.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def rfm2.ui.prefs.hold_current_state (   mode)
Called by Maya: The callback function to save or restore the preference
setting of the tab.

+ Here is the call graph for this function:

def rfm2.ui.prefs.pref_window ( )
Return the name of Maya's preferences window.

+ Here is the caller graph for this function:

def rfm2.ui.prefs.qt_ui (   param_desc)
Create a Qt UI by calling its 'create' callback.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def rfm2.ui.prefs.register_pref_item (   group,
  param_desc 
)
Register a preference that will be displayed in Maya's preferences
dialog.

Args:
- group (string): groups are used to identify and order the prefs in the
                  UI. Groups are alphabetically sorted and will be drawn in
                  the same order. The value of the group string should be
                  consistent accross modules but isn't used beyond ordering.
- param_desc (NodeDescParamJSON): full pref description object.

Raises:
- KeyError: if the same pref has been registered in the same group.

+ Here is the caller graph for this function:

def rfm2.ui.prefs.register_prefs_ui ( )
Register the RenderMan preference tab in Maya.
NOTE: addCustomPrefsTab() only takes MEL procs as arguments, so we use the
MEL proc declared below to call our python code.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def rfm2.ui.prefs.remove_all_prefs ( )
Delete all registered prefs from Maya, by deleting the optionVars.

+ Here is the call graph for this function:

def rfm2.ui.prefs.remove_pref (   pdesc,
  hold = False 
)
Remove a pref from Maya's optionVars.

Args:
- pdesc (NodeDescParamJSON): a pref description.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def rfm2.ui.prefs.resize_tab_layout_to_fit (   tablyt)
Resize our tab layout by recursively computing the size of enclosed
controls.
def rfm2.ui.prefs.set_defaults ( )
Called by Maya: The callback function to set option vars to default
values.

+ Here is the call graph for this function:

def rfm2.ui.prefs.set_pref (   pdesc,
  value,
  hold = False 
)
Sets the value of a pref, based on it's description object.

Args:
- pdesc (NodeDescParamJSON): full pref description.
- value (any type): the new value.

Kwargs:
- hold:  write the new value to the holding optionVar instead.

Raises:
- TypeError: if we encounter an unknown data type.

+ Here is the caller graph for this function:

def rfm2.ui.prefs.set_pref_by_name (   pref_name,
  val 
)
Set the value of a pref, based on its name.

Args:
- pref_name (str): the pref's name.
- val (any type): the new value.

Raises:
- KeyError: if this is not a registered pref.

+ Here is the call graph for this function:

def rfm2.ui.prefs.unregister_ui ( )
Unregister the RenderMan preference tab in Maya and clear our preference
storage.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def rfm2.ui.prefs.update_ui ( )
Called by Maya: The callback function to update UI elements when option
vars changed

+ Here is the call graph for this function:

def rfm2.ui.prefs.widget (   param_desc)
Create/update a preference widget.

We support the following widgets (arrays not supported for now):
- int: mapper, checkBox, default
- float: default
- string: popup, fileInput, default

Args:
- param_desc (NodeDescParamJSON): full pref description.

Raises:
- TypeError: if we encounter an un-implemented data type.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

rfm2.ui.prefs._ACCEPTED_ = False
string rfm2.ui.prefs._FRAMENAME_ = 'rfmPrefsFrame'
dictionary rfm2.ui.prefs._PREFS_ = {}
string rfm2.ui.prefs._TABNAME_ = 'rfmPrefsTab'
string rfm2.ui.prefs.kQtUI = 'qt_ui'
string rfm2.ui.prefs.PAGE_SEP = '|'