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