Commit 973bc3c11dab085b1cfae4820e5b79c4048eab81

Authored by Thiago Franco de Moraes
1 parent 794ea503

Created an class to keep measurements data

Showing 1 changed file with 30 additions and 1 deletions   Show diff stats
invesalius/data/measures.py
... ... @@ -22,6 +22,35 @@ LOCATION = {const.SURFACE: _(u"3D"),
22 22 }
23 23  
24 24  
  25 +class MeasureData:
  26 + """
  27 + Responsible to keep measures data.
  28 + """
  29 + def __init__(self):
  30 + self.measures = {const.SURFACE: {},
  31 + const.AXIAL: {},
  32 + const.CORONAL: {},
  33 + const.SAGITAL: {}}
  34 + self._list_measures = []
  35 +
  36 + def append(self, m):
  37 + print m[0].location, m[0].slice_number
  38 + try:
  39 + self.measures[m[0].location][m[0].slice_number].append(m)
  40 + except KeyError:
  41 + self.measures[m[0].location][m[0].slice_number] = [m, ]
  42 +
  43 + self._list_measures.append(m)
  44 +
  45 + def pop(self, idx):
  46 + m = self._list_measures.pop(idx)
  47 + self.measures[m[0].location][m[0].slice_number].remove(m)
  48 + return m
  49 +
  50 + def __len__(self):
  51 + return len(self._list_measures)
  52 +
  53 +
25 54 class MeasurementManager(object):
26 55 """
27 56 A class to manage the use (Addition, remotion and visibility) from
... ... @@ -29,7 +58,7 @@ class MeasurementManager(object):
29 58 """
30 59 def __init__(self):
31 60 self.current = None
32   - self.measures = []
  61 + self.measures = MeasureData()
33 62 self._bind_events()
34 63  
35 64 def _bind_events(self):
... ...