Commit e7d7870d8eac0e739eed2c2044a9acd7b3d37394

Authored by tfmoraes
1 parent cc2c99a6

FIX: A keyerror on add a measure

Showing 1 changed file with 19 additions and 3 deletions   Show diff stats
invesalius/data/measures.py
... ... @@ -65,15 +65,20 @@ class MeasurementManager(object):
65 65 except IndexError:
66 66 slice_number = 0
67 67  
  68 + to_remove = False
68 69 if self.current is None:
69 70 print "To Create"
70 71 to_create = True
71   - elif self.current[0].slice_number != slice_number:
  72 + elif self.current[0].location != location:
72 73 print "To Create"
  74 + print "To Remove"
73 75 to_create = True
74   - elif self.current[0].location != location:
  76 + to_remove = True
  77 + elif self.current[0].slice_number != slice_number:
75 78 print "To Create"
  79 + print "To Remove"
76 80 to_create = True
  81 + to_remove = True
77 82 else:
78 83 print "To not Create"
79 84 to_create = False
... ... @@ -83,11 +88,22 @@ class MeasurementManager(object):
83 88 m.index = len(self.measures)
84 89 m.location = location
85 90 m.slice_number = slice_number
  91 + m.type = type
86 92 if type == const.LINEAR:
87 93 mr = LinearMeasure(m.colour)
88 94 else:
89 95 mr = AngularMeasure(m.colour)
90   - m.type = type
  96 + if to_remove:
  97 + print "---To REMOVE"
  98 + actors = self.current[1].GetActors()
  99 + slice_number = self.current[0].slice_number
  100 + ps.Publisher().sendMessage(('Remove actors',
  101 + self.current[0].location), (actors, slice_number))
  102 + if self.current[0].location == const.SURFACE:
  103 + ps.Publisher().sendMessage('Render volume viewer')
  104 + else:
  105 + ps.Publisher().sendMessage('Update slice viewer')
  106 +
91 107 self.current = (m, mr)
92 108  
93 109 x, y, z = position
... ...