usd_chunks.chunk_notice
Notices and the dependency graph behind every chunk object.
Tf.Notice is USD's built-in callback system, similar to Qt's signals. This module uses Tf.Notice extensively but hides most of its API, so a client can be up and running with callbacks without managing the lifetime of listeners.
ChunkNoticeAlias names each supported notice class, so the notice you are interested in can be found without caring how it is implemented. Every custom notice subclasses ChunkNotice, which carries additional data whose type depends on the notice and on who sends it.
The easiest way to send a notice is explicitly, with send_notice:
AttributeChangeNotice
⚓︎
Bases: ChunkNotice
Sent when an attribute changes; data is its AttributeSender.
Source code in usd_chunks/chunk_notice.py
AttributeFlagsChangeNotice
⚓︎
Bases: AttributeChangeNotice
Sent when an object's flags change.
Source code in usd_chunks/chunk_notice.py
AttributeStateChangeNotice
⚓︎
Bases: AttributeChangeNotice
Sent when an object's state bits change.
Source code in usd_chunks/chunk_notice.py
CallbackContainer
⚓︎
The callbacks on one ChunkNoticePropagator, with their private and on-create tags.
Kept here rather than on the NoticeConnection objects so as not to pollute that class. Private callbacks are neither serialized nor copied between propagators. Callbacks created in init should be private: they are recreated when deserializing, so serializing them too would duplicate them.
Callbacks are stored in self.callbacks as a list of dicts with the keys 'conn' (the NoticeConnection), 'on_create' and 'private'.
Source code in usd_chunks/chunk_notice.py
add
⚓︎
Store a callback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
NoticeConnection
|
The connection. |
required |
trigger_on_create
|
Run it when the owning object is added to the scene. |
True
|
|
private
|
Keep it out of copies and serialization. |
False
|
Source code in usd_chunks/chunk_notice.py
clear
⚓︎
extend
⚓︎
Add another container's non-private callbacks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
CallbackContainer
|
The container to copy from. |
required |
Source code in usd_chunks/chunk_notice.py
get
⚓︎
The stored connections.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_private
|
Include private callbacks. |
False
|
Returns:
| Type | Description |
|---|---|
|
The connections. |
Source code in usd_chunks/chunk_notice.py
get_on_create
⚓︎
The connections to run when the owning object is added to the scene.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_private
|
Include private callbacks. |
False
|
Returns:
| Type | Description |
|---|---|
|
The connections. |
Source code in usd_chunks/chunk_notice.py
CameraChangedNotice
⚓︎
Bases: ChunkNotice
Sent when the host's active camera changes; data is the camera.
Source code in usd_chunks/chunk_notice.py
ChunkChangeNotice
⚓︎
Bases: ChunkNotice
Sent when a chunk or anything inside it changes; data is the chunk.
Source code in usd_chunks/chunk_notice.py
ChunkConfigChanged
⚓︎
Bases: ChunkNotice
Sent when a chunk's config changes; data is the config.
Source code in usd_chunks/chunk_notice.py
ChunkDeletedNotice
⚓︎
Bases: ChunkNotice
Sent when any chunk object is deleted; data is the object.
Source code in usd_chunks/chunk_notice.py
ChunkLoadedNotice
⚓︎
Bases: ChunkNotice
Sent when a chunk is added to the scene; data is the chunk.
Source code in usd_chunks/chunk_notice.py
ChunkNotice
⚓︎
Bases: Notice
A Tf.Notice that carries data about what changed.
Receivers use the data to find what has been changed, including globally registered listeners that did not subscribe to a particular sender.
Attributes:
| Name | Type | Description |
|---|---|---|
data |
Any
|
The data sent with the notice. Its type varies between notices. |
alias |
ChunkNoticeAlias
|
The alias associated with this notice. |
Source code in usd_chunks/chunk_notice.py
ChunkNoticeAlias
⚓︎
Bases: IntEnum
The name of each supported Tf.Notice class, used as the client-facing way to pick a notice.
Any supported notice has an alias in this enum.
Attributes:
| Name | Type | Description |
|---|---|---|
NONE |
A default, empty alias |
|
PARAM_CHANGED |
Sent when a param changes |
|
GROUP_CHANGED |
Sent when a group changes. This includes nested groups and param changes |
|
CHUNK_CHANGED |
Similar to GROUP_CHANGED but only for chunks |
|
PARAM_ADDED |
Sent when a param was added as a child to a group or chunk |
|
PARAM_REMOVED |
Sent when a param was removed as a child from a group or chunk. Not necessarily deleted |
|
CHUNK_DELETED |
A chunk object was deleted. Use instead of PARAM_REMOVED for most applications: PARAM_REMOVED is only sent for a child of a NameSyncedContainer (group / chunk / vector), while CHUNK_DELETED is sent whenever ANY chunk object is deleted |
|
ATTRIBUTE_CHANGED |
Default notice for attributes that do not set an alias explicitly |
|
FLAGS_CHANGED |
Sent when the flags attribute changes |
|
STATE_CHANGED |
Sent when the state attribute changes |
|
MENU_ACTION_NOTICE |
Sent when a menu action should be executed |
|
PRIM_SELECTION_CHANGED |
Sent whenever the host's prim selection changes |
|
PROP_SELECTION_CHANGED |
Sent whenever the host's property selection changes |
|
OBJECT_CHANGED |
Sent whenever anything was changed on the stage |
|
STAGE_CHANGED |
Sent when the stage is changed |
|
STAGE_CONTENTS_CHANGED |
Sent when stage contents changed |
|
STAGE_EDIT_TARGET_CHANGED |
Sent when the edit target on the stage changed |
|
CHUNK_LOADED |
Sent when a new chunk has been added to the registry |
|
CHUNK_UNLOADED |
Sent when a chunk was unloaded |
|
CUSTOM |
Custom notices should be registered with aliases > CUSTOM |
ChunkNoticePropagator
⚓︎
Base class that makes chunk objects connectable, to each other and to callbacks.
Chunk objects connect to each other through 'physical' connections and to callbacks through 'non-physical' ones. Physical connections rely on dependencies (inputs) and dependants (outputs and owners); non-physical connections rely on the Tf.Notice system and have no dependencies. Callbacks are non-physical; inputs, outputs and the owner are physical.
Physical:
'Children' reference their owning object (parent), and call data_changed() on the owner when the child has been modified. The DagNode manages these connections: it holds references to inputs, outputs and an owner, and solves its outputs recursively while respecting dependencies, so a node does not solve until all its inputs are solved. Any number of dependencies (inputs) can be added to an instance of this class; once all of them are solved, the instance's DagNode solves too, calling data_changed(). Combined with callbacks, this lets a client build dependency graphs of chunk classes and have the system trigger callbacks when appropriate.
Non-physical:
Connections added with add_callback are not managed by the DAG. The Tf.Notice system manages them, without any dependency information, so a callback never triggers another callback implicitly.
By default send_self() is called whenever an attribute or child attribute has been modified. The notice sent is decided by get_notice_alias(), and the DagNode also propagates it up the owner hierarchy.
get_edit_context(), get_layer_identifier() and get_stage() can be implemented to support layer contexts when modifying the stage. A NoticeConnection sets the edit context to the layer returned by get_edit_context() before running its callback, which keeps callbacks contained to the layers managed by ChunkLayerManager. See NoticeConnection.handle_callback.
Source code in usd_chunks/chunk_notice.py
add_callback
⚓︎
add_callback(method, sender=None, listen_globally=False, notice_alias=ChunkNoticeAlias.NONE, send_on_create=False, private=False)
Subscribe a callback to a notice.
When the notice is sent, method is called with one of two signatures, chosen from the
callback's own declared parameters:
(notice(Tf.Notice), sender(Any))
Matches Tf.Notice. This is what a bound method gets, where self is already the
object holding the state -- the preferred form. Plain functions may declare it too.
(owner(Any), notice(Tf.Notice), sender(Any))
The convenience form for module-level functions, where owner is the object
add_callback was called on. Note owner is not the same as sender: sender is
whatever dispatched the notice, which may be a proxy, an attribute sender, or an
unrelated object when listening globally.
With no sender, self is assumed to be the sender, which keeps the simple case simple::
my_param.add_callback(my_callback)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
Callable
|
The method to call when the notice is sent |
required |
sender
|
Any
|
The sender to subscribe to. If None, self is used unless listen_globally is True. Defaults to None. |
None
|
listen_globally
|
bool
|
Subscribe to every notice of type notice_alias, whatever its sender. Defaults to False. |
False
|
notice_alias
|
ChunkNoticeAlias
|
The notice to subscribe to. NONE uses the sender's get_notice_alias(). Defaults to ChunkNoticeAlias.NONE. |
NONE
|
send_on_create
|
bool
|
Also call it when the owning object is added to the scene. Defaults to False. |
False
|
private
|
bool
|
Keep the callback out of serialization and copies, which is what a callback added inside init needs. Defaults to False. |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
It would hear another chunk. Chunks speak to each other only through wires: listen_globally is for the stage and the host (SCENE_ALIASES), and a sender is this object's own chunk or something in it. |
Source code in usd_chunks/chunk_notice.py
1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 | |
add_dependency
⚓︎
Add an input. This propagator does not evaluate until all inputs are solved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
ChunkNoticePropagator
|
The node to add as input |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The dependency index |
Source code in usd_chunks/chunk_notice.py
data_changed
⚓︎
Called by the DagNode when it solves, once all inputs (dependencies) are solved.
The returned notice is propagated by the DagNode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notice
|
ChunkNotice | None
|
The notice that was sent |
None
|
Returns:
| Type | Description |
|---|---|
ChunkNotice | None
|
ChunkNotice | None: The notice to propagate, or None when blocked |
Source code in usd_chunks/chunk_notice.py
execute
⚓︎
Re-execute this object, and everything downstream of it, now.
Dirties it and solves downstream: each solved object's data_changed() runs, and with it send_self(), which triggers any connected callbacks. When the solve has finished, every chunk it reached runs its module's execute(node) once, upstream first (chunk_cook.flush, then chunk_cook.cook). Inside batched_solve() it only dirties, and the solve waits for the block to end; inside another chunk's cook, the chunks it reaches cook once that cook has ended.
This is the one way to run a chunk again: a module's execute(node) is written, never called directly, and chunk_cook.cook is the framework's step, not an API.
Source code in usd_chunks/chunk_notice.py
find_callbacks
⚓︎
Find the NoticeConnections stored on this object that match every given filter.
For example, passing method finds connections whose method is that function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
Callable
|
Filter by method on connections. Defaults to None. |
None
|
sender
|
ChunkNoticePropagator
|
Filter by sender. Defaults to None. |
None
|
notice_type
|
ChunkNoticeAlias
|
Filter by alias. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
list[NoticeConnection]
|
list[NoticeConnection]: The matching connections |
Source code in usd_chunks/chunk_notice.py
get_callbacks
⚓︎
Get the callback connections, private ones included.
Returns:
| Type | Description |
|---|---|
list[NoticeConnection]
|
list[NoticeConnection]: The callback connections |
get_chunk_module
⚓︎
The registered chunk module this object's behaviour comes from, or None.
Only a chunk has one -- ChunkBase overrides this to look its module up in the registry. Declared here so the solve can ask any propagator whether it has behaviour to run without knowing the chunk classes, which this module cannot import.
Returns:
| Type | Description |
|---|---|
ChunkModule | None
|
Always None here. |
Source code in usd_chunks/chunk_notice.py
get_dag_node
⚓︎
Get this object's DagNode, creating it on first use.
Returns:
| Name | Type | Description |
|---|---|---|
DagNode |
DagNode
|
The DagNode held by this ChunkNoticePropagator instance |
Source code in usd_chunks/chunk_notice.py
get_dependencies
⚓︎
Get the inputs of this propagator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predicate
|
Predicate[_T] | None
|
Only return inputs matching this. |
None
|
Returns:
| Type | Description |
|---|---|
|
list[tuple[int, ChunkNoticePropagator]]: (key, input) pairs |
Source code in usd_chunks/chunk_notice.py
get_dependency
⚓︎
Get one input of this propagator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
The key of the input. |
0
|
predicate
|
Predicate[_T] | None
|
Only return the input if it matches this. |
None
|
Returns:
| Type | Description |
|---|---|
ChunkNoticePropagator | None | _T
|
ChunkNoticePropagator | None: The input at index, or None if there is none |
Raises:
| Type | Description |
|---|---|
ValueError
|
The input exists but does not match the predicate. |
Source code in usd_chunks/chunk_notice.py
get_dependent
⚓︎
Get one output of this propagator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
The key of the output. |
0
|
predicate
|
Predicate[_T] | None
|
Only return the output if it matches this. |
None
|
Returns:
| Type | Description |
|---|---|
ChunkNoticePropagator | None | _T
|
ChunkNoticePropagator | None: The output at index, or None if there is none |
Raises:
| Type | Description |
|---|---|
ValueError
|
The output exists but does not match the predicate. |
Source code in usd_chunks/chunk_notice.py
get_dependents
⚓︎
Get every propagator that depends on this one (connected to its output).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predicate
|
Predicate[_T] | None
|
Only return dependents matching this. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
|
list[tuple[int, ChunkNoticePropagator]]: (key, dependent) pairs |
Source code in usd_chunks/chunk_notice.py
get_edit_context
abstractmethod
⚓︎
Get a layer the chunk object can safely add changes to the stage in.
Returns:
| Type | Description |
|---|---|
Layer | None
|
Sdf.Layer | None: The layer that can be modified |
get_layer_identifier
abstractmethod
⚓︎
Get a unique layer identifier for creating and accessing layers.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The unique layer identifier |
get_notice_alias
abstractmethod
⚓︎
The notice this object sends from send_self(), and listens for by default in add_callback().
Subclasses override this to send the right notice when something on the chunk object changes.
Returns:
| Name | Type | Description |
|---|---|---|
ChunkNoticeAlias |
ChunkNoticeAlias
|
The default notice alias |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
A subclass does not implement it. |
Source code in usd_chunks/chunk_notice.py
get_notice_data
⚓︎
The data attached to the notice send_self() sends.
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
This object, by default |
get_on_create_callbacks
⚓︎
Get the callbacks to trigger when the chunk is added to the scene.
Returns:
| Type | Description |
|---|---|
list[NoticeConnection]
|
list[NoticeConnection]: The connections to trigger when loaded |
Source code in usd_chunks/chunk_notice.py
get_owner
⚓︎
Get the owning ChunkNoticePropagator of this object.
Returns:
| Type | Description |
|---|---|
ChunkNoticePropagator | None
|
ChunkNoticePropagator | None: The owning object, or None |
get_stage
abstractmethod
⚓︎
Get a handle to the stage.
Returns:
| Type | Description |
|---|---|
Stage | None
|
Usd.Stage | None: A Usd.Stage if available |
is_blocked
abstractmethod
⚓︎
Check whether this instance should be blocked from sending notices.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if blocked or the owner is blocked, False otherwise |
Source code in usd_chunks/chunk_notice.py
is_presentation_change
⚓︎
Whether the change this propagator is being dirtied for is presentation only.
A presentation change is one nothing downstream computes from -- hiding a param, folding a group open, selecting a node. Such a change still has to reach the UI, so it solves and sends its notice as usual, but it must not dirty anything that reads this propagator's data: see chunk_scheduler.propagate_dirty.
Asked at dirty time, so an implementation describes the change that just happened rather than the object in general. Only AttributeSender answers True (for the state attribute, and only while DISABLED is untouched) -- everything else is a data change.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if this change must not dirty dependants |
Source code in usd_chunks/chunk_notice.py
remove_dependency
⚓︎
Remove an input previously added with add_dependency.
Dirties this propagator so the loss of the input propagates downstream like any other change. Sends DEPENDENCY_REMOVED, so ChunkStageSync removes the USD connection too and the saved file loses the wire. When the connection is already gone (the stage sync mirroring a wire the graph cut) that is a no-op.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
ChunkNoticePropagator
|
The node to drop as input |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if input was a dependency and got removed |
Source code in usd_chunks/chunk_notice.py
request_delete
abstractmethod
⚓︎
Delete this object. Implemented by a subclass.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
A subclass does not implement it. |
send_self
⚓︎
Sends a Tf.Notice, with self as sender. The type of notice is determined by get_notice_alias(), or optionally the alias argument.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alias
|
Optional[ChunkNoticeAlias]
|
An optional alias to send. If alias is not None, it will be used instead of the default from get_notice_alias() |
None
|
data
|
Any
|
The data to attach to the notice. If None, will use self.get_notice_data(). Defaults to None |
None
|
Returns:
| Type | Description |
|---|---|
ChunkNotice | None
|
Optional[ChunkNotice]: The notice that was sent, or None if no notice was sent |
Source code in usd_chunks/chunk_notice.py
set_blocked
⚓︎
set_owner
⚓︎
Set the owner of this object: its parent in a parent-child relationship.
Call this once the parent has actually taken ownership of this object, to update the child when the relationship has changed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
owner
|
ChunkNoticePropagator | None
|
The owning (parent) object that should receive notices when this instance is modified |
required |
dirty
|
bool
|
Whether joining marks the owner dirty; see DagNode.set_owner. |
True
|
Source code in usd_chunks/chunk_notice.py
ChunkNoticeRegistry
⚓︎
The registry mapping each ChunkNoticeAlias to its Tf.Notice class.
The easiest way to register a new notice is to decorate its class with @chunk_notice::
@chunk_notice(ChunkNoticeAlias.PARAM_CHANGED)
class ParamChangeNotice(ChunkNotice):
pass
Attributes:
| Name | Type | Description |
|---|---|---|
registered |
dict[int, type[Notice]]
|
Maps a ChunkNoticeAlias to a registered notice class |
get_from_alias
classmethod
⚓︎
Get a registered notice from a ChunkNoticeAlias.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alias
|
ChunkNoticeAlias
|
The alias to look up |
required |
Raises:
| Type | Description |
|---|---|
ErrorException
|
If the alias has not been registered |
Returns:
| Type | Description |
|---|---|
type[ChunkNotice]
|
type[Tf.Notice]: The class of the registered notice |
Source code in usd_chunks/chunk_notice.py
register
classmethod
⚓︎
Register a new notice and associate it with an alias.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alias
|
ChunkNoticeAlias
|
The alias to associate with the notice |
required |
notice_class
|
type[Any]
|
The class that should be registered |
required |
Source code in usd_chunks/chunk_notice.py
ChunkUnloadedNotice
⚓︎
Bases: ChunkNotice
Sent when a chunk is unloaded; data is the chunk.
Source code in usd_chunks/chunk_notice.py
DagConnections
⚓︎
The connections of one DagNode.
Attributes:
| Name | Type | Description |
|---|
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
owner
|
ReferenceType[ChunkNoticePropagator] | None
|
|
None
|
inputs
|
ConnSetT
|
Mapping class that references values weakly. Entries in the dictionary will be discarded when no strong reference to the value exists anymore |
<dynamic>
|
outputs
|
ConnSetT
|
Mapping class that references values weakly. Entries in the dictionary will be discarded when no strong reference to the value exists anymore |
<dynamic>
|
DagGraphID
⚓︎
Which connected graph a DagNode belongs to, merged union-find style as nodes connect.
Source code in usd_chunks/chunk_notice.py
get_identifier
⚓︎
root
⚓︎
The terminal DagGraphID of the _store chain, found iteratively.
The path is compressed on the way, so every visited id points directly at the root afterwards.
Returns:
| Type | Description |
|---|---|
DagGraphID
|
The root id. |
Source code in usd_chunks/chunk_notice.py
DagNode
⚓︎
A connectable node in the dependency graph between chunk objects.
A DagNode handles the 'physical' connections between ChunkNoticePropagator objects, as opposed to NoticeConnection, which handles non-physical ones. It may have any number of inputs and outputs, and one owner. Dirtying a node dirties its outputs and owner, recursively. A client solves this node and everything connected downstream by calling solve_outputs().
Attributes:
| Name | Type | Description |
|---|---|---|
dirty |
bool
|
Whether this node needs solving |
propagator |
ChunkNoticePropagator
|
The propagator this node represents |
Source code in usd_chunks/chunk_notice.py
dirty
property
writable
⚓︎
Whether this node needs solving; setting it True dirties everything downstream.
add_dependant
⚓︎
Add a node that depends on this one (an output), which dirties that node.
Only the new dependant has something new to read. Dirtying this node instead re-ran it and every other branch below it too.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
DagNode
|
The dependant node |
required |
Source code in usd_chunks/chunk_notice.py
add_dependency
⚓︎
Add a dependency (an input) to this node, which dirties it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
DagNode
|
The new dependency to add |
required |
connect_reverse
|
bool
|
Also add this node to the input's outputs. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The key the dependency was stored under |
Source code in usd_chunks/chunk_notice.py
dirty_dependants
⚓︎
Mark every output and the owner dirty, transitively.
Each one records which change caused it. See chunk_scheduler.propagate_dirty.
disconnect
⚓︎
Drop every edge into and out of this node, on both sides.
Clearing only this node's own dicts leaves each peer still pointing back here, so a disconnected node stays reachable as somebody else's input or output. That was invisible while chunk-level edges were rarely populated, but request_delete calls this on any node with outputs -- a stale reverse link there resurrects the deleted chunk as a live dependency of its former successor.
Source code in usd_chunks/chunk_notice.py
get_graph_id
⚓︎
get_input
⚓︎
get_inputs
⚓︎
get_output
⚓︎
get_outputs
⚓︎
get_owner
⚓︎
Get the owner of this node: its 'parent', treated like an output.
The propagator, by contrast, is the ChunkNoticePropagator this node represents in the graph.
Returns:
| Type | Description |
|---|---|
ChunkNoticePropagator | None
|
ChunkNoticePropagator | None: The owner if it exists, else None |
Source code in usd_chunks/chunk_notice.py
get_owner_node
⚓︎
Get the owner's dag node: owner.get_dag_node().
Returns:
| Type | Description |
|---|---|
DagNode | None
|
DagNode | None: The dag node of the owner, or None if there is no owner |
Source code in usd_chunks/chunk_notice.py
get_sort_key
⚓︎
This node's position in the dependency order: the longest chain of dependencies ending here.
Derived from the graph on demand by chunk_scheduler rather than maintained on every connect.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The sort key, 0 for a node with no dependencies |
Source code in usd_chunks/chunk_notice.py
iter_changes
⚓︎
The changes that dirtied this node, shallowest first.
Sorted by how often the source node was itself dirtied; ties keep the order the changes arrived in.
Yields:
| Type | Description |
|---|---|
tuple[ChunkNoticeAlias, ChunkNoticePropagator | None]
|
(alias, propagator) for each change. |
Source code in usd_chunks/chunk_notice.py
next_key
⚓︎
Get the next key for either inputs or outputs dictionaries. The result is safe to use as key for the dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
items
|
ConnSetT
|
A dictionairy t find the next best key for |
required |
Raises:
| Type | Description |
|---|---|
KeyError
|
No valid key was found |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
A new valid key for the dict |
Source code in usd_chunks/chunk_notice.py
only_presentation_changed
⚓︎
Whether every change that dirtied this node was presentation only.
That is, something nothing computes from. A chunk whose changes are all presentation must not re-cook.
The verdict is read back from what chunk_scheduler recorded when each change was propagated, not re-derived here. Both other ways of asking are lossy:
- The aliases in _changes are only a proxy. A
presentation_onlyparam raises PARAM_CHANGED rather than STATE_CHANGED, so an alias test disagrees with AttributeSender.is_presentation_change in exactly that case. - Asking the sender again reads an old_value/value pair that has moved on since, and is only meaningful while the solve that recorded it is still running.
False when nothing was recorded, so a direct dirty solve -- execute-on-creation, which carries no propagated change -- still counts as real work and cooks.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if there is at least one recorded change and all of them are |
bool
|
presentation only |
Source code in usd_chunks/chunk_notice.py
remove_dependant
⚓︎
Remove a node that depends on this one (an output).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
DagNode
|
The dependant node to remove |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if node was an output and got removed |
Source code in usd_chunks/chunk_notice.py
remove_dependency
⚓︎
Remove a dependency (an input) from this node, which dirties it.
Losing an input changes what this node evaluates to. The counterpart to add_dependency; disconnect() drops every edge at once and is not a substitute when a single wire is detached.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
DagNode
|
The dependency to remove |
required |
disconnect_reverse
|
bool
|
If the input node should drop this node from its outputs. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if node was an input and got removed |
Source code in usd_chunks/chunk_notice.py
set_graph_id
⚓︎
Merge this node's graph with node's, if both take part in a graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
DagNode
|
The node being connected to. |
required |
Source code in usd_chunks/chunk_notice.py
set_owner
⚓︎
Set the owner of this node.
The owner is treated like an output, with some semantic differences; see DagConnections.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
owner
|
ChunkNoticePropagator | None
|
The owner propagator |
required |
dirty
|
bool
|
Whether joining marks the owner dirty. A new child is new data for its owner; an attribute's own sender is not -- see AttributeSender. |
True
|
Source code in usd_chunks/chunk_notice.py
should_solve
⚓︎
Whether this dirty node should solve.
A clean node never does. For a dirty one the check is whether it has outputs or an owner to propagate to -- but get_outputs() returns a WeakValueDictionary's items(), a generator, which is always truthy, so in practice every dirty node solves. Callers rely on that; it is not to be "fixed" in isolation.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
Whether the node should solve |
Source code in usd_chunks/chunk_notice.py
solve_outputs
⚓︎
Solve this node, then everything downstream of it and its owner.
This is the solve method clients should use, as it makes every dependent node solve once this one has. The solve starts at the dirty frontier upstream of this node, so a node whose own dependencies have not run yet still solves in the right order. See chunk_scheduler.solve.
Yields:
| Name | Type | Description |
|---|---|---|
DagNode |
DagNode
|
Every node solved, this one included |
Source code in usd_chunks/chunk_notice.py
DependencyAddedNotice
⚓︎
Bases: ChunkNotice
Sent when add_dependency() is called. sender=dependent, data=input propagator.
Source code in usd_chunks/chunk_notice.py
DependencyRemovedNotice
⚓︎
Bases: ChunkNotice
Sent when remove_dependency() removed an input. sender=dependent, data=input propagator.
Source code in usd_chunks/chunk_notice.py
GizmoChangedNotice
⚓︎
GizmoStartedNotice
⚓︎
Bases: ChunkNotice
Sent when a host starts dragging a gizmo.
Source code in usd_chunks/chunk_notice.py
GizmoStoppedNotice
⚓︎
Bases: ChunkNotice
Sent when a host stops dragging a gizmo.
Source code in usd_chunks/chunk_notice.py
GroupChangeNotice
⚓︎
Bases: ChunkNotice
Sent when a group or anything inside it changes; data is the group.
Source code in usd_chunks/chunk_notice.py
InputChangedNotice
⚓︎
Bases: ChunkNotice
Sent when a dependency of a chunk object changes; data is the object.
Source code in usd_chunks/chunk_notice.py
MenuActionNotice
⚓︎
NoticeConnection
⚓︎
A Tf.Notice listener with a simple client-facing interface, as ChunkNoticePropagators store them.
All references to external objects -- method, sender and owner -- are weakrefs, so the connection never takes ownership; properties give access to them. Because of this, connection.method, connection.owner or connection.sender may be None once collected. If any of the weakrefs dies, the connection is broken.
The owner passes an additional object to the call, enabling::
def func(obj: AClass, notice, sender):
pass
class AClass:
def __init__(self):
NoticeConnection(func, owner=self)
as well as::
class AnotherClass:
def func(self, notice, sender):
pass
def bind(obj: AnotherClass):
return NoticeConnection(obj.func, owner=obj)
If the owner implements get_stage() and get_edit_context(), the method runs inside that edit context, so all its edits land in that layer.
Attributes:
| Name | Type | Description |
|---|---|---|
alias |
ChunkNoticeAlias
|
The ChunkNoticeAlias of the notice to listen for |
sender |
Any | None
|
The sender of the notice. When globally is True, this has no effect |
globally |
bool
|
Listen for every notice of this alias, whatever its sender |
owner |
ChunkNoticePropagator | None
|
An optional owner object. Usually 'self', when adding callbacks on a class |
Source code in usd_chunks/chunk_notice.py
__del__
⚓︎
connect
⚓︎
Build the Tf listener from this connection's settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sender
|
Any
|
Override the sender. Defaults to None. |
None
|
Source code in usd_chunks/chunk_notice.py
disconnect
⚓︎
get_method
⚓︎
Get the referenced method or function.
Returns:
| Type | Description |
|---|---|
Callable | None
|
Callable | None: The callable if it is still alive, otherwise None |
Source code in usd_chunks/chunk_notice.py
handle_callback
⚓︎
Forward a notice to the callback, if the method, sender and owner are still alive.
If the owner is valid and implements get_stage() and get_edit_context(), the method is called inside that edit context, so its stage edits land in the right layer.
The callback may declare either (notice, sender) -- matching Tf.Notice -- or (owner, notice, sender). Which one it gets is decided by its own signature, so both forms work whether the callback is a plain function or a bound method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notice
|
Notice
|
The notice to forward |
required |
sender
|
ChunkNoticePropagator
|
The sender of the original notice. Defaults to None. |
None
|
context
|
bool
|
Run inside the owner's edit context. Defaults to True. |
True
|
origin
|
_NoticeOrigin
|
Where the notice came from, when the caller has already worked it out for several listeners. Defaults to working it out. |
None
|
Source code in usd_chunks/chunk_notice.py
trigger
⚓︎
Call the callback directly with this connection's alias and sender.
No Tf.Notice is sent.
ParamAddedNotice
⚓︎
Bases: ChunkNotice
Sent when a param is added to a group or chunk; data is the param.
Source code in usd_chunks/chunk_notice.py
ParamChangeNotice
⚓︎
Bases: ChunkNotice
Sent when a param changes; data is the param.
Source code in usd_chunks/chunk_notice.py
ParamRemovedNotice
⚓︎
Bases: ChunkNotice
Sent when a param is removed from a group or chunk; data is the param.
Source code in usd_chunks/chunk_notice.py
PrimSelectionChangedNotice
⚓︎
Bases: ChunkNotice
Sent when the host's prim selection changes; data is the selected prims.
Source code in usd_chunks/chunk_notice.py
PropSelectionChangedNotice
⚓︎
Bases: ChunkNotice
Sent when the host's property selection changes; data is the property.
Source code in usd_chunks/chunk_notice.py
RegistrySingleton
⚓︎
Bases: type
Metaclass that makes a class a process-wide singleton: every call returns the one instance.
ValueChangedNotice
⚓︎
Bases: AttributeChangeNotice
Sent when a param's value changes.
Source code in usd_chunks/chunk_notice.py
ViewportRendererSettingsChangedNotice
⚓︎
Bases: ChunkNotice
Sent when the host's own UI (usdview's Hydra Settings) sets renderer settings on the viewport's delegate; data is (renderer plugin id, {setting key: value}). Not sent for settings a chunk set through ChunkScene.set_viewport_renderer_settings.
Source code in usd_chunks/chunk_notice.py
WidgetChangedNotice
⚓︎
Bases: ChunkNotice
Sent when a param widget changes; data is the widget.
Source code in usd_chunks/chunk_notice.py
chunk_notice
⚓︎
Decorator that registers a Tf.Notice class with the ChunkNoticeRegistry under an alias.
Once registered, get_notice(alias).Send() sends it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alias
|
ChunkNoticeAlias
|
The alias which maps to the new Tf.Notice class |
required |
Returns:
| Type | Description |
|---|---|
|
The class decorator. |
Source code in usd_chunks/chunk_notice.py
get_notice
⚓︎
The Tf.Notice class registered for a ChunkNoticeAlias.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alias
|
ChunkNoticeAlias
|
The alias to look up |
required |
Returns:
| Type | Description |
|---|---|
type[ChunkNotice]
|
type[ChunkNotice]: The notice class |
Raises:
| Type | Description |
|---|---|
ErrorException
|
If the alias has not been registered |
Source code in usd_chunks/chunk_notice.py
is_notice_type
⚓︎
Check whether a notice is the class registered for an alias.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notice
|
Notice
|
The notice to check |
required |
alias
|
ChunkNoticeAlias
|
The alias to compare against |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
TypeGuard[ChunkNotice]
|
True if get_notice(alias) is exactly the notice's type |
Source code in usd_chunks/chunk_notice.py
send_notice
⚓︎
Send a notice of type alias, running the callbacks subscribed to it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alias
|
ChunkNoticeAlias
|
The type of the notice to send |
required |
sender
|
Any
|
The object to pass as sender. If None, the notice is sent globally. Defaults to None. |
None
|
data
|
Any
|
Any additional data to attach to the notice object. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
ChunkNotice | None
|
ChunkNotice | None: The sent notice, or None if the alias is not a ChunkNotice. |
Source code in usd_chunks/chunk_notice.py
without_edit_context
⚓︎
Mark a callback to run outside its owner's edit context.
For a callback that authors nothing itself, only hands on to others that each run in their own: resolving the context makes the owner's layer, which puts it on the stage.