Slicer  4.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkScriptedExampleDisplayableManager.py
Go to the documentation of this file.
1 from __future__ import print_function
2 
3 #
4 # ScriptedExampleDisplayableManager
5 #
6 
7 #
8 # Since it's not possible to derive a VTK class in python, all scripted DisplayableManager
9 # should expose the following methods:
10 # - Create
11 # - GetMRMLSceneEventsToObserve
12 # - ProcessMRMLSceneEvents
13 # - ProcessMRMLNodesEvents
14 # - RemoveMRMLObservers
15 # - UpdateFromMRML
16 # - OnInteractorStyleEvent
17 # - OnMRMLDisplayableNodeModifiedEvent
18 #
19 # The constructor has one parameter named 'parent' corresponding to the associated instance of
20 # vtkScriptedDisplayableManager in the C++ world.
21 #
22 # The python methods listed above corresponds to the implementation of the virtual method
23 # available in vtkScriptedDisplayableManager.
24 #
25 # The only exception is the virtual method SetMRMLSceneInternal, the python class only needs to
26 # implement the method GetMRMLSceneEventsToObserve. This later one just return a list of integer
27 # representing the eventid to observe.
28 #
29 # It's also possible to access the API of the associated C++ instance using the self.Parent
30 # For example:
31 # self.Parent.RemoveInteractorStyleObservableEvent(26) # vtkCommand::MouseWheelForwardEvent
32 #
33 # Make also sure NOT to call the corresponding C++ method from it's python equivalent, it will
34 # result in an infinite loop.
35 # The following statement will likely lead to an unstable state:
36 # def Create(self): self.Parent.Create()
37 #
38 # If a a method isn't implemented, the following syntax should be used:
39 # def Create(self): pass
40 #
41 # NOTE
42 # Ideally, a DisplayableManager should deal only with MRMLNodes. Incriminated code should
43 # be moved either in the DisplayableManager itself, in the associated MRML Node or
44 # in a MRMLNode helper class.
45 #
46 # TODO
47 # While porting existing code, to overcome this problem, the following need to be done:
48 # - DisplayableManager abstract base class should have a reference to the current MRMLApplicationLogic
49 # - The MRMLApplicationLogic should contain a map of logics
50 # - The list of logic internally used by the qSlicerLayoutManager should be removed and
51 # the list from the MRMLApplicationLogic used instead.
52 
54 
55  def __init__(self, parent):
56  self.Parent = parent
57  print("vtkScriptedExampleDisplayableManager - __init__")
58 
59  def Create(self):
60  print("vtkScriptedExampleDisplayableManager - Create")
61  pass
62 
64  print("vtkScriptedExampleDisplayableManager - GetMRMLSceneEventsToObserve")
65  sceneEvents = vtkIntArray()
66  sceneEvents.InsertNextValue(slicer.vtkMRMLScene.NodeAddedEvent)
67  sceneEvents.InsertNextValue(slicer.vtkMRMLScene.NodeRemovedEvent)
68  return sceneEvents
69 
70  def ProcessMRMLSceneEvents(self, scene, eventid, node):
71  print("vtkScriptedExampleDisplayableManager - ProcessMRMLSceneEvents(eventid,", eventid, ")")
72  pass
73 
74  def ProcessMRMLNodesEvents(self, scene, eventid, callData):
75  print("vtkScriptedExampleDisplayableManager - ProcessMRMLNodesEvents(eventid,", eventid, ")")
76  pass
77 
79  print("vtkScriptedExampleDisplayableManager - RemoveMRMLObservers")
80  pass
81 
82  def UpdateFromMRML(self):
83  print("vtkScriptedExampleDisplayableManager - UpdateFromMRML")
84  pass
85 
86  def OnInteractorStyleEvent(self, eventid):
87  print("vtkScriptedExampleDisplayableManager - OnInteractorStyleEvent(eventid,", eventid, ")")
88 
90  print("vtkScriptedExampleDisplayableManager - onMRMLDisplayableNodeModifiedEvent")
91 
92 
93 
94