diff --git a/invesalius/gui/task_importer.py b/invesalius/gui/task_importer.py index e3b6f43..be9daa0 100644 --- a/invesalius/gui/task_importer.py +++ b/invesalius/gui/task_importer.py @@ -34,19 +34,19 @@ WILDCARD_OPEN = "InVesalius 1 project (*.promed)|*.promed|"\ class TaskPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) - + inner_panel = InnerTaskPanel(self) - + sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(inner_panel, 1, wx.EXPAND | wx.GROW | wx.BOTTOM | wx.RIGHT | wx.LEFT, 7) sizer.Fit(self) - + self.SetSizer(sizer) self.Update() self.SetAutoLayout(1) - -class InnerTaskPanel(wx.Panel): + +class InnerTaskPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) self.SetBackgroundColour(wx.Colour(255,255,255)) @@ -54,7 +54,7 @@ class InnerTaskPanel(wx.Panel): # Counter for projects loaded in current GUI self.proj_count = 0 - + # Floating items (to be inserted) self.float_hyper_list = [] @@ -85,20 +85,20 @@ class InnerTaskPanel(wx.Panel): link_open_proj.AutoBrowse(False) link_open_proj.UpdateLink() link_open_proj.Bind(hl.EVT_HYPERLINK_LEFT, self.OnLinkOpenProject) - + # Image(s) for buttons BMP_IMPORT = wx.Bitmap("../icons/file_import.png", wx.BITMAP_TYPE_PNG) BMP_NET = wx.Bitmap("../icons/file_from_internet.png", wx.BITMAP_TYPE_PNG) BMP_NULL = wx.Bitmap("../icons/object_invisible.jpg", wx.BITMAP_TYPE_JPEG) - + bmp_list = [BMP_IMPORT, BMP_NET, BMP_NULL] for bmp in bmp_list: bmp.SetWidth(25) bmp.SetHeight(25) - + # Buttons related to hyperlinks - button_style = pbtn.PB_STYLE_SQUARE | pbtn.PB_STYLE_NOBG - + button_style = pbtn.PB_STYLE_SQUARE | pbtn.PB_STYLE_DEFAULT + button_import_local = pbtn.PlateButton(self, BTN_IMPORT_LOCAL, "", BMP_IMPORT, style=button_style) button_import_pacs = pbtn.PlateButton(self, BTN_IMPORT_PACS, "", BMP_NET, @@ -121,21 +121,21 @@ class InnerTaskPanel(wx.Panel): (button_import_pacs, 0, flag_button), (link_open_proj, 1, flag_link, 3), (button_open_proj, 0, flag_button) ]) - + # Add line sizers into main sizer main_sizer = wx.BoxSizer(wx.VERTICAL) main_sizer.Add(fixed_sizer, 0, wx.GROW|wx.EXPAND) - - # Update main sizer and panel layout + + # Update main sizer and panel layout self.SetSizer(main_sizer) self.Fit() self.sizer = main_sizer - + # Test load and unload specific projects' links self.TestLoadProjects() #self.UnloadProjects() - + def OnLinkImport(self, evt=None): dlg = wx.DirDialog(self, "Choose a directory:", "", style=wx.DD_DEFAULT_STYLE @@ -145,29 +145,29 @@ class InnerTaskPanel(wx.Panel): if dlg.ShowModal() == wx.ID_OK: path = dlg.GetPath() ps.Publisher().sendMessage("Show import panel", path) - + # Only destroy a dialog after you're done with it. dlg.Destroy() - + if evt: evt.Skip() - + def OnLinkImportPACS(self, evt=None): print "TODO: Send Signal - Import DICOM files from PACS" if evt: evt.Skip() - + def OnLinkOpenProject(self, evt=None, proj_name=""): if proj_name: print "TODO: Send Signal - Open project "+ proj_name else: dlg = wx.FileDialog(self, message="Open project...", - defaultDir=os.getcwd(), + defaultDir=os.getcwd(), defaultFile="", wildcard=WILDCARD_OPEN, style=wx.OPEN|wx.CHANGE_DIR) dlg.SetFilterIndex(3) - - # Show the dialog and retrieve the user response. If it is the OK response, + + # Show the dialog and retrieve the user response. If it is the OK response, # process the data. if dlg.ShowModal() == wx.ID_OK: # This returns a Python list of files that were selected. @@ -175,29 +175,29 @@ class InnerTaskPanel(wx.Panel): proj_name = dlg.GetFilename() print "TODO: Send Signal - Open project "+ proj_path print "TODO: Send Signal - Change frame title "+ proj_name - + # Destroy the dialog. Don't do this until you are done with it! # BAD things can happen otherwise! dlg.Destroy() - + if evt: evt.Skip() - + def OnButton(self, evt): id = evt.GetId() - + if id == BTN_IMPORT_LOCAL: self.OnLinkImport() elif id == BTN_IMPORT_PACS: self.OnLinkImportPACS() else: #elif id == BTN_OPEN_PROJECT: self.OnLinkOpenProject() - + def TestLoadProjects(self): self.LoadProject("test1.iv3") self.LoadProject("test2.iv3") self.LoadProject("test3.iv3") - + def LoadProject(self, proj_name="Unnamed"): """ Load into user interface name of project into import task panel. @@ -206,13 +206,13 @@ class InnerTaskPanel(wx.Panel): """ # TODO: What todo when it is called more than 3 times? # TODO: Load from config file last 3 recent projects - + if (self.proj_count < 3): self.proj_count += 1 - + # Create name to be plot on GUI label = " "+str(self.proj_count)+". "+proj_name - + # Create corresponding hyperlink proj_link = hl.HyperLinkCtrl(self, -1, label) proj_link.SetUnderlines(False, False, False) @@ -221,34 +221,33 @@ class InnerTaskPanel(wx.Panel): proj_link.UpdateLink() proj_link.Bind(hl.EVT_HYPERLINK_LEFT, lambda e: self.OnLinkOpenProject(e, proj_name)) - + # Add to existing frame self.sizer.Add(proj_link, 1, wx.GROW | wx.EXPAND | wx.ALL, 2) self.Update() # Add hyperlink to floating hyperlinks list - self.float_hyper_list.append(proj_link) - + self.float_hyper_list.append(proj_link) + def UnloadProjects(self): """ Unload all projects from interface into import task panel. This will be called when the current project is closed. """ - + # Remove each project from sizer for i in xrange(0, self.proj_count): self.sizer.Remove(self.float_hyper_list[i]) - + # Delete hyperlinks for hyper in self.float_hyper_list: hyper.Destroy() del(hyper) - + # Update GUI self.sizer.Layout() self.Update() - + # Now we set projects loaded to 0 self.proj_count = 0 self.float_hyper_list = [] - \ No newline at end of file diff --git a/invesalius/gui/task_slice.py b/invesalius/gui/task_slice.py index c4c64d7..7d72285 100644 --- a/invesalius/gui/task_slice.py +++ b/invesalius/gui/task_slice.py @@ -44,20 +44,20 @@ MASK_LIST = [] class TaskPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) - + inner_panel = InnerTaskPanel(self) sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(inner_panel, 1, wx.EXPAND | wx.GROW | wx.BOTTOM | wx.RIGHT | wx.LEFT, 7) sizer.Fit(self) - - + + self.SetSizer(sizer) self.Update() self.SetAutoLayout(1) -class InnerTaskPanel(wx.Panel): +class InnerTaskPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) default_colour = self.GetBackgroundColour() @@ -68,10 +68,10 @@ class InnerTaskPanel(wx.Panel): BMP_ADD = wx.Bitmap("../icons/object_add.png", wx.BITMAP_TYPE_PNG) BMP_ADD.SetWidth(25) BMP_ADD.SetHeight(25) - + # Button for creating new surface button_new_mask = pbtn.PlateButton(self, BTN_NEW, "", BMP_ADD, style=\ - pbtn.PB_STYLE_SQUARE | pbtn.PB_STYLE_NOBG) + pbtn.PB_STYLE_SQUARE | pbtn.PB_STYLE_DEFAULT) self.Bind(wx.EVT_BUTTON, self.OnButton) @@ -100,7 +100,7 @@ class InnerTaskPanel(wx.Panel): button_next = wx.Button(self, -1, "Create 3D surface") button_next.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) button_next.Bind(wx.EVT_BUTTON, self.OnButtonNextTask) - + # Add line sizers into main sizer main_sizer = wx.BoxSizer(wx.VERTICAL) main_sizer.Add(line_new, 0,wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5) @@ -108,66 +108,66 @@ class InnerTaskPanel(wx.Panel): main_sizer.Add(button_next, 0, wx.ALIGN_RIGHT|wx.RIGHT|wx.LEFT|wx.BOTTOM, 5) main_sizer.Fit(self) - + self.SetSizer(main_sizer) self.Update() self.SetAutoLayout(1) self.sizer = main_sizer - + def OnButton(self, evt): id = evt.GetId() if id == BTN_NEW: self.OnLinkNewMask() - + def OnButtonNextTask(self, evt): - ps.Publisher().sendMessage('Create surface from index', + ps.Publisher().sendMessage('Create surface from index', self.GetMaskSelected()) - + def OnLinkNewMask(self, evt=None): dlg = wx.TextEntryDialog(self, 'Name of new mask:', 'InVesalius 3.0 - New mask') dlg.CenterOnScreen() default_mask_name = const.MASK_NAME_PATTERN %(mask.Mask.general_index+2) dlg.SetValue(default_mask_name) - + if dlg.ShowModal() == wx.ID_OK: print "TODO: Send Signal - New mask" mask_name = dlg.GetValue() ps.Publisher().sendMessage('Create new mask', mask_name) if evt: evt.Skip() - + def GetMaskSelected(self): return self.fold_panel.GetMaskSelected() - + class FoldPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent, size=(50,50)) self.SetBackgroundColour(wx.Colour(0,255,0)) - + inner_panel = InnerFoldPanel(self) - - sizer = wx.BoxSizer(wx.VERTICAL) + + sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(inner_panel, 1, wx.EXPAND|wx.GROW, 2) sizer.Fit(self) - + self.SetSizer(sizer) self.Update() self.SetAutoLayout(1) - + self.inner_panel = inner_panel - + def GetMaskSelected(self): x = self.inner_panel.GetMaskSelected() return self.inner_panel.GetMaskSelected() - + class InnerFoldPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) self.SetBackgroundColour(wx.Colour(221, 221, 221, 255)) #self.SetBackgroundColour(wx.Colour(0,0,0)) - + # Fold panel and its style settings # FIXME: If we dont insert a value in size or if we set wx.DefaultSize, # the fold_panel doesnt show. This means that, for some reason, Sizer @@ -189,7 +189,7 @@ class InnerFoldPanel(wx.Panel): fold_panel.AddFoldPanelWindow(item, self.mask_prop_panel, Spacing= 0, leftSpacing=0, rightSpacing=0) fold_panel.Expand(fold_panel.GetFoldPanel(0)) - + # Fold 2 - Advanced edition tools item = fold_panel.AddFoldPanel("Advanced edition tools", collapsed=True) fold_panel.ApplyCaptionStyle(item, style) @@ -200,11 +200,11 @@ class InnerFoldPanel(wx.Panel): # Panel sizer to expand fold panel sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(fold_panel, 1, wx.GROW|wx.EXPAND) - sizer.Fit(self) + sizer.Fit(self) self.SetSizer(sizer) self.Update() self.SetAutoLayout(1) - + def GetMaskSelected(self): x= self.mask_prop_panel.GetMaskSelected() return self.mask_prop_panel.GetMaskSelected() @@ -213,7 +213,7 @@ class MaskProperties(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent, size=(50,240)) self.SetBackgroundColour(wx.Colour(221, 221, 221, 255)) - + ## LINE 1 # Combo related to mask naem @@ -222,16 +222,16 @@ class MaskProperties(wx.Panel): combo_mask_name.SetSelection(0) # wx.CB_SORT combo_mask_name.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) self.combo_mask_name = combo_mask_name - + # Mask colour button_colour= csel.ColourSelect(self, 111,colour=(0,255,0),size=(-1,22)) self.button_colour = button_colour - + # Sizer which represents the first line line1 = wx.BoxSizer(wx.HORIZONTAL) line1.Add(combo_mask_name, 1, wx.EXPAND|wx.GROW|wx.TOP|wx.RIGHT, 2) - line1.Add(button_colour, 0, wx.TOP|wx.LEFT|wx.RIGHT, 2) - + line1.Add(button_colour, 0, wx.TOP|wx.LEFT|wx.RIGHT, 2) + ## LINE 2 text_thresh = wx.StaticText(self, -1, "Set predefined or manual threshold:") @@ -245,10 +245,10 @@ class MaskProperties(wx.Panel): self.combo_thresh = combo_thresh ## LINE 4 - gradient = grad.GradientSlider(self, -1, -5000, 5000, 0, 5000, + gradient = grad.GradientSlider(self, -1, -5000, 5000, 0, 5000, (0, 255, 0, 100)) self.gradient = gradient - + # Add all lines into main sizer sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(line1, 1, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5) @@ -256,13 +256,13 @@ class MaskProperties(wx.Panel): sizer.Add(combo_thresh, 1, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT, 5) sizer.Add(gradient, 1, wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT|wx.BOTTOM, 6) sizer.Fit(self) - + self.SetSizer(sizer) self.Update() self.SetAutoLayout(1) - + # Non GUI stuff - + proj = Project() self.threshold_modes = proj.threshold_modes self.bind_evt_gradient = True @@ -280,7 +280,7 @@ class MaskProperties(wx.Panel): 'Set threshold values in gradient') ps.Publisher().subscribe(self.SelectMaskName, 'Select mask name in combo') ps.Publisher().subscribe(self.ChangeMaskName, 'Change mask name') - + def __bind_events_wx(self): self.Bind(grad.EVT_THRESHOLD_CHANGE, self.OnSlideChanged, self.gradient) self.combo_thresh.Bind(wx.EVT_COMBOBOX, self.OnComboThresh) @@ -290,7 +290,7 @@ class MaskProperties(wx.Panel): def SelectMaskName(self, pubsub_evt): index = pubsub_evt.data self.combo_mask_name.SetSelection(index) - + def ChangeMaskName(self, pubsub_evt): index, name = pubsub_evt.data self.combo_mask_name.SetString(index, name) @@ -302,7 +302,7 @@ class MaskProperties(wx.Panel): self.gradient.SetMinValue(thresh_min) self.gradient.SetMaxValue(thresh_max) self.bind_evt_gradient = True - + def SetItemsColour(self, evt_pubsub): colour = evt_pubsub.data self.gradient.SetColour(colour) @@ -329,7 +329,7 @@ class MaskProperties(wx.Panel): (thresh_min, thresh_max) = self.threshold_modes[thresh_modes_names[default_thresh]] self.gradient.SetMinValue(thresh_min) self.gradient.SetMaxValue(thresh_max) - + def SetThresholdBounds(self, pubsub_evt): thresh_min = pubsub_evt.data[0] thresh_max = pubsub_evt.data[1] @@ -362,13 +362,13 @@ class EditionTools(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent, size=(50,240)) self.SetBackgroundColour(wx.Colour(221, 221, 221, 255)) - + ## LINE 1 text1 = wx.StaticText(self, -1, "Choose brush type, size or operation:") - + ## LINE 2 menu = wx.Menu() - + CIRCLE_BMP = wx.Bitmap("../icons/brush_circle.jpg", wx.BITMAP_TYPE_JPEG) item = wx.MenuItem(menu, MENU_BRUSH_CIRCLE, "Circle") item.SetBitmap(CIRCLE_BMP) @@ -378,12 +378,12 @@ class EditionTools(wx.Panel): item2.SetBitmap(SQUARE_BMP) menu.AppendItem(item) - menu.AppendItem(item2) - + menu.AppendItem(item2) + bmp_brush_format = {const.BRUSH_CIRCLE: CIRCLE_BMP, const.BRUSH_SQUARE: SQUARE_BMP} selected_bmp = bmp_brush_format[const.DEFAULT_BRUSH_FORMAT] - + btn_brush_format = pbtn.PlateButton(self, wx.ID_ANY,"", selected_bmp, style=pbtn.PB_STYLE_SQUARE) btn_brush_format.SetMenu(menu) @@ -412,7 +412,7 @@ class EditionTools(wx.Panel): text_thresh = wx.StaticText(self, -1, "Brush threshold range:") ## LINE 4 - gradient_thresh = grad.GradientSlider(self, -1, 0, 5000, 0, 5000, + gradient_thresh = grad.GradientSlider(self, -1, 0, 5000, 0, 5000, (0, 0, 255, 100)) self.gradient_thresh = gradient_thresh self.bind_evt_gradient = True @@ -425,12 +425,12 @@ class EditionTools(wx.Panel): sizer.Add(gradient_thresh, 0, wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT| wx.BOTTOM, 6) sizer.Fit(self) - + self.SetSizer(sizer) self.Update() self.SetAutoLayout(1) - self.__bind_events() + self.__bind_events() self.__bind_events_wx() @@ -439,7 +439,7 @@ class EditionTools(wx.Panel): self.Bind(grad.EVT_THRESHOLD_CHANGE, self.OnGradientChanged, self.gradient_thresh) self.combo_brush_op.Bind(wx.EVT_COMBOBOX, self.OnComboBrushOp) - + def __bind_events(self): ps.Publisher().subscribe(self.SetThresholdBounds, 'Update threshold limits') @@ -449,19 +449,19 @@ class EditionTools(wx.Panel): def ChangeMaskColour(self, pubsub_evt): colour = pubsub_evt.data self.gradient_thresh.SetColour(colour) - + def SetGradientColour(self, pubsub_evt): vtk_colour = pubsub_evt.data[3] wx_colour = [c*255 for c in vtk_colour] self.gradient_thresh.SetColour(wx_colour) - + def SetThresholdValues(self, pubsub_evt): thresh_min, thresh_max = pubsub_evt.data self.bind_evt_gradient = False self.gradient_thresh.SetMinValue(thresh_min) self.gradient_thresh.SetMaxValue(thresh_max) self.bind_evt_gradient = True - + def SetThresholdBounds(self, pubsub_evt): thresh_min = pubsub_evt.data[0] thresh_max = pubsub_evt.data[1] @@ -469,14 +469,14 @@ class EditionTools(wx.Panel): self.gradient_thresh.SetMaxRange(thresh_max) self.gradient_thresh.SetMinValue(thresh_min) self.gradient_thresh.SetMaxValue(thresh_max) - + def OnGradientChanged(self, evt): thresh_min = self.gradient_thresh.GetMinValue() thresh_max = self.gradient_thresh.GetMaxValue() if self.bind_evt_gradient: ps.Publisher().sendMessage('Set edition threshold values', (thresh_min, thresh_max)) - + def OnMenu(self, evt): SQUARE_BMP = wx.Bitmap("../icons/brush_square.jpg", wx.BITMAP_TYPE_JPEG) CIRCLE_BMP = wx.Bitmap("../icons/brush_circle.jpg", wx.BITMAP_TYPE_JPEG) @@ -487,7 +487,7 @@ class EditionTools(wx.Panel): MENU_BRUSH_SQUARE: SQUARE_BMP} self.btn_brush_format.SetBitmap(bitmap[evt.GetId()]) - + ps.Publisher().sendMessage('Set brush format', brush[evt.GetId()]) def OnBrushSize(self, evt): @@ -496,9 +496,9 @@ class EditionTools(wx.Panel): # in the text ctrl - so we are capturing only changes on text # Strangelly this is being called twice ps.Publisher().sendMessage('Set edition brush size',self.spin.GetValue()) - + def OnComboBrushOp(self, evt): brush_op_id = evt.GetSelection() ps.Publisher().sendMessage('Set edition operation', brush_op_id) - + diff --git a/invesalius/gui/task_surface.py b/invesalius/gui/task_surface.py index 46619a1..b265489 100644 --- a/invesalius/gui/task_surface.py +++ b/invesalius/gui/task_surface.py @@ -42,14 +42,14 @@ OP_LIST = ["Draw", "Erase", "Threshold"] class TaskPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) - + inner_panel = InnerTaskPanel(self) sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(inner_panel, 1, wx.EXPAND | wx.GROW | wx.BOTTOM | wx.RIGHT | wx.LEFT, 7) sizer.Fit(self) - + self.SetSizer(sizer) self.Update() self.SetAutoLayout(1) @@ -60,7 +60,7 @@ class TaskPanel(wx.Panel): # Contour - slider # enable / disable Fill holes -class InnerTaskPanel(wx.Panel): +class InnerTaskPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) default_colour = self.GetBackgroundColour() @@ -71,10 +71,10 @@ class InnerTaskPanel(wx.Panel): BMP_ADD = wx.Bitmap("../icons/object_add.png", wx.BITMAP_TYPE_PNG) BMP_ADD.SetWidth(25) BMP_ADD.SetHeight(25) - + # Button for creating new surface button_new_surface = pbtn.PlateButton(self, BTN_NEW, "", BMP_ADD, style=\ - pbtn.PB_STYLE_SQUARE | pbtn.PB_STYLE_NOBG) + pbtn.PB_STYLE_SQUARE | pbtn.PB_STYLE_DEFAULT) self.Bind(wx.EVT_BUTTON, self.OnButton) # Fixed hyperlink items @@ -100,20 +100,20 @@ class InnerTaskPanel(wx.Panel): button_next = wx.Button(self, -1, "Next step") button_next.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) #button_next.Bind(wx.EVT_BUTTON, self.OnButtonNextTask) - + # Add line sizers into main sizer main_sizer = wx.BoxSizer(wx.VERTICAL) main_sizer.Add(line_new, 0,wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5) main_sizer.Add(fold_panel, 1, wx.GROW|wx.EXPAND|wx.ALL, 5) main_sizer.Add(button_next, 0, wx.ALIGN_RIGHT|wx.RIGHT|wx.BOTTOM, 5) main_sizer.Fit(self) - + self.SetSizer(main_sizer) self.Update() self.SetAutoLayout(1) self.sizer = main_sizer - + def OnButton(self, evt): id = evt.GetId() if id == BTN_NEW: @@ -123,7 +123,7 @@ class InnerTaskPanel(wx.Panel): self.OnLinkNewSurface() if evt: evt.Skip() - + def OnLinkNewSurface(self, evt=None): dlg = NewSurfaceDialog(self, -1, 'InVesalius 3.0 - New surface') if dlg.ShowModal() == wx.ID_OK: @@ -131,10 +131,10 @@ class InnerTaskPanel(wx.Panel): dlg.Destroy() if evt: evt.Skip() - + class NewSurfaceDialog(wx.Dialog): def __init__(self, parent, ID, title, size=wx.DefaultSize, - pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE, + pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE, useMetal=False): # Instead of calling wx.Dialog.__init__ we precreate the dialog @@ -158,7 +158,7 @@ class NewSurfaceDialog(wx.Dialog): # Now continue with the normal construction of the dialog # contents - + # Label related to mask name label_mask = wx.StaticText(self, -1, "Select mask to be used for creating 3D surface:") @@ -176,7 +176,7 @@ class NewSurfaceDialog(wx.Dialog): text.SetHelpText("Name the new surface to be created") text.SetValue("Default 3D") self.text = text - + sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(label_mask, 0, wx.ALL|wx.GROW|wx.EXPAND, 5) sizer.Add(combo_surface_name, 1, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT, 10) @@ -184,11 +184,11 @@ class NewSurfaceDialog(wx.Dialog): sizer.Add(text, 0, wx.GROW|wx.EXPAND|wx.RIGHT|wx.LEFT, 10) btnsizer = wx.StdDialogButtonSizer() - + #if wx.Platform != "__WXMSW__": # btn = wx.ContextHelpButton(self) # btnsizer.AddButton(btn) - + btn = wx.Button(self, wx.ID_OK) btn.SetDefault() btnsizer.AddButton(btn) @@ -204,28 +204,28 @@ class NewSurfaceDialog(wx.Dialog): def GetValue(self): return self.text.GetValue() +"| mask: "+ MASK_LIST[self.combo_surface_name.GetSelection()] - + class FoldPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent, size=(50,50)) self.SetBackgroundColour(wx.Colour(0,255,0)) - + inner_panel = InnerFoldPanel(self) - - sizer = wx.BoxSizer(wx.VERTICAL) + + sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(inner_panel, 1, wx.EXPAND|wx.GROW, 2) sizer.Fit(self) - + self.SetSizer(sizer) self.Update() self.SetAutoLayout(1) - + class InnerFoldPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) self.SetBackgroundColour(wx.Colour(221, 221, 221, 255)) #self.SetBackgroundColour(wx.Colour(0,0,0)) - + # Fold panel and its style settings # FIXME: If we dont insert a value in size or if we set wx.DefaultSize, # the fold_panel doesnt show. This means that, for some reason, Sizer @@ -246,7 +246,7 @@ class InnerFoldPanel(wx.Panel): fold_panel.AddFoldPanelWindow(item, SurfaceProperties(item), Spacing= 0, leftSpacing=0, rightSpacing=0) fold_panel.Expand(fold_panel.GetFoldPanel(0)) - + # Fold 2 - Surface quality item = fold_panel.AddFoldPanel("Surface quality", collapsed=True) fold_panel.ApplyCaptionStyle(item, style) @@ -258,7 +258,7 @@ class InnerFoldPanel(wx.Panel): sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(fold_panel, 1, wx.GROW|wx.EXPAND) sizer.Fit(self) - + self.SetSizer(sizer) self.Update() self.SetAutoLayout(1) @@ -267,9 +267,9 @@ class SurfaceProperties(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent, size=(50,240)) self.SetBackgroundColour(wx.Colour(221, 221, 221, 255)) - + ## LINE 1 - + # Combo related to mask naem combo_surface_name = wx.ComboBox(self, -1, "", choices= SURFACE_LIST, style=wx.CB_DROPDOWN|wx.CB_READONLY) @@ -277,56 +277,56 @@ class SurfaceProperties(wx.Panel): combo_surface_name.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) combo_surface_name.Bind(wx.EVT_COMBOBOX, self.OnComboName) self.combo_surface_name = combo_surface_name - + # Mask colour button_colour= csel.ColourSelect(self, -1,colour=(0,0,255),size=(-1,22)) button_colour.Bind(csel.EVT_COLOURSELECT, self.OnSelectColour) self.button_colour = button_colour - + # Sizer which represents the first line line1 = wx.BoxSizer(wx.HORIZONTAL) line1.Add(combo_surface_name, 1, wx.EXPAND|wx.GROW|wx.TOP|wx.RIGHT, 2) - line1.Add(button_colour, 0, wx.TOP|wx.LEFT|wx.RIGHT, 2) - - + line1.Add(button_colour, 0, wx.TOP|wx.LEFT|wx.RIGHT, 2) + + ## LINE 2 - + text_transparency = wx.StaticText(self, -1, "Transparency:") - + slider_transparency = wx.Slider(self, -1, 0, MIN_TRANSPARENCY, - MAX_TRANSPARENCY, + MAX_TRANSPARENCY, style=wx.SL_HORIZONTAL)#|wx.SL_AUTOTICKS) slider_transparency.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) slider_transparency.Bind(wx.EVT_SLIDER, self.OnTransparency) self.slider_transparency = slider_transparency - - + + ## MIX LINE 2 AND 3 flag_link = wx.EXPAND|wx.GROW|wx.RIGHT flag_slider = wx.EXPAND | wx.GROW| wx.LEFT|wx.TOP flag_combo = wx.EXPAND | wx.GROW| wx.LEFT - + fixed_sizer = wx.FlexGridSizer(rows=2, cols=2, hgap=2, vgap=4) fixed_sizer.AddMany([ (text_transparency, 0, flag_link, 0), (slider_transparency, 1, flag_slider,4)]) - + # LINE 4 #cb = wx.CheckBox(self, -1, "Fill largest surface holes") #cb.SetValue(True) - + # Add all lines into main sizer sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(line1, 1, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5) sizer.Add(fixed_sizer, 0, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5) #sizer.Add(cb, 0, wx.GROW|wx.EXPAND|wx.RIGHT|wx.LEFT|wx.TOP|wx.BOTTOM, 5) sizer.Fit(self) - + self.SetSizer(sizer) self.Update() self.SetAutoLayout(1) - + self.__bind_events() - + def __bind_events(self): ps.Publisher().subscribe(self.InsertNewSurface, 'Update surface info in GUI') @@ -344,10 +344,10 @@ class SurfaceProperties(wx.Panel): colour = [value*255 for value in pubsub_evt.data[2]] transparency = 100*pubsub_evt.data[4] index = self.combo_surface_name.Append(name) - self.combo_surface_name.SetSelection(index) + self.combo_surface_name.SetSelection(index) self.button_colour.SetColour(colour) self.slider_transparency.SetValue(transparency) - + def OnComboName(self, evt): print "TODO: Send Signal - Change 3D surface selected: %s" % (evt.GetString()) @@ -373,19 +373,19 @@ class QualityAdjustment(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent, size=(50,240)) self.SetBackgroundColour(wx.Colour(221, 221, 221, 255)) - + # LINE 1 combo_quality = wx.ComboBox(self, -1, "", choices= QUALITY_LIST, style=wx.CB_DROPDOWN|wx.CB_READONLY) combo_quality.SetSelection(3) combo_quality.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) - #combo_quality.Bind(wx.EVT_COMBOBOX, self.OnComboQuality) - + #combo_quality.Bind(wx.EVT_COMBOBOX, self.OnComboQuality) + # LINE 2 check_decimate = wx.CheckBox(self, -1, "") - + text_decimate = wx.StaticText(self, -1, "Decimate resolution:") - + spin_decimate = wx.SpinCtrl(self, -1, "", (30, 50)) spin_decimate.SetRange(1,100) spin_decimate.SetValue(30) @@ -393,18 +393,18 @@ class QualityAdjustment(wx.Panel): # LINE 3 check_smooth = wx.CheckBox(self, -1, "") - + text_smooth = wx.StaticText(self, -1, "Smooth iterations:") - + spin_smooth = wx.SpinCtrl(self, -1, "", (30, 50)) spin_smooth.SetRange(1,100) spin_smooth.SetValue(0) - + # MIXED LINE 2 AND 3 flag_link = wx.EXPAND|wx.GROW|wx.RIGHT|wx.LEFT flag_slider = wx.EXPAND | wx.GROW| wx.LEFT|wx.TOP flag_combo = wx.EXPAND | wx.GROW| wx.LEFT - + fixed_sizer = wx.FlexGridSizer(rows=2, cols=3, hgap=2, vgap=0) fixed_sizer.AddMany([ (check_decimate, 0, flag_combo, 2), (text_decimate, 0, flag_slider, 7), @@ -413,19 +413,18 @@ class QualityAdjustment(wx.Panel): (text_smooth, 0, flag_slider, 7), (spin_smooth, 1, flag_link, 14)]) fixed_sizer.AddGrowableCol(2) - + sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(combo_quality, 1, wx.EXPAND|wx.GROW|wx.LEFT|wx.RIGHT|wx.TOP, 5) sizer.Add(fixed_sizer, 0, wx.LEFT|wx.RIGHT, 5) sizer.Fit(self) - + self.SetSizer(sizer) self.Update() self.SetAutoLayout(1) - + def OnComboQuality(self, evt): print "TODO: Send Signal - Change surface quality: %s" % (evt.GetString()) - + def OnDecimate(self, evt): print "TODO: Send Signal - Decimate: %s" % float(self.spin.GetValue())/100 - \ No newline at end of file diff --git a/invesalius/gui/task_tools.py b/invesalius/gui/task_tools.py index ab577eb..353496b 100644 --- a/invesalius/gui/task_tools.py +++ b/invesalius/gui/task_tools.py @@ -29,19 +29,19 @@ ID_BTN_ANNOTATION = wx.NewId() class TaskPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) - + inner_panel = InnerTaskPanel(self) - + sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(inner_panel, 1, wx.EXPAND | wx.GROW | wx.BOTTOM | wx.RIGHT | wx.LEFT, 7) sizer.Fit(self) - + self.SetSizer(sizer) self.Update() self.SetAutoLayout(1) - -class InnerTaskPanel(wx.Panel): + +class InnerTaskPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) self.SetBackgroundColour(wx.Colour(255,255,255)) @@ -49,7 +49,7 @@ class InnerTaskPanel(wx.Panel): # Counter for projects loaded in current GUI self.proj_count = 0 - + # Floating items (to be inserted) self.float_hyper_list = [] @@ -66,7 +66,7 @@ class InnerTaskPanel(wx.Panel): txt_annotation.AutoBrowse(False) txt_annotation.UpdateLink() txt_annotation.Bind(hl.EVT_HYPERLINK_LEFT, self.OnTextAnnotation) - + # Image(s) for buttons BMP_ANNOTATE = wx.Bitmap("../icons/annotation.png", wx.BITMAP_TYPE_PNG) BMP_ANGLE = wx.Bitmap("../icons/measure_angle.jpg", wx.BITMAP_TYPE_JPEG) @@ -77,16 +77,16 @@ class InnerTaskPanel(wx.Panel): BMP_ANGLE.SetHeight(25) BMP_DISTANCE.SetWidth(25) BMP_DISTANCE.SetHeight(25) - + # Buttons related to hyperlinks - button_style = pbtn.PB_STYLE_SQUARE | pbtn.PB_STYLE_NOBG - + button_style = pbtn.PB_STYLE_SQUARE | pbtn.PB_STYLE_DEFAULT + button_measure_linear = pbtn.PlateButton(self, ID_BTN_MEASURE_LINEAR, "", BMP_DISTANCE, style=button_style) - button_measure_angular = pbtn.PlateButton(self, ID_BTN_MEASURE_ANGULAR, "", + button_measure_angular = pbtn.PlateButton(self, ID_BTN_MEASURE_ANGULAR, "", BMP_ANGLE, style=button_style) - button_annotation = pbtn.PlateButton(self, ID_BTN_ANNOTATION, "", + button_annotation = pbtn.PlateButton(self, ID_BTN_ANNOTATION, "", BMP_ANNOTATE, style=button_style) # When using PlaneButton, it is necessary to bind events from parent win @@ -103,35 +103,34 @@ class InnerTaskPanel(wx.Panel): sizer.Add(txt_annotation, pos=(1,0),flag=wx.GROW|wx.EXPAND) sizer.Add(button_annotation, pos=(1,2),span=(2,1), flag=wx.GROW|wx.EXPAND) sizer.AddGrowableCol(0) - + # Add line sizers into main sizer main_sizer = wx.BoxSizer(wx.VERTICAL) main_sizer.Add(sizer, 0, wx.GROW|wx.EXPAND) main_sizer.Fit(self) - - # Update main sizer and panel layout + + # Update main sizer and panel layout self.SetSizer(sizer) self.Fit() self.sizer = main_sizer def OnTextAnnotation(self, evt=None): print "TODO: Send Signal - Add text annotation (both 2d and 3d)" - + def OnLinkLinearMeasure(self): print "TODO: Send Signal - Add linear measure (both 2d and 3d)" def OnLinkAngularMeasure(self): print "TODO: Send Signal - Add angular measure (both 2d and 3d)" - + def OnButton(self, evt): id = evt.GetId() - + if id == ID_BTN_MEASURE_LINEAR: self.OnLinkLinearMeasure() elif id == ID_BTN_MEASURE_ANGULAR: self.OnLinkAngularMeasure() else: # elif id == ID_BTN_ANNOTATION: self.OnTextAnnotation() - - \ No newline at end of file + -- libgit2 0.21.2