relation¶
- class janim.items.relation.Relation¶
基类:
Refreshable,Generic定义了有向无环图的包含关系以及一些实用操作
也就是,对于每个对象:
self.parents存储了与其直接关联的父对象self.children存储了与其直接关联的子对象使用
add()建立对象间的关系使用
remove()取消对象间的关系ancestors()表示与其直接关联的祖先对象(包括父对象,以及父对象的父对象,......)descendants()表示与其直接关联的后代对象(包括子对象、以及子对象的子对象,......)- 对于
ancestors()以及descendants(): 不包含调用者自身并且返回的列表中没有重复元素
物件顺序是 DFS 顺序
- 对于
- parents: list[GRelT]¶
- children: list[GRelT]¶
- mark_refresh(func: Callable | str, *, recurse_up=False, recurse_down=False) Self¶
标记指定的
func需要进行更新
- parents_changed() None¶
信号,在
self.parents改变时触发
- children_changed() None¶
信号,在
self.children改变时触发
- add(*objs: GRelT, insert=False) Self¶
向该对象添加子对象
如果
insert=True(默认为False),那么插入到子物件列表的开头
- remove(*objs: GRelT) Self¶
从该对象移除子对象
- shuffle() Self¶
- clear_parents() Self¶
- clear_children() Self¶
- ancestors() list[GRelT]¶
获得祖先对象列表
- descendants() list[GRelT]¶
获得后代对象列表
- walk_ancestors(base_cls: type[RelT] = None) Generator[RelT, None, None]¶
遍历祖先节点中以
base_cls(缺省则遍历全部)为基类的对象
- walk_descendants(base_cls: type[RelT] = None) Generator[RelT, None, None]¶
遍历后代节点中以
base_cls(缺省则遍历全部)为基类的对象
- walk_self_and_ancestors(root_only=False) Generator[GRelT, None, None]¶
遍历自己以及祖先节点
- walk_self_and_descendants(root_only=False) Generator[GRelT, None, None]¶
遍历自己以及后代节点
- walk_nearest_ancestors(base_cls: type[RelT]) Generator[RelT, None, None]¶
遍历祖先节点中以
base_cls为基类的对象,但是排除已经满足条件的对象的祖先对象
- walk_nearest_descendants(base_cls: type[RelT]) Generator[RelT, None, None]¶
遍历后代节点中以
base_cls为基类的对象,但是排除已经满足条件的对象的后代对象