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 | 37 | ps.Publisher().subscribe(self._set_visibility, "Show measurement") |
| 38 | 38 | ps.Publisher().subscribe(self._load_measurements, "Load measurement dict") |
| 39 | 39 | |
| 40 | - | |
| 41 | 40 | def _load_measurements(self, pubsub_evt): |
| 42 | 41 | dict = pubsub_evt.data |
| 43 | 42 | for i in dict: |
| ... | ... | @@ -55,7 +54,6 @@ class MeasurementManager(object): |
| 55 | 54 | (actors, m.slice_number)) |
| 56 | 55 | self.current = None |
| 57 | 56 | |
| 58 | - | |
| 59 | 57 | def _add_point(self, pubsub_evt): |
| 60 | 58 | position = pubsub_evt.data[0] |
| 61 | 59 | type = pubsub_evt.data[1] # Linear or Angular |
| ... | ... | @@ -107,24 +105,24 @@ class MeasurementManager(object): |
| 107 | 105 | self.current = (m, mr) |
| 108 | 106 | |
| 109 | 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 | 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 | 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 | 120 | type_ = TYPE[type] |
| 123 | 121 | location = LOCATION[location] |
| 124 | 122 | if type == const.LINEAR: |
| 125 | - value = u"%.2f mm"% self.current[0].value | |
| 123 | + value = u"%.2f mm"% m.value | |
| 126 | 124 | else: |
| 127 | - value = u"%.2f˚"% self.current[0].value | |
| 125 | + value = u"%.2f˚"% m.value | |
| 128 | 126 | |
| 129 | 127 | msg = 'Update measurement info in GUI', |
| 130 | 128 | ps.Publisher().sendMessage(msg, |
| ... | ... | @@ -138,12 +136,13 @@ class MeasurementManager(object): |
| 138 | 136 | self.measures[index][0].name = new_name |
| 139 | 137 | |
| 140 | 138 | def _remove_measurements(self, pubsub_evt): |
| 139 | + print "---- measures: _remove_measurements" | |
| 141 | 140 | indexes = pubsub_evt.data |
| 142 | 141 | print indexes |
| 143 | 142 | for index in indexes: |
| 144 | 143 | m, mr = self.measures.pop(index) |
| 145 | 144 | actors = mr.GetActors() |
| 146 | - prj.Project().RemoveMeasurement(m) | |
| 145 | + prj.Project().RemoveMeasurement(index) | |
| 147 | 146 | ps.Publisher().sendMessage(('Remove actors', m.location), |
| 148 | 147 | (actors, m.slice_number)) |
| 149 | 148 | ps.Publisher().sendMessage('Update slice viewer') | ... | ... |