Commit dc3edb075e04adabec5f322ea57c2c61028bce8f
1 parent
b7bb24bd
Exists in
measure_improvements
Improvements
Showing
3 changed files
with
47 additions
and
26 deletions
Show diff stats
invesalius/data/measures.py
... | ... | @@ -98,6 +98,7 @@ class MeasurementManager(object): |
98 | 98 | Publisher.subscribe(self._load_measurements, "Load measurement dict") |
99 | 99 | Publisher.subscribe(self._rm_incomplete_measurements, |
100 | 100 | "Remove incomplete measurements") |
101 | + Publisher.subscribe(self._change_measure_point_pos, 'Change measurement point position') | |
101 | 102 | |
102 | 103 | def _load_measurements(self, pubsub_evt): |
103 | 104 | try: |
... | ... | @@ -246,6 +247,40 @@ class MeasurementManager(object): |
246 | 247 | value)) |
247 | 248 | self.current = None |
248 | 249 | |
250 | + def _change_measure_point_pos(self, pubsub_evt): | |
251 | + index, npoint, pos = pubsub_evt.data | |
252 | + print index, npoint, pos | |
253 | + m, mr = self.measures[index] | |
254 | + x, y, z = pos | |
255 | + if npoint == 0: | |
256 | + mr.SetPoint1(x, y, z) | |
257 | + m.points[0] = x, y, z | |
258 | + elif npoint == 1: | |
259 | + mr.SetPoint2(x, y, z) | |
260 | + m.points[1] = x, y, z | |
261 | + elif npoint == 2: | |
262 | + mr.SetPoint3(x, y, z) | |
263 | + m.points[2] = x, y, z | |
264 | + | |
265 | + m.value = mr.GetValue() | |
266 | + | |
267 | + name = m.name | |
268 | + colour = m.colour | |
269 | + m.value = mr.GetValue() | |
270 | + type_ = TYPE[m.type] | |
271 | + location = LOCATION[m.location] | |
272 | + | |
273 | + if m.type == const.LINEAR: | |
274 | + value = u"%.2f mm"% m.value | |
275 | + else: | |
276 | + value = u"%.2f°"% m.value | |
277 | + | |
278 | + Publisher.sendMessage('Update measurement info in GUI', | |
279 | + (index, name, colour, | |
280 | + location, | |
281 | + type_, | |
282 | + value)) | |
283 | + | |
249 | 284 | def _change_name(self, pubsub_evt): |
250 | 285 | index, new_name = pubsub_evt.data |
251 | 286 | self.measures[index].name = new_name | ... | ... |
invesalius/data/styles.py
... | ... | @@ -394,36 +394,19 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): |
394 | 394 | |
395 | 395 | def OnReleaseMeasurePoint(self, obj, evt): |
396 | 396 | if self.selected: |
397 | - print "Changing Position" | |
398 | 397 | n, m, mr = self.selected |
399 | 398 | x, y, z = self._get_pos_clicked() |
400 | - ren = self.slice_data.renderer | |
401 | - mr.renderer = ren | |
402 | - if n == 0: | |
403 | - mr.SetPoint1(x, y, z) | |
404 | - m.points[0] = x, y, z | |
405 | - elif n == 1: | |
406 | - mr.SetPoint2(x, y, z) | |
407 | - m.points[1] = x, y, z | |
408 | - | |
409 | - m.value = mr.GetValue() | |
410 | - | |
399 | + idx = self.measures._list_measures.index((m, mr)) | |
400 | + Publisher.sendMessage('Change measurement point position', (idx, n, (x, y, z))) | |
411 | 401 | Publisher.sendMessage('Reload actual slice %s' % self.orientation) |
412 | 402 | self.selected = None |
413 | 403 | |
414 | 404 | def OnMoveMeasurePoint(self, obj, evt): |
415 | 405 | if self.selected: |
416 | - print "Changing Position" | |
417 | 406 | n, m, mr = self.selected |
418 | 407 | x, y, z = self._get_pos_clicked() |
419 | - ren = self.slice_data.renderer | |
420 | - mr.renderer = ren | |
421 | - if n == 0: | |
422 | - mr.SetPoint1(x, y, z) | |
423 | - m.points[0] = x, y, z | |
424 | - elif n == 1: | |
425 | - mr.SetPoint2(x, y, z) | |
426 | - m.points[1] = x, y, z | |
408 | + idx = self.measures._list_measures.index((m, mr)) | |
409 | + Publisher.sendMessage('Change measurement point position', (idx, n, (x, y, z))) | |
427 | 410 | |
428 | 411 | Publisher.sendMessage('Reload actual slice %s' % self.orientation) |
429 | 412 | |
... | ... | @@ -452,11 +435,12 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): |
452 | 435 | |
453 | 436 | if slice_number in self.measures.measures[self._ori]: |
454 | 437 | for m, mr in self.measures.measures[self._ori][slice_number]: |
455 | - for n, p in enumerate(m.points): | |
456 | - px, py, pz = p | |
457 | - dist = ((px-x)**2 + (py-y)**2 + (pz-z)**2)**0.5 | |
458 | - if dist < max_dist: | |
459 | - return (n, m, mr) | |
438 | + if mr.IsComplete(): | |
439 | + for n, p in enumerate(m.points): | |
440 | + px, py, pz = p | |
441 | + dist = ((px-x)**2 + (py-y)**2 + (pz-z)**2)**0.5 | |
442 | + if dist < max_dist: | |
443 | + return (n, m, mr) | |
460 | 444 | return None |
461 | 445 | |
462 | 446 | class AngularMeasureInteractorStyle(DefaultInteractorStyle): | ... | ... |
invesalius/gui/data_notebook.py
... | ... | @@ -1127,6 +1127,8 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
1127 | 1127 | self.UpdateItemInfo(index, name, colour, location, type_, value) |
1128 | 1128 | else: |
1129 | 1129 | self.InsertNewItem(index, name, colour, location, type_, value) |
1130 | + else: | |
1131 | + self.UpdateItemInfo(index, name, colour, location, type_, value) | |
1130 | 1132 | |
1131 | 1133 | |
1132 | 1134 | ... | ... |