Commit 4e80f1ec877de787818a8daf44e5790cb74d5823

Authored by tatiana
1 parent 83eaa757

ENH: Measurements operations in project

Showing 1 changed file with 27 additions and 6 deletions   Show diff stats
invesalius/project.py
@@ -60,14 +60,14 @@ class Project(object): @@ -60,14 +60,14 @@ class Project(object):
60 60
61 # Masks (vtkImageData) 61 # Masks (vtkImageData)
62 self.mask_dict = {} 62 self.mask_dict = {}
63 - self.last_mask_index = 0 63 + #self.last_mask_index = 0
64 64
65 # Surfaces are (vtkPolyData) 65 # Surfaces are (vtkPolyData)
66 self.surface_dict = {} 66 self.surface_dict = {}
67 - self.last_surface_index = -1 67 + #self.last_surface_index = -1
68 68
69 - # TODO: Future  
70 - self.measure_dict = {} 69 + # Measurements
  70 + self.measurement_dict = {}
71 71
72 # TODO: Future ++ 72 # TODO: Future ++
73 self.annotation_dict = {} 73 self.annotation_dict = {}
@@ -109,7 +109,7 @@ class Project(object): @@ -109,7 +109,7 @@ class Project(object):
109 output 109 output
110 @ index: index of item that was inserted 110 @ index: index of item that was inserted
111 """ 111 """
112 - self.last_mask_index = mask.index 112 + #self.last_mask_index = mask.index
113 index = len(self.mask_dict) 113 index = len(self.mask_dict)
114 self.mask_dict[index] = mask 114 self.mask_dict[index] = mask
115 return index 115 return index
@@ -128,7 +128,7 @@ class Project(object): @@ -128,7 +128,7 @@ class Project(object):
128 return self.mask_dict[index] 128 return self.mask_dict[index]
129 129
130 def AddSurface(self, surface): 130 def AddSurface(self, surface):
131 - self.last_surface_index = surface.index 131 + #self.last_surface_index = surface.index
132 index = len(self.surface_dict) 132 index = len(self.surface_dict)
133 self.surface_dict[index] = surface 133 self.surface_dict[index] = surface
134 return index 134 return index
@@ -147,6 +147,27 @@ class Project(object): @@ -147,6 +147,27 @@ class Project(object):
147 new_dict[i-1].index = i-1 147 new_dict[i-1].index = i-1
148 self.surface_dict = new_dict 148 self.surface_dict = new_dict
149 149
  150 +
  151 + def AddMeasurement(self, measurement):
  152 + index = len(self.measurement_dict)
  153 + self.measurement_dict[index] = measurement
  154 + return index
  155 +
  156 + def ChangeMeasurement(self, measurement):
  157 + index = measurement.index
  158 + self.measurement_dict[index] = measurement
  159 +
  160 + def RemoveMeasurement(self, index):
  161 + new_dict = {}
  162 + for i in self.measurement_dict:
  163 + if i < index:
  164 + new_dict[i] = self.measurement_dict[i]
  165 + if i > index:
  166 + new_dict[i-1] = self.measurement_dict[i]
  167 + new_dict[i-1].index = i-1
  168 + self.measurement_dict = new_dict
  169 +
  170 +
150 def SetAcquisitionModality(self, type_=None): 171 def SetAcquisitionModality(self, type_=None):
151 if type_ is None: 172 if type_ is None:
152 type_ = self.modality 173 type_ = self.modality