Package mrv :: Module dge :: Class NodeBase
[hide private]
[frames] | no frames]

Class NodeBase

source code

         object --+        
                  |        
interface.Interface --+    
                      |    
interface.iDuplicatable --+
                          |
                         NodeBase
Known Subclasses:

Base class that provides support for plugs to the superclass. It will create some simple tracking attriubtes required for the plug system to work

Nodes can compute values of their plugs if these do not have a cache.

Nodes are identified by an ID - the default graph implementation though will be okay with just having instances. It is also being used for string representations of this node

Nested Classes [hide private]
  shellcls
Handles per-node-instance plug connection setup and storage.
  __metaclass__
Class checking the consistency of the nodebase class before it is being created
Instance Methods [hide private]

Inherited from interface.iDuplicatable: copyTo, copyToOther, duplicate

Inherited from interface.Interface: supports

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

    Overridden from Object
 
__init__(self, *args, **kwargs)
We require a directed graph to track the connectivity between the plugs.
source code
 
__del__(self)
Remove ourselves from the graph and delete our connections
source code
 
__str__(self)
Use our id as string or the default implementation
source code
    iDuplicatable Interface
 
createInstance(self, *args, **kwargs)
Create a copy of self and return it
source code
 
copyFrom(self, other, add_to_graph=True)
Just take the graph from other, but do not ( never ) duplicate it
source code
    Base Interface
 
compute(self, plug, mode)
Called whenever a plug needs computation as the value its value is not cached or marked dirty ( as one of the inputs changed )
source code
    ID Handling
 
setID(self, newID)
Set id of this node to newiD :return: previously assigned id
source code
 
id(self)
Returns: ID of this instance
source code
    Base
 
toShells(self, plugs)
Returns: list of shells made from plugs and our node
source code
 
toShell(self, plug)
Returns: a plugshell as suitable to for this class
source code
 
clearCache(self)
Clear the cache of all plugs on this node - this basically forces it to recompute the next time an output plug is being queried
source code
 
plugs(self, predicate=<function <lambda> at 0x2f59cf8>)
Returns: list of dynamic plugs as defined on this node - they are usually retrieved on class level, but may be overridden on instance level
source code
 
inputPlugs(self, **kwargs)
Returns: list of plugs suitable as input
source code
 
outputPlugs(self, **kwargs)
Returns: list of plugs suitable to deliver output
source code
 
connections(self, inpt, output)
Returns: Tuples of input shells defining a connection of the given type from tuple( InputNodeOuptutShell, OurNodeInputShell ) for input connections and tuple( OurNodeOuptutShell, OutputNodeInputShell )
source code
Class Methods [hide private]
    Base
 
plugsStatic(cls, predicate=<function <lambda> at 0x2f59c08>)
Returns: list of static plugs as defined on this node - they are class members
source code
 
inputPlugsStatic(cls, **kwargs)
Returns: list of static plugs suitable as input
source code
 
outputPlugsStatic(cls, **kwargs)
Returns: list of static plugs suitable to deliver output
source code
 
filterCompatiblePlugs(cls, plugs, attrOrValue, raise_on_ambiguity=False, attr_affinity=False, attr_as_source=True)
Returns: sorted list of (rate,plug) tuples suitable to deal with the given attribute.
source code
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, *args, **kwargs)
(Constructor)

source code 
We require a directed graph to track the connectivity between the plugs. It must be supplied by the super class and should be as global as required to connecte the NodeBases together properly.
Parameters:
  • kwargs - 'id' = id of the instance, defaults to None if it is not required
Overrides: object.__init__

Note: we are super() compatible, and assure our base is initialized correctly

__str__(self)
(Informal representation operator)

source code 
Use our id as string or the default implementation
Overrides: object.__str__

createInstance(self, *args, **kwargs)

source code 
Create a copy of self and return it
Returns:
new instance of self
Overrides: interface.iDuplicatable.createInstance

Note: override by subclass - the __init__ methods shuld do the rest

copyFrom(self, other, add_to_graph=True)

source code 
Just take the graph from other, but do not ( never ) duplicate it
Parameters:
  • add_to_graph - if true, the new node instance will be added to the graph of
Overrides: interface.iDuplicatable.copyFrom

Note: default implementation does not copy plug caches ( which are stored in the node dict - this is because a reevaluate is usually required on the duplicated node

compute(self, plug, mode)

source code 
Called whenever a plug needs computation as the value its value is not cached or marked dirty ( as one of the inputs changed )
Parameters:
  • plug - the static plug instance that requested which requested the computation. It is the instance you defined on the class
  • mode - the mode of operation. Its completely up to the superclasses how that attribute is going to be used

Note: to be implemented by superclass

id(self)

source code 
Returns:
ID of this instance

toShells(self, plugs)

source code 
Returns:
list of shells made from plugs and our node

toShell(self, plug)

source code 
Returns:
a plugshell as suitable to for this class

plugsStatic(cls, predicate=<function <lambda> at 0x2f59c08>)
Class Method

source code 
Parameters:
  • predicate - return static plug only if predicate is true
Returns:
list of static plugs as defined on this node - they are class members

Note: Use this method only if you do not have an instance - there are nodes that actually have no static plug information, but will dynamically generate them. For this to work, they need an instance - thus the plugs method is an instance method and is meant to be the most commonly used one.

plugs(self, predicate=<function <lambda> at 0x2f59cf8>)

source code 
Parameters:
  • predicate - return static plug only if predicate is true
Returns:
list of dynamic plugs as defined on this node - they are usually retrieved on class level, but may be overridden on instance level

inputPlugsStatic(cls, **kwargs)
Class Method

source code 
Returns:
list of static plugs suitable as input

Note: convenience method

inputPlugs(self, **kwargs)

source code 
Returns:
list of plugs suitable as input

Note: convenience method

outputPlugsStatic(cls, **kwargs)
Class Method

source code 
Returns:
list of static plugs suitable to deliver output

Note: convenience method

outputPlugs(self, **kwargs)

source code 
Returns:
list of plugs suitable to deliver output

Note: convenience method

connections(self, inpt, output)

source code 
Parameters:
  • inpt - include input connections to this node
  • output - include output connections ( from this node to others )
Returns:
Tuples of input shells defining a connection of the given type from tuple( InputNodeOuptutShell, OurNodeInputShell ) for input connections and tuple( OurNodeOuptutShell, OutputNodeInputShell )

filterCompatiblePlugs(cls, plugs, attrOrValue, raise_on_ambiguity=False, attr_affinity=False, attr_as_source=True)
Class Method

source code 
Parameters:
  • attrOrValue - either an attribute or the value you would like to set to the attr at the plug in question.
  • raise_on_ambiguity - if True, the method raises if a plug has the same rating as another plug already on the output list, thus it's not clear anymore which plug should handle a request
  • attr_affinity - if True, it will not check connection affinity, but attribute affinity only. It checks how compatible the attributes of the plugs are, disregarding whether they can be connected or not Only valid if attrOrValue is an attribute
  • attr_as_source - if True, attrOrValue will be treated as the source of a connection or each plug would need to take its values. if False, attrOrValue is the destination of a connection and it needs to take values of the given plugs or they would connect to it. Only used if attrOrValue is an attribute.
Returns:
sorted list of (rate,plug) tuples suitable to deal with the given attribute. Thus they could connect to it as well as get their value set. Most suitable plug comes first. Incompatible plugs will be pruned.
Raises:
  • TypeError - if ambiguous input was found