Commit afd317a1e1e9090f182eb1aaccfd1071a03e9aec
1 parent
0e1a9c34
Exists in
master
and in
68 other branches
FIX: Remove measurement
Showing
1 changed file
with
13 additions
and
14 deletions
Show diff stats
invesalius/data/measures.py
| @@ -37,7 +37,6 @@ class MeasurementManager(object): | @@ -37,7 +37,6 @@ class MeasurementManager(object): | ||
| 37 | ps.Publisher().subscribe(self._set_visibility, "Show measurement") | 37 | ps.Publisher().subscribe(self._set_visibility, "Show measurement") |
| 38 | ps.Publisher().subscribe(self._load_measurements, "Load measurement dict") | 38 | ps.Publisher().subscribe(self._load_measurements, "Load measurement dict") |
| 39 | 39 | ||
| 40 | - | ||
| 41 | def _load_measurements(self, pubsub_evt): | 40 | def _load_measurements(self, pubsub_evt): |
| 42 | dict = pubsub_evt.data | 41 | dict = pubsub_evt.data |
| 43 | for i in dict: | 42 | for i in dict: |
| @@ -55,7 +54,6 @@ class MeasurementManager(object): | @@ -55,7 +54,6 @@ class MeasurementManager(object): | ||
| 55 | (actors, m.slice_number)) | 54 | (actors, m.slice_number)) |
| 56 | self.current = None | 55 | self.current = None |
| 57 | 56 | ||
| 58 | - | ||
| 59 | def _add_point(self, pubsub_evt): | 57 | def _add_point(self, pubsub_evt): |
| 60 | position = pubsub_evt.data[0] | 58 | position = pubsub_evt.data[0] |
| 61 | type = pubsub_evt.data[1] # Linear or Angular | 59 | type = pubsub_evt.data[1] # Linear or Angular |
| @@ -107,24 +105,24 @@ class MeasurementManager(object): | @@ -107,24 +105,24 @@ class MeasurementManager(object): | ||
| 107 | self.current = (m, mr) | 105 | self.current = (m, mr) |
| 108 | 106 | ||
| 109 | x, y, z = position | 107 | x, y, z = position |
| 110 | - actors = self.current[1].AddPoint(x, y, z) | ||
| 111 | - self.current[0].points.append(position) | 108 | + actors = mr.AddPoint(x, y, z) |
| 109 | + m.points.append(position) | ||
| 112 | ps.Publisher().sendMessage(("Add actors", location), | 110 | ps.Publisher().sendMessage(("Add actors", location), |
| 113 | - (actors, self.current[0].slice_number)) | 111 | + (actors, m.slice_number)) |
| 114 | 112 | ||
| 115 | - if self.current[1].IsComplete(): | ||
| 116 | - index = prj.Project().AddMeasurement(self.current[0]) | ||
| 117 | - self.current[0].index = index | 113 | + if self.mr.IsComplete(): |
| 114 | + index = prj.Project().AddMeasurement(m) | ||
| 115 | + #m.index = index # already done in proj | ||
| 118 | self.measures.append(self.current) | 116 | self.measures.append(self.current) |
| 119 | - name = self.current[0].name | ||
| 120 | - colour = self.current[0].colour | ||
| 121 | - self.current[0].value = self.current[1].GetValue() | 117 | + name = m.name |
| 118 | + colour = m.colour | ||
| 119 | + m.value = mr.GetValue() | ||
| 122 | type_ = TYPE[type] | 120 | type_ = TYPE[type] |
| 123 | location = LOCATION[location] | 121 | location = LOCATION[location] |
| 124 | if type == const.LINEAR: | 122 | if type == const.LINEAR: |
| 125 | - value = u"%.2f mm"% self.current[0].value | 123 | + value = u"%.2f mm"% m.value |
| 126 | else: | 124 | else: |
| 127 | - value = u"%.2f˚"% self.current[0].value | 125 | + value = u"%.2f˚"% m.value |
| 128 | 126 | ||
| 129 | msg = 'Update measurement info in GUI', | 127 | msg = 'Update measurement info in GUI', |
| 130 | ps.Publisher().sendMessage(msg, | 128 | ps.Publisher().sendMessage(msg, |
| @@ -138,12 +136,13 @@ class MeasurementManager(object): | @@ -138,12 +136,13 @@ class MeasurementManager(object): | ||
| 138 | self.measures[index][0].name = new_name | 136 | self.measures[index][0].name = new_name |
| 139 | 137 | ||
| 140 | def _remove_measurements(self, pubsub_evt): | 138 | def _remove_measurements(self, pubsub_evt): |
| 139 | + print "---- measures: _remove_measurements" | ||
| 141 | indexes = pubsub_evt.data | 140 | indexes = pubsub_evt.data |
| 142 | print indexes | 141 | print indexes |
| 143 | for index in indexes: | 142 | for index in indexes: |
| 144 | m, mr = self.measures.pop(index) | 143 | m, mr = self.measures.pop(index) |
| 145 | actors = mr.GetActors() | 144 | actors = mr.GetActors() |
| 146 | - prj.Project().RemoveMeasurement(m) | 145 | + prj.Project().RemoveMeasurement(index) |
| 147 | ps.Publisher().sendMessage(('Remove actors', m.location), | 146 | ps.Publisher().sendMessage(('Remove actors', m.location), |
| 148 | (actors, m.slice_number)) | 147 | (actors, m.slice_number)) |
| 149 | ps.Publisher().sendMessage('Update slice viewer') | 148 | ps.Publisher().sendMessage('Update slice viewer') |