67 Registers a pipeline creator for the getPipelines classes, adds the getSceneObservers observers and
68 calls onConnected. Any previous connection held by this instance is removed first.
70 :raises TypeError: If any of the getPipelines classes doesn't implement TryCreatePipeline.
71 Checked eagerly, as a missing TryCreatePipeline would otherwise only fail when a node is
72 added to the scene, far from the actual mistake.
74 pipelines = self.getPipelines()
75 for pipeline
in pipelines:
76 if not callable(getattr(pipeline,
"TryCreatePipeline",
None)):
78 f
"{pipeline.__name__} cannot be used with {type(self).__name__}: "
79 "it does not implement the TryCreatePipeline(viewNode, node) class method.")
82 self._connectedScene = self._scene
if self._scene
is not None else slicer.mrmlScene
84 def tryCreate(viewNode, node):
85 for pipeline
in pipelines:
86 ret = pipeline.TryCreatePipeline(viewNode, node)
92 self._pipelineCreator.SetPythonCallback(tryCreate)
95 for eventId, callback
in self.getSceneObservers():
96 self._sceneObserverTags.append(self._connectedScene.AddObserver(eventId, callback))