Slicer 5.13
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
Python.ScriptedPipelineSceneConnector.ScriptedPipelineSceneConnector Class Reference

Public Member Functions

 __init__ (self, scene=None)
 
None connect (self)
 
None disconnect (self)
 
list getPipelines (self)
 
 getScene (self)
 
list getSceneObservers (self)
 
None onConnected (self)
 

Protected Attributes

 _connectedScene = None
 
 _pipelineCreator = None
 
 _scene = scene
 
list _sceneObserverTags = []
 

Detailed Description

Convenience base class connecting the scripted LayerDM pipelines of one module to the scene.

Subclass and override:
    - getPipelines: return the pipeline classes handled by the module.
    - getSceneObservers: optionally return (eventId, callback) pairs to observe on the MRML scene.
    - onConnected: optionally perform additional setup after connecting (for instance adding
        data nodes to the scene).

Expected usage in a scripted module:
    - Instantiate the subclass at module level.
    - Call connect at application startup and from the module widget's setup. connect removes any
        previous connection first, so re-connecting from setup makes a module reload rebind the
        reloaded pipeline classes (the LayerDM pipeline managers automatically recreate the pipelines
        of a creator which was removed from the factory).
    - Call disconnect from the module widget's cleanup, which is invoked by the module reload
        machinery before the widget is rebuilt and when the module is unloaded.

Definition at line 8 of file ScriptedPipelineSceneConnector.py.

Constructor & Destructor Documentation

◆ __init__()

Python.ScriptedPipelineSceneConnector.ScriptedPipelineSceneConnector.__init__ ( self,
scene = None )
:param scene: Optional MRML scene to connect to. If None, the slicer.mrmlScene singleton is used
    when connect is called. Passing the scene explicitly avoids depending on the singleton, which
    is not available in trame-slicer.

Definition at line 28 of file ScriptedPipelineSceneConnector.py.

Member Function Documentation

◆ connect()

None Python.ScriptedPipelineSceneConnector.ScriptedPipelineSceneConnector.connect ( self)
Registers a pipeline creator for the getPipelines classes, adds the getSceneObservers observers and
calls onConnected. Any previous connection held by this instance is removed first.

:raises TypeError: If any of the getPipelines classes doesn't implement TryCreatePipeline.
    Checked eagerly, as a missing TryCreatePipeline would otherwise only fail when a node is
    added to the scene, far from the actual mistake.

Definition at line 65 of file ScriptedPipelineSceneConnector.py.

◆ disconnect()

None Python.ScriptedPipelineSceneConnector.ScriptedPipelineSceneConnector.disconnect ( self)
Undoes the connection done by connect. Safe to call when nothing is connected.

Definition at line 100 of file ScriptedPipelineSceneConnector.py.

◆ getPipelines()

list Python.ScriptedPipelineSceneConnector.ScriptedPipelineSceneConnector.getPipelines ( self)
Override to return the pipeline classes handled by the module.
Each class should provide a TryCreatePipeline(viewNode, node) class method returning a new pipeline
instance or None. The classes are queried in order until one returns a pipeline.

Definition at line 50 of file ScriptedPipelineSceneConnector.py.

◆ getScene()

Python.ScriptedPipelineSceneConnector.ScriptedPipelineSceneConnector.getScene ( self)
Returns the scene this connector is connected to.
While disconnected, returns the scene it would connect to (the scene given at construction,
or the slicer.mrmlScene singleton).
Subclass overrides should use this instead of the slicer.mrmlScene singleton.

Definition at line 39 of file ScriptedPipelineSceneConnector.py.

◆ getSceneObservers()

list Python.ScriptedPipelineSceneConnector.ScriptedPipelineSceneConnector.getSceneObservers ( self)
Override to return (eventId, callback) pairs to observe on the MRML scene while connected.

Definition at line 58 of file ScriptedPipelineSceneConnector.py.

◆ onConnected()

None Python.ScriptedPipelineSceneConnector.ScriptedPipelineSceneConnector.onConnected ( self)
Override to perform additional setup after connecting (for instance adding data nodes to the scene).

Definition at line 62 of file ScriptedPipelineSceneConnector.py.

Member Data Documentation

◆ _connectedScene

Python.ScriptedPipelineSceneConnector.ScriptedPipelineSceneConnector._connectedScene = None
protected

Definition at line 35 of file ScriptedPipelineSceneConnector.py.

◆ _pipelineCreator

Python.ScriptedPipelineSceneConnector.ScriptedPipelineSceneConnector._pipelineCreator = None
protected

Definition at line 36 of file ScriptedPipelineSceneConnector.py.

◆ _scene

Python.ScriptedPipelineSceneConnector.ScriptedPipelineSceneConnector._scene = scene
protected

Definition at line 34 of file ScriptedPipelineSceneConnector.py.

◆ _sceneObserverTags

list Python.ScriptedPipelineSceneConnector.ScriptedPipelineSceneConnector._sceneObserverTags = []
protected

Definition at line 37 of file ScriptedPipelineSceneConnector.py.


The documentation for this class was generated from the following file: