Commit d17cea011eab997bebc73761fa16e037e483db26

Authored by Thiago Franco de Moraes
1 parent dbecc12e

Created a class to store watershed configs

Showing 1 changed file with 15 additions and 2 deletions   Show diff stats
invesalius/data/styles.py
... ... @@ -34,6 +34,8 @@ from scipy.misc import imsave
34 34 from skimage.morphology import watershed
35 35 from skimage import filter
36 36  
  37 +import utils
  38 +
37 39 ORIENTATIONS = {
38 40 "AXIAL": const.AXIAL,
39 41 "CORONAL": const.CORONAL,
... ... @@ -734,6 +736,16 @@ class EditorInteractorStyle(DefaultInteractorStyle):
734 736 return x, y, z
735 737  
736 738  
  739 +class WatershedConfig(object):
  740 + __metaclass__= utils.Singleton
  741 + def __init__(self):
  742 + self.operation = BRUSH_FOREGROUND
  743 + Publisher.subscribe(self.set_operation, 'Set watershed operation')
  744 +
  745 + def set_operation(self, pubsub_evt):
  746 + self.operation = WATERSHED_OPERATIONS[pubsub_evt.data]
  747 +
  748 +
737 749 class WaterShedInteractorStyle(DefaultInteractorStyle):
738 750 def __init__(self, viewer):
739 751 DefaultInteractorStyle.__init__(self, viewer)
... ... @@ -745,6 +757,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle):
745 757 self.operation = BRUSH_FOREGROUND
746 758  
747 759 self.mg_size = 3
  760 + self.config = WatershedConfig()
748 761  
749 762 self.picker = vtk.vtkWorldPointPicker()
750 763  
... ... @@ -869,7 +882,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle):
869 882 if position < 0:
870 883 position = viewer.calculate_matrix_position(coord)
871 884  
872   - operation = self.operation
  885 + operation = self.config.operation
873 886  
874 887 if operation == BRUSH_FOREGROUND:
875 888 if iren.GetControlKey():
... ... @@ -937,7 +950,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle):
937 950 if position < 0:
938 951 position = viewer.calculate_matrix_position(coord)
939 952  
940   - operation = self.operation
  953 + operation = self.config.operation
941 954  
942 955 if operation == BRUSH_FOREGROUND:
943 956 if iren.GetControlKey():
... ...