Commit edd9a1e8896df4fdee38d3afc7d713616956733c

Authored by vhosouza
2 parents 3e651efa 9a71385e
Exists in usp-navegador

Merge remote-tracking branch 'upstream/master'

invesalius/control.py
@@ -204,7 +204,7 @@ class Controller(): @@ -204,7 +204,7 @@ class Controller():
204 Publisher.sendMessage("Enable state project", False) 204 Publisher.sendMessage("Enable state project", False)
205 Publisher.sendMessage('Set project name') 205 Publisher.sendMessage('Set project name')
206 Publisher.sendMessage("Stop Config Recording") 206 Publisher.sendMessage("Stop Config Recording")
207 - #Publisher.sendMessage("Exit") 207 + Publisher.sendMessage("Exit")
208 elif answer == 1: 208 elif answer == 1:
209 self.ShowDialogSaveProject() 209 self.ShowDialogSaveProject()
210 utils.debug("Save changes and close") 210 utils.debug("Save changes and close")
@@ -212,7 +212,7 @@ class Controller(): @@ -212,7 +212,7 @@ class Controller():
212 Publisher.sendMessage("Enable state project", False) 212 Publisher.sendMessage("Enable state project", False)
213 Publisher.sendMessage('Set project name') 213 Publisher.sendMessage('Set project name')
214 Publisher.sendMessage("Stop Config Recording") 214 Publisher.sendMessage("Stop Config Recording")
215 - #Publisher.sendMessage("Exit") 215 + Publisher.sendMessage("Exit")
216 elif answer == -1: 216 elif answer == -1:
217 utils.debug("Cancel") 217 utils.debug("Cancel")
218 else: 218 else:
@@ -220,11 +220,11 @@ class Controller(): @@ -220,11 +220,11 @@ class Controller():
220 Publisher.sendMessage("Enable state project", False) 220 Publisher.sendMessage("Enable state project", False)
221 Publisher.sendMessage('Set project name') 221 Publisher.sendMessage('Set project name')
222 Publisher.sendMessage("Stop Config Recording") 222 Publisher.sendMessage("Stop Config Recording")
223 - #Publisher.sendMessage("Exit") 223 + Publisher.sendMessage("Exit")
224 224
225 else: 225 else:
226 Publisher.sendMessage('Stop Config Recording') 226 Publisher.sendMessage('Stop Config Recording')
227 - #Publisher.sendMessage('Exit') 227 + Publisher.sendMessage('Exit')
228 228
229 229
230 ########################### 230 ###########################
@@ -265,10 +265,6 @@ class Controller(): @@ -265,10 +265,6 @@ class Controller():
265 self.Slice.window_level = proj.level 265 self.Slice.window_level = proj.level
266 self.Slice.window_width = proj.window 266 self.Slice.window_width = proj.window
267 267
268 - mask = msk.Mask()  
269 - mask._set_class_index(proj.last_mask_index)  
270 - self.mask_dict_copy = proj.mask_dict.copy()  
271 -  
272 Publisher.sendMessage('Update threshold limits list', 268 Publisher.sendMessage('Update threshold limits list',
273 proj.threshold_range) 269 proj.threshold_range)
274 270
@@ -395,8 +391,7 @@ class Controller(): @@ -395,8 +391,7 @@ class Controller():
395 self.Slice.spacing = proj.spacing 391 self.Slice.spacing = proj.spacing
396 392
397 Publisher.sendMessage('Load slice to viewer', 393 Publisher.sendMessage('Load slice to viewer',
398 - (proj.imagedata,  
399 - proj.mask_dict)) 394 + (proj.mask_dict))
400 395
401 396
402 Publisher.sendMessage('Load slice plane') 397 Publisher.sendMessage('Load slice plane')
invesalius/data/slice_.py
@@ -16,7 +16,6 @@ @@ -16,7 +16,6 @@
16 # PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais 16 # PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais
17 # detalhes. 17 # detalhes.
18 #-------------------------------------------------------------------------- 18 #--------------------------------------------------------------------------
19 -import math  
20 import os 19 import os
21 import tempfile 20 import tempfile
22 21
@@ -79,7 +78,6 @@ class Slice(object): @@ -79,7 +78,6 @@ class Slice(object):
79 # Therefore, we use Singleton design pattern for implementing it. 78 # Therefore, we use Singleton design pattern for implementing it.
80 79
81 def __init__(self): 80 def __init__(self):
82 - self.imagedata = None  
83 self.current_mask = None 81 self.current_mask = None
84 self.blend_filter = None 82 self.blend_filter = None
85 self.histogram = None 83 self.histogram = None
@@ -159,9 +157,8 @@ class Slice(object): @@ -159,9 +157,8 @@ class Slice(object):
159 157
160 Publisher.subscribe(self.UpdateColourTableBackgroundWidget,\ 158 Publisher.subscribe(self.UpdateColourTableBackgroundWidget,\
161 'Change colour table from background image from widget') 159 'Change colour table from background image from widget')
162 - Publisher.subscribe(self._set_projection_type, 'Set projection type')  
163 160
164 - Publisher.subscribe(self.InputImageWidget, 'Input Image in the widget') 161 + Publisher.subscribe(self._set_projection_type, 'Set projection type')
165 162
166 Publisher.subscribe(self.OnExportMask,'Export mask to file') 163 Publisher.subscribe(self.OnExportMask,'Export mask to file')
167 164
@@ -249,7 +246,6 @@ class Slice(object): @@ -249,7 +246,6 @@ class Slice(object):
249 self.CloseProject() 246 self.CloseProject()
250 247
251 def CloseProject(self): 248 def CloseProject(self):
252 - self.imagedata = None  
253 f = self._matrix.filename 249 f = self._matrix.filename
254 self._matrix._mmap.close() 250 self._matrix._mmap.close()
255 self._matrix = None 251 self._matrix = None
@@ -276,10 +272,6 @@ class Slice(object): @@ -276,10 +272,6 @@ class Slice(object):
276 272
277 Publisher.sendMessage('Select first item from slice menu') 273 Publisher.sendMessage('Select first item from slice menu')
278 274
279 - #self.blend_filter = None  
280 - #self.blend_filter = None  
281 - #self.num_gradient = 0  
282 -  
283 def __set_current_mask_threshold_limits(self, pubsub_evt): 275 def __set_current_mask_threshold_limits(self, pubsub_evt):
284 thresh_min = pubsub_evt.data[0] 276 thresh_min = pubsub_evt.data[0]
285 thresh_max = pubsub_evt.data[1] 277 thresh_max = pubsub_evt.data[1]
@@ -287,10 +279,6 @@ class Slice(object): @@ -287,10 +279,6 @@ class Slice(object):
287 index = self.current_mask.index 279 index = self.current_mask.index
288 self.SetMaskEditionThreshold(index, (thresh_min, thresh_max)) 280 self.SetMaskEditionThreshold(index, (thresh_min, thresh_max))
289 281
290 - #---------------------------------------------------------------------------  
291 - # BEGIN PUBSUB_EVT METHODS  
292 - #---------------------------------------------------------------------------  
293 -  
294 def __add_mask(self, pubsub_evt): 282 def __add_mask(self, pubsub_evt):
295 mask_name = pubsub_evt.data 283 mask_name = pubsub_evt.data
296 self.CreateMask(name=mask_name) 284 self.CreateMask(name=mask_name)
@@ -308,7 +296,7 @@ class Slice(object): @@ -308,7 +296,7 @@ class Slice(object):
308 def __select_current_mask(self, pubsub_evt): 296 def __select_current_mask(self, pubsub_evt):
309 mask_index = pubsub_evt.data 297 mask_index = pubsub_evt.data
310 self.SelectCurrentMask(mask_index) 298 self.SelectCurrentMask(mask_index)
311 - #--------------------------------------------------------------------------- 299 +
312 def __set_current_mask_edition_threshold(self, evt_pubsub): 300 def __set_current_mask_edition_threshold(self, evt_pubsub):
313 if self.current_mask: 301 if self.current_mask:
314 threshold_range = evt_pubsub.data 302 threshold_range = evt_pubsub.data
@@ -324,7 +312,6 @@ class Slice(object): @@ -324,7 +312,6 @@ class Slice(object):
324 312
325 to_reload = False 313 to_reload = False
326 if threshold_range != self.current_mask.threshold_range: 314 if threshold_range != self.current_mask.threshold_range:
327 - print "<<<<<<<<<<<<<<<< DIFERENT >>>>>>>>>>>>>>>>>>>>>>>"  
328 to_reload = True 315 to_reload = True
329 for orientation in self.buffer_slices: 316 for orientation in self.buffer_slices:
330 self.buffer_slices[orientation].discard_vtk_mask() 317 self.buffer_slices[orientation].discard_vtk_mask()
@@ -482,7 +469,6 @@ class Slice(object): @@ -482,7 +469,6 @@ class Slice(object):
482 469
483 def GetSlices(self, orientation, slice_number, number_slices, 470 def GetSlices(self, orientation, slice_number, number_slices,
484 inverted=False, border_size=1.0): 471 inverted=False, border_size=1.0):
485 - print "min max ->", self.matrix.min(), self.matrix.max()  
486 if self.buffer_slices[orientation].index == slice_number and \ 472 if self.buffer_slices[orientation].index == slice_number and \
487 self._type_projection == const.PROJECTION_NORMAL: 473 self._type_projection == const.PROJECTION_NORMAL:
488 if self.buffer_slices[orientation].vtk_image: 474 if self.buffer_slices[orientation].vtk_image:
@@ -837,19 +823,12 @@ class Slice(object): @@ -837,19 +823,12 @@ class Slice(object):
837 823
838 def SelectCurrentMask(self, index): 824 def SelectCurrentMask(self, index):
839 "Insert mask data, based on given index, into pipeline." 825 "Insert mask data, based on given index, into pipeline."
840 - # This condition is not necessary in Linux, only under mac and windows  
841 - # because combobox event is binded when the same item is selected again.  
842 - #if index != self.current_mask.index:  
843 - print "SelectCurrentMask"  
844 - print "index:", index  
845 proj = Project() 826 proj = Project()
846 future_mask = proj.GetMask(index) 827 future_mask = proj.GetMask(index)
847 future_mask.is_shown = True 828 future_mask.is_shown = True
848 self.current_mask = future_mask 829 self.current_mask = future_mask
849 830
850 colour = future_mask.colour 831 colour = future_mask.colour
851 - #index = future_mask.index  
852 - print index  
853 self.SetMaskColour(index, colour, update=False) 832 self.SetMaskColour(index, colour, update=False)
854 833
855 self.buffer_slices = {"AXIAL": SliceBuffer(), 834 self.buffer_slices = {"AXIAL": SliceBuffer(),
@@ -872,18 +851,9 @@ class Slice(object): @@ -872,18 +851,9 @@ class Slice(object):
872 proj = Project() 851 proj = Project()
873 mask = proj.mask_dict[surface_parameters['options']['index']] 852 mask = proj.mask_dict[surface_parameters['options']['index']]
874 853
875 - # This is very important. Do not use masks' imagedata. It would mess up  
876 - # surface quality event when using contour  
877 - #self.SetMaskThreshold(mask.index, threshold)  
878 - for n in xrange(1, mask.matrix.shape[0]):  
879 - if mask.matrix[n, 0, 0] == 0:  
880 - m = mask.matrix[n, 1:, 1:]  
881 - mask.matrix[n, 1:, 1:] = self.do_threshold_to_a_slice(self.matrix[n-1], m)  
882 -  
883 - mask.matrix.flush() 854 + self.do_threshold_to_all_slices(mask)
  855 + Publisher.sendMessage('Create surface', (self, mask, surface_parameters))
884 856
885 - Publisher.sendMessage('Create surface', (self, mask,  
886 - surface_parameters))  
887 def GetOutput(self): 857 def GetOutput(self):
888 return self.blend_filter.GetOutput() 858 return self.blend_filter.GetOutput()
889 859
@@ -907,59 +877,6 @@ class Slice(object): @@ -907,59 +877,6 @@ class Slice(object):
907 877
908 Publisher.sendMessage('Check projection menu', tprojection) 878 Publisher.sendMessage('Check projection menu', tprojection)
909 879
910 - def SetInput(self, imagedata, mask_dict):  
911 - print "SETINPUT!"  
912 - self.imagedata = imagedata  
913 - self.extent = imagedata.GetExtent()  
914 -  
915 - imagedata_bg = self.__create_background(imagedata)  
916 -  
917 - if not mask_dict:  
918 - imagedata_mask = self.__build_mask(imagedata, create=True)  
919 - else:  
920 - self.__load_masks(imagedata, mask_dict)  
921 - imagedata_mask = self.img_colours_mask.GetOutput()  
922 -  
923 - mask_opacity = self.current_mask.opacity  
924 -  
925 - # blend both imagedatas, so it can be inserted into viewer  
926 - blend_filter = vtk.vtkImageBlend()  
927 - blend_filter.SetBlendModeToNormal()  
928 - blend_filter.SetOpacity(0, 1)  
929 - if self.current_mask.is_shown:  
930 - blend_filter.SetOpacity(1, mask_opacity)  
931 - else:  
932 - blend_filter.SetOpacity(1, 0)  
933 - blend_filter.SetInput(0, imagedata_bg)  
934 - blend_filter.SetInput(1, imagedata_mask)  
935 - blend_filter.SetBlendModeToNormal()  
936 - blend_filter.GetOutput().ReleaseDataFlagOn()  
937 - self.blend_filter = blend_filter  
938 -  
939 - self.window_level = vtk.vtkImageMapToWindowLevelColors()  
940 - self.window_level.SetInput(self.imagedata)  
941 -  
942 - def __create_background(self, imagedata):  
943 - thresh_min, thresh_max = imagedata.GetScalarRange()  
944 - Publisher.sendMessage('Update threshold limits list', (thresh_min,  
945 - thresh_max))  
946 -  
947 - # map scalar values into colors  
948 - lut_bg = self.lut_bg = vtk.vtkLookupTable()  
949 - lut_bg.SetTableRange(thresh_min, thresh_max)  
950 - lut_bg.SetSaturationRange(0, 0)  
951 - lut_bg.SetHueRange(0, 0)  
952 - lut_bg.SetValueRange(0, 1)  
953 - lut_bg.Build()  
954 -  
955 - # map the input image through a lookup table  
956 - img_colours_bg = self.img_colours_bg = vtk.vtkImageMapToColors()  
957 - img_colours_bg.SetOutputFormatToRGBA()  
958 - img_colours_bg.SetLookupTable(lut_bg)  
959 - img_colours_bg.SetInput(imagedata)  
960 -  
961 - return img_colours_bg.GetOutput()  
962 -  
963 def UpdateWindowLevelBackground(self, pubsub_evt): 880 def UpdateWindowLevelBackground(self, pubsub_evt):
964 window, level = pubsub_evt.data 881 window, level = pubsub_evt.data
965 self.window_width = window 882 self.window_width = window
@@ -1018,29 +935,6 @@ class Slice(object): @@ -1018,29 +935,6 @@ class Slice(object):
1018 935
1019 Publisher.sendMessage('Reload actual slice') 936 Publisher.sendMessage('Reload actual slice')
1020 937
1021 - def InputImageWidget(self, pubsub_evt):  
1022 - widget, orientation = pubsub_evt.data  
1023 -  
1024 - original_orientation = Project().original_orientation  
1025 -  
1026 - img = self.buffer_slices[orientation].vtk_image  
1027 -  
1028 - cast = vtk.vtkImageCast()  
1029 - cast.SetInput(img)  
1030 - cast.SetOutputScalarTypeToDouble()  
1031 - cast.ClampOverflowOn()  
1032 - cast.Update()  
1033 -  
1034 - #if (original_orientation == const.AXIAL):  
1035 - flip = vtk.vtkImageFlip()  
1036 - flip.SetInput(cast.GetOutput())  
1037 - flip.SetFilteredAxis(1)  
1038 - flip.FlipAboutOriginOn()  
1039 - flip.Update()  
1040 - widget.SetInput(flip.GetOutput())  
1041 - #else:  
1042 - #widget.SetInput(cast.GetOutput())  
1043 -  
1044 def UpdateSlice3D(self, pubsub_evt): 938 def UpdateSlice3D(self, pubsub_evt):
1045 widget, orientation = pubsub_evt.data 939 widget, orientation = pubsub_evt.data
1046 img = self.buffer_slices[orientation].vtk_image 940 img = self.buffer_slices[orientation].vtk_image
@@ -1112,27 +1006,6 @@ class Slice(object): @@ -1112,27 +1006,6 @@ class Slice(object):
1112 Publisher.sendMessage('Change mask selected', mask.index) 1006 Publisher.sendMessage('Change mask selected', mask.index)
1113 Publisher.sendMessage('Update slice viewer') 1007 Publisher.sendMessage('Update slice viewer')
1114 1008
1115 - def __load_masks(self, imagedata, mask_dict):  
1116 - keys = mask_dict.keys()  
1117 - keys.sort()  
1118 - for key in keys:  
1119 - mask = mask_dict[key]  
1120 -  
1121 - # update gui related to mask  
1122 - utils.debug("__load_masks")  
1123 - utils.debug('THRESHOLD_RANGE %s'% mask.threshold_range)  
1124 - Publisher.sendMessage('Add mask',  
1125 - (mask.index,  
1126 - mask.name,  
1127 - mask.threshold_range,  
1128 - mask.colour))  
1129 -  
1130 - self.current_mask = mask  
1131 - self.__build_mask(imagedata, False)  
1132 -  
1133 - Publisher.sendMessage('Change mask selected', mask.index)  
1134 - Publisher.sendMessage('Update slice viewer')  
1135 -  
1136 def do_ww_wl(self, image): 1009 def do_ww_wl(self, image):
1137 if self.from_ == PLIST: 1010 if self.from_ == PLIST:
1138 lut = vtk.vtkWindowLevelLookupTable() 1011 lut = vtk.vtkWindowLevelLookupTable()
@@ -1213,12 +1086,16 @@ class Slice(object): @@ -1213,12 +1086,16 @@ class Slice(object):
1213 m[mask == 254] = 254 1086 m[mask == 254] = 254
1214 return m.astype('uint8') 1087 return m.astype('uint8')
1215 1088
1216 - def do_threshold_to_all_slices(self):  
1217 - mask = self.current_mask 1089 + def do_threshold_to_all_slices(self, mask=None):
  1090 + """
  1091 + Apply threshold to all slices.
1218 1092
1219 - # This is very important. Do not use masks' imagedata. It would mess up  
1220 - # surface quality event when using contour  
1221 - #self.SetMaskThreshold(mask.index, threshold) 1093 + Params:
  1094 + - mask: the mask where result of the threshold will be stored.If
  1095 + None, it'll be the current mask.
  1096 + """
  1097 + if mask is None:
  1098 + mask = self.current_mask
1222 for n in xrange(1, mask.matrix.shape[0]): 1099 for n in xrange(1, mask.matrix.shape[0]):
1223 if mask.matrix[n, 0, 0] == 0: 1100 if mask.matrix[n, 0, 0] == 0:
1224 m = mask.matrix[n, 1:, 1:] 1101 m = mask.matrix[n, 1:, 1:]
@@ -1391,76 +1268,9 @@ class Slice(object): @@ -1391,76 +1268,9 @@ class Slice(object):
1391 self.buffer_slices[o].discard_vtk_mask() 1268 self.buffer_slices[o].discard_vtk_mask()
1392 Publisher.sendMessage('Reload actual slice') 1269 Publisher.sendMessage('Reload actual slice')
1393 1270
1394 - def __build_mask(self, imagedata, create=True):  
1395 - # create new mask instance and insert it into project  
1396 - if create:  
1397 - self.CreateMask(imagedata=imagedata)  
1398 - current_mask = self.current_mask  
1399 -  
1400 - # properties to be inserted into pipeline  
1401 - scalar_range = int(imagedata.GetScalarRange()[1])  
1402 - r,g,b = current_mask.colour  
1403 -  
1404 - # map scalar values into colors  
1405 - lut_mask = vtk.vtkLookupTable()  
1406 - lut_mask.SetNumberOfTableValues(1)  
1407 - lut_mask.SetNumberOfColors(1)  
1408 - lut_mask.SetHueRange(const.THRESHOLD_HUE_RANGE)  
1409 - lut_mask.SetSaturationRange(1, 1)  
1410 - lut_mask.SetValueRange(1, 1)  
1411 - lut_mask.SetNumberOfTableValues(scalar_range)  
1412 - lut_mask.SetTableValue(1, r, g, b, 1.0)  
1413 - lut_mask.SetTableValue(scalar_range - 1, r, g, b, 1.0)  
1414 - lut_mask.SetRampToLinear()  
1415 - lut_mask.Build()  
1416 - self.lut_mask = lut_mask  
1417 -  
1418 - mask_thresh_imagedata = self.__create_mask_threshold(imagedata)  
1419 -  
1420 - if create:  
1421 - # threshold pipeline  
1422 - current_mask.imagedata.DeepCopy(mask_thresh_imagedata)  
1423 - else:  
1424 - mask_thresh_imagedata = self.current_mask.imagedata  
1425 -  
1426 - # map the input image through a lookup table  
1427 - img_colours_mask = vtk.vtkImageMapToColors()  
1428 - img_colours_mask.SetOutputFormatToRGBA()  
1429 - img_colours_mask.SetLookupTable(lut_mask)  
1430 -  
1431 - img_colours_mask.SetInput(mask_thresh_imagedata)  
1432 -  
1433 - self.img_colours_mask = img_colours_mask  
1434 -  
1435 - return img_colours_mask.GetOutput()  
1436 -  
1437 - def __create_mask_threshold(self, imagedata, threshold_range=None):  
1438 - if not threshold_range:  
1439 - thresh_min, thresh_max = self.current_mask.threshold_range  
1440 - else:  
1441 - thresh_min, thresh_max = threshold_range  
1442 -  
1443 - # flexible threshold  
1444 - img_thresh_mask = vtk.vtkImageThreshold()  
1445 - img_thresh_mask.SetInValue(const.THRESHOLD_INVALUE)  
1446 - img_thresh_mask.SetInput(imagedata)  
1447 - img_thresh_mask.SetOutValue(const.THRESHOLD_OUTVALUE)  
1448 - img_thresh_mask.ThresholdBetween(float(thresh_min), float(thresh_max))  
1449 - img_thresh_mask.Update()  
1450 - self.img_thresh_mask = img_thresh_mask  
1451 -  
1452 - # copy of threshold output  
1453 - imagedata_mask = vtk.vtkImageData()  
1454 - imagedata_mask.DeepCopy(img_thresh_mask.GetOutput())  
1455 - imagedata_mask.Update()  
1456 -  
1457 - return imagedata_mask  
1458 -  
1459 def _open_image_matrix(self, filename, shape, dtype): 1271 def _open_image_matrix(self, filename, shape, dtype):
1460 self.matrix_filename = filename 1272 self.matrix_filename = filename
1461 - print ">>>", filename  
1462 - self.matrix = numpy.memmap(filename, shape=shape, dtype=dtype,  
1463 - mode='r+') 1273 + self.matrix = numpy.memmap(filename, shape=shape, dtype=dtype, mode='r+')
1464 1274
1465 def OnFlipVolume(self, pubsub_evt): 1275 def OnFlipVolume(self, pubsub_evt):
1466 axis = pubsub_evt.data 1276 axis = pubsub_evt.data
@@ -1490,8 +1300,9 @@ class Slice(object): @@ -1490,8 +1300,9 @@ class Slice(object):
1490 print type(self.matrix) 1300 print type(self.matrix)
1491 1301
1492 def OnExportMask(self, pubsub_evt): 1302 def OnExportMask(self, pubsub_evt):
1493 - #imagedata = self.current_mask.imagedata  
1494 - imagedata = self.imagedata  
1495 - filename, filetype = pubsub_evt.data  
1496 - if (filetype == const.FILETYPE_IMAGEDATA):  
1497 - iu.Export(imagedata, filename) 1303 + pass
  1304 + ##imagedata = self.current_mask.imagedata
  1305 + #imagedata = self.imagedata
  1306 + #filename, filetype = pubsub_evt.data
  1307 + #if (filetype == const.FILETYPE_IMAGEDATA):
  1308 + #iu.Export(imagedata, filename)
invesalius/data/styles.py
@@ -427,7 +427,6 @@ class SpinInteractorStyle(DefaultInteractorStyle): @@ -427,7 +427,6 @@ class SpinInteractorStyle(DefaultInteractorStyle):
427 cam = ren.GetActiveCamera() 427 cam = ren.GetActiveCamera()
428 if (self.left_pressed): 428 if (self.left_pressed):
429 self.viewer.UpdateTextDirection(cam) 429 self.viewer.UpdateTextDirection(cam)
430 - self.spined_image = True  
431 obj.Spin() 430 obj.Spin()
432 obj.OnRightButtonDown() 431 obj.OnRightButtonDown()
433 432
invesalius/data/viewer_slice.py
@@ -152,16 +152,10 @@ class Viewer(wx.Panel): @@ -152,16 +152,10 @@ class Viewer(wx.Panel):
152 #self.SetBackgroundColour(colour) 152 #self.SetBackgroundColour(colour)
153 153
154 # Interactor additional style 154 # Interactor additional style
155 - #self.modes = []#['DEFAULT']  
156 - self.left_pressed = 0  
157 - self.right_pressed = 0  
158 155
159 self._number_slices = const.PROJECTION_MIP_SIZE 156 self._number_slices = const.PROJECTION_MIP_SIZE
160 self._mip_inverted = False 157 self._mip_inverted = False
161 158
162 - self.spined_image = False #Use to control to spin  
163 - self.paned_image = False  
164 -  
165 self.style = None 159 self.style = None
166 self.last_position_mouse_move = () 160 self.last_position_mouse_move = ()
167 self.state = const.STATE_DEFAULT 161 self.state = const.STATE_DEFAULT
@@ -200,7 +194,6 @@ class Viewer(wx.Panel): @@ -200,7 +194,6 @@ class Viewer(wx.Panel):
200 self.__bind_events() 194 self.__bind_events()
201 self.__bind_events_wx() 195 self.__bind_events_wx()
202 196
203 - self._warped = False  
204 self._flush_buffer = False 197 self._flush_buffer = False
205 198
206 def __init_gui(self): 199 def __init_gui(self):
@@ -230,7 +223,6 @@ class Viewer(wx.Panel): @@ -230,7 +223,6 @@ class Viewer(wx.Panel):
230 self.interactor.SetPicker(self.pick) 223 self.interactor.SetPicker(self.pick)
231 224
232 def OnContextMenu(self, evt): 225 def OnContextMenu(self, evt):
233 - self.right_pressed = 0  
234 if (self.last_position_mouse_move ==\ 226 if (self.last_position_mouse_move ==\
235 self.interactor.GetLastEventPosition()): 227 self.interactor.GetLastEventPosition()):
236 self.menu.caller = self 228 self.menu.caller = self
@@ -849,7 +841,6 @@ class Viewer(wx.Panel): @@ -849,7 +841,6 @@ class Viewer(wx.Panel):
849 for slice_data in self.slice_data_list: 841 for slice_data in self.slice_data_list:
850 del slice_data 842 del slice_data
851 843
852 - self.modes = []#['DEFAULT']  
853 self.slice_data_list = [] 844 self.slice_data_list = []
854 self.layout = (1, 1) 845 self.layout = (1, 1)
855 self.orientation_texts = [] 846 self.orientation_texts = []
@@ -877,8 +868,8 @@ class Viewer(wx.Panel): @@ -877,8 +868,8 @@ class Viewer(wx.Panel):
877 self.interactor.Bind(wx.EVT_SIZE, self.OnSize) 868 self.interactor.Bind(wx.EVT_SIZE, self.OnSize)
878 869
879 def LoadImagedata(self, pubsub_evt): 870 def LoadImagedata(self, pubsub_evt):
880 - imagedata, mask_dict = pubsub_evt.data  
881 - self.SetInput(imagedata, mask_dict) 871 + mask_dict = pubsub_evt.data
  872 + self.SetInput(mask_dict)
882 873
883 def LoadRenderers(self, imagedata): 874 def LoadRenderers(self, imagedata):
884 number_renderers = self.layout[0] * self.layout[1] 875 number_renderers = self.layout[0] * self.layout[1]
@@ -943,7 +934,7 @@ class Viewer(wx.Panel): @@ -943,7 +934,7 @@ class Viewer(wx.Panel):
943 self.cursor_ = cursor 934 self.cursor_ = cursor
944 return cursor 935 return cursor
945 936
946 - def SetInput(self, imagedata, mask_dict): 937 + def SetInput(self, mask_dict):
947 self.slice_ = sl.Slice() 938 self.slice_ = sl.Slice()
948 939
949 max_slice_number = sl.Slice().GetNumberOfSlices(self.orientation) 940 max_slice_number = sl.Slice().GetNumberOfSlices(self.orientation)
@@ -951,11 +942,9 @@ class Viewer(wx.Panel): @@ -951,11 +942,9 @@ class Viewer(wx.Panel):
951 max_slice_number) 942 max_slice_number)
952 943
953 self.slice_data = self.create_slice_window() 944 self.slice_data = self.create_slice_window()
954 - #self.slice_data.actor.SetInput(imagedata)  
955 self.slice_data.SetCursor(self.__create_cursor()) 945 self.slice_data.SetCursor(self.__create_cursor())
956 self.cam = self.slice_data.renderer.GetActiveCamera() 946 self.cam = self.slice_data.renderer.GetActiveCamera()
957 - self.__build_cross_lines(imagedata)  
958 - #self.set_slice_number(0) 947 + self.__build_cross_lines()
959 948
960 # Set the slice number to the last slice to ensure the camera is far 949 # Set the slice number to the last slice to ensure the camera is far
961 # enough to show all slices. 950 # enough to show all slices.
@@ -963,30 +952,6 @@ class Viewer(wx.Panel): @@ -963,30 +952,6 @@ class Viewer(wx.Panel):
963 self.__update_camera() 952 self.__update_camera()
964 self.slice_data.renderer.ResetCamera() 953 self.slice_data.renderer.ResetCamera()
965 self.interactor.GetRenderWindow().AddRenderer(self.slice_data.renderer) 954 self.interactor.GetRenderWindow().AddRenderer(self.slice_data.renderer)
966 - #if slice_.imagedata is None:  
967 - #slice_.SetInput(imagedata, mask_dict)  
968 -  
969 - ##actor.SetInput(slice_.GetOutput())  
970 - #self.LoadRenderers(slice_.GetOutput())  
971 - #self.__configure_renderers()  
972 - #ren = self.slice_data_list[0].renderer  
973 - #actor = self.slice_data_list[0].actor  
974 - #actor_bound = actor.GetBounds()  
975 - #self.cam = ren.GetActiveCamera()  
976 -  
977 - #for slice_data in self.slice_data_list:  
978 - #self.__update_camera(slice_data)  
979 - #self.Reposition(slice_data)  
980 -  
981 - #number_of_slices = self.layout[0] * self.layout[1]  
982 - #max_slice_number = actor.GetSliceNumberMax() + 1/ \  
983 - #number_of_slices  
984 -  
985 - #if actor.GetSliceNumberMax() % number_of_slices:  
986 - #max_slice_number += 1  
987 - #self.set_scroll_position(0)  
988 -  
989 - #actor_bound = actor.GetBounds()  
990 self.interactor.Render() 955 self.interactor.Render()
991 956
992 self.EnableText() 957 self.EnableText()
@@ -994,7 +959,7 @@ class Viewer(wx.Panel): @@ -994,7 +959,7 @@ class Viewer(wx.Panel):
994 ## Insert cursor 959 ## Insert cursor
995 self.SetInteractorStyle(const.STATE_DEFAULT) 960 self.SetInteractorStyle(const.STATE_DEFAULT)
996 961
997 - def __build_cross_lines(self, imagedata): 962 + def __build_cross_lines(self):
998 renderer = self.slice_data.overlay_renderer 963 renderer = self.slice_data.overlay_renderer
999 964
1000 cross = vtk.vtkCursor3D() 965 cross = vtk.vtkCursor3D()
@@ -1033,28 +998,6 @@ class Viewer(wx.Panel): @@ -1033,28 +998,6 @@ class Viewer(wx.Panel):
1033 for slice_data in self.slice_data_list: 998 for slice_data in self.slice_data_list:
1034 slice_data.cursor.actor.SetVisibility(visibility) 999 slice_data.cursor.actor.SetVisibility(visibility)
1035 1000
1036 - def __update_cursor_position(self, slice_data, position):  
1037 - x, y, z = position  
1038 - if (slice_data.cursor):  
1039 - slice_number = slice_data.number  
1040 - actor_bound = slice_data.actor.GetBounds()  
1041 -  
1042 - yz = [x + abs(x * 0.001), y, z]  
1043 - xz = [x, y - abs(y * 0.001), z]  
1044 - xy = [x, y, z + abs(z * 0.001)]  
1045 -  
1046 - proj = project.Project()  
1047 - orig_orien = proj.original_orientation  
1048 -  
1049 - if (orig_orien == const.SAGITAL):  
1050 - coordinates = {"SAGITAL": xy, "CORONAL": yz, "AXIAL": xz}  
1051 - elif(orig_orien == const.CORONAL):  
1052 - coordinates = {"SAGITAL": yz, "CORONAL": xy, "AXIAL": xz}  
1053 - else:  
1054 - coordinates = {"SAGITAL": yz, "CORONAL": xz, "AXIAL": xy}  
1055 -  
1056 - slice_data.cursor.SetPosition(coordinates[self.orientation])  
1057 -  
1058 def SetOrientation(self, orientation): 1001 def SetOrientation(self, orientation):
1059 self.orientation = orientation 1002 self.orientation = orientation
1060 for slice_data in self.slice_data_list: 1003 for slice_data in self.slice_data_list:
@@ -1070,7 +1013,6 @@ class Viewer(wx.Panel): @@ -1070,7 +1013,6 @@ class Viewer(wx.Panel):
1070 overlay_renderer.SetActiveCamera(cam) 1013 overlay_renderer.SetActiveCamera(cam)
1071 overlay_renderer.SetInteractive(0) 1014 overlay_renderer.SetInteractive(0)
1072 1015
1073 -  
1074 self.interactor.GetRenderWindow().SetNumberOfLayers(2) 1016 self.interactor.GetRenderWindow().SetNumberOfLayers(2)
1075 self.interactor.GetRenderWindow().AddRenderer(overlay_renderer) 1017 self.interactor.GetRenderWindow().AddRenderer(overlay_renderer)
1076 self.interactor.GetRenderWindow().AddRenderer(renderer) 1018 self.interactor.GetRenderWindow().AddRenderer(renderer)
@@ -1309,30 +1251,6 @@ class Viewer(wx.Panel): @@ -1309,30 +1251,6 @@ class Viewer(wx.Panel):
1309 self.set_slice_number(pos) 1251 self.set_slice_number(pos)
1310 self.interactor.Render() 1252 self.interactor.Render()
1311 1253
1312 - def test_operation_position(self, coord):  
1313 - """  
1314 - Test if coord is into the imagedata limits.  
1315 - """  
1316 - x, y, z = coord  
1317 - xi, yi, zi = 0, 0, 0  
1318 - xf, yf, zf = self.imagedata.GetDimensions()  
1319 - if xi <= x <= xf \  
1320 - and yi <= y <= yf\  
1321 - and zi <= z <= zf:  
1322 - return True  
1323 - return False  
1324 -  
1325 - def _assert_coord_into_image(self, coord):  
1326 - extent = self.imagedata.GetWholeExtent()  
1327 - extent_min = extent[0], extent[2], extent[4]  
1328 - extent_max = extent[1], extent[3], extent[5]  
1329 - for index in xrange(3):  
1330 - if coord[index] > extent_max[index]:  
1331 - coord[index] = extent_max[index]  
1332 - elif coord[index] < extent_min[index]:  
1333 - coord[index] = extent_min[index]  
1334 - return coord  
1335 -  
1336 def ReloadActualSlice(self, pubsub_evt=None): 1254 def ReloadActualSlice(self, pubsub_evt=None):
1337 pos = self.scroll.GetThumbPosition() 1255 pos = self.scroll.GetThumbPosition()
1338 self.set_slice_number(pos) 1256 self.set_slice_number(pos)
invesalius/gui/frame.py
@@ -348,7 +348,6 @@ class Frame(wx.Frame): @@ -348,7 +348,6 @@ class Frame(wx.Frame):
348 Close all project data. 348 Close all project data.
349 """ 349 """
350 Publisher.sendMessage('Close Project') 350 Publisher.sendMessage('Close Project')
351 - Publisher.sendMessage('Exit')  
352 351
353 def OnMenuClick(self, evt): 352 def OnMenuClick(self, evt):
354 """ 353 """
invesalius/project.py
@@ -22,7 +22,6 @@ import glob @@ -22,7 +22,6 @@ import glob
22 import os 22 import os
23 import plistlib 23 import plistlib
24 import shutil 24 import shutil
25 -import stat  
26 import tarfile 25 import tarfile
27 import tempfile 26 import tempfile
28 27
@@ -35,7 +34,6 @@ import data.mask as msk @@ -35,7 +34,6 @@ import data.mask as msk
35 import data.polydata_utils as pu 34 import data.polydata_utils as pu
36 import data.surface as srf 35 import data.surface as srf
37 from presets import Presets 36 from presets import Presets
38 -from reader import dicom  
39 from utils import Singleton, debug 37 from utils import Singleton, debug
40 import version 38 import version
41 39
@@ -47,18 +45,13 @@ class Project(object): @@ -47,18 +45,13 @@ class Project(object):
47 def __init__(self): 45 def __init__(self):
48 # Patient/ acquistion information 46 # Patient/ acquistion information
49 self.name = '' 47 self.name = ''
50 - self.dicom_sample = ''  
51 self.modality = '' 48 self.modality = ''
52 self.original_orientation = '' 49 self.original_orientation = ''
53 self.window = '' 50 self.window = ''
54 self.level = '' 51 self.level = ''
55 52
56 - # Original imagedata (shouldn't be changed)  
57 - self.imagedata = ''  
58 -  
59 # Masks (vtkImageData) 53 # Masks (vtkImageData)
60 self.mask_dict = {} 54 self.mask_dict = {}
61 - self.last_mask_index = 0  
62 55
63 # Surfaces are (vtkPolyData) 56 # Surfaces are (vtkPolyData)
64 self.surface_dict = {} 57 self.surface_dict = {}
@@ -107,7 +100,6 @@ class Project(object): @@ -107,7 +100,6 @@ class Project(object):
107 output 100 output
108 @ index: index of item that was inserted 101 @ index: index of item that was inserted
109 """ 102 """
110 - #self.last_mask_index = mask.index  
111 index = len(self.mask_dict) 103 index = len(self.mask_dict)
112 self.mask_dict[index] = mask 104 self.mask_dict[index] = mask
113 return index 105 return index