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