From 203f403de2d015c8590a6845d62892a825bd57a8 Mon Sep 17 00:00:00 2001 From: tfmoraes Date: Tue, 26 Jan 2010 19:14:23 +0000 Subject: [PATCH] STL: removed certain prints --- invesalius/control.py | 14 ++++++++------ invesalius/data/imagedata_utils.py | 51 +++++++++++++++++++++++++++++++++++++++------------ invesalius/data/slice_.py | 4 ++-- invesalius/data/viewer_slice.py | 35 +---------------------------------- invesalius/data/viewer_volume.py | 11 ++++------- invesalius/data/volume.py | 8 -------- invesalius/gui/default_viewers.py | 4 ---- invesalius/gui/dialogs.py | 6 +++--- invesalius/gui/dicom_preview_panel.py | 36 +++++++----------------------------- invesalius/gui/frame.py | 15 ++++++--------- invesalius/gui/import_panel.py | 14 ++------------ invesalius/gui/task_slice.py | 3 +++ invesalius/gui/widgets/gradient.py | 1 + invesalius/invesalius.py | 3 ++- invesalius/project.py | 11 +---------- invesalius/reader/dicom.py | 1 - invesalius/reader/dicom_grouper.py | 5 +++++ invesalius/reader/dicom_reader.py | 2 ++ invesalius/session.py | 13 ++++++------- invesalius/utils.py | 10 +++++----- 20 files changed, 97 insertions(+), 150 deletions(-) diff --git a/invesalius/control.py b/invesalius/control.py index 94ffd5c..ebcf206 100755 --- a/invesalius/control.py +++ b/invesalius/control.py @@ -36,6 +36,8 @@ import reader.dicom_reader as dcm import reader.analyze_reader as analyze import session as ses +from utils import debug + DEFAULT_THRESH_MODE = 0 class Controller(): @@ -147,7 +149,7 @@ class Controller(): def ShowDialogCloseProject(self): - utils.debug("ShowDialogCloseProject") + debug("ShowDialogCloseProject") session = ses.Session() st = session.project_status if st == const.PROJ_CLOSE: @@ -156,18 +158,18 @@ class Controller(): if (st == const.PROJ_NEW) or (st == const.PROJ_CHANGE): answer = dialog.SaveChangesDialog(filename) if not answer: - utils.debug("Close without changes") + debug("Close without changes") self.CloseProject() ps.Publisher().sendMessage("Enable state project", False) ps.Publisher().sendMessage('Set project name') elif answer == 1: self.ShowDialogSaveProject() - utils.debug("Save changes and close") + debug("Save changes and close") self.CloseProject() ps.Publisher().sendMessage("Enable state project", False) ps.Publisher().sendMessage('Set project name') elif answer == -1: - utils.debug("Cancel") + debug("Cancel") else: self.CloseProject() ps.Publisher().sendMessage("Enable state project", False) @@ -307,7 +309,7 @@ class Controller(): self.CreateAnalyzeProject(imagedata) # OPTION 3: Nothing... else: - utils.debug("No medical images found on given directory") + debug("No medical images found on given directory") return self.LoadProject() ps.Publisher().sendMessage("Enable state project", True) @@ -392,7 +394,7 @@ class Controller(): interval += 1 filelist = dicom_group.GetFilenameList()[::interval] if not filelist: - utils.debug("Not used the IPPSorter") + debug("Not used the IPPSorter") filelist = [i.image.file for i in dicom_group.GetHandSortedList()[::interval]] diff --git a/invesalius/data/imagedata_utils.py b/invesalius/data/imagedata_utils.py index b83b539..1942a4e 100644 --- a/invesalius/data/imagedata_utils.py +++ b/invesalius/data/imagedata_utils.py @@ -227,7 +227,7 @@ def CreateImageData(filelist, zspacing, size, bits): x,y = size px, py = utils.PredictingMemory(len(filelist), x, y, bits) - print "Image Resized to >>>", px, "x", py + utils.debug("Image Resized to >>> %f x %f" % (px, py)) if (x == px) and (y == py): const.REDUCE_IMAGEDATA_QUALITY = 0 @@ -294,35 +294,61 @@ def CreateImageData(filelist, zspacing, size, bits): return imagedata -""" class ImageCreator: def __init__(self): - ps.Publisher().sendMessage("Cancel imagedata load", self.CancelImageDataLoad) + self.running = True + ps.Publisher().subscribe(self.CancelImageDataLoad, "Cancel DICOM load") def CancelImageDataLoad(self, evt_pusub): - self.running = evt_pusub.data + utils.debug("Canceling") + self.running = False + + def CreateImageData(self, filelist, zspacing, size, bits): + message = _("Generating multiplanar visualization...") + + if not const.VTK_WARNING: + log_path = os.path.join(const.LOG_FOLDER, 'vtkoutput.txt') + fow = vtk.vtkFileOutputWindow() + fow.SetFileName(log_path) + ow = vtk.vtkOutputWindow() + ow.SetInstance(fow) + + x,y = size + px, py = utils.PredictingMemory(len(filelist), x, y, bits) + utils.debug("Image Resized to >>> %f x %f" % (px, py)) + + if (x == px) and (y == py): + const.REDUCE_IMAGEDATA_QUALITY = 0 + else: + const.REDUCE_IMAGEDATA_QUALITY = 1 - def CreateImageData(filelist, zspacing): - message = "Generating multiplanar visualization..." if not(const.REDUCE_IMAGEDATA_QUALITY): - update_progress= vtk_utils.ShowProgress(1) + update_progress= vtk_utils.ShowProgress(1, dialog_type = "ProgressDialog") array = vtk.vtkStringArray() for x in xrange(len(filelist)): + if not self.running: + return False array.InsertValue(x,filelist[x]) + if not self.running: + return False reader = vtkgdcm.vtkGDCMImageReader() reader.SetFileNames(array) reader.AddObserver("ProgressEvent", lambda obj,evt: update_progress(reader,message)) reader.Update() + if not self.running: + reader.AbortExecuteOn() + return False # The zpacing is a DicomGroup property, so we need to set it imagedata = vtk.vtkImageData() imagedata.DeepCopy(reader.GetOutput()) spacing = imagedata.GetSpacing() imagedata.SetSpacing(spacing[0], spacing[1], zspacing) else: + update_progress= vtk_utils.ShowProgress(2*len(filelist), dialog_type = "ProgressDialog") @@ -330,11 +356,14 @@ class ImageCreator: appender = vtk.vtkImageAppend() appender.SetAppendAxis(2) #Define Stack in Z + # Reformat each slice for x in xrange(len(filelist)): # TODO: We need to check this automatically according # to each computer's architecture # If the resolution of the matrix is too large + if not self.running: + return False reader = vtkgdcm.vtkGDCMImageReader() reader.SetFileName(filelist[x]) reader.AddObserver("ProgressEvent", lambda obj,evt: @@ -342,15 +371,15 @@ class ImageCreator: reader.Update() #Resample image in x,y dimension - - slice_imagedata = ResampleImage2D(reader.GetOutput(), 256, update_progress) - + slice_imagedata = ResampleImage2D(reader.GetOutput(), px, py, update_progress) #Stack images in Z axes appender.AddInput(slice_imagedata) #appender.AddObserver("ProgressEvent", lambda obj,evt:update_progress(appender)) appender.Update() # The zpacing is a DicomGroup property, so we need to set it + if not self.running: + return False imagedata = vtk.vtkImageData() imagedata.DeepCopy(appender.GetOutput()) spacing = imagedata.GetSpacing() @@ -362,5 +391,3 @@ class ImageCreator: imagedata.Update() return imagedata -""" - diff --git a/invesalius/data/slice_.py b/invesalius/data/slice_.py index a8f9ee9..6e8403f 100644 --- a/invesalius/data/slice_.py +++ b/invesalius/data/slice_.py @@ -581,8 +581,8 @@ class Slice(object): mask = mask_dict[key] # update gui related to mask - print "__load_masks" - print 'THRESHOLD_RANGE', mask.threshold_range + utils.debug("__load_masks") + utils.debug('THRESHOLD_RANGE %s', mask.threshold_range) ps.Publisher().sendMessage('Add mask', (mask.index, mask.name, diff --git a/invesalius/data/viewer_slice.py b/invesalius/data/viewer_slice.py index f35aab1..a66a585 100755 --- a/invesalius/data/viewer_slice.py +++ b/invesalius/data/viewer_slice.py @@ -35,6 +35,7 @@ import data.slice_ as sl import data.vtk_utils as vtku import project import slice_data as sd +import utils ID_TO_TOOL_ITEM = {} STR_WL = "WL: %d WW: %d" @@ -286,14 +287,12 @@ class Viewer(wx.Panel): style.AddObserver("RightButtonPressEvent", self.QuitRubberBandZoom) def OnRightClick(self, evt, obj): - print "OnRightClick" self.last_position_mouse_move = \ self.interactor.GetLastEventPosition() self.right_pressed = 1 def OnReleaseRightButton(self, evt, obj): - print "OnReleaseRightButton" self.right_pressed = 0 ps.Publisher().sendMessage('Update slice viewer') @@ -301,7 +300,6 @@ class Viewer(wx.Panel): self.left_pressed = 1 def OnZoomLeftClick(self, evt, obj): - print "OnZoomLeftClick" evt.StartDolly() def OnReleaseLeftButton(self, evt, obj): @@ -383,12 +381,10 @@ class Viewer(wx.Panel): def OnZoomMoveLeft(self, evt, obj): if self.left_pressed: - print "OnZoomMoveLeft:" evt.Dolly() evt.OnRightButtonDown() def OnVtkRightRelease(self, evt, obj): - print "On VTK" evt.OnRightButtonUp() @@ -688,12 +684,10 @@ class Viewer(wx.Panel): if (self.right_pressed): - print "OnZoomMoveRight" evt.Dolly() evt.OnRightButtonDown() def OnZoomRightClick(self, evt, obj): - print "OnZoomRightClick" evt.StartDolly() @@ -752,8 +746,6 @@ class Viewer(wx.Panel): coord[index] = extent_max[index] elif coord[index] < extent_min[index]: coord[index] = extent_min[index] - #print "New coordinate: ", coord - return coord def get_coordinate_cursor(self): @@ -854,9 +846,7 @@ class Viewer(wx.Panel): "SAGITAL": const.SAGITAL} if id == dict[self.orientation]: - print "ok" if filetype == const.FILETYPE_POV: - print 1 renwin = self.interactor.GetRenderWindow() image = vtk.vtkWindowToImageFilter() image.SetInput(renwin) @@ -866,7 +856,6 @@ class Viewer(wx.Panel): writer.Write() return else: - print 2 #Use tiling to generate a large rendering. image = vtk.vtkRenderLargeImage() image.SetInput(self.ren) @@ -877,19 +866,14 @@ class Viewer(wx.Panel): # write image file if (filetype == const.FILETYPE_BMP): - print 3 writer = vtk.vtkBMPWriter() elif (filetype == const.FILETYPE_JPG): - print 4 writer = vtk.vtkJPEGWriter() elif (filetype == const.FILETYPE_PNG): - print 5 writer = vtk.vtkPNGWriter() elif (filetype == const.FILETYPE_PS): - print 6 writer = vtk.vtkPostScriptWriter() elif (filetype == const.FILETYPE_TIF): - print 7 writer = vtk.vtkTIFFWriter() filename = "%s.tif"%filename.strip(".tif") @@ -904,11 +888,9 @@ class Viewer(wx.Panel): ps.Publisher().sendMessage('End busy cursor') def OnShowText(self, pubsub_evt): - print "OnShowText" self.ShowTextActors() def OnHideText(self, pubsub_evt): - print "OnHideText" self.HideTextActors() @@ -939,7 +921,6 @@ class Viewer(wx.Panel): def ChangeBrushOperation(self, pubsub_evt): - #print pubsub_evt.data self._brush_cursor_op = pubsub_evt.data def __bind_events_wx(self): @@ -1005,8 +986,6 @@ class Viewer(wx.Panel): if i == self.layout[0] - 1: style = style | sd.BORDER_RIGHT - print "->Style", style - slice_data.SetBorderStyle(style) n += 1 @@ -1130,21 +1109,10 @@ class Viewer(wx.Panel): extent = slice_data.actor.GetDisplayExtent() cam = slice_data.renderer.GetActiveCamera() - #print - #print self.orientation - #print x, y, z - #print actor_bound - #print "ViewUp", cam.GetViewUp() - #print "Position", cam.GetPosition() - #print "Orientation", cam.GetOrientation() - #print "Focal Point", cam.GetFocalPoint() - vCamera = numpy.array(cam.GetPosition()) - numpy.array(cam.GetFocalPoint()) n_vCamera = vCamera / numpy.linalg.norm(vCamera) - #print "Normalized", n_vCamera pos = [j + 0.01 * i for i,j in zip(n_vCamera, (x, y, z))] - #print "posicao", pos #yz = [x + abs(x * 0.001), y, z] #xz = [x, y - abs(y * 0.001), z] @@ -1174,7 +1142,6 @@ class Viewer(wx.Panel): # elif orientation == "CORONAL": # pos[1] -= abs(pos[1] * 0.001) - #print ">POS", pos #pos = [x, y, z] #if orientation == "AXIAL": diff --git a/invesalius/data/viewer_volume.py b/invesalius/data/viewer_volume.py index c54df80..a28f24e 100755 --- a/invesalius/data/viewer_volume.py +++ b/invesalius/data/viewer_volume.py @@ -25,10 +25,10 @@ from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor import wx.lib.pubsub as ps import constants as const -import project as prj import data.vtk_utils as vtku -from gui.widgets.clut_raycasting import CLUTRaycastingWidget +import project as prj import style as st +import utils class Viewer(wx.Panel): def __init__(self, parent): @@ -274,7 +274,6 @@ class Viewer(wx.Panel): # Check each event available for each mode for event in action[state]: - print event # Bind event style.AddObserver(event,action[state][event]) @@ -439,14 +438,14 @@ class Viewer(wx.Panel): self.interactor.Render() def RemoveActor(self, pubsub_evt): - print "RemoveActor" + utils.debug("RemoveActor") actor = pubsub_evt.data ren = self.ren ren.RemoveActor(actor) self.interactor.Render() def RemoveAllActor(self, pubsub_evt): - print "RemoveAllActor" + utils.debug("RemoveAllActor") self.ren.RemoveAllProps() ps.Publisher().sendMessage('Render volume viewer') @@ -503,7 +502,6 @@ class Viewer(wx.Panel): self.interactor.Render() def ShowOrientationCube(self): - print "ORIENTATION CUBE!" cube = vtk.vtkAnnotatedCubeActor() cube.GetXMinusFaceProperty().SetColor(1,0,0) cube.GetXPlusFaceProperty().SetColor(1,0,0) @@ -696,7 +694,6 @@ class SlicePlane: a.SetBackfaceCulling(0) c = self.plane_x.GetTexture() c.SetRestrictPowerOf2ImageSmaller(1) - #print dir(a) elif(self.original_orientation == const.SAGITAL): if(label == "Axial"): diff --git a/invesalius/data/volume.py b/invesalius/data/volume.py index 91f5918..e385d83 100755 --- a/invesalius/data/volume.py +++ b/invesalius/data/volume.py @@ -418,17 +418,13 @@ class Volume(): def SetTypeRaycasting(self): if self.volume_mapper.IsA("vtkFixedPointVolumeRayCastMapper"): if self.config.get('MIP', False): - print "MIP" self.volume_mapper.SetBlendModeToMaximumIntensity() else: - print "Composite" self.volume_mapper.SetBlendModeToComposite() else: if self.config.get('MIP', False): - print "MIP" raycasting_function = vtk.vtkVolumeRayCastMIPFunction() else: - print "Composite" raycasting_function = vtk.vtkVolumeRayCastCompositeFunction() raycasting_function.SetCompositeMethodToInterpolateFirst() self.volume_mapper.SetVolumeRayCastFunction(raycasting_function) @@ -551,20 +547,16 @@ class Volume(): (volume, colour, (self.ww, self.wl))) def OnEnableTool(self, pubsub_evt): - print "OnEnableTool" tool_name, enable = pubsub_evt.data if tool_name == _("Cut plane"): if self.plane: if enable: - print "Enable" self.plane_on = True self.plane.Enable() else: - print "Disable" self.plane_on = False self.plane.Disable() else: - print "Enable" self.final_imagedata.Update() self.plane_on = True self.plane = CutPlane(self.final_imagedata, diff --git a/invesalius/gui/default_viewers.py b/invesalius/gui/default_viewers.py index 1ff6cdb..3260286 100755 --- a/invesalius/gui/default_viewers.py +++ b/invesalius/gui/default_viewers.py @@ -262,7 +262,6 @@ class VolumeInteraction(wx.Panel): self.aui_manager.Update() def OnPointChanged(self, evt): - print "Removed" ps.Publisher.sendMessage('Set raycasting refresh', None) ps.Publisher.sendMessage('Set raycasting curve', evt.GetCurve()) ps.Publisher().sendMessage('Render volume viewer') @@ -278,7 +277,6 @@ class VolumeInteraction(wx.Panel): def OnSetRaycastPreset(self, evt_pubsub): preset = project.Project().raycasting_preset - print "Preset >>>", preset p = self.aui_manager.GetPane(self.clut_raycasting) self.clut_raycasting.SetRaycastPreset(preset) if self.clut_raycasting.to_draw_points and \ @@ -542,13 +540,11 @@ class VolumeToolPanel(wx.Panel): # if i is not item: # i.Check(0) if not TOOL_STATE[id]: - print "item is checked" ps.Publisher().sendMessage('Enable raycasting tool', [ID_TO_TOOL[id],1]) TOOL_STATE[id] = True item.Check(1) else: - print "item is not checked" ps.Publisher().sendMessage('Enable raycasting tool', [ID_TO_TOOL[id],0]) TOOL_STATE[id] = False diff --git a/invesalius/gui/dialogs.py b/invesalius/gui/dialogs.py index 9981e6b..a96e1b7 100644 --- a/invesalius/gui/dialogs.py +++ b/invesalius/gui/dialogs.py @@ -28,6 +28,7 @@ import wx.lib.pubsub as ps import constants as const import project as proj import session as ses +import utils class NumberDialog(wx.Dialog): @@ -275,7 +276,7 @@ def SaveChangesDialog__Old(filename): def ImportEmptyDirectory(dirpath): - msg = _("%s is an empty directory.") % dirpath + msg = _("%s is an empty directory.") % dirpath.decode("utf-8") if sys.platform == 'darwin': dlg = wx.MessageDialog(None, "", msg, @@ -532,7 +533,7 @@ def ExportPicture(type_=""): 4: const.FILETYPE_POV, 5: const.FILETYPE_TIF} - print "ExportPicture" + utils.debug("ExportPicture") project = proj.Project() if sys.platform == 'win32': @@ -554,7 +555,6 @@ def ExportPicture(type_=""): filetype = INDEX_TO_TYPE[filetype_index] extension = INDEX_TO_EXTENSION[filetype_index] filename = dlg.GetPath() - print "filename", filename if sys.platform != 'win32': if filename.split(".")[-1] != extension: filename = filename + "."+ extension diff --git a/invesalius/gui/dicom_preview_panel.py b/invesalius/gui/dicom_preview_panel.py index b55fa22..bbdb49d 100755 --- a/invesalius/gui/dicom_preview_panel.py +++ b/invesalius/gui/dicom_preview_panel.py @@ -32,6 +32,7 @@ from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor import constants as const from reader import dicom_reader import data.vtk_utils as vtku +import utils NROWS = 3 NCOLS = 6 @@ -107,7 +108,6 @@ class DicomInfo(object): if self._preview: return self._preview else: - print "First time!" colorer = vtk.vtkImageMapToWindowLevelColors() colorer.SetInput(self.dicom.image.imagedata) colorer.SetWindow(float(self.dicom.image.window)) @@ -256,7 +256,6 @@ class Preview(wx.Panel): if not self.select_on: #c = wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DHILIGHT) c = wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE) - print c self.SetBackgroundColour(c) def OnLeave(self, evt): @@ -265,7 +264,6 @@ class Preview(wx.Panel): self.SetBackgroundColour(c) def OnSelect(self, evt): - print "OnSelect" self.select_on = True self.dicom_info.selected = True ##c = wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNHIGHLIGHT) @@ -287,7 +285,6 @@ class Preview(wx.Panel): my_evt.SetSelectedID(self.dicom_info.id) my_evt.SetItemData(self.dicom_info.dicom) my_evt.SetEventObject(self) - print "patient", self.dicom_info.dicom.patient self.GetEventHandler().ProcessEvent(my_evt) def OnSize(self, evt): @@ -370,7 +367,6 @@ class DicomPreviewSeries(wx.Panel): self.Bind(wx.EVT_MOUSEWHEEL, self.OnWheel) def OnSelect(self, evt): - print dir(evt) my_evt = SerieEvent(myEVT_CLICK_SERIE, self.GetId()) my_evt.SetSelectedID(evt.GetSelectID()) my_evt.SetItemData(evt.GetItemData()) @@ -379,7 +375,6 @@ class DicomPreviewSeries(wx.Panel): self.selected_dicom.selected = self.selected_dicom is \ evt.GetEventObject().dicom_info self.selected_panel.select_on = self.selected_panel is evt.GetEventObject() - print "Unselecting a panel", self.selected_panel.select_on self.selected_panel.Select() self.selected_panel = evt.GetEventObject() self.selected_dicom = self.selected_panel.dicom_info @@ -416,7 +411,7 @@ class DicomPreviewSeries(wx.Panel): try: self.previews[-i-1].Hide() except IndexError: - #print "doesn't exist!" + utils.debug("doesn't exist!") pass self.nhidden_last_display = final-len(self.files) else: @@ -425,16 +420,14 @@ class DicomPreviewSeries(wx.Panel): try: self.previews[-i-1].Show() except IndexError: - #print "doesn't exist!" + utils.debug("doesn't exist!") pass self.nhidden_last_display = 0 for f, p in zip(self.files[initial:final], self.previews): - #print "f", f p.SetDicomToPreview(f) if f.selected: self.selected_panel = p - #p.interactor.Render() for f, p in zip(self.files[initial:final], self.previews): p.Show() @@ -449,7 +442,6 @@ class DicomPreviewSeries(wx.Panel): self._display_previews() def OnWheel(self, evt): - print "OnWheel" d = evt.GetWheelDelta() / evt.GetWheelRotation() self.scroll.SetThumbPosition(self.scroll.GetThumbPosition() - d) self.OnScroll() @@ -506,7 +498,7 @@ class DicomPreviewSlice(wx.Panel): self.Bind(wx.EVT_MOUSEWHEEL, self.OnWheel) def SetDicomDirectory(self, directory): - print "Setting Dicom Directory", directory + utils.debug("Setting Dicom Directory %s" % directory) self.directory = directory self.series = dicom_reader.GetSeries(directory)[0] @@ -561,16 +553,13 @@ class DicomPreviewSlice(wx.Panel): def _display_previews(self): initial = self.displayed_position * NCOLS final = initial + NUM_PREVIEWS - print "len:", len(self.files) if len(self.files) < final: for i in xrange(final-len(self.files)): - print "hide ", i try: self.previews[-i-1].Hide() except IndexError: - #print "doesn't exist!" - pass + utils.debug("doesn't exist!") self.nhidden_last_display = final-len(self.files) else: if self.nhidden_last_display: @@ -578,8 +567,7 @@ class DicomPreviewSlice(wx.Panel): try: self.previews[-i-1].Show() except IndexError: - #print "doesn't exist!" - pass + utils.debug("doesn't exist!") self.nhidden_last_display = 0 for f, p in zip(self.files[initial:final], self.previews): @@ -592,7 +580,6 @@ class DicomPreviewSlice(wx.Panel): p.Show() def OnPreviewClick(self, evt): - print "Hey man, you've clicked over me" my_evt = SerieEvent(myEVT_CLICK_SLICE, self.GetId()) my_evt.SetSelectedID(evt.GetSelectID()) my_evt.SetItemData(evt.GetItemData()) @@ -601,7 +588,6 @@ class DicomPreviewSlice(wx.Panel): self.selected_dicom.selected = self.selected_dicom is \ evt.GetEventObject().dicom_info self.selected_panel.select_on = self.selected_panel is evt.GetEventObject() - print "Unselecting a panel", self.selected_panel.select_on self.selected_panel.Select() self.selected_panel = evt.GetEventObject() self.selected_dicom = self.selected_panel.dicom_info @@ -617,7 +603,6 @@ class DicomPreviewSlice(wx.Panel): self._display_previews() def OnWheel(self, evt): - print "OnWheel" d = evt.GetWheelDelta() / evt.GetWheelRotation() self.scroll.SetThumbPosition(self.scroll.GetThumbPosition() - d) self.OnScroll() @@ -747,7 +732,7 @@ class SingleImagePreview(wx.Panel): #TODO: temporary fix necessary in the Windows XP 64 Bits #BUG in wxWidgets http://trac.wxwidgets.org/ticket/10896 except(wx._core.PyAssertionError): - print "wx._core.PyAssertionError" + utils.debug("wx._core.PyAssertionError") finally: wx.CallAfter(self.OnRun) @@ -757,12 +742,10 @@ class SingleImagePreview(wx.Panel): self.nimages = len(self.dicom_list) # GUI self.slider.SetMax(self.nimages-1) - print self.nimages self.slider.SetValue(0) self.ShowSlice() def ShowSlice(self, index = 0): - print "ShowSlice" dicom = self.dicom_list[index] # UPDATE GUI @@ -773,7 +756,6 @@ class SingleImagePreview(wx.Panel): ## Text related to slice position value1 = STR_SPC %(dicom.image.spacing[2]) value2 = STR_LOCAL %(dicom.image.position[2]) - print "Este eh o meu tipo", type(value1) value = "%s\n%s" %(value1, value2) self.text_image_location.SetValue(value) @@ -802,7 +784,3 @@ class SingleImagePreview(wx.Panel): # Setting slider position self.slider.SetValue(index) - - def __del__(self): - print "---------> morri" - diff --git a/invesalius/gui/frame.py b/invesalius/gui/frame.py index 8c21196..4aeb568 100755 --- a/invesalius/gui/frame.py +++ b/invesalius/gui/frame.py @@ -32,6 +32,7 @@ import gui.dialogs as dlg import import_panel as imp import project as prj import session as ses +import utils # Object toolbar #OBJ_TOOLS = [ID_ZOOM, ID_ZOOM_SELECT, ID_ROTATE, ID_MOVE, @@ -200,7 +201,7 @@ class Frame(wx.Frame): aui_manager.Update() def HideImportPanel(self, evt_pubsub): - print "HideImportPanel" + utils.debug("HideImportPanel") aui_manager = self.aui_manager aui_manager.GetPane("Import").Show(0) aui_manager.GetPane("Data").Show(0) @@ -208,7 +209,7 @@ class Frame(wx.Frame): aui_manager.Update() def ShowContentPanel(self, evt_pubsub): - print "ShowContentPanel" + utils.debug("ShowContentPanel") ps.Publisher().sendMessage("Set layout button full") aui_manager = self.aui_manager aui_manager.GetPane("Import").Show(0) @@ -264,16 +265,15 @@ class Frame(wx.Frame): ps.Publisher().sendMessage('Show save dialog', False) def CloseProject(self): - print "CloseProject" + utils.debug("CloseProject") ps.Publisher().sendMessage('Close Project') def OnExit(self, event): - print "OnExit" self.Exit() event.Skip() def Exit(self): - print "Exit" + utils.debug("Exit") ps.Publisher().sendMessage('Close Project') def ShowTask(self, pubsub_evt): @@ -284,7 +284,6 @@ class Frame(wx.Frame): self.aui_manager.GetPane("Tasks").Hide() self.aui_manager.Update() - #def OnClose(self): # # TODO: implement this, based on wx.Demo # pass @@ -387,9 +386,7 @@ class MenuBar(wx.MenuBar): self.SetStateProjectClose() def OnEnableState(self, pubsub_evt): - print "----- OnEnableState" state = pubsub_evt.data - print "state", state if state: self.SetStateProjectOpen() else: @@ -473,7 +470,7 @@ class StatusBar(wx.StatusBar): #TODO: temporary fix necessary in the Windows XP 64 Bits #BUG in wxWidgets http://trac.wxwidgets.org/ticket/10896 except(wx._core.PyAssertionError): - print "wx._core.PyAssertionError" + utils.debug("wx._core.PyAssertionError") def UpdateStatusLabel(self, pubsub_evt): label = pubsub_evt.data diff --git a/invesalius/gui/import_panel.py b/invesalius/gui/import_panel.py index ebfa8d3..e23d256 100644 --- a/invesalius/gui/import_panel.py +++ b/invesalius/gui/import_panel.py @@ -152,10 +152,10 @@ class InnerPanel(wx.Panel): self.image_panel.SetSerie(group) def OnSelectSlice(self, evt): - print "You've selected the slice", evt.GetSelectID() + pass def OnSelectPatient(self, evt): - print "You've selected the patient", evt.GetSelectID() + pass def OnDblClickTextPanel(self, evt): group = evt.GetItemData() @@ -286,10 +286,7 @@ class TextPanel(wx.Panel): dicom.acquisition.serie_number)] = child tree.Expand(self.root) - tree.SelectItem(parent_select) - print "parent select", parent_select - tree.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate) tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged) @@ -372,12 +369,9 @@ class ImagePanel(wx.Panel): self.text_panel.Bind(EVT_SELECT_SLICE, self.OnSelectSlice) def OnSelectSerie(self, evt): - print "Hi, You selected Serie" evt.Skip() def OnSelectSlice(self, evt): - print "Hi, You selected slice" - print "Selected ID", evt.GetSelectID() self.image_panel.dicom_preview.ShowSlice(evt.GetSelectID()) evt.Skip() @@ -437,7 +431,6 @@ class SeriesPanel(wx.Panel): self.Update() def OnSelectSerie(self, evt): - print "Hey, You selected a serie" serie = evt.GetItemData() data = evt.GetItemData() @@ -454,8 +447,6 @@ class SeriesPanel(wx.Panel): self.Update() def OnSelectSlice(self, evt): - print "Hey, Ho, Let's go", evt.GetSelectID() - my_evt = SelectEvent(myEVT_SELECT_SLICE, self.GetId()) my_evt.SetSelectedID(evt.GetSelectID()) my_evt.SetItemData(evt.GetItemData()) @@ -481,7 +472,6 @@ class SlicePanel(wx.Panel): def __init_gui(self): self.SetBackgroundColour((255,255,255)) - print "----------------------------" self.dicom_preview = dpp.SingleImagePreview(self) sizer = wx.BoxSizer(wx.VERTICAL) diff --git a/invesalius/gui/task_slice.py b/invesalius/gui/task_slice.py index 1cf41c1..58826f2 100644 --- a/invesalius/gui/task_slice.py +++ b/invesalius/gui/task_slice.py @@ -408,6 +408,7 @@ class MaskProperties(wx.Panel): def SetThresholdModes(self, pubsub_evt): (thresh_modes_names, default_thresh) = pubsub_evt.data + print pubsub_evt.data self.combo_thresh.SetItems(thresh_modes_names) if isinstance(default_thresh, int): self.combo_thresh.SetSelection(default_thresh) @@ -417,10 +418,12 @@ class MaskProperties(wx.Panel): self.combo_thresh.SetSelection(3) thresh_min, thresh_max = default_thresh + print "Este e threshold", thresh_min, thresh_max self.gradient.SetMinValue(thresh_min) self.gradient.SetMaxValue(thresh_max) def SetThresholdBounds(self, pubsub_evt): + print ">>>Threshold Limits", pubsub_evt.data thresh_min = pubsub_evt.data[0] thresh_max = pubsub_evt.data[1] self.gradient.SetMinRange(thresh_min) diff --git a/invesalius/gui/widgets/gradient.py b/invesalius/gui/widgets/gradient.py index 8adeec8..f74e9ec 100755 --- a/invesalius/gui/widgets/gradient.py +++ b/invesalius/gui/widgets/gradient.py @@ -582,6 +582,7 @@ class GradientSlider(wx.Panel): self.GradientPanel.Refresh() def SetMaxRange(self, value): + print "Setting max range ", value self.SliderData.SetMaxRange(value) self.SpinMin.SetMax(value) self.SpinMax.SetMax(value) diff --git a/invesalius/invesalius.py b/invesalius/invesalius.py index 1a0443b..0713fd2 100755 --- a/invesalius/invesalius.py +++ b/invesalius/invesalius.py @@ -25,6 +25,7 @@ import sys import gui.language_dialog as lang_dlg import i18n from session import Session +import utils # TODO: This should be called during installation @@ -179,7 +180,7 @@ def parse_comand_line(): def print_events(data): - print data.topic + utils.debug(data.topic) def main(): application = InVesalius(0) diff --git a/invesalius/project.py b/invesalius/project.py index c0e394a..fd0f475 100755 --- a/invesalius/project.py +++ b/invesalius/project.py @@ -153,7 +153,7 @@ class Project(object): elif type_ == "CT": self.threshold_modes = self.presets.thresh_ct else: - print "Different Acquisition Modality!!!" + utils.debug("Different Acquisition Modality!!!") self.modality = type_ def SetRaycastPreset(self, label): @@ -187,13 +187,11 @@ class Project(object): for index in self.mask_dict: masks[str(index)] = {'#mask':\ self.mask_dict[index].SavePlist(filename_tmp).decode('utf-8')} - print index surfaces = {} for index in self.surface_dict: surfaces[str(index)] = {'#surface':\ self.surface_dict[index].SavePlist(filename_tmp)} - print index project['surface_dict'] = surfaces project['mask_dict'] = masks @@ -219,15 +217,8 @@ class Project(object): filelist = Extract(filename, tempfile.gettempdir()) main_plist = min(filter(lambda x: x.endswith('.plist'), filelist), key=lambda x: len(x)) - #print main_plist - print main_plist project = plistlib.readPlist(main_plist) - - #print "antes", self.__dict__ - - # Path were extracted project is dirpath = os.path.abspath(os.path.split(filelist[0])[0]) - #print "* dirpath", dirpath for key in project: if key == 'imagedata': diff --git a/invesalius/reader/dicom.py b/invesalius/reader/dicom.py index 252ac80..8bc5c1e 100644 --- a/invesalius/reader/dicom.py +++ b/invesalius/reader/dicom.py @@ -1821,7 +1821,6 @@ class Acquisition(object): def SetParser(self, parser): self.patient_orientation = parser.GetImagePatientOrientation() self.tilt = parser.GetAcquisitionGantryTilt() - self.serie_number = parser.GetImageSeriesNumber() self.id_study = parser.GetStudyID() self.modality = parser.GetAcquisitionModality() self.study_description = parser.GetStudyDescription() diff --git a/invesalius/reader/dicom_grouper.py b/invesalius/reader/dicom_grouper.py index 604b39b..3f14164 100644 --- a/invesalius/reader/dicom_grouper.py +++ b/invesalius/reader/dicom_grouper.py @@ -53,6 +53,8 @@ import gdcm +import utils + ORIENT_MAP = {"SAGITTAL":0, "CORONAL":1, "AXIAL":2, "OBLIQUE":2} @@ -209,12 +211,15 @@ class PatientGroup: # Check if Problem 1 occurs (n groups with 1 slice each) is_there_problem_1 = False + utils.debug("n slice %d" % self.nslices) + utils.debug("len %d" % len(self.groups_dict)) if (self.nslices == len(self.groups_dict)) and\ (self.nslices > 1): is_there_problem_1 = True # Fix Problem 1 if is_there_problem_1: + utils.debug("Problem1") self.groups_dict = self.FixProblem1(self.groups_dict) def GetGroups(self): diff --git a/invesalius/reader/dicom_reader.py b/invesalius/reader/dicom_reader.py index 0f17b6d..d1059fe 100644 --- a/invesalius/reader/dicom_reader.py +++ b/invesalius/reader/dicom_reader.py @@ -141,6 +141,8 @@ def yGetDicomGroups(directory, recursive=True, gui=True): for t in threads: t.join() + #TODO: Is this commented update necessary? + #grouper.Update() yield grouper.GetPatientsGroups() def GetDicomGroups(directory, recursive=True): diff --git a/invesalius/session.py b/invesalius/session.py index 4b84693..90eec01 100644 --- a/invesalius/session.py +++ b/invesalius/session.py @@ -4,7 +4,7 @@ from threading import Thread import time import wx.lib.pubsub as ps -from utils import Singleton +from utils import Singleton, debug import wx.lib.pubsub as ps @@ -46,7 +46,6 @@ class Session(object): # Recent projects list self.recent_projects = [(const.SAMPLE_DIR, "Cranium.inv3")] - print self.recent_projects self.last_dicom_folder = '' self.CreateSessionFile() @@ -57,7 +56,7 @@ class Session(object): def CloseProject(self): import constants as const - print "-- CloseProject" + debug("Session.CloseProject") self.project_path = () self.project_status = const.PROJ_CLOSE self.mode = const.MODE_RP @@ -65,7 +64,7 @@ class Session(object): def SaveProject(self, path=()): import constants as const - print "-- SaveProject" + debug("Session.SaveProject") self.project_status = const.PROJ_OPEN if path: self.project_path = path @@ -75,13 +74,13 @@ class Session(object): def ChangeProject(self): import constants as const - print "-- ChangeProject" + debug("Session.ChangeProject") self.project_status = const.PROJ_CHANGE def CreateProject(self, filename): import constants as const + debug("Session.CreateProject") ps.Publisher().sendMessage('Begin busy cursor') - print "-- CreateProject" # Set session info self.project_path = (self.tempdir, filename) self.project_status = const.PROJ_NEW @@ -90,7 +89,7 @@ class Session(object): def OpenProject(self, filepath): import constants as const - print "-- OpenProject" + debug("Session.OpenProject") # Add item to recent projects list item = (path, file) = os.path.split(filepath) self.__add_to_list(item) diff --git a/invesalius/utils.py b/invesalius/utils.py index 375eed3..4b71abe 100755 --- a/invesalius/utils.py +++ b/invesalius/utils.py @@ -25,10 +25,10 @@ import sys def debug(error_str): - from project import Project - proj = Project() - if proj.debug: - print >> stderr, str + from session import Session + session = Session() + if session.debug: + print >> sys.stderr, error_str #http://www.garyrobinson.net/2004/03/python_singleto.html @@ -67,7 +67,7 @@ class TwoWaysDictionary(dict): try: self.pop(key) except TypeError: - print "TwoWaysDictionary: no item" + debug("TwoWaysDictionary: no item") def get_value(self, key): """ -- libgit2 0.21.2