Commit b7bb24bd090e7ac4b850dda8abb2302d191ee335

Authored by Thiago Franco de Moraes
1 parent 2abd1cd3

Improvements

invesalius/data/measures.py
@@ -107,7 +107,7 @@ class MeasurementManager(object): @@ -107,7 +107,7 @@ class MeasurementManager(object):
107 spacing = 1.0, 1.0, 1.0 107 spacing = 1.0, 1.0, 1.0
108 for i in dict: 108 for i in dict:
109 m = dict[i] 109 m = dict[i]
110 - 110 +
111 if m.location == const.AXIAL: 111 if m.location == const.AXIAL:
112 radius = min(spacing[1], spacing[2]) * const.PROP_MEASURE 112 radius = min(spacing[1], spacing[2]) * const.PROP_MEASURE
113 113
@@ -130,8 +130,10 @@ class MeasurementManager(object): @@ -130,8 +130,10 @@ class MeasurementManager(object):
130 for point in m.points: 130 for point in m.points:
131 x, y, z = point 131 x, y, z = point
132 actors = mr.AddPoint(x, y, z) 132 actors = mr.AddPoint(x, y, z)
133 - # Publisher.sendMessage(("Add actors " + str(m.location)),  
134 - # (actors, m.slice_number)) 133 +
  134 + if m.location == const.SURFACE:
  135 + Publisher.sendMessage(("Add actors " + str(m.location)),
  136 + (actors, m.slice_number))
135 self.current = None 137 self.current = None
136 138
137 if not m.is_shown: 139 if not m.is_shown:
@@ -145,7 +147,6 @@ class MeasurementManager(object): @@ -145,7 +147,6 @@ class MeasurementManager(object):
145 position = pubsub_evt.data[0] 147 position = pubsub_evt.data[0]
146 type = pubsub_evt.data[1] # Linear or Angular 148 type = pubsub_evt.data[1] # Linear or Angular
147 location = pubsub_evt.data[2] # 3D, AXIAL, SAGITAL, CORONAL 149 location = pubsub_evt.data[2] # 3D, AXIAL, SAGITAL, CORONAL
148 - renderer = pubsub_evt.data[-1]  
149 150
150 if location == const.SURFACE: 151 if location == const.SURFACE:
151 slice_number = 0 152 slice_number = 0
@@ -193,7 +194,6 @@ class MeasurementManager(object): @@ -193,7 +194,6 @@ class MeasurementManager(object):
193 mr = LinearMeasure(m.colour, representation) 194 mr = LinearMeasure(m.colour, representation)
194 else: 195 else:
195 mr = AngularMeasure(m.colour, representation) 196 mr = AngularMeasure(m.colour, representation)
196 - mr.renderer = renderer  
197 if to_remove: 197 if to_remove:
198 print "---To REMOVE" 198 print "---To REMOVE"
199 # actors = self.current[1].GetActors() 199 # actors = self.current[1].GetActors()
@@ -217,8 +217,10 @@ class MeasurementManager(object): @@ -217,8 +217,10 @@ class MeasurementManager(object):
217 x, y, z = position 217 x, y, z = position
218 actors = mr.AddPoint(x, y, z) 218 actors = mr.AddPoint(x, y, z)
219 m.points.append(position) 219 m.points.append(position)
220 - # Publisher.sendMessage("Add actors " + str(location),  
221 - # (actors, m.slice_number)) 220 +
  221 + if m.location == const.SURFACE:
  222 + Publisher.sendMessage("Add actors " + str(location),
  223 + (actors, m.slice_number))
222 224
223 if self.current not in self.measures: 225 if self.current not in self.measures:
224 self.measures.append(self.current) 226 self.measures.append(self.current)
@@ -250,13 +252,17 @@ class MeasurementManager(object): @@ -250,13 +252,17 @@ class MeasurementManager(object):
250 252
251 def _remove_measurements(self, pubsub_evt): 253 def _remove_measurements(self, pubsub_evt):
252 indexes = pubsub_evt.data 254 indexes = pubsub_evt.data
253 - print indexes  
254 for index in indexes: 255 for index in indexes:
255 m, mr = self.measures.pop(index) 256 m, mr = self.measures.pop(index)
256 - actors = mr.GetActors() 257 + try:
  258 + mr.Remove()
  259 + except AttributeError:
  260 + # The is not being displayed
  261 + pass
257 prj.Project().RemoveMeasurement(index) 262 prj.Project().RemoveMeasurement(index)
258 - Publisher.sendMessage(('Remove actors ' + str(m.location)),  
259 - (actors, m.slice_number)) 263 + if m.location == const.SURFACE:
  264 + Publisher.sendMessage(('Remove actors ' + str(m.location)),
  265 + (mr.GetActors(), m.slice_number))
260 Publisher.sendMessage('Update slice viewer') 266 Publisher.sendMessage('Update slice viewer')
261 Publisher.sendMessage('Render volume viewer') 267 Publisher.sendMessage('Render volume viewer')
262 268
@@ -275,7 +281,7 @@ class MeasurementManager(object): @@ -275,7 +281,7 @@ class MeasurementManager(object):
275 281
276 def _rm_incomplete_measurements(self, pubsub_evt): 282 def _rm_incomplete_measurements(self, pubsub_evt):
277 if self.current is None: 283 if self.current is None:
278 - return 284 + return
279 285
280 mr = self.current[1] 286 mr = self.current[1]
281 print "RM INC M", self.current, mr.IsComplete() 287 print "RM INC M", self.current, mr.IsComplete()
invesalius/data/styles.py
@@ -389,7 +389,7 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): @@ -389,7 +389,7 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle):
389 Publisher.sendMessage("Add measurement point", 389 Publisher.sendMessage("Add measurement point",
390 ((x, y,z), const.LINEAR, 390 ((x, y,z), const.LINEAR,
391 ORIENTATIONS[self.orientation], 391 ORIENTATIONS[self.orientation],
392 - slice_number, self.radius, renderer)) 392 + slice_number, self.radius))
393 Publisher.sendMessage('Reload actual slice %s' % self.orientation) 393 Publisher.sendMessage('Reload actual slice %s' % self.orientation)
394 394
395 def OnReleaseMeasurePoint(self, obj, evt): 395 def OnReleaseMeasurePoint(self, obj, evt):
invesalius/data/viewer_slice.py
@@ -1189,6 +1189,7 @@ class Viewer(wx.Panel): @@ -1189,6 +1189,7 @@ class Viewer(wx.Panel):
1189 self.slice_data.renderer.RemoveActor(actor) 1189 self.slice_data.renderer.RemoveActor(actor)
1190 1190
1191 for (m, mr) in self.measures.get(self.orientation, index): 1191 for (m, mr) in self.measures.get(self.orientation, index):
  1192 + mr.renderer = self.slice_data.renderer
1192 for actor in mr.GetActors(): 1193 for actor in mr.GetActors():
1193 self.slice_data.renderer.AddActor(actor) 1194 self.slice_data.renderer.AddActor(actor)
1194 1195