diff --git a/invesalius/gui/dicom_preview_panel.py b/invesalius/gui/dicom_preview_panel.py index 2849b23..5a70d46 100755 --- a/invesalius/gui/dicom_preview_panel.py +++ b/invesalius/gui/dicom_preview_panel.py @@ -70,14 +70,14 @@ class SingleImagePreview(wx.Panel): text_image_location.SetPosition(const.TEXT_POS_LEFT_DOWN) text_image_location.SetValue("localization") self.text_image_location = text_image_location - + value = "id\nprotocol" text_patient = vtku.Text() text_patient.SetJustificationToRight() text_patient.SetPosition(const.TEXT_POS_RIGHT_UP) text_patient.SetValue(value) self.text_patient = text_patient - + value = "date time\n Made in InVesalius" text_acquisition = vtku.Text() text_acquisition.SetJustificationToRight() @@ -130,7 +130,7 @@ class SingleImagePreview(wx.Panel): in_sizer = wx.BoxSizer(wx.HORIZONTAL) in_sizer.Add(slider, 1, wx.GROW|wx.EXPAND) in_sizer.Add(checkbox, 0) - + sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.panel, 20, wx.GROW|wx.EXPAND) sizer.Add(in_sizer, 1, wx.GROW|wx.EXPAND) @@ -165,9 +165,15 @@ class SingleImagePreview(wx.Panel): self.ShowSlice(pos) time.sleep(0.2) if self.ischecked: - wx.Yield() - wx.CallAfter(self.OnRun) - + try: + wx.Yield() + #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" + finally: + wx.CallAfter(self.OnRun) + def SetDicomGroup(self, group): self.dicom_list = group.GetHandSortedList() self.current_index = 0 @@ -181,7 +187,7 @@ class SingleImagePreview(wx.Panel): def ShowSlice(self, index = 0): print "ShowSlice" dicom = self.dicom_list[index] - + # UPDATE GUI ## Text related to size value = STR_SIZE %(dicom.image.size[0], dicom.image.size[1]) @@ -274,10 +280,10 @@ class Preview(wx.Panel): def _init_ui(self): - self.title = wx.StaticText(self, -1, "Image", + self.title = wx.StaticText(self, -1, "Image", style=wx.ALIGN_CENTER) - self.subtitle = wx.StaticText(self, -1, "Image", + self.subtitle = wx.StaticText(self, -1, "Image", style=wx.ALIGN_CENTER) self.panel = wx.Panel(self, -1) @@ -306,7 +312,7 @@ class Preview(wx.Panel): def _init_vtk(self): self.interactor = wxVTKRenderWindowInteractor(self.panel, -1, size=(70, 70)) - + sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self.interactor, 1, wx.GROW|wx.EXPAND) sizer.Fit(self.panel) @@ -316,7 +322,7 @@ class Preview(wx.Panel): self.panel.Layout() self.panel.Update() self.panel.SetAutoLayout(1) - + self.actor = vtk.vtkImageActor() self.render = vtk.vtkRenderer() @@ -351,7 +357,7 @@ class Preview(wx.Panel): self.title.Bind(wx.EVT_LEFT_DOWN, self.OnSelect) self.subtitle.Bind(wx.EVT_LEFT_DOWN, self.OnSelect) - + def OnEnter(self, evt): @@ -422,7 +428,7 @@ class Preview(wx.Panel): image = image_file[0] scale = image.GetScalarRange() - + cast = vtk.vtkImageMapToWindowLevelColors() #cast.SetShift(abs(scale[0])) #cast.SetScale(255.0/(scale[1] - scale[0])) @@ -438,7 +444,7 @@ class Preview(wx.Panel): window = 150 self.data = image_file[-1] - + cast.SetWindow(window) cast.SetLevel(level) self.actor.SetInput(cast.GetOutput()) @@ -485,7 +491,7 @@ class Preview(wx.Panel): if 1: - # Default values for the surronounding rectangle + # Default values for the surronounding rectangle # around a button rectWidth = self._nImgSize * 2 # To avoid the recangle to 'touch' the borders rectHeight = self._nImgSize * 2 @@ -497,7 +503,7 @@ class Preview(wx.Panel): # not ((style & INB_LEFT) or (style & INB_RIGHT)) and \ # not self._pagesInfoVec[i].GetCaption() == "" and \ # not (style & INB_SHOW_ONLY_IMAGES): - + #rectWidth = ((textWidth + nPadding * 2) > rectWidth and [nPadding * 2 + textWidth] or [rectWidth])[0] @@ -509,7 +515,7 @@ class Preview(wx.Panel): # If Pin button is used, consider its space as well (applicable for top/botton style) # since in the left/right, its size is already considered in 'pos' #pinBtnSize = (bUsePin and [20] or [0])[0] - + #if pos + rectWidth + pinBtnSize > clientSize: # break @@ -562,7 +568,7 @@ class DicomPreviewSeries(wx.Panel): self.SetAutoLayout(1) self.sizer = background_sizer - + self._Add_Panels_Preview() self._bind_events() @@ -579,7 +585,7 @@ class DicomPreviewSeries(wx.Panel): #def _show_shadow(self, preview): # preview.ShowShadow() - + def _bind_events(self): # When the user scrolls the window @@ -609,7 +615,7 @@ class DicomPreviewSeries(wx.Panel): group_list) self.files.append(info) n+=1 - + scroll_range = len(self.files)/NCOLS if scroll_range * NCOLS < len(self.files): scroll_range +=1 @@ -619,7 +625,7 @@ class DicomPreviewSeries(wx.Panel): def _display_previews(self): initial = self.displayed_position * NCOLS final = initial + MAX_VALUE - + if len(self.files) < final: for i in xrange(final-len(self.files)): try: @@ -686,7 +692,7 @@ class DicomPreview(wx.Panel): self.SetAutoLayout(1) self.sizer = background_sizer - + self._Add_Panels_Preview() self._bind_events() @@ -767,7 +773,7 @@ class DicomPreview(wx.Panel): initial = self.displayed_position * NCOLS final = initial + MAX_VALUE print "len:", len(self.files) - + if len(self.files) < final: for i in xrange(final-len(self.files)): print "hide ", i diff --git a/invesalius/gui/frame.py b/invesalius/gui/frame.py index 4749c63..1c6ee9d 100755 --- a/invesalius/gui/frame.py +++ b/invesalius/gui/frame.py @@ -34,7 +34,7 @@ import project as prj import session as ses # Object toolbar -#OBJ_TOOLS = [ID_ZOOM, ID_ZOOM_SELECT, ID_ROTATE, ID_MOVE, +#OBJ_TOOLS = [ID_ZOOM, ID_ZOOM_SELECT, ID_ROTATE, ID_MOVE, #ID_CONTRAST] = [wx.NewId() for number in range(5)] #MODE_BY_ID = {ID_ZOOM: const.STATE_ZOOM, # ID_ZOOM_SELECT: const.STATE_ZOOM_SL, @@ -111,7 +111,7 @@ class Frame(wx.Frame): self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_MENU, self.OnMenuClick) #self.Bind(wx.EVT_CLOSE, self.OnExit) - + def __init_aui(self): # Tell aui_manager to manage this frame @@ -127,7 +127,7 @@ class Frame(wx.Frame): #CloseButton(False).Floatable(False). #Layer(1).Left().MaximizeButton(False).Name("Task"). #Position(0)) - + aui_manager.AddPane(viewers.Panel(self), wx.aui.AuiPaneInfo(). Caption("Data panel").CaptionVisible(False). @@ -214,12 +214,12 @@ class Frame(wx.Frame): aui_manager = self.aui_manager aui_manager.GetPane("Data").Show(0) aui_manager.GetPane("Tasks").Show(1) - aui_manager.Update() + aui_manager.Update() def OnSize(self, evt): ps.Publisher().sendMessage(('ProgressBar Reposition')) evt.Skip() - + def OnMenuClick(self, evt): id = evt.GetId() session = ses.Session() @@ -234,7 +234,7 @@ class Frame(wx.Frame): else: self.SaveProject() elif id == const.ID_PROJECT_SAVE_AS: - self.SaveAsProject() + self.SaveAsProject() elif id == const.ID_PROJECT_CLOSE: self.CloseProject() #elif id == const.ID_EXIT: @@ -269,15 +269,15 @@ class Frame(wx.Frame): def Exit(self): print "Exit" ps.Publisher().sendMessage('Close Project') - + def ShowTask(self, pubsub_evt): self.aui_manager.GetPane("Tasks").Show() self.aui_manager.Update() - + def HideTask(self, pubsub_evt): self.aui_manager.GetPane("Tasks").Hide() self.aui_manager.Update() - + #def OnClose(self): # # TODO: implement this, based on wx.Demo @@ -436,8 +436,12 @@ class StatusBar(wx.StatusBar): if (int(value) >= 99): self.SetStatusText("",0) if sys.platform == 'win32': - wx.SafeYield() - + try: + wx.SafeYield() + #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" def UpdateStatusLabel(self, pubsub_evt): label = pubsub_evt.data @@ -476,7 +480,7 @@ class ProjectToolBar(wx.ToolBar): self.__init_items() self.__bind_events() - + #FIXME: self.save_as = True @@ -559,16 +563,16 @@ class ProjectToolBar(wx.ToolBar): filename = (prj.name).replace(' ','_') if prj.save_as: filename = dlg.ShowSaveAsProjectDialog(filename) - if filename: + if filename: prj.save_as = False else: return ps.Publisher().sendMessage('Save Project',filename) event.Skip() - - - + + + # ------------------------------------------------------------------ class ObjectToolBar(wx.ToolBar): @@ -577,7 +581,7 @@ class ObjectToolBar(wx.ToolBar): wx.DefaultSize, wx.TB_FLAT|wx.TB_NODIVIDER | wx.TB_DOCKABLE) - self.SetToolBitmapSize(wx.Size(32,32)) + self.SetToolBitmapSize(wx.Size(32,32)) self.parent = parent self.__init_items() @@ -603,7 +607,7 @@ class ObjectToolBar(wx.ToolBar): "tool_contrast_original.png"), wx.BITMAP_TYPE_PNG) else: - + BMP_ROTATE = wx.Bitmap(os.path.join(const.ICON_DIR, "tool_rotate.gif"), wx.BITMAP_TYPE_GIF) @@ -665,7 +669,7 @@ class ObjectToolBar(wx.ToolBar): self.ToggleTool(item, False) evt.Skip() - + def UntoggleAllItems(self, pubsub_evt=None): for id in const.TOOL_STATES: @@ -783,25 +787,25 @@ class LayoutToolBar(wx.ToolBar): self.AddLabelTool(ID_LAYOUT, "",bitmap=self.BMP_WITHOUT_MENU, shortHelp= "Hide task panel") self.AddCheckTool(ID_TEXT, bitmap=BMP_TEXT, shortHelp= "Hide texts") - + self.Realize() def __bind_events_wx(self): self.Bind(wx.EVT_TOOL, self.OnClick) - + def OnClick(self, event): id = event.GetId() if id == ID_LAYOUT: self.OnTask() elif id== ID_TEXT: self.OnText(event) - + for item in VIEW_TOOLS: state = self.GetToolState(item) if state and (item != id): self.ToggleTool(item, False) - + def OnTask(self): if self.ontool: -- libgit2 0.21.2