Exemplo n.º 1
0
def initWrappers( targetmoduledict ):
    """Create Standin Classes that will delay the creation of the actual class till
    the first instance is requested
    
    :param targetmoduledict: the module's dictionary (globals()) to which to put the wrappers"""
    global nodeTypeTree
    mrvmaya.initWrappers( targetmoduledict, nodeTypeTree.nodes_iter(), MetaClassCreatorNodes )
Exemplo n.º 2
0
def initWrappers( targetmoduledict ):
	"""Create Standin Classes that will delay the creation of the actual class till
	the first instance is requested
	
	:param targetmoduledict: the module's dictionary (globals()) to which to put the wrappers"""
	global nodeTypeTree
	mrvmaya.initWrappers( targetmoduledict, nodeTypeTree.nodes_iter(), MetaClassCreatorNodes )
Exemplo n.º 3
0
def _addCustomTypeFromDagtree( targetmoduledict, dagtree, metaclass=MetaClassCreatorNodes,
                                force_creation=False, **kwargs ):
    """As `_addCustomType`, but allows to enter the type relations using a
    `mrv.util.DAGTree` instead of individual names. Thus multiple edges can be added at once
    
    :note: special care is being taken to make force_creation work - first all the standind classes
        are needed, then we can create them - just iterating the nodes in undefined order will not work
        as a parent node might not be created yet
    :note: node names in dagtree must be uncapitalized"""
    # add edges - have to start at root
    rootnode = dagtree.get_root()
    def recurseOutEdges( node ):        # postorder
        for child in dagtree.children_iter( node ):
            yield (node,child)
            for edge in recurseOutEdges( child ):   # step down the hierarchy
                yield edge

    nodeTypeTree.add_edges_from( recurseOutEdges( rootnode ) )
    mrvmaya.initWrappers( targetmoduledict, dagtree.nodes_iter(), metaclass, force_creation = force_creation, **kwargs )
Exemplo n.º 4
0
def _addCustomTypeFromDagtree( targetmoduledict, dagtree, metaclass=MetaClassCreatorNodes,
							  	force_creation=False, **kwargs ):
	"""As `_addCustomType`, but allows to enter the type relations using a
	`mrv.util.DAGTree` instead of individual names. Thus multiple edges can be added at once
	
	:note: special care is being taken to make force_creation work - first all the standind classes
		are needed, then we can create them - just iterating the nodes in undefined order will not work
		as a parent node might not be created yet
	:note: node names in dagtree must be uncapitalized"""
	# add edges - have to start at root
	rootnode = dagtree.get_root()
	def recurseOutEdges( node ):		# postorder
		for child in dagtree.children_iter( node ):
			yield (node,child)
			for edge in recurseOutEdges( child ):	# step down the hierarchy
				yield edge

	nodeTypeTree.add_edges_from( recurseOutEdges( rootnode ) )
	mrvmaya.initWrappers( targetmoduledict, dagtree.nodes_iter(), metaclass, force_creation = force_creation, **kwargs )
Exemplo n.º 5
0
def _addCustomType( targetmoduledict, parentclsname, newclsname,
                    metaclass=MetaClassCreatorNodes, **kwargs ):
    """Add a custom type to the system such that a node with the given type will
    automatically be wrapped with the corresponding class name
    
    :param targetmoduledict: the module's dict to which standin classes are supposed to be added
    :param parentclsname: the name of the parent node type - if your new class
        has several parents, you have to add the new types beginning at the first exsiting parent
        as written in the maya/cache/nodeHierarchy.html file
    :param newclsname: the new name of your class - it must exist targetmodule
    :param metaclass: meta class object to be called to modify your type upon creation
        It will not be called if the class already exist in targetModule. Its recommended to derive it
        from the metaclass given as default value.
    :raise KeyError: if the parentclsname does not exist"""
    # add new type into the type hierarchy #
    parentclsname = uncapitalize( parentclsname )
    newclsname = uncapitalize( newclsname )
    nodeTypeTree.add_edge( parentclsname, newclsname )

    # create wrapper ( in case newclsname does not yet exist in target module )
    mrvmaya.initWrappers( targetmoduledict, [ newclsname ], metaclass, **kwargs )
Exemplo n.º 6
0
def _addCustomType( targetmoduledict, parentclsname, newclsname,
				   	metaclass=MetaClassCreatorNodes, **kwargs ):
	"""Add a custom type to the system such that a node with the given type will
	automatically be wrapped with the corresponding class name
	
	:param targetmoduledict: the module's dict to which standin classes are supposed to be added
	:param parentclsname: the name of the parent node type - if your new class
		has several parents, you have to add the new types beginning at the first exsiting parent
		as written in the maya/cache/nodeHierarchy.html file
	:param newclsname: the new name of your class - it must exist targetmodule
	:param metaclass: meta class object to be called to modify your type upon creation
		It will not be called if the class already exist in targetModule. Its recommended to derive it
		from the metaclass given as default value.
	:raise KeyError: if the parentclsname does not exist"""
	# add new type into the type hierarchy #
	parentclsname = uncapitalize( parentclsname )
	newclsname = uncapitalize( newclsname )
	nodeTypeTree.add_edge( parentclsname, newclsname )

	# create wrapper ( in case newclsname does not yet exist in target module )
	mrvmaya.initWrappers( targetmoduledict, [ newclsname ], metaclass, **kwargs )
Exemplo n.º 7
0
Arquivo: typ.py Projeto: kthulhu/mrv
def initWrappers( ):
	""" Create Standin Classes that will delay the creation of the actual class till
	the first instance is requested"""
	mrvmaya.initWrappers( _uipackage.__dict__, _typetree.nodes_iter(), MetaClassCreatorUI )