Commit e7d7870d8eac0e739eed2c2044a9acd7b3d37394
1 parent
cc2c99a6
Exists in
master
and in
6 other branches
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,15 +65,20 @@ class MeasurementManager(object): | ||
65 | except IndexError: | 65 | except IndexError: |
66 | slice_number = 0 | 66 | slice_number = 0 |
67 | 67 | ||
68 | + to_remove = False | ||
68 | if self.current is None: | 69 | if self.current is None: |
69 | print "To Create" | 70 | print "To Create" |
70 | to_create = True | 71 | to_create = True |
71 | - elif self.current[0].slice_number != slice_number: | 72 | + elif self.current[0].location != location: |
72 | print "To Create" | 73 | print "To Create" |
74 | + print "To Remove" | ||
73 | to_create = True | 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 | print "To Create" | 78 | print "To Create" |
79 | + print "To Remove" | ||
76 | to_create = True | 80 | to_create = True |
81 | + to_remove = True | ||
77 | else: | 82 | else: |
78 | print "To not Create" | 83 | print "To not Create" |
79 | to_create = False | 84 | to_create = False |
@@ -83,11 +88,22 @@ class MeasurementManager(object): | @@ -83,11 +88,22 @@ class MeasurementManager(object): | ||
83 | m.index = len(self.measures) | 88 | m.index = len(self.measures) |
84 | m.location = location | 89 | m.location = location |
85 | m.slice_number = slice_number | 90 | m.slice_number = slice_number |
91 | + m.type = type | ||
86 | if type == const.LINEAR: | 92 | if type == const.LINEAR: |
87 | mr = LinearMeasure(m.colour) | 93 | mr = LinearMeasure(m.colour) |
88 | else: | 94 | else: |
89 | mr = AngularMeasure(m.colour) | 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 | self.current = (m, mr) | 107 | self.current = (m, mr) |
92 | 108 | ||
93 | x, y, z = position | 109 | x, y, z = position |